@nestia/migrate 4.2.0 → 4.3.0-dev.20241215-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 (52) hide show
  1. package/README.md +87 -87
  2. package/lib/MigrateApplication.js +5 -1
  3. package/lib/MigrateApplication.js.map +1 -1
  4. package/lib/bundles/NEST_TEMPLATE.js +66 -66
  5. package/lib/bundles/NEST_TEMPLATE.js.map +1 -1
  6. package/lib/bundles/SDK_TEMPLATE.js +30 -30
  7. package/lib/bundles/SDK_TEMPLATE.js.map +1 -1
  8. package/lib/index.mjs +97 -93
  9. package/lib/index.mjs.map +1 -1
  10. package/lib/utils/openapi-down-convert/converter.js +2 -2
  11. package/package.json +3 -3
  12. package/src/MigrateApplication.ts +107 -107
  13. package/src/analyzers/MigrateAnalyzer.ts +18 -18
  14. package/src/analyzers/MigrateControllerAnalyzer.ts +40 -40
  15. package/src/archivers/MigrateFileArchiver.ts +38 -38
  16. package/src/bundles/NEST_TEMPLATE.ts +66 -66
  17. package/src/bundles/SDK_TEMPLATE.ts +30 -30
  18. package/src/executable/bundle.js +125 -125
  19. package/src/executable/migrate.ts +7 -7
  20. package/src/factories/TypeLiteralFactory.ts +57 -57
  21. package/src/index.ts +4 -4
  22. package/src/internal/MigrateCommander.ts +86 -86
  23. package/src/internal/MigrateInquirer.ts +89 -89
  24. package/src/module.ts +8 -8
  25. package/src/programmers/MigrateApiFileProgrammer.ts +49 -49
  26. package/src/programmers/MigrateApiFunctionProgrammer.ts +210 -210
  27. package/src/programmers/MigrateApiNamespaceProgrammer.ts +417 -417
  28. package/src/programmers/MigrateApiProgrammer.ts +103 -103
  29. package/src/programmers/MigrateApiSimulatationProgrammer.ts +324 -324
  30. package/src/programmers/MigrateApiStartProgrammer.ts +194 -194
  31. package/src/programmers/MigrateDtoProgrammer.ts +87 -87
  32. package/src/programmers/MigrateE2eFileProgrammer.ts +117 -117
  33. package/src/programmers/MigrateE2eProgrammer.ts +34 -34
  34. package/src/programmers/MigrateImportProgrammer.ts +118 -118
  35. package/src/programmers/MigrateNestControllerProgrammer.ts +50 -50
  36. package/src/programmers/MigrateNestMethodProgrammer.ts +371 -371
  37. package/src/programmers/MigrateNestModuleProgrammer.ts +65 -65
  38. package/src/programmers/MigrateNestProgrammer.ts +79 -79
  39. package/src/programmers/MigrateSchemaProgrammer.ts +373 -373
  40. package/src/structures/IHttpMigrateController.ts +8 -8
  41. package/src/structures/IHttpMigrateDto.ts +8 -8
  42. package/src/structures/IHttpMigrateFile.ts +5 -5
  43. package/src/structures/IHttpMigrateProgram.ts +27 -27
  44. package/src/structures/IHttpMigrateRoute.ts +1 -1
  45. package/src/structures/IHttpMigrateSchema.ts +4 -4
  46. package/src/utils/FilePrinter.ts +36 -36
  47. package/src/utils/MapUtil.ts +13 -13
  48. package/src/utils/OpenApiTypeChecker.ts +73 -73
  49. package/src/utils/SetupWizard.ts +12 -12
  50. package/src/utils/StringUtil.ts +113 -113
  51. package/src/utils/openapi-down-convert/RefVisitor.ts +139 -139
  52. package/src/utils/openapi-down-convert/converter.ts +527 -527
