typia 9.7.1 → 10.0.0-dev.20251107
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/LICENSE +21 -21
- package/README.md +153 -153
- 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 +2 -4
- package/lib/factories/ProtobufFactory.js.map +1 -1
- package/lib/factories/ProtobufFactory.mjs +2 -4
- 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/json_schema_station.d.mts +2 -2
- package/lib/programmers/internal/json_schema_station.d.ts +2 -2
- 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/programmers/json/JsonStringifyProgrammer.js +2 -2
- package/lib/programmers/json/JsonStringifyProgrammer.js.map +1 -1
- package/lib/programmers/json/JsonStringifyProgrammer.mjs +2 -2
- package/lib/programmers/llm/LlmApplicationProgrammer.js +5 -1
- package/lib/programmers/llm/LlmApplicationProgrammer.js.map +1 -1
- package/lib/programmers/llm/LlmApplicationProgrammer.mjs +5 -1
- package/lib/programmers/llm/LlmSchemaProgrammer.js +1 -4
- package/lib/programmers/llm/LlmSchemaProgrammer.js.map +1 -1
- package/lib/programmers/llm/LlmSchemaProgrammer.mjs +1 -35
- 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 +16 -16
- package/lib/tags/Constant.d.ts +16 -16
- package/lib/tags/ContentMediaType.d.mts +7 -7
- package/lib/tags/ContentMediaType.d.ts +7 -7
- package/lib/tags/Default.d.mts +19 -19
- package/lib/tags/Default.d.ts +19 -19
- package/lib/tags/Example.d.mts +18 -18
- package/lib/tags/Example.d.ts +18 -18
- package/lib/tags/Examples.d.mts +23 -23
- package/lib/tags/Examples.d.ts +23 -23
- package/lib/tags/ExclusiveMaximum.d.mts +8 -5
- package/lib/tags/ExclusiveMaximum.d.ts +8 -5
- package/lib/tags/ExclusiveMinimum.d.mts +8 -5
- package/lib/tags/ExclusiveMinimum.d.ts +8 -5
- package/lib/tags/Format.d.mts +12 -8
- package/lib/tags/Format.d.ts +12 -8
- package/lib/tags/JsonSchemaPlugin.d.mts +20 -18
- package/lib/tags/JsonSchemaPlugin.d.ts +20 -18
- package/lib/tags/MaxItems.d.mts +9 -9
- package/lib/tags/MaxItems.d.ts +9 -9
- package/lib/tags/MaxLength.d.mts +6 -5
- package/lib/tags/MaxLength.d.ts +6 -5
- package/lib/tags/Maximum.d.mts +9 -7
- package/lib/tags/Maximum.d.ts +9 -7
- package/lib/tags/MinItems.d.mts +9 -9
- package/lib/tags/MinItems.d.ts +9 -9
- package/lib/tags/MinLength.d.mts +6 -5
- package/lib/tags/MinLength.d.ts +6 -5
- package/lib/tags/Minimum.d.mts +9 -7
- package/lib/tags/Minimum.d.ts +9 -7
- package/lib/tags/MultipleOf.d.mts +10 -7
- package/lib/tags/MultipleOf.d.ts +10 -7
- package/lib/tags/Pattern.d.mts +7 -4
- package/lib/tags/Pattern.d.ts +7 -4
- package/lib/tags/Sequence.d.mts +19 -17
- package/lib/tags/Sequence.d.ts +19 -17
- package/lib/tags/TagBase.d.mts +21 -28
- package/lib/tags/TagBase.d.ts +21 -28
- package/lib/tags/Type.d.mts +12 -11
- package/lib/tags/Type.d.ts +12 -11
- package/lib/tags/UniqueItems.d.mts +10 -9
- package/lib/tags/UniqueItems.d.ts +10 -9
- 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 +5 -10
- package/lib/transformers/ImportTransformer.js.map +1 -1
- package/lib/transformers/ImportTransformer.mjs +5 -10
- 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 +121 -120
- package/src/AssertionGuard.ts +41 -39
- package/src/CamelCase.ts +75 -75
- package/src/IRandomGenerator.ts +337 -335
- package/src/IReadableURLSearchParams.ts +9 -9
- package/src/PascalCase.ts +71 -71
- package/src/Primitive.ts +90 -92
- package/src/Resolved.ts +72 -74
- package/src/SnakeCase.ts +127 -126
- package/src/TypeGuardError.ts +216 -179
- package/src/factories/MetadataCollection.ts +270 -278
- package/src/factories/MetadataCommentTagFactory.ts +632 -648
- package/src/factories/MetadataFactory.ts +402 -404
- package/src/factories/ProtobufFactory.ts +873 -875
- package/src/functional.ts +705 -740
- package/src/http.ts +972 -1040
- package/src/internal/_ProtobufReader.ts +188 -194
- package/src/internal/_ProtobufSizer.ts +137 -145
- package/src/internal/_ProtobufWriter.ts +135 -145
- package/src/internal/_jsonStringifyString.ts +42 -42
- package/src/json.ts +643 -696
- package/src/llm.ts +615 -540
- package/src/misc.ts +594 -651
- package/src/module.ts +889 -937
- package/src/notations.ts +751 -820
- package/src/programmers/FeatureProgrammer.ts +605 -627
- package/src/programmers/ImportProgrammer.ts +179 -185
- package/src/programmers/RandomProgrammer.ts +1195 -1190
- package/src/programmers/helpers/ProtobufWire.ts +34 -34
- package/src/programmers/internal/check_array_length.ts +43 -47
- package/src/programmers/internal/check_bigint.ts +46 -50
- package/src/programmers/internal/check_dynamic_key.ts +197 -201
- package/src/programmers/internal/check_dynamic_properties.ts +231 -237
- package/src/programmers/internal/check_everything.ts +21 -23
- package/src/programmers/internal/check_native.ts +23 -27
- package/src/programmers/internal/check_number.ts +108 -112
- package/src/programmers/internal/check_object.ts +72 -78
- package/src/programmers/internal/check_string.ts +46 -50
- package/src/programmers/internal/check_template.ts +46 -48
- package/src/programmers/internal/check_union_array_like.ts +331 -335
- package/src/programmers/internal/decode_union_object.ts +110 -116
- package/src/programmers/internal/feature_object_entries.ts +59 -61
- package/src/programmers/internal/json_schema_escaped.ts +78 -82
- package/src/programmers/internal/json_schema_object.ts +150 -158
- package/src/programmers/internal/json_schema_station.ts +2 -2
- package/src/programmers/internal/metadata_to_pattern.ts +40 -42
- package/src/programmers/internal/postfix_of_tuple.ts +3 -5
- package/src/programmers/internal/prune_object_properties.ts +69 -71
- package/src/programmers/internal/stringify_dynamic_properties.ts +158 -162
- package/src/programmers/internal/stringify_native.ts +5 -7
- package/src/programmers/internal/stringify_regular_properties.ts +77 -81
- package/src/programmers/internal/template_to_pattern.ts +21 -23
- package/src/programmers/internal/wrap_metadata_rest_tuple.ts +21 -23
- package/src/programmers/json/JsonStringifyProgrammer.ts +1124 -1124
- package/src/programmers/llm/LlmApplicationProgrammer.ts +10 -1
- package/src/programmers/llm/LlmSchemaProgrammer.ts +2 -7
- package/src/protobuf.ts +820 -861
- package/src/reflect.ts +46 -50
- package/src/schemas/json/IJsonApplication.ts +77 -77
- package/src/schemas/json/IJsonSchemaCollection.ts +212 -195
- package/src/schemas/json/IJsonSchemaUnit.ts +263 -250
- package/src/schemas/metadata/IMetadataTypeTag.ts +14 -16
- package/src/schemas/metadata/Metadata.ts +669 -687
- package/src/schemas/metadata/MetadataAliasType.ts +57 -63
- package/src/schemas/metadata/MetadataApplication.ts +40 -44
- package/src/schemas/metadata/MetadataArray.ts +47 -49
- package/src/schemas/metadata/MetadataArrayType.ts +51 -57
- package/src/schemas/metadata/MetadataAtomic.ts +85 -87
- package/src/schemas/metadata/MetadataEscaped.ts +45 -51
- package/src/schemas/metadata/MetadataFunction.ts +45 -49
- package/src/schemas/metadata/MetadataObject.ts +46 -48
- package/src/schemas/metadata/MetadataObjectType.ts +137 -149
- package/src/schemas/metadata/MetadataParameter.ts +52 -54
- package/src/schemas/metadata/MetadataProperty.ts +53 -59
- package/src/schemas/metadata/MetadataTemplate.ts +78 -80
- package/src/schemas/metadata/MetadataTuple.ts +28 -32
- package/src/schemas/metadata/MetadataTupleType.ts +61 -67
- package/src/tags/Constant.ts +47 -47
- package/src/tags/ContentMediaType.ts +27 -27
- package/src/tags/Default.ts +52 -52
- package/src/tags/Example.ts +56 -56
- package/src/tags/Examples.ts +56 -56
- package/src/tags/ExclusiveMaximum.ts +44 -41
- package/src/tags/ExclusiveMinimum.ts +44 -41
- package/src/tags/Format.ts +78 -74
- package/src/tags/JsonSchemaPlugin.ts +36 -34
- package/src/tags/MaxItems.ts +31 -31
- package/src/tags/MaxLength.ts +25 -24
- package/src/tags/Maximum.ts +39 -37
- package/src/tags/MinItems.ts +31 -31
- package/src/tags/MinLength.ts +25 -24
- package/src/tags/Minimum.ts +39 -37
- package/src/tags/MultipleOf.ts +42 -39
- package/src/tags/Pattern.ts +49 -46
- package/src/tags/Sequence.ts +37 -35
- package/src/tags/TagBase.ts +102 -109
- package/src/tags/Type.ts +64 -63
- package/src/tags/UniqueItems.ts +34 -33
- package/src/tags/internal/FormatCheatSheet.ts +71 -73
- package/src/transformers/ITransformOptions.ts +70 -62
- package/src/transformers/ImportTransformer.ts +253 -258
- package/src/transformers/NoTransformConfigurationError.ts +16 -18
- package/src/transformers/features/llm/LlmApplicationTransformer.ts +224 -226
- package/src/typings/Equal.ts +18 -18
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2022 Jeongho Nam
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Jeongho Nam
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,153 +1,153 @@
|
|
|
1
|
-
# Typia
|
|
2
|
-

