@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.
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 +176 -127
  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 +12 -3
  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 +18 -8
  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,8 +1,15 @@
1
- import { IdentifierFactory, LiteralFactory } from "@typia/core";
1
+ import {
2
+ type CallExpression,
3
+ type FunctionDeclaration,
4
+ NodeFlags,
5
+ type Statement,
6
+ SyntaxKind,
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, LiteralFactory } from "../factories";
6
13
  import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
7
14
  import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
8
15
  import { NestiaMigrateSchemaProgrammer } from "./NestiaMigrateSchemaProgrammer";
@@ -15,11 +22,11 @@ export namespace NestiaMigrateE2eFunctionProgrammer {
15
22
  route: IHttpMigrateRoute;
16
23
  }
17
24
 
18
- export const write = (ctx: IContext): ts.FunctionDeclaration =>
19
- ts.factory.createFunctionDeclaration(
25
+ export const write = (ctx: IContext): FunctionDeclaration =>
26
+ factory.createFunctionDeclaration(
20
27
  [
21
- ts.factory.createModifier(ts.SyntaxKind.ExportKeyword),
22
- ts.factory.createModifier(ts.SyntaxKind.AsyncKeyword),
28
+ factory.createModifier(SyntaxKind.ExportKeyword),
29
+ factory.createModifier(SyntaxKind.AsyncKeyword),
23
30
  ],
24
31
  undefined,
25
32
  ["test", "api", ...ctx.route.accessor].join("_"),
@@ -27,30 +34,30 @@ export namespace NestiaMigrateE2eFunctionProgrammer {
27
34
  [
28
35
  IdentifierFactory.parameter(
29
36
  "connection",
30
- ts.factory.createTypeReferenceNode(
31
- ts.factory.createQualifiedName(
32
- ts.factory.createIdentifier(
37
+ factory.createTypeReferenceNode(
38
+ factory.createQualifiedName(
39
+ factory.createIdentifier(
33
40
  ctx.importer.external({
34
41
  type: "default",
35
42
  library: "@ORGANIZATION/PROJECT-api",
36
43
  name: "api",
37
44
  }),
38
45
  ),
39
- ts.factory.createIdentifier("IConnection"),
46
+ factory.createIdentifier("IConnection"),
40
47
  ),
41
48
  ),
42
49
  ),
43
50
  ],
44
51
  undefined,
45
- ts.factory.createBlock(writeBody(ctx), true),
52
+ factory.createBlock(writeBody(ctx), true),
46
53
  );
47
54
 
48
- export const writeBody = (ctx: IContext): ts.Statement[] => [
49
- ts.factory.createVariableStatement(
55
+ export const writeBody = (ctx: IContext): Statement[] => [
56
+ factory.createVariableStatement(
50
57
  [],
51
- ts.factory.createVariableDeclarationList(
58
+ factory.createVariableDeclarationList(
52
59
  [
53
- ts.factory.createVariableDeclaration(
60
+ factory.createVariableDeclaration(
54
61
  "output",
55
62
  undefined,
56
63
  ctx.route.success
@@ -60,16 +67,16 @@ export namespace NestiaMigrateE2eFunctionProgrammer {
60
67
  schema: ctx.route.success.schema,
61
68
  })
62
69
  : undefined,
63
- ts.factory.createAwaitExpression(writeCallExpressionn(ctx)),
70
+ factory.createAwaitExpression(writeCallExpressionn(ctx)),
64
71
  ),
65
72
  ],
66
- ts.NodeFlags.Const,
73
+ NodeFlags.Const,
67
74
  ),
68
75
  ),
69
- ts.factory.createExpressionStatement(
70
- ts.factory.createCallExpression(
71
- ts.factory.createPropertyAccessExpression(
72
- ts.factory.createIdentifier(
76
+ factory.createExpressionStatement(
77
+ factory.createCallExpression(
78
+ factory.createPropertyAccessExpression(
79
+ factory.createIdentifier(
73
80
  ctx.importer.external({
74
81
  type: "default",
75
82
  library: "typia",
@@ -79,26 +86,26 @@ export namespace NestiaMigrateE2eFunctionProgrammer {
79
86
  "assert",
80
87
  ),
81
88
  undefined,
82
- [ts.factory.createIdentifier("output")],
89
+ [factory.createIdentifier("output")],
83
90
  ),
84
91
  ),
85
92
  ];
86
93
 
87
- const writeCallExpressionn = (ctx: IContext): ts.CallExpression => {
88
- const fetch = ts.factory.createPropertyAccessExpression(
89
- ts.factory.createIdentifier("api.functional"),
90
- ts.factory.createIdentifier(ctx.route.accessor.join(".")),
94
+ const writeCallExpressionn = (ctx: IContext): CallExpression => {
95
+ const fetch = factory.createPropertyAccessExpression(
96
+ factory.createIdentifier("api.functional"),
97
+ factory.createIdentifier(ctx.route.accessor.join(".")),
91
98
  );
92
- const connection = ts.factory.createIdentifier("connection");
99
+ const connection = factory.createIdentifier("connection");
93
100
  if (
94
101
  ctx.route.parameters.length === 0 &&
95
102
  ctx.route.query === null &&
96
103
  ctx.route.body === null
97
104
  )
98
- return ts.factory.createCallExpression(fetch, undefined, [connection]);
105
+ return factory.createCallExpression(fetch, undefined, [connection]);
99
106
 
100
- const random = ts.factory.createPropertyAccessExpression(
101
- ts.factory.createIdentifier(
107
+ const random = factory.createPropertyAccessExpression(
108
+ factory.createIdentifier(
102
109
  ctx.importer.external({
103
110
  type: "default",
104
111
  library: "typia",
@@ -108,7 +115,7 @@ export namespace NestiaMigrateE2eFunctionProgrammer {
108
115
  "random",
109
116
  );
110
117
  if (ctx.config.keyword === true)
111
- return ts.factory.createCallExpression(fetch, undefined, [
118
+ return factory.createCallExpression(fetch, undefined, [
112
119
  connection,
113
120
  LiteralFactory.write(
114
121
  Object.fromEntries(
@@ -116,7 +123,7 @@ export namespace NestiaMigrateE2eFunctionProgrammer {
116
123
  .filter((x) => x !== null)
117
124
  .map(({ key, schema: value }) => [
118
125
  key,
119
- ts.factory.createCallExpression(
126
+ factory.createCallExpression(
120
127
  random,
121
128
  [
122
129
  NestiaMigrateSchemaProgrammer.write({
@@ -131,12 +138,12 @@ export namespace NestiaMigrateE2eFunctionProgrammer {
131
138
  ),
132
139
  ),
133
140
  ]);
134
- return ts.factory.createCallExpression(fetch, undefined, [
141
+ return factory.createCallExpression(fetch, undefined, [
135
142
  connection,
136
143
  ...[...ctx.route.parameters, ctx.route.query, ctx.route.body]
137
144
  .filter((p) => !!p)
138
145
  .map((p) =>
139
- ts.factory.createCallExpression(
146
+ factory.createCallExpression(
140
147
  random,
141
148
  [
142
149
  NestiaMigrateSchemaProgrammer.write({
@@ -1,5 +1,5 @@
1
+ import { type FunctionDeclaration, type Statement } from "@ttsc/factory";
1
2
  import { IHttpMigrateRoute, OpenApi } from "@typia/interface";
2
- import ts from "typescript";
3
3
 
4
4
  import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
5
5
  import { INestiaMigrateContext } from "../structures/INestiaMigrateContext";
@@ -25,14 +25,13 @@ export namespace NestiaMigrateE2eProgrammer {
25
25
  ): INestiaMigrateFile => {
26
26
  const importer: NestiaMigrateImportProgrammer =
27
27
  new NestiaMigrateImportProgrammer();
28
- const func: ts.FunctionDeclaration =
29
- NestiaMigrateE2eFunctionProgrammer.write({
30
- config,
31
- components,
32
- importer,
33
- route,
34
- });
35
- const statements: ts.Statement[] = [
28
+ const func: FunctionDeclaration = NestiaMigrateE2eFunctionProgrammer.write({
29
+ config,
30
+ components,
31
+ importer,
32
+ route,
33
+ });
34
+ const statements: Statement[] = [
36
35
  ...importer.toStatements(
37
36
  (name) => `@ORGANIZATION/PROJECT-api/lib/structures/${name}`,
38
37
  ),
@@ -1,4 +1,4 @@
1
- import ts from "typescript";
1
+ import { type Statement, type TypeReferenceNode, factory } from "@ttsc/factory";
2
2
 
3
3
  import { TypeLiteralFactory } from "../factories/TypeLiteralFactory";
4
4
  import { FilePrinter } from "../utils/FilePrinter";
@@ -25,26 +25,26 @@ export class NestiaMigrateImportProgrammer {
25
25
  return name;
26
26
  }
27
27
 
28
- public dto(name: string, namespace?: string): ts.TypeReferenceNode {
28
+ public dto(name: string, namespace?: string): TypeReferenceNode {
29
29
  const file: string = name.split(".")[0]!;
30
30
  this.dtos_.add(file);
31
- return ts.factory.createTypeReferenceNode(
31
+ return factory.createTypeReferenceNode(
32
32
  namespace?.length
33
- ? ts.factory.createQualifiedName(
34
- ts.factory.createIdentifier(namespace),
35
- ts.factory.createIdentifier(file),
33
+ ? factory.createQualifiedName(
34
+ factory.createIdentifier(namespace),
35
+ factory.createIdentifier(file),
36
36
  )
37
37
  : name,
38
38
  );
39
39
  }
40
40
 
41
- public tag(type: string, arg?: any): ts.TypeReferenceNode {
41
+ public tag(type: string, arg?: any): TypeReferenceNode {
42
42
  const instance: string = this.external({
43
43
  type: "instance",
44
44
  library: "typia",
45
45
  name: "tags",
46
46
  });
47
- return ts.factory.createTypeReferenceNode(
47
+ return factory.createTypeReferenceNode(
48
48
  `${instance}.${type}`,
49
49
  arg === undefined ? [] : [TypeLiteralFactory.generate(arg)],
50
50
  );
@@ -53,29 +53,29 @@ export class NestiaMigrateImportProgrammer {
53
53
  public toStatements(
54
54
  dtoPath: (name: string) => string,
55
55
  current?: string,
56
- ): ts.Statement[] {
56
+ ): Statement[] {
57
57
  return [
58
58
  ...[...this.external_.entries()].map(([library, props]) =>
59
- ts.factory.createImportDeclaration(
59
+ factory.createImportDeclaration(
60
60
  undefined,
61
- ts.factory.createImportClause(
61
+ factory.createImportClause(
62
62
  false,
63
63
  props.default !== null
64
- ? ts.factory.createIdentifier(props.default)
64
+ ? factory.createIdentifier(props.default)
65
65
  : undefined,
66
66
  props.instances.size
67
- ? ts.factory.createNamedImports(
67
+ ? factory.createNamedImports(
68
68
  [...props.instances].map((i) =>
69
- ts.factory.createImportSpecifier(
69
+ factory.createImportSpecifier(
70
70
  false,
71
71
  undefined,
72
- ts.factory.createIdentifier(i),
72
+ factory.createIdentifier(i),
73
73
  ),
74
74
  ),
75
75
  )
76
76
  : undefined,
77
77
  ),
78
- ts.factory.createStringLiteral(library),
78
+ factory.createStringLiteral(library),
79
79
  ),
80
80
  ),
81
81
  ...(this.external_.size && this.dtos_.size
@@ -86,20 +86,20 @@ export class NestiaMigrateImportProgrammer {
86
86
  current ? (name) => name !== current!.split(".")[0] : () => true,
87
87
  )
88
88
  .map((i) =>
89
- ts.factory.createImportDeclaration(
89
+ factory.createImportDeclaration(
90
90
  undefined,
91
- ts.factory.createImportClause(
91
+ factory.createImportClause(
92
92
  false,
93
93
  undefined,
94
- ts.factory.createNamedImports([
95
- ts.factory.createImportSpecifier(
94
+ factory.createNamedImports([
95
+ factory.createImportSpecifier(
96
96
  false,
97
97
  undefined,
98
- ts.factory.createIdentifier(i),
98
+ factory.createIdentifier(i),
99
99
  ),
100
100
  ]),
101
101
  ),
102
- ts.factory.createStringLiteral(dtoPath(i)),
102
+ factory.createStringLiteral(dtoPath(i)),
103
103
  ),
104
104
  ),
105
105
  ];
@@ -1,5 +1,5 @@
1
+ import { type Statement, SyntaxKind, factory } from "@ttsc/factory";
1
2
  import { OpenApi } from "@typia/interface";
2
- import ts from "typescript";
3
3
 
4
4
  import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
5
5
  import { INestiaMigrateController } from "../structures/INestiaMigrateController";
@@ -15,14 +15,14 @@ export namespace NestiaMigrateNestControllerProgrammer {
15
15
  controller: INestiaMigrateController;
16
16
  }
17
17
 
18
- export const write = (props: IProps): ts.Statement[] => {
18
+ export const write = (props: IProps): Statement[] => {
19
19
  const importer: NestiaMigrateImportProgrammer =
20
20
  new NestiaMigrateImportProgrammer();
21
- const $class = ts.factory.createClassDeclaration(
21
+ const $class = factory.createClassDeclaration(
22
22
  [
23
- ts.factory.createDecorator(
24
- ts.factory.createCallExpression(
25
- ts.factory.createIdentifier(
23
+ factory.createDecorator(
24
+ factory.createCallExpression(
25
+ factory.createIdentifier(
26
26
  importer.external({
27
27
  type: "instance",
28
28
  library: "@nestjs/common",
@@ -30,10 +30,10 @@ export namespace NestiaMigrateNestControllerProgrammer {
30
30
  }),
31
31
  ),
32
32
  [],
33
- [ts.factory.createStringLiteral(props.controller.path)],
33
+ [factory.createStringLiteral(props.controller.path)],
34
34
  ),
35
35
  ),
36
- ts.factory.createToken(ts.SyntaxKind.ExportKeyword),
36
+ factory.createToken(SyntaxKind.ExportKeyword),
37
37
  ],
38
38
  props.controller.name,
39
39
  [],
@@ -1,13 +1,22 @@
1
+ import {
2
+ type Decorator,
3
+ type Expression,
4
+ type Identifier,
5
+ type MethodDeclaration,
6
+ type ParameterDeclaration,
7
+ SyntaxKind,
8
+ type TypeNode,
9
+ factory,
10
+ } from "@ttsc/factory";
11
+ import { IHttpMigrateRoute } from "@typia/interface";
12
+ import { OpenApi } from "typia";
13
+
1
14
  import {
2
15
  ExpressionFactory,
3
16
  IdentifierFactory,
4
17
  LiteralFactory,
5
18
  TypeFactory,
6
- } from "@typia/core";
7
- import { IHttpMigrateRoute } from "@typia/interface";
8
- import ts from "typescript";
9
- import { OpenApi } from "typia";
10
-
19
+ } from "../factories";
11
20
  import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
12
21
  import { INestiaMigrateController } from "../structures/INestiaMigrateController";
13
22
  import { FilePrinter } from "../utils/FilePrinter";
@@ -24,8 +33,8 @@ export namespace NestiaMigrateNestMethodProgrammer {
24
33
  route: IHttpMigrateRoute;
25
34
  }
26
35
 
27
- export const write = (ctx: IContext): ts.MethodDeclaration => {
28
- const output: ts.TypeNode = ctx.route.success
36
+ export const write = (ctx: IContext): MethodDeclaration => {
37
+ const output: TypeNode = ctx.route.success
29
38
  ? NestiaMigrateSchemaProgrammer.write({
30
39
  components: ctx.components,
31
40
  importer: ctx.importer,
@@ -33,19 +42,19 @@ export namespace NestiaMigrateNestMethodProgrammer {
33
42
  })
34
43
  : TypeFactory.keyword("void");
35
44
 
36
- const method: ts.MethodDeclaration = ts.factory.createMethodDeclaration(
45
+ const method: MethodDeclaration = factory.createMethodDeclaration(
37
46
  [
38
47
  ...writeMethodDecorators(ctx),
39
- ts.factory.createToken(ts.SyntaxKind.PublicKeyword),
40
- ts.factory.createToken(ts.SyntaxKind.AsyncKeyword),
48
+ factory.createToken(SyntaxKind.PublicKeyword),
49
+ factory.createToken(SyntaxKind.AsyncKeyword),
41
50
  ],
42
51
  undefined,
43
52
  ctx.route.accessor.at(-1)!,
44
53
  undefined,
45
54
  undefined,
46
55
  writeParameters(ctx),
47
- ts.factory.createTypeReferenceNode("Promise", [output]),
48
- ts.factory.createBlock(
56
+ factory.createTypeReferenceNode("Promise", [output]),
57
+ factory.createBlock(
49
58
  [
50
59
  ...[
51
60
  ...ctx.route.parameters.map((p) => p.key),
@@ -53,14 +62,12 @@ export namespace NestiaMigrateNestMethodProgrammer {
53
62
  ...(ctx.route.query ? ["query"] : []),
54
63
  ...(ctx.route.body ? ["body"] : []),
55
64
  ].map((str) =>
56
- ts.factory.createExpressionStatement(
57
- ts.factory.createIdentifier(str),
58
- ),
65
+ factory.createExpressionStatement(factory.createIdentifier(str)),
59
66
  ),
60
- ts.factory.createReturnStatement(
61
- ts.factory.createCallExpression(
67
+ factory.createReturnStatement(
68
+ factory.createCallExpression(
62
69
  IdentifierFactory.access(
63
- ts.factory.createIdentifier(
70
+ factory.createIdentifier(
64
71
  ctx.importer.external({
65
72
  type: "default",
66
73
  library: "typia",
@@ -92,9 +99,9 @@ export namespace NestiaMigrateNestMethodProgrammer {
92
99
  `@${config.author?.tag ?? "nestia"} ${config.author?.value ?? "Generated by Nestia - https://github.com/samchon/nestia"}`,
93
100
  ].join("\n");
94
101
 
95
- const writeMethodDecorators = (ctx: IContext): ts.Decorator[] => {
96
- const external = (lib: string, instance: string): ts.Identifier =>
97
- ts.factory.createIdentifier(
102
+ const writeMethodDecorators = (ctx: IContext): Decorator[] => {
103
+ const external = (lib: string, instance: string): Identifier =>
104
+ factory.createIdentifier(
98
105
  ctx.importer.external({
99
106
  type: "instance",
100
107
  library: lib,
@@ -103,7 +110,7 @@ export namespace NestiaMigrateNestMethodProgrammer {
103
110
  );
104
111
 
105
112
  // EXAMPLES
106
- const decorators: ts.Decorator[] = [];
113
+ const decorators: Decorator[] = [];
107
114
  if (ctx.route.success)
108
115
  decorators.push(
109
116
  ...writeExampleDecorators("Response")(ctx.importer)(
@@ -114,8 +121,8 @@ export namespace NestiaMigrateNestMethodProgrammer {
114
121
  // HUMAN-ONLY
115
122
  if (ctx.route.operation()["x-samchon-human"] === true)
116
123
  decorators.push(
117
- ts.factory.createDecorator(
118
- ts.factory.createCallExpression(
124
+ factory.createDecorator(
125
+ factory.createCallExpression(
119
126
  external("@nestia/core", "HumanRoute"),
120
127
  undefined,
121
128
  undefined,
@@ -130,15 +137,15 @@ export namespace NestiaMigrateNestMethodProgrammer {
130
137
  .filter((str) => !!str.length)
131
138
  .join("/");
132
139
  const router = (instance: string) =>
133
- ts.factory.createDecorator(
134
- ts.factory.createCallExpression(
140
+ factory.createDecorator(
141
+ factory.createCallExpression(
135
142
  IdentifierFactory.access(
136
143
  external("@nestia/core", instance),
137
144
  StringUtil.capitalize(ctx.route.method),
138
145
  ),
139
146
  [],
140
147
  localPath.length
141
- ? [ts.factory.createStringLiteral(localPath)]
148
+ ? [factory.createStringLiteral(localPath)]
142
149
  : undefined,
143
150
  ),
144
151
  );
@@ -146,11 +153,11 @@ export namespace NestiaMigrateNestMethodProgrammer {
146
153
  decorators.push(router("EncryptedRoute"));
147
154
  else if (ctx.route.success?.type === "text/plain")
148
155
  decorators.push(
149
- ts.factory.createDecorator(
150
- ts.factory.createCallExpression(
156
+ factory.createDecorator(
157
+ factory.createCallExpression(
151
158
  external("@nestjs/common", StringUtil.capitalize(ctx.route.method)),
152
159
  [],
153
- [ts.factory.createStringLiteral(ctx.route.path)],
160
+ [factory.createStringLiteral(ctx.route.path)],
154
161
  ),
155
162
  ),
156
163
  );
@@ -158,11 +165,11 @@ export namespace NestiaMigrateNestMethodProgrammer {
158
165
  decorators.push(router("TypedQuery"));
159
166
  else if (ctx.route.method === "head")
160
167
  decorators.push(
161
- ts.factory.createDecorator(
162
- ts.factory.createCallExpression(
168
+ factory.createDecorator(
169
+ factory.createCallExpression(
163
170
  external("@nestjs/common", "Head"),
164
171
  [],
165
- [ts.factory.createStringLiteral(ctx.route.path)],
172
+ [factory.createStringLiteral(ctx.route.path)],
166
173
  ),
167
174
  ),
168
175
  );
@@ -173,8 +180,8 @@ export namespace NestiaMigrateNestMethodProgrammer {
173
180
  decorators.push(router("TypedRoute"));
174
181
  for (const [key, value] of Object.entries(ctx.route.exceptions ?? {}))
175
182
  decorators.push(
176
- ts.factory.createDecorator(
177
- ts.factory.createCallExpression(
183
+ factory.createDecorator(
184
+ factory.createCallExpression(
178
185
  external("@nestia/core", "TypedException"),
179
186
  [
180
187
  NestiaMigrateSchemaProgrammer.write({
@@ -185,14 +192,10 @@ export namespace NestiaMigrateNestMethodProgrammer {
185
192
  ],
186
193
  [
187
194
  isNaN(Number(key))
188
- ? ts.factory.createStringLiteral(key)
195
+ ? factory.createStringLiteral(key)
189
196
  : ExpressionFactory.number(Number(key)),
190
197
  ...(value.response().description?.length
191
- ? [
192
- ts.factory.createStringLiteral(
193
- value.response().description!,
194
- ),
195
- ]
198
+ ? [factory.createStringLiteral(value.response().description!)]
196
199
  : []),
197
200
  ],
198
201
  ),
@@ -201,14 +204,14 @@ export namespace NestiaMigrateNestMethodProgrammer {
201
204
  return decorators;
202
205
  };
203
206
 
204
- const writeParameters = (ctx: IContext): ts.ParameterDeclaration[] => [
207
+ const writeParameters = (ctx: IContext): ParameterDeclaration[] => [
205
208
  ...ctx.route.parameters.map((p) =>
206
- ts.factory.createParameterDeclaration(
209
+ factory.createParameterDeclaration(
207
210
  [
208
211
  ...writeExampleDecorators("Parameter")(ctx.importer)(p.parameter()),
209
- ts.factory.createDecorator(
210
- ts.factory.createCallExpression(
211
- ts.factory.createIdentifier(
212
+ factory.createDecorator(
213
+ factory.createCallExpression(
214
+ factory.createIdentifier(
212
215
  ctx.importer.external({
213
216
  type: "instance",
214
217
  library: "@nestia/core",
@@ -216,7 +219,7 @@ export namespace NestiaMigrateNestMethodProgrammer {
216
219
  }),
217
220
  ),
218
221
  undefined,
219
- [ts.factory.createStringLiteral(p.key)],
222
+ [factory.createStringLiteral(p.key)],
220
223
  ),
221
224
  ),
222
225
  ],
@@ -276,14 +279,14 @@ export namespace NestiaMigrateNestMethodProgrammer {
276
279
  arguments:
277
280
  ctx.route.body.type === "multipart/form-data"
278
281
  ? [
279
- ts.factory.createArrowFunction(
282
+ factory.createArrowFunction(
280
283
  undefined,
281
284
  undefined,
282
285
  [],
283
286
  undefined,
284
287
  undefined,
285
- ts.factory.createCallExpression(
286
- ts.factory.createIdentifier(
288
+ factory.createCallExpression(
289
+ factory.createIdentifier(
287
290
  ctx.importer.external({
288
291
  type: "default",
289
292
  library: "multer",
@@ -314,7 +317,7 @@ export namespace NestiaMigrateNestMethodProgrammer {
314
317
  (accessor: {
315
318
  method: string | [string, string];
316
319
  variable: string;
317
- arguments: ts.Expression[];
320
+ arguments: Expression[];
318
321
  }) =>
319
322
  (components: OpenApi.IComponents) =>
320
323
  (importer: NestiaMigrateImportProgrammer) =>
@@ -323,8 +326,8 @@ export namespace NestiaMigrateNestMethodProgrammer {
323
326
  required: boolean;
324
327
  example?: any;
325
328
  examples?: Record<string, any>;
326
- }): ts.ParameterDeclaration => {
327
- const instance = ts.factory.createIdentifier(
329
+ }): ParameterDeclaration => {
330
+ const instance = factory.createIdentifier(
328
331
  importer.external({
329
332
  type: "instance",
330
333
  library: "@nestia/core",
@@ -334,11 +337,11 @@ export namespace NestiaMigrateNestMethodProgrammer {
334
337
  : accessor.method[0],
335
338
  }),
336
339
  );
337
- return ts.factory.createParameterDeclaration(
340
+ return factory.createParameterDeclaration(
338
341
  [
339
342
  ...writeExampleDecorators("Parameter")(importer)(props),
340
- ts.factory.createDecorator(
341
- ts.factory.createCallExpression(
343
+ factory.createDecorator(
344
+ factory.createCallExpression(
342
345
  typeof accessor.method === "string"
343
346
  ? instance
344
347
  : IdentifierFactory.access(instance, accessor.method[1]),
@@ -350,7 +353,7 @@ export namespace NestiaMigrateNestMethodProgrammer {
350
353
  undefined,
351
354
  accessor.variable,
352
355
  props.required === false
353
- ? ts.factory.createToken(ts.SyntaxKind.QuestionToken)
356
+ ? factory.createToken(SyntaxKind.QuestionToken)
354
357
  : undefined,
355
358
  NestiaMigrateSchemaProgrammer.write({
356
359
  components,
@@ -363,16 +366,13 @@ export namespace NestiaMigrateNestMethodProgrammer {
363
366
  const writeExampleDecorators =
364
367
  (kind: "Response" | "Parameter") =>
365
368
  (importer: NestiaMigrateImportProgrammer) =>
366
- (media: {
367
- example?: any;
368
- examples?: Record<string, any>;
369
- }): ts.Decorator[] => [
369
+ (media: { example?: any; examples?: Record<string, any> }): Decorator[] => [
370
370
  ...(media.example !== undefined
371
371
  ? [
372
- ts.factory.createDecorator(
373
- ts.factory.createCallExpression(
372
+ factory.createDecorator(
373
+ factory.createCallExpression(
374
374
  IdentifierFactory.access(
375
- ts.factory.createIdentifier(
375
+ factory.createIdentifier(
376
376
  importer.external({
377
377
  type: "instance",
378
378
  library: "@nestia/core",
@@ -388,10 +388,10 @@ export namespace NestiaMigrateNestMethodProgrammer {
388
388
  ]
389
389
  : []),
390
390
  ...Object.entries(media.examples ?? {}).map(([key, value]) =>
391
- ts.factory.createDecorator(
392
- ts.factory.createCallExpression(
391
+ factory.createDecorator(
392
+ factory.createCallExpression(
393
393
  IdentifierFactory.access(
394
- ts.factory.createIdentifier(
394
+ factory.createIdentifier(
395
395
  importer.external({
396
396
  type: "instance",
397
397
  library: "@nestia/core",
@@ -401,7 +401,7 @@ export namespace NestiaMigrateNestMethodProgrammer {
401
401
  kind,
402
402
  ),
403
403
  [],
404
- [ts.factory.createStringLiteral(key), LiteralFactory.write(value)],
404
+ [factory.createStringLiteral(key), LiteralFactory.write(value)],
405
405
  ),
406
406
  ),
407
407
  ),