arkos 1.3.4-canary.6 → 1.4.0-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/modules/debugger/debugger.service.js +5 -5
- package/dist/cjs/modules/debugger/debugger.service.js.map +1 -1
- package/dist/cjs/modules/debugger/utils/loaded-components-logger.js +2 -1
- package/dist/cjs/modules/debugger/utils/loaded-components-logger.js.map +1 -1
- package/dist/cjs/utils/cli/generate.js +13 -1
- package/dist/cjs/utils/cli/generate.js.map +1 -1
- package/dist/cjs/utils/cli/prisma-generate.js +1 -1
- package/dist/cjs/utils/cli/prisma-generate.js.map +1 -1
- package/dist/cjs/utils/cli/utils/cli.helpers.js +1 -1
- package/dist/cjs/utils/dynamic-loader.js +86 -38
- package/dist/cjs/utils/dynamic-loader.js.map +1 -1
- package/dist/esm/modules/debugger/debugger.service.js +1 -1
- package/dist/esm/modules/debugger/debugger.service.js.map +1 -1
- package/dist/esm/modules/debugger/utils/loaded-components-logger.js +2 -1
- package/dist/esm/modules/debugger/utils/loaded-components-logger.js.map +1 -1
- package/dist/esm/utils/cli/generate.js +13 -1
- package/dist/esm/utils/cli/generate.js.map +1 -1
- package/dist/esm/utils/cli/prisma-generate.js +1 -1
- package/dist/esm/utils/cli/prisma-generate.js.map +1 -1
- package/dist/esm/utils/cli/utils/cli.helpers.js +1 -1
- package/dist/esm/utils/dynamic-loader.js +86 -38
- package/dist/esm/utils/dynamic-loader.js.map +1 -1
- package/dist/types/utils/cli/generate.d.ts +2 -0
- package/dist/types/utils/dynamic-loader.d.ts +3 -3
- package/package.json +1 -1
|
@@ -4,13 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const sheu_1 = __importDefault(require("../../utils/sheu"));
|
|
7
|
-
const exports_1 = require("../../exports");
|
|
8
7
|
const util_1 = __importDefault(require("util"));
|
|
9
8
|
const fs_helpers_1 = require("../../utils/helpers/fs.helpers");
|
|
10
9
|
const loaded_components_logger_1 = __importDefault(require("./utils/loaded-components-logger"));
|
|
10
|
+
const server_1 = require("../../server");
|
|
11
11
|
class DebuggerService {
|
|
12
12
|
logModuleFinalRouter(moduleName, router) {
|
|
13
|
-
const config = (0,
|
|
13
|
+
const config = (0, server_1.getArkosConfig)();
|
|
14
14
|
const debugLevel = config.debugging?.dynamicLoader?.level || 0;
|
|
15
15
|
if (debugLevel < 3)
|
|
16
16
|
return;
|
|
@@ -22,7 +22,7 @@ class DebuggerService {
|
|
|
22
22
|
sheu_1.default.print(util_1.default.inspect(router, { depth: 2, colors: true }));
|
|
23
23
|
}
|
|
24
24
|
logDynamicLoadedModulesComponents(appModules) {
|
|
25
|
-
const config = (0,
|
|
25
|
+
const config = (0, server_1.getArkosConfig)();
|
|
26
26
|
const debugLevel = config.debugging?.dynamicLoader?.level || 0;
|
|
27
27
|
if (debugLevel < 1)
|
|
28
28
|
return;
|
|
@@ -41,7 +41,7 @@ ${sheu_1.default.bold("Ending:")} ${moduleName}\n`);
|
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
handleTransformedQueryLog(transformedQuery) {
|
|
44
|
-
const config = (0,
|
|
44
|
+
const config = (0, server_1.getArkosConfig)();
|
|
45
45
|
const debugLevel = config.debugging?.requests?.level || 0;
|
|
46
46
|
if (debugLevel < 2)
|
|
47
47
|
return;
|
|
@@ -54,7 +54,7 @@ ${sheu_1.default.bold("Ending:")} ${moduleName}\n`);
|
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
56
|
logLevel2RequestInfo(req, _, next) {
|
|
57
|
-
const config = (0,
|
|
57
|
+
const config = (0, server_1.getArkosConfig)();
|
|
58
58
|
const debugLevel = config.debugging?.requests?.level || 0;
|
|
59
59
|
if (debugLevel < 2)
|
|
60
60
|
return next();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debugger.service.js","sourceRoot":"","sources":["../../../../src/modules/debugger/debugger.service.ts"],"names":[],"mappings":";;;;;AAAA,4DAAoC;
|
|
1
|
+
{"version":3,"file":"debugger.service.js","sourceRoot":"","sources":["../../../../src/modules/debugger/debugger.service.ts"],"names":[],"mappings":";;;;;AAAA,4DAAoC;AAGpC,gDAAwB;AACxB,+DAAqD;AACrD,gGAAsE;AAEtE,yCAA8C;AAE9C,MAAM,eAAe;IACnB,oBAAoB,CAAC,UAAkB,EAAE,MAAc;QACrD,MAAM,MAAM,GAAG,IAAA,uBAAc,GAAE,CAAC;QAChC,MAAM,UAAU,GAAG,MAAM,CAAC,SAAS,EAAE,aAAa,EAAE,KAAK,IAAI,CAAC,CAAC;QAC/D,IAAI,UAAU,GAAG,CAAC;YAAE,OAAO;QAE3B,MAAM,gBAAgB,GAAG,MAAM,CAAC,SAAS,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,CAAC;QAC3E,IACE,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC;YACxC,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAC/B,UAAU,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CACxD;YAED,OAAO;QAET,cAAI,CAAC,KAAK,CAAC,GAAG,cAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,IAAI,UAAU,EAAE,CAAC,CAAC;QACjE,cAAI,CAAC,KAAK,CAAC,cAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC/D,CAAC;IAED,iCAAiC,CAC/B,UAIG;QAEH,MAAM,MAAM,GAAG,IAAA,uBAAc,GAAE,CAAC;QAChC,MAAM,UAAU,GAAG,MAAM,CAAC,SAAS,EAAE,aAAa,EAAE,KAAK,IAAI,CAAC,CAAC;QAE/D,I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,IAAI,GAAG,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC;YAC9C,cAAI,CAAC,KAAK,CACR,qCAAqC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,EACxE,EAAE,SAAS,EAAE,IAAI,EAAE,CACpB,CAAC;;YAEF,cAAI,CAAC,KAAK,CAAC,0CAA0C,EAAE;gBACrD,SAAS,EAAE,IAAI;aAChB,CAAC,CAAC;QAEL,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC;YACnC,cAAI,CAAC,KAAK,CACR,uCAAuC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,EACjF,EAAE,SAAS,EAAE,IAAI,EAAE,CACpB,CAAC;;YAEF,cAAI,CAAC,KAAK,CAAC,4CAA4C,EAAE;gBACvD,SAAS,EAAE,IAAI;aAChB,CAAC,CAAC;QAEL,IAAI,EAAE,CAAC;IACT,CAAC;CACF;AAED,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;AAE9C,kBAAe,eAAe,CAAC","sourcesContent":["import sheu from \"../../utils/sheu\";\nimport { ArkosNextFunction, ArkosRequest, ArkosResponse } from \"../../exports\";\nimport { ModuleComponents } from \"../../utils/dynamic-loader\";\nimport util from \"util\";\nimport { crd } from \"../../utils/helpers/fs.helpers\";\nimport loadedComponentsLogger from \"./utils/loaded-components-logger\";\nimport { Router } from \"express\";\nimport { getArkosConfig } from \"../../server\";\n\nclass DebuggerService {\n logModuleFinalRouter(moduleName: string, router: Router) {\n const config = getArkosConfig();\n const debugLevel = config.debugging?.dynamicLoader?.level || 0;\n if (debugLevel < 3) return;\n\n const moduleNameFilter = config.debugging?.dynamicLoader?.filters?.modules;\n if (\n (moduleNameFilter?.[0]?.length || 0) > 0 &&\n !moduleNameFilter?.some((name) =>\n moduleName.toLowerCase().startsWith(name.toLowerCase())\n )\n )\n return;\n\n sheu.debug(`${sheu.bold(\"Final Router Module:\")} ${moduleName}`);\n sheu.print(util.inspect(router, { depth: 2, colors: true }));\n }\n\n logDynamicLoadedModulesComponents(\n appModules: {\n moduleName: string;\n moduleDir: string;\n components: ModuleComponents;\n }[]\n ) {\n const config = getArkosConfig();\n const debugLevel = config.debugging?.dynamicLoader?.level || 0;\n\n if (debugLevel < 1) return;\n sheu.debug(`${sheu.bold(\"Dynamic Loader Components\")}`, {\n timestamp: true,\n });\n\n const moduleNameFilter = config.debugging?.dynamicLoader?.filters?.modules;\n\n appModules.forEach(({ moduleName, moduleDir, components }) => {\n if (\n (moduleNameFilter?.[0]?.length || 0) > 0 &&\n !moduleNameFilter?.some((name) =>\n moduleName.toLowerCase().startsWith(name.toLowerCase())\n )\n )\n return;\n\n sheu.print(`\\n${sheu.bold(\"Module:\")} ${moduleName}\n${sheu.bold(\"Path:\")} ${moduleDir.replace(crd(), \"\")}\n${sheu.bold(\"Components:\")} ${loadedComponentsLogger.getComponentsNameList(moduleName, components).join(\", \")}${debugLevel >= 2 ? `\\n${loadedComponentsLogger.getLogText(components)}` : \"\"}\n${sheu.bold(\"Ending:\")} ${moduleName}\\n`);\n });\n }\n\n handleTransformedQueryLog(transformedQuery: Record<string, any>) {\n const config = getArkosConfig();\n const debugLevel = config.debugging?.requests?.level || 0;\n if (debugLevel < 2) return;\n\n if (transformedQuery && Object.keys(transformedQuery).length > 0) {\n sheu.debug(\n `Transformed Request Parameters\\n${JSON.stringify(transformedQuery, null, 2)}`,\n { timestamp: true }\n );\n } else\n sheu.debug(`Transformed Request Parameters - Empty`, {\n timestamp: true,\n });\n }\n\n logLevel2RequestInfo(\n req: ArkosRequest,\n _: ArkosResponse,\n next: ArkosNextFunction\n ): void {\n const config = getArkosConfig();\n const debugLevel = config.debugging?.requests?.level || 0;\n if (debugLevel < 2) return next();\n\n if (req.modelName)\n sheu.debug(`Prisma Model Module\\n${req.modelName}`, { timestamp: true });\n\n if (Object.keys(req.query).length > 0)\n sheu.debug(\n `Original Request Params (req.params)\\n${JSON.stringify(req.params || {}, null, 2)}`,\n { timestamp: true }\n );\n else\n sheu.debug(`Original Request Params (req.params) - Empty`, {\n timestamp: true,\n });\n\n if (req.body && Object.keys(req.body).length > 0)\n sheu.debug(\n `Original Request Body (req.body)\\n${JSON.stringify(req.body, null, 2)}`,\n { timestamp: true }\n );\n else\n sheu.debug(`Original Request Body (req.body) - Empty`, {\n timestamp: true,\n });\n\n if (Object.keys(req.query).length > 0)\n sheu.debug(\n `Original Request Query (req.query)\\n${JSON.stringify(req.query || {}, null, 2)}`,\n { timestamp: true }\n );\n else\n sheu.debug(`Original Request Query (req.query) - Empty`, {\n timestamp: true,\n });\n\n next();\n }\n}\n\nconst debuggerService = new DebuggerService();\n\nexport default debuggerService;\n"]}
|
|
@@ -12,7 +12,8 @@ class LoadedComponentsLogger {
|
|
|
12
12
|
this.componentsToPath = {
|
|
13
13
|
authConfigs: `{{module-name}}.auth.${this.ext}`,
|
|
14
14
|
prismaQueryOptions: `{{module-name}}.query.${this.ext}`,
|
|
15
|
-
interceptors: `{{module-name}}.
|
|
15
|
+
interceptors: `{{module-name}}.interceptors.${this.ext}`,
|
|
16
|
+
interceptorsOld: `{{module-name}}.middlewares.${this.ext}`,
|
|
16
17
|
router: `{{module-name}}.router.${this.ext}`,
|
|
17
18
|
hooks: `{{module-name}}.hooks.${this.ext}`,
|
|
18
19
|
dtos: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loaded-components-logger.js","sourceRoot":"","sources":["../../../../../src/modules/debugger/utils/loaded-components-logger.ts"],"names":[],"mappings":";;;;;AACA,kEAAgF;AAChF,+DAAuC;AACvC,gDAAwB;AAExB,MAAM,sBAAsB;IAA5B;QACE,QAAG,GAAG,IAAA,iCAAG,GAAE,CAAC;QACZ,qBAAgB,GAGZ;YACF,WAAW,EAAE,wBAAwB,IAAI,CAAC,GAAG,EAAE;YAC/C,kBAAkB,EAAE,yBAAyB,IAAI,CAAC,GAAG,EAAE;YACvD,YAAY,EAAE,+BAA+B,IAAI,CAAC,GAAG,EAAE;
|
|
1
|
+
{"version":3,"file":"loaded-components-logger.js","sourceRoot":"","sources":["../../../../../src/modules/debugger/utils/loaded-components-logger.ts"],"names":[],"mappings":";;;;;AACA,kEAAgF;AAChF,+DAAuC;AACvC,gDAAwB;AAExB,MAAM,sBAAsB;IAA5B;QACE,QAAG,GAAG,IAAA,iCAAG,GAAE,CAAC;QACZ,qBAAgB,GAGZ;YACF,WAAW,EAAE,wBAAwB,IAAI,CAAC,GAAG,EAAE;YAC/C,kBAAkB,EAAE,yBAAyB,IAAI,CAAC,GAAG,EAAE;YACvD,YAAY,EAAE,gCAAgC,IAAI,CAAC,GAAG,EAAE;YACxD,eAAe,EAAE,+BAA+B,IAAI,CAAC,GAAG,EAAE;YAC1D,MAAM,EAAE,0BAA0B,IAAI,CAAC,GAAG,EAAE;YAC5C,KAAK,EAAE,yBAAyB,IAAI,CAAC,GAAG,EAAE;YAC1C,IAAI,EAAE;gBACJ,MAAM,EAAE,8BAA8B,IAAI,CAAC,GAAG,EAAE;gBAChD,MAAM,EAAE,8BAA8B,IAAI,CAAC,GAAG,EAAE;aACjD;YACD,OAAO,EAAE;gBACP,MAAM,EAAE,iCAAiC,IAAI,CAAC,GAAG,EAAE;gBACnD,MAAM,EAAE,iCAAiC,IAAI,CAAC,GAAG,EAAE;aACpD;SACF,CAAC;IAsCJ,CAAC;IApCC,qBAAqB,CAAC,UAAkB,EAAE,UAA4B;QACpE,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YACjD,IAAI,UAAU,CAAC,GAA6B,CAAC,EAAE,CAAC;gBAC9C,MAAM,OAAO,GAAG,IAAI,CAAC,gBAAg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,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI;EACxH,cAAI,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,cAAI,CAAC,OAAO,CAAC,UAAU,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI;EAC1I,cAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,cAAI,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI;CACtH,CAAC;IACA,CAAC;CACF;AAED,MAAM,sBAAsB,GAAG,IAAI,sBAAsB,EAAE,CAAC;AAE5D,kBAAe,sBAAsB,CAAC","sourcesContent":["import { ModuleComponents } from \"../../../utils/dynamic-loader\";\nimport { getUserFileExtension as ext } from \"../../../utils/helpers/fs.helpers\";\nimport sheu from \"../../../utils/sheu\";\nimport util from \"util\";\n\nclass LoadedComponentsLogger {\n ext = ext();\n componentsToPath: Record<\n keyof ModuleComponents,\n string | ModuleComponents[\"dtos\"]\n > = {\n authConfigs: `{{module-name}}.auth.${this.ext}`,\n prismaQueryOptions: `{{module-name}}.query.${this.ext}`,\n interceptors: `{{module-name}}.interceptors.${this.ext}`,\n interceptorsOld: `{{module-name}}.middlewares.${this.ext}`,\n router: `{{module-name}}.router.${this.ext}`,\n hooks: `{{module-name}}.hooks.${this.ext}`,\n dtos: {\n create: `create-{{module-name}}.dto.${this.ext}`,\n update: `update-{{module-name}}.dto.${this.ext}`,\n },\n schemas: {\n create: `create-{{module-name}}.schema.${this.ext}`,\n update: `update-{{module-name}}.schema.${this.ext}`,\n },\n };\n\n getComponentsNameList(moduleName: string, components: ModuleComponents) {\n return Object.keys(components).reduce((acc, key) => {\n if (components[key as keyof ModuleComponents]) {\n const mapping = this.componentsToPath[key as keyof ModuleComponents];\n if (![\"schemas\", \"dtos\"].includes(key))\n acc.push((mapping as string)!.replace(\"{{module-name}}\", moduleName));\n else {\n if ((components as any)[key as keyof ModuleComponents]?.create)\n acc.push(\n (mapping as ModuleComponents[\"dtos\"])?.create.replace(\n \"{{module-name}}\",\n moduleName\n )\n );\n if ((components as any)[key as keyof ModuleComponents]?.update)\n acc.push(\n (mapping as ModuleComponents[\"dtos\"])?.update.replace(\n \"{{module-name}}\",\n moduleName\n )\n );\n }\n }\n\n return acc;\n }, [] as string[]);\n }\n\n getLogText(components: ModuleComponents) {\n return `${sheu.bold(\"AuthConfigs:\")} ${components?.authConfigs ? `\\n${util.inspect(components.authConfigs, { depth: null, colors: true })}` : \" -\"}\n${sheu.bold(\"PrismaQueryOptions:\")}${components?.prismaQueryOptions ? `\\n${util.inspect(components.prismaQueryOptions, { depth: null, colors: true })}` : \" -\"}\n${sheu.bold(\"Router:\")}${components?.router ? `\\n${util.inspect(components.router, { depth: null, colors: true })}` : \" -\"}\n${sheu.bold(\"Interceptors:\")}${components?.interceptors ? `\\n${util.inspect(components.interceptors, { depth: null, colors: true })}` : \" -\"}\n${sheu.bold(\"Hooks:\")}${components?.hooks ? `\\n${util.inspect(components.hooks, { depth: null, colors: true })}` : \" -\"}\n`;\n }\n}\n\nconst loadedComponentsLogger = new LoadedComponentsLogger();\n\nexport default loadedComponentsLogger;\n"]}
|
|
@@ -83,7 +83,7 @@ exports.generateCommand = {
|
|
|
83
83
|
interceptors: async (options) => {
|
|
84
84
|
await generateFile(options, {
|
|
85
85
|
templateName: "interceptors",
|
|
86
|
-
fileSuffix: "
|
|
86
|
+
fileSuffix: "interceptors",
|
|
87
87
|
});
|
|
88
88
|
},
|
|
89
89
|
authConfigs: async (options) => {
|
|
@@ -98,6 +98,18 @@ exports.generateCommand = {
|
|
|
98
98
|
fileSuffix: "hooks",
|
|
99
99
|
});
|
|
100
100
|
},
|
|
101
|
+
createDto: async (options) => {
|
|
102
|
+
await generateFile(options, {
|
|
103
|
+
templateName: "create-dto",
|
|
104
|
+
fileSuffix: "dto",
|
|
105
|
+
});
|
|
106
|
+
},
|
|
107
|
+
updateDto: async (options) => {
|
|
108
|
+
await generateFile(options, {
|
|
109
|
+
templateName: "update-dto",
|
|
110
|
+
fileSuffix: "dto",
|
|
111
|
+
});
|
|
112
|
+
},
|
|
101
113
|
queryOptions: async (options) => {
|
|
102
114
|
await generateFile(options, {
|
|
103
115
|
templateName: "query-options",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../../src/utils/cli/generate.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,qEAA+D;AAC/D,qDAA4D;AAC5D,wEAIwC;AACxC,sDAA2E;AAC3E,mDAA2B;AAC3B,0DAAqD;AAcrD,MAAM,YAAY,GAAG,KAAK,EACxB,OAAwB,EACxB,MAAsB,EACtB,EAAE;IACF,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC;IAEhC,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,cAAI,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;QACvC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,IAAI,MAAM,CAAC,gBAAgB;QAAE,MAAM,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;IAEhE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,aAAa,EAAE,GAAG,OAAO,CAAC;IAErD,MAAM,KAAK,GAAG;QACZ,MAAM,EAAE,IAAA,gCAAU,EAAC,SAAS,CAAC;QAC7B,KAAK,EAAE,IAAA,+BAAS,EAAC,SAAS,CAAC;QAC3B,KAAK,EAAE,IAAA,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ent":["import fs from \"fs\";\nimport path from \"path\";\nimport { generateTemplate } from \"./utils/template-generators\";\nimport { ensureDirectoryExists } from \"./utils/cli.helpers\";\nimport {\n camelCase,\n kebabCase,\n pascalCase,\n} from \"../helpers/change-case.helpers\";\nimport { fullCleanCwd, getUserFileExtension } from \"../helpers/fs.helpers\";\nimport sheu from \"../sheu\";\nimport { capitalize } from \"../helpers/text.helpers\";\n\ninterface GenerateOptions {\n path?: string;\n model: string;\n}\n\ninterface GenerateConfig {\n templateName: string;\n fileSuffix: string;\n customValidation?: (modelName: string) => void;\n customImports?: (names: any) => any;\n}\n\nconst generateFile = async (\n options: GenerateOptions,\n config: GenerateConfig\n) => {\n const modelName = options.model;\n\n if (!modelName) {\n sheu.error(\"Module name is required!\");\n process.exit(1);\n }\n\n if (config.customValidation) config.customValidation(modelName);\n\n const { path: customPath = \"src/modules\" } = options;\n\n const names = {\n pascal: pascalCase(modelName),\n camel: camelCase(modelName),\n kebab: kebabCase(modelName),\n };\n\n const ext = getUserFileExtension();\n const modulePath = path.join(process.cwd(), customPath, names.kebab);\n const filePath = path.join(\n modulePath,\n `${names.kebab}.${config.fileSuffix}.${ext}`\n );\n const humamReadableTemplateName =\n config.templateName.charAt(0).toUpperCase() +\n config.templateName.slice(1).replaceAll(\"-\", \" \");\n\n try {\n ensureDirectoryExists(modulePath);\n\n const templateData = {\n modelName: names,\n ...(config.customImports && { imports: config.customImports(names) }),\n };\n\n const content = generateTemplate(config.templateName, templateData);\n if (fs.existsSync(filePath))\n throw new Error(\n `${capitalize(humamReadableTemplateName.toLowerCase())} for ${options.model} already exists.`\n );\n fs.writeFileSync(filePath, content);\n\n console.info(\"\");\n sheu.done(\n `${humamReadableTemplateName} for ${options.model} generated under ${fullCleanCwd(filePath)}`\n );\n } catch (err: any) {\n console.info(\"\");\n sheu.error(\n `${`Failed to generate ${humamReadableTemplateName.toLowerCase()}`} for ${options.model} ${filePath ? \"under \" + fullCleanCwd(filePath) + \".\" : \".\"}`\n );\n console.info(`${sheu.bold(\"Reason: \")}${err?.message || \"unknown\"}`);\n process.exit(1);\n }\n};\n\nexport const generateCommand = {\n controller: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"controller\",\n fileSuffix: \"controller\",\n customImports: () => ({\n baseController: \"arkos/controllers\",\n }),\n });\n },\n\n service: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"service\",\n fileSuffix: \"service\",\n customImports: () => ({\n baseService: \"arkos/services\",\n }),\n });\n },\n\n router: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"router\",\n fileSuffix: \"router\",\n customImports: (names) => ({\n baseRouter: \"arkos\",\n controller: `./${names.kebab}.controller`,\n }),\n });\n },\n\n interceptors: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"interceptors\",\n fileSuffix: \"interceptors\",\n });\n },\n\n authConfigs: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"auth-configs\",\n fileSuffix: \"auth\",\n });\n },\n\n hooks: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"hooks\",\n fileSuffix: \"hooks\",\n });\n },\n\n createDto: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"create-dto\",\n fileSuffix: \"dto\",\n });\n },\n\n updateDto: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"update-dto\",\n fileSuffix: \"dto\",\n });\n },\n\n queryOptions: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"query-options\",\n fileSuffix: \"query\",\n customValidation: (modelName) => {\n if (modelName === \"file-upload\") {\n sheu.error(\n \"Prisma query options are not available to file-upload resource\"\n );\n process.exit(1);\n }\n },\n });\n },\n};\n"]}
|
|
@@ -16,7 +16,7 @@ import { ModelGroupRelationFields } from "./utils/helpers/base.service.helpers.j
|
|
|
16
16
|
import { ServiceBaseContext } from "./types/base.service.types.js";
|
|
17
17
|
import { Prisma } from "@prisma/client"
|
|
18
18
|
|
|
19
|
-
declare type ModelsGetPayload<T extends Record<string, any>> = {
|
|
19
|
+
export declare type ModelsGetPayload<T extends Record<string, any>> = {
|
|
20
20
|
${prisma_schema_parser_1.default.models.map((model) => `
|
|
21
21
|
"${(0, change_case_helpers_1.kebabCase)(model.name)}": {
|
|
22
22
|
Delegate: Prisma.${model.name}Delegate,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prisma-generate.js","sourceRoot":"","sources":["../../../../src/utils/cli/prisma-generate.ts"],"names":[],"mappings":";;;;;AAOA,wCAoHC;AA3HD,0FAAgE;AAChE,wEAA2D;AAC3D,4CAAoB;AACpB,iDAAyC;AACzC,mDAA2B;AAC3B,gDAAwB;AAExB,SAAwB,qBAAqB;IACzC,MAAM,OAAO,GAAG;;;;;;EAMlB,8BAAkB,CAAC,MAAM,CAAC,GAAG,CAC3B,CAAC,KAAK,EAAE,EAAE,CACN;OACD,IAAA,+BAAS,EAAC,KAAK,CAAC,IAAI,CAAC;2BACD,KAAK,CAAC,IAAI;6BACR,KAAK,CAAC,IAAI;+BACR,KAAK,CAAC,IAAI;gCACT,KAAK,CAAC,IAAI;6BACb,KAAK,CAAC,IAAI;iCACN,KAAK,CAAC,IAAI;6BACd,KAAK,CAAC,IAAI;iCACN,KAAK,CAAC,IAAI;6BACd,KAAK,CAAC,IAAI;iCACN,KAAK,CAAC,IAAI;4BACf,KAAK,CAAC,IAAI;;CAErC,CACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8EA,CAAC;IACE,IAAA,wBAAQ,EAAC,qBAAqB,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAEtD,MAAM,QAAQ,GAAG,cAAI,CAAC,OAAO,CACzB,SAAS,EACT,+CAA+C,CAClD,CAAC;IACF,YAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE;QAChC,QAAQ,EAAE,MAAM;KACnB,CAAC,CAAC;IAEH,cAAI,CAAC,IAAI,CACL,mEAAmE,CACtE,CAAC;AACN,CAAC","sourcesContent":["import prismaSchemaParser from \"../prisma/prisma-schema-parser\";\nimport { kebabCase } from \"../helpers/change-case.helpers\";\nimport fs from \"fs\";\nimport { execSync } from \"child_process\";\nimport sheu from \"../sheu\";\nimport path from \"path\";\n\nexport default function prismaGenerateCommand() {\n const content = `\nimport { ModelGroupRelationFields } from \"./utils/helpers/base.service.helpers\";\nimport { ServiceBaseContext } from \"./types/base.service.types\";\nimport { Prisma } from \"@prisma/client\"\n\
|
|
1
|
+
{"version":3,"file":"prisma-generate.js","sourceRoot":"","sources":["../../../../src/utils/cli/prisma-generate.ts"],"names":[],"mappings":";;;;;AAOA,wCAoHC;AA3HD,0FAAgE;AAChE,wEAA2D;AAC3D,4CAAoB;AACpB,iDAAyC;AACzC,mDAA2B;AAC3B,gDAAwB;AAExB,SAAwB,qBAAqB;IACzC,MAAM,OAAO,GAAG;;;;;;EAMlB,8BAAkB,CAAC,MAAM,CAAC,GAAG,CAC3B,CAAC,KAAK,EAAE,EAAE,CACN;OACD,IAAA,+BAAS,EAAC,KAAK,CAAC,IAAI,CAAC;2BACD,KAAK,CAAC,IAAI;6BACR,KAAK,CAAC,IAAI;+BACR,KAAK,CAAC,IAAI;gCACT,KAAK,CAAC,IAAI;6BACb,KAAK,CAAC,IAAI;iCACN,KAAK,CAAC,IAAI;6BACd,KAAK,CAAC,IAAI;iCACN,KAAK,CAAC,IAAI;6BACd,KAAK,CAAC,IAAI;iCACN,KAAK,CAAC,IAAI;4BACf,KAAK,CAAC,IAAI;;CAErC,CACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8EA,CAAC;IACE,IAAA,wBAAQ,EAAC,qBAAqB,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAEtD,MAAM,QAAQ,GAAG,cAAI,CAAC,OAAO,CACzB,SAAS,EACT,+CAA+C,CAClD,CAAC;IACF,YAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE;QAChC,QAAQ,EAAE,MAAM;KACnB,CAAC,CAAC;IAEH,cAAI,CAAC,IAAI,CACL,mEAAmE,CACtE,CAAC;AACN,CAAC","sourcesContent":["import prismaSchemaParser from \"../prisma/prisma-schema-parser\";\nimport { kebabCase } from \"../helpers/change-case.helpers\";\nimport fs from \"fs\";\nimport { execSync } from \"child_process\";\nimport sheu from \"../sheu\";\nimport path from \"path\";\n\nexport default function prismaGenerateCommand() {\n const content = `\nimport { ModelGroupRelationFields } from \"./utils/helpers/base.service.helpers\";\nimport { ServiceBaseContext } from \"./types/base.service.types\";\nimport { Prisma } from \"@prisma/client\"\n\nexport declare type ModelsGetPayload<T extends Record<string, any>> = {\n${prismaSchemaParser.models.map(\n (model) =>\n `\n \"${kebabCase(model.name)}\": {\n Delegate: Prisma.${model.name}Delegate,\n GetPayload: Prisma.${model.name}GetPayload<T>,\n FindManyArgs: Prisma.${model.name}FindManyArgs,\n FindFirstArgs: Prisma.${model.name}FindFirstArgs,\n CreateArgs: Prisma.${model.name}CreateArgs,\n CreateManyArgs: Prisma.${model.name}CreateManyArgs,\n UpdateArgs: Prisma.${model.name}UpdateArgs,\n UpdateManyArgs: Prisma.${model.name}UpdateManyArgs,\n DeleteArgs: Prisma.${model.name}DeleteArgs,\n DeleteManyArgs: Prisma.${model.name}DeleteManyArgs,\n CountArgs: Prisma.${model.name}CountArgs\n }\n`\n)}\n}\n\nexport type ExtractFilters<T> = T extends { where?: infer W; [x: string]: any } ? W : any;\nexport type ExtractQueryOptions<T, K extends keyof T = never> = Omit<T, K>;\nexport type ExtractData<T> = T extends { data: infer D; [x: string]: any } ? D : any;\n\nexport declare class BaseService<\n TModelName extends keyof ModelsGetPayload<any>\n> {\n modelName: TModelName;\n relationFields: ModelGroupRelationFields;\n prisma: any;\n \n constructor(modelName: TModelName);\n \n createOne<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['CreateArgs'], 'data'>>(\n data: ExtractData<ModelsGetPayload<any>[TModelName]['CreateArgs']>, \n queryOptions?: TOptions, \n context?: ServiceBaseContext\n ): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload']>;\n \n createMany<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['CreateManyArgs'], 'data'>>(\n data: ExtractData<ModelsGetPayload<any>[TModelName]['CreateManyArgs']>, \n queryOptions?: TOptions, \n context?: ServiceBaseContext\n ): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload'][]>;\n \n count<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['CountArgs'], 'where'>>(\n filters?: ExtractFilters<ModelsGetPayload<any>[TModelName]['CountArgs']>, \n queryOptions?: TOptions,\n context?: ServiceBaseContext\n ): Promise<number>;\n \n findMany<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['FindManyArgs'], 'where'>>(\n filters?: ExtractFilters<ModelsGetPayload<any>[TModelName]['FindManyArgs']>, \n queryOptions?: TOptions, \n context?: ServiceBaseContext\n ): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload'][]>;\n \n findById<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['FindFirstArgs'], 'where'>>(\n id: string | number, \n queryOptions?: TOptions, \n context?: ServiceBaseContext\n ): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload'] | null>;\n \n findOne<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['FindFirstArgs'], 'where'>>(\n filters: ExtractFilters<ModelsGetPayload<any>[TModelName]['FindManyArgs']>, \n queryOptions?: TOptions, \n context?: ServiceBaseContext\n ): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload'] | null>;\n \n updateOne<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['UpdateArgs'], 'where' | 'data'>>(\n filters: ExtractFilters<ModelsGetPayload<any>[TModelName]['UpdateArgs']>, \n data: ExtractData<ModelsGetPayload<any>[TModelName]['UpdateArgs']>, \n queryOptions?: TOptions, \n context?: ServiceBaseContext\n ): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload']>;\n \n updateMany<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['UpdateManyArgs'], 'where' | 'data'>>(\n filters: ExtractFilters<ModelsGetPayload<any>[TModelName]['UpdateManyArgs']>, \n data: ExtractData<ModelsGetPayload<any>[TModelName]['UpdateManyArgs']>, \n queryOptions?: TOptions, \n context?: ServiceBaseContext\n ): Promise<{ count: number }>;\n \n deleteOne<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['DeleteArgs'], 'where'>>(\n filters: ExtractFilters<ModelsGetPayload<any>[TModelName]['DeleteArgs']>, \n queryOptions?: TOptions,\n context?: ServiceBaseContext\n ): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload']>;\n \n deleteMany<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['DeleteManyArgs'], 'where'>>(\n filters: ExtractFilters<ModelsGetPayload<any>[TModelName]['DeleteManyArgs']>, \n queryOptions?: TOptions,\n context?: ServiceBaseContext\n ): Promise<{ count: number }>;\n}\n`;\n execSync(\"npx prisma generate\", { stdio: \"inherit\" });\n\n const filePath = path.resolve(\n __dirname,\n `../../../types/modules/base/base.service.d.ts`\n );\n fs.writeFileSync(filePath, content, {\n encoding: \"utf8\",\n });\n\n sheu.done(\n \"Types for @prisma/client and base service generated successfully!\"\n );\n}\n"]}
|
|
@@ -38,11 +38,10 @@ function getFileModuleComponentsFileStructure(modelName) {
|
|
|
38
38
|
return {
|
|
39
39
|
core: {
|
|
40
40
|
hooks: `${kebabModelName}.hooks.${ext}`,
|
|
41
|
-
interceptors: `${kebabModelName}.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
prismaQueryOptions: `${kebabModelName}.
|
|
45
|
-
prismaQueryOptionsNew: `${kebabModelName}.query.${ext}`,
|
|
41
|
+
interceptors: `${kebabModelName}.interceptors.${ext}`,
|
|
42
|
+
interceptorsOld: `${kebabModelName}.middlewares.${ext}`,
|
|
43
|
+
authConfigs: `${kebabModelName}.auth.${ext}`,
|
|
44
|
+
prismaQueryOptions: `${kebabModelName}.query.${ext}`,
|
|
46
45
|
router: `${kebabModelName}.router.${ext}`,
|
|
47
46
|
},
|
|
48
47
|
dtos: isAuthModule
|
|
@@ -137,43 +136,91 @@ async function processSubdir(modelName, type) {
|
|
|
137
136
|
}
|
|
138
137
|
return result;
|
|
139
138
|
}
|
|
139
|
+
const availableInterceptors = {
|
|
140
|
+
auth: [
|
|
141
|
+
"beforeGetMe",
|
|
142
|
+
"afterGetMe",
|
|
143
|
+
"onGetMeError",
|
|
144
|
+
"beforeUpdateMe",
|
|
145
|
+
"afterUpdateMe",
|
|
146
|
+
"onUpdateMeError",
|
|
147
|
+
"beforeLogin",
|
|
148
|
+
"afterLogin",
|
|
149
|
+
"onLoginError",
|
|
150
|
+
"beforeLogout",
|
|
151
|
+
"afterLogout",
|
|
152
|
+
"onLogoutError",
|
|
153
|
+
"beforeSignup",
|
|
154
|
+
"afterSignup",
|
|
155
|
+
"onSignupError",
|
|
156
|
+
"beforeUpdatePassword",
|
|
157
|
+
"afterUpdatePassword",
|
|
158
|
+
"onUpdatePasswordError",
|
|
159
|
+
],
|
|
160
|
+
"file-upload": [
|
|
161
|
+
"beforeFindFile",
|
|
162
|
+
"onFindFileError",
|
|
163
|
+
"beforeUploadFile",
|
|
164
|
+
"afterUploadFile",
|
|
165
|
+
"onUploadFileError",
|
|
166
|
+
"beforeUpdateFile",
|
|
167
|
+
"afterUpdateFile",
|
|
168
|
+
"onUpdateFileError",
|
|
169
|
+
"beforeDeleteFile",
|
|
170
|
+
"afterDeleteFile",
|
|
171
|
+
"onDeleteFileError",
|
|
172
|
+
],
|
|
173
|
+
prisma: [
|
|
174
|
+
"beforeCreateOne",
|
|
175
|
+
"afterCreateOne",
|
|
176
|
+
"onCreateOneError",
|
|
177
|
+
"beforeFindOne",
|
|
178
|
+
"afterFindOne",
|
|
179
|
+
"onFindOneError",
|
|
180
|
+
"beforeFindMany",
|
|
181
|
+
"afterFindMany",
|
|
182
|
+
"onFindManyError",
|
|
183
|
+
"beforeUpdateOne",
|
|
184
|
+
"afterUpdateOne",
|
|
185
|
+
"onUpdateOneError",
|
|
186
|
+
"beforeDeleteOne",
|
|
187
|
+
"afterDeleteOne",
|
|
188
|
+
"onDeleteOneError",
|
|
189
|
+
"beforeCreateMany",
|
|
190
|
+
"afterCreateMany",
|
|
191
|
+
"onCreateManyError",
|
|
192
|
+
"beforeUpdateMany",
|
|
193
|
+
"afterUpdateMany",
|
|
194
|
+
"onUpdateManyError",
|
|
195
|
+
"beforeDeleteMany",
|
|
196
|
+
"afterDeleteMany",
|
|
197
|
+
"onDeleteManyError",
|
|
198
|
+
],
|
|
199
|
+
};
|
|
140
200
|
function validateNamingConventions(key, fileName, result) {
|
|
141
|
-
if (key === "
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
(0, cli_helpers_1.killServerChildProcess)();
|
|
145
|
-
throw new Error(`\n Cannot use both ${fileName} and ${fileName.replace("prisma-query-options", "query")} at once, please choose only one name convention. \n`);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
else if (key === "prismaQueryOptionsNew") {
|
|
149
|
-
if (result.prismaQueryOptions) {
|
|
150
|
-
(0, cli_helpers_1.killServerChildProcess)();
|
|
151
|
-
throw new Error(`\n Cannot use both ${fileName} and ${fileName.replace("query", "prisma-query-options")} at once, please choose only one name convention. \n`);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
else if (key === "authConfigs") {
|
|
155
|
-
sheu_1.default.warn(`Found ${fileName} which will be deprecated from 1.4.0-beta, consider switching to ${fileName.replace("auth-configs", "auth")}.`);
|
|
156
|
-
if (result.authConfigs) {
|
|
157
|
-
(0, cli_helpers_1.killServerChildProcess)();
|
|
158
|
-
throw new Error(`\n Cannot use both ${fileName} and ${fileName.replace("auth-configs", "auth")} at once, please choose only one name convention. \n`);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
else if (key === "authConfigsNew") {
|
|
162
|
-
if (result.authConfigs) {
|
|
163
|
-
(0, cli_helpers_1.killServerChildProcess)();
|
|
164
|
-
throw new Error(`\n Cannot use both ${fileName} and ${fileName.replace("auth", "auth-configs")} at once, please choose only one name convention. \n`);
|
|
165
|
-
}
|
|
201
|
+
if (key === "interceptorsOld") {
|
|
202
|
+
if (!result.interceptors)
|
|
203
|
+
sheu_1.default.warn(`Found deprecated ${fileName} that will removed from v1.5.0-beta, consider switching to ${fileName.replace("middlewares", "interceptors")}`);
|
|
166
204
|
}
|
|
167
205
|
}
|
|
168
206
|
function assignModuleToResult(appModule, key, module, result, arkosConfig) {
|
|
169
|
-
if (key === "
|
|
170
|
-
result.
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
207
|
+
if (key === "interceptors")
|
|
208
|
+
result.interceptors = module;
|
|
209
|
+
else if (key === "interceptorsOld") {
|
|
210
|
+
const kebabCaseAppModule = (0, change_case_helpers_1.kebabCase)(appModule);
|
|
211
|
+
const moduleName = kebabCaseAppModule === "auth"
|
|
212
|
+
? "auth"
|
|
213
|
+
: kebabCaseAppModule === "file-upload"
|
|
214
|
+
? "file-upload"
|
|
215
|
+
: "prisma";
|
|
216
|
+
if (result.interceptors &&
|
|
217
|
+
Object.keys(module).some((interceptorName) => availableInterceptors[moduleName].includes(interceptorName))) {
|
|
218
|
+
const exportedInterceptors = Object.keys(module).filter((interceptorName) => availableInterceptors[moduleName].includes(interceptorName));
|
|
219
|
+
const ext = (0, fs_helpers_1.getUserFileExtension)();
|
|
220
|
+
sheu_1.default.warn(`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`);
|
|
221
|
+
}
|
|
222
|
+
else if (!result.interceptors)
|
|
223
|
+
result.interceptors = module;
|
|
177
224
|
}
|
|
178
225
|
else if (key === "router") {
|
|
179
226
|
result[key] = {
|
|
@@ -231,6 +278,7 @@ async function importModuleComponents(modelName, arkosConfig, moduleDirExists) {
|
|
|
231
278
|
if (!module && key === "router" && usingStrictRouting)
|
|
232
279
|
module = {};
|
|
233
280
|
if (module) {
|
|
281
|
+
result[key] = module;
|
|
234
282
|
validateNamingConventions(key, fileName, result);
|
|
235
283
|
assignModuleToResult(modelName, key, module, result, arkosConfig);
|
|
236
284
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-loader.js","sourceRoot":"","sources":["../../../src/utils/dynamic-loader.ts"],"names":[],"mappings":";;;;;;AAuBA,kDAKC;AAED,kDAEC;AAaD,oFA0DC;AAED,0BAKC;AAED,kCAEC;AAED,sCAqDC;AAwCD,8DAoDC;AAQD,oDAyBC;AASD,wDAuFC;AAaD,0DAwCC;AA3bD,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,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,CAAC,CAAC,WAAW,EAAE,CAAC;IAC1D,MAAM,YAAY,GAAG,SAAS,CAAC,WAAW,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AC,SAAS,CAAC,CAAC;IACnE,CAAC,CAAC,CACH,CAAC;IAEF,MAAM,+BAA+B,GAAG,kBAAU,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,0BAAe,CAAC,iCAAiC,CAC/C,iBAAiB,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE;QACtC,MAAM,SAAS,GAAG,cAAI,CAAC,OAAO,CAC5B,IAAA,gBAAG,GAAE,EACL,KAAK,EACL,SAAS,EACT,IAAA,+BAAS,EAAC,kBAAU,CAAC,CAAC,CAAC,CAAC,CACzB,CAAC;QAEF,OAAO;YACL,UAAU,EAAE,IAAA,+BAAS,EAAC,kBAAU,CAAC,CAAC,CAAC,CAAC;YACpC,SAAS;YACT,UAAU;SACX,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { z, ZodTypeAny } from \"zod\";\nimport path from \"path\";\nimport { AuthConfigs } from \"../types/auth\";\nimport { killServerChildProcess } from \"./cli/utils/cli.helpers\";\nimport { ArkosConfig, RouterConfig } from \"../exports\";\nimport sheu from \"./sheu\";\nimport {\n applyStrictRoutingRules,\n pathExists,\n} 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): any {\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}.middlewares.${ext}`,\n authConfigs: `${kebabModelName}.auth-configs.${ext}`,\n authConfigsNew: `${kebabModelName}.auth.${ext}`,\n prismaQueryOptions: `${kebabModelName}.prisma-query-options.${ext}`,\n prismaQueryOptionsNew: `${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 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\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 === \"prismaQueryOptions\") {\n sheu.warn(\n `Found ${fileName} which will be deprecated from 1.4.0-beta, consider switching to ${fileName.replace(\"prisma-query-options\", \"query\")}.`\n );\n if (result.prismaQueryOptions) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"prisma-query-options\",\n \"query\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n } else if (key === \"prismaQueryOptionsNew\") {\n if (result.prismaQueryOptions) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"query\",\n \"prisma-query-options\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n } else if (key === \"authConfigs\") {\n sheu.warn(\n `Found ${fileName} which will be deprecated from 1.4.0-beta, consider switching to ${fileName.replace(\"auth-configs\", \"auth\")}.`\n );\n if (result.authConfigs) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"auth-configs\",\n \"auth\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n } else if (key === \"authConfigsNew\") {\n if (result.authConfigs) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"auth\",\n \"auth-configs\"\n )} at once, please choose only one name convention. \\n`\n );\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 === \"prismaQueryOptions\" || key === \"prismaQueryOptionsNew\") {\n result.prismaQueryOptions = module.default || module;\n } else if (key === \"authConfigs\" || key === \"authConfigsNew\") {\n result.authConfigs = module.default || module;\n } else if (key === \"interceptors\") {\n result[key] = 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 // Batch process core files\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 // Validate naming conventions before assignment\n validateNamingConventions(key, fileName, result);\n\n // Assign module to 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":";;;;;;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,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,CAAC,CAAC,WAAW,EAAE,CAAC;IAC1D,MAAM,YAAY,GAAG,SAAS,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AU,uBAAuB,CAAC,WAAwB;IACpE,MAAM,eAAe,GAAa,EAAE,CAAC;IACrC,MAAM,OAAO,CAAC,GAAG,CACf,kBAAU,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE;QACjC,MAAM,SAAS,GAAG,cAAI,CAAC,OAAO,CAC5B,IAAA,gBAAG,GAAE,EACL,KAAK,EACL,SAAS,EACT,IAAA,+BAAS,EAAC,SAAS,CAAC,CACrB,CAAC;QACF,IAAI,MAAM,IAAA,mCAAU,EAAC,SAAS,CAAC;YAAE,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACnE,CAAC,CAAC,CACH,CAAC;IAEF,MAAM,+BAA+B,GAAG,kBAAU,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,0BAAe,CAAC,iCAAiC,CAC/C,iBAAiB,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE;QACtC,MAAM,SAAS,GAAG,cAAI,CAAC,OAAO,CAC5B,IAAA,gBAAG,GAAE,EACL,KAAK,EACL,SAAS,EACT,IAAA,+BAAS,EAAC,kBAAU,CAAC,CAAC,CAAC,CAAC,CACzB,CAAC;QAEF,OAAO;YACL,UAAU,EAAE,IAAA,+BAAS,EAAC,kBAAU,CAAC,CAAC,CAAC,CAAC;YACpC,SAAS;YACT,UAAU;SACX,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { z, ZodTypeAny } from \"zod\";\nimport path from \"path\";\nimport { AuthConfigs } from \"../types/auth\";\nimport { killServerChildProcess } from \"./cli/utils/cli.helpers\";\nimport { ArkosConfig, RouterConfig } from \"../exports\";\nimport sheu from \"./sheu\";\nimport {\n applyStrictRoutingRules,\n pathExists,\n} 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,8 +1,8 @@
|
|
|
1
1
|
import sheu from "../../utils/sheu.js";
|
|
2
|
-
import { getArkosConfig, } from "../../exports/index.js";
|
|
3
2
|
import util from "util";
|
|
4
3
|
import { crd } from "../../utils/helpers/fs.helpers.js";
|
|
5
4
|
import loadedComponentsLogger from "./utils/loaded-components-logger.js";
|
|
5
|
+
import { getArkosConfig } from "../../server.js";
|
|
6
6
|
class DebuggerService {
|
|
7
7
|
logModuleFinalRouter(moduleName, router) {
|
|
8
8
|
const config = getArkosConfig();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debugger.service.js","sourceRoot":"","sources":["../../../../src/modules/debugger/debugger.service.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"debugger.service.js","sourceRoot":"","sources":["../../../../src/modules/debugger/debugger.service.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,kBAAkB,CAAC;AAGpC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,GAAG,EAAE,MAAM,gCAAgC,CAAC;AACrD,OAAO,sBAAsB,MAAM,kCAAkC,CAAC;AAEtE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,eAAe;IACnB,oBAAoB,CAAC,UAAkB,EAAE,MAAc;QACrD,MAAM,MAAM,GAAG,cAAc,EAAE,CAAC;QAChC,MAAM,UAAU,GAAG,MAAM,CAAC,SAAS,EAAE,aAAa,EAAE,KAAK,IAAI,CAAC,CAAC;QAC/D,IAAI,UAAU,GAAG,CAAC;YAAE,OAAO;QAE3B,MAAM,gBAAgB,GAAG,MAAM,CAAC,SAAS,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,CAAC;QAC3E,IACE,CAAC,gBAAgB,EAAE,CAAC,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IAAI,CAAC,KAAK,CAAC,4CAA4C,EAAE;gBACvD,SAAS,EAAE,IAAI;aAChB,CAAC,CAAC;QAEL,IAAI,EAAE,CAAC;IACT,CAAC;CACF;AAED,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;AAE9C,eAAe,eAAe,CAAC","sourcesContent":["import sheu from \"../../utils/sheu\";\nimport { ArkosNextFunction, ArkosRequest, ArkosResponse } from \"../../exports\";\nimport { ModuleComponents } from \"../../utils/dynamic-loader\";\nimport util from \"util\";\nimport { crd } from \"../../utils/helpers/fs.helpers\";\nimport loadedComponentsLogger from \"./utils/loaded-components-logger\";\nimport { Router } from \"express\";\nimport { getArkosConfig } from \"../../server\";\n\nclass DebuggerService {\n logModuleFinalRouter(moduleName: string, router: Router) {\n const config = getArkosConfig();\n const debugLevel = config.debugging?.dynamicLoader?.level || 0;\n if (debugLevel < 3) return;\n\n const moduleNameFilter = config.debugging?.dynamicLoader?.filters?.modules;\n if (\n (moduleNameFilter?.[0]?.length || 0) > 0 &&\n !moduleNameFilter?.some((name) =>\n moduleName.toLowerCase().startsWith(name.toLowerCase())\n )\n )\n return;\n\n sheu.debug(`${sheu.bold(\"Final Router Module:\")} ${moduleName}`);\n sheu.print(util.inspect(router, { depth: 2, colors: true }));\n }\n\n logDynamicLoadedModulesComponents(\n appModules: {\n moduleName: string;\n moduleDir: string;\n components: ModuleComponents;\n }[]\n ) {\n const config = getArkosConfig();\n const debugLevel = config.debugging?.dynamicLoader?.level || 0;\n\n if (debugLevel < 1) return;\n sheu.debug(`${sheu.bold(\"Dynamic Loader Components\")}`, {\n timestamp: true,\n });\n\n const moduleNameFilter = config.debugging?.dynamicLoader?.filters?.modules;\n\n appModules.forEach(({ moduleName, moduleDir, components }) => {\n if (\n (moduleNameFilter?.[0]?.length || 0) > 0 &&\n !moduleNameFilter?.some((name) =>\n moduleName.toLowerCase().startsWith(name.toLowerCase())\n )\n )\n return;\n\n sheu.print(`\\n${sheu.bold(\"Module:\")} ${moduleName}\n${sheu.bold(\"Path:\")} ${moduleDir.replace(crd(), \"\")}\n${sheu.bold(\"Components:\")} ${loadedComponentsLogger.getComponentsNameList(moduleName, components).join(\", \")}${debugLevel >= 2 ? `\\n${loadedComponentsLogger.getLogText(components)}` : \"\"}\n${sheu.bold(\"Ending:\")} ${moduleName}\\n`);\n });\n }\n\n handleTransformedQueryLog(transformedQuery: Record<string, any>) {\n const config = getArkosConfig();\n const debugLevel = config.debugging?.requests?.level || 0;\n if (debugLevel < 2) return;\n\n if (transformedQuery && Object.keys(transformedQuery).length > 0) {\n sheu.debug(\n `Transformed Request Parameters\\n${JSON.stringify(transformedQuery, null, 2)}`,\n { timestamp: true }\n );\n } else\n sheu.debug(`Transformed Request Parameters - Empty`, {\n timestamp: true,\n });\n }\n\n logLevel2RequestInfo(\n req: ArkosRequest,\n _: ArkosResponse,\n next: ArkosNextFunction\n ): void {\n const config = getArkosConfig();\n const debugLevel = config.debugging?.requests?.level || 0;\n if (debugLevel < 2) return next();\n\n if (req.modelName)\n sheu.debug(`Prisma Model Module\\n${req.modelName}`, { timestamp: true });\n\n if (Object.keys(req.query).length > 0)\n sheu.debug(\n `Original Request Params (req.params)\\n${JSON.stringify(req.params || {}, null, 2)}`,\n { timestamp: true }\n );\n else\n sheu.debug(`Original Request Params (req.params) - Empty`, {\n timestamp: true,\n });\n\n if (req.body && Object.keys(req.body).length > 0)\n sheu.debug(\n `Original Request Body (req.body)\\n${JSON.stringify(req.body, null, 2)}`,\n { timestamp: true }\n );\n else\n sheu.debug(`Original Request Body (req.body) - Empty`, {\n timestamp: true,\n });\n\n if (Object.keys(req.query).length > 0)\n sheu.debug(\n `Original Request Query (req.query)\\n${JSON.stringify(req.query || {}, null, 2)}`,\n { timestamp: true }\n );\n else\n sheu.debug(`Original Request Query (req.query) - Empty`, {\n timestamp: true,\n });\n\n next();\n }\n}\n\nconst debuggerService = new DebuggerService();\n\nexport default debuggerService;\n"]}
|
|
@@ -7,7 +7,8 @@ class LoadedComponentsLogger {
|
|
|
7
7
|
this.componentsToPath = {
|
|
8
8
|
authConfigs: `{{module-name}}.auth.${this.ext}`,
|
|
9
9
|
prismaQueryOptions: `{{module-name}}.query.${this.ext}`,
|
|
10
|
-
interceptors: `{{module-name}}.
|
|
10
|
+
interceptors: `{{module-name}}.interceptors.${this.ext}`,
|
|
11
|
+
interceptorsOld: `{{module-name}}.middlewares.${this.ext}`,
|
|
11
12
|
router: `{{module-name}}.router.${this.ext}`,
|
|
12
13
|
hooks: `{{module-name}}.hooks.${this.ext}`,
|
|
13
14
|
dtos: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loaded-components-logger.js","sourceRoot":"","sources":["../../../../../src/modules/debugger/utils/loaded-components-logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,IAAI,GAAG,EAAE,MAAM,mCAAmC,CAAC;AAChF,OAAO,IAAI,MAAM,qBAAqB,CAAC;AACvC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,sBAAsB;IAA5B;QACE,QAAG,GAAG,GAAG,EAAE,CAAC;QACZ,qBAAgB,GAGZ;YACF,WAAW,EAAE,wBAAwB,IAAI,CAAC,GAAG,EAAE;YAC/C,kBAAkB,EAAE,yBAAyB,IAAI,CAAC,GAAG,EAAE;YACvD,YAAY,EAAE,+BAA+B,IAAI,CAAC,GAAG,EAAE;
|
|
1
|
+
{"version":3,"file":"loaded-components-logger.js","sourceRoot":"","sources":["../../../../../src/modules/debugger/utils/loaded-components-logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,IAAI,GAAG,EAAE,MAAM,mCAAmC,CAAC;AAChF,OAAO,IAAI,MAAM,qBAAqB,CAAC;AACvC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,sBAAsB;IAA5B;QACE,QAAG,GAAG,GAAG,EAAE,CAAC;QACZ,qBAAgB,GAGZ;YACF,WAAW,EAAE,wBAAwB,IAAI,CAAC,GAAG,EAAE;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AO,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI;CACtH,CAAC;IACA,CAAC;CACF;AAED,MAAM,sBAAsB,GAAG,IAAI,sBAAsB,EAAE,CAAC;AAE5D,eAAe,sBAAsB,CAAC","sourcesContent":["import { ModuleComponents } from \"../../../utils/dynamic-loader\";\nimport { getUserFileExtension as ext } from \"../../../utils/helpers/fs.helpers\";\nimport sheu from \"../../../utils/sheu\";\nimport util from \"util\";\n\nclass LoadedComponentsLogger {\n ext = ext();\n componentsToPath: Record<\n keyof ModuleComponents,\n string | ModuleComponents[\"dtos\"]\n > = {\n authConfigs: `{{module-name}}.auth.${this.ext}`,\n prismaQueryOptions: `{{module-name}}.query.${this.ext}`,\n interceptors: `{{module-name}}.interceptors.${this.ext}`,\n interceptorsOld: `{{module-name}}.middlewares.${this.ext}`,\n router: `{{module-name}}.router.${this.ext}`,\n hooks: `{{module-name}}.hooks.${this.ext}`,\n dtos: {\n create: `create-{{module-name}}.dto.${this.ext}`,\n update: `update-{{module-name}}.dto.${this.ext}`,\n },\n schemas: {\n create: `create-{{module-name}}.schema.${this.ext}`,\n update: `update-{{module-name}}.schema.${this.ext}`,\n },\n };\n\n getComponentsNameList(moduleName: string, components: ModuleComponents) {\n return Object.keys(components).reduce((acc, key) => {\n if (components[key as keyof ModuleComponents]) {\n const mapping = this.componentsToPath[key as keyof ModuleComponents];\n if (![\"schemas\", \"dtos\"].includes(key))\n acc.push((mapping as string)!.replace(\"{{module-name}}\", moduleName));\n else {\n if ((components as any)[key as keyof ModuleComponents]?.create)\n acc.push(\n (mapping as ModuleComponents[\"dtos\"])?.create.replace(\n \"{{module-name}}\",\n moduleName\n )\n );\n if ((components as any)[key as keyof ModuleComponents]?.update)\n acc.push(\n (mapping as ModuleComponents[\"dtos\"])?.update.replace(\n \"{{module-name}}\",\n moduleName\n )\n );\n }\n }\n\n return acc;\n }, [] as string[]);\n }\n\n getLogText(components: ModuleComponents) {\n return `${sheu.bold(\"AuthConfigs:\")} ${components?.authConfigs ? `\\n${util.inspect(components.authConfigs, { depth: null, colors: true })}` : \" -\"}\n${sheu.bold(\"PrismaQueryOptions:\")}${components?.prismaQueryOptions ? `\\n${util.inspect(components.prismaQueryOptions, { depth: null, colors: true })}` : \" -\"}\n${sheu.bold(\"Router:\")}${components?.router ? `\\n${util.inspect(components.router, { depth: null, colors: true })}` : \" -\"}\n${sheu.bold(\"Interceptors:\")}${components?.interceptors ? `\\n${util.inspect(components.interceptors, { depth: null, colors: true })}` : \" -\"}\n${sheu.bold(\"Hooks:\")}${components?.hooks ? `\\n${util.inspect(components.hooks, { depth: null, colors: true })}` : \" -\"}\n`;\n }\n}\n\nconst loadedComponentsLogger = new LoadedComponentsLogger();\n\nexport default loadedComponentsLogger;\n"]}
|
|
@@ -77,7 +77,7 @@ export const generateCommand = {
|
|
|
77
77
|
interceptors: async (options) => {
|
|
78
78
|
await generateFile(options, {
|
|
79
79
|
templateName: "interceptors",
|
|
80
|
-
fileSuffix: "
|
|
80
|
+
fileSuffix: "interceptors",
|
|
81
81
|
});
|
|
82
82
|
},
|
|
83
83
|
authConfigs: async (options) => {
|
|
@@ -92,6 +92,18 @@ export const generateCommand = {
|
|
|
92
92
|
fileSuffix: "hooks",
|
|
93
93
|
});
|
|
94
94
|
},
|
|
95
|
+
createDto: async (options) => {
|
|
96
|
+
await generateFile(options, {
|
|
97
|
+
templateName: "create-dto",
|
|
98
|
+
fileSuffix: "dto",
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
updateDto: async (options) => {
|
|
102
|
+
await generateFile(options, {
|
|
103
|
+
templateName: "update-dto",
|
|
104
|
+
fileSuffix: "dto",
|
|
105
|
+
});
|
|
106
|
+
},
|
|
95
107
|
queryOptions: async (options) => {
|
|
96
108
|
await generateFile(options, {
|
|
97
109
|
templateName: "query-options",
|
|
@@ -1 +1 @@
|
|
|
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import fs from \"fs\";\nimport path from \"path\";\nimport { generateTemplate } from \"./utils/template-generators\";\nimport { ensureDirectoryExists } from \"./utils/cli.helpers\";\nimport {\n camelCase,\n kebabCase,\n pascalCase,\n} from \"../helpers/change-case.helpers\";\nimport { fullCleanCwd, getUserFileExtension } from \"../helpers/fs.helpers\";\nimport sheu from \"../sheu\";\nimport { capitalize } from \"../helpers/text.helpers\";\n\ninterface GenerateOptions {\n path?: string;\n model: string;\n}\n\ninterface GenerateConfig {\n templateName: string;\n fileSuffix: string;\n customValidation?: (modelName: string) => void;\n customImports?: (names: any) => any;\n}\n\nconst generateFile = async (\n options: GenerateOptions,\n config: GenerateConfig\n) => {\n const modelName = options.model;\n\n if (!modelName) {\n sheu.error(\"Module name is required!\");\n process.exit(1);\n }\n\n if (config.customValidation) config.customValidation(modelName);\n\n const { path: customPath = \"src/modules\" } = options;\n\n const names = {\n pascal: pascalCase(modelName),\n camel: camelCase(modelName),\n kebab: kebabCase(modelName),\n };\n\n const ext = getUserFileExtension();\n const modulePath = path.join(process.cwd(), customPath, names.kebab);\n const filePath = path.join(\n modulePath,\n `${names.kebab}.${config.fileSuffix}.${ext}`\n );\n const humamReadableTemplateName =\n config.templateName.charAt(0).toUpperCase() +\n config.templateName.slice(1).replaceAll(\"-\", \" \");\n\n try {\n ensureDirectoryExists(modulePath);\n\n const templateData = {\n modelName: names,\n ...(config.customImports && { imports: config.customImports(names) }),\n };\n\n const content = generateTemplate(config.templateName, templateData);\n if (fs.existsSync(filePath))\n throw new Error(\n `${capitalize(humamReadableTemplateName.toLowerCase())} for ${options.model} already exists.`\n );\n fs.writeFileSync(filePath, content);\n\n console.info(\"\");\n sheu.done(\n `${humamReadableTemplateName} for ${options.model} generated under ${fullCleanCwd(filePath)}`\n );\n } catch (err: any) {\n console.info(\"\");\n sheu.error(\n `${`Failed to generate ${humamReadableTemplateName.toLowerCase()}`} for ${options.model} ${filePath ? \"under \" + fullCleanCwd(filePath) + \".\" : \".\"}`\n );\n console.info(`${sheu.bold(\"Reason: \")}${err?.message || \"unknown\"}`);\n process.exit(1);\n }\n};\n\nexport const generateCommand = {\n controller: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"controller\",\n fileSuffix: \"controller\",\n customImports: () => ({\n baseController: \"arkos/controllers\",\n }),\n });\n },\n\n service: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"service\",\n fileSuffix: \"service\",\n customImports: () => ({\n baseService: \"arkos/services\",\n }),\n });\n },\n\n router: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"router\",\n fileSuffix: \"router\",\n customImports: (names) => ({\n baseRouter: \"arkos\",\n controller: `./${names.kebab}.controller`,\n }),\n });\n },\n\n interceptors: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"interceptors\",\n fileSuffix: \"interceptors\",\n });\n },\n\n authConfigs: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"auth-configs\",\n fileSuffix: \"auth\",\n });\n },\n\n hooks: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"hooks\",\n fileSuffix: \"hooks\",\n });\n },\n\n createDto: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"create-dto\",\n fileSuffix: \"dto\",\n });\n },\n\n updateDto: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"update-dto\",\n fileSuffix: \"dto\",\n });\n },\n\n queryOptions: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"query-options\",\n fileSuffix: \"query\",\n customValidation: (modelName) => {\n if (modelName === \"file-upload\") {\n sheu.error(\n \"Prisma query options are not available to file-upload resource\"\n );\n process.exit(1);\n }\n },\n });\n },\n};\n"]}
|
|
@@ -10,7 +10,7 @@ import { ModelGroupRelationFields } from "./utils/helpers/base.service.helpers.j
|
|
|
10
10
|
import { ServiceBaseContext } from "./types/base.service.types.js";
|
|
11
11
|
import { Prisma } from "@prisma/client"
|
|
12
12
|
|
|
13
|
-
declare type ModelsGetPayload<T extends Record<string, any>> = {
|
|
13
|
+
export declare type ModelsGetPayload<T extends Record<string, any>> = {
|
|
14
14
|
${prismaSchemaParser.models.map((model) => `
|
|
15
15
|
"${kebabCase(model.name)}": {
|
|
16
16
|
Delegate: Prisma.${model.name}Delegate,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prisma-generate.js","sourceRoot":"","sources":["../../../../src/utils/cli/prisma-generate.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,CAAC,OAAO,UAAU,qBAAqB;IACzC,MAAM,OAAO,GAAG;;;;;;EAMlB,kBAAkB,CAAC,MAAM,CAAC,GAAG,CAC3B,CAAC,KAAK,EAAE,EAAE,CACN;OACD,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC;2BACD,KAAK,CAAC,IAAI;6BACR,KAAK,CAAC,IAAI;+BACR,KAAK,CAAC,IAAI;gCACT,KAAK,CAAC,IAAI;6BACb,KAAK,CAAC,IAAI;iCACN,KAAK,CAAC,IAAI;6BACd,KAAK,CAAC,IAAI;iCACN,KAAK,CAAC,IAAI;6BACd,KAAK,CAAC,IAAI;iCACN,KAAK,CAAC,IAAI;4BACf,KAAK,CAAC,IAAI;;CAErC,CACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8EA,CAAC;IACE,QAAQ,CAAC,qBAAqB,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAEtD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CACzB,SAAS,EACT,+CAA+C,CAClD,CAAC;IACF,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE;QAChC,QAAQ,EAAE,MAAM;KACnB,CAAC,CAAC;IAEH,IAAI,CAAC,IAAI,CACL,mEAAmE,CACtE,CAAC;AACN,CAAC","sourcesContent":["import prismaSchemaParser from \"../prisma/prisma-schema-parser\";\nimport { kebabCase } from \"../helpers/change-case.helpers\";\nimport fs from \"fs\";\nimport { execSync } from \"child_process\";\nimport sheu from \"../sheu\";\nimport path from \"path\";\n\nexport default function prismaGenerateCommand() {\n const content = `\nimport { ModelGroupRelationFields } from \"./utils/helpers/base.service.helpers\";\nimport { ServiceBaseContext } from \"./types/base.service.types\";\nimport { Prisma } from \"@prisma/client\"\n\
|
|
1
|
+
{"version":3,"file":"prisma-generate.js","sourceRoot":"","sources":["../../../../src/utils/cli/prisma-generate.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,CAAC,OAAO,UAAU,qBAAqB;IACzC,MAAM,OAAO,GAAG;;;;;;EAMlB,kBAAkB,CAAC,MAAM,CAAC,GAAG,CAC3B,CAAC,KAAK,EAAE,EAAE,CACN;OACD,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC;2BACD,KAAK,CAAC,IAAI;6BACR,KAAK,CAAC,IAAI;+BACR,KAAK,CAAC,IAAI;gCACT,KAAK,CAAC,IAAI;6BACb,KAAK,CAAC,IAAI;iCACN,KAAK,CAAC,IAAI;6BACd,KAAK,CAAC,IAAI;iCACN,KAAK,CAAC,IAAI;6BACd,KAAK,CAAC,IAAI;iCACN,KAAK,CAAC,IAAI;4BACf,KAAK,CAAC,IAAI;;CAErC,CACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8EA,CAAC;IACE,QAAQ,CAAC,qBAAqB,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAEtD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CACzB,SAAS,EACT,+CAA+C,CAClD,CAAC;IACF,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE;QAChC,QAAQ,EAAE,MAAM;KACnB,CAAC,CAAC;IAEH,IAAI,CAAC,IAAI,CACL,mEAAmE,CACtE,CAAC;AACN,CAAC","sourcesContent":["import prismaSchemaParser from \"../prisma/prisma-schema-parser\";\nimport { kebabCase } from \"../helpers/change-case.helpers\";\nimport fs from \"fs\";\nimport { execSync } from \"child_process\";\nimport sheu from \"../sheu\";\nimport path from \"path\";\n\nexport default function prismaGenerateCommand() {\n const content = `\nimport { ModelGroupRelationFields } from \"./utils/helpers/base.service.helpers\";\nimport { ServiceBaseContext } from \"./types/base.service.types\";\nimport { Prisma } from \"@prisma/client\"\n\nexport declare type ModelsGetPayload<T extends Record<string, any>> = {\n${prismaSchemaParser.models.map(\n (model) =>\n `\n \"${kebabCase(model.name)}\": {\n Delegate: Prisma.${model.name}Delegate,\n GetPayload: Prisma.${model.name}GetPayload<T>,\n FindManyArgs: Prisma.${model.name}FindManyArgs,\n FindFirstArgs: Prisma.${model.name}FindFirstArgs,\n CreateArgs: Prisma.${model.name}CreateArgs,\n CreateManyArgs: Prisma.${model.name}CreateManyArgs,\n UpdateArgs: Prisma.${model.name}UpdateArgs,\n UpdateManyArgs: Prisma.${model.name}UpdateManyArgs,\n DeleteArgs: Prisma.${model.name}DeleteArgs,\n DeleteManyArgs: Prisma.${model.name}DeleteManyArgs,\n CountArgs: Prisma.${model.name}CountArgs\n }\n`\n)}\n}\n\nexport type ExtractFilters<T> = T extends { where?: infer W; [x: string]: any } ? W : any;\nexport type ExtractQueryOptions<T, K extends keyof T = never> = Omit<T, K>;\nexport type ExtractData<T> = T extends { data: infer D; [x: string]: any } ? D : any;\n\nexport declare class BaseService<\n TModelName extends keyof ModelsGetPayload<any>\n> {\n modelName: TModelName;\n relationFields: ModelGroupRelationFields;\n prisma: any;\n \n constructor(modelName: TModelName);\n \n createOne<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['CreateArgs'], 'data'>>(\n data: ExtractData<ModelsGetPayload<any>[TModelName]['CreateArgs']>, \n queryOptions?: TOptions, \n context?: ServiceBaseContext\n ): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload']>;\n \n createMany<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['CreateManyArgs'], 'data'>>(\n data: ExtractData<ModelsGetPayload<any>[TModelName]['CreateManyArgs']>, \n queryOptions?: TOptions, \n context?: ServiceBaseContext\n ): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload'][]>;\n \n count<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['CountArgs'], 'where'>>(\n filters?: ExtractFilters<ModelsGetPayload<any>[TModelName]['CountArgs']>, \n queryOptions?: TOptions,\n context?: ServiceBaseContext\n ): Promise<number>;\n \n findMany<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['FindManyArgs'], 'where'>>(\n filters?: ExtractFilters<ModelsGetPayload<any>[TModelName]['FindManyArgs']>, \n queryOptions?: TOptions, \n context?: ServiceBaseContext\n ): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload'][]>;\n \n findById<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['FindFirstArgs'], 'where'>>(\n id: string | number, \n queryOptions?: TOptions, \n context?: ServiceBaseContext\n ): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload'] | null>;\n \n findOne<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['FindFirstArgs'], 'where'>>(\n filters: ExtractFilters<ModelsGetPayload<any>[TModelName]['FindManyArgs']>, \n queryOptions?: TOptions, \n context?: ServiceBaseContext\n ): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload'] | null>;\n \n updateOne<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['UpdateArgs'], 'where' | 'data'>>(\n filters: ExtractFilters<ModelsGetPayload<any>[TModelName]['UpdateArgs']>, \n data: ExtractData<ModelsGetPayload<any>[TModelName]['UpdateArgs']>, \n queryOptions?: TOptions, \n context?: ServiceBaseContext\n ): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload']>;\n \n updateMany<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['UpdateManyArgs'], 'where' | 'data'>>(\n filters: ExtractFilters<ModelsGetPayload<any>[TModelName]['UpdateManyArgs']>, \n data: ExtractData<ModelsGetPayload<any>[TModelName]['UpdateManyArgs']>, \n queryOptions?: TOptions, \n context?: ServiceBaseContext\n ): Promise<{ count: number }>;\n \n deleteOne<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['DeleteArgs'], 'where'>>(\n filters: ExtractFilters<ModelsGetPayload<any>[TModelName]['DeleteArgs']>, \n queryOptions?: TOptions,\n context?: ServiceBaseContext\n ): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload']>;\n \n deleteMany<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['DeleteManyArgs'], 'where'>>(\n filters: ExtractFilters<ModelsGetPayload<any>[TModelName]['DeleteManyArgs']>, \n queryOptions?: TOptions,\n context?: ServiceBaseContext\n ): Promise<{ count: number }>;\n}\n`;\n execSync(\"npx prisma generate\", { stdio: \"inherit\" });\n\n const filePath = path.resolve(\n __dirname,\n `../../../types/modules/base/base.service.d.ts`\n );\n fs.writeFileSync(filePath, content, {\n encoding: \"utf8\",\n });\n\n sheu.done(\n \"Types for @prisma/client and base service generated successfully!\"\n );\n}\n"]}
|
|
@@ -22,11 +22,10 @@ export function getFileModuleComponentsFileStructure(modelName) {
|
|
|
22
22
|
return {
|
|
23
23
|
core: {
|
|
24
24
|
hooks: `${kebabModelName}.hooks.${ext}`,
|
|
25
|
-
interceptors: `${kebabModelName}.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
prismaQueryOptions: `${kebabModelName}.
|
|
29
|
-
prismaQueryOptionsNew: `${kebabModelName}.query.${ext}`,
|
|
25
|
+
interceptors: `${kebabModelName}.interceptors.${ext}`,
|
|
26
|
+
interceptorsOld: `${kebabModelName}.middlewares.${ext}`,
|
|
27
|
+
authConfigs: `${kebabModelName}.auth.${ext}`,
|
|
28
|
+
prismaQueryOptions: `${kebabModelName}.query.${ext}`,
|
|
30
29
|
router: `${kebabModelName}.router.${ext}`,
|
|
31
30
|
},
|
|
32
31
|
dtos: isAuthModule
|
|
@@ -121,43 +120,91 @@ export async function processSubdir(modelName, type) {
|
|
|
121
120
|
}
|
|
122
121
|
return result;
|
|
123
122
|
}
|
|
123
|
+
const availableInterceptors = {
|
|
124
|
+
auth: [
|
|
125
|
+
"beforeGetMe",
|
|
126
|
+
"afterGetMe",
|
|
127
|
+
"onGetMeError",
|
|
128
|
+
"beforeUpdateMe",
|
|
129
|
+
"afterUpdateMe",
|
|
130
|
+
"onUpdateMeError",
|
|
131
|
+
"beforeLogin",
|
|
132
|
+
"afterLogin",
|
|
133
|
+
"onLoginError",
|
|
134
|
+
"beforeLogout",
|
|
135
|
+
"afterLogout",
|
|
136
|
+
"onLogoutError",
|
|
137
|
+
"beforeSignup",
|
|
138
|
+
"afterSignup",
|
|
139
|
+
"onSignupError",
|
|
140
|
+
"beforeUpdatePassword",
|
|
141
|
+
"afterUpdatePassword",
|
|
142
|
+
"onUpdatePasswordError",
|
|
143
|
+
],
|
|
144
|
+
"file-upload": [
|
|
145
|
+
"beforeFindFile",
|
|
146
|
+
"onFindFileError",
|
|
147
|
+
"beforeUploadFile",
|
|
148
|
+
"afterUploadFile",
|
|
149
|
+
"onUploadFileError",
|
|
150
|
+
"beforeUpdateFile",
|
|
151
|
+
"afterUpdateFile",
|
|
152
|
+
"onUpdateFileError",
|
|
153
|
+
"beforeDeleteFile",
|
|
154
|
+
"afterDeleteFile",
|
|
155
|
+
"onDeleteFileError",
|
|
156
|
+
],
|
|
157
|
+
prisma: [
|
|
158
|
+
"beforeCreateOne",
|
|
159
|
+
"afterCreateOne",
|
|
160
|
+
"onCreateOneError",
|
|
161
|
+
"beforeFindOne",
|
|
162
|
+
"afterFindOne",
|
|
163
|
+
"onFindOneError",
|
|
164
|
+
"beforeFindMany",
|
|
165
|
+
"afterFindMany",
|
|
166
|
+
"onFindManyError",
|
|
167
|
+
"beforeUpdateOne",
|
|
168
|
+
"afterUpdateOne",
|
|
169
|
+
"onUpdateOneError",
|
|
170
|
+
"beforeDeleteOne",
|
|
171
|
+
"afterDeleteOne",
|
|
172
|
+
"onDeleteOneError",
|
|
173
|
+
"beforeCreateMany",
|
|
174
|
+
"afterCreateMany",
|
|
175
|
+
"onCreateManyError",
|
|
176
|
+
"beforeUpdateMany",
|
|
177
|
+
"afterUpdateMany",
|
|
178
|
+
"onUpdateManyError",
|
|
179
|
+
"beforeDeleteMany",
|
|
180
|
+
"afterDeleteMany",
|
|
181
|
+
"onDeleteManyError",
|
|
182
|
+
],
|
|
183
|
+
};
|
|
124
184
|
export function validateNamingConventions(key, fileName, result) {
|
|
125
|
-
if (key === "
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
killServerChildProcess();
|
|
129
|
-
throw new Error(`\n Cannot use both ${fileName} and ${fileName.replace("prisma-query-options", "query")} at once, please choose only one name convention. \n`);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
else if (key === "prismaQueryOptionsNew") {
|
|
133
|
-
if (result.prismaQueryOptions) {
|
|
134
|
-
killServerChildProcess();
|
|
135
|
-
throw new Error(`\n Cannot use both ${fileName} and ${fileName.replace("query", "prisma-query-options")} at once, please choose only one name convention. \n`);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
else if (key === "authConfigs") {
|
|
139
|
-
sheu.warn(`Found ${fileName} which will be deprecated from 1.4.0-beta, consider switching to ${fileName.replace("auth-configs", "auth")}.`);
|
|
140
|
-
if (result.authConfigs) {
|
|
141
|
-
killServerChildProcess();
|
|
142
|
-
throw new Error(`\n Cannot use both ${fileName} and ${fileName.replace("auth-configs", "auth")} at once, please choose only one name convention. \n`);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
else if (key === "authConfigsNew") {
|
|
146
|
-
if (result.authConfigs) {
|
|
147
|
-
killServerChildProcess();
|
|
148
|
-
throw new Error(`\n Cannot use both ${fileName} and ${fileName.replace("auth", "auth-configs")} at once, please choose only one name convention. \n`);
|
|
149
|
-
}
|
|
185
|
+
if (key === "interceptorsOld") {
|
|
186
|
+
if (!result.interceptors)
|
|
187
|
+
sheu.warn(`Found deprecated ${fileName} that will removed from v1.5.0-beta, consider switching to ${fileName.replace("middlewares", "interceptors")}`);
|
|
150
188
|
}
|
|
151
189
|
}
|
|
152
190
|
export function assignModuleToResult(appModule, key, module, result, arkosConfig) {
|
|
153
|
-
if (key === "
|
|
154
|
-
result.
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
191
|
+
if (key === "interceptors")
|
|
192
|
+
result.interceptors = module;
|
|
193
|
+
else if (key === "interceptorsOld") {
|
|
194
|
+
const kebabCaseAppModule = kebabCase(appModule);
|
|
195
|
+
const moduleName = kebabCaseAppModule === "auth"
|
|
196
|
+
? "auth"
|
|
197
|
+
: kebabCaseAppModule === "file-upload"
|
|
198
|
+
? "file-upload"
|
|
199
|
+
: "prisma";
|
|
200
|
+
if (result.interceptors &&
|
|
201
|
+
Object.keys(module).some((interceptorName) => availableInterceptors[moduleName].includes(interceptorName))) {
|
|
202
|
+
const exportedInterceptors = Object.keys(module).filter((interceptorName) => availableInterceptors[moduleName].includes(interceptorName));
|
|
203
|
+
const ext = getUserFileExtension();
|
|
204
|
+
sheu.warn(`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`);
|
|
205
|
+
}
|
|
206
|
+
else if (!result.interceptors)
|
|
207
|
+
result.interceptors = module;
|
|
161
208
|
}
|
|
162
209
|
else if (key === "router") {
|
|
163
210
|
result[key] = {
|
|
@@ -215,6 +262,7 @@ export async function importModuleComponents(modelName, arkosConfig, moduleDirEx
|
|
|
215
262
|
if (!module && key === "router" && usingStrictRouting)
|
|
216
263
|
module = {};
|
|
217
264
|
if (module) {
|
|
265
|
+
result[key] = module;
|
|
218
266
|
validateNamingConventions(key, fileName, result);
|
|
219
267
|
assignModuleToResult(modelName, key, module, result, arkosConfig);
|
|
220
268
|
}
|
|
@@ -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,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AAU,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE;QACjC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAC5B,GAAG,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): any {\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}.middlewares.${ext}`,\n authConfigs: `${kebabModelName}.auth-configs.${ext}`,\n authConfigsNew: `${kebabModelName}.auth.${ext}`,\n prismaQueryOptions: `${kebabModelName}.prisma-query-options.${ext}`,\n prismaQueryOptionsNew: `${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 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\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 === \"prismaQueryOptions\") {\n sheu.warn(\n `Found ${fileName} which will be deprecated from 1.4.0-beta, consider switching to ${fileName.replace(\"prisma-query-options\", \"query\")}.`\n );\n if (result.prismaQueryOptions) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"prisma-query-options\",\n \"query\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n } else if (key === \"prismaQueryOptionsNew\") {\n if (result.prismaQueryOptions) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"query\",\n \"prisma-query-options\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n } else if (key === \"authConfigs\") {\n sheu.warn(\n `Found ${fileName} which will be deprecated from 1.4.0-beta, consider switching to ${fileName.replace(\"auth-configs\", \"auth\")}.`\n );\n if (result.authConfigs) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"auth-configs\",\n \"auth\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n } else if (key === \"authConfigsNew\") {\n if (result.authConfigs) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"auth\",\n \"auth-configs\"\n )} at once, please choose only one name convention. \\n`\n );\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 === \"prismaQueryOptions\" || key === \"prismaQueryOptionsNew\") {\n result.prismaQueryOptions = module.default || module;\n } else if (key === \"authConfigs\" || key === \"authConfigsNew\") {\n result.authConfigs = module.default || module;\n } else if (key === \"interceptors\") {\n result[key] = 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 // Batch process core files\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 // Validate naming conventions before assignment\n validateNamingConventions(key, fileName, result);\n\n // Assign module to result\n assignModuleToResult(modelName, key, module, result, arkosConfig);\n }\n } catch (err: any) {\n if (err.message?.includes(\"Cannot use both\")) throw err;\n console.error(err);\n killServerChildProcess();\n }\n }),\n validationSubdir && processSubdir(modelName, validationSubdir),\n ]);\n\n prismaModelsModules[pascalCase(modelName)] = {\n ...result,\n ...(validationSubdir && { [validationSubdir]: validators }),\n };\n\n return {\n ...result,\n ...(validationSubdir && { [validationSubdir]: validators }),\n };\n}\n\nexport const appModules = Array.from(\n new Set([\n \"auth\",\n \"file-upload\",\n ...prismaSchemaParser.getModelsAsArrayOfStrings(),\n ])\n);\n\n/**\n * Allows to asynchronously load all app modules components at once to speed up app start time.\n */\nexport async function loadAllModuleComponents(arkosConfig: ArkosConfig) {\n const moduleDirExists: string[] = [];\n await Promise.all(\n appModules.map(async (appModule) => {\n const moduleDir = path.resolve(\n crd(),\n \"src\",\n \"modules\",\n kebabCase(appModule)\n );\n if (await pathExists(moduleDir)) moduleDirExists.push(appModule);\n })\n );\n\n const modulesComponentsImportPromises = appModules.map(\n async (appModule) =>\n await importModuleComponents(\n appModule,\n arkosConfig,\n moduleDirExists.includes(appModule)\n )\n );\n\n const modulesComponents = await Promise.all(modulesComponentsImportPromises);\n debuggerService.logDynamicLoadedModulesComponents(\n modulesComponents.map((components, i) => {\n const moduleDir = path.resolve(\n crd(),\n \"src\",\n \"modules\",\n kebabCase(appModules[i])\n );\n\n return {\n moduleName: kebabCase(appModules[i]),\n moduleDir,\n components,\n };\n })\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dynamic-loader.js","sourceRoot":"","sources":["../../../src/utils/dynamic-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAc,MAAM,KAAK,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,EACL,uBAAuB,EACvB,UAAU,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,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C;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"]}
|
|
@@ -9,6 +9,8 @@ export declare const generateCommand: {
|
|
|
9
9
|
interceptors: (options: GenerateOptions) => Promise<void>;
|
|
10
10
|
authConfigs: (options: GenerateOptions) => Promise<void>;
|
|
11
11
|
hooks: (options: GenerateOptions) => Promise<void>;
|
|
12
|
+
createDto: (options: GenerateOptions) => Promise<void>;
|
|
13
|
+
updateDto: (options: GenerateOptions) => Promise<void>;
|
|
12
14
|
queryOptions: (options: GenerateOptions) => Promise<void>;
|
|
13
15
|
};
|
|
14
16
|
export {};
|
|
@@ -4,17 +4,16 @@ import { ArkosConfig, RouterConfig } from "../exports";
|
|
|
4
4
|
import { PrismaQueryOptions } from "../types";
|
|
5
5
|
import { ServiceHook } from "../modules/base/utils/service-hooks-manager";
|
|
6
6
|
type AppModuleComponent = Awaited<ReturnType<typeof importModuleComponents>>;
|
|
7
|
-
export declare function setModuleComponents(modelName: string, modules: AppModuleComponent):
|
|
7
|
+
export declare function setModuleComponents(modelName: string, modules: AppModuleComponent): void;
|
|
8
8
|
export declare function getModuleComponents(modelName: string): ImportModuleComponentsReturnType;
|
|
9
9
|
export type ValidationFileMappingKey = keyof ReturnType<typeof getFileModuleComponentsFileStructure>["dtos"];
|
|
10
10
|
export declare function getFileModuleComponentsFileStructure(modelName: string): {
|
|
11
11
|
core: {
|
|
12
12
|
hooks: string;
|
|
13
13
|
interceptors: string;
|
|
14
|
+
interceptorsOld: string;
|
|
14
15
|
authConfigs: string;
|
|
15
|
-
authConfigsNew: string;
|
|
16
16
|
prismaQueryOptions: string;
|
|
17
|
-
prismaQueryOptionsNew: string;
|
|
18
17
|
router: string;
|
|
19
18
|
};
|
|
20
19
|
dtos: {
|
|
@@ -92,6 +91,7 @@ type ImportModuleComponentsReturnType = {
|
|
|
92
91
|
hooks?: Record<string, ServiceHook | ServiceHook[]>;
|
|
93
92
|
interceptors?: Record<string, Function | Function[]>;
|
|
94
93
|
authConfigs?: AuthConfigs;
|
|
94
|
+
interceptorsOld?: any;
|
|
95
95
|
authConfigsNew?: AuthConfigs;
|
|
96
96
|
prismaQueryOptions?: PrismaQueryOptions<any>;
|
|
97
97
|
prismaQueryOptionsNew?: PrismaQueryOptions<any>;
|