@carlonicora/nestjs-neo4jsonapi 1.3.0 → 1.4.0

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 (120) hide show
  1. package/dist/foundations/auth/auth.module.d.ts.map +1 -1
  2. package/dist/foundations/auth/auth.module.js +9 -6
  3. package/dist/foundations/auth/auth.module.js.map +1 -1
  4. package/dist/foundations/auth/controllers/auth.discord.controller.d.ts +9 -0
  5. package/dist/foundations/auth/controllers/auth.discord.controller.d.ts.map +1 -0
  6. package/dist/foundations/{discord/controllers/discord.controller.js → auth/controllers/auth.discord.controller.js} +19 -19
  7. package/dist/foundations/auth/controllers/auth.discord.controller.js.map +1 -0
  8. package/dist/foundations/{discord/services/discord.service.d.ts → auth/services/auth.discord.service.d.ts} +7 -7
  9. package/dist/foundations/auth/services/auth.discord.service.d.ts.map +1 -0
  10. package/dist/foundations/{discord/services/discord.service.js → auth/services/auth.discord.service.js} +16 -14
  11. package/dist/foundations/auth/services/auth.discord.service.js.map +1 -0
  12. package/dist/foundations/discord-user/discord.module.d.ts +3 -0
  13. package/dist/foundations/discord-user/discord.module.d.ts.map +1 -0
  14. package/dist/foundations/{discord → discord-user}/discord.module.js +10 -13
  15. package/dist/foundations/discord-user/discord.module.js.map +1 -0
  16. package/dist/foundations/{discord/entities/discord.d.ts → discord-user/entities/discord-user.d.ts} +4 -4
  17. package/dist/foundations/discord-user/entities/discord-user.d.ts.map +1 -0
  18. package/dist/foundations/{discord/entities/discord.js → discord-user/entities/discord-user.js} +7 -7
  19. package/dist/foundations/discord-user/entities/discord-user.js.map +1 -0
  20. package/dist/foundations/{discord/repositories/discord.repository.d.ts → discord-user/repositories/discord-user.repository.d.ts} +5 -5
  21. package/dist/foundations/discord-user/repositories/discord-user.repository.d.ts.map +1 -0
  22. package/dist/foundations/{discord/repositories/discord.repository.js → discord-user/repositories/discord-user.repository.js} +9 -9
  23. package/dist/foundations/discord-user/repositories/discord-user.repository.js.map +1 -0
  24. package/dist/foundations/discord-user/types/discord.user.type.d.ts.map +1 -0
  25. package/dist/foundations/discord-user/types/discord.user.type.js.map +1 -0
  26. package/dist/foundations/foundations.modules.js +2 -2
  27. package/dist/foundations/foundations.modules.js.map +1 -1
  28. package/dist/scripts/generate-module/generator.d.ts +13 -0
  29. package/dist/scripts/generate-module/generator.d.ts.map +1 -0
  30. package/dist/scripts/generate-module/generator.js +193 -0
  31. package/dist/scripts/generate-module/generator.js.map +1 -0
  32. package/dist/scripts/generate-module/index.d.ts +3 -0
  33. package/dist/scripts/generate-module/index.d.ts.map +1 -0
  34. package/dist/scripts/generate-module/index.js +70 -0
  35. package/dist/scripts/generate-module/index.js.map +1 -0
  36. package/dist/scripts/generate-module/templates/controller.template.d.ts +9 -0
  37. package/dist/scripts/generate-module/templates/controller.template.d.ts.map +1 -0
  38. package/dist/scripts/generate-module/templates/controller.template.js +177 -0
  39. package/dist/scripts/generate-module/templates/controller.template.js.map +1 -0
  40. package/dist/scripts/generate-module/templates/dto.base.template.d.ts +9 -0
  41. package/dist/scripts/generate-module/templates/dto.base.template.d.ts.map +1 -0
  42. package/dist/scripts/generate-module/templates/dto.base.template.js +39 -0
  43. package/dist/scripts/generate-module/templates/dto.base.template.js.map +1 -0
  44. package/dist/scripts/generate-module/templates/dto.post.template.d.ts +9 -0
  45. package/dist/scripts/generate-module/templates/dto.post.template.d.ts.map +1 -0
  46. package/dist/scripts/generate-module/templates/dto.post.template.js +106 -0
  47. package/dist/scripts/generate-module/templates/dto.post.template.js.map +1 -0
  48. package/dist/scripts/generate-module/templates/dto.put.template.d.ts +10 -0
  49. package/dist/scripts/generate-module/templates/dto.put.template.d.ts.map +1 -0
  50. package/dist/scripts/generate-module/templates/dto.put.template.js +107 -0
  51. package/dist/scripts/generate-module/templates/dto.put.template.js.map +1 -0
  52. package/dist/scripts/generate-module/templates/entity.template.d.ts +12 -0
  53. package/dist/scripts/generate-module/templates/entity.template.d.ts.map +1 -0
  54. package/dist/scripts/generate-module/templates/entity.template.js +128 -0
  55. package/dist/scripts/generate-module/templates/entity.template.js.map +1 -0
  56. package/dist/scripts/generate-module/templates/module.template.d.ts +9 -0
  57. package/dist/scripts/generate-module/templates/module.template.d.ts.map +1 -0
  58. package/dist/scripts/generate-module/templates/module.template.js +39 -0
  59. package/dist/scripts/generate-module/templates/module.template.js.map +1 -0
  60. package/dist/scripts/generate-module/templates/repository.template.d.ts +9 -0
  61. package/dist/scripts/generate-module/templates/repository.template.d.ts.map +1 -0
  62. package/dist/scripts/generate-module/templates/repository.template.js +38 -0
  63. package/dist/scripts/generate-module/templates/repository.template.js.map +1 -0
  64. package/dist/scripts/generate-module/templates/service.template.d.ts +9 -0
  65. package/dist/scripts/generate-module/templates/service.template.d.ts.map +1 -0
  66. package/dist/scripts/generate-module/templates/service.template.js +43 -0
  67. package/dist/scripts/generate-module/templates/service.template.js.map +1 -0
  68. package/dist/scripts/generate-module/transformers/import-resolver.d.ts +78 -0
  69. package/dist/scripts/generate-module/transformers/import-resolver.d.ts.map +1 -0
  70. package/dist/scripts/generate-module/transformers/import-resolver.js +89 -0
  71. package/dist/scripts/generate-module/transformers/import-resolver.js.map +1 -0
  72. package/dist/scripts/generate-module/transformers/name-transformer.d.ts +39 -0
  73. package/dist/scripts/generate-module/transformers/name-transformer.d.ts.map +1 -0
  74. package/dist/scripts/generate-module/transformers/name-transformer.js +69 -0
  75. package/dist/scripts/generate-module/transformers/name-transformer.js.map +1 -0
  76. package/dist/scripts/generate-module/transformers/nested-route-generator.d.ts +26 -0
  77. package/dist/scripts/generate-module/transformers/nested-route-generator.d.ts.map +1 -0
  78. package/dist/scripts/generate-module/transformers/nested-route-generator.js +55 -0
  79. package/dist/scripts/generate-module/transformers/nested-route-generator.js.map +1 -0
  80. package/dist/scripts/generate-module/transformers/relationship-mapper.d.ts +40 -0
  81. package/dist/scripts/generate-module/transformers/relationship-mapper.d.ts.map +1 -0
  82. package/dist/scripts/generate-module/transformers/relationship-mapper.js +95 -0
  83. package/dist/scripts/generate-module/transformers/relationship-mapper.js.map +1 -0
  84. package/dist/scripts/generate-module/types/json-schema.interface.d.ts +39 -0
  85. package/dist/scripts/generate-module/types/json-schema.interface.d.ts.map +1 -0
  86. package/dist/scripts/generate-module/types/json-schema.interface.js +9 -0
  87. package/dist/scripts/generate-module/types/json-schema.interface.js.map +1 -0
  88. package/dist/scripts/generate-module/types/template-data.interface.d.ts +101 -0
  89. package/dist/scripts/generate-module/types/template-data.interface.d.ts.map +1 -0
  90. package/dist/scripts/generate-module/types/template-data.interface.js +8 -0
  91. package/dist/scripts/generate-module/types/template-data.interface.js.map +1 -0
  92. package/dist/scripts/generate-module/utils/file-writer.d.ts +29 -0
  93. package/dist/scripts/generate-module/utils/file-writer.d.ts.map +1 -0
  94. package/dist/scripts/generate-module/utils/file-writer.js +89 -0
  95. package/dist/scripts/generate-module/utils/file-writer.js.map +1 -0
  96. package/dist/scripts/generate-module/utils/module-registrar.d.ts +12 -0
  97. package/dist/scripts/generate-module/utils/module-registrar.d.ts.map +1 -0
  98. package/dist/scripts/generate-module/utils/module-registrar.js +119 -0
  99. package/dist/scripts/generate-module/utils/module-registrar.js.map +1 -0
  100. package/dist/scripts/generate-module/validators/json-schema-validator.d.ts +27 -0
  101. package/dist/scripts/generate-module/validators/json-schema-validator.d.ts.map +1 -0
  102. package/dist/scripts/generate-module/validators/json-schema-validator.js +156 -0
  103. package/dist/scripts/generate-module/validators/json-schema-validator.js.map +1 -0
  104. package/package.json +17 -16
  105. package/dist/foundations/discord/controllers/discord.controller.d.ts +0 -9
  106. package/dist/foundations/discord/controllers/discord.controller.d.ts.map +0 -1
  107. package/dist/foundations/discord/controllers/discord.controller.js.map +0 -1
  108. package/dist/foundations/discord/discord.module.d.ts +0 -3
  109. package/dist/foundations/discord/discord.module.d.ts.map +0 -1
  110. package/dist/foundations/discord/discord.module.js.map +0 -1
  111. package/dist/foundations/discord/entities/discord.d.ts.map +0 -1
  112. package/dist/foundations/discord/entities/discord.js.map +0 -1
  113. package/dist/foundations/discord/repositories/discord.repository.d.ts.map +0 -1
  114. package/dist/foundations/discord/repositories/discord.repository.js.map +0 -1
  115. package/dist/foundations/discord/services/discord.service.d.ts.map +0 -1
  116. package/dist/foundations/discord/services/discord.service.js.map +0 -1
  117. package/dist/foundations/discord/types/discord.user.type.d.ts.map +0 -1
  118. package/dist/foundations/discord/types/discord.user.type.js.map +0 -1
  119. /package/dist/foundations/{discord → discord-user}/types/discord.user.type.d.ts +0 -0
  120. /package/dist/foundations/{discord → discord-user}/types/discord.user.type.js +0 -0
