@nestia/migrate 11.2.1 → 12.0.0-dev.20260520.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/lib/NestiaMigrateApplication.d.ts +1 -12
- package/lib/NestiaMigrateApplication.js +22 -24873
- package/lib/NestiaMigrateApplication.js.map +1 -1
- package/lib/analyzers/NestiaMigrateControllerAnalyzer.js.map +1 -1
- package/lib/archivers/NestiaMigrateFileArchiver.js.map +1 -1
- package/lib/bundles/NEST_TEMPLATE.js +5 -5
- package/lib/bundles/NEST_TEMPLATE.js.map +1 -1
- package/lib/bundles/SDK_TEMPLATE.js +4 -4
- package/lib/bundles/SDK_TEMPLATE.js.map +1 -1
- package/lib/executable/NestiaMigrateCommander.js +14 -5
- package/lib/executable/NestiaMigrateCommander.js.map +1 -1
- package/lib/executable/NestiaMigrateInquirer.js.map +1 -1
- package/lib/factories/TypeLiteralFactory.d.ts +1 -1
- package/lib/factories/TypeLiteralFactory.js +49 -13
- package/lib/factories/TypeLiteralFactory.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +177 -24588
- package/lib/index.mjs.map +1 -1
- package/lib/internal/ts.d.ts +32 -0
- package/lib/internal/ts.js +37 -0
- package/lib/internal/ts.js.map +1 -0
- package/lib/programmers/NestiaMigrateApiFileProgrammer.d.ts +1 -1
- package/lib/programmers/NestiaMigrateApiFileProgrammer.js +2 -5
- package/lib/programmers/NestiaMigrateApiFileProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateApiFunctionProgrammer.d.ts +1 -1
- package/lib/programmers/NestiaMigrateApiFunctionProgrammer.js +87 -49
- package/lib/programmers/NestiaMigrateApiFunctionProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.d.ts +2 -2
- package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.js +80 -82
- package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateApiProgrammer.js +3 -2
- package/lib/programmers/NestiaMigrateApiProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateApiSimulationProgrammer.d.ts +2 -2
- package/lib/programmers/NestiaMigrateApiSimulationProgrammer.js +39 -37
- package/lib/programmers/NestiaMigrateApiSimulationProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateApiStartProgrammer.js +33 -35
- package/lib/programmers/NestiaMigrateApiStartProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateDtoProgrammer.d.ts +1 -1
- package/lib/programmers/NestiaMigrateDtoProgrammer.js +17 -19
- package/lib/programmers/NestiaMigrateDtoProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateE2eFileProgrammer.d.ts +1 -1
- package/lib/programmers/NestiaMigrateE2eFileProgrammer.js +26 -23
- package/lib/programmers/NestiaMigrateE2eFileProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateE2eProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateImportProgrammer.d.ts +1 -1
- package/lib/programmers/NestiaMigrateImportProgrammer.js +11 -14
- package/lib/programmers/NestiaMigrateImportProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateNestControllerProgrammer.d.ts +1 -1
- package/lib/programmers/NestiaMigrateNestControllerProgrammer.js +16 -18
- package/lib/programmers/NestiaMigrateNestControllerProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateNestMethodProgrammer.d.ts +1 -1
- package/lib/programmers/NestiaMigrateNestMethodProgrammer.js +128 -132
- package/lib/programmers/NestiaMigrateNestMethodProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateNestModuleProgrammer.d.ts +1 -1
- package/lib/programmers/NestiaMigrateNestModuleProgrammer.js +10 -9
- package/lib/programmers/NestiaMigrateNestModuleProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateNestProgrammer.js +3 -2
- package/lib/programmers/NestiaMigrateNestProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateSchemaProgrammer.d.ts +2 -2
- package/lib/programmers/NestiaMigrateSchemaProgrammer.js +114 -81
- package/lib/programmers/NestiaMigrateSchemaProgrammer.js.map +1 -1
- package/lib/structures/INestiaMigrateConfig.d.ts +1 -1
- package/lib/utils/FilePrinter.d.ts +2 -2
- package/lib/utils/FilePrinter.js +8 -10
- package/lib/utils/FilePrinter.js.map +1 -1
- package/lib/utils/MapUtil.js.map +1 -1
- package/lib/utils/StringUtil.d.ts +0 -1
- package/lib/utils/StringUtil.js +0 -1
- package/lib/utils/StringUtil.js.map +1 -1
- package/package.json +9 -11
- package/src/NestiaMigrateApplication.ts +29 -30
- package/src/bundles/NEST_TEMPLATE.ts +5 -5
- package/src/bundles/SDK_TEMPLATE.ts +4 -4
- package/src/executable/NestiaMigrateCommander.ts +15 -4
- package/src/executable/bundle.js +237 -4
- package/src/factories/TypeLiteralFactory.ts +22 -16
- package/src/internal/ts.ts +94 -0
- package/src/programmers/NestiaMigrateApiFileProgrammer.ts +7 -4
- package/src/programmers/NestiaMigrateApiFunctionProgrammer.ts +88 -68
- package/src/programmers/NestiaMigrateApiNamespaceProgrammer.ts +122 -111
- package/src/programmers/NestiaMigrateApiProgrammer.ts +6 -5
- package/src/programmers/NestiaMigrateApiSimulationProgrammer.ts +67 -61
- package/src/programmers/NestiaMigrateApiStartProgrammer.ts +46 -45
- package/src/programmers/NestiaMigrateDtoProgrammer.ts +4 -3
- package/src/programmers/NestiaMigrateE2eFileProgrammer.ts +33 -30
- package/src/programmers/NestiaMigrateE2eProgrammer.ts +1 -1
- package/src/programmers/NestiaMigrateImportProgrammer.ts +20 -19
- package/src/programmers/NestiaMigrateNestControllerProgrammer.ts +8 -7
- package/src/programmers/NestiaMigrateNestMethodProgrammer.ts +82 -77
- package/src/programmers/NestiaMigrateNestModuleProgrammer.ts +18 -17
- package/src/programmers/NestiaMigrateNestProgrammer.ts +6 -5
- package/src/programmers/NestiaMigrateSchemaProgrammer.ts +54 -42
- package/src/structures/INestiaMigrateConfig.ts +1 -1
- package/src/utils/FilePrinter.ts +9 -14
- package/src/utils/StringUtil.ts +0 -5
- package/lib/structures/INestiaMigrateDto.d.ts +0 -7
- package/lib/structures/INestiaMigrateDto.js +0 -3
- package/lib/structures/INestiaMigrateDto.js.map +0 -1
- package/lib/structures/INestiaMigrateProgram.d.ts +0 -9
- package/lib/structures/INestiaMigrateProgram.js +0 -3
- package/lib/structures/INestiaMigrateProgram.js.map +0 -1
- package/lib/structures/INestiaMigrateSchema.d.ts +0 -4
- package/lib/structures/INestiaMigrateSchema.js +0 -3
- package/lib/structures/INestiaMigrateSchema.js.map +0 -1
- package/lib/utils/SetupWizard.d.ts +0 -3
- package/lib/utils/SetupWizard.js +0 -18
- package/lib/utils/SetupWizard.js.map +0 -1
- package/lib/utils/openapi-down-convert/RefVisitor.d.ts +0 -52
- package/lib/utils/openapi-down-convert/RefVisitor.js +0 -102
- package/lib/utils/openapi-down-convert/RefVisitor.js.map +0 -1
- package/lib/utils/openapi-down-convert/converter.d.ts +0 -146
- package/lib/utils/openapi-down-convert/converter.js +0 -441
- package/lib/utils/openapi-down-convert/converter.js.map +0 -1
- package/src/structures/INestiaMigrateDto.ts +0 -8
- package/src/structures/INestiaMigrateProgram.ts +0 -11
- package/src/structures/INestiaMigrateSchema.ts +0 -4
- package/src/utils/SetupWizard.ts +0 -12
- package/src/utils/openapi-down-convert/RefVisitor.ts +0 -134
- package/src/utils/openapi-down-convert/converter.ts +0 -536
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { TypeScriptFactory } from "@nestia/factory";
|
|
2
|
+
import ts from "../internal/ts";
|
|
2
3
|
|
|
3
4
|
import { TypeLiteralFactory } from "../factories/TypeLiteralFactory";
|
|
4
5
|
import { FilePrinter } from "../utils/FilePrinter";
|
|
@@ -28,11 +29,11 @@ export class NestiaMigrateImportProgrammer {
|
|
|
28
29
|
public dto(name: string, namespace?: string): ts.TypeReferenceNode {
|
|
29
30
|
const file: string = name.split(".")[0]!;
|
|
30
31
|
this.dtos_.add(file);
|
|
31
|
-
return
|
|
32
|
+
return TypeScriptFactory.createTypeReferenceNode(
|
|
32
33
|
namespace?.length
|
|
33
|
-
?
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
? TypeScriptFactory.createQualifiedName(
|
|
35
|
+
TypeScriptFactory.createIdentifier(namespace),
|
|
36
|
+
TypeScriptFactory.createIdentifier(file),
|
|
36
37
|
)
|
|
37
38
|
: name,
|
|
38
39
|
);
|
|
@@ -44,7 +45,7 @@ export class NestiaMigrateImportProgrammer {
|
|
|
44
45
|
library: "typia",
|
|
45
46
|
name: "tags",
|
|
46
47
|
});
|
|
47
|
-
return
|
|
48
|
+
return TypeScriptFactory.createTypeReferenceNode(
|
|
48
49
|
`${instance}.${type}`,
|
|
49
50
|
arg === undefined ? [] : [TypeLiteralFactory.generate(arg)],
|
|
50
51
|
);
|
|
@@ -56,26 +57,26 @@ export class NestiaMigrateImportProgrammer {
|
|
|
56
57
|
): ts.Statement[] {
|
|
57
58
|
return [
|
|
58
59
|
...[...this.external_.entries()].map(([library, props]) =>
|
|
59
|
-
|
|
60
|
+
TypeScriptFactory.createImportDeclaration(
|
|
60
61
|
undefined,
|
|
61
|
-
|
|
62
|
+
TypeScriptFactory.createImportClause(
|
|
62
63
|
false,
|
|
63
64
|
props.default !== null
|
|
64
|
-
?
|
|
65
|
+
? TypeScriptFactory.createIdentifier(props.default)
|
|
65
66
|
: undefined,
|
|
66
67
|
props.instances.size
|
|
67
|
-
?
|
|
68
|
+
? TypeScriptFactory.createNamedImports(
|
|
68
69
|
[...props.instances].map((i) =>
|
|
69
|
-
|
|
70
|
+
TypeScriptFactory.createImportSpecifier(
|
|
70
71
|
false,
|
|
71
72
|
undefined,
|
|
72
|
-
|
|
73
|
+
TypeScriptFactory.createIdentifier(i),
|
|
73
74
|
),
|
|
74
75
|
),
|
|
75
76
|
)
|
|
76
77
|
: undefined,
|
|
77
78
|
),
|
|
78
|
-
|
|
79
|
+
TypeScriptFactory.createStringLiteral(library),
|
|
79
80
|
),
|
|
80
81
|
),
|
|
81
82
|
...(this.external_.size && this.dtos_.size
|
|
@@ -86,20 +87,20 @@ export class NestiaMigrateImportProgrammer {
|
|
|
86
87
|
current ? (name) => name !== current!.split(".")[0] : () => true,
|
|
87
88
|
)
|
|
88
89
|
.map((i) =>
|
|
89
|
-
|
|
90
|
+
TypeScriptFactory.createImportDeclaration(
|
|
90
91
|
undefined,
|
|
91
|
-
|
|
92
|
+
TypeScriptFactory.createImportClause(
|
|
92
93
|
false,
|
|
93
94
|
undefined,
|
|
94
|
-
|
|
95
|
-
|
|
95
|
+
TypeScriptFactory.createNamedImports([
|
|
96
|
+
TypeScriptFactory.createImportSpecifier(
|
|
96
97
|
false,
|
|
97
98
|
undefined,
|
|
98
|
-
|
|
99
|
+
TypeScriptFactory.createIdentifier(i),
|
|
99
100
|
),
|
|
100
101
|
]),
|
|
101
102
|
),
|
|
102
|
-
|
|
103
|
+
TypeScriptFactory.createStringLiteral(dtoPath(i)),
|
|
103
104
|
),
|
|
104
105
|
),
|
|
105
106
|
];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { TypeScriptFactory } from "@nestia/factory";
|
|
1
2
|
import { OpenApi } from "@typia/interface";
|
|
2
|
-
import ts from "
|
|
3
|
+
import ts from "../internal/ts";
|
|
3
4
|
|
|
4
5
|
import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
|
|
5
6
|
import { INestiaMigrateController } from "../structures/INestiaMigrateController";
|
|
@@ -18,11 +19,11 @@ export namespace NestiaMigrateNestControllerProgrammer {
|
|
|
18
19
|
export const write = (props: IProps): ts.Statement[] => {
|
|
19
20
|
const importer: NestiaMigrateImportProgrammer =
|
|
20
21
|
new NestiaMigrateImportProgrammer();
|
|
21
|
-
const $class =
|
|
22
|
+
const $class = TypeScriptFactory.createClassDeclaration(
|
|
22
23
|
[
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
TypeScriptFactory.createDecorator(
|
|
25
|
+
TypeScriptFactory.createCallExpression(
|
|
26
|
+
TypeScriptFactory.createIdentifier(
|
|
26
27
|
importer.external({
|
|
27
28
|
type: "instance",
|
|
28
29
|
library: "@nestjs/common",
|
|
@@ -30,10 +31,10 @@ export namespace NestiaMigrateNestControllerProgrammer {
|
|
|
30
31
|
}),
|
|
31
32
|
),
|
|
32
33
|
[],
|
|
33
|
-
[
|
|
34
|
+
[TypeScriptFactory.createStringLiteral(props.controller.path)],
|
|
34
35
|
),
|
|
35
36
|
),
|
|
36
|
-
|
|
37
|
+
TypeScriptFactory.createToken(ts.SyntaxKind.ExportKeyword),
|
|
37
38
|
],
|
|
38
39
|
props.controller.name,
|
|
39
40
|
[],
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { TypeScriptFactory } from "@nestia/factory";
|
|
1
2
|
import {
|
|
2
3
|
ExpressionFactory,
|
|
3
4
|
IdentifierFactory,
|
|
4
5
|
LiteralFactory,
|
|
5
6
|
TypeFactory,
|
|
6
|
-
} from "@
|
|
7
|
+
} from "@nestia/factory";
|
|
7
8
|
import { IHttpMigrateRoute } from "@typia/interface";
|
|
8
|
-
import ts from "
|
|
9
|
+
import ts from "../internal/ts";
|
|
9
10
|
import { OpenApi } from "typia";
|
|
10
11
|
|
|
11
12
|
import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
|
|
@@ -33,50 +34,51 @@ export namespace NestiaMigrateNestMethodProgrammer {
|
|
|
33
34
|
})
|
|
34
35
|
: TypeFactory.keyword("void");
|
|
35
36
|
|
|
36
|
-
const method: ts.MethodDeclaration =
|
|
37
|
-
|
|
38
|
-
...writeMethodDecorators(ctx),
|
|
39
|
-
ts.factory.createToken(ts.SyntaxKind.PublicKeyword),
|
|
40
|
-
ts.factory.createToken(ts.SyntaxKind.AsyncKeyword),
|
|
41
|
-
],
|
|
42
|
-
undefined,
|
|
43
|
-
ctx.route.accessor.at(-1)!,
|
|
44
|
-
undefined,
|
|
45
|
-
undefined,
|
|
46
|
-
writeParameters(ctx),
|
|
47
|
-
ts.factory.createTypeReferenceNode("Promise", [output]),
|
|
48
|
-
ts.factory.createBlock(
|
|
37
|
+
const method: ts.MethodDeclaration =
|
|
38
|
+
TypeScriptFactory.createMethodDeclaration(
|
|
49
39
|
[
|
|
50
|
-
...
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
40
|
+
...writeMethodDecorators(ctx),
|
|
41
|
+
TypeScriptFactory.createToken(ts.SyntaxKind.PublicKeyword),
|
|
42
|
+
TypeScriptFactory.createToken(ts.SyntaxKind.AsyncKeyword),
|
|
43
|
+
],
|
|
44
|
+
undefined,
|
|
45
|
+
ctx.route.accessor.at(-1)!,
|
|
46
|
+
undefined,
|
|
47
|
+
undefined,
|
|
48
|
+
writeParameters(ctx),
|
|
49
|
+
TypeScriptFactory.createTypeReferenceNode("Promise", [output]),
|
|
50
|
+
TypeScriptFactory.createBlock(
|
|
51
|
+
[
|
|
52
|
+
...[
|
|
53
|
+
...ctx.route.parameters.map((p) => p.key),
|
|
54
|
+
...(ctx.route.headers ? ["headers"] : []),
|
|
55
|
+
...(ctx.route.query ? ["query"] : []),
|
|
56
|
+
...(ctx.route.body ? ["body"] : []),
|
|
57
|
+
].map((str) =>
|
|
58
|
+
TypeScriptFactory.createExpressionStatement(
|
|
59
|
+
TypeScriptFactory.createIdentifier(str),
|
|
60
|
+
),
|
|
58
61
|
),
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
TypeScriptFactory.createReturnStatement(
|
|
63
|
+
TypeScriptFactory.createCallExpression(
|
|
64
|
+
IdentifierFactory.access(
|
|
65
|
+
TypeScriptFactory.createIdentifier(
|
|
66
|
+
ctx.importer.external({
|
|
67
|
+
type: "default",
|
|
68
|
+
library: "typia",
|
|
69
|
+
name: "typia",
|
|
70
|
+
}),
|
|
71
|
+
),
|
|
72
|
+
"random",
|
|
69
73
|
),
|
|
70
|
-
|
|
74
|
+
[output],
|
|
75
|
+
undefined,
|
|
71
76
|
),
|
|
72
|
-
[output],
|
|
73
|
-
undefined,
|
|
74
77
|
),
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
)
|
|
79
|
-
);
|
|
78
|
+
],
|
|
79
|
+
true,
|
|
80
|
+
),
|
|
81
|
+
);
|
|
80
82
|
return FilePrinter.description(
|
|
81
83
|
method,
|
|
82
84
|
writeDescription(ctx.config, ctx.route),
|
|
@@ -94,7 +96,7 @@ export namespace NestiaMigrateNestMethodProgrammer {
|
|
|
94
96
|
|
|
95
97
|
const writeMethodDecorators = (ctx: IContext): ts.Decorator[] => {
|
|
96
98
|
const external = (lib: string, instance: string): ts.Identifier =>
|
|
97
|
-
|
|
99
|
+
TypeScriptFactory.createIdentifier(
|
|
98
100
|
ctx.importer.external({
|
|
99
101
|
type: "instance",
|
|
100
102
|
library: lib,
|
|
@@ -114,8 +116,8 @@ export namespace NestiaMigrateNestMethodProgrammer {
|
|
|
114
116
|
// HUMAN-ONLY
|
|
115
117
|
if (ctx.route.operation()["x-samchon-human"] === true)
|
|
116
118
|
decorators.push(
|
|
117
|
-
|
|
118
|
-
|
|
119
|
+
TypeScriptFactory.createDecorator(
|
|
120
|
+
TypeScriptFactory.createCallExpression(
|
|
119
121
|
external("@nestia/core", "HumanRoute"),
|
|
120
122
|
undefined,
|
|
121
123
|
undefined,
|
|
@@ -130,15 +132,15 @@ export namespace NestiaMigrateNestMethodProgrammer {
|
|
|
130
132
|
.filter((str) => !!str.length)
|
|
131
133
|
.join("/");
|
|
132
134
|
const router = (instance: string) =>
|
|
133
|
-
|
|
134
|
-
|
|
135
|
+
TypeScriptFactory.createDecorator(
|
|
136
|
+
TypeScriptFactory.createCallExpression(
|
|
135
137
|
IdentifierFactory.access(
|
|
136
138
|
external("@nestia/core", instance),
|
|
137
139
|
StringUtil.capitalize(ctx.route.method),
|
|
138
140
|
),
|
|
139
141
|
[],
|
|
140
142
|
localPath.length
|
|
141
|
-
? [
|
|
143
|
+
? [TypeScriptFactory.createStringLiteral(localPath)]
|
|
142
144
|
: undefined,
|
|
143
145
|
),
|
|
144
146
|
);
|
|
@@ -146,11 +148,11 @@ export namespace NestiaMigrateNestMethodProgrammer {
|
|
|
146
148
|
decorators.push(router("EncryptedRoute"));
|
|
147
149
|
else if (ctx.route.success?.type === "text/plain")
|
|
148
150
|
decorators.push(
|
|
149
|
-
|
|
150
|
-
|
|
151
|
+
TypeScriptFactory.createDecorator(
|
|
152
|
+
TypeScriptFactory.createCallExpression(
|
|
151
153
|
external("@nestjs/common", StringUtil.capitalize(ctx.route.method)),
|
|
152
154
|
[],
|
|
153
|
-
[
|
|
155
|
+
[TypeScriptFactory.createStringLiteral(ctx.route.path)],
|
|
154
156
|
),
|
|
155
157
|
),
|
|
156
158
|
);
|
|
@@ -158,11 +160,11 @@ export namespace NestiaMigrateNestMethodProgrammer {
|
|
|
158
160
|
decorators.push(router("TypedQuery"));
|
|
159
161
|
else if (ctx.route.method === "head")
|
|
160
162
|
decorators.push(
|
|
161
|
-
|
|
162
|
-
|
|
163
|
+
TypeScriptFactory.createDecorator(
|
|
164
|
+
TypeScriptFactory.createCallExpression(
|
|
163
165
|
external("@nestjs/common", "Head"),
|
|
164
166
|
[],
|
|
165
|
-
[
|
|
167
|
+
[TypeScriptFactory.createStringLiteral(ctx.route.path)],
|
|
166
168
|
),
|
|
167
169
|
),
|
|
168
170
|
);
|
|
@@ -173,8 +175,8 @@ export namespace NestiaMigrateNestMethodProgrammer {
|
|
|
173
175
|
decorators.push(router("TypedRoute"));
|
|
174
176
|
for (const [key, value] of Object.entries(ctx.route.exceptions ?? {}))
|
|
175
177
|
decorators.push(
|
|
176
|
-
|
|
177
|
-
|
|
178
|
+
TypeScriptFactory.createDecorator(
|
|
179
|
+
TypeScriptFactory.createCallExpression(
|
|
178
180
|
external("@nestia/core", "TypedException"),
|
|
179
181
|
[
|
|
180
182
|
NestiaMigrateSchemaProgrammer.write({
|
|
@@ -185,11 +187,11 @@ export namespace NestiaMigrateNestMethodProgrammer {
|
|
|
185
187
|
],
|
|
186
188
|
[
|
|
187
189
|
isNaN(Number(key))
|
|
188
|
-
?
|
|
190
|
+
? TypeScriptFactory.createStringLiteral(key)
|
|
189
191
|
: ExpressionFactory.number(Number(key)),
|
|
190
192
|
...(value.response().description?.length
|
|
191
193
|
? [
|
|
192
|
-
|
|
194
|
+
TypeScriptFactory.createStringLiteral(
|
|
193
195
|
value.response().description!,
|
|
194
196
|
),
|
|
195
197
|
]
|
|
@@ -203,12 +205,12 @@ export namespace NestiaMigrateNestMethodProgrammer {
|
|
|
203
205
|
|
|
204
206
|
const writeParameters = (ctx: IContext): ts.ParameterDeclaration[] => [
|
|
205
207
|
...ctx.route.parameters.map((p) =>
|
|
206
|
-
|
|
208
|
+
TypeScriptFactory.createParameterDeclaration(
|
|
207
209
|
[
|
|
208
210
|
...writeExampleDecorators("Parameter")(ctx.importer)(p.parameter()),
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
211
|
+
TypeScriptFactory.createDecorator(
|
|
212
|
+
TypeScriptFactory.createCallExpression(
|
|
213
|
+
TypeScriptFactory.createIdentifier(
|
|
212
214
|
ctx.importer.external({
|
|
213
215
|
type: "instance",
|
|
214
216
|
library: "@nestia/core",
|
|
@@ -216,7 +218,7 @@ export namespace NestiaMigrateNestMethodProgrammer {
|
|
|
216
218
|
}),
|
|
217
219
|
),
|
|
218
220
|
undefined,
|
|
219
|
-
[
|
|
221
|
+
[TypeScriptFactory.createStringLiteral(p.key)],
|
|
220
222
|
),
|
|
221
223
|
),
|
|
222
224
|
],
|
|
@@ -276,14 +278,14 @@ export namespace NestiaMigrateNestMethodProgrammer {
|
|
|
276
278
|
arguments:
|
|
277
279
|
ctx.route.body.type === "multipart/form-data"
|
|
278
280
|
? [
|
|
279
|
-
|
|
281
|
+
TypeScriptFactory.createArrowFunction(
|
|
280
282
|
undefined,
|
|
281
283
|
undefined,
|
|
282
284
|
[],
|
|
283
285
|
undefined,
|
|
284
286
|
undefined,
|
|
285
|
-
|
|
286
|
-
|
|
287
|
+
TypeScriptFactory.createCallExpression(
|
|
288
|
+
TypeScriptFactory.createIdentifier(
|
|
287
289
|
ctx.importer.external({
|
|
288
290
|
type: "default",
|
|
289
291
|
library: "multer",
|
|
@@ -324,7 +326,7 @@ export namespace NestiaMigrateNestMethodProgrammer {
|
|
|
324
326
|
example?: any;
|
|
325
327
|
examples?: Record<string, any>;
|
|
326
328
|
}): ts.ParameterDeclaration => {
|
|
327
|
-
const instance =
|
|
329
|
+
const instance = TypeScriptFactory.createIdentifier(
|
|
328
330
|
importer.external({
|
|
329
331
|
type: "instance",
|
|
330
332
|
library: "@nestia/core",
|
|
@@ -334,11 +336,11 @@ export namespace NestiaMigrateNestMethodProgrammer {
|
|
|
334
336
|
: accessor.method[0],
|
|
335
337
|
}),
|
|
336
338
|
);
|
|
337
|
-
return
|
|
339
|
+
return TypeScriptFactory.createParameterDeclaration(
|
|
338
340
|
[
|
|
339
341
|
...writeExampleDecorators("Parameter")(importer)(props),
|
|
340
|
-
|
|
341
|
-
|
|
342
|
+
TypeScriptFactory.createDecorator(
|
|
343
|
+
TypeScriptFactory.createCallExpression(
|
|
342
344
|
typeof accessor.method === "string"
|
|
343
345
|
? instance
|
|
344
346
|
: IdentifierFactory.access(instance, accessor.method[1]),
|
|
@@ -350,7 +352,7 @@ export namespace NestiaMigrateNestMethodProgrammer {
|
|
|
350
352
|
undefined,
|
|
351
353
|
accessor.variable,
|
|
352
354
|
props.required === false
|
|
353
|
-
?
|
|
355
|
+
? TypeScriptFactory.createToken(ts.SyntaxKind.QuestionToken)
|
|
354
356
|
: undefined,
|
|
355
357
|
NestiaMigrateSchemaProgrammer.write({
|
|
356
358
|
components,
|
|
@@ -369,10 +371,10 @@ export namespace NestiaMigrateNestMethodProgrammer {
|
|
|
369
371
|
}): ts.Decorator[] => [
|
|
370
372
|
...(media.example !== undefined
|
|
371
373
|
? [
|
|
372
|
-
|
|
373
|
-
|
|
374
|
+
TypeScriptFactory.createDecorator(
|
|
375
|
+
TypeScriptFactory.createCallExpression(
|
|
374
376
|
IdentifierFactory.access(
|
|
375
|
-
|
|
377
|
+
TypeScriptFactory.createIdentifier(
|
|
376
378
|
importer.external({
|
|
377
379
|
type: "instance",
|
|
378
380
|
library: "@nestia/core",
|
|
@@ -388,10 +390,10 @@ export namespace NestiaMigrateNestMethodProgrammer {
|
|
|
388
390
|
]
|
|
389
391
|
: []),
|
|
390
392
|
...Object.entries(media.examples ?? {}).map(([key, value]) =>
|
|
391
|
-
|
|
392
|
-
|
|
393
|
+
TypeScriptFactory.createDecorator(
|
|
394
|
+
TypeScriptFactory.createCallExpression(
|
|
393
395
|
IdentifierFactory.access(
|
|
394
|
-
|
|
396
|
+
TypeScriptFactory.createIdentifier(
|
|
395
397
|
importer.external({
|
|
396
398
|
type: "instance",
|
|
397
399
|
library: "@nestia/core",
|
|
@@ -401,7 +403,10 @@ export namespace NestiaMigrateNestMethodProgrammer {
|
|
|
401
403
|
kind,
|
|
402
404
|
),
|
|
403
405
|
[],
|
|
404
|
-
[
|
|
406
|
+
[
|
|
407
|
+
TypeScriptFactory.createStringLiteral(key),
|
|
408
|
+
LiteralFactory.write(value),
|
|
409
|
+
],
|
|
405
410
|
),
|
|
406
411
|
),
|
|
407
412
|
),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { TypeScriptFactory } from "@nestia/factory";
|
|
2
|
+
import ts from "../internal/ts";
|
|
2
3
|
|
|
3
4
|
import { INestiaMigrateController } from "../structures/INestiaMigrateController";
|
|
4
5
|
import { FilePrinter } from "../utils/FilePrinter";
|
|
@@ -13,20 +14,20 @@ export namespace NestiaMigrateNestModuleProgrammer {
|
|
|
13
14
|
$import(`${c.location.replace("src/", "./")}/${c.name}`)(c.name),
|
|
14
15
|
),
|
|
15
16
|
...(controllers.length ? [FilePrinter.newLine()] : []),
|
|
16
|
-
|
|
17
|
+
TypeScriptFactory.createClassDeclaration(
|
|
17
18
|
[
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
TypeScriptFactory.createDecorator(
|
|
20
|
+
TypeScriptFactory.createCallExpression(
|
|
21
|
+
TypeScriptFactory.createIdentifier("Module"),
|
|
21
22
|
undefined,
|
|
22
23
|
[
|
|
23
|
-
|
|
24
|
+
TypeScriptFactory.createObjectLiteralExpression(
|
|
24
25
|
[
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
TypeScriptFactory.createPropertyAssignment(
|
|
27
|
+
TypeScriptFactory.createIdentifier("controllers"),
|
|
28
|
+
TypeScriptFactory.createArrayLiteralExpression(
|
|
28
29
|
controllers.map((c) =>
|
|
29
|
-
|
|
30
|
+
TypeScriptFactory.createIdentifier(c.name),
|
|
30
31
|
),
|
|
31
32
|
true,
|
|
32
33
|
),
|
|
@@ -37,7 +38,7 @@ export namespace NestiaMigrateNestModuleProgrammer {
|
|
|
37
38
|
],
|
|
38
39
|
),
|
|
39
40
|
),
|
|
40
|
-
|
|
41
|
+
TypeScriptFactory.createToken(ts.SyntaxKind.ExportKeyword),
|
|
41
42
|
],
|
|
42
43
|
"MyModule",
|
|
43
44
|
undefined,
|
|
@@ -48,18 +49,18 @@ export namespace NestiaMigrateNestModuleProgrammer {
|
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
const $import = (file: string) => (instance: string) =>
|
|
51
|
-
|
|
52
|
+
TypeScriptFactory.createImportDeclaration(
|
|
52
53
|
undefined,
|
|
53
|
-
|
|
54
|
+
TypeScriptFactory.createImportClause(
|
|
54
55
|
false,
|
|
55
56
|
undefined,
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
TypeScriptFactory.createNamedImports([
|
|
58
|
+
TypeScriptFactory.createImportSpecifier(
|
|
58
59
|
false,
|
|
59
60
|
undefined,
|
|
60
|
-
|
|
61
|
+
TypeScriptFactory.createIdentifier(instance),
|
|
61
62
|
),
|
|
62
63
|
]),
|
|
63
64
|
),
|
|
64
|
-
|
|
65
|
+
TypeScriptFactory.createStringLiteral(file),
|
|
65
66
|
);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { TypeScriptFactory } from "@nestia/factory";
|
|
2
|
+
import ts from "../internal/ts";
|
|
2
3
|
|
|
3
4
|
import { NestiaMigrateControllerAnalyzer } from "../analyzers/NestiaMigrateControllerAnalyzer";
|
|
4
5
|
import { INestiaMigrateContext } from "../structures/INestiaMigrateContext";
|
|
@@ -74,10 +75,10 @@ export namespace NestiaMigrateNestProgrammer {
|
|
|
74
75
|
for (const child of modulo.children.values())
|
|
75
76
|
internal.push(...iterate(importer)(child));
|
|
76
77
|
output.push(
|
|
77
|
-
|
|
78
|
-
[
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
TypeScriptFactory.createModuleDeclaration(
|
|
79
|
+
[TypeScriptFactory.createModifier(ts.SyntaxKind.ExportKeyword)],
|
|
80
|
+
TypeScriptFactory.createIdentifier(modulo.name),
|
|
81
|
+
TypeScriptFactory.createModuleBlock(internal),
|
|
81
82
|
ts.NodeFlags.Namespace,
|
|
82
83
|
),
|
|
83
84
|
);
|