@temelj/workflow 0.0.0-alpha.1
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/LICENSE +21 -0
- package/README.md +38 -0
- package/dist/attributes.d.mts +15 -0
- package/dist/attributes.mjs +30 -0
- package/dist/client/create.d.mts +31 -0
- package/dist/client/create.mjs +67 -0
- package/dist/client/facades.d.mts +21 -0
- package/dist/client/facades.mjs +142 -0
- package/dist/client/mod.d.mts +2 -0
- package/dist/client/mod.mjs +2 -0
- package/dist/client/run-handle.d.mts +66 -0
- package/dist/client/run-handle.mjs +156 -0
- package/dist/client/worker-options.d.mts +17 -0
- package/dist/client/worker-options.mjs +25 -0
- package/dist/collection.d.mts +15 -0
- package/dist/collection.mjs +33 -0
- package/dist/compiled-function.d.mts +27 -0
- package/dist/compiled-function.mjs +54 -0
- package/dist/definition.d.mts +37 -0
- package/dist/definition.mjs +83 -0
- package/dist/engine/child-workflow.d.mts +10 -0
- package/dist/engine/child-workflow.mjs +333 -0
- package/dist/engine/command-identity.d.mts +9 -0
- package/dist/engine/command-identity.mjs +14 -0
- package/dist/engine/create.d.mts +106 -0
- package/dist/engine/create.mjs +402 -0
- package/dist/engine/deterministic.d.mts +12 -0
- package/dist/engine/deterministic.mjs +102 -0
- package/dist/engine/durable-command.d.mts +10 -0
- package/dist/engine/durable-command.mjs +17 -0
- package/dist/engine/execution-api.d.mts +29 -0
- package/dist/engine/execution-api.mjs +33 -0
- package/dist/engine/execution-service.d.mts +41 -0
- package/dist/engine/execution-service.mjs +288 -0
- package/dist/engine/hooks.d.mts +56 -0
- package/dist/engine/hooks.mjs +237 -0
- package/dist/engine/inspection-api.d.mts +34 -0
- package/dist/engine/inspection-api.mjs +77 -0
- package/dist/engine/inspection.d.mts +18 -0
- package/dist/engine/inspection.mjs +149 -0
- package/dist/engine/lifecycle.d.mts +18 -0
- package/dist/engine/lifecycle.mjs +38 -0
- package/dist/engine/lock-replay.d.mts +30 -0
- package/dist/engine/lock-replay.mjs +38 -0
- package/dist/engine/lock.d.mts +21 -0
- package/dist/engine/lock.mjs +197 -0
- package/dist/engine/message.d.mts +47 -0
- package/dist/engine/message.mjs +357 -0
- package/dist/engine/mod.d.mts +4 -0
- package/dist/engine/mod.mjs +2 -0
- package/dist/engine/observation.d.mts +35 -0
- package/dist/engine/observation.mjs +201 -0
- package/dist/engine/recovery.d.mts +26 -0
- package/dist/engine/recovery.mjs +92 -0
- package/dist/engine/replay.d.mts +41 -0
- package/dist/engine/replay.mjs +122 -0
- package/dist/engine/retry-policy.d.mts +4 -0
- package/dist/engine/retry-policy.mjs +4 -0
- package/dist/engine/retry.d.mts +23 -0
- package/dist/engine/retry.mjs +75 -0
- package/dist/engine/run-data.d.mts +9 -0
- package/dist/engine/run-data.mjs +74 -0
- package/dist/engine/run-service.d.mts +38 -0
- package/dist/engine/run-service.mjs +133 -0
- package/dist/engine/run-utils.d.mts +16 -0
- package/dist/engine/run-utils.mjs +83 -0
- package/dist/engine/schedule.d.mts +25 -0
- package/dist/engine/schedule.mjs +207 -0
- package/dist/engine/serialization.d.mts +9 -0
- package/dist/engine/serialization.mjs +85 -0
- package/dist/engine/start-api.d.mts +30 -0
- package/dist/engine/start-api.mjs +98 -0
- package/dist/engine/state.d.mts +77 -0
- package/dist/engine/state.mjs +464 -0
- package/dist/engine/step-api.d.mts +9 -0
- package/dist/engine/step-api.mjs +25 -0
- package/dist/engine/stream.d.mts +55 -0
- package/dist/engine/stream.mjs +333 -0
- package/dist/engine/summary/active-events.d.mts +34 -0
- package/dist/engine/summary/active-events.mjs +69 -0
- package/dist/engine/summary/child-workflow-runs.d.mts +24 -0
- package/dist/engine/summary/child-workflow-runs.mjs +138 -0
- package/dist/engine/summary/child-workflow-waits.d.mts +21 -0
- package/dist/engine/summary/child-workflow-waits.mjs +67 -0
- package/dist/engine/summary/recovery-child-workflow-waits.d.mts +11 -0
- package/dist/engine/summary/recovery-child-workflow-waits.mjs +89 -0
- package/dist/engine/summary/recovery-due-runs.d.mts +16 -0
- package/dist/engine/summary/recovery-due-runs.mjs +52 -0
- package/dist/engine/summary/recovery-failed-runs.d.mts +14 -0
- package/dist/engine/summary/recovery-failed-runs.mjs +33 -0
- package/dist/engine/summary/recovery-lease-runs.d.mts +16 -0
- package/dist/engine/summary/recovery-lease-runs.mjs +69 -0
- package/dist/engine/summary/recovery-locks.d.mts +18 -0
- package/dist/engine/summary/recovery-locks.mjs +100 -0
- package/dist/engine/summary/recovery-message-waits.d.mts +11 -0
- package/dist/engine/summary/recovery-message-waits.mjs +74 -0
- package/dist/engine/summary/recovery-retry-runs.d.mts +17 -0
- package/dist/engine/summary/recovery-retry-runs.mjs +65 -0
- package/dist/engine/summary/recovery-run-timestamps.d.mts +13 -0
- package/dist/engine/summary/recovery-run-timestamps.mjs +18 -0
- package/dist/engine/summary/recovery-runs.d.mts +23 -0
- package/dist/engine/summary/recovery-runs.mjs +54 -0
- package/dist/engine/summary/recovery-schedules.d.mts +10 -0
- package/dist/engine/summary/recovery-schedules.mjs +46 -0
- package/dist/engine/summary/recovery-sleep-waits.d.mts +10 -0
- package/dist/engine/summary/recovery-sleep-waits.mjs +53 -0
- package/dist/engine/summary/recovery-waits.d.mts +21 -0
- package/dist/engine/summary/recovery-waits.mjs +29 -0
- package/dist/engine/summary/run-availability.d.mts +13 -0
- package/dist/engine/summary/run-availability.mjs +37 -0
- package/dist/engine/summary/run-cleanup.d.mts +14 -0
- package/dist/engine/summary/run-cleanup.mjs +44 -0
- package/dist/engine/summary/run-failure.d.mts +14 -0
- package/dist/engine/summary/run-failure.mjs +62 -0
- package/dist/engine/summary/run-hooks.d.mts +14 -0
- package/dist/engine/summary/run-hooks.mjs +63 -0
- package/dist/engine/summary/run-lease.d.mts +11 -0
- package/dist/engine/summary/run-lease.mjs +64 -0
- package/dist/engine/summary/run-message-waits.d.mts +15 -0
- package/dist/engine/summary/run-message-waits.mjs +62 -0
- package/dist/engine/summary/run-metrics.d.mts +31 -0
- package/dist/engine/summary/run-metrics.mjs +93 -0
- package/dist/engine/summary/run-retry.d.mts +9 -0
- package/dist/engine/summary/run-retry.mjs +69 -0
- package/dist/engine/summary/run-sleeps.d.mts +15 -0
- package/dist/engine/summary/run-sleeps.mjs +61 -0
- package/dist/engine/summary/run-state.d.mts +26 -0
- package/dist/engine/summary/run-state.mjs +48 -0
- package/dist/engine/summary/run-status.d.mts +16 -0
- package/dist/engine/summary/run-status.mjs +35 -0
- package/dist/engine/summary/run-streams.d.mts +14 -0
- package/dist/engine/summary/run-streams.mjs +46 -0
- package/dist/engine/summary/run-transition.d.mts +9 -0
- package/dist/engine/summary/run-transition.mjs +39 -0
- package/dist/engine/summary/run-workflow.d.mts +9 -0
- package/dist/engine/summary/run-workflow.mjs +47 -0
- package/dist/engine/summary/step-attempt-active-child-workflows.d.mts +13 -0
- package/dist/engine/summary/step-attempt-active-child-workflows.mjs +55 -0
- package/dist/engine/summary/step-attempt-active-fields.d.mts +23 -0
- package/dist/engine/summary/step-attempt-active-fields.mjs +14 -0
- package/dist/engine/summary/step-attempt-active-message-waits.d.mts +12 -0
- package/dist/engine/summary/step-attempt-active-message-waits.mjs +47 -0
- package/dist/engine/summary/step-attempt-active-sleeps.d.mts +19 -0
- package/dist/engine/summary/step-attempt-active-sleeps.mjs +44 -0
- package/dist/engine/summary/step-attempt-buckets.d.mts +22 -0
- package/dist/engine/summary/step-attempt-buckets.mjs +152 -0
- package/dist/engine/summary/step-attempt-failure.d.mts +12 -0
- package/dist/engine/summary/step-attempt-failure.mjs +61 -0
- package/dist/engine/summary/step-attempt-lifecycle.d.mts +13 -0
- package/dist/engine/summary/step-attempt-lifecycle.mjs +19 -0
- package/dist/engine/summary/step-attempts.d.mts +11 -0
- package/dist/engine/summary/step-attempts.mjs +43 -0
- package/dist/engine/summary.d.mts +32 -0
- package/dist/engine/summary.mjs +37 -0
- package/dist/engine/task.d.mts +6 -0
- package/dist/engine/task.mjs +207 -0
- package/dist/errors/base.d.mts +99 -0
- package/dist/errors/base.mjs +426 -0
- package/dist/errors/capability.d.mts +11 -0
- package/dist/errors/capability.mjs +23 -0
- package/dist/errors/definition.d.mts +21 -0
- package/dist/errors/definition.mjs +51 -0
- package/dist/errors/details.d.mts +13 -0
- package/dist/errors/details.mjs +65 -0
- package/dist/errors/failures.d.mts +81 -0
- package/dist/errors/failures.mjs +168 -0
- package/dist/errors/hook.d.mts +14 -0
- package/dist/errors/hook.mjs +30 -0
- package/dist/errors/implementation.d.mts +11 -0
- package/dist/errors/implementation.mjs +25 -0
- package/dist/errors/lock.d.mts +28 -0
- package/dist/errors/lock.mjs +70 -0
- package/dist/errors/message.d.mts +106 -0
- package/dist/errors/message.mjs +122 -0
- package/dist/errors/mod.d.mts +17 -0
- package/dist/errors/mod.mjs +17 -0
- package/dist/errors/record-view.d.mts +11 -0
- package/dist/errors/record-view.mjs +24 -0
- package/dist/errors/records.d.mts +7 -0
- package/dist/errors/records.mjs +280 -0
- package/dist/errors/run.d.mts +116 -0
- package/dist/errors/run.mjs +232 -0
- package/dist/errors/runtime.d.mts +12 -0
- package/dist/errors/runtime.mjs +24 -0
- package/dist/errors/schedule.d.mts +27 -0
- package/dist/errors/schedule.mjs +65 -0
- package/dist/errors/step.d.mts +76 -0
- package/dist/errors/step.mjs +113 -0
- package/dist/errors/stream.d.mts +24 -0
- package/dist/errors/stream.mjs +64 -0
- package/dist/esbuild.d.mts +7 -0
- package/dist/esbuild.mjs +6 -0
- package/dist/events/descriptors.d.mts +245 -0
- package/dist/events/descriptors.mjs +405 -0
- package/dist/events/mod.d.mts +3 -0
- package/dist/events/mod.mjs +2 -0
- package/dist/history/attempt-key.d.mts +6 -0
- package/dist/history/attempt-key.mjs +7 -0
- package/dist/history/mod.d.mts +71 -0
- package/dist/history/mod.mjs +195 -0
- package/dist/history/projection.d.mts +8 -0
- package/dist/history/projection.mjs +259 -0
- package/dist/history/replay-projection.d.mts +88 -0
- package/dist/history/replay-projection.mjs +369 -0
- package/dist/history/sequencer.d.mts +16 -0
- package/dist/history/sequencer.mjs +78 -0
- package/dist/history/step-attempts.d.mts +9 -0
- package/dist/history/step-attempts.mjs +50 -0
- package/dist/history/timeline.d.mts +16 -0
- package/dist/history/timeline.mjs +272 -0
- package/dist/history/validator.d.mts +9 -0
- package/dist/history/validator.mjs +110 -0
- package/dist/inspection/mod.d.mts +5 -0
- package/dist/inspection/mod.mjs +3 -0
- package/dist/message-options.d.mts +8 -0
- package/dist/message-options.mjs +25 -0
- package/dist/mod.d.mts +52 -0
- package/dist/mod.mjs +26 -0
- package/dist/otel/support.d.mts +18 -0
- package/dist/otel/support.mjs +102 -0
- package/dist/otel.d.mts +30 -0
- package/dist/otel.mjs +588 -0
- package/dist/pagination.d.mts +25 -0
- package/dist/pagination.mjs +73 -0
- package/dist/registry.d.mts +20 -0
- package/dist/registry.mjs +48 -0
- package/dist/rolldown.d.mts +7 -0
- package/dist/rolldown.mjs +6 -0
- package/dist/rollup.d.mts +7 -0
- package/dist/rollup.mjs +6 -0
- package/dist/rspack.d.mts +7 -0
- package/dist/rspack.mjs +6 -0
- package/dist/runtime.d.mts +34 -0
- package/dist/runtime.mjs +194 -0
- package/dist/step-definition.d.mts +10 -0
- package/dist/step-definition.mjs +15 -0
- package/dist/store/append-projection.d.mts +15 -0
- package/dist/store/append-projection.mjs +26 -0
- package/dist/store/capabilities.d.mts +14 -0
- package/dist/store/capabilities.mjs +42 -0
- package/dist/store/cleanup.d.mts +18 -0
- package/dist/store/cleanup.mjs +338 -0
- package/dist/store/compaction.d.mts +5 -0
- package/dist/store/compaction.mjs +8 -0
- package/dist/store/create.d.mts +52 -0
- package/dist/store/create.mjs +159 -0
- package/dist/store/event-append-project.d.mts +15 -0
- package/dist/store/event-append-project.mjs +77 -0
- package/dist/store/event-append.d.mts +37 -0
- package/dist/store/event-append.mjs +80 -0
- package/dist/store/event-history.d.mts +22 -0
- package/dist/store/event-history.mjs +75 -0
- package/dist/store/event.d.mts +10 -0
- package/dist/store/event.mjs +28 -0
- package/dist/store/idempotency.d.mts +10 -0
- package/dist/store/idempotency.mjs +167 -0
- package/dist/store/instrumentation.d.mts +7 -0
- package/dist/store/instrumentation.mjs +123 -0
- package/dist/store/lock.d.mts +8 -0
- package/dist/store/lock.mjs +28 -0
- package/dist/store/materialization.d.mts +30 -0
- package/dist/store/materialization.mjs +127 -0
- package/dist/store/message-index.d.mts +21 -0
- package/dist/store/message-index.mjs +121 -0
- package/dist/store/mod.d.mts +5 -0
- package/dist/store/mod.mjs +4 -0
- package/dist/store/query.d.mts +24 -0
- package/dist/store/query.mjs +82 -0
- package/dist/store/revision.d.mts +4 -0
- package/dist/store/revision.mjs +7 -0
- package/dist/store/run.d.mts +49 -0
- package/dist/store/run.mjs +236 -0
- package/dist/store/schedule.d.mts +12 -0
- package/dist/store/schedule.mjs +41 -0
- package/dist/store/schema.d.mts +14 -0
- package/dist/store/schema.mjs +17 -0
- package/dist/store/step-attempt.d.mts +14 -0
- package/dist/store/step-attempt.mjs +23 -0
- package/dist/store/storage-value.d.mts +5 -0
- package/dist/store/storage-value.mjs +6 -0
- package/dist/store/validation.d.mts +35 -0
- package/dist/store/validation.mjs +77 -0
- package/dist/store-keys.d.mts +49 -0
- package/dist/store-keys.mjs +63 -0
- package/dist/telemetry.d.mts +132 -0
- package/dist/telemetry.mjs +172 -0
- package/dist/temporal.d.mts +23 -0
- package/dist/temporal.mjs +59 -0
- package/dist/timer.d.mts +12 -0
- package/dist/timer.mjs +28 -0
- package/dist/types/cleanup.d.mts +112 -0
- package/dist/types/cleanup.mjs +22 -0
- package/dist/types/client.d.mts +270 -0
- package/dist/types/client.mjs +1 -0
- package/dist/types/common.d.mts +19 -0
- package/dist/types/common.mjs +15 -0
- package/dist/types/definition.d.mts +92 -0
- package/dist/types/definition.mjs +1 -0
- package/dist/types/engine-options.d.mts +76 -0
- package/dist/types/engine-options.mjs +1 -0
- package/dist/types/engine.d.mts +309 -0
- package/dist/types/engine.mjs +1 -0
- package/dist/types/error-code.d.mts +256 -0
- package/dist/types/error-code.mjs +131 -0
- package/dist/types/error.d.mts +236 -0
- package/dist/types/error.mjs +48 -0
- package/dist/types/events.d.mts +2869 -0
- package/dist/types/events.mjs +283 -0
- package/dist/types/hook.d.mts +149 -0
- package/dist/types/hook.mjs +66 -0
- package/dist/types/lock.d.mts +63 -0
- package/dist/types/lock.mjs +18 -0
- package/dist/types/message-id.d.mts +7 -0
- package/dist/types/message-id.mjs +5 -0
- package/dist/types/message.d.mts +87 -0
- package/dist/types/message.mjs +1 -0
- package/dist/types/observation.d.mts +146 -0
- package/dist/types/observation.mjs +1 -0
- package/dist/types/pagination.d.mts +32 -0
- package/dist/types/pagination.mjs +13 -0
- package/dist/types/result.d.mts +62 -0
- package/dist/types/result.mjs +1 -0
- package/dist/types/retry.d.mts +48 -0
- package/dist/types/retry.mjs +1 -0
- package/dist/types/run-id.d.mts +7 -0
- package/dist/types/run-id.mjs +5 -0
- package/dist/types/run-list.d.mts +43 -0
- package/dist/types/run-list.mjs +1 -0
- package/dist/types/run-options.d.mts +86 -0
- package/dist/types/run-options.mjs +1 -0
- package/dist/types/run.d.mts +355 -0
- package/dist/types/run.mjs +207 -0
- package/dist/types/runtime.d.mts +143 -0
- package/dist/types/runtime.mjs +21 -0
- package/dist/types/schedule.d.mts +127 -0
- package/dist/types/schedule.mjs +48 -0
- package/dist/types/step-attempts.d.mts +326 -0
- package/dist/types/step-attempts.mjs +43 -0
- package/dist/types/step-id.d.mts +7 -0
- package/dist/types/step-id.mjs +5 -0
- package/dist/types/step.d.mts +183 -0
- package/dist/types/step.mjs +5 -0
- package/dist/types/store.d.mts +254 -0
- package/dist/types/store.mjs +1 -0
- package/dist/types/stream-id.d.mts +7 -0
- package/dist/types/stream-id.mjs +5 -0
- package/dist/types/stream.d.mts +126 -0
- package/dist/types/stream.mjs +1 -0
- package/dist/types/summary.d.mts +318 -0
- package/dist/types/summary.mjs +1 -0
- package/dist/types/telemetry.d.mts +74 -0
- package/dist/types/telemetry.mjs +9 -0
- package/dist/types/timeline.d.mts +237 -0
- package/dist/types/timeline.mjs +1 -0
- package/dist/types/vite.d.mts +65 -0
- package/dist/types/vite.mjs +1 -0
- package/dist/types/worker-id.d.mts +7 -0
- package/dist/types/worker-id.mjs +5 -0
- package/dist/types/worker.d.mts +94 -0
- package/dist/types/worker.mjs +1 -0
- package/dist/utility.d.mts +49 -0
- package/dist/utility.mjs +122 -0
- package/dist/vite/ast.d.mts +23 -0
- package/dist/vite/ast.mjs +73 -0
- package/dist/vite/error.d.mts +19 -0
- package/dist/vite/error.mjs +47 -0
- package/dist/vite/generated-name.d.mts +7 -0
- package/dist/vite/generated-name.mjs +9 -0
- package/dist/vite/manifest.d.mts +7 -0
- package/dist/vite/manifest.mjs +106 -0
- package/dist/vite/plugin.d.mts +7 -0
- package/dist/vite/plugin.mjs +190 -0
- package/dist/vite/safety.d.mts +12 -0
- package/dist/vite/safety.mjs +96 -0
- package/dist/vite/source-edit.d.mts +12 -0
- package/dist/vite/source-edit.mjs +44 -0
- package/dist/vite/source-map.d.mts +11 -0
- package/dist/vite/source-map.mjs +53 -0
- package/dist/vite/source.d.mts +7 -0
- package/dist/vite/source.mjs +14 -0
- package/dist/vite/transform.d.mts +7 -0
- package/dist/vite/transform.mjs +405 -0
- package/dist/vite.d.mts +6 -0
- package/dist/vite.mjs +5 -0
- package/dist/webhook.d.mts +16 -0
- package/dist/webhook.mjs +17 -0
- package/dist/webpack.d.mts +7 -0
- package/dist/webpack.mjs +6 -0
- package/dist/worker/error.d.mts +11 -0
- package/dist/worker/error.mjs +40 -0
- package/dist/worker.d.mts +18 -0
- package/dist/worker.mjs +427 -0
- package/package.json +144 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { RunId } from "./run-id.mjs";
|
|
2
|
+
import { WorkflowPage } from "./pagination.mjs";
|
|
3
|
+
import { ListSchedulesOptions, ListSchedulesPageOptions, ScheduleConfig, ScheduleId, ScheduleRecord, TickSchedulesOptions, TickSchedulesResult } from "./schedule.mjs";
|
|
4
|
+
import { RegistryLike, WorkflowDefinition, WorkflowHandler, WorkflowImplementation, WorkflowStartTarget } from "./definition.mjs";
|
|
5
|
+
import { AcquireLockOptions, LockRecord, ReleaseLockOptions, ReleaseStaleLockOptions } from "./lock.mjs";
|
|
6
|
+
import { WorkflowListRunsOptions } from "./run-list.mjs";
|
|
7
|
+
import { Telemetry } from "./telemetry.mjs";
|
|
8
|
+
import { WorkflowLifecycleCallback, WorkflowRunRecord } from "./run.mjs";
|
|
9
|
+
import { ScheduleNextOptions, WorkflowRunArguments, WorkflowStartOptions } from "./run-options.mjs";
|
|
10
|
+
import { WorkflowDeterministicBytesContext, WorkflowDeterministicValueContext, WorkflowExecutionLimits, WorkflowRecordedIdContext } from "./engine-options.mjs";
|
|
11
|
+
import { WorkflowClientEngine, WorkflowWorkerEngine } from "./engine.mjs";
|
|
12
|
+
import { CompiledWorkflowFunction, WorkflowClientWorkersApi, WorkflowRunHandle } from "./client.mjs";
|
|
13
|
+
import { z } from "zod";
|
|
14
|
+
import { Logger } from "@temelj/log";
|
|
15
|
+
//#region src/types/runtime.d.ts
|
|
16
|
+
declare const workflowRuntimeSchema: z.ZodObject<{
|
|
17
|
+
runs: z.ZodObject<{}, z.core.$strip>;
|
|
18
|
+
schedules: z.ZodObject<{}, z.core.$strip>;
|
|
19
|
+
locks: z.ZodObject<{}, z.core.$strip>;
|
|
20
|
+
workers: z.ZodObject<{}, z.core.$strip>;
|
|
21
|
+
close: z.ZodCustom<(...args: never[]) => unknown, (...args: never[]) => unknown>;
|
|
22
|
+
implementWorkflow: z.ZodCustom<(...args: never[]) => unknown, (...args: never[]) => unknown>;
|
|
23
|
+
register: z.ZodCustom<(...args: never[]) => unknown, (...args: never[]) => unknown>;
|
|
24
|
+
start: z.ZodCustom<(...args: never[]) => unknown, (...args: never[]) => unknown>;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
/** Asserts that a value has the minimum shape required by runtime helper functions. */
|
|
27
|
+
declare function parseWorkflowRuntime(value: unknown): asserts value is WorkflowRuntime;
|
|
28
|
+
/** Options for workflow creation runtime. */
|
|
29
|
+
interface CreateWorkflowRuntimeOptions extends WorkflowExecutionLimits {
|
|
30
|
+
readonly engine?: WorkflowClientEngine;
|
|
31
|
+
readonly workerEngine?: WorkflowWorkerEngine;
|
|
32
|
+
readonly registry?: RegistryLike;
|
|
33
|
+
/**
|
|
34
|
+
* Clock used for workflow timestamps and the first value recorded by
|
|
35
|
+
* deterministic time commands.
|
|
36
|
+
*
|
|
37
|
+
* Hosts that patch `Date.now()` during workflow execution should route
|
|
38
|
+
* patched calls through the same durable recording path.
|
|
39
|
+
*/
|
|
40
|
+
readonly now?: () => Temporal.Instant;
|
|
41
|
+
readonly createRunId?: () => string;
|
|
42
|
+
readonly createRecordedId?: (context: WorkflowRecordedIdContext) => string;
|
|
43
|
+
/**
|
|
44
|
+
* Creates the first value recorded by deterministic random commands.
|
|
45
|
+
*
|
|
46
|
+
* Hosts that patch `Math.random()` during workflow execution should route
|
|
47
|
+
* patched calls through the same durable recording path.
|
|
48
|
+
*/
|
|
49
|
+
readonly createDeterministicRandom?: (context: WorkflowDeterministicValueContext) => number;
|
|
50
|
+
/**
|
|
51
|
+
* Creates the first value recorded by deterministic UUID commands.
|
|
52
|
+
*
|
|
53
|
+
* Hosts that patch `crypto.randomUUID()` during workflow execution should
|
|
54
|
+
* route patched calls through the same durable recording path.
|
|
55
|
+
*/
|
|
56
|
+
readonly createDeterministicUuid?: (context: WorkflowDeterministicValueContext) => string;
|
|
57
|
+
/**
|
|
58
|
+
* Creates the first value recorded by deterministic byte commands.
|
|
59
|
+
*
|
|
60
|
+
* Hosts that patch `crypto.getRandomValues()` during workflow execution
|
|
61
|
+
* should route patched calls through the same durable recording path.
|
|
62
|
+
*/
|
|
63
|
+
readonly createDeterministicBytes?: (context: WorkflowDeterministicBytesContext) => Uint8Array;
|
|
64
|
+
readonly onLifecycleEvent?: WorkflowLifecycleCallback;
|
|
65
|
+
readonly onRunCompleted?: WorkflowLifecycleCallback;
|
|
66
|
+
readonly onRunFailed?: WorkflowLifecycleCallback;
|
|
67
|
+
readonly onRunCanceled?: WorkflowLifecycleCallback;
|
|
68
|
+
readonly onRunWaiting?: WorkflowLifecycleCallback;
|
|
69
|
+
readonly onRunRetry?: WorkflowLifecycleCallback;
|
|
70
|
+
readonly maximumStepAttemptsPerRun?: number;
|
|
71
|
+
readonly telemetry?: Telemetry | false;
|
|
72
|
+
readonly logger?: Logger | false;
|
|
73
|
+
}
|
|
74
|
+
/** Describes the workflow runtime contract. */
|
|
75
|
+
interface WorkflowRuntime {
|
|
76
|
+
/** Grouped run handle and run listing operations. */
|
|
77
|
+
readonly runs: WorkflowRuntimeRunsApi;
|
|
78
|
+
/** Grouped schedule management operations. */
|
|
79
|
+
readonly schedules: WorkflowRuntimeSchedulesApi;
|
|
80
|
+
/** Grouped workflow lock operations. */
|
|
81
|
+
readonly locks: WorkflowRuntimeLocksApi;
|
|
82
|
+
/** Grouped worker operations. */
|
|
83
|
+
readonly workers: WorkflowClientWorkersApi;
|
|
84
|
+
/** Flushes resources owned by this runtime. */
|
|
85
|
+
close(): Promise<void>;
|
|
86
|
+
/** Creates and registers a workflow implementation. */
|
|
87
|
+
implementWorkflow<TInput, TOutput, TRawInput = TInput>(definition: WorkflowDefinition<TInput, TOutput, TRawInput>, handler: WorkflowHandler<TInput, TOutput>): WorkflowImplementation<TInput, TOutput, TRawInput>;
|
|
88
|
+
/** Registers an existing workflow implementation. */
|
|
89
|
+
register<TInput, TOutput, TRawInput = TInput>(implementation: WorkflowImplementation<TInput, TOutput, TRawInput>): void;
|
|
90
|
+
/** Starts a registered workflow definition. */
|
|
91
|
+
start<TInput, TOutput, TRawInput = TInput>(workflow: WorkflowDefinition<TInput, TOutput, TRawInput>, ...args: WorkflowRunArguments<TRawInput, WorkflowStartOptions>): Promise<WorkflowRunHandle<TOutput>>;
|
|
92
|
+
/** Registers and starts a workflow implementation. */
|
|
93
|
+
start<TInput, TOutput, TRawInput = TInput>(workflow: WorkflowImplementation<TInput, TOutput, TRawInput>, ...args: WorkflowRunArguments<TRawInput, WorkflowStartOptions>): Promise<WorkflowRunHandle<TOutput>>;
|
|
94
|
+
/** Starts a compiled workflow function produced by the workflow transform. */
|
|
95
|
+
start<TArgs extends readonly unknown[], TOutput>(workflow: CompiledWorkflowFunction<TArgs, TOutput>, ...args: TArgs): Promise<WorkflowRunHandle<Awaited<TOutput>>>;
|
|
96
|
+
}
|
|
97
|
+
/** Describes runtime-level run operations. */
|
|
98
|
+
interface WorkflowRuntimeRunsApi {
|
|
99
|
+
/** Returns a typed handle for an existing run. */
|
|
100
|
+
getHandle<TOutput = unknown>(runId: RunId): Promise<WorkflowRunHandle<TOutput>>;
|
|
101
|
+
/** Lists workflow runs visible to the runtime client. */
|
|
102
|
+
list(options?: WorkflowListRunsOptions): Promise<readonly WorkflowRunRecord[]>;
|
|
103
|
+
}
|
|
104
|
+
/** Describes runtime-level schedule operations. */
|
|
105
|
+
interface WorkflowRuntimeSchedulesApi {
|
|
106
|
+
/** Schedules one workflow run at the next interval boundary. */
|
|
107
|
+
next<TInput, TOutput, TRawInput = TInput>(workflow: WorkflowStartTarget<TInput, TOutput, TRawInput>, input: TRawInput, options: ScheduleNextOptions): Promise<WorkflowRunHandle<TOutput>>;
|
|
108
|
+
/** Creates a recurring workflow schedule. */
|
|
109
|
+
create<TInput, TOutput, TRawInput = TInput>(workflow: WorkflowStartTarget<TInput, TOutput, TRawInput>, options: ScheduleConfig<TInput, TRawInput>): Promise<ScheduleRecord<TInput>>;
|
|
110
|
+
/** Creates or updates a recurring workflow schedule. */
|
|
111
|
+
upsert<TInput, TOutput, TRawInput = TInput>(workflow: WorkflowStartTarget<TInput, TOutput, TRawInput>, options: ScheduleConfig<TInput, TRawInput>): Promise<ScheduleRecord<TInput>>;
|
|
112
|
+
/** Returns a schedule by ID, if it exists. */
|
|
113
|
+
get(scheduleId: ScheduleId): Promise<ScheduleRecord | undefined>;
|
|
114
|
+
/** Lists schedules matching optional filters. */
|
|
115
|
+
list(options?: ListSchedulesOptions): Promise<readonly ScheduleRecord[]>;
|
|
116
|
+
/** Lists one page of schedules matching optional filters. */
|
|
117
|
+
page(options?: ListSchedulesPageOptions): Promise<WorkflowPage<ScheduleRecord>>;
|
|
118
|
+
/** Pauses an active schedule. */
|
|
119
|
+
pause(scheduleId: ScheduleId): Promise<ScheduleRecord>;
|
|
120
|
+
/** Resumes a paused or archived schedule. */
|
|
121
|
+
resume(scheduleId: ScheduleId): Promise<ScheduleRecord>;
|
|
122
|
+
/** Archives a schedule without deleting its record. */
|
|
123
|
+
archive(scheduleId: ScheduleId): Promise<ScheduleRecord>;
|
|
124
|
+
/** Marks a schedule as deleted. */
|
|
125
|
+
delete(scheduleId: ScheduleId): Promise<ScheduleRecord>;
|
|
126
|
+
/** Starts runs for schedules that are due. */
|
|
127
|
+
tick(options?: TickSchedulesOptions): Promise<TickSchedulesResult>;
|
|
128
|
+
}
|
|
129
|
+
/** Describes runtime-level workflow lock operations. */
|
|
130
|
+
interface WorkflowRuntimeLocksApi {
|
|
131
|
+
/** Acquires a workflow lock. */
|
|
132
|
+
acquire(key: string, options: AcquireLockOptions): Promise<LockRecord>;
|
|
133
|
+
/** Returns a workflow lock by key, if it exists. */
|
|
134
|
+
get(key: string): Promise<LockRecord | undefined>;
|
|
135
|
+
/** Lists workflow locks. */
|
|
136
|
+
list(): Promise<readonly LockRecord[]>;
|
|
137
|
+
/** Releases a workflow lock held by the supplied holder. */
|
|
138
|
+
release(key: string, options: ReleaseLockOptions): Promise<LockRecord>;
|
|
139
|
+
/** Releases a workflow lock only when its lease is stale. */
|
|
140
|
+
releaseStale(key: string, options?: ReleaseStaleLockOptions): Promise<LockRecord>;
|
|
141
|
+
}
|
|
142
|
+
//#endregion
|
|
143
|
+
export { CreateWorkflowRuntimeOptions, WorkflowRuntime, WorkflowRuntimeLocksApi, WorkflowRuntimeRunsApi, WorkflowRuntimeSchedulesApi, parseWorkflowRuntime, workflowRuntimeSchema };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { WorkflowRuntimeError } from "../errors/runtime.mjs";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/types/runtime.ts
|
|
4
|
+
const workflowRuntimeObjectPropertySchema = z.object({});
|
|
5
|
+
const workflowRuntimeFunctionPropertySchema = z.custom((value) => typeof value === "function");
|
|
6
|
+
const workflowRuntimeSchema = z.object({
|
|
7
|
+
runs: workflowRuntimeObjectPropertySchema,
|
|
8
|
+
schedules: workflowRuntimeObjectPropertySchema,
|
|
9
|
+
locks: workflowRuntimeObjectPropertySchema,
|
|
10
|
+
workers: workflowRuntimeObjectPropertySchema,
|
|
11
|
+
close: workflowRuntimeFunctionPropertySchema,
|
|
12
|
+
implementWorkflow: workflowRuntimeFunctionPropertySchema,
|
|
13
|
+
register: workflowRuntimeFunctionPropertySchema,
|
|
14
|
+
start: workflowRuntimeFunctionPropertySchema
|
|
15
|
+
});
|
|
16
|
+
/** Asserts that a value has the minimum shape required by runtime helper functions. */
|
|
17
|
+
function parseWorkflowRuntime(value) {
|
|
18
|
+
if (!workflowRuntimeSchema.safeParse(value).success) WorkflowRuntimeError.invalid();
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { parseWorkflowRuntime, workflowRuntimeSchema };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { RunId } from "./run-id.mjs";
|
|
2
|
+
import { PageOptions } from "./pagination.mjs";
|
|
3
|
+
import "./run.mjs";
|
|
4
|
+
import { StorageValue } from "@temelj/storage";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
//#region src/types/schedule.d.ts
|
|
7
|
+
declare const scheduleIdSchema: z.ZodString;
|
|
8
|
+
declare const workflowScheduleStatusSchema: z.ZodEnum<{
|
|
9
|
+
active: "active";
|
|
10
|
+
archived: "archived";
|
|
11
|
+
deleted: "deleted";
|
|
12
|
+
paused: "paused";
|
|
13
|
+
}>;
|
|
14
|
+
declare const workflowScheduleCatchUpPolicySchema: z.ZodEnum<{
|
|
15
|
+
all: "all";
|
|
16
|
+
one: "one";
|
|
17
|
+
skip: "skip";
|
|
18
|
+
}>;
|
|
19
|
+
declare const workflowScheduleOverlapPolicySchema: z.ZodEnum<{
|
|
20
|
+
allow: "allow";
|
|
21
|
+
buffer: "buffer";
|
|
22
|
+
cancel: "cancel";
|
|
23
|
+
skip: "skip";
|
|
24
|
+
}>;
|
|
25
|
+
declare const workflowSchedulePositiveDurationSchema: z.ZodCustom<Temporal.Duration, Temporal.Duration>;
|
|
26
|
+
declare const workflowScheduleRecordSchema: z.ZodObject<{
|
|
27
|
+
id: z.ZodString;
|
|
28
|
+
namespace: z.ZodString;
|
|
29
|
+
workflowName: z.ZodString;
|
|
30
|
+
workflowVersion: z.ZodOptional<z.ZodString>;
|
|
31
|
+
input: z.ZodOptional<z.ZodType<StorageValue, unknown, z.core.$ZodTypeInternals<StorageValue, unknown>>>;
|
|
32
|
+
context: z.ZodOptional<z.ZodType<StorageValue, unknown, z.core.$ZodTypeInternals<StorageValue, unknown>>>;
|
|
33
|
+
status: z.ZodEnum<{
|
|
34
|
+
active: "active";
|
|
35
|
+
archived: "archived";
|
|
36
|
+
deleted: "deleted";
|
|
37
|
+
paused: "paused";
|
|
38
|
+
}>;
|
|
39
|
+
every: z.ZodCustom<Temporal.Duration, Temporal.Duration>;
|
|
40
|
+
catchUp: z.ZodEnum<{
|
|
41
|
+
all: "all";
|
|
42
|
+
one: "one";
|
|
43
|
+
skip: "skip";
|
|
44
|
+
}>;
|
|
45
|
+
maxCatchUpRuns: z.ZodOptional<z.ZodNumber>;
|
|
46
|
+
maxLateness: z.ZodOptional<z.ZodCustom<Temporal.Duration, Temporal.Duration>>;
|
|
47
|
+
overlap: z.ZodEnum<{
|
|
48
|
+
allow: "allow";
|
|
49
|
+
buffer: "buffer";
|
|
50
|
+
cancel: "cancel";
|
|
51
|
+
skip: "skip";
|
|
52
|
+
}>;
|
|
53
|
+
createdAt: z.ZodCustom<Temporal.Instant, Temporal.Instant>;
|
|
54
|
+
updatedAt: z.ZodCustom<Temporal.Instant, Temporal.Instant>;
|
|
55
|
+
nextFireAt: z.ZodCustom<Temporal.Instant, Temporal.Instant>;
|
|
56
|
+
endAt: z.ZodOptional<z.ZodCustom<Temporal.Instant, Temporal.Instant>>;
|
|
57
|
+
bufferedFireAt: z.ZodOptional<z.ZodCustom<Temporal.Instant, Temporal.Instant>>;
|
|
58
|
+
lastFireAt: z.ZodOptional<z.ZodCustom<Temporal.Instant, Temporal.Instant>>;
|
|
59
|
+
lastRunId: z.ZodOptional<z.ZodString>;
|
|
60
|
+
tickCount: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<0>]>;
|
|
61
|
+
}, z.core.$strip>;
|
|
62
|
+
type ScheduleId = string;
|
|
63
|
+
/** Lifecycle status of a stored recurring workflow schedule. */
|
|
64
|
+
type ScheduleStatus = "active" | "paused" | "archived" | "deleted";
|
|
65
|
+
/** Policy for handling missed recurring schedule fire times. */
|
|
66
|
+
type ScheduleCatchUpPolicy = "skip" | "one" | "all";
|
|
67
|
+
/** Policy for handling schedule ticks while a prior scheduled run is still active. */
|
|
68
|
+
type ScheduleOverlapPolicy = "allow" | "skip" | "buffer" | "cancel";
|
|
69
|
+
/** Stored recurring workflow schedule state. */
|
|
70
|
+
interface ScheduleRecord<TInput = StorageValue> {
|
|
71
|
+
readonly id: ScheduleId;
|
|
72
|
+
readonly namespace: string;
|
|
73
|
+
readonly workflowName: string;
|
|
74
|
+
readonly workflowVersion?: string;
|
|
75
|
+
readonly input?: TInput;
|
|
76
|
+
readonly context?: StorageValue;
|
|
77
|
+
readonly status: ScheduleStatus;
|
|
78
|
+
readonly every: Temporal.Duration;
|
|
79
|
+
readonly catchUp: ScheduleCatchUpPolicy;
|
|
80
|
+
readonly maxCatchUpRuns?: number;
|
|
81
|
+
readonly maxLateness?: Temporal.Duration;
|
|
82
|
+
readonly overlap: ScheduleOverlapPolicy;
|
|
83
|
+
readonly createdAt: Temporal.Instant;
|
|
84
|
+
readonly updatedAt: Temporal.Instant;
|
|
85
|
+
readonly nextFireAt: Temporal.Instant;
|
|
86
|
+
readonly endAt?: Temporal.Instant;
|
|
87
|
+
readonly bufferedFireAt?: Temporal.Instant;
|
|
88
|
+
readonly lastFireAt?: Temporal.Instant;
|
|
89
|
+
readonly lastRunId?: RunId;
|
|
90
|
+
readonly tickCount: number;
|
|
91
|
+
}
|
|
92
|
+
/** Configuration for creating or replacing a recurring workflow schedule. */
|
|
93
|
+
interface ScheduleConfig<TInput = unknown, TRawInput = TInput> {
|
|
94
|
+
readonly id: ScheduleId;
|
|
95
|
+
readonly every: Temporal.Duration;
|
|
96
|
+
readonly input: TRawInput;
|
|
97
|
+
readonly context?: unknown;
|
|
98
|
+
readonly from?: Temporal.Instant;
|
|
99
|
+
readonly endAt?: Temporal.Instant;
|
|
100
|
+
readonly catchUp?: ScheduleCatchUpPolicy;
|
|
101
|
+
readonly maxCatchUpRuns?: number;
|
|
102
|
+
readonly maxLateness?: Temporal.Duration;
|
|
103
|
+
readonly overlap?: ScheduleOverlapPolicy;
|
|
104
|
+
}
|
|
105
|
+
/** Filters for listing recurring workflow schedules. */
|
|
106
|
+
interface ListSchedulesOptions {
|
|
107
|
+
readonly status?: ScheduleStatus | readonly ScheduleStatus[];
|
|
108
|
+
readonly workflowName?: string;
|
|
109
|
+
readonly workflowVersion?: string;
|
|
110
|
+
readonly limit?: number;
|
|
111
|
+
}
|
|
112
|
+
/** Paginated filters for listing recurring workflow schedules. */
|
|
113
|
+
type ListSchedulesPageOptions = ListSchedulesOptions & PageOptions;
|
|
114
|
+
/** Options for advancing due recurring workflow schedules. */
|
|
115
|
+
interface TickSchedulesOptions {
|
|
116
|
+
readonly now?: Temporal.Instant;
|
|
117
|
+
readonly limit?: number;
|
|
118
|
+
}
|
|
119
|
+
/** Summary returned after advancing due recurring workflow schedules. */
|
|
120
|
+
interface TickSchedulesResult {
|
|
121
|
+
readonly ticked: number;
|
|
122
|
+
readonly runIds: readonly RunId[];
|
|
123
|
+
readonly scheduleIds: readonly ScheduleId[];
|
|
124
|
+
readonly nextScheduleAt?: Temporal.Instant;
|
|
125
|
+
}
|
|
126
|
+
//#endregion
|
|
127
|
+
export { ListSchedulesOptions, ListSchedulesPageOptions, ScheduleCatchUpPolicy, ScheduleConfig, ScheduleId, ScheduleOverlapPolicy, ScheduleRecord, ScheduleStatus, TickSchedulesOptions, TickSchedulesResult, scheduleIdSchema, workflowScheduleCatchUpPolicySchema, workflowScheduleOverlapPolicySchema, workflowSchedulePositiveDurationSchema, workflowScheduleRecordSchema, workflowScheduleStatusSchema };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { nonBlankStringSchema, positiveSafeIntegerSchema, temporalDurationSchema, temporalInstantSchema } from "./common.mjs";
|
|
2
|
+
import { runIdSchema } from "./run-id.mjs";
|
|
3
|
+
import { workflowPersistedValueSchema } from "./run.mjs";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
//#region src/types/schedule.ts
|
|
6
|
+
const scheduleIdSchema = z.string().refine((value) => value.trim().length > 0, "Expected an ID");
|
|
7
|
+
const workflowScheduleStatusSchema = z.enum([
|
|
8
|
+
"active",
|
|
9
|
+
"paused",
|
|
10
|
+
"archived",
|
|
11
|
+
"deleted"
|
|
12
|
+
]);
|
|
13
|
+
const workflowScheduleCatchUpPolicySchema = z.enum([
|
|
14
|
+
"skip",
|
|
15
|
+
"one",
|
|
16
|
+
"all"
|
|
17
|
+
]);
|
|
18
|
+
const workflowScheduleOverlapPolicySchema = z.enum([
|
|
19
|
+
"allow",
|
|
20
|
+
"skip",
|
|
21
|
+
"buffer",
|
|
22
|
+
"cancel"
|
|
23
|
+
]);
|
|
24
|
+
const workflowSchedulePositiveDurationSchema = temporalDurationSchema.refine((value) => value.total({ unit: "millisecond" }) > 0, { error: "Expected a positive duration" });
|
|
25
|
+
const workflowScheduleRecordSchema = z.object({
|
|
26
|
+
id: scheduleIdSchema,
|
|
27
|
+
namespace: nonBlankStringSchema,
|
|
28
|
+
workflowName: nonBlankStringSchema,
|
|
29
|
+
workflowVersion: nonBlankStringSchema.optional(),
|
|
30
|
+
input: workflowPersistedValueSchema.optional(),
|
|
31
|
+
context: workflowPersistedValueSchema.optional(),
|
|
32
|
+
status: workflowScheduleStatusSchema,
|
|
33
|
+
every: workflowSchedulePositiveDurationSchema,
|
|
34
|
+
catchUp: workflowScheduleCatchUpPolicySchema,
|
|
35
|
+
maxCatchUpRuns: positiveSafeIntegerSchema.optional(),
|
|
36
|
+
maxLateness: workflowSchedulePositiveDurationSchema.optional(),
|
|
37
|
+
overlap: workflowScheduleOverlapPolicySchema,
|
|
38
|
+
createdAt: temporalInstantSchema,
|
|
39
|
+
updatedAt: temporalInstantSchema,
|
|
40
|
+
nextFireAt: temporalInstantSchema,
|
|
41
|
+
endAt: temporalInstantSchema.optional(),
|
|
42
|
+
bufferedFireAt: temporalInstantSchema.optional(),
|
|
43
|
+
lastFireAt: temporalInstantSchema.optional(),
|
|
44
|
+
lastRunId: runIdSchema.optional(),
|
|
45
|
+
tickCount: z.union([positiveSafeIntegerSchema, z.literal(0)])
|
|
46
|
+
});
|
|
47
|
+
//#endregion
|
|
48
|
+
export { scheduleIdSchema, workflowScheduleCatchUpPolicySchema, workflowScheduleOverlapPolicySchema, workflowSchedulePositiveDurationSchema, workflowScheduleRecordSchema, workflowScheduleStatusSchema };
|