@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,355 @@
|
|
|
1
|
+
import { RunId } from "./run-id.mjs";
|
|
2
|
+
import { StepId } from "./step-id.mjs";
|
|
3
|
+
import { WorkerId } from "./worker-id.mjs";
|
|
4
|
+
import { TelemetryContext } from "./telemetry.mjs";
|
|
5
|
+
import { WorkflowErrorRecord } from "./error.mjs";
|
|
6
|
+
import { StorageValue } from "@temelj/storage";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
//#region src/types/run.d.ts
|
|
9
|
+
declare const WORKFLOW_ATTRIBUTE_MAX_KEY_LENGTH = 128;
|
|
10
|
+
declare const WORKFLOW_ATTRIBUTE_MAX_COUNT = 64;
|
|
11
|
+
declare const WORKFLOW_ATTRIBUTE_MAX_VALUE_BYTES = 1024;
|
|
12
|
+
declare const WORKFLOW_ATTRIBUTE_RESERVED_PREFIX = "$";
|
|
13
|
+
/** Validation issue describing why a value cannot be stored in workflow history. */
|
|
14
|
+
interface WorkflowValueIssue {
|
|
15
|
+
readonly path: string;
|
|
16
|
+
readonly message: string;
|
|
17
|
+
}
|
|
18
|
+
declare const workflowPersistedValueSchema: z.ZodType<StorageValue>;
|
|
19
|
+
/** Returns the first persistence validation issue for a workflow value, if one exists. */
|
|
20
|
+
declare function persistedValueIssue(value: unknown, path: string, seen: WeakSet<object>, allowUndefined: boolean): WorkflowValueIssue | undefined;
|
|
21
|
+
declare const workflowAttributeKeySchema: z.ZodString;
|
|
22
|
+
declare const workflowAttributePrimitiveValueSchema: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
23
|
+
declare const workflowAttributeValueSchema: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
24
|
+
declare const workflowRunAttributesSchema: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>;
|
|
25
|
+
declare const workflowAttributePatchSchema: z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
|
|
26
|
+
declare const workflowRunStatusSchema: z.ZodEnum<{
|
|
27
|
+
canceled: "canceled";
|
|
28
|
+
completed: "completed";
|
|
29
|
+
failed: "failed";
|
|
30
|
+
pending: "pending";
|
|
31
|
+
running: "running";
|
|
32
|
+
waiting: "waiting";
|
|
33
|
+
}>;
|
|
34
|
+
declare const workflowTerminalRunStatusSchema: z.ZodEnum<{
|
|
35
|
+
canceled: "canceled";
|
|
36
|
+
completed: "completed";
|
|
37
|
+
failed: "failed";
|
|
38
|
+
}>;
|
|
39
|
+
declare const workflowRunRetryReasonSchema: z.ZodEnum<{
|
|
40
|
+
missing_implementation: "missing_implementation";
|
|
41
|
+
step: "step";
|
|
42
|
+
workflow: "workflow";
|
|
43
|
+
}>;
|
|
44
|
+
declare const workflowRunTransitionReasonSchema: z.ZodEnum<{
|
|
45
|
+
canceled: "canceled";
|
|
46
|
+
claimed: "claimed";
|
|
47
|
+
completed: "completed";
|
|
48
|
+
created: "created";
|
|
49
|
+
deadline: "deadline";
|
|
50
|
+
failed: "failed";
|
|
51
|
+
lease_released: "lease_released";
|
|
52
|
+
manual_retry: "manual_retry";
|
|
53
|
+
missing_implementation: "missing_implementation";
|
|
54
|
+
permanent_failure: "permanent_failure";
|
|
55
|
+
reclaimed: "reclaimed";
|
|
56
|
+
rescheduled: "rescheduled";
|
|
57
|
+
retry: "retry";
|
|
58
|
+
started: "started";
|
|
59
|
+
waiting: "waiting";
|
|
60
|
+
}>;
|
|
61
|
+
/** Type used for workflow step type values. */
|
|
62
|
+
declare const workflowStepTypeSchema: z.ZodEnum<{
|
|
63
|
+
attributes: "attributes";
|
|
64
|
+
deterministic: "deterministic";
|
|
65
|
+
"message-send": "message-send";
|
|
66
|
+
"message-wait": "message-wait";
|
|
67
|
+
metadata: "metadata";
|
|
68
|
+
run: "run";
|
|
69
|
+
sleep: "sleep";
|
|
70
|
+
stream: "stream";
|
|
71
|
+
workflow: "workflow";
|
|
72
|
+
}>;
|
|
73
|
+
declare const workflowMaterializedStepTypeSchema: z.ZodEnum<{
|
|
74
|
+
deterministic: "deterministic";
|
|
75
|
+
"message-send": "message-send";
|
|
76
|
+
"message-wait": "message-wait";
|
|
77
|
+
run: "run";
|
|
78
|
+
sleep: "sleep";
|
|
79
|
+
stream: "stream";
|
|
80
|
+
workflow: "workflow";
|
|
81
|
+
}>;
|
|
82
|
+
declare const workflowRunRecordSchema: z.ZodObject<{
|
|
83
|
+
id: z.ZodString;
|
|
84
|
+
namespace: z.ZodString;
|
|
85
|
+
workflowName: z.ZodString;
|
|
86
|
+
workflowVersion: z.ZodOptional<z.ZodString>;
|
|
87
|
+
status: z.ZodEnum<{
|
|
88
|
+
canceled: "canceled";
|
|
89
|
+
completed: "completed";
|
|
90
|
+
failed: "failed";
|
|
91
|
+
pending: "pending";
|
|
92
|
+
running: "running";
|
|
93
|
+
waiting: "waiting";
|
|
94
|
+
}>;
|
|
95
|
+
input: z.ZodOptional<z.ZodType<StorageValue, unknown, z.core.$ZodTypeInternals<StorageValue, unknown>>>;
|
|
96
|
+
context: z.ZodOptional<z.ZodType<StorageValue, unknown, z.core.$ZodTypeInternals<StorageValue, unknown>>>;
|
|
97
|
+
telemetryContext: z.ZodOptional<z.ZodObject<{
|
|
98
|
+
traceparent: z.ZodOptional<z.ZodString>;
|
|
99
|
+
tracestate: z.ZodOptional<z.ZodString>;
|
|
100
|
+
}, z.core.$strip>>;
|
|
101
|
+
metadata: z.ZodOptional<z.ZodType<StorageValue, unknown, z.core.$ZodTypeInternals<StorageValue, unknown>>>;
|
|
102
|
+
attributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
|
|
103
|
+
output: z.ZodOptional<z.ZodType<StorageValue, unknown, z.core.$ZodTypeInternals<StorageValue, unknown>>>;
|
|
104
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
105
|
+
code: z.ZodOptional<z.ZodEnum<{
|
|
106
|
+
readonly ERROR: "workflow.error";
|
|
107
|
+
readonly DEFINITION_INVALID: "definition.invalid";
|
|
108
|
+
readonly CAPABILITY_UNSUPPORTED: "capability.unsupported";
|
|
109
|
+
readonly OPTIONS_INVALID: "options.invalid";
|
|
110
|
+
readonly OPTIONS_EXPECTED_OBJECT: "options.expected_object";
|
|
111
|
+
readonly OPTIONS_EXPECTED_ARRAY: "options.expected_array";
|
|
112
|
+
readonly OPTIONS_EXPECTED_FUNCTION: "options.expected_function";
|
|
113
|
+
readonly OPTIONS_EXPECTED_STRING: "options.expected_string";
|
|
114
|
+
readonly OPTIONS_EXPECTED_NON_EMPTY: "options.expected_non_empty";
|
|
115
|
+
readonly OPTIONS_EXPECTED_NON_BLANK: "options.expected_non_blank";
|
|
116
|
+
readonly OPTIONS_EXPECTED_NUMBER: "options.expected_number";
|
|
117
|
+
readonly OPTIONS_EXPECTED_BOOLEAN: "options.expected_boolean";
|
|
118
|
+
readonly OPTIONS_REQUIRED: "options.required";
|
|
119
|
+
readonly OPTIONS_EXPECTED_POSITIVE_SAFE_INTEGER: "options.expected_positive_safe_integer";
|
|
120
|
+
readonly OPTIONS_EXPECTED_NON_NEGATIVE_SAFE_INTEGER: "options.expected_non_negative_safe_integer";
|
|
121
|
+
readonly OPTIONS_EXPECTED_POSITIVE_DURATION: "options.expected_positive_duration";
|
|
122
|
+
readonly OPTIONS_EXPECTED_NON_NEGATIVE_DURATION: "options.expected_non_negative_duration";
|
|
123
|
+
readonly OPTIONS_EXPECTED_TIMER_SAFE_DURATION: "options.expected_timer_safe_duration";
|
|
124
|
+
readonly OPTIONS_EXPECTED_POSITIVE_SAFE_INTEGER_DURATION: "options.expected_positive_safe_integer_duration";
|
|
125
|
+
readonly OPTIONS_EXPECTED_TEMPORAL_INSTANT: "options.expected_temporal_instant";
|
|
126
|
+
readonly OPTIONS_EXPECTED_ABORT_SIGNAL: "options.expected_abort_signal";
|
|
127
|
+
readonly OPTIONS_CHILD_CANCELLATION_POLICY_INVALID: "options.child_cancellation_policy_invalid";
|
|
128
|
+
readonly OPTIONS_CURSOR_INVALID: "options.cursor_invalid";
|
|
129
|
+
readonly OPTIONS_RETRY_MAXIMUM_INTERVAL_TOO_SMALL: "options.retry_maximum_interval_too_small";
|
|
130
|
+
readonly OPTIONS_RETRYABLE_ERROR_DELAY_CONFLICT: "options.retryable_error_delay_conflict";
|
|
131
|
+
readonly OPTIONS_ENGINE_STORE_STORAGE_CONFLICT: "options.engine_store_storage_conflict";
|
|
132
|
+
readonly OPTIONS_MISSING_IMPLEMENTATION_RETRY_ATTEMPT_INVALID: "options.missing_implementation_retry_attempt_invalid";
|
|
133
|
+
readonly STATE_INVALID: "state.invalid";
|
|
134
|
+
readonly STATE_RUN_NAMESPACE_MISMATCH: "state.run_namespace_mismatch";
|
|
135
|
+
readonly STATE_RUN_ID_MISMATCH: "state.run_id_mismatch";
|
|
136
|
+
readonly STATE_RUN_ALREADY_EXISTS: "state.run_already_exists";
|
|
137
|
+
readonly STATE_EVENT_HISTORY_ALREADY_EXISTS: "state.event_history_already_exists";
|
|
138
|
+
readonly STATE_EVENT_NOT_TERMINAL_STEP: "state.event_not_terminal_step";
|
|
139
|
+
readonly STATE_RECORDED_STEP_EVENT_UNSUPPORTED: "state.recorded_step_event_unsupported";
|
|
140
|
+
readonly STATE_STEP_ATTEMPT_FIELD_MISMATCH: "state.step_attempt_field_mismatch";
|
|
141
|
+
readonly STATE_FAILED_RUN_MISSING_ERROR: "state.failed_run_missing_error";
|
|
142
|
+
readonly STATE_RUN_NOT_CLAIMABLE: "state.run_not_claimable";
|
|
143
|
+
readonly STATE_WORKER_STOPPED_BEFORE_RUN: "state.worker_stopped_before_run";
|
|
144
|
+
readonly STATE_STORE_RUN_ID_INVALID: "state.store_run_id_invalid";
|
|
145
|
+
readonly STATE_IDEMPOTENCY_KEY_CLAIMED_WITHOUT_RUN: "state.idempotency_key_claimed_without_run";
|
|
146
|
+
readonly STATE_RUN_MISSING_IDEMPOTENCY_KEY: "state.run_missing_idempotency_key";
|
|
147
|
+
readonly STATE_RUN_METADATA_UPDATE_FAILED: "state.run_metadata_update_failed";
|
|
148
|
+
readonly STATE_RUN_ATTRIBUTES_UPDATE_FAILED: "state.run_attributes_update_failed";
|
|
149
|
+
readonly STATE_RUN_CANNOT_BE_RESCHEDULED: "state.run_cannot_be_rescheduled";
|
|
150
|
+
readonly STATE_RUN_RESCHEDULE_FAILED: "state.run_reschedule_failed";
|
|
151
|
+
readonly STATE_STALE_LEASE_RELEASE_REQUIRES_RUNNING: "state.stale_lease_release_requires_running";
|
|
152
|
+
readonly STATE_RUN_LEASE_STILL_ACTIVE: "state.run_lease_still_active";
|
|
153
|
+
readonly STATE_STALE_RUN_LEASE_RELEASE_FAILED: "state.stale_run_lease_release_failed";
|
|
154
|
+
readonly STATE_RUN_RETRY_REQUIRES_FAILED: "state.run_retry_requires_failed";
|
|
155
|
+
readonly STATE_RUN_RETRY_REQUIRES_FORCE_AFTER_PERMANENT_FAILURE: "state.run_retry_requires_force_after_permanent_failure";
|
|
156
|
+
readonly STATE_FAILED_RUN_RETRY_REQUIRES_FORCE: "state.failed_run_retry_requires_force";
|
|
157
|
+
readonly STATE_RUN_RETRY_FAILED: "state.run_retry_failed";
|
|
158
|
+
readonly STATE_PERMANENT_RUN_FAILURE_FAILED: "state.permanent_run_failure_failed";
|
|
159
|
+
readonly STATE_PERMANENT_FAILURE_STATUS_INVALID: "state.permanent_failure_status_invalid";
|
|
160
|
+
readonly STATE_MESSAGE_APPEND_FAILED: "state.message_append_failed";
|
|
161
|
+
readonly STATE_CLEANUP_SELECTED_NON_TERMINAL_RUN: "state.cleanup_selected_non_terminal_run";
|
|
162
|
+
readonly STATE_CLEANUP_RUN_MISSING_FINISHED_AT: "state.cleanup_run_missing_finished_at";
|
|
163
|
+
readonly STATE_WORKFLOW_EVENT_APPEND_FAILED: "state.workflow_event_append_failed";
|
|
164
|
+
readonly STATE_STEP_ATTEMPT_MATERIALIZATION_FAILED: "state.step_attempt_materialization_failed";
|
|
165
|
+
readonly STATE_APPEND_PROJECTION_PIPELINE_MISSING: "state.append_projection_pipeline_missing";
|
|
166
|
+
readonly RUNTIME_INVALID: "runtime.invalid";
|
|
167
|
+
readonly RUN_ERROR: "run.error";
|
|
168
|
+
readonly STEP_ERROR: "step.error";
|
|
169
|
+
readonly MESSAGE_ERROR: "message.error";
|
|
170
|
+
readonly IMPLEMENTATION_NOT_FOUND: "implementation.not_found";
|
|
171
|
+
readonly DURATION_INVALID: "duration.invalid";
|
|
172
|
+
readonly SERIALIZATION_FAILED: "serialization.failed";
|
|
173
|
+
readonly NON_RETRYABLE_FAILURE: "failure.non_retryable";
|
|
174
|
+
readonly PERMANENT_FAILURE: "failure.permanent";
|
|
175
|
+
readonly RETRYABLE_FAILURE: "failure.retryable";
|
|
176
|
+
readonly REPLAY_DIVERGED: "replay.diverged";
|
|
177
|
+
readonly LOCK_ALREADY_HELD: "lock.already_held";
|
|
178
|
+
readonly RUN_NOT_FOUND: "run.not_found";
|
|
179
|
+
readonly RUN_INVALID: "run.invalid";
|
|
180
|
+
readonly RUN_WORKFLOW_MISMATCH: "run.workflow_mismatch";
|
|
181
|
+
readonly RUN_RESULT_TIMEOUT: "run.result_timeout";
|
|
182
|
+
readonly RUN_CANCELED: "run.canceled";
|
|
183
|
+
readonly RUN_CANCELLATION_REJECTED: "run.cancellation_rejected";
|
|
184
|
+
readonly RUN_TRANSITION_INVALID: "run.transition_invalid";
|
|
185
|
+
readonly RUN_PARENT_INVALID: "run.parent_invalid";
|
|
186
|
+
readonly RUN_DEADLINE_EXCEEDED: "run.deadline_exceeded";
|
|
187
|
+
readonly CHILD_WORKFLOW_TIMEOUT: "child_workflow.timeout";
|
|
188
|
+
readonly MESSAGE_WAIT_TIMEOUT: "message.wait_timeout";
|
|
189
|
+
readonly HOOK_DISPOSED: "hook.disposed";
|
|
190
|
+
readonly MESSAGE_DELIVERY_REJECTED: "message.delivery_rejected";
|
|
191
|
+
readonly MESSAGE_IDEMPOTENCY_CONFLICT: "message.idempotency_conflict";
|
|
192
|
+
readonly STEP_TIMEOUT: "step.timeout";
|
|
193
|
+
readonly STEP_EXECUTION_FAILED: "step.execution_failed";
|
|
194
|
+
readonly STEP_RETRY_LIMIT_EXCEEDED: "step.retry_limit_exceeded";
|
|
195
|
+
readonly STEP_ATTEMPT_LIMIT_EXCEEDED: "step.attempt_limit_exceeded";
|
|
196
|
+
readonly SCHEDULE_ALREADY_EXISTS: "schedule.already_exists";
|
|
197
|
+
readonly SCHEDULE_NAMESPACE_MISMATCH: "schedule.namespace_mismatch";
|
|
198
|
+
readonly SCHEDULE_RECORD_INVALID: "schedule.record_invalid";
|
|
199
|
+
readonly SCHEDULE_ID_CHANGE_REJECTED: "schedule.id_change_rejected";
|
|
200
|
+
readonly SCHEDULE_CURRENT_RECORD_INVALID: "schedule.current_record_invalid";
|
|
201
|
+
readonly SCHEDULE_NEXT_RECORD_INVALID: "schedule.next_record_invalid";
|
|
202
|
+
readonly SCHEDULE_UPSERT_CONFLICT_EXHAUSTED: "schedule.upsert_conflict_exhausted";
|
|
203
|
+
readonly SCHEDULE_NOT_FOUND: "schedule.not_found";
|
|
204
|
+
readonly SCHEDULE_UPDATE_CONFLICT_EXHAUSTED: "schedule.update_conflict_exhausted";
|
|
205
|
+
readonly STREAM_NOT_FOUND: "stream.not_found";
|
|
206
|
+
readonly STREAM_CHUNK_LIMIT_EXCEEDED: "stream.chunk_limit_exceeded";
|
|
207
|
+
readonly STREAM_READ_OFFSET_CONFLICT: "stream.read_offset_conflict";
|
|
208
|
+
readonly STREAM_CHUNK_INDEX_NON_CONTIGUOUS: "stream.chunk_index_non_contiguous";
|
|
209
|
+
readonly STREAM_CHUNK_AFTER_TERMINAL: "stream.chunk_after_terminal";
|
|
210
|
+
readonly STREAM_ALREADY_CLOSED: "stream.already_closed";
|
|
211
|
+
readonly LOCK_ALREADY_HELD_WITHOUT_WAIT: "lock.already_held_without_wait";
|
|
212
|
+
readonly LOCK_HOLDER_MISMATCH: "lock.holder_mismatch";
|
|
213
|
+
readonly LOCK_ALREADY_RELEASED: "lock.already_released";
|
|
214
|
+
readonly LOCK_NOT_STALE: "lock.not_stale";
|
|
215
|
+
readonly LOCK_WAIT_DEADLINE_CONFLICT: "lock.wait_deadline_conflict";
|
|
216
|
+
readonly LOCK_TIMEOUT_REQUIRES_WAIT: "lock.timeout_requires_wait";
|
|
217
|
+
readonly LOCK_NAMESPACE_MISMATCH: "lock.namespace_mismatch";
|
|
218
|
+
readonly LOCK_KEY_CHANGE_REJECTED: "lock.key_change_rejected";
|
|
219
|
+
readonly LOCK_CURRENT_RECORD_INVALID: "lock.current_record_invalid";
|
|
220
|
+
readonly LOCK_NEXT_RECORD_INVALID: "lock.next_record_invalid";
|
|
221
|
+
readonly LOCK_ACQUIRE_CONFLICT_EXHAUSTED: "lock.acquire_conflict_exhausted";
|
|
222
|
+
readonly LOCK_NOT_FOUND: "lock.not_found";
|
|
223
|
+
readonly LOCK_RELEASE_CONFLICT_EXHAUSTED: "lock.release_conflict_exhausted";
|
|
224
|
+
readonly LOCK_STALE_RELEASE_CONFLICT_EXHAUSTED: "lock.stale_release_conflict_exhausted";
|
|
225
|
+
readonly HOOK_TOKEN_INVALID: "hook.token_invalid";
|
|
226
|
+
readonly WEBHOOK_TOKEN_INVALID: "webhook.token_invalid";
|
|
227
|
+
readonly HOOK_TOKEN_NOT_UNIQUE: "hook.token_not_unique";
|
|
228
|
+
readonly HOOK_WAITING_STEP_MISSING: "hook.waiting_step_missing";
|
|
229
|
+
}>>;
|
|
230
|
+
name: z.ZodString;
|
|
231
|
+
message: z.ZodString;
|
|
232
|
+
stack: z.ZodOptional<z.ZodString>;
|
|
233
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
|
|
234
|
+
}, z.core.$loose>>;
|
|
235
|
+
attempts: z.ZodOptional<z.ZodNumber>;
|
|
236
|
+
idempotencyKey: z.ZodOptional<z.ZodString>;
|
|
237
|
+
parentRunId: z.ZodOptional<z.ZodString>;
|
|
238
|
+
parentStepId: z.ZodOptional<z.ZodString>;
|
|
239
|
+
parentStepName: z.ZodOptional<z.ZodString>;
|
|
240
|
+
parentStepAttempt: z.ZodOptional<z.ZodNumber>;
|
|
241
|
+
workerId: z.ZodOptional<z.ZodCustom<string, string>>;
|
|
242
|
+
createdAt: z.ZodCustom<Temporal.Instant, Temporal.Instant>;
|
|
243
|
+
updatedAt: z.ZodCustom<Temporal.Instant, Temporal.Instant>;
|
|
244
|
+
lastTransitionAt: z.ZodCustom<Temporal.Instant, Temporal.Instant>;
|
|
245
|
+
lastTransitionReason: z.ZodEnum<{
|
|
246
|
+
canceled: "canceled";
|
|
247
|
+
claimed: "claimed";
|
|
248
|
+
completed: "completed";
|
|
249
|
+
created: "created";
|
|
250
|
+
deadline: "deadline";
|
|
251
|
+
failed: "failed";
|
|
252
|
+
lease_released: "lease_released";
|
|
253
|
+
manual_retry: "manual_retry";
|
|
254
|
+
missing_implementation: "missing_implementation";
|
|
255
|
+
permanent_failure: "permanent_failure";
|
|
256
|
+
reclaimed: "reclaimed";
|
|
257
|
+
rescheduled: "rescheduled";
|
|
258
|
+
retry: "retry";
|
|
259
|
+
started: "started";
|
|
260
|
+
waiting: "waiting";
|
|
261
|
+
}>;
|
|
262
|
+
availableAt: z.ZodOptional<z.ZodCustom<Temporal.Instant, Temporal.Instant>>;
|
|
263
|
+
retryAt: z.ZodOptional<z.ZodCustom<Temporal.Instant, Temporal.Instant>>;
|
|
264
|
+
retryReason: z.ZodOptional<z.ZodEnum<{
|
|
265
|
+
missing_implementation: "missing_implementation";
|
|
266
|
+
step: "step";
|
|
267
|
+
workflow: "workflow";
|
|
268
|
+
}>>;
|
|
269
|
+
retryAttempt: z.ZodOptional<z.ZodNumber>;
|
|
270
|
+
retryStepId: z.ZodOptional<z.ZodString>;
|
|
271
|
+
retryStepName: z.ZodOptional<z.ZodString>;
|
|
272
|
+
deadlineAt: z.ZodOptional<z.ZodCustom<Temporal.Instant, Temporal.Instant>>;
|
|
273
|
+
leaseExpiresAt: z.ZodOptional<z.ZodCustom<Temporal.Instant, Temporal.Instant>>;
|
|
274
|
+
startedAt: z.ZodOptional<z.ZodCustom<Temporal.Instant, Temporal.Instant>>;
|
|
275
|
+
finishedAt: z.ZodOptional<z.ZodCustom<Temporal.Instant, Temporal.Instant>>;
|
|
276
|
+
}, z.core.$strip>;
|
|
277
|
+
/** Type used for workflow attribute value values. */
|
|
278
|
+
type WorkflowAttributeValue = string | number | boolean | null;
|
|
279
|
+
/** Type used for workflow run attributes values. */
|
|
280
|
+
type WorkflowRunAttributes = Readonly<Record<string, WorkflowAttributeValue>>;
|
|
281
|
+
/** Type used for workflow attribute patch values. */
|
|
282
|
+
type WorkflowAttributePatch = Readonly<Record<string, WorkflowAttributeValue | undefined>>;
|
|
283
|
+
/** Status values for workflow run. */
|
|
284
|
+
type WorkflowRunStatus = "pending" | "running" | "waiting" | "completed" | "failed" | "canceled";
|
|
285
|
+
/** Status values for workflow terminal run. */
|
|
286
|
+
type WorkflowTerminalRunStatus = "completed" | "failed" | "canceled";
|
|
287
|
+
/** Type used for workflow step type values. */
|
|
288
|
+
type WorkflowStepType = "run" | "sleep" | "workflow" | "message-send" | "message-wait" | "stream" | "deterministic" | "metadata" | "attributes";
|
|
289
|
+
/** Stable identity assigned to a durable step occurrence within a workflow run. */
|
|
290
|
+
interface WorkflowStepIdentity<TType extends WorkflowStepType = WorkflowStepType> {
|
|
291
|
+
readonly id: string;
|
|
292
|
+
readonly name: string;
|
|
293
|
+
readonly count: number;
|
|
294
|
+
readonly kind: TType;
|
|
295
|
+
}
|
|
296
|
+
/** Type used for workflow materialized step type values. */
|
|
297
|
+
type WorkflowMaterializedStepType = "run" | "sleep" | "workflow" | "message-send" | "message-wait" | "stream" | "deterministic";
|
|
298
|
+
/** Type used for workflow run retry reason values. */
|
|
299
|
+
type WorkflowRunRetryReason = "workflow" | "step" | "missing_implementation";
|
|
300
|
+
/** Type used for workflow definition name values stored on runs. */
|
|
301
|
+
type WorkflowRunWorkflowName = string;
|
|
302
|
+
/** Type used for workflow definition version values stored on runs. */
|
|
303
|
+
type WorkflowRunWorkflowVersion = string;
|
|
304
|
+
/** Type used for workflow run transition reason values. */
|
|
305
|
+
type WorkflowRunTransitionReason = "created" | "claimed" | "reclaimed" | "started" | "waiting" | "rescheduled" | "lease_released" | "manual_retry" | "permanent_failure" | "retry" | "missing_implementation" | "completed" | "failed" | "deadline" | "canceled";
|
|
306
|
+
/** Stored record for workflow run. */
|
|
307
|
+
interface WorkflowRunRecord<TInput = StorageValue, TOutput = StorageValue> {
|
|
308
|
+
readonly id: RunId;
|
|
309
|
+
readonly namespace: string;
|
|
310
|
+
readonly workflowName: WorkflowRunWorkflowName;
|
|
311
|
+
readonly workflowVersion?: WorkflowRunWorkflowVersion;
|
|
312
|
+
readonly status: WorkflowRunStatus;
|
|
313
|
+
readonly input?: TInput;
|
|
314
|
+
readonly context?: StorageValue;
|
|
315
|
+
readonly telemetryContext?: TelemetryContext;
|
|
316
|
+
readonly metadata?: StorageValue;
|
|
317
|
+
readonly attributes?: WorkflowRunAttributes;
|
|
318
|
+
readonly output?: TOutput;
|
|
319
|
+
readonly error?: WorkflowErrorRecord;
|
|
320
|
+
readonly attempts?: number;
|
|
321
|
+
readonly idempotencyKey?: string;
|
|
322
|
+
readonly parentRunId?: RunId;
|
|
323
|
+
readonly parentStepId?: StepId;
|
|
324
|
+
readonly parentStepName?: string;
|
|
325
|
+
readonly parentStepAttempt?: number;
|
|
326
|
+
readonly workerId?: WorkerId;
|
|
327
|
+
readonly createdAt: Temporal.Instant;
|
|
328
|
+
readonly updatedAt: Temporal.Instant;
|
|
329
|
+
readonly lastTransitionAt: Temporal.Instant;
|
|
330
|
+
readonly lastTransitionReason: WorkflowRunTransitionReason;
|
|
331
|
+
readonly availableAt?: Temporal.Instant;
|
|
332
|
+
readonly retryAt?: Temporal.Instant;
|
|
333
|
+
readonly retryReason?: WorkflowRunRetryReason;
|
|
334
|
+
readonly retryAttempt?: number;
|
|
335
|
+
readonly retryStepId?: StepId;
|
|
336
|
+
readonly retryStepName?: string;
|
|
337
|
+
readonly deadlineAt?: Temporal.Instant;
|
|
338
|
+
readonly leaseExpiresAt?: Temporal.Instant;
|
|
339
|
+
readonly startedAt?: Temporal.Instant;
|
|
340
|
+
readonly finishedAt?: Temporal.Instant;
|
|
341
|
+
}
|
|
342
|
+
/** Describes the workflow lifecycle event contract. */
|
|
343
|
+
interface WorkflowLifecycleEvent {
|
|
344
|
+
readonly run: WorkflowRunRecord;
|
|
345
|
+
readonly previousRun?: WorkflowRunRecord;
|
|
346
|
+
readonly status: WorkflowRunStatus;
|
|
347
|
+
readonly reason: WorkflowRunTransitionReason;
|
|
348
|
+
readonly timestamp: Temporal.Instant;
|
|
349
|
+
readonly workflowName: string;
|
|
350
|
+
readonly workflowVersion?: string;
|
|
351
|
+
}
|
|
352
|
+
/** Type used for workflow lifecycle callback values. */
|
|
353
|
+
type WorkflowLifecycleCallback = (event: WorkflowLifecycleEvent) => void | Promise<void>;
|
|
354
|
+
//#endregion
|
|
355
|
+
export { type RunId, WORKFLOW_ATTRIBUTE_MAX_COUNT, WORKFLOW_ATTRIBUTE_MAX_KEY_LENGTH, WORKFLOW_ATTRIBUTE_MAX_VALUE_BYTES, WORKFLOW_ATTRIBUTE_RESERVED_PREFIX, WorkflowAttributePatch, WorkflowAttributeValue, WorkflowLifecycleCallback, WorkflowLifecycleEvent, WorkflowMaterializedStepType, WorkflowRunAttributes, WorkflowRunRecord, WorkflowRunRetryReason, WorkflowRunStatus, WorkflowRunTransitionReason, WorkflowRunWorkflowName, WorkflowRunWorkflowVersion, WorkflowStepIdentity, WorkflowStepType, WorkflowTerminalRunStatus, WorkflowValueIssue, persistedValueIssue, workflowAttributeKeySchema, workflowAttributePatchSchema, workflowAttributePrimitiveValueSchema, workflowAttributeValueSchema, workflowMaterializedStepTypeSchema, workflowPersistedValueSchema, workflowRunAttributesSchema, workflowRunRecordSchema, workflowRunRetryReasonSchema, workflowRunStatusSchema, workflowRunTransitionReasonSchema, workflowStepTypeSchema, workflowTerminalRunStatusSchema };
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { nonBlankStringSchema, nonNegativeSafeIntegerSchema, positiveSafeIntegerSchema, temporalInstantSchema } from "./common.mjs";
|
|
2
|
+
import { workflowErrorRecordSchema } from "./error.mjs";
|
|
3
|
+
import { runIdSchema } from "./run-id.mjs";
|
|
4
|
+
import { stepIdSchema } from "./step-id.mjs";
|
|
5
|
+
import { workflowTelemetryContextSchema } from "./telemetry.mjs";
|
|
6
|
+
import { workerIdSchema } from "./worker-id.mjs";
|
|
7
|
+
import { isTemporalStorageValue } from "@temelj/storage";
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
//#region src/types/run.ts
|
|
10
|
+
const WORKFLOW_ATTRIBUTE_MAX_KEY_LENGTH = 128;
|
|
11
|
+
const WORKFLOW_ATTRIBUTE_MAX_COUNT = 64;
|
|
12
|
+
const WORKFLOW_ATTRIBUTE_MAX_VALUE_BYTES = 1024;
|
|
13
|
+
const WORKFLOW_ATTRIBUTE_RESERVED_PREFIX = "$";
|
|
14
|
+
const workflowPersistedValueSchema = z.custom((value) => persistedValueIssue(value, "value", /* @__PURE__ */ new WeakSet(), false) === void 0);
|
|
15
|
+
/** Returns the first persistence validation issue for a workflow value, if one exists. */
|
|
16
|
+
function persistedValueIssue(value, path, seen, allowUndefined) {
|
|
17
|
+
if (value === void 0) return allowUndefined ? void 0 : unsupportedUndefinedIssue(path);
|
|
18
|
+
if (value === null || typeof value === "boolean" || typeof value === "string") return;
|
|
19
|
+
if (typeof value === "number") return Number.isFinite(value) ? void 0 : {
|
|
20
|
+
path,
|
|
21
|
+
message: "number must be finite"
|
|
22
|
+
};
|
|
23
|
+
if (typeof value === "bigint") return;
|
|
24
|
+
if (typeof value === "function" || typeof value === "symbol") return {
|
|
25
|
+
path,
|
|
26
|
+
message: `${typeof value} values are not supported`
|
|
27
|
+
};
|
|
28
|
+
if (typeof value !== "object") return {
|
|
29
|
+
path,
|
|
30
|
+
message: `${typeof value} values are not supported`
|
|
31
|
+
};
|
|
32
|
+
if (seen.has(value)) return {
|
|
33
|
+
path,
|
|
34
|
+
message: "circular references are not supported"
|
|
35
|
+
};
|
|
36
|
+
if (value instanceof Date) return Number.isFinite(value.getTime()) ? void 0 : {
|
|
37
|
+
path,
|
|
38
|
+
message: "Date must be valid"
|
|
39
|
+
};
|
|
40
|
+
if (isTemporalStorageValue(value) || value instanceof RegExp || value instanceof Uint8Array) return;
|
|
41
|
+
seen.add(value);
|
|
42
|
+
try {
|
|
43
|
+
if (value instanceof Map) return persistedMapIssue(value, path, seen);
|
|
44
|
+
if (value instanceof Set) return persistedSetIssue(value, path, seen);
|
|
45
|
+
if (Array.isArray(value)) return persistedArrayIssue(value, path, seen);
|
|
46
|
+
if (isPlainPersistedRecord(value)) return persistedRecordIssue(value, path, seen);
|
|
47
|
+
return {
|
|
48
|
+
path,
|
|
49
|
+
message: "object type is not supported"
|
|
50
|
+
};
|
|
51
|
+
} finally {
|
|
52
|
+
seen.delete(value);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function persistedArrayIssue(value, path, seen) {
|
|
56
|
+
for (const [index, item] of value.entries()) {
|
|
57
|
+
const issue = persistedValueIssue(item, `${path}[${index}]`, seen, false);
|
|
58
|
+
if (issue !== void 0) return issue;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function persistedRecordIssue(value, path, seen) {
|
|
62
|
+
for (const [key, item] of Object.entries(value)) {
|
|
63
|
+
const issue = persistedValueIssue(item, `${path}.${key}`, seen, false);
|
|
64
|
+
if (issue !== void 0) return issue;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function persistedMapIssue(value, path, seen) {
|
|
68
|
+
let index = 0;
|
|
69
|
+
for (const [key, item] of value) {
|
|
70
|
+
const keyIssue = persistedValueIssue(key, `${path}.<key:${index}>`, seen, false);
|
|
71
|
+
if (keyIssue !== void 0) return keyIssue;
|
|
72
|
+
const itemIssue = persistedValueIssue(item, `${path}.<value:${index}>`, seen, false);
|
|
73
|
+
if (itemIssue !== void 0) return itemIssue;
|
|
74
|
+
index++;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function persistedSetIssue(value, path, seen) {
|
|
78
|
+
let index = 0;
|
|
79
|
+
for (const item of value) {
|
|
80
|
+
const issue = persistedValueIssue(item, `${path}.<value:${index}>`, seen, false);
|
|
81
|
+
if (issue !== void 0) return issue;
|
|
82
|
+
index++;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function unsupportedUndefinedIssue(path) {
|
|
86
|
+
return {
|
|
87
|
+
path,
|
|
88
|
+
message: "undefined is not supported here"
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function isPlainPersistedRecord(value) {
|
|
92
|
+
if (typeof value !== "object" || value === null) return false;
|
|
93
|
+
const prototype = Reflect.getPrototypeOf(value);
|
|
94
|
+
if (prototype === Object.prototype || prototype === null) return true;
|
|
95
|
+
return isObjectPrototypeNamedObject(prototype);
|
|
96
|
+
}
|
|
97
|
+
function isObjectPrototypeNamedObject(prototype) {
|
|
98
|
+
if (!("constructor" in prototype)) return false;
|
|
99
|
+
const constructor = prototype.constructor;
|
|
100
|
+
return typeof constructor === "function" && "name" in constructor && constructor.name === "Object";
|
|
101
|
+
}
|
|
102
|
+
const workflowAttributeKeySchema = z.string().min(1, "Workflow run attribute keys must not be empty").max(128, `Workflow run attribute key must not exceed 128 characters`).refine((key) => key.trim() !== "", { error: "Workflow run attribute keys must not be empty" }).refine((key) => !key.startsWith("$"), { error: `Workflow run attribute key uses reserved prefix \$` });
|
|
103
|
+
const workflowAttributePrimitiveValueSchema = z.union([
|
|
104
|
+
z.string(),
|
|
105
|
+
z.number(),
|
|
106
|
+
z.boolean(),
|
|
107
|
+
z.null()
|
|
108
|
+
]);
|
|
109
|
+
const workflowAttributeValueSchema = workflowAttributePrimitiveValueSchema.refine((value) => encodedWorkflowAttributeByteLength(value) <= WORKFLOW_ATTRIBUTE_MAX_VALUE_BYTES, { error: `Workflow run attribute value must not exceed ${WORKFLOW_ATTRIBUTE_MAX_VALUE_BYTES} encoded bytes` });
|
|
110
|
+
const workflowRunAttributesSchema = z.record(workflowAttributeKeySchema, workflowAttributeValueSchema).refine((attributes) => Object.keys(attributes).length <= 64, { error: `Workflow run attributes must not include more than 64 keys` });
|
|
111
|
+
const workflowAttributePatchSchema = z.record(workflowAttributeKeySchema, workflowAttributeValueSchema.optional()).refine((attributes) => Object.keys(attributes).length <= 64, { error: `Workflow run attributes must not include more than 64 keys` });
|
|
112
|
+
function encodedWorkflowAttributeByteLength(value) {
|
|
113
|
+
return new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
114
|
+
}
|
|
115
|
+
const workflowRunStatusSchema = z.enum([
|
|
116
|
+
"pending",
|
|
117
|
+
"running",
|
|
118
|
+
"waiting",
|
|
119
|
+
"completed",
|
|
120
|
+
"failed",
|
|
121
|
+
"canceled"
|
|
122
|
+
]);
|
|
123
|
+
const workflowTerminalRunStatusSchema = z.enum([
|
|
124
|
+
"completed",
|
|
125
|
+
"failed",
|
|
126
|
+
"canceled"
|
|
127
|
+
]);
|
|
128
|
+
const workflowRunRetryReasonSchema = z.enum([
|
|
129
|
+
"workflow",
|
|
130
|
+
"step",
|
|
131
|
+
"missing_implementation"
|
|
132
|
+
]);
|
|
133
|
+
const workflowRunTransitionReasonSchema = z.enum([
|
|
134
|
+
"created",
|
|
135
|
+
"claimed",
|
|
136
|
+
"reclaimed",
|
|
137
|
+
"started",
|
|
138
|
+
"waiting",
|
|
139
|
+
"rescheduled",
|
|
140
|
+
"lease_released",
|
|
141
|
+
"manual_retry",
|
|
142
|
+
"permanent_failure",
|
|
143
|
+
"retry",
|
|
144
|
+
"missing_implementation",
|
|
145
|
+
"completed",
|
|
146
|
+
"failed",
|
|
147
|
+
"deadline",
|
|
148
|
+
"canceled"
|
|
149
|
+
]);
|
|
150
|
+
/** Type used for workflow step type values. */
|
|
151
|
+
const workflowStepTypeSchema = z.enum([
|
|
152
|
+
"run",
|
|
153
|
+
"sleep",
|
|
154
|
+
"workflow",
|
|
155
|
+
"message-send",
|
|
156
|
+
"message-wait",
|
|
157
|
+
"stream",
|
|
158
|
+
"deterministic",
|
|
159
|
+
"metadata",
|
|
160
|
+
"attributes"
|
|
161
|
+
]);
|
|
162
|
+
const workflowMaterializedStepTypeSchema = z.enum([
|
|
163
|
+
"run",
|
|
164
|
+
"sleep",
|
|
165
|
+
"workflow",
|
|
166
|
+
"message-send",
|
|
167
|
+
"message-wait",
|
|
168
|
+
"stream",
|
|
169
|
+
"deterministic"
|
|
170
|
+
]);
|
|
171
|
+
const workflowRunRecordSchema = z.object({
|
|
172
|
+
id: runIdSchema,
|
|
173
|
+
namespace: nonBlankStringSchema,
|
|
174
|
+
workflowName: nonBlankStringSchema,
|
|
175
|
+
workflowVersion: nonBlankStringSchema.optional(),
|
|
176
|
+
status: workflowRunStatusSchema,
|
|
177
|
+
input: workflowPersistedValueSchema.optional(),
|
|
178
|
+
context: workflowPersistedValueSchema.optional(),
|
|
179
|
+
telemetryContext: workflowTelemetryContextSchema.optional(),
|
|
180
|
+
metadata: workflowPersistedValueSchema.optional(),
|
|
181
|
+
attributes: workflowRunAttributesSchema.optional(),
|
|
182
|
+
output: workflowPersistedValueSchema.optional(),
|
|
183
|
+
error: workflowErrorRecordSchema.optional(),
|
|
184
|
+
attempts: nonNegativeSafeIntegerSchema.optional(),
|
|
185
|
+
idempotencyKey: nonBlankStringSchema.optional(),
|
|
186
|
+
parentRunId: runIdSchema.optional(),
|
|
187
|
+
parentStepId: stepIdSchema.optional(),
|
|
188
|
+
parentStepName: nonBlankStringSchema.optional(),
|
|
189
|
+
parentStepAttempt: positiveSafeIntegerSchema.optional(),
|
|
190
|
+
workerId: workerIdSchema.optional(),
|
|
191
|
+
createdAt: temporalInstantSchema,
|
|
192
|
+
updatedAt: temporalInstantSchema,
|
|
193
|
+
lastTransitionAt: temporalInstantSchema,
|
|
194
|
+
lastTransitionReason: workflowRunTransitionReasonSchema,
|
|
195
|
+
availableAt: temporalInstantSchema.optional(),
|
|
196
|
+
retryAt: temporalInstantSchema.optional(),
|
|
197
|
+
retryReason: workflowRunRetryReasonSchema.optional(),
|
|
198
|
+
retryAttempt: positiveSafeIntegerSchema.optional(),
|
|
199
|
+
retryStepId: stepIdSchema.optional(),
|
|
200
|
+
retryStepName: nonBlankStringSchema.optional(),
|
|
201
|
+
deadlineAt: temporalInstantSchema.optional(),
|
|
202
|
+
leaseExpiresAt: temporalInstantSchema.optional(),
|
|
203
|
+
startedAt: temporalInstantSchema.optional(),
|
|
204
|
+
finishedAt: temporalInstantSchema.optional()
|
|
205
|
+
});
|
|
206
|
+
//#endregion
|
|
207
|
+
export { WORKFLOW_ATTRIBUTE_MAX_COUNT, WORKFLOW_ATTRIBUTE_MAX_KEY_LENGTH, WORKFLOW_ATTRIBUTE_MAX_VALUE_BYTES, WORKFLOW_ATTRIBUTE_RESERVED_PREFIX, persistedValueIssue, workflowAttributeKeySchema, workflowAttributePatchSchema, workflowAttributePrimitiveValueSchema, workflowAttributeValueSchema, workflowMaterializedStepTypeSchema, workflowPersistedValueSchema, workflowRunAttributesSchema, workflowRunRecordSchema, workflowRunRetryReasonSchema, workflowRunStatusSchema, workflowRunTransitionReasonSchema, workflowStepTypeSchema, workflowTerminalRunStatusSchema };
|