@nestia/sdk 11.2.0 → 12.0.0-dev.20260520.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 +1 -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 -792
- 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 +9 -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/package.json +21 -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 +1 -1
- package/src/executable/internal/NestiaConfigLoader.ts +419 -52
- 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 +68 -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,240 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CommentFactory,
|
|
3
|
-
MetadataCollection,
|
|
4
|
-
MetadataFactory,
|
|
5
|
-
MetadataObjectType,
|
|
6
|
-
MetadataSchema,
|
|
7
|
-
TypeFactory,
|
|
8
|
-
} from "@typia/core";
|
|
9
|
-
import { ValidationPipe } from "@typia/interface";
|
|
10
|
-
import { NamingConvention } from "@typia/utils";
|
|
11
|
-
import { Singleton } from "tstl";
|
|
12
|
-
import ts from "typescript";
|
|
13
|
-
|
|
14
|
-
import { DtoAnalyzer } from "../analyses/DtoAnalyzer";
|
|
15
|
-
import { IReflectImport } from "../structures/IReflectImport";
|
|
16
|
-
import { MetadataUtil } from "../utils/MetadataUtil";
|
|
17
|
-
import { IOperationMetadata } from "./IOperationMetadata";
|
|
18
|
-
import { ISdkOperationTransformerContext } from "./ISdkOperationTransformerContext";
|
|
19
|
-
|
|
20
|
-
export namespace SdkOperationProgrammer {
|
|
21
|
-
export interface IProps {
|
|
22
|
-
context: ISdkOperationTransformerContext;
|
|
23
|
-
imports: Singleton<IReflectImport[]>;
|
|
24
|
-
node: ts.MethodDeclaration;
|
|
25
|
-
symbol: ts.Symbol | undefined;
|
|
26
|
-
exceptions: ts.TypeNode[];
|
|
27
|
-
}
|
|
28
|
-
export const write = (p: IProps): IOperationMetadata => {
|
|
29
|
-
return {
|
|
30
|
-
parameters: p.node.parameters.map((parameter, index) =>
|
|
31
|
-
writeParameter({
|
|
32
|
-
context: p.context,
|
|
33
|
-
imports: p.imports,
|
|
34
|
-
parameter,
|
|
35
|
-
index,
|
|
36
|
-
}),
|
|
37
|
-
),
|
|
38
|
-
success: writeResponse({
|
|
39
|
-
context: p.context,
|
|
40
|
-
imports: p.imports,
|
|
41
|
-
typeNode: p.node.type ? getReturnTypeNode(p.node.type) : null,
|
|
42
|
-
type: getReturnType({
|
|
43
|
-
checker: p.context.checker,
|
|
44
|
-
signature: p.context.checker.getSignatureFromDeclaration(p.node),
|
|
45
|
-
}),
|
|
46
|
-
}),
|
|
47
|
-
exceptions: p.exceptions.map((e) =>
|
|
48
|
-
writeResponse({
|
|
49
|
-
context: p.context,
|
|
50
|
-
imports: p.imports,
|
|
51
|
-
typeNode: e,
|
|
52
|
-
type: p.context.checker.getTypeFromTypeNode(e),
|
|
53
|
-
}),
|
|
54
|
-
),
|
|
55
|
-
jsDocTags: p.symbol?.getJsDocTags() ?? [],
|
|
56
|
-
description: p.symbol
|
|
57
|
-
? (CommentFactory.description(p.symbol) ?? null)
|
|
58
|
-
: null,
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const writeParameter = (props: {
|
|
63
|
-
context: ISdkOperationTransformerContext;
|
|
64
|
-
imports: Singleton<IReflectImport[]>;
|
|
65
|
-
parameter: ts.ParameterDeclaration;
|
|
66
|
-
index: number;
|
|
67
|
-
}): IOperationMetadata.IParameter => {
|
|
68
|
-
const symbol: ts.Symbol | undefined =
|
|
69
|
-
props.context.checker.getSymbolAtLocation(props.parameter);
|
|
70
|
-
const common: IOperationMetadata.IResponse = writeResponse({
|
|
71
|
-
context: props.context,
|
|
72
|
-
imports: props.imports,
|
|
73
|
-
typeNode: props.parameter.type ?? null,
|
|
74
|
-
type:
|
|
75
|
-
props.context.checker.getTypeFromTypeNode(
|
|
76
|
-
props.parameter.type ?? TypeFactory.keyword("any"),
|
|
77
|
-
) ?? null,
|
|
78
|
-
});
|
|
79
|
-
const optional: boolean = props.parameter.questionToken !== undefined;
|
|
80
|
-
if (common.primitive.success)
|
|
81
|
-
common.primitive.data.metadata.optional = optional;
|
|
82
|
-
if (common.resolved.success)
|
|
83
|
-
common.resolved.data.metadata.optional = optional;
|
|
84
|
-
|
|
85
|
-
return {
|
|
86
|
-
...common,
|
|
87
|
-
name: props.parameter.name.getText(),
|
|
88
|
-
index: props.index,
|
|
89
|
-
description: (symbol && CommentFactory.description(symbol)) ?? null,
|
|
90
|
-
jsDocTags: symbol?.getJsDocTags() ?? [],
|
|
91
|
-
};
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
const writeResponse = (p: {
|
|
95
|
-
context: ISdkOperationTransformerContext;
|
|
96
|
-
imports: Singleton<IReflectImport[]>;
|
|
97
|
-
typeNode: ts.TypeNode | null;
|
|
98
|
-
type: ts.Type | null;
|
|
99
|
-
}): IOperationMetadata.IResponse => {
|
|
100
|
-
const analyzed: DtoAnalyzer.IOutput | null = p.typeNode
|
|
101
|
-
? DtoAnalyzer.analyzeNode({
|
|
102
|
-
checker: p.context.checker,
|
|
103
|
-
imports: p.imports.get(),
|
|
104
|
-
typeNode: p.typeNode,
|
|
105
|
-
})
|
|
106
|
-
: p.type
|
|
107
|
-
? DtoAnalyzer.analyzeType({
|
|
108
|
-
checker: p.context.checker,
|
|
109
|
-
imports: p.imports.get(),
|
|
110
|
-
type: p.type,
|
|
111
|
-
})
|
|
112
|
-
: {
|
|
113
|
-
type: { name: "any" },
|
|
114
|
-
imports: [],
|
|
115
|
-
};
|
|
116
|
-
const [primitive, resolved] = [true, false].map((escape) =>
|
|
117
|
-
MetadataFactory.analyze({
|
|
118
|
-
checker: p.context.checker,
|
|
119
|
-
transformer: p.context.transformer,
|
|
120
|
-
options: {
|
|
121
|
-
escape,
|
|
122
|
-
constant: true,
|
|
123
|
-
absorb: true,
|
|
124
|
-
},
|
|
125
|
-
components: p.context.collection,
|
|
126
|
-
type: p.type,
|
|
127
|
-
}),
|
|
128
|
-
);
|
|
129
|
-
return {
|
|
130
|
-
...(analyzed
|
|
131
|
-
? analyzed
|
|
132
|
-
: {
|
|
133
|
-
imports: [],
|
|
134
|
-
type: null,
|
|
135
|
-
}),
|
|
136
|
-
primitive: writeSchema({
|
|
137
|
-
collection: p.context.collection,
|
|
138
|
-
result: primitive!,
|
|
139
|
-
}),
|
|
140
|
-
resolved: writeSchema({
|
|
141
|
-
collection: p.context.collection,
|
|
142
|
-
result: resolved!,
|
|
143
|
-
}),
|
|
144
|
-
};
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
const writeSchema = (p: {
|
|
148
|
-
collection: MetadataCollection;
|
|
149
|
-
result: ValidationPipe<MetadataSchema, MetadataFactory.IError>;
|
|
150
|
-
}): ValidationPipe<IOperationMetadata.ISchema, IOperationMetadata.IError> => {
|
|
151
|
-
if (p.result.success === false)
|
|
152
|
-
return {
|
|
153
|
-
success: false,
|
|
154
|
-
errors: p.result.errors.map((e) => ({
|
|
155
|
-
name: e.name,
|
|
156
|
-
accessor:
|
|
157
|
-
e.explore.object !== null
|
|
158
|
-
? join({
|
|
159
|
-
object: e.explore.object,
|
|
160
|
-
key: e.explore.property,
|
|
161
|
-
})
|
|
162
|
-
: null,
|
|
163
|
-
messages: e.messages,
|
|
164
|
-
})),
|
|
165
|
-
};
|
|
166
|
-
const visited: Set<string> = iterateVisited(p.result.data);
|
|
167
|
-
return {
|
|
168
|
-
success: true,
|
|
169
|
-
data: {
|
|
170
|
-
components: {
|
|
171
|
-
objects: p.collection
|
|
172
|
-
.objects()
|
|
173
|
-
.filter((o) => visited.has(o.name))
|
|
174
|
-
.map((o) => o.toJSON()),
|
|
175
|
-
aliases: p.collection
|
|
176
|
-
.aliases()
|
|
177
|
-
.filter((a) => visited.has(a.name))
|
|
178
|
-
.map((a) => a.toJSON()),
|
|
179
|
-
arrays: p.collection
|
|
180
|
-
.arrays()
|
|
181
|
-
.filter((a) => visited.has(a.name))
|
|
182
|
-
.map((a) => a.toJSON()),
|
|
183
|
-
tuples: p.collection
|
|
184
|
-
.tuples()
|
|
185
|
-
.filter((t) => visited.has(t.name))
|
|
186
|
-
.map((t) => t.toJSON()),
|
|
187
|
-
},
|
|
188
|
-
metadata: p.result.data.toJSON(),
|
|
189
|
-
},
|
|
190
|
-
};
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
const iterateVisited = (metadata: MetadataSchema): Set<string> => {
|
|
195
|
-
const names: Set<string> = new Set();
|
|
196
|
-
MetadataUtil.visit((m) => {
|
|
197
|
-
for (const alias of m.aliases) names.add(alias.type.name);
|
|
198
|
-
for (const array of m.arrays) names.add(array.type.name);
|
|
199
|
-
for (const tuple of m.tuples) names.add(tuple.type.name);
|
|
200
|
-
for (const object of m.objects) names.add(object.type.name);
|
|
201
|
-
})(metadata);
|
|
202
|
-
return names;
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
const join = ({
|
|
206
|
-
object,
|
|
207
|
-
key,
|
|
208
|
-
}: {
|
|
209
|
-
object: MetadataObjectType;
|
|
210
|
-
key: string | object | null;
|
|
211
|
-
}) => {
|
|
212
|
-
if (key === null) return object.name;
|
|
213
|
-
else if (typeof key === "object") return `${object.name}[key]`;
|
|
214
|
-
else if (NamingConvention.variable(key)) return `${object.name}.${key}`;
|
|
215
|
-
return `${object.name}[${JSON.stringify(key)}]`;
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
const getReturnTypeNode = (node: ts.TypeNode): ts.TypeNode | null => {
|
|
219
|
-
if (ts.isTypeReferenceNode(node)) {
|
|
220
|
-
const typeName: string = node.typeName.getText();
|
|
221
|
-
if (typeName === "Promise") return node.typeArguments?.[0] ?? null;
|
|
222
|
-
}
|
|
223
|
-
return node;
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
const getReturnType = (p: {
|
|
227
|
-
checker: ts.TypeChecker;
|
|
228
|
-
signature: ts.Signature | undefined;
|
|
229
|
-
}): ts.Type | null => {
|
|
230
|
-
const type: ts.Type | null =
|
|
231
|
-
(p.signature && p.checker.getReturnTypeOfSignature(p.signature)) ?? null;
|
|
232
|
-
if (type === null) return null;
|
|
233
|
-
else if (type.symbol?.name === "Promise") {
|
|
234
|
-
const generic: readonly ts.Type[] = p.checker.getTypeArguments(
|
|
235
|
-
type as ts.TypeReference,
|
|
236
|
-
);
|
|
237
|
-
return generic[0] ?? null;
|
|
238
|
-
}
|
|
239
|
-
return type;
|
|
240
|
-
};
|
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
import { LiteralFactory, MetadataCollection, TypeFactory } from "@typia/core";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { HashSet, Singleton, hash } from "tstl";
|
|
4
|
-
import ts from "typescript";
|
|
5
|
-
|
|
6
|
-
import { ImportAnalyzer } from "../analyses/ImportAnalyzer";
|
|
7
|
-
import { IReflectImport } from "../structures/IReflectImport";
|
|
8
|
-
import { IOperationMetadata } from "./IOperationMetadata";
|
|
9
|
-
import { ISdkOperationTransformerContext } from "./ISdkOperationTransformerContext";
|
|
10
|
-
import { SdkOperationProgrammer } from "./SdkOperationProgrammer";
|
|
11
|
-
|
|
12
|
-
export namespace SdkOperationTransformer {
|
|
13
|
-
export const iterateFile =
|
|
14
|
-
(checker: ts.TypeChecker) => (api: ts.TransformationContext) => {
|
|
15
|
-
const context: ISdkOperationTransformerContext = {
|
|
16
|
-
checker,
|
|
17
|
-
transformer: api,
|
|
18
|
-
collection: collection.get(),
|
|
19
|
-
};
|
|
20
|
-
return (file: ts.SourceFile): ts.SourceFile => {
|
|
21
|
-
if (file.isDeclarationFile === true) return file;
|
|
22
|
-
const visitor: IVisitor = {
|
|
23
|
-
done: false,
|
|
24
|
-
visited: new HashSet(),
|
|
25
|
-
};
|
|
26
|
-
file = ts.visitEachChild(
|
|
27
|
-
file,
|
|
28
|
-
(node) =>
|
|
29
|
-
iterateNode({
|
|
30
|
-
context,
|
|
31
|
-
imports: new Singleton(() => ImportAnalyzer.analyze(file)),
|
|
32
|
-
visitor,
|
|
33
|
-
node,
|
|
34
|
-
}),
|
|
35
|
-
api,
|
|
36
|
-
);
|
|
37
|
-
if (visitor.done === false) return file;
|
|
38
|
-
return ts.factory.updateSourceFile(file, [
|
|
39
|
-
ts.factory.createImportDeclaration(
|
|
40
|
-
undefined,
|
|
41
|
-
ts.factory.createImportClause(
|
|
42
|
-
false,
|
|
43
|
-
undefined,
|
|
44
|
-
ts.factory.createNamespaceImport(
|
|
45
|
-
ts.factory.createIdentifier("__OperationMetadata"),
|
|
46
|
-
),
|
|
47
|
-
),
|
|
48
|
-
ts.factory.createStringLiteral("@nestia/sdk"),
|
|
49
|
-
undefined,
|
|
50
|
-
),
|
|
51
|
-
...file.statements,
|
|
52
|
-
]);
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
interface IVisitor {
|
|
57
|
-
done: boolean;
|
|
58
|
-
visited: HashSet<MethodKey>;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const iterateNode = (props: {
|
|
62
|
-
context: ISdkOperationTransformerContext;
|
|
63
|
-
imports: Singleton<IReflectImport[]>;
|
|
64
|
-
visitor: IVisitor;
|
|
65
|
-
node: ts.Node;
|
|
66
|
-
}): ts.Node =>
|
|
67
|
-
ts.visitEachChild(
|
|
68
|
-
transformNode(props),
|
|
69
|
-
(child) =>
|
|
70
|
-
iterateNode({
|
|
71
|
-
...props,
|
|
72
|
-
node: child,
|
|
73
|
-
}),
|
|
74
|
-
props.context.transformer,
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
const transformNode = (props: {
|
|
78
|
-
context: ISdkOperationTransformerContext;
|
|
79
|
-
imports: Singleton<IReflectImport[]>;
|
|
80
|
-
visitor: IVisitor;
|
|
81
|
-
node: ts.Node;
|
|
82
|
-
}): ts.Node => {
|
|
83
|
-
return ts.isClassDeclaration(props.node)
|
|
84
|
-
? transformClass({
|
|
85
|
-
...props,
|
|
86
|
-
node: props.node,
|
|
87
|
-
})
|
|
88
|
-
: props.node;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const transformClass = (props: {
|
|
92
|
-
context: ISdkOperationTransformerContext;
|
|
93
|
-
visitor: IVisitor;
|
|
94
|
-
imports: Singleton<IReflectImport[]>;
|
|
95
|
-
node: ts.ClassDeclaration;
|
|
96
|
-
}): ts.ClassDeclaration => {
|
|
97
|
-
// TO AVOID COMMENT COMPILATION BUG
|
|
98
|
-
const symbolDict: Map<string, ts.Symbol> = new Map();
|
|
99
|
-
const classType: ts.InterfaceType = props.context.checker.getTypeAtLocation(
|
|
100
|
-
props.node,
|
|
101
|
-
) as ts.InterfaceType;
|
|
102
|
-
for (const symbol of classType.getProperties()) {
|
|
103
|
-
const declaration: ts.Declaration | undefined = (symbol.declarations ||
|
|
104
|
-
[])[0];
|
|
105
|
-
if (!declaration || !ts.isMethodDeclaration(declaration)) continue;
|
|
106
|
-
const identifier = declaration.name;
|
|
107
|
-
if (!ts.isIdentifier(identifier)) continue;
|
|
108
|
-
symbolDict.set(identifier.escapedText.toString(), symbol);
|
|
109
|
-
}
|
|
110
|
-
return ts.factory.updateClassDeclaration(
|
|
111
|
-
props.node,
|
|
112
|
-
props.node.modifiers,
|
|
113
|
-
props.node.name,
|
|
114
|
-
props.node.typeParameters,
|
|
115
|
-
props.node.heritageClauses,
|
|
116
|
-
props.node.members.map((m) =>
|
|
117
|
-
ts.isMethodDeclaration(m)
|
|
118
|
-
? transformMethod({
|
|
119
|
-
...props,
|
|
120
|
-
class: props.node,
|
|
121
|
-
node: m,
|
|
122
|
-
symbol: symbolDict.get(m.name.getText()),
|
|
123
|
-
})
|
|
124
|
-
: m,
|
|
125
|
-
),
|
|
126
|
-
);
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
const transformMethod = (props: {
|
|
130
|
-
context: ISdkOperationTransformerContext;
|
|
131
|
-
visitor: IVisitor;
|
|
132
|
-
imports: Singleton<IReflectImport[]>;
|
|
133
|
-
class: ts.ClassDeclaration;
|
|
134
|
-
node: ts.MethodDeclaration;
|
|
135
|
-
symbol: ts.Symbol | undefined;
|
|
136
|
-
}): ts.MethodDeclaration => {
|
|
137
|
-
const decorators: readonly ts.Decorator[] | undefined = ts.getDecorators
|
|
138
|
-
? ts.getDecorators(props.node)
|
|
139
|
-
: (props.node as any).decorators;
|
|
140
|
-
if (!decorators?.length) return props.node;
|
|
141
|
-
|
|
142
|
-
const key: MethodKey = new MethodKey(
|
|
143
|
-
props.class.name?.getText() ?? "",
|
|
144
|
-
props.node.name.getText(),
|
|
145
|
-
);
|
|
146
|
-
props.visitor.done ||= true;
|
|
147
|
-
if (props.visitor.visited.has(key)) return props.node;
|
|
148
|
-
else props.visitor.visited.insert(key);
|
|
149
|
-
|
|
150
|
-
const metadata: IOperationMetadata = SdkOperationProgrammer.write({
|
|
151
|
-
...props,
|
|
152
|
-
exceptions: getExceptionTypes({
|
|
153
|
-
checker: props.context.checker,
|
|
154
|
-
decorators,
|
|
155
|
-
}),
|
|
156
|
-
});
|
|
157
|
-
return ts.factory.updateMethodDeclaration(
|
|
158
|
-
props.node,
|
|
159
|
-
[
|
|
160
|
-
...(props.node.modifiers ?? []),
|
|
161
|
-
ts.factory.createDecorator(
|
|
162
|
-
ts.factory.createCallExpression(
|
|
163
|
-
ts.factory.createIdentifier(
|
|
164
|
-
"__OperationMetadata.OperationMetadata",
|
|
165
|
-
),
|
|
166
|
-
undefined,
|
|
167
|
-
[
|
|
168
|
-
ts.factory.createAsExpression(
|
|
169
|
-
LiteralFactory.write(metadata),
|
|
170
|
-
TypeFactory.keyword("any"),
|
|
171
|
-
),
|
|
172
|
-
],
|
|
173
|
-
),
|
|
174
|
-
),
|
|
175
|
-
],
|
|
176
|
-
props.node.asteriskToken,
|
|
177
|
-
props.node.name,
|
|
178
|
-
props.node.questionToken,
|
|
179
|
-
props.node.typeParameters,
|
|
180
|
-
props.node.parameters,
|
|
181
|
-
props.node.type,
|
|
182
|
-
props.node.body,
|
|
183
|
-
);
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
const getExceptionTypes = (props: {
|
|
187
|
-
checker: ts.TypeChecker;
|
|
188
|
-
decorators: readonly ts.Decorator[];
|
|
189
|
-
}) =>
|
|
190
|
-
props.decorators
|
|
191
|
-
.map((deco) => {
|
|
192
|
-
if (false === ts.isCallExpression(deco.expression)) return null;
|
|
193
|
-
|
|
194
|
-
const signature: ts.Signature | undefined =
|
|
195
|
-
props.checker.getResolvedSignature(deco.expression);
|
|
196
|
-
if (signature === undefined) return null;
|
|
197
|
-
else if (!signature.declaration) return null;
|
|
198
|
-
|
|
199
|
-
const location: string = path.resolve(
|
|
200
|
-
signature.declaration.getSourceFile()?.fileName ?? "",
|
|
201
|
-
);
|
|
202
|
-
if (
|
|
203
|
-
location.includes(TYPED_EXCEPTION_LIB_PATH) === false &&
|
|
204
|
-
location.includes(TYPED_EXCEPTION_MONO_PATH) === false
|
|
205
|
-
)
|
|
206
|
-
return null;
|
|
207
|
-
else if (deco.expression.typeArguments?.length !== 1) return null;
|
|
208
|
-
return deco.expression.typeArguments[0]!;
|
|
209
|
-
})
|
|
210
|
-
.filter((t) => t !== null);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
class MethodKey {
|
|
214
|
-
public constructor(
|
|
215
|
-
public readonly className: string,
|
|
216
|
-
public readonly methodName: string,
|
|
217
|
-
) {}
|
|
218
|
-
|
|
219
|
-
public equals(o: MethodKey): boolean {
|
|
220
|
-
return this.className === o.className && this.methodName === o.methodName;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
public hashCode(): number {
|
|
224
|
-
return hash(this.className, this.methodName);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
const TYPED_EXCEPTION_LIB_PATH = path.join(
|
|
229
|
-
"@nestia",
|
|
230
|
-
"core",
|
|
231
|
-
"lib",
|
|
232
|
-
"decorators",
|
|
233
|
-
`TypedException.d.ts`,
|
|
234
|
-
);
|
|
235
|
-
const TYPED_EXCEPTION_MONO_PATH = path.join(
|
|
236
|
-
"packages",
|
|
237
|
-
"core",
|
|
238
|
-
"src",
|
|
239
|
-
"decorators",
|
|
240
|
-
`TypedException.ts`,
|
|
241
|
-
);
|
|
242
|
-
|
|
243
|
-
const collection = new Singleton(
|
|
244
|
-
() =>
|
|
245
|
-
new MetadataCollection({
|
|
246
|
-
replace: MetadataCollection.replace,
|
|
247
|
-
}),
|
|
248
|
-
);
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { MetadataSchema } from "@typia/core";
|
|
2
|
-
|
|
3
|
-
export namespace MetadataUtil {
|
|
4
|
-
export const visit = (closure: (m: MetadataSchema) => unknown) => {
|
|
5
|
-
const visited: WeakSet<MetadataSchema> = new WeakSet();
|
|
6
|
-
const iterate = (metadata: MetadataSchema): void => {
|
|
7
|
-
if (visited.has(metadata)) return;
|
|
8
|
-
visited.add(metadata);
|
|
9
|
-
closure(metadata);
|
|
10
|
-
for (const alias of metadata.aliases) iterate(alias.type.value);
|
|
11
|
-
for (const array of metadata.arrays) iterate(array.type.value);
|
|
12
|
-
for (const tuple of metadata.tuples) tuple.type.elements.map(iterate);
|
|
13
|
-
for (const object of metadata.objects)
|
|
14
|
-
object.type.properties.forEach((p) => {
|
|
15
|
-
iterate(p.key);
|
|
16
|
-
iterate(p.value);
|
|
17
|
-
});
|
|
18
|
-
if (metadata.escaped) {
|
|
19
|
-
iterate(metadata.escaped.original);
|
|
20
|
-
iterate(metadata.escaped.returns);
|
|
21
|
-
}
|
|
22
|
-
if (metadata.rest) iterate(metadata.rest);
|
|
23
|
-
};
|
|
24
|
-
return iterate;
|
|
25
|
-
};
|
|
26
|
-
}
|
package/src/utils/StripEnums.ts
DELETED
|
File without changes
|
|
File without changes
|