@nestia/sdk 12.0.0-dev.20260601.1 → 12.0.0-dev.20260612.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +93 -93
- package/assets/bundle/api/HttpError.ts +1 -1
- package/assets/bundle/api/IConnection.ts +1 -1
- package/assets/bundle/api/Primitive.ts +1 -1
- package/assets/bundle/api/Resolved.ts +1 -1
- package/assets/bundle/api/index.ts +4 -4
- package/assets/bundle/api/module.ts +6 -6
- package/assets/bundle/distribute/README.md +37 -37
- package/assets/bundle/distribute/package.json +28 -28
- package/assets/bundle/distribute/tsconfig.json +109 -109
- package/assets/bundle/e2e/index.ts +42 -42
- package/assets/config/nestia.config.ts +97 -97
- package/lib/NestiaSdkApplication.js +29 -7
- package/lib/NestiaSdkApplication.js.map +1 -1
- package/lib/NestiaSwaggerComposer.js +21 -13
- package/lib/NestiaSwaggerComposer.js.map +1 -1
- package/lib/analyses/AccessorAnalyzer.d.ts +4 -1
- package/lib/analyses/AccessorAnalyzer.js.map +1 -1
- package/lib/analyses/ConfigAnalyzer.js +1 -1
- package/lib/analyses/PathAnalyzer.d.ts +18 -3
- package/lib/analyses/PathAnalyzer.js +32 -0
- package/lib/analyses/PathAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectControllerAnalyzer.js +3 -2
- package/lib/analyses/ReflectControllerAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationAnalyzer.d.ts +1 -1
- package/lib/analyses/ReflectHttpOperationAnalyzer.js +1 -1
- package/lib/analyses/ReflectHttpOperationAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.d.ts +1 -1
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.js +53 -20
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectMcpOperationAnalyzer.d.ts +14 -0
- package/lib/analyses/ReflectMcpOperationAnalyzer.js +79 -0
- package/lib/analyses/ReflectMcpOperationAnalyzer.js.map +1 -0
- package/lib/analyses/TypedMcpRouteAnalyzer.d.ts +9 -0
- package/lib/analyses/TypedMcpRouteAnalyzer.js +31 -0
- package/lib/analyses/TypedMcpRouteAnalyzer.js.map +1 -0
- package/lib/executable/internal/NestiaConfigLoader.js +5 -1
- package/lib/executable/internal/NestiaConfigLoader.js.map +1 -1
- package/lib/executable/internal/NestiaSdkCommand.js +30 -14
- package/lib/executable/internal/NestiaSdkCommand.js.map +1 -1
- package/lib/executable/internal/NestiaSdkWatcher.d.ts +10 -0
- package/lib/executable/internal/NestiaSdkWatcher.js +322 -0
- package/lib/executable/internal/NestiaSdkWatcher.js.map +1 -0
- package/lib/executable/sdk.js +12 -12
- package/lib/executable/sdk.js.map +1 -1
- package/lib/generates/CloneGenerator.js +4 -2
- package/lib/generates/CloneGenerator.js.map +1 -1
- package/lib/generates/SdkGenerator.js +50 -1
- package/lib/generates/SdkGenerator.js.map +1 -1
- package/lib/generates/SwaggerGenerator.js +18 -2
- package/lib/generates/SwaggerGenerator.js.map +1 -1
- package/lib/generates/internal/E2eFileProgrammer.js +3 -1
- package/lib/generates/internal/E2eFileProgrammer.js.map +1 -1
- package/lib/generates/internal/ImportDictionary.d.ts +1 -0
- package/lib/generates/internal/ImportDictionary.js +9 -4
- package/lib/generates/internal/ImportDictionary.js.map +1 -1
- package/lib/generates/internal/SdkAliasCollection.d.ts +2 -0
- package/lib/generates/internal/SdkAliasCollection.js +11 -2
- package/lib/generates/internal/SdkAliasCollection.js.map +1 -1
- package/lib/generates/internal/SdkDistributionComposer.d.ts +1 -0
- package/lib/generates/internal/SdkDistributionComposer.js +3 -0
- package/lib/generates/internal/SdkDistributionComposer.js.map +1 -1
- package/lib/generates/internal/SdkFileProgrammer.js +4 -1
- package/lib/generates/internal/SdkFileProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpCloneReferencer.d.ts +1 -1
- package/lib/generates/internal/SdkHttpCloneReferencer.js +42 -9
- package/lib/generates/internal/SdkHttpCloneReferencer.js.map +1 -1
- package/lib/generates/internal/SdkHttpFunctionProgrammer.js +3 -4
- package/lib/generates/internal/SdkHttpFunctionProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.js +2 -1
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpSimulationProgrammer.js +6 -3
- package/lib/generates/internal/SdkHttpSimulationProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkMcpRouteProgrammer.d.ts +15 -0
- package/lib/generates/internal/SdkMcpRouteProgrammer.js +148 -0
- package/lib/generates/internal/SdkMcpRouteProgrammer.js.map +1 -0
- package/lib/generates/internal/SdkRouteDirectory.d.ts +2 -1
- package/lib/generates/internal/SdkRouteDirectory.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketCloneProgrammer.d.ts +6 -0
- package/lib/generates/internal/SdkWebSocketCloneProgrammer.js +283 -0
- package/lib/generates/internal/SdkWebSocketCloneProgrammer.js.map +1 -0
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.js +11 -9
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.js.map +1 -1
- package/lib/generates/internal/SwaggerOperationParameterComposer.js +10 -2
- package/lib/generates/internal/SwaggerOperationParameterComposer.js.map +1 -1
- package/lib/generates/internal/SwaggerOperationResponseComposer.d.ts +1 -1
- package/lib/generates/internal/SwaggerOperationResponseComposer.js +6 -1
- package/lib/generates/internal/SwaggerOperationResponseComposer.js.map +1 -1
- package/lib/generates/internal/SwaggerReadonlyArrayEmender.d.ts +9 -0
- package/lib/generates/internal/SwaggerReadonlyArrayEmender.js +174 -0
- package/lib/generates/internal/SwaggerReadonlyArrayEmender.js.map +1 -0
- package/lib/structures/INestiaSdkInput.d.ts +9 -2
- package/lib/structures/IReflectController.d.ts +2 -1
- package/lib/structures/IReflectHttpOperationSuccess.d.ts +4 -2
- package/lib/structures/IReflectMcpOperation.d.ts +35 -0
- package/lib/structures/IReflectMcpOperation.js +3 -0
- package/lib/structures/IReflectMcpOperation.js.map +1 -0
- package/lib/structures/IReflectMcpOperationParameter.d.ts +19 -0
- package/lib/structures/IReflectMcpOperationParameter.js +3 -0
- package/lib/structures/IReflectMcpOperationParameter.js.map +1 -0
- package/lib/structures/ITypedApplication.d.ts +2 -1
- package/lib/structures/ITypedHttpRouteSuccess.d.ts +3 -1
- package/lib/structures/ITypedMcpRoute.d.ts +31 -0
- package/lib/structures/ITypedMcpRoute.js +3 -0
- package/lib/structures/ITypedMcpRoute.js.map +1 -0
- package/lib/utils/HttpResponseContentTypeUtil.d.ts +5 -0
- package/lib/utils/HttpResponseContentTypeUtil.js +22 -0
- package/lib/utils/HttpResponseContentTypeUtil.js.map +1 -0
- package/native/go.mod +52 -52
- package/native/go.sum +84 -54
- package/native/sdk/register.go +322 -165
- package/native/sdk/sdk.go +17 -17
- package/native/sdk/sdk_metadata_json.go +327 -327
- package/native/sdk/sdk_transform.go +1879 -1549
- package/package.json +11 -9
- package/src/INestiaConfig.ts +267 -267
- package/src/NestiaSdkApplication.ts +39 -8
- package/src/NestiaSwaggerComposer.ts +153 -142
- package/src/analyses/AccessorAnalyzer.ts +64 -67
- package/src/analyses/ConfigAnalyzer.ts +330 -330
- package/src/analyses/ImportAnalyzer.ts +92 -92
- package/src/analyses/PathAnalyzer.ts +130 -69
- package/src/analyses/ReflectControllerAnalyzer.ts +112 -105
- package/src/analyses/ReflectHttpOperationAnalyzer.ts +183 -183
- package/src/analyses/ReflectHttpOperationExceptionAnalyzer.ts +90 -90
- package/src/analyses/ReflectHttpOperationParameterAnalyzer.ts +350 -350
- package/src/analyses/ReflectHttpOperationResponseAnalyzer.ts +163 -130
- package/src/analyses/ReflectMcpOperationAnalyzer.ts +124 -0
- package/src/analyses/ReflectMetadataAnalyzer.ts +44 -44
- package/src/analyses/SecurityAnalyzer.ts +25 -25
- package/src/analyses/TypedMcpRouteAnalyzer.ts +34 -0
- package/src/decorators/OperationMetadata.ts +29 -29
- package/src/executable/internal/CommandParser.ts +15 -15
- package/src/executable/internal/NestiaConfigLoader.ts +451 -446
- package/src/executable/internal/NestiaSdkCommand.ts +124 -106
- package/src/executable/internal/NestiaSdkWatcher.ts +342 -0
- package/src/executable/sdk.ts +90 -88
- package/src/generates/CloneGenerator.ts +73 -66
- package/src/generates/E2eGenerator.ts +32 -32
- package/src/generates/SdkGenerator.ts +176 -118
- package/src/generates/SwaggerGenerator.ts +342 -310
- package/src/generates/internal/E2eFileProgrammer.ts +240 -233
- package/src/generates/internal/FilePrinter.ts +65 -65
- package/src/generates/internal/ImportDictionary.ts +209 -204
- package/src/generates/internal/SdkAliasCollection.ts +274 -261
- package/src/generates/internal/SdkDistributionComposer.ts +123 -116
- package/src/generates/internal/SdkFileProgrammer.ts +116 -112
- package/src/generates/internal/SdkHttpCloneProgrammer.ts +126 -126
- package/src/generates/internal/SdkHttpCloneReferencer.ts +131 -77
- package/src/generates/internal/SdkHttpFunctionProgrammer.ts +301 -301
- package/src/generates/internal/SdkHttpNamespaceProgrammer.ts +520 -510
- package/src/generates/internal/SdkHttpParameterProgrammer.ts +165 -165
- package/src/generates/internal/SdkHttpRouteProgrammer.ts +109 -109
- package/src/generates/internal/SdkHttpSimulationProgrammer.ts +331 -314
- package/src/generates/internal/SdkImportWizard.ts +62 -62
- package/src/generates/internal/SdkMcpRouteProgrammer.ts +452 -0
- package/src/generates/internal/SdkRouteDirectory.ts +21 -18
- package/src/generates/internal/SdkTypeTagProgrammer.ts +114 -114
- package/src/generates/internal/SdkWebSocketCloneProgrammer.ts +319 -0
- package/src/generates/internal/SdkWebSocketNamespaceProgrammer.ts +389 -389
- package/src/generates/internal/SdkWebSocketParameterProgrammer.ts +89 -89
- package/src/generates/internal/SdkWebSocketRouteProgrammer.ts +331 -323
- package/src/generates/internal/SwaggerDescriptionComposer.ts +64 -64
- package/src/generates/internal/SwaggerOperationComposer.ts +119 -119
- package/src/generates/internal/SwaggerOperationParameterComposer.ts +175 -162
- package/src/generates/internal/SwaggerOperationResponseComposer.ts +115 -110
- package/src/generates/internal/SwaggerReadonlyArrayEmender.ts +262 -0
- package/src/index.ts +4 -4
- package/src/internal/legacy.ts +492 -492
- package/src/module.ts +4 -4
- package/src/structures/INestiaProject.ts +10 -10
- package/src/structures/INestiaSdkInput.ts +27 -20
- package/src/structures/IOperationMetadata.ts +41 -41
- package/src/structures/IReflectController.ts +18 -15
- package/src/structures/IReflectHttpOperation.ts +26 -26
- package/src/structures/IReflectHttpOperationException.ts +18 -18
- package/src/structures/IReflectHttpOperationParameter.ts +79 -79
- package/src/structures/IReflectHttpOperationSuccess.ts +18 -21
- package/src/structures/IReflectImport.ts +6 -6
- package/src/structures/IReflectMcpOperation.ts +38 -0
- package/src/structures/IReflectMcpOperationParameter.ts +27 -0
- package/src/structures/IReflectOperationError.ts +26 -26
- package/src/structures/IReflectType.ts +4 -4
- package/src/structures/IReflectWebSocketOperation.ts +17 -17
- package/src/structures/ITypedApplication.ts +12 -11
- package/src/structures/ITypedHttpRoute.ts +41 -41
- package/src/structures/ITypedHttpRouteException.ts +15 -15
- package/src/structures/ITypedHttpRouteParameter.ts +41 -41
- package/src/structures/ITypedHttpRouteSuccess.ts +18 -22
- package/src/structures/ITypedMcpRoute.ts +33 -0
- package/src/structures/ITypedWebSocketRoute.ts +24 -24
- package/src/structures/ITypedWebSocketRouteParameter.ts +3 -3
- package/src/transform.ts +59 -59
- package/src/typings/get-function-location.d.ts +7 -7
- package/src/utils/ArrayUtil.ts +26 -26
- package/src/utils/EmittedJavaScriptPatcher.ts +88 -88
- package/src/utils/FileRetriever.ts +22 -22
- package/src/utils/HttpResponseContentTypeUtil.ts +30 -0
- package/src/utils/MapUtil.ts +14 -14
- package/src/utils/PathUtil.ts +10 -10
- package/src/utils/SourceFinder.ts +63 -63
- package/src/utils/StringUtil.ts +17 -17
- package/src/utils/TsConfigReader.ts +108 -108
- package/src/utils/TtscExecutor.ts +68 -68
- package/src/utils/VersioningStrategy.ts +28 -28
- package/src/validators/HttpHeadersValidator.ts +11 -11
- package/src/validators/HttpQueryValidator.ts +11 -11
- package/src/validators/TextPlainValidator.ts +17 -17
package/src/executable/sdk.ts
CHANGED
|
@@ -1,88 +1,90 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import cp from "child_process";
|
|
3
|
-
import fs from "fs";
|
|
4
|
-
import process from "process";
|
|
5
|
-
|
|
6
|
-
import { CommandParser } from "./internal/CommandParser";
|
|
7
|
-
import type { NestiaSdkCommand } from "./internal/NestiaSdkCommand";
|
|
8
|
-
|
|
9
|
-
const USAGE = `Wrong command has been detected. Use like below:
|
|
10
|
-
|
|
11
|
-
npx @nestia/sdk [command] [options?]
|
|
12
|
-
|
|
13
|
-
1. npx @nestia/sdk dependencies --manager (npm|pnpm|yarn)
|
|
14
|
-
- npx @nestia/sdk dependencies
|
|
15
|
-
- npx @nestia/sdk dependencies --manager pnpm
|
|
16
|
-
2. npx @nestia/sdk init
|
|
17
|
-
3. npx @nestia/sdk sdk --config? [config file] --project? [project file]
|
|
18
|
-
4. npx @nestia/sdk swagger --config? [config file] --project? [project file]
|
|
19
|
-
5. npx @nestia/sdk e2e --config? [config file] --project? [project file]
|
|
20
|
-
6. npx @nestia/sdk all --config? [config file] --project? [project file]
|
|
21
|
-
`;
|
|
22
|
-
|
|
23
|
-
function halt(desc: string): never {
|
|
24
|
-
console.error(desc);
|
|
25
|
-
process.exit(-1);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function dependencies(argv: string[]): void {
|
|
29
|
-
// INSTALL DEPENDENCIES
|
|
30
|
-
const options = CommandParser.parse(argv);
|
|
31
|
-
const module = options.manager ?? options.module ?? "npm";
|
|
32
|
-
const prefix: string = module === "yarn" ? "yarn add" : `${module} install`;
|
|
33
|
-
|
|
34
|
-
for (const lib of ["@nestia/e2e", "@nestia/fetcher", "typia"]) {
|
|
35
|
-
const command: string = `${prefix} ${lib}`;
|
|
36
|
-
console.log(`\n$ ${command}`);
|
|
37
|
-
cp.execSync(command, { stdio: "inherit" });
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async function initialize(): Promise<void> {
|
|
42
|
-
if (fs.existsSync("nestia.config.ts") === true)
|
|
43
|
-
halt(
|
|
44
|
-
`Error on nestia.sdk.initialize(): "nestia.config.ts" file already has been configured.`,
|
|
45
|
-
);
|
|
46
|
-
await fs.promises.copyFile(
|
|
47
|
-
`${__dirname}/../../assets/config/nestia.config.ts`,
|
|
48
|
-
"nestia.config.ts",
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
async function execute(
|
|
53
|
-
closure: (commander: typeof NestiaSdkCommand) => Promise<void>,
|
|
54
|
-
): Promise<void> {
|
|
55
|
-
const module = await import(
|
|
56
|
-
"./internal/NestiaSdkCommand" as "./internal/NestiaSdkCommand.js"
|
|
57
|
-
);
|
|
58
|
-
await closure(module.NestiaSdkCommand);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
async function main() {
|
|
62
|
-
const type: string | undefined = process.argv[2];
|
|
63
|
-
const argv: string[] = process.argv.slice(3);
|
|
64
|
-
|
|
65
|
-
if (type === "dependencies") dependencies(argv);
|
|
66
|
-
else if (type === "init") await initialize();
|
|
67
|
-
else if (type === "sdk") await execute((c) => c.sdk());
|
|
68
|
-
else if (type === "swagger") await execute((c) => c.swagger());
|
|
69
|
-
else if (type === "e2e") await execute((c) => c.e2e());
|
|
70
|
-
else if (type === "all") await execute((c) => c.all());
|
|
71
|
-
else halt(USAGE);
|
|
72
|
-
|
|
73
|
-
process.exit(0);
|
|
74
|
-
}
|
|
75
|
-
main().catch((exp) => {
|
|
76
|
-
let current: unknown = exp;
|
|
77
|
-
let depth = 0;
|
|
78
|
-
while (current !== undefined && current !== null && depth < 10) {
|
|
79
|
-
const message: string =
|
|
80
|
-
current instanceof Error ? current.message : String(current);
|
|
81
|
-
console.error(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import cp from "child_process";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import process from "process";
|
|
5
|
+
|
|
6
|
+
import { CommandParser } from "./internal/CommandParser";
|
|
7
|
+
import type { NestiaSdkCommand } from "./internal/NestiaSdkCommand";
|
|
8
|
+
|
|
9
|
+
const USAGE = `Wrong command has been detected. Use like below:
|
|
10
|
+
|
|
11
|
+
npx @nestia/sdk [command] [options?]
|
|
12
|
+
|
|
13
|
+
1. npx @nestia/sdk dependencies --manager (npm|pnpm|yarn)
|
|
14
|
+
- npx @nestia/sdk dependencies
|
|
15
|
+
- npx @nestia/sdk dependencies --manager pnpm
|
|
16
|
+
2. npx @nestia/sdk init
|
|
17
|
+
3. npx @nestia/sdk sdk --config? [config file] --project? [project file]
|
|
18
|
+
4. npx @nestia/sdk swagger --watch? --config? [config file] --project? [project file]
|
|
19
|
+
5. npx @nestia/sdk e2e --config? [config file] --project? [project file]
|
|
20
|
+
6. npx @nestia/sdk all --config? [config file] --project? [project file]
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
function halt(desc: string): never {
|
|
24
|
+
console.error(desc);
|
|
25
|
+
process.exit(-1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function dependencies(argv: string[]): void {
|
|
29
|
+
// INSTALL DEPENDENCIES
|
|
30
|
+
const options = CommandParser.parse(argv);
|
|
31
|
+
const module = options.manager ?? options.module ?? "npm";
|
|
32
|
+
const prefix: string = module === "yarn" ? "yarn add" : `${module} install`;
|
|
33
|
+
|
|
34
|
+
for (const lib of ["@nestia/e2e", "@nestia/fetcher", "typia"]) {
|
|
35
|
+
const command: string = `${prefix} ${lib}`;
|
|
36
|
+
console.log(`\n$ ${command}`);
|
|
37
|
+
cp.execSync(command, { stdio: "inherit" });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function initialize(): Promise<void> {
|
|
42
|
+
if (fs.existsSync("nestia.config.ts") === true)
|
|
43
|
+
halt(
|
|
44
|
+
`Error on nestia.sdk.initialize(): "nestia.config.ts" file already has been configured.`,
|
|
45
|
+
);
|
|
46
|
+
await fs.promises.copyFile(
|
|
47
|
+
`${__dirname}/../../assets/config/nestia.config.ts`,
|
|
48
|
+
"nestia.config.ts",
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async function execute(
|
|
53
|
+
closure: (commander: typeof NestiaSdkCommand) => Promise<void>,
|
|
54
|
+
): Promise<void> {
|
|
55
|
+
const module = await import(
|
|
56
|
+
"./internal/NestiaSdkCommand" as "./internal/NestiaSdkCommand.js"
|
|
57
|
+
);
|
|
58
|
+
await closure(module.NestiaSdkCommand);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async function main() {
|
|
62
|
+
const type: string | undefined = process.argv[2];
|
|
63
|
+
const argv: string[] = process.argv.slice(3);
|
|
64
|
+
|
|
65
|
+
if (type === "dependencies") dependencies(argv);
|
|
66
|
+
else if (type === "init") await initialize();
|
|
67
|
+
else if (type === "sdk") await execute((c) => c.sdk());
|
|
68
|
+
else if (type === "swagger") await execute((c) => c.swagger());
|
|
69
|
+
else if (type === "e2e") await execute((c) => c.e2e());
|
|
70
|
+
else if (type === "all") await execute((c) => c.all());
|
|
71
|
+
else halt(USAGE);
|
|
72
|
+
|
|
73
|
+
process.exit(0);
|
|
74
|
+
}
|
|
75
|
+
main().catch((exp) => {
|
|
76
|
+
let current: unknown = exp;
|
|
77
|
+
let depth = 0;
|
|
78
|
+
while (current !== undefined && current !== null && depth < 10) {
|
|
79
|
+
const message: string =
|
|
80
|
+
current instanceof Error ? current.message : String(current);
|
|
81
|
+
console.error(
|
|
82
|
+
`${" ".repeat(depth)}${depth === 0 ? "" : "caused by: "}${message}`,
|
|
83
|
+
);
|
|
84
|
+
if (current instanceof Error && current.cause !== undefined) {
|
|
85
|
+
current = current.cause;
|
|
86
|
+
depth++;
|
|
87
|
+
} else break;
|
|
88
|
+
}
|
|
89
|
+
process.exit(-1);
|
|
90
|
+
});
|
|
@@ -1,66 +1,73 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
1
|
+
import {
|
|
2
|
+
Node,
|
|
3
|
+
NodeFlags,
|
|
4
|
+
SyntaxKind,
|
|
5
|
+
TypeScriptFactory,
|
|
6
|
+
} from "@nestia/factory";
|
|
7
|
+
import fs from "fs";
|
|
8
|
+
|
|
9
|
+
import { INestiaProject } from "../structures/INestiaProject";
|
|
10
|
+
import { ITypedApplication } from "../structures/ITypedApplication";
|
|
11
|
+
import { FilePrinter } from "./internal/FilePrinter";
|
|
12
|
+
import { ImportDictionary } from "./internal/ImportDictionary";
|
|
13
|
+
import { SdkHttpCloneProgrammer } from "./internal/SdkHttpCloneProgrammer";
|
|
14
|
+
import { SdkHttpCloneReferencer } from "./internal/SdkHttpCloneReferencer";
|
|
15
|
+
import { SdkWebSocketCloneProgrammer } from "./internal/SdkWebSocketCloneProgrammer";
|
|
16
|
+
|
|
17
|
+
export namespace CloneGenerator {
|
|
18
|
+
export const write = async (app: ITypedApplication): Promise<void> => {
|
|
19
|
+
const dict: Map<string, SdkHttpCloneProgrammer.IModule> =
|
|
20
|
+
SdkHttpCloneProgrammer.write(app);
|
|
21
|
+
const websocket: Set<string> = await SdkWebSocketCloneProgrammer.write(app);
|
|
22
|
+
if (dict.size === 0 && websocket.size === 0) return;
|
|
23
|
+
|
|
24
|
+
SdkHttpCloneReferencer.replace(app, websocket);
|
|
25
|
+
try {
|
|
26
|
+
await fs.promises.mkdir(`${app.project.config.output}/structures`);
|
|
27
|
+
} catch {}
|
|
28
|
+
for (const [key, value] of dict)
|
|
29
|
+
await writeDtoFile(app.project)(key, value);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const writeDtoFile =
|
|
33
|
+
(project: INestiaProject) =>
|
|
34
|
+
async (
|
|
35
|
+
key: string,
|
|
36
|
+
value: SdkHttpCloneProgrammer.IModule,
|
|
37
|
+
): Promise<void> => {
|
|
38
|
+
const location: string = `${project.config.output}/structures/${key}.ts`;
|
|
39
|
+
const importer: ImportDictionary = new ImportDictionary(location);
|
|
40
|
+
const statements: Node[] = iterate(importer)(value);
|
|
41
|
+
if (statements.length === 0) return;
|
|
42
|
+
|
|
43
|
+
await FilePrinter.write({
|
|
44
|
+
location,
|
|
45
|
+
statements: [
|
|
46
|
+
...importer.toStatements(`${project.config.output}/structures`),
|
|
47
|
+
...(importer.empty() ? [] : [FilePrinter.enter()]),
|
|
48
|
+
...statements,
|
|
49
|
+
],
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const iterate =
|
|
54
|
+
(importer: ImportDictionary) =>
|
|
55
|
+
(modulo: SdkHttpCloneProgrammer.IModule): Node[] => {
|
|
56
|
+
const output: Node[] = [];
|
|
57
|
+
if (modulo.programmer !== null) output.push(modulo.programmer(importer));
|
|
58
|
+
if (modulo.children.size) {
|
|
59
|
+
const internal: Node[] = [];
|
|
60
|
+
for (const child of modulo.children.values())
|
|
61
|
+
internal.push(...iterate(importer)(child));
|
|
62
|
+
output.push(
|
|
63
|
+
TypeScriptFactory.createModuleDeclaration(
|
|
64
|
+
[TypeScriptFactory.createModifier(SyntaxKind.ExportKeyword)],
|
|
65
|
+
TypeScriptFactory.createIdentifier(modulo.name),
|
|
66
|
+
TypeScriptFactory.createModuleBlock(internal),
|
|
67
|
+
NodeFlags.Namespace,
|
|
68
|
+
),
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
return output;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
|
|
4
|
-
import { ITypedApplication } from "../structures/ITypedApplication";
|
|
5
|
-
import { E2eFileProgrammer } from "./internal/E2eFileProgrammer";
|
|
6
|
-
|
|
7
|
-
export namespace E2eGenerator {
|
|
8
|
-
export const generate = async (app: ITypedApplication): Promise<void> => {
|
|
9
|
-
console.log("Generating E2E Test Functions");
|
|
10
|
-
|
|
11
|
-
// PREPARE DIRECTORIES
|
|
12
|
-
const output: string = path.resolve(app.project.config.e2e!);
|
|
13
|
-
await mkdir(output);
|
|
14
|
-
await mkdir(path.join(output, "features"));
|
|
15
|
-
await mkdir(path.join(output, "features", "api"));
|
|
16
|
-
await mkdir(path.join(output, "features", "api", "automated"));
|
|
17
|
-
|
|
18
|
-
// GENERATE EACH TEST FILES
|
|
19
|
-
for (const route of app.routes)
|
|
20
|
-
if (route.protocol === "http")
|
|
21
|
-
await E2eFileProgrammer.generate(app.project)({
|
|
22
|
-
api: path.resolve(app.project.config.output!),
|
|
23
|
-
current: path.join(output, "features", "api", "automated"),
|
|
24
|
-
})(route);
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const mkdir = async (location: string): Promise<void> => {
|
|
29
|
-
try {
|
|
30
|
-
await fs.promises.mkdir(location);
|
|
31
|
-
} catch {}
|
|
32
|
-
};
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
import { ITypedApplication } from "../structures/ITypedApplication";
|
|
5
|
+
import { E2eFileProgrammer } from "./internal/E2eFileProgrammer";
|
|
6
|
+
|
|
7
|
+
export namespace E2eGenerator {
|
|
8
|
+
export const generate = async (app: ITypedApplication): Promise<void> => {
|
|
9
|
+
console.log("Generating E2E Test Functions");
|
|
10
|
+
|
|
11
|
+
// PREPARE DIRECTORIES
|
|
12
|
+
const output: string = path.resolve(app.project.config.e2e!);
|
|
13
|
+
await mkdir(output);
|
|
14
|
+
await mkdir(path.join(output, "features"));
|
|
15
|
+
await mkdir(path.join(output, "features", "api"));
|
|
16
|
+
await mkdir(path.join(output, "features", "api", "automated"));
|
|
17
|
+
|
|
18
|
+
// GENERATE EACH TEST FILES
|
|
19
|
+
for (const route of app.routes)
|
|
20
|
+
if (route.protocol === "http")
|
|
21
|
+
await E2eFileProgrammer.generate(app.project)({
|
|
22
|
+
api: path.resolve(app.project.config.output!),
|
|
23
|
+
current: path.join(output, "features", "api", "automated"),
|
|
24
|
+
})(route);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const mkdir = async (location: string): Promise<void> => {
|
|
29
|
+
try {
|
|
30
|
+
await fs.promises.mkdir(location);
|
|
31
|
+
} catch {}
|
|
32
|
+
};
|