typia 9.7.0 → 9.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/AssertionGuard.d.mts +27 -25
- package/lib/AssertionGuard.d.ts +27 -25
- package/lib/CamelCase.d.mts +1 -1
- package/lib/CamelCase.d.ts +1 -1
- package/lib/IRandomGenerator.d.mts +44 -42
- package/lib/IRandomGenerator.d.ts +44 -42
- package/lib/IReadableURLSearchParams.d.mts +2 -2
- package/lib/IReadableURLSearchParams.d.ts +2 -2
- package/lib/PascalCase.d.mts +1 -1
- package/lib/PascalCase.d.ts +1 -1
- package/lib/Primitive.d.mts +20 -22
- package/lib/Primitive.d.ts +20 -22
- package/lib/Resolved.d.mts +16 -18
- package/lib/Resolved.d.ts +16 -18
- package/lib/SnakeCase.d.mts +3 -2
- package/lib/SnakeCase.d.ts +3 -2
- package/lib/TypeGuardError.d.mts +88 -61
- package/lib/TypeGuardError.d.ts +88 -61
- package/lib/TypeGuardError.js +40 -29
- package/lib/TypeGuardError.js.map +1 -1
- package/lib/TypeGuardError.mjs +70 -48
- package/lib/factories/MetadataCollection.js +4 -12
- package/lib/factories/MetadataCollection.js.map +1 -1
- package/lib/factories/MetadataCollection.mjs +4 -12
- package/lib/factories/MetadataCommentTagFactory.js +5 -15
- package/lib/factories/MetadataCommentTagFactory.js.map +1 -1
- package/lib/factories/MetadataCommentTagFactory.mjs +5 -15
- package/lib/factories/MetadataFactory.js +1 -3
- package/lib/factories/MetadataFactory.js.map +1 -1
- package/lib/factories/MetadataFactory.mjs +1 -3
- package/lib/factories/ProtobufFactory.js +1 -3
- package/lib/factories/ProtobufFactory.js.map +1 -1
- package/lib/factories/ProtobufFactory.mjs +1 -3
- package/lib/functional.d.mts +196 -195
- package/lib/functional.d.ts +196 -195
- package/lib/functional.js +18 -54
- package/lib/functional.js.map +1 -1
- package/lib/functional.mjs +18 -54
- package/lib/http.d.mts +303 -319
- package/lib/http.d.ts +303 -319
- package/lib/http.js +26 -78
- package/lib/http.js.map +1 -1
- package/lib/http.mjs +26 -78
- package/lib/internal/_ProtobufReader.d.mts +3 -9
- package/lib/internal/_ProtobufReader.d.ts +3 -9
- package/lib/internal/_ProtobufReader.js.map +1 -1
- package/lib/internal/_ProtobufReader.mjs +3 -9
- package/lib/internal/_ProtobufSizer.d.mts +4 -12
- package/lib/internal/_ProtobufSizer.d.ts +4 -12
- package/lib/internal/_ProtobufSizer.js.map +1 -1
- package/lib/internal/_ProtobufSizer.mjs +4 -12
- package/lib/internal/_ProtobufWriter.d.mts +5 -15
- package/lib/internal/_ProtobufWriter.d.ts +5 -15
- package/lib/internal/_ProtobufWriter.js.map +1 -1
- package/lib/internal/_ProtobufWriter.mjs +5 -15
- package/lib/internal/_jsonStringifyString.d.mts +4 -4
- package/lib/internal/_jsonStringifyString.d.ts +4 -4
- package/lib/internal/_jsonStringifyString.js +4 -4
- package/lib/internal/_jsonStringifyString.mjs +4 -4
- package/lib/json.d.mts +174 -195
- package/lib/json.d.ts +174 -195
- package/lib/json.js +16 -48
- package/lib/json.js.map +1 -1
- package/lib/json.mjs +16 -48
- package/lib/llm.d.mts +275 -192
- package/lib/llm.d.ts +275 -192
- package/lib/llm.js +4 -12
- package/lib/llm.js.map +1 -1
- package/lib/llm.mjs +4 -12
- package/lib/misc.d.mts +149 -172
- package/lib/misc.d.ts +149 -172
- package/lib/misc.js +17 -51
- package/lib/misc.js.map +1 -1
- package/lib/misc.mjs +17 -51
- package/lib/module.d.mts +263 -275
- package/lib/module.d.ts +263 -275
- package/lib/module.js +18 -54
- package/lib/module.js.map +1 -1
- package/lib/module.mjs +18 -54
- package/lib/notations.d.mts +153 -174
- package/lib/notations.d.ts +153 -174
- package/lib/notations.js +24 -72
- package/lib/notations.js.map +1 -1
- package/lib/notations.mjs +24 -72
- package/lib/programmers/FeatureProgrammer.d.mts +19 -41
- package/lib/programmers/FeatureProgrammer.d.ts +19 -41
- package/lib/programmers/FeatureProgrammer.js.map +1 -1
- package/lib/programmers/ImportProgrammer.js +3 -9
- package/lib/programmers/ImportProgrammer.js.map +1 -1
- package/lib/programmers/ImportProgrammer.mjs +3 -9
- package/lib/programmers/RandomProgrammer.js +6 -0
- package/lib/programmers/RandomProgrammer.js.map +1 -1
- package/lib/programmers/RandomProgrammer.mjs +6 -0
- package/lib/programmers/helpers/ProtobufWire.d.mts +13 -13
- package/lib/programmers/helpers/ProtobufWire.d.ts +13 -13
- package/lib/programmers/internal/check_array_length.js +2 -6
- package/lib/programmers/internal/check_array_length.js.map +1 -1
- package/lib/programmers/internal/check_array_length.mjs +2 -6
- package/lib/programmers/internal/check_bigint.js +2 -6
- package/lib/programmers/internal/check_bigint.js.map +1 -1
- package/lib/programmers/internal/check_bigint.mjs +2 -6
- package/lib/programmers/internal/check_dynamic_key.js +2 -6
- package/lib/programmers/internal/check_dynamic_key.js.map +1 -1
- package/lib/programmers/internal/check_dynamic_key.mjs +2 -6
- package/lib/programmers/internal/check_dynamic_properties.js +3 -9
- package/lib/programmers/internal/check_dynamic_properties.js.map +1 -1
- package/lib/programmers/internal/check_dynamic_properties.mjs +3 -9
- package/lib/programmers/internal/check_everything.js +1 -3
- package/lib/programmers/internal/check_everything.js.map +1 -1
- package/lib/programmers/internal/check_everything.mjs +1 -3
- package/lib/programmers/internal/check_native.js +2 -6
- package/lib/programmers/internal/check_native.js.map +1 -1
- package/lib/programmers/internal/check_native.mjs +2 -6
- package/lib/programmers/internal/check_number.js +2 -6
- package/lib/programmers/internal/check_number.js.map +1 -1
- package/lib/programmers/internal/check_number.mjs +2 -6
- package/lib/programmers/internal/check_object.js +2 -6
- package/lib/programmers/internal/check_object.js.map +1 -1
- package/lib/programmers/internal/check_object.mjs +2 -6
- package/lib/programmers/internal/check_string.js +2 -6
- package/lib/programmers/internal/check_string.js.map +1 -1
- package/lib/programmers/internal/check_string.mjs +2 -6
- package/lib/programmers/internal/check_template.js +1 -3
- package/lib/programmers/internal/check_template.js.map +1 -1
- package/lib/programmers/internal/check_template.mjs +1 -3
- package/lib/programmers/internal/check_union_array_like.js +1 -3
- package/lib/programmers/internal/check_union_array_like.js.map +1 -1
- package/lib/programmers/internal/check_union_array_like.mjs +1 -3
- package/lib/programmers/internal/decode_union_object.js +2 -6
- package/lib/programmers/internal/decode_union_object.js.map +1 -1
- package/lib/programmers/internal/decode_union_object.mjs +2 -6
- package/lib/programmers/internal/feature_object_entries.js +1 -3
- package/lib/programmers/internal/feature_object_entries.js.map +1 -1
- package/lib/programmers/internal/feature_object_entries.mjs +1 -3
- package/lib/programmers/internal/json_schema_escaped.js +2 -6
- package/lib/programmers/internal/json_schema_escaped.js.map +1 -1
- package/lib/programmers/internal/json_schema_escaped.mjs +2 -6
- package/lib/programmers/internal/json_schema_object.js +3 -9
- package/lib/programmers/internal/json_schema_object.js.map +1 -1
- package/lib/programmers/internal/json_schema_object.mjs +3 -9
- package/lib/programmers/internal/metadata_to_pattern.js +1 -3
- package/lib/programmers/internal/metadata_to_pattern.js.map +1 -1
- package/lib/programmers/internal/metadata_to_pattern.mjs +1 -3
- package/lib/programmers/internal/postfix_of_tuple.js +1 -3
- package/lib/programmers/internal/postfix_of_tuple.js.map +1 -1
- package/lib/programmers/internal/postfix_of_tuple.mjs +1 -3
- package/lib/programmers/internal/prune_object_properties.js +1 -3
- package/lib/programmers/internal/prune_object_properties.js.map +1 -1
- package/lib/programmers/internal/prune_object_properties.mjs +1 -3
- package/lib/programmers/internal/stringify_dynamic_properties.js +2 -6
- package/lib/programmers/internal/stringify_dynamic_properties.js.map +1 -1
- package/lib/programmers/internal/stringify_dynamic_properties.mjs +2 -6
- package/lib/programmers/internal/stringify_native.js +1 -3
- package/lib/programmers/internal/stringify_native.js.map +1 -1
- package/lib/programmers/internal/stringify_native.mjs +1 -3
- package/lib/programmers/internal/stringify_regular_properties.js +2 -6
- package/lib/programmers/internal/stringify_regular_properties.js.map +1 -1
- package/lib/programmers/internal/stringify_regular_properties.mjs +2 -6
- package/lib/programmers/internal/template_to_pattern.js +1 -3
- package/lib/programmers/internal/template_to_pattern.js.map +1 -1
- package/lib/programmers/internal/template_to_pattern.mjs +1 -3
- package/lib/programmers/internal/wrap_metadata_rest_tuple.js +1 -3
- package/lib/programmers/internal/wrap_metadata_rest_tuple.js.map +1 -1
- package/lib/programmers/internal/wrap_metadata_rest_tuple.mjs +1 -3
- package/lib/protobuf.d.mts +290 -297
- package/lib/protobuf.d.ts +290 -297
- package/lib/protobuf.js +17 -51
- package/lib/protobuf.js.map +1 -1
- package/lib/protobuf.mjs +17 -51
- package/lib/reflect.d.mts +2 -4
- package/lib/reflect.d.ts +2 -4
- package/lib/reflect.js +1 -3
- package/lib/reflect.js.map +1 -1
- package/lib/reflect.mjs +1 -3
- package/lib/schemas/json/IJsonApplication.d.mts +4 -4
- package/lib/schemas/json/IJsonApplication.d.ts +4 -4
- package/lib/schemas/json/IJsonSchemaCollection.d.mts +73 -56
- package/lib/schemas/json/IJsonSchemaCollection.d.ts +73 -56
- package/lib/schemas/json/IJsonSchemaUnit.d.mts +83 -70
- package/lib/schemas/json/IJsonSchemaUnit.d.ts +83 -70
- package/lib/schemas/metadata/Metadata.d.mts +1 -3
- package/lib/schemas/metadata/Metadata.d.ts +1 -3
- package/lib/schemas/metadata/Metadata.js +9 -27
- package/lib/schemas/metadata/Metadata.js.map +1 -1
- package/lib/schemas/metadata/Metadata.mjs +9 -27
- package/lib/schemas/metadata/MetadataAliasType.d.mts +1 -3
- package/lib/schemas/metadata/MetadataAliasType.d.ts +1 -3
- package/lib/schemas/metadata/MetadataAliasType.js +3 -9
- package/lib/schemas/metadata/MetadataAliasType.js.map +1 -1
- package/lib/schemas/metadata/MetadataAliasType.mjs +3 -9
- package/lib/schemas/metadata/MetadataApplication.d.mts +1 -3
- package/lib/schemas/metadata/MetadataApplication.d.ts +1 -3
- package/lib/schemas/metadata/MetadataApplication.js +2 -6
- package/lib/schemas/metadata/MetadataApplication.js.map +1 -1
- package/lib/schemas/metadata/MetadataApplication.mjs +2 -6
- package/lib/schemas/metadata/MetadataArray.d.mts +1 -3
- package/lib/schemas/metadata/MetadataArray.d.ts +1 -3
- package/lib/schemas/metadata/MetadataArray.js +1 -3
- package/lib/schemas/metadata/MetadataArray.js.map +1 -1
- package/lib/schemas/metadata/MetadataArray.mjs +1 -3
- package/lib/schemas/metadata/MetadataArrayType.d.mts +1 -3
- package/lib/schemas/metadata/MetadataArrayType.d.ts +1 -3
- package/lib/schemas/metadata/MetadataArrayType.js +3 -9
- package/lib/schemas/metadata/MetadataArrayType.js.map +1 -1
- package/lib/schemas/metadata/MetadataArrayType.mjs +3 -9
- package/lib/schemas/metadata/MetadataAtomic.js +1 -3
- package/lib/schemas/metadata/MetadataAtomic.js.map +1 -1
- package/lib/schemas/metadata/MetadataAtomic.mjs +1 -3
- package/lib/schemas/metadata/MetadataEscaped.d.mts +1 -3
- package/lib/schemas/metadata/MetadataEscaped.d.ts +1 -3
- package/lib/schemas/metadata/MetadataEscaped.js +3 -9
- package/lib/schemas/metadata/MetadataEscaped.js.map +1 -1
- package/lib/schemas/metadata/MetadataEscaped.mjs +3 -9
- package/lib/schemas/metadata/MetadataFunction.d.mts +1 -3
- package/lib/schemas/metadata/MetadataFunction.d.ts +1 -3
- package/lib/schemas/metadata/MetadataFunction.js +2 -6
- package/lib/schemas/metadata/MetadataFunction.js.map +1 -1
- package/lib/schemas/metadata/MetadataFunction.mjs +2 -6
- package/lib/schemas/metadata/MetadataObject.d.mts +1 -3
- package/lib/schemas/metadata/MetadataObject.d.ts +1 -3
- package/lib/schemas/metadata/MetadataObject.js +1 -3
- package/lib/schemas/metadata/MetadataObject.js.map +1 -1
- package/lib/schemas/metadata/MetadataObject.mjs +1 -3
- package/lib/schemas/metadata/MetadataObjectType.d.mts +1 -3
- package/lib/schemas/metadata/MetadataObjectType.d.ts +1 -3
- package/lib/schemas/metadata/MetadataObjectType.js +5 -15
- package/lib/schemas/metadata/MetadataObjectType.js.map +1 -1
- package/lib/schemas/metadata/MetadataObjectType.mjs +6 -18
- package/lib/schemas/metadata/MetadataParameter.js +1 -3
- package/lib/schemas/metadata/MetadataParameter.js.map +1 -1
- package/lib/schemas/metadata/MetadataParameter.mjs +1 -3
- package/lib/schemas/metadata/MetadataProperty.d.mts +1 -3
- package/lib/schemas/metadata/MetadataProperty.d.ts +1 -3
- package/lib/schemas/metadata/MetadataProperty.js +3 -9
- package/lib/schemas/metadata/MetadataProperty.js.map +1 -1
- package/lib/schemas/metadata/MetadataProperty.mjs +3 -9
- package/lib/schemas/metadata/MetadataTemplate.js +1 -3
- package/lib/schemas/metadata/MetadataTemplate.js.map +1 -1
- package/lib/schemas/metadata/MetadataTemplate.mjs +1 -3
- package/lib/schemas/metadata/MetadataTuple.d.mts +1 -3
- package/lib/schemas/metadata/MetadataTuple.d.ts +1 -3
- package/lib/schemas/metadata/MetadataTuple.js +2 -6
- package/lib/schemas/metadata/MetadataTuple.js.map +1 -1
- package/lib/schemas/metadata/MetadataTuple.mjs +2 -6
- package/lib/schemas/metadata/MetadataTupleType.js +2 -6
- package/lib/schemas/metadata/MetadataTupleType.js.map +1 -1
- package/lib/schemas/metadata/MetadataTupleType.mjs +3 -9
- package/lib/tags/Constant.d.mts +32 -0
- package/lib/tags/Constant.d.ts +32 -0
- package/lib/tags/ContentMediaType.d.mts +17 -0
- package/lib/tags/ContentMediaType.d.ts +17 -0
- package/lib/tags/Default.d.mts +30 -0
- package/lib/tags/Default.d.ts +30 -0
- package/lib/tags/Example.d.mts +32 -0
- package/lib/tags/Example.d.ts +32 -0
- package/lib/tags/Examples.d.mts +40 -0
- package/lib/tags/Examples.d.ts +40 -0
- package/lib/tags/ExclusiveMaximum.d.mts +21 -0
- package/lib/tags/ExclusiveMaximum.d.ts +21 -0
- package/lib/tags/ExclusiveMinimum.d.mts +21 -0
- package/lib/tags/ExclusiveMinimum.d.ts +21 -0
- package/lib/tags/Format.d.mts +28 -0
- package/lib/tags/Format.d.ts +28 -0
- package/lib/tags/JsonSchemaPlugin.d.mts +28 -0
- package/lib/tags/JsonSchemaPlugin.d.ts +28 -0
- package/lib/tags/MaxItems.d.mts +19 -0
- package/lib/tags/MaxItems.d.ts +19 -0
- package/lib/tags/MaxLength.d.mts +13 -0
- package/lib/tags/MaxLength.d.ts +13 -0
- package/lib/tags/Maximum.d.mts +20 -0
- package/lib/tags/Maximum.d.ts +20 -0
- package/lib/tags/MinItems.d.mts +19 -0
- package/lib/tags/MinItems.d.ts +19 -0
- package/lib/tags/MinLength.d.mts +13 -0
- package/lib/tags/MinLength.d.ts +13 -0
- package/lib/tags/Minimum.d.mts +20 -0
- package/lib/tags/Minimum.d.ts +20 -0
- package/lib/tags/MultipleOf.d.mts +21 -0
- package/lib/tags/MultipleOf.d.ts +21 -0
- package/lib/tags/Pattern.d.mts +18 -0
- package/lib/tags/Pattern.d.ts +18 -0
- package/lib/tags/Sequence.d.mts +27 -0
- package/lib/tags/Sequence.d.ts +27 -0
- package/lib/tags/TagBase.d.mts +38 -18
- package/lib/tags/TagBase.d.ts +38 -18
- package/lib/tags/Type.d.mts +27 -0
- package/lib/tags/Type.d.ts +27 -0
- package/lib/tags/UniqueItems.d.mts +20 -0
- package/lib/tags/UniqueItems.d.ts +20 -0
- package/lib/tags/internal/FormatCheatSheet.d.mts +1 -3
- package/lib/tags/internal/FormatCheatSheet.d.ts +1 -3
- package/lib/tags/internal/FormatCheatSheet.js +1 -3
- package/lib/tags/internal/FormatCheatSheet.js.map +1 -1
- package/lib/tags/internal/FormatCheatSheet.mjs +1 -3
- package/lib/transformers/ITransformOptions.d.mts +27 -19
- package/lib/transformers/ITransformOptions.d.ts +27 -19
- package/lib/transformers/ImportTransformer.js +114 -1
- package/lib/transformers/ImportTransformer.js.map +1 -1
- package/lib/transformers/ImportTransformer.mjs +114 -1
- package/lib/transformers/NoTransformConfigurationError.js +1 -3
- package/lib/transformers/NoTransformConfigurationError.js.map +1 -1
- package/lib/transformers/NoTransformConfigurationError.mjs +1 -3
- package/lib/transformers/features/llm/LlmApplicationTransformer.js +1 -3
- package/lib/transformers/features/llm/LlmApplicationTransformer.js.map +1 -1
- package/lib/transformers/features/llm/LlmApplicationTransformer.mjs +1 -3
- package/lib/typings/Equal.d.mts +6 -6
- package/lib/typings/Equal.d.ts +6 -6
- package/package.json +2 -1
- package/src/AssertionGuard.ts +27 -25
- package/src/CamelCase.ts +1 -1
- package/src/IRandomGenerator.ts +57 -47
- package/src/IReadableURLSearchParams.ts +2 -2
- package/src/PascalCase.ts +1 -1
- package/src/Primitive.ts +20 -22
- package/src/Resolved.ts +16 -18
- package/src/SnakeCase.ts +3 -2
- package/src/TypeGuardError.ts +101 -64
- package/src/factories/MetadataCollection.ts +4 -12
- package/src/factories/MetadataCommentTagFactory.ts +8 -24
- package/src/factories/MetadataFactory.ts +1 -3
- package/src/factories/ProtobufFactory.ts +1 -3
- package/src/functional.ts +214 -249
- package/src/http.ts +329 -397
- package/src/internal/_ProtobufReader.ts +3 -9
- package/src/internal/_ProtobufSizer.ts +4 -12
- package/src/internal/_ProtobufWriter.ts +5 -15
- package/src/internal/_jsonStringifyString.ts +4 -4
- package/src/json.ts +190 -243
- package/src/llm.ts +279 -204
- package/src/misc.ts +166 -223
- package/src/module.ts +281 -329
- package/src/notations.ts +177 -246
- package/src/programmers/FeatureProgrammer.ts +19 -41
- package/src/programmers/ImportProgrammer.ts +3 -9
- package/src/programmers/RandomProgrammer.ts +6 -1
- package/src/programmers/helpers/ProtobufWire.ts +13 -13
- package/src/programmers/internal/check_array_length.ts +2 -6
- package/src/programmers/internal/check_bigint.ts +2 -6
- package/src/programmers/internal/check_dynamic_key.ts +2 -6
- package/src/programmers/internal/check_dynamic_properties.ts +3 -9
- package/src/programmers/internal/check_everything.ts +1 -3
- package/src/programmers/internal/check_native.ts +2 -6
- package/src/programmers/internal/check_number.ts +2 -6
- package/src/programmers/internal/check_object.ts +3 -9
- package/src/programmers/internal/check_string.ts +2 -6
- package/src/programmers/internal/check_template.ts +1 -3
- package/src/programmers/internal/check_union_array_like.ts +2 -6
- package/src/programmers/internal/decode_union_object.ts +3 -9
- package/src/programmers/internal/feature_object_entries.ts +1 -3
- package/src/programmers/internal/json_schema_escaped.ts +2 -6
- package/src/programmers/internal/json_schema_object.ts +4 -12
- package/src/programmers/internal/metadata_to_pattern.ts +1 -3
- package/src/programmers/internal/postfix_of_tuple.ts +1 -3
- package/src/programmers/internal/prune_object_properties.ts +1 -3
- package/src/programmers/internal/stringify_dynamic_properties.ts +2 -6
- package/src/programmers/internal/stringify_native.ts +1 -3
- package/src/programmers/internal/stringify_regular_properties.ts +2 -6
- package/src/programmers/internal/template_to_pattern.ts +1 -3
- package/src/programmers/internal/wrap_metadata_rest_tuple.ts +1 -3
- package/src/protobuf.ts +307 -348
- package/src/reflect.ts +3 -7
- package/src/schemas/json/IJsonApplication.ts +4 -4
- package/src/schemas/json/IJsonSchemaCollection.ts +73 -56
- package/src/schemas/json/IJsonSchemaUnit.ts +83 -70
- package/src/schemas/metadata/IMetadataTypeTag.ts +1 -3
- package/src/schemas/metadata/Metadata.ts +9 -27
- package/src/schemas/metadata/MetadataAliasType.ts +3 -9
- package/src/schemas/metadata/MetadataApplication.ts +2 -6
- package/src/schemas/metadata/MetadataArray.ts +1 -3
- package/src/schemas/metadata/MetadataArrayType.ts +3 -9
- package/src/schemas/metadata/MetadataAtomic.ts +1 -3
- package/src/schemas/metadata/MetadataEscaped.ts +3 -9
- package/src/schemas/metadata/MetadataFunction.ts +2 -6
- package/src/schemas/metadata/MetadataObject.ts +1 -3
- package/src/schemas/metadata/MetadataObjectType.ts +6 -18
- package/src/schemas/metadata/MetadataParameter.ts +1 -3
- package/src/schemas/metadata/MetadataProperty.ts +3 -9
- package/src/schemas/metadata/MetadataTemplate.ts +1 -3
- package/src/schemas/metadata/MetadataTuple.ts +2 -6
- package/src/schemas/metadata/MetadataTupleType.ts +3 -9
- package/src/tags/Constant.ts +32 -0
- package/src/tags/ContentMediaType.ts +17 -0
- package/src/tags/Default.ts +30 -0
- package/src/tags/Example.ts +32 -0
- package/src/tags/Examples.ts +40 -0
- package/src/tags/ExclusiveMaximum.ts +21 -0
- package/src/tags/ExclusiveMinimum.ts +21 -0
- package/src/tags/Format.ts +28 -0
- package/src/tags/JsonSchemaPlugin.ts +28 -0
- package/src/tags/MaxItems.ts +19 -0
- package/src/tags/MaxLength.ts +13 -0
- package/src/tags/Maximum.ts +20 -0
- package/src/tags/MinItems.ts +19 -0
- package/src/tags/MinLength.ts +13 -0
- package/src/tags/Minimum.ts +20 -0
- package/src/tags/MultipleOf.ts +21 -0
- package/src/tags/Pattern.ts +18 -0
- package/src/tags/Sequence.ts +27 -0
- package/src/tags/TagBase.ts +38 -18
- package/src/tags/Type.ts +27 -0
- package/src/tags/UniqueItems.ts +20 -0
- package/src/tags/internal/FormatCheatSheet.ts +1 -3
- package/src/transformers/ITransformOptions.ts +27 -19
- package/src/transformers/ImportTransformer.ts +173 -1
- package/src/transformers/NoTransformConfigurationError.ts +1 -3
- package/src/transformers/features/llm/LlmApplicationTransformer.ts +1 -3
- package/src/typings/Equal.ts +6 -6
package/src/IRandomGenerator.ts
CHANGED
|
@@ -3,28 +3,28 @@ import { OpenApi } from "@samchon/openapi";
|
|
|
3
3
|
/**
|
|
4
4
|
* Interface for generating random values for various data types.
|
|
5
5
|
*
|
|
6
|
-
* `IRandomGenerator` defines the contract for generating random values
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* `IRandomGenerator` defines the contract for generating random values that can
|
|
7
|
+
* be used by typia for creating mock data, testing scenarios, and random value
|
|
8
|
+
* generation based on JSON schema constraints.
|
|
9
9
|
*
|
|
10
10
|
* This interface supports generating random values for:
|
|
11
|
+
*
|
|
11
12
|
* - Basic types (boolean, number, integer, bigint, string, array)
|
|
12
13
|
* - String format patterns (email, URL, UUID, etc.)
|
|
13
14
|
* - Date and time formats
|
|
14
15
|
* - Various address and identifier formats
|
|
15
16
|
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* const generator: IRandomGenerator = {
|
|
19
|
-
* boolean: () => Math.random() > 0.5,
|
|
20
|
-
* number: (schema) => Math.random() * (schema.maximum ?? 100),
|
|
21
|
-
* string: (schema) => "example-string",
|
|
22
|
-
* email: () => "test@example.com",
|
|
23
|
-
* // ... implement other methods
|
|
24
|
-
* };
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
17
|
* @author Jeongho Nam - https://github.com/samchon
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const generator: IRandomGenerator = {
|
|
21
|
+
* boolean: () => Math.random() > 0.5,
|
|
22
|
+
* number: (schema) => Math.random() * (schema.maximum ?? 100),
|
|
23
|
+
* string: (schema) => "example-string",
|
|
24
|
+
* email: () => "test@example.com",
|
|
25
|
+
* // ... implement other methods
|
|
26
|
+
* };
|
|
27
|
+
* ```;
|
|
28
28
|
*/
|
|
29
29
|
export interface IRandomGenerator {
|
|
30
30
|
// REGULAR DATA TYPES
|
|
@@ -63,13 +63,15 @@ export interface IRandomGenerator {
|
|
|
63
63
|
/**
|
|
64
64
|
* Generates a random string based on JSON schema constraints.
|
|
65
65
|
*
|
|
66
|
-
* @param schema JSON schema with string constraints (minLength, maxLength,
|
|
66
|
+
* @param schema JSON schema with string constraints (minLength, maxLength,
|
|
67
|
+
* pattern, etc.)
|
|
67
68
|
* @returns Random string matching the specified constraints
|
|
68
69
|
*/
|
|
69
70
|
string(schema: OpenApi.IJsonSchema.IString): string;
|
|
70
71
|
|
|
71
72
|
/**
|
|
72
|
-
* Generates a random array with elements created by the provided generator
|
|
73
|
+
* Generates a random array with elements created by the provided generator
|
|
74
|
+
* function.
|
|
73
75
|
*
|
|
74
76
|
* @param schema Array schema with element generator function
|
|
75
77
|
* @returns Random array with generated elements
|
|
@@ -261,52 +263,60 @@ export namespace IRandomGenerator {
|
|
|
261
263
|
/**
|
|
262
264
|
* Map of custom generators for different data types.
|
|
263
265
|
*
|
|
264
|
-
* This interface allows customization of random generation for specific
|
|
265
|
-
*
|
|
266
|
+
* This interface allows customization of random generation for specific types
|
|
267
|
+
* when they have certain schema properties or constraints.
|
|
266
268
|
*
|
|
267
269
|
* @example
|
|
268
|
-
*
|
|
269
|
-
*
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
270
|
+
* ```typescript
|
|
271
|
+
* const generator: Partial<IRandomGenerator> = {
|
|
272
|
+
* string: (schema) => {
|
|
273
|
+
* if ((schema as any)["x-typia-monetary"] === "dollar") {
|
|
274
|
+
* return "$" + Math.floor(Math.random() * 1000);
|
|
275
|
+
* }
|
|
276
|
+
* return "default-string";
|
|
277
|
+
* },
|
|
278
|
+
* number: (schema) => {
|
|
279
|
+
* if ((schema as any)["x-typia-powerOf"] !== undefined) {
|
|
280
|
+
* const powerOf = (schema as any)["x-typia-powerOf"];
|
|
281
|
+
* return Math.pow(powerOf, Math.random() * 10 + 1);
|
|
282
|
+
* }
|
|
283
|
+
* return Math.random() * 100;
|
|
280
284
|
* }
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
* };
|
|
284
|
-
* ```
|
|
285
|
+
* };
|
|
286
|
+
* ```;
|
|
285
287
|
*/
|
|
286
288
|
export interface CustomMap {
|
|
287
289
|
/**
|
|
288
|
-
* Custom string generator that can handle special string formats
|
|
289
|
-
*
|
|
290
|
+
* Custom string generator that can handle special string formats based on
|
|
291
|
+
* schema properties.
|
|
290
292
|
*/
|
|
291
|
-
string?: (
|
|
293
|
+
string?: (
|
|
294
|
+
schema: OpenApi.IJsonSchema.IString & Record<string, any>,
|
|
295
|
+
) => string;
|
|
292
296
|
|
|
293
297
|
/**
|
|
294
|
-
* Custom number generator that can handle special number constraints
|
|
295
|
-
*
|
|
298
|
+
* Custom number generator that can handle special number constraints based
|
|
299
|
+
* on schema properties.
|
|
296
300
|
*/
|
|
297
|
-
number?: (
|
|
301
|
+
number?: (
|
|
302
|
+
schema: OpenApi.IJsonSchema.INumber & Record<string, any>,
|
|
303
|
+
) => number;
|
|
298
304
|
|
|
299
305
|
/**
|
|
300
306
|
* Custom integer generator that can handle special integer constraints
|
|
301
307
|
* based on schema properties.
|
|
302
308
|
*/
|
|
303
|
-
integer?: (
|
|
309
|
+
integer?: (
|
|
310
|
+
schema: OpenApi.IJsonSchema.IInteger & Record<string, any>,
|
|
311
|
+
) => number;
|
|
304
312
|
|
|
305
313
|
/**
|
|
306
|
-
* Custom bigint generator that can handle special bigint constraints
|
|
307
|
-
*
|
|
314
|
+
* Custom bigint generator that can handle special bigint constraints based
|
|
315
|
+
* on schema properties.
|
|
308
316
|
*/
|
|
309
|
-
bigint?: (
|
|
317
|
+
bigint?: (
|
|
318
|
+
schema: OpenApi.IJsonSchema.IInteger & Record<string, any>,
|
|
319
|
+
) => bigint;
|
|
310
320
|
|
|
311
321
|
/**
|
|
312
322
|
* Custom boolean generator that can handle special boolean constraints
|
|
@@ -315,13 +325,13 @@ export namespace IRandomGenerator {
|
|
|
315
325
|
boolean?: (schema: Record<string, any>) => boolean | undefined;
|
|
316
326
|
|
|
317
327
|
/**
|
|
318
|
-
* Custom array generator that can handle special array constraints
|
|
319
|
-
*
|
|
328
|
+
* Custom array generator that can handle special array constraints based on
|
|
329
|
+
* schema properties.
|
|
320
330
|
*/
|
|
321
331
|
array?: <T>(
|
|
322
332
|
schema: Omit<OpenApi.IJsonSchema.IArray, "items"> & {
|
|
323
333
|
element: (index: number, count: number) => T;
|
|
324
|
-
} & Record<string, any
|
|
334
|
+
} & Record<string, any>,
|
|
325
335
|
) => T[];
|
|
326
336
|
}
|
|
327
337
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Interface for a readable URLSearchParams object.
|
|
3
3
|
*
|
|
4
|
-
* This interface is a subset of the {@link URLSearchParams} interface,
|
|
5
|
-
*
|
|
4
|
+
* This interface is a subset of the {@link URLSearchParams} interface, designed
|
|
5
|
+
* especially for the [Hono.JS](https://hono.dev/) library.
|
|
6
6
|
*
|
|
7
7
|
* @author https://github.com/miyaji255
|
|
8
8
|
*/
|
package/src/PascalCase.ts
CHANGED
|
@@ -10,8 +10,8 @@ import { ValueOf } from "./typings/ValueOf";
|
|
|
10
10
|
*
|
|
11
11
|
* It also erases every method property like {@link Resolved} type.
|
|
12
12
|
*
|
|
13
|
-
* @template T Target type to be pascalized
|
|
14
13
|
* @author Jeongho Nam - https://github.com/samchon
|
|
14
|
+
* @template T Target type to be pascalized
|
|
15
15
|
*/
|
|
16
16
|
export type PascalCase<T> =
|
|
17
17
|
Equal<T, PascalizeMain<T>> extends true ? T : PascalizeMain<T>;
|
package/src/Primitive.ts
CHANGED
|
@@ -8,36 +8,34 @@ import { Format } from "./tags";
|
|
|
8
8
|
/**
|
|
9
9
|
* Primitive type of JSON.
|
|
10
10
|
*
|
|
11
|
-
* `Primitive<T>` is a TMP (Type Meta Programming) type which converts
|
|
12
|
-
*
|
|
11
|
+
* `Primitive<T>` is a TMP (Type Meta Programming) type which converts its
|
|
12
|
+
* argument as a primitive type within the framework JSON.
|
|
13
13
|
*
|
|
14
|
-
* If the target argument is a built-in class which returns its origin primitive
|
|
15
|
-
* through the `valueOf()` method like the `String` or `Number`, its return
|
|
16
|
-
* be the `string` or `number`. Otherwise, if the built-in class does
|
|
17
|
-
* `valueOf()` method, the return type will be an empty object
|
|
14
|
+
* If the target argument is a built-in class which returns its origin primitive
|
|
15
|
+
* type through the `valueOf()` method like the `String` or `Number`, its return
|
|
16
|
+
* type will be the `string` or `number`. Otherwise, if the built-in class does
|
|
17
|
+
* not have the `valueOf()` method, the return type will be an empty object
|
|
18
|
+
* (`{}`).
|
|
18
19
|
*
|
|
19
|
-
* Otherwise, if the target argument is a type of custom class, all of its
|
|
20
|
-
* will be erased and its prototype will be changed to the
|
|
21
|
-
* Therefore, the return type of the TMP type will finally
|
|
20
|
+
* Otherwise, if the target argument is a type of custom class, all of its
|
|
21
|
+
* custom methods will be erased and its prototype will be changed to the
|
|
22
|
+
* primitive `object`. Therefore, the return type of the TMP type will finally
|
|
23
|
+
* be the primitive object.
|
|
22
24
|
*
|
|
23
|
-
* In addition, if the target argument is a type of custom class and it has a
|
|
24
|
-
* method `toJSON()`, the return type of this `Primitive` will be not
|
|
25
|
-
* but `Primitive<ReturnType<Instance.toJSON>>`.
|
|
25
|
+
* In addition, if the target argument is a type of custom class and it has a
|
|
26
|
+
* special method `toJSON()`, the return type of this `Primitive` will be not
|
|
27
|
+
* `Primitive<Instance>` but `Primitive<ReturnType<Instance.toJSON>>`.
|
|
26
28
|
*
|
|
27
|
-
* Before
|
|
28
|
-
* ------------------------|----------------------------------------
|
|
29
|
-
* `
|
|
30
|
-
* `
|
|
31
|
-
*
|
|
32
|
-
* `Class` | `object`
|
|
33
|
-
* `Class` with `toJSON()` | `Primitive<ReturnType<Class.toJSON>>`
|
|
34
|
-
* Native Class | never
|
|
35
|
-
* Others | No change
|
|
29
|
+
* Before | After
|
|
30
|
+
* ------------------------|---------------------------------------- `Boolean` |
|
|
31
|
+
* `boolean` `Number` | `number` `String` | `string` `Class` | `object` `Class`
|
|
32
|
+
* with `toJSON()` | `Primitive<ReturnType<Class.toJSON>>` Native Class | never
|
|
33
|
+
* Others | No change
|
|
36
34
|
*
|
|
37
|
-
* @template T Target argument type.
|
|
38
35
|
* @author Jeongho Nam - https://github.com/samchon
|
|
39
36
|
* @author Kyungsu Kang - https://github.com/kakasoo
|
|
40
37
|
* @author Michael - https://github.com/8471919
|
|
38
|
+
* @template T Target argument type.
|
|
41
39
|
*/
|
|
42
40
|
export type Primitive<T> =
|
|
43
41
|
Equal<T, PrimitiveMain<T>> extends true ? T : PrimitiveMain<T>;
|
package/src/Resolved.ts
CHANGED
|
@@ -6,30 +6,28 @@ import { ValueOf } from "./typings/ValueOf";
|
|
|
6
6
|
/**
|
|
7
7
|
* Resolved type that erases every method.
|
|
8
8
|
*
|
|
9
|
-
* `Resolved` is a TMP (Type Meta Programming) type which converts
|
|
10
|
-
*
|
|
9
|
+
* `Resolved` is a TMP (Type Meta Programming) type which converts its argument
|
|
10
|
+
* as a resolved type that erases every method property.
|
|
11
11
|
*
|
|
12
|
-
* If the target argument is a built-in class which returns its origin primitive
|
|
13
|
-
* through the `valueOf()` method like the `String` or `Number`, its return
|
|
14
|
-
* be the `string` or `number`. Otherwise, if the built-in class does
|
|
15
|
-
* `valueOf()` method, the return type will be the same as the
|
|
12
|
+
* If the target argument is a built-in class which returns its origin primitive
|
|
13
|
+
* type through the `valueOf()` method like the `String` or `Number`, its return
|
|
14
|
+
* type will be the `string` or `number`. Otherwise, if the built-in class does
|
|
15
|
+
* not have the `valueOf()` method, the return type will be the same as the
|
|
16
|
+
* target argument.
|
|
16
17
|
*
|
|
17
|
-
* Otherwise, if the target argument is a type of custom class, all of its
|
|
18
|
-
* will be erased and its prototype will be changed to the
|
|
19
|
-
* Therefore, the return type of the TMP type will finally
|
|
18
|
+
* Otherwise, if the target argument is a type of custom class, all of its
|
|
19
|
+
* custom methods will be erased and its prototype will be changed to the
|
|
20
|
+
* primitive `object`. Therefore, the return type of the TMP type will finally
|
|
21
|
+
* be the resolved object.
|
|
20
22
|
*
|
|
21
|
-
* Before
|
|
22
|
-
* ------------------------|----------------------------------------
|
|
23
|
-
* `
|
|
24
|
-
* `
|
|
25
|
-
* `BigInt` | `bigint`
|
|
26
|
-
* `String` | `string`
|
|
27
|
-
* `Class` | `interface`
|
|
28
|
-
* Native Class or Others | No change
|
|
23
|
+
* Before | After
|
|
24
|
+
* ------------------------|---------------------------------------- `Boolean` |
|
|
25
|
+
* `boolean` `Number` | `number` `BigInt` | `bigint` `String` | `string` `Class`
|
|
26
|
+
* | `interface` Native Class or Others | No change
|
|
29
27
|
*
|
|
30
|
-
* @template T Target argument type.
|
|
31
28
|
* @author Jeongho Nam - https://github.com/samchon
|
|
32
29
|
* @author Kyungsu Kang - https://github.com/kakasoo
|
|
30
|
+
* @template T Target argument type.
|
|
33
31
|
*/
|
|
34
32
|
export type Resolved<T> =
|
|
35
33
|
Equal<T, ResolvedMain<T>> extends true ? T : ResolvedMain<T>;
|
package/src/SnakeCase.ts
CHANGED
|
@@ -5,12 +5,13 @@ import { ValueOf } from "./typings/ValueOf";
|
|
|
5
5
|
/**
|
|
6
6
|
* Snake case type.
|
|
7
7
|
*
|
|
8
|
-
* `SnakeCase` type is a type that all keys of an object are converted to snake
|
|
8
|
+
* `SnakeCase` type is a type that all keys of an object are converted to snake
|
|
9
|
+
* case.
|
|
9
10
|
*
|
|
10
11
|
* It also erases every method property like {@link Resolved} type.
|
|
11
12
|
*
|
|
12
|
-
* @template T Target type to be snake cased
|
|
13
13
|
* @author Jeongho Nam - https://github.com/samchon
|
|
14
|
+
* @template T Target type to be snake cased
|
|
14
15
|
*/
|
|
15
16
|
export type SnakeCase<T> =
|
|
16
17
|
Equal<T, SnakageMain<T>> extends true ? T : SnakageMain<T>;
|
package/src/TypeGuardError.ts
CHANGED
|
@@ -1,52 +1,56 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Custom error class thrown when runtime assertion fails in `typia.assert<T>()`
|
|
2
|
+
* Custom error class thrown when runtime assertion fails in `typia.assert<T>()`
|
|
3
|
+
* function.
|
|
3
4
|
*
|
|
4
5
|
* This error is thrown by the `typia.assert<T>()` function when the input value
|
|
5
6
|
* doesn't match the expected type.
|
|
6
7
|
*
|
|
7
|
-
* The error provides detailed information about the first assertion failure
|
|
8
|
-
* including the access path where the error occurred, the expected
|
|
8
|
+
* The error provides detailed information about the first assertion failure
|
|
9
|
+
* encountered, including the access path where the error occurred, the expected
|
|
10
|
+
* type, and the actual value.
|
|
9
11
|
*
|
|
10
|
-
* @template T - The expected type (generic for type safety)
|
|
11
12
|
* @author Jeongho Nam - https://github.com/samchon
|
|
12
13
|
* @example
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
14
|
+
* ```typescript
|
|
15
|
+
* interface IMember {
|
|
16
|
+
* name: string;
|
|
17
|
+
* age: number & ExclusiveMinimum<19>;
|
|
18
|
+
* }
|
|
18
19
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
20
|
+
* try {
|
|
21
|
+
* typia.assert<IMember>({ name: "John", age: 18 });
|
|
22
|
+
* } catch (error) {
|
|
23
|
+
* if (error instanceof TypeGuardError) {
|
|
24
|
+
* console.log(error.method); // "typia.assert"
|
|
25
|
+
* console.log(error.path); // "input.age"
|
|
26
|
+
* console.log(error.expected); // "number & ExclusiveMinimum<19>"
|
|
27
|
+
* console.log(error.value); // 18
|
|
28
|
+
* }
|
|
27
29
|
* }
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
+
* ```;
|
|
31
|
+
*
|
|
32
|
+
* @template T - The expected type (generic for type safety)
|
|
30
33
|
*/
|
|
31
34
|
export class TypeGuardError<T = any> extends Error {
|
|
32
35
|
/**
|
|
33
36
|
* The name of the typia method that threw this error.
|
|
34
37
|
*
|
|
35
|
-
* @example
|
|
38
|
+
* @example
|
|
39
|
+
* typia.assert;
|
|
36
40
|
*/
|
|
37
41
|
public readonly method: string;
|
|
38
42
|
|
|
39
43
|
/**
|
|
40
44
|
* The access path to the property where the assertion error occurred.
|
|
41
45
|
*
|
|
42
|
-
* Uses dot notation to indicate the path for nested object properties.
|
|
43
|
-
*
|
|
46
|
+
* Uses dot notation to indicate the path for nested object properties. May be
|
|
47
|
+
* `undefined` if the error occurred at the root level.
|
|
44
48
|
*
|
|
45
49
|
* @example
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
+
* - `"input.age"` - Error in the age property of the object
|
|
51
|
+
* - `"input.profile.email"` - Error in the email property of a nested object
|
|
52
|
+
* - `"input[0].name"` - Error in the name property of the first array element
|
|
53
|
+
* - `undefined` - Error occurred at the root level
|
|
50
54
|
*/
|
|
51
55
|
public readonly path: string | undefined;
|
|
52
56
|
|
|
@@ -57,32 +61,43 @@ export class TypeGuardError<T = any> extends Error {
|
|
|
57
61
|
* for complex types.
|
|
58
62
|
*
|
|
59
63
|
* @example
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
+
* - `"string"` - Expected string type
|
|
65
|
+
* - `"number & ExclusiveMinimum<19>"` - Expected number greater than 19
|
|
66
|
+
* - `"undefined"` - Expected undefined (when superfluous property found in assertion)
|
|
67
|
+
* - `"{ name: string; age: number }"` - Expected object type
|
|
64
68
|
*/
|
|
65
69
|
public readonly expected: string;
|
|
66
70
|
|
|
67
71
|
/**
|
|
68
72
|
* The actual value that failed assertion.
|
|
69
73
|
*
|
|
70
|
-
* Stores the actual value at the error path as-is.
|
|
71
|
-
*
|
|
74
|
+
* Stores the actual value at the error path as-is. Useful for debugging by
|
|
75
|
+
* comparing the expected type with the actual value.
|
|
72
76
|
*
|
|
73
77
|
* @example
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
78
|
+
* - `18` - Numeric value
|
|
79
|
+
* - `"invalid"` - String value
|
|
80
|
+
* - `{ name: "John", age: 18, sex: 1 }` - Object value
|
|
77
81
|
*/
|
|
78
82
|
public readonly value: unknown;
|
|
79
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Optional human-readable description of the type guard error
|
|
86
|
+
*
|
|
87
|
+
* This field is rarely populated in standard typia type assertion and is
|
|
88
|
+
* primarily intended for specialized AI agent libraries or custom validation
|
|
89
|
+
* scenarios that require additional context beyond the technical type
|
|
90
|
+
* information. Most assertion errors rely solely on the path, expected, and
|
|
91
|
+
* value fields for comprehensive error reporting.
|
|
92
|
+
*/
|
|
93
|
+
public readonly description?: string | undefined;
|
|
94
|
+
|
|
80
95
|
/**
|
|
81
96
|
* Phantom property for type safety purposes.
|
|
82
97
|
*
|
|
83
|
-
* This property is not actually used and exists only to maintain
|
|
84
|
-
*
|
|
85
|
-
*
|
|
98
|
+
* This property is not actually used and exists only to maintain the generic
|
|
99
|
+
* type T in TypeScript's type system. Always has an `undefined` value at
|
|
100
|
+
* runtime.
|
|
86
101
|
*
|
|
87
102
|
* @internal
|
|
88
103
|
*/
|
|
@@ -91,17 +106,17 @@ export class TypeGuardError<T = any> extends Error {
|
|
|
91
106
|
/**
|
|
92
107
|
* Creates a new TypeGuardError instance.
|
|
93
108
|
*
|
|
94
|
-
* @param props - Object containing the properties needed to create the error
|
|
95
|
-
*
|
|
96
109
|
* @example
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
110
|
+
* ```typescript
|
|
111
|
+
* const error = new TypeGuardError({
|
|
112
|
+
* method: "typia.assert",
|
|
113
|
+
* path: "input.age",
|
|
114
|
+
* expected: "number & ExclusiveMinimum<19>",
|
|
115
|
+
* value: 18
|
|
116
|
+
* });
|
|
117
|
+
* ```;
|
|
118
|
+
*
|
|
119
|
+
* @param props - Object containing the properties needed to create the error
|
|
105
120
|
*/
|
|
106
121
|
public constructor(props: TypeGuardError.IProps) {
|
|
107
122
|
// MESSAGE CONSTRUCTION
|
|
@@ -124,6 +139,14 @@ export class TypeGuardError<T = any> extends Error {
|
|
|
124
139
|
this.path = props.path;
|
|
125
140
|
this.expected = props.expected;
|
|
126
141
|
this.value = props.value;
|
|
142
|
+
if (props.description || props.value === undefined)
|
|
143
|
+
this.description =
|
|
144
|
+
props.description ??
|
|
145
|
+
[
|
|
146
|
+
"The value at this path is `undefined`.",
|
|
147
|
+
"",
|
|
148
|
+
`Please fill the \`${props.expected}\` typed value next time.`,
|
|
149
|
+
].join("\n");
|
|
127
150
|
}
|
|
128
151
|
}
|
|
129
152
|
|
|
@@ -132,47 +155,61 @@ export namespace TypeGuardError {
|
|
|
132
155
|
* Interface for properties passed to the TypeGuardError constructor.
|
|
133
156
|
*
|
|
134
157
|
* @example
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
158
|
+
* ```typescript
|
|
159
|
+
* const props: TypeGuardError.IProps = {
|
|
160
|
+
* method: "typia.assertEquals",
|
|
161
|
+
* path: "input.sex",
|
|
162
|
+
* expected: "undefined",
|
|
163
|
+
* value: 1,
|
|
164
|
+
* message: "Custom error message" // optional
|
|
165
|
+
* };
|
|
166
|
+
* ```;
|
|
144
167
|
*/
|
|
145
168
|
export interface IProps {
|
|
146
169
|
/**
|
|
147
170
|
* The name of the typia method that threw the error.
|
|
148
171
|
*
|
|
149
|
-
* @example
|
|
172
|
+
* @example
|
|
173
|
+
* typia.assert, "typia.assertEquals";
|
|
150
174
|
*/
|
|
151
175
|
method: string;
|
|
152
176
|
|
|
153
177
|
/**
|
|
154
|
-
* The access path to the property where the assertion error occurred
|
|
178
|
+
* The access path to the property where the assertion error occurred
|
|
179
|
+
* (optional).
|
|
155
180
|
*
|
|
156
|
-
* @example
|
|
181
|
+
* @example
|
|
182
|
+
* input.age, "input.profile.email";
|
|
157
183
|
*/
|
|
158
184
|
path?: undefined | string;
|
|
159
185
|
|
|
160
186
|
/**
|
|
161
187
|
* String representation of the expected type at the error location.
|
|
162
188
|
*
|
|
163
|
-
* @example
|
|
189
|
+
* @example
|
|
190
|
+
* string, "number & ExclusiveMinimum<19>";
|
|
164
191
|
*/
|
|
165
192
|
expected: string;
|
|
166
193
|
|
|
194
|
+
/** The actual value that failed assertion. */
|
|
195
|
+
value: unknown;
|
|
196
|
+
|
|
167
197
|
/**
|
|
168
|
-
*
|
|
198
|
+
* Optional human-readable description of the type guard error
|
|
199
|
+
*
|
|
200
|
+
* This field is rarely populated in standard typia type assertion and is
|
|
201
|
+
* primarily intended for specialized AI agent libraries or custom
|
|
202
|
+
* validation scenarios that require additional context beyond the technical
|
|
203
|
+
* type information. Most assertion errors rely solely on the path,
|
|
204
|
+
* expected, and value fields for comprehensive error reporting.
|
|
169
205
|
*/
|
|
170
|
-
|
|
206
|
+
description?: string;
|
|
171
207
|
|
|
172
208
|
/**
|
|
173
209
|
* Custom error message (optional).
|
|
174
210
|
*
|
|
175
|
-
* If not provided, a default format message will be automatically
|
|
211
|
+
* If not provided, a default format message will be automatically
|
|
212
|
+
* generated.
|
|
176
213
|
*/
|
|
177
214
|
message?: undefined | string;
|
|
178
215
|
}
|
|
@@ -100,9 +100,7 @@ export class MetadataCollection {
|
|
|
100
100
|
return addicted;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
/**
|
|
104
|
-
* @internal
|
|
105
|
-
*/
|
|
103
|
+
/** @internal */
|
|
106
104
|
public getUnionIndex(meta: Metadata): number {
|
|
107
105
|
const key: string = meta.objects.map((obj) => obj.type.name).join(" | ");
|
|
108
106
|
MapUtil.take(this.object_unions_, key, () =>
|
|
@@ -199,23 +197,17 @@ export class MetadataCollection {
|
|
|
199
197
|
return [tuple, true, (elements) => (Writable(tuple).elements = elements)];
|
|
200
198
|
}
|
|
201
199
|
|
|
202
|
-
/**
|
|
203
|
-
* @internal
|
|
204
|
-
*/
|
|
200
|
+
/** @internal */
|
|
205
201
|
public setObjectRecursive(obj: MetadataObjectType, recursive: boolean): void {
|
|
206
202
|
Writable(obj).recursive = recursive;
|
|
207
203
|
}
|
|
208
204
|
|
|
209
|
-
/**
|
|
210
|
-
* @internal
|
|
211
|
-
*/
|
|
205
|
+
/** @internal */
|
|
212
206
|
public setAliasRecursive(alias: MetadataAliasType, recursive: boolean): void {
|
|
213
207
|
Writable(alias).recursive = recursive;
|
|
214
208
|
}
|
|
215
209
|
|
|
216
|
-
/**
|
|
217
|
-
* @internal
|
|
218
|
-
*/
|
|
210
|
+
/** @internal */
|
|
219
211
|
public setArrayRecursive(array: MetadataArrayType, recursive: boolean): void {
|
|
220
212
|
Writable(array).recursive = recursive;
|
|
221
213
|
if (recursive) Writable(array).index = this.recursive_array_index_++;
|