@carlonicora/nestjs-neo4jsonapi 1.3.1 → 1.4.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/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 +180 -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 +109 -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 +110 -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 +133 -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 +93 -0
- package/dist/scripts/generate-module/transformers/import-resolver.d.ts.map +1 -0
- package/dist/scripts/generate-module/transformers/import-resolver.js +108 -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,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generatePostDTOFile = generatePostDTOFile;
|
|
4
|
+
const import_resolver_1 = require("../transformers/import-resolver");
|
|
5
|
+
/**
|
|
6
|
+
* Generate POST DTO file content
|
|
7
|
+
*
|
|
8
|
+
* @param data - Template data
|
|
9
|
+
* @returns Generated TypeScript code
|
|
10
|
+
*/
|
|
11
|
+
function generatePostDTOFile(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)
|
|
17
|
+
if (rel.contextKey)
|
|
18
|
+
continue;
|
|
19
|
+
const importPath = (0, import_resolver_1.isFoundationImport)(rel.relatedEntity.directory)
|
|
20
|
+
? import_resolver_1.FOUNDATION_PACKAGE
|
|
21
|
+
: `../../${rel.relatedEntity.directory}/${rel.relatedEntity.kebabCase}/dtos/${rel.relatedEntity.kebabCase}.dto`;
|
|
22
|
+
if (!dtoImportPaths.has(importPath)) {
|
|
23
|
+
dtoImportPaths.set(importPath, new Set());
|
|
24
|
+
}
|
|
25
|
+
// Add both singular and list DTOs
|
|
26
|
+
dtoImportPaths.get(importPath).add(`${rel.relatedEntity.name}DataDTO`);
|
|
27
|
+
if (rel.cardinality === "many") {
|
|
28
|
+
dtoImportPaths.get(importPath).add(`${rel.relatedEntity.name}DataListDTO`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const dtoImportsCode = dtoImportPaths.size > 0
|
|
32
|
+
? `\n${Array.from(dtoImportPaths.entries())
|
|
33
|
+
.map(([path, items]) => `import { ${Array.from(items).join(", ")} } from "${path}";`)
|
|
34
|
+
.join("\n")}\n`
|
|
35
|
+
: "";
|
|
36
|
+
// Build attribute validation
|
|
37
|
+
const attributeFields = fields
|
|
38
|
+
.map((field) => {
|
|
39
|
+
const decorators = [];
|
|
40
|
+
decorators.push("@IsDefined()");
|
|
41
|
+
decorators.push("@IsNotEmpty()");
|
|
42
|
+
decorators.push(`@IsString()`); // Simplified - all fields are strings in current schema
|
|
43
|
+
const optional = !field.required ? "?" : "";
|
|
44
|
+
return ` ${decorators.join("\n ")}\n ${field.name}${optional}: ${field.tsType};`;
|
|
45
|
+
})
|
|
46
|
+
.join("\n\n");
|
|
47
|
+
// Build relationship validation (exclude contextKey)
|
|
48
|
+
const relationshipFields = relationships
|
|
49
|
+
.filter((rel) => !rel.contextKey) // Exclude Author and other contextKey relationships
|
|
50
|
+
.map((rel) => {
|
|
51
|
+
const decorators = [];
|
|
52
|
+
const dtoClass = rel.cardinality === "many" ? `${rel.relatedEntity.name}DataListDTO` : `${rel.relatedEntity.name}DataDTO`;
|
|
53
|
+
if (rel.cardinality === "many") {
|
|
54
|
+
decorators.push("@ValidateNested({ each: true })");
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
decorators.push("@ValidateNested()");
|
|
58
|
+
}
|
|
59
|
+
if (rel.nullable) {
|
|
60
|
+
decorators.push("@IsOptional()");
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
decorators.push("@IsDefined()");
|
|
64
|
+
}
|
|
65
|
+
decorators.push(`@Type(() => ${dtoClass})`);
|
|
66
|
+
const optional = rel.nullable ? "?" : "";
|
|
67
|
+
const dtoKey = rel.dtoKey || rel.key;
|
|
68
|
+
return ` ${decorators.join("\n ")}\n ${dtoKey}${optional}: ${dtoClass};`;
|
|
69
|
+
})
|
|
70
|
+
.join("\n\n");
|
|
71
|
+
return `import { Type } from "class-transformer";
|
|
72
|
+
import { Equals, IsDefined, IsNotEmpty, IsOptional, IsString, IsUUID, ValidateNested } from "class-validator";${dtoImportsCode}
|
|
73
|
+
import { ${names.pascalCase}Descriptor } from "src/${targetDir}/${names.kebabCase}/entities/${names.kebabCase}";
|
|
74
|
+
|
|
75
|
+
export class ${names.pascalCase}PostAttributesDTO {
|
|
76
|
+
${attributeFields}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export class ${names.pascalCase}PostRelationshipsDTO {
|
|
80
|
+
${relationshipFields || " // No relationships (excluding contextKey relationships)"}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export class ${names.pascalCase}PostDataDTO {
|
|
84
|
+
@Equals(${names.pascalCase}Descriptor.model.endpoint)
|
|
85
|
+
type: string;
|
|
86
|
+
|
|
87
|
+
@IsUUID()
|
|
88
|
+
id: string;
|
|
89
|
+
|
|
90
|
+
@ValidateNested()
|
|
91
|
+
@IsNotEmpty()
|
|
92
|
+
@Type(() => ${names.pascalCase}PostAttributesDTO)
|
|
93
|
+
attributes: ${names.pascalCase}PostAttributesDTO;
|
|
94
|
+
|
|
95
|
+
@ValidateNested()
|
|
96
|
+
@IsNotEmpty()
|
|
97
|
+
@Type(() => ${names.pascalCase}PostRelationshipsDTO)
|
|
98
|
+
relationships: ${names.pascalCase}PostRelationshipsDTO;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export class ${names.pascalCase}PostDTO {
|
|
102
|
+
@ValidateNested()
|
|
103
|
+
@IsNotEmpty()
|
|
104
|
+
@Type(() => ${names.pascalCase}PostDataDTO)
|
|
105
|
+
data: ${names.pascalCase}PostDataDTO;
|
|
106
|
+
}
|
|
107
|
+
`;
|
|
108
|
+
}
|
|
109
|
+
//# 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":";;AASA,kDA8GC;AAtHD,qEAAyF;AAEzF;;;;;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,IAAA,oCAAkB,EAAC,GAAG,CAAC,aAAa,CAAC,SAAS,CAAC;YAChE,CAAC,CAAC,oCAAkB;YACpB,CAAC,CAAC,SAAS,GAAG,CAAC,aAAa,CAAC,SAAS,IAAI,GAAG,CAAC,aAAa,CAAC,SAAS,SAAS,GAAG,CAAC,aAAa,CAAC,SAAS,MAAM,CAAC;QAElH,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YACpC,cAAc,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,GAAG,EAAE,CA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H,KAAK,CAAC,UAAU,0BAA0B,SAAS,IAAI,KAAK,CAAC,SAAS,aAAa,KAAK,CAAC,SAAS;;eAE9F,KAAK,CAAC,UAAU;EAC7B,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,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;AAGhE;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CA8G7D"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generatePutDTOFile = generatePutDTOFile;
|
|
4
|
+
const import_resolver_1 = require("../transformers/import-resolver");
|
|
5
|
+
/**
|
|
6
|
+
* Generate PUT DTO file content
|
|
7
|
+
* Same as POST but excludes contextKey relationships (like Author)
|
|
8
|
+
*
|
|
9
|
+
* @param data - Template data
|
|
10
|
+
* @returns Generated TypeScript code
|
|
11
|
+
*/
|
|
12
|
+
function generatePutDTOFile(data) {
|
|
13
|
+
const { names, targetDir, fields, relationships } = data;
|
|
14
|
+
// Build DTO imports for relationships (excluding contextKey)
|
|
15
|
+
const dtoImportPaths = new Map();
|
|
16
|
+
for (const rel of relationships) {
|
|
17
|
+
// Skip contextKey relationships (like Author) - same as POST
|
|
18
|
+
if (rel.contextKey)
|
|
19
|
+
continue;
|
|
20
|
+
const importPath = (0, import_resolver_1.isFoundationImport)(rel.relatedEntity.directory)
|
|
21
|
+
? import_resolver_1.FOUNDATION_PACKAGE
|
|
22
|
+
: `../../${rel.relatedEntity.directory}/${rel.relatedEntity.kebabCase}/dtos/${rel.relatedEntity.kebabCase}.dto`;
|
|
23
|
+
if (!dtoImportPaths.has(importPath)) {
|
|
24
|
+
dtoImportPaths.set(importPath, new Set());
|
|
25
|
+
}
|
|
26
|
+
// Add both singular and list DTOs
|
|
27
|
+
dtoImportPaths.get(importPath).add(`${rel.relatedEntity.name}DataDTO`);
|
|
28
|
+
if (rel.cardinality === "many") {
|
|
29
|
+
dtoImportPaths.get(importPath).add(`${rel.relatedEntity.name}DataListDTO`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const dtoImportsCode = dtoImportPaths.size > 0
|
|
33
|
+
? `\n${Array.from(dtoImportPaths.entries())
|
|
34
|
+
.map(([path, items]) => `import { ${Array.from(items).join(", ")} } from "${path}";`)
|
|
35
|
+
.join("\n")}\n`
|
|
36
|
+
: "";
|
|
37
|
+
// Build attribute validation (same as POST)
|
|
38
|
+
const attributeFields = fields
|
|
39
|
+
.map((field) => {
|
|
40
|
+
const decorators = [];
|
|
41
|
+
decorators.push("@IsDefined()");
|
|
42
|
+
decorators.push("@IsNotEmpty()");
|
|
43
|
+
decorators.push(`@IsString()`); // Simplified - all fields are strings in current schema
|
|
44
|
+
const optional = !field.required ? "?" : "";
|
|
45
|
+
return ` ${decorators.join("\n ")}\n ${field.name}${optional}: ${field.tsType};`;
|
|
46
|
+
})
|
|
47
|
+
.join("\n\n");
|
|
48
|
+
// Build relationship validation (exclude contextKey - same as POST)
|
|
49
|
+
const relationshipFields = relationships
|
|
50
|
+
.filter((rel) => !rel.contextKey) // Exclude Author and other contextKey relationships
|
|
51
|
+
.map((rel) => {
|
|
52
|
+
const decorators = [];
|
|
53
|
+
const dtoClass = rel.cardinality === "many" ? `${rel.relatedEntity.name}DataListDTO` : `${rel.relatedEntity.name}DataDTO`;
|
|
54
|
+
if (rel.cardinality === "many") {
|
|
55
|
+
decorators.push("@ValidateNested({ each: true })");
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
decorators.push("@ValidateNested()");
|
|
59
|
+
}
|
|
60
|
+
if (rel.nullable) {
|
|
61
|
+
decorators.push("@IsOptional()");
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
decorators.push("@IsDefined()");
|
|
65
|
+
}
|
|
66
|
+
decorators.push(`@Type(() => ${dtoClass})`);
|
|
67
|
+
const optional = rel.nullable ? "?" : "";
|
|
68
|
+
const dtoKey = rel.dtoKey || rel.key;
|
|
69
|
+
return ` ${decorators.join("\n ")}\n ${dtoKey}${optional}: ${dtoClass};`;
|
|
70
|
+
})
|
|
71
|
+
.join("\n\n");
|
|
72
|
+
return `import { Type } from "class-transformer";
|
|
73
|
+
import { Equals, IsDefined, IsNotEmpty, IsOptional, IsString, IsUUID, ValidateNested } from "class-validator";${dtoImportsCode}
|
|
74
|
+
import { ${names.pascalCase}Descriptor } from "src/${targetDir}/${names.kebabCase}/entities/${names.kebabCase}";
|
|
75
|
+
|
|
76
|
+
export class ${names.pascalCase}PutAttributesDTO {
|
|
77
|
+
${attributeFields}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export class ${names.pascalCase}PutRelationshipsDTO {
|
|
81
|
+
${relationshipFields || " // No relationships (excluding contextKey relationships)"}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export class ${names.pascalCase}PutDataDTO {
|
|
85
|
+
@Equals(${names.pascalCase}Descriptor.model.endpoint)
|
|
86
|
+
type: string;
|
|
87
|
+
|
|
88
|
+
@IsUUID()
|
|
89
|
+
id: string;
|
|
90
|
+
|
|
91
|
+
@ValidateNested()
|
|
92
|
+
@IsNotEmpty()
|
|
93
|
+
@Type(() => ${names.pascalCase}PutAttributesDTO)
|
|
94
|
+
attributes: ${names.pascalCase}PutAttributesDTO;
|
|
95
|
+
|
|
96
|
+
@ValidateNested()
|
|
97
|
+
@IsNotEmpty()
|
|
98
|
+
@Type(() => ${names.pascalCase}PutRelationshipsDTO)
|
|
99
|
+
relationships: ${names.pascalCase}PutRelationshipsDTO;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export class ${names.pascalCase}PutDTO {
|
|
103
|
+
@ValidateNested()
|
|
104
|
+
@IsNotEmpty()
|
|
105
|
+
@Type(() => ${names.pascalCase}PutDataDTO)
|
|
106
|
+
data: ${names.pascalCase}PutDataDTO;
|
|
107
|
+
}
|
|
108
|
+
`;
|
|
109
|
+
}
|
|
110
|
+
//# 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":";;AAUA,gDA8GC;AAvHD,qEAAyF;AAEzF;;;;;;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;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,QAAQ,GAAG,CAAC,CAAC;QAE5C,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QACzC,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC;QACrC,OAAO,KAAK,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,MAAM,GAAG,QAAQ,KAAK,QAAQ,GAAG,CAAC;IAC9E,CAAC,CAAC;SACD,IAAI,CAAC,MAAM,CAAC,CAAC;IAEhB,OAAO;gHACuG,cAAc;WACnH,KAAK,CAAC,UAAU,0BAA0B,SAAS,IAAI,KAAK,CAAC,SAAS,aAAa,KAAK,CAAC,SAAS;;eAE9F,KAAK,CAAC,UAAU;EAC7B,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;AAGhE;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAkI7D"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateEntityFile = generateEntityFile;
|
|
4
|
+
const import_resolver_1 = require("../transformers/import-resolver");
|
|
5
|
+
/**
|
|
6
|
+
* Generate entity file content (Type + Descriptor)
|
|
7
|
+
*
|
|
8
|
+
* This is the most critical file - it defines both the TypeScript type
|
|
9
|
+
* and the descriptor using defineEntity()
|
|
10
|
+
*
|
|
11
|
+
* @param data - Template data
|
|
12
|
+
* @returns Generated TypeScript code
|
|
13
|
+
*/
|
|
14
|
+
function generateEntityFile(data) {
|
|
15
|
+
const { names, endpoint, nodeName, labelName, fields, relationships, entityImports, metaImports } = data;
|
|
16
|
+
// Build imports
|
|
17
|
+
const libraryImports = ["defineEntity", "Entity"];
|
|
18
|
+
if (data.isCompanyScoped) {
|
|
19
|
+
libraryImports.push("Company");
|
|
20
|
+
}
|
|
21
|
+
// Add entity imports for relationships
|
|
22
|
+
const uniqueEntityImports = new Set();
|
|
23
|
+
const entityImportsByPath = new Map();
|
|
24
|
+
for (const rel of relationships) {
|
|
25
|
+
if (!uniqueEntityImports.has(rel.relatedEntity.name)) {
|
|
26
|
+
uniqueEntityImports.add(rel.relatedEntity.name);
|
|
27
|
+
// Group by import path
|
|
28
|
+
const importPath = (0, import_resolver_1.isFoundationImport)(rel.relatedEntity.directory)
|
|
29
|
+
? import_resolver_1.FOUNDATION_PACKAGE
|
|
30
|
+
: `../../${rel.relatedEntity.directory}/${rel.relatedEntity.kebabCase}/entities/${rel.relatedEntity.kebabCase}.entity`;
|
|
31
|
+
if (!entityImportsByPath.has(importPath)) {
|
|
32
|
+
entityImportsByPath.set(importPath, []);
|
|
33
|
+
}
|
|
34
|
+
entityImportsByPath.get(importPath).push(rel.relatedEntity.name);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// Add meta imports for relationships
|
|
38
|
+
const uniqueMetaImports = new Set();
|
|
39
|
+
const metaImportsByPath = new Map();
|
|
40
|
+
for (const rel of relationships) {
|
|
41
|
+
if (!uniqueMetaImports.has(rel.model)) {
|
|
42
|
+
uniqueMetaImports.add(rel.model);
|
|
43
|
+
// Group by import path
|
|
44
|
+
const importPath = (0, import_resolver_1.isFoundationImport)(rel.relatedEntity.directory)
|
|
45
|
+
? import_resolver_1.FOUNDATION_PACKAGE
|
|
46
|
+
: `../../${rel.relatedEntity.directory}/${rel.relatedEntity.kebabCase}/entities/${rel.relatedEntity.kebabCase}.meta`;
|
|
47
|
+
if (!metaImportsByPath.has(importPath)) {
|
|
48
|
+
metaImportsByPath.set(importPath, []);
|
|
49
|
+
}
|
|
50
|
+
metaImportsByPath.get(importPath).push(rel.model);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// Build field definitions for descriptor
|
|
54
|
+
const fieldDefinitions = fields
|
|
55
|
+
.map((field) => {
|
|
56
|
+
const parts = [];
|
|
57
|
+
parts.push(`type: "${field.type}"`);
|
|
58
|
+
if (field.required) {
|
|
59
|
+
parts.push(`required: true`);
|
|
60
|
+
}
|
|
61
|
+
return ` ${field.name}: { ${parts.join(", ")} },`;
|
|
62
|
+
})
|
|
63
|
+
.join("\n");
|
|
64
|
+
// Build relationship definitions for descriptor
|
|
65
|
+
const relationshipDefinitions = relationships
|
|
66
|
+
.map((rel) => {
|
|
67
|
+
const parts = [];
|
|
68
|
+
parts.push(`model: ${rel.model}`);
|
|
69
|
+
parts.push(`direction: "${rel.direction}"`);
|
|
70
|
+
parts.push(`relationship: "${rel.relationship}"`);
|
|
71
|
+
parts.push(`cardinality: "${rel.cardinality}"`);
|
|
72
|
+
if (rel.contextKey) {
|
|
73
|
+
parts.push(`contextKey: "${rel.contextKey}"`);
|
|
74
|
+
}
|
|
75
|
+
if (rel.dtoKey) {
|
|
76
|
+
parts.push(`dtoKey: "${rel.dtoKey}"`);
|
|
77
|
+
}
|
|
78
|
+
return ` ${rel.key}: {\n ${parts.join(",\n ")},\n },`;
|
|
79
|
+
})
|
|
80
|
+
.join("\n");
|
|
81
|
+
return `import { ${libraryImports.join(", ")} } from "@carlonicora/nestjs-neo4jsonapi";
|
|
82
|
+
${Array.from(entityImportsByPath.entries())
|
|
83
|
+
.map(([path, items]) => `import { ${items.join(", ")} } from "${path}";`)
|
|
84
|
+
.join("\n")}
|
|
85
|
+
${Array.from(metaImportsByPath.entries())
|
|
86
|
+
.map(([path, items]) => `import { ${items.join(", ")} } from "${path}";`)
|
|
87
|
+
.join("\n")}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* ${names.pascalCase} Entity Type
|
|
91
|
+
*/
|
|
92
|
+
export type ${names.pascalCase} = Entity & {
|
|
93
|
+
${fields
|
|
94
|
+
.map((field) => {
|
|
95
|
+
const optional = !field.required ? "?" : "";
|
|
96
|
+
return ` ${field.name}${optional}: ${field.tsType};`;
|
|
97
|
+
})
|
|
98
|
+
.join("\n")}
|
|
99
|
+
|
|
100
|
+
${data.isCompanyScoped ? " company: Company;\n" : ""}${relationships
|
|
101
|
+
.map((rel) => {
|
|
102
|
+
const optional = rel.nullable ? "?" : "";
|
|
103
|
+
const type = rel.cardinality === "many" ? `${rel.relatedEntity.name}[]` : rel.relatedEntity.name;
|
|
104
|
+
return ` ${rel.key}${optional}: ${type};`;
|
|
105
|
+
})
|
|
106
|
+
.join("\n")}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* ${names.pascalCase} Entity Descriptor
|
|
111
|
+
*
|
|
112
|
+
* Single source of truth for the ${names.pascalCase} entity configuration.
|
|
113
|
+
* Auto-generates mapper, serialiser, constraints, and indexes.
|
|
114
|
+
*/
|
|
115
|
+
export const ${names.pascalCase}Descriptor = defineEntity<${names.pascalCase}>()({
|
|
116
|
+
type: "${endpoint}",
|
|
117
|
+
endpoint: "${endpoint}",
|
|
118
|
+
nodeName: "${nodeName}",
|
|
119
|
+
labelName: "${labelName}",
|
|
120
|
+
${!data.isCompanyScoped ? "\n isCompanyScoped: false,\n" : ""}
|
|
121
|
+
fields: {
|
|
122
|
+
${fieldDefinitions}
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
relationships: {
|
|
126
|
+
${relationshipDefinitions}
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
export type ${names.pascalCase}DescriptorType = typeof ${names.pascalCase}Descriptor;
|
|
131
|
+
`;
|
|
132
|
+
}
|
|
133
|
+
//# 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":";;AAYA,gDAkIC;AA7ID,qEAAyF;AAEzF;;;;;;;;GAQG;AACH,SAAgB,kBAAkB,CAAC,IAAkB;IACnD,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;IAEzG,gBAAgB;IAChB,MAAM,cAAc,GAAG,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;IAClD,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;QACzB,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACjC,CAAC;IAED,uCAAuC;IACvC,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9C,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAAoB,CAAC;IAExD,KAAK,MAAM,GAAG,IAAI,aAAa,EAAE,CAAC;QAChC,IAAI,CAAC,m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AAC,CAAC,EAAE,GAAG,aAAa;SAClE,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;QACX,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,GAAG,GAAG,CAAC,WAAW,KAAK,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC;QACjG,OAAO,KAAK,GAAG,CAAC,GAAG,GAAG,QAAQ,KAAK,IAAI,GAAG,CAAC;IAC7C,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC;;;;KAIR,KAAK,CAAC,UAAU;;oCAEe,KAAK,CAAC,UAAU;;;eAGrC,KAAK,CAAC,UAAU,6BAA6B,KAAK,CAAC,UAAU;WACjE,QAAQ;eACJ,QAAQ;eACR,QAAQ;gBACP,SAAS;EACvB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,+BAA+B,CAAC,CAAC,CAAC,EAAE;;EAE5D,gBAAgB;;;;EAIhB,uBAAuB;;;;cAIX,KAAK,CAAC,UAAU,2BAA2B,KAAK,CAAC,UAAU;CACxE,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TemplateData } from "../types/template-data.interface";
|
|
2
|
+
/**
|
|
3
|
+
* Generate module file content
|
|
4
|
+
*
|
|
5
|
+
* @param data - Template data
|
|
6
|
+
* @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"}
|