@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,260 +0,0 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { IReflectImport } from "../structures/IReflectImport";
|
|
4
|
-
import { IReflectType } from "../structures/IReflectType";
|
|
5
|
-
import { ImportAnalyzer } from "./ImportAnalyzer";
|
|
6
|
-
|
|
7
|
-
export namespace DtoAnalyzer {
|
|
8
|
-
export interface INodeProps {
|
|
9
|
-
checker: ts.TypeChecker;
|
|
10
|
-
imports: IReflectImport[];
|
|
11
|
-
typeNode: ts.TypeNode;
|
|
12
|
-
}
|
|
13
|
-
export interface ITypeProps {
|
|
14
|
-
checker: ts.TypeChecker;
|
|
15
|
-
imports: IReflectImport[];
|
|
16
|
-
type: ts.Type;
|
|
17
|
-
}
|
|
18
|
-
export interface IOutput {
|
|
19
|
-
imports: IReflectImport[];
|
|
20
|
-
type: IReflectType;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const analyzeNode = (props: INodeProps): IOutput | null => {
|
|
24
|
-
try {
|
|
25
|
-
const container: IReflectImport[] = [];
|
|
26
|
-
const type: IReflectType = exploreNode(
|
|
27
|
-
{
|
|
28
|
-
checker: props.checker,
|
|
29
|
-
imports: props.imports,
|
|
30
|
-
container,
|
|
31
|
-
},
|
|
32
|
-
props.typeNode,
|
|
33
|
-
);
|
|
34
|
-
return {
|
|
35
|
-
type,
|
|
36
|
-
imports: ImportAnalyzer.merge(container),
|
|
37
|
-
};
|
|
38
|
-
} catch {
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export const analyzeType = (props: ITypeProps): IOutput | null => {
|
|
44
|
-
try {
|
|
45
|
-
const container: IReflectImport[] = [];
|
|
46
|
-
const type: IReflectType = exploreType(
|
|
47
|
-
{
|
|
48
|
-
checker: props.checker,
|
|
49
|
-
imports: props.imports,
|
|
50
|
-
container,
|
|
51
|
-
},
|
|
52
|
-
props.type,
|
|
53
|
-
);
|
|
54
|
-
return {
|
|
55
|
-
type,
|
|
56
|
-
imports: ImportAnalyzer.merge(container),
|
|
57
|
-
};
|
|
58
|
-
} catch {
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
type IContext = Omit<INodeProps, "typeNode"> & {
|
|
64
|
-
container: IReflectImport[];
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const exploreNode = (ctx: IContext, typeNode: ts.TypeNode): IReflectType => {
|
|
68
|
-
// Analyze symbol, and take special cares
|
|
69
|
-
if (ts.isIntersectionTypeNode(typeNode))
|
|
70
|
-
return {
|
|
71
|
-
name: typeNode.types
|
|
72
|
-
.map((child) => exploreNode(ctx, child))
|
|
73
|
-
.map(getEscapedText)
|
|
74
|
-
.join(" & "),
|
|
75
|
-
};
|
|
76
|
-
else if (ts.isUnionTypeNode(typeNode))
|
|
77
|
-
return {
|
|
78
|
-
name: typeNode.types
|
|
79
|
-
.map((child) => exploreNode(ctx, child))
|
|
80
|
-
.map(getEscapedText)
|
|
81
|
-
.join(" | "),
|
|
82
|
-
};
|
|
83
|
-
else if (ts.isArrayTypeNode(typeNode)) {
|
|
84
|
-
const element: IReflectType = exploreNode(ctx, typeNode.elementType);
|
|
85
|
-
return {
|
|
86
|
-
name: "Array",
|
|
87
|
-
typeArguments: [element],
|
|
88
|
-
};
|
|
89
|
-
} else if (ts.isParenthesizedTypeNode(typeNode))
|
|
90
|
-
return {
|
|
91
|
-
name: `(${exploreNode(ctx, typeNode.type).name})`,
|
|
92
|
-
};
|
|
93
|
-
else if (ts.isTypeOperatorNode(typeNode)) {
|
|
94
|
-
const prefix: string | null =
|
|
95
|
-
typeNode.operator === ts.SyntaxKind.KeyOfKeyword
|
|
96
|
-
? "keyof"
|
|
97
|
-
: typeNode.operator === ts.SyntaxKind.UniqueKeyword
|
|
98
|
-
? "unique"
|
|
99
|
-
: typeNode.operator === ts.SyntaxKind.ReadonlyKeyword
|
|
100
|
-
? "readonly"
|
|
101
|
-
: null;
|
|
102
|
-
if (prefix === null)
|
|
103
|
-
return exploreType(ctx, ctx.checker.getTypeFromTypeNode(typeNode));
|
|
104
|
-
return {
|
|
105
|
-
name: `${prefix} ${exploreNode(ctx, typeNode.type).name}`,
|
|
106
|
-
};
|
|
107
|
-
} else if (ts.isTypePredicateNode(typeNode) || ts.isTypeQueryNode(typeNode))
|
|
108
|
-
return exploreType(ctx, ctx.checker.getTypeFromTypeNode(typeNode));
|
|
109
|
-
else if (ts.isTypeReferenceNode(typeNode) === false)
|
|
110
|
-
return {
|
|
111
|
-
name: typeNode.getText(),
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
// Find matched import statement
|
|
115
|
-
const name: string = typeNode.typeName.getText();
|
|
116
|
-
const prefix: string = name.split(".")[0]!;
|
|
117
|
-
|
|
118
|
-
let matched: boolean = false;
|
|
119
|
-
const insert = (imp: IReflectImport): void => {
|
|
120
|
-
matched ||= true;
|
|
121
|
-
ctx.container.push(imp);
|
|
122
|
-
};
|
|
123
|
-
for (const imp of ctx.imports)
|
|
124
|
-
if (prefix === imp.default)
|
|
125
|
-
insert({
|
|
126
|
-
file: imp.file,
|
|
127
|
-
asterisk: null,
|
|
128
|
-
default: prefix,
|
|
129
|
-
elements: [],
|
|
130
|
-
});
|
|
131
|
-
else if (prefix === imp.asterisk)
|
|
132
|
-
insert({
|
|
133
|
-
file: imp.file,
|
|
134
|
-
asterisk: prefix,
|
|
135
|
-
default: null,
|
|
136
|
-
elements: [],
|
|
137
|
-
});
|
|
138
|
-
else if (imp.elements.includes(prefix))
|
|
139
|
-
insert({
|
|
140
|
-
file: imp.file,
|
|
141
|
-
asterisk: null,
|
|
142
|
-
default: null,
|
|
143
|
-
elements: [prefix],
|
|
144
|
-
});
|
|
145
|
-
if (prefix !== "Promise" && matched === false)
|
|
146
|
-
return exploreType(ctx, ctx.checker.getTypeFromTypeNode(typeNode));
|
|
147
|
-
|
|
148
|
-
// Finalize with generic arguments
|
|
149
|
-
if (!!typeNode.typeArguments?.length) {
|
|
150
|
-
const top: ts.TypeNode = typeNode.typeArguments[0]!;
|
|
151
|
-
if (name === "Promise") return exploreNode(ctx, top);
|
|
152
|
-
return {
|
|
153
|
-
name,
|
|
154
|
-
typeArguments: typeNode.typeArguments.map((child) =>
|
|
155
|
-
exploreNode(ctx, child),
|
|
156
|
-
),
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
return { name };
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
const exploreType = (ctx: IContext, type: ts.Type): IReflectType => {
|
|
163
|
-
// Analyze symbol, and take special cares
|
|
164
|
-
const symbol: ts.Symbol | undefined = type.aliasSymbol ?? type.symbol;
|
|
165
|
-
if (type.aliasSymbol === undefined && type.isUnionOrIntersection()) {
|
|
166
|
-
const joiner: string = type.isIntersection() ? " & " : " | ";
|
|
167
|
-
return {
|
|
168
|
-
name: type.types
|
|
169
|
-
.map((child) => exploreType(ctx, child))
|
|
170
|
-
.map(getEscapedText)
|
|
171
|
-
.join(joiner),
|
|
172
|
-
};
|
|
173
|
-
} else if (ctx.checker.isArrayLikeType(type)) {
|
|
174
|
-
const arrayItem: ts.Type | undefined =
|
|
175
|
-
ctx.checker.getElementTypeOfArrayType(type);
|
|
176
|
-
if (arrayItem === undefined) return { name: "Array<any>" };
|
|
177
|
-
return {
|
|
178
|
-
name: "Array",
|
|
179
|
-
typeArguments: [exploreType(ctx, arrayItem)],
|
|
180
|
-
};
|
|
181
|
-
} else if (symbol === undefined)
|
|
182
|
-
return {
|
|
183
|
-
name: ctx.checker.typeToString(
|
|
184
|
-
type,
|
|
185
|
-
undefined,
|
|
186
|
-
ts.TypeFormatFlags.NoTruncation,
|
|
187
|
-
),
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
// Find matched import statement
|
|
191
|
-
const name: string = getNameOfSymbol(symbol);
|
|
192
|
-
const prefix: string = name.split(".")[0]!;
|
|
193
|
-
|
|
194
|
-
let matched: boolean = false;
|
|
195
|
-
const insert = (imp: IReflectImport): void => {
|
|
196
|
-
matched ||= true;
|
|
197
|
-
ctx.container.push(imp);
|
|
198
|
-
};
|
|
199
|
-
for (const imp of ctx.imports)
|
|
200
|
-
if (imp.elements.includes(prefix))
|
|
201
|
-
insert({
|
|
202
|
-
file: imp.file,
|
|
203
|
-
asterisk: null,
|
|
204
|
-
default: null,
|
|
205
|
-
elements: [prefix],
|
|
206
|
-
});
|
|
207
|
-
if (prefix !== "Promise" && matched === false)
|
|
208
|
-
emplaceSymbol(ctx, symbol, prefix);
|
|
209
|
-
|
|
210
|
-
// Finalize with generic arguments
|
|
211
|
-
const generic: readonly ts.Type[] = type.aliasSymbol
|
|
212
|
-
? (type.aliasTypeArguments ?? [])
|
|
213
|
-
: ctx.checker.getTypeArguments(type as ts.TypeReference);
|
|
214
|
-
return generic.length
|
|
215
|
-
? name === "Promise"
|
|
216
|
-
? exploreType(ctx, generic[0]!)
|
|
217
|
-
: {
|
|
218
|
-
name,
|
|
219
|
-
typeArguments: generic.map((child) => exploreType(ctx, child)),
|
|
220
|
-
}
|
|
221
|
-
: { name };
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
const emplaceSymbol = (
|
|
225
|
-
ctx: IContext,
|
|
226
|
-
symbol: ts.Symbol,
|
|
227
|
-
prefix: string,
|
|
228
|
-
): void => {
|
|
229
|
-
// GET SOURCE FILE
|
|
230
|
-
const sourceFile: ts.SourceFile | undefined =
|
|
231
|
-
symbol.declarations?.[0]?.getSourceFile();
|
|
232
|
-
if (sourceFile === undefined) return;
|
|
233
|
-
if (sourceFile.fileName.indexOf("/typescript/lib") === -1)
|
|
234
|
-
ctx.container.push({
|
|
235
|
-
file: sourceFile.fileName,
|
|
236
|
-
asterisk: null,
|
|
237
|
-
default: null,
|
|
238
|
-
elements: [prefix],
|
|
239
|
-
});
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
const getEscapedText = (type: IReflectType): string =>
|
|
244
|
-
type.typeArguments
|
|
245
|
-
? `${type.name}<${type.typeArguments.map(getEscapedText).join(", ")}>`
|
|
246
|
-
: type.name;
|
|
247
|
-
|
|
248
|
-
const getNameOfSymbol = (symbol: ts.Symbol): string =>
|
|
249
|
-
exploreName(
|
|
250
|
-
symbol.escapedName.toString(),
|
|
251
|
-
symbol.getDeclarations()?.[0]?.parent,
|
|
252
|
-
);
|
|
253
|
-
|
|
254
|
-
const exploreName = (name: string, decl?: ts.Node): string =>
|
|
255
|
-
decl && ts.isModuleBlock(decl)
|
|
256
|
-
? exploreName(
|
|
257
|
-
`${decl.parent.name.getFullText().trim()}.${name}`,
|
|
258
|
-
decl.parent.parent,
|
|
259
|
-
)
|
|
260
|
-
: name;
|
|
@@ -1,154 +0,0 @@
|
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
120
|
-
// const getStatus =
|
|
121
|
-
// (checker: ts.TypeChecker) =>
|
|
122
|
-
// (expression: ts.Expression | null): string | null => {
|
|
123
|
-
// if (expression === null) return null;
|
|
124
|
-
|
|
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
|
-
|
|
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
|
-
|
|
147
|
-
// const TYPED_EXCEPTION_PATH = path.join(
|
|
148
|
-
// "node_modules",
|
|
149
|
-
// "@nestia",
|
|
150
|
-
// "core",
|
|
151
|
-
// "lib",
|
|
152
|
-
// "decorators",
|
|
153
|
-
// "TypedException.d.ts",
|
|
154
|
-
// );
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
export namespace GenericAnalyzer {
|
|
4
|
-
export function analyze(
|
|
5
|
-
checker: ts.TypeChecker,
|
|
6
|
-
classNode: ts.ClassDeclaration,
|
|
7
|
-
): WeakMap<ts.Type, ts.Type> {
|
|
8
|
-
const dict: WeakMap<ts.Type, ts.Type> = new WeakMap();
|
|
9
|
-
explore(checker, dict, classNode);
|
|
10
|
-
return dict;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function explore(
|
|
14
|
-
checker: ts.TypeChecker,
|
|
15
|
-
dict: WeakMap<ts.Type, ts.Type>,
|
|
16
|
-
classNode: ts.ClassDeclaration,
|
|
17
|
-
): void {
|
|
18
|
-
if (classNode.heritageClauses === undefined) return;
|
|
19
|
-
|
|
20
|
-
for (const heritage of classNode.heritageClauses)
|
|
21
|
-
for (const hType of heritage.types) {
|
|
22
|
-
// MUST BE CLASS
|
|
23
|
-
const expression: ts.Type = checker.getTypeAtLocation(hType.expression);
|
|
24
|
-
const superNode: ts.Declaration | undefined =
|
|
25
|
-
expression.symbol?.getDeclarations?.()?.[0];
|
|
26
|
-
|
|
27
|
-
if (superNode === undefined || !ts.isClassDeclaration(superNode))
|
|
28
|
-
continue;
|
|
29
|
-
|
|
30
|
-
// SPECIFY GENERICS
|
|
31
|
-
const usages: ReadonlyArray<ts.TypeNode> = hType.typeArguments || [];
|
|
32
|
-
const parameters: ReadonlyArray<ts.TypeParameterDeclaration> =
|
|
33
|
-
superNode.typeParameters || [];
|
|
34
|
-
|
|
35
|
-
parameters.forEach((param, index) => {
|
|
36
|
-
const paramType: ts.Type = checker.getTypeAtLocation(param);
|
|
37
|
-
const usageType: ts.Type =
|
|
38
|
-
usages[index] !== undefined
|
|
39
|
-
? checker.getTypeAtLocation(usages[index])
|
|
40
|
-
: checker.getTypeAtLocation(param.default!);
|
|
41
|
-
|
|
42
|
-
dict.set(paramType, usageType);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
// RECURSIVE EXPLORATION
|
|
46
|
-
explore(checker, dict, superNode);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type ParamCategory = "param" | "query" | "body" | "rawBody" | "headers";
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { hash } from "tstl";
|
|
2
|
-
import ts from "typescript";
|
|
3
|
-
|
|
4
|
-
export class TypeEntry {
|
|
5
|
-
public constructor(
|
|
6
|
-
public readonly type: ts.Type,
|
|
7
|
-
public readonly nullable: boolean,
|
|
8
|
-
public readonly required: boolean,
|
|
9
|
-
) {}
|
|
10
|
-
|
|
11
|
-
public equals(obj: TypeEntry): boolean {
|
|
12
|
-
return (
|
|
13
|
-
this.type === obj.type &&
|
|
14
|
-
this.nullable === obj.nullable &&
|
|
15
|
-
this.required === obj.required
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
public hashCode(): number {
|
|
20
|
-
return hash(this.type, this.nullable, this.required);
|
|
21
|
-
}
|
|
22
|
-
}
|