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
|
@@ -2,6 +2,7 @@ import { createCommand } from "commander";
|
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import inquirer from "inquirer";
|
|
4
4
|
import { createRequire } from "module";
|
|
5
|
+
import os from "os";
|
|
5
6
|
import path from "path";
|
|
6
7
|
import { glob, isDynamicPattern } from "tinyglobby";
|
|
7
8
|
import type {
|
|
@@ -9,6 +10,8 @@ import type {
|
|
|
9
10
|
ITtscCompilerTransformation,
|
|
10
11
|
} from "ttsc";
|
|
11
12
|
|
|
13
|
+
import { FileSystemIdentity } from "./FileSystemIdentity";
|
|
14
|
+
|
|
12
15
|
export namespace TypiaGenerateWizard {
|
|
13
16
|
export async function generate(): Promise<void> {
|
|
14
17
|
console.log("----------------------------------------");
|
|
@@ -98,24 +101,61 @@ export namespace TypiaGenerateWizard {
|
|
|
98
101
|
location.output = path.resolve(location.output);
|
|
99
102
|
location.project = resolveProjectConfigFile(location.project);
|
|
100
103
|
|
|
104
|
+
const policy = new FileSystemIdentity.Policy();
|
|
105
|
+
const outputProbe: string = await nearestExistingAncestor(location.output);
|
|
106
|
+
await ensureExistingDirectoryPath({
|
|
107
|
+
label: "output parent path",
|
|
108
|
+
directory: outputProbe,
|
|
109
|
+
});
|
|
110
|
+
policy.observe(
|
|
111
|
+
await FileSystemIdentity.probeDirectory(outputProbe),
|
|
112
|
+
outputProbe,
|
|
113
|
+
);
|
|
114
|
+
policy.observe(
|
|
115
|
+
await FileSystemIdentity.inspectDirectory(path.dirname(location.project)),
|
|
116
|
+
path.dirname(location.project),
|
|
117
|
+
);
|
|
118
|
+
|
|
101
119
|
const entries: IInputFile[] =
|
|
102
120
|
location.files.length === 0
|
|
103
|
-
? await prepareDirectoryInput(location)
|
|
104
|
-
: await prepareFileInputs(location);
|
|
121
|
+
? await prepareDirectoryInput(location, policy)
|
|
122
|
+
: await prepareFileInputs(location, policy);
|
|
123
|
+
const identity: FileSystemIdentity.IIdentity = policy.get();
|
|
124
|
+
await inspectTargetDirectories({
|
|
125
|
+
identity,
|
|
126
|
+
output: location.output,
|
|
127
|
+
targets: entries.map((entry) => entry.target),
|
|
128
|
+
});
|
|
105
129
|
|
|
106
130
|
const binary = resolveTsgoBinary();
|
|
107
131
|
const cwd = path.dirname(location.project);
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
tsconfig: location.project,
|
|
132
|
+
const temporaryProject: ITemporaryProject = await createTemporaryProject({
|
|
133
|
+
entries,
|
|
134
|
+
project: location.project,
|
|
112
135
|
});
|
|
113
|
-
|
|
114
|
-
|
|
136
|
+
let transformed: Record<string, string>;
|
|
137
|
+
try {
|
|
138
|
+
transformed = transformProject({
|
|
139
|
+
binary,
|
|
140
|
+
cwd,
|
|
141
|
+
projectRoot: cwd,
|
|
142
|
+
tsconfig: temporaryProject.config,
|
|
143
|
+
});
|
|
144
|
+
} finally {
|
|
145
|
+
await fs.promises.rm(temporaryProject.directory, {
|
|
146
|
+
force: true,
|
|
147
|
+
recursive: true,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
const outputByKey: Map<string, string> = indexTransformedOutputs(
|
|
151
|
+
transformed,
|
|
152
|
+
identity,
|
|
153
|
+
);
|
|
115
154
|
const outputs: IOutputFile[] = entries.map((entry) => {
|
|
116
155
|
const output = getTransformedOutput({
|
|
117
156
|
cwd,
|
|
118
157
|
entry,
|
|
158
|
+
identity,
|
|
119
159
|
outputByKey,
|
|
120
160
|
});
|
|
121
161
|
if (output === undefined) {
|
|
@@ -128,14 +168,19 @@ export namespace TypiaGenerateWizard {
|
|
|
128
168
|
|
|
129
169
|
await ensureOutputDirectory(location.output);
|
|
130
170
|
await ensureTargetDirectories({
|
|
171
|
+
identity,
|
|
131
172
|
output: location.output,
|
|
132
173
|
targets: outputs.map(({ entry }) => entry.target),
|
|
133
174
|
});
|
|
134
175
|
await ensurePhysicalTargets({
|
|
176
|
+
identity,
|
|
135
177
|
output: location.output,
|
|
136
178
|
entries: outputs.map(({ entry }) => entry),
|
|
137
179
|
});
|
|
138
|
-
await ensureTargetFiles(
|
|
180
|
+
await ensureTargetFiles(
|
|
181
|
+
outputs.map(({ entry }) => entry),
|
|
182
|
+
identity,
|
|
183
|
+
);
|
|
139
184
|
for (const { entry, output } of outputs) {
|
|
140
185
|
await fs.promises.writeFile(entry.target, formatOutput(output), "utf8");
|
|
141
186
|
}
|
|
@@ -151,6 +196,45 @@ export namespace TypiaGenerateWizard {
|
|
|
151
196
|
output: string;
|
|
152
197
|
}
|
|
153
198
|
|
|
199
|
+
interface ITraversalEntry {
|
|
200
|
+
file: string;
|
|
201
|
+
name: string;
|
|
202
|
+
stat: fs.Stats;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
interface ITemporaryProject {
|
|
206
|
+
config: string;
|
|
207
|
+
directory: string;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
async function createTemporaryProject(props: {
|
|
211
|
+
entries: IInputFile[];
|
|
212
|
+
project: string;
|
|
213
|
+
}): Promise<ITemporaryProject> {
|
|
214
|
+
const directory: string = await fs.promises.mkdtemp(
|
|
215
|
+
path.join(os.tmpdir(), "typia-generate-project-"),
|
|
216
|
+
);
|
|
217
|
+
const config: string = path.join(directory, "tsconfig.json");
|
|
218
|
+
try {
|
|
219
|
+
await fs.promises.writeFile(
|
|
220
|
+
config,
|
|
221
|
+
JSON.stringify({
|
|
222
|
+
extends: props.project,
|
|
223
|
+
exclude: [],
|
|
224
|
+
files: props.entries.map((entry) => compilerInputPath(entry.file)),
|
|
225
|
+
include: [],
|
|
226
|
+
}),
|
|
227
|
+
"utf8",
|
|
228
|
+
);
|
|
229
|
+
return { config, directory };
|
|
230
|
+
} catch (error) {
|
|
231
|
+
await fs.promises.rm(directory, { force: true, recursive: true });
|
|
232
|
+
throw new URIError(
|
|
233
|
+
`Error on TypiaGenerateWizard.generate(): unable to prepare the bounded input project: ${formatUnknownError(error)}`,
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
154
238
|
async function ensureOutputDirectory(output: string): Promise<void> {
|
|
155
239
|
if (fs.existsSync(output) === false) {
|
|
156
240
|
await ensureCreatableDirectory(output);
|
|
@@ -164,17 +248,36 @@ export namespace TypiaGenerateWizard {
|
|
|
164
248
|
}
|
|
165
249
|
|
|
166
250
|
async function ensureTargetDirectories(props: {
|
|
251
|
+
identity: FileSystemIdentity.IIdentity;
|
|
167
252
|
output: string;
|
|
168
253
|
targets: string[];
|
|
169
254
|
}): Promise<void> {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
255
|
+
await inspectTargetDirectories(props);
|
|
256
|
+
const directories: Map<string, string> = targetDirectories(props);
|
|
257
|
+
for (const directory of directories.values()) {
|
|
258
|
+
try {
|
|
259
|
+
await fs.promises.mkdir(directory, { recursive: true });
|
|
260
|
+
} catch (exp) {
|
|
261
|
+
throw new URIError(
|
|
262
|
+
`Error on TypiaGenerateWizard.generate(): unable to create output parent directory ${directory}: ${formatUnknownError(exp)}`,
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
await ensureExistingDirectory({
|
|
266
|
+
label: "output parent path",
|
|
267
|
+
directory,
|
|
268
|
+
});
|
|
174
269
|
}
|
|
270
|
+
}
|
|
175
271
|
|
|
272
|
+
async function inspectTargetDirectories(props: {
|
|
273
|
+
identity: FileSystemIdentity.IIdentity;
|
|
274
|
+
output: string;
|
|
275
|
+
targets: string[];
|
|
276
|
+
}): Promise<void> {
|
|
277
|
+
const directories: Map<string, string> = targetDirectories(props);
|
|
176
278
|
for (const directory of directories.values()) {
|
|
177
279
|
await ensureOutputAncestorDirectories({
|
|
280
|
+
identity: props.identity,
|
|
178
281
|
output: props.output,
|
|
179
282
|
directory,
|
|
180
283
|
});
|
|
@@ -185,19 +288,18 @@ export namespace TypiaGenerateWizard {
|
|
|
185
288
|
});
|
|
186
289
|
}
|
|
187
290
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
directory,
|
|
199
|
-
});
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function targetDirectories(props: {
|
|
294
|
+
identity: FileSystemIdentity.IIdentity;
|
|
295
|
+
targets: string[];
|
|
296
|
+
}): Map<string, string> {
|
|
297
|
+
const directories: Map<string, string> = new Map();
|
|
298
|
+
for (const target of props.targets) {
|
|
299
|
+
const directory: string = path.dirname(target);
|
|
300
|
+
directories.set(props.identity.filesystemKey(directory), directory);
|
|
200
301
|
}
|
|
302
|
+
return directories;
|
|
201
303
|
}
|
|
202
304
|
|
|
203
305
|
async function ensureCreatableDirectory(directory: string): Promise<void> {
|
|
@@ -223,12 +325,13 @@ export namespace TypiaGenerateWizard {
|
|
|
223
325
|
}
|
|
224
326
|
|
|
225
327
|
async function ensureOutputAncestorDirectories(props: {
|
|
328
|
+
identity: FileSystemIdentity.IIdentity;
|
|
226
329
|
output: string;
|
|
227
330
|
directory: string;
|
|
228
331
|
}): Promise<void> {
|
|
229
332
|
const output: string = path.resolve(props.output);
|
|
230
333
|
const directory: string = path.resolve(props.directory);
|
|
231
|
-
if (
|
|
334
|
+
if (props.identity.contains(directory, output) === false) {
|
|
232
335
|
throw new URIError(
|
|
233
336
|
`Error on TypiaGenerateWizard.generate(): output parent path escapes output directory: ${props.directory}`,
|
|
234
337
|
);
|
|
@@ -285,7 +388,7 @@ export namespace TypiaGenerateWizard {
|
|
|
285
388
|
current = path.join(current, segment);
|
|
286
389
|
await ensureExistingDirectorySegment({
|
|
287
390
|
label:
|
|
288
|
-
|
|
391
|
+
path.normalize(current) === path.normalize(directory)
|
|
289
392
|
? props.label
|
|
290
393
|
: `${props.label} ancestor`,
|
|
291
394
|
directory: current,
|
|
@@ -311,26 +414,29 @@ export namespace TypiaGenerateWizard {
|
|
|
311
414
|
}
|
|
312
415
|
|
|
313
416
|
async function ensurePhysicalTargets(props: {
|
|
417
|
+
identity: FileSystemIdentity.IIdentity;
|
|
314
418
|
output: string;
|
|
315
419
|
entries: IInputFile[];
|
|
316
420
|
}): Promise<void> {
|
|
317
421
|
const output: string = await fs.promises.realpath(props.output);
|
|
318
422
|
const inputs: Set<string> = new Set();
|
|
319
423
|
for (const entry of props.entries) {
|
|
320
|
-
inputs.add(
|
|
424
|
+
inputs.add(
|
|
425
|
+
props.identity.filesystemKey(await fs.promises.realpath(entry.file)),
|
|
426
|
+
);
|
|
321
427
|
}
|
|
322
428
|
|
|
323
429
|
for (const entry of props.entries) {
|
|
324
430
|
const parent: string = path.dirname(entry.target);
|
|
325
431
|
const directory: string = await fs.promises.realpath(parent);
|
|
326
|
-
if (
|
|
432
|
+
if (props.identity.contains(directory, output) === false) {
|
|
327
433
|
throw new URIError(
|
|
328
434
|
`Error on TypiaGenerateWizard.generate(): output parent path escapes output directory through a symbolic link: ${parent}`,
|
|
329
435
|
);
|
|
330
436
|
}
|
|
331
437
|
|
|
332
438
|
const target: string = path.join(directory, path.basename(entry.target));
|
|
333
|
-
if (inputs.has(filesystemKey(target))) {
|
|
439
|
+
if (inputs.has(props.identity.filesystemKey(target))) {
|
|
334
440
|
throw new URIError(
|
|
335
441
|
`Error on TypiaGenerateWizard.generate(): output file would overwrite input file through a symbolic link: ${entry.target}`,
|
|
336
442
|
);
|
|
@@ -338,18 +444,26 @@ export namespace TypiaGenerateWizard {
|
|
|
338
444
|
}
|
|
339
445
|
}
|
|
340
446
|
|
|
341
|
-
async function ensureTargetFiles(
|
|
447
|
+
async function ensureTargetFiles(
|
|
448
|
+
entries: IInputFile[],
|
|
449
|
+
identity: FileSystemIdentity.IIdentity,
|
|
450
|
+
): Promise<void> {
|
|
342
451
|
const inputs: Set<string> = new Set();
|
|
343
452
|
const files: Map<string, IInputFile> = new Map();
|
|
344
453
|
for (const entry of entries) {
|
|
345
|
-
inputs.add(
|
|
346
|
-
|
|
454
|
+
inputs.add(
|
|
455
|
+
fileIdentityKey(
|
|
456
|
+
await fs.promises.stat(entry.file, { bigint: true }),
|
|
457
|
+
await fs.promises.realpath(entry.file),
|
|
458
|
+
),
|
|
459
|
+
);
|
|
460
|
+
files.set(identity.filesystemKey(entry.target), entry);
|
|
347
461
|
}
|
|
348
462
|
|
|
349
463
|
for (const entry of files.values()) {
|
|
350
|
-
let stat: fs.
|
|
464
|
+
let stat: fs.BigIntStats;
|
|
351
465
|
try {
|
|
352
|
-
stat = await fs.promises.lstat(entry.target);
|
|
466
|
+
stat = await fs.promises.lstat(entry.target, { bigint: true });
|
|
353
467
|
} catch (exp) {
|
|
354
468
|
if (isMissingFileError(exp)) {
|
|
355
469
|
continue;
|
|
@@ -363,12 +477,16 @@ export namespace TypiaGenerateWizard {
|
|
|
363
477
|
`Error on TypiaGenerateWizard.generate(): output file path is not a regular file: ${entry.target}`,
|
|
364
478
|
);
|
|
365
479
|
}
|
|
366
|
-
if (
|
|
480
|
+
if (
|
|
481
|
+
inputs.has(
|
|
482
|
+
fileIdentityKey(stat, await fs.promises.realpath(entry.target)),
|
|
483
|
+
)
|
|
484
|
+
) {
|
|
367
485
|
throw new URIError(
|
|
368
486
|
`Error on TypiaGenerateWizard.generate(): output file would overwrite input file through a physical file alias: ${entry.target}`,
|
|
369
487
|
);
|
|
370
488
|
}
|
|
371
|
-
if (stat.nlink > 1) {
|
|
489
|
+
if (stat.nlink > BigInt(1)) {
|
|
372
490
|
throw new URIError(
|
|
373
491
|
`Error on TypiaGenerateWizard.generate(): output file has multiple hard links: ${entry.target}`,
|
|
374
492
|
);
|
|
@@ -378,6 +496,7 @@ export namespace TypiaGenerateWizard {
|
|
|
378
496
|
|
|
379
497
|
async function prepareDirectoryInput(
|
|
380
498
|
location: IArguments,
|
|
499
|
+
policy: FileSystemIdentity.Policy,
|
|
381
500
|
): Promise<IInputFile[]> {
|
|
382
501
|
if (location.input === undefined) {
|
|
383
502
|
throw new URIError(
|
|
@@ -396,15 +515,19 @@ export namespace TypiaGenerateWizard {
|
|
|
396
515
|
);
|
|
397
516
|
}
|
|
398
517
|
|
|
518
|
+
const inputReal: string = await fs.promises.realpath(input);
|
|
519
|
+
const outputReal: string | undefined = await optionalRealPath(
|
|
520
|
+
location.output,
|
|
521
|
+
);
|
|
399
522
|
const files: string[] = [];
|
|
400
523
|
await gather({
|
|
401
|
-
location: {
|
|
402
|
-
input,
|
|
403
|
-
output: location.output,
|
|
404
|
-
},
|
|
405
524
|
container: files,
|
|
406
525
|
from: input,
|
|
407
|
-
|
|
526
|
+
inputReal,
|
|
527
|
+
outputReal,
|
|
528
|
+
policy,
|
|
529
|
+
visitedDirectories: new Set(),
|
|
530
|
+
visitedFiles: new Set(),
|
|
408
531
|
});
|
|
409
532
|
return files.map((file) => ({
|
|
410
533
|
file,
|
|
@@ -414,14 +537,21 @@ export namespace TypiaGenerateWizard {
|
|
|
414
537
|
|
|
415
538
|
async function prepareFileInputs(
|
|
416
539
|
location: IArguments,
|
|
540
|
+
policy: FileSystemIdentity.Policy,
|
|
417
541
|
): Promise<IInputFile[]> {
|
|
418
542
|
const targets: Set<string> = new Set();
|
|
419
543
|
const output: IInputFile[] = [];
|
|
420
544
|
for (const input of await expandFileInputs(
|
|
421
545
|
location.files,
|
|
422
546
|
location.output,
|
|
547
|
+
policy,
|
|
423
548
|
)) {
|
|
424
549
|
const file: string = path.resolve(input);
|
|
550
|
+
policy.observe(
|
|
551
|
+
await FileSystemIdentity.inspectDirectory(path.dirname(file)),
|
|
552
|
+
path.dirname(file),
|
|
553
|
+
);
|
|
554
|
+
const identity: FileSystemIdentity.IIdentity = policy.get();
|
|
425
555
|
if (fs.existsSync(file) === false) {
|
|
426
556
|
throw new URIError(
|
|
427
557
|
`Error on TypiaGenerateWizard.generate(): input file does not exist: ${input}`,
|
|
@@ -430,21 +560,21 @@ export namespace TypiaGenerateWizard {
|
|
|
430
560
|
throw new URIError(
|
|
431
561
|
`Error on TypiaGenerateWizard.generate(): input path is not a file: ${input}`,
|
|
432
562
|
);
|
|
433
|
-
} else if (isDeclarationFile(file)) {
|
|
563
|
+
} else if (identity.isDeclarationFile(file)) {
|
|
434
564
|
continue;
|
|
435
|
-
} else if (isSupportedExtension(file) === false) {
|
|
565
|
+
} else if (identity.isSupportedExtension(file) === false) {
|
|
436
566
|
throw new URIError(
|
|
437
567
|
`Error on TypiaGenerateWizard.generate(): input file is not a supported TypeScript source: ${input}`,
|
|
438
568
|
);
|
|
439
569
|
}
|
|
440
570
|
|
|
441
571
|
const target: string = path.join(location.output, path.basename(file));
|
|
442
|
-
if (isSamePath(file, target)) {
|
|
572
|
+
if (identity.isSamePath(file, target)) {
|
|
443
573
|
throw new URIError(
|
|
444
574
|
`Error on TypiaGenerateWizard.generate(): output file would overwrite input file: ${input}`,
|
|
445
575
|
);
|
|
446
576
|
}
|
|
447
|
-
const key: string = filesystemKey(target);
|
|
577
|
+
const key: string = identity.filesystemKey(target);
|
|
448
578
|
if (targets.has(key)) {
|
|
449
579
|
throw new URIError(
|
|
450
580
|
`Error on TypiaGenerateWizard.generate(): duplicate output filename for ${target}`,
|
|
@@ -464,14 +594,25 @@ export namespace TypiaGenerateWizard {
|
|
|
464
594
|
async function expandFileInputs(
|
|
465
595
|
inputs: string[],
|
|
466
596
|
directory: string,
|
|
597
|
+
policy: FileSystemIdentity.Policy,
|
|
467
598
|
): Promise<string[]> {
|
|
468
599
|
const output: string[] = [];
|
|
469
600
|
for (const input of inputs) {
|
|
470
601
|
const pattern: string = toGlobPattern(input);
|
|
471
602
|
if (isDynamicPattern(pattern, { caseSensitiveMatch: true })) {
|
|
603
|
+
const searchDirectory: string = await globSearchDirectory(input);
|
|
604
|
+
const caseSensitive: boolean | undefined =
|
|
605
|
+
await FileSystemIdentity.inspectDirectory(searchDirectory);
|
|
606
|
+
if (caseSensitive === undefined) {
|
|
607
|
+
throw new URIError(
|
|
608
|
+
`Error on TypiaGenerateWizard.generate(): unable to determine filesystem case behavior for input pattern base ${searchDirectory}.`,
|
|
609
|
+
);
|
|
610
|
+
}
|
|
611
|
+
policy.observe(caseSensitive, searchDirectory);
|
|
612
|
+
const identity: FileSystemIdentity.IIdentity = policy.get();
|
|
472
613
|
const matches: string[] = await glob(pattern, {
|
|
473
614
|
absolute: true,
|
|
474
|
-
caseSensitiveMatch:
|
|
615
|
+
caseSensitiveMatch: identity.caseSensitive,
|
|
475
616
|
cwd: process.cwd(),
|
|
476
617
|
onlyFiles: true,
|
|
477
618
|
});
|
|
@@ -481,13 +622,17 @@ export namespace TypiaGenerateWizard {
|
|
|
481
622
|
);
|
|
482
623
|
}
|
|
483
624
|
output.push(
|
|
484
|
-
...excludeOutputFiles(matches, directory).filter(
|
|
485
|
-
isSupportedExtension,
|
|
625
|
+
...excludeOutputFiles(matches, directory, identity).filter((file) =>
|
|
626
|
+
identity.isSupportedExtension(file),
|
|
486
627
|
),
|
|
487
628
|
);
|
|
488
629
|
} else {
|
|
489
630
|
const file: string = path.resolve(input);
|
|
490
|
-
|
|
631
|
+
policy.observe(
|
|
632
|
+
await FileSystemIdentity.inspectDirectory(path.dirname(file)),
|
|
633
|
+
path.dirname(file),
|
|
634
|
+
);
|
|
635
|
+
if (policy.get().contains(file, directory) === false) {
|
|
491
636
|
output.push(file);
|
|
492
637
|
}
|
|
493
638
|
}
|
|
@@ -495,8 +640,25 @@ export namespace TypiaGenerateWizard {
|
|
|
495
640
|
return output;
|
|
496
641
|
}
|
|
497
642
|
|
|
498
|
-
function excludeOutputFiles(
|
|
499
|
-
|
|
643
|
+
function excludeOutputFiles(
|
|
644
|
+
files: string[],
|
|
645
|
+
directory: string,
|
|
646
|
+
identity: FileSystemIdentity.IIdentity,
|
|
647
|
+
): string[] {
|
|
648
|
+
return files.filter((file) => identity.contains(file, directory) === false);
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
async function globSearchDirectory(input: string): Promise<string> {
|
|
652
|
+
let current: string = path.resolve(input);
|
|
653
|
+
while (
|
|
654
|
+
isDynamicPattern(toGlobPattern(current), { caseSensitiveMatch: true })
|
|
655
|
+
) {
|
|
656
|
+
const parent: string = path.dirname(current);
|
|
657
|
+
if (parent === current) break;
|
|
658
|
+
current = parent;
|
|
659
|
+
}
|
|
660
|
+
if (fs.existsSync(current) && (await isDirectory(current))) return current;
|
|
661
|
+
return nearestExistingAncestor(path.dirname(current));
|
|
500
662
|
}
|
|
501
663
|
|
|
502
664
|
function toGlobPattern(input: string): string {
|
|
@@ -506,12 +668,14 @@ export namespace TypiaGenerateWizard {
|
|
|
506
668
|
function transformProject(props: {
|
|
507
669
|
binary: string;
|
|
508
670
|
cwd: string;
|
|
671
|
+
projectRoot: string;
|
|
509
672
|
tsconfig: string;
|
|
510
673
|
}): Record<string, string> {
|
|
511
674
|
const TtscCompiler = loadTtscCompiler();
|
|
512
675
|
const result: ITtscCompilerTransformation = new TtscCompiler({
|
|
513
676
|
binary: props.binary,
|
|
514
677
|
cwd: props.cwd,
|
|
678
|
+
projectRoot: props.projectRoot,
|
|
515
679
|
tsconfig: props.tsconfig,
|
|
516
680
|
}).transform();
|
|
517
681
|
if (result.type === "success") {
|
|
@@ -671,7 +835,7 @@ export namespace TypiaGenerateWizard {
|
|
|
671
835
|
function resolveFromRoots(request: string, roots: string[]): string | null {
|
|
672
836
|
for (const root of roots) {
|
|
673
837
|
try {
|
|
674
|
-
return
|
|
838
|
+
return createRequire(path.join(root, "package.json")).resolve(request);
|
|
675
839
|
} catch {
|
|
676
840
|
continue;
|
|
677
841
|
}
|
|
@@ -690,47 +854,104 @@ export namespace TypiaGenerateWizard {
|
|
|
690
854
|
}
|
|
691
855
|
|
|
692
856
|
async function gather(props: {
|
|
693
|
-
location: {
|
|
694
|
-
input: string;
|
|
695
|
-
output: string;
|
|
696
|
-
};
|
|
697
857
|
container: string[];
|
|
698
858
|
from: string;
|
|
699
|
-
|
|
859
|
+
inputReal: string;
|
|
860
|
+
outputReal: string | undefined;
|
|
861
|
+
policy: FileSystemIdentity.Policy;
|
|
862
|
+
visitedDirectories: Set<string>;
|
|
863
|
+
visitedFiles: Set<string>;
|
|
700
864
|
}): Promise<void> {
|
|
701
|
-
|
|
865
|
+
const currentReal: string = await resolveTraversalPath(props.from);
|
|
866
|
+
if (
|
|
867
|
+
props.outputReal !== undefined &&
|
|
868
|
+
isPhysicalSameOrChildPath(currentReal, props.outputReal)
|
|
869
|
+
)
|
|
870
|
+
return;
|
|
871
|
+
ensurePhysicalInputContainment({
|
|
872
|
+
file: props.from,
|
|
873
|
+
input: props.inputReal,
|
|
874
|
+
real: currentReal,
|
|
875
|
+
});
|
|
702
876
|
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
877
|
+
const currentStat: fs.BigIntStats = await fs.promises.stat(props.from, {
|
|
878
|
+
bigint: true,
|
|
879
|
+
});
|
|
880
|
+
const directoryIdentity: string = fileIdentityKey(currentStat, currentReal);
|
|
881
|
+
if (props.visitedDirectories.has(directoryIdentity)) {
|
|
882
|
+
const lexicalStat: fs.Stats = await fs.promises.lstat(props.from);
|
|
883
|
+
if (lexicalStat.isSymbolicLink()) {
|
|
884
|
+
throw new URIError(
|
|
885
|
+
`Error on TypiaGenerateWizard.generate(): input directory link revisits a physical directory: ${props.from}.`,
|
|
886
|
+
);
|
|
887
|
+
}
|
|
888
|
+
return;
|
|
889
|
+
}
|
|
890
|
+
props.visitedDirectories.add(directoryIdentity);
|
|
891
|
+
|
|
892
|
+
props.policy.observe(
|
|
893
|
+
await FileSystemIdentity.inspectDirectory(props.from),
|
|
894
|
+
props.from,
|
|
895
|
+
);
|
|
896
|
+
const identity: FileSystemIdentity.IIdentity = props.policy.get();
|
|
897
|
+
const entries: ITraversalEntry[] = await Promise.all(
|
|
898
|
+
(await fs.promises.readdir(props.from)).map(async (name) => {
|
|
899
|
+
const file: string = path.join(props.from, name);
|
|
900
|
+
try {
|
|
901
|
+
return { file, name, stat: await fs.promises.lstat(file) };
|
|
902
|
+
} catch (error) {
|
|
903
|
+
throw new URIError(
|
|
904
|
+
`Error on TypiaGenerateWizard.generate(): unable to inspect input path ${file}: ${formatUnknownError(error)}`,
|
|
905
|
+
);
|
|
906
|
+
}
|
|
907
|
+
}),
|
|
908
|
+
);
|
|
909
|
+
entries.sort((x, y) => {
|
|
910
|
+
const linkOrder: number =
|
|
911
|
+
Number(x.stat.isSymbolicLink()) - Number(y.stat.isSymbolicLink());
|
|
912
|
+
return linkOrder !== 0
|
|
913
|
+
? linkOrder
|
|
914
|
+
: Buffer.compare(Buffer.from(x.name), Buffer.from(y.name));
|
|
915
|
+
});
|
|
916
|
+
|
|
917
|
+
for (const entry of entries) {
|
|
918
|
+
let stat: fs.BigIntStats;
|
|
919
|
+
let real: string;
|
|
920
|
+
try {
|
|
921
|
+
stat = await fs.promises.stat(entry.file, { bigint: true });
|
|
922
|
+
real = await fs.promises.realpath(entry.file);
|
|
923
|
+
} catch (error) {
|
|
924
|
+
throw new URIError(
|
|
925
|
+
`Error on TypiaGenerateWizard.generate(): input link target is missing or unreadable: ${entry.file}: ${formatUnknownError(error)}`,
|
|
926
|
+
);
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
if (
|
|
930
|
+
props.outputReal !== undefined &&
|
|
931
|
+
isPhysicalSameOrChildPath(real, props.outputReal)
|
|
932
|
+
)
|
|
933
|
+
continue;
|
|
934
|
+
ensurePhysicalInputContainment({
|
|
935
|
+
file: entry.file,
|
|
936
|
+
input: props.inputReal,
|
|
937
|
+
real,
|
|
938
|
+
});
|
|
706
939
|
|
|
707
940
|
if (stat.isDirectory()) {
|
|
708
|
-
await gather({
|
|
709
|
-
location: props.location,
|
|
710
|
-
container: props.container,
|
|
711
|
-
from: next,
|
|
712
|
-
to: path.join(props.to, file),
|
|
713
|
-
});
|
|
941
|
+
await gather({ ...props, from: entry.file });
|
|
714
942
|
continue;
|
|
715
943
|
}
|
|
716
|
-
if (
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
function isSupportedExtension(filename: string): boolean {
|
|
723
|
-
const normalized: string = isCaseSensitive()
|
|
724
|
-
? filename
|
|
725
|
-
: filename.toLowerCase();
|
|
726
|
-
return TS_PATTERN.test(normalized) && !DTS_PATTERN.test(normalized);
|
|
727
|
-
}
|
|
944
|
+
if (
|
|
945
|
+
stat.isFile() === false ||
|
|
946
|
+
identity.isSupportedExtension(entry.name) === false
|
|
947
|
+
)
|
|
948
|
+
continue;
|
|
728
949
|
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
950
|
+
const fileIdentity: string = fileIdentityKey(stat, real);
|
|
951
|
+
if (props.visitedFiles.has(fileIdentity)) continue;
|
|
952
|
+
props.visitedFiles.add(fileIdentity);
|
|
953
|
+
props.container.push(entry.file);
|
|
954
|
+
}
|
|
734
955
|
}
|
|
735
956
|
|
|
736
957
|
function formatOutput(output: string): string {
|
|
@@ -741,10 +962,17 @@ export namespace TypiaGenerateWizard {
|
|
|
741
962
|
|
|
742
963
|
function indexTransformedOutputs(
|
|
743
964
|
outputs: Record<string, string>,
|
|
965
|
+
identity: FileSystemIdentity.IIdentity,
|
|
744
966
|
): Map<string, string> {
|
|
745
967
|
const map: Map<string, string> = new Map();
|
|
746
968
|
for (const [file, output] of Object.entries(outputs)) {
|
|
747
|
-
|
|
969
|
+
const key: string = identity.projectFileKey(file);
|
|
970
|
+
if (map.has(key)) {
|
|
971
|
+
throw new URIError(
|
|
972
|
+
`Error on TypiaGenerateWizard.generate(): transformed outputs have ambiguous filesystem identities: ${file}.`,
|
|
973
|
+
);
|
|
974
|
+
}
|
|
975
|
+
map.set(key, output);
|
|
748
976
|
}
|
|
749
977
|
return map;
|
|
750
978
|
}
|
|
@@ -752,33 +980,43 @@ export namespace TypiaGenerateWizard {
|
|
|
752
980
|
function getTransformedOutput(props: {
|
|
753
981
|
cwd: string;
|
|
754
982
|
entry: IInputFile;
|
|
983
|
+
identity: FileSystemIdentity.IIdentity;
|
|
755
984
|
outputByKey: Map<string, string>;
|
|
756
985
|
}): string | undefined {
|
|
757
986
|
const output = props.outputByKey.get(
|
|
758
|
-
projectFileKey(projectKey(props.cwd, props.entry.file)),
|
|
987
|
+
props.identity.projectFileKey(projectKey(props.cwd, props.entry.file)),
|
|
759
988
|
);
|
|
760
989
|
if (output !== undefined) {
|
|
761
990
|
return output;
|
|
762
991
|
}
|
|
763
992
|
|
|
993
|
+
const compilerFile: string = compilerInputPath(props.entry.file);
|
|
994
|
+
if (
|
|
995
|
+
props.identity.isSamePath(compilerFile, props.entry.file) === false &&
|
|
996
|
+
props.identity.contains(compilerFile, props.cwd)
|
|
997
|
+
) {
|
|
998
|
+
const compiled: string | undefined = props.outputByKey.get(
|
|
999
|
+
props.identity.projectFileKey(projectKey(props.cwd, compilerFile)),
|
|
1000
|
+
);
|
|
1001
|
+
if (compiled !== undefined) return compiled;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
764
1004
|
const real: string = resolveRealPath(props.entry.file);
|
|
765
1005
|
if (
|
|
766
|
-
isSamePath(real, props.entry.file) ||
|
|
767
|
-
|
|
1006
|
+
props.identity.isSamePath(real, props.entry.file) ||
|
|
1007
|
+
props.identity.contains(real, props.cwd) === false
|
|
768
1008
|
) {
|
|
769
1009
|
return undefined;
|
|
770
1010
|
}
|
|
771
|
-
return props.outputByKey.get(
|
|
1011
|
+
return props.outputByKey.get(
|
|
1012
|
+
props.identity.projectFileKey(projectKey(props.cwd, real)),
|
|
1013
|
+
);
|
|
772
1014
|
}
|
|
773
1015
|
|
|
774
1016
|
function projectKey(root: string, file: string): string {
|
|
775
1017
|
return path.relative(root, file).replace(/\\/g, "/");
|
|
776
1018
|
}
|
|
777
1019
|
|
|
778
|
-
function projectFileKey(file: string): string {
|
|
779
|
-
return isCaseSensitive() ? file : file.toLowerCase();
|
|
780
|
-
}
|
|
781
|
-
|
|
782
1020
|
function resolveRealPath(file: string): string {
|
|
783
1021
|
try {
|
|
784
1022
|
return fs.realpathSync(file);
|
|
@@ -787,26 +1025,60 @@ export namespace TypiaGenerateWizard {
|
|
|
787
1025
|
}
|
|
788
1026
|
}
|
|
789
1027
|
|
|
790
|
-
function
|
|
791
|
-
|
|
1028
|
+
function compilerInputPath(file: string): string {
|
|
1029
|
+
try {
|
|
1030
|
+
if (fs.lstatSync(file).isSymbolicLink()) {
|
|
1031
|
+
return path.join(
|
|
1032
|
+
resolveRealPath(path.dirname(file)),
|
|
1033
|
+
path.basename(file),
|
|
1034
|
+
);
|
|
1035
|
+
}
|
|
1036
|
+
} catch {
|
|
1037
|
+
return file;
|
|
1038
|
+
}
|
|
1039
|
+
return resolveRealPath(file);
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
async function optionalRealPath(file: string): Promise<string | undefined> {
|
|
1043
|
+
try {
|
|
1044
|
+
return await fs.promises.realpath(file);
|
|
1045
|
+
} catch (error) {
|
|
1046
|
+
if (isMissingFileError(error)) return undefined;
|
|
1047
|
+
throw new URIError(
|
|
1048
|
+
`Error on TypiaGenerateWizard.generate(): unable to resolve path ${file}: ${formatUnknownError(error)}`,
|
|
1049
|
+
);
|
|
1050
|
+
}
|
|
792
1051
|
}
|
|
793
1052
|
|
|
794
|
-
function
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
1053
|
+
async function resolveTraversalPath(file: string): Promise<string> {
|
|
1054
|
+
try {
|
|
1055
|
+
return await fs.promises.realpath(file);
|
|
1056
|
+
} catch (error) {
|
|
1057
|
+
throw new URIError(
|
|
1058
|
+
`Error on TypiaGenerateWizard.generate(): unable to resolve input path ${file}: ${formatUnknownError(error)}`,
|
|
1059
|
+
);
|
|
1060
|
+
}
|
|
801
1061
|
}
|
|
802
1062
|
|
|
803
|
-
function
|
|
804
|
-
|
|
805
|
-
|
|
1063
|
+
function ensurePhysicalInputContainment(props: {
|
|
1064
|
+
file: string;
|
|
1065
|
+
input: string;
|
|
1066
|
+
real: string;
|
|
1067
|
+
}): void {
|
|
1068
|
+
if (isPhysicalSameOrChildPath(props.real, props.input)) return;
|
|
1069
|
+
throw new URIError(
|
|
1070
|
+
`Error on TypiaGenerateWizard.generate(): input path resolves outside the input directory: ${props.file}.`,
|
|
1071
|
+
);
|
|
806
1072
|
}
|
|
807
1073
|
|
|
808
|
-
function
|
|
809
|
-
|
|
1074
|
+
function isPhysicalSameOrChildPath(file: string, directory: string): boolean {
|
|
1075
|
+
const relative: string = path.relative(directory, file);
|
|
1076
|
+
return (
|
|
1077
|
+
relative === "" ||
|
|
1078
|
+
(relative !== ".." &&
|
|
1079
|
+
relative.startsWith(`..${path.sep}`) === false &&
|
|
1080
|
+
path.isAbsolute(relative) === false)
|
|
1081
|
+
);
|
|
810
1082
|
}
|
|
811
1083
|
|
|
812
1084
|
function isMissingFileError(exp: unknown): boolean {
|
|
@@ -818,8 +1090,12 @@ export namespace TypiaGenerateWizard {
|
|
|
818
1090
|
);
|
|
819
1091
|
}
|
|
820
1092
|
|
|
821
|
-
|
|
822
|
-
|
|
1093
|
+
/**
|
|
1094
|
+
* Delegates to {@link FileSystemIdentity.identityKey}, which owns the rule and
|
|
1095
|
+
* carries the reasoning for reading the identity as a `bigint`.
|
|
1096
|
+
*/
|
|
1097
|
+
function fileIdentityKey(stat: fs.BigIntStats, realpath: string): string {
|
|
1098
|
+
return FileSystemIdentity.identityKey(stat, realpath);
|
|
823
1099
|
}
|
|
824
1100
|
|
|
825
1101
|
function formatDiagnostics(diagnostics: ITtscCompilerDiagnostic[]): string {
|
|
@@ -855,6 +1131,3 @@ export namespace TypiaGenerateWizard {
|
|
|
855
1131
|
return String(error);
|
|
856
1132
|
}
|
|
857
1133
|
}
|
|
858
|
-
|
|
859
|
-
const TS_PATTERN = /\.[cm]?tsx?$/;
|
|
860
|
-
const DTS_PATTERN = /\.d\.[cm]?tsx?$/;
|