@nestia/migrate 6.0.6 → 7.0.0-dev.20250606
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 +92 -92
- package/lib/NestiaMigrateApplication.d.ts +23 -0
- package/lib/NestiaMigrateApplication.js +17522 -0
- package/lib/NestiaMigrateApplication.js.map +1 -0
- package/lib/analyzers/NestiaMigrateControllerAnalyzer.d.ts +5 -0
- package/lib/analyzers/{MigrateControllerAnalyzer.js → NestiaMigrateControllerAnalyzer.js} +10 -10
- package/lib/analyzers/NestiaMigrateControllerAnalyzer.js.map +1 -0
- package/lib/archivers/NestiaMigrateFileArchiver.d.ts +8 -0
- package/lib/archivers/NestiaMigrateFileArchiver.js +36 -0
- package/lib/archivers/NestiaMigrateFileArchiver.js.map +1 -0
- package/lib/bundles/NEST_TEMPLATE.d.ts +1 -5
- package/lib/bundles/NEST_TEMPLATE.js +50 -242
- package/lib/bundles/NEST_TEMPLATE.js.map +1 -1
- package/lib/bundles/SDK_TEMPLATE.d.ts +1 -5
- package/lib/bundles/SDK_TEMPLATE.js +23 -107
- package/lib/bundles/SDK_TEMPLATE.js.map +1 -1
- package/lib/{internal/MigrateCommander.d.ts → executable/NestiaMigrateCommander.d.ts} +1 -1
- package/lib/{internal/MigrateCommander.js → executable/NestiaMigrateCommander.js} +23 -21
- package/lib/executable/NestiaMigrateCommander.js.map +1 -0
- package/lib/{internal/MigrateInquirer.d.ts → executable/NestiaMigrateInquirer.d.ts} +2 -1
- package/lib/{internal/MigrateInquirer.js → executable/NestiaMigrateInquirer.js} +22 -9
- package/lib/executable/NestiaMigrateInquirer.js.map +1 -0
- package/lib/executable/migrate.js +2 -2
- package/lib/executable/migrate.js.map +1 -1
- package/lib/index.mjs +10041 -693
- package/lib/index.mjs.map +1 -1
- package/lib/module.d.ts +2 -5
- package/lib/module.js +2 -5
- package/lib/module.js.map +1 -1
- package/lib/programmers/NestiaMigrateApiFileProgrammer.d.ts +13 -0
- package/lib/programmers/NestiaMigrateApiFileProgrammer.js +40 -0
- package/lib/programmers/NestiaMigrateApiFileProgrammer.js.map +1 -0
- package/lib/programmers/NestiaMigrateApiFunctionProgrammer.d.ts +14 -0
- package/lib/programmers/NestiaMigrateApiFunctionProgrammer.js +132 -0
- package/lib/programmers/NestiaMigrateApiFunctionProgrammer.js.map +1 -0
- package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.d.ts +14 -0
- package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.js +237 -0
- package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.js.map +1 -0
- package/lib/programmers/NestiaMigrateApiProgrammer.d.ts +4 -0
- package/lib/programmers/{MigrateApiProgrammer.js → NestiaMigrateApiProgrammer.js} +31 -30
- package/lib/programmers/NestiaMigrateApiProgrammer.js.map +1 -0
- package/lib/programmers/NestiaMigrateApiSimulationProgrammer.d.ts +14 -0
- package/lib/programmers/{MigrateApiSimulationProgrammer.js → NestiaMigrateApiSimulationProgrammer.js} +54 -36
- package/lib/programmers/NestiaMigrateApiSimulationProgrammer.js.map +1 -0
- package/lib/programmers/NestiaMigrateApiStartProgrammer.d.ts +4 -0
- package/lib/programmers/{MigrateApiStartProgrammer.js → NestiaMigrateApiStartProgrammer.js} +23 -20
- package/lib/programmers/NestiaMigrateApiStartProgrammer.js.map +1 -0
- package/lib/programmers/NestiaMigrateDtoProgrammer.d.ts +15 -0
- package/lib/programmers/{MigrateDtoProgrammer.js → NestiaMigrateDtoProgrammer.js} +14 -10
- package/lib/programmers/NestiaMigrateDtoProgrammer.js.map +1 -0
- package/lib/programmers/NestiaMigrateE2eFileProgrammer.d.ts +14 -0
- package/lib/programmers/NestiaMigrateE2eFileProgrammer.js +81 -0
- package/lib/programmers/NestiaMigrateE2eFileProgrammer.js.map +1 -0
- package/lib/programmers/NestiaMigrateE2eProgrammer.d.ts +4 -0
- package/lib/programmers/NestiaMigrateE2eProgrammer.js +32 -0
- package/lib/programmers/NestiaMigrateE2eProgrammer.js.map +1 -0
- package/lib/programmers/{MigrateImportProgrammer.d.ts → NestiaMigrateImportProgrammer.d.ts} +1 -1
- package/lib/programmers/{MigrateImportProgrammer.js → NestiaMigrateImportProgrammer.js} +4 -4
- package/lib/programmers/NestiaMigrateImportProgrammer.js.map +1 -0
- package/lib/programmers/NestiaMigrateNestControllerProgrammer.d.ts +12 -0
- package/lib/programmers/{MigrateNestControllerProgrammer.js → NestiaMigrateNestControllerProgrammer.js} +20 -13
- package/lib/programmers/NestiaMigrateNestControllerProgrammer.js.map +1 -0
- package/lib/programmers/NestiaMigrateNestMethodProgrammer.d.ts +15 -0
- package/lib/programmers/{MigrateNestMethodProgrammer.js → NestiaMigrateNestMethodProgrammer.js} +85 -69
- package/lib/programmers/NestiaMigrateNestMethodProgrammer.js.map +1 -0
- package/lib/programmers/NestiaMigrateNestModuleProgrammer.d.ts +5 -0
- package/lib/programmers/{MigrateNestModuleProgrammer.js → NestiaMigrateNestModuleProgrammer.js} +6 -6
- package/lib/programmers/NestiaMigrateNestModuleProgrammer.js.map +1 -0
- package/lib/programmers/NestiaMigrateNestProgrammer.d.ts +4 -0
- package/lib/programmers/NestiaMigrateNestProgrammer.js +65 -0
- package/lib/programmers/NestiaMigrateNestProgrammer.js.map +1 -0
- package/lib/programmers/NestiaMigrateSchemaProgrammer.d.ts +10 -0
- package/lib/programmers/NestiaMigrateSchemaProgrammer.js +414 -0
- package/lib/programmers/NestiaMigrateSchemaProgrammer.js.map +1 -0
- package/lib/structures/INestiaMigrateConfig.d.ts +10 -0
- package/lib/structures/{IHttpMigrateFile.js → INestiaMigrateConfig.js} +1 -1
- package/lib/structures/INestiaMigrateConfig.js.map +1 -0
- package/lib/structures/INestiaMigrateContext.d.ts +9 -0
- package/lib/structures/INestiaMigrateContext.js +3 -0
- package/lib/structures/INestiaMigrateContext.js.map +1 -0
- package/lib/structures/INestiaMigrateController.d.ts +7 -0
- package/lib/structures/{IHttpMigrateController.js → INestiaMigrateController.js} +1 -1
- package/lib/structures/INestiaMigrateController.js.map +1 -0
- package/lib/structures/{IHttpMigrateDto.d.ts → INestiaMigrateDto.d.ts} +2 -2
- package/lib/structures/{IHttpMigrateRoute.js → INestiaMigrateDto.js} +1 -1
- package/lib/structures/INestiaMigrateDto.js.map +1 -0
- package/lib/structures/{IHttpMigrateFile.d.ts → INestiaMigrateFile.d.ts} +1 -1
- package/lib/structures/{IHttpMigrateDto.js → INestiaMigrateFile.js} +1 -1
- package/lib/structures/INestiaMigrateFile.js.map +1 -0
- package/lib/structures/INestiaMigrateProgram.d.ts +9 -0
- package/lib/structures/INestiaMigrateProgram.js +3 -0
- package/lib/structures/INestiaMigrateProgram.js.map +1 -0
- package/lib/structures/INestiaMigrateSchema.d.ts +4 -0
- package/lib/structures/{IHttpMigrateProgram.js → INestiaMigrateSchema.js} +1 -1
- package/lib/structures/INestiaMigrateSchema.js.map +1 -0
- package/lib/utils/openapi-down-convert/converter.js +2 -2
- package/package.json +8 -8
- package/src/NestiaMigrateApplication.ts +144 -0
- package/src/analyzers/{MigrateControllerAnalyzer.ts → NestiaMigrateControllerAnalyzer.ts} +51 -51
- package/src/archivers/NestiaMigrateFileArchiver.ts +28 -0
- package/src/bundles/NEST_TEMPLATE.ts +50 -242
- package/src/bundles/SDK_TEMPLATE.ts +23 -107
- package/src/{internal/MigrateCommander.ts → executable/NestiaMigrateCommander.ts} +98 -94
- package/src/{internal/MigrateInquirer.ts → executable/NestiaMigrateInquirer.ts} +106 -89
- package/src/executable/bundle.js +129 -127
- package/src/executable/migrate.ts +7 -7
- package/src/factories/TypeLiteralFactory.ts +57 -57
- package/src/index.ts +4 -4
- package/src/module.ts +2 -8
- package/src/programmers/NestiaMigrateApiFileProgrammer.ts +55 -0
- package/src/programmers/NestiaMigrateApiFunctionProgrammer.ts +256 -0
- package/src/programmers/NestiaMigrateApiNamespaceProgrammer.ts +524 -0
- package/src/programmers/NestiaMigrateApiProgrammer.ts +107 -0
- package/src/programmers/NestiaMigrateApiSimulationProgrammer.ts +340 -0
- package/src/programmers/NestiaMigrateApiStartProgrammer.ts +198 -0
- package/src/programmers/{MigrateDtoProgrammer.ts → NestiaMigrateDtoProgrammer.ts} +101 -96
- package/src/programmers/NestiaMigrateE2eFileProgrammer.ts +153 -0
- package/src/programmers/NestiaMigrateE2eProgrammer.ts +46 -0
- package/src/programmers/{MigrateImportProgrammer.ts → NestiaMigrateImportProgrammer.ts} +118 -118
- package/src/programmers/NestiaMigrateNestControllerProgrammer.ts +66 -0
- package/src/programmers/NestiaMigrateNestMethodProgrammer.ts +406 -0
- package/src/programmers/{MigrateNestModuleProgrammer.ts → NestiaMigrateNestModuleProgrammer.ts} +65 -65
- package/src/programmers/NestiaMigrateNestProgrammer.ts +88 -0
- package/src/programmers/NestiaMigrateSchemaProgrammer.ts +475 -0
- package/src/structures/INestiaMigrateConfig.ts +10 -0
- package/src/structures/INestiaMigrateContext.ts +15 -0
- package/src/structures/INestiaMigrateController.ts +8 -0
- package/src/structures/{IHttpMigrateDto.ts → INestiaMigrateDto.ts} +8 -8
- package/src/structures/{IHttpMigrateFile.ts → INestiaMigrateFile.ts} +5 -5
- package/src/structures/INestiaMigrateProgram.ts +11 -0
- package/src/structures/INestiaMigrateSchema.ts +4 -0
- package/src/utils/FilePrinter.ts +38 -38
- 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
- package/lib/MigrateApplication.d.ts +0 -28
- package/lib/MigrateApplication.js +0 -7994
- package/lib/MigrateApplication.js.map +0 -1
- package/lib/analyzers/MigrateApplicationAnalyzer.d.ts +0 -4
- package/lib/analyzers/MigrateApplicationAnalyzer.js +0 -12
- package/lib/analyzers/MigrateApplicationAnalyzer.js.map +0 -1
- package/lib/analyzers/MigrateControllerAnalyzer.d.ts +0 -7
- package/lib/analyzers/MigrateControllerAnalyzer.js.map +0 -1
- package/lib/archivers/MigrateFileArchiver.d.ts +0 -8
- package/lib/archivers/MigrateFileArchiver.js +0 -35
- package/lib/archivers/MigrateFileArchiver.js.map +0 -1
- package/lib/internal/MigrateCommander.js.map +0 -1
- package/lib/internal/MigrateInquirer.js.map +0 -1
- package/lib/programmers/MigrateApiFileProgrammer.d.ts +0 -11
- package/lib/programmers/MigrateApiFileProgrammer.js +0 -30
- package/lib/programmers/MigrateApiFileProgrammer.js.map +0 -1
- package/lib/programmers/MigrateApiFunctionProgrammer.d.ts +0 -9
- package/lib/programmers/MigrateApiFunctionProgrammer.js +0 -102
- package/lib/programmers/MigrateApiFunctionProgrammer.js.map +0 -1
- package/lib/programmers/MigrateApiNamespaceProgrammer.d.ts +0 -9
- package/lib/programmers/MigrateApiNamespaceProgrammer.js +0 -142
- package/lib/programmers/MigrateApiNamespaceProgrammer.js.map +0 -1
- package/lib/programmers/MigrateApiProgrammer.d.ts +0 -5
- package/lib/programmers/MigrateApiProgrammer.js.map +0 -1
- package/lib/programmers/MigrateApiSimulationProgrammer.d.ts +0 -8
- package/lib/programmers/MigrateApiSimulationProgrammer.js.map +0 -1
- package/lib/programmers/MigrateApiStartProgrammer.d.ts +0 -5
- package/lib/programmers/MigrateApiStartProgrammer.js.map +0 -1
- package/lib/programmers/MigrateDtoProgrammer.d.ts +0 -12
- package/lib/programmers/MigrateDtoProgrammer.js.map +0 -1
- package/lib/programmers/MigrateE2eFileProgrammer.d.ts +0 -8
- package/lib/programmers/MigrateE2eFileProgrammer.js +0 -45
- package/lib/programmers/MigrateE2eFileProgrammer.js.map +0 -1
- package/lib/programmers/MigrateE2eProgrammer.d.ts +0 -5
- package/lib/programmers/MigrateE2eProgrammer.js +0 -25
- package/lib/programmers/MigrateE2eProgrammer.js.map +0 -1
- package/lib/programmers/MigrateImportProgrammer.js.map +0 -1
- package/lib/programmers/MigrateNestControllerProgrammer.d.ts +0 -7
- package/lib/programmers/MigrateNestControllerProgrammer.js.map +0 -1
- package/lib/programmers/MigrateNestMethodProgrammer.d.ts +0 -9
- package/lib/programmers/MigrateNestMethodProgrammer.js.map +0 -1
- package/lib/programmers/MigrateNestModuleProgrammer.d.ts +0 -5
- package/lib/programmers/MigrateNestModuleProgrammer.js.map +0 -1
- package/lib/programmers/MigrateNestProgrammer.d.ts +0 -5
- package/lib/programmers/MigrateNestProgrammer.js +0 -69
- package/lib/programmers/MigrateNestProgrammer.js.map +0 -1
- package/lib/programmers/MigrateSchemaProgrammer.d.ts +0 -6
- package/lib/programmers/MigrateSchemaProgrammer.js +0 -335
- package/lib/programmers/MigrateSchemaProgrammer.js.map +0 -1
- package/lib/structures/IHttpMigrateController.d.ts +0 -7
- package/lib/structures/IHttpMigrateController.js.map +0 -1
- package/lib/structures/IHttpMigrateDto.js.map +0 -1
- package/lib/structures/IHttpMigrateFile.js.map +0 -1
- package/lib/structures/IHttpMigrateProgram.d.ts +0 -33
- package/lib/structures/IHttpMigrateProgram.js.map +0 -1
- package/lib/structures/IHttpMigrateRoute.d.ts +0 -1
- package/lib/structures/IHttpMigrateRoute.js.map +0 -1
- package/lib/structures/IHttpMigrateSchema.d.ts +0 -4
- package/lib/structures/IHttpMigrateSchema.js +0 -3
- package/lib/structures/IHttpMigrateSchema.js.map +0 -1
- package/src/MigrateApplication.ts +0 -124
- package/src/analyzers/MigrateApplicationAnalyzer.ts +0 -18
- package/src/archivers/MigrateFileArchiver.ts +0 -38
- package/src/programmers/MigrateApiFileProgrammer.ts +0 -51
- package/src/programmers/MigrateApiFunctionProgrammer.ts +0 -213
- package/src/programmers/MigrateApiNamespaceProgrammer.ts +0 -418
- package/src/programmers/MigrateApiProgrammer.ts +0 -104
- package/src/programmers/MigrateApiSimulationProgrammer.ts +0 -324
- package/src/programmers/MigrateApiStartProgrammer.ts +0 -194
- package/src/programmers/MigrateE2eFileProgrammer.ts +0 -117
- package/src/programmers/MigrateE2eProgrammer.ts +0 -34
- package/src/programmers/MigrateNestControllerProgrammer.ts +0 -57
- package/src/programmers/MigrateNestMethodProgrammer.ts +0 -397
- package/src/programmers/MigrateNestProgrammer.ts +0 -84
- package/src/programmers/MigrateSchemaProgrammer.ts +0 -378
- package/src/structures/IHttpMigrateController.ts +0 -8
- package/src/structures/IHttpMigrateProgram.ts +0 -35
- package/src/structures/IHttpMigrateRoute.ts +0 -1
- package/src/structures/IHttpMigrateSchema.ts +0 -4
@@ -1,96 +1,101 @@
|
|
1
|
-
import { OpenApi } from "@samchon/openapi";
|
2
|
-
import { IPointer } from "tstl";
|
3
|
-
import ts from "typescript";
|
4
|
-
|
5
|
-
import {
|
6
|
-
import { FilePrinter } from "../utils/FilePrinter";
|
7
|
-
import { MapUtil } from "../utils/MapUtil";
|
8
|
-
import { StringUtil } from "../utils/StringUtil";
|
9
|
-
import {
|
10
|
-
import {
|
11
|
-
|
12
|
-
export namespace
|
13
|
-
export interface IModule {
|
14
|
-
name: string;
|
15
|
-
children: Map<string, IModule>;
|
16
|
-
programmer:
|
17
|
-
| null
|
18
|
-
| ((importer:
|
19
|
-
}
|
20
|
-
|
21
|
-
export const compose =
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
)
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
(
|
41
|
-
(
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
const
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
(
|
64
|
-
(
|
65
|
-
(
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
...(schema.
|
87
|
-
...(schema.
|
88
|
-
|
89
|
-
? [
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
1
|
+
import { OpenApi } from "@samchon/openapi";
|
2
|
+
import { IPointer } from "tstl";
|
3
|
+
import ts from "typescript";
|
4
|
+
|
5
|
+
import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
|
6
|
+
import { FilePrinter } from "../utils/FilePrinter";
|
7
|
+
import { MapUtil } from "../utils/MapUtil";
|
8
|
+
import { StringUtil } from "../utils/StringUtil";
|
9
|
+
import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
|
10
|
+
import { NestiaMigrateSchemaProgrammer } from "./NestiaMigrateSchemaProgrammer";
|
11
|
+
|
12
|
+
export namespace NestiaMigrateDtoProgrammer {
|
13
|
+
export interface IModule {
|
14
|
+
name: string;
|
15
|
+
children: Map<string, IModule>;
|
16
|
+
programmer:
|
17
|
+
| null
|
18
|
+
| ((importer: NestiaMigrateImportProgrammer) => ts.TypeAliasDeclaration);
|
19
|
+
}
|
20
|
+
|
21
|
+
export const compose = (props: {
|
22
|
+
config: INestiaMigrateConfig;
|
23
|
+
components: OpenApi.IComponents;
|
24
|
+
}): Map<string, IModule> => {
|
25
|
+
const dict: Map<string, IModule> = new Map();
|
26
|
+
for (const [key, value] of Object.entries(props.components.schemas ?? {})) {
|
27
|
+
const emendedKey: string = key
|
28
|
+
.split("/")
|
29
|
+
.filter((str) => str.length !== 0)
|
30
|
+
.map(StringUtil.escapeNonVariable)
|
31
|
+
.join("");
|
32
|
+
prepare(dict)(emendedKey)((importer) =>
|
33
|
+
writeAlias(props.config)(props.components)(importer)(emendedKey, value),
|
34
|
+
);
|
35
|
+
}
|
36
|
+
return dict;
|
37
|
+
};
|
38
|
+
|
39
|
+
const prepare =
|
40
|
+
(dict: Map<string, IModule>) =>
|
41
|
+
(name: string) =>
|
42
|
+
(
|
43
|
+
programmer: (
|
44
|
+
importer: NestiaMigrateImportProgrammer,
|
45
|
+
) => ts.TypeAliasDeclaration,
|
46
|
+
) => {
|
47
|
+
const accessors: string[] = name.split(".");
|
48
|
+
const modulo: IPointer<IModule> = { value: null! };
|
49
|
+
|
50
|
+
accessors.forEach((acc, i) => {
|
51
|
+
modulo.value = MapUtil.take(dict)(acc)(() => ({
|
52
|
+
name: acc,
|
53
|
+
children: new Map(),
|
54
|
+
programmer: null,
|
55
|
+
}));
|
56
|
+
if (i === accessors.length - 1) modulo.value.programmer = programmer;
|
57
|
+
dict = modulo.value.children;
|
58
|
+
});
|
59
|
+
return modulo!;
|
60
|
+
};
|
61
|
+
|
62
|
+
const writeAlias =
|
63
|
+
(config: INestiaMigrateConfig) =>
|
64
|
+
(components: OpenApi.IComponents) =>
|
65
|
+
(importer: NestiaMigrateImportProgrammer) =>
|
66
|
+
(key: string, value: OpenApi.IJsonSchema) =>
|
67
|
+
FilePrinter.description(
|
68
|
+
ts.factory.createTypeAliasDeclaration(
|
69
|
+
[ts.factory.createToken(ts.SyntaxKind.ExportKeyword)],
|
70
|
+
key.split(".").at(-1)!,
|
71
|
+
[],
|
72
|
+
NestiaMigrateSchemaProgrammer.write({
|
73
|
+
components,
|
74
|
+
importer,
|
75
|
+
schema: value,
|
76
|
+
}),
|
77
|
+
),
|
78
|
+
writeComment(config)(value, key.indexOf(".") === -1),
|
79
|
+
);
|
80
|
+
}
|
81
|
+
|
82
|
+
const writeComment =
|
83
|
+
(config: INestiaMigrateConfig) =>
|
84
|
+
(schema: OpenApi.IJsonSchema, top: boolean): string =>
|
85
|
+
[
|
86
|
+
...(schema.description?.length ? [schema.description] : []),
|
87
|
+
...(schema.description?.length &&
|
88
|
+
(schema.title !== undefined || schema.deprecated === true)
|
89
|
+
? [""]
|
90
|
+
: []),
|
91
|
+
...(schema.title !== undefined ? [`@title ${schema.title}`] : []),
|
92
|
+
...(schema.deprecated === true ? [`@deprecated`] : []),
|
93
|
+
...(top
|
94
|
+
? [
|
95
|
+
`@${config.author?.tag ?? "nestia"} ${config.author?.value ?? "Generated by Nestia - https://github.com/samchon/nestia"}`,
|
96
|
+
]
|
97
|
+
: []),
|
98
|
+
]
|
99
|
+
.join("\n")
|
100
|
+
.split("*/")
|
101
|
+
.join("*\\/");
|
@@ -0,0 +1,153 @@
|
|
1
|
+
import { IHttpMigrateRoute, OpenApi } from "@samchon/openapi";
|
2
|
+
import ts from "typescript";
|
3
|
+
import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
|
4
|
+
import { LiteralFactory } from "typia/lib/factories/LiteralFactory";
|
5
|
+
|
6
|
+
import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
|
7
|
+
import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
|
8
|
+
import { NestiaMigrateSchemaProgrammer } from "./NestiaMigrateSchemaProgrammer";
|
9
|
+
|
10
|
+
export namespace NestiaMigrateE2eFunctionProgrammer {
|
11
|
+
export interface IContext {
|
12
|
+
config: INestiaMigrateConfig;
|
13
|
+
components: OpenApi.IComponents;
|
14
|
+
importer: NestiaMigrateImportProgrammer;
|
15
|
+
route: IHttpMigrateRoute;
|
16
|
+
}
|
17
|
+
|
18
|
+
export const write = (ctx: IContext): ts.FunctionDeclaration =>
|
19
|
+
ts.factory.createFunctionDeclaration(
|
20
|
+
[
|
21
|
+
ts.factory.createModifier(ts.SyntaxKind.ExportKeyword),
|
22
|
+
ts.factory.createModifier(ts.SyntaxKind.AsyncKeyword),
|
23
|
+
],
|
24
|
+
undefined,
|
25
|
+
["test", "api", ...ctx.route.accessor].join("_"),
|
26
|
+
undefined,
|
27
|
+
[
|
28
|
+
IdentifierFactory.parameter(
|
29
|
+
"connection",
|
30
|
+
ts.factory.createTypeReferenceNode(
|
31
|
+
ts.factory.createQualifiedName(
|
32
|
+
ts.factory.createIdentifier(
|
33
|
+
ctx.importer.external({
|
34
|
+
type: "default",
|
35
|
+
library: "@ORGANIZATION/PROJECT-api",
|
36
|
+
name: "api",
|
37
|
+
}),
|
38
|
+
),
|
39
|
+
ts.factory.createIdentifier("IConnection"),
|
40
|
+
),
|
41
|
+
),
|
42
|
+
),
|
43
|
+
],
|
44
|
+
undefined,
|
45
|
+
ts.factory.createBlock(writeBody(ctx), true),
|
46
|
+
);
|
47
|
+
|
48
|
+
export const writeBody = (ctx: IContext): ts.Statement[] => [
|
49
|
+
ts.factory.createVariableStatement(
|
50
|
+
[],
|
51
|
+
ts.factory.createVariableDeclarationList(
|
52
|
+
[
|
53
|
+
ts.factory.createVariableDeclaration(
|
54
|
+
"output",
|
55
|
+
undefined,
|
56
|
+
ctx.route.success
|
57
|
+
? NestiaMigrateSchemaProgrammer.write({
|
58
|
+
components: ctx.components,
|
59
|
+
importer: ctx.importer,
|
60
|
+
schema: ctx.route.success.schema,
|
61
|
+
})
|
62
|
+
: undefined,
|
63
|
+
ts.factory.createAwaitExpression(writeCallExpressionn(ctx)),
|
64
|
+
),
|
65
|
+
],
|
66
|
+
ts.NodeFlags.Const,
|
67
|
+
),
|
68
|
+
),
|
69
|
+
ts.factory.createExpressionStatement(
|
70
|
+
ts.factory.createCallExpression(
|
71
|
+
ts.factory.createPropertyAccessExpression(
|
72
|
+
ts.factory.createIdentifier(
|
73
|
+
ctx.importer.external({
|
74
|
+
type: "default",
|
75
|
+
library: "typia",
|
76
|
+
name: "typia",
|
77
|
+
}),
|
78
|
+
),
|
79
|
+
"assert",
|
80
|
+
),
|
81
|
+
undefined,
|
82
|
+
[ts.factory.createIdentifier("output")],
|
83
|
+
),
|
84
|
+
),
|
85
|
+
];
|
86
|
+
|
87
|
+
const writeCallExpressionn = (ctx: IContext): ts.CallExpression => {
|
88
|
+
const fetch = ts.factory.createPropertyAccessExpression(
|
89
|
+
ts.factory.createIdentifier("api.functional"),
|
90
|
+
ts.factory.createIdentifier(ctx.route.accessor.join(".")),
|
91
|
+
);
|
92
|
+
const connection = ts.factory.createIdentifier("connection");
|
93
|
+
if (
|
94
|
+
ctx.route.parameters.length === 0 &&
|
95
|
+
ctx.route.query === null &&
|
96
|
+
ctx.route.body === null
|
97
|
+
)
|
98
|
+
return ts.factory.createCallExpression(fetch, undefined, [connection]);
|
99
|
+
|
100
|
+
const random = ts.factory.createPropertyAccessExpression(
|
101
|
+
ts.factory.createIdentifier(
|
102
|
+
ctx.importer.external({
|
103
|
+
type: "default",
|
104
|
+
library: "typia",
|
105
|
+
name: "typia",
|
106
|
+
}),
|
107
|
+
),
|
108
|
+
"random",
|
109
|
+
);
|
110
|
+
if (ctx.config.keyword === true)
|
111
|
+
return ts.factory.createCallExpression(fetch, undefined, [
|
112
|
+
connection,
|
113
|
+
LiteralFactory.write(
|
114
|
+
Object.fromEntries(
|
115
|
+
[...ctx.route.parameters, ctx.route.query, ctx.route.body]
|
116
|
+
.filter((x) => x !== null)
|
117
|
+
.map(({ key, schema: value }) => [
|
118
|
+
key,
|
119
|
+
ts.factory.createCallExpression(
|
120
|
+
random,
|
121
|
+
[
|
122
|
+
NestiaMigrateSchemaProgrammer.write({
|
123
|
+
components: ctx.components,
|
124
|
+
importer: ctx.importer,
|
125
|
+
schema: value,
|
126
|
+
}),
|
127
|
+
],
|
128
|
+
undefined,
|
129
|
+
),
|
130
|
+
]),
|
131
|
+
),
|
132
|
+
),
|
133
|
+
]);
|
134
|
+
return ts.factory.createCallExpression(fetch, undefined, [
|
135
|
+
connection,
|
136
|
+
...[...ctx.route.parameters, ctx.route.query, ctx.route.body]
|
137
|
+
.filter((p) => !!p)
|
138
|
+
.map((p) =>
|
139
|
+
ts.factory.createCallExpression(
|
140
|
+
random,
|
141
|
+
[
|
142
|
+
NestiaMigrateSchemaProgrammer.write({
|
143
|
+
components: ctx.components,
|
144
|
+
importer: ctx.importer,
|
145
|
+
schema: p.schema,
|
146
|
+
}),
|
147
|
+
],
|
148
|
+
undefined,
|
149
|
+
),
|
150
|
+
),
|
151
|
+
]);
|
152
|
+
};
|
153
|
+
}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import { IHttpMigrateRoute, OpenApi } from "@samchon/openapi";
|
2
|
+
import ts from "typescript";
|
3
|
+
|
4
|
+
import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
|
5
|
+
import { INestiaMigrateContext } from "../structures/INestiaMigrateContext";
|
6
|
+
import { INestiaMigrateFile } from "../structures/INestiaMigrateFile";
|
7
|
+
import { FilePrinter } from "../utils/FilePrinter";
|
8
|
+
import { NestiaMigrateE2eFunctionProgrammer } from "./NestiaMigrateE2eFileProgrammer";
|
9
|
+
import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
|
10
|
+
|
11
|
+
export namespace NestiaMigrateE2eProgrammer {
|
12
|
+
export const write = (ctx: INestiaMigrateContext): Record<string, string> =>
|
13
|
+
Object.fromEntries(
|
14
|
+
ctx.routes
|
15
|
+
.map((r) => writeFile(ctx.config, ctx.document.components, r))
|
16
|
+
.map((r) => [`${r.location}/${r.file}`, r.content]),
|
17
|
+
);
|
18
|
+
|
19
|
+
const writeFile = (
|
20
|
+
config: INestiaMigrateConfig,
|
21
|
+
components: OpenApi.IComponents,
|
22
|
+
route: IHttpMigrateRoute,
|
23
|
+
): INestiaMigrateFile => {
|
24
|
+
const importer: NestiaMigrateImportProgrammer =
|
25
|
+
new NestiaMigrateImportProgrammer();
|
26
|
+
const func: ts.FunctionDeclaration =
|
27
|
+
NestiaMigrateE2eFunctionProgrammer.write({
|
28
|
+
config,
|
29
|
+
components,
|
30
|
+
importer,
|
31
|
+
route,
|
32
|
+
});
|
33
|
+
const statements: ts.Statement[] = [
|
34
|
+
...importer.toStatements(
|
35
|
+
(name) => `@ORGANIZATION/PROJECT-api/lib/structures/${name}`,
|
36
|
+
),
|
37
|
+
FilePrinter.newLine(),
|
38
|
+
func,
|
39
|
+
];
|
40
|
+
return {
|
41
|
+
location: `test/features/api`,
|
42
|
+
file: `${["test", "api", ...route.accessor].join("_")}.ts`,
|
43
|
+
content: FilePrinter.write({ statements }),
|
44
|
+
};
|
45
|
+
};
|
46
|
+
}
|
@@ -1,118 +1,118 @@
|
|
1
|
-
import ts from "typescript";
|
2
|
-
|
3
|
-
import { TypeLiteralFactory } from "../factories/TypeLiteralFactory";
|
4
|
-
import { FilePrinter } from "../utils/FilePrinter";
|
5
|
-
import { MapUtil } from "../utils/MapUtil";
|
6
|
-
|
7
|
-
export class
|
8
|
-
private external_: Map<string, IClause> = new Map();
|
9
|
-
private dtos_: Set<string> = new Set();
|
10
|
-
|
11
|
-
public constructor() {}
|
12
|
-
|
13
|
-
public empty(): boolean {
|
14
|
-
return this.external_.size === 0 && this.dtos_.size === 0;
|
15
|
-
}
|
16
|
-
|
17
|
-
public external(props: MigrateImportProgrammer.IProps): string {
|
18
|
-
const clause: IClause = MapUtil.take(this.external_)(props.library)(() => ({
|
19
|
-
default: null,
|
20
|
-
instances: new Set(),
|
21
|
-
}));
|
22
|
-
const name: string = props.name.split(".")[0];
|
23
|
-
if (props.type === "default") clause.default = props.name;
|
24
|
-
else clause.instances.add(name);
|
25
|
-
return name;
|
26
|
-
}
|
27
|
-
|
28
|
-
public dto(name: string, namespace?: string): ts.TypeReferenceNode {
|
29
|
-
const file: string = name.split(".")[0];
|
30
|
-
this.dtos_.add(file);
|
31
|
-
return ts.factory.createTypeReferenceNode(
|
32
|
-
namespace?.length
|
33
|
-
? ts.factory.createQualifiedName(
|
34
|
-
ts.factory.createIdentifier(namespace),
|
35
|
-
ts.factory.createIdentifier(file),
|
36
|
-
)
|
37
|
-
: name,
|
38
|
-
);
|
39
|
-
}
|
40
|
-
|
41
|
-
public tag(type: string, arg?: any): ts.TypeReferenceNode {
|
42
|
-
const instance: string = this.external({
|
43
|
-
type: "instance",
|
44
|
-
library: "typia",
|
45
|
-
name: "tags",
|
46
|
-
});
|
47
|
-
return ts.factory.createTypeReferenceNode(
|
48
|
-
`${instance}.${type}`,
|
49
|
-
arg === undefined ? [] : [TypeLiteralFactory.generate(arg)],
|
50
|
-
);
|
51
|
-
}
|
52
|
-
|
53
|
-
public toStatements(
|
54
|
-
dtoPath: (name: string) => string,
|
55
|
-
current?: string,
|
56
|
-
): ts.Statement[] {
|
57
|
-
return [
|
58
|
-
...[...this.external_.entries()].map(([library, props]) =>
|
59
|
-
ts.factory.createImportDeclaration(
|
60
|
-
undefined,
|
61
|
-
ts.factory.createImportClause(
|
62
|
-
false,
|
63
|
-
props.default !== null
|
64
|
-
? ts.factory.createIdentifier(props.default)
|
65
|
-
: undefined,
|
66
|
-
props.instances.size
|
67
|
-
? ts.factory.createNamedImports(
|
68
|
-
[...props.instances].map((i) =>
|
69
|
-
ts.factory.createImportSpecifier(
|
70
|
-
false,
|
71
|
-
undefined,
|
72
|
-
ts.factory.createIdentifier(i),
|
73
|
-
),
|
74
|
-
),
|
75
|
-
)
|
76
|
-
: undefined,
|
77
|
-
),
|
78
|
-
ts.factory.createStringLiteral(library),
|
79
|
-
),
|
80
|
-
),
|
81
|
-
...(this.external_.size && this.dtos_.size
|
82
|
-
? [FilePrinter.newLine()]
|
83
|
-
: []),
|
84
|
-
...[...this.dtos_]
|
85
|
-
.filter(
|
86
|
-
current ? (name) => name !== current!.split(".")[0] : () => true,
|
87
|
-
)
|
88
|
-
.map((i) =>
|
89
|
-
ts.factory.createImportDeclaration(
|
90
|
-
undefined,
|
91
|
-
ts.factory.createImportClause(
|
92
|
-
false,
|
93
|
-
undefined,
|
94
|
-
ts.factory.createNamedImports([
|
95
|
-
ts.factory.createImportSpecifier(
|
96
|
-
false,
|
97
|
-
undefined,
|
98
|
-
ts.factory.createIdentifier(i),
|
99
|
-
),
|
100
|
-
]),
|
101
|
-
),
|
102
|
-
ts.factory.createStringLiteral(dtoPath(i)),
|
103
|
-
),
|
104
|
-
),
|
105
|
-
];
|
106
|
-
}
|
107
|
-
}
|
108
|
-
export namespace MigrateImportProgrammer {
|
109
|
-
export interface IProps {
|
110
|
-
type: "default" | "instance";
|
111
|
-
library: string;
|
112
|
-
name: string;
|
113
|
-
}
|
114
|
-
}
|
115
|
-
interface IClause {
|
116
|
-
default: string | null;
|
117
|
-
instances: Set<string>;
|
118
|
-
}
|
1
|
+
import ts from "typescript";
|
2
|
+
|
3
|
+
import { TypeLiteralFactory } from "../factories/TypeLiteralFactory";
|
4
|
+
import { FilePrinter } from "../utils/FilePrinter";
|
5
|
+
import { MapUtil } from "../utils/MapUtil";
|
6
|
+
|
7
|
+
export class NestiaMigrateImportProgrammer {
|
8
|
+
private external_: Map<string, IClause> = new Map();
|
9
|
+
private dtos_: Set<string> = new Set();
|
10
|
+
|
11
|
+
public constructor() {}
|
12
|
+
|
13
|
+
public empty(): boolean {
|
14
|
+
return this.external_.size === 0 && this.dtos_.size === 0;
|
15
|
+
}
|
16
|
+
|
17
|
+
public external(props: MigrateImportProgrammer.IProps): string {
|
18
|
+
const clause: IClause = MapUtil.take(this.external_)(props.library)(() => ({
|
19
|
+
default: null,
|
20
|
+
instances: new Set(),
|
21
|
+
}));
|
22
|
+
const name: string = props.name.split(".")[0];
|
23
|
+
if (props.type === "default") clause.default = props.name;
|
24
|
+
else clause.instances.add(name);
|
25
|
+
return name;
|
26
|
+
}
|
27
|
+
|
28
|
+
public dto(name: string, namespace?: string): ts.TypeReferenceNode {
|
29
|
+
const file: string = name.split(".")[0];
|
30
|
+
this.dtos_.add(file);
|
31
|
+
return ts.factory.createTypeReferenceNode(
|
32
|
+
namespace?.length
|
33
|
+
? ts.factory.createQualifiedName(
|
34
|
+
ts.factory.createIdentifier(namespace),
|
35
|
+
ts.factory.createIdentifier(file),
|
36
|
+
)
|
37
|
+
: name,
|
38
|
+
);
|
39
|
+
}
|
40
|
+
|
41
|
+
public tag(type: string, arg?: any): ts.TypeReferenceNode {
|
42
|
+
const instance: string = this.external({
|
43
|
+
type: "instance",
|
44
|
+
library: "typia",
|
45
|
+
name: "tags",
|
46
|
+
});
|
47
|
+
return ts.factory.createTypeReferenceNode(
|
48
|
+
`${instance}.${type}`,
|
49
|
+
arg === undefined ? [] : [TypeLiteralFactory.generate(arg)],
|
50
|
+
);
|
51
|
+
}
|
52
|
+
|
53
|
+
public toStatements(
|
54
|
+
dtoPath: (name: string) => string,
|
55
|
+
current?: string,
|
56
|
+
): ts.Statement[] {
|
57
|
+
return [
|
58
|
+
...[...this.external_.entries()].map(([library, props]) =>
|
59
|
+
ts.factory.createImportDeclaration(
|
60
|
+
undefined,
|
61
|
+
ts.factory.createImportClause(
|
62
|
+
false,
|
63
|
+
props.default !== null
|
64
|
+
? ts.factory.createIdentifier(props.default)
|
65
|
+
: undefined,
|
66
|
+
props.instances.size
|
67
|
+
? ts.factory.createNamedImports(
|
68
|
+
[...props.instances].map((i) =>
|
69
|
+
ts.factory.createImportSpecifier(
|
70
|
+
false,
|
71
|
+
undefined,
|
72
|
+
ts.factory.createIdentifier(i),
|
73
|
+
),
|
74
|
+
),
|
75
|
+
)
|
76
|
+
: undefined,
|
77
|
+
),
|
78
|
+
ts.factory.createStringLiteral(library),
|
79
|
+
),
|
80
|
+
),
|
81
|
+
...(this.external_.size && this.dtos_.size
|
82
|
+
? [FilePrinter.newLine()]
|
83
|
+
: []),
|
84
|
+
...[...this.dtos_]
|
85
|
+
.filter(
|
86
|
+
current ? (name) => name !== current!.split(".")[0] : () => true,
|
87
|
+
)
|
88
|
+
.map((i) =>
|
89
|
+
ts.factory.createImportDeclaration(
|
90
|
+
undefined,
|
91
|
+
ts.factory.createImportClause(
|
92
|
+
false,
|
93
|
+
undefined,
|
94
|
+
ts.factory.createNamedImports([
|
95
|
+
ts.factory.createImportSpecifier(
|
96
|
+
false,
|
97
|
+
undefined,
|
98
|
+
ts.factory.createIdentifier(i),
|
99
|
+
),
|
100
|
+
]),
|
101
|
+
),
|
102
|
+
ts.factory.createStringLiteral(dtoPath(i)),
|
103
|
+
),
|
104
|
+
),
|
105
|
+
];
|
106
|
+
}
|
107
|
+
}
|
108
|
+
export namespace MigrateImportProgrammer {
|
109
|
+
export interface IProps {
|
110
|
+
type: "default" | "instance";
|
111
|
+
library: string;
|
112
|
+
name: string;
|
113
|
+
}
|
114
|
+
}
|
115
|
+
interface IClause {
|
116
|
+
default: string | null;
|
117
|
+
instances: Set<string>;
|
118
|
+
}
|