nestjs-ddd-cli 2.2.0 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +485 -32
- 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 +82 -24
- 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-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 +3941 -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 +7 -0
- package/dist/commands/recipes/index.js +24 -0
- package/dist/commands/recipes/index.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 +1088 -0
- package/dist/index.js.map +1 -1
- package/dist/templates/ai-context/CLAUDE.md.hbs +158 -0
- package/dist/templates/ai-context/conventions.md.hbs +154 -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 +55 -13
- 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 +19 -7
- 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/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 +389 -0
- package/dist/utils/field.utils.js.map +1 -0
- package/dist/utils/file.utils.d.ts +19 -8
- package/dist/utils/file.utils.js +135 -4
- 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 +26 -3
- 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 +463 -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 +3 -1
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified Error & Exception Framework
|
|
3
|
+
* Provides centralized exception handling for CLI and generated code
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Base CLI Error with error codes
|
|
7
|
+
*/
|
|
8
|
+
export declare class CliError extends Error {
|
|
9
|
+
readonly code: string;
|
|
10
|
+
readonly details?: Record<string, any>;
|
|
11
|
+
readonly suggestion?: string;
|
|
12
|
+
readonly cause?: Error;
|
|
13
|
+
constructor(message: string, code: string, options?: {
|
|
14
|
+
details?: Record<string, any>;
|
|
15
|
+
suggestion?: string;
|
|
16
|
+
cause?: Error;
|
|
17
|
+
});
|
|
18
|
+
toJSON(): {
|
|
19
|
+
name: string;
|
|
20
|
+
code: string;
|
|
21
|
+
message: string;
|
|
22
|
+
details: Record<string, any>;
|
|
23
|
+
suggestion: string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export declare class ValidationError extends CliError {
|
|
27
|
+
constructor(message: string, details?: Record<string, any>);
|
|
28
|
+
}
|
|
29
|
+
export declare class FileNotFoundError extends CliError {
|
|
30
|
+
constructor(filePath: string);
|
|
31
|
+
}
|
|
32
|
+
export declare class FileExistsError extends CliError {
|
|
33
|
+
constructor(filePath: string);
|
|
34
|
+
}
|
|
35
|
+
export declare class ModuleNotFoundError extends CliError {
|
|
36
|
+
constructor(moduleName: string);
|
|
37
|
+
}
|
|
38
|
+
export declare class EntityNotFoundError extends CliError {
|
|
39
|
+
constructor(entityName: string, moduleName?: string);
|
|
40
|
+
}
|
|
41
|
+
export declare class InvalidFieldError extends CliError {
|
|
42
|
+
constructor(fieldStr: string, reason: string);
|
|
43
|
+
}
|
|
44
|
+
export declare class DuplicateEntityError extends CliError {
|
|
45
|
+
constructor(entityName: string, existingPath: string);
|
|
46
|
+
}
|
|
47
|
+
export declare class CircularDependencyError extends CliError {
|
|
48
|
+
constructor(chain: string[]);
|
|
49
|
+
}
|
|
50
|
+
export declare class TemplateError extends CliError {
|
|
51
|
+
constructor(templateName: string, reason: string);
|
|
52
|
+
}
|
|
53
|
+
export declare class ConfigurationError extends CliError {
|
|
54
|
+
constructor(message: string, configKey?: string);
|
|
55
|
+
}
|
|
56
|
+
export declare class RelationError extends CliError {
|
|
57
|
+
constructor(message: string, details?: Record<string, any>);
|
|
58
|
+
}
|
|
59
|
+
export declare class SchemaError extends CliError {
|
|
60
|
+
constructor(message: string, details?: Record<string, any>);
|
|
61
|
+
}
|
|
62
|
+
export declare class GenerationError extends CliError {
|
|
63
|
+
constructor(message: string, details?: Record<string, any>);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Error codes for structured error handling
|
|
67
|
+
*/
|
|
68
|
+
export declare const ErrorCodes: {
|
|
69
|
+
readonly VALIDATION_ERROR: "E1000";
|
|
70
|
+
readonly INVALID_FIELD: "E1001";
|
|
71
|
+
readonly INVALID_NAME: "E1002";
|
|
72
|
+
readonly INVALID_TYPE: "E1003";
|
|
73
|
+
readonly MISSING_REQUIRED: "E1004";
|
|
74
|
+
readonly SCHEMA_INVALID: "E1005";
|
|
75
|
+
readonly FILE_NOT_FOUND: "E2000";
|
|
76
|
+
readonly FILE_EXISTS: "E2001";
|
|
77
|
+
readonly FILE_WRITE_ERROR: "E2002";
|
|
78
|
+
readonly FILE_READ_ERROR: "E2003";
|
|
79
|
+
readonly DIRECTORY_NOT_FOUND: "E2004";
|
|
80
|
+
readonly ENTITY_NOT_FOUND: "E3000";
|
|
81
|
+
readonly DUPLICATE_ENTITY: "E3001";
|
|
82
|
+
readonly ENTITY_INVALID: "E3002";
|
|
83
|
+
readonly MODULE_NOT_FOUND: "E4000";
|
|
84
|
+
readonly DUPLICATE_MODULE: "E4001";
|
|
85
|
+
readonly MODULE_INVALID: "E4002";
|
|
86
|
+
readonly RELATION_ERROR: "E5000";
|
|
87
|
+
readonly CIRCULAR_DEPENDENCY: "E5001";
|
|
88
|
+
readonly INVALID_RELATION_TYPE: "E5002";
|
|
89
|
+
readonly MISSING_INVERSE_SIDE: "E5003";
|
|
90
|
+
readonly TEMPLATE_ERROR: "E6000";
|
|
91
|
+
readonly TEMPLATE_NOT_FOUND: "E6001";
|
|
92
|
+
readonly TEMPLATE_PARSE_ERROR: "E6002";
|
|
93
|
+
readonly CONFIGURATION_ERROR: "E7000";
|
|
94
|
+
readonly CONFIG_NOT_FOUND: "E7001";
|
|
95
|
+
readonly CONFIG_INVALID: "E7002";
|
|
96
|
+
readonly GENERATION_ERROR: "E8000";
|
|
97
|
+
readonly GENERATION_FAILED: "E8001";
|
|
98
|
+
readonly ROLLBACK_FAILED: "E8002";
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Error handler for consistent error output
|
|
102
|
+
*/
|
|
103
|
+
export interface ErrorHandler {
|
|
104
|
+
handle(error: Error): void;
|
|
105
|
+
format(error: Error): string;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Default error handler with chalk output
|
|
109
|
+
*/
|
|
110
|
+
export declare function createErrorHandler(options?: {
|
|
111
|
+
verbose?: boolean;
|
|
112
|
+
}): ErrorHandler;
|
|
113
|
+
/**
|
|
114
|
+
* Domain Exception Templates
|
|
115
|
+
* These are templates for generated domain exceptions
|
|
116
|
+
* SECURITY: Designed to prevent information disclosure (OWASP A01:2021)
|
|
117
|
+
*/
|
|
118
|
+
export declare const DomainExceptionTemplates: {
|
|
119
|
+
entityNotFound: (entityName: string) => string;
|
|
120
|
+
entityAlreadyExists: (entityName: string) => string;
|
|
121
|
+
validationFailed: (entityName: string) => string;
|
|
122
|
+
operationFailed: (entityName: string) => string;
|
|
123
|
+
domainException: (entityName: string) => string;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Generate domain exceptions for an entity
|
|
127
|
+
*/
|
|
128
|
+
export declare function generateDomainExceptions(entityName: string): string;
|
|
129
|
+
/**
|
|
130
|
+
* Error result type for operations that can fail
|
|
131
|
+
*/
|
|
132
|
+
export type Result<T, E = Error> = {
|
|
133
|
+
success: true;
|
|
134
|
+
data: T;
|
|
135
|
+
} | {
|
|
136
|
+
success: false;
|
|
137
|
+
error: E;
|
|
138
|
+
};
|
|
139
|
+
export declare function ok<T>(data: T): Result<T, never>;
|
|
140
|
+
export declare function err<E>(error: E): Result<never, E>;
|
|
141
|
+
/**
|
|
142
|
+
* Try-catch wrapper returning Result type
|
|
143
|
+
*/
|
|
144
|
+
export declare function tryAsync<T>(fn: () => Promise<T>): Promise<Result<T, Error>>;
|
|
145
|
+
export declare function trySync<T>(fn: () => T): Result<T, Error>;
|
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Unified Error & Exception Framework
|
|
4
|
+
* Provides centralized exception handling for CLI and generated code
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.DomainExceptionTemplates = exports.ErrorCodes = exports.GenerationError = exports.SchemaError = exports.RelationError = exports.ConfigurationError = exports.TemplateError = exports.CircularDependencyError = exports.DuplicateEntityError = exports.InvalidFieldError = exports.EntityNotFoundError = exports.ModuleNotFoundError = exports.FileExistsError = exports.FileNotFoundError = exports.ValidationError = exports.CliError = void 0;
|
|
8
|
+
exports.createErrorHandler = createErrorHandler;
|
|
9
|
+
exports.generateDomainExceptions = generateDomainExceptions;
|
|
10
|
+
exports.ok = ok;
|
|
11
|
+
exports.err = err;
|
|
12
|
+
exports.tryAsync = tryAsync;
|
|
13
|
+
exports.trySync = trySync;
|
|
14
|
+
/**
|
|
15
|
+
* Base CLI Error with error codes
|
|
16
|
+
*/
|
|
17
|
+
class CliError extends Error {
|
|
18
|
+
constructor(message, code, options) {
|
|
19
|
+
super(message);
|
|
20
|
+
this.name = 'CliError';
|
|
21
|
+
this.code = code;
|
|
22
|
+
this.details = options?.details;
|
|
23
|
+
this.suggestion = options?.suggestion;
|
|
24
|
+
this.cause = options?.cause;
|
|
25
|
+
}
|
|
26
|
+
toJSON() {
|
|
27
|
+
return {
|
|
28
|
+
name: this.name,
|
|
29
|
+
code: this.code,
|
|
30
|
+
message: this.message,
|
|
31
|
+
details: this.details,
|
|
32
|
+
suggestion: this.suggestion,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.CliError = CliError;
|
|
37
|
+
// Specific error classes
|
|
38
|
+
class ValidationError extends CliError {
|
|
39
|
+
constructor(message, details) {
|
|
40
|
+
super(message, 'VALIDATION_ERROR', { details });
|
|
41
|
+
this.name = 'ValidationError';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.ValidationError = ValidationError;
|
|
45
|
+
class FileNotFoundError extends CliError {
|
|
46
|
+
constructor(filePath) {
|
|
47
|
+
super(`File not found: ${filePath}`, 'FILE_NOT_FOUND', {
|
|
48
|
+
details: { filePath },
|
|
49
|
+
suggestion: `Ensure the file exists at the specified path`,
|
|
50
|
+
});
|
|
51
|
+
this.name = 'FileNotFoundError';
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.FileNotFoundError = FileNotFoundError;
|
|
55
|
+
class FileExistsError extends CliError {
|
|
56
|
+
constructor(filePath) {
|
|
57
|
+
super(`File already exists: ${filePath}`, 'FILE_EXISTS', {
|
|
58
|
+
details: { filePath },
|
|
59
|
+
suggestion: `Use --force to overwrite or choose a different name`,
|
|
60
|
+
});
|
|
61
|
+
this.name = 'FileExistsError';
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.FileExistsError = FileExistsError;
|
|
65
|
+
class ModuleNotFoundError extends CliError {
|
|
66
|
+
constructor(moduleName) {
|
|
67
|
+
super(`Module not found: ${moduleName}`, 'MODULE_NOT_FOUND', {
|
|
68
|
+
details: { moduleName },
|
|
69
|
+
suggestion: `Create the module first with: ddd g module ${moduleName}`,
|
|
70
|
+
});
|
|
71
|
+
this.name = 'ModuleNotFoundError';
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.ModuleNotFoundError = ModuleNotFoundError;
|
|
75
|
+
class EntityNotFoundError extends CliError {
|
|
76
|
+
constructor(entityName, moduleName) {
|
|
77
|
+
super(`Entity not found: ${entityName}`, 'ENTITY_NOT_FOUND', {
|
|
78
|
+
details: { entityName, moduleName },
|
|
79
|
+
suggestion: moduleName
|
|
80
|
+
? `Create the entity first with: ddd g entity ${entityName} -m ${moduleName}`
|
|
81
|
+
: `Create the entity first with: ddd g entity ${entityName}`,
|
|
82
|
+
});
|
|
83
|
+
this.name = 'EntityNotFoundError';
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.EntityNotFoundError = EntityNotFoundError;
|
|
87
|
+
class InvalidFieldError extends CliError {
|
|
88
|
+
constructor(fieldStr, reason) {
|
|
89
|
+
super(`Invalid field definition: ${fieldStr}`, 'INVALID_FIELD', {
|
|
90
|
+
details: { fieldStr, reason },
|
|
91
|
+
suggestion: `Use format: name:type:modifier (e.g., email:string:unique)`,
|
|
92
|
+
});
|
|
93
|
+
this.name = 'InvalidFieldError';
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.InvalidFieldError = InvalidFieldError;
|
|
97
|
+
class DuplicateEntityError extends CliError {
|
|
98
|
+
constructor(entityName, existingPath) {
|
|
99
|
+
super(`Entity already exists: ${entityName}`, 'DUPLICATE_ENTITY', {
|
|
100
|
+
details: { entityName, existingPath },
|
|
101
|
+
suggestion: `Use a different name or remove the existing entity first`,
|
|
102
|
+
});
|
|
103
|
+
this.name = 'DuplicateEntityError';
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
exports.DuplicateEntityError = DuplicateEntityError;
|
|
107
|
+
class CircularDependencyError extends CliError {
|
|
108
|
+
constructor(chain) {
|
|
109
|
+
super(`Circular dependency detected: ${chain.join(' -> ')}`, 'CIRCULAR_DEPENDENCY', {
|
|
110
|
+
details: { chain },
|
|
111
|
+
suggestion: `Break the cycle by introducing an interface or restructuring the modules`,
|
|
112
|
+
});
|
|
113
|
+
this.name = 'CircularDependencyError';
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.CircularDependencyError = CircularDependencyError;
|
|
117
|
+
class TemplateError extends CliError {
|
|
118
|
+
constructor(templateName, reason) {
|
|
119
|
+
super(`Template error in ${templateName}: ${reason}`, 'TEMPLATE_ERROR', {
|
|
120
|
+
details: { templateName, reason },
|
|
121
|
+
});
|
|
122
|
+
this.name = 'TemplateError';
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
exports.TemplateError = TemplateError;
|
|
126
|
+
class ConfigurationError extends CliError {
|
|
127
|
+
constructor(message, configKey) {
|
|
128
|
+
super(message, 'CONFIGURATION_ERROR', {
|
|
129
|
+
details: { configKey },
|
|
130
|
+
suggestion: `Check your .dddrc.json configuration file`,
|
|
131
|
+
});
|
|
132
|
+
this.name = 'ConfigurationError';
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
exports.ConfigurationError = ConfigurationError;
|
|
136
|
+
class RelationError extends CliError {
|
|
137
|
+
constructor(message, details) {
|
|
138
|
+
super(message, 'RELATION_ERROR', {
|
|
139
|
+
details,
|
|
140
|
+
suggestion: `Ensure both entities exist and relation types are compatible`,
|
|
141
|
+
});
|
|
142
|
+
this.name = 'RelationError';
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
exports.RelationError = RelationError;
|
|
146
|
+
class SchemaError extends CliError {
|
|
147
|
+
constructor(message, details) {
|
|
148
|
+
super(message, 'SCHEMA_ERROR', { details });
|
|
149
|
+
this.name = 'SchemaError';
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
exports.SchemaError = SchemaError;
|
|
153
|
+
class GenerationError extends CliError {
|
|
154
|
+
constructor(message, details) {
|
|
155
|
+
super(message, 'GENERATION_ERROR', { details });
|
|
156
|
+
this.name = 'GenerationError';
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
exports.GenerationError = GenerationError;
|
|
160
|
+
/**
|
|
161
|
+
* Error codes for structured error handling
|
|
162
|
+
*/
|
|
163
|
+
exports.ErrorCodes = {
|
|
164
|
+
// Validation errors (1xxx)
|
|
165
|
+
VALIDATION_ERROR: 'E1000',
|
|
166
|
+
INVALID_FIELD: 'E1001',
|
|
167
|
+
INVALID_NAME: 'E1002',
|
|
168
|
+
INVALID_TYPE: 'E1003',
|
|
169
|
+
MISSING_REQUIRED: 'E1004',
|
|
170
|
+
SCHEMA_INVALID: 'E1005',
|
|
171
|
+
// File errors (2xxx)
|
|
172
|
+
FILE_NOT_FOUND: 'E2000',
|
|
173
|
+
FILE_EXISTS: 'E2001',
|
|
174
|
+
FILE_WRITE_ERROR: 'E2002',
|
|
175
|
+
FILE_READ_ERROR: 'E2003',
|
|
176
|
+
DIRECTORY_NOT_FOUND: 'E2004',
|
|
177
|
+
// Entity errors (3xxx)
|
|
178
|
+
ENTITY_NOT_FOUND: 'E3000',
|
|
179
|
+
DUPLICATE_ENTITY: 'E3001',
|
|
180
|
+
ENTITY_INVALID: 'E3002',
|
|
181
|
+
// Module errors (4xxx)
|
|
182
|
+
MODULE_NOT_FOUND: 'E4000',
|
|
183
|
+
DUPLICATE_MODULE: 'E4001',
|
|
184
|
+
MODULE_INVALID: 'E4002',
|
|
185
|
+
// Relation errors (5xxx)
|
|
186
|
+
RELATION_ERROR: 'E5000',
|
|
187
|
+
CIRCULAR_DEPENDENCY: 'E5001',
|
|
188
|
+
INVALID_RELATION_TYPE: 'E5002',
|
|
189
|
+
MISSING_INVERSE_SIDE: 'E5003',
|
|
190
|
+
// Template errors (6xxx)
|
|
191
|
+
TEMPLATE_ERROR: 'E6000',
|
|
192
|
+
TEMPLATE_NOT_FOUND: 'E6001',
|
|
193
|
+
TEMPLATE_PARSE_ERROR: 'E6002',
|
|
194
|
+
// Configuration errors (7xxx)
|
|
195
|
+
CONFIGURATION_ERROR: 'E7000',
|
|
196
|
+
CONFIG_NOT_FOUND: 'E7001',
|
|
197
|
+
CONFIG_INVALID: 'E7002',
|
|
198
|
+
// Generation errors (8xxx)
|
|
199
|
+
GENERATION_ERROR: 'E8000',
|
|
200
|
+
GENERATION_FAILED: 'E8001',
|
|
201
|
+
ROLLBACK_FAILED: 'E8002',
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* Default error handler with chalk output
|
|
205
|
+
*/
|
|
206
|
+
function createErrorHandler(options = {}) {
|
|
207
|
+
return {
|
|
208
|
+
handle(error) {
|
|
209
|
+
console.error(this.format(error));
|
|
210
|
+
if (options.verbose && error.stack) {
|
|
211
|
+
console.error(error.stack);
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
format(error) {
|
|
215
|
+
if (error instanceof CliError) {
|
|
216
|
+
let msg = `Error [${error.code}]: ${error.message}`;
|
|
217
|
+
if (error.suggestion) {
|
|
218
|
+
msg += `\n Suggestion: ${error.suggestion}`;
|
|
219
|
+
}
|
|
220
|
+
if (options.verbose && error.details) {
|
|
221
|
+
msg += `\n Details: ${JSON.stringify(error.details, null, 2)}`;
|
|
222
|
+
}
|
|
223
|
+
return msg;
|
|
224
|
+
}
|
|
225
|
+
return `Error: ${error.message}`;
|
|
226
|
+
},
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Domain Exception Templates
|
|
231
|
+
* These are templates for generated domain exceptions
|
|
232
|
+
* SECURITY: Designed to prevent information disclosure (OWASP A01:2021)
|
|
233
|
+
*/
|
|
234
|
+
exports.DomainExceptionTemplates = {
|
|
235
|
+
entityNotFound: (entityName) => `
|
|
236
|
+
import { NotFoundException, Logger } from '@nestjs/common';
|
|
237
|
+
|
|
238
|
+
export class ${entityName}NotFoundException extends NotFoundException {
|
|
239
|
+
private readonly logger = new Logger(${entityName}NotFoundException.name);
|
|
240
|
+
|
|
241
|
+
constructor(id: string) {
|
|
242
|
+
// Don't expose internal IDs in production
|
|
243
|
+
const isProduction = process.env.NODE_ENV === 'production';
|
|
244
|
+
const message = isProduction
|
|
245
|
+
? '${entityName} not found'
|
|
246
|
+
: \`${entityName} with id \${id} not found\`;
|
|
247
|
+
|
|
248
|
+
super(message);
|
|
249
|
+
|
|
250
|
+
// Log the actual ID for debugging
|
|
251
|
+
this.logger.debug(\`${entityName} not found: \${id}\`);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
`,
|
|
255
|
+
entityAlreadyExists: (entityName) => `
|
|
256
|
+
import { ConflictException, Logger } from '@nestjs/common';
|
|
257
|
+
|
|
258
|
+
export class ${entityName}AlreadyExistsException extends ConflictException {
|
|
259
|
+
private readonly logger = new Logger(${entityName}AlreadyExistsException.name);
|
|
260
|
+
|
|
261
|
+
constructor(identifier: string) {
|
|
262
|
+
// Don't expose which field/value conflicts in production
|
|
263
|
+
const isProduction = process.env.NODE_ENV === 'production';
|
|
264
|
+
const message = isProduction
|
|
265
|
+
? '${entityName} already exists'
|
|
266
|
+
: \`${entityName} with identifier \${identifier} already exists\`;
|
|
267
|
+
|
|
268
|
+
super(message);
|
|
269
|
+
this.logger.debug(\`${entityName} conflict: \${identifier}\`);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
`,
|
|
273
|
+
validationFailed: (entityName) => `
|
|
274
|
+
import { BadRequestException, Logger } from '@nestjs/common';
|
|
275
|
+
|
|
276
|
+
export class ${entityName}ValidationException extends BadRequestException {
|
|
277
|
+
private readonly logger = new Logger(${entityName}ValidationException.name);
|
|
278
|
+
|
|
279
|
+
constructor(errors: string[]) {
|
|
280
|
+
// In production, provide generic message; in dev, show field errors
|
|
281
|
+
const isProduction = process.env.NODE_ENV === 'production';
|
|
282
|
+
const message = isProduction
|
|
283
|
+
? { message: 'Validation failed', errorCount: errors.length }
|
|
284
|
+
: { message: '${entityName} validation failed', errors };
|
|
285
|
+
|
|
286
|
+
super(message);
|
|
287
|
+
this.logger.debug(\`Validation errors: \${errors.join(', ')}\`);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
`,
|
|
291
|
+
operationFailed: (entityName) => `
|
|
292
|
+
import { InternalServerErrorException, Logger } from '@nestjs/common';
|
|
293
|
+
|
|
294
|
+
export class ${entityName}OperationFailedException extends InternalServerErrorException {
|
|
295
|
+
private readonly logger = new Logger(${entityName}OperationFailedException.name);
|
|
296
|
+
|
|
297
|
+
constructor(operation: string, reason?: string) {
|
|
298
|
+
// NEVER expose internal error details to client in production
|
|
299
|
+
const isProduction = process.env.NODE_ENV === 'production';
|
|
300
|
+
const clientMessage = isProduction
|
|
301
|
+
? 'An error occurred processing your request'
|
|
302
|
+
: \`${entityName} \${operation} failed\`;
|
|
303
|
+
|
|
304
|
+
super(clientMessage);
|
|
305
|
+
|
|
306
|
+
// Log the actual reason for debugging
|
|
307
|
+
this.logger.error(\`${entityName} \${operation} failed: \${reason || 'unknown'}\`);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
`,
|
|
311
|
+
domainException: (entityName) => `
|
|
312
|
+
import { HttpException, HttpStatus, Logger } from '@nestjs/common';
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Base domain exception with secure error handling
|
|
316
|
+
* Does not expose internal details in production
|
|
317
|
+
*/
|
|
318
|
+
export abstract class ${entityName}DomainException extends HttpException {
|
|
319
|
+
protected readonly logger = new Logger(${entityName}DomainException.name);
|
|
320
|
+
protected readonly isProduction = process.env.NODE_ENV === 'production';
|
|
321
|
+
|
|
322
|
+
constructor(
|
|
323
|
+
publicMessage: string,
|
|
324
|
+
internalMessage: string,
|
|
325
|
+
status: HttpStatus = HttpStatus.BAD_REQUEST
|
|
326
|
+
) {
|
|
327
|
+
// Use generic message in production
|
|
328
|
+
super(
|
|
329
|
+
process.env.NODE_ENV === 'production' ? publicMessage : internalMessage,
|
|
330
|
+
status
|
|
331
|
+
);
|
|
332
|
+
|
|
333
|
+
// Always log the internal message for debugging
|
|
334
|
+
this.logger.debug(internalMessage);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export class ${entityName}NotFoundException extends ${entityName}DomainException {
|
|
339
|
+
constructor(id: string) {
|
|
340
|
+
super(
|
|
341
|
+
'${entityName} not found',
|
|
342
|
+
\`${entityName} with id \${id} not found\`,
|
|
343
|
+
HttpStatus.NOT_FOUND
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
export class ${entityName}AlreadyExistsException extends ${entityName}DomainException {
|
|
349
|
+
constructor(field: string, value: string) {
|
|
350
|
+
super(
|
|
351
|
+
'${entityName} already exists',
|
|
352
|
+
\`${entityName} with \${field} '\${value}' already exists\`,
|
|
353
|
+
HttpStatus.CONFLICT
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
export class ${entityName}ValidationException extends ${entityName}DomainException {
|
|
359
|
+
constructor(errors: string[]) {
|
|
360
|
+
super(
|
|
361
|
+
'Validation failed',
|
|
362
|
+
\`Validation failed: \${errors.join(', ')}\`,
|
|
363
|
+
HttpStatus.BAD_REQUEST
|
|
364
|
+
);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
export class ${entityName}InvalidStateException extends ${entityName}DomainException {
|
|
369
|
+
constructor(currentState: string, expectedState: string) {
|
|
370
|
+
super(
|
|
371
|
+
'Operation not allowed',
|
|
372
|
+
\`Cannot perform operation: ${entityName} is in '\${currentState}' state, expected '\${expectedState}'\`,
|
|
373
|
+
HttpStatus.UNPROCESSABLE_ENTITY
|
|
374
|
+
);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
export class ${entityName}UnauthorizedException extends ${entityName}DomainException {
|
|
379
|
+
constructor(action: string) {
|
|
380
|
+
super(
|
|
381
|
+
'Unauthorized',
|
|
382
|
+
\`Unauthorized to \${action} ${entityName}\`,
|
|
383
|
+
HttpStatus.FORBIDDEN
|
|
384
|
+
);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
`,
|
|
388
|
+
};
|
|
389
|
+
/**
|
|
390
|
+
* Generate domain exceptions for an entity
|
|
391
|
+
*/
|
|
392
|
+
function generateDomainExceptions(entityName) {
|
|
393
|
+
return exports.DomainExceptionTemplates.domainException(entityName);
|
|
394
|
+
}
|
|
395
|
+
function ok(data) {
|
|
396
|
+
return { success: true, data };
|
|
397
|
+
}
|
|
398
|
+
function err(error) {
|
|
399
|
+
return { success: false, error };
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Try-catch wrapper returning Result type
|
|
403
|
+
*/
|
|
404
|
+
async function tryAsync(fn) {
|
|
405
|
+
try {
|
|
406
|
+
const data = await fn();
|
|
407
|
+
return ok(data);
|
|
408
|
+
}
|
|
409
|
+
catch (error) {
|
|
410
|
+
return err(error instanceof Error ? error : new Error(String(error)));
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
function trySync(fn) {
|
|
414
|
+
try {
|
|
415
|
+
const data = fn();
|
|
416
|
+
return ok(data);
|
|
417
|
+
}
|
|
418
|
+
catch (error) {
|
|
419
|
+
return err(error instanceof Error ? error : new Error(String(error)));
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
//# sourceMappingURL=error.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.utils.js","sourceRoot":"","sources":["../../src/utils/error.utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAgOH,gDAuBC;AA0KD,4DAEC;AASD,gBA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,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,GAAG,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACxE,CAAC;AACH,CAAC;AAED,SAAgB,OAAO,CAAI,EAAW;IACpC,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,EAAE,EAAE,CAAC;QAClB,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,GAAG,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACxE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export interface FieldDefinition {
|
|
2
|
+
name: string;
|
|
3
|
+
camelCase: string;
|
|
4
|
+
snakeCase: string;
|
|
5
|
+
pascalCase: string;
|
|
6
|
+
type: string;
|
|
7
|
+
tsType: string;
|
|
8
|
+
dbType: string;
|
|
9
|
+
prismaType: string;
|
|
10
|
+
isRequired: boolean;
|
|
11
|
+
isOptional: boolean;
|
|
12
|
+
isUnique: boolean;
|
|
13
|
+
isArray: boolean;
|
|
14
|
+
validators: string[];
|
|
15
|
+
description: string;
|
|
16
|
+
example?: string;
|
|
17
|
+
defaultValue?: string;
|
|
18
|
+
enumValues?: string[];
|
|
19
|
+
isRelation: boolean;
|
|
20
|
+
relationType?: 'OneToOne' | 'OneToMany' | 'ManyToOne' | 'ManyToMany';
|
|
21
|
+
relationTarget?: string;
|
|
22
|
+
relationInverse?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface ParsedFields {
|
|
25
|
+
fields: FieldDefinition[];
|
|
26
|
+
hasEmail: boolean;
|
|
27
|
+
hasDate: boolean;
|
|
28
|
+
hasEnum: boolean;
|
|
29
|
+
hasRelation: boolean;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Parse field definitions from CLI --fields flag
|
|
33
|
+
* Format: "name:type:modifier1:modifier2"
|
|
34
|
+
*
|
|
35
|
+
* Examples:
|
|
36
|
+
* "name:string" -> required string
|
|
37
|
+
* "email:string:unique" -> required unique string with IsEmail
|
|
38
|
+
* "age:number:optional" -> optional number
|
|
39
|
+
* "status:enum:active,inactive" -> enum with values
|
|
40
|
+
* "tags:string[]" -> string array
|
|
41
|
+
* "userId:uuid:relation" -> foreign key relation
|
|
42
|
+
*/
|
|
43
|
+
export declare function parseFields(fieldsString: string): ParsedFields;
|
|
44
|
+
/**
|
|
45
|
+
* Generate field-aware template data
|
|
46
|
+
*/
|
|
47
|
+
export declare function generateFieldsTemplateData(fields: FieldDefinition[]): {
|
|
48
|
+
entityProperties: string;
|
|
49
|
+
entityPropsInterface: string;
|
|
50
|
+
dtoProperties: string;
|
|
51
|
+
ormColumns: string;
|
|
52
|
+
migrationColumns: string;
|
|
53
|
+
responseProperties: string;
|
|
54
|
+
};
|