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