typia 13.1.1 → 13.2.0
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 +3 -0
- package/lib/_virtual/_rolldown/runtime.mjs +1 -5
- package/lib/executable/FileSystemIdentity.d.ts +44 -0
- package/lib/executable/FileSystemIdentity.js +213 -0
- package/lib/executable/FileSystemIdentity.js.map +1 -0
- package/lib/executable/FileSystemIdentity.mjs +133 -0
- package/lib/executable/FileSystemIdentity.mjs.map +1 -0
- package/lib/executable/TypiaGenerateWizard.js +272 -106
- package/lib/executable/TypiaGenerateWizard.js.map +1 -1
- package/lib/executable/TypiaGenerateWizard.mjs +239 -95
- package/lib/executable/TypiaGenerateWizard.mjs.map +1 -1
- package/lib/functional.d.ts +15 -12
- package/lib/functional.js.map +1 -1
- package/lib/functional.mjs.map +1 -1
- package/lib/internal/_ProtobufReader.d.ts +32 -0
- package/lib/internal/_ProtobufReader.js +148 -48
- package/lib/internal/_ProtobufReader.js.map +1 -1
- package/lib/internal/_ProtobufReader.mjs +137 -41
- package/lib/internal/_ProtobufReader.mjs.map +1 -1
- package/lib/internal/_createStandardSchema.js +18 -1
- package/lib/internal/_createStandardSchema.js.map +1 -1
- package/lib/internal/_createStandardSchema.mjs +12 -1
- package/lib/internal/_createStandardSchema.mjs.map +1 -1
- package/lib/internal/_decimal.d.ts +14 -0
- package/lib/internal/_decimal.js +61 -0
- package/lib/internal/_decimal.js.map +1 -0
- package/lib/internal/_decimal.mjs +49 -0
- package/lib/internal/_decimal.mjs.map +1 -0
- package/lib/internal/_httpQueryParseURLSearchParams.js +23 -2
- package/lib/internal/_httpQueryParseURLSearchParams.js.map +1 -1
- package/lib/internal/_httpQueryParseURLSearchParams.mjs +20 -2
- package/lib/internal/_httpQueryParseURLSearchParams.mjs.map +1 -1
- package/lib/internal/_isFormatByte.js +2 -5
- package/lib/internal/_isFormatByte.js.map +1 -1
- package/lib/internal/_isFormatByte.mjs +2 -5
- package/lib/internal/_isFormatByte.mjs.map +1 -1
- package/lib/internal/_isFormatDate.js +15 -2
- package/lib/internal/_isFormatDate.js.map +1 -1
- package/lib/internal/_isFormatDate.mjs +22 -2
- package/lib/internal/_isFormatDate.mjs.map +1 -1
- package/lib/internal/_isFormatDateTime.js +21 -2
- package/lib/internal/_isFormatDateTime.js.map +1 -1
- package/lib/internal/_isFormatDateTime.mjs +13 -2
- package/lib/internal/_isFormatDateTime.mjs.map +1 -1
- package/lib/internal/_isFormatIri.js +3 -2
- package/lib/internal/_isFormatIri.js.map +1 -1
- package/lib/internal/_isFormatIri.mjs +3 -2
- package/lib/internal/_isFormatIri.mjs.map +1 -1
- package/lib/internal/_isFormatIriReference.js +10 -2
- package/lib/internal/_isFormatIriReference.js.map +1 -1
- package/lib/internal/_isFormatIriReference.mjs +9 -2
- package/lib/internal/_isFormatIriReference.mjs.map +1 -1
- package/lib/internal/_isFormatUriReference.js +1 -1
- package/lib/internal/_isFormatUriReference.js.map +1 -1
- package/lib/internal/_isFormatUriReference.mjs +1 -1
- package/lib/internal/_isFormatUriReference.mjs.map +1 -1
- package/lib/internal/_isMultipleOf.d.ts +1 -0
- package/lib/internal/_isMultipleOf.js +13 -0
- package/lib/internal/_isMultipleOf.js.map +1 -0
- package/lib/internal/_isMultipleOf.mjs +12 -0
- package/lib/internal/_isMultipleOf.mjs.map +1 -0
- package/lib/internal/_isTypeFloat.js +1 -1
- package/lib/internal/_isTypeFloat.js.map +1 -1
- package/lib/internal/_isTypeFloat.mjs +1 -1
- package/lib/internal/_isTypeFloat.mjs.map +1 -1
- package/lib/internal/_isTypeInt64.js +1 -0
- package/lib/internal/_isTypeInt64.js.map +1 -1
- package/lib/internal/_isTypeInt64.mjs.map +1 -1
- package/lib/internal/_isTypeInt64Bigint.d.ts +1 -0
- package/lib/internal/_isTypeInt64Bigint.js +15 -0
- package/lib/internal/_isTypeInt64Bigint.js.map +1 -0
- package/lib/internal/_isTypeInt64Bigint.mjs +8 -0
- package/lib/internal/_isTypeInt64Bigint.mjs.map +1 -0
- package/lib/internal/_isTypeUint64.js +1 -0
- package/lib/internal/_isTypeUint64.js.map +1 -1
- package/lib/internal/_isTypeUint64.mjs.map +1 -1
- package/lib/internal/_isTypeUint64Bigint.d.ts +1 -0
- package/lib/internal/_isTypeUint64Bigint.js +10 -0
- package/lib/internal/_isTypeUint64Bigint.js.map +1 -0
- package/lib/internal/_isTypeUint64Bigint.mjs +8 -0
- package/lib/internal/_isTypeUint64Bigint.mjs.map +1 -0
- package/lib/internal/_isUniqueItems.js +96 -109
- package/lib/internal/_isUniqueItems.js.map +1 -1
- package/lib/internal/_isUniqueItems.mjs +62 -50
- package/lib/internal/_isUniqueItems.mjs.map +1 -1
- package/lib/internal/_jsonStringifyArray.d.ts +1 -0
- package/lib/internal/_jsonStringifyArray.js +48 -0
- package/lib/internal/_jsonStringifyArray.js.map +1 -0
- package/lib/internal/_jsonStringifyArray.mjs +40 -0
- package/lib/internal/_jsonStringifyArray.mjs.map +1 -0
- package/lib/internal/_jsonStringifyElement.d.ts +1 -0
- package/lib/internal/_jsonStringifyElement.js +23 -0
- package/lib/internal/_jsonStringifyElement.js.map +1 -0
- package/lib/internal/_jsonStringifyElement.mjs +23 -0
- package/lib/internal/_jsonStringifyElement.mjs.map +1 -0
- package/lib/internal/_jsonStringifyProperty.d.ts +1 -0
- package/lib/internal/_jsonStringifyProperty.js +31 -0
- package/lib/internal/_jsonStringifyProperty.js.map +1 -0
- package/lib/internal/_jsonStringifyProperty.mjs +31 -0
- package/lib/internal/_jsonStringifyProperty.mjs.map +1 -0
- package/lib/internal/_llmApplicationFinalize.js +1 -1
- package/lib/internal/_llmApplicationFinalize.js.map +1 -1
- package/lib/internal/_llmApplicationFinalize.mjs +1 -1
- package/lib/internal/_llmApplicationFinalize.mjs.map +1 -1
- package/lib/internal/_notationAny.js +8 -1
- package/lib/internal/_notationAny.js.map +1 -1
- package/lib/internal/_notationAny.mjs +7 -1
- package/lib/internal/_notationAny.mjs.map +1 -1
- package/lib/internal/_notationAssign.d.ts +1 -0
- package/lib/internal/_notationAssign.js +18 -0
- package/lib/internal/_notationAssign.js.map +1 -0
- package/lib/internal/_notationAssign.mjs +17 -0
- package/lib/internal/_notationAssign.mjs.map +1 -0
- package/lib/internal/_notationCamel.js +30 -9
- package/lib/internal/_notationCamel.js.map +1 -1
- package/lib/internal/_notationCamel.mjs +13 -5
- package/lib/internal/_notationCamel.mjs.map +1 -1
- package/lib/internal/_notationKebab.d.ts +1 -0
- package/lib/internal/_notationKebab.js +15 -0
- package/lib/internal/_notationKebab.js.map +1 -0
- package/lib/internal/_notationKebab.mjs +15 -0
- package/lib/internal/_notationKebab.mjs.map +1 -0
- package/lib/internal/_notationKeyCollision.d.ts +1 -0
- package/lib/internal/_notationKeyCollision.js +8 -0
- package/lib/internal/_notationKeyCollision.js.map +1 -0
- package/lib/internal/_notationKeyCollision.mjs +8 -0
- package/lib/internal/_notationKeyCollision.mjs.map +1 -0
- package/lib/internal/_notationPascal.js +20 -5
- package/lib/internal/_notationPascal.js.map +1 -1
- package/lib/internal/_notationPascal.mjs +10 -5
- package/lib/internal/_notationPascal.mjs.map +1 -1
- package/lib/internal/_notationSnake.js +25 -22
- package/lib/internal/_notationSnake.js.map +1 -1
- package/lib/internal/_notationSnake.mjs +11 -11
- package/lib/internal/_notationSnake.mjs.map +1 -1
- package/lib/internal/_plainCloneAny.js +174 -38
- package/lib/internal/_plainCloneAny.js.map +1 -1
- package/lib/internal/_plainCloneAny.mjs +126 -22
- package/lib/internal/_plainCloneAny.mjs.map +1 -1
- package/lib/internal/_randomArray.d.ts +1 -1
- package/lib/internal/_randomArray.js +11 -4
- package/lib/internal/_randomArray.js.map +1 -1
- package/lib/internal/_randomArray.mjs +9 -3
- package/lib/internal/_randomArray.mjs.map +1 -1
- package/lib/internal/_randomFormatByte.d.ts +2 -1
- package/lib/internal/_randomFormatByte.js +25 -1
- package/lib/internal/_randomFormatByte.js.map +1 -1
- package/lib/internal/_randomFormatByte.mjs +20 -1
- package/lib/internal/_randomFormatByte.mjs.map +1 -1
- package/lib/internal/_randomFormatDate.d.ts +3 -4
- package/lib/internal/_randomFormatDate.js +3 -10
- package/lib/internal/_randomFormatDate.js.map +1 -1
- package/lib/internal/_randomFormatDate.mjs +3 -6
- package/lib/internal/_randomFormatDate.mjs.map +1 -1
- package/lib/internal/_randomFormatDatetime.d.ts +3 -4
- package/lib/internal/_randomFormatDatetime.js +26 -8
- package/lib/internal/_randomFormatDatetime.js.map +1 -1
- package/lib/internal/_randomFormatDatetime.mjs +17 -6
- package/lib/internal/_randomFormatDatetime.mjs.map +1 -1
- package/lib/internal/_randomFormatDuration.d.ts +2 -1
- package/lib/internal/_randomFormatDuration.js +23 -14
- package/lib/internal/_randomFormatDuration.js.map +1 -1
- package/lib/internal/_randomFormatDuration.mjs +22 -13
- package/lib/internal/_randomFormatDuration.mjs.map +1 -1
- package/lib/internal/_randomFormatEmail.d.ts +2 -1
- package/lib/internal/_randomFormatEmail.js +8 -1
- package/lib/internal/_randomFormatEmail.js.map +1 -1
- package/lib/internal/_randomFormatEmail.mjs +5 -1
- package/lib/internal/_randomFormatEmail.mjs.map +1 -1
- package/lib/internal/_randomFormatHostname.d.ts +8 -1
- package/lib/internal/_randomFormatHostname.js +45 -2
- package/lib/internal/_randomFormatHostname.js.map +1 -1
- package/lib/internal/_randomFormatHostname.mjs +38 -2
- package/lib/internal/_randomFormatHostname.mjs.map +1 -1
- package/lib/internal/_randomFormatIdnEmail.d.ts +2 -1
- package/lib/internal/_randomFormatIdnEmail.js +16 -2
- package/lib/internal/_randomFormatIdnEmail.js.map +1 -1
- package/lib/internal/_randomFormatIdnEmail.mjs +11 -2
- package/lib/internal/_randomFormatIdnEmail.mjs.map +1 -1
- package/lib/internal/_randomFormatIdnHostname.d.ts +2 -1
- package/lib/internal/_randomFormatIdnHostname.js +26 -1
- package/lib/internal/_randomFormatIdnHostname.js.map +1 -1
- package/lib/internal/_randomFormatIdnHostname.mjs +25 -2
- package/lib/internal/_randomFormatIdnHostname.mjs.map +1 -1
- package/lib/internal/_randomFormatIpv4.d.ts +2 -1
- package/lib/internal/_randomFormatIpv4.js +32 -1
- package/lib/internal/_randomFormatIpv4.js.map +1 -1
- package/lib/internal/_randomFormatIpv4.mjs +23 -1
- package/lib/internal/_randomFormatIpv4.mjs.map +1 -1
- package/lib/internal/_randomFormatIpv6.d.ts +2 -1
- package/lib/internal/_randomFormatIpv6.js +58 -1
- package/lib/internal/_randomFormatIpv6.js.map +1 -1
- package/lib/internal/_randomFormatIpv6.mjs +45 -1
- package/lib/internal/_randomFormatIpv6.mjs.map +1 -1
- package/lib/internal/_randomFormatIri.d.ts +2 -1
- package/lib/internal/_randomFormatIri.js +1 -1
- package/lib/internal/_randomFormatIri.js.map +1 -1
- package/lib/internal/_randomFormatIri.mjs +1 -1
- package/lib/internal/_randomFormatIri.mjs.map +1 -1
- package/lib/internal/_randomFormatIriReference.d.ts +2 -1
- package/lib/internal/_randomFormatIriReference.js +1 -1
- package/lib/internal/_randomFormatIriReference.js.map +1 -1
- package/lib/internal/_randomFormatIriReference.mjs +1 -1
- package/lib/internal/_randomFormatIriReference.mjs.map +1 -1
- package/lib/internal/_randomFormatJsonPointer.d.ts +2 -1
- package/lib/internal/_randomFormatJsonPointer.js +20 -1
- package/lib/internal/_randomFormatJsonPointer.js.map +1 -1
- package/lib/internal/_randomFormatJsonPointer.mjs +15 -1
- package/lib/internal/_randomFormatJsonPointer.mjs.map +1 -1
- package/lib/internal/_randomFormatPassword.d.ts +2 -1
- package/lib/internal/_randomFormatPassword.js +7 -5
- package/lib/internal/_randomFormatPassword.js.map +1 -1
- package/lib/internal/_randomFormatPassword.mjs +5 -1
- package/lib/internal/_randomFormatPassword.mjs.map +1 -1
- package/lib/internal/_randomFormatRegex.d.ts +2 -1
- package/lib/internal/_randomFormatRegex.js +15 -1
- package/lib/internal/_randomFormatRegex.js.map +1 -1
- package/lib/internal/_randomFormatRegex.mjs +14 -1
- package/lib/internal/_randomFormatRegex.mjs.map +1 -1
- package/lib/internal/_randomFormatRelativeJsonPointer.d.ts +2 -1
- package/lib/internal/_randomFormatRelativeJsonPointer.js +20 -5
- package/lib/internal/_randomFormatRelativeJsonPointer.js.map +1 -1
- package/lib/internal/_randomFormatRelativeJsonPointer.mjs +21 -5
- package/lib/internal/_randomFormatRelativeJsonPointer.mjs.map +1 -1
- package/lib/internal/_randomFormatTime.d.ts +2 -1
- package/lib/internal/_randomFormatTime.js +34 -7
- package/lib/internal/_randomFormatTime.js.map +1 -1
- package/lib/internal/_randomFormatTime.mjs +37 -4
- package/lib/internal/_randomFormatTime.mjs.map +1 -1
- package/lib/internal/_randomFormatUri.d.ts +2 -1
- package/lib/internal/_randomFormatUri.js +1 -1
- package/lib/internal/_randomFormatUri.js.map +1 -1
- package/lib/internal/_randomFormatUri.mjs +1 -1
- package/lib/internal/_randomFormatUri.mjs.map +1 -1
- package/lib/internal/_randomFormatUriReference.d.ts +2 -1
- package/lib/internal/_randomFormatUriReference.js +1 -1
- package/lib/internal/_randomFormatUriReference.js.map +1 -1
- package/lib/internal/_randomFormatUriReference.mjs +1 -1
- package/lib/internal/_randomFormatUriReference.mjs.map +1 -1
- package/lib/internal/_randomFormatUriTemplate.d.ts +2 -1
- package/lib/internal/_randomFormatUriTemplate.js +1 -1
- package/lib/internal/_randomFormatUriTemplate.js.map +1 -1
- package/lib/internal/_randomFormatUriTemplate.mjs +1 -1
- package/lib/internal/_randomFormatUriTemplate.mjs.map +1 -1
- package/lib/internal/_randomFormatUrl.d.ts +2 -1
- package/lib/internal/_randomFormatUrl.js +21 -1
- package/lib/internal/_randomFormatUrl.js.map +1 -1
- package/lib/internal/_randomFormatUrl.mjs +18 -1
- package/lib/internal/_randomFormatUrl.mjs.map +1 -1
- package/lib/internal/_randomFormatUuid.d.ts +2 -1
- package/lib/internal/_randomFormatUuid.js +3 -2
- package/lib/internal/_randomFormatUuid.js.map +1 -1
- package/lib/internal/_randomFormatUuid.mjs +3 -2
- package/lib/internal/_randomFormatUuid.mjs.map +1 -1
- package/lib/internal/_randomInteger.js +59 -28
- package/lib/internal/_randomInteger.js.map +1 -1
- package/lib/internal/_randomInteger.mjs +56 -16
- package/lib/internal/_randomInteger.mjs.map +1 -1
- package/lib/internal/_randomMultiple.d.ts +8 -0
- package/lib/internal/_randomMultiple.js +168 -0
- package/lib/internal/_randomMultiple.js.map +1 -0
- package/lib/internal/_randomMultiple.mjs +158 -0
- package/lib/internal/_randomMultiple.mjs.map +1 -0
- package/lib/internal/_randomNumber.js +42 -42
- package/lib/internal/_randomNumber.js.map +1 -1
- package/lib/internal/_randomNumber.mjs +41 -27
- package/lib/internal/_randomNumber.mjs.map +1 -1
- package/lib/internal/_randomPattern.d.ts +2 -1
- package/lib/internal/_randomPattern.js +19 -4
- package/lib/internal/_randomPattern.js.map +1 -1
- package/lib/internal/_randomPattern.mjs +10 -4
- package/lib/internal/_randomPattern.mjs.map +1 -1
- package/lib/internal/_randomStringLength.d.ts +64 -0
- package/lib/internal/_randomStringLength.js +84 -0
- package/lib/internal/_randomStringLength.js.map +1 -0
- package/lib/internal/_randomStringLength.mjs +79 -0
- package/lib/internal/_randomStringLength.mjs.map +1 -0
- package/lib/internal/_stringLength.d.ts +1 -0
- package/lib/internal/_stringLength.js +11 -0
- package/lib/internal/_stringLength.js.map +1 -0
- package/lib/internal/_stringLength.mjs +10 -0
- package/lib/internal/_stringLength.mjs.map +1 -0
- package/lib/internal/_validateReport.js +4 -1
- package/lib/internal/_validateReport.js.map +1 -1
- package/lib/internal/_validateReport.mjs +2 -1
- package/lib/internal/_validateReport.mjs.map +1 -1
- package/lib/internal/private/__notationRename.d.ts +14 -0
- package/lib/internal/private/__notationRename.js +25 -0
- package/lib/internal/private/__notationRename.js.map +1 -0
- package/lib/internal/private/__notationRename.mjs +24 -0
- package/lib/internal/private/__notationRename.mjs.map +1 -0
- package/lib/internal/private/__randomComposition.d.ts +23 -0
- package/lib/internal/private/__randomComposition.js +48 -0
- package/lib/internal/private/__randomComposition.js.map +1 -0
- package/lib/internal/private/__randomComposition.mjs +54 -0
- package/lib/internal/private/__randomComposition.mjs.map +1 -0
- package/lib/internal/private/__randomEpoch.d.ts +19 -0
- package/lib/internal/private/__randomEpoch.js +31 -0
- package/lib/internal/private/__randomEpoch.js.map +1 -0
- package/lib/internal/private/__randomEpoch.mjs +28 -0
- package/lib/internal/private/__randomEpoch.mjs.map +1 -0
- package/lib/json.d.ts +2 -2
- package/lib/json.mjs.map +1 -1
- package/lib/module.d.ts +2 -2
- package/lib/module.js.map +1 -1
- package/lib/module.mjs.map +1 -1
- package/lib/notations.d.ts +20 -4
- package/lib/notations.js.map +1 -1
- package/lib/notations.mjs.map +1 -1
- package/native/adapter/plugin_options.go +117 -0
- package/native/adapter/plugin_options_payload_matrix_test.go +181 -0
- package/native/cmd/ttsc-typia/any_array_type_tags_transform_test.go +63 -9
- package/native/cmd/ttsc-typia/assert_guard_factory_contract_test.go +152 -0
- package/native/cmd/ttsc-typia/build.go +84 -64
- package/native/cmd/ttsc-typia/build_no_emit_preserves_analysis_options_test.go +67 -0
- package/native/cmd/ttsc-typia/build_no_emit_transform_diagnostics_test.go +138 -0
- package/native/cmd/ttsc-typia/build_plugin_options_come_from_payload_test.go +48 -0
- package/native/cmd/ttsc-typia/build_transactional_emit_success_test.go +81 -0
- package/native/cmd/ttsc-typia/build_transform_failure_atomicity_test.go +138 -0
- package/native/cmd/ttsc-typia/callable_interface_function_semantics_transform_test.go +331 -0
- package/native/cmd/ttsc-typia/callable_type_literal_boundaries_transform_test.go +1184 -0
- package/native/cmd/ttsc-typia/command_routes_and_diagnostics_coverage_test.go +3 -1
- package/native/cmd/ttsc-typia/compare_functional_union_membership_transform_test.go +434 -0
- package/native/cmd/ttsc-typia/compare_less_nan_transform_test.go +98 -0
- package/native/cmd/ttsc-typia/compare_native_object_overmatch_transform_test.go +161 -0
- package/native/cmd/ttsc-typia/compare_nondiscriminable_union_transform_test.go +343 -0
- package/native/cmd/ttsc-typia/compare_template_literal_union_transform_test.go +241 -0
- package/native/cmd/ttsc-typia/compare_union_discrimination_transform_test.go +289 -0
- package/native/cmd/ttsc-typia/default_library_spoof_native_identity_transform_test.go +216 -0
- package/native/cmd/ttsc-typia/escaped_property_key_path_transform_test.go +193 -0
- package/native/cmd/ttsc-typia/finite_option_number_leaf_transform_test.go +240 -0
- package/native/cmd/ttsc-typia/functional_promised_type_transform_test.go +220 -0
- package/native/cmd/ttsc-typia/functional_receiver_transform_test.go +232 -0
- package/native/cmd/ttsc-typia/is_object_function_member_transform_test.go +205 -0
- package/native/cmd/ttsc-typia/json_application_alias_function_validation_transform_test.go +151 -0
- package/native/cmd/ttsc-typia/json_is_stringify_finite_number_transform_test.go +198 -0
- package/native/cmd/ttsc-typia/json_schema_dynamic_key_determinism_transform_test.go +246 -0
- package/native/cmd/ttsc-typia/json_stringify_contextual_undefined_transform_test.go +556 -0
- package/native/cmd/ttsc-typia/json_stringify_special_key_transform_test.go +238 -0
- package/native/cmd/ttsc-typia/lib_replacement_native_identity_transform_test.go +277 -0
- package/native/cmd/ttsc-typia/main_wasm.go +21 -2
- package/native/cmd/ttsc-typia/native_collection_identity_is_transform_test.go +234 -0
- package/native/cmd/ttsc-typia/native_generic_name_guard_is_transform_test.go +194 -0
- package/native/cmd/ttsc-typia/native_name_collision_is_transform_test.go +204 -0
- package/native/cmd/ttsc-typia/native_named_intersection_union_transform_test.go +390 -0
- package/native/cmd/ttsc-typia/node_buffer_native_exports_is_transform_test.go +526 -0
- package/native/cmd/ttsc-typia/non_trailing_rest_tuple_transform_test.go +23 -11
- package/native/cmd/ttsc-typia/notation_dynamic_keys_transform_test.go +286 -0
- package/native/cmd/ttsc-typia/notation_kebab_case_transform_test.go +1 -1
- package/native/cmd/ttsc-typia/notation_literal_collision_transform_test.go +164 -0
- package/native/cmd/ttsc-typia/notation_pascal_case_transform_test.go +230 -0
- package/native/cmd/ttsc-typia/notation_unicode_key_transform_test.go +309 -0
- package/native/cmd/ttsc-typia/package_declaration_native_identity_is_transform_test.go +293 -0
- package/native/cmd/ttsc-typia/pattern_line_terminator_escape_transform_test.go +224 -0
- package/native/cmd/ttsc-typia/plain_prune_union_object_overmatch_transform_test.go +219 -0
- package/native/cmd/ttsc-typia/plugin_options_payload_helpers_test.go +181 -0
- package/native/cmd/ttsc-typia/private_field_filter_is_transform_test.go +278 -0
- package/native/cmd/ttsc-typia/project_catalog_transform_coverage_test.go +73 -27
- package/native/cmd/ttsc-typia/project_dependencies_barrel_reexport_transform_test.go +120 -0
- package/native/cmd/ttsc-typia/project_dependencies_collapsed_alias_transform_test.go +134 -0
- package/native/cmd/ttsc-typia/project_dependencies_custom_lib_name_transform_test.go +135 -0
- package/native/cmd/ttsc-typia/project_dependencies_default_barrel_transform_test.go +114 -0
- package/native/cmd/ttsc-typia/project_dependencies_empty_heritage_transform_test.go +100 -0
- package/native/cmd/ttsc-typia/project_dependencies_envelope_transform_test.go +148 -0
- package/native/cmd/ttsc-typia/project_dependencies_index_signature_alias_transform_test.go +139 -0
- package/native/cmd/ttsc-typia/project_dependencies_local_reexport_transform_test.go +122 -0
- package/native/cmd/ttsc-typia/project_dependencies_signature_alias_transform_test.go +125 -0
- package/native/cmd/ttsc-typia/project_dependencies_star_barrel_transform_test.go +112 -0
- package/native/cmd/ttsc-typia/project_reference_graph_envelope_transform_test.go +190 -0
- package/native/cmd/ttsc-typia/protobuf_diagnostic_code_transform_test.go +167 -0
- package/native/cmd/ttsc-typia/protobuf_is_encode_finite_number_transform_test.go +98 -0
- package/native/cmd/ttsc-typia/protobuf_sequence_field_numbers_transform_test.go +52 -22
- package/native/cmd/ttsc-typia/symbol_index_domain_transform_test.go +316 -0
- package/native/cmd/ttsc-typia/symbol_key_member_filter_transform_test.go +279 -0
- package/native/cmd/ttsc-typia/template_interpolation_type_tags_transform_test.go +86 -23
- package/native/cmd/ttsc-typia/template_literal_type_tags_transform_test.go +3 -1
- package/native/cmd/ttsc-typia/transform.go +251 -39
- package/native/cmd/ttsc-typia/{transform_declaration_source_produces_no_js_test.go → transform_declaration_source_produces_no_javascript_test.go} +10 -2
- package/native/cmd/ttsc-typia/transform_fixtures_emit_coverage_test.go +21 -4
- package/native/cmd/ttsc-typia/transform_helpers_test.go +236 -3
- package/native/cmd/ttsc-typia/transform_plugin_options_come_from_payload_test.go +43 -0
- package/native/cmd/ttsc-typia/transform_single_file_failure_atomicity_test.go +114 -0
- package/native/cmd/ttsc-typia/transform_single_file_failure_writes_no_stdout_test.go +43 -0
- package/native/cmd/ttsc-typia/transform_single_file_js_distinguishes_same_basename_sources_test.go +81 -0
- package/native/cmd/ttsc-typia/transform_single_file_js_empty_emit_reports_no_output_test.go +100 -0
- package/native/cmd/ttsc-typia/transform_single_file_js_locates_output_across_layouts_test.go +160 -0
- package/native/cmd/ttsc-typia/transform_single_file_success_publishes_artifact_test.go +54 -0
- package/native/cmd/ttsc-typia/transform_wasm_host_argv_reports_diagnostics_test.go +39 -0
- package/native/cmd/ttsc-typia/tuple_optional_compare_clone_transform_test.go +227 -0
- package/native/cmd/ttsc-typia/user_global_native_identity_transform_test.go +484 -0
- package/native/core/factories/FormatCheatSheet.go +40 -7
- package/native/core/factories/IdentifierFactory.go +131 -4
- package/native/core/factories/MetadataCommentTagFactory.go +83 -40
- package/native/core/factories/MetadataTypeTagFactory.go +13 -1
- package/native/core/factories/NumericRangeFactory.go +60 -17
- package/native/core/factories/ProtobufFactory.go +13 -5
- package/native/core/factories/factory_utility_coverage_test.go +8 -2
- package/native/core/factories/format_alias_resolves_to_cheat_sheet_test.go +57 -0
- package/native/core/factories/format_alias_table_targets_the_cheat_sheet_test.go +44 -0
- package/native/core/factories/identifier_factory_postfix_escapes_every_key_test.go +147 -0
- package/native/core/factories/identifier_factory_postfix_survives_every_code_point_test.go +86 -0
- package/native/core/factories/internal/metadata/MetadataHelper.go +226 -17
- package/native/core/factories/internal/metadata/emplace_metadata_object.go +141 -8
- package/native/core/factories/internal/metadata/iterate_metadata.go +6 -0
- package/native/core/factories/internal/metadata/iterate_metadata_function.go +5 -12
- package/native/core/factories/internal/metadata/iterate_metadata_intersection.go +111 -29
- package/native/core/factories/internal/metadata/iterate_metadata_map.go +5 -0
- package/native/core/factories/internal/metadata/iterate_metadata_native.go +45 -2
- package/native/core/factories/internal/metadata/iterate_metadata_set.go +5 -0
- package/native/core/factories/internal/metadata/type_arguments_precondition_test.go +70 -0
- package/native/core/factories/metadata_comment_tag_factory_coverage_test.go +39 -0
- package/native/core/factories/metadata_comment_tag_factory_exclusivity_matches_interface_test.go +84 -0
- package/native/core/factories/metadata_type_tag_factory_accepts_legal_tag_combinations_test.go +60 -0
- package/native/core/factories/metadata_type_tag_factory_declarations_test.go +86 -0
- package/native/core/factories/metadata_type_tag_factory_keeps_bool_form_exclusivity_test.go +38 -0
- package/native/core/factories/metadata_type_tag_factory_rejects_cross_kind_exclusive_tags_test.go +65 -0
- package/native/core/factories/metadata_type_tag_factory_rejects_duplicated_array_form_tags_test.go +41 -0
- package/native/core/factories/numeric_range_factory_enforces_64bit_bounds_test.go +69 -0
- package/native/core/factories/protobuf_recovery_ownership_test.go +64 -0
- package/native/core/programmers/IsProgrammer.go +15 -1
- package/native/core/programmers/RandomProgrammer.go +51 -14
- package/native/core/programmers/compare/CompareEqualProgrammer.go +410 -8
- package/native/core/programmers/compare/CompareLessProgrammer.go +4 -2
- package/native/core/programmers/functional/FunctionalAssertFunctionProgrammer.go +4 -6
- package/native/core/programmers/functional/FunctionalAssertParametersProgrammer.go +5 -13
- package/native/core/programmers/functional/FunctionalAssertReturnProgrammer.go +6 -14
- package/native/core/programmers/functional/FunctionalIsFunctionProgrammer.go +4 -6
- package/native/core/programmers/functional/FunctionalIsParametersProgrammer.go +49 -14
- package/native/core/programmers/functional/FunctionalIsReturnProgrammer.go +5 -13
- package/native/core/programmers/functional/FunctionalValidateFunctionProgrammer.go +4 -6
- package/native/core/programmers/functional/FunctionalValidateParametersProgrammer.go +5 -13
- package/native/core/programmers/functional/FunctionalValidateReturnProgrammer.go +5 -13
- package/native/core/programmers/functional/internal/FunctionalGeneralProgrammer.go +4 -17
- package/native/core/programmers/helpers/CloneJoiner.go +32 -0
- package/native/core/programmers/helpers/FunctionProgrammer.go +6 -13
- package/native/core/programmers/helpers/NotationJoiner.go +86 -28
- package/native/core/programmers/helpers/StringifyJoinder.go +161 -51
- package/native/core/programmers/helpers/UnionExplorer.go +203 -61
- package/native/core/programmers/helpers/joiner_branch_coverage_test.go +116 -118
- package/native/core/programmers/helpers/union_explorer_coverage_test.go +1 -1
- package/native/core/programmers/internal/CheckerProgrammer.go +100 -48
- package/native/core/programmers/iterate/check_template.go +344 -32
- package/native/core/programmers/iterate/iterate_check_coverage_test.go +76 -158
- package/native/core/programmers/iterate/iterate_utility_coverage_test.go +231 -270
- package/native/core/programmers/iterate/json_schema_discriminator.go +36 -10
- package/native/core/programmers/iterate/json_schema_discriminator_declaration_syntax_test.go +205 -0
- package/native/core/programmers/iterate/json_schema_object.go +49 -7
- package/native/core/programmers/iterate/json_schema_pattern_property_order_test.go +44 -0
- package/native/core/programmers/iterate/openapi_v3_downgrader.go +674 -0
- package/native/core/programmers/iterate/openapi_v3_downgrader_boolean_default_test.go +95 -0
- package/native/core/programmers/iterate/openapi_v3_downgrader_test.go +123 -0
- package/native/core/programmers/iterate/template_interpolation_tags_test.go +40 -8
- package/native/core/programmers/iterate/template_runtime_pattern.go +63 -7
- package/native/core/programmers/json/JsonApplicationProgrammer.go +45 -11
- package/native/core/programmers/json/JsonSchemasProgrammer.go +12 -2
- package/native/core/programmers/json/JsonStringifyProgrammer.go +47 -6
- package/native/core/programmers/llm/LlmApplicationProgrammer.go +21 -11
- package/native/core/programmers/llm/LlmSchemaProgrammer.go +23 -6
- package/native/core/programmers/llm/llm_reference_codec_test.go +24 -0
- package/native/core/programmers/notations/NotationGeneralProgrammer.go +183 -67
- package/native/core/programmers/notations/notation_general_helpers_test.go +1 -3
- package/native/core/programmers/notations/notation_general_programmer_pascal_multiword_test.go +72 -0
- package/native/core/programmers/notations/notation_general_programmer_underscore_boundary_test.go +68 -0
- package/native/core/programmers/plain/PlainClassifyProgrammer.go +23 -15
- package/native/core/programmers/plain/PlainCloneProgrammer.go +20 -7
- package/native/core/programmers/plain/PlainPruneProgrammer.go +19 -5
- package/native/core/programmers/plain/plain_tuple_seed_recovery_ownership_test.go +25 -0
- package/native/core/programmers/protobuf/ProtobufDecodeProgrammer.go +37 -28
- package/native/core/programmers/protobuf/ProtobufMessageProgrammer.go +41 -22
- package/native/core/programmers/protobuf/protobuf_programmer_helper_coverage_test.go +26 -0
- package/native/core/programmers/random_programmer_length_argument_test.go +53 -0
- package/native/core/schemas/metadata/MetadataCollection.go +266 -25
- package/native/core/schemas/metadata/MetadataDefaultLibrary.go +81 -0
- package/native/core/schemas/metadata/MetadataDependency.go +388 -0
- package/native/core/schemas/metadata/MetadataObjectType.go +24 -22
- package/native/core/schemas/metadata/metadata_collection_generic_argument_dot_test.go +122 -0
- package/native/core/schemas/metadata/metadata_collection_name_allocation_test.go +147 -0
- package/native/core/schemas/metadata/metadata_collection_openapi_name_cascade_test.go +55 -0
- package/native/core/schemas/metadata/metadata_collection_openapi_name_test.go +68 -0
- package/native/core/utils/PatternUtil.go +13 -0
- package/native/core/utils/PromiseTypeFactory.go +59 -0
- package/native/core/utils/ProtobufNameEncoder.go +8 -0
- package/native/core/utils/promise_type_factory_semantics_test.go +118 -0
- package/native/go.mod +9 -1
- package/native/transform/CallExpressionTransformer.go +12 -0
- package/native/transform/features/json/JsonApplicationTransformer.go +1 -1
- package/native/transform/features/json/JsonSchemaTransformer.go +1 -1
- package/native/transform/features/json/JsonSchemasTransformer.go +5 -4
- package/native/transform/features/protobuf/ProtobufMessageTransformer.go +1 -1
- package/package.json +12 -4
- package/src/executable/FileSystemIdentity.ts +222 -0
- package/src/executable/TypiaGenerateWizard.ts +386 -113
- package/src/functional.ts +30 -60
- package/src/internal/_ProtobufReader.ts +161 -46
- package/src/internal/_createStandardSchema.ts +15 -1
- package/src/internal/_decimal.ts +69 -0
- package/src/internal/_httpQueryParseURLSearchParams.ts +24 -2
- package/src/internal/_isFormatByte.ts +2 -5
- package/src/internal/_isFormatDate.ts +15 -2
- package/src/internal/_isFormatDateTime.ts +28 -2
- package/src/internal/_isFormatIri.ts +5 -2
- package/src/internal/_isFormatIriReference.ts +11 -3
- package/src/internal/_isFormatUriReference.ts +1 -1
- package/src/internal/_isMultipleOf.ts +8 -0
- package/src/internal/_isTypeFloat.ts +1 -1
- package/src/internal/_isTypeInt64.ts +1 -0
- package/src/internal/_isTypeInt64Bigint.ts +12 -0
- package/src/internal/_isTypeUint64.ts +1 -0
- package/src/internal/_isTypeUint64Bigint.ts +7 -0
- package/src/internal/_isUniqueItems.ts +134 -132
- package/src/internal/_jsonStringifyArray.ts +50 -0
- package/src/internal/_jsonStringifyElement.ts +19 -0
- package/src/internal/_jsonStringifyProperty.ts +30 -0
- package/src/internal/_llmApplicationFinalize.ts +6 -1
- package/src/internal/_notationAny.ts +9 -4
- package/src/internal/_notationAssign.ts +20 -0
- package/src/internal/_notationCamel.ts +31 -10
- package/src/internal/_notationKebab.ts +11 -0
- package/src/internal/_notationKeyCollision.ts +9 -0
- package/src/internal/_notationPascal.ts +19 -6
- package/src/internal/_notationSnake.ts +24 -21
- package/src/internal/_plainCloneAny.ts +208 -33
- package/src/internal/_randomArray.ts +13 -4
- package/src/internal/_randomFormatByte.ts +31 -1
- package/src/internal/_randomFormatDate.ts +6 -17
- package/src/internal/_randomFormatDatetime.ts +34 -15
- package/src/internal/_randomFormatDuration.ts +30 -13
- package/src/internal/_randomFormatEmail.ts +8 -2
- package/src/internal/_randomFormatHostname.ts +48 -1
- package/src/internal/_randomFormatIdnEmail.ts +18 -2
- package/src/internal/_randomFormatIdnHostname.ts +34 -2
- package/src/internal/_randomFormatIpv4.ts +43 -2
- package/src/internal/_randomFormatIpv6.ts +67 -2
- package/src/internal/_randomFormatIri.ts +3 -1
- package/src/internal/_randomFormatIriReference.ts +3 -1
- package/src/internal/_randomFormatJsonPointer.ts +28 -2
- package/src/internal/_randomFormatPassword.ts +11 -6
- package/src/internal/_randomFormatRegex.ts +22 -1
- package/src/internal/_randomFormatRelativeJsonPointer.ts +26 -6
- package/src/internal/_randomFormatTime.ts +46 -10
- package/src/internal/_randomFormatUri.ts +3 -1
- package/src/internal/_randomFormatUriReference.ts +3 -1
- package/src/internal/_randomFormatUriTemplate.ts +3 -1
- package/src/internal/_randomFormatUrl.ts +25 -2
- package/src/internal/_randomFormatUuid.ts +10 -6
- package/src/internal/_randomInteger.ts +87 -40
- package/src/internal/_randomMultiple.ts +245 -0
- package/src/internal/_randomNumber.ts +72 -55
- package/src/internal/_randomPattern.ts +29 -4
- package/src/internal/_randomStringLength.ts +116 -0
- package/src/internal/_stringLength.ts +5 -0
- package/src/internal/_validateReport.ts +5 -1
- package/src/internal/private/__notationRename.ts +21 -0
- package/src/internal/private/__randomComposition.ts +50 -0
- package/src/internal/private/__randomEpoch.ts +34 -0
- package/src/json.ts +2 -2
- package/src/module.ts +4 -6
- package/src/notations.ts +20 -4
- package/lib/internal/private/__notationCapitalize.d.ts +0 -1
- package/lib/internal/private/__notationCapitalize.js +0 -6
- package/lib/internal/private/__notationCapitalize.js.map +0 -1
- package/lib/internal/private/__notationCapitalize.mjs +0 -6
- package/lib/internal/private/__notationCapitalize.mjs.map +0 -1
- package/lib/internal/private/__notationUnsnake.d.ts +0 -4
- package/lib/internal/private/__notationUnsnake.js +0 -26
- package/lib/internal/private/__notationUnsnake.js.map +0 -1
- package/lib/internal/private/__notationUnsnake.mjs +0 -15
- package/lib/internal/private/__notationUnsnake.mjs.map +0 -1
- package/native/adapter/visit.go +0 -173
- package/native/adapter/visit_property_chain_edges_test.go +0 -129
- package/native/cmd/ttsc-typia/plugin_options_missing_config_test.go +0 -26
- package/native/cmd/ttsc-typia/plugin_options_undefined_false_test.go +0 -36
- package/native/core/programmers/helpers/disable_function_programmer_declare.go +0 -10
- package/native/core/programmers/iterate/check_union_array_like.go +0 -422
- package/native/core/programmers/iterate/prune_object_properties.go +0 -105
- package/native/core/programmers/iterate/stringify_dynamic_properties.go +0 -219
- package/native/core/programmers/iterate/stringify_native.go +0 -14
- package/native/core/programmers/iterate/stringify_regular_properties.go +0 -112
- package/native/core/schemas/metadata/MetadataApplication.go +0 -41
- package/src/internal/private/__notationCapitalize.ts +0 -2
- package/src/internal/private/__notationUnsnake.ts +0 -24
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"fmt"
|
|
5
|
+
"os"
|
|
6
|
+
"os/exec"
|
|
7
|
+
"path/filepath"
|
|
8
|
+
"strings"
|
|
9
|
+
"testing"
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
// TestUserGlobalNativeIdentityTransform keeps a user-authored global structural
|
|
13
|
+
// while a runtime-provided global of the same name stays runtime-native (#2200).
|
|
14
|
+
//
|
|
15
|
+
// Winning the checker's global type table proves only that a declaration is
|
|
16
|
+
// global. A project whose sole `File` or `Blob` declaration is its own `declare
|
|
17
|
+
// global` block wins that same lookup, so a resolution-only identity gate erases
|
|
18
|
+
// the user's members, emits `input instanceof File`, and throws `ReferenceError`
|
|
19
|
+
// wherever no runtime supplies that constructor. Native classification therefore
|
|
20
|
+
// has to ask which authority provides the constructor, and it must ask that
|
|
21
|
+
// question without demoting the genuine default-library, Node bare-global, or
|
|
22
|
+
// augmented natives that legitimately answer it.
|
|
23
|
+
//
|
|
24
|
+
// 1. Transform a project whose only File/Blob declarations are user globals in
|
|
25
|
+
// both the interface and the class spelling, one of them carrying its own
|
|
26
|
+
// `declare var` constructor binding, across is/assert/assertGuard/validate/
|
|
27
|
+
// equals/random, direct and factory forms, and alias, nested, intersection,
|
|
28
|
+
// union, and re-exported compositions.
|
|
29
|
+
// 2. Transform that project's json, protobuf, and llm schema surfaces, which a
|
|
30
|
+
// native classification removes from those consumers entirely.
|
|
31
|
+
// 3. Transform a global `type` alias spelling of the same collision in a second
|
|
32
|
+
// project, and near-miss control names in the first.
|
|
33
|
+
// 4. Transform a third project where @types/node provides the runtime bridge
|
|
34
|
+
// and the user contributes only an empty augmentation, requiring every
|
|
35
|
+
// default-library and Node-provided native to keep its `instanceof` check.
|
|
36
|
+
// 5. Execute every emitted validator in Node against structural user values and
|
|
37
|
+
// against the real runtime instances, requiring exact case counts so a
|
|
38
|
+
// dropped branch cannot pass silently.
|
|
39
|
+
func TestUserGlobalNativeIdentityTransform(t *testing.T) {
|
|
40
|
+
project := userGlobalNativeIdentityProject(t)
|
|
41
|
+
aliasProject := userGlobalNativeIdentityAliasProject(t)
|
|
42
|
+
providedProject := userGlobalNativeIdentityProvidedProject(t)
|
|
43
|
+
transform := func(dir string, file string) string {
|
|
44
|
+
t.Helper()
|
|
45
|
+
js, errText, code := ttscTypiaTestCapture(func() int {
|
|
46
|
+
return runTransform([]string{
|
|
47
|
+
"--cwd", dir,
|
|
48
|
+
"--tsconfig", "tsconfig.json",
|
|
49
|
+
"--file", file,
|
|
50
|
+
"--output", "js",
|
|
51
|
+
})
|
|
52
|
+
})
|
|
53
|
+
if code != 0 {
|
|
54
|
+
t.Fatalf("user global native identity transform %s/%s failed: code=%d stderr=\n%s", dir, file, code, errText)
|
|
55
|
+
}
|
|
56
|
+
return js
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
js := transform(project, "src/input.ts")
|
|
60
|
+
schemasJS := transform(project, "src/schemas.ts")
|
|
61
|
+
controlsJS := transform(project, "src/controls.ts")
|
|
62
|
+
aliasJS := transform(aliasProject, "src/input.ts")
|
|
63
|
+
providedJS := transform(providedProject, "src/input.ts")
|
|
64
|
+
|
|
65
|
+
failures := []string{}
|
|
66
|
+
for _, native := range []string{"instanceof File", "instanceof Blob"} {
|
|
67
|
+
for name, emit := range map[string]string{
|
|
68
|
+
"validator emit": js,
|
|
69
|
+
"schema emit": schemasJS,
|
|
70
|
+
"type alias emit": aliasJS,
|
|
71
|
+
"near-miss control": controlsJS,
|
|
72
|
+
} {
|
|
73
|
+
if strings.Contains(emit, native) {
|
|
74
|
+
failures = append(failures, fmt.Sprintf("%s promoted a user-authored global to %q", name, native))
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
for _, member := range []string{"userBlobBrand", "userFileBrand"} {
|
|
79
|
+
for name, emit := range map[string]string{
|
|
80
|
+
"validator emit": js,
|
|
81
|
+
"schema emit": schemasJS,
|
|
82
|
+
"type alias emit": aliasJS,
|
|
83
|
+
} {
|
|
84
|
+
if !strings.Contains(emit, member) {
|
|
85
|
+
failures = append(failures, fmt.Sprintf("%s dropped user-declared member %q", name, member))
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
for _, member := range []string{"intersectionBrand", "unionControl", "nestedHolder"} {
|
|
90
|
+
if !strings.Contains(js, member) {
|
|
91
|
+
failures = append(failures, fmt.Sprintf("validator emit dropped composition member %q", member))
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
for _, member := range []string{"nearMissBrand", "prefixBrand"} {
|
|
95
|
+
if !strings.Contains(controlsJS, member) {
|
|
96
|
+
failures = append(failures, fmt.Sprintf("near-miss control emit dropped member %q", member))
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
for _, kept := range []string{
|
|
100
|
+
"instanceof Date",
|
|
101
|
+
"instanceof RegExp",
|
|
102
|
+
"instanceof Uint8Array",
|
|
103
|
+
"instanceof Map",
|
|
104
|
+
"instanceof Set",
|
|
105
|
+
"instanceof WeakMap",
|
|
106
|
+
"instanceof WeakSet",
|
|
107
|
+
"instanceof File",
|
|
108
|
+
"instanceof Blob",
|
|
109
|
+
} {
|
|
110
|
+
if !strings.Contains(providedJS, kept) {
|
|
111
|
+
failures = append(failures, fmt.Sprintf("runtime-provided native lost %q", kept))
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
output, runtimeErr := userGlobalNativeIdentityRun(t, project, js, controlsJS)
|
|
116
|
+
if runtimeErr != nil {
|
|
117
|
+
failures = append(failures, fmt.Sprintf("user global runtime matrix failed: %v\n%s", runtimeErr, output))
|
|
118
|
+
}
|
|
119
|
+
// Counted from the runner's own table, which is the ground truth: 11 rows for
|
|
120
|
+
// the is/assert/assertGuard/validate/equals/random matrix, 15 for the
|
|
121
|
+
// createIs forms across direct, alias, re-export, branded intersection, union,
|
|
122
|
+
// and nested positions, and 2 near-miss name controls. The count is asserted
|
|
123
|
+
// rather than the exit code so a row that silently stops running cannot pass
|
|
124
|
+
// as a row that ran and agreed.
|
|
125
|
+
if expected := "RAN 28 USER GLOBAL CASES"; !strings.Contains(output, expected) {
|
|
126
|
+
failures = append(failures, fmt.Sprintf("user global runner did not report %q; got:\n%s", expected, output))
|
|
127
|
+
}
|
|
128
|
+
providedOutput, providedErr := userGlobalNativeIdentityProvidedRun(t, providedProject, providedJS)
|
|
129
|
+
if providedErr != nil {
|
|
130
|
+
failures = append(failures, fmt.Sprintf("runtime-provided matrix failed: %v\n%s", providedErr, providedOutput))
|
|
131
|
+
}
|
|
132
|
+
if expected := "RAN 18 PROVIDED CASES"; !strings.Contains(providedOutput, expected) {
|
|
133
|
+
failures = append(failures, fmt.Sprintf("provided runner did not report %q; got:\n%s", expected, providedOutput))
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if len(failures) != 0 {
|
|
137
|
+
t.Fatalf(
|
|
138
|
+
"user global native identity mismatches:\n%s\n\nvalidator emit:\n%s\n\nschema emit:\n%s\n\nalias emit:\n%s\n\ncontrol emit:\n%s\n\nprovided emit:\n%s",
|
|
139
|
+
strings.Join(failures, "\n"),
|
|
140
|
+
js,
|
|
141
|
+
schemasJS,
|
|
142
|
+
aliasJS,
|
|
143
|
+
controlsJS,
|
|
144
|
+
providedJS,
|
|
145
|
+
)
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
func userGlobalNativeIdentityWriteProject(t *testing.T, prefix string, files map[string]string) string {
|
|
150
|
+
t.Helper()
|
|
151
|
+
root := ttscTypiaTestRepoRoot(t)
|
|
152
|
+
base := filepath.Join(root, "packages", "typia", "native", ".tmp-ttsc-typia-tests")
|
|
153
|
+
if err := os.MkdirAll(base, 0o755); err != nil {
|
|
154
|
+
t.Fatalf("mkdir temp base: %v", err)
|
|
155
|
+
}
|
|
156
|
+
dir, err := os.MkdirTemp(base, prefix)
|
|
157
|
+
if err != nil {
|
|
158
|
+
t.Fatalf("create temp fixture: %v", err)
|
|
159
|
+
}
|
|
160
|
+
t.Cleanup(func() {
|
|
161
|
+
_ = os.RemoveAll(dir)
|
|
162
|
+
})
|
|
163
|
+
for name, content := range files {
|
|
164
|
+
path := filepath.Join(dir, filepath.FromSlash(name))
|
|
165
|
+
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
|
|
166
|
+
t.Fatalf("mkdir fixture path %s: %v", filepath.Dir(path), err)
|
|
167
|
+
}
|
|
168
|
+
if err := os.WriteFile(path, []byte(content), 0o644); err != nil {
|
|
169
|
+
t.Fatalf("write fixture file %s: %v", path, err)
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return dir
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
func userGlobalNativeIdentityProject(t *testing.T) string {
|
|
176
|
+
t.Helper()
|
|
177
|
+
return userGlobalNativeIdentityWriteProject(t, "user-global-native-identity-", map[string]string{
|
|
178
|
+
"tsconfig.json": userGlobalNativeIdentityTSConfig,
|
|
179
|
+
"src/globals.d.ts": userGlobalNativeIdentityGlobals,
|
|
180
|
+
"src/reexport.ts": userGlobalNativeIdentityReexport,
|
|
181
|
+
"src/input.ts": userGlobalNativeIdentitySource,
|
|
182
|
+
"src/schemas.ts": userGlobalNativeIdentitySchemaSource,
|
|
183
|
+
"src/controls.ts": userGlobalNativeIdentityControlSource,
|
|
184
|
+
})
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
func userGlobalNativeIdentityAliasProject(t *testing.T) string {
|
|
188
|
+
t.Helper()
|
|
189
|
+
return userGlobalNativeIdentityWriteProject(t, "user-global-native-identity-alias-", map[string]string{
|
|
190
|
+
"tsconfig.json": userGlobalNativeIdentityTSConfig,
|
|
191
|
+
"src/globals.d.ts": userGlobalNativeIdentityAliasGlobals,
|
|
192
|
+
"src/input.ts": userGlobalNativeIdentityAliasSource,
|
|
193
|
+
})
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
func userGlobalNativeIdentityProvidedProject(t *testing.T) string {
|
|
197
|
+
t.Helper()
|
|
198
|
+
return userGlobalNativeIdentityWriteProject(t, "user-global-native-identity-provided-", map[string]string{
|
|
199
|
+
"tsconfig.json": userGlobalNativeIdentityProvidedTSConfig,
|
|
200
|
+
"src/globals.d.ts": userGlobalNativeIdentityProvidedGlobals,
|
|
201
|
+
"src/input.ts": userGlobalNativeIdentityProvidedSource,
|
|
202
|
+
})
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
func userGlobalNativeIdentityRunner(t *testing.T, project string, modules map[string]string) (string, error) {
|
|
206
|
+
t.Helper()
|
|
207
|
+
node, err := exec.LookPath("node")
|
|
208
|
+
if err != nil {
|
|
209
|
+
t.Skip("node executable not found")
|
|
210
|
+
return "", nil
|
|
211
|
+
}
|
|
212
|
+
runtimeDir := filepath.Join(project, "runtime")
|
|
213
|
+
if err := os.MkdirAll(runtimeDir, 0o755); err != nil {
|
|
214
|
+
t.Fatalf("mkdir runtime dir: %v", err)
|
|
215
|
+
}
|
|
216
|
+
ttscTypiaTestWriteCommonRuntimeStubs(t, runtimeDir)
|
|
217
|
+
for name, content := range modules {
|
|
218
|
+
if err := os.WriteFile(filepath.Join(runtimeDir, name), []byte(content), 0o644); err != nil {
|
|
219
|
+
t.Fatalf("write runtime file %s: %v", name, err)
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
cmd := exec.Command(node, filepath.Join(runtimeDir, "run.cjs"))
|
|
223
|
+
cmd.Dir = runtimeDir
|
|
224
|
+
output, err := cmd.CombinedOutput()
|
|
225
|
+
return string(output), err
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
func userGlobalNativeIdentityRun(t *testing.T, project string, js string, controlsJS string) (string, error) {
|
|
229
|
+
t.Helper()
|
|
230
|
+
return userGlobalNativeIdentityRunner(t, project, map[string]string{
|
|
231
|
+
"input.cjs": ttscTypiaTestRewriteCommonJS(t, js),
|
|
232
|
+
"controls.cjs": ttscTypiaTestRewriteCommonJS(t, controlsJS),
|
|
233
|
+
"run.cjs": userGlobalNativeIdentityRuntimeRunner,
|
|
234
|
+
})
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
func userGlobalNativeIdentityProvidedRun(t *testing.T, project string, js string) (string, error) {
|
|
238
|
+
t.Helper()
|
|
239
|
+
return userGlobalNativeIdentityRunner(t, project, map[string]string{
|
|
240
|
+
"input.cjs": ttscTypiaTestRewriteCommonJS(t, js),
|
|
241
|
+
"run.cjs": userGlobalNativeIdentityProvidedRuntimeRunner,
|
|
242
|
+
})
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const userGlobalNativeIdentityTSConfig = `{
|
|
246
|
+
"compilerOptions": {
|
|
247
|
+
"target": "ES2022",
|
|
248
|
+
"module": "commonjs",
|
|
249
|
+
"moduleResolution": "bundler",
|
|
250
|
+
"ignoreDeprecations": "6.0",
|
|
251
|
+
"lib": ["ES2022"],
|
|
252
|
+
"types": [],
|
|
253
|
+
"esModuleInterop": true,
|
|
254
|
+
"strict": true,
|
|
255
|
+
"skipLibCheck": true
|
|
256
|
+
},
|
|
257
|
+
"include": ["src"]
|
|
258
|
+
}
|
|
259
|
+
`
|
|
260
|
+
|
|
261
|
+
const userGlobalNativeIdentityProvidedTSConfig = `{
|
|
262
|
+
"compilerOptions": {
|
|
263
|
+
"target": "ES2022",
|
|
264
|
+
"module": "commonjs",
|
|
265
|
+
"moduleResolution": "bundler",
|
|
266
|
+
"ignoreDeprecations": "6.0",
|
|
267
|
+
"lib": ["ES2022"],
|
|
268
|
+
"types": ["node"],
|
|
269
|
+
"esModuleInterop": true,
|
|
270
|
+
"strict": true,
|
|
271
|
+
"skipLibCheck": true
|
|
272
|
+
},
|
|
273
|
+
"include": ["src"]
|
|
274
|
+
}
|
|
275
|
+
`
|
|
276
|
+
|
|
277
|
+
// userGlobalNativeIdentityGlobals is the whole runtime-native declaration set of
|
|
278
|
+
// its project: neither the DOM libraries nor @types/node is loaded, so Blob and
|
|
279
|
+
// File exist only because this file declares them. Blob is the interface-only
|
|
280
|
+
// spelling and File is the class spelling, which additionally gives File a
|
|
281
|
+
// user-owned constructor binding — the one signal a runtime provider would
|
|
282
|
+
// otherwise be recognized by.
|
|
283
|
+
const userGlobalNativeIdentityGlobals = `export {};
|
|
284
|
+
|
|
285
|
+
declare global {
|
|
286
|
+
interface Blob {
|
|
287
|
+
userBlobBrand: string;
|
|
288
|
+
}
|
|
289
|
+
class File {
|
|
290
|
+
userBlobBrand: string;
|
|
291
|
+
userFileBrand: string;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
`
|
|
295
|
+
|
|
296
|
+
const userGlobalNativeIdentityReexport = `export type ReexportedFile = File;
|
|
297
|
+
`
|
|
298
|
+
|
|
299
|
+
const userGlobalNativeIdentitySource = `import typia from "typia";
|
|
300
|
+
import type { ReexportedFile } from "./reexport";
|
|
301
|
+
|
|
302
|
+
type FileAlias = File;
|
|
303
|
+
type BrandedFile = File & { intersectionBrand: string };
|
|
304
|
+
type FileUnion = BrandedFile | { unionControl: boolean };
|
|
305
|
+
type NestedFile = { nestedHolder: File };
|
|
306
|
+
|
|
307
|
+
export const isFile = (input: unknown): boolean => typia.is<File>(input);
|
|
308
|
+
export const assertFile = (input: unknown): File => typia.assert<File>(input);
|
|
309
|
+
export const assertGuardFile = (input: unknown): void => typia.assertGuard<File>(input);
|
|
310
|
+
export const validateFile = (input: unknown) => typia.validate<File>(input);
|
|
311
|
+
export const equalsFile = (input: unknown): boolean => typia.equals<File>(input);
|
|
312
|
+
export const randomBlob = (): Blob => typia.random<Blob>();
|
|
313
|
+
|
|
314
|
+
export const createdIsBlob = typia.createIs<Blob>();
|
|
315
|
+
export const createdIsFile = typia.createIs<File>();
|
|
316
|
+
export const createdIsAlias = typia.createIs<FileAlias>();
|
|
317
|
+
export const createdIsReexported = typia.createIs<ReexportedFile>();
|
|
318
|
+
export const createdIsBranded = typia.createIs<BrandedFile>();
|
|
319
|
+
export const createdIsUnion = typia.createIs<FileUnion>();
|
|
320
|
+
export const createdIsNested = typia.createIs<NestedFile>();
|
|
321
|
+
`
|
|
322
|
+
|
|
323
|
+
const userGlobalNativeIdentitySchemaSource = `import typia from "typia";
|
|
324
|
+
|
|
325
|
+
export const jsonSchema = typia.json.schema<File>();
|
|
326
|
+
export const jsonStringify = typia.json.createStringify<File>();
|
|
327
|
+
export const jsonIsStringify = typia.json.createIsStringify<File>();
|
|
328
|
+
export const protobufMessage = typia.protobuf.message<Blob>();
|
|
329
|
+
export const protobufEncode = typia.protobuf.createIsEncode<Blob>();
|
|
330
|
+
export const llmSchema = typia.llm.schema<File>({});
|
|
331
|
+
`
|
|
332
|
+
|
|
333
|
+
const userGlobalNativeIdentityControlSource = `import typia from "typia";
|
|
334
|
+
|
|
335
|
+
interface FileEntry {
|
|
336
|
+
nearMissBrand: string;
|
|
337
|
+
}
|
|
338
|
+
interface Blobby {
|
|
339
|
+
prefixBrand: string;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
export const createdIsFileEntry = typia.createIs<FileEntry>();
|
|
343
|
+
export const createdIsBlobby = typia.createIs<Blobby>();
|
|
344
|
+
`
|
|
345
|
+
|
|
346
|
+
// userGlobalNativeIdentityAliasGlobals spells the same collision as a global
|
|
347
|
+
// `type` alias, whose symbol is an anonymous type literal rather than a named
|
|
348
|
+
// declaration. It is the negative twin that proves the classification is decided
|
|
349
|
+
// by declaration provenance rather than by the shape of the declaring node.
|
|
350
|
+
const userGlobalNativeIdentityAliasGlobals = `export {};
|
|
351
|
+
|
|
352
|
+
declare global {
|
|
353
|
+
type Blob = { userBlobBrand: string };
|
|
354
|
+
type File = { userBlobBrand: string; userFileBrand: string };
|
|
355
|
+
}
|
|
356
|
+
`
|
|
357
|
+
|
|
358
|
+
const userGlobalNativeIdentityAliasSource = `import typia from "typia";
|
|
359
|
+
|
|
360
|
+
export const isAliasFile = (input: unknown): boolean => typia.is<File>(input);
|
|
361
|
+
export const createdIsAliasBlob = typia.createIs<Blob>();
|
|
362
|
+
`
|
|
363
|
+
|
|
364
|
+
// userGlobalNativeIdentityProvidedGlobals is the positive control: @types/node
|
|
365
|
+
// bridges the node:buffer constructors to the bare globals, and the user adds
|
|
366
|
+
// only an empty augmentation. Merging a declaration into a runtime-provided
|
|
367
|
+
// global must not change what provides that global.
|
|
368
|
+
const userGlobalNativeIdentityProvidedGlobals = `export {};
|
|
369
|
+
|
|
370
|
+
declare global {
|
|
371
|
+
interface Blob {}
|
|
372
|
+
interface File {}
|
|
373
|
+
}
|
|
374
|
+
`
|
|
375
|
+
|
|
376
|
+
const userGlobalNativeIdentityProvidedSource = `import typia from "typia";
|
|
377
|
+
|
|
378
|
+
export const createdIsDate = typia.createIs<Date>();
|
|
379
|
+
export const createdIsRegExp = typia.createIs<RegExp>();
|
|
380
|
+
export const createdIsBytes = typia.createIs<Uint8Array>();
|
|
381
|
+
export const createdIsMap = typia.createIs<Map<string, number>>();
|
|
382
|
+
export const createdIsSet = typia.createIs<Set<string>>();
|
|
383
|
+
export const createdIsWeakMap = typia.createIs<WeakMap<object, string>>();
|
|
384
|
+
export const createdIsWeakSet = typia.createIs<WeakSet<object>>();
|
|
385
|
+
export const createdIsFile = typia.createIs<File>();
|
|
386
|
+
export const createdIsBlob = typia.createIs<Blob>();
|
|
387
|
+
`
|
|
388
|
+
|
|
389
|
+
const userGlobalNativeIdentityRuntimeRunner = `const validators = require("./input.cjs");
|
|
390
|
+
const controls = require("./controls.cjs");
|
|
391
|
+
|
|
392
|
+
let ran = 0;
|
|
393
|
+
const failures = [];
|
|
394
|
+
const eq = (name, actual, expected) => {
|
|
395
|
+
ran += 1;
|
|
396
|
+
if (actual !== expected) {
|
|
397
|
+
failures.push(name + ": expected " + expected + " but got " + actual);
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
const throws = (name, run) => {
|
|
401
|
+
ran += 1;
|
|
402
|
+
try {
|
|
403
|
+
run();
|
|
404
|
+
failures.push(name + ": expected a throw but none happened");
|
|
405
|
+
} catch {}
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
const userBlob = { userBlobBrand: "user" };
|
|
409
|
+
const userFile = { userBlobBrand: "user", userFileBrand: "user" };
|
|
410
|
+
const realBlob = new Blob(["x"]);
|
|
411
|
+
const realFile = new File(["x"], "x.txt");
|
|
412
|
+
|
|
413
|
+
eq("is user File", validators.isFile(userFile), true);
|
|
414
|
+
eq("is real File", validators.isFile(realFile), false);
|
|
415
|
+
eq("assert user File", validators.assertFile(userFile), userFile);
|
|
416
|
+
throws("assert real File", () => validators.assertFile(realFile));
|
|
417
|
+
eq("assertGuard user File", validators.assertGuardFile(userFile), undefined);
|
|
418
|
+
throws("assertGuard real File", () => validators.assertGuardFile(realFile));
|
|
419
|
+
eq("validate user File", validators.validateFile(userFile).success, true);
|
|
420
|
+
eq("validate real File", validators.validateFile(realFile).success, false);
|
|
421
|
+
eq("equals user File", validators.equalsFile(userFile), true);
|
|
422
|
+
eq("equals real File", validators.equalsFile(realFile), false);
|
|
423
|
+
eq("random Blob brand", typeof validators.randomBlob().userBlobBrand, "string");
|
|
424
|
+
|
|
425
|
+
eq("createIs user Blob", validators.createdIsBlob(userBlob), true);
|
|
426
|
+
eq("createIs real Blob", validators.createdIsBlob(realBlob), false);
|
|
427
|
+
eq("createIs user File", validators.createdIsFile(userFile), true);
|
|
428
|
+
eq("createIs real File", validators.createdIsFile(realFile), false);
|
|
429
|
+
eq("alias user File", validators.createdIsAlias(userFile), true);
|
|
430
|
+
eq("alias real File", validators.createdIsAlias(realFile), false);
|
|
431
|
+
eq("re-export user File", validators.createdIsReexported(userFile), true);
|
|
432
|
+
eq("re-export real File", validators.createdIsReexported(realFile), false);
|
|
433
|
+
eq("branded user File", validators.createdIsBranded({ ...userFile, intersectionBrand: "x" }), true);
|
|
434
|
+
eq("branded user File without brand", validators.createdIsBranded(userFile), false);
|
|
435
|
+
eq("union branded arm", validators.createdIsUnion({ ...userFile, intersectionBrand: "x" }), true);
|
|
436
|
+
eq("union control arm", validators.createdIsUnion({ unionControl: true }), true);
|
|
437
|
+
eq("union rejects real File", validators.createdIsUnion(realFile), false);
|
|
438
|
+
eq("nested user File", validators.createdIsNested({ nestedHolder: userFile }), true);
|
|
439
|
+
eq("nested real File", validators.createdIsNested({ nestedHolder: realFile }), false);
|
|
440
|
+
|
|
441
|
+
eq("near-miss FileEntry", controls.createdIsFileEntry({ nearMissBrand: "x" }), true);
|
|
442
|
+
eq("prefix Blobby", controls.createdIsBlobby({ prefixBrand: "x" }), true);
|
|
443
|
+
|
|
444
|
+
console.log("RAN " + ran + " USER GLOBAL CASES");
|
|
445
|
+
if (failures.length !== 0) {
|
|
446
|
+
throw new Error("MISMATCHES:\n" + failures.join("\n"));
|
|
447
|
+
}
|
|
448
|
+
`
|
|
449
|
+
|
|
450
|
+
const userGlobalNativeIdentityProvidedRuntimeRunner = `const validators = require("./input.cjs");
|
|
451
|
+
|
|
452
|
+
let ran = 0;
|
|
453
|
+
const failures = [];
|
|
454
|
+
const eq = (name, actual, expected) => {
|
|
455
|
+
ran += 1;
|
|
456
|
+
if (actual !== expected) {
|
|
457
|
+
failures.push(name + ": expected " + expected + " but got " + actual);
|
|
458
|
+
}
|
|
459
|
+
};
|
|
460
|
+
|
|
461
|
+
eq("Date real", validators.createdIsDate(new Date()), true);
|
|
462
|
+
eq("Date plain", validators.createdIsDate({}), false);
|
|
463
|
+
eq("RegExp real", validators.createdIsRegExp(/x/), true);
|
|
464
|
+
eq("RegExp plain", validators.createdIsRegExp({}), false);
|
|
465
|
+
eq("Uint8Array real", validators.createdIsBytes(new Uint8Array(1)), true);
|
|
466
|
+
eq("Uint8Array plain", validators.createdIsBytes({}), false);
|
|
467
|
+
eq("Map real", validators.createdIsMap(new Map([["x", 1]])), true);
|
|
468
|
+
eq("Map plain", validators.createdIsMap({}), false);
|
|
469
|
+
eq("Set real", validators.createdIsSet(new Set(["x"])), true);
|
|
470
|
+
eq("Set plain", validators.createdIsSet({}), false);
|
|
471
|
+
eq("WeakMap real", validators.createdIsWeakMap(new WeakMap()), true);
|
|
472
|
+
eq("WeakMap plain", validators.createdIsWeakMap({}), false);
|
|
473
|
+
eq("WeakSet real", validators.createdIsWeakSet(new WeakSet()), true);
|
|
474
|
+
eq("WeakSet plain", validators.createdIsWeakSet({}), false);
|
|
475
|
+
eq("File real", validators.createdIsFile(new File(["x"], "x.txt")), true);
|
|
476
|
+
eq("File plain", validators.createdIsFile({ name: "x.txt", size: 1 }), false);
|
|
477
|
+
eq("Blob real", validators.createdIsBlob(new Blob(["x"])), true);
|
|
478
|
+
eq("Blob plain", validators.createdIsBlob({ size: 1, type: "text/plain" }), false);
|
|
479
|
+
|
|
480
|
+
console.log("RAN " + ran + " PROVIDED CASES");
|
|
481
|
+
if (failures.length !== 0) {
|
|
482
|
+
throw new Error("MISMATCHES:\n" + failures.join("\n"));
|
|
483
|
+
}
|
|
484
|
+
`
|
|
@@ -4,8 +4,41 @@ func formatCheatSheet_RegexCall(text string) string {
|
|
|
4
4
|
return text + ".test($input)"
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
+
// formatCheatSheet_ALIASES maps an alternative `@format` spelling onto the
|
|
8
|
+
// canonical FormatCheatSheet key it means.
|
|
9
|
+
//
|
|
10
|
+
// An alias owns no validator. It resolves to the cheat sheet entry through
|
|
11
|
+
// formatCheatSheet_resolve, so FormatCheatSheet stays the single owner of every
|
|
12
|
+
// format's validator and a correction to one reaches every spelling of it. The
|
|
13
|
+
// aliases previously carried validator strings of their own, which made each of
|
|
14
|
+
// them a second implementation sharing a name and free to drift: `datetime`
|
|
15
|
+
// emitted `format: "date-time"` while validating with `new Date`, so it accepted
|
|
16
|
+
// February 30th and rejected the RFC 3339 leap second the cheat sheet handles.
|
|
17
|
+
//
|
|
18
|
+
// Aliases live beside the cheat sheet so that enumerating this file enumerates
|
|
19
|
+
// every owner of the `@format` contract.
|
|
20
|
+
var formatCheatSheet_ALIASES = map[string]string{
|
|
21
|
+
"datetime": "date-time",
|
|
22
|
+
"dateTime": "date-time",
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// formatCheatSheet_resolve resolves a written `@format` value to the canonical
|
|
26
|
+
// format name and the validator FormatCheatSheet owns for it, reporting whether
|
|
27
|
+
// the value names a supported format at all.
|
|
28
|
+
func formatCheatSheet_resolve(value string) (string, string, bool) {
|
|
29
|
+
name := value
|
|
30
|
+
if canonical, ok := formatCheatSheet_ALIASES[value]; ok {
|
|
31
|
+
name = canonical
|
|
32
|
+
}
|
|
33
|
+
validate, ok := FormatCheatSheet[name]
|
|
34
|
+
if ok == false {
|
|
35
|
+
return "", "", false
|
|
36
|
+
}
|
|
37
|
+
return name, validate, true
|
|
38
|
+
}
|
|
39
|
+
|
|
7
40
|
var FormatCheatSheet = map[string]string{
|
|
8
|
-
"byte":
|
|
41
|
+
"byte": `/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test($input)`,
|
|
9
42
|
"password": "true",
|
|
10
43
|
"regex": "(() => { try { new RegExp($input); return true; } catch { return false; } })()",
|
|
11
44
|
"uuid": "/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test($input)",
|
|
@@ -13,16 +46,16 @@ var FormatCheatSheet = map[string]string{
|
|
|
13
46
|
"hostname": "/^(?=.{1,253}\\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\\.?$/i.test($input)",
|
|
14
47
|
"idn-email": "/^(([^<>()[\\]\\.,;:\\s@\\\"]+(\\.[^<>()[\\]\\.,;:\\s@\\\"]+)*)|(\\\".+\\\"))@(([^<>()[\\]\\.,;:\\s@\\\"]+\\.)+[^<>()[\\]\\.,;:\\s@\\\"]{2,})$/i.test($input)",
|
|
15
48
|
"idn-hostname": "/^([a-z0-9\\u00a1-\\uffff0-9]+(-[a-z0-9\\u00a1-\\uffff0-9]+)*\\.)+[a-z\\u00a1-\\uffff]{2,}$/i.test($input)",
|
|
16
|
-
"iri": "/^[A-Za-z][
|
|
17
|
-
"iri-reference": "/^[A-Za-z][
|
|
49
|
+
"iri": `(() => !/[\u0000-\u0020\u007f-\u009f\ud800-\udfff"<>\\^\x60{|}]/u.test($input) && !/%(?![0-9A-Fa-f]{2})/u.test($input) && /^[A-Za-z][A-Za-z0-9+.-]*:/u.test($input))()`,
|
|
50
|
+
"iri-reference": `(() => { if (/[\u0000-\u0020\u007f-\u009f\ud800-\udfff"<>\\^\x60{|}]/u.test($input) || /%(?![0-9A-Fa-f]{2})/u.test($input)) return false; const colon = $input.indexOf(":"); const boundary = $input.search(/[/?#]/u); return colon === -1 || (boundary !== -1 && boundary < colon) || /^[A-Za-z][A-Za-z0-9+.-]*:/u.test($input); })()`,
|
|
18
51
|
"ipv4": "/^(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)$/.test($input)",
|
|
19
|
-
"ipv6":
|
|
52
|
+
"ipv6": `/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i.test($input)`,
|
|
20
53
|
"uri": "/\\/|:/.test($input) && /^(?:[a-z][a-z0-9+\\-.]*:)(?:\\/?\\/(?:(?:[a-z0-9\\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\\.[a-z0-9\\-._~!$&'()*+,;=:]+)\\]|(?:(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)|(?:[a-z0-9\\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\\d*)?(?:\\/(?:[a-z0-9\\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\\/(?:(?:[a-z0-9\\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\\/(?:[a-z0-9\\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\\/(?:[a-z0-9\\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\\?(?:[a-z0-9\\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i.test($input)",
|
|
21
|
-
"uri-reference": "/^(?:[a-z][a-z0-9+\\-.]*:)?(?:\\/?\\/(?:(?:[a-z0-9\\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\\.[a-z0-9\\-._~!$&'()*+,;=:]+)\\]|(?:(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)|(?:[a-z0-9\\-._~!$&'
|
|
54
|
+
"uri-reference": "/^(?:(?:[a-z][a-z0-9+\\-.]*:)?(?:\\/?\\/(?:(?:[a-z0-9\\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\\.[a-z0-9\\-._~!$&'()*+,;=:]+)\\]|(?:(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)|(?:[a-z0-9\\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\\d*)?(?:\\/(?:[a-z0-9\\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\\/(?:(?:[a-z0-9\\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\\/(?:[a-z0-9\\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?)?|(?:[a-z][a-z0-9+\\-.]*:)(?:[a-z0-9\\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\\/(?:[a-z0-9\\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|(?:[a-z0-9\\-._~!$&'()*+,;=@]|%[0-9a-f]{2})+(?:\\/(?:[a-z0-9\\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\\?(?:[a-z0-9\\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i.test($input)",
|
|
22
55
|
"uri-template": "/^(?:(?:[^\\x00-\\x20\"'<>%\\\\^`{|}]|%[0-9a-f]{2})|\\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\\*)?)*\\})*$/i.test($input)",
|
|
23
56
|
"url": "/^(?:https?|ftp):\\/\\/(?:[^\\s/?#@]+(?::[^\\s/?#@]*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?=.{1,253}(?::\\d{2,5})?(?:\\/[^\\s]*)?$)(?:[a-z0-9\\u00a1-\\uffff](?:[-a-z0-9\\u00a1-\\uffff]{0,61}[a-z0-9\\u00a1-\\uffff])?\\.)+(?:[a-z\\u00a1-\\uffff](?:[-a-z0-9\\u00a1-\\uffff]{0,61}[a-z0-9\\u00a1-\\uffff])))(?::\\d{2,5})?(?:\\/[^\\s]*)?$/iu.test($input)",
|
|
24
|
-
"date-time":
|
|
25
|
-
"date":
|
|
57
|
+
"date-time": `(() => { const match = /^([0-9]{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])[Tt]((?:[01][0-9]|2[0-3])):([0-5][0-9]):([0-5][0-9]|60)(?:\.[0-9]+)?(?:[Zz]|([+-])((?:[01][0-9]|2[0-3])):([0-5][0-9]))$/.exec($input); if (match === null) return false; const year = Number(match[1]); const month = Number(match[2]); const day = Number(match[3]); if (day > [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month - 1] + (month === 2 && (year % 400 === 0 || (year % 4 === 0 && year % 100 !== 0)) ? 1 : 0)) return false; if (match[6] !== "60") return true; const instant = new Date(0); instant.setUTCFullYear(year, month - 1, day); instant.setUTCHours(Number(match[4]), Number(match[5]), 0, 0); const offset = match[7] === undefined ? 0 : (match[7] === "+" ? 1 : -1) * (Number(match[8]) * 60 + Number(match[9])); instant.setUTCMinutes(instant.getUTCMinutes() - offset); return instant.getUTCHours() === 23 && instant.getUTCMinutes() === 59 && ((instant.getUTCMonth() === 5 && instant.getUTCDate() === 30) || (instant.getUTCMonth() === 11 && instant.getUTCDate() === 31)); })()`,
|
|
58
|
+
"date": `(() => { const match = /^([0-9]{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/.exec($input); if (match === null) return false; const year = Number(match[1]); const month = Number(match[2]); const day = Number(match[3]); return day <= [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month - 1] + (month === 2 && (year % 400 === 0 || (year % 4 === 0 && year % 100 !== 0)) ? 1 : 0); })()`,
|
|
26
59
|
"time": "/^([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]{1,9})?(Z|[+-]([01][0-9]|2[0-3]):[0-5][0-9])$/i.test($input)",
|
|
27
60
|
"duration": "/^P(?!$)((\\d+Y)?(\\d+M)?(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+S)?)?|(\\d+W)?)$/.test($input)",
|
|
28
61
|
"json-pointer": "/^(?:\\/(?:[^~/]|~0|~1)*)*$/.test($input)",
|