@rxap/schematics-ts-morph 18.0.3-dev.0 → 18.0.3-dev.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/CHANGELOG.md +4 -0
- package/package.json +8 -8
- package/src/index.d.ts +0 -3
- package/src/index.js +0 -3
- package/src/index.js.map +1 -1
- package/src/lib/nest/coerce-autocomplete-options-operation.d.ts +2 -2
- package/src/lib/nest/coerce-autocomplete-options-operation.js.map +1 -1
- package/src/lib/nest/coerce-form-submit-operation.js +1 -1
- package/src/lib/nest/coerce-form-submit-operation.js.map +1 -1
- package/src/lib/nest/coerce-get-by-id-operation.d.ts +2 -2
- package/src/lib/nest/coerce-get-by-id-operation.js +7 -7
- package/src/lib/nest/coerce-get-by-id-operation.js.map +1 -1
- package/src/lib/nest/coerce-get-operation.d.ts +1 -1
- package/src/lib/nest/coerce-get-operation.js.map +1 -1
- package/src/lib/nest/coerce-get-page-operation.d.ts +4 -5
- package/src/lib/nest/coerce-get-page-operation.js +4 -3
- package/src/lib/nest/coerce-get-page-operation.js.map +1 -1
- package/src/lib/nest/coerce-get-root-operation.d.ts +2 -3
- package/src/lib/nest/coerce-get-root-operation.js +1 -1
- package/src/lib/nest/coerce-get-root-operation.js.map +1 -1
- package/src/lib/nest/coerce-operation.d.ts +3 -45
- package/src/lib/nest/coerce-operation.js +3 -201
- package/src/lib/nest/coerce-operation.js.map +1 -1
- package/src/lib/nest/coerce-options-operation.d.ts +3 -3
- package/src/lib/nest/coerce-options-operation.js.map +1 -1
- package/src/lib/nest/coerce-page-dto-class.d.ts +2 -2
- package/src/lib/nest/coerce-page-dto-class.js +2 -2
- package/src/lib/nest/coerce-page-dto-class.js.map +1 -1
- package/src/lib/nest/coerce-row-dto-class.d.ts +2 -2
- 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-value-resolve-operation.d.ts +2 -2
- package/src/lib/nest/table-query-list.d.ts +1 -1
- package/src/lib/nest/add-operation-to-controller.d.ts +0 -41
- package/src/lib/nest/add-operation-to-controller.js +0 -238
- package/src/lib/nest/add-operation-to-controller.js.map +0 -1
- package/src/lib/nest/coerce-dto-class.d.ts +0 -16
- package/src/lib/nest/coerce-dto-class.js +0 -228
- package/src/lib/nest/coerce-dto-class.js.map +0 -1
- package/src/lib/nest/dto-class-property.d.ts +0 -11
- package/src/lib/nest/dto-class-property.js +0 -30
- package/src/lib/nest/dto-class-property.js.map +0 -1
|
@@ -1,181 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CoerceOperation =
|
|
3
|
+
exports.CoerceOperation = void 0;
|
|
4
4
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
-
const schematics_utilities_1 = require("@rxap/schematics-utilities");
|
|
6
5
|
const ts_morph_1 = require("@rxap/ts-morph");
|
|
7
6
|
const utilities_1 = require("@rxap/utilities");
|
|
8
7
|
const path_1 = require("path");
|
|
9
|
-
const ts_morph_2 = require("ts-morph");
|
|
10
8
|
const ts_morph_transform_1 = require("../ts-morph-transform");
|
|
11
|
-
const add_operation_to_controller_1 = require("./add-operation-to-controller");
|
|
12
9
|
const build_nest_controller_name_1 = require("./build-nest-controller-name");
|
|
13
|
-
const coerce_dto_class_1 = require("./coerce-dto-class");
|
|
14
10
|
const coerce_nest_controller_1 = require("./coerce-nest-controller");
|
|
15
|
-
function CoerceUpstreamBasicOperationImplementation(classDeclaration, moduleSourceFile, upstream) {
|
|
16
|
-
if ((0, ts_morph_1.IsNormalizedOpenApiUpstreamOptions)(upstream)) {
|
|
17
|
-
const sourceFile = classDeclaration.getSourceFile();
|
|
18
|
-
const commandClassName = (0, ts_morph_1.OperationIdToCommandClassName)(upstream.operationId);
|
|
19
|
-
(0, ts_morph_1.CoerceImports)(sourceFile, {
|
|
20
|
-
namedImports: [commandClassName],
|
|
21
|
-
moduleSpecifier: (0, ts_morph_1.OperationIdToCommandClassImportPath)(upstream.operationId, upstream.scope, upstream.isService),
|
|
22
|
-
});
|
|
23
|
-
(0, ts_morph_1.CoerceNestModuleImport)(moduleSourceFile, {
|
|
24
|
-
moduleName: 'HttpModule',
|
|
25
|
-
moduleSpecifier: '@nestjs/axios',
|
|
26
|
-
});
|
|
27
|
-
(0, ts_morph_1.CoerceNestModuleProvider)(moduleSourceFile, {
|
|
28
|
-
providerObject: 'Logger',
|
|
29
|
-
moduleSpecifier: '@nestjs/common',
|
|
30
|
-
});
|
|
31
|
-
(0, ts_morph_1.CoerceNestModuleProvider)(moduleSourceFile, {
|
|
32
|
-
providerObject: commandClassName,
|
|
33
|
-
moduleSpecifier: (0, ts_morph_1.OperationIdToCommandClassImportPath)(upstream.operationId, upstream.scope, upstream.isService),
|
|
34
|
-
});
|
|
35
|
-
const commandMemberName = (0, utilities_1.camelize)(commandClassName);
|
|
36
|
-
(0, ts_morph_1.CoerceImports)(sourceFile, {
|
|
37
|
-
namedImports: ['Inject'],
|
|
38
|
-
moduleSpecifier: '@nestjs/common',
|
|
39
|
-
});
|
|
40
|
-
(0, ts_morph_1.CoercePropertyDeclaration)(classDeclaration, commandMemberName, {
|
|
41
|
-
type: commandClassName,
|
|
42
|
-
hasExclamationToken: true,
|
|
43
|
-
scope: ts_morph_2.Scope.Private,
|
|
44
|
-
isReadonly: true,
|
|
45
|
-
decorators: [
|
|
46
|
-
{
|
|
47
|
-
name: 'Inject',
|
|
48
|
-
arguments: [commandClassName],
|
|
49
|
-
},
|
|
50
|
-
],
|
|
51
|
-
});
|
|
52
|
-
return {
|
|
53
|
-
className: commandClassName,
|
|
54
|
-
memberName: commandMemberName,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
throw new Error(`Upstream kind '${upstream.kind}' not supported`);
|
|
58
|
-
}
|
|
59
|
-
exports.CoerceUpstreamBasicOperationImplementation = CoerceUpstreamBasicOperationImplementation;
|
|
60
|
-
function BuildOperationDtoClassName(controllerName, options) {
|
|
61
|
-
const { dtoClassNameSuffix, dtoClassName, } = options;
|
|
62
|
-
return dtoClassName !== null && dtoClassName !== void 0 ? dtoClassName : (dtoClassNameSuffix ? (0, utilities_1.CoerceSuffix)(controllerName, (0, utilities_1.CoercePrefix)(dtoClassNameSuffix, '-')) : controllerName);
|
|
63
|
-
}
|
|
64
|
-
exports.BuildOperationDtoClassName = BuildOperationDtoClassName;
|
|
65
|
-
function CoerceOperationDtoClass(classDeclaration, controllerName, moduleSourceFile, options) {
|
|
66
|
-
const sourceFile = classDeclaration.getSourceFile();
|
|
67
|
-
const project = sourceFile.getProject();
|
|
68
|
-
const { dtoClassNameSuffix, dtoClassName, propertyList = [], isReturnVoid, buildOperationDtoClassName = BuildOperationDtoClassName } = options;
|
|
69
|
-
let dto = null;
|
|
70
|
-
if (propertyList.length > 0 || isReturnVoid === false || dtoClassNameSuffix || dtoClassName) {
|
|
71
|
-
dto = (0, coerce_dto_class_1.CoerceDtoClass)({
|
|
72
|
-
project,
|
|
73
|
-
name: buildOperationDtoClassName(controllerName, options),
|
|
74
|
-
propertyList,
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
return dto;
|
|
78
|
-
}
|
|
79
|
-
exports.CoerceOperationDtoClass = CoerceOperationDtoClass;
|
|
80
|
-
function BuiltDtoDataMapperImplementation(classDeclaration, moduleSourceFile, dto, options) {
|
|
81
|
-
const { propertyList = [], upstream, isArray, } = options;
|
|
82
|
-
return () => {
|
|
83
|
-
var _a;
|
|
84
|
-
if (upstream) {
|
|
85
|
-
const mapper = {};
|
|
86
|
-
for (const property of propertyList) {
|
|
87
|
-
mapper[property.name] = `data.${(_a = property.source) !== null && _a !== void 0 ? _a : property.name}`;
|
|
88
|
-
}
|
|
89
|
-
if (isArray) {
|
|
90
|
-
return w => {
|
|
91
|
-
w.write('data.map(item => (');
|
|
92
|
-
ts_morph_2.Writers.object(mapper)(w);
|
|
93
|
-
w.write('))');
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
return ts_morph_2.Writers.object(mapper);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
return isArray ? '[]' : '{}';
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
exports.BuiltDtoDataMapperImplementation = BuiltDtoDataMapperImplementation;
|
|
106
|
-
function BuildDtoReturnImplementation(classDeclaration, moduleSourceFile, dto, options) {
|
|
107
|
-
return (operationOptions) => {
|
|
108
|
-
var _a;
|
|
109
|
-
const { isArray, isReturnVoid = !dto, builtDtoDataMapperImplementation = BuiltDtoDataMapperImplementation, } = options;
|
|
110
|
-
if (!isReturnVoid && dto) {
|
|
111
|
-
const sourceFile = classDeclaration.getSourceFile();
|
|
112
|
-
(0, ts_morph_1.CoerceImports)(sourceFile, {
|
|
113
|
-
namedImports: [isArray ? 'ToDtoInstanceList' : 'ToDtoInstance'],
|
|
114
|
-
moduleSpecifier: '@rxap/nest-dto',
|
|
115
|
-
});
|
|
116
|
-
const mapper = builtDtoDataMapperImplementation(classDeclaration, moduleSourceFile, dto, options)(operationOptions);
|
|
117
|
-
operationOptions.returnType = dto.className + (isArray ? '[]' : '');
|
|
118
|
-
(_a = operationOptions.statements) !== null && _a !== void 0 ? _a : (operationOptions.statements = []);
|
|
119
|
-
operationOptions.statements = (0, utilities_1.coerceArray)(operationOptions.statements);
|
|
120
|
-
if (isArray) {
|
|
121
|
-
operationOptions.statements.push('return ToDtoInstanceList(');
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
operationOptions.statements.push('return ToDtoInstance(');
|
|
125
|
-
}
|
|
126
|
-
operationOptions.statements.push(dto.className + ',', w => {
|
|
127
|
-
if (typeof mapper === 'string') {
|
|
128
|
-
w.write(mapper);
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
mapper(w);
|
|
132
|
-
}
|
|
133
|
-
w.write(',');
|
|
134
|
-
}, ');');
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
exports.BuildDtoReturnImplementation = BuildDtoReturnImplementation;
|
|
139
|
-
function BuildUpstreamGetDataImplementation(classDeclaration, moduleSourceFile, dto, options) {
|
|
140
|
-
return (operationOptions) => {
|
|
141
|
-
var _a;
|
|
142
|
-
const { buildUpstreamGetParametersImplementation = (() => () => ''), upstream, } = options;
|
|
143
|
-
if (upstream) {
|
|
144
|
-
if ((0, ts_morph_1.IsNormalizedOpenApiUpstreamOptions)(upstream)) {
|
|
145
|
-
const { memberName: commandMemberName } = CoerceUpstreamBasicOperationImplementation(classDeclaration, moduleSourceFile, upstream);
|
|
146
|
-
const commandParameter = buildUpstreamGetParametersImplementation(classDeclaration, moduleSourceFile, dto, options)(operationOptions);
|
|
147
|
-
(_a = operationOptions.statements) !== null && _a !== void 0 ? _a : (operationOptions.statements = []);
|
|
148
|
-
operationOptions.statements = (0, utilities_1.coerceArray)(operationOptions.statements);
|
|
149
|
-
operationOptions.statements.push(w => {
|
|
150
|
-
w.write(`const data = await this.${commandMemberName}.execute(`);
|
|
151
|
-
if (typeof commandParameter === 'function') {
|
|
152
|
-
commandParameter(w);
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
w.write(commandParameter);
|
|
156
|
-
}
|
|
157
|
-
w.write(');');
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
exports.BuildUpstreamGetDataImplementation = BuildUpstreamGetDataImplementation;
|
|
164
|
-
function CoerceUpstreamDefaultOperationImplementation(classDeclaration, moduleSourceFile, dto, options) {
|
|
165
|
-
return (operationOptions) => {
|
|
166
|
-
var _a;
|
|
167
|
-
const { upstream, buildDtoReturnImplementation = BuildDtoReturnImplementation, buildUpstreamGetDataImplementation = BuildUpstreamGetDataImplementation, buildGetDataImplementation = utilities_1.noop, } = options;
|
|
168
|
-
(_a = buildGetDataImplementation(classDeclaration, moduleSourceFile, dto, options)) === null || _a === void 0 ? void 0 : _a(operationOptions);
|
|
169
|
-
if (upstream) {
|
|
170
|
-
operationOptions.isAsync = true;
|
|
171
|
-
buildUpstreamGetDataImplementation(classDeclaration, moduleSourceFile, dto, options)(operationOptions);
|
|
172
|
-
}
|
|
173
|
-
buildDtoReturnImplementation(classDeclaration, moduleSourceFile, dto, options)(operationOptions);
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
exports.CoerceUpstreamDefaultOperationImplementation = CoerceUpstreamDefaultOperationImplementation;
|
|
177
11
|
function CoerceOperation(options) {
|
|
178
|
-
const { controllerName, project, paramList = [], feature, shared,
|
|
12
|
+
const { controllerName, project, paramList = [], feature, shared, operationName, skipCoerce, } = options;
|
|
179
13
|
let { nestModule, directory, path } = options;
|
|
180
14
|
/**
|
|
181
15
|
* If the module is not specified. This controller has an own module. Else the
|
|
@@ -236,39 +70,7 @@ function CoerceOperation(options) {
|
|
|
236
70
|
// controller and module source file
|
|
237
71
|
filter: false,
|
|
238
72
|
}, (project, [controllerSourceFile, moduleSourceFile]) => {
|
|
239
|
-
|
|
240
|
-
const classDeclaration = controllerSourceFile.getClassOrThrow(`${(0, schematics_utilities_1.classify)(nestController)}Controller`);
|
|
241
|
-
const dto = coerceOperationDtoClass(classDeclaration, nestController, moduleSourceFile, options);
|
|
242
|
-
if (dto) {
|
|
243
|
-
(0, ts_morph_1.CoerceImports)(controllerSourceFile, {
|
|
244
|
-
namedImports: [dto.className],
|
|
245
|
-
moduleSpecifier: dto.filePath,
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
let operationOptions = {};
|
|
249
|
-
coerceUpstreamOperationImplementation(classDeclaration, moduleSourceFile, dto, options)(operationOptions);
|
|
250
|
-
operationOptions = Object.assign(Object.assign({}, operationOptions), (_a = tsMorphTransform(project, controllerSourceFile, classDeclaration, nestController, moduleSourceFile, dto)) !== null && _a !== void 0 ? _a : {});
|
|
251
|
-
if (controllerPath) {
|
|
252
|
-
console.log(`Overwrite controller path with '${controllerPath}' for operation '${operationName}' in controller '${nestController}' in module '${nestModule}'`.yellow);
|
|
253
|
-
classDeclaration.getDecoratorOrThrow('Controller').set({
|
|
254
|
-
arguments: [w => w.quote(controllerPath)],
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
else if (!isFirstBornSibling) {
|
|
258
|
-
const parentParamList = paramList.filter(p => p.fromParent);
|
|
259
|
-
classDeclaration.getDecoratorOrThrow('Controller').set({
|
|
260
|
-
arguments: [
|
|
261
|
-
w => w.quote(`${nestModule}/${parentParamList.length ?
|
|
262
|
-
parentParamList.map(param => `:${param.name}`).join('/') + '/' :
|
|
263
|
-
''}${controllerName.replace(nestModule + '-', '')}`),
|
|
264
|
-
],
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
(0, ts_morph_1.CoerceOperationParamList)(paramList, classDeclaration);
|
|
268
|
-
(0, add_operation_to_controller_1.AddOperationToController)(controllerSourceFile, classDeclaration, operationName, Object.assign({ isAsync: true, paramList,
|
|
269
|
-
queryList,
|
|
270
|
-
path,
|
|
271
|
-
overwrite }, operationOptions));
|
|
73
|
+
(0, ts_morph_1.CoerceNestOperation)(controllerSourceFile, options, moduleSourceFile);
|
|
272
74
|
}, [`${nestController}.controller.ts?`, `${(0, utilities_1.dasherize)(nestModule)}.module.ts?`]),
|
|
273
75
|
]);
|
|
274
76
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coerce-operation.js","sourceRoot":"","sources":["../../../../../../../packages/schematic/ts-morph/src/lib/nest/coerce-operation.ts"],"names":[],"mappings":";;;AAAA,2DAGoC;AACpC,
|
|
1
|
+
{"version":3,"file":"coerce-operation.js","sourceRoot":"","sources":["../../../../../../../packages/schematic/ts-morph/src/lib/nest/coerce-operation.ts"],"names":[],"mappings":";;;AAAA,2DAGoC;AACpC,6CAGwB;AACxB,+CAA4C;AAE5C,+BAA4B;AAC5B,8DAAwE;AACxE,6EAAuE;AACvE,qEAAgE;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'ts-morph';
|
|
3
3
|
import { AbstractControl } from '../types/abstract-control';
|
|
4
|
-
import { CoerceDtoClassOutput } from '
|
|
5
|
-
import { CoerceOperationOptions
|
|
4
|
+
import { CoerceOperationOptions as NEW_CoerceOperationOptions, TransformOperation, CoerceDtoClassOutput } from '@rxap/ts-morph';
|
|
5
|
+
import { CoerceOperationOptions } from './coerce-operation';
|
|
6
6
|
export interface CoerceOptionsOperationRuleOptions extends CoerceOperationOptions {
|
|
7
7
|
control: AbstractControl;
|
|
8
8
|
responseDtoName?: string;
|
|
9
9
|
}
|
|
10
|
-
export declare function BuildOptionsDtoDataMapperImplementation(classDeclaration: ClassDeclaration, moduleSourceFile: SourceFile, dto: CoerceDtoClassOutput | null, options: Readonly<
|
|
10
|
+
export declare function BuildOptionsDtoDataMapperImplementation(classDeclaration: ClassDeclaration, moduleSourceFile: SourceFile, dto: CoerceDtoClassOutput | null, options: Readonly<NEW_CoerceOperationOptions>): TransformOperation<string | WriterFunction>;
|
|
11
11
|
export declare function CoerceOptionsOperationRule(options: Readonly<CoerceOptionsOperationRuleOptions>): Rule;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coerce-options-operation.js","sourceRoot":"","sources":["../../../../../../../packages/schematic/ts-morph/src/lib/nest/coerce-options-operation.ts"],"names":[],"mappings":";;;AACA,6CAKwB;AACxB,+CAGyB;AAQzB,yDAI4B;AAO5B,SAAgB,uCAAuC,CACrD,gBAAkC,EAClC,gBAA4B,EAC5B,GAAgC,EAChC,
|
|
1
|
+
{"version":3,"file":"coerce-options-operation.js","sourceRoot":"","sources":["../../../../../../../packages/schematic/ts-morph/src/lib/nest/coerce-options-operation.ts"],"names":[],"mappings":";;;AACA,6CAKwB;AACxB,+CAGyB;AAQzB,yDAI4B;AAO5B,SAAgB,uCAAuC,CACrD,gBAAkC,EAClC,gBAA4B,EAC5B,GAAgC,EAChC,OAA6C;IAE7C,MAAM,EACJ,OAAO,EACP,QAAQ,GACT,GAAG,OAAO,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AAC,CAAC,CAAC,CAAC,SAAS,CAC7E,CAAC;QACJ,CAAC,IACD,CAAC;AACL,CAAC;AA7BD,gEA6BC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { CoerceDtoClassOptions } from '
|
|
1
|
+
import { CoerceDtoClassOptions } from '@rxap/ts-morph';
|
|
2
2
|
export interface CoercePageDtoClassOptions extends CoerceDtoClassOptions {
|
|
3
3
|
rowClassName: string;
|
|
4
4
|
rowFilePath: string;
|
|
5
5
|
}
|
|
6
6
|
export declare function BuildPageDtoClassName(name: string): string;
|
|
7
|
-
export declare function CoercePageDtoClass(options: CoercePageDtoClassOptions): import("
|
|
7
|
+
export declare function CoercePageDtoClass(options: CoercePageDtoClassOptions): import("@rxap/ts-morph").CoerceDtoClassOutput;
|
|
@@ -5,7 +5,7 @@ const schematics_utilities_1 = require("@rxap/schematics-utilities");
|
|
|
5
5
|
const ts_morph_1 = require("@rxap/ts-morph");
|
|
6
6
|
const utilities_1 = require("@rxap/utilities");
|
|
7
7
|
const path_1 = require("path");
|
|
8
|
-
const
|
|
8
|
+
const ts_morph_2 = require("@rxap/ts-morph");
|
|
9
9
|
function BuildPageDtoClassName(name) {
|
|
10
10
|
return (0, schematics_utilities_1.CoerceSuffix)(name, '-page');
|
|
11
11
|
}
|
|
@@ -49,7 +49,7 @@ function CoercePageDtoClass(options) {
|
|
|
49
49
|
isOptional: true,
|
|
50
50
|
}
|
|
51
51
|
], (a, b) => a.name === b.name);
|
|
52
|
-
return (0,
|
|
52
|
+
return (0, ts_morph_2.CoerceDtoClass)(Object.assign(Object.assign({}, options), { project, name: BuildPageDtoClassName(name), propertyList, tsMorphTransform: (p, sourceFile, classDeclaration) => {
|
|
53
53
|
(0, ts_morph_1.CoerceImports)(sourceFile, [
|
|
54
54
|
{
|
|
55
55
|
namedImports: [rowClassName],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coerce-page-dto-class.js","sourceRoot":"","sources":["../../../../../../../packages/schematic/ts-morph/src/lib/nest/coerce-page-dto-class.ts"],"names":[],"mappings":";;;AAAA,qEAA0D;AAC1D,6CAA+C;AAC/C,+CAGyB;AACzB,+BAAgC;AAChC,
|
|
1
|
+
{"version":3,"file":"coerce-page-dto-class.js","sourceRoot":"","sources":["../../../../../../../packages/schematic/ts-morph/src/lib/nest/coerce-page-dto-class.ts"],"names":[],"mappings":";;;AAAA,qEAA0D;AAC1D,6CAA+C;AAC/C,+CAGyB;AACzB,+BAAgC;AAChC,6CAGwB;AAOxB,SAAgB,qBAAqB,CAAC,IAAY;IAChD,OAAO,IAAA,mCAAY,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACrC,CAAC;AAFD,sDAEC;AAED,SAAgB,kBAAkB,CAAC,OAAkC;IACnE,MAAM,EACJ,OAAO,EACP,IAAI,EACJ,YAAY,GAAE,EAAE,EAChB,YAAY,EACZ,WAAW,EACX,gBAAgB,GAAG,gBAAI,GACxB,GAAG,OAAO,CAAC;IACZ,IAAA,4BAAgB,EAAC,YAAY,EAAE;QAC7B;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,YAAY;YAClB,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,IAAI;SACb;QACD;YACE,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,QAAQ;SACf;QACD;YACE,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,QAAQ;SACf;QACD;YACE,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,QAAQ;SACf;QACD;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE,IAAI;SACjB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE,IAAI;SACjB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,gBAAgB;YACtB,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,IAAI;YACZ,UAAU,EAAE,IAAI;SACjB;KACF,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;IAChC,OAAO,IAAA,yBAAc,kCAChB,OAAO,KACV,OAAO,EACP,IAAI,EAAE,qBAAqB,CAAC,IAAI,CAAC,EACjC,YAAY,EACZ,gBAAgB,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,gBAAgB,EAAE,EAAE;YACpD,IAAA,wBAAa,EAAC,UAAU,EAAE;gBACxB;oBACE,YAAY,EAAE,CAAE,YAAY,CAAE;oBAC9B,eAAe,EAAE,KAAM,IAAA,eAAQ,EAAC,WAAW,CAAE,EAAE;iBAChD;gBACD;oBACE,YAAY,EAAE,CAAE,gBAAgB,CAAE;oBAClC,eAAe,EAAE,gBAAgB;iBAClC;aACF,CAAC,CAAC;YACH,gBAAgB,CAAC,CAAC,EAAE,UAAU,EAAE,gBAAgB,CAAC,CAAC;QACpD,CAAC,IACD,CAAC;AACL,CAAC;AAjED,gDAiEC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TypeImport, TypeName } from '@rxap/ts-morph';
|
|
2
|
-
import { CoerceDtoClassOptions } from '
|
|
2
|
+
import { CoerceDtoClassOptions } from '@rxap/ts-morph';
|
|
3
3
|
export interface CoerceRowDtoClassOptions extends CoerceDtoClassOptions {
|
|
4
4
|
/**
|
|
5
5
|
* the type of the property used as row id type. defaults to the type 'string'. If null the type will be
|
|
@@ -8,4 +8,4 @@ export interface CoerceRowDtoClassOptions extends CoerceDtoClassOptions {
|
|
|
8
8
|
rowIdType?: TypeImport | TypeName;
|
|
9
9
|
}
|
|
10
10
|
export declare function BuildRowDtoClassName(name: string): string;
|
|
11
|
-
export declare function CoerceRowDtoClass(options: CoerceRowDtoClassOptions): import("
|
|
11
|
+
export declare function CoerceRowDtoClass(options: CoerceRowDtoClassOptions): import("@rxap/ts-morph").CoerceDtoClassOutput;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CoerceRowDtoClass = exports.BuildRowDtoClassName = void 0;
|
|
4
4
|
const schematics_utilities_1 = require("@rxap/schematics-utilities");
|
|
5
5
|
const utilities_1 = require("@rxap/utilities");
|
|
6
|
-
const
|
|
6
|
+
const ts_morph_1 = require("@rxap/ts-morph");
|
|
7
7
|
function BuildRowDtoClassName(name) {
|
|
8
8
|
return (0, schematics_utilities_1.CoerceSuffix)(name, '-row');
|
|
9
9
|
}
|
|
@@ -14,7 +14,7 @@ function CoerceRowDtoClass(options) {
|
|
|
14
14
|
name: '__rowId',
|
|
15
15
|
type: rowIdType,
|
|
16
16
|
}], (a, b) => a.name === b.name);
|
|
17
|
-
return (0,
|
|
17
|
+
return (0, ts_morph_1.CoerceDtoClass)({
|
|
18
18
|
project,
|
|
19
19
|
name: BuildRowDtoClassName(name),
|
|
20
20
|
propertyList,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coerce-row-dto-class.js","sourceRoot":"","sources":["../../../../../../../packages/schematic/ts-morph/src/lib/nest/coerce-row-dto-class.ts"],"names":[],"mappings":";;;AAAA,qEAA0D;AAK1D,+CAAmD;AACnD,
|
|
1
|
+
{"version":3,"file":"coerce-row-dto-class.js","sourceRoot":"","sources":["../../../../../../../packages/schematic/ts-morph/src/lib/nest/coerce-row-dto-class.ts"],"names":[],"mappings":";;;AAAA,qEAA0D;AAK1D,+CAAmD;AACnD,6CAGwB;AAUxB,SAAgB,oBAAoB,CAAC,IAAY;IAC/C,OAAO,IAAA,mCAAY,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACpC,CAAC;AAFD,oDAEC;AAED,SAAgB,iBAAiB,CAAC,OAAiC;IACjE,MAAM,EACJ,SAAS,GAAG,QAAQ,EACpB,OAAO,EACP,IAAI,EACJ,YAAY,GAAG,EAAE,GAClB,GAAG,OAAO,CAAC;IACZ,IAAA,4BAAgB,EAAC,YAAY,EAAE,CAAC;YAC9B,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,SAAS;SAChB,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;IACjC,OAAO,IAAA,yBAAc,EAAC;QACpB,OAAO;QACP,IAAI,EAAE,oBAAoB,CAAC,IAAI,CAAC;QAChC,YAAY;KACb,CAAC,CAAC;AACL,CAAC;AAhBD,8CAgBC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DataProperty, NormalizedDataProperty } from '@rxap/ts-morph';
|
|
2
2
|
import { ClassDeclaration, SourceFile, WriterFunction } from 'ts-morph';
|
|
3
|
-
import { CoerceDtoClassOutput } from '
|
|
4
|
-
import { CoerceOperationOptions
|
|
3
|
+
import { TransformOperation, CoerceDtoClassOutput } from '@rxap/ts-morph';
|
|
4
|
+
import { CoerceOperationOptions } from './coerce-operation';
|
|
5
5
|
export interface CoerceTableSelectValueResolveOperationOptions extends CoerceOperationOptions {
|
|
6
6
|
rowIdProperty: DataProperty;
|
|
7
7
|
rowDisplayProperty: NormalizedDataProperty;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { OperationParameter } from '
|
|
1
|
+
import { OperationParameter } from '@rxap/ts-morph';
|
|
2
2
|
export declare const TABLE_QUERY_LIST: OperationParameter[];
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { OverwriteOptions } from '@rxap/schematics-utilities';
|
|
2
|
-
import { TypeImport } from '@rxap/ts-morph';
|
|
3
|
-
import { ClassDeclaration, DecoratorStructure, MethodDeclaration, OptionalKind, SourceFile, StatementStructures, WriterFunction } from 'ts-morph';
|
|
4
|
-
export interface OperationParameter {
|
|
5
|
-
name: string;
|
|
6
|
-
type?: string | WriterFunction | TypeImport;
|
|
7
|
-
pipeList?: Array<string | WriterFunction | TypeImport>;
|
|
8
|
-
defaultValue?: string | WriterFunction;
|
|
9
|
-
hasQuestionToken?: boolean;
|
|
10
|
-
required?: boolean;
|
|
11
|
-
isArray?: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* (optional) the method parameter name. If not defined the name property will be used
|
|
14
|
-
*/
|
|
15
|
-
alias?: string;
|
|
16
|
-
/**
|
|
17
|
-
* true - the parameter is a parent parameter.
|
|
18
|
-
* Example
|
|
19
|
-
* @Controller('/user/:uuid')
|
|
20
|
-
* ...
|
|
21
|
-
* @Get('/profile')
|
|
22
|
-
*
|
|
23
|
-
* In this case the uuid parameter should not be added to the operation path.
|
|
24
|
-
*
|
|
25
|
-
*/
|
|
26
|
-
fromParent?: boolean;
|
|
27
|
-
}
|
|
28
|
-
export interface OperationOptions {
|
|
29
|
-
path?: string;
|
|
30
|
-
returnType?: string | WriterFunction;
|
|
31
|
-
isAsync?: boolean;
|
|
32
|
-
paramList?: OperationParameter[];
|
|
33
|
-
queryList?: OperationParameter[];
|
|
34
|
-
method?: string;
|
|
35
|
-
overwrite?: OverwriteOptions;
|
|
36
|
-
body?: string | WriterFunction;
|
|
37
|
-
statements?: (string | WriterFunction | StatementStructures)[] | string | WriterFunction;
|
|
38
|
-
decorators?: OptionalKind<DecoratorStructure>[];
|
|
39
|
-
tsMorphTransform?: (sourceFile: SourceFile, classDeclaration: ClassDeclaration, methodDeclaration: MethodDeclaration, options: OperationOptions) => void;
|
|
40
|
-
}
|
|
41
|
-
export declare function AddOperationToController(sourceFile: SourceFile, classDeclaration: ClassDeclaration, name: string, options: OperationOptions): void;
|