@nestia/migrate 11.3.0 → 11.3.2
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 +176 -127
- 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 +12 -3
- 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 +18 -8
- 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,13 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type Block,
|
|
3
|
+
type Expression,
|
|
4
|
+
type ModuleDeclaration,
|
|
5
|
+
NodeFlags,
|
|
6
|
+
SyntaxKind,
|
|
7
|
+
type TypeAliasDeclaration,
|
|
8
|
+
type TypeNode,
|
|
9
|
+
type VariableStatement,
|
|
10
|
+
factory,
|
|
11
|
+
} from "@ttsc/factory";
|
|
12
|
+
import { IHttpMigrateRoute } from "@typia/interface";
|
|
13
|
+
import { OpenApi } from "typia";
|
|
14
|
+
|
|
1
15
|
import {
|
|
2
16
|
ExpressionFactory,
|
|
3
17
|
IdentifierFactory,
|
|
4
18
|
LiteralFactory,
|
|
5
19
|
TypeFactory,
|
|
6
|
-
} from "
|
|
7
|
-
import { IHttpMigrateRoute } from "@typia/interface";
|
|
8
|
-
import ts from "typescript";
|
|
9
|
-
import { OpenApi } from "typia";
|
|
10
|
-
|
|
20
|
+
} from "../factories";
|
|
11
21
|
import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
|
|
12
22
|
import { FilePrinter } from "../utils/FilePrinter";
|
|
13
23
|
import { NestiaMigrateApiSimulationProgrammer } from "./NestiaMigrateApiSimulationProgrammer";
|
|
@@ -22,12 +32,12 @@ export namespace NestiaMigrateApiNamespaceProgrammer {
|
|
|
22
32
|
route: IHttpMigrateRoute;
|
|
23
33
|
}
|
|
24
34
|
|
|
25
|
-
export const write = (ctx: IContext):
|
|
26
|
-
const types:
|
|
27
|
-
return
|
|
28
|
-
[
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
export const write = (ctx: IContext): ModuleDeclaration => {
|
|
36
|
+
const types: TypeAliasDeclaration[] = writeTypes(ctx);
|
|
37
|
+
return factory.createModuleDeclaration(
|
|
38
|
+
[factory.createToken(SyntaxKind.ExportKeyword)],
|
|
39
|
+
factory.createIdentifier(ctx.route.accessor.at(-1)!),
|
|
40
|
+
factory.createModuleBlock([
|
|
31
41
|
...types,
|
|
32
42
|
...(types.length ? [FilePrinter.newLine()] : []),
|
|
33
43
|
writeMetadata(ctx),
|
|
@@ -40,7 +50,7 @@ export namespace NestiaMigrateApiNamespaceProgrammer {
|
|
|
40
50
|
]
|
|
41
51
|
: []),
|
|
42
52
|
]),
|
|
43
|
-
|
|
53
|
+
NodeFlags.Namespace,
|
|
44
54
|
);
|
|
45
55
|
};
|
|
46
56
|
|
|
@@ -48,24 +58,24 @@ export namespace NestiaMigrateApiNamespaceProgrammer {
|
|
|
48
58
|
config: INestiaMigrateConfig,
|
|
49
59
|
route: IHttpMigrateRoute,
|
|
50
60
|
) =>
|
|
51
|
-
|
|
52
|
-
|
|
61
|
+
factory.createCallExpression(
|
|
62
|
+
factory.createIdentifier(`${route.accessor.at(-1)!}.path`),
|
|
53
63
|
undefined,
|
|
54
64
|
route.parameters.length === 0 && route.query === null
|
|
55
65
|
? []
|
|
56
66
|
: config.keyword === true
|
|
57
|
-
? [
|
|
67
|
+
? [factory.createIdentifier("props")]
|
|
58
68
|
: [...route.parameters, ...(route.query ? [route.query] : [])].map(
|
|
59
|
-
(p) =>
|
|
69
|
+
(p) => factory.createIdentifier(p.key),
|
|
60
70
|
),
|
|
61
71
|
);
|
|
62
72
|
|
|
63
|
-
const writeTypes = (ctx: IContext):
|
|
64
|
-
const array:
|
|
65
|
-
const declare = (name: string, type:
|
|
73
|
+
const writeTypes = (ctx: IContext): TypeAliasDeclaration[] => {
|
|
74
|
+
const array: TypeAliasDeclaration[] = [];
|
|
75
|
+
const declare = (name: string, type: TypeNode) =>
|
|
66
76
|
array.push(
|
|
67
|
-
|
|
68
|
-
[
|
|
77
|
+
factory.createTypeAliasDeclaration(
|
|
78
|
+
[factory.createModifier(SyntaxKind.ExportKeyword)],
|
|
69
79
|
name,
|
|
70
80
|
undefined,
|
|
71
81
|
type,
|
|
@@ -161,44 +171,44 @@ export namespace NestiaMigrateApiNamespaceProgrammer {
|
|
|
161
171
|
return array;
|
|
162
172
|
};
|
|
163
173
|
|
|
164
|
-
const writeMetadata = (ctx: IContext):
|
|
174
|
+
const writeMetadata = (ctx: IContext): VariableStatement =>
|
|
165
175
|
constant(
|
|
166
176
|
"METADATA",
|
|
167
|
-
|
|
168
|
-
|
|
177
|
+
factory.createAsExpression(
|
|
178
|
+
factory.createObjectLiteralExpression(
|
|
169
179
|
[
|
|
170
|
-
|
|
180
|
+
factory.createPropertyAssignment(
|
|
171
181
|
"method",
|
|
172
|
-
|
|
182
|
+
factory.createStringLiteral(ctx.route.method.toUpperCase()),
|
|
173
183
|
),
|
|
174
|
-
|
|
184
|
+
factory.createPropertyAssignment(
|
|
175
185
|
"path",
|
|
176
|
-
|
|
186
|
+
factory.createStringLiteral(getPath(ctx.route)),
|
|
177
187
|
),
|
|
178
|
-
|
|
188
|
+
factory.createPropertyAssignment(
|
|
179
189
|
"request",
|
|
180
190
|
ctx.route.body
|
|
181
191
|
? LiteralFactory.write({
|
|
182
192
|
type: ctx.route.body.type,
|
|
183
193
|
encrypted: !!ctx.route.body["x-nestia-encrypted"],
|
|
184
194
|
})
|
|
185
|
-
:
|
|
195
|
+
: factory.createNull(),
|
|
186
196
|
),
|
|
187
|
-
|
|
197
|
+
factory.createPropertyAssignment(
|
|
188
198
|
"response",
|
|
189
199
|
ctx.route.method.toUpperCase() !== "HEAD"
|
|
190
200
|
? LiteralFactory.write({
|
|
191
201
|
type: ctx.route.success?.type ?? "application/json",
|
|
192
202
|
encrypted: !!ctx.route.success?.["x-nestia-encrypted"],
|
|
193
203
|
})
|
|
194
|
-
:
|
|
204
|
+
: factory.createNull(),
|
|
195
205
|
),
|
|
196
206
|
...(ctx.route.success?.type === "application/x-www-form-urlencoded"
|
|
197
207
|
? [
|
|
198
|
-
|
|
208
|
+
factory.createPropertyAssignment(
|
|
199
209
|
"parseQuery",
|
|
200
|
-
|
|
201
|
-
|
|
210
|
+
factory.createCallExpression(
|
|
211
|
+
factory.createIdentifier(
|
|
202
212
|
`${ctx.importer.external({
|
|
203
213
|
type: "default",
|
|
204
214
|
library: "typia",
|
|
@@ -220,23 +230,21 @@ export namespace NestiaMigrateApiNamespaceProgrammer {
|
|
|
220
230
|
],
|
|
221
231
|
true,
|
|
222
232
|
),
|
|
223
|
-
|
|
224
|
-
ts.factory.createIdentifier("const"),
|
|
225
|
-
),
|
|
233
|
+
factory.createTypeReferenceNode(factory.createIdentifier("const")),
|
|
226
234
|
),
|
|
227
235
|
);
|
|
228
236
|
|
|
229
|
-
const writePathFunction = (ctx: IContext):
|
|
237
|
+
const writePathFunction = (ctx: IContext): VariableStatement => {
|
|
230
238
|
const empty: boolean =
|
|
231
239
|
ctx.route.parameters.length === 0 && ctx.route.query === null;
|
|
232
240
|
const property = (key: string) =>
|
|
233
241
|
ctx.config.keyword === true
|
|
234
|
-
? IdentifierFactory.access(
|
|
235
|
-
:
|
|
236
|
-
const out = (body:
|
|
242
|
+
? IdentifierFactory.access(factory.createIdentifier("props"), key)
|
|
243
|
+
: factory.createIdentifier(key);
|
|
244
|
+
const out = (body: Block | Expression) =>
|
|
237
245
|
constant(
|
|
238
246
|
"path",
|
|
239
|
-
|
|
247
|
+
factory.createArrowFunction(
|
|
240
248
|
[],
|
|
241
249
|
[],
|
|
242
250
|
empty
|
|
@@ -246,13 +254,13 @@ export namespace NestiaMigrateApiNamespaceProgrammer {
|
|
|
246
254
|
IdentifierFactory.parameter(
|
|
247
255
|
"props",
|
|
248
256
|
ctx.route.body
|
|
249
|
-
?
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
257
|
+
? factory.createTypeReferenceNode("Omit", [
|
|
258
|
+
factory.createTypeReferenceNode("Props"),
|
|
259
|
+
factory.createLiteralTypeNode(
|
|
260
|
+
factory.createStringLiteral(ctx.route.body.key),
|
|
253
261
|
),
|
|
254
262
|
])
|
|
255
|
-
:
|
|
263
|
+
: factory.createTypeReferenceNode("Props"),
|
|
256
264
|
),
|
|
257
265
|
]
|
|
258
266
|
: [
|
|
@@ -270,7 +278,7 @@ export namespace NestiaMigrateApiNamespaceProgrammer {
|
|
|
270
278
|
? [
|
|
271
279
|
IdentifierFactory.parameter(
|
|
272
280
|
ctx.route.query.key,
|
|
273
|
-
|
|
281
|
+
factory.createTypeReferenceNode(
|
|
274
282
|
`${ctx.route.accessor.at(-1)!}.Query`,
|
|
275
283
|
),
|
|
276
284
|
),
|
|
@@ -285,28 +293,28 @@ export namespace NestiaMigrateApiNamespaceProgrammer {
|
|
|
285
293
|
const template = () => {
|
|
286
294
|
const path: string = getPath(ctx.route);
|
|
287
295
|
const split: string[] = path.split(":");
|
|
288
|
-
if (split.length === 1) return
|
|
289
|
-
return
|
|
290
|
-
|
|
296
|
+
if (split.length === 1) return factory.createStringLiteral(path);
|
|
297
|
+
return factory.createTemplateExpression(
|
|
298
|
+
factory.createTemplateHead(split[0]!),
|
|
291
299
|
split.slice(1).map((s, i, arr) => {
|
|
292
300
|
const name: string = s.split("/")[0]!;
|
|
293
|
-
return
|
|
294
|
-
|
|
295
|
-
|
|
301
|
+
return factory.createTemplateSpan(
|
|
302
|
+
factory.createCallExpression(
|
|
303
|
+
factory.createIdentifier("encodeURIComponent"),
|
|
296
304
|
undefined,
|
|
297
305
|
[
|
|
298
|
-
|
|
306
|
+
factory.createBinaryExpression(
|
|
299
307
|
property(
|
|
300
308
|
ctx.route.parameters.find((p) => p.name === name)!.key,
|
|
301
309
|
),
|
|
302
|
-
|
|
303
|
-
|
|
310
|
+
factory.createToken(SyntaxKind.QuestionQuestionToken),
|
|
311
|
+
factory.createStringLiteral("null"),
|
|
304
312
|
),
|
|
305
313
|
],
|
|
306
314
|
),
|
|
307
315
|
(i !== arr.length - 1
|
|
308
|
-
?
|
|
309
|
-
:
|
|
316
|
+
? factory.createTemplateMiddle
|
|
317
|
+
: factory.createTemplateTail)(s.substring(name.length)),
|
|
310
318
|
);
|
|
311
319
|
}),
|
|
312
320
|
);
|
|
@@ -319,33 +327,33 @@ export namespace NestiaMigrateApiNamespaceProgrammer {
|
|
|
319
327
|
: str;
|
|
320
328
|
const variables: string = computeName("variables");
|
|
321
329
|
return out(
|
|
322
|
-
|
|
330
|
+
factory.createBlock(
|
|
323
331
|
[
|
|
324
332
|
local({
|
|
325
333
|
name: variables,
|
|
326
334
|
type: "URLSearchParams",
|
|
327
|
-
expression:
|
|
328
|
-
|
|
335
|
+
expression: factory.createNewExpression(
|
|
336
|
+
factory.createIdentifier("URLSearchParams"),
|
|
329
337
|
[],
|
|
330
338
|
[],
|
|
331
339
|
),
|
|
332
340
|
}),
|
|
333
|
-
|
|
341
|
+
factory.createForOfStatement(
|
|
334
342
|
undefined,
|
|
335
|
-
|
|
343
|
+
factory.createVariableDeclarationList(
|
|
336
344
|
[
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
345
|
+
factory.createVariableDeclaration(
|
|
346
|
+
factory.createArrayBindingPattern([
|
|
347
|
+
factory.createBindingElement(
|
|
340
348
|
undefined,
|
|
341
349
|
undefined,
|
|
342
|
-
|
|
350
|
+
factory.createIdentifier("key"),
|
|
343
351
|
undefined,
|
|
344
352
|
),
|
|
345
|
-
|
|
353
|
+
factory.createBindingElement(
|
|
346
354
|
undefined,
|
|
347
355
|
undefined,
|
|
348
|
-
|
|
356
|
+
factory.createIdentifier("value"),
|
|
349
357
|
undefined,
|
|
350
358
|
),
|
|
351
359
|
]),
|
|
@@ -354,56 +362,56 @@ export namespace NestiaMigrateApiNamespaceProgrammer {
|
|
|
354
362
|
undefined,
|
|
355
363
|
),
|
|
356
364
|
],
|
|
357
|
-
|
|
365
|
+
NodeFlags.Const,
|
|
358
366
|
),
|
|
359
|
-
|
|
360
|
-
|
|
367
|
+
factory.createCallExpression(
|
|
368
|
+
factory.createIdentifier("Object.entries"),
|
|
361
369
|
undefined,
|
|
362
370
|
[
|
|
363
|
-
|
|
371
|
+
factory.createAsExpression(
|
|
364
372
|
property(ctx.route.query.key),
|
|
365
373
|
TypeFactory.keyword("any"),
|
|
366
374
|
),
|
|
367
375
|
],
|
|
368
376
|
),
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
377
|
+
factory.createIfStatement(
|
|
378
|
+
factory.createStrictEquality(
|
|
379
|
+
factory.createIdentifier("undefined"),
|
|
380
|
+
factory.createIdentifier("value"),
|
|
373
381
|
),
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
382
|
+
factory.createContinueStatement(),
|
|
383
|
+
factory.createIfStatement(
|
|
384
|
+
factory.createCallExpression(
|
|
385
|
+
factory.createIdentifier("Array.isArray"),
|
|
378
386
|
undefined,
|
|
379
|
-
[
|
|
387
|
+
[factory.createIdentifier("value")],
|
|
380
388
|
),
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
389
|
+
factory.createExpressionStatement(
|
|
390
|
+
factory.createCallExpression(
|
|
391
|
+
factory.createPropertyAccessExpression(
|
|
392
|
+
factory.createIdentifier("value"),
|
|
393
|
+
factory.createIdentifier("forEach"),
|
|
386
394
|
),
|
|
387
395
|
undefined,
|
|
388
396
|
[
|
|
389
|
-
|
|
397
|
+
factory.createArrowFunction(
|
|
390
398
|
undefined,
|
|
391
399
|
undefined,
|
|
392
400
|
[IdentifierFactory.parameter("elem")],
|
|
393
401
|
undefined,
|
|
394
402
|
undefined,
|
|
395
|
-
|
|
403
|
+
factory.createCallExpression(
|
|
396
404
|
IdentifierFactory.access(
|
|
397
|
-
|
|
405
|
+
factory.createIdentifier(variables),
|
|
398
406
|
"append",
|
|
399
407
|
),
|
|
400
408
|
undefined,
|
|
401
409
|
[
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
410
|
+
factory.createIdentifier("key"),
|
|
411
|
+
factory.createCallExpression(
|
|
412
|
+
factory.createIdentifier("String"),
|
|
405
413
|
undefined,
|
|
406
|
-
[
|
|
414
|
+
[factory.createIdentifier("elem")],
|
|
407
415
|
),
|
|
408
416
|
],
|
|
409
417
|
),
|
|
@@ -411,19 +419,19 @@ export namespace NestiaMigrateApiNamespaceProgrammer {
|
|
|
411
419
|
],
|
|
412
420
|
),
|
|
413
421
|
),
|
|
414
|
-
|
|
415
|
-
|
|
422
|
+
factory.createExpressionStatement(
|
|
423
|
+
factory.createCallExpression(
|
|
416
424
|
IdentifierFactory.access(
|
|
417
|
-
|
|
425
|
+
factory.createIdentifier(variables),
|
|
418
426
|
"set",
|
|
419
427
|
),
|
|
420
428
|
undefined,
|
|
421
429
|
[
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
430
|
+
factory.createIdentifier("key"),
|
|
431
|
+
factory.createCallExpression(
|
|
432
|
+
factory.createIdentifier("String"),
|
|
425
433
|
undefined,
|
|
426
|
-
[
|
|
434
|
+
[factory.createIdentifier("value")],
|
|
427
435
|
),
|
|
428
436
|
],
|
|
429
437
|
),
|
|
@@ -436,38 +444,35 @@ export namespace NestiaMigrateApiNamespaceProgrammer {
|
|
|
436
444
|
type: "string",
|
|
437
445
|
expression: template(),
|
|
438
446
|
}),
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
447
|
+
factory.createReturnStatement(
|
|
448
|
+
factory.createConditionalExpression(
|
|
449
|
+
factory.createStrictEquality(
|
|
442
450
|
ExpressionFactory.number(0),
|
|
443
451
|
IdentifierFactory.access(
|
|
444
|
-
|
|
452
|
+
factory.createIdentifier(variables),
|
|
445
453
|
"size",
|
|
446
454
|
),
|
|
447
455
|
),
|
|
448
456
|
undefined,
|
|
449
|
-
|
|
457
|
+
factory.createIdentifier("location"),
|
|
450
458
|
undefined,
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
ts.factory.createIdentifier(variables),
|
|
462
|
-
"toString",
|
|
463
|
-
),
|
|
464
|
-
undefined,
|
|
465
|
-
undefined,
|
|
459
|
+
factory.createTemplateExpression(factory.createTemplateHead(""), [
|
|
460
|
+
factory.createTemplateSpan(
|
|
461
|
+
factory.createIdentifier("location"),
|
|
462
|
+
factory.createTemplateMiddle("?"),
|
|
463
|
+
),
|
|
464
|
+
factory.createTemplateSpan(
|
|
465
|
+
factory.createCallExpression(
|
|
466
|
+
IdentifierFactory.access(
|
|
467
|
+
factory.createIdentifier(variables),
|
|
468
|
+
"toString",
|
|
466
469
|
),
|
|
467
|
-
|
|
470
|
+
undefined,
|
|
471
|
+
undefined,
|
|
468
472
|
),
|
|
469
|
-
|
|
470
|
-
|
|
473
|
+
factory.createTemplateTail(""),
|
|
474
|
+
),
|
|
475
|
+
]),
|
|
471
476
|
),
|
|
472
477
|
),
|
|
473
478
|
],
|
|
@@ -477,41 +482,37 @@ export namespace NestiaMigrateApiNamespaceProgrammer {
|
|
|
477
482
|
};
|
|
478
483
|
}
|
|
479
484
|
|
|
480
|
-
const constant = (name: string, expression:
|
|
481
|
-
|
|
482
|
-
[
|
|
483
|
-
|
|
485
|
+
const constant = (name: string, expression: Expression) =>
|
|
486
|
+
factory.createVariableStatement(
|
|
487
|
+
[factory.createModifier(SyntaxKind.ExportKeyword)],
|
|
488
|
+
factory.createVariableDeclarationList(
|
|
484
489
|
[
|
|
485
|
-
|
|
490
|
+
factory.createVariableDeclaration(
|
|
486
491
|
name,
|
|
487
492
|
undefined,
|
|
488
493
|
undefined,
|
|
489
494
|
expression,
|
|
490
495
|
),
|
|
491
496
|
],
|
|
492
|
-
|
|
497
|
+
NodeFlags.Const,
|
|
493
498
|
),
|
|
494
499
|
);
|
|
495
500
|
|
|
496
501
|
const getPath = (route: IHttpMigrateRoute) =>
|
|
497
502
|
(route.emendedPath.startsWith("/") ? "" : "/") + route.emendedPath;
|
|
498
503
|
|
|
499
|
-
const local = (props: {
|
|
500
|
-
|
|
501
|
-
type: string;
|
|
502
|
-
expression: ts.Expression;
|
|
503
|
-
}) =>
|
|
504
|
-
ts.factory.createVariableStatement(
|
|
504
|
+
const local = (props: { name: string; type: string; expression: Expression }) =>
|
|
505
|
+
factory.createVariableStatement(
|
|
505
506
|
[],
|
|
506
|
-
|
|
507
|
+
factory.createVariableDeclarationList(
|
|
507
508
|
[
|
|
508
|
-
|
|
509
|
+
factory.createVariableDeclaration(
|
|
509
510
|
props.name,
|
|
510
511
|
undefined,
|
|
511
|
-
|
|
512
|
+
factory.createTypeReferenceNode(props.type),
|
|
512
513
|
props.expression,
|
|
513
514
|
),
|
|
514
515
|
],
|
|
515
|
-
|
|
516
|
+
NodeFlags.Const,
|
|
516
517
|
),
|
|
517
518
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { NodeFlags, type Statement, SyntaxKind, factory } from "@ttsc/factory";
|
|
1
2
|
import { HashMap, hash } from "tstl";
|
|
2
|
-
import ts from "typescript";
|
|
3
3
|
|
|
4
4
|
import { INestiaMigrateContext } from "../structures/INestiaMigrateContext";
|
|
5
5
|
import { FilePrinter } from "../utils/FilePrinter";
|
|
@@ -71,9 +71,9 @@ export namespace NestiaMigrateApiProgrammer {
|
|
|
71
71
|
const writeDtoFile = (
|
|
72
72
|
key: string,
|
|
73
73
|
modulo: NestiaMigrateDtoProgrammer.IModule,
|
|
74
|
-
):
|
|
74
|
+
): Statement[] => {
|
|
75
75
|
const importer = new NestiaMigrateImportProgrammer();
|
|
76
|
-
const statements:
|
|
76
|
+
const statements: Statement[] = iterate(importer, modulo);
|
|
77
77
|
if (statements.length === 0) return [];
|
|
78
78
|
return [
|
|
79
79
|
...importer.toStatements((name) => `./${name}`, key),
|
|
@@ -85,19 +85,19 @@ export namespace NestiaMigrateApiProgrammer {
|
|
|
85
85
|
const iterate = (
|
|
86
86
|
importer: NestiaMigrateImportProgrammer,
|
|
87
87
|
modulo: NestiaMigrateDtoProgrammer.IModule,
|
|
88
|
-
):
|
|
89
|
-
const output:
|
|
88
|
+
): Statement[] => {
|
|
89
|
+
const output: Statement[] = [];
|
|
90
90
|
if (modulo.programmer !== null) output.push(modulo.programmer(importer));
|
|
91
91
|
if (modulo.children.size !== 0) {
|
|
92
|
-
const internal:
|
|
92
|
+
const internal: Statement[] = [];
|
|
93
93
|
for (const child of modulo.children.values())
|
|
94
94
|
internal.push(...iterate(importer, child));
|
|
95
95
|
output.push(
|
|
96
|
-
|
|
97
|
-
[
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
factory.createModuleDeclaration(
|
|
97
|
+
[factory.createModifier(SyntaxKind.ExportKeyword)],
|
|
98
|
+
factory.createIdentifier(modulo.name),
|
|
99
|
+
factory.createModuleBlock(internal),
|
|
100
|
+
NodeFlags.Namespace,
|
|
101
101
|
),
|
|
102
102
|
);
|
|
103
103
|
}
|