arkos 1.2.29-test → 1.2.30-test

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.
Files changed (76) hide show
  1. package/dist/cjs/modules/auth/auth.router.js +1 -1
  2. package/dist/cjs/modules/auth/auth.router.js.map +1 -1
  3. package/dist/cjs/modules/base/base.service.js.map +1 -1
  4. package/dist/cjs/modules/base/utils/helpers/base.router.helpers.js +1 -1
  5. package/dist/cjs/modules/base/utils/helpers/base.router.helpers.js.map +1 -1
  6. package/dist/cjs/modules/error-handler/error-handler.controller.js +2 -0
  7. package/dist/cjs/modules/error-handler/error-handler.controller.js.map +1 -1
  8. package/dist/cjs/modules/error-handler/utils/catch-async.js +1 -1
  9. package/dist/cjs/modules/error-handler/utils/catch-async.js.map +1 -1
  10. package/dist/cjs/modules/error-handler/utils/error-handler.helpers.js +6 -0
  11. package/dist/cjs/modules/error-handler/utils/error-handler.helpers.js.map +1 -1
  12. package/dist/cjs/modules/file-upload/file-upload.router.js +3 -2
  13. package/dist/cjs/modules/file-upload/file-upload.router.js.map +1 -1
  14. package/dist/cjs/modules/swagger/swagger.router.js +1 -1
  15. package/dist/cjs/modules/swagger/swagger.router.js.map +1 -1
  16. package/dist/cjs/modules/swagger/utils/helpers/swagger.router.helpers.js +3 -2
  17. package/dist/cjs/modules/swagger/utils/helpers/swagger.router.helpers.js.map +1 -1
  18. package/dist/cjs/server.js +2 -2
  19. package/dist/cjs/server.js.map +1 -1
  20. package/dist/cjs/utils/cli/dev.js +19 -17
  21. package/dist/cjs/utils/cli/dev.js.map +1 -1
  22. package/dist/cjs/utils/cli/generate.js +1 -1
  23. package/dist/cjs/utils/cli/generate.js.map +1 -1
  24. package/dist/cjs/utils/cli/utils/cli.helpers.js +1 -1
  25. package/dist/cjs/utils/cli/utils/template-generator/templates/generate-service-template.js +1 -1
  26. package/dist/cjs/utils/cli/utils/template-generator/templates/generate-service-template.js.map +1 -1
  27. package/dist/cjs/utils/helpers/global.helpers.js +7 -19
  28. package/dist/cjs/utils/helpers/global.helpers.js.map +1 -1
  29. package/dist/cjs/utils/helpers/models.helpers.js +20 -8
  30. package/dist/cjs/utils/helpers/models.helpers.js.map +1 -1
  31. package/dist/cjs/utils/helpers/prisma.helpers.js +7 -4
  32. package/dist/cjs/utils/helpers/prisma.helpers.js.map +1 -1
  33. package/dist/esm/modules/auth/auth.router.js +1 -1
  34. package/dist/esm/modules/auth/auth.router.js.map +1 -1
  35. package/dist/esm/modules/base/base.service.js.map +1 -1
  36. package/dist/esm/modules/base/utils/helpers/base.router.helpers.js +1 -1
  37. package/dist/esm/modules/base/utils/helpers/base.router.helpers.js.map +1 -1
  38. package/dist/esm/modules/error-handler/error-handler.controller.js +2 -0
  39. package/dist/esm/modules/error-handler/error-handler.controller.js.map +1 -1
  40. package/dist/esm/modules/error-handler/utils/catch-async.js +1 -1
  41. package/dist/esm/modules/error-handler/utils/catch-async.js.map +1 -1
  42. package/dist/esm/modules/error-handler/utils/error-handler.helpers.js +5 -0
  43. package/dist/esm/modules/error-handler/utils/error-handler.helpers.js.map +1 -1
  44. package/dist/esm/modules/file-upload/file-upload.router.js +3 -2
  45. package/dist/esm/modules/file-upload/file-upload.router.js.map +1 -1
  46. package/dist/esm/modules/swagger/swagger.router.js +1 -1
  47. package/dist/esm/modules/swagger/swagger.router.js.map +1 -1
  48. package/dist/esm/modules/swagger/utils/helpers/swagger.router.helpers.js +3 -2
  49. package/dist/esm/modules/swagger/utils/helpers/swagger.router.helpers.js.map +1 -1
  50. package/dist/esm/server.js +2 -2
  51. package/dist/esm/server.js.map +1 -1
  52. package/dist/esm/utils/cli/dev.js +19 -17
  53. package/dist/esm/utils/cli/dev.js.map +1 -1
  54. package/dist/esm/utils/cli/generate.js +1 -1
  55. package/dist/esm/utils/cli/generate.js.map +1 -1
  56. package/dist/esm/utils/cli/utils/cli.helpers.js +1 -1
  57. package/dist/esm/utils/cli/utils/template-generator/templates/generate-service-template.js +1 -1
  58. package/dist/esm/utils/cli/utils/template-generator/templates/generate-service-template.js.map +1 -1
  59. package/dist/esm/utils/helpers/global.helpers.js +7 -19
  60. package/dist/esm/utils/helpers/global.helpers.js.map +1 -1
  61. package/dist/esm/utils/helpers/models.helpers.js +19 -8
  62. package/dist/esm/utils/helpers/models.helpers.js.map +1 -1
  63. package/dist/esm/utils/helpers/prisma.helpers.js +7 -4
  64. package/dist/esm/utils/helpers/prisma.helpers.js.map +1 -1
  65. package/dist/types/modules/auth/auth.controller.d.ts +7 -7
  66. package/dist/types/modules/auth/auth.service.d.ts +1 -1
  67. package/dist/types/modules/base/base.controller.d.ts +9 -9
  68. package/dist/types/modules/base/base.service.d.ts +1 -1
  69. package/dist/types/modules/error-handler/utils/catch-async.d.ts +1 -1
  70. package/dist/types/modules/error-handler/utils/error-handler.helpers.d.ts +4 -0
  71. package/dist/types/modules/file-upload/file-upload.controller.d.ts +4 -4
  72. package/dist/types/modules/file-upload/file-upload.router.d.ts +1 -1
  73. package/dist/types/modules/swagger/utils/helpers/swagger.router.helpers.d.ts +1 -1
  74. package/dist/types/utils/helpers/models.helpers.d.ts +7 -4
  75. package/dist/types/utils/helpers/prisma.helpers.d.ts +1 -1
  76. package/package.json +2 -3
@@ -2,6 +2,7 @@ import fs from "fs";
2
2
  import path from "path";
3
3
  import { createRequire } from "module";
4
4
  import { pathToFileURL } from "url";
