@nestia/migrate 4.6.1-dev.20250117 → 4.6.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 (57) hide show
  1. package/README.md +92 -87
  2. package/lib/MigrateApplication.js +3 -3
  3. package/lib/bundles/NEST_TEMPLATE.js +84 -64
  4. package/lib/bundles/NEST_TEMPLATE.js.map +1 -1
  5. package/lib/bundles/SDK_TEMPLATE.js +30 -30
  6. package/lib/bundles/SDK_TEMPLATE.js.map +1 -1
  7. package/lib/index.mjs +118 -102
  8. package/lib/index.mjs.map +1 -1
  9. package/lib/programmers/MigrateApiNamespaceProgrammer.js +6 -6
  10. package/lib/programmers/MigrateApiNamespaceProgrammer.js.map +1 -1
  11. package/lib/programmers/{MigrateApiSimulatationProgrammer.d.ts → MigrateApiSimulationProgrammer.d.ts} +1 -1
  12. package/lib/programmers/{MigrateApiSimulatationProgrammer.js → MigrateApiSimulationProgrammer.js} +7 -7
  13. package/lib/programmers/MigrateApiSimulationProgrammer.js.map +1 -0
  14. package/lib/utils/openapi-down-convert/converter.js +2 -2
  15. package/package.json +6 -6
  16. package/src/MigrateApplication.ts +107 -107
  17. package/src/analyzers/MigrateApplicationAnalyzer.ts +18 -18
  18. package/src/analyzers/MigrateControllerAnalyzer.ts +51 -51
  19. package/src/archivers/MigrateFileArchiver.ts +38 -38
  20. package/src/bundles/NEST_TEMPLATE.ts +84 -64
  21. package/src/bundles/SDK_TEMPLATE.ts +30 -30
  22. package/src/executable/bundle.js +125 -125
  23. package/src/executable/migrate.ts +7 -7
  24. package/src/factories/TypeLiteralFactory.ts +57 -57
  25. package/src/index.ts +4 -4
  26. package/src/internal/MigrateCommander.ts +86 -86
  27. package/src/internal/MigrateInquirer.ts +89 -89
  28. package/src/module.ts +8 -8
  29. package/src/programmers/MigrateApiFileProgrammer.ts +49 -49
  30. package/src/programmers/MigrateApiFunctionProgrammer.ts +210 -210
  31. package/src/programmers/MigrateApiNamespaceProgrammer.ts +417 -417
  32. package/src/programmers/MigrateApiProgrammer.ts +103 -103
  33. package/src/programmers/{MigrateApiSimulatationProgrammer.ts → MigrateApiSimulationProgrammer.ts} +324 -324
  34. package/src/programmers/MigrateApiStartProgrammer.ts +194 -194
  35. package/src/programmers/MigrateDtoProgrammer.ts +87 -87
  36. package/src/programmers/MigrateE2eFileProgrammer.ts +117 -117
  37. package/src/programmers/MigrateE2eProgrammer.ts +34 -34
  38. package/src/programmers/MigrateImportProgrammer.ts +118 -118
  39. package/src/programmers/MigrateNestControllerProgrammer.ts +50 -50
  40. package/src/programmers/MigrateNestMethodProgrammer.ts +393 -393
  41. package/src/programmers/MigrateNestModuleProgrammer.ts +65 -65
  42. package/src/programmers/MigrateNestProgrammer.ts +81 -81
  43. package/src/programmers/MigrateSchemaProgrammer.ts +373 -373
  44. package/src/structures/IHttpMigrateController.ts +8 -8
  45. package/src/structures/IHttpMigrateDto.ts +8 -8
  46. package/src/structures/IHttpMigrateFile.ts +5 -5
  47. package/src/structures/IHttpMigrateProgram.ts +27 -27
  48. package/src/structures/IHttpMigrateRoute.ts +1 -1
  49. package/src/structures/IHttpMigrateSchema.ts +4 -4
  50. package/src/utils/FilePrinter.ts +36 -36
  51. package/src/utils/MapUtil.ts +13 -13
  52. package/src/utils/OpenApiTypeChecker.ts +73 -73
  53. package/src/utils/SetupWizard.ts +12 -12
  54. package/src/utils/StringUtil.ts +113 -113
  55. package/src/utils/openapi-down-convert/RefVisitor.ts +139 -139
  56. package/src/utils/openapi-down-convert/converter.ts +527 -527
  57. package/lib/programmers/MigrateApiSimulatationProgrammer.js.map +0 -1
