arkos 1.2.13-beta → 1.2.13-test.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.
Files changed (222) hide show
  1. package/dist/cjs/app.js +138 -1
  2. package/dist/cjs/app.js.map +1 -1
  3. package/dist/cjs/index.js +22 -0
  4. package/dist/cjs/modules/base/base.middlewares.js +4 -4
  5. package/dist/cjs/modules/base/base.middlewares.js.map +1 -1
  6. package/dist/cjs/modules/swagger/swagger.router.js +62 -43
  7. package/dist/cjs/modules/swagger/swagger.router.js.map +1 -1
  8. package/dist/cjs/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js +82 -62
  9. package/dist/cjs/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js.map +1 -1
  10. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js +23 -16
  11. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js.map +1 -1
  12. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.js +1 -1
  13. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.js.map +1 -1
  14. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes.js +40 -11
  15. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes.js.map +1 -1
  16. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.js +419 -9
  17. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.js.map +1 -1
  18. package/dist/cjs/modules/swagger/utils/helpers/missing-json-schemas-generator.js +253 -0
  19. package/dist/cjs/modules/swagger/utils/helpers/missing-json-schemas-generator.js.map +1 -0
  20. package/dist/cjs/modules/swagger/utils/helpers/swagger.router.helpers.js +31 -20
  21. package/dist/cjs/modules/swagger/utils/helpers/swagger.router.helpers.js.map +1 -1
  22. package/dist/cjs/paths.js +9 -1
  23. package/dist/cjs/server.js +85 -5
  24. package/dist/cjs/server.js.map +1 -1
  25. package/dist/cjs/types/arkos-config.js.map +1 -1
  26. package/dist/cjs/utils/cli/dev.js +7 -7
  27. package/dist/cjs/utils/cli/dev.js.map +1 -1
  28. package/dist/cjs/utils/cli/start.js +4 -3
  29. package/dist/cjs/utils/cli/start.js.map +1 -1
  30. package/dist/cjs/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js +1 -1
  31. package/dist/cjs/utils/cli/utils/template-generator/templates/generate-service-template.js +1 -1
  32. package/dist/cjs/utils/features/api.features.js +1 -1
  33. package/dist/cjs/utils/features/api.features.js.map +1 -1
  34. package/dist/cjs/utils/helpers/global.helpers.js.map +1 -1
  35. package/dist/cjs/utils/helpers/models.helpers.js +43 -21
  36. package/dist/cjs/utils/helpers/models.helpers.js.map +1 -1
  37. package/dist/cjs/utils/prisma/enhaced-prisma-json-schema-generator.js +451 -0
  38. package/dist/cjs/utils/prisma/enhaced-prisma-json-schema-generator.js.map +1 -0
  39. package/dist/cjs/utils/prisma/prisma-json-schema-generator.js +88 -0
  40. package/dist/cjs/utils/prisma/prisma-json-schema-generator.js.map +1 -0
  41. package/dist/cjs/utils/prisma/prisma-schema-parser.js +158 -0
  42. package/dist/cjs/utils/prisma/prisma-schema-parser.js.map +1 -0
  43. package/dist/cjs/utils/prisma/types.js +3 -0
  44. package/dist/cjs/utils/prisma/types.js.map +1 -0
  45. package/dist/esm/index.d.mts +280 -0
  46. package/dist/esm/index.mjs +22 -0
  47. package/dist/exports/index.js +1 -0
  48. package/dist/types/arkos-config.js +1 -0
  49. package/dist/types/auth.js +1 -0
  50. package/dist/types/index.js +1 -0
  51. package/dist/types/modules/base/base.middlewares.d.ts +4 -4
  52. package/dist/types/modules/swagger/utils/helpers/get-authentication-json-schema-paths.d.ts +2 -1
  53. package/dist/types/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.d.ts +2 -1
  54. package/dist/types/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes.d.ts +2 -1
  55. package/dist/types/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.d.ts +2 -1
  56. package/dist/types/modules/swagger/utils/helpers/missing-json-schemas-generator.d.ts +34 -0
  57. package/dist/types/modules/swagger/utils/helpers/swagger.router.helpers.d.ts +2 -2
  58. package/dist/types/router-config.js +1 -0
  59. package/dist/types/types/arkos-config.d.ts +3 -1
  60. package/dist/types/utils/helpers/models.helpers.d.ts +18 -4
  61. package/dist/types/utils/prisma/enhaced-prisma-json-schema-generator.d.ts +34 -0
  62. package/dist/types/utils/prisma/prisma-json-schema-generator.d.ts +10 -0
  63. package/dist/types/utils/prisma/prisma-schema-parser.d.ts +18 -0
  64. package/dist/types/utils/prisma/types.d.ts +48 -0
  65. package/dist/utils/arkos-env.js +1 -0
  66. package/dist/utils/dotenv.helpers.js +1 -0
  67. package/dist/utils/sheu.js +1 -0
  68. package/dist/utils/validate-dto.js +1 -0
  69. package/dist/utils/validate-schema.js +1 -0
  70. package/package.json +11 -6
  71. package/dist/esm/app.js +0 -1
  72. package/dist/esm/app.js.map +0 -1
  73. package/dist/esm/exports/auth/index.js +0 -2
  74. package/dist/esm/exports/auth/index.js.map +0 -1
  75. package/dist/esm/exports/controllers/index.js +0 -4
  76. package/dist/esm/exports/controllers/index.js.map +0 -1
  77. package/dist/esm/exports/error-handler/index.js +0 -4
  78. package/dist/esm/exports/error-handler/index.js.map +0 -1
  79. package/dist/esm/exports/index.js +0 -8
  80. package/dist/esm/exports/index.js.map +0 -1
  81. package/dist/esm/exports/middlewares/index.js +0 -2
  82. package/dist/esm/exports/middlewares/index.js.map +0 -1
  83. package/dist/esm/exports/prisma/index.js +0 -3
  84. package/dist/esm/exports/prisma/index.js.map +0 -1
  85. package/dist/esm/exports/services/index.js +0 -9
  86. package/dist/esm/exports/services/index.js.map +0 -1
  87. package/dist/esm/exports/utils/index.js +0 -4
  88. package/dist/esm/exports/utils/index.js.map +0 -1
  89. package/dist/esm/exports/validation/index.js +0 -4
  90. package/dist/esm/exports/validation/index.js.map +0 -1
  91. package/dist/esm/modules/auth/auth.controller.js +0 -187
  92. package/dist/esm/modules/auth/auth.controller.js.map +0 -1
  93. package/dist/esm/modules/auth/auth.router.js +0 -44
  94. package/dist/esm/modules/auth/auth.router.js.map +0 -1
  95. package/dist/esm/modules/auth/auth.service.js +0 -178
  96. package/dist/esm/modules/auth/auth.service.js.map +0 -1
  97. package/dist/esm/modules/auth/utils/helpers/auth.controller.helpers.js +0 -73
  98. package/dist/esm/modules/auth/utils/helpers/auth.controller.helpers.js.map +0 -1
  99. package/dist/esm/modules/base/base.controller.js +0 -150
  100. package/dist/esm/modules/base/base.controller.js.map +0 -1
  101. package/dist/esm/modules/base/base.middlewares.js +0 -81
  102. package/dist/esm/modules/base/base.middlewares.js.map +0 -1
  103. package/dist/esm/modules/base/base.router.js +0 -17
  104. package/dist/esm/modules/base/base.router.js.map +0 -1
  105. package/dist/esm/modules/base/base.service.js +0 -120
  106. package/dist/esm/modules/base/base.service.js.map +0 -1
  107. package/dist/esm/modules/base/utils/helpers/base.controller.helpers.js +0 -77
  108. package/dist/esm/modules/base/utils/helpers/base.controller.helpers.js.map +0 -1
  109. package/dist/esm/modules/base/utils/helpers/base.middlewares.helpers.js +0 -44
  110. package/dist/esm/modules/base/utils/helpers/base.middlewares.helpers.js.map +0 -1
  111. package/dist/esm/modules/base/utils/helpers/base.router.helpers.js +0 -89
  112. package/dist/esm/modules/base/utils/helpers/base.router.helpers.js.map +0 -1
  113. package/dist/esm/modules/base/utils/helpers/base.service.helpers.js +0 -165
  114. package/dist/esm/modules/base/utils/helpers/base.service.helpers.js.map +0 -1
  115. package/dist/esm/modules/email/email.service.js +0 -97
  116. package/dist/esm/modules/email/email.service.js.map +0 -1
  117. package/dist/esm/modules/error-handler/error-handler.controller.js +0 -107
  118. package/dist/esm/modules/error-handler/error-handler.controller.js.map +0 -1
  119. package/dist/esm/modules/error-handler/utils/app-error.js +0 -15
  120. package/dist/esm/modules/error-handler/utils/app-error.js.map +0 -1
  121. package/dist/esm/modules/error-handler/utils/catch-async.js +0 -10
  122. package/dist/esm/modules/error-handler/utils/catch-async.js.map +0 -1
  123. package/dist/esm/modules/error-handler/utils/error-handler.helpers.js +0 -160
  124. package/dist/esm/modules/error-handler/utils/error-handler.helpers.js.map +0 -1
  125. package/dist/esm/modules/file-upload/file-upload.controller.js +0 -266
  126. package/dist/esm/modules/file-upload/file-upload.controller.js.map +0 -1
  127. package/dist/esm/modules/file-upload/file-upload.router.js +0 -38
  128. package/dist/esm/modules/file-upload/file-upload.router.js.map +0 -1
  129. package/dist/esm/modules/file-upload/file-upload.service.js +0 -314
  130. package/dist/esm/modules/file-upload/file-upload.service.js.map +0 -1
  131. package/dist/esm/modules/file-upload/utils/helpers/file-upload.helpers.js +0 -87
  132. package/dist/esm/modules/file-upload/utils/helpers/file-upload.helpers.js.map +0 -1
  133. package/dist/esm/modules/swagger/swagger.router.js +0 -94
  134. package/dist/esm/modules/swagger/swagger.router.js.map +0 -1
  135. package/dist/esm/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js +0 -247
  136. package/dist/esm/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js.map +0 -1
  137. package/dist/esm/modules/swagger/utils/helpers/get-system-json-schema-paths.js +0 -63
  138. package/dist/esm/modules/swagger/utils/helpers/get-system-json-schema-paths.js.map +0 -1
  139. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js +0 -38
  140. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js.map +0 -1
  141. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js +0 -19
  142. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js.map +0 -1
  143. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.js +0 -24
  144. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.js.map +0 -1
  145. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes.js +0 -436
  146. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes.js.map +0 -1
  147. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.js +0 -159
  148. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.js.map +0 -1
  149. package/dist/esm/modules/swagger/utils/helpers/swagger.router.helpers.js +0 -84
  150. package/dist/esm/modules/swagger/utils/helpers/swagger.router.helpers.js.map +0 -1
  151. package/dist/esm/paths.js +0 -1
  152. package/dist/esm/paths.js.map +0 -1
  153. package/dist/esm/server.js +0 -5
  154. package/dist/esm/server.js.map +0 -1
  155. package/dist/esm/types/arkos-config.js +0 -2
  156. package/dist/esm/types/arkos-config.js.map +0 -1
  157. package/dist/esm/types/auth.js +0 -2
  158. package/dist/esm/types/auth.js.map +0 -1
  159. package/dist/esm/types/index.js +0 -8
  160. package/dist/esm/types/index.js.map +0 -1
  161. package/dist/esm/types/router-config.js +0 -2
  162. package/dist/esm/types/router-config.js.map +0 -1
  163. package/dist/esm/utils/arkos-env.js +0 -7
  164. package/dist/esm/utils/arkos-env.js.map +0 -1
  165. package/dist/esm/utils/cli/build.js +0 -206
  166. package/dist/esm/utils/cli/build.js.map +0 -1
  167. package/dist/esm/utils/cli/dev.js +0 -249
  168. package/dist/esm/utils/cli/dev.js.map +0 -1
  169. package/dist/esm/utils/cli/generate.js +0 -183
  170. package/dist/esm/utils/cli/generate.js.map +0 -1
  171. package/dist/esm/utils/cli/index.js +0 -74
  172. package/dist/esm/utils/cli/index.js.map +0 -1
  173. package/dist/esm/utils/cli/start.js +0 -86
  174. package/dist/esm/utils/cli/start.js.map +0 -1
  175. package/dist/esm/utils/cli/utils/cli.helpers.js +0 -16
  176. package/dist/esm/utils/cli/utils/cli.helpers.js.map +0 -1
  177. package/dist/esm/utils/cli/utils/template-generator/templates/generate-auth-configs-template.js +0 -33
  178. package/dist/esm/utils/cli/utils/template-generator/templates/generate-auth-configs-template.js.map +0 -1
  179. package/dist/esm/utils/cli/utils/template-generator/templates/generate-controller-template.js +0 -18
  180. package/dist/esm/utils/cli/utils/template-generator/templates/generate-controller-template.js.map +0 -1
  181. package/dist/esm/utils/cli/utils/template-generator/templates/generate-middlewares.js +0 -232
  182. package/dist/esm/utils/cli/utils/template-generator/templates/generate-middlewares.js.map +0 -1
  183. package/dist/esm/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js +0 -61
  184. package/dist/esm/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js.map +0 -1
  185. package/dist/esm/utils/cli/utils/template-generator/templates/generate-router-template.js +0 -37
  186. package/dist/esm/utils/cli/utils/template-generator/templates/generate-router-template.js.map +0 -1
  187. package/dist/esm/utils/cli/utils/template-generator/templates/generate-service-template.js +0 -32
  188. package/dist/esm/utils/cli/utils/template-generator/templates/generate-service-template.js.map +0 -1
  189. package/dist/esm/utils/cli/utils/template-generators.js +0 -25
  190. package/dist/esm/utils/cli/utils/template-generators.js.map +0 -1
  191. package/dist/esm/utils/dotenv.helpers.js +0 -37
  192. package/dist/esm/utils/dotenv.helpers.js.map +0 -1
  193. package/dist/esm/utils/features/api.features.js +0 -160
  194. package/dist/esm/utils/features/api.features.js.map +0 -1
  195. package/dist/esm/utils/features/change-case.features.js +0 -31
  196. package/dist/esm/utils/features/change-case.features.js.map +0 -1
  197. package/dist/esm/utils/helpers/api.features.helpers.js +0 -103
  198. package/dist/esm/utils/helpers/api.features.helpers.js.map +0 -1
  199. package/dist/esm/utils/helpers/change-case.helpers.js +0 -161
  200. package/dist/esm/utils/helpers/change-case.helpers.js.map +0 -1
  201. package/dist/esm/utils/helpers/deepmerge.helper.js +0 -113
  202. package/dist/esm/utils/helpers/deepmerge.helper.js.map +0 -1
  203. package/dist/esm/utils/helpers/fs.helpers.js +0 -52
  204. package/dist/esm/utils/helpers/fs.helpers.js.map +0 -1
  205. package/dist/esm/utils/helpers/global.helpers.js +0 -47
  206. package/dist/esm/utils/helpers/global.helpers.js.map +0 -1
  207. package/dist/esm/utils/helpers/models.helpers.js +0 -300
  208. package/dist/esm/utils/helpers/models.helpers.js.map +0 -1
  209. package/dist/esm/utils/helpers/prisma.helpers.js +0 -44
  210. package/dist/esm/utils/helpers/prisma.helpers.js.map +0 -1
  211. package/dist/esm/utils/helpers/query-parser.helpers.js +0 -40
  212. package/dist/esm/utils/helpers/query-parser.helpers.js.map +0 -1
  213. package/dist/esm/utils/helpers/routers.helpers.js +0 -16
  214. package/dist/esm/utils/helpers/routers.helpers.js.map +0 -1
  215. package/dist/esm/utils/helpers/text.helpers.js +0 -22
  216. package/dist/esm/utils/helpers/text.helpers.js.map +0 -1
  217. package/dist/esm/utils/sheu.js +0 -117
  218. package/dist/esm/utils/sheu.js.map +0 -1
  219. package/dist/esm/utils/validate-dto.js +0 -11
  220. package/dist/esm/utils/validate-dto.js.map +0 -1
  221. package/dist/esm/utils/validate-schema.js +0 -9
  222. package/dist/esm/utils/validate-schema.js.map +0 -1
