@nestia/sdk 11.2.1 → 12.0.0-dev.20260521.1
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/assets/bundle/distribute/package.json +1 -1
- package/lib/NestiaSdkApplication.js +5 -4
- package/lib/NestiaSdkApplication.js.map +1 -1
- package/lib/NestiaSwaggerComposer.js +2 -2
- package/lib/NestiaSwaggerComposer.js.map +1 -1
- package/lib/analyses/AccessorAnalyzer.js.map +1 -1
- package/lib/analyses/ConfigAnalyzer.js +133 -7
- package/lib/analyses/ConfigAnalyzer.js.map +1 -1
- package/lib/analyses/ImportAnalyzer.d.ts +9 -2
- package/lib/analyses/ImportAnalyzer.js +13 -50
- package/lib/analyses/ImportAnalyzer.js.map +1 -1
- package/lib/analyses/PathAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectControllerAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationAnalyzer.d.ts +1 -1
- package/lib/analyses/ReflectHttpOperationAnalyzer.js +5 -4
- package/lib/analyses/ReflectHttpOperationAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationExceptionAnalyzer.d.ts +1 -1
- package/lib/analyses/ReflectHttpOperationExceptionAnalyzer.js +22 -5
- package/lib/analyses/ReflectHttpOperationExceptionAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationParameterAnalyzer.d.ts +1 -1
- package/lib/analyses/ReflectHttpOperationParameterAnalyzer.js +8 -8
- package/lib/analyses/ReflectHttpOperationParameterAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.d.ts +1 -1
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.js +15 -15
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectMetadataAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectWebSocketOperationAnalyzer.d.ts +1 -1
- package/lib/analyses/ReflectWebSocketOperationAnalyzer.js +1 -1
- package/lib/analyses/ReflectWebSocketOperationAnalyzer.js.map +1 -1
- package/lib/analyses/SecurityAnalyzer.js.map +1 -1
- package/lib/analyses/TypedHttpRouteAnalyzer.d.ts +2 -1
- package/lib/analyses/TypedHttpRouteAnalyzer.js +296 -39
- package/lib/analyses/TypedHttpRouteAnalyzer.js.map +1 -1
- package/lib/analyses/TypedWebSocketRouteAnalyzer.js +1 -4
- package/lib/analyses/TypedWebSocketRouteAnalyzer.js.map +1 -1
- package/lib/decorators/OperationMetadata.d.ts +12 -2
- package/lib/decorators/OperationMetadata.js +14 -1
- package/lib/decorators/OperationMetadata.js.map +1 -1
- package/lib/executable/internal/CommandParser.js.map +1 -1
- package/lib/executable/internal/NestiaConfigLoader.d.ts +6 -2
- package/lib/executable/internal/NestiaConfigLoader.js +285 -793
- package/lib/executable/internal/NestiaConfigLoader.js.map +1 -1
- package/lib/executable/internal/NestiaSdkCommand.js +6 -4
- package/lib/executable/internal/NestiaSdkCommand.js.map +1 -1
- package/lib/executable/sdk.js +17 -5
- package/lib/executable/sdk.js.map +1 -1
- package/lib/generates/CloneGenerator.js +2 -2
- package/lib/generates/CloneGenerator.js.map +1 -1
- package/lib/generates/E2eGenerator.js.map +1 -1
- package/lib/generates/SdkGenerator.js +6 -9
- package/lib/generates/SdkGenerator.js.map +1 -1
- package/lib/generates/SwaggerGenerator.js +20 -107
- package/lib/generates/SwaggerGenerator.js.map +1 -1
- package/lib/generates/internal/E2eFileProgrammer.js +44 -28
- package/lib/generates/internal/E2eFileProgrammer.js.map +1 -1
- package/lib/generates/internal/FilePrinter.d.ts +4 -4
- package/lib/generates/internal/FilePrinter.js +25 -16
- package/lib/generates/internal/FilePrinter.js.map +1 -1
- package/lib/generates/internal/ImportDictionary.d.ts +2 -2
- package/lib/generates/internal/ImportDictionary.js +7 -5
- package/lib/generates/internal/ImportDictionary.js.map +1 -1
- package/lib/generates/internal/SdkAliasCollection.d.ts +11 -11
- package/lib/generates/internal/SdkAliasCollection.js +27 -31
- package/lib/generates/internal/SdkAliasCollection.js.map +1 -1
- package/lib/generates/internal/SdkDistributionComposer.js +15 -70
- package/lib/generates/internal/SdkDistributionComposer.js.map +1 -1
- package/lib/generates/internal/SdkFileProgrammer.js +2 -2
- package/lib/generates/internal/SdkFileProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpCloneProgrammer.d.ts +2 -2
- package/lib/generates/internal/SdkHttpCloneProgrammer.js +6 -12
- package/lib/generates/internal/SdkHttpCloneProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpCloneReferencer.js +2 -1
- package/lib/generates/internal/SdkHttpCloneReferencer.js.map +1 -1
- package/lib/generates/internal/SdkHttpFunctionProgrammer.d.ts +2 -2
- package/lib/generates/internal/SdkHttpFunctionProgrammer.js +73 -77
- package/lib/generates/internal/SdkHttpFunctionProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.d.ts +2 -2
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.js +64 -66
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpParameterProgrammer.d.ts +4 -10
- package/lib/generates/internal/SdkHttpParameterProgrammer.js +15 -22
- package/lib/generates/internal/SdkHttpParameterProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpRouteProgrammer.d.ts +2 -2
- package/lib/generates/internal/SdkHttpRouteProgrammer.js +18 -20
- package/lib/generates/internal/SdkHttpRouteProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpSimulationProgrammer.d.ts +3 -3
- package/lib/generates/internal/SdkHttpSimulationProgrammer.js +47 -49
- package/lib/generates/internal/SdkHttpSimulationProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkImportWizard.js.map +1 -1
- package/lib/generates/internal/SdkRouteDirectory.js.map +1 -1
- package/lib/generates/internal/SdkTypeProgrammer.d.ts +4 -4
- package/lib/generates/internal/SdkTypeProgrammer.js +66 -67
- package/lib/generates/internal/SdkTypeProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkTypeTagProgrammer.d.ts +1 -2
- package/lib/generates/internal/SdkTypeTagProgrammer.js +29 -11
- package/lib/generates/internal/SdkTypeTagProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.d.ts +2 -2
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js +55 -55
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketParameterProgrammer.d.ts +3 -3
- package/lib/generates/internal/SdkWebSocketParameterProgrammer.js +9 -12
- package/lib/generates/internal/SdkWebSocketParameterProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.d.ts +2 -2
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.js +43 -45
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.js.map +1 -1
- package/lib/generates/internal/SwaggerDescriptionComposer.js.map +1 -1
- package/lib/generates/internal/SwaggerOperationComposer.d.ts +1 -1
- package/lib/generates/internal/SwaggerOperationComposer.js +5 -4
- package/lib/generates/internal/SwaggerOperationComposer.js.map +1 -1
- package/lib/generates/internal/SwaggerOperationParameterComposer.d.ts +0 -3
- package/lib/generates/internal/SwaggerOperationParameterComposer.js +19 -20
- package/lib/generates/internal/SwaggerOperationParameterComposer.js.map +1 -1
- package/lib/generates/internal/SwaggerOperationResponseComposer.d.ts +1 -1
- package/lib/generates/internal/SwaggerOperationResponseComposer.js +4 -3
- package/lib/generates/internal/SwaggerOperationResponseComposer.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/internal/legacy.d.ts +180 -0
- package/lib/internal/legacy.js +361 -0
- package/lib/internal/legacy.js.map +1 -0
- package/lib/structures/INestiaProject.d.ts +0 -2
- package/lib/{transformers → structures}/IOperationMetadata.d.ts +2 -7
- package/lib/structures/IOperationMetadata.js.map +1 -0
- package/lib/structures/IReflectHttpOperationException.d.ts +1 -1
- package/lib/structures/IReflectHttpOperationParameter.d.ts +1 -1
- package/lib/structures/IReflectHttpOperationSuccess.d.ts +1 -1
- package/lib/structures/IReflectOperationError.d.ts +1 -1
- package/lib/structures/IReflectOperationError.js.map +1 -1
- package/lib/structures/IReflectWebSocketOperation.d.ts +2 -2
- package/lib/structures/ITypedApplication.d.ts +1 -1
- package/lib/structures/ITypedHttpRouteException.d.ts +1 -1
- package/lib/structures/ITypedHttpRouteParameter.d.ts +1 -1
- package/lib/structures/ITypedHttpRouteSuccess.d.ts +1 -1
- package/lib/structures/ITypedWebSocketRoute.d.ts +2 -2
- package/lib/transform.d.ts +16 -3
- package/lib/transform.js +47 -5
- package/lib/transform.js.map +1 -1
- package/lib/utils/ArrayUtil.js.map +1 -1
- package/lib/utils/FileRetriever.js.map +1 -1
- package/lib/utils/MapUtil.js.map +1 -1
- package/lib/utils/PathUtil.js.map +1 -1
- package/lib/utils/SourceFinder.js.map +1 -1
- package/lib/utils/StringUtil.js.map +1 -1
- package/lib/utils/TsConfigReader.d.ts +7 -0
- package/lib/utils/TsConfigReader.js +102 -0
- package/lib/utils/TsConfigReader.js.map +1 -0
- package/lib/utils/TtscExecutor.d.ts +8 -0
- package/lib/utils/TtscExecutor.js +58 -0
- package/lib/utils/TtscExecutor.js.map +1 -0
- package/lib/utils/VersioningStrategy.js.map +1 -1
- package/lib/validators/HttpHeadersValidator.d.ts +8 -5
- package/lib/validators/HttpHeadersValidator.js +7 -26
- package/lib/validators/HttpHeadersValidator.js.map +1 -1
- package/lib/validators/HttpQueryValidator.d.ts +8 -5
- package/lib/validators/HttpQueryValidator.js +7 -26
- package/lib/validators/HttpQueryValidator.js.map +1 -1
- package/lib/{transformers → validators}/TextPlainValidator.d.ts +1 -1
- package/lib/{transformers → validators}/TextPlainValidator.js +2 -1
- package/lib/validators/TextPlainValidator.js.map +1 -0
- package/native/go.mod +52 -0
- package/native/go.sum +54 -0
- package/native/sdk/register.go +130 -0
- package/native/sdk/sdk.go +17 -0
- package/native/sdk/sdk_metadata_json.go +327 -0
- package/native/sdk/sdk_transform.go +1542 -0
- package/package.json +19 -19
- package/src/NestiaSdkApplication.ts +9 -5
- package/src/NestiaSwaggerComposer.ts +2 -3
- package/src/analyses/ConfigAnalyzer.ts +175 -1
- package/src/analyses/ImportAnalyzer.ts +15 -49
- package/src/analyses/ReflectControllerAnalyzer.ts +1 -1
- package/src/analyses/ReflectHttpOperationAnalyzer.ts +1 -1
- package/src/analyses/ReflectHttpOperationExceptionAnalyzer.ts +24 -6
- package/src/analyses/ReflectHttpOperationParameterAnalyzer.ts +3 -3
- package/src/analyses/ReflectHttpOperationResponseAnalyzer.ts +14 -10
- package/src/analyses/ReflectWebSocketOperationAnalyzer.ts +2 -2
- package/src/analyses/TypedHttpRouteAnalyzer.ts +354 -22
- package/src/decorators/OperationMetadata.ts +17 -3
- package/src/executable/internal/NestiaConfigLoader.ts +419 -53
- package/src/executable/internal/NestiaSdkCommand.ts +9 -10
- package/src/executable/sdk.ts +15 -4
- package/src/generates/CloneGenerator.ts +10 -10
- package/src/generates/SwaggerGenerator.ts +28 -9
- package/src/generates/internal/E2eFileProgrammer.ts +80 -43
- package/src/generates/internal/FilePrinter.ts +38 -37
- package/src/generates/internal/ImportDictionary.ts +18 -16
- package/src/generates/internal/SdkAliasCollection.ts +41 -40
- package/src/generates/internal/SdkDistributionComposer.ts +21 -8
- package/src/generates/internal/SdkFileProgrammer.ts +7 -5
- package/src/generates/internal/SdkHttpCloneProgrammer.ts +10 -10
- package/src/generates/internal/SdkHttpCloneReferencer.ts +6 -6
- package/src/generates/internal/SdkHttpFunctionProgrammer.ts +101 -78
- package/src/generates/internal/SdkHttpNamespaceProgrammer.ts +153 -145
- package/src/generates/internal/SdkHttpParameterProgrammer.ts +20 -33
- package/src/generates/internal/SdkHttpRouteProgrammer.ts +2 -2
- package/src/generates/internal/SdkHttpSimulationProgrammer.ts +88 -86
- package/src/generates/internal/SdkTypeProgrammer.ts +93 -99
- package/src/generates/internal/SdkTypeTagProgrammer.ts +12 -12
- package/src/generates/internal/SdkWebSocketNamespaceProgrammer.ts +128 -118
- package/src/generates/internal/SdkWebSocketParameterProgrammer.ts +15 -13
- package/src/generates/internal/SdkWebSocketRouteProgrammer.ts +133 -112
- package/src/generates/internal/SwaggerOperationComposer.ts +1 -1
- package/src/generates/internal/SwaggerOperationParameterComposer.ts +10 -9
- package/src/generates/internal/SwaggerOperationResponseComposer.ts +1 -1
- package/src/internal/legacy.ts +492 -0
- package/src/structures/INestiaProject.ts +0 -3
- package/src/{transformers → structures}/IOperationMetadata.ts +2 -7
- package/src/structures/IReflectHttpOperationException.ts +1 -1
- package/src/structures/IReflectHttpOperationParameter.ts +1 -1
- package/src/structures/IReflectHttpOperationSuccess.ts +1 -1
- package/src/structures/IReflectOperationError.ts +1 -1
- package/src/structures/IReflectWebSocketOperation.ts +2 -2
- package/src/structures/ITypedApplication.ts +1 -1
- package/src/structures/ITypedHttpRouteException.ts +1 -1
- package/src/structures/ITypedHttpRouteParameter.ts +1 -1
- package/src/structures/ITypedHttpRouteSuccess.ts +1 -1
- package/src/structures/ITypedWebSocketRoute.ts +2 -2
- package/src/transform.ts +57 -7
- package/src/utils/TsConfigReader.ts +108 -0
- package/src/utils/TtscExecutor.ts +63 -0
- package/src/validators/HttpHeadersValidator.ts +8 -37
- package/src/validators/HttpQueryValidator.ts +8 -37
- package/src/{transformers → validators}/TextPlainValidator.ts +2 -2
- package/lib/analyses/DtoAnalyzer.d.ts +0 -21
- package/lib/analyses/DtoAnalyzer.js +0 -219
- package/lib/analyses/DtoAnalyzer.js.map +0 -1
- package/lib/analyses/ExceptionAnalyzer.d.ts +0 -0
- package/lib/analyses/ExceptionAnalyzer.js +0 -2
- package/lib/analyses/ExceptionAnalyzer.js.map +0 -1
- package/lib/analyses/GenericAnalyzer.d.ts +0 -4
- package/lib/analyses/GenericAnalyzer.js +0 -42
- package/lib/analyses/GenericAnalyzer.js.map +0 -1
- package/lib/structures/IReflectApplication.d.ts +0 -6
- package/lib/structures/IReflectApplication.js +0 -3
- package/lib/structures/IReflectApplication.js.map +0 -1
- package/lib/structures/MethodType.d.ts +0 -4
- package/lib/structures/MethodType.js +0 -8
- package/lib/structures/MethodType.js.map +0 -1
- package/lib/structures/ParamCategory.d.ts +0 -1
- package/lib/structures/ParamCategory.js +0 -3
- package/lib/structures/ParamCategory.js.map +0 -1
- package/lib/structures/TypeEntry.d.ts +0 -9
- package/lib/structures/TypeEntry.js +0 -21
- package/lib/structures/TypeEntry.js.map +0 -1
- package/lib/transformers/IOperationMetadata.js.map +0 -1
- package/lib/transformers/ISdkOperationTransformerContext.d.ts +0 -7
- package/lib/transformers/ISdkOperationTransformerContext.js +0 -3
- package/lib/transformers/ISdkOperationTransformerContext.js.map +0 -1
- package/lib/transformers/SdkOperationProgrammer.d.ts +0 -15
- package/lib/transformers/SdkOperationProgrammer.js +0 -186
- package/lib/transformers/SdkOperationProgrammer.js.map +0 -1
- package/lib/transformers/SdkOperationTransformer.d.ts +0 -4
- package/lib/transformers/SdkOperationTransformer.js +0 -128
- package/lib/transformers/SdkOperationTransformer.js.map +0 -1
- package/lib/transformers/TextPlainValidator.js.map +0 -1
- package/lib/utils/MetadataUtil.d.ts +0 -4
- package/lib/utils/MetadataUtil.js +0 -34
- package/lib/utils/MetadataUtil.js.map +0 -1
- package/lib/utils/StripEnums.d.ts +0 -3
- package/lib/utils/StripEnums.js +0 -3
- package/lib/utils/StripEnums.js.map +0 -1
- package/lib/utils/TypeLiteralExpression.d.ts +0 -0
- package/lib/utils/TypeLiteralExpression.js +0 -2
- package/lib/utils/TypeLiteralExpression.js.map +0 -1
- package/src/analyses/DtoAnalyzer.ts +0 -260
- package/src/analyses/ExceptionAnalyzer.ts +0 -154
- package/src/analyses/GenericAnalyzer.ts +0 -49
- package/src/structures/IReflectApplication.ts +0 -8
- package/src/structures/MethodType.ts +0 -5
- package/src/structures/ParamCategory.ts +0 -1
- package/src/structures/TypeEntry.ts +0 -22
- package/src/transformers/ISdkOperationTransformerContext.ts +0 -8
- package/src/transformers/SdkOperationProgrammer.ts +0 -240
- package/src/transformers/SdkOperationTransformer.ts +0 -248
- package/src/utils/MetadataUtil.ts +0 -26
- package/src/utils/StripEnums.ts +0 -5
- package/src/utils/TypeLiteralExpression.ts +0 -0
- /package/lib/{transformers → structures}/IOperationMetadata.js +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SwaggerCustomizer } from "@nestia/core";
|
|
2
|
-
import { JsonSchemasProgrammer, MetadataSchema } from "
|
|
2
|
+
import { JsonSchemasProgrammer, MetadataSchema, sizeOf } from "../internal/legacy";
|
|
3
3
|
import {
|
|
4
4
|
OpenApi,
|
|
5
5
|
OpenApiV3,
|
|
@@ -11,7 +11,7 @@ import { OpenApiConverter } from "@typia/utils";
|
|
|
11
11
|
import fs from "fs";
|
|
12
12
|
import path from "path";
|
|
13
13
|
import { Singleton } from "tstl";
|
|
14
|
-
import
|
|
14
|
+
import type { IJsonSchemaCollection } from "typia";
|
|
15
15
|
|
|
16
16
|
import { INestiaConfig } from "../INestiaConfig";
|
|
17
17
|
import { ITypedApplication } from "../structures/ITypedApplication";
|
|
@@ -89,7 +89,7 @@ export namespace SwaggerGenerator {
|
|
|
89
89
|
...Object.values(r.exceptions).map((e) => e.metadata),
|
|
90
90
|
])
|
|
91
91
|
.flat()
|
|
92
|
-
.filter((m) => m
|
|
92
|
+
.filter((m) => sizeOf(m) !== 0);
|
|
93
93
|
|
|
94
94
|
// COMPOSE JSON SCHEMAS
|
|
95
95
|
const json: IJsonSchemaCollection = JsonSchemasProgrammer.writeSchemas({
|
|
@@ -127,7 +127,7 @@ export namespace SwaggerGenerator {
|
|
|
127
127
|
|
|
128
128
|
try {
|
|
129
129
|
const content: string = await fs.promises.readFile(location, "utf8");
|
|
130
|
-
const data =
|
|
130
|
+
const data = JSON.parse(content) as {
|
|
131
131
|
name?: string;
|
|
132
132
|
version?: string;
|
|
133
133
|
description?: string;
|
|
@@ -138,12 +138,16 @@ export namespace SwaggerGenerator {
|
|
|
138
138
|
/** @format uri */
|
|
139
139
|
url: string;
|
|
140
140
|
};
|
|
141
|
-
}
|
|
141
|
+
};
|
|
142
142
|
return {
|
|
143
|
-
title: data.name,
|
|
144
|
-
version:
|
|
145
|
-
|
|
146
|
-
|
|
143
|
+
title: typeof data.name === "string" ? data.name : undefined,
|
|
144
|
+
version:
|
|
145
|
+
typeof data.version === "string" ? data.version : undefined,
|
|
146
|
+
description:
|
|
147
|
+
typeof data.description === "string"
|
|
148
|
+
? data.description
|
|
149
|
+
: undefined,
|
|
150
|
+
license: isLicense(data.license)
|
|
147
151
|
? typeof data.license === "string"
|
|
148
152
|
? { name: data.license }
|
|
149
153
|
: typeof data.license === "object"
|
|
@@ -191,6 +195,21 @@ export namespace SwaggerGenerator {
|
|
|
191
195
|
};
|
|
192
196
|
};
|
|
193
197
|
|
|
198
|
+
const isLicense = (
|
|
199
|
+
input: unknown,
|
|
200
|
+
): input is
|
|
201
|
+
| string
|
|
202
|
+
| {
|
|
203
|
+
type: string;
|
|
204
|
+
url: string;
|
|
205
|
+
} =>
|
|
206
|
+
typeof input === "string" ||
|
|
207
|
+
(typeof input === "object" &&
|
|
208
|
+
input !== null &&
|
|
209
|
+
Array.isArray(input) === false &&
|
|
210
|
+
typeof (input as { type?: unknown }).type === "string" &&
|
|
211
|
+
typeof (input as { url?: unknown }).url === "string");
|
|
212
|
+
|
|
194
213
|
const fillPaths = (props: {
|
|
195
214
|
config: Omit<INestiaConfig.ISwaggerConfig, "output">;
|
|
196
215
|
document: OpenApi.IDocument;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { Node, NodeFlags, SyntaxKind, TypeScriptFactory } from "@nestia/factory";
|
|
2
|
+
import { IdentifierFactory, LiteralFactory } from "@nestia/factory";
|
|
3
3
|
|
|
4
4
|
import { INestiaProject } from "../../structures/INestiaProject";
|
|
5
5
|
import { ITypedHttpRoute } from "../../structures/ITypedHttpRoute";
|
|
@@ -24,7 +24,7 @@ export namespace E2eFileProgrammer {
|
|
|
24
24
|
type: "default",
|
|
25
25
|
name: "api",
|
|
26
26
|
});
|
|
27
|
-
const functor:
|
|
27
|
+
const functor: Node = generateFunctor(project)(importer)(route);
|
|
28
28
|
await FilePrinter.write({
|
|
29
29
|
location: importer.file,
|
|
30
30
|
statements: [
|
|
@@ -38,19 +38,19 @@ export namespace E2eFileProgrammer {
|
|
|
38
38
|
const generateFunctor =
|
|
39
39
|
(project: INestiaProject) =>
|
|
40
40
|
(importer: ImportDictionary) =>
|
|
41
|
-
(route: ITypedHttpRoute):
|
|
42
|
-
|
|
43
|
-
[
|
|
44
|
-
|
|
41
|
+
(route: ITypedHttpRoute): Node =>
|
|
42
|
+
TypeScriptFactory.createVariableStatement(
|
|
43
|
+
[TypeScriptFactory.createModifier(SyntaxKind.ExportKeyword)],
|
|
44
|
+
TypeScriptFactory.createVariableDeclarationList(
|
|
45
45
|
[
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
TypeScriptFactory.createVariableDeclaration(
|
|
47
|
+
TypeScriptFactory.createIdentifier(getFunctionName(route)),
|
|
48
48
|
undefined,
|
|
49
49
|
undefined,
|
|
50
50
|
generateArrow(project)(importer)(route),
|
|
51
51
|
),
|
|
52
52
|
],
|
|
53
|
-
|
|
53
|
+
NodeFlags.Const,
|
|
54
54
|
),
|
|
55
55
|
);
|
|
56
56
|
|
|
@@ -59,27 +59,27 @@ export namespace E2eFileProgrammer {
|
|
|
59
59
|
(importer: ImportDictionary) =>
|
|
60
60
|
(route: ITypedHttpRoute) => {
|
|
61
61
|
const random = IdentifierFactory.access(
|
|
62
|
-
|
|
62
|
+
TypeScriptFactory.createIdentifier(SdkImportWizard.typia(importer)),
|
|
63
63
|
"random",
|
|
64
64
|
);
|
|
65
65
|
const connection = route.headerObject
|
|
66
|
-
?
|
|
66
|
+
? TypeScriptFactory.createObjectLiteralExpression(
|
|
67
67
|
[
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
TypeScriptFactory.createSpreadAssignment(
|
|
69
|
+
TypeScriptFactory.createIdentifier("connection"),
|
|
70
70
|
),
|
|
71
|
-
|
|
71
|
+
TypeScriptFactory.createPropertyAssignment(
|
|
72
72
|
"headers",
|
|
73
|
-
|
|
73
|
+
TypeScriptFactory.createObjectLiteralExpression(
|
|
74
74
|
[
|
|
75
|
-
|
|
75
|
+
TypeScriptFactory.createSpreadAssignment(
|
|
76
76
|
IdentifierFactory.access(
|
|
77
|
-
|
|
77
|
+
TypeScriptFactory.createIdentifier("connection"),
|
|
78
78
|
"headers",
|
|
79
79
|
),
|
|
80
80
|
),
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
TypeScriptFactory.createSpreadAssignment(
|
|
82
|
+
TypeScriptFactory.createCallExpression(
|
|
83
83
|
random,
|
|
84
84
|
[
|
|
85
85
|
project.config.clone === true
|
|
@@ -98,7 +98,7 @@ export namespace E2eFileProgrammer {
|
|
|
98
98
|
],
|
|
99
99
|
true,
|
|
100
100
|
)
|
|
101
|
-
:
|
|
101
|
+
: TypeScriptFactory.createIdentifier("connection");
|
|
102
102
|
const entries = SdkHttpParameterProgrammer.getEntries({
|
|
103
103
|
project,
|
|
104
104
|
importer,
|
|
@@ -107,8 +107,8 @@ export namespace E2eFileProgrammer {
|
|
|
107
107
|
e2e: true,
|
|
108
108
|
prefix: ["api", "functional", ...route.accessor].join(".") + ".",
|
|
109
109
|
});
|
|
110
|
-
const fetch =
|
|
111
|
-
|
|
110
|
+
const fetch = TypeScriptFactory.createCallExpression(
|
|
111
|
+
TypeScriptFactory.createIdentifier(
|
|
112
112
|
["api", "functional", ...route.accessor].join("."),
|
|
113
113
|
),
|
|
114
114
|
undefined,
|
|
@@ -120,14 +120,14 @@ export namespace E2eFileProgrammer {
|
|
|
120
120
|
Object.fromEntries(
|
|
121
121
|
entries.map((e) => [
|
|
122
122
|
e.key,
|
|
123
|
-
|
|
123
|
+
TypeScriptFactory.createCallExpression(
|
|
124
124
|
IdentifierFactory.access(
|
|
125
|
-
|
|
125
|
+
TypeScriptFactory.createIdentifier(
|
|
126
126
|
SdkImportWizard.typia(importer),
|
|
127
127
|
),
|
|
128
128
|
"random",
|
|
129
129
|
),
|
|
130
|
-
[e
|
|
130
|
+
[getRandomType(importer)(e)],
|
|
131
131
|
undefined,
|
|
132
132
|
),
|
|
133
133
|
]),
|
|
@@ -135,62 +135,99 @@ export namespace E2eFileProgrammer {
|
|
|
135
135
|
),
|
|
136
136
|
]
|
|
137
137
|
: entries.map((e) =>
|
|
138
|
-
|
|
138
|
+
TypeScriptFactory.createCallExpression(
|
|
139
139
|
IdentifierFactory.access(
|
|
140
|
-
|
|
140
|
+
TypeScriptFactory.createIdentifier(
|
|
141
141
|
SdkImportWizard.typia(importer),
|
|
142
142
|
),
|
|
143
143
|
"random",
|
|
144
144
|
),
|
|
145
|
-
[e
|
|
145
|
+
[getRandomType(importer)(e)],
|
|
146
146
|
undefined,
|
|
147
147
|
),
|
|
148
148
|
)),
|
|
149
149
|
],
|
|
150
150
|
);
|
|
151
|
-
const assert =
|
|
151
|
+
const assert = TypeScriptFactory.createCallExpression(
|
|
152
152
|
IdentifierFactory.access(
|
|
153
|
-
|
|
153
|
+
TypeScriptFactory.createIdentifier(SdkImportWizard.typia(importer)),
|
|
154
154
|
"assert",
|
|
155
155
|
),
|
|
156
156
|
undefined,
|
|
157
|
-
[
|
|
157
|
+
[TypeScriptFactory.createIdentifier("output")],
|
|
158
158
|
);
|
|
159
159
|
|
|
160
|
-
return
|
|
161
|
-
[
|
|
160
|
+
return TypeScriptFactory.createArrowFunction(
|
|
161
|
+
[TypeScriptFactory.createModifier(SyntaxKind.AsyncKeyword)],
|
|
162
162
|
undefined,
|
|
163
163
|
[
|
|
164
164
|
IdentifierFactory.parameter(
|
|
165
165
|
"connection",
|
|
166
|
-
|
|
166
|
+
TypeScriptFactory.createTypeReferenceNode("api.IConnection"),
|
|
167
167
|
),
|
|
168
168
|
],
|
|
169
169
|
undefined,
|
|
170
170
|
undefined,
|
|
171
|
-
|
|
172
|
-
|
|
171
|
+
TypeScriptFactory.createBlock([
|
|
172
|
+
TypeScriptFactory.createVariableStatement(
|
|
173
173
|
[],
|
|
174
|
-
|
|
174
|
+
TypeScriptFactory.createVariableDeclarationList(
|
|
175
175
|
[
|
|
176
|
-
|
|
176
|
+
TypeScriptFactory.createVariableDeclaration(
|
|
177
177
|
"output",
|
|
178
178
|
undefined,
|
|
179
179
|
project.config.propagate !== true &&
|
|
180
|
-
route.success.type
|
|
180
|
+
route.success.type!.name === "void"
|
|
181
181
|
? undefined
|
|
182
182
|
: SdkAliasCollection.response(project)(importer)(route),
|
|
183
|
-
|
|
183
|
+
TypeScriptFactory.createAwaitExpression(fetch),
|
|
184
184
|
),
|
|
185
185
|
],
|
|
186
|
-
|
|
186
|
+
NodeFlags.Const,
|
|
187
187
|
),
|
|
188
188
|
),
|
|
189
|
-
|
|
189
|
+
TypeScriptFactory.createExpressionStatement(assert),
|
|
190
190
|
]),
|
|
191
191
|
);
|
|
192
192
|
};
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
+
const getRandomType =
|
|
196
|
+
(importer: ImportDictionary) =>
|
|
197
|
+
(entry: SdkHttpParameterProgrammer.IEntry): Node => {
|
|
198
|
+
if (isPlainStringPathParameter(entry) === false) return entry.type;
|
|
199
|
+
return TypeScriptFactory.createIntersectionTypeNode([
|
|
200
|
+
entry.type,
|
|
201
|
+
TypeScriptFactory.createTypeReferenceNode(
|
|
202
|
+
TypeScriptFactory.createQualifiedName(
|
|
203
|
+
TypeScriptFactory.createIdentifier(
|
|
204
|
+
importer.external({
|
|
205
|
+
declaration: true,
|
|
206
|
+
file: "typia",
|
|
207
|
+
type: "element",
|
|
208
|
+
name: "tags",
|
|
209
|
+
}),
|
|
210
|
+
),
|
|
211
|
+
TypeScriptFactory.createIdentifier("MinLength"),
|
|
212
|
+
),
|
|
213
|
+
[
|
|
214
|
+
TypeScriptFactory.createLiteralTypeNode(
|
|
215
|
+
LiteralFactory.write(1) as Node,
|
|
216
|
+
),
|
|
217
|
+
],
|
|
218
|
+
),
|
|
219
|
+
]);
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
const isPlainStringPathParameter = (
|
|
223
|
+
entry: SdkHttpParameterProgrammer.IEntry,
|
|
224
|
+
): boolean =>
|
|
225
|
+
entry.parameter.category === "param" &&
|
|
226
|
+
entry.parameter.metadata.atomics.length === 1 &&
|
|
227
|
+
entry.parameter.metadata.atomics[0]!.type === "string" &&
|
|
228
|
+
entry.parameter.metadata.atomics[0]!.tags.every((row) =>
|
|
229
|
+
row.every((tag) => tag.kind !== "minLength"),
|
|
230
|
+
);
|
|
231
|
+
|
|
195
232
|
const getFunctionName = (route: ITypedHttpRoute): string =>
|
|
196
233
|
["test", "api", ...route.accessor].join("_");
|
|
@@ -1,55 +1,56 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Node,
|
|
3
|
+
SyntaxKind,
|
|
4
|
+
TypeScriptFactory,
|
|
5
|
+
TypeScriptPrinter,
|
|
6
|
+
} from "@nestia/factory";
|
|
1
7
|
import fs from "fs";
|
|
2
8
|
import { format } from "prettier";
|
|
3
|
-
import ts from "typescript";
|
|
4
9
|
|
|
5
10
|
export namespace FilePrinter {
|
|
6
|
-
export const description = <
|
|
7
|
-
node:
|
|
11
|
+
export const description = <T extends Node>(
|
|
12
|
+
node: T,
|
|
8
13
|
comment: string,
|
|
9
|
-
):
|
|
14
|
+
): T => {
|
|
10
15
|
if (comment.length === 0) return node;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
16
|
+
node.emitNode ??= {};
|
|
17
|
+
node.emitNode.leadingComments = [
|
|
18
|
+
...(node.emitNode.leadingComments ?? []),
|
|
19
|
+
{
|
|
20
|
+
kind: SyntaxKind.MultiLineCommentTrivia,
|
|
21
|
+
text: [
|
|
22
|
+
"*",
|
|
23
|
+
...comment
|
|
24
|
+
.split("\r\n")
|
|
25
|
+
.join("\n")
|
|
26
|
+
.split("\n")
|
|
27
|
+
.map(
|
|
28
|
+
(str) =>
|
|
29
|
+
` * ${str.split("*/").join("*\\\\/").split("*\\/").join("*\\\\/")}`,
|
|
30
|
+
),
|
|
31
|
+
"",
|
|
32
|
+
].join("\n"),
|
|
33
|
+
hasTrailingNewLine: true,
|
|
34
|
+
},
|
|
35
|
+
];
|
|
28
36
|
return node;
|
|
29
37
|
};
|
|
30
38
|
|
|
31
39
|
export const enter = () =>
|
|
32
|
-
|
|
40
|
+
TypeScriptFactory.createExpressionStatement(
|
|
41
|
+
TypeScriptFactory.createIdentifier("\n"),
|
|
42
|
+
);
|
|
33
43
|
|
|
34
44
|
export const write = async (props: {
|
|
35
45
|
location: string;
|
|
36
|
-
statements:
|
|
46
|
+
statements: Node[];
|
|
37
47
|
top?: string;
|
|
38
48
|
}): Promise<void> => {
|
|
39
|
-
const script: string =
|
|
40
|
-
.
|
|
41
|
-
.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
ts.factory.createToken(ts.SyntaxKind.EndOfFileToken),
|
|
45
|
-
ts.NodeFlags.None,
|
|
46
|
-
),
|
|
47
|
-
);
|
|
48
|
-
await fs.promises.writeFile(
|
|
49
|
-
props.location,
|
|
50
|
-
await beautify((props.top ?? "") + script),
|
|
51
|
-
"utf8",
|
|
52
|
-
);
|
|
49
|
+
const script: string = TypeScriptPrinter.write({
|
|
50
|
+
statements: props.statements,
|
|
51
|
+
top: props.top,
|
|
52
|
+
});
|
|
53
|
+
await fs.promises.writeFile(props.location, await beautify(script), "utf8");
|
|
53
54
|
};
|
|
54
55
|
|
|
55
56
|
const beautify = async (script: string): Promise<string> => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { Node, TypeScriptFactory } from "@nestia/factory";
|
|
1
2
|
import path from "path";
|
|
2
3
|
import { HashMap, TreeSet, hash } from "tstl";
|
|
3
|
-
import ts from "typescript";
|
|
4
4
|
|
|
5
5
|
import { ImportAnalyzer } from "../../analyses/ImportAnalyzer";
|
|
6
6
|
import { IReflectImport } from "../../structures/IReflectImport";
|
|
@@ -84,11 +84,11 @@ export class ImportDictionary {
|
|
|
84
84
|
return props.name;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
public toStatements(outDir: string):
|
|
87
|
+
public toStatements(outDir: string): Node[] {
|
|
88
88
|
outDir = path.resolve(outDir);
|
|
89
89
|
|
|
90
|
-
const external:
|
|
91
|
-
const internal:
|
|
90
|
+
const external: Node[] = [];
|
|
91
|
+
const internal: Node[] = [];
|
|
92
92
|
const locator = (str: string) => {
|
|
93
93
|
const location: string = path
|
|
94
94
|
.relative(outDir, str)
|
|
@@ -103,7 +103,7 @@ export class ImportDictionary {
|
|
|
103
103
|
};
|
|
104
104
|
const enroll =
|
|
105
105
|
(filter: (str: string) => boolean) =>
|
|
106
|
-
(container:
|
|
106
|
+
(container: Node[]) => {
|
|
107
107
|
const compositions: ICompositeValue[] = this.components_
|
|
108
108
|
.toJSON()
|
|
109
109
|
.filter((c) => filter(c.second.file))
|
|
@@ -117,10 +117,10 @@ export class ImportDictionary {
|
|
|
117
117
|
.sort((a, b) => a.file.localeCompare(b.file));
|
|
118
118
|
for (const c of compositions)
|
|
119
119
|
container.push(
|
|
120
|
-
|
|
120
|
+
TypeScriptFactory.createImportDeclaration(
|
|
121
121
|
undefined,
|
|
122
122
|
this.toImportClaude(c),
|
|
123
|
-
|
|
123
|
+
TypeScriptFactory.createStringLiteral(c.file),
|
|
124
124
|
undefined,
|
|
125
125
|
),
|
|
126
126
|
);
|
|
@@ -135,25 +135,27 @@ export class ImportDictionary {
|
|
|
135
135
|
];
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
private toImportClaude(c: ICompositeValue):
|
|
138
|
+
private toImportClaude(c: ICompositeValue): Node {
|
|
139
139
|
if (c.asterisk !== null)
|
|
140
|
-
return
|
|
140
|
+
return TypeScriptFactory.createImportClause(
|
|
141
141
|
c.declaration,
|
|
142
142
|
undefined,
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
TypeScriptFactory.createNamespaceImport(
|
|
144
|
+
TypeScriptFactory.createIdentifier(c.asterisk),
|
|
145
145
|
),
|
|
146
146
|
);
|
|
147
|
-
return
|
|
147
|
+
return TypeScriptFactory.createImportClause(
|
|
148
148
|
c.declaration,
|
|
149
|
-
c.default !== null
|
|
149
|
+
c.default !== null
|
|
150
|
+
? TypeScriptFactory.createIdentifier(c.default)
|
|
151
|
+
: undefined,
|
|
150
152
|
c.elements.size() !== 0
|
|
151
|
-
?
|
|
153
|
+
? TypeScriptFactory.createNamedImports(
|
|
152
154
|
Array.from(c.elements).map((elem) =>
|
|
153
|
-
|
|
155
|
+
TypeScriptFactory.createImportSpecifier(
|
|
154
156
|
false,
|
|
155
157
|
undefined,
|
|
156
|
-
|
|
158
|
+
TypeScriptFactory.createIdentifier(elem),
|
|
157
159
|
),
|
|
158
160
|
),
|
|
159
161
|
)
|