@proompteng/temporal-bun-sdk 0.1.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 +387 -0
- package/dist/bin/start-worker.js +3 -0
- package/dist/bin/temporal-bun.js +3 -0
- package/dist/src/activities/index.d.ts +6 -0
- package/dist/src/activities/index.d.ts.map +1 -0
- package/dist/src/activities/index.js +5 -0
- package/dist/src/activities/index.js.map +1 -0
- package/dist/src/activities/lifecycle.d.ts +48 -0
- package/dist/src/activities/lifecycle.d.ts.map +1 -0
- package/dist/src/activities/lifecycle.js +306 -0
- package/dist/src/activities/lifecycle.js.map +1 -0
- package/dist/src/bin/replay-command.d.ts +104 -0
- package/dist/src/bin/replay-command.d.ts.map +1 -0
- package/dist/src/bin/replay-command.js +582 -0
- package/dist/src/bin/replay-command.js.map +1 -0
- package/dist/src/bin/start-worker.d.ts +3 -0
- package/dist/src/bin/start-worker.d.ts.map +1 -0
- package/dist/src/bin/start-worker.js +29 -0
- package/dist/src/bin/start-worker.js.map +1 -0
- package/dist/src/bin/temporal-bun.d.ts +25 -0
- package/dist/src/bin/temporal-bun.d.ts.map +1 -0
- package/dist/src/bin/temporal-bun.js +427 -0
- package/dist/src/bin/temporal-bun.js.map +1 -0
- package/dist/src/build_id_preflight.d.ts +7 -0
- package/dist/src/build_id_preflight.d.ts.map +1 -0
- package/dist/src/build_id_preflight.js +123 -0
- package/dist/src/build_id_preflight.js.map +1 -0
- package/dist/src/client/headers.d.ts +4 -0
- package/dist/src/client/headers.d.ts.map +1 -0
- package/dist/src/client/headers.js +79 -0
- package/dist/src/client/headers.js.map +1 -0
- package/dist/src/client/index.d.ts +2 -0
- package/dist/src/client/index.d.ts.map +1 -0
- package/dist/src/client/index.js +2 -0
- package/dist/src/client/index.js.map +1 -0
- package/dist/src/client/interceptors.d.ts +17 -0
- package/dist/src/client/interceptors.d.ts.map +1 -0
- package/dist/src/client/interceptors.js +71 -0
- package/dist/src/client/interceptors.js.map +1 -0
- package/dist/src/client/layer.d.ts +10 -0
- package/dist/src/client/layer.d.ts.map +1 -0
- package/dist/src/client/layer.js +7 -0
- package/dist/src/client/layer.js.map +1 -0
- package/dist/src/client/retries.d.ts +13 -0
- package/dist/src/client/retries.d.ts.map +1 -0
- package/dist/src/client/retries.js +51 -0
- package/dist/src/client/retries.js.map +1 -0
- package/dist/src/client/serialization.d.ts +48 -0
- package/dist/src/client/serialization.d.ts.map +1 -0
- package/dist/src/client/serialization.js +310 -0
- package/dist/src/client/serialization.js.map +1 -0
- package/dist/src/client/serialization.test.d.ts +2 -0
- package/dist/src/client/serialization.test.d.ts.map +1 -0
- package/dist/src/client/serialization.test.js +251 -0
- package/dist/src/client/serialization.test.js.map +1 -0
- package/dist/src/client/transport.d.ts +12 -0
- package/dist/src/client/transport.d.ts.map +1 -0
- package/dist/src/client/transport.js +36 -0
- package/dist/src/client/transport.js.map +1 -0
- package/dist/src/client/types.d.ts +51 -0
- package/dist/src/client/types.d.ts.map +1 -0
- package/dist/src/client/types.js +7 -0
- package/dist/src/client/types.js.map +1 -0
- package/dist/src/client.d.ts +92 -0
- package/dist/src/client.d.ts.map +1 -0
- package/dist/src/client.js +666 -0
- package/dist/src/client.js.map +1 -0
- package/dist/src/common/duration.d.ts +4 -0
- package/dist/src/common/duration.d.ts.map +1 -0
- package/dist/src/common/duration.js +14 -0
- package/dist/src/common/duration.js.map +1 -0
- package/dist/src/common/index.d.ts +2 -0
- package/dist/src/common/index.d.ts.map +1 -0
- package/dist/src/common/index.js +2 -0
- package/dist/src/common/index.js.map +1 -0
- package/dist/src/common/payloads/converter.d.ts +16 -0
- package/dist/src/common/payloads/converter.d.ts.map +1 -0
- package/dist/src/common/payloads/converter.js +33 -0
- package/dist/src/common/payloads/converter.js.map +1 -0
- package/dist/src/common/payloads/failure.d.ts +7 -0
- package/dist/src/common/payloads/failure.d.ts.map +1 -0
- package/dist/src/common/payloads/failure.js +53 -0
- package/dist/src/common/payloads/failure.js.map +1 -0
- package/dist/src/common/payloads/index.d.ts +4 -0
- package/dist/src/common/payloads/index.d.ts.map +1 -0
- package/dist/src/common/payloads/index.js +4 -0
- package/dist/src/common/payloads/index.js.map +1 -0
- package/dist/src/common/payloads/json-codec.d.ts +16 -0
- package/dist/src/common/payloads/json-codec.d.ts.map +1 -0
- package/dist/src/common/payloads/json-codec.js +185 -0
- package/dist/src/common/payloads/json-codec.js.map +1 -0
- package/dist/src/common/sleep.d.ts +2 -0
- package/dist/src/common/sleep.d.ts.map +1 -0
- package/dist/src/common/sleep.js +3 -0
- package/dist/src/common/sleep.js.map +1 -0
- package/dist/src/config.d.ts +115 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/config.js +505 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/core-bridge/client.d.ts +36 -0
- package/dist/src/core-bridge/client.d.ts.map +1 -0
- package/dist/src/core-bridge/client.js +111 -0
- package/dist/src/core-bridge/client.js.map +1 -0
- package/dist/src/core-bridge/index.d.ts +4 -0
- package/dist/src/core-bridge/index.d.ts.map +1 -0
- package/dist/src/core-bridge/index.js +4 -0
- package/dist/src/core-bridge/index.js.map +1 -0
- package/dist/src/core-bridge/runtime.d.ts +20 -0
- package/dist/src/core-bridge/runtime.d.ts.map +1 -0
- package/dist/src/core-bridge/runtime.js +62 -0
- package/dist/src/core-bridge/runtime.js.map +1 -0
- package/dist/src/core-bridge/runtime.test.d.ts +2 -0
- package/dist/src/core-bridge/runtime.test.d.ts.map +1 -0
- package/dist/src/core-bridge/runtime.test.js +68 -0
- package/dist/src/core-bridge/runtime.test.js.map +1 -0
- package/dist/src/index.d.ts +11 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +7 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/internal/core-bridge/native.d.ts +176 -0
- package/dist/src/internal/core-bridge/native.d.ts.map +1 -0
- package/dist/src/internal/core-bridge/native.js +1208 -0
- package/dist/src/internal/core-bridge/native.js.map +1 -0
- package/dist/src/observability/index.d.ts +21 -0
- package/dist/src/observability/index.d.ts.map +1 -0
- package/dist/src/observability/index.js +19 -0
- package/dist/src/observability/index.js.map +1 -0
- package/dist/src/observability/logger.d.ts +28 -0
- package/dist/src/observability/logger.d.ts.map +1 -0
- package/dist/src/observability/logger.js +53 -0
- package/dist/src/observability/logger.js.map +1 -0
- package/dist/src/observability/metrics.d.ts +28 -0
- package/dist/src/observability/metrics.d.ts.map +1 -0
- package/dist/src/observability/metrics.js +355 -0
- package/dist/src/observability/metrics.js.map +1 -0
- package/dist/src/proto/google/api/annotations_pb.d.ts +14 -0
- package/dist/src/proto/google/api/annotations_pb.d.ts.map +1 -0
- package/dist/src/proto/google/api/annotations_pb.js +27 -0
- package/dist/src/proto/google/api/annotations_pb.js.map +1 -0
- package/dist/src/proto/google/api/http_pb.d.ts +441 -0
- package/dist/src/proto/google/api/http_pb.d.ts.map +1 -0
- package/dist/src/proto/google/api/http_pb.js +34 -0
- package/dist/src/proto/google/api/http_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/activity/v1/message_pb.d.ts +67 -0
- package/dist/src/proto/temporal/api/activity/v1/message_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/activity/v1/message_pb.js +17 -0
- package/dist/src/proto/temporal/api/activity/v1/message_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/batch/v1/message_pb.d.ts +464 -0
- package/dist/src/proto/temporal/api/batch/v1/message_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/batch/v1/message_pb.js +71 -0
- package/dist/src/proto/temporal/api/batch/v1/message_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/command/v1/message_pb.d.ts +796 -0
- package/dist/src/proto/temporal/api/command/v1/message_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/command/v1/message_pb.js +106 -0
- package/dist/src/proto/temporal/api/command/v1/message_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/common/v1/message_pb.d.ts +751 -0
- package/dist/src/proto/temporal/api/common/v1/message_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/common/v1/message_pb.js +133 -0
- package/dist/src/proto/temporal/api/common/v1/message_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/deployment/v1/message_pb.d.ts +639 -0
- package/dist/src/proto/temporal/api/deployment/v1/message_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/deployment/v1/message_pb.js +83 -0
- package/dist/src/proto/temporal/api/deployment/v1/message_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/enums/v1/batch_operation_pb.d.ts +80 -0
- package/dist/src/proto/temporal/api/enums/v1/batch_operation_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/enums/v1/batch_operation_pb.js +85 -0
- package/dist/src/proto/temporal/api/enums/v1/batch_operation_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/enums/v1/command_type_pb.d.ts +89 -0
- package/dist/src/proto/temporal/api/enums/v1/command_type_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/enums/v1/command_type_pb.js +93 -0
- package/dist/src/proto/temporal/api/enums/v1/command_type_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/enums/v1/common_pb.d.ts +314 -0
- package/dist/src/proto/temporal/api/enums/v1/common_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/enums/v1/common_pb.js +326 -0
- package/dist/src/proto/temporal/api/enums/v1/common_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/enums/v1/deployment_pb.d.ts +186 -0
- package/dist/src/proto/temporal/api/enums/v1/deployment_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/enums/v1/deployment_pb.js +193 -0
- package/dist/src/proto/temporal/api/enums/v1/deployment_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/enums/v1/event_type_pb.d.ts +407 -0
- package/dist/src/proto/temporal/api/enums/v1/event_type_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/enums/v1/event_type_pb.js +411 -0
- package/dist/src/proto/temporal/api/enums/v1/event_type_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/enums/v1/failed_cause_pb.d.ts +371 -0
- package/dist/src/proto/temporal/api/enums/v1/failed_cause_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/enums/v1/failed_cause_pb.js +380 -0
- package/dist/src/proto/temporal/api/enums/v1/failed_cause_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/enums/v1/namespace_pb.d.ts +73 -0
- package/dist/src/proto/temporal/api/enums/v1/namespace_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/enums/v1/namespace_pb.js +79 -0
- package/dist/src/proto/temporal/api/enums/v1/namespace_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/enums/v1/nexus_pb.d.ts +35 -0
- package/dist/src/proto/temporal/api/enums/v1/nexus_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/enums/v1/nexus_pb.js +39 -0
- package/dist/src/proto/temporal/api/enums/v1/nexus_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/enums/v1/query_pb.d.ts +58 -0
- package/dist/src/proto/temporal/api/enums/v1/query_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/enums/v1/query_pb.js +63 -0
- package/dist/src/proto/temporal/api/enums/v1/query_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/enums/v1/reset_pb.d.ts +108 -0
- package/dist/src/proto/temporal/api/enums/v1/reset_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/enums/v1/reset_pb.js +114 -0
- package/dist/src/proto/temporal/api/enums/v1/reset_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/enums/v1/schedule_pb.d.ts +67 -0
- package/dist/src/proto/temporal/api/enums/v1/schedule_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/enums/v1/schedule_pb.js +71 -0
- package/dist/src/proto/temporal/api/enums/v1/schedule_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/enums/v1/task_queue_pb.d.ts +249 -0
- package/dist/src/proto/temporal/api/enums/v1/task_queue_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/enums/v1/task_queue_pb.js +259 -0
- package/dist/src/proto/temporal/api/enums/v1/task_queue_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/enums/v1/update_pb.d.ts +78 -0
- package/dist/src/proto/temporal/api/enums/v1/update_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/enums/v1/update_pb.js +83 -0
- package/dist/src/proto/temporal/api/enums/v1/update_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/enums/v1/workflow_pb.d.ts +408 -0
- package/dist/src/proto/temporal/api/enums/v1/workflow_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/enums/v1/workflow_pb.js +422 -0
- package/dist/src/proto/temporal/api/enums/v1/workflow_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/errordetails/v1/message_pb.d.ts +331 -0
- package/dist/src/proto/temporal/api/errordetails/v1/message_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/errordetails/v1/message_pb.js +104 -0
- package/dist/src/proto/temporal/api/errordetails/v1/message_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/export/v1/message_pb.d.ts +39 -0
- package/dist/src/proto/temporal/api/export/v1/message_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/export/v1/message_pb.js +20 -0
- package/dist/src/proto/temporal/api/export/v1/message_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/failure/v1/message_pb.d.ts +381 -0
- package/dist/src/proto/temporal/api/failure/v1/message_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/failure/v1/message_pb.js +74 -0
- package/dist/src/proto/temporal/api/failure/v1/message_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/filter/v1/message_pb.d.ts +73 -0
- package/dist/src/proto/temporal/api/filter/v1/message_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/filter/v1/message_pb.js +31 -0
- package/dist/src/proto/temporal/api/filter/v1/message_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/history/v1/message_pb.d.ts +3136 -0
- package/dist/src/proto/temporal/api/history/v1/message_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/history/v1/message_pb.js +317 -0
- package/dist/src/proto/temporal/api/history/v1/message_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/namespace/v1/message_pb.d.ts +242 -0
- package/dist/src/proto/temporal/api/namespace/v1/message_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/namespace/v1/message_pb.js +46 -0
- package/dist/src/proto/temporal/api/namespace/v1/message_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/nexus/v1/message_pb.d.ts +549 -0
- package/dist/src/proto/temporal/api/nexus/v1/message_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/nexus/v1/message_pb.js +97 -0
- package/dist/src/proto/temporal/api/nexus/v1/message_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/operatorservice/v1/request_response_pb.d.ts +499 -0
- package/dist/src/proto/temporal/api/operatorservice/v1/request_response_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/operatorservice/v1/request_response_pb.js +137 -0
- package/dist/src/proto/temporal/api/operatorservice/v1/request_response_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/operatorservice/v1/service_pb.d.ts +153 -0
- package/dist/src/proto/temporal/api/operatorservice/v1/service_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/operatorservice/v1/service_pb.js +22 -0
- package/dist/src/proto/temporal/api/operatorservice/v1/service_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/protocol/v1/message_pb.d.ts +64 -0
- package/dist/src/proto/temporal/api/protocol/v1/message_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/protocol/v1/message_pb.js +15 -0
- package/dist/src/proto/temporal/api/protocol/v1/message_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/query/v1/message_pb.d.ts +96 -0
- package/dist/src/proto/temporal/api/query/v1/message_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/query/v1/message_pb.js +28 -0
- package/dist/src/proto/temporal/api/query/v1/message_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/replication/v1/message_pb.d.ts +67 -0
- package/dist/src/proto/temporal/api/replication/v1/message_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/replication/v1/message_pb.js +26 -0
- package/dist/src/proto/temporal/api/replication/v1/message_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/rules/v1/message_pb.d.ts +172 -0
- package/dist/src/proto/temporal/api/rules/v1/message_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/rules/v1/message_pb.js +35 -0
- package/dist/src/proto/temporal/api/rules/v1/message_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/schedule/v1/message_pb.d.ts +779 -0
- package/dist/src/proto/temporal/api/schedule/v1/message_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/schedule/v1/message_pb.js +95 -0
- package/dist/src/proto/temporal/api/schedule/v1/message_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/sdk/v1/enhanced_stack_trace_pb.d.ts +157 -0
- package/dist/src/proto/temporal/api/sdk/v1/enhanced_stack_trace_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/sdk/v1/enhanced_stack_trace_pb.js +34 -0
- package/dist/src/proto/temporal/api/sdk/v1/enhanced_stack_trace_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/sdk/v1/task_complete_metadata_pb.d.ts +71 -0
- package/dist/src/proto/temporal/api/sdk/v1/task_complete_metadata_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/sdk/v1/task_complete_metadata_pb.js +14 -0
- package/dist/src/proto/temporal/api/sdk/v1/task_complete_metadata_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/sdk/v1/user_metadata_pb.d.ts +37 -0
- package/dist/src/proto/temporal/api/sdk/v1/user_metadata_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/sdk/v1/user_metadata_pb.js +15 -0
- package/dist/src/proto/temporal/api/sdk/v1/user_metadata_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/sdk/v1/worker_config_pb.d.ts +84 -0
- package/dist/src/proto/temporal/api/sdk/v1/worker_config_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/sdk/v1/worker_config_pb.js +24 -0
- package/dist/src/proto/temporal/api/sdk/v1/worker_config_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/sdk/v1/workflow_metadata_pb.d.ts +99 -0
- package/dist/src/proto/temporal/api/sdk/v1/workflow_metadata_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/sdk/v1/workflow_metadata_pb.js +24 -0
- package/dist/src/proto/temporal/api/sdk/v1/workflow_metadata_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/taskqueue/v1/message_pb.d.ts +757 -0
- package/dist/src/proto/temporal/api/taskqueue/v1/message_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/taskqueue/v1/message_pb.js +138 -0
- package/dist/src/proto/temporal/api/taskqueue/v1/message_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/update/v1/message_pb.d.ts +230 -0
- package/dist/src/proto/temporal/api/update/v1/message_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/update/v1/message_pb.js +57 -0
- package/dist/src/proto/temporal/api/update/v1/message_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/version/v1/message_pb.d.ts +85 -0
- package/dist/src/proto/temporal/api/version/v1/message_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/version/v1/message_pb.js +26 -0
- package/dist/src/proto/temporal/api/version/v1/message_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/worker/v1/message_pb.d.ts +311 -0
- package/dist/src/proto/temporal/api/worker/v1/message_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/worker/v1/message_pb.js +42 -0
- package/dist/src/proto/temporal/api/worker/v1/message_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/workflow/v1/message_pb.d.ts +1500 -0
- package/dist/src/proto/temporal/api/workflow/v1/message_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/workflow/v1/message_pb.js +183 -0
- package/dist/src/proto/temporal/api/workflow/v1/message_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/workflowservice/v1/request_response_pb.d.ts +6967 -0
- package/dist/src/proto/temporal/api/workflowservice/v1/request_response_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/workflowservice/v1/request_response_pb.js +1073 -0
- package/dist/src/proto/temporal/api/workflowservice/v1/request_response_pb.js.map +1 -0
- package/dist/src/proto/temporal/api/workflowservice/v1/service_pb.d.ts +1305 -0
- package/dist/src/proto/temporal/api/workflowservice/v1/service_pb.d.ts.map +1 -0
- package/dist/src/proto/temporal/api/workflowservice/v1/service_pb.js +27 -0
- package/dist/src/proto/temporal/api/workflowservice/v1/service_pb.js.map +1 -0
- package/dist/src/runtime/cli-layer.d.ts +12 -0
- package/dist/src/runtime/cli-layer.d.ts.map +1 -0
- package/dist/src/runtime/cli-layer.js +19 -0
- package/dist/src/runtime/cli-layer.js.map +1 -0
- package/dist/src/runtime/config-layer.d.ts +9 -0
- package/dist/src/runtime/config-layer.d.ts.map +1 -0
- package/dist/src/runtime/config-layer.js +15 -0
- package/dist/src/runtime/config-layer.js.map +1 -0
- package/dist/src/runtime/effect-layers.d.ts +518 -0
- package/dist/src/runtime/effect-layers.d.ts.map +1 -0
- package/dist/src/runtime/effect-layers.js +68 -0
- package/dist/src/runtime/effect-layers.js.map +1 -0
- package/dist/src/runtime/worker-app.d.ts +14 -0
- package/dist/src/runtime/worker-app.d.ts.map +1 -0
- package/dist/src/runtime/worker-app.js +58 -0
- package/dist/src/runtime/worker-app.js.map +1 -0
- package/dist/src/telemetry/runtime.d.ts +5 -0
- package/dist/src/telemetry/runtime.d.ts.map +1 -0
- package/dist/src/telemetry/runtime.js +94 -0
- package/dist/src/telemetry/runtime.js.map +1 -0
- package/dist/src/worker/activity-context.d.ts +30 -0
- package/dist/src/worker/activity-context.d.ts.map +1 -0
- package/dist/src/worker/activity-context.js +9 -0
- package/dist/src/worker/activity-context.js.map +1 -0
- package/dist/src/worker/build-id.d.ts +20 -0
- package/dist/src/worker/build-id.d.ts.map +1 -0
- package/dist/src/worker/build-id.js +98 -0
- package/dist/src/worker/build-id.js.map +1 -0
- package/dist/src/worker/concurrency.d.ts +31 -0
- package/dist/src/worker/concurrency.d.ts.map +1 -0
- package/dist/src/worker/concurrency.js +129 -0
- package/dist/src/worker/concurrency.js.map +1 -0
- package/dist/src/worker/defaults.d.ts +9 -0
- package/dist/src/worker/defaults.d.ts.map +1 -0
- package/dist/src/worker/defaults.js +53 -0
- package/dist/src/worker/defaults.js.map +1 -0
- package/dist/src/worker/index.d.ts +7 -0
- package/dist/src/worker/index.d.ts.map +1 -0
- package/dist/src/worker/index.js +4 -0
- package/dist/src/worker/index.js.map +1 -0
- package/dist/src/worker/layer.d.ts +19 -0
- package/dist/src/worker/layer.d.ts.map +1 -0
- package/dist/src/worker/layer.js +71 -0
- package/dist/src/worker/layer.js.map +1 -0
- package/dist/src/worker/runtime.d.ts +59 -0
- package/dist/src/worker/runtime.d.ts.map +1 -0
- package/dist/src/worker/runtime.js +1415 -0
- package/dist/src/worker/runtime.js.map +1 -0
- package/dist/src/worker/service.d.ts +19 -0
- package/dist/src/worker/service.d.ts.map +1 -0
- package/dist/src/worker/service.js +14 -0
- package/dist/src/worker/service.js.map +1 -0
- package/dist/src/worker/sticky-cache.d.ts +41 -0
- package/dist/src/worker/sticky-cache.d.ts.map +1 -0
- package/dist/src/worker/sticky-cache.js +127 -0
- package/dist/src/worker/sticky-cache.js.map +1 -0
- package/dist/src/worker.d.ts +30 -0
- package/dist/src/worker.d.ts.map +1 -0
- package/dist/src/worker.js +82 -0
- package/dist/src/worker.js.map +1 -0
- package/dist/src/workflow/commands.d.ts +84 -0
- package/dist/src/workflow/commands.d.ts.map +1 -0
- package/dist/src/workflow/commands.js +159 -0
- package/dist/src/workflow/commands.js.map +1 -0
- package/dist/src/workflow/context.d.ts +119 -0
- package/dist/src/workflow/context.d.ts.map +1 -0
- package/dist/src/workflow/context.js +197 -0
- package/dist/src/workflow/context.js.map +1 -0
- package/dist/src/workflow/definition.d.ts +15 -0
- package/dist/src/workflow/definition.d.ts.map +1 -0
- package/dist/src/workflow/definition.js +19 -0
- package/dist/src/workflow/definition.js.map +1 -0
- package/dist/src/workflow/determinism.d.ts +54 -0
- package/dist/src/workflow/determinism.d.ts.map +1 -0
- package/dist/src/workflow/determinism.js +147 -0
- package/dist/src/workflow/determinism.js.map +1 -0
- package/dist/src/workflow/errors.d.ts +37 -0
- package/dist/src/workflow/errors.d.ts.map +1 -0
- package/dist/src/workflow/errors.js +35 -0
- package/dist/src/workflow/errors.js.map +1 -0
- package/dist/src/workflow/executor.d.ts +35 -0
- package/dist/src/workflow/executor.d.ts.map +1 -0
- package/dist/src/workflow/executor.js +178 -0
- package/dist/src/workflow/executor.js.map +1 -0
- package/dist/src/workflow/index.d.ts +8 -0
- package/dist/src/workflow/index.d.ts.map +1 -0
- package/dist/src/workflow/index.js +8 -0
- package/dist/src/workflow/index.js.map +1 -0
- package/dist/src/workflow/registry.d.ts +9 -0
- package/dist/src/workflow/registry.d.ts.map +1 -0
- package/dist/src/workflow/registry.js +51 -0
- package/dist/src/workflow/registry.js.map +1 -0
- package/dist/src/workflow/replay.d.ts +87 -0
- package/dist/src/workflow/replay.d.ts.map +1 -0
- package/dist/src/workflow/replay.js +759 -0
- package/dist/src/workflow/replay.js.map +1 -0
- package/dist/src/workflow/runtime/bootstrap.d.ts +15 -0
- package/dist/src/workflow/runtime/bootstrap.d.ts.map +1 -0
- package/dist/src/workflow/runtime/bootstrap.js +124 -0
- package/dist/src/workflow/runtime/bootstrap.js.map +1 -0
- package/dist/src/workflow/runtime/engine.d.ts +21 -0
- package/dist/src/workflow/runtime/engine.d.ts.map +1 -0
- package/dist/src/workflow/runtime/engine.js +73 -0
- package/dist/src/workflow/runtime/engine.js.map +1 -0
- package/dist/src/workflow/runtime/environment.d.ts +29 -0
- package/dist/src/workflow/runtime/environment.d.ts.map +1 -0
- package/dist/src/workflow/runtime/environment.js +298 -0
- package/dist/src/workflow/runtime/environment.js.map +1 -0
- package/dist/src/workflow/runtime/index.d.ts +7 -0
- package/dist/src/workflow/runtime/index.d.ts.map +1 -0
- package/dist/src/workflow/runtime/index.js +4 -0
- package/dist/src/workflow/runtime/index.js.map +1 -0
- package/dist/src/workflow/runtime/info.d.ts +5 -0
- package/dist/src/workflow/runtime/info.d.ts.map +1 -0
- package/dist/src/workflow/runtime/info.js +22 -0
- package/dist/src/workflow/runtime/info.js.map +1 -0
- package/dist/src/workflow/runtime/replay.d.ts +26 -0
- package/dist/src/workflow/runtime/replay.d.ts.map +1 -0
- package/dist/src/workflow/runtime/replay.js +254 -0
- package/dist/src/workflow/runtime/replay.js.map +1 -0
- package/dist/src/workflows/index.d.ts +3 -0
- package/dist/src/workflows/index.d.ts.map +1 -0
- package/dist/src/workflows/index.js +15 -0
- package/dist/src/workflows/index.js.map +1 -0
- package/package.json +74 -0
|
@@ -0,0 +1,759 @@
|
|
|
1
|
+
import { create } from '@bufbuild/protobuf';
|
|
2
|
+
import { Effect } from 'effect';
|
|
3
|
+
import { durationToMillis } from '../common/duration';
|
|
4
|
+
import { decodePayloadsToValues, encodeValuesToPayloads } from '../common/payloads';
|
|
5
|
+
import { PayloadsSchema } from '../proto/temporal/api/common/v1/message_pb';
|
|
6
|
+
import { EventType } from '../proto/temporal/api/enums/v1/event_type_pb';
|
|
7
|
+
import { ParentClosePolicy, TimeoutType, WorkflowIdReusePolicy } from '../proto/temporal/api/enums/v1/workflow_pb';
|
|
8
|
+
import { intentsEqual } from './determinism';
|
|
9
|
+
export const DETERMINISM_MARKER_NAME = 'temporal-bun-sdk/determinism';
|
|
10
|
+
const DETERMINISM_MARKER_SCHEMA_VERSION = 1;
|
|
11
|
+
const DETERMINISM_MARKER_DETAIL_KEY = 'snapshot';
|
|
12
|
+
/**
|
|
13
|
+
* Encode a workflow determinism snapshot into a marker payload map suitable for
|
|
14
|
+
* use with {@link RecordMarkerCommandAttributes.details}.
|
|
15
|
+
*/
|
|
16
|
+
export const encodeDeterminismMarkerDetails = (converter, input) => Effect.tryPromise(async () => {
|
|
17
|
+
const recordedAt = (input.recordedAt ?? new Date()).toISOString();
|
|
18
|
+
const envelope = {
|
|
19
|
+
schemaVersion: DETERMINISM_MARKER_SCHEMA_VERSION,
|
|
20
|
+
workflow: input.info,
|
|
21
|
+
determinismState: input.determinismState,
|
|
22
|
+
lastEventId: normalizeEventId(input.lastEventId),
|
|
23
|
+
recordedAtIso: recordedAt,
|
|
24
|
+
};
|
|
25
|
+
const payloads = await encodeValuesToPayloads(converter, [envelope]);
|
|
26
|
+
if (!payloads || payloads.length === 0) {
|
|
27
|
+
throw new Error('Failed to encode determinism marker payloads');
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
[DETERMINISM_MARKER_DETAIL_KEY]: create(PayloadsSchema, { payloads }),
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
/**
|
|
34
|
+
* Decode determinism snapshot metadata from a marker payload map. Returns
|
|
35
|
+
* `undefined` when the supplied details do not contain a determinism snapshot.
|
|
36
|
+
*/
|
|
37
|
+
export const decodeDeterminismMarkerEnvelope = (input) => Effect.tryPromise(async () => {
|
|
38
|
+
const snapshot = input.details?.[DETERMINISM_MARKER_DETAIL_KEY];
|
|
39
|
+
if (!snapshot) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
const values = await decodePayloadsToValues(input.converter, snapshot.payloads ?? []);
|
|
43
|
+
if (!values || values.length === 0) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
const envelope = values[0];
|
|
47
|
+
if (!isRecord(envelope)) {
|
|
48
|
+
throw new Error('Determinism marker payload was not an object');
|
|
49
|
+
}
|
|
50
|
+
return sanitizeDeterminismMarkerEnvelope(envelope);
|
|
51
|
+
});
|
|
52
|
+
/**
|
|
53
|
+
* Processes workflow history into a determinism snapshot that can seed the
|
|
54
|
+
* {@link DeterminismGuard}. Downstream tasks populate sticky caches and replay
|
|
55
|
+
* diagnostics from the returned state.
|
|
56
|
+
*/
|
|
57
|
+
export const ingestWorkflowHistory = (intake) => Effect.gen(function* () {
|
|
58
|
+
const events = sortHistoryEvents(intake.history ?? []);
|
|
59
|
+
const shouldUseDeterminismMarker = intake.ignoreDeterminismMarker !== true;
|
|
60
|
+
let markerSnapshot;
|
|
61
|
+
if (shouldUseDeterminismMarker) {
|
|
62
|
+
for (const event of events) {
|
|
63
|
+
if (event.eventType !== EventType.MARKER_RECORDED) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (event.attributes?.case !== 'markerRecordedEventAttributes') {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const decoded = yield* Effect.catchAll(decodeDeterminismMarkerEnvelope({
|
|
70
|
+
converter: intake.dataConverter,
|
|
71
|
+
details: event.attributes.value.details,
|
|
72
|
+
}), () => Effect.succeed(undefined));
|
|
73
|
+
if (decoded) {
|
|
74
|
+
markerSnapshot = decoded;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const extractedFailureMetadata = extractFailureMetadata(events);
|
|
79
|
+
if (shouldUseDeterminismMarker && markerSnapshot) {
|
|
80
|
+
const determinismState = markerSnapshot.determinismState.failureMetadata
|
|
81
|
+
? markerSnapshot.determinismState
|
|
82
|
+
: {
|
|
83
|
+
...markerSnapshot.determinismState,
|
|
84
|
+
...(extractedFailureMetadata ? { failureMetadata: extractedFailureMetadata } : {}),
|
|
85
|
+
};
|
|
86
|
+
const latestEventId = resolveHistoryLastEventId(events) ?? markerSnapshot.lastEventId ?? null;
|
|
87
|
+
return {
|
|
88
|
+
determinismState,
|
|
89
|
+
lastEventId: latestEventId,
|
|
90
|
+
hasDeterminismMarker: true,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
return yield* reconstructDeterminismState(events, intake, extractedFailureMetadata);
|
|
94
|
+
});
|
|
95
|
+
/**
|
|
96
|
+
* Diff determinism state against freshly emitted intents to produce rich
|
|
97
|
+
* diagnostics for `WorkflowNondeterminismError` instances.
|
|
98
|
+
*/
|
|
99
|
+
export const diffDeterminismState = (expected, actual) => Effect.sync(() => {
|
|
100
|
+
const mismatches = [];
|
|
101
|
+
const maxCommands = Math.max(expected.commandHistory.length, actual.commandHistory.length);
|
|
102
|
+
for (let index = 0; index < maxCommands; index += 1) {
|
|
103
|
+
const expectedEntry = expected.commandHistory[index];
|
|
104
|
+
const actualEntry = actual.commandHistory[index];
|
|
105
|
+
const expectedIntent = expectedEntry?.intent;
|
|
106
|
+
const actualIntent = actualEntry?.intent;
|
|
107
|
+
const metadata = resolveCommandMismatchMetadata(expectedEntry, actualEntry);
|
|
108
|
+
if (!expectedIntent || !actualIntent) {
|
|
109
|
+
if (expectedIntent !== actualIntent) {
|
|
110
|
+
mismatches.push({
|
|
111
|
+
kind: 'command',
|
|
112
|
+
index,
|
|
113
|
+
expected: expectedIntent,
|
|
114
|
+
actual: actualIntent,
|
|
115
|
+
...metadata,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
if (!intentsEqual(expectedIntent, actualIntent)) {
|
|
121
|
+
mismatches.push({
|
|
122
|
+
kind: 'command',
|
|
123
|
+
index,
|
|
124
|
+
expected: expectedIntent,
|
|
125
|
+
actual: actualIntent,
|
|
126
|
+
...metadata,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const maxRandom = Math.max(expected.randomValues.length, actual.randomValues.length);
|
|
131
|
+
for (let index = 0; index < maxRandom; index += 1) {
|
|
132
|
+
const expectedValue = expected.randomValues[index];
|
|
133
|
+
const actualValue = actual.randomValues[index];
|
|
134
|
+
if (!valuesEqual(expectedValue, actualValue)) {
|
|
135
|
+
mismatches.push({
|
|
136
|
+
kind: 'random',
|
|
137
|
+
index,
|
|
138
|
+
expected: expectedValue,
|
|
139
|
+
actual: actualValue,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const maxTime = Math.max(expected.timeValues.length, actual.timeValues.length);
|
|
144
|
+
for (let index = 0; index < maxTime; index += 1) {
|
|
145
|
+
const expectedValue = expected.timeValues[index];
|
|
146
|
+
const actualValue = actual.timeValues[index];
|
|
147
|
+
if (!valuesEqual(expectedValue, actualValue)) {
|
|
148
|
+
mismatches.push({
|
|
149
|
+
kind: 'time',
|
|
150
|
+
index,
|
|
151
|
+
expected: expectedValue,
|
|
152
|
+
actual: actualValue,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return { mismatches };
|
|
157
|
+
});
|
|
158
|
+
export const resolveHistoryLastEventId = (events) => {
|
|
159
|
+
if (!events || events.length === 0) {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
const last = events[events.length - 1];
|
|
163
|
+
if (!last) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
const { eventId } = last;
|
|
167
|
+
if (eventId === undefined || eventId === null) {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
if (typeof eventId === 'number' && !Number.isFinite(eventId)) {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
return String(eventId);
|
|
174
|
+
};
|
|
175
|
+
export const cloneDeterminismState = (state) => ({
|
|
176
|
+
commandHistory: state.commandHistory.map((entry) => ({
|
|
177
|
+
intent: entry.intent,
|
|
178
|
+
metadata: entry.metadata ? { ...entry.metadata } : undefined,
|
|
179
|
+
})),
|
|
180
|
+
randomValues: [...state.randomValues],
|
|
181
|
+
timeValues: [...state.timeValues],
|
|
182
|
+
failureMetadata: state.failureMetadata ? { ...state.failureMetadata } : undefined,
|
|
183
|
+
});
|
|
184
|
+
const sortHistoryEvents = (events) => events.slice().sort((left, right) => {
|
|
185
|
+
const leftId = resolveEventIdForSort(left);
|
|
186
|
+
const rightId = resolveEventIdForSort(right);
|
|
187
|
+
if (leftId === rightId) {
|
|
188
|
+
return 0;
|
|
189
|
+
}
|
|
190
|
+
return leftId < rightId ? -1 : 1;
|
|
191
|
+
});
|
|
192
|
+
const resolveEventIdForSort = (event) => {
|
|
193
|
+
const eventId = event.eventId;
|
|
194
|
+
if (typeof eventId === 'bigint') {
|
|
195
|
+
return eventId;
|
|
196
|
+
}
|
|
197
|
+
if (typeof eventId === 'number' && Number.isFinite(eventId)) {
|
|
198
|
+
return BigInt(eventId);
|
|
199
|
+
}
|
|
200
|
+
if (typeof eventId === 'string' && eventId.length > 0) {
|
|
201
|
+
try {
|
|
202
|
+
return BigInt(eventId);
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
return 0n;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return 0n;
|
|
209
|
+
};
|
|
210
|
+
const buildCommandMetadata = (event, attributes) => {
|
|
211
|
+
const eventId = normalizeEventId(event.eventId);
|
|
212
|
+
const workflowTaskCompletedEventId = resolveWorkflowTaskCompletedEventId(attributes);
|
|
213
|
+
const eventType = event.eventType;
|
|
214
|
+
if (!eventId && !workflowTaskCompletedEventId && (eventType === undefined || eventType === EventType.UNSPECIFIED)) {
|
|
215
|
+
return undefined;
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
...(eventId !== null ? { eventId } : {}),
|
|
219
|
+
...(typeof eventType === 'number' ? { eventType } : {}),
|
|
220
|
+
...(workflowTaskCompletedEventId ? { workflowTaskCompletedEventId } : {}),
|
|
221
|
+
};
|
|
222
|
+
};
|
|
223
|
+
const resolveWorkflowTaskCompletedEventId = (attributes) => {
|
|
224
|
+
if (!attributes || typeof attributes !== 'object') {
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
const candidate = attributes.workflowTaskCompletedEventId;
|
|
228
|
+
if (candidate === undefined || candidate === null) {
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
try {
|
|
232
|
+
return normalizeEventId(candidate);
|
|
233
|
+
}
|
|
234
|
+
catch {
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
const extractFailureMetadata = (events) => {
|
|
239
|
+
for (let index = events.length - 1; index >= 0; index -= 1) {
|
|
240
|
+
const metadata = buildFailureMetadata(events[index]);
|
|
241
|
+
if (metadata) {
|
|
242
|
+
return metadata;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return undefined;
|
|
246
|
+
};
|
|
247
|
+
const buildFailureMetadata = (event) => {
|
|
248
|
+
const eventId = normalizeEventId(event.eventId);
|
|
249
|
+
switch (event.eventType) {
|
|
250
|
+
case EventType.WORKFLOW_EXECUTION_FAILED: {
|
|
251
|
+
if (event.attributes?.case !== 'workflowExecutionFailedEventAttributes') {
|
|
252
|
+
return undefined;
|
|
253
|
+
}
|
|
254
|
+
const attributes = event.attributes.value;
|
|
255
|
+
return {
|
|
256
|
+
eventId,
|
|
257
|
+
eventType: event.eventType,
|
|
258
|
+
failureType: resolveFailureType(attributes.failure),
|
|
259
|
+
failureMessage: attributes.failure?.message ?? undefined,
|
|
260
|
+
retryState: attributes.retryState !== undefined ? Number(attributes.retryState) : undefined,
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
case EventType.WORKFLOW_EXECUTION_TIMED_OUT: {
|
|
264
|
+
if (event.attributes?.case !== 'workflowExecutionTimedOutEventAttributes') {
|
|
265
|
+
return undefined;
|
|
266
|
+
}
|
|
267
|
+
const attributes = event.attributes.value;
|
|
268
|
+
return {
|
|
269
|
+
eventId,
|
|
270
|
+
eventType: event.eventType,
|
|
271
|
+
failureType: 'WORKFLOW_EXECUTION_TIMED_OUT',
|
|
272
|
+
failureMessage: undefined,
|
|
273
|
+
retryState: attributes.retryState !== undefined ? Number(attributes.retryState) : undefined,
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
case EventType.WORKFLOW_TASK_FAILED: {
|
|
277
|
+
if (event.attributes?.case !== 'workflowTaskFailedEventAttributes') {
|
|
278
|
+
return undefined;
|
|
279
|
+
}
|
|
280
|
+
const attributes = event.attributes.value;
|
|
281
|
+
return {
|
|
282
|
+
eventId,
|
|
283
|
+
eventType: event.eventType,
|
|
284
|
+
failureType: resolveFailureType(attributes.failure),
|
|
285
|
+
failureMessage: attributes.failure?.message ?? undefined,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
case EventType.WORKFLOW_TASK_TIMED_OUT: {
|
|
289
|
+
if (event.attributes?.case !== 'workflowTaskTimedOutEventAttributes') {
|
|
290
|
+
return undefined;
|
|
291
|
+
}
|
|
292
|
+
const attributes = event.attributes.value;
|
|
293
|
+
const timeoutTypeName = TimeoutType[attributes.timeoutType] ?? 'TIMEOUT_TYPE_UNSPECIFIED';
|
|
294
|
+
return {
|
|
295
|
+
eventId,
|
|
296
|
+
eventType: event.eventType,
|
|
297
|
+
failureType: `WORKFLOW_TASK_TIMED_OUT:${timeoutTypeName}`,
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
default:
|
|
301
|
+
return undefined;
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
const resolveFailureType = (failure) => {
|
|
305
|
+
if (!failure) {
|
|
306
|
+
return undefined;
|
|
307
|
+
}
|
|
308
|
+
switch (failure.failureInfo?.case) {
|
|
309
|
+
case 'applicationFailureInfo':
|
|
310
|
+
return failure.failureInfo.value.type || 'ApplicationFailure';
|
|
311
|
+
case 'timeoutFailureInfo': {
|
|
312
|
+
const timeoutName = TimeoutType[failure.failureInfo.value.timeoutType] ?? 'TIMEOUT_TYPE_UNSPECIFIED';
|
|
313
|
+
return `Timeout:${timeoutName}`;
|
|
314
|
+
}
|
|
315
|
+
case 'activityFailureInfo':
|
|
316
|
+
return 'ActivityFailure';
|
|
317
|
+
case 'childWorkflowExecutionFailureInfo':
|
|
318
|
+
return 'ChildWorkflowFailure';
|
|
319
|
+
case 'canceledFailureInfo':
|
|
320
|
+
return 'CanceledFailure';
|
|
321
|
+
case 'terminatedFailureInfo':
|
|
322
|
+
return 'TerminatedFailure';
|
|
323
|
+
case 'serverFailureInfo':
|
|
324
|
+
return 'ServerFailure';
|
|
325
|
+
case 'resetWorkflowFailureInfo':
|
|
326
|
+
return 'ResetWorkflowFailure';
|
|
327
|
+
default:
|
|
328
|
+
return failure.failureInfo?.case ?? failure.source ?? failure.message ?? undefined;
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
const resolveCommandMismatchMetadata = (expectedEntry, actualEntry) => {
|
|
332
|
+
const expectedMetadata = expectedEntry?.metadata;
|
|
333
|
+
const actualMetadata = actualEntry?.metadata;
|
|
334
|
+
const workflowTaskCompletedEventId = expectedMetadata?.workflowTaskCompletedEventId ?? actualMetadata?.workflowTaskCompletedEventId ?? null;
|
|
335
|
+
const eventType = expectedMetadata?.eventType ?? actualMetadata?.eventType;
|
|
336
|
+
return {
|
|
337
|
+
expectedEventId: expectedMetadata?.eventId ?? null,
|
|
338
|
+
actualEventId: actualMetadata?.eventId ?? null,
|
|
339
|
+
workflowTaskCompletedEventId,
|
|
340
|
+
eventType,
|
|
341
|
+
};
|
|
342
|
+
};
|
|
343
|
+
const reconstructDeterminismState = (events, intake, failureMetadata) => Effect.gen(function* () {
|
|
344
|
+
let sequence = 0;
|
|
345
|
+
const commandHistory = [];
|
|
346
|
+
for (const event of events) {
|
|
347
|
+
switch (event.eventType) {
|
|
348
|
+
case EventType.ACTIVITY_TASK_SCHEDULED: {
|
|
349
|
+
if (event.attributes?.case !== 'activityTaskScheduledEventAttributes') {
|
|
350
|
+
break;
|
|
351
|
+
}
|
|
352
|
+
const intent = yield* fromActivityTaskScheduled(event.attributes.value, sequence, intake);
|
|
353
|
+
if (intent) {
|
|
354
|
+
commandHistory.push({
|
|
355
|
+
intent,
|
|
356
|
+
metadata: buildCommandMetadata(event, event.attributes.value),
|
|
357
|
+
});
|
|
358
|
+
sequence += 1;
|
|
359
|
+
}
|
|
360
|
+
break;
|
|
361
|
+
}
|
|
362
|
+
case EventType.TIMER_STARTED: {
|
|
363
|
+
if (event.attributes?.case !== 'timerStartedEventAttributes') {
|
|
364
|
+
break;
|
|
365
|
+
}
|
|
366
|
+
const intent = fromTimerStarted(event.attributes.value, sequence);
|
|
367
|
+
if (intent) {
|
|
368
|
+
commandHistory.push({
|
|
369
|
+
intent,
|
|
370
|
+
metadata: buildCommandMetadata(event, event.attributes.value),
|
|
371
|
+
});
|
|
372
|
+
sequence += 1;
|
|
373
|
+
}
|
|
374
|
+
break;
|
|
375
|
+
}
|
|
376
|
+
case EventType.START_CHILD_WORKFLOW_EXECUTION_INITIATED: {
|
|
377
|
+
if (event.attributes?.case !== 'startChildWorkflowExecutionInitiatedEventAttributes') {
|
|
378
|
+
break;
|
|
379
|
+
}
|
|
380
|
+
const intent = yield* fromStartChildWorkflow(event.attributes.value, sequence, intake);
|
|
381
|
+
if (intent) {
|
|
382
|
+
commandHistory.push({
|
|
383
|
+
intent,
|
|
384
|
+
metadata: buildCommandMetadata(event, event.attributes.value),
|
|
385
|
+
});
|
|
386
|
+
sequence += 1;
|
|
387
|
+
}
|
|
388
|
+
break;
|
|
389
|
+
}
|
|
390
|
+
case EventType.SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_INITIATED: {
|
|
391
|
+
if (event.attributes?.case !== 'signalExternalWorkflowExecutionInitiatedEventAttributes') {
|
|
392
|
+
break;
|
|
393
|
+
}
|
|
394
|
+
const intent = yield* fromSignalExternalWorkflow(event.attributes.value, sequence, intake);
|
|
395
|
+
if (intent) {
|
|
396
|
+
commandHistory.push({
|
|
397
|
+
intent,
|
|
398
|
+
metadata: buildCommandMetadata(event, event.attributes.value),
|
|
399
|
+
});
|
|
400
|
+
sequence += 1;
|
|
401
|
+
}
|
|
402
|
+
break;
|
|
403
|
+
}
|
|
404
|
+
case EventType.WORKFLOW_EXECUTION_CONTINUED_AS_NEW: {
|
|
405
|
+
if (event.attributes?.case !== 'workflowExecutionContinuedAsNewEventAttributes') {
|
|
406
|
+
break;
|
|
407
|
+
}
|
|
408
|
+
const intent = yield* fromContinueAsNew(event.attributes.value, sequence, intake);
|
|
409
|
+
if (intent) {
|
|
410
|
+
commandHistory.push({
|
|
411
|
+
intent,
|
|
412
|
+
metadata: buildCommandMetadata(event, event.attributes.value),
|
|
413
|
+
});
|
|
414
|
+
sequence += 1;
|
|
415
|
+
}
|
|
416
|
+
break;
|
|
417
|
+
}
|
|
418
|
+
default:
|
|
419
|
+
break;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
return {
|
|
423
|
+
determinismState: {
|
|
424
|
+
commandHistory,
|
|
425
|
+
randomValues: [],
|
|
426
|
+
timeValues: [],
|
|
427
|
+
...(failureMetadata ? { failureMetadata } : {}),
|
|
428
|
+
},
|
|
429
|
+
lastEventId: resolveHistoryLastEventId(events),
|
|
430
|
+
hasDeterminismMarker: false,
|
|
431
|
+
};
|
|
432
|
+
});
|
|
433
|
+
const fromActivityTaskScheduled = (attributes, sequence, intake) => Effect.gen(function* () {
|
|
434
|
+
const activityType = attributes.activityType?.name;
|
|
435
|
+
if (!activityType) {
|
|
436
|
+
return undefined;
|
|
437
|
+
}
|
|
438
|
+
const input = yield* decodePayloadArray(intake.dataConverter, attributes.input);
|
|
439
|
+
const eagerAttributes = attributes;
|
|
440
|
+
const intent = {
|
|
441
|
+
id: `schedule-activity-${sequence}`,
|
|
442
|
+
kind: 'schedule-activity',
|
|
443
|
+
sequence,
|
|
444
|
+
activityType,
|
|
445
|
+
activityId: attributes.activityId || `activity-${sequence}`,
|
|
446
|
+
taskQueue: attributes.taskQueue?.name ?? intake.info.taskQueue,
|
|
447
|
+
input,
|
|
448
|
+
header: attributes.header,
|
|
449
|
+
timeouts: {
|
|
450
|
+
scheduleToCloseTimeoutMs: durationToMillis(attributes.scheduleToCloseTimeout),
|
|
451
|
+
scheduleToStartTimeoutMs: durationToMillis(attributes.scheduleToStartTimeout),
|
|
452
|
+
startToCloseTimeoutMs: durationToMillis(attributes.startToCloseTimeout),
|
|
453
|
+
heartbeatTimeoutMs: durationToMillis(attributes.heartbeatTimeout),
|
|
454
|
+
},
|
|
455
|
+
retry: convertRetryPolicy(attributes.retryPolicy),
|
|
456
|
+
requestEagerExecution: eagerAttributes.requestEagerExecution ?? undefined,
|
|
457
|
+
};
|
|
458
|
+
return intent;
|
|
459
|
+
});
|
|
460
|
+
const fromTimerStarted = (attributes, sequence) => {
|
|
461
|
+
const timeout = durationToMillis(attributes.startToFireTimeout);
|
|
462
|
+
if (timeout === undefined) {
|
|
463
|
+
return undefined;
|
|
464
|
+
}
|
|
465
|
+
const timerId = attributes.timerId || `timer-${sequence}`;
|
|
466
|
+
return {
|
|
467
|
+
id: `start-timer-${sequence}`,
|
|
468
|
+
kind: 'start-timer',
|
|
469
|
+
sequence,
|
|
470
|
+
timerId,
|
|
471
|
+
timeoutMs: timeout,
|
|
472
|
+
};
|
|
473
|
+
};
|
|
474
|
+
const fromStartChildWorkflow = (attributes, sequence, intake) => Effect.gen(function* () {
|
|
475
|
+
const workflowType = attributes.workflowType?.name;
|
|
476
|
+
if (!workflowType) {
|
|
477
|
+
return undefined;
|
|
478
|
+
}
|
|
479
|
+
const input = yield* decodePayloadArray(intake.dataConverter, attributes.input);
|
|
480
|
+
const parentClosePolicy = attributes.parentClosePolicy !== undefined && attributes.parentClosePolicy !== ParentClosePolicy.UNSPECIFIED
|
|
481
|
+
? attributes.parentClosePolicy
|
|
482
|
+
: undefined;
|
|
483
|
+
const workflowIdReusePolicy = attributes.workflowIdReusePolicy !== undefined &&
|
|
484
|
+
attributes.workflowIdReusePolicy !== WorkflowIdReusePolicy.UNSPECIFIED
|
|
485
|
+
? attributes.workflowIdReusePolicy
|
|
486
|
+
: undefined;
|
|
487
|
+
const intent = {
|
|
488
|
+
id: `start-child-workflow-${sequence}`,
|
|
489
|
+
kind: 'start-child-workflow',
|
|
490
|
+
sequence,
|
|
491
|
+
workflowType,
|
|
492
|
+
workflowId: attributes.workflowId || `${intake.info.workflowId}-child-${sequence}`,
|
|
493
|
+
namespace: attributes.namespace || intake.info.namespace,
|
|
494
|
+
taskQueue: attributes.taskQueue?.name ?? intake.info.taskQueue,
|
|
495
|
+
input,
|
|
496
|
+
timeouts: {
|
|
497
|
+
workflowExecutionTimeoutMs: durationToMillis(attributes.workflowExecutionTimeout),
|
|
498
|
+
workflowRunTimeoutMs: durationToMillis(attributes.workflowRunTimeout),
|
|
499
|
+
workflowTaskTimeoutMs: durationToMillis(attributes.workflowTaskTimeout),
|
|
500
|
+
},
|
|
501
|
+
parentClosePolicy,
|
|
502
|
+
workflowIdReusePolicy,
|
|
503
|
+
retry: convertRetryPolicy(attributes.retryPolicy),
|
|
504
|
+
cronSchedule: attributes.cronSchedule || undefined,
|
|
505
|
+
header: attributes.header,
|
|
506
|
+
memo: attributes.memo,
|
|
507
|
+
searchAttributes: attributes.searchAttributes,
|
|
508
|
+
};
|
|
509
|
+
return intent;
|
|
510
|
+
});
|
|
511
|
+
const fromSignalExternalWorkflow = (attributes, sequence, intake) => Effect.gen(function* () {
|
|
512
|
+
if (!attributes.signalName) {
|
|
513
|
+
return undefined;
|
|
514
|
+
}
|
|
515
|
+
const input = yield* decodePayloadArray(intake.dataConverter, attributes.input);
|
|
516
|
+
const intent = {
|
|
517
|
+
id: `signal-external-${sequence}`,
|
|
518
|
+
kind: 'signal-external-workflow',
|
|
519
|
+
sequence,
|
|
520
|
+
namespace: attributes.namespace || intake.info.namespace,
|
|
521
|
+
workflowId: attributes.workflowExecution?.workflowId ?? intake.info.workflowId,
|
|
522
|
+
runId: attributes.workflowExecution?.runId || undefined,
|
|
523
|
+
signalName: attributes.signalName,
|
|
524
|
+
input,
|
|
525
|
+
childWorkflowOnly: attributes.childWorkflowOnly ?? false,
|
|
526
|
+
header: attributes.header,
|
|
527
|
+
};
|
|
528
|
+
return intent;
|
|
529
|
+
});
|
|
530
|
+
const fromContinueAsNew = (attributes, sequence, intake) => Effect.gen(function* () {
|
|
531
|
+
const input = yield* decodePayloadArray(intake.dataConverter, attributes.input);
|
|
532
|
+
const extendedAttributes = attributes;
|
|
533
|
+
const intent = {
|
|
534
|
+
id: `continue-as-new-${sequence}`,
|
|
535
|
+
kind: 'continue-as-new',
|
|
536
|
+
sequence,
|
|
537
|
+
workflowType: attributes.workflowType?.name ?? intake.info.workflowType,
|
|
538
|
+
taskQueue: attributes.taskQueue?.name ?? intake.info.taskQueue,
|
|
539
|
+
input,
|
|
540
|
+
timeouts: {
|
|
541
|
+
workflowRunTimeoutMs: durationToMillis(attributes.workflowRunTimeout),
|
|
542
|
+
workflowTaskTimeoutMs: durationToMillis(attributes.workflowTaskTimeout),
|
|
543
|
+
},
|
|
544
|
+
backoffStartIntervalMs: durationToMillis(attributes.backoffStartInterval),
|
|
545
|
+
retry: convertRetryPolicy(extendedAttributes.retryPolicy),
|
|
546
|
+
memo: attributes.memo,
|
|
547
|
+
searchAttributes: attributes.searchAttributes,
|
|
548
|
+
header: attributes.header,
|
|
549
|
+
cronSchedule: extendedAttributes.cronSchedule || undefined,
|
|
550
|
+
};
|
|
551
|
+
return intent;
|
|
552
|
+
});
|
|
553
|
+
const decodePayloadArray = (converter, payloads) => Effect.tryPromise(async () => await decodePayloadsToValues(converter, payloads?.payloads ?? []));
|
|
554
|
+
const convertRetryPolicy = (policy) => {
|
|
555
|
+
if (!policy) {
|
|
556
|
+
return undefined;
|
|
557
|
+
}
|
|
558
|
+
const initialIntervalMs = durationToMillis(policy.initialInterval);
|
|
559
|
+
const maximumIntervalMs = durationToMillis(policy.maximumInterval);
|
|
560
|
+
const backoffCoefficient = policy.backoffCoefficient !== 0 ? policy.backoffCoefficient : undefined;
|
|
561
|
+
const maximumAttempts = policy.maximumAttempts > 0 ? policy.maximumAttempts : undefined;
|
|
562
|
+
const nonRetryable = policy.nonRetryableErrorTypes.length > 0 ? [...policy.nonRetryableErrorTypes] : undefined;
|
|
563
|
+
if (initialIntervalMs === undefined &&
|
|
564
|
+
maximumIntervalMs === undefined &&
|
|
565
|
+
backoffCoefficient === undefined &&
|
|
566
|
+
maximumAttempts === undefined &&
|
|
567
|
+
(nonRetryable === undefined || nonRetryable.length === 0)) {
|
|
568
|
+
return undefined;
|
|
569
|
+
}
|
|
570
|
+
return {
|
|
571
|
+
...(initialIntervalMs !== undefined ? { initialIntervalMs } : {}),
|
|
572
|
+
...(backoffCoefficient !== undefined ? { backoffCoefficient } : {}),
|
|
573
|
+
...(maximumIntervalMs !== undefined ? { maximumIntervalMs } : {}),
|
|
574
|
+
...(maximumAttempts !== undefined ? { maximumAttempts } : {}),
|
|
575
|
+
...(nonRetryable !== undefined ? { nonRetryableErrorTypes: nonRetryable } : {}),
|
|
576
|
+
};
|
|
577
|
+
};
|
|
578
|
+
const sanitizeDeterminismMarkerEnvelope = (input) => {
|
|
579
|
+
const schemaVersion = input.schemaVersion;
|
|
580
|
+
if (schemaVersion !== DETERMINISM_MARKER_SCHEMA_VERSION) {
|
|
581
|
+
throw new Error(`Unsupported determinism marker schema version: ${String(schemaVersion)}`);
|
|
582
|
+
}
|
|
583
|
+
const workflow = sanitizeWorkflowInfo(input.workflow);
|
|
584
|
+
const determinismState = sanitizeDeterminismState(input.determinismState);
|
|
585
|
+
const lastEventId = normalizeEventId(input.lastEventId);
|
|
586
|
+
const recordedAt = sanitizeRecordedAt(input.recordedAtIso);
|
|
587
|
+
return {
|
|
588
|
+
schemaVersion: DETERMINISM_MARKER_SCHEMA_VERSION,
|
|
589
|
+
workflow,
|
|
590
|
+
determinismState,
|
|
591
|
+
lastEventId,
|
|
592
|
+
recordedAtIso: recordedAt,
|
|
593
|
+
};
|
|
594
|
+
};
|
|
595
|
+
const sanitizeWorkflowInfo = (value) => {
|
|
596
|
+
if (!isRecord(value)) {
|
|
597
|
+
throw new Error('Determinism marker missing workflow metadata');
|
|
598
|
+
}
|
|
599
|
+
return {
|
|
600
|
+
namespace: coerceString(value.namespace, 'workflow.namespace'),
|
|
601
|
+
taskQueue: coerceString(value.taskQueue, 'workflow.taskQueue'),
|
|
602
|
+
workflowId: coerceString(value.workflowId, 'workflow.workflowId'),
|
|
603
|
+
runId: coerceString(value.runId, 'workflow.runId'),
|
|
604
|
+
workflowType: coerceString(value.workflowType, 'workflow.workflowType'),
|
|
605
|
+
};
|
|
606
|
+
};
|
|
607
|
+
const sanitizeDeterminismState = (value) => {
|
|
608
|
+
if (!isRecord(value)) {
|
|
609
|
+
throw new Error('Determinism marker missing determinism state');
|
|
610
|
+
}
|
|
611
|
+
const commandHistoryRaw = value.commandHistory;
|
|
612
|
+
const randomValuesRaw = value.randomValues;
|
|
613
|
+
const timeValuesRaw = value.timeValues;
|
|
614
|
+
if (!Array.isArray(commandHistoryRaw) || !Array.isArray(randomValuesRaw) || !Array.isArray(timeValuesRaw)) {
|
|
615
|
+
throw new Error('Determinism marker contained invalid determinism state shape');
|
|
616
|
+
}
|
|
617
|
+
const commandHistory = commandHistoryRaw.map((entry, index) => {
|
|
618
|
+
if (!isRecord(entry) || entry.intent === undefined) {
|
|
619
|
+
throw new Error(`Determinism marker command history entry ${index} is invalid`);
|
|
620
|
+
}
|
|
621
|
+
const metadata = sanitizeCommandMetadata(entry.metadata, index);
|
|
622
|
+
return {
|
|
623
|
+
intent: entry.intent,
|
|
624
|
+
...(metadata ? { metadata } : {}),
|
|
625
|
+
};
|
|
626
|
+
});
|
|
627
|
+
const randomValues = randomValuesRaw.map((val, index) => coerceNumber(val, `determinism.randomValues[${index}]`));
|
|
628
|
+
const timeValues = timeValuesRaw.map((val, index) => coerceNumber(val, `determinism.timeValues[${index}]`));
|
|
629
|
+
const failureMetadata = sanitizeFailureMetadata(value.failureMetadata);
|
|
630
|
+
return {
|
|
631
|
+
commandHistory,
|
|
632
|
+
randomValues,
|
|
633
|
+
timeValues,
|
|
634
|
+
...(failureMetadata ? { failureMetadata } : {}),
|
|
635
|
+
};
|
|
636
|
+
};
|
|
637
|
+
const sanitizeCommandMetadata = (value, index) => {
|
|
638
|
+
if (value === undefined || value === null) {
|
|
639
|
+
return undefined;
|
|
640
|
+
}
|
|
641
|
+
if (!isRecord(value)) {
|
|
642
|
+
throw new Error(`Determinism marker command history entry ${index} metadata is invalid`);
|
|
643
|
+
}
|
|
644
|
+
const eventId = normalizeOptionalEventId(value.eventId, `determinism.commandHistory[${index}].metadata.eventId`);
|
|
645
|
+
const workflowTaskCompletedEventId = normalizeOptionalEventId(value.workflowTaskCompletedEventId, `determinism.commandHistory[${index}].metadata.workflowTaskCompletedEventId`);
|
|
646
|
+
const eventTypeValue = value.eventType;
|
|
647
|
+
const eventType = typeof eventTypeValue === 'number' && Number.isFinite(eventTypeValue) ? eventTypeValue : undefined;
|
|
648
|
+
const hasMetadata = eventId || workflowTaskCompletedEventId || eventType !== undefined;
|
|
649
|
+
if (!hasMetadata) {
|
|
650
|
+
return undefined;
|
|
651
|
+
}
|
|
652
|
+
return {
|
|
653
|
+
...(eventId ? { eventId } : {}),
|
|
654
|
+
...(workflowTaskCompletedEventId ? { workflowTaskCompletedEventId } : {}),
|
|
655
|
+
...(eventType !== undefined ? { eventType } : {}),
|
|
656
|
+
};
|
|
657
|
+
};
|
|
658
|
+
const sanitizeFailureMetadata = (value) => {
|
|
659
|
+
if (value === undefined || value === null) {
|
|
660
|
+
return undefined;
|
|
661
|
+
}
|
|
662
|
+
if (!isRecord(value)) {
|
|
663
|
+
throw new Error('Determinism marker contained invalid failure metadata');
|
|
664
|
+
}
|
|
665
|
+
const eventId = normalizeOptionalEventId(value.eventId, 'determinism.failureMetadata.eventId');
|
|
666
|
+
const failureType = coerceOptionalString(value.failureType, 'determinism.failureMetadata.failureType');
|
|
667
|
+
const failureMessage = coerceOptionalString(value.failureMessage, 'determinism.failureMetadata.failureMessage');
|
|
668
|
+
const workflowEventType = typeof value.eventType === 'number' && Number.isFinite(value.eventType) ? value.eventType : undefined;
|
|
669
|
+
const retryState = coerceOptionalNumber(value.retryState, 'determinism.failureMetadata.retryState');
|
|
670
|
+
if (!eventId && !failureType && !failureMessage && workflowEventType === undefined && retryState === undefined) {
|
|
671
|
+
return undefined;
|
|
672
|
+
}
|
|
673
|
+
return {
|
|
674
|
+
...(eventId ? { eventId } : {}),
|
|
675
|
+
...(workflowEventType !== undefined ? { eventType: workflowEventType } : {}),
|
|
676
|
+
...(failureType ? { failureType } : {}),
|
|
677
|
+
...(failureMessage ? { failureMessage } : {}),
|
|
678
|
+
...(retryState !== undefined ? { retryState } : {}),
|
|
679
|
+
};
|
|
680
|
+
};
|
|
681
|
+
const sanitizeRecordedAt = (value) => {
|
|
682
|
+
if (typeof value === 'string' && value.length > 0) {
|
|
683
|
+
return value;
|
|
684
|
+
}
|
|
685
|
+
if (value instanceof Date) {
|
|
686
|
+
return value.toISOString();
|
|
687
|
+
}
|
|
688
|
+
throw new Error('Determinism marker missing recordedAt timestamp');
|
|
689
|
+
};
|
|
690
|
+
const normalizeEventId = (value) => {
|
|
691
|
+
if (value === null || value === undefined) {
|
|
692
|
+
return null;
|
|
693
|
+
}
|
|
694
|
+
if (typeof value === 'string' && value.length > 0) {
|
|
695
|
+
return value;
|
|
696
|
+
}
|
|
697
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
698
|
+
return value.toString();
|
|
699
|
+
}
|
|
700
|
+
if (typeof value === 'bigint') {
|
|
701
|
+
return value.toString();
|
|
702
|
+
}
|
|
703
|
+
throw new Error(`Determinism marker contained invalid lastEventId: ${String(value)}`);
|
|
704
|
+
};
|
|
705
|
+
const coerceString = (value, label) => {
|
|
706
|
+
if (typeof value === 'string' && value.length > 0) {
|
|
707
|
+
return value;
|
|
708
|
+
}
|
|
709
|
+
throw new Error(`Determinism marker missing ${label}`);
|
|
710
|
+
};
|
|
711
|
+
const coerceOptionalString = (value, label) => {
|
|
712
|
+
if (value === undefined || value === null) {
|
|
713
|
+
return undefined;
|
|
714
|
+
}
|
|
715
|
+
if (typeof value !== 'string') {
|
|
716
|
+
throw new Error(`Determinism marker contained invalid ${label}`);
|
|
717
|
+
}
|
|
718
|
+
return value.length > 0 ? value : undefined;
|
|
719
|
+
};
|
|
720
|
+
const coerceNumber = (value, label) => {
|
|
721
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
722
|
+
return value;
|
|
723
|
+
}
|
|
724
|
+
if (typeof value === 'bigint') {
|
|
725
|
+
const numeric = Number(value);
|
|
726
|
+
if (Number.isFinite(numeric)) {
|
|
727
|
+
return numeric;
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
throw new Error(`Determinism marker contained non-finite ${label}`);
|
|
731
|
+
};
|
|
732
|
+
const coerceOptionalNumber = (value, label) => {
|
|
733
|
+
if (value === undefined || value === null) {
|
|
734
|
+
return undefined;
|
|
735
|
+
}
|
|
736
|
+
return coerceNumber(value, label);
|
|
737
|
+
};
|
|
738
|
+
const normalizeOptionalEventId = (value, label) => {
|
|
739
|
+
if (value === undefined || value === null) {
|
|
740
|
+
return undefined;
|
|
741
|
+
}
|
|
742
|
+
try {
|
|
743
|
+
return normalizeEventId(value) ?? undefined;
|
|
744
|
+
}
|
|
745
|
+
catch {
|
|
746
|
+
throw new Error(`Determinism marker contained invalid ${label}`);
|
|
747
|
+
}
|
|
748
|
+
};
|
|
749
|
+
const valuesEqual = (expected, actual) => {
|
|
750
|
+
if (expected === undefined && actual === undefined) {
|
|
751
|
+
return true;
|
|
752
|
+
}
|
|
753
|
+
if (expected === undefined || actual === undefined) {
|
|
754
|
+
return false;
|
|
755
|
+
}
|
|
756
|
+
return Object.is(expected, actual);
|
|
757
|
+
};
|
|
758
|
+
const isRecord = (value) => typeof value === 'object' && value !== null;
|
|
759
|
+
//# sourceMappingURL=replay.js.map
|