@@ -0,0 +1,193 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.generateModule = generateModule;
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
39
+ const name_transformer_1 = require("./transformers/name-transformer");
40
+ const relationship_mapper_1 = require("./transformers/relationship-mapper");
41
+ const nested_route_generator_1 = require("./transformers/nested-route-generator");
42
+ const json_schema_validator_1 = require("./validators/json-schema-validator");
43
+ const entity_template_1 = require("./templates/entity.template");
44
+ const module_template_1 = require("./templates/module.template");
45
+ const service_template_1 = require("./templates/service.template");
46
+ const repository_template_1 = require("./templates/repository.template");
47
+ const controller_template_1 = require("./templates/controller.template");
48
+ const dto_base_template_1 = require("./templates/dto.base.template");
49
+ const dto_post_template_1 = require("./templates/dto.post.template");
50
+ const dto_put_template_1 = require("./templates/dto.put.template");
51
+ const file_writer_1 = require("./utils/file-writer");
52
+ const module_registrar_1 = require("./utils/module-registrar");
53
+ /**
54
+ * Main generator function
55
+ *
56
+ * @param options - Generation options
57
+ */
58
+ async function generateModule(options) {
59
+ const { jsonPath, dryRun = false, force = false, noRegister = false } = options;
60
+ // 1. Load and parse JSON
61
+ console.log(`📖 Loading JSON schema from: ${jsonPath}`);
62
+ const jsonContent = fs.readFileSync(jsonPath, "utf-8");
63
+ let jsonSchema = JSON.parse(jsonContent);
64
+ // Handle array format (for bulk import compatibility)
65
+ if (Array.isArray(jsonSchema)) {
66
+ if (jsonSchema.length === 0) {
67
+ throw new Error("JSON array is empty");
68
+ }
69
+ if (jsonSchema.length > 1) {
70
+ console.warn(`⚠️ Warning: JSON file contains ${jsonSchema.length} definitions. Only processing the first one.`);
71
+ }
72
+ jsonSchema = jsonSchema[0];
73
+ }
74
+ // 2. Validate JSON schema
75
+ console.log(`✓ Validating JSON schema...`);
76
+ const validationErrors = (0, json_schema_validator_1.validateJsonSchema)(jsonSchema);
77
+ if (validationErrors.length > 0) {
78
+ console.error("❌ Validation failed:\n");
79
+ console.error((0, json_schema_validator_1.formatValidationErrors)(validationErrors));
80
+ if (!(0, json_schema_validator_1.validationPassed)(validationErrors)) {
81
+ process.exit(1);
82
+ }
83
+ }
84
+ // 3. Transform data
85
+ console.log(`✓ Transforming data...`);
86
+ const names = (0, name_transformer_1.transformNames)(jsonSchema.moduleName, jsonSchema.endpointName);
87
+ const relationships = (0, relationship_mapper_1.mapRelationships)(jsonSchema.relationships);
88
+ const nestedRoutes = (0, nested_route_generator_1.generateNestedRoutes)(relationships, {
89
+ endpoint: jsonSchema.endpointName,
90
+ nodeName: names.camelCase,
91
+ });
92
+ // Map fields to template fields
93
+ const fields = jsonSchema.fields.map((field) => ({
94
+ name: field.name,
95
+ type: field.type,
96
+ required: !field.nullable,
97
+ tsType: field.type, // Simplified: all string types
98
+ }));
99
+ // Build template data
100
+ const templateData = {
101
+ names,
102
+ endpoint: jsonSchema.endpointName,
103
+ labelName: names.pascalCase,
104
+ nodeName: names.camelCase,
105
+ isCompanyScoped: true, // Default: true
106
+ targetDir: jsonSchema.targetDir,
107
+ fields,
108
+ relationships,
109
+ libraryImports: [],
110
+ entityImports: [],
111
+ metaImports: [],
112
+ dtoImports: [],
113
+ nestedRoutes,
114
+ dtoFields: fields.map((field) => ({
115
+ name: field.name,
116
+ type: field.tsType,
117
+ isOptional: !field.required,
118
+ decorators: ["@IsDefined()", "@IsNotEmpty()", "@IsString()"],
119
+ })),
120
+ postDtoRelationships: [],
121
+ putDtoRelationships: [],
122
+ };
123
+ // 4. Generate files
124
+ console.log(`✓ Generating files...`);
125
+ const basePath = `apps/api/src/${jsonSchema.targetDir}/${names.kebabCase}`;
126
+ const filesToWrite = [
127
+ // Entity
128
+ {
129
+ path: path.resolve(process.cwd(), `${basePath}/entities/${names.kebabCase}.ts`),
130
+ content: (0, entity_template_1.generateEntityFile)(templateData),
131
+ },
132
+ // Module
133
+ {
134
+ path: path.resolve(process.cwd(), `${basePath}/${names.kebabCase}.module.ts`),
135
+ content: (0, module_template_1.generateModuleFile)(templateData),
136
+ },
137
+ // Service
138
+ {
139
+ path: path.resolve(process.cwd(), `${basePath}/services/${names.kebabCase}.service.ts`),
140
+ content: (0, service_template_1.generateServiceFile)(templateData),
141
+ },
142
+ // Repository
143
+ {
144
+ path: path.resolve(process.cwd(), `${basePath}/repositories/${names.kebabCase}.repository.ts`),
145
+ content: (0, repository_template_1.generateRepositoryFile)(templateData),
146
+ },
147
+ // Controller
148
+ {
149
+ path: path.resolve(process.cwd(), `${basePath}/controllers/${names.kebabCase}.controller.ts`),
150
+ content: (0, controller_template_1.generateControllerFile)(templateData),
151
+ },
152
+ // DTOs
153
+ {
154
+ path: path.resolve(process.cwd(), `${basePath}/dtos/${names.kebabCase}.dto.ts`),
155
+ content: (0, dto_base_template_1.generateBaseDTOFile)(templateData),
156
+ },
157
+ {
158
+ path: path.resolve(process.cwd(), `${basePath}/dtos/${names.kebabCase}.post.dto.ts`),
159
+ content: (0, dto_post_template_1.generatePostDTOFile)(templateData),
160
+ },
161
+ {
162
+ path: path.resolve(process.cwd(), `${basePath}/dtos/${names.kebabCase}.put.dto.ts`),
163
+ content: (0, dto_put_template_1.generatePutDTOFile)(templateData),
164
+ },
165
+ ];
166
+ // 5. Write files
167
+ console.log(`\n📝 Writing ${filesToWrite.length} files...\n`);
168
+ (0, file_writer_1.writeFiles)(filesToWrite, { dryRun, force });
169
+ // 6. Register module
170
+ if (!noRegister && !dryRun) {
171
+ console.log(`\n📦 Registering module...`);
172
+ try {
173
+ (0, module_registrar_1.registerModule)({
174
+ moduleName: names.pascalCase,
175
+ targetDir: jsonSchema.targetDir,
176
+ kebabName: names.kebabCase,
177
+ dryRun,
178
+ });
179
+ }
180
+ catch (error) {
181
+ console.error(`⚠️ Warning: Could not register module: ${error.message}`);
182
+ }
183
+ }
184
+ // 7. Summary
185
+ console.log(`\n✅ Module generation complete!`);
186
+ console.log(`\n📂 Generated files in: apps/api/src/${jsonSchema.targetDir}/${names.kebabCase}/`);
187
+ console.log(`\n📋 Next steps:`);
188
+ console.log(` 1. Review generated code`);
189
+ console.log(` 2. Run: pnpm lint:api --fix`);
190
+ console.log(` 3. Run: pnpm build:api`);
191
+ console.log(` 4. Test your new module!`);
192
+ }
193
+ //# sourceMappingURL=generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../scripts/generate-module/generator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,wCAkJC;AAjLD,uCAAyB;AACzB,2CAA6B;AAG7B,sEAAiE;AACjE,4EAAsE;AACtE,kFAA6E;AAC7E,8EAAkH;AAClH,iEAAiE;AACjE,iEAAiE;AACjE,mEAAmE;AACnE,yEAAyE;AACzE,yEAAyE;AACzE,qEAAoE;AACpE,qEAAoE;AACpE,mEAAkE;AAClE,qDAA8D;AAC9D,+DAA0D;AAS1D;;;;GAIG;AACI,KAAK,UAAU,cAAc,CAAC,OAA8B;IACjE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,KAAK,EAAE,KAAK,GAAG,KAAK,EAAE,UAAU,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;IAEhF,yBAAyB;IACzB,OAAO,CAAC,GAAG,CAAC,gCAAgC,QAAQ,EAAE,CAAC,CAAC;IACxD,MAAM,WAAW,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACvD,IAAI,UAAU,GAAyB,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAE/D,sDAAsD;IACtD,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;QACzC,CAAC;QACD,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1B,OAAO,CAAC,IAAI,CAAC,mCAAmC,UAAU,CAAC,MAAM,8CAA8C,CAAC,CAAC;QACnH,CAAC;QACD,UAAU,GAAG,UAAU,C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CAAC,CAAC;IAC9D,IAAA,wBAAU,EAAC,YAAY,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;IAE5C,qBAAqB;IACrB,IAAI,CAAC,UAAU,IAAI,CAAC,MAAM,EAAE,CAAC;QAC3B,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;QAC1C,IAAI,CAAC;YACH,IAAA,iCAAc,EAAC;gBACb,UAAU,EAAE,KAAK,CAAC,UAAU;gBAC5B,SAAS,EAAE,UAAU,CAAC,SAAS;gBAC/B,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,MAAM;aACP,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,CAAC,KAAK,CAAC,2CAA2C,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC5E,CAAC;IACH,CAAC;IAED,aAAa;IACb,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;IAC/C,OAAO,CAAC,GAAG,CAAC,yCAAyC,UAAU,CAAC,SAAS,IAAI,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC;IACjG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAChC,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;IAC3C,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;IAC9C,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;IACzC,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../scripts/generate-module/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ const commander_1 = require("commander");
38
+ const generator_1 = require("./generator");
39
+ const path = __importStar(require("path"));
40
+ const program = new commander_1.Command();
41
+ program
42
+ .name("generate-module")
43
+ .description("Generate a NestJS module from a JSON schema definition")
44
+ .version("1.0.0")
45
+ .argument("<json-file>", "Path to JSON schema file")
46
+ .option("--dry-run", "Preview files without writing them", false)
47
+ .option("--force", "Overwrite existing files", false)
48
+ .option("--no-register", "Skip module registration in parent module", false)
49
+ .action(async (jsonFile, options) => {
50
+ try {
51
+ const jsonPath = path.resolve(process.cwd(), jsonFile);
52
+ console.log(`\n🚀 NestJS Module Generator\n`);
53
+ console.log(` JSON File: ${jsonPath}`);
54
+ console.log(` Dry Run: ${options.dryRun ? "Yes" : "No"}`);
55
+ console.log(` Force: ${options.force ? "Yes" : "No"}`);
56
+ console.log(` Register: ${options.register ? "Yes" : "No"}\n`);
57
+ await (0, generator_1.generateModule)({
58
+ jsonPath,
59
+ dryRun: options.dryRun,
60
+ force: options.force,
61
+ noRegister: !options.register,
62
+ });
63
+ }
64
+ catch (error) {
65
+ console.error(`\n❌ Error: ${error.message}\n`);
66
+ process.exit(1);
67
+ }
68
+ });
69
+ program.parse(process.argv);
70
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../scripts/generate-module/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,yCAAoC;AACpC,2CAA6C;AAC7C,2CAA6B;AAE7B,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,iBAAiB,CAAC;KACvB,WAAW,CAAC,wDAAwD,CAAC;KACrE,OAAO,CAAC,OAAO,CAAC;KAChB,QAAQ,CAAC,aAAa,EAAE,0BAA0B,CAAC;KACnD,MAAM,CAAC,WAAW,EAAE,oCAAoC,EAAE,KAAK,CAAC;KAChE,MAAM,CAAC,SAAS,EAAE,0BAA0B,EAAE,KAAK,CAAC;KACpD,MAAM,CAAC,eAAe,EAAE,2CAA2C,EAAE,KAAK,CAAC;KAC3E,MAAM,CAAC,KAAK,EAAE,QAAgB,EAAE,OAAO,EAAE,EAAE;IAC1C,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAC,CAAC;QAEvD,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;QAC9C,OAAO,CAAC,GAAG,CAAC,iBAAiB,QAAQ,EAAE,CAAC,CAAC;QACzC,OAAO,CAAC,GAAG,CAAC,eAAe,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QAC5D,OAAO,CAAC,GAAG,CAAC,aAAa,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QACzD,OAAO,CAAC,GAAG,CAAC,gBAAgB,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC;QAEjE,MAAM,IAAA,0BAAc,EAAC;YACnB,QAAQ;YACR,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,UAAU,EAAE,CAAC,OAAO,CAAC,QAAQ;SAC9B,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,CAAC,KAAK,CAAC,cAAc,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;QAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { TemplateData } from "../types/template-data.interface";
2
+ /**
3
+ * Generate controller file content with CRUD and nested routes
4
+ *
5
+ * @param data - Template data
6
+ * @returns Generated TypeScript code
7
+ */
8
+ export declare function generateControllerFile(data: TemplateData): string;
9
+ //# sourceMappingURL=controller.template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controller.template.d.ts","sourceRoot":"","sources":["../../../../scripts/generate-module/templates/controller.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAEhE;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CA6KjE"}
@@ -0,0 +1,177 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateControllerFile = generateControllerFile;
4
+ /**
5
+ * Generate controller file content with CRUD and nested routes
6
+ *
7
+ * @param data - Template data
8
+ * @returns Generated TypeScript code
9
+ */
10
+ function generateControllerFile(data) {
11
+ const { names, targetDir, nestedRoutes } = data;
12
+ // Build meta imports for nested routes
13
+ const metaImportPaths = new Map();
14
+ for (const route of nestedRoutes) {
15
+ const rel = data.relationships.find((r) => r.model === route.relatedMeta);
16
+ const path = `../../${rel.relatedEntity.directory}/${rel.relatedEntity.kebabCase}/entities/${rel.relatedEntity.kebabCase}.meta`;
17
+ if (!metaImportPaths.has(path)) {
18
+ metaImportPaths.set(path, []);
19
+ }
20
+ metaImportPaths.get(path).push(route.relatedMeta);
21
+ }
22
+ const metaImportsCode = metaImportPaths.size > 0
23
+ ? `\n${Array.from(metaImportPaths.entries())
24
+ .map(([path, items]) => `import { ${items.join(", ")} } from "${path}";`)
25
+ .join("\n")}\n`
26
+ : "";
27
+ // Generate nested route methods
28
+ const nestedRouteMethods = nestedRoutes
29
+ .map((route) => `
30
+ @Get(\`\${${route.relatedMeta}.endpoint}/:\${${route.paramName}}/\${${names.pascalCase}Descriptor.model.endpoint}\`)
31
+ async ${route.methodName}(
32
+ @Req() req: AuthenticatedRequest,
33
+ @Res() reply: FastifyReply,
34
+ @Param("${route.paramName}") ${route.paramName}: string,
35
+ @Query() query: any,
36
+ @Query("search") search?: string,
37
+ @Query("fetchAll") fetchAll?: boolean,
38
+ @Query("orderBy") orderBy?: string,
39
+ ) {
40
+ const response = await this.${names.camelCase}Service.findByRelated({
41
+ relationship: ${names.pascalCase}Descriptor.relationshipKeys.${route.relationshipKey},
42
+ id: ${route.paramName},
43
+ term: search,
44
+ query: query,
45
+ fetchAll: fetchAll,
46
+ orderBy: orderBy,
47
+ });
48
+
49
+ reply.send(response);
50
+ }`)
51
+ .join("\n");
52
+ return `import {
53
+ Body,
54
+ Controller,
55
+ Delete,
56
+ Get,
57
+ HttpCode,
58
+ HttpStatus,
59
+ Param,
60
+ Post,
61
+ PreconditionFailedException,
62
+ Put,
63
+ Query,
64
+ Req,
65
+ Res,
66
+ UseGuards,
67
+ } from "@nestjs/common";
68
+ import { FastifyReply } from "fastify";
69
+ import {
70
+ AuditService,
71
+ AuthenticatedRequest,
72
+ CacheService,
73
+ JsonApiDTOData,
74
+ JwtAuthGuard,
75
+ } from "@carlonicora/nestjs-neo4jsonapi";${metaImportsCode}
76
+ import { ${names.pascalCase}PostDTO } from "src/${targetDir}/${names.kebabCase}/dtos/${names.kebabCase}.post.dto";
77
+ import { ${names.pascalCase}PutDTO } from "src/${targetDir}/${names.kebabCase}/dtos/${names.kebabCase}.put.dto";
78
+ import { ${names.pascalCase}Descriptor } from "src/${targetDir}/${names.kebabCase}/entities/${names.kebabCase}";
79
+ import { ${names.pascalCase}Service } from "src/${targetDir}/${names.kebabCase}/services/${names.kebabCase}.service";
80
+
81
+ @UseGuards(JwtAuthGuard)
82
+ @Controller()
83
+ export class ${names.pascalCase}Controller {
84
+ constructor(
85
+ private readonly ${names.camelCase}Service: ${names.pascalCase}Service,
86
+ private readonly cacheService: CacheService,
87
+ private readonly auditService: AuditService,
88
+ ) {}
89
+
90
+ @Get(${names.pascalCase}Descriptor.model.endpoint)
91
+ async findAll(
92
+ @Req() req: AuthenticatedRequest,
93
+ @Res() reply: FastifyReply,
94
+ @Query() query: any,
95
+ @Query("search") search?: string,
96
+ @Query("fetchAll") fetchAll?: boolean,
97
+ @Query("orderBy") orderBy?: string,
98
+ ) {
99
+ const response = await this.${names.camelCase}Service.find({
100
+ term: search,
101
+ query: query,
102
+ fetchAll: fetchAll,
103
+ orderBy: orderBy,
104
+ });
105
+
106
+ reply.send(response);
107
+ }
108
+
109
+ @Get(\`\${${names.pascalCase}Descriptor.model.endpoint}/:${names.camelCase}Id\`)
110
+ async findById(
111
+ @Req() req: AuthenticatedRequest,
112
+ @Res() reply: FastifyReply,
113
+ @Param("${names.camelCase}Id") ${names.camelCase}Id: string,
114
+ ) {
115
+ const response = await this.${names.camelCase}Service.findById({
116
+ id: ${names.camelCase}Id,
117
+ });
118
+
119
+ reply.send(response);
120
+
121
+ this.auditService.createAuditEntry({
122
+ entityType: ${names.pascalCase}Descriptor.model.labelName,
123
+ entityId: ${names.camelCase}Id,
124
+ });
125
+ }
126
+
127
+ @Post(${names.pascalCase}Descriptor.model.endpoint)
128
+ async create(
129
+ @Req() req: AuthenticatedRequest,
130
+ @Res() reply: FastifyReply,
131
+ @Body() body: ${names.pascalCase}PostDTO,
132
+ ) {
133
+ const response = await this.${names.camelCase}Service.createFromDTO({
134
+ data: body.data as unknown as JsonApiDTOData,
135
+ });
136
+
137
+ reply.send(response);
138
+
139
+ await this.cacheService.invalidateByType(${names.pascalCase}Descriptor.model.endpoint);
140
+ }
141
+
142
+ @Put(\`\${${names.pascalCase}Descriptor.model.endpoint}/:${names.camelCase}Id\`)
143
+ async update(
144
+ @Req() req: AuthenticatedRequest,
145
+ @Res() reply: FastifyReply,
146
+ @Param("${names.camelCase}Id") ${names.camelCase}Id: string,
147
+ @Body() body: ${names.pascalCase}PutDTO,
148
+ ) {
149
+ if (${names.camelCase}Id !== body.data.id)
150
+ throw new PreconditionFailedException("ID in URL does not match ID in body");
151
+
152
+ const response = await this.${names.camelCase}Service.putFromDTO({
153
+ data: body.data as unknown as JsonApiDTOData,
154
+ });
155
+
156
+ reply.send(response);
157
+
158
+ await this.cacheService.invalidateByElement(${names.pascalCase}Descriptor.model.endpoint, body.data.id);
159
+ }
160
+
161
+ @Delete(\`\${${names.pascalCase}Descriptor.model.endpoint}/:${names.camelCase}Id\`)
162
+ @HttpCode(HttpStatus.NO_CONTENT)
163
+ async delete(
164
+ @Req() req: AuthenticatedRequest,
165
+ @Res() reply: FastifyReply,
166
+ @Param("${names.camelCase}Id") ${names.camelCase}Id: string,
167
+ ) {
168
+ await this.${names.camelCase}Service.delete({ id: ${names.camelCase}Id });
169
+ reply.send();
170
+
171
+ await this.cacheService.invalidateByElement(${names.pascalCase}Descriptor.model.endpoint, ${names.camelCase}Id);
172
+ }
173
+ ${nestedRouteMethods}
174
+ }
175
+ `;
176
+ }
177
+ //# sourceMappingURL=controller.template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controller.template.js","sourceRoot":"","sources":["../../../../scripts/generate-module/templates/controller.template.ts"],"names":[],"mappings":";;AAQA,wDA6KC;AAnLD;;;;;GAKG;AACH,SAAgB,sBAAsB,CAAC,IAAkB;IACvD,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;IAEhD,uCAAuC;IACvC,MAAM,eAAe,GAAG,IAAI,GAAG,EAAoB,CAAC;IACpD,KAAK,MAAM,KAAK,IAAI,YAAY,EAAE,CAAC;QACjC,MAAM,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,WAAW,CAAE,CAAC;QAC3E,MAAM,IAAI,GAAG,SAAS,GAAG,CAAC,aAAa,CAAC,SAAS,IAAI,GAAG,CAAC,aAAa,CAAC,SAAS,aAAa,GAAG,CAAC,aAAa,CAAC,SAAS,OAAO,CAAC;QAChI,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC/B,eAAe,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAChC,CAAC;QACD,eAAe,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IACrD,CAAC;IAED,MAAM,eAAe,GACnB,eAAe,CAAC,IAAI,GAAG,CAAC;QACtB,CAAC,CAAC,KAAK,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;aACvC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,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SAAS;YACrC,KAAK,CAAC,SAAS;;;;;;oBAMP,KAAK,CAAC,UAAU;kBAClB,KAAK,CAAC,SAAS;;;;UAIvB,KAAK,CAAC,UAAU;;;;oBAIN,KAAK,CAAC,UAAU;;kCAEF,KAAK,CAAC,SAAS;;;;;;+CAMF,KAAK,CAAC,UAAU;;;cAGjD,KAAK,CAAC,UAAU,+BAA+B,KAAK,CAAC,SAAS;;;;cAI9D,KAAK,CAAC,SAAS,QAAQ,KAAK,CAAC,SAAS;oBAChC,KAAK,CAAC,UAAU;;UAE1B,KAAK,CAAC,SAAS;;;kCAGS,KAAK,CAAC,SAAS;;;;;;kDAMC,KAAK,CAAC,UAAU;;;iBAGjD,KAAK,CAAC,UAAU,+BAA+B,KAAK,CAAC,SAAS;;;;;cAKjE,KAAK,CAAC,SAAS,QAAQ,KAAK,CAAC,SAAS;;iBAEnC,KAAK,CAAC,SAAS,wBAAwB,KAAK,CAAC,SAAS;;;kDAGrB,KAAK,CAAC,UAAU,8BAA8B,KAAK,CAAC,SAAS;;EAE7G,kBAAkB;;CAEnB,CAAC;AACF,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { TemplateData } from "../types/template-data.interface";
2
+ /**
3
+ * Generate base DTO file content
4
+ *
5
+ * @param data - Template data
6
+ * @returns Generated TypeScript code
7
+ */
8
+ export declare function generateBaseDTOFile(data: TemplateData): string;
9
+ //# sourceMappingURL=dto.base.template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dto.base.template.d.ts","sourceRoot":"","sources":["../../../../scripts/generate-module/templates/dto.base.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAEhE;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CA6B9D"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateBaseDTOFile = generateBaseDTOFile;
4
+ /**
5
+ * Generate base DTO file content
6
+ *
7
+ * @param data - Template data
8
+ * @returns Generated TypeScript code
9
+ */
10
+ function generateBaseDTOFile(data) {
11
+ const { names, targetDir } = data;
12
+ return `import { Type } from "class-transformer";
13
+ import { Equals, IsNotEmpty, IsUUID, ValidateNested } from "class-validator";
14
+ import { ${names.pascalCase}Descriptor } from "src/${targetDir}/${names.kebabCase}/entities/${names.kebabCase}";
15
+
16
+ export class ${names.pascalCase}DTO {
17
+ @Equals(${names.pascalCase}Descriptor.model.endpoint)
18
+ type: string;
19
+
20
+ @IsUUID()
21
+ id: string;
22
+ }
23
+
24
+ export class ${names.pascalCase}DataDTO {
25
+ @ValidateNested()
26
+ @IsNotEmpty()
27
+ @Type(() => ${names.pascalCase}DTO)
28
+ data: ${names.pascalCase}DTO;
29
+ }
30
+
31
+ export class ${names.pascalCase}DataListDTO {
32
+ @ValidateNested({ each: true })
33
+ @IsNotEmpty()
34
+ @Type(() => ${names.pascalCase}DTO)
35
+ data: ${names.pascalCase}DTO[];
36
+ }
37
+ `;
38
+ }
39
+ //# sourceMappingURL=dto.base.template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dto.base.template.js","sourceRoot":"","sources":["../../../../scripts/generate-module/templates/dto.base.template.ts"],"names":[],"mappings":";;AAQA,kDA6BC;AAnCD;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,IAAkB;IACpD,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IAElC,OAAO;;WAEE,KAAK,CAAC,UAAU,0BAA0B,SAAS,IAAI,KAAK,CAAC,SAAS,aAAa,KAAK,CAAC,SAAS;;eAE9F,KAAK,CAAC,UAAU;YACnB,KAAK,CAAC,UAAU;;;;;;;eAOb,KAAK,CAAC,UAAU;;;gBAGf,KAAK,CAAC,UAAU;UACtB,KAAK,CAAC,UAAU;;;eAGX,KAAK,CAAC,UAAU;;;gBAGf,KAAK,CAAC,UAAU;UACtB,KAAK,CAAC,UAAU;;CAEzB,CAAC;AACF,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { TemplateData } from "../types/template-data.interface";
2
+ /**
3
+ * Generate POST DTO file content
4
+ *
5
+ * @param data - Template data
6
+ * @returns Generated TypeScript code
7
+ */
8
+ export declare function generatePostDTOFile(data: TemplateData): string;
9
+ //# sourceMappingURL=dto.post.template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dto.post.template.d.ts","sourceRoot":"","sources":["../../../../scripts/generate-module/templates/dto.post.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA0B,MAAM,kCAAkC,CAAC;AAExF;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CA4G9D"}
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generatePostDTOFile = generatePostDTOFile;
4
+ /**
5
+ * Generate POST DTO file content
6
+ *
7
+ * @param data - Template data
8
+ * @returns Generated TypeScript code
9
+ */
10
+ function generatePostDTOFile(data) {
11
+ const { names, targetDir, fields, relationships } = data;
12
+ // Build DTO imports for relationships (excluding contextKey)
13
+ const dtoImportPaths = new Map();
14
+ for (const rel of relationships) {
15
+ // Skip contextKey relationships (like Author)
16
+ if (rel.contextKey)
17
+ continue;
18
+ const importPath = `../../${rel.relatedEntity.directory}/${rel.relatedEntity.kebabCase}/dtos/${rel.relatedEntity.kebabCase}.dto`;
19
+ if (!dtoImportPaths.has(importPath)) {
20
+ dtoImportPaths.set(importPath, new Set());
21
+ }
22
+ // Add both singular and list DTOs
23
+ dtoImportPaths.get(importPath).add(`${rel.relatedEntity.name}DataDTO`);
24
+ if (rel.cardinality === "many") {
25
+ dtoImportPaths.get(importPath).add(`${rel.relatedEntity.name}DataListDTO`);
26
+ }
27
+ }
28
+ const dtoImportsCode = dtoImportPaths.size > 0
29
+ ? `\n${Array.from(dtoImportPaths.entries())
30
+ .map(([path, items]) => `import { ${Array.from(items).join(", ")} } from "${path}";`)
31
+ .join("\n")}\n`
32
+ : "";
33
+ // Build attribute validation
34
+ const attributeFields = fields
35
+ .map((field) => {
36
+ const decorators = [];
37
+ decorators.push("@IsDefined()");
38
+ decorators.push("@IsNotEmpty()");
39
+ decorators.push(`@IsString()`); // Simplified - all fields are strings in current schema
40
+ const optional = !field.required ? "?" : "";
41
+ return ` ${decorators.join("\n ")}\n ${field.name}${optional}: ${field.tsType};`;
42
+ })
43
+ .join("\n\n");
44
+ // Build relationship validation (exclude contextKey)
45
+ const relationshipFields = relationships
46
+ .filter((rel) => !rel.contextKey) // Exclude Author and other contextKey relationships
47
+ .map((rel) => {
48
+ const decorators = [];
49
+ const dtoClass = rel.cardinality === "many" ? `${rel.relatedEntity.name}DataListDTO` : `${rel.relatedEntity.name}DataDTO`;
50
+ if (rel.cardinality === "many") {
51
+ decorators.push("@ValidateNested({ each: true })");
52
+ }
53
+ else {
54
+ decorators.push("@ValidateNested()");
55
+ }
56
+ if (rel.nullable) {
57
+ decorators.push("@IsOptional()");
58
+ }
59
+ else {
60
+ decorators.push("@IsDefined()");
61
+ }
62
+ decorators.push(`@Type(() => ${dtoClass})`);
63
+ const optional = rel.nullable ? "?" : "";
64
+ const dtoKey = rel.dtoKey || rel.key;
65
+ return ` ${decorators.join("\n ")}\n ${dtoKey}${optional}: ${dtoClass};`;
66
+ })
67
+ .join("\n\n");
68
+ return `import { Type } from "class-transformer";
69
+ import { Equals, IsDefined, IsNotEmpty, IsOptional, IsString, IsUUID, ValidateNested } from "class-validator";${dtoImportsCode}
70
+ import { ${names.pascalCase}Descriptor } from "src/${targetDir}/${names.kebabCase}/entities/${names.kebabCase}";
71
+
72
+ export class ${names.pascalCase}PostAttributesDTO {
73
+ ${attributeFields}
74
+ }
75
+
76
+ export class ${names.pascalCase}PostRelationshipsDTO {
77
+ ${relationshipFields || " // No relationships (excluding contextKey relationships)"}
78
+ }
79
+
80
+ export class ${names.pascalCase}PostDataDTO {
81
+ @Equals(${names.pascalCase}Descriptor.model.endpoint)
82
+ type: string;
83
+
84
+ @IsUUID()
85
+ id: string;
86
+
87
+ @ValidateNested()
88
+ @IsNotEmpty()
89
+ @Type(() => ${names.pascalCase}PostAttributesDTO)
90
+ attributes: ${names.pascalCase}PostAttributesDTO;
91
+
92
+ @ValidateNested()
93
+ @IsNotEmpty()
94
+ @Type(() => ${names.pascalCase}PostRelationshipsDTO)
95
+ relationships: ${names.pascalCase}PostRelationshipsDTO;
96
+ }
97
+
98
+ export class ${names.pascalCase}PostDTO {
99
+ @ValidateNested()
100
+ @IsNotEmpty()
101
+ @Type(() => ${names.pascalCase}PostDataDTO)
102
+ data: ${names.pascalCase}PostDataDTO;
103
+ }
104
+ `;
105
+ }
106
+ //# sourceMappingURL=dto.post.template.js.map