@nestia/migrate 0.11.3 → 0.11.5

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 (55) hide show
  1. package/lib/analyzers/MigrateMethodAnalyzer.js +1 -1
  2. package/lib/analyzers/MigrateMethodAnalyzer.js.map +1 -1
  3. package/lib/bundles/NEST_TEMPLATE.js +5 -5
  4. package/lib/bundles/NEST_TEMPLATE.js.map +1 -1
  5. package/lib/bundles/SDK_TEMPLATE.js +1 -1
  6. package/lib/bundles/SDK_TEMPLATE.js.map +1 -1
  7. package/lib/utils/openapi-down-convert/converter.js +2 -2
  8. package/package.json +75 -75
  9. package/src/MigrateApplication.ts +81 -81
  10. package/src/analyzers/MigrateAnalyzer.ts +9 -9
  11. package/src/analyzers/MigrateControllerAnalyzer.ts +135 -135
  12. package/src/analyzers/MigrateMethodAnalyzer.ts +439 -437
  13. package/src/archivers/MigrateFileArchiver.ts +38 -38
  14. package/src/bundles/NEST_TEMPLATE.ts +5 -5
  15. package/src/bundles/SDK_TEMPLATE.ts +1 -1
  16. package/src/executable/bundle.ts +110 -110
  17. package/src/internal/MigrateCommander.ts +70 -70
  18. package/src/internal/MigrateInquirer.ts +86 -86
  19. package/src/module.ts +14 -14
  20. package/src/programmers/MigrateApiFileProgrammer.ts +53 -53
  21. package/src/programmers/MigrateApiFunctionProgrammer.ts +199 -199
  22. package/src/programmers/MigrateApiNamespaceProgrammer.ts +431 -431
  23. package/src/programmers/MigrateApiProgrammer.ts +170 -170
  24. package/src/programmers/MigrateApiSimulatationProgrammer.ts +327 -327
  25. package/src/programmers/MigrateApiStartProgrammer.ts +194 -194
  26. package/src/programmers/MigrateDtoProgrammer.ts +78 -78
  27. package/src/programmers/MigrateE2eFileProgrammer.ts +117 -117
  28. package/src/programmers/MigrateE2eProgrammer.ts +36 -36
  29. package/src/programmers/MigrateImportProgrammer.ts +121 -121
  30. package/src/programmers/MigrateNestControllerProgrammer.ts +50 -50
  31. package/src/programmers/MigrateNestMethodProgrammer.ts +250 -250
  32. package/src/programmers/MigrateNestModuleProgrammer.ts +63 -63
  33. package/src/programmers/MigrateNestProgrammer.ts +74 -74
  34. package/src/programmers/MigrateSchemaProgrammer.ts +267 -267
  35. package/src/structures/IMigrateDto.ts +8 -8
  36. package/src/structures/IMigrateProgram.ts +27 -27
  37. package/src/structures/IMigrateRoute.ts +51 -51
  38. package/src/structures/ISwagger.ts +23 -23
  39. package/src/structures/ISwaggerComponents.ts +14 -14
  40. package/src/structures/ISwaggerRoute.ts +20 -20
  41. package/src/structures/ISwaggerRouteBodyContent.ts +15 -15
  42. package/src/structures/ISwaggerRouteParameter.ts +14 -14
  43. package/src/structures/ISwaggerRouteRequestBody.ts +12 -12
  44. package/src/structures/ISwaggerRouteResponse.ts +11 -11
  45. package/src/structures/ISwaggerSchema.ts +90 -90
  46. package/src/structures/ISwaggerSecurityScheme.ts +47 -47
  47. package/src/structures/ISwaggerV20.ts +10 -10
  48. package/src/structures/ISwaggerV31.ts +10 -10
  49. package/src/utils/FilePrinter.ts +36 -36
  50. package/src/utils/OpenApiConverter.ts +19 -19
  51. package/src/utils/StringUtil.ts +60 -60
  52. package/src/utils/SwaggerComponentsExplorer.ts +43 -43
  53. package/src/utils/SwaggerTypeChecker.ts +67 -67
  54. package/src/utils/openapi-down-convert/RefVisitor.ts +139 -139
  55. package/src/utils/openapi-down-convert/converter.ts +527 -527
