@nestia/sdk 3.10.0 → 3.11.0-dev.20240813
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/lib/NestiaSdkApplication.d.ts +1 -3
- package/lib/NestiaSdkApplication.js +138 -136
- package/lib/NestiaSdkApplication.js.map +1 -1
- package/lib/analyses/ConfigAnalyzer.d.ts +2 -2
- package/lib/analyses/ConfigAnalyzer.js +39 -80
- package/lib/analyses/ConfigAnalyzer.js.map +1 -1
- package/lib/analyses/ExceptionAnalyzer.d.ts +0 -16
- package/lib/analyses/ExceptionAnalyzer.js +142 -105
- package/lib/analyses/ExceptionAnalyzer.js.map +1 -1
- package/lib/analyses/GenericAnalyzer.d.ts +1 -2
- package/lib/analyses/GenericAnalyzer.js.map +1 -1
- package/lib/analyses/ImportAnalyzer.d.ts +6 -11
- package/lib/analyses/ImportAnalyzer.js +70 -42
- package/lib/analyses/ImportAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectControllerAnalyzer.d.ts +7 -1
- package/lib/analyses/ReflectControllerAnalyzer.js +28 -99
- package/lib/analyses/ReflectControllerAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationAnalyzer.d.ts +6 -2
- package/lib/analyses/ReflectHttpOperationAnalyzer.js +72 -152
- package/lib/analyses/ReflectHttpOperationAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationParameterAnalyzer.d.ts +15 -0
- package/lib/analyses/ReflectHttpOperationParameterAnalyzer.js +215 -0
- package/lib/analyses/ReflectHttpOperationParameterAnalyzer.js.map +1 -0
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.d.ts +15 -0
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.js +81 -0
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.js.map +1 -0
- package/lib/analyses/ReflectMetadataAnalyzer.d.ts +1 -3
- package/lib/analyses/ReflectMetadataAnalyzer.js +0 -4
- package/lib/analyses/ReflectMetadataAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectWebSocketOperationAnalyzer.d.ts +6 -2
- package/lib/analyses/ReflectWebSocketOperationAnalyzer.js +72 -48
- package/lib/analyses/ReflectWebSocketOperationAnalyzer.js.map +1 -1
- package/lib/analyses/TypedHttpRouteAnalyzer.d.ts +15 -0
- package/lib/analyses/TypedHttpRouteAnalyzer.js +111 -0
- package/lib/analyses/TypedHttpRouteAnalyzer.js.map +1 -0
- package/lib/analyses/TypedWebSocketRouteAnalyzer.d.ts +10 -0
- package/lib/analyses/TypedWebSocketRouteAnalyzer.js +9 -0
- package/lib/analyses/TypedWebSocketRouteAnalyzer.js.map +1 -0
- package/lib/decorators/OperationMetadata.d.ts +2 -0
- package/lib/decorators/OperationMetadata.js +10 -0
- package/lib/decorators/OperationMetadata.js.map +1 -0
- package/lib/executable/internal/NestiaConfigLoader.d.ts +1 -1
- package/lib/executable/internal/NestiaConfigLoader.js +34 -3
- package/lib/executable/internal/NestiaConfigLoader.js.map +1 -1
- package/lib/executable/internal/NestiaSdkCommand.js +1 -1
- package/lib/executable/internal/NestiaSdkCommand.js.map +1 -1
- package/lib/generates/CloneGenerator.d.ts +0 -5
- package/lib/generates/CloneGenerator.js +60 -60
- package/lib/generates/CloneGenerator.js.map +1 -1
- package/lib/generates/E2eGenerator.d.ts +2 -3
- package/lib/generates/E2eGenerator.js +9 -8
- package/lib/generates/E2eGenerator.js.map +1 -1
- package/lib/generates/OpenAiGenerator.d.ts +2 -4
- package/lib/generates/OpenAiGenerator.js +13 -3
- package/lib/generates/OpenAiGenerator.js.map +1 -1
- package/lib/generates/SdkGenerator.d.ts +4 -4
- package/lib/generates/SdkGenerator.js +63 -73
- package/lib/generates/SdkGenerator.js.map +1 -1
- package/lib/generates/SwaggerGenerator.d.ts +6 -18
- package/lib/generates/SwaggerGenerator.js +60 -235
- package/lib/generates/SwaggerGenerator.js.map +1 -1
- package/lib/generates/internal/E2eFileProgrammer.js +5 -9
- package/lib/generates/internal/E2eFileProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkAliasCollection.d.ts +6 -4
- package/lib/generates/internal/SdkAliasCollection.js +33 -31
- package/lib/generates/internal/SdkAliasCollection.js.map +1 -1
- package/lib/generates/internal/SdkDistributionComposer.d.ts +4 -1
- package/lib/generates/internal/SdkDistributionComposer.js +6 -6
- package/lib/generates/internal/SdkDistributionComposer.js.map +1 -1
- package/lib/generates/internal/SdkFileProgrammer.d.ts +2 -4
- package/lib/generates/internal/SdkFileProgrammer.js +6 -6
- package/lib/generates/internal/SdkFileProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpCloneProgrammer.d.ts +0 -12
- package/lib/generates/internal/SdkHttpCloneProgrammer.js +142 -97
- package/lib/generates/internal/SdkHttpCloneProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpFunctionProgrammer.d.ts +4 -3
- package/lib/generates/internal/SdkHttpFunctionProgrammer.js +37 -59
- package/lib/generates/internal/SdkHttpFunctionProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.d.ts +4 -3
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.js +31 -48
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpRouteProgrammer.js +7 -3
- package/lib/generates/internal/SdkHttpRouteProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpSimulationProgrammer.d.ts +4 -3
- package/lib/generates/internal/SdkHttpSimulationProgrammer.js +7 -13
- package/lib/generates/internal/SdkHttpSimulationProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.d.ts +1 -2
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js +11 -16
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.d.ts +1 -2
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.js +7 -10
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.js.map +1 -1
- package/lib/generates/internal/SwaggerDescriptionComposer.d.ts +23 -0
- package/lib/generates/internal/SwaggerDescriptionComposer.js +44 -0
- package/lib/generates/internal/SwaggerDescriptionComposer.js.map +1 -0
- package/lib/generates/internal/SwaggerOperationComposer.d.ts +12 -0
- package/lib/generates/internal/SwaggerOperationComposer.js +68 -0
- package/lib/generates/internal/SwaggerOperationComposer.js.map +1 -0
- package/lib/generates/internal/SwaggerOperationParameterComposer.d.ts +18 -0
- package/lib/generates/internal/SwaggerOperationParameterComposer.js +99 -0
- package/lib/generates/internal/SwaggerOperationParameterComposer.js.map +1 -0
- package/lib/generates/internal/SwaggerOperationResponseComposer.d.ts +9 -0
- package/lib/generates/internal/SwaggerOperationResponseComposer.js +91 -0
- package/lib/generates/internal/SwaggerOperationResponseComposer.js.map +1 -0
- package/lib/structures/INestiaProject.d.ts +5 -5
- package/lib/structures/INestiaSdkInput.d.ts +20 -0
- package/lib/structures/{ISwaggerError.js → INestiaSdkInput.js} +1 -1
- package/lib/structures/INestiaSdkInput.js.map +1 -0
- package/lib/structures/IReflectApplication.d.ts +6 -0
- package/lib/structures/IReflectApplication.js +3 -0
- package/lib/structures/IReflectApplication.js.map +1 -0
- package/lib/structures/IReflectController.d.ts +3 -5
- package/lib/structures/IReflectHttpOperation.d.ts +13 -65
- package/lib/structures/IReflectHttpOperationException.d.ts +14 -0
- package/lib/structures/IReflectHttpOperationException.js +3 -0
- package/lib/structures/IReflectHttpOperationException.js.map +1 -0
- package/lib/structures/IReflectHttpOperationParameter.d.ts +35 -0
- package/lib/structures/IReflectHttpOperationParameter.js +3 -0
- package/lib/structures/IReflectHttpOperationParameter.js.map +1 -0
- package/lib/structures/IReflectHttpOperationSuccess.d.ts +15 -0
- package/lib/structures/IReflectHttpOperationSuccess.js +3 -0
- package/lib/structures/IReflectHttpOperationSuccess.js.map +1 -0
- package/lib/structures/IReflectOperationError.d.ts +16 -0
- package/lib/structures/IReflectOperationError.js +23 -0
- package/lib/structures/IReflectOperationError.js.map +1 -0
- package/lib/structures/IReflectType.d.ts +4 -0
- package/lib/structures/{IErrorReport.js → IReflectType.js} +1 -1
- package/lib/structures/IReflectType.js.map +1 -0
- package/lib/structures/IReflectTypeImport.d.ts +4 -0
- package/lib/structures/{ISwaggerLazySchema.js → IReflectTypeImport.js} +1 -1
- package/lib/structures/IReflectTypeImport.js.map +1 -0
- package/lib/structures/IReflectWebSocketOperation.d.ts +8 -9
- package/lib/structures/IReflectWebSocketOperationParameter.d.ts +23 -0
- package/lib/structures/IReflectWebSocketOperationParameter.js +3 -0
- package/lib/structures/IReflectWebSocketOperationParameter.js.map +1 -0
- package/lib/structures/ITypedApplication.d.ts +7 -0
- package/lib/structures/{INormalizedInput.js → ITypedApplication.js} +1 -1
- package/lib/structures/ITypedApplication.js.map +1 -0
- package/lib/structures/ITypedHttpRoute.d.ts +14 -42
- package/lib/structures/ITypedHttpRouteException.d.ts +10 -0
- package/lib/structures/ITypedHttpRouteException.js +3 -0
- package/lib/structures/ITypedHttpRouteException.js.map +1 -0
- package/lib/structures/ITypedHttpRouteParameter.d.ts +31 -0
- package/lib/structures/ITypedHttpRouteParameter.js +3 -0
- package/lib/structures/ITypedHttpRouteParameter.js.map +1 -0
- package/lib/structures/ITypedHttpRouteSuccess.d.ts +19 -0
- package/lib/structures/{ISwaggerLazyProperty.js → ITypedHttpRouteSuccess.js} +1 -1
- package/lib/structures/ITypedHttpRouteSuccess.js.map +1 -0
- package/lib/structures/ITypedWebSocketRoute.d.ts +8 -44
- package/lib/structures/ITypedWebSocketRouteParameter.d.ts +2 -0
- package/lib/structures/ITypedWebSocketRouteParameter.js +3 -0
- package/lib/structures/ITypedWebSocketRouteParameter.js.map +1 -0
- package/lib/transform.d.ts +3 -0
- package/lib/transform.js +8 -0
- package/lib/transform.js.map +1 -0
- package/lib/transformers/IOperationMetadata.d.ts +36 -0
- package/lib/transformers/IOperationMetadata.js +3 -0
- package/lib/transformers/IOperationMetadata.js.map +1 -0
- package/lib/transformers/ISdkTransformerContext.d.ts +7 -0
- package/lib/transformers/ISdkTransformerContext.js +3 -0
- package/lib/transformers/ISdkTransformerContext.js.map +1 -0
- package/lib/transformers/SdkMetadataProgrammer.d.ts +11 -0
- package/lib/transformers/SdkMetadataProgrammer.js +159 -0
- package/lib/transformers/SdkMetadataProgrammer.js.map +1 -0
- package/lib/transformers/SdkTransformer.d.ts +4 -0
- package/lib/transformers/SdkTransformer.js +88 -0
- package/lib/transformers/SdkTransformer.js.map +1 -0
- package/lib/transformers/TextPlainValidator.d.ts +4 -0
- package/lib/transformers/TextPlainValidator.js +19 -0
- package/lib/transformers/TextPlainValidator.js.map +1 -0
- package/lib/utils/StringUtil.d.ts +1 -0
- package/lib/utils/StringUtil.js +1 -0
- package/lib/utils/StringUtil.js.map +1 -1
- package/package.json +8 -8
- package/src/NestiaSdkApplication.ts +173 -160
- package/src/analyses/ConfigAnalyzer.ts +50 -98
- package/src/analyses/ExceptionAnalyzer.ts +142 -142
- package/src/analyses/GenericAnalyzer.ts +3 -5
- package/src/analyses/ImportAnalyzer.ts +130 -115
- package/src/analyses/ReflectControllerAnalyzer.ts +63 -115
- package/src/analyses/ReflectHttpOperationAnalyzer.ts +142 -278
- package/src/analyses/ReflectHttpOperationParameterAnalyzer.ts +319 -0
- package/src/analyses/ReflectHttpOperationResponseAnalyzer.ts +117 -0
- package/src/analyses/ReflectMetadataAnalyzer.ts +1 -18
- package/src/analyses/ReflectWebSocketOperationAnalyzer.ts +143 -78
- package/src/analyses/TypedHttpRouteAnalyzer.ts +178 -0
- package/src/analyses/TypedWebSocketRouteAnalyzer.ts +18 -0
- package/src/decorators/OperationMetadata.ts +15 -0
- package/src/executable/internal/NestiaConfigLoader.ts +18 -3
- package/src/executable/internal/NestiaSdkCommand.ts +1 -4
- package/src/generates/CloneGenerator.ts +60 -59
- package/src/generates/E2eGenerator.ts +20 -21
- package/src/generates/OpenAiGenerator.ts +44 -45
- package/src/generates/SdkGenerator.ts +97 -125
- package/src/generates/SwaggerGenerator.ts +114 -416
- package/src/generates/internal/E2eFileProgrammer.ts +5 -14
- package/src/generates/internal/SdkAliasCollection.ts +33 -41
- package/src/generates/internal/SdkDistributionComposer.ts +9 -6
- package/src/generates/internal/SdkFileProgrammer.ts +11 -14
- package/src/generates/internal/SdkHttpCloneProgrammer.ts +142 -142
- package/src/generates/internal/SdkHttpFunctionProgrammer.ts +20 -47
- package/src/generates/internal/SdkHttpNamespaceProgrammer.ts +245 -275
- package/src/generates/internal/SdkHttpRouteProgrammer.ts +7 -7
- package/src/generates/internal/SdkHttpSimulationProgrammer.ts +11 -23
- package/src/generates/internal/SdkWebSocketNamespaceProgrammer.ts +197 -233
- package/src/generates/internal/SdkWebSocketRouteProgrammer.ts +5 -15
- package/src/generates/internal/{SwaggerDescriptionGenerator.ts → SwaggerDescriptionComposer.ts} +25 -5
- package/src/generates/internal/SwaggerOperationComposer.ts +90 -0
- package/src/generates/internal/SwaggerOperationParameterComposer.ts +173 -0
- package/src/generates/internal/SwaggerOperationResponseComposer.ts +110 -0
- package/src/structures/INestiaProject.ts +5 -5
- package/src/structures/INestiaSdkInput.ts +25 -0
- package/src/structures/IReflectApplication.ts +8 -0
- package/src/structures/IReflectController.ts +3 -5
- package/src/structures/IReflectHttpOperation.ts +14 -76
- package/src/structures/IReflectHttpOperationException.ts +19 -0
- package/src/structures/IReflectHttpOperationParameter.ts +81 -0
- package/src/structures/IReflectHttpOperationSuccess.ts +22 -0
- package/src/structures/IReflectOperationError.ts +26 -0
- package/src/structures/IReflectType.ts +4 -0
- package/src/structures/IReflectTypeImport.ts +4 -0
- package/src/structures/IReflectWebSocketOperation.ts +9 -9
- package/src/structures/IReflectWebSocketOperationParameter.ts +38 -0
- package/src/structures/ITypedApplication.ts +8 -0
- package/src/structures/ITypedHttpRoute.ts +15 -45
- package/src/structures/ITypedHttpRouteException.ts +15 -0
- package/src/structures/ITypedHttpRouteParameter.ts +41 -0
- package/src/structures/ITypedHttpRouteSuccess.ts +22 -0
- package/src/structures/ITypedWebSocketRoute.ts +8 -56
- package/src/structures/ITypedWebSocketRouteParameter.ts +3 -0
- package/src/transform.ts +9 -0
- package/src/transformers/IOperationMetadata.ts +38 -0
- package/src/transformers/ISdkTransformerContext.ts +8 -0
- package/src/transformers/SdkMetadataProgrammer.ts +227 -0
- package/src/transformers/SdkTransformer.ts +168 -0
- package/src/transformers/TextPlainValidator.ts +17 -0
- package/src/utils/StringUtil.ts +3 -0
- package/lib/analyses/TypedControllerAnalyzer.d.ts +0 -8
- package/lib/analyses/TypedControllerAnalyzer.js +0 -77
- package/lib/analyses/TypedControllerAnalyzer.js.map +0 -1
- package/lib/analyses/TypedHttpOperationAnalyzer.d.ts +0 -15
- package/lib/analyses/TypedHttpOperationAnalyzer.js +0 -263
- package/lib/analyses/TypedHttpOperationAnalyzer.js.map +0 -1
- package/lib/analyses/TypedWebSocketOperationAnalyzer.d.ts +0 -15
- package/lib/analyses/TypedWebSocketOperationAnalyzer.js +0 -226
- package/lib/analyses/TypedWebSocketOperationAnalyzer.js.map +0 -1
- package/lib/generates/internal/SwaggerDescriptionGenerator.d.ts +0 -14
- package/lib/generates/internal/SwaggerDescriptionGenerator.js +0 -33
- package/lib/generates/internal/SwaggerDescriptionGenerator.js.map +0 -1
- package/lib/generates/internal/SwaggerSchemaGenerator.d.ts +0 -21
- package/lib/generates/internal/SwaggerSchemaGenerator.js +0 -289
- package/lib/generates/internal/SwaggerSchemaGenerator.js.map +0 -1
- package/lib/generates/internal/SwaggerSchemaValidator.d.ts +0 -7
- package/lib/generates/internal/SwaggerSchemaValidator.js +0 -191
- package/lib/generates/internal/SwaggerSchemaValidator.js.map +0 -1
- package/lib/structures/IErrorReport.d.ts +0 -6
- package/lib/structures/IErrorReport.js.map +0 -1
- package/lib/structures/INormalizedInput.d.ts +0 -19
- package/lib/structures/INormalizedInput.js.map +0 -1
- package/lib/structures/ISwaggerError.d.ts +0 -6
- package/lib/structures/ISwaggerError.js.map +0 -1
- package/lib/structures/ISwaggerLazyProperty.d.ts +0 -6
- package/lib/structures/ISwaggerLazyProperty.js.map +0 -1
- package/lib/structures/ISwaggerLazySchema.d.ts +0 -6
- package/lib/structures/ISwaggerLazySchema.js.map +0 -1
- package/lib/structures/ITypeTuple.d.ts +0 -5
- package/lib/structures/ITypeTuple.js +0 -3
- package/lib/structures/ITypeTuple.js.map +0 -1
- package/src/analyses/TypedControllerAnalyzer.ts +0 -92
- package/src/analyses/TypedHttpOperationAnalyzer.ts +0 -365
- package/src/analyses/TypedWebSocketOperationAnalyzer.ts +0 -375
- package/src/generates/internal/SwaggerSchemaGenerator.ts +0 -473
- package/src/generates/internal/SwaggerSchemaValidator.ts +0 -206
- package/src/structures/IErrorReport.ts +0 -6
- package/src/structures/INormalizedInput.ts +0 -20
- package/src/structures/ISwaggerError.ts +0 -8
- package/src/structures/ISwaggerLazyProperty.ts +0 -7
- package/src/structures/ISwaggerLazySchema.ts +0 -7
- package/src/structures/ITypeTuple.ts +0 -6
|
@@ -1,154 +1,154 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import ts from "typescript";
|
|
3
|
-
import { MetadataCollection } from "typia/lib/factories/MetadataCollection";
|
|
4
|
-
import { MetadataFactory } from "typia/lib/factories/MetadataFactory";
|
|
5
|
-
import { Metadata } from "typia/lib/schemas/metadata/Metadata";
|
|
1
|
+
// import path from "path";
|
|
2
|
+
// import ts from "typescript";
|
|
3
|
+
// import { MetadataCollection } from "typia/lib/factories/MetadataCollection";
|
|
4
|
+
// import { MetadataFactory } from "typia/lib/factories/MetadataFactory";
|
|
5
|
+
// import { Metadata } from "typia/lib/schemas/metadata/Metadata";
|
|
6
6
|
|
|
7
|
-
import { INestiaProject } from "../structures/INestiaProject";
|
|
8
|
-
import { IReflectController } from "../structures/IReflectController";
|
|
9
|
-
import { IReflectHttpOperation } from "../structures/IReflectHttpOperation";
|
|
10
|
-
import { ITypeTuple } from "../structures/ITypeTuple";
|
|
11
|
-
import { ITypedHttpRoute } from "../structures/ITypedHttpRoute";
|
|
12
|
-
import { GenericAnalyzer } from "./GenericAnalyzer";
|
|
13
|
-
import { ImportAnalyzer } from "./ImportAnalyzer";
|
|
7
|
+
// import { INestiaProject } from "../structures/INestiaProject";
|
|
8
|
+
// import { IReflectController } from "../structures/IReflectController";
|
|
9
|
+
// import { IReflectHttpOperation } from "../structures/IReflectHttpOperation";
|
|
10
|
+
// import { ITypeTuple } from "../structures/ITypeTuple";
|
|
11
|
+
// import { ITypedHttpRoute } from "../structures/ITypedHttpRoute";
|
|
12
|
+
// import { GenericAnalyzer } from "./GenericAnalyzer";
|
|
13
|
+
// import { ImportAnalyzer } from "./ImportAnalyzer";
|
|
14
14
|
|
|
15
|
-
export namespace ExceptionAnalyzer {
|
|
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
|
-
|
|
15
|
+
// export namespace ExceptionAnalyzer {
|
|
16
|
+
// export const analyze =
|
|
17
|
+
// (project: INestiaProject) =>
|
|
18
|
+
// (props: {
|
|
19
|
+
// generics: GenericAnalyzer.Dictionary;
|
|
20
|
+
// imports: ImportAnalyzer.Dictionary;
|
|
21
|
+
// controller: IReflectController;
|
|
22
|
+
// operation: IReflectHttpOperation;
|
|
23
|
+
// declaration: ts.MethodDeclaration;
|
|
24
|
+
// }): Record<
|
|
25
|
+
// number | "2XX" | "3XX" | "4XX" | "5XX",
|
|
26
|
+
// ITypedHttpRoute.IOutput
|
|
27
|
+
// > => {
|
|
28
|
+
// const output: Record<
|
|
29
|
+
// number | "2XX" | "3XX" | "4XX" | "5XX",
|
|
30
|
+
// ITypedHttpRoute.IOutput
|
|
31
|
+
// > = {} as any;
|
|
32
|
+
// for (const decorator of props.declaration.modifiers ?? [])
|
|
33
|
+
// if (ts.isDecorator(decorator))
|
|
34
|
+
// analyzeTyped(project)({
|
|
35
|
+
// ...props,
|
|
36
|
+
// output,
|
|
37
|
+
// decorator,
|
|
38
|
+
// });
|
|
39
|
+
// return output;
|
|
40
|
+
// };
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
42
|
+
// const analyzeTyped =
|
|
43
|
+
// (project: INestiaProject) =>
|
|
44
|
+
// (props: {
|
|
45
|
+
// generics: GenericAnalyzer.Dictionary;
|
|
46
|
+
// imports: ImportAnalyzer.Dictionary;
|
|
47
|
+
// controller: IReflectController;
|
|
48
|
+
// operation: IReflectHttpOperation;
|
|
49
|
+
// output: Record<
|
|
50
|
+
// number | "2XX" | "3XX" | "4XX" | "5XX",
|
|
51
|
+
// ITypedHttpRoute.IOutput
|
|
52
|
+
// >;
|
|
53
|
+
// decorator: ts.Decorator;
|
|
54
|
+
// }): boolean => {
|
|
55
|
+
// // CHECK DECORATOR
|
|
56
|
+
// if (!ts.isCallExpression(props.decorator.expression)) return false;
|
|
57
|
+
// else if ((props.decorator.expression.typeArguments ?? []).length !== 1)
|
|
58
|
+
// return false;
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
60
|
+
// // CHECK SIGNATURE
|
|
61
|
+
// const signature: ts.Signature | undefined =
|
|
62
|
+
// project.checker.getResolvedSignature(props.decorator.expression);
|
|
63
|
+
// if (!signature || !signature.declaration) return false;
|
|
64
|
+
// else if (
|
|
65
|
+
// path
|
|
66
|
+
// .resolve(signature.declaration.getSourceFile().fileName)
|
|
67
|
+
// .indexOf(TYPED_EXCEPTION_PATH) === -1
|
|
68
|
+
// )
|
|
69
|
+
// return false;
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
// // GET TYPE INFO
|
|
72
|
+
// const status: string | null = getStatus(project.checker)(
|
|
73
|
+
// props.decorator.expression.arguments[0] ?? null,
|
|
74
|
+
// );
|
|
75
|
+
// if (status === null) return false;
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
77
|
+
// const node: ts.TypeNode = props.decorator.expression.typeArguments![0];
|
|
78
|
+
// const type: ts.Type = project.checker.getTypeFromTypeNode(node);
|
|
79
|
+
// if (type.isTypeParameter()) {
|
|
80
|
+
// project.errors.push({
|
|
81
|
+
// file: props.controller.file,
|
|
82
|
+
// controller: props.controller.name,
|
|
83
|
+
// function: props.operation.name,
|
|
84
|
+
// message: "TypedException() without generic argument specification.",
|
|
85
|
+
// });
|
|
86
|
+
// return false;
|
|
87
|
+
// }
|
|
88
88
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
89
|
+
// const tuple: ITypeTuple | null = ImportAnalyzer.analyze(project.checker)({
|
|
90
|
+
// generics: props.generics,
|
|
91
|
+
// imports: props.imports,
|
|
92
|
+
// type,
|
|
93
|
+
// });
|
|
94
|
+
// if (tuple === null) {
|
|
95
|
+
// project.errors.push({
|
|
96
|
+
// file: props.controller.file,
|
|
97
|
+
// controller: props.controller.name,
|
|
98
|
+
// function: props.operation.name,
|
|
99
|
+
// message: `TypeException() with unknown type on ${status} status.`,
|
|
100
|
+
// });
|
|
101
|
+
// return false;
|
|
102
|
+
// }
|
|
103
103
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
104
|
+
// // DO ASSIGN
|
|
105
|
+
// const matched: IReflectHttpOperation.IException[] = Object.entries(
|
|
106
|
+
// props.operation.exceptions,
|
|
107
|
+
// )
|
|
108
|
+
// .filter(([key]) => status === key)
|
|
109
|
+
// .map(([_key, value]) => value);
|
|
110
|
+
// for (const m of matched)
|
|
111
|
+
// props.output[m.status] = {
|
|
112
|
+
// type: tuple.type,
|
|
113
|
+
// typeName: tuple.typeName,
|
|
114
|
+
// contentType: "application/json",
|
|
115
|
+
// description: m.description,
|
|
116
|
+
// };
|
|
117
|
+
// return true;
|
|
118
|
+
// };
|
|
119
119
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
120
|
+
// const getStatus =
|
|
121
|
+
// (checker: ts.TypeChecker) =>
|
|
122
|
+
// (expression: ts.Expression | null): string | null => {
|
|
123
|
+
// if (expression === null) return null;
|
|
124
124
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
125
|
+
// const type: ts.Type = checker.getTypeAtLocation(expression);
|
|
126
|
+
// const result = MetadataFactory.analyze(checker)({
|
|
127
|
+
// escape: true,
|
|
128
|
+
// constant: true,
|
|
129
|
+
// absorb: true,
|
|
130
|
+
// })(new MetadataCollection())(type);
|
|
131
|
+
// if (false === result.success) return null;
|
|
132
132
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
133
|
+
// const meta: Metadata = result.data;
|
|
134
|
+
// if (meta.constants.length === 1)
|
|
135
|
+
// return meta.constants[0].values[0].value.toString();
|
|
136
|
+
// else if (meta.escaped && meta.escaped.returns.constants.length === 1)
|
|
137
|
+
// return meta.escaped.returns.constants[0].values[0].value.toString();
|
|
138
|
+
// else if (ts.isStringLiteral(expression)) return expression.text;
|
|
139
|
+
// else if (ts.isNumericLiteral(expression)) {
|
|
140
|
+
// const value: number = Number(expression.text.split("_").join(""));
|
|
141
|
+
// if (false === isNaN(value)) return value.toString();
|
|
142
|
+
// }
|
|
143
|
+
// return null;
|
|
144
|
+
// };
|
|
145
|
+
// }
|
|
146
146
|
|
|
147
|
-
const TYPED_EXCEPTION_PATH = path.join(
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
);
|
|
147
|
+
// const TYPED_EXCEPTION_PATH = path.join(
|
|
148
|
+
// "node_modules",
|
|
149
|
+
// "@nestia",
|
|
150
|
+
// "core",
|
|
151
|
+
// "lib",
|
|
152
|
+
// "decorators",
|
|
153
|
+
// "TypedException.d.ts",
|
|
154
|
+
// );
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
2
|
|
|
3
3
|
export namespace GenericAnalyzer {
|
|
4
|
-
export type Dictionary = WeakMap<ts.Type, ts.Type>;
|
|
5
|
-
|
|
6
4
|
export function analyze(
|
|
7
5
|
checker: ts.TypeChecker,
|
|
8
6
|
classNode: ts.ClassDeclaration,
|
|
9
|
-
):
|
|
10
|
-
const dict:
|
|
7
|
+
): WeakMap<ts.Type, ts.Type> {
|
|
8
|
+
const dict: WeakMap<ts.Type, ts.Type> = new WeakMap();
|
|
11
9
|
explore(checker, dict, classNode);
|
|
12
10
|
return dict;
|
|
13
11
|
}
|
|
14
12
|
|
|
15
13
|
function explore(
|
|
16
14
|
checker: ts.TypeChecker,
|
|
17
|
-
dict:
|
|
15
|
+
dict: WeakMap<ts.Type, ts.Type>,
|
|
18
16
|
classNode: ts.ClassDeclaration,
|
|
19
17
|
): void {
|
|
20
18
|
if (classNode.heritageClauses === undefined) return;
|
|
@@ -1,57 +1,61 @@
|
|
|
1
|
-
import { HashMap, HashSet } from "tstl";
|
|
2
1
|
import ts from "typescript";
|
|
3
2
|
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { IReflectType } from "../structures/IReflectType";
|
|
4
|
+
import { IReflectTypeImport } from "../structures/IReflectTypeImport";
|
|
5
|
+
import { MapUtil } from "../utils/MapUtil";
|
|
6
6
|
|
|
7
7
|
export namespace ImportAnalyzer {
|
|
8
8
|
export interface IOutput {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
imports: IReflectTypeImport[];
|
|
10
|
+
type: IReflectType | null;
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
type,
|
|
26
|
-
});
|
|
27
|
-
try {
|
|
28
|
-
return {
|
|
12
|
+
export const analyze = (
|
|
13
|
+
checker: ts.TypeChecker,
|
|
14
|
+
generics: WeakMap<ts.Type, ts.Type>,
|
|
15
|
+
type: ts.Type,
|
|
16
|
+
): IOutput => {
|
|
17
|
+
const imports: Map<string, Set<string>> = new Map();
|
|
18
|
+
try {
|
|
19
|
+
type = escape(checker, type);
|
|
20
|
+
return {
|
|
21
|
+
type: explore({
|
|
22
|
+
checker,
|
|
23
|
+
generics,
|
|
24
|
+
imports,
|
|
29
25
|
type,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
26
|
+
}),
|
|
27
|
+
imports: [...imports].map(([file, instances]) => ({
|
|
28
|
+
file,
|
|
29
|
+
instances: Array.from(instances),
|
|
30
|
+
})),
|
|
31
|
+
};
|
|
32
|
+
} catch {
|
|
33
|
+
return {
|
|
34
|
+
imports: [],
|
|
35
|
+
type: null,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
40
|
+
export const unique = (
|
|
41
|
+
imports: IReflectTypeImport[],
|
|
42
|
+
): IReflectTypeImport[] => {
|
|
43
|
+
const map: Map<string, Set<string>> = new Map();
|
|
44
|
+
imports.forEach(({ file, instances }) => {
|
|
45
|
+
const set: Set<string> = MapUtil.take(map, file, () => new Set());
|
|
46
|
+
instances.forEach((instance) => set.add(instance));
|
|
47
|
+
});
|
|
48
|
+
return [...map].map(([file, instances]) => ({
|
|
49
|
+
file,
|
|
50
|
+
instances: Array.from(instances),
|
|
51
|
+
}));
|
|
52
|
+
};
|
|
51
53
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
/* ---------------------------------------------------------
|
|
55
|
+
TYPE
|
|
56
|
+
--------------------------------------------------------- */
|
|
57
|
+
const escape = (checker: ts.TypeChecker, type: ts.Type): ts.Type => {
|
|
58
|
+
if (type.symbol && getNameOfSymbol(type.symbol) === "Promise") {
|
|
55
59
|
const generic: readonly ts.Type[] = checker.getTypeArguments(
|
|
56
60
|
type as ts.TypeReference,
|
|
57
61
|
);
|
|
@@ -59,98 +63,109 @@ export namespace ImportAnalyzer {
|
|
|
59
63
|
throw new Error(
|
|
60
64
|
"Error on ImportAnalyzer.analyze(): invalid promise type.",
|
|
61
65
|
);
|
|
62
|
-
|
|
63
|
-
}
|
|
66
|
+
type = generic[0];
|
|
67
|
+
}
|
|
68
|
+
return type;
|
|
69
|
+
};
|
|
64
70
|
|
|
65
|
-
const
|
|
66
|
-
|
|
71
|
+
const getNameOfSymbol = (symbol: ts.Symbol): string =>
|
|
72
|
+
exploreName(
|
|
67
73
|
symbol.escapedName.toString(),
|
|
68
74
|
symbol.getDeclarations()?.[0]?.parent,
|
|
69
75
|
);
|
|
70
76
|
|
|
71
77
|
/* ---------------------------------------------------------
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
while (props.generics.has(type) === true)
|
|
87
|
-
type = props.generics.get(type)!;
|
|
78
|
+
ESCAPED TEXT WITH IMPORT STATEMENTS
|
|
79
|
+
--------------------------------------------------------- */
|
|
80
|
+
const explore = (props: {
|
|
81
|
+
checker: ts.TypeChecker;
|
|
82
|
+
generics: WeakMap<ts.Type, ts.Type>;
|
|
83
|
+
imports: Map<string, Set<string>>;
|
|
84
|
+
type: ts.Type;
|
|
85
|
+
}): IReflectType => {
|
|
86
|
+
//----
|
|
87
|
+
// CONDITIONAL BRANCHES
|
|
88
|
+
//----
|
|
89
|
+
// DECOMPOSE GENERIC ARGUMENT
|
|
90
|
+
let type: ts.Type = props.type;
|
|
91
|
+
while (props.generics.has(type) === true) type = props.generics.get(type)!;
|
|
88
92
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
type.aliasSymbol ?? type.getSymbol();
|
|
93
|
+
// PRIMITIVE
|
|
94
|
+
const symbol: ts.Symbol | undefined = type.aliasSymbol ?? type.symbol;
|
|
92
95
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
// UNION OR INTERSECT
|
|
97
|
+
if (type.aliasSymbol === undefined && type.isUnionOrIntersection()) {
|
|
98
|
+
const joiner: string = type.isIntersection() ? " & " : " | ";
|
|
99
|
+
return {
|
|
100
|
+
name: type.types
|
|
97
101
|
.map((child) =>
|
|
98
|
-
|
|
102
|
+
explore({
|
|
99
103
|
...props,
|
|
100
104
|
type: child,
|
|
101
105
|
}),
|
|
102
106
|
)
|
|
103
|
-
.
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
.map(getEscapedText)
|
|
108
|
+
.join(joiner),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
// NO SYMBOL
|
|
112
|
+
else if (symbol === undefined)
|
|
113
|
+
return {
|
|
114
|
+
name: props.checker.typeToString(
|
|
108
115
|
type,
|
|
109
116
|
undefined,
|
|
110
117
|
ts.TypeFormatFlags.NoTruncation,
|
|
111
|
-
)
|
|
118
|
+
),
|
|
119
|
+
};
|
|
112
120
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
)
|
|
125
|
-
|
|
126
|
-
|
|
121
|
+
//----
|
|
122
|
+
// SPECIALIZATION
|
|
123
|
+
//----
|
|
124
|
+
const name: string = getNameOfSymbol(symbol);
|
|
125
|
+
const sourceFile: ts.SourceFile | undefined =
|
|
126
|
+
symbol.declarations?.[0]?.getSourceFile();
|
|
127
|
+
if (sourceFile === undefined) return { name };
|
|
128
|
+
else if (sourceFile.fileName.indexOf("typescript/lib") === -1) {
|
|
129
|
+
const set: Set<string> = MapUtil.take(
|
|
130
|
+
props.imports,
|
|
131
|
+
sourceFile.fileName,
|
|
132
|
+
() => new Set(),
|
|
133
|
+
);
|
|
134
|
+
set.add(name.split(".")[0]);
|
|
135
|
+
}
|
|
127
136
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
)
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
137
|
+
// CHECK GENERIC
|
|
138
|
+
const generic: readonly ts.Type[] = type.aliasSymbol
|
|
139
|
+
? type.aliasTypeArguments ?? []
|
|
140
|
+
: props.checker.getTypeArguments(type as ts.TypeReference);
|
|
141
|
+
return generic.length
|
|
142
|
+
? name === "Promise"
|
|
143
|
+
? explore({
|
|
144
|
+
...props,
|
|
145
|
+
type: generic[0],
|
|
146
|
+
})
|
|
147
|
+
: {
|
|
148
|
+
name,
|
|
149
|
+
typeArguments: generic.map((child) =>
|
|
150
|
+
explore({
|
|
151
|
+
...props,
|
|
152
|
+
type: child,
|
|
153
|
+
}),
|
|
154
|
+
),
|
|
155
|
+
}
|
|
156
|
+
: { name };
|
|
157
|
+
};
|
|
148
158
|
|
|
149
|
-
const
|
|
159
|
+
const exploreName = (name: string, decl?: ts.Node): string =>
|
|
150
160
|
decl && ts.isModuleBlock(decl)
|
|
151
|
-
?
|
|
161
|
+
? exploreName(
|
|
152
162
|
`${decl.parent.name.getFullText().trim()}.${name}`,
|
|
153
163
|
decl.parent.parent,
|
|
154
164
|
)
|
|
155
165
|
: name;
|
|
166
|
+
|
|
167
|
+
const getEscapedText = (type: IReflectType): string =>
|
|
168
|
+
type.typeArguments
|
|
169
|
+
? `${type.name}<${type.typeArguments.map(getEscapedText).join(", ")}>`
|
|
170
|
+
: type.name;
|
|
156
171
|
}
|