@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.
- package/LICENSE +21 -0
- package/README.md +93 -93
- package/package.json +32 -46
- package/src/NestiaMigrateApplication.ts +161 -159
- package/src/analyzers/NestiaMigrateControllerAnalyzer.ts +51 -51
- package/src/archivers/NestiaMigrateFileArchiver.ts +28 -28
- package/src/bundles/NEST_TEMPLATE.ts +48 -48
- package/src/bundles/SDK_TEMPLATE.ts +21 -21
- package/src/executable/NestiaMigrateCommander.ts +98 -98
- package/src/executable/NestiaMigrateInquirer.ts +106 -106
- package/src/executable/bundle.js +125 -125
- package/src/executable/migrate.ts +7 -7
- package/src/factories/TypeLiteralFactory.ts +57 -57
- package/src/index.ts +4 -4
- package/src/module.ts +6 -2
- package/src/programmers/NestiaMigrateApiFileProgrammer.ts +55 -55
- package/src/programmers/NestiaMigrateApiFunctionProgrammer.ts +347 -344
- package/src/programmers/NestiaMigrateApiNamespaceProgrammer.ts +517 -514
- package/src/programmers/NestiaMigrateApiProgrammer.ts +107 -107
- package/src/programmers/NestiaMigrateApiSimulationProgrammer.ts +308 -309
- package/src/programmers/NestiaMigrateApiStartProgrammer.ts +197 -198
- package/src/programmers/NestiaMigrateDtoProgrammer.ts +98 -98
- package/src/programmers/NestiaMigrateE2eFileProgrammer.ts +153 -153
- package/src/programmers/NestiaMigrateE2eProgrammer.ts +48 -48
- package/src/programmers/NestiaMigrateImportProgrammer.ts +118 -118
- package/src/programmers/NestiaMigrateNestControllerProgrammer.ts +69 -69
- package/src/programmers/NestiaMigrateNestMethodProgrammer.ts +409 -406
- package/src/programmers/NestiaMigrateNestModuleProgrammer.ts +65 -65
- package/src/programmers/NestiaMigrateNestProgrammer.ts +88 -88
- package/src/programmers/NestiaMigrateSchemaProgrammer.ts +465 -467
- package/src/structures/INestiaMigrateConfig.ts +19 -19
- package/src/structures/INestiaMigrateContext.ts +9 -9
- package/src/structures/INestiaMigrateController.ts +8 -8
- package/src/structures/INestiaMigrateDto.ts +8 -8
- package/src/structures/INestiaMigrateFile.ts +5 -5
- package/src/structures/INestiaMigrateProgram.ts +11 -11
- package/src/structures/INestiaMigrateSchema.ts +4 -4
- package/src/utils/FilePrinter.ts +49 -49
- package/src/utils/MapUtil.ts +13 -13
- package/src/utils/SetupWizard.ts +12 -12
- package/src/utils/StringUtil.ts +114 -113
- package/src/utils/openapi-down-convert/RefVisitor.ts +134 -134
- package/src/utils/openapi-down-convert/converter.ts +536 -536
- package/lib/NestiaMigrateApplication.d.ts +0 -24
- package/lib/NestiaMigrateApplication.js +0 -18757
- package/lib/NestiaMigrateApplication.js.map +0 -1
- package/lib/analyzers/NestiaMigrateControllerAnalyzer.d.ts +0 -5
- package/lib/analyzers/NestiaMigrateControllerAnalyzer.js +0 -46
- package/lib/analyzers/NestiaMigrateControllerAnalyzer.js.map +0 -1
- package/lib/archivers/NestiaMigrateFileArchiver.d.ts +0 -8
- package/lib/archivers/NestiaMigrateFileArchiver.js +0 -36
- package/lib/archivers/NestiaMigrateFileArchiver.js.map +0 -1
- package/lib/bundles/NEST_TEMPLATE.d.ts +0 -1
- package/lib/bundles/NEST_TEMPLATE.js +0 -55
- package/lib/bundles/NEST_TEMPLATE.js.map +0 -1
- package/lib/bundles/SDK_TEMPLATE.d.ts +0 -1
- package/lib/bundles/SDK_TEMPLATE.js +0 -27
- package/lib/bundles/SDK_TEMPLATE.js.map +0 -1
- package/lib/executable/NestiaMigrateCommander.d.ts +0 -4
- package/lib/executable/NestiaMigrateCommander.js +0 -125
- package/lib/executable/NestiaMigrateCommander.js.map +0 -1
- package/lib/executable/NestiaMigrateInquirer.d.ts +0 -12
- package/lib/executable/NestiaMigrateInquirer.js +0 -94
- package/lib/executable/NestiaMigrateInquirer.js.map +0 -1
- package/lib/executable/migrate.d.ts +0 -2
- package/lib/executable/migrate.js +0 -9
- package/lib/executable/migrate.js.map +0 -1
- package/lib/factories/TypeLiteralFactory.d.ts +0 -4
- package/lib/factories/TypeLiteralFactory.js +0 -35
- package/lib/factories/TypeLiteralFactory.js.map +0 -1
- package/lib/index.d.ts +0 -3
- package/lib/index.js +0 -42
- package/lib/index.js.map +0 -1
- package/lib/index.mjs +0 -19359
- package/lib/index.mjs.map +0 -1
- package/lib/module.d.ts +0 -2
- package/lib/module.js +0 -19
- package/lib/module.js.map +0 -1
- package/lib/programmers/NestiaMigrateApiFileProgrammer.d.ts +0 -13
- package/lib/programmers/NestiaMigrateApiFileProgrammer.js +0 -40
- package/lib/programmers/NestiaMigrateApiFileProgrammer.js.map +0 -1
- package/lib/programmers/NestiaMigrateApiFunctionProgrammer.d.ts +0 -14
- package/lib/programmers/NestiaMigrateApiFunctionProgrammer.js +0 -179
- package/lib/programmers/NestiaMigrateApiFunctionProgrammer.js.map +0 -1
- package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.d.ts +0 -14
- package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.js +0 -226
- package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.js.map +0 -1
- package/lib/programmers/NestiaMigrateApiProgrammer.d.ts +0 -4
- package/lib/programmers/NestiaMigrateApiProgrammer.js +0 -82
- package/lib/programmers/NestiaMigrateApiProgrammer.js.map +0 -1
- package/lib/programmers/NestiaMigrateApiSimulationProgrammer.d.ts +0 -14
- package/lib/programmers/NestiaMigrateApiSimulationProgrammer.js +0 -142
- package/lib/programmers/NestiaMigrateApiSimulationProgrammer.js.map +0 -1
- package/lib/programmers/NestiaMigrateApiStartProgrammer.d.ts +0 -4
- package/lib/programmers/NestiaMigrateApiStartProgrammer.js +0 -80
- package/lib/programmers/NestiaMigrateApiStartProgrammer.js.map +0 -1
- package/lib/programmers/NestiaMigrateDtoProgrammer.d.ts +0 -15
- package/lib/programmers/NestiaMigrateDtoProgrammer.js +0 -65
- package/lib/programmers/NestiaMigrateDtoProgrammer.js.map +0 -1
- package/lib/programmers/NestiaMigrateE2eFileProgrammer.d.ts +0 -14
- package/lib/programmers/NestiaMigrateE2eFileProgrammer.js +0 -81
- package/lib/programmers/NestiaMigrateE2eFileProgrammer.js.map +0 -1
- package/lib/programmers/NestiaMigrateE2eProgrammer.d.ts +0 -4
- package/lib/programmers/NestiaMigrateE2eProgrammer.js +0 -32
- package/lib/programmers/NestiaMigrateE2eProgrammer.js.map +0 -1
- package/lib/programmers/NestiaMigrateImportProgrammer.d.ts +0 -18
- package/lib/programmers/NestiaMigrateImportProgrammer.js +0 -65
- package/lib/programmers/NestiaMigrateImportProgrammer.js.map +0 -1
- package/lib/programmers/NestiaMigrateNestControllerProgrammer.d.ts +0 -12
- package/lib/programmers/NestiaMigrateNestControllerProgrammer.js +0 -46
- package/lib/programmers/NestiaMigrateNestControllerProgrammer.js.map +0 -1
- package/lib/programmers/NestiaMigrateNestMethodProgrammer.d.ts +0 -15
- package/lib/programmers/NestiaMigrateNestMethodProgrammer.js +0 -224
- package/lib/programmers/NestiaMigrateNestMethodProgrammer.js.map +0 -1
- package/lib/programmers/NestiaMigrateNestModuleProgrammer.d.ts +0 -5
- package/lib/programmers/NestiaMigrateNestModuleProgrammer.js +0 -29
- package/lib/programmers/NestiaMigrateNestModuleProgrammer.js.map +0 -1
- package/lib/programmers/NestiaMigrateNestProgrammer.d.ts +0 -4
- package/lib/programmers/NestiaMigrateNestProgrammer.js +0 -65
- package/lib/programmers/NestiaMigrateNestProgrammer.js.map +0 -1
- package/lib/programmers/NestiaMigrateSchemaProgrammer.d.ts +0 -10
- package/lib/programmers/NestiaMigrateSchemaProgrammer.js +0 -341
- package/lib/programmers/NestiaMigrateSchemaProgrammer.js.map +0 -1
- package/lib/structures/INestiaMigrateConfig.d.ts +0 -15
- package/lib/structures/INestiaMigrateConfig.js +0 -3
- package/lib/structures/INestiaMigrateConfig.js.map +0 -1
- package/lib/structures/INestiaMigrateContext.d.ts +0 -7
- package/lib/structures/INestiaMigrateContext.js +0 -3
- package/lib/structures/INestiaMigrateContext.js.map +0 -1
- package/lib/structures/INestiaMigrateController.d.ts +0 -7
- package/lib/structures/INestiaMigrateController.js +0 -3
- package/lib/structures/INestiaMigrateController.js.map +0 -1
- package/lib/structures/INestiaMigrateDto.d.ts +0 -7
- package/lib/structures/INestiaMigrateDto.js +0 -3
- package/lib/structures/INestiaMigrateDto.js.map +0 -1
- package/lib/structures/INestiaMigrateFile.d.ts +0 -5
- package/lib/structures/INestiaMigrateFile.js +0 -3
- package/lib/structures/INestiaMigrateFile.js.map +0 -1
- package/lib/structures/INestiaMigrateProgram.d.ts +0 -9
- package/lib/structures/INestiaMigrateProgram.js +0 -3
- package/lib/structures/INestiaMigrateProgram.js.map +0 -1
- package/lib/structures/INestiaMigrateSchema.d.ts +0 -4
- package/lib/structures/INestiaMigrateSchema.js +0 -3
- package/lib/structures/INestiaMigrateSchema.js.map +0 -1
- package/lib/utils/FilePrinter.d.ts +0 -9
- package/lib/utils/FilePrinter.js +0 -35
- package/lib/utils/FilePrinter.js.map +0 -1
- package/lib/utils/MapUtil.d.ts +0 -3
- package/lib/utils/MapUtil.js +0 -15
- package/lib/utils/MapUtil.js.map +0 -1
- package/lib/utils/SetupWizard.d.ts +0 -3
- package/lib/utils/SetupWizard.js +0 -18
- package/lib/utils/SetupWizard.js.map +0 -1
- package/lib/utils/StringUtil.d.ts +0 -6
- package/lib/utils/StringUtil.js +0 -108
- package/lib/utils/StringUtil.js.map +0 -1
- package/lib/utils/openapi-down-convert/RefVisitor.d.ts +0 -52
- package/lib/utils/openapi-down-convert/RefVisitor.js +0 -102
- package/lib/utils/openapi-down-convert/RefVisitor.js.map +0 -1
- package/lib/utils/openapi-down-convert/converter.d.ts +0 -146
- package/lib/utils/openapi-down-convert/converter.js +0 -441
- package/lib/utils/openapi-down-convert/converter.js.map +0 -1
|
@@ -1,309 +1,308 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
undefined,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
undefined,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
undefined,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
ctx
|
|
69
|
-
|
|
70
|
-
ctx.route.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
];
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
"method",
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
"host",
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
ctx.
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
);
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
undefined,
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
undefined,
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
)
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
ts.factory.
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
],
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
"status",
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
"headers",
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
"
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
),
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
undefined,
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
);
|
|
1
|
+
import { IdentifierFactory, StatementFactory, TypeFactory } from "@typia/core";
|
|
2
|
+
import { IHttpMigrateRoute } from "@typia/interface";
|
|
3
|
+
import ts from "typescript";
|
|
4
|
+
import { OpenApi } from "typia";
|
|
5
|
+
|
|
6
|
+
import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
|
|
7
|
+
import { NestiaMigrateApiFunctionProgrammer } from "./NestiaMigrateApiFunctionProgrammer";
|
|
8
|
+
import { NestiaMigrateApiNamespaceProgrammer } from "./NestiaMigrateApiNamespaceProgrammer";
|
|
9
|
+
import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
|
|
10
|
+
import { NestiaMigrateSchemaProgrammer } from "./NestiaMigrateSchemaProgrammer";
|
|
11
|
+
|
|
12
|
+
export namespace NestiaMigrateApiSimulationProgrammer {
|
|
13
|
+
export interface IContext {
|
|
14
|
+
config: INestiaMigrateConfig;
|
|
15
|
+
components: OpenApi.IComponents;
|
|
16
|
+
importer: NestiaMigrateImportProgrammer;
|
|
17
|
+
route: IHttpMigrateRoute;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const random = (ctx: IContext) => {
|
|
21
|
+
const output = ctx.route.success
|
|
22
|
+
? NestiaMigrateSchemaProgrammer.write({
|
|
23
|
+
components: ctx.components,
|
|
24
|
+
importer: ctx.importer,
|
|
25
|
+
schema: ctx.route.success.schema,
|
|
26
|
+
})
|
|
27
|
+
: TypeFactory.keyword("void");
|
|
28
|
+
return constant(
|
|
29
|
+
"random",
|
|
30
|
+
ts.factory.createArrowFunction(
|
|
31
|
+
undefined,
|
|
32
|
+
undefined,
|
|
33
|
+
[],
|
|
34
|
+
output,
|
|
35
|
+
undefined,
|
|
36
|
+
ts.factory.createCallExpression(
|
|
37
|
+
IdentifierFactory.access(
|
|
38
|
+
ts.factory.createIdentifier(
|
|
39
|
+
ctx.importer.external({
|
|
40
|
+
type: "default",
|
|
41
|
+
library: "typia",
|
|
42
|
+
name: "typia",
|
|
43
|
+
}),
|
|
44
|
+
),
|
|
45
|
+
"random",
|
|
46
|
+
),
|
|
47
|
+
[output],
|
|
48
|
+
undefined,
|
|
49
|
+
),
|
|
50
|
+
),
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const simulate = (ctx: IContext): ts.VariableStatement => {
|
|
55
|
+
const caller = () =>
|
|
56
|
+
ts.factory.createCallExpression(
|
|
57
|
+
ts.factory.createIdentifier("random"),
|
|
58
|
+
undefined,
|
|
59
|
+
undefined,
|
|
60
|
+
);
|
|
61
|
+
return constant(
|
|
62
|
+
"simulate",
|
|
63
|
+
ts.factory.createArrowFunction(
|
|
64
|
+
undefined,
|
|
65
|
+
undefined,
|
|
66
|
+
NestiaMigrateApiFunctionProgrammer.writeParameterDeclarations(
|
|
67
|
+
ctx,
|
|
68
|
+
ctx.route.parameters.length === 0 &&
|
|
69
|
+
ctx.route.query === null &&
|
|
70
|
+
ctx.route.body === null
|
|
71
|
+
? "_connection"
|
|
72
|
+
: undefined,
|
|
73
|
+
),
|
|
74
|
+
ts.factory.createTypeReferenceNode(
|
|
75
|
+
ctx.route.success ? "Response" : "void",
|
|
76
|
+
),
|
|
77
|
+
undefined,
|
|
78
|
+
ts.factory.createBlock(
|
|
79
|
+
[...assert(ctx), ts.factory.createReturnStatement(caller())],
|
|
80
|
+
true,
|
|
81
|
+
),
|
|
82
|
+
),
|
|
83
|
+
);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const assert = (ctx: IContext): ts.Statement[] => {
|
|
87
|
+
const property = (key: string) =>
|
|
88
|
+
ctx.config.keyword === true
|
|
89
|
+
? IdentifierFactory.access(ts.factory.createIdentifier("props"), key)
|
|
90
|
+
: ts.factory.createIdentifier(key);
|
|
91
|
+
const parameters = [
|
|
92
|
+
...ctx.route.parameters.map((p) => ({
|
|
93
|
+
category: "param",
|
|
94
|
+
name: p.key,
|
|
95
|
+
schema: NestiaMigrateSchemaProgrammer.write({
|
|
96
|
+
components: ctx.components,
|
|
97
|
+
importer: ctx.importer,
|
|
98
|
+
schema: p.schema,
|
|
99
|
+
}),
|
|
100
|
+
})),
|
|
101
|
+
...(ctx.route.query
|
|
102
|
+
? [
|
|
103
|
+
{
|
|
104
|
+
category: "query",
|
|
105
|
+
name: ctx.route.query.key,
|
|
106
|
+
schema: NestiaMigrateSchemaProgrammer.write({
|
|
107
|
+
components: ctx.components,
|
|
108
|
+
importer: ctx.importer,
|
|
109
|
+
schema: ctx.route.query.schema,
|
|
110
|
+
}),
|
|
111
|
+
},
|
|
112
|
+
]
|
|
113
|
+
: []),
|
|
114
|
+
...(ctx.route.body
|
|
115
|
+
? [
|
|
116
|
+
{
|
|
117
|
+
category: "body",
|
|
118
|
+
name: ctx.route.body.key,
|
|
119
|
+
schema: NestiaMigrateSchemaProgrammer.write({
|
|
120
|
+
components: ctx.components,
|
|
121
|
+
importer: ctx.importer,
|
|
122
|
+
schema: ctx.route.body.schema,
|
|
123
|
+
}),
|
|
124
|
+
},
|
|
125
|
+
]
|
|
126
|
+
: []),
|
|
127
|
+
];
|
|
128
|
+
if (parameters.length === 0) return [];
|
|
129
|
+
|
|
130
|
+
const validator = StatementFactory.constant({
|
|
131
|
+
name: "assert",
|
|
132
|
+
value: ts.factory.createCallExpression(
|
|
133
|
+
IdentifierFactory.access(
|
|
134
|
+
ts.factory.createIdentifier(
|
|
135
|
+
ctx.importer.external({
|
|
136
|
+
type: "instance",
|
|
137
|
+
library: `@nestia/fetcher`,
|
|
138
|
+
name: "NestiaSimulator",
|
|
139
|
+
}),
|
|
140
|
+
),
|
|
141
|
+
"assert",
|
|
142
|
+
),
|
|
143
|
+
undefined,
|
|
144
|
+
[
|
|
145
|
+
ts.factory.createObjectLiteralExpression(
|
|
146
|
+
[
|
|
147
|
+
ts.factory.createPropertyAssignment(
|
|
148
|
+
"method",
|
|
149
|
+
ts.factory.createIdentifier("METADATA.method"),
|
|
150
|
+
),
|
|
151
|
+
ts.factory.createPropertyAssignment(
|
|
152
|
+
"host",
|
|
153
|
+
ts.factory.createIdentifier("connection.host"),
|
|
154
|
+
),
|
|
155
|
+
ts.factory.createPropertyAssignment(
|
|
156
|
+
"path",
|
|
157
|
+
NestiaMigrateApiNamespaceProgrammer.writePathCallExpression(
|
|
158
|
+
ctx.config,
|
|
159
|
+
ctx.route,
|
|
160
|
+
),
|
|
161
|
+
),
|
|
162
|
+
ts.factory.createPropertyAssignment(
|
|
163
|
+
"contentType",
|
|
164
|
+
ts.factory.createStringLiteral(
|
|
165
|
+
ctx.route.success?.type ?? "application/json",
|
|
166
|
+
),
|
|
167
|
+
),
|
|
168
|
+
],
|
|
169
|
+
true,
|
|
170
|
+
),
|
|
171
|
+
],
|
|
172
|
+
),
|
|
173
|
+
});
|
|
174
|
+
const individual = parameters
|
|
175
|
+
.map((p) =>
|
|
176
|
+
ts.factory.createCallExpression(
|
|
177
|
+
(() => {
|
|
178
|
+
const base = IdentifierFactory.access(
|
|
179
|
+
ts.factory.createIdentifier("assert"),
|
|
180
|
+
p.category,
|
|
181
|
+
);
|
|
182
|
+
if (p.category !== "param") return base;
|
|
183
|
+
return ts.factory.createCallExpression(base, undefined, [
|
|
184
|
+
ts.factory.createStringLiteral(p.name),
|
|
185
|
+
]);
|
|
186
|
+
})(),
|
|
187
|
+
undefined,
|
|
188
|
+
[
|
|
189
|
+
ts.factory.createArrowFunction(
|
|
190
|
+
undefined,
|
|
191
|
+
undefined,
|
|
192
|
+
[],
|
|
193
|
+
undefined,
|
|
194
|
+
undefined,
|
|
195
|
+
ts.factory.createCallExpression(
|
|
196
|
+
IdentifierFactory.access(
|
|
197
|
+
ts.factory.createIdentifier(
|
|
198
|
+
ctx.importer.external({
|
|
199
|
+
type: "default",
|
|
200
|
+
library: "typia",
|
|
201
|
+
name: "typia",
|
|
202
|
+
}),
|
|
203
|
+
),
|
|
204
|
+
"assert",
|
|
205
|
+
),
|
|
206
|
+
undefined,
|
|
207
|
+
[
|
|
208
|
+
p.category === "headers"
|
|
209
|
+
? ts.factory.createIdentifier("connection.headers")
|
|
210
|
+
: property(p.name),
|
|
211
|
+
],
|
|
212
|
+
),
|
|
213
|
+
),
|
|
214
|
+
],
|
|
215
|
+
),
|
|
216
|
+
)
|
|
217
|
+
.map(ts.factory.createExpressionStatement);
|
|
218
|
+
return [validator, tryAndCatch(ctx.importer, individual)];
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
const tryAndCatch = (
|
|
222
|
+
importer: NestiaMigrateImportProgrammer,
|
|
223
|
+
individual: ts.Statement[],
|
|
224
|
+
) =>
|
|
225
|
+
ts.factory.createTryStatement(
|
|
226
|
+
ts.factory.createBlock(individual, true),
|
|
227
|
+
ts.factory.createCatchClause(
|
|
228
|
+
"exp",
|
|
229
|
+
ts.factory.createBlock(
|
|
230
|
+
[
|
|
231
|
+
ts.factory.createIfStatement(
|
|
232
|
+
ts.factory.createLogicalNot(
|
|
233
|
+
ts.factory.createCallExpression(
|
|
234
|
+
IdentifierFactory.access(
|
|
235
|
+
ts.factory.createIdentifier(
|
|
236
|
+
importer.external({
|
|
237
|
+
type: "default",
|
|
238
|
+
library: "typia",
|
|
239
|
+
name: "typia",
|
|
240
|
+
}),
|
|
241
|
+
),
|
|
242
|
+
"is",
|
|
243
|
+
),
|
|
244
|
+
[
|
|
245
|
+
ts.factory.createTypeReferenceNode(
|
|
246
|
+
importer.external({
|
|
247
|
+
type: "instance",
|
|
248
|
+
library: "@nestia/fetcher",
|
|
249
|
+
name: "HttpError",
|
|
250
|
+
}),
|
|
251
|
+
),
|
|
252
|
+
],
|
|
253
|
+
[ts.factory.createIdentifier("exp")],
|
|
254
|
+
),
|
|
255
|
+
),
|
|
256
|
+
ts.factory.createThrowStatement(
|
|
257
|
+
ts.factory.createIdentifier("exp"),
|
|
258
|
+
),
|
|
259
|
+
),
|
|
260
|
+
ts.factory.createReturnStatement(
|
|
261
|
+
ts.factory.createAsExpression(
|
|
262
|
+
ts.factory.createObjectLiteralExpression(
|
|
263
|
+
[
|
|
264
|
+
ts.factory.createPropertyAssignment(
|
|
265
|
+
"success",
|
|
266
|
+
ts.factory.createFalse(),
|
|
267
|
+
),
|
|
268
|
+
ts.factory.createPropertyAssignment(
|
|
269
|
+
"status",
|
|
270
|
+
ts.factory.createIdentifier("exp.status"),
|
|
271
|
+
),
|
|
272
|
+
ts.factory.createPropertyAssignment(
|
|
273
|
+
"headers",
|
|
274
|
+
ts.factory.createIdentifier("exp.headers"),
|
|
275
|
+
),
|
|
276
|
+
ts.factory.createPropertyAssignment(
|
|
277
|
+
"data",
|
|
278
|
+
ts.factory.createIdentifier("exp.toJSON().message"),
|
|
279
|
+
),
|
|
280
|
+
],
|
|
281
|
+
true,
|
|
282
|
+
),
|
|
283
|
+
TypeFactory.keyword("any"),
|
|
284
|
+
),
|
|
285
|
+
),
|
|
286
|
+
],
|
|
287
|
+
true,
|
|
288
|
+
),
|
|
289
|
+
),
|
|
290
|
+
undefined,
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
const constant = (name: string, expression: ts.Expression) =>
|
|
295
|
+
ts.factory.createVariableStatement(
|
|
296
|
+
[ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
|
|
297
|
+
ts.factory.createVariableDeclarationList(
|
|
298
|
+
[
|
|
299
|
+
ts.factory.createVariableDeclaration(
|
|
300
|
+
ts.factory.createIdentifier(name),
|
|
301
|
+
undefined,
|
|
302
|
+
undefined,
|
|
303
|
+
expression,
|
|
304
|
+
),
|
|
305
|
+
],
|
|
306
|
+
ts.NodeFlags.Const,
|
|
307
|
+
),
|
|
308
|
+
);
|