@@ -1,86 +1,86 @@
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
- }
12
-
13
- export const parse = async (): Promise<IOutput> => {
14
- // PREPARE ASSETS
15
- commander.program.option("--mode [nest/sdk]", "migration mode");
16
- commander.program.option(
17
- "--input [swagger.json]",
18
- "location of target swagger.json file",
19
- );
20
- commander.program.option("--output [directory]", "output directory path");
21
- commander.program.option("--simulate", "Mockup simulator");
22
- commander.program.option("--e2e [boolean]", "Generate E2E tests");
23
-
24
- // INTERNAL PROCEDURES
25
- const questioned = { value: false };
26
- const action = (closure: (options: Partial<IOutput>) => Promise<IOutput>) =>
27
- new Promise<IOutput>((resolve, reject) => {
28
- commander.program.action(async (options) => {
29
- try {
30
- resolve(await closure(options));
31
- } catch (exp) {
32
- reject(exp);
33
- }
34
- });
35
- commander.program.parseAsync().catch(reject);
36
- });
37
- const select =
38
- (name: string) =>
39
- (message: string) =>
40
- async <Choice extends string>(
41
- choices: Choice[],
42
- filter?: (value: string) => Choice,
43
- ): Promise<Choice> => {
44
- questioned.value = true;
45
- return (
46
- await inquirer.createPromptModule()({
47
- type: "list",
48
- name: name,
49
- message: message,
50
- choices: choices,
51
- filter,
52
- })
53
- )[name];
54
- };
55
- const input = (name: string) => async (message: string) =>
56
- (
57
- await inquirer.createPromptModule()({
58
- type: "input",
59
- name,
60
- message,
61
- })
62
- )[name];
63
-
64
- // DO CONSTRUCT
65
- return action(async (partial) => {
66
- partial.mode ??= await select("mode")("Migration mode")(
67
- ["NestJS" as "nest", "SDK" as "sdk"],
68
- (value) => (value === "NestJS" ? "nest" : "sdk"),
69
- );
70
- partial.input ??= await input("input")("Swagger file location");
71
- partial.output ??= await input("output")("Output directory path");
72
- if (partial.simulate)
73
- partial.simulate = (partial.simulate as any) === "true";
74
- else
75
- partial.simulate =
76
- (await select("simulate")("Mokup Simulator")(["true", "false"])) ===
77
- "true";
78
- if (partial.e2e) partial.e2e = (partial.e2e as any) === "true";
79
- else
80
- partial.e2e =
81
- (await select("e2e")("Generate E2E tests")(["true", "false"])) ===
82
- "true";
83
- return partial as IOutput;
84
- });
85
- };
86
- }
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
+ }
12
+
13
+ export const parse = async (): Promise<IOutput> => {
14
+ // PREPARE ASSETS
15
+ commander.program.option("--mode [nest/sdk]", "migration mode");
16
+ commander.program.option(
17
+ "--input [swagger.json]",
18
+ "location of target swagger.json file",
19
+ );
20
+ commander.program.option("--output [directory]", "output directory path");
21
+ commander.program.option("--simulate", "Mockup simulator");
22
+ commander.program.option("--e2e [boolean]", "Generate E2E tests");
23
+
24
+ // INTERNAL PROCEDURES
25
+ const questioned = { value: false };
26
+ const action = (closure: (options: Partial<IOutput>) => Promise<IOutput>) =>
27
+ new Promise<IOutput>((resolve, reject) => {
28
+ commander.program.action(async (options) => {
29
+ try {
30
+ resolve(await closure(options));
31
+ } catch (exp) {
32
+ reject(exp);
33
+ }
34
+ });
35
+ commander.program.parseAsync().catch(reject);
36
+ });
37
+ const select =
38
+ (name: string) =>
39
+ (message: string) =>
40
+ async <Choice extends string>(
41
+ choices: Choice[],
42
+ filter?: (value: string) => Choice,
43
+ ): Promise<Choice> => {
44
+ questioned.value = true;
45
+ return (
46
+ await inquirer.createPromptModule()({
47
+ type: "list",
48
+ name: name,
49
+ message: message,
50
+ choices: choices,
51
+ filter,
52
+ })
53
+ )[name];
54
+ };
55
+ const input = (name: string) => async (message: string) =>
56
+ (
57
+ await inquirer.createPromptModule()({
58
+ type: "input",
59
+ name,
60
+ message,
61
+ })
62
+ )[name];
63
+
64
+ // DO CONSTRUCT
65
+ return action(async (partial) => {
66
+ partial.mode ??= await select("mode")("Migration mode")(
67
+ ["NestJS" as "nest", "SDK" as "sdk"],
68
+ (value) => (value === "NestJS" ? "nest" : "sdk"),
69
+ );
70
+ partial.input ??= await input("input")("Swagger file location");
71
+ partial.output ??= await input("output")("Output directory path");
72
+ if (partial.simulate)
73
+ partial.simulate = (partial.simulate as any) === "true";
74
+ else
75
+ partial.simulate =
76
+ (await select("simulate")("Mokup Simulator")(["true", "false"])) ===
77
+ "true";
78
+ if (partial.e2e) partial.e2e = (partial.e2e as any) === "true";
79
+ else
80
+ partial.e2e =
81
+ (await select("e2e")("Generate E2E tests")(["true", "false"])) ===
82
+ "true";
83
+ return partial as IOutput;
84
+ });
85
+ };
86
+ }
package/src/module.ts CHANGED
@@ -1,14 +1,14 @@
1
- export * from "./MigrateApplication";
2
-
3
- export * from "./analyzers/MigrateAnalyzer";
4
-
5
- export * from "./archivers/MigrateFileArchiver";
6
-
7
- export * from "./structures/ISwagger";
8
- export * from "./structures/ISwaggerComponents";
9
- export * from "./structures/ISwaggerInfo";
10
- export * from "./structures/ISwaggerRoute";
11
- export * from "./structures/ISwaggerSecurityScheme";
12
- export * from "./structures/ISwaggerSchema";
13
- export * from "./structures/IMigrateProgram";
14
- export * from "./structures/IMigrateSchema";
1
+ export * from "./MigrateApplication";
2
+
3
+ export * from "./analyzers/MigrateAnalyzer";
4
+
5
+ export * from "./archivers/MigrateFileArchiver";
6
+
7
+ export * from "./structures/ISwagger";
8
+ export * from "./structures/ISwaggerComponents";
9
+ export * from "./structures/ISwaggerInfo";
10
+ export * from "./structures/ISwaggerRoute";
11
+ export * from "./structures/ISwaggerSecurityScheme";
12
+ export * from "./structures/ISwaggerSchema";
13
+ export * from "./structures/IMigrateProgram";
14
+ export * from "./structures/IMigrateSchema";
@@ -1,53 +1,53 @@
1
- import ts from "typescript";
2
-
3
- import { IMigrateController } from "../structures/IMigrateController";
4
- import { IMigrateProgram } from "../structures/IMigrateProgram";
5
- import { IMigrateRoute } from "../structures/IMigrateRoute";
6
- import { ISwaggerComponents } from "../structures/ISwaggerComponents";
7
- import { MigrateApiFunctionProgrammer } from "./MigrateApiFunctionProgrammer";
8
- import { MigrateApiNamespaceProgrammer } from "./MigrateApiNamespaceProgrammer";
9
- import { MigrateImportProgrammer } from "./MigrateImportProgrammer";
10
-
11
- export namespace MigrateApiFileProgrammer {
12
- export interface IProps {
13
- namespace: string[];
14
- entries: IEntry[];
15
- children: Set<string>;
16
- }
17
- export interface IEntry {
18
- controller: IMigrateController;
19
- route: IMigrateRoute;
20
- alias: string;
21
- }
22
-
23
- export const write =
24
- (config: IMigrateProgram.IConfig) =>
25
- (components: ISwaggerComponents) =>
26
- (props: IProps): ts.Statement[] => {
27
- const importer: MigrateImportProgrammer = new MigrateImportProgrammer();
28
- const statements: ts.Statement[] = props.entries
29
- .map((p) => [
30
- MigrateApiFunctionProgrammer.write(config)(components)(importer)(p),
31
- MigrateApiNamespaceProgrammer.write(config)(components)(importer)(p),
32
- ])
33
- .flat();
34
- return [
35
- ...importer.toStatements(
36
- (ref) =>
37
- `../${"../".repeat(props.namespace.length)}structures/${ref}`,
38
- ),
39
- ...[...props.children].map((child) =>
40
- ts.factory.createExportDeclaration(
41
- undefined,
42
- false,
43
- ts.factory.createNamespaceExport(
44
- ts.factory.createIdentifier(child),
45
- ),
46
- ts.factory.createStringLiteral(`./${child}`),
47
- undefined,
48
- ),
49
- ),
50
- ...statements,
51
- ];
52
- };
53
- }
1
+ import ts from "typescript";
2
+
3
+ import { IMigrateController } from "../structures/IMigrateController";
4
+ import { IMigrateProgram } from "../structures/IMigrateProgram";
5
+ import { IMigrateRoute } from "../structures/IMigrateRoute";
6
+ import { ISwaggerComponents } from "../structures/ISwaggerComponents";
7
+ import { MigrateApiFunctionProgrammer } from "./MigrateApiFunctionProgrammer";
8
+ import { MigrateApiNamespaceProgrammer } from "./MigrateApiNamespaceProgrammer";
9
+ import { MigrateImportProgrammer } from "./MigrateImportProgrammer";
10
+
11
+ export namespace MigrateApiFileProgrammer {
12
+ export interface IProps {
13
+ namespace: string[];
14
+ entries: IEntry[];
15
+ children: Set<string>;
16
+ }
17
+ export interface IEntry {
18
+ controller: IMigrateController;
19
+ route: IMigrateRoute;
20
+ alias: string;
21
+ }
22
+
23
+ export const write =
24
+ (config: IMigrateProgram.IConfig) =>
25
+ (components: ISwaggerComponents) =>
26
+ (props: IProps): ts.Statement[] => {
27
+ const importer: MigrateImportProgrammer = new MigrateImportProgrammer();
28
+ const statements: ts.Statement[] = props.entries
29
+ .map((p) => [
30
+ MigrateApiFunctionProgrammer.write(config)(components)(importer)(p),
31
+ MigrateApiNamespaceProgrammer.write(config)(components)(importer)(p),
32
+ ])
33
+ .flat();
34
+ return [
35
+ ...importer.toStatements(
36
+ (ref) =>
37
+ `../${"../".repeat(props.namespace.length)}structures/${ref}`,
38
+ ),
39
+ ...[...props.children].map((child) =>
40
+ ts.factory.createExportDeclaration(
41
+ undefined,
42
+ false,
43
+ ts.factory.createNamespaceExport(
44
+ ts.factory.createIdentifier(child),
45
+ ),
46
+ ts.factory.createStringLiteral(`./${child}`),
47
+ undefined,
48
+ ),
49
+ ),
50
+ ...statements,
51
+ ];
52
+ };
53
+ }