@temelj/workflow 0.0.0-alpha.2 → 0.0.0-alpha.4
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 +394 -2
- package/dist/attributes.d.mts +11 -9
- package/dist/attributes.mjs +23 -5
- package/dist/bundle.d.mts +5 -23
- package/dist/bundle.mjs +2 -18
- package/dist/client/create.d.mts +26 -23
- package/dist/client/create.mjs +26 -32
- package/dist/client/facades.d.mts +12 -18
- package/dist/client/facades.mjs +102 -93
- package/dist/client/mod.mjs +1 -2
- package/dist/client/run-handle.d.mts +17 -54
- package/dist/client/run-handle.mjs +35 -105
- package/dist/client/worker-options.d.mts +8 -8
- package/dist/client/worker-options.mjs +11 -11
- package/dist/cloudflare/cloudflare.d.mts +4 -5
- package/dist/cloudflare/codec.d.mts +28 -13
- package/dist/cloudflare/codec.mjs +40 -17
- package/dist/cloudflare/entrypoint.d.mts +3 -4
- package/dist/cloudflare/entrypoint.mjs +4 -3
- package/dist/cloudflare/execution.d.mts +3 -4
- package/dist/cloudflare/execution.mjs +20 -13
- package/dist/cloudflare/host.d.mts +6 -7
- package/dist/cloudflare/host.mjs +7 -6
- package/dist/cloudflare/mod.d.mts +4 -4
- package/dist/cloudflare/mod.mjs +2 -2
- package/dist/cloudflare/name.d.mts +3 -4
- package/dist/cloudflare/name.mjs +3 -3
- package/dist/cloudflare/registry.d.mts +3 -23
- package/dist/cloudflare/registry.mjs +2 -20
- package/dist/cloudflare/runtime.d.mts +11 -18
- package/dist/cloudflare/runtime.mjs +52 -73
- package/dist/cloudflare/step.d.mts +6 -6
- package/dist/cloudflare/step.mjs +69 -57
- package/dist/cloudflare/types.d.mts +17 -36
- package/dist/collection.d.mts +8 -11
- package/dist/collection.mjs +10 -14
- package/dist/compiled-function.d.mts +14 -19
- package/dist/compiled-function.mjs +12 -24
- package/dist/compiled.d.mts +4 -0
- package/dist/compiled.mjs +4 -0
- package/dist/compiler/ast.d.mts +26 -0
- package/dist/{vite → compiler}/ast.mjs +24 -16
- package/dist/{vite → compiler}/error.d.mts +4 -6
- package/dist/{vite → compiler}/error.mjs +14 -16
- package/dist/compiler/manifest.d.mts +6 -0
- package/dist/{vite → compiler}/manifest.mjs +9 -7
- package/dist/compiler/plugin.d.mts +7 -0
- package/dist/{vite → compiler}/plugin.mjs +45 -46
- package/dist/compiler/safety.d.mts +12 -0
- package/dist/{vite → compiler}/safety.mjs +5 -11
- package/dist/{vite → compiler}/source-edit.d.mts +3 -4
- package/dist/{vite → compiler}/source-edit.mjs +1 -1
- package/dist/{vite → compiler}/source-map.d.mts +4 -3
- package/dist/{vite → compiler}/source-map.mjs +3 -3
- package/dist/compiler/source.d.mts +7 -0
- package/dist/{vite → compiler}/source.mjs +1 -1
- package/dist/compiler/transform.d.mts +12 -0
- package/dist/{vite → compiler}/transform.mjs +37 -38
- package/dist/definition.d.mts +17 -25
- package/dist/definition.mjs +19 -35
- package/dist/engine/child-workflow.d.mts +5 -9
- package/dist/engine/child-workflow.mjs +46 -67
- package/dist/engine/command-identity.d.mts +5 -6
- package/dist/engine/command-identity.mjs +9 -5
- package/dist/engine/context.d.mts +17 -0
- package/dist/engine/create.d.mts +36 -94
- package/dist/engine/create.mjs +55 -260
- package/dist/engine/deterministic.d.mts +6 -11
- package/dist/engine/deterministic.mjs +47 -68
- package/dist/engine/durable-command.d.mts +5 -5
- package/dist/engine/durable-command.mjs +2 -2
- package/dist/engine/execution-service.d.mts +20 -24
- package/dist/engine/execution-service.mjs +54 -52
- package/dist/engine/hooks.d.mts +17 -39
- package/dist/engine/hooks.mjs +73 -94
- package/dist/engine/inspection.d.mts +23 -15
- package/dist/engine/inspection.mjs +55 -29
- package/dist/engine/lifecycle.d.mts +6 -12
- package/dist/engine/lifecycle.mjs +5 -5
- package/dist/engine/lock-replay.d.mts +8 -15
- package/dist/engine/lock-replay.mjs +12 -25
- package/dist/engine/lock.d.mts +10 -15
- package/dist/engine/lock.mjs +65 -51
- package/dist/engine/message.d.mts +14 -34
- package/dist/engine/message.mjs +94 -127
- package/dist/engine/observation.d.mts +9 -11
- package/dist/engine/observation.mjs +18 -27
- package/dist/engine/replay.d.mts +18 -19
- package/dist/engine/replay.mjs +32 -56
- package/dist/engine/resume.d.mts +16 -0
- package/dist/engine/resume.mjs +24 -0
- package/dist/engine/retry.d.mts +15 -19
- package/dist/engine/retry.mjs +17 -17
- package/dist/engine/run-data.d.mts +4 -8
- package/dist/engine/run-data.mjs +24 -22
- package/dist/engine/run-service.d.mts +24 -33
- package/dist/engine/run-service.mjs +125 -93
- package/dist/engine/run-utils.d.mts +11 -13
- package/dist/engine/run-utils.mjs +23 -46
- package/dist/engine/schedule.d.mts +8 -22
- package/dist/engine/schedule.mjs +37 -34
- package/dist/engine/serialization.d.mts +9 -6
- package/dist/engine/serialization.mjs +30 -21
- package/dist/engine/signals.d.mts +23 -0
- package/dist/engine/signals.mjs +41 -0
- package/dist/engine/start.d.mts +18 -0
- package/dist/engine/start.mjs +88 -0
- package/dist/engine/state.d.mts +37 -67
- package/dist/engine/state.mjs +127 -282
- package/dist/engine/step-api.d.mts +5 -8
- package/dist/engine/step-api.mjs +16 -16
- package/dist/engine/stream-reader.d.mts +12 -0
- package/dist/engine/stream-reader.mjs +154 -0
- package/dist/engine/stream.d.mts +9 -54
- package/dist/engine/stream.mjs +54 -196
- package/dist/engine/summary/recovery.d.mts +35 -0
- package/dist/engine/summary/recovery.mjs +363 -0
- package/dist/engine/summary/runs.d.mts +43 -0
- package/dist/engine/summary/runs.mjs +294 -0
- package/dist/engine/summary/step-attempts.d.mts +5 -10
- package/dist/engine/summary/step-attempts.mjs +157 -36
- package/dist/engine/summary/tally.d.mts +44 -0
- package/dist/engine/summary/tally.mjs +142 -0
- package/dist/engine/task.d.mts +4 -5
- package/dist/engine/task.mjs +40 -48
- package/dist/errors/base.d.mts +17 -77
- package/dist/errors/base.mjs +26 -327
- package/dist/errors/capability.d.mts +3 -6
- package/dist/errors/capability.mjs +4 -8
- package/dist/errors/codes.d.mts +116 -0
- package/dist/{types/error-code.mjs → errors/codes.mjs} +2 -17
- package/dist/errors/definition.d.mts +3 -17
- package/dist/errors/definition.mjs +5 -42
- package/dist/errors/failures.d.mts +17 -51
- package/dist/errors/failures.mjs +35 -102
- package/dist/errors/hook.d.mts +5 -9
- package/dist/errors/hook.mjs +4 -16
- package/dist/errors/implementation.d.mts +3 -6
- package/dist/errors/implementation.mjs +7 -12
- package/dist/errors/lock.d.mts +7 -20
- package/dist/errors/lock.mjs +8 -44
- package/dist/errors/message.d.mts +14 -59
- package/dist/errors/message.mjs +13 -39
- package/dist/errors/mod.d.mts +4 -5
- package/dist/errors/mod.mjs +5 -7
- package/dist/errors/records.d.mts +10 -4
- package/dist/errors/records.mjs +256 -256
- package/dist/errors/run.d.mts +27 -68
- package/dist/errors/run.mjs +31 -85
- package/dist/errors/schedule.d.mts +7 -18
- package/dist/errors/schedule.mjs +7 -39
- package/dist/errors/step.d.mts +12 -45
- package/dist/errors/step.mjs +13 -34
- package/dist/errors/stream.d.mts +8 -16
- package/dist/errors/stream.mjs +7 -41
- package/dist/esbuild.d.mts +6 -4
- package/dist/esbuild.mjs +2 -1
- package/dist/events/descriptors.d.mts +12 -241
- package/dist/events/descriptors.mjs +12 -5
- package/dist/history/projection.d.mts +4 -6
- package/dist/history/projection.mjs +22 -26
- package/dist/history/replay-projection.d.mts +44 -48
- package/dist/history/replay-projection.mjs +41 -50
- package/dist/history/{mod.d.mts → replay.d.mts} +16 -21
- package/dist/history/{mod.mjs → replay.mjs} +21 -25
- package/dist/history/sequencer.d.mts +10 -11
- package/dist/history/sequencer.mjs +11 -7
- package/dist/history/step-attempts.d.mts +4 -7
- package/dist/history/step-attempts.mjs +8 -9
- package/dist/history/timeline.d.mts +4 -13
- package/dist/history/timeline.mjs +46 -265
- package/dist/history/validator.d.mts +5 -7
- package/dist/history/validator.mjs +9 -24
- package/dist/hook-token.d.mts +7 -0
- package/dist/hook-token.mjs +32 -0
- package/dist/ids.d.mts +8 -0
- package/dist/ids.mjs +21 -0
- package/dist/message-options.d.mts +11 -5
- package/dist/message-options.mjs +9 -7
- package/dist/mod.d.mts +32 -36
- package/dist/mod.mjs +9 -13
- package/dist/otel/metrics.d.mts +31 -0
- package/dist/otel/metrics.mjs +60 -0
- package/dist/otel/mod.d.mts +3 -0
- package/dist/otel/mod.mjs +3 -0
- package/dist/otel/spans.d.mts +24 -0
- package/dist/otel/spans.mjs +218 -0
- package/dist/otel/support.d.mts +15 -8
- package/dist/otel/support.mjs +18 -40
- package/dist/{otel.d.mts → otel/telemetry.d.mts} +5 -6
- package/dist/otel/telemetry.mjs +305 -0
- package/dist/pagination.d.mts +6 -12
- package/dist/pagination.mjs +10 -14
- package/dist/registry.d.mts +8 -5
- package/dist/registry.mjs +19 -10
- package/dist/rolldown.d.mts +6 -4
- package/dist/rolldown.mjs +2 -1
- package/dist/rollup.d.mts +6 -4
- package/dist/rollup.mjs +2 -1
- package/dist/rspack.d.mts +6 -4
- package/dist/rspack.mjs +2 -1
- package/dist/run-status.d.mts +29 -0
- package/dist/run-status.mjs +42 -0
- package/dist/schema/common.d.mts +22 -0
- package/dist/schema/common.mjs +54 -0
- package/dist/schema/error.d.mts +17 -0
- package/dist/schema/error.mjs +39 -0
- package/dist/schema/events.d.mts +446 -0
- package/dist/schema/events.mjs +235 -0
- package/dist/schema/pagination.d.mts +5 -0
- package/dist/schema/pagination.mjs +11 -0
- package/dist/schema/persisted-value.d.mts +8 -0
- package/dist/schema/persisted-value.mjs +94 -0
- package/dist/schema/run.d.mts +51 -0
- package/dist/schema/run.mjs +88 -0
- package/dist/schema/store.d.mts +94 -0
- package/dist/schema/store.mjs +116 -0
- package/dist/step-definition.d.mts +4 -9
- package/dist/step-definition.mjs +2 -2
- package/dist/store/capabilities.d.mts +8 -9
- package/dist/store/capabilities.mjs +7 -7
- package/dist/store/cleanup.d.mts +9 -14
- package/dist/store/cleanup.mjs +86 -85
- package/dist/store/create.d.mts +28 -29
- package/dist/store/create.mjs +10 -11
- package/dist/store/events.d.mts +48 -0
- package/dist/store/events.mjs +263 -0
- package/dist/store/indexes.d.mts +25 -0
- package/dist/store/indexes.mjs +282 -0
- package/dist/store/instrumentation.d.mts +2 -3
- package/dist/store/instrumentation.mjs +30 -30
- package/dist/store/lock.d.mts +4 -5
- package/dist/store/lock.mjs +5 -7
- package/dist/store/materialization.d.mts +10 -17
- package/dist/store/materialization.mjs +39 -33
- package/dist/store/mod.d.mts +3 -3
- package/dist/store/mod.mjs +2 -2
- package/dist/store/query.d.mts +13 -17
- package/dist/store/query.mjs +13 -13
- package/dist/store/run.d.mts +25 -34
- package/dist/store/run.mjs +67 -108
- package/dist/store/schedule.d.mts +6 -8
- package/dist/store/schedule.mjs +11 -11
- package/dist/store/step-attempt.d.mts +9 -12
- package/dist/store/step-attempt.mjs +9 -9
- package/dist/store/storage-value.d.mts +3 -3
- package/dist/store/storage-value.mjs +17 -1
- package/dist/store/validation.d.mts +17 -20
- package/dist/store/validation.mjs +30 -33
- package/dist/store-keys.d.mts +35 -47
- package/dist/store-keys.mjs +9 -17
- package/dist/telemetry.d.mts +16 -16
- package/dist/telemetry.mjs +3 -3
- package/dist/temporal.d.mts +11 -16
- package/dist/temporal.mjs +8 -9
- package/dist/timer.d.mts +12 -10
- package/dist/timer.mjs +11 -3
- package/dist/types/cleanup.d.mts +13 -50
- package/dist/types/cleanup.mjs +1 -22
- package/dist/types/client.d.mts +101 -162
- package/dist/types/{vite.d.mts → compiler.d.mts} +17 -24
- package/dist/types/compiler.mjs +1 -0
- package/dist/types/definition.d.mts +22 -34
- package/dist/types/engine-options.d.mts +10 -17
- package/dist/types/engine.d.mts +15 -274
- package/dist/types/error.d.mts +15 -217
- package/dist/types/error.mjs +1 -48
- package/dist/types/events.d.mts +59 -2730
- package/dist/types/events.mjs +1 -283
- package/dist/types/hook.d.mts +27 -85
- package/dist/types/hook.mjs +1 -66
- package/dist/types/ids.d.mts +9 -0
- package/dist/types/ids.mjs +1 -0
- package/dist/types/lock.d.mts +8 -26
- package/dist/types/lock.mjs +1 -18
- package/dist/types/message.d.mts +29 -43
- package/dist/types/observation.d.mts +43 -58
- package/dist/types/pagination.d.mts +6 -22
- package/dist/types/pagination.mjs +1 -13
- package/dist/types/result.d.mts +11 -43
- package/dist/types/retry.d.mts +7 -14
- package/dist/types/run-list.d.mts +9 -11
- package/dist/types/run-options.d.mts +25 -32
- package/dist/types/run.d.mts +35 -315
- package/dist/types/run.mjs +1 -207
- package/dist/types/runtime.d.mts +33 -145
- package/dist/types/runtime.mjs +1 -21
- package/dist/types/schedule.d.mts +13 -72
- package/dist/types/schedule.mjs +1 -48
- package/dist/types/step-attempts.d.mts +65 -261
- package/dist/types/step-attempts.mjs +1 -43
- package/dist/types/step.d.mts +66 -77
- package/dist/types/step.mjs +1 -5
- package/dist/types/store.d.mts +50 -182
- package/dist/types/stream.d.mts +19 -40
- package/dist/types/summary.d.mts +174 -278
- package/dist/types/telemetry.d.mts +23 -28
- package/dist/types/telemetry.mjs +1 -9
- package/dist/types/timeline.d.mts +46 -233
- package/dist/types/worker.d.mts +22 -29
- package/dist/values.d.mts +15 -0
- package/dist/values.mjs +57 -0
- package/dist/vite.d.mts +5 -6
- package/dist/vite.mjs +3 -4
- package/dist/webpack.d.mts +6 -4
- package/dist/webpack.mjs +2 -1
- package/dist/worker/error.d.mts +2 -9
- package/dist/worker/error.mjs +20 -32
- package/dist/worker/missing-implementation.d.mts +19 -0
- package/dist/worker/missing-implementation.mjs +62 -0
- package/dist/worker/worker.d.mts +18 -0
- package/dist/{worker.mjs → worker/worker.mjs} +64 -118
- package/package.json +28 -47
- package/dist/engine/execution-api.d.mts +0 -29
- package/dist/engine/execution-api.mjs +0 -33
- package/dist/engine/inspection-api.d.mts +0 -34
- package/dist/engine/inspection-api.mjs +0 -78
- package/dist/engine/mod.d.mts +0 -4
- package/dist/engine/mod.mjs +0 -2
- package/dist/engine/recovery.d.mts +0 -26
- package/dist/engine/recovery.mjs +0 -92
- package/dist/engine/retry-policy.d.mts +0 -4
- package/dist/engine/retry-policy.mjs +0 -4
- package/dist/engine/start-api.d.mts +0 -30
- package/dist/engine/start-api.mjs +0 -99
- package/dist/engine/summary/active-events.d.mts +0 -34
- package/dist/engine/summary/active-events.mjs +0 -69
- package/dist/engine/summary/child-workflow-runs.d.mts +0 -24
- package/dist/engine/summary/child-workflow-runs.mjs +0 -138
- package/dist/engine/summary/child-workflow-waits.d.mts +0 -21
- package/dist/engine/summary/child-workflow-waits.mjs +0 -67
- package/dist/engine/summary/recovery-child-workflow-waits.d.mts +0 -11
- package/dist/engine/summary/recovery-child-workflow-waits.mjs +0 -89
- package/dist/engine/summary/recovery-due-runs.d.mts +0 -16
- package/dist/engine/summary/recovery-due-runs.mjs +0 -52
- package/dist/engine/summary/recovery-failed-runs.d.mts +0 -14
- package/dist/engine/summary/recovery-failed-runs.mjs +0 -33
- package/dist/engine/summary/recovery-lease-runs.d.mts +0 -16
- package/dist/engine/summary/recovery-lease-runs.mjs +0 -69
- package/dist/engine/summary/recovery-locks.d.mts +0 -18
- package/dist/engine/summary/recovery-locks.mjs +0 -100
- package/dist/engine/summary/recovery-message-waits.d.mts +0 -11
- package/dist/engine/summary/recovery-message-waits.mjs +0 -74
- package/dist/engine/summary/recovery-retry-runs.d.mts +0 -17
- package/dist/engine/summary/recovery-retry-runs.mjs +0 -65
- package/dist/engine/summary/recovery-run-timestamps.d.mts +0 -13
- package/dist/engine/summary/recovery-run-timestamps.mjs +0 -18
- package/dist/engine/summary/recovery-runs.d.mts +0 -23
- package/dist/engine/summary/recovery-runs.mjs +0 -54
- package/dist/engine/summary/recovery-schedules.d.mts +0 -10
- package/dist/engine/summary/recovery-schedules.mjs +0 -46
- package/dist/engine/summary/recovery-sleep-waits.d.mts +0 -10
- package/dist/engine/summary/recovery-sleep-waits.mjs +0 -53
- package/dist/engine/summary/recovery-waits.d.mts +0 -21
- package/dist/engine/summary/recovery-waits.mjs +0 -29
- package/dist/engine/summary/run-availability.d.mts +0 -13
- package/dist/engine/summary/run-availability.mjs +0 -37
- package/dist/engine/summary/run-cleanup.d.mts +0 -14
- package/dist/engine/summary/run-cleanup.mjs +0 -44
- package/dist/engine/summary/run-failure.d.mts +0 -14
- package/dist/engine/summary/run-failure.mjs +0 -62
- package/dist/engine/summary/run-hooks.d.mts +0 -14
- package/dist/engine/summary/run-hooks.mjs +0 -63
- package/dist/engine/summary/run-lease.d.mts +0 -11
- package/dist/engine/summary/run-lease.mjs +0 -64
- package/dist/engine/summary/run-message-waits.d.mts +0 -15
- package/dist/engine/summary/run-message-waits.mjs +0 -62
- package/dist/engine/summary/run-metrics.d.mts +0 -31
- package/dist/engine/summary/run-metrics.mjs +0 -93
- package/dist/engine/summary/run-retry.d.mts +0 -9
- package/dist/engine/summary/run-retry.mjs +0 -69
- package/dist/engine/summary/run-sleeps.d.mts +0 -15
- package/dist/engine/summary/run-sleeps.mjs +0 -61
- package/dist/engine/summary/run-state.d.mts +0 -26
- package/dist/engine/summary/run-state.mjs +0 -48
- package/dist/engine/summary/run-status.d.mts +0 -16
- package/dist/engine/summary/run-status.mjs +0 -35
- package/dist/engine/summary/run-streams.d.mts +0 -14
- package/dist/engine/summary/run-streams.mjs +0 -46
- package/dist/engine/summary/run-transition.d.mts +0 -9
- package/dist/engine/summary/run-transition.mjs +0 -39
- package/dist/engine/summary/run-workflow.d.mts +0 -9
- package/dist/engine/summary/run-workflow.mjs +0 -47
- package/dist/engine/summary/step-attempt-active-child-workflows.d.mts +0 -13
- package/dist/engine/summary/step-attempt-active-child-workflows.mjs +0 -55
- package/dist/engine/summary/step-attempt-active-fields.d.mts +0 -23
- package/dist/engine/summary/step-attempt-active-fields.mjs +0 -14
- package/dist/engine/summary/step-attempt-active-message-waits.d.mts +0 -12
- package/dist/engine/summary/step-attempt-active-message-waits.mjs +0 -47
- package/dist/engine/summary/step-attempt-active-sleeps.d.mts +0 -19
- package/dist/engine/summary/step-attempt-active-sleeps.mjs +0 -44
- package/dist/engine/summary/step-attempt-buckets.d.mts +0 -22
- package/dist/engine/summary/step-attempt-buckets.mjs +0 -152
- package/dist/engine/summary/step-attempt-failure.d.mts +0 -12
- package/dist/engine/summary/step-attempt-failure.mjs +0 -61
- package/dist/engine/summary/step-attempt-lifecycle.d.mts +0 -13
- package/dist/engine/summary/step-attempt-lifecycle.mjs +0 -19
- package/dist/engine/summary.d.mts +0 -32
- package/dist/engine/summary.mjs +0 -37
- package/dist/errors/details.d.mts +0 -13
- package/dist/errors/details.mjs +0 -66
- package/dist/errors/record-view.d.mts +0 -11
- package/dist/errors/record-view.mjs +0 -24
- package/dist/errors/runtime.d.mts +0 -12
- package/dist/errors/runtime.mjs +0 -24
- package/dist/events/mod.d.mts +0 -3
- package/dist/events/mod.mjs +0 -2
- package/dist/history/attempt-key.d.mts +0 -6
- package/dist/history/attempt-key.mjs +0 -7
- package/dist/inspection/mod.d.mts +0 -5
- package/dist/inspection/mod.mjs +0 -3
- package/dist/otel.mjs +0 -590
- package/dist/runtime.d.mts +0 -35
- package/dist/runtime.mjs +0 -198
- package/dist/store/append-projection.d.mts +0 -15
- package/dist/store/append-projection.mjs +0 -26
- package/dist/store/compaction.d.mts +0 -5
- package/dist/store/compaction.mjs +0 -8
- package/dist/store/event-append-project.d.mts +0 -15
- package/dist/store/event-append-project.mjs +0 -77
- package/dist/store/event-append.d.mts +0 -37
- package/dist/store/event-append.mjs +0 -80
- package/dist/store/event-history.d.mts +0 -22
- package/dist/store/event-history.mjs +0 -75
- package/dist/store/event.d.mts +0 -10
- package/dist/store/event.mjs +0 -28
- package/dist/store/idempotency.d.mts +0 -10
- package/dist/store/idempotency.mjs +0 -167
- package/dist/store/message-index.d.mts +0 -21
- package/dist/store/message-index.mjs +0 -122
- package/dist/store/revision.d.mts +0 -4
- package/dist/store/revision.mjs +0 -7
- package/dist/store/schema.d.mts +0 -14
- package/dist/store/schema.mjs +0 -17
- package/dist/types/common.d.mts +0 -20
- package/dist/types/common.mjs +0 -16
- package/dist/types/error-code.d.mts +0 -256
- package/dist/types/message-id.d.mts +0 -7
- package/dist/types/message-id.mjs +0 -5
- package/dist/types/run-id.d.mts +0 -7
- package/dist/types/run-id.mjs +0 -5
- package/dist/types/step-id.d.mts +0 -7
- package/dist/types/step-id.mjs +0 -5
- package/dist/types/stream-id.d.mts +0 -7
- package/dist/types/stream-id.mjs +0 -5
- package/dist/types/worker-id.d.mts +0 -7
- package/dist/types/worker-id.mjs +0 -5
- package/dist/utility.d.mts +0 -49
- package/dist/utility.mjs +0 -122
- package/dist/vite/ast.d.mts +0 -23
- package/dist/vite/generated-name.d.mts +0 -7
- package/dist/vite/generated-name.mjs +0 -9
- package/dist/vite/manifest.d.mts +0 -7
- package/dist/vite/plugin.d.mts +0 -7
- package/dist/vite/safety.d.mts +0 -12
- package/dist/vite/source.d.mts +0 -7
- package/dist/vite/transform.d.mts +0 -7
- package/dist/webhook.d.mts +0 -16
- package/dist/webhook.mjs +0 -17
- package/dist/worker.d.mts +0 -19
- /package/dist/{types/vite.mjs → engine/context.mjs} +0 -0
package/dist/otel.mjs
DELETED
|
@@ -1,590 +0,0 @@
|
|
|
1
|
-
import { optionalDurationBetweenMilliseconds } from "./temporal.mjs";
|
|
2
|
-
import { WORKFLOW_ATTRIBUTES, WORKFLOW_INSTRUMENTATION_NAME, WORKFLOW_INSTRUMENTATION_VERSION, WORKFLOW_MESSAGING_ATTRIBUTES, WORKFLOW_METRIC_NAMES, WORKFLOW_SPAN_NAMES, WORKFLOW_SYSTEM } from "./telemetry.mjs";
|
|
3
|
-
import { getEventDescriptor } from "./events/descriptors.mjs";
|
|
4
|
-
import { WorkflowHistory } from "./history/mod.mjs";
|
|
5
|
-
import { contextFromTraceContext, errorRecordToException, spanLinkFromTraceContext, streamStatusFromEventKind, toException, withRunSpanStatus, withSpanStatus } from "./otel/support.mjs";
|
|
6
|
-
import { SpanStatusCode, context, metrics, propagation, trace } from "@opentelemetry/api";
|
|
7
|
-
//#region src/otel.ts
|
|
8
|
-
function createOpenTelemetryTelemetry(options = {}) {
|
|
9
|
-
return new OpenTelemetryWorkflowTelemetry(options);
|
|
10
|
-
}
|
|
11
|
-
var OpenTelemetryWorkflowTelemetry = class {
|
|
12
|
-
#tracer = trace.getTracer(WORKFLOW_INSTRUMENTATION_NAME, WORKFLOW_INSTRUMENTATION_VERSION);
|
|
13
|
-
#meter = metrics.getMeter(WORKFLOW_INSTRUMENTATION_NAME, WORKFLOW_INSTRUMENTATION_VERSION);
|
|
14
|
-
#options;
|
|
15
|
-
#runTransitions = this.#meter.createCounter(WORKFLOW_METRIC_NAMES.runTransitions, { description: "Count of workflow run transitions." });
|
|
16
|
-
#runDuration = this.#meter.createHistogram(WORKFLOW_METRIC_NAMES.runDuration, {
|
|
17
|
-
description: "Workflow run duration in milliseconds.",
|
|
18
|
-
unit: "ms"
|
|
19
|
-
});
|
|
20
|
-
#eventsAppended = this.#meter.createCounter(WORKFLOW_METRIC_NAMES.eventsAppended, { description: "Count of durable workflow events appended." });
|
|
21
|
-
#stepAttempts = this.#meter.createCounter(WORKFLOW_METRIC_NAMES.stepAttempts, { description: "Count of workflow step attempt updates." });
|
|
22
|
-
#stepDuration = this.#meter.createHistogram(WORKFLOW_METRIC_NAMES.stepDuration, {
|
|
23
|
-
description: "Workflow step attempt duration in milliseconds.",
|
|
24
|
-
unit: "ms"
|
|
25
|
-
});
|
|
26
|
-
#messagesSent = this.#meter.createCounter(WORKFLOW_METRIC_NAMES.messagesSent, { description: "Count of workflow messages sent." });
|
|
27
|
-
#messageWaitLatency = this.#meter.createHistogram(WORKFLOW_METRIC_NAMES.messageWaitLatency, {
|
|
28
|
-
description: "Latency from workflow message wait creation to message receipt.",
|
|
29
|
-
unit: "ms"
|
|
30
|
-
});
|
|
31
|
-
#hooksResumed = this.#meter.createCounter(WORKFLOW_METRIC_NAMES.hooksResumed, { description: "Count of workflow hooks resumed." });
|
|
32
|
-
#hookResumeLatency = this.#meter.createHistogram(WORKFLOW_METRIC_NAMES.hookResumeLatency, {
|
|
33
|
-
description: "Latency from workflow hook wait creation to hook resume message receipt.",
|
|
34
|
-
unit: "ms"
|
|
35
|
-
});
|
|
36
|
-
#streamUpdates = this.#meter.createCounter(WORKFLOW_METRIC_NAMES.streamUpdates, { description: "Count of workflow stream updates." });
|
|
37
|
-
#cleanupDeletedRuns = this.#meter.createCounter(WORKFLOW_METRIC_NAMES.cleanupDeletedRuns, { description: "Count of workflow runs deleted by cleanup or retention operations." });
|
|
38
|
-
#runGauge;
|
|
39
|
-
#workerActiveExecutionsGauge;
|
|
40
|
-
#workerClaims = this.#meter.createCounter(WORKFLOW_METRIC_NAMES.workerClaims, { description: "Count of workflow run claims by workers." });
|
|
41
|
-
#workerClaimFailures = this.#meter.createCounter(WORKFLOW_METRIC_NAMES.workerClaimFailures, { description: "Count of failed targeted workflow run claims by workers." });
|
|
42
|
-
#workerHeartbeatFailures = this.#meter.createCounter(WORKFLOW_METRIC_NAMES.workerHeartbeatFailures, { description: "Count of failed workflow worker heartbeat lease extensions." });
|
|
43
|
-
#workerLeaseExtensions = this.#meter.createCounter(WORKFLOW_METRIC_NAMES.workerLeaseExtensions, { description: "Count of workflow run lease extension attempts." });
|
|
44
|
-
#workerLeaseReleases = this.#meter.createCounter(WORKFLOW_METRIC_NAMES.workerLeaseReleases, { description: "Count of workflow run lease releases." });
|
|
45
|
-
#pendingToClaimedLatency = this.#meter.createHistogram(WORKFLOW_METRIC_NAMES.pendingToClaimedLatency, {
|
|
46
|
-
description: "Latency from workflow availability to worker claim in milliseconds.",
|
|
47
|
-
unit: "ms"
|
|
48
|
-
});
|
|
49
|
-
#waitingToResumedLatency = this.#meter.createHistogram(WORKFLOW_METRIC_NAMES.runWaitingToResumedLatency, {
|
|
50
|
-
description: "Latency from workflow waiting state to resumed execution in milliseconds.",
|
|
51
|
-
unit: "ms"
|
|
52
|
-
});
|
|
53
|
-
#retryScheduled = this.#meter.createCounter(WORKFLOW_METRIC_NAMES.retryScheduled, { description: "Count of workflow retries scheduled." });
|
|
54
|
-
#retryExhausted = this.#meter.createCounter(WORKFLOW_METRIC_NAMES.retryExhausted, { description: "Count of workflow retries exhausted into permanent failure." });
|
|
55
|
-
#retryDelay = this.#meter.createHistogram(WORKFLOW_METRIC_NAMES.retryDelay, {
|
|
56
|
-
description: "Delay until a scheduled workflow retry in milliseconds.",
|
|
57
|
-
unit: "ms"
|
|
58
|
-
});
|
|
59
|
-
#scheduleDueToRunCreatedLatency = this.#meter.createHistogram(WORKFLOW_METRIC_NAMES.scheduleDueToRunCreatedLatency, {
|
|
60
|
-
description: "Latency from recurring schedule fire time to scheduled run creation.",
|
|
61
|
-
unit: "ms"
|
|
62
|
-
});
|
|
63
|
-
#storageOperationDuration = this.#meter.createHistogram(WORKFLOW_METRIC_NAMES.storageOperationDuration, {
|
|
64
|
-
description: "Workflow storage/backend operation duration in milliseconds.",
|
|
65
|
-
unit: "ms"
|
|
66
|
-
});
|
|
67
|
-
#storageOperationErrors = this.#meter.createCounter(WORKFLOW_METRIC_NAMES.storageOperationErrors, { description: "Count of workflow storage/backend operation failures." });
|
|
68
|
-
#engine;
|
|
69
|
-
constructor(options) {
|
|
70
|
-
this.#options = options;
|
|
71
|
-
this.#runGauge = this.#meter.createObservableGauge(WORKFLOW_METRIC_NAMES.runs, { description: "Current count of workflow runs by status." });
|
|
72
|
-
this.#workerActiveExecutionsGauge = this.#meter.createObservableGauge(WORKFLOW_METRIC_NAMES.workerActiveExecutions, { description: "Current count of workflow runs actively held by workers." });
|
|
73
|
-
this.#runGauge.addCallback(async (result) => {
|
|
74
|
-
if (this.#engine?.getRunSummary === void 0) return;
|
|
75
|
-
try {
|
|
76
|
-
const summary = await this.#engine.getRunSummary();
|
|
77
|
-
for (const [status, count] of Object.entries(summary.status)) result.observe(count, this.#attributes({ [WORKFLOW_ATTRIBUTES.runStatus]: status }));
|
|
78
|
-
} catch {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
this.#workerActiveExecutionsGauge.addCallback(async (result) => {
|
|
83
|
-
if (this.#engine?.getRunSummary === void 0) return;
|
|
84
|
-
try {
|
|
85
|
-
const summary = await this.#engine.getRunSummary();
|
|
86
|
-
result.observe(summary.status.running, this.#attributes({ [WORKFLOW_ATTRIBUTES.runStatus]: "running" }));
|
|
87
|
-
} catch {
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
captureContext() {
|
|
93
|
-
const carrier = {};
|
|
94
|
-
propagation.inject(context.active(), carrier);
|
|
95
|
-
return Object.keys(carrier).length === 0 ? void 0 : {
|
|
96
|
-
...carrier.traceparent === void 0 ? {} : { traceparent: carrier.traceparent },
|
|
97
|
-
...carrier.tracestate === void 0 ? {} : { tracestate: carrier.tracestate }
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
async withRunExecution(telemetryContext, callback) {
|
|
101
|
-
const parent = contextFromTraceContext(telemetryContext.traceContext);
|
|
102
|
-
return await this.#tracer.startActiveSpan(this.#runExecutionSpanName(telemetryContext), { attributes: this.#attributes({
|
|
103
|
-
[WORKFLOW_ATTRIBUTES.workflowName]: telemetryContext.run.workflowName,
|
|
104
|
-
...telemetryContext.run.workflowVersion === void 0 ? {} : { [WORKFLOW_ATTRIBUTES.workflowVersion]: telemetryContext.run.workflowVersion },
|
|
105
|
-
[WORKFLOW_ATTRIBUTES.runId]: telemetryContext.run.id,
|
|
106
|
-
[WORKFLOW_ATTRIBUTES.namespace]: telemetryContext.run.namespace,
|
|
107
|
-
...telemetryContext.run.attempts === void 0 ? {} : { [WORKFLOW_ATTRIBUTES.runAttempt]: telemetryContext.run.attempts },
|
|
108
|
-
...telemetryContext.run.workerId === void 0 ? {} : { [WORKFLOW_ATTRIBUTES.workerId]: telemetryContext.run.workerId }
|
|
109
|
-
}) }, parent, async (span) => await withRunSpanStatus(span, callback));
|
|
110
|
-
}
|
|
111
|
-
async withStepExecution(telemetryContext, callback) {
|
|
112
|
-
return await this.#tracer.startActiveSpan(this.#stepExecutionSpanName(telemetryContext), { attributes: this.#attributes({
|
|
113
|
-
[WORKFLOW_ATTRIBUTES.workflowName]: telemetryContext.run.workflowName,
|
|
114
|
-
...telemetryContext.run.workflowVersion === void 0 ? {} : { [WORKFLOW_ATTRIBUTES.workflowVersion]: telemetryContext.run.workflowVersion },
|
|
115
|
-
[WORKFLOW_ATTRIBUTES.runId]: telemetryContext.run.id,
|
|
116
|
-
[WORKFLOW_ATTRIBUTES.stepId]: telemetryContext.step.id,
|
|
117
|
-
[WORKFLOW_ATTRIBUTES.stepName]: telemetryContext.step.name,
|
|
118
|
-
[WORKFLOW_ATTRIBUTES.stepKind]: telemetryContext.step.kind,
|
|
119
|
-
[WORKFLOW_ATTRIBUTES.stepAttempt]: telemetryContext.attempt,
|
|
120
|
-
...telemetryContext.timeoutAt === void 0 ? {} : { [WORKFLOW_ATTRIBUTES.stepTimeoutAt]: telemetryContext.timeoutAt.toString() }
|
|
121
|
-
}) }, async (span) => await withSpanStatus(span, callback));
|
|
122
|
-
}
|
|
123
|
-
async withStorageOperation(telemetryContext, callback) {
|
|
124
|
-
const startedAt = Date.now();
|
|
125
|
-
const attributes = this.#attributes({
|
|
126
|
-
[WORKFLOW_ATTRIBUTES.storageOperation]: telemetryContext.operation,
|
|
127
|
-
[WORKFLOW_ATTRIBUTES.storageBackend]: telemetryContext.backend
|
|
128
|
-
});
|
|
129
|
-
if (this.#options.includeStorageOperationSpans === false) try {
|
|
130
|
-
const result = await callback();
|
|
131
|
-
this.#recordStorageOperationResult(startedAt, attributes, "success");
|
|
132
|
-
return result;
|
|
133
|
-
} catch (error) {
|
|
134
|
-
this.#recordStorageOperationResult(startedAt, attributes, "failure");
|
|
135
|
-
throw error;
|
|
136
|
-
}
|
|
137
|
-
return await this.#tracer.startActiveSpan(WORKFLOW_SPAN_NAMES.storageOperation, { attributes }, async (span) => {
|
|
138
|
-
try {
|
|
139
|
-
const result = await callback();
|
|
140
|
-
this.#recordStorageOperationResult(startedAt, attributes, "success");
|
|
141
|
-
span.setAttribute(WORKFLOW_ATTRIBUTES.storageOperationStatus, "success");
|
|
142
|
-
span.setStatus({ code: SpanStatusCode.OK });
|
|
143
|
-
return result;
|
|
144
|
-
} catch (error) {
|
|
145
|
-
this.#recordStorageOperationResult(startedAt, attributes, "failure");
|
|
146
|
-
span.setAttribute(WORKFLOW_ATTRIBUTES.storageOperationStatus, "failure");
|
|
147
|
-
span.recordException(toException(error));
|
|
148
|
-
span.setStatus({ code: SpanStatusCode.ERROR });
|
|
149
|
-
throw error;
|
|
150
|
-
} finally {
|
|
151
|
-
span.end();
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
recordRunExecution(telemetryContext) {
|
|
156
|
-
const result = telemetryContext.result;
|
|
157
|
-
if (result?.kind === "completed" || result?.kind === "failed") {
|
|
158
|
-
const duration = optionalDurationBetweenMilliseconds(result.run.startedAt ?? result.run.createdAt, result.run.finishedAt);
|
|
159
|
-
if (duration !== void 0) this.#runDuration.record(duration, this.#attributes({
|
|
160
|
-
[WORKFLOW_ATTRIBUTES.workflowName]: result.run.workflowName,
|
|
161
|
-
...result.run.workflowVersion === void 0 ? {} : { [WORKFLOW_ATTRIBUTES.workflowVersion]: result.run.workflowVersion },
|
|
162
|
-
[WORKFLOW_ATTRIBUTES.runStatus]: result.run.status
|
|
163
|
-
}));
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
observe(name, payload) {
|
|
167
|
-
switch (name) {
|
|
168
|
-
case "workflow:run-created":
|
|
169
|
-
case "workflow:run-waiting":
|
|
170
|
-
case "workflow:run-rescheduled":
|
|
171
|
-
case "workflow:run-manual-retry":
|
|
172
|
-
case "workflow:run-completed":
|
|
173
|
-
case "workflow:run-canceled": {
|
|
174
|
-
const event = payload;
|
|
175
|
-
this.#recordRunTransition(event);
|
|
176
|
-
break;
|
|
177
|
-
}
|
|
178
|
-
case "workflow:run-failed": {
|
|
179
|
-
const event = payload;
|
|
180
|
-
this.#recordRunTransition(event);
|
|
181
|
-
this.#recordRetryExhausted(event);
|
|
182
|
-
break;
|
|
183
|
-
}
|
|
184
|
-
case "workflow:run-permanently-failed": {
|
|
185
|
-
const event = payload;
|
|
186
|
-
this.#recordRunTransition(event);
|
|
187
|
-
this.#recordRetryExhausted(event);
|
|
188
|
-
break;
|
|
189
|
-
}
|
|
190
|
-
case "workflow:run-claimed": {
|
|
191
|
-
const event = payload;
|
|
192
|
-
this.#recordRunTransition(event);
|
|
193
|
-
const attributes = this.#runMetricAttributes(event, { [WORKFLOW_ATTRIBUTES.workerOperation]: event.reason });
|
|
194
|
-
this.#workerClaims.add(1, attributes);
|
|
195
|
-
const startedAt = event.previousRun?.availableAt ?? event.run.availableAt ?? event.run.createdAt;
|
|
196
|
-
const latency = optionalDurationBetweenMilliseconds(startedAt, event.timestamp);
|
|
197
|
-
if (latency !== void 0) this.#pendingToClaimedLatency.record(latency, attributes);
|
|
198
|
-
break;
|
|
199
|
-
}
|
|
200
|
-
case "workflow:run-started": {
|
|
201
|
-
const event = payload;
|
|
202
|
-
this.#recordRunTransition(event);
|
|
203
|
-
if (event.previousRun?.status !== "waiting") break;
|
|
204
|
-
const startedAt = event.previousRun.availableAt ?? event.previousRun.lastTransitionAt;
|
|
205
|
-
const latency = optionalDurationBetweenMilliseconds(startedAt, event.timestamp);
|
|
206
|
-
if (latency !== void 0) this.#waitingToResumedLatency.record(latency, this.#runMetricAttributes(event));
|
|
207
|
-
break;
|
|
208
|
-
}
|
|
209
|
-
case "workflow:run-lease-released": {
|
|
210
|
-
const event = payload;
|
|
211
|
-
this.#recordRunTransition(event);
|
|
212
|
-
this.#workerLeaseReleases.add(1, this.#runMetricAttributes(event));
|
|
213
|
-
break;
|
|
214
|
-
}
|
|
215
|
-
case "workflow:run-retrying": {
|
|
216
|
-
const event = payload;
|
|
217
|
-
this.#recordRunTransition(event);
|
|
218
|
-
const attributes = event.run.retryReason === void 0 ? this.#runMetricAttributes(event) : this.#runMetricAttributes(event, { [WORKFLOW_ATTRIBUTES.retryReason]: event.run.retryReason });
|
|
219
|
-
this.#retryScheduled.add(1, attributes);
|
|
220
|
-
const delay = optionalDurationBetweenMilliseconds(event.timestamp, event.run.retryAt);
|
|
221
|
-
if (delay !== void 0) this.#retryDelay.record(delay, attributes);
|
|
222
|
-
break;
|
|
223
|
-
}
|
|
224
|
-
case "workflow:durable-event-appended": {
|
|
225
|
-
const event = payload;
|
|
226
|
-
const descriptor = getEventDescriptor(event.event.kind);
|
|
227
|
-
this.#eventsAppended.add(1, this.#attributes({
|
|
228
|
-
[WORKFLOW_ATTRIBUTES.eventKind]: descriptor.kind,
|
|
229
|
-
[WORKFLOW_ATTRIBUTES.eventCategory]: descriptor.category
|
|
230
|
-
}));
|
|
231
|
-
const history = new WorkflowHistory(event.events);
|
|
232
|
-
this.#recordDurableEventLatency(event, history);
|
|
233
|
-
this.#recordDurableSleepSpan(event, history);
|
|
234
|
-
this.#recordChildWorkflowOperationSpan(event, history);
|
|
235
|
-
break;
|
|
236
|
-
}
|
|
237
|
-
case "workflow:step-attempt-updated": {
|
|
238
|
-
const event = payload;
|
|
239
|
-
const attributes = this.#attributes({
|
|
240
|
-
[WORKFLOW_ATTRIBUTES.stepKind]: event.attempt.kind,
|
|
241
|
-
[WORKFLOW_ATTRIBUTES.stepStatus]: event.attempt.status,
|
|
242
|
-
...this.#options.includeStepNameMetricAttribute ? { [WORKFLOW_ATTRIBUTES.stepName]: event.attempt.stepName } : {}
|
|
243
|
-
});
|
|
244
|
-
this.#stepAttempts.add(1, attributes);
|
|
245
|
-
if (event.attempt.status === "completed" || event.attempt.status === "failed") {
|
|
246
|
-
const duration = optionalDurationBetweenMilliseconds(event.attempt.startedAt, event.attempt.finishedAt);
|
|
247
|
-
if (duration !== void 0) this.#stepDuration.record(duration, attributes);
|
|
248
|
-
}
|
|
249
|
-
break;
|
|
250
|
-
}
|
|
251
|
-
case "workflow:message-sent": {
|
|
252
|
-
const event = payload;
|
|
253
|
-
this.#messagesSent.add(1, this.#attributes({}));
|
|
254
|
-
this.#recordMessageSentSpan(event);
|
|
255
|
-
break;
|
|
256
|
-
}
|
|
257
|
-
case "workflow:hook-resumed": {
|
|
258
|
-
const event = payload;
|
|
259
|
-
this.#hooksResumed.add(1, this.#attributes({ [WORKFLOW_ATTRIBUTES.hookKind]: "hook" }));
|
|
260
|
-
this.#recordHookResumeSpan("hook", event);
|
|
261
|
-
break;
|
|
262
|
-
}
|
|
263
|
-
case "workflow:webhook-resumed": {
|
|
264
|
-
const event = payload;
|
|
265
|
-
this.#hooksResumed.add(1, this.#attributes({ [WORKFLOW_ATTRIBUTES.hookKind]: "webhook" }));
|
|
266
|
-
this.#recordHookResumeSpan("webhook", event);
|
|
267
|
-
break;
|
|
268
|
-
}
|
|
269
|
-
case "workflow:stream-updated": {
|
|
270
|
-
const event = payload;
|
|
271
|
-
this.#streamUpdates.add(1, this.#attributes({
|
|
272
|
-
[WORKFLOW_ATTRIBUTES.streamEventKind]: event.eventKind,
|
|
273
|
-
[WORKFLOW_ATTRIBUTES.streamStatus]: streamStatusFromEventKind(event.eventKind)
|
|
274
|
-
}));
|
|
275
|
-
this.#recordStreamOperationSpan(event);
|
|
276
|
-
break;
|
|
277
|
-
}
|
|
278
|
-
case "workflow:child-workflow-started": {
|
|
279
|
-
const event = payload;
|
|
280
|
-
this.#recordChildWorkflowStartedSpan(event);
|
|
281
|
-
break;
|
|
282
|
-
}
|
|
283
|
-
case "workflow:cleanup-completed": {
|
|
284
|
-
const event = payload;
|
|
285
|
-
this.#cleanupDeletedRuns.add(event.result.deletedRuns, this.#attributes({ [WORKFLOW_ATTRIBUTES.cleanupSource]: "cleanup" }));
|
|
286
|
-
this.#recordCleanupOperationSpan("cleanup", event);
|
|
287
|
-
break;
|
|
288
|
-
}
|
|
289
|
-
case "workflow:retention-applied": {
|
|
290
|
-
const event = payload;
|
|
291
|
-
this.#cleanupDeletedRuns.add(event.result.deletedRuns, this.#attributes({ [WORKFLOW_ATTRIBUTES.cleanupSource]: "retention" }));
|
|
292
|
-
this.#recordCleanupOperationSpan("retention", event);
|
|
293
|
-
break;
|
|
294
|
-
}
|
|
295
|
-
case "workflow:worker-operation": {
|
|
296
|
-
const event = payload;
|
|
297
|
-
const attributes = this.#attributes({
|
|
298
|
-
[WORKFLOW_ATTRIBUTES.workerOperation]: event.operation,
|
|
299
|
-
[WORKFLOW_ATTRIBUTES.workerOperationStatus]: event.status
|
|
300
|
-
});
|
|
301
|
-
if (event.operation === "claim" && event.status === "failure") this.#workerClaimFailures.add(1, attributes);
|
|
302
|
-
if (event.operation === "heartbeat" && event.status === "failure") this.#workerHeartbeatFailures.add(1, attributes);
|
|
303
|
-
if (event.operation === "lease_extension") this.#workerLeaseExtensions.add(1, attributes);
|
|
304
|
-
if (event.operation === "lease_release") this.#workerLeaseReleases.add(1, attributes);
|
|
305
|
-
this.#recordWorkerOperationSpan(event);
|
|
306
|
-
break;
|
|
307
|
-
}
|
|
308
|
-
case "workflow:schedule-ticked": {
|
|
309
|
-
const event = payload;
|
|
310
|
-
this.#recordScheduleTickSpan(event);
|
|
311
|
-
break;
|
|
312
|
-
}
|
|
313
|
-
case "workflow:schedule-run-created": {
|
|
314
|
-
const event = payload;
|
|
315
|
-
const attributes = this.#attributes({
|
|
316
|
-
[WORKFLOW_ATTRIBUTES.workflowName]: event.workflowName,
|
|
317
|
-
...event.workflowVersion === void 0 ? {} : { [WORKFLOW_ATTRIBUTES.workflowVersion]: event.workflowVersion }
|
|
318
|
-
});
|
|
319
|
-
const latency = optionalDurationBetweenMilliseconds(event.fireAt, event.timestamp);
|
|
320
|
-
if (latency !== void 0) this.#scheduleDueToRunCreatedLatency.record(latency, attributes);
|
|
321
|
-
this.#recordScheduleRunCreatedSpan(event);
|
|
322
|
-
break;
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
bindEngine(engine) {
|
|
327
|
-
this.#engine = engine;
|
|
328
|
-
}
|
|
329
|
-
async shutdown() {
|
|
330
|
-
const errors = [];
|
|
331
|
-
try {
|
|
332
|
-
await this.#options.forceFlush?.();
|
|
333
|
-
} catch (error) {
|
|
334
|
-
errors.push(error);
|
|
335
|
-
}
|
|
336
|
-
try {
|
|
337
|
-
await this.#options.shutdown?.();
|
|
338
|
-
} catch (error) {
|
|
339
|
-
errors.push(error);
|
|
340
|
-
}
|
|
341
|
-
if (errors.length > 0) throw errors[0];
|
|
342
|
-
}
|
|
343
|
-
#recordRunTransition(event) {
|
|
344
|
-
this.#runTransitions.add(1, this.#runMetricAttributes(event));
|
|
345
|
-
}
|
|
346
|
-
#recordRetryExhausted(event) {
|
|
347
|
-
const retryReason = event.previousRun?.retryReason ?? ((event.previousRun?.attempts ?? event.run.attempts ?? 1) > 1 ? "workflow" : void 0);
|
|
348
|
-
if (retryReason === void 0) return;
|
|
349
|
-
this.#retryExhausted.add(1, this.#runMetricAttributes(event, {
|
|
350
|
-
[WORKFLOW_ATTRIBUTES.retryReason]: retryReason,
|
|
351
|
-
[WORKFLOW_ATTRIBUTES.retryExhausted]: true
|
|
352
|
-
}));
|
|
353
|
-
}
|
|
354
|
-
#attributes(attributes) {
|
|
355
|
-
return {
|
|
356
|
-
...this.#options.serviceNamespace === void 0 ? {} : { "service.namespace": this.#options.serviceNamespace },
|
|
357
|
-
[WORKFLOW_ATTRIBUTES.system]: WORKFLOW_SYSTEM,
|
|
358
|
-
...attributes
|
|
359
|
-
};
|
|
360
|
-
}
|
|
361
|
-
#runExecutionSpanName(telemetryContext) {
|
|
362
|
-
return this.#options.includeNamesInSpanNames === true ? `${WORKFLOW_SPAN_NAMES.runExecution} ${telemetryContext.run.workflowName}` : WORKFLOW_SPAN_NAMES.runExecution;
|
|
363
|
-
}
|
|
364
|
-
#stepExecutionSpanName(telemetryContext) {
|
|
365
|
-
return this.#options.includeNamesInSpanNames === true ? `${WORKFLOW_SPAN_NAMES.stepExecution} ${telemetryContext.step.name}` : WORKFLOW_SPAN_NAMES.stepExecution;
|
|
366
|
-
}
|
|
367
|
-
#recordStorageOperationResult(startedAt, attributes, status) {
|
|
368
|
-
const resultAttributes = {
|
|
369
|
-
...attributes,
|
|
370
|
-
[WORKFLOW_ATTRIBUTES.storageOperationStatus]: status
|
|
371
|
-
};
|
|
372
|
-
this.#storageOperationDuration.record(Date.now() - startedAt, resultAttributes);
|
|
373
|
-
if (status === "failure") this.#storageOperationErrors.add(1, resultAttributes);
|
|
374
|
-
}
|
|
375
|
-
#runMetricAttributes(event, attributes = {}) {
|
|
376
|
-
return this.#attributes({
|
|
377
|
-
[WORKFLOW_ATTRIBUTES.workflowName]: event.workflowName,
|
|
378
|
-
...event.workflowVersion === void 0 ? {} : { [WORKFLOW_ATTRIBUTES.workflowVersion]: event.workflowVersion },
|
|
379
|
-
[WORKFLOW_ATTRIBUTES.runStatus]: event.status,
|
|
380
|
-
[WORKFLOW_ATTRIBUTES.runTransition]: event.reason,
|
|
381
|
-
...attributes
|
|
382
|
-
});
|
|
383
|
-
}
|
|
384
|
-
#recordDurableEventLatency(event, history) {
|
|
385
|
-
if (event.event.kind !== "message_wait_completed") return;
|
|
386
|
-
const completed = event.event;
|
|
387
|
-
const started = history.startedMessageWaitForCompleted(completed);
|
|
388
|
-
if (started === void 0) return;
|
|
389
|
-
const latency = optionalDurationBetweenMilliseconds(started.timestamp, completed.messageTimestamp);
|
|
390
|
-
if (latency === void 0) return;
|
|
391
|
-
const source = started.source ?? "message";
|
|
392
|
-
const attributes = this.#attributes({ [WORKFLOW_ATTRIBUTES.messageSource]: source });
|
|
393
|
-
this.#messageWaitLatency.record(latency, attributes);
|
|
394
|
-
if (source === "hook" || source === "webhook") this.#hookResumeLatency.record(latency, this.#attributes({ [WORKFLOW_ATTRIBUTES.hookKind]: source }));
|
|
395
|
-
this.#recordMessageWaitSpan(completed, started, history);
|
|
396
|
-
}
|
|
397
|
-
#recordDurableSleepSpan(event, history) {
|
|
398
|
-
if (event.event.kind !== "sleep_completed") return;
|
|
399
|
-
const completed = event.event;
|
|
400
|
-
const started = history.startedSleepForCompleted(completed);
|
|
401
|
-
if (started === void 0) return;
|
|
402
|
-
const requestedDuration = started.duration === void 0 ? void 0 : started.duration.total({ unit: "millisecond" });
|
|
403
|
-
const actualDuration = optionalDurationBetweenMilliseconds(started.timestamp, completed.timestamp);
|
|
404
|
-
const span = this.#tracer.startSpan(WORKFLOW_SPAN_NAMES.sleep, { attributes: this.#attributes({
|
|
405
|
-
[WORKFLOW_ATTRIBUTES.runId]: event.runId,
|
|
406
|
-
[WORKFLOW_ATTRIBUTES.stepId]: completed.stepId,
|
|
407
|
-
[WORKFLOW_ATTRIBUTES.stepName]: completed.stepName,
|
|
408
|
-
[WORKFLOW_ATTRIBUTES.stepKind]: "sleep",
|
|
409
|
-
[WORKFLOW_ATTRIBUTES.sleepUntil]: started.until.toString(),
|
|
410
|
-
...requestedDuration === void 0 ? {} : { [WORKFLOW_ATTRIBUTES.sleepDurationMs]: requestedDuration },
|
|
411
|
-
...actualDuration === void 0 ? {} : { [WORKFLOW_ATTRIBUTES.sleepActualMs]: actualDuration }
|
|
412
|
-
}) });
|
|
413
|
-
span.setStatus({ code: SpanStatusCode.OK });
|
|
414
|
-
span.end();
|
|
415
|
-
}
|
|
416
|
-
#recordChildWorkflowOperationSpan(event, history) {
|
|
417
|
-
if (event.event.kind !== "child_workflow_completed" && event.event.kind !== "child_workflow_failed") return;
|
|
418
|
-
const terminal = event.event;
|
|
419
|
-
const started = history.startedChildWorkflowForTerminal(terminal);
|
|
420
|
-
const duration = started === void 0 ? void 0 : optionalDurationBetweenMilliseconds(started.timestamp, terminal.timestamp);
|
|
421
|
-
const failed = terminal.kind === "child_workflow_failed";
|
|
422
|
-
const span = this.#tracer.startSpan(WORKFLOW_SPAN_NAMES.childWorkflowOperation, { attributes: this.#attributes({
|
|
423
|
-
[WORKFLOW_ATTRIBUTES.runId]: event.runId,
|
|
424
|
-
[WORKFLOW_ATTRIBUTES.stepId]: terminal.stepId,
|
|
425
|
-
[WORKFLOW_ATTRIBUTES.stepName]: terminal.stepName,
|
|
426
|
-
[WORKFLOW_ATTRIBUTES.stepKind]: "workflow",
|
|
427
|
-
[WORKFLOW_ATTRIBUTES.stepAttempt]: terminal.attempt,
|
|
428
|
-
[WORKFLOW_ATTRIBUTES.childWorkflowOperation]: failed ? "fail" : "complete",
|
|
429
|
-
[WORKFLOW_ATTRIBUTES.childWorkflowRunId]: terminal.childRunId,
|
|
430
|
-
...started === void 0 ? {} : {
|
|
431
|
-
[WORKFLOW_ATTRIBUTES.childWorkflowName]: started.workflowName,
|
|
432
|
-
...started.workflowVersion === void 0 ? {} : { [WORKFLOW_ATTRIBUTES.childWorkflowVersion]: started.workflowVersion }
|
|
433
|
-
},
|
|
434
|
-
[WORKFLOW_ATTRIBUTES.childWorkflowStatus]: failed ? "failed" : "completed",
|
|
435
|
-
...duration === void 0 ? {} : { [WORKFLOW_ATTRIBUTES.childWorkflowDurationMs]: duration },
|
|
436
|
-
...failed ? { [WORKFLOW_ATTRIBUTES.errorKind]: terminal.error.name } : {}
|
|
437
|
-
}) });
|
|
438
|
-
if (failed) {
|
|
439
|
-
span.recordException(errorRecordToException(terminal.error));
|
|
440
|
-
span.setStatus({
|
|
441
|
-
code: SpanStatusCode.ERROR,
|
|
442
|
-
message: terminal.error.message
|
|
443
|
-
});
|
|
444
|
-
} else span.setStatus({ code: SpanStatusCode.OK });
|
|
445
|
-
span.end();
|
|
446
|
-
}
|
|
447
|
-
#recordChildWorkflowStartedSpan(event) {
|
|
448
|
-
const started = event.event;
|
|
449
|
-
const span = this.#tracer.startSpan(WORKFLOW_SPAN_NAMES.childWorkflowOperation, { attributes: this.#attributes({
|
|
450
|
-
[WORKFLOW_ATTRIBUTES.runId]: event.runId,
|
|
451
|
-
[WORKFLOW_ATTRIBUTES.stepId]: started.stepId,
|
|
452
|
-
[WORKFLOW_ATTRIBUTES.stepName]: started.stepName,
|
|
453
|
-
[WORKFLOW_ATTRIBUTES.stepKind]: "workflow",
|
|
454
|
-
[WORKFLOW_ATTRIBUTES.stepAttempt]: started.attempt,
|
|
455
|
-
[WORKFLOW_ATTRIBUTES.childWorkflowOperation]: "start",
|
|
456
|
-
[WORKFLOW_ATTRIBUTES.childWorkflowRunId]: started.childRunId,
|
|
457
|
-
[WORKFLOW_ATTRIBUTES.childWorkflowName]: started.workflowName,
|
|
458
|
-
...started.workflowVersion === void 0 ? {} : { [WORKFLOW_ATTRIBUTES.childWorkflowVersion]: started.workflowVersion },
|
|
459
|
-
[WORKFLOW_ATTRIBUTES.childWorkflowStatus]: "started"
|
|
460
|
-
}) });
|
|
461
|
-
span.setStatus({ code: SpanStatusCode.OK });
|
|
462
|
-
span.end();
|
|
463
|
-
}
|
|
464
|
-
#recordMessageSentSpan(event) {
|
|
465
|
-
const parent = contextFromTraceContext(event.traceContext);
|
|
466
|
-
const span = this.#tracer.startSpan(WORKFLOW_SPAN_NAMES.messageSend, { attributes: this.#attributes({
|
|
467
|
-
[WORKFLOW_ATTRIBUTES.runId]: event.runId,
|
|
468
|
-
[WORKFLOW_ATTRIBUTES.messageId]: event.messageId,
|
|
469
|
-
[WORKFLOW_MESSAGING_ATTRIBUTES.system]: "temelj.workflow",
|
|
470
|
-
[WORKFLOW_MESSAGING_ATTRIBUTES.destinationName]: event.runId,
|
|
471
|
-
[WORKFLOW_MESSAGING_ATTRIBUTES.messageId]: event.messageId,
|
|
472
|
-
[WORKFLOW_MESSAGING_ATTRIBUTES.operationName]: "send",
|
|
473
|
-
[WORKFLOW_MESSAGING_ATTRIBUTES.operationType]: "publish"
|
|
474
|
-
}) }, parent);
|
|
475
|
-
span.setStatus({ code: SpanStatusCode.OK });
|
|
476
|
-
span.end();
|
|
477
|
-
}
|
|
478
|
-
#recordHookResumeSpan(kind, event) {
|
|
479
|
-
const parent = contextFromTraceContext(event.traceContext);
|
|
480
|
-
const span = this.#tracer.startSpan(WORKFLOW_SPAN_NAMES.hookResume, { attributes: this.#attributes({
|
|
481
|
-
[WORKFLOW_ATTRIBUTES.hookKind]: kind,
|
|
482
|
-
[WORKFLOW_ATTRIBUTES.runId]: event.runId,
|
|
483
|
-
[WORKFLOW_ATTRIBUTES.messageId]: event.messageId,
|
|
484
|
-
[WORKFLOW_MESSAGING_ATTRIBUTES.system]: "temelj.workflow",
|
|
485
|
-
[WORKFLOW_MESSAGING_ATTRIBUTES.destinationName]: event.runId,
|
|
486
|
-
[WORKFLOW_MESSAGING_ATTRIBUTES.messageId]: event.messageId,
|
|
487
|
-
[WORKFLOW_MESSAGING_ATTRIBUTES.operationName]: "resume",
|
|
488
|
-
[WORKFLOW_MESSAGING_ATTRIBUTES.operationType]: "publish"
|
|
489
|
-
}) }, parent);
|
|
490
|
-
span.setStatus({ code: SpanStatusCode.OK });
|
|
491
|
-
span.end();
|
|
492
|
-
}
|
|
493
|
-
#recordScheduleRunCreatedSpan(event) {
|
|
494
|
-
const span = this.#tracer.startSpan(WORKFLOW_SPAN_NAMES.scheduleRunCreate, { attributes: this.#attributes({
|
|
495
|
-
[WORKFLOW_ATTRIBUTES.workflowName]: event.workflowName,
|
|
496
|
-
...event.workflowVersion === void 0 ? {} : { [WORKFLOW_ATTRIBUTES.workflowVersion]: event.workflowVersion },
|
|
497
|
-
[WORKFLOW_ATTRIBUTES.scheduleId]: event.scheduleId,
|
|
498
|
-
[WORKFLOW_ATTRIBUTES.scheduleFireAt]: event.fireAt.toString(),
|
|
499
|
-
[WORKFLOW_ATTRIBUTES.runId]: event.runId
|
|
500
|
-
}) });
|
|
501
|
-
span.setStatus({ code: SpanStatusCode.OK });
|
|
502
|
-
span.end();
|
|
503
|
-
}
|
|
504
|
-
#recordScheduleTickSpan(event) {
|
|
505
|
-
const span = this.#tracer.startSpan(WORKFLOW_SPAN_NAMES.scheduleTick, { attributes: this.#attributes({
|
|
506
|
-
[WORKFLOW_ATTRIBUTES.scheduleTickedRuns]: event.result.ticked,
|
|
507
|
-
[WORKFLOW_ATTRIBUTES.scheduleTickedSchedules]: event.result.scheduleIds.length,
|
|
508
|
-
...event.result.nextScheduleAt === void 0 ? {} : { [WORKFLOW_ATTRIBUTES.scheduleNextAt]: event.result.nextScheduleAt.toString() }
|
|
509
|
-
}) });
|
|
510
|
-
span.setStatus({ code: SpanStatusCode.OK });
|
|
511
|
-
span.end();
|
|
512
|
-
}
|
|
513
|
-
#recordWorkerOperationSpan(event) {
|
|
514
|
-
const span = this.#tracer.startSpan(WORKFLOW_SPAN_NAMES.workerOperation, { attributes: this.#attributes({
|
|
515
|
-
[WORKFLOW_ATTRIBUTES.workerId]: event.workerId,
|
|
516
|
-
...event.runId === void 0 ? {} : { [WORKFLOW_ATTRIBUTES.runId]: event.runId },
|
|
517
|
-
...event.run === void 0 ? {} : {
|
|
518
|
-
[WORKFLOW_ATTRIBUTES.workflowName]: event.run.workflowName,
|
|
519
|
-
...event.run.workflowVersion === void 0 ? {} : { [WORKFLOW_ATTRIBUTES.workflowVersion]: event.run.workflowVersion },
|
|
520
|
-
[WORKFLOW_ATTRIBUTES.runStatus]: event.run.status
|
|
521
|
-
},
|
|
522
|
-
[WORKFLOW_ATTRIBUTES.workerOperation]: event.operation,
|
|
523
|
-
[WORKFLOW_ATTRIBUTES.workerOperationStatus]: event.status
|
|
524
|
-
}) });
|
|
525
|
-
if (event.status === "failure") {
|
|
526
|
-
span.setStatus({ code: SpanStatusCode.ERROR });
|
|
527
|
-
if (event.error !== void 0) span.recordException(toException(event.error));
|
|
528
|
-
} else span.setStatus({ code: SpanStatusCode.OK });
|
|
529
|
-
span.end();
|
|
530
|
-
}
|
|
531
|
-
#recordCleanupOperationSpan(source, event) {
|
|
532
|
-
const span = this.#tracer.startSpan(WORKFLOW_SPAN_NAMES.cleanupOperation, { attributes: this.#attributes({
|
|
533
|
-
[WORKFLOW_ATTRIBUTES.cleanupSource]: source,
|
|
534
|
-
[WORKFLOW_ATTRIBUTES.cleanupDeletedRuns]: event.result.deletedRuns,
|
|
535
|
-
[WORKFLOW_ATTRIBUTES.cleanupCreatedMarkers]: event.result.createdCleanupMarkers,
|
|
536
|
-
[WORKFLOW_ATTRIBUTES.cleanupDeletedMarkers]: event.result.deletedCleanupMarkers,
|
|
537
|
-
[WORKFLOW_ATTRIBUTES.cleanupDeletedEvents]: event.result.deletedEvents,
|
|
538
|
-
[WORKFLOW_ATTRIBUTES.cleanupDeletedStepAttempts]: event.result.deletedStepAttempts,
|
|
539
|
-
[WORKFLOW_ATTRIBUTES.cleanupDeletedIdempotencyKeys]: event.result.deletedIdempotencyKeys,
|
|
540
|
-
[WORKFLOW_ATTRIBUTES.cleanupDeletedMessageIdempotencyKeys]: event.result.deletedMessageIdempotencyKeys,
|
|
541
|
-
...event.result.dryRun === void 0 ? {} : { [WORKFLOW_ATTRIBUTES.cleanupDryRun]: event.result.dryRun },
|
|
542
|
-
[WORKFLOW_ATTRIBUTES.cleanupMatchedRuns]: event.result.matchedRuns ?? event.result.runIds.length
|
|
543
|
-
}) });
|
|
544
|
-
span.setStatus({ code: SpanStatusCode.OK });
|
|
545
|
-
span.end();
|
|
546
|
-
}
|
|
547
|
-
#recordStreamOperationSpan(event) {
|
|
548
|
-
const span = this.#tracer.startSpan(WORKFLOW_SPAN_NAMES.streamOperation, { attributes: this.#attributes({
|
|
549
|
-
[WORKFLOW_ATTRIBUTES.runId]: event.runId,
|
|
550
|
-
[WORKFLOW_ATTRIBUTES.streamId]: event.streamId,
|
|
551
|
-
[WORKFLOW_ATTRIBUTES.streamEventKind]: event.eventKind,
|
|
552
|
-
[WORKFLOW_ATTRIBUTES.streamStatus]: streamStatusFromEventKind(event.eventKind),
|
|
553
|
-
[WORKFLOW_ATTRIBUTES.stepId]: event.stepId,
|
|
554
|
-
[WORKFLOW_ATTRIBUTES.stepName]: event.stepName,
|
|
555
|
-
...event.index === void 0 ? {} : { [WORKFLOW_ATTRIBUTES.streamIndex]: event.index },
|
|
556
|
-
...event.error === void 0 ? {} : { [WORKFLOW_ATTRIBUTES.errorKind]: event.error.name }
|
|
557
|
-
}) });
|
|
558
|
-
if (event.error === void 0) span.setStatus({ code: SpanStatusCode.OK });
|
|
559
|
-
else {
|
|
560
|
-
span.recordException(errorRecordToException(event.error));
|
|
561
|
-
span.setStatus({
|
|
562
|
-
code: SpanStatusCode.ERROR,
|
|
563
|
-
message: event.error.message
|
|
564
|
-
});
|
|
565
|
-
}
|
|
566
|
-
span.end();
|
|
567
|
-
}
|
|
568
|
-
#recordMessageWaitSpan(completed, started, history) {
|
|
569
|
-
const message = history.messageSentByTimestamp(completed.messageId, completed.messageTimestamp);
|
|
570
|
-
const link = spanLinkFromTraceContext(completed.telemetryContext ?? message?.telemetryContext);
|
|
571
|
-
return this.#tracer.startActiveSpan(WORKFLOW_SPAN_NAMES.messageWait, {
|
|
572
|
-
attributes: this.#attributes({
|
|
573
|
-
[WORKFLOW_ATTRIBUTES.messageId]: completed.messageId,
|
|
574
|
-
[WORKFLOW_ATTRIBUTES.messageSource]: started.source ?? "message",
|
|
575
|
-
[WORKFLOW_ATTRIBUTES.stepId]: completed.stepId,
|
|
576
|
-
[WORKFLOW_ATTRIBUTES.stepName]: completed.stepName,
|
|
577
|
-
[WORKFLOW_MESSAGING_ATTRIBUTES.system]: "temelj.workflow",
|
|
578
|
-
[WORKFLOW_MESSAGING_ATTRIBUTES.messageId]: completed.messageId,
|
|
579
|
-
[WORKFLOW_MESSAGING_ATTRIBUTES.operationName]: "receive",
|
|
580
|
-
[WORKFLOW_MESSAGING_ATTRIBUTES.operationType]: "receive"
|
|
581
|
-
}),
|
|
582
|
-
...link === void 0 ? {} : { links: [link] }
|
|
583
|
-
}, (span) => {
|
|
584
|
-
span.setStatus({ code: SpanStatusCode.OK });
|
|
585
|
-
span.end();
|
|
586
|
-
});
|
|
587
|
-
}
|
|
588
|
-
};
|
|
589
|
-
//#endregion
|
|
590
|
-
export { createOpenTelemetryTelemetry };
|
package/dist/runtime.d.mts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { RunId } from "./types/run-id.mjs";
|
|
2
|
-
import { WorkflowDefinition, WorkflowHandler, WorkflowImplementation } from "./types/definition.mjs";
|
|
3
|
-
import "./types/run.mjs";
|
|
4
|
-
import { WorkflowRunArguments, WorkflowStartOptions } from "./types/run-options.mjs";
|
|
5
|
-
import { CompiledWorkflowFunction, WorkflowClientWorkersApi, WorkflowRunHandle } from "./types/client.mjs";
|
|
6
|
-
import { CreateWorkflowRuntimeOptions, WorkflowRuntime as WorkflowRuntime$1, WorkflowRuntimeLocksApi, WorkflowRuntimeRunsApi, WorkflowRuntimeSchedulesApi } from "./types/runtime.mjs";
|
|
7
|
-
import "temporal-polyfill/global";
|
|
8
|
-
//#region src/runtime.d.ts
|
|
9
|
-
/** Creates a workflow runtime backed by a workflow client. */
|
|
10
|
-
declare function createWorkflowRuntime(options?: CreateWorkflowRuntimeOptions): WorkflowRuntime$1;
|
|
11
|
-
/** Workflow runtime implementation backed by a workflow client. */
|
|
12
|
-
declare class WorkflowRuntime implements WorkflowRuntime$1 {
|
|
13
|
-
#private;
|
|
14
|
-
readonly runs: WorkflowRuntimeRunsApi;
|
|
15
|
-
readonly schedules: WorkflowRuntimeSchedulesApi;
|
|
16
|
-
readonly locks: WorkflowRuntimeLocksApi;
|
|
17
|
-
readonly workers: WorkflowClientWorkersApi;
|
|
18
|
-
constructor(options?: CreateWorkflowRuntimeOptions);
|
|
19
|
-
close(): Promise<void>;
|
|
20
|
-
implementWorkflow<TInput, TOutput, TRawInput = TInput>(definition: WorkflowDefinition<TInput, TOutput, TRawInput>, handler: WorkflowHandler<TInput, TOutput>): WorkflowImplementation<TInput, TOutput, TRawInput>;
|
|
21
|
-
register<TInput, TOutput, TRawInput = TInput>(implementation: WorkflowImplementation<TInput, TOutput, TRawInput>): void;
|
|
22
|
-
start<TInput, TOutput, TRawInput = TInput>(workflow: WorkflowDefinition<TInput, TOutput, TRawInput>, ...args: WorkflowRunArguments<TRawInput, WorkflowStartOptions>): Promise<WorkflowRunHandle<TOutput>>;
|
|
23
|
-
start<TInput, TOutput, TRawInput = TInput>(workflow: WorkflowImplementation<TInput, TOutput, TRawInput>, ...args: WorkflowRunArguments<TRawInput, WorkflowStartOptions>): Promise<WorkflowRunHandle<TOutput>>;
|
|
24
|
-
start<TArgs extends readonly unknown[], TOutput>(workflow: CompiledWorkflowFunction<TArgs, TOutput>, ...args: TArgs): Promise<WorkflowRunHandle<Awaited<TOutput>>>;
|
|
25
|
-
}
|
|
26
|
-
/** Starts a workflow through an explicit runtime and returns a client run handle. */
|
|
27
|
-
declare function startWorkflowRuntimeRun<TInput, TOutput, TRawInput = TInput>(runtime: WorkflowRuntime, workflow: WorkflowImplementation<TInput, TOutput, TRawInput>, ...args: WorkflowRunArguments<TRawInput, WorkflowStartOptions>): Promise<WorkflowRunHandle<TOutput>>;
|
|
28
|
-
/** Starts a workflow through an explicit runtime and returns a client run handle. */
|
|
29
|
-
declare function startWorkflowRuntimeRun<TInput, TOutput, TRawInput = TInput>(runtime: WorkflowRuntime, workflow: WorkflowDefinition<TInput, TOutput, TRawInput>, ...args: WorkflowRunArguments<TRawInput, WorkflowStartOptions>): Promise<WorkflowRunHandle<TOutput>>;
|
|
30
|
-
/** Starts a workflow through an explicit runtime and returns a client run handle. */
|
|
31
|
-
declare function startWorkflowRuntimeRun<TArgs extends readonly unknown[], TOutput>(runtime: WorkflowRuntime, workflow: CompiledWorkflowFunction<TArgs, TOutput>, ...args: TArgs): Promise<WorkflowRunHandle<Awaited<TOutput>>>;
|
|
32
|
-
/** Returns a typed handle for an existing run through an explicit runtime. */
|
|
33
|
-
declare function getWorkflowRuntimeRun<TOutput = unknown>(runtime: WorkflowRuntime, runId: RunId): Promise<WorkflowRunHandle<TOutput>>;
|
|
34
|
-
//#endregion
|
|
35
|
-
export { WorkflowRuntime, createWorkflowRuntime, getWorkflowRuntimeRun, startWorkflowRuntimeRun };
|