@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.
Files changed (52) 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 +69 -69
  9. package/lib/index.mjs.map +1 -1
  10. package/lib/utils/openapi-down-convert/converter.js +2 -2
  11. package/package.json +7 -7
  12. package/src/NestiaMigrateApplication.ts +144 -144
  13. package/src/analyzers/NestiaMigrateControllerAnalyzer.ts +51 -51
  14. package/src/archivers/NestiaMigrateFileArchiver.ts +28 -28
  15. package/src/bundles/NEST_TEMPLATE.ts +47 -47
  16. package/src/bundles/SDK_TEMPLATE.ts +21 -21
  17. package/src/executable/NestiaMigrateCommander.ts +98 -98
  18. package/src/executable/NestiaMigrateInquirer.ts +106 -106
  19. package/src/executable/bundle.js +129 -129
  20. package/src/executable/migrate.ts +7 -7
  21. package/src/factories/TypeLiteralFactory.ts +57 -57
  22. package/src/index.ts +4 -4
  23. package/src/module.ts +2 -2
  24. package/src/programmers/NestiaMigrateApiFileProgrammer.ts +55 -55
  25. package/src/programmers/NestiaMigrateApiFunctionProgrammer.ts +256 -256
  26. package/src/programmers/NestiaMigrateApiNamespaceProgrammer.ts +515 -515
  27. package/src/programmers/NestiaMigrateApiProgrammer.ts +107 -107
  28. package/src/programmers/NestiaMigrateApiSimulationProgrammer.ts +340 -340
  29. package/src/programmers/NestiaMigrateApiStartProgrammer.ts +198 -198
  30. package/src/programmers/NestiaMigrateDtoProgrammer.ts +101 -101
  31. package/src/programmers/NestiaMigrateE2eFileProgrammer.ts +153 -153
  32. package/src/programmers/NestiaMigrateE2eProgrammer.ts +46 -46
  33. package/src/programmers/NestiaMigrateImportProgrammer.ts +118 -118
  34. package/src/programmers/NestiaMigrateNestControllerProgrammer.ts +66 -66
  35. package/src/programmers/NestiaMigrateNestMethodProgrammer.ts +406 -406
  36. package/src/programmers/NestiaMigrateNestModuleProgrammer.ts +65 -65
  37. package/src/programmers/NestiaMigrateNestProgrammer.ts +88 -88
  38. package/src/programmers/NestiaMigrateSchemaProgrammer.ts +475 -475
  39. package/src/structures/INestiaMigrateConfig.ts +10 -10
  40. package/src/structures/INestiaMigrateContext.ts +15 -15
  41. package/src/structures/INestiaMigrateController.ts +8 -8
  42. package/src/structures/INestiaMigrateDto.ts +8 -8
  43. package/src/structures/INestiaMigrateFile.ts +5 -5
  44. package/src/structures/INestiaMigrateProgram.ts +11 -11
  45. package/src/structures/INestiaMigrateSchema.ts +4 -4
  46. package/src/utils/FilePrinter.ts +38 -38
  47. package/src/utils/MapUtil.ts +13 -13
  48. package/src/utils/OpenApiTypeChecker.ts +73 -73
  49. package/src/utils/SetupWizard.ts +12 -12
  50. package/src/utils/StringUtil.ts +113 -113
  51. package/src/utils/openapi-down-convert/RefVisitor.ts +139 -139
  52. package/src/utils/openapi-down-convert/converter.ts +527 -527
