@carlonicora/nestjs-neo4jsonapi 1.5.1 → 1.7.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.
- package/dist/agents/community.detector/services/community.detector.service.d.ts.map +1 -1
- package/dist/agents/community.detector/services/community.detector.service.js.map +1 -1
- package/dist/bootstrap/app.module.factory.d.ts.map +1 -1
- package/dist/bootstrap/app.module.factory.js +23 -1
- package/dist/bootstrap/app.module.factory.js.map +1 -1
- package/dist/common/guards/index.d.ts +1 -1
- package/dist/common/guards/index.d.ts.map +1 -1
- package/dist/common/guards/index.js +1 -1
- package/dist/common/guards/index.js.map +1 -1
- package/dist/common/interfaces/entity.schema.interface.d.ts +10 -2
- package/dist/common/interfaces/entity.schema.interface.d.ts.map +1 -1
- package/dist/config/base.config.d.ts.map +1 -1
- package/dist/config/base.config.js +2 -0
- package/dist/config/base.config.js.map +1 -1
- package/dist/config/interfaces/config.discord.interface.d.ts +2 -0
- package/dist/config/interfaces/config.discord.interface.d.ts.map +1 -1
- package/dist/config/interfaces/index.d.ts +1 -0
- package/dist/config/interfaces/index.d.ts.map +1 -1
- package/dist/config/interfaces/index.js +1 -0
- package/dist/config/interfaces/index.js.map +1 -1
- package/dist/core/neo4j/abstracts/abstract.repository.d.ts.map +1 -1
- package/dist/core/neo4j/abstracts/abstract.repository.js +42 -6
- package/dist/core/neo4j/abstracts/abstract.repository.js.map +1 -1
- package/dist/foundations/auth/auth.module.js +2 -2
- package/dist/foundations/auth/auth.module.js.map +1 -1
- package/dist/foundations/auth/services/auth.discord.service.d.ts +3 -3
- package/dist/foundations/auth/services/auth.discord.service.d.ts.map +1 -1
- package/dist/foundations/auth/services/auth.discord.service.js +6 -25
- package/dist/foundations/auth/services/auth.discord.service.js.map +1 -1
- package/dist/foundations/company/repositories/company.repository.d.ts.map +1 -1
- package/dist/foundations/company/repositories/company.repository.js +77 -36
- package/dist/foundations/company/repositories/company.repository.js.map +1 -1
- package/dist/foundations/discord/discord.module.d.ts +3 -0
- package/dist/foundations/discord/discord.module.d.ts.map +1 -0
- package/dist/foundations/discord/discord.module.js +23 -0
- package/dist/foundations/discord/discord.module.js.map +1 -0
- package/dist/foundations/discord/index.d.ts +4 -0
- package/dist/foundations/discord/index.d.ts.map +1 -0
- package/dist/foundations/discord/index.js +20 -0
- package/dist/foundations/discord/index.js.map +1 -0
- package/dist/foundations/discord/serialisers/discord.error.serialiser.d.ts +8 -0
- package/dist/foundations/discord/serialisers/discord.error.serialiser.d.ts.map +1 -0
- package/dist/foundations/discord/serialisers/discord.error.serialiser.js +23 -0
- package/dist/foundations/discord/serialisers/discord.error.serialiser.js.map +1 -0
- package/dist/foundations/discord/services/discord.service.d.ts +11 -0
- package/dist/foundations/discord/services/discord.service.d.ts.map +1 -0
- package/dist/foundations/discord/services/discord.service.js +54 -0
- package/dist/foundations/discord/services/discord.service.js.map +1 -0
- package/dist/foundations/discord-user/discord-user.module.d.ts +3 -0
- package/dist/foundations/discord-user/discord-user.module.d.ts.map +1 -0
- package/dist/foundations/discord-user/{discord.module.js → discord-user.module.js} +4 -3
- package/dist/foundations/discord-user/discord-user.module.js.map +1 -0
- package/dist/foundations/discord-user/index.d.ts +5 -0
- package/dist/foundations/discord-user/index.d.ts.map +1 -0
- package/dist/foundations/discord-user/index.js +21 -0
- package/dist/foundations/discord-user/index.js.map +1 -0
- package/dist/foundations/discord-user/services/discord-user.service.d.ts +18 -0
- package/dist/foundations/discord-user/services/discord-user.service.d.ts.map +1 -0
- package/dist/foundations/discord-user/services/discord-user.service.js +59 -0
- package/dist/foundations/discord-user/services/discord-user.service.js.map +1 -0
- package/dist/foundations/discord-user/types/discord.user.type.d.ts +1 -1
- package/dist/foundations/discord-user/types/discord.user.type.d.ts.map +1 -1
- package/dist/foundations/foundations.modules.js +2 -2
- package/dist/foundations/foundations.modules.js.map +1 -1
- package/dist/foundations/index.d.ts +2 -0
- package/dist/foundations/index.d.ts.map +1 -1
- package/dist/foundations/index.js +2 -0
- package/dist/foundations/index.js.map +1 -1
- package/dist/scripts/generate-module/generator.d.ts.map +1 -1
- package/dist/scripts/generate-module/generator.js +21 -8
- package/dist/scripts/generate-module/generator.js.map +1 -1
- package/dist/scripts/generate-module/templates/controller.template.d.ts.map +1 -1
- package/dist/scripts/generate-module/templates/controller.template.js +40 -13
- package/dist/scripts/generate-module/templates/controller.template.js.map +1 -1
- package/dist/scripts/generate-module/templates/dto.post.template.d.ts.map +1 -1
- package/dist/scripts/generate-module/templates/dto.post.template.js +34 -13
- package/dist/scripts/generate-module/templates/dto.post.template.js.map +1 -1
- package/dist/scripts/generate-module/templates/dto.put.template.d.ts.map +1 -1
- package/dist/scripts/generate-module/templates/dto.put.template.js +34 -13
- package/dist/scripts/generate-module/templates/dto.put.template.js.map +1 -1
- package/dist/scripts/generate-module/templates/entity.template.d.ts.map +1 -1
- package/dist/scripts/generate-module/templates/entity.template.js +48 -24
- package/dist/scripts/generate-module/templates/entity.template.js.map +1 -1
- package/dist/scripts/generate-module/templates/meta.template.d.ts +12 -0
- package/dist/scripts/generate-module/templates/meta.template.d.ts.map +1 -0
- package/dist/scripts/generate-module/templates/meta.template.js +25 -0
- package/dist/scripts/generate-module/templates/meta.template.js.map +1 -0
- package/dist/scripts/generate-module/transformers/import-resolver.d.ts +70 -2
- package/dist/scripts/generate-module/transformers/import-resolver.d.ts.map +1 -1
- package/dist/scripts/generate-module/transformers/import-resolver.js +99 -4
- package/dist/scripts/generate-module/transformers/import-resolver.js.map +1 -1
- package/dist/scripts/generate-module/transformers/nested-route-generator.d.ts.map +1 -1
- package/dist/scripts/generate-module/transformers/nested-route-generator.js +13 -3
- package/dist/scripts/generate-module/transformers/nested-route-generator.js.map +1 -1
- package/dist/scripts/generate-module/transformers/relationship-mapper.d.ts +3 -3
- package/dist/scripts/generate-module/transformers/relationship-mapper.d.ts.map +1 -1
- package/dist/scripts/generate-module/transformers/relationship-mapper.js +33 -10
- package/dist/scripts/generate-module/transformers/relationship-mapper.js.map +1 -1
- package/dist/scripts/generate-module/types/template-data.interface.d.ts +7 -0
- package/dist/scripts/generate-module/types/template-data.interface.d.ts.map +1 -1
- package/dist/scripts/generate-module/utils/type-utils.d.ts +61 -0
- package/dist/scripts/generate-module/utils/type-utils.d.ts.map +1 -0
- package/dist/scripts/generate-module/utils/type-utils.js +205 -0
- package/dist/scripts/generate-module/utils/type-utils.js.map +1 -0
- package/dist/scripts/generate-module/validators/json-schema-validator.d.ts.map +1 -1
- package/dist/scripts/generate-module/validators/json-schema-validator.js +9 -0
- package/dist/scripts/generate-module/validators/json-schema-validator.js.map +1 -1
- package/package.json +8 -6
- package/dist/foundations/discord-user/discord.module.d.ts +0 -3
- package/dist/foundations/discord-user/discord.module.d.ts.map +0 -1
- package/dist/foundations/discord-user/discord.module.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meta.template.d.ts","sourceRoot":"","sources":["../../../../scripts/generate-module/templates/meta.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAEhE;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAY3D"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateMetaFile = generateMetaFile;
|
|
4
|
+
/**
|
|
5
|
+
* Generate meta file content
|
|
6
|
+
*
|
|
7
|
+
* Meta files contain lightweight metadata (type, endpoint, nodeName, labelName)
|
|
8
|
+
* that can be imported without causing circular dependencies.
|
|
9
|
+
*
|
|
10
|
+
* @param data - Template data
|
|
11
|
+
* @returns Generated TypeScript code for meta file
|
|
12
|
+
*/
|
|
13
|
+
function generateMetaFile(data) {
|
|
14
|
+
const { names, endpoint, nodeName, labelName } = data;
|
|
15
|
+
return `import { DataMeta } from "@carlonicora/nestjs-neo4jsonapi";
|
|
16
|
+
|
|
17
|
+
export const ${names.camelCase}Meta: DataMeta = {
|
|
18
|
+
type: "${endpoint}",
|
|
19
|
+
endpoint: "${endpoint}",
|
|
20
|
+
nodeName: "${nodeName}",
|
|
21
|
+
labelName: "${labelName}",
|
|
22
|
+
};
|
|
23
|
+
`;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=meta.template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meta.template.js","sourceRoot":"","sources":["../../../../scripts/generate-module/templates/meta.template.ts"],"names":[],"mappings":";;AAWA,4CAYC;AArBD;;;;;;;;GAQG;AACH,SAAgB,gBAAgB,CAAC,IAAkB;IACjD,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IAEtD,OAAO;;eAEM,KAAK,CAAC,SAAS;WACnB,QAAQ;eACJ,QAAQ;eACR,QAAQ;gBACP,SAAS;;CAExB,CAAC;AACF,CAAC"}
|
|
@@ -13,6 +13,47 @@ export declare const FOUNDATION_PACKAGE = "@carlonicora/nestjs-neo4jsonapi";
|
|
|
13
13
|
* isFoundationImport("features/campaign") // false
|
|
14
14
|
*/
|
|
15
15
|
export declare function isFoundationImport(directory: string): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Check if a related entity uses the NEW structure (Descriptor pattern)
|
|
18
|
+
*
|
|
19
|
+
* IMPORTANT: As of the circular dependency fix, we ALWAYS generate .meta.ts files
|
|
20
|
+
* for all entities. This means all entities now use the OLD structure (meta pattern)
|
|
21
|
+
* to avoid circular imports between entities that reference each other.
|
|
22
|
+
*
|
|
23
|
+
* @param params - Directory and module name of the related entity
|
|
24
|
+
* @returns Always false - all entities now use meta pattern
|
|
25
|
+
*
|
|
26
|
+
* @deprecated This function now always returns false. All entities use meta pattern.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isNewEntityStructure(params: {
|
|
29
|
+
directory: string;
|
|
30
|
+
moduleName: string;
|
|
31
|
+
}): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Get the model reference string for a relationship
|
|
34
|
+
*
|
|
35
|
+
* @param params - Entity name and structure type
|
|
36
|
+
* @returns Model reference string for use in relationship definition
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* getModelReference({ isNewStructure: false, entityName: "User", variantName: "owner" })
|
|
40
|
+
* // Returns: "ownerMeta"
|
|
41
|
+
*
|
|
42
|
+
* getModelReference({ isNewStructure: true, entityName: "Character" })
|
|
43
|
+
* // Returns: "CharacterDescriptor.model"
|
|
44
|
+
*/
|
|
45
|
+
export declare function getModelReference(params: {
|
|
46
|
+
isNewStructure: boolean;
|
|
47
|
+
entityName: string;
|
|
48
|
+
variantName?: string;
|
|
49
|
+
}): string;
|
|
50
|
+
/**
|
|
51
|
+
* Get the Descriptor name for NEW structure entities
|
|
52
|
+
*
|
|
53
|
+
* @param entityName - PascalCase entity name
|
|
54
|
+
* @returns Descriptor name (e.g., "CharacterDescriptor")
|
|
55
|
+
*/
|
|
56
|
+
export declare function getDescriptorName(entityName: string): string;
|
|
16
57
|
/**
|
|
17
58
|
* Resolve relative import path between two modules
|
|
18
59
|
*
|
|
@@ -48,13 +89,14 @@ export declare function resolveEntityImportPath(params: {
|
|
|
48
89
|
}): string;
|
|
49
90
|
/**
|
|
50
91
|
* Resolve import path for meta file
|
|
92
|
+
* Note: Controller files are in a controllers/ subdirectory, so we need extra ../ to get out first
|
|
51
93
|
*
|
|
52
94
|
* @param params - From and to module info
|
|
53
95
|
* @returns Import path to meta file
|
|
54
96
|
*
|
|
55
97
|
* @example
|
|
56
98
|
* resolveMetaImportPath({ fromDir: "features", fromModule: "comment", toDir: "foundations", toModule: "user" })
|
|
57
|
-
* // Returns: "
|
|
99
|
+
* // Returns: "../../../foundations/user/entities/user.meta" (from comment/controllers/ to user/entities/)
|
|
58
100
|
*/
|
|
59
101
|
export declare function resolveMetaImportPath(params: {
|
|
60
102
|
fromDir: string;
|
|
@@ -64,13 +106,14 @@ export declare function resolveMetaImportPath(params: {
|
|
|
64
106
|
}): string;
|
|
65
107
|
/**
|
|
66
108
|
* Resolve import path for DTO file
|
|
109
|
+
* Note: DTO files are in a dtos/ subdirectory, so we need extra ../ to get out first
|
|
67
110
|
*
|
|
68
111
|
* @param params - From and to module info
|
|
69
112
|
* @returns Import path to DTO file
|
|
70
113
|
*
|
|
71
114
|
* @example
|
|
72
115
|
* resolveDtoImportPath({ fromDir: "features", fromModule: "comment", toDir: "features", toModule: "discussion" })
|
|
73
|
-
* // Returns: "
|
|
116
|
+
* // Returns: "../../discussion/dtos/discussion.dto" (from comment/dtos/ to discussion/dtos/)
|
|
74
117
|
*/
|
|
75
118
|
export declare function resolveDtoImportPath(params: {
|
|
76
119
|
fromDir: string;
|
|
@@ -90,4 +133,29 @@ export declare function resolveDtoImportPath(params: {
|
|
|
90
133
|
* // Returns: "../entities/comment"
|
|
91
134
|
*/
|
|
92
135
|
export declare function resolveModuleInternalPath(subpath: string): string;
|
|
136
|
+
/**
|
|
137
|
+
* Resolve import path for NEW structure entity file
|
|
138
|
+
* NEW structure uses absolute paths from src and no .entity suffix
|
|
139
|
+
*
|
|
140
|
+
* @param params - Directory and module info
|
|
141
|
+
* @returns Absolute import path for entity (e.g., "src/features/character/entities/character")
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* resolveNewEntityImportPath({ directory: "features", moduleName: "character" })
|
|
145
|
+
* // Returns: "src/features/character/entities/character"
|
|
146
|
+
*/
|
|
147
|
+
export declare function resolveNewEntityImportPath(params: {
|
|
148
|
+
directory: string;
|
|
149
|
+
moduleName: string;
|
|
150
|
+
}): string;
|
|
151
|
+
/**
|
|
152
|
+
* Resolve import path for NEW structure DTO file
|
|
153
|
+
*
|
|
154
|
+
* @param params - Directory and module info
|
|
155
|
+
* @returns Absolute import path for DTO (e.g., "src/features/character/dtos/character.dto")
|
|
156
|
+
*/
|
|
157
|
+
export declare function resolveNewDtoImportPath(params: {
|
|
158
|
+
directory: string;
|
|
159
|
+
moduleName: string;
|
|
160
|
+
}): string;
|
|
93
161
|
//# sourceMappingURL=import-resolver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-resolver.d.ts","sourceRoot":"","sources":["../../../../scripts/generate-module/transformers/import-resolver.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"import-resolver.d.ts","sourceRoot":"","sources":["../../../../scripts/generate-module/transformers/import-resolver.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,kBAAkB,oCAAoC,CAAC;AAEpE;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAE7D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAK/F;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IACxC,cAAc,EAAE,OAAO,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,MAAM,CAUT;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,MAAM,CAgBT;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,MAAM,CAGT;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,MAAM,CAIT;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,MAAM,CAIT;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEjE;AAMD;;;;;;;;;;GAUG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CASpG;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAQjG"}
|
|
@@ -2,11 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FOUNDATION_PACKAGE = void 0;
|
|
4
4
|
exports.isFoundationImport = isFoundationImport;
|
|
5
|
+
exports.isNewEntityStructure = isNewEntityStructure;
|
|
6
|
+
exports.getModelReference = getModelReference;
|
|
7
|
+
exports.getDescriptorName = getDescriptorName;
|
|
5
8
|
exports.resolveImportPath = resolveImportPath;
|
|
6
9
|
exports.resolveEntityImportPath = resolveEntityImportPath;
|
|
7
10
|
exports.resolveMetaImportPath = resolveMetaImportPath;
|
|
8
11
|
exports.resolveDtoImportPath = resolveDtoImportPath;
|
|
9
12
|
exports.resolveModuleInternalPath = resolveModuleInternalPath;
|
|
13
|
+
exports.resolveNewEntityImportPath = resolveNewEntityImportPath;
|
|
14
|
+
exports.resolveNewDtoImportPath = resolveNewDtoImportPath;
|
|
10
15
|
/**
|
|
11
16
|
* Foundation package name constant
|
|
12
17
|
*/
|
|
@@ -24,6 +29,57 @@ exports.FOUNDATION_PACKAGE = "@carlonicora/nestjs-neo4jsonapi";
|
|
|
24
29
|
function isFoundationImport(directory) {
|
|
25
30
|
return directory === "@foundation" || directory.startsWith("@foundation/");
|
|
26
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Check if a related entity uses the NEW structure (Descriptor pattern)
|
|
34
|
+
*
|
|
35
|
+
* IMPORTANT: As of the circular dependency fix, we ALWAYS generate .meta.ts files
|
|
36
|
+
* for all entities. This means all entities now use the OLD structure (meta pattern)
|
|
37
|
+
* to avoid circular imports between entities that reference each other.
|
|
38
|
+
*
|
|
39
|
+
* @param params - Directory and module name of the related entity
|
|
40
|
+
* @returns Always false - all entities now use meta pattern
|
|
41
|
+
*
|
|
42
|
+
* @deprecated This function now always returns false. All entities use meta pattern.
|
|
43
|
+
*/
|
|
44
|
+
function isNewEntityStructure(params) {
|
|
45
|
+
// Always return false - we now generate .meta.ts files for ALL entities
|
|
46
|
+
// This prevents circular dependencies when entities reference each other
|
|
47
|
+
void params; // Suppress unused parameter warning
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get the model reference string for a relationship
|
|
52
|
+
*
|
|
53
|
+
* @param params - Entity name and structure type
|
|
54
|
+
* @returns Model reference string for use in relationship definition
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* getModelReference({ isNewStructure: false, entityName: "User", variantName: "owner" })
|
|
58
|
+
* // Returns: "ownerMeta"
|
|
59
|
+
*
|
|
60
|
+
* getModelReference({ isNewStructure: true, entityName: "Character" })
|
|
61
|
+
* // Returns: "CharacterDescriptor.model"
|
|
62
|
+
*/
|
|
63
|
+
function getModelReference(params) {
|
|
64
|
+
const { isNewStructure, entityName, variantName } = params;
|
|
65
|
+
if (isNewStructure) {
|
|
66
|
+
return `${entityName}Descriptor.model`;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
// OLD structure: use variant name if provided, otherwise entity name
|
|
70
|
+
const baseName = variantName || entityName;
|
|
71
|
+
return `${baseName.charAt(0).toLowerCase()}${baseName.slice(1)}Meta`;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get the Descriptor name for NEW structure entities
|
|
76
|
+
*
|
|
77
|
+
* @param entityName - PascalCase entity name
|
|
78
|
+
* @returns Descriptor name (e.g., "CharacterDescriptor")
|
|
79
|
+
*/
|
|
80
|
+
function getDescriptorName(entityName) {
|
|
81
|
+
return `${entityName}Descriptor`;
|
|
82
|
+
}
|
|
27
83
|
/**
|
|
28
84
|
* Resolve relative import path between two modules
|
|
29
85
|
*
|
|
@@ -65,31 +121,35 @@ function resolveEntityImportPath(params) {
|
|
|
65
121
|
}
|
|
66
122
|
/**
|
|
67
123
|
* Resolve import path for meta file
|
|
124
|
+
* Note: Controller files are in a controllers/ subdirectory, so we need extra ../ to get out first
|
|
68
125
|
*
|
|
69
126
|
* @param params - From and to module info
|
|
70
127
|
* @returns Import path to meta file
|
|
71
128
|
*
|
|
72
129
|
* @example
|
|
73
130
|
* resolveMetaImportPath({ fromDir: "features", fromModule: "comment", toDir: "foundations", toModule: "user" })
|
|
74
|
-
* // Returns: "
|
|
131
|
+
* // Returns: "../../../foundations/user/entities/user.meta" (from comment/controllers/ to user/entities/)
|
|
75
132
|
*/
|
|
76
133
|
function resolveMetaImportPath(params) {
|
|
134
|
+
// Controller files are in module/controllers/, so add ../ to get out of controllers/ subdirectory
|
|
77
135
|
const basePath = resolveImportPath(params);
|
|
78
|
-
return
|
|
136
|
+
return `../${basePath}/entities/${params.toModule}.meta`;
|
|
79
137
|
}
|
|
80
138
|
/**
|
|
81
139
|
* Resolve import path for DTO file
|
|
140
|
+
* Note: DTO files are in a dtos/ subdirectory, so we need extra ../ to get out first
|
|
82
141
|
*
|
|
83
142
|
* @param params - From and to module info
|
|
84
143
|
* @returns Import path to DTO file
|
|
85
144
|
*
|
|
86
145
|
* @example
|
|
87
146
|
* resolveDtoImportPath({ fromDir: "features", fromModule: "comment", toDir: "features", toModule: "discussion" })
|
|
88
|
-
* // Returns: "
|
|
147
|
+
* // Returns: "../../discussion/dtos/discussion.dto" (from comment/dtos/ to discussion/dtos/)
|
|
89
148
|
*/
|
|
90
149
|
function resolveDtoImportPath(params) {
|
|
150
|
+
// DTO files are in module/dtos/, so add ../ to get out of dtos/ subdirectory
|
|
91
151
|
const basePath = resolveImportPath(params);
|
|
92
|
-
return
|
|
152
|
+
return `../${basePath}/dtos/${params.toModule}.dto`;
|
|
93
153
|
}
|
|
94
154
|
/**
|
|
95
155
|
* Resolve import path relative to module root
|
|
@@ -105,4 +165,39 @@ function resolveDtoImportPath(params) {
|
|
|
105
165
|
function resolveModuleInternalPath(subpath) {
|
|
106
166
|
return `../${subpath}`;
|
|
107
167
|
}
|
|
168
|
+
// ============================================================================
|
|
169
|
+
// NEW Structure Import Path Functions
|
|
170
|
+
// ============================================================================
|
|
171
|
+
/**
|
|
172
|
+
* Resolve import path for NEW structure entity file
|
|
173
|
+
* NEW structure uses absolute paths from src and no .entity suffix
|
|
174
|
+
*
|
|
175
|
+
* @param params - Directory and module info
|
|
176
|
+
* @returns Absolute import path for entity (e.g., "src/features/character/entities/character")
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* resolveNewEntityImportPath({ directory: "features", moduleName: "character" })
|
|
180
|
+
* // Returns: "src/features/character/entities/character"
|
|
181
|
+
*/
|
|
182
|
+
function resolveNewEntityImportPath(params) {
|
|
183
|
+
const { directory, moduleName } = params;
|
|
184
|
+
if (isFoundationImport(directory)) {
|
|
185
|
+
// Foundation: use package path (when foundations are migrated to NEW structure)
|
|
186
|
+
return `src/foundations/${moduleName}/entities/${moduleName}`;
|
|
187
|
+
}
|
|
188
|
+
return `src/${directory}/${moduleName}/entities/${moduleName}`;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Resolve import path for NEW structure DTO file
|
|
192
|
+
*
|
|
193
|
+
* @param params - Directory and module info
|
|
194
|
+
* @returns Absolute import path for DTO (e.g., "src/features/character/dtos/character.dto")
|
|
195
|
+
*/
|
|
196
|
+
function resolveNewDtoImportPath(params) {
|
|
197
|
+
const { directory, moduleName } = params;
|
|
198
|
+
if (isFoundationImport(directory)) {
|
|
199
|
+
return `src/foundations/${moduleName}/dtos/${moduleName}.dto`;
|
|
200
|
+
}
|
|
201
|
+
return `src/${directory}/${moduleName}/dtos/${moduleName}.dto`;
|
|
202
|
+
}
|
|
108
203
|
//# sourceMappingURL=import-resolver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-resolver.js","sourceRoot":"","sources":["../../../../scripts/generate-module/transformers/import-resolver.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"import-resolver.js","sourceRoot":"","sources":["../../../../scripts/generate-module/transformers/import-resolver.ts"],"names":[],"mappings":";;;AAiBA,gDAEC;AAcD,oDAKC;AAeD,8CAcC;AAQD,8CAEC;AAaD,8CAqBC;AAYD,0DAQC;AAaD,sDASC;AAaD,oDASC;AAaD,8DAEC;AAiBD,gEASC;AAQD,0DAQC;AAtOD;;GAEG;AACU,QAAA,kBAAkB,GAAG,iCAAiC,CAAC;AAEpE;;;;;;;;;GASG;AACH,SAAgB,kBAAkB,CAAC,SAAiB;IAClD,OAAO,SAAS,KAAK,aAAa,IAAI,SAAS,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;AAC7E,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,oBAAoB,CAAC,MAAiD;IACpF,wEAAwE;IACxE,yEAAyE;IACzE,KAAK,MAAM,CAAC,CAAC,oCAAoC;IACjD,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1 @@
|
|
|
1
|
-
{"version":3,"file":"nested-route-generator.d.ts","sourceRoot":"","sources":["../../../../scripts/generate-module/transformers/nested-route-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAGvF;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,sBAAsB,EAAE,EACvC,UAAU,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACjD,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"nested-route-generator.d.ts","sourceRoot":"","sources":["../../../../scripts/generate-module/transformers/nested-route-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAGvF;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,sBAAsB,EAAE,EACvC,UAAU,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACjD,WAAW,EAAE,CA2Cf;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,sBAAsB,GAAG,OAAO,CAG9E"}
|
|
@@ -26,10 +26,16 @@ function generateNestedRoutes(relationships, thisEntity) {
|
|
|
26
26
|
.map((rel) => {
|
|
27
27
|
const relatedName = rel.relatedEntity.camelCase;
|
|
28
28
|
const relatedMeta = rel.model;
|
|
29
|
+
// For NEW structure, the endpoint is accessed via Descriptor.model.endpoint
|
|
30
|
+
// For OLD structure, it's accessed via meta.endpoint
|
|
31
|
+
const endpointAccess = rel.isNewStructure ? `${rel.descriptorName}.model.endpoint` : `${relatedMeta}.endpoint`;
|
|
32
|
+
// The current entity's Descriptor name (PascalCase)
|
|
33
|
+
const thisEntityDescriptor = `${(0, name_transformer_1.toPascalCase)(thisEntity.nodeName)}Descriptor`;
|
|
29
34
|
return {
|
|
30
35
|
// Path template using descriptor endpoint
|
|
31
|
-
//
|
|
32
|
-
|
|
36
|
+
// OLD: ${discussionMeta.endpoint}/:discussionId/${CommentDescriptor.model.endpoint}
|
|
37
|
+
// NEW: ${CharacterDescriptor.model.endpoint}/:characterId/${AttributeDescriptor.model.endpoint}
|
|
38
|
+
path: `\${${endpointAccess}}/:${relatedName}Id/\${${thisEntityDescriptor}.model.endpoint}`,
|
|
33
39
|
// Method name: findByDiscussion, findByTopic, etc.
|
|
34
40
|
methodName: `findBy${(0, name_transformer_1.toPascalCase)(rel.key)}`,
|
|
35
41
|
// Relationship key used in findByRelated call
|
|
@@ -37,8 +43,12 @@ function generateNestedRoutes(relationships, thisEntity) {
|
|
|
37
43
|
relationshipKey: rel.key,
|
|
38
44
|
// Parameter name in route: discussionId, topicId, etc.
|
|
39
45
|
paramName: `${relatedName}Id`,
|
|
40
|
-
// Meta import name
|
|
46
|
+
// Meta import name (for OLD structure) or endpoint access expression
|
|
41
47
|
relatedMeta: relatedMeta,
|
|
48
|
+
// NEW structure support
|
|
49
|
+
isNewStructure: rel.isNewStructure,
|
|
50
|
+
descriptorName: rel.descriptorName,
|
|
51
|
+
importPath: rel.importPath,
|
|
42
52
|
};
|
|
43
53
|
});
|
|
44
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nested-route-generator.js","sourceRoot":"","sources":["../../../../scripts/generate-module/transformers/nested-route-generator.ts"],"names":[],"mappings":";;AAgBA,
|
|
1
|
+
{"version":3,"file":"nested-route-generator.js","sourceRoot":"","sources":["../../../../scripts/generate-module/transformers/nested-route-generator.ts"],"names":[],"mappings":";;AAgBA,oDA8CC;AAQD,8DAGC;AAxED,yDAAkD;AAElD;;;;;;;;;;;;GAYG;AACH,SAAgB,oBAAoB,CAClC,aAAuC,EACvC,UAAkD;IAElD,OAAO,aAAa;SACjB,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE;QACd,mDAAmD;QACnD,gDAAgD;QAChD,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;IACzB,CAAC,CAAC;SACD,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;QACX,MAAM,WAAW,GAAG,GAAG,CAAC,aAAa,CAAC,SAAS,CAAC;QAChD,MAAM,WAAW,GAAG,GAAG,CAAC,KAAK,CAAC;QAE9B,4EAA4E;QAC5E,qDAAqD;QACrD,MAAM,cAAc,GAAG,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,cAAc,iBAAiB,CAAC,CAAC,CAAC,GAAG,WAAW,WAAW,CAAC;QAE/G,oDAAoD;QACpD,MAAM,oBAAoB,GAAG,GAAG,IAAA,+BAAY,EAAC,UAAU,CAAC,QAAQ,CAAC,YAAY,CAAC;QAE9E,OAAO;YACL,0CAA0C;YAC1C,oFAAoF;YACpF,gGAAgG;YAChG,IAAI,EAAE,MAAM,cAAc,MAAM,WAAW,SAAS,oBAAoB,kBAAkB;YAE1F,mDAAmD;YACnD,UAAU,EAAE,SAAS,IAAA,+BAAY,EAAC,GAAG,CAAC,GAAG,CAAC,EAAE;YAE5C,8CAA8C;YAC9C,uDAAuD;YACvD,eAAe,EAAE,GAAG,CAAC,GAAG;YAExB,uDAAuD;YACvD,SAAS,EAAE,GAAG,WAAW,IAAI;YAE7B,qEAAqE;YACrE,WAAW,EAAE,WAAW;YAExB,wBAAwB;YACxB,cAAc,EAAE,GAAG,CAAC,cAAc;YAClC,cAAc,EAAE,GAAG,CAAC,cAAc;YAClC,UAAU,EAAE,GAAG,CAAC,UAAU;SAC3B,CAAC;IACJ,CAAC,CAAC,CAAC;AACP,CAAC;AAED;;;;;GAKG;AACH,SAAgB,yBAAyB,CAAC,GAA2B;IACnE,uDAAuD;IACvD,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;AACzB,CAAC"}
|
|
@@ -4,12 +4,12 @@ import { DescriptorRelationship } from "../types/template-data.interface";
|
|
|
4
4
|
* Map JSON relationship definition to descriptor relationship
|
|
5
5
|
*
|
|
6
6
|
* Key mappings:
|
|
7
|
-
* - toNode: true → direction: "
|
|
8
|
-
* - toNode: false → direction: "
|
|
7
|
+
* - toNode: true → direction: "out" (relationship FROM this entity TO related)
|
|
8
|
+
* - toNode: false → direction: "in" (relationship FROM related TO this entity)
|
|
9
9
|
* - single: true → cardinality: "one"
|
|
10
10
|
* - single: false → cardinality: "many"
|
|
11
11
|
* - variant: "Author" → contextKey: "userId"
|
|
12
|
-
* - variant: other → dtoKey:
|
|
12
|
+
* - variant: other → dtoKey: singular/plural based on cardinality
|
|
13
13
|
*
|
|
14
14
|
* @param rel - JSON relationship definition
|
|
15
15
|
* @returns Descriptor relationship configuration
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relationship-mapper.d.ts","sourceRoot":"","sources":["../../../../scripts/generate-module/transformers/relationship-mapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"relationship-mapper.d.ts","sourceRoot":"","sources":["../../../../scripts/generate-module/transformers/relationship-mapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAS1E;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,0BAA0B,GAAG,sBAAsB,CAsEvF;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,0BAA0B,EAAE,GAAG,sBAAsB,EAAE,CAEtG;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,sBAAsB,EAAE,GAAG,MAAM,EAAE,CAGtF;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,aAAa,EAAE,sBAAsB,EAAE,GAAG,MAAM,EAAE,CAGxF"}
|
|
@@ -5,23 +5,24 @@ exports.mapRelationships = mapRelationships;
|
|
|
5
5
|
exports.getUniqueMetaImports = getUniqueMetaImports;
|
|
6
6
|
exports.getUniqueEntityImports = getUniqueEntityImports;
|
|
7
7
|
const name_transformer_1 = require("./name-transformer");
|
|
8
|
+
const import_resolver_1 = require("./import-resolver");
|
|
8
9
|
/**
|
|
9
10
|
* Map JSON relationship definition to descriptor relationship
|
|
10
11
|
*
|
|
11
12
|
* Key mappings:
|
|
12
|
-
* - toNode: true → direction: "
|
|
13
|
-
* - toNode: false → direction: "
|
|
13
|
+
* - toNode: true → direction: "out" (relationship FROM this entity TO related)
|
|
14
|
+
* - toNode: false → direction: "in" (relationship FROM related TO this entity)
|
|
14
15
|
* - single: true → cardinality: "one"
|
|
15
16
|
* - single: false → cardinality: "many"
|
|
16
17
|
* - variant: "Author" → contextKey: "userId"
|
|
17
|
-
* - variant: other → dtoKey:
|
|
18
|
+
* - variant: other → dtoKey: singular/plural based on cardinality
|
|
18
19
|
*
|
|
19
20
|
* @param rel - JSON relationship definition
|
|
20
21
|
* @returns Descriptor relationship configuration
|
|
21
22
|
*/
|
|
22
23
|
function mapRelationship(rel) {
|
|
23
24
|
// Core mappings
|
|
24
|
-
const direction = rel.toNode ? "
|
|
25
|
+
const direction = rel.toNode ? "out" : "in";
|
|
25
26
|
const cardinality = rel.single ? "one" : "many";
|
|
26
27
|
// Determine contextKey and dtoKey based on variant
|
|
27
28
|
let contextKey;
|
|
@@ -31,19 +32,38 @@ function mapRelationship(rel) {
|
|
|
31
32
|
contextKey = "userId";
|
|
32
33
|
}
|
|
33
34
|
else if (rel.variant) {
|
|
34
|
-
// Other variants: use variant name as dtoKey
|
|
35
|
-
|
|
35
|
+
// Other variants: use variant name as dtoKey
|
|
36
|
+
// Pluralize only for "many" cardinality
|
|
37
|
+
dtoKey = rel.single ? rel.variant.toLowerCase() : (0, name_transformer_1.pluralize)(rel.variant.toLowerCase());
|
|
36
38
|
}
|
|
37
39
|
else {
|
|
38
|
-
// No variant: use entity name as dtoKey
|
|
39
|
-
|
|
40
|
+
// No variant: use entity name as dtoKey
|
|
41
|
+
// Pluralize only for "many" cardinality
|
|
42
|
+
dtoKey = rel.single ? rel.name.toLowerCase() : (0, name_transformer_1.pluralize)(rel.name.toLowerCase());
|
|
40
43
|
}
|
|
41
44
|
// Determine relationship key (what it's called in the descriptor)
|
|
42
45
|
const key = (0, name_transformer_1.toCamelCase)(rel.variant || rel.name);
|
|
43
|
-
// Meta import name (e.g., "userMeta", "discussionMeta")
|
|
44
|
-
const model = `${(0, name_transformer_1.toCamelCase)(rel.name)}Meta`;
|
|
45
46
|
// Related entity name transformations
|
|
46
47
|
const relatedEntityNames = (0, name_transformer_1.transformNames)(rel.name, (0, name_transformer_1.pluralize)(rel.name.toLowerCase()));
|
|
48
|
+
// Detect if related entity uses NEW structure (Descriptor pattern)
|
|
49
|
+
const isNewStructure = (0, import_resolver_1.isNewEntityStructure)({
|
|
50
|
+
directory: rel.directory,
|
|
51
|
+
moduleName: relatedEntityNames.kebabCase,
|
|
52
|
+
});
|
|
53
|
+
// Get model reference based on structure type
|
|
54
|
+
const model = (0, import_resolver_1.getModelReference)({
|
|
55
|
+
isNewStructure,
|
|
56
|
+
entityName: rel.name,
|
|
57
|
+
variantName: rel.variant,
|
|
58
|
+
});
|
|
59
|
+
// NEW structure specific fields
|
|
60
|
+
const descriptorName = isNewStructure ? (0, import_resolver_1.getDescriptorName)(rel.name) : undefined;
|
|
61
|
+
const importPath = isNewStructure
|
|
62
|
+
? (0, import_resolver_1.resolveNewEntityImportPath)({
|
|
63
|
+
directory: rel.directory,
|
|
64
|
+
moduleName: relatedEntityNames.kebabCase,
|
|
65
|
+
})
|
|
66
|
+
: undefined;
|
|
47
67
|
return {
|
|
48
68
|
key,
|
|
49
69
|
model,
|
|
@@ -60,6 +80,9 @@ function mapRelationship(rel) {
|
|
|
60
80
|
camelCase: relatedEntityNames.camelCase,
|
|
61
81
|
kebabCase: relatedEntityNames.kebabCase,
|
|
62
82
|
},
|
|
83
|
+
isNewStructure,
|
|
84
|
+
descriptorName,
|
|
85
|
+
importPath,
|
|
63
86
|
};
|
|
64
87
|
}
|
|
65
88
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relationship-mapper.js","sourceRoot":"","sources":["../../../../scripts/generate-module/transformers/relationship-mapper.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"relationship-mapper.js","sourceRoot":"","sources":["../../../../scripts/generate-module/transformers/relationship-mapper.ts"],"names":[],"mappings":";;AAwBA,0CAsEC;AAQD,4CAEC;AASD,oDAGC;AAQD,wDAGC;AA7HD,yDAA4E;AAC5E,uDAK2B;AAE3B;;;;;;;;;;;;;GAaG;AACH,SAAgB,eAAe,CAAC,GAA+B;IAC7D,gBAAgB;IAChB,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IAC5C,MAAM,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;IAEhD,mDAAmD;IACnD,IAAI,UAA8B,CAAC;IACnC,IAAI,MAA0B,CAAC;IAE/B,IAAI,GAAG,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC7B,+CAA+C;QAC/C,UAAU,GAAG,QAAQ,CAAC;IACxB,CAAC;SAAM,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;QACvB,6CAA6C;QAC7C,wCAAwC;QACxC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,IAAA,4BAAS,EAAC,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IACzF,CAAC;SAAM,CAAC;QACN,wCAAwC;QACxC,wCAAwC;QACxC,M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AC,QAAQ;QACtB,aAAa,EAAE;YACb,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,UAAU,EAAE,kBAAkB,CAAC,UAAU;YACzC,SAAS,EAAE,kBAAkB,CAAC,SAAS;YACvC,SAAS,EAAE,kBAAkB,CAAC,SAAS;SACxC;QACD,cAAc;QACd,cAAc;QACd,UAAU;KACX,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAgB,gBAAgB,CAAC,aAA2C;IAC1E,OAAO,aAAa,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AAC5C,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAAC,aAAuC;IAC1E,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/D,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;AACpC,CAAC;AAED;;;;;GAKG;AACH,SAAgB,sBAAsB,CAAC,aAAuC;IAC5E,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9E,OAAO,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,CAAC;AACtC,CAAC"}
|
|
@@ -47,6 +47,9 @@ export interface DescriptorRelationship {
|
|
|
47
47
|
camelCase: string;
|
|
48
48
|
kebabCase: string;
|
|
49
49
|
};
|
|
50
|
+
isNewStructure: boolean;
|
|
51
|
+
descriptorName?: string;
|
|
52
|
+
importPath?: string;
|
|
50
53
|
}
|
|
51
54
|
/**
|
|
52
55
|
* Nested route configuration
|
|
@@ -57,6 +60,9 @@ export interface NestedRoute {
|
|
|
57
60
|
relationshipKey: string;
|
|
58
61
|
paramName: string;
|
|
59
62
|
relatedMeta: string;
|
|
63
|
+
isNewStructure: boolean;
|
|
64
|
+
descriptorName?: string;
|
|
65
|
+
importPath?: string;
|
|
60
66
|
}
|
|
61
67
|
/**
|
|
62
68
|
* DTO field configuration
|
|
@@ -76,6 +82,7 @@ export interface DTORelationship {
|
|
|
76
82
|
isList: boolean;
|
|
77
83
|
isOptional: boolean;
|
|
78
84
|
importPath: string;
|
|
85
|
+
isNewStructure: boolean;
|
|
79
86
|
}
|
|
80
87
|
/**
|
|
81
88
|
* Complete template data passed to all templates
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-data.interface.d.ts","sourceRoot":"","sources":["../../../../scripts/generate-module/types/template-data.interface.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,IAAI,GAAG,KAAK,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,KAAK,GAAG,MAAM,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,aAAa,EAAE;QACb,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;
|
|
1
|
+
{"version":3,"file":"template-data.interface.d.ts","sourceRoot":"","sources":["../../../../scripts/generate-module/types/template-data.interface.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,IAAI,GAAG,KAAK,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,KAAK,GAAG,MAAM,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,aAAa,EAAE;QACb,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;KACnB,CAA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E,eAAe,EAAE,CAAC;IAG9B,YAAY,EAAE,WAAW,EAAE,CAAC;IAG5B,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,oBAAoB,EAAE,eAAe,EAAE,CAAC;IACxC,mBAAmB,EAAE,eAAe,EAAE,CAAC;CACxC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type utilities for the generate-module command
|
|
3
|
+
* Handles type normalization, TypeScript mapping, and validation decorator generation
|
|
4
|
+
*/
|
|
5
|
+
declare const VALID_BASE_TYPES: readonly ["string", "number", "boolean", "date", "datetime", "json"];
|
|
6
|
+
declare const VALID_ARRAY_TYPES: readonly ["string[]", "number[]", "boolean[]", "date[]", "datetime[]", "json[]"];
|
|
7
|
+
export type CypherBaseType = (typeof VALID_BASE_TYPES)[number];
|
|
8
|
+
export type CypherArrayType = (typeof VALID_ARRAY_TYPES)[number];
|
|
9
|
+
export type CypherType = CypherBaseType | CypherArrayType;
|
|
10
|
+
/**
|
|
11
|
+
* Normalize a type string to canonical lowercase form
|
|
12
|
+
* Handles case-insensitive input (e.g., "String", "NUMBER[]", "DateTime")
|
|
13
|
+
*
|
|
14
|
+
* @param input - The input type string (case-insensitive)
|
|
15
|
+
* @returns The normalized CypherType or null if invalid
|
|
16
|
+
*/
|
|
17
|
+
export declare function normalizeCypherType(input: string): CypherType | null;
|
|
18
|
+
/**
|
|
19
|
+
* Check if a type is an array type
|
|
20
|
+
*
|
|
21
|
+
* @param type - The CypherType to check
|
|
22
|
+
* @returns true if the type ends with []
|
|
23
|
+
*/
|
|
24
|
+
export declare function isArrayType(type: CypherType): type is CypherArrayType;
|
|
25
|
+
/**
|
|
26
|
+
* Get the base type from an array type
|
|
27
|
+
*
|
|
28
|
+
* @param type - The CypherType (may be array or scalar)
|
|
29
|
+
* @returns The base type (e.g., "number[]" -> "number")
|
|
30
|
+
*/
|
|
31
|
+
export declare function getBaseType(type: CypherType): CypherBaseType;
|
|
32
|
+
/**
|
|
33
|
+
* Get the TypeScript type string for a CypherType
|
|
34
|
+
*
|
|
35
|
+
* @param type - The CypherType
|
|
36
|
+
* @returns The TypeScript type string
|
|
37
|
+
*/
|
|
38
|
+
export declare function getTsType(type: CypherType): string;
|
|
39
|
+
/**
|
|
40
|
+
* Get validation decorators for a field type
|
|
41
|
+
*
|
|
42
|
+
* @param type - The CypherType
|
|
43
|
+
* @param required - Whether the field is required
|
|
44
|
+
* @returns Array of decorator strings
|
|
45
|
+
*/
|
|
46
|
+
export declare function getValidationDecorators(type: CypherType, required: boolean): string[];
|
|
47
|
+
/**
|
|
48
|
+
* Get required class-validator imports for a set of types
|
|
49
|
+
*
|
|
50
|
+
* @param types - Array of CypherTypes used in the entity
|
|
51
|
+
* @returns Array of import names needed from class-validator
|
|
52
|
+
*/
|
|
53
|
+
export declare function getValidationImports(types: CypherType[]): string[];
|
|
54
|
+
/**
|
|
55
|
+
* Get all valid type strings for validation messages
|
|
56
|
+
*
|
|
57
|
+
* @returns Array of all valid type strings
|
|
58
|
+
*/
|
|
59
|
+
export declare function getValidTypes(): string[];
|
|
60
|
+
export {};
|
|
61
|
+
//# sourceMappingURL=type-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-utils.d.ts","sourceRoot":"","sources":["../../../../scripts/generate-module/utils/type-utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,QAAA,MAAM,gBAAgB,sEAAuE,CAAC;AAG9F,QAAA,MAAM,iBAAiB,kFAAmF,CAAC;AAE3G,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAC/D,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AACjE,MAAM,MAAM,UAAU,GAAG,cAAc,GAAG,eAAe,CAAC;AAE1D;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAYpE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,IAAI,eAAe,CAErE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,cAAc,CAK5D;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAgBlD;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,EAAE,CA0DrF;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,MAAM,EAAE,CAgDlE;AAED;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,MAAM,EAAE,CAExC"}
|