@nestia/migrate 0.7.5 → 0.7.6
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 +9 -2
- package/lib/MigrateApplication.js +14 -8
- package/lib/MigrateApplication.js.map +1 -1
- package/lib/analyzers/MigrateAnalyzer.js +2 -2
- package/lib/analyzers/MigrateAnalyzer.js.map +1 -1
- package/lib/analyzers/{ControllerAnalyzer.d.ts → MigrateControllerAnalyzer.d.ts} +1 -1
- package/lib/analyzers/{ControllerAnalyzer.js → MigrateControllerAnalyzer.js} +11 -9
- package/lib/analyzers/MigrateControllerAnalyzer.js.map +1 -0
- package/lib/analyzers/{MethodAnalyzer.d.ts → MigrateMethodAnalyzer.d.ts} +1 -1
- package/lib/analyzers/{MethodAnalyzer.js → MigrateMethodAnalyzer.js} +26 -25
- package/lib/analyzers/MigrateMethodAnalyzer.js.map +1 -0
- package/lib/archivers/{FileArchiver.d.ts → MigrateFileArchiver.d.ts} +1 -1
- package/lib/archivers/{FileArchiver.js → MigrateFileArchiver.js} +6 -6
- package/lib/archivers/MigrateFileArchiver.js.map +1 -0
- package/lib/bundles/SDK_TEMPLATE.js +0 -5
- package/lib/bundles/SDK_TEMPLATE.js.map +1 -1
- package/lib/executable/bundle.js +1 -0
- package/lib/executable/bundle.js.map +1 -1
- package/lib/internal/MigrateCommander.js +3 -3
- package/lib/internal/MigrateCommander.js.map +1 -1
- package/lib/programmers/{ApiFileProgrammer.d.ts → MigrateApiFileProgrammer.d.ts} +1 -1
- package/lib/programmers/MigrateApiFileProgrammer.js +28 -0
- package/lib/programmers/MigrateApiFileProgrammer.js.map +1 -0
- package/lib/programmers/{ApiFunctionProgrammer.d.ts → MigrateApiFunctionProgrammer.d.ts} +4 -4
- package/lib/programmers/{ApiFunctionProgrammer.js → MigrateApiFunctionProgrammer.js} +10 -10
- package/lib/programmers/MigrateApiFunctionProgrammer.js.map +1 -0
- package/lib/programmers/{ApiNamespaceProgrammer.d.ts → MigrateApiNamespaceProgrammer.d.ts} +3 -3
- package/lib/programmers/{ApiNamespaceProgrammer.js → MigrateApiNamespaceProgrammer.js} +19 -19
- package/lib/programmers/MigrateApiNamespaceProgrammer.js.map +1 -0
- package/lib/programmers/{ApiProgrammer.d.ts → MigrateApiProgrammer.d.ts} +1 -1
- package/lib/programmers/{ApiProgrammer.js → MigrateApiProgrammer.js} +25 -20
- package/lib/programmers/MigrateApiProgrammer.js.map +1 -0
- package/lib/programmers/{ApiSimulatationProgrammer.d.ts → MigrateApiSimulatationProgrammer.d.ts} +4 -4
- package/lib/programmers/{ApiSimulatationProgrammer.js → MigrateApiSimulatationProgrammer.js} +16 -16
- package/lib/programmers/MigrateApiSimulatationProgrammer.js.map +1 -0
- package/lib/programmers/{DtoProgrammer.d.ts → MigrateDtoProgrammer.d.ts} +3 -3
- package/lib/programmers/{DtoProgrammer.js → MigrateDtoProgrammer.js} +8 -8
- package/lib/programmers/MigrateDtoProgrammer.js.map +1 -0
- package/lib/programmers/{ImportProgrammer.d.ts → MigrateImportProgrammer.d.ts} +3 -3
- package/lib/programmers/{ImportProgrammer.js → MigrateImportProgrammer.js} +7 -5
- package/lib/programmers/MigrateImportProgrammer.js.map +1 -0
- package/lib/programmers/{NestControllerProgrammer.d.ts → MigrateNestControllerProgrammer.d.ts} +1 -1
- package/lib/programmers/{NestControllerProgrammer.js → MigrateNestControllerProgrammer.js} +11 -11
- package/lib/programmers/MigrateNestControllerProgrammer.js.map +1 -0
- package/lib/programmers/{NestMethodProgrammer.d.ts → MigrateNestMethodProgrammer.d.ts} +3 -3
- package/lib/programmers/{NestMethodProgrammer.js → MigrateNestMethodProgrammer.js} +13 -11
- package/lib/programmers/MigrateNestMethodProgrammer.js.map +1 -0
- package/lib/programmers/{NestModuleProgrammer.d.ts → MigrateNestModuleProgrammer.d.ts} +1 -1
- package/lib/programmers/{NestModuleProgrammer.js → MigrateNestModuleProgrammer.js} +8 -8
- package/lib/programmers/MigrateNestModuleProgrammer.js.map +1 -0
- package/lib/programmers/{NestProgrammer.d.ts → MigrateNestProgrammer.d.ts} +1 -1
- package/lib/programmers/{NestProgrammer.js → MigrateNestProgrammer.js} +17 -15
- package/lib/programmers/MigrateNestProgrammer.js.map +1 -0
- package/lib/programmers/{SchemaProgrammer.d.ts → MigrateSchemaProgrammer.d.ts} +3 -3
- package/lib/programmers/{SchemaProgrammer.js → MigrateSchemaProgrammer.js} +23 -23
- package/lib/programmers/MigrateSchemaProgrammer.js.map +1 -0
- package/lib/structures/IMigrateRoute.d.ts +1 -0
- package/lib/utils/FilePrinter.d.ts +1 -1
- package/lib/utils/FilePrinter.js +1 -1
- package/lib/utils/FilePrinter.js.map +1 -1
- package/lib/utils/{JsonTypeChecker.d.ts → SwaggerTypeChecker.d.ts} +1 -1
- package/lib/utils/SwaggerTypeChecker.js +34 -0
- package/lib/utils/SwaggerTypeChecker.js.map +1 -0
- package/package.json +68 -68
- package/src/IMigrateConfig.ts +4 -4
- package/src/MigrateApplication.ts +48 -35
- package/src/analyzers/MigrateAnalyzer.ts +13 -13
- package/src/analyzers/{ControllerAnalyzer.ts → MigrateControllerAnalyzer.ts} +122 -123
- package/src/analyzers/{MethodAnalyzer.ts → MigrateMethodAnalyzer.ts} +348 -347
- package/src/archivers/{FileArchiver.ts → MigrateFileArchiver.ts} +38 -38
- package/src/bundles/SDK_TEMPLATE.ts +0 -5
- package/src/executable/bundle.ts +109 -108
- package/src/executable/migrate.ts +7 -7
- package/src/internal/MigrateCommander.ts +51 -52
- package/src/internal/MigrateInquirer.ts +79 -79
- package/src/module.ts +4 -4
- package/src/programmers/{ApiFileProgrammer.ts → MigrateApiFileProgrammer.ts} +53 -53
- package/src/programmers/{ApiFunctionProgrammer.ts → MigrateApiFunctionProgrammer.ts} +203 -203
- package/src/programmers/{ApiNamespaceProgrammer.ts → MigrateApiNamespaceProgrammer.ts} +430 -418
- package/src/programmers/{ApiProgrammer.ts → MigrateApiProgrammer.ts} +132 -128
- package/src/programmers/{ApiSimulatationProgrammer.ts → MigrateApiSimulatationProgrammer.ts} +328 -328
- package/src/programmers/{DtoProgrammer.ts → MigrateDtoProgrammer.ts} +78 -74
- package/src/programmers/{ImportProgrammer.ts → MigrateImportProgrammer.ts} +116 -114
- package/src/programmers/{NestControllerProgrammer.ts → MigrateNestControllerProgrammer.ts} +50 -48
- package/src/programmers/{NestMethodProgrammer.ts → MigrateNestMethodProgrammer.ts} +249 -243
- package/src/programmers/{NestModuleProgrammer.ts → MigrateNestModuleProgrammer.ts} +62 -62
- package/src/programmers/{NestProgrammer.ts → MigrateNestProgrammer.ts} +74 -74
- package/src/programmers/{SchemaProgrammer.ts → MigrateSchemaProgrammer.ts} +257 -255
- package/src/structures/IMigrateProgram.ts +9 -9
- package/src/structures/IMigrateRoute.ts +46 -45
- package/src/structures/ISwaggeSchema.ts +90 -90
- package/src/structures/ISwaggerInfo.ts +80 -80
- package/src/utils/FilePrinter.ts +36 -36
- package/src/utils/SetupWizard.ts +12 -12
- package/src/utils/StringUtil.ts +60 -60
- package/src/utils/{JsonTypeChecker.ts → SwaggerTypeChecker.ts} +67 -67
- package/lib/analyzers/ControllerAnalyzer.js.map +0 -1
- package/lib/analyzers/MethodAnalyzer.js.map +0 -1
- package/lib/archivers/FileArchiver.js.map +0 -1
- package/lib/programmers/ApiFileProgrammer.js +0 -28
- package/lib/programmers/ApiFileProgrammer.js.map +0 -1
- package/lib/programmers/ApiFunctionProgrammer.js.map +0 -1
- package/lib/programmers/ApiNamespaceProgrammer.js.map +0 -1
- package/lib/programmers/ApiProgrammer.js.map +0 -1
- package/lib/programmers/ApiSimulatationProgrammer.js.map +0 -1
- package/lib/programmers/DtoProgrammer.js.map +0 -1
- package/lib/programmers/ImportProgrammer.js.map +0 -1
- package/lib/programmers/NestControllerProgrammer.js.map +0 -1
- package/lib/programmers/NestMethodProgrammer.js.map +0 -1
- package/lib/programmers/NestModuleProgrammer.js.map +0 -1
- package/lib/programmers/NestProgrammer.js.map +0 -1
- package/lib/programmers/SchemaProgrammer.js.map +0 -1
- package/lib/utils/JsonTypeChecker.js +0 -34
- package/lib/utils/JsonTypeChecker.js.map +0 -1
@@ -1,74 +1,78 @@
|
|
1
|
-
import { IPointer } from "tstl";
|
2
|
-
import ts from "typescript";
|
3
|
-
|
4
|
-
import { ISwaggerSchema } from "../structures/ISwaggeSchema";
|
5
|
-
import { ISwaggerComponents } from "../structures/ISwaggerComponents";
|
6
|
-
import { FilePrinter } from "../utils/FilePrinter";
|
7
|
-
import { MapUtil } from "../utils/MapUtil";
|
8
|
-
import {
|
9
|
-
import {
|
10
|
-
|
11
|
-
export namespace
|
12
|
-
export interface IModule {
|
13
|
-
name: string;
|
14
|
-
children: Map<string, IModule>;
|
15
|
-
programmer:
|
16
|
-
| null
|
17
|
-
| ((importer:
|
18
|
-
}
|
19
|
-
|
20
|
-
export const write = (
|
21
|
-
components: ISwaggerComponents,
|
22
|
-
): Map<string, IModule> => {
|
23
|
-
const dict: Map<string, IModule> = new Map();
|
24
|
-
for (const [key, value] of Object.entries(components.schemas ?? {}))
|
25
|
-
prepare(dict)(key)((importer) =>
|
26
|
-
writeAlias(components)(importer)(key, value),
|
27
|
-
);
|
28
|
-
return dict;
|
29
|
-
};
|
30
|
-
|
31
|
-
const prepare =
|
32
|
-
(dict: Map<string, IModule>) =>
|
33
|
-
(name: string) =>
|
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
|
-
...(schema.
|
73
|
-
|
74
|
-
|
1
|
+
import { IPointer } from "tstl";
|
2
|
+
import ts from "typescript";
|
3
|
+
|
4
|
+
import { ISwaggerSchema } from "../structures/ISwaggeSchema";
|
5
|
+
import { ISwaggerComponents } from "../structures/ISwaggerComponents";
|
6
|
+
import { FilePrinter } from "../utils/FilePrinter";
|
7
|
+
import { MapUtil } from "../utils/MapUtil";
|
8
|
+
import { MigrateImportProgrammer } from "./MigrateImportProgrammer";
|
9
|
+
import { MigrateSchemaProgrammer } from "./MigrateSchemaProgrammer";
|
10
|
+
|
11
|
+
export namespace MigrateDtoProgrammer {
|
12
|
+
export interface IModule {
|
13
|
+
name: string;
|
14
|
+
children: Map<string, IModule>;
|
15
|
+
programmer:
|
16
|
+
| null
|
17
|
+
| ((importer: MigrateImportProgrammer) => ts.TypeAliasDeclaration);
|
18
|
+
}
|
19
|
+
|
20
|
+
export const write = (
|
21
|
+
components: ISwaggerComponents,
|
22
|
+
): Map<string, IModule> => {
|
23
|
+
const dict: Map<string, IModule> = new Map();
|
24
|
+
for (const [key, value] of Object.entries(components.schemas ?? {}))
|
25
|
+
prepare(dict)(key)((importer) =>
|
26
|
+
writeAlias(components)(importer)(key, value),
|
27
|
+
);
|
28
|
+
return dict;
|
29
|
+
};
|
30
|
+
|
31
|
+
const prepare =
|
32
|
+
(dict: Map<string, IModule>) =>
|
33
|
+
(name: string) =>
|
34
|
+
(
|
35
|
+
programmer: (
|
36
|
+
importer: MigrateImportProgrammer,
|
37
|
+
) => ts.TypeAliasDeclaration,
|
38
|
+
) => {
|
39
|
+
const accessors: string[] = name.split(".");
|
40
|
+
const modulo: IPointer<IModule> = { value: null! };
|
41
|
+
|
42
|
+
accessors.forEach((acc, i) => {
|
43
|
+
modulo.value = MapUtil.take(dict)(acc)(() => ({
|
44
|
+
name: acc,
|
45
|
+
children: new Map(),
|
46
|
+
programmer: null,
|
47
|
+
}));
|
48
|
+
if (i === accessors.length - 1) modulo.value.programmer = programmer;
|
49
|
+
dict = modulo.value.children;
|
50
|
+
});
|
51
|
+
return modulo!;
|
52
|
+
};
|
53
|
+
|
54
|
+
const writeAlias =
|
55
|
+
(components: ISwaggerComponents) =>
|
56
|
+
(importer: MigrateImportProgrammer) =>
|
57
|
+
(key: string, value: ISwaggerSchema) =>
|
58
|
+
FilePrinter.description(
|
59
|
+
ts.factory.createTypeAliasDeclaration(
|
60
|
+
[ts.factory.createToken(ts.SyntaxKind.ExportKeyword)],
|
61
|
+
key.split(".").at(-1)!,
|
62
|
+
[],
|
63
|
+
MigrateSchemaProgrammer.write(components)(importer)(value),
|
64
|
+
),
|
65
|
+
writeComment(value),
|
66
|
+
);
|
67
|
+
}
|
68
|
+
|
69
|
+
const writeComment = (schema: ISwaggerSchema): string =>
|
70
|
+
[
|
71
|
+
...(schema.description?.length ? [schema.description] : []),
|
72
|
+
...(schema.description?.length &&
|
73
|
+
(schema.title !== undefined || schema.deprecated === true)
|
74
|
+
? [""]
|
75
|
+
: []),
|
76
|
+
...(schema.title !== undefined ? [`@title ${schema.title}`] : []),
|
77
|
+
...(schema.deprecated === true ? [`@deprecated`] : []),
|
78
|
+
].join("\n");
|
@@ -1,114 +1,116 @@
|
|
1
|
-
import ts from "typescript";
|
2
|
-
import { ExpressionFactory } from "typia/lib/factories/ExpressionFactory";
|
3
|
-
|
4
|
-
import { FilePrinter } from "../utils/FilePrinter";
|
5
|
-
import { MapUtil } from "../utils/MapUtil";
|
6
|
-
|
7
|
-
export class
|
8
|
-
private external_: Map<
|
9
|
-
string,
|
10
|
-
{
|
11
|
-
default: string | null;
|
12
|
-
instances: Set<string>;
|
13
|
-
}
|
14
|
-
> = new Map();
|
15
|
-
private dtos_: Set<string> = new Set();
|
16
|
-
|
17
|
-
public constructor() {}
|
18
|
-
|
19
|
-
public empty(): boolean {
|
20
|
-
return this.external_.size === 0 && this.dtos_.size === 0;
|
21
|
-
}
|
22
|
-
|
23
|
-
public external(props:
|
24
|
-
const element = MapUtil.take(this.external_)(props.library)(() => ({
|
25
|
-
default: null,
|
26
|
-
instances: new Set(),
|
27
|
-
}));
|
28
|
-
const name: string = props.name.split(".")[0];
|
29
|
-
if (props.type === "default") element.default = props.name;
|
30
|
-
else element.instances.add(name);
|
31
|
-
return name;
|
32
|
-
}
|
33
|
-
|
34
|
-
public dto(name: string): ts.TypeReferenceNode {
|
35
|
-
const file: string = name.split(".")[0];
|
36
|
-
this.dtos_.add(file);
|
37
|
-
return ts.factory.createTypeReferenceNode(name);
|
38
|
-
}
|
39
|
-
|
40
|
-
public tag(type: string, arg: number | string): ts.TypeReferenceNode {
|
41
|
-
this.external({
|
42
|
-
type: "instance",
|
43
|
-
library: "typia",
|
44
|
-
name: "tags",
|
45
|
-
});
|
46
|
-
return ts.factory.createTypeReferenceNode(`tags.${type}`, [
|
47
|
-
ts.factory.createLiteralTypeNode(
|
48
|
-
typeof arg === "string"
|
49
|
-
? ts.factory.createStringLiteral(arg)
|
50
|
-
: ExpressionFactory.number(arg),
|
51
|
-
),
|
52
|
-
]);
|
53
|
-
}
|
54
|
-
|
55
|
-
public toStatements(
|
56
|
-
dtoPath: (name: string) => string,
|
57
|
-
current?: string,
|
58
|
-
): ts.Statement[] {
|
59
|
-
return [
|
60
|
-
...[...this.external_.entries()].map(([library, props]) => {
|
61
|
-
return ts.factory.createImportDeclaration(
|
62
|
-
undefined,
|
63
|
-
ts.factory.createImportClause(
|
64
|
-
false,
|
65
|
-
props.default !== null
|
66
|
-
? ts.factory.createIdentifier(props.default)
|
67
|
-
: undefined,
|
68
|
-
props.instances.size
|
69
|
-
? ts.factory.createNamedImports(
|
70
|
-
[...props.instances].map((i) =>
|
71
|
-
ts.factory.createImportSpecifier(
|
72
|
-
false,
|
73
|
-
undefined,
|
74
|
-
ts.factory.createIdentifier(i),
|
75
|
-
),
|
76
|
-
),
|
77
|
-
)
|
78
|
-
: undefined,
|
79
|
-
),
|
80
|
-
ts.factory.createStringLiteral(library),
|
81
|
-
);
|
82
|
-
}),
|
83
|
-
...(this.external_.size && this.dtos_.size
|
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
|
-
|
1
|
+
import ts from "typescript";
|
2
|
+
import { ExpressionFactory } from "typia/lib/factories/ExpressionFactory";
|
3
|
+
|
4
|
+
import { FilePrinter } from "../utils/FilePrinter";
|
5
|
+
import { MapUtil } from "../utils/MapUtil";
|
6
|
+
|
7
|
+
export class MigrateImportProgrammer {
|
8
|
+
private external_: Map<
|
9
|
+
string,
|
10
|
+
{
|
11
|
+
default: string | null;
|
12
|
+
instances: Set<string>;
|
13
|
+
}
|
14
|
+
> = new Map();
|
15
|
+
private dtos_: Set<string> = new Set();
|
16
|
+
|
17
|
+
public constructor() {}
|
18
|
+
|
19
|
+
public empty(): boolean {
|
20
|
+
return this.external_.size === 0 && this.dtos_.size === 0;
|
21
|
+
}
|
22
|
+
|
23
|
+
public external(props: MigrateImportProgrammer.IProps): string {
|
24
|
+
const element = MapUtil.take(this.external_)(props.library)(() => ({
|
25
|
+
default: null,
|
26
|
+
instances: new Set(),
|
27
|
+
}));
|
28
|
+
const name: string = props.name.split(".")[0];
|
29
|
+
if (props.type === "default") element.default = props.name;
|
30
|
+
else element.instances.add(name);
|
31
|
+
return name;
|
32
|
+
}
|
33
|
+
|
34
|
+
public dto(name: string): ts.TypeReferenceNode {
|
35
|
+
const file: string = name.split(".")[0];
|
36
|
+
this.dtos_.add(file);
|
37
|
+
return ts.factory.createTypeReferenceNode(name);
|
38
|
+
}
|
39
|
+
|
40
|
+
public tag(type: string, arg: number | string): ts.TypeReferenceNode {
|
41
|
+
this.external({
|
42
|
+
type: "instance",
|
43
|
+
library: "typia",
|
44
|
+
name: "tags",
|
45
|
+
});
|
46
|
+
return ts.factory.createTypeReferenceNode(`tags.${type}`, [
|
47
|
+
ts.factory.createLiteralTypeNode(
|
48
|
+
typeof arg === "string"
|
49
|
+
? ts.factory.createStringLiteral(arg)
|
50
|
+
: ExpressionFactory.number(arg),
|
51
|
+
),
|
52
|
+
]);
|
53
|
+
}
|
54
|
+
|
55
|
+
public toStatements(
|
56
|
+
dtoPath: (name: string) => string,
|
57
|
+
current?: string,
|
58
|
+
): ts.Statement[] {
|
59
|
+
return [
|
60
|
+
...[...this.external_.entries()].map(([library, props]) => {
|
61
|
+
return ts.factory.createImportDeclaration(
|
62
|
+
undefined,
|
63
|
+
ts.factory.createImportClause(
|
64
|
+
false,
|
65
|
+
props.default !== null
|
66
|
+
? ts.factory.createIdentifier(props.default)
|
67
|
+
: undefined,
|
68
|
+
props.instances.size
|
69
|
+
? ts.factory.createNamedImports(
|
70
|
+
[...props.instances].map((i) =>
|
71
|
+
ts.factory.createImportSpecifier(
|
72
|
+
false,
|
73
|
+
undefined,
|
74
|
+
ts.factory.createIdentifier(i),
|
75
|
+
),
|
76
|
+
),
|
77
|
+
)
|
78
|
+
: undefined,
|
79
|
+
),
|
80
|
+
ts.factory.createStringLiteral(library),
|
81
|
+
);
|
82
|
+
}),
|
83
|
+
...(this.external_.size && this.dtos_.size
|
84
|
+
? [FilePrinter.newLine()]
|
85
|
+
: []),
|
86
|
+
...[...this.dtos_]
|
87
|
+
.filter(
|
88
|
+
current ? (name) => name !== current!.split(".")[0] : () => true,
|
89
|
+
)
|
90
|
+
.map((i) =>
|
91
|
+
ts.factory.createImportDeclaration(
|
92
|
+
undefined,
|
93
|
+
ts.factory.createImportClause(
|
94
|
+
false,
|
95
|
+
undefined,
|
96
|
+
ts.factory.createNamedImports([
|
97
|
+
ts.factory.createImportSpecifier(
|
98
|
+
false,
|
99
|
+
undefined,
|
100
|
+
ts.factory.createIdentifier(i),
|
101
|
+
),
|
102
|
+
]),
|
103
|
+
),
|
104
|
+
ts.factory.createStringLiteral(dtoPath(i)),
|
105
|
+
),
|
106
|
+
),
|
107
|
+
];
|
108
|
+
}
|
109
|
+
}
|
110
|
+
export namespace MigrateImportProgrammer {
|
111
|
+
export interface IProps {
|
112
|
+
type: "default" | "instance";
|
113
|
+
library: string;
|
114
|
+
name: string;
|
115
|
+
}
|
116
|
+
}
|
@@ -1,48 +1,50 @@
|
|
1
|
-
import ts from "typescript";
|
2
|
-
|
3
|
-
import { IMigrateController } from "../structures/IMigrateController";
|
4
|
-
import { ISwaggerComponents } from "../structures/ISwaggerComponents";
|
5
|
-
import { FilePrinter } from "../utils/FilePrinter";
|
6
|
-
import { StringUtil } from "../utils/StringUtil";
|
7
|
-
import {
|
8
|
-
import {
|
9
|
-
|
10
|
-
export namespace
|
11
|
-
export const write =
|
12
|
-
(components: ISwaggerComponents) =>
|
13
|
-
(controller: IMigrateController): ts.Statement[] => {
|
14
|
-
const importer:
|
15
|
-
const $class = ts.factory.createClassDeclaration(
|
16
|
-
[
|
17
|
-
ts.factory.createDecorator(
|
18
|
-
ts.factory.createCallExpression(
|
19
|
-
ts.factory.createIdentifier(
|
20
|
-
importer.external({
|
21
|
-
type: "instance",
|
22
|
-
library: "@nestjs/common",
|
23
|
-
name: "Controller",
|
24
|
-
}),
|
25
|
-
),
|
26
|
-
[],
|
27
|
-
[ts.factory.createStringLiteral(controller.path)],
|
28
|
-
),
|
29
|
-
),
|
30
|
-
ts.factory.createToken(ts.SyntaxKind.ExportKeyword),
|
31
|
-
],
|
32
|
-
controller.name,
|
33
|
-
[],
|
34
|
-
[],
|
35
|
-
controller.routes.map(
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
1
|
+
import ts from "typescript";
|
2
|
+
|
3
|
+
import { IMigrateController } from "../structures/IMigrateController";
|
4
|
+
import { ISwaggerComponents } from "../structures/ISwaggerComponents";
|
5
|
+
import { FilePrinter } from "../utils/FilePrinter";
|
6
|
+
import { StringUtil } from "../utils/StringUtil";
|
7
|
+
import { MigrateImportProgrammer } from "./MigrateImportProgrammer";
|
8
|
+
import { MigrateNestMethodProgrammer } from "./MigrateNestMethodProgrammer";
|
9
|
+
|
10
|
+
export namespace MigrateNestControllerProgrammer {
|
11
|
+
export const write =
|
12
|
+
(components: ISwaggerComponents) =>
|
13
|
+
(controller: IMigrateController): ts.Statement[] => {
|
14
|
+
const importer: MigrateImportProgrammer = new MigrateImportProgrammer();
|
15
|
+
const $class = ts.factory.createClassDeclaration(
|
16
|
+
[
|
17
|
+
ts.factory.createDecorator(
|
18
|
+
ts.factory.createCallExpression(
|
19
|
+
ts.factory.createIdentifier(
|
20
|
+
importer.external({
|
21
|
+
type: "instance",
|
22
|
+
library: "@nestjs/common",
|
23
|
+
name: "Controller",
|
24
|
+
}),
|
25
|
+
),
|
26
|
+
[],
|
27
|
+
[ts.factory.createStringLiteral(controller.path)],
|
28
|
+
),
|
29
|
+
),
|
30
|
+
ts.factory.createToken(ts.SyntaxKind.ExportKeyword),
|
31
|
+
],
|
32
|
+
controller.name,
|
33
|
+
[],
|
34
|
+
[],
|
35
|
+
controller.routes.map(
|
36
|
+
MigrateNestMethodProgrammer.write(components)(importer),
|
37
|
+
),
|
38
|
+
);
|
39
|
+
return [
|
40
|
+
...importer.toStatements(
|
41
|
+
(ref) =>
|
42
|
+
`${"../".repeat(
|
43
|
+
StringUtil.splitWithNormalization(controller.location).length - 1,
|
44
|
+
)}api/structures/${ref}`,
|
45
|
+
),
|
46
|
+
...(importer.empty() ? [] : [FilePrinter.newLine()]),
|
47
|
+
$class,
|
48
|
+
];
|
49
|
+
};
|
50
|
+
}
|