5
+ import { getUserFileExtension } from "./fs.helpers.js";
5
6
  export function getPackageJson() {
6
7
  try {
7
8
  const pkgPath = path.join(process.cwd(), "package.json");
@@ -15,34 +16,23 @@ export function getPackageJson() {
15
16
  }
16
17
  export function isEsm() {
17
18
  const pkg = getPackageJson();
18
- return pkg.type === "module";
19
+ return pkg?.type === "module";
19
20
  }
20
21
  export async function importModule(modulePath, options = { fixExtension: true }) {
21
- let correctedPath = modulePath;
22
- if (options?.fixExtension &&
23
- isEsm() &&
24
- modulePath.startsWith(".") &&
25
- !modulePath.endsWith(".js")) {
26
- const fullImportPath = path.resolve(process.cwd(), modulePath);
27
- const indexPath = fullImportPath + "/index.js";
28
- if (fs.existsSync(indexPath)) {
29
- correctedPath = modulePath + "/index.js";
30
- }
31
- else {
32
- correctedPath = modulePath + ".js";
33
- }
34
- }
35
- if (!options.fixExtension)
22
+ if (!options.fixExtension ||
23
+ modulePath.endsWith(".ts") ||
24
+ getUserFileExtension() === "ts")
36
25
  return await import(modulePath);
37
26
  const userRequire = createRequire(pathToFileURL(process.cwd() + "/package.json"));
38
27
  const resolved = userRequire.resolve(modulePath);
39
28
  return await import(pathToFileURL(resolved));
40
- return await import(correctedPath);
41
29
  }
42
30
  export function detectPackageManagerFromUserAgent() {
43
31
  const userAgent = process.env.npm_config_user_agent || "";
44
32
  if (!userAgent)
45
33
  return "npm";
34
+ if (userAgent.includes("cnpm"))
35
+ return "cnpm";
46
36
  if (userAgent.includes("pnpm"))
47
37
  return "pnpm";
48
38
  if (userAgent.includes("yarn"))
@@ -51,8 +41,6 @@ export function detectPackageManagerFromUserAgent() {
51
41
  return "npm";
52
42
  if (userAgent.includes("bun"))
53
43
  return "bun";
54
- if (userAgent.includes("cnpm"))
55
- return "cnpm";
56
44
  if (userAgent.includes("corepack"))
57
45
  return "corepack";
58
46
  if (userAgent.includes("deno"))
@@ -1 +1 @@
1
- {"version":3,"file":"global.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/global.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,UAAU,cAAc;IAC5B,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC;QACzD,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YAC3B,O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jD,OAAO,MAAM,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAQ,CAAC,CAAC;IAEpD,OAAO,MAAM,MAAM,CAAC,aAAa,CAAC,CAAC;AACrC,CAAC;AAQD,MAAM,UAAU,iCAAiC;IAC/C,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,EAAE,CAAC;IAE1D,IAAI,CAAC,SAAS;QAAE,OAAO,KAAK,CAAC;IAC7B,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAC9C,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAC9C,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAC9C,IAAI,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC;QAAE,OAAO,UAAU,CAAC;IACtD,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAE9C,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport { createRequire } from \"module\";\nimport { pathToFileURL } from \"url\";\n\nexport function getPackageJson() {\n try {\n const pkgPath = path.join(process.cwd(), \"package.json\");\n if (fs.existsSync(pkgPath)) {\n return JSON.parse(fs.readFileSync(pkgPath, \"utf8\"));\n }\n } catch (err) {\n console.error(\"Error checking package.json:\", err);\n }\n}\n\nexport function isEsm() {\n const pkg = getPackageJson();\n return pkg.type === \"module\";\n}\n\nexport async function importModule(\n modulePath: string,\n options: { fixExtension: boolean } = { fixExtension: true }\n) {\n // Add .js extension if it's a relative path without extension\n let correctedPath = modulePath;\n\n if (\n options?.fixExtension &&\n isEsm() &&\n modulePath.startsWith(\".\") &&\n !modulePath.endsWith(\".js\")\n ) {\n const fullImportPath = path.resolve(process.cwd(), modulePath);\n const indexPath = fullImportPath + \"/index.js\";\n\n // Check if it's a directory with index.js or a direct file\n if (fs.existsSync(indexPath)) {\n correctedPath = modulePath + \"/index.js\";\n } else {\n correctedPath = modulePath + \".js\";\n }\n }\n\n if (!options.fixExtension) return await import(modulePath);\n\n // When importing user modules:\n const userRequire = createRequire(\n pathToFileURL(process.cwd() + \"/package.json\")\n );\n const resolved = userRequire.resolve(modulePath);\n return await import(pathToFileURL(resolved) as any);\n\n return await import(correctedPath);\n}\n\n/**\n * Helps getting the current package manager from user agent\n *\n * @returns {string} the package manager\n * @default \"npm\"\n */\nexport function detectPackageManagerFromUserAgent(): string {\n const userAgent = process.env.npm_config_user_agent || \"\";\n\n if (!userAgent) return \"npm\";\n if (userAgent.includes(\"pnpm\")) return \"pnpm\";\n if (userAgent.includes(\"yarn\")) return \"yarn\";\n if (userAgent.includes(\"npm\")) return \"npm\";\n if (userAgent.includes(\"bun\")) return \"bun\";\n if (userAgent.includes(\"cnpm\")) return \"cnpm\";\n if (userAgent.includes(\"corepack\")) return \"corepack\";\n if (userAgent.includes(\"deno\")) return \"deno\";\n\n return \"npm\";\n}\n"]}
1
+ {"version":3,"file":"global.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/global.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,UAAU,cAAc;IAC5B,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,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AC;QAAE,OAAO,MAAM,CAAC;IAC9C,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAC9C,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC;QAAE,OAAO,UAAU,CAAC;IACtD,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAE9C,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport { createRequire } from \"module\";\nimport { pathToFileURL } from \"url\";\nimport { getUserFileExtension } from \"./fs.helpers\";\n\nexport function getPackageJson() {\n try {\n const pkgPath = path.join(process.cwd(), \"package.json\");\n if (fs.existsSync(pkgPath)) {\n return JSON.parse(fs.readFileSync(pkgPath, \"utf8\"));\n }\n } catch (err) {\n console.error(\"Error checking package.json:\", err);\n }\n}\n\nexport function isEsm() {\n const pkg = getPackageJson();\n return pkg?.type === \"module\";\n}\n\nexport async function importModule(\n modulePath: string,\n options: { fixExtension: boolean } = { fixExtension: true }\n) {\n if (\n !options.fixExtension ||\n modulePath.endsWith(\".ts\") ||\n getUserFileExtension() === \"ts\"\n )\n return await import(modulePath);\n\n // When importing user modules:\n const userRequire = createRequire(\n pathToFileURL(process.cwd() + \"/package.json\")\n );\n const resolved = userRequire.resolve(modulePath);\n return await import(pathToFileURL(resolved) as any);\n}\n\n/**\n * Helps getting the current package manager from user agent\n *\n * @returns {string} the package manager\n * @default \"npm\"\n */\nexport function detectPackageManagerFromUserAgent(): string {\n const userAgent = process.env.npm_config_user_agent || \"\";\n\n if (!userAgent) return \"npm\";\n if (userAgent.includes(\"cnpm\")) return \"cnpm\";\n if (userAgent.includes(\"pnpm\")) return \"pnpm\";\n if (userAgent.includes(\"yarn\")) return \"yarn\";\n if (userAgent.includes(\"npm\")) return \"npm\";\n if (userAgent.includes(\"bun\")) return \"bun\";\n if (userAgent.includes(\"corepack\")) return \"corepack\";\n if (userAgent.includes(\"deno\")) return \"deno\";\n\n return \"npm\";\n}\n"]}
@@ -5,6 +5,9 @@ import { crd, getUserFileExtension } from "./fs.helpers.js";
5
5
  import { importModule } from "./global.helpers.js";
6
6
  import { killServerChildProcess } from "../cli/utils/cli.helpers.js";
7
7
  let prismaModelsModules = {};
8
+ export function setModelModules(modelName, modules) {
9
+ prismaModelsModules[kebabCase(modelName)] = modules;
10
+ }
8
11
  export function getModelModules(modelName) {
9
12
  return prismaModelsModules[kebabCase(modelName)];
10
13
  }
@@ -59,7 +62,7 @@ export function getFileModelModulesFileStructure(modelName) {
59
62
  },
60
63
  };
61
64
  }
