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,388 @@
|
|
|
1
|
+
package metadata
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"sync"
|
|
5
|
+
|
|
6
|
+
nativeast "github.com/microsoft/typescript-go/shim/ast"
|
|
7
|
+
nativechecker "github.com/microsoft/typescript-go/shim/checker"
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
// MetadataDependency routes the source files owning the declarations that
|
|
11
|
+
// metadata analysis consults to a per-checker listener. The project transform
|
|
12
|
+
// host registers a listener before transforming a file and receives every
|
|
13
|
+
// declaration file the analysis reads for that file's typia call sites, which
|
|
14
|
+
// it reports as the transform envelope's `dependencies` so bundler caches can
|
|
15
|
+
// invalidate generated validators when a consulted type's file changes.
|
|
16
|
+
//
|
|
17
|
+
// The registry is keyed by checker: analysis code deep inside the metadata
|
|
18
|
+
// iterators has the checker at hand but no transform context, while one
|
|
19
|
+
// transform host drives exactly one program (and checker) at a time. A
|
|
20
|
+
// sync.Map keeps unrelated programs in the same process (tests) isolated, and
|
|
21
|
+
// every touch is a no-op when no listener is registered (build and single-file
|
|
22
|
+
// modes register none).
|
|
23
|
+
var metadataDependency_listeners sync.Map
|
|
24
|
+
|
|
25
|
+
// MetadataDependency_listen registers the listener that receives every
|
|
26
|
+
// consulted declaration file name resolved through `checker`. The caller owns
|
|
27
|
+
// attribution (which transformed file the touches belong to) and filtering.
|
|
28
|
+
func MetadataDependency_listen(checker *nativechecker.Checker, listener func(fileName string)) {
|
|
29
|
+
if checker == nil || listener == nil {
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
metadataDependency_listeners.Store(checker, listener)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// MetadataDependency_release removes the listener registered for `checker`.
|
|
36
|
+
func MetadataDependency_release(checker *nativechecker.Checker) {
|
|
37
|
+
if checker == nil {
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
metadataDependency_listeners.Delete(checker)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// MetadataDependency_active reports whether a listener is registered for
|
|
44
|
+
// `checker`, so analysis code can skip walks performed only for collection.
|
|
45
|
+
func MetadataDependency_active(checker *nativechecker.Checker) bool {
|
|
46
|
+
return metadataDependency_listener(checker) != nil
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// MetadataDependency_touchType reports the declaration files of a consulted
|
|
50
|
+
// type: both the structural symbol (interface / class / enum / object literal)
|
|
51
|
+
// and the type-name symbol (a `type` alias), which differ for aliased types.
|
|
52
|
+
func MetadataDependency_touchType(checker *nativechecker.Checker, typ *nativechecker.Type) {
|
|
53
|
+
if typ == nil {
|
|
54
|
+
return
|
|
55
|
+
}
|
|
56
|
+
listener := metadataDependency_listener(checker)
|
|
57
|
+
if listener == nil {
|
|
58
|
+
return
|
|
59
|
+
}
|
|
60
|
+
visited := map[*nativeast.Symbol]bool{}
|
|
61
|
+
metadataDependency_touchVisited(checker, listener, typ.Symbol(), visited)
|
|
62
|
+
metadataDependency_touchVisited(checker, listener, nativechecker.Type_getTypeNameSymbol(typ), visited)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// MetadataDependency_touchSymbol reports the declaration files of a consulted
|
|
66
|
+
// symbol (e.g. an object property or a heritage target).
|
|
67
|
+
func MetadataDependency_touchSymbol(checker *nativechecker.Checker, symbol *nativeast.Symbol) {
|
|
68
|
+
listener := metadataDependency_listener(checker)
|
|
69
|
+
if listener == nil {
|
|
70
|
+
return
|
|
71
|
+
}
|
|
72
|
+
metadataDependency_touchVisited(checker, listener, symbol, map[*nativeast.Symbol]bool{})
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// MetadataDependency_touchTypeNode reports every type reference WRITTEN inside
|
|
76
|
+
// a type node (a call-site type argument, a heritage element) by resolving each
|
|
77
|
+
// referenced name to its symbol. This is the syntactic complement of the
|
|
78
|
+
// type-graph touches: an alias of an intrinsic (`type Id = string`) leaves no
|
|
79
|
+
// trace on checker types — the checker interns the intrinsic without an alias
|
|
80
|
+
// symbol — so only the written reference can register the alias' own file.
|
|
81
|
+
func MetadataDependency_touchTypeNode(checker *nativechecker.Checker, node *nativeast.Node) {
|
|
82
|
+
listener := metadataDependency_listener(checker)
|
|
83
|
+
if listener == nil || node == nil {
|
|
84
|
+
return
|
|
85
|
+
}
|
|
86
|
+
metadataDependency_walkNode(checker, listener, node, map[*nativeast.Symbol]bool{})
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
func metadataDependency_listener(checker *nativechecker.Checker) func(fileName string) {
|
|
90
|
+
if checker == nil {
|
|
91
|
+
return nil
|
|
92
|
+
}
|
|
93
|
+
value, ok := metadataDependency_listeners.Load(checker)
|
|
94
|
+
if ok == false {
|
|
95
|
+
return nil
|
|
96
|
+
}
|
|
97
|
+
listener, ok := value.(func(fileName string))
|
|
98
|
+
if ok == false {
|
|
99
|
+
return nil
|
|
100
|
+
}
|
|
101
|
+
return listener
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// metadataDependency_touchVisited reports the symbol's declaration files and
|
|
105
|
+
// walks the type references written inside declarations that carry type
|
|
106
|
+
// annotations (aliases, properties, methods, parameters, index signatures), so
|
|
107
|
+
// checker-collapsed references — an alias of an intrinsic consumed through a
|
|
108
|
+
// property or another alias — still register their declaring files. `visited`
|
|
109
|
+
// guards alias cycles and bounds repeated work within one touch.
|
|
110
|
+
func metadataDependency_touchVisited(
|
|
111
|
+
checker *nativechecker.Checker,
|
|
112
|
+
listener func(fileName string),
|
|
113
|
+
symbol *nativeast.Symbol,
|
|
114
|
+
visited map[*nativeast.Symbol]bool,
|
|
115
|
+
) {
|
|
116
|
+
if symbol == nil || visited[symbol] {
|
|
117
|
+
return
|
|
118
|
+
}
|
|
119
|
+
visited[symbol] = true
|
|
120
|
+
for _, declaration := range symbol.Declarations {
|
|
121
|
+
if declaration == nil {
|
|
122
|
+
continue
|
|
123
|
+
}
|
|
124
|
+
if src := nativeast.GetSourceFileOfNode(declaration); src != nil {
|
|
125
|
+
listener(src.FileName())
|
|
126
|
+
}
|
|
127
|
+
for _, surface := range metadataDependency_typeSurface(declaration) {
|
|
128
|
+
metadataDependency_walkNode(checker, listener, surface, visited)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// metadataDependency_typeSurface selects the WRITTEN type nodes of a
|
|
134
|
+
// declaration: the whole node for a `type` alias (type parameters + aliased
|
|
135
|
+
// type), the annotation for properties and parameters, and parameter types +
|
|
136
|
+
// return type for methods, accessors, and index signatures. Bodies and
|
|
137
|
+
// initializers are excluded — a reference appearing only there is not part of
|
|
138
|
+
// the type the analysis consulted. Interface, class, and type-literal
|
|
139
|
+
// declarations contribute only their index signatures: every other member
|
|
140
|
+
// surfaces individually through property enumeration.
|
|
141
|
+
func metadataDependency_typeSurface(declaration *nativeast.Node) []*nativeast.Node {
|
|
142
|
+
switch declaration.Kind {
|
|
143
|
+
case nativeast.KindTypeAliasDeclaration:
|
|
144
|
+
return []*nativeast.Node{declaration}
|
|
145
|
+
case nativeast.KindInterfaceDeclaration,
|
|
146
|
+
nativeast.KindClassDeclaration,
|
|
147
|
+
nativeast.KindClassExpression,
|
|
148
|
+
nativeast.KindTypeLiteral:
|
|
149
|
+
// An index signature has no property symbol, so — unlike every other
|
|
150
|
+
// member — it never reaches the apparent-property walk that registers a
|
|
151
|
+
// member's declaring files. Its written key and value types are consulted
|
|
152
|
+
// (the analysis reads both off each index info), so an alias used there
|
|
153
|
+
// must register its file like any other consulted alias; without this the
|
|
154
|
+
// aliased file changed the generated validator with no reported edge for a
|
|
155
|
+
// bundler cache to invalidate (samchon/typia#2126). Members are surfaced
|
|
156
|
+
// through this same selector, which keeps an index signature's own body-
|
|
157
|
+
// free key/value contract as the boundary.
|
|
158
|
+
output := []*nativeast.Node{}
|
|
159
|
+
for _, member := range declaration.Members() {
|
|
160
|
+
if member == nil || member.Kind != nativeast.KindIndexSignature {
|
|
161
|
+
continue
|
|
162
|
+
}
|
|
163
|
+
output = append(output, metadataDependency_typeSurface(member)...)
|
|
164
|
+
}
|
|
165
|
+
return output
|
|
166
|
+
case nativeast.KindPropertySignature,
|
|
167
|
+
nativeast.KindPropertyDeclaration,
|
|
168
|
+
nativeast.KindParameter:
|
|
169
|
+
if annotation := declaration.Type(); annotation != nil {
|
|
170
|
+
return []*nativeast.Node{annotation}
|
|
171
|
+
}
|
|
172
|
+
return nil
|
|
173
|
+
case nativeast.KindMethodSignature,
|
|
174
|
+
nativeast.KindMethodDeclaration,
|
|
175
|
+
nativeast.KindGetAccessor,
|
|
176
|
+
nativeast.KindSetAccessor,
|
|
177
|
+
nativeast.KindIndexSignature:
|
|
178
|
+
output := []*nativeast.Node{}
|
|
179
|
+
for _, parameter := range declaration.Parameters() {
|
|
180
|
+
if parameter == nil {
|
|
181
|
+
continue
|
|
182
|
+
}
|
|
183
|
+
if annotation := parameter.Type(); annotation != nil {
|
|
184
|
+
output = append(output, annotation)
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if annotation := declaration.Type(); annotation != nil {
|
|
188
|
+
output = append(output, annotation)
|
|
189
|
+
}
|
|
190
|
+
return output
|
|
191
|
+
}
|
|
192
|
+
return nil
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// metadataDependency_walkNode descends a written node and resolves every type
|
|
196
|
+
// reference it contains: `TypeReference` names, heritage / `extends`
|
|
197
|
+
// expressions, `typeof` targets, and `import("...").T` qualifiers. Each
|
|
198
|
+
// resolved symbol is touched (following import aliases to their targets),
|
|
199
|
+
// which in turn walks type-alias declarations transitively.
|
|
200
|
+
func metadataDependency_walkNode(
|
|
201
|
+
checker *nativechecker.Checker,
|
|
202
|
+
listener func(fileName string),
|
|
203
|
+
node *nativeast.Node,
|
|
204
|
+
visited map[*nativeast.Symbol]bool,
|
|
205
|
+
) {
|
|
206
|
+
if node == nil {
|
|
207
|
+
return
|
|
208
|
+
}
|
|
209
|
+
var name *nativeast.Node
|
|
210
|
+
switch node.Kind {
|
|
211
|
+
case nativeast.KindTypeReference:
|
|
212
|
+
if ref := node.AsTypeReferenceNode(); ref != nil {
|
|
213
|
+
name = ref.TypeName
|
|
214
|
+
}
|
|
215
|
+
case nativeast.KindExpressionWithTypeArguments:
|
|
216
|
+
if expr := node.AsExpressionWithTypeArguments(); expr != nil {
|
|
217
|
+
name = expr.Expression
|
|
218
|
+
}
|
|
219
|
+
case nativeast.KindTypeQuery:
|
|
220
|
+
if query := node.AsTypeQueryNode(); query != nil {
|
|
221
|
+
name = query.ExprName
|
|
222
|
+
}
|
|
223
|
+
case nativeast.KindImportType:
|
|
224
|
+
if imported := node.AsImportTypeNode(); imported != nil {
|
|
225
|
+
name = imported.Qualifier
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if name != nil {
|
|
229
|
+
metadataDependency_touchVisited(checker, listener, metadataDependency_resolve(checker, listener, name), visited)
|
|
230
|
+
}
|
|
231
|
+
node.ForEachChild(func(child *nativeast.Node) bool {
|
|
232
|
+
metadataDependency_walkNode(checker, listener, child, visited)
|
|
233
|
+
return false
|
|
234
|
+
})
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// metadataDependency_resolve resolves a written reference name to its final
|
|
238
|
+
// symbol, following import aliases so the touched declarations are the real
|
|
239
|
+
// declaring files rather than the local import specifier. Every module the
|
|
240
|
+
// alias path traverses is reported on the way, because those intermediates
|
|
241
|
+
// SELECT which declaration the terminus is (see metadataDependency_touchPath).
|
|
242
|
+
func metadataDependency_resolve(
|
|
243
|
+
checker *nativechecker.Checker,
|
|
244
|
+
listener func(fileName string),
|
|
245
|
+
name *nativeast.Node,
|
|
246
|
+
) *nativeast.Symbol {
|
|
247
|
+
if checker == nil || name == nil {
|
|
248
|
+
return nil
|
|
249
|
+
}
|
|
250
|
+
symbol := checker.GetSymbolAtLocation(name)
|
|
251
|
+
if symbol == nil {
|
|
252
|
+
return nil
|
|
253
|
+
}
|
|
254
|
+
if symbol.Flags&nativeast.SymbolFlagsAlias != 0 {
|
|
255
|
+
metadataDependency_touchPath(checker, listener, symbol)
|
|
256
|
+
if resolved := nativechecker.Checker_getAliasedSymbol(checker, symbol); resolved != nil {
|
|
257
|
+
symbol = resolved
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return symbol
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// metadataDependency_touchPath reports every module an alias path traverses on
|
|
264
|
+
// its way to the declaration it finally names.
|
|
265
|
+
//
|
|
266
|
+
// Resolving an alias straight to its terminus reports where the type is
|
|
267
|
+
// declared, not what was consulted to find it. A barrel (`export { Alpha } from
|
|
268
|
+
// "./alpha"`) never holds the declaration, yet re-pointing that line at another
|
|
269
|
+
// module changes the generated validator — so a consumer that watches only the
|
|
270
|
+
// terminus has no edge to invalidate and serves a stale validator
|
|
271
|
+
// (samchon/typia#2126). Walking the path hop by hop reports each intermediate.
|
|
272
|
+
//
|
|
273
|
+
// Only the modules actually traversed for THIS reference are reported: the walk
|
|
274
|
+
// steps through the single named export it followed, never the rest of a
|
|
275
|
+
// barrel's exports, keeping unrelated siblings out of the envelope.
|
|
276
|
+
func metadataDependency_touchPath(
|
|
277
|
+
checker *nativechecker.Checker,
|
|
278
|
+
listener func(fileName string),
|
|
279
|
+
symbol *nativeast.Symbol,
|
|
280
|
+
) {
|
|
281
|
+
visited := map[*nativeast.Symbol]bool{}
|
|
282
|
+
for symbol != nil && symbol.Flags&nativeast.SymbolFlagsAlias != 0 && visited[symbol] == false {
|
|
283
|
+
visited[symbol] = true
|
|
284
|
+
declaration := nativechecker.Checker_getDeclarationOfAliasSymbol(checker, symbol)
|
|
285
|
+
if declaration == nil {
|
|
286
|
+
return
|
|
287
|
+
}
|
|
288
|
+
// The file that WRITES this hop (the barrel's own `export ... from` line).
|
|
289
|
+
if src := nativeast.GetSourceFileOfNode(declaration); src != nil {
|
|
290
|
+
listener(src.FileName())
|
|
291
|
+
}
|
|
292
|
+
specifier := metadataDependency_moduleSpecifier(declaration)
|
|
293
|
+
if specifier == nil {
|
|
294
|
+
// A `from`-less `export { Alpha }` re-publishes a LOCAL binding, which is
|
|
295
|
+
// itself an alias when the file imported the name first (`import { Alpha }
|
|
296
|
+
// from "./mid"; export { Alpha };`). Continuing from that local keeps the
|
|
297
|
+
// module it reads (`./mid`) on the path instead of ending the walk here.
|
|
298
|
+
symbol = metadataDependency_local(declaration)
|
|
299
|
+
continue
|
|
300
|
+
}
|
|
301
|
+
// A module specifier's symbol is its resolved module, whose declaration is
|
|
302
|
+
// the target source file. Reporting it keeps the next module registered
|
|
303
|
+
// even when the hop cannot be stepped through below (`export *` publishes
|
|
304
|
+
// no local specifier symbol to follow).
|
|
305
|
+
module := checker.GetSymbolAtLocation(specifier)
|
|
306
|
+
if module == nil {
|
|
307
|
+
return
|
|
308
|
+
}
|
|
309
|
+
for _, moduleDeclaration := range module.Declarations {
|
|
310
|
+
if src := nativeast.GetSourceFileOfNode(moduleDeclaration); src != nil {
|
|
311
|
+
listener(src.FileName())
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
symbol = metadataDependency_exported(module, declaration)
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// metadataDependency_exported steps one alias hop to the member `module`
|
|
319
|
+
// publishes under the name this declaration reads: `default` for an import
|
|
320
|
+
// clause, and for a named import / export specifier its property name when the
|
|
321
|
+
// hop renames (`export { Beta as Alpha }`) or its own name otherwise.
|
|
322
|
+
//
|
|
323
|
+
// Only those kinds are stepped. Any other alias binds the whole module rather
|
|
324
|
+
// than one export — a namespace import above all — so its local name is not an
|
|
325
|
+
// export name at all; looking one up would land on whatever member happens to
|
|
326
|
+
// share that name and report files the reference never consults. Returning nil
|
|
327
|
+
// stops the walk at the module already reported, which loses no edge: the
|
|
328
|
+
// terminus is resolved separately by the checker.
|
|
329
|
+
func metadataDependency_exported(module *nativeast.Symbol, declaration *nativeast.Node) *nativeast.Symbol {
|
|
330
|
+
if module.Exports == nil {
|
|
331
|
+
return nil
|
|
332
|
+
}
|
|
333
|
+
switch declaration.Kind {
|
|
334
|
+
case nativeast.KindImportClause:
|
|
335
|
+
// ast.InternalSymbolNameDefault, which the shim does not re-export.
|
|
336
|
+
return module.Exports["default"]
|
|
337
|
+
case nativeast.KindImportSpecifier, nativeast.KindExportSpecifier:
|
|
338
|
+
name := declaration.PropertyNameOrName()
|
|
339
|
+
if name == nil {
|
|
340
|
+
return nil
|
|
341
|
+
}
|
|
342
|
+
switch name.Kind {
|
|
343
|
+
case nativeast.KindIdentifier, nativeast.KindStringLiteral:
|
|
344
|
+
return module.Exports[name.Text()]
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
return nil
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// metadataDependency_local returns the local binding a `from`-less export
|
|
351
|
+
// specifier re-publishes, so a walk that reaches one can continue through the
|
|
352
|
+
// import that bound the name. Other declaration kinds have no such local to
|
|
353
|
+
// resume from.
|
|
354
|
+
func metadataDependency_local(declaration *nativeast.Node) *nativeast.Symbol {
|
|
355
|
+
if declaration.Kind != nativeast.KindExportSpecifier {
|
|
356
|
+
return nil
|
|
357
|
+
}
|
|
358
|
+
name := declaration.PropertyNameOrName()
|
|
359
|
+
if name == nil || name.Kind != nativeast.KindIdentifier {
|
|
360
|
+
return nil
|
|
361
|
+
}
|
|
362
|
+
source := nativeast.GetSourceFileOfNode(declaration)
|
|
363
|
+
if source == nil {
|
|
364
|
+
return nil
|
|
365
|
+
}
|
|
366
|
+
locals := source.AsNode().LocalsContainerData()
|
|
367
|
+
if locals == nil {
|
|
368
|
+
return nil
|
|
369
|
+
}
|
|
370
|
+
return locals.Locals[name.Text()]
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// metadataDependency_moduleSpecifier returns the module specifier of the
|
|
374
|
+
// import / export declaration an alias declaration belongs to, or nil when the
|
|
375
|
+
// alias has no module specifier to traverse (a local `import X = Y`, an
|
|
376
|
+
// `export =`, or an export clause with no `from`). Node.ModuleSpecifier panics
|
|
377
|
+
// on other kinds, so every kind is matched explicitly.
|
|
378
|
+
func metadataDependency_moduleSpecifier(declaration *nativeast.Node) *nativeast.Node {
|
|
379
|
+
for node := declaration; node != nil; node = node.Parent {
|
|
380
|
+
switch node.Kind {
|
|
381
|
+
case nativeast.KindImportDeclaration, nativeast.KindExportDeclaration:
|
|
382
|
+
return node.ModuleSpecifier()
|
|
383
|
+
case nativeast.KindSourceFile:
|
|
384
|
+
return nil
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
return nil
|
|
388
|
+
}
|
|
@@ -13,25 +13,25 @@ type IMetadataSchema_IObjectType struct {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
type MetadataObjectType struct {
|
|
16
|
-
Name
|
|
17
|
-
DisplayName
|
|
16
|
+
Name string
|
|
17
|
+
DisplayName string
|
|
18
18
|
// Source is the absolute-or-as-declared path of the file declaring a named
|
|
19
19
|
// class, captured at analysis time so plain.classify can value-import a
|
|
20
20
|
// cross-module class it reconstructs (Object.create / new / from). nil for
|
|
21
21
|
// anonymous/literal shapes and types with no locatable declaration. Read
|
|
22
22
|
// in-process by the classify programmer; not serialized (classify is
|
|
23
23
|
// single-pass), and ignored by clone/prune.
|
|
24
|
-
Source
|
|
24
|
+
Source *string
|
|
25
25
|
// SourceDefault is true when the class is the default export of Source, so a
|
|
26
26
|
// cross-module classify value-import uses a default (not named) import.
|
|
27
|
-
SourceDefault
|
|
27
|
+
SourceDefault bool
|
|
28
28
|
// PrivateFields is true when the named class declaration carries at least one
|
|
29
29
|
// ES `#private` member (a member named with a PrivateIdentifier). Such slots
|
|
30
30
|
// are installed only by running the constructor; plain.classify's field-copy
|
|
31
31
|
// (Object.create + assign) cannot restore them, so classify rejects any such
|
|
32
32
|
// class at a field-copied position. Read in-process by the classify
|
|
33
33
|
// programmer; ignored by clone/prune, not serialized.
|
|
34
|
-
PrivateFields
|
|
34
|
+
PrivateFields bool
|
|
35
35
|
// IsClass is true when this object's declaration is a `class` (declaration or
|
|
36
36
|
// expression), so it has a runtime VALUE binding plain.classify can
|
|
37
37
|
// `Object.create(<name>.prototype)`/`new` against. False for an interface, a
|
|
@@ -39,7 +39,7 @@ type MetadataObjectType struct {
|
|
|
39
39
|
// value, so classify field-copies a plain {} instead of referencing a
|
|
40
40
|
// type-only name. Read in-process by the classify programmer; ignored by
|
|
41
41
|
// clone/prune, not serialized.
|
|
42
|
-
IsClass
|
|
42
|
+
IsClass bool
|
|
43
43
|
// ValueRef overrides the runtime VALUE-binding name plain.classify uses when
|
|
44
44
|
// the class's metadata Name is not a usable runtime constructor reference —
|
|
45
45
|
// namely a NAMED class EXPRESSION (`const X = class Beast {...}`), whose Name
|
|
@@ -56,7 +56,7 @@ type MetadataObjectType struct {
|
|
|
56
56
|
Validated bool
|
|
57
57
|
Recursive bool
|
|
58
58
|
Nullables []bool
|
|
59
|
-
Parent_objects_
|
|
59
|
+
Parent_objects_ []*MetadataObject
|
|
60
60
|
Check_properties_ []*MetadataProperty
|
|
61
61
|
Tagged_ bool
|
|
62
62
|
literal_ *bool
|
|
@@ -165,16 +165,29 @@ func (obj *MetadataObjectType) IsLiteral() bool {
|
|
|
165
165
|
if obj.Recursive == false {
|
|
166
166
|
name := strings.ToValidUTF8(obj.Name, "__")
|
|
167
167
|
name = strings.ReplaceAll(name, "\uFFFD", "__")
|
|
168
|
-
value = name
|
|
169
|
-
name
|
|
170
|
-
strings.HasPrefix(name, "__type.") ||
|
|
171
|
-
strings.HasPrefix(name, "__object.") ||
|
|
168
|
+
value = metadataObjectType_isAnonymousName(name, "__type") ||
|
|
169
|
+
metadataObjectType_isAnonymousName(name, "__object") ||
|
|
172
170
|
strings.Contains(name, "readonly [")
|
|
173
171
|
}
|
|
174
172
|
obj.literal_ = &value
|
|
175
173
|
return value
|
|
176
174
|
}
|
|
177
175
|
|
|
176
|
+
// metadataObjectType_isAnonymousName reports whether an allocated id names an
|
|
177
|
+
// anonymous type literal, which the schema generators inline instead of
|
|
178
|
+
// emitting as a component.
|
|
179
|
+
//
|
|
180
|
+
// A second anonymous type is a duplicate of the first, so its id carries the
|
|
181
|
+
// collection's disambiguating counter and the bare marker is not enough to
|
|
182
|
+
// recognize it. This reads that counter back out of an id, which is why it must
|
|
183
|
+
// track `metadataCollection_duplicateSuffix` rather than spell the separator
|
|
184
|
+
// again: when the two disagreed, every anonymous type after the first stopped
|
|
185
|
+
// being recognized and was emitted as a `__type`-keyed component.
|
|
186
|
+
func metadataObjectType_isAnonymousName(name string, marker string) bool {
|
|
187
|
+
return name == marker ||
|
|
188
|
+
strings.HasPrefix(name, marker+metadataCollection_duplicateSuffix)
|
|
189
|
+
}
|
|
190
|
+
|
|
178
191
|
func (obj *MetadataObjectType) ToJSON() IMetadataSchema_IObjectType {
|
|
179
192
|
properties := make([]*IMetadataSchema_IProperty, 0, len(obj.Properties))
|
|
180
193
|
for _, property := range obj.Properties {
|
|
@@ -192,17 +205,6 @@ func (obj *MetadataObjectType) ToJSON() IMetadataSchema_IObjectType {
|
|
|
192
205
|
}
|
|
193
206
|
}
|
|
194
207
|
|
|
195
|
-
func MetadataObjectType_intersects(x *MetadataObjectType, y *MetadataObjectType) bool {
|
|
196
|
-
for _, prop := range x.Properties {
|
|
197
|
-
for _, oppo := range y.Properties {
|
|
198
|
-
if prop.Key.GetName() == oppo.Key.GetName() {
|
|
199
|
-
return true
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
return false
|
|
204
|
-
}
|
|
205
|
-
|
|
206
208
|
func MetadataObjectType_covers(x *MetadataObjectType, y *MetadataObjectType) bool {
|
|
207
209
|
if len(x.Properties) < len(y.Properties) {
|
|
208
210
|
return false
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
package metadata
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"regexp"
|
|
5
|
+
"strings"
|
|
6
|
+
"testing"
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
// TestMetadataCollectionGenericArgumentDot verifies only a type's own namespace
|
|
10
|
+
// qualification survives OpenAPI normalization as a dot.
|
|
11
|
+
//
|
|
12
|
+
// A dot in a Components Object key is read downstream as a namespace boundary:
|
|
13
|
+
// `JsonDescriptor.cascade` inherits the prefix component's description into the
|
|
14
|
+
// child. Normalization used to delete the angle brackets of `Gen<Ns.Inner>` and
|
|
15
|
+
// leave the argument's dot behind, so `GenNs.Inner` presented the unrelated
|
|
16
|
+
// `GenNs` interface as its parent — typia's and nestia's own
|
|
17
|
+
// `IPage<IShoppingSale.ISummary>` idiom, needing no contrived naming.
|
|
18
|
+
//
|
|
19
|
+
// Rewriting a dot must not merge two names that differ only by it, so a quoted
|
|
20
|
+
// literal's dot takes the escape-and-hash tier rather than the separator.
|
|
21
|
+
//
|
|
22
|
+
// 1. Preserve a real qualification, including a qualified generic's prefix.
|
|
23
|
+
// 2. Rewrite every dot that belongs to a flattened nested rendering.
|
|
24
|
+
// 3. Prove the rewrite keeps distinct names distinct and legal, and that the
|
|
25
|
+
// LLM key space is deliberately left alone.
|
|
26
|
+
func TestMetadataCollectionGenericArgumentDot(t *testing.T) {
|
|
27
|
+
// 1. AND 2. THE RULE
|
|
28
|
+
expected := map[string]string{
|
|
29
|
+
// a real namespace qualification is the whole point of the cascade
|
|
30
|
+
"Merged.Child": "Merged.Child",
|
|
31
|
+
"A.B.C": "A.B.C",
|
|
32
|
+
"Plain": "Plain",
|
|
33
|
+
"__type": "__type",
|
|
34
|
+
"_": "_",
|
|
35
|
+
"RecursiveA_x2F_B": "RecursiveA_x2F_B",
|
|
36
|
+
// a flattened type argument is not this type's namespace boundary
|
|
37
|
+
"Gen<Ns.Inner>": "GenNs-Inner",
|
|
38
|
+
"IPage<IShop.ISum>": "IPageIShop-ISum",
|
|
39
|
+
"Ns.Gen<Bar.Baz>": "Ns.GenBar-Baz",
|
|
40
|
+
"Gen<A.B, C.D>": "GenA-BC-D",
|
|
41
|
+
"Gen<Gen<A.B>>": "GenGenA-B",
|
|
42
|
+
// nor is a flattened union member's
|
|
43
|
+
"Array<A.B | C.D>": "ArrayA-BC-D",
|
|
44
|
+
// no dot, no change
|
|
45
|
+
"Gen<Plain>": "GenPlain",
|
|
46
|
+
}
|
|
47
|
+
for input, want := range expected {
|
|
48
|
+
if actual := MetadataCollection_replaceOpenApi(input); actual != want {
|
|
49
|
+
t.Fatalf("OpenAPI name normalization: input=%q actual=%q expected=%q", input, actual, want)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// 3. A UNICODE QUALIFICATION IS STILL A QUALIFICATION
|
|
54
|
+
//
|
|
55
|
+
// The accented rune is escaped, but the dot after it is a real namespace
|
|
56
|
+
// boundary and must not be rewritten as a flattened one.
|
|
57
|
+
if actual := MetadataCollection_replaceOpenApi("Café.Member"); strings.Contains(actual, ".") == false {
|
|
58
|
+
t.Fatalf("a Unicode qualification lost its namespace boundary: actual=%q", actual)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// 4. REWRITING A DOT NEVER MERGES A LITERAL WITH ITS PEERS
|
|
62
|
+
//
|
|
63
|
+
// A quoted literal can own the separator itself, so a literal dot takes the
|
|
64
|
+
// escape-and-hash tier instead of the separator. Without it `Recursive<"A.B">`
|
|
65
|
+
// and `Recursive<"A-B">` would become one name, and the allocator would then
|
|
66
|
+
// decide by discovery order which of the two keeps it.
|
|
67
|
+
grammar := regexp.MustCompile(`^[a-zA-Z0-9.\-_]+$`)
|
|
68
|
+
distinct := []string{
|
|
69
|
+
`Recursive<"A.B">`,
|
|
70
|
+
`Recursive<"A-B">`,
|
|
71
|
+
`Recursive<"A_x2E_B">`,
|
|
72
|
+
`Recursive<"AB">`,
|
|
73
|
+
"Recursive<Plain>",
|
|
74
|
+
"Recursive.A",
|
|
75
|
+
}
|
|
76
|
+
outputs := map[string]string{}
|
|
77
|
+
for _, input := range distinct {
|
|
78
|
+
actual := MetadataCollection_replaceOpenApi(input)
|
|
79
|
+
if grammar.MatchString(actual) == false {
|
|
80
|
+
t.Fatalf("illegal OpenAPI component name: input=%q output=%q", input, actual)
|
|
81
|
+
}
|
|
82
|
+
if previous, ok := outputs[actual]; ok {
|
|
83
|
+
t.Fatalf("distinct names merged: first=%q second=%q output=%q", previous, input, actual)
|
|
84
|
+
}
|
|
85
|
+
outputs[actual] = input
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// 5. NORMALIZATION IS NOT WHAT KEEPS EVERY NAME DISTINCT
|
|
89
|
+
//
|
|
90
|
+
// A qualified type argument and a quoted literal owning the separator do
|
|
91
|
+
// normalize alike. Escaping out of that would cost every `IPage<IShop.ISum>`
|
|
92
|
+
// key a hash, to separate names no real program declares together. The
|
|
93
|
+
// allocator is the layer that bounds it instead, so both types survive with
|
|
94
|
+
// their own key and neither schema is dropped. Uniqueness must never rest on
|
|
95
|
+
// the separator alone.
|
|
96
|
+
if MetadataCollection_replaceOpenApi("Recursive<A.B>") !=
|
|
97
|
+
MetadataCollection_replaceOpenApi(`Recursive<"A-B">`) {
|
|
98
|
+
t.Fatalf("this case no longer documents the residual; re-derive the note above")
|
|
99
|
+
}
|
|
100
|
+
taken := map[string]bool{}
|
|
101
|
+
counters := map[string]int{}
|
|
102
|
+
for _, input := range []string{"Recursive<A.B>", `Recursive<"A-B">`} {
|
|
103
|
+
// Allocate exactly as `getName` does, counter and all, so this pins the
|
|
104
|
+
// real path rather than a convenient approximation of it.
|
|
105
|
+
name := MetadataCollection_replaceOpenApi(input)
|
|
106
|
+
allocated, index := metadataCollection_allocateName(taken, name, counters[name])
|
|
107
|
+
if taken[allocated] {
|
|
108
|
+
t.Fatalf("a normalization collision dropped a type: input=%q id=%q", input, allocated)
|
|
109
|
+
}
|
|
110
|
+
taken[allocated] = true
|
|
111
|
+
counters[name] = index + 1
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// 6. THE LLM KEY SPACE IS DELIBERATELY UNTOUCHED
|
|
115
|
+
//
|
|
116
|
+
// Nothing reads a namespace parent out of an LLM `$defs` key or a
|
|
117
|
+
// `reflect.name` result, so the rule is scoped to the OpenAPI key space and
|
|
118
|
+
// this replacer keeps its existing contract.
|
|
119
|
+
if actual := MetadataCollection_replace("Gen<Ns.Inner>"); actual != "GenNs.Inner" {
|
|
120
|
+
t.Fatalf("the LLM key space changed shape: actual=%q", actual)
|
|
121
|
+
}
|
|
122
|
+
}
|