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