@nestia/migrate 11.3.0 → 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.
Files changed (98) hide show
  1. package/lib/bundles/NEST_TEMPLATE.js +2 -2
  2. package/lib/bundles/NEST_TEMPLATE.js.map +1 -1
  3. package/lib/bundles/SDK_TEMPLATE.js +1 -1
  4. package/lib/bundles/SDK_TEMPLATE.js.map +1 -1
  5. package/lib/factories/ExpressionFactory.d.ts +9 -0
  6. package/lib/factories/ExpressionFactory.js +16 -0
  7. package/lib/factories/ExpressionFactory.js.map +1 -0
  8. package/lib/factories/IdentifierFactory.d.ts +11 -0
  9. package/lib/factories/IdentifierFactory.js +36 -0
  10. package/lib/factories/IdentifierFactory.js.map +1 -0
  11. package/lib/factories/LiteralFactory.d.ts +9 -0
  12. package/lib/factories/LiteralFactory.js +52 -0
  13. package/lib/factories/LiteralFactory.js.map +1 -0
  14. package/lib/factories/StatementFactory.d.ts +12 -0
  15. package/lib/factories/StatementFactory.js +20 -0
  16. package/lib/factories/StatementFactory.js.map +1 -0
  17. package/lib/factories/TypeFactory.d.ts +8 -0
  18. package/lib/factories/TypeFactory.js +25 -0
  19. package/lib/factories/TypeFactory.js.map +1 -0
  20. package/lib/factories/TypeLiteralFactory.d.ts +2 -2
  21. package/lib/factories/TypeLiteralFactory.js +12 -15
  22. package/lib/factories/TypeLiteralFactory.js.map +1 -1
  23. package/lib/factories/index.d.ts +5 -0
  24. package/lib/factories/index.js +22 -0
  25. package/lib/factories/index.js.map +1 -0
  26. package/lib/index.mjs +171 -126
  27. package/lib/index.mjs.map +1 -1
  28. package/lib/programmers/NestiaMigrateApiFileProgrammer.d.ts +2 -2
  29. package/lib/programmers/NestiaMigrateApiFileProgrammer.js +2 -5
  30. package/lib/programmers/NestiaMigrateApiFileProgrammer.js.map +1 -1
  31. package/lib/programmers/NestiaMigrateApiFunctionProgrammer.d.ts +3 -3
  32. package/lib/programmers/NestiaMigrateApiFunctionProgrammer.js +45 -48
  33. package/lib/programmers/NestiaMigrateApiFunctionProgrammer.js.map +1 -1
  34. package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.d.ts +3 -3
  35. package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.js +59 -62
  36. package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.js.map +1 -1
  37. package/lib/programmers/NestiaMigrateApiProgrammer.js +2 -5
  38. package/lib/programmers/NestiaMigrateApiProgrammer.js.map +1 -1
  39. package/lib/programmers/NestiaMigrateApiSimulationProgrammer.d.ts +3 -3
  40. package/lib/programmers/NestiaMigrateApiSimulationProgrammer.js +36 -39
  41. package/lib/programmers/NestiaMigrateApiSimulationProgrammer.js.map +1 -1
  42. package/lib/programmers/NestiaMigrateApiStartProgrammer.js +20 -23
  43. package/lib/programmers/NestiaMigrateApiStartProgrammer.js.map +1 -1
  44. package/lib/programmers/NestiaMigrateDtoProgrammer.d.ts +2 -2
  45. package/lib/programmers/NestiaMigrateDtoProgrammer.js +2 -5
  46. package/lib/programmers/NestiaMigrateDtoProgrammer.js.map +1 -1
  47. package/lib/programmers/NestiaMigrateE2eFileProgrammer.d.ts +3 -3
  48. package/lib/programmers/NestiaMigrateE2eFileProgrammer.js +23 -26
  49. package/lib/programmers/NestiaMigrateE2eFileProgrammer.js.map +1 -1
  50. package/lib/programmers/NestiaMigrateE2eProgrammer.js.map +1 -1
  51. package/lib/programmers/NestiaMigrateImportProgrammer.d.ts +4 -4
  52. package/lib/programmers/NestiaMigrateImportProgrammer.js +11 -14
  53. package/lib/programmers/NestiaMigrateImportProgrammer.js.map +1 -1
  54. package/lib/programmers/NestiaMigrateNestControllerProgrammer.d.ts +2 -2
  55. package/lib/programmers/NestiaMigrateNestControllerProgrammer.js +5 -8
  56. package/lib/programmers/NestiaMigrateNestControllerProgrammer.js.map +1 -1
  57. package/lib/programmers/NestiaMigrateNestMethodProgrammer.d.ts +2 -2
  58. package/lib/programmers/NestiaMigrateNestMethodProgrammer.js +32 -37
  59. package/lib/programmers/NestiaMigrateNestMethodProgrammer.js.map +1 -1
  60. package/lib/programmers/NestiaMigrateNestModuleProgrammer.d.ts +2 -2
  61. package/lib/programmers/NestiaMigrateNestModuleProgrammer.js +9 -12
  62. package/lib/programmers/NestiaMigrateNestModuleProgrammer.js.map +1 -1
  63. package/lib/programmers/NestiaMigrateNestProgrammer.js +2 -5
  64. package/lib/programmers/NestiaMigrateNestProgrammer.js.map +1 -1
  65. package/lib/programmers/NestiaMigrateSchemaProgrammer.d.ts +2 -2
  66. package/lib/programmers/NestiaMigrateSchemaProgrammer.js +44 -43
  67. package/lib/programmers/NestiaMigrateSchemaProgrammer.js.map +1 -1
  68. package/lib/structures/INestiaMigrateConfig.d.ts +2 -2
  69. package/lib/utils/FilePrinter.d.ts +4 -4
  70. package/lib/utils/FilePrinter.js +9 -11
  71. package/lib/utils/FilePrinter.js.map +1 -1
  72. package/package.json +8 -7
  73. package/src/bundles/NEST_TEMPLATE.ts +2 -2
  74. package/src/bundles/SDK_TEMPLATE.ts +1 -1
  75. package/src/factories/ExpressionFactory.ts +30 -0
  76. package/src/factories/IdentifierFactory.ts +69 -0
  77. package/src/factories/LiteralFactory.ts +61 -0
  78. package/src/factories/StatementFactory.ts +40 -0
  79. package/src/factories/TypeFactory.ts +33 -0
  80. package/src/factories/TypeLiteralFactory.ts +17 -17
  81. package/src/factories/index.ts +5 -0
  82. package/src/programmers/NestiaMigrateApiFileProgrammer.ts +6 -7
  83. package/src/programmers/NestiaMigrateApiFunctionProgrammer.ts +81 -74
  84. package/src/programmers/NestiaMigrateApiNamespaceProgrammer.ts +143 -142
  85. package/src/programmers/NestiaMigrateApiProgrammer.ts +11 -11
  86. package/src/programmers/NestiaMigrateApiSimulationProgrammer.ts +71 -66
  87. package/src/programmers/NestiaMigrateApiStartProgrammer.ts +58 -52
  88. package/src/programmers/NestiaMigrateDtoProgrammer.ts +5 -5
  89. package/src/programmers/NestiaMigrateE2eFileProgrammer.ts +41 -34
  90. package/src/programmers/NestiaMigrateE2eProgrammer.ts +8 -9
  91. package/src/programmers/NestiaMigrateImportProgrammer.ts +22 -22
  92. package/src/programmers/NestiaMigrateNestControllerProgrammer.ts +8 -8
  93. package/src/programmers/NestiaMigrateNestMethodProgrammer.ts +68 -68
  94. package/src/programmers/NestiaMigrateNestModuleProgrammer.ts +18 -20
  95. package/src/programmers/NestiaMigrateNestProgrammer.ts +14 -14
  96. package/src/programmers/NestiaMigrateSchemaProgrammer.ts +67 -59
  97. package/src/structures/INestiaMigrateConfig.ts +2 -2
  98. 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 "@typia/core";
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): ts.ModuleDeclaration => {
26
- const types: ts.TypeAliasDeclaration[] = writeTypes(ctx);
27
- return ts.factory.createModuleDeclaration(
28
- [ts.factory.createToken(ts.SyntaxKind.ExportKeyword)],
29
- ts.factory.createIdentifier(ctx.route.accessor.at(-1)!),
30
- ts.factory.createModuleBlock([
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
- ts.NodeFlags.Namespace,
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
- ts.factory.createCallExpression(
52
- ts.factory.createIdentifier(`${route.accessor.at(-1)!}.path`),
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
- ? [ts.factory.createIdentifier("props")]
67
+ ? [factory.createIdentifier("props")]
58
68
  : [...route.parameters, ...(route.query ? [route.query] : [])].map(
59
- (p) => ts.factory.createIdentifier(p.key),
69
+ (p) => factory.createIdentifier(p.key),
60
70
  ),
61
71
  );
62
72
 
63
- const writeTypes = (ctx: IContext): ts.TypeAliasDeclaration[] => {
64
- const array: ts.TypeAliasDeclaration[] = [];
65
- const declare = (name: string, type: ts.TypeNode) =>
73
+ const writeTypes = (ctx: IContext): TypeAliasDeclaration[] => {
74
+ const array: TypeAliasDeclaration[] = [];
75
+ const declare = (name: string, type: TypeNode) =>
66
76
  array.push(
67
- ts.factory.createTypeAliasDeclaration(
68
- [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
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): ts.VariableStatement =>
174
+ const writeMetadata = (ctx: IContext): VariableStatement =>
165
175
  constant(
166
176
  "METADATA",
167
- ts.factory.createAsExpression(
168
- ts.factory.createObjectLiteralExpression(
177
+ factory.createAsExpression(
178
+ factory.createObjectLiteralExpression(
169
179
  [
170
- ts.factory.createPropertyAssignment(
180
+ factory.createPropertyAssignment(
171
181
  "method",
172
- ts.factory.createStringLiteral(ctx.route.method.toUpperCase()),
182
+ factory.createStringLiteral(ctx.route.method.toUpperCase()),
173
183
  ),
174
- ts.factory.createPropertyAssignment(
184
+ factory.createPropertyAssignment(
175
185
  "path",
176
- ts.factory.createStringLiteral(getPath(ctx.route)),
186
+ factory.createStringLiteral(getPath(ctx.route)),
177
187
  ),
178
- ts.factory.createPropertyAssignment(
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
- : ts.factory.createNull(),
195
+ : factory.createNull(),
186
196
  ),
187
- ts.factory.createPropertyAssignment(
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
- : ts.factory.createNull(),
204
+ : factory.createNull(),
195
205
  ),
196
206
  ...(ctx.route.success?.type === "application/x-www-form-urlencoded"
197
207
  ? [
198
- ts.factory.createPropertyAssignment(
208
+ factory.createPropertyAssignment(
199
209
  "parseQuery",
200
- ts.factory.createCallExpression(
201
- ts.factory.createIdentifier(
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
- ts.factory.createTypeReferenceNode(
224
- ts.factory.createIdentifier("const"),
225
- ),
233
+ factory.createTypeReferenceNode(factory.createIdentifier("const")),
226
234
  ),
227
235
  );
228
236
 
229
- const writePathFunction = (ctx: IContext): ts.VariableStatement => {
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(ts.factory.createIdentifier("props"), key)
235
- : ts.factory.createIdentifier(key);
236
- const out = (body: ts.ConciseBody) =>
242
+ ? IdentifierFactory.access(factory.createIdentifier("props"), key)
243
+ : factory.createIdentifier(key);
244
+ const out = (body: Block | Expression) =>
237
245
  constant(
238
246
  "path",
239
- ts.factory.createArrowFunction(
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
- ? ts.factory.createTypeReferenceNode("Omit", [
250
- ts.factory.createTypeReferenceNode("Props"),
251
- ts.factory.createLiteralTypeNode(
252
- ts.factory.createStringLiteral(ctx.route.body.key),
257
+ ? factory.createTypeReferenceNode("Omit", [
258
+ factory.createTypeReferenceNode("Props"),
259
+ factory.createLiteralTypeNode(
260
+ factory.createStringLiteral(ctx.route.body.key),
253
261
  ),
254
262
  ])
255
- : ts.factory.createTypeReferenceNode("Props"),
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
- ts.factory.createTypeReferenceNode(
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 ts.factory.createStringLiteral(path);
289
- return ts.factory.createTemplateExpression(
290
- ts.factory.createTemplateHead(split[0]!),
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 ts.factory.createTemplateSpan(
294
- ts.factory.createCallExpression(
295
- ts.factory.createIdentifier("encodeURIComponent"),
301
+ return factory.createTemplateSpan(
302
+ factory.createCallExpression(
303
+ factory.createIdentifier("encodeURIComponent"),
296
304
  undefined,
297
305
  [
298
- ts.factory.createBinaryExpression(
306
+ factory.createBinaryExpression(
299
307
  property(
300
308
  ctx.route.parameters.find((p) => p.name === name)!.key,
301
309
  ),
302
- ts.factory.createToken(ts.SyntaxKind.QuestionQuestionToken),
303
- ts.factory.createStringLiteral("null"),
310
+ factory.createToken(SyntaxKind.QuestionQuestionToken),
311
+ factory.createStringLiteral("null"),
304
312
  ),
305
313
  ],
306
314
  ),
307
315
  (i !== arr.length - 1
308
- ? ts.factory.createTemplateMiddle
309
- : ts.factory.createTemplateTail)(s.substring(name.length)),
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
- ts.factory.createBlock(
330
+ factory.createBlock(
323
331
  [
324
332
  local({
325
333
  name: variables,
326
334
  type: "URLSearchParams",
327
- expression: ts.factory.createNewExpression(
328
- ts.factory.createIdentifier("URLSearchParams"),
335
+ expression: factory.createNewExpression(
336
+ factory.createIdentifier("URLSearchParams"),
329
337
  [],
330
338
  [],
331
339
  ),
332
340
  }),
333
- ts.factory.createForOfStatement(
341
+ factory.createForOfStatement(
334
342
  undefined,
335
- ts.factory.createVariableDeclarationList(
343
+ factory.createVariableDeclarationList(
336
344
  [
337
- ts.factory.createVariableDeclaration(
338
- ts.factory.createArrayBindingPattern([
339
- ts.factory.createBindingElement(
345
+ factory.createVariableDeclaration(
346
+ factory.createArrayBindingPattern([
347
+ factory.createBindingElement(
340
348
  undefined,
341
349
  undefined,
342
- ts.factory.createIdentifier("key"),
350
+ factory.createIdentifier("key"),
343
351
  undefined,
344
352
  ),
345
- ts.factory.createBindingElement(
353
+ factory.createBindingElement(
346
354
  undefined,
347
355
  undefined,
348
- ts.factory.createIdentifier("value"),
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
- ts.NodeFlags.Const,
365
+ NodeFlags.Const,
358
366
  ),
359
- ts.factory.createCallExpression(
360
- ts.factory.createIdentifier("Object.entries"),
367
+ factory.createCallExpression(
368
+ factory.createIdentifier("Object.entries"),
361
369
  undefined,
362
370
  [
363
- ts.factory.createAsExpression(
371
+ factory.createAsExpression(
364
372
  property(ctx.route.query.key),
365
373
  TypeFactory.keyword("any"),
366
374
  ),
367
375
  ],
368
376
  ),
369
- ts.factory.createIfStatement(
370
- ts.factory.createStrictEquality(
371
- ts.factory.createIdentifier("undefined"),
372
- ts.factory.createIdentifier("value"),
377
+ factory.createIfStatement(
378
+ factory.createStrictEquality(
379
+ factory.createIdentifier("undefined"),
380
+ factory.createIdentifier("value"),
373
381
  ),
374
- ts.factory.createContinueStatement(),
375
- ts.factory.createIfStatement(
376
- ts.factory.createCallExpression(
377
- ts.factory.createIdentifier("Array.isArray"),
382
+ factory.createContinueStatement(),
383
+ factory.createIfStatement(
384
+ factory.createCallExpression(
385
+ factory.createIdentifier("Array.isArray"),
378
386
  undefined,
379
- [ts.factory.createIdentifier("value")],
387
+ [factory.createIdentifier("value")],
380
388
  ),
381
- ts.factory.createExpressionStatement(
382
- ts.factory.createCallExpression(
383
- ts.factory.createPropertyAccessExpression(
384
- ts.factory.createIdentifier("value"),
385
- ts.factory.createIdentifier("forEach"),
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
- ts.factory.createArrowFunction(
397
+ factory.createArrowFunction(
390
398
  undefined,
391
399
  undefined,
392
400
  [IdentifierFactory.parameter("elem")],
393
401
  undefined,
394
402
  undefined,
395
- ts.factory.createCallExpression(
403
+ factory.createCallExpression(
396
404
  IdentifierFactory.access(
397
- ts.factory.createIdentifier(variables),
405
+ factory.createIdentifier(variables),
398
406
  "append",
399
407
  ),
400
408
  undefined,
401
409
  [
402
- ts.factory.createIdentifier("key"),
403
- ts.factory.createCallExpression(
404
- ts.factory.createIdentifier("String"),
410
+ factory.createIdentifier("key"),
411
+ factory.createCallExpression(
412
+ factory.createIdentifier("String"),
405
413
  undefined,
406
- [ts.factory.createIdentifier("elem")],
414
+ [factory.createIdentifier("elem")],
407
415
  ),
408
416
  ],
409
417
  ),
@@ -411,19 +419,19 @@ export namespace NestiaMigrateApiNamespaceProgrammer {
411
419
  ],
412
420
  ),
413
421
  ),
414
- ts.factory.createExpressionStatement(
415
- ts.factory.createCallExpression(
422
+ factory.createExpressionStatement(
423
+ factory.createCallExpression(
416
424
  IdentifierFactory.access(
417
- ts.factory.createIdentifier(variables),
425
+ factory.createIdentifier(variables),
418
426
  "set",
419
427
  ),
420
428
  undefined,
421
429
  [
422
- ts.factory.createIdentifier("key"),
423
- ts.factory.createCallExpression(
424
- ts.factory.createIdentifier("String"),
430
+ factory.createIdentifier("key"),
431
+ factory.createCallExpression(
432
+ factory.createIdentifier("String"),
425
433
  undefined,
426
- [ts.factory.createIdentifier("value")],
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
- ts.factory.createReturnStatement(
440
- ts.factory.createConditionalExpression(
441
- ts.factory.createStrictEquality(
447
+ factory.createReturnStatement(
448
+ factory.createConditionalExpression(
449
+ factory.createStrictEquality(
442
450
  ExpressionFactory.number(0),
443
451
  IdentifierFactory.access(
444
- ts.factory.createIdentifier(variables),
452
+ factory.createIdentifier(variables),
445
453
  "size",
446
454
  ),
447
455
  ),
448
456
  undefined,
449
- ts.factory.createIdentifier("location"),
457
+ factory.createIdentifier("location"),
450
458
  undefined,
451
- ts.factory.createTemplateExpression(
452
- ts.factory.createTemplateHead(""),
453
- [
454
- ts.factory.createTemplateSpan(
455
- ts.factory.createIdentifier("location"),
456
- ts.factory.createTemplateMiddle("?"),
457
- ),
458
- ts.factory.createTemplateSpan(
459
- ts.factory.createCallExpression(
460
- IdentifierFactory.access(
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
- ts.factory.createTemplateTail(""),
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: ts.Expression) =>
481
- ts.factory.createVariableStatement(
482
- [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
483
- ts.factory.createVariableDeclarationList(
485
+ const constant = (name: string, expression: Expression) =>
486
+ factory.createVariableStatement(
487
+ [factory.createModifier(SyntaxKind.ExportKeyword)],
488
+ factory.createVariableDeclarationList(
484
489
  [
485
- ts.factory.createVariableDeclaration(
490
+ factory.createVariableDeclaration(
486
491
  name,
487
492
  undefined,
488
493
  undefined,
489
494
  expression,
490
495
  ),
491
496
  ],
492
- ts.NodeFlags.Const,
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
- name: string;
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
- ts.factory.createVariableDeclarationList(
507
+ factory.createVariableDeclarationList(
507
508
  [
508
- ts.factory.createVariableDeclaration(
509
+ factory.createVariableDeclaration(
509
510
  props.name,
510
511
  undefined,
511
- ts.factory.createTypeReferenceNode(props.type),
512
+ factory.createTypeReferenceNode(props.type),
512
513
  props.expression,
513
514
  ),
514
515
  ],
515
- ts.NodeFlags.Const,
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
- ): ts.Statement[] => {
74
+ ): Statement[] => {
75
75
  const importer = new NestiaMigrateImportProgrammer();
76
- const statements: ts.Statement[] = iterate(importer, modulo);
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
- ): ts.Statement[] => {
89
- const output: ts.Statement[] = [];
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: ts.Statement[] = [];
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
- ts.factory.createModuleDeclaration(
97
- [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
98
- ts.factory.createIdentifier(modulo.name),
99
- ts.factory.createModuleBlock(internal),
100
- ts.NodeFlags.Namespace,
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
  }