@nestia/migrate 10.0.2 → 11.0.0-dev.20260305

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 (162) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +93 -93
  3. package/package.json +32 -46
  4. package/src/NestiaMigrateApplication.ts +161 -159
  5. package/src/analyzers/NestiaMigrateControllerAnalyzer.ts +51 -51
  6. package/src/archivers/NestiaMigrateFileArchiver.ts +28 -28
  7. package/src/bundles/NEST_TEMPLATE.ts +48 -48
  8. package/src/bundles/SDK_TEMPLATE.ts +21 -21
  9. package/src/executable/NestiaMigrateCommander.ts +98 -98
  10. package/src/executable/NestiaMigrateInquirer.ts +106 -106
  11. package/src/executable/bundle.js +125 -125
  12. package/src/executable/migrate.ts +7 -7
  13. package/src/factories/TypeLiteralFactory.ts +57 -57
  14. package/src/index.ts +4 -4
  15. package/src/module.ts +6 -2
  16. package/src/programmers/NestiaMigrateApiFileProgrammer.ts +55 -55
  17. package/src/programmers/NestiaMigrateApiFunctionProgrammer.ts +347 -344
  18. package/src/programmers/NestiaMigrateApiNamespaceProgrammer.ts +517 -514
  19. package/src/programmers/NestiaMigrateApiProgrammer.ts +107 -107
  20. package/src/programmers/NestiaMigrateApiSimulationProgrammer.ts +308 -309
  21. package/src/programmers/NestiaMigrateApiStartProgrammer.ts +197 -198
  22. package/src/programmers/NestiaMigrateDtoProgrammer.ts +98 -98
  23. package/src/programmers/NestiaMigrateE2eFileProgrammer.ts +153 -153
  24. package/src/programmers/NestiaMigrateE2eProgrammer.ts +48 -48
  25. package/src/programmers/NestiaMigrateImportProgrammer.ts +118 -118
  26. package/src/programmers/NestiaMigrateNestControllerProgrammer.ts +69 -69
  27. package/src/programmers/NestiaMigrateNestMethodProgrammer.ts +409 -406
  28. package/src/programmers/NestiaMigrateNestModuleProgrammer.ts +65 -65
  29. package/src/programmers/NestiaMigrateNestProgrammer.ts +88 -88
  30. package/src/programmers/NestiaMigrateSchemaProgrammer.ts +465 -467
  31. package/src/structures/INestiaMigrateConfig.ts +19 -19
  32. package/src/structures/INestiaMigrateContext.ts +9 -9
  33. package/src/structures/INestiaMigrateController.ts +8 -8
  34. package/src/structures/INestiaMigrateDto.ts +8 -8
  35. package/src/structures/INestiaMigrateFile.ts +5 -5
  36. package/src/structures/INestiaMigrateProgram.ts +11 -11
  37. package/src/structures/INestiaMigrateSchema.ts +4 -4
  38. package/src/utils/FilePrinter.ts +49 -49
  39. package/src/utils/MapUtil.ts +13 -13
  40. package/src/utils/SetupWizard.ts +12 -12
  41. package/src/utils/StringUtil.ts +114 -113
  42. package/src/utils/openapi-down-convert/RefVisitor.ts +134 -134
  43. package/src/utils/openapi-down-convert/converter.ts +536 -536
  44. package/lib/NestiaMigrateApplication.d.ts +0 -24
  45. package/lib/NestiaMigrateApplication.js +0 -18757
  46. package/lib/NestiaMigrateApplication.js.map +0 -1
  47. package/lib/analyzers/NestiaMigrateControllerAnalyzer.d.ts +0 -5
  48. package/lib/analyzers/NestiaMigrateControllerAnalyzer.js +0 -46
  49. package/lib/analyzers/NestiaMigrateControllerAnalyzer.js.map +0 -1
  50. package/lib/archivers/NestiaMigrateFileArchiver.d.ts +0 -8
  51. package/lib/archivers/NestiaMigrateFileArchiver.js +0 -36
  52. package/lib/archivers/NestiaMigrateFileArchiver.js.map +0 -1
  53. package/lib/bundles/NEST_TEMPLATE.d.ts +0 -1
  54. package/lib/bundles/NEST_TEMPLATE.js +0 -55
  55. package/lib/bundles/NEST_TEMPLATE.js.map +0 -1
  56. package/lib/bundles/SDK_TEMPLATE.d.ts +0 -1
  57. package/lib/bundles/SDK_TEMPLATE.js +0 -27
  58. package/lib/bundles/SDK_TEMPLATE.js.map +0 -1
  59. package/lib/executable/NestiaMigrateCommander.d.ts +0 -4
  60. package/lib/executable/NestiaMigrateCommander.js +0 -125
  61. package/lib/executable/NestiaMigrateCommander.js.map +0 -1
  62. package/lib/executable/NestiaMigrateInquirer.d.ts +0 -12
  63. package/lib/executable/NestiaMigrateInquirer.js +0 -94
  64. package/lib/executable/NestiaMigrateInquirer.js.map +0 -1
  65. package/lib/executable/migrate.d.ts +0 -2
  66. package/lib/executable/migrate.js +0 -9
  67. package/lib/executable/migrate.js.map +0 -1
  68. package/lib/factories/TypeLiteralFactory.d.ts +0 -4
  69. package/lib/factories/TypeLiteralFactory.js +0 -35
  70. package/lib/factories/TypeLiteralFactory.js.map +0 -1
  71. package/lib/index.d.ts +0 -3
  72. package/lib/index.js +0 -42
  73. package/lib/index.js.map +0 -1
  74. package/lib/index.mjs +0 -19359
  75. package/lib/index.mjs.map +0 -1
  76. package/lib/module.d.ts +0 -2
  77. package/lib/module.js +0 -19
  78. package/lib/module.js.map +0 -1
  79. package/lib/programmers/NestiaMigrateApiFileProgrammer.d.ts +0 -13
  80. package/lib/programmers/NestiaMigrateApiFileProgrammer.js +0 -40
  81. package/lib/programmers/NestiaMigrateApiFileProgrammer.js.map +0 -1
  82. package/lib/programmers/NestiaMigrateApiFunctionProgrammer.d.ts +0 -14
  83. package/lib/programmers/NestiaMigrateApiFunctionProgrammer.js +0 -179
  84. package/lib/programmers/NestiaMigrateApiFunctionProgrammer.js.map +0 -1
  85. package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.d.ts +0 -14
  86. package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.js +0 -226
  87. package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.js.map +0 -1
  88. package/lib/programmers/NestiaMigrateApiProgrammer.d.ts +0 -4
  89. package/lib/programmers/NestiaMigrateApiProgrammer.js +0 -82
  90. package/lib/programmers/NestiaMigrateApiProgrammer.js.map +0 -1
  91. package/lib/programmers/NestiaMigrateApiSimulationProgrammer.d.ts +0 -14
  92. package/lib/programmers/NestiaMigrateApiSimulationProgrammer.js +0 -142
  93. package/lib/programmers/NestiaMigrateApiSimulationProgrammer.js.map +0 -1
  94. package/lib/programmers/NestiaMigrateApiStartProgrammer.d.ts +0 -4
  95. package/lib/programmers/NestiaMigrateApiStartProgrammer.js +0 -80
  96. package/lib/programmers/NestiaMigrateApiStartProgrammer.js.map +0 -1
  97. package/lib/programmers/NestiaMigrateDtoProgrammer.d.ts +0 -15
  98. package/lib/programmers/NestiaMigrateDtoProgrammer.js +0 -65
  99. package/lib/programmers/NestiaMigrateDtoProgrammer.js.map +0 -1
  100. package/lib/programmers/NestiaMigrateE2eFileProgrammer.d.ts +0 -14
  101. package/lib/programmers/NestiaMigrateE2eFileProgrammer.js +0 -81
  102. package/lib/programmers/NestiaMigrateE2eFileProgrammer.js.map +0 -1
  103. package/lib/programmers/NestiaMigrateE2eProgrammer.d.ts +0 -4
  104. package/lib/programmers/NestiaMigrateE2eProgrammer.js +0 -32
  105. package/lib/programmers/NestiaMigrateE2eProgrammer.js.map +0 -1
  106. package/lib/programmers/NestiaMigrateImportProgrammer.d.ts +0 -18
  107. package/lib/programmers/NestiaMigrateImportProgrammer.js +0 -65
  108. package/lib/programmers/NestiaMigrateImportProgrammer.js.map +0 -1
  109. package/lib/programmers/NestiaMigrateNestControllerProgrammer.d.ts +0 -12
  110. package/lib/programmers/NestiaMigrateNestControllerProgrammer.js +0 -46
  111. package/lib/programmers/NestiaMigrateNestControllerProgrammer.js.map +0 -1
  112. package/lib/programmers/NestiaMigrateNestMethodProgrammer.d.ts +0 -15
  113. package/lib/programmers/NestiaMigrateNestMethodProgrammer.js +0 -224
  114. package/lib/programmers/NestiaMigrateNestMethodProgrammer.js.map +0 -1
  115. package/lib/programmers/NestiaMigrateNestModuleProgrammer.d.ts +0 -5
  116. package/lib/programmers/NestiaMigrateNestModuleProgrammer.js +0 -29
  117. package/lib/programmers/NestiaMigrateNestModuleProgrammer.js.map +0 -1
  118. package/lib/programmers/NestiaMigrateNestProgrammer.d.ts +0 -4
  119. package/lib/programmers/NestiaMigrateNestProgrammer.js +0 -65
  120. package/lib/programmers/NestiaMigrateNestProgrammer.js.map +0 -1
  121. package/lib/programmers/NestiaMigrateSchemaProgrammer.d.ts +0 -10
  122. package/lib/programmers/NestiaMigrateSchemaProgrammer.js +0 -341
  123. package/lib/programmers/NestiaMigrateSchemaProgrammer.js.map +0 -1
  124. package/lib/structures/INestiaMigrateConfig.d.ts +0 -15
  125. package/lib/structures/INestiaMigrateConfig.js +0 -3
  126. package/lib/structures/INestiaMigrateConfig.js.map +0 -1
  127. package/lib/structures/INestiaMigrateContext.d.ts +0 -7
  128. package/lib/structures/INestiaMigrateContext.js +0 -3
  129. package/lib/structures/INestiaMigrateContext.js.map +0 -1
  130. package/lib/structures/INestiaMigrateController.d.ts +0 -7
  131. package/lib/structures/INestiaMigrateController.js +0 -3
  132. package/lib/structures/INestiaMigrateController.js.map +0 -1
  133. package/lib/structures/INestiaMigrateDto.d.ts +0 -7
  134. package/lib/structures/INestiaMigrateDto.js +0 -3
  135. package/lib/structures/INestiaMigrateDto.js.map +0 -1
  136. package/lib/structures/INestiaMigrateFile.d.ts +0 -5
  137. package/lib/structures/INestiaMigrateFile.js +0 -3
  138. package/lib/structures/INestiaMigrateFile.js.map +0 -1
  139. package/lib/structures/INestiaMigrateProgram.d.ts +0 -9
  140. package/lib/structures/INestiaMigrateProgram.js +0 -3
  141. package/lib/structures/INestiaMigrateProgram.js.map +0 -1
  142. package/lib/structures/INestiaMigrateSchema.d.ts +0 -4
  143. package/lib/structures/INestiaMigrateSchema.js +0 -3
  144. package/lib/structures/INestiaMigrateSchema.js.map +0 -1
  145. package/lib/utils/FilePrinter.d.ts +0 -9
  146. package/lib/utils/FilePrinter.js +0 -35
  147. package/lib/utils/FilePrinter.js.map +0 -1
  148. package/lib/utils/MapUtil.d.ts +0 -3
  149. package/lib/utils/MapUtil.js +0 -15
  150. package/lib/utils/MapUtil.js.map +0 -1
  151. package/lib/utils/SetupWizard.d.ts +0 -3
  152. package/lib/utils/SetupWizard.js +0 -18
  153. package/lib/utils/SetupWizard.js.map +0 -1
  154. package/lib/utils/StringUtil.d.ts +0 -6
  155. package/lib/utils/StringUtil.js +0 -108
  156. package/lib/utils/StringUtil.js.map +0 -1
  157. package/lib/utils/openapi-down-convert/RefVisitor.d.ts +0 -52
  158. package/lib/utils/openapi-down-convert/RefVisitor.js +0 -102
  159. package/lib/utils/openapi-down-convert/RefVisitor.js.map +0 -1
  160. package/lib/utils/openapi-down-convert/converter.d.ts +0 -146
  161. package/lib/utils/openapi-down-convert/converter.js +0 -441
  162. package/lib/utils/openapi-down-convert/converter.js.map +0 -1
