@nestia/migrate 4.5.2 → 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 (50) 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/index.mjs.map +1 -1
  8. package/lib/utils/openapi-down-convert/converter.js +2 -2
  9. package/package.json +9 -9
  10. package/src/MigrateApplication.ts +107 -107
  11. package/src/analyzers/MigrateApplicationAnalyzer.ts +18 -18
  12. package/src/analyzers/MigrateControllerAnalyzer.ts +51 -51
  13. package/src/archivers/MigrateFileArchiver.ts +38 -38
  14. package/src/bundles/NEST_TEMPLATE.ts +66 -66
  15. package/src/bundles/SDK_TEMPLATE.ts +30 -30
  16. package/src/executable/bundle.js +125 -125
  17. package/src/executable/migrate.ts +7 -7
  18. package/src/factories/TypeLiteralFactory.ts +57 -57
  19. package/src/index.ts +4 -4
  20. package/src/internal/MigrateCommander.ts +86 -86
  21. package/src/internal/MigrateInquirer.ts +89 -89
  22. package/src/module.ts +8 -8
  23. package/src/programmers/MigrateApiFileProgrammer.ts +49 -49
  24. package/src/programmers/MigrateApiFunctionProgrammer.ts +210 -210
  25. package/src/programmers/MigrateApiNamespaceProgrammer.ts +417 -417
  26. package/src/programmers/MigrateApiProgrammer.ts +103 -103
  27. package/src/programmers/MigrateApiSimulatationProgrammer.ts +324 -324
  28. package/src/programmers/MigrateApiStartProgrammer.ts +194 -194
  29. package/src/programmers/MigrateDtoProgrammer.ts +87 -87
  30. package/src/programmers/MigrateE2eFileProgrammer.ts +117 -117
  31. package/src/programmers/MigrateE2eProgrammer.ts +34 -34
  32. package/src/programmers/MigrateImportProgrammer.ts +118 -118
  33. package/src/programmers/MigrateNestControllerProgrammer.ts +50 -50
  34. package/src/programmers/MigrateNestMethodProgrammer.ts +393 -393
  35. package/src/programmers/MigrateNestModuleProgrammer.ts +65 -65
  36. package/src/programmers/MigrateNestProgrammer.ts +81 -81
  37. package/src/programmers/MigrateSchemaProgrammer.ts +373 -373
  38. package/src/structures/IHttpMigrateController.ts +8 -8
  39. package/src/structures/IHttpMigrateDto.ts +8 -8
  40. package/src/structures/IHttpMigrateFile.ts +5 -5
  41. package/src/structures/IHttpMigrateProgram.ts +27 -27
  42. package/src/structures/IHttpMigrateRoute.ts +1 -1
  43. package/src/structures/IHttpMigrateSchema.ts +4 -4
  44. package/src/utils/FilePrinter.ts +36 -36
  45. package/src/utils/MapUtil.ts +13 -13
  46. package/src/utils/OpenApiTypeChecker.ts +73 -73
  47. package/src/utils/SetupWizard.ts +12 -12
  48. package/src/utils/StringUtil.ts +113 -113
  49. package/src/utils/openapi-down-convert/RefVisitor.ts +139 -139
  50. package/src/utils/openapi-down-convert/converter.ts +527 -527
@@ -1,51 +1,51 @@
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 = (props: {
9
- routes: IHttpMigrateRoute[];
10
- }): IHttpMigrateController[] => {
11
- const collection: Map<string, IHttpMigrateController> = new Map();
12
- for (const route of props.routes) {
13
- const name: string =
14
- route.operation()["x-samchon-controller"] ??
15
- (route.accessor.length <= 1
16
- ? "__App"
17
- : route.accessor.slice(0, -1).map(StringUtil.capitalize).join("")) +
18
- "Controller";
19
- MapUtil.take(collection)(name)(() => ({
20
- name,
21
- path: "@lazy",
22
- location: "@lazy",
23
- routes: [],
24
- })).routes.push(route);
25
- }
26
-
27
- const controllers: IHttpMigrateController[] = [...collection.values()];
28
- for (const col of controllers) {
29
- const splitPath = (r: IHttpMigrateRoute): string[] =>
30
- r.emendedPath.split("/");
31
- const splitLocation = (r: IHttpMigrateRoute): string[] =>
32
- splitPath(r).filter((s) => s[0] !== ":");
33
-
34
- const minPath: string[] = splitPath(col.routes[0]);
35
- const minLocation: string[] = splitLocation(col.routes[0]);
36
- for (const r of col.routes.slice(1)) {
37
- minPath.splice(getSplitIndex(minPath, splitPath(r)));
38
- minLocation.splice(getSplitIndex(minLocation, splitLocation(r)));
39
- }
40
- col.path = minPath.join("/");
41
- col.location = "src/controllers/" + minLocation.join("/");
42
- }
43
- return controllers;
44
- };
45
- }
46
-
47
- const getSplitIndex = (x: string[], y: string[]) => {
48
- const n: number = Math.min(x.length, y.length);
49
- for (let i: number = 0; i < n; ++i) if (x[i] !== y[i]) return i;
50
- return n;
51
- };
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 = (props: {
9
+ routes: IHttpMigrateRoute[];
10
+ }): IHttpMigrateController[] => {
11
+ const collection: Map<string, IHttpMigrateController> = new Map();
12
+ for (const route of props.routes) {
13
+ const name: string =
14
+ route.operation()["x-samchon-controller"] ??
15
+ (route.accessor.length <= 1
16
+ ? "__App"
17
+ : route.accessor.slice(0, -1).map(StringUtil.capitalize).join("")) +
18
+ "Controller";
19
+ MapUtil.take(collection)(name)(() => ({
20
+ name,
21
+ path: "@lazy",
22
+ location: "@lazy",
23
+ routes: [],
24
+ })).routes.push(route);
25
+ }
26
+
27
+ const controllers: IHttpMigrateController[] = [...collection.values()];
28
+ for (const col of controllers) {
29
+ const splitPath = (r: IHttpMigrateRoute): string[] =>
30
+ r.emendedPath.split("/");
31
+ const splitLocation = (r: IHttpMigrateRoute): string[] =>
32
+ splitPath(r).filter((s) => s[0] !== ":");
33
+
34
+ const minPath: string[] = splitPath(col.routes[0]);
35
+ const minLocation: string[] = splitLocation(col.routes[0]);
36
+ for (const r of col.routes.slice(1)) {
37
+ minPath.splice(getSplitIndex(minPath, splitPath(r)));
38
+ minLocation.splice(getSplitIndex(minLocation, splitLocation(r)));
39
+ }
40
+ col.path = minPath.join("/");
41
+ col.location = "src/controllers/" + minLocation.join("/");
42
+ }
43
+ return controllers;
44
+ };
45
+ }
46
+
47
+ const getSplitIndex = (x: string[], y: string[]) => {
48
+ const n: number = Math.min(x.length, y.length);
49
+ for (let i: number = 0; i < n; ++i) if (x[i] !== y[i]) return i;
50
+ return n;
51
+ };
@@ -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
+ }