@rxap/ts-morph 1.3.0 → 1.3.1-dev.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 +6 -0
- package/package.json +2 -2
- package/src/index.d.ts +3 -0
- package/src/index.js +3 -0
- package/src/index.js.map +1 -1
- package/src/lib/nest/coerce-dto-class.d.ts +16 -0
- package/src/lib/nest/coerce-dto-class.js +233 -0
- package/src/lib/nest/coerce-dto-class.js.map +1 -0
- package/src/lib/nest/coerce-nest-operation.d.ts +49 -8
- package/src/lib/nest/coerce-nest-operation.js +279 -37
- package/src/lib/nest/coerce-nest-operation.js.map +1 -1
- package/src/lib/nest/dto-class-property.d.ts +11 -0
- package/src/lib/nest/dto-class-property.js +31 -0
- package/src/lib/nest/dto-class-property.js.map +1 -0
- package/src/lib/overwrite-options.d.ts +1 -0
- package/src/lib/overwrite-options.js +3 -0
- package/src/lib/overwrite-options.js.map +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.3.1-dev.0](https://gitlab.com/rxap/packages/compare/@rxap/ts-morph@1.3.0...@rxap/ts-morph@1.3.1-dev.0) (2024-06-04)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- sort operation parameters ([22e54c5](https://gitlab.com/rxap/packages/commit/22e54c59ec67d6c657f26f7284143f36e5fc0928))
|
|
11
|
+
|
|
6
12
|
# [1.3.0](https://gitlab.com/rxap/packages/compare/@rxap/ts-morph@1.3.0-dev.2...@rxap/ts-morph@1.3.0) (2024-06-02)
|
|
7
13
|
|
|
8
14
|
**Note:** Version bump only for package @rxap/ts-morph
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.3.0",
|
|
2
|
+
"version": "1.3.1-dev.0",
|
|
3
3
|
"name": "@rxap/ts-morph",
|
|
4
4
|
"license": "GPL-3.0-or-later",
|
|
5
5
|
"dependencies": {
|
|
@@ -44,6 +44,6 @@
|
|
|
44
44
|
"directory": "packages/ts-morph"
|
|
45
45
|
},
|
|
46
46
|
"type": "commonjs",
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "ae79ca2aed680609ef2b560fe7528fb03ec87756",
|
|
48
48
|
"main": "./src/index.js"
|
|
49
49
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './lib/nest/add-health-endpoint';
|
|
|
2
2
|
export * from './lib/nest/add-health-indicator';
|
|
3
3
|
export * from './lib/nest/add-to-global-health-endpoint';
|
|
4
4
|
export * from './lib/nest/coerce-app-guard-provider';
|
|
5
|
+
export * from './lib/nest/coerce-dto-class';
|
|
5
6
|
export * from './lib/nest/coerce-health-controller';
|
|
6
7
|
export * from './lib/nest/coerce-health-module';
|
|
7
8
|
export * from './lib/nest/coerce-nest-app-config';
|
|
@@ -19,6 +20,7 @@ export * from './lib/nest/coerce-nest-module';
|
|
|
19
20
|
export * from './lib/nest/coerce-nest-operation';
|
|
20
21
|
export * from './lib/nest/coerce-nest-provider-to-array';
|
|
21
22
|
export * from './lib/nest/coerce-nest-throttler-module-import';
|
|
23
|
+
export * from './lib/nest/dto-class-property';
|
|
22
24
|
export * from './lib/nest/find-nest-module-source-file';
|
|
23
25
|
export * from './lib/nest/get-controller-class';
|
|
24
26
|
export * from './lib/nest/get-nest-module-metadata';
|
|
@@ -71,6 +73,7 @@ export * from './lib/get-class';
|
|
|
71
73
|
export * from './lib/get-coerce-array-literal-form-object-literal';
|
|
72
74
|
export * from './lib/has-constructor-parameter';
|
|
73
75
|
export * from './lib/identifier';
|
|
76
|
+
export * from './lib/overwrite-options';
|
|
74
77
|
export * from './lib/provider-object';
|
|
75
78
|
export * from './lib/to-mapping-object';
|
|
76
79
|
export * from './lib/type-import';
|
package/src/index.js
CHANGED
|
@@ -6,6 +6,7 @@ tslib_1.__exportStar(require("./lib/nest/add-health-endpoint"), exports);
|
|
|
6
6
|
tslib_1.__exportStar(require("./lib/nest/add-health-indicator"), exports);
|
|
7
7
|
tslib_1.__exportStar(require("./lib/nest/add-to-global-health-endpoint"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./lib/nest/coerce-app-guard-provider"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./lib/nest/coerce-dto-class"), exports);
|
|
9
10
|
tslib_1.__exportStar(require("./lib/nest/coerce-health-controller"), exports);
|
|
10
11
|
tslib_1.__exportStar(require("./lib/nest/coerce-health-module"), exports);
|
|
11
12
|
tslib_1.__exportStar(require("./lib/nest/coerce-nest-app-config"), exports);
|
|
@@ -23,6 +24,7 @@ tslib_1.__exportStar(require("./lib/nest/coerce-nest-module"), exports);
|
|
|
23
24
|
tslib_1.__exportStar(require("./lib/nest/coerce-nest-operation"), exports);
|
|
24
25
|
tslib_1.__exportStar(require("./lib/nest/coerce-nest-provider-to-array"), exports);
|
|
25
26
|
tslib_1.__exportStar(require("./lib/nest/coerce-nest-throttler-module-import"), exports);
|
|
27
|
+
tslib_1.__exportStar(require("./lib/nest/dto-class-property"), exports);
|
|
26
28
|
tslib_1.__exportStar(require("./lib/nest/find-nest-module-source-file"), exports);
|
|
27
29
|
tslib_1.__exportStar(require("./lib/nest/get-controller-class"), exports);
|
|
28
30
|
tslib_1.__exportStar(require("./lib/nest/get-nest-module-metadata"), exports);
|
|
@@ -79,6 +81,7 @@ tslib_1.__exportStar(require("./lib/get-class"), exports);
|
|
|
79
81
|
tslib_1.__exportStar(require("./lib/get-coerce-array-literal-form-object-literal"), exports);
|
|
80
82
|
tslib_1.__exportStar(require("./lib/has-constructor-parameter"), exports);
|
|
81
83
|
tslib_1.__exportStar(require("./lib/identifier"), exports);
|
|
84
|
+
tslib_1.__exportStar(require("./lib/overwrite-options"), exports);
|
|
82
85
|
tslib_1.__exportStar(require("./lib/provider-object"), exports);
|
|
83
86
|
tslib_1.__exportStar(require("./lib/to-mapping-object"), exports);
|
|
84
87
|
tslib_1.__exportStar(require("./lib/type-import"), exports);
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/ts-morph/src/index.ts"],"names":[],"mappings":";;;AAAA,cAAc;AACd,yEAA+C;AAC/C,0EAAgD;AAChD,mFAAyD;AACzD,+EAAqD;AACrD,8EAAoD;AACpD,0EAAgD;AAChD,4EAAkD;AAClD,gFAAsD;AACtD,4EAAkD;AAClD,qFAA2D;AAC3D,sFAA4D;AAC5D,4EAAkD;AAClD,sFAA4D;AAC5D,iFAAuD;AACvD,mFAAyD;AACzD,+EAAqD;AACrD,iFAAuD;AACvD,wEAA8C;AAC9C,2EAAiD;AACjD,mFAAyD;AACzD,yFAA+D;AAC/D,kFAAwD;AACxD,0EAAgD;AAChD,8EAAoD;AACpD,2EAAiD;AACjD,4EAAkD;AAClD,0EAAgD;AAChD,0EAAgD;AAChD,4EAAkD;AAClD,+EAAqD;AACrD,iFAAuD;AACvD,mFAAyD;AACzD,YAAY;AAEZ,iBAAiB;AACjB,kEAAwC;AACxC,2EAAiD;AACjD,mFAAyD;AACzD,8EAAoD;AACpD,0EAAgD;AAChD,gFAAsD;AACtD,+EAAqD;AACrD,yEAA+C;AAC/C,6EAAmD;AACnD,2EAAiD;AACjD,sEAA4C;AAC5C,0EAAgD;AAChD,4EAAkD;AAClD,uFAA6D;AAC7D,gFAAsD;AACtD,qEAA2C;AAC3C,YAAY;AAEZ,UAAU;AACV,sEAA4C;AAC5C,4EAAkD;AAClD,qEAA2C;AAC3C,yEAA+C;AAC/C,oEAA0C;AAC1C,sEAA4C;AAC5C,6DAAmC;AACnC,iEAAuC;AACvC,4EAAkD;AAClD,sEAA4C;AAC5C,4EAAkD;AAClD,+DAAqC;AACrC,4EAAkD;AAClD,4EAAkD;AAClD,mEAAyC;AACzC,kEAAwC;AACxC,4EAAkD;AAClD,+DAAqC;AACrC,8DAAoC;AACpC,8DAAoC;AACpC,8EAAoD;AACpD,0DAAgC;AAChC,6FAAmE;AACnE,0EAAgD;AAChD,2DAAiC;AACjC,gEAAsC;AACtC,kEAAwC;AACxC,4DAAkC;AAClC,iEAAuC;AACvC,2DAAiC;AACjC,YAAY"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/ts-morph/src/index.ts"],"names":[],"mappings":";;;AAAA,cAAc;AACd,yEAA+C;AAC/C,0EAAgD;AAChD,mFAAyD;AACzD,+EAAqD;AACrD,sEAA4C;AAC5C,8EAAoD;AACpD,0EAAgD;AAChD,4EAAkD;AAClD,gFAAsD;AACtD,4EAAkD;AAClD,qFAA2D;AAC3D,sFAA4D;AAC5D,4EAAkD;AAClD,sFAA4D;AAC5D,iFAAuD;AACvD,mFAAyD;AACzD,+EAAqD;AACrD,iFAAuD;AACvD,wEAA8C;AAC9C,2EAAiD;AACjD,mFAAyD;AACzD,yFAA+D;AAC/D,wEAA8C;AAC9C,kFAAwD;AACxD,0EAAgD;AAChD,8EAAoD;AACpD,2EAAiD;AACjD,4EAAkD;AAClD,0EAAgD;AAChD,0EAAgD;AAChD,4EAAkD;AAClD,+EAAqD;AACrD,iFAAuD;AACvD,mFAAyD;AACzD,YAAY;AAEZ,iBAAiB;AACjB,kEAAwC;AACxC,2EAAiD;AACjD,mFAAyD;AACzD,8EAAoD;AACpD,0EAAgD;AAChD,gFAAsD;AACtD,+EAAqD;AACrD,yEAA+C;AAC/C,6EAAmD;AACnD,2EAAiD;AACjD,sEAA4C;AAC5C,0EAAgD;AAChD,4EAAkD;AAClD,uFAA6D;AAC7D,gFAAsD;AACtD,qEAA2C;AAC3C,YAAY;AAEZ,UAAU;AACV,sEAA4C;AAC5C,4EAAkD;AAClD,qEAA2C;AAC3C,yEAA+C;AAC/C,oEAA0C;AAC1C,sEAA4C;AAC5C,6DAAmC;AACnC,iEAAuC;AACvC,4EAAkD;AAClD,sEAA4C;AAC5C,4EAAkD;AAClD,+DAAqC;AACrC,4EAAkD;AAClD,4EAAkD;AAClD,mEAAyC;AACzC,kEAAwC;AACxC,4EAAkD;AAClD,+DAAqC;AACrC,8DAAoC;AACpC,8DAAoC;AACpC,8EAAoD;AACpD,0DAAgC;AAChC,6FAAmE;AACnE,0EAAgD;AAChD,2DAAiC;AACjC,kEAAwC;AACxC,gEAAsC;AACtC,kEAAwC;AACxC,4DAAkC;AAClC,iEAAuC;AACvC,2DAAiC;AACjC,YAAY"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ClassDeclaration, Project, SourceFile } from 'ts-morph';
|
|
2
|
+
import { DtoClassProperty } from './dto-class-property';
|
|
3
|
+
import 'colors';
|
|
4
|
+
export interface CoerceDtoClassOutput {
|
|
5
|
+
className: string;
|
|
6
|
+
filePath: string;
|
|
7
|
+
sourceFile: SourceFile;
|
|
8
|
+
classDeclaration: ClassDeclaration;
|
|
9
|
+
}
|
|
10
|
+
export interface CoerceDtoClassOptions {
|
|
11
|
+
project: Project;
|
|
12
|
+
name: string;
|
|
13
|
+
propertyList?: DtoClassProperty[];
|
|
14
|
+
tsMorphTransform?: (project: Project, sourceFile: SourceFile, classDeclaration: ClassDeclaration) => void;
|
|
15
|
+
}
|
|
16
|
+
export declare function CoerceDtoClass(options: CoerceDtoClassOptions): CoerceDtoClassOutput;
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CoerceDtoClass = void 0;
|
|
4
|
+
const utilities_1 = require("@rxap/utilities");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const ts_morph_1 = require("ts-morph");
|
|
7
|
+
const dto_class_property_1 = require("./dto-class-property");
|
|
8
|
+
require("colors");
|
|
9
|
+
const coerce_source_file_1 = require("../coerce-source-file");
|
|
10
|
+
const coerce_class_1 = require("../coerce-class");
|
|
11
|
+
const type_import_1 = require("../type-import");
|
|
12
|
+
const coerce_property_declaration_1 = require("../coerce-property-declaration");
|
|
13
|
+
const write_type_1 = require("../write-type");
|
|
14
|
+
const coerce_decorator_1 = require("../coerce-decorator");
|
|
15
|
+
const coerce_imports_1 = require("../coerce-imports");
|
|
16
|
+
function CoerceDtoClass(options) {
|
|
17
|
+
const { project, propertyList = [], tsMorphTransform = utilities_1.noop, } = options;
|
|
18
|
+
let { name, } = options;
|
|
19
|
+
name = (0, utilities_1.dasherize)(name);
|
|
20
|
+
const className = (0, utilities_1.CoerceSuffix)((0, utilities_1.classify)(name), 'Dto');
|
|
21
|
+
const fileName = (0, utilities_1.CoerceSuffix)(name, '.dto');
|
|
22
|
+
const sourceFile = (0, coerce_source_file_1.CoerceSourceFile)(project, (0, path_1.join)('dtos', fileName + '.ts'));
|
|
23
|
+
const classDeclaration = (0, coerce_class_1.CoerceClass)(sourceFile, className);
|
|
24
|
+
classDeclaration.setIsExported(true);
|
|
25
|
+
for (const property of propertyList.map(dto_class_property_1.NormalizeDataClassProperty)) {
|
|
26
|
+
// create a clone of the property type to avoid modifying the original type
|
|
27
|
+
// if the property type is a self reference we need to replace the self reference with the class name
|
|
28
|
+
// if the property type is a deferred reference we need to replace the deferred reference with the class name
|
|
29
|
+
const propertyType = Object.assign({}, property.type);
|
|
30
|
+
let subTypeOutput;
|
|
31
|
+
switch (propertyType.name) {
|
|
32
|
+
case type_import_1.TypeNames.Self:
|
|
33
|
+
propertyType.name = className;
|
|
34
|
+
propertyType.isTypeOnly = false;
|
|
35
|
+
propertyType.moduleSpecifier = null;
|
|
36
|
+
propertyType.namedImport = null;
|
|
37
|
+
propertyType.namespaceImport = null;
|
|
38
|
+
propertyType.defaultImport = null;
|
|
39
|
+
property.isType = true;
|
|
40
|
+
break;
|
|
41
|
+
case type_import_1.TypeNames.Deferred:
|
|
42
|
+
subTypeOutput = CoerceDtoClass({
|
|
43
|
+
project,
|
|
44
|
+
name: [name, (0, utilities_1.dasherize)(property.name)].join('-'),
|
|
45
|
+
propertyList: property.memberList,
|
|
46
|
+
});
|
|
47
|
+
propertyType.name = subTypeOutput.className;
|
|
48
|
+
propertyType.moduleSpecifier = './' + (0, utilities_1.dasherize)(subTypeOutput.className.replace(/Dto$/, '')) + '.dto';
|
|
49
|
+
propertyType.isTypeOnly = false;
|
|
50
|
+
propertyType.namedImport = null;
|
|
51
|
+
propertyType.namespaceImport = null;
|
|
52
|
+
propertyType.defaultImport = null;
|
|
53
|
+
property.isType = true;
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
let propertyName = (0, utilities_1.camelize)(property.name);
|
|
57
|
+
const prefixMatch = property.name.match(/^(_+)/);
|
|
58
|
+
if (prefixMatch) {
|
|
59
|
+
propertyName = (0, utilities_1.camelize)(property.name.replace(/^_+/, ''));
|
|
60
|
+
propertyName = prefixMatch[0] + propertyName;
|
|
61
|
+
}
|
|
62
|
+
const propertyDeclaration = (0, coerce_property_declaration_1.CoercePropertyDeclaration)(classDeclaration, propertyName).set({
|
|
63
|
+
type: (0, write_type_1.WriteType)({
|
|
64
|
+
isArray: property.isArray,
|
|
65
|
+
type: propertyType,
|
|
66
|
+
}, sourceFile),
|
|
67
|
+
hasQuestionToken: property.isOptional,
|
|
68
|
+
hasExclamationToken: !property.isOptional,
|
|
69
|
+
});
|
|
70
|
+
addExposeDecorator(propertyDeclaration);
|
|
71
|
+
if (property.isArray) {
|
|
72
|
+
addClassValidatorDecoratorForIsArray(propertyDeclaration);
|
|
73
|
+
}
|
|
74
|
+
if (property.isType) {
|
|
75
|
+
addClassValidatorDecoratorForNestedDto(propertyDeclaration, propertyType, property.isArray);
|
|
76
|
+
}
|
|
77
|
+
if (property.isOptional) {
|
|
78
|
+
addIsOptionalDecorator(propertyDeclaration);
|
|
79
|
+
}
|
|
80
|
+
addClassValidatorDecoratorForType(propertyDeclaration, propertyType);
|
|
81
|
+
if (propertyType.name !== 'unknown') {
|
|
82
|
+
cleanupUnknownApiPropertyDecorator(propertyDeclaration);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
tsMorphTransform(project, sourceFile, classDeclaration);
|
|
86
|
+
return {
|
|
87
|
+
className,
|
|
88
|
+
filePath: '.' + (0, path_1.join)(sourceFile.getDirectoryPath(), sourceFile.getBaseNameWithoutExtension()),
|
|
89
|
+
sourceFile,
|
|
90
|
+
classDeclaration,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
exports.CoerceDtoClass = CoerceDtoClass;
|
|
94
|
+
function addIsOptionalDecorator(propertyDeclaration) {
|
|
95
|
+
const sourceFile = propertyDeclaration.getSourceFile();
|
|
96
|
+
(0, coerce_decorator_1.CoerceDecorator)(propertyDeclaration, 'IsOptional', {
|
|
97
|
+
arguments: [],
|
|
98
|
+
});
|
|
99
|
+
(0, coerce_imports_1.CoerceImports)(sourceFile, {
|
|
100
|
+
namedImports: ['IsOptional'],
|
|
101
|
+
moduleSpecifier: 'class-validator',
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function addExposeDecorator(propertyDeclaration) {
|
|
105
|
+
const sourceFile = propertyDeclaration.getSourceFile();
|
|
106
|
+
(0, coerce_decorator_1.CoerceDecorator)(propertyDeclaration, 'Expose', {
|
|
107
|
+
arguments: [],
|
|
108
|
+
});
|
|
109
|
+
(0, coerce_imports_1.CoerceImports)(sourceFile, {
|
|
110
|
+
namedImports: ['Expose'],
|
|
111
|
+
moduleSpecifier: 'class-transformer',
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
function addClassValidatorDecoratorForIsArray(propertyDeclaration) {
|
|
115
|
+
const sourceFile = propertyDeclaration.getSourceFile();
|
|
116
|
+
(0, coerce_decorator_1.CoerceDecorator)(propertyDeclaration, 'IsArray', {
|
|
117
|
+
arguments: [],
|
|
118
|
+
});
|
|
119
|
+
(0, coerce_imports_1.CoerceImports)(sourceFile, {
|
|
120
|
+
namedImports: ['IsArray'],
|
|
121
|
+
moduleSpecifier: 'class-validator',
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
function addClassValidatorDecoratorForNestedDto(propertyDeclaration, propertyType, isArray) {
|
|
125
|
+
const sourceFile = propertyDeclaration.getSourceFile();
|
|
126
|
+
(0, coerce_decorator_1.CoerceDecorator)(propertyDeclaration, 'Type', {
|
|
127
|
+
arguments: [
|
|
128
|
+
w => {
|
|
129
|
+
w.write('() => ');
|
|
130
|
+
(0, write_type_1.WriteType)({
|
|
131
|
+
type: propertyType,
|
|
132
|
+
isArray: false,
|
|
133
|
+
}, sourceFile)(w);
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
});
|
|
137
|
+
(0, coerce_imports_1.CoerceImports)(sourceFile, {
|
|
138
|
+
namedImports: ['Type'],
|
|
139
|
+
moduleSpecifier: 'class-transformer',
|
|
140
|
+
});
|
|
141
|
+
(0, coerce_decorator_1.CoerceDecorator)(propertyDeclaration, 'IsInstance', {
|
|
142
|
+
arguments: [
|
|
143
|
+
(0, write_type_1.WriteType)({
|
|
144
|
+
type: propertyType,
|
|
145
|
+
isArray: false,
|
|
146
|
+
}, sourceFile),
|
|
147
|
+
w => {
|
|
148
|
+
if (isArray) {
|
|
149
|
+
ts_morph_1.Writers.object({ each: 'true' })(w);
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
],
|
|
153
|
+
});
|
|
154
|
+
(0, coerce_imports_1.CoerceImports)(sourceFile, {
|
|
155
|
+
namedImports: ['IsInstance'],
|
|
156
|
+
moduleSpecifier: 'class-validator',
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
function addClassValidatorDecoratorForType(propertyDeclaration, propertyType) {
|
|
160
|
+
var _a;
|
|
161
|
+
const sourceFile = propertyDeclaration.getSourceFile();
|
|
162
|
+
switch (propertyType.name) {
|
|
163
|
+
case 'date':
|
|
164
|
+
(0, coerce_decorator_1.CoerceDecorator)(propertyDeclaration, 'IsDate', {
|
|
165
|
+
arguments: [],
|
|
166
|
+
});
|
|
167
|
+
(0, coerce_imports_1.CoerceImports)(sourceFile, {
|
|
168
|
+
namedImports: ['IsDate'],
|
|
169
|
+
moduleSpecifier: 'class-validator',
|
|
170
|
+
});
|
|
171
|
+
break;
|
|
172
|
+
case 'number':
|
|
173
|
+
(0, coerce_decorator_1.CoerceDecorator)(propertyDeclaration, 'IsNumber', {
|
|
174
|
+
arguments: [],
|
|
175
|
+
});
|
|
176
|
+
(0, coerce_imports_1.CoerceImports)(sourceFile, {
|
|
177
|
+
namedImports: ['IsNumber'],
|
|
178
|
+
moduleSpecifier: 'class-validator',
|
|
179
|
+
});
|
|
180
|
+
break;
|
|
181
|
+
case 'string':
|
|
182
|
+
if ((_a = propertyDeclaration.getName()) === null || _a === void 0 ? void 0 : _a.match(/^uuid|Uuid$/)) {
|
|
183
|
+
(0, coerce_imports_1.CoerceImports)(sourceFile, {
|
|
184
|
+
namedImports: ['IsUUID'],
|
|
185
|
+
moduleSpecifier: 'class-validator',
|
|
186
|
+
});
|
|
187
|
+
(0, coerce_decorator_1.CoerceDecorator)(propertyDeclaration, 'IsUUID', {
|
|
188
|
+
arguments: [],
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
(0, coerce_imports_1.CoerceImports)(sourceFile, {
|
|
193
|
+
namedImports: ['IsString'],
|
|
194
|
+
moduleSpecifier: 'class-validator',
|
|
195
|
+
});
|
|
196
|
+
(0, coerce_decorator_1.CoerceDecorator)(propertyDeclaration, 'IsString', {
|
|
197
|
+
arguments: [],
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
break;
|
|
201
|
+
case 'boolean':
|
|
202
|
+
(0, coerce_decorator_1.CoerceDecorator)(propertyDeclaration, 'IsBoolean', {
|
|
203
|
+
arguments: [],
|
|
204
|
+
});
|
|
205
|
+
(0, coerce_imports_1.CoerceImports)(sourceFile, {
|
|
206
|
+
namedImports: ['IsBoolean'],
|
|
207
|
+
moduleSpecifier: 'class-validator',
|
|
208
|
+
});
|
|
209
|
+
break;
|
|
210
|
+
case 'unknown':
|
|
211
|
+
(0, coerce_decorator_1.CoerceDecorator)(propertyDeclaration, 'ApiProperty', {
|
|
212
|
+
arguments: [ts_morph_1.Writers.object({ type: w => w.quote('unknown') })],
|
|
213
|
+
});
|
|
214
|
+
(0, coerce_imports_1.CoerceImports)(sourceFile, {
|
|
215
|
+
namedImports: ['ApiProperty'],
|
|
216
|
+
moduleSpecifier: '@nestjs/swagger',
|
|
217
|
+
});
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
function cleanupUnknownApiPropertyDecorator(propertyDeclaration) {
|
|
222
|
+
var _a;
|
|
223
|
+
const apiProperty = propertyDeclaration.getDecorators().find(d => d.getName() === 'ApiProperty');
|
|
224
|
+
if (apiProperty) {
|
|
225
|
+
const args = apiProperty.getArguments()[0];
|
|
226
|
+
if (args instanceof ts_morph_1.ObjectLiteralExpression) {
|
|
227
|
+
if ((_a = args.getProperty('type')) === null || _a === void 0 ? void 0 : _a.getText().includes('unknown')) {
|
|
228
|
+
apiProperty.remove();
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
//# sourceMappingURL=coerce-dto-class.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coerce-dto-class.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/nest/coerce-dto-class.ts"],"names":[],"mappings":";;;AAAA,+CAMyB;AACzB,+BAA4B;AAC5B,uCAOkB;AAClB,6DAG8B;AAC9B,kBAAgB;AAChB,8DAAyD;AACzD,kDAA8C;AAC9C,gDAGwB;AACxB,gFAA2E;AAC3E,8CAA0C;AAC1C,0DAAsD;AACtD,sDAAkD;AAgBlD,SAAgB,cAAc,CAAC,OAA8B;IAC3D,MAAM,EACJ,OAAO,EACP,YAAY,GAAG,EAAE,EACjB,gBAAgB,GAAG,gBAAI,GACxB,GAAG,OAAO,CAAC;IACZ,IAAI,EACF,IAAI,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CAAuB,EAAE,CAAC;YAC5C,IAAI,MAAA,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,0CAAE,OAAO,GAAG,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;gBAC5D,WAAW,CAAC,MAAM,EAAE,CAAC;YACvB,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { ClassDeclaration, DecoratorStructure, MethodDeclaration, OptionalKind, SourceFile, StatementStructures, WriterFunction } from 'ts-morph';
|
|
1
|
+
import { ClassDeclaration, DecoratorStructure, MethodDeclaration, OptionalKind, ParameterDeclarationStructure, Project, SourceFile, StatementStructures, WriterFunction } from 'ts-morph';
|
|
2
2
|
import { DataProperty } from '../data-property';
|
|
3
|
+
import { OverwriteOptions } from '../overwrite-options';
|
|
3
4
|
import { TypeImport } from '../type-import';
|
|
5
|
+
import { NormalizedUpstreamOptions } from '../upstream-options';
|
|
6
|
+
import { CoerceDtoClassOutput } from './coerce-dto-class';
|
|
7
|
+
import { DtoClassProperty } from './dto-class-property';
|
|
4
8
|
export interface OperationParameter extends DataProperty {
|
|
5
9
|
type?: string | WriterFunction | TypeImport;
|
|
6
10
|
pipeList?: Array<string | WriterFunction | TypeImport>;
|
|
@@ -23,19 +27,56 @@ export interface OperationParameter extends DataProperty {
|
|
|
23
27
|
*/
|
|
24
28
|
fromParent?: boolean;
|
|
25
29
|
}
|
|
26
|
-
export interface
|
|
27
|
-
controllerName?: string;
|
|
28
|
-
tsMorphTransform?: (sourceFile: SourceFile, classDeclaration: ClassDeclaration, methodDeclaration: MethodDeclaration, options: CoerceOperationOptions) => void;
|
|
30
|
+
export interface OperationOptions {
|
|
29
31
|
paramList?: OperationParameter[];
|
|
30
32
|
queryList?: OperationParameter[];
|
|
31
33
|
operationName: string;
|
|
32
|
-
path?: string;
|
|
34
|
+
path?: string | null;
|
|
33
35
|
returnType?: string | WriterFunction;
|
|
34
36
|
isAsync?: boolean;
|
|
35
37
|
method?: string;
|
|
36
|
-
body?: string | WriterFunction;
|
|
37
|
-
statements?: (string | WriterFunction | StatementStructures)[] | string | WriterFunction;
|
|
38
|
+
body?: string | WriterFunction | null;
|
|
39
|
+
statements?: (string | WriterFunction | StatementStructures)[] | string | WriterFunction | null;
|
|
38
40
|
decorators?: OptionalKind<DecoratorStructure>[];
|
|
39
41
|
}
|
|
42
|
+
export interface CoerceOperationOptions extends OperationOptions {
|
|
43
|
+
tsMorphTransform?: (project: Project, sourceFile: SourceFile, classDeclaration: ClassDeclaration, controllerName: string, moduleSourceFile: SourceFile, dto: CoerceDtoClassOutput | null, options: Readonly<CoerceOperationOptions & any>) => Partial<OperationOptions> | void;
|
|
44
|
+
overwrite?: OverwriteOptions;
|
|
45
|
+
controllerPath?: string;
|
|
46
|
+
/**
|
|
47
|
+
* true - the control path is overwritten with
|
|
48
|
+
*/
|
|
49
|
+
overwriteControllerPath?: boolean;
|
|
50
|
+
context?: string | null;
|
|
51
|
+
coerceUpstreamOperationImplementation?: (classDeclaration: ClassDeclaration, moduleSourceFile: SourceFile, dto: CoerceDtoClassOutput | null, options: Readonly<CoerceOperationOptions & any>) => TransformOperation;
|
|
52
|
+
buildUpstreamGetParametersImplementation?: (classDeclaration: ClassDeclaration, moduleSourceFile: SourceFile, dto: CoerceDtoClassOutput | null, options: Readonly<CoerceOperationOptions & any>) => TransformOperation<string | WriterFunction>;
|
|
53
|
+
buildDtoReturnImplementation?: (classDeclaration: ClassDeclaration, moduleSourceFile: SourceFile, dto: CoerceDtoClassOutput | null, options: Readonly<CoerceOperationOptions & any>) => TransformOperation;
|
|
54
|
+
builtDtoDataMapperImplementation?: (classDeclaration: ClassDeclaration, moduleSourceFile: SourceFile, dto: CoerceDtoClassOutput | null, options: Readonly<CoerceOperationOptions & any>) => TransformOperation<string | WriterFunction>;
|
|
55
|
+
buildUpstreamGetDataImplementation?: (classDeclaration: ClassDeclaration, moduleSourceFile: SourceFile, dto: CoerceDtoClassOutput | null, options: Readonly<CoerceOperationOptions & any>) => TransformOperation<void>;
|
|
56
|
+
buildGetDataImplementation?: (classDeclaration: ClassDeclaration, moduleSourceFile: SourceFile, dto: CoerceDtoClassOutput | null, options: Readonly<CoerceOperationOptions & any>) => TransformOperation<void>;
|
|
57
|
+
coerceOperationDtoClass?: (classDeclaration: ClassDeclaration, controllerName: string, moduleSourceFile: SourceFile, options: Readonly<CoerceOperationOptions & any>) => CoerceDtoClassOutput | null;
|
|
58
|
+
buildOperationDtoClassName?: (controllerName: string, options: Readonly<Pick<CoerceOperationOptions, 'dtoClassNameSuffix' | 'dtoClassName'>>) => string;
|
|
59
|
+
upstream?: NormalizedUpstreamOptions | null;
|
|
60
|
+
propertyList?: DtoClassProperty[];
|
|
61
|
+
isArray?: boolean;
|
|
62
|
+
isReturnVoid?: boolean;
|
|
63
|
+
dtoClassNameSuffix?: string;
|
|
64
|
+
dtoClassName?: string;
|
|
65
|
+
}
|
|
66
|
+
export declare function CoerceUpstreamBasicOperationImplementation(classDeclaration: ClassDeclaration, moduleSourceFile: SourceFile, upstream: NormalizedUpstreamOptions): {
|
|
67
|
+
className: string;
|
|
68
|
+
memberName: string;
|
|
69
|
+
};
|
|
70
|
+
export declare function BuildOperationDtoClassName(controllerName: string, options: Readonly<Pick<CoerceOperationOptions, 'dtoClassNameSuffix' | 'dtoClassName'>>): string;
|
|
71
|
+
export declare function CoerceOperationDtoClass(classDeclaration: ClassDeclaration, controllerName: string, moduleSourceFile: SourceFile, options: Readonly<CoerceOperationOptions>): CoerceDtoClassOutput | null;
|
|
72
|
+
export type TransformOperation<T = void> = (operationOptions: OperationOptions) => T;
|
|
73
|
+
export declare function BuiltDtoDataMapperImplementation(classDeclaration: ClassDeclaration, moduleSourceFile: SourceFile, dto: CoerceDtoClassOutput | null, options: Readonly<CoerceOperationOptions>): TransformOperation<string | WriterFunction>;
|
|
74
|
+
export declare function BuildDtoReturnImplementation(classDeclaration: ClassDeclaration, moduleSourceFile: SourceFile, dto: CoerceDtoClassOutput | null, options: Readonly<CoerceOperationOptions>): TransformOperation;
|
|
75
|
+
export declare function BuildUpstreamGetDataImplementation(classDeclaration: ClassDeclaration, moduleSourceFile: SourceFile, dto: CoerceDtoClassOutput | null, options: Readonly<CoerceOperationOptions>): TransformOperation;
|
|
76
|
+
export declare function CoerceUpstreamDefaultOperationImplementation(classDeclaration: ClassDeclaration, moduleSourceFile: SourceFile, dto: CoerceDtoClassOutput | null, options: Readonly<CoerceOperationOptions>): TransformOperation;
|
|
77
|
+
export declare function BuildMethodQueryParameters(queryList: OperationParameter[], sourceFile: SourceFile): Array<OptionalKind<ParameterDeclarationStructure>>;
|
|
78
|
+
export declare function BuildMethodParamParameters(paramList: OperationParameter[], sourceFile: SourceFile): Array<OptionalKind<ParameterDeclarationStructure>>;
|
|
79
|
+
export declare function BuildMethodBodyParameters(body: string | WriterFunction | undefined | null): Array<OptionalKind<ParameterDeclarationStructure>>;
|
|
80
|
+
export declare function CoerceApiQueryDecorators(queryList: OperationParameter[], methodDeclaration: MethodDeclaration): void;
|
|
40
81
|
export declare function CoerceOperationParamList(paramList: OperationParameter[], classDeclaration: ClassDeclaration): void;
|
|
41
|
-
export declare function CoerceNestOperation(sourceFile: SourceFile, options: CoerceOperationOptions): MethodDeclaration;
|
|
82
|
+
export declare function CoerceNestOperation(sourceFile: SourceFile, options: CoerceOperationOptions, moduleSourceFile?: SourceFile): MethodDeclaration;
|
|
@@ -1,15 +1,184 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CoerceNestOperation = exports.CoerceOperationParamList = void 0;
|
|
3
|
+
exports.CoerceNestOperation = exports.CoerceOperationParamList = exports.CoerceApiQueryDecorators = exports.BuildMethodBodyParameters = exports.BuildMethodParamParameters = exports.BuildMethodQueryParameters = exports.CoerceUpstreamDefaultOperationImplementation = exports.BuildUpstreamGetDataImplementation = exports.BuildDtoReturnImplementation = exports.BuiltDtoDataMapperImplementation = exports.CoerceOperationDtoClass = exports.BuildOperationDtoClassName = exports.CoerceUpstreamBasicOperationImplementation = void 0;
|
|
4
4
|
const utilities_1 = require("@rxap/utilities");
|
|
5
5
|
const ts_morph_1 = require("ts-morph");
|
|
6
6
|
const coerce_class_method_1 = require("../coerce-class-method");
|
|
7
7
|
const coerce_decorator_1 = require("../coerce-decorator");
|
|
8
8
|
const coerce_imports_1 = require("../coerce-imports");
|
|
9
|
+
const coerce_property_declaration_1 = require("../coerce-property-declaration");
|
|
9
10
|
const coerce_statements_1 = require("../coerce-statements");
|
|
11
|
+
const upstream_options_1 = require("../upstream-options");
|
|
10
12
|
const write_type_1 = require("../write-type");
|
|
13
|
+
const coerce_dto_class_1 = require("./coerce-dto-class");
|
|
14
|
+
const coerce_nest_module_import_1 = require("./coerce-nest-module-import");
|
|
15
|
+
const coerce_nest_module_provider_1 = require("./coerce-nest-module-provider");
|
|
16
|
+
const find_nest_module_source_file_1 = require("./find-nest-module-source-file");
|
|
11
17
|
const get_controller_class_1 = require("./get-controller-class");
|
|
12
|
-
|
|
18
|
+
const operation_id_utilities_1 = require("./operation-id-utilities");
|
|
19
|
+
function CoerceUpstreamBasicOperationImplementation(classDeclaration, moduleSourceFile, upstream) {
|
|
20
|
+
if ((0, upstream_options_1.IsNormalizedOpenApiUpstreamOptions)(upstream)) {
|
|
21
|
+
const sourceFile = classDeclaration.getSourceFile();
|
|
22
|
+
const commandClassName = (0, operation_id_utilities_1.OperationIdToCommandClassName)(upstream.operationId);
|
|
23
|
+
(0, coerce_imports_1.CoerceImports)(sourceFile, {
|
|
24
|
+
namedImports: [commandClassName],
|
|
25
|
+
moduleSpecifier: (0, operation_id_utilities_1.OperationIdToCommandClassImportPath)(upstream.operationId, upstream.scope, upstream.isService),
|
|
26
|
+
});
|
|
27
|
+
(0, coerce_nest_module_import_1.CoerceNestModuleImport)(moduleSourceFile, {
|
|
28
|
+
moduleName: 'HttpModule',
|
|
29
|
+
moduleSpecifier: '@nestjs/axios',
|
|
30
|
+
});
|
|
31
|
+
(0, coerce_nest_module_provider_1.CoerceNestModuleProvider)(moduleSourceFile, {
|
|
32
|
+
providerObject: 'Logger',
|
|
33
|
+
moduleSpecifier: '@nestjs/common',
|
|
34
|
+
});
|
|
35
|
+
(0, coerce_nest_module_provider_1.CoerceNestModuleProvider)(moduleSourceFile, {
|
|
36
|
+
providerObject: commandClassName,
|
|
37
|
+
moduleSpecifier: (0, operation_id_utilities_1.OperationIdToCommandClassImportPath)(upstream.operationId, upstream.scope, upstream.isService),
|
|
38
|
+
});
|
|
39
|
+
const commandMemberName = (0, utilities_1.camelize)(commandClassName);
|
|
40
|
+
(0, coerce_imports_1.CoerceImports)(sourceFile, {
|
|
41
|
+
namedImports: ['Inject'],
|
|
42
|
+
moduleSpecifier: '@nestjs/common',
|
|
43
|
+
});
|
|
44
|
+
(0, coerce_property_declaration_1.CoercePropertyDeclaration)(classDeclaration, commandMemberName, {
|
|
45
|
+
type: commandClassName,
|
|
46
|
+
hasExclamationToken: true,
|
|
47
|
+
scope: ts_morph_1.Scope.Private,
|
|
48
|
+
isReadonly: true,
|
|
49
|
+
decorators: [
|
|
50
|
+
{
|
|
51
|
+
name: 'Inject',
|
|
52
|
+
arguments: [commandClassName],
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
});
|
|
56
|
+
return {
|
|
57
|
+
className: commandClassName,
|
|
58
|
+
memberName: commandMemberName,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
throw new Error(`Upstream kind '${upstream.kind}' not supported`);
|
|
62
|
+
}
|
|
63
|
+
exports.CoerceUpstreamBasicOperationImplementation = CoerceUpstreamBasicOperationImplementation;
|
|
64
|
+
function BuildOperationDtoClassName(controllerName, options) {
|
|
65
|
+
const { dtoClassNameSuffix, dtoClassName, } = options;
|
|
66
|
+
return dtoClassName !== null && dtoClassName !== void 0 ? dtoClassName : (dtoClassNameSuffix ? (0, utilities_1.CoerceSuffix)(controllerName, (0, utilities_1.CoercePrefix)(dtoClassNameSuffix, '-')) : controllerName);
|
|
67
|
+
}
|
|
68
|
+
exports.BuildOperationDtoClassName = BuildOperationDtoClassName;
|
|
69
|
+
function CoerceOperationDtoClass(classDeclaration, controllerName, moduleSourceFile, options) {
|
|
70
|
+
const sourceFile = classDeclaration.getSourceFile();
|
|
71
|
+
const project = sourceFile.getProject();
|
|
72
|
+
const { dtoClassNameSuffix, dtoClassName, propertyList = [], isReturnVoid, buildOperationDtoClassName = BuildOperationDtoClassName } = options;
|
|
73
|
+
let dto = null;
|
|
74
|
+
if (propertyList.length > 0 || isReturnVoid === false || dtoClassNameSuffix || dtoClassName) {
|
|
75
|
+
dto = (0, coerce_dto_class_1.CoerceDtoClass)({
|
|
76
|
+
project,
|
|
77
|
+
name: buildOperationDtoClassName(controllerName, options),
|
|
78
|
+
propertyList,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return dto;
|
|
82
|
+
}
|
|
83
|
+
exports.CoerceOperationDtoClass = CoerceOperationDtoClass;
|
|
84
|
+
function BuiltDtoDataMapperImplementation(classDeclaration, moduleSourceFile, dto, options) {
|
|
85
|
+
const { propertyList = [], upstream, isArray, } = options;
|
|
86
|
+
return () => {
|
|
87
|
+
var _a;
|
|
88
|
+
if (upstream) {
|
|
89
|
+
const mapper = {};
|
|
90
|
+
for (const property of propertyList) {
|
|
91
|
+
mapper[property.name] = `data.${(_a = property.source) !== null && _a !== void 0 ? _a : property.name}`;
|
|
92
|
+
}
|
|
93
|
+
if (isArray) {
|
|
94
|
+
return w => {
|
|
95
|
+
w.write('data.map(item => (');
|
|
96
|
+
ts_morph_1.Writers.object(mapper)(w);
|
|
97
|
+
w.write('))');
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
return ts_morph_1.Writers.object(mapper);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
return isArray ? '[]' : '{}';
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
exports.BuiltDtoDataMapperImplementation = BuiltDtoDataMapperImplementation;
|
|
110
|
+
function BuildDtoReturnImplementation(classDeclaration, moduleSourceFile, dto, options) {
|
|
111
|
+
return (operationOptions) => {
|
|
112
|
+
var _a;
|
|
113
|
+
const { isArray, isReturnVoid = !dto, builtDtoDataMapperImplementation = BuiltDtoDataMapperImplementation, } = options;
|
|
114
|
+
if (!isReturnVoid && dto) {
|
|
115
|
+
const sourceFile = classDeclaration.getSourceFile();
|
|
116
|
+
(0, coerce_imports_1.CoerceImports)(sourceFile, {
|
|
117
|
+
namedImports: [isArray ? 'ToDtoInstanceList' : 'ToDtoInstance'],
|
|
118
|
+
moduleSpecifier: '@rxap/nest-dto',
|
|
119
|
+
});
|
|
120
|
+
const mapper = builtDtoDataMapperImplementation(classDeclaration, moduleSourceFile, dto, options)(operationOptions);
|
|
121
|
+
operationOptions.returnType = dto.className + (isArray ? '[]' : '');
|
|
122
|
+
(_a = operationOptions.statements) !== null && _a !== void 0 ? _a : (operationOptions.statements = []);
|
|
123
|
+
operationOptions.statements = (0, utilities_1.coerceArray)(operationOptions.statements);
|
|
124
|
+
if (isArray) {
|
|
125
|
+
operationOptions.statements.push('return ToDtoInstanceList(');
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
operationOptions.statements.push('return ToDtoInstance(');
|
|
129
|
+
}
|
|
130
|
+
operationOptions.statements.push(dto.className + ',', w => {
|
|
131
|
+
if (typeof mapper === 'string') {
|
|
132
|
+
w.write(mapper);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
mapper(w);
|
|
136
|
+
}
|
|
137
|
+
w.write(',');
|
|
138
|
+
}, ');');
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
exports.BuildDtoReturnImplementation = BuildDtoReturnImplementation;
|
|
143
|
+
function BuildUpstreamGetDataImplementation(classDeclaration, moduleSourceFile, dto, options) {
|
|
144
|
+
return (operationOptions) => {
|
|
145
|
+
var _a;
|
|
146
|
+
const { buildUpstreamGetParametersImplementation = (() => () => ''), upstream, } = options;
|
|
147
|
+
if (upstream) {
|
|
148
|
+
if ((0, upstream_options_1.IsNormalizedOpenApiUpstreamOptions)(upstream)) {
|
|
149
|
+
const { memberName: commandMemberName } = CoerceUpstreamBasicOperationImplementation(classDeclaration, moduleSourceFile, upstream);
|
|
150
|
+
const commandParameter = buildUpstreamGetParametersImplementation(classDeclaration, moduleSourceFile, dto, options)(operationOptions);
|
|
151
|
+
(_a = operationOptions.statements) !== null && _a !== void 0 ? _a : (operationOptions.statements = []);
|
|
152
|
+
operationOptions.statements = (0, utilities_1.coerceArray)(operationOptions.statements);
|
|
153
|
+
operationOptions.statements.push(w => {
|
|
154
|
+
w.write(`const data = await this.${commandMemberName}.execute(`);
|
|
155
|
+
if (typeof commandParameter === 'function') {
|
|
156
|
+
commandParameter(w);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
w.write(commandParameter);
|
|
160
|
+
}
|
|
161
|
+
w.write(');');
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
exports.BuildUpstreamGetDataImplementation = BuildUpstreamGetDataImplementation;
|
|
168
|
+
function CoerceUpstreamDefaultOperationImplementation(classDeclaration, moduleSourceFile, dto, options) {
|
|
169
|
+
return (operationOptions) => {
|
|
170
|
+
var _a;
|
|
171
|
+
const { upstream, buildDtoReturnImplementation = BuildDtoReturnImplementation, buildUpstreamGetDataImplementation = BuildUpstreamGetDataImplementation, buildGetDataImplementation = utilities_1.noop, } = options;
|
|
172
|
+
(_a = buildGetDataImplementation(classDeclaration, moduleSourceFile, dto, options)) === null || _a === void 0 ? void 0 : _a(operationOptions);
|
|
173
|
+
if (upstream) {
|
|
174
|
+
operationOptions.isAsync = true;
|
|
175
|
+
buildUpstreamGetDataImplementation(classDeclaration, moduleSourceFile, dto, options)(operationOptions);
|
|
176
|
+
}
|
|
177
|
+
buildDtoReturnImplementation(classDeclaration, moduleSourceFile, dto, options)(operationOptions);
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
exports.CoerceUpstreamDefaultOperationImplementation = CoerceUpstreamDefaultOperationImplementation;
|
|
181
|
+
function BuildMethodQueryParameters(queryList, sourceFile) {
|
|
13
182
|
if (queryList.length) {
|
|
14
183
|
return queryList.map(query => {
|
|
15
184
|
var _a, _b;
|
|
@@ -36,7 +205,7 @@ function buildMethodQueryParameters(queryList, sourceFile) {
|
|
|
36
205
|
w.write(')');
|
|
37
206
|
});
|
|
38
207
|
return Object.assign(Object.assign({}, query), { pipeList });
|
|
39
|
-
}).map(({ alias, name, type, hasQuestionToken, required, defaultValue, pipeList = [], isArray
|
|
208
|
+
}).map(({ alias, name, type, hasQuestionToken, required, defaultValue, pipeList = [], isArray }) => ({
|
|
40
209
|
name: alias !== null && alias !== void 0 ? alias : name,
|
|
41
210
|
type: (0, write_type_1.WriteType)({ type: type !== null && type !== void 0 ? type : 'unknown', isArray: isArray }, sourceFile),
|
|
42
211
|
hasQuestionToken: hasQuestionToken !== null && hasQuestionToken !== void 0 ? hasQuestionToken : (!required && defaultValue === undefined),
|
|
@@ -61,25 +230,27 @@ function buildMethodQueryParameters(queryList, sourceFile) {
|
|
|
61
230
|
}
|
|
62
231
|
return [];
|
|
63
232
|
}
|
|
64
|
-
|
|
233
|
+
exports.BuildMethodQueryParameters = BuildMethodQueryParameters;
|
|
234
|
+
function BuildMethodParamParameters(paramList, sourceFile) {
|
|
65
235
|
if (paramList.length) {
|
|
66
|
-
return paramList.map(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
});
|
|
236
|
+
return paramList.map(({ alias, name, type }) => ({
|
|
237
|
+
name: alias !== null && alias !== void 0 ? alias : name,
|
|
238
|
+
type: type ? (0, write_type_1.WriteType)({
|
|
239
|
+
type: type,
|
|
240
|
+
isArray: false
|
|
241
|
+
}, sourceFile) : undefined,
|
|
242
|
+
decorators: [
|
|
243
|
+
{
|
|
244
|
+
name: 'Param',
|
|
245
|
+
arguments: [w => w.quote(name)],
|
|
246
|
+
},
|
|
247
|
+
],
|
|
248
|
+
}));
|
|
79
249
|
}
|
|
80
250
|
return [];
|
|
81
251
|
}
|
|
82
|
-
|
|
252
|
+
exports.BuildMethodParamParameters = BuildMethodParamParameters;
|
|
253
|
+
function BuildMethodBodyParameters(body) {
|
|
83
254
|
if (body) {
|
|
84
255
|
return [
|
|
85
256
|
{
|
|
@@ -96,7 +267,8 @@ function buildMethodBodyParameters(body) {
|
|
|
96
267
|
}
|
|
97
268
|
return [];
|
|
98
269
|
}
|
|
99
|
-
|
|
270
|
+
exports.BuildMethodBodyParameters = BuildMethodBodyParameters;
|
|
271
|
+
function CoerceApiQueryDecorators(queryList, methodDeclaration) {
|
|
100
272
|
for (const query of queryList) {
|
|
101
273
|
(0, coerce_decorator_1.CoerceDecorator)(methodDeclaration, 'ApiQuery', {
|
|
102
274
|
arguments: [
|
|
@@ -122,6 +294,7 @@ function coerceApiQueryDecorators(queryList, methodDeclaration) {
|
|
|
122
294
|
});
|
|
123
295
|
}
|
|
124
296
|
}
|
|
297
|
+
exports.CoerceApiQueryDecorators = CoerceApiQueryDecorators;
|
|
125
298
|
function CoerceOperationParamList(paramList, classDeclaration) {
|
|
126
299
|
var _a, _b;
|
|
127
300
|
const currentControllerPath = (_b = (_a = classDeclaration.getDecoratorOrThrow('Controller').getArguments()[0]) === null || _a === void 0 ? void 0 : _a.getText()) !== null && _b !== void 0 ? _b : '';
|
|
@@ -134,10 +307,58 @@ function CoerceOperationParamList(paramList, classDeclaration) {
|
|
|
134
307
|
}
|
|
135
308
|
}
|
|
136
309
|
exports.CoerceOperationParamList = CoerceOperationParamList;
|
|
137
|
-
function CoerceNestOperation(sourceFile, options) {
|
|
138
|
-
|
|
139
|
-
|
|
310
|
+
function CoerceNestOperation(sourceFile, options, moduleSourceFile) {
|
|
311
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
312
|
+
const project = sourceFile.getProject();
|
|
313
|
+
if (!moduleSourceFile) {
|
|
314
|
+
moduleSourceFile = (0, find_nest_module_source_file_1.FindNestModuleSourceFile)(project, sourceFile.getDirectoryPath());
|
|
315
|
+
if (!moduleSourceFile) {
|
|
316
|
+
throw new Error(`Could not find Nest module in '${sourceFile.getDirectoryPath()}'`);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
const { tsMorphTransform = () => void 0, coerceUpstreamOperationImplementation = CoerceUpstreamDefaultOperationImplementation, coerceOperationDtoClass = CoerceOperationDtoClass, overwrite, controllerPath, } = options;
|
|
320
|
+
const moduleName = (0, utilities_1.dasherize)(moduleSourceFile.getClasses()[0].getName().replace(/Module$/, ''));
|
|
140
321
|
const classDeclaration = (0, get_controller_class_1.GetControllerClass)(sourceFile);
|
|
322
|
+
const controllerName = (0, utilities_1.dasherize)(classDeclaration.getName().replace(/Controller$/, ''));
|
|
323
|
+
const dto = coerceOperationDtoClass(classDeclaration, controllerName, moduleSourceFile, options);
|
|
324
|
+
if (dto) {
|
|
325
|
+
(0, coerce_imports_1.CoerceImports)(sourceFile, {
|
|
326
|
+
namedImports: [dto.className],
|
|
327
|
+
moduleSpecifier: dto.filePath,
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
const operationOptions = {
|
|
331
|
+
paramList: (_a = options.paramList) !== null && _a !== void 0 ? _a : [],
|
|
332
|
+
queryList: (_b = options.queryList) !== null && _b !== void 0 ? _b : [],
|
|
333
|
+
operationName: options.operationName,
|
|
334
|
+
path: (_c = options.path) !== null && _c !== void 0 ? _c : null,
|
|
335
|
+
returnType: (_d = options.returnType) !== null && _d !== void 0 ? _d : 'void',
|
|
336
|
+
isAsync: (_e = options.isAsync) !== null && _e !== void 0 ? _e : true,
|
|
337
|
+
method: (_f = options.method) !== null && _f !== void 0 ? _f : 'get',
|
|
338
|
+
body: (_g = options.body) !== null && _g !== void 0 ? _g : null,
|
|
339
|
+
statements: (_h = options.statements) !== null && _h !== void 0 ? _h : null,
|
|
340
|
+
decorators: (_j = options.decorators) !== null && _j !== void 0 ? _j : [],
|
|
341
|
+
};
|
|
342
|
+
coerceUpstreamOperationImplementation(classDeclaration, moduleSourceFile, dto, options)(operationOptions);
|
|
343
|
+
Object.assign(operationOptions, (_k = tsMorphTransform(project, sourceFile, classDeclaration, controllerName, moduleSourceFile, dto, options)) !== null && _k !== void 0 ? _k : {});
|
|
344
|
+
const { paramList, queryList, operationName, returnType, isAsync, body, decorators, } = operationOptions;
|
|
345
|
+
let { path, statements, method, } = operationOptions;
|
|
346
|
+
if (controllerPath) {
|
|
347
|
+
console.log(`Overwrite controller path with '${controllerPath}' for operation '${operationName}' in controller '${controllerName}' in module '${moduleName}'`.yellow);
|
|
348
|
+
classDeclaration.getDecoratorOrThrow('Controller').set({
|
|
349
|
+
arguments: [w => w.quote(controllerPath)],
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
else if (moduleName !== controllerName) {
|
|
353
|
+
const parentParamList = paramList.filter(p => p.fromParent);
|
|
354
|
+
classDeclaration.getDecoratorOrThrow('Controller').set({
|
|
355
|
+
arguments: [
|
|
356
|
+
w => w.quote(`${moduleName}/${parentParamList.length ?
|
|
357
|
+
parentParamList.map(param => `:${param.name}`).join('/') + '/' :
|
|
358
|
+
''}${controllerName.replace(moduleName + '-', '')}`),
|
|
359
|
+
],
|
|
360
|
+
});
|
|
361
|
+
}
|
|
141
362
|
CoerceOperationParamList(paramList, classDeclaration);
|
|
142
363
|
method = (0, utilities_1.capitalize)(method.toLowerCase());
|
|
143
364
|
queryList.forEach(query => {
|
|
@@ -211,17 +432,37 @@ function CoerceNestOperation(sourceFile, options) {
|
|
|
211
432
|
const methodDeclaration = (0, coerce_class_method_1.CoerceClassMethod)(classDeclaration, (0, utilities_1.camelize)(operationName), {
|
|
212
433
|
scope: ts_morph_1.Scope.Public,
|
|
213
434
|
isAsync,
|
|
214
|
-
parameters: [
|
|
215
|
-
...buildMethodQueryParameters(queryList, sourceFile),
|
|
216
|
-
...buildMethodParamParameters(paramList, sourceFile),
|
|
217
|
-
...buildMethodBodyParameters(body),
|
|
218
|
-
].sort((a, b) => {
|
|
219
|
-
if (a.hasQuestionToken && b.hasQuestionToken) {
|
|
220
|
-
return 0;
|
|
221
|
-
}
|
|
222
|
-
return a.hasQuestionToken ? 1 : -1;
|
|
223
|
-
}),
|
|
224
435
|
});
|
|
436
|
+
// region coerce parameters
|
|
437
|
+
const existingParameters = methodDeclaration.getParameters().map(p => p.getStructure());
|
|
438
|
+
(0, utilities_1.CoerceArrayItems)(existingParameters, [
|
|
439
|
+
...BuildMethodQueryParameters(queryList, sourceFile),
|
|
440
|
+
...BuildMethodParamParameters(paramList, sourceFile),
|
|
441
|
+
...BuildMethodBodyParameters(body),
|
|
442
|
+
], (a, b) => a.name === b.name);
|
|
443
|
+
methodDeclaration.getParameters().forEach(p => p.remove());
|
|
444
|
+
function sortByName(a, b) {
|
|
445
|
+
if (a.name < b.name) {
|
|
446
|
+
return -1;
|
|
447
|
+
}
|
|
448
|
+
if (a.name > b.name) {
|
|
449
|
+
return 1;
|
|
450
|
+
}
|
|
451
|
+
return 0;
|
|
452
|
+
}
|
|
453
|
+
function sortByOptional(a, b) {
|
|
454
|
+
if (a.hasQuestionToken && !b.hasQuestionToken) {
|
|
455
|
+
return 1;
|
|
456
|
+
}
|
|
457
|
+
if (!a.hasQuestionToken && b.hasQuestionToken) {
|
|
458
|
+
return -1;
|
|
459
|
+
}
|
|
460
|
+
return 0;
|
|
461
|
+
}
|
|
462
|
+
for (const parameter of existingParameters.sort(sortByName).sort(sortByOptional)) {
|
|
463
|
+
methodDeclaration.addParameter(parameter);
|
|
464
|
+
}
|
|
465
|
+
// endregion
|
|
225
466
|
if (returnType) {
|
|
226
467
|
if (isAsync) {
|
|
227
468
|
methodDeclaration.setReturnType(w => {
|
|
@@ -245,12 +486,13 @@ function CoerceNestOperation(sourceFile, options) {
|
|
|
245
486
|
decorators.forEach(decorator => {
|
|
246
487
|
(0, coerce_decorator_1.CoerceDecorator)(methodDeclaration, decorator.name, decorator);
|
|
247
488
|
});
|
|
248
|
-
(0, coerce_decorator_1.CoerceDecorator)(methodDeclaration, method, { arguments: path ? [w => w.quote(path)] : [] })
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
489
|
+
const methodDecorator = (0, coerce_decorator_1.CoerceDecorator)(methodDeclaration, method, { arguments: path ? [w => w.quote(path)] : [] });
|
|
490
|
+
if (overwrite) {
|
|
491
|
+
methodDecorator.set({ arguments: path ? [w => w.quote(path)] : [] });
|
|
492
|
+
}
|
|
493
|
+
CoerceApiQueryDecorators(queryList, methodDeclaration);
|
|
494
|
+
(0, coerce_statements_1.CoerceStatements)(methodDeclaration, statements, Array.isArray(overwrite) ? overwrite.includes('statements') : overwrite !== null && overwrite !== void 0 ? overwrite : false);
|
|
252
495
|
(0, coerce_imports_1.CoerceImports)(sourceFile, importStructures);
|
|
253
|
-
tsMorphTransform(sourceFile, classDeclaration, methodDeclaration, options);
|
|
254
496
|
return methodDeclaration;
|
|
255
497
|
}
|
|
256
498
|
exports.CoerceNestOperation = CoerceNestOperation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coerce-nest-operation.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/nest/coerce-nest-operation.ts"],"names":[],"mappings":";;;AAAA,+CAGyB;AACzB,uCAckB;AAClB,gEAA2D;AAC3D,0DAAsD;AACtD,sDAAkD;AAClD,4DAAwD;AAGxD,8CAA0C;AAC1C,iEAA4D;AA+C5D,SAAS,0BAA0B,CACjC,SAA+B,EAC/B,UAAsB;IAEtB,IAAI,SAAS,CAAC,MAAM,EAAE,CAAC;QACrB,OAAO,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;;YAC3B,IAAI,K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1,11 @@
|
|
|
1
|
+
import { DataProperty, NormalizedDataProperty } from '../data-property';
|
|
2
|
+
import { Normalized } from '@rxap/utilities';
|
|
3
|
+
export interface DtoClassProperty extends DataProperty {
|
|
4
|
+
/**
|
|
5
|
+
* indicates that the @Type decorator should be used as the type of the property is another dto class
|
|
6
|
+
*/
|
|
7
|
+
isType?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface NormalizedDtoClassProperty extends Normalized<Pick<DtoClassProperty, 'isType'>>, NormalizedDataProperty {
|
|
10
|
+
}
|
|
11
|
+
export declare function NormalizeDataClassProperty(property: DtoClassProperty): NormalizedDtoClassProperty;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NormalizeDataClassProperty = void 0;
|
|
4
|
+
const ts_morph_1 = require("@rxap/ts-morph");
|
|
5
|
+
const data_property_1 = require("../data-property");
|
|
6
|
+
function NormalizeDataClassProperty(property) {
|
|
7
|
+
var _a;
|
|
8
|
+
const { name, type, isArray, memberList, source, isOptional, } = (0, data_property_1.NormalizeDataProperty)(property);
|
|
9
|
+
let isType = (_a = property.isType) !== null && _a !== void 0 ? _a : false;
|
|
10
|
+
if ([ts_morph_1.TypeNames.Self, ts_morph_1.TypeNames.Deferred].includes(type.name)) {
|
|
11
|
+
isType = true;
|
|
12
|
+
}
|
|
13
|
+
switch (type.name) {
|
|
14
|
+
case 'IconConfig':
|
|
15
|
+
type.name = 'IconDto';
|
|
16
|
+
type.moduleSpecifier = '@rxap/nest-dto';
|
|
17
|
+
isType = true;
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
source,
|
|
22
|
+
memberList,
|
|
23
|
+
name,
|
|
24
|
+
type,
|
|
25
|
+
isArray,
|
|
26
|
+
isType,
|
|
27
|
+
isOptional,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
exports.NormalizeDataClassProperty = NormalizeDataClassProperty;
|
|
31
|
+
//# sourceMappingURL=dto-class-property.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dto-class-property.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/nest/dto-class-property.ts"],"names":[],"mappings":";;;AAAA,6CAA2C;AAC3C,oDAI0B;AAc1B,SAAgB,0BAA0B,CAAC,QAA0B;;IACnE,MAAM,EACJ,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,UAAU,EACV,MAAM,EACN,UAAU,GACX,GAAG,IAAA,qCAAqB,EAAC,QAAQ,CAAC,CAAC;IACpC,IAAI,MAAM,GAAG,MAAA,QAAQ,CAAC,MAAM,mCAAI,KAAK,CAAC;IACtC,IAAK,CAAE,oBAAS,CAAC,IAAI,EAAE,oBAAS,CAAC,QAAQ,CAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7E,MAAM,GAAG,IAAI,CAAC;IAChB,CAAC;IACD,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,YAAY;YACf,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;YACtB,IAAI,CAAC,eAAe,GAAG,gBAAgB,CAAC;YACxC,MAAM,GAAG,IAAI,CAAC;YACd,MAAM;IACV,CAAC;IACD,OAAO;QACL,MAAM;QACN,UAAU;QACV,IAAI;QACJ,IAAI;QACJ,OAAO;QACP,MAAM;QACN,UAAU;KACX,CAAC;AACJ,CAAC;AA7BD,gEA6BC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type OverwriteOptions = boolean | string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overwrite-options.js","sourceRoot":"","sources":["../../../../../packages/ts-morph/src/lib/overwrite-options.ts"],"names":[],"mappings":""}
|