@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,324 +0,0 @@
|
|
1
|
-
import { OpenApi } from "@samchon/openapi";
|
2
|
-
import ts from "typescript";
|
3
|
-
import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
|
4
|
-
import { StatementFactory } from "typia/lib/factories/StatementFactory";
|
5
|
-
import { TypeFactory } from "typia/lib/factories/TypeFactory";
|
6
|
-
|
7
|
-
import { IHttpMigrateRoute } from "../structures/IHttpMigrateRoute";
|
8
|
-
import { MigrateApiFunctionProgrammer } from "./MigrateApiFunctionProgrammer";
|
9
|
-
import { MigrateApiNamespaceProgrammer } from "./MigrateApiNamespaceProgrammer";
|
10
|
-
import { MigrateImportProgrammer } from "./MigrateImportProgrammer";
|
11
|
-
import { MigrateSchemaProgrammer } from "./MigrateSchemaProgrammer";
|
12
|
-
|
13
|
-
export namespace MigrateApiSimulationProgrammer {
|
14
|
-
export const random =
|
15
|
-
(components: OpenApi.IComponents) =>
|
16
|
-
(importer: MigrateImportProgrammer) =>
|
17
|
-
(route: IHttpMigrateRoute) => {
|
18
|
-
const output = route.success
|
19
|
-
? MigrateSchemaProgrammer.write(components)(importer)(
|
20
|
-
route.success.schema,
|
21
|
-
)
|
22
|
-
: TypeFactory.keyword("void");
|
23
|
-
return constant("random")(
|
24
|
-
ts.factory.createArrowFunction(
|
25
|
-
undefined,
|
26
|
-
undefined,
|
27
|
-
[
|
28
|
-
ts.factory.createParameterDeclaration(
|
29
|
-
undefined,
|
30
|
-
undefined,
|
31
|
-
"g",
|
32
|
-
ts.factory.createToken(ts.SyntaxKind.QuestionToken),
|
33
|
-
ts.factory.createTypeReferenceNode(
|
34
|
-
ts.factory.createIdentifier("Partial"),
|
35
|
-
[
|
36
|
-
ts.factory.createTypeReferenceNode(
|
37
|
-
`${importer.external({
|
38
|
-
type: "default",
|
39
|
-
library: "typia",
|
40
|
-
name: "typia",
|
41
|
-
})}.IRandomGenerator`,
|
42
|
-
),
|
43
|
-
],
|
44
|
-
),
|
45
|
-
),
|
46
|
-
],
|
47
|
-
output,
|
48
|
-
undefined,
|
49
|
-
ts.factory.createCallExpression(
|
50
|
-
IdentifierFactory.access(
|
51
|
-
ts.factory.createIdentifier(
|
52
|
-
importer.external({
|
53
|
-
type: "default",
|
54
|
-
library: "typia",
|
55
|
-
name: "typia",
|
56
|
-
}),
|
57
|
-
),
|
58
|
-
"random",
|
59
|
-
),
|
60
|
-
[output],
|
61
|
-
[ts.factory.createIdentifier("g")],
|
62
|
-
),
|
63
|
-
),
|
64
|
-
);
|
65
|
-
};
|
66
|
-
|
67
|
-
export const simulate =
|
68
|
-
(components: OpenApi.IComponents) =>
|
69
|
-
(importer: MigrateImportProgrammer) =>
|
70
|
-
(route: IHttpMigrateRoute): ts.VariableStatement => {
|
71
|
-
const caller = () =>
|
72
|
-
ts.factory.createCallExpression(
|
73
|
-
ts.factory.createIdentifier("random"),
|
74
|
-
undefined,
|
75
|
-
[
|
76
|
-
ts.factory.createConditionalExpression(
|
77
|
-
ts.factory.createLogicalAnd(
|
78
|
-
ts.factory.createStrictEquality(
|
79
|
-
ts.factory.createStringLiteral("object"),
|
80
|
-
ts.factory.createTypeOfExpression(
|
81
|
-
ts.factory.createIdentifier("connection.simulate"),
|
82
|
-
),
|
83
|
-
),
|
84
|
-
ts.factory.createStrictInequality(
|
85
|
-
ts.factory.createNull(),
|
86
|
-
ts.factory.createIdentifier("connection.simulate"),
|
87
|
-
),
|
88
|
-
),
|
89
|
-
undefined,
|
90
|
-
ts.factory.createIdentifier("connection.simulate"),
|
91
|
-
undefined,
|
92
|
-
ts.factory.createIdentifier("undefined"),
|
93
|
-
),
|
94
|
-
],
|
95
|
-
);
|
96
|
-
return constant("simulate")(
|
97
|
-
ts.factory.createArrowFunction(
|
98
|
-
undefined,
|
99
|
-
undefined,
|
100
|
-
MigrateApiFunctionProgrammer.writeParameterDeclarations(components)(
|
101
|
-
importer,
|
102
|
-
)(route),
|
103
|
-
ts.factory.createTypeReferenceNode(route.success ? "Output" : "void"),
|
104
|
-
undefined,
|
105
|
-
ts.factory.createBlock(
|
106
|
-
[
|
107
|
-
...assert(components)(importer)(route),
|
108
|
-
ts.factory.createReturnStatement(caller()),
|
109
|
-
],
|
110
|
-
true,
|
111
|
-
),
|
112
|
-
),
|
113
|
-
);
|
114
|
-
};
|
115
|
-
|
116
|
-
const assert =
|
117
|
-
(components: OpenApi.IComponents) =>
|
118
|
-
(importer: MigrateImportProgrammer) =>
|
119
|
-
(route: IHttpMigrateRoute): ts.Statement[] => {
|
120
|
-
const parameters = [
|
121
|
-
...route.parameters.map((p) => ({
|
122
|
-
category: "param",
|
123
|
-
name: p.key,
|
124
|
-
schema: MigrateSchemaProgrammer.write(components)(importer)(p.schema),
|
125
|
-
})),
|
126
|
-
...(route.query
|
127
|
-
? [
|
128
|
-
{
|
129
|
-
category: "query",
|
130
|
-
name: route.query.key,
|
131
|
-
schema: MigrateSchemaProgrammer.write(components)(importer)(
|
132
|
-
route.query.schema,
|
133
|
-
),
|
134
|
-
},
|
135
|
-
]
|
136
|
-
: []),
|
137
|
-
...(route.body
|
138
|
-
? [
|
139
|
-
{
|
140
|
-
category: "body",
|
141
|
-
name: route.body.key,
|
142
|
-
schema: MigrateSchemaProgrammer.write(components)(importer)(
|
143
|
-
route.body.schema,
|
144
|
-
),
|
145
|
-
},
|
146
|
-
]
|
147
|
-
: []),
|
148
|
-
];
|
149
|
-
if (parameters.length === 0) return [];
|
150
|
-
|
151
|
-
const validator = StatementFactory.constant({
|
152
|
-
name: "assert",
|
153
|
-
value: ts.factory.createCallExpression(
|
154
|
-
IdentifierFactory.access(
|
155
|
-
ts.factory.createIdentifier(
|
156
|
-
importer.external({
|
157
|
-
type: "instance",
|
158
|
-
library: `@nestia/fetcher/lib/NestiaSimulator`,
|
159
|
-
name: "NestiaSimulator",
|
160
|
-
}),
|
161
|
-
),
|
162
|
-
"assert",
|
163
|
-
),
|
164
|
-
undefined,
|
165
|
-
[
|
166
|
-
ts.factory.createObjectLiteralExpression(
|
167
|
-
[
|
168
|
-
ts.factory.createPropertyAssignment(
|
169
|
-
"method",
|
170
|
-
ts.factory.createIdentifier("METADATA.method"),
|
171
|
-
),
|
172
|
-
ts.factory.createPropertyAssignment(
|
173
|
-
"host",
|
174
|
-
ts.factory.createIdentifier("connection.host"),
|
175
|
-
),
|
176
|
-
ts.factory.createPropertyAssignment(
|
177
|
-
"path",
|
178
|
-
MigrateApiNamespaceProgrammer.writePathCallExpression(route),
|
179
|
-
),
|
180
|
-
ts.factory.createPropertyAssignment(
|
181
|
-
"contentType",
|
182
|
-
ts.factory.createStringLiteral(
|
183
|
-
route.success?.type ?? "application/json",
|
184
|
-
),
|
185
|
-
),
|
186
|
-
],
|
187
|
-
true,
|
188
|
-
),
|
189
|
-
],
|
190
|
-
),
|
191
|
-
});
|
192
|
-
const individual = parameters
|
193
|
-
.map((p) =>
|
194
|
-
ts.factory.createCallExpression(
|
195
|
-
(() => {
|
196
|
-
const base = IdentifierFactory.access(
|
197
|
-
ts.factory.createIdentifier("assert"),
|
198
|
-
p.category,
|
199
|
-
);
|
200
|
-
if (p.category !== "param") return base;
|
201
|
-
return ts.factory.createCallExpression(base, undefined, [
|
202
|
-
ts.factory.createStringLiteral(p.name),
|
203
|
-
]);
|
204
|
-
})(),
|
205
|
-
undefined,
|
206
|
-
[
|
207
|
-
ts.factory.createArrowFunction(
|
208
|
-
undefined,
|
209
|
-
undefined,
|
210
|
-
[],
|
211
|
-
undefined,
|
212
|
-
undefined,
|
213
|
-
ts.factory.createCallExpression(
|
214
|
-
IdentifierFactory.access(
|
215
|
-
ts.factory.createIdentifier(
|
216
|
-
importer.external({
|
217
|
-
type: "default",
|
218
|
-
library: "typia",
|
219
|
-
name: "typia",
|
220
|
-
}),
|
221
|
-
),
|
222
|
-
"assert",
|
223
|
-
),
|
224
|
-
undefined,
|
225
|
-
[
|
226
|
-
ts.factory.createIdentifier(
|
227
|
-
p.category === "headers" ? "connection.headers" : p.name,
|
228
|
-
),
|
229
|
-
],
|
230
|
-
),
|
231
|
-
),
|
232
|
-
],
|
233
|
-
),
|
234
|
-
)
|
235
|
-
.map(ts.factory.createExpressionStatement);
|
236
|
-
return [validator, tryAndCatch(importer)(individual)];
|
237
|
-
};
|
238
|
-
|
239
|
-
const tryAndCatch =
|
240
|
-
(importer: MigrateImportProgrammer) => (individual: ts.Statement[]) =>
|
241
|
-
ts.factory.createTryStatement(
|
242
|
-
ts.factory.createBlock(individual, true),
|
243
|
-
ts.factory.createCatchClause(
|
244
|
-
"exp",
|
245
|
-
ts.factory.createBlock(
|
246
|
-
[
|
247
|
-
ts.factory.createIfStatement(
|
248
|
-
ts.factory.createLogicalNot(
|
249
|
-
ts.factory.createCallExpression(
|
250
|
-
IdentifierFactory.access(
|
251
|
-
ts.factory.createIdentifier(
|
252
|
-
importer.external({
|
253
|
-
type: "default",
|
254
|
-
library: "typia",
|
255
|
-
name: "typia",
|
256
|
-
}),
|
257
|
-
),
|
258
|
-
"is",
|
259
|
-
),
|
260
|
-
[
|
261
|
-
ts.factory.createTypeReferenceNode(
|
262
|
-
importer.external({
|
263
|
-
type: "instance",
|
264
|
-
library: "@nestia/fetcher",
|
265
|
-
name: "HttpError",
|
266
|
-
}),
|
267
|
-
),
|
268
|
-
],
|
269
|
-
[ts.factory.createIdentifier("exp")],
|
270
|
-
),
|
271
|
-
),
|
272
|
-
ts.factory.createThrowStatement(
|
273
|
-
ts.factory.createIdentifier("exp"),
|
274
|
-
),
|
275
|
-
),
|
276
|
-
ts.factory.createReturnStatement(
|
277
|
-
ts.factory.createAsExpression(
|
278
|
-
ts.factory.createObjectLiteralExpression(
|
279
|
-
[
|
280
|
-
ts.factory.createPropertyAssignment(
|
281
|
-
"success",
|
282
|
-
ts.factory.createFalse(),
|
283
|
-
),
|
284
|
-
ts.factory.createPropertyAssignment(
|
285
|
-
"status",
|
286
|
-
ts.factory.createIdentifier("exp.status"),
|
287
|
-
),
|
288
|
-
ts.factory.createPropertyAssignment(
|
289
|
-
"headers",
|
290
|
-
ts.factory.createIdentifier("exp.headers"),
|
291
|
-
),
|
292
|
-
ts.factory.createPropertyAssignment(
|
293
|
-
"data",
|
294
|
-
ts.factory.createIdentifier("exp.toJSON().message"),
|
295
|
-
),
|
296
|
-
],
|
297
|
-
true,
|
298
|
-
),
|
299
|
-
TypeFactory.keyword("any"),
|
300
|
-
),
|
301
|
-
),
|
302
|
-
],
|
303
|
-
true,
|
304
|
-
),
|
305
|
-
),
|
306
|
-
undefined,
|
307
|
-
);
|
308
|
-
}
|
309
|
-
|
310
|
-
const constant = (name: string) => (expression: ts.Expression) =>
|
311
|
-
ts.factory.createVariableStatement(
|
312
|
-
[ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
|
313
|
-
ts.factory.createVariableDeclarationList(
|
314
|
-
[
|
315
|
-
ts.factory.createVariableDeclaration(
|
316
|
-
ts.factory.createIdentifier(name),
|
317
|
-
undefined,
|
318
|
-
undefined,
|
319
|
-
expression,
|
320
|
-
),
|
321
|
-
],
|
322
|
-
ts.NodeFlags.Const,
|
323
|
-
),
|
324
|
-
);
|
@@ -1,194 +0,0 @@
|
|
1
|
-
import { OpenApi } from "@samchon/openapi";
|
2
|
-
import ts from "typescript";
|
3
|
-
import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
|
4
|
-
import { StatementFactory } from "typia/lib/factories/StatementFactory";
|
5
|
-
|
6
|
-
import { IHttpMigrateFile } from "../structures/IHttpMigrateFile";
|
7
|
-
import { IHttpMigrateProgram } from "../structures/IHttpMigrateProgram";
|
8
|
-
import { IHttpMigrateRoute } from "../structures/IHttpMigrateRoute";
|
9
|
-
import { FilePrinter } from "../utils/FilePrinter";
|
10
|
-
import { MigrateE2eFunctionProgrammer } from "./MigrateE2eFileProgrammer";
|
11
|
-
import { MigrateImportProgrammer } from "./MigrateImportProgrammer";
|
12
|
-
|
13
|
-
export namespace MigrateApiStartProgrammer {
|
14
|
-
export const write = (program: IHttpMigrateProgram): IHttpMigrateFile => {
|
15
|
-
const importer: MigrateImportProgrammer = new MigrateImportProgrammer();
|
16
|
-
const main: ts.VariableStatement = writeMain(program)(program.document)(
|
17
|
-
importer,
|
18
|
-
)(pick(program.routes));
|
19
|
-
const statements: ts.Statement[] = [
|
20
|
-
...importer.toStatements(
|
21
|
-
(name) => `@ORGANIZATION/PROJECT-api/lib/structures/${name}`,
|
22
|
-
),
|
23
|
-
FilePrinter.newLine(),
|
24
|
-
ts.factory.createImportDeclaration(
|
25
|
-
undefined,
|
26
|
-
ts.factory.createImportClause(
|
27
|
-
false,
|
28
|
-
undefined,
|
29
|
-
ts.factory.createNamedImports([
|
30
|
-
ts.factory.createImportSpecifier(
|
31
|
-
false,
|
32
|
-
undefined,
|
33
|
-
ts.factory.createIdentifier("TestGlobal"),
|
34
|
-
),
|
35
|
-
]),
|
36
|
-
),
|
37
|
-
ts.factory.createStringLiteral("./TestGlobal"),
|
38
|
-
undefined,
|
39
|
-
),
|
40
|
-
FilePrinter.newLine(),
|
41
|
-
main,
|
42
|
-
ts.factory.createExpressionStatement(writeStarter()),
|
43
|
-
];
|
44
|
-
return {
|
45
|
-
location: `test`,
|
46
|
-
file: "start.ts",
|
47
|
-
content: FilePrinter.write({ statements }),
|
48
|
-
};
|
49
|
-
};
|
50
|
-
|
51
|
-
const writeMain =
|
52
|
-
(config: IHttpMigrateProgram.IConfig) =>
|
53
|
-
(document: OpenApi.IDocument) =>
|
54
|
-
(importer: MigrateImportProgrammer) =>
|
55
|
-
(route: IHttpMigrateRoute): ts.VariableStatement =>
|
56
|
-
StatementFactory.constant({
|
57
|
-
name: "main",
|
58
|
-
value: ts.factory.createArrowFunction(
|
59
|
-
[ts.factory.createToken(ts.SyntaxKind.AsyncKeyword)],
|
60
|
-
undefined,
|
61
|
-
[],
|
62
|
-
undefined,
|
63
|
-
undefined,
|
64
|
-
ts.factory.createBlock(
|
65
|
-
[
|
66
|
-
writeConnection(config)(document)(importer),
|
67
|
-
...MigrateE2eFunctionProgrammer.writeBody(document.components)(
|
68
|
-
importer,
|
69
|
-
)(route),
|
70
|
-
],
|
71
|
-
true,
|
72
|
-
),
|
73
|
-
),
|
74
|
-
});
|
75
|
-
|
76
|
-
const writeConnection =
|
77
|
-
(config: IHttpMigrateProgram.IConfig) =>
|
78
|
-
(document: OpenApi.IDocument) =>
|
79
|
-
(importer: MigrateImportProgrammer): ts.VariableStatement =>
|
80
|
-
ts.factory.createVariableStatement(
|
81
|
-
undefined,
|
82
|
-
ts.factory.createVariableDeclarationList(
|
83
|
-
[
|
84
|
-
ts.factory.createVariableDeclaration(
|
85
|
-
"connection",
|
86
|
-
undefined,
|
87
|
-
ts.factory.createTypeReferenceNode(
|
88
|
-
ts.factory.createQualifiedName(
|
89
|
-
ts.factory.createIdentifier(
|
90
|
-
importer.external({
|
91
|
-
type: "default",
|
92
|
-
library: "@ORGANIZATION/PROJECT-api",
|
93
|
-
name: "api",
|
94
|
-
}),
|
95
|
-
),
|
96
|
-
ts.factory.createIdentifier("IConnection"),
|
97
|
-
),
|
98
|
-
),
|
99
|
-
ts.factory.createObjectLiteralExpression(
|
100
|
-
[
|
101
|
-
ts.factory.createSpreadAssignment(
|
102
|
-
ts.factory.createCallExpression(
|
103
|
-
ts.factory.createPropertyAccessExpression(
|
104
|
-
ts.factory.createIdentifier("TestGlobal"),
|
105
|
-
"connection",
|
106
|
-
),
|
107
|
-
undefined,
|
108
|
-
undefined,
|
109
|
-
),
|
110
|
-
),
|
111
|
-
...(document.servers?.[0]?.url?.length
|
112
|
-
? [
|
113
|
-
ts.factory.createPropertyAssignment(
|
114
|
-
"host",
|
115
|
-
ts.factory.createStringLiteral(
|
116
|
-
document.servers[0].url,
|
117
|
-
),
|
118
|
-
),
|
119
|
-
]
|
120
|
-
: []),
|
121
|
-
...(config.simulate === true
|
122
|
-
? [
|
123
|
-
ts.factory.createPropertyAssignment(
|
124
|
-
"simulate",
|
125
|
-
ts.factory.createTrue(),
|
126
|
-
),
|
127
|
-
]
|
128
|
-
: []),
|
129
|
-
],
|
130
|
-
true,
|
131
|
-
),
|
132
|
-
),
|
133
|
-
],
|
134
|
-
ts.NodeFlags.Const,
|
135
|
-
),
|
136
|
-
);
|
137
|
-
|
138
|
-
const writeStarter = (): ts.CallExpression =>
|
139
|
-
ts.factory.createCallExpression(
|
140
|
-
ts.factory.createPropertyAccessExpression(
|
141
|
-
ts.factory.createCallExpression(
|
142
|
-
ts.factory.createIdentifier("main"),
|
143
|
-
undefined,
|
144
|
-
undefined,
|
145
|
-
),
|
146
|
-
"catch",
|
147
|
-
),
|
148
|
-
undefined,
|
149
|
-
[
|
150
|
-
ts.factory.createArrowFunction(
|
151
|
-
undefined,
|
152
|
-
undefined,
|
153
|
-
[IdentifierFactory.parameter("exp")],
|
154
|
-
undefined,
|
155
|
-
undefined,
|
156
|
-
ts.factory.createBlock(
|
157
|
-
[
|
158
|
-
ts.factory.createExpressionStatement(
|
159
|
-
ts.factory.createCallExpression(
|
160
|
-
ts.factory.createPropertyAccessExpression(
|
161
|
-
ts.factory.createIdentifier("console"),
|
162
|
-
"log",
|
163
|
-
),
|
164
|
-
undefined,
|
165
|
-
[ts.factory.createIdentifier("exp")],
|
166
|
-
),
|
167
|
-
),
|
168
|
-
ts.factory.createExpressionStatement(
|
169
|
-
ts.factory.createCallExpression(
|
170
|
-
ts.factory.createPropertyAccessExpression(
|
171
|
-
ts.factory.createIdentifier("process"),
|
172
|
-
"exit",
|
173
|
-
),
|
174
|
-
undefined,
|
175
|
-
[
|
176
|
-
ts.factory.createPrefixMinus(
|
177
|
-
ts.factory.createNumericLiteral("1"),
|
178
|
-
),
|
179
|
-
],
|
180
|
-
),
|
181
|
-
),
|
182
|
-
],
|
183
|
-
true,
|
184
|
-
),
|
185
|
-
),
|
186
|
-
],
|
187
|
-
);
|
188
|
-
}
|
189
|
-
|
190
|
-
const pick = <T>(array: T[]): T => {
|
191
|
-
const rand: number = Math.random() * array.length;
|
192
|
-
const index: number = Math.min(array.length - 1, Math.floor(rand));
|
193
|
-
return array[index];
|
194
|
-
};
|
@@ -1,117 +0,0 @@
|
|
1
|
-
import { OpenApi } from "@samchon/openapi";
|
2
|
-
import ts from "typescript";
|
3
|
-
import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
|
4
|
-
|
5
|
-
import { IHttpMigrateRoute } from "../structures/IHttpMigrateRoute";
|
6
|
-
import { MigrateImportProgrammer } from "./MigrateImportProgrammer";
|
7
|
-
import { MigrateSchemaProgrammer } from "./MigrateSchemaProgrammer";
|
8
|
-
|
9
|
-
export namespace MigrateE2eFunctionProgrammer {
|
10
|
-
export const write =
|
11
|
-
(components: OpenApi.IComponents) =>
|
12
|
-
(importer: MigrateImportProgrammer) =>
|
13
|
-
(route: IHttpMigrateRoute): ts.FunctionDeclaration =>
|
14
|
-
ts.factory.createFunctionDeclaration(
|
15
|
-
[
|
16
|
-
ts.factory.createModifier(ts.SyntaxKind.ExportKeyword),
|
17
|
-
ts.factory.createModifier(ts.SyntaxKind.AsyncKeyword),
|
18
|
-
],
|
19
|
-
undefined,
|
20
|
-
["test", "api", ...route.accessor].join("_"),
|
21
|
-
undefined,
|
22
|
-
[
|
23
|
-
IdentifierFactory.parameter(
|
24
|
-
"connection",
|
25
|
-
ts.factory.createTypeReferenceNode(
|
26
|
-
ts.factory.createQualifiedName(
|
27
|
-
ts.factory.createIdentifier(
|
28
|
-
importer.external({
|
29
|
-
type: "default",
|
30
|
-
library: "@ORGANIZATION/PROJECT-api",
|
31
|
-
name: "api",
|
32
|
-
}),
|
33
|
-
),
|
34
|
-
ts.factory.createIdentifier("IConnection"),
|
35
|
-
),
|
36
|
-
),
|
37
|
-
),
|
38
|
-
],
|
39
|
-
undefined,
|
40
|
-
ts.factory.createBlock(writeBody(components)(importer)(route), true),
|
41
|
-
);
|
42
|
-
|
43
|
-
export const writeBody =
|
44
|
-
(components: OpenApi.IComponents) =>
|
45
|
-
(importer: MigrateImportProgrammer) =>
|
46
|
-
(route: IHttpMigrateRoute): ts.Statement[] => [
|
47
|
-
ts.factory.createVariableStatement(
|
48
|
-
[],
|
49
|
-
ts.factory.createVariableDeclarationList(
|
50
|
-
[
|
51
|
-
ts.factory.createVariableDeclaration(
|
52
|
-
"output",
|
53
|
-
undefined,
|
54
|
-
route.success
|
55
|
-
? MigrateSchemaProgrammer.write(components)(importer)(
|
56
|
-
route.success.schema,
|
57
|
-
)
|
58
|
-
: undefined,
|
59
|
-
ts.factory.createAwaitExpression(
|
60
|
-
writeCallExpressionn(components)(importer)(route),
|
61
|
-
),
|
62
|
-
),
|
63
|
-
],
|
64
|
-
ts.NodeFlags.Const,
|
65
|
-
),
|
66
|
-
),
|
67
|
-
ts.factory.createExpressionStatement(
|
68
|
-
ts.factory.createCallExpression(
|
69
|
-
ts.factory.createPropertyAccessExpression(
|
70
|
-
ts.factory.createIdentifier(
|
71
|
-
importer.external({
|
72
|
-
type: "default",
|
73
|
-
library: "typia",
|
74
|
-
name: "typia",
|
75
|
-
}),
|
76
|
-
),
|
77
|
-
"assert",
|
78
|
-
),
|
79
|
-
undefined,
|
80
|
-
[ts.factory.createIdentifier("output")],
|
81
|
-
),
|
82
|
-
),
|
83
|
-
];
|
84
|
-
|
85
|
-
const writeCallExpressionn =
|
86
|
-
(components: OpenApi.IComponents) =>
|
87
|
-
(importer: MigrateImportProgrammer) =>
|
88
|
-
(route: IHttpMigrateRoute): ts.CallExpression =>
|
89
|
-
ts.factory.createCallExpression(
|
90
|
-
ts.factory.createPropertyAccessExpression(
|
91
|
-
ts.factory.createIdentifier("api.functional"),
|
92
|
-
ts.factory.createIdentifier(route.accessor.join(".")),
|
93
|
-
),
|
94
|
-
undefined,
|
95
|
-
[
|
96
|
-
ts.factory.createIdentifier("connection"),
|
97
|
-
...[...route.parameters, route.query!, route.body!]
|
98
|
-
.filter((p) => !!p)
|
99
|
-
.map((p) =>
|
100
|
-
ts.factory.createCallExpression(
|
101
|
-
ts.factory.createPropertyAccessExpression(
|
102
|
-
ts.factory.createIdentifier(
|
103
|
-
importer.external({
|
104
|
-
type: "default",
|
105
|
-
library: "typia",
|
106
|
-
name: "typia",
|
107
|
-
}),
|
108
|
-
),
|
109
|
-
"random",
|
110
|
-
),
|
111
|
-
[MigrateSchemaProgrammer.write(components)(importer)(p.schema)],
|
112
|
-
undefined,
|
113
|
-
),
|
114
|
-
),
|
115
|
-
],
|
116
|
-
);
|
117
|
-
}
|
@@ -1,34 +0,0 @@
|
|
1
|
-
import { OpenApi } from "@samchon/openapi";
|
2
|
-
import ts from "typescript";
|
3
|
-
|
4
|
-
import { IHttpMigrateFile } from "../structures/IHttpMigrateFile";
|
5
|
-
import { IHttpMigrateProgram } from "../structures/IHttpMigrateProgram";
|
6
|
-
import { IHttpMigrateRoute } from "../structures/IHttpMigrateRoute";
|
7
|
-
import { FilePrinter } from "../utils/FilePrinter";
|
8
|
-
import { MigrateE2eFunctionProgrammer } from "./MigrateE2eFileProgrammer";
|
9
|
-
import { MigrateImportProgrammer } from "./MigrateImportProgrammer";
|
10
|
-
|
11
|
-
export namespace MigrateE2eProgrammer {
|
12
|
-
export const write = (program: IHttpMigrateProgram): IHttpMigrateFile[] =>
|
13
|
-
program.routes.map(writeFile(program.document.components));
|
14
|
-
|
15
|
-
const writeFile =
|
16
|
-
(components: OpenApi.IComponents) =>
|
17
|
-
(route: IHttpMigrateRoute): IHttpMigrateFile => {
|
18
|
-
const importer: MigrateImportProgrammer = new MigrateImportProgrammer();
|
19
|
-
const func: ts.FunctionDeclaration =
|
20
|
-
MigrateE2eFunctionProgrammer.write(components)(importer)(route);
|
21
|
-
const statements: ts.Statement[] = [
|
22
|
-
...importer.toStatements(
|
23
|
-
(name) => `@ORGANIZATION/PROJECT-api/lib/structures/${name}`,
|
24
|
-
),
|
25
|
-
FilePrinter.newLine(),
|
26
|
-
func,
|
27
|
-
];
|
28
|
-
return {
|
29
|
-
location: `test/features/api`,
|
30
|
-
file: `${["test", "api", ...route.accessor].join("_")}.ts`,
|
31
|
-
content: FilePrinter.write({ statements }),
|
32
|
-
};
|
33
|
-
};
|
34
|
-
}
|