@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.
- package/README.md +87 -87
- package/lib/bundles/NEST_TEMPLATE.js +66 -66
- package/lib/bundles/NEST_TEMPLATE.js.map +1 -1
- package/lib/bundles/SDK_TEMPLATE.js +30 -30
- package/lib/bundles/SDK_TEMPLATE.js.map +1 -1
- package/lib/index.mjs +92 -92
- package/lib/index.mjs.map +1 -1
- package/lib/utils/openapi-down-convert/converter.js +2 -2
- package/package.json +9 -9
- package/src/MigrateApplication.ts +107 -107
- package/src/analyzers/MigrateApplicationAnalyzer.ts +18 -18
- package/src/analyzers/MigrateControllerAnalyzer.ts +51 -51
- package/src/archivers/MigrateFileArchiver.ts +38 -38
- package/src/bundles/NEST_TEMPLATE.ts +66 -66
- package/src/bundles/SDK_TEMPLATE.ts +30 -30
- package/src/executable/bundle.js +125 -125
- package/src/executable/migrate.ts +7 -7
- package/src/factories/TypeLiteralFactory.ts +57 -57
- package/src/index.ts +4 -4
- package/src/internal/MigrateCommander.ts +86 -86
- package/src/internal/MigrateInquirer.ts +89 -89
- package/src/module.ts +8 -8
- package/src/programmers/MigrateApiFileProgrammer.ts +49 -49
- package/src/programmers/MigrateApiFunctionProgrammer.ts +210 -210
- package/src/programmers/MigrateApiNamespaceProgrammer.ts +417 -417
- package/src/programmers/MigrateApiProgrammer.ts +103 -103
- package/src/programmers/MigrateApiSimulatationProgrammer.ts +324 -324
- package/src/programmers/MigrateApiStartProgrammer.ts +194 -194
- package/src/programmers/MigrateDtoProgrammer.ts +87 -87
- package/src/programmers/MigrateE2eFileProgrammer.ts +117 -117
- package/src/programmers/MigrateE2eProgrammer.ts +34 -34
- package/src/programmers/MigrateImportProgrammer.ts +118 -118
- package/src/programmers/MigrateNestControllerProgrammer.ts +50 -50
- package/src/programmers/MigrateNestMethodProgrammer.ts +393 -393
- package/src/programmers/MigrateNestModuleProgrammer.ts +65 -65
- package/src/programmers/MigrateNestProgrammer.ts +81 -81
- package/src/programmers/MigrateSchemaProgrammer.ts +373 -373
- package/src/structures/IHttpMigrateController.ts +8 -8
- package/src/structures/IHttpMigrateDto.ts +8 -8
- package/src/structures/IHttpMigrateFile.ts +5 -5
- package/src/structures/IHttpMigrateProgram.ts +27 -27
- package/src/structures/IHttpMigrateRoute.ts +1 -1
- package/src/structures/IHttpMigrateSchema.ts +4 -4
- package/src/utils/FilePrinter.ts +36 -36
- package/src/utils/MapUtil.ts +13 -13
- package/src/utils/OpenApiTypeChecker.ts +73 -73
- package/src/utils/SetupWizard.ts +12 -12
- package/src/utils/StringUtil.ts +113 -113
- package/src/utils/openapi-down-convert/RefVisitor.ts +139 -139
- 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
|
+
}
|