@temporalio/core-bridge 1.13.2 → 1.14.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/Cargo.lock +135 -100
- package/Cargo.toml +3 -2
- package/{sdk-core/fsm/rustfsm_trait/LICENSE.txt → LICENSE} +5 -5
- package/README.md +0 -1
- package/bridge-macros/Cargo.toml +16 -0
- package/bridge-macros/src/derive_js_function.rs +126 -0
- package/bridge-macros/src/derive_tryfromjs.rs +138 -0
- package/bridge-macros/src/derive_tryintojs.rs +151 -0
- package/bridge-macros/src/lib.rs +42 -0
- package/lib/native.d.ts +13 -6
- package/package.json +6 -5
- package/releases/aarch64-apple-darwin/index.node +0 -0
- package/releases/aarch64-unknown-linux-gnu/index.node +0 -0
- package/releases/x86_64-apple-darwin/index.node +0 -0
- package/releases/x86_64-pc-windows-msvc/index.node +0 -0
- package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
- package/sdk-core/.cargo/config.toml +9 -3
- package/sdk-core/.github/workflows/per-pr.yml +42 -5
- package/sdk-core/AGENTS.md +17 -19
- package/sdk-core/Cargo.toml +6 -7
- package/sdk-core/README.md +12 -15
- package/sdk-core/arch_docs/diagrams/deps.svg +102 -0
- package/sdk-core/{client → crates/client}/Cargo.toml +7 -9
- package/sdk-core/{client → crates/client}/src/lib.rs +110 -159
- package/sdk-core/{client → crates/client}/src/metrics.rs +1 -1
- package/sdk-core/{client → crates/client}/src/raw.rs +73 -44
- package/sdk-core/crates/client/src/request_extensions.rs +40 -0
- package/sdk-core/{client → crates/client}/src/retry.rs +24 -17
- package/sdk-core/crates/client/src/worker/mod.rs +1468 -0
- package/sdk-core/{client → crates/client}/src/workflow_handle/mod.rs +4 -4
- package/sdk-core/{core-api → crates/common}/Cargo.toml +17 -8
- package/sdk-core/crates/common/protos/api_cloud_upstream/VERSION +1 -0
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/account/v1/message.proto +18 -0
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/cloudservice/v1/request_response.proto +38 -11
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/cloudservice/v1/service.proto +21 -4
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/operation/v1/message.proto +6 -6
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/sink/v1/message.proto +22 -0
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/create-release.yml +5 -0
- package/sdk-core/{core-api → crates/common}/src/envconfig.rs +2 -2
- package/sdk-core/{core-api → crates/common}/src/errors.rs +8 -1
- package/sdk-core/{fsm/rustfsm_trait/src/lib.rs → crates/common/src/fsm_trait.rs} +1 -27
- package/sdk-core/{core-api → crates/common}/src/lib.rs +24 -9
- package/sdk-core/{sdk-core-protos/src → crates/common/src/protos}/canned_histories.rs +1 -1
- package/sdk-core/{sdk-core-protos/src → crates/common/src/protos}/history_builder.rs +1 -1
- package/sdk-core/{sdk-core-protos/src → crates/common/src/protos}/history_info.rs +2 -2
- package/sdk-core/{sdk-core-protos/src/lib.rs → crates/common/src/protos/mod.rs} +18 -17
- package/sdk-core/{sdk-core-protos/src → crates/common/src/protos}/test_utils.rs +1 -1
- package/sdk-core/{core-api → crates/common}/src/telemetry/metrics.rs +447 -50
- package/sdk-core/{core-api → crates/common}/src/telemetry.rs +3 -1
- package/sdk-core/{core-api → crates/common}/src/worker.rs +112 -18
- package/sdk-core/crates/common/tests/worker_task_types_test.rs +129 -0
- package/sdk-core/crates/macros/Cargo.toml +23 -0
- package/sdk-core/{fsm/rustfsm_procmacro → crates/macros}/src/lib.rs +6 -11
- package/sdk-core/{sdk → crates/sdk}/Cargo.toml +10 -10
- package/sdk-core/{sdk → crates/sdk}/src/activity_context.rs +8 -6
- package/sdk-core/{sdk → crates/sdk}/src/interceptors.rs +1 -1
- package/sdk-core/{sdk → crates/sdk}/src/lib.rs +42 -37
- package/sdk-core/{sdk → crates/sdk}/src/workflow_context/options.rs +2 -2
- package/sdk-core/{sdk → crates/sdk}/src/workflow_context.rs +21 -19
- package/sdk-core/{sdk → crates/sdk}/src/workflow_future.rs +1 -1
- package/sdk-core/{core → crates/sdk-core}/Cargo.toml +32 -25
- package/sdk-core/{tests → crates/sdk-core/benches}/workflow_replay_bench.rs +10 -10
- package/sdk-core/crates/sdk-core/machine_coverage/ActivityMachine_Coverage.puml +32 -0
- package/sdk-core/crates/sdk-core/machine_coverage/CancelExternalMachine_Coverage.puml +9 -0
- package/sdk-core/crates/sdk-core/machine_coverage/CancelWorkflowMachine_Coverage.puml +6 -0
- package/sdk-core/crates/sdk-core/machine_coverage/ChildWorkflowMachine_Coverage.puml +27 -0
- package/sdk-core/crates/sdk-core/machine_coverage/CompleteWorkflowMachine_Coverage.puml +6 -0
- package/sdk-core/crates/sdk-core/machine_coverage/ContinueAsNewWorkflowMachine_Coverage.puml +6 -0
- package/sdk-core/crates/sdk-core/machine_coverage/FailWorkflowMachine_Coverage.puml +6 -0
- package/sdk-core/crates/sdk-core/machine_coverage/LocalActivityMachine_Coverage.puml +23 -0
- package/sdk-core/crates/sdk-core/machine_coverage/ModifyWorkflowPropertiesMachine_Coverage.puml +5 -0
- package/sdk-core/crates/sdk-core/machine_coverage/PatchMachine_Coverage.puml +8 -0
- package/sdk-core/crates/sdk-core/machine_coverage/SignalExternalMachine_Coverage.puml +12 -0
- package/sdk-core/crates/sdk-core/machine_coverage/TimerMachine_Coverage.puml +13 -0
- package/sdk-core/crates/sdk-core/machine_coverage/UpdateMachine_Coverage.puml +19 -0
- package/sdk-core/crates/sdk-core/machine_coverage/UpsertSearchAttributesMachine_Coverage.puml +5 -0
- package/sdk-core/crates/sdk-core/machine_coverage/WorkflowTaskMachine_Coverage.puml +11 -0
- package/sdk-core/{core → crates/sdk-core}/src/abstractions.rs +62 -6
- package/sdk-core/crates/sdk-core/src/antithesis.rs +60 -0
- package/sdk-core/{core → crates/sdk-core}/src/core_tests/activity_tasks.rs +36 -31
- package/sdk-core/{core → crates/sdk-core}/src/core_tests/mod.rs +12 -9
- package/sdk-core/{core → crates/sdk-core}/src/core_tests/queries.rs +24 -21
- package/sdk-core/{core → crates/sdk-core}/src/core_tests/replay_flag.rs +10 -8
- package/sdk-core/{core → crates/sdk-core}/src/core_tests/updates.rs +17 -15
- package/sdk-core/{core → crates/sdk-core}/src/core_tests/workers.rs +242 -17
- package/sdk-core/{core → crates/sdk-core}/src/core_tests/workflow_cancels.rs +1 -1
- package/sdk-core/{core → crates/sdk-core}/src/core_tests/workflow_tasks.rs +126 -39
- package/sdk-core/{core → crates/sdk-core}/src/debug_client.rs +1 -1
- package/sdk-core/{core → crates/sdk-core}/src/ephemeral_server/mod.rs +3 -3
- package/sdk-core/crates/sdk-core/src/histfetch.rs +33 -0
- package/sdk-core/{core → crates/sdk-core}/src/internal_flags.rs +4 -3
- package/sdk-core/{core → crates/sdk-core}/src/lib.rs +85 -43
- package/sdk-core/{core → crates/sdk-core}/src/pollers/mod.rs +8 -6
- package/sdk-core/{core → crates/sdk-core}/src/pollers/poll_buffer.rs +51 -16
- package/sdk-core/{core → crates/sdk-core}/src/protosext/mod.rs +1 -1
- package/sdk-core/{core → crates/sdk-core}/src/protosext/protocol_messages.rs +1 -1
- package/sdk-core/{core → crates/sdk-core}/src/replay/mod.rs +14 -11
- package/sdk-core/{core → crates/sdk-core}/src/retry_logic.rs +19 -1
- package/sdk-core/{core → crates/sdk-core}/src/telemetry/log_export.rs +2 -2
- package/sdk-core/{core → crates/sdk-core}/src/telemetry/metrics.rs +80 -34
- package/sdk-core/{core → crates/sdk-core}/src/telemetry/mod.rs +4 -4
- package/sdk-core/{core → crates/sdk-core}/src/telemetry/otel.rs +1 -1
- package/sdk-core/{core → crates/sdk-core}/src/telemetry/prometheus_meter.rs +13 -13
- package/sdk-core/{core → crates/sdk-core}/src/telemetry/prometheus_server.rs +2 -2
- package/sdk-core/{core → crates/sdk-core}/src/test_help/integ_helpers.rs +127 -40
- package/sdk-core/{core → crates/sdk-core}/src/test_help/unit_helpers.rs +13 -11
- package/sdk-core/{core → crates/sdk-core}/src/worker/activities/activity_heartbeat_manager.rs +2 -2
- package/sdk-core/{core → crates/sdk-core}/src/worker/activities/local_activities.rs +14 -12
- package/sdk-core/{core → crates/sdk-core}/src/worker/activities.rs +21 -12
- package/sdk-core/{core → crates/sdk-core}/src/worker/client/mocks.rs +25 -12
- package/sdk-core/{core → crates/sdk-core}/src/worker/client.rs +164 -71
- package/sdk-core/crates/sdk-core/src/worker/heartbeat.rs +246 -0
- package/sdk-core/crates/sdk-core/src/worker/mod.rs +1462 -0
- package/sdk-core/{core → crates/sdk-core}/src/worker/nexus.rs +15 -14
- package/sdk-core/{core → crates/sdk-core}/src/worker/slot_provider.rs +12 -13
- package/sdk-core/{core → crates/sdk-core}/src/worker/tuner/fixed_size.rs +5 -1
- package/sdk-core/{core → crates/sdk-core}/src/worker/tuner/resource_based.rs +453 -57
- package/sdk-core/{core → crates/sdk-core}/src/worker/tuner.rs +21 -4
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/driven_workflow.rs +1 -1
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/history_update.rs +2 -2
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/activity_state_machine.rs +147 -37
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/cancel_external_state_machine.rs +8 -9
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/cancel_nexus_op_state_machine.rs +14 -12
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/cancel_workflow_state_machine.rs +6 -7
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/child_workflow_state_machine.rs +31 -37
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/complete_workflow_state_machine.rs +13 -8
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +6 -7
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/fail_workflow_state_machine.rs +6 -7
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/local_activity_state_machine.rs +33 -30
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/mod.rs +22 -17
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +4 -3
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/nexus_operation_state_machine.rs +20 -22
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/patch_state_machine.rs +12 -11
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/signal_external_state_machine.rs +9 -12
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/timer_state_machine.rs +26 -13
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/transition_coverage.rs +1 -2
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/update_state_machine.rs +19 -13
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +20 -18
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/workflow_machines/local_acts.rs +1 -1
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/workflow_machines.rs +61 -70
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/workflow_task_state_machine.rs +13 -15
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/managed_run.rs +55 -37
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/mod.rs +166 -60
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/run_cache.rs +10 -7
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/wft_extraction.rs +4 -2
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/wft_poller.rs +15 -4
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/workflow_stream.rs +30 -16
- package/sdk-core/{tests → crates/sdk-core/tests}/c_bridge_smoke_test.c +1 -1
- package/sdk-core/{tests → crates/sdk-core/tests}/cloud_tests.rs +1 -1
- package/sdk-core/crates/sdk-core/tests/common/fake_grpc_server.rs +106 -0
- package/sdk-core/{tests → crates/sdk-core/tests}/common/http_proxy.rs +1 -1
- package/sdk-core/{tests → crates/sdk-core/tests}/common/mod.rs +93 -74
- package/sdk-core/{tests → crates/sdk-core/tests}/common/workflows.rs +4 -3
- package/sdk-core/crates/sdk-core/tests/fsm_procmacro.rs +6 -0
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/dupe_transitions_fail.rs +1 -3
- package/sdk-core/crates/sdk-core/tests/fsm_trybuild/dupe_transitions_fail.stderr +12 -0
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/dynamic_dest_pass.rs +2 -4
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/forgot_name_fail.rs +1 -3
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/forgot_name_fail.stderr +4 -4
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/handler_arg_pass.rs +2 -4
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/handler_pass.rs +2 -4
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/medium_complex_pass.rs +2 -4
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/no_handle_conversions_require_into_fail.rs +2 -4
- package/sdk-core/crates/sdk-core/tests/fsm_trybuild/no_handle_conversions_require_into_fail.stderr +15 -0
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/simple_pass.rs +2 -4
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/struct_event_variant_fail.rs +1 -3
- package/sdk-core/crates/sdk-core/tests/fsm_trybuild/struct_event_variant_fail.stderr +5 -0
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/tuple_more_item_event_variant_fail.rs +1 -3
- package/sdk-core/crates/sdk-core/tests/fsm_trybuild/tuple_more_item_event_variant_fail.stderr +5 -0
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/tuple_zero_item_event_variant_fail.rs +1 -3
- package/sdk-core/crates/sdk-core/tests/fsm_trybuild/tuple_zero_item_event_variant_fail.stderr +5 -0
- package/sdk-core/{tests → crates/sdk-core/tests}/global_metric_tests.rs +14 -15
- package/sdk-core/{tests → crates/sdk-core/tests/heavy_tests}/fuzzy_workflow.rs +3 -3
- package/sdk-core/{tests → crates/sdk-core/tests}/heavy_tests.rs +19 -12
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/activity_functions.rs +1 -1
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/client_tests.rs +16 -111
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/ephemeral_server_tests.rs +5 -6
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/heartbeat_tests.rs +23 -19
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/metrics_tests.rs +134 -60
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/pagination_tests.rs +4 -4
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/polling_tests.rs +37 -36
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/queries_tests.rs +12 -10
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/update_tests.rs +41 -29
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/visibility_tests.rs +24 -19
- package/sdk-core/crates/sdk-core/tests/integ_tests/worker_heartbeat_tests.rs +1061 -0
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/worker_tests.rs +113 -51
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/worker_versioning_tests.rs +19 -17
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/activities.rs +35 -30
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/appdata_propagation.rs +3 -3
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/cancel_external.rs +14 -9
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/cancel_wf.rs +13 -8
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/child_workflows.rs +48 -35
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/continue_as_new.rs +14 -9
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/determinism.rs +24 -15
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/eager.rs +9 -4
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/local_activities.rs +47 -47
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/modify_wf_properties.rs +16 -11
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/nexus.rs +51 -23
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/patches.rs +22 -10
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/replay.rs +19 -17
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/resets.rs +14 -5
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/signals.rs +24 -15
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/stickyness.rs +8 -6
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/timers.rs +28 -18
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/upsert_search_attrs.rs +18 -13
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests.rs +46 -41
- package/sdk-core/{tests → crates/sdk-core/tests}/main.rs +15 -9
- package/sdk-core/{tests → crates/sdk-core/tests}/manual_tests.rs +20 -14
- package/sdk-core/{tests → crates/sdk-core/tests}/runner.rs +2 -2
- package/sdk-core/{tests → crates/sdk-core/tests}/shared_tests/mod.rs +10 -5
- package/sdk-core/{tests → crates/sdk-core/tests}/shared_tests/priority.rs +5 -5
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/Cargo.toml +13 -10
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/include/temporal-sdk-core-c-bridge.h +32 -23
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/client.rs +55 -32
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/envconfig.rs +1 -1
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/lib.rs +1 -1
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/metric.rs +1 -1
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/runtime.rs +24 -9
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/testing.rs +1 -1
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/tests/context.rs +11 -10
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/tests/mod.rs +7 -7
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/tests/utils.rs +3 -4
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/worker.rs +111 -58
- package/sdk-core/docker-cgroup-tests.sh +24 -0
- package/sdk-core/{docker → etc/docker}/docker-compose-ci.yaml +9 -9
- package/sdk-core/{docker → etc/docker}/docker-compose-telem.yaml +11 -11
- package/sdk-core/{docker → etc/docker}/docker-compose.yaml +8 -8
- package/sdk-core/{integ-with-otel.sh → etc/integ-with-otel.sh} +1 -1
- package/sdk-core/etc/regen-depgraph.sh +2 -2
- package/src/client.rs +24 -33
- package/src/helpers/try_from_js.rs +1 -1
- package/src/logs.rs +1 -1
- package/src/metrics.rs +3 -3
- package/src/runtime.rs +42 -28
- package/src/testing.rs +3 -3
- package/src/worker.rs +70 -36
- package/ts/native.ts +13 -6
- package/LICENSE.md +0 -23
- package/sdk-core/client/src/worker_registry/mod.rs +0 -282
- package/sdk-core/core/src/worker/heartbeat.rs +0 -230
- package/sdk-core/core/src/worker/mod.rs +0 -990
- package/sdk-core/etc/deps.svg +0 -162
- package/sdk-core/fsm/Cargo.toml +0 -21
- package/sdk-core/fsm/README.md +0 -3
- package/sdk-core/fsm/rustfsm_procmacro/Cargo.toml +0 -27
- package/sdk-core/fsm/rustfsm_procmacro/LICENSE.txt +0 -21
- package/sdk-core/fsm/rustfsm_procmacro/tests/progress.rs +0 -8
- package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/dupe_transitions_fail.stderr +0 -12
- package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +0 -15
- package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/struct_event_variant_fail.stderr +0 -5
- package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_more_item_event_variant_fail.stderr +0 -5
- package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_zero_item_event_variant_fail.stderr +0 -5
- package/sdk-core/fsm/rustfsm_trait/Cargo.toml +0 -14
- package/sdk-core/fsm/src/lib.rs +0 -2
- package/sdk-core/sdk-core-protos/Cargo.toml +0 -37
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/VERSION +0 -1
- /package/sdk-core/{client → crates/client}/src/callback_based.rs +0 -0
- /package/sdk-core/{client → crates/client}/src/proxy.rs +0 -0
- /package/sdk-core/{client → crates/client}/src/replaceable.rs +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/build.rs +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/.github/workflows/build.yaml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/.github/workflows/push-to-buf.yml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/CODEOWNERS +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/LICENSE +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/Makefile +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/README.md +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/buf.gen.yaml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/buf.lock +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/buf.yaml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/connectivityrule/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/identity/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/namespace/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/nexus/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/region/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/resource/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/usage/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/CODEOWNERS +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/ci.yml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/publish-docs.yml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/push-to-buf.yml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/trigger-api-go-delete-release.yml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/trigger-api-go-publish-release.yml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/trigger-api-go-update.yml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/LICENSE +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/Makefile +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/README.md +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/api-linter.yaml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/buf.gen.yaml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/buf.lock +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/buf.yaml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/api/annotations.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/api/http.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/any.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/descriptor.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/duration.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/empty.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/struct.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/timestamp.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/wrappers.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/openapi/openapiv2.json +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/openapi/openapiv3.yaml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/openapi/payload_description.txt +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/activity/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/batch/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/command/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/common/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/deployment/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/batch_operation.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/command_type.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/common.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/deployment.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/event_type.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/namespace.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/nexus.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/query.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/reset.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/schedule.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/update.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/workflow.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/errordetails/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/export/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/failure/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/filter/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/history/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/namespace/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/nexus/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/protocol/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/query/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/replication/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/rules/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/schedule/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/sdk/v1/enhanced_stack_trace.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/sdk/v1/task_complete_metadata.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/sdk/v1/user_metadata.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/sdk/v1/worker_config.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/sdk/v1/workflow_metadata.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/update/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/version/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/worker/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/workflow/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/google/rpc/status.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/grpc/health/v1/health.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/activity_result/activity_result.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/activity_task/activity_task.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/child_workflow/child_workflow.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/common/common.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/core_interface.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/external_data/external_data.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/nexus/nexus.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/workflow_completion/workflow_completion.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/testsrv_upstream/Makefile +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/testsrv_upstream/api-linter.yaml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/testsrv_upstream/buf.yaml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/testsrv_upstream/temporal/api/testservice/v1/request_response.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/testsrv_upstream/temporal/api/testservice/v1/service.proto +0 -0
- /package/sdk-core/{sdk-core-protos/src → crates/common/src/protos}/constants.rs +0 -0
- /package/sdk-core/{sdk-core-protos/src → crates/common/src/protos}/task_token.rs +0 -0
- /package/sdk-core/{sdk-core-protos/src → crates/common/src/protos}/utilities.rs +0 -0
- /package/sdk-core/{fsm → crates/macros}/LICENSE.txt +0 -0
- /package/sdk-core/{sdk → crates/sdk}/src/app_data.rs +0 -0
- /package/sdk-core/{core → crates/sdk-core}/src/abstractions/take_cell.rs +0 -0
- /package/sdk-core/{core → crates/sdk-core}/src/test_help/mod.rs +0 -0
- /package/sdk-core/{core → crates/sdk-core}/src/worker/slot_supplier.rs +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/ends_empty_wft_complete.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/evict_while_la_running_no_interference-16_history.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/evict_while_la_running_no_interference-23_history.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/evict_while_la_running_no_interference-85_history.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/fail_wf_task.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/long_local_activity_with_update-0_history.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/long_local_activity_with_update-1_history.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/long_local_activity_with_update-2_history.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/long_local_activity_with_update-3_history.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/old_change_marker_format.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/timer_workflow_history.bin +0 -0
- /package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/priority.rs +0 -0
- /package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/build.rs +0 -0
- /package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/random.rs +0 -0
- /package/sdk-core/{cargo-tokio-console.sh → etc/cargo-tokio-console.sh} +0 -0
package/Cargo.lock
CHANGED
|
@@ -159,6 +159,31 @@ version = "2.9.1"
|
|
|
159
159
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
160
160
|
checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967"
|
|
161
161
|
|
|
162
|
+
[[package]]
|
|
163
|
+
name = "bon"
|
|
164
|
+
version = "3.8.1"
|
|
165
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
166
|
+
checksum = "ebeb9aaf9329dff6ceb65c689ca3db33dbf15f324909c60e4e5eef5701ce31b1"
|
|
167
|
+
dependencies = [
|
|
168
|
+
"bon-macros",
|
|
169
|
+
"rustversion",
|
|
170
|
+
]
|
|
171
|
+
|
|
172
|
+
[[package]]
|
|
173
|
+
name = "bon-macros"
|
|
174
|
+
version = "3.8.1"
|
|
175
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
176
|
+
checksum = "77e9d642a7e3a318e37c2c9427b5a6a48aa1ad55dcd986f3034ab2239045a645"
|
|
177
|
+
dependencies = [
|
|
178
|
+
"darling 0.21.3",
|
|
179
|
+
"ident_case",
|
|
180
|
+
"prettyplease",
|
|
181
|
+
"proc-macro2",
|
|
182
|
+
"quote",
|
|
183
|
+
"rustversion",
|
|
184
|
+
"syn",
|
|
185
|
+
]
|
|
186
|
+
|
|
162
187
|
[[package]]
|
|
163
188
|
name = "bridge-macros"
|
|
164
189
|
version = "0.1.0"
|
|
@@ -287,8 +312,18 @@ version = "0.20.11"
|
|
|
287
312
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
288
313
|
checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee"
|
|
289
314
|
dependencies = [
|
|
290
|
-
"darling_core",
|
|
291
|
-
"darling_macro",
|
|
315
|
+
"darling_core 0.20.11",
|
|
316
|
+
"darling_macro 0.20.11",
|
|
317
|
+
]
|
|
318
|
+
|
|
319
|
+
[[package]]
|
|
320
|
+
name = "darling"
|
|
321
|
+
version = "0.21.3"
|
|
322
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
323
|
+
checksum = "9cdf337090841a411e2a7f3deb9187445851f91b309c0c0a29e05f74a00a48c0"
|
|
324
|
+
dependencies = [
|
|
325
|
+
"darling_core 0.21.3",
|
|
326
|
+
"darling_macro 0.21.3",
|
|
292
327
|
]
|
|
293
328
|
|
|
294
329
|
[[package]]
|
|
@@ -305,13 +340,38 @@ dependencies = [
|
|
|
305
340
|
"syn",
|
|
306
341
|
]
|
|
307
342
|
|
|
343
|
+
[[package]]
|
|
344
|
+
name = "darling_core"
|
|
345
|
+
version = "0.21.3"
|
|
346
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
347
|
+
checksum = "1247195ecd7e3c85f83c8d2a366e4210d588e802133e1e355180a9870b517ea4"
|
|
348
|
+
dependencies = [
|
|
349
|
+
"fnv",
|
|
350
|
+
"ident_case",
|
|
351
|
+
"proc-macro2",
|
|
352
|
+
"quote",
|
|
353
|
+
"strsim",
|
|
354
|
+
"syn",
|
|
355
|
+
]
|
|
356
|
+
|
|
308
357
|
[[package]]
|
|
309
358
|
name = "darling_macro"
|
|
310
359
|
version = "0.20.11"
|
|
311
360
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
312
361
|
checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead"
|
|
313
362
|
dependencies = [
|
|
314
|
-
"darling_core",
|
|
363
|
+
"darling_core 0.20.11",
|
|
364
|
+
"quote",
|
|
365
|
+
"syn",
|
|
366
|
+
]
|
|
367
|
+
|
|
368
|
+
[[package]]
|
|
369
|
+
name = "darling_macro"
|
|
370
|
+
version = "0.21.3"
|
|
371
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
372
|
+
checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81"
|
|
373
|
+
dependencies = [
|
|
374
|
+
"darling_core 0.21.3",
|
|
315
375
|
"quote",
|
|
316
376
|
"syn",
|
|
317
377
|
]
|
|
@@ -356,7 +416,7 @@ version = "0.20.2"
|
|
|
356
416
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
357
417
|
checksum = "2d5bcf7b024d6835cfb3d473887cd966994907effbe9227e8c8219824d06c4e8"
|
|
358
418
|
dependencies = [
|
|
359
|
-
"darling",
|
|
419
|
+
"darling 0.20.11",
|
|
360
420
|
"proc-macro2",
|
|
361
421
|
"quote",
|
|
362
422
|
"syn",
|
|
@@ -2048,29 +2108,6 @@ version = "2.1.1"
|
|
|
2048
2108
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
2049
2109
|
checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d"
|
|
2050
2110
|
|
|
2051
|
-
[[package]]
|
|
2052
|
-
name = "rustfsm"
|
|
2053
|
-
version = "0.1.0"
|
|
2054
|
-
dependencies = [
|
|
2055
|
-
"rustfsm_procmacro",
|
|
2056
|
-
"rustfsm_trait",
|
|
2057
|
-
]
|
|
2058
|
-
|
|
2059
|
-
[[package]]
|
|
2060
|
-
name = "rustfsm_procmacro"
|
|
2061
|
-
version = "0.1.0"
|
|
2062
|
-
dependencies = [
|
|
2063
|
-
"derive_more",
|
|
2064
|
-
"proc-macro2",
|
|
2065
|
-
"quote",
|
|
2066
|
-
"rustfsm_trait",
|
|
2067
|
-
"syn",
|
|
2068
|
-
]
|
|
2069
|
-
|
|
2070
|
-
[[package]]
|
|
2071
|
-
name = "rustfsm_trait"
|
|
2072
|
-
version = "0.1.0"
|
|
2073
|
-
|
|
2074
2111
|
[[package]]
|
|
2075
2112
|
name = "rustix"
|
|
2076
2113
|
version = "1.0.8"
|
|
@@ -2412,15 +2449,42 @@ dependencies = [
|
|
|
2412
2449
|
]
|
|
2413
2450
|
|
|
2414
2451
|
[[package]]
|
|
2415
|
-
name = "temporal-
|
|
2452
|
+
name = "temporal-sdk-typescript-bridge"
|
|
2453
|
+
version = "0.1.0"
|
|
2454
|
+
dependencies = [
|
|
2455
|
+
"anyhow",
|
|
2456
|
+
"async-trait",
|
|
2457
|
+
"bridge-macros",
|
|
2458
|
+
"futures",
|
|
2459
|
+
"neon",
|
|
2460
|
+
"opentelemetry",
|
|
2461
|
+
"os_pipe",
|
|
2462
|
+
"parking_lot",
|
|
2463
|
+
"prost",
|
|
2464
|
+
"prost-types",
|
|
2465
|
+
"serde",
|
|
2466
|
+
"serde_json",
|
|
2467
|
+
"temporalio-client",
|
|
2468
|
+
"temporalio-common",
|
|
2469
|
+
"temporalio-sdk-core",
|
|
2470
|
+
"thiserror 2.0.14",
|
|
2471
|
+
"tokio",
|
|
2472
|
+
"tokio-stream",
|
|
2473
|
+
"tonic",
|
|
2474
|
+
"tracing",
|
|
2475
|
+
"tracing-subscriber",
|
|
2476
|
+
]
|
|
2477
|
+
|
|
2478
|
+
[[package]]
|
|
2479
|
+
name = "temporalio-client"
|
|
2416
2480
|
version = "0.1.0"
|
|
2417
2481
|
dependencies = [
|
|
2418
2482
|
"anyhow",
|
|
2419
2483
|
"async-trait",
|
|
2420
2484
|
"backoff",
|
|
2421
2485
|
"base64",
|
|
2486
|
+
"bon",
|
|
2422
2487
|
"bytes",
|
|
2423
|
-
"derive_builder",
|
|
2424
2488
|
"derive_more",
|
|
2425
2489
|
"dyn-clone",
|
|
2426
2490
|
"futures-retry",
|
|
@@ -2430,9 +2494,9 @@ dependencies = [
|
|
|
2430
2494
|
"hyper",
|
|
2431
2495
|
"hyper-util",
|
|
2432
2496
|
"parking_lot",
|
|
2497
|
+
"rand 0.9.2",
|
|
2433
2498
|
"slotmap",
|
|
2434
|
-
"
|
|
2435
|
-
"temporal-sdk-core-protos",
|
|
2499
|
+
"temporalio-common",
|
|
2436
2500
|
"thiserror 2.0.14",
|
|
2437
2501
|
"tokio",
|
|
2438
2502
|
"tonic",
|
|
@@ -2443,7 +2507,43 @@ dependencies = [
|
|
|
2443
2507
|
]
|
|
2444
2508
|
|
|
2445
2509
|
[[package]]
|
|
2446
|
-
name = "
|
|
2510
|
+
name = "temporalio-common"
|
|
2511
|
+
version = "0.1.0"
|
|
2512
|
+
dependencies = [
|
|
2513
|
+
"anyhow",
|
|
2514
|
+
"async-trait",
|
|
2515
|
+
"base64",
|
|
2516
|
+
"derive_builder",
|
|
2517
|
+
"derive_more",
|
|
2518
|
+
"opentelemetry",
|
|
2519
|
+
"prost",
|
|
2520
|
+
"prost-wkt",
|
|
2521
|
+
"prost-wkt-types",
|
|
2522
|
+
"rand 0.9.2",
|
|
2523
|
+
"serde",
|
|
2524
|
+
"serde_json",
|
|
2525
|
+
"thiserror 2.0.14",
|
|
2526
|
+
"tonic",
|
|
2527
|
+
"tonic-prost",
|
|
2528
|
+
"tonic-prost-build",
|
|
2529
|
+
"tracing",
|
|
2530
|
+
"tracing-core",
|
|
2531
|
+
"url",
|
|
2532
|
+
"uuid",
|
|
2533
|
+
]
|
|
2534
|
+
|
|
2535
|
+
[[package]]
|
|
2536
|
+
name = "temporalio-macros"
|
|
2537
|
+
version = "0.1.0"
|
|
2538
|
+
dependencies = [
|
|
2539
|
+
"derive_more",
|
|
2540
|
+
"proc-macro2",
|
|
2541
|
+
"quote",
|
|
2542
|
+
"syn",
|
|
2543
|
+
]
|
|
2544
|
+
|
|
2545
|
+
[[package]]
|
|
2546
|
+
name = "temporalio-sdk-core"
|
|
2447
2547
|
version = "0.1.0"
|
|
2448
2548
|
dependencies = [
|
|
2449
2549
|
"anyhow",
|
|
@@ -2479,16 +2579,15 @@ dependencies = [
|
|
|
2479
2579
|
"rand 0.9.2",
|
|
2480
2580
|
"reqwest",
|
|
2481
2581
|
"ringbuf",
|
|
2482
|
-
"rustfsm",
|
|
2483
2582
|
"serde",
|
|
2484
2583
|
"serde_json",
|
|
2485
2584
|
"siphasher",
|
|
2486
2585
|
"slotmap",
|
|
2487
2586
|
"sysinfo",
|
|
2488
2587
|
"tar",
|
|
2489
|
-
"
|
|
2490
|
-
"
|
|
2491
|
-
"
|
|
2588
|
+
"temporalio-client",
|
|
2589
|
+
"temporalio-common",
|
|
2590
|
+
"temporalio-macros",
|
|
2492
2591
|
"thiserror 2.0.14",
|
|
2493
2592
|
"tokio",
|
|
2494
2593
|
"tokio-stream",
|
|
@@ -2501,70 +2600,6 @@ dependencies = [
|
|
|
2501
2600
|
"zip",
|
|
2502
2601
|
]
|
|
2503
2602
|
|
|
2504
|
-
[[package]]
|
|
2505
|
-
name = "temporal-sdk-core-api"
|
|
2506
|
-
version = "0.1.0"
|
|
2507
|
-
dependencies = [
|
|
2508
|
-
"async-trait",
|
|
2509
|
-
"derive_builder",
|
|
2510
|
-
"derive_more",
|
|
2511
|
-
"opentelemetry",
|
|
2512
|
-
"prost",
|
|
2513
|
-
"serde_json",
|
|
2514
|
-
"temporal-sdk-core-protos",
|
|
2515
|
-
"thiserror 2.0.14",
|
|
2516
|
-
"tonic",
|
|
2517
|
-
"tracing",
|
|
2518
|
-
"tracing-core",
|
|
2519
|
-
"url",
|
|
2520
|
-
]
|
|
2521
|
-
|
|
2522
|
-
[[package]]
|
|
2523
|
-
name = "temporal-sdk-core-protos"
|
|
2524
|
-
version = "0.1.0"
|
|
2525
|
-
dependencies = [
|
|
2526
|
-
"anyhow",
|
|
2527
|
-
"base64",
|
|
2528
|
-
"derive_more",
|
|
2529
|
-
"prost",
|
|
2530
|
-
"prost-wkt",
|
|
2531
|
-
"prost-wkt-types",
|
|
2532
|
-
"rand 0.9.2",
|
|
2533
|
-
"serde",
|
|
2534
|
-
"serde_json",
|
|
2535
|
-
"thiserror 2.0.14",
|
|
2536
|
-
"tonic",
|
|
2537
|
-
"tonic-prost",
|
|
2538
|
-
"tonic-prost-build",
|
|
2539
|
-
"uuid",
|
|
2540
|
-
]
|
|
2541
|
-
|
|
2542
|
-
[[package]]
|
|
2543
|
-
name = "temporal-sdk-typescript-bridge"
|
|
2544
|
-
version = "0.1.0"
|
|
2545
|
-
dependencies = [
|
|
2546
|
-
"anyhow",
|
|
2547
|
-
"async-trait",
|
|
2548
|
-
"bridge-macros",
|
|
2549
|
-
"futures",
|
|
2550
|
-
"neon",
|
|
2551
|
-
"opentelemetry",
|
|
2552
|
-
"os_pipe",
|
|
2553
|
-
"parking_lot",
|
|
2554
|
-
"prost",
|
|
2555
|
-
"prost-types",
|
|
2556
|
-
"serde",
|
|
2557
|
-
"serde_json",
|
|
2558
|
-
"temporal-client",
|
|
2559
|
-
"temporal-sdk-core",
|
|
2560
|
-
"thiserror 2.0.14",
|
|
2561
|
-
"tokio",
|
|
2562
|
-
"tokio-stream",
|
|
2563
|
-
"tonic",
|
|
2564
|
-
"tracing",
|
|
2565
|
-
"tracing-subscriber",
|
|
2566
|
-
]
|
|
2567
|
-
|
|
2568
2603
|
[[package]]
|
|
2569
2604
|
name = "termtree"
|
|
2570
2605
|
version = "0.5.1"
|
package/Cargo.toml
CHANGED
|
@@ -35,10 +35,11 @@ prost = "0.14"
|
|
|
35
35
|
prost-types = "0.14"
|
|
36
36
|
serde = { version = "1.0", features = ["derive"] }
|
|
37
37
|
serde_json = "1.0"
|
|
38
|
-
|
|
38
|
+
temporalio-sdk-core = { version = "*", path = "./sdk-core/crates/sdk-core", features = [
|
|
39
39
|
"ephemeral-server",
|
|
40
40
|
] }
|
|
41
|
-
|
|
41
|
+
temporalio-client = { version = "*", path = "./sdk-core/crates/client" }
|
|
42
|
+
temporalio-common = { version = "*", path = "./sdk-core/crates/common" }
|
|
42
43
|
thiserror = "2"
|
|
43
44
|
tokio = "1.13"
|
|
44
45
|
tokio-stream = "0.1"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2021 Temporal Technologies
|
|
3
|
+
Copyright (c) 2021-2025 Temporal Technologies Inc. All rights reserved.
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
9
9
|
copies of the Software, and to permit persons to whom the Software is
|
|
10
10
|
furnished to do so, subject to the following conditions:
|
|
11
11
|
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
copies or substantial portions of the Software.
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
14
|
|
|
15
15
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
16
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
17
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
SOFTWARE.
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@temporalio/core-bridge)
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
Part of [Temporal](https://temporal.io)'s [TypeScript SDK](https://docs.temporal.io/typescript/introduction/).
|
|
7
6
|
|
|
8
7
|
> [!CAUTION]
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "bridge-macros"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
edition = "2024"
|
|
5
|
+
|
|
6
|
+
[lib]
|
|
7
|
+
proc-macro = true
|
|
8
|
+
|
|
9
|
+
[dependencies]
|
|
10
|
+
syn = { version = "2.0", features = ["full", "extra-traits"] }
|
|
11
|
+
quote = "1.0"
|
|
12
|
+
proc-macro2 = "1.0"
|
|
13
|
+
convert_case = "0.6"
|
|
14
|
+
|
|
15
|
+
[dev-dependencies]
|
|
16
|
+
temporal-sdk-typescript-bridge = { path = ".." }
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
use quote::format_ident;
|
|
2
|
+
use quote::quote;
|
|
3
|
+
use syn::GenericArgument;
|
|
4
|
+
use syn::Pat;
|
|
5
|
+
use syn::PathArguments;
|
|
6
|
+
use syn::Type;
|
|
7
|
+
use syn::{FnArg, ItemFn, PatType, ReturnType, parse_macro_input};
|
|
8
|
+
|
|
9
|
+
pub fn js_function_impl(
|
|
10
|
+
_attr: proc_macro::TokenStream,
|
|
11
|
+
item: proc_macro::TokenStream,
|
|
12
|
+
) -> proc_macro::TokenStream {
|
|
13
|
+
let input = parse_macro_input!(item as ItemFn);
|
|
14
|
+
|
|
15
|
+
let vis = &input.vis;
|
|
16
|
+
let fn_name = &input.sig.ident;
|
|
17
|
+
let generics = &input.sig.generics; // Is this still pertinent?
|
|
18
|
+
let args = &input.sig.inputs;
|
|
19
|
+
let return_type = &input.sig.output; // Can we avoid in some cases?
|
|
20
|
+
let fn_block = &input.block;
|
|
21
|
+
let attrs = &input.attrs;
|
|
22
|
+
|
|
23
|
+
let fn_impl_name = format_ident!("{}_impl", fn_name);
|
|
24
|
+
|
|
25
|
+
// Extract function arguments
|
|
26
|
+
let args = args
|
|
27
|
+
.iter()
|
|
28
|
+
.filter_map(|arg| {
|
|
29
|
+
if let FnArg::Typed(PatType { pat, ty, .. }) = arg {
|
|
30
|
+
if let Pat::Ident(pat_ident) = &**pat {
|
|
31
|
+
Some((pat_ident.ident.clone(), (*ty).clone()))
|
|
32
|
+
} else {
|
|
33
|
+
None
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
None
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
.collect::<Vec<_>>();
|
|
40
|
+
|
|
41
|
+
// Extract return type
|
|
42
|
+
let (result_return_type, inner_return_type) = match return_type {
|
|
43
|
+
ReturnType::Type(_, ty) => match extract_bridge_result_type(ty) {
|
|
44
|
+
Some(inner_type) => (ty, inner_type),
|
|
45
|
+
None => panic!("Return type must be a BridgeResult"),
|
|
46
|
+
},
|
|
47
|
+
ReturnType::Default => panic!("Return type must be a BridgeResult"),
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// Generate argument conversions
|
|
51
|
+
let arg_conversions = args.iter().enumerate().map(|(i, (name, ty))| {
|
|
52
|
+
quote! {
|
|
53
|
+
use crate::helpers::*;
|
|
54
|
+
let #name = cx.argument_into::<#ty>(#i).field(format!("fn {}", stringify!(#fn_name)).as_str()).into_throw(&mut cx)?;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// Generate implementation function arguments
|
|
59
|
+
let impl_args = args.iter().map(|(name, ty)| {
|
|
60
|
+
quote! { #name: #ty }
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// Generate argument names for impl function call
|
|
64
|
+
let arg_names = args.iter().map(|(name, _)| quote! { #name });
|
|
65
|
+
|
|
66
|
+
let expanded = if args.is_empty() {
|
|
67
|
+
// No arguments case
|
|
68
|
+
quote! {
|
|
69
|
+
// Bridge function
|
|
70
|
+
#[allow(clippy::significant_drop_tightening, clippy::unnecessary_wraps)]
|
|
71
|
+
#vis fn #fn_name #generics(
|
|
72
|
+
mut cx: FunctionContext #generics
|
|
73
|
+
) -> JsResult<<#inner_return_type as crate::helpers::TryIntoJs>::Output> {
|
|
74
|
+
let result = #fn_impl_name().into_throw(&mut cx)?;
|
|
75
|
+
result.try_into_js(&mut cx)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Implementation function
|
|
79
|
+
#(#attrs)*
|
|
80
|
+
#[allow(clippy::unnecessary_wraps)]
|
|
81
|
+
#vis fn #fn_impl_name #generics() -> #result_return_type {
|
|
82
|
+
#fn_block
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
// With arguments case
|
|
87
|
+
quote! {
|
|
88
|
+
// Bridge function
|
|
89
|
+
#[allow(clippy::significant_drop_tightening, clippy::unnecessary_wraps)]
|
|
90
|
+
#vis fn #fn_name #generics(
|
|
91
|
+
mut cx: FunctionContext #generics
|
|
92
|
+
) -> JsResult<<#inner_return_type as crate::helpers::TryIntoJs>::Output> {
|
|
93
|
+
#(#arg_conversions)*
|
|
94
|
+
|
|
95
|
+
let result = #fn_impl_name(#(#arg_names),*).into_throw(&mut cx)?;
|
|
96
|
+
result.try_into_js(&mut cx)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Implementation function
|
|
100
|
+
#(#attrs)*
|
|
101
|
+
#[allow(clippy::unnecessary_wraps)]
|
|
102
|
+
#vis fn #fn_impl_name #generics(#(#impl_args),*) -> #result_return_type {
|
|
103
|
+
#fn_block
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
proc_macro::TokenStream::from(expanded)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
fn extract_bridge_result_type(ty: &Type) -> Option<&Type> {
|
|
112
|
+
if let Type::Path(type_path) = ty {
|
|
113
|
+
if let Some(last_segment) = type_path.path.segments.last() {
|
|
114
|
+
// Check if it's BridgeResult
|
|
115
|
+
if last_segment.ident == "BridgeResult" {
|
|
116
|
+
// Extract the type parameter T from BridgeResult<T>
|
|
117
|
+
if let PathArguments::AngleBracketed(generic_args) = &last_segment.arguments {
|
|
118
|
+
if let Some(GenericArgument::Type(inner_type)) = generic_args.args.first() {
|
|
119
|
+
return Some(inner_type);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
None
|
|
126
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
use convert_case::{Case, Casing};
|
|
2
|
+
use proc_macro2::TokenStream;
|
|
3
|
+
use quote::quote;
|
|
4
|
+
use syn::{DeriveInput, FieldsNamed, FieldsUnnamed};
|
|
5
|
+
|
|
6
|
+
pub fn derive_tryfromjs_struct(input: &DeriveInput, data: &syn::DataStruct) -> TokenStream {
|
|
7
|
+
let struct_ident = &input.ident;
|
|
8
|
+
let generics = &input.generics;
|
|
9
|
+
let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
|
|
10
|
+
|
|
11
|
+
let field_conversions = if let syn::Fields::Named(ref fields) = data.fields {
|
|
12
|
+
field_conversions_for_named_fields(fields)
|
|
13
|
+
} else {
|
|
14
|
+
panic!("Only named fields are supported")
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
let expanded = quote! {
|
|
18
|
+
impl #impl_generics crate::helpers::TryFromJs for #struct_ident #ty_generics #where_clause {
|
|
19
|
+
fn try_from_js<'cx, 'b>(cx: &mut impl neon::prelude::Context<'cx>, js_value: neon::prelude::Handle<'b, neon::prelude::JsValue>) -> crate::helpers::BridgeResult<Self> {
|
|
20
|
+
use crate::helpers::*;
|
|
21
|
+
|
|
22
|
+
let obj = js_value.downcast::<neon::prelude::JsObject, _>(cx)?;
|
|
23
|
+
Ok(Self {
|
|
24
|
+
#(#field_conversions),*
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
TokenStream::from(expanded)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
pub fn derive_tryfromjs_enum(input: &DeriveInput, data: &syn::DataEnum) -> TokenStream {
|
|
34
|
+
let enum_ident = &input.ident;
|
|
35
|
+
let enum_name = enum_ident.to_string();
|
|
36
|
+
let variants = &data.variants;
|
|
37
|
+
let generics = &input.generics;
|
|
38
|
+
let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
|
|
39
|
+
|
|
40
|
+
let variant_conversions = variants.iter().map(|v| {
|
|
41
|
+
let variant_ident = &v.ident;
|
|
42
|
+
let discriminant = variant_ident.to_string().to_case(Case::Kebab);
|
|
43
|
+
let js_discriminant = variant_ident.to_string().to_case(Case::Camel);
|
|
44
|
+
|
|
45
|
+
match &v.fields {
|
|
46
|
+
syn::Fields::Unit => {
|
|
47
|
+
// e.g. "otel" => Ok(MetricsExporter::Otel)
|
|
48
|
+
quote! {
|
|
49
|
+
#discriminant => Ok(#enum_ident::#variant_ident),
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
syn::Fields::Unnamed(FieldsUnnamed { unnamed, .. }) => {
|
|
53
|
+
if unnamed.len() != 1 {
|
|
54
|
+
panic!("Enum variant must have a single unnamed field that implements the TryFromJs trait");
|
|
55
|
+
}
|
|
56
|
+
let ty = unnamed.first().map(|f| f.ty.clone()).unwrap();
|
|
57
|
+
match ty {
|
|
58
|
+
syn::Type::Path(path) => {
|
|
59
|
+
// Example output:
|
|
60
|
+
//
|
|
61
|
+
// "otel" => {
|
|
62
|
+
// <OtelConfig>::try_from_js(cx, js_value).field("otel").map(MetricsExporter::Otel)
|
|
63
|
+
// }
|
|
64
|
+
quote! {
|
|
65
|
+
#discriminant => {
|
|
66
|
+
<#path>::try_from_js(cx, js_value).field(&#js_discriminant).map(#enum_ident::#variant_ident)
|
|
67
|
+
},
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
_ => panic!("Enum variant must have a single unnamed field that implements the TryFromJs trait"),
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
syn::Fields::Named(fields) => {
|
|
74
|
+
// Example output:
|
|
75
|
+
//
|
|
76
|
+
// "console" => Ok((|| {
|
|
77
|
+
// Ok::<LogExporter, BridgeError>(LogExporter::Console {
|
|
78
|
+
// filter: { obj.get_property_into(cx, "filter")? },
|
|
79
|
+
// })
|
|
80
|
+
// })()
|
|
81
|
+
// .field(format!("type={}", type_str).as_str())?),
|
|
82
|
+
//
|
|
83
|
+
// The inner closure is required so that we can use the `field` method on the result.
|
|
84
|
+
// An alternative would be to do that at the field level, but then that concern would
|
|
85
|
+
// spill into the field_conversions_for_named_fields function, which is used in
|
|
86
|
+
// other places.
|
|
87
|
+
let field_conversions = field_conversions_for_named_fields(fields);
|
|
88
|
+
quote! {
|
|
89
|
+
#discriminant => Ok(( || {
|
|
90
|
+
Ok::<#enum_ident #ty_generics, crate::helpers::BridgeError>(#enum_ident::#variant_ident {
|
|
91
|
+
#(#field_conversions),*
|
|
92
|
+
})
|
|
93
|
+
})()
|
|
94
|
+
.field(&#js_discriminant)?),
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
let expanded = quote! {
|
|
101
|
+
impl #impl_generics crate::helpers::TryFromJs for #enum_ident #ty_generics #where_clause {
|
|
102
|
+
fn try_from_js<'cx, 'b>(cx: &mut impl neon::prelude::Context<'cx>, js_value: neon::prelude::Handle<'b, neon::prelude::JsValue>) -> crate::helpers::BridgeResult<Self> {
|
|
103
|
+
use crate::helpers::*;
|
|
104
|
+
|
|
105
|
+
let obj = js_value.downcast::<neon::prelude::JsObject, _>(cx)?;
|
|
106
|
+
let type_str: String = obj.get_property_into(cx, "type")?;
|
|
107
|
+
|
|
108
|
+
match type_str.as_str() {
|
|
109
|
+
#(#variant_conversions)*
|
|
110
|
+
_ => Err(crate::helpers::BridgeError::InvalidVariant {
|
|
111
|
+
enum_name: #enum_name.to_string(),
|
|
112
|
+
variant: type_str,
|
|
113
|
+
}),
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
TokenStream::from(expanded)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
fn field_conversions_for_named_fields(
|
|
123
|
+
fields: &FieldsNamed,
|
|
124
|
+
) -> impl Iterator<Item = TokenStream> + '_ {
|
|
125
|
+
fields.named.iter().map(|f| {
|
|
126
|
+
let field_ident = f
|
|
127
|
+
.ident
|
|
128
|
+
.as_ref()
|
|
129
|
+
.expect("FieldsNamed.named must have an identifier");
|
|
130
|
+
let js_name = field_ident.to_string().to_case(Case::Camel);
|
|
131
|
+
|
|
132
|
+
quote! {
|
|
133
|
+
#field_ident: {
|
|
134
|
+
obj.get_property_into(cx, #js_name)?
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
})
|
|
138
|
+
}
|