arkos 1.4.0-canary.65 → 1.4.0-canary.67

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.
@@ -19,6 +19,6 @@ function killServerChildProcess() {
19
19
  (0, start_1.killProductionServerChildProcess)();
20
20
  }
21
21
  function getVersion() {
22
- return "1.4.0-canary.65";
22
+ return "1.4.0-canary.67";
23
23
  }
24
24
  //# sourceMappingURL=cli.helpers.js.map
@@ -30,7 +30,10 @@ ${modelName.camel}Router.get(
30
30
  route: "/custom-endpoint",
31
31
  authentication: { action: "CustomAction", resource: "${modelName.kebab}" },
32
32
  validation: {},
33
- openapi: {}
33
+ experimental: {
34
+ openapi: {},
35
+ // uploads: {}
36
+ }
34
37
  },
35
38
  ${controllerHandlerLine}
36
39
  )
@@ -1 +1 @@
1
- {"version":3,"file":"router-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/router-template.ts"],"names":[],"mappings":";;AAMA,wDAgDC;AAtDD,+DAGwC;AAGxC,SAAgB,sBAAsB,CAAC,OAAwB;IAC7D,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAEvC,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IAEjE,MAAM,GAAG,GAAG,IAAA,iCAAoB,GAAE,CAAC;IACnC,MAAM,cAAc,GAClB,OAAO,EAAE,UAAU,IAAI,KAAK,SAAS,CAAC,KAAK,eAAe,GAAG,EAAE,CAAC;IAElE,MAAM,kBAAkB,GAAG,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;IAChE,MAAM,wBAAwB,GAC5B,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,sCAAsC,CAAC,CAAC,CAAC,EAAE,CAAC;IAE7D,MAAM,gBAAgB,GAAG,IAAA,4BAAe,EAAC,cAAc,CAAC,CAAC;IAEzD,MAAM,oBAAoB,GAAG,gBAAgB;QAC3C,CAAC,CAAC,UAAU,SAAS,CAAC,KAAK,oBACvB,OAAO,EAAE,UAAU;YACnB,KAAK,SAAS,CAAC,KAAK,cAAc,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,EAClE,GAAG;QACL,CAAC,CAAC,UAAU,SAAS,CAAC,KAAK,oBACvB,OAAO,EAAE,UAAU;YACnB,KAAK,SAAS,CAAC,KAAK,cAAc,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,EAClE,GAAG,CAAC;IAER,MAAM,qBAAqB,GAAG,GAAG,SAAS,CAAC,KAAK,wBAAwB,CAAC;IAEzE,OAAO;EACP,oBAAoB;EACpB,wBAAwB;;qBAEL,kBAAkB;;QAE/B,SAAS,CAAC,KAAK;;EAErB,SAAS,CAAC,KAAK;;;2DAG0C,SAAS,CAAC,KAAK;;;;IAItE,qBAAqB;;;iBAGR,SAAS,CAAC,KAAK;CAC/B,CAAC;AACF,CAAC","sourcesContent":["import {\n checkFileExists,\n getUserFileExtension,\n} from \"../../../../helpers/fs.helpers\";\nimport { TemplateOptions } from \"../../template-generators\";\n\nexport function generateRouterTemplate(options: TemplateOptions): string {\n const { modelName, imports } = options;\n\n if (!modelName)\n throw new Error(\"Module name is required for router template\");\n\n const ext = getUserFileExtension();\n const controllerPath =\n imports?.controller || `./${modelName.kebab}.controller.${ext}`;\n\n const routerConfigTsType = ext === \"ts\" ? \": RouterConfig\" : \"\";\n const routerConfigTsTypeImport =\n ext === \"ts\" ? \"import { RouterConfig } from 'arkos'\" : \"\";\n\n const controllerExists = checkFileExists(controllerPath);\n\n const controllerImportLine = controllerExists\n ? `import ${modelName.camel}Controller from \"${\n imports?.controller ||\n `./${modelName.kebab}.controller${ext === \"js\" ? \".\" + \"js\" : \"\"}`\n }\"`\n : `import ${modelName.camel}Controller from \"${\n imports?.controller ||\n `./${modelName.kebab}.controller${ext === \"js\" ? \".\" + \"js\" : \"\"}`\n }\"`;\n\n const controllerHandlerLine = `${modelName.camel}Controller.someHandler`;\n\n return `import { ArkosRouter } from 'arkos'\n${controllerImportLine}\n${routerConfigTsTypeImport}\n\nexport const config${routerConfigTsType} = { }\n\nconst ${modelName.camel}Router = ArkosRouter()\n\n${modelName.camel}Router.get(\n {\n route: \"/custom-endpoint\",\n authentication: { action: \"CustomAction\", resource: \"${modelName.kebab}\" },\n validation: {},\n openapi: {}\n },\n ${controllerHandlerLine}\n)\n\nexport default ${modelName.camel}Router\n`;\n}\n"]}
1
+ {"version":3,"file":"router-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/router-template.ts"],"names":[],"mappings":";;AAMA,wDAmDC;AAzDD,+DAGwC;AAGxC,SAAgB,sBAAsB,CAAC,OAAwB;IAC7D,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAEvC,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IAEjE,MAAM,GAAG,GAAG,IAAA,iCAAoB,GAAE,CAAC;IACnC,MAAM,cAAc,GAClB,OAAO,EAAE,UAAU,IAAI,KAAK,SAAS,CAAC,KAAK,eAAe,GAAG,EAAE,CAAC;IAElE,MAAM,kBAAkB,GAAG,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;IAChE,MAAM,wBAAwB,GAC5B,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,sCAAsC,CAAC,CAAC,CAAC,EAAE,CAAC;IAE7D,MAAM,gBAAgB,GAAG,IAAA,4BAAe,EAAC,cAAc,CAAC,CAAC;IAEzD,MAAM,oBAAoB,GAAG,gBAAgB;QAC3C,CAAC,CAAC,UAAU,SAAS,CAAC,KAAK,oBACvB,OAAO,EAAE,UAAU;YACnB,KAAK,SAAS,CAAC,KAAK,cAAc,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,EAClE,GAAG;QACL,CAAC,CAAC,UAAU,SAAS,CAAC,KAAK,oBACvB,OAAO,EAAE,UAAU;YACnB,KAAK,SAAS,CAAC,KAAK,cAAc,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,EAClE,GAAG,CAAC;IAER,MAAM,qBAAqB,GAAG,GAAG,SAAS,CAAC,KAAK,wBAAwB,CAAC;IAEzE,OAAO;EACP,oBAAoB;EACpB,wBAAwB;;qBAEL,kBAAkB;;QAE/B,SAAS,CAAC,KAAK;;EAErB,SAAS,CAAC,KAAK;;;2DAG0C,SAAS,CAAC,KAAK;;;;;;;IAOtE,qBAAqB;;;iBAGR,SAAS,CAAC,KAAK;CAC/B,CAAC;AACF,CAAC","sourcesContent":["import {\n checkFileExists,\n getUserFileExtension,\n} from \"../../../../helpers/fs.helpers\";\nimport { TemplateOptions } from \"../../template-generators\";\n\nexport function generateRouterTemplate(options: TemplateOptions): string {\n const { modelName, imports } = options;\n\n if (!modelName)\n throw new Error(\"Module name is required for router template\");\n\n const ext = getUserFileExtension();\n const controllerPath =\n imports?.controller || `./${modelName.kebab}.controller.${ext}`;\n\n const routerConfigTsType = ext === \"ts\" ? \": RouterConfig\" : \"\";\n const routerConfigTsTypeImport =\n ext === \"ts\" ? \"import { RouterConfig } from 'arkos'\" : \"\";\n\n const controllerExists = checkFileExists(controllerPath);\n\n const controllerImportLine = controllerExists\n ? `import ${modelName.camel}Controller from \"${\n imports?.controller ||\n `./${modelName.kebab}.controller${ext === \"js\" ? \".\" + \"js\" : \"\"}`\n }\"`\n : `import ${modelName.camel}Controller from \"${\n imports?.controller ||\n `./${modelName.kebab}.controller${ext === \"js\" ? \".\" + \"js\" : \"\"}`\n }\"`;\n\n const controllerHandlerLine = `${modelName.camel}Controller.someHandler`;\n\n return `import { ArkosRouter } from 'arkos'\n${controllerImportLine}\n${routerConfigTsTypeImport}\n\nexport const config${routerConfigTsType} = { }\n\nconst ${modelName.camel}Router = ArkosRouter()\n\n${modelName.camel}Router.get(\n {\n route: \"/custom-endpoint\",\n authentication: { action: \"CustomAction\", resource: \"${modelName.kebab}\" },\n validation: {},\n experimental: {\n openapi: {},\n // uploads: {}\n }\n },\n ${controllerHandlerLine}\n)\n\nexport default ${modelName.camel}Router\n`;\n}\n"]}
@@ -227,6 +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
231
  }
