@nestia/migrate 7.0.0-dev.20250607 → 7.0.0

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 (54) hide show
  1. package/README.md +92 -92
  2. package/lib/analyzers/NestiaMigrateControllerAnalyzer.js +1 -1
  3. package/lib/analyzers/NestiaMigrateControllerAnalyzer.js.map +1 -1
  4. package/lib/bundles/NEST_TEMPLATE.js +47 -47
  5. package/lib/bundles/NEST_TEMPLATE.js.map +1 -1
  6. package/lib/bundles/SDK_TEMPLATE.js +21 -21
  7. package/lib/bundles/SDK_TEMPLATE.js.map +1 -1
  8. package/lib/index.mjs +70 -70
  9. package/lib/index.mjs.map +1 -1
  10. package/lib/programmers/NestiaMigrateApiProgrammer.js +1 -1
  11. package/lib/programmers/NestiaMigrateApiProgrammer.js.map +1 -1
  12. package/lib/utils/openapi-down-convert/converter.js +2 -2
  13. package/package.json +7 -7
  14. package/src/NestiaMigrateApplication.ts +144 -144
  15. package/src/analyzers/NestiaMigrateControllerAnalyzer.ts +51 -51
  16. package/src/archivers/NestiaMigrateFileArchiver.ts +28 -28
  17. package/src/bundles/NEST_TEMPLATE.ts +47 -47
  18. package/src/bundles/SDK_TEMPLATE.ts +21 -21
  19. package/src/executable/NestiaMigrateCommander.ts +98 -98
  20. package/src/executable/NestiaMigrateInquirer.ts +106 -106
  21. package/src/executable/bundle.js +129 -129
  22. package/src/executable/migrate.ts +7 -7
  23. package/src/factories/TypeLiteralFactory.ts +57 -57
  24. package/src/index.ts +4 -4
  25. package/src/module.ts +2 -2
  26. package/src/programmers/NestiaMigrateApiFileProgrammer.ts +55 -55
  27. package/src/programmers/NestiaMigrateApiFunctionProgrammer.ts +256 -256
  28. package/src/programmers/NestiaMigrateApiNamespaceProgrammer.ts +515 -515
  29. package/src/programmers/NestiaMigrateApiProgrammer.ts +107 -107
  30. package/src/programmers/NestiaMigrateApiSimulationProgrammer.ts +340 -340
  31. package/src/programmers/NestiaMigrateApiStartProgrammer.ts +198 -198
  32. package/src/programmers/NestiaMigrateDtoProgrammer.ts +101 -101
  33. package/src/programmers/NestiaMigrateE2eFileProgrammer.ts +153 -153
  34. package/src/programmers/NestiaMigrateE2eProgrammer.ts +46 -46
  35. package/src/programmers/NestiaMigrateImportProgrammer.ts +118 -118
  36. package/src/programmers/NestiaMigrateNestControllerProgrammer.ts +66 -66
  37. package/src/programmers/NestiaMigrateNestMethodProgrammer.ts +406 -406
  38. package/src/programmers/NestiaMigrateNestModuleProgrammer.ts +65 -65
  39. package/src/programmers/NestiaMigrateNestProgrammer.ts +88 -88
  40. package/src/programmers/NestiaMigrateSchemaProgrammer.ts +475 -475
  41. package/src/structures/INestiaMigrateConfig.ts +10 -10
  42. package/src/structures/INestiaMigrateContext.ts +15 -15
  43. package/src/structures/INestiaMigrateController.ts +8 -8
  44. package/src/structures/INestiaMigrateDto.ts +8 -8
  45. package/src/structures/INestiaMigrateFile.ts +5 -5
  46. package/src/structures/INestiaMigrateProgram.ts +11 -11
  47. package/src/structures/INestiaMigrateSchema.ts +4 -4
  48. package/src/utils/FilePrinter.ts +38 -38
  49. package/src/utils/MapUtil.ts +13 -13
  50. package/src/utils/OpenApiTypeChecker.ts +73 -73
  51. package/src/utils/SetupWizard.ts +12 -12
  52. package/src/utils/StringUtil.ts +113 -113
  53. package/src/utils/openapi-down-convert/RefVisitor.ts +139 -139
  54. package/src/utils/openapi-down-convert/converter.ts +527 -527
