nestjs-ddd-cli 2.2.1 → 3.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +247 -408
- package/ddd.schema.json +111 -0
- package/dist/commands/aggregate-validator.d.ts +9 -0
- package/dist/commands/aggregate-validator.js +953 -0
- package/dist/commands/aggregate-validator.js.map +1 -0
- package/dist/commands/ai-assist.d.ts +8 -0
- package/dist/commands/ai-assist.js +337 -0
- package/dist/commands/ai-assist.js.map +1 -0
- package/dist/commands/api-contracts.d.ts +9 -0
- package/dist/commands/api-contracts.js +1368 -0
- package/dist/commands/api-contracts.js.map +1 -0
- package/dist/commands/api-docs.d.ts +8 -0
- package/dist/commands/api-docs.js +408 -0
- package/dist/commands/api-docs.js.map +1 -0
- package/dist/commands/api-versioning.d.ts +11 -0
- package/dist/commands/api-versioning.js +643 -0
- package/dist/commands/api-versioning.js.map +1 -0
- package/dist/commands/audit-logging.d.ts +9 -0
- package/dist/commands/audit-logging.js +1129 -0
- package/dist/commands/audit-logging.js.map +1 -0
- package/dist/commands/batch-generate.d.ts +10 -0
- package/dist/commands/batch-generate.js +405 -0
- package/dist/commands/batch-generate.js.map +1 -0
- package/dist/commands/caching-strategies.d.ts +9 -0
- package/dist/commands/caching-strategies.js +874 -0
- package/dist/commands/caching-strategies.js.map +1 -0
- package/dist/commands/code-analyzer.d.ts +42 -0
- package/dist/commands/code-analyzer.js +474 -0
- package/dist/commands/code-analyzer.js.map +1 -0
- package/dist/commands/database-seeding.d.ts +6 -0
- package/dist/commands/database-seeding.js +621 -0
- package/dist/commands/database-seeding.js.map +1 -0
- package/dist/commands/db-optimization.d.ts +7 -0
- package/dist/commands/db-optimization.js +687 -0
- package/dist/commands/db-optimization.js.map +1 -0
- package/dist/commands/dependency-graph.d.ts +6 -0
- package/dist/commands/dependency-graph.js +329 -0
- package/dist/commands/dependency-graph.js.map +1 -0
- package/dist/commands/doctor-enhanced.d.ts +22 -0
- package/dist/commands/doctor-enhanced.js +543 -0
- package/dist/commands/doctor-enhanced.js.map +1 -0
- package/dist/commands/doctor.d.ts +4 -0
- package/dist/commands/doctor.js +151 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/env-manager.d.ts +6 -0
- package/dist/commands/env-manager.js +419 -0
- package/dist/commands/env-manager.js.map +1 -0
- package/dist/commands/event-sourcing-full.d.ts +10 -0
- package/dist/commands/event-sourcing-full.js +1107 -0
- package/dist/commands/event-sourcing-full.js.map +1 -0
- package/dist/commands/feature-flags.d.ts +9 -0
- package/dist/commands/feature-flags.js +824 -0
- package/dist/commands/feature-flags.js.map +1 -0
- package/dist/commands/filter-dsl.d.ts +10 -0
- package/dist/commands/filter-dsl.js +1407 -0
- package/dist/commands/filter-dsl.js.map +1 -0
- package/dist/commands/generate-all.js +525 -36
- package/dist/commands/generate-all.js.map +1 -1
- package/dist/commands/generate-deployment.d.ts +8 -0
- package/dist/commands/generate-deployment.js +746 -0
- package/dist/commands/generate-deployment.js.map +1 -0
- package/dist/commands/generate-domain-service.d.ts +14 -0
- package/dist/commands/generate-domain-service.js +796 -0
- package/dist/commands/generate-domain-service.js.map +1 -0
- package/dist/commands/generate-entity.js +87 -25
- package/dist/commands/generate-entity.js.map +1 -1
- package/dist/commands/generate-from-schema.d.ts +56 -0
- package/dist/commands/generate-from-schema.js +222 -0
- package/dist/commands/generate-from-schema.js.map +1 -0
- package/dist/commands/generate-module.js +37 -29
- package/dist/commands/generate-module.js.map +1 -1
- package/dist/commands/generate-orchestrator.d.ts +14 -0
- package/dist/commands/generate-orchestrator.js +887 -0
- package/dist/commands/generate-orchestrator.js.map +1 -0
- package/dist/commands/generate-repository.d.ts +14 -0
- package/dist/commands/generate-repository.js +1019 -0
- package/dist/commands/generate-repository.js.map +1 -0
- package/dist/commands/generate-shared.d.ts +4 -0
- package/dist/commands/generate-shared.js +388 -0
- package/dist/commands/generate-shared.js.map +1 -0
- package/dist/commands/generate-value-object.d.ts +32 -0
- package/dist/commands/generate-value-object.js +700 -0
- package/dist/commands/generate-value-object.js.map +1 -0
- package/dist/commands/graphql-subscriptions.d.ts +6 -0
- package/dist/commands/graphql-subscriptions.js +607 -0
- package/dist/commands/graphql-subscriptions.js.map +1 -0
- package/dist/commands/graphql-types.d.ts +5 -0
- package/dist/commands/graphql-types.js +423 -0
- package/dist/commands/graphql-types.js.map +1 -0
- package/dist/commands/health-probes-advanced.d.ts +6 -0
- package/dist/commands/health-probes-advanced.js +655 -0
- package/dist/commands/health-probes-advanced.js.map +1 -0
- package/dist/commands/i18n-setup.d.ts +10 -0
- package/dist/commands/i18n-setup.js +677 -0
- package/dist/commands/i18n-setup.js.map +1 -0
- package/dist/commands/init-config.d.ts +6 -0
- package/dist/commands/init-config.js +370 -0
- package/dist/commands/init-config.js.map +1 -0
- package/dist/commands/init-project.js +56 -6
- package/dist/commands/init-project.js.map +1 -1
- package/dist/commands/interactive-scaffold.d.ts +5 -0
- package/dist/commands/interactive-scaffold.js +271 -0
- package/dist/commands/interactive-scaffold.js.map +1 -0
- package/dist/commands/metrics-prometheus.d.ts +6 -0
- package/dist/commands/metrics-prometheus.js +681 -0
- package/dist/commands/metrics-prometheus.js.map +1 -0
- package/dist/commands/migration-engine.d.ts +6 -0
- package/dist/commands/migration-engine.js +446 -0
- package/dist/commands/migration-engine.js.map +1 -0
- package/dist/commands/migration.d.ts +12 -0
- package/dist/commands/migration.js +484 -0
- package/dist/commands/migration.js.map +1 -0
- package/dist/commands/monorepo.d.ts +8 -0
- package/dist/commands/monorepo.js +483 -0
- package/dist/commands/monorepo.js.map +1 -0
- package/dist/commands/multi-database.d.ts +5 -0
- package/dist/commands/multi-database.js +439 -0
- package/dist/commands/multi-database.js.map +1 -0
- package/dist/commands/observability-tracing.d.ts +10 -0
- package/dist/commands/observability-tracing.js +740 -0
- package/dist/commands/observability-tracing.js.map +1 -0
- package/dist/commands/openapi-export.d.ts +8 -0
- package/dist/commands/openapi-export.js +359 -0
- package/dist/commands/openapi-export.js.map +1 -0
- package/dist/commands/perf-analyzer.d.ts +8 -0
- package/dist/commands/perf-analyzer.js +423 -0
- package/dist/commands/perf-analyzer.js.map +1 -0
- package/dist/commands/rate-limiting.d.ts +10 -0
- package/dist/commands/rate-limiting.js +953 -0
- package/dist/commands/rate-limiting.js.map +1 -0
- package/dist/commands/recipe-plugin.d.ts +56 -0
- package/dist/commands/recipe-plugin.js +315 -0
- package/dist/commands/recipe-plugin.js.map +1 -0
- package/dist/commands/recipe.d.ts +6 -0
- package/dist/commands/recipe.js +3988 -0
- package/dist/commands/recipe.js.map +1 -0
- package/dist/commands/recipes/elasticsearch.recipe.d.ts +1 -0
- package/dist/commands/recipes/elasticsearch.recipe.js +761 -0
- package/dist/commands/recipes/elasticsearch.recipe.js.map +1 -0
- package/dist/commands/recipes/event-sourcing.recipe.d.ts +1 -0
- package/dist/commands/recipes/event-sourcing.recipe.js +889 -0
- package/dist/commands/recipes/event-sourcing.recipe.js.map +1 -0
- package/dist/commands/recipes/index.d.ts +8 -0
- package/dist/commands/recipes/index.js +25 -0
- package/dist/commands/recipes/index.js.map +1 -0
- package/dist/commands/recipes/joi-env.recipe.d.ts +1 -0
- package/dist/commands/recipes/joi-env.recipe.js +301 -0
- package/dist/commands/recipes/joi-env.recipe.js.map +1 -0
- package/dist/commands/recipes/message-queue.recipe.d.ts +1 -0
- package/dist/commands/recipes/message-queue.recipe.js +706 -0
- package/dist/commands/recipes/message-queue.recipe.js.map +1 -0
- package/dist/commands/recipes/middleware.recipe.d.ts +1 -0
- package/dist/commands/recipes/middleware.recipe.js +383 -0
- package/dist/commands/recipes/middleware.recipe.js.map +1 -0
- package/dist/commands/recipes/multi-tenancy.recipe.d.ts +1 -0
- package/dist/commands/recipes/multi-tenancy.recipe.js +520 -0
- package/dist/commands/recipes/multi-tenancy.recipe.js.map +1 -0
- package/dist/commands/recipes/oauth2.recipe.d.ts +1 -0
- package/dist/commands/recipes/oauth2.recipe.js +472 -0
- package/dist/commands/recipes/oauth2.recipe.js.map +1 -0
- package/dist/commands/recipes/websocket.recipe.d.ts +1 -0
- package/dist/commands/recipes/websocket.recipe.js +453 -0
- package/dist/commands/recipes/websocket.recipe.js.map +1 -0
- package/dist/commands/resilience-patterns.d.ts +13 -0
- package/dist/commands/resilience-patterns.js +1029 -0
- package/dist/commands/resilience-patterns.js.map +1 -0
- package/dist/commands/security-patterns.d.ts +11 -0
- package/dist/commands/security-patterns.js +2233 -0
- package/dist/commands/security-patterns.js.map +1 -0
- package/dist/commands/template-debug.d.ts +27 -0
- package/dist/commands/template-debug.js +388 -0
- package/dist/commands/template-debug.js.map +1 -0
- package/dist/commands/test-factory-full.d.ts +9 -0
- package/dist/commands/test-factory-full.js +1570 -0
- package/dist/commands/test-factory-full.js.map +1 -0
- package/dist/commands/test-scaffold.d.ts +7 -0
- package/dist/commands/test-scaffold.js +621 -0
- package/dist/commands/test-scaffold.js.map +1 -0
- package/dist/index.js +1092 -1
- package/dist/index.js.map +1 -1
- package/dist/templates/ai-context/CLAUDE.md.hbs +173 -0
- package/dist/templates/ai-context/conventions.md.hbs +161 -0
- package/dist/templates/command/create-command.hbs +6 -14
- package/dist/templates/command/delete-command.hbs +19 -0
- package/dist/templates/command/update-command.hbs +24 -0
- package/dist/templates/controller/controller.hbs +64 -17
- package/dist/templates/dto/create-dto.hbs +29 -5
- package/dist/templates/dto/filter-dto.hbs +52 -0
- package/dist/templates/dto/filter-query.dto.hbs +148 -0
- package/dist/templates/dto/paginated-response.dto.hbs +29 -0
- package/dist/templates/dto/pagination-query.dto.hbs +30 -0
- package/dist/templates/dto/response-dto.hbs +38 -0
- package/dist/templates/dto/update-dto.hbs +11 -0
- package/dist/templates/entity/entity.hbs +32 -1
- package/dist/templates/event/domain-event.hbs +33 -7
- package/dist/templates/event/event-handler.hbs +40 -0
- package/dist/templates/exception/base-exceptions.hbs +69 -0
- package/dist/templates/exception/entity-not-found.exception.hbs +7 -0
- package/dist/templates/mapper/mapper.hbs +49 -24
- package/dist/templates/module/module.hbs +34 -10
- package/dist/templates/orm-entity/orm-entity.hbs +63 -12
- package/dist/templates/prisma/prisma-mapper.hbs +71 -0
- package/dist/templates/prisma/prisma-repository.hbs +114 -0
- package/dist/templates/prisma/prisma-schema.hbs +20 -0
- package/dist/templates/prisma/prisma-service.hbs +51 -0
- package/dist/templates/query/get-all.query.hbs +50 -0
- package/dist/templates/query/get-by-id.query.hbs +31 -0
- package/dist/templates/repository/repository.hbs +56 -14
- package/dist/templates/resolver/graphql-input.hbs +54 -0
- package/dist/templates/resolver/graphql-type.hbs +58 -0
- package/dist/templates/resolver/pagination-args.hbs +33 -0
- package/dist/templates/resolver/resolver.hbs +62 -0
- package/dist/templates/shared/prisma-query-builder.util.hbs +189 -0
- package/dist/templates/shared/query-builder.util.hbs +218 -0
- package/dist/templates/test/controller.spec.hbs +124 -0
- package/dist/templates/test/repository.spec.hbs +158 -0
- package/dist/templates/test/usecase.spec.hbs +116 -0
- package/dist/templates/usecase/create-usecase.hbs +20 -8
- package/dist/templates/usecase/delete-usecase.hbs +17 -0
- package/dist/templates/usecase/update-usecase.hbs +31 -0
- package/dist/utils/config.utils.d.ts +45 -0
- package/dist/utils/config.utils.js +211 -0
- package/dist/utils/config.utils.js.map +1 -0
- package/dist/utils/dependency.utils.d.ts +2 -0
- package/dist/utils/dependency.utils.js +44 -3
- package/dist/utils/dependency.utils.js.map +1 -1
- package/dist/utils/error.utils.d.ts +145 -0
- package/dist/utils/error.utils.js +422 -0
- package/dist/utils/error.utils.js.map +1 -0
- package/dist/utils/field.utils.d.ts +54 -0
- package/dist/utils/field.utils.js +401 -0
- package/dist/utils/field.utils.js.map +1 -0
- package/dist/utils/file.utils.d.ts +33 -8
- package/dist/utils/file.utils.js +237 -5
- package/dist/utils/file.utils.js.map +1 -1
- package/dist/utils/idempotency.utils.d.ts +123 -0
- package/dist/utils/idempotency.utils.js +444 -0
- package/dist/utils/idempotency.utils.js.map +1 -0
- package/dist/utils/naming.utils.js +24 -5
- package/dist/utils/naming.utils.js.map +1 -1
- package/dist/utils/performance.utils.d.ts +37 -0
- package/dist/utils/performance.utils.js +158 -0
- package/dist/utils/performance.utils.js.map +1 -0
- package/dist/utils/relation.utils.d.ts +92 -0
- package/dist/utils/relation.utils.js +388 -0
- package/dist/utils/relation.utils.js.map +1 -0
- package/dist/utils/rollback.utils.d.ts +49 -0
- package/dist/utils/rollback.utils.js +306 -0
- package/dist/utils/rollback.utils.js.map +1 -0
- package/dist/utils/schema.utils.d.ts +123 -0
- package/dist/utils/schema.utils.js +419 -0
- package/dist/utils/schema.utils.js.map +1 -0
- package/dist/utils/security.utils.d.ts +57 -0
- package/dist/utils/security.utils.js +315 -0
- package/dist/utils/security.utils.js.map +1 -0
- package/dist/utils/template-engine.utils.d.ts +80 -0
- package/dist/utils/template-engine.utils.js +478 -0
- package/dist/utils/template-engine.utils.js.map +1 -0
- package/dist/utils/validation-registry.utils.d.ts +160 -0
- package/dist/utils/validation-registry.utils.js +526 -0
- package/dist/utils/validation-registry.utils.js.map +1 -0
- package/package.json +12 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter-dsl.js","sourceRoot":"","sources":["../../src/commands/filter-dsl.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYH,8CAoCC;AA9CD,2CAA6B;AAC7B,kDAA0B;AAC1B,oDAA2D;AAQpD,KAAK,UAAU,iBAAiB,CAAC,QAAgB,EAAE,UAA4B,EAAE;IACtF,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC,CAAC;IAEpE,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;IACrD,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;IAErD,MAAM,IAAA,sBAAS,EAAC,WAAW,CAAC,CAAC;I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,CAAC;IAClE,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -41,64 +41,218 @@ const path = __importStar(require("path"));
|
|
|
41
41
|
const chalk_1 = __importDefault(require("chalk"));
|
|
42
42
|
const generate_module_1 = require("./generate-module");
|
|
43
43
|
const generate_entity_1 = require("./generate-entity");
|
|
44
|
-
const generate_usecase_1 = require("./generate-usecase");
|
|
45
44
|
const file_utils_1 = require("../utils/file.utils");
|
|
46
45
|
const naming_utils_1 = require("../utils/naming.utils");
|
|
47
46
|
const dependency_utils_1 = require("../utils/dependency.utils");
|
|
48
47
|
async function generateAll(entityName, options) {
|
|
49
|
-
console.log(chalk_1.default.blue(
|
|
48
|
+
console.log(chalk_1.default.blue(`\n🚀 Generating complete scaffolding for: ${entityName}`));
|
|
49
|
+
const orm = options.orm || 'typeorm';
|
|
50
|
+
const dryRun = !!options.dryRun;
|
|
51
|
+
if (dryRun) {
|
|
52
|
+
(0, file_utils_1.resetDryRunFiles)();
|
|
53
|
+
console.log(chalk_1.default.yellow(' Dry run: no files, directories, or dependencies will be written.'));
|
|
54
|
+
}
|
|
50
55
|
// Check if we need to install dependencies
|
|
51
|
-
const requiredDeps = ['@nestjs/cqrs', 'class-validator', 'class-transformer'];
|
|
52
|
-
if (
|
|
56
|
+
const requiredDeps = ['@nestjs/cqrs', 'class-validator', 'class-transformer', '@nestjs/swagger'];
|
|
57
|
+
if (orm === 'prisma') {
|
|
58
|
+
requiredDeps.push('@prisma/client', 'prisma');
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
requiredDeps.push('typeorm', '@nestjs/typeorm');
|
|
62
|
+
}
|
|
63
|
+
if (options.installDeps && !dryRun) {
|
|
53
64
|
await (0, dependency_utils_1.installDependencies)(options.path || process.cwd(), requiredDeps);
|
|
54
65
|
}
|
|
66
|
+
else if (options.installDeps && dryRun) {
|
|
67
|
+
console.log(chalk_1.default.yellow(` Dry run: would install dependencies: ${requiredDeps.join(', ')}`));
|
|
68
|
+
}
|
|
55
69
|
const moduleName = options.module || entityName;
|
|
56
70
|
const basePath = options.path || process.cwd();
|
|
57
71
|
const modulePath = (0, file_utils_1.getModulePath)(basePath, moduleName);
|
|
72
|
+
const fieldsString = options.fields || '';
|
|
58
73
|
// Check if module exists, create if not
|
|
59
74
|
const moduleFilePath = path.join(modulePath, `${(0, naming_utils_1.toKebabCase)(moduleName)}.module.ts`);
|
|
60
75
|
if (!(await (0, file_utils_1.fileExists)(moduleFilePath))) {
|
|
61
|
-
console.log(chalk_1.default.yellow(`Module ${moduleName} doesn't exist. Creating...`));
|
|
62
|
-
await (0, generate_module_1.generateModule)(moduleName, options);
|
|
76
|
+
console.log(chalk_1.default.yellow(` Module ${moduleName} doesn't exist. Creating...`));
|
|
77
|
+
await (0, generate_module_1.generateModule)(moduleName, { ...options, dryRun });
|
|
63
78
|
}
|
|
79
|
+
// Prepare template data with fields
|
|
80
|
+
const templateData = (0, file_utils_1.prepareTemplateData)(entityName, moduleName, fieldsString);
|
|
64
81
|
// Generate entity with all related files
|
|
65
|
-
await (0, generate_entity_1.generateEntity)(entityName, {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
82
|
+
await (0, generate_entity_1.generateEntity)(entityName, {
|
|
83
|
+
...options,
|
|
84
|
+
module: moduleName,
|
|
85
|
+
fields: fieldsString,
|
|
86
|
+
orm,
|
|
87
|
+
dryRun,
|
|
88
|
+
_fromGenerateAll: true,
|
|
89
|
+
});
|
|
90
|
+
// Generate PrismaService if using Prisma
|
|
91
|
+
if (orm === 'prisma') {
|
|
92
|
+
await generatePrismaService(basePath, dryRun);
|
|
71
93
|
}
|
|
94
|
+
// Generate CRUD commands
|
|
95
|
+
console.log(chalk_1.default.cyan(' Generating commands...'));
|
|
96
|
+
await generateCommand('create', entityName, modulePath, templateData, dryRun);
|
|
97
|
+
await generateCommand('update', entityName, modulePath, templateData, dryRun);
|
|
98
|
+
await generateCommand('delete', entityName, modulePath, templateData, dryRun);
|
|
99
|
+
// Generate use cases
|
|
100
|
+
console.log(chalk_1.default.cyan(' Generating use cases...'));
|
|
101
|
+
await generateUseCase('create', entityName, modulePath, templateData, dryRun);
|
|
102
|
+
await generateUseCase('update', entityName, modulePath, templateData, dryRun);
|
|
103
|
+
await generateUseCase('delete', entityName, modulePath, templateData, dryRun);
|
|
104
|
+
// Generate queries
|
|
105
|
+
console.log(chalk_1.default.cyan(' Generating queries...'));
|
|
106
|
+
await generateQueryHandler('get-by-id', entityName, modulePath, templateData, dryRun);
|
|
107
|
+
await generateQueryHandler('get-all', entityName, modulePath, templateData, dryRun);
|
|
108
|
+
// Generate DTOs
|
|
109
|
+
console.log(chalk_1.default.cyan(' Generating DTOs...'));
|
|
110
|
+
await generateDto('create', entityName, modulePath, templateData, dryRun);
|
|
111
|
+
await generateDto('update', entityName, modulePath, templateData, dryRun);
|
|
112
|
+
await generateDto('response', entityName, modulePath, templateData, dryRun);
|
|
113
|
+
await generatePaginationDtos(modulePath, dryRun);
|
|
72
114
|
// Generate controller
|
|
73
|
-
|
|
115
|
+
console.log(chalk_1.default.cyan(' Generating controller...'));
|
|
74
116
|
const controllerTemplatePath = path.join(__dirname, '../templates/controller/controller.hbs');
|
|
75
117
|
const controllerOutputPath = path.join(modulePath, 'application/controllers', `${(0, naming_utils_1.toKebabCase)(entityName)}.controller.ts`);
|
|
76
|
-
await (0, file_utils_1.generateFromTemplate)(controllerTemplatePath, controllerOutputPath, templateData);
|
|
77
|
-
// Generate migration file
|
|
78
|
-
|
|
118
|
+
await (0, file_utils_1.generateFromTemplate)(controllerTemplatePath, controllerOutputPath, templateData, dryRun);
|
|
119
|
+
// Generate migration file or Prisma schema snippet
|
|
120
|
+
if (orm === 'prisma') {
|
|
121
|
+
console.log(chalk_1.default.cyan(' Generating Prisma schema snippet...'));
|
|
122
|
+
await generatePrismaSchemaSnippet(entityName, basePath, templateData, dryRun);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
console.log(chalk_1.default.cyan(' Generating migration...'));
|
|
126
|
+
await generateMigration(entityName, basePath, templateData, dryRun);
|
|
127
|
+
}
|
|
128
|
+
// Generate barrel exports
|
|
129
|
+
console.log(chalk_1.default.cyan(' Generating barrel exports...'));
|
|
130
|
+
await generateBarrelExports(entityName, modulePath, orm, dryRun);
|
|
131
|
+
// Generate tests if requested
|
|
132
|
+
if (options.withTests) {
|
|
133
|
+
console.log(chalk_1.default.cyan(' Generating tests...'));
|
|
134
|
+
await generateTests(entityName, modulePath, templateData, dryRun);
|
|
135
|
+
}
|
|
136
|
+
// Generate GraphQL files if requested
|
|
137
|
+
if (options.withGraphql) {
|
|
138
|
+
console.log(chalk_1.default.cyan(' Generating GraphQL resolvers and types...'));
|
|
139
|
+
await generateGraphQL(entityName, modulePath, templateData, dryRun);
|
|
140
|
+
}
|
|
141
|
+
if (dryRun) {
|
|
142
|
+
printDryRunSummary(basePath);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
79
145
|
console.log(chalk_1.default.green(`\n✅ Complete scaffolding generated successfully!`));
|
|
80
|
-
console.log(chalk_1.default.cyan(`\n📁 Generated
|
|
81
|
-
console.log(` Module: ${modulePath}`);
|
|
82
|
-
console.log(` Entity: ${entityName}`);
|
|
83
|
-
console.log(`
|
|
84
|
-
console.log(`
|
|
85
|
-
console.log(`
|
|
86
|
-
console.log(`
|
|
87
|
-
console.log(chalk_1.default.
|
|
88
|
-
console.log(`
|
|
89
|
-
console.log(`
|
|
90
|
-
console.log(`
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
|
|
146
|
+
console.log(chalk_1.default.cyan(`\n📁 Generated structure:`));
|
|
147
|
+
console.log(` ${chalk_1.default.white('Module:')} ${modulePath}`);
|
|
148
|
+
console.log(` ${chalk_1.default.white('Entity:')} ${entityName}`);
|
|
149
|
+
console.log(` ${chalk_1.default.white('ORM:')} ${orm === 'prisma' ? 'Prisma' : 'TypeORM'}`);
|
|
150
|
+
console.log(` ${chalk_1.default.white('Commands:')} Create, Update, Delete`);
|
|
151
|
+
console.log(` ${chalk_1.default.white('Queries:')} GetById, GetAll (paginated)`);
|
|
152
|
+
console.log(` ${chalk_1.default.white('Use Cases:')} Create, Update, Delete`);
|
|
153
|
+
console.log(` ${chalk_1.default.white('DTOs:')} Create, Update, Response, Pagination`);
|
|
154
|
+
console.log(` ${chalk_1.default.white('Controller:')} Full CRUD REST endpoints`);
|
|
155
|
+
console.log(` ${chalk_1.default.white('Repository:')} With pagination support`);
|
|
156
|
+
console.log(` ${chalk_1.default.white('Mapper:')} Domain ↔ ${orm === 'prisma' ? 'Prisma' : 'ORM'} ↔ Response`);
|
|
157
|
+
if (options.withGraphql) {
|
|
158
|
+
console.log(` ${chalk_1.default.white('GraphQL:')} Resolver, Types, Inputs`);
|
|
159
|
+
}
|
|
160
|
+
if (templateData.hasFields) {
|
|
161
|
+
console.log(chalk_1.default.green(`\n✨ Fields generated: ${templateData.fields?.map((f) => f.name).join(', ')}`));
|
|
162
|
+
}
|
|
163
|
+
console.log(chalk_1.default.yellow(`\n📋 Next steps:`));
|
|
164
|
+
console.log(` 1. ${templateData.hasFields ? 'Review' : 'Add properties to'} your entity and DTOs`);
|
|
165
|
+
if (orm === 'prisma') {
|
|
166
|
+
console.log(` 2. Add the generated model to your ${chalk_1.default.cyan('prisma/schema.prisma')}`);
|
|
167
|
+
console.log(` 3. Run: ${chalk_1.default.cyan('npx prisma migrate dev --name add_' + (0, naming_utils_1.toKebabCase)(entityName))}`);
|
|
168
|
+
console.log(` 4. Run: ${chalk_1.default.cyan('npx prisma generate')}`);
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
console.log(` 2. Run the migration: ${chalk_1.default.cyan('npm run migration:run')}`);
|
|
172
|
+
}
|
|
173
|
+
console.log(` ${orm === 'prisma' ? '5' : '3'}. Import ${(0, naming_utils_1.toPascalCase)(moduleName)}Module in your app.module.ts`);
|
|
174
|
+
console.log(` ${orm === 'prisma' ? '6' : '4'}. Start your server and test the API at ${chalk_1.default.cyan(`/${templateData.entityNamePluralKebab}`)}`);
|
|
175
|
+
}
|
|
176
|
+
function printDryRunSummary(basePath) {
|
|
177
|
+
const changes = (0, file_utils_1.getDryRunFiles)();
|
|
178
|
+
console.log(chalk_1.default.cyan(`\n🧪 Dry run complete. Planned file changes (${changes.length}):`));
|
|
179
|
+
if (!changes.length) {
|
|
180
|
+
console.log(chalk_1.default.gray(' No file changes planned.'));
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
for (const change of changes) {
|
|
184
|
+
const relativePath = path.relative(basePath, change.filePath);
|
|
185
|
+
console.log(` ${change.action.padEnd(6)} ${relativePath}`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
async function generateCommand(action, entityName, modulePath, templateData, dryRun = false) {
|
|
189
|
+
const templatePath = path.join(__dirname, `../templates/command/${action}-command.hbs`);
|
|
190
|
+
const outputPath = path.join(modulePath, 'application/commands', `${action}-${(0, naming_utils_1.toKebabCase)(entityName)}.command.ts`);
|
|
191
|
+
await (0, file_utils_1.generateFromTemplate)(templatePath, outputPath, templateData, dryRun);
|
|
192
|
+
}
|
|
193
|
+
async function generateUseCase(action, entityName, modulePath, templateData, dryRun = false) {
|
|
194
|
+
const templatePath = path.join(__dirname, `../templates/usecase/${action}-usecase.hbs`);
|
|
195
|
+
const outputPath = path.join(modulePath, 'application/domain/usecases', `${action}-${(0, naming_utils_1.toKebabCase)(entityName)}.use-case.ts`);
|
|
196
|
+
await (0, file_utils_1.generateFromTemplate)(templatePath, outputPath, templateData, dryRun);
|
|
197
|
+
}
|
|
198
|
+
async function generateQueryHandler(type, entityName, modulePath, templateData, dryRun = false) {
|
|
199
|
+
const fileName = type === 'get-all'
|
|
200
|
+
? `get-all-${templateData.entityNamePluralKebab}.query.ts`
|
|
201
|
+
: `get-${(0, naming_utils_1.toKebabCase)(entityName)}-by-id.query.ts`;
|
|
202
|
+
const templatePath = path.join(__dirname, `../templates/query/${type}.query.hbs`);
|
|
203
|
+
const outputPath = path.join(modulePath, 'application/queries', fileName);
|
|
204
|
+
await (0, file_utils_1.generateFromTemplate)(templatePath, outputPath, templateData, dryRun);
|
|
205
|
+
}
|
|
206
|
+
async function generateDto(type, entityName, modulePath, templateData, dryRun = false) {
|
|
207
|
+
const templateMap = {
|
|
208
|
+
create: 'create-dto.hbs',
|
|
209
|
+
update: 'update-dto.hbs',
|
|
210
|
+
response: 'response-dto.hbs',
|
|
211
|
+
};
|
|
212
|
+
const outputDirMap = {
|
|
213
|
+
create: 'requests',
|
|
214
|
+
update: 'requests',
|
|
215
|
+
response: 'responses',
|
|
216
|
+
};
|
|
217
|
+
const fileNameMap = {
|
|
218
|
+
create: `create-${(0, naming_utils_1.toKebabCase)(entityName)}.dto.ts`,
|
|
219
|
+
update: `update-${(0, naming_utils_1.toKebabCase)(entityName)}.dto.ts`,
|
|
220
|
+
response: `${(0, naming_utils_1.toKebabCase)(entityName)}.response.dto.ts`,
|
|
221
|
+
};
|
|
222
|
+
const templatePath = path.join(__dirname, `../templates/dto/${templateMap[type]}`);
|
|
223
|
+
const outputPath = path.join(modulePath, `application/dto/${outputDirMap[type]}`, fileNameMap[type]);
|
|
224
|
+
await (0, file_utils_1.generateFromTemplate)(templatePath, outputPath, templateData, dryRun);
|
|
225
|
+
}
|
|
226
|
+
async function generatePaginationDtos(modulePath, dryRun = false) {
|
|
227
|
+
// Generate pagination query DTO
|
|
228
|
+
const paginationQueryTemplatePath = path.join(__dirname, '../templates/dto/pagination-query.dto.hbs');
|
|
229
|
+
const paginationQueryOutputPath = path.join(modulePath, 'application/dto/requests', 'pagination.query.dto.ts');
|
|
230
|
+
if (!(await (0, file_utils_1.fileExists)(paginationQueryOutputPath))) {
|
|
231
|
+
await (0, file_utils_1.generateFromTemplate)(paginationQueryTemplatePath, paginationQueryOutputPath, (0, file_utils_1.prepareTemplateData)('Pagination', 'shared'), dryRun);
|
|
232
|
+
}
|
|
233
|
+
// Generate paginated response DTO
|
|
234
|
+
const paginatedResponseTemplatePath = path.join(__dirname, '../templates/dto/paginated-response.dto.hbs');
|
|
235
|
+
const paginatedResponseOutputPath = path.join(modulePath, 'application/dto/responses', 'paginated.response.dto.ts');
|
|
236
|
+
if (!(await (0, file_utils_1.fileExists)(paginatedResponseOutputPath))) {
|
|
237
|
+
await (0, file_utils_1.generateFromTemplate)(paginatedResponseTemplatePath, paginatedResponseOutputPath, (0, file_utils_1.prepareTemplateData)('Paginated', 'shared'), dryRun);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
async function generateMigration(entityName, basePath, templateData, dryRun = false) {
|
|
95
241
|
const timestamp = Date.now();
|
|
96
|
-
const tableName =
|
|
242
|
+
const tableName = templateData.tableName;
|
|
97
243
|
const migrationName = `create_${tableName}_table`;
|
|
98
244
|
const fileName = `${timestamp}-${migrationName}.ts`;
|
|
245
|
+
const fieldsColumns = templateData.migrationColumns ||
|
|
246
|
+
` // Add your custom columns here
|
|
247
|
+
// Example:
|
|
248
|
+
// {
|
|
249
|
+
// name: "name",
|
|
250
|
+
// type: "varchar",
|
|
251
|
+
// isNullable: false,
|
|
252
|
+
// },`;
|
|
99
253
|
const content = `import { MigrationInterface, QueryRunner, Table } from "typeorm";
|
|
100
254
|
|
|
101
|
-
export class Create${entityName}Table${timestamp} implements MigrationInterface {
|
|
255
|
+
export class Create${(0, naming_utils_1.toPascalCase)(entityName)}Table${timestamp} implements MigrationInterface {
|
|
102
256
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
103
257
|
await queryRunner.createTable(
|
|
104
258
|
new Table({
|
|
@@ -111,6 +265,7 @@ export class Create${entityName}Table${timestamp} implements MigrationInterface
|
|
|
111
265
|
generationStrategy: "uuid",
|
|
112
266
|
default: "uuid_generate_v4()",
|
|
113
267
|
},
|
|
268
|
+
${fieldsColumns}
|
|
114
269
|
{
|
|
115
270
|
name: "is_active",
|
|
116
271
|
type: "boolean",
|
|
@@ -131,7 +286,6 @@ export class Create${entityName}Table${timestamp} implements MigrationInterface
|
|
|
131
286
|
type: "timestamp",
|
|
132
287
|
isNullable: true,
|
|
133
288
|
},
|
|
134
|
-
// Add your custom columns here
|
|
135
289
|
],
|
|
136
290
|
}),
|
|
137
291
|
true,
|
|
@@ -144,7 +298,342 @@ export class Create${entityName}Table${timestamp} implements MigrationInterface
|
|
|
144
298
|
}
|
|
145
299
|
`;
|
|
146
300
|
const migrationPath = path.join(basePath, 'src/migrations', fileName);
|
|
147
|
-
await
|
|
148
|
-
console.log(chalk_1.default.green(` Migration: ${fileName}`));
|
|
301
|
+
await (0, file_utils_1.writeGeneratedFile)(migrationPath, content, dryRun);
|
|
302
|
+
console.log(chalk_1.default.green(` ✓ Migration: ${fileName}`));
|
|
303
|
+
}
|
|
304
|
+
async function generateBarrelExports(entityName, modulePath, orm = 'typeorm', dryRun = false) {
|
|
305
|
+
const entityNameKebab = (0, naming_utils_1.toKebabCase)(entityName);
|
|
306
|
+
const entityNamePascal = (0, naming_utils_1.toPascalCase)(entityName);
|
|
307
|
+
const entityNamePluralKebab = (0, naming_utils_1.toKebabCase)((0, naming_utils_1.toPlural)(entityName));
|
|
308
|
+
const entityNamePluralPascal = (0, naming_utils_1.toPlural)((0, naming_utils_1.toPascalCase)(entityName));
|
|
309
|
+
const isPrisma = orm === 'prisma';
|
|
310
|
+
// Commands index
|
|
311
|
+
const commandsIndexPath = path.join(modulePath, 'application/commands/index.ts');
|
|
312
|
+
await (0, file_utils_1.updateBarrelFile)(commandsIndexPath, {
|
|
313
|
+
exports: [
|
|
314
|
+
`export * from './create-${entityNameKebab}.command';`,
|
|
315
|
+
`export * from './update-${entityNameKebab}.command';`,
|
|
316
|
+
`export * from './delete-${entityNameKebab}.command';`,
|
|
317
|
+
],
|
|
318
|
+
imports: [
|
|
319
|
+
`import { Create${entityNamePascal}Handler } from './create-${entityNameKebab}.command';`,
|
|
320
|
+
`import { Update${entityNamePascal}Handler } from './update-${entityNameKebab}.command';`,
|
|
321
|
+
`import { Delete${entityNamePascal}Handler } from './delete-${entityNameKebab}.command';`,
|
|
322
|
+
],
|
|
323
|
+
arrayName: 'CommandHandlers',
|
|
324
|
+
arrayItems: [
|
|
325
|
+
`Create${entityNamePascal}Handler`,
|
|
326
|
+
`Update${entityNamePascal}Handler`,
|
|
327
|
+
`Delete${entityNamePascal}Handler`,
|
|
328
|
+
],
|
|
329
|
+
dryRun,
|
|
330
|
+
});
|
|
331
|
+
// Queries index
|
|
332
|
+
const queriesIndexPath = path.join(modulePath, 'application/queries/index.ts');
|
|
333
|
+
await (0, file_utils_1.updateBarrelFile)(queriesIndexPath, {
|
|
334
|
+
exports: [
|
|
335
|
+
`export * from './get-${entityNameKebab}-by-id.query';`,
|
|
336
|
+
`export * from './get-all-${entityNamePluralKebab}.query';`,
|
|
337
|
+
],
|
|
338
|
+
imports: [
|
|
339
|
+
`import { Get${entityNamePascal}ByIdHandler } from './get-${entityNameKebab}-by-id.query';`,
|
|
340
|
+
`import { GetAll${entityNamePluralPascal}Handler } from './get-all-${entityNamePluralKebab}.query';`,
|
|
341
|
+
],
|
|
342
|
+
arrayName: 'Queries',
|
|
343
|
+
arrayItems: [`Get${entityNamePascal}ByIdHandler`, `GetAll${entityNamePluralPascal}Handler`],
|
|
344
|
+
dryRun,
|
|
345
|
+
});
|
|
346
|
+
// Use cases index
|
|
347
|
+
const useCasesIndexPath = path.join(modulePath, 'application/domain/usecases/index.ts');
|
|
348
|
+
await (0, file_utils_1.updateBarrelFile)(useCasesIndexPath, {
|
|
349
|
+
exports: [
|
|
350
|
+
`export * from './create-${entityNameKebab}.use-case';`,
|
|
351
|
+
`export * from './update-${entityNameKebab}.use-case';`,
|
|
352
|
+
`export * from './delete-${entityNameKebab}.use-case';`,
|
|
353
|
+
],
|
|
354
|
+
imports: [
|
|
355
|
+
`import { Create${entityNamePascal}UseCase } from './create-${entityNameKebab}.use-case';`,
|
|
356
|
+
`import { Update${entityNamePascal}UseCase } from './update-${entityNameKebab}.use-case';`,
|
|
357
|
+
`import { Delete${entityNamePascal}UseCase } from './delete-${entityNameKebab}.use-case';`,
|
|
358
|
+
],
|
|
359
|
+
arrayName: 'UseCases',
|
|
360
|
+
arrayItems: [
|
|
361
|
+
`Create${entityNamePascal}UseCase`,
|
|
362
|
+
`Update${entityNamePascal}UseCase`,
|
|
363
|
+
`Delete${entityNamePascal}UseCase`,
|
|
364
|
+
],
|
|
365
|
+
dryRun,
|
|
366
|
+
});
|
|
367
|
+
// DTOs index
|
|
368
|
+
const dtosIndexPath = path.join(modulePath, 'application/dto/index.ts');
|
|
369
|
+
await (0, file_utils_1.updateBarrelFile)(dtosIndexPath, {
|
|
370
|
+
exports: [`export * from './requests';`, `export * from './responses';`],
|
|
371
|
+
dryRun,
|
|
372
|
+
});
|
|
373
|
+
// Requests index
|
|
374
|
+
const requestsIndexPath = path.join(modulePath, 'application/dto/requests/index.ts');
|
|
375
|
+
await (0, file_utils_1.updateBarrelFile)(requestsIndexPath, {
|
|
376
|
+
exports: [
|
|
377
|
+
`export * from './create-${entityNameKebab}.dto';`,
|
|
378
|
+
`export * from './update-${entityNameKebab}.dto';`,
|
|
379
|
+
`export * from './pagination.query.dto';`,
|
|
380
|
+
],
|
|
381
|
+
dryRun,
|
|
382
|
+
});
|
|
383
|
+
// Responses index
|
|
384
|
+
const responsesIndexPath = path.join(modulePath, 'application/dto/responses/index.ts');
|
|
385
|
+
await (0, file_utils_1.updateBarrelFile)(responsesIndexPath, {
|
|
386
|
+
exports: [
|
|
387
|
+
`export * from './${entityNameKebab}.response.dto';`,
|
|
388
|
+
`export * from './paginated.response.dto';`,
|
|
389
|
+
],
|
|
390
|
+
dryRun,
|
|
391
|
+
});
|
|
392
|
+
// Controllers index
|
|
393
|
+
const controllersIndexPath = path.join(modulePath, 'application/controllers/index.ts');
|
|
394
|
+
await (0, file_utils_1.updateBarrelFile)(controllersIndexPath, {
|
|
395
|
+
exports: [`export * from './${entityNameKebab}.controller';`],
|
|
396
|
+
imports: [`import { ${entityNamePascal}Controller } from './${entityNameKebab}.controller';`],
|
|
397
|
+
arrayName: 'Controllers',
|
|
398
|
+
arrayItems: [`${entityNamePascal}Controller`],
|
|
399
|
+
dryRun,
|
|
400
|
+
});
|
|
401
|
+
// Entities index
|
|
402
|
+
const entitiesIndexPath = path.join(modulePath, 'application/domain/entities/index.ts');
|
|
403
|
+
await (0, file_utils_1.updateBarrelFile)(entitiesIndexPath, {
|
|
404
|
+
exports: [`export * from './${entityNameKebab}.entity';`],
|
|
405
|
+
dryRun,
|
|
406
|
+
});
|
|
407
|
+
// Repositories index
|
|
408
|
+
const repositoriesIndexPath = path.join(modulePath, 'infrastructure/repositories/index.ts');
|
|
409
|
+
await (0, file_utils_1.updateBarrelFile)(repositoriesIndexPath, {
|
|
410
|
+
exports: [`export * from './${entityNameKebab}.repository';`],
|
|
411
|
+
imports: [`import { ${entityNamePascal}Repository } from './${entityNameKebab}.repository';`],
|
|
412
|
+
arrayName: 'Repositories',
|
|
413
|
+
arrayItems: [`${entityNamePascal}Repository`],
|
|
414
|
+
dryRun,
|
|
415
|
+
});
|
|
416
|
+
// Mappers index
|
|
417
|
+
const mappersIndexPath = path.join(modulePath, 'infrastructure/mappers/index.ts');
|
|
418
|
+
await (0, file_utils_1.updateBarrelFile)(mappersIndexPath, {
|
|
419
|
+
exports: [`export * from './${entityNameKebab}.mapper';`],
|
|
420
|
+
imports: [`import { ${entityNamePascal}Mapper } from './${entityNameKebab}.mapper';`],
|
|
421
|
+
arrayName: 'Mappers',
|
|
422
|
+
arrayItems: [`${entityNamePascal}Mapper`],
|
|
423
|
+
dryRun,
|
|
424
|
+
});
|
|
425
|
+
// ORM entities index (TypeORM only)
|
|
426
|
+
if (!isPrisma) {
|
|
427
|
+
const ormEntitiesIndexPath = path.join(modulePath, 'infrastructure/orm-entities/index.ts');
|
|
428
|
+
await (0, file_utils_1.updateBarrelFile)(ormEntitiesIndexPath, {
|
|
429
|
+
exports: [`export * from './${entityNameKebab}.orm-entity';`],
|
|
430
|
+
imports: [`import { ${entityNamePascal}OrmEntity } from './${entityNameKebab}.orm-entity';`],
|
|
431
|
+
arrayName: 'OrmEntities',
|
|
432
|
+
arrayItems: [`${entityNamePascal}OrmEntity`],
|
|
433
|
+
dryRun,
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
async function generateTests(entityName, modulePath, templateData, dryRun = false) {
|
|
438
|
+
const entityNameKebab = (0, naming_utils_1.toKebabCase)(entityName);
|
|
439
|
+
// Repository test
|
|
440
|
+
const repoTestTemplatePath = path.join(__dirname, '../templates/test/repository.spec.hbs');
|
|
441
|
+
const repoTestOutputPath = path.join(modulePath, 'infrastructure/repositories', `${entityNameKebab}.repository.spec.ts`);
|
|
442
|
+
await (0, file_utils_1.generateFromTemplate)(repoTestTemplatePath, repoTestOutputPath, templateData, dryRun);
|
|
443
|
+
console.log(chalk_1.default.green(` ✓ Repository test`));
|
|
444
|
+
// Use case tests
|
|
445
|
+
const useCaseTestTemplatePath = path.join(__dirname, '../templates/test/usecase.spec.hbs');
|
|
446
|
+
const useCaseTestOutputPath = path.join(modulePath, 'application/domain/usecases', `${entityNameKebab}.use-case.spec.ts`);
|
|
447
|
+
await (0, file_utils_1.generateFromTemplate)(useCaseTestTemplatePath, useCaseTestOutputPath, templateData, dryRun);
|
|
448
|
+
console.log(chalk_1.default.green(` ✓ Use case tests`));
|
|
449
|
+
// Controller test
|
|
450
|
+
const controllerTestTemplatePath = path.join(__dirname, '../templates/test/controller.spec.hbs');
|
|
451
|
+
const controllerTestOutputPath = path.join(modulePath, 'application/controllers', `${entityNameKebab}.controller.spec.ts`);
|
|
452
|
+
await (0, file_utils_1.generateFromTemplate)(controllerTestTemplatePath, controllerTestOutputPath, templateData, dryRun);
|
|
453
|
+
console.log(chalk_1.default.green(` ✓ Controller test`));
|
|
454
|
+
}
|
|
455
|
+
async function generateGraphQL(entityName, modulePath, templateData, dryRun = false) {
|
|
456
|
+
const entityNameKebab = (0, naming_utils_1.toKebabCase)(entityName);
|
|
457
|
+
const entityNamePascal = (0, naming_utils_1.toPascalCase)(entityName);
|
|
458
|
+
// Create GraphQL directories
|
|
459
|
+
const graphqlPath = path.join(modulePath, 'application/graphql');
|
|
460
|
+
const typesPath = path.join(graphqlPath, 'types');
|
|
461
|
+
const inputsPath = path.join(graphqlPath, 'inputs');
|
|
462
|
+
const argsPath = path.join(graphqlPath, 'args');
|
|
463
|
+
// Generate resolver
|
|
464
|
+
const resolverTemplatePath = path.join(__dirname, '../templates/resolver/resolver.hbs');
|
|
465
|
+
const resolverOutputPath = path.join(graphqlPath, `${entityNameKebab}.resolver.ts`);
|
|
466
|
+
await (0, file_utils_1.generateFromTemplate)(resolverTemplatePath, resolverOutputPath, templateData, dryRun);
|
|
467
|
+
console.log(chalk_1.default.green(` ✓ Resolver`));
|
|
468
|
+
// Generate GraphQL type
|
|
469
|
+
const typeTemplatePath = path.join(__dirname, '../templates/resolver/graphql-type.hbs');
|
|
470
|
+
const typeOutputPath = path.join(typesPath, `${entityNameKebab}.type.ts`);
|
|
471
|
+
await (0, file_utils_1.generateFromTemplate)(typeTemplatePath, typeOutputPath, templateData, dryRun);
|
|
472
|
+
console.log(chalk_1.default.green(` ✓ GraphQL Type`));
|
|
473
|
+
// Generate GraphQL inputs
|
|
474
|
+
const inputTemplatePath = path.join(__dirname, '../templates/resolver/graphql-input.hbs');
|
|
475
|
+
const inputOutputPath = path.join(inputsPath, `${entityNameKebab}.input.ts`);
|
|
476
|
+
await (0, file_utils_1.generateFromTemplate)(inputTemplatePath, inputOutputPath, templateData, dryRun);
|
|
477
|
+
console.log(chalk_1.default.green(` ✓ GraphQL Inputs`));
|
|
478
|
+
// Generate pagination args (if not exists)
|
|
479
|
+
const paginationArgsPath = path.join(argsPath, 'pagination.args.ts');
|
|
480
|
+
if (!(await (0, file_utils_1.fileExists)(paginationArgsPath))) {
|
|
481
|
+
const paginationArgsTemplatePath = path.join(__dirname, '../templates/resolver/pagination-args.hbs');
|
|
482
|
+
await (0, file_utils_1.generateFromTemplate)(paginationArgsTemplatePath, paginationArgsPath, templateData, dryRun);
|
|
483
|
+
console.log(chalk_1.default.green(` ✓ Pagination Args`));
|
|
484
|
+
}
|
|
485
|
+
// Generate barrel exports
|
|
486
|
+
const typesIndexContent = `export * from "./${entityNameKebab}.type";
|
|
487
|
+
`;
|
|
488
|
+
await (0, file_utils_1.writeGeneratedFile)(path.join(typesPath, 'index.ts'), typesIndexContent, dryRun);
|
|
489
|
+
const inputsIndexContent = `export * from "./${entityNameKebab}.input";
|
|
490
|
+
`;
|
|
491
|
+
await (0, file_utils_1.writeGeneratedFile)(path.join(inputsPath, 'index.ts'), inputsIndexContent, dryRun);
|
|
492
|
+
const argsIndexContent = `export * from "./pagination.args";
|
|
493
|
+
`;
|
|
494
|
+
await (0, file_utils_1.writeGeneratedFile)(path.join(argsPath, 'index.ts'), argsIndexContent, dryRun);
|
|
495
|
+
const graphqlIndexContent = `export * from "./${entityNameKebab}.resolver";
|
|
496
|
+
export * from "./types";
|
|
497
|
+
export * from "./inputs";
|
|
498
|
+
export * from "./args";
|
|
499
|
+
|
|
500
|
+
import { ${entityNamePascal}Resolver } from "./${entityNameKebab}.resolver";
|
|
501
|
+
|
|
502
|
+
export const Resolvers = [${entityNamePascal}Resolver];
|
|
503
|
+
`;
|
|
504
|
+
await (0, file_utils_1.writeGeneratedFile)(path.join(graphqlPath, 'index.ts'), graphqlIndexContent, dryRun);
|
|
505
|
+
}
|
|
506
|
+
async function generatePrismaService(basePath, dryRun = false) {
|
|
507
|
+
const prismaServicePath = path.join(basePath, 'src/prisma/prisma.service.ts');
|
|
508
|
+
if (await (0, file_utils_1.fileExists)(prismaServicePath)) {
|
|
509
|
+
console.log(chalk_1.default.yellow(` PrismaService already exists. Skipping...`));
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
const content = `import { Injectable, OnModuleInit, OnModuleDestroy } from "@nestjs/common";
|
|
513
|
+
import { PrismaClient } from "@prisma/client";
|
|
514
|
+
|
|
515
|
+
@Injectable()
|
|
516
|
+
export class PrismaService extends PrismaClient implements OnModuleInit, OnModuleDestroy {
|
|
517
|
+
constructor() {
|
|
518
|
+
super({
|
|
519
|
+
log: process.env.NODE_ENV === "development"
|
|
520
|
+
? ["query", "info", "warn", "error"]
|
|
521
|
+
: ["error"],
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
async onModuleInit() {
|
|
526
|
+
await this.$connect();
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
async onModuleDestroy() {
|
|
530
|
+
await this.$disconnect();
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* Execute operations in a transaction
|
|
535
|
+
*/
|
|
536
|
+
async executeInTransaction<T>(
|
|
537
|
+
fn: (prisma: Omit<PrismaClient, "$connect" | "$disconnect" | "$on" | "$transaction" | "$use">) => Promise<T>,
|
|
538
|
+
): Promise<T> {
|
|
539
|
+
return this.$transaction(fn);
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* Clean database (useful for testing)
|
|
544
|
+
*/
|
|
545
|
+
async cleanDatabase() {
|
|
546
|
+
if (process.env.NODE_ENV !== "test") {
|
|
547
|
+
throw new Error("cleanDatabase can only be called in test environment");
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
const models = Reflect.ownKeys(this).filter(
|
|
551
|
+
(key) => typeof key === "string" && !key.startsWith("_") && !key.startsWith("$"),
|
|
552
|
+
);
|
|
553
|
+
|
|
554
|
+
for (const model of models) {
|
|
555
|
+
try {
|
|
556
|
+
await (this as any)[model].deleteMany();
|
|
557
|
+
} catch (error) {
|
|
558
|
+
// Ignore if model doesn't support deleteMany
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
`;
|
|
564
|
+
await (0, file_utils_1.writeGeneratedFile)(prismaServicePath, content, dryRun);
|
|
565
|
+
console.log(chalk_1.default.green(` ✓ PrismaService`));
|
|
566
|
+
// Also generate prisma.module.ts
|
|
567
|
+
const prismaModulePath = path.join(basePath, 'src/prisma/prisma.module.ts');
|
|
568
|
+
if (!(await (0, file_utils_1.fileExists)(prismaModulePath))) {
|
|
569
|
+
const moduleContent = `import { Global, Module } from "@nestjs/common";
|
|
570
|
+
import { PrismaService } from "./prisma.service";
|
|
571
|
+
|
|
572
|
+
@Global()
|
|
573
|
+
@Module({
|
|
574
|
+
providers: [PrismaService],
|
|
575
|
+
exports: [PrismaService],
|
|
576
|
+
})
|
|
577
|
+
export class PrismaModule {}
|
|
578
|
+
`;
|
|
579
|
+
await (0, file_utils_1.writeGeneratedFile)(prismaModulePath, moduleContent, dryRun);
|
|
580
|
+
console.log(chalk_1.default.green(` ✓ PrismaModule`));
|
|
581
|
+
}
|
|
582
|
+
// Generate index.ts
|
|
583
|
+
const indexPath = path.join(basePath, 'src/prisma/index.ts');
|
|
584
|
+
if (!(await (0, file_utils_1.fileExists)(indexPath))) {
|
|
585
|
+
const indexContent = `export * from "./prisma.service";
|
|
586
|
+
export * from "./prisma.module";
|
|
587
|
+
`;
|
|
588
|
+
await (0, file_utils_1.writeGeneratedFile)(indexPath, indexContent, dryRun);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
async function generatePrismaSchemaSnippet(entityName, basePath, templateData, dryRun = false) {
|
|
592
|
+
const tableName = templateData.tableName;
|
|
593
|
+
const entityNamePascal = (0, naming_utils_1.toPascalCase)(entityName);
|
|
594
|
+
// Generate fields for Prisma schema
|
|
595
|
+
let fieldsContent = '';
|
|
596
|
+
if (templateData.fields && templateData.fields.length > 0) {
|
|
597
|
+
fieldsContent = templateData.fields
|
|
598
|
+
.map((f) => {
|
|
599
|
+
let line = ` ${f.snakeCase.padEnd(20)} ${f.prismaType}`;
|
|
600
|
+
if (f.isOptional)
|
|
601
|
+
line += '?';
|
|
602
|
+
if (f.isUnique)
|
|
603
|
+
line += ' @unique';
|
|
604
|
+
return line;
|
|
605
|
+
})
|
|
606
|
+
.join('\n');
|
|
607
|
+
}
|
|
608
|
+
else {
|
|
609
|
+
fieldsContent = ` // Add your fields here
|
|
610
|
+
// name String
|
|
611
|
+
// email String @unique`;
|
|
612
|
+
}
|
|
613
|
+
const content = `// =============================================================
|
|
614
|
+
// Prisma Schema Snippet for ${entityNamePascal}
|
|
615
|
+
// Add this to your prisma/schema.prisma file
|
|
616
|
+
// =============================================================
|
|
617
|
+
|
|
618
|
+
model ${entityNamePascal} {
|
|
619
|
+
id String @id @default(uuid())
|
|
620
|
+
${fieldsContent}
|
|
621
|
+
is_active Boolean @default(true)
|
|
622
|
+
created_at DateTime @default(now())
|
|
623
|
+
updated_at DateTime @updatedAt
|
|
624
|
+
deleted_at DateTime?
|
|
625
|
+
|
|
626
|
+
@@map("${tableName}")
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
// =============================================================
|
|
630
|
+
// After adding, run:
|
|
631
|
+
// npx prisma migrate dev --name add_${(0, naming_utils_1.toKebabCase)(entityName)}
|
|
632
|
+
// npx prisma generate
|
|
633
|
+
// =============================================================
|
|
634
|
+
`;
|
|
635
|
+
const snippetPath = path.join(basePath, `prisma/snippets/${(0, naming_utils_1.toKebabCase)(entityName)}.prisma`);
|
|
636
|
+
await (0, file_utils_1.writeGeneratedFile)(snippetPath, content, dryRun);
|
|
637
|
+
console.log(chalk_1.default.green(` ✓ Prisma schema snippet: prisma/snippets/${(0, naming_utils_1.toKebabCase)(entityName)}.prisma`));
|
|
149
638
|
}
|
|
150
639
|
//# sourceMappingURL=generate-all.js.map
|