|
|
3
|
-
|
|
4
|
-
[](https://github.com/samchon/typia/blob/master/LICENSE)
|
|
5
|
-
[](https://www.npmjs.com/package/typia)
|
|
6
|
-
[](https://www.npmjs.com/package/typia)
|
|
7
|
-
[](https://github.com/samchon/typia/actions?query=workflow%3Abuild)
|
|
8
|
-
[](https://typia.io/docs/)
|
|
9
|
-
[](https://gurubase.io/g/typia)
|
|
10
|
-
[](https://discord.gg/E94XhzrUCZ)
|
|
11
|
-
|
|
12
|
-
```typescript
|
|
13
|
-
// RUNTIME VALIDATORS
|
|
14
|
-
export function is<T>(input: unknown): input is T; // returns boolean
|
|
15
|
-
export function assert<T>(input: unknown): T; // throws TypeGuardError
|
|
16
|
-
export function assertGuard<T>(input: unknown): asserts input is T;
|
|
17
|
-
export function validate<T>(input: unknown): IValidation<T>; // detailed
|
|
18
|
-
|
|
19
|
-
// JSON FUNCTIONS
|
|
20
|
-
export namespace json {
|
|
21
|
-
export function application<T>(): IJsonApplication; // JSON schema
|
|
22
|
-
export function assertParse<T>(input: string): T; // type safe parser
|
|
23
|
-
export function assertStringify<T>(input: T): string; // safe and faster
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// AI FUNCTION CALLING SCHEMA
|
|
27
|
-
export namespace llm {
|
|
28
|
-
// collection of function calling schemas
|
|
29
|
-
export function application<Class, Model>(): ILlmApplication<Class>;
|
|
30
|
-
export function controller<Class, Model>(
|
|
31
|
-
name: string,
|
|
32
|
-
execute: Class,
|
|
33
|
-
): ILlmController<Model>; // +executor
|
|
34
|
-
// structured output
|
|
35
|
-
export function parameters<P, Model>(): ILlmSchema.IParameters<Model>;
|
|
36
|
-
export function schema<T, Model>(): ILlmSchema<Model>; // type schema
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// PROTOCOL BUFFER
|
|
40
|
-
export namespace protobuf {
|
|
41
|
-
export function message<T>(): string; // Protocol Buffer message
|
|
42
|
-
export function assertDecode<T>(buffer: Uint8Array): T; // safe decoder
|
|
43
|
-
export function assertEncode<T>(input: T): Uint8Array; // safe encoder
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// RANDOM GENERATOR
|
|
47
|
-
export function random<T>(g?: Partial<IRandomGenerator>): T;
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
`typia` is a transformer library supporting below features:
|
|
51
|
-
|
|
52
|
-
- Super-fast Runtime Validators
|
|
53
|
-
- Enhanced JSON schema and serde functions
|
|
54
|
-
- LLM function calling schema and structured output
|
|
55
|
-
- Protocol Buffer encoder and decoder
|
|
56
|
-
- Random data generator
|
|
57
|
-
|
|
58
|
-
> [!NOTE]
|
|
59
|
-
>
|
|
60
|
-
> - **Only one line** required, with pure TypeScript type
|
|
61
|
-
> - Runtime validator is **20,000x faster** than `class-validator`
|
|
62
|
-
> - JSON serialization is **200x faster** than `class-transformer`
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
## Transformation
|
|
68
|
-
If you call `typia` function, it would be compiled like below.
|
|
69
|
-
|
|
70
|
-
This is the key concept of `typia`, transforming TypeScript type to a runtime function. The `typia.is<T>()` function is transformed to a dedicated type checker by analyzing the target type `T` in the compilation level.
|
|
71
|
-
|
|
72
|
-
This feature enables developers to ensure type safety in their applications, leveraging TypeScript's static typing while also providing runtime validation. Instead of defining additional schemas, you can simply utilize the pure TypeScript type itself.
|
|
73
|
-
|
|
74
|
-
```typescript
|
|
75
|
-
//----
|
|
76
|
-
// examples/checkString.ts
|
|
77
|
-
//----
|
|
78
|
-
import typia, { tags } from "typia";
|
|
79
|
-
export const checkString = typia.createIs<string>();
|
|
80
|
-
|
|
81
|
-
//----
|
|
82
|
-
// examples/checkString.js
|
|
83
|
-
//----
|
|
84
|
-
import typia from "typia";
|
|
85
|
-
export const checkString = (() => {
|
|
86
|
-
return (input) => "string" === typeof input;
|
|
87
|
-
})();
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
## Sponsors
|
|
93
|
-
Thanks for your support.
|
|
94
|
-
|
|
95
|
-
Your donation encourages `typia` development.
|
|
96
|
-
|
|
97
|
-
Also, `typia` is re-distributing half of donations to core contributors of `typia`.
|
|
98
|
-
|
|
99
|
-
- [`nonara/ts-patch`](https://github.com/nonara/ts-patch)
|
|
100
|
-
- [`ryoppippi/unplugin-typia`](https://github.com/ryoppippi/unplugin-typia)
|
|
101
|
-
|
|
102
|
-
[](https://opencollective.com/typia)
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
## Playground
|
|
108
|
-
You can experience how typia works by [playground website](https://typia.io/playground):
|
|
109
|
-
|
|
110
|
-
- 💻 https://typia.io/playground
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
## Guide Documents
|
|
116
|
-
Check out the document in the [website](https://typia.io/docs/):
|
|
117
|
-
|
|
118
|
-
### 🏠 Home
|
|
119
|
-
- [Introduction](https://typia.io/docs/)
|
|
120
|
-
- [Setup](https://typia.io/docs/setup/)
|
|
121
|
-
- [Pure TypeScript](https://typia.io/docs/pure/)
|
|
122
|
-
|
|
123
|
-
### 📖 Features
|
|
124
|
-
- Runtime Validators
|
|
125
|
-
- [`assert()` function](https://typia.io/docs/validators/assert/)
|
|
126
|
-
- [`is()` function](https://typia.io/docs/validators/is/)
|
|
127
|
-
- [`validate()` function](https://typia.io/docs/validators/validate/)
|
|
128
|
-
- [Functional Module](https://typia.io/docs/validators/functional)
|
|
129
|
-
- [Special Tags](https://typia.io/docs/validators/tags/)
|
|
130
|
-
- Enhanced JSON
|
|
131
|
-
- [JSON Schema](https://typia.io/docs/json/schema/)
|
|
132
|
-
- [`stringify()` functions](https://typia.io/docs/json/stringify/)
|
|
133
|
-
- [`parse()` functions](https://typia.io/docs/json/parse/)
|
|
134
|
-
- LLM Function Calling
|
|
135
|
-
- [`application()` function](https://typia.io/docs/llm/application/)
|
|
136
|
-
- [`parameters()` function](https://typia.io/docs/llm/parameters/)
|
|
137
|
-
- [`schema()` function](https://typia.io/docs/llm/schema/)
|
|
138
|
-
- [AI Chatbot Development](https://typia.io/docs/llm/chat/)
|
|
139
|
-
- [Documentation Strategy](https://typia.io/docs/llm/strategy/)
|
|
140
|
-
- Protocol Buffer
|
|
141
|
-
- [Message Schema](https://typia.io/docs/protobuf/message)
|
|
142
|
-
- [`decode()` functions](https://typia.io/docs/protobuf/decode/)
|
|
143
|
-
- [`encode()` functions](https://typia.io/docs/protobuf/encode/)
|
|
144
|
-
- [Random Generator](https://typia.io/docs/random/)
|
|
145
|
-
- [Miscellaneous](https://typia.io/docs/misc/)
|
|
146
|
-
|
|
147
|
-
### 🔗 Appendix
|
|
148
|
-
- [API Documents](https://typia.io/api)
|
|
149
|
-
-
|
|
150
|
-
- [NestJS](https://typia.io/docs/utilization/nestjs/)
|
|
151
|
-
- [tRPC](https://typia.io/docs/utilization/trpc/)
|
|
152
|
-
- [⇲ Benchmark Result](https://github.com/samchon/typia/tree/master/benchmark/results/11th%20Gen%20Intel(R)%20Core(TM)%20i5-1135G7%20%40%202.40GHz)
|
|
153
|
-
- [⇲ `dev.to` Articles](https://dev.to/samchon/series/22474)
|
|
1
|
+
# Typia
|
|
2
|
+

|
|
3
|
+
|
|
4
|
+
[](https://github.com/samchon/typia/blob/master/LICENSE)
|
|
5
|
+
[](https://www.npmjs.com/package/typia)
|
|
6
|
+
[](https://www.npmjs.com/package/typia)
|
|
7
|
+
[](https://github.com/samchon/typia/actions?query=workflow%3Abuild)
|
|
8
|
+
[](https://typia.io/docs/)
|
|
9
|
+
[](https://gurubase.io/g/typia)
|
|
10
|
+
[](https://discord.gg/E94XhzrUCZ)
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
// RUNTIME VALIDATORS
|
|
14
|
+
export function is<T>(input: unknown): input is T; // returns boolean
|
|
15
|
+
export function assert<T>(input: unknown): T; // throws TypeGuardError
|
|
16
|
+
export function assertGuard<T>(input: unknown): asserts input is T;
|
|
17
|
+
export function validate<T>(input: unknown): IValidation<T>; // detailed
|
|
18
|
+
|
|
19
|
+
// JSON FUNCTIONS
|
|
20
|
+
export namespace json {
|
|
21
|
+
export function application<T>(): IJsonApplication; // JSON schema
|
|
22
|
+
export function assertParse<T>(input: string): T; // type safe parser
|
|
23
|
+
export function assertStringify<T>(input: T): string; // safe and faster
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// AI FUNCTION CALLING SCHEMA
|
|
27
|
+
export namespace llm {
|
|
28
|
+
// collection of function calling schemas
|
|
29
|
+
export function application<Class, Model>(): ILlmApplication<Class>;
|
|
30
|
+
export function controller<Class, Model>(
|
|
31
|
+
name: string,
|
|
32
|
+
execute: Class,
|
|
33
|
+
): ILlmController<Model>; // +executor
|
|
34
|
+
// structured output
|
|
35
|
+
export function parameters<P, Model>(): ILlmSchema.IParameters<Model>;
|
|
36
|
+
export function schema<T, Model>(): ILlmSchema<Model>; // type schema
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// PROTOCOL BUFFER
|
|
40
|
+
export namespace protobuf {
|
|
41
|
+
export function message<T>(): string; // Protocol Buffer message
|
|
42
|
+
export function assertDecode<T>(buffer: Uint8Array): T; // safe decoder
|
|
43
|
+
export function assertEncode<T>(input: T): Uint8Array; // safe encoder
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// RANDOM GENERATOR
|
|
47
|
+
export function random<T>(g?: Partial<IRandomGenerator>): T;
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
`typia` is a transformer library supporting below features:
|
|
51
|
+
|
|
52
|
+
- Super-fast Runtime Validators
|
|
53
|
+
- Enhanced JSON schema and serde functions
|
|
54
|
+
- LLM function calling schema and structured output
|
|
55
|
+
- Protocol Buffer encoder and decoder
|
|
56
|
+
- Random data generator
|
|
57
|
+
|
|
58
|
+
> [!NOTE]
|
|
59
|
+
>
|
|
60
|
+
> - **Only one line** required, with pure TypeScript type
|
|
61
|
+
> - Runtime validator is **20,000x faster** than `class-validator`
|
|
62
|
+
> - JSON serialization is **200x faster** than `class-transformer`
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
## Transformation
|
|
68
|
+
If you call `typia` function, it would be compiled like below.
|
|
69
|
+
|
|
70
|
+
This is the key concept of `typia`, transforming TypeScript type to a runtime function. The `typia.is<T>()` function is transformed to a dedicated type checker by analyzing the target type `T` in the compilation level.
|
|
71
|
+
|
|
72
|
+
This feature enables developers to ensure type safety in their applications, leveraging TypeScript's static typing while also providing runtime validation. Instead of defining additional schemas, you can simply utilize the pure TypeScript type itself.
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
//----
|
|
76
|
+
// examples/checkString.ts
|
|
77
|
+
//----
|
|
78
|
+
import typia, { tags } from "typia";
|
|
79
|
+
export const checkString = typia.createIs<string>();
|
|
80
|
+
|
|
81
|
+
//----
|
|
82
|
+
// examples/checkString.js
|
|
83
|
+
//----
|
|
84
|
+
import typia from "typia";
|
|
85
|
+
export const checkString = (() => {
|
|
86
|
+
return (input) => "string" === typeof input;
|
|
87
|
+
})();
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
## Sponsors
|
|
93
|
+
Thanks for your support.
|
|
94
|
+
|
|
95
|
+
Your donation encourages `typia` development.
|
|
96
|
+
|
|
97
|
+
Also, `typia` is re-distributing half of donations to core contributors of `typia`.
|
|
98
|
+
|
|
99
|
+
- [`nonara/ts-patch`](https://github.com/nonara/ts-patch)
|
|
100
|
+
- [`ryoppippi/unplugin-typia`](https://github.com/ryoppippi/unplugin-typia)
|
|
101
|
+
|
|
102
|
+
[](https://opencollective.com/typia)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
## Playground
|
|
108
|
+
You can experience how typia works by [playground website](https://typia.io/playground):
|
|
109
|
+
|
|
110
|
+
- 💻 https://typia.io/playground
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
## Guide Documents
|
|
116
|
+
Check out the document in the [website](https://typia.io/docs/):
|
|
117
|
+
|
|
118
|
+
### 🏠 Home
|
|
119
|
+
- [Introduction](https://typia.io/docs/)
|
|
120
|
+
- [Setup](https://typia.io/docs/setup/)
|
|
121
|
+
- [Pure TypeScript](https://typia.io/docs/pure/)
|
|
122
|
+
|
|
123
|
+
### 📖 Features
|
|
124
|
+
- Runtime Validators
|
|
125
|
+
- [`assert()` function](https://typia.io/docs/validators/assert/)
|
|
126
|
+
- [`is()` function](https://typia.io/docs/validators/is/)
|
|
127
|
+
- [`validate()` function](https://typia.io/docs/validators/validate/)
|
|
128
|
+
- [Functional Module](https://typia.io/docs/validators/functional)
|
|
129
|
+
- [Special Tags](https://typia.io/docs/validators/tags/)
|
|
130
|
+
- Enhanced JSON
|
|
131
|
+
- [JSON Schema](https://typia.io/docs/json/schema/)
|
|
132
|
+
- [`stringify()` functions](https://typia.io/docs/json/stringify/)
|
|
133
|
+
- [`parse()` functions](https://typia.io/docs/json/parse/)
|
|
134
|
+
- LLM Function Calling
|
|
135
|
+
- [`application()` function](https://typia.io/docs/llm/application/)
|
|
136
|
+
- [`parameters()` function](https://typia.io/docs/llm/parameters/)
|
|
137
|
+
- [`schema()` function](https://typia.io/docs/llm/schema/)
|
|
138
|
+
- [AI Chatbot Development](https://typia.io/docs/llm/chat/)
|
|
139
|
+
- [Documentation Strategy](https://typia.io/docs/llm/strategy/)
|
|
140
|
+
- Protocol Buffer
|
|
141
|
+
- [Message Schema](https://typia.io/docs/protobuf/message)
|
|
142
|
+
- [`decode()` functions](https://typia.io/docs/protobuf/decode/)
|
|
143
|
+
- [`encode()` functions](https://typia.io/docs/protobuf/encode/)
|
|
144
|
+
- [Random Generator](https://typia.io/docs/random/)
|
|
145
|
+
- [Miscellaneous](https://typia.io/docs/misc/)
|
|
146
|
+
|
|
147
|
+
### 🔗 Appendix
|
|
148
|
+
- [API Documents](https://typia.io/api)
|
|
149
|
+
- Utilization Cases
|
|
150
|
+
- [NestJS](https://typia.io/docs/utilization/nestjs/)
|
|
151
|
+
- [tRPC](https://typia.io/docs/utilization/trpc/)
|
|
152
|
+
- [⇲ Benchmark Result](https://github.com/samchon/typia/tree/master/benchmark/results/11th%20Gen%20Intel(R)%20Core(TM)%20i5-1135G7%20%40%202.40GHz)
|
|
153
|
+
- [⇲ `dev.to` Articles](https://dev.to/samchon/series/22474)
|
package/lib/AssertionGuard.d.mts
CHANGED
|
@@ -1,39 +1,41 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Type definition for assertion guard functions in `typia`.
|
|
3
3
|
*
|
|
4
|
-
* An assertion guard is a function that asserts an input value's type at
|
|
5
|
-
* and performs a TypeScript type assertion if validation passes. Unlike
|
|
6
|
-
* assertion functions that return the validated value, assertion guards
|
|
7
|
-
* nothing but automatically cast the input parameter to the expected
|
|
4
|
+
* An assertion guard is a function that asserts an input value's type at
|
|
5
|
+
* runtime and performs a TypeScript type assertion if validation passes. Unlike
|
|
6
|
+
* regular assertion functions that return the validated value, assertion guards
|
|
7
|
+
* return nothing but automatically cast the input parameter to the expected
|
|
8
|
+
* type `T`.
|
|
8
9
|
*
|
|
9
|
-
* This type is used by `typia.createAssertGuard<T>()` and
|
|
10
|
-
* to generate reusable assertion guard
|
|
11
|
-
*
|
|
12
|
-
* @template T - The expected type to validate and assert against
|
|
13
|
-
* @param input - The value to validate (type unknown)
|
|
14
|
-
* @throws {TypeGuardError} When the input value doesn't match the expected type T
|
|
15
|
-
* @returns void - Returns nothing, but asserts that input is type T
|
|
10
|
+
* This type is used by `typia.createAssertGuard<T>()` and
|
|
11
|
+
* `typia.createAssertGuardEquals<T>()` to generate reusable assertion guard
|
|
12
|
+
* functions.
|
|
16
13
|
*
|
|
14
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
17
15
|
* @example
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
16
|
+
* ```typescript
|
|
17
|
+
* interface IMember {
|
|
18
|
+
* name: string;
|
|
19
|
+
* age: number;
|
|
20
|
+
* }
|
|
23
21
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
22
|
+
* // Create reusable assertion guard
|
|
23
|
+
* const assertMember: AssertionGuard<IMember> = typia.createAssertGuard<IMember>();
|
|
26
24
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
25
|
+
* // Usage - input will be automatically cast to IMember if validation passes
|
|
26
|
+
* const unknownData: unknown = { name: "John", age: 25 };
|
|
29
27
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
28
|
+
* assertMember(unknownData);
|
|
29
|
+
* // After this line, unknownData is automatically treated as IMember type
|
|
30
|
+
* console.log(unknownData.name); // TypeScript knows this is safe
|
|
31
|
+
* ```;
|
|
34
32
|
*
|
|
33
|
+
* @template T - The expected type to validate and assert against
|
|
34
|
+
* @param input - The value to validate (type unknown)
|
|
35
|
+
* @returns Void - Returns nothing, but asserts that input is type T
|
|
36
|
+
* @throws {TypeGuardError} When the input value doesn't match the expected type
|
|
37
|
+
* T
|
|
35
38
|
* @see {@link https://github.com/samchon/typia#assertguard-functions} Typia assertion guards documentation
|
|
36
39
|
* @see {@link TypeGuardError} Error thrown when assertion fails
|
|
37
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
38
40
|
*/
|
|
39
41
|
export type AssertionGuard<T> = (input: unknown) => asserts input is T;
|
package/lib/AssertionGuard.d.ts
CHANGED
|
@@ -1,39 +1,41 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Type definition for assertion guard functions in `typia`.
|
|
3
3
|
*
|
|
4
|
-
* An assertion guard is a function that asserts an input value's type at
|
|
5
|
-
* and performs a TypeScript type assertion if validation passes. Unlike
|
|
6
|
-
* assertion functions that return the validated value, assertion guards
|
|
7
|
-
* nothing but automatically cast the input parameter to the expected
|
|
4
|
+
* An assertion guard is a function that asserts an input value's type at
|
|
5
|
+
* runtime and performs a TypeScript type assertion if validation passes. Unlike
|
|
6
|
+
* regular assertion functions that return the validated value, assertion guards
|
|
7
|
+
* return nothing but automatically cast the input parameter to the expected
|
|
8
|
+
* type `T`.
|
|
8
9
|
*
|
|
9
|
-
* This type is used by `typia.createAssertGuard<T>()` and
|
|
10
|
-
* to generate reusable assertion guard
|
|
11
|
-
*
|
|
12
|
-
* @template T - The expected type to validate and assert against
|
|
13
|
-
* @param input - The value to validate (type unknown)
|
|
14
|
-
* @throws {TypeGuardError} When the input value doesn't match the expected type T
|
|
15
|
-
* @returns void - Returns nothing, but asserts that input is type T
|
|
10
|
+
* This type is used by `typia.createAssertGuard<T>()` and
|
|
11
|
+
* `typia.createAssertGuardEquals<T>()` to generate reusable assertion guard
|
|
12
|
+
* functions.
|
|
16
13
|
*
|
|
14
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
17
15
|
* @example
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
16
|
+
* ```typescript
|
|
17
|
+
* interface IMember {
|
|
18
|
+
* name: string;
|
|
19
|
+
* age: number;
|
|
20
|
+
* }
|
|
23
21
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
22
|
+
* // Create reusable assertion guard
|
|
23
|
+
* const assertMember: AssertionGuard<IMember> = typia.createAssertGuard<IMember>();
|
|
26
24
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
25
|
+
* // Usage - input will be automatically cast to IMember if validation passes
|
|
26
|
+
* const unknownData: unknown = { name: "John", age: 25 };
|
|
29
27
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
28
|
+
* assertMember(unknownData);
|
|
29
|
+
* // After this line, unknownData is automatically treated as IMember type
|
|
30
|
+
* console.log(unknownData.name); // TypeScript knows this is safe
|
|
31
|
+
* ```;
|
|
34
32
|
*
|
|
33
|
+
* @template T - The expected type to validate and assert against
|
|
34
|
+
* @param input - The value to validate (type unknown)
|
|
35
|
+
* @returns Void - Returns nothing, but asserts that input is type T
|
|
36
|
+
* @throws {TypeGuardError} When the input value doesn't match the expected type
|
|
37
|
+
* T
|
|
35
38
|
* @see {@link https://github.com/samchon/typia#assertguard-functions} Typia assertion guards documentation
|
|
36
39
|
* @see {@link TypeGuardError} Error thrown when assertion fails
|
|
37
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
38
40
|
*/
|
|
39
41
|
export type AssertionGuard<T> = (input: unknown) => asserts input is T;
|
package/lib/CamelCase.d.mts
CHANGED
|
@@ -9,8 +9,8 @@ import { ValueOf } from "./typings/ValueOf";
|
|
|
9
9
|
*
|
|
10
10
|
* It also erases every method property like {@link Resolved} type.
|
|
11
11
|
*
|
|
12
|
-
* @template T Target type to be camelized
|
|
13
12
|
* @author Jeongho Nam - https://github.com/samchon
|
|
13
|
+
* @template T Target type to be camelized
|
|
14
14
|
*/
|
|
15
15
|
export type CamelCase<T> = Equal<T, CamelizeMain<T>> extends true ? T : CamelizeMain<T>;
|
|
16
16
|
type CamelizeMain<T> = T extends [never] ? never : T extends {
|
package/lib/CamelCase.d.ts
CHANGED
|
@@ -9,8 +9,8 @@ import { ValueOf } from "./typings/ValueOf";
|
|
|
9
9
|
*
|
|
10
10
|
* It also erases every method property like {@link Resolved} type.
|
|
11
11
|
*
|
|
12
|
-
* @template T Target type to be camelized
|
|
13
12
|
* @author Jeongho Nam - https://github.com/samchon
|
|
13
|
+
* @template T Target type to be camelized
|
|
14
14
|
*/
|
|
15
15
|
export type CamelCase<T> = Equal<T, CamelizeMain<T>> extends true ? T : CamelizeMain<T>;
|
|
16
16
|
type CamelizeMain<T> = T extends [never] ? never : T extends {
|
|
@@ -2,28 +2,28 @@ import { OpenApi } from "@samchon/openapi";
|
|
|
2
2
|
/**
|
|
3
3
|
* Interface for generating random values for various data types.
|
|
4
4
|
*
|
|
5
|
-
* `IRandomGenerator` defines the contract for generating random values
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* `IRandomGenerator` defines the contract for generating random values that can
|
|
6
|
+
* be used by typia for creating mock data, testing scenarios, and random value
|
|
7
|
+
* generation based on JSON schema constraints.
|
|
8
8
|
*
|
|
9
9
|
* This interface supports generating random values for:
|
|
10
|
+
*
|
|
10
11
|
* - Basic types (boolean, number, integer, bigint, string, array)
|
|
11
12
|
* - String format patterns (email, URL, UUID, etc.)
|
|
12
13
|
* - Date and time formats
|
|
13
14
|
* - Various address and identifier formats
|
|
14
15
|
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```typescript
|
|
17
|
-
* const generator: IRandomGenerator = {
|
|
18
|
-
* boolean: () => Math.random() > 0.5,
|
|
19
|
-
* number: (schema) => Math.random() * (schema.maximum ?? 100),
|
|
20
|
-
* string: (schema) => "example-string",
|
|
21
|
-
* email: () => "test@example.com",
|
|
22
|
-
* // ... implement other methods
|
|
23
|
-
* };
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
16
|
* @author Jeongho Nam - https://github.com/samchon
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const generator: IRandomGenerator = {
|
|
20
|
+
* boolean: () => Math.random() > 0.5,
|
|
21
|
+
* number: (schema) => Math.random() * (schema.maximum ?? 100),
|
|
22
|
+
* string: (schema) => "example-string",
|
|
23
|
+
* email: () => "test@example.com",
|
|
24
|
+
* // ... implement other methods
|
|
25
|
+
* };
|
|
26
|
+
* ```;
|
|
27
27
|
*/
|
|
28
28
|
export interface IRandomGenerator {
|
|
29
29
|
/**
|
|
@@ -56,12 +56,14 @@ export interface IRandomGenerator {
|
|
|
56
56
|
/**
|
|
57
57
|
* Generates a random string based on JSON schema constraints.
|
|
58
58
|
*
|
|
59
|
-
* @param schema JSON schema with string constraints (minLength, maxLength,
|
|
59
|
+
* @param schema JSON schema with string constraints (minLength, maxLength,
|
|
60
|
+
* pattern, etc.)
|
|
60
61
|
* @returns Random string matching the specified constraints
|
|
61
62
|
*/
|
|
62
63
|
string(schema: OpenApi.IJsonSchema.IString): string;
|
|
63
64
|
/**
|
|
64
|
-
* Generates a random array with elements created by the provided generator
|
|
65
|
+
* Generates a random array with elements created by the provided generator
|
|
66
|
+
* function.
|
|
65
67
|
*
|
|
66
68
|
* @param schema Array schema with element generator function
|
|
67
69
|
* @returns Random array with generated elements
|
|
@@ -221,37 +223,37 @@ export declare namespace IRandomGenerator {
|
|
|
221
223
|
/**
|
|
222
224
|
* Map of custom generators for different data types.
|
|
223
225
|
*
|
|
224
|
-
* This interface allows customization of random generation for specific
|
|
225
|
-
*
|
|
226
|
+
* This interface allows customization of random generation for specific types
|
|
227
|
+
* when they have certain schema properties or constraints.
|
|
226
228
|
*
|
|
227
229
|
* @example
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
230
|
+
* ```typescript
|
|
231
|
+
* const generator: Partial<IRandomGenerator> = {
|
|
232
|
+
* string: (schema) => {
|
|
233
|
+
* if ((schema as any)["x-typia-monetary"] === "dollar") {
|
|
234
|
+
* return "$" + Math.floor(Math.random() * 1000);
|
|
235
|
+
* }
|
|
236
|
+
* return "default-string";
|
|
237
|
+
* },
|
|
238
|
+
* number: (schema) => {
|
|
239
|
+
* if ((schema as any)["x-typia-powerOf"] !== undefined) {
|
|
240
|
+
* const powerOf = (schema as any)["x-typia-powerOf"];
|
|
241
|
+
* return Math.pow(powerOf, Math.random() * 10 + 1);
|
|
242
|
+
* }
|
|
243
|
+
* return Math.random() * 100;
|
|
240
244
|
* }
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
* };
|
|
244
|
-
* ```
|
|
245
|
+
* };
|
|
246
|
+
* ```;
|
|
245
247
|
*/
|
|
246
248
|
interface CustomMap {
|
|
247
249
|
/**
|
|
248
|
-
* Custom string generator that can handle special string formats
|
|
249
|
-
*
|
|
250
|
+
* Custom string generator that can handle special string formats based on
|
|
251
|
+
* schema properties.
|
|
250
252
|
*/
|
|
251
253
|
string?: (schema: OpenApi.IJsonSchema.IString & Record<string, any>) => string;
|
|
252
254
|
/**
|
|
253
|
-
* Custom number generator that can handle special number constraints
|
|
254
|
-
*
|
|
255
|
+
* Custom number generator that can handle special number constraints based
|
|
256
|
+
* on schema properties.
|
|
255
257
|
*/
|
|
256
258
|
number?: (schema: OpenApi.IJsonSchema.INumber & Record<string, any>) => number;
|
|
257
259
|
/**
|
|
@@ -260,8 +262,8 @@ export declare namespace IRandomGenerator {
|
|
|
260
262
|
*/
|
|
261
263
|
integer?: (schema: OpenApi.IJsonSchema.IInteger & Record<string, any>) => number;
|
|
262
264
|
/**
|
|
263
|
-
* Custom bigint generator that can handle special bigint constraints
|
|
264
|
-
*
|
|
265
|
+
* Custom bigint generator that can handle special bigint constraints based
|
|
266
|
+
* on schema properties.
|
|
265
267
|
*/
|
|
266
268
|
bigint?: (schema: OpenApi.IJsonSchema.IInteger & Record<string, any>) => bigint;
|
|
267
269
|
/**
|
|
@@ -270,8 +272,8 @@ export declare namespace IRandomGenerator {
|
|
|
270
272
|
*/
|
|
271
273
|
boolean?: (schema: Record<string, any>) => boolean | undefined;
|
|
272
274
|
/**
|
|
273
|
-
* Custom array generator that can handle special array constraints
|
|
274
|
-
*
|
|
275
|
+
* Custom array generator that can handle special array constraints based on
|
|
276
|
+
* schema properties.
|
|
275
277
|
*/
|
|
276
278
|
array?: <T>(schema: Omit<OpenApi.IJsonSchema.IArray, "items"> & {
|
|
277
279
|
element: (index: number, count: number) => T;
|