@carlonicora/nestjs-neo4jsonapi 1.3.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/scripts/generate-module/generator.d.ts +13 -0
- package/dist/scripts/generate-module/generator.d.ts.map +1 -0
- package/dist/scripts/generate-module/generator.js +193 -0
- package/dist/scripts/generate-module/generator.js.map +1 -0
- package/dist/scripts/generate-module/index.d.ts +3 -0
- package/dist/scripts/generate-module/index.d.ts.map +1 -0
- package/dist/scripts/generate-module/index.js +70 -0
- package/dist/scripts/generate-module/index.js.map +1 -0
- package/dist/scripts/generate-module/templates/controller.template.d.ts +9 -0
- package/dist/scripts/generate-module/templates/controller.template.d.ts.map +1 -0
- package/dist/scripts/generate-module/templates/controller.template.js +177 -0
- package/dist/scripts/generate-module/templates/controller.template.js.map +1 -0
- package/dist/scripts/generate-module/templates/dto.base.template.d.ts +9 -0
- package/dist/scripts/generate-module/templates/dto.base.template.d.ts.map +1 -0
- package/dist/scripts/generate-module/templates/dto.base.template.js +39 -0
- package/dist/scripts/generate-module/templates/dto.base.template.js.map +1 -0
- package/dist/scripts/generate-module/templates/dto.post.template.d.ts +9 -0
- package/dist/scripts/generate-module/templates/dto.post.template.d.ts.map +1 -0
- package/dist/scripts/generate-module/templates/dto.post.template.js +106 -0
- package/dist/scripts/generate-module/templates/dto.post.template.js.map +1 -0
- package/dist/scripts/generate-module/templates/dto.put.template.d.ts +10 -0
- package/dist/scripts/generate-module/templates/dto.put.template.d.ts.map +1 -0
- package/dist/scripts/generate-module/templates/dto.put.template.js +107 -0
- package/dist/scripts/generate-module/templates/dto.put.template.js.map +1 -0
- package/dist/scripts/generate-module/templates/entity.template.d.ts +12 -0
- package/dist/scripts/generate-module/templates/entity.template.d.ts.map +1 -0
- package/dist/scripts/generate-module/templates/entity.template.js +128 -0
- package/dist/scripts/generate-module/templates/entity.template.js.map +1 -0
- package/dist/scripts/generate-module/templates/module.template.d.ts +9 -0
- package/dist/scripts/generate-module/templates/module.template.d.ts.map +1 -0
- package/dist/scripts/generate-module/templates/module.template.js +39 -0
- package/dist/scripts/generate-module/templates/module.template.js.map +1 -0
- package/dist/scripts/generate-module/templates/repository.template.d.ts +9 -0
- package/dist/scripts/generate-module/templates/repository.template.d.ts.map +1 -0
- package/dist/scripts/generate-module/templates/repository.template.js +38 -0
- package/dist/scripts/generate-module/templates/repository.template.js.map +1 -0
- package/dist/scripts/generate-module/templates/service.template.d.ts +9 -0
- package/dist/scripts/generate-module/templates/service.template.d.ts.map +1 -0
- package/dist/scripts/generate-module/templates/service.template.js +43 -0
- package/dist/scripts/generate-module/templates/service.template.js.map +1 -0
- package/dist/scripts/generate-module/transformers/import-resolver.d.ts +78 -0
- package/dist/scripts/generate-module/transformers/import-resolver.d.ts.map +1 -0
- package/dist/scripts/generate-module/transformers/import-resolver.js +89 -0
- package/dist/scripts/generate-module/transformers/import-resolver.js.map +1 -0
- package/dist/scripts/generate-module/transformers/name-transformer.d.ts +39 -0
- package/dist/scripts/generate-module/transformers/name-transformer.d.ts.map +1 -0
- package/dist/scripts/generate-module/transformers/name-transformer.js +69 -0
- package/dist/scripts/generate-module/transformers/name-transformer.js.map +1 -0
- package/dist/scripts/generate-module/transformers/nested-route-generator.d.ts +26 -0
- package/dist/scripts/generate-module/transformers/nested-route-generator.d.ts.map +1 -0
- package/dist/scripts/generate-module/transformers/nested-route-generator.js +55 -0
- package/dist/scripts/generate-module/transformers/nested-route-generator.js.map +1 -0
- package/dist/scripts/generate-module/transformers/relationship-mapper.d.ts +40 -0
- package/dist/scripts/generate-module/transformers/relationship-mapper.d.ts.map +1 -0
- package/dist/scripts/generate-module/transformers/relationship-mapper.js +95 -0
- package/dist/scripts/generate-module/transformers/relationship-mapper.js.map +1 -0
- package/dist/scripts/generate-module/types/json-schema.interface.d.ts +39 -0
- package/dist/scripts/generate-module/types/json-schema.interface.d.ts.map +1 -0
- package/dist/scripts/generate-module/types/json-schema.interface.js +9 -0
- package/dist/scripts/generate-module/types/json-schema.interface.js.map +1 -0
- package/dist/scripts/generate-module/types/template-data.interface.d.ts +101 -0
- package/dist/scripts/generate-module/types/template-data.interface.d.ts.map +1 -0
- package/dist/scripts/generate-module/types/template-data.interface.js +8 -0
- package/dist/scripts/generate-module/types/template-data.interface.js.map +1 -0
- package/dist/scripts/generate-module/utils/file-writer.d.ts +29 -0
- package/dist/scripts/generate-module/utils/file-writer.d.ts.map +1 -0
- package/dist/scripts/generate-module/utils/file-writer.js +89 -0
- package/dist/scripts/generate-module/utils/file-writer.js.map +1 -0
- package/dist/scripts/generate-module/utils/module-registrar.d.ts +12 -0
- package/dist/scripts/generate-module/utils/module-registrar.d.ts.map +1 -0
- package/dist/scripts/generate-module/utils/module-registrar.js +119 -0
- package/dist/scripts/generate-module/utils/module-registrar.js.map +1 -0
- package/dist/scripts/generate-module/validators/json-schema-validator.d.ts +27 -0
- package/dist/scripts/generate-module/validators/json-schema-validator.d.ts.map +1 -0
- package/dist/scripts/generate-module/validators/json-schema-validator.js +156 -0
- package/dist/scripts/generate-module/validators/json-schema-validator.js.map +1 -0
- package/package.json +17 -16
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generatePostDTOFile = generatePostDTOFile;
|
|
4
|
+
/**
|
|
5
|
+
* Generate POST DTO file content
|
|
6
|
+
*
|
|
7
|
+
* @param data - Template data
|
|
8
|
+
* @returns Generated TypeScript code
|
|
9
|
+
*/
|
|
10
|
+
function generatePostDTOFile(data) {
|
|
11
|
+
const { names, targetDir, fields, relationships } = data;
|
|
12
|
+
// Build DTO imports for relationships (excluding contextKey)
|
|
13
|
+
const dtoImportPaths = new Map();
|
|
14
|
+
for (const rel of relationships) {
|
|
15
|
+
// Skip contextKey relationships (like Author)
|
|
16
|
+
if (rel.contextKey)
|
|
17
|
+
continue;
|
|
18
|
+
const importPath = `../../${rel.relatedEntity.directory}/${rel.relatedEntity.kebabCase}/dtos/${rel.relatedEntity.kebabCase}.dto`;
|
|
19
|
+
if (!dtoImportPaths.has(importPath)) {
|
|
20
|
+
dtoImportPaths.set(importPath, new Set());
|
|
21
|
+
}
|
|
22
|
+
// Add both singular and list DTOs
|
|
23
|
+
dtoImportPaths.get(importPath).add(`${rel.relatedEntity.name}DataDTO`);
|
|
24
|
+
if (rel.cardinality === "many") {
|
|
25
|
+
dtoImportPaths.get(importPath).add(`${rel.relatedEntity.name}DataListDTO`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const dtoImportsCode = dtoImportPaths.size > 0
|
|
29
|
+
? `\n${Array.from(dtoImportPaths.entries())
|
|
30
|
+
.map(([path, items]) => `import { ${Array.from(items).join(", ")} } from "${path}";`)
|
|
31
|
+
.join("\n")}\n`
|
|
32
|
+
: "";
|
|
33
|
+
// Build attribute validation
|
|
34
|
+
const attributeFields = fields
|
|
35
|
+
.map((field) => {
|
|
36
|
+
const decorators = [];
|
|
37
|
+
decorators.push("@IsDefined()");
|
|
38
|
+
decorators.push("@IsNotEmpty()");
|
|
39
|
+
decorators.push(`@IsString()`); // Simplified - all fields are strings in current schema
|
|
40
|
+
const optional = !field.required ? "?" : "";
|
|
41
|
+
return ` ${decorators.join("\n ")}\n ${field.name}${optional}: ${field.tsType};`;
|
|
42
|
+
})
|
|
43
|
+
.join("\n\n");
|
|
44
|
+
// Build relationship validation (exclude contextKey)
|
|
45
|
+
const relationshipFields = relationships
|
|
46
|
+
.filter((rel) => !rel.contextKey) // Exclude Author and other contextKey relationships
|
|
47
|
+
.map((rel) => {
|
|
48
|
+
const decorators = [];
|
|
49
|
+
const dtoClass = rel.cardinality === "many" ? `${rel.relatedEntity.name}DataListDTO` : `${rel.relatedEntity.name}DataDTO`;
|
|
50
|
+
if (rel.cardinality === "many") {
|
|
51
|
+
decorators.push("@ValidateNested({ each: true })");
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
decorators.push("@ValidateNested()");
|
|
55
|
+
}
|
|
56
|
+
if (rel.nullable) {
|
|
57
|
+
decorators.push("@IsOptional()");
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
decorators.push("@IsDefined()");
|
|
61
|
+
}
|
|
62
|
+
decorators.push(`@Type(() => ${dtoClass})`);
|
|
63
|
+
const optional = rel.nullable ? "?" : "";
|
|
64
|
+
const dtoKey = rel.dtoKey || rel.key;
|
|
65
|
+
return ` ${decorators.join("\n ")}\n ${dtoKey}${optional}: ${dtoClass};`;
|
|
66
|
+
})
|
|
67
|
+
.join("\n\n");
|
|
68
|
+
return `import { Type } from "class-transformer";
|
|
69
|
+
import { Equals, IsDefined, IsNotEmpty, IsOptional, IsString, IsUUID, ValidateNested } from "class-validator";${dtoImportsCode}
|
|
70
|
+
import { ${names.pascalCase}Descriptor } from "src/${targetDir}/${names.kebabCase}/entities/${names.kebabCase}";
|
|
71
|
+
|
|
72
|
+
export class ${names.pascalCase}PostAttributesDTO {
|
|
73
|
+
${attributeFields}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export class ${names.pascalCase}PostRelationshipsDTO {
|
|
77
|
+
${relationshipFields || " // No relationships (excluding contextKey relationships)"}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export class ${names.pascalCase}PostDataDTO {
|
|
81
|
+
@Equals(${names.pascalCase}Descriptor.model.endpoint)
|
|
82
|
+
type: string;
|
|
83
|
+
|
|
84
|
+
@IsUUID()
|
|
85
|
+
id: string;
|
|
86
|
+
|
|
87
|
+
@ValidateNested()
|
|
88
|
+
@IsNotEmpty()
|
|
89
|
+
@Type(() => ${names.pascalCase}PostAttributesDTO)
|
|
90
|
+
attributes: ${names.pascalCase}PostAttributesDTO;
|
|
91
|
+
|
|
92
|
+
@ValidateNested()
|
|
93
|
+
@IsNotEmpty()
|
|
94
|
+
@Type(() => ${names.pascalCase}PostRelationshipsDTO)
|
|
95
|
+
relationships: ${names.pascalCase}PostRelationshipsDTO;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export class ${names.pascalCase}PostDTO {
|
|
99
|
+
@ValidateNested()
|
|
100
|
+
@IsNotEmpty()
|
|
101
|
+
@Type(() => ${names.pascalCase}PostDataDTO)
|
|
102
|
+
data: ${names.pascalCase}PostDataDTO;
|
|
103
|
+
}
|
|
104
|
+
`;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=dto.post.template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dto.post.template.js","sourceRoot":"","sources":["../../../../scripts/generate-module/templates/dto.post.template.ts"],"names":[],"mappings":";;AAQA,kDA4GC;AAlHD;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,IAAkB;IACpD,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC;IAEzD,6DAA6D;IAC7D,MAAM,cAAc,GAAG,IAAI,GAAG,EAAuB,CAAC;IAEtD,KAAK,MAAM,GAAG,IAAI,aAAa,EAAE,CAAC;QAChC,8CAA8C;QAC9C,IAAI,GAAG,CAAC,UAAU;YAAE,SAAS;QAE7B,MAAM,UAAU,GAAG,SAAS,GAAG,CAAC,aAAa,CAAC,SAAS,IAAI,GAAG,CAAC,aAAa,CAAC,SAAS,SAAS,GAAG,CAAC,aAAa,CAAC,SAAS,MAAM,CAAC;QAEjI,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YACpC,cAAc,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;QAC5C,CAAC;QAED,kCAAkC;QAClC,cAAc,CAAC,GAAG,CAAC,UAAU,CAAE,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,aAAa,CAAC,IAAI,SAAS,CAAC,CAAC;QACxE,IAAI,GAAG,CAAC,WAAW,KAAK,MAAM,EAAE,CAAC;YAC/B,cAAc,CAAC,GAAG,CAAC,UAAU,CAAE,CA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AK,CAAC,UAAU;gBAChB,KAAK,CAAC,UAAU;;;;gBAIhB,KAAK,CAAC,UAAU;mBACb,KAAK,CAAC,UAAU;;;eAGpB,KAAK,CAAC,UAAU;;;gBAGf,KAAK,CAAC,UAAU;UACtB,KAAK,CAAC,UAAU;;CAEzB,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TemplateData } from "../types/template-data.interface";
|
|
2
|
+
/**
|
|
3
|
+
* Generate PUT DTO file content
|
|
4
|
+
* Same as POST but excludes contextKey relationships (like Author)
|
|
5
|
+
*
|
|
6
|
+
* @param data - Template data
|
|
7
|
+
* @returns Generated TypeScript code
|
|
8
|
+
*/
|
|
9
|
+
export declare function generatePutDTOFile(data: TemplateData): string;
|
|
10
|
+
//# sourceMappingURL=dto.put.template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dto.put.template.d.ts","sourceRoot":"","sources":["../../../../scripts/generate-module/templates/dto.put.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAEhE;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CA4G7D"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generatePutDTOFile = generatePutDTOFile;
|
|
4
|
+
/**
|
|
5
|
+
* Generate PUT DTO file content
|
|
6
|
+
* Same as POST but excludes contextKey relationships (like Author)
|
|
7
|
+
*
|
|
8
|
+
* @param data - Template data
|
|
9
|
+
* @returns Generated TypeScript code
|
|
10
|
+
*/
|
|
11
|
+
function generatePutDTOFile(data) {
|
|
12
|
+
const { names, targetDir, fields, relationships } = data;
|
|
13
|
+
// Build DTO imports for relationships (excluding contextKey)
|
|
14
|
+
const dtoImportPaths = new Map();
|
|
15
|
+
for (const rel of relationships) {
|
|
16
|
+
// Skip contextKey relationships (like Author) - same as POST
|
|
17
|
+
if (rel.contextKey)
|
|
18
|
+
continue;
|
|
19
|
+
const importPath = `../../${rel.relatedEntity.directory}/${rel.relatedEntity.kebabCase}/dtos/${rel.relatedEntity.kebabCase}.dto`;
|
|
20
|
+
if (!dtoImportPaths.has(importPath)) {
|
|
21
|
+
dtoImportPaths.set(importPath, new Set());
|
|
22
|
+
}
|
|
23
|
+
// Add both singular and list DTOs
|
|
24
|
+
dtoImportPaths.get(importPath).add(`${rel.relatedEntity.name}DataDTO`);
|
|
25
|
+
if (rel.cardinality === "many") {
|
|
26
|
+
dtoImportPaths.get(importPath).add(`${rel.relatedEntity.name}DataListDTO`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const dtoImportsCode = dtoImportPaths.size > 0
|
|
30
|
+
? `\n${Array.from(dtoImportPaths.entries())
|
|
31
|
+
.map(([path, items]) => `import { ${Array.from(items).join(", ")} } from "${path}";`)
|
|
32
|
+
.join("\n")}\n`
|
|
33
|
+
: "";
|
|
34
|
+
// Build attribute validation (same as POST)
|
|
35
|
+
const attributeFields = fields
|
|
36
|
+
.map((field) => {
|
|
37
|
+
const decorators = [];
|
|
38
|
+
decorators.push("@IsDefined()");
|
|
39
|
+
decorators.push("@IsNotEmpty()");
|
|
40
|
+
decorators.push(`@IsString()`); // Simplified - all fields are strings in current schema
|
|
41
|
+
const optional = !field.required ? "?" : "";
|
|
42
|
+
return ` ${decorators.join("\n ")}\n ${field.name}${optional}: ${field.tsType};`;
|
|
43
|
+
})
|
|
44
|
+
.join("\n\n");
|
|
45
|
+
// Build relationship validation (exclude contextKey - same as POST)
|
|
46
|
+
const relationshipFields = relationships
|
|
47
|
+
.filter((rel) => !rel.contextKey) // Exclude Author and other contextKey relationships
|
|
48
|
+
.map((rel) => {
|
|
49
|
+
const decorators = [];
|
|
50
|
+
const dtoClass = rel.cardinality === "many" ? `${rel.relatedEntity.name}DataListDTO` : `${rel.relatedEntity.name}DataDTO`;
|
|
51
|
+
if (rel.cardinality === "many") {
|
|
52
|
+
decorators.push("@ValidateNested({ each: true })");
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
decorators.push("@ValidateNested()");
|
|
56
|
+
}
|
|
57
|
+
if (rel.nullable) {
|
|
58
|
+
decorators.push("@IsOptional()");
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
decorators.push("@IsDefined()");
|
|
62
|
+
}
|
|
63
|
+
decorators.push(`@Type(() => ${dtoClass})`);
|
|
64
|
+
const optional = rel.nullable ? "?" : "";
|
|
65
|
+
const dtoKey = rel.dtoKey || rel.key;
|
|
66
|
+
return ` ${decorators.join("\n ")}\n ${dtoKey}${optional}: ${dtoClass};`;
|
|
67
|
+
})
|
|
68
|
+
.join("\n\n");
|
|
69
|
+
return `import { Type } from "class-transformer";
|
|
70
|
+
import { Equals, IsDefined, IsNotEmpty, IsOptional, IsString, IsUUID, ValidateNested } from "class-validator";${dtoImportsCode}
|
|
71
|
+
import { ${names.pascalCase}Descriptor } from "src/${targetDir}/${names.kebabCase}/entities/${names.kebabCase}";
|
|
72
|
+
|
|
73
|
+
export class ${names.pascalCase}PutAttributesDTO {
|
|
74
|
+
${attributeFields}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export class ${names.pascalCase}PutRelationshipsDTO {
|
|
78
|
+
${relationshipFields || " // No relationships (excluding contextKey relationships)"}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export class ${names.pascalCase}PutDataDTO {
|
|
82
|
+
@Equals(${names.pascalCase}Descriptor.model.endpoint)
|
|
83
|
+
type: string;
|
|
84
|
+
|
|
85
|
+
@IsUUID()
|
|
86
|
+
id: string;
|
|
87
|
+
|
|
88
|
+
@ValidateNested()
|
|
89
|
+
@IsNotEmpty()
|
|
90
|
+
@Type(() => ${names.pascalCase}PutAttributesDTO)
|
|
91
|
+
attributes: ${names.pascalCase}PutAttributesDTO;
|
|
92
|
+
|
|
93
|
+
@ValidateNested()
|
|
94
|
+
@IsNotEmpty()
|
|
95
|
+
@Type(() => ${names.pascalCase}PutRelationshipsDTO)
|
|
96
|
+
relationships: ${names.pascalCase}PutRelationshipsDTO;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export class ${names.pascalCase}PutDTO {
|
|
100
|
+
@ValidateNested()
|
|
101
|
+
@IsNotEmpty()
|
|
102
|
+
@Type(() => ${names.pascalCase}PutDataDTO)
|
|
103
|
+
data: ${names.pascalCase}PutDataDTO;
|
|
104
|
+
}
|
|
105
|
+
`;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=dto.put.template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dto.put.template.js","sourceRoot":"","sources":["../../../../scripts/generate-module/templates/dto.put.template.ts"],"names":[],"mappings":";;AASA,gDA4GC;AAnHD;;;;;;GAMG;AACH,SAAgB,kBAAkB,CAAC,IAAkB;IACnD,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC;IAEzD,6DAA6D;IAC7D,MAAM,cAAc,GAAG,IAAI,GAAG,EAAuB,CAAC;IAEtD,KAAK,MAAM,GAAG,IAAI,aAAa,EAAE,CAAC;QAChC,6DAA6D;QAC7D,IAAI,GAAG,CAAC,UAAU;YAAE,SAAS;QAE7B,MAAM,UAAU,GAAG,SAAS,GAAG,CAAC,aAAa,CAAC,SAAS,IAAI,GAAG,CAAC,aAAa,CAAC,SAAS,SAAS,GAAG,CAAC,aAAa,CAAC,SAAS,MAAM,CAAC;QAEjI,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YACpC,cAAc,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;QAC5C,CAAC;QAED,kCAAkC;QAClC,cAAc,CAAC,GAAG,CAAC,UAAU,CAAE,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,a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,eAAe;;;eAGF,KAAK,CAAC,UAAU;EAC7B,kBAAkB,IAAI,4DAA4D;;;eAGrE,KAAK,CAAC,UAAU;YACnB,KAAK,CAAC,UAAU;;;;;;;;gBAQZ,KAAK,CAAC,UAAU;gBAChB,KAAK,CAAC,UAAU;;;;gBAIhB,KAAK,CAAC,UAAU;mBACb,KAAK,CAAC,UAAU;;;eAGpB,KAAK,CAAC,UAAU;;;gBAGf,KAAK,CAAC,UAAU;UACtB,KAAK,CAAC,UAAU;;CAEzB,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TemplateData } from "../types/template-data.interface";
|
|
2
|
+
/**
|
|
3
|
+
* Generate entity file content (Type + Descriptor)
|
|
4
|
+
*
|
|
5
|
+
* This is the most critical file - it defines both the TypeScript type
|
|
6
|
+
* and the descriptor using defineEntity()
|
|
7
|
+
*
|
|
8
|
+
* @param data - Template data
|
|
9
|
+
* @returns Generated TypeScript code
|
|
10
|
+
*/
|
|
11
|
+
export declare function generateEntityFile(data: TemplateData): string;
|
|
12
|
+
//# sourceMappingURL=entity.template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity.template.d.ts","sourceRoot":"","sources":["../../../../scripts/generate-module/templates/entity.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAEhE;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CA8H7D"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateEntityFile = generateEntityFile;
|
|
4
|
+
/**
|
|
5
|
+
* Generate entity file content (Type + Descriptor)
|
|
6
|
+
*
|
|
7
|
+
* This is the most critical file - it defines both the TypeScript type
|
|
8
|
+
* and the descriptor using defineEntity()
|
|
9
|
+
*
|
|
10
|
+
* @param data - Template data
|
|
11
|
+
* @returns Generated TypeScript code
|
|
12
|
+
*/
|
|
13
|
+
function generateEntityFile(data) {
|
|
14
|
+
const { names, endpoint, nodeName, labelName, fields, relationships, entityImports, metaImports } = data;
|
|
15
|
+
// Build imports
|
|
16
|
+
const libraryImports = ["defineEntity", "Entity"];
|
|
17
|
+
if (data.isCompanyScoped) {
|
|
18
|
+
libraryImports.push("Company");
|
|
19
|
+
}
|
|
20
|
+
// Add entity imports for relationships
|
|
21
|
+
const uniqueEntityImports = new Set();
|
|
22
|
+
const entityImportsByPath = new Map();
|
|
23
|
+
for (const rel of relationships) {
|
|
24
|
+
if (!uniqueEntityImports.has(rel.relatedEntity.name)) {
|
|
25
|
+
uniqueEntityImports.add(rel.relatedEntity.name);
|
|
26
|
+
// Group by import path
|
|
27
|
+
const importPath = `../../${rel.relatedEntity.directory}/${rel.relatedEntity.kebabCase}/entities/${rel.relatedEntity.kebabCase}.entity`;
|
|
28
|
+
if (!entityImportsByPath.has(importPath)) {
|
|
29
|
+
entityImportsByPath.set(importPath, []);
|
|
30
|
+
}
|
|
31
|
+
entityImportsByPath.get(importPath).push(rel.relatedEntity.name);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// Add meta imports for relationships
|
|
35
|
+
const uniqueMetaImports = new Set();
|
|
36
|
+
const metaImportsByPath = new Map();
|
|
37
|
+
for (const rel of relationships) {
|
|
38
|
+
if (!uniqueMetaImports.has(rel.model)) {
|
|
39
|
+
uniqueMetaImports.add(rel.model);
|
|
40
|
+
// Group by import path
|
|
41
|
+
const importPath = `../../${rel.relatedEntity.directory}/${rel.relatedEntity.kebabCase}/entities/${rel.relatedEntity.kebabCase}.meta`;
|
|
42
|
+
if (!metaImportsByPath.has(importPath)) {
|
|
43
|
+
metaImportsByPath.set(importPath, []);
|
|
44
|
+
}
|
|
45
|
+
metaImportsByPath.get(importPath).push(rel.model);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// Build field definitions for descriptor
|
|
49
|
+
const fieldDefinitions = fields
|
|
50
|
+
.map((field) => {
|
|
51
|
+
const parts = [];
|
|
52
|
+
parts.push(`type: "${field.type}"`);
|
|
53
|
+
if (field.required) {
|
|
54
|
+
parts.push(`required: true`);
|
|
55
|
+
}
|
|
56
|
+
return ` ${field.name}: { ${parts.join(", ")} },`;
|
|
57
|
+
})
|
|
58
|
+
.join("\n");
|
|
59
|
+
// Build relationship definitions for descriptor
|
|
60
|
+
const relationshipDefinitions = relationships
|
|
61
|
+
.map((rel) => {
|
|
62
|
+
const parts = [];
|
|
63
|
+
parts.push(`model: ${rel.model}`);
|
|
64
|
+
parts.push(`direction: "${rel.direction}"`);
|
|
65
|
+
parts.push(`relationship: "${rel.relationship}"`);
|
|
66
|
+
parts.push(`cardinality: "${rel.cardinality}"`);
|
|
67
|
+
if (rel.contextKey) {
|
|
68
|
+
parts.push(`contextKey: "${rel.contextKey}"`);
|
|
69
|
+
}
|
|
70
|
+
if (rel.dtoKey) {
|
|
71
|
+
parts.push(`dtoKey: "${rel.dtoKey}"`);
|
|
72
|
+
}
|
|
73
|
+
return ` ${rel.key}: {\n ${parts.join(",\n ")},\n },`;
|
|
74
|
+
})
|
|
75
|
+
.join("\n");
|
|
76
|
+
return `import { ${libraryImports.join(", ")} } from "@carlonicora/nestjs-neo4jsonapi";
|
|
77
|
+
${Array.from(entityImportsByPath.entries())
|
|
78
|
+
.map(([path, items]) => `import { ${items.join(", ")} } from "${path}";`)
|
|
79
|
+
.join("\n")}
|
|
80
|
+
${Array.from(metaImportsByPath.entries())
|
|
81
|
+
.map(([path, items]) => `import { ${items.join(", ")} } from "${path}";`)
|
|
82
|
+
.join("\n")}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* ${names.pascalCase} Entity Type
|
|
86
|
+
*/
|
|
87
|
+
export type ${names.pascalCase} = Entity & {
|
|
88
|
+
${fields
|
|
89
|
+
.map((field) => {
|
|
90
|
+
const optional = !field.required ? "?" : "";
|
|
91
|
+
return ` ${field.name}${optional}: ${field.tsType};`;
|
|
92
|
+
})
|
|
93
|
+
.join("\n")}
|
|
94
|
+
|
|
95
|
+
${data.isCompanyScoped ? " company: Company;\n" : ""}${relationships
|
|
96
|
+
.map((rel) => {
|
|
97
|
+
const optional = rel.nullable ? "?" : "";
|
|
98
|
+
const type = rel.cardinality === "many" ? `${rel.relatedEntity.name}[]` : rel.relatedEntity.name;
|
|
99
|
+
return ` ${rel.key}${optional}: ${type};`;
|
|
100
|
+
})
|
|
101
|
+
.join("\n")}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* ${names.pascalCase} Entity Descriptor
|
|
106
|
+
*
|
|
107
|
+
* Single source of truth for the ${names.pascalCase} entity configuration.
|
|
108
|
+
* Auto-generates mapper, serialiser, constraints, and indexes.
|
|
109
|
+
*/
|
|
110
|
+
export const ${names.pascalCase}Descriptor = defineEntity<${names.pascalCase}>()({
|
|
111
|
+
type: "${endpoint}",
|
|
112
|
+
endpoint: "${endpoint}",
|
|
113
|
+
nodeName: "${nodeName}",
|
|
114
|
+
labelName: "${labelName}",
|
|
115
|
+
${!data.isCompanyScoped ? "\n isCompanyScoped: false,\n" : ""}
|
|
116
|
+
fields: {
|
|
117
|
+
${fieldDefinitions}
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
relationships: {
|
|
121
|
+
${relationshipDefinitions}
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
export type ${names.pascalCase}DescriptorType = typeof ${names.pascalCase}Descriptor;
|
|
126
|
+
`;
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=entity.template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity.template.js","sourceRoot":"","sources":["../../../../scripts/generate-module/templates/entity.template.ts"],"names":[],"mappings":";;AAWA,gDA8HC;AAvID;;;;;;;;GAQG;AACH,SAAgB,kBAAkB,CAAC,IAAkB;IACnD,MAAM,EAAE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
|
+
* @returns Generated TypeScript code
|
|
7
|
+
*/
|
|
8
|
+
export declare function generateModuleFile(data: TemplateData): string;
|
|
9
|
+
//# sourceMappingURL=module.template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.template.d.ts","sourceRoot":"","sources":["../../../../scripts/generate-module/templates/module.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAEhE;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CA6B7D"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateModuleFile = generateModuleFile;
|
|
4
|
+
/**
|
|
5
|
+
* Generate module file content
|
|
6
|
+
*
|
|
7
|
+
* @param data - Template data
|
|
8
|
+
* @returns Generated TypeScript code
|
|
9
|
+
*/
|
|
10
|
+
function generateModuleFile(data) {
|
|
11
|
+
const { names, targetDir } = data;
|
|
12
|
+
return `import {
|
|
13
|
+
AuditModule,
|
|
14
|
+
modelRegistry,
|
|
15
|
+
} from "@carlonicora/nestjs-neo4jsonapi";
|
|
16
|
+
import { Module, OnModuleInit } from "@nestjs/common";
|
|
17
|
+
import { ${names.pascalCase}Controller } from "src/${targetDir}/${names.kebabCase}/controllers/${names.kebabCase}.controller";
|
|
18
|
+
import { ${names.pascalCase}Descriptor } from "src/${targetDir}/${names.kebabCase}/entities/${names.kebabCase}";
|
|
19
|
+
import { ${names.pascalCase}Repository } from "src/${targetDir}/${names.kebabCase}/repositories/${names.kebabCase}.repository";
|
|
20
|
+
import { ${names.pascalCase}Service } from "src/${targetDir}/${names.kebabCase}/services/${names.kebabCase}.service";
|
|
21
|
+
|
|
22
|
+
@Module({
|
|
23
|
+
controllers: [${names.pascalCase}Controller],
|
|
24
|
+
providers: [
|
|
25
|
+
${names.pascalCase}Descriptor.model.serialiser,
|
|
26
|
+
${names.pascalCase}Repository,
|
|
27
|
+
${names.pascalCase}Service,
|
|
28
|
+
],
|
|
29
|
+
exports: [],
|
|
30
|
+
imports: [AuditModule],
|
|
31
|
+
})
|
|
32
|
+
export class ${names.pascalCase}Module implements OnModuleInit {
|
|
33
|
+
onModuleInit() {
|
|
34
|
+
modelRegistry.register(${names.pascalCase}Descriptor.model);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=module.template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.template.js","sourceRoot":"","sources":["../../../../scripts/generate-module/templates/module.template.ts"],"names":[],"mappings":";;AAQA,gDA6BC;AAnCD;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAC,IAAkB;IACnD,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IAElC,OAAO;;;;;WAKE,KAAK,CAAC,UAAU,0BAA0B,SAAS,IAAI,KAAK,CAAC,SAAS,gBAAgB,KAAK,CAAC,SAAS;WACrG,KAAK,CAAC,UAAU,0BAA0B,SAAS,IAAI,KAAK,CAAC,SAAS,aAAa,KAAK,CAAC,SAAS;WAClG,KAAK,CAAC,UAAU,0BAA0B,SAAS,IAAI,KAAK,CAAC,SAAS,iBAAiB,KAAK,CAAC,SAAS;WACtG,KAAK,CAAC,UAAU,uBAAuB,SAAS,IAAI,KAAK,CAAC,SAAS,aAAa,KAAK,CAAC,SAAS;;;kBAGxF,KAAK,CAAC,UAAU;;MAE5B,KAAK,CAAC,UAAU;MAChB,KAAK,CAAC,UAAU;MAChB,KAAK,CAAC,UAAU;;;;;eAKP,KAAK,CAAC,UAAU;;6BAEF,KAAK,CAAC,UAAU;;;CAG5C,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TemplateData } from "../types/template-data.interface";
|
|
2
|
+
/**
|
|
3
|
+
* Generate repository file content
|
|
4
|
+
*
|
|
5
|
+
* @param data - Template data
|
|
6
|
+
* @returns Generated TypeScript code
|
|
7
|
+
*/
|
|
8
|
+
export declare function generateRepositoryFile(data: TemplateData): string;
|
|
9
|
+
//# sourceMappingURL=repository.template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repository.template.d.ts","sourceRoot":"","sources":["../../../../scripts/generate-module/templates/repository.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAEhE;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CA4BjE"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateRepositoryFile = generateRepositoryFile;
|
|
4
|
+
/**
|
|
5
|
+
* Generate repository file content
|
|
6
|
+
*
|
|
7
|
+
* @param data - Template data
|
|
8
|
+
* @returns Generated TypeScript code
|
|
9
|
+
*/
|
|
10
|
+
function generateRepositoryFile(data) {
|
|
11
|
+
const { names, targetDir } = data;
|
|
12
|
+
return `import { Injectable } from "@nestjs/common";
|
|
13
|
+
import {
|
|
14
|
+
AbstractRepository,
|
|
15
|
+
Neo4jService,
|
|
16
|
+
SecurityService,
|
|
17
|
+
} from "@carlonicora/nestjs-neo4jsonapi";
|
|
18
|
+
import { ${names.pascalCase} } from "src/${targetDir}/${names.kebabCase}/entities/${names.kebabCase}";
|
|
19
|
+
import { ${names.pascalCase}Descriptor } from "src/${targetDir}/${names.kebabCase}/entities/${names.kebabCase}";
|
|
20
|
+
|
|
21
|
+
@Injectable()
|
|
22
|
+
export class ${names.pascalCase}Repository extends AbstractRepository<${names.pascalCase}, typeof ${names.pascalCase}Descriptor.relationships> {
|
|
23
|
+
protected readonly descriptor = ${names.pascalCase}Descriptor;
|
|
24
|
+
|
|
25
|
+
constructor(neo4j: Neo4jService, securityService: SecurityService) {
|
|
26
|
+
super(neo4j, securityService);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Inherited methods:
|
|
30
|
+
// - find, findById, create, put, patch, delete
|
|
31
|
+
// - findByRelated
|
|
32
|
+
// - onModuleInit (creates constraints and indexes)
|
|
33
|
+
|
|
34
|
+
// Add custom Cypher queries here if needed
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=repository.template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repository.template.js","sourceRoot":"","sources":["../../../../scripts/generate-module/templates/repository.template.ts"],"names":[],"mappings":";;AAQA,wDA4BC;AAlCD;;;;;GAKG;AACH,SAAgB,sBAAsB,CAAC,IAAkB;IACvD,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IAElC,OAAO;;;;;;WAME,KAAK,CAAC,UAAU,gBAAgB,SAAS,IAAI,KAAK,CAAC,SAAS,aAAa,KAAK,CAAC,SAAS;WACxF,KAAK,CAAC,UAAU,0BAA0B,SAAS,IAAI,KAAK,CAAC,SAAS,aAAa,KAAK,CAAC,SAAS;;;eAG9F,KAAK,CAAC,UAAU,yCAAyC,KAAK,CAAC,UAAU,YAAY,KAAK,CAAC,UAAU;oCAChF,KAAK,CAAC,UAAU;;;;;;;;;;;;;CAanD,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TemplateData } from "../types/template-data.interface";
|
|
2
|
+
/**
|
|
3
|
+
* Generate service file content
|
|
4
|
+
*
|
|
5
|
+
* @param data - Template data
|
|
6
|
+
* @returns Generated TypeScript code
|
|
7
|
+
*/
|
|
8
|
+
export declare function generateServiceFile(data: TemplateData): string;
|
|
9
|
+
//# sourceMappingURL=service.template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.template.d.ts","sourceRoot":"","sources":["../../../../scripts/generate-module/templates/service.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAEhE;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAiC9D"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateServiceFile = generateServiceFile;
|
|
4
|
+
/**
|
|
5
|
+
* Generate service file content
|
|
6
|
+
*
|
|
7
|
+
* @param data - Template data
|
|
8
|
+
* @returns Generated TypeScript code
|
|
9
|
+
*/
|
|
10
|
+
function generateServiceFile(data) {
|
|
11
|
+
const { names, targetDir } = data;
|
|
12
|
+
return `import { Injectable } from "@nestjs/common";
|
|
13
|
+
import { ClsService } from "nestjs-cls";
|
|
14
|
+
import {
|
|
15
|
+
AbstractService,
|
|
16
|
+
JsonApiService,
|
|
17
|
+
} from "@carlonicora/nestjs-neo4jsonapi";
|
|
18
|
+
import { ${names.pascalCase} } from "src/${targetDir}/${names.kebabCase}/entities/${names.kebabCase}";
|
|
19
|
+
import { ${names.pascalCase}Descriptor } from "src/${targetDir}/${names.kebabCase}/entities/${names.kebabCase}";
|
|
20
|
+
import { ${names.pascalCase}Repository } from "src/${targetDir}/${names.kebabCase}/repositories/${names.kebabCase}.repository";
|
|
21
|
+
|
|
22
|
+
@Injectable()
|
|
23
|
+
export class ${names.pascalCase}Service extends AbstractService<${names.pascalCase}, typeof ${names.pascalCase}Descriptor.relationships> {
|
|
24
|
+
protected readonly descriptor = ${names.pascalCase}Descriptor;
|
|
25
|
+
|
|
26
|
+
constructor(
|
|
27
|
+
jsonApiService: JsonApiService,
|
|
28
|
+
private readonly ${names.camelCase}Repository: ${names.pascalCase}Repository,
|
|
29
|
+
clsService: ClsService,
|
|
30
|
+
) {
|
|
31
|
+
super(jsonApiService, ${names.camelCase}Repository, clsService, ${names.pascalCase}Descriptor.model);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Inherited methods:
|
|
35
|
+
// - find, findById, create, put, patch, delete
|
|
36
|
+
// - createFromDTO, putFromDTO, patchFromDTO
|
|
37
|
+
// - findByRelated
|
|
38
|
+
|
|
39
|
+
// Add custom business logic methods here if needed
|
|
40
|
+
}
|
|
41
|
+
`;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=service.template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.template.js","sourceRoot":"","sources":["../../../../scripts/generate-module/templates/service.template.ts"],"names":[],"mappings":";;AAQA,kDAiCC;AAvCD;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,IAAkB;IACpD,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IAElC,OAAO;;;;;;WAME,KAAK,CAAC,UAAU,gBAAgB,SAAS,IAAI,KAAK,CAAC,SAAS,aAAa,KAAK,CAAC,SAAS;WACxF,KAAK,CAAC,UAAU,0BAA0B,SAAS,IAAI,KAAK,CAAC,SAAS,aAAa,KAAK,CAAC,SAAS;WAClG,KAAK,CAAC,UAAU,0BAA0B,SAAS,IAAI,KAAK,CAAC,SAAS,iBAAiB,KAAK,CAAC,SAAS;;;eAGlG,KAAK,CAAC,UAAU,mCAAmC,KAAK,CAAC,UAAU,YAAY,KAAK,CAAC,UAAU;oCAC1E,KAAK,CAAC,UAAU;;;;uBAI7B,KAAK,CAAC,SAAS,eAAe,KAAK,CAAC,UAAU;;;4BAGzC,KAAK,CAAC,SAAS,2BAA2B,KAAK,CAAC,UAAU;;;;;;;;;;CAUrF,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve relative import path between two modules
|
|
3
|
+
*
|
|
4
|
+
* @param params - From and to directories and modules
|
|
5
|
+
* @returns Relative import path
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* From: src/features/comment
|
|
9
|
+
* To: src/foundations/user
|
|
10
|
+
* Result: "../../foundations/user"
|
|
11
|
+
*/
|
|
12
|
+
export declare function resolveImportPath(params: {
|
|
13
|
+
fromDir: string;
|
|
14
|
+
fromModule: string;
|
|
15
|
+
toDir: string;
|
|
16
|
+
toModule: string;
|
|
17
|
+
}): string;
|
|
18
|
+
/**
|
|
19
|
+
* Resolve import path for entity file
|
|
20
|
+
*
|
|
21
|
+
* @param params - From and to module info
|
|
22
|
+
* @returns Import path to entity file
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* resolveEntityImportPath({ fromDir: "features", fromModule: "comment", toDir: "foundations", toModule: "user" })
|
|
26
|
+
* // Returns: "../../foundations/user/entities/user.entity"
|
|
27
|
+
*/
|
|
28
|
+
export declare function resolveEntityImportPath(params: {
|
|
29
|
+
fromDir: string;
|
|
30
|
+
fromModule: string;
|
|
31
|
+
toDir: string;
|
|
32
|
+
toModule: string;
|
|
33
|
+
}): string;
|
|
34
|
+
/**
|
|
35
|
+
* Resolve import path for meta file
|
|
36
|
+
*
|
|
37
|
+
* @param params - From and to module info
|
|
38
|
+
* @returns Import path to meta file
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* resolveMetaImportPath({ fromDir: "features", fromModule: "comment", toDir: "foundations", toModule: "user" })
|
|
42
|
+
* // Returns: "../../foundations/user/entities/user.meta"
|
|
43
|
+
*/
|
|
44
|
+
export declare function resolveMetaImportPath(params: {
|
|
45
|
+
fromDir: string;
|
|
46
|
+
fromModule: string;
|
|
47
|
+
toDir: string;
|
|
48
|
+
toModule: string;
|
|
49
|
+
}): string;
|
|
50
|
+
/**
|
|
51
|
+
* Resolve import path for DTO file
|
|
52
|
+
*
|
|
53
|
+
* @param params - From and to module info
|
|
54
|
+
* @returns Import path to DTO file
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* resolveDtoImportPath({ fromDir: "features", fromModule: "comment", toDir: "features", toModule: "discussion" })
|
|
58
|
+
* // Returns: "../discussion/dtos/discussion.dto"
|
|
59
|
+
*/
|
|
60
|
+
export declare function resolveDtoImportPath(params: {
|
|
61
|
+
fromDir: string;
|
|
62
|
+
fromModule: string;
|
|
63
|
+
toDir: string;
|
|
64
|
+
toModule: string;
|
|
65
|
+
}): string;
|
|
66
|
+
/**
|
|
67
|
+
* Resolve import path relative to module root
|
|
68
|
+
* Used for imports within the same module
|
|
69
|
+
*
|
|
70
|
+
* @param subpath - Subpath within module (e.g., "entities/comment", "services/comment.service")
|
|
71
|
+
* @returns Relative import path
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* resolveModuleInternalPath("entities/comment")
|
|
75
|
+
* // Returns: "../entities/comment"
|
|
76
|
+
*/
|
|
77
|
+
export declare function resolveModuleInternalPath(subpath: string): string;
|
|
78
|
+
//# sourceMappingURL=import-resolver.d.ts.map
|