@nestia/migrate 0.5.0 → 0.6.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.
- package/lib/NestiaMigrateApplication.js +15 -15
- package/lib/NestiaMigrateApplication.js.map +1 -1
- package/lib/archivers/FileArchiver.js.map +1 -1
- package/lib/bundles/TEMPLATE.js +11 -11
- package/lib/bundles/TEMPLATE.js.map +1 -1
- package/lib/executable/bundle.js.map +1 -1
- package/lib/executable/migrate.js +5 -5
- package/lib/executable/migrate.js.map +1 -1
- package/lib/programmers/ControllerProgrammer.d.ts +2 -1
- package/lib/programmers/ControllerProgrammer.js +21 -18
- package/lib/programmers/ControllerProgrammer.js.map +1 -1
- package/lib/programmers/DtoProgrammer.d.ts +8 -4
- package/lib/programmers/DtoProgrammer.js +36 -77
- package/lib/programmers/DtoProgrammer.js.map +1 -1
- package/lib/programmers/ImportProgrammer.d.ts +5 -5
- package/lib/programmers/ImportProgrammer.js +27 -19
- package/lib/programmers/ImportProgrammer.js.map +1 -1
- package/lib/programmers/MigrateProgrammer.d.ts +1 -2
- package/lib/programmers/MigrateProgrammer.js +52 -36
- package/lib/programmers/MigrateProgrammer.js.map +1 -1
- package/lib/programmers/ModuleProgrammer.d.ts +5 -0
- package/lib/programmers/ModuleProgrammer.js +29 -0
- package/lib/programmers/ModuleProgrammer.js.map +1 -0
- package/lib/programmers/RouteProgrammer.d.ts +2 -2
- package/lib/programmers/RouteProgrammer.js +108 -111
- package/lib/programmers/RouteProgrammer.js.map +1 -1
- package/lib/programmers/SchemaProgrammer.d.ts +2 -1
- package/lib/programmers/SchemaProgrammer.js +122 -189
- package/lib/programmers/SchemaProgrammer.js.map +1 -1
- package/lib/structures/IMigrateProgram.d.ts +2 -2
- package/lib/structures/ISwaggerInfo.d.ts +3 -3
- package/lib/utils/FilePrinter.d.ts +9 -0
- package/lib/utils/FilePrinter.js +25 -0
- package/lib/utils/FilePrinter.js.map +1 -0
- package/lib/utils/JsonTypeChecker.d.ts +3 -1
- package/lib/utils/JsonTypeChecker.js +31 -18
- package/lib/utils/JsonTypeChecker.js.map +1 -1
- package/lib/utils/MapUtil.js.map +1 -1
- package/lib/utils/SetupWizard.js.map +1 -1
- package/lib/utils/StringUtil.js.map +1 -1
- package/package.json +11 -9
- package/src/NestiaMigrateApplication.ts +68 -73
- package/src/archivers/FileArchiver.ts +35 -38
- package/src/bundles/TEMPLATE.ts +11 -11
- package/src/executable/bundle.ts +72 -78
- package/src/executable/migrate.ts +59 -60
- package/src/index.ts +4 -4
- package/src/module.ts +4 -4
- package/src/programmers/ControllerProgrammer.ts +155 -157
- package/src/programmers/DtoProgrammer.ts +74 -118
- package/src/programmers/ImportProgrammer.ts +98 -60
- package/src/programmers/MigrateProgrammer.ts +75 -62
- package/src/programmers/ModuleProgrammer.ts +62 -0
- package/src/programmers/RouteProgrammer.ts +486 -466
- package/src/programmers/SchemaProgrammer.ts +247 -339
- package/src/structures/IMigrateController.ts +8 -8
- package/src/structures/IMigrateDto.ts +8 -8
- package/src/structures/IMigrateFile.ts +5 -5
- package/src/structures/IMigrateProgram.ts +7 -7
- package/src/structures/IMigrateRoute.ts +36 -36
- package/src/structures/IMigrateSchema.ts +4 -4
- package/src/structures/ISwaggeSchema.ts +82 -82
- package/src/structures/ISwagger.ts +20 -20
- package/src/structures/ISwaggerComponents.ts +7 -7
- package/src/structures/ISwaggerInfo.ts +57 -57
- package/src/structures/ISwaggerRoute.ts +52 -52
- package/src/structures/ISwaggerSecurity.ts +47 -47
- package/src/utils/FilePrinter.ts +36 -0
- package/src/utils/JsonTypeChecker.ts +67 -52
- package/src/utils/MapUtil.ts +13 -13
- package/src/utils/SetupWizard.ts +15 -15
- package/src/utils/StringUtil.ts +51 -51
@@ -1,347 +1,255 @@
|
|
1
|
+
import ts from "typescript";
|
2
|
+
import { ExpressionFactory } from "typia/lib/factories/ExpressionFactory";
|
3
|
+
import { TypeFactory } from "typia/lib/factories/TypeFactory";
|
4
|
+
import { FormatCheatSheet } from "typia/lib/tags/internal/FormatCheatSheet";
|
1
5
|
import { Escaper } from "typia/lib/utils/Escaper";
|
2
6
|
|
3
7
|
import { ISwaggerSchema } from "../structures/ISwaggeSchema";
|
4
8
|
import { ISwaggerComponents } from "../structures/ISwaggerComponents";
|
5
|
-
import {
|
9
|
+
import { FilePrinter } from "../utils/FilePrinter";
|
10
|
+
import { SwaggerTypeChecker } from "../utils/JsonTypeChecker";
|
6
11
|
import { ImportProgrammer } from "./ImportProgrammer";
|
7
12
|
|
8
13
|
export namespace SchemaProgrammer {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
(
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
(
|
26
|
-
(schema
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
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
|
-
(importer
|
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
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
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
|
-
|
192
|
-
(
|
193
|
-
|
194
|
-
|
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
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
importer,
|
240
|
-
)(schema.additionalProperties)}`
|
241
|
-
: writeDynamicObject(components)(references)(importer)(
|
242
|
-
schema.additionalProperties,
|
243
|
-
)
|
244
|
-
: writeStaticObject(components)(references)(importer)(schema);
|
245
|
-
};
|
246
|
-
const writeStaticObject =
|
247
|
-
(components: ISwaggerComponents) =>
|
248
|
-
(references: ISwaggerSchema.IReference[]) =>
|
249
|
-
(importer: ImportProgrammer) =>
|
250
|
-
(schema: ISwaggerSchema.IObject): string =>
|
251
|
-
[
|
252
|
-
"{",
|
253
|
-
...Object.entries(schema.properties ?? {})
|
254
|
-
.map(([key, value]) =>
|
255
|
-
writeProperty(components)(references)(importer)(key)(
|
256
|
-
(schema.required ?? []).some((r) => r === key),
|
257
|
-
)(value),
|
258
|
-
)
|
259
|
-
.map(tab(4)),
|
260
|
-
"}",
|
261
|
-
].join("\n");
|
262
|
-
const writeDynamicObject =
|
263
|
-
(components: ISwaggerComponents) =>
|
264
|
-
(references: ISwaggerSchema.IReference[]) =>
|
265
|
-
(importer: ImportProgrammer) =>
|
266
|
-
(additional: ISwaggerSchema): string => {
|
267
|
-
return [
|
268
|
-
"{",
|
269
|
-
tab(4)(
|
270
|
-
writeProperty(components)(references)(importer)(
|
271
|
-
"[key: string]",
|
272
|
-
true,
|
273
|
-
)(true)(additional),
|
274
|
-
),
|
275
|
-
"}",
|
276
|
-
].join("\n");
|
277
|
-
};
|
278
|
-
|
279
|
-
const writeProperty =
|
280
|
-
(components: ISwaggerComponents) =>
|
281
|
-
(references: ISwaggerSchema.IReference[]) =>
|
282
|
-
(importer: ImportProgrammer) =>
|
283
|
-
(key: string, ensureVariable: boolean = false) =>
|
284
|
-
(required: boolean) =>
|
285
|
-
(schema: ISwaggerSchema): string => {
|
286
|
-
const content: string[] = [];
|
287
|
-
const commentTagger = (tag: string) => (value?: string) => {
|
288
|
-
const exists: boolean =
|
289
|
-
(!!schema.description?.length &&
|
290
|
-
schema.description.includes(`@${tag}`)) ||
|
291
|
-
content.some((line) => line.includes(`@${tag}`));
|
292
|
-
if (exists === false)
|
293
|
-
if (value?.length) content.push(`@${tag} ${value}`);
|
294
|
-
else content.push(`@${tag}`);
|
295
|
-
};
|
296
|
-
if (schema.description) {
|
297
|
-
content.push(...schema.description.split("\n"));
|
298
|
-
if (!schema.description.split("\n").at(-1)?.startsWith("@"))
|
299
|
-
content.push("");
|
300
|
-
}
|
301
|
-
|
302
|
-
// STARTS FROM TITLE
|
303
|
-
if (schema.title) commentTagger("@title")(schema.title);
|
304
|
-
|
305
|
-
// GET TYPE WITH SPECIAL TAGS
|
306
|
-
const type: string =
|
307
|
-
writeSchema(components)(references)(importer)(commentTagger)(
|
308
|
-
true,
|
309
|
-
)(schema);
|
310
|
-
|
311
|
-
// ENDS WITH DEPRECATED TAG
|
312
|
-
if (schema.deprecated) commentTagger("@deprecated")();
|
313
|
-
|
314
|
-
const description: string =
|
315
|
-
content.length === 0
|
316
|
-
? ""
|
317
|
-
: [
|
318
|
-
"/**",
|
319
|
-
...content.map((line) => ` * ${line}`),
|
320
|
-
" */",
|
321
|
-
"",
|
322
|
-
].join("\n");
|
323
|
-
return `${description}${
|
324
|
-
ensureVariable === false && Escaper.variable(key) === false
|
325
|
-
? JSON.stringify(key)
|
326
|
-
: key
|
327
|
-
}${required ? "" : "?"}: ${required ? type : `undefined | ${type}`};`;
|
328
|
-
};
|
329
|
-
|
330
|
-
const tab =
|
331
|
-
(size: number) =>
|
332
|
-
(str: string): string =>
|
333
|
-
str
|
334
|
-
.split("\n")
|
335
|
-
.map((l) => `${" ".repeat(size)}${l}`)
|
336
|
-
.join("\n");
|
14
|
+
/* -----------------------------------------------------------
|
15
|
+
FACADE
|
16
|
+
----------------------------------------------------------- */
|
17
|
+
export const write =
|
18
|
+
(importer: ImportProgrammer) =>
|
19
|
+
(components: ISwaggerComponents) =>
|
20
|
+
(schema: ISwaggerSchema): ts.TypeNode => {
|
21
|
+
const union: ts.TypeNode[] = [];
|
22
|
+
if (SwaggerTypeChecker.isUnknown(schema))
|
23
|
+
return TypeFactory.keyword("any");
|
24
|
+
else if (SwaggerTypeChecker.isNullOnly(schema)) return createNode("null");
|
25
|
+
else if (SwaggerTypeChecker.isNullable(components)(schema))
|
26
|
+
union.push(createNode("null"));
|
27
|
+
|
28
|
+
const type: ts.TypeNode = (() => {
|
29
|
+
// ATOMIC
|
30
|
+
if (SwaggerTypeChecker.isBoolean(schema)) return writeBoolean(schema);
|
31
|
+
else if (SwaggerTypeChecker.isInteger(schema))
|
32
|
+
return writeInteger(importer)(schema);
|
33
|
+
else if (SwaggerTypeChecker.isNumber(schema))
|
34
|
+
return writeNumber(importer)(schema);
|
35
|
+
// INSTANCES
|
36
|
+
else if (SwaggerTypeChecker.isString(schema))
|
37
|
+
return writeString(importer)(schema);
|
38
|
+
else if (SwaggerTypeChecker.isArray(schema))
|
39
|
+
return writeArray(importer)(components)(schema);
|
40
|
+
else if (SwaggerTypeChecker.isObject(schema))
|
41
|
+
return writeObject(importer)(components)(schema);
|
42
|
+
else if (SwaggerTypeChecker.isReference(schema))
|
43
|
+
return writeReference(importer)(schema);
|
44
|
+
// NESTED UNION
|
45
|
+
else if (SwaggerTypeChecker.isAnyOf(schema))
|
46
|
+
return writeUnion(importer)(components)(schema.anyOf);
|
47
|
+
else if (SwaggerTypeChecker.isOneOf(schema))
|
48
|
+
return writeUnion(importer)(components)(schema.oneOf);
|
49
|
+
else return TypeFactory.keyword("any");
|
50
|
+
})();
|
51
|
+
union.push(type);
|
52
|
+
|
53
|
+
if (union.length === 0) return TypeFactory.keyword("any");
|
54
|
+
else if (union.length === 1) return union[0];
|
55
|
+
return ts.factory.createUnionTypeNode(union);
|
56
|
+
};
|
57
|
+
|
58
|
+
/* -----------------------------------------------------------
|
59
|
+
ATOMICS
|
60
|
+
----------------------------------------------------------- */
|
61
|
+
const writeBoolean = (schema: ISwaggerSchema.IBoolean): ts.TypeNode => {
|
62
|
+
if (schema.enum?.length)
|
63
|
+
return ts.factory.createLiteralTypeNode(
|
64
|
+
schema.enum[0] ? ts.factory.createTrue() : ts.factory.createFalse(),
|
65
|
+
);
|
66
|
+
return TypeFactory.keyword("boolean");
|
67
|
+
};
|
68
|
+
|
69
|
+
const writeInteger =
|
70
|
+
(importer: ImportProgrammer) =>
|
71
|
+
(schema: ISwaggerSchema.IInteger): ts.TypeNode =>
|
72
|
+
writeNumeric(() => [
|
73
|
+
TypeFactory.keyword("number"),
|
74
|
+
importer.tag("Type", "int32"),
|
75
|
+
])(importer)(schema);
|
76
|
+
|
77
|
+
const writeNumber =
|
78
|
+
(importer: ImportProgrammer) =>
|
79
|
+
(schema: ISwaggerSchema.INumber): ts.TypeNode =>
|
80
|
+
writeNumeric(() => [TypeFactory.keyword("number")])(importer)(schema);
|
81
|
+
|
82
|
+
const writeNumeric =
|
83
|
+
(factory: () => ts.TypeNode[]) =>
|
84
|
+
(importer: ImportProgrammer) =>
|
85
|
+
(schema: ISwaggerSchema.IInteger | ISwaggerSchema.INumber): ts.TypeNode => {
|
86
|
+
if (schema.enum?.length)
|
87
|
+
return ts.factory.createUnionTypeNode(
|
88
|
+
schema.enum.map((i) =>
|
89
|
+
ts.factory.createLiteralTypeNode(ExpressionFactory.number(i)),
|
90
|
+
),
|
91
|
+
);
|
92
|
+
const intersection: ts.TypeNode[] = factory();
|
93
|
+
if (schema.default !== undefined)
|
94
|
+
intersection.push(importer.tag("Default", schema.default));
|
95
|
+
if (schema.minimum !== undefined)
|
96
|
+
intersection.push(
|
97
|
+
importer.tag(
|
98
|
+
schema.exclusiveMinimum ? "ExclusiveMinimum" : "Minimum",
|
99
|
+
schema.minimum,
|
100
|
+
),
|
101
|
+
);
|
102
|
+
if (schema.maximum !== undefined)
|
103
|
+
intersection.push(
|
104
|
+
importer.tag(
|
105
|
+
schema.exclusiveMaximum ? "ExclusiveMaximum" : "Maximum",
|
106
|
+
schema.maximum,
|
107
|
+
),
|
108
|
+
);
|
109
|
+
if (schema.multipleOf !== undefined)
|
110
|
+
intersection.push(importer.tag("MultipleOf", schema.multipleOf));
|
111
|
+
|
112
|
+
return intersection.length === 1
|
113
|
+
? intersection[0]
|
114
|
+
: ts.factory.createIntersectionTypeNode(intersection);
|
115
|
+
};
|
116
|
+
|
117
|
+
const writeString =
|
118
|
+
(importer: ImportProgrammer) =>
|
119
|
+
(schema: ISwaggerSchema.IString): ts.TypeNode => {
|
120
|
+
const intersection: ts.TypeNode[] = [TypeFactory.keyword("string")];
|
121
|
+
if (schema.default !== undefined)
|
122
|
+
intersection.push(importer.tag("Default", schema.default));
|
123
|
+
if (schema.minLength !== undefined)
|
124
|
+
intersection.push(importer.tag("MinLength", schema.minLength));
|
125
|
+
if (schema.maxLength !== undefined)
|
126
|
+
intersection.push(importer.tag("MaxLength", schema.maxLength));
|
127
|
+
if (schema.pattern !== undefined)
|
128
|
+
intersection.push(importer.tag("Pattern", schema.pattern));
|
129
|
+
if (
|
130
|
+
schema.format !== undefined &&
|
131
|
+
(FormatCheatSheet as Record<string, string>)[schema.format] !==
|
132
|
+
undefined
|
133
|
+
)
|
134
|
+
intersection.push(importer.tag("Format", schema.format));
|
135
|
+
return intersection.length === 1
|
136
|
+
? intersection[0]
|
137
|
+
: ts.factory.createIntersectionTypeNode(intersection);
|
138
|
+
};
|
139
|
+
|
140
|
+
/* -----------------------------------------------------------
|
141
|
+
INSTANCES
|
142
|
+
----------------------------------------------------------- */
|
143
|
+
const writeArray =
|
144
|
+
(importer: ImportProgrammer) =>
|
145
|
+
(components: ISwaggerComponents) =>
|
146
|
+
(schema: ISwaggerSchema.IArray): ts.TypeNode => {
|
147
|
+
const intersection: ts.TypeNode[] = [
|
148
|
+
ts.factory.createArrayTypeNode(
|
149
|
+
write(importer)(components)(schema.items),
|
150
|
+
),
|
151
|
+
];
|
152
|
+
if (schema.minItems !== undefined)
|
153
|
+
intersection.push(importer.tag("MinItems", schema.minItems));
|
154
|
+
if (schema.maxItems !== undefined)
|
155
|
+
intersection.push(importer.tag("MaxItems", schema.maxItems));
|
156
|
+
return intersection.length === 1
|
157
|
+
? intersection[0]
|
158
|
+
: ts.factory.createIntersectionTypeNode(intersection);
|
159
|
+
};
|
160
|
+
|
161
|
+
const writeObject =
|
162
|
+
(importer: ImportProgrammer) =>
|
163
|
+
(components: ISwaggerComponents) =>
|
164
|
+
(schema: ISwaggerSchema.IObject): ts.TypeNode => {
|
165
|
+
const regular = () =>
|
166
|
+
ts.factory.createTypeLiteralNode(
|
167
|
+
Object.entries(schema.properties ?? []).map(([key, value]) =>
|
168
|
+
writeRegularProperty(importer)(components)(schema.required ?? [])(
|
169
|
+
key,
|
170
|
+
value,
|
171
|
+
),
|
172
|
+
),
|
173
|
+
);
|
174
|
+
const dynamic = () =>
|
175
|
+
ts.factory.createTypeLiteralNode([
|
176
|
+
writeDynamicProperty(importer)(components)(
|
177
|
+
schema.additionalProperties as ISwaggerSchema,
|
178
|
+
),
|
179
|
+
]);
|
180
|
+
return FilePrinter.description(
|
181
|
+
!!schema.properties?.length &&
|
182
|
+
typeof schema.additionalProperties === "object"
|
183
|
+
? ts.factory.createIntersectionTypeNode([regular(), dynamic()])
|
184
|
+
: typeof schema.additionalProperties === "object"
|
185
|
+
? dynamic()
|
186
|
+
: regular(),
|
187
|
+
writeComment(schema),
|
188
|
+
);
|
189
|
+
};
|
190
|
+
|
191
|
+
const writeRegularProperty =
|
192
|
+
(importer: ImportProgrammer) =>
|
193
|
+
(components: ISwaggerComponents) =>
|
194
|
+
(required: string[]) =>
|
195
|
+
(key: string, value: ISwaggerSchema) =>
|
196
|
+
FilePrinter.description(
|
197
|
+
ts.factory.createPropertySignature(
|
198
|
+
undefined,
|
199
|
+
Escaper.variable(key)
|
200
|
+
? ts.factory.createIdentifier(key)
|
201
|
+
: ts.factory.createStringLiteral(key),
|
202
|
+
required.includes(key)
|
203
|
+
? undefined
|
204
|
+
: ts.factory.createToken(ts.SyntaxKind.QuestionToken),
|
205
|
+
write(importer)(components)(value),
|
206
|
+
),
|
207
|
+
writeComment(value),
|
208
|
+
);
|
209
|
+
|
210
|
+
const writeDynamicProperty =
|
211
|
+
(importer: ImportProgrammer) =>
|
212
|
+
(components: ISwaggerComponents) =>
|
213
|
+
(value: ISwaggerSchema) =>
|
214
|
+
FilePrinter.description(
|
215
|
+
ts.factory.createIndexSignature(
|
216
|
+
undefined,
|
217
|
+
[
|
218
|
+
ts.factory.createParameterDeclaration(
|
219
|
+
undefined,
|
220
|
+
undefined,
|
221
|
+
ts.factory.createIdentifier("key"),
|
222
|
+
undefined,
|
223
|
+
TypeFactory.keyword("string"),
|
224
|
+
),
|
225
|
+
],
|
226
|
+
write(importer)(components)(value),
|
227
|
+
),
|
228
|
+
writeComment(value),
|
229
|
+
);
|
230
|
+
|
231
|
+
const writeReference =
|
232
|
+
(importer: ImportProgrammer) =>
|
233
|
+
(schema: ISwaggerSchema.IReference): ts.TypeReferenceNode =>
|
234
|
+
importer.dto(schema.$ref.split("/").at(-1)!);
|
235
|
+
|
236
|
+
/* -----------------------------------------------------------
|
237
|
+
UNIONS
|
238
|
+
----------------------------------------------------------- */
|
239
|
+
const writeUnion =
|
240
|
+
(importer: ImportProgrammer) =>
|
241
|
+
(components: ISwaggerComponents) =>
|
242
|
+
(elements: ISwaggerSchema[]): ts.UnionTypeNode =>
|
243
|
+
ts.factory.createUnionTypeNode(elements.map(write(importer)(components)));
|
337
244
|
}
|
338
|
-
|
339
|
-
const
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
])
|
245
|
+
const createNode = (text: string) => ts.factory.createTypeReferenceNode(text);
|
246
|
+
const writeComment = (schema: ISwaggerSchema): string =>
|
247
|
+
[
|
248
|
+
...(schema.description?.length ? [schema.description] : []),
|
249
|
+
...(schema.description?.length &&
|
250
|
+
(schema.title !== undefined || schema.deprecated === true)
|
251
|
+
? [""]
|
252
|
+
: []),
|
253
|
+
...(schema.title !== undefined ? [`@title ${schema.title}`] : []),
|
254
|
+
...(schema.deprecated === true ? [`@deprecated`] : []),
|
255
|
+
].join("\n");
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import { IMigrateRoute } from "./IMigrateRoute";
|
2
|
-
|
3
|
-
export interface IMigrateController {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
}
|
1
|
+
import { IMigrateRoute } from "./IMigrateRoute";
|
2
|
+
|
3
|
+
export interface IMigrateController {
|
4
|
+
name: string;
|
5
|
+
path: string;
|
6
|
+
location: string;
|
7
|
+
routes: IMigrateRoute[];
|
8
|
+
}
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import { ISwaggerSchema } from "./ISwaggeSchema";
|
2
|
-
|
3
|
-
export interface IMigrateDto {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
}
|
1
|
+
import { ISwaggerSchema } from "./ISwaggeSchema";
|
2
|
+
|
3
|
+
export interface IMigrateDto {
|
4
|
+
name: string;
|
5
|
+
location: string;
|
6
|
+
schema: ISwaggerSchema | null;
|
7
|
+
children: IMigrateDto[];
|
8
|
+
}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
export interface IMigrateFile {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
}
|
1
|
+
export interface IMigrateFile {
|
2
|
+
location: string;
|
3
|
+
file: string;
|
4
|
+
content: string;
|
5
|
+
}
|