arkos 1.2.3-test → 1.2.4-beta

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 (101) hide show
  1. package/cli.js +0 -9
  2. package/dist/cjs/app.js +1 -1
  3. package/dist/cjs/app.js.map +1 -1
  4. package/dist/cjs/exports/utils/index.js +26 -0
  5. package/dist/cjs/exports/utils/index.js.map +1 -1
  6. package/dist/cjs/modules/base/base.controller.js +12 -16
  7. package/dist/cjs/modules/base/base.controller.js.map +1 -1
  8. package/dist/cjs/modules/base/base.router.js.map +1 -1
  9. package/dist/cjs/modules/base/utils/helpers/base.router.helpers.js +32 -18
  10. package/dist/cjs/modules/base/utils/helpers/base.router.helpers.js.map +1 -1
  11. package/dist/cjs/modules/error-handler/error-handler.controller.js +1 -0
  12. package/dist/cjs/modules/error-handler/error-handler.controller.js.map +1 -1
  13. package/dist/cjs/modules/swagger/swagger.router.js +16 -38
  14. package/dist/cjs/modules/swagger/swagger.router.js.map +1 -1
  15. package/dist/cjs/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js +250 -0
  16. package/dist/cjs/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js.map +1 -0
  17. package/dist/cjs/modules/swagger/utils/helpers/get-system-json-schema-paths.js +66 -0
  18. package/dist/cjs/modules/swagger/utils/helpers/get-system-json-schema-paths.js.map +1 -0
  19. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js +41 -0
  20. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js.map +1 -0
  21. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js +22 -0
  22. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js.map +1 -0
  23. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.js +29 -0
  24. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.js.map +1 -0
  25. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes.js +439 -0
  26. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes.js.map +1 -0
  27. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.js +162 -0
  28. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.js.map +1 -0
  29. package/dist/cjs/modules/swagger/utils/helpers/swagger.router.helpers.js +90 -0
  30. package/dist/cjs/modules/swagger/utils/helpers/swagger.router.helpers.js.map +1 -0
  31. package/dist/cjs/server.js +2 -2
  32. package/dist/cjs/server.js.map +1 -1
  33. package/dist/cjs/types/arkos-config.js.map +1 -1
  34. package/dist/cjs/utils/cli/dev.js +2 -2
  35. package/dist/cjs/utils/cli/dev.js.map +1 -1
  36. package/dist/cjs/utils/features/api.features.js +34 -22
  37. package/dist/cjs/utils/features/api.features.js.map +1 -1
  38. package/dist/cjs/utils/helpers/fs.helpers.js +2 -1
  39. package/dist/cjs/utils/helpers/fs.helpers.js.map +1 -1
  40. package/dist/cjs/utils/helpers/models.helpers.js +10 -2
  41. package/dist/cjs/utils/helpers/models.helpers.js.map +1 -1
  42. package/dist/cjs/utils/sheu.js +143 -0
  43. package/dist/cjs/utils/sheu.js.map +1 -0
  44. package/dist/es2020/app.js +1 -1
  45. package/dist/es2020/app.js.map +1 -1
  46. package/dist/es2020/exports/utils/index.js +2 -0
  47. package/dist/es2020/exports/utils/index.js.map +1 -1
  48. package/dist/es2020/modules/base/base.controller.js +12 -16
  49. package/dist/es2020/modules/base/base.controller.js.map +1 -1
  50. package/dist/es2020/modules/base/base.router.js.map +1 -1
  51. package/dist/es2020/modules/base/utils/helpers/base.router.helpers.js +30 -18
  52. package/dist/es2020/modules/base/utils/helpers/base.router.helpers.js.map +1 -1
  53. package/dist/es2020/modules/error-handler/error-handler.controller.js +1 -0
  54. package/dist/es2020/modules/error-handler/error-handler.controller.js.map +1 -1
  55. package/dist/es2020/modules/swagger/swagger.router.js +16 -38
  56. package/dist/es2020/modules/swagger/swagger.router.js.map +1 -1
  57. package/dist/es2020/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js +247 -0
  58. package/dist/es2020/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js.map +1 -0
  59. package/dist/es2020/modules/swagger/utils/helpers/get-system-json-schema-paths.js +63 -0
  60. package/dist/es2020/modules/swagger/utils/helpers/get-system-json-schema-paths.js.map +1 -0
  61. package/dist/es2020/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js +38 -0
  62. package/dist/es2020/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js.map +1 -0
  63. package/dist/es2020/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js +19 -0
  64. package/dist/es2020/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js.map +1 -0
  65. package/dist/es2020/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.js +23 -0
  66. package/dist/es2020/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.js.map +1 -0
  67. package/dist/es2020/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes.js +436 -0
  68. package/dist/es2020/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes.js.map +1 -0
  69. package/dist/es2020/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.js +159 -0
  70. package/dist/es2020/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.js.map +1 -0
  71. package/dist/es2020/modules/swagger/utils/helpers/swagger.router.helpers.js +83 -0
  72. package/dist/es2020/modules/swagger/utils/helpers/swagger.router.helpers.js.map +1 -0
  73. package/dist/es2020/server.js +2 -2
  74. package/dist/es2020/server.js.map +1 -1
  75. package/dist/es2020/types/arkos-config.js.map +1 -1
  76. package/dist/es2020/utils/cli/dev.js +2 -2
  77. package/dist/es2020/utils/cli/dev.js.map +1 -1
  78. package/dist/es2020/utils/features/api.features.js +33 -22
  79. package/dist/es2020/utils/features/api.features.js.map +1 -1
  80. package/dist/es2020/utils/helpers/fs.helpers.js +2 -1
  81. package/dist/es2020/utils/helpers/fs.helpers.js.map +1 -1
  82. package/dist/es2020/utils/helpers/models.helpers.js +9 -1
  83. package/dist/es2020/utils/helpers/models.helpers.js.map +1 -1
  84. package/dist/es2020/utils/sheu.js +141 -0
  85. package/dist/es2020/utils/sheu.js.map +1 -0
  86. package/dist/types/exports/utils/index.d.ts +2 -0
  87. package/dist/types/modules/base/utils/helpers/base.router.helpers.d.ts +4 -1
  88. package/dist/types/modules/swagger/swagger.router.d.ts +1 -1
  89. package/dist/types/modules/swagger/utils/helpers/get-authentication-json-schema-paths.d.ts +2 -0
  90. package/dist/types/modules/swagger/utils/helpers/get-system-json-schema-paths.d.ts +2 -0
  91. package/dist/types/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.d.ts +1 -0
  92. package/dist/types/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.d.ts +1 -0
  93. package/dist/types/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.d.ts +1 -0
  94. package/dist/types/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes.d.ts +2 -0
  95. package/dist/types/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.d.ts +2 -0
  96. package/dist/types/modules/swagger/utils/helpers/swagger.router.helpers.d.ts +7 -0
  97. package/dist/types/types/arkos-config.d.ts +7 -4
  98. package/dist/types/utils/features/api.features.d.ts +5 -4
  99. package/dist/types/utils/helpers/models.helpers.d.ts +10 -0
  100. package/dist/types/utils/sheu.d.ts +25 -0
  101. package/package.json +7 -3
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSystemJsonSchemaPaths = getSystemJsonSchemaPaths;
4
+ function getSystemJsonSchemaPaths() {
5
+ const paths = {};
6
+ paths["/api/available-resources"] = {
7
+ get: {
8
+ tags: ["System"],
9
+ summary: "Get available resources",
10
+ description: "Returns a comprehensive list of all available API resource endpoints",
11
+ operationId: "getAvailableResources",
12
+ responses: {
13
+ "200": {
14
+ description: "List of available resources retrieved successfully",
15
+ content: {
16
+ "application/json": {
17
+ schema: {
18
+ type: "object",
19
+ properties: {
20
+ data: {
21
+ type: "array",
22
+ items: {
23
+ type: "string",
24
+ },
25
+ description: "Array of available resource endpoints",
26
+ },
27
+ },
28
+ },
29
+ },
30
+ },
31
+ },
32
+ },
33
+ },
34
+ };
35
+ paths["/api/available-routes"] = {
36
+ get: {
37
+ tags: ["System"],
38
+ summary: "Get available routes",
39
+ description: "Returns a comprehensive list of all registered API routes and their methods",
40
+ operationId: "getAvailableRoutes",
41
+ responses: {
42
+ "200": {
43
+ description: "List of available routes retrieved successfully",
44
+ content: {
45
+ "application/json": {
46
+ schema: {
47
+ type: "object",
48
+ properties: {
49
+ routes: {
50
+ type: "array",
51
+ items: {
52
+ type: "string",
53
+ },
54
+ description: "Array of available API routes",
55
+ },
56
+ },
57
+ },
58
+ },
59
+ },
60
+ },
61
+ },
62
+ },
63
+ };
64
+ return paths;
65
+ }
66
+ //# sourceMappingURL=get-system-json-schema-paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-system-json-schema-paths.js","sourceRoot":"","sources":["../../../../../../src/modules/swagger/utils/helpers/get-system-json-schema-paths.ts"],"names":[],"mappings":";;AAEA,4DAkEC;AAlED,SAAgB,wBAAwB;IACtC,MAAM,KAAK,GAA0B,EAAE,CAAC;IAExC,KAAK,CAAC,0BAA0B,CAAC,GAAG;QAClC,GAAG,EAAE;YACH,IAAI,EAAE,CAAC,QAAQ,CAAC;YAChB,OAAO,EAAE,yBAAyB;YAClC,WAAW,EACT,sEAAsE;YACxE,WAAW,EAAE,uBAAuB;YACpC,SAAS,EAAE;gBACT,KAAK,EAAE;oBACL,WAAW,EAAE,oDAAoD;oBACjE,OAAO,EAAE;wBACP,kBAAkB,EAAE;4BAClB,MAAM,EAAE;gCACN,IAAI,EAAE,QAAQ;gCACd,UAAU,EAAE;oCACV,IAAI,EAAE;wCACJ,IAAI,EAAE,OAAO;wCACb,KAAK,EAAE;4CACL,IAAI,EAAE,QAAQ;yCACf;wCACD,WAAW,EAAE,uCAAuC;qCACrD;iCACF;6BACF;yBACF;qBACF;iBACF;aACF;SACF;KACF,CAAC;IAEF,KAAK,CAAC,uBAAuB,CAAC,GAAG;QAC/B,GAAG,EAAE;YACH,IAAI,EAAE,CAAC,QAAQ,CAAC;YAChB,OAAO,EAAE,sBAAsB;YAC/B,WAAW,EACT,6EAA6E;YAC/E,WAAW,EAAE,oBAAoB;YACjC,SAAS,EAAE;gBACT,KAAK,EAAE;oBACL,WAAW,EAAE,iDAAiD;oBAC9D,OAAO,EAAE;wBACP,kBAAkB,EAAE;4BAClB,MAAM,EAAE;gCACN,IAAI,EAAE,QAAQ;gCACd,UAAU,EAAE;oCACV,MAAM,EAAE;wCACN,IAAI,EAAE,OAAO;wCACb,KAAK,EAAE;4CACL,IAAI,EAAE,QAAQ;yCACf;wCACD,WAAW,EAAE,+BAA+B;qCAC7C;iCACF;6BACF;yBACF;qBACF;iBACF;aACF;SACF;KACF,CAAC;IAEF,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { OpenAPIV3 } from \"openapi-types\";\n\nexport function getSystemJsonSchemaPaths() {\n const paths: OpenAPIV3.PathsObject = {};\n\n paths[\"/api/available-resources\"] = {\n get: {\n tags: [\"System\"],\n summary: \"Get available resources\",\n description:\n \"Returns a comprehensive list of all available API resource endpoints\",\n operationId: \"getAvailableResources\",\n responses: {\n \"200\": {\n description: \"List of available resources retrieved successfully\",\n content: {\n \"application/json\": {\n schema: {\n type: \"object\",\n properties: {\n data: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n description: \"Array of available resource endpoints\",\n },\n },\n },\n },\n },\n },\n },\n },\n };\n\n paths[\"/api/available-routes\"] = {\n get: {\n tags: [\"System\"],\n summary: \"Get available routes\",\n description:\n \"Returns a comprehensive list of all registered API routes and their methods\",\n operationId: \"getAvailableRoutes\",\n responses: {\n \"200\": {\n description: \"List of available routes retrieved successfully\",\n content: {\n \"application/json\": {\n schema: {\n type: \"object\",\n properties: {\n routes: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n description: \"Array of available API routes\",\n },\n },\n },\n },\n },\n },\n },\n },\n };\n\n return paths;\n}\n"]}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateClassValidatorJsonSchemas = generateClassValidatorJsonSchemas;
4
+ const class_validator_jsonschema_1 = require("class-validator-jsonschema");
5
+ const global_helpers_1 = require("../../../../../utils/helpers/global.helpers");
6
+ const class_validator_1 = require("class-validator");
7
+ const models_helpers_1 = require("../../../../../utils/helpers/models.helpers");
8
+ const swagger_router_helpers_1 = require("../swagger.router.helpers");
9
+ async function generateClassValidatorJsonSchemas() {
10
+ const models = (0, models_helpers_1.getModels)();
11
+ const schemas = {};
12
+ const { defaultMetadataStorage } = await (0, global_helpers_1.importModule)("class-transformer/cjs/storage");
13
+ const jsonSchema = (0, class_validator_jsonschema_1.validationMetadatasToSchemas)({
14
+ classValidatorMetadataStorage: (0, class_validator_1.getMetadataStorage)(),
15
+ classTransformerMetadataStorage: defaultMetadataStorage,
16
+ refPointerPrefix: "#/components/schemas/",
17
+ });
18
+ Object.entries(jsonSchema).forEach(([className, schema]) => {
19
+ schemas[className] = schema;
20
+ });
21
+ models.forEach((modelName) => {
22
+ const modelModules = (0, models_helpers_1.getModelModules)(modelName);
23
+ if (modelModules?.dtos) {
24
+ Object.entries(modelModules.dtos).forEach(([dtoType, dtoClass]) => {
25
+ if (dtoClass) {
26
+ try {
27
+ const schemaName = (0, swagger_router_helpers_1.getCorrectJsonSchemaName)(dtoType, modelName, "Dto");
28
+ schemas[schemaName] = jsonSchema[dtoClass.name] || {};
29
+ if (schemas[dtoClass.name])
30
+ delete schemas[dtoClass.name];
31
+ }
32
+ catch (error) {
33
+ console.warn(`Failed to generate schema for ${dtoType} ${modelName}:`, error);
34
+ }
35
+ }
36
+ });
37
+ }
38
+ });
39
+ return schemas;
40
+ }
41
+ //# sourceMappingURL=generate-class-validator-json-schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-class-validator-json-schemas.js","sourceRoot":"","sources":["../../../../../../../src/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.ts"],"names":[],"mappings":";;AASA,8EA4CC;AArDD,2EAA0E;AAC1E,gFAA2E;AAC3E,qDAAqD;AACrD,gFAGqD;AACrD,sEAAqE;AAE9D,KAAK,UAAU,iCAAiC;IACrD,MAAM,MAAM,GAAG,IAAA,0BAAS,GAAE,CAAC;IAC3B,MAAM,OAAO,GAAwB,EAAE,CAAC;IAExC,MAAM,EAAE,sBAAsB,EAAE,GAAG,MAAM,IAAA,6BAAY,EACnD,+BAA+B,CAChC,CAAC;IAEF,MAAM,UAAU,GAAG,IAAA,yDAA4B,EAAC;QAC9C,6BAA6B,EAAE,IAAA,oCAAkB,GAAE;QACnD,+BAA+B,EAAE,sBAAsB;QACvD,gBAAgB,EAAE,uBAAuB;KAC1C,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,MAAM,CAAC,EAAE,EAAE;QACzD,OAAO,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC;IAC9B,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;QAC3B,MAAM,YAAY,GAAG,IAAA,gCAAe,EAAC,SAAS,CAAC,CAAC;QAEhD,IAAI,YAAY,EAAE,IAAI,EAAE,CAAC;YACvB,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,EAAE;gBAChE,IAAI,QAAQ,EAAE,CAAC;oBACb,IAAI,CAAC;wBACH,MAAM,UAAU,GAAG,IAAA,iDAAwB,EACzC,OAAO,EACP,SAAS,EACT,KAAK,CACN,CAAC;wBACF,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;wBACtD,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;4BAAE,OAAO,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;oBAC5D,CAAC;oBAAC,OAAO,KAAK,EAAE,CAAC;wBACf,OAAO,CAAC,IAAI,CACV,iCAAiC,OAAO,IAAI,SAAS,GAAG,EACxD,KAAK,CACN,CAAC;oBACJ,CAAC;gBACH,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import { validationMetadatasToSchemas } from \"class-validator-jsonschema\";\nimport { importModule } from \"../../../../../utils/helpers/global.helpers\";\nimport { getMetadataStorage } from \"class-validator\";\nimport {\n getModelModules,\n getModels,\n} from \"../../../../../utils/helpers/models.helpers\";\nimport { getCorrectJsonSchemaName } from \"../swagger.router.helpers\";\n\nexport async function generateClassValidatorJsonSchemas() {\n const models = getModels();\n const schemas: Record<string, any> = {};\n\n const { defaultMetadataStorage } = await importModule(\n \"class-transformer/cjs/storage\"\n );\n\n const jsonSchema = validationMetadatasToSchemas({\n classValidatorMetadataStorage: getMetadataStorage(),\n classTransformerMetadataStorage: defaultMetadataStorage,\n refPointerPrefix: \"#/components/schemas/\",\n });\n\n Object.entries(jsonSchema).forEach(([className, schema]) => {\n schemas[className] = schema;\n });\n\n models.forEach((modelName) => {\n const modelModules = getModelModules(modelName);\n\n if (modelModules?.dtos) {\n Object.entries(modelModules.dtos).forEach(([dtoType, dtoClass]) => {\n if (dtoClass) {\n try {\n const schemaName = getCorrectJsonSchemaName(\n dtoType,\n modelName,\n \"Dto\"\n );\n schemas[schemaName] = jsonSchema[dtoClass.name] || {};\n if (schemas[dtoClass.name]) delete schemas[dtoClass.name];\n } catch (error) {\n console.warn(\n `Failed to generate schema for ${dtoType} ${modelName}:`,\n error\n );\n }\n }\n });\n }\n });\n\n return schemas;\n}\n"]}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generatePrismaJsonSchemas = generatePrismaJsonSchemas;
4
+ const utils_1 = require("../../../../../exports/utils");
5
+ const models_helpers_1 = require("../../../../../utils/helpers/models.helpers");
6
+ async function generatePrismaJsonSchemas() {
7
+ const schemas = {};
8
+ const prismaContent = (0, models_helpers_1.getPrismaSchemasContent)();
9
+ const models = (0, models_helpers_1.getModels)();
10
+ models.forEach((modelName) => {
11
+ const pascalModelName = (0, utils_1.pascalCase)(modelName);
12
+ schemas[`Create${pascalModelName}Schema`] = {
13
+ type: "object",
14
+ properties: {},
15
+ };
16
+ schemas[`Update${pascalModelName}Schema`] = {
17
+ type: "object",
18
+ properties: {},
19
+ };
20
+ });
21
+ }
22
+ //# sourceMappingURL=generate-prisma-json-schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-prisma-json-schemas.js","sourceRoot":"","sources":["../../../../../../../src/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.ts"],"names":[],"mappings":";;AAMA,8DAsBC;AA5BD,wDAA0D;AAC1D,gFAGqD;AAE9C,KAAK,UAAU,yBAAyB;IAC7C,MAAM,OAAO,GAAwB,EAAE,CAAC;IACxC,MAAM,aAAa,GAAG,IAAA,wCAAuB,GAAE,CAAC;IAChD,MAAM,MAAM,GAAG,IAAA,0BAAS,GAAE,CAAC;IAE3B,MAAM,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;QAC3B,MAAM,eAAe,GAAG,IAAA,kBAAU,EAAC,SAAS,CAAC,CAAC;QAE9C,OAAO,CAAC,SAAS,eAAe,QAAQ,CAAC,GAAG;YAC1C,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE,EAEX;SACF,CAAC;QAEF,OAAO,CAAC,SAAS,eAAe,QAAQ,CAAC,GAAG;YAC1C,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE,EAEX;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { pascalCase } from \"../../../../../exports/utils\";\nimport {\n getModels,\n getPrismaSchemasContent,\n} from \"../../../../../utils/helpers/models.helpers\";\n\nexport async function generatePrismaJsonSchemas() {\n const schemas: Record<string, any> = {};\n const prismaContent = getPrismaSchemasContent();\n const models = getModels();\n\n models.forEach((modelName) => {\n const pascalModelName = pascalCase(modelName);\n\n schemas[`Create${pascalModelName}Schema`] = {\n type: \"object\",\n properties: {\n // Omit auto-generated fields like id, createdAt, updatedAt\n },\n };\n\n schemas[`Update${pascalModelName}Schema`] = {\n type: \"object\",\n properties: {\n // Make all fields optional for updates\n },\n };\n });\n}\n"]}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.generateZodJsonSchemas = generateZodJsonSchemas;
7
+ const models_helpers_1 = require("../../../../../utils/helpers/models.helpers");
8
+ const zod_to_json_schema_1 = __importDefault(require("zod-to-json-schema"));
9
+ const swagger_router_helpers_1 = require("../swagger.router.helpers");
10
+ async function generateZodJsonSchemas() {
11
+ const models = (0, models_helpers_1.getModels)();
12
+ models.forEach((modelName) => {
13
+ const modelModules = (0, models_helpers_1.getModelModules)(modelName);
14
+ const schemas = {};
15
+ if (modelModules?.schemas)
16
+ Object.entries(modelModules.schemas).forEach(([schemaType, zodSchema]) => {
17
+ if (zodSchema)
18
+ try {
19
+ const jsonSchema = (0, zod_to_json_schema_1.default)(zodSchema);
20
+ const schemaName = (0, swagger_router_helpers_1.getCorrectJsonSchemaName)(schemaType, modelName, "Schema");
21
+ schemas[schemaName] = jsonSchema;
22
+ }
23
+ catch (error) {
24
+ console.warn(`Failed to generate schema for ${schemaType} ${modelName}:`, error);
25
+ }
26
+ });
27
+ });
28
+ }
29
+ //# sourceMappingURL=generate-zod-json-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-zod-json-schema.js","sourceRoot":"","sources":["../../../../../../../src/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.ts"],"names":[],"mappings":";;;;;AAOA,wDA6BC;AApCD,gFAGqD;AACrD,4EAAiD;AACjD,sEAAqE;AAE9D,KAAK,UAAU,sBAAsB;IAC1C,MAAM,MAAM,GAAG,IAAA,0BAAS,GAAE,CAAC;IAE3B,MAAM,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;QAC3B,MAAM,YAAY,GAAG,IAAA,gCAAe,EAAC,SAAS,CAAC,CAAC;QAChD,MAAM,OAAO,GAAwB,EAAE,CAAC;QAExC,IAAI,YAAY,EAAE,OAAO;YACvB,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,OAAO,CAC1C,CAAC,CAAC,UAAU,EAAE,SAAS,CAAC,EAAE,EAAE;gBAC1B,IAAI,SAAS;oBACX,IAAI,CAAC;wBACH,MAAM,UAAU,GAAG,IAAA,4BAAe,EAAC,SAAS,CAAC,CAAC;wBAC9C,MAAM,UAAU,GAAG,IAAA,iDAAwB,EACzC,UAAU,EACV,SAAS,EACT,QAAQ,CACT,CAAC;wBAEF,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;oBACnC,CAAC;oBAAC,OAAO,KAAK,EAAE,CAAC;wBACf,OAAO,CAAC,IAAI,CACV,iCAAiC,UAAU,IAAI,SAAS,GAAG,EAC3D,KAAK,CACN,CAAC;oBACJ,CAAC;YACL,CAAC,CACF,CAAC;IACN,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n getModelModules,\n getModels,\n} from \"../../../../../utils/helpers/models.helpers\";\nimport zodToJsonSchema from \"zod-to-json-schema\";\nimport { getCorrectJsonSchemaName } from \"../swagger.router.helpers\";\n\nexport async function generateZodJsonSchemas() {\n const models = getModels();\n\n models.forEach((modelName) => {\n const modelModules = getModelModules(modelName);\n const schemas: Record<string, any> = {};\n\n if (modelModules?.schemas)\n Object.entries(modelModules.schemas).forEach(\n ([schemaType, zodSchema]) => {\n if (zodSchema)\n try {\n const jsonSchema = zodToJsonSchema(zodSchema);\n const schemaName = getCorrectJsonSchemaName(\n schemaType,\n modelName,\n \"Schema\"\n );\n\n schemas[schemaName] = jsonSchema;\n } catch (error) {\n console.warn(\n `Failed to generate schema for ${schemaType} ${modelName}:`,\n error\n );\n }\n }\n );\n });\n}\n"]}
@@ -0,0 +1,439 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generatePrismaModelMainRoutesPaths = generatePrismaModelMainRoutesPaths;
4
+ const swagger_router_helpers_1 = require("../../swagger.router.helpers");
5
+ const pluralize_1 = require("pluralize");
6
+ const base_router_helpers_1 = require("../../../../../base/utils/helpers/base.router.helpers");
7
+ async function generatePrismaModelMainRoutesPaths(paths, routeName, pascalModelName, humanReadableName, humanReadableNamePlural, routerConfig, mode) {
8
+ if (!(0, base_router_helpers_1.isEndpointDisabled)(routerConfig, "createOne")) {
9
+ if (!paths[`/api/${routeName}`])
10
+ paths[`/api/${routeName}`] = {};
11
+ paths[`/api/${routeName}`].post = {
12
+ tags: [humanReadableNamePlural],
13
+ summary: `Create a new ${humanReadableName}`,
14
+ description: `Creates a new ${humanReadableName} record in the system`,
15
+ operationId: `create${pascalModelName}`,
16
+ requestBody: {
17
+ description: `${humanReadableName} data to create`,
18
+ required: true,
19
+ content: {
20
+ "application/json": {
21
+ schema: {
22
+ $ref: (0, swagger_router_helpers_1.getSchemaRef)(`Create${pascalModelName}`, mode),
23
+ },
24
+ },
25
+ },
26
+ },
27
+ responses: {
28
+ "201": {
29
+ description: `${humanReadableName} created successfully`,
30
+ content: {
31
+ "application/json": {
32
+ schema: {
33
+ $ref: (0, swagger_router_helpers_1.getSchemaRef)(`${pascalModelName}`, mode),
34
+ },
35
+ },
36
+ },
37
+ },
38
+ "400": {
39
+ description: "Invalid input data provided",
40
+ },
41
+ "401": {
42
+ description: "Authentication required",
43
+ },
44
+ "403": {
45
+ description: "Insufficient permissions",
46
+ },
47
+ },
48
+ security: [{ BearerAuth: [] }],
49
+ };
50
+ }
51
+ if (!(0, base_router_helpers_1.isEndpointDisabled)(routerConfig, "findMany")) {
52
+ if (!paths[`/api/${routeName}`])
53
+ paths[`/api/${routeName}`] = {};
54
+ paths[`/api/${routeName}`].get = {
55
+ tags: [humanReadableNamePlural],
56
+ summary: `Get ${humanReadableNamePlural}`,
57
+ description: `Retrieves a paginated list of ${humanReadableNamePlural} with optional filtering and sorting`,
58
+ operationId: `get${(0, pluralize_1.plural)(pascalModelName)}`,
59
+ parameters: [
60
+ {
61
+ name: "filter",
62
+ in: "query",
63
+ description: "Filter criteria in JSON format",
64
+ schema: {
65
+ type: "string",
66
+ },
67
+ },
68
+ {
69
+ name: "sort",
70
+ in: "query",
71
+ description: "Sort field (prefix with '-' for descending order)",
72
+ schema: {
73
+ type: "string",
74
+ },
75
+ },
76
+ {
77
+ name: "page",
78
+ in: "query",
79
+ description: "Page number (starts from 1)",
80
+ schema: {
81
+ type: "integer",
82
+ minimum: 1,
83
+ },
84
+ },
85
+ {
86
+ name: "limit",
87
+ in: "query",
88
+ description: "Number of items per page",
89
+ schema: {
90
+ type: "integer",
91
+ minimum: 1,
92
+ maximum: 100,
93
+ },
94
+ },
95
+ {
96
+ name: "fields",
97
+ in: "query",
98
+ description: "Comma-separated list of fields to include in response",
99
+ schema: {
100
+ type: "string",
101
+ },
102
+ },
103
+ ],
104
+ responses: {
105
+ "200": {
106
+ description: `List of ${humanReadableNamePlural} retrieved successfully`,
107
+ content: {
108
+ "application/json": {
109
+ schema: {
110
+ type: "object",
111
+ properties: {
112
+ total: {
113
+ type: "integer",
114
+ description: "Total number of records matching the criteria",
115
+ },
116
+ results: {
117
+ type: "integer",
118
+ description: "Number of records returned in current page",
119
+ },
120
+ data: {
121
+ type: "array",
122
+ items: {
123
+ $ref: (0, swagger_router_helpers_1.getSchemaRef)(`FindMany${pascalModelName}`, mode),
124
+ },
125
+ },
126
+ },
127
+ },
128
+ },
129
+ },
130
+ },
131
+ "401": {
132
+ description: "Authentication required",
133
+ },
134
+ "403": {
135
+ description: "Insufficient permissions",
136
+ },
137
+ },
138
+ security: [{ BearerAuth: [] }],
139
+ };
140
+ }
141
+ if (!(0, base_router_helpers_1.isEndpointDisabled)(routerConfig, "createMany")) {
142
+ paths[`/api/${routeName}/many`] = {
143
+ post: {
144
+ tags: [humanReadableNamePlural],
145
+ summary: `Create multiple ${humanReadableNamePlural}`,
146
+ description: `Creates multiple ${humanReadableNamePlural} records in a single batch operation`,
147
+ operationId: `createMany${pascalModelName}`,
148
+ requestBody: {
149
+ description: `Array of ${humanReadableName} data to create`,
150
+ required: true,
151
+ content: {
152
+ "application/json": {
153
+ schema: {
154
+ type: "array",
155
+ items: {
156
+ $ref: (0, swagger_router_helpers_1.getSchemaRef)(`Create${pascalModelName}`, mode),
157
+ },
158
+ },
159
+ },
160
+ },
161
+ },
162
+ responses: {
163
+ "201": {
164
+ description: `${humanReadableNamePlural} created successfully`,
165
+ content: {
166
+ "application/json": {
167
+ schema: {
168
+ type: "object",
169
+ properties: {
170
+ count: {
171
+ type: "integer",
172
+ description: "Number of records created",
173
+ },
174
+ },
175
+ },
176
+ },
177
+ },
178
+ },
179
+ "400": {
180
+ description: "Invalid input data provided",
181
+ },
182
+ "401": {
183
+ description: "Authentication required",
184
+ },
185
+ "403": {
186
+ description: "Insufficient permissions",
187
+ },
188
+ },
189
+ security: [{ BearerAuth: [] }],
190
+ },
191
+ };
192
+ }
193
+ if (!(0, base_router_helpers_1.isEndpointDisabled)(routerConfig, "updateMany")) {
194
+ if (!paths[`/api/${routeName}/many`])
195
+ paths[`/api/${routeName}/many`] = {};
196
+ paths[`/api/${routeName}/many`].patch = {
197
+ tags: [humanReadableNamePlural],
198
+ summary: `Update multiple ${humanReadableNamePlural}`,
199
+ description: `Updates multiple ${humanReadableNamePlural} records that match the specified filter criteria`,
200
+ operationId: `updateMany${pascalModelName}`,
201
+ parameters: [
202
+ {
203
+ name: "filter",
204
+ in: "query",
205
+ description: "Filter criteria in JSON format (required)",
206
+ required: true,
207
+ schema: {
208
+ type: "string",
209
+ },
210
+ },
211
+ ],
212
+ requestBody: {
213
+ description: `Partial ${humanReadableName} data to update`,
214
+ required: true,
215
+ content: {
216
+ "application/json": {
217
+ schema: {
218
+ $ref: (0, swagger_router_helpers_1.getSchemaRef)(`Update${pascalModelName}`, mode),
219
+ },
220
+ },
221
+ },
222
+ },
223
+ responses: {
224
+ "200": {
225
+ description: `${humanReadableNamePlural} updated successfully`,
226
+ content: {
227
+ "application/json": {
228
+ schema: {
229
+ type: "object",
230
+ properties: {
231
+ count: {
232
+ type: "integer",
233
+ description: "Number of records updated",
234
+ },
235
+ },
236
+ },
237
+ },
238
+ },
239
+ },
240
+ "400": {
241
+ description: "Invalid input data or missing filter criteria",
242
+ },
243
+ "401": {
244
+ description: "Authentication required",
245
+ },
246
+ "403": {
247
+ description: "Insufficient permissions",
248
+ },
249
+ },
250
+ security: [{ BearerAuth: [] }],
251
+ };
252
+ }
253
+ if (!(0, base_router_helpers_1.isEndpointDisabled)(routerConfig, "deleteMany")) {
254
+ if (!paths[`/api/${routeName}/many`])
255
+ paths[`/api/${routeName}/many`] = {};
256
+ paths[`/api/${routeName}/many`].delete = {
257
+ tags: [humanReadableNamePlural],
258
+ summary: `Delete multiple ${humanReadableNamePlural}`,
259
+ description: `Deletes multiple ${humanReadableNamePlural} records that match the specified filter criteria`,
260
+ operationId: `deleteMany${pascalModelName}`,
261
+ parameters: [
262
+ {
263
+ name: "filter",
264
+ in: "query",
265
+ description: "Filter criteria in JSON format (required)",
266
+ required: true,
267
+ schema: {
268
+ type: "string",
269
+ },
270
+ },
271
+ ],
272
+ responses: {
273
+ "200": {
274
+ description: `${humanReadableNamePlural} deleted successfully`,
275
+ content: {
276
+ "application/json": {
277
+ schema: {
278
+ type: "object",
279
+ properties: {
280
+ count: {
281
+ type: "integer",
282
+ description: "Number of records deleted",
283
+ },
284
+ },
285
+ },
286
+ },
287
+ },
288
+ },
289
+ "400": {
290
+ description: "Missing filter criteria",
291
+ },
292
+ "401": {
293
+ description: "Authentication required",
294
+ },
295
+ "403": {
296
+ description: "Insufficient permissions",
297
+ },
298
+ },
299
+ security: [{ BearerAuth: [] }],
300
+ };
301
+ }
302
+ if (!(0, base_router_helpers_1.isEndpointDisabled)(routerConfig, "findOne")) {
303
+ paths[`/api/${routeName}/{id}`] = {
304
+ get: {
305
+ tags: [humanReadableNamePlural],
306
+ summary: `Get ${humanReadableName} by ID`,
307
+ description: `Retrieves a single ${humanReadableName} record by its unique identifier`,
308
+ operationId: `get${pascalModelName}ById`,
309
+ parameters: [
310
+ {
311
+ name: "id",
312
+ in: "path",
313
+ description: `Unique identifier of the ${humanReadableName}`,
314
+ required: true,
315
+ schema: {
316
+ type: "string",
317
+ },
318
+ },
319
+ ],
320
+ responses: {
321
+ "200": {
322
+ description: `${humanReadableName} retrieved successfully`,
323
+ content: {
324
+ "application/json": {
325
+ schema: {
326
+ $ref: (0, swagger_router_helpers_1.getSchemaRef)(`FindOne${pascalModelName}`, mode),
327
+ },
328
+ },
329
+ },
330
+ },
331
+ "401": {
332
+ description: "Authentication required",
333
+ },
334
+ "403": {
335
+ description: "Insufficient permissions",
336
+ },
337
+ "404": {
338
+ description: `${humanReadableName} not found`,
339
+ },
340
+ },
341
+ security: [{ BearerAuth: [] }],
342
+ },
343
+ };
344
+ }
345
+ if (!(0, base_router_helpers_1.isEndpointDisabled)(routerConfig, "updateOne")) {
346
+ if (!paths[`/api/${routeName}/{id}`])
347
+ paths[`/api/${routeName}/{id}`] = {};
348
+ paths[`/api/${routeName}/{id}`].patch = {
349
+ tags: [humanReadableNamePlural],
350
+ summary: `Update ${humanReadableName} by ID`,
351
+ description: `Updates a single ${humanReadableName} record by its unique identifier`,
352
+ operationId: `update${pascalModelName}`,
353
+ parameters: [
354
+ {
355
+ name: "id",
356
+ in: "path",
357
+ description: `Unique identifier of the ${humanReadableName}`,
358
+ required: true,
359
+ schema: {
360
+ type: "string",
361
+ },
362
+ },
363
+ ],
364
+ requestBody: {
365
+ description: `Partial ${humanReadableName} data to update`,
366
+ required: true,
367
+ content: {
368
+ "application/json": {
369
+ schema: {
370
+ $ref: (0, swagger_router_helpers_1.getSchemaRef)(`Update${pascalModelName}`, mode),
371
+ },
372
+ },
373
+ },
374
+ },
375
+ responses: {
376
+ "200": {
377
+ description: `${humanReadableName} updated successfully`,
378
+ content: {
379
+ "application/json": {
380
+ schema: {
381
+ $ref: (0, swagger_router_helpers_1.getSchemaRef)(`${pascalModelName}`, mode),
382
+ },
383
+ },
384
+ },
385
+ },
386
+ "400": {
387
+ description: "Invalid input data provided",
388
+ },
389
+ "401": {
390
+ description: "Authentication required",
391
+ },
392
+ "403": {
393
+ description: "Insufficient permissions",
394
+ },
395
+ "404": {
396
+ description: `${humanReadableName} not found`,
397
+ },
398
+ },
399
+ security: [{ BearerAuth: [] }],
400
+ };
401
+ }
402
+ if (!(0, base_router_helpers_1.isEndpointDisabled)(routerConfig, "deleteOne")) {
403
+ if (!paths[`/api/${routeName}/{id}`])
404
+ paths[`/api/${routeName}/{id}`] = {};
405
+ paths[`/api/${routeName}/{id}`].delete = {
406
+ tags: [humanReadableNamePlural],
407
+ summary: `Delete ${humanReadableName} by ID`,
408
+ description: `Permanently deletes a single ${humanReadableName} record by its unique identifier`,
409
+ operationId: `delete${pascalModelName}`,
410
+ parameters: [
411
+ {
412
+ name: "id",
413
+ in: "path",
414
+ description: `Unique identifier of the ${humanReadableName}`,
415
+ required: true,
416
+ schema: {
417
+ type: "string",
418
+ },
419
+ },
420
+ ],
421
+ responses: {
422
+ "204": {
423
+ description: `${humanReadableName} deleted successfully`,
424
+ },
425
+ "401": {
426
+ description: "Authentication required",
427
+ },
428
+ "403": {
429
+ description: "Insufficient permissions",
430
+ },
431
+ "404": {
432
+ description: `${humanReadableName} not found`,
433
+ },
434
+ },
435
+ security: [{ BearerAuth: [] }],
436
+ };
437
+ }
438
+ }
439
+ //# sourceMappingURL=generate-prisma-model-main-routes.js.map