@nestia/migrate 7.0.0-dev.20250608 → 7.0.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/README.md +92 -92
- package/lib/analyzers/NestiaMigrateControllerAnalyzer.js +1 -1
- package/lib/analyzers/NestiaMigrateControllerAnalyzer.js.map +1 -1
- package/lib/bundles/NEST_TEMPLATE.js +47 -47
- package/lib/bundles/NEST_TEMPLATE.js.map +1 -1
- package/lib/bundles/SDK_TEMPLATE.js +21 -21
- package/lib/bundles/SDK_TEMPLATE.js.map +1 -1
- package/lib/index.mjs +69 -69
- package/lib/index.mjs.map +1 -1
- package/lib/utils/openapi-down-convert/converter.js +2 -2
- package/package.json +7 -7
- package/src/NestiaMigrateApplication.ts +144 -144
- package/src/analyzers/NestiaMigrateControllerAnalyzer.ts +51 -51
- package/src/archivers/NestiaMigrateFileArchiver.ts +28 -28
- package/src/bundles/NEST_TEMPLATE.ts +47 -47
- package/src/bundles/SDK_TEMPLATE.ts +21 -21
- package/src/executable/NestiaMigrateCommander.ts +98 -98
- package/src/executable/NestiaMigrateInquirer.ts +106 -106
- package/src/executable/bundle.js +129 -129
- package/src/executable/migrate.ts +7 -7
- package/src/factories/TypeLiteralFactory.ts +57 -57
- package/src/index.ts +4 -4
- package/src/module.ts +2 -2
- package/src/programmers/NestiaMigrateApiFileProgrammer.ts +55 -55
- package/src/programmers/NestiaMigrateApiFunctionProgrammer.ts +256 -256
- package/src/programmers/NestiaMigrateApiNamespaceProgrammer.ts +515 -515
- package/src/programmers/NestiaMigrateApiProgrammer.ts +107 -107
- package/src/programmers/NestiaMigrateApiSimulationProgrammer.ts +340 -340
- package/src/programmers/NestiaMigrateApiStartProgrammer.ts +198 -198
- package/src/programmers/NestiaMigrateDtoProgrammer.ts +101 -101
- package/src/programmers/NestiaMigrateE2eFileProgrammer.ts +153 -153
- package/src/programmers/NestiaMigrateE2eProgrammer.ts +46 -46
- package/src/programmers/NestiaMigrateImportProgrammer.ts +118 -118
- package/src/programmers/NestiaMigrateNestControllerProgrammer.ts +66 -66
- package/src/programmers/NestiaMigrateNestMethodProgrammer.ts +406 -406
- package/src/programmers/NestiaMigrateNestModuleProgrammer.ts +65 -65
- package/src/programmers/NestiaMigrateNestProgrammer.ts +88 -88
- package/src/programmers/NestiaMigrateSchemaProgrammer.ts +475 -475
- package/src/structures/INestiaMigrateConfig.ts +10 -10
- package/src/structures/INestiaMigrateContext.ts +15 -15
- package/src/structures/INestiaMigrateController.ts +8 -8
- package/src/structures/INestiaMigrateDto.ts +8 -8
- package/src/structures/INestiaMigrateFile.ts +5 -5
- package/src/structures/INestiaMigrateProgram.ts +11 -11
- package/src/structures/INestiaMigrateSchema.ts +4 -4
- package/src/utils/FilePrinter.ts +38 -38
- 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 { INestiaMigrateController } from "../structures/INestiaMigrateController";
|
4
|
-
import { FilePrinter } from "../utils/FilePrinter";
|
5
|
-
|
6
|
-
export namespace NestiaMigrateNestModuleProgrammer {
|
7
|
-
export const write = (
|
8
|
-
controllers: INestiaMigrateController[],
|
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 { INestiaMigrateController } from "../structures/INestiaMigrateController";
|
4
|
+
import { FilePrinter } from "../utils/FilePrinter";
|
5
|
+
|
6
|
+
export namespace NestiaMigrateNestModuleProgrammer {
|
7
|
+
export const write = (
|
8
|
+
controllers: INestiaMigrateController[],
|
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,88 +1,88 @@
|
|
1
|
-
import ts from "typescript";
|
2
|
-
|
3
|
-
import { NestiaMigrateControllerAnalyzer } from "../analyzers/NestiaMigrateControllerAnalyzer";
|
4
|
-
import { INestiaMigrateContext } from "../structures/INestiaMigrateContext";
|
5
|
-
import { INestiaMigrateController } from "../structures/INestiaMigrateController";
|
6
|
-
import { FilePrinter } from "../utils/FilePrinter";
|
7
|
-
import { NestiaMigrateDtoProgrammer } from "./NestiaMigrateDtoProgrammer";
|
8
|
-
import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
|
9
|
-
import { NestiaMigrateNestControllerProgrammer } from "./NestiaMigrateNestControllerProgrammer";
|
10
|
-
import { NestiaMigrateNestModuleProgrammer } from "./NestiaMigrateNestModuleProgrammer";
|
11
|
-
|
12
|
-
export namespace NestiaMigrateNestProgrammer {
|
13
|
-
export const write = (
|
14
|
-
context: INestiaMigrateContext,
|
15
|
-
): Record<string, string> => {
|
16
|
-
const controllers: INestiaMigrateController[] =
|
17
|
-
NestiaMigrateControllerAnalyzer.analyze(context.routes);
|
18
|
-
const statements: [string, ts.Statement[]][] = [
|
19
|
-
["src/MyModule.ts", NestiaMigrateNestModuleProgrammer.write(controllers)],
|
20
|
-
...controllers.map(
|
21
|
-
(c) =>
|
22
|
-
[
|
23
|
-
`${c.location}/${c.name}.ts`,
|
24
|
-
NestiaMigrateNestControllerProgrammer.write({
|
25
|
-
config: context.config,
|
26
|
-
components: context.document.components,
|
27
|
-
controller: c,
|
28
|
-
}),
|
29
|
-
] satisfies [string, ts.Statement[]],
|
30
|
-
),
|
31
|
-
...[
|
32
|
-
...NestiaMigrateDtoProgrammer.compose({
|
33
|
-
config: context.config,
|
34
|
-
components: context.document.components,
|
35
|
-
}).entries(),
|
36
|
-
].map(
|
37
|
-
([key, value]) =>
|
38
|
-
[`src/api/structures/${key}.ts`, writeDtoFile(key, value)] satisfies [
|
39
|
-
string,
|
40
|
-
ts.Statement[],
|
41
|
-
],
|
42
|
-
),
|
43
|
-
];
|
44
|
-
return Object.fromEntries(
|
45
|
-
statements.map(([key, value]) => [
|
46
|
-
key,
|
47
|
-
FilePrinter.write({ statements: value }),
|
48
|
-
]),
|
49
|
-
);
|
50
|
-
};
|
51
|
-
|
52
|
-
const writeDtoFile = (
|
53
|
-
key: string,
|
54
|
-
modulo: NestiaMigrateDtoProgrammer.IModule,
|
55
|
-
): ts.Statement[] => {
|
56
|
-
const importer = new NestiaMigrateImportProgrammer();
|
57
|
-
const statements: ts.Statement[] = iterate(importer)(modulo);
|
58
|
-
if (statements.length === 0) return [];
|
59
|
-
|
60
|
-
return [
|
61
|
-
...importer.toStatements((name) => `./${name}`, key),
|
62
|
-
...(importer.empty() ? [] : [FilePrinter.newLine()]),
|
63
|
-
...statements,
|
64
|
-
];
|
65
|
-
};
|
66
|
-
|
67
|
-
const iterate =
|
68
|
-
(importer: NestiaMigrateImportProgrammer) =>
|
69
|
-
(modulo: NestiaMigrateDtoProgrammer.IModule): ts.Statement[] => {
|
70
|
-
const output: ts.Statement[] = [];
|
71
|
-
if (modulo.programmer !== null) output.push(modulo.programmer(importer));
|
72
|
-
if (modulo.children.size) {
|
73
|
-
const internal: ts.Statement[] = [];
|
74
|
-
for (const child of modulo.children.values())
|
75
|
-
internal.push(...iterate(importer)(child));
|
76
|
-
output.push(
|
77
|
-
ts.factory.createModuleDeclaration(
|
78
|
-
[ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
|
79
|
-
ts.factory.createIdentifier(modulo.name),
|
80
|
-
ts.factory.createModuleBlock(internal),
|
81
|
-
ts.NodeFlags.Namespace,
|
82
|
-
),
|
83
|
-
);
|
84
|
-
}
|
85
|
-
output.push(FilePrinter.newLine());
|
86
|
-
return output;
|
87
|
-
};
|
88
|
-
}
|
1
|
+
import ts from "typescript";
|
2
|
+
|
3
|
+
import { NestiaMigrateControllerAnalyzer } from "../analyzers/NestiaMigrateControllerAnalyzer";
|
4
|
+
import { INestiaMigrateContext } from "../structures/INestiaMigrateContext";
|
5
|
+
import { INestiaMigrateController } from "../structures/INestiaMigrateController";
|
6
|
+
import { FilePrinter } from "../utils/FilePrinter";
|
7
|
+
import { NestiaMigrateDtoProgrammer } from "./NestiaMigrateDtoProgrammer";
|
8
|
+
import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
|
9
|
+
import { NestiaMigrateNestControllerProgrammer } from "./NestiaMigrateNestControllerProgrammer";
|
10
|
+
import { NestiaMigrateNestModuleProgrammer } from "./NestiaMigrateNestModuleProgrammer";
|
11
|
+
|
12
|
+
export namespace NestiaMigrateNestProgrammer {
|
13
|
+
export const write = (
|
14
|
+
context: INestiaMigrateContext,
|
15
|
+
): Record<string, string> => {
|
16
|
+
const controllers: INestiaMigrateController[] =
|
17
|
+
NestiaMigrateControllerAnalyzer.analyze(context.routes);
|
18
|
+
const statements: [string, ts.Statement[]][] = [
|
19
|
+
["src/MyModule.ts", NestiaMigrateNestModuleProgrammer.write(controllers)],
|
20
|
+
...controllers.map(
|
21
|
+
(c) =>
|
22
|
+
[
|
23
|
+
`${c.location}/${c.name}.ts`,
|
24
|
+
NestiaMigrateNestControllerProgrammer.write({
|
25
|
+
config: context.config,
|
26
|
+
components: context.document.components,
|
27
|
+
controller: c,
|
28
|
+
}),
|
29
|
+
] satisfies [string, ts.Statement[]],
|
30
|
+
),
|
31
|
+
...[
|
32
|
+
...NestiaMigrateDtoProgrammer.compose({
|
33
|
+
config: context.config,
|
34
|
+
components: context.document.components,
|
35
|
+
}).entries(),
|
36
|
+
].map(
|
37
|
+
([key, value]) =>
|
38
|
+
[`src/api/structures/${key}.ts`, writeDtoFile(key, value)] satisfies [
|
39
|
+
string,
|
40
|
+
ts.Statement[],
|
41
|
+
],
|
42
|
+
),
|
43
|
+
];
|
44
|
+
return Object.fromEntries(
|
45
|
+
statements.map(([key, value]) => [
|
46
|
+
key,
|
47
|
+
FilePrinter.write({ statements: value }),
|
48
|
+
]),
|
49
|
+
);
|
50
|
+
};
|
51
|
+
|
52
|
+
const writeDtoFile = (
|
53
|
+
key: string,
|
54
|
+
modulo: NestiaMigrateDtoProgrammer.IModule,
|
55
|
+
): ts.Statement[] => {
|
56
|
+
const importer = new NestiaMigrateImportProgrammer();
|
57
|
+
const statements: ts.Statement[] = iterate(importer)(modulo);
|
58
|
+
if (statements.length === 0) return [];
|
59
|
+
|
60
|
+
return [
|
61
|
+
...importer.toStatements((name) => `./${name}`, key),
|
62
|
+
...(importer.empty() ? [] : [FilePrinter.newLine()]),
|
63
|
+
...statements,
|
64
|
+
];
|
65
|
+
};
|
66
|
+
|
67
|
+
const iterate =
|
68
|
+
(importer: NestiaMigrateImportProgrammer) =>
|
69
|
+
(modulo: NestiaMigrateDtoProgrammer.IModule): ts.Statement[] => {
|
70
|
+
const output: ts.Statement[] = [];
|
71
|
+
if (modulo.programmer !== null) output.push(modulo.programmer(importer));
|
72
|
+
if (modulo.children.size) {
|
73
|
+
const internal: ts.Statement[] = [];
|
74
|
+
for (const child of modulo.children.values())
|
75
|
+
internal.push(...iterate(importer)(child));
|
76
|
+
output.push(
|
77
|
+
ts.factory.createModuleDeclaration(
|
78
|
+
[ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
|
79
|
+
ts.factory.createIdentifier(modulo.name),
|
80
|
+
ts.factory.createModuleBlock(internal),
|
81
|
+
ts.NodeFlags.Namespace,
|
82
|
+
),
|
83
|
+
);
|
84
|
+
}
|
85
|
+
output.push(FilePrinter.newLine());
|
86
|
+
return output;
|
87
|
+
};
|
88
|
+
}
|