arkos 1.4.0-canary.67 → 1.4.0-canary.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/utils/cli/utils/cli.helpers.js +1 -1
- package/dist/cjs/utils/dynamic-loader.js +1 -1
- package/dist/cjs/utils/dynamic-loader.js.map +1 -1
- package/dist/cjs/utils/helpers/dynamic-loader.helpers.js +7 -13
- package/dist/cjs/utils/helpers/dynamic-loader.helpers.js.map +1 -1
- package/dist/esm/utils/cli/utils/cli.helpers.js +1 -1
- package/dist/esm/utils/dynamic-loader.js +1 -1
- package/dist/esm/utils/dynamic-loader.js.map +1 -1
- package/dist/esm/utils/helpers/dynamic-loader.helpers.js +7 -13
- package/dist/esm/utils/helpers/dynamic-loader.helpers.js.map +1 -1
- package/dist/types/utils/helpers/dynamic-loader.helpers.d.ts +1 -1
- package/package.json +1 -1
|
@@ -227,7 +227,7 @@ function assignModuleToResult(appModule, key, module, result, arkosConfig) {
|
|
|
227
227
|
...module,
|
|
228
228
|
config: (0, dynamic_loader_helpers_1.applyStrictRoutingRules)(appModule, arkosConfig, module?.config || {}),
|
|
229
229
|
};
|
|
230
|
-
(0, dynamic_loader_helpers_1.validateRouterConfigConsistency)(result[key]?.config || {});
|
|
230
|
+
(0, dynamic_loader_helpers_1.validateRouterConfigConsistency)((0, change_case_helpers_1.kebabCase)(appModule), result[key]?.config || {});
|
|
231
231
|
}
|
|
232
232
|
else {
|
|
233
233
|
result[key] = module.default || module;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-loader.js","sourceRoot":"","sources":["../../../src/utils/dynamic-loader.ts"],"names":[],"mappings":";;;;;;AAwBA,kDAKC;AAED,kDAEC;AAaD,oFAyDC;AAED,0BAKC;AAED,kCAEC;AAED,sCAqDC;AAuGD,8DAWC;AAQD,oDA6CC;AASD,wDAoFC;AAaD,0DAwCC;AAleD,6BAAoC;AACpC,gDAAwB;AAExB,yDAA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ACJ,CAAC;IAEF,MAAM,iBAAiB,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;IAC7E,0BAAe,CAAC,iCAAiC,CAC/C,iBAAiB,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE;QACtC,MAAM,SAAS,GAAG,cAAI,CAAC,OAAO,CAC5B,IAAA,gBAAG,GAAE,EACL,KAAK,EACL,SAAS,EACT,IAAA,+BAAS,EAAC,kBAAU,CAAC,CAAC,CAAC,CAAC,CACzB,CAAC;QAEF,OAAO;YACL,UAAU,EAAE,IAAA,+BAAS,EAAC,kBAAU,CAAC,CAAC,CAAC,CAAC;YACpC,SAAS;YACT,UAAU;SACX,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { z, ZodTypeAny } from \"zod\";\nimport path from \"path\";\nimport { AuthConfigs } from \"../types/auth\";\nimport { killServerChildProcess } from \"./cli/utils/cli.helpers\";\nimport { ArkosConfig, RouterConfig } from \"../exports\";\nimport sheu from \"./sheu\";\nimport {\n applyStrictRoutingRules,\n pathExists,\n validateRouterConfigConsistency,\n} from \"./helpers/dynamic-loader.helpers\";\nimport { kebabCase, pascalCase } from \"./helpers/change-case.helpers\";\nimport { crd, getUserFileExtension } from \"./helpers/fs.helpers\";\nimport { importModule } from \"./helpers/global.helpers\";\nimport prismaSchemaParser from \"./prisma/prisma-schema-parser\";\nimport debuggerService from \"../modules/debugger/debugger.service\";\nimport { PrismaQueryOptions } from \"../types\";\nimport { ServiceHook } from \"../modules/base/utils/service-hooks-manager\";\n\ntype AppModuleComponent = Awaited<ReturnType<typeof importModuleComponents>>;\n\nlet prismaModelsModules: Record<string, AppModuleComponent> = {};\n\n/** This was a workaround when testing and also when cjs was generated while `prismaModelsModules` was exported there where some problems */\nexport function setModuleComponents(\n modelName: string,\n modules: AppModuleComponent\n) {\n prismaModelsModules[pascalCase(modelName)] = modules;\n}\n\nexport function getModuleComponents(modelName: string) {\n return prismaModelsModules[pascalCase(modelName)];\n}\n\n/**\n * To be reused on other part of code for correct typing\n *\n * @param key\n * @param fileName\n * @param result\n */\nexport type ValidationFileMappingKey = keyof ReturnType<\n typeof getFileModuleComponentsFileStructure\n>[\"dtos\"];\n\nexport function getFileModuleComponentsFileStructure(modelName: string) {\n const kebabModelName = kebabCase(modelName).toLowerCase();\n const isAuthModule = modelName.toLowerCase() === \"auth\";\n const ext = getUserFileExtension();\n\n return {\n core: {\n hooks: `${kebabModelName}.hooks.${ext}`,\n interceptors: `${kebabModelName}.interceptors.${ext}`,\n interceptorsOld: `${kebabModelName}.middlewares.${ext}`,\n authConfigs: `${kebabModelName}.auth.${ext}`,\n prismaQueryOptions: `${kebabModelName}.query.${ext}`,\n router: `${kebabModelName}.router.${ext}`,\n },\n dtos: isAuthModule\n ? {\n login: `login.dto.${ext}`,\n signup: `signup.dto.${ext}`,\n getMe: `get-me.dto.${ext}`,\n updateMe: `update-me.dto.${ext}`,\n updatePassword: `update-password.dto.${ext}`,\n }\n : {\n model: `${kebabModelName}.dto.${ext}`,\n create: `create-${kebabModelName}.dto.${ext}`,\n createOne: `create-${kebabModelName}.dto.${ext}`, // just for sake of completion and reusability around other parts of code\n createMany: ``,\n update: `update-${kebabModelName}.dto.${ext}`,\n updateOne: `update-${kebabModelName}.dto.${ext}`, // same as createOne\n updateMany: ``,\n query: `query-${kebabModelName}.dto.${ext}`,\n // looking for some better naming convetion\n findOne: ``,\n findMany: ``,\n },\n schemas: isAuthModule\n ? {\n login: `login.schema.${ext}`,\n signup: `signup.schema.${ext}`,\n getMe: `get-me.schema.${ext}`,\n updateMe: `update-me.schema.${ext}`,\n updatePassword: `update-password.schema.${ext}`,\n }\n : {\n model: `${kebabModelName}.schema.${ext}`,\n create: `create-${kebabModelName}.schema.${ext}`,\n createOne: `create-${kebabModelName}.schema.${ext}`,\n createMany: ``, // just for sake of completion and reusability around other parts of code\n update: `update-${kebabModelName}.schema.${ext}`,\n updateOne: `update-${kebabModelName}.schema.${ext}`, // same as createOne\n updateMany: ``,\n query: `query-${kebabModelName}.schema.${ext}`,\n // looking for some better naming convetion\n findOne: ``,\n findMany: ``,\n },\n };\n}\n\nexport function isClass(value: any): boolean {\n return (\n typeof value === \"function\" &&\n /^class\\s/.test(Function.prototype.toString.call(value))\n );\n}\n\nexport function isZodSchema(value: any): value is ZodTypeAny {\n return value instanceof z.ZodType;\n}\n\nexport async function processSubdir(\n modelName: string,\n type: \"dtos\" | \"schemas\"\n) {\n const moduleDir = path.resolve(crd(), \"src\", \"modules\", kebabCase(modelName));\n\n const subdir = path.join(moduleDir, type);\n const fileStructure = getFileModuleComponentsFileStructure(modelName);\n const result: Record<string, any> = {};\n\n if (!(await pathExists(subdir))) return result;\n\n try {\n await Promise.all(\n Object.entries(fileStructure[type]).map(async ([key, fileName]) => {\n const filePath = path.join(subdir, fileName);\n if (!fileName || !(await pathExists(filePath))) return;\n\n try {\n const module = await importModule(filePath).catch(\n async (err: any) => {\n if (await pathExists(filePath)) {\n sheu.error(`Failed to import ${fileName}: `);\n console.error(err);\n killServerChildProcess();\n process.exit(1);\n }\n }\n );\n\n const cleanFilePath = `src/modules/${kebabCase(modelName)}/${fileName}`;\n if (type === \"dtos\" && !isClass(module?.default))\n throw Error(\n `ValidationError: Please export as default a valid class under ${cleanFilePath}, in order to use as Dto.`\n );\n else if (type === \"schemas\" && !isZodSchema(module?.default))\n throw Error(\n `ValidationError: Please export as default a valid zod schema under ${cleanFilePath}, in order to use as Schema`\n );\n\n if (module && module?.default) result[key] = module.default;\n } catch (err: any) {\n if (err?.message?.includes(\"ValidationError\")) throw err;\n console.error(err);\n }\n })\n );\n } catch (err: any) {\n if (err?.message?.includes(\"ValidationError\")) throw err;\n console.error(err);\n }\n\n return result;\n}\n\nexport type ModuleComponents = Omit<\n ImportModuleComponentsReturnType,\n \"authConfigsNew\" | \"prismaQueryOptionsNew\"\n>;\n\ntype ImportModuleComponentsReturnType = {\n hooks?: Record<string, ServiceHook | ServiceHook[]>;\n interceptors?: Record<string, Function | Function[]>;\n authConfigs?: AuthConfigs;\n interceptorsOld?: any;\n authConfigsNew?: AuthConfigs;\n prismaQueryOptions?: PrismaQueryOptions<any>;\n prismaQueryOptionsNew?: PrismaQueryOptions<any>;\n router?: { config?: RouterConfig<any>; default: RouterConfig };\n dtos?: {\n create?: any;\n update?: any;\n signup?: any;\n login?: any;\n updatePassword?: any;\n updateMe?: any;\n };\n schemas?: {\n create?: any;\n update?: any;\n signup?: any;\n login?: any;\n updatePassword?: any;\n updateMe?: any;\n };\n};\n\nconst availableInterceptors = {\n auth: [\n \"beforeGetMe\",\n \"afterGetMe\",\n \"onGetMeError\",\n \"beforeUpdateMe\",\n \"afterUpdateMe\",\n \"onUpdateMeError\",\n \"beforeLogin\",\n \"afterLogin\",\n \"onLoginError\",\n \"beforeLogout\",\n \"afterLogout\",\n \"onLogoutError\",\n \"beforeSignup\",\n \"afterSignup\",\n \"onSignupError\",\n \"beforeUpdatePassword\",\n \"afterUpdatePassword\",\n \"onUpdatePasswordError\",\n ],\n \"file-upload\": [\n \"beforeFindFile\",\n \"onFindFileError\",\n \"beforeUploadFile\",\n \"afterUploadFile\",\n \"onUploadFileError\",\n \"beforeUpdateFile\",\n \"afterUpdateFile\",\n \"onUpdateFileError\",\n \"beforeDeleteFile\",\n \"afterDeleteFile\",\n \"onDeleteFileError\",\n ],\n prisma: [\n \"beforeCreateOne\",\n \"afterCreateOne\",\n \"onCreateOneError\",\n \"beforeFindOne\",\n \"afterFindOne\",\n \"onFindOneError\",\n \"beforeFindMany\",\n \"afterFindMany\",\n \"onFindManyError\",\n \"beforeUpdateOne\",\n \"afterUpdateOne\",\n \"onUpdateOneError\",\n \"beforeDeleteOne\",\n \"afterDeleteOne\",\n \"onDeleteOneError\",\n \"beforeCreateMany\",\n \"afterCreateMany\",\n \"onCreateManyError\",\n \"beforeUpdateMany\",\n \"afterUpdateMany\",\n \"onUpdateManyError\",\n \"beforeDeleteMany\",\n \"afterDeleteMany\",\n \"onDeleteManyError\",\n ],\n};\n\n/**\n * Validates naming convention conflicts for prismaQueryOptions and authConfigs\n * @param {string} key - The current file key being processed\n * @param {string} fileName - The filename being imported\n * @param {ImportModuleComponentsReturnType} result - The current result object\n * @throws {Error} When conflicting naming conventions are detected\n */\nexport function validateNamingConventions(\n key: string,\n fileName: string,\n result: ImportModuleComponentsReturnType\n): void {\n if (key === \"interceptorsOld\") {\n if (!result.interceptors)\n sheu.warn(\n `Found deprecated ${fileName} that will removed from v1.5.0-beta, consider switching to ${fileName.replace(\"middlewares\", \"interceptors\")}`\n );\n }\n}\n\n/**\n * Processes and assigns module to the result object based on the key\n * @param {string} key - The file key being processed\n * @param {any} module - The imported module\n * @param {ImportModuleComponentsReturnType} result - The result object to modify\n */\nexport function assignModuleToResult(\n appModule: string,\n key: string,\n module: any,\n result: ImportModuleComponentsReturnType,\n arkosConfig: ArkosConfig\n): void {\n if (key === \"interceptors\") result.interceptors = module;\n else if (key === \"interceptorsOld\") {\n const kebabCaseAppModule = kebabCase(appModule);\n const moduleName =\n kebabCaseAppModule === \"auth\"\n ? \"auth\"\n : kebabCaseAppModule === \"file-upload\"\n ? \"file-upload\"\n : \"prisma\";\n\n if (\n result.interceptors &&\n Object.keys(module).some((interceptorName) =>\n availableInterceptors[moduleName].includes(interceptorName)\n )\n ) {\n const exportedInterceptors = Object.keys(module).filter(\n (interceptorName) =>\n availableInterceptors[moduleName].includes(interceptorName)\n );\n const ext = getUserFileExtension();\n sheu.warn(\n `Found ${kebabCaseAppModule}.middlewares.${ext} exporting ${exportedInterceptors.join(\", \")}. Which by convention should go at ${kebabCaseAppModule}.interceptors.${ext} This is simply a warning that will stop from v1.5.0-beta`\n );\n } else if (!result.interceptors) result.interceptors = module;\n } else if (key === \"router\") {\n result[key] = {\n ...module,\n config: applyStrictRoutingRules(\n appModule,\n arkosConfig,\n module?.config || {}\n ),\n };\n validateRouterConfigConsistency(result[key]?.config || {});\n } else {\n result[key as keyof typeof result] = module.default || module;\n }\n}\n\n/**\n * Dynamically imports model-specific modules for a given model with optimized file handling.\n * Includes special handling for the Auth module.\n *\n * @param {string} modelName - The name of the model (e.g., \"User\", \"Post\", \"Auth\").\n * @returns {Promise<Object>} An object containing the imported modules\n */\nexport async function importModuleComponents(\n modelName: string,\n arkosConfig: ArkosConfig,\n moduleDirExists?: boolean\n): Promise<ImportModuleComponentsReturnType> {\n const result: ImportModuleComponentsReturnType = {\n dtos: {},\n schemas: {},\n };\n const usingStrictRouting = arkosConfig.routers?.strict;\n\n if (!moduleDirExists && !usingStrictRouting) return result;\n\n if (getModuleComponents(modelName)) return getModuleComponents(modelName);\n\n const moduleDir = path.resolve(crd(), \"src\", \"modules\", kebabCase(modelName));\n const fileStructure = getFileModuleComponentsFileStructure(modelName);\n\n const validationSubdir = arkosConfig.validation?.resolver\n ? arkosConfig.validation.resolver === \"zod\"\n ? \"schemas\"\n : \"dtos\"\n : null;\n\n const [_, validators] = await Promise.all([\n ...Object.entries(fileStructure.core).map(async ([key, fileName]) => {\n if (\n [\"createMany\", \"findMany\", \"findOne\", \"updateMany\"].includes(key) ||\n !fileName\n )\n return;\n\n const filePath = path.join(moduleDir, fileName);\n\n if (\n key === \"router\" &&\n !usingStrictRouting &&\n !(await pathExists(filePath))\n )\n return;\n else if (\n key !== \"router\" &&\n usingStrictRouting &&\n !(await pathExists(filePath))\n )\n return;\n\n try {\n let module = await importModule(filePath).catch(async (err) => {\n try {\n if (await pathExists(filePath)) {\n sheu.error(`Failed to import ${fileName}`);\n console.error(err);\n killServerChildProcess();\n process.exit(1);\n }\n } catch (err) {}\n });\n\n if (!module && key === \"router\" && usingStrictRouting) module = {};\n\n if (module) {\n (result as any)[key] = module;\n validateNamingConventions(key, fileName, result);\n assignModuleToResult(modelName, key, module, result, arkosConfig);\n }\n } catch (err: any) {\n if (err.message?.includes(\"Cannot use both\")) throw err;\n console.error(err);\n killServerChildProcess();\n }\n }),\n validationSubdir && processSubdir(modelName, validationSubdir),\n ]);\n\n prismaModelsModules[pascalCase(modelName)] = {\n ...result,\n ...(validationSubdir && { [validationSubdir]: validators }),\n };\n\n return {\n ...result,\n ...(validationSubdir && { [validationSubdir]: validators }),\n };\n}\n\nexport const appModules = Array.from(\n new Set([\n \"auth\",\n \"file-upload\",\n ...prismaSchemaParser.getModelsAsArrayOfStrings(),\n ])\n);\n\n/**\n * Allows to asynchronously load all app modules components at once to speed up app start time.\n */\nexport async function loadAllModuleComponents(arkosConfig: ArkosConfig) {\n const moduleDirExists: string[] = [];\n await Promise.all(\n appModules.map(async (appModule) => {\n const moduleDir = path.resolve(\n crd(),\n \"src\",\n \"modules\",\n kebabCase(appModule)\n );\n if (await pathExists(moduleDir)) moduleDirExists.push(appModule);\n })\n );\n\n const modulesComponentsImportPromises = appModules.map(\n async (appModule) =>\n await importModuleComponents(\n appModule,\n arkosConfig,\n moduleDirExists.includes(appModule)\n )\n );\n\n const modulesComponents = await Promise.all(modulesComponentsImportPromises);\n debuggerService.logDynamicLoadedModulesComponents(\n modulesComponents.map((components, i) => {\n const moduleDir = path.resolve(\n crd(),\n \"src\",\n \"modules\",\n kebabCase(appModules[i])\n );\n\n return {\n moduleName: kebabCase(appModules[i]),\n moduleDir,\n components,\n };\n })\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dynamic-loader.js","sourceRoot":"","sources":["../../../src/utils/dynamic-loader.ts"],"names":[],"mappings":";;;;;;AAwBA,kDAKC;AAED,kDAEC;AAaD,oFAyDC;AAED,0BAKC;AAED,kCAEC;AAED,sCAqDC;AAuGD,8DAWC;AAQD,oDAgDC;AASD,wDAoFC;AAaD,0DAwCC;AAreD,6BAAoC;AACpC,gDAAwB;AAExB,yDAAiE;AAEjE,kDAA0B;AAC1B,6EAI0C;AAC1C,uEAAsE;AACtE,qDAAiE;AACjE,6DAAwD;AACxD,yFAA+D;AAC/D,4FAAmE;AAMnE,IAAI,mBAAmB,GAAuC,EAAE,CAAC;AAGjE,SAAgB,mBAAmB,CACjC,SAA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CAAC,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE;QACtC,MAAM,SAAS,GAAG,cAAI,CAAC,OAAO,CAC5B,IAAA,gBAAG,GAAE,EACL,KAAK,EACL,SAAS,EACT,IAAA,+BAAS,EAAC,kBAAU,CAAC,CAAC,CAAC,CAAC,CACzB,CAAC;QAEF,OAAO;YACL,UAAU,EAAE,IAAA,+BAAS,EAAC,kBAAU,CAAC,CAAC,CAAC,CAAC;YACpC,SAAS;YACT,UAAU;SACX,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { z, ZodTypeAny } from \"zod\";\nimport path from \"path\";\nimport { AuthConfigs } from \"../types/auth\";\nimport { killServerChildProcess } from \"./cli/utils/cli.helpers\";\nimport { ArkosConfig, RouterConfig } from \"../exports\";\nimport sheu from \"./sheu\";\nimport {\n applyStrictRoutingRules,\n pathExists,\n validateRouterConfigConsistency,\n} from \"./helpers/dynamic-loader.helpers\";\nimport { kebabCase, pascalCase } from \"./helpers/change-case.helpers\";\nimport { crd, getUserFileExtension } from \"./helpers/fs.helpers\";\nimport { importModule } from \"./helpers/global.helpers\";\nimport prismaSchemaParser from \"./prisma/prisma-schema-parser\";\nimport debuggerService from \"../modules/debugger/debugger.service\";\nimport { PrismaQueryOptions } from \"../types\";\nimport { ServiceHook } from \"../modules/base/utils/service-hooks-manager\";\n\ntype AppModuleComponent = Awaited<ReturnType<typeof importModuleComponents>>;\n\nlet prismaModelsModules: Record<string, AppModuleComponent> = {};\n\n/** This was a workaround when testing and also when cjs was generated while `prismaModelsModules` was exported there where some problems */\nexport function setModuleComponents(\n modelName: string,\n modules: AppModuleComponent\n) {\n prismaModelsModules[pascalCase(modelName)] = modules;\n}\n\nexport function getModuleComponents(modelName: string) {\n return prismaModelsModules[pascalCase(modelName)];\n}\n\n/**\n * To be reused on other part of code for correct typing\n *\n * @param key\n * @param fileName\n * @param result\n */\nexport type ValidationFileMappingKey = keyof ReturnType<\n typeof getFileModuleComponentsFileStructure\n>[\"dtos\"];\n\nexport function getFileModuleComponentsFileStructure(modelName: string) {\n const kebabModelName = kebabCase(modelName).toLowerCase();\n const isAuthModule = modelName.toLowerCase() === \"auth\";\n const ext = getUserFileExtension();\n\n return {\n core: {\n hooks: `${kebabModelName}.hooks.${ext}`,\n interceptors: `${kebabModelName}.interceptors.${ext}`,\n interceptorsOld: `${kebabModelName}.middlewares.${ext}`,\n authConfigs: `${kebabModelName}.auth.${ext}`,\n prismaQueryOptions: `${kebabModelName}.query.${ext}`,\n router: `${kebabModelName}.router.${ext}`,\n },\n dtos: isAuthModule\n ? {\n login: `login.dto.${ext}`,\n signup: `signup.dto.${ext}`,\n getMe: `get-me.dto.${ext}`,\n updateMe: `update-me.dto.${ext}`,\n updatePassword: `update-password.dto.${ext}`,\n }\n : {\n model: `${kebabModelName}.dto.${ext}`,\n create: `create-${kebabModelName}.dto.${ext}`,\n createOne: `create-${kebabModelName}.dto.${ext}`, // just for sake of completion and reusability around other parts of code\n createMany: ``,\n update: `update-${kebabModelName}.dto.${ext}`,\n updateOne: `update-${kebabModelName}.dto.${ext}`, // same as createOne\n updateMany: ``,\n query: `query-${kebabModelName}.dto.${ext}`,\n // looking for some better naming convetion\n findOne: ``,\n findMany: ``,\n },\n schemas: isAuthModule\n ? {\n login: `login.schema.${ext}`,\n signup: `signup.schema.${ext}`,\n getMe: `get-me.schema.${ext}`,\n updateMe: `update-me.schema.${ext}`,\n updatePassword: `update-password.schema.${ext}`,\n }\n : {\n model: `${kebabModelName}.schema.${ext}`,\n create: `create-${kebabModelName}.schema.${ext}`,\n createOne: `create-${kebabModelName}.schema.${ext}`,\n createMany: ``, // just for sake of completion and reusability around other parts of code\n update: `update-${kebabModelName}.schema.${ext}`,\n updateOne: `update-${kebabModelName}.schema.${ext}`, // same as createOne\n updateMany: ``,\n query: `query-${kebabModelName}.schema.${ext}`,\n // looking for some better naming convetion\n findOne: ``,\n findMany: ``,\n },\n };\n}\n\nexport function isClass(value: any): boolean {\n return (\n typeof value === \"function\" &&\n /^class\\s/.test(Function.prototype.toString.call(value))\n );\n}\n\nexport function isZodSchema(value: any): value is ZodTypeAny {\n return value instanceof z.ZodType;\n}\n\nexport async function processSubdir(\n modelName: string,\n type: \"dtos\" | \"schemas\"\n) {\n const moduleDir = path.resolve(crd(), \"src\", \"modules\", kebabCase(modelName));\n\n const subdir = path.join(moduleDir, type);\n const fileStructure = getFileModuleComponentsFileStructure(modelName);\n const result: Record<string, any> = {};\n\n if (!(await pathExists(subdir))) return result;\n\n try {\n await Promise.all(\n Object.entries(fileStructure[type]).map(async ([key, fileName]) => {\n const filePath = path.join(subdir, fileName);\n if (!fileName || !(await pathExists(filePath))) return;\n\n try {\n const module = await importModule(filePath).catch(\n async (err: any) => {\n if (await pathExists(filePath)) {\n sheu.error(`Failed to import ${fileName}: `);\n console.error(err);\n killServerChildProcess();\n process.exit(1);\n }\n }\n );\n\n const cleanFilePath = `src/modules/${kebabCase(modelName)}/${fileName}`;\n if (type === \"dtos\" && !isClass(module?.default))\n throw Error(\n `ValidationError: Please export as default a valid class under ${cleanFilePath}, in order to use as Dto.`\n );\n else if (type === \"schemas\" && !isZodSchema(module?.default))\n throw Error(\n `ValidationError: Please export as default a valid zod schema under ${cleanFilePath}, in order to use as Schema`\n );\n\n if (module && module?.default) result[key] = module.default;\n } catch (err: any) {\n if (err?.message?.includes(\"ValidationError\")) throw err;\n console.error(err);\n }\n })\n );\n } catch (err: any) {\n if (err?.message?.includes(\"ValidationError\")) throw err;\n console.error(err);\n }\n\n return result;\n}\n\nexport type ModuleComponents = Omit<\n ImportModuleComponentsReturnType,\n \"authConfigsNew\" | \"prismaQueryOptionsNew\"\n>;\n\ntype ImportModuleComponentsReturnType = {\n hooks?: Record<string, ServiceHook | ServiceHook[]>;\n interceptors?: Record<string, Function | Function[]>;\n authConfigs?: AuthConfigs;\n interceptorsOld?: any;\n authConfigsNew?: AuthConfigs;\n prismaQueryOptions?: PrismaQueryOptions<any>;\n prismaQueryOptionsNew?: PrismaQueryOptions<any>;\n router?: { config?: RouterConfig<any>; default: RouterConfig };\n dtos?: {\n create?: any;\n update?: any;\n signup?: any;\n login?: any;\n updatePassword?: any;\n updateMe?: any;\n };\n schemas?: {\n create?: any;\n update?: any;\n signup?: any;\n login?: any;\n updatePassword?: any;\n updateMe?: any;\n };\n};\n\nconst availableInterceptors = {\n auth: [\n \"beforeGetMe\",\n \"afterGetMe\",\n \"onGetMeError\",\n \"beforeUpdateMe\",\n \"afterUpdateMe\",\n \"onUpdateMeError\",\n \"beforeLogin\",\n \"afterLogin\",\n \"onLoginError\",\n \"beforeLogout\",\n \"afterLogout\",\n \"onLogoutError\",\n \"beforeSignup\",\n \"afterSignup\",\n \"onSignupError\",\n \"beforeUpdatePassword\",\n \"afterUpdatePassword\",\n \"onUpdatePasswordError\",\n ],\n \"file-upload\": [\n \"beforeFindFile\",\n \"onFindFileError\",\n \"beforeUploadFile\",\n \"afterUploadFile\",\n \"onUploadFileError\",\n \"beforeUpdateFile\",\n \"afterUpdateFile\",\n \"onUpdateFileError\",\n \"beforeDeleteFile\",\n \"afterDeleteFile\",\n \"onDeleteFileError\",\n ],\n prisma: [\n \"beforeCreateOne\",\n \"afterCreateOne\",\n \"onCreateOneError\",\n \"beforeFindOne\",\n \"afterFindOne\",\n \"onFindOneError\",\n \"beforeFindMany\",\n \"afterFindMany\",\n \"onFindManyError\",\n \"beforeUpdateOne\",\n \"afterUpdateOne\",\n \"onUpdateOneError\",\n \"beforeDeleteOne\",\n \"afterDeleteOne\",\n \"onDeleteOneError\",\n \"beforeCreateMany\",\n \"afterCreateMany\",\n \"onCreateManyError\",\n \"beforeUpdateMany\",\n \"afterUpdateMany\",\n \"onUpdateManyError\",\n \"beforeDeleteMany\",\n \"afterDeleteMany\",\n \"onDeleteManyError\",\n ],\n};\n\n/**\n * Validates naming convention conflicts for prismaQueryOptions and authConfigs\n * @param {string} key - The current file key being processed\n * @param {string} fileName - The filename being imported\n * @param {ImportModuleComponentsReturnType} result - The current result object\n * @throws {Error} When conflicting naming conventions are detected\n */\nexport function validateNamingConventions(\n key: string,\n fileName: string,\n result: ImportModuleComponentsReturnType\n): void {\n if (key === \"interceptorsOld\") {\n if (!result.interceptors)\n sheu.warn(\n `Found deprecated ${fileName} that will removed from v1.5.0-beta, consider switching to ${fileName.replace(\"middlewares\", \"interceptors\")}`\n );\n }\n}\n\n/**\n * Processes and assigns module to the result object based on the key\n * @param {string} key - The file key being processed\n * @param {any} module - The imported module\n * @param {ImportModuleComponentsReturnType} result - The result object to modify\n */\nexport function assignModuleToResult(\n appModule: string,\n key: string,\n module: any,\n result: ImportModuleComponentsReturnType,\n arkosConfig: ArkosConfig\n): void {\n if (key === \"interceptors\") result.interceptors = module;\n else if (key === \"interceptorsOld\") {\n const kebabCaseAppModule = kebabCase(appModule);\n const moduleName =\n kebabCaseAppModule === \"auth\"\n ? \"auth\"\n : kebabCaseAppModule === \"file-upload\"\n ? \"file-upload\"\n : \"prisma\";\n\n if (\n result.interceptors &&\n Object.keys(module).some((interceptorName) =>\n availableInterceptors[moduleName].includes(interceptorName)\n )\n ) {\n const exportedInterceptors = Object.keys(module).filter(\n (interceptorName) =>\n availableInterceptors[moduleName].includes(interceptorName)\n );\n const ext = getUserFileExtension();\n sheu.warn(\n `Found ${kebabCaseAppModule}.middlewares.${ext} exporting ${exportedInterceptors.join(\", \")}. Which by convention should go at ${kebabCaseAppModule}.interceptors.${ext} This is simply a warning that will stop from v1.5.0-beta`\n );\n } else if (!result.interceptors) result.interceptors = module;\n } else if (key === \"router\") {\n result[key] = {\n ...module,\n config: applyStrictRoutingRules(\n appModule,\n arkosConfig,\n module?.config || {}\n ),\n };\n validateRouterConfigConsistency(\n kebabCase(appModule),\n result[key]?.config || {}\n );\n } else {\n result[key as keyof typeof result] = module.default || module;\n }\n}\n\n/**\n * Dynamically imports model-specific modules for a given model with optimized file handling.\n * Includes special handling for the Auth module.\n *\n * @param {string} modelName - The name of the model (e.g., \"User\", \"Post\", \"Auth\").\n * @returns {Promise<Object>} An object containing the imported modules\n */\nexport async function importModuleComponents(\n modelName: string,\n arkosConfig: ArkosConfig,\n moduleDirExists?: boolean\n): Promise<ImportModuleComponentsReturnType> {\n const result: ImportModuleComponentsReturnType = {\n dtos: {},\n schemas: {},\n };\n const usingStrictRouting = arkosConfig.routers?.strict;\n\n if (!moduleDirExists && !usingStrictRouting) return result;\n\n if (getModuleComponents(modelName)) return getModuleComponents(modelName);\n\n const moduleDir = path.resolve(crd(), \"src\", \"modules\", kebabCase(modelName));\n const fileStructure = getFileModuleComponentsFileStructure(modelName);\n\n const validationSubdir = arkosConfig.validation?.resolver\n ? arkosConfig.validation.resolver === \"zod\"\n ? \"schemas\"\n : \"dtos\"\n : null;\n\n const [_, validators] = await Promise.all([\n ...Object.entries(fileStructure.core).map(async ([key, fileName]) => {\n if (\n [\"createMany\", \"findMany\", \"findOne\", \"updateMany\"].includes(key) ||\n !fileName\n )\n return;\n\n const filePath = path.join(moduleDir, fileName);\n\n if (\n key === \"router\" &&\n !usingStrictRouting &&\n !(await pathExists(filePath))\n )\n return;\n else if (\n key !== \"router\" &&\n usingStrictRouting &&\n !(await pathExists(filePath))\n )\n return;\n\n try {\n let module = await importModule(filePath).catch(async (err) => {\n try {\n if (await pathExists(filePath)) {\n sheu.error(`Failed to import ${fileName}`);\n console.error(err);\n killServerChildProcess();\n process.exit(1);\n }\n } catch (err) {}\n });\n\n if (!module && key === \"router\" && usingStrictRouting) module = {};\n\n if (module) {\n (result as any)[key] = module;\n validateNamingConventions(key, fileName, result);\n assignModuleToResult(modelName, key, module, result, arkosConfig);\n }\n } catch (err: any) {\n if (err.message?.includes(\"Cannot use both\")) throw err;\n console.error(err);\n killServerChildProcess();\n }\n }),\n validationSubdir && processSubdir(modelName, validationSubdir),\n ]);\n\n prismaModelsModules[pascalCase(modelName)] = {\n ...result,\n ...(validationSubdir && { [validationSubdir]: validators }),\n };\n\n return {\n ...result,\n ...(validationSubdir && { [validationSubdir]: validators }),\n };\n}\n\nexport const appModules = Array.from(\n new Set([\n \"auth\",\n \"file-upload\",\n ...prismaSchemaParser.getModelsAsArrayOfStrings(),\n ])\n);\n\n/**\n * Allows to asynchronously load all app modules components at once to speed up app start time.\n */\nexport async function loadAllModuleComponents(arkosConfig: ArkosConfig) {\n const moduleDirExists: string[] = [];\n await Promise.all(\n appModules.map(async (appModule) => {\n const moduleDir = path.resolve(\n crd(),\n \"src\",\n \"modules\",\n kebabCase(appModule)\n );\n if (await pathExists(moduleDir)) moduleDirExists.push(appModule);\n })\n );\n\n const modulesComponentsImportPromises = appModules.map(\n async (appModule) =>\n await importModuleComponents(\n appModule,\n arkosConfig,\n moduleDirExists.includes(appModule)\n )\n );\n\n const modulesComponents = await Promise.all(modulesComponentsImportPromises);\n debuggerService.logDynamicLoadedModulesComponents(\n modulesComponents.map((components, i) => {\n const moduleDir = path.resolve(\n crd(),\n \"src\",\n \"modules\",\n kebabCase(appModules[i])\n );\n\n return {\n moduleName: kebabCase(appModules[i]),\n moduleDir,\n components,\n };\n })\n );\n}\n"]}
|
|
@@ -83,9 +83,7 @@ function applyStrictRoutingRules(appModule, arkosConfig, moduleConfig) {
|
|
|
83
83
|
const disableConfig = (0, deepmerge_helper_1.default)(strictDefaults, config?.disable || {});
|
|
84
84
|
const endpointConfigs = {};
|
|
85
85
|
for (const endpoint of Object.keys(strictDefaults)) {
|
|
86
|
-
endpointConfigs[endpoint] = (0, deepmerge_helper_1.default)(config[endpoint] || {}
|
|
87
|
-
disabled: strictDefaults[endpoint],
|
|
88
|
-
});
|
|
86
|
+
endpointConfigs[endpoint] = (0, deepmerge_helper_1.default)({ disabled: strictDefaults[endpoint] }, config[endpoint] || {});
|
|
89
87
|
}
|
|
90
88
|
const syncedDisable = { ...disableConfig };
|
|
91
89
|
for (const endpoint of allEndpoints) {
|
|
@@ -96,9 +94,9 @@ function applyStrictRoutingRules(appModule, arkosConfig, moduleConfig) {
|
|
|
96
94
|
}
|
|
97
95
|
const syncedEndpoints = { ...endpointConfigs };
|
|
98
96
|
for (const endpoint of allEndpoints) {
|
|
99
|
-
if (
|
|
97
|
+
if (syncedDisable[endpoint] !== undefined) {
|
|
100
98
|
syncedEndpoints[endpoint] = (0, deepmerge_helper_1.default)(syncedEndpoints[endpoint] || {}, {
|
|
101
|
-
disabled:
|
|
99
|
+
disabled: syncedDisable[endpoint],
|
|
102
100
|
});
|
|
103
101
|
}
|
|
104
102
|
}
|
|
@@ -117,9 +115,7 @@ function applyStrictRoutingRules(appModule, arkosConfig, moduleConfig) {
|
|
|
117
115
|
const disableConfig = (0, deepmerge_helper_1.default)(noBulkDefaults, config.disable || {});
|
|
118
116
|
const endpointConfigs = {};
|
|
119
117
|
for (const endpoint of Object.keys(noBulkDefaults)) {
|
|
120
|
-
endpointConfigs[endpoint] = (0, deepmerge_helper_1.default)(config[endpoint] || {}
|
|
121
|
-
disabled: noBulkDefaults[endpoint],
|
|
122
|
-
});
|
|
118
|
+
endpointConfigs[endpoint] = (0, deepmerge_helper_1.default)({ disabled: noBulkDefaults[endpoint] }, config[endpoint] || {});
|
|
123
119
|
}
|
|
124
120
|
const syncedDisable = { ...disableConfig };
|
|
125
121
|
for (const endpoint of allEndpoints) {
|
|
@@ -131,9 +127,7 @@ function applyStrictRoutingRules(appModule, arkosConfig, moduleConfig) {
|
|
|
131
127
|
const syncedEndpoints = { ...endpointConfigs };
|
|
132
128
|
for (const endpoint of allEndpoints) {
|
|
133
129
|
if (syncedDisable[endpoint] !== undefined) {
|
|
134
|
-
syncedEndpoints[endpoint] = (0, deepmerge_helper_1.default)(syncedEndpoints[endpoint] || {}
|
|
135
|
-
disabled: syncedDisable[endpoint],
|
|
136
|
-
});
|
|
130
|
+
syncedEndpoints[endpoint] = (0, deepmerge_helper_1.default)({ disabled: syncedDisable[endpoint] }, syncedEndpoints[endpoint] || {});
|
|
137
131
|
}
|
|
138
132
|
}
|
|
139
133
|
return (0, deepmerge_helper_1.default)(config, {
|
|
@@ -143,7 +137,7 @@ function applyStrictRoutingRules(appModule, arkosConfig, moduleConfig) {
|
|
|
143
137
|
}
|
|
144
138
|
return config;
|
|
145
139
|
}
|
|
146
|
-
function validateRouterConfigConsistency(config) {
|
|
140
|
+
function validateRouterConfigConsistency(appModule, config) {
|
|
147
141
|
if (!config.disable || typeof config.disable === "boolean")
|
|
148
142
|
return;
|
|
149
143
|
const endpoints = Object.keys(config.disable);
|
|
@@ -153,7 +147,7 @@ function validateRouterConfigConsistency(config) {
|
|
|
153
147
|
if (oldWayValue !== undefined &&
|
|
154
148
|
newWayValue !== undefined &&
|
|
155
149
|
oldWayValue !== newWayValue) {
|
|
156
|
-
throw new Error(`Conflicting disabled values for endpoint "${endpoint}": ` +
|
|
150
|
+
throw new Error(`Conflicting disabled values for endpoint "${endpoint}" of module ${appModule}: ` +
|
|
157
151
|
`disable.${endpoint} = ${oldWayValue}, but ${endpoint}.disabled = ${newWayValue}. ` +
|
|
158
152
|
`Please use only one method to disable endpoints.`);
|
|
159
153
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-loader.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/dynamic-loader.helpers.ts"],"names":[],"mappings":";;;;;AAOA,0DAoKC;AAED,0EAuBC;AAED,gCAOC;AA5MD,4CAAoB;AACpB,0EAA2C;AAK3C,SAAgB,uBAAuB,CACrC,SAAY,EACZ,WAAwB,EACxB,YAA8B;IAE9B,MAAM,UAAU,GAAG,WAAW,EAAE,OAAO,EAAE,MAAM,IAAI,KAAK,CAAC;IACzD,IAAI,MAAM,GAAQ,YAAY,IAAK,EAAsB,CAAC;IAC1D,SAAS,GAAG,SAAS,CAAC,WAAW,EAAO,CAAC;IAEzC,MAAM,YAAY,GAChB,SAAS,KAAK,MAAM;QAClB,CAAC,CAAC;YACE,OAAO;YACP,UAAU;YACV,UAAU;YACV,OAAO;YACP,QAAQ;YACR,QAAQ;YACR,gBAAgB;YAChB,oBAAoB;SACrB;QACH,CAAC,CAAC,SAAS,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AAG,EAAE,CAAC;QACb,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC","sourcesContent":["import { ArkosConfig, RouterConfig } from \"../../exports\";\nimport fs from \"fs\";\nimport deepmerge from \"./deepmerge.helper\";\n\n/**\n * Applies strict routing rules to module configuration\n */\nexport function applyStrictRoutingRules<T extends string>(\n appModule: T,\n arkosConfig: ArkosConfig,\n moduleConfig?: RouterConfig<T>\n): RouterConfig<T> {\n const strictMode = arkosConfig?.routers?.strict || false;\n let config: any = moduleConfig || ({} as RouterConfig<T>);\n appModule = appModule.toLowerCase() as T;\n\n const allEndpoints =\n appModule === \"auth\"\n ? [\n \"getMe\",\n \"updateMe\",\n \"deleteMe\",\n \"login\",\n \"logout\",\n \"signup\",\n \"updatePassword\",\n \"findManyAuthAction\",\n ]\n : appModule === \"file-upload\"\n ? [\"findFile\", \"uploadFile\", \"updateFile\", \"deleteFile\"]\n : [\n \"createOne\",\n \"findOne\",\n \"updateOne\",\n \"deleteOne\",\n \"createMany\",\n \"findMany\",\n \"updateMany\",\n \"deleteMany\",\n ];\n\n const hadBooleanDisable = typeof config.disable === \"boolean\";\n\n if (hadBooleanDisable) {\n const disableValue = config.disable;\n const disableObject: Record<string, boolean> = {};\n const endpointConfigs: Record<string, any> = {};\n\n for (const endpoint of allEndpoints) {\n (disableObject as any)[endpoint] = disableValue;\n endpointConfigs[endpoint] = deepmerge((config as any)[endpoint] || {}, {\n disabled: disableValue,\n });\n }\n\n return deepmerge(config as any, {\n disable: disableObject,\n ...endpointConfigs,\n }) as RouterConfig<T>;\n }\n\n if (strictMode === true) {\n const strictDefaults: any =\n appModule === \"auth\"\n ? {\n getMe: true,\n updateMe: true,\n deleteMe: true,\n login: true,\n logout: true,\n signup: true,\n updatePassword: true,\n findManyAuthAction: true,\n }\n : appModule === \"file-upload\"\n ? {\n findFile: true,\n uploadFile: true,\n updateFile: true,\n deleteFile: true,\n }\n : {\n createOne: true,\n findOne: true,\n updateOne: true,\n deleteOne: true,\n createMany: true,\n findMany: true,\n updateMany: true,\n deleteMany: true,\n };\n\n const disableConfig: any = deepmerge(\n strictDefaults,\n (config?.disable as any) || {}\n );\n\n const endpointConfigs: Record<string, any> = {};\n for (const endpoint of Object.keys(strictDefaults)) {\n endpointConfigs[endpoint] = deepmerge((config as any)[endpoint] || {}, {\n disabled: strictDefaults[endpoint],\n });\n }\n\n const syncedDisable: Record<string, boolean> = { ...disableConfig };\n for (const endpoint of allEndpoints) {\n const endpointDisabled = (config as any)[endpoint]?.disabled;\n if (endpointDisabled !== undefined) {\n syncedDisable[endpoint] = endpointDisabled;\n }\n }\n\n const syncedEndpoints: Record<string, any> = { ...endpointConfigs };\n for (const endpoint of allEndpoints) {\n if (disableConfig[endpoint] !== undefined) {\n syncedEndpoints[endpoint] = deepmerge(syncedEndpoints[endpoint] || {}, {\n disabled: disableConfig[endpoint],\n });\n }\n }\n\n return deepmerge(config, {\n disable: syncedDisable,\n ...syncedEndpoints,\n }) as RouterConfig<T>;\n } else if (\n strictMode === \"no-bulk\" &&\n ![\"auth\", \"file-upload\"].includes(appModule.toLowerCase())\n ) {\n const noBulkDefaults: any = {\n createMany: true,\n updateMany: true,\n deleteMany: true,\n };\n\n const disableConfig: any = deepmerge(\n noBulkDefaults,\n (config.disable as any) || {}\n );\n\n const endpointConfigs: Record<string, any> = {};\n for (const endpoint of Object.keys(noBulkDefaults)) {\n endpointConfigs[endpoint] = deepmerge((config as any)[endpoint] || {}, {\n disabled: noBulkDefaults[endpoint],\n });\n }\n\n const syncedDisable: Record<string, boolean> = { ...disableConfig };\n for (const endpoint of allEndpoints) {\n const endpointDisabled = (config as any)[endpoint]?.disabled;\n if (endpointDisabled !== undefined) {\n syncedDisable[endpoint] = endpointDisabled;\n }\n }\n\n const syncedEndpoints: Record<string, any> = { ...endpointConfigs };\n for (const endpoint of allEndpoints) {\n if (syncedDisable[endpoint] !== undefined) {\n syncedEndpoints[endpoint] = deepmerge(syncedEndpoints[endpoint] || {}, {\n disabled: syncedDisable[endpoint],\n });\n }\n }\n\n return deepmerge(config as any, {\n disable: syncedDisable,\n ...syncedEndpoints,\n }) as RouterConfig<T>;\n }\n\n return config;\n}\n\nexport function validateRouterConfigConsistency(\n config: Record<string, any>\n): void {\n if (!config.disable || typeof config.disable === \"boolean\") return;\n\n const endpoints = Object.keys(config.disable) as any[];\n\n for (const endpoint of endpoints) {\n const oldWayValue = (config.disable as any)[endpoint];\n const newWayValue = (config as any)[endpoint]?.disabled;\n\n if (\n oldWayValue !== undefined &&\n newWayValue !== undefined &&\n oldWayValue !== newWayValue\n ) {\n throw new Error(\n `Conflicting disabled values for endpoint \"${endpoint}\": ` +\n `disable.${endpoint} = ${oldWayValue}, but ${endpoint}.disabled = ${newWayValue}. ` +\n `Please use only one method to disable endpoints.`\n );\n }\n }\n}\n\nexport async function pathExists(path: string) {\n try {\n await fs.promises.stat(path);\n return true;\n } catch (err) {\n return false;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dynamic-loader.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/dynamic-loader.helpers.ts"],"names":[],"mappings":";;;;;AAOA,0DA0KC;AAED,0EAwBC;AAED,gCAOC;AAnND,4CAAoB;AACpB,0EAA2C;AAK3C,SAAgB,uBAAuB,CACrC,SAAY,EACZ,WAAwB,EACxB,YAA8B;IAE9B,MAAM,UAAU,GAAG,WAAW,EAAE,OAAO,EAAE,MAAM,IAAI,KAAK,CAAC;IACzD,IAAI,MAAM,GAAQ,YAAY,IAAK,EAAsB,CAAC;IAC1D,SAAS,GAAG,SAAS,CAAC,WAAW,EAAO,CAAC;IAEzC,MAAM,YAAY,GAChB,SAAS,KAAK,MAAM;QAClB,CAAC,CAAC;YACE,OAAO;YACP,UAAU;YACV,UAAU;YACV,OAAO;YACP,QAAQ;YACR,QAAQ;YACR,gBAAgB;YAChB,oBAAoB;SACrB;QACH,CAAC,CAAC,SAAS,KAAK,aAAa;YAC3B,CAAC,CAAC,CAAC,UAAU,EAAE,YAAY,EAA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,CAAC;IACf,CAAC;AACH,CAAC","sourcesContent":["import { ArkosConfig, RouterConfig } from \"../../exports\";\nimport fs from \"fs\";\nimport deepmerge from \"./deepmerge.helper\";\n\n/**\n * Applies strict routing rules to module configuration\n */\nexport function applyStrictRoutingRules<T extends string>(\n appModule: T,\n arkosConfig: ArkosConfig,\n moduleConfig?: RouterConfig<T>\n): RouterConfig<T> {\n const strictMode = arkosConfig?.routers?.strict || false;\n let config: any = moduleConfig || ({} as RouterConfig<T>);\n appModule = appModule.toLowerCase() as T;\n\n const allEndpoints =\n appModule === \"auth\"\n ? [\n \"getMe\",\n \"updateMe\",\n \"deleteMe\",\n \"login\",\n \"logout\",\n \"signup\",\n \"updatePassword\",\n \"findManyAuthAction\",\n ]\n : appModule === \"file-upload\"\n ? [\"findFile\", \"uploadFile\", \"updateFile\", \"deleteFile\"]\n : [\n \"createOne\",\n \"findOne\",\n \"updateOne\",\n \"deleteOne\",\n \"createMany\",\n \"findMany\",\n \"updateMany\",\n \"deleteMany\",\n ];\n\n const hadBooleanDisable = typeof config.disable === \"boolean\";\n\n // IMPORTANT: Order matters in deepmerge!\n // User config must be SECOND argument to override defaults\n\n if (hadBooleanDisable) {\n const disableValue = config.disable;\n const disableObject: Record<string, boolean> = {};\n const endpointConfigs: Record<string, any> = {};\n\n for (const endpoint of allEndpoints) {\n (disableObject as any)[endpoint] = disableValue;\n endpointConfigs[endpoint] = deepmerge((config as any)[endpoint] || {}, {\n disabled: disableValue,\n });\n }\n\n return deepmerge(config as any, {\n disable: disableObject,\n ...endpointConfigs,\n }) as RouterConfig<T>;\n }\n\n if (strictMode === true) {\n const strictDefaults: any =\n appModule === \"auth\"\n ? {\n getMe: true,\n updateMe: true,\n deleteMe: true,\n login: true,\n logout: true,\n signup: true,\n updatePassword: true,\n findManyAuthAction: true,\n }\n : appModule === \"file-upload\"\n ? {\n findFile: true,\n uploadFile: true,\n updateFile: true,\n deleteFile: true,\n }\n : {\n createOne: true,\n findOne: true,\n updateOne: true,\n deleteOne: true,\n createMany: true,\n findMany: true,\n updateMany: true,\n deleteMany: true,\n };\n\n const disableConfig: any = deepmerge(\n strictDefaults,\n (config?.disable as any) || {}\n );\n\n const endpointConfigs: Record<string, any> = {};\n for (const endpoint of Object.keys(strictDefaults)) {\n endpointConfigs[endpoint] = deepmerge(\n { disabled: strictDefaults[endpoint] },\n (config as any)[endpoint] || {}\n );\n }\n\n const syncedDisable: Record<string, boolean> = { ...disableConfig };\n for (const endpoint of allEndpoints) {\n const endpointDisabled = (config as any)[endpoint]?.disabled;\n if (endpointDisabled !== undefined) {\n syncedDisable[endpoint] = endpointDisabled;\n }\n }\n\n const syncedEndpoints: Record<string, any> = { ...endpointConfigs };\n for (const endpoint of allEndpoints) {\n if (syncedDisable[endpoint] !== undefined) {\n syncedEndpoints[endpoint] = deepmerge(syncedEndpoints[endpoint] || {}, {\n disabled: syncedDisable[endpoint],\n });\n }\n }\n\n return deepmerge(config as any, {\n disable: syncedDisable,\n ...syncedEndpoints,\n }) as RouterConfig<T>;\n } else if (\n strictMode === \"no-bulk\" &&\n ![\"auth\", \"file-upload\"].includes(appModule.toLowerCase())\n ) {\n const noBulkDefaults: any = {\n createMany: true,\n updateMany: true,\n deleteMany: true,\n };\n\n const disableConfig: any = deepmerge(\n noBulkDefaults,\n (config.disable as any) || {}\n );\n\n const endpointConfigs: Record<string, any> = {};\n for (const endpoint of Object.keys(noBulkDefaults)) {\n endpointConfigs[endpoint] = deepmerge(\n { disabled: noBulkDefaults[endpoint] },\n (config as any)[endpoint] || {}\n );\n }\n\n const syncedDisable: Record<string, boolean> = { ...disableConfig };\n for (const endpoint of allEndpoints) {\n const endpointDisabled = (config as any)[endpoint]?.disabled;\n if (endpointDisabled !== undefined) {\n syncedDisable[endpoint] = endpointDisabled;\n }\n }\n\n const syncedEndpoints: Record<string, any> = { ...endpointConfigs };\n for (const endpoint of allEndpoints) {\n if (syncedDisable[endpoint] !== undefined) {\n syncedEndpoints[endpoint] = deepmerge(\n { disabled: syncedDisable[endpoint] },\n syncedEndpoints[endpoint] || {}\n );\n }\n }\n\n return deepmerge(config as any, {\n disable: syncedDisable,\n ...syncedEndpoints,\n }) as RouterConfig<T>;\n }\n\n return config;\n}\n\nexport function validateRouterConfigConsistency(\n appModule: string,\n config: Record<string, any>\n): void {\n if (!config.disable || typeof config.disable === \"boolean\") return;\n\n const endpoints = Object.keys(config.disable) as any[];\n\n for (const endpoint of endpoints) {\n const oldWayValue = (config.disable as any)[endpoint];\n const newWayValue = (config as any)[endpoint]?.disabled;\n\n if (\n oldWayValue !== undefined &&\n newWayValue !== undefined &&\n oldWayValue !== newWayValue\n ) {\n throw new Error(\n `Conflicting disabled values for endpoint \"${endpoint}\" of module ${appModule}: ` +\n `disable.${endpoint} = ${oldWayValue}, but ${endpoint}.disabled = ${newWayValue}. ` +\n `Please use only one method to disable endpoints.`\n );\n }\n }\n}\n\nexport async function pathExists(path: string) {\n try {\n await fs.promises.stat(path);\n return true;\n } catch (err) {\n return false;\n }\n}\n"]}
|
|
@@ -211,7 +211,7 @@ export function assignModuleToResult(appModule, key, module, result, arkosConfig
|
|
|
211
211
|
...module,
|
|
212
212
|
config: applyStrictRoutingRules(appModule, arkosConfig, module?.config || {}),
|
|
213
213
|
};
|
|
214
|
-
validateRouterConfigConsistency(result[key]?.config || {});
|
|
214
|
+
validateRouterConfigConsistency(kebabCase(appModule), result[key]?.config || {});
|
|
215
215
|
}
|
|
216
216
|
else {
|
|
217
217
|
result[key] = module.default || module;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-loader.js","sourceRoot":"","sources":["../../../src/utils/dynamic-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAc,MAAM,KAAK,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,EACL,uBAA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,MAAM,sBAAsB,CAC1B,SAAS,EACT,WAAW,EACX,eAAe,CAAC,QAAQ,CAAC,SAAS,CAAC,CACpC,CACJ,CAAC;IAEF,MAAM,iBAAiB,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;IAC7E,eAAe,CAAC,iCAAiC,CAC/C,iBAAiB,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE;QACtC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAC5B,GAAG,EAAE,EACL,KAAK,EACL,SAAS,EACT,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CACzB,CAAC;QAEF,OAAO;YACL,UAAU,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YACpC,SAAS;YACT,UAAU;SACX,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { z, ZodTypeAny } from \"zod\";\nimport path from \"path\";\nimport { AuthConfigs } from \"../types/auth\";\nimport { killServerChildProcess } from \"./cli/utils/cli.helpers\";\nimport { ArkosConfig, RouterConfig } from \"../exports\";\nimport sheu from \"./sheu\";\nimport {\n applyStrictRoutingRules,\n pathExists,\n validateRouterConfigConsistency,\n} from \"./helpers/dynamic-loader.helpers\";\nimport { kebabCase, pascalCase } from \"./helpers/change-case.helpers\";\nimport { crd, getUserFileExtension } from \"./helpers/fs.helpers\";\nimport { importModule } from \"./helpers/global.helpers\";\nimport prismaSchemaParser from \"./prisma/prisma-schema-parser\";\nimport debuggerService from \"../modules/debugger/debugger.service\";\nimport { PrismaQueryOptions } from \"../types\";\nimport { ServiceHook } from \"../modules/base/utils/service-hooks-manager\";\n\ntype AppModuleComponent = Awaited<ReturnType<typeof importModuleComponents>>;\n\nlet prismaModelsModules: Record<string, AppModuleComponent> = {};\n\n/** This was a workaround when testing and also when cjs was generated while `prismaModelsModules` was exported there where some problems */\nexport function setModuleComponents(\n modelName: string,\n modules: AppModuleComponent\n) {\n prismaModelsModules[pascalCase(modelName)] = modules;\n}\n\nexport function getModuleComponents(modelName: string) {\n return prismaModelsModules[pascalCase(modelName)];\n}\n\n/**\n * To be reused on other part of code for correct typing\n *\n * @param key\n * @param fileName\n * @param result\n */\nexport type ValidationFileMappingKey = keyof ReturnType<\n typeof getFileModuleComponentsFileStructure\n>[\"dtos\"];\n\nexport function getFileModuleComponentsFileStructure(modelName: string) {\n const kebabModelName = kebabCase(modelName).toLowerCase();\n const isAuthModule = modelName.toLowerCase() === \"auth\";\n const ext = getUserFileExtension();\n\n return {\n core: {\n hooks: `${kebabModelName}.hooks.${ext}`,\n interceptors: `${kebabModelName}.interceptors.${ext}`,\n interceptorsOld: `${kebabModelName}.middlewares.${ext}`,\n authConfigs: `${kebabModelName}.auth.${ext}`,\n prismaQueryOptions: `${kebabModelName}.query.${ext}`,\n router: `${kebabModelName}.router.${ext}`,\n },\n dtos: isAuthModule\n ? {\n login: `login.dto.${ext}`,\n signup: `signup.dto.${ext}`,\n getMe: `get-me.dto.${ext}`,\n updateMe: `update-me.dto.${ext}`,\n updatePassword: `update-password.dto.${ext}`,\n }\n : {\n model: `${kebabModelName}.dto.${ext}`,\n create: `create-${kebabModelName}.dto.${ext}`,\n createOne: `create-${kebabModelName}.dto.${ext}`, // just for sake of completion and reusability around other parts of code\n createMany: ``,\n update: `update-${kebabModelName}.dto.${ext}`,\n updateOne: `update-${kebabModelName}.dto.${ext}`, // same as createOne\n updateMany: ``,\n query: `query-${kebabModelName}.dto.${ext}`,\n // looking for some better naming convetion\n findOne: ``,\n findMany: ``,\n },\n schemas: isAuthModule\n ? {\n login: `login.schema.${ext}`,\n signup: `signup.schema.${ext}`,\n getMe: `get-me.schema.${ext}`,\n updateMe: `update-me.schema.${ext}`,\n updatePassword: `update-password.schema.${ext}`,\n }\n : {\n model: `${kebabModelName}.schema.${ext}`,\n create: `create-${kebabModelName}.schema.${ext}`,\n createOne: `create-${kebabModelName}.schema.${ext}`,\n createMany: ``, // just for sake of completion and reusability around other parts of code\n update: `update-${kebabModelName}.schema.${ext}`,\n updateOne: `update-${kebabModelName}.schema.${ext}`, // same as createOne\n updateMany: ``,\n query: `query-${kebabModelName}.schema.${ext}`,\n // looking for some better naming convetion\n findOne: ``,\n findMany: ``,\n },\n };\n}\n\nexport function isClass(value: any): boolean {\n return (\n typeof value === \"function\" &&\n /^class\\s/.test(Function.prototype.toString.call(value))\n );\n}\n\nexport function isZodSchema(value: any): value is ZodTypeAny {\n return value instanceof z.ZodType;\n}\n\nexport async function processSubdir(\n modelName: string,\n type: \"dtos\" | \"schemas\"\n) {\n const moduleDir = path.resolve(crd(), \"src\", \"modules\", kebabCase(modelName));\n\n const subdir = path.join(moduleDir, type);\n const fileStructure = getFileModuleComponentsFileStructure(modelName);\n const result: Record<string, any> = {};\n\n if (!(await pathExists(subdir))) return result;\n\n try {\n await Promise.all(\n Object.entries(fileStructure[type]).map(async ([key, fileName]) => {\n const filePath = path.join(subdir, fileName);\n if (!fileName || !(await pathExists(filePath))) return;\n\n try {\n const module = await importModule(filePath).catch(\n async (err: any) => {\n if (await pathExists(filePath)) {\n sheu.error(`Failed to import ${fileName}: `);\n console.error(err);\n killServerChildProcess();\n process.exit(1);\n }\n }\n );\n\n const cleanFilePath = `src/modules/${kebabCase(modelName)}/${fileName}`;\n if (type === \"dtos\" && !isClass(module?.default))\n throw Error(\n `ValidationError: Please export as default a valid class under ${cleanFilePath}, in order to use as Dto.`\n );\n else if (type === \"schemas\" && !isZodSchema(module?.default))\n throw Error(\n `ValidationError: Please export as default a valid zod schema under ${cleanFilePath}, in order to use as Schema`\n );\n\n if (module && module?.default) result[key] = module.default;\n } catch (err: any) {\n if (err?.message?.includes(\"ValidationError\")) throw err;\n console.error(err);\n }\n })\n );\n } catch (err: any) {\n if (err?.message?.includes(\"ValidationError\")) throw err;\n console.error(err);\n }\n\n return result;\n}\n\nexport type ModuleComponents = Omit<\n ImportModuleComponentsReturnType,\n \"authConfigsNew\" | \"prismaQueryOptionsNew\"\n>;\n\ntype ImportModuleComponentsReturnType = {\n hooks?: Record<string, ServiceHook | ServiceHook[]>;\n interceptors?: Record<string, Function | Function[]>;\n authConfigs?: AuthConfigs;\n interceptorsOld?: any;\n authConfigsNew?: AuthConfigs;\n prismaQueryOptions?: PrismaQueryOptions<any>;\n prismaQueryOptionsNew?: PrismaQueryOptions<any>;\n router?: { config?: RouterConfig<any>; default: RouterConfig };\n dtos?: {\n create?: any;\n update?: any;\n signup?: any;\n login?: any;\n updatePassword?: any;\n updateMe?: any;\n };\n schemas?: {\n create?: any;\n update?: any;\n signup?: any;\n login?: any;\n updatePassword?: any;\n updateMe?: any;\n };\n};\n\nconst availableInterceptors = {\n auth: [\n \"beforeGetMe\",\n \"afterGetMe\",\n \"onGetMeError\",\n \"beforeUpdateMe\",\n \"afterUpdateMe\",\n \"onUpdateMeError\",\n \"beforeLogin\",\n \"afterLogin\",\n \"onLoginError\",\n \"beforeLogout\",\n \"afterLogout\",\n \"onLogoutError\",\n \"beforeSignup\",\n \"afterSignup\",\n \"onSignupError\",\n \"beforeUpdatePassword\",\n \"afterUpdatePassword\",\n \"onUpdatePasswordError\",\n ],\n \"file-upload\": [\n \"beforeFindFile\",\n \"onFindFileError\",\n \"beforeUploadFile\",\n \"afterUploadFile\",\n \"onUploadFileError\",\n \"beforeUpdateFile\",\n \"afterUpdateFile\",\n \"onUpdateFileError\",\n \"beforeDeleteFile\",\n \"afterDeleteFile\",\n \"onDeleteFileError\",\n ],\n prisma: [\n \"beforeCreateOne\",\n \"afterCreateOne\",\n \"onCreateOneError\",\n \"beforeFindOne\",\n \"afterFindOne\",\n \"onFindOneError\",\n \"beforeFindMany\",\n \"afterFindMany\",\n \"onFindManyError\",\n \"beforeUpdateOne\",\n \"afterUpdateOne\",\n \"onUpdateOneError\",\n \"beforeDeleteOne\",\n \"afterDeleteOne\",\n \"onDeleteOneError\",\n \"beforeCreateMany\",\n \"afterCreateMany\",\n \"onCreateManyError\",\n \"beforeUpdateMany\",\n \"afterUpdateMany\",\n \"onUpdateManyError\",\n \"beforeDeleteMany\",\n \"afterDeleteMany\",\n \"onDeleteManyError\",\n ],\n};\n\n/**\n * Validates naming convention conflicts for prismaQueryOptions and authConfigs\n * @param {string} key - The current file key being processed\n * @param {string} fileName - The filename being imported\n * @param {ImportModuleComponentsReturnType} result - The current result object\n * @throws {Error} When conflicting naming conventions are detected\n */\nexport function validateNamingConventions(\n key: string,\n fileName: string,\n result: ImportModuleComponentsReturnType\n): void {\n if (key === \"interceptorsOld\") {\n if (!result.interceptors)\n sheu.warn(\n `Found deprecated ${fileName} that will removed from v1.5.0-beta, consider switching to ${fileName.replace(\"middlewares\", \"interceptors\")}`\n );\n }\n}\n\n/**\n * Processes and assigns module to the result object based on the key\n * @param {string} key - The file key being processed\n * @param {any} module - The imported module\n * @param {ImportModuleComponentsReturnType} result - The result object to modify\n */\nexport function assignModuleToResult(\n appModule: string,\n key: string,\n module: any,\n result: ImportModuleComponentsReturnType,\n arkosConfig: ArkosConfig\n): void {\n if (key === \"interceptors\") result.interceptors = module;\n else if (key === \"interceptorsOld\") {\n const kebabCaseAppModule = kebabCase(appModule);\n const moduleName =\n kebabCaseAppModule === \"auth\"\n ? \"auth\"\n : kebabCaseAppModule === \"file-upload\"\n ? \"file-upload\"\n : \"prisma\";\n\n if (\n result.interceptors &&\n Object.keys(module).some((interceptorName) =>\n availableInterceptors[moduleName].includes(interceptorName)\n )\n ) {\n const exportedInterceptors = Object.keys(module).filter(\n (interceptorName) =>\n availableInterceptors[moduleName].includes(interceptorName)\n );\n const ext = getUserFileExtension();\n sheu.warn(\n `Found ${kebabCaseAppModule}.middlewares.${ext} exporting ${exportedInterceptors.join(\", \")}. Which by convention should go at ${kebabCaseAppModule}.interceptors.${ext} This is simply a warning that will stop from v1.5.0-beta`\n );\n } else if (!result.interceptors) result.interceptors = module;\n } else if (key === \"router\") {\n result[key] = {\n ...module,\n config: applyStrictRoutingRules(\n appModule,\n arkosConfig,\n module?.config || {}\n ),\n };\n validateRouterConfigConsistency(result[key]?.config || {});\n } else {\n result[key as keyof typeof result] = module.default || module;\n }\n}\n\n/**\n * Dynamically imports model-specific modules for a given model with optimized file handling.\n * Includes special handling for the Auth module.\n *\n * @param {string} modelName - The name of the model (e.g., \"User\", \"Post\", \"Auth\").\n * @returns {Promise<Object>} An object containing the imported modules\n */\nexport async function importModuleComponents(\n modelName: string,\n arkosConfig: ArkosConfig,\n moduleDirExists?: boolean\n): Promise<ImportModuleComponentsReturnType> {\n const result: ImportModuleComponentsReturnType = {\n dtos: {},\n schemas: {},\n };\n const usingStrictRouting = arkosConfig.routers?.strict;\n\n if (!moduleDirExists && !usingStrictRouting) return result;\n\n if (getModuleComponents(modelName)) return getModuleComponents(modelName);\n\n const moduleDir = path.resolve(crd(), \"src\", \"modules\", kebabCase(modelName));\n const fileStructure = getFileModuleComponentsFileStructure(modelName);\n\n const validationSubdir = arkosConfig.validation?.resolver\n ? arkosConfig.validation.resolver === \"zod\"\n ? \"schemas\"\n : \"dtos\"\n : null;\n\n const [_, validators] = await Promise.all([\n ...Object.entries(fileStructure.core).map(async ([key, fileName]) => {\n if (\n [\"createMany\", \"findMany\", \"findOne\", \"updateMany\"].includes(key) ||\n !fileName\n )\n return;\n\n const filePath = path.join(moduleDir, fileName);\n\n if (\n key === \"router\" &&\n !usingStrictRouting &&\n !(await pathExists(filePath))\n )\n return;\n else if (\n key !== \"router\" &&\n usingStrictRouting &&\n !(await pathExists(filePath))\n )\n return;\n\n try {\n let module = await importModule(filePath).catch(async (err) => {\n try {\n if (await pathExists(filePath)) {\n sheu.error(`Failed to import ${fileName}`);\n console.error(err);\n killServerChildProcess();\n process.exit(1);\n }\n } catch (err) {}\n });\n\n if (!module && key === \"router\" && usingStrictRouting) module = {};\n\n if (module) {\n (result as any)[key] = module;\n validateNamingConventions(key, fileName, result);\n assignModuleToResult(modelName, key, module, result, arkosConfig);\n }\n } catch (err: any) {\n if (err.message?.includes(\"Cannot use both\")) throw err;\n console.error(err);\n killServerChildProcess();\n }\n }),\n validationSubdir && processSubdir(modelName, validationSubdir),\n ]);\n\n prismaModelsModules[pascalCase(modelName)] = {\n ...result,\n ...(validationSubdir && { [validationSubdir]: validators }),\n };\n\n return {\n ...result,\n ...(validationSubdir && { [validationSubdir]: validators }),\n };\n}\n\nexport const appModules = Array.from(\n new Set([\n \"auth\",\n \"file-upload\",\n ...prismaSchemaParser.getModelsAsArrayOfStrings(),\n ])\n);\n\n/**\n * Allows to asynchronously load all app modules components at once to speed up app start time.\n */\nexport async function loadAllModuleComponents(arkosConfig: ArkosConfig) {\n const moduleDirExists: string[] = [];\n await Promise.all(\n appModules.map(async (appModule) => {\n const moduleDir = path.resolve(\n crd(),\n \"src\",\n \"modules\",\n kebabCase(appModule)\n );\n if (await pathExists(moduleDir)) moduleDirExists.push(appModule);\n })\n );\n\n const modulesComponentsImportPromises = appModules.map(\n async (appModule) =>\n await importModuleComponents(\n appModule,\n arkosConfig,\n moduleDirExists.includes(appModule)\n )\n );\n\n const modulesComponents = await Promise.all(modulesComponentsImportPromises);\n debuggerService.logDynamicLoadedModulesComponents(\n modulesComponents.map((components, i) => {\n const moduleDir = path.resolve(\n crd(),\n \"src\",\n \"modules\",\n kebabCase(appModules[i])\n );\n\n return {\n moduleName: kebabCase(appModules[i]),\n moduleDir,\n components,\n };\n })\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dynamic-loader.js","sourceRoot":"","sources":["../../../src/utils/dynamic-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAc,MAAM,KAAK,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,EACL,uBAAuB,EACvB,UAAU,EACV,+BAA+B,GAChC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MA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SAAS,CAAC,CACpC,CACJ,CAAC;IAEF,MAAM,iBAAiB,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;IAC7E,eAAe,CAAC,iCAAiC,CAC/C,iBAAiB,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE;QACtC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAC5B,GAAG,EAAE,EACL,KAAK,EACL,SAAS,EACT,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CACzB,CAAC;QAEF,OAAO;YACL,UAAU,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YACpC,SAAS;YACT,UAAU;SACX,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { z, ZodTypeAny } from \"zod\";\nimport path from \"path\";\nimport { AuthConfigs } from \"../types/auth\";\nimport { killServerChildProcess } from \"./cli/utils/cli.helpers\";\nimport { ArkosConfig, RouterConfig } from \"../exports\";\nimport sheu from \"./sheu\";\nimport {\n applyStrictRoutingRules,\n pathExists,\n validateRouterConfigConsistency,\n} from \"./helpers/dynamic-loader.helpers\";\nimport { kebabCase, pascalCase } from \"./helpers/change-case.helpers\";\nimport { crd, getUserFileExtension } from \"./helpers/fs.helpers\";\nimport { importModule } from \"./helpers/global.helpers\";\nimport prismaSchemaParser from \"./prisma/prisma-schema-parser\";\nimport debuggerService from \"../modules/debugger/debugger.service\";\nimport { PrismaQueryOptions } from \"../types\";\nimport { ServiceHook } from \"../modules/base/utils/service-hooks-manager\";\n\ntype AppModuleComponent = Awaited<ReturnType<typeof importModuleComponents>>;\n\nlet prismaModelsModules: Record<string, AppModuleComponent> = {};\n\n/** This was a workaround when testing and also when cjs was generated while `prismaModelsModules` was exported there where some problems */\nexport function setModuleComponents(\n modelName: string,\n modules: AppModuleComponent\n) {\n prismaModelsModules[pascalCase(modelName)] = modules;\n}\n\nexport function getModuleComponents(modelName: string) {\n return prismaModelsModules[pascalCase(modelName)];\n}\n\n/**\n * To be reused on other part of code for correct typing\n *\n * @param key\n * @param fileName\n * @param result\n */\nexport type ValidationFileMappingKey = keyof ReturnType<\n typeof getFileModuleComponentsFileStructure\n>[\"dtos\"];\n\nexport function getFileModuleComponentsFileStructure(modelName: string) {\n const kebabModelName = kebabCase(modelName).toLowerCase();\n const isAuthModule = modelName.toLowerCase() === \"auth\";\n const ext = getUserFileExtension();\n\n return {\n core: {\n hooks: `${kebabModelName}.hooks.${ext}`,\n interceptors: `${kebabModelName}.interceptors.${ext}`,\n interceptorsOld: `${kebabModelName}.middlewares.${ext}`,\n authConfigs: `${kebabModelName}.auth.${ext}`,\n prismaQueryOptions: `${kebabModelName}.query.${ext}`,\n router: `${kebabModelName}.router.${ext}`,\n },\n dtos: isAuthModule\n ? {\n login: `login.dto.${ext}`,\n signup: `signup.dto.${ext}`,\n getMe: `get-me.dto.${ext}`,\n updateMe: `update-me.dto.${ext}`,\n updatePassword: `update-password.dto.${ext}`,\n }\n : {\n model: `${kebabModelName}.dto.${ext}`,\n create: `create-${kebabModelName}.dto.${ext}`,\n createOne: `create-${kebabModelName}.dto.${ext}`, // just for sake of completion and reusability around other parts of code\n createMany: ``,\n update: `update-${kebabModelName}.dto.${ext}`,\n updateOne: `update-${kebabModelName}.dto.${ext}`, // same as createOne\n updateMany: ``,\n query: `query-${kebabModelName}.dto.${ext}`,\n // looking for some better naming convetion\n findOne: ``,\n findMany: ``,\n },\n schemas: isAuthModule\n ? {\n login: `login.schema.${ext}`,\n signup: `signup.schema.${ext}`,\n getMe: `get-me.schema.${ext}`,\n updateMe: `update-me.schema.${ext}`,\n updatePassword: `update-password.schema.${ext}`,\n }\n : {\n model: `${kebabModelName}.schema.${ext}`,\n create: `create-${kebabModelName}.schema.${ext}`,\n createOne: `create-${kebabModelName}.schema.${ext}`,\n createMany: ``, // just for sake of completion and reusability around other parts of code\n update: `update-${kebabModelName}.schema.${ext}`,\n updateOne: `update-${kebabModelName}.schema.${ext}`, // same as createOne\n updateMany: ``,\n query: `query-${kebabModelName}.schema.${ext}`,\n // looking for some better naming convetion\n findOne: ``,\n findMany: ``,\n },\n };\n}\n\nexport function isClass(value: any): boolean {\n return (\n typeof value === \"function\" &&\n /^class\\s/.test(Function.prototype.toString.call(value))\n );\n}\n\nexport function isZodSchema(value: any): value is ZodTypeAny {\n return value instanceof z.ZodType;\n}\n\nexport async function processSubdir(\n modelName: string,\n type: \"dtos\" | \"schemas\"\n) {\n const moduleDir = path.resolve(crd(), \"src\", \"modules\", kebabCase(modelName));\n\n const subdir = path.join(moduleDir, type);\n const fileStructure = getFileModuleComponentsFileStructure(modelName);\n const result: Record<string, any> = {};\n\n if (!(await pathExists(subdir))) return result;\n\n try {\n await Promise.all(\n Object.entries(fileStructure[type]).map(async ([key, fileName]) => {\n const filePath = path.join(subdir, fileName);\n if (!fileName || !(await pathExists(filePath))) return;\n\n try {\n const module = await importModule(filePath).catch(\n async (err: any) => {\n if (await pathExists(filePath)) {\n sheu.error(`Failed to import ${fileName}: `);\n console.error(err);\n killServerChildProcess();\n process.exit(1);\n }\n }\n );\n\n const cleanFilePath = `src/modules/${kebabCase(modelName)}/${fileName}`;\n if (type === \"dtos\" && !isClass(module?.default))\n throw Error(\n `ValidationError: Please export as default a valid class under ${cleanFilePath}, in order to use as Dto.`\n );\n else if (type === \"schemas\" && !isZodSchema(module?.default))\n throw Error(\n `ValidationError: Please export as default a valid zod schema under ${cleanFilePath}, in order to use as Schema`\n );\n\n if (module && module?.default) result[key] = module.default;\n } catch (err: any) {\n if (err?.message?.includes(\"ValidationError\")) throw err;\n console.error(err);\n }\n })\n );\n } catch (err: any) {\n if (err?.message?.includes(\"ValidationError\")) throw err;\n console.error(err);\n }\n\n return result;\n}\n\nexport type ModuleComponents = Omit<\n ImportModuleComponentsReturnType,\n \"authConfigsNew\" | \"prismaQueryOptionsNew\"\n>;\n\ntype ImportModuleComponentsReturnType = {\n hooks?: Record<string, ServiceHook | ServiceHook[]>;\n interceptors?: Record<string, Function | Function[]>;\n authConfigs?: AuthConfigs;\n interceptorsOld?: any;\n authConfigsNew?: AuthConfigs;\n prismaQueryOptions?: PrismaQueryOptions<any>;\n prismaQueryOptionsNew?: PrismaQueryOptions<any>;\n router?: { config?: RouterConfig<any>; default: RouterConfig };\n dtos?: {\n create?: any;\n update?: any;\n signup?: any;\n login?: any;\n updatePassword?: any;\n updateMe?: any;\n };\n schemas?: {\n create?: any;\n update?: any;\n signup?: any;\n login?: any;\n updatePassword?: any;\n updateMe?: any;\n };\n};\n\nconst availableInterceptors = {\n auth: [\n \"beforeGetMe\",\n \"afterGetMe\",\n \"onGetMeError\",\n \"beforeUpdateMe\",\n \"afterUpdateMe\",\n \"onUpdateMeError\",\n \"beforeLogin\",\n \"afterLogin\",\n \"onLoginError\",\n \"beforeLogout\",\n \"afterLogout\",\n \"onLogoutError\",\n \"beforeSignup\",\n \"afterSignup\",\n \"onSignupError\",\n \"beforeUpdatePassword\",\n \"afterUpdatePassword\",\n \"onUpdatePasswordError\",\n ],\n \"file-upload\": [\n \"beforeFindFile\",\n \"onFindFileError\",\n \"beforeUploadFile\",\n \"afterUploadFile\",\n \"onUploadFileError\",\n \"beforeUpdateFile\",\n \"afterUpdateFile\",\n \"onUpdateFileError\",\n \"beforeDeleteFile\",\n \"afterDeleteFile\",\n \"onDeleteFileError\",\n ],\n prisma: [\n \"beforeCreateOne\",\n \"afterCreateOne\",\n \"onCreateOneError\",\n \"beforeFindOne\",\n \"afterFindOne\",\n \"onFindOneError\",\n \"beforeFindMany\",\n \"afterFindMany\",\n \"onFindManyError\",\n \"beforeUpdateOne\",\n \"afterUpdateOne\",\n \"onUpdateOneError\",\n \"beforeDeleteOne\",\n \"afterDeleteOne\",\n \"onDeleteOneError\",\n \"beforeCreateMany\",\n \"afterCreateMany\",\n \"onCreateManyError\",\n \"beforeUpdateMany\",\n \"afterUpdateMany\",\n \"onUpdateManyError\",\n \"beforeDeleteMany\",\n \"afterDeleteMany\",\n \"onDeleteManyError\",\n ],\n};\n\n/**\n * Validates naming convention conflicts for prismaQueryOptions and authConfigs\n * @param {string} key - The current file key being processed\n * @param {string} fileName - The filename being imported\n * @param {ImportModuleComponentsReturnType} result - The current result object\n * @throws {Error} When conflicting naming conventions are detected\n */\nexport function validateNamingConventions(\n key: string,\n fileName: string,\n result: ImportModuleComponentsReturnType\n): void {\n if (key === \"interceptorsOld\") {\n if (!result.interceptors)\n sheu.warn(\n `Found deprecated ${fileName} that will removed from v1.5.0-beta, consider switching to ${fileName.replace(\"middlewares\", \"interceptors\")}`\n );\n }\n}\n\n/**\n * Processes and assigns module to the result object based on the key\n * @param {string} key - The file key being processed\n * @param {any} module - The imported module\n * @param {ImportModuleComponentsReturnType} result - The result object to modify\n */\nexport function assignModuleToResult(\n appModule: string,\n key: string,\n module: any,\n result: ImportModuleComponentsReturnType,\n arkosConfig: ArkosConfig\n): void {\n if (key === \"interceptors\") result.interceptors = module;\n else if (key === \"interceptorsOld\") {\n const kebabCaseAppModule = kebabCase(appModule);\n const moduleName =\n kebabCaseAppModule === \"auth\"\n ? \"auth\"\n : kebabCaseAppModule === \"file-upload\"\n ? \"file-upload\"\n : \"prisma\";\n\n if (\n result.interceptors &&\n Object.keys(module).some((interceptorName) =>\n availableInterceptors[moduleName].includes(interceptorName)\n )\n ) {\n const exportedInterceptors = Object.keys(module).filter(\n (interceptorName) =>\n availableInterceptors[moduleName].includes(interceptorName)\n );\n const ext = getUserFileExtension();\n sheu.warn(\n `Found ${kebabCaseAppModule}.middlewares.${ext} exporting ${exportedInterceptors.join(\", \")}. Which by convention should go at ${kebabCaseAppModule}.interceptors.${ext} This is simply a warning that will stop from v1.5.0-beta`\n );\n } else if (!result.interceptors) result.interceptors = module;\n } else if (key === \"router\") {\n result[key] = {\n ...module,\n config: applyStrictRoutingRules(\n appModule,\n arkosConfig,\n module?.config || {}\n ),\n };\n validateRouterConfigConsistency(\n kebabCase(appModule),\n result[key]?.config || {}\n );\n } else {\n result[key as keyof typeof result] = module.default || module;\n }\n}\n\n/**\n * Dynamically imports model-specific modules for a given model with optimized file handling.\n * Includes special handling for the Auth module.\n *\n * @param {string} modelName - The name of the model (e.g., \"User\", \"Post\", \"Auth\").\n * @returns {Promise<Object>} An object containing the imported modules\n */\nexport async function importModuleComponents(\n modelName: string,\n arkosConfig: ArkosConfig,\n moduleDirExists?: boolean\n): Promise<ImportModuleComponentsReturnType> {\n const result: ImportModuleComponentsReturnType = {\n dtos: {},\n schemas: {},\n };\n const usingStrictRouting = arkosConfig.routers?.strict;\n\n if (!moduleDirExists && !usingStrictRouting) return result;\n\n if (getModuleComponents(modelName)) return getModuleComponents(modelName);\n\n const moduleDir = path.resolve(crd(), \"src\", \"modules\", kebabCase(modelName));\n const fileStructure = getFileModuleComponentsFileStructure(modelName);\n\n const validationSubdir = arkosConfig.validation?.resolver\n ? arkosConfig.validation.resolver === \"zod\"\n ? \"schemas\"\n : \"dtos\"\n : null;\n\n const [_, validators] = await Promise.all([\n ...Object.entries(fileStructure.core).map(async ([key, fileName]) => {\n if (\n [\"createMany\", \"findMany\", \"findOne\", \"updateMany\"].includes(key) ||\n !fileName\n )\n return;\n\n const filePath = path.join(moduleDir, fileName);\n\n if (\n key === \"router\" &&\n !usingStrictRouting &&\n !(await pathExists(filePath))\n )\n return;\n else if (\n key !== \"router\" &&\n usingStrictRouting &&\n !(await pathExists(filePath))\n )\n return;\n\n try {\n let module = await importModule(filePath).catch(async (err) => {\n try {\n if (await pathExists(filePath)) {\n sheu.error(`Failed to import ${fileName}`);\n console.error(err);\n killServerChildProcess();\n process.exit(1);\n }\n } catch (err) {}\n });\n\n if (!module && key === \"router\" && usingStrictRouting) module = {};\n\n if (module) {\n (result as any)[key] = module;\n validateNamingConventions(key, fileName, result);\n assignModuleToResult(modelName, key, module, result, arkosConfig);\n }\n } catch (err: any) {\n if (err.message?.includes(\"Cannot use both\")) throw err;\n console.error(err);\n killServerChildProcess();\n }\n }),\n validationSubdir && processSubdir(modelName, validationSubdir),\n ]);\n\n prismaModelsModules[pascalCase(modelName)] = {\n ...result,\n ...(validationSubdir && { [validationSubdir]: validators }),\n };\n\n return {\n ...result,\n ...(validationSubdir && { [validationSubdir]: validators }),\n };\n}\n\nexport const appModules = Array.from(\n new Set([\n \"auth\",\n \"file-upload\",\n ...prismaSchemaParser.getModelsAsArrayOfStrings(),\n ])\n);\n\n/**\n * Allows to asynchronously load all app modules components at once to speed up app start time.\n */\nexport async function loadAllModuleComponents(arkosConfig: ArkosConfig) {\n const moduleDirExists: string[] = [];\n await Promise.all(\n appModules.map(async (appModule) => {\n const moduleDir = path.resolve(\n crd(),\n \"src\",\n \"modules\",\n kebabCase(appModule)\n );\n if (await pathExists(moduleDir)) moduleDirExists.push(appModule);\n })\n );\n\n const modulesComponentsImportPromises = appModules.map(\n async (appModule) =>\n await importModuleComponents(\n appModule,\n arkosConfig,\n moduleDirExists.includes(appModule)\n )\n );\n\n const modulesComponents = await Promise.all(modulesComponentsImportPromises);\n debuggerService.logDynamicLoadedModulesComponents(\n modulesComponents.map((components, i) => {\n const moduleDir = path.resolve(\n crd(),\n \"src\",\n \"modules\",\n kebabCase(appModules[i])\n );\n\n return {\n moduleName: kebabCase(appModules[i]),\n moduleDir,\n components,\n };\n })\n );\n}\n"]}
|
|
@@ -75,9 +75,7 @@ export function applyStrictRoutingRules(appModule, arkosConfig, moduleConfig) {
|
|
|
75
75
|
const disableConfig = deepmerge(strictDefaults, config?.disable || {});
|
|
76
76
|
const endpointConfigs = {};
|
|
77
77
|
for (const endpoint of Object.keys(strictDefaults)) {
|
|
78
|
-
endpointConfigs[endpoint] = deepmerge(config[endpoint] || {}
|
|
79
|
-
disabled: strictDefaults[endpoint],
|
|
80
|
-
});
|
|
78
|
+
endpointConfigs[endpoint] = deepmerge({ disabled: strictDefaults[endpoint] }, config[endpoint] || {});
|
|
81
79
|
}
|
|
82
80
|
const syncedDisable = { ...disableConfig };
|
|
83
81
|
for (const endpoint of allEndpoints) {
|
|
@@ -88,9 +86,9 @@ export function applyStrictRoutingRules(appModule, arkosConfig, moduleConfig) {
|
|
|
88
86
|
}
|
|
89
87
|
const syncedEndpoints = { ...endpointConfigs };
|
|
90
88
|
for (const endpoint of allEndpoints) {
|
|
91
|
-
if (
|
|
89
|
+
if (syncedDisable[endpoint] !== undefined) {
|
|
92
90
|
syncedEndpoints[endpoint] = deepmerge(syncedEndpoints[endpoint] || {}, {
|
|
93
|
-
disabled:
|
|
91
|
+
disabled: syncedDisable[endpoint],
|
|
94
92
|
});
|
|
95
93
|
}
|
|
96
94
|
}
|
|
@@ -109,9 +107,7 @@ export function applyStrictRoutingRules(appModule, arkosConfig, moduleConfig) {
|
|
|
109
107
|
const disableConfig = deepmerge(noBulkDefaults, config.disable || {});
|
|
110
108
|
const endpointConfigs = {};
|
|
111
109
|
for (const endpoint of Object.keys(noBulkDefaults)) {
|
|
112
|
-
endpointConfigs[endpoint] = deepmerge(config[endpoint] || {}
|
|
113
|
-
disabled: noBulkDefaults[endpoint],
|
|
114
|
-
});
|
|
110
|
+
endpointConfigs[endpoint] = deepmerge({ disabled: noBulkDefaults[endpoint] }, config[endpoint] || {});
|
|
115
111
|
}
|
|
116
112
|
const syncedDisable = { ...disableConfig };
|
|
117
113
|
for (const endpoint of allEndpoints) {
|
|
@@ -123,9 +119,7 @@ export function applyStrictRoutingRules(appModule, arkosConfig, moduleConfig) {
|
|
|
123
119
|
const syncedEndpoints = { ...endpointConfigs };
|
|
124
120
|
for (const endpoint of allEndpoints) {
|
|
125
121
|
if (syncedDisable[endpoint] !== undefined) {
|
|
126
|
-
syncedEndpoints[endpoint] = deepmerge(syncedEndpoints[endpoint] || {}
|
|
127
|
-
disabled: syncedDisable[endpoint],
|
|
128
|
-
});
|
|
122
|
+
syncedEndpoints[endpoint] = deepmerge({ disabled: syncedDisable[endpoint] }, syncedEndpoints[endpoint] || {});
|
|
129
123
|
}
|
|
130
124
|
}
|
|
131
125
|
return deepmerge(config, {
|
|
@@ -135,7 +129,7 @@ export function applyStrictRoutingRules(appModule, arkosConfig, moduleConfig) {
|
|
|
135
129
|
}
|
|
136
130
|
return config;
|
|
137
131
|
}
|
|
138
|
-
export function validateRouterConfigConsistency(config) {
|
|
132
|
+
export function validateRouterConfigConsistency(appModule, config) {
|
|
139
133
|
if (!config.disable || typeof config.disable === "boolean")
|
|
140
134
|
return;
|
|
141
135
|
const endpoints = Object.keys(config.disable);
|
|
@@ -145,7 +139,7 @@ export function validateRouterConfigConsistency(config) {
|
|
|
145
139
|
if (oldWayValue !== undefined &&
|
|
146
140
|
newWayValue !== undefined &&
|
|
147
141
|
oldWayValue !== newWayValue) {
|
|
148
|
-
throw new Error(`Conflicting disabled values for endpoint "${endpoint}": ` +
|
|
142
|
+
throw new Error(`Conflicting disabled values for endpoint "${endpoint}" of module ${appModule}: ` +
|
|
149
143
|
`disable.${endpoint} = ${oldWayValue}, but ${endpoint}.disabled = ${newWayValue}. ` +
|
|
150
144
|
`Please use only one method to disable endpoints.`);
|
|
151
145
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-loader.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/dynamic-loader.helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAK3C,MAAM,UAAU,uBAAuB,CACrC,SAAY,EACZ,WAAwB,EACxB,YAA8B;IAE9B,MAAM,UAAU,GAAG,WAAW,EAAE,OAAO,EAAE,MAAM,IAAI,KAAK,CAAC;IACzD,IAAI,MAAM,GAAQ,YAAY,IAAK,EAAsB,CAAC;IAC1D,SAAS,GAAG,SAAS,CAAC,WAAW,EAAO,CAAC;IAEzC,MAAM,YAAY,GAChB,SAAS,KAAK,MAAM;QAClB,CAAC,CAAC;YACE,OAAO;YACP,UAAU;YACV,UAAU;YACV,OAAO;YACP,QAAQ;YACR,QAAQ;YACR,gBAAgB;YAChB,oBAAoB;SACrB;QACH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C;IACf,CAAC;AACH,CAAC","sourcesContent":["import { ArkosConfig, RouterConfig } from \"../../exports\";\nimport fs from \"fs\";\nimport deepmerge from \"./deepmerge.helper\";\n\n/**\n * Applies strict routing rules to module configuration\n */\nexport function applyStrictRoutingRules<T extends string>(\n appModule: T,\n arkosConfig: ArkosConfig,\n moduleConfig?: RouterConfig<T>\n): RouterConfig<T> {\n const strictMode = arkosConfig?.routers?.strict || false;\n let config: any = moduleConfig || ({} as RouterConfig<T>);\n appModule = appModule.toLowerCase() as T;\n\n const allEndpoints =\n appModule === \"auth\"\n ? [\n \"getMe\",\n \"updateMe\",\n \"deleteMe\",\n \"login\",\n \"logout\",\n \"signup\",\n \"updatePassword\",\n \"findManyAuthAction\",\n ]\n : appModule === \"file-upload\"\n ? [\"findFile\", \"uploadFile\", \"updateFile\", \"deleteFile\"]\n : [\n \"createOne\",\n \"findOne\",\n \"updateOne\",\n \"deleteOne\",\n \"createMany\",\n \"findMany\",\n \"updateMany\",\n \"deleteMany\",\n ];\n\n const hadBooleanDisable = typeof config.disable === \"boolean\";\n\n if (hadBooleanDisable) {\n const disableValue = config.disable;\n const disableObject: Record<string, boolean> = {};\n const endpointConfigs: Record<string, any> = {};\n\n for (const endpoint of allEndpoints) {\n (disableObject as any)[endpoint] = disableValue;\n endpointConfigs[endpoint] = deepmerge((config as any)[endpoint] || {}, {\n disabled: disableValue,\n });\n }\n\n return deepmerge(config as any, {\n disable: disableObject,\n ...endpointConfigs,\n }) as RouterConfig<T>;\n }\n\n if (strictMode === true) {\n const strictDefaults: any =\n appModule === \"auth\"\n ? {\n getMe: true,\n updateMe: true,\n deleteMe: true,\n login: true,\n logout: true,\n signup: true,\n updatePassword: true,\n findManyAuthAction: true,\n }\n : appModule === \"file-upload\"\n ? {\n findFile: true,\n uploadFile: true,\n updateFile: true,\n deleteFile: true,\n }\n : {\n createOne: true,\n findOne: true,\n updateOne: true,\n deleteOne: true,\n createMany: true,\n findMany: true,\n updateMany: true,\n deleteMany: true,\n };\n\n const disableConfig: any = deepmerge(\n strictDefaults,\n (config?.disable as any) || {}\n );\n\n const endpointConfigs: Record<string, any> = {};\n for (const endpoint of Object.keys(strictDefaults)) {\n endpointConfigs[endpoint] = deepmerge((config as any)[endpoint] || {}, {\n disabled: strictDefaults[endpoint],\n });\n }\n\n const syncedDisable: Record<string, boolean> = { ...disableConfig };\n for (const endpoint of allEndpoints) {\n const endpointDisabled = (config as any)[endpoint]?.disabled;\n if (endpointDisabled !== undefined) {\n syncedDisable[endpoint] = endpointDisabled;\n }\n }\n\n const syncedEndpoints: Record<string, any> = { ...endpointConfigs };\n for (const endpoint of allEndpoints) {\n if (disableConfig[endpoint] !== undefined) {\n syncedEndpoints[endpoint] = deepmerge(syncedEndpoints[endpoint] || {}, {\n disabled: disableConfig[endpoint],\n });\n }\n }\n\n return deepmerge(config, {\n disable: syncedDisable,\n ...syncedEndpoints,\n }) as RouterConfig<T>;\n } else if (\n strictMode === \"no-bulk\" &&\n ![\"auth\", \"file-upload\"].includes(appModule.toLowerCase())\n ) {\n const noBulkDefaults: any = {\n createMany: true,\n updateMany: true,\n deleteMany: true,\n };\n\n const disableConfig: any = deepmerge(\n noBulkDefaults,\n (config.disable as any) || {}\n );\n\n const endpointConfigs: Record<string, any> = {};\n for (const endpoint of Object.keys(noBulkDefaults)) {\n endpointConfigs[endpoint] = deepmerge((config as any)[endpoint] || {}, {\n disabled: noBulkDefaults[endpoint],\n });\n }\n\n const syncedDisable: Record<string, boolean> = { ...disableConfig };\n for (const endpoint of allEndpoints) {\n const endpointDisabled = (config as any)[endpoint]?.disabled;\n if (endpointDisabled !== undefined) {\n syncedDisable[endpoint] = endpointDisabled;\n }\n }\n\n const syncedEndpoints: Record<string, any> = { ...endpointConfigs };\n for (const endpoint of allEndpoints) {\n if (syncedDisable[endpoint] !== undefined) {\n syncedEndpoints[endpoint] = deepmerge(syncedEndpoints[endpoint] || {}, {\n disabled: syncedDisable[endpoint],\n });\n }\n }\n\n return deepmerge(config as any, {\n disable: syncedDisable,\n ...syncedEndpoints,\n }) as RouterConfig<T>;\n }\n\n return config;\n}\n\nexport function validateRouterConfigConsistency(\n config: Record<string, any>\n): void {\n if (!config.disable || typeof config.disable === \"boolean\") return;\n\n const endpoints = Object.keys(config.disable) as any[];\n\n for (const endpoint of endpoints) {\n const oldWayValue = (config.disable as any)[endpoint];\n const newWayValue = (config as any)[endpoint]?.disabled;\n\n if (\n oldWayValue !== undefined &&\n newWayValue !== undefined &&\n oldWayValue !== newWayValue\n ) {\n throw new Error(\n `Conflicting disabled values for endpoint \"${endpoint}\": ` +\n `disable.${endpoint} = ${oldWayValue}, but ${endpoint}.disabled = ${newWayValue}. ` +\n `Please use only one method to disable endpoints.`\n );\n }\n }\n}\n\nexport async function pathExists(path: string) {\n try {\n await fs.promises.stat(path);\n return true;\n } catch (err) {\n return false;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dynamic-loader.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/dynamic-loader.helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAK3C,MAAM,UAAU,uBAAuB,CACrC,SAAY,EACZ,WAAwB,EACxB,YAA8B;IAE9B,MAAM,UAAU,GAAG,WAAW,EAAE,OAAO,EAAE,MAAM,IAAI,KAAK,CAAC;IACzD,IAAI,MAAM,GAAQ,YAAY,IAAK,EAAsB,CAAC;IAC1D,SAAS,GAAG,SAAS,CAAC,WAAW,EAAO,CAAC;IAEzC,MAAM,YAAY,GAChB,SAAS,KAAK,MAAM;QAClB,CAAC,CAAC;YACE,OAAO;YACP,UAAU;YACV,UAAU;YACV,OAAO;YACP,QAAQ;YACR,QAAQ;YACR,gBAAgB;YAChB,oBAAoB;SACrB;QACH,CAAC,CAAC,SAAS,KAAK,aAAa;YAC3B,CAAC,CAAC,CAAC,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,CAAC;YACxD,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port deepmerge from \"./deepmerge.helper\";\n\n/**\n * Applies strict routing rules to module configuration\n */\nexport function applyStrictRoutingRules<T extends string>(\n appModule: T,\n arkosConfig: ArkosConfig,\n moduleConfig?: RouterConfig<T>\n): RouterConfig<T> {\n const strictMode = arkosConfig?.routers?.strict || false;\n let config: any = moduleConfig || ({} as RouterConfig<T>);\n appModule = appModule.toLowerCase() as T;\n\n const allEndpoints =\n appModule === \"auth\"\n ? [\n \"getMe\",\n \"updateMe\",\n \"deleteMe\",\n \"login\",\n \"logout\",\n \"signup\",\n \"updatePassword\",\n \"findManyAuthAction\",\n ]\n : appModule === \"file-upload\"\n ? [\"findFile\", \"uploadFile\", \"updateFile\", \"deleteFile\"]\n : [\n \"createOne\",\n \"findOne\",\n \"updateOne\",\n \"deleteOne\",\n \"createMany\",\n \"findMany\",\n \"updateMany\",\n \"deleteMany\",\n ];\n\n const hadBooleanDisable = typeof config.disable === \"boolean\";\n\n // IMPORTANT: Order matters in deepmerge!\n // User config must be SECOND argument to override defaults\n\n if (hadBooleanDisable) {\n const disableValue = config.disable;\n const disableObject: Record<string, boolean> = {};\n const endpointConfigs: Record<string, any> = {};\n\n for (const endpoint of allEndpoints) {\n (disableObject as any)[endpoint] = disableValue;\n endpointConfigs[endpoint] = deepmerge((config as any)[endpoint] || {}, {\n disabled: disableValue,\n });\n }\n\n return deepmerge(config as any, {\n disable: disableObject,\n ...endpointConfigs,\n }) as RouterConfig<T>;\n }\n\n if (strictMode === true) {\n const strictDefaults: any =\n appModule === \"auth\"\n ? {\n getMe: true,\n updateMe: true,\n deleteMe: true,\n login: true,\n logout: true,\n signup: true,\n updatePassword: true,\n findManyAuthAction: true,\n }\n : appModule === \"file-upload\"\n ? {\n findFile: true,\n uploadFile: true,\n updateFile: true,\n deleteFile: true,\n }\n : {\n createOne: true,\n findOne: true,\n updateOne: true,\n deleteOne: true,\n createMany: true,\n findMany: true,\n updateMany: true,\n deleteMany: true,\n };\n\n const disableConfig: any = deepmerge(\n strictDefaults,\n (config?.disable as any) || {}\n );\n\n const endpointConfigs: Record<string, any> = {};\n for (const endpoint of Object.keys(strictDefaults)) {\n endpointConfigs[endpoint] = deepmerge(\n { disabled: strictDefaults[endpoint] },\n (config as any)[endpoint] || {}\n );\n }\n\n const syncedDisable: Record<string, boolean> = { ...disableConfig };\n for (const endpoint of allEndpoints) {\n const endpointDisabled = (config as any)[endpoint]?.disabled;\n if (endpointDisabled !== undefined) {\n syncedDisable[endpoint] = endpointDisabled;\n }\n }\n\n const syncedEndpoints: Record<string, any> = { ...endpointConfigs };\n for (const endpoint of allEndpoints) {\n if (syncedDisable[endpoint] !== undefined) {\n syncedEndpoints[endpoint] = deepmerge(syncedEndpoints[endpoint] || {}, {\n disabled: syncedDisable[endpoint],\n });\n }\n }\n\n return deepmerge(config as any, {\n disable: syncedDisable,\n ...syncedEndpoints,\n }) as RouterConfig<T>;\n } else if (\n strictMode === \"no-bulk\" &&\n ![\"auth\", \"file-upload\"].includes(appModule.toLowerCase())\n ) {\n const noBulkDefaults: any = {\n createMany: true,\n updateMany: true,\n deleteMany: true,\n };\n\n const disableConfig: any = deepmerge(\n noBulkDefaults,\n (config.disable as any) || {}\n );\n\n const endpointConfigs: Record<string, any> = {};\n for (const endpoint of Object.keys(noBulkDefaults)) {\n endpointConfigs[endpoint] = deepmerge(\n { disabled: noBulkDefaults[endpoint] },\n (config as any)[endpoint] || {}\n );\n }\n\n const syncedDisable: Record<string, boolean> = { ...disableConfig };\n for (const endpoint of allEndpoints) {\n const endpointDisabled = (config as any)[endpoint]?.disabled;\n if (endpointDisabled !== undefined) {\n syncedDisable[endpoint] = endpointDisabled;\n }\n }\n\n const syncedEndpoints: Record<string, any> = { ...endpointConfigs };\n for (const endpoint of allEndpoints) {\n if (syncedDisable[endpoint] !== undefined) {\n syncedEndpoints[endpoint] = deepmerge(\n { disabled: syncedDisable[endpoint] },\n syncedEndpoints[endpoint] || {}\n );\n }\n }\n\n return deepmerge(config as any, {\n disable: syncedDisable,\n ...syncedEndpoints,\n }) as RouterConfig<T>;\n }\n\n return config;\n}\n\nexport function validateRouterConfigConsistency(\n appModule: string,\n config: Record<string, any>\n): void {\n if (!config.disable || typeof config.disable === \"boolean\") return;\n\n const endpoints = Object.keys(config.disable) as any[];\n\n for (const endpoint of endpoints) {\n const oldWayValue = (config.disable as any)[endpoint];\n const newWayValue = (config as any)[endpoint]?.disabled;\n\n if (\n oldWayValue !== undefined &&\n newWayValue !== undefined &&\n oldWayValue !== newWayValue\n ) {\n throw new Error(\n `Conflicting disabled values for endpoint \"${endpoint}\" of module ${appModule}: ` +\n `disable.${endpoint} = ${oldWayValue}, but ${endpoint}.disabled = ${newWayValue}. ` +\n `Please use only one method to disable endpoints.`\n );\n }\n }\n}\n\nexport async function pathExists(path: string) {\n try {\n await fs.promises.stat(path);\n return true;\n } catch (err) {\n return false;\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ArkosConfig, RouterConfig } from "../../exports";
|
|
2
2
|
export declare function applyStrictRoutingRules<T extends string>(appModule: T, arkosConfig: ArkosConfig, moduleConfig?: RouterConfig<T>): RouterConfig<T>;
|
|
3
|
-
export declare function validateRouterConfigConsistency(config: Record<string, any>): void;
|
|
3
|
+
export declare function validateRouterConfigConsistency(appModule: string, config: Record<string, any>): void;
|
|
4
4
|
export declare function pathExists(path: string): Promise<boolean>;
|