@nestia/migrate 7.0.0-dev.20250607 → 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.
Files changed (54) hide show
  1. package/README.md +92 -92
  2. package/lib/analyzers/NestiaMigrateControllerAnalyzer.js +1 -1
  3. package/lib/analyzers/NestiaMigrateControllerAnalyzer.js.map +1 -1
  4. package/lib/bundles/NEST_TEMPLATE.js +47 -47
  5. package/lib/bundles/NEST_TEMPLATE.js.map +1 -1
  6. package/lib/bundles/SDK_TEMPLATE.js +21 -21
  7. package/lib/bundles/SDK_TEMPLATE.js.map +1 -1
  8. package/lib/index.mjs +70 -70
  9. package/lib/index.mjs.map +1 -1
  10. package/lib/programmers/NestiaMigrateApiProgrammer.js +1 -1
  11. package/lib/programmers/NestiaMigrateApiProgrammer.js.map +1 -1
  12. package/lib/utils/openapi-down-convert/converter.js +2 -2
  13. package/package.json +7 -7
  14. package/src/NestiaMigrateApplication.ts +144 -144
  15. package/src/analyzers/NestiaMigrateControllerAnalyzer.ts +51 -51
  16. package/src/archivers/NestiaMigrateFileArchiver.ts +28 -28
  17. package/src/bundles/NEST_TEMPLATE.ts +47 -47
  18. package/src/bundles/SDK_TEMPLATE.ts +21 -21
  19. package/src/executable/NestiaMigrateCommander.ts +98 -98
  20. package/src/executable/NestiaMigrateInquirer.ts +106 -106
  21. package/src/executable/bundle.js +129 -129
  22. package/src/executable/migrate.ts +7 -7
  23. package/src/factories/TypeLiteralFactory.ts +57 -57
  24. package/src/index.ts +4 -4
  25. package/src/module.ts +2 -2
  26. package/src/programmers/NestiaMigrateApiFileProgrammer.ts +55 -55
  27. package/src/programmers/NestiaMigrateApiFunctionProgrammer.ts +256 -256
  28. package/src/programmers/NestiaMigrateApiNamespaceProgrammer.ts +515 -515
  29. package/src/programmers/NestiaMigrateApiProgrammer.ts +107 -107
  30. package/src/programmers/NestiaMigrateApiSimulationProgrammer.ts +340 -340
  31. package/src/programmers/NestiaMigrateApiStartProgrammer.ts +198 -198
  32. package/src/programmers/NestiaMigrateDtoProgrammer.ts +101 -101
  33. package/src/programmers/NestiaMigrateE2eFileProgrammer.ts +153 -153
  34. package/src/programmers/NestiaMigrateE2eProgrammer.ts +46 -46
  35. package/src/programmers/NestiaMigrateImportProgrammer.ts +118 -118
  36. package/src/programmers/NestiaMigrateNestControllerProgrammer.ts +66 -66
  37. package/src/programmers/NestiaMigrateNestMethodProgrammer.ts +406 -406
  38. package/src/programmers/NestiaMigrateNestModuleProgrammer.ts +65 -65
  39. package/src/programmers/NestiaMigrateNestProgrammer.ts +88 -88
  40. package/src/programmers/NestiaMigrateSchemaProgrammer.ts +475 -475
  41. package/src/structures/INestiaMigrateConfig.ts +10 -10
  42. package/src/structures/INestiaMigrateContext.ts +15 -15
  43. package/src/structures/INestiaMigrateController.ts +8 -8
  44. package/src/structures/INestiaMigrateDto.ts +8 -8
  45. package/src/structures/INestiaMigrateFile.ts +5 -5
  46. package/src/structures/INestiaMigrateProgram.ts +11 -11
  47. package/src/structures/INestiaMigrateSchema.ts +4 -4
  48. package/src/utils/FilePrinter.ts +38 -38
  49. package/src/utils/MapUtil.ts +13 -13
  50. package/src/utils/OpenApiTypeChecker.ts +73 -73
  51. package/src/utils/SetupWizard.ts +12 -12
  52. package/src/utils/StringUtil.ts +113 -113
  53. package/src/utils/openapi-down-convert/RefVisitor.ts +139 -139
  54. 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
+ }