@rxap/schematics-ts-morph 16.1.0-dev.1 → 16.1.0-dev.11
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/CHANGELOG.md +76 -0
- package/README.md +1 -1
- package/package.json +13 -10
- package/src/index.d.ts +7 -2
- package/src/index.js +7 -2
- package/src/index.js.map +1 -1
- package/src/lib/angular/coerce-component.d.ts +6 -0
- package/src/lib/angular/coerce-component.js +57 -2
- package/src/lib/angular/coerce-component.js.map +1 -1
- package/src/lib/angular/coerce-dialog-table-action-component.js +2 -2
- package/src/lib/angular/coerce-dialog-table-action-component.js.map +1 -1
- package/src/lib/angular/coerce-form-definition-array.d.ts +14 -0
- package/src/lib/angular/coerce-form-definition-array.js +87 -0
- package/src/lib/angular/coerce-form-definition-array.js.map +1 -0
- package/src/lib/angular/coerce-form-definition-control.d.ts +9 -12
- package/src/lib/angular/coerce-form-definition-control.js +68 -125
- package/src/lib/angular/coerce-form-definition-control.js.map +1 -1
- package/src/lib/angular/coerce-form-definition-form-control.d.ts +11 -0
- package/src/lib/angular/coerce-form-definition-form-control.js +66 -0
- package/src/lib/angular/coerce-form-definition-form-control.js.map +1 -0
- package/src/lib/angular/coerce-form-definition-group.d.ts +14 -0
- package/src/lib/angular/coerce-form-definition-group.js +80 -0
- package/src/lib/angular/coerce-form-definition-group.js.map +1 -0
- package/src/lib/angular/coerce-form-definition-type.d.ts +2 -2
- package/src/lib/angular/coerce-form-definition-type.js +16 -2
- package/src/lib/angular/coerce-form-definition-type.js.map +1 -1
- package/src/lib/angular/coerce-form-definition.d.ts +4 -4
- package/src/lib/angular/coerce-form-definition.js +24 -13
- package/src/lib/angular/coerce-form-definition.js.map +1 -1
- package/src/lib/angular/coerce-options-data-source.d.ts +3 -1
- package/src/lib/angular/coerce-options-data-source.js +35 -6
- package/src/lib/angular/coerce-options-data-source.js.map +1 -1
- package/src/lib/angular/coerce-proxy-remote-method-class.d.ts +2 -2
- package/src/lib/angular/coerce-proxy-remote-method-class.js +15 -18
- package/src/lib/angular/coerce-proxy-remote-method-class.js.map +1 -1
- package/src/lib/angular/coerce-table-data-source.js +1 -1
- package/src/lib/angular/coerce-table-data-source.js.map +1 -1
- package/src/lib/angular/coerce-table-parameters-from-route.js +4 -4
- package/src/lib/angular/coerce-table-parameters-from-route.js.map +1 -1
- package/src/lib/angular/coerce-table-select-resolve-value-method.js +2 -2
- package/src/lib/angular/coerce-table-select-resolve-value-method.js.map +1 -1
- package/src/lib/angular/coerce-tree-table-children-proxy-remote-method-class.js +2 -2
- package/src/lib/angular/coerce-tree-table-children-proxy-remote-method-class.js.map +1 -1
- package/src/lib/angular/form-definition-utilities.d.ts +1 -0
- package/src/lib/angular/form-definition-utilities.js +7 -3
- package/src/lib/angular/form-definition-utilities.js.map +1 -1
- package/src/lib/nest/add-operation-to-controller.d.ts +1 -1
- package/src/lib/nest/add-operation-to-controller.js +59 -55
- package/src/lib/nest/add-operation-to-controller.js.map +1 -1
- package/src/lib/nest/build-nest-controller-name.js +10 -0
- package/src/lib/nest/build-nest-controller-name.js.map +1 -1
- package/src/lib/nest/coerce-dto-class.d.ts +3 -15
- package/src/lib/nest/coerce-dto-class.js +56 -63
- package/src/lib/nest/coerce-dto-class.js.map +1 -1
- package/src/lib/nest/coerce-form-submit-operation.d.ts +2 -4
- package/src/lib/nest/coerce-form-submit-operation.js +13 -15
- package/src/lib/nest/coerce-form-submit-operation.js.map +1 -1
- package/src/lib/nest/coerce-get-by-id-operation.d.ts +9 -7
- package/src/lib/nest/coerce-get-by-id-operation.js +85 -56
- package/src/lib/nest/coerce-get-by-id-operation.js.map +1 -1
- package/src/lib/nest/coerce-get-children-operation.js +8 -46
- package/src/lib/nest/coerce-get-children-operation.js.map +1 -1
- package/src/lib/nest/coerce-get-data-grid-operation.d.ts +5 -4
- package/src/lib/nest/coerce-get-data-grid-operation.js +7 -22
- package/src/lib/nest/coerce-get-data-grid-operation.js.map +1 -1
- package/src/lib/nest/coerce-get-operation.d.ts +5 -0
- package/src/lib/nest/coerce-get-operation.js +11 -0
- package/src/lib/nest/coerce-get-operation.js.map +1 -0
- package/src/lib/nest/coerce-get-page-operation.d.ts +17 -27
- package/src/lib/nest/coerce-get-page-operation.js +157 -145
- package/src/lib/nest/coerce-get-page-operation.js.map +1 -1
- package/src/lib/nest/coerce-get-root-operation.d.ts +2 -4
- package/src/lib/nest/coerce-get-root-operation.js +8 -28
- package/src/lib/nest/coerce-get-root-operation.js.map +1 -1
- package/src/lib/nest/coerce-operation.d.ts +32 -9
- package/src/lib/nest/coerce-operation.js +191 -29
- package/src/lib/nest/coerce-operation.js.map +1 -1
- package/src/lib/nest/coerce-options-operation.d.ts +2 -2
- package/src/lib/nest/coerce-options-operation.js +13 -42
- package/src/lib/nest/coerce-options-operation.js.map +1 -1
- package/src/lib/nest/coerce-page-dto-class.d.ts +3 -8
- package/src/lib/nest/coerce-page-dto-class.js +52 -22
- package/src/lib/nest/coerce-page-dto-class.js.map +1 -1
- package/src/lib/nest/coerce-row-dto-class.d.ts +1 -0
- package/src/lib/nest/coerce-row-dto-class.js +12 -10
- package/src/lib/nest/coerce-row-dto-class.js.map +1 -1
- package/src/lib/nest/coerce-submit-data-grid-operation.js +3 -7
- package/src/lib/nest/coerce-submit-data-grid-operation.js.map +1 -1
- package/src/lib/nest/coerce-table-select-operation.js +6 -6
- package/src/lib/nest/coerce-table-select-operation.js.map +1 -1
- package/src/lib/nest/coerce-table-select-value-resolve-operation.d.ts +7 -6
- package/src/lib/nest/coerce-table-select-value-resolve-operation.js +32 -33
- package/src/lib/nest/coerce-table-select-value-resolve-operation.js.map +1 -1
- package/src/lib/nest/coerce-tree-operation.js +35 -44
- package/src/lib/nest/coerce-tree-operation.js.map +1 -1
- package/src/lib/nest/dto-class-property.d.ts +18 -0
- package/src/lib/nest/dto-class-property.js +26 -0
- package/src/lib/nest/dto-class-property.js.map +1 -0
- package/src/lib/nest/table-query-list.d.ts +2 -0
- package/src/lib/nest/table-query-list.js +41 -0
- package/src/lib/nest/table-query-list.js.map +1 -0
- package/src/lib/ts-morph/coerce-imports.js +1 -1
- package/src/lib/ts-morph/coerce-imports.js.map +1 -1
- package/src/lib/types/abstract-control.d.ts +8 -0
- package/src/lib/types/{form-definition-control.js → abstract-control.js} +1 -1
- package/src/lib/types/abstract-control.js.map +1 -0
- package/src/lib/nest/create-dto-class.d.ts +0 -24
- package/src/lib/nest/create-dto-class.js +0 -169
- package/src/lib/nest/create-dto-class.js.map +0 -1
- package/src/lib/types/form-definition-control.d.ts +0 -10
- package/src/lib/types/form-definition-control.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-nest-controller-name.js","sourceRoot":"","sources":["../../../../../../../packages/schematic/ts-morph/src/lib/nest/build-nest-controller-name.ts"],"names":[],"mappings":";;;AAAA,2DAAiE;AACjE,qEAA0D;AAQ1D,SAAgB,uBAAuB,CAAC,OAAuC;IAC7E,IAAI,EACF,cAAc,EACd,oBAAoB,EACpB,UAAU,GACX,GAAG,OAAO,CAAC;IAEZ,IAAI,UAAU,IAAI,UAAU,KAAK,cAAc,EAAE;QAC/C,IAAI,cAAc,EAAE;YAClB,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;gBAC1C,cAAc,GAAG,CAAE,UAAU,EAAE,cAAc,CAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;aAC3D;SACF;aAAM;YACL,cAAc,GAAG,UAAU,CAAC;SAC7B;KACF;IAED,IAAI,oBAAoB,EAAE;QACxB,cAAc,GAAG,IAAA,mCAAY,EAAC,cAAe,EAAE,GAAG,GAAG,oBAAoB,CAAC,CAAC;KAC5E;IAED,IAAI,CAAC,cAAc,EAAE;QACnB,MAAM,IAAI,gCAAmB,CAAC,yCAAyC,CAAC,CAAC;KAC1E;IAED,OAAO,cAAc,CAAC;AAExB,CAAC;
|
|
1
|
+
{"version":3,"file":"build-nest-controller-name.js","sourceRoot":"","sources":["../../../../../../../packages/schematic/ts-morph/src/lib/nest/build-nest-controller-name.ts"],"names":[],"mappings":";;;AAAA,2DAAiE;AACjE,qEAA0D;AAQ1D,SAAgB,uBAAuB,CAAC,OAAuC;IAC7E,IAAI,EACF,cAAc,EACd,oBAAoB,EACpB,UAAU,GACX,GAAG,OAAO,CAAC;IAEZ,IAAI,UAAU,IAAI,UAAU,KAAK,cAAc,EAAE;QAC/C,OAAO,CAAC,GAAG,CAAC,4DAA4D,CAAC,CAAC;QAC1E,IAAI,cAAc,EAAE;YAClB,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;YAC9C,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;gBAC1C,OAAO,CAAC,GAAG,CAAC,+DAA+D,CAAC,CAAC;gBAC7E,cAAc,GAAG,CAAE,UAAU,EAAE,cAAc,CAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;aAC3D;iBAAM;gBACL,OAAO,CAAC,IAAI,CAAC,mEAAmE,CAAC,CAAC;aACnF;SACF;aAAM;YACL,OAAO,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;YACnD,cAAc,GAAG,UAAU,CAAC;SAC7B;KACF;SAAM;QACL,OAAO,CAAC,GAAG,CAAC,yDAAyD,CAAC,CAAC;KACxE;IAED,IAAI,oBAAoB,EAAE;QACxB,cAAc,GAAG,IAAA,mCAAY,EAAC,cAAe,EAAE,GAAG,GAAG,oBAAoB,CAAC,CAAC;KAC5E;IAED,IAAI,CAAC,cAAc,EAAE;QACnB,MAAM,IAAI,gCAAmB,CAAC,yCAAyC,CAAC,CAAC;KAC1E;IAED,OAAO,cAAc,CAAC;AAExB,CAAC;AAnCD,0DAmCC"}
|
|
@@ -1,28 +1,16 @@
|
|
|
1
|
-
import { ClassDeclaration,
|
|
2
|
-
import { DtoClassProperty } from './
|
|
1
|
+
import { ClassDeclaration, Project, SourceFile } from 'ts-morph';
|
|
2
|
+
import { DtoClassProperty } from './dto-class-property';
|
|
3
|
+
import 'colors';
|
|
3
4
|
export interface CoerceDtoClassOutput {
|
|
4
5
|
className: string;
|
|
5
6
|
filePath: string;
|
|
6
7
|
sourceFile: SourceFile;
|
|
7
8
|
classDeclaration: ClassDeclaration;
|
|
8
9
|
}
|
|
9
|
-
/**
|
|
10
|
-
* @deprecated import from @rxap/ts-morph
|
|
11
|
-
*/
|
|
12
|
-
export declare function CoercePropertyDeclaration(typeElementMemberedNode: TypeElementMemberedNode, name: string, structure?: Partial<PropertyDeclarationStructure>): PropertySignature;
|
|
13
|
-
export declare function CoercePropertyDeclaration(classLikeDeclarationBase: ClassLikeDeclarationBase, name: string, structure?: Partial<PropertyDeclarationStructure>): PropertyDeclaration;
|
|
14
10
|
export interface CoerceDtoClassOptions {
|
|
15
11
|
project: Project;
|
|
16
12
|
name: string;
|
|
17
13
|
propertyList?: DtoClassProperty[];
|
|
18
|
-
/**
|
|
19
|
-
* @deprecated use the tsMorphTransform to adapt the class
|
|
20
|
-
*/
|
|
21
|
-
classStructure?: Omit<OptionalKind<ClassDeclarationStructure>, 'name'>;
|
|
22
|
-
/**
|
|
23
|
-
* @deprecated use the tsMorphTransform to add imports
|
|
24
|
-
*/
|
|
25
|
-
importStructureList?: Array<OptionalKind<ImportDeclarationStructure>>;
|
|
26
14
|
tsMorphTransform?: (project: Project, sourceFile: SourceFile, classDeclaration: ClassDeclaration) => void;
|
|
27
15
|
}
|
|
28
16
|
export declare function CoerceDtoClass(options: CoerceDtoClassOptions): CoerceDtoClassOutput;
|
|
@@ -1,37 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CoerceDtoClass =
|
|
3
|
+
exports.CoerceDtoClass = void 0;
|
|
4
4
|
const schematics_utilities_1 = require("@rxap/schematics-utilities");
|
|
5
|
+
const ts_morph_1 = require("@rxap/ts-morph");
|
|
5
6
|
const utilities_1 = require("@rxap/utilities");
|
|
6
7
|
const path_1 = require("path");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
const coerce_decorator_1 = require("../ts-morph/coerce-decorator");
|
|
11
|
-
const coerce_imports_1 = require("../ts-morph/coerce-imports");
|
|
12
|
-
const ts_morph_2 = require("@rxap/ts-morph");
|
|
13
|
-
function CoercePropertyDeclaration(node, name, structure = {}) {
|
|
14
|
-
let property = node.getProperty(name);
|
|
15
|
-
if (!property) {
|
|
16
|
-
property = node.addProperty({ name });
|
|
17
|
-
property.set(structure);
|
|
18
|
-
}
|
|
19
|
-
return property;
|
|
20
|
-
}
|
|
21
|
-
exports.CoercePropertyDeclaration = CoercePropertyDeclaration;
|
|
8
|
+
const ts_morph_2 = require("ts-morph");
|
|
9
|
+
const dto_class_property_1 = require("./dto-class-property");
|
|
10
|
+
require("colors");
|
|
22
11
|
function CoerceDtoClass(options) {
|
|
23
|
-
|
|
12
|
+
var _a;
|
|
13
|
+
const { project, propertyList = [], tsMorphTransform = utilities_1.noop, } = options;
|
|
24
14
|
let { name, } = options;
|
|
25
15
|
name = (0, schematics_utilities_1.dasherize)(name);
|
|
26
16
|
const className = (0, schematics_utilities_1.CoerceSuffix)((0, schematics_utilities_1.classify)(name), 'Dto');
|
|
27
17
|
const fileName = (0, schematics_utilities_1.CoerceSuffix)(name, '.dto');
|
|
28
|
-
const sourceFile = (0,
|
|
29
|
-
const classDeclaration = (0,
|
|
18
|
+
const sourceFile = (0, ts_morph_1.CoerceSourceFile)(project, (0, path_1.join)('dtos', fileName + '.ts'));
|
|
19
|
+
const classDeclaration = (0, ts_morph_1.CoerceClass)(sourceFile, className);
|
|
30
20
|
classDeclaration.setIsExported(true);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
property.
|
|
21
|
+
for (const property of propertyList.map(dto_class_property_1.NormalizeDataClassProperty)) {
|
|
22
|
+
if (property.type.name === '<self>') {
|
|
23
|
+
property.type.name = className;
|
|
24
|
+
property.isType = true;
|
|
35
25
|
}
|
|
36
26
|
let propertyName = (0, schematics_utilities_1.camelize)(property.name);
|
|
37
27
|
const prefixMatch = property.name.match(/^(_+)/);
|
|
@@ -39,146 +29,149 @@ function CoerceDtoClass(options) {
|
|
|
39
29
|
propertyName = (0, schematics_utilities_1.camelize)(property.name.replace(/^_+/, ''));
|
|
40
30
|
propertyName = prefixMatch[0] + propertyName;
|
|
41
31
|
}
|
|
42
|
-
const propertyDeclaration = CoercePropertyDeclaration(classDeclaration, propertyName).set({
|
|
43
|
-
type: (0,
|
|
44
|
-
hasQuestionToken:
|
|
32
|
+
const propertyDeclaration = (0, ts_morph_1.CoercePropertyDeclaration)(classDeclaration, propertyName).set({
|
|
33
|
+
type: (0, ts_morph_1.WriteType)(property, sourceFile),
|
|
34
|
+
hasQuestionToken: property.isOptional,
|
|
45
35
|
hasExclamationToken: !property.isOptional,
|
|
46
36
|
});
|
|
47
|
-
(0,
|
|
37
|
+
(0, ts_morph_1.CoerceDecorator)(propertyDeclaration, 'Expose', {
|
|
48
38
|
arguments: [],
|
|
49
39
|
});
|
|
50
|
-
|
|
40
|
+
(0, ts_morph_1.CoerceImports)(sourceFile, {
|
|
51
41
|
namedImports: ['Expose'],
|
|
52
42
|
moduleSpecifier: 'class-transformer',
|
|
53
43
|
});
|
|
54
44
|
if (property.isArray) {
|
|
55
|
-
(0,
|
|
45
|
+
(0, ts_morph_1.CoerceDecorator)(propertyDeclaration, 'IsArray', {
|
|
56
46
|
arguments: [],
|
|
57
47
|
});
|
|
58
|
-
|
|
48
|
+
(0, ts_morph_1.CoerceImports)(sourceFile, {
|
|
59
49
|
namedImports: ['IsArray'],
|
|
60
50
|
moduleSpecifier: 'class-validator',
|
|
61
51
|
});
|
|
62
52
|
}
|
|
63
53
|
if (property.isType) {
|
|
64
|
-
(0,
|
|
54
|
+
(0, ts_morph_1.CoerceDecorator)(propertyDeclaration, 'Type', {
|
|
65
55
|
arguments: [
|
|
66
56
|
w => {
|
|
67
57
|
w.write('() => ');
|
|
68
|
-
(0,
|
|
58
|
+
(0, ts_morph_1.WriteType)({
|
|
69
59
|
type: property.type,
|
|
70
60
|
isArray: false
|
|
71
61
|
}, sourceFile)(w);
|
|
72
62
|
},
|
|
73
63
|
],
|
|
74
64
|
});
|
|
75
|
-
|
|
65
|
+
(0, ts_morph_1.CoerceImports)(sourceFile, {
|
|
76
66
|
namedImports: ['Type'],
|
|
77
67
|
moduleSpecifier: 'class-transformer',
|
|
78
68
|
});
|
|
79
|
-
(0,
|
|
69
|
+
(0, ts_morph_1.CoerceDecorator)(propertyDeclaration, 'IsInstance', {
|
|
80
70
|
arguments: [
|
|
81
|
-
(0,
|
|
71
|
+
(0, ts_morph_1.WriteType)({
|
|
82
72
|
type: property.type,
|
|
83
73
|
isArray: false
|
|
84
74
|
}, sourceFile),
|
|
85
75
|
w => {
|
|
86
76
|
if (property.isArray) {
|
|
87
|
-
|
|
77
|
+
ts_morph_2.Writers.object({ each: 'true' })(w);
|
|
88
78
|
}
|
|
89
79
|
},
|
|
90
80
|
],
|
|
91
81
|
});
|
|
92
|
-
|
|
82
|
+
(0, ts_morph_1.CoerceImports)(sourceFile, {
|
|
93
83
|
namedImports: ['IsInstance'],
|
|
94
84
|
moduleSpecifier: 'class-validator',
|
|
95
85
|
});
|
|
96
86
|
}
|
|
97
87
|
if (property.isOptional) {
|
|
98
|
-
(0,
|
|
88
|
+
(0, ts_morph_1.CoerceDecorator)(propertyDeclaration, 'IsOptional', {
|
|
99
89
|
arguments: [],
|
|
100
90
|
});
|
|
101
|
-
|
|
91
|
+
(0, ts_morph_1.CoerceImports)(sourceFile, {
|
|
102
92
|
namedImports: ['IsOptional'],
|
|
103
93
|
moduleSpecifier: 'class-validator',
|
|
104
94
|
});
|
|
105
95
|
}
|
|
106
|
-
|
|
107
|
-
if (typeof property.type === 'string') {
|
|
108
|
-
autoType = property.type;
|
|
109
|
-
}
|
|
110
|
-
else if (typeof property.type === 'object') {
|
|
111
|
-
autoType = property.type.name;
|
|
112
|
-
}
|
|
113
|
-
switch (autoType) {
|
|
96
|
+
switch (property.type.name) {
|
|
114
97
|
case 'date':
|
|
115
|
-
(0,
|
|
98
|
+
(0, ts_morph_1.CoerceDecorator)(propertyDeclaration, 'IsDate', {
|
|
116
99
|
arguments: [],
|
|
117
100
|
});
|
|
118
|
-
|
|
101
|
+
(0, ts_morph_1.CoerceImports)(sourceFile, {
|
|
119
102
|
namedImports: ['IsDate'],
|
|
120
103
|
moduleSpecifier: 'class-validator',
|
|
121
104
|
});
|
|
122
105
|
break;
|
|
123
106
|
case 'number':
|
|
124
|
-
(0,
|
|
107
|
+
(0, ts_morph_1.CoerceDecorator)(propertyDeclaration, 'IsNumber', {
|
|
125
108
|
arguments: [],
|
|
126
109
|
});
|
|
127
|
-
|
|
110
|
+
(0, ts_morph_1.CoerceImports)(sourceFile, {
|
|
128
111
|
namedImports: ['IsNumber'],
|
|
129
112
|
moduleSpecifier: 'class-validator',
|
|
130
113
|
});
|
|
131
114
|
break;
|
|
132
115
|
case 'string':
|
|
133
116
|
if (property.name === 'uuid') {
|
|
134
|
-
|
|
117
|
+
(0, ts_morph_1.CoerceImports)(sourceFile, {
|
|
135
118
|
namedImports: ['IsUUID'],
|
|
136
119
|
moduleSpecifier: 'class-validator',
|
|
137
120
|
});
|
|
138
|
-
(0,
|
|
121
|
+
(0, ts_morph_1.CoerceDecorator)(propertyDeclaration, 'IsUUID', {
|
|
139
122
|
arguments: [],
|
|
140
123
|
});
|
|
141
124
|
}
|
|
142
125
|
else {
|
|
143
|
-
|
|
126
|
+
(0, ts_morph_1.CoerceImports)(sourceFile, {
|
|
144
127
|
namedImports: ['IsString'],
|
|
145
128
|
moduleSpecifier: 'class-validator',
|
|
146
129
|
});
|
|
147
|
-
(0,
|
|
130
|
+
(0, ts_morph_1.CoerceDecorator)(propertyDeclaration, 'IsString', {
|
|
148
131
|
arguments: [],
|
|
149
132
|
});
|
|
150
133
|
}
|
|
151
134
|
break;
|
|
152
135
|
case 'uuid':
|
|
153
|
-
(0,
|
|
136
|
+
(0, ts_morph_1.CoerceDecorator)(propertyDeclaration, 'IsUUID', {
|
|
154
137
|
arguments: [],
|
|
155
138
|
});
|
|
156
|
-
|
|
139
|
+
(0, ts_morph_1.CoerceImports)(sourceFile, {
|
|
157
140
|
namedImports: ['IsUUID'],
|
|
158
141
|
moduleSpecifier: 'class-validator',
|
|
159
142
|
});
|
|
160
143
|
break;
|
|
161
144
|
case 'boolean':
|
|
162
|
-
(0,
|
|
145
|
+
(0, ts_morph_1.CoerceDecorator)(propertyDeclaration, 'IsBoolean', {
|
|
163
146
|
arguments: [],
|
|
164
147
|
});
|
|
165
|
-
|
|
148
|
+
(0, ts_morph_1.CoerceImports)(sourceFile, {
|
|
166
149
|
namedImports: ['IsBoolean'],
|
|
167
150
|
moduleSpecifier: 'class-validator',
|
|
168
151
|
});
|
|
169
152
|
break;
|
|
170
153
|
case 'unknown':
|
|
171
|
-
(0,
|
|
172
|
-
arguments: [
|
|
154
|
+
(0, ts_morph_1.CoerceDecorator)(propertyDeclaration, 'ApiProperty', {
|
|
155
|
+
arguments: [ts_morph_2.Writers.object({ type: w => w.quote('unknown') })],
|
|
173
156
|
});
|
|
174
|
-
|
|
157
|
+
(0, ts_morph_1.CoerceImports)(sourceFile, {
|
|
175
158
|
namedImports: ['ApiProperty'],
|
|
176
159
|
moduleSpecifier: '@nestjs/swagger',
|
|
177
160
|
});
|
|
178
161
|
break;
|
|
179
162
|
}
|
|
163
|
+
if (property.type.name !== 'unknown') {
|
|
164
|
+
const apiProperty = propertyDeclaration.getDecorators().find(d => d.getName() === 'ApiProperty');
|
|
165
|
+
if (apiProperty) {
|
|
166
|
+
const args = apiProperty.getArguments()[0];
|
|
167
|
+
if (args instanceof ts_morph_2.ObjectLiteralExpression) {
|
|
168
|
+
if ((_a = args.getProperty('type')) === null || _a === void 0 ? void 0 : _a.getText().includes('unknown')) {
|
|
169
|
+
apiProperty.remove();
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
180
174
|
}
|
|
181
|
-
(0, coerce_imports_1.CoerceImports)(sourceFile, importStructureList);
|
|
182
175
|
tsMorphTransform(project, sourceFile, classDeclaration);
|
|
183
176
|
return {
|
|
184
177
|
className,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coerce-dto-class.js","sourceRoot":"","sources":["../../../../../../../packages/schematic/ts-morph/src/lib/nest/coerce-dto-class.ts"],"names":[],"mappings":";;;AAAA,qEAKoC;AACpC,+CAAuC;AACvC,+BAA4B;AAC5B,
|
|
1
|
+
{"version":3,"file":"coerce-dto-class.js","sourceRoot":"","sources":["../../../../../../../packages/schematic/ts-morph/src/lib/nest/coerce-dto-class.ts"],"names":[],"mappings":";;;AAAA,qEAKoC;AACpC,6CAOwB;AACxB,+CAAuC;AACvC,+BAA4B;AAC5B,uCAakB;AAClB,6DAG8B;AAC9B,kBAAgB;AAgBhB,SAAgB,cAAc,CAAC,OAA8B;;IAC3D,MAAM,EACJ,OAAO,EACP,YAAY,GAAG,EAAE,EACjB,gBAAgB,GAAG,gBAAI,GACxB,GAAG,OAAO,CAAC;IACZ,IAAI,EACF,IAAI,GACL,GAAG,OAAO,CAAC;IAEZ,IAAI,GAAG,IAAA,gCAAS,EAAC,IAAI,CAAC,CAAC;IAEvB,MAAM,SAAS,GAAG,IAAA,mCAAY,EAAC,IAAA,+BAAQ,EAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC;IACtD,MAAM,QAAQ,GAAG,IAAA,mCAAY,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAE5C,MAAM,UAAU,GAAG,IAAA,2BAAgB,EAAC,OAAO,EAAE,IAAA,WAAI,EAAC,MAAM,EAAE,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC;IAC7E,MAAM,gBAAgB,GAAG,IAAA,sBAAW,EAAC,UAAU,EAAE,SAAS,CAAC,CAAC;IAC5D,gBAAgB,CAAC,aAAa,CAAC,IAAI,CAAC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,EAAE;wBAC3D,WAAW,CAAC,MAAM,EAAE,CAAC;qBACtB;iBACF;aACF;SACF;KAEF;IAED,gBAAgB,CAAC,OAAO,EAAE,UAAU,EAAE,gBAAgB,CAAC,CAAC;IAExD,OAAO;QACL,SAAS;QACT,QAAQ,EAAE,GAAG,GAAG,IAAA,WAAI,EAAC,UAAU,CAAC,gBAAgB,EAAE,EAAE,UAAU,CAAC,2BAA2B,EAAE,CAAC;QAC7F,UAAU;QACV,gBAAgB;KACjB,CAAC;AAEJ,CAAC;AA1OD,wCA0OC"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export interface CoerceFormSubmitOperationOptions extends Omit<CoerceOperationOptions, 'operationName'> {
|
|
4
|
-
propertyList?: DtoClassProperty[];
|
|
1
|
+
import { CoerceGetByIdControllerOptions } from './coerce-get-by-id-operation';
|
|
2
|
+
export interface CoerceFormSubmitOperationOptions extends CoerceGetByIdControllerOptions {
|
|
5
3
|
bodyDtoName?: string;
|
|
6
4
|
}
|
|
7
5
|
export declare function CoerceFormSubmitOperation(options: CoerceFormSubmitOperationOptions): import("@angular-devkit/schematics").Rule;
|
|
@@ -2,22 +2,20 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CoerceFormSubmitOperation = void 0;
|
|
4
4
|
const utilities_1 = require("@rxap/utilities");
|
|
5
|
-
const
|
|
6
|
-
const coerce_dto_class_1 = require("./coerce-dto-class");
|
|
7
|
-
const coerce_operation_1 = require("./coerce-operation");
|
|
5
|
+
const coerce_get_by_id_operation_1 = require("./coerce-get-by-id-operation");
|
|
8
6
|
function CoerceFormSubmitOperation(options) {
|
|
9
|
-
const { tsMorphTransform = utilities_1.noop,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
return Object.assign({ body:
|
|
7
|
+
const { tsMorphTransform = utilities_1.noop, bodyDtoName, isReturnVoid = true,
|
|
8
|
+
// if not explicitly defined the idProperty is set to null, as not each data grid operation has an id
|
|
9
|
+
idProperty = null, operationName = idProperty ? 'submitById' : 'submit', } = options;
|
|
10
|
+
return (0, coerce_get_by_id_operation_1.CoerceGetByIdOperation)(Object.assign(Object.assign({}, options), { operationName,
|
|
11
|
+
isReturnVoid,
|
|
12
|
+
idProperty, buildOperationDtoClassName: (controllerName, { dtoClassName, dtoClassNameSuffix }) => {
|
|
13
|
+
return dtoClassName !== null && dtoClassName !== void 0 ? dtoClassName : (dtoClassNameSuffix ? (0, utilities_1.CoerceSuffix)(bodyDtoName !== null && bodyDtoName !== void 0 ? bodyDtoName : controllerName, dtoClassNameSuffix) : bodyDtoName !== null && bodyDtoName !== void 0 ? bodyDtoName : controllerName);
|
|
14
|
+
}, tsMorphTransform: (project, sourceFile, classDeclaration, controllerName, moduleSourceFile, dto) => {
|
|
15
|
+
if (!dto) {
|
|
16
|
+
throw new Error('The dto must be created for an submit operation');
|
|
17
|
+
}
|
|
18
|
+
return Object.assign({ body: dto.className, method: 'post' }, tsMorphTransform(project, sourceFile, classDeclaration, controllerName, moduleSourceFile, dto));
|
|
21
19
|
} }));
|
|
22
20
|
}
|
|
23
21
|
exports.CoerceFormSubmitOperation = CoerceFormSubmitOperation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coerce-form-submit-operation.js","sourceRoot":"","sources":["../../../../../../../packages/schematic/ts-morph/src/lib/nest/coerce-form-submit-operation.ts"],"names":[],"mappings":";;;AAAA,+CAGyB;AACzB
|
|
1
|
+
{"version":3,"file":"coerce-form-submit-operation.js","sourceRoot":"","sources":["../../../../../../../packages/schematic/ts-morph/src/lib/nest/coerce-form-submit-operation.ts"],"names":[],"mappings":";;;AAAA,+CAGyB;AACzB,6EAGsC;AAMtC,SAAgB,yBAAyB,CAAC,OAAyC;IACjF,MAAM,EACJ,gBAAgB,GAAG,gBAAI,EACvB,WAAW,EACX,YAAY,GAAG,IAAI;IACnB,qGAAqG;IACrG,UAAU,GAAG,IAAI,EACjB,aAAa,GAAG,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,GACrD,GAAG,OAAO,CAAC;IAEZ,OAAO,IAAA,mDAAsB,kCACxB,OAAO,KACV,aAAa;QACb,YAAY;QACZ,UAAU,EACV,0BAA0B,EAAE,CAAC,cAAc,EAAE,EAAE,YAAY,EAAE,kBAAkB,EAAE,EAAE,EAAE;YACnF,OAAO,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,CACrB,kBAAkB,CAAC,CAAC,CAAC,IAAA,wBAAY,EAAC,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,cAAc,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,cAAc,CACrH,CAAC;QACJ,CAAC,EACD,gBAAgB,EAAE,CAChB,OAAO,EACP,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,GAAG,EACH,EAAE;YAEF,IAAI,CAAC,GAAG,EAAE;gBACR,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;aACpE;YAED,uBACE,IAAI,EAAE,GAAG,CAAC,SAAS,EACnB,MAAM,EAAE,MAAM,IACX,gBAAiB,CAAC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,cAAc,EAAE,gBAAgB,EAAE,GAAG,CAAC,EAClG;QAEJ,CAAC,IACD,CAAC;AAEL,CAAC;AA1CD,8DA0CC"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { OperationParameter } from '@rxap/ts-morph';
|
|
2
|
+
import { ClassDeclaration, SourceFile, WriterFunction } from 'ts-morph';
|
|
3
|
+
import { CoerceDtoClassOutput } from './coerce-dto-class';
|
|
4
|
+
import { CoerceGetControllerOptions } from './coerce-get-operation';
|
|
5
|
+
import { TransformOperation } from './coerce-operation';
|
|
6
|
+
export interface CoerceGetByIdControllerOptions extends CoerceGetControllerOptions {
|
|
7
|
+
idProperty?: OperationParameter | null;
|
|
8
8
|
}
|
|
9
|
+
export declare function BuildUpstreamGetByIdParametersImplementation(classDeclaration: ClassDeclaration, moduleSourceFile: SourceFile, dto: CoerceDtoClassOutput | null, options: Readonly<CoerceGetByIdControllerOptions>): TransformOperation<string | WriterFunction>;
|
|
10
|
+
export declare function BuiltGetByIdDtoDataMapperImplementation(classDeclaration: ClassDeclaration, moduleSourceFile: SourceFile, dto: CoerceDtoClassOutput | null, options: Readonly<CoerceGetByIdControllerOptions>): TransformOperation<string | WriterFunction>;
|
|
9
11
|
export declare function CoerceGetByIdOperation(options: CoerceGetByIdControllerOptions): import("@angular-devkit/schematics").Rule;
|
|
@@ -1,64 +1,93 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CoerceGetByIdOperation = void 0;
|
|
4
|
-
const
|
|
5
|
-
const ts_morph_1 = require("
|
|
6
|
-
const
|
|
7
|
-
|
|
3
|
+
exports.CoerceGetByIdOperation = exports.BuiltGetByIdDtoDataMapperImplementation = exports.BuildUpstreamGetByIdParametersImplementation = void 0;
|
|
4
|
+
const utilities_1 = require("@rxap/utilities");
|
|
5
|
+
const ts_morph_1 = require("ts-morph");
|
|
6
|
+
const coerce_get_operation_1 = require("./coerce-get-operation");
|
|
7
|
+
function BuildUpstreamGetByIdParametersImplementation(classDeclaration, moduleSourceFile, dto, options) {
|
|
8
|
+
return () => {
|
|
9
|
+
const { idProperty } = options;
|
|
10
|
+
return idProperty ? `{ parameters: { ${idProperty.name} } }` : '';
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
exports.BuildUpstreamGetByIdParametersImplementation = BuildUpstreamGetByIdParametersImplementation;
|
|
14
|
+
function BuiltGetByIdDtoDataMapperImplementation(classDeclaration, moduleSourceFile, dto, options) {
|
|
15
|
+
const { propertyList = [], upstream, isArray, idProperty, } = options;
|
|
16
|
+
return () => {
|
|
17
|
+
var _a;
|
|
18
|
+
if (upstream) {
|
|
19
|
+
const mapper = {};
|
|
20
|
+
if (idProperty) {
|
|
21
|
+
mapper[idProperty.name] = idProperty.name;
|
|
22
|
+
}
|
|
23
|
+
for (const property of propertyList.filter(p => !idProperty || p.name !== idProperty.name)) {
|
|
24
|
+
mapper[property.name] = `data.${(_a = property.source) !== null && _a !== void 0 ? _a : property.name}`;
|
|
25
|
+
}
|
|
26
|
+
if (isArray) {
|
|
27
|
+
return w => {
|
|
28
|
+
w.write('data.map(item => (');
|
|
29
|
+
ts_morph_1.Writers.object(mapper)(w);
|
|
30
|
+
w.write('))');
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
return ts_morph_1.Writers.object(mapper);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
if (isArray) {
|
|
39
|
+
return '[]';
|
|
40
|
+
}
|
|
41
|
+
if (idProperty) {
|
|
42
|
+
return `{ ${idProperty.name} }`;
|
|
43
|
+
}
|
|
44
|
+
return '{}';
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
exports.BuiltGetByIdDtoDataMapperImplementation = BuiltGetByIdDtoDataMapperImplementation;
|
|
8
49
|
function CoerceGetByIdOperation(options) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
50
|
+
var _a, _b;
|
|
51
|
+
const { controllerName, paramList = [], propertyList = [], idProperty = { name: 'uuid', type: 'string' }, operationName = 'getById', nestModule, buildUpstreamGetParametersImplementation = BuildUpstreamGetByIdParametersImplementation, builtDtoDataMapperImplementation = BuiltGetByIdDtoDataMapperImplementation, } = options;
|
|
52
|
+
if (idProperty) {
|
|
53
|
+
/**
|
|
54
|
+
* If the module is not specified. This controller has an own module. Else the
|
|
55
|
+
* module is originated by another controller.
|
|
56
|
+
*
|
|
57
|
+
* **Example**
|
|
58
|
+
* true:
|
|
59
|
+
* The controller ReportDetailsController should be extended with getById Operation.
|
|
60
|
+
* And the controller is used in the module ReportDetailsModule
|
|
61
|
+
*
|
|
62
|
+
* name = "report-details"
|
|
63
|
+
* module = undefined
|
|
64
|
+
*
|
|
65
|
+
* false:
|
|
66
|
+
* The controller ReportDetailsNotificationController should be extend with getById Operation.
|
|
67
|
+
* And the controller ise used in the module ReportDetailsModule
|
|
68
|
+
*
|
|
69
|
+
* name = "notification"
|
|
70
|
+
* module = "report-details"
|
|
71
|
+
*/
|
|
72
|
+
const isFirstBornSibling = !nestModule || nestModule === controllerName;
|
|
73
|
+
if (isFirstBornSibling) {
|
|
74
|
+
(0, utilities_1.CoerceArrayItems)(propertyList, [{
|
|
75
|
+
name: idProperty.name,
|
|
76
|
+
type: (_a = idProperty.type) !== null && _a !== void 0 ? _a : 'string',
|
|
77
|
+
isArray: idProperty.isArray,
|
|
78
|
+
}], (a, b) => a.name === b.name, true);
|
|
79
|
+
}
|
|
80
|
+
(0, utilities_1.CoerceArrayItems)(paramList, [{
|
|
81
|
+
name: idProperty.name,
|
|
82
|
+
type: idProperty.type,
|
|
83
|
+
fromParent: (_b = idProperty.fromParent) !== null && _b !== void 0 ? _b : !isFirstBornSibling,
|
|
84
|
+
}], (a, b) => a.name === b.name, true);
|
|
44
85
|
}
|
|
45
|
-
return (0,
|
|
46
|
-
controllerName,
|
|
86
|
+
return (0, coerce_get_operation_1.CoerceGetOperation)(Object.assign(Object.assign({}, options), { operationName,
|
|
47
87
|
paramList,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
name: controllerName,
|
|
52
|
-
propertyList,
|
|
53
|
-
});
|
|
54
|
-
(0, ts_morph_1.CoerceImports)(sourceFile, {
|
|
55
|
-
namedImports: [dtoClassName],
|
|
56
|
-
moduleSpecifier: dtoFilePath,
|
|
57
|
-
});
|
|
58
|
-
return {
|
|
59
|
-
returnType: dtoClassName + (isArray ? '[]' : ''),
|
|
60
|
-
};
|
|
61
|
-
} }));
|
|
88
|
+
propertyList,
|
|
89
|
+
buildUpstreamGetParametersImplementation,
|
|
90
|
+
builtDtoDataMapperImplementation }));
|
|
62
91
|
}
|
|
63
92
|
exports.CoerceGetByIdOperation = CoerceGetByIdOperation;
|
|
64
93
|
//# sourceMappingURL=coerce-get-by-id-operation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coerce-get-by-id-operation.js","sourceRoot":"","sources":["../../../../../../../packages/schematic/ts-morph/src/lib/nest/coerce-get-by-id-operation.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"coerce-get-by-id-operation.js","sourceRoot":"","sources":["../../../../../../../packages/schematic/ts-morph/src/lib/nest/coerce-get-by-id-operation.ts"],"names":[],"mappings":";;;AACA,+CAAmD;AACnD,uCAKkB;AAElB,iEAGgC;AAOhC,SAAgB,4CAA4C,CAC1D,gBAAkC,EAClC,gBAA4B,EAC5B,GAAgC,EAChC,OAAiD;IAEjD,OAAO,GAAG,EAAE;QACV,MAAM,EAAE,UAAU,EAAC,GAAG,OAAO,CAAC;QAC9B,OAAO,UAAU,CAAC,CAAC,CAAC,mBAAoB,UAAU,CAAC,IAAK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