typia 5.0.4 → 5.0.5-dev.20230921
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/README.md +1 -1
- package/package.json +1 -1
- package/src/IRandomGenerator.ts +35 -35
- package/src/IValidation.ts +21 -21
- package/src/Primitive.ts +135 -135
- package/src/Resolved.ts +116 -116
- package/src/TypeGuardError.ts +36 -36
- package/src/executable/TypiaGenerateWizard.ts +85 -85
- package/src/executable/TypiaSetupWizard.ts +153 -153
- package/src/executable/setup/ArgumentParser.ts +45 -45
- package/src/executable/setup/CommandExecutor.ts +8 -8
- package/src/executable/setup/FileRetriever.ts +22 -22
- package/src/executable/setup/PackageManager.ts +71 -71
- package/src/executable/setup/PluginConfigurator.ts +70 -70
- package/src/executable/typia.ts +52 -52
- package/src/factories/CommentFactory.ts +84 -84
- package/src/factories/ExpressionFactory.ts +159 -159
- package/src/factories/IdentifierFactory.ts +74 -74
- package/src/factories/JsonMetadataFactory.ts +43 -43
- package/src/factories/LiteralFactory.ts +47 -47
- package/src/factories/MetadataCollection.ts +269 -269
- package/src/factories/MetadataCommentTagFactory.ts +629 -629
- package/src/factories/MetadataFactory.ts +214 -214
- package/src/factories/MetadataTypeTagFactory.ts +313 -313
- package/src/factories/NumericRangeFactory.ts +33 -33
- package/src/factories/ProtobufFactory.ts +272 -272
- package/src/factories/StatementFactory.ts +72 -72
- package/src/factories/TemplateFactory.ts +58 -58
- package/src/factories/TypeFactory.ts +119 -119
- package/src/factories/ValueFactory.ts +12 -12
- package/src/factories/internal/metadata/MetadataHelper.ts +12 -12
- package/src/factories/internal/metadata/emend_metadata_atomics.ts +40 -40
- package/src/factories/internal/metadata/emplace_metadata_alias.ts +41 -41
- package/src/factories/internal/metadata/emplace_metadata_array_type.ts +41 -41
- package/src/factories/internal/metadata/emplace_metadata_object.ts +150 -150
- package/src/factories/internal/metadata/emplace_metadata_tuple.ts +60 -60
- package/src/factories/internal/metadata/explore_metadata.ts +32 -32
- package/src/factories/internal/metadata/iterate_metadata.ts +101 -101
- package/src/factories/internal/metadata/iterate_metadata_alias.ts +35 -35
- package/src/factories/internal/metadata/iterate_metadata_array.ts +37 -37
- package/src/factories/internal/metadata/iterate_metadata_atomic.ts +62 -62
- package/src/factories/internal/metadata/iterate_metadata_coalesce.ts +33 -33
- package/src/factories/internal/metadata/iterate_metadata_collection.ts +141 -141
- package/src/factories/internal/metadata/iterate_metadata_comment_tags.ts +26 -26
- package/src/factories/internal/metadata/iterate_metadata_constant.ts +58 -58
- package/src/factories/internal/metadata/iterate_metadata_intersection.ts +197 -197
- package/src/factories/internal/metadata/iterate_metadata_map.ts +57 -57
- package/src/factories/internal/metadata/iterate_metadata_native.ts +210 -210
- package/src/factories/internal/metadata/iterate_metadata_object.ts +44 -44
- package/src/factories/internal/metadata/iterate_metadata_resolve.ts +52 -52
- package/src/factories/internal/metadata/iterate_metadata_set.ts +42 -42
- package/src/factories/internal/metadata/iterate_metadata_sort.ts +69 -69
- package/src/factories/internal/metadata/iterate_metadata_template.ts +47 -47
- package/src/factories/internal/metadata/iterate_metadata_tuple.ts +37 -37
- package/src/factories/internal/metadata/iterate_metadata_union.ts +27 -27
- package/src/functional/$ProtobufReader.ts +201 -201
- package/src/functional/$ProtobufSizer.ts +147 -147
- package/src/functional/$ProtobufWriter.ts +151 -151
- package/src/functional/$any.ts +4 -4
- package/src/functional/$clone.ts +4 -4
- package/src/functional/$dictionary.ts +25 -25
- package/src/functional/$every.ts +11 -11
- package/src/functional/$guard.ts +35 -35
- package/src/functional/$is_between.ts +2 -2
- package/src/functional/$join.ts +46 -46
- package/src/functional/$number.ts +13 -13
- package/src/functional/$report.ts +15 -15
- package/src/functional/$rest.ts +3 -3
- package/src/functional/$string.ts +50 -50
- package/src/functional/$strlen.ts +7 -7
- package/src/functional/$tail.ts +5 -5
- package/src/functional/$varint.ts +130 -130
- package/src/functional/$zigzag.ts +39 -39
- package/src/functional/IProtobufWriter.ts +18 -18
- package/src/functional/Namespace.ts +133 -133
- package/src/index.ts +4 -4
- package/src/json.ts +648 -648
- package/src/misc.ts +651 -651
- package/src/module.ts +656 -656
- package/src/programmers/AssertProgrammer.ts +317 -317
- package/src/programmers/CheckerProgrammer.ts +1137 -1137
- package/src/programmers/FeatureProgrammer.ts +478 -478
- package/src/programmers/IsProgrammer.ts +252 -252
- package/src/programmers/RandomProgrammer.ts +878 -878
- package/src/programmers/TypiaProgrammer.ts +163 -163
- package/src/programmers/ValidateProgrammer.ts +346 -346
- package/src/programmers/helpers/AtomicPredicator.ts +31 -31
- package/src/programmers/helpers/CloneJoiner.ts +144 -144
- package/src/programmers/helpers/FunctionImporeter.ts +91 -91
- package/src/programmers/helpers/ICheckEntry.ts +13 -13
- package/src/programmers/helpers/IExpressionEntry.ts +12 -12
- package/src/programmers/helpers/OptionPredicator.ts +15 -15
- package/src/programmers/helpers/ProtobufUtil.ts +125 -125
- package/src/programmers/helpers/ProtobufWire.ts +34 -34
- package/src/programmers/helpers/PruneJoiner.ts +143 -143
- package/src/programmers/helpers/RandomJoiner.ts +151 -151
- package/src/programmers/helpers/RandomRanger.ts +173 -173
- package/src/programmers/helpers/StringifyJoinder.ts +113 -113
- package/src/programmers/helpers/StringifyPredicator.ts +12 -12
- package/src/programmers/helpers/UnionExplorer.ts +305 -305
- package/src/programmers/helpers/UnionPredicator.ts +81 -81
- package/src/programmers/helpers/disable_function_importer_declare.ts +32 -32
- package/src/programmers/internal/JSON_SCHEMA_PREFIX.ts +1 -1
- package/src/programmers/internal/application_alias.ts +65 -65
- package/src/programmers/internal/application_array.ts +53 -53
- package/src/programmers/internal/application_boolean.ts +15 -15
- package/src/programmers/internal/application_constant.ts +26 -26
- package/src/programmers/internal/application_default.ts +17 -17
- package/src/programmers/internal/application_default_string.ts +37 -37
- package/src/programmers/internal/application_escaped.ts +55 -55
- package/src/programmers/internal/application_native.ts +39 -39
- package/src/programmers/internal/application_number.ts +88 -88
- package/src/programmers/internal/application_object.ts +162 -162
- package/src/programmers/internal/application_schema.ts +175 -175
- package/src/programmers/internal/application_string.ts +51 -51
- package/src/programmers/internal/application_templates.ts +25 -25
- package/src/programmers/internal/application_tuple.ts +58 -58
- package/src/programmers/internal/check_array_length.ts +41 -41
- package/src/programmers/internal/check_bigint.ts +45 -45
- package/src/programmers/internal/check_dynamic_properties.ts +194 -194
- package/src/programmers/internal/check_everything.ts +28 -28
- package/src/programmers/internal/check_native.ts +21 -21
- package/src/programmers/internal/check_number.ts +105 -105
- package/src/programmers/internal/check_object.ts +55 -55
- package/src/programmers/internal/check_string.ts +45 -45
- package/src/programmers/internal/check_template.ts +61 -61
- package/src/programmers/internal/check_union_array_like.ts +323 -323
- package/src/programmers/internal/decode_union_object.ts +84 -84
- package/src/programmers/internal/feature_object_entries.ts +58 -58
- package/src/programmers/internal/metadata_to_pattern.ts +34 -34
- package/src/programmers/internal/prune_object_properties.ts +60 -60
- package/src/programmers/internal/random_custom.ts +37 -37
- package/src/programmers/internal/stringify_dynamic_properties.ts +171 -171
- package/src/programmers/internal/stringify_native.ts +7 -7
- package/src/programmers/internal/stringify_regular_properties.ts +83 -83
- package/src/programmers/internal/template_to_pattern.ts +15 -15
- package/src/programmers/internal/wrap_metadata_rest_tuple.ts +20 -20
- package/src/programmers/json/JsonApplicationProgrammer.ts +50 -50
- package/src/programmers/json/JsonAssertParseProgrammer.ts +71 -71
- package/src/programmers/json/JsonAssertStringifyProgrammer.ts +66 -66
- package/src/programmers/json/JsonIsParseProgrammer.ts +77 -77
- package/src/programmers/json/JsonIsStringifyProgrammer.ts +76 -76
- package/src/programmers/json/JsonStringifyProgrammer.ts +964 -964
- package/src/programmers/json/JsonValidateParseProgrammer.ts +68 -68
- package/src/programmers/json/JsonValidateStringifyProgrammer.ts +84 -84
- package/src/programmers/misc/MiscAssertCloneProgrammer.ts +71 -71
- package/src/programmers/misc/MiscAssertPruneProgrammer.ts +68 -68
- package/src/programmers/misc/MiscCloneProgrammer.ts +774 -774
- package/src/programmers/misc/MiscIsCloneProgrammer.ts +78 -78
- package/src/programmers/misc/MiscIsPruneProgrammer.ts +73 -73
- package/src/programmers/misc/MiscLiteralsProgrammer.ts +69 -69
- package/src/programmers/misc/MiscPruneProgrammer.ts +550 -550
- package/src/programmers/misc/MiscValidateCloneProgrammer.ts +85 -85
- package/src/programmers/misc/MiscValidatePruneProgrammer.ts +78 -78
- package/src/programmers/protobuf/ProtobufAssertDecodeProgrammer.ts +75 -75
- package/src/programmers/protobuf/ProtobufAssertEncodeProgrammer.ts +66 -66
- package/src/programmers/protobuf/ProtobufDecodeProgrammer.ts +655 -655
- package/src/programmers/protobuf/ProtobufEncodeProgrammer.ts +883 -883
- package/src/programmers/protobuf/ProtobufIsDecodeProgrammer.ts +85 -85
- package/src/programmers/protobuf/ProtobufIsEncodeProgrammer.ts +76 -76
- package/src/programmers/protobuf/ProtobufMessageProgrammer.ts +165 -165
- package/src/programmers/protobuf/ProtobufValidateDecodeProgrammer.ts +75 -75
- package/src/programmers/protobuf/ProtobufValidateEncodeProgrammer.ts +86 -86
- package/src/protobuf.ts +881 -881
- package/src/schemas/json/IJsonApplication.ts +8 -8
- package/src/schemas/json/IJsonComponents.ts +33 -33
- package/src/schemas/json/IJsonSchema.ts +110 -110
- package/src/schemas/metadata/IJsDocTagInfo.ts +10 -10
- package/src/schemas/metadata/IMetadata.ts +34 -34
- package/src/schemas/metadata/IMetadataAlias.ts +12 -12
- package/src/schemas/metadata/IMetadataApplication.ts +7 -7
- package/src/schemas/metadata/IMetadataArray.ts +7 -7
- package/src/schemas/metadata/IMetadataArrayType.ts +10 -10
- package/src/schemas/metadata/IMetadataAtomic.ts +6 -6
- package/src/schemas/metadata/IMetadataCollection.ts +11 -11
- package/src/schemas/metadata/IMetadataConstant.ts +16 -16
- package/src/schemas/metadata/IMetadataDictionary.ts +14 -14
- package/src/schemas/metadata/IMetadataEntry.ts +6 -6
- package/src/schemas/metadata/IMetadataEscaped.ts +6 -6
- package/src/schemas/metadata/IMetadataObject.ts +18 -18
- package/src/schemas/metadata/IMetadataProperty.ts +9 -9
- package/src/schemas/metadata/IMetadataTuple.ts +7 -7
- package/src/schemas/metadata/IMetadataTupleType.ts +10 -10
- package/src/schemas/metadata/IMetadataTypeTag.ts +8 -8
- package/src/schemas/metadata/Metadata.ts +685 -685
- package/src/schemas/metadata/MetadataAlias.ts +61 -61
- package/src/schemas/metadata/MetadataArray.ts +49 -49
- package/src/schemas/metadata/MetadataArrayType.ts +57 -57
- package/src/schemas/metadata/MetadataAtomic.ts +42 -42
- package/src/schemas/metadata/MetadataConstant.ts +3 -3
- package/src/schemas/metadata/MetadataEscaped.ts +51 -51
- package/src/schemas/metadata/MetadataObject.ts +139 -139
- package/src/schemas/metadata/MetadataProperty.ts +59 -59
- package/src/schemas/metadata/MetadataTuple.ts +32 -32
- package/src/schemas/metadata/MetadataTupleType.ts +67 -67
- package/src/tags/ExclusiveMaximum.ts +13 -13
- package/src/tags/ExclusiveMinimum.ts +13 -13
- package/src/tags/Format.ts +30 -30
- package/src/tags/MaxItems.ts +9 -9
- package/src/tags/MaxLength.ts +9 -9
- package/src/tags/Maximum.ts +13 -13
- package/src/tags/MinItems.ts +9 -9
- package/src/tags/MinLength.ts +9 -9
- package/src/tags/Minimum.ts +13 -13
- package/src/tags/MultipleOf.ts +15 -15
- package/src/tags/Pattern.ts +8 -8
- package/src/tags/TagBase.ts +68 -68
- package/src/tags/Type.ts +27 -27
- package/src/tags/index.ts +13 -13
- package/src/transform.ts +35 -35
- package/src/transformers/CallExpressionTransformer.ts +243 -243
- package/src/transformers/FileTransformer.ts +57 -57
- package/src/transformers/IProject.ts +15 -15
- package/src/transformers/ITransformOptions.ts +62 -62
- package/src/transformers/ImportTransformer.ts +66 -66
- package/src/transformers/NodeTransformer.ts +13 -13
- package/src/transformers/TransformerError.ts +55 -55
- package/src/transformers/features/AssertTransformer.ts +11 -11
- package/src/transformers/features/CreateAssertTransformer.ts +13 -13
- package/src/transformers/features/CreateIsTransformer.ts +11 -11
- package/src/transformers/features/CreateRandomTransformer.ts +43 -43
- package/src/transformers/features/CreateValidateTransformer.ts +13 -13
- package/src/transformers/features/IsTransformer.ts +11 -11
- package/src/transformers/features/RandomTransformer.ts +46 -46
- package/src/transformers/features/ValidateTransformer.ts +11 -11
- package/src/transformers/features/json/JsonApplicationTransformer.ts +118 -118
- package/src/transformers/features/json/JsonAssertParseTransformer.ts +10 -10
- package/src/transformers/features/json/JsonAssertStringifyTransformer.ts +10 -10
- package/src/transformers/features/json/JsonCreateAssertParseTransformer.ts +10 -10
- package/src/transformers/features/json/JsonCreateAssertStringifyTransformer.ts +12 -12
- package/src/transformers/features/json/JsonCreateIsParseTransformer.ts +9 -9
- package/src/transformers/features/json/JsonCreateIsStringifyTransformer.ts +10 -10
- package/src/transformers/features/json/JsonCreateStringifyTransformer.ts +9 -9
- package/src/transformers/features/json/JsonCreateValidateParseTransformer.ts +10 -10
- package/src/transformers/features/json/JsonCreateValidateStringifyProgrammer.ts +12 -12
- package/src/transformers/features/json/JsonIsParseTransformer.ts +9 -9
- package/src/transformers/features/json/JsonIsStringifyTransformer.ts +10 -10
- package/src/transformers/features/json/JsonStringifyTransformer.ts +9 -9
- package/src/transformers/features/json/JsonValidateParseTransformer.ts +10 -10
- package/src/transformers/features/json/JsonValidateStringifyTransformer.ts +10 -10
- package/src/transformers/features/misc/MetadataTransformer.ts +61 -61
- package/src/transformers/features/misc/MiscAssertCloneTransformer.ts +10 -10
- package/src/transformers/features/misc/MiscAssertPruneTransformer.ts +10 -10
- package/src/transformers/features/misc/MiscCloneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscCreateAssertCloneTransformer.ts +10 -10
- package/src/transformers/features/misc/MiscCreateAssertPruneTransformer.ts +10 -10
- package/src/transformers/features/misc/MiscCreateCloneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscCreateIsCloneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscCreateIsPruneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscCreatePruneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscCreateValidateCloneTransformer.ts +10 -10
- package/src/transformers/features/misc/MiscCreateValidatePruneTransformer.ts +10 -10
- package/src/transformers/features/misc/MiscIsCloneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscIsPruneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscLiteralsTransformer.ts +32 -32
- package/src/transformers/features/misc/MiscPruneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscValidateCloneTransformer.ts +10 -10
- package/src/transformers/features/misc/MiscValidatePruneTransformer.ts +10 -10
- package/src/transformers/features/protobuf/CreateProtobufAssertDecodeTransformer.ts +12 -12
- package/src/transformers/features/protobuf/CreateProtobufAssertEncodeTransformer.ts +12 -12
- package/src/transformers/features/protobuf/CreateProtobufDecodeTransformer.ts +9 -9
- package/src/transformers/features/protobuf/CreateProtobufEncodeTransformer.ts +9 -9
- package/src/transformers/features/protobuf/CreateProtobufIsDecodeTransformer.ts +12 -12
- package/src/transformers/features/protobuf/CreateProtobufIsEncodeTransformer.ts +12 -12
- package/src/transformers/features/protobuf/CreateProtobufValidateDecodeTransformer.ts +12 -12
- package/src/transformers/features/protobuf/CreateProtobufValidateEncodeTransformer.ts +12 -12
- package/src/transformers/features/protobuf/ProtobufAssertDecodeTransformer.ts +10 -10
- package/src/transformers/features/protobuf/ProtobufAssertEncodeTransformer.ts +10 -10
- package/src/transformers/features/protobuf/ProtobufDecodeTransformer.ts +10 -10
- package/src/transformers/features/protobuf/ProtobufEncodeTransformer.ts +10 -10
- package/src/transformers/features/protobuf/ProtobufIsDecodeTransformer.ts +10 -10
- package/src/transformers/features/protobuf/ProtobufIsEncodeTransformer.ts +10 -10
- package/src/transformers/features/protobuf/ProtobufMessageTransformer.ts +33 -33
- package/src/transformers/features/protobuf/ProtobufValidateDecodeTransformer.ts +12 -12
- package/src/transformers/features/protobuf/ProtobufValidateEncodeTransformer.ts +12 -12
- package/src/transformers/internal/GenericTransformer.ts +104 -104
- package/src/typings/Atomic.ts +18 -18
- package/src/typings/ClassProperties.ts +5 -5
- package/src/typings/Customizable.ts +5 -5
- package/src/typings/OmitNever.ts +3 -3
- package/src/typings/ProtobufAtomic.ts +19 -19
- package/src/typings/SpecialFields.ts +3 -3
- package/src/typings/ValidationPipe.ts +9 -9
- package/src/typings/Writable.ts +11 -11
- package/src/utils/ArrayUtil.ts +45 -45
- package/src/utils/Escaper.ts +46 -46
- package/src/utils/MapUtil.ts +12 -12
- package/src/utils/NameEncoder.ts +32 -32
- package/src/utils/PatternUtil.ts +33 -33
- package/src/utils/RandomGenerator.ts +83 -83
- package/src/utils/Singleton.ts +17 -17
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
-
import { MetadataAlias } from "../../../schemas/metadata/MetadataAlias";
|
|
5
|
-
|
|
6
|
-
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
7
|
-
|
|
8
|
-
import { MetadataCollection } from "../../MetadataCollection";
|
|
9
|
-
import { MetadataFactory } from "../../MetadataFactory";
|
|
10
|
-
import { explore_metadata } from "./explore_metadata";
|
|
11
|
-
|
|
12
|
-
export const emplace_metadata_alias =
|
|
13
|
-
(checker: ts.TypeChecker) =>
|
|
14
|
-
(options: MetadataFactory.IOptions) =>
|
|
15
|
-
(collection: MetadataCollection) =>
|
|
16
|
-
(errors: MetadataFactory.IError[]) =>
|
|
17
|
-
(
|
|
18
|
-
type: ts.Type,
|
|
19
|
-
nullable: boolean,
|
|
20
|
-
explore: MetadataFactory.IExplore,
|
|
21
|
-
): MetadataAlias => {
|
|
22
|
-
// CHECK EXISTENCE
|
|
23
|
-
const [alias, newbie, closure] = collection.emplaceAlias(
|
|
24
|
-
checker,
|
|
25
|
-
type,
|
|
26
|
-
type.aliasSymbol!,
|
|
27
|
-
);
|
|
28
|
-
ArrayUtil.add(alias.nullables, nullable);
|
|
29
|
-
if (newbie === false) return alias;
|
|
30
|
-
|
|
31
|
-
// CONSTRUCT VALUE TYPE
|
|
32
|
-
const value: Metadata = explore_metadata(checker)(options)(collection)(
|
|
33
|
-
errors,
|
|
34
|
-
)(type, {
|
|
35
|
-
...explore,
|
|
36
|
-
escaped: false,
|
|
37
|
-
aliased: true,
|
|
38
|
-
});
|
|
39
|
-
closure(value);
|
|
40
|
-
return alias;
|
|
41
|
-
};
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
+
import { MetadataAlias } from "../../../schemas/metadata/MetadataAlias";
|
|
5
|
+
|
|
6
|
+
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
7
|
+
|
|
8
|
+
import { MetadataCollection } from "../../MetadataCollection";
|
|
9
|
+
import { MetadataFactory } from "../../MetadataFactory";
|
|
10
|
+
import { explore_metadata } from "./explore_metadata";
|
|
11
|
+
|
|
12
|
+
export const emplace_metadata_alias =
|
|
13
|
+
(checker: ts.TypeChecker) =>
|
|
14
|
+
(options: MetadataFactory.IOptions) =>
|
|
15
|
+
(collection: MetadataCollection) =>
|
|
16
|
+
(errors: MetadataFactory.IError[]) =>
|
|
17
|
+
(
|
|
18
|
+
type: ts.Type,
|
|
19
|
+
nullable: boolean,
|
|
20
|
+
explore: MetadataFactory.IExplore,
|
|
21
|
+
): MetadataAlias => {
|
|
22
|
+
// CHECK EXISTENCE
|
|
23
|
+
const [alias, newbie, closure] = collection.emplaceAlias(
|
|
24
|
+
checker,
|
|
25
|
+
type,
|
|
26
|
+
type.aliasSymbol!,
|
|
27
|
+
);
|
|
28
|
+
ArrayUtil.add(alias.nullables, nullable);
|
|
29
|
+
if (newbie === false) return alias;
|
|
30
|
+
|
|
31
|
+
// CONSTRUCT VALUE TYPE
|
|
32
|
+
const value: Metadata = explore_metadata(checker)(options)(collection)(
|
|
33
|
+
errors,
|
|
34
|
+
)(type, {
|
|
35
|
+
...explore,
|
|
36
|
+
escaped: false,
|
|
37
|
+
aliased: true,
|
|
38
|
+
});
|
|
39
|
+
closure(value);
|
|
40
|
+
return alias;
|
|
41
|
+
};
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
-
import { MetadataArrayType } from "../../../schemas/metadata/MetadataArrayType";
|
|
5
|
-
|
|
6
|
-
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
7
|
-
|
|
8
|
-
import { MetadataCollection } from "../../MetadataCollection";
|
|
9
|
-
import { MetadataFactory } from "../../MetadataFactory";
|
|
10
|
-
import { explore_metadata } from "./explore_metadata";
|
|
11
|
-
|
|
12
|
-
export const emplace_metadata_array_type =
|
|
13
|
-
(checker: ts.TypeChecker) =>
|
|
14
|
-
(options: MetadataFactory.IOptions) =>
|
|
15
|
-
(collection: MetadataCollection) =>
|
|
16
|
-
(errors: MetadataFactory.IError[]) =>
|
|
17
|
-
(
|
|
18
|
-
type: ts.Type,
|
|
19
|
-
nullable: boolean,
|
|
20
|
-
explore: MetadataFactory.IExplore,
|
|
21
|
-
): MetadataArrayType => {
|
|
22
|
-
// CHECK EXISTENCE
|
|
23
|
-
const [array, newbie, setValue] = collection.emplaceArray(
|
|
24
|
-
checker,
|
|
25
|
-
type,
|
|
26
|
-
);
|
|
27
|
-
ArrayUtil.add(array.nullables, nullable);
|
|
28
|
-
if (newbie === false) return array;
|
|
29
|
-
|
|
30
|
-
// CONSTRUCT VALUE TYPE
|
|
31
|
-
const value: Metadata = explore_metadata(checker)(options)(collection)(
|
|
32
|
-
errors,
|
|
33
|
-
)(type.getNumberIndexType()!, {
|
|
34
|
-
...explore,
|
|
35
|
-
escaped: false,
|
|
36
|
-
aliased: false,
|
|
37
|
-
});
|
|
38
|
-
setValue(value);
|
|
39
|
-
|
|
40
|
-
return array;
|
|
41
|
-
};
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
+
import { MetadataArrayType } from "../../../schemas/metadata/MetadataArrayType";
|
|
5
|
+
|
|
6
|
+
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
7
|
+
|
|
8
|
+
import { MetadataCollection } from "../../MetadataCollection";
|
|
9
|
+
import { MetadataFactory } from "../../MetadataFactory";
|
|
10
|
+
import { explore_metadata } from "./explore_metadata";
|
|
11
|
+
|
|
12
|
+
export const emplace_metadata_array_type =
|
|
13
|
+
(checker: ts.TypeChecker) =>
|
|
14
|
+
(options: MetadataFactory.IOptions) =>
|
|
15
|
+
(collection: MetadataCollection) =>
|
|
16
|
+
(errors: MetadataFactory.IError[]) =>
|
|
17
|
+
(
|
|
18
|
+
type: ts.Type,
|
|
19
|
+
nullable: boolean,
|
|
20
|
+
explore: MetadataFactory.IExplore,
|
|
21
|
+
): MetadataArrayType => {
|
|
22
|
+
// CHECK EXISTENCE
|
|
23
|
+
const [array, newbie, setValue] = collection.emplaceArray(
|
|
24
|
+
checker,
|
|
25
|
+
type,
|
|
26
|
+
);
|
|
27
|
+
ArrayUtil.add(array.nullables, nullable);
|
|
28
|
+
if (newbie === false) return array;
|
|
29
|
+
|
|
30
|
+
// CONSTRUCT VALUE TYPE
|
|
31
|
+
const value: Metadata = explore_metadata(checker)(options)(collection)(
|
|
32
|
+
errors,
|
|
33
|
+
)(type.getNumberIndexType()!, {
|
|
34
|
+
...explore,
|
|
35
|
+
escaped: false,
|
|
36
|
+
aliased: false,
|
|
37
|
+
});
|
|
38
|
+
setValue(value);
|
|
39
|
+
|
|
40
|
+
return array;
|
|
41
|
+
};
|
|
@@ -1,150 +1,150 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
-
import { MetadataObject } from "../../../schemas/metadata/MetadataObject";
|
|
5
|
-
import { MetadataProperty } from "../../../schemas/metadata/MetadataProperty";
|
|
6
|
-
|
|
7
|
-
import { Writable } from "../../../typings/Writable";
|
|
8
|
-
|
|
9
|
-
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
10
|
-
|
|
11
|
-
import { CommentFactory } from "../../CommentFactory";
|
|
12
|
-
import { MetadataCollection } from "../../MetadataCollection";
|
|
13
|
-
import { MetadataFactory } from "../../MetadataFactory";
|
|
14
|
-
import { MetadataHelper } from "./MetadataHelper";
|
|
15
|
-
import { explore_metadata } from "./explore_metadata";
|
|
16
|
-
|
|
17
|
-
export const emplace_metadata_object =
|
|
18
|
-
(checker: ts.TypeChecker) =>
|
|
19
|
-
(options: MetadataFactory.IOptions) =>
|
|
20
|
-
(collection: MetadataCollection) =>
|
|
21
|
-
(errors: MetadataFactory.IError[]) =>
|
|
22
|
-
(parent: ts.Type, nullable: boolean): MetadataObject => {
|
|
23
|
-
// EMPLACE OBJECT
|
|
24
|
-
const [obj, newbie] = collection.emplace(checker, parent);
|
|
25
|
-
ArrayUtil.add(obj.nullables, nullable, (elem) => elem === nullable);
|
|
26
|
-
|
|
27
|
-
if (newbie === false) return obj;
|
|
28
|
-
|
|
29
|
-
// PREPARE ASSETS
|
|
30
|
-
const isClass: boolean = parent.isClass();
|
|
31
|
-
const pred: (node: ts.Declaration) => boolean = isClass
|
|
32
|
-
? (node) => {
|
|
33
|
-
const kind: ts.SyntaxKind | undefined = node
|
|
34
|
-
.getChildren()[0]
|
|
35
|
-
?.getChildren()[0]?.kind;
|
|
36
|
-
return (
|
|
37
|
-
kind !== ts.SyntaxKind.PrivateKeyword &&
|
|
38
|
-
kind !== ts.SyntaxKind.ProtectedKeyword &&
|
|
39
|
-
(ts.isParameter(node) || isProperty(node))
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
: (node) => isProperty(node);
|
|
43
|
-
|
|
44
|
-
const insert =
|
|
45
|
-
(key: Metadata) =>
|
|
46
|
-
(value: Metadata) =>
|
|
47
|
-
(
|
|
48
|
-
symbol: ts.Symbol | undefined,
|
|
49
|
-
filter?: (doc: ts.JSDocTagInfo) => boolean,
|
|
50
|
-
): MetadataProperty => {
|
|
51
|
-
// COMMENTS AND TAGS
|
|
52
|
-
const description: string | null = symbol
|
|
53
|
-
? CommentFactory.description(symbol) ?? null
|
|
54
|
-
: null;
|
|
55
|
-
const jsDocTags: ts.JSDocTagInfo[] = (
|
|
56
|
-
symbol?.getJsDocTags() ?? []
|
|
57
|
-
).filter(filter ?? (() => true));
|
|
58
|
-
|
|
59
|
-
// THE PROPERTY
|
|
60
|
-
const property = MetadataProperty.create({
|
|
61
|
-
key,
|
|
62
|
-
value,
|
|
63
|
-
description,
|
|
64
|
-
jsDocTags,
|
|
65
|
-
});
|
|
66
|
-
obj.properties.push(property);
|
|
67
|
-
return property;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
//----
|
|
71
|
-
// REGULAR PROPERTIES
|
|
72
|
-
//----
|
|
73
|
-
for (const prop of parent.getApparentProperties()) {
|
|
74
|
-
// CHECK INTERNAL TAG
|
|
75
|
-
if (
|
|
76
|
-
(prop.getJsDocTags(checker) ?? []).find(
|
|
77
|
-
(tag) => tag.name === "internal",
|
|
78
|
-
) !== undefined
|
|
79
|
-
)
|
|
80
|
-
continue;
|
|
81
|
-
|
|
82
|
-
// CHECK NODE IS A FORMAL PROPERTY
|
|
83
|
-
const [node, type] = (() => {
|
|
84
|
-
const node = (prop.getDeclarations() ?? [])[0] as
|
|
85
|
-
| ts.PropertyDeclaration
|
|
86
|
-
| undefined;
|
|
87
|
-
const type: ts.Type | undefined = node
|
|
88
|
-
? checker.getTypeOfSymbolAtLocation(prop, node)
|
|
89
|
-
: "getTypeOfPropertyOfType" in checker
|
|
90
|
-
? (checker as any).getTypeOfPropertyOfType(
|
|
91
|
-
parent,
|
|
92
|
-
prop.name,
|
|
93
|
-
)
|
|
94
|
-
: undefined;
|
|
95
|
-
return [node, type];
|
|
96
|
-
})();
|
|
97
|
-
if ((node && pred(node) === false) || type === undefined) continue;
|
|
98
|
-
|
|
99
|
-
// GET EXACT TYPE
|
|
100
|
-
const key: Metadata = MetadataHelper.literal_to_metadata(prop.name);
|
|
101
|
-
const value: Metadata = explore_metadata(checker)(options)(
|
|
102
|
-
collection,
|
|
103
|
-
)(errors)(type, {
|
|
104
|
-
top: false,
|
|
105
|
-
object: obj,
|
|
106
|
-
property: prop.name,
|
|
107
|
-
nested: null,
|
|
108
|
-
escaped: false,
|
|
109
|
-
aliased: false,
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
// OPTIONAL, BUT CAN BE RQUIRED BY `Required<T>` TYPE
|
|
113
|
-
if (node?.questionToken) Writable(value).optional = true;
|
|
114
|
-
insert(key)(value)(prop);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
//----
|
|
118
|
-
// DYNAMIC PROPERTIES
|
|
119
|
-
//----
|
|
120
|
-
for (const index of checker.getIndexInfosOfType(parent)) {
|
|
121
|
-
// GET EXACT TYPE
|
|
122
|
-
const analyzer = (type: ts.Type) => (property: {} | null) =>
|
|
123
|
-
explore_metadata(checker)(options)(collection)(errors)(type, {
|
|
124
|
-
top: false,
|
|
125
|
-
object: obj,
|
|
126
|
-
property,
|
|
127
|
-
nested: null,
|
|
128
|
-
escaped: false,
|
|
129
|
-
aliased: false,
|
|
130
|
-
});
|
|
131
|
-
const key: Metadata = analyzer(index.keyType)(null);
|
|
132
|
-
const value: Metadata = analyzer(index.type)({});
|
|
133
|
-
|
|
134
|
-
// INSERT WITH REQUIRED CONFIGURATION
|
|
135
|
-
insert(key)(value)(
|
|
136
|
-
index.declaration?.parent
|
|
137
|
-
? checker.getSymbolAtLocation(index.declaration.parent)
|
|
138
|
-
: undefined,
|
|
139
|
-
(doc) => doc.name !== "default",
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return obj;
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
const isProperty = (node: ts.Declaration) =>
|
|
147
|
-
ts.isPropertyDeclaration(node) ||
|
|
148
|
-
ts.isPropertyAssignment(node) ||
|
|
149
|
-
ts.isPropertySignature(node) ||
|
|
150
|
-
ts.isTypeLiteralNode(node);
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
+
import { MetadataObject } from "../../../schemas/metadata/MetadataObject";
|
|
5
|
+
import { MetadataProperty } from "../../../schemas/metadata/MetadataProperty";
|
|
6
|
+
|
|
7
|
+
import { Writable } from "../../../typings/Writable";
|
|
8
|
+
|
|
9
|
+
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
10
|
+
|
|
11
|
+
import { CommentFactory } from "../../CommentFactory";
|
|
12
|
+
import { MetadataCollection } from "../../MetadataCollection";
|
|
13
|
+
import { MetadataFactory } from "../../MetadataFactory";
|
|
14
|
+
import { MetadataHelper } from "./MetadataHelper";
|
|
15
|
+
import { explore_metadata } from "./explore_metadata";
|
|
16
|
+
|
|
17
|
+
export const emplace_metadata_object =
|
|
18
|
+
(checker: ts.TypeChecker) =>
|
|
19
|
+
(options: MetadataFactory.IOptions) =>
|
|
20
|
+
(collection: MetadataCollection) =>
|
|
21
|
+
(errors: MetadataFactory.IError[]) =>
|
|
22
|
+
(parent: ts.Type, nullable: boolean): MetadataObject => {
|
|
23
|
+
// EMPLACE OBJECT
|
|
24
|
+
const [obj, newbie] = collection.emplace(checker, parent);
|
|
25
|
+
ArrayUtil.add(obj.nullables, nullable, (elem) => elem === nullable);
|
|
26
|
+
|
|
27
|
+
if (newbie === false) return obj;
|
|
28
|
+
|
|
29
|
+
// PREPARE ASSETS
|
|
30
|
+
const isClass: boolean = parent.isClass();
|
|
31
|
+
const pred: (node: ts.Declaration) => boolean = isClass
|
|
32
|
+
? (node) => {
|
|
33
|
+
const kind: ts.SyntaxKind | undefined = node
|
|
34
|
+
.getChildren()[0]
|
|
35
|
+
?.getChildren()[0]?.kind;
|
|
36
|
+
return (
|
|
37
|
+
kind !== ts.SyntaxKind.PrivateKeyword &&
|
|
38
|
+
kind !== ts.SyntaxKind.ProtectedKeyword &&
|
|
39
|
+
(ts.isParameter(node) || isProperty(node))
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
: (node) => isProperty(node);
|
|
43
|
+
|
|
44
|
+
const insert =
|
|
45
|
+
(key: Metadata) =>
|
|
46
|
+
(value: Metadata) =>
|
|
47
|
+
(
|
|
48
|
+
symbol: ts.Symbol | undefined,
|
|
49
|
+
filter?: (doc: ts.JSDocTagInfo) => boolean,
|
|
50
|
+
): MetadataProperty => {
|
|
51
|
+
// COMMENTS AND TAGS
|
|
52
|
+
const description: string | null = symbol
|
|
53
|
+
? CommentFactory.description(symbol) ?? null
|
|
54
|
+
: null;
|
|
55
|
+
const jsDocTags: ts.JSDocTagInfo[] = (
|
|
56
|
+
symbol?.getJsDocTags() ?? []
|
|
57
|
+
).filter(filter ?? (() => true));
|
|
58
|
+
|
|
59
|
+
// THE PROPERTY
|
|
60
|
+
const property = MetadataProperty.create({
|
|
61
|
+
key,
|
|
62
|
+
value,
|
|
63
|
+
description,
|
|
64
|
+
jsDocTags,
|
|
65
|
+
});
|
|
66
|
+
obj.properties.push(property);
|
|
67
|
+
return property;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
//----
|
|
71
|
+
// REGULAR PROPERTIES
|
|
72
|
+
//----
|
|
73
|
+
for (const prop of parent.getApparentProperties()) {
|
|
74
|
+
// CHECK INTERNAL TAG
|
|
75
|
+
if (
|
|
76
|
+
(prop.getJsDocTags(checker) ?? []).find(
|
|
77
|
+
(tag) => tag.name === "internal",
|
|
78
|
+
) !== undefined
|
|
79
|
+
)
|
|
80
|
+
continue;
|
|
81
|
+
|
|
82
|
+
// CHECK NODE IS A FORMAL PROPERTY
|
|
83
|
+
const [node, type] = (() => {
|
|
84
|
+
const node = (prop.getDeclarations() ?? [])[0] as
|
|
85
|
+
| ts.PropertyDeclaration
|
|
86
|
+
| undefined;
|
|
87
|
+
const type: ts.Type | undefined = node
|
|
88
|
+
? checker.getTypeOfSymbolAtLocation(prop, node)
|
|
89
|
+
: "getTypeOfPropertyOfType" in checker
|
|
90
|
+
? (checker as any).getTypeOfPropertyOfType(
|
|
91
|
+
parent,
|
|
92
|
+
prop.name,
|
|
93
|
+
)
|
|
94
|
+
: undefined;
|
|
95
|
+
return [node, type];
|
|
96
|
+
})();
|
|
97
|
+
if ((node && pred(node) === false) || type === undefined) continue;
|
|
98
|
+
|
|
99
|
+
// GET EXACT TYPE
|
|
100
|
+
const key: Metadata = MetadataHelper.literal_to_metadata(prop.name);
|
|
101
|
+
const value: Metadata = explore_metadata(checker)(options)(
|
|
102
|
+
collection,
|
|
103
|
+
)(errors)(type, {
|
|
104
|
+
top: false,
|
|
105
|
+
object: obj,
|
|
106
|
+
property: prop.name,
|
|
107
|
+
nested: null,
|
|
108
|
+
escaped: false,
|
|
109
|
+
aliased: false,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// OPTIONAL, BUT CAN BE RQUIRED BY `Required<T>` TYPE
|
|
113
|
+
if (node?.questionToken) Writable(value).optional = true;
|
|
114
|
+
insert(key)(value)(prop);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
//----
|
|
118
|
+
// DYNAMIC PROPERTIES
|
|
119
|
+
//----
|
|
120
|
+
for (const index of checker.getIndexInfosOfType(parent)) {
|
|
121
|
+
// GET EXACT TYPE
|
|
122
|
+
const analyzer = (type: ts.Type) => (property: {} | null) =>
|
|
123
|
+
explore_metadata(checker)(options)(collection)(errors)(type, {
|
|
124
|
+
top: false,
|
|
125
|
+
object: obj,
|
|
126
|
+
property,
|
|
127
|
+
nested: null,
|
|
128
|
+
escaped: false,
|
|
129
|
+
aliased: false,
|
|
130
|
+
});
|
|
131
|
+
const key: Metadata = analyzer(index.keyType)(null);
|
|
132
|
+
const value: Metadata = analyzer(index.type)({});
|
|
133
|
+
|
|
134
|
+
// INSERT WITH REQUIRED CONFIGURATION
|
|
135
|
+
insert(key)(value)(
|
|
136
|
+
index.declaration?.parent
|
|
137
|
+
? checker.getSymbolAtLocation(index.declaration.parent)
|
|
138
|
+
: undefined,
|
|
139
|
+
(doc) => doc.name !== "default",
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return obj;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const isProperty = (node: ts.Declaration) =>
|
|
147
|
+
ts.isPropertyDeclaration(node) ||
|
|
148
|
+
ts.isPropertyAssignment(node) ||
|
|
149
|
+
ts.isPropertySignature(node) ||
|
|
150
|
+
ts.isTypeLiteralNode(node);
|
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
-
import { MetadataTupleType } from "../../../schemas/metadata/MetadataTupleType";
|
|
5
|
-
|
|
6
|
-
import { Writable } from "../../../typings/Writable";
|
|
7
|
-
|
|
8
|
-
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
9
|
-
|
|
10
|
-
import { MetadataCollection } from "../../MetadataCollection";
|
|
11
|
-
import { MetadataFactory } from "../../MetadataFactory";
|
|
12
|
-
import { explore_metadata } from "./explore_metadata";
|
|
13
|
-
|
|
14
|
-
export const emplace_metadata_tuple =
|
|
15
|
-
(checker: ts.TypeChecker) =>
|
|
16
|
-
(options: MetadataFactory.IOptions) =>
|
|
17
|
-
(collection: MetadataCollection) =>
|
|
18
|
-
(errors: MetadataFactory.IError[]) =>
|
|
19
|
-
(
|
|
20
|
-
type: ts.TupleType,
|
|
21
|
-
nullable: boolean,
|
|
22
|
-
explore: MetadataFactory.IExplore,
|
|
23
|
-
): MetadataTupleType => {
|
|
24
|
-
// CHECK EXISTENCE
|
|
25
|
-
const [tuple, newbie, closure] = collection.emplaceTuple(checker, type);
|
|
26
|
-
ArrayUtil.add(tuple.nullables, nullable);
|
|
27
|
-
if (newbie === false) return tuple;
|
|
28
|
-
|
|
29
|
-
// CONSTRUCT ELEMENT TYPES
|
|
30
|
-
const flagList: readonly ts.ElementFlags[] =
|
|
31
|
-
type.elementFlags ??
|
|
32
|
-
(type.target as ts.TupleType)?.elementFlags ??
|
|
33
|
-
[];
|
|
34
|
-
const elements: Metadata[] = checker
|
|
35
|
-
.getTypeArguments(type as ts.TypeReference)
|
|
36
|
-
.map((elem, i) => {
|
|
37
|
-
const child: Metadata = explore_metadata(checker)(options)(
|
|
38
|
-
collection,
|
|
39
|
-
)(errors)(elem, {
|
|
40
|
-
...explore,
|
|
41
|
-
nested: tuple,
|
|
42
|
-
aliased: false,
|
|
43
|
-
escaped: false,
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
// CHECK OPTIONAL
|
|
47
|
-
const flag: ts.ElementFlags | undefined = flagList[i];
|
|
48
|
-
if (flag === ts.ElementFlags.Optional)
|
|
49
|
-
Writable(child).optional = true;
|
|
50
|
-
|
|
51
|
-
// REST TYPE
|
|
52
|
-
if (flag !== ts.ElementFlags.Rest) return child;
|
|
53
|
-
const wrapper: Metadata = Metadata.initialize();
|
|
54
|
-
Writable(wrapper).rest = child;
|
|
55
|
-
return wrapper;
|
|
56
|
-
});
|
|
57
|
-
closure(elements);
|
|
58
|
-
|
|
59
|
-
return tuple;
|
|
60
|
-
};
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
+
import { MetadataTupleType } from "../../../schemas/metadata/MetadataTupleType";
|
|
5
|
+
|
|
6
|
+
import { Writable } from "../../../typings/Writable";
|
|
7
|
+
|
|
8
|
+
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
9
|
+
|
|
10
|
+
import { MetadataCollection } from "../../MetadataCollection";
|
|
11
|
+
import { MetadataFactory } from "../../MetadataFactory";
|
|
12
|
+
import { explore_metadata } from "./explore_metadata";
|
|
13
|
+
|
|
14
|
+
export const emplace_metadata_tuple =
|
|
15
|
+
(checker: ts.TypeChecker) =>
|
|
16
|
+
(options: MetadataFactory.IOptions) =>
|
|
17
|
+
(collection: MetadataCollection) =>
|
|
18
|
+
(errors: MetadataFactory.IError[]) =>
|
|
19
|
+
(
|
|
20
|
+
type: ts.TupleType,
|
|
21
|
+
nullable: boolean,
|
|
22
|
+
explore: MetadataFactory.IExplore,
|
|
23
|
+
): MetadataTupleType => {
|
|
24
|
+
// CHECK EXISTENCE
|
|
25
|
+
const [tuple, newbie, closure] = collection.emplaceTuple(checker, type);
|
|
26
|
+
ArrayUtil.add(tuple.nullables, nullable);
|
|
27
|
+
if (newbie === false) return tuple;
|
|
28
|
+
|
|
29
|
+
// CONSTRUCT ELEMENT TYPES
|
|
30
|
+
const flagList: readonly ts.ElementFlags[] =
|
|
31
|
+
type.elementFlags ??
|
|
32
|
+
(type.target as ts.TupleType)?.elementFlags ??
|
|
33
|
+
[];
|
|
34
|
+
const elements: Metadata[] = checker
|
|
35
|
+
.getTypeArguments(type as ts.TypeReference)
|
|
36
|
+
.map((elem, i) => {
|
|
37
|
+
const child: Metadata = explore_metadata(checker)(options)(
|
|
38
|
+
collection,
|
|
39
|
+
)(errors)(elem, {
|
|
40
|
+
...explore,
|
|
41
|
+
nested: tuple,
|
|
42
|
+
aliased: false,
|
|
43
|
+
escaped: false,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// CHECK OPTIONAL
|
|
47
|
+
const flag: ts.ElementFlags | undefined = flagList[i];
|
|
48
|
+
if (flag === ts.ElementFlags.Optional)
|
|
49
|
+
Writable(child).optional = true;
|
|
50
|
+
|
|
51
|
+
// REST TYPE
|
|
52
|
+
if (flag !== ts.ElementFlags.Rest) return child;
|
|
53
|
+
const wrapper: Metadata = Metadata.initialize();
|
|
54
|
+
Writable(wrapper).rest = child;
|
|
55
|
+
return wrapper;
|
|
56
|
+
});
|
|
57
|
+
closure(elements);
|
|
58
|
+
|
|
59
|
+
return tuple;
|
|
60
|
+
};
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
-
|
|
5
|
-
import { MetadataCollection } from "../../MetadataCollection";
|
|
6
|
-
import { MetadataFactory } from "../../MetadataFactory";
|
|
7
|
-
import { emend_metadata_atomics } from "./emend_metadata_atomics";
|
|
8
|
-
import { iterate_metadata } from "./iterate_metadata";
|
|
9
|
-
|
|
10
|
-
export const explore_metadata =
|
|
11
|
-
(checker: ts.TypeChecker) =>
|
|
12
|
-
(options: MetadataFactory.IOptions) =>
|
|
13
|
-
(collection: MetadataCollection) =>
|
|
14
|
-
(errors: MetadataFactory.IError[]) =>
|
|
15
|
-
(type: ts.Type | null, explore: MetadataFactory.IExplore): Metadata => {
|
|
16
|
-
// CONSTRUCT METADATA
|
|
17
|
-
const meta: Metadata = Metadata.initialize(explore.escaped);
|
|
18
|
-
if (type === null) return meta;
|
|
19
|
-
|
|
20
|
-
// ITERATE TYPESCRIPT TYPES
|
|
21
|
-
iterate_metadata(checker)(options)(collection)(errors)(
|
|
22
|
-
meta,
|
|
23
|
-
type,
|
|
24
|
-
explore,
|
|
25
|
-
);
|
|
26
|
-
emend_metadata_atomics(meta);
|
|
27
|
-
if (meta.escaped) {
|
|
28
|
-
emend_metadata_atomics(meta.escaped.original);
|
|
29
|
-
emend_metadata_atomics(meta.escaped.returns);
|
|
30
|
-
}
|
|
31
|
-
return meta;
|
|
32
|
-
};
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
+
|
|
5
|
+
import { MetadataCollection } from "../../MetadataCollection";
|
|
6
|
+
import { MetadataFactory } from "../../MetadataFactory";
|
|
7
|
+
import { emend_metadata_atomics } from "./emend_metadata_atomics";
|
|
8
|
+
import { iterate_metadata } from "./iterate_metadata";
|
|
9
|
+
|
|
10
|
+
export const explore_metadata =
|
|
11
|
+
(checker: ts.TypeChecker) =>
|
|
12
|
+
(options: MetadataFactory.IOptions) =>
|
|
13
|
+
(collection: MetadataCollection) =>
|
|
14
|
+
(errors: MetadataFactory.IError[]) =>
|
|
15
|
+
(type: ts.Type | null, explore: MetadataFactory.IExplore): Metadata => {
|
|
16
|
+
// CONSTRUCT METADATA
|
|
17
|
+
const meta: Metadata = Metadata.initialize(explore.escaped);
|
|
18
|
+
if (type === null) return meta;
|
|
19
|
+
|
|
20
|
+
// ITERATE TYPESCRIPT TYPES
|
|
21
|
+
iterate_metadata(checker)(options)(collection)(errors)(
|
|
22
|
+
meta,
|
|
23
|
+
type,
|
|
24
|
+
explore,
|
|
25
|
+
);
|
|
26
|
+
emend_metadata_atomics(meta);
|
|
27
|
+
if (meta.escaped) {
|
|
28
|
+
emend_metadata_atomics(meta.escaped.original);
|
|
29
|
+
emend_metadata_atomics(meta.escaped.returns);
|
|
30
|
+
}
|
|
31
|
+
return meta;
|
|
32
|
+
};
|