@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,66 +1,66 @@
1
- import { TypeScriptFactory } from "@nestia/factory";
2
- import ts from "../internal/ts";
3
-
4
- import { INestiaMigrateController } from "../structures/INestiaMigrateController";
5
- import { FilePrinter } from "../utils/FilePrinter";
6
-
7
- export namespace NestiaMigrateNestModuleProgrammer {
8
- export const write = (
9
- controllers: INestiaMigrateController[],
10
- ): ts.Statement[] => [
11
- $import("@nestjs/common")("Module"),
12
- ...(controllers.length ? [FilePrinter.newLine()] : []),
13
- ...controllers.map((c) =>
14
- $import(`${c.location.replace("src/", "./")}/${c.name}`)(c.name),
15
- ),
16
- ...(controllers.length ? [FilePrinter.newLine()] : []),
17
- TypeScriptFactory.createClassDeclaration(
18
- [
19
- TypeScriptFactory.createDecorator(
20
- TypeScriptFactory.createCallExpression(
21
- TypeScriptFactory.createIdentifier("Module"),
22
- undefined,
23
- [
24
- TypeScriptFactory.createObjectLiteralExpression(
25
- [
26
- TypeScriptFactory.createPropertyAssignment(
27
- TypeScriptFactory.createIdentifier("controllers"),
28
- TypeScriptFactory.createArrayLiteralExpression(
29
- controllers.map((c) =>
30
- TypeScriptFactory.createIdentifier(c.name),
31
- ),
32
- true,
33
- ),
34
- ),
35
- ],
36
- true,
37
- ),
38
- ],
39
- ),
40
- ),
41
- TypeScriptFactory.createToken(ts.SyntaxKind.ExportKeyword),
42
- ],
43
- "MyModule",
44
- undefined,
45
- undefined,
46
- [],
47
- ),
48
- ];
49
- }
50
-
51
- const $import = (file: string) => (instance: string) =>
52
- TypeScriptFactory.createImportDeclaration(
53
- undefined,
54
- TypeScriptFactory.createImportClause(
55
- false,
56
- undefined,
57
- TypeScriptFactory.createNamedImports([
58
- TypeScriptFactory.createImportSpecifier(
59
- false,
60
- undefined,
61
- TypeScriptFactory.createIdentifier(instance),
62
- ),
63
- ]),
64
- ),
65
- TypeScriptFactory.createStringLiteral(file),
66
- );
1
+ import { TypeScriptFactory } from "@nestia/factory";
2
+ import ts from "../internal/ts";
3
+
4
+ import { INestiaMigrateController } from "../structures/INestiaMigrateController";
5
+ import { FilePrinter } from "../utils/FilePrinter";
6
+
7
+ export namespace NestiaMigrateNestModuleProgrammer {
8
+ export const write = (
9
+ controllers: INestiaMigrateController[],
10
+ ): ts.Statement[] => [
11
+ $import("@nestjs/common")("Module"),
12
+ ...(controllers.length ? [FilePrinter.newLine()] : []),
13
+ ...controllers.map((c) =>
14
+ $import(`${c.location.replace("src/", "./")}/${c.name}`)(c.name),
15
+ ),
16
+ ...(controllers.length ? [FilePrinter.newLine()] : []),
17
+ TypeScriptFactory.createClassDeclaration(
18
+ [
19
+ TypeScriptFactory.createDecorator(
20
+ TypeScriptFactory.createCallExpression(
21
+ TypeScriptFactory.createIdentifier("Module"),
22
+ undefined,
23
+ [
24
+ TypeScriptFactory.createObjectLiteralExpression(
25
+ [
26
+ TypeScriptFactory.createPropertyAssignment(
27
+ TypeScriptFactory.createIdentifier("controllers"),
28
+ TypeScriptFactory.createArrayLiteralExpression(
29
+ controllers.map((c) =>
30
+ TypeScriptFactory.createIdentifier(c.name),
31
+ ),
32
+ true,
33
+ ),
34
+ ),
35
+ ],
36
+ true,
37
+ ),
38
+ ],
39
+ ),
40
+ ),
41
+ TypeScriptFactory.createToken(ts.SyntaxKind.ExportKeyword),
42
+ ],
43
+ "MyModule",
44
+ undefined,
45
+ undefined,
46
+ [],
47
+ ),
48
+ ];
49
+ }
50
+
51
+ const $import = (file: string) => (instance: string) =>
52
+ TypeScriptFactory.createImportDeclaration(
53
+ undefined,
54
+ TypeScriptFactory.createImportClause(
55
+ false,
56
+ undefined,
57
+ TypeScriptFactory.createNamedImports([
58
+ TypeScriptFactory.createImportSpecifier(
59
+ false,
60
+ undefined,
61
+ TypeScriptFactory.createIdentifier(instance),
62
+ ),
63
+ ]),
64
+ ),
65
+ TypeScriptFactory.createStringLiteral(file),
66
+ );
@@ -1,89 +1,89 @@
1
- import { TypeScriptFactory } from "@nestia/factory";
2
- import ts from "../internal/ts";
3
-
4
- import { NestiaMigrateControllerAnalyzer } from "../analyzers/NestiaMigrateControllerAnalyzer";
5
- import { INestiaMigrateContext } from "../structures/INestiaMigrateContext";
6
- import { INestiaMigrateController } from "../structures/INestiaMigrateController";
7
- import { FilePrinter } from "../utils/FilePrinter";
8
- import { NestiaMigrateDtoProgrammer } from "./NestiaMigrateDtoProgrammer";
9
- import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
10
- import { NestiaMigrateNestControllerProgrammer } from "./NestiaMigrateNestControllerProgrammer";
11
- import { NestiaMigrateNestModuleProgrammer } from "./NestiaMigrateNestModuleProgrammer";
12
-
13
- export namespace NestiaMigrateNestProgrammer {
14
- export const write = (
15
- context: INestiaMigrateContext,
16
- ): Record<string, string> => {
17
- const controllers: INestiaMigrateController[] =
18
- NestiaMigrateControllerAnalyzer.analyze(context.application.routes);
19
- const statements: [string, ts.Statement[]][] = [
20
- ["src/MyModule.ts", NestiaMigrateNestModuleProgrammer.write(controllers)],
21
- ...controllers.map(
22
- (c) =>
23
- [
24
- `${c.location}/${c.name}.ts`,
25
- NestiaMigrateNestControllerProgrammer.write({
26
- config: context.config,
27
- components: context.application.document().components,
28
- controller: c,
29
- }),
30
- ] satisfies [string, ts.Statement[]],
31
- ),
32
- ...[
33
- ...NestiaMigrateDtoProgrammer.compose({
34
- config: context.config,
35
- components: context.application.document().components,
36
- }).entries(),
37
- ].map(
38
- ([key, value]) =>
39
- [`src/api/structures/${key}.ts`, writeDtoFile(key, value)] satisfies [
40
- string,
41
- ts.Statement[],
42
- ],
43
- ),
44
- ];
45
- return Object.fromEntries(
46
- statements.map(([key, value]) => [
47
- key,
48
- FilePrinter.write({ statements: value }),
49
- ]),
50
- );
51
- };
52
-
53
- const writeDtoFile = (
54
- key: string,
55
- modulo: NestiaMigrateDtoProgrammer.IModule,
56
- ): ts.Statement[] => {
57
- const importer = new NestiaMigrateImportProgrammer();
58
- const statements: ts.Statement[] = iterate(importer)(modulo);
59
- if (statements.length === 0) return [];
60
-
61
- return [
62
- ...importer.toStatements((name) => `./${name}`, key),
63
- ...(importer.empty() ? [] : [FilePrinter.newLine()]),
64
- ...statements,
65
- ];
66
- };
67
-
68
- const iterate =
69
- (importer: NestiaMigrateImportProgrammer) =>
70
- (modulo: NestiaMigrateDtoProgrammer.IModule): ts.Statement[] => {
71
- const output: ts.Statement[] = [];
72
- if (modulo.programmer !== null) output.push(modulo.programmer(importer));
73
- if (modulo.children.size) {
74
- const internal: ts.Statement[] = [];
75
- for (const child of modulo.children.values())
76
- internal.push(...iterate(importer)(child));
77
- output.push(
78
- TypeScriptFactory.createModuleDeclaration(
79
- [TypeScriptFactory.createModifier(ts.SyntaxKind.ExportKeyword)],
80
- TypeScriptFactory.createIdentifier(modulo.name),
81
- TypeScriptFactory.createModuleBlock(internal),
82
- ts.NodeFlags.Namespace,
83
- ),
84
- );
85
- }
86
- output.push(FilePrinter.newLine());
87
- return output;
88
- };
89
- }
1
+ import { TypeScriptFactory } from "@nestia/factory";
2
+ import ts from "../internal/ts";
3
+
4
+ import { NestiaMigrateControllerAnalyzer } from "../analyzers/NestiaMigrateControllerAnalyzer";
5
+ import { INestiaMigrateContext } from "../structures/INestiaMigrateContext";
6
+ import { INestiaMigrateController } from "../structures/INestiaMigrateController";
7
+ import { FilePrinter } from "../utils/FilePrinter";
8
+ import { NestiaMigrateDtoProgrammer } from "./NestiaMigrateDtoProgrammer";
9
+ import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
10
+ import { NestiaMigrateNestControllerProgrammer } from "./NestiaMigrateNestControllerProgrammer";
11
+ import { NestiaMigrateNestModuleProgrammer } from "./NestiaMigrateNestModuleProgrammer";
12
+
13
+ export namespace NestiaMigrateNestProgrammer {
14
+ export const write = (
15
+ context: INestiaMigrateContext,
16
+ ): Record<string, string> => {
17
+ const controllers: INestiaMigrateController[] =
18
+ NestiaMigrateControllerAnalyzer.analyze(context.application.routes);
19
+ const statements: [string, ts.Statement[]][] = [
20
+ ["src/MyModule.ts", NestiaMigrateNestModuleProgrammer.write(controllers)],
21
+ ...controllers.map(
22
+ (c) =>
23
+ [
24
+ `${c.location}/${c.name}.ts`,
25
+ NestiaMigrateNestControllerProgrammer.write({
26
+ config: context.config,
27
+ components: context.application.document().components,
28
+ controller: c,
29
+ }),
30
+ ] satisfies [string, ts.Statement[]],
31
+ ),
32
+ ...[
33
+ ...NestiaMigrateDtoProgrammer.compose({
34
+ config: context.config,
35
+ components: context.application.document().components,
36
+ }).entries(),
37
+ ].map(
38
+ ([key, value]) =>
39
+ [`src/api/structures/${key}.ts`, writeDtoFile(key, value)] satisfies [
40
+ string,
41
+ ts.Statement[],
42
+ ],
43
+ ),
44
+ ];
45
+ return Object.fromEntries(
46
+ statements.map(([key, value]) => [
47
+ key,
48
+ FilePrinter.write({ statements: value }),
49
+ ]),
50
+ );
51
+ };
52
+
53
+ const writeDtoFile = (
54
+ key: string,
55
+ modulo: NestiaMigrateDtoProgrammer.IModule,
56
+ ): ts.Statement[] => {
57
+ const importer = new NestiaMigrateImportProgrammer();
58
+ const statements: ts.Statement[] = iterate(importer)(modulo);
59
+ if (statements.length === 0) return [];
60
+
61
+ return [
62
+ ...importer.toStatements((name) => `./${name}`, key),
63
+ ...(importer.empty() ? [] : [FilePrinter.newLine()]),
64
+ ...statements,
65
+ ];
66
+ };
67
+
68
+ const iterate =
69
+ (importer: NestiaMigrateImportProgrammer) =>
70
+ (modulo: NestiaMigrateDtoProgrammer.IModule): ts.Statement[] => {
71
+ const output: ts.Statement[] = [];
72
+ if (modulo.programmer !== null) output.push(modulo.programmer(importer));
73
+ if (modulo.children.size) {
74
+ const internal: ts.Statement[] = [];
75
+ for (const child of modulo.children.values())
76
+ internal.push(...iterate(importer)(child));
77
+ output.push(
78
+ TypeScriptFactory.createModuleDeclaration(
79
+ [TypeScriptFactory.createModifier(ts.SyntaxKind.ExportKeyword)],
80
+ TypeScriptFactory.createIdentifier(modulo.name),
81
+ TypeScriptFactory.createModuleBlock(internal),
82
+ ts.NodeFlags.Namespace,
83
+ ),
84
+ );
85
+ }
86
+ output.push(FilePrinter.newLine());
87
+ return output;
88
+ };
89
+ }