@@ -1,153 +1,153 @@
1
- import { IHttpMigrateRoute, OpenApi } from "@samchon/openapi";
2
- import ts from "typescript";
3
- import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
4
- import { LiteralFactory } from "typia/lib/factories/LiteralFactory";
5
-
6
- import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
7
- import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
8
- import { NestiaMigrateSchemaProgrammer } from "./NestiaMigrateSchemaProgrammer";
9
-
10
- export namespace NestiaMigrateE2eFunctionProgrammer {
11
- export interface IContext {
12
- config: INestiaMigrateConfig;
13
- components: OpenApi.IComponents;
14
- importer: NestiaMigrateImportProgrammer;
15
- route: IHttpMigrateRoute;
16
- }
17
-
18
- export const write = (ctx: IContext): ts.FunctionDeclaration =>
19
- ts.factory.createFunctionDeclaration(
20
- [
21
- ts.factory.createModifier(ts.SyntaxKind.ExportKeyword),
22
- ts.factory.createModifier(ts.SyntaxKind.AsyncKeyword),
23
- ],
24
- undefined,
25
- ["test", "api", ...ctx.route.accessor].join("_"),
26
- undefined,
27
- [
28
- IdentifierFactory.parameter(
29
- "connection",
30
- ts.factory.createTypeReferenceNode(
31
- ts.factory.createQualifiedName(
32
- ts.factory.createIdentifier(
33
- ctx.importer.external({
34
- type: "default",
35
- library: "@ORGANIZATION/PROJECT-api",
36
- name: "api",
37
- }),
38
- ),
39
- ts.factory.createIdentifier("IConnection"),
40
- ),
41
- ),
42
- ),
43
- ],
44
- undefined,
45
- ts.factory.createBlock(writeBody(ctx), true),
46
- );
47
-
48
- export const writeBody = (ctx: IContext): ts.Statement[] => [
49
- ts.factory.createVariableStatement(
50
- [],
51
- ts.factory.createVariableDeclarationList(
52
- [
53
- ts.factory.createVariableDeclaration(
54
- "output",
55
- undefined,
56
- ctx.route.success
57
- ? NestiaMigrateSchemaProgrammer.write({
58
- components: ctx.components,
59
- importer: ctx.importer,
60
- schema: ctx.route.success.schema,
61
- })
62
- : undefined,
63
- ts.factory.createAwaitExpression(writeCallExpressionn(ctx)),
64
- ),
65
- ],
66
- ts.NodeFlags.Const,
67
- ),
68
- ),
69
- ts.factory.createExpressionStatement(
70
- ts.factory.createCallExpression(
71
- ts.factory.createPropertyAccessExpression(
72
- ts.factory.createIdentifier(
73
- ctx.importer.external({
74
- type: "default",
75
- library: "typia",
76
- name: "typia",
77
- }),
78
- ),
79
- "assert",
80
- ),
81
- undefined,
82
- [ts.factory.createIdentifier("output")],
83
- ),
84
- ),
85
- ];
86
-
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(".")),
91
- );
92
- const connection = ts.factory.createIdentifier("connection");
93
- if (
94
- ctx.route.parameters.length === 0 &&
95
- ctx.route.query === null &&
96
- ctx.route.body === null
97
- )
98
- return ts.factory.createCallExpression(fetch, undefined, [connection]);
99
-
100
- const random = ts.factory.createPropertyAccessExpression(
101
- ts.factory.createIdentifier(
102
- ctx.importer.external({
103
- type: "default",
104
- library: "typia",
105
- name: "typia",
106
- }),
107
- ),
108
- "random",
109
- );
110
- if (ctx.config.keyword === true)
111
- return ts.factory.createCallExpression(fetch, undefined, [
112
- connection,
113
- LiteralFactory.write(
114
- Object.fromEntries(
115
- [...ctx.route.parameters, ctx.route.query, ctx.route.body]
116
- .filter((x) => x !== null)
117
- .map(({ key, schema: value }) => [
118
- key,
119
- ts.factory.createCallExpression(
120
- random,
121
- [
122
- NestiaMigrateSchemaProgrammer.write({
123
- components: ctx.components,
124
- importer: ctx.importer,
125
- schema: value,
126
- }),
127
- ],
128
- undefined,
129
- ),
130
- ]),
131
- ),
132
- ),
133
- ]);
134
- return ts.factory.createCallExpression(fetch, undefined, [
135
- connection,
136
- ...[...ctx.route.parameters, ctx.route.query, ctx.route.body]
137
- .filter((p) => !!p)
138
- .map((p) =>
139
- ts.factory.createCallExpression(
140
- random,
141
- [
142
- NestiaMigrateSchemaProgrammer.write({
143
- components: ctx.components,
144
- importer: ctx.importer,
145
- schema: p.schema,
146
- }),
147
- ],
148
- undefined,
149
- ),
150
- ),
151
- ]);
152
- };
153
- }
1
+ import { IHttpMigrateRoute, OpenApi } from "@samchon/openapi";
2
+ import ts from "typescript";
3
+ import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
4
+ import { LiteralFactory } from "typia/lib/factories/LiteralFactory";
5
+
6
+ import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
7
+ import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
8
+ import { NestiaMigrateSchemaProgrammer } from "./NestiaMigrateSchemaProgrammer";
9
+
10
+ export namespace NestiaMigrateE2eFunctionProgrammer {
11
+ export interface IContext {
12
+ config: INestiaMigrateConfig;
13
+ components: OpenApi.IComponents;
14
+ importer: NestiaMigrateImportProgrammer;
15
+ route: IHttpMigrateRoute;
16
+ }
17
+
18
+ export const write = (ctx: IContext): ts.FunctionDeclaration =>
19
+ ts.factory.createFunctionDeclaration(
20
+ [
21
+ ts.factory.createModifier(ts.SyntaxKind.ExportKeyword),
22
+ ts.factory.createModifier(ts.SyntaxKind.AsyncKeyword),
23
+ ],
24
+ undefined,
25
+ ["test", "api", ...ctx.route.accessor].join("_"),
26
+ undefined,
27
+ [
28
+ IdentifierFactory.parameter(
29
+ "connection",
30
+ ts.factory.createTypeReferenceNode(
31
+ ts.factory.createQualifiedName(
32
+ ts.factory.createIdentifier(
33
+ ctx.importer.external({
34
+ type: "default",
35
+ library: "@ORGANIZATION/PROJECT-api",
36
+ name: "api",
37
+ }),
38
+ ),
39
+ ts.factory.createIdentifier("IConnection"),
40
+ ),
41
+ ),
42
+ ),
43
+ ],
44
+ undefined,
45
+ ts.factory.createBlock(writeBody(ctx), true),
46
+ );
47
+
48
+ export const writeBody = (ctx: IContext): ts.Statement[] => [
49
+ ts.factory.createVariableStatement(
50
+ [],
51
+ ts.factory.createVariableDeclarationList(
52
+ [
53
+ ts.factory.createVariableDeclaration(
54
+ "output",
55
+ undefined,
56
+ ctx.route.success
57
+ ? NestiaMigrateSchemaProgrammer.write({
58
+ components: ctx.components,
59
+ importer: ctx.importer,
60
+ schema: ctx.route.success.schema,
61
+ })
62
+ : undefined,
63
+ ts.factory.createAwaitExpression(writeCallExpressionn(ctx)),
64
+ ),
65
+ ],
66
+ ts.NodeFlags.Const,
67
+ ),
68
+ ),
69
+ ts.factory.createExpressionStatement(
70
+ ts.factory.createCallExpression(
71
+ ts.factory.createPropertyAccessExpression(
72
+ ts.factory.createIdentifier(
73
+ ctx.importer.external({
74
+ type: "default",
75
+ library: "typia",
76
+ name: "typia",
77
+ }),
78
+ ),
79
+ "assert",
80
+ ),
81
+ undefined,
82
+ [ts.factory.createIdentifier("output")],
83
+ ),
84
+ ),
85
+ ];
86
+
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(".")),
91
+ );
92
+ const connection = ts.factory.createIdentifier("connection");
93
+ if (
94
+ ctx.route.parameters.length === 0 &&
95
+ ctx.route.query === null &&
96
+ ctx.route.body === null
97
+ )
98
+ return ts.factory.createCallExpression(fetch, undefined, [connection]);
99
+
100
+ const random = ts.factory.createPropertyAccessExpression(
101
+ ts.factory.createIdentifier(
102
+ ctx.importer.external({
103
+ type: "default",
104
+ library: "typia",
105
+ name: "typia",
106
+ }),
107
+ ),
108
+ "random",
109
+ );
110
+ if (ctx.config.keyword === true)
111
+ return ts.factory.createCallExpression(fetch, undefined, [
112
+ connection,
113
+ LiteralFactory.write(
114
+ Object.fromEntries(
115
+ [...ctx.route.parameters, ctx.route.query, ctx.route.body]
116
+ .filter((x) => x !== null)
117
+ .map(({ key, schema: value }) => [
118
+ key,
119
+ ts.factory.createCallExpression(
120
+ random,
121
+ [
122
+ NestiaMigrateSchemaProgrammer.write({
123
+ components: ctx.components,
124
+ importer: ctx.importer,
125
+ schema: value,
126
+ }),
127
+ ],
128
+ undefined,
129
+ ),
130
+ ]),
131
+ ),
132
+ ),
133
+ ]);
134
+ return ts.factory.createCallExpression(fetch, undefined, [
135
+ connection,
136
+ ...[...ctx.route.parameters, ctx.route.query, ctx.route.body]
137
+ .filter((p) => !!p)
138
+ .map((p) =>
139
+ ts.factory.createCallExpression(
140
+ random,
141
+ [
142
+ NestiaMigrateSchemaProgrammer.write({
143
+ components: ctx.components,
144
+ importer: ctx.importer,
145
+ schema: p.schema,
146
+ }),
147
+ ],
148
+ undefined,
149
+ ),
150
+ ),
151
+ ]);
152
+ };
153
+ }
@@ -1,46 +1,46 @@
1
- import { IHttpMigrateRoute, OpenApi } from "@samchon/openapi";
2
- import ts from "typescript";
3
-
4
- import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
5
- import { INestiaMigrateContext } from "../structures/INestiaMigrateContext";
6
- import { INestiaMigrateFile } from "../structures/INestiaMigrateFile";
7
- import { FilePrinter } from "../utils/FilePrinter";
8
- import { NestiaMigrateE2eFunctionProgrammer } from "./NestiaMigrateE2eFileProgrammer";
9
- import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
10
-
11
- export namespace NestiaMigrateE2eProgrammer {
12
- export const write = (ctx: INestiaMigrateContext): Record<string, string> =>
13
- Object.fromEntries(
14
- ctx.routes
15
- .map((r) => writeFile(ctx.config, ctx.document.components, r))
16
- .map((r) => [`${r.location}/${r.file}`, r.content]),
17
- );
18
-
19
- const writeFile = (
20
- config: INestiaMigrateConfig,
21
- components: OpenApi.IComponents,
22
- route: IHttpMigrateRoute,
23
- ): INestiaMigrateFile => {
24
- const importer: NestiaMigrateImportProgrammer =
25
- new NestiaMigrateImportProgrammer();
26
- const func: ts.FunctionDeclaration =
27
- NestiaMigrateE2eFunctionProgrammer.write({
28
- config,
29
- components,
30
- importer,
31
- route,
32
- });
33
- const statements: ts.Statement[] = [
34
- ...importer.toStatements(
35
- (name) => `@ORGANIZATION/PROJECT-api/lib/structures/${name}`,
36
- ),
37
- FilePrinter.newLine(),
38
- func,
39
- ];
40
- return {
41
- location: `test/features/api`,
42
- file: `${["test", "api", ...route.accessor].join("_")}.ts`,
43
- content: FilePrinter.write({ statements }),
44
- };
45
- };
46
- }
1
+ import { IHttpMigrateRoute, OpenApi } from "@samchon/openapi";
2
+ import ts from "typescript";
3
+
4
+ import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
5
+ import { INestiaMigrateContext } from "../structures/INestiaMigrateContext";
6
+ import { INestiaMigrateFile } from "../structures/INestiaMigrateFile";
7
+ import { FilePrinter } from "../utils/FilePrinter";
8
+ import { NestiaMigrateE2eFunctionProgrammer } from "./NestiaMigrateE2eFileProgrammer";
9
+ import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
10
+
11
+ export namespace NestiaMigrateE2eProgrammer {
12
+ export const write = (ctx: INestiaMigrateContext): Record<string, string> =>
13
+ Object.fromEntries(
14
+ ctx.routes
15
+ .map((r) => writeFile(ctx.config, ctx.document.components, r))
16
+ .map((r) => [`${r.location}/${r.file}`, r.content]),
17
+ );
18
+
19
+ const writeFile = (
20
+ config: INestiaMigrateConfig,
21
+ components: OpenApi.IComponents,
22
+ route: IHttpMigrateRoute,
23
+ ): INestiaMigrateFile => {
24
+ const importer: NestiaMigrateImportProgrammer =
25
+ new NestiaMigrateImportProgrammer();
26
+ const func: ts.FunctionDeclaration =
27
+ NestiaMigrateE2eFunctionProgrammer.write({
28
+ config,
29
+ components,
30
+ importer,
31
+ route,
32
+ });
33
+ const statements: ts.Statement[] = [
34
+ ...importer.toStatements(
35
+ (name) => `@ORGANIZATION/PROJECT-api/lib/structures/${name}`,
36
+ ),
37
+ FilePrinter.newLine(),
38
+ func,
39
+ ];
40
+ return {
41
+ location: `test/features/api`,
42
+ file: `${["test", "api", ...route.accessor].join("_")}.ts`,
43
+ content: FilePrinter.write({ statements }),
44
+ };
45
+ };
46
+ }
@@ -1,118 +1,118 @@
1
- import ts from "typescript";
2
-
3
- import { TypeLiteralFactory } from "../factories/TypeLiteralFactory";
4
- import { FilePrinter } from "../utils/FilePrinter";
5
- import { MapUtil } from "../utils/MapUtil";
6
-
7
- export class NestiaMigrateImportProgrammer {
8
- private external_: Map<string, IClause> = new Map();
9
- private dtos_: Set<string> = new Set();
10
-
11
- public constructor() {}
12
-
13
- public empty(): boolean {
14
- return this.external_.size === 0 && this.dtos_.size === 0;
15
- }
16
-
17
- public external(props: MigrateImportProgrammer.IProps): string {
18
- const clause: IClause = MapUtil.take(this.external_)(props.library)(() => ({
19
- default: null,
20
- instances: new Set(),
21
- }));
22
- const name: string = props.name.split(".")[0];
23
- if (props.type === "default") clause.default = props.name;
24
- else clause.instances.add(name);
25
- return name;
26
- }
27
-
28
- public dto(name: string, namespace?: string): ts.TypeReferenceNode {
29
- const file: string = name.split(".")[0];
30
- this.dtos_.add(file);
31
- return ts.factory.createTypeReferenceNode(
32
- namespace?.length
33
- ? ts.factory.createQualifiedName(
34
- ts.factory.createIdentifier(namespace),
35
- ts.factory.createIdentifier(file),
36
- )
37
- : name,
38
- );
39
- }
40
-
41
- public tag(type: string, arg?: any): ts.TypeReferenceNode {
42
- const instance: string = this.external({
43
- type: "instance",
44
- library: "typia",
45
- name: "tags",
46
- });
47
- return ts.factory.createTypeReferenceNode(
48
- `${instance}.${type}`,
49
- arg === undefined ? [] : [TypeLiteralFactory.generate(arg)],
50
- );
51
- }
52
-
53
- public toStatements(
54
- dtoPath: (name: string) => string,
55
- current?: string,
56
- ): ts.Statement[] {
57
- return [
58
- ...[...this.external_.entries()].map(([library, props]) =>
59
- ts.factory.createImportDeclaration(
60
- undefined,
61
- ts.factory.createImportClause(
62
- false,
63
- props.default !== null
64
- ? ts.factory.createIdentifier(props.default)
65
- : undefined,
66
- props.instances.size
67
- ? ts.factory.createNamedImports(
68
- [...props.instances].map((i) =>
69
- ts.factory.createImportSpecifier(
70
- false,
71
- undefined,
72
- ts.factory.createIdentifier(i),
73
- ),
74
- ),
75
- )
76
- : undefined,
77
- ),
78
- ts.factory.createStringLiteral(library),
79
- ),
80
- ),
81
- ...(this.external_.size && this.dtos_.size
82
- ? [FilePrinter.newLine()]
83
- : []),
84
- ...[...this.dtos_]
85
- .filter(
86
- current ? (name) => name !== current!.split(".")[0] : () => true,
87
- )
88
- .map((i) =>
89
- ts.factory.createImportDeclaration(
90
- undefined,
91
- ts.factory.createImportClause(
92
- false,
93
- undefined,
94
- ts.factory.createNamedImports([
95
- ts.factory.createImportSpecifier(
96
- false,
97
- undefined,
98
- ts.factory.createIdentifier(i),
99
- ),
100
- ]),
101
- ),
102
- ts.factory.createStringLiteral(dtoPath(i)),
103
- ),
104
- ),
105
- ];
106
- }
107
- }
108
- export namespace MigrateImportProgrammer {
109
- export interface IProps {
110
- type: "default" | "instance";
111
- library: string;
112
- name: string;
113
- }
114
- }
115
- interface IClause {
116
- default: string | null;
117
- instances: Set<string>;
118
- }
1
+ import ts from "typescript";
2
+
3
+ import { TypeLiteralFactory } from "../factories/TypeLiteralFactory";
4
+ import { FilePrinter } from "../utils/FilePrinter";
5
+ import { MapUtil } from "../utils/MapUtil";
6
+
7
+ export class NestiaMigrateImportProgrammer {
8
+ private external_: Map<string, IClause> = new Map();
9
+ private dtos_: Set<string> = new Set();
10
+
11
+ public constructor() {}
12
+
13
+ public empty(): boolean {
14
+ return this.external_.size === 0 && this.dtos_.size === 0;
15
+ }
16
+
17
+ public external(props: MigrateImportProgrammer.IProps): string {
18
+ const clause: IClause = MapUtil.take(this.external_)(props.library)(() => ({
19
+ default: null,
20
+ instances: new Set(),
21
+ }));
22
+ const name: string = props.name.split(".")[0];
23
+ if (props.type === "default") clause.default = props.name;
24
+ else clause.instances.add(name);
25
+ return name;
26
+ }
27
+
28
+ public dto(name: string, namespace?: string): ts.TypeReferenceNode {
29
+ const file: string = name.split(".")[0];
30
+ this.dtos_.add(file);
31
+ return ts.factory.createTypeReferenceNode(
32
+ namespace?.length
33
+ ? ts.factory.createQualifiedName(
34
+ ts.factory.createIdentifier(namespace),
35
+ ts.factory.createIdentifier(file),
36
+ )
37
+ : name,
38
+ );
39
+ }
40
+
41
+ public tag(type: string, arg?: any): ts.TypeReferenceNode {
42
+ const instance: string = this.external({
43
+ type: "instance",
44
+ library: "typia",
45
+ name: "tags",
46
+ });
47
+ return ts.factory.createTypeReferenceNode(
48
+ `${instance}.${type}`,
49
+ arg === undefined ? [] : [TypeLiteralFactory.generate(arg)],
50
+ );
51
+ }
52
+
53
+ public toStatements(
54
+ dtoPath: (name: string) => string,
55
+ current?: string,
56
+ ): ts.Statement[] {
57
+ return [
58
+ ...[...this.external_.entries()].map(([library, props]) =>
59
+ ts.factory.createImportDeclaration(
60
+ undefined,
61
+ ts.factory.createImportClause(
62
+ false,
63
+ props.default !== null
64
+ ? ts.factory.createIdentifier(props.default)
65
+ : undefined,
66
+ props.instances.size
67
+ ? ts.factory.createNamedImports(
68
+ [...props.instances].map((i) =>
69
+ ts.factory.createImportSpecifier(
70
+ false,
71
+ undefined,
72
+ ts.factory.createIdentifier(i),
73
+ ),
74
+ ),
75
+ )
76
+ : undefined,
77
+ ),
78
+ ts.factory.createStringLiteral(library),
79
+ ),
80
+ ),
81
+ ...(this.external_.size && this.dtos_.size
82
+ ? [FilePrinter.newLine()]
83
+ : []),
84
+ ...[...this.dtos_]
85
+ .filter(
86
+ current ? (name) => name !== current!.split(".")[0] : () => true,
87
+ )
88
+ .map((i) =>
89
+ ts.factory.createImportDeclaration(
90
+ undefined,
91
+ ts.factory.createImportClause(
92
+ false,
93
+ undefined,
94
+ ts.factory.createNamedImports([
95
+ ts.factory.createImportSpecifier(
96
+ false,
97
+ undefined,
98
+ ts.factory.createIdentifier(i),
99
+ ),
100
+ ]),
101
+ ),
102
+ ts.factory.createStringLiteral(dtoPath(i)),
103
+ ),
104
+ ),
105
+ ];
106
+ }
107
+ }
108
+ export namespace MigrateImportProgrammer {
109
+ export interface IProps {
110
+ type: "default" | "instance";
111
+ library: string;
112
+ name: string;
113
+ }
114
+ }
115
+ interface IClause {
116
+ default: string | null;
117
+ instances: Set<string>;
118
+ }