@@ -1,107 +1,107 @@
1
- import { HashMap, hash } from "tstl";
2
- import ts from "typescript";
3
-
4
- import { INestiaMigrateContext } from "../structures/INestiaMigrateContext";
5
- import { FilePrinter } from "../utils/FilePrinter";
6
- import { NestiaMigrateApiFileProgrammer } from "./NestiaMigrateApiFileProgrammer";
7
- import { NestiaMigrateDtoProgrammer } from "./NestiaMigrateDtoProgrammer";
8
- import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
9
-
10
- export namespace NestiaMigrateApiProgrammer {
11
- export const write = (ctx: INestiaMigrateContext): Record<string, string> => {
12
- const dict: HashMap<string[], NestiaMigrateApiFileProgrammer.IProps> =
13
- new HashMap(
14
- (x) => hash(x.join(".")),
15
- (x, y) => x.length === y.length && x.join(".") === y.join("."),
16
- );
17
- for (const route of ctx.routes) {
18
- const namespace: string[] = route.accessor.slice(0, -1);
19
- let last: NestiaMigrateApiFileProgrammer.IProps = dict.take(
20
- namespace,
21
- () => ({
22
- config: ctx.config,
23
- components: ctx.document.components,
24
- namespace,
25
- routes: [],
26
- children: new Set(),
27
- }),
28
- );
29
- last.routes.push(route);
30
- namespace.forEach((_s, i, array) => {
31
- const partial: string[] = namespace.slice(0, array.length - i - 1);
32
- const props: NestiaMigrateApiFileProgrammer.IProps = dict.take(
33
- partial,
34
- () => ({
35
- config: ctx.config,
36
- components: ctx.document.components,
37
- namespace: partial,
38
- children: new Set(),
39
- routes: [],
40
- }),
41
- );
42
- props.children.add(last.namespace.at(-1)!);
43
- last = props;
44
- });
45
- }
46
-
47
- // DO GENERATE
48
- const files: Record<string, string> = Object.fromEntries(
49
- dict.toJSON().map(({ second: value }) => [
50
- `src/${ctx.mode === "nest" ? "api/" : ""}functional/${[...value.namespace, "index.ts"].join("/")}`,
51
- FilePrinter.write({
52
- statements: NestiaMigrateApiFileProgrammer.write({
53
- ...value,
54
- config: ctx.config,
55
- components: ctx.document.components,
56
- }),
57
- }),
58
- ]),
59
- );
60
- if (ctx.mode === "sdk")
61
- for (const [key, value] of NestiaMigrateDtoProgrammer.compose({
62
- config: ctx.config,
63
- components: ctx.document.components,
64
- }).entries())
65
- files[`src/structures/${key}.ts`] = FilePrinter.write({
66
- statements: writeDtoFile(key, value),
67
- });
68
- return files;
69
- };
70
-
71
- const writeDtoFile = (
72
- key: string,
73
- modulo: NestiaMigrateDtoProgrammer.IModule,
74
- ): ts.Statement[] => {
75
- const importer = new NestiaMigrateImportProgrammer();
76
- const statements: ts.Statement[] = iterate(importer, modulo);
77
- if (statements.length === 0) return [];
78
- return [
79
- ...importer.toStatements((name) => `./${name}`, key),
80
- ...(importer.empty() ? [] : [FilePrinter.newLine()]),
81
- ...statements,
82
- ];
83
- };
84
-
85
- const iterate = (
86
- importer: NestiaMigrateImportProgrammer,
87
- modulo: NestiaMigrateDtoProgrammer.IModule,
88
- ): ts.Statement[] => {
89
- const output: ts.Statement[] = [];
90
- if (modulo.programmer !== null) output.push(modulo.programmer(importer));
91
- if (modulo.children.size !== 0) {
92
- const internal: ts.Statement[] = [];
93
- for (const child of modulo.children.values())
94
- internal.push(...iterate(importer, child));
95
- output.push(
96
- ts.factory.createModuleDeclaration(
97
- [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
98
- ts.factory.createIdentifier(modulo.name),
99
- ts.factory.createModuleBlock(internal),
100
- ts.NodeFlags.Namespace,
101
- ),
102
- );
103
- }
104
- output.push(FilePrinter.newLine());
105
- return output;
106
- };
107
- }
1
+ import { HashMap, hash } from "tstl";
2
+ import ts from "typescript";
3
+
4
+ import { INestiaMigrateContext } from "../structures/INestiaMigrateContext";
5
+ import { FilePrinter } from "../utils/FilePrinter";
6
+ import { NestiaMigrateApiFileProgrammer } from "./NestiaMigrateApiFileProgrammer";
7
+ import { NestiaMigrateDtoProgrammer } from "./NestiaMigrateDtoProgrammer";
8
+ import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
9
+
10
+ export namespace NestiaMigrateApiProgrammer {
11
+ export const write = (ctx: INestiaMigrateContext): Record<string, string> => {
12
+ const dict: HashMap<string[], NestiaMigrateApiFileProgrammer.IProps> =
13
+ new HashMap(
14
+ (x) => hash(x.join(".")),
15
+ (x, y) => x.length === y.length && x.join(".") === y.join("."),
16
+ );
17
+ for (const route of ctx.routes) {
18
+ const namespace: string[] = route.accessor.slice(0, -1);
19
+ let last: NestiaMigrateApiFileProgrammer.IProps = dict.take(
20
+ namespace,
21
+ () => ({
22
+ config: ctx.config,
23
+ components: ctx.document.components,
24
+ namespace,
25
+ routes: [],
26
+ children: new Set(),
27
+ }),
28
+ );
29
+ last.routes.push(route);
30
+ namespace.forEach((_s, i, array) => {
31
+ const partial: string[] = namespace.slice(0, array.length - i - 1);
32
+ const props: NestiaMigrateApiFileProgrammer.IProps = dict.take(
33
+ partial,
34
+ () => ({
35
+ config: ctx.config,
36
+ components: ctx.document.components,
37
+ namespace: partial,
38
+ children: new Set(),
39
+ routes: [],
40
+ }),
41
+ );
42
+ props.children.add(last.namespace.at(-1)!);
43
+ last = props;
44
+ });
45
+ }
46
+
47
+ // DO GENERATE
48
+ const files: Record<string, string> = Object.fromEntries(
49
+ dict.toJSON().map(({ second: value }) => [
50
+ `src/${ctx.mode === "nest" ? "api/" : ""}functional/${[...value.namespace, "index.ts"].join("/")}`,
51
+ FilePrinter.write({
52
+ statements: NestiaMigrateApiFileProgrammer.write({
53
+ ...value,
54
+ config: ctx.config,
55
+ components: ctx.document.components,
56
+ }),
57
+ }),
58
+ ]),
59
+ );
60
+ if (ctx.mode === "sdk")
61
+ for (const [key, value] of NestiaMigrateDtoProgrammer.compose({
62
+ config: ctx.config,
63
+ components: ctx.document.components,
64
+ }).entries())
65
+ files[`src/structures/${key}.ts`] = FilePrinter.write({
66
+ statements: writeDtoFile(key, value),
67
+ });
68
+ return files;
69
+ };
70
+
71
+ const writeDtoFile = (
72
+ key: string,
73
+ modulo: NestiaMigrateDtoProgrammer.IModule,
74
+ ): ts.Statement[] => {
75
+ const importer = new NestiaMigrateImportProgrammer();
76
+ const statements: ts.Statement[] = iterate(importer, modulo);
77
+ if (statements.length === 0) return [];
78
+ return [
79
+ ...importer.toStatements((name) => `./${name}`, key),
80
+ ...(importer.empty() ? [] : [FilePrinter.newLine()]),
81
+ ...statements,
82
+ ];
83
+ };
84
+
85
+ const iterate = (
86
+ importer: NestiaMigrateImportProgrammer,
87
+ modulo: NestiaMigrateDtoProgrammer.IModule,
88
+ ): ts.Statement[] => {
89
+ const output: ts.Statement[] = [];
90
+ if (modulo.programmer !== null) output.push(modulo.programmer(importer));
91
+ if (modulo.children.size !== 0) {
92
+ const internal: ts.Statement[] = [];
93
+ for (const child of modulo.children.values())
94
+ internal.push(...iterate(importer, child));
95
+ output.push(
96
+ ts.factory.createModuleDeclaration(
97
+ [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
98
+ ts.factory.createIdentifier(modulo.name),
99
+ ts.factory.createModuleBlock(internal),
100
+ ts.NodeFlags.Namespace,
101
+ ),
102
+ );
103
+ }
104
+ output.push(FilePrinter.newLine());
105
+ return output;
106
+ };
107
+ }