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