@nestia/migrate 0.12.0 → 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 +5160 -947
- 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 +2 -2
- package/lib/bundles/NEST_TEMPLATE.js.map +1 -1
- package/lib/bundles/SDK_TEMPLATE.js +1 -1
- package/lib/bundles/SDK_TEMPLATE.js.map +1 -1
- package/lib/factories/TypeLiteralFactory.d.ts +4 -0
- package/lib/factories/TypeLiteralFactory.js +35 -0
- package/lib/factories/TypeLiteralFactory.js.map +1 -0
- 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/MigrateImportProgrammer.d.ts +1 -1
- package/lib/programmers/MigrateImportProgrammer.js +2 -4
- package/lib/programmers/MigrateImportProgrammer.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 +151 -28
- 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 +4 -3
- package/src/MigrateApplication.ts +81 -86
- package/src/analyzers/MigrateControllerAnalyzer.ts +7 -5
- package/src/analyzers/MigrateMethodAnalyzer.ts +103 -179
- package/src/bundles/NEST_TEMPLATE.ts +2 -2
- package/src/bundles/SDK_TEMPLATE.ts +1 -1
- package/src/factories/TypeLiteralFactory.ts +57 -0
- 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 -121
- 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 +355 -263
- 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 -75
- 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 -1568
- 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 -90
- 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,121 +1,117 @@
|
|
1
|
-
import ts from "typescript";
|
2
|
-
|
3
|
-
|
4
|
-
import { FilePrinter } from "../utils/FilePrinter";
|
5
|
-
import { MapUtil } from "../utils/MapUtil";
|
6
|
-
|
7
|
-
export class MigrateImportProgrammer {
|
8
|
-
private external_: Map<string, IClause> = new Map();
|
9
|
-
private dtos_: Set<string> = new Set();
|
10
|
-
|
11
|
-
public constructor() {}
|
12
|
-
|
13
|
-
public empty(): boolean {
|
14
|
-
return this.external_.size === 0 && this.dtos_.size === 0;
|
15
|
-
}
|
16
|
-
|
17
|
-
public external(props: MigrateImportProgrammer.IProps): string {
|
18
|
-
const clause: IClause = MapUtil.take(this.external_)(props.library)(() => ({
|
19
|
-
default: null,
|
20
|
-
instances: new Set(),
|
21
|
-
}));
|
22
|
-
const name: string = props.name.split(".")[0];
|
23
|
-
if (props.type === "default") clause.default = props.name;
|
24
|
-
else clause.instances.add(name);
|
25
|
-
return name;
|
26
|
-
}
|
27
|
-
|
28
|
-
public dto(name: string, namespace?: string): ts.TypeReferenceNode {
|
29
|
-
const file: string = name.split(".")[0];
|
30
|
-
this.dtos_.add(file);
|
31
|
-
return ts.factory.createTypeReferenceNode(
|
32
|
-
namespace?.length
|
33
|
-
? ts.factory.createQualifiedName(
|
34
|
-
ts.factory.createIdentifier(namespace),
|
35
|
-
ts.factory.createIdentifier(file),
|
36
|
-
)
|
37
|
-
: name,
|
38
|
-
);
|
39
|
-
}
|
40
|
-
|
41
|
-
public tag(type: string, arg:
|
42
|
-
const instance: string = this.external({
|
43
|
-
type: "instance",
|
44
|
-
library: "typia",
|
45
|
-
name: "tags",
|
46
|
-
});
|
47
|
-
return ts.factory.createTypeReferenceNode(`${instance}.${type}`, [
|
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
|
-
interface IClause {
|
119
|
-
default: string | null;
|
120
|
-
instances: Set<string>;
|
121
|
-
}
|
1
|
+
import ts from "typescript";
|
2
|
+
|
3
|
+
import { TypeLiteralFactory } from "../factories/TypeLiteralFactory";
|
4
|
+
import { FilePrinter } from "../utils/FilePrinter";
|
5
|
+
import { MapUtil } from "../utils/MapUtil";
|
6
|
+
|
7
|
+
export class MigrateImportProgrammer {
|
8
|
+
private external_: Map<string, IClause> = new Map();
|
9
|
+
private dtos_: Set<string> = new Set();
|
10
|
+
|
11
|
+
public constructor() {}
|
12
|
+
|
13
|
+
public empty(): boolean {
|
14
|
+
return this.external_.size === 0 && this.dtos_.size === 0;
|
15
|
+
}
|
16
|
+
|
17
|
+
public external(props: MigrateImportProgrammer.IProps): string {
|
18
|
+
const clause: IClause = MapUtil.take(this.external_)(props.library)(() => ({
|
19
|
+
default: null,
|
20
|
+
instances: new Set(),
|
21
|
+
}));
|
22
|
+
const name: string = props.name.split(".")[0];
|
23
|
+
if (props.type === "default") clause.default = props.name;
|
24
|
+
else clause.instances.add(name);
|
25
|
+
return name;
|
26
|
+
}
|
27
|
+
|
28
|
+
public dto(name: string, namespace?: string): ts.TypeReferenceNode {
|
29
|
+
const file: string = name.split(".")[0];
|
30
|
+
this.dtos_.add(file);
|
31
|
+
return ts.factory.createTypeReferenceNode(
|
32
|
+
namespace?.length
|
33
|
+
? ts.factory.createQualifiedName(
|
34
|
+
ts.factory.createIdentifier(namespace),
|
35
|
+
ts.factory.createIdentifier(file),
|
36
|
+
)
|
37
|
+
: name,
|
38
|
+
);
|
39
|
+
}
|
40
|
+
|
41
|
+
public tag(type: string, arg: any): ts.TypeReferenceNode {
|
42
|
+
const instance: string = this.external({
|
43
|
+
type: "instance",
|
44
|
+
library: "typia",
|
45
|
+
name: "tags",
|
46
|
+
});
|
47
|
+
return ts.factory.createTypeReferenceNode(`${instance}.${type}`, [
|
48
|
+
TypeLiteralFactory.generate(arg),
|
49
|
+
]);
|
50
|
+
}
|
51
|
+
|
52
|
+
public toStatements(
|
53
|
+
dtoPath: (name: string) => string,
|
54
|
+
current?: string,
|
55
|
+
): ts.Statement[] {
|
56
|
+
return [
|
57
|
+
...[...this.external_.entries()].map(([library, props]) =>
|
58
|
+
ts.factory.createImportDeclaration(
|
59
|
+
undefined,
|
60
|
+
ts.factory.createImportClause(
|
61
|
+
false,
|
62
|
+
props.default !== null
|
63
|
+
? ts.factory.createIdentifier(props.default)
|
64
|
+
: undefined,
|
65
|
+
props.instances.size
|
66
|
+
? ts.factory.createNamedImports(
|
67
|
+
[...props.instances].map((i) =>
|
68
|
+
ts.factory.createImportSpecifier(
|
69
|
+
false,
|
70
|
+
undefined,
|
71
|
+
ts.factory.createIdentifier(i),
|
72
|
+
),
|
73
|
+
),
|
74
|
+
)
|
75
|
+
: undefined,
|
76
|
+
),
|
77
|
+
ts.factory.createStringLiteral(library),
|
78
|
+
),
|
79
|
+
),
|
80
|
+
...(this.external_.size && this.dtos_.size
|
81
|
+
? [FilePrinter.newLine()]
|
82
|
+
: []),
|
83
|
+
...[...this.dtos_]
|
84
|
+
.filter(
|
85
|
+
current ? (name) => name !== current!.split(".")[0] : () => true,
|
86
|
+
)
|
87
|
+
.map((i) =>
|
88
|
+
ts.factory.createImportDeclaration(
|
89
|
+
undefined,
|
90
|
+
ts.factory.createImportClause(
|
91
|
+
false,
|
92
|
+
undefined,
|
93
|
+
ts.factory.createNamedImports([
|
94
|
+
ts.factory.createImportSpecifier(
|
95
|
+
false,
|
96
|
+
undefined,
|
97
|
+
ts.factory.createIdentifier(i),
|
98
|
+
),
|
99
|
+
]),
|
100
|
+
),
|
101
|
+
ts.factory.createStringLiteral(dtoPath(i)),
|
102
|
+
),
|
103
|
+
),
|
104
|
+
];
|
105
|
+
}
|
106
|
+
}
|
107
|
+
export namespace MigrateImportProgrammer {
|
108
|
+
export interface IProps {
|
109
|
+
type: "default" | "instance";
|
110
|
+
library: string;
|
111
|
+
name: string;
|
112
|
+
}
|
113
|
+
}
|
114
|
+
interface IClause {
|
115
|
+
default: string | null;
|
116
|
+
instances: Set<string>;
|
117
|
+
}
|
@@ -1,7 +1,7 @@
|
|
1
|
+
import { OpenApi } from "@samchon/openapi";
|
1
2
|
import ts from "typescript";
|
2
3
|
|
3
4
|
import { IMigrateController } from "../structures/IMigrateController";
|
4
|
-
import { ISwaggerComponents } from "../structures/ISwaggerComponents";
|
5
5
|
import { FilePrinter } from "../utils/FilePrinter";
|
6
6
|
import { StringUtil } from "../utils/StringUtil";
|
7
7
|
import { MigrateImportProgrammer } from "./MigrateImportProgrammer";
|
@@ -9,7 +9,7 @@ import { MigrateNestMethodProgrammer } from "./MigrateNestMethodProgrammer";
|
|
9
9
|
|
10
10
|
export namespace MigrateNestControllerProgrammer {
|
11
11
|
export const write =
|
12
|
-
(components:
|
12
|
+
(components: OpenApi.IComponents) =>
|
13
13
|
(controller: IMigrateController): ts.Statement[] => {
|
14
14
|
const importer: MigrateImportProgrammer = new MigrateImportProgrammer();
|
15
15
|
const $class = ts.factory.createClassDeclaration(
|
@@ -1,11 +1,10 @@
|
|
1
|
+
import { OpenApi } from "@samchon/openapi";
|
1
2
|
import ts from "typescript";
|
2
3
|
import { ExpressionFactory } from "typia/lib/factories/ExpressionFactory";
|
3
4
|
import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
|
4
5
|
import { TypeFactory } from "typia/lib/factories/TypeFactory";
|
5
6
|
|
6
7
|
import { IMigrateRoute } from "../structures/IMigrateRoute";
|
7
|
-
import { ISwaggerComponents } from "../structures/ISwaggerComponents";
|
8
|
-
import { ISwaggerSchema } from "../structures/ISwaggerSchema";
|
9
8
|
import { FilePrinter } from "../utils/FilePrinter";
|
10
9
|
import { StringUtil } from "../utils/StringUtil";
|
11
10
|
import { MigrateImportProgrammer } from "./MigrateImportProgrammer";
|
@@ -13,7 +12,7 @@ import { MigrateSchemaProgrammer } from "./MigrateSchemaProgrammer";
|
|
13
12
|
|
14
13
|
export namespace MigrateNestMethodProgrammer {
|
15
14
|
export const write =
|
16
|
-
(components:
|
15
|
+
(components: OpenApi.IComponents) =>
|
17
16
|
(importer: MigrateImportProgrammer) =>
|
18
17
|
(route: IMigrateRoute): ts.MethodDeclaration => {
|
19
18
|
const output: ts.TypeNode = route.success
|
@@ -75,7 +74,7 @@ export namespace MigrateNestMethodProgrammer {
|
|
75
74
|
].join("\n");
|
76
75
|
|
77
76
|
const writeMethodDecorators =
|
78
|
-
(components:
|
77
|
+
(components: OpenApi.IComponents) =>
|
79
78
|
(importer: MigrateImportProgrammer) =>
|
80
79
|
(route: IMigrateRoute): ts.Decorator[] => {
|
81
80
|
const external =
|
@@ -154,7 +153,7 @@ export namespace MigrateNestMethodProgrammer {
|
|
154
153
|
};
|
155
154
|
|
156
155
|
const writeParameters =
|
157
|
-
(components:
|
156
|
+
(components: OpenApi.IComponents) =>
|
158
157
|
(importer: MigrateImportProgrammer) =>
|
159
158
|
(route: IMigrateRoute): ts.ParameterDeclaration[] => [
|
160
159
|
...route.parameters.map(({ key, schema: value }) =>
|
@@ -216,9 +215,9 @@ export namespace MigrateNestMethodProgrammer {
|
|
216
215
|
|
217
216
|
const writeDtoParameter =
|
218
217
|
(accessor: { method: string | [string, string]; variable: string }) =>
|
219
|
-
(components:
|
218
|
+
(components: OpenApi.IComponents) =>
|
220
219
|
(importer: MigrateImportProgrammer) =>
|
221
|
-
(schema:
|
220
|
+
(schema: OpenApi.IJsonSchema): ts.ParameterDeclaration => {
|
222
221
|
const instance = ts.factory.createIdentifier(
|
223
222
|
importer.external({
|
224
223
|
type: "instance",
|
@@ -20,11 +20,11 @@ export namespace MigrateNestProgrammer {
|
|
20
20
|
location: c.location,
|
21
21
|
file: `${c.name}.ts`,
|
22
22
|
statements: MigrateNestControllerProgrammer.write(
|
23
|
-
program.
|
23
|
+
program.document.components,
|
24
24
|
)(c),
|
25
25
|
})),
|
26
26
|
...[
|
27
|
-
...MigrateDtoProgrammer.compose(program.
|
27
|
+
...MigrateDtoProgrammer.compose(program.document.components).entries(),
|
28
28
|
].map(([key, value]) => ({
|
29
29
|
location: "src/api/structures",
|
30
30
|
file: `${key}.ts`,
|