'use strict';
import { createEslintRule } from '@flint/infra/create-eslint-rule';
import { isStringType } from '@flint/infra/analysis/string-analysis';
import { nodeTypes, getSpecifierName } from '@flint/infra/analysis';
import { folders, packagesPath } from '../../../base-repo/app-constants/project-paths.js';
import { fileSuffixes } from '../../../base-repo/constants/internal-extensions.js';
import { importKindNames } from '../../../base-repo/constants/internal-common-strings.js';

var __defProp=Object['defineProperty'],__name=(_0x49803f,_0x3b449a)=>__defProp(_0x49803f,'name',{'value':_0x3b449a,'configurable':!![]});const ruleName='must-use-resource-provider-functions-to-get-resources-on-server';const ruleContent='\x0a###\x20**Must**\x20use\x20resource-provider\x20functions\x20to\x20get\x20resources\x20on\x20server\x0a\x0aFunctions\x20from\x20db\x20can\x20be\x20used\x20only\x20in\x20resource\x20provider\x0a\x0a####\x20Wrong\x0a\x0aimport\x20{\x20getResourcesByName\x20}\x20from\x20\x22@server/fd/fd-toolbox/db/db\x22;\x0a\x0aconst\x20resources\x20=\x20getResourcesByName(\x22Foo\x22);\x0a\x0a####\x20Correct\x0a\x0aimport\x20{\x20getResources\x20}\x20from\x20\x22@meta/server/services/resource-provider\x22;\x0a\x0aconst\x20resources\x20=\x20getResources(\x22Foo\x22,\x20getUuid());\x0a\x0a####\x20Why\x0a\x0aHelps\x20with\x20standardizing\x20getting\x20resources\x20and\x20preventing\x20bugs.',forbiddenImportSources=['@server/fd/fd-toolbox/db/db','@meta/server/db/db'],lowLevelDbFunctions=new Set(['getResourcesByName','getResourcesWithOData','findResourceById']),exemptionPatterns=[''+packagesPath['packagesMeta']+folders['server']+'/','resource-provider',fileSuffixes['dotSpecDot'],folders['testInfra'],'seeding','migrations'];function isExemptFile(_0x236da5){if(!_0x236da5)return ![];return _0x236da5['endsWith']('-db.ts')||exemptionPatterns['some'](_0x5f3bd1=>_0x236da5['includes'](_0x5f3bd1));}__name(isExemptFile,'isExemptFile');var mustUseResourceProviderFunctionsToGetResourcesOnServer = createEslintRule(ruleName,ruleContent,_0x31e0d0=>{if(isExemptFile(_0x31e0d0['filename']))return {};return {'ImportDeclaration'(_0x507b7a){const _0x38e3fe=_0x507b7a['source']['value'],_0x38d1bd=!isStringType(_0x38e3fe)||_0x507b7a['importKind']===importKindNames['type']||!forbiddenImportSources['includes'](_0x38e3fe);if(_0x38d1bd)return;const _0x3662f1=(_0x507b7a['specifiers']||[])['filter'](_0x336d83=>_0x336d83['type']===nodeTypes['importSpecifier']);for(const _0x577929 of _0x3662f1){const _0x175e3a=getSpecifierName(_0x577929['imported']);_0x175e3a&&lowLevelDbFunctions['has'](_0x175e3a)&&_0x31e0d0['report']({'node':_0x577929,'messageId':ruleName});}}};});

export { mustUseResourceProviderFunctionsToGetResourcesOnServer as default, ruleName };