@@ -1,89 +1,89 @@
1
- import commander from "commander";
2
- import inquirer from "inquirer";
3
-
4
- export namespace MigrateInquirer {
5
- export interface IOutput {
6
- mode: "nest" | "sdk";
7
- input: string;
8
- output: string;
9
- simulate: boolean;
10
- e2e: boolean;
11
- package: string;
12
- }
13
-
14
- export const parse = async (): Promise<IOutput> => {
15
- // PREPARE ASSETS
16
- commander.program.option("--mode [nest/sdk]", "migration mode");
17
- commander.program.option(
18
- "--input [swagger.json]",
19
- "location of target swagger.json file",
20
- );
21
- commander.program.option("--output [directory]", "output directory path");
22
- commander.program.option("--simulate", "Mockup simulator");
23
- commander.program.option("--e2e [boolean]", "Generate E2E tests");
24
- commander.program.option("--package [name]", "Package name");
25
-
26
- // INTERNAL PROCEDURES
27
- const questioned = { value: false };
28
- const action = (closure: (options: Partial<IOutput>) => Promise<IOutput>) =>
29
- new Promise<IOutput>((resolve, reject) => {
30
- commander.program.action(async (options) => {
31
- try {
32
- resolve(await closure(options));
33
- } catch (exp) {
34
- reject(exp);
35
- }
36
- });
37
- commander.program.parseAsync().catch(reject);
38
- });
39
- const select =
40
- (name: string) =>
41
- (message: string) =>
42
- async <Choice extends string>(
43
- choices: Choice[],
44
- filter?: (value: string) => Choice,
45
- ): Promise<Choice> => {
46
- questioned.value = true;
47
- return (
48
- await inquirer.createPromptModule()({
49
- type: "list",
50
- name: name,
51
- message: message,
52
- choices: choices,
53
- filter,
54
- })
55
- )[name];
56
- };
57
- const input = (name: string) => async (message: string) =>
58
- (
59
- await inquirer.createPromptModule()({
60
- type: "input",
61
- name,
62
- message,
63
- })
64
- )[name];
65
-
66
- // DO CONSTRUCT
67
- return action(async (partial) => {
68
- partial.mode ??= await select("mode")("Migration mode")(
69
- ["NestJS" as "nest", "SDK" as "sdk"],
70
- (value) => (value === "NestJS" ? "nest" : "sdk"),
71
- );
72
- partial.input ??= await input("input")("Swagger file location");
73
- partial.output ??= await input("output")("Output directory path");
74
- partial.package ??= await input("package")("Package name");
75
- if (partial.simulate)
76
- partial.simulate = (partial.simulate as any) === "true";
77
- else
78
- partial.simulate =
79
- (await select("simulate")("Mokup Simulator")(["true", "false"])) ===
80
- "true";
81
- if (partial.e2e) partial.e2e = (partial.e2e as any) === "true";
82
- else
83
- partial.e2e =
84
- (await select("e2e")("Generate E2E tests")(["true", "false"])) ===
85
- "true";
86
- return partial as IOutput;
87
- });
88
- };
89
- }
1
+ import commander from "commander";
2
+ import inquirer from "inquirer";
3
+
4
+ export namespace MigrateInquirer {
5
+ export interface IOutput {
6
+ mode: "nest" | "sdk";
7
+ input: string;
8
+ output: string;
9
+ simulate: boolean;
10
+ e2e: boolean;
11
+ package: string;
12
+ }
13
+
14
+ export const parse = async (): Promise<IOutput> => {
15
+ // PREPARE ASSETS
16
+ commander.program.option("--mode [nest/sdk]", "migration mode");
17
+ commander.program.option(
18
+ "--input [swagger.json]",
19
+ "location of target swagger.json file",
20
+ );
21
+ commander.program.option("--output [directory]", "output directory path");
22
+ commander.program.option("--simulate", "Mockup simulator");
23
+ commander.program.option("--e2e [boolean]", "Generate E2E tests");
24
+ commander.program.option("--package [name]", "Package name");
25
+
26
+ // INTERNAL PROCEDURES
27
+ const questioned = { value: false };
28
+ const action = (closure: (options: Partial<IOutput>) => Promise<IOutput>) =>
29
+ new Promise<IOutput>((resolve, reject) => {
30
+ commander.program.action(async (options) => {
31
+ try {
32
+ resolve(await closure(options));
33
+ } catch (exp) {
34
+ reject(exp);
35
+ }
36
+ });
37
+ commander.program.parseAsync().catch(reject);
38
+ });
39
+ const select =
40
+ (name: string) =>
41
+ (message: string) =>
42
+ async <Choice extends string>(
43
+ choices: Choice[],
44
+ filter?: (value: string) => Choice,
45
+ ): Promise<Choice> => {
46
+ questioned.value = true;
47
+ return (
48
+ await inquirer.createPromptModule()({
49
+ type: "list",
50
+ name: name,
51
+ message: message,
52
+ choices: choices,
53
+ filter,
54
+ })
55
+ )[name];
56
+ };
57
+ const input = (name: string) => async (message: string) =>
58
+ (
59
+ await inquirer.createPromptModule()({
60
+ type: "input",
61
+ name,
62
+ message,
63
+ })
64
+ )[name];
65
+
66
+ // DO CONSTRUCT
67
+ return action(async (partial) => {
68
+ partial.mode ??= await select("mode")("Migration mode")(
69
+ ["NestJS" as "nest", "SDK" as "sdk"],
70
+ (value) => (value === "NestJS" ? "nest" : "sdk"),
71
+ );
72
+ partial.input ??= await input("input")("Swagger file location");
73
+ partial.output ??= await input("output")("Output directory path");
74
+ partial.package ??= await input("package")("Package name");
75
+ if (partial.simulate)
76
+ partial.simulate = (partial.simulate as any) === "true";
77
+ else
78
+ partial.simulate =
79
+ (await select("simulate")("Mokup Simulator")(["true", "false"])) ===
80
+ "true";
81
+ if (partial.e2e) partial.e2e = (partial.e2e as any) === "true";
82
+ else
83
+ partial.e2e =
84
+ (await select("e2e")("Generate E2E tests")(["true", "false"])) ===
85
+ "true";
86
+ return partial as IOutput;
87
+ });
88
+ };
89
+ }
package/src/module.ts CHANGED
@@ -1,8 +1,8 @@
1
- export * from "./MigrateApplication";
2
-
3
- export * from "./analyzers/MigrateApplicationAnalyzer";
4
-
5
- export * from "./archivers/MigrateFileArchiver";
6
-
7
- export * from "./structures/IHttpMigrateProgram";
8
- export * from "./structures/IHttpMigrateSchema";
1
+ export * from "./MigrateApplication";
2
+
3
+ export * from "./analyzers/MigrateApplicationAnalyzer";
4
+
5
+ export * from "./archivers/MigrateFileArchiver";
6
+
7
+ export * from "./structures/IHttpMigrateProgram";
8
+ export * from "./structures/IHttpMigrateSchema";
@@ -1,49 +1,49 @@
1
- import { IHttpMigrateRoute, OpenApi } from "@samchon/openapi";
2
- import ts from "typescript";
3
-
4
- import { IHttpMigrateProgram } from "../structures/IHttpMigrateProgram";
5
- import { MigrateApiFunctionProgrammer } from "./MigrateApiFunctionProgrammer";
6
- import { MigrateApiNamespaceProgrammer } from "./MigrateApiNamespaceProgrammer";
7
- import { MigrateImportProgrammer } from "./MigrateImportProgrammer";
8
-
9
- export namespace MigrateApiFileProgrammer {
10
- export interface IProps {
11
- namespace: string[];
12
- routes: IHttpMigrateRoute[];
13
- children: Set<string>;
14
- }
15
- export const write =
16
- (config: IHttpMigrateProgram.IConfig) =>
17
- (components: OpenApi.IComponents) =>
18
- (props: IProps): ts.Statement[] => {
19
- const importer: MigrateImportProgrammer = new MigrateImportProgrammer();
20
- const statements: ts.Statement[] = props.routes
21
- .map((route) => [
22
- MigrateApiFunctionProgrammer.write(config)(components)(importer)(
23
- route,
24
- ),
25
- MigrateApiNamespaceProgrammer.write(config)(components)(importer)(
26
- route,
27
- ),
28
- ])
29
- .flat();
30
- return [
31
- ...importer.toStatements(
32
- (ref) =>
33
- `../${"../".repeat(props.namespace.length)}structures/${ref}`,
34
- ),
35
- ...[...props.children].map((child) =>
36
- ts.factory.createExportDeclaration(
37
- undefined,
38
- false,
39
- ts.factory.createNamespaceExport(
40
- ts.factory.createIdentifier(child),
41
- ),
42
- ts.factory.createStringLiteral(`./${child}`),
43
- undefined,
44
- ),
45
- ),
46
- ...statements,
47
- ];
48
- };
49
- }
1
+ import { IHttpMigrateRoute, OpenApi } from "@samchon/openapi";
2
+ import ts from "typescript";
3
+
4
+ import { IHttpMigrateProgram } from "../structures/IHttpMigrateProgram";
5
+ import { MigrateApiFunctionProgrammer } from "./MigrateApiFunctionProgrammer";
6
+ import { MigrateApiNamespaceProgrammer } from "./MigrateApiNamespaceProgrammer";
7
+ import { MigrateImportProgrammer } from "./MigrateImportProgrammer";
8
+
9
+ export namespace MigrateApiFileProgrammer {
10
+ export interface IProps {
11
+ namespace: string[];
12
+ routes: IHttpMigrateRoute[];
13
+ children: Set<string>;
14
+ }
15
+ export const write =
16
+ (config: IHttpMigrateProgram.IConfig) =>
17
+ (components: OpenApi.IComponents) =>
18
+ (props: IProps): ts.Statement[] => {
19
+ const importer: MigrateImportProgrammer = new MigrateImportProgrammer();
20
+ const statements: ts.Statement[] = props.routes
21
+ .map((route) => [
22
+ MigrateApiFunctionProgrammer.write(config)(components)(importer)(
23
+ route,
24
+ ),
25
+ MigrateApiNamespaceProgrammer.write(config)(components)(importer)(
26
+ route,
27
+ ),
28
+ ])
29
+ .flat();
30
+ return [
31
+ ...importer.toStatements(
32
+ (ref) =>
33
+ `../${"../".repeat(props.namespace.length)}structures/${ref}`,
34
+ ),
35
+ ...[...props.children].map((child) =>
36
+ ts.factory.createExportDeclaration(
37
+ undefined,
38
+ false,
39
+ ts.factory.createNamespaceExport(
40
+ ts.factory.createIdentifier(child),
41
+ ),
42
+ ts.factory.createStringLiteral(`./${child}`),
43
+ undefined,
44
+ ),
45
+ ),
46
+ ...statements,
47
+ ];
48
+ };
49
+ }