@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 +0,0 @@
|
|
1
|
-
{"version":3,"file":"IHttpMigrateDto.js","sourceRoot":"","sources":["../../src/structures/IHttpMigrateDto.ts"],"names":[],"mappings":""}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"IHttpMigrateFile.js","sourceRoot":"","sources":["../../src/structures/IHttpMigrateFile.ts"],"names":[],"mappings":""}
|
@@ -1,33 +0,0 @@
|
|
1
|
-
import { OpenApi } from "@samchon/openapi";
|
2
|
-
import { IHttpMigrateRoute } from "./IHttpMigrateRoute";
|
3
|
-
export interface IHttpMigrateProgram extends IHttpMigrateProgram.IProps {
|
4
|
-
routes: IHttpMigrateRoute[];
|
5
|
-
errors: IHttpMigrateProgram.IError[];
|
6
|
-
}
|
7
|
-
export declare namespace IHttpMigrateProgram {
|
8
|
-
interface IProps {
|
9
|
-
mode: "nest" | "sdk";
|
10
|
-
simulate: boolean;
|
11
|
-
e2e: boolean;
|
12
|
-
document: OpenApi.IDocument;
|
13
|
-
author?: {
|
14
|
-
tag: string;
|
15
|
-
value: string;
|
16
|
-
};
|
17
|
-
}
|
18
|
-
interface IConfig {
|
19
|
-
mode: "nest" | "sdk";
|
20
|
-
simulate: boolean;
|
21
|
-
e2e: boolean;
|
22
|
-
author?: {
|
23
|
-
tag: string;
|
24
|
-
value: string;
|
25
|
-
};
|
26
|
-
}
|
27
|
-
interface IError {
|
28
|
-
method: string;
|
29
|
-
path: string;
|
30
|
-
operation: () => OpenApi.IOperation;
|
31
|
-
messages: string[];
|
32
|
-
}
|
33
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"IHttpMigrateProgram.js","sourceRoot":"","sources":["../../src/structures/IHttpMigrateProgram.ts"],"names":[],"mappings":""}
|
@@ -1 +0,0 @@
|
|
1
|
-
export { IHttpMigrateRoute } from "@samchon/openapi";
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"IHttpMigrateRoute.js","sourceRoot":"","sources":["../../src/structures/IHttpMigrateRoute.ts"],"names":[],"mappings":""}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"IHttpMigrateSchema.js","sourceRoot":"","sources":["../../src/structures/IHttpMigrateSchema.ts"],"names":[],"mappings":""}
|
@@ -1,124 +0,0 @@
|
|
1
|
-
import { OpenApi, OpenApiV3, OpenApiV3_1, SwaggerV2 } from "@samchon/openapi";
|
2
|
-
import typia, { IValidation } from "typia";
|
3
|
-
|
4
|
-
import { MigrateApplicationAnalyzer } from "./analyzers/MigrateApplicationAnalyzer";
|
5
|
-
import { NEST_TEMPLATE } from "./bundles/NEST_TEMPLATE";
|
6
|
-
import { SDK_TEMPLATE } from "./bundles/SDK_TEMPLATE";
|
7
|
-
import { MigrateApiProgrammer } from "./programmers/MigrateApiProgrammer";
|
8
|
-
import { MigrateApiStartProgrammer } from "./programmers/MigrateApiStartProgrammer";
|
9
|
-
import { MigrateE2eProgrammer } from "./programmers/MigrateE2eProgrammer";
|
10
|
-
import { MigrateNestProgrammer } from "./programmers/MigrateNestProgrammer";
|
11
|
-
import { IHttpMigrateFile } from "./structures/IHttpMigrateFile";
|
12
|
-
import { IHttpMigrateProgram } from "./structures/IHttpMigrateProgram";
|
13
|
-
|
14
|
-
export class MigrateApplication {
|
15
|
-
private constructor(public readonly document: OpenApi.IDocument) {}
|
16
|
-
|
17
|
-
public static create(
|
18
|
-
document:
|
19
|
-
| SwaggerV2.IDocument
|
20
|
-
| OpenApiV3.IDocument
|
21
|
-
| OpenApiV3_1.IDocument
|
22
|
-
| OpenApi.IDocument,
|
23
|
-
): IValidation<MigrateApplication> {
|
24
|
-
const result: IValidation<
|
25
|
-
| SwaggerV2.IDocument
|
26
|
-
| OpenApiV3.IDocument
|
27
|
-
| OpenApiV3_1.IDocument
|
28
|
-
| OpenApi.IDocument
|
29
|
-
> = typia.validate(document);
|
30
|
-
if (result.success === false) return result;
|
31
|
-
return {
|
32
|
-
success: true,
|
33
|
-
data: new MigrateApplication(OpenApi.convert(document)),
|
34
|
-
};
|
35
|
-
}
|
36
|
-
|
37
|
-
public nest(config: MigrateApplication.IConfig): MigrateApplication.IOutput {
|
38
|
-
const program: IHttpMigrateProgram = MigrateApplicationAnalyzer.analyze({
|
39
|
-
mode: "nest",
|
40
|
-
document: this.document,
|
41
|
-
simulate: config.simulate,
|
42
|
-
e2e: config.e2e,
|
43
|
-
author: config.author,
|
44
|
-
});
|
45
|
-
const output: MigrateApplication.IOutput = {
|
46
|
-
program,
|
47
|
-
files: [
|
48
|
-
...NEST_TEMPLATE.filter(
|
49
|
-
(f) =>
|
50
|
-
f.location.startsWith("src/api/structures") === false &&
|
51
|
-
f.location.startsWith("src/api/functional") === false &&
|
52
|
-
f.location.startsWith("src/api/controllers") === false &&
|
53
|
-
f.location.startsWith("test/features") === false,
|
54
|
-
),
|
55
|
-
...MigrateNestProgrammer.write(program),
|
56
|
-
...MigrateApiProgrammer.write(program),
|
57
|
-
...(config.e2e ? MigrateE2eProgrammer.write(program) : []),
|
58
|
-
],
|
59
|
-
errors: program.errors,
|
60
|
-
};
|
61
|
-
return this.finalize(config, output);
|
62
|
-
}
|
63
|
-
|
64
|
-
public sdk(config: MigrateApplication.IConfig): MigrateApplication.IOutput {
|
65
|
-
const program: IHttpMigrateProgram = MigrateApplicationAnalyzer.analyze({
|
66
|
-
mode: "sdk",
|
67
|
-
document: this.document,
|
68
|
-
simulate: config.simulate,
|
69
|
-
e2e: config.e2e,
|
70
|
-
author: config.author,
|
71
|
-
});
|
72
|
-
const output: MigrateApplication.IOutput = {
|
73
|
-
program,
|
74
|
-
files: [
|
75
|
-
...SDK_TEMPLATE.filter(
|
76
|
-
(f) =>
|
77
|
-
f.location.startsWith("src/structures") === false &&
|
78
|
-
f.location.startsWith("src/functional") === false &&
|
79
|
-
f.location.startsWith("test/features") === false,
|
80
|
-
),
|
81
|
-
...MigrateApiProgrammer.write(program),
|
82
|
-
MigrateApiStartProgrammer.write(program),
|
83
|
-
...(config.e2e ? MigrateE2eProgrammer.write(program) : []),
|
84
|
-
{
|
85
|
-
location: "",
|
86
|
-
file: "swagger.json",
|
87
|
-
content: JSON.stringify(this.document, null, 2),
|
88
|
-
},
|
89
|
-
],
|
90
|
-
errors: program.errors,
|
91
|
-
};
|
92
|
-
return this.finalize(config, output);
|
93
|
-
}
|
94
|
-
|
95
|
-
private finalize(
|
96
|
-
config: MigrateApplication.IConfig,
|
97
|
-
output: MigrateApplication.IOutput,
|
98
|
-
): MigrateApplication.IOutput {
|
99
|
-
if (config.package)
|
100
|
-
output.files = output.files.map((file) => ({
|
101
|
-
...file,
|
102
|
-
content: file.content
|
103
|
-
.split(`@ORGANIZATION/PROJECT`)
|
104
|
-
.join(config.package),
|
105
|
-
}));
|
106
|
-
return output;
|
107
|
-
}
|
108
|
-
}
|
109
|
-
export namespace MigrateApplication {
|
110
|
-
export interface IOutput {
|
111
|
-
program: IHttpMigrateProgram;
|
112
|
-
files: IHttpMigrateFile[];
|
113
|
-
errors: IHttpMigrateProgram.IError[];
|
114
|
-
}
|
115
|
-
export interface IConfig {
|
116
|
-
simulate: boolean;
|
117
|
-
e2e: boolean;
|
118
|
-
package?: string;
|
119
|
-
author?: {
|
120
|
-
tag: string;
|
121
|
-
value: string;
|
122
|
-
};
|
123
|
-
}
|
124
|
-
}
|
@@ -1,18 +0,0 @@
|
|
1
|
-
import { HttpMigration, IHttpMigrateApplication } from "@samchon/openapi";
|
2
|
-
|
3
|
-
import { IHttpMigrateProgram } from "../structures/IHttpMigrateProgram";
|
4
|
-
|
5
|
-
export namespace MigrateApplicationAnalyzer {
|
6
|
-
export const analyze = (
|
7
|
-
props: IHttpMigrateProgram.IProps,
|
8
|
-
): IHttpMigrateProgram => {
|
9
|
-
const application: IHttpMigrateApplication = HttpMigration.application(
|
10
|
-
props.document,
|
11
|
-
);
|
12
|
-
return {
|
13
|
-
...props,
|
14
|
-
routes: application.routes,
|
15
|
-
errors: application.errors,
|
16
|
-
};
|
17
|
-
};
|
18
|
-
}
|
@@ -1,38 +0,0 @@
|
|
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,51 +0,0 @@
|
|
1
|
-
import { IHttpMigrateRoute, OpenApi } from "@samchon/openapi";
|
2
|
-
import ts from "typescript";
|
3
|
-
|
4
|
-
import { IHttpMigrateProgram } from "../structures/IHttpMigrateProgram";
|
5
|
-
import { FilePrinter } from "../utils/FilePrinter";
|
6
|
-
import { MigrateApiFunctionProgrammer } from "./MigrateApiFunctionProgrammer";
|
7
|
-
import { MigrateApiNamespaceProgrammer } from "./MigrateApiNamespaceProgrammer";
|
8
|
-
import { MigrateImportProgrammer } from "./MigrateImportProgrammer";
|
9
|
-
|
10
|
-
export namespace MigrateApiFileProgrammer {
|
11
|
-
export interface IProps {
|
12
|
-
namespace: string[];
|
13
|
-
routes: IHttpMigrateRoute[];
|
14
|
-
children: Set<string>;
|
15
|
-
}
|
16
|
-
export const write =
|
17
|
-
(config: IHttpMigrateProgram.IConfig) =>
|
18
|
-
(components: OpenApi.IComponents) =>
|
19
|
-
(props: IProps): ts.Statement[] => {
|
20
|
-
const importer: MigrateImportProgrammer = new MigrateImportProgrammer();
|
21
|
-
const statements: ts.Statement[] = props.routes
|
22
|
-
.map((route) => [
|
23
|
-
FilePrinter.newLine(),
|
24
|
-
MigrateApiFunctionProgrammer.write(config)(components)(importer)(
|
25
|
-
route,
|
26
|
-
),
|
27
|
-
MigrateApiNamespaceProgrammer.write(config)(components)(importer)(
|
28
|
-
route,
|
29
|
-
),
|
30
|
-
])
|
31
|
-
.flat();
|
32
|
-
return [
|
33
|
-
...importer.toStatements(
|
34
|
-
(ref) =>
|
35
|
-
`../${"../".repeat(props.namespace.length)}structures/${ref}`,
|
36
|
-
),
|
37
|
-
...[...props.children].map((child) =>
|
38
|
-
ts.factory.createExportDeclaration(
|
39
|
-
undefined,
|
40
|
-
false,
|
41
|
-
ts.factory.createNamespaceExport(
|
42
|
-
ts.factory.createIdentifier(child),
|
43
|
-
),
|
44
|
-
ts.factory.createStringLiteral(`./${child}`),
|
45
|
-
undefined,
|
46
|
-
),
|
47
|
-
),
|
48
|
-
...statements,
|
49
|
-
];
|
50
|
-
};
|
51
|
-
}
|
@@ -1,213 +0,0 @@
|
|
1
|
-
import { OpenApi } from "@samchon/openapi";
|
2
|
-
import ts from "typescript";
|
3
|
-
import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
|
4
|
-
|
5
|
-
import { MigrateApplication } from "../MigrateApplication";
|
6
|
-
import { IHttpMigrateProgram } from "../structures/IHttpMigrateProgram";
|
7
|
-
import { IHttpMigrateRoute } from "../structures/IHttpMigrateRoute";
|
8
|
-
import { FilePrinter } from "../utils/FilePrinter";
|
9
|
-
import { MigrateImportProgrammer } from "./MigrateImportProgrammer";
|
10
|
-
import { MigrateSchemaProgrammer } from "./MigrateSchemaProgrammer";
|
11
|
-
|
12
|
-
export namespace MigrateApiFunctionProgrammer {
|
13
|
-
export const write =
|
14
|
-
(config: IHttpMigrateProgram.IConfig) =>
|
15
|
-
(components: OpenApi.IComponents) =>
|
16
|
-
(importer: MigrateImportProgrammer) =>
|
17
|
-
(route: IHttpMigrateRoute): ts.FunctionDeclaration =>
|
18
|
-
FilePrinter.description(
|
19
|
-
ts.factory.createFunctionDeclaration(
|
20
|
-
[
|
21
|
-
ts.factory.createModifier(ts.SyntaxKind.ExportKeyword),
|
22
|
-
ts.factory.createModifier(ts.SyntaxKind.AsyncKeyword),
|
23
|
-
],
|
24
|
-
undefined,
|
25
|
-
route.accessor.at(-1)!,
|
26
|
-
undefined,
|
27
|
-
writeParameterDeclarations(components)(importer)(route),
|
28
|
-
ts.factory.createTypeReferenceNode("Promise", [
|
29
|
-
ts.factory.createTypeReferenceNode(
|
30
|
-
route.success === null
|
31
|
-
? "void"
|
32
|
-
: `${route.accessor.at(-1)!}.Output`,
|
33
|
-
),
|
34
|
-
]),
|
35
|
-
ts.factory.createBlock(writeBody(config)(importer)(route), true),
|
36
|
-
),
|
37
|
-
writeDescription(config)(route),
|
38
|
-
);
|
39
|
-
|
40
|
-
export const writeParameterDeclarations =
|
41
|
-
(components: OpenApi.IComponents) =>
|
42
|
-
(importer: MigrateImportProgrammer) =>
|
43
|
-
(route: IHttpMigrateRoute): ts.ParameterDeclaration[] => [
|
44
|
-
IdentifierFactory.parameter(
|
45
|
-
"connection",
|
46
|
-
ts.factory.createTypeReferenceNode(
|
47
|
-
importer.external({
|
48
|
-
type: "instance",
|
49
|
-
library: "@nestia/fetcher",
|
50
|
-
name: "IConnection",
|
51
|
-
}),
|
52
|
-
route.headers
|
53
|
-
? [
|
54
|
-
ts.factory.createTypeReferenceNode(
|
55
|
-
`${route.accessor.at(-1)!}.Headers`,
|
56
|
-
),
|
57
|
-
]
|
58
|
-
: undefined,
|
59
|
-
),
|
60
|
-
),
|
61
|
-
...route.parameters.map((p) =>
|
62
|
-
IdentifierFactory.parameter(
|
63
|
-
p.key,
|
64
|
-
MigrateSchemaProgrammer.write(components)(importer)(p.schema),
|
65
|
-
),
|
66
|
-
),
|
67
|
-
...(route.query
|
68
|
-
? [
|
69
|
-
IdentifierFactory.parameter(
|
70
|
-
route.query.key,
|
71
|
-
ts.factory.createTypeReferenceNode(
|
72
|
-
`${route.accessor.at(-1)!}.Query`,
|
73
|
-
),
|
74
|
-
),
|
75
|
-
]
|
76
|
-
: []),
|
77
|
-
...(route.body
|
78
|
-
? [
|
79
|
-
IdentifierFactory.parameter(
|
80
|
-
route.body.key,
|
81
|
-
ts.factory.createTypeReferenceNode(
|
82
|
-
`${route.accessor.at(-1)!}.Input`,
|
83
|
-
),
|
84
|
-
(route.body.type === "application/json" ||
|
85
|
-
route.body.type === "text/plain") &&
|
86
|
-
route.operation().requestBody?.required === false
|
87
|
-
? ts.factory.createToken(ts.SyntaxKind.QuestionToken)
|
88
|
-
: undefined,
|
89
|
-
),
|
90
|
-
]
|
91
|
-
: []),
|
92
|
-
];
|
93
|
-
|
94
|
-
const writeDescription =
|
95
|
-
(config: MigrateApplication.IConfig) =>
|
96
|
-
(route: IHttpMigrateRoute): string =>
|
97
|
-
[
|
98
|
-
route.comment(),
|
99
|
-
`@path ${route.emendedPath}`,
|
100
|
-
`@${config.author?.tag ?? "nestia"} ${config.author?.value ?? "Generated by Nestia - https://github.com/samchon/nestia"}`,
|
101
|
-
].join("\n");
|
102
|
-
|
103
|
-
const writeBody =
|
104
|
-
(config: IHttpMigrateProgram.IConfig) =>
|
105
|
-
(importer: MigrateImportProgrammer) =>
|
106
|
-
(route: IHttpMigrateRoute): ts.Statement[] => {
|
107
|
-
const encrypted: boolean = !!route.success?.["x-nestia-encrypted"];
|
108
|
-
const contentType: string = route.body?.type ?? "application/json";
|
109
|
-
|
110
|
-
const caller = () =>
|
111
|
-
ts.factory.createCallExpression(
|
112
|
-
IdentifierFactory.access(
|
113
|
-
ts.factory.createIdentifier(
|
114
|
-
importer.external({
|
115
|
-
type: "instance",
|
116
|
-
library: `@nestia/fetcher/lib/${encrypted ? "EncryptedFetcher" : "PlainFetcher"}`,
|
117
|
-
name: encrypted ? "EncryptedFetcher" : "PlainFetcher",
|
118
|
-
}),
|
119
|
-
),
|
120
|
-
"fetch",
|
121
|
-
),
|
122
|
-
undefined,
|
123
|
-
[
|
124
|
-
contentType && contentType !== "multipart/form-data"
|
125
|
-
? ts.factory.createObjectLiteralExpression(
|
126
|
-
[
|
127
|
-
ts.factory.createSpreadAssignment(
|
128
|
-
ts.factory.createIdentifier("connection"),
|
129
|
-
),
|
130
|
-
ts.factory.createPropertyAssignment(
|
131
|
-
"headers",
|
132
|
-
ts.factory.createObjectLiteralExpression(
|
133
|
-
[
|
134
|
-
ts.factory.createSpreadAssignment(
|
135
|
-
IdentifierFactory.access(
|
136
|
-
ts.factory.createIdentifier("connection"),
|
137
|
-
"headers",
|
138
|
-
),
|
139
|
-
),
|
140
|
-
ts.factory.createPropertyAssignment(
|
141
|
-
ts.factory.createStringLiteral("Content-Type"),
|
142
|
-
ts.factory.createStringLiteral(contentType),
|
143
|
-
),
|
144
|
-
],
|
145
|
-
true,
|
146
|
-
),
|
147
|
-
),
|
148
|
-
],
|
149
|
-
true,
|
150
|
-
)
|
151
|
-
: ts.factory.createIdentifier("connection"),
|
152
|
-
ts.factory.createObjectLiteralExpression(
|
153
|
-
[
|
154
|
-
ts.factory.createSpreadAssignment(
|
155
|
-
IdentifierFactory.access(
|
156
|
-
ts.factory.createIdentifier(route.accessor.at(-1)!),
|
157
|
-
"METADATA",
|
158
|
-
),
|
159
|
-
),
|
160
|
-
ts.factory.createPropertyAssignment(
|
161
|
-
"path",
|
162
|
-
ts.factory.createCallExpression(
|
163
|
-
IdentifierFactory.access(
|
164
|
-
ts.factory.createIdentifier(route.accessor.at(-1)!),
|
165
|
-
"path",
|
166
|
-
),
|
167
|
-
undefined,
|
168
|
-
[
|
169
|
-
...route.parameters.map((p) =>
|
170
|
-
ts.factory.createIdentifier(p.key),
|
171
|
-
),
|
172
|
-
...(route.query
|
173
|
-
? [ts.factory.createIdentifier(route.query.key)]
|
174
|
-
: []),
|
175
|
-
],
|
176
|
-
),
|
177
|
-
),
|
178
|
-
ts.factory.createPropertyAssignment(
|
179
|
-
"status",
|
180
|
-
ts.factory.createNull(),
|
181
|
-
),
|
182
|
-
],
|
183
|
-
true,
|
184
|
-
),
|
185
|
-
...(route.body
|
186
|
-
? [ts.factory.createIdentifier(route.body.key)]
|
187
|
-
: []),
|
188
|
-
],
|
189
|
-
);
|
190
|
-
if (config.simulate !== true)
|
191
|
-
return [ts.factory.createReturnStatement(caller())];
|
192
|
-
return [
|
193
|
-
ts.factory.createReturnStatement(
|
194
|
-
ts.factory.createConditionalExpression(
|
195
|
-
ts.factory.createIdentifier("!!connection.simulate"),
|
196
|
-
undefined,
|
197
|
-
ts.factory.createCallExpression(
|
198
|
-
ts.factory.createIdentifier(`${route.accessor.at(-1)!}.simulate`),
|
199
|
-
[],
|
200
|
-
[
|
201
|
-
"connection",
|
202
|
-
...route.parameters.map((p) => p.key),
|
203
|
-
...(route.query ? [route.query.key] : []),
|
204
|
-
...(route.body ? [route.body.key] : []),
|
205
|
-
].map((key) => ts.factory.createIdentifier(key)),
|
206
|
-
),
|
207
|
-
undefined,
|
208
|
-
caller(),
|
209
|
-
),
|
210
|
-
),
|
211
|
-
];
|
212
|
-
};
|
213
|
-
}
|