@nestia/migrate 4.6.0 → 4.6.1-dev.20250117
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/README.md +87 -87
- package/lib/bundles/NEST_TEMPLATE.js +66 -66
- package/lib/bundles/NEST_TEMPLATE.js.map +1 -1
- package/lib/bundles/SDK_TEMPLATE.js +30 -30
- package/lib/bundles/SDK_TEMPLATE.js.map +1 -1
- package/lib/index.mjs +92 -92
- package/lib/utils/openapi-down-convert/converter.js +2 -2
- package/package.json +6 -6
- package/src/MigrateApplication.ts +107 -107
- package/src/analyzers/MigrateApplicationAnalyzer.ts +18 -18
- package/src/analyzers/MigrateControllerAnalyzer.ts +51 -51
- package/src/archivers/MigrateFileArchiver.ts +38 -38
- package/src/bundles/NEST_TEMPLATE.ts +66 -66
- package/src/bundles/SDK_TEMPLATE.ts +30 -30
- package/src/executable/bundle.js +125 -125
- package/src/executable/migrate.ts +7 -7
- package/src/factories/TypeLiteralFactory.ts +57 -57
- package/src/index.ts +4 -4
- package/src/internal/MigrateCommander.ts +86 -86
- package/src/internal/MigrateInquirer.ts +89 -89
- package/src/module.ts +8 -8
- package/src/programmers/MigrateApiFileProgrammer.ts +49 -49
- package/src/programmers/MigrateApiFunctionProgrammer.ts +210 -210
- package/src/programmers/MigrateApiNamespaceProgrammer.ts +417 -417
- package/src/programmers/MigrateApiProgrammer.ts +103 -103
- package/src/programmers/MigrateApiSimulatationProgrammer.ts +324 -324
- package/src/programmers/MigrateApiStartProgrammer.ts +194 -194
- package/src/programmers/MigrateDtoProgrammer.ts +87 -87
- package/src/programmers/MigrateE2eFileProgrammer.ts +117 -117
- package/src/programmers/MigrateE2eProgrammer.ts +34 -34
- package/src/programmers/MigrateImportProgrammer.ts +118 -118
- package/src/programmers/MigrateNestControllerProgrammer.ts +50 -50
- package/src/programmers/MigrateNestMethodProgrammer.ts +393 -393
- package/src/programmers/MigrateNestModuleProgrammer.ts +65 -65
- package/src/programmers/MigrateNestProgrammer.ts +81 -81
- package/src/programmers/MigrateSchemaProgrammer.ts +373 -373
- package/src/structures/IHttpMigrateController.ts +8 -8
- package/src/structures/IHttpMigrateDto.ts +8 -8
- package/src/structures/IHttpMigrateFile.ts +5 -5
- package/src/structures/IHttpMigrateProgram.ts +27 -27
- package/src/structures/IHttpMigrateRoute.ts +1 -1
- package/src/structures/IHttpMigrateSchema.ts +4 -4
- package/src/utils/FilePrinter.ts +36 -36
- package/src/utils/MapUtil.ts +13 -13
- package/src/utils/OpenApiTypeChecker.ts +73 -73
- package/src/utils/SetupWizard.ts +12 -12
- package/src/utils/StringUtil.ts +113 -113
- package/src/utils/openapi-down-convert/RefVisitor.ts +139 -139
- package/src/utils/openapi-down-convert/converter.ts +527 -527
@@ -1,65 +1,65 @@
|
|
1
|
-
import ts from "typescript";
|
2
|
-
|
3
|
-
import { IHttpMigrateController } from "../structures/IHttpMigrateController";
|
4
|
-
import { FilePrinter } from "../utils/FilePrinter";
|
5
|
-
|
6
|
-
export namespace MigrateNestModuleProgrammer {
|
7
|
-
export const write = (
|
8
|
-
controllers: IHttpMigrateController[],
|
9
|
-
): ts.Statement[] => [
|
10
|
-
$import("@nestjs/common")("Module"),
|
11
|
-
...(controllers.length ? [FilePrinter.newLine()] : []),
|
12
|
-
...controllers.map((c) =>
|
13
|
-
$import(`${c.location.replace("src/", "./")}/${c.name}`)(c.name),
|
14
|
-
),
|
15
|
-
...(controllers.length ? [FilePrinter.newLine()] : []),
|
16
|
-
ts.factory.createClassDeclaration(
|
17
|
-
[
|
18
|
-
ts.factory.createDecorator(
|
19
|
-
ts.factory.createCallExpression(
|
20
|
-
ts.factory.createIdentifier("Module"),
|
21
|
-
undefined,
|
22
|
-
[
|
23
|
-
ts.factory.createObjectLiteralExpression(
|
24
|
-
[
|
25
|
-
ts.factory.createPropertyAssignment(
|
26
|
-
ts.factory.createIdentifier("controllers"),
|
27
|
-
ts.factory.createArrayLiteralExpression(
|
28
|
-
controllers.map((c) =>
|
29
|
-
ts.factory.createIdentifier(c.name),
|
30
|
-
),
|
31
|
-
true,
|
32
|
-
),
|
33
|
-
),
|
34
|
-
],
|
35
|
-
true,
|
36
|
-
),
|
37
|
-
],
|
38
|
-
),
|
39
|
-
),
|
40
|
-
ts.factory.createToken(ts.SyntaxKind.ExportKeyword),
|
41
|
-
],
|
42
|
-
"MyModule",
|
43
|
-
undefined,
|
44
|
-
undefined,
|
45
|
-
[],
|
46
|
-
),
|
47
|
-
];
|
48
|
-
}
|
49
|
-
|
50
|
-
const $import = (file: string) => (instance: string) =>
|
51
|
-
ts.factory.createImportDeclaration(
|
52
|
-
undefined,
|
53
|
-
ts.factory.createImportClause(
|
54
|
-
false,
|
55
|
-
undefined,
|
56
|
-
ts.factory.createNamedImports([
|
57
|
-
ts.factory.createImportSpecifier(
|
58
|
-
false,
|
59
|
-
undefined,
|
60
|
-
ts.factory.createIdentifier(instance),
|
61
|
-
),
|
62
|
-
]),
|
63
|
-
),
|
64
|
-
ts.factory.createStringLiteral(file),
|
65
|
-
);
|
1
|
+
import ts from "typescript";
|
2
|
+
|
3
|
+
import { IHttpMigrateController } from "../structures/IHttpMigrateController";
|
4
|
+
import { FilePrinter } from "../utils/FilePrinter";
|
5
|
+
|
6
|
+
export namespace MigrateNestModuleProgrammer {
|
7
|
+
export const write = (
|
8
|
+
controllers: IHttpMigrateController[],
|
9
|
+
): ts.Statement[] => [
|
10
|
+
$import("@nestjs/common")("Module"),
|
11
|
+
...(controllers.length ? [FilePrinter.newLine()] : []),
|
12
|
+
...controllers.map((c) =>
|
13
|
+
$import(`${c.location.replace("src/", "./")}/${c.name}`)(c.name),
|
14
|
+
),
|
15
|
+
...(controllers.length ? [FilePrinter.newLine()] : []),
|
16
|
+
ts.factory.createClassDeclaration(
|
17
|
+
[
|
18
|
+
ts.factory.createDecorator(
|
19
|
+
ts.factory.createCallExpression(
|
20
|
+
ts.factory.createIdentifier("Module"),
|
21
|
+
undefined,
|
22
|
+
[
|
23
|
+
ts.factory.createObjectLiteralExpression(
|
24
|
+
[
|
25
|
+
ts.factory.createPropertyAssignment(
|
26
|
+
ts.factory.createIdentifier("controllers"),
|
27
|
+
ts.factory.createArrayLiteralExpression(
|
28
|
+
controllers.map((c) =>
|
29
|
+
ts.factory.createIdentifier(c.name),
|
30
|
+
),
|
31
|
+
true,
|
32
|
+
),
|
33
|
+
),
|
34
|
+
],
|
35
|
+
true,
|
36
|
+
),
|
37
|
+
],
|
38
|
+
),
|
39
|
+
),
|
40
|
+
ts.factory.createToken(ts.SyntaxKind.ExportKeyword),
|
41
|
+
],
|
42
|
+
"MyModule",
|
43
|
+
undefined,
|
44
|
+
undefined,
|
45
|
+
[],
|
46
|
+
),
|
47
|
+
];
|
48
|
+
}
|
49
|
+
|
50
|
+
const $import = (file: string) => (instance: string) =>
|
51
|
+
ts.factory.createImportDeclaration(
|
52
|
+
undefined,
|
53
|
+
ts.factory.createImportClause(
|
54
|
+
false,
|
55
|
+
undefined,
|
56
|
+
ts.factory.createNamedImports([
|
57
|
+
ts.factory.createImportSpecifier(
|
58
|
+
false,
|
59
|
+
undefined,
|
60
|
+
ts.factory.createIdentifier(instance),
|
61
|
+
),
|
62
|
+
]),
|
63
|
+
),
|
64
|
+
ts.factory.createStringLiteral(file),
|
65
|
+
);
|
@@ -1,81 +1,81 @@
|
|
1
|
-
import ts from "typescript";
|
2
|
-
|
3
|
-
import { MigrateControllerAnalyzer } from "../analyzers/MigrateControllerAnalyzer";
|
4
|
-
import { IHttpMigrateController } from "../structures/IHttpMigrateController";
|
5
|
-
import { IHttpMigrateFile } from "../structures/IHttpMigrateFile";
|
6
|
-
import { IHttpMigrateProgram } from "../structures/IHttpMigrateProgram";
|
7
|
-
import { FilePrinter } from "../utils/FilePrinter";
|
8
|
-
import { MigrateDtoProgrammer } from "./MigrateDtoProgrammer";
|
9
|
-
import { MigrateImportProgrammer } from "./MigrateImportProgrammer";
|
10
|
-
import { MigrateNestControllerProgrammer } from "./MigrateNestControllerProgrammer";
|
11
|
-
import { MigrateNestModuleProgrammer } from "./MigrateNestModuleProgrammer";
|
12
|
-
|
13
|
-
export namespace MigrateNestProgrammer {
|
14
|
-
export const write = (program: IHttpMigrateProgram): IHttpMigrateFile[] => {
|
15
|
-
const controllers: IHttpMigrateController[] =
|
16
|
-
MigrateControllerAnalyzer.analyze({
|
17
|
-
routes: program.routes,
|
18
|
-
});
|
19
|
-
return [
|
20
|
-
{
|
21
|
-
location: "src",
|
22
|
-
file: "MyModule.ts",
|
23
|
-
statements: MigrateNestModuleProgrammer.write(controllers),
|
24
|
-
},
|
25
|
-
...controllers.map((c) => ({
|
26
|
-
location: c.location,
|
27
|
-
file: `${c.name}.ts`,
|
28
|
-
statements: MigrateNestControllerProgrammer.write(
|
29
|
-
program.document.components,
|
30
|
-
)(c),
|
31
|
-
})),
|
32
|
-
...[
|
33
|
-
...MigrateDtoProgrammer.compose(program.document.components).entries(),
|
34
|
-
].map(([key, value]) => ({
|
35
|
-
location: "src/api/structures",
|
36
|
-
file: `${key}.ts`,
|
37
|
-
statements: writeDtoFile(key, value),
|
38
|
-
})),
|
39
|
-
].map((o) => ({
|
40
|
-
location: o.location,
|
41
|
-
file: o.file,
|
42
|
-
content: FilePrinter.write({ statements: o.statements }),
|
43
|
-
}));
|
44
|
-
};
|
45
|
-
|
46
|
-
const writeDtoFile = (
|
47
|
-
key: string,
|
48
|
-
modulo: MigrateDtoProgrammer.IModule,
|
49
|
-
): ts.Statement[] => {
|
50
|
-
const importer = new MigrateImportProgrammer();
|
51
|
-
const statements: ts.Statement[] = iterate(importer)(modulo);
|
52
|
-
if (statements.length === 0) return [];
|
53
|
-
|
54
|
-
return [
|
55
|
-
...importer.toStatements((name) => `./${name}`, key),
|
56
|
-
...(importer.empty() ? [] : [FilePrinter.newLine()]),
|
57
|
-
...statements,
|
58
|
-
];
|
59
|
-
};
|
60
|
-
|
61
|
-
const iterate =
|
62
|
-
(importer: MigrateImportProgrammer) =>
|
63
|
-
(modulo: MigrateDtoProgrammer.IModule): ts.Statement[] => {
|
64
|
-
const output: ts.Statement[] = [];
|
65
|
-
if (modulo.programmer !== null) output.push(modulo.programmer(importer));
|
66
|
-
if (modulo.children.size) {
|
67
|
-
const internal: ts.Statement[] = [];
|
68
|
-
for (const child of modulo.children.values())
|
69
|
-
internal.push(...iterate(importer)(child));
|
70
|
-
output.push(
|
71
|
-
ts.factory.createModuleDeclaration(
|
72
|
-
[ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
|
73
|
-
ts.factory.createIdentifier(modulo.name),
|
74
|
-
ts.factory.createModuleBlock(internal),
|
75
|
-
ts.NodeFlags.Namespace,
|
76
|
-
),
|
77
|
-
);
|
78
|
-
}
|
79
|
-
return output;
|
80
|
-
};
|
81
|
-
}
|
1
|
+
import ts from "typescript";
|
2
|
+
|
3
|
+
import { MigrateControllerAnalyzer } from "../analyzers/MigrateControllerAnalyzer";
|
4
|
+
import { IHttpMigrateController } from "../structures/IHttpMigrateController";
|
5
|
+
import { IHttpMigrateFile } from "../structures/IHttpMigrateFile";
|
6
|
+
import { IHttpMigrateProgram } from "../structures/IHttpMigrateProgram";
|
7
|
+
import { FilePrinter } from "../utils/FilePrinter";
|
8
|
+
import { MigrateDtoProgrammer } from "./MigrateDtoProgrammer";
|
9
|
+
import { MigrateImportProgrammer } from "./MigrateImportProgrammer";
|
10
|
+
import { MigrateNestControllerProgrammer } from "./MigrateNestControllerProgrammer";
|
11
|
+
import { MigrateNestModuleProgrammer } from "./MigrateNestModuleProgrammer";
|
12
|
+
|
13
|
+
export namespace MigrateNestProgrammer {
|
14
|
+
export const write = (program: IHttpMigrateProgram): IHttpMigrateFile[] => {
|
15
|
+
const controllers: IHttpMigrateController[] =
|
16
|
+
MigrateControllerAnalyzer.analyze({
|
17
|
+
routes: program.routes,
|
18
|
+
});
|
19
|
+
return [
|
20
|
+
{
|
21
|
+
location: "src",
|
22
|
+
file: "MyModule.ts",
|
23
|
+
statements: MigrateNestModuleProgrammer.write(controllers),
|
24
|
+
},
|
25
|
+
...controllers.map((c) => ({
|
26
|
+
location: c.location,
|
27
|
+
file: `${c.name}.ts`,
|
28
|
+
statements: MigrateNestControllerProgrammer.write(
|
29
|
+
program.document.components,
|
30
|
+
)(c),
|
31
|
+
})),
|
32
|
+
...[
|
33
|
+
...MigrateDtoProgrammer.compose(program.document.components).entries(),
|
34
|
+
].map(([key, value]) => ({
|
35
|
+
location: "src/api/structures",
|
36
|
+
file: `${key}.ts`,
|
37
|
+
statements: writeDtoFile(key, value),
|
38
|
+
})),
|
39
|
+
].map((o) => ({
|
40
|
+
location: o.location,
|
41
|
+
file: o.file,
|
42
|
+
content: FilePrinter.write({ statements: o.statements }),
|
43
|
+
}));
|
44
|
+
};
|
45
|
+
|
46
|
+
const writeDtoFile = (
|
47
|
+
key: string,
|
48
|
+
modulo: MigrateDtoProgrammer.IModule,
|
49
|
+
): ts.Statement[] => {
|
50
|
+
const importer = new MigrateImportProgrammer();
|
51
|
+
const statements: ts.Statement[] = iterate(importer)(modulo);
|
52
|
+
if (statements.length === 0) return [];
|
53
|
+
|
54
|
+
return [
|
55
|
+
...importer.toStatements((name) => `./${name}`, key),
|
56
|
+
...(importer.empty() ? [] : [FilePrinter.newLine()]),
|
57
|
+
...statements,
|
58
|
+
];
|
59
|
+
};
|
60
|
+
|
61
|
+
const iterate =
|
62
|
+
(importer: MigrateImportProgrammer) =>
|
63
|
+
(modulo: MigrateDtoProgrammer.IModule): ts.Statement[] => {
|
64
|
+
const output: ts.Statement[] = [];
|
65
|
+
if (modulo.programmer !== null) output.push(modulo.programmer(importer));
|
66
|
+
if (modulo.children.size) {
|
67
|
+
const internal: ts.Statement[] = [];
|
68
|
+
for (const child of modulo.children.values())
|
69
|
+
internal.push(...iterate(importer)(child));
|
70
|
+
output.push(
|
71
|
+
ts.factory.createModuleDeclaration(
|
72
|
+
[ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
|
73
|
+
ts.factory.createIdentifier(modulo.name),
|
74
|
+
ts.factory.createModuleBlock(internal),
|
75
|
+
ts.NodeFlags.Namespace,
|
76
|
+
),
|
77
|
+
);
|
78
|
+
}
|
79
|
+
return output;
|
80
|
+
};
|
81
|
+
}
|