231
232
  else {
232
233
  result[key] = module.default || module;
@@ -250,7 +251,7 @@ async function importModuleComponents(modelName, arkosConfig, moduleDirExists) {
250
251
  : "dtos"
251
252
  : null;
252
253
  const [_, validators] = await Promise.all([
253
- Object.entries(fileStructure.core).map(async ([key, fileName]) => {
254
+ ...Object.entries(fileStructure.core).map(async ([key, fileName]) => {
254
255
  if (["createMany", "findMany", "findOne", "updateMany"].includes(key) ||
255
256
  !fileName)
256
257
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"dynamic-loader.js","sourceRoot":"","sources":["../../../src/utils/dynamic-loader.ts"],"names":[],"mappings":";;;;;;AAuBA,kDAKC;AAED,kDAEC;AAaD,oFAyDC;AAED,0BAKC;AAED,kCAEC;AAED,sCAqDC;AAuGD,8DAWC;AAQD,oDA4CC;AASD,wDAoFC;AAaD,0DAwCC;AAheD,6BAAoC;AACpC,gDAAwB;AAExB,yDAAiE;AAEjE,kDAA0B;AAC1B,6EAG0C;AAC1C,uEAAsE;AACtE,qDAAiE;AACjE,6DAAwD;AACxD,yFAA+D;AAC/D,4FAAmE;AAMnE,IAAI,mBAAmB,GAAuC,EAAE,CAAC;AAGjE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,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} 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 } 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,oDA6CC;AASD,wDAoFC;AAaD,0DAwCC;AAleD,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,SAAiB,EACjB,OAA2B;IAE3B,mBAAmB,CAAC,IAAA,gCAAU,EAAC,SAAS,CAAC,CAAC,GAAG,OAAO,CAAC;AACvD,CAAC;AAED,SAAgB,mBAAmB,CAAC,SAAiB;IACnD,OAAO,mBAAmB,CAAC,IAAA,gCAAU,EAAC,SAAS,CAAC,CAAC,CAAC;AACpD,CAAC;AAaD,SAAgB,oCAAoC,CAAC,SAAiB;IACpE,MAAM,cAAc,GAAG,IAAA,+BAAS,EAAC,SAAS,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J,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"]}
@@ -4,66 +4,161 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.applyStrictRoutingRules = applyStrictRoutingRules;
7
+ exports.validateRouterConfigConsistency = validateRouterConfigConsistency;
7
8
  exports.pathExists = pathExists;
8
9
  const fs_1 = __importDefault(require("fs"));
10
+ const deepmerge_helper_1 = __importDefault(require("./deepmerge.helper"));
9
11
  function applyStrictRoutingRules(appModule, arkosConfig, moduleConfig) {
10
12
  const strictMode = arkosConfig?.routers?.strict || false;
11
- const config = moduleConfig || {};
13
+ let config = moduleConfig || {};
12
14
  appModule = appModule.toLowerCase();
13
- if (strictMode === true) {
14
- return {
15
- ...config,
16
- disable: typeof config.disable === "boolean"
17
- ? config.disable
18
- : appModule === "auth"
19
- ? {
20
- getMe: true,
21
- updateMe: true,
22
- deleteMe: true,
23
- login: true,
24
- logout: true,
25
- signup: true,
26
- updatePassword: true,
27
- findManyAuthAction: true,
28
- ...(typeof config.disable === "object" ? config.disable : {}),
29
- }
30
- : appModule === "file-upload"
31
- ? {
32
- findFile: true,
33
- uploadFile: true,
34
- updateFile: true,
35
- deleteFile: true,
36
- ...(typeof config.disable === "object" ? config.disable : {}),
37
- }
38
- : {
39
- createOne: true,
40
- findOne: true,
41
- updateOne: true,
42
- deleteOne: true,
43
- createMany: true,
44
- findMany: true,
45
- updateMany: true,
46
- deleteMany: true,
47
- ...(typeof config.disable === "object" ? config.disable : {}),
48
- },
49
- };
15
+ const allEndpoints = appModule === "auth"
16
+ ? [
17
+ "getMe",
18
+ "updateMe",
19
+ "deleteMe",
20
+ "login",
21
+ "logout",
22
+ "signup",
23
+ "updatePassword",
24
+ "findManyAuthAction",
25
+ ]
26
+ : appModule === "file-upload"
27
+ ? ["findFile", "uploadFile", "updateFile", "deleteFile"]
28
+ : [
29
+ "createOne",
30
+ "findOne",
31
+ "updateOne",
32
+ "deleteOne",
33
+ "createMany",
34
+ "findMany",
35
+ "updateMany",
36
+ "deleteMany",
37
+ ];
38
+ const hadBooleanDisable = typeof config.disable === "boolean";
39
+ if (hadBooleanDisable) {
40
+ const disableValue = config.disable;
41
+ const disableObject = {};
42
+ const endpointConfigs = {};
43
+ for (const endpoint of allEndpoints) {
44
+ disableObject[endpoint] = disableValue;
45
+ endpointConfigs[endpoint] = (0, deepmerge_helper_1.default)(config[endpoint] || {}, {
46
+ disabled: disableValue,
47
+ });
48
+ }
49
+ return (0, deepmerge_helper_1.default)(config, {
50
+ disable: disableObject,
51
+ ...endpointConfigs,
52
+ });
50
53
  }
51
- else if (strictMode === "no-bulk" &&
52
- !["auth", "file-upload"].includes(appModule.toLowerCase())) {
53
- return {
54
- ...config,
55
- disable: typeof config.disable === "boolean"
56
- ? config.disable
54
+ if (strictMode === true) {
55
+ const strictDefaults = appModule === "auth"
56
+ ? {
57
+ getMe: true,
58
+ updateMe: true,
59
+ deleteMe: true,
60
+ login: true,
61
+ logout: true,
62
+ signup: true,
63
+ updatePassword: true,
64
+ findManyAuthAction: true,
65
+ }
66
+ : appModule === "file-upload"
67
+ ? {
68
+ findFile: true,
69
+ uploadFile: true,
70
+ updateFile: true,
71
+ deleteFile: true,
72
+ }
57
73
  : {
74
+ createOne: true,
75
+ findOne: true,
76
+ updateOne: true,
77
+ deleteOne: true,
58
78
  createMany: true,
79
+ findMany: true,
59
80
  updateMany: true,
60
81
  deleteMany: true,
61
- ...(typeof config.disable === "object" ? config.disable : {}),
62
- },
82
+ };
83
+ const disableConfig = (0, deepmerge_helper_1.default)(strictDefaults, config?.disable || {});
84
+ const endpointConfigs = {};
85
+ for (const endpoint of Object.keys(strictDefaults)) {
86
+ endpointConfigs[endpoint] = (0, deepmerge_helper_1.default)(config[endpoint] || {}, {
87
+ disabled: strictDefaults[endpoint],
88
+ });
89
+ }
90
+ const syncedDisable = { ...disableConfig };
91
+ for (const endpoint of allEndpoints) {
92
+ const endpointDisabled = config[endpoint]?.disabled;
93
+ if (endpointDisabled !== undefined) {
94
+ syncedDisable[endpoint] = endpointDisabled;
95
+ }
96
+ }
97
+ const syncedEndpoints = { ...endpointConfigs };
98
+ for (const endpoint of allEndpoints) {
99
+ if (disableConfig[endpoint] !== undefined) {
100
+ syncedEndpoints[endpoint] = (0, deepmerge_helper_1.default)(syncedEndpoints[endpoint] || {}, {
101
+ disabled: disableConfig[endpoint],
102
+ });
103
+ }
104
+ }
105
+ return (0, deepmerge_helper_1.default)(config, {
106
+ disable: syncedDisable,
107
+ ...syncedEndpoints,
108
+ });
109
+ }
110
+ else if (strictMode === "no-bulk" &&
111
+ !["auth", "file-upload"].includes(appModule.toLowerCase())) {
112
+ const noBulkDefaults = {
113
+ createMany: true,
114
+ updateMany: true,
115
+ deleteMany: true,
63
116
  };
117
+ const disableConfig = (0, deepmerge_helper_1.default)(noBulkDefaults, config.disable || {});
118
+ const endpointConfigs = {};
119
+ for (const endpoint of Object.keys(noBulkDefaults)) {
120
+ endpointConfigs[endpoint] = (0, deepmerge_helper_1.default)(config[endpoint] || {}, {
121
+ disabled: noBulkDefaults[endpoint],
122
+ });
123
+ }
124
+ const syncedDisable = { ...disableConfig };
125
+ for (const endpoint of allEndpoints) {
126
+ const endpointDisabled = config[endpoint]?.disabled;
127
+ if (endpointDisabled !== undefined) {
128
+ syncedDisable[endpoint] = endpointDisabled;
129
+ }
130
+ }
131
+ const syncedEndpoints = { ...endpointConfigs };
132
+ for (const endpoint of allEndpoints) {
133
+ if (syncedDisable[endpoint] !== undefined) {
134
+ syncedEndpoints[endpoint] = (0, deepmerge_helper_1.default)(syncedEndpoints[endpoint] || {}, {
135
+ disabled: syncedDisable[endpoint],
136
+ });
137
+ }
138
+ }
139
+ return (0, deepmerge_helper_1.default)(config, {
140
+ disable: syncedDisable,
141
+ ...syncedEndpoints,
142
+ });
64
143
  }
65
144
  return config;
66
145
  }
146
+ function validateRouterConfigConsistency(config) {
147
+ if (!config.disable || typeof config.disable === "boolean")
148
+ return;
149
+ const endpoints = Object.keys(config.disable);
150
+ for (const endpoint of endpoints) {
151
+ const oldWayValue = config.disable[endpoint];
152
+ const newWayValue = config[endpoint]?.disabled;
153
+ if (oldWayValue !== undefined &&
154
+ newWayValue !== undefined &&
155
+ oldWayValue !== newWayValue) {
156
+ throw new Error(`Conflicting disabled values for endpoint "${endpoint}": ` +
157
+ `disable.${endpoint} = ${oldWayValue}, but ${endpoint}.disabled = ${newWayValue}. ` +
158
+ `Please use only one method to disable endpoints.`);
159
+ }
160
+ }
161
+ }
67
162
  async function pathExists(path) {
68
163
  try {
69
164
  await fs_1.default.promises.stat(path);
@@ -1 +1 @@
1
- {"version":3,"file":"dynamic-loader.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/dynamic-loader.helpers.ts"],"names":[],"mappings":";;;;;AAMA,0DAkEC;AAED,gCAOC;AAhFD,4CAAoB;AAKpB,SAAgB,uBAAuB,CACrC,SAAY,EACZ,WAAwB,EACxB,YAA8B;IAE9B,MAAM,UAAU,GAAG,WAAW,EAAE,OAAO,EAAE,MAAM,IAAI,KAAK,CAAC;IACzD,MAAM,MAAM,GAAG,YAAY,IAAK,EAAsB,CAAC;IACvD,SAAS,GAAG,SAAS,CAAC,WAAW,EAAO,CAAC;IAEzC,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;QACxB,OAAO;YACL,GAAG,MAAM;YACT,OAAO,EACL,OAAO,MAAM,CAAC,OAAO,KAAK,SAAS;gBACjC,CAAC,CAAC,MAAM,CAAC,OAAO;gBAChB,CAAC,CAAC,SAAS,KAAK,MAAM;o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CAAC,MAAM,CAAC,OAAO;gBAChB,CAAC,CAAC;oBACE,UAAU,EAAE,IAAI;oBAChB,UAAU,EAAE,IAAI;oBAChB,UAAU,EAAE,IAAI;oBAChB,GAAG,CAAC,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;iBAC9D;SACW,CAAC;IACvB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAEM,KAAK,UAAU,UAAU,CAAC,IAAY;IAC3C,IAAI,CAAC;QACH,MAAM,YAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC","sourcesContent":["import { ArkosConfig, RouterConfig } from \"../../exports\";\nimport fs from \"fs\";\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 const config = moduleConfig || ({} as RouterConfig<T>);\n appModule = appModule.toLowerCase() as T;\n\n if (strictMode === true) {\n return {\n ...config,\n disable:\n typeof config.disable === \"boolean\"\n ? config.disable\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 ...(typeof config.disable === \"object\" ? config.disable : {}),\n }\n : appModule === \"file-upload\"\n ? {\n findFile: true,\n uploadFile: true,\n updateFile: true,\n deleteFile: true,\n ...(typeof config.disable === \"object\" ? config.disable : {}),\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 ...(typeof config.disable === \"object\" ? config.disable : {}),\n },\n } as RouterConfig<T>;\n } else if (\n strictMode === \"no-bulk\" &&\n ![\"auth\", \"file-upload\"].includes(appModule.toLowerCase())\n ) {\n return {\n ...config,\n disable:\n typeof config.disable === \"boolean\"\n ? config.disable\n : {\n createMany: true,\n updateMany: true,\n deleteMany: true,\n ...(typeof config.disable === \"object\" ? config.disable : {}),\n },\n } as RouterConfig<T>;\n }\n\n return config;\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,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,KAAK,aAAa;YAC3B,CAAC,CAAC,CAAC,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,CAAC;YACxD,CAAC,CAAC;gBACE,WAAW;gBACX,SAAS;gBACT,WAAW;gBACX,WAAW;gBACX,YAAY;gBACZ,UAAU;gBACV,YAAY;gBACZ,YAAY;aACb,CAAC;IAEV,MAAM,iBAAiB,GAAG,OAAO,MAAM,CAAC,OAAO,KAAK,SAAS,CAAC;IAE9D,IAAI,i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AC9B,OAAO,EAAE,aAAa;YACtB,GAAG,eAAe;SACnB,CAAoB,CAAC;IACxB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAgB,+BAA+B,CAC7C,MAA2B;IAE3B,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,SAAS;QAAE,OAAO;IAEnE,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAU,CAAC;IAEvD,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,MAAM,WAAW,GAAI,MAAM,CAAC,OAAe,CAAC,QAAQ,CAAC,CAAC;QACtD,MAAM,WAAW,GAAI,MAAc,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;QAExD,IACE,WAAW,KAAK,SAAS;YACzB,WAAW,KAAK,SAAS;YACzB,WAAW,KAAK,WAAW,EAC3B,CAAC;YACD,MAAM,IAAI,KAAK,CACb,6CAA6C,QAAQ,KAAK;gBACxD,WAAW,QAAQ,MAAM,WAAW,SAAS,QAAQ,eAAe,WAAW,IAAI;gBACnF,kDAAkD,CACrD,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC;AAEM,KAAK,UAAU,UAAU,CAAC,IAAY;IAC3C,IAAI,CAAC;QACH,MAAM,YAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,GAAG,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"]}
@@ -11,6 +11,6 @@ export function killServerChildProcess() {
11
11
  killProductionServerChildProcess();
12
12
  }
13
13
  export function getVersion() {
14
- return "1.4.0-canary.65";
14
+ return "1.4.0-canary.67";
15
15
  }
16
16
  //# sourceMappingURL=cli.helpers.js.map
@@ -27,7 +27,10 @@ ${modelName.camel}Router.get(
27
27
  route: "/custom-endpoint",
28
28
  authentication: { action: "CustomAction", resource: "${modelName.kebab}" },
29
29
  validation: {},
30
- openapi: {}
30
+ experimental: {
31
+ openapi: {},
32
+ // uploads: {}
33
+ }
31
34
  },
32
35
  ${controllerHandlerLine}
33
36
  )
@@ -1 +1 @@
1
- {"version":3,"file":"router-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/router-template.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,oBAAoB,GACrB,MAAM,gCAAgC,CAAC;AAGxC,MAAM,UAAU,sBAAsB,CAAC,OAAwB;IAC7D,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAEvC,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IAEjE,MAAM,GAAG,GAAG,oBAAoB,EAAE,CAAC;IACnC,MAAM,cAAc,GAClB,OAAO,EAAE,UAAU,IAAI,KAAK,SAAS,CAAC,KAAK,eAAe,GAAG,EAAE,CAAC;IAElE,MAAM,kBAAkB,GAAG,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;IAChE,MAAM,wBAAwB,GAC5B,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,sCAAsC,CAAC,CAAC,CAAC,EAAE,CAAC;IAE7D,MAAM,gBAAgB,GAAG,eAAe,CAAC,cAAc,CAAC,CAAC;IAEzD,MAAM,oBAAoB,GAAG,gBAAgB;QAC3C,CAAC,CAAC,UAAU,SAAS,CAAC,KAAK,oBACvB,OAAO,EAAE,UAAU;YACnB,KAAK,SAAS,CAAC,KAAK,cAAc,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,EAClE,GAAG;QACL,CAAC,CAAC,UAAU,SAAS,CAAC,KAAK,oBACvB,OAAO,EAAE,UAAU;YACnB,KAAK,SAAS,CAAC,KAAK,cAAc,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,EAClE,GAAG,CAAC;IAER,MAAM,qBAAqB,GAAG,GAAG,SAAS,CAAC,KAAK,wBAAwB,CAAC;IAEzE,OAAO;EACP,oBAAoB;EACpB,wBAAwB;;qBAEL,kBAAkB;;QAE/B,SAAS,CAAC,KAAK;;EAErB,SAAS,CAAC,KAAK;;;2DAG0C,SAAS,CAAC,KAAK;;;;IAItE,qBAAqB;;;iBAGR,SAAS,CAAC,KAAK;CAC/B,CAAC;AACF,CAAC","sourcesContent":["import {\n checkFileExists,\n getUserFileExtension,\n} from \"../../../../helpers/fs.helpers\";\nimport { TemplateOptions } from \"../../template-generators\";\n\nexport function generateRouterTemplate(options: TemplateOptions): string {\n const { modelName, imports } = options;\n\n if (!modelName)\n throw new Error(\"Module name is required for router template\");\n\n const ext = getUserFileExtension();\n const controllerPath =\n imports?.controller || `./${modelName.kebab}.controller.${ext}`;\n\n const routerConfigTsType = ext === \"ts\" ? \": RouterConfig\" : \"\";\n const routerConfigTsTypeImport =\n ext === \"ts\" ? \"import { RouterConfig } from 'arkos'\" : \"\";\n\n const controllerExists = checkFileExists(controllerPath);\n\n const controllerImportLine = controllerExists\n ? `import ${modelName.camel}Controller from \"${\n imports?.controller ||\n `./${modelName.kebab}.controller${ext === \"js\" ? \".\" + \"js\" : \"\"}`\n }\"`\n : `import ${modelName.camel}Controller from \"${\n imports?.controller ||\n `./${modelName.kebab}.controller${ext === \"js\" ? \".\" + \"js\" : \"\"}`\n }\"`;\n\n const controllerHandlerLine = `${modelName.camel}Controller.someHandler`;\n\n return `import { ArkosRouter } from 'arkos'\n${controllerImportLine}\n${routerConfigTsTypeImport}\n\nexport const config${routerConfigTsType} = { }\n\nconst ${modelName.camel}Router = ArkosRouter()\n\n${modelName.camel}Router.get(\n {\n route: \"/custom-endpoint\",\n authentication: { action: \"CustomAction\", resource: \"${modelName.kebab}\" },\n validation: {},\n openapi: {}\n },\n ${controllerHandlerLine}\n)\n\nexport default ${modelName.camel}Router\n`;\n}\n"]}
1
+ {"version":3,"file":"router-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/router-template.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,oBAAoB,GACrB,MAAM,gCAAgC,CAAC;AAGxC,MAAM,UAAU,sBAAsB,CAAC,OAAwB;IAC7D,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAEvC,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IAEjE,MAAM,GAAG,GAAG,oBAAoB,EAAE,CAAC;IACnC,MAAM,cAAc,GAClB,OAAO,EAAE,UAAU,IAAI,KAAK,SAAS,CAAC,KAAK,eAAe,GAAG,EAAE,CAAC;IAElE,MAAM,kBAAkB,GAAG,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;IAChE,MAAM,wBAAwB,GAC5B,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,sCAAsC,CAAC,CAAC,CAAC,EAAE,CAAC;IAE7D,MAAM,gBAAgB,GAAG,eAAe,CAAC,cAAc,CAAC,CAAC;IAEzD,MAAM,oBAAoB,GAAG,gBAAgB;QAC3C,CAAC,CAAC,UAAU,SAAS,CAAC,KAAK,oBACvB,OAAO,EAAE,UAAU;YACnB,KAAK,SAAS,CAAC,KAAK,cAAc,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,EAClE,GAAG;QACL,CAAC,CAAC,UAAU,SAAS,CAAC,KAAK,oBACvB,OAAO,EAAE,UAAU;YACnB,KAAK,SAAS,CAAC,KAAK,cAAc,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,EAClE,GAAG,CAAC;IAER,MAAM,qBAAqB,GAAG,GAAG,SAAS,CAAC,KAAK,wBAAwB,CAAC;IAEzE,OAAO;EACP,oBAAoB;EACpB,wBAAwB;;qBAEL,kBAAkB;;QAE/B,SAAS,CAAC,KAAK;;EAErB,SAAS,CAAC,KAAK;;;2DAG0C,SAAS,CAAC,KAAK;;;;;;;IAOtE,qBAAqB;;;iBAGR,SAAS,CAAC,KAAK;CAC/B,CAAC;AACF,CAAC","sourcesContent":["import {\n checkFileExists,\n getUserFileExtension,\n} from \"../../../../helpers/fs.helpers\";\nimport { TemplateOptions } from \"../../template-generators\";\n\nexport function generateRouterTemplate(options: TemplateOptions): string {\n const { modelName, imports } = options;\n\n if (!modelName)\n throw new Error(\"Module name is required for router template\");\n\n const ext = getUserFileExtension();\n const controllerPath =\n imports?.controller || `./${modelName.kebab}.controller.${ext}`;\n\n const routerConfigTsType = ext === \"ts\" ? \": RouterConfig\" : \"\";\n const routerConfigTsTypeImport =\n ext === \"ts\" ? \"import { RouterConfig } from 'arkos'\" : \"\";\n\n const controllerExists = checkFileExists(controllerPath);\n\n const controllerImportLine = controllerExists\n ? `import ${modelName.camel}Controller from \"${\n imports?.controller ||\n `./${modelName.kebab}.controller${ext === \"js\" ? \".\" + \"js\" : \"\"}`\n }\"`\n : `import ${modelName.camel}Controller from \"${\n imports?.controller ||\n `./${modelName.kebab}.controller${ext === \"js\" ? \".\" + \"js\" : \"\"}`\n }\"`;\n\n const controllerHandlerLine = `${modelName.camel}Controller.someHandler`;\n\n return `import { ArkosRouter } from 'arkos'\n${controllerImportLine}\n${routerConfigTsTypeImport}\n\nexport const config${routerConfigTsType} = { }\n\nconst ${modelName.camel}Router = ArkosRouter()\n\n${modelName.camel}Router.get(\n {\n route: \"/custom-endpoint\",\n authentication: { action: \"CustomAction\", resource: \"${modelName.kebab}\" },\n validation: {},\n experimental: {\n openapi: {},\n // uploads: {}\n }\n },\n ${controllerHandlerLine}\n)\n\nexport default ${modelName.camel}Router\n`;\n}\n"]}
@@ -2,7 +2,7 @@ import { z } from "zod";
2
2
  import path from "path";
3
3
  import { killServerChildProcess } from "./cli/utils/cli.helpers.js";
4
4
  import sheu from "./sheu.js";
5
- import { applyStrictRoutingRules, pathExists, } from "./helpers/dynamic-loader.helpers.js";
5
+ import { applyStrictRoutingRules, pathExists, validateRouterConfigConsistency, } from "./helpers/dynamic-loader.helpers.js";
6
6
  import { kebabCase, pascalCase } from "./helpers/change-case.helpers.js";
7
7
  import { crd, getUserFileExtension } from "./helpers/fs.helpers.js";
8
8
  import { importModule } from "./helpers/global.helpers.js";
@@ -211,6 +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
215
  }
215
216
  else {
216
217
  result[key] = module.default || module;
@@ -234,7 +235,7 @@ export async function importModuleComponents(modelName, arkosConfig, moduleDirEx
234
235
  : "dtos"
235
236
  : null;
236
237
  const [_, validators] = await Promise.all([
237
- Object.entries(fileStructure.core).map(async ([key, fileName]) => {
238
+ ...Object.entries(fileStructure.core).map(async ([key, fileName]) => {
238
239
  if (["createMany", "findMany", "findOne", "updateMany"].includes(key) ||
239
240
  !fileName)
240
241
  return;
@@ -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,uBAAuB,EACvB,UAAU,GACX,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,GAAG,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,kBAAkB,MAAM,+BAA+B,CAAC;AAC/D,OAAO,eAAe,MAAM,sCAAsC,CAAC;AAMnE,IAAI,mBAAmB,GAAuC,EAAE,CAAC;AAGjE,MAAM,UAAU,mBAAmB,CACjC,SAAiB,EACjB,OAA2B;IAE3B,mBAAmB,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,GAAG,OAAO,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,SAAiB;IACnD,OAAO,mBAAmB,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;AACpD,CAAC;AAaD,MAAM,UAAU,oCAAoC,CAAC,SAAiB;IACpE,MAAM,cAAc,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC;IAC1D,MAAM,YAAY,GAAG,SAAS,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC;IACxD,MAAM,GAAG,GAAG,oBAAoB,EAAE,CAAC;IAEnC,OAAO;QACL,IAAI,EAAE;YACJ,KAAK,EA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,EAAE,EACL,KAAK,EACL,SAAS,EACT,SAAS,CAAC,SAAS,CAAC,CACrB,CAAC;QACF,IAAI,MAAM,UAAU,CAAC,SAAS,CAAC;YAAE,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACnE,CAAC,CAAC,CACH,CAAC;IAEF,MAAM,+BAA+B,GAAG,UAAU,CAAC,GAAG,CACpD,KAAK,EAAE,SAAS,EAAE,EAAE,CAClB,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} 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 } 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;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IACnE,CAAC,CAAC,CACH,CAAC;IAEF,MAAM,+BAA+B,GAAG,UAAU,CAAC,GAAG,CACpD,KAAK,EAAE,SAAS,EAAE,EAAE,CAClB,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,62 +1,156 @@
1
1
  import fs from "fs";
2
+ import deepmerge from "./deepmerge.helper.js";
2
3
  export function applyStrictRoutingRules(appModule, arkosConfig, moduleConfig) {
3
4
  const strictMode = arkosConfig?.routers?.strict || false;
4
- const config = moduleConfig || {};
5
+ let config = moduleConfig || {};
5
6
  appModule = appModule.toLowerCase();
6
- if (strictMode === true) {
7
- return {
8
- ...config,
9
- disable: typeof config.disable === "boolean"
10
- ? config.disable
11
- : appModule === "auth"
12
- ? {
13
- getMe: true,
14
- updateMe: true,
15
- deleteMe: true,
16
- login: true,
17
- logout: true,
18
- signup: true,
19
- updatePassword: true,
20
- findManyAuthAction: true,
21
- ...(typeof config.disable === "object" ? config.disable : {}),
22
- }
23
- : appModule === "file-upload"
24
- ? {
25
- findFile: true,
26
- uploadFile: true,
27
- updateFile: true,
28
- deleteFile: true,
29
- ...(typeof config.disable === "object" ? config.disable : {}),
30
- }
31
- : {
32
- createOne: true,
33
- findOne: true,
34
- updateOne: true,
35
- deleteOne: true,
36
- createMany: true,
37
- findMany: true,
38
- updateMany: true,
39
- deleteMany: true,
40
- ...(typeof config.disable === "object" ? config.disable : {}),
41
- },
42
- };
7
+ const allEndpoints = appModule === "auth"
8
+ ? [
9
+ "getMe",
10
+ "updateMe",
11
+ "deleteMe",
12
+ "login",
13
+ "logout",
14
+ "signup",
15
+ "updatePassword",
16
+ "findManyAuthAction",
17
+ ]
18
+ : appModule === "file-upload"
19
+ ? ["findFile", "uploadFile", "updateFile", "deleteFile"]
20
+ : [
21
+ "createOne",
22
+ "findOne",
23
+ "updateOne",
24
+ "deleteOne",
25
+ "createMany",
26
+ "findMany",
27
+ "updateMany",
28
+ "deleteMany",
29
+ ];
30
+ const hadBooleanDisable = typeof config.disable === "boolean";
31
+ if (hadBooleanDisable) {
32
+ const disableValue = config.disable;
33
+ const disableObject = {};
34
+ const endpointConfigs = {};
35
+ for (const endpoint of allEndpoints) {
36
+ disableObject[endpoint] = disableValue;
37
+ endpointConfigs[endpoint] = deepmerge(config[endpoint] || {}, {
38
+ disabled: disableValue,
39
+ });
40
+ }
41
+ return deepmerge(config, {
42
+ disable: disableObject,
43
+ ...endpointConfigs,
44
+ });
43
45
  }
44
- else if (strictMode === "no-bulk" &&
45
- !["auth", "file-upload"].includes(appModule.toLowerCase())) {
46
- return {
47
- ...config,
48
- disable: typeof config.disable === "boolean"
49
- ? config.disable
46
+ if (strictMode === true) {
47
+ const strictDefaults = appModule === "auth"
48
+ ? {
49
+ getMe: true,
50
+ updateMe: true,
51
+ deleteMe: true,
52
+ login: true,
53
+ logout: true,
54
+ signup: true,
55
+ updatePassword: true,
56
+ findManyAuthAction: true,
57
+ }
58
+ : appModule === "file-upload"
59
+ ? {
60
+ findFile: true,
61
+ uploadFile: true,
62
+ updateFile: true,
63
+ deleteFile: true,
64
+ }
50
65
  : {
66
+ createOne: true,
67
+ findOne: true,
68
+ updateOne: true,
69
+ deleteOne: true,
51
70
  createMany: true,
71
+ findMany: true,
52
72
  updateMany: true,
53
73
  deleteMany: true,
54
- ...(typeof config.disable === "object" ? config.disable : {}),
55
- },
74
+ };
75
+ const disableConfig = deepmerge(strictDefaults, config?.disable || {});
76
+ const endpointConfigs = {};
77
+ for (const endpoint of Object.keys(strictDefaults)) {
78
+ endpointConfigs[endpoint] = deepmerge(config[endpoint] || {}, {
79
+ disabled: strictDefaults[endpoint],
80
+ });
81
+ }
82
+ const syncedDisable = { ...disableConfig };
83
+ for (const endpoint of allEndpoints) {
84
+ const endpointDisabled = config[endpoint]?.disabled;
85
+ if (endpointDisabled !== undefined) {
86
+ syncedDisable[endpoint] = endpointDisabled;
87
+ }
88
+ }
89
+ const syncedEndpoints = { ...endpointConfigs };
90
+ for (const endpoint of allEndpoints) {
91
+ if (disableConfig[endpoint] !== undefined) {
92
+ syncedEndpoints[endpoint] = deepmerge(syncedEndpoints[endpoint] || {}, {
93
+ disabled: disableConfig[endpoint],
94
+ });
95
+ }
96
+ }
97
+ return deepmerge(config, {
98
+ disable: syncedDisable,
99
+ ...syncedEndpoints,
100
+ });
101
+ }
102
+ else if (strictMode === "no-bulk" &&
103
+ !["auth", "file-upload"].includes(appModule.toLowerCase())) {
104
+ const noBulkDefaults = {
105
+ createMany: true,
106
+ updateMany: true,
107
+ deleteMany: true,
56
108
  };
109
+ const disableConfig = deepmerge(noBulkDefaults, config.disable || {});
110
+ const endpointConfigs = {};
111
+ for (const endpoint of Object.keys(noBulkDefaults)) {
112
+ endpointConfigs[endpoint] = deepmerge(config[endpoint] || {}, {
113
+ disabled: noBulkDefaults[endpoint],
114
+ });
115
+ }
116
+ const syncedDisable = { ...disableConfig };
117
+ for (const endpoint of allEndpoints) {
118
+ const endpointDisabled = config[endpoint]?.disabled;
119
+ if (endpointDisabled !== undefined) {
120
+ syncedDisable[endpoint] = endpointDisabled;
121
+ }
122
+ }
123
+ const syncedEndpoints = { ...endpointConfigs };
124
+ for (const endpoint of allEndpoints) {
125
+ if (syncedDisable[endpoint] !== undefined) {
126
+ syncedEndpoints[endpoint] = deepmerge(syncedEndpoints[endpoint] || {}, {
127
+ disabled: syncedDisable[endpoint],
128
+ });
129
+ }
130
+ }
131
+ return deepmerge(config, {
132
+ disable: syncedDisable,
133
+ ...syncedEndpoints,
134
+ });
57
135
  }
58
136
  return config;
59
137
  }
138
+ export function validateRouterConfigConsistency(config) {
139
+ if (!config.disable || typeof config.disable === "boolean")
140
+ return;
141
+ const endpoints = Object.keys(config.disable);
142
+ for (const endpoint of endpoints) {
143
+ const oldWayValue = config.disable[endpoint];
144
+ const newWayValue = config[endpoint]?.disabled;
145
+ if (oldWayValue !== undefined &&
146
+ newWayValue !== undefined &&
147
+ oldWayValue !== newWayValue) {
148
+ throw new Error(`Conflicting disabled values for endpoint "${endpoint}": ` +
149
+ `disable.${endpoint} = ${oldWayValue}, but ${endpoint}.disabled = ${newWayValue}. ` +
150
+ `Please use only one method to disable endpoints.`);
151
+ }
152
+ }
153
+ }
60
154
  export async function pathExists(path) {
61
155
  try {
62
156
  await fs.promises.stat(path);
@@ -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;AAKpB,MAAM,UAAU,uBAAuB,CACrC,SAAY,EACZ,WAAwB,EACxB,YAA8B;IAE9B,MAAM,UAAU,GAAG,WAAW,EAAE,OAAO,EAAE,M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C,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;yBAC9D;SACO,CAAC;IACvB,CAAC;SAAM,IACL,UAAU,KAAK,SAAS;QACxB,CAAC,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,EAC1D,CAAC;QACD,OAAO;YACL,GAAG,MAAM;YACT,OAAO,EACL,OAAO,MAAM,CAAC,OAAO,KAAK,SAAS;gBACjC,CAAC,CAAC,MAAM,CAAC,OAAO;gBAChB,CAAC,CAAC;oBACE,UAAU,EAAE,IAAI;oBAChB,UAAU,EAAE,IAAI;oBAChB,UAAU,EAAE,IAAI;oBAChB,GAAG,CAAC,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;iBAC9D;SACW,CAAC;IACvB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,IAAY;IAC3C,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC","sourcesContent":["import { ArkosConfig, RouterConfig } from \"../../exports\";\nimport fs from \"fs\";\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 const config = moduleConfig || ({} as RouterConfig<T>);\n appModule = appModule.toLowerCase() as T;\n\n if (strictMode === true) {\n return {\n ...config,\n disable:\n typeof config.disable === \"boolean\"\n ? config.disable\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 ...(typeof config.disable === \"object\" ? config.disable : {}),\n }\n : appModule === \"file-upload\"\n ? {\n findFile: true,\n uploadFile: true,\n updateFile: true,\n deleteFile: true,\n ...(typeof config.disable === \"object\" ? config.disable : {}),\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 ...(typeof config.disable === \"object\" ? config.disable : {}),\n },\n } as RouterConfig<T>;\n } else if (\n strictMode === \"no-bulk\" &&\n ![\"auth\", \"file-upload\"].includes(appModule.toLowerCase())\n ) {\n return {\n ...config,\n disable:\n typeof config.disable === \"boolean\"\n ? config.disable\n : {\n createMany: true,\n updateMany: true,\n deleteMany: true,\n ...(typeof config.disable === \"object\" ? config.disable : {}),\n },\n } as RouterConfig<T>;\n }\n\n return config;\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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ACb,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,3 +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
4
  export declare function pathExists(path: string): Promise<boolean>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arkos",
3
- "version": "1.4.0-canary.65",
3
+ "version": "1.4.0-canary.67",
4
4
  "description": "The Express & Prisma RESTful Framework",
5
5
  "main": "dist/cjs/exports/index.js",
6
6
  "module": "dist/esm/exports/index.js",