@nestia/migrate 0.6.1 → 0.6.3

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 (86) hide show
  1. package/lib/IMigrateConfig.d.ts +3 -0
  2. package/lib/IMigrateConfig.js +3 -0
  3. package/lib/IMigrateConfig.js.map +1 -0
  4. package/lib/MigrateApplication.d.ts +4 -2
  5. package/lib/MigrateApplication.js +49 -29
  6. package/lib/MigrateApplication.js.map +1 -1
  7. package/lib/analyzers/ControllerAnalyzer.js +11 -2
  8. package/lib/analyzers/ControllerAnalyzer.js.map +1 -1
  9. package/lib/analyzers/MethodAnalyzer.js +18 -5
  10. package/lib/analyzers/MethodAnalyzer.js.map +1 -1
  11. package/lib/analyzers/MigrateAnalyzer.d.ts +2 -1
  12. package/lib/analyzers/MigrateAnalyzer.js +2 -1
  13. package/lib/analyzers/MigrateAnalyzer.js.map +1 -1
  14. package/lib/archivers/FileArchiver.d.ts +3 -3
  15. package/lib/archivers/FileArchiver.js +16 -7
  16. package/lib/archivers/FileArchiver.js.map +1 -1
  17. package/lib/executable/migrate.js +22 -10
  18. package/lib/executable/migrate.js.map +1 -1
  19. package/lib/internal/MigrateArguments.d.ts +8 -0
  20. package/lib/internal/MigrateArguments.js +67 -0
  21. package/lib/internal/MigrateArguments.js.map +1 -0
  22. package/lib/programmers/ApiFileProgrammer.d.ts +18 -0
  23. package/lib/programmers/ApiFileProgrammer.js +28 -0
  24. package/lib/programmers/ApiFileProgrammer.js.map +1 -0
  25. package/lib/programmers/ApiFunctionProgrammer.d.ts +15 -0
  26. package/lib/programmers/ApiFunctionProgrammer.js +96 -0
  27. package/lib/programmers/ApiFunctionProgrammer.js.map +1 -0
  28. package/lib/programmers/ApiNamespaceProgrammer.d.ts +15 -0
  29. package/lib/programmers/ApiNamespaceProgrammer.js +147 -0
  30. package/lib/programmers/ApiNamespaceProgrammer.js.map +1 -0
  31. package/lib/programmers/ApiProgrammer.d.ts +5 -0
  32. package/lib/programmers/ApiProgrammer.js +62 -0
  33. package/lib/programmers/ApiProgrammer.js.map +1 -0
  34. package/lib/programmers/ApiSimulatationProgrammer.d.ts +14 -0
  35. package/lib/programmers/ApiSimulatationProgrammer.js +127 -0
  36. package/lib/programmers/ApiSimulatationProgrammer.js.map +1 -0
  37. package/lib/programmers/DtoProgrammer.js +2 -2
  38. package/lib/programmers/DtoProgrammer.js.map +1 -1
  39. package/lib/programmers/ImportProgrammer.d.ts +2 -1
  40. package/lib/programmers/ImportProgrammer.js +19 -4
  41. package/lib/programmers/ImportProgrammer.js.map +1 -1
  42. package/lib/programmers/NestControllerProgrammer.js +2 -1
  43. package/lib/programmers/NestControllerProgrammer.js.map +1 -1
  44. package/lib/programmers/NestMethodProgrammer.js +33 -18
  45. package/lib/programmers/NestMethodProgrammer.js.map +1 -1
  46. package/lib/programmers/NestProgrammer.d.ts +1 -1
  47. package/lib/programmers/NestProgrammer.js +5 -5
  48. package/lib/programmers/NestProgrammer.js.map +1 -1
  49. package/lib/programmers/SchemaProgrammer.d.ts +1 -1
  50. package/lib/programmers/SchemaProgrammer.js +17 -17
  51. package/lib/programmers/SchemaProgrammer.js.map +1 -1
  52. package/lib/structures/IMigrateProgram.d.ts +2 -0
  53. package/lib/structures/IMigrateRoute.d.ts +13 -4
  54. package/lib/utils/SetupWizard.js +0 -3
  55. package/lib/utils/SetupWizard.js.map +1 -1
  56. package/lib/utils/StringUtil.d.ts +1 -0
  57. package/lib/utils/StringUtil.js +4 -2
  58. package/lib/utils/StringUtil.js.map +1 -1
  59. package/package.json +67 -64
  60. package/src/IMigrateConfig.ts +3 -0
  61. package/src/MigrateApplication.ts +42 -33
  62. package/src/analyzers/ControllerAnalyzer.ts +19 -3
  63. package/src/analyzers/MethodAnalyzer.ts +18 -5
  64. package/src/analyzers/MigrateAnalyzer.ts +8 -4
  65. package/src/archivers/FileArchiver.ts +10 -7
  66. package/src/executable/migrate.ts +15 -9
  67. package/src/internal/MigrateArguments.ts +74 -0
  68. package/src/programmers/ApiFileProgrammer.ts +53 -0
  69. package/src/programmers/ApiFunctionProgrammer.ts +204 -0
  70. package/src/programmers/ApiNamespaceProgrammer.ts +418 -0
  71. package/src/programmers/ApiProgrammer.ts +70 -0
  72. package/src/programmers/ApiSimulatationProgrammer.ts +328 -0
  73. package/src/programmers/DtoProgrammer.ts +3 -3
  74. package/src/programmers/ImportProgrammer.ts +37 -21
  75. package/src/programmers/NestControllerProgrammer.ts +2 -1
  76. package/src/programmers/NestMethodProgrammer.ts +39 -22
  77. package/src/programmers/NestProgrammer.ts +1 -1
  78. package/src/programmers/SchemaProgrammer.ts +22 -25
  79. package/src/structures/IMigrateProgram.ts +2 -0
  80. package/src/structures/IMigrateRoute.ts +13 -5
  81. package/src/utils/SetupWizard.ts +0 -3
  82. package/src/utils/StringUtil.ts +11 -2
  83. package/lib/analyzers/RouteAnalyzer.d.ts +0 -0
  84. package/lib/analyzers/RouteAnalyzer.js +0 -2
  85. package/lib/analyzers/RouteAnalyzer.js.map +0 -1
  86. package/src/analyzers/RouteAnalyzer.ts +0 -0
