@nestia/migrate 0.12.1 → 0.13.0-dev.20240411
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/MigrateApplication.d.ts +3 -4
- package/lib/MigrateApplication.js +5157 -948
- package/lib/MigrateApplication.js.map +1 -1
- package/lib/analyzers/MigrateControllerAnalyzer.js +2 -1
- package/lib/analyzers/MigrateControllerAnalyzer.js.map +1 -1
- package/lib/analyzers/MigrateMethodAnalyzer.d.ts +2 -2
- package/lib/analyzers/MigrateMethodAnalyzer.js +60 -143
- package/lib/analyzers/MigrateMethodAnalyzer.js.map +1 -1
- package/lib/bundles/NEST_TEMPLATE.js +1 -1
- package/lib/factories/TypeLiteralFactory.js +3 -1
- package/lib/factories/TypeLiteralFactory.js.map +1 -1
- package/lib/internal/MigrateCommander.js +2 -2
- package/lib/internal/MigrateCommander.js.map +1 -1
- package/lib/module.d.ts +0 -6
- package/lib/module.js +0 -6
- package/lib/module.js.map +1 -1
- package/lib/programmers/MigrateApiFileProgrammer.d.ts +2 -2
- package/lib/programmers/MigrateApiFileProgrammer.js.map +1 -1
- package/lib/programmers/MigrateApiFunctionProgrammer.d.ts +3 -3
- package/lib/programmers/MigrateApiFunctionProgrammer.js.map +1 -1
- package/lib/programmers/MigrateApiNamespaceProgrammer.d.ts +2 -2
- package/lib/programmers/MigrateApiNamespaceProgrammer.js.map +1 -1
- package/lib/programmers/MigrateApiProgrammer.js +2 -2
- package/lib/programmers/MigrateApiProgrammer.js.map +1 -1
- package/lib/programmers/MigrateApiSimulatationProgrammer.d.ts +3 -3
- package/lib/programmers/MigrateApiSimulatationProgrammer.js.map +1 -1
- package/lib/programmers/MigrateApiStartProgrammer.js +8 -8
- package/lib/programmers/MigrateApiStartProgrammer.js.map +1 -1
- package/lib/programmers/MigrateDtoProgrammer.d.ts +2 -2
- package/lib/programmers/MigrateDtoProgrammer.js.map +1 -1
- package/lib/programmers/MigrateE2eFileProgrammer.d.ts +3 -3
- package/lib/programmers/MigrateE2eFileProgrammer.js.map +1 -1
- package/lib/programmers/MigrateE2eProgrammer.js +1 -1
- package/lib/programmers/MigrateE2eProgrammer.js.map +1 -1
- package/lib/programmers/MigrateNestControllerProgrammer.d.ts +2 -2
- package/lib/programmers/MigrateNestControllerProgrammer.js.map +1 -1
- package/lib/programmers/MigrateNestMethodProgrammer.d.ts +2 -2
- package/lib/programmers/MigrateNestMethodProgrammer.js.map +1 -1
- package/lib/programmers/MigrateNestProgrammer.js +2 -2
- package/lib/programmers/MigrateNestProgrammer.js.map +1 -1
- package/lib/programmers/MigrateSchemaProgrammer.d.ts +2 -3
- package/lib/programmers/MigrateSchemaProgrammer.js +81 -44
- package/lib/programmers/MigrateSchemaProgrammer.js.map +1 -1
- package/lib/structures/IMigrateDto.d.ts +2 -2
- package/lib/structures/IMigrateProgram.d.ts +3 -4
- package/lib/structures/IMigrateRoute.d.ts +6 -6
- package/lib/utils/OpenApiTypeChecker.d.ts +15 -0
- package/lib/utils/OpenApiTypeChecker.js +28 -0
- package/lib/utils/OpenApiTypeChecker.js.map +1 -0
- package/package.json +79 -78
- package/src/MigrateApplication.ts +8 -13
- package/src/analyzers/MigrateControllerAnalyzer.ts +7 -5
- package/src/analyzers/MigrateMethodAnalyzer.ts +103 -179
- package/src/bundles/NEST_TEMPLATE.ts +1 -1
- package/src/factories/TypeLiteralFactory.ts +8 -1
- package/src/internal/MigrateCommander.ts +4 -4
- package/src/module.ts +0 -6
- package/src/programmers/MigrateApiFileProgrammer.ts +2 -2
- package/src/programmers/MigrateApiFunctionProgrammer.ts +3 -3
- package/src/programmers/MigrateApiNamespaceProgrammer.ts +5 -5
- package/src/programmers/MigrateApiProgrammer.ts +4 -2
- package/src/programmers/MigrateApiSimulatationProgrammer.ts +4 -4
- package/src/programmers/MigrateApiStartProgrammer.ts +8 -8
- package/src/programmers/MigrateDtoProgrammer.ts +5 -6
- package/src/programmers/MigrateE2eFileProgrammer.ts +4 -4
- package/src/programmers/MigrateE2eProgrammer.ts +3 -3
- package/src/programmers/MigrateImportProgrammer.ts +117 -117
- package/src/programmers/MigrateNestControllerProgrammer.ts +2 -2
- package/src/programmers/MigrateNestMethodProgrammer.ts +6 -7
- package/src/programmers/MigrateNestProgrammer.ts +2 -2
- package/src/programmers/MigrateSchemaProgrammer.ts +102 -54
- package/src/structures/IMigrateDto.ts +2 -2
- package/src/structures/IMigrateProgram.ts +4 -4
- package/src/structures/IMigrateRoute.ts +6 -6
- package/src/utils/OpenApiTypeChecker.ts +73 -0
- package/lib/structures/ISwagger.d.ts +0 -18
- package/lib/structures/ISwagger.js +0 -3
- package/lib/structures/ISwagger.js.map +0 -1
- package/lib/structures/ISwaggerComponents.d.ts +0 -12
- package/lib/structures/ISwaggerComponents.js +0 -3
- package/lib/structures/ISwaggerComponents.js.map +0 -1
- package/lib/structures/ISwaggerInfo.d.ts +0 -71
- package/lib/structures/ISwaggerInfo.js +0 -3
- package/lib/structures/ISwaggerInfo.js.map +0 -1
- package/lib/structures/ISwaggerRoute.d.ts +0 -15
- package/lib/structures/ISwaggerRoute.js +0 -3
- package/lib/structures/ISwaggerRoute.js.map +0 -1
- package/lib/structures/ISwaggerRouteBodyContent.d.ts +0 -14
- package/lib/structures/ISwaggerRouteBodyContent.js +0 -3
- package/lib/structures/ISwaggerRouteBodyContent.js.map +0 -1
- package/lib/structures/ISwaggerRouteHeader.d.ts +0 -0
- package/lib/structures/ISwaggerRouteHeader.js +0 -2
- package/lib/structures/ISwaggerRouteHeader.js.map +0 -1
- package/lib/structures/ISwaggerRouteParameter.d.ts +0 -13
- package/lib/structures/ISwaggerRouteParameter.js +0 -3
- package/lib/structures/ISwaggerRouteParameter.js.map +0 -1
- package/lib/structures/ISwaggerRouteRequestBody.d.ts +0 -11
- package/lib/structures/ISwaggerRouteRequestBody.js +0 -3
- package/lib/structures/ISwaggerRouteRequestBody.js.map +0 -1
- package/lib/structures/ISwaggerRouteResponse.d.ts +0 -10
- package/lib/structures/ISwaggerRouteResponse.js +0 -3
- package/lib/structures/ISwaggerRouteResponse.js.map +0 -1
- package/lib/structures/ISwaggerSchema.d.ts +0 -76
- package/lib/structures/ISwaggerSchema.js +0 -3
- package/lib/structures/ISwaggerSchema.js.map +0 -1
- package/lib/structures/ISwaggerSecurityScheme.d.ts +0 -40
- package/lib/structures/ISwaggerSecurityScheme.js +0 -3
- package/lib/structures/ISwaggerSecurityScheme.js.map +0 -1
- package/lib/structures/ISwaggerV20.d.ts +0 -8
- package/lib/structures/ISwaggerV20.js +0 -3
- package/lib/structures/ISwaggerV20.js.map +0 -1
- package/lib/structures/ISwaggerV31.d.ts +0 -9
- package/lib/structures/ISwaggerV31.js +0 -3
- package/lib/structures/ISwaggerV31.js.map +0 -1
- package/lib/utils/OpenApiConverter.d.ts +0 -5
- package/lib/utils/OpenApiConverter.js +0 -1572
- package/lib/utils/OpenApiConverter.js.map +0 -1
- package/lib/utils/SwaggerComponentsExplorer.d.ts +0 -9
- package/lib/utils/SwaggerComponentsExplorer.js +0 -29
- package/lib/utils/SwaggerComponentsExplorer.js.map +0 -1
- package/lib/utils/SwaggerTypeChecker.d.ts +0 -16
- package/lib/utils/SwaggerTypeChecker.js +0 -34
- package/lib/utils/SwaggerTypeChecker.js.map +0 -1
- package/src/structures/ISwagger.ts +0 -23
- package/src/structures/ISwaggerComponents.ts +0 -13
- package/src/structures/ISwaggerInfo.ts +0 -80
- package/src/structures/ISwaggerRoute.ts +0 -20
- package/src/structures/ISwaggerRouteBodyContent.ts +0 -15
- package/src/structures/ISwaggerRouteHeader.ts +0 -0
- package/src/structures/ISwaggerRouteParameter.ts +0 -14
- package/src/structures/ISwaggerRouteRequestBody.ts +0 -12
- package/src/structures/ISwaggerRouteResponse.ts +0 -11
- package/src/structures/ISwaggerSchema.ts +0 -91
- package/src/structures/ISwaggerSecurityScheme.ts +0 -47
- package/src/structures/ISwaggerV20.ts +0 -10
- package/src/structures/ISwaggerV31.ts +0 -10
- package/src/utils/OpenApiConverter.ts +0 -19
- package/src/utils/SwaggerComponentsExplorer.ts +0 -43
- package/src/utils/SwaggerTypeChecker.ts +0 -67
@@ -1,14 +1,12 @@
|
|
1
|
+
import { OpenApi } from "@samchon/openapi";
|
1
2
|
import ts from "typescript";
|
2
3
|
import typia from "typia";
|
3
|
-
import { ExpressionFactory } from "typia/lib/factories/ExpressionFactory";
|
4
4
|
import { TypeFactory } from "typia/lib/factories/TypeFactory";
|
5
5
|
import { FormatCheatSheet } from "typia/lib/tags/internal/FormatCheatSheet";
|
6
6
|
import { Escaper } from "typia/lib/utils/Escaper";
|
7
7
|
|
8
|
-
import { ISwaggerComponents } from "../structures/ISwaggerComponents";
|
9
|
-
import { ISwaggerSchema } from "../structures/ISwaggerSchema";
|
10
8
|
import { FilePrinter } from "../utils/FilePrinter";
|
11
|
-
import {
|
9
|
+
import { OpenApiTypeChecker } from "../utils/OpenApiTypeChecker";
|
12
10
|
import { MigrateImportProgrammer } from "./MigrateImportProgrammer";
|
13
11
|
|
14
12
|
export namespace MigrateSchemaProgrammer {
|
@@ -16,42 +14,45 @@ export namespace MigrateSchemaProgrammer {
|
|
16
14
|
FACADE
|
17
15
|
----------------------------------------------------------- */
|
18
16
|
export const write =
|
19
|
-
(components:
|
17
|
+
(components: OpenApi.IComponents) =>
|
20
18
|
(importer: MigrateImportProgrammer) =>
|
21
|
-
(schema:
|
19
|
+
(schema: OpenApi.IJsonSchema): ts.TypeNode => {
|
20
|
+
// CONSIDER ANY TYPE CASE
|
22
21
|
const union: ts.TypeNode[] = [];
|
23
|
-
if (
|
22
|
+
if (OpenApiTypeChecker.isUnknown(schema))
|
24
23
|
return TypeFactory.keyword("any");
|
25
|
-
else if (SwaggerTypeChecker.isNullOnly(schema)) return createNode("null");
|
26
|
-
else if (SwaggerTypeChecker.isNullable(components)(schema))
|
27
|
-
union.push(createNode("null"));
|
28
24
|
|
25
|
+
// ITERATION
|
29
26
|
const type: ts.TypeNode = (() => {
|
30
27
|
// ATOMIC
|
31
|
-
if (
|
28
|
+
if (OpenApiTypeChecker.isConstant(schema))
|
29
|
+
return writeConstant(importer)(schema);
|
30
|
+
else if (OpenApiTypeChecker.isBoolean(schema))
|
32
31
|
return writeBoolean(importer)(schema);
|
33
|
-
else if (
|
32
|
+
else if (OpenApiTypeChecker.isInteger(schema))
|
34
33
|
return writeInteger(importer)(schema);
|
35
|
-
else if (
|
34
|
+
else if (OpenApiTypeChecker.isNumber(schema))
|
36
35
|
return writeNumber(importer)(schema);
|
37
|
-
|
38
|
-
else if (SwaggerTypeChecker.isString(schema))
|
36
|
+
else if (OpenApiTypeChecker.isString(schema))
|
39
37
|
return writeString(importer)(schema);
|
40
|
-
|
38
|
+
// INSTANCES
|
39
|
+
else if (OpenApiTypeChecker.isArray(schema))
|
41
40
|
return writeArray(components)(importer)(schema);
|
42
|
-
else if (
|
41
|
+
else if (OpenApiTypeChecker.isTuple(schema))
|
42
|
+
return writeTuple(components)(importer)(schema);
|
43
|
+
else if (OpenApiTypeChecker.isObject(schema))
|
43
44
|
return writeObject(components)(importer)(schema);
|
44
|
-
else if (
|
45
|
+
else if (OpenApiTypeChecker.isReference(schema))
|
45
46
|
return writeReference(importer)(schema);
|
46
|
-
//
|
47
|
-
else if (
|
48
|
-
return writeUnion(components)(importer)(schema.anyOf);
|
49
|
-
else if (SwaggerTypeChecker.isOneOf(schema))
|
47
|
+
// UNION
|
48
|
+
else if (OpenApiTypeChecker.isOneOf(schema))
|
50
49
|
return writeUnion(components)(importer)(schema.oneOf);
|
50
|
+
else if (OpenApiTypeChecker.isNull(schema)) return createNode("null");
|
51
51
|
else return TypeFactory.keyword("any");
|
52
52
|
})();
|
53
53
|
union.push(type);
|
54
54
|
|
55
|
+
// DETERMINE
|
55
56
|
if (union.length === 0) return TypeFactory.keyword("any");
|
56
57
|
else if (union.length === 1) return union[0];
|
57
58
|
return ts.factory.createUnionTypeNode(union);
|
@@ -60,17 +61,42 @@ export namespace MigrateSchemaProgrammer {
|
|
60
61
|
/* -----------------------------------------------------------
|
61
62
|
ATOMICS
|
62
63
|
----------------------------------------------------------- */
|
64
|
+
const writeConstant =
|
65
|
+
(importer: MigrateImportProgrammer) =>
|
66
|
+
(schema: OpenApi.IJsonSchema.IConstant): ts.TypeNode => {
|
67
|
+
const intersection: ts.TypeNode[] = [
|
68
|
+
ts.factory.createLiteralTypeNode(
|
69
|
+
typeof schema.const === "boolean"
|
70
|
+
? schema.const === true
|
71
|
+
? ts.factory.createTrue()
|
72
|
+
: ts.factory.createFalse()
|
73
|
+
: typeof schema.const === "number"
|
74
|
+
? schema.const < 0
|
75
|
+
? ts.factory.createPrefixUnaryExpression(
|
76
|
+
ts.SyntaxKind.MinusToken,
|
77
|
+
ts.factory.createNumericLiteral(-schema.const),
|
78
|
+
)
|
79
|
+
: ts.factory.createNumericLiteral(schema.const)
|
80
|
+
: ts.factory.createStringLiteral(schema.const),
|
81
|
+
),
|
82
|
+
];
|
83
|
+
writePlugin({
|
84
|
+
importer,
|
85
|
+
regular: typia.misc.literals<keyof OpenApi.IJsonSchema.IConstant>(),
|
86
|
+
intersection,
|
87
|
+
})(schema);
|
88
|
+
return intersection.length === 1
|
89
|
+
? intersection[0]
|
90
|
+
: ts.factory.createIntersectionTypeNode(intersection);
|
91
|
+
};
|
92
|
+
|
63
93
|
const writeBoolean =
|
64
94
|
(importer: MigrateImportProgrammer) =>
|
65
|
-
(schema:
|
66
|
-
if (schema.enum?.length)
|
67
|
-
return ts.factory.createLiteralTypeNode(
|
68
|
-
schema.enum[0] ? ts.factory.createTrue() : ts.factory.createFalse(),
|
69
|
-
);
|
95
|
+
(schema: OpenApi.IJsonSchema.IBoolean): ts.TypeNode => {
|
70
96
|
const intersection: ts.TypeNode[] = [TypeFactory.keyword("boolean")];
|
71
97
|
writePlugin({
|
72
98
|
importer,
|
73
|
-
regular: typia.misc.literals<keyof
|
99
|
+
regular: typia.misc.literals<keyof OpenApi.IJsonSchema.IBoolean>(),
|
74
100
|
intersection,
|
75
101
|
})(schema);
|
76
102
|
return intersection.length === 1
|
@@ -80,7 +106,7 @@ export namespace MigrateSchemaProgrammer {
|
|
80
106
|
|
81
107
|
const writeInteger =
|
82
108
|
(importer: MigrateImportProgrammer) =>
|
83
|
-
(schema:
|
109
|
+
(schema: OpenApi.IJsonSchema.IInteger): ts.TypeNode =>
|
84
110
|
writeNumeric(() => [
|
85
111
|
TypeFactory.keyword("number"),
|
86
112
|
importer.tag("Type", "int32"),
|
@@ -88,19 +114,15 @@ export namespace MigrateSchemaProgrammer {
|
|
88
114
|
|
89
115
|
const writeNumber =
|
90
116
|
(importer: MigrateImportProgrammer) =>
|
91
|
-
(schema:
|
117
|
+
(schema: OpenApi.IJsonSchema.INumber): ts.TypeNode =>
|
92
118
|
writeNumeric(() => [TypeFactory.keyword("number")])(importer)(schema);
|
93
119
|
|
94
120
|
const writeNumeric =
|
95
121
|
(factory: () => ts.TypeNode[]) =>
|
96
122
|
(importer: MigrateImportProgrammer) =>
|
97
|
-
(
|
98
|
-
|
99
|
-
|
100
|
-
schema.enum.map((i) =>
|
101
|
-
ts.factory.createLiteralTypeNode(ExpressionFactory.number(i)),
|
102
|
-
),
|
103
|
-
);
|
123
|
+
(
|
124
|
+
schema: OpenApi.IJsonSchema.IInteger | OpenApi.IJsonSchema.INumber,
|
125
|
+
): ts.TypeNode => {
|
104
126
|
const intersection: ts.TypeNode[] = factory();
|
105
127
|
if (schema.default !== undefined)
|
106
128
|
intersection.push(importer.tag("Default", schema.default));
|
@@ -122,7 +144,7 @@ export namespace MigrateSchemaProgrammer {
|
|
122
144
|
intersection.push(importer.tag("MultipleOf", schema.multipleOf));
|
123
145
|
writePlugin({
|
124
146
|
importer,
|
125
|
-
regular: typia.misc.literals<keyof
|
147
|
+
regular: typia.misc.literals<keyof OpenApi.IJsonSchema.INumber>(),
|
126
148
|
intersection,
|
127
149
|
})(schema);
|
128
150
|
return intersection.length === 1
|
@@ -132,7 +154,7 @@ export namespace MigrateSchemaProgrammer {
|
|
132
154
|
|
133
155
|
const writeString =
|
134
156
|
(importer: MigrateImportProgrammer) =>
|
135
|
-
(schema:
|
157
|
+
(schema: OpenApi.IJsonSchema.IString): ts.TypeNode => {
|
136
158
|
if (schema.format === "binary")
|
137
159
|
return ts.factory.createTypeReferenceNode("File");
|
138
160
|
|
@@ -157,7 +179,7 @@ export namespace MigrateSchemaProgrammer {
|
|
157
179
|
);
|
158
180
|
writePlugin({
|
159
181
|
importer,
|
160
|
-
regular: typia.misc.literals<keyof
|
182
|
+
regular: typia.misc.literals<keyof OpenApi.IJsonSchema.IString>(),
|
161
183
|
intersection,
|
162
184
|
})(schema);
|
163
185
|
return intersection.length === 1
|
@@ -169,9 +191,9 @@ export namespace MigrateSchemaProgrammer {
|
|
169
191
|
INSTANCES
|
170
192
|
----------------------------------------------------------- */
|
171
193
|
const writeArray =
|
172
|
-
(components:
|
194
|
+
(components: OpenApi.IComponents) =>
|
173
195
|
(importer: MigrateImportProgrammer) =>
|
174
|
-
(schema:
|
196
|
+
(schema: OpenApi.IJsonSchema.IArray): ts.TypeNode => {
|
175
197
|
const intersection: ts.TypeNode[] = [
|
176
198
|
ts.factory.createArrayTypeNode(
|
177
199
|
write(components)(importer)(schema.items),
|
@@ -183,7 +205,33 @@ export namespace MigrateSchemaProgrammer {
|
|
183
205
|
intersection.push(importer.tag("MaxItems", schema.maxItems));
|
184
206
|
writePlugin({
|
185
207
|
importer,
|
186
|
-
regular: typia.misc.literals<keyof
|
208
|
+
regular: typia.misc.literals<keyof OpenApi.IJsonSchema.IArray>(),
|
209
|
+
intersection,
|
210
|
+
})(schema);
|
211
|
+
return intersection.length === 1
|
212
|
+
? intersection[0]
|
213
|
+
: ts.factory.createIntersectionTypeNode(intersection);
|
214
|
+
};
|
215
|
+
|
216
|
+
const writeTuple =
|
217
|
+
(components: OpenApi.IComponents) =>
|
218
|
+
(importer: MigrateImportProgrammer) =>
|
219
|
+
(schema: OpenApi.IJsonSchema.ITuple): ts.TypeNode => {
|
220
|
+
const tuple: ts.TypeNode = ts.factory.createTupleTypeNode([
|
221
|
+
...schema.prefixItems.map(write(components)(importer)),
|
222
|
+
...(typeof schema.additionalItems === "object" &&
|
223
|
+
schema.additionalItems !== null
|
224
|
+
? [
|
225
|
+
ts.factory.createRestTypeNode(
|
226
|
+
write(components)(importer)(schema.additionalItems),
|
227
|
+
),
|
228
|
+
]
|
229
|
+
: []),
|
230
|
+
]);
|
231
|
+
const intersection: ts.TypeNode[] = [tuple];
|
232
|
+
writePlugin({
|
233
|
+
importer,
|
234
|
+
regular: typia.misc.literals<keyof OpenApi.IJsonSchema.ITuple>(),
|
187
235
|
intersection,
|
188
236
|
})(schema);
|
189
237
|
return intersection.length === 1
|
@@ -192,9 +240,9 @@ export namespace MigrateSchemaProgrammer {
|
|
192
240
|
};
|
193
241
|
|
194
242
|
const writeObject =
|
195
|
-
(components:
|
243
|
+
(components: OpenApi.IComponents) =>
|
196
244
|
(importer: MigrateImportProgrammer) =>
|
197
|
-
(schema:
|
245
|
+
(schema: OpenApi.IJsonSchema.IObject): ts.TypeNode => {
|
198
246
|
const regular = () =>
|
199
247
|
ts.factory.createTypeLiteralNode(
|
200
248
|
Object.entries(schema.properties ?? []).map(([key, value]) =>
|
@@ -207,7 +255,7 @@ export namespace MigrateSchemaProgrammer {
|
|
207
255
|
const dynamic = () =>
|
208
256
|
ts.factory.createTypeLiteralNode([
|
209
257
|
writeDynamicProperty(components)(importer)(
|
210
|
-
schema.additionalProperties as
|
258
|
+
schema.additionalProperties as OpenApi.IJsonSchema,
|
211
259
|
),
|
212
260
|
]);
|
213
261
|
return !!schema.properties?.length &&
|
@@ -219,10 +267,10 @@ export namespace MigrateSchemaProgrammer {
|
|
219
267
|
};
|
220
268
|
|
221
269
|
const writeRegularProperty =
|
222
|
-
(components:
|
270
|
+
(components: OpenApi.IComponents) =>
|
223
271
|
(importer: MigrateImportProgrammer) =>
|
224
272
|
(required: string[]) =>
|
225
|
-
(key: string, value:
|
273
|
+
(key: string, value: OpenApi.IJsonSchema) =>
|
226
274
|
FilePrinter.description(
|
227
275
|
ts.factory.createPropertySignature(
|
228
276
|
undefined,
|
@@ -238,9 +286,9 @@ export namespace MigrateSchemaProgrammer {
|
|
238
286
|
);
|
239
287
|
|
240
288
|
const writeDynamicProperty =
|
241
|
-
(components:
|
289
|
+
(components: OpenApi.IComponents) =>
|
242
290
|
(importer: MigrateImportProgrammer) =>
|
243
|
-
(value:
|
291
|
+
(value: OpenApi.IJsonSchema) =>
|
244
292
|
FilePrinter.description(
|
245
293
|
ts.factory.createIndexSignature(
|
246
294
|
undefined,
|
@@ -261,7 +309,7 @@ export namespace MigrateSchemaProgrammer {
|
|
261
309
|
const writeReference =
|
262
310
|
(importer: MigrateImportProgrammer) =>
|
263
311
|
(
|
264
|
-
schema:
|
312
|
+
schema: OpenApi.IJsonSchema.IReference,
|
265
313
|
): ts.TypeReferenceNode | ts.KeywordTypeNode => {
|
266
314
|
if (schema.$ref.startsWith("#/components/schemas") === false)
|
267
315
|
return TypeFactory.keyword("any");
|
@@ -275,13 +323,13 @@ export namespace MigrateSchemaProgrammer {
|
|
275
323
|
UNIONS
|
276
324
|
----------------------------------------------------------- */
|
277
325
|
const writeUnion =
|
278
|
-
(components:
|
326
|
+
(components: OpenApi.IComponents) =>
|
279
327
|
(importer: MigrateImportProgrammer) =>
|
280
|
-
(elements:
|
328
|
+
(elements: OpenApi.IJsonSchema[]): ts.UnionTypeNode =>
|
281
329
|
ts.factory.createUnionTypeNode(elements.map(write(components)(importer)));
|
282
330
|
}
|
283
331
|
const createNode = (text: string) => ts.factory.createTypeReferenceNode(text);
|
284
|
-
const writeComment = (schema:
|
332
|
+
const writeComment = (schema: OpenApi.IJsonSchema): string =>
|
285
333
|
[
|
286
334
|
...(schema.description?.length ? [schema.description] : []),
|
287
335
|
...(schema.description?.length &&
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import {
|
1
|
+
import { OpenApi } from "@samchon/openapi";
|
2
2
|
|
3
3
|
export interface IMigrateDto {
|
4
4
|
name: string;
|
5
5
|
location: string;
|
6
|
-
schema:
|
6
|
+
schema: OpenApi.IJsonSchema | null;
|
7
7
|
children: IMigrateDto[];
|
8
8
|
}
|
@@ -1,13 +1,13 @@
|
|
1
|
+
import { OpenApi } from "@samchon/openapi";
|
2
|
+
|
1
3
|
import { IMigrateController } from "./IMigrateController";
|
2
4
|
import { IMigrateRoute } from "./IMigrateRoute";
|
3
|
-
import { ISwagger } from "./ISwagger";
|
4
|
-
import { ISwaggerRoute } from "./ISwaggerRoute";
|
5
5
|
|
6
6
|
export interface IMigrateProgram extends IMigrateProgram.IProps {
|
7
7
|
controllers: IMigrateController[];
|
8
8
|
}
|
9
9
|
export namespace IMigrateProgram {
|
10
|
-
export type Dictionary = Map<
|
10
|
+
export type Dictionary = Map<OpenApi.IOperation, IEntry>;
|
11
11
|
export interface IEntry {
|
12
12
|
controller: IMigrateController;
|
13
13
|
route: IMigrateRoute;
|
@@ -16,7 +16,7 @@ export namespace IMigrateProgram {
|
|
16
16
|
mode: "nest" | "sdk";
|
17
17
|
simulate: boolean;
|
18
18
|
e2e: boolean;
|
19
|
-
|
19
|
+
document: OpenApi.IDocument;
|
20
20
|
dictionary: Dictionary;
|
21
21
|
}
|
22
22
|
export interface IConfig {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { OpenApi } from "@samchon/openapi";
|
2
2
|
|
3
3
|
export interface IMigrateRoute {
|
4
4
|
name: string;
|
@@ -20,18 +20,18 @@ export namespace IMigrateRoute {
|
|
20
20
|
export interface IParameter {
|
21
21
|
name: string;
|
22
22
|
key: string;
|
23
|
-
schema:
|
23
|
+
schema: OpenApi.IJsonSchema;
|
24
24
|
description?: string;
|
25
25
|
}
|
26
26
|
export interface IHeaders {
|
27
27
|
name: string;
|
28
28
|
key: string;
|
29
|
-
schema:
|
29
|
+
schema: OpenApi.IJsonSchema;
|
30
30
|
}
|
31
31
|
export interface IQuery {
|
32
32
|
name: string;
|
33
33
|
key: string;
|
34
|
-
schema:
|
34
|
+
schema: OpenApi.IJsonSchema;
|
35
35
|
}
|
36
36
|
export interface IBody {
|
37
37
|
name: string;
|
@@ -41,11 +41,11 @@ export namespace IMigrateRoute {
|
|
41
41
|
| "application/json"
|
42
42
|
| "application/x-www-form-urlencoded"
|
43
43
|
| "multipart/form-data";
|
44
|
-
schema:
|
44
|
+
schema: OpenApi.IJsonSchema;
|
45
45
|
"x-nestia-encrypted"?: boolean;
|
46
46
|
}
|
47
47
|
export interface IException {
|
48
48
|
description?: string;
|
49
|
-
schema:
|
49
|
+
schema: OpenApi.IJsonSchema;
|
50
50
|
}
|
51
51
|
}
|
@@ -0,0 +1,73 @@
|
|
1
|
+
import { OpenApi } from "@samchon/openapi";
|
2
|
+
|
3
|
+
export namespace OpenApiTypeChecker {
|
4
|
+
export const isOneOf = (
|
5
|
+
schema: OpenApi.IJsonSchema,
|
6
|
+
): schema is OpenApi.IJsonSchema.IOneOf =>
|
7
|
+
(schema as any).oneOf !== undefined;
|
8
|
+
|
9
|
+
export const isNull = (
|
10
|
+
schema: OpenApi.IJsonSchema,
|
11
|
+
): schema is OpenApi.IJsonSchema.INull =>
|
12
|
+
(schema as OpenApi.IJsonSchema.INull).type === "null";
|
13
|
+
|
14
|
+
export const isConstant = (
|
15
|
+
schema: OpenApi.IJsonSchema,
|
16
|
+
): schema is OpenApi.IJsonSchema.IConstant =>
|
17
|
+
(schema as OpenApi.IJsonSchema.IConstant).const !== undefined;
|
18
|
+
|
19
|
+
export const isBoolean = (
|
20
|
+
schema: OpenApi.IJsonSchema,
|
21
|
+
): schema is OpenApi.IJsonSchema.IBoolean =>
|
22
|
+
(schema as OpenApi.IJsonSchema.IBoolean).type === "boolean";
|
23
|
+
|
24
|
+
export const isInteger = (
|
25
|
+
schema: OpenApi.IJsonSchema,
|
26
|
+
): schema is OpenApi.IJsonSchema.IInteger =>
|
27
|
+
(schema as OpenApi.IJsonSchema.IInteger).type === "integer";
|
28
|
+
|
29
|
+
export const isNumber = (
|
30
|
+
schema: OpenApi.IJsonSchema,
|
31
|
+
): schema is OpenApi.IJsonSchema.INumber =>
|
32
|
+
(schema as OpenApi.IJsonSchema.INumber).type === "number";
|
33
|
+
|
34
|
+
export const isString = (
|
35
|
+
schema: OpenApi.IJsonSchema,
|
36
|
+
): schema is OpenApi.IJsonSchema.IString =>
|
37
|
+
(schema as OpenApi.IJsonSchema.IString).type === "string";
|
38
|
+
|
39
|
+
export const isArray = (
|
40
|
+
schema: OpenApi.IJsonSchema,
|
41
|
+
): schema is OpenApi.IJsonSchema.IArray =>
|
42
|
+
(schema as OpenApi.IJsonSchema.IArray).type === "array" &&
|
43
|
+
(schema as OpenApi.IJsonSchema.IArray).items !== undefined;
|
44
|
+
|
45
|
+
export const isTuple = (
|
46
|
+
schema: OpenApi.IJsonSchema,
|
47
|
+
): schema is OpenApi.IJsonSchema.ITuple =>
|
48
|
+
(schema as OpenApi.IJsonSchema.ITuple).type === "array" &&
|
49
|
+
(schema as OpenApi.IJsonSchema.ITuple).prefixItems !== undefined;
|
50
|
+
|
51
|
+
export const isObject = (
|
52
|
+
schema: OpenApi.IJsonSchema,
|
53
|
+
): schema is OpenApi.IJsonSchema.IObject =>
|
54
|
+
(schema as OpenApi.IJsonSchema.IObject).type === "object";
|
55
|
+
|
56
|
+
export const isReference = (
|
57
|
+
schema: OpenApi.IJsonSchema,
|
58
|
+
): schema is OpenApi.IJsonSchema.IReference =>
|
59
|
+
(schema as OpenApi.IJsonSchema.IReference).$ref !== undefined;
|
60
|
+
|
61
|
+
export const isUnknown = (
|
62
|
+
schema: OpenApi.IJsonSchema,
|
63
|
+
): schema is OpenApi.IJsonSchema.IUnknown =>
|
64
|
+
(schema as OpenApi.IJsonSchema.__ISignificant<any>).type === undefined &&
|
65
|
+
!isOneOf(schema) &&
|
66
|
+
!isReference(schema) &&
|
67
|
+
!isConstant(schema);
|
68
|
+
|
69
|
+
// export const isNullable = (schema: OpenApi.IJsonSchema): boolean =>
|
70
|
+
// SwaggerTypeChecker.isOneOf(schema)
|
71
|
+
// ? schema.oneOf.some(isNullable)
|
72
|
+
// : (schema as OpenApi.IJsonSchema.INullOnly).type === "null";
|
73
|
+
}
|
@@ -1,18 +0,0 @@
|
|
1
|
-
import { ISwaggerComponents } from "./ISwaggerComponents";
|
2
|
-
import { ISwaggerInfo } from "./ISwaggerInfo";
|
3
|
-
import { ISwaggerRoute } from "./ISwaggerRoute";
|
4
|
-
export interface ISwagger {
|
5
|
-
openapi: `3.0.${number}`;
|
6
|
-
info: ISwaggerInfo;
|
7
|
-
servers: ISwagger.IServer[];
|
8
|
-
components: ISwaggerComponents;
|
9
|
-
paths: Record<string, ISwagger.IPath>;
|
10
|
-
security?: Record<string, string[]>[];
|
11
|
-
}
|
12
|
-
export declare namespace ISwagger {
|
13
|
-
interface IServer {
|
14
|
-
url: string;
|
15
|
-
description?: string;
|
16
|
-
}
|
17
|
-
type IPath = Record<"get" | "post" | "patch" | "put" | "delete", ISwaggerRoute | undefined>;
|
18
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"ISwagger.js","sourceRoot":"","sources":["../../src/structures/ISwagger.ts"],"names":[],"mappings":""}
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import { ISwaggerRouteParameter } from "./ISwaggerRouteParameter";
|
2
|
-
import { ISwaggerRouteRequestBody } from "./ISwaggerRouteRequestBody";
|
3
|
-
import { ISwaggerRouteResponse } from "./ISwaggerRouteResponse";
|
4
|
-
import { ISwaggerSchema } from "./ISwaggerSchema";
|
5
|
-
import { ISwaggerSecurityScheme } from "./ISwaggerSecurityScheme";
|
6
|
-
export interface ISwaggerComponents {
|
7
|
-
parameters?: Record<string, ISwaggerRouteParameter>;
|
8
|
-
requestBodies?: Record<string, ISwaggerRouteRequestBody>;
|
9
|
-
responses?: Record<string, ISwaggerRouteResponse>;
|
10
|
-
schemas?: Record<string, ISwaggerSchema>;
|
11
|
-
securitySchemes?: Record<string, ISwaggerSecurityScheme>;
|
12
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"ISwaggerComponents.js","sourceRoot":"","sources":["../../src/structures/ISwaggerComponents.ts"],"names":[],"mappings":""}
|
@@ -1,71 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Information about the API.
|
3
|
-
*
|
4
|
-
* @author Samchon
|
5
|
-
*/
|
6
|
-
export interface ISwaggerInfo {
|
7
|
-
/**
|
8
|
-
* The title of the API.
|
9
|
-
*/
|
10
|
-
title: string;
|
11
|
-
/**
|
12
|
-
* A short description of the API.
|
13
|
-
*/
|
14
|
-
description?: string;
|
15
|
-
/**
|
16
|
-
* A URL to the Terms of Service for the API.
|
17
|
-
*
|
18
|
-
* @format uri
|
19
|
-
*/
|
20
|
-
termsOfService?: string;
|
21
|
-
/**
|
22
|
-
* The contact information for the exposed API.
|
23
|
-
*/
|
24
|
-
contact?: ISwaggerInfo.IContact;
|
25
|
-
/**
|
26
|
-
* The license information for the exposed API.
|
27
|
-
*/
|
28
|
-
license?: ISwaggerInfo.ILicense;
|
29
|
-
/**
|
30
|
-
* Version of the API.
|
31
|
-
*/
|
32
|
-
version: string;
|
33
|
-
}
|
34
|
-
export declare namespace ISwaggerInfo {
|
35
|
-
/**
|
36
|
-
* Contact information for the exposed API.
|
37
|
-
*/
|
38
|
-
interface IContact {
|
39
|
-
/**
|
40
|
-
* The identifying name of the contact person/organization.
|
41
|
-
*/
|
42
|
-
name?: string;
|
43
|
-
/**
|
44
|
-
* The URL pointing to the contact information.
|
45
|
-
*
|
46
|
-
* @format uri
|
47
|
-
*/
|
48
|
-
url?: string;
|
49
|
-
/**
|
50
|
-
* The email address of the contact person/organization.
|
51
|
-
*
|
52
|
-
* @format email
|
53
|
-
*/
|
54
|
-
email?: string;
|
55
|
-
}
|
56
|
-
/**
|
57
|
-
* License information for the exposed API.
|
58
|
-
*/
|
59
|
-
interface ILicense {
|
60
|
-
/**
|
61
|
-
* The license name used for the API.
|
62
|
-
*/
|
63
|
-
name: string;
|
64
|
-
/**
|
65
|
-
* A URL to the license used for the API.
|
66
|
-
*
|
67
|
-
* @format uri
|
68
|
-
*/
|
69
|
-
url?: string;
|
70
|
-
}
|
71
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"ISwaggerInfo.js","sourceRoot":"","sources":["../../src/structures/ISwaggerInfo.ts"],"names":[],"mappings":""}
|
@@ -1,15 +0,0 @@
|
|
1
|
-
import { IJsDocTagInfo } from "typia/lib/schemas/metadata/IJsDocTagInfo";
|
2
|
-
import { ISwaggerRouteParameter } from "./ISwaggerRouteParameter";
|
3
|
-
import { ISwaggerRouteRequestBody } from "./ISwaggerRouteRequestBody";
|
4
|
-
import { ISwaggerRouteResponse } from "./ISwaggerRouteResponse";
|
5
|
-
export interface ISwaggerRoute {
|
6
|
-
parameters?: (ISwaggerRouteParameter | ISwaggerRouteParameter.IReference)[];
|
7
|
-
requestBody?: ISwaggerRouteRequestBody;
|
8
|
-
responses?: Record<string, ISwaggerRouteResponse | ISwaggerRouteResponse.IReference>;
|
9
|
-
summary?: string;
|
10
|
-
description?: string;
|
11
|
-
deprecated?: boolean;
|
12
|
-
security?: Record<string, string[]>[];
|
13
|
-
tags?: string[];
|
14
|
-
"x-nestia-jsDocTags"?: IJsDocTagInfo[];
|
15
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"ISwaggerRoute.js","sourceRoot":"","sources":["../../src/structures/ISwaggerRoute.ts"],"names":[],"mappings":""}
|
@@ -1,14 +0,0 @@
|
|
1
|
-
import { ISwaggerSchema } from "./ISwaggerSchema";
|
2
|
-
export interface ISwaggerRouteBodyContent {
|
3
|
-
"text/plain"?: ISwaggerRouteBodyContent.IMediaType;
|
4
|
-
"application/json"?: ISwaggerRouteBodyContent.IMediaType;
|
5
|
-
"application/x-www-form-urlencoded"?: ISwaggerRouteBodyContent.IMediaType;
|
6
|
-
"multipart/form-data"?: ISwaggerRouteBodyContent.IMediaType;
|
7
|
-
"*/*"?: ISwaggerRouteBodyContent.IMediaType;
|
8
|
-
}
|
9
|
-
export declare namespace ISwaggerRouteBodyContent {
|
10
|
-
interface IMediaType {
|
11
|
-
schema?: ISwaggerSchema;
|
12
|
-
"x-nestia-encrypted"?: boolean;
|
13
|
-
}
|
14
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"ISwaggerRouteBodyContent.js","sourceRoot":"","sources":["../../src/structures/ISwaggerRouteBodyContent.ts"],"names":[],"mappings":""}
|
File without changes
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"ISwaggerRouteHeader.js","sourceRoot":"","sources":["../../src/structures/ISwaggerRouteHeader.ts"],"names":[],"mappings":""}
|
@@ -1,13 +0,0 @@
|
|
1
|
-
import { ISwaggerSchema } from "./ISwaggerSchema";
|
2
|
-
export interface ISwaggerRouteParameter {
|
3
|
-
name?: string;
|
4
|
-
in: "path" | "query" | "header" | "cookie";
|
5
|
-
schema: ISwaggerSchema;
|
6
|
-
required?: boolean;
|
7
|
-
description?: string;
|
8
|
-
}
|
9
|
-
export declare namespace ISwaggerRouteParameter {
|
10
|
-
interface IReference {
|
11
|
-
$ref: `#/components/parameters/${string}`;
|
12
|
-
}
|
13
|
-
}
|