@nestia/migrate 4.6.0 → 4.6.1-dev.20250117

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 (49) hide show
  1. package/README.md +87 -87
  2. package/lib/bundles/NEST_TEMPLATE.js +66 -66
  3. package/lib/bundles/NEST_TEMPLATE.js.map +1 -1
  4. package/lib/bundles/SDK_TEMPLATE.js +30 -30
  5. package/lib/bundles/SDK_TEMPLATE.js.map +1 -1
  6. package/lib/index.mjs +92 -92
  7. package/lib/utils/openapi-down-convert/converter.js +2 -2
  8. package/package.json +6 -6
  9. package/src/MigrateApplication.ts +107 -107
  10. package/src/analyzers/MigrateApplicationAnalyzer.ts +18 -18
  11. package/src/analyzers/MigrateControllerAnalyzer.ts +51 -51
  12. package/src/archivers/MigrateFileArchiver.ts +38 -38
  13. package/src/bundles/NEST_TEMPLATE.ts +66 -66
  14. package/src/bundles/SDK_TEMPLATE.ts +30 -30
  15. package/src/executable/bundle.js +125 -125
  16. package/src/executable/migrate.ts +7 -7
  17. package/src/factories/TypeLiteralFactory.ts +57 -57
  18. package/src/index.ts +4 -4
  19. package/src/internal/MigrateCommander.ts +86 -86
  20. package/src/internal/MigrateInquirer.ts +89 -89
  21. package/src/module.ts +8 -8
  22. package/src/programmers/MigrateApiFileProgrammer.ts +49 -49
  23. package/src/programmers/MigrateApiFunctionProgrammer.ts +210 -210
  24. package/src/programmers/MigrateApiNamespaceProgrammer.ts +417 -417
  25. package/src/programmers/MigrateApiProgrammer.ts +103 -103
  26. package/src/programmers/MigrateApiSimulatationProgrammer.ts +324 -324
  27. package/src/programmers/MigrateApiStartProgrammer.ts +194 -194
  28. package/src/programmers/MigrateDtoProgrammer.ts +87 -87
  29. package/src/programmers/MigrateE2eFileProgrammer.ts +117 -117
  30. package/src/programmers/MigrateE2eProgrammer.ts +34 -34
  31. package/src/programmers/MigrateImportProgrammer.ts +118 -118
  32. package/src/programmers/MigrateNestControllerProgrammer.ts +50 -50
  33. package/src/programmers/MigrateNestMethodProgrammer.ts +393 -393
  34. package/src/programmers/MigrateNestModuleProgrammer.ts +65 -65
  35. package/src/programmers/MigrateNestProgrammer.ts +81 -81
  36. package/src/programmers/MigrateSchemaProgrammer.ts +373 -373
  37. package/src/structures/IHttpMigrateController.ts +8 -8
  38. package/src/structures/IHttpMigrateDto.ts +8 -8
  39. package/src/structures/IHttpMigrateFile.ts +5 -5
  40. package/src/structures/IHttpMigrateProgram.ts +27 -27
  41. package/src/structures/IHttpMigrateRoute.ts +1 -1
  42. package/src/structures/IHttpMigrateSchema.ts +4 -4
  43. package/src/utils/FilePrinter.ts +36 -36
  44. package/src/utils/MapUtil.ts +13 -13
  45. package/src/utils/OpenApiTypeChecker.ts +73 -73
  46. package/src/utils/SetupWizard.ts +12 -12
  47. package/src/utils/StringUtil.ts +113 -113
  48. package/src/utils/openapi-down-convert/RefVisitor.ts +139 -139
  49. package/src/utils/openapi-down-convert/converter.ts +527 -527
@@ -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
+ }