@@ -0,0 +1,328 @@
1
+ import ts from "typescript";
2
+ import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
3
+ import { StatementFactory } from "typia/lib/factories/StatementFactory";
4
+ import { TypeFactory } from "typia/lib/factories/TypeFactory";
5
+
6
+ import { IMigrateController } from "../structures/IMigrateController";
7
+ import { IMigrateRoute } from "../structures/IMigrateRoute";
8
+ import { ISwaggerComponents } from "../structures/ISwaggerComponents";
9
+ import { ApiFunctionProgrammer } from "./ApiFunctionProgrammer";
10
+ import { ApiNamespaceProgrammer } from "./ApiNamespaceProgrammer";
11
+ import { ImportProgrammer } from "./ImportProgrammer";
12
+ import { SchemaProgrammer } from "./SchemaProgrammer";
13
+
14
+ export namespace ApiSimulatationProgrammer {
15
+ export interface IProps {
16
+ controller: IMigrateController;
17
+ route: IMigrateRoute;
18
+ alias: string;
19
+ }
20
+ export const random =
21
+ (components: ISwaggerComponents) =>
22
+ (importer: ImportProgrammer) =>
23
+ (props: IProps) =>
24
+ constant("random")(
25
+ ts.factory.createArrowFunction(
26
+ undefined,
27
+ undefined,
28
+ [
29
+ ts.factory.createParameterDeclaration(
30
+ undefined,
31
+ undefined,
32
+ "g",
33
+ ts.factory.createToken(ts.SyntaxKind.QuestionToken),
34
+ ts.factory.createTypeReferenceNode(
35
+ ts.factory.createIdentifier("Partial"),
36
+ [
37
+ ts.factory.createTypeReferenceNode(
38
+ `${importer.external({
39
+ type: "default",
40
+ library: "typia",
41
+ name: "typia",
42
+ })}.IRandomGenerator`,
43
+ ),
44
+ ],
45
+ ),
46
+ ),
47
+ ],
48
+ undefined,
49
+ undefined,
50
+ ts.factory.createCallExpression(
51
+ IdentifierFactory.access(
52
+ ts.factory.createIdentifier(
53
+ importer.external({
54
+ type: "default",
55
+ library: "typia",
56
+ name: "typia",
57
+ }),
58
+ ),
59
+ )("random"),
60
+ [
61
+ props.route.success
62
+ ? SchemaProgrammer.write(components)(importer)(
63
+ props.route.success.schema,
64
+ )
65
+ : TypeFactory.keyword("void"),
66
+ ],
67
+ [ts.factory.createIdentifier("g")],
68
+ ),
69
+ ),
70
+ );
71
+
72
+ export const simulate =
73
+ (components: ISwaggerComponents) =>
74
+ (importer: ImportProgrammer) =>
75
+ (props: IProps): ts.VariableStatement => {
76
+ const caller = () =>
77
+ ts.factory.createCallExpression(
78
+ ts.factory.createIdentifier("random"),
79
+ undefined,
80
+ [
81
+ ts.factory.createConditionalExpression(
82
+ ts.factory.createLogicalAnd(
83
+ ts.factory.createStrictEquality(
84
+ ts.factory.createStringLiteral("object"),
85
+ ts.factory.createTypeOfExpression(
86
+ ts.factory.createIdentifier("connection.simulate"),
87
+ ),
88
+ ),
89
+ ts.factory.createStrictInequality(
90
+ ts.factory.createNull(),
91
+ ts.factory.createIdentifier("connection.simulate"),
92
+ ),
93
+ ),
94
+ undefined,
95
+ ts.factory.createIdentifier("connection.simulate"),
96
+ undefined,
97
+ ts.factory.createIdentifier("undefined"),
98
+ ),
99
+ ],
100
+ );
101
+ assert;
102
+ return constant("simulate")(
103
+ ts.factory.createArrowFunction(
104
+ undefined,
105
+ undefined,
106
+ ApiFunctionProgrammer.writeParameterDeclarations(components)(
107
+ importer,
108
+ )(props),
109
+ ts.factory.createTypeReferenceNode(
110
+ props.route.success ? "Output" : "void",
111
+ ),
112
+ undefined,
113
+ ts.factory.createBlock(
114
+ [
115
+ ...assert(components)(importer)(props),
116
+ ts.factory.createReturnStatement(caller()),
117
+ ],
118
+ true,
119
+ ),
120
+ ),
121
+ );
122
+ };
123
+
124
+ const assert =
125
+ (components: ISwaggerComponents) =>
126
+ (importer: ImportProgrammer) =>
127
+ (props: IProps): ts.Statement[] => {
128
+ const parameters = [
129
+ ...props.route.parameters.map((p) => ({
130
+ category: "param",
131
+ name: p.key,
132
+ schema: SchemaProgrammer.write(components)(importer)(p.schema),
133
+ })),
134
+ ...(props.route.query
135
+ ? [
136
+ {
137
+ category: "query",
138
+ name: props.route.query.key,
139
+ schema: SchemaProgrammer.write(components)(importer)(
140
+ props.route.query.schema,
141
+ ),
142
+ },
143
+ ]
144
+ : []),
145
+ ...(props.route.body
146
+ ? [
147
+ {
148
+ category: "body",
149
+ name: props.route.body.key,
150
+ schema: SchemaProgrammer.write(components)(importer)(
151
+ props.route.body.schema,
152
+ ),
153
+ },
154
+ ]
155
+ : []),
156
+ ];
157
+ if (parameters.length === 0) return [];
158
+
159
+ const validator = StatementFactory.constant(
160
+ "assert",
161
+ ts.factory.createCallExpression(
162
+ IdentifierFactory.access(
163
+ ts.factory.createIdentifier(
164
+ importer.external({
165
+ type: "instance",
166
+ library: `@nestia/fetcher/lib/NestiaSimulator`,
167
+ name: "NestiaSimulator",
168
+ }),
169
+ ),
170
+ )("assert"),
171
+ undefined,
172
+ [
173
+ ts.factory.createObjectLiteralExpression(
174
+ [
175
+ ts.factory.createPropertyAssignment(
176
+ "method",
177
+ ts.factory.createIdentifier("METADATA.method"),
178
+ ),
179
+ ts.factory.createPropertyAssignment(
180
+ "host",
181
+ ts.factory.createIdentifier("connection.host"),
182
+ ),
183
+ ts.factory.createPropertyAssignment(
184
+ "path",
185
+ ApiNamespaceProgrammer.writePathCallExpression(props),
186
+ ),
187
+ ts.factory.createPropertyAssignment(
188
+ "contentType",
189
+ ts.factory.createStringLiteral(
190
+ props.route.success?.type ?? "application/json",
191
+ ),
192
+ ),
193
+ ],
194
+ true,
195
+ ),
196
+ ],
197
+ ),
198
+ );
199
+ const individual = parameters
200
+ .map((p) =>
201
+ ts.factory.createCallExpression(
202
+ (() => {
203
+ const base = IdentifierFactory.access(
204
+ ts.factory.createIdentifier("assert"),
205
+ )(p.category);
206
+ if (p.category !== "param") return base;
207
+ return ts.factory.createCallExpression(base, undefined, [
208
+ ts.factory.createStringLiteral(p.name),
209
+ ]);
210
+ })(),
211
+ undefined,
212
+ [
213
+ ts.factory.createArrowFunction(
214
+ undefined,
215
+ undefined,
216
+ [],
217
+ undefined,
218
+ undefined,
219
+ ts.factory.createCallExpression(
220
+ IdentifierFactory.access(
221
+ ts.factory.createIdentifier(
222
+ importer.external({
223
+ type: "default",
224
+ library: "typia",
225
+ name: "typia",
226
+ }),
227
+ ),
228
+ )("assert"),
229
+ undefined,
230
+ [
231
+ ts.factory.createIdentifier(
232
+ p.category === "headers" ? "connection.headers" : p.name,
233
+ ),
234
+ ],
235
+ ),
236
+ ),
237
+ ],
238
+ ),
239
+ )
240
+ .map(ts.factory.createExpressionStatement);
241
+ return [validator, tryAndCatch(importer)(individual)];
242
+ };
243
+
244
+ const tryAndCatch =
245
+ (importer: ImportProgrammer) => (individual: ts.Statement[]) =>
246
+ ts.factory.createTryStatement(
247
+ ts.factory.createBlock(individual, true),
248
+ ts.factory.createCatchClause(
249
+ "exp",
250
+ ts.factory.createBlock(
251
+ [
252
+ ts.factory.createIfStatement(
253
+ ts.factory.createLogicalNot(
254
+ ts.factory.createCallExpression(
255
+ IdentifierFactory.access(
256
+ ts.factory.createIdentifier(
257
+ importer.external({
258
+ type: "default",
259
+ library: "typia",
260
+ name: "typia",
261
+ }),
262
+ ),
263
+ )("is"),
264
+ [
265
+ ts.factory.createTypeReferenceNode(
266
+ importer.external({
267
+ type: "instance",
268
+ library: "@nestia/Fetcher",
269
+ name: "HttpError",
270
+ }),
271
+ ),
272
+ ],
273
+ [ts.factory.createIdentifier("exp")],
274
+ ),
275
+ ),
276
+ ts.factory.createThrowStatement(
277
+ ts.factory.createIdentifier("exp"),
278
+ ),
279
+ ),
280
+ ts.factory.createReturnStatement(
281
+ ts.factory.createAsExpression(
282
+ ts.factory.createObjectLiteralExpression(
283
+ [
284
+ ts.factory.createPropertyAssignment(
285
+ "success",
286
+ ts.factory.createFalse(),
287
+ ),
288
+ ts.factory.createPropertyAssignment(
289
+ "status",
290
+ ts.factory.createIdentifier("exp.status"),
291
+ ),
292
+ ts.factory.createPropertyAssignment(
293
+ "headers",
294
+ ts.factory.createIdentifier("exp.headers"),
295
+ ),
296
+ ts.factory.createPropertyAssignment(
297
+ "data",
298
+ ts.factory.createIdentifier("exp.toJSON().message"),
299
+ ),
300
+ ],
301
+ true,
302
+ ),
303
+ TypeFactory.keyword("any"),
304
+ ),
305
+ ),
306
+ ],
307
+ true,
308
+ ),
309
+ ),
310
+ undefined,
311
+ );
312
+ }
313
+
314
+ const constant = (name: string) => (expression: ts.Expression) =>
315
+ ts.factory.createVariableStatement(
316
+ [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
317
+ ts.factory.createVariableDeclarationList(
318
+ [
319
+ ts.factory.createVariableDeclaration(
320
+ ts.factory.createIdentifier(name),
321
+ undefined,
322
+ undefined,
323
+ expression,
324
+ ),
325
+ ],
326
+ ts.NodeFlags.Const,
327
+ ),
328
+ );
@@ -23,7 +23,7 @@ export namespace DtoProgrammer {
23
23
  const dict: Map<string, IModule> = new Map();
24
24
  for (const [key, value] of Object.entries(components.schemas ?? {}))
25
25
  prepare(dict)(key)((importer) =>
26
- writeAlias(importer)(components)(key, value),
26
+ writeAlias(components)(importer)(key, value),
27
27
  );
28
28
  return dict;
29
29
  };
@@ -48,15 +48,15 @@ export namespace DtoProgrammer {
48
48
  };
49
49
 
50
50
  const writeAlias =
51
- (importer: ImportProgrammer) =>
52
51
  (components: ISwaggerComponents) =>
52
+ (importer: ImportProgrammer) =>
53
53
  (key: string, value: ISwaggerSchema) =>
54
54
  FilePrinter.description(
55
55
  ts.factory.createTypeAliasDeclaration(
56
56
  [ts.factory.createToken(ts.SyntaxKind.ExportKeyword)],
57
57
  key.split(".").at(-1)!,
58
58
  [],
59
- SchemaProgrammer.write(importer)(components)(value),
59
+ SchemaProgrammer.write(components)(importer)(value),
60
60
  ),
61
61
  writeComment(value),
62
62
  );
@@ -5,7 +5,13 @@ import { FilePrinter } from "../utils/FilePrinter";
5
5
  import { MapUtil } from "../utils/MapUtil";
6
6
 
7
7
  export class ImportProgrammer {
8
- private external_: Map<string, Set<string>> = new Map();
8
+ private external_: Map<
9
+ string,
10
+ {
11
+ default: string | null;
12
+ instances: Set<string>;
13
+ }
14
+ > = new Map();
9
15
  private dtos_: Set<string> = new Set();
10
16
 
11
17
  public constructor() {}
@@ -15,10 +21,14 @@ export class ImportProgrammer {
15
21
  }
16
22
 
17
23
  public external(props: ImportProgrammer.IProps): string {
18
- MapUtil.take(this.external_)(props.library)(() => new Set()).add(
19
- props.instance.split(".")[0],
20
- );
21
- return props.instance;
24
+ const element = MapUtil.take(this.external_)(props.library)(() => ({
25
+ default: null,
26
+ instances: new Set(),
27
+ }));
28
+ const name: string = props.name.split(".")[0];
29
+ if (props.type === "default") element.default = props.name;
30
+ else element.instances.add(name);
31
+ return name;
22
32
  }
23
33
 
24
34
  public dto(name: string): ts.TypeReferenceNode {
@@ -29,8 +39,9 @@ export class ImportProgrammer {
29
39
 
30
40
  public tag(type: string, arg: number | string): ts.TypeReferenceNode {
31
41
  this.external({
42
+ type: "instance",
32
43
  library: "typia",
33
- instance: "tags",
44
+ name: "tags",
34
45
  });
35
46
  return ts.factory.createTypeReferenceNode(`tags.${type}`, [
36
47
  ts.factory.createLiteralTypeNode(
@@ -46,25 +57,29 @@ export class ImportProgrammer {
46
57
  current?: string,
47
58
  ): ts.Statement[] {
48
59
  return [
49
- ...[...this.external_.entries()].map(([library, properties]) =>
50
- ts.factory.createImportDeclaration(
60
+ ...[...this.external_.entries()].map(([library, props]) => {
61
+ return ts.factory.createImportDeclaration(
51
62
  undefined,
52
63
  ts.factory.createImportClause(
53
64
  false,
54
- undefined,
55
- ts.factory.createNamedImports(
56
- [...properties].map((i) =>
57
- ts.factory.createImportSpecifier(
58
- false,
59
- undefined,
60
- ts.factory.createIdentifier(i),
61
- ),
62
- ),
63
- ),
65
+ props.default !== null
66
+ ? ts.factory.createIdentifier(props.default)
67
+ : undefined,
68
+ props.instances.size
69
+ ? ts.factory.createNamedImports(
70
+ [...props.instances].map((i) =>
71
+ ts.factory.createImportSpecifier(
72
+ false,
73
+ undefined,
74
+ ts.factory.createIdentifier(i),
75
+ ),
76
+ ),
77
+ )
78
+ : undefined,
64
79
  ),
65
80
  ts.factory.createStringLiteral(library),
66
- ),
67
- ),
81
+ );
82
+ }),
68
83
  ...(this.external_.size && this.dtos_.size ? [FilePrinter.enter()] : []),
69
84
  ...[...this.dtos_]
70
85
  .filter(
@@ -92,7 +107,8 @@ export class ImportProgrammer {
92
107
  }
93
108
  export namespace ImportProgrammer {
94
109
  export interface IProps {
110
+ type: "default" | "instance";
95
111
  library: string;
96
- instance: string;
112
+ name: string;
97
113
  }
98
114
  }
@@ -18,8 +18,9 @@ export namespace NestControllerProgrammer {
18
18
  ts.factory.createCallExpression(
19
19
  ts.factory.createIdentifier(
20
20
  importer.external({
21
+ type: "instance",
21
22
  library: "@nestjs/common",
22
- instance: "Controller",
23
+ name: "Controller",
23
24
  }),
24
25
  ),
25
26
  [],
@@ -17,7 +17,7 @@ export namespace NestMethodProgrammer {
17
17
  (importer: ImportProgrammer) =>
18
18
  (route: IMigrateRoute): ts.MethodDeclaration => {
19
19
  const output: ts.TypeNode = route.success
20
- ? SchemaProgrammer.write(importer)(components)(route.success.schema)
20
+ ? SchemaProgrammer.write(components)(importer)(route.success.schema)
21
21
  : TypeFactory.keyword("void");
22
22
 
23
23
  const method: ts.MethodDeclaration = ts.factory.createMethodDeclaration(
@@ -30,7 +30,7 @@ export namespace NestMethodProgrammer {
30
30
  route.name,
31
31
  undefined,
32
32
  undefined,
33
- writeParameters(importer)(components)(route),
33
+ writeParameters(components)(importer)(route),
34
34
  ts.factory.createTypeReferenceNode("Promise", [output]),
35
35
  ts.factory.createBlock(
36
36
  [
@@ -46,12 +46,15 @@ export namespace NestMethodProgrammer {
46
46
  ),
47
47
  ts.factory.createReturnStatement(
48
48
  ts.factory.createCallExpression(
49
- ts.factory.createIdentifier(
50
- importer.external({
51
- library: "typia",
52
- instance: "random",
53
- }),
54
- ),
49
+ IdentifierFactory.access(
50
+ ts.factory.createIdentifier(
51
+ importer.external({
52
+ type: "default",
53
+ library: "typia",
54
+ name: "typia",
55
+ }),
56
+ ),
57
+ )("random"),
55
58
  [output],
56
59
  undefined,
57
60
  ),
@@ -60,9 +63,17 @@ export namespace NestMethodProgrammer {
60
63
  true,
61
64
  ),
62
65
  );
63
- return FilePrinter.description(method, route.description ?? "");
66
+ return FilePrinter.description(method, writeDescription(route));
64
67
  };
65
68
 
69
+ const writeDescription = (method: IMigrateRoute): string =>
70
+ [
71
+ ...(method.description?.length ? [method.description.length, ""] : []),
72
+ ...(method.deprecated ? ["@deprecated"] : []),
73
+ ...method.tags.map((value) => `@tag ${value}`),
74
+ "@nestia Generated by Nestia - https://github.com/samchon/nestia",
75
+ ].join("\n");
76
+
66
77
  const writeMethodDecorators =
67
78
  (components: ISwaggerComponents) =>
68
79
  (importer: ImportProgrammer) =>
@@ -71,7 +82,11 @@ export namespace NestMethodProgrammer {
71
82
  (lib: string) =>
72
83
  (instance: string): ts.Identifier =>
73
84
  ts.factory.createIdentifier(
74
- importer.external({ library: lib, instance }),
85
+ importer.external({
86
+ type: "instance",
87
+ library: lib,
88
+ name: instance,
89
+ }),
75
90
  );
76
91
  const router = (instance: string) =>
77
92
  ts.factory.createDecorator(
@@ -116,7 +131,7 @@ export namespace NestMethodProgrammer {
116
131
  ts.factory.createDecorator(
117
132
  ts.factory.createCallExpression(
118
133
  external("@nestia/core")("TypedException"),
119
- [SchemaProgrammer.write(importer)(components)(value.schema)],
134
+ [SchemaProgrammer.write(components)(importer)(value.schema)],
120
135
  [
121
136
  isNaN(Number(key))
122
137
  ? ts.factory.createStringLiteral(key)
@@ -132,8 +147,8 @@ export namespace NestMethodProgrammer {
132
147
  };
133
148
 
134
149
  const writeParameters =
135
- (importer: ImportProgrammer) =>
136
150
  (components: ISwaggerComponents) =>
151
+ (importer: ImportProgrammer) =>
137
152
  (route: IMigrateRoute): ts.ParameterDeclaration[] => [
138
153
  ...route.parameters.map(({ key, schema: value }) =>
139
154
  ts.factory.createParameterDeclaration(
@@ -142,8 +157,9 @@ export namespace NestMethodProgrammer {
142
157
  ts.factory.createCallExpression(
143
158
  ts.factory.createIdentifier(
144
159
  importer.external({
160
+ type: "instance",
145
161
  library: "@nestia/core",
146
- instance: "TypedParam",
162
+ name: "TypedParam",
147
163
  }),
148
164
  ),
149
165
  undefined,
@@ -154,21 +170,21 @@ export namespace NestMethodProgrammer {
154
170
  undefined,
155
171
  StringUtil.normalize(key),
156
172
  undefined,
157
- SchemaProgrammer.write(importer)(components)(value),
173
+ SchemaProgrammer.write(components)(importer)(value),
158
174
  ),
159
175
  ),
160
176
  ...(route.headers
161
177
  ? [
162
178
  writeDtoParameter({ method: "TypedHeaders", variable: "headers" })(
163
- importer,
164
- )(components)(route.headers),
179
+ components,
180
+ )(importer)(route.headers.schema),
165
181
  ]
166
182
  : []),
167
183
  ...(route.query
168
184
  ? [
169
185
  writeDtoParameter({ method: "TypedQuery", variable: "query" })(
170
- importer,
171
- )(components)(route.query),
186
+ components,
187
+ )(importer)(route.query.schema),
172
188
  ]
173
189
  : []),
174
190
  ...(route.body
@@ -178,15 +194,15 @@ export namespace NestMethodProgrammer {
178
194
  ? "EncryptedBody"
179
195
  : "TypedBody",
180
196
  variable: "body",
181
- })(importer)(components)(route.body.schema),
197
+ })(components)(importer)(route.body.schema),
182
198
  ]
183
199
  : []),
184
200
  ];
185
201
 
186
202
  const writeDtoParameter =
187
203
  (accessor: { method: string; variable: string }) =>
188
- (importer: ImportProgrammer) =>
189
204
  (components: ISwaggerComponents) =>
205
+ (importer: ImportProgrammer) =>
190
206
  (schema: ISwaggerSchema): ts.ParameterDeclaration =>
191
207
  ts.factory.createParameterDeclaration(
192
208
  [
@@ -194,8 +210,9 @@ export namespace NestMethodProgrammer {
194
210
  ts.factory.createCallExpression(
195
211
  ts.factory.createIdentifier(
196
212
  importer.external({
213
+ type: "instance",
197
214
  library: "@nestia/core",
198
- instance: accessor.method,
215
+ name: accessor.method,
199
216
  }),
200
217
  ),
201
218
  undefined,
@@ -206,6 +223,6 @@ export namespace NestMethodProgrammer {
206
223
  undefined,
207
224
  StringUtil.normalize(accessor.variable),
208
225
  undefined,
209
- SchemaProgrammer.write(importer)(components)(schema),
226
+ SchemaProgrammer.write(components)(importer)(schema),
210
227
  );
211
228
  }
@@ -8,7 +8,7 @@ import { ImportProgrammer } from "./ImportProgrammer";
8
8
  import { NestControllerProgrammer } from "./NestControllerProgrammer";
9
9
  import { NestModuleProgrammer } from "./NestModuleProgrammer";
10
10
 
11
- export namespace MigrateProgrammer {
11
+ export namespace NestProgrammer {
12
12
  export const write = (program: IMigrateProgram): IMigrateFile[] =>
13
13
  [
14
14
  {