@nestia/migrate 12.0.0-dev.20260601.1 → 12.0.0-dev.20260612.2

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