@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,232 @@
|
|
|
1
|
+
import { WorkflowErrorCode } from "../types/error-code.mjs";
|
|
2
|
+
import { WorkflowRunError } from "./base.mjs";
|
|
3
|
+
//#region src/errors/run.ts
|
|
4
|
+
/** Error thrown for run not found failures. */
|
|
5
|
+
var WorkflowRunNotFoundError = class WorkflowRunNotFoundError extends WorkflowRunError {
|
|
6
|
+
runId;
|
|
7
|
+
constructor(runId, context) {
|
|
8
|
+
super(`Workflow run not found: ${runId}`, {
|
|
9
|
+
code: WorkflowErrorCode.RUN_NOT_FOUND,
|
|
10
|
+
details: { runId }
|
|
11
|
+
}, context);
|
|
12
|
+
this.name = "WorkflowRunNotFoundError";
|
|
13
|
+
this.runId = runId;
|
|
14
|
+
}
|
|
15
|
+
static notFound(runId) {
|
|
16
|
+
throw new WorkflowRunNotFoundError(runId, WorkflowRunNotFoundError.notFound);
|
|
17
|
+
}
|
|
18
|
+
static create(runId) {
|
|
19
|
+
return new WorkflowRunNotFoundError(runId, WorkflowRunNotFoundError.create);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
/** Error thrown for run not found failures. */
|
|
23
|
+
var WorkflowRunInvalidError = class WorkflowRunInvalidError extends WorkflowRunError {
|
|
24
|
+
runId;
|
|
25
|
+
constructor(runId, message, context) {
|
|
26
|
+
super(`Workflow run '${runId}' invalid: ${message}`, {
|
|
27
|
+
code: WorkflowErrorCode.RUN_INVALID,
|
|
28
|
+
details: { runId }
|
|
29
|
+
}, context);
|
|
30
|
+
this.name = "WorkflowRunInvalidError";
|
|
31
|
+
this.runId = runId;
|
|
32
|
+
}
|
|
33
|
+
static invalid(runId, message) {
|
|
34
|
+
throw new WorkflowRunInvalidError(runId, message, WorkflowRunInvalidError.invalid);
|
|
35
|
+
}
|
|
36
|
+
static create(runId, message) {
|
|
37
|
+
return new WorkflowRunInvalidError(runId, message, WorkflowRunInvalidError.create);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
/** Error thrown for run mismatch failures. */
|
|
41
|
+
var WorkflowRunMismatchError = class WorkflowRunMismatchError extends WorkflowRunError {
|
|
42
|
+
runId;
|
|
43
|
+
expectedWorkflowName;
|
|
44
|
+
actualWorkflowName;
|
|
45
|
+
constructor(options, context) {
|
|
46
|
+
super(`Workflow run ${options.runId} belongs to ${options.actualWorkflowName}, not ${options.expectedWorkflowName}`, {
|
|
47
|
+
code: WorkflowErrorCode.RUN_WORKFLOW_MISMATCH,
|
|
48
|
+
details: {
|
|
49
|
+
runId: options.runId,
|
|
50
|
+
expectedWorkflowName: options.expectedWorkflowName,
|
|
51
|
+
actualWorkflowName: options.actualWorkflowName
|
|
52
|
+
}
|
|
53
|
+
}, context);
|
|
54
|
+
this.name = "WorkflowRunMismatchError";
|
|
55
|
+
this.runId = options.runId;
|
|
56
|
+
this.expectedWorkflowName = options.expectedWorkflowName;
|
|
57
|
+
this.actualWorkflowName = options.actualWorkflowName;
|
|
58
|
+
}
|
|
59
|
+
static mismatch(options) {
|
|
60
|
+
throw new WorkflowRunMismatchError(options, WorkflowRunMismatchError.mismatch);
|
|
61
|
+
}
|
|
62
|
+
static create(options) {
|
|
63
|
+
return new WorkflowRunMismatchError(options, WorkflowRunMismatchError.create);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
/** Error thrown for result timeout failures. */
|
|
67
|
+
var WorkflowResultTimeoutError = class WorkflowResultTimeoutError extends WorkflowRunError {
|
|
68
|
+
runId;
|
|
69
|
+
timeout;
|
|
70
|
+
constructor(runId, timeout, context) {
|
|
71
|
+
super(`Workflow result timed out after ${timeout.toString()}: ${runId}`, {
|
|
72
|
+
code: WorkflowErrorCode.RUN_RESULT_TIMEOUT,
|
|
73
|
+
details: {
|
|
74
|
+
runId,
|
|
75
|
+
timeout: timeout.toString()
|
|
76
|
+
}
|
|
77
|
+
}, context);
|
|
78
|
+
this.name = "WorkflowResultTimeoutError";
|
|
79
|
+
this.runId = runId;
|
|
80
|
+
this.timeout = timeout;
|
|
81
|
+
}
|
|
82
|
+
static timedOut(runId, timeout) {
|
|
83
|
+
throw new WorkflowResultTimeoutError(runId, timeout, WorkflowResultTimeoutError.timedOut);
|
|
84
|
+
}
|
|
85
|
+
static create(runId, timeout) {
|
|
86
|
+
return new WorkflowResultTimeoutError(runId, timeout, WorkflowResultTimeoutError.create);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
/** Error thrown for run canceled failures. */
|
|
90
|
+
var WorkflowRunCanceledError = class WorkflowRunCanceledError extends WorkflowRunError {
|
|
91
|
+
runId;
|
|
92
|
+
constructor(runId, context) {
|
|
93
|
+
super(`Workflow run was canceled: ${runId}`, {
|
|
94
|
+
code: WorkflowErrorCode.RUN_CANCELED,
|
|
95
|
+
details: { runId }
|
|
96
|
+
}, context);
|
|
97
|
+
this.name = "WorkflowRunCanceledError";
|
|
98
|
+
this.runId = runId;
|
|
99
|
+
}
|
|
100
|
+
static canceled(runId) {
|
|
101
|
+
throw new WorkflowRunCanceledError(runId, WorkflowRunCanceledError.canceled);
|
|
102
|
+
}
|
|
103
|
+
static create(runId) {
|
|
104
|
+
return new WorkflowRunCanceledError(runId, WorkflowRunCanceledError.create);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
/** Error thrown for run cancellation failures. */
|
|
108
|
+
var WorkflowRunCancellationError = class WorkflowRunCancellationError extends WorkflowRunError {
|
|
109
|
+
runId;
|
|
110
|
+
status;
|
|
111
|
+
constructor(runId, status, context) {
|
|
112
|
+
super(`Cannot cancel ${status} workflow run: ${runId}`, {
|
|
113
|
+
code: WorkflowErrorCode.RUN_CANCELLATION_REJECTED,
|
|
114
|
+
details: {
|
|
115
|
+
runId,
|
|
116
|
+
status
|
|
117
|
+
}
|
|
118
|
+
}, context);
|
|
119
|
+
this.name = "WorkflowRunCancellationError";
|
|
120
|
+
this.runId = runId;
|
|
121
|
+
this.status = status;
|
|
122
|
+
}
|
|
123
|
+
static cannotCancel(runId, status) {
|
|
124
|
+
throw new WorkflowRunCancellationError(runId, status, WorkflowRunCancellationError.cannotCancel);
|
|
125
|
+
}
|
|
126
|
+
static create(runId, status) {
|
|
127
|
+
return new WorkflowRunCancellationError(runId, status, WorkflowRunCancellationError.create);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
/** Error thrown for run transition failures. */
|
|
131
|
+
var WorkflowRunTransitionError = class WorkflowRunTransitionError extends WorkflowRunError {
|
|
132
|
+
runId;
|
|
133
|
+
from;
|
|
134
|
+
to;
|
|
135
|
+
constructor(runId, from, to, context) {
|
|
136
|
+
super(`Invalid workflow run status transition: ${runId} ${from} -> ${to}`, {
|
|
137
|
+
code: WorkflowErrorCode.RUN_TRANSITION_INVALID,
|
|
138
|
+
details: {
|
|
139
|
+
runId,
|
|
140
|
+
from,
|
|
141
|
+
to
|
|
142
|
+
}
|
|
143
|
+
}, context);
|
|
144
|
+
this.name = "WorkflowRunTransitionError";
|
|
145
|
+
this.runId = runId;
|
|
146
|
+
this.from = from;
|
|
147
|
+
this.to = to;
|
|
148
|
+
}
|
|
149
|
+
static invalidTransition(runId, from, to) {
|
|
150
|
+
throw new WorkflowRunTransitionError(runId, from, to, WorkflowRunTransitionError.invalidTransition);
|
|
151
|
+
}
|
|
152
|
+
static create(runId, from, to) {
|
|
153
|
+
return new WorkflowRunTransitionError(runId, from, to, WorkflowRunTransitionError.create);
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
/** Error thrown for run parent failures. */
|
|
157
|
+
var WorkflowRunParentError = class WorkflowRunParentError extends WorkflowRunError {
|
|
158
|
+
runId;
|
|
159
|
+
reason;
|
|
160
|
+
constructor(runId, message, context) {
|
|
161
|
+
super(`Invalid workflow run parent metadata for ${runId}: ${message}`, {
|
|
162
|
+
code: WorkflowErrorCode.RUN_PARENT_INVALID,
|
|
163
|
+
details: {
|
|
164
|
+
runId,
|
|
165
|
+
reason: message
|
|
166
|
+
}
|
|
167
|
+
}, context);
|
|
168
|
+
this.name = "WorkflowRunParentError";
|
|
169
|
+
this.runId = runId;
|
|
170
|
+
this.reason = message;
|
|
171
|
+
}
|
|
172
|
+
static invalidParent(runId, message) {
|
|
173
|
+
throw new WorkflowRunParentError(runId, message, WorkflowRunParentError.invalidParent);
|
|
174
|
+
}
|
|
175
|
+
static create(runId, message) {
|
|
176
|
+
return new WorkflowRunParentError(runId, message, WorkflowRunParentError.create);
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
/** Error thrown for run deadline exceeded failures. */
|
|
180
|
+
var WorkflowRunDeadlineExceededError = class WorkflowRunDeadlineExceededError extends WorkflowRunError {
|
|
181
|
+
runId;
|
|
182
|
+
deadlineAt;
|
|
183
|
+
constructor(runId, deadlineAt, context) {
|
|
184
|
+
super(`Workflow run deadline exceeded: ${runId} at ${deadlineAt.toString()}`, {
|
|
185
|
+
code: WorkflowErrorCode.RUN_DEADLINE_EXCEEDED,
|
|
186
|
+
details: {
|
|
187
|
+
runId,
|
|
188
|
+
deadlineAt: deadlineAt.toString()
|
|
189
|
+
}
|
|
190
|
+
}, context);
|
|
191
|
+
this.name = "WorkflowRunDeadlineExceededError";
|
|
192
|
+
this.runId = runId;
|
|
193
|
+
this.deadlineAt = deadlineAt;
|
|
194
|
+
}
|
|
195
|
+
static deadlineExceeded(runId, deadlineAt) {
|
|
196
|
+
throw new WorkflowRunDeadlineExceededError(runId, deadlineAt, WorkflowRunDeadlineExceededError.deadlineExceeded);
|
|
197
|
+
}
|
|
198
|
+
static create(runId, deadlineAt) {
|
|
199
|
+
return new WorkflowRunDeadlineExceededError(runId, deadlineAt, WorkflowRunDeadlineExceededError.create);
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
/** Error thrown for child workflow timeout failures. */
|
|
203
|
+
var WorkflowChildWorkflowTimeoutError = class WorkflowChildWorkflowTimeoutError extends WorkflowRunError {
|
|
204
|
+
runId;
|
|
205
|
+
childRunId;
|
|
206
|
+
stepId;
|
|
207
|
+
timeoutAt;
|
|
208
|
+
constructor(options, context) {
|
|
209
|
+
super(`Child workflow timed out: ${options.childRunId} for parent ${options.runId} step ${options.stepId} at ${options.timeoutAt.toString()}`, {
|
|
210
|
+
code: WorkflowErrorCode.CHILD_WORKFLOW_TIMEOUT,
|
|
211
|
+
details: {
|
|
212
|
+
runId: options.runId,
|
|
213
|
+
childRunId: options.childRunId,
|
|
214
|
+
stepId: options.stepId,
|
|
215
|
+
timeoutAt: options.timeoutAt.toString()
|
|
216
|
+
}
|
|
217
|
+
}, context);
|
|
218
|
+
this.name = "WorkflowChildWorkflowTimeoutError";
|
|
219
|
+
this.runId = options.runId;
|
|
220
|
+
this.childRunId = options.childRunId;
|
|
221
|
+
this.stepId = options.stepId;
|
|
222
|
+
this.timeoutAt = options.timeoutAt;
|
|
223
|
+
}
|
|
224
|
+
static timedOut(options) {
|
|
225
|
+
throw new WorkflowChildWorkflowTimeoutError(options, WorkflowChildWorkflowTimeoutError.timedOut);
|
|
226
|
+
}
|
|
227
|
+
static create(options) {
|
|
228
|
+
return new WorkflowChildWorkflowTimeoutError(options, WorkflowChildWorkflowTimeoutError.create);
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
//#endregion
|
|
232
|
+
export { WorkflowChildWorkflowTimeoutError, WorkflowResultTimeoutError, WorkflowRunCanceledError, WorkflowRunCancellationError, WorkflowRunDeadlineExceededError, WorkflowRunInvalidError, WorkflowRunMismatchError, WorkflowRunNotFoundError, WorkflowRunParentError, WorkflowRunTransitionError };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { WorkflowError } from "./base.mjs";
|
|
2
|
+
//#region src/errors/runtime.d.ts
|
|
3
|
+
/** Error thrown for invalid workflow runtime usage. */
|
|
4
|
+
declare class WorkflowRuntimeError extends WorkflowError {
|
|
5
|
+
constructor(message: string, context?: Function);
|
|
6
|
+
static create(this: void, message: string): WorkflowRuntimeError;
|
|
7
|
+
static invalid(this: void): never;
|
|
8
|
+
static clientMissing(this: void): never;
|
|
9
|
+
static registryMissing(this: void): never;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { WorkflowRuntimeError };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { WorkflowErrorCode } from "../types/error-code.mjs";
|
|
2
|
+
import { WorkflowError } from "./base.mjs";
|
|
3
|
+
//#region src/errors/runtime.ts
|
|
4
|
+
/** Error thrown for invalid workflow runtime usage. */
|
|
5
|
+
var WorkflowRuntimeError = class WorkflowRuntimeError extends WorkflowError {
|
|
6
|
+
constructor(message, context) {
|
|
7
|
+
super(message, { code: WorkflowErrorCode.RUNTIME_INVALID }, context);
|
|
8
|
+
this.name = "WorkflowRuntimeError";
|
|
9
|
+
}
|
|
10
|
+
static create(message) {
|
|
11
|
+
return new WorkflowRuntimeError(message, WorkflowRuntimeError.create);
|
|
12
|
+
}
|
|
13
|
+
static invalid() {
|
|
14
|
+
throw new WorkflowRuntimeError("Workflow runtime is invalid", WorkflowRuntimeError.invalid);
|
|
15
|
+
}
|
|
16
|
+
static clientMissing() {
|
|
17
|
+
throw new WorkflowRuntimeError("Workflow runtime is not backed by a workflow client", WorkflowRuntimeError.clientMissing);
|
|
18
|
+
}
|
|
19
|
+
static registryMissing() {
|
|
20
|
+
throw new WorkflowRuntimeError("Workflow runtime is not backed by a workflow registry", WorkflowRuntimeError.registryMissing);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { WorkflowRuntimeError };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { WorkflowErrorCode } from "../types/error-code.mjs";
|
|
2
|
+
import { ScheduleId } from "../types/schedule.mjs";
|
|
3
|
+
import { WorkflowErrorDetails } from "../types/error.mjs";
|
|
4
|
+
import { WorkflowStateError } from "./base.mjs";
|
|
5
|
+
//#region src/errors/schedule.d.ts
|
|
6
|
+
/** Errors caused by invalid persisted schedule state or exhausted schedule updates. */
|
|
7
|
+
declare class WorkflowScheduleError extends WorkflowStateError {
|
|
8
|
+
constructor(message: string, code: WorkflowErrorCode, details?: WorkflowErrorDetails, context?: Function);
|
|
9
|
+
static namespaceMismatch(this: void, actual: string, expected: string): never;
|
|
10
|
+
static recordInvalid(this: void): never;
|
|
11
|
+
static idChangeRejected(this: void): never;
|
|
12
|
+
static currentRecordInvalid(this: void): never;
|
|
13
|
+
static nextRecordInvalid(this: void): never;
|
|
14
|
+
static upsertConflictExhausted(this: void, scheduleId: ScheduleId): never;
|
|
15
|
+
static notFound(this: void, scheduleId: ScheduleId): never;
|
|
16
|
+
static updateConflictExhausted(this: void, scheduleId: ScheduleId): never;
|
|
17
|
+
}
|
|
18
|
+
/** Error thrown when creating a schedule whose id is already stored. */
|
|
19
|
+
declare class WorkflowScheduleAlreadyExistsError extends WorkflowStateError {
|
|
20
|
+
readonly scheduleId: ScheduleId;
|
|
21
|
+
constructor(scheduleId: ScheduleId, context?: Function);
|
|
22
|
+
static alreadyExists(this: void, scheduleId: ScheduleId): never;
|
|
23
|
+
static create(this: void, scheduleId: ScheduleId): WorkflowScheduleAlreadyExistsError;
|
|
24
|
+
static isAlreadyExists(error: unknown, scheduleId?: ScheduleId): boolean;
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { WorkflowScheduleAlreadyExistsError, WorkflowScheduleError };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { WorkflowErrorCode } from "../types/error-code.mjs";
|
|
2
|
+
import { WorkflowStateError } from "./base.mjs";
|
|
3
|
+
import { workflowErrorRecordView } from "./record-view.mjs";
|
|
4
|
+
//#region src/errors/schedule.ts
|
|
5
|
+
/** Errors caused by invalid persisted schedule state or exhausted schedule updates. */
|
|
6
|
+
var WorkflowScheduleError = class WorkflowScheduleError extends WorkflowStateError {
|
|
7
|
+
constructor(message, code, details, context) {
|
|
8
|
+
super(message, context, {
|
|
9
|
+
code,
|
|
10
|
+
details
|
|
11
|
+
});
|
|
12
|
+
this.name = "WorkflowScheduleError";
|
|
13
|
+
}
|
|
14
|
+
static namespaceMismatch(actual, expected) {
|
|
15
|
+
throw new WorkflowScheduleError(`Workflow schedule namespace mismatch: ${actual} !== ${expected}`, WorkflowErrorCode.SCHEDULE_NAMESPACE_MISMATCH, {
|
|
16
|
+
actual,
|
|
17
|
+
expected
|
|
18
|
+
}, WorkflowScheduleError.namespaceMismatch);
|
|
19
|
+
}
|
|
20
|
+
static recordInvalid() {
|
|
21
|
+
throw new WorkflowScheduleError("Workflow schedule record is invalid", WorkflowErrorCode.SCHEDULE_RECORD_INVALID, void 0, WorkflowScheduleError.recordInvalid);
|
|
22
|
+
}
|
|
23
|
+
static idChangeRejected() {
|
|
24
|
+
throw new WorkflowScheduleError("Workflow schedule id cannot change", WorkflowErrorCode.SCHEDULE_ID_CHANGE_REJECTED, void 0, WorkflowScheduleError.idChangeRejected);
|
|
25
|
+
}
|
|
26
|
+
static currentRecordInvalid() {
|
|
27
|
+
throw new WorkflowScheduleError("Current workflow schedule record is invalid", WorkflowErrorCode.SCHEDULE_CURRENT_RECORD_INVALID, void 0, WorkflowScheduleError.currentRecordInvalid);
|
|
28
|
+
}
|
|
29
|
+
static nextRecordInvalid() {
|
|
30
|
+
throw new WorkflowScheduleError("Next workflow schedule record is invalid", WorkflowErrorCode.SCHEDULE_NEXT_RECORD_INVALID, void 0, WorkflowScheduleError.nextRecordInvalid);
|
|
31
|
+
}
|
|
32
|
+
static upsertConflictExhausted(scheduleId) {
|
|
33
|
+
throw new WorkflowScheduleError(`Failed to upsert workflow schedule ${scheduleId}`, WorkflowErrorCode.SCHEDULE_UPSERT_CONFLICT_EXHAUSTED, { scheduleId }, WorkflowScheduleError.upsertConflictExhausted);
|
|
34
|
+
}
|
|
35
|
+
static notFound(scheduleId) {
|
|
36
|
+
throw new WorkflowScheduleError(`Workflow schedule not found: ${scheduleId}`, WorkflowErrorCode.SCHEDULE_NOT_FOUND, { scheduleId }, WorkflowScheduleError.notFound);
|
|
37
|
+
}
|
|
38
|
+
static updateConflictExhausted(scheduleId) {
|
|
39
|
+
throw new WorkflowScheduleError(`Failed to update workflow schedule ${scheduleId}`, WorkflowErrorCode.SCHEDULE_UPDATE_CONFLICT_EXHAUSTED, { scheduleId }, WorkflowScheduleError.updateConflictExhausted);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
/** Error thrown when creating a schedule whose id is already stored. */
|
|
43
|
+
var WorkflowScheduleAlreadyExistsError = class WorkflowScheduleAlreadyExistsError extends WorkflowStateError {
|
|
44
|
+
scheduleId;
|
|
45
|
+
constructor(scheduleId, context) {
|
|
46
|
+
super(`Workflow schedule already exists: ${scheduleId}`, context, {
|
|
47
|
+
code: WorkflowErrorCode.SCHEDULE_ALREADY_EXISTS,
|
|
48
|
+
details: { scheduleId }
|
|
49
|
+
});
|
|
50
|
+
this.name = "WorkflowScheduleAlreadyExistsError";
|
|
51
|
+
this.scheduleId = scheduleId;
|
|
52
|
+
}
|
|
53
|
+
static alreadyExists(scheduleId) {
|
|
54
|
+
throw new WorkflowScheduleAlreadyExistsError(scheduleId, WorkflowScheduleAlreadyExistsError.alreadyExists);
|
|
55
|
+
}
|
|
56
|
+
static create(scheduleId) {
|
|
57
|
+
return new WorkflowScheduleAlreadyExistsError(scheduleId, WorkflowScheduleAlreadyExistsError.create);
|
|
58
|
+
}
|
|
59
|
+
static isAlreadyExists(error, scheduleId) {
|
|
60
|
+
const record = workflowErrorRecordView(error);
|
|
61
|
+
return record?.code === WorkflowErrorCode.SCHEDULE_ALREADY_EXISTS && (scheduleId === void 0 || record.details?.scheduleId === scheduleId);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
//#endregion
|
|
65
|
+
export { WorkflowScheduleAlreadyExistsError, WorkflowScheduleError };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { RunId } from "../types/run-id.mjs";
|
|
2
|
+
import { StepId } from "../types/step-id.mjs";
|
|
3
|
+
import "../types/step.mjs";
|
|
4
|
+
import "../types/run.mjs";
|
|
5
|
+
import { WorkflowStepExecutionErrorOptions } from "../types/error.mjs";
|
|
6
|
+
import { WorkflowStepError } from "./base.mjs";
|
|
7
|
+
//#region src/errors/step.d.ts
|
|
8
|
+
/** Error thrown for step timeout failures. */
|
|
9
|
+
declare class WorkflowStepTimeoutError extends WorkflowStepError {
|
|
10
|
+
readonly runId: RunId;
|
|
11
|
+
readonly stepId: StepId;
|
|
12
|
+
readonly stepName: string;
|
|
13
|
+
readonly attempt: number;
|
|
14
|
+
readonly timeoutAt: Temporal.Instant;
|
|
15
|
+
constructor(options: {
|
|
16
|
+
readonly runId: RunId;
|
|
17
|
+
readonly stepId: StepId;
|
|
18
|
+
readonly stepName: string;
|
|
19
|
+
readonly attempt: number;
|
|
20
|
+
readonly timeoutAt: Temporal.Instant;
|
|
21
|
+
}, context?: Function);
|
|
22
|
+
static timedOut(this: void, options: {
|
|
23
|
+
readonly runId: RunId;
|
|
24
|
+
readonly stepId: StepId;
|
|
25
|
+
readonly stepName: string;
|
|
26
|
+
readonly attempt: number;
|
|
27
|
+
readonly timeoutAt: Temporal.Instant;
|
|
28
|
+
}): never;
|
|
29
|
+
static create(this: void, options: {
|
|
30
|
+
readonly runId: RunId;
|
|
31
|
+
readonly stepId: StepId;
|
|
32
|
+
readonly stepName: string;
|
|
33
|
+
readonly attempt: number;
|
|
34
|
+
readonly timeoutAt: Temporal.Instant;
|
|
35
|
+
}): WorkflowStepTimeoutError;
|
|
36
|
+
}
|
|
37
|
+
/** Error thrown for step execution failures. */
|
|
38
|
+
declare class WorkflowStepExecutionError extends WorkflowStepError {
|
|
39
|
+
readonly stepId: StepId;
|
|
40
|
+
readonly stepName: string;
|
|
41
|
+
readonly attempt: number;
|
|
42
|
+
constructor(options: WorkflowStepExecutionErrorOptions, context?: Function);
|
|
43
|
+
static failed(this: void, options: WorkflowStepExecutionErrorOptions): never;
|
|
44
|
+
static create(this: void, options: WorkflowStepExecutionErrorOptions): WorkflowStepExecutionError;
|
|
45
|
+
}
|
|
46
|
+
/** Error thrown when a step exhausts its retry policy. */
|
|
47
|
+
declare class WorkflowStepRetryLimitError extends WorkflowStepError {
|
|
48
|
+
readonly stepId: StepId;
|
|
49
|
+
readonly stepName: string;
|
|
50
|
+
readonly attempt: number;
|
|
51
|
+
constructor(options: {
|
|
52
|
+
readonly stepId: StepId;
|
|
53
|
+
readonly stepName: string;
|
|
54
|
+
readonly attempt: number;
|
|
55
|
+
}, context?: Function);
|
|
56
|
+
static exceeded(this: void, options: {
|
|
57
|
+
readonly stepId: StepId;
|
|
58
|
+
readonly stepName: string;
|
|
59
|
+
readonly attempt: number;
|
|
60
|
+
}): never;
|
|
61
|
+
static create(this: void, options: {
|
|
62
|
+
readonly stepId: StepId;
|
|
63
|
+
readonly stepName: string;
|
|
64
|
+
readonly attempt: number;
|
|
65
|
+
}): WorkflowStepRetryLimitError;
|
|
66
|
+
}
|
|
67
|
+
/** Error thrown for step attempt limit failures. */
|
|
68
|
+
declare class WorkflowStepAttemptLimitError extends WorkflowStepError {
|
|
69
|
+
readonly runId: RunId;
|
|
70
|
+
readonly maximumAttempts: number;
|
|
71
|
+
constructor(runId: RunId, maximumAttempts: number, context?: Function);
|
|
72
|
+
static exceeded(this: void, runId: RunId, maximumAttempts: number): never;
|
|
73
|
+
static create(this: void, runId: RunId, maximumAttempts: number): WorkflowStepAttemptLimitError;
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
export { WorkflowStepAttemptLimitError, WorkflowStepExecutionError, WorkflowStepRetryLimitError, WorkflowStepTimeoutError };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { WorkflowErrorCode } from "../types/error-code.mjs";
|
|
2
|
+
import { WorkflowStepError } from "./base.mjs";
|
|
3
|
+
//#region src/errors/step.ts
|
|
4
|
+
/** Error thrown for step timeout failures. */
|
|
5
|
+
var WorkflowStepTimeoutError = class WorkflowStepTimeoutError extends WorkflowStepError {
|
|
6
|
+
runId;
|
|
7
|
+
stepId;
|
|
8
|
+
stepName;
|
|
9
|
+
attempt;
|
|
10
|
+
timeoutAt;
|
|
11
|
+
constructor(options, context) {
|
|
12
|
+
super(`Workflow step timed out: ${options.stepName} for run ${options.runId} attempt ${options.attempt} at ${options.timeoutAt.toString()}`, {
|
|
13
|
+
code: WorkflowErrorCode.STEP_TIMEOUT,
|
|
14
|
+
details: {
|
|
15
|
+
runId: options.runId,
|
|
16
|
+
stepId: options.stepId,
|
|
17
|
+
stepName: options.stepName,
|
|
18
|
+
attempt: options.attempt,
|
|
19
|
+
timeoutAt: options.timeoutAt.toString()
|
|
20
|
+
}
|
|
21
|
+
}, context);
|
|
22
|
+
this.name = "WorkflowStepTimeoutError";
|
|
23
|
+
this.runId = options.runId;
|
|
24
|
+
this.stepId = options.stepId;
|
|
25
|
+
this.stepName = options.stepName;
|
|
26
|
+
this.attempt = options.attempt;
|
|
27
|
+
this.timeoutAt = options.timeoutAt;
|
|
28
|
+
}
|
|
29
|
+
static timedOut(options) {
|
|
30
|
+
throw new WorkflowStepTimeoutError(options, WorkflowStepTimeoutError.timedOut);
|
|
31
|
+
}
|
|
32
|
+
static create(options) {
|
|
33
|
+
return new WorkflowStepTimeoutError(options, WorkflowStepTimeoutError.create);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
/** Error thrown for step execution failures. */
|
|
37
|
+
var WorkflowStepExecutionError = class WorkflowStepExecutionError extends WorkflowStepError {
|
|
38
|
+
stepId;
|
|
39
|
+
stepName;
|
|
40
|
+
attempt;
|
|
41
|
+
constructor(options, context) {
|
|
42
|
+
super(`Workflow step failed: ${options.stepName}`, {
|
|
43
|
+
code: WorkflowErrorCode.STEP_EXECUTION_FAILED,
|
|
44
|
+
cause: options.cause,
|
|
45
|
+
details: {
|
|
46
|
+
stepId: options.stepId,
|
|
47
|
+
stepName: options.stepName,
|
|
48
|
+
attempt: options.attempt
|
|
49
|
+
}
|
|
50
|
+
}, context);
|
|
51
|
+
this.name = "WorkflowStepExecutionError";
|
|
52
|
+
this.stepId = options.stepId;
|
|
53
|
+
this.stepName = options.stepName;
|
|
54
|
+
this.attempt = options.attempt;
|
|
55
|
+
}
|
|
56
|
+
static failed(options) {
|
|
57
|
+
throw new WorkflowStepExecutionError(options, WorkflowStepExecutionError.failed);
|
|
58
|
+
}
|
|
59
|
+
static create(options) {
|
|
60
|
+
return new WorkflowStepExecutionError(options, WorkflowStepExecutionError.create);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
/** Error thrown when a step exhausts its retry policy. */
|
|
64
|
+
var WorkflowStepRetryLimitError = class WorkflowStepRetryLimitError extends WorkflowStepError {
|
|
65
|
+
stepId;
|
|
66
|
+
stepName;
|
|
67
|
+
attempt;
|
|
68
|
+
constructor(options, context) {
|
|
69
|
+
super(`Workflow step retry limit exceeded: ${options.stepName}`, {
|
|
70
|
+
code: WorkflowErrorCode.STEP_RETRY_LIMIT_EXCEEDED,
|
|
71
|
+
details: {
|
|
72
|
+
stepId: options.stepId,
|
|
73
|
+
stepName: options.stepName,
|
|
74
|
+
attempt: options.attempt
|
|
75
|
+
}
|
|
76
|
+
}, context);
|
|
77
|
+
this.name = "WorkflowStepRetryLimitError";
|
|
78
|
+
this.stepId = options.stepId;
|
|
79
|
+
this.stepName = options.stepName;
|
|
80
|
+
this.attempt = options.attempt;
|
|
81
|
+
}
|
|
82
|
+
static exceeded(options) {
|
|
83
|
+
throw new WorkflowStepRetryLimitError(options, WorkflowStepRetryLimitError.exceeded);
|
|
84
|
+
}
|
|
85
|
+
static create(options) {
|
|
86
|
+
return new WorkflowStepRetryLimitError(options, WorkflowStepRetryLimitError.create);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
/** Error thrown for step attempt limit failures. */
|
|
90
|
+
var WorkflowStepAttemptLimitError = class WorkflowStepAttemptLimitError extends WorkflowStepError {
|
|
91
|
+
runId;
|
|
92
|
+
maximumAttempts;
|
|
93
|
+
constructor(runId, maximumAttempts, context) {
|
|
94
|
+
super(`Workflow run exceeded total step attempt limit: ${runId} (${maximumAttempts})`, {
|
|
95
|
+
code: WorkflowErrorCode.STEP_ATTEMPT_LIMIT_EXCEEDED,
|
|
96
|
+
details: {
|
|
97
|
+
runId,
|
|
98
|
+
maximumAttempts
|
|
99
|
+
}
|
|
100
|
+
}, context);
|
|
101
|
+
this.name = "WorkflowStepAttemptLimitError";
|
|
102
|
+
this.runId = runId;
|
|
103
|
+
this.maximumAttempts = maximumAttempts;
|
|
104
|
+
}
|
|
105
|
+
static exceeded(runId, maximumAttempts) {
|
|
106
|
+
throw new WorkflowStepAttemptLimitError(runId, maximumAttempts, WorkflowStepAttemptLimitError.exceeded);
|
|
107
|
+
}
|
|
108
|
+
static create(runId, maximumAttempts) {
|
|
109
|
+
return new WorkflowStepAttemptLimitError(runId, maximumAttempts, WorkflowStepAttemptLimitError.create);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
//#endregion
|
|
113
|
+
export { WorkflowStepAttemptLimitError, WorkflowStepExecutionError, WorkflowStepRetryLimitError, WorkflowStepTimeoutError };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { WorkflowErrorCode } from "../types/error-code.mjs";
|
|
2
|
+
import { StreamIdOrName } from "../types/stream-id.mjs";
|
|
3
|
+
import { WorkflowErrorDetails } from "../types/error.mjs";
|
|
4
|
+
import { WorkflowOptionsError } from "./base.mjs";
|
|
5
|
+
//#region src/errors/stream.d.ts
|
|
6
|
+
/** Errors caused by invalid stream operations or stream history. */
|
|
7
|
+
declare class WorkflowStreamError extends WorkflowOptionsError {
|
|
8
|
+
constructor(message: string, code: WorkflowErrorCode, details?: WorkflowErrorDetails, context?: Function);
|
|
9
|
+
static chunkLimitExceeded(this: void, streamId: string, maximumChunks: number): never;
|
|
10
|
+
static readOffsetConflict(this: void): never;
|
|
11
|
+
static nonContiguousChunkIndex(this: void, streamId: string, actualIndex: number, expectedIndex: number): never;
|
|
12
|
+
static chunkAfterTerminal(this: void, streamId: string, chunkIndex: number, terminalKind: string): never;
|
|
13
|
+
static alreadyClosed(this: void, streamId: string): never;
|
|
14
|
+
}
|
|
15
|
+
/** Error thrown when a requested workflow stream cannot be found. */
|
|
16
|
+
declare class WorkflowStreamNotFoundError extends WorkflowOptionsError {
|
|
17
|
+
readonly streamIdOrName: StreamIdOrName;
|
|
18
|
+
constructor(streamIdOrName: StreamIdOrName, context?: Function);
|
|
19
|
+
static notFound(this: void, streamIdOrName: StreamIdOrName): never;
|
|
20
|
+
static create(this: void, streamIdOrName: StreamIdOrName): WorkflowStreamNotFoundError;
|
|
21
|
+
static isNotFound(error: unknown, streamIdOrName?: StreamIdOrName): boolean;
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { WorkflowStreamError, WorkflowStreamNotFoundError };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { WorkflowErrorCode } from "../types/error-code.mjs";
|
|
2
|
+
import { WorkflowOptionsError } from "./base.mjs";
|
|
3
|
+
import { workflowErrorRecordView } from "./record-view.mjs";
|
|
4
|
+
//#region src/errors/stream.ts
|
|
5
|
+
/** Errors caused by invalid stream operations or stream history. */
|
|
6
|
+
var WorkflowStreamError = class WorkflowStreamError extends WorkflowOptionsError {
|
|
7
|
+
constructor(message, code, details, context) {
|
|
8
|
+
super(message, context, {
|
|
9
|
+
code,
|
|
10
|
+
details
|
|
11
|
+
});
|
|
12
|
+
this.name = "WorkflowStreamError";
|
|
13
|
+
}
|
|
14
|
+
static chunkLimitExceeded(streamId, maximumChunks) {
|
|
15
|
+
throw new WorkflowStreamError(`Workflow stream ${streamId} chunk count would exceed maximumStreamChunks ${maximumChunks}`, WorkflowErrorCode.STREAM_CHUNK_LIMIT_EXCEEDED, {
|
|
16
|
+
streamId,
|
|
17
|
+
maximumChunks
|
|
18
|
+
}, WorkflowStreamError.chunkLimitExceeded);
|
|
19
|
+
}
|
|
20
|
+
static readOffsetConflict() {
|
|
21
|
+
throw new WorkflowStreamError("Cannot include both fromIndex and fromTail", WorkflowErrorCode.STREAM_READ_OFFSET_CONFLICT, void 0, WorkflowStreamError.readOffsetConflict);
|
|
22
|
+
}
|
|
23
|
+
static nonContiguousChunkIndex(streamId, actualIndex, expectedIndex) {
|
|
24
|
+
throw new WorkflowStreamError(`Workflow stream ${streamId} has non-contiguous chunk index ${actualIndex}; expected ${expectedIndex}`, WorkflowErrorCode.STREAM_CHUNK_INDEX_NON_CONTIGUOUS, {
|
|
25
|
+
streamId,
|
|
26
|
+
actualIndex,
|
|
27
|
+
expectedIndex
|
|
28
|
+
}, WorkflowStreamError.nonContiguousChunkIndex);
|
|
29
|
+
}
|
|
30
|
+
static chunkAfterTerminal(streamId, chunkIndex, terminalKind) {
|
|
31
|
+
throw new WorkflowStreamError(`Workflow stream ${streamId} has chunk ${chunkIndex} after terminal event ${terminalKind}`, WorkflowErrorCode.STREAM_CHUNK_AFTER_TERMINAL, {
|
|
32
|
+
streamId,
|
|
33
|
+
chunkIndex,
|
|
34
|
+
terminalKind
|
|
35
|
+
}, WorkflowStreamError.chunkAfterTerminal);
|
|
36
|
+
}
|
|
37
|
+
static alreadyClosed(streamId) {
|
|
38
|
+
throw new WorkflowStreamError(`Workflow stream is already closed: ${streamId}`, WorkflowErrorCode.STREAM_ALREADY_CLOSED, { streamId }, WorkflowStreamError.alreadyClosed);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
/** Error thrown when a requested workflow stream cannot be found. */
|
|
42
|
+
var WorkflowStreamNotFoundError = class WorkflowStreamNotFoundError extends WorkflowOptionsError {
|
|
43
|
+
streamIdOrName;
|
|
44
|
+
constructor(streamIdOrName, context) {
|
|
45
|
+
super(`Workflow stream was not found: ${streamIdOrName}`, context, {
|
|
46
|
+
code: WorkflowErrorCode.STREAM_NOT_FOUND,
|
|
47
|
+
details: { streamIdOrName }
|
|
48
|
+
});
|
|
49
|
+
this.name = "WorkflowStreamNotFoundError";
|
|
50
|
+
this.streamIdOrName = streamIdOrName;
|
|
51
|
+
}
|
|
52
|
+
static notFound(streamIdOrName) {
|
|
53
|
+
throw new WorkflowStreamNotFoundError(streamIdOrName, WorkflowStreamNotFoundError.notFound);
|
|
54
|
+
}
|
|
55
|
+
static create(streamIdOrName) {
|
|
56
|
+
return new WorkflowStreamNotFoundError(streamIdOrName, WorkflowStreamNotFoundError.create);
|
|
57
|
+
}
|
|
58
|
+
static isNotFound(error, streamIdOrName) {
|
|
59
|
+
const record = workflowErrorRecordView(error);
|
|
60
|
+
return record?.code === WorkflowErrorCode.STREAM_NOT_FOUND && (streamIdOrName === void 0 || record.details?.streamIdOrName === streamIdOrName);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
//#endregion
|
|
64
|
+
export { WorkflowStreamError, WorkflowStreamNotFoundError };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { WorkflowPluginOptions } from "./types/vite.mjs";
|
|
2
|
+
import { workflowPlugin } from "./vite/plugin.mjs";
|
|
3
|
+
//#region src/esbuild.d.ts
|
|
4
|
+
/** Creates the esbuild plugin that compiles workflow and step directives. */
|
|
5
|
+
declare const workflow: (options?: WorkflowPluginOptions | undefined) => import("esbuild").Plugin;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { type WorkflowPluginOptions, workflow, workflowPlugin };
|
package/dist/esbuild.mjs
ADDED