@@ -1,198 +1,197 @@
1
- import { IHttpMigrateRoute } from "@samchon/openapi";
2
- import ts from "typescript";
3
- import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
4
- import { StatementFactory } from "typia/lib/factories/StatementFactory";
5
-
6
- import { INestiaMigrateContext } from "../structures/INestiaMigrateContext";
7
- import { FilePrinter } from "../utils/FilePrinter";
8
- import { NestiaMigrateE2eFunctionProgrammer } from "./NestiaMigrateE2eFileProgrammer";
9
- import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
10
-
11
- export namespace NestiaMigrateApiStartProgrammer {
12
- export const write = (
13
- context: INestiaMigrateContext,
14
- ): Record<string, string> => {
15
- const importer: NestiaMigrateImportProgrammer =
16
- new NestiaMigrateImportProgrammer();
17
- const main: ts.VariableStatement = writeMain(
18
- context,
19
- importer,
20
- pick(context.application.routes),
21
- );
22
- const statements: ts.Statement[] = [
23
- ...importer.toStatements(
24
- (name) => `@ORGANIZATION/PROJECT-api/lib/structures/${name}`,
25
- ),
26
- FilePrinter.newLine(),
27
- ts.factory.createImportDeclaration(
28
- undefined,
29
- ts.factory.createImportClause(
30
- false,
31
- undefined,
32
- ts.factory.createNamedImports([
33
- ts.factory.createImportSpecifier(
34
- false,
35
- undefined,
36
- ts.factory.createIdentifier("TestGlobal"),
37
- ),
38
- ]),
39
- ),
40
- ts.factory.createStringLiteral("./TestGlobal"),
41
- undefined,
42
- ),
43
- FilePrinter.newLine(),
44
- main,
45
- ts.factory.createExpressionStatement(writeStarter()),
46
- ];
47
- return {
48
- "test/start.ts": FilePrinter.write({ statements }),
49
- };
50
- };
51
-
52
- const writeMain = (
53
- ctx: INestiaMigrateContext,
54
- importer: NestiaMigrateImportProgrammer,
55
- route: IHttpMigrateRoute,
56
- ): ts.VariableStatement =>
57
- StatementFactory.constant({
58
- name: "main",
59
- value: ts.factory.createArrowFunction(
60
- [ts.factory.createToken(ts.SyntaxKind.AsyncKeyword)],
61
- undefined,
62
- [],
63
- undefined,
64
- undefined,
65
- ts.factory.createBlock(
66
- [
67
- writeConnection(ctx, importer),
68
- ...NestiaMigrateE2eFunctionProgrammer.writeBody({
69
- config: ctx.config,
70
- components: ctx.application.document().components,
71
- importer,
72
- route,
73
- }),
74
- ],
75
- true,
76
- ),
77
- ),
78
- });
79
-
80
- const writeConnection = (
81
- ctx: INestiaMigrateContext,
82
- importer: NestiaMigrateImportProgrammer,
83
- ): ts.VariableStatement =>
84
- ts.factory.createVariableStatement(
85
- undefined,
86
- ts.factory.createVariableDeclarationList(
87
- [
88
- ts.factory.createVariableDeclaration(
89
- "connection",
90
- undefined,
91
- ts.factory.createTypeReferenceNode(
92
- ts.factory.createQualifiedName(
93
- ts.factory.createIdentifier(
94
- importer.external({
95
- type: "default",
96
- library: "@ORGANIZATION/PROJECT-api",
97
- name: "api",
98
- }),
99
- ),
100
- ts.factory.createIdentifier("IConnection"),
101
- ),
102
- ),
103
- ts.factory.createObjectLiteralExpression(
104
- [
105
- ts.factory.createSpreadAssignment(
106
- ts.factory.createCallExpression(
107
- ts.factory.createPropertyAccessExpression(
108
- ts.factory.createIdentifier("TestGlobal"),
109
- "connection",
110
- ),
111
- undefined,
112
- undefined,
113
- ),
114
- ),
115
- ...(ctx.application.document().servers?.[0]?.url?.length
116
- ? [
117
- ts.factory.createPropertyAssignment(
118
- "host",
119
- ts.factory.createStringLiteral(
120
- ctx.application.document().servers![0].url,
121
- ),
122
- ),
123
- ]
124
- : []),
125
- ...(ctx.config.simulate === true
126
- ? [
127
- ts.factory.createPropertyAssignment(
128
- "simulate",
129
- ts.factory.createTrue(),
130
- ),
131
- ]
132
- : []),
133
- ],
134
- true,
135
- ),
136
- ),
137
- ],
138
- ts.NodeFlags.Const,
139
- ),
140
- );
141
-
142
- const writeStarter = (): ts.CallExpression =>
143
- ts.factory.createCallExpression(
144
- ts.factory.createPropertyAccessExpression(
145
- ts.factory.createCallExpression(
146
- ts.factory.createIdentifier("main"),
147
- undefined,
148
- undefined,
149
- ),
150
- "catch",
151
- ),
152
- undefined,
153
- [
154
- ts.factory.createArrowFunction(
155
- undefined,
156
- undefined,
157
- [IdentifierFactory.parameter("exp")],
158
- undefined,
159
- undefined,
160
- ts.factory.createBlock(
161
- [
162
- ts.factory.createExpressionStatement(
163
- ts.factory.createCallExpression(
164
- ts.factory.createPropertyAccessExpression(
165
- ts.factory.createIdentifier("console"),
166
- "log",
167
- ),
168
- undefined,
169
- [ts.factory.createIdentifier("exp")],
170
- ),
171
- ),
172
- ts.factory.createExpressionStatement(
173
- ts.factory.createCallExpression(
174
- ts.factory.createPropertyAccessExpression(
175
- ts.factory.createIdentifier("process"),
176
- "exit",
177
- ),
178
- undefined,
179
- [
180
- ts.factory.createPrefixMinus(
181
- ts.factory.createNumericLiteral("1"),
182
- ),
183
- ],
184
- ),
185
- ),
186
- ],
187
- true,
188
- ),
189
- ),
190
- ],
191
- );
192
- }
193
-
194
- const pick = <T>(array: T[]): T => {
195
- const rand: number = Math.random() * array.length;
196
- const index: number = Math.min(array.length - 1, Math.floor(rand));
197
- return array[index];
198
- };
1
+ import { IdentifierFactory, StatementFactory } from "@typia/core";
2
+ import { IHttpMigrateRoute } from "@typia/interface";
3
+ import ts from "typescript";
4
+
5
+ import { INestiaMigrateContext } from "../structures/INestiaMigrateContext";
6
+ import { FilePrinter } from "../utils/FilePrinter";
7
+ import { NestiaMigrateE2eFunctionProgrammer } from "./NestiaMigrateE2eFileProgrammer";
8
+ import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
9
+
10
+ export namespace NestiaMigrateApiStartProgrammer {
11
+ export const write = (
12
+ context: INestiaMigrateContext,
13
+ ): Record<string, string> => {
14
+ const importer: NestiaMigrateImportProgrammer =
15
+ new NestiaMigrateImportProgrammer();
16
+ const main: ts.VariableStatement = writeMain(
17
+ context,
18
+ importer,
19
+ pick(context.application.routes),
20
+ );
21
+ const statements: ts.Statement[] = [
22
+ ...importer.toStatements(
23
+ (name) => `@ORGANIZATION/PROJECT-api/lib/structures/${name}`,
24
+ ),
25
+ FilePrinter.newLine(),
26
+ ts.factory.createImportDeclaration(
27
+ undefined,
28
+ ts.factory.createImportClause(
29
+ false,
30
+ undefined,
31
+ ts.factory.createNamedImports([
32
+ ts.factory.createImportSpecifier(
33
+ false,
34
+ undefined,
35
+ ts.factory.createIdentifier("TestGlobal"),
36
+ ),
37
+ ]),
38
+ ),
39
+ ts.factory.createStringLiteral("./TestGlobal"),
40
+ undefined,
41
+ ),
42
+ FilePrinter.newLine(),
43
+ main,
44
+ ts.factory.createExpressionStatement(writeStarter()),
45
+ ];
46
+ return {
47
+ "test/start.ts": FilePrinter.write({ statements }),
48
+ };
49
+ };
50
+
51
+ const writeMain = (
52
+ ctx: INestiaMigrateContext,
53
+ importer: NestiaMigrateImportProgrammer,
54
+ route: IHttpMigrateRoute,
55
+ ): ts.VariableStatement =>
56
+ StatementFactory.constant({
57
+ name: "main",
58
+ value: ts.factory.createArrowFunction(
59
+ [ts.factory.createToken(ts.SyntaxKind.AsyncKeyword)],
60
+ undefined,
61
+ [],
62
+ undefined,
63
+ undefined,
64
+ ts.factory.createBlock(
65
+ [
66
+ writeConnection(ctx, importer),
67
+ ...NestiaMigrateE2eFunctionProgrammer.writeBody({
68
+ config: ctx.config,
69
+ components: ctx.application.document().components,
70
+ importer,
71
+ route,
72
+ }),
73
+ ],
74
+ true,
75
+ ),
76
+ ),
77
+ });
78
+
79
+ const writeConnection = (
80
+ ctx: INestiaMigrateContext,
81
+ importer: NestiaMigrateImportProgrammer,
82
+ ): ts.VariableStatement =>
83
+ ts.factory.createVariableStatement(
84
+ undefined,
85
+ ts.factory.createVariableDeclarationList(
86
+ [
87
+ ts.factory.createVariableDeclaration(
88
+ "connection",
89
+ undefined,
90
+ ts.factory.createTypeReferenceNode(
91
+ ts.factory.createQualifiedName(
92
+ ts.factory.createIdentifier(
93
+ importer.external({
94
+ type: "default",
95
+ library: "@ORGANIZATION/PROJECT-api",
96
+ name: "api",
97
+ }),
98
+ ),
99
+ ts.factory.createIdentifier("IConnection"),
100
+ ),
101
+ ),
102
+ ts.factory.createObjectLiteralExpression(
103
+ [
104
+ ts.factory.createSpreadAssignment(
105
+ ts.factory.createCallExpression(
106
+ ts.factory.createPropertyAccessExpression(
107
+ ts.factory.createIdentifier("TestGlobal"),
108
+ "connection",
109
+ ),
110
+ undefined,
111
+ undefined,
112
+ ),
113
+ ),
114
+ ...(ctx.application.document().servers?.[0]?.url?.length
115
+ ? [
116
+ ts.factory.createPropertyAssignment(
117
+ "host",
118
+ ts.factory.createStringLiteral(
119
+ ctx.application.document().servers![0]!.url,
120
+ ),
121
+ ),
122
+ ]
123
+ : []),
124
+ ...(ctx.config.simulate === true
125
+ ? [
126
+ ts.factory.createPropertyAssignment(
127
+ "simulate",
128
+ ts.factory.createTrue(),
129
+ ),
130
+ ]
131
+ : []),
132
+ ],
133
+ true,
134
+ ),
135
+ ),
136
+ ],
137
+ ts.NodeFlags.Const,
138
+ ),
139
+ );
140
+
141
+ const writeStarter = (): ts.CallExpression =>
142
+ ts.factory.createCallExpression(
143
+ ts.factory.createPropertyAccessExpression(
144
+ ts.factory.createCallExpression(
145
+ ts.factory.createIdentifier("main"),
146
+ undefined,
147
+ undefined,
148
+ ),
149
+ "catch",
150
+ ),
151
+ undefined,
152
+ [
153
+ ts.factory.createArrowFunction(
154
+ undefined,
155
+ undefined,
156
+ [IdentifierFactory.parameter("exp")],
157
+ undefined,
158
+ undefined,
159
+ ts.factory.createBlock(
160
+ [
161
+ ts.factory.createExpressionStatement(
162
+ ts.factory.createCallExpression(
163
+ ts.factory.createPropertyAccessExpression(
164
+ ts.factory.createIdentifier("console"),
165
+ "log",
166
+ ),
167
+ undefined,
168
+ [ts.factory.createIdentifier("exp")],
169
+ ),
170
+ ),
171
+ ts.factory.createExpressionStatement(
172
+ ts.factory.createCallExpression(
173
+ ts.factory.createPropertyAccessExpression(
174
+ ts.factory.createIdentifier("process"),
175
+ "exit",
176
+ ),
177
+ undefined,
178
+ [
179
+ ts.factory.createPrefixMinus(
180
+ ts.factory.createNumericLiteral("1"),
181
+ ),
182
+ ],
183
+ ),
184
+ ),
185
+ ],
186
+ true,
187
+ ),
188
+ ),
189
+ ],
190
+ );
191
+ }
192
+
193
+ const pick = <T>(array: T[]): T => {
194
+ const rand: number = Math.random() * array.length;
195
+ const index: number = Math.min(array.length - 1, Math.floor(rand));
196
+ return array[index]!;
197
+ };
@@ -1,98 +1,98 @@
1
- import { OpenApi } from "@samchon/openapi";
2
- import { IPointer } from "tstl";
3
- import ts from "typescript";
4
-
5
- import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
6
- import { FilePrinter } from "../utils/FilePrinter";
7
- import { MapUtil } from "../utils/MapUtil";
8
- import { StringUtil } from "../utils/StringUtil";
9
- import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
10
- import { NestiaMigrateSchemaProgrammer } from "./NestiaMigrateSchemaProgrammer";
11
-
12
- export namespace NestiaMigrateDtoProgrammer {
13
- export interface IModule {
14
- name: string;
15
- children: Map<string, IModule>;
16
- programmer:
17
- | null
18
- | ((importer: NestiaMigrateImportProgrammer) => ts.TypeAliasDeclaration);
19
- }
20
-
21
- export const compose = (props: {
22
- config: INestiaMigrateConfig;
23
- components: OpenApi.IComponents;
24
- }): Map<string, IModule> => {
25
- const dict: Map<string, IModule> = new Map();
26
- for (const [key, value] of Object.entries(props.components.schemas ?? {})) {
27
- const emendedKey: string = key
28
- .split("/")
29
- .filter((str) => str.length !== 0)
30
- .map(StringUtil.escapeNonVariable)
31
- .join("");
32
- prepare(dict)(emendedKey)((importer) =>
33
- writeAlias(props.config)(props.components)(importer)(emendedKey, value),
34
- );
35
- }
36
- return dict;
37
- };
38
-
39
- const prepare =
40
- (dict: Map<string, IModule>) =>
41
- (name: string) =>
42
- (
43
- programmer: (
44
- importer: NestiaMigrateImportProgrammer,
45
- ) => ts.TypeAliasDeclaration,
46
- ) => {
47
- const accessors: string[] = name.split(".");
48
- const modulo: IPointer<IModule> = { value: null! };
49
-
50
- accessors.forEach((acc, i) => {
51
- modulo.value = MapUtil.take(dict)(acc)(() => ({
52
- name: acc,
53
- children: new Map(),
54
- programmer: null,
55
- }));
56
- if (i === accessors.length - 1) modulo.value.programmer = programmer;
57
- dict = modulo.value.children;
58
- });
59
- return modulo!;
60
- };
61
-
62
- const writeAlias =
63
- (config: INestiaMigrateConfig) =>
64
- (components: OpenApi.IComponents) =>
65
- (importer: NestiaMigrateImportProgrammer) =>
66
- (key: string, value: OpenApi.IJsonSchema) =>
67
- FilePrinter.description(
68
- ts.factory.createTypeAliasDeclaration(
69
- [ts.factory.createToken(ts.SyntaxKind.ExportKeyword)],
70
- key.split(".").at(-1)!,
71
- [],
72
- NestiaMigrateSchemaProgrammer.write({
73
- components,
74
- importer,
75
- schema: value,
76
- }),
77
- ),
78
- writeComment(config)(value, key.indexOf(".") === -1),
79
- );
80
- }
81
-
82
- const writeComment =
83
- (config: INestiaMigrateConfig) =>
84
- (schema: OpenApi.IJsonSchema, top: boolean): string =>
85
- [
86
- ...(schema.description?.length ? [schema.description] : []),
87
- ...(schema.description?.length &&
88
- (schema.title !== undefined || schema.deprecated === true)
89
- ? [""]
90
- : []),
91
- ...(schema.title !== undefined ? [`@title ${schema.title}`] : []),
92
- ...(schema.deprecated === true ? [`@deprecated`] : []),
93
- ...(top
94
- ? [
95
- `@${config.author?.tag ?? "nestia"} ${config.author?.value ?? "Generated by Nestia - https://github.com/samchon/nestia"}`,
96
- ]
97
- : []),
98
- ].join("\n");
1
+ import { OpenApi } from "@typia/interface";
2
+ import { IPointer } from "tstl";
3
+ import ts from "typescript";
4
+
5
+ import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
6
+ import { FilePrinter } from "../utils/FilePrinter";
7
+ import { MapUtil } from "../utils/MapUtil";
8
+ import { StringUtil } from "../utils/StringUtil";
9
+ import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
10
+ import { NestiaMigrateSchemaProgrammer } from "./NestiaMigrateSchemaProgrammer";
11
+
12
+ export namespace NestiaMigrateDtoProgrammer {
13
+ export interface IModule {
14
+ name: string;
15
+ children: Map<string, IModule>;
16
+ programmer:
17
+ | null
18
+ | ((importer: NestiaMigrateImportProgrammer) => ts.TypeAliasDeclaration);
19
+ }
20
+
21
+ export const compose = (props: {
22
+ config: INestiaMigrateConfig;
23
+ components: OpenApi.IComponents;
24
+ }): Map<string, IModule> => {
25
+ const dict: Map<string, IModule> = new Map();
26
+ for (const [key, value] of Object.entries(props.components.schemas ?? {})) {
27
+ const emendedKey: string = key
28
+ .split("/")
29
+ .filter((str) => str.length !== 0)
30
+ .map(StringUtil.escapeNonVariable)
31
+ .join("");
32
+ prepare(dict)(emendedKey)((importer) =>
33
+ writeAlias(props.config)(props.components)(importer)(emendedKey, value),
34
+ );
35
+ }
36
+ return dict;
37
+ };
38
+
39
+ const prepare =
40
+ (dict: Map<string, IModule>) =>
41
+ (name: string) =>
42
+ (
43
+ programmer: (
44
+ importer: NestiaMigrateImportProgrammer,
45
+ ) => ts.TypeAliasDeclaration,
46
+ ) => {
47
+ const accessors: string[] = name.split(".");
48
+ const modulo: IPointer<IModule> = { value: null! };
49
+
50
+ accessors.forEach((acc, i) => {
51
+ modulo.value = MapUtil.take(dict)(acc)(() => ({
52
+ name: acc,
53
+ children: new Map(),
54
+ programmer: null,
55
+ }));
56
+ if (i === accessors.length - 1) modulo.value.programmer = programmer;
57
+ dict = modulo.value.children;
58
+ });
59
+ return modulo!;
60
+ };
61
+
62
+ const writeAlias =
63
+ (config: INestiaMigrateConfig) =>
64
+ (components: OpenApi.IComponents) =>
65
+ (importer: NestiaMigrateImportProgrammer) =>
66
+ (key: string, value: OpenApi.IJsonSchema) =>
67
+ FilePrinter.description(
68
+ ts.factory.createTypeAliasDeclaration(
69
+ [ts.factory.createToken(ts.SyntaxKind.ExportKeyword)],
70
+ key.split(".").at(-1)!,
71
+ [],
72
+ NestiaMigrateSchemaProgrammer.write({
73
+ components,
74
+ importer,
75
+ schema: value,
76
+ }),
77
+ ),
78
+ writeComment(config)(value, key.indexOf(".") === -1),
79
+ );
80
+ }
81
+
82
+ const writeComment =
83
+ (config: INestiaMigrateConfig) =>
84
+ (schema: OpenApi.IJsonSchema, top: boolean): string =>
85
+ [
86
+ ...(schema.description?.length ? [schema.description] : []),
87
+ ...(schema.description?.length &&
88
+ (schema.title !== undefined || schema.deprecated === true)
89
+ ? [""]
90
+ : []),
91
+ ...(schema.title !== undefined ? [`@title ${schema.title}`] : []),
92
+ ...(schema.deprecated === true ? [`@deprecated`] : []),
93
+ ...(top
94
+ ? [
95
+ `@${config.author?.tag ?? "nestia"} ${config.author?.value ?? "Generated by Nestia - https://github.com/samchon/nestia"}`,
96
+ ]
97
+ : []),
98
+ ].join("\n");