@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,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TypeScriptFactory } from "@nestia/factory";
|
|
2
|
+
import { IdentifierFactory, StatementFactory, TypeFactory } from "@nestia/factory";
|
|
2
3
|
import { IHttpMigrateRoute } from "@typia/interface";
|
|
3
|
-
import ts from "
|
|
4
|
+
import ts from "../internal/ts";
|
|
4
5
|
import { OpenApi } from "typia";
|
|
5
6
|
|
|
6
7
|
import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
|
|
@@ -27,15 +28,15 @@ export namespace NestiaMigrateApiSimulationProgrammer {
|
|
|
27
28
|
: TypeFactory.keyword("void");
|
|
28
29
|
return constant(
|
|
29
30
|
"random",
|
|
30
|
-
|
|
31
|
+
TypeScriptFactory.createArrowFunction(
|
|
31
32
|
undefined,
|
|
32
33
|
undefined,
|
|
33
34
|
[],
|
|
34
35
|
output,
|
|
35
36
|
undefined,
|
|
36
|
-
|
|
37
|
+
TypeScriptFactory.createCallExpression(
|
|
37
38
|
IdentifierFactory.access(
|
|
38
|
-
|
|
39
|
+
TypeScriptFactory.createIdentifier(
|
|
39
40
|
ctx.importer.external({
|
|
40
41
|
type: "default",
|
|
41
42
|
library: "typia",
|
|
@@ -53,14 +54,14 @@ export namespace NestiaMigrateApiSimulationProgrammer {
|
|
|
53
54
|
|
|
54
55
|
export const simulate = (ctx: IContext): ts.VariableStatement => {
|
|
55
56
|
const caller = () =>
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
TypeScriptFactory.createCallExpression(
|
|
58
|
+
TypeScriptFactory.createIdentifier("random"),
|
|
58
59
|
undefined,
|
|
59
60
|
undefined,
|
|
60
61
|
);
|
|
61
62
|
return constant(
|
|
62
63
|
"simulate",
|
|
63
|
-
|
|
64
|
+
TypeScriptFactory.createArrowFunction(
|
|
64
65
|
undefined,
|
|
65
66
|
undefined,
|
|
66
67
|
NestiaMigrateApiFunctionProgrammer.writeParameterDeclarations(
|
|
@@ -71,12 +72,12 @@ export namespace NestiaMigrateApiSimulationProgrammer {
|
|
|
71
72
|
? "_connection"
|
|
72
73
|
: undefined,
|
|
73
74
|
),
|
|
74
|
-
|
|
75
|
+
TypeScriptFactory.createTypeReferenceNode(
|
|
75
76
|
ctx.route.success ? "Response" : "void",
|
|
76
77
|
),
|
|
77
78
|
undefined,
|
|
78
|
-
|
|
79
|
-
[...assert(ctx),
|
|
79
|
+
TypeScriptFactory.createBlock(
|
|
80
|
+
[...assert(ctx), TypeScriptFactory.createReturnStatement(caller())],
|
|
80
81
|
true,
|
|
81
82
|
),
|
|
82
83
|
),
|
|
@@ -86,8 +87,11 @@ export namespace NestiaMigrateApiSimulationProgrammer {
|
|
|
86
87
|
const assert = (ctx: IContext): ts.Statement[] => {
|
|
87
88
|
const property = (key: string) =>
|
|
88
89
|
ctx.config.keyword === true
|
|
89
|
-
? IdentifierFactory.access(
|
|
90
|
-
|
|
90
|
+
? IdentifierFactory.access(
|
|
91
|
+
TypeScriptFactory.createIdentifier("props"),
|
|
92
|
+
key,
|
|
93
|
+
)
|
|
94
|
+
: TypeScriptFactory.createIdentifier(key);
|
|
91
95
|
const parameters = [
|
|
92
96
|
...ctx.route.parameters.map((p) => ({
|
|
93
97
|
category: "param",
|
|
@@ -129,9 +133,9 @@ export namespace NestiaMigrateApiSimulationProgrammer {
|
|
|
129
133
|
|
|
130
134
|
const validator = StatementFactory.constant({
|
|
131
135
|
name: "assert",
|
|
132
|
-
value:
|
|
136
|
+
value: TypeScriptFactory.createCallExpression(
|
|
133
137
|
IdentifierFactory.access(
|
|
134
|
-
|
|
138
|
+
TypeScriptFactory.createIdentifier(
|
|
135
139
|
ctx.importer.external({
|
|
136
140
|
type: "instance",
|
|
137
141
|
library: `@nestia/fetcher`,
|
|
@@ -142,26 +146,26 @@ export namespace NestiaMigrateApiSimulationProgrammer {
|
|
|
142
146
|
),
|
|
143
147
|
undefined,
|
|
144
148
|
[
|
|
145
|
-
|
|
149
|
+
TypeScriptFactory.createObjectLiteralExpression(
|
|
146
150
|
[
|
|
147
|
-
|
|
151
|
+
TypeScriptFactory.createPropertyAssignment(
|
|
148
152
|
"method",
|
|
149
|
-
|
|
153
|
+
TypeScriptFactory.createIdentifier("METADATA.method"),
|
|
150
154
|
),
|
|
151
|
-
|
|
155
|
+
TypeScriptFactory.createPropertyAssignment(
|
|
152
156
|
"host",
|
|
153
|
-
|
|
157
|
+
TypeScriptFactory.createIdentifier("connection.host"),
|
|
154
158
|
),
|
|
155
|
-
|
|
159
|
+
TypeScriptFactory.createPropertyAssignment(
|
|
156
160
|
"path",
|
|
157
161
|
NestiaMigrateApiNamespaceProgrammer.writePathCallExpression(
|
|
158
162
|
ctx.config,
|
|
159
163
|
ctx.route,
|
|
160
164
|
),
|
|
161
165
|
),
|
|
162
|
-
|
|
166
|
+
TypeScriptFactory.createPropertyAssignment(
|
|
163
167
|
"contentType",
|
|
164
|
-
|
|
168
|
+
TypeScriptFactory.createStringLiteral(
|
|
165
169
|
ctx.route.success?.type ?? "application/json",
|
|
166
170
|
),
|
|
167
171
|
),
|
|
@@ -171,30 +175,30 @@ export namespace NestiaMigrateApiSimulationProgrammer {
|
|
|
171
175
|
],
|
|
172
176
|
),
|
|
173
177
|
});
|
|
174
|
-
const individual = parameters
|
|
178
|
+
const individual: ts.Statement[] = parameters
|
|
175
179
|
.map((p) =>
|
|
176
|
-
|
|
180
|
+
TypeScriptFactory.createCallExpression(
|
|
177
181
|
(() => {
|
|
178
182
|
const base = IdentifierFactory.access(
|
|
179
|
-
|
|
183
|
+
TypeScriptFactory.createIdentifier("assert"),
|
|
180
184
|
p.category,
|
|
181
185
|
);
|
|
182
186
|
if (p.category !== "param") return base;
|
|
183
|
-
return
|
|
184
|
-
|
|
187
|
+
return TypeScriptFactory.createCallExpression(base, undefined, [
|
|
188
|
+
TypeScriptFactory.createStringLiteral(p.name),
|
|
185
189
|
]);
|
|
186
190
|
})(),
|
|
187
191
|
undefined,
|
|
188
192
|
[
|
|
189
|
-
|
|
193
|
+
TypeScriptFactory.createArrowFunction(
|
|
190
194
|
undefined,
|
|
191
195
|
undefined,
|
|
192
196
|
[],
|
|
193
197
|
undefined,
|
|
194
198
|
undefined,
|
|
195
|
-
|
|
199
|
+
TypeScriptFactory.createCallExpression(
|
|
196
200
|
IdentifierFactory.access(
|
|
197
|
-
|
|
201
|
+
TypeScriptFactory.createIdentifier(
|
|
198
202
|
ctx.importer.external({
|
|
199
203
|
type: "default",
|
|
200
204
|
library: "typia",
|
|
@@ -206,7 +210,7 @@ export namespace NestiaMigrateApiSimulationProgrammer {
|
|
|
206
210
|
undefined,
|
|
207
211
|
[
|
|
208
212
|
p.category === "headers"
|
|
209
|
-
?
|
|
213
|
+
? TypeScriptFactory.createIdentifier("connection.headers")
|
|
210
214
|
: property(p.name),
|
|
211
215
|
],
|
|
212
216
|
),
|
|
@@ -214,7 +218,7 @@ export namespace NestiaMigrateApiSimulationProgrammer {
|
|
|
214
218
|
],
|
|
215
219
|
),
|
|
216
220
|
)
|
|
217
|
-
.map(
|
|
221
|
+
.map(TypeScriptFactory.createExpressionStatement) as ts.Statement[];
|
|
218
222
|
return [validator, tryAndCatch(ctx.importer, individual)];
|
|
219
223
|
};
|
|
220
224
|
|
|
@@ -222,17 +226,17 @@ export namespace NestiaMigrateApiSimulationProgrammer {
|
|
|
222
226
|
importer: NestiaMigrateImportProgrammer,
|
|
223
227
|
individual: ts.Statement[],
|
|
224
228
|
) =>
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
229
|
+
TypeScriptFactory.createTryStatement(
|
|
230
|
+
TypeScriptFactory.createBlock(individual, true),
|
|
231
|
+
TypeScriptFactory.createCatchClause(
|
|
228
232
|
"exp",
|
|
229
|
-
|
|
233
|
+
TypeScriptFactory.createBlock(
|
|
230
234
|
[
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
235
|
+
TypeScriptFactory.createIfStatement(
|
|
236
|
+
TypeScriptFactory.createLogicalNot(
|
|
237
|
+
TypeScriptFactory.createCallExpression(
|
|
234
238
|
IdentifierFactory.access(
|
|
235
|
-
|
|
239
|
+
TypeScriptFactory.createIdentifier(
|
|
236
240
|
importer.external({
|
|
237
241
|
type: "default",
|
|
238
242
|
library: "typia",
|
|
@@ -242,7 +246,7 @@ export namespace NestiaMigrateApiSimulationProgrammer {
|
|
|
242
246
|
"is",
|
|
243
247
|
),
|
|
244
248
|
[
|
|
245
|
-
|
|
249
|
+
TypeScriptFactory.createTypeReferenceNode(
|
|
246
250
|
importer.external({
|
|
247
251
|
type: "instance",
|
|
248
252
|
library: "@nestia/fetcher",
|
|
@@ -250,32 +254,34 @@ export namespace NestiaMigrateApiSimulationProgrammer {
|
|
|
250
254
|
}),
|
|
251
255
|
),
|
|
252
256
|
],
|
|
253
|
-
[
|
|
257
|
+
[TypeScriptFactory.createIdentifier("exp")],
|
|
254
258
|
),
|
|
255
259
|
),
|
|
256
|
-
|
|
257
|
-
|
|
260
|
+
TypeScriptFactory.createThrowStatement(
|
|
261
|
+
TypeScriptFactory.createIdentifier("exp"),
|
|
258
262
|
),
|
|
259
263
|
),
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
264
|
+
TypeScriptFactory.createReturnStatement(
|
|
265
|
+
TypeScriptFactory.createAsExpression(
|
|
266
|
+
TypeScriptFactory.createObjectLiteralExpression(
|
|
263
267
|
[
|
|
264
|
-
|
|
268
|
+
TypeScriptFactory.createPropertyAssignment(
|
|
265
269
|
"success",
|
|
266
|
-
|
|
270
|
+
TypeScriptFactory.createFalse(),
|
|
267
271
|
),
|
|
268
|
-
|
|
272
|
+
TypeScriptFactory.createPropertyAssignment(
|
|
269
273
|
"status",
|
|
270
|
-
|
|
274
|
+
TypeScriptFactory.createIdentifier("exp.status"),
|
|
271
275
|
),
|
|
272
|
-
|
|
276
|
+
TypeScriptFactory.createPropertyAssignment(
|
|
273
277
|
"headers",
|
|
274
|
-
|
|
278
|
+
TypeScriptFactory.createIdentifier("exp.headers"),
|
|
275
279
|
),
|
|
276
|
-
|
|
280
|
+
TypeScriptFactory.createPropertyAssignment(
|
|
277
281
|
"data",
|
|
278
|
-
|
|
282
|
+
TypeScriptFactory.createIdentifier(
|
|
283
|
+
"exp.toJSON().message",
|
|
284
|
+
),
|
|
279
285
|
),
|
|
280
286
|
],
|
|
281
287
|
true,
|
|
@@ -292,12 +298,12 @@ export namespace NestiaMigrateApiSimulationProgrammer {
|
|
|
292
298
|
}
|
|
293
299
|
|
|
294
300
|
const constant = (name: string, expression: ts.Expression) =>
|
|
295
|
-
|
|
296
|
-
[
|
|
297
|
-
|
|
301
|
+
TypeScriptFactory.createVariableStatement(
|
|
302
|
+
[TypeScriptFactory.createModifier(ts.SyntaxKind.ExportKeyword)],
|
|
303
|
+
TypeScriptFactory.createVariableDeclarationList(
|
|
298
304
|
[
|
|
299
|
-
|
|
300
|
-
|
|
305
|
+
TypeScriptFactory.createVariableDeclaration(
|
|
306
|
+
TypeScriptFactory.createIdentifier(name),
|
|
301
307
|
undefined,
|
|
302
308
|
undefined,
|
|
303
309
|
expression,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TypeScriptFactory } from "@nestia/factory";
|
|
2
|
+
import { IdentifierFactory, StatementFactory } from "@nestia/factory";
|
|
2
3
|
import { IHttpMigrateRoute } from "@typia/interface";
|
|
3
|
-
import ts from "
|
|
4
|
+
import ts from "../internal/ts";
|
|
4
5
|
|
|
5
6
|
import { INestiaMigrateContext } from "../structures/INestiaMigrateContext";
|
|
6
7
|
import { FilePrinter } from "../utils/FilePrinter";
|
|
@@ -23,25 +24,25 @@ export namespace NestiaMigrateApiStartProgrammer {
|
|
|
23
24
|
(name) => `@ORGANIZATION/PROJECT-api/lib/structures/${name}`,
|
|
24
25
|
),
|
|
25
26
|
FilePrinter.newLine(),
|
|
26
|
-
|
|
27
|
+
TypeScriptFactory.createImportDeclaration(
|
|
27
28
|
undefined,
|
|
28
|
-
|
|
29
|
+
TypeScriptFactory.createImportClause(
|
|
29
30
|
false,
|
|
30
31
|
undefined,
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
TypeScriptFactory.createNamedImports([
|
|
33
|
+
TypeScriptFactory.createImportSpecifier(
|
|
33
34
|
false,
|
|
34
35
|
undefined,
|
|
35
|
-
|
|
36
|
+
TypeScriptFactory.createIdentifier("TestGlobal"),
|
|
36
37
|
),
|
|
37
38
|
]),
|
|
38
39
|
),
|
|
39
|
-
|
|
40
|
+
TypeScriptFactory.createStringLiteral("./TestGlobal"),
|
|
40
41
|
undefined,
|
|
41
42
|
),
|
|
42
43
|
FilePrinter.newLine(),
|
|
43
44
|
main,
|
|
44
|
-
|
|
45
|
+
TypeScriptFactory.createExpressionStatement(writeStarter()),
|
|
45
46
|
];
|
|
46
47
|
return {
|
|
47
48
|
"test/start.ts": FilePrinter.write({ statements }),
|
|
@@ -55,13 +56,13 @@ export namespace NestiaMigrateApiStartProgrammer {
|
|
|
55
56
|
): ts.VariableStatement =>
|
|
56
57
|
StatementFactory.constant({
|
|
57
58
|
name: "main",
|
|
58
|
-
value:
|
|
59
|
-
[
|
|
59
|
+
value: TypeScriptFactory.createArrowFunction(
|
|
60
|
+
[TypeScriptFactory.createToken(ts.SyntaxKind.AsyncKeyword)],
|
|
60
61
|
undefined,
|
|
61
62
|
[],
|
|
62
63
|
undefined,
|
|
63
64
|
undefined,
|
|
64
|
-
|
|
65
|
+
TypeScriptFactory.createBlock(
|
|
65
66
|
[
|
|
66
67
|
writeConnection(ctx, importer),
|
|
67
68
|
...NestiaMigrateE2eFunctionProgrammer.writeBody({
|
|
@@ -80,31 +81,31 @@ export namespace NestiaMigrateApiStartProgrammer {
|
|
|
80
81
|
ctx: INestiaMigrateContext,
|
|
81
82
|
importer: NestiaMigrateImportProgrammer,
|
|
82
83
|
): ts.VariableStatement =>
|
|
83
|
-
|
|
84
|
+
TypeScriptFactory.createVariableStatement(
|
|
84
85
|
undefined,
|
|
85
|
-
|
|
86
|
+
TypeScriptFactory.createVariableDeclarationList(
|
|
86
87
|
[
|
|
87
|
-
|
|
88
|
+
TypeScriptFactory.createVariableDeclaration(
|
|
88
89
|
"connection",
|
|
89
90
|
undefined,
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
TypeScriptFactory.createTypeReferenceNode(
|
|
92
|
+
TypeScriptFactory.createQualifiedName(
|
|
93
|
+
TypeScriptFactory.createIdentifier(
|
|
93
94
|
importer.external({
|
|
94
95
|
type: "default",
|
|
95
96
|
library: "@ORGANIZATION/PROJECT-api",
|
|
96
97
|
name: "api",
|
|
97
98
|
}),
|
|
98
99
|
),
|
|
99
|
-
|
|
100
|
+
TypeScriptFactory.createIdentifier("IConnection"),
|
|
100
101
|
),
|
|
101
102
|
),
|
|
102
|
-
|
|
103
|
+
TypeScriptFactory.createObjectLiteralExpression(
|
|
103
104
|
[
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
TypeScriptFactory.createSpreadAssignment(
|
|
106
|
+
TypeScriptFactory.createCallExpression(
|
|
107
|
+
TypeScriptFactory.createPropertyAccessExpression(
|
|
108
|
+
TypeScriptFactory.createIdentifier("TestGlobal"),
|
|
108
109
|
"connection",
|
|
109
110
|
),
|
|
110
111
|
undefined,
|
|
@@ -113,9 +114,9 @@ export namespace NestiaMigrateApiStartProgrammer {
|
|
|
113
114
|
),
|
|
114
115
|
...(ctx.application.document().servers?.[0]?.url?.length
|
|
115
116
|
? [
|
|
116
|
-
|
|
117
|
+
TypeScriptFactory.createPropertyAssignment(
|
|
117
118
|
"host",
|
|
118
|
-
|
|
119
|
+
TypeScriptFactory.createStringLiteral(
|
|
119
120
|
ctx.application.document().servers![0]!.url,
|
|
120
121
|
),
|
|
121
122
|
),
|
|
@@ -123,9 +124,9 @@ export namespace NestiaMigrateApiStartProgrammer {
|
|
|
123
124
|
: []),
|
|
124
125
|
...(ctx.config.simulate === true
|
|
125
126
|
? [
|
|
126
|
-
|
|
127
|
+
TypeScriptFactory.createPropertyAssignment(
|
|
127
128
|
"simulate",
|
|
128
|
-
|
|
129
|
+
TypeScriptFactory.createTrue(),
|
|
129
130
|
),
|
|
130
131
|
]
|
|
131
132
|
: []),
|
|
@@ -139,10 +140,10 @@ export namespace NestiaMigrateApiStartProgrammer {
|
|
|
139
140
|
);
|
|
140
141
|
|
|
141
142
|
const writeStarter = (): ts.CallExpression =>
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
143
|
+
TypeScriptFactory.createCallExpression(
|
|
144
|
+
TypeScriptFactory.createPropertyAccessExpression(
|
|
145
|
+
TypeScriptFactory.createCallExpression(
|
|
146
|
+
TypeScriptFactory.createIdentifier("main"),
|
|
146
147
|
undefined,
|
|
147
148
|
undefined,
|
|
148
149
|
),
|
|
@@ -150,34 +151,34 @@ export namespace NestiaMigrateApiStartProgrammer {
|
|
|
150
151
|
),
|
|
151
152
|
undefined,
|
|
152
153
|
[
|
|
153
|
-
|
|
154
|
+
TypeScriptFactory.createArrowFunction(
|
|
154
155
|
undefined,
|
|
155
156
|
undefined,
|
|
156
157
|
[IdentifierFactory.parameter("exp")],
|
|
157
158
|
undefined,
|
|
158
159
|
undefined,
|
|
159
|
-
|
|
160
|
+
TypeScriptFactory.createBlock(
|
|
160
161
|
[
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
162
|
+
TypeScriptFactory.createExpressionStatement(
|
|
163
|
+
TypeScriptFactory.createCallExpression(
|
|
164
|
+
TypeScriptFactory.createPropertyAccessExpression(
|
|
165
|
+
TypeScriptFactory.createIdentifier("console"),
|
|
165
166
|
"log",
|
|
166
167
|
),
|
|
167
168
|
undefined,
|
|
168
|
-
[
|
|
169
|
+
[TypeScriptFactory.createIdentifier("exp")],
|
|
169
170
|
),
|
|
170
171
|
),
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
172
|
+
TypeScriptFactory.createExpressionStatement(
|
|
173
|
+
TypeScriptFactory.createCallExpression(
|
|
174
|
+
TypeScriptFactory.createPropertyAccessExpression(
|
|
175
|
+
TypeScriptFactory.createIdentifier("process"),
|
|
175
176
|
"exit",
|
|
176
177
|
),
|
|
177
178
|
undefined,
|
|
178
179
|
[
|
|
179
|
-
|
|
180
|
-
|
|
180
|
+
TypeScriptFactory.createPrefixMinus(
|
|
181
|
+
TypeScriptFactory.createNumericLiteral("1"),
|
|
181
182
|
),
|
|
182
183
|
],
|
|
183
184
|
),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { TypeScriptFactory } from "@nestia/factory";
|
|
1
2
|
import { OpenApi } from "@typia/interface";
|
|
2
3
|
import { IPointer } from "tstl";
|
|
3
|
-
import ts from "
|
|
4
|
+
import ts from "../internal/ts";
|
|
4
5
|
|
|
5
6
|
import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
|
|
6
7
|
import { FilePrinter } from "../utils/FilePrinter";
|
|
@@ -65,8 +66,8 @@ export namespace NestiaMigrateDtoProgrammer {
|
|
|
65
66
|
(importer: NestiaMigrateImportProgrammer) =>
|
|
66
67
|
(key: string, value: OpenApi.IJsonSchema) =>
|
|
67
68
|
FilePrinter.description(
|
|
68
|
-
|
|
69
|
-
[
|
|
69
|
+
TypeScriptFactory.createTypeAliasDeclaration(
|
|
70
|
+
[TypeScriptFactory.createToken(ts.SyntaxKind.ExportKeyword)],
|
|
70
71
|
key.split(".").at(-1)!,
|
|
71
72
|
[],
|
|
72
73
|
NestiaMigrateSchemaProgrammer.write({
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TypeScriptFactory } from "@nestia/factory";
|
|
2
|
+
import { IdentifierFactory, LiteralFactory } from "@nestia/factory";
|
|
2
3
|
import { IHttpMigrateRoute } from "@typia/interface";
|
|
3
|
-
import ts from "
|
|
4
|
+
import ts from "../internal/ts";
|
|
4
5
|
import { OpenApi } from "typia";
|
|
5
6
|
|
|
6
7
|
import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
|
|
@@ -16,10 +17,10 @@ export namespace NestiaMigrateE2eFunctionProgrammer {
|
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
export const write = (ctx: IContext): ts.FunctionDeclaration =>
|
|
19
|
-
|
|
20
|
+
TypeScriptFactory.createFunctionDeclaration(
|
|
20
21
|
[
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
TypeScriptFactory.createModifier(ts.SyntaxKind.ExportKeyword),
|
|
23
|
+
TypeScriptFactory.createModifier(ts.SyntaxKind.AsyncKeyword),
|
|
23
24
|
],
|
|
24
25
|
undefined,
|
|
25
26
|
["test", "api", ...ctx.route.accessor].join("_"),
|
|
@@ -27,30 +28,30 @@ export namespace NestiaMigrateE2eFunctionProgrammer {
|
|
|
27
28
|
[
|
|
28
29
|
IdentifierFactory.parameter(
|
|
29
30
|
"connection",
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
TypeScriptFactory.createTypeReferenceNode(
|
|
32
|
+
TypeScriptFactory.createQualifiedName(
|
|
33
|
+
TypeScriptFactory.createIdentifier(
|
|
33
34
|
ctx.importer.external({
|
|
34
35
|
type: "default",
|
|
35
36
|
library: "@ORGANIZATION/PROJECT-api",
|
|
36
37
|
name: "api",
|
|
37
38
|
}),
|
|
38
39
|
),
|
|
39
|
-
|
|
40
|
+
TypeScriptFactory.createIdentifier("IConnection"),
|
|
40
41
|
),
|
|
41
42
|
),
|
|
42
43
|
),
|
|
43
44
|
],
|
|
44
45
|
undefined,
|
|
45
|
-
|
|
46
|
+
TypeScriptFactory.createBlock(writeBody(ctx), true),
|
|
46
47
|
);
|
|
47
48
|
|
|
48
49
|
export const writeBody = (ctx: IContext): ts.Statement[] => [
|
|
49
|
-
|
|
50
|
+
TypeScriptFactory.createVariableStatement(
|
|
50
51
|
[],
|
|
51
|
-
|
|
52
|
+
TypeScriptFactory.createVariableDeclarationList(
|
|
52
53
|
[
|
|
53
|
-
|
|
54
|
+
TypeScriptFactory.createVariableDeclaration(
|
|
54
55
|
"output",
|
|
55
56
|
undefined,
|
|
56
57
|
ctx.route.success
|
|
@@ -60,16 +61,16 @@ export namespace NestiaMigrateE2eFunctionProgrammer {
|
|
|
60
61
|
schema: ctx.route.success.schema,
|
|
61
62
|
})
|
|
62
63
|
: undefined,
|
|
63
|
-
|
|
64
|
+
TypeScriptFactory.createAwaitExpression(writeCallExpressionn(ctx)),
|
|
64
65
|
),
|
|
65
66
|
],
|
|
66
67
|
ts.NodeFlags.Const,
|
|
67
68
|
),
|
|
68
69
|
),
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
TypeScriptFactory.createExpressionStatement(
|
|
71
|
+
TypeScriptFactory.createCallExpression(
|
|
72
|
+
TypeScriptFactory.createPropertyAccessExpression(
|
|
73
|
+
TypeScriptFactory.createIdentifier(
|
|
73
74
|
ctx.importer.external({
|
|
74
75
|
type: "default",
|
|
75
76
|
library: "typia",
|
|
@@ -79,26 +80,28 @@ export namespace NestiaMigrateE2eFunctionProgrammer {
|
|
|
79
80
|
"assert",
|
|
80
81
|
),
|
|
81
82
|
undefined,
|
|
82
|
-
[
|
|
83
|
+
[TypeScriptFactory.createIdentifier("output")],
|
|
83
84
|
),
|
|
84
85
|
),
|
|
85
86
|
];
|
|
86
87
|
|
|
87
88
|
const writeCallExpressionn = (ctx: IContext): ts.CallExpression => {
|
|
88
|
-
const fetch =
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
const fetch = TypeScriptFactory.createPropertyAccessExpression(
|
|
90
|
+
TypeScriptFactory.createIdentifier("api.functional"),
|
|
91
|
+
TypeScriptFactory.createIdentifier(ctx.route.accessor.join(".")),
|
|
91
92
|
);
|
|
92
|
-
const connection =
|
|
93
|
+
const connection = TypeScriptFactory.createIdentifier("connection");
|
|
93
94
|
if (
|
|
94
95
|
ctx.route.parameters.length === 0 &&
|
|
95
96
|
ctx.route.query === null &&
|
|
96
97
|
ctx.route.body === null
|
|
97
98
|
)
|
|
98
|
-
return
|
|
99
|
+
return TypeScriptFactory.createCallExpression(fetch, undefined, [
|
|
100
|
+
connection,
|
|
101
|
+
]);
|
|
99
102
|
|
|
100
|
-
const random =
|
|
101
|
-
|
|
103
|
+
const random = TypeScriptFactory.createPropertyAccessExpression(
|
|
104
|
+
TypeScriptFactory.createIdentifier(
|
|
102
105
|
ctx.importer.external({
|
|
103
106
|
type: "default",
|
|
104
107
|
library: "typia",
|
|
@@ -108,7 +111,7 @@ export namespace NestiaMigrateE2eFunctionProgrammer {
|
|
|
108
111
|
"random",
|
|
109
112
|
);
|
|
110
113
|
if (ctx.config.keyword === true)
|
|
111
|
-
return
|
|
114
|
+
return TypeScriptFactory.createCallExpression(fetch, undefined, [
|
|
112
115
|
connection,
|
|
113
116
|
LiteralFactory.write(
|
|
114
117
|
Object.fromEntries(
|
|
@@ -116,7 +119,7 @@ export namespace NestiaMigrateE2eFunctionProgrammer {
|
|
|
116
119
|
.filter((x) => x !== null)
|
|
117
120
|
.map(({ key, schema: value }) => [
|
|
118
121
|
key,
|
|
119
|
-
|
|
122
|
+
TypeScriptFactory.createCallExpression(
|
|
120
123
|
random,
|
|
121
124
|
[
|
|
122
125
|
NestiaMigrateSchemaProgrammer.write({
|
|
@@ -131,12 +134,12 @@ export namespace NestiaMigrateE2eFunctionProgrammer {
|
|
|
131
134
|
),
|
|
132
135
|
),
|
|
133
136
|
]);
|
|
134
|
-
return
|
|
137
|
+
return TypeScriptFactory.createCallExpression(fetch, undefined, [
|
|
135
138
|
connection,
|
|
136
139
|
...[...ctx.route.parameters, ctx.route.query, ctx.route.body]
|
|
137
140
|
.filter((p) => !!p)
|
|
138
141
|
.map((p) =>
|
|
139
|
-
|
|
142
|
+
TypeScriptFactory.createCallExpression(
|
|
140
143
|
random,
|
|
141
144
|
[
|
|
142
145
|
NestiaMigrateSchemaProgrammer.write({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IHttpMigrateRoute, OpenApi } from "@typia/interface";
|
|
2
|
-
import ts from "
|
|
2
|
+
import ts from "../internal/ts";
|
|
3
3
|
|
|
4
4
|
import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
|
|
5
5
|
import { INestiaMigrateContext } from "../structures/INestiaMigrateContext";
|