62
- export async function processSubdir(modelName, type, result) {
65
+ export async function processSubdir(modelName, type, result = {}) {
63
66
  const moduleDir = path.resolve(crd(), "src", "modules", kebabCase(modelName));
64
67
  const subdir = path.join(moduleDir, type);
65
68
  const fileStructure = getFileModelModulesFileStructure(modelName);
@@ -72,7 +75,7 @@ export async function processSubdir(modelName, type, result) {
72
75
  try {
73
76
  const module = await importModule(filePath).catch(() => null);
74
77
  if (module)
75
- result[type][key] = module.default;
78
+ result[key] = module.default;
76
79
  }
77
80
  catch (error) {
78
81
  console.error(error);
@@ -82,6 +85,7 @@ export async function processSubdir(modelName, type, result) {
82
85
  catch (error) {
83
86
  console.error(error);
84
87
  }
88
+ return result;
85
89
  }
86
90
  export function validateNamingConventions(key, fileName, result) {
87
91
  if (key === "prismaQueryOptions") {
@@ -123,7 +127,7 @@ export function assignModuleToResult(key, module, result) {
123
127
  result[key] = module.default || module;
124
128
  }
125
129
  }
126
- export async function importPrismaModelModules(modelName) {
130
+ export async function importPrismaModelModules(modelName, arkosConfig) {
127
131
  const moduleDir = path.resolve(crd(), "src", "modules", kebabCase(modelName));
128
132
  const result = {
129
133
  dtos: {},
@@ -155,11 +159,18 @@ export async function importPrismaModelModules(modelName) {
155
159
  killServerChildProcess();
156
160
  }
157
161
  }));
158
- await Promise.all([
159
- processSubdir(modelName, "dtos", result),
160
- processSubdir(modelName, "schemas", result),
161
- ]);
162
- prismaModelsModules[modelName] = result;
162
+ const validationSubdir = arkosConfig.validation?.resolver
163
+ ? arkosConfig.validation.resolver === "zod"
164
+ ? "schemas"
165
+ : "dtos"
166
+ : null;
167
+ let validators = {};
168
+ if (validationSubdir)
169
+ validators = await processSubdir(modelName, validationSubdir);
170
+ prismaModelsModules[modelName] = {
171
+ ...result,
172
+ ...(validationSubdir && { [validationSubdir]: validators }),
173
+ };
163
174
  return result;
164
175
  }
165
176
  export const prismaModelRelationFields = {};
@@ -1 +1 @@
1
- {"version":3,"file":"models.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/models.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EACL,SAAS,EACT,SAAS,EACT,UAAU,GACX,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,GAAG,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAGlE,IAAI,mBAAmB,GAGnB,EAAE,CAAC;AAEP,MAAM,UAAU,eAAe,CAAC,SAAiB;IAC/C,OAAO,mBAAmB,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,gCAAgC,CAAC,SAAiB;IAChE,MAAM,cAAc,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC;IAC1D,MAAM,YAAY,GAAG,SAAS,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC;IACxD,MAAM,GAAG,GA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AAMD,SAAS,oBAAoB,CAAC,SAAiB;IAC7C,OAAO,wBAAwB,CAAC,SAAS,CAAC,CAAC;AAC7C,CAAC;AAED,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,CAAC","sourcesContent":["import path from \"path\";\nimport fs from \"fs\";\nimport {\n camelCase,\n kebabCase,\n pascalCase,\n} from \"../../utils/helpers/change-case.helpers\";\nimport { crd, getUserFileExtension } from \"./fs.helpers\";\nimport { importModule } from \"./global.helpers\";\nimport { AuthConfigs } from \"../../types/auth\";\nimport { killServerChildProcess } from \"../cli/utils/cli.helpers\";\n\n// Must be exported to not cause problems on cjs\nlet prismaModelsModules: Record<\n string,\n Awaited<ReturnType<typeof importPrismaModelModules>>\n> = {};\n\nexport function getModelModules(modelName: string) {\n return prismaModelsModules[kebabCase(modelName)];\n}\n\nexport function getFileModelModulesFileStructure(modelName: string) {\n const kebabModelName = kebabCase(modelName).toLowerCase();\n const isAuthModule = modelName.toLowerCase() === \"auth\";\n const ext = getUserFileExtension();\n\n return {\n core: {\n service: `${kebabModelName}.service.${ext}`,\n controller: `${kebabModelName}.controller.${ext}`,\n middlewares: `${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 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 createMany: `create-many-${kebabModelName}.dto.${ext}`,\n update: `update-${kebabModelName}.dto.${ext}`,\n updateMany: `update-many-${kebabModelName}.dto.${ext}`,\n findOne: `find-one-${kebabModelName}.dto.${ext}`,\n findMany: `find-many-${kebabModelName}.dto.${ext}`,\n query: `query-${kebabModelName}.dto.${ext}`,\n },\n schemas: isAuthModule\n ? {\n login: `login.schema.${ext}`,\n signup: `signup.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 createMany: `create-many-${kebabModelName}.schema.${ext}`,\n update: `update-${kebabModelName}.schema.${ext}`,\n updateMany: `update-many-${kebabModelName}.schema.${ext}`,\n findOne: `find-one-${kebabModelName}.schema.${ext}`,\n findMany: `find-many-${kebabModelName}.schema.${ext}`,\n query: `query-${kebabModelName}.schema.${ext}`,\n },\n };\n}\n\nexport async function processSubdir(\n modelName: string,\n type: \"dtos\" | \"schemas\",\n result: Record<string, any>\n) {\n const moduleDir = path.resolve(crd(), \"src\", \"modules\", kebabCase(modelName));\n\n const subdir = path.join(moduleDir, type);\n const fileStructure = getFileModelModulesFileStructure(modelName);\n\n // Skip if directory doesn't exist\n try {\n await fs.promises.access(subdir).catch(() => {\n return; // Directory doesn't exist\n });\n\n await Promise.all(\n Object.entries(fileStructure[type]).map(async ([key, fileName]) => {\n const filePath = path.join(subdir, fileName);\n try {\n const module = await importModule(filePath).catch(() => null);\n if (module) result[type][key] = module.default;\n } catch (error) {\n // Silent fail - file might not exist\n console.error(error);\n }\n })\n );\n } catch (error) {\n // Directory doesn't exist, continue silently\n console.error(error);\n }\n}\n\ntype importPrismaModelModulesReturnType = {\n service?: any;\n controller?: any;\n middlewares?: any;\n authConfigs?: AuthConfigs;\n authConfigsNew?: AuthConfigs;\n prismaQueryOptions?: any;\n prismaQueryOptionsNew?: any;\n router?: any;\n dtos: Record<string, any>;\n schemas: Record<string, any>;\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 {importPrismaModelModulesReturnType} 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: importPrismaModelModulesReturnType\n): void {\n if (key === \"prismaQueryOptions\") {\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 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 {importPrismaModelModulesReturnType} result - The result object to modify\n */\nexport function assignModuleToResult(\n key: string,\n module: any,\n result: importPrismaModelModulesReturnType\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 === \"middlewares\" || key === \"router\") {\n result[key] = module;\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 importPrismaModelModules(\n modelName: string\n): Promise<importPrismaModelModulesReturnType> {\n const moduleDir = path.resolve(crd(), \"src\", \"modules\", kebabCase(modelName));\n\n const result: importPrismaModelModulesReturnType = {\n dtos: {},\n schemas: {},\n };\n\n if (getModelModules(modelName)) return getModelModules(modelName);\n\n const fileStructure = getFileModelModulesFileStructure(modelName);\n\n // Batch process core files\n await Promise.all(\n Object.entries(fileStructure.core).map(async ([key, fileName]) => {\n const filePath = path.join(moduleDir, fileName);\n try {\n const module = await importModule(filePath).catch((err) => {\n if (!err.message.includes(\"Cannot find module\")) {\n console.error(`Failed to import ${fileName}: \\n`);\n console.error(err);\n killServerChildProcess();\n process.exit(1);\n }\n });\n\n if (module) {\n // Validate naming conventions before assignment\n validateNamingConventions(key, fileName, result);\n\n // Assign module to result\n assignModuleToResult(key, module, result);\n }\n } catch (err: any) {\n if (err.message.includes(\"Cannot use both\")) throw err;\n console.error(err);\n killServerChildProcess();\n }\n })\n );\n\n await Promise.all([\n processSubdir(modelName, \"dtos\", result),\n processSubdir(modelName, \"schemas\", result),\n ]);\n\n // Removed because caused problems with cached ZObjects\n // Cache the result making shallow copy to not cause problems after build\n // prismaModelsModules[modelName] = JSON.parse(JSON.stringify(result));\n prismaModelsModules[modelName] = result;\n\n return result;\n}\n\nexport type ModelFieldDefition = {\n name: string;\n type: string;\n isUnique: boolean;\n};\n\n/**\n * Represents the structure of relation fields for Prisma models.\n * It includes both singular (one-to-one) and list (one-to-many) relationships.\n *\n * @typedef {Object} RelationFields\n * @property {Array<{name: string, type: string}>} singular - List of singular relationships.\n * @property {Array<{name: string, type: string}>} list - List of list relationships.\n */\nexport type RelationFields = {\n singular: Omit<ModelFieldDefition, \"isUnique\">[];\n list: Omit<ModelFieldDefition, \"isUnique\">[];\n};\n\n/**\n * Reads the Prisma schema files and extracts all model definitions,\n * identifying their relations (one-to-one and one-to-many).\n */\nexport const prismaModelRelationFields: Record<string, RelationFields> = {};\n\nexport function getAllPrismaFiles(dirPath: string, fileList: string[] = []) {\n const files = fs.readdirSync(dirPath);\n\n files?.forEach((file) => {\n const filePath = path.join(dirPath, file);\n const stat = fs.statSync(filePath);\n\n // Skip migrations folder\n if (stat.isDirectory() && file !== \"migrations\") {\n fileList = getAllPrismaFiles(filePath, fileList);\n } else if (stat.isFile() && file.endsWith(\".prisma\")) {\n fileList.push(filePath);\n }\n });\n\n return fileList;\n}\n\nconst modelRegex = /model\\s+(\\w+)\\s*{/g;\nexport const models: string[] = [];\nexport let prismaSchemasContent: string;\nexport const prismaModelsUniqueFields: Record<string, ModelFieldDefition[]> =\n [] as any;\n\nexport function initializePrismaModels() {\n const prismaContent: string[] = [];\n\n const files = getAllPrismaFiles(\"./prisma\");\n\n for (const file of files) {\n const content = fs.readFileSync(file, \"utf-8\");\n\n if (!prismaContent?.includes?.(content)) prismaContent.push(content);\n }\n\n // Gather the content of all *.prisma files into single one\n const content = prismaContent\n .join(\"\\n\")\n .replace(modelRegex, (_, modelName) => {\n if (!models?.includes?.(modelName))\n models.push(camelCase(modelName.trim()));\n return `model ${modelName} {`;\n });\n\n const copiedContent = content;\n prismaSchemasContent = content;\n\n for (const model of models) {\n const modelName = pascalCase(model);\n\n const modelStart = copiedContent.indexOf(`model ${modelName} {`);\n const modelEnd = copiedContent.indexOf(\"}\", modelStart);\n const modelDefinition = copiedContent.slice(modelStart, modelEnd);\n\n const relations: RelationFields = {\n singular: [],\n list: [],\n };\n const lines = modelDefinition.split(\"\\n\");\n\n for (const line of lines) {\n const trimmedLine = line.trim();\n\n if (\n !trimmedLine ||\n trimmedLine.startsWith(\"model\") ||\n trimmedLine.startsWith(\"//\") ||\n trimmedLine.startsWith(\"/*\")\n )\n continue;\n\n const [fieldName, type] = trimmedLine.split(/\\s+/);\n const isUnique = trimmedLine?.includes?.(\"@unique\");\n\n if (isUnique) {\n const existingFields = prismaModelsUniqueFields[model] || [];\n\n const alreadyExists = existingFields.some(\n (field) =>\n field.name === fieldName &&\n field.type === type &&\n field.isUnique === isUnique\n );\n\n if (!alreadyExists) {\n prismaModelsUniqueFields[model] = [\n ...existingFields,\n { name: fieldName, type, isUnique },\n ];\n }\n }\n\n const cleanType = type?.replace(\"[]\", \"\").replace(\"?\", \"\");\n\n if (\n trimmedLine?.includes?.(\"@relation\") ||\n trimmedLine.match(/\\s+\\w+(\\[\\])?(\\s+@|$)/) ||\n models?.includes?.(camelCase(cleanType || \"\"))\n ) {\n const enumStart = copiedContent.indexOf(`enum ${cleanType} {`);\n const typeStart = copiedContent.indexOf(`type ${cleanType} {`);\n\n if (\n !cleanType ||\n enumStart >= 0 ||\n typeStart >= 0 ||\n cleanType === \"String\" ||\n cleanType === \"Int\" ||\n cleanType === \"Float\" ||\n cleanType === \"Boolean\" ||\n cleanType === \"DateTime\" ||\n cleanType === \"Bytes\" ||\n cleanType === \"Decimal\" ||\n cleanType === \"BigInt\" ||\n cleanType === \"Json\"\n ) {\n continue;\n }\n\n if (!type?.includes?.(\"[]\")) {\n relations.singular.push({\n name: fieldName,\n type: cleanType,\n });\n } else {\n relations.list.push({\n name: fieldName,\n type: cleanType,\n });\n }\n }\n\n prismaModelRelationFields[modelName] = relations;\n }\n }\n}\n\n// initializePrismaModels();\n\n/**\n * Retrieves the relations for a given Prisma model.\n *\n * @param {string} modelName - The name of the model (e.g., \"User\").\n * @returns {RelationFields|undefined} The relation fields for the model, or `undefined` if no relations are found.\n */\nexport function getPrismaModelRelations(\n modelName: string\n): RelationFields | undefined {\n modelName = pascalCase(modelName);\n\n if (!(modelName in prismaModelRelationFields)) return;\n return prismaModelRelationFields[modelName];\n}\n\n/**\n * Retrieves all the model names from the Prisma schema.\n *\n * @returns {string[]} An array of model names (e.g., [\"User\", \"Post\"]).\n */\nfunction getModels(): string[] {\n return models;\n}\n\n/**\n * Returns all content of all .prisma files gathered together\n *\n * @returns {string}\n */\nexport function getPrismaSchemasContent(): string {\n return prismaSchemasContent;\n}\n\n/** Retuns a given model unique fields\n * @param {string} modelName - The name of model in PascalCase\n * @returns {string[]} An array of all unique fields,\n */\nfunction getModelUniqueFields(modelName: string): ModelFieldDefition[] {\n return prismaModelsUniqueFields[modelName];\n}\n\nexport { getModels, getModelUniqueFields };\n"]}
1
+ {"version":3,"file":"models.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/models.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EACL,SAAS,EACT,SAAS,EACT,UAAU,GACX,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,GAAG,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAMlE,IAAI,mBAAmB,GAAgC,EAAE,CAAC;AAE1D,MAAM,UAAU,eAAe,CAAC,SAAiB,EAAE,OAAoB;IACrE,mBAAmB,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,GAAG,OAAO,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,SAAiB;IAC/C,OAAO,mBAAmB,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,gCAAgC,CAAC,SAAiB;IAChE,MAAM,cAAc,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC;IAC1D,MAAM,YAAY,GAAG,SAAS,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC;IACxD,MAAM,GAAG,GAAG,oBAAoB,EAAE,CAAC;IAEnC,OAAO;QACL,IAAI,EAAE;YACJ,OAAO,EAAE,GAAG,cAAc,YAAY,GAAG,EAAE;YAC3C,UAAU,EAAE,GAAG,cAAc,eAAe,GAAG,EAAE;YACjD,WAAW,EAAE,GAAG,cAAc,gBAAgB,GAAG,EAAE;YACnD,WAAW,EAAE,GAAG,cAAc,iBAAiB,G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B;IACrC,OAAO,oBAAoB,CAAC;AAC9B,CAAC;AAMD,SAAS,oBAAoB,CAAC,SAAiB;IAC7C,OAAO,wBAAwB,CAAC,SAAS,CAAC,CAAC;AAC7C,CAAC;AAED,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,CAAC","sourcesContent":["import path from \"path\";\nimport fs from \"fs\";\nimport {\n camelCase,\n kebabCase,\n pascalCase,\n} from \"../../utils/helpers/change-case.helpers\";\nimport { crd, getUserFileExtension } from \"./fs.helpers\";\nimport { importModule } from \"./global.helpers\";\nimport { AuthConfigs } from \"../../types/auth\";\nimport { killServerChildProcess } from \"../cli/utils/cli.helpers\";\nimport { ArkosConfig } from \"../../exports\";\n\ntype ModeModules = Awaited<ReturnType<typeof importPrismaModelModules>>;\n\n// Must be exported to not cause problems on cjs\nlet prismaModelsModules: Record<string, ModeModules> = {};\n\nexport function setModelModules(modelName: string, modules: ModeModules) {\n prismaModelsModules[kebabCase(modelName)] = modules;\n}\n\nexport function getModelModules(modelName: string) {\n return prismaModelsModules[kebabCase(modelName)];\n}\n\nexport function getFileModelModulesFileStructure(modelName: string) {\n const kebabModelName = kebabCase(modelName).toLowerCase();\n const isAuthModule = modelName.toLowerCase() === \"auth\";\n const ext = getUserFileExtension();\n\n return {\n core: {\n service: `${kebabModelName}.service.${ext}`,\n controller: `${kebabModelName}.controller.${ext}`,\n middlewares: `${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 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 createMany: `create-many-${kebabModelName}.dto.${ext}`,\n update: `update-${kebabModelName}.dto.${ext}`,\n updateMany: `update-many-${kebabModelName}.dto.${ext}`,\n findOne: `find-one-${kebabModelName}.dto.${ext}`,\n findMany: `find-many-${kebabModelName}.dto.${ext}`,\n query: `query-${kebabModelName}.dto.${ext}`,\n },\n schemas: isAuthModule\n ? {\n login: `login.schema.${ext}`,\n signup: `signup.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 createMany: `create-many-${kebabModelName}.schema.${ext}`,\n update: `update-${kebabModelName}.schema.${ext}`,\n updateMany: `update-many-${kebabModelName}.schema.${ext}`,\n findOne: `find-one-${kebabModelName}.schema.${ext}`,\n findMany: `find-many-${kebabModelName}.schema.${ext}`,\n query: `query-${kebabModelName}.schema.${ext}`,\n },\n };\n}\n\nexport async function processSubdir(\n modelName: string,\n type: \"dtos\" | \"schemas\",\n result: Record<string, any> = {}\n) {\n const moduleDir = path.resolve(crd(), \"src\", \"modules\", kebabCase(modelName));\n\n const subdir = path.join(moduleDir, type);\n const fileStructure = getFileModelModulesFileStructure(modelName);\n\n // Skip if directory doesn't exist\n try {\n await fs.promises.access(subdir).catch(() => {\n return; // Directory doesn't exist\n });\n\n await Promise.all(\n Object.entries(fileStructure[type]).map(async ([key, fileName]) => {\n const filePath = path.join(subdir, fileName);\n try {\n const module = await importModule(filePath).catch(() => null);\n if (module) result[key] = module.default;\n } catch (error) {\n // Silent fail - file might not exist\n console.error(error);\n }\n })\n );\n } catch (error) {\n // Directory doesn't exist, continue silently\n console.error(error);\n }\n\n return result;\n}\n\ntype importPrismaModelModulesReturnType = {\n service?: any;\n controller?: any;\n middlewares?: any;\n authConfigs?: AuthConfigs;\n authConfigsNew?: AuthConfigs;\n prismaQueryOptions?: any;\n prismaQueryOptionsNew?: any;\n router?: any;\n dtos?: Record<string, any>;\n schemas?: Record<string, any>;\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 {importPrismaModelModulesReturnType} 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: importPrismaModelModulesReturnType\n): void {\n if (key === \"prismaQueryOptions\") {\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 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 {importPrismaModelModulesReturnType} result - The result object to modify\n */\nexport function assignModuleToResult(\n key: string,\n module: any,\n result: importPrismaModelModulesReturnType\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 === \"middlewares\" || key === \"router\") {\n result[key] = module;\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 importPrismaModelModules(\n modelName: string,\n arkosConfig: ArkosConfig\n): Promise<importPrismaModelModulesReturnType> {\n const moduleDir = path.resolve(crd(), \"src\", \"modules\", kebabCase(modelName));\n\n const result: importPrismaModelModulesReturnType = {\n dtos: {},\n schemas: {},\n };\n\n if (getModelModules(modelName)) return getModelModules(modelName);\n\n const fileStructure = getFileModelModulesFileStructure(modelName);\n\n // Batch process core files\n await Promise.all(\n Object.entries(fileStructure.core).map(async ([key, fileName]) => {\n const filePath = path.join(moduleDir, fileName);\n try {\n const module = await importModule(filePath).catch((err) => {\n if (!err.message.includes(\"Cannot find module\")) {\n console.error(`Failed to import ${fileName}: \\n`);\n console.error(err);\n killServerChildProcess();\n process.exit(1);\n }\n });\n\n if (module) {\n // Validate naming conventions before assignment\n validateNamingConventions(key, fileName, result);\n\n // Assign module to result\n assignModuleToResult(key, module, result);\n }\n } catch (err: any) {\n if (err.message.includes(\"Cannot use both\")) throw err;\n console.error(err);\n killServerChildProcess();\n }\n })\n );\n\n const validationSubdir = arkosConfig.validation?.resolver\n ? arkosConfig.validation.resolver === \"zod\"\n ? \"schemas\"\n : \"dtos\"\n : null;\n\n let validators = {};\n if (validationSubdir)\n validators = await processSubdir(modelName, validationSubdir);\n\n // Removed because caused problems with cached ZObjects\n // Cache the result making shallow copy to not cause problems after build\n // prismaModelsModules[modelName] = JSON.parse(JSON.stringify(result));\n prismaModelsModules[modelName] = {\n ...result,\n ...(validationSubdir && { [validationSubdir]: validators }),\n };\n\n return result;\n}\n\nexport type ModelFieldDefition = {\n name: string;\n type: string;\n isUnique: boolean;\n};\n\n/**\n * Represents the structure of relation fields for Prisma models.\n * It includes both singular (one-to-one) and list (one-to-many) relationships.\n *\n * @typedef {Object} RelationFields\n * @property {Array<{name: string, type: string}>} singular - List of singular relationships.\n * @property {Array<{name: string, type: string}>} list - List of list relationships.\n */\nexport type RelationFields = {\n singular: Omit<ModelFieldDefition, \"isUnique\">[];\n list: Omit<ModelFieldDefition, \"isUnique\">[];\n};\n\n/**\n * Reads the Prisma schema files and extracts all model definitions,\n * identifying their relations (one-to-one and one-to-many).\n */\nexport const prismaModelRelationFields: Record<string, RelationFields> = {};\n\nexport function getAllPrismaFiles(dirPath: string, fileList: string[] = []) {\n const files = fs.readdirSync(dirPath);\n\n files?.forEach((file) => {\n const filePath = path.join(dirPath, file);\n const stat = fs.statSync(filePath);\n\n // Skip migrations folder\n if (stat.isDirectory() && file !== \"migrations\") {\n fileList = getAllPrismaFiles(filePath, fileList);\n } else if (stat.isFile() && file.endsWith(\".prisma\")) {\n fileList.push(filePath);\n }\n });\n\n return fileList;\n}\n\nconst modelRegex = /model\\s+(\\w+)\\s*{/g;\nexport const models: string[] = [];\nexport let prismaSchemasContent: string;\nexport const prismaModelsUniqueFields: Record<string, ModelFieldDefition[]> =\n [] as any;\n\nexport function initializePrismaModels() {\n const prismaContent: string[] = [];\n\n const files = getAllPrismaFiles(\"./prisma\");\n\n for (const file of files) {\n const content = fs.readFileSync(file, \"utf-8\");\n\n if (!prismaContent?.includes?.(content)) prismaContent.push(content);\n }\n\n // Gather the content of all *.prisma files into single one\n const content = prismaContent\n .join(\"\\n\")\n .replace(modelRegex, (_, modelName) => {\n if (!models?.includes?.(modelName))\n models.push(camelCase(modelName.trim()));\n return `model ${modelName} {`;\n });\n\n const copiedContent = content;\n prismaSchemasContent = content;\n\n for (const model of models) {\n const modelName = pascalCase(model);\n\n const modelStart = copiedContent.indexOf(`model ${modelName} {`);\n const modelEnd = copiedContent.indexOf(\"}\", modelStart);\n const modelDefinition = copiedContent.slice(modelStart, modelEnd);\n\n const relations: RelationFields = {\n singular: [],\n list: [],\n };\n const lines = modelDefinition.split(\"\\n\");\n\n for (const line of lines) {\n const trimmedLine = line.trim();\n\n if (\n !trimmedLine ||\n trimmedLine.startsWith(\"model\") ||\n trimmedLine.startsWith(\"//\") ||\n trimmedLine.startsWith(\"/*\")\n )\n continue;\n\n const [fieldName, type] = trimmedLine.split(/\\s+/);\n const isUnique = trimmedLine?.includes?.(\"@unique\");\n\n if (isUnique) {\n const existingFields = prismaModelsUniqueFields[model] || [];\n\n const alreadyExists = existingFields.some(\n (field) =>\n field.name === fieldName &&\n field.type === type &&\n field.isUnique === isUnique\n );\n\n if (!alreadyExists) {\n prismaModelsUniqueFields[model] = [\n ...existingFields,\n { name: fieldName, type, isUnique },\n ];\n }\n }\n\n const cleanType = type?.replace(\"[]\", \"\").replace(\"?\", \"\");\n\n if (\n trimmedLine?.includes?.(\"@relation\") ||\n trimmedLine.match(/\\s+\\w+(\\[\\])?(\\s+@|$)/) ||\n models?.includes?.(camelCase(cleanType || \"\"))\n ) {\n const enumStart = copiedContent.indexOf(`enum ${cleanType} {`);\n const typeStart = copiedContent.indexOf(`type ${cleanType} {`);\n\n if (\n !cleanType ||\n enumStart >= 0 ||\n typeStart >= 0 ||\n cleanType === \"String\" ||\n cleanType === \"Int\" ||\n cleanType === \"Float\" ||\n cleanType === \"Boolean\" ||\n cleanType === \"DateTime\" ||\n cleanType === \"Bytes\" ||\n cleanType === \"Decimal\" ||\n cleanType === \"BigInt\" ||\n cleanType === \"Json\"\n ) {\n continue;\n }\n\n if (!type?.includes?.(\"[]\")) {\n relations.singular.push({\n name: fieldName,\n type: cleanType,\n });\n } else {\n relations.list.push({\n name: fieldName,\n type: cleanType,\n });\n }\n }\n\n prismaModelRelationFields[modelName] = relations;\n }\n }\n}\n\n/**\n * Retrieves the relations for a given Prisma model.\n *\n * @param {string} modelName - The name of the model (e.g., \"User\").\n * @returns {RelationFields|undefined} The relation fields for the model, or `undefined` if no relations are found.\n */\nexport function getPrismaModelRelations(\n modelName: string\n): RelationFields | undefined {\n modelName = pascalCase(modelName);\n\n if (!(modelName in prismaModelRelationFields)) return;\n return prismaModelRelationFields[modelName];\n}\n\n/**\n * Retrieves all the model names from the Prisma schema.\n *\n * @returns {string[]} An array of model names (e.g., [\"User\", \"Post\"]).\n */\nfunction getModels(): string[] {\n return models;\n}\n\n/**\n * Returns all content of all .prisma files gathered together\n *\n * @returns {string}\n */\nexport function getPrismaSchemasContent(): string {\n return prismaSchemasContent;\n}\n\n/** Retuns a given model unique fields\n * @param {string} modelName - The name of model in PascalCase\n * @returns {string[]} An array of all unique fields,\n */\nfunction getModelUniqueFields(modelName: string): ModelFieldDefition[] {\n return prismaModelsUniqueFields[modelName];\n}\n\nexport { getModels, getModelUniqueFields };\n"]}
@@ -8,17 +8,20 @@ export async function loadPrismaModule() {
8
8
  if (!prismaInstance) {
9
9
  try {
10
10
  let prismaPath = `${crd()}/src/utils/prisma.${ext()}`;
11
- if (!fs.existsSync(prismaPath)) {
11
+ if (!fs.existsSync(prismaPath))
12
12
  prismaPath = `${crd()}/src/utils/prisma/index.${ext()}`;
13
- }
14
- const prismaModule = await importModule(prismaPath);
13
+ if (!fs.existsSync(prismaPath))
14
+ throw new Error("Could not found exported prisma insteance");
15
+ const prismaModule = await importModule(prismaPath, {
16
+ fixExtension: false,
17
+ });
15
18
  prismaInstance = prismaModule.default || prismaModule.prisma;
16
19
  if (!prismaInstance)
17
20
  throw new Error("Prisma not found");
18
21
  }
19
22
  catch (error) {
20
23
  if (error.message === "Prisma not found")
21
- throw new AppError(`Could not initialize Prisma module. Make sure your prisma instance is exported under src/utils/prisma.${ext()} or src/utils/prisma/index.${ext()}, read more about Arkos' Project Structure under https://www.arkosjs.com/docs/project-structure#root-structure`, 500, {}, "prisma_instance_not_found");
24
+ throw new AppError(`Could not initialize Prisma module. Make sure your prisma instance is exported under src/utils/prisma.${ext()} or src/utils/prisma/index.${ext()}, read more about Arkos' Project Structure under https://www.arkosjs.com/docs/project-structure#root-structure`, 500, {}, "PrismaInstanceNotFound");
22
25
  throw error;
23
26
  }
24
27
  }
@@ -1 +1 @@
1
- {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,cAAc,CAAC;AACxB,CAAC;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG,UAAU,CAC/C,KAAK,EAAE,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAE,EAAE;IACxD,MAAM,MAAM,GAAG,MAAM,gBAAgB,EAAE,CAAC;IACxC,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAC;QACxB,IAAI,EAAE,CAAC;IACT,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QAC1D,IAAI,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;IACzC,CAAC;AACH,CAAC,CACF,CAAC","sourcesContent":["import fs from \"fs\";\nimport { Request, Response, NextFunction } from \"express\";\nimport catchAsync from \"../../modules/error-handler/utils/catch-async\";\nimport AppError from \"../../modules/error-handler/utils/app-error\";\nimport { crd, getUserFileExtension as ext } from \"./fs.helpers\";\nimport { importModule } from \"./global.helpers\";\n\nexport let prismaInstance: any = null;\n\nexport async function loadPrismaModule() {\n if (!prismaInstance) {\n try {\n let prismaPath = `${crd()}/src/utils/prisma.${ext()}`;\n\n if (!fs.existsSync(prismaPath)) {\n prismaPath = `${crd()}/src/utils/prisma/index.${ext()}`;\n }\n\n const prismaModule = await importModule(prismaPath);\n prismaInstance = prismaModule.default || prismaModule.prisma;\n\n if (!prismaInstance) throw new Error(\"Prisma not found\");\n } catch (error: any) {\n if (error.message === \"Prisma not found\")\n throw new AppError(\n `Could not initialize Prisma module. Make sure your prisma instance is exported under src/utils/prisma.${ext()} or src/utils/prisma/index.${ext()}, read more about Arkos' Project Structure under https://www.arkosjs.com/docs/project-structure#root-structure`,\n 500,\n {},\n \"prisma_instance_not_found\"\n );\n throw error;\n }\n }\n return prismaInstance;\n}\n\nexport function getPrismaInstance() {\n return prismaInstance;\n}\n\nexport const checkDatabaseConnection = catchAsync(\n async (req: Request, res: Response, next: NextFunction) => {\n const prisma = await loadPrismaModule();\n try {\n await prisma.$connect();\n next();\n } catch (error: any) {\n console.error(\"Database connection error\", error.message);\n next(new AppError(error.message, 503));\n }\n }\n);\n"]}
1
+ {"version":3,"file":"prisma.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/prisma.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,UAAU,MAAM,+CAA+C,CAAC;AACvE,OAAO,QAAQ,MAAM,6CAA6C,CAAC;AACnE,OAAO,EAAE,GAAG,EAAE,oBAAoB,IAAI,GAAG,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,CAAC,IAAI,cAAc,GAAQ,IAAI,CAAC;AAEtC,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,IAAI,CAAC;YACH,IAAI,UAAU,GAAG,GAAG,GAAG,EAAE,qBAAqB,GAAG,EAAE,EAAE,CAAC;YAEtD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;gBAC5B,UAAU,GAAG,GAAG,GAAG,EAAE,2BAA2B,GAAG,EAAE,EAAE,CAAC;YAE1D,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;gBAC5B,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;YAE/D,MAAM,YAAY,GAAG,MAAM,YAAY,CAAC,UAAU,EAAE;gBAClD,YAAY,EAAE,KAAK;aACpB,CAAC,CAAC;YACH,cAAc,GAAG,YAAY,CAAC,OAAO,IAAI,YAAY,CAAC,MAAM,CAAC;YAE7D,IAAI,CAAC,cAAc;gBAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAC3D,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,KAAK,CAAC,OAAO,KAAK,kBAAkB;gBACtC,MAAM,IAAI,QAAQ,CAChB,yGAAyG,GAAG,EAAE,8BAA8B,GAAG,EAAE,gHAAgH,EACjQ,GAAG,EACH,EAAE,EACF,wBAAwB,CACzB,CAAC;YACJ,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,iBAAiB;IAC/B,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG,UAAU,CAC/C,KAAK,EAAE,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAE,EAAE;IACxD,MAAM,MAAM,GAAG,MAAM,gBAAgB,EAAE,CAAC;IACxC,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAC;QACxB,IAAI,EAAE,CAAC;IACT,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QAC1D,IAAI,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;IACzC,CAAC;AACH,CAAC,CACF,CAAC","sourcesContent":["import fs from \"fs\";\nimport { Request, Response, NextFunction } from \"express\";\nimport catchAsync from \"../../modules/error-handler/utils/catch-async\";\nimport AppError from \"../../modules/error-handler/utils/app-error\";\nimport { crd, getUserFileExtension as ext } from \"./fs.helpers\";\nimport { importModule } from \"./global.helpers\";\n\nexport let prismaInstance: any = null;\n\nexport async function loadPrismaModule() {\n if (!prismaInstance) {\n try {\n let prismaPath = `${crd()}/src/utils/prisma.${ext()}`;\n\n if (!fs.existsSync(prismaPath))\n prismaPath = `${crd()}/src/utils/prisma/index.${ext()}`;\n\n if (!fs.existsSync(prismaPath))\n throw new Error(\"Could not found exported prisma insteance\");\n\n const prismaModule = await importModule(prismaPath, {\n fixExtension: false,\n });\n prismaInstance = prismaModule.default || prismaModule.prisma;\n\n if (!prismaInstance) throw new Error(\"Prisma not found\");\n } catch (error: any) {\n if (error.message === \"Prisma not found\")\n throw new AppError(\n `Could not initialize Prisma module. Make sure your prisma instance is exported under src/utils/prisma.${ext()} or src/utils/prisma/index.${ext()}, read more about Arkos' Project Structure under https://www.arkosjs.com/docs/project-structure#root-structure`,\n 500,\n {},\n \"PrismaInstanceNotFound\"\n );\n throw error;\n }\n }\n return prismaInstance;\n}\n\nexport function getPrismaInstance() {\n return prismaInstance;\n}\n\nexport const checkDatabaseConnection = catchAsync(\n async (req: Request, res: Response, next: NextFunction) => {\n const prisma = await loadPrismaModule();\n try {\n await prisma.$connect();\n next();\n } catch (error: any) {\n console.error(\"Database connection error\", error.message);\n next(new AppError(error.message, 503));\n }\n }\n);\n"]}
@@ -3,11 +3,11 @@ export declare const defaultExcludedUserFields: {
3
3
  password: boolean;
4
4
  };
5
5
  export declare const authControllerFactory: (middlewares?: any) => Promise<{
6
- getMe: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<unknown>;
7
- updateMe: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<unknown>;
8
- logout: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<unknown>;
9
- login: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<unknown>;
10
- signup: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<unknown>;
11
- deleteMe: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<unknown>;
12
- updatePassword: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<unknown>;
6
+ getMe: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<void>;
7
+ updateMe: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<void>;
8
+ logout: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<void>;
9
+ login: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<void>;
10
+ signup: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<void>;
11
+ deleteMe: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<void>;
12
+ updatePassword: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<void>;
13
13
  }>;
@@ -12,7 +12,7 @@ export declare class AuthService {
12
12
  verifyJwtToken(token: string, secret?: string): Promise<AuthJwtPayload>;
13
13
  handleAccessControl(action: AccessAction, resourceName: string, accessControl?: AccessControlConfig): ArkosRequestHandler;
14
14
  getAuthenticatedUser(req: ArkosRequest): Promise<User | null>;
15
- authenticate: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<unknown>;
15
+ authenticate: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<void>;
16
16
  handleAuthenticationControl(action: AccessAction, authenticationControl?: AuthenticationControlConfig | undefined): ArkosRequestHandler;
17
17
  }
18
18
  declare const authService: AuthService;
@@ -4,14 +4,14 @@ export declare class BaseController {
4
4
  private modelName;
5
5
  private middlewares;
6
6
  constructor(modelName: string);
7
- createOne: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<unknown>;
8
- createMany: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<unknown>;
9
- findMany: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<unknown>;
10
- findOne: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<unknown>;
11
- updateOne: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<unknown>;
12
- updateMany: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<unknown>;
13
- deleteOne: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<unknown>;
14
- deleteMany: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<unknown>;
7
+ createOne: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<void>;
8
+ createMany: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<void>;
9
+ findMany: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<void>;
10
+ findOne: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<void>;
11
+ updateOne: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<void>;
12
+ updateMany: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<void>;
13
+ deleteOne: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<void>;
14
+ deleteMany: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<void>;
15
15
  }
16
16
  export declare function getAvalibleRoutes(req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction): void;
17
- export declare const getAvailableResources: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<unknown>;
17
+ export declare const getAvailableResources: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<void>;
@@ -20,7 +20,7 @@ export declare class BaseService<ModelDelegate extends Record<string, any> = any
20
20
  where?: infer W;
21
21
  [x: string]: any;
22
22
  } ? W : any): Promise<number>;
23
- findMany<TOptions extends Omit<Parameters<ModelDelegate["findMany"]>[0], "where">>(filters: Parameters<ModelDelegate["findMany"]>[0] extends {
23
+ findMany<TOptions extends Omit<Parameters<ModelDelegate["findMany"]>[0], "where">>(filters?: Parameters<ModelDelegate["findMany"]>[0] extends {
24
24
  where?: infer W;
25
25
  [x: string]: any;
26
26
  } ? W : any, queryOptions?: TOptions): Promise<ModelDelegate["findMany"] extends (args: {
@@ -1,3 +1,3 @@
1
1
  import { ArkosRequest, ArkosResponse, ArkosNextFunction, ArkosRequestHandler } from "../../../types";
2
- declare const catchAsync: (fn: ArkosRequestHandler) => (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<unknown>;
2
+ declare const catchAsync: (fn: ArkosRequestHandler) => (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<void>;
3
3
  export default catchAsync;
@@ -40,3 +40,7 @@ export declare function handleNetworkError(err: AppError): AppError;
40
40
  export declare function handleUnhandledPromiseError(err: AppError): AppError;
41
41
  export declare function handleDataTypeError(err: AppError): AppError;
42
42
  export declare function handleEmptyResultError(err: AppError): AppError;
43
+ export declare function handleNonExistingRecord(err: {
44
+ meta?: Record<string, any>;
45
+ [x: string]: any;
46
+ }): AppError;
@@ -1,10 +1,10 @@
1
1
  import { ArkosNextFunction, ArkosRequest, ArkosResponse } from "../../types";
2
2
  declare class FileUploadController {
3
3
  private middlewares;
4
- uploadFile: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<unknown>;
5
- deleteFile: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<unknown>;
6
- updateFile: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<unknown>;
7
- streamFile: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<unknown>;
4
+ uploadFile: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<void>;
5
+ deleteFile: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<void>;
6
+ updateFile: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<void>;
7
+ streamFile: (req: ArkosRequest, res: ArkosResponse, next: ArkosNextFunction) => Promise<void>;
8
8
  }
9
9
  declare const fileUploadController: FileUploadController;
10
10
  export default fileUploadController;
@@ -1,3 +1,3 @@
1
1
  import { Router } from "express";
2
2
  import { ArkosConfig } from "../../types/arkos-config";
3
- export declare function getFileUploadRouter({ fileUpload }: ArkosConfig): Promise<Router>;
3
+ export declare function getFileUploadRouter(arkosConfig: ArkosConfig): Promise<Router>;
@@ -4,4 +4,4 @@ export declare function getOpenAPIJsonSchemasByConfigMode(swaggerConfig: ArkosCo
4
4
  export declare function getCorrectJsonSchemaName(type: string, modelName: string, suffix: "Dto" | "Schema"): string;
5
5
  export declare function kebabToHuman(kebabStr: string): string;
6
6
  export declare function getSchemaRef(schemaName: string, mode: string): string;
7
- export declare function generatePathsForModels(swaggerConfig: ArkosConfig["swagger"]): Promise<OpenAPIV3.PathsObject>;
7
+ export declare function generatePathsForModels(arkosConfig: ArkosConfig): Promise<OpenAPIV3.PathsObject>;
@@ -1,4 +1,7 @@
1
1
  import { AuthConfigs } from "../../types/auth";
2
+ import { ArkosConfig } from "../../exports";
3
+ type ModeModules = Awaited<ReturnType<typeof importPrismaModelModules>>;
4
+ export declare function setModelModules(modelName: string, modules: ModeModules): void;
2
5
  export declare function getModelModules(modelName: string): importPrismaModelModulesReturnType;
3
6
  export declare function getFileModelModulesFileStructure(modelName: string): {
4
7
  core: {
@@ -66,7 +69,7 @@ export declare function getFileModelModulesFileStructure(modelName: string): {
66
69
  updatePassword?: undefined;
67
70
  };
68
71
  };
69
- export declare function processSubdir(modelName: string, type: "dtos" | "schemas", result: Record<string, any>): Promise<void>;
72
+ export declare function processSubdir(modelName: string, type: "dtos" | "schemas", result?: Record<string, any>): Promise<Record<string, any>>;
70
73
  type importPrismaModelModulesReturnType = {
71
74
  service?: any;
72
75
  controller?: any;
@@ -76,12 +79,12 @@ type importPrismaModelModulesReturnType = {
76
79
  prismaQueryOptions?: any;
77
80
  prismaQueryOptionsNew?: any;
78
81
  router?: any;
79
- dtos: Record<string, any>;
80
- schemas: Record<string, any>;
82
+ dtos?: Record<string, any>;
83
+ schemas?: Record<string, any>;
81
84
  };
82
85
  export declare function validateNamingConventions(key: string, fileName: string, result: importPrismaModelModulesReturnType): void;
83
86
  export declare function assignModuleToResult(key: string, module: any, result: importPrismaModelModulesReturnType): void;
84
- export declare function importPrismaModelModules(modelName: string): Promise<importPrismaModelModulesReturnType>;
87
+ export declare function importPrismaModelModules(modelName: string, arkosConfig: ArkosConfig): Promise<importPrismaModelModulesReturnType>;
85
88
  export type ModelFieldDefition = {
86
89
  name: string;
87
90
  type: string;
@@ -1,4 +1,4 @@
1
1
  export declare let prismaInstance: any;
2
2
  export declare function loadPrismaModule(): Promise<any>;
3
3
  export declare function getPrismaInstance(): any;
4
- export declare const checkDatabaseConnection: (req: import("../../types").ArkosRequest, res: import("../../types").ArkosResponse, next: import("../../types").ArkosNextFunction) => Promise<unknown>;
4
+ export declare const checkDatabaseConnection: (req: import("../../types").ArkosRequest, res: import("../../types").ArkosResponse, next: import("../../types").ArkosNextFunction) => Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arkos",
3
- "version": "1.2.29-test",
3
+ "version": "1.2.30-test",
4
4
  "description": "The Express & Prisma Framework For RESTful API",
5
5
  "main": "dist/cjs/exports/index.js",
6
6
  "module": "dist/esm/exports/index.js",
@@ -138,7 +138,7 @@
138
138
  "@types/html-to-text": "^9.0.4",
139
139
  "@types/jest": "^29.5.14",
140
140
  "@types/jsonwebtoken": "^9.0.9",
141
- "@types/multer": "^1.4.12",
141
+ "@types/multer": "2.0.0",
142
142
  "@types/node": "^22.13.13",
143
143
  "@types/nodemailer": "^6.4.17",
144
144
  "@types/pluralize": "^0.0.33",
@@ -152,7 +152,6 @@
152
152
  "openapi-types": "^12.1.3",
153
153
  "prisma": "^6.4.1",
154
154
  "ts-jest": "^29.3.1",
155
- "ts-node": "^10.9.2",
156
155
  "typescript": "^5.8.2"
157
156
  },
158
157
  "dependencies": {