@@ -1,40 +1,40 @@
1
- import { IHttpMigrateRoute } from "@samchon/openapi";
2
-
3
- import { IHttpMigrateController } from "../structures/IHttpMigrateController";
4
- import { MapUtil } from "../utils/MapUtil";
5
- import { StringUtil } from "../utils/StringUtil";
6
-
7
- export namespace MigrateControllerAnalyzer {
8
- export const analyze = (
9
- routes: IHttpMigrateRoute[],
10
- ): IHttpMigrateController[] => {
11
- const endpoints: Map<string, IHttpMigrateRoute[]> = new Map();
12
- for (const r of routes) {
13
- const location: string = r.emendedPath
14
- .split("/")
15
- .filter((s) => s[0] !== ":")
16
- .join("/");
17
- MapUtil.take(endpoints)(location)(() => []).push(r);
18
- }
19
- const total: IHttpMigrateController[] = [...endpoints.entries()]
20
- .filter(([_l, routes]) => !!routes.length)
21
- .map(([path, routes]) => {
22
- const name: string =
23
- routes[0].accessor.slice(0, -1).map(StringUtil.capitalize).join("") +
24
- "Controller";
25
- const location: string = routes[0].accessor.slice(0, -2).join("/");
26
- return {
27
- name,
28
- path,
29
- location: "src/controllers/" + location,
30
- routes,
31
- };
32
- });
33
- for (const c of total)
34
- if (c.name === "Controller")
35
- c.name = StringUtil.escapeDuplicate([...total.map((c) => c.name)])(
36
- "AppController",
37
- );
38
- return total;
39
- };
40
- }
1
+ import { IHttpMigrateRoute } from "@samchon/openapi";
2
+
3
+ import { IHttpMigrateController } from "../structures/IHttpMigrateController";
4
+ import { MapUtil } from "../utils/MapUtil";
5
+ import { StringUtil } from "../utils/StringUtil";
6
+
7
+ export namespace MigrateControllerAnalyzer {
8
+ export const analyze = (
9
+ routes: IHttpMigrateRoute[],
10
+ ): IHttpMigrateController[] => {
11
+ const endpoints: Map<string, IHttpMigrateRoute[]> = new Map();
12
+ for (const r of routes) {
13
+ const location: string = r.emendedPath
14
+ .split("/")
15
+ .filter((s) => s[0] !== ":")
16
+ .join("/");
17
+ MapUtil.take(endpoints)(location)(() => []).push(r);
18
+ }
19
+ const total: IHttpMigrateController[] = [...endpoints.entries()]
20
+ .filter(([_l, routes]) => !!routes.length)
21
+ .map(([path, routes]) => {
22
+ const name: string =
23
+ routes[0].accessor.slice(0, -1).map(StringUtil.capitalize).join("") +
24
+ "Controller";
25
+ const location: string = routes[0].accessor.slice(0, -2).join("/");
26
+ return {
27
+ name,
28
+ path,
29
+ location: "src/controllers/" + location,
30
+ routes,
31
+ };
32
+ });
33
+ for (const c of total)
34
+ if (c.name === "Controller")
35
+ c.name = StringUtil.escapeDuplicate([...total.map((c) => c.name)])(
36
+ "AppController",
37
+ );
38
+ return total;
39
+ };
40
+ }
@@ -1,38 +1,38 @@
1
- import { IHttpMigrateFile } from "../structures/IHttpMigrateFile";
2
-
3
- export namespace MigrateFileArchiver {
4
- export interface IOperator {
5
- mkdir(path: string): Promise<void>;
6
- writeFile(path: string, content: string): Promise<void>;
7
- }
8
-
9
- export const archive =
10
- (operator: IOperator) =>
11
- (output: string) =>
12
- async (files: IHttpMigrateFile[]): Promise<void> => {
13
- const visited: Set<string> = new Set();
14
- for (const f of files) {
15
- await mkdir(operator.mkdir)(output)(visited)(f.location);
16
- await operator.writeFile(
17
- [output, f.location, f.file].join("/"),
18
- f.content,
19
- );
20
- }
21
- };
22
-
23
- const mkdir =
24
- (creator: (path: string) => void) =>
25
- (output: string) =>
26
- (visited: Set<string>) =>
27
- async (path: string): Promise<void> => {
28
- const sequence: string[] = path
29
- .split("/")
30
- .map((_str, i, entire) => entire.slice(0, i + 1).join("/"));
31
- for (const s of sequence)
32
- if (visited.has(s) === false)
33
- try {
34
- await creator([output, s].join("/"));
35
- visited.add(s);
36
- } catch {}
37
- };
38
- }
1
+ import { IHttpMigrateFile } from "../structures/IHttpMigrateFile";
2
+
3
+ export namespace MigrateFileArchiver {
4
+ export interface IOperator {
5
+ mkdir(path: string): Promise<void>;
6
+ writeFile(path: string, content: string): Promise<void>;
7
+ }
8
+
9
+ export const archive =
10
+ (operator: IOperator) =>
11
+ (output: string) =>
12
+ async (files: IHttpMigrateFile[]): Promise<void> => {
13
+ const visited: Set<string> = new Set();
14
+ for (const f of files) {
15
+ await mkdir(operator.mkdir)(output)(visited)(f.location);
16
+ await operator.writeFile(
17
+ [output, f.location, f.file].join("/"),
18
+ f.content,
19
+ );
20
+ }
21
+ };
22
+
23
+ const mkdir =
24
+ (creator: (path: string) => void) =>
25
+ (output: string) =>
26
+ (visited: Set<string>) =>
27
+ async (path: string): Promise<void> => {
28
+ const sequence: string[] = path
29
+ .split("/")
30
+ .map((_str, i, entire) => entire.slice(0, i + 1).join("/"));
31
+ for (const s of sequence)
32
+ if (visited.has(s) === false)
33
+ try {
34
+ await creator([output, s].join("/"));
35
+ visited.add(s);
36
+ } catch {}
37
+ };
38
+ }