@@ -7,12 +7,47 @@ exports.generatePrismaModelParentRoutePaths = generatePrismaModelParentRoutePath
7
7
  const pluralize_1 = __importDefault(require("pluralize"));
8
8
  const utils_1 = require("../../../../../../exports/utils");
9
9
  const swagger_router_helpers_1 = require("../../swagger.router.helpers");
10
- const base_router_helpers_1 = require("../../../../../base/utils/helpers/base.router.helpers");
11
- async function generatePrismaModelParentRoutePaths(paths, routeName, pascalModelName, humanReadableName, humanReadableNamePlural, routerConfig, mode) {
10
+ const models_helpers_1 = require("../../../../../../utils/helpers/models.helpers");
11
+ const models_helpers_2 = require("../../../../../../utils/helpers/models.helpers");
12
+ async function generatePrismaModelParentRoutePaths(model, paths, arkosConfig) {
13
+ const modelName = (0, utils_1.kebabCase)(model);
14
+ const routeName = pluralize_1.default.plural(modelName);
15
+ const pascalModelName = (0, utils_1.pascalCase)(model);
16
+ const humanReadableName = (0, swagger_router_helpers_1.kebabToHuman)(modelName);
17
+ const humanReadableNamePlural = pluralize_1.default.plural(humanReadableName);
18
+ const modelModules = await (0, models_helpers_1.importPrismaModelModules)(model, arkosConfig);
19
+ const routerConfig = modelModules?.router?.config;
20
+ if (routerConfig?.disable === true)
21
+ return;
22
+ if (!routerConfig?.parent)
23
+ return;
12
24
  const parentModel = routerConfig.parent.model;
13
25
  const parentRouteName = pluralize_1.default.plural((0, utils_1.kebabCase)(parentModel));
14
26
  const parentHumanName = (0, swagger_router_helpers_1.kebabToHuman)((0, utils_1.kebabCase)(parentModel));
15
- if ((0, base_router_helpers_1.isParentEndpointAllowed)(routerConfig, "createOne")) {
27
+ const isParentEndpointAllowed = (endpoint) => {
28
+ const parentEndpoints = routerConfig?.parent?.endpoints;
29
+ if (!parentEndpoints || parentEndpoints === "*") {
30
+ return true;
31
+ }
32
+ if (Array.isArray(parentEndpoints)) {
33
+ return parentEndpoints.includes(endpoint);
34
+ }
35
+ return false;
36
+ };
37
+ const getSchemaMode = async (action) => {
38
+ const swaggerMode = arkosConfig.swagger?.mode;
39
+ const isStrict = arkosConfig.swagger?.strict;
40
+ if (isStrict) {
41
+ return swaggerMode || "prisma";
42
+ }
43
+ const actionKey = action;
44
+ const localFileExists = await (0, models_helpers_2.localValidatorFileExists)(actionKey, model, arkosConfig);
45
+ if (!localFileExists)
46
+ return "prisma";
47
+ return swaggerMode || "prisma";
48
+ };
49
+ if (isParentEndpointAllowed("createOne")) {
50
+ const createMode = await getSchemaMode("create");
16
51
  paths[`/api/${parentRouteName}/{id}/${routeName}`] = {
17
52
  post: {
18
53
  tags: [humanReadableNamePlural],
@@ -36,7 +71,7 @@ async function generatePrismaModelParentRoutePaths(paths, routeName, pascalModel
36
71
  content: {
37
72
  "application/json": {
38
73
  schema: {
39
- $ref: (0, swagger_router_helpers_1.getSchemaRef)(`Create${pascalModelName}`, mode),
74
+ $ref: (0, swagger_router_helpers_1.getSchemaRef)(`Create${pascalModelName}`, createMode),
40
75
  },
41
76
  },
42
77
  },
@@ -47,7 +82,7 @@ async function generatePrismaModelParentRoutePaths(paths, routeName, pascalModel
47
82
  content: {
48
83
  "application/json": {
49
84
  schema: {
50
- $ref: (0, swagger_router_helpers_1.getSchemaRef)(`${pascalModelName}`, mode),
85
+ $ref: (0, swagger_router_helpers_1.getSchemaRef)(`${pascalModelName}`, createMode),
51
86
  },
52
87
  },
53
88
  },
@@ -69,9 +104,10 @@ async function generatePrismaModelParentRoutePaths(paths, routeName, pascalModel
69
104
  },
70
105
  };
71
106
  }
72
- if ((0, base_router_helpers_1.isParentEndpointAllowed)(routerConfig, "findMany")) {
107
+ if (isParentEndpointAllowed("findMany")) {
73
108
  if (!paths[`/api/${parentRouteName}/{id}/${routeName}`])
74
109
  paths[`/api/${parentRouteName}/{id}/${routeName}`] = {};
110
+ const findManyMode = await getSchemaMode("findMany");
75
111
  paths[`/api/${parentRouteName}/{id}/${routeName}`].get = {
76
112
  tags: [humanReadableNamePlural],
77
113
  summary: `Get ${humanReadableNamePlural} for ${parentHumanName}`,
@@ -118,6 +154,16 @@ async function generatePrismaModelParentRoutePaths(paths, routeName, pascalModel
118
154
  description: "Number of items per page",
119
155
  schema: {
120
156
  type: "integer",
157
+ minimum: 1,
158
+ maximum: 100,
159
+ },
160
+ },
161
+ {
162
+ name: "fields",
163
+ in: "query",
164
+ description: "Comma-separated list of fields to include in response",
165
+ schema: {
166
+ type: "string",
121
167
  },
122
168
  },
123
169
  ],
@@ -131,22 +177,221 @@ async function generatePrismaModelParentRoutePaths(paths, routeName, pascalModel
131
177
  properties: {
132
178
  total: {
133
179
  type: "integer",
134
- description: "Total number of records",
180
+ description: "Total number of records matching the criteria",
135
181
  },
136
182
  results: {
137
183
  type: "integer",
138
- description: "Number of records in current page",
184
+ description: "Number of records returned in current page",
139
185
  },
140
186
  data: {
141
187
  type: "array",
142
188
  items: {
143
- $ref: (0, swagger_router_helpers_1.getSchemaRef)(`${pascalModelName}`, mode),
189
+ $ref: (0, swagger_router_helpers_1.getSchemaRef)(`FindMany${pascalModelName}`, findManyMode),
190
+ },
191
+ },
192
+ },
193
+ },
194
+ },
195
+ },
196
+ },
197
+ "401": {
198
+ description: "Authentication required",
199
+ },
200
+ "403": {
201
+ description: "Insufficient permissions",
202
+ },
203
+ "404": {
204
+ description: `${parentHumanName} not found`,
205
+ },
206
+ },
207
+ security: [{ BearerAuth: [] }],
208
+ };
209
+ }
210
+ if (isParentEndpointAllowed("createMany")) {
211
+ const createManyMode = await getSchemaMode("createMany");
212
+ paths[`/api/${parentRouteName}/{id}/${routeName}/many`] = {
213
+ post: {
214
+ tags: [humanReadableNamePlural],
215
+ summary: `Create multiple ${humanReadableNamePlural} for ${parentHumanName}`,
216
+ description: `Creates multiple ${humanReadableNamePlural} records associated with the specified ${parentHumanName}`,
217
+ operationId: `createMany${pascalModelName}For${(0, utils_1.pascalCase)(parentModel)}`,
218
+ parameters: [
219
+ {
220
+ name: "id",
221
+ in: "path",
222
+ description: `Unique identifier of the ${parentHumanName}`,
223
+ required: true,
224
+ schema: {
225
+ type: "string",
226
+ },
227
+ },
228
+ ],
229
+ requestBody: {
230
+ description: `Array of ${humanReadableName} data to create`,
231
+ required: true,
232
+ content: {
233
+ "application/json": {
234
+ schema: {
235
+ type: "array",
236
+ items: {
237
+ $ref: (0, swagger_router_helpers_1.getSchemaRef)(`CreateMany${pascalModelName}`, createManyMode),
238
+ },
239
+ },
240
+ },
241
+ },
242
+ },
243
+ responses: {
244
+ "201": {
245
+ description: `${humanReadableNamePlural} created successfully`,
246
+ content: {
247
+ "application/json": {
248
+ schema: {
249
+ type: "object",
250
+ properties: {
251
+ count: {
252
+ type: "integer",
253
+ description: "Number of records created",
144
254
  },
145
255
  },
146
256
  },
147
257
  },
148
258
  },
149
259
  },
260
+ "400": {
261
+ description: "Invalid input data provided",
262
+ },
263
+ "401": {
264
+ description: "Authentication required",
265
+ },
266
+ "403": {
267
+ description: "Insufficient permissions",
268
+ },
269
+ "404": {
270
+ description: `${parentHumanName} not found`,
271
+ },
272
+ },
273
+ security: [{ BearerAuth: [] }],
274
+ },
275
+ };
276
+ }
277
+ if (isParentEndpointAllowed("updateMany")) {
278
+ if (!paths[`/api/${parentRouteName}/{id}/${routeName}/many`])
279
+ paths[`/api/${parentRouteName}/{id}/${routeName}/many`] = {};
280
+ const updateManyMode = await getSchemaMode("updateMany");
281
+ paths[`/api/${parentRouteName}/{id}/${routeName}/many`].patch = {
282
+ tags: [humanReadableNamePlural],
283
+ summary: `Update multiple ${humanReadableNamePlural} for ${parentHumanName}`,
284
+ description: `Updates multiple ${humanReadableNamePlural} records associated with the specified ${parentHumanName}`,
285
+ operationId: `updateMany${pascalModelName}For${(0, utils_1.pascalCase)(parentModel)}`,
286
+ parameters: [
287
+ {
288
+ name: "id",
289
+ in: "path",
290
+ description: `Unique identifier of the ${parentHumanName}`,
291
+ required: true,
292
+ schema: {
293
+ type: "string",
294
+ },
295
+ },
296
+ {
297
+ name: "filter",
298
+ in: "query",
299
+ description: "Additional filter criteria in JSON format",
300
+ schema: {
301
+ type: "string",
302
+ },
303
+ },
304
+ ],
305
+ requestBody: {
306
+ description: `Partial ${humanReadableName} data to update`,
307
+ required: true,
308
+ content: {
309
+ "application/json": {
310
+ schema: {
311
+ $ref: (0, swagger_router_helpers_1.getSchemaRef)(`UpdateMany${pascalModelName}`, updateManyMode),
312
+ },
313
+ },
314
+ },
315
+ },
316
+ responses: {
317
+ "200": {
318
+ description: `${humanReadableNamePlural} updated successfully`,
319
+ content: {
320
+ "application/json": {
321
+ schema: {
322
+ type: "object",
323
+ properties: {
324
+ count: {
325
+ type: "integer",
326
+ description: "Number of records updated",
327
+ },
328
+ },
329
+ },
330
+ },
331
+ },
332
+ },
333
+ "400": {
334
+ description: "Invalid input data provided",
335
+ },
336
+ "401": {
337
+ description: "Authentication required",
338
+ },
339
+ "403": {
340
+ description: "Insufficient permissions",
341
+ },
342
+ "404": {
343
+ description: `${parentHumanName} not found`,
344
+ },
345
+ },
346
+ security: [{ BearerAuth: [] }],
347
+ };
348
+ }
349
+ if (isParentEndpointAllowed("deleteMany")) {
350
+ if (!paths[`/api/${parentRouteName}/{id}/${routeName}/many`])
351
+ paths[`/api/${parentRouteName}/{id}/${routeName}/many`] = {};
352
+ paths[`/api/${parentRouteName}/{id}/${routeName}/many`].delete = {
353
+ tags: [humanReadableNamePlural],
354
+ summary: `Delete multiple ${humanReadableNamePlural} for ${parentHumanName}`,
355
+ description: `Deletes multiple ${humanReadableNamePlural} records associated with the specified ${parentHumanName}`,
356
+ operationId: `deleteMany${pascalModelName}For${(0, utils_1.pascalCase)(parentModel)}`,
357
+ parameters: [
358
+ {
359
+ name: "id",
360
+ in: "path",
361
+ description: `Unique identifier of the ${parentHumanName}`,
362
+ required: true,
363
+ schema: {
364
+ type: "string",
365
+ },
366
+ },
367
+ {
368
+ name: "filter",
369
+ in: "query",
370
+ description: "Additional filter criteria in JSON format",
371
+ schema: {
372
+ type: "string",
373
+ },
374
+ },
375
+ ],
376
+ responses: {
377
+ "200": {
378
+ description: `${humanReadableNamePlural} deleted successfully`,
379
+ content: {
380
+ "application/json": {
381
+ schema: {
382
+ type: "object",
383
+ properties: {
384
+ count: {
385
+ type: "integer",
386
+ description: "Number of records deleted",
387
+ },
388
+ },
389
+ },
390
+ },
391
+ },
392
+ },
393
+ "400": {
394
+ description: "Missing filter criteria",
150
395
  },
151
396
  "401": {
152
397
  description: "Authentication required",
@@ -161,5 +406,170 @@ async function generatePrismaModelParentRoutePaths(paths, routeName, pascalModel
161
406
  security: [{ BearerAuth: [] }],
162
407
  };
163
408
  }
409
+ if (isParentEndpointAllowed("findOne")) {
410
+ const findOneMode = await getSchemaMode("findOne");
411
+ paths[`/api/${parentRouteName}/{id}/${routeName}/{childId}`] = {
412
+ get: {
413
+ tags: [humanReadableNamePlural],
414
+ summary: `Get ${humanReadableName} by ID for ${parentHumanName}`,
415
+ description: `Retrieves a single ${humanReadableName} record by its unique identifier associated with the specified ${parentHumanName}`,
416
+ operationId: `get${pascalModelName}ByIdFor${(0, utils_1.pascalCase)(parentModel)}`,
417
+ parameters: [
418
+ {
419
+ name: "id",
420
+ in: "path",
421
+ description: `Unique identifier of the ${parentHumanName}`,
422
+ required: true,
423
+ schema: {
424
+ type: "string",
425
+ },
426
+ },
427
+ {
428
+ name: "childId",
429
+ in: "path",
430
+ description: `Unique identifier of the ${humanReadableName}`,
431
+ required: true,
432
+ schema: {
433
+ type: "string",
434
+ },
435
+ },
436
+ ],
437
+ responses: {
438
+ "200": {
439
+ description: `${humanReadableName} retrieved successfully`,
440
+ content: {
441
+ "application/json": {
442
+ schema: {
443
+ $ref: (0, swagger_router_helpers_1.getSchemaRef)(`FindOne${pascalModelName}`, findOneMode),
444
+ },
445
+ },
446
+ },
447
+ },
448
+ "401": {
449
+ description: "Authentication required",
450
+ },
451
+ "403": {
452
+ description: "Insufficient permissions",
453
+ },
454
+ "404": {
455
+ description: `${humanReadableName} or ${parentHumanName} not found`,
456
+ },
457
+ },
458
+ security: [{ BearerAuth: [] }],
459
+ },
460
+ };
461
+ }
462
+ if (isParentEndpointAllowed("updateOne")) {
463
+ if (!paths[`/api/${parentRouteName}/{id}/${routeName}/{childId}`])
464
+ paths[`/api/${parentRouteName}/{id}/${routeName}/{childId}`] = {};
465
+ const updateMode = await getSchemaMode("update");
466
+ paths[`/api/${parentRouteName}/{id}/${routeName}/{childId}`].patch = {
467
+ tags: [humanReadableNamePlural],
468
+ summary: `Update ${humanReadableName} by ID for ${parentHumanName}`,
469
+ description: `Updates a single ${humanReadableName} record by its unique identifier associated with the specified ${parentHumanName}`,
470
+ operationId: `update${pascalModelName}ByIdFor${(0, utils_1.pascalCase)(parentModel)}`,
471
+ parameters: [
472
+ {
473
+ name: "id",
474
+ in: "path",
475
+ description: `Unique identifier of the ${parentHumanName}`,
476
+ required: true,
477
+ schema: {
478
+ type: "string",
479
+ },
480
+ },
481
+ {
482
+ name: "childId",
483
+ in: "path",
484
+ description: `Unique identifier of the ${humanReadableName}`,
485
+ required: true,
486
+ schema: {
487
+ type: "string",
488
+ },
489
+ },
490
+ ],
491
+ requestBody: {
492
+ description: `Partial ${humanReadableName} data to update`,
493
+ required: true,
494
+ content: {
495
+ "application/json": {
496
+ schema: {
497
+ $ref: (0, swagger_router_helpers_1.getSchemaRef)(`Update${pascalModelName}`, updateMode),
498
+ },
499
+ },
500
+ },
501
+ },
502
+ responses: {
503
+ "200": {
504
+ description: `${humanReadableName} updated successfully`,
505
+ content: {
506
+ "application/json": {
507
+ schema: {
508
+ $ref: (0, swagger_router_helpers_1.getSchemaRef)(`${pascalModelName}`, updateMode),
509
+ },
510
+ },
511
+ },
512
+ },
513
+ "400": {
514
+ description: "Invalid input data provided",
515
+ },
516
+ "401": {
517
+ description: "Authentication required",
518
+ },
519
+ "403": {
520
+ description: "Insufficient permissions",
521
+ },
522
+ "404": {
523
+ description: `${humanReadableName} or ${parentHumanName} not found`,
524
+ },
525
+ },
526
+ security: [{ BearerAuth: [] }],
527
+ };
528
+ }
529
+ if (isParentEndpointAllowed("deleteOne")) {
530
+ if (!paths[`/api/${parentRouteName}/{id}/${routeName}/{childId}`])
531
+ paths[`/api/${parentRouteName}/{id}/${routeName}/{childId}`] = {};
532
+ paths[`/api/${parentRouteName}/{id}/${routeName}/{childId}`].delete = {
533
+ tags: [humanReadableNamePlural],
534
+ summary: `Delete ${humanReadableName} by ID for ${parentHumanName}`,
535
+ description: `Permanently deletes a single ${humanReadableName} record by its unique identifier associated with the specified ${parentHumanName}`,
536
+ operationId: `delete${pascalModelName}ByIdFor${(0, utils_1.pascalCase)(parentModel)}`,
537
+ parameters: [
538
+ {
539
+ name: "id",
540
+ in: "path",
541
+ description: `Unique identifier of the ${parentHumanName}`,
542
+ required: true,
543
+ schema: {
544
+ type: "string",
545
+ },
546
+ },
547
+ {
548
+ name: "childId",
549
+ in: "path",
550
+ description: `Unique identifier of the ${humanReadableName}`,
551
+ required: true,
552
+ schema: {
553
+ type: "string",
554
+ },
555
+ },
556
+ ],
557
+ responses: {
558
+ "204": {
559
+ description: `${humanReadableName} deleted successfully`,
560
+ },
561
+ "401": {
562
+ description: "Authentication required",
563
+ },
564
+ "403": {
565
+ description: "Insufficient permissions",
566
+ },
567
+ "404": {
568
+ description: `${humanReadableName} or ${parentHumanName} not found`,
569
+ },
570
+ },
571
+ security: [{ BearerAuth: [] }],
572
+ };
573
+ }
164
574
  }
165
575
  //# sourceMappingURL=generate-prisma-model-parent-routes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate-prisma-model-parent-routes.js","sourceRoot":"","sources":["../../../../../../../../src/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.ts"],"names":[],"mappings":";;;;;AAMA,kFAyKC;AA9KD,0DAAkC;AAClC,2DAAwE;AACxE,yEAA0E;AAC1E,+FAAgG;AAEzF,KAAK,UAAU,mCAAmC,CACvD,KAA4B,EAC5B,SAAiB,EACjB,eAAuB,EACvB,iBAAyB,EACzB,uBAA+B,EAC/B,YAAiB,EACjB,IAAY;IAEZ,MAAM,WAAW,GAAG,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC;IAC9C,MAAM,eAAe,GAAG,mBAAS,CAAC,MAAM,CAAC,IAAA,iBAAS,EAAC,WAAW,CAAC,CAAC,CAAC;IACjE,MAAM,eAAe,GAAG,IAAA,qCAAY,EAAC,IAAA,iBAAS,EAAC,WAAW,CAAC,CAAC,CAAC;IAK7D,IAAI,IAAA,6CAAuB,EAAC,YAAY,EAAE,WAAW,CAAC,EAAE,CAAC;QACvD,KAAK,CAAC,QAAQ,eAAe,SAAS,SAAS,EAAE,CAAC,GAAG;YACnD,IAAI,EAAE;gBACJ,IAAI,EAAE,CAAC,uBAAuB,CAAC;gBAC/B,OAAO,EAAE,UAAU,iBAAiB,QAAQ,eAAe,EAAE;gBAC7D,WAAW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,WAAW,EAAE,WAAW,uBAAuB,yBAAyB;oBACxE,OAAO,EAAE;wBACP,kBAAkB,EAAE;4BAClB,MAAM,EAAE;gCACN,IAAI,EAAE,QAAQ;gCACd,UAAU,EAAE;oCACV,KAAK,EAAE;wCACL,IAAI,EAAE,SAAS;wCACf,WAAW,EAAE,yBAAyB;qCACvC;oCACD,OAAO,EAAE;wCACP,IAAI,EAAE,SAAS;wCACf,WAAW,EAAE,mCAAmC;qCACjD;oCACD,IAAI,EAAE;wCACJ,IAAI,EAAE,OAAO;wCACb,KAAK,EAAE;4CACL,IAAI,EAAE,IAAA,qCAAY,EAAC,GAAG,eAAe,EAAE,EAAE,IAAI,CAAC;yCAC/C;qCACF;iCACF;6BACF;yBACF;qBACF;iBACF;gBACD,KAAK,EAAE;oBACL,WAAW,EAAE,yBAAyB;iBACvC;gBACD,KAAK,EAAE;oBACL,WAAW,EAAE,0BAA0B;iBACxC;gBACD,KAAK,EAAE;oBACL,WAAW,EAAE,GAAG,eAAe,YAAY;iBAC5C;aACF;YACD,QAAQ,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;SAC/B,CAAC;IACJ,CAAC;AAGH,CAAC","sourcesContent":["import { OpenAPIV3 } from \"openapi-types\";\nimport pluralize from \"pluralize\";\nimport { kebabCase, pascalCase } from \"../../../../../../exports/utils\";\nimport { getSchemaRef, kebabToHuman } from \"../../swagger.router.helpers\";\nimport { isParentEndpointAllowed } from \"../../../../../base/utils/helpers/base.router.helpers\";\n\nexport async function generatePrismaModelParentRoutePaths(\n paths: OpenAPIV3.PathsObject,\n routeName: string,\n pascalModelName: string,\n humanReadableName: string,\n humanReadableNamePlural: string,\n routerConfig: any,\n mode: string\n) {\n const parentModel = routerConfig.parent.model;\n const parentRouteName = pluralize.plural(kebabCase(parentModel));\n const parentHumanName = kebabToHuman(kebabCase(parentModel));\n // const foreignKeyField =\n // routerConfig.parent.foreignKeyField || `${kebabCase(parentModel)}Id`;\n\n // Create One (Parent)\n if (isParentEndpointAllowed(routerConfig, \"createOne\")) {\n paths[`/api/${parentRouteName}/{id}/${routeName}`] = {\n post: {\n tags: [humanReadableNamePlural],\n summary: `Create ${humanReadableName} for ${parentHumanName}`,\n description: `Creates a new ${humanReadableName} record associated with the specified ${parentHumanName}`,\n operationId: `create${pascalModelName}For${pascalCase(parentModel)}`,\n parameters: [\n {\n name: \"id\",\n in: \"path\",\n description: `Unique identifier of the ${parentHumanName}`,\n required: true,\n schema: {\n type: \"string\",\n },\n },\n ],\n requestBody: {\n description: `${humanReadableName} data to create`,\n required: true,\n content: {\n \"application/json\": {\n schema: {\n $ref: getSchemaRef(`Create${pascalModelName}`, mode),\n },\n },\n },\n },\n responses: {\n \"201\": {\n description: `${humanReadableName} created successfully`,\n content: {\n \"application/json\": {\n schema: {\n $ref: getSchemaRef(`${pascalModelName}`, mode),\n },\n },\n },\n },\n \"400\": {\n description: \"Invalid input data provided\",\n },\n \"401\": {\n description: \"Authentication required\",\n },\n \"403\": {\n description: \"Insufficient permissions\",\n },\n \"404\": {\n description: `${parentHumanName} not found`,\n },\n },\n security: [{ BearerAuth: [] }],\n },\n };\n }\n\n // Find Many (Parent)\n if (isParentEndpointAllowed(routerConfig, \"findMany\")) {\n if (!paths[`/api/${parentRouteName}/{id}/${routeName}`])\n paths[`/api/${parentRouteName}/{id}/${routeName}`] = {};\n paths[`/api/${parentRouteName}/{id}/${routeName}`]!.get = {\n tags: [humanReadableNamePlural],\n summary: `Get ${humanReadableNamePlural} for ${parentHumanName}`,\n description: `Retrieves all ${humanReadableNamePlural} associated with the specified ${parentHumanName}`,\n operationId: `get${pluralize.plural(pascalModelName)}For${pascalCase(parentModel)}`,\n parameters: [\n {\n name: \"id\",\n in: \"path\",\n description: `Unique identifier of the ${parentHumanName}`,\n required: true,\n schema: {\n type: \"string\",\n },\n },\n {\n name: \"filter\",\n in: \"query\",\n description: \"Additional filter criteria in JSON format\",\n schema: {\n type: \"string\",\n },\n },\n {\n name: \"sort\",\n in: \"query\",\n description: \"Sort field (prefix with '-' for descending order)\",\n schema: {\n type: \"string\",\n },\n },\n {\n name: \"page\",\n in: \"query\",\n description: \"Page number (starts from 1)\",\n schema: {\n type: \"integer\",\n minimum: 1,\n },\n },\n {\n name: \"limit\",\n in: \"query\",\n description: \"Number of items per page\",\n schema: {\n type: \"integer\",\n },\n },\n ],\n responses: {\n \"200\": {\n description: `List of ${humanReadableNamePlural} retrieved successfully`,\n content: {\n \"application/json\": {\n schema: {\n type: \"object\",\n properties: {\n total: {\n type: \"integer\",\n description: \"Total number of records\",\n },\n results: {\n type: \"integer\",\n description: \"Number of records in current page\",\n },\n data: {\n type: \"array\",\n items: {\n $ref: getSchemaRef(`${pascalModelName}`, mode),\n },\n },\n },\n },\n },\n },\n },\n \"401\": {\n description: \"Authentication required\",\n },\n \"403\": {\n description: \"Insufficient permissions\",\n },\n \"404\": {\n description: `${parentHumanName} not found`,\n },\n },\n security: [{ BearerAuth: [] }],\n };\n }\n\n // Add other parent endpoints (findOne, updateOne, deleteOne, etc.) following the same pattern...\n}\n"]}
1
+ {"version":3,"file":"generate-prisma-model-parent-routes.js","sourceRoot":"","sources":["../../../../../../../../src/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.ts"],"names":[],"mappings":";;;;;AAQA,kFAqmBC;AA5mBD,0DAAkC;AAClC,2DAAwE;AACxE,yEAA0E;AAE1E,mFAA0F;AAC1F,mFAA0F;AAEnF,KAAK,UAAU,mCAAmC,CACvD,KAAa,EACb,KAA4B,EAC5B,WAAwB;IAExB,MAAM,SAAS,GAAG,IAAA,iBAAS,EAAC,KAAK,CAAC,CAAC;IACnC,MAAM,SAAS,GAAG,mBAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAC9C,MAAM,eAAe,GAAG,IAAA,kBAAU,EAAC,KAAK,CAAC,CAAC;IAC1C,MAAM,iBAAiB,GAAG,IAAA,qCAAY,EAAC,SAAS,CAAC,CAAC;IAClD,MAAM,uBA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AW,EAAE,4BAA4B,iBAAiB,EAAE;oBAC5D,QAAQ,EAAE,IAAI;oBACd,MAAM,EAAE;wBACN,IAAI,EAAE,QAAQ;qBACf;iBACF;aACF;YACD,SAAS,EAAE;gBACT,KAAK,EAAE;oBACL,WAAW,EAAE,GAAG,iBAAiB,uBAAuB;iBACzD;gBACD,KAAK,EAAE;oBACL,WAAW,EAAE,yBAAyB;iBACvC;gBACD,KAAK,EAAE;oBACL,WAAW,EAAE,0BAA0B;iBACxC;gBACD,KAAK,EAAE;oBACL,WAAW,EAAE,GAAG,iBAAiB,OAAO,eAAe,YAAY;iBACpE;aACF;YACD,QAAQ,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;SAC/B,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import { OpenAPIV3 } from \"openapi-types\";\nimport pluralize from \"pluralize\";\nimport { kebabCase, pascalCase } from \"../../../../../../exports/utils\";\nimport { getSchemaRef, kebabToHuman } from \"../../swagger.router.helpers\";\nimport { ArkosConfig } from \"../../../../../../exports\";\nimport { importPrismaModelModules } from \"../../../../../../utils/helpers/models.helpers\";\nimport { localValidatorFileExists } from \"../../../../../../utils/helpers/models.helpers\";\n\nexport async function generatePrismaModelParentRoutePaths(\n model: string,\n paths: OpenAPIV3.PathsObject,\n arkosConfig: ArkosConfig\n) {\n const modelName = kebabCase(model);\n const routeName = pluralize.plural(modelName);\n const pascalModelName = pascalCase(model);\n const humanReadableName = kebabToHuman(modelName);\n const humanReadableNamePlural = pluralize.plural(humanReadableName);\n\n // Import model modules to get router config\n const modelModules = await importPrismaModelModules(model, arkosConfig);\n const routerConfig = modelModules?.router?.config;\n\n // Skip if router is completely disabled\n if (routerConfig?.disable === true) return;\n if (!routerConfig?.parent) return;\n\n const parentModel = routerConfig.parent.model;\n const parentRouteName = pluralize.plural(kebabCase(parentModel));\n const parentHumanName = kebabToHuman(kebabCase(parentModel));\n\n // Check if parent endpoint is allowed\n const isParentEndpointAllowed = (endpoint: string): boolean => {\n const parentEndpoints = routerConfig?.parent?.endpoints;\n\n // If endpoints is \"*\" or undefined, allow all\n if (!parentEndpoints || parentEndpoints === \"*\") {\n return true;\n }\n\n // If endpoints is array, check if endpoint is included\n if (Array.isArray(parentEndpoints)) {\n return parentEndpoints.includes(endpoint as any);\n }\n\n return false;\n };\n\n // Helper function to determine the correct mode for schema ref\n const getSchemaMode = async (\n action: string\n ): Promise<\"prisma\" | \"zod\" | \"class-validator\"> => {\n const swaggerMode = arkosConfig.swagger?.mode;\n const isStrict = arkosConfig.swagger?.strict;\n\n if (isStrict) {\n return swaggerMode || \"prisma\";\n }\n\n const actionKey = action as any;\n const localFileExists = await localValidatorFileExists(\n actionKey,\n model,\n arkosConfig\n );\n\n if (!localFileExists) return \"prisma\";\n\n return swaggerMode || \"prisma\";\n };\n\n // Create One (Parent)\n if (isParentEndpointAllowed(\"createOne\")) {\n const createMode = await getSchemaMode(\"create\");\n paths[`/api/${parentRouteName}/{id}/${routeName}`] = {\n post: {\n tags: [humanReadableNamePlural],\n summary: `Create ${humanReadableName} for ${parentHumanName}`,\n description: `Creates a new ${humanReadableName} record associated with the specified ${parentHumanName}`,\n operationId: `create${pascalModelName}For${pascalCase(parentModel)}`,\n parameters: [\n {\n name: \"id\",\n in: \"path\",\n description: `Unique identifier of the ${parentHumanName}`,\n required: true,\n schema: {\n type: \"string\",\n },\n },\n ],\n requestBody: {\n description: `${humanReadableName} data to create`,\n required: true,\n content: {\n \"application/json\": {\n schema: {\n $ref: getSchemaRef(`Create${pascalModelName}`, createMode),\n },\n },\n },\n },\n responses: {\n \"201\": {\n description: `${humanReadableName} created successfully`,\n content: {\n \"application/json\": {\n schema: {\n $ref: getSchemaRef(`${pascalModelName}`, createMode),\n },\n },\n },\n },\n \"400\": {\n description: \"Invalid input data provided\",\n },\n \"401\": {\n description: \"Authentication required\",\n },\n \"403\": {\n description: \"Insufficient permissions\",\n },\n \"404\": {\n description: `${parentHumanName} not found`,\n },\n },\n security: [{ BearerAuth: [] }],\n },\n };\n }\n\n // Find Many (Parent)\n if (isParentEndpointAllowed(\"findMany\")) {\n if (!paths[`/api/${parentRouteName}/{id}/${routeName}`])\n paths[`/api/${parentRouteName}/{id}/${routeName}`] = {};\n const findManyMode = await getSchemaMode(\"findMany\");\n paths[`/api/${parentRouteName}/{id}/${routeName}`]!.get = {\n tags: [humanReadableNamePlural],\n summary: `Get ${humanReadableNamePlural} for ${parentHumanName}`,\n description: `Retrieves all ${humanReadableNamePlural} associated with the specified ${parentHumanName}`,\n operationId: `get${pluralize.plural(pascalModelName)}For${pascalCase(parentModel)}`,\n parameters: [\n {\n name: \"id\",\n in: \"path\",\n description: `Unique identifier of the ${parentHumanName}`,\n required: true,\n schema: {\n type: \"string\",\n },\n },\n {\n name: \"filter\",\n in: \"query\",\n description: \"Additional filter criteria in JSON format\",\n schema: {\n type: \"string\",\n },\n },\n {\n name: \"sort\",\n in: \"query\",\n description: \"Sort field (prefix with '-' for descending order)\",\n schema: {\n type: \"string\",\n },\n },\n {\n name: \"page\",\n in: \"query\",\n description: \"Page number (starts from 1)\",\n schema: {\n type: \"integer\",\n minimum: 1,\n },\n },\n {\n name: \"limit\",\n in: \"query\",\n description: \"Number of items per page\",\n schema: {\n type: \"integer\",\n minimum: 1,\n maximum: 100,\n },\n },\n {\n name: \"fields\",\n in: \"query\",\n description: \"Comma-separated list of fields to include in response\",\n schema: {\n type: \"string\",\n },\n },\n ],\n responses: {\n \"200\": {\n description: `List of ${humanReadableNamePlural} retrieved successfully`,\n content: {\n \"application/json\": {\n schema: {\n type: \"object\",\n properties: {\n total: {\n type: \"integer\",\n description:\n \"Total number of records matching the criteria\",\n },\n results: {\n type: \"integer\",\n description: \"Number of records returned in current page\",\n },\n data: {\n type: \"array\",\n items: {\n $ref: getSchemaRef(\n `FindMany${pascalModelName}`,\n findManyMode\n ),\n },\n },\n },\n },\n },\n },\n },\n \"401\": {\n description: \"Authentication required\",\n },\n \"403\": {\n description: \"Insufficient permissions\",\n },\n \"404\": {\n description: `${parentHumanName} not found`,\n },\n },\n security: [{ BearerAuth: [] }],\n };\n }\n\n // Create Many (Parent)\n if (isParentEndpointAllowed(\"createMany\")) {\n const createManyMode = await getSchemaMode(\"createMany\");\n paths[`/api/${parentRouteName}/{id}/${routeName}/many`] = {\n post: {\n tags: [humanReadableNamePlural],\n summary: `Create multiple ${humanReadableNamePlural} for ${parentHumanName}`,\n description: `Creates multiple ${humanReadableNamePlural} records associated with the specified ${parentHumanName}`,\n operationId: `createMany${pascalModelName}For${pascalCase(parentModel)}`,\n parameters: [\n {\n name: \"id\",\n in: \"path\",\n description: `Unique identifier of the ${parentHumanName}`,\n required: true,\n schema: {\n type: \"string\",\n },\n },\n ],\n requestBody: {\n description: `Array of ${humanReadableName} data to create`,\n required: true,\n content: {\n \"application/json\": {\n schema: {\n type: \"array\",\n items: {\n $ref: getSchemaRef(\n `CreateMany${pascalModelName}`,\n createManyMode\n ),\n },\n },\n },\n },\n },\n responses: {\n \"201\": {\n description: `${humanReadableNamePlural} created successfully`,\n content: {\n \"application/json\": {\n schema: {\n type: \"object\",\n properties: {\n count: {\n type: \"integer\",\n description: \"Number of records created\",\n },\n },\n },\n },\n },\n },\n \"400\": {\n description: \"Invalid input data provided\",\n },\n \"401\": {\n description: \"Authentication required\",\n },\n \"403\": {\n description: \"Insufficient permissions\",\n },\n \"404\": {\n description: `${parentHumanName} not found`,\n },\n },\n security: [{ BearerAuth: [] }],\n },\n };\n }\n\n // Update Many (Parent)\n if (isParentEndpointAllowed(\"updateMany\")) {\n if (!paths[`/api/${parentRouteName}/{id}/${routeName}/many`])\n paths[`/api/${parentRouteName}/{id}/${routeName}/many`] = {};\n const updateManyMode = await getSchemaMode(\"updateMany\");\n paths[`/api/${parentRouteName}/{id}/${routeName}/many`]!.patch = {\n tags: [humanReadableNamePlural],\n summary: `Update multiple ${humanReadableNamePlural} for ${parentHumanName}`,\n description: `Updates multiple ${humanReadableNamePlural} records associated with the specified ${parentHumanName}`,\n operationId: `updateMany${pascalModelName}For${pascalCase(parentModel)}`,\n parameters: [\n {\n name: \"id\",\n in: \"path\",\n description: `Unique identifier of the ${parentHumanName}`,\n required: true,\n schema: {\n type: \"string\",\n },\n },\n {\n name: \"filter\",\n in: \"query\",\n description: \"Additional filter criteria in JSON format\",\n schema: {\n type: \"string\",\n },\n },\n ],\n requestBody: {\n description: `Partial ${humanReadableName} data to update`,\n required: true,\n content: {\n \"application/json\": {\n schema: {\n $ref: getSchemaRef(\n `UpdateMany${pascalModelName}`,\n updateManyMode\n ),\n },\n },\n },\n },\n responses: {\n \"200\": {\n description: `${humanReadableNamePlural} updated successfully`,\n content: {\n \"application/json\": {\n schema: {\n type: \"object\",\n properties: {\n count: {\n type: \"integer\",\n description: \"Number of records updated\",\n },\n },\n },\n },\n },\n },\n \"400\": {\n description: \"Invalid input data provided\",\n },\n \"401\": {\n description: \"Authentication required\",\n },\n \"403\": {\n description: \"Insufficient permissions\",\n },\n \"404\": {\n description: `${parentHumanName} not found`,\n },\n },\n security: [{ BearerAuth: [] }],\n };\n }\n\n // Delete Many (Parent)\n if (isParentEndpointAllowed(\"deleteMany\")) {\n if (!paths[`/api/${parentRouteName}/{id}/${routeName}/many`])\n paths[`/api/${parentRouteName}/{id}/${routeName}/many`] = {};\n paths[`/api/${parentRouteName}/{id}/${routeName}/many`]!.delete = {\n tags: [humanReadableNamePlural],\n summary: `Delete multiple ${humanReadableNamePlural} for ${parentHumanName}`,\n description: `Deletes multiple ${humanReadableNamePlural} records associated with the specified ${parentHumanName}`,\n operationId: `deleteMany${pascalModelName}For${pascalCase(parentModel)}`,\n parameters: [\n {\n name: \"id\",\n in: \"path\",\n description: `Unique identifier of the ${parentHumanName}`,\n required: true,\n schema: {\n type: \"string\",\n },\n },\n {\n name: \"filter\",\n in: \"query\",\n description: \"Additional filter criteria in JSON format\",\n schema: {\n type: \"string\",\n },\n },\n ],\n responses: {\n \"200\": {\n description: `${humanReadableNamePlural} deleted successfully`,\n content: {\n \"application/json\": {\n schema: {\n type: \"object\",\n properties: {\n count: {\n type: \"integer\",\n description: \"Number of records deleted\",\n },\n },\n },\n },\n },\n },\n \"400\": {\n description: \"Missing filter criteria\",\n },\n \"401\": {\n description: \"Authentication required\",\n },\n \"403\": {\n description: \"Insufficient permissions\",\n },\n \"404\": {\n description: `${parentHumanName} not found`,\n },\n },\n security: [{ BearerAuth: [] }],\n };\n }\n\n // Find One (Parent)\n if (isParentEndpointAllowed(\"findOne\")) {\n const findOneMode = await getSchemaMode(\"findOne\");\n paths[`/api/${parentRouteName}/{id}/${routeName}/{childId}`] = {\n get: {\n tags: [humanReadableNamePlural],\n summary: `Get ${humanReadableName} by ID for ${parentHumanName}`,\n description: `Retrieves a single ${humanReadableName} record by its unique identifier associated with the specified ${parentHumanName}`,\n operationId: `get${pascalModelName}ByIdFor${pascalCase(parentModel)}`,\n parameters: [\n {\n name: \"id\",\n in: \"path\",\n description: `Unique identifier of the ${parentHumanName}`,\n required: true,\n schema: {\n type: \"string\",\n },\n },\n {\n name: \"childId\",\n in: \"path\",\n description: `Unique identifier of the ${humanReadableName}`,\n required: true,\n schema: {\n type: \"string\",\n },\n },\n ],\n responses: {\n \"200\": {\n description: `${humanReadableName} retrieved successfully`,\n content: {\n \"application/json\": {\n schema: {\n $ref: getSchemaRef(`FindOne${pascalModelName}`, findOneMode),\n },\n },\n },\n },\n \"401\": {\n description: \"Authentication required\",\n },\n \"403\": {\n description: \"Insufficient permissions\",\n },\n \"404\": {\n description: `${humanReadableName} or ${parentHumanName} not found`,\n },\n },\n security: [{ BearerAuth: [] }],\n },\n };\n }\n\n // Update One (Parent)\n if (isParentEndpointAllowed(\"updateOne\")) {\n if (!paths[`/api/${parentRouteName}/{id}/${routeName}/{childId}`])\n paths[`/api/${parentRouteName}/{id}/${routeName}/{childId}`] = {};\n const updateMode = await getSchemaMode(\"update\");\n paths[`/api/${parentRouteName}/{id}/${routeName}/{childId}`]!.patch = {\n tags: [humanReadableNamePlural],\n summary: `Update ${humanReadableName} by ID for ${parentHumanName}`,\n description: `Updates a single ${humanReadableName} record by its unique identifier associated with the specified ${parentHumanName}`,\n operationId: `update${pascalModelName}ByIdFor${pascalCase(parentModel)}`,\n parameters: [\n {\n name: \"id\",\n in: \"path\",\n description: `Unique identifier of the ${parentHumanName}`,\n required: true,\n schema: {\n type: \"string\",\n },\n },\n {\n name: \"childId\",\n in: \"path\",\n description: `Unique identifier of the ${humanReadableName}`,\n required: true,\n schema: {\n type: \"string\",\n },\n },\n ],\n requestBody: {\n description: `Partial ${humanReadableName} data to update`,\n required: true,\n content: {\n \"application/json\": {\n schema: {\n $ref: getSchemaRef(`Update${pascalModelName}`, updateMode),\n },\n },\n },\n },\n responses: {\n \"200\": {\n description: `${humanReadableName} updated successfully`,\n content: {\n \"application/json\": {\n schema: {\n $ref: getSchemaRef(`${pascalModelName}`, updateMode),\n },\n },\n },\n },\n \"400\": {\n description: \"Invalid input data provided\",\n },\n \"401\": {\n description: \"Authentication required\",\n },\n \"403\": {\n description: \"Insufficient permissions\",\n },\n \"404\": {\n description: `${humanReadableName} or ${parentHumanName} not found`,\n },\n },\n security: [{ BearerAuth: [] }],\n };\n }\n\n // Delete One (Parent)\n if (isParentEndpointAllowed(\"deleteOne\")) {\n if (!paths[`/api/${parentRouteName}/{id}/${routeName}/{childId}`])\n paths[`/api/${parentRouteName}/{id}/${routeName}/{childId}`] = {};\n paths[`/api/${parentRouteName}/{id}/${routeName}/{childId}`]!.delete = {\n tags: [humanReadableNamePlural],\n summary: `Delete ${humanReadableName} by ID for ${parentHumanName}`,\n description: `Permanently deletes a single ${humanReadableName} record by its unique identifier associated with the specified ${parentHumanName}`,\n operationId: `delete${pascalModelName}ByIdFor${pascalCase(parentModel)}`,\n parameters: [\n {\n name: \"id\",\n in: \"path\",\n description: `Unique identifier of the ${parentHumanName}`,\n required: true,\n schema: {\n type: \"string\",\n },\n },\n {\n name: \"childId\",\n in: \"path\",\n description: `Unique identifier of the ${humanReadableName}`,\n required: true,\n schema: {\n type: \"string\",\n },\n },\n ],\n responses: {\n \"204\": {\n description: `${humanReadableName} deleted successfully`,\n },\n \"401\": {\n description: \"Authentication required\",\n },\n \"403\": {\n description: \"Insufficient permissions\",\n },\n \"404\": {\n description: `${humanReadableName} or ${parentHumanName} not found`,\n },\n },\n security: [{ BearerAuth: [] }],\n };\n }\n}\n"]}