@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,18 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
MetadataArray,
|
|
5
|
-
MetadataAtomic,
|
|
6
|
-
MetadataConstantValue,
|
|
7
|
-
MetadataEscaped,
|
|
8
|
-
MetadataObjectType,
|
|
9
|
-
MetadataProperty,
|
|
10
|
-
MetadataSchema,
|
|
11
|
-
MetadataTuple,
|
|
12
|
-
TypeFactory,
|
|
13
|
-
} from "@typia/core";
|
|
1
|
+
import { Node, SyntaxKind, TypeScriptFactory } from "@nestia/factory";
|
|
2
|
+
import { ExpressionFactory, TypeFactory } from "@nestia/factory";
|
|
3
|
+
import { MetadataAliasType, MetadataArray, MetadataAtomic, MetadataConstantValue, MetadataEscaped, MetadataObjectType, MetadataProperty, MetadataSchema, MetadataTuple, isSoleLiteralOf, sizeOf } from "../../internal/legacy";
|
|
14
4
|
import { NamingConvention } from "@typia/utils";
|
|
15
|
-
import ts from "typescript";
|
|
16
5
|
import { IJsDocTagInfo, IMetadataTypeTag } from "typia";
|
|
17
6
|
|
|
18
7
|
import { INestiaProject } from "../../structures/INestiaProject";
|
|
@@ -27,13 +16,13 @@ export namespace SdkTypeProgrammer {
|
|
|
27
16
|
export const write =
|
|
28
17
|
(project: INestiaProject) =>
|
|
29
18
|
(importer: ImportDictionary) =>
|
|
30
|
-
(meta: MetadataSchema, parentEscaped: boolean = false):
|
|
31
|
-
const union:
|
|
19
|
+
(meta: MetadataSchema, parentEscaped: boolean = false): Node => {
|
|
20
|
+
const union: Node[] = [];
|
|
32
21
|
|
|
33
22
|
// COALESCES
|
|
34
23
|
if (meta.any) union.push(TypeFactory.keyword("any"));
|
|
35
24
|
if (meta.nullable) union.push(writeNode("null"));
|
|
36
|
-
if (meta.
|
|
25
|
+
if (meta.required === false) union.push(writeNode("undefined"));
|
|
37
26
|
if (parentEscaped === false && meta.escaped)
|
|
38
27
|
union.push(write_escaped(project)(importer)(meta.escaped));
|
|
39
28
|
|
|
@@ -46,43 +35,45 @@ export namespace SdkTypeProgrammer {
|
|
|
46
35
|
|
|
47
36
|
// OBJECT TYPES
|
|
48
37
|
for (const tuple of meta.tuples)
|
|
49
|
-
union.push(write_tuple(project)(importer)(tuple));
|
|
38
|
+
union.push(write_tuple(project)(importer)(tuple as MetadataTuple));
|
|
50
39
|
for (const array of meta.arrays)
|
|
51
|
-
union.push(write_array(project)(importer)(array));
|
|
52
|
-
for (const object of meta.objects)
|
|
40
|
+
union.push(write_array(project)(importer)(array as MetadataArray));
|
|
41
|
+
for (const object of meta.objects) {
|
|
42
|
+
const target = object.type as MetadataObjectType;
|
|
53
43
|
if (
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
44
|
+
target.name === "object" ||
|
|
45
|
+
target.name === "__type" ||
|
|
46
|
+
target.name.startsWith("__type.") ||
|
|
47
|
+
target.name === "__object" ||
|
|
48
|
+
target.name.startsWith("__object.")
|
|
59
49
|
)
|
|
60
|
-
union.push(write_object(project)(importer)(
|
|
61
|
-
else union.push(writeAlias(project)(importer)(
|
|
50
|
+
union.push(write_object(project)(importer)(target));
|
|
51
|
+
else union.push(writeAlias(project)(importer)(target));
|
|
52
|
+
}
|
|
62
53
|
for (const alias of meta.aliases)
|
|
63
|
-
union.push(writeAlias(project)(importer)(alias.type));
|
|
54
|
+
union.push(writeAlias(project)(importer)(alias.type as MetadataAliasType));
|
|
64
55
|
for (const native of meta.natives)
|
|
65
56
|
if (native.name === "Blob" || native.name === "File")
|
|
66
57
|
union.push(write_native(native.name));
|
|
67
58
|
|
|
68
59
|
return union.length === 1
|
|
69
60
|
? union[0]!
|
|
70
|
-
:
|
|
61
|
+
: TypeScriptFactory.createUnionTypeNode(union);
|
|
71
62
|
};
|
|
72
63
|
|
|
73
64
|
export const write_object =
|
|
74
65
|
(project: INestiaProject) =>
|
|
75
66
|
(importer: ImportDictionary) =>
|
|
76
|
-
(object: MetadataObjectType):
|
|
77
|
-
const regular = object.properties.filter((p) => p.key
|
|
78
|
-
const dynamic = object.properties.filter((p) => !p.key
|
|
67
|
+
(object: MetadataObjectType): Node => {
|
|
68
|
+
const regular = object.properties.filter((p) => isSoleLiteralOf(p.key));
|
|
69
|
+
const dynamic = object.properties.filter((p) => !isSoleLiteralOf(p.key));
|
|
79
70
|
return regular.length && dynamic.length
|
|
80
|
-
?
|
|
71
|
+
? TypeScriptFactory.createIntersectionTypeNode([
|
|
81
72
|
write_regular_property(project)(importer)(regular),
|
|
82
73
|
...dynamic.map(write_dynamic_property(project)(importer)),
|
|
83
74
|
])
|
|
84
75
|
: dynamic.length
|
|
85
|
-
?
|
|
76
|
+
? TypeScriptFactory.createIntersectionTypeNode(
|
|
86
77
|
dynamic.map(write_dynamic_property(project)(importer)),
|
|
87
78
|
)
|
|
88
79
|
: write_regular_property(project)(importer)(regular);
|
|
@@ -91,13 +82,13 @@ export namespace SdkTypeProgrammer {
|
|
|
91
82
|
const write_escaped =
|
|
92
83
|
(project: INestiaProject) =>
|
|
93
84
|
(importer: ImportDictionary) =>
|
|
94
|
-
(meta: MetadataEscaped):
|
|
85
|
+
(meta: MetadataEscaped): Node => {
|
|
95
86
|
if (
|
|
96
|
-
meta.original
|
|
87
|
+
sizeOf(meta.original) === 1 &&
|
|
97
88
|
meta.original.natives.length === 1 &&
|
|
98
89
|
meta.original.natives[0]!.name === "Date"
|
|
99
90
|
)
|
|
100
|
-
return
|
|
91
|
+
return TypeScriptFactory.createIntersectionTypeNode([
|
|
101
92
|
TypeFactory.keyword("string"),
|
|
102
93
|
SdkTypeTagProgrammer.write(importer, "string", {
|
|
103
94
|
name: "Format",
|
|
@@ -112,48 +103,50 @@ export namespace SdkTypeProgrammer {
|
|
|
112
103
|
----------------------------------------------------------- */
|
|
113
104
|
const write_constant = (value: MetadataConstantValue) => {
|
|
114
105
|
if (typeof value.value === "boolean")
|
|
115
|
-
return
|
|
116
|
-
value
|
|
106
|
+
return TypeScriptFactory.createLiteralTypeNode(
|
|
107
|
+
value.value
|
|
108
|
+
? TypeScriptFactory.createTrue()
|
|
109
|
+
: TypeScriptFactory.createFalse(),
|
|
117
110
|
);
|
|
118
111
|
else if (typeof value.value === "bigint")
|
|
119
|
-
return
|
|
112
|
+
return TypeScriptFactory.createLiteralTypeNode(
|
|
120
113
|
value.value < BigInt(0)
|
|
121
|
-
?
|
|
122
|
-
|
|
123
|
-
|
|
114
|
+
? TypeScriptFactory.createPrefixUnaryExpression(
|
|
115
|
+
SyntaxKind.MinusToken,
|
|
116
|
+
TypeScriptFactory.createBigIntLiteral((-value.value).toString()),
|
|
124
117
|
)
|
|
125
|
-
:
|
|
118
|
+
: TypeScriptFactory.createBigIntLiteral(value.value.toString()),
|
|
126
119
|
);
|
|
127
120
|
else if (typeof value.value === "number")
|
|
128
|
-
return
|
|
121
|
+
return TypeScriptFactory.createLiteralTypeNode(
|
|
129
122
|
ExpressionFactory.number(value.value),
|
|
130
123
|
);
|
|
131
|
-
return
|
|
132
|
-
|
|
124
|
+
return TypeScriptFactory.createLiteralTypeNode(
|
|
125
|
+
TypeScriptFactory.createStringLiteral(value.value as string),
|
|
133
126
|
);
|
|
134
127
|
};
|
|
135
128
|
|
|
136
129
|
const write_template =
|
|
137
130
|
(project: INestiaProject) =>
|
|
138
131
|
(importer: ImportDictionary) =>
|
|
139
|
-
(meta: MetadataSchema[]):
|
|
140
|
-
const head: boolean = meta[0]
|
|
141
|
-
const spans: [
|
|
132
|
+
(meta: MetadataSchema[]): Node => {
|
|
133
|
+
const head: boolean = isSoleLiteralOf(meta[0]!);
|
|
134
|
+
const spans: [Node | null, string | null][] = [];
|
|
142
135
|
for (const elem of meta.slice(head ? 1 : 0)) {
|
|
143
136
|
const last =
|
|
144
137
|
spans.at(-1) ??
|
|
145
138
|
(() => {
|
|
146
|
-
const tuple = [null!, null!] as [
|
|
139
|
+
const tuple = [null!, null!] as [Node | null, string | null];
|
|
147
140
|
spans.push(tuple);
|
|
148
141
|
return tuple;
|
|
149
142
|
})();
|
|
150
|
-
if (elem
|
|
143
|
+
if (isSoleLiteralOf(elem))
|
|
151
144
|
if (last[1] === null)
|
|
152
145
|
last[1] = String(elem.constants[0]!.values[0]!.value);
|
|
153
146
|
else
|
|
154
147
|
spans.push([
|
|
155
|
-
|
|
156
|
-
|
|
148
|
+
TypeScriptFactory.createLiteralTypeNode(
|
|
149
|
+
TypeScriptFactory.createStringLiteral(
|
|
157
150
|
String(elem.constants[0]!.values[0]!.value),
|
|
158
151
|
),
|
|
159
152
|
),
|
|
@@ -162,18 +155,18 @@ export namespace SdkTypeProgrammer {
|
|
|
162
155
|
else if (last[0] === null) last[0] = write(project)(importer)(elem);
|
|
163
156
|
else spans.push([write(project)(importer)(elem), null]);
|
|
164
157
|
}
|
|
165
|
-
return
|
|
166
|
-
|
|
158
|
+
return TypeScriptFactory.createTemplateLiteralType(
|
|
159
|
+
TypeScriptFactory.createTemplateHead(
|
|
167
160
|
head ? (meta[0]!.constants[0]!.values[0]!.value as string) : "",
|
|
168
161
|
),
|
|
169
162
|
spans
|
|
170
163
|
.filter(([node]) => node !== null)
|
|
171
164
|
.map(([node, str], i, array) =>
|
|
172
|
-
|
|
165
|
+
TypeScriptFactory.createTemplateLiteralTypeSpan(
|
|
173
166
|
node!,
|
|
174
167
|
(i !== array.length - 1
|
|
175
|
-
?
|
|
176
|
-
:
|
|
168
|
+
? TypeScriptFactory.createTemplateMiddle
|
|
169
|
+
: TypeScriptFactory.createTemplateTail)(str ?? ""),
|
|
177
170
|
),
|
|
178
171
|
),
|
|
179
172
|
);
|
|
@@ -181,17 +174,17 @@ export namespace SdkTypeProgrammer {
|
|
|
181
174
|
|
|
182
175
|
const write_atomic =
|
|
183
176
|
(importer: ImportDictionary) =>
|
|
184
|
-
(meta: MetadataAtomic):
|
|
177
|
+
(meta: MetadataAtomic): Node =>
|
|
185
178
|
write_type_tag_matrix(importer)(
|
|
186
179
|
meta.type as "boolean" | "bigint" | "number" | "string",
|
|
187
|
-
|
|
180
|
+
TypeScriptFactory.createKeywordTypeNode(
|
|
188
181
|
meta.type === "boolean"
|
|
189
|
-
?
|
|
182
|
+
? SyntaxKind.BooleanKeyword
|
|
190
183
|
: meta.type === "bigint"
|
|
191
|
-
?
|
|
184
|
+
? SyntaxKind.BigIntKeyword
|
|
192
185
|
: meta.type === "number"
|
|
193
|
-
?
|
|
194
|
-
:
|
|
186
|
+
? SyntaxKind.NumberKeyword
|
|
187
|
+
: SyntaxKind.StringKeyword,
|
|
195
188
|
),
|
|
196
189
|
meta.tags,
|
|
197
190
|
);
|
|
@@ -202,11 +195,11 @@ export namespace SdkTypeProgrammer {
|
|
|
202
195
|
const write_array =
|
|
203
196
|
(project: INestiaProject) =>
|
|
204
197
|
(importer: ImportDictionary) =>
|
|
205
|
-
(meta: MetadataArray):
|
|
198
|
+
(meta: MetadataArray): Node =>
|
|
206
199
|
write_type_tag_matrix(importer)(
|
|
207
200
|
"array",
|
|
208
|
-
|
|
209
|
-
write(project)(importer)(meta.type
|
|
201
|
+
TypeScriptFactory.createArrayTypeNode(
|
|
202
|
+
write(project)(importer)(meta.type!.value),
|
|
210
203
|
),
|
|
211
204
|
meta.tags,
|
|
212
205
|
);
|
|
@@ -214,17 +207,17 @@ export namespace SdkTypeProgrammer {
|
|
|
214
207
|
const write_tuple =
|
|
215
208
|
(project: INestiaProject) =>
|
|
216
209
|
(importer: ImportDictionary) =>
|
|
217
|
-
(meta: MetadataTuple):
|
|
218
|
-
|
|
219
|
-
meta.type
|
|
210
|
+
(meta: MetadataTuple): Node =>
|
|
211
|
+
TypeScriptFactory.createTupleTypeNode(
|
|
212
|
+
meta.type!.elements.map((elem) =>
|
|
220
213
|
elem.rest
|
|
221
|
-
?
|
|
222
|
-
|
|
214
|
+
? TypeScriptFactory.createRestTypeNode(
|
|
215
|
+
TypeScriptFactory.createArrayTypeNode(
|
|
223
216
|
write(project)(importer)(elem.rest),
|
|
224
217
|
),
|
|
225
218
|
)
|
|
226
219
|
: elem.optional
|
|
227
|
-
?
|
|
220
|
+
? TypeScriptFactory.createOptionalTypeNode(
|
|
228
221
|
write(project)(importer)(elem),
|
|
229
222
|
)
|
|
230
223
|
: write(project)(importer)(elem),
|
|
@@ -234,34 +227,34 @@ export namespace SdkTypeProgrammer {
|
|
|
234
227
|
const write_regular_property =
|
|
235
228
|
(project: INestiaProject) =>
|
|
236
229
|
(importer: ImportDictionary) =>
|
|
237
|
-
(properties: MetadataProperty[]):
|
|
238
|
-
|
|
230
|
+
(properties: MetadataProperty[]): Node =>
|
|
231
|
+
TypeScriptFactory.createTypeLiteralNode(
|
|
239
232
|
properties
|
|
240
233
|
.map((p) => {
|
|
241
234
|
const description: string = writeComment(p.value.atomics)(
|
|
242
235
|
p.description,
|
|
243
236
|
p.jsDocTags,
|
|
244
237
|
);
|
|
245
|
-
const signature:
|
|
246
|
-
|
|
238
|
+
const signature: Node =
|
|
239
|
+
TypeScriptFactory.createPropertySignature(
|
|
247
240
|
undefined,
|
|
248
241
|
NamingConvention.variable(
|
|
249
242
|
String(p.key.constants[0]!.values[0]!.value),
|
|
250
243
|
)
|
|
251
|
-
?
|
|
244
|
+
? TypeScriptFactory.createIdentifier(
|
|
252
245
|
String(p.key.constants[0]!.values[0]!.value),
|
|
253
246
|
)
|
|
254
|
-
:
|
|
247
|
+
: TypeScriptFactory.createStringLiteral(
|
|
255
248
|
String(p.key.constants[0]!.values[0]!.value),
|
|
256
249
|
),
|
|
257
|
-
p.value.
|
|
258
|
-
?
|
|
250
|
+
p.value.required === false
|
|
251
|
+
? TypeScriptFactory.createToken(SyntaxKind.QuestionToken)
|
|
259
252
|
: undefined,
|
|
260
253
|
SdkTypeProgrammer.write(project)(importer)(p.value),
|
|
261
254
|
);
|
|
262
255
|
return !!description.length
|
|
263
256
|
? [
|
|
264
|
-
|
|
257
|
+
TypeScriptFactory.createIdentifier("\n") as any,
|
|
265
258
|
FilePrinter.description(signature, description),
|
|
266
259
|
]
|
|
267
260
|
: signature;
|
|
@@ -272,16 +265,16 @@ export namespace SdkTypeProgrammer {
|
|
|
272
265
|
const write_dynamic_property =
|
|
273
266
|
(project: INestiaProject) =>
|
|
274
267
|
(importer: ImportDictionary) =>
|
|
275
|
-
(property: MetadataProperty):
|
|
276
|
-
|
|
268
|
+
(property: MetadataProperty): Node =>
|
|
269
|
+
TypeScriptFactory.createTypeLiteralNode([
|
|
277
270
|
FilePrinter.description(
|
|
278
|
-
|
|
271
|
+
TypeScriptFactory.createIndexSignature(
|
|
279
272
|
undefined,
|
|
280
273
|
[
|
|
281
|
-
|
|
274
|
+
TypeScriptFactory.createParameterDeclaration(
|
|
282
275
|
undefined,
|
|
283
276
|
undefined,
|
|
284
|
-
|
|
277
|
+
TypeScriptFactory.createIdentifier("key"),
|
|
285
278
|
undefined,
|
|
286
279
|
SdkTypeProgrammer.write(project)(importer)(property.key),
|
|
287
280
|
),
|
|
@@ -298,13 +291,13 @@ export namespace SdkTypeProgrammer {
|
|
|
298
291
|
const writeAlias =
|
|
299
292
|
(project: INestiaProject) =>
|
|
300
293
|
(importer: ImportDictionary) =>
|
|
301
|
-
(meta: MetadataAliasType | MetadataObjectType):
|
|
294
|
+
(meta: MetadataAliasType | MetadataObjectType): Node => {
|
|
302
295
|
importInternalFile(project)(importer)(meta.name);
|
|
303
|
-
return
|
|
296
|
+
return TypeScriptFactory.createTypeReferenceNode(meta.name);
|
|
304
297
|
};
|
|
305
298
|
|
|
306
|
-
const write_native = (name: string):
|
|
307
|
-
|
|
299
|
+
const write_native = (name: string): Node =>
|
|
300
|
+
TypeScriptFactory.createTypeReferenceNode(name);
|
|
308
301
|
|
|
309
302
|
/* -----------------------------------------------------------
|
|
310
303
|
MISCELLANEOUS
|
|
@@ -313,25 +306,25 @@ export namespace SdkTypeProgrammer {
|
|
|
313
306
|
(importer: ImportDictionary) =>
|
|
314
307
|
(
|
|
315
308
|
from: "array" | "boolean" | "number" | "bigint" | "string" | "object",
|
|
316
|
-
base:
|
|
309
|
+
base: Node,
|
|
317
310
|
matrix: IMetadataTypeTag[][],
|
|
318
|
-
):
|
|
311
|
+
): Node => {
|
|
319
312
|
matrix = matrix.filter((row) => row.length !== 0);
|
|
320
313
|
if (matrix.length === 0) return base;
|
|
321
314
|
else if (matrix.length === 1)
|
|
322
|
-
return
|
|
315
|
+
return TypeScriptFactory.createIntersectionTypeNode([
|
|
323
316
|
base,
|
|
324
317
|
...matrix[0]!.map((tag) =>
|
|
325
318
|
SdkTypeTagProgrammer.write(importer, from, tag),
|
|
326
319
|
),
|
|
327
320
|
]);
|
|
328
|
-
return
|
|
321
|
+
return TypeScriptFactory.createIntersectionTypeNode([
|
|
329
322
|
base,
|
|
330
|
-
|
|
323
|
+
TypeScriptFactory.createUnionTypeNode(
|
|
331
324
|
matrix.map((row) =>
|
|
332
325
|
row.length === 1
|
|
333
326
|
? SdkTypeTagProgrammer.write(importer, from, row[0]!)
|
|
334
|
-
:
|
|
327
|
+
: TypeScriptFactory.createIntersectionTypeNode(
|
|
335
328
|
row.map((tag) =>
|
|
336
329
|
SdkTypeTagProgrammer.write(importer, from, tag),
|
|
337
330
|
),
|
|
@@ -342,7 +335,8 @@ export namespace SdkTypeProgrammer {
|
|
|
342
335
|
};
|
|
343
336
|
}
|
|
344
337
|
|
|
345
|
-
const writeNode = (text: string) =>
|
|
338
|
+
const writeNode = (text: string) =>
|
|
339
|
+
TypeScriptFactory.createTypeReferenceNode(text);
|
|
346
340
|
const writeComment =
|
|
347
341
|
(atomics: MetadataAtomic[]) =>
|
|
348
342
|
(description: string | null, jsDocTags: IJsDocTagInfo[]): string => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TypeScriptFactory } from "@nestia/factory";
|
|
2
|
+
import { LiteralFactory } from "@nestia/factory";
|
|
2
3
|
import { IMetadataTypeTag } from "@typia/interface";
|
|
3
|
-
import ts from "typescript";
|
|
4
4
|
|
|
5
5
|
import { ImportDictionary } from "./ImportDictionary";
|
|
6
6
|
|
|
@@ -12,9 +12,9 @@ export namespace SdkTypeTagProgrammer {
|
|
|
12
12
|
) => {
|
|
13
13
|
const name: string = tag.name.split("<")[0]!;
|
|
14
14
|
if (PREDEFINED[from]?.has(name) === true)
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
return TypeScriptFactory.createTypeReferenceNode(
|
|
16
|
+
TypeScriptFactory.createQualifiedName(
|
|
17
|
+
TypeScriptFactory.createIdentifier(
|
|
18
18
|
importer.external({
|
|
19
19
|
declaration: true,
|
|
20
20
|
file: `typia`,
|
|
@@ -22,17 +22,17 @@ export namespace SdkTypeTagProgrammer {
|
|
|
22
22
|
name: "tags",
|
|
23
23
|
}),
|
|
24
24
|
),
|
|
25
|
-
|
|
25
|
+
TypeScriptFactory.createIdentifier(name),
|
|
26
26
|
),
|
|
27
27
|
[
|
|
28
|
-
|
|
28
|
+
TypeScriptFactory.createLiteralTypeNode(
|
|
29
29
|
LiteralFactory.write(tag.value) as any,
|
|
30
30
|
),
|
|
31
31
|
],
|
|
32
32
|
);
|
|
33
|
-
return
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
return TypeScriptFactory.createTypeReferenceNode(
|
|
34
|
+
TypeScriptFactory.createQualifiedName(
|
|
35
|
+
TypeScriptFactory.createIdentifier(
|
|
36
36
|
importer.external({
|
|
37
37
|
declaration: true,
|
|
38
38
|
file: `typia`,
|
|
@@ -40,10 +40,10 @@ export namespace SdkTypeTagProgrammer {
|
|
|
40
40
|
name: "tags",
|
|
41
41
|
}),
|
|
42
42
|
),
|
|
43
|
-
|
|
43
|
+
TypeScriptFactory.createIdentifier("TagBase"),
|
|
44
44
|
),
|
|
45
45
|
[
|
|
46
|
-
|
|
46
|
+
TypeScriptFactory.createLiteralTypeNode(
|
|
47
47
|
LiteralFactory.write({
|
|
48
48
|
target: from,
|
|
49
49
|
kind: tag.kind,
|