typia 3.3.12 → 3.4.0-dev.20221212-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/README.md +169 -403
- package/lib/IValidation.d.ts +10 -4
- package/lib/Primitive.d.ts +45 -0
- package/lib/Primitive.js +3 -0
- package/lib/Primitive.js.map +1 -0
- package/lib/executable/internal/TypiaSetupWizard.d.ts +4 -0
- package/lib/executable/internal/TypiaSetupWizard.js +200 -0
- package/lib/executable/internal/TypiaSetupWizard.js.map +1 -0
- package/lib/executable/typia.d.ts +1 -0
- package/lib/executable/typia.js +98 -0
- package/lib/executable/typia.js.map +1 -0
- package/lib/factories/CommentFactory.js +1 -1
- package/lib/factories/CommentFactory.js.map +1 -1
- package/lib/factories/ExpressionFactory.d.ts +1 -0
- package/lib/factories/ExpressionFactory.js +4 -0
- package/lib/factories/ExpressionFactory.js.map +1 -1
- package/lib/factories/IdentifierFactory.d.ts +1 -1
- package/lib/factories/IdentifierFactory.js +4 -2
- package/lib/factories/IdentifierFactory.js.map +1 -1
- package/lib/factories/MetadataCollection.d.ts +2 -1
- package/lib/factories/MetadataCollection.js +24 -5
- package/lib/factories/MetadataCollection.js.map +1 -1
- package/lib/factories/MetadataTagFactory.js +1 -1
- package/lib/factories/MetadataTagFactory.js.map +1 -1
- package/lib/factories/StatementFactory.d.ts +1 -3
- package/lib/factories/StatementFactory.js +3 -13
- package/lib/factories/StatementFactory.js.map +1 -1
- package/lib/factories/TemplateFactory.js +4 -0
- package/lib/factories/TemplateFactory.js.map +1 -1
- package/lib/factories/TypeFactory.d.ts +2 -1
- package/lib/factories/TypeFactory.js +14 -7
- package/lib/factories/TypeFactory.js.map +1 -1
- package/lib/factories/internal/explore_metadata.js +1 -1
- package/lib/factories/internal/explore_metadata.js.map +1 -1
- package/lib/factories/internal/iterate_metadata.js +12 -3
- package/lib/factories/internal/iterate_metadata.js.map +1 -1
- package/lib/factories/internal/iterate_metadata_array.js +2 -3
- package/lib/factories/internal/iterate_metadata_array.js.map +1 -1
- package/lib/factories/internal/iterate_metadata_atomic.js +30 -55
- package/lib/factories/internal/iterate_metadata_atomic.js.map +1 -1
- package/lib/factories/internal/iterate_metadata_coalesce.js +2 -3
- package/lib/factories/internal/iterate_metadata_coalesce.js.map +1 -1
- package/lib/factories/internal/iterate_metadata_map.d.ts +5 -0
- package/lib/factories/internal/iterate_metadata_map.js +30 -0
- package/lib/factories/internal/iterate_metadata_map.js.map +1 -0
- package/lib/factories/internal/iterate_metadata_native.d.ts +3 -0
- package/lib/factories/internal/iterate_metadata_native.js +230 -0
- package/lib/factories/internal/iterate_metadata_native.js.map +1 -0
- package/lib/factories/internal/iterate_metadata_set.d.ts +5 -0
- package/lib/factories/internal/iterate_metadata_set.js +26 -0
- package/lib/factories/internal/iterate_metadata_set.js.map +1 -0
- package/lib/factories/internal/iterate_metadata_tuple.d.ts +1 -1
- package/lib/factories/internal/iterate_metadata_tuple.js +25 -3
- package/lib/factories/internal/iterate_metadata_tuple.js.map +1 -1
- package/lib/functional/$every.d.ts +2 -0
- package/lib/functional/$every.js +12 -0
- package/lib/functional/$every.js.map +1 -0
- package/lib/functional/$guard.d.ts +1 -0
- package/lib/functional/$guard.js +18 -0
- package/lib/functional/$guard.js.map +1 -0
- package/lib/functional/$number.js +4 -4
- package/lib/functional/$number.js.map +1 -1
- package/lib/functional/$report.d.ts +2 -0
- package/lib/functional/$report.js +18 -0
- package/lib/functional/$report.js.map +1 -0
- package/lib/functional/$rest.d.ts +1 -0
- package/lib/functional/$rest.js +8 -0
- package/lib/functional/$rest.js.map +1 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/metadata/IMetadata.d.ts +5 -0
- package/lib/metadata/IMetadataApplication.d.ts +6 -0
- package/lib/metadata/IMetadataApplication.js +3 -0
- package/lib/metadata/IMetadataApplication.js.map +1 -0
- package/lib/metadata/IMetadataConstant.d.ts +1 -1
- package/lib/metadata/IMetadataEntry.d.ts +5 -0
- package/lib/metadata/IMetadataEntry.js +3 -0
- package/lib/metadata/IMetadataEntry.js.map +1 -0
- package/lib/metadata/IMetadataTag.d.ts +1 -1
- package/lib/metadata/Metadata.d.ts +10 -0
- package/lib/metadata/Metadata.js +156 -59
- package/lib/metadata/Metadata.js.map +1 -1
- package/lib/metadata/MetadataObject.d.ts +0 -1
- package/lib/metadata/MetadataObject.js +10 -0
- package/lib/metadata/MetadataObject.js.map +1 -1
- package/lib/module.d.ts +603 -72
- package/lib/module.js +185 -23
- package/lib/module.js.map +1 -1
- package/lib/programmers/ApplicationProgrammer.js +2 -2
- package/lib/programmers/ApplicationProgrammer.js.map +1 -1
- package/lib/programmers/AssertParseProgrammer.d.ts +5 -0
- package/lib/programmers/AssertParseProgrammer.js +23 -0
- package/lib/programmers/AssertParseProgrammer.js.map +1 -0
- package/lib/programmers/AssertProgrammer.d.ts +1 -1
- package/lib/programmers/AssertProgrammer.js +133 -58
- package/lib/programmers/AssertProgrammer.js.map +1 -1
- package/lib/programmers/AssertStringifyProgrammer.d.ts +5 -0
- package/lib/programmers/AssertStringifyProgrammer.js +26 -0
- package/lib/programmers/AssertStringifyProgrammer.js.map +1 -0
- package/lib/programmers/CheckerProgrammer.d.ts +17 -7
- package/lib/programmers/CheckerProgrammer.js +284 -79
- package/lib/programmers/CheckerProgrammer.js.map +1 -1
- package/lib/programmers/FeatureProgrammer.d.ts +14 -9
- package/lib/programmers/FeatureProgrammer.js +76 -116
- package/lib/programmers/FeatureProgrammer.js.map +1 -1
- package/lib/programmers/IsParseProgrammer.d.ts +5 -0
- package/lib/programmers/IsParseProgrammer.js +23 -0
- package/lib/programmers/IsParseProgrammer.js.map +1 -0
- package/lib/programmers/IsProgrammer.d.ts +5 -4
- package/lib/programmers/IsProgrammer.js +69 -44
- package/lib/programmers/IsProgrammer.js.map +1 -1
- package/lib/programmers/IsStringifyProgrammer.d.ts +5 -0
- package/lib/programmers/IsStringifyProgrammer.js +24 -0
- package/lib/programmers/IsStringifyProgrammer.js.map +1 -0
- package/lib/programmers/StringifyProgrammer.js +118 -47
- package/lib/programmers/StringifyProgrammer.js.map +1 -1
- package/lib/programmers/ValidateParseProgrammer.d.ts +5 -0
- package/lib/programmers/ValidateParseProgrammer.js +24 -0
- package/lib/programmers/ValidateParseProgrammer.js.map +1 -0
- package/lib/programmers/ValidateProgrammer.d.ts +1 -1
- package/lib/programmers/ValidateProgrammer.js +124 -68
- package/lib/programmers/ValidateProgrammer.js.map +1 -1
- package/lib/programmers/ValidateStringifyProgrammer.d.ts +5 -0
- package/lib/programmers/ValidateStringifyProgrammer.js +26 -0
- package/lib/programmers/ValidateStringifyProgrammer.js.map +1 -0
- package/lib/programmers/helpers/AtomicPredicator.d.ts +6 -0
- package/lib/programmers/helpers/AtomicPredicator.js +16 -0
- package/lib/programmers/helpers/AtomicPredicator.js.map +1 -0
- package/lib/programmers/helpers/FunctionImporeter.js +1 -1
- package/lib/programmers/helpers/FunctionImporeter.js.map +1 -1
- package/lib/programmers/helpers/OptionPredicator.d.ts +1 -1
- package/lib/programmers/helpers/OptionPredicator.js +7 -7
- package/lib/programmers/helpers/OptionPredicator.js.map +1 -1
- package/lib/programmers/helpers/StringifyJoinder.d.ts +2 -2
- package/lib/programmers/helpers/StringifyJoinder.js +5 -2
- package/lib/programmers/helpers/StringifyJoinder.js.map +1 -1
- package/lib/programmers/helpers/UnionExplorer.d.ts +33 -4
- package/lib/programmers/helpers/UnionExplorer.js +85 -47
- package/lib/programmers/helpers/UnionExplorer.js.map +1 -1
- package/lib/programmers/internal/application_array.js +1 -1
- package/lib/programmers/internal/application_array.js.map +1 -1
- package/lib/programmers/internal/application_default.js +1 -1
- package/lib/programmers/internal/application_default.js.map +1 -1
- package/lib/programmers/internal/application_native.d.ts +4 -0
- package/lib/programmers/internal/application_native.js +35 -0
- package/lib/programmers/internal/application_native.js.map +1 -0
- package/lib/programmers/internal/application_number.js +6 -2
- package/lib/programmers/internal/application_number.js.map +1 -1
- package/lib/programmers/internal/application_object.js +44 -31
- package/lib/programmers/internal/application_object.js.map +1 -1
- package/lib/programmers/internal/application_schema.js +70 -36
- package/lib/programmers/internal/application_schema.js.map +1 -1
- package/lib/programmers/internal/application_string.js +2 -2
- package/lib/programmers/internal/application_string.js.map +1 -1
- package/lib/programmers/internal/check_array.js +4 -10
- package/lib/programmers/internal/check_array.js.map +1 -1
- package/lib/programmers/internal/check_dynamic_properties.js +40 -50
- package/lib/programmers/internal/check_dynamic_properties.js.map +1 -1
- package/lib/programmers/internal/check_everything.js +1 -3
- package/lib/programmers/internal/check_everything.js.map +1 -1
- package/lib/programmers/internal/check_length.js +2 -2
- package/lib/programmers/internal/check_length.js.map +1 -1
- package/lib/programmers/internal/check_native.d.ts +1 -0
- package/lib/programmers/internal/check_native.js +9 -0
- package/lib/programmers/internal/check_native.js.map +1 -0
- package/lib/programmers/internal/check_number.js +1 -1
- package/lib/programmers/internal/check_number.js.map +1 -1
- package/lib/programmers/internal/check_object.d.ts +12 -1
- package/lib/programmers/internal/check_object.js +12 -22
- package/lib/programmers/internal/check_object.js.map +1 -1
- package/lib/programmers/internal/decode_union_object.js +9 -7
- package/lib/programmers/internal/decode_union_object.js.map +1 -1
- package/lib/programmers/internal/feature_object_entries.d.ts +9 -0
- package/lib/programmers/internal/feature_object_entries.js +38 -0
- package/lib/programmers/internal/feature_object_entries.js.map +1 -0
- package/lib/programmers/internal/stringify_dynamic_properties.js +4 -2
- package/lib/programmers/internal/stringify_dynamic_properties.js.map +1 -1
- package/lib/programmers/internal/stringify_native.d.ts +1 -0
- package/lib/programmers/internal/stringify_native.js +12 -0
- package/lib/programmers/internal/stringify_native.js.map +1 -0
- package/lib/schemas/IJsonComponents.d.ts +1 -1
- package/lib/schemas/IJsonSchema.d.ts +10 -8
- package/lib/transformers/CallExpressionTransformer.js +47 -10
- package/lib/transformers/CallExpressionTransformer.js.map +1 -1
- package/lib/transformers/FileTransformer.js +1 -1
- package/lib/transformers/features/{ApplicationTransformer.d.ts → miscellaneous/ApplicationTransformer.d.ts} +1 -1
- package/lib/transformers/features/{ApplicationTransformer.js → miscellaneous/ApplicationTransformer.js} +8 -8
- package/lib/transformers/features/miscellaneous/ApplicationTransformer.js.map +1 -0
- package/lib/transformers/features/{CreateTransformer.d.ts → miscellaneous/CreateInstanceTransformer.d.ts} +2 -2
- package/lib/transformers/features/{CreateTransformer.js → miscellaneous/CreateInstanceTransformer.js} +8 -8
- package/lib/transformers/features/miscellaneous/CreateInstanceTransformer.js.map +1 -0
- package/lib/transformers/features/miscellaneous/MetadataTransformer.d.ts +5 -0
- package/lib/transformers/features/miscellaneous/MetadataTransformer.js +43 -0
- package/lib/transformers/features/miscellaneous/MetadataTransformer.js.map +1 -0
- package/lib/transformers/features/parsers/AssertParseTransformer.d.ts +5 -0
- package/lib/transformers/features/parsers/AssertParseTransformer.js +21 -0
- package/lib/transformers/features/parsers/AssertParseTransformer.js.map +1 -0
- package/lib/transformers/features/parsers/CreateAssertParseTransformer.d.ts +5 -0
- package/lib/transformers/features/parsers/CreateAssertParseTransformer.js +17 -0
- package/lib/transformers/features/parsers/CreateAssertParseTransformer.js.map +1 -0
- package/lib/transformers/features/parsers/CreateIsParseTransformer.d.ts +5 -0
- package/lib/transformers/features/parsers/CreateIsParseTransformer.js +17 -0
- package/lib/transformers/features/parsers/CreateIsParseTransformer.js.map +1 -0
- package/lib/transformers/features/parsers/CreateValidateParseTransformer.d.ts +5 -0
- package/lib/transformers/features/parsers/CreateValidateParseTransformer.js +17 -0
- package/lib/transformers/features/parsers/CreateValidateParseTransformer.js.map +1 -0
- package/lib/transformers/features/parsers/IsParseTransformer.d.ts +5 -0
- package/lib/transformers/features/parsers/IsParseTransformer.js +21 -0
- package/lib/transformers/features/parsers/IsParseTransformer.js.map +1 -0
- package/lib/transformers/features/parsers/ValidateParseTransformer.d.ts +5 -0
- package/lib/transformers/features/parsers/ValidateParseTransformer.js +21 -0
- package/lib/transformers/features/parsers/ValidateParseTransformer.js.map +1 -0
- package/lib/transformers/features/stringifiers/AssertStringifyTransformer.d.ts +5 -0
- package/lib/transformers/features/stringifiers/AssertStringifyTransformer.js +23 -0
- package/lib/transformers/features/stringifiers/AssertStringifyTransformer.js.map +1 -0
- package/lib/transformers/features/stringifiers/CreateAssertStringifyTransformer.d.ts +5 -0
- package/lib/transformers/features/stringifiers/CreateAssertStringifyTransformer.js +17 -0
- package/lib/transformers/features/stringifiers/CreateAssertStringifyTransformer.js.map +1 -0
- package/lib/transformers/features/stringifiers/CreateIsStringifyTransformer.d.ts +5 -0
- package/lib/transformers/features/stringifiers/CreateIsStringifyTransformer.js +17 -0
- package/lib/transformers/features/stringifiers/CreateIsStringifyTransformer.js.map +1 -0
- package/lib/transformers/features/stringifiers/CreateStringifyTransformer.d.ts +5 -0
- package/lib/transformers/features/stringifiers/CreateStringifyTransformer.js +17 -0
- package/lib/transformers/features/stringifiers/CreateStringifyTransformer.js.map +1 -0
- package/lib/transformers/features/stringifiers/CreateValidateStringifyProgrammer.d.ts +5 -0
- package/lib/transformers/features/stringifiers/CreateValidateStringifyProgrammer.js +17 -0
- package/lib/transformers/features/stringifiers/CreateValidateStringifyProgrammer.js.map +1 -0
- package/lib/transformers/features/stringifiers/IsStringifyTransformer.d.ts +5 -0
- package/lib/transformers/features/stringifiers/IsStringifyTransformer.js +23 -0
- package/lib/transformers/features/stringifiers/IsStringifyTransformer.js.map +1 -0
- package/lib/transformers/features/{StringifyTransformer.d.ts → stringifiers/StringifyTransformer.d.ts} +1 -1
- package/lib/transformers/features/{StringifyTransformer.js → stringifiers/StringifyTransformer.js} +3 -3
- package/lib/transformers/features/stringifiers/StringifyTransformer.js.map +1 -0
- package/lib/transformers/features/stringifiers/ValidateStringifyTransformer.d.ts +5 -0
- package/lib/transformers/features/stringifiers/ValidateStringifyTransformer.js +23 -0
- package/lib/transformers/features/stringifiers/ValidateStringifyTransformer.js.map +1 -0
- package/lib/transformers/features/{AssertTransformer.d.ts → validators/AssertTransformer.d.ts} +1 -1
- package/lib/transformers/features/{AssertTransformer.js → validators/AssertTransformer.js} +4 -4
- package/lib/transformers/features/validators/AssertTransformer.js.map +1 -0
- package/lib/transformers/features/validators/CreateAssertTransformer.d.ts +5 -0
- package/lib/transformers/features/validators/CreateAssertTransformer.js +24 -0
- package/lib/transformers/features/validators/CreateAssertTransformer.js.map +1 -0
- package/lib/transformers/features/validators/CreateIsTransformer.d.ts +5 -0
- package/lib/transformers/features/validators/CreateIsTransformer.js +24 -0
- package/lib/transformers/features/validators/CreateIsTransformer.js.map +1 -0
- package/lib/transformers/features/validators/CreateValidateTransformer.d.ts +5 -0
- package/lib/transformers/features/validators/CreateValidateTransformer.js +24 -0
- package/lib/transformers/features/validators/CreateValidateTransformer.js.map +1 -0
- package/lib/transformers/features/{IsTransformer.d.ts → validators/IsTransformer.d.ts} +1 -1
- package/lib/transformers/features/{IsTransformer.js → validators/IsTransformer.js} +3 -3
- package/lib/transformers/features/validators/IsTransformer.js.map +1 -0
- package/lib/transformers/features/{ValidateTransformer.d.ts → validators/ValidateTransformer.d.ts} +1 -1
- package/lib/transformers/features/{ValidateTransformer.js → validators/ValidateTransformer.js} +3 -3
- package/lib/transformers/features/validators/ValidateTransformer.js.map +1 -0
- package/lib/typings/ClassProperties.d.ts +1 -1
- package/lib/typings/OmitNever.d.ts +1 -1
- package/lib/typings/SpecialFields.d.ts +1 -1
- package/lib/typings/Writable.d.ts +1 -1
- package/lib/utils/PatternUtil.js +1 -1
- package/lib/utils/PatternUtil.js.map +1 -1
- package/package.json +114 -78
- package/src/IValidation.ts +21 -0
- package/src/Primitive.ts +82 -0
- package/src/TypeGuardError.ts +36 -0
- package/src/executable/internal/TypiaSetupWizard.ts +130 -0
- package/src/executable/typia.ts +34 -0
- package/src/factories/CommentFactory.ts +10 -0
- package/src/factories/ExpressionFactory.ts +52 -0
- package/src/factories/IdentifierFactory.ts +72 -0
- package/src/factories/LiteralFactory.ts +44 -0
- package/src/factories/MetadataCollection.ts +122 -0
- package/src/factories/MetadataFactory.ts +46 -0
- package/src/factories/MetadataTagFactory.ts +347 -0
- package/src/factories/StatementFactory.ts +60 -0
- package/src/factories/TemplateFactory.ts +56 -0
- package/src/factories/TypeFactory.ts +101 -0
- package/src/factories/ValueFactory.ts +12 -0
- package/src/factories/internal/MetadataHelper.ts +12 -0
- package/src/factories/internal/emplace_metadata_object.ts +140 -0
- package/src/factories/internal/explore_metadata.ts +91 -0
- package/src/factories/internal/iterate_metadata.ts +81 -0
- package/src/factories/internal/iterate_metadata_array.ts +29 -0
- package/src/factories/internal/iterate_metadata_atomic.ts +59 -0
- package/src/factories/internal/iterate_metadata_coalesce.ts +33 -0
- package/src/factories/internal/iterate_metadata_constant.ts +58 -0
- package/src/factories/internal/iterate_metadata_map.ts +41 -0
- package/src/factories/internal/iterate_metadata_native.ts +227 -0
- package/src/factories/internal/iterate_metadata_object.ts +45 -0
- package/src/factories/internal/iterate_metadata_resolve.ts +27 -0
- package/src/factories/internal/iterate_metadata_set.ts +33 -0
- package/src/factories/internal/iterate_metadata_template.ts +38 -0
- package/src/factories/internal/iterate_metadata_tuple.ts +51 -0
- package/src/factories/internal/iterate_metadata_union.ts +59 -0
- package/src/functional/$every.ts +11 -0
- package/src/functional/$guard.ts +35 -0
- package/src/functional/$is_email.ts +5 -0
- package/src/functional/$is_ipv4.ts +5 -0
- package/src/functional/$is_ipv6.ts +5 -0
- package/src/functional/$is_url.ts +5 -0
- package/src/functional/$is_uuid.ts +5 -0
- package/src/functional/$join.ts +50 -0
- package/src/functional/$number.ts +19 -0
- package/src/functional/$report.ts +15 -0
- package/src/functional/$rest.ts +3 -0
- package/src/functional/$string.ts +37 -0
- package/src/functional/$tail.ts +6 -0
- package/src/index.ts +4 -0
- package/src/metadata/IJsDocTagInfo.ts +10 -0
- package/src/metadata/IMetadata.ts +25 -0
- package/src/metadata/IMetadataApplication.ts +7 -0
- package/src/metadata/IMetadataConstant.ts +16 -0
- package/src/metadata/IMetadataEntry.ts +6 -0
- package/src/metadata/IMetadataObject.ts +29 -0
- package/src/metadata/IMetadataProperty.ts +11 -0
- package/src/metadata/IMetadataTag.ts +122 -0
- package/src/metadata/Metadata.ts +477 -0
- package/src/metadata/MetadataConstant.ts +3 -0
- package/src/metadata/MetadataObject.ts +131 -0
- package/src/metadata/MetadataProperty.ts +64 -0
- package/src/module.ts +1535 -0
- package/src/programmers/ApplicationProgrammer.ts +55 -0
- package/src/programmers/AssertParseProgrammer.ts +45 -0
- package/src/programmers/AssertProgrammer.ts +444 -0
- package/src/programmers/AssertStringifyProgrammer.ts +45 -0
- package/src/programmers/CheckerProgrammer.ts +798 -0
- package/src/programmers/FeatureProgrammer.ts +327 -0
- package/src/programmers/IsParseProgrammer.ts +51 -0
- package/src/programmers/IsProgrammer.ts +169 -0
- package/src/programmers/IsStringifyProgrammer.ts +49 -0
- package/src/programmers/StringifyProgrammer.ts +746 -0
- package/src/programmers/ValidateParseProgrammer.ts +49 -0
- package/src/programmers/ValidateProgrammer.ts +236 -0
- package/src/programmers/ValidateStringifyProgrammer.ts +60 -0
- package/src/programmers/helpers/AtomicPredicator.ts +15 -0
- package/src/programmers/helpers/FunctionImporeter.ts +31 -0
- package/src/programmers/helpers/IExpressionEntry.ts +10 -0
- package/src/programmers/helpers/OptionPredicator.ts +18 -0
- package/src/programmers/helpers/StringifyJoinder.ts +111 -0
- package/src/programmers/helpers/StringifyPredicator.ts +18 -0
- package/src/programmers/helpers/UnionExplorer.ts +437 -0
- package/src/programmers/helpers/UnionPredicator.ts +81 -0
- package/src/programmers/internal/application_array.ts +45 -0
- package/src/programmers/internal/application_boolean.ts +17 -0
- package/src/programmers/internal/application_constant.ts +29 -0
- package/src/programmers/internal/application_default.ts +17 -0
- package/src/programmers/internal/application_default_string.ts +32 -0
- package/src/programmers/internal/application_native.ts +29 -0
- package/src/programmers/internal/application_number.ts +76 -0
- package/src/programmers/internal/application_object.ts +103 -0
- package/src/programmers/internal/application_schema.ts +221 -0
- package/src/programmers/internal/application_string.ts +49 -0
- package/src/programmers/internal/application_templates.ts +27 -0
- package/src/programmers/internal/application_tuple.ts +25 -0
- package/src/programmers/internal/check_array.ts +44 -0
- package/src/programmers/internal/check_dynamic_properties.ts +146 -0
- package/src/programmers/internal/check_everything.ts +25 -0
- package/src/programmers/internal/check_length.ts +46 -0
- package/src/programmers/internal/check_native.ts +9 -0
- package/src/programmers/internal/check_number.ts +181 -0
- package/src/programmers/internal/check_object.ts +42 -0
- package/src/programmers/internal/check_string.ts +24 -0
- package/src/programmers/internal/check_string_tags.ts +63 -0
- package/src/programmers/internal/check_template.ts +50 -0
- package/src/programmers/internal/decode_union_object.ts +73 -0
- package/src/programmers/internal/feature_object_entries.ts +49 -0
- package/src/programmers/internal/metadata_to_pattern.ts +31 -0
- package/src/programmers/internal/stringify_dynamic_properties.ts +164 -0
- package/src/programmers/internal/stringify_native.ts +8 -0
- package/src/programmers/internal/stringify_regular_properties.ts +81 -0
- package/src/programmers/internal/template_to_pattern.ts +15 -0
- package/src/schemas/IJsonApplication.ts +9 -0
- package/src/schemas/IJsonComponents.ts +24 -0
- package/src/schemas/IJsonSchema.ts +92 -0
- package/src/transform.ts +20 -0
- package/src/transformers/CallExpressionTransformer.ts +124 -0
- package/src/transformers/ExpressionWithArgumentTransformer.ts +66 -0
- package/src/transformers/FileTransformer.ts +49 -0
- package/src/transformers/IProject.ts +11 -0
- package/src/transformers/ITransformOptions.ts +4 -0
- package/src/transformers/NodeTransformer.ts +19 -0
- package/src/transformers/features/miscellaneous/ApplicationTransformer.ts +114 -0
- package/src/transformers/features/miscellaneous/CreateInstanceTransformer.ts +41 -0
- package/src/transformers/features/miscellaneous/MetadataTransformer.ts +55 -0
- package/src/transformers/features/parsers/AssertParseTransformer.ts +36 -0
- package/src/transformers/features/parsers/CreateAssertParseTransformer.ts +32 -0
- package/src/transformers/features/parsers/CreateIsParseTransformer.ts +32 -0
- package/src/transformers/features/parsers/CreateValidateParseTransformer.ts +32 -0
- package/src/transformers/features/parsers/IsParseTransformer.ts +36 -0
- package/src/transformers/features/parsers/ValidateParseTransformer.ts +36 -0
- package/src/transformers/features/stringifiers/AssertStringifyTransformer.ts +38 -0
- package/src/transformers/features/stringifiers/CreateAssertStringifyTransformer.ts +32 -0
- package/src/transformers/features/stringifiers/CreateIsStringifyTransformer.ts +32 -0
- package/src/transformers/features/stringifiers/CreateStringifyTransformer.ts +31 -0
- package/src/transformers/features/stringifiers/CreateValidateStringifyProgrammer.ts +32 -0
- package/src/transformers/features/stringifiers/IsStringifyTransformer.ts +38 -0
- package/src/transformers/features/stringifiers/StringifyTransformer.ts +36 -0
- package/src/transformers/features/stringifiers/ValidateStringifyTransformer.ts +38 -0
- package/src/transformers/features/validators/AssertTransformer.ts +43 -0
- package/src/transformers/features/validators/CreateAssertTransformer.ts +35 -0
- package/src/transformers/features/validators/CreateIsTransformer.ts +35 -0
- package/src/transformers/features/validators/CreateValidateTransformer.ts +35 -0
- package/src/transformers/features/validators/IsTransformer.ts +43 -0
- package/src/transformers/features/validators/ValidateTransformer.ts +43 -0
- package/src/typings/Atomic.ts +17 -0
- package/src/typings/ClassProperties.ts +5 -0
- package/src/typings/OmitNever.ts +3 -0
- package/src/typings/SpecialFields.ts +3 -0
- package/src/typings/Writable.ts +11 -0
- package/src/utils/ArrayUtil.ts +49 -0
- package/src/utils/Escaper.ts +50 -0
- package/src/utils/MapUtil.ts +14 -0
- package/src/utils/PatternUtil.ts +30 -0
- package/src/utils/Singleton.ts +17 -0
- package/CODE_OF_CONDUCT.md +0 -133
- package/CONTRIBUTING.md +0 -104
- package/lib/transformers/features/ApplicationTransformer.js.map +0 -1
- package/lib/transformers/features/AssertTransformer.js.map +0 -1
- package/lib/transformers/features/CreateTransformer.js.map +0 -1
- package/lib/transformers/features/IsTransformer.js.map +0 -1
- package/lib/transformers/features/StringifyTransformer.js.map +0 -1
- package/lib/transformers/features/ValidateTransformer.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,113 +1,99 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
[](https://github.com/samchon/typescript-json/actions?query=workflow%3Abuild)
|
|
8
|
-
[](https://github.com/samchon/typescript-json/wiki)
|
|
9
|
-
|
|
10
|
-
- Github: https://github.com/samchon/typescript-json
|
|
11
|
-
- NPM: https://www.npmjs.com/package/typescript-json
|
|
12
|
-
- Guide Documents: https://github.com/samchon/typescript-json/wiki
|
|
1
|
+
# Typia
|
|
2
|
+
[](https://github.com/samchon/typia/blob/master/LICENSE)
|
|
3
|
+
[](https://www.npmjs.com/package/typia)
|
|
4
|
+
[](https://www.npmjs.com/package/typia)
|
|
5
|
+
[](https://github.com/samchon/typia/actions?query=workflow%3Abuild)
|
|
6
|
+
[](https://github.com/samchon/typia/wiki)
|
|
13
7
|
|
|
14
8
|
```typescript
|
|
15
|
-
import TSON from "typescript-json";
|
|
16
|
-
|
|
17
|
-
//----
|
|
18
9
|
// RUNTIME VALIDATORS
|
|
19
|
-
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
TSON.application<[T, U, V], "swagger">(); // JSON schema application generator
|
|
35
|
-
TSON.create<T>(input); // 2x faster object creator (only one-time construction)
|
|
10
|
+
export function is<T>(input: unknown | T): input is T; // returns boolean
|
|
11
|
+
export function assert<T>(input: unknown | T): T; // throws TypeGuardError
|
|
12
|
+
export function validate<T>(input: unknown | T): IValidation<T>; // detailed
|
|
13
|
+
|
|
14
|
+
// STRICT VALIDATORS
|
|
15
|
+
export function equals<T>(input: unknown: T): input is T;
|
|
16
|
+
export function assertEquals<T>(input: unknown | T): T;
|
|
17
|
+
export function validateEquals<T>(input: unknown | T): IValidation<T>;
|
|
18
|
+
|
|
19
|
+
// JSON
|
|
20
|
+
export function application<T>(): IJsonApplication; // JSON schema
|
|
21
|
+
export function assertParse<T>(input: string): T; // type safe parser
|
|
22
|
+
export function assertStringify<T>(input: T): string; // safe and faster
|
|
23
|
+
// +) isParse, validateParse
|
|
24
|
+
// +) stringify, isStringify, validateStringify
|
|
36
25
|
```
|
|
37
26
|
|
|
38
|
-
`
|
|
27
|
+
`typia` is a transformer library of TypeScript, supporting below features:
|
|
39
28
|
|
|
40
|
-
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
- Maximum 2,000x faster than other libraries
|
|
44
|
-
- 5x faster `JSON.stringify()` function:
|
|
45
|
-
- Performed by only one line: `TSON.stringify<T>(input)`
|
|
46
|
-
- Only one library which can stringify union type
|
|
47
|
-
- 10,000x faster optimizer construction time than similar libraries
|
|
29
|
+
- Super-fast Runtime Validators
|
|
30
|
+
- Safe JSON parse and fast stringify functions
|
|
31
|
+
- JSON schema generator
|
|
48
32
|
|
|
49
|
-
|
|
33
|
+
All functions in `typia` require **only one line**. You don't need any extra dedication like JSON schema definitions or decorator function calls. Just call `typia` function with only one line like `typia.assert<T>(input)`.
|
|
50
34
|
|
|
51
|
-
|
|
35
|
+
Also, as `typia` performs AOT (Ahead of Time) compilation skill, its performance is much faster than other competitive libaries. For an example, when comparing validate function `is()` with other competitive libraries, `typia` is maximum **15,000x times faster** than `class-validator`.
|
|
52
36
|
|
|
37
|
+
%20Core(TM)%20i5-1135G7%20%40%202.40GHz/images/is.svg)
|
|
53
38
|
|
|
39
|
+
> Measured on [Intel i5-1135g7, Surface Pro 8](https://github.com/samchon/typia/tree/master/benchmark/results/11th%20Gen%20Intel(R)%20Core(TM)%20i5-1135G7%20%40%202.40GHz#is)
|
|
54
40
|
|
|
55
41
|
|
|
56
|
-
## Setup
|
|
57
|
-
### NPM Package
|
|
58
|
-
At first, install this `typescript-json` by the `npm install` command.
|
|
59
42
|
|
|
60
|
-
Also, you need additional `devDependencies` to compile the TypeScript code with transformation. Therefore, install those all libraries `typescript`, `ttypescript` and `ts-node`. Inform that, `ttypescript` is not mis-writing. Do not forget to install the `ttypescript`.
|
|
61
43
|
|
|
44
|
+
## Setup
|
|
45
|
+
### Setup Wizard
|
|
62
46
|
```bash
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
# ENSURE THOSE PACKAGES ARE INSTALLED
|
|
66
|
-
npm install --save-dev typescript
|
|
67
|
-
npm install --save-dev ttypescript
|
|
68
|
-
npm install --save-dev ts-node
|
|
47
|
+
npx typia setup
|
|
69
48
|
```
|
|
70
49
|
|
|
71
|
-
|
|
72
|
-
After the installation, you've to configure `tsconfig.json` file like below.
|
|
73
|
-
|
|
74
|
-
Add a property `transform` and its value as `typescript-json/lib/transform` into `compilerOptions.plugins` array. When configuring, I recommend you to use the `strict` option, to enforce developers to distinguish whether each property is nullable or undefindable.
|
|
75
|
-
|
|
76
|
-
Also, you can configure additional properties like `numeric` and `functional`. The first, `numeric` is an option whether to test `Number.isNaN()` and `Number.isFinite()` to numeric value or not. The second, `functional` is an option whether to test function type or not. Default values of those options are all `true`.
|
|
77
|
-
|
|
78
|
-
```typescript
|
|
79
|
-
{
|
|
80
|
-
"compilerOptions": {
|
|
81
|
-
"strict": true,
|
|
82
|
-
"plugins": [
|
|
83
|
-
{
|
|
84
|
-
"transform": "typescript-json/lib/transform",
|
|
85
|
-
// "functional": true, // test function type
|
|
86
|
-
// "numeric": true, // test `isNaN()` and `isFinite()`
|
|
87
|
-
}
|
|
88
|
-
]
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
```
|
|
50
|
+
Just type `npx typia setup`, that's all.
|
|
92
51
|
|
|
93
|
-
After the
|
|
52
|
+
After the setup, you can compile `typia` utilized code by using `ttsc` ([`ttypescript`](https://github.com/cevek/ttypescript)) command. If you want to run your TypeScript file directly through `ts-node`, add `-C ttypescript` argument like below:
|
|
94
53
|
|
|
95
|
-
```bash
|
|
96
|
-
# COMPILE
|
|
54
|
+
<!-- ```bash
|
|
55
|
+
# COMPILE THROUGH TTYPESCRIPT
|
|
97
56
|
npx ttsc
|
|
98
57
|
|
|
99
|
-
#
|
|
100
|
-
npx ts-node -C ttypescript
|
|
58
|
+
# RUN TS-NODE WITH TTYPESCRIPT
|
|
59
|
+
npx ts-node -C ttypescript src/index.ts
|
|
101
60
|
```
|
|
102
61
|
|
|
62
|
+
> If you want to use only `tsc` command, you can choose another option: [`ts-patch`](https://github.com/nonara/ts-patch).
|
|
63
|
+
>
|
|
64
|
+
> Set it up through `npx typia setup ts-patch` command and compile your project with pure(?) TypeScript compiler (`tsc`). When you want to run your TypeScript file directly, just use the pure `ts-node`, too.
|
|
65
|
+
>
|
|
66
|
+
> However, note that, the `ts-patch` will modify JavaScript files in `node_modules/typescript` directly. Therefore, it may cause some problems when you update typescript version after the `setup` process, until running `npm run prepare` command.
|
|
67
|
+
>
|
|
68
|
+
> ```bash
|
|
69
|
+
> # SETUP
|
|
70
|
+
> npx typia setup ts-patch
|
|
71
|
+
>
|
|
72
|
+
> #COMPILE
|
|
73
|
+
> npx tsc
|
|
74
|
+
> npx ts-node src/index.ts
|
|
75
|
+
>
|
|
76
|
+
> # AFTER UPDATE, HAVE TO RUN PREPARE COMMAND
|
|
77
|
+
> npm install --save-dev typescript@latest
|
|
78
|
+
> npm run prepare
|
|
79
|
+
> ``` -->
|
|
80
|
+
|
|
81
|
+
### Manual Setup
|
|
82
|
+
If you want to install and setup `typia` manually, read [Guide Documents - Setup](https://github.com/samchon/typia/wiki/Setup).
|
|
83
|
+
|
|
84
|
+
- [NPM Packages](https://github.com/samchon/typia/wiki/Setup#npm-packages)
|
|
85
|
+
- [`tsconfig.json`](https://github.com/samchon/typia/wiki/Setup#tsconfigjson)
|
|
86
|
+
- [vite](https://github.com/samchon/typia/wiki/Setup#vite)
|
|
87
|
+
- [webpack](https://github.com/samchon/typia/wiki/Setup#webpack)
|
|
88
|
+
|
|
103
89
|
### vite
|
|
104
|
-
|
|
90
|
+
When you want to setup `typia` on your frontend project with [`vite`](https://vitejs.dev/), just configure `vite.config.ts` like below.
|
|
105
91
|
|
|
106
|
-
For reference, don't forget
|
|
92
|
+
For reference, don't forget [setting up](#setup) before.
|
|
107
93
|
|
|
108
94
|
```typescript
|
|
109
|
-
import { defineConfig } from
|
|
110
|
-
import react from
|
|
95
|
+
import { defineConfig } from "vite";
|
|
96
|
+
import react from "@vitejs/plugin-react";
|
|
111
97
|
import typescript from "@rollup/plugin-typescript";
|
|
112
98
|
import ttsc from "ttypescript";
|
|
113
99
|
|
|
@@ -122,156 +108,90 @@ export default defineConfig({
|
|
|
122
108
|
});
|
|
123
109
|
```
|
|
124
110
|
|
|
125
|
-
### webpack
|
|
126
|
-
If you're using `webpack` with `ts-loader`, configure the `webpack.config.js` file like below.
|
|
127
|
-
|
|
128
|
-
```javascript
|
|
129
|
-
const transform = require("typescript-json/lib/transform").default;
|
|
130
|
-
|
|
131
|
-
module.exports = {
|
|
132
|
-
// I am hiding the rest of the webpack config
|
|
133
|
-
module: {
|
|
134
|
-
rules: [
|
|
135
|
-
{
|
|
136
|
-
test: /\.(ts|tsx)$/,
|
|
137
|
-
exclude: /node_modules/,
|
|
138
|
-
loader: 'ts-loader',
|
|
139
|
-
options: {
|
|
140
|
-
getCustomTransformers: program => ({
|
|
141
|
-
before: [transform(program)]
|
|
142
|
-
// before: [
|
|
143
|
-
// transform(program, {
|
|
144
|
-
// functional: true,
|
|
145
|
-
// numeric: true
|
|
146
|
-
// })
|
|
147
|
-
// ]
|
|
148
|
-
})
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
]
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
```
|
|
155
|
-
|
|
156
111
|
|
|
157
112
|
|
|
158
113
|
|
|
159
114
|
## Features
|
|
115
|
+
[](https://github.com/samchon/typia/wiki)
|
|
116
|
+
|
|
117
|
+
In here README documents, only summarized informations are provided.
|
|
118
|
+
|
|
119
|
+
For more details, please refer to the [Guide Documents (wiki)](https://github.com/samchon/typia/wiki).
|
|
120
|
+
|
|
121
|
+
> - **Runtime Validators**
|
|
122
|
+
> - [powerful validator](https://github.com/samchon/typia/wiki/Runtime-Validators#powerful-validator)
|
|
123
|
+
> - [`is()` function](https://github.com/samchon/typia/wiki/Runtime-Validators#is-function)
|
|
124
|
+
> - [`assert()` function](https://github.com/samchon/typia/wiki/Runtime-Validators#assert-function)
|
|
125
|
+
> - [`validate()` function](https://github.com/samchon/typia/wiki/Runtime-Validators#validate-function)
|
|
126
|
+
> - [strict validators](https://github.com/samchon/typia/wiki/Runtime-Validators#strict-validators)
|
|
127
|
+
> - [factory functions](https://github.com/samchon/typia/wiki/Runtime-Validators#factory-functions)
|
|
128
|
+
> - [comment tags](https://github.com/samchon/typia/wiki/Runtime-Validators#comment-tags)
|
|
129
|
+
> - **Enhanced JSON**
|
|
130
|
+
> - [JSON schema](https://github.com/samchon/typia/wiki/Enhanced-JSON#json-schema)
|
|
131
|
+
> - [`parse()` functions](https://github.com/samchon/typia/wiki/Enhanced-JSON#parse-functions)
|
|
132
|
+
> - [`stringify()` functions](https://github.com/samchon/typia/wiki/Enhanced-JSON#stringify-functions)
|
|
133
|
+
> - [comment tags](https://github.com/samchon/typia/wiki/Enhanced-JSON#comment-tags)
|
|
134
|
+
|
|
160
135
|
### Runtime Validators
|
|
161
136
|
```typescript
|
|
162
137
|
// ALLOW SUPERFLUOUS PROPERTIES
|
|
163
|
-
export function is<T>(input: T):
|
|
164
|
-
export function
|
|
165
|
-
export function validate<T>(input: T): IValidation
|
|
138
|
+
export function is<T>(input: T | unknown): input is T; // returns boolean
|
|
139
|
+
export function assert<T>(input: T | unknown): T; // throws `TypeGuardError`
|
|
140
|
+
export function validate<T>(input: T | unknown): IValidation<T>; // detailed
|
|
166
141
|
|
|
167
142
|
// DO NOT ALLOW SUPERFLUOUS PROPERTIES
|
|
168
|
-
export function equals<T>(input: T): boolean;
|
|
169
|
-
export function assertEquals<T>(input: T): T;
|
|
170
|
-
export function validateEquals<T>(input: T): IValidation
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
export
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
expected: string;
|
|
180
|
-
value: any;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
export class TypeGuardError extends Error {
|
|
185
|
-
public readonly method: string;
|
|
186
|
-
public readonly path: string | undefined;
|
|
187
|
-
public readonly expected: string;
|
|
188
|
-
public readonly value: any;
|
|
189
|
-
}
|
|
143
|
+
export function equals<T>(input: T | unknown): boolean;
|
|
144
|
+
export function assertEquals<T>(input: T | unknown): T;
|
|
145
|
+
export function validateEquals<T>(input: T | unknown): IValidation<T>;
|
|
146
|
+
|
|
147
|
+
// REUSABLE FACTORY FUNCTIONS
|
|
148
|
+
export function createIs<T>(): (input: unknown) => T;
|
|
149
|
+
export function createAssert<T>(): (input: unknown) => T;
|
|
150
|
+
export function createValidate<T>(): (input: unknown) => IValidation<T>;
|
|
151
|
+
export function createEquals<T>(): (input: unknown) => boolean;
|
|
152
|
+
export function createAssertEquals<T>(): (input: unknown) => T;
|
|
153
|
+
export function createValidateEquals<T>(): (input: unknown) => IValidation<T>;
|
|
190
154
|
```
|
|
191
155
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
`validate`
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
[Object (simple)](https://github.com/samchon/typescript-json/blob/master/test/structures/ObjectSimple.ts) | ✔ | ✔ | ✔ | ✔ | ✔
|
|
230
|
-
[Object (hierarchical)](https://github.com/samchon/typescript-json/blob/master/test/structures/ObjectHierarchical.ts) | ✔ | ❌ | ✔ | ✔ | ✔
|
|
231
|
-
[Object (recursive)](https://github.com/samchon/typescript-json/blob/master/test/structures/ObjectRecursive.ts) | ✔ | ❌ | ✔ | ✔ | ✔ | ✔
|
|
232
|
-
[Object (union, implicit)](https://github.com/samchon/typescript-json/blob/master/test/structures/ObjectUnionImplicit.ts) | ✅ | ❌ | ❌ | ❌ | ❌
|
|
233
|
-
[Object (union, explicit)](https://github.com/samchon/typescript-json/blob/master/test/structures/ObjectUnionExplicit.ts) | ✔ | ✔ | ✔ | ✔ | ❌
|
|
234
|
-
[Object (additional tags)](https://github.com/samchon/typescript-json/#comment-tags) | ✔ | ✔ | ✔ | ✔ | ✔
|
|
235
|
-
[Object (template literal types)](https://github.com/samchon/typescript-json/blob/master/test/structures/TemplateUnion.ts) | ✔ | ✔ | ❌ | ❌ | ❌
|
|
236
|
-
[Object (dynamic properties)](https://github.com/samchon/typescript-json/blob/master/test/structures/DynamicTemplate.ts) | ✔ | ✔ | ❌ | ❌ | ❌
|
|
237
|
-
[Array (hierarchical)](https://github.com/samchon/typescript-json/blob/master/test/structures/ArrayHierarchical.ts) | ✔ | ✔ | ✔ | ✔ | ✔
|
|
238
|
-
[Array (recursive)](https://github.com/samchon/typescript-json/blob/master/test/structures/ArrayRecursive.ts) | ✔ | ❌ | ✔ | ✔ | ✔
|
|
239
|
-
[Array (recursive, union)](https://github.com/samchon/typescript-json/blob/master/test/structures/ArrayRecursiveUnionExplicit.ts) | ✔ | ❌ | ✔ | ✔ | ❌
|
|
240
|
-
[Array (R+U, implicit)](https://github.com/samchon/typescript-json/blob/master/test/structures/ArrayRecursiveUnionImplicit.ts) | ✅ | ❌ | ❌ | ❌ | ❌
|
|
241
|
-
[**Ultimate Union Type**](https://github.com/samchon/typescript-json/blob/master/src/schemas/IJsonSchema.ts) | ✅ | ❌ | ❌ | ❌ | ❌
|
|
242
|
-
|
|
243
|
-
> - TSON: `typescript-json`
|
|
244
|
-
> - C.V.: `class-validator`
|
|
245
|
-
|
|
246
|
-
Furthermore, when union type comes, `typescript-json` is extremely faster than others.
|
|
247
|
-
|
|
248
|
-
As you can see from the above table, `ajv` and `typescript-is` are fallen in the most union type cases. Also, they're even showing a huge different from `typescript-json`, in the time benchmark that does not care whether the validation is exact or not.
|
|
249
|
-
|
|
250
|
-
The extreme different is shown in the "ultimate union" type, when validating [JSON schema](https://github.com/samchon/typescript-json/blob/master/src/schemas/IJsonSchema.ts).
|
|
251
|
-
|
|
252
|
-

|
|
253
|
-
|
|
254
|
-
> Measured on Intel i5-1135g7, Surface Pro 8
|
|
255
|
-
|
|
256
|
-
### Fastest JSON String Converter
|
|
257
|
-
```typescript
|
|
258
|
-
export function stringify<T>(input: T): string;
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
Super-fast JSON string conversion function.
|
|
262
|
-
|
|
263
|
-
If you call `TSON.stringify()` function instead of the native `JSON.stringify()`, the JSON conversion time would be 5x times faster. Also, you can perform such super-fast JSON string conversion very easily, by only one line: `TSON.stringify<T>(input)`.
|
|
264
|
-
|
|
265
|
-
On the other side, other similary library like `fast-json-stringify` requires complicate JSON schema definition. Furthermore, `typescript-json` can convert complicate structured data that `fast-json-stringify` cannot convert.
|
|
266
|
-
|
|
267
|
-
Comparing performance, `typescript-json` is about 5x times faster when comparing only JSON string conversion time. If compare optimizer construction time, `typescript-json` is even 10,000x times faster.
|
|
268
|
-
|
|
269
|
-

|
|
270
|
-
|
|
271
|
-
> AMD CPU shows dramatic improvement
|
|
272
|
-
|
|
273
|
-
### JSON Schema Generation
|
|
156
|
+
`typia` supports three type of validator functions:
|
|
157
|
+
|
|
158
|
+
- `is()`: returns `false` if not matched with the type `T`
|
|
159
|
+
- `assert()`: throws a [`TypeGuardError`](https://github.com/samchon/typia/blob/master/src/TypeGuardError.ts) when not matched
|
|
160
|
+
- `validate()`
|
|
161
|
+
- when matched, returns [`IValidation.ISuccess<T>`](https://github.com/samchon/typia/blob/master/src/IValidation.ts) with `value` property
|
|
162
|
+
- when not matched, returns [`IValidation.IFailure`](https://github.com/samchon/typia/blob/master/src/IValidation.ts) with `errors` property
|
|
163
|
+
|
|
164
|
+
Also, if you want more strict validator functions that even do not allowing superfluous properties not written in the type `T`, you can use those functions instead; `equals()`, `assertEquals()`, `validateEquals()`. Otherwise you want to create resuable validator functions, you can utilize factory functions like `createIs()` instead.
|
|
165
|
+
|
|
166
|
+
When you want to add special validation logics, like limiting range of numeric values, you can do it through comment tags. If you want to know about it, please visit the Guide Documents ([Features > Runtime Validators > Comment Tags](https://github.com/samchon/typia/wiki/Runtime-Validators#comment-tags)).
|
|
167
|
+
|
|
168
|
+
<!-- > By the way, comparing those validator functions with other competitive libaries, you can find that only `typia` is able to validate complicate union type. It is because `typia` is supporting entire TypeScript type specs. Therefore, adapt `typia` with confidence. It can validate everything.
|
|
169
|
+
>
|
|
170
|
+
> Moreover, validation speed of `typia` is extremely faster than any other validation libraries. For an example, `typia` is maximum 15,000x times faster than `class-validator`. Visit [benchmarks](https://github.com/samchon/typia/wiki/Benchmarks#validate-functions) section of Guide Documents and feel how fast `typia` is.
|
|
171
|
+
>
|
|
172
|
+
> Components | `typia` | `TypeBox` | `ajv` | `io-ts` | `zod` | `C.V.`
|
|
173
|
+
> -------------------------|--------|-----------|-------|---------|-------|------------------
|
|
174
|
+
> **Easy to use** | ✅ | ❌ | ❌ | ❌ | ❌ | ❌
|
|
175
|
+
> [Object (simple)](https://github.com/samchon/typia/blob/master/test/structures/ObjectSimple.ts) | ✔ | ✔ | ✔ | ✔ | ✔ | ✔
|
|
176
|
+
> [Object (hierarchical)](https://github.com/samchon/typia/blob/master/test/structures/ObjectHierarchical.ts) | ✔ | ✔ | ✔ | ✔ | ✔ | ✔
|
|
177
|
+
> [Object (recursive)](https://github.com/samchon/typia/blob/master/test/structures/ObjectRecursive.ts) | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔
|
|
178
|
+
> [Object (union, implicit)](https://github.com/samchon/typia/blob/master/test/structures/ObjectUnionImplicit.ts) | ✅ | ❌ | ❌ | ❌ | ❌ | ❌
|
|
179
|
+
> [Object (union, explicit)](https://github.com/samchon/typia/blob/master/test/structures/ObjectUnionExplicit.ts) | ✔ | ✔ | ✔ | ✔ | ✔ | ❌
|
|
180
|
+
> [Object (additional tags)](https://github.com/samchon/typia/#comment-tags) | ✔ | ✔ | ✔ | ✔ | ✔ | ✔
|
|
181
|
+
> [Object (template literal types)](https://github.com/samchon/typia/blob/master/test/structures/TemplateUnion.ts) | ✅ | ❌ | ❌ | ❌ | ❌ | ❌
|
|
182
|
+
> [Object (dynamic properties)](https://github.com/samchon/typia/blob/master/test/structures/DynamicTemplate.ts) | ✔ | ✔ | ✔ | ❌ | ❌ | ❌
|
|
183
|
+
> [Array (hierarchical)](https://github.com/samchon/typia/blob/master/test/structures/ArrayHierarchical.ts) | ✔ | ✔ | ✔ | ✔ | ✔ | ✔
|
|
184
|
+
> [Array (recursive)](https://github.com/samchon/typia/blob/master/test/structures/ArrayRecursive.ts) | ✔ | ✔ | ✔ | ✔ | ✔ | ❌
|
|
185
|
+
> [Array (recursive, union)](https://github.com/samchon/typia/blob/master/test/structures/ArrayRecursiveUnionExplicit.ts) | ✔ | ✔ | ❌ | ✔ | ✔ | ❌
|
|
186
|
+
> [Array (R+U, implicit)](https://github.com/samchon/typia/blob/master/test/structures/ArrayRecursiveUnionImplicit.ts) | ✅ | ❌ | ❌ | ❌ | ❌ | ❌
|
|
187
|
+
> [**Ultimate Union Type**](https://github.com/samchon/typia/blob/master/src/schemas/IJsonSchema.ts) | ✅ | ❌ | ❌ | ❌ | ❌ | ❌
|
|
188
|
+
>
|
|
189
|
+
> - typia: `typia`
|
|
190
|
+
> - C.V.: `class-validator` -->
|
|
191
|
+
|
|
192
|
+
### Enhanced JSON
|
|
274
193
|
```typescript
|
|
194
|
+
// JSON SCHEMA GENERATOR
|
|
275
195
|
export function application<
|
|
276
196
|
Types extends unknown[],
|
|
277
197
|
Purpose extends "swagger" | "ajv" = "swagger",
|
|
@@ -279,190 +199,36 @@ export function application<
|
|
|
279
199
|
? "#/components/schemas"
|
|
280
200
|
: "components#/schemas",
|
|
281
201
|
>(): IJsonApplication;
|
|
282
|
-
```
|
|
283
202
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
203
|
+
// SAFE PARSER FUNCTIONS
|
|
204
|
+
export function isParse<T>(input: string): T | null;
|
|
205
|
+
export function assertParse<T>(input: string): T;
|
|
206
|
+
export function validateParse<T>(input: string): IValidation<T>;
|
|
207
|
+
|
|
208
|
+
// FASTER STRINGIFY FUNCTIONS
|
|
209
|
+
export function stringify<T>(input: T): string; // unsafe
|
|
210
|
+
export function isStringify<T>(input: T): string | null; // safe
|
|
211
|
+
export function assertStringify<T>(input: T): string;
|
|
212
|
+
export function validateStringify<T>(input: T): IValidation<string>;
|
|
213
|
+
|
|
214
|
+
// FACTORY FUNCTIONS
|
|
215
|
+
export function createAssertParse<T>(): (input: string) => T;
|
|
216
|
+
export function createAssertStringify<T>(): (input: T) => string;
|
|
217
|
+
// +) createIsParse, createValidateParse
|
|
218
|
+
// +) createStringify, createIsStringify, createValidateStringify
|
|
219
|
+
```
|
|
291
220
|
|
|
292
|
-
|
|
293
|
-
You can enhance [Runtime Validators](#runtime-validators) and [JSON Schema Generator](#json-schema-generation) by writing comment tags.
|
|
221
|
+
`typia` supports enhanced JSON functions.
|
|
294
222
|
|
|
295
|
-
|
|
223
|
+
- `application()`: generate JSON schema with only one line
|
|
224
|
+
- you can complement JSON schema contents through [comment tags](https://github.com/samchon/typia/wiki/Enhanced-JSON#comment-tags)
|
|
225
|
+
- `assertParse()`: parse JSON string safely with type validation
|
|
226
|
+
- `isStringify()`: maximum 10x faster JSON stringify fuction even type safe
|
|
296
227
|
|
|
297
|
-
|
|
228
|
+

|
|
298
229
|
|
|
299
|
-
|
|
300
|
-
------------|-----------------
|
|
301
|
-
`@type {"int"\|"uint"}` | number
|
|
302
|
-
`@range (number, number]` | number
|
|
303
|
-
`@minimum {number}` | number
|
|
304
|
-
`@maximum {number}` | number
|
|
305
|
-
`@exclusiveMinimum {number}` | number
|
|
306
|
-
`@exclusiveMaximum {number}` | number
|
|
307
|
-
`@multipleOf {number}` | number
|
|
308
|
-
`@step {number}` | number
|
|
309
|
-
`@length {number} \| [number, number)` | string
|
|
310
|
-
`@minLength {number}` | string
|
|
311
|
-
`@maxLength {number}` | string
|
|
312
|
-
`@format {"email"\|"uuid"\|"url"\|"ipv4"\|"ipv6"}` | string
|
|
313
|
-
`@pattern {string}` | string
|
|
314
|
-
`@items {number} \| [number, number)` | array
|
|
315
|
-
`@minItems {number}` | array
|
|
316
|
-
`@maxItems {number}` | array
|
|
230
|
+
> Measured on [AMD R7 5800H](https://github.com/samchon/typia/tree/master/benchmark/results/AMD%20Ryzen%207%205800H%20with%20Radeon%20Graphics#stringify)
|
|
317
231
|
|
|
318
|
-
```typescript
|
|
319
|
-
export interface TagExample {
|
|
320
|
-
/* -----------------------------------------------------------
|
|
321
|
-
ARRAYS
|
|
322
|
-
----------------------------------------------------------- */
|
|
323
|
-
/**
|
|
324
|
-
* You can limit array length like below.
|
|
325
|
-
*
|
|
326
|
-
* @minItems 3
|
|
327
|
-
* @maxItems 10
|
|
328
|
-
*
|
|
329
|
-
* Also, you can use `@items` tag instead.
|
|
330
|
-
*
|
|
331
|
-
* @items (5, 10] --> 5 < length <= 10
|
|
332
|
-
* @items [7 --> 7 <= length
|
|
333
|
-
* @items 12) --> length < 12
|
|
334
|
-
*
|
|
335
|
-
* Furthermore, you can use additional tags for each item.
|
|
336
|
-
*
|
|
337
|
-
* @type uint
|
|
338
|
-
* @format uuid
|
|
339
|
-
*/
|
|
340
|
-
array: Array<string|number>;
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
* If two-dimensional array comes, length limit would work for
|
|
344
|
-
* both 1st and 2nd level arraies. Also using additional tags
|
|
345
|
-
* for each item (string) would still work.
|
|
346
|
-
*
|
|
347
|
-
* @items (5, 10)
|
|
348
|
-
* @format url
|
|
349
|
-
*/
|
|
350
|
-
matrix: string[][];
|
|
351
|
-
|
|
352
|
-
/* -----------------------------------------------------------
|
|
353
|
-
NUMBERS
|
|
354
|
-
----------------------------------------------------------- */
|
|
355
|
-
/**
|
|
356
|
-
* Type of number.
|
|
357
|
-
*
|
|
358
|
-
* It must be one of integer or unsigned integer.
|
|
359
|
-
*
|
|
360
|
-
* @type int
|
|
361
|
-
* @type uint
|
|
362
|
-
*/
|
|
363
|
-
type: number;
|
|
364
|
-
|
|
365
|
-
/**
|
|
366
|
-
* You can limit range of numeric value like below.
|
|
367
|
-
*
|
|
368
|
-
* @minimum 5
|
|
369
|
-
* @maximum 10
|
|
370
|
-
*
|
|
371
|
-
* Also, you can use `@range` tag instead.
|
|
372
|
-
*
|
|
373
|
-
* @range (5, 10] --> 5 < x <= 10
|
|
374
|
-
* @range [7 --> 7 <= x
|
|
375
|
-
* @range 12) --> x < 12
|
|
376
|
-
*/
|
|
377
|
-
range: number;
|
|
378
|
-
|
|
379
|
-
/**
|
|
380
|
-
* Step tag requires minmum or exclusiveMinimum tag.
|
|
381
|
-
*
|
|
382
|
-
* 3, 13, 23, 33, ...
|
|
383
|
-
*
|
|
384
|
-
* @step 10
|
|
385
|
-
* @exclusiveMinimum 3
|
|
386
|
-
* @range [3
|
|
387
|
-
*/
|
|
388
|
-
step: number;
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
* Value must be multiple of the given number.
|
|
392
|
-
*
|
|
393
|
-
* -5, 0, 5, 10, 15, ...
|
|
394
|
-
*
|
|
395
|
-
* @multipleOf 5
|
|
396
|
-
*/
|
|
397
|
-
multipleOf: number;
|
|
398
|
-
|
|
399
|
-
/* -----------------------------------------------------------
|
|
400
|
-
STRINGS
|
|
401
|
-
----------------------------------------------------------- */
|
|
402
|
-
/**
|
|
403
|
-
* You can limit string length like below.
|
|
404
|
-
*
|
|
405
|
-
* @minLength 3
|
|
406
|
-
* @maxLength 10
|
|
407
|
-
*
|
|
408
|
-
* Also, you can use `@length` tag instead.
|
|
409
|
-
*
|
|
410
|
-
* @length 10 --> length = 10
|
|
411
|
-
* @length [3, 7] --> 3 <= length && length <= 7
|
|
412
|
-
* @length (5, 10) --> 5 < length && length < 10
|
|
413
|
-
* @length [4 --> 4 < length
|
|
414
|
-
* @length 7) --> length < 7
|
|
415
|
-
*/
|
|
416
|
-
length: string;
|
|
417
|
-
|
|
418
|
-
/**
|
|
419
|
-
* Mobile number composed by only numbers.
|
|
420
|
-
*
|
|
421
|
-
* Note that, `typescript-json` does not support flag of regex,
|
|
422
|
-
* because JSON schema definition does not suppor it either.
|
|
423
|
-
* Therefore, write regex pattern without `/` characters and flag.
|
|
424
|
-
*
|
|
425
|
-
* @pattern ^0[0-9]{7,16}
|
|
426
|
-
* -> RegExp(/[0-9]{7,16}/).test("01012345678")
|
|
427
|
-
*/
|
|
428
|
-
mobile: string;
|
|
429
|
-
|
|
430
|
-
/**
|
|
431
|
-
* E-mail address.
|
|
432
|
-
*
|
|
433
|
-
* @format email
|
|
434
|
-
*/
|
|
435
|
-
email: string;
|
|
436
|
-
|
|
437
|
-
/**
|
|
438
|
-
* UUID value.
|
|
439
|
-
*
|
|
440
|
-
* @format uuid
|
|
441
|
-
*/
|
|
442
|
-
uuid: string;
|
|
443
|
-
|
|
444
|
-
/**
|
|
445
|
-
* URL address.
|
|
446
|
-
*
|
|
447
|
-
* @format url
|
|
448
|
-
*/
|
|
449
|
-
url: string;
|
|
450
|
-
|
|
451
|
-
/**
|
|
452
|
-
* IPv4 address.
|
|
453
|
-
*
|
|
454
|
-
* @format ipv4
|
|
455
|
-
*/
|
|
456
|
-
ipv4: string;
|
|
457
|
-
|
|
458
|
-
/**
|
|
459
|
-
* IPv6 address.
|
|
460
|
-
*
|
|
461
|
-
* @format ipv6
|
|
462
|
-
*/
|
|
463
|
-
ipv6: string;
|
|
464
|
-
}
|
|
465
|
-
```
|
|
466
232
|
|
|
467
233
|
|
|
468
234
|
|
|
@@ -551,9 +317,9 @@ export async function trace_sale_question_and_comment
|
|
|
551
317
|
### Nestia-Helper
|
|
552
318
|
https://github.com/samchon/nestia-helper
|
|
553
319
|
|
|
554
|
-
Helper library of `NestJS`, using this `
|
|
320
|
+
Helper library of `NestJS`, using this `typia`.
|
|
555
321
|
|
|
556
|
-
`nestia-helper` is a helper library of `NestJS`, which boosts up the `JSON.stringify()` speed 5x times faster about the API responses, automatically. Also, `nestia-helper` supports automatic
|
|
322
|
+
`nestia-helper` is a helper library of `NestJS`, which boosts up the `JSON.stringify()` speed 5x times faster about the API responses, automatically. Also, `nestia-helper` supports automatic validation of request body, that is maximum 15,000x times faster than legacy `class-validator` too.
|
|
557
323
|
|
|
558
324
|
```typescript
|
|
559
325
|
import helper from "nestia-helper";
|
|
@@ -562,10 +328,10 @@ import * as nest from "@nestjs/common";
|
|
|
562
328
|
@nest.Controller("bbs/articles")
|
|
563
329
|
export class BbsArticlesController
|
|
564
330
|
{
|
|
565
|
-
// automatic
|
|
331
|
+
// automatic typia.stringify() for response body
|
|
566
332
|
@helper.TypedRoute.Get()
|
|
567
333
|
public store(
|
|
568
|
-
// automatic
|
|
334
|
+
// automatic typia.assert() for request body
|
|
569
335
|
@helper.TypedBody() input: IBbsArticle.IStore
|
|
570
336
|
): Promise<IBbsArticle>;
|
|
571
337
|
}
|