@rxap/schematics-ts-morph 16.1.0-dev.8 → 16.1.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/CHANGELOG.md +124 -0
- package/README.md +1 -1
- package/package.json +22 -18
- package/src/index.d.ts +7 -1
- package/src/index.js +7 -1
- package/src/index.js.map +1 -1
- package/src/lib/angular/coerce-component.d.ts +3 -1
- package/src/lib/angular/coerce-component.js +13 -6
- package/src/lib/angular/coerce-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 -124
- 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 +20 -9
- 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-pipe.d.ts +10 -0
- package/src/lib/angular/coerce-pipe.js +63 -0
- package/src/lib/angular/coerce-pipe.js.map +1 -0
- package/src/lib/angular/coerce-proxy-remote-method-class.d.ts +2 -0
- package/src/lib/angular/coerce-proxy-remote-method-class.js +41 -19
- package/src/lib/angular/coerce-proxy-remote-method-class.js.map +1 -1
- package/src/lib/angular/coerce-tree-table-root-proxy-remote-method-class.d.ts +1 -0
- package/src/lib/angular/coerce-tree-table-root-proxy-remote-method-class.js +10 -3
- package/src/lib/angular/coerce-tree-table-root-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 +2 -0
- package/src/lib/nest/add-operation-to-controller.js +9 -2
- package/src/lib/nest/add-operation-to-controller.js.map +1 -1
- package/src/lib/nest/assert-nest-project.d.ts +1 -0
- package/src/lib/nest/assert-nest-project.js +7 -3
- package/src/lib/nest/assert-nest-project.js.map +1 -1
- package/src/lib/nest/coerce-autocomplete-options-operation.d.ts +12 -0
- package/src/lib/nest/coerce-autocomplete-options-operation.js +65 -0
- package/src/lib/nest/coerce-autocomplete-options-operation.js.map +1 -0
- package/src/lib/nest/coerce-autocomplete-table-select-value-resolve-operation.d.ts +7 -0
- package/src/lib/nest/coerce-autocomplete-table-select-value-resolve-operation.js +16 -0
- package/src/lib/nest/coerce-autocomplete-table-select-value-resolve-operation.js.map +1 -0
- package/src/lib/nest/coerce-dto-class.js +169 -125
- package/src/lib/nest/coerce-dto-class.js.map +1 -1
- package/src/lib/nest/coerce-form-submit-operation.js +4 -3
- package/src/lib/nest/coerce-form-submit-operation.js.map +1 -1
- package/src/lib/nest/coerce-get-by-id-operation.js +28 -10
- package/src/lib/nest/coerce-get-by-id-operation.js.map +1 -1
- package/src/lib/nest/coerce-get-page-operation.d.ts +4 -3
- package/src/lib/nest/coerce-get-page-operation.js +90 -33
- package/src/lib/nest/coerce-get-page-operation.js.map +1 -1
- package/src/lib/nest/coerce-get-root-operation.d.ts +4 -0
- package/src/lib/nest/coerce-get-root-operation.js +14 -4
- package/src/lib/nest/coerce-get-root-operation.js.map +1 -1
- package/src/lib/nest/coerce-operation.d.ts +6 -3
- package/src/lib/nest/coerce-operation.js +14 -5
- package/src/lib/nest/coerce-operation.js.map +1 -1
- package/src/lib/nest/coerce-options-operation.d.ts +6 -3
- package/src/lib/nest/coerce-options-operation.js +59 -5
- package/src/lib/nest/coerce-options-operation.js.map +1 -1
- package/src/lib/nest/coerce-row-dto-class.d.ts +2 -1
- package/src/lib/nest/coerce-row-dto-class.js +2 -2
- package/src/lib/nest/coerce-row-dto-class.js.map +1 -1
- package/src/lib/nest/coerce-table-select-operation.d.ts +3 -2
- package/src/lib/nest/coerce-table-select-operation.js +10 -15
- package/src/lib/nest/coerce-table-select-operation.js.map +1 -1
- package/src/lib/nest/coerce-table-select-value-resolve-operation.d.ts +5 -3
- package/src/lib/nest/coerce-table-select-value-resolve-operation.js +17 -15
- package/src/lib/nest/coerce-table-select-value-resolve-operation.js.map +1 -1
- package/src/lib/nest/coerce-tree-operation.js +2 -1
- package/src/lib/nest/coerce-tree-operation.js.map +1 -1
- package/src/lib/nest/dto-class-property.d.ts +2 -10
- package/src/lib/nest/dto-class-property.js +8 -4
- package/src/lib/nest/dto-class-property.js.map +1 -1
- package/src/lib/ts-morph/coerce-imports.js +1 -1
- package/src/lib/ts-morph/coerce-imports.js.map +1 -1
- package/src/lib/ts-morph/write-type.js +1 -1
- package/src/lib/ts-morph/write-type.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/types/form-definition-control.d.ts +0 -10
- package/src/lib/types/form-definition-control.js.map +0 -1
|
@@ -9,7 +9,6 @@ const ts_morph_2 = require("ts-morph");
|
|
|
9
9
|
const dto_class_property_1 = require("./dto-class-property");
|
|
10
10
|
require("colors");
|
|
11
11
|
function CoerceDtoClass(options) {
|
|
12
|
-
var _a;
|
|
13
12
|
const { project, propertyList = [], tsMorphTransform = utilities_1.noop, } = options;
|
|
14
13
|
let { name, } = options;
|
|
15
14
|
name = (0, schematics_utilities_1.dasherize)(name);
|
|
@@ -19,9 +18,35 @@ function CoerceDtoClass(options) {
|
|
|
19
18
|
const classDeclaration = (0, ts_morph_1.CoerceClass)(sourceFile, className);
|
|
20
19
|
classDeclaration.setIsExported(true);
|
|
21
20
|
for (const property of propertyList.map(dto_class_property_1.NormalizeDataClassProperty)) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
// create a clone of the property type to avoid modifying the original type
|
|
22
|
+
// if the property type is a self reference we need to replace the self reference with the class name
|
|
23
|
+
// if the property type is a deferred reference we need to replace the deferred reference with the class name
|
|
24
|
+
const propertyType = Object.assign({}, property.type);
|
|
25
|
+
let subTypeOutput;
|
|
26
|
+
switch (propertyType.name) {
|
|
27
|
+
case ts_morph_1.TypeNames.Self:
|
|
28
|
+
propertyType.name = className;
|
|
29
|
+
propertyType.isTypeOnly = false;
|
|
30
|
+
propertyType.moduleSpecifier = null;
|
|
31
|
+
propertyType.namedImport = null;
|
|
32
|
+
propertyType.namespaceImport = null;
|
|
33
|
+
propertyType.defaultImport = null;
|
|
34
|
+
property.isType = true;
|
|
35
|
+
break;
|
|
36
|
+
case ts_morph_1.TypeNames.Deferred:
|
|
37
|
+
subTypeOutput = CoerceDtoClass({
|
|
38
|
+
project,
|
|
39
|
+
name: [name, (0, schematics_utilities_1.dasherize)(property.name)].join('-'),
|
|
40
|
+
propertyList: property.memberList,
|
|
41
|
+
});
|
|
42
|
+
propertyType.name = subTypeOutput.className;
|
|
43
|
+
propertyType.moduleSpecifier = './' + (0, schematics_utilities_1.dasherize)(subTypeOutput.className.replace(/Dto$/, '')) + '.dto';
|
|
44
|
+
propertyType.isTypeOnly = false;
|
|
45
|
+
propertyType.namedImport = null;
|
|
46
|
+
propertyType.namespaceImport = null;
|
|
47
|
+
propertyType.defaultImport = null;
|
|
48
|
+
property.isType = true;
|
|
49
|
+
break;
|
|
25
50
|
}
|
|
26
51
|
let propertyName = (0, schematics_utilities_1.camelize)(property.name);
|
|
27
52
|
const prefixMatch = property.name.match(/^(_+)/);
|
|
@@ -30,155 +55,174 @@ function CoerceDtoClass(options) {
|
|
|
30
55
|
propertyName = prefixMatch[0] + propertyName;
|
|
31
56
|
}
|
|
32
57
|
const propertyDeclaration = (0, ts_morph_1.CoercePropertyDeclaration)(classDeclaration, propertyName).set({
|
|
33
|
-
type: (0, ts_morph_1.WriteType)(
|
|
58
|
+
type: (0, ts_morph_1.WriteType)({
|
|
59
|
+
isArray: property.isArray,
|
|
60
|
+
type: propertyType,
|
|
61
|
+
}, sourceFile),
|
|
34
62
|
hasQuestionToken: property.isOptional,
|
|
35
63
|
hasExclamationToken: !property.isOptional,
|
|
36
64
|
});
|
|
37
|
-
(
|
|
38
|
-
arguments: [],
|
|
39
|
-
});
|
|
40
|
-
(0, ts_morph_1.CoerceImports)(sourceFile, {
|
|
41
|
-
namedImports: ['Expose'],
|
|
42
|
-
moduleSpecifier: 'class-transformer',
|
|
43
|
-
});
|
|
65
|
+
addExposeDecorator(propertyDeclaration);
|
|
44
66
|
if (property.isArray) {
|
|
45
|
-
(
|
|
46
|
-
arguments: [],
|
|
47
|
-
});
|
|
48
|
-
(0, ts_morph_1.CoerceImports)(sourceFile, {
|
|
49
|
-
namedImports: ['IsArray'],
|
|
50
|
-
moduleSpecifier: 'class-validator',
|
|
51
|
-
});
|
|
67
|
+
addClassValidatorDecoratorForIsArray(propertyDeclaration);
|
|
52
68
|
}
|
|
53
69
|
if (property.isType) {
|
|
54
|
-
(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
70
|
+
addClassValidatorDecoratorForNestedDto(propertyDeclaration, propertyType, property.isArray);
|
|
71
|
+
}
|
|
72
|
+
if (property.isOptional) {
|
|
73
|
+
addIsOptionalDecorator(propertyDeclaration);
|
|
74
|
+
}
|
|
75
|
+
addClassValidatorDecoratorForType(propertyDeclaration, propertyType);
|
|
76
|
+
if (propertyType.name !== 'unknown') {
|
|
77
|
+
cleanupUnknownApiPropertyDecorator(propertyDeclaration);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
tsMorphTransform(project, sourceFile, classDeclaration);
|
|
81
|
+
return {
|
|
82
|
+
className,
|
|
83
|
+
filePath: '.' + (0, path_1.join)(sourceFile.getDirectoryPath(), sourceFile.getBaseNameWithoutExtension()),
|
|
84
|
+
sourceFile,
|
|
85
|
+
classDeclaration,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
exports.CoerceDtoClass = CoerceDtoClass;
|
|
89
|
+
function addIsOptionalDecorator(propertyDeclaration) {
|
|
90
|
+
const sourceFile = propertyDeclaration.getSourceFile();
|
|
91
|
+
(0, ts_morph_1.CoerceDecorator)(propertyDeclaration, 'IsOptional', {
|
|
92
|
+
arguments: [],
|
|
93
|
+
});
|
|
94
|
+
(0, ts_morph_1.CoerceImports)(sourceFile, {
|
|
95
|
+
namedImports: ['IsOptional'],
|
|
96
|
+
moduleSpecifier: 'class-validator',
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function addExposeDecorator(propertyDeclaration) {
|
|
100
|
+
const sourceFile = propertyDeclaration.getSourceFile();
|
|
101
|
+
(0, ts_morph_1.CoerceDecorator)(propertyDeclaration, 'Expose', {
|
|
102
|
+
arguments: [],
|
|
103
|
+
});
|
|
104
|
+
(0, ts_morph_1.CoerceImports)(sourceFile, {
|
|
105
|
+
namedImports: ['Expose'],
|
|
106
|
+
moduleSpecifier: 'class-transformer',
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
function addClassValidatorDecoratorForIsArray(propertyDeclaration) {
|
|
110
|
+
const sourceFile = propertyDeclaration.getSourceFile();
|
|
111
|
+
(0, ts_morph_1.CoerceDecorator)(propertyDeclaration, 'IsArray', {
|
|
112
|
+
arguments: [],
|
|
113
|
+
});
|
|
114
|
+
(0, ts_morph_1.CoerceImports)(sourceFile, {
|
|
115
|
+
namedImports: ['IsArray'],
|
|
116
|
+
moduleSpecifier: 'class-validator',
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function addClassValidatorDecoratorForNestedDto(propertyDeclaration, propertyType, isArray) {
|
|
120
|
+
const sourceFile = propertyDeclaration.getSourceFile();
|
|
121
|
+
(0, ts_morph_1.CoerceDecorator)(propertyDeclaration, 'Type', {
|
|
122
|
+
arguments: [
|
|
123
|
+
w => {
|
|
124
|
+
w.write('() => ');
|
|
125
|
+
(0, ts_morph_1.WriteType)({
|
|
126
|
+
type: propertyType,
|
|
127
|
+
isArray: false,
|
|
128
|
+
}, sourceFile)(w);
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
});
|
|
132
|
+
(0, ts_morph_1.CoerceImports)(sourceFile, {
|
|
133
|
+
namedImports: ['Type'],
|
|
134
|
+
moduleSpecifier: 'class-transformer',
|
|
135
|
+
});
|
|
136
|
+
(0, ts_morph_1.CoerceDecorator)(propertyDeclaration, 'IsInstance', {
|
|
137
|
+
arguments: [
|
|
138
|
+
(0, ts_morph_1.WriteType)({
|
|
139
|
+
type: propertyType,
|
|
140
|
+
isArray: false,
|
|
141
|
+
}, sourceFile),
|
|
142
|
+
w => {
|
|
143
|
+
if (isArray) {
|
|
144
|
+
ts_morph_2.Writers.object({ each: 'true' })(w);
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
});
|
|
149
|
+
(0, ts_morph_1.CoerceImports)(sourceFile, {
|
|
150
|
+
namedImports: ['IsInstance'],
|
|
151
|
+
moduleSpecifier: 'class-validator',
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
function addClassValidatorDecoratorForType(propertyDeclaration, propertyType) {
|
|
155
|
+
var _a;
|
|
156
|
+
const sourceFile = propertyDeclaration.getSourceFile();
|
|
157
|
+
switch (propertyType.name) {
|
|
158
|
+
case 'date':
|
|
159
|
+
(0, ts_morph_1.CoerceDecorator)(propertyDeclaration, 'IsDate', {
|
|
160
|
+
arguments: [],
|
|
81
161
|
});
|
|
82
162
|
(0, ts_morph_1.CoerceImports)(sourceFile, {
|
|
83
|
-
namedImports: ['
|
|
163
|
+
namedImports: ['IsDate'],
|
|
84
164
|
moduleSpecifier: 'class-validator',
|
|
85
165
|
});
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
(0, ts_morph_1.CoerceDecorator)(propertyDeclaration, '
|
|
166
|
+
break;
|
|
167
|
+
case 'number':
|
|
168
|
+
(0, ts_morph_1.CoerceDecorator)(propertyDeclaration, 'IsNumber', {
|
|
89
169
|
arguments: [],
|
|
90
170
|
});
|
|
91
171
|
(0, ts_morph_1.CoerceImports)(sourceFile, {
|
|
92
|
-
namedImports: ['
|
|
172
|
+
namedImports: ['IsNumber'],
|
|
93
173
|
moduleSpecifier: 'class-validator',
|
|
94
174
|
});
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
(0, ts_morph_1.CoerceDecorator)(propertyDeclaration, 'IsDate', {
|
|
99
|
-
arguments: [],
|
|
100
|
-
});
|
|
101
|
-
(0, ts_morph_1.CoerceImports)(sourceFile, {
|
|
102
|
-
namedImports: ['IsDate'],
|
|
103
|
-
moduleSpecifier: 'class-validator',
|
|
104
|
-
});
|
|
105
|
-
break;
|
|
106
|
-
case 'number':
|
|
107
|
-
(0, ts_morph_1.CoerceDecorator)(propertyDeclaration, 'IsNumber', {
|
|
108
|
-
arguments: [],
|
|
109
|
-
});
|
|
175
|
+
break;
|
|
176
|
+
case 'string':
|
|
177
|
+
if ((_a = propertyDeclaration.getName()) === null || _a === void 0 ? void 0 : _a.match(/^uuid|Uuid$/)) {
|
|
110
178
|
(0, ts_morph_1.CoerceImports)(sourceFile, {
|
|
111
|
-
namedImports: ['
|
|
179
|
+
namedImports: ['IsUUID'],
|
|
112
180
|
moduleSpecifier: 'class-validator',
|
|
113
181
|
});
|
|
114
|
-
break;
|
|
115
|
-
case 'string':
|
|
116
|
-
if (property.name === 'uuid') {
|
|
117
|
-
(0, ts_morph_1.CoerceImports)(sourceFile, {
|
|
118
|
-
namedImports: ['IsUUID'],
|
|
119
|
-
moduleSpecifier: 'class-validator',
|
|
120
|
-
});
|
|
121
|
-
(0, ts_morph_1.CoerceDecorator)(propertyDeclaration, 'IsUUID', {
|
|
122
|
-
arguments: [],
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
(0, ts_morph_1.CoerceImports)(sourceFile, {
|
|
127
|
-
namedImports: ['IsString'],
|
|
128
|
-
moduleSpecifier: 'class-validator',
|
|
129
|
-
});
|
|
130
|
-
(0, ts_morph_1.CoerceDecorator)(propertyDeclaration, 'IsString', {
|
|
131
|
-
arguments: [],
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
break;
|
|
135
|
-
case 'uuid':
|
|
136
182
|
(0, ts_morph_1.CoerceDecorator)(propertyDeclaration, 'IsUUID', {
|
|
137
183
|
arguments: [],
|
|
138
184
|
});
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
139
187
|
(0, ts_morph_1.CoerceImports)(sourceFile, {
|
|
140
|
-
namedImports: ['
|
|
188
|
+
namedImports: ['IsString'],
|
|
141
189
|
moduleSpecifier: 'class-validator',
|
|
142
190
|
});
|
|
143
|
-
|
|
144
|
-
case 'boolean':
|
|
145
|
-
(0, ts_morph_1.CoerceDecorator)(propertyDeclaration, 'IsBoolean', {
|
|
191
|
+
(0, ts_morph_1.CoerceDecorator)(propertyDeclaration, 'IsString', {
|
|
146
192
|
arguments: [],
|
|
147
193
|
});
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
194
|
+
}
|
|
195
|
+
break;
|
|
196
|
+
case 'boolean':
|
|
197
|
+
(0, ts_morph_1.CoerceDecorator)(propertyDeclaration, 'IsBoolean', {
|
|
198
|
+
arguments: [],
|
|
199
|
+
});
|
|
200
|
+
(0, ts_morph_1.CoerceImports)(sourceFile, {
|
|
201
|
+
namedImports: ['IsBoolean'],
|
|
202
|
+
moduleSpecifier: 'class-validator',
|
|
203
|
+
});
|
|
204
|
+
break;
|
|
205
|
+
case 'unknown':
|
|
206
|
+
(0, ts_morph_1.CoerceDecorator)(propertyDeclaration, 'ApiProperty', {
|
|
207
|
+
arguments: [ts_morph_2.Writers.object({ type: w => w.quote('unknown') })],
|
|
208
|
+
});
|
|
209
|
+
(0, ts_morph_1.CoerceImports)(sourceFile, {
|
|
210
|
+
namedImports: ['ApiProperty'],
|
|
211
|
+
moduleSpecifier: '@nestjs/swagger',
|
|
212
|
+
});
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
function cleanupUnknownApiPropertyDecorator(propertyDeclaration) {
|
|
217
|
+
var _a;
|
|
218
|
+
const apiProperty = propertyDeclaration.getDecorators().find(d => d.getName() === 'ApiProperty');
|
|
219
|
+
if (apiProperty) {
|
|
220
|
+
const args = apiProperty.getArguments()[0];
|
|
221
|
+
if (args instanceof ts_morph_2.ObjectLiteralExpression) {
|
|
222
|
+
if ((_a = args.getProperty('type')) === null || _a === void 0 ? void 0 : _a.getText().includes('unknown')) {
|
|
223
|
+
apiProperty.remove();
|
|
172
224
|
}
|
|
173
225
|
}
|
|
174
226
|
}
|
|
175
|
-
tsMorphTransform(project, sourceFile, classDeclaration);
|
|
176
|
-
return {
|
|
177
|
-
className,
|
|
178
|
-
filePath: '.' + (0, path_1.join)(sourceFile.getDirectoryPath(), sourceFile.getBaseNameWithoutExtension()),
|
|
179
|
-
sourceFile,
|
|
180
|
-
classDeclaration,
|
|
181
|
-
};
|
|
182
227
|
}
|
|
183
|
-
exports.CoerceDtoClass = CoerceDtoClass;
|
|
184
228
|
//# sourceMappingURL=coerce-dto-class.js.map
|
|
@@ -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,
|
|
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,6CASwB;AACxB,+CAAuC;AACvC,+BAA4B;AAC5B,uCAOkB;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,GAA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BAC7B,eAAe,EAAE,iBAAiB;aACnC,CAAC,CAAC;YACH,MAAM;QACR,KAAK,SAAS;YACZ,IAAA,0BAAe,EACb,mBAAmB,EACnB,aAAa,EACb;gBACE,SAAS,EAAE,CAAE,kBAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC,CAAE;aACjE,CACF,CAAC;YACF,IAAA,wBAAa,EAAC,UAAU,EAAE;gBACxB,YAAY,EAAE,CAAE,aAAa,CAAE;gBAC/B,eAAe,EAAE,iBAAiB;aACnC,CAAC,CAAC;YACH,MAAM;KACT;AAEH,CAAC;AAED,SAAS,kCAAkC,CAAC,mBAAwC;;IAClF,MAAM,WAAW,GAAG,mBAAmB,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,KAAK,aAAa,CAAC,CAAC;IACjG,IAAI,WAAW,EAAE;QACf,MAAM,IAAI,GAAG,WAAW,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC;QAC3C,IAAI,IAAI,YAAY,kCAAuB,EAAE;YAC3C,IAAI,MAAA,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,0CAAE,OAAO,GAAG,QAAQ,CAAC,SAAS,CAAC,EAAE;gBAC3D,WAAW,CAAC,MAAM,EAAE,CAAC;aACtB;SACF;KACF;AACH,CAAC"}
|
|
@@ -6,11 +6,12 @@ const coerce_get_by_id_operation_1 = require("./coerce-get-by-id-operation");
|
|
|
6
6
|
function CoerceFormSubmitOperation(options) {
|
|
7
7
|
const { tsMorphTransform = utilities_1.noop, bodyDtoName, isReturnVoid = true,
|
|
8
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;
|
|
9
|
+
idProperty = null, operationName = idProperty ? 'submitById' : 'submit', dtoClassNameSuffix = '-submit', } = options;
|
|
10
10
|
return (0, coerce_get_by_id_operation_1.CoerceGetByIdOperation)(Object.assign(Object.assign({}, options), { operationName,
|
|
11
11
|
isReturnVoid,
|
|
12
|
-
idProperty,
|
|
13
|
-
|
|
12
|
+
idProperty,
|
|
13
|
+
dtoClassNameSuffix, buildOperationDtoClassName: (controllerName, { dtoClassName, dtoClassNameSuffix = '-submit' }) => {
|
|
14
|
+
return dtoClassName !== null && dtoClassName !== void 0 ? dtoClassName : (0, utilities_1.CoerceSuffix)(bodyDtoName !== null && bodyDtoName !== void 0 ? bodyDtoName : controllerName, dtoClassNameSuffix);
|
|
14
15
|
}, tsMorphTransform: (project, sourceFile, classDeclaration, controllerName, moduleSourceFile, dto) => {
|
|
15
16
|
if (!dto) {
|
|
16
17
|
throw new Error('The dto must be created for an submit operation');
|
|
@@ -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,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,
|
|
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,EACpD,kBAAkB,GAAG,SAAS,GAC/B,GAAG,OAAO,CAAC;IAEZ,OAAO,IAAA,mDAAsB,kCACxB,OAAO,KACV,aAAa;QACb,YAAY;QACZ,UAAU;QACV,kBAAkB,EAClB,0BAA0B,EAAE,CAAC,cAAc,EAAE,EAAE,YAAY,EAAE,kBAAkB,GAAG,SAAS,EAAE,EAAE,EAAE;YAC/F,OAAO,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,IAAA,wBAAY,EAAC,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,cAAc,EAAE,kBAAkB,CAAC,CAAC;QACzF,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"}
|
|
@@ -4,6 +4,7 @@ exports.CoerceGetByIdOperation = exports.BuiltGetByIdDtoDataMapperImplementation
|
|
|
4
4
|
const utilities_1 = require("@rxap/utilities");
|
|
5
5
|
const ts_morph_1 = require("ts-morph");
|
|
6
6
|
const coerce_get_operation_1 = require("./coerce-get-operation");
|
|
7
|
+
const dto_class_property_1 = require("./dto-class-property");
|
|
7
8
|
function BuildUpstreamGetByIdParametersImplementation(classDeclaration, moduleSourceFile, dto, options) {
|
|
8
9
|
return () => {
|
|
9
10
|
const { idProperty } = options;
|
|
@@ -11,27 +12,44 @@ function BuildUpstreamGetByIdParametersImplementation(classDeclaration, moduleSo
|
|
|
11
12
|
};
|
|
12
13
|
}
|
|
13
14
|
exports.BuildUpstreamGetByIdParametersImplementation = BuildUpstreamGetByIdParametersImplementation;
|
|
15
|
+
function UpstreamMapper(sourceProperty, propertyList, idProperty) {
|
|
16
|
+
var _a;
|
|
17
|
+
const mapper = {};
|
|
18
|
+
if (idProperty) {
|
|
19
|
+
mapper[idProperty.name] = idProperty.name;
|
|
20
|
+
}
|
|
21
|
+
for (const property of propertyList.filter(p => !idProperty || p.name !== idProperty.name).map(p => (0, dto_class_property_1.NormalizeDataClassProperty)(p))) {
|
|
22
|
+
mapper[property.name] = `${sourceProperty}.${(_a = property.source) !== null && _a !== void 0 ? _a : property.name}`;
|
|
23
|
+
if (property.isType) {
|
|
24
|
+
// property is a complex object
|
|
25
|
+
if (property.isArray) {
|
|
26
|
+
mapper[property.name] = w => {
|
|
27
|
+
var _a;
|
|
28
|
+
w.write(`${sourceProperty}.${(_a = property.source) !== null && _a !== void 0 ? _a : property.name}.map(item => (`);
|
|
29
|
+
ts_morph_1.Writers.object(UpstreamMapper('item', property.memberList))(w);
|
|
30
|
+
w.write('))');
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
mapper[property.name] = ts_morph_1.Writers.object(UpstreamMapper(mapper[property.name], property.memberList));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return mapper;
|
|
39
|
+
}
|
|
14
40
|
function BuiltGetByIdDtoDataMapperImplementation(classDeclaration, moduleSourceFile, dto, options) {
|
|
15
41
|
const { propertyList = [], upstream, isArray, idProperty, } = options;
|
|
16
42
|
return () => {
|
|
17
|
-
var _a;
|
|
18
43
|
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
44
|
if (isArray) {
|
|
27
45
|
return w => {
|
|
28
46
|
w.write('data.map(item => (');
|
|
29
|
-
ts_morph_1.Writers.object(
|
|
47
|
+
ts_morph_1.Writers.object(UpstreamMapper('data', propertyList, idProperty))(w);
|
|
30
48
|
w.write('))');
|
|
31
49
|
};
|
|
32
50
|
}
|
|
33
51
|
else {
|
|
34
|
-
return ts_morph_1.Writers.object(
|
|
52
|
+
return ts_morph_1.Writers.object(UpstreamMapper('data', propertyList, idProperty));
|
|
35
53
|
}
|
|
36
54
|
}
|
|
37
55
|
else {
|
|
@@ -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":";;;AACA,+CAAmD;AACnD,uCAKkB;AAElB,iEAGgC;
|
|
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;AAEhC,6DAG8B;AAM9B,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,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACtE,CAAC,CAAC;AACJ,CAAC;AAVD,oGAUC;AAED,SAAS,cAAc,CAAC,cAAsB,EAAE,YAAgC,EAAE,UAAsC;;IACtH,MAAM,MAAM,GAA4C,EAAE,CAAC;IAC3D,IAAI,UAAU,EAAE;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BAC9B,IAAI,EAAE,UAAU,CAAC,IAAI;oBACrB,IAAI,EAAE,MAAA,UAAU,CAAC,IAAI,mCAAI,QAAQ;oBACjC,OAAO,EAAE,UAAU,CAAC,OAAO;iBAC5B,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;SACxC;QAED,IAAA,4BAAgB,EAAC,SAAS,EAAC,CAAC;gBAC1B,IAAI,EAAE,UAAU,CAAC,IAAI;gBACrB,IAAI,EAAE,UAAU,CAAC,IAAI;gBACrB,UAAU,EAAE,MAAA,UAAU,CAAC,UAAU,mCAAI,CAAC,kBAAkB;aACzD,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;KAExC;IAED,OAAO,IAAA,yCAAkB,kCACpB,OAAO,KACV,aAAa;QACb,SAAS;QACT,YAAY;QACZ,wCAAwC;QACxC,gCAAgC,IAChC,CAAC;AAEL,CAAC;AA3DD,wDA2DC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NormalizedUpstreamOptions, TypeImport } from '@rxap/ts-morph';
|
|
1
|
+
import { NormalizedUpstreamOptions, OperationParameter, TypeImport } from '@rxap/ts-morph';
|
|
2
2
|
import { ClassDeclaration, Project, SourceFile, WriterFunction } from 'ts-morph';
|
|
3
3
|
import { OperationOptions } from './add-operation-to-controller';
|
|
4
4
|
import { CoerceDtoClassOutput } from './coerce-dto-class';
|
|
@@ -10,13 +10,14 @@ export interface CoerceGetPageOperationOptions extends Omit<CoerceOperationOptio
|
|
|
10
10
|
* the name of the property used as row id value. defaults to the value 'uuid'. If null the __rowId property will be
|
|
11
11
|
* set to the absolute row index absolute row index = page * pageSize + rowIndex
|
|
12
12
|
*/
|
|
13
|
-
rowIdProperty?: string | null;
|
|
14
13
|
operationName?: string;
|
|
15
14
|
coerceToRowDtoMethod?: (sourceFile: SourceFile, classDeclaration: ClassDeclaration, rowClassName: string, options: CoerceGetPageOperationOptions) => void;
|
|
16
15
|
coerceToPageDtoMethod?: (sourceFile: SourceFile, classDeclaration: ClassDeclaration, pageClassName: string, rowClassName: string, options: CoerceGetPageOperationOptions) => void;
|
|
17
16
|
coerceGetPageDataMethod?: (sourceFile: SourceFile, classDeclaration: ClassDeclaration, moduleSourceFile: SourceFile, options: CoerceGetPageOperationOptions) => void;
|
|
18
17
|
coerceOperationDtoClass?: (classDeclaration: ClassDeclaration, controllerName: string, moduleSourceFile: SourceFile, options: Readonly<CoerceGetPageOperationOptions>) => CoerceDtoClassOutput | null;
|
|
19
18
|
upstream?: NormalizedUpstreamOptions | null;
|
|
19
|
+
idProperty?: OperationParameter;
|
|
20
|
+
rowId: DtoClassProperty | null;
|
|
20
21
|
}
|
|
21
22
|
export declare function GetPageOperationColumnToCodeText(property: DtoClassProperty): string;
|
|
22
23
|
export declare function CoerceToRowDtoMethod(sourceFile: SourceFile, classDeclaration: ClassDeclaration, rowClassName: string, options: CoerceGetPageOperationOptions): void;
|
|
@@ -24,7 +25,7 @@ export declare function CoerceToPageDtoMethod(sourceFile: SourceFile, classDecla
|
|
|
24
25
|
export declare function CoerceGetPageDataMethod(sourceFile: SourceFile, classDeclaration: ClassDeclaration, moduleSourceFile: SourceFile, options: CoerceGetPageOperationOptions): void;
|
|
25
26
|
export declare function GetResponseTypeFromUpstream(upstream: NormalizedUpstreamOptions): TypeImport;
|
|
26
27
|
export declare function GetRawRowDataType(options: Readonly<CoerceGetPageOperationOptions>): TypeImport;
|
|
27
|
-
export declare function
|
|
28
|
+
export declare function BuildGetPageGetDataImplementation(classDeclaration: ClassDeclaration, moduleSourceFile: SourceFile, dto: CoerceDtoClassOutput | null, options: Readonly<CoerceOperationOptions>): TransformOperation;
|
|
28
29
|
export declare function CoerceGetPageOperationDtoClass(classDeclaration: ClassDeclaration, controllerName: string, moduleSourceFile: SourceFile, options: Readonly<CoerceGetPageOperationOptions>): CoerceDtoClassOutput | null;
|
|
29
30
|
export declare function BuiltGetPageDtoDataMapperImplementation(classDeclaration: ClassDeclaration, moduleSourceFile: SourceFile, dto: CoerceDtoClassOutput | null, options: Readonly<CoerceOperationOptions>): TransformOperation<string | WriterFunction>;
|
|
30
31
|
export declare function CoerceGetPageOperation(options: Readonly<CoerceGetPageOperationOptions>): import("@angular-devkit/schematics").Rule;
|