@lostgradient/weft 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -24
- package/dist/cli/conformance.js +7 -1
- package/dist/cli/generated/operation-client.generated.d.ts +28 -13
- package/dist/cli/generated/operation-client.generated.js +1 -0
- package/dist/cli/help-text.d.ts +1 -1
- package/dist/cli/help-text.js +1 -0
- package/dist/cli/operation-catalog-snapshot.d.ts +8 -0
- package/dist/cli/operation-catalog-snapshot.js +11 -0
- package/dist/cli/parse-schedule-arguments.js +3 -1
- package/dist/cli/schedule.js +2 -1
- package/dist/cli/types.d.ts +1 -0
- package/dist/cli-main.js +79 -78
- package/dist/client/handle-delegation.d.ts +3 -2
- package/dist/client/handle-delegation.js +3 -1
- package/dist/client/http-client-requests.d.ts +2 -1
- package/dist/client/http-client-requests.js +7 -0
- package/dist/client/http-client.d.ts +9 -6
- package/dist/client/http-client.js +10 -1
- package/dist/client/http-request.d.ts +11 -1
- package/dist/client/http-request.js +17 -7
- package/dist/client/index.d.ts +1 -1
- package/dist/client/interface.d.ts +61 -5
- package/dist/client/local-handles.d.ts +22 -0
- package/dist/client/local-handles.js +23 -0
- package/dist/client/local.d.ts +6 -3
- package/dist/client/local.js +12 -26
- package/dist/client/start-body.d.ts +4 -3
- package/dist/core/byte-arrays.d.ts +5 -0
- package/dist/core/byte-arrays.js +5 -0
- package/dist/core/checkpoint/lifecycle.d.ts +3 -0
- package/dist/core/checkpoint/lifecycle.js +9 -4
- package/dist/core/checkpoint/serialization.js +12 -5
- package/dist/core/codec/extension-codec.d.ts +16 -0
- package/dist/core/codec/extension-codec.js +100 -6
- package/dist/core/context/activity-retry-state.d.ts +38 -0
- package/dist/core/context/activity-retry-state.js +89 -0
- package/dist/core/context/activity-schedule-to-close.d.ts +159 -0
- package/dist/core/context/activity-schedule-to-close.js +69 -0
- package/dist/core/context/child-workflow-pipe.d.ts +5 -5
- package/dist/core/context/child-workflow-pipe.js +15 -2
- package/dist/core/context/context-presence.d.ts +19 -0
- package/dist/core/context/context-presence.js +13 -0
- package/dist/core/context/durable-operations.d.ts +25 -0
- package/dist/core/context/durable-operations.js +64 -0
- package/dist/core/context/index.d.ts +9 -5
- package/dist/core/context/index.js +17 -12
- package/dist/core/context/internals.d.ts +20 -0
- package/dist/core/context/internals.js +3 -1
- package/dist/core/context/operation-request.d.ts +35 -0
- package/dist/core/context/parallel-cache-entry.d.ts +14 -5
- package/dist/core/context/run-operation.d.ts +6 -1
- package/dist/core/context/run-operation.js +41 -87
- package/dist/core/context/session-state.js +7 -8
- package/dist/core/context/speculative-child.js +2 -0
- package/dist/core/context/types.d.ts +15 -0
- package/dist/core/context/version-patching.d.ts +8 -0
- package/dist/core/context/version-patching.js +40 -0
- package/dist/core/context/workflow-logger.d.ts +98 -0
- package/dist/core/context/workflow-logger.js +68 -0
- package/dist/core/engine/activity-heartbeat-tracking.d.ts +64 -0
- package/dist/core/engine/activity-heartbeat-tracking.js +42 -0
- package/dist/core/engine/activity-per-attempt-timeout.d.ts +46 -0
- package/dist/core/engine/activity-per-attempt-timeout.js +36 -0
- package/dist/core/engine/activity-reconciliation.d.ts +1 -0
- package/dist/core/engine/activity-reconciliation.js +12 -1
- package/dist/core/engine/activity-resolution.d.ts +23 -0
- package/dist/core/engine/activity-resolution.js +37 -0
- package/dist/core/engine/aggregate.js +66 -30
- package/dist/core/engine/async-activity-completion.d.ts +23 -6
- package/dist/core/engine/async-activity-completion.js +53 -12
- package/dist/core/engine/attributes-tags.js +9 -4
- package/dist/core/engine/bulk-operations-purge.d.ts +26 -0
- package/dist/core/engine/bulk-operations-purge.js +38 -3
- package/dist/core/engine/bulk-operations-shared.d.ts +2 -0
- package/dist/core/engine/bulk-operations-shared.js +8 -2
- package/dist/core/engine/bulk-operations.d.ts +4 -1
- package/dist/core/engine/bulk-operations.js +235 -24
- package/dist/core/engine/callback-creators-bundles.d.ts +9 -0
- package/dist/core/engine/callback-creators-bundles.js +30 -2
- package/dist/core/engine/callback-creators-core.js +6 -4
- package/dist/core/engine/callback-creators-router.js +10 -0
- package/dist/core/engine/callback-creators-schedule.d.ts +2 -2
- package/dist/core/engine/callback-creators-schedule.js +12 -8
- package/dist/core/engine/candidate-read-batching.d.ts +6 -0
- package/dist/core/engine/candidate-read-batching.js +1 -0
- package/dist/core/engine/checkpoint-io.js +61 -25
- package/dist/core/engine/checkpoint-reads.js +3 -2
- package/dist/core/engine/checkpoint-replay.d.ts +20 -0
- package/dist/core/engine/checkpoint-replay.js +242 -0
- package/dist/core/engine/checkpoint-side-effects.d.ts +23 -0
- package/dist/core/engine/checkpoint-side-effects.js +35 -0
- package/dist/core/engine/child-workflow-cancellation.d.ts +10 -0
- package/dist/core/engine/child-workflow-cancellation.js +40 -0
- package/dist/core/engine/child-workflow.js +27 -4
- package/dist/core/engine/condition-waiters.d.ts +14 -0
- package/dist/core/engine/condition-waiters.js +5 -0
- package/dist/core/engine/construction.d.ts +3 -0
- package/dist/core/engine/construction.js +21 -8
- package/dist/core/engine/coordination-branch-executors.d.ts +70 -0
- package/dist/core/engine/coordination-branch-executors.js +107 -0
- package/dist/core/engine/deferred-consume-envelope.d.ts +59 -0
- package/dist/core/engine/deferred-consume-envelope.js +14 -0
- package/dist/core/engine/disposal.js +13 -0
- package/dist/core/engine/engine-create-types.d.ts +14 -4
- package/dist/core/engine/engine-internal-types.d.ts +26 -3
- package/dist/core/engine/errors.d.ts +47 -0
- package/dist/core/engine/errors.js +20 -0
- package/dist/core/engine/event-log-compaction.d.ts +8 -0
- package/dist/core/engine/event-log-compaction.js +20 -2
- package/dist/core/engine/fenced-write.d.ts +65 -0
- package/dist/core/engine/fenced-write.js +71 -0
- package/dist/core/engine/finalizer-state.d.ts +28 -0
- package/dist/core/engine/finalizer-state.js +16 -0
- package/dist/core/engine/handles.d.ts +8 -0
- package/dist/core/engine/index.d.ts +34 -16
- package/dist/core/engine/index.js +136 -9
- package/dist/core/engine/inline-parking.js +3 -2
- package/dist/core/engine/internals.d.ts +107 -3
- package/dist/core/engine/lease-codec.d.ts +35 -0
- package/dist/core/engine/lease-codec.js +32 -0
- package/dist/core/engine/lease-deposition.d.ts +66 -0
- package/dist/core/engine/lease-deposition.js +10 -0
- package/dist/core/engine/lease-errors.d.ts +99 -0
- package/dist/core/engine/lease-errors.js +30 -0
- package/dist/core/engine/lease-manager.d.ts +114 -0
- package/dist/core/engine/lease-manager.js +135 -0
- package/dist/core/engine/lifecycle/persist.js +10 -32
- package/dist/core/engine/lifecycle/recovered-services.d.ts +8 -6
- package/dist/core/engine/lifecycle/recovered-services.js +18 -3
- package/dist/core/engine/lifecycle/resume.js +16 -9
- package/dist/core/engine/lifecycle/shared.d.ts +8 -1
- package/dist/core/engine/lifecycle/start-batch.d.ts +1 -1
- package/dist/core/engine/lifecycle/start-batch.js +2 -1
- package/dist/core/engine/lifecycle/start-commit.d.ts +9 -0
- package/dist/core/engine/lifecycle/start-commit.js +50 -8
- package/dist/core/engine/lifecycle/start-or-signal-create.d.ts +58 -0
- package/dist/core/engine/lifecycle/start-or-signal-create.js +95 -0
- package/dist/core/engine/lifecycle/start-or-signal.d.ts +3 -2
- package/dist/core/engine/lifecycle/start-or-signal.js +11 -81
- package/dist/core/engine/lifecycle/start-terminal-conflict-purge.d.ts +39 -0
- package/dist/core/engine/lifecycle/start-terminal-conflict-purge.js +28 -0
- package/dist/core/engine/lifecycle/start.d.ts +4 -4
- package/dist/core/engine/lifecycle/start.js +17 -9
- package/dist/core/engine/lifecycle/transition.js +17 -5
- package/dist/core/engine/lifecycle.d.ts +1 -1
- package/dist/core/engine/list-candidate-resolution.js +2 -2
- package/dist/core/engine/listing.js +9 -5
- package/dist/core/engine/operations-activity.d.ts +6 -13
- package/dist/core/engine/operations-activity.js +26 -53
- package/dist/core/engine/operations-coordination.d.ts +10 -0
- package/dist/core/engine/operations-coordination.js +44 -9
- package/dist/core/engine/operations-router.d.ts +6 -0
- package/dist/core/engine/operations-router.js +2 -0
- package/dist/core/engine/operations-speculate.js +6 -2
- package/dist/core/engine/operations-stream.js +12 -2
- package/dist/core/engine/operations-time.d.ts +4 -2
- package/dist/core/engine/operations-time.js +14 -2
- package/dist/core/engine/operations-wait-condition.d.ts +23 -0
- package/dist/core/engine/operations-wait-condition.js +62 -0
- package/dist/core/engine/ownership-options.d.ts +23 -0
- package/dist/core/engine/ownership-options.js +26 -0
- package/dist/core/engine/payload-size-policy.d.ts +3 -0
- package/dist/core/engine/payload-size-policy.js +4 -0
- package/dist/core/engine/pending-updates.d.ts +17 -0
- package/dist/core/engine/pending-updates.js +33 -11
- package/dist/core/engine/queries.js +1 -1
- package/dist/core/engine/registration.d.ts +1 -0
- package/dist/core/engine/registration.js +18 -3
- package/dist/core/engine/schedule-jitter.d.ts +5 -0
- package/dist/core/engine/schedule-jitter.js +10 -0
- package/dist/core/engine/schedule-run.d.ts +17 -0
- package/dist/core/engine/schedule-run.js +38 -0
- package/dist/core/engine/schedule-timer.js +81 -17
- package/dist/core/engine/schedules.d.ts +7 -4
- package/dist/core/engine/schedules.js +37 -16
- package/dist/core/engine/search-attribute-records.d.ts +4 -0
- package/dist/core/engine/search-attribute-records.js +17 -0
- package/dist/core/engine/signals.d.ts +18 -2
- package/dist/core/engine/signals.js +42 -21
- package/dist/core/engine/state-utilities.d.ts +49 -2
- package/dist/core/engine/state-utilities.js +114 -3
- package/dist/core/engine/storage-io.d.ts +16 -2
- package/dist/core/engine/storage-io.js +26 -5
- package/dist/core/engine/stream-chunk-loading.d.ts +2 -0
- package/dist/core/engine/stream-chunk-loading.js +24 -1
- package/dist/core/engine/sub-operation.js +25 -6
- package/dist/core/engine/termination/cleanup.d.ts +3 -1
- package/dist/core/engine/termination/cleanup.js +25 -1
- package/dist/core/engine/termination/complete.js +44 -6
- package/dist/core/engine/termination/finalizer-activity.d.ts +53 -0
- package/dist/core/engine/termination/finalizer-activity.js +30 -0
- package/dist/core/engine/termination/finalizer-claim.d.ts +110 -0
- package/dist/core/engine/termination/finalizer-claim.js +80 -0
- package/dist/core/engine/termination/finalizer.d.ts +48 -0
- package/dist/core/engine/termination/finalizer.js +159 -0
- package/dist/core/engine/termination/suspend.d.ts +3 -1
- package/dist/core/engine/termination.d.ts +1 -0
- package/dist/core/engine/termination.js +4 -0
- package/dist/core/engine/updates.js +5 -25
- package/dist/core/engine/validation/schedule.d.ts +2 -1
- package/dist/core/engine/validation/schedule.js +51 -2
- package/dist/core/engine/validation.js +32 -5
- package/dist/core/engine/waiting-update-response.d.ts +8 -0
- package/dist/core/engine/waiting-update-response.js +22 -0
- package/dist/core/engine/workflow-concurrency.d.ts +10 -0
- package/dist/core/engine/workflow-concurrency.js +136 -0
- package/dist/core/engine/workflow-feed.d.ts +4 -5
- package/dist/core/engine/workflow-feed.js +4 -1
- package/dist/core/engine/workflow-indexes.d.ts +9 -0
- package/dist/core/engine/workflow-indexes.js +10 -0
- package/dist/core/engine/workflow-state-stream.js +33 -13
- package/dist/core/engine/workflow-visibility-queries.d.ts +2 -2
- package/dist/core/engine-helpers.js +1 -0
- package/dist/core/events/activity-events.d.ts +43 -12
- package/dist/core/events/activity-events.js +28 -0
- package/dist/core/events/attribute-events.d.ts +2 -3
- package/dist/core/events/event-map.d.ts +18 -12
- package/dist/core/events/index.d.ts +1 -0
- package/dist/core/events/index.js +1 -0
- package/dist/core/events/schedule-events.d.ts +71 -0
- package/dist/core/events/schedule-events.js +29 -0
- package/dist/core/events/signal-events.d.ts +4 -6
- package/dist/core/events/system-events.d.ts +29 -19
- package/dist/core/events/system-events.js +26 -0
- package/dist/core/events/update-events.d.ts +6 -8
- package/dist/core/events/workflow-events.d.ts +88 -23
- package/dist/core/events/workflow-events.js +26 -0
- package/dist/core/failure-categories.js +5 -17
- package/dist/core/fault-code.d.ts +9 -3
- package/dist/core/fault-code.js +1 -0
- package/dist/core/inline-execution-strategy.context-options.d.ts +69 -0
- package/dist/core/inline-execution-strategy.context-options.js +56 -0
- package/dist/core/inline-execution-strategy.d.ts +31 -36
- package/dist/core/inline-execution-strategy.js +16 -27
- package/dist/core/list-filter-validation.d.ts +1 -1
- package/dist/core/payload-size.d.ts +1 -1
- package/dist/core/persisted-data-incompatible-error.d.ts +9 -7
- package/dist/core/review/events.d.ts +6 -8
- package/dist/core/scheduler/scheduler-class.d.ts +10 -1
- package/dist/core/scheduler/scheduler-class.js +38 -11
- package/dist/core/scheduler/timer-batch.js +9 -1
- package/dist/core/scheduler/timer-sources.d.ts +1 -0
- package/dist/core/scheduler/timer-sources.js +11 -5
- package/dist/core/session-state.d.ts +0 -1
- package/dist/core/session-state.js +2 -2
- package/dist/core/start-workflow-validation.d.ts +34 -0
- package/dist/core/start-workflow-validation.js +19 -0
- package/dist/core/types/activity-verification.d.ts +67 -0
- package/dist/core/types/activity-verification.js +0 -0
- package/dist/core/types/activity.d.ts +80 -61
- package/dist/core/types/bulk.d.ts +50 -9
- package/dist/core/types/checkpoint.d.ts +44 -8
- package/dist/core/types/list-options.d.ts +146 -0
- package/dist/core/types/list-options.js +0 -0
- package/dist/core/types/options.d.ts +121 -165
- package/dist/core/types/schedules.d.ts +39 -3
- package/dist/core/types/services-resolution.d.ts +2 -2
- package/dist/core/types/workflow-builder-runtime.d.ts +12 -3
- package/dist/core/types/workflow-builder-runtime.js +11 -2
- package/dist/core/types/workflow-builder.d.ts +42 -11
- package/dist/core/types/workflow-concurrency.d.ts +39 -0
- package/dist/core/types/workflow-concurrency.js +0 -0
- package/dist/core/types/workflow-context.d.ts +157 -14
- package/dist/core/types/workflow-definition.d.ts +53 -10
- package/dist/core/types/workflow-function.d.ts +84 -9
- package/dist/core/types/workflow-log.d.ts +98 -0
- package/dist/core/types/workflow-log.js +0 -0
- package/dist/core/types/workflow-registries.d.ts +14 -3
- package/dist/core/types/workflow-registry.d.ts +3 -0
- package/dist/core/types.d.ts +4 -0
- package/dist/core/types.js +4 -0
- package/dist/core/versioning.d.ts +9 -39
- package/dist/core/versioning.js +2 -12
- package/dist/core/weft-error.d.ts +44 -1
- package/dist/core/weft-error.js +16 -0
- package/dist/core/worker-execution-strategy-options.d.ts +26 -0
- package/dist/core/worker-execution-strategy.js +40 -36
- package/dist/core/worker-inbound-message.d.ts +38 -0
- package/dist/core/worker-inbound-message.js +37 -0
- package/dist/core/worker-log-abuse-counter.d.ts +175 -0
- package/dist/core/worker-log-abuse-counter.js +107 -0
- package/dist/core/worker-message-helpers.d.ts +47 -0
- package/dist/core/worker-message-helpers.js +26 -0
- package/dist/core/worker-protocol-guard.js +1 -1
- package/dist/core/worker-protocol-log.d.ts +56 -0
- package/dist/core/worker-protocol-log.js +18 -0
- package/dist/core/worker-protocol.d.ts +23 -0
- package/dist/core/worker-protocol.js +12 -2
- package/dist/core/workflow-version-tuple.d.ts +3 -9
- package/dist/core/workflow-version-tuple.js +2 -3
- package/dist/diagnostics/format.js +1 -6
- package/dist/diagnostics/types.d.ts +4 -5
- package/dist/diagnostics/validate.d.ts +0 -1
- package/dist/diagnostics/version-check.d.ts +1 -1
- package/dist/diagnostics/version-check.js +4 -9
- package/dist/index.d.ts +12 -10
- package/dist/index.js +29 -3
- package/dist/json-schema.js +3 -3
- package/dist/mcp/cli.js +19 -19
- package/dist/mcp/dispatcher.js +1 -1
- package/dist/mcp/http.js +16 -6
- package/dist/mcp/protocol.d.ts +2 -0
- package/dist/mcp/protocol.js +1 -1
- package/dist/mcp/session.d.ts +16 -0
- package/dist/mcp/session.js +59 -6
- package/dist/mcp/tools.js +73 -6
- package/dist/observability/index.js +2 -2
- package/dist/server/asyncapi-channels.js +5 -2
- package/dist/server/attribute-filters.d.ts +8 -3
- package/dist/server/attribute-filters.js +6 -1
- package/dist/server/authentication/api-key.d.ts +2 -1
- package/dist/server/authentication/api-key.js +5 -2
- package/dist/server/authentication/constant-time-api-key.d.ts +15 -0
- package/dist/server/authentication/constant-time-api-key.js +24 -0
- package/dist/server/authentication/index.d.ts +1 -1
- package/dist/server/authentication/index.js +7 -4
- package/dist/server/authentication/rotating-api-key-store.d.ts +5 -3
- package/dist/server/authentication/rotating-api-key-store.js +19 -11
- package/dist/server/engine-event-feed-backend.d.ts +4 -5
- package/dist/server/fault-to-http.js +8 -1
- package/dist/server/fault-to-json-rpc.js +1 -0
- package/dist/server/fleet-event-feed.d.ts +31 -0
- package/dist/server/fleet-event-feed.js +157 -0
- package/dist/server/handler/index.js +1 -1
- package/dist/server/handler/response-helpers.js +2 -1
- package/dist/server/handler/route-dispatch.d.ts +6 -3
- package/dist/server/handler/route-dispatch.js +2 -2
- package/dist/server/handler.js +23 -23
- package/dist/server/index.d.ts +32 -2
- package/dist/server/index.js +32 -32
- package/dist/server/json-rpc-transport-helpers.d.ts +1 -0
- package/dist/server/json-rpc-transport-helpers.js +2 -1
- package/dist/server/json-rpc-websocket-runtime.d.ts +11 -2
- package/dist/server/json-rpc-websocket-runtime.js +1 -0
- package/dist/server/json-rpc-websocket-subscriptions.d.ts +10 -0
- package/dist/server/json-rpc-websocket-subscriptions.js +29 -0
- package/dist/server/json-rpc-websocket-types.d.ts +22 -0
- package/dist/server/json-rpc-websocket-types.js +0 -0
- package/dist/server/json-rpc-websocket-validation.js +20 -4
- package/dist/server/json-rpc-websocket.d.ts +2 -43
- package/dist/server/json-rpc-websocket.js +57 -74
- package/dist/server/openapi.d.ts +2 -1
- package/dist/server/openapi.js +1 -3
- package/dist/server/openrpc-document-schema.d.ts +78 -0
- package/dist/server/openrpc-document-schema.js +27 -1
- package/dist/server/openrpc-errors.d.ts +3 -0
- package/dist/server/openrpc-errors.js +2 -1
- package/dist/server/openrpc.js +32 -0
- package/dist/server/operation-catalog/index.d.ts +1 -1
- package/dist/server/operation-catalog/pipeline-helpers.js +1 -0
- package/dist/server/operation-catalog/pipeline-stages.js +26 -12
- package/dist/server/operation-catalog/pipeline.js +8 -1
- package/dist/server/operation-catalog/registry.js +13 -0
- package/dist/server/operation-catalog/types.d.ts +20 -9
- package/dist/server/operation-fault.d.ts +10 -0
- package/dist/server/operation-fault.js +2 -0
- package/dist/server/operation-registry.d.ts +12 -11
- package/dist/server/operation-registry.js +12 -3
- package/dist/server/operations/aggregate-workflows.d.ts +15 -15
- package/dist/server/operations/async-activity.d.ts +2 -2
- package/dist/server/operations/async-activity.js +12 -7
- package/dist/server/operations/bulk-cancel-workflows.d.ts +1 -1
- package/dist/server/operations/bulk-cancel-workflows.js +2 -2
- package/dist/server/operations/bulk-delete-workflows.d.ts +1 -1
- package/dist/server/operations/bulk-delete-workflows.js +2 -2
- package/dist/server/operations/bulk-filter-helpers.d.ts +8 -6
- package/dist/server/operations/bulk-filter-helpers.js +54 -24
- package/dist/server/operations/bulk-mutate-workflow-tags.d.ts +11 -9
- package/dist/server/operations/bulk-mutate-workflow-tags.js +2 -2
- package/dist/server/operations/bulk-operation-helpers.d.ts +2 -2
- package/dist/server/operations/bulk-retry-failed-workflows.d.ts +7 -0
- package/dist/server/operations/bulk-retry-failed-workflows.js +64 -0
- package/dist/server/operations/bulk-signal-workflows.d.ts +11 -9
- package/dist/server/operations/bulk-signal-workflows.js +2 -2
- package/dist/server/operations/cancel-schedule.d.ts +1 -1
- package/dist/server/operations/create-schedule.d.ts +3 -1
- package/dist/server/operations/create-schedule.js +29 -11
- package/dist/server/operations/fleet-events-subscription.d.ts +54 -0
- package/dist/server/operations/fleet-events-subscription.js +99 -0
- package/dist/server/operations/fork-workflow.d.ts +1 -1
- package/dist/server/operations/fork-workflow.js +3 -2
- package/dist/server/operations/get-checkpoint-at.d.ts +1 -1
- package/dist/server/operations/get-registry.d.ts +1 -1
- package/dist/server/operations/get-retention-overview.d.ts +1 -1
- package/dist/server/operations/get-review.d.ts +1 -1
- package/dist/server/operations/get-schedule.d.ts +1 -1
- package/dist/server/operations/get-stream-chunks.d.ts +1 -1
- package/dist/server/operations/get-system-metrics.d.ts +2 -2
- package/dist/server/operations/get-task-diagnostics.d.ts +45 -6
- package/dist/server/operations/get-task-diagnostics.js +101 -7
- package/dist/server/operations/get-update-result.d.ts +1 -1
- package/dist/server/operations/get-workflow-attributes.d.ts +1 -1
- package/dist/server/operations/get-workflow-events.d.ts +1 -1
- package/dist/server/operations/get-workflow-result.d.ts +1 -1
- package/dist/server/operations/get-workflow-timeline.d.ts +1 -1
- package/dist/server/operations/get-workflow.d.ts +1 -1
- package/dist/server/operations/list-checkpoints.d.ts +1 -1
- package/dist/server/operations/list-reviews.d.ts +1 -1
- package/dist/server/operations/list-schedules.d.ts +1 -1
- package/dist/server/operations/list-task-queues.d.ts +2 -2
- package/dist/server/operations/list-workers.d.ts +2 -2
- package/dist/server/operations/list-workflows.d.ts +1 -1
- package/dist/server/operations/operation-helpers.d.ts +16 -1
- package/dist/server/operations/operation-helpers.js +15 -3
- package/dist/server/operations/pause-schedule.d.ts +1 -1
- package/dist/server/operations/purge-workflows.d.ts +5 -5
- package/dist/server/operations/purge-workflows.js +2 -2
- package/dist/server/operations/query-workflow.d.ts +1 -1
- package/dist/server/operations/query-workflow.js +3 -2
- package/dist/server/operations/recover-all.d.ts +1 -1
- package/dist/server/operations/replay-workflow.d.ts +1 -1
- package/dist/server/operations/resume-schedule.d.ts +1 -1
- package/dist/server/operations/set-workflow-attributes.d.ts +1 -1
- package/dist/server/operations/set-workflow-attributes.js +6 -3
- package/dist/server/operations/signal-workflow.js +8 -3
- package/dist/server/operations/single-workflow-tag-mutation.js +13 -3
- package/dist/server/operations/start-or-signal-workflow.d.ts +6 -1
- package/dist/server/operations/start-or-signal-workflow.js +14 -24
- package/dist/server/operations/start-workflow-options.d.ts +6 -0
- package/dist/server/operations/start-workflow-rest-input.d.ts +14 -0
- package/dist/server/operations/start-workflow-rest-input.js +31 -0
- package/dist/server/operations/start-workflow.d.ts +1 -1
- package/dist/server/operations/start-workflow.js +8 -23
- package/dist/server/operations/storage.d.ts +6 -6
- package/dist/server/operations/storage.js +24 -14
- package/dist/server/operations/stream-workflow-sse.d.ts +1 -1
- package/dist/server/operations/submit-review-decision.d.ts +1 -1
- package/dist/server/operations/submit-review-decision.js +6 -3
- package/dist/server/operations/update-schedule.d.ts +1 -1
- package/dist/server/operations/update-schedule.js +7 -4
- package/dist/server/operations/update-workflow.d.ts +1 -1
- package/dist/server/operations/update-workflow.js +7 -3
- package/dist/server/operations/worker-drain.d.ts +8 -8
- package/dist/server/operations/worker-drain.js +11 -8
- package/dist/server/operations/workflow-events-subscription.d.ts +7 -8
- package/dist/server/operations/workflow-events-subscription.js +43 -8
- package/dist/server/rest-binding.d.ts +3 -1
- package/dist/server/rest-bindings.js +12 -0
- package/dist/server/rest-body.d.ts +10 -0
- package/dist/server/rest-body.js +80 -0
- package/dist/server/runtime/authentication-bridge.d.ts +1 -0
- package/dist/server/runtime/authentication-bridge.js +33 -6
- package/dist/server/runtime/client-visible-events.d.ts +3 -0
- package/dist/server/runtime/client-visible-events.js +65 -0
- package/dist/server/runtime/context.d.ts +7 -0
- package/dist/server/runtime/event-broadcasting.d.ts +6 -0
- package/dist/server/runtime/event-broadcasting.js +72 -38
- package/dist/server/runtime/retry.d.ts +1 -0
- package/dist/server/runtime/retry.js +14 -0
- package/dist/server/runtime/shutdown.d.ts +7 -6
- package/dist/server/runtime/shutdown.js +6 -1
- package/dist/server/runtime/task-polling.js +61 -20
- package/dist/server/runtime/task-reconciliation.js +9 -1
- package/dist/server/runtime/task-result-resolution.d.ts +15 -0
- package/dist/server/runtime/task-result-resolution.js +81 -0
- package/dist/server/runtime/websocket-stream.d.ts +20 -1
- package/dist/server/runtime/websocket-stream.js +173 -7
- package/dist/server/runtime/websocket-upgrade.js +22 -3
- package/dist/server/runtime/websocket-worker.d.ts +1 -1
- package/dist/server/runtime/websocket-worker.js +38 -30
- package/dist/server/serve-internals.d.ts +3 -1
- package/dist/server/serve-internals.js +18 -2
- package/dist/server/task-state.d.ts +30 -0
- package/dist/server/task-state.js +28 -0
- package/dist/server/workflow-event-feed.d.ts +36 -115
- package/dist/server/workflow-event-feed.js +92 -27
- package/dist/service-worker/index.js +30 -30
- package/dist/storage/auto.js +1 -1
- package/dist/storage/bun-sql.js +24 -0
- package/dist/storage/compressed-storage.js +1 -1
- package/dist/storage/default-scope.d.ts +7 -4
- package/dist/storage/http.js +2 -2
- package/dist/storage/index.d.ts +76 -4
- package/dist/storage/indexeddb.js +1 -1
- package/dist/storage/interface.d.ts +163 -0
- package/dist/storage/interface.js +1 -1
- package/dist/storage/key-prefixes.d.ts +1 -1
- package/dist/storage/key-prefixes.js +10 -0
- package/dist/storage/lmdb.d.ts +4 -3
- package/dist/storage/lmdb.js +1 -1
- package/dist/storage/memory.js +1 -1
- package/dist/storage/neon-batch.d.ts +30 -0
- package/dist/storage/neon-batch.js +30 -0
- package/dist/storage/neon-value-mapping.d.ts +30 -3
- package/dist/storage/neon-value-mapping.js +12 -0
- package/dist/storage/neon.d.ts +16 -0
- package/dist/storage/neon.js +9 -4
- package/dist/storage/node-sqlite.js +23 -0
- package/dist/storage/postgres-key-value-queries.d.ts +69 -44
- package/dist/storage/postgres-key-value-queries.js +62 -24
- package/dist/storage/resolve.js +1 -1
- package/dist/storage/scoped-storage.js +1 -1
- package/dist/storage/testing.d.ts +168 -0
- package/dist/storage/testing.js +2 -0
- package/dist/storage/turso.d.ts +8 -0
- package/dist/storage/turso.js +2 -2
- package/dist/storage/typed-storage.js +1 -1
- package/dist/storage/web-extension.js +1 -1
- package/dist/testing/index.js +20 -20
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worker/protocol.js +1 -1
- package/dist/workers/worker-replay-state.d.ts +32 -0
- package/dist/workers/worker-replay-state.js +35 -0
- package/dist/workers/worker-state-namespace.d.ts +21 -0
- package/dist/workers/worker-state-namespace.js +13 -0
- package/dist/workers/workflow-runner.d.ts +19 -15
- package/dist/workers/workflow-runner.js +72 -60
- package/dist/workers/workflow-worker-entry.js +5 -2
- package/package.json +5 -1
|
@@ -10,10 +10,10 @@ export declare const purgeWorkflowsOperation: import("../operation-catalog.ts").
|
|
|
10
10
|
attributes?: {
|
|
11
11
|
key: string;
|
|
12
12
|
value?: import("../../index.ts").SearchAttributeValue | undefined;
|
|
13
|
-
gt?: import("../../
|
|
14
|
-
lt?: import("../../
|
|
15
|
-
gte?: import("../../
|
|
16
|
-
lte?: import("../../
|
|
13
|
+
gt?: import("../../core/types.ts").AttributeFilterScalarValue | undefined;
|
|
14
|
+
lt?: import("../../core/types.ts").AttributeFilterScalarValue | undefined;
|
|
15
|
+
gte?: import("../../core/types.ts").AttributeFilterScalarValue | undefined;
|
|
16
|
+
lte?: import("../../core/types.ts").AttributeFilterScalarValue | undefined;
|
|
17
17
|
}[] | undefined;
|
|
18
18
|
limit?: number | undefined;
|
|
19
19
|
offset?: number | undefined;
|
|
@@ -37,5 +37,5 @@ export declare const purgeWorkflowsOperation: import("../operation-catalog.ts").
|
|
|
37
37
|
lte?: number | undefined;
|
|
38
38
|
lt?: number | undefined;
|
|
39
39
|
} | undefined;
|
|
40
|
-
}, PurgeResult>;
|
|
40
|
+
}, PurgeResult, unknown>;
|
|
41
41
|
export declare const purgeWorkflowsRestBinding: UnknownRestBinding;
|
|
@@ -43,8 +43,8 @@ export const purgeWorkflowsOperation = defineOperation({
|
|
|
43
43
|
pathParamNames: [],
|
|
44
44
|
operationName: "weft.workflows.purge",
|
|
45
45
|
inputSources: {},
|
|
46
|
-
extractInput: async (request) => {
|
|
47
|
-
const raw = await readOptionalJsonBody(request);
|
|
46
|
+
extractInput: async (request, _pathParams, context) => {
|
|
47
|
+
const raw = await readOptionalJsonBody(request, context);
|
|
48
48
|
try {
|
|
49
49
|
return { ...parseBulkListFilterFromBody(raw) };
|
|
50
50
|
} catch (error) {
|
|
@@ -13,7 +13,7 @@ export declare const queryWorkflowOperation: import("../operation-catalog.ts").O
|
|
|
13
13
|
workflowId: string;
|
|
14
14
|
queryName: string;
|
|
15
15
|
input?: unknown;
|
|
16
|
-
}, QueryWorkflowOutput>;
|
|
16
|
+
}, QueryWorkflowOutput, unknown>;
|
|
17
17
|
export declare const queryWorkflowRestBinding: UnknownRestBinding;
|
|
18
18
|
export declare const queryWorkflowWithInputRestBinding: UnknownRestBinding;
|
|
19
19
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { defineOperation } from "../operation-registry.js";
|
|
3
|
+
import { readRestTextBody } from "../rest-body.js";
|
|
3
4
|
import { invalidParamsFault, shapeRestFault } from "./operation-helpers.js";
|
|
4
5
|
const queryWorkflowInput = z.object({
|
|
5
6
|
workflowId: z.string().min(1),
|
|
@@ -71,8 +72,8 @@ export const queryWorkflowRestBinding = {
|
|
|
71
72
|
queryName: { kind: "path", pathParam: "name" },
|
|
72
73
|
input: { kind: "body-field", bodyField: "input" }
|
|
73
74
|
},
|
|
74
|
-
extractInput: async (request, pathParams) => {
|
|
75
|
-
const rawBody = await request
|
|
75
|
+
extractInput: async (request, pathParams, context) => {
|
|
76
|
+
const rawBody = await readRestTextBody(request, context);
|
|
76
77
|
if (rawBody.trim().length === 0)
|
|
77
78
|
return {
|
|
78
79
|
workflowId: pathParams.id ?? "",
|
|
@@ -8,6 +8,6 @@ export type RecoverAllInput = z.infer<typeof recoverAllInput>;
|
|
|
8
8
|
export type RecoverAllOutput = z.infer<typeof recoverAllOutput>;
|
|
9
9
|
export declare const recoverAllOperation: import("../operation-catalog.ts").OperationDefinition<Record<string, never>, {
|
|
10
10
|
recovered: string[];
|
|
11
|
-
}>;
|
|
11
|
+
}, unknown>;
|
|
12
12
|
export declare const recoverAllRestBinding: UnknownRestBinding;
|
|
13
13
|
export {};
|
|
@@ -23,6 +23,6 @@ export type ReplayWorkflowOutput = WorkflowReplay;
|
|
|
23
23
|
export declare const replayWorkflowOperation: import("../operation-catalog.ts").OperationDefinition<{
|
|
24
24
|
workflowId: string;
|
|
25
25
|
step: string | number;
|
|
26
|
-
}, WorkflowReplay>;
|
|
26
|
+
}, WorkflowReplay, unknown>;
|
|
27
27
|
export declare const replayWorkflowRestBinding: UnknownRestBinding;
|
|
28
28
|
export {};
|
|
@@ -8,6 +8,6 @@ export type ResumeScheduleInput = z.infer<typeof resumeScheduleInput>;
|
|
|
8
8
|
export type ResumeScheduleOutput = z.infer<typeof resumeScheduleOutput>;
|
|
9
9
|
export declare const resumeScheduleOperation: import("../operation-catalog.ts").OperationDefinition<{
|
|
10
10
|
scheduleId: string;
|
|
11
|
-
}, undefined>;
|
|
11
|
+
}, undefined, unknown>;
|
|
12
12
|
export declare const resumeScheduleRestBinding: UnknownRestBinding;
|
|
13
13
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { defineOperation } from "../operation-registry.js";
|
|
3
|
-
import {
|
|
3
|
+
import { readRestJsonBody } from "../rest-body.js";
|
|
4
|
+
import { isOperationFault, shapeRestFault } from "./operation-helpers.js";
|
|
4
5
|
const setWorkflowAttributesInput = z.object({
|
|
5
6
|
workflowId: z.string().min(1),
|
|
6
7
|
attributes: z.unknown().optional()
|
|
@@ -50,8 +51,10 @@ export const setWorkflowAttributesRestBinding = {
|
|
|
50
51
|
workflowId: { kind: "path", pathParam: "id" },
|
|
51
52
|
attributes: { kind: "body-field", bodyField: "attributes" }
|
|
52
53
|
},
|
|
53
|
-
extractInput: async (request, pathParams) => {
|
|
54
|
-
const body = await request
|
|
54
|
+
extractInput: async (request, pathParams, context) => {
|
|
55
|
+
const body = await readRestJsonBody(request, context).catch((error) => {
|
|
56
|
+
if (isOperationFault(error))
|
|
57
|
+
throw error;
|
|
55
58
|
throw Error("Invalid JSON body");
|
|
56
59
|
});
|
|
57
60
|
if (body === null)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { isSignalIdWithinByteLimit } from "../../core/signal-id.js";
|
|
3
|
-
import {
|
|
3
|
+
import { readRestJsonBody } from "../rest-body.js";
|
|
4
|
+
import { isOperationFault, shapeRestFault } from "./operation-helpers.js";
|
|
4
5
|
import {
|
|
5
6
|
createSingleWorkflowControlOperation,
|
|
6
7
|
extractWorkflowIdFromPath
|
|
@@ -43,8 +44,12 @@ export const signalWorkflowRestBinding = {
|
|
|
43
44
|
signalName: { kind: "path", pathParam: "name" },
|
|
44
45
|
payload: { kind: "body-field", bodyField: "payload" }
|
|
45
46
|
},
|
|
46
|
-
extractInput: async (request, pathParams) => {
|
|
47
|
-
const body = await request
|
|
47
|
+
extractInput: async (request, pathParams, context) => {
|
|
48
|
+
const body = await readRestJsonBody(request, context).catch((error) => {
|
|
49
|
+
if (isOperationFault(error))
|
|
50
|
+
throw error;
|
|
51
|
+
return null;
|
|
52
|
+
}), payload = typeof body === "object" && body !== null ? body.payload : void 0, signalId = typeof body === "object" && body !== null ? body.signalId : void 0;
|
|
48
53
|
return {
|
|
49
54
|
...extractWorkflowIdFromPath(pathParams),
|
|
50
55
|
signalName: pathParams.name ?? "",
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { WorkflowNotFoundError } from "../../core/engine/errors.js";
|
|
2
3
|
import {
|
|
3
4
|
coerceStartWorkflowTags,
|
|
4
5
|
StartWorkflowValidationError
|
|
5
6
|
} from "../../core/start-workflow-validation.js";
|
|
6
7
|
import { defineOperation } from "../operation-registry.js";
|
|
7
|
-
import {
|
|
8
|
+
import { readRestJsonBody } from "../rest-body.js";
|
|
9
|
+
import { isOperationFault, jsonErrorResponse, shapeRestFault } from "./operation-helpers.js";
|
|
8
10
|
const singleWorkflowTagMutationInput = z.object({
|
|
9
11
|
workflowId: z.string().min(1),
|
|
10
12
|
tags: z.unknown().optional()
|
|
@@ -50,8 +52,10 @@ export function createSingleWorkflowTagMutationRestBinding(configuration) {
|
|
|
50
52
|
workflowId: { kind: "path", pathParam: "id" },
|
|
51
53
|
tags: { kind: "body-field", bodyField: "tags" }
|
|
52
54
|
},
|
|
53
|
-
extractInput: async (request, pathParams) => {
|
|
54
|
-
const body = await request
|
|
55
|
+
extractInput: async (request, pathParams, context) => {
|
|
56
|
+
const body = await readRestJsonBody(request, context).catch((error) => {
|
|
57
|
+
if (isOperationFault(error))
|
|
58
|
+
throw error;
|
|
55
59
|
throw Error("Invalid JSON body");
|
|
56
60
|
});
|
|
57
61
|
if (!isJsonObject(body))
|
|
@@ -79,6 +83,12 @@ function shapeSingleWorkflowTagMutationFault(fault) {
|
|
|
79
83
|
}
|
|
80
84
|
function mapTagMutationErrorToFault(error, workflowId) {
|
|
81
85
|
const message = faultMessage(error);
|
|
86
|
+
if (error instanceof WorkflowNotFoundError)
|
|
87
|
+
return {
|
|
88
|
+
code: "NotFound",
|
|
89
|
+
message,
|
|
90
|
+
data: { resource: "workflow", identifier: workflowId, weftCode: error.code }
|
|
91
|
+
};
|
|
82
92
|
if (message.includes("not found"))
|
|
83
93
|
return {
|
|
84
94
|
code: "NotFound",
|
|
@@ -16,6 +16,10 @@ declare const startOrSignalWorkflowInput: z.ZodObject<{
|
|
|
16
16
|
}, z.core.$strip>;
|
|
17
17
|
declare const startOrSignalWorkflowOutput: z.ZodObject<{
|
|
18
18
|
id: z.ZodString;
|
|
19
|
+
outcome: z.ZodEnum<{
|
|
20
|
+
started: "started";
|
|
21
|
+
signalled: "signalled";
|
|
22
|
+
}>;
|
|
19
23
|
}, z.core.$strip>;
|
|
20
24
|
export type StartOrSignalWorkflowInput = z.infer<typeof startOrSignalWorkflowInput>;
|
|
21
25
|
export type StartOrSignalWorkflowOutput = z.infer<typeof startOrSignalWorkflowOutput>;
|
|
@@ -34,6 +38,7 @@ export declare const startOrSignalWorkflowOperation: import("../operation-catalo
|
|
|
34
38
|
searchAttributes?: unknown;
|
|
35
39
|
}, {
|
|
36
40
|
id: string;
|
|
37
|
-
|
|
41
|
+
outcome: "started" | "signalled";
|
|
42
|
+
}, unknown>;
|
|
38
43
|
export declare const startOrSignalWorkflowRestBinding: UnknownRestBinding;
|
|
39
44
|
export {};
|
|
@@ -10,6 +10,10 @@ import { StartWorkflowValidationError } from "../../core/start-workflow-validati
|
|
|
10
10
|
import { defineOperation } from "../operation-registry.js";
|
|
11
11
|
import { invalidParamsFault, shapeRestFault } from "./operation-helpers.js";
|
|
12
12
|
import { buildSharedStartWorkflowOptions } from "./start-workflow-options.js";
|
|
13
|
+
import {
|
|
14
|
+
extractSharedStartWorkflowRestFields,
|
|
15
|
+
parseStartWorkflowRequestRecord
|
|
16
|
+
} from "./start-workflow-rest-input.js";
|
|
13
17
|
const startOrSignalWorkflowInput = z.object({
|
|
14
18
|
type: z.unknown().describe("Workflow type name. Runtime validation requires a non-empty string."),
|
|
15
19
|
input: z.unknown().optional(),
|
|
@@ -24,7 +28,8 @@ const startOrSignalWorkflowInput = z.object({
|
|
|
24
28
|
idempotencyKey: z.unknown().optional(),
|
|
25
29
|
searchAttributes: z.unknown().optional()
|
|
26
30
|
}), startOrSignalWorkflowOutput = z.object({
|
|
27
|
-
id: z.string()
|
|
31
|
+
id: z.string(),
|
|
32
|
+
outcome: z.enum(["started", "signalled"])
|
|
28
33
|
});
|
|
29
34
|
function validateStartOrSignalWorkflowInput(input, lookupSearchAttributeSchema) {
|
|
30
35
|
if (typeof input.type !== "string" || input.type.length === 0)
|
|
@@ -53,12 +58,12 @@ function assertConvergenceTokenProvided(signalId, idempotencyKey) {
|
|
|
53
58
|
function resolveStartOrSignalWorkflowFault(error) {
|
|
54
59
|
const message = error instanceof Error ? error.message : String(error);
|
|
55
60
|
if (error instanceof WorkflowNotRegisteredError)
|
|
56
|
-
throw invalidParamsFault(message);
|
|
61
|
+
throw invalidParamsFault(message, error.code);
|
|
57
62
|
if (error instanceof StartOrSignalConflictError || error instanceof IdempotencyKeyPurgedError)
|
|
58
63
|
throw {
|
|
59
64
|
code: "Conflict",
|
|
60
65
|
message,
|
|
61
|
-
data: { reason: message }
|
|
66
|
+
data: { reason: message, weftCode: error.code }
|
|
62
67
|
};
|
|
63
68
|
if (error instanceof StartWorkflowValidationError)
|
|
64
69
|
throw invalidParamsFault(message);
|
|
@@ -86,7 +91,8 @@ export const startOrSignalWorkflowOperation = defineOperation({
|
|
|
86
91
|
return typedEngine.getWorkflowDefinition(validType)?.searchAttributes;
|
|
87
92
|
});
|
|
88
93
|
try {
|
|
89
|
-
|
|
94
|
+
const { handle, outcome } = await typedEngine.startOrSignal(type, input.input, signal, options);
|
|
95
|
+
return { id: handle.id, outcome };
|
|
90
96
|
} catch (error) {
|
|
91
97
|
resolveStartOrSignalWorkflowFault(error);
|
|
92
98
|
}
|
|
@@ -110,29 +116,13 @@ export const startOrSignalWorkflowOperation = defineOperation({
|
|
|
110
116
|
idempotencyKey: { kind: "body-field", bodyField: "idempotencyKey" },
|
|
111
117
|
searchAttributes: { kind: "body-field", bodyField: "searchAttributes" }
|
|
112
118
|
},
|
|
113
|
-
extractInput: async (request) => {
|
|
114
|
-
|
|
115
|
-
try {
|
|
116
|
-
body = await request.json();
|
|
117
|
-
} catch {
|
|
118
|
-
throw invalidParamsFault("Invalid JSON body");
|
|
119
|
-
}
|
|
120
|
-
if (typeof body !== "object" || body === null)
|
|
121
|
-
throw invalidParamsFault("Request body must be a JSON object");
|
|
122
|
-
const record = body;
|
|
119
|
+
extractInput: async (request, _pathParams, context) => {
|
|
120
|
+
const record = await parseStartWorkflowRequestRecord(request, context);
|
|
123
121
|
return {
|
|
124
|
-
|
|
125
|
-
input: record.input,
|
|
122
|
+
...extractSharedStartWorkflowRestFields(record),
|
|
126
123
|
signalName: record.signalName,
|
|
127
124
|
signalPayload: record.signalPayload,
|
|
128
|
-
signalId: record.signalId
|
|
129
|
-
id: record.id,
|
|
130
|
-
executionTimeout: record.executionTimeout,
|
|
131
|
-
startAt: record.startAt,
|
|
132
|
-
startAfter: record.startAfter,
|
|
133
|
-
tags: record.tags,
|
|
134
|
-
idempotencyKey: record.idempotencyKey,
|
|
135
|
-
searchAttributes: record.searchAttributes
|
|
125
|
+
signalId: record.signalId
|
|
136
126
|
};
|
|
137
127
|
},
|
|
138
128
|
success: { kind: "json", status: 201 },
|
|
@@ -20,6 +20,12 @@ export type SharedStartWorkflowOptionInput = {
|
|
|
20
20
|
* `executionTimeout`, `startAt`/`startAfter`, `tags`, `idempotencyKey`, and
|
|
21
21
|
* `searchAttributes` (a new field added here covers both surfaces at once). Throws
|
|
22
22
|
* {@link StartWorkflowValidationError} on any malformed field.
|
|
23
|
+
*
|
|
24
|
+
* `onTerminalConflict` is intentionally NOT part of this shared path: it is an
|
|
25
|
+
* in-process `engine.start`-only policy (its purge-and-restart would make the
|
|
26
|
+
* transport `weft.workflows.start` operation conditionally destructive and would
|
|
27
|
+
* violate `startOrSignal`'s at-most-once identity), so it is not exposed over
|
|
28
|
+
* REST/JSON-RPC. See follow-up issue #489.
|
|
23
29
|
*/
|
|
24
30
|
export declare function buildSharedStartWorkflowOptions(input: SharedStartWorkflowOptionInput, searchAttributeSchema: SearchAttributeSchema | undefined): StartOptions;
|
|
25
31
|
/**
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RestInputContext } from '../rest-binding.ts';
|
|
2
|
+
export type SharedStartWorkflowRestFields = {
|
|
3
|
+
readonly type: unknown;
|
|
4
|
+
readonly input: unknown;
|
|
5
|
+
readonly id: unknown;
|
|
6
|
+
readonly executionTimeout: unknown;
|
|
7
|
+
readonly startAt: unknown;
|
|
8
|
+
readonly startAfter: unknown;
|
|
9
|
+
readonly tags: unknown;
|
|
10
|
+
readonly idempotencyKey: unknown;
|
|
11
|
+
readonly searchAttributes: unknown;
|
|
12
|
+
};
|
|
13
|
+
export declare function parseStartWorkflowRequestRecord(request: Request, context?: RestInputContext): Promise<Record<string, unknown>>;
|
|
14
|
+
export declare function extractSharedStartWorkflowRestFields(record: Record<string, unknown>): SharedStartWorkflowRestFields;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { readRestJsonBody } from "../rest-body.js";
|
|
2
|
+
import { invalidParamsFault, isOperationFault } from "./operation-helpers.js";
|
|
3
|
+
function isJsonObjectLikeRecord(value) {
|
|
4
|
+
return typeof value === "object" && value !== null;
|
|
5
|
+
}
|
|
6
|
+
export async function parseStartWorkflowRequestRecord(request, context) {
|
|
7
|
+
let body;
|
|
8
|
+
try {
|
|
9
|
+
body = await readRestJsonBody(request, context);
|
|
10
|
+
} catch (error) {
|
|
11
|
+
if (isOperationFault(error))
|
|
12
|
+
throw error;
|
|
13
|
+
throw invalidParamsFault("Invalid JSON body");
|
|
14
|
+
}
|
|
15
|
+
if (body === null || typeof body !== "object")
|
|
16
|
+
throw invalidParamsFault("Request body must be a JSON object");
|
|
17
|
+
return isJsonObjectLikeRecord(body) ? body : {};
|
|
18
|
+
}
|
|
19
|
+
export function extractSharedStartWorkflowRestFields(record) {
|
|
20
|
+
return {
|
|
21
|
+
type: record.type,
|
|
22
|
+
input: record.input,
|
|
23
|
+
id: record.id,
|
|
24
|
+
executionTimeout: record.executionTimeout,
|
|
25
|
+
startAt: record.startAt,
|
|
26
|
+
startAfter: record.startAfter,
|
|
27
|
+
tags: record.tags,
|
|
28
|
+
idempotencyKey: record.idempotencyKey,
|
|
29
|
+
searchAttributes: record.searchAttributes
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -9,6 +9,10 @@ import { StartWorkflowValidationError } from "../../core/start-workflow-validati
|
|
|
9
9
|
import { defineOperation } from "../operation-registry.js";
|
|
10
10
|
import { invalidParamsFault, shapeRestFault } from "./operation-helpers.js";
|
|
11
11
|
import { buildSharedStartWorkflowOptions } from "./start-workflow-options.js";
|
|
12
|
+
import {
|
|
13
|
+
extractSharedStartWorkflowRestFields,
|
|
14
|
+
parseStartWorkflowRequestRecord
|
|
15
|
+
} from "./start-workflow-rest-input.js";
|
|
12
16
|
const startWorkflowInput = z.object({
|
|
13
17
|
type: z.unknown().describe("Workflow type name. Runtime validation requires a non-empty string."),
|
|
14
18
|
input: z.unknown().optional(),
|
|
@@ -38,12 +42,12 @@ function validateStartWorkflowInput(input, lookupSearchAttributeSchema) {
|
|
|
38
42
|
function resolveStartWorkflowAccess(error) {
|
|
39
43
|
const message = error instanceof Error ? error.message : String(error);
|
|
40
44
|
if (error instanceof WorkflowNotRegisteredError)
|
|
41
|
-
throw invalidParamsFault(message);
|
|
45
|
+
throw invalidParamsFault(message, error.code);
|
|
42
46
|
if (error instanceof WorkflowAlreadyExistsError || error instanceof IdempotencyKeyPurgedError)
|
|
43
47
|
throw {
|
|
44
48
|
code: "Conflict",
|
|
45
49
|
message,
|
|
46
|
-
data: { reason: message }
|
|
50
|
+
data: { reason: message, weftCode: error.code }
|
|
47
51
|
};
|
|
48
52
|
if (error instanceof StartWorkflowValidationError)
|
|
49
53
|
throw invalidParamsFault(message);
|
|
@@ -92,27 +96,8 @@ export const startWorkflowOperation = defineOperation({
|
|
|
92
96
|
idempotencyKey: { kind: "body-field", bodyField: "idempotencyKey" },
|
|
93
97
|
searchAttributes: { kind: "body-field", bodyField: "searchAttributes" }
|
|
94
98
|
},
|
|
95
|
-
extractInput: async (request) => {
|
|
96
|
-
|
|
97
|
-
try {
|
|
98
|
-
body = await request.json();
|
|
99
|
-
} catch {
|
|
100
|
-
throw invalidParamsFault("Invalid JSON body");
|
|
101
|
-
}
|
|
102
|
-
if (typeof body !== "object" || body === null)
|
|
103
|
-
throw invalidParamsFault("Request body must be a JSON object");
|
|
104
|
-
const record = body;
|
|
105
|
-
return {
|
|
106
|
-
type: record.type,
|
|
107
|
-
input: record.input,
|
|
108
|
-
id: record.id,
|
|
109
|
-
executionTimeout: record.executionTimeout,
|
|
110
|
-
startAt: record.startAt,
|
|
111
|
-
startAfter: record.startAfter,
|
|
112
|
-
tags: record.tags,
|
|
113
|
-
idempotencyKey: record.idempotencyKey,
|
|
114
|
-
searchAttributes: record.searchAttributes
|
|
115
|
-
};
|
|
99
|
+
extractInput: async (request, _pathParams, context) => {
|
|
100
|
+
return extractSharedStartWorkflowRestFields(await parseStartWorkflowRequestRecord(request, context));
|
|
116
101
|
},
|
|
117
102
|
success: { kind: "json", status: 201 },
|
|
118
103
|
shapeFault: shapeRestFault
|
|
@@ -60,14 +60,14 @@ export type StorageConditionalBatchInput = z.infer<typeof storageConditionalBatc
|
|
|
60
60
|
export type StorageConditionalBatchOutput = z.infer<typeof storageConditionalBatchOutput>;
|
|
61
61
|
export declare const storageGetOperation: import("../operation-catalog.ts").OperationDefinition<{
|
|
62
62
|
key: string;
|
|
63
|
-
}, Uint8Array<ArrayBufferLike> | null>;
|
|
63
|
+
}, Uint8Array<ArrayBufferLike> | null, unknown>;
|
|
64
64
|
export declare const storagePutOperation: import("../operation-catalog.ts").OperationDefinition<{
|
|
65
65
|
key: string;
|
|
66
66
|
value: Uint8Array<ArrayBuffer>;
|
|
67
|
-
}, null>;
|
|
67
|
+
}, null, unknown>;
|
|
68
68
|
export declare const storageDeleteOperation: import("../operation-catalog.ts").OperationDefinition<{
|
|
69
69
|
key: string;
|
|
70
|
-
}, null>;
|
|
70
|
+
}, null, unknown>;
|
|
71
71
|
export declare const storageScanOperation: import("../operation-catalog.ts").OperationDefinition<{
|
|
72
72
|
prefix: string;
|
|
73
73
|
limit?: number | undefined;
|
|
@@ -76,7 +76,7 @@ export declare const storageScanOperation: import("../operation-catalog.ts").Ope
|
|
|
76
76
|
gte?: string | undefined;
|
|
77
77
|
lt?: string | undefined;
|
|
78
78
|
lte?: string | undefined;
|
|
79
|
-
}, StorageScanOutput>;
|
|
79
|
+
}, StorageScanOutput, unknown>;
|
|
80
80
|
export declare const storageBatchOperation: import("../operation-catalog.ts").OperationDefinition<{
|
|
81
81
|
operations: ({
|
|
82
82
|
type: "put";
|
|
@@ -86,7 +86,7 @@ export declare const storageBatchOperation: import("../operation-catalog.ts").Op
|
|
|
86
86
|
type: "delete";
|
|
87
87
|
key: string;
|
|
88
88
|
})[];
|
|
89
|
-
}, null>;
|
|
89
|
+
}, null, unknown>;
|
|
90
90
|
export declare const storageConditionalBatchOperation: import("../operation-catalog.ts").OperationDefinition<{
|
|
91
91
|
conditions: {
|
|
92
92
|
key: string;
|
|
@@ -102,7 +102,7 @@ export declare const storageConditionalBatchOperation: import("../operation-cata
|
|
|
102
102
|
})[];
|
|
103
103
|
}, {
|
|
104
104
|
applied: boolean;
|
|
105
|
-
}>;
|
|
105
|
+
}, unknown>;
|
|
106
106
|
export declare const storageGetRestBinding: UnknownRestBinding;
|
|
107
107
|
export declare const storagePutRestBinding: UnknownRestBinding;
|
|
108
108
|
export declare const storageDeleteRestBinding: UnknownRestBinding;
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { copyBytesToArrayBuffer } from "../../core/byte-arrays.js";
|
|
2
3
|
import { decodeBase64ToBytes, encodeBytesToBase64 } from "../../storage/byte-encoding.js";
|
|
3
4
|
import {
|
|
5
|
+
MAX_BATCH_OPERATIONS,
|
|
6
|
+
MAX_SCAN_LIMIT,
|
|
7
|
+
storageBatch,
|
|
4
8
|
storageConditionalBatch
|
|
5
9
|
} from "../../storage/interface.js";
|
|
6
10
|
import { raiseFault } from "../operation-catalog.js";
|
|
7
11
|
import { defineOperation } from "../operation-registry.js";
|
|
8
12
|
import { isAuthenticated } from "../principal.js";
|
|
9
|
-
import {
|
|
13
|
+
import { readRestBodyBounded, readRestJsonBody } from "../rest-body.js";
|
|
14
|
+
import { invalidParamsFault, isOperationFault, shapeRestFault } from "./operation-helpers.js";
|
|
10
15
|
const storageReadAccess = {
|
|
11
16
|
kind: "scoped",
|
|
12
17
|
scopes: { kind: "anyOf", scopes: ["storage:read", "storage:admin"] }
|
|
@@ -26,7 +31,7 @@ const storageReadAccess = {
|
|
|
26
31
|
jsonRpcWebSocket: !1
|
|
27
32
|
}, binaryValueSchema = z.instanceof(Uint8Array).meta({ type: "string", format: "binary" }), storageGetInput = z.object({ key: z.string().min(1) }), storagePutInput = z.object({ key: z.string().min(1), value: binaryValueSchema }), storageDeleteInput = z.object({ key: z.string().min(1) }), storageScanInput = z.object({
|
|
28
33
|
prefix: z.string(),
|
|
29
|
-
limit: z.number().int().positive().optional(),
|
|
34
|
+
limit: z.number().int().positive().max(MAX_SCAN_LIMIT).optional(),
|
|
30
35
|
reverse: z.boolean().optional(),
|
|
31
36
|
gt: z.string().optional(),
|
|
32
37
|
gte: z.string().optional(),
|
|
@@ -38,9 +43,11 @@ const storageReadAccess = {
|
|
|
38
43
|
]), storageConditionInput = z.object({
|
|
39
44
|
key: z.string().min(1),
|
|
40
45
|
expectedValue: z.string().nullable()
|
|
41
|
-
}), storageBatchInput = z.object({
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
}), storageBatchInput = z.object({
|
|
47
|
+
operations: z.array(storageBatchOperationInput).max(MAX_BATCH_OPERATIONS)
|
|
48
|
+
}), storageConditionalBatchInput = z.object({
|
|
49
|
+
conditions: z.array(storageConditionInput).max(MAX_BATCH_OPERATIONS),
|
|
50
|
+
operations: z.array(storageBatchOperationInput).max(MAX_BATCH_OPERATIONS)
|
|
44
51
|
}), emptyOutput = z.null(), storageGetOutput = binaryValueSchema.nullable(), storageScanOutput = z.custom((value) => typeof value === "object" && value !== null && (Symbol.asyncIterator in value) && typeof value[Symbol.asyncIterator] === "function", "Storage scan output must be an async iterable."), storageConditionalBatchOutput = z.object({ applied: z.boolean() });
|
|
45
52
|
function resolveAuthorizedStorage(engine, principal, operation) {
|
|
46
53
|
if (!isAuthenticated(principal))
|
|
@@ -89,10 +96,12 @@ function decodeCondition(condition) {
|
|
|
89
96
|
expectedValue: condition.expectedValue === null ? null : decodeStorageBytes(condition.expectedValue, "Storage conditional batch expectedValue must be base64.")
|
|
90
97
|
};
|
|
91
98
|
}
|
|
92
|
-
async function readJsonRequestBody(request) {
|
|
99
|
+
async function readJsonRequestBody(request, context) {
|
|
93
100
|
try {
|
|
94
|
-
return await request
|
|
95
|
-
} catch {
|
|
101
|
+
return await readRestJsonBody(request, context);
|
|
102
|
+
} catch (error) {
|
|
103
|
+
if (isOperationFault(error))
|
|
104
|
+
throw error;
|
|
96
105
|
throw invalidParamsFault("Request body must be valid JSON.");
|
|
97
106
|
}
|
|
98
107
|
}
|
|
@@ -137,7 +146,7 @@ function createNoContentResponse() {
|
|
|
137
146
|
function createBinaryResponse(value) {
|
|
138
147
|
if (value === null)
|
|
139
148
|
return new Response(null, { status: 404 });
|
|
140
|
-
return new Response(value, {
|
|
149
|
+
return new Response(copyBytesToArrayBuffer(value), {
|
|
141
150
|
status: 200,
|
|
142
151
|
headers: { "Content-Type": "application/octet-stream" }
|
|
143
152
|
});
|
|
@@ -246,7 +255,8 @@ export const storageGetOperation = defineOperation({
|
|
|
246
255
|
transports: httpOnlyStorageTransports,
|
|
247
256
|
unknownKeyPolicy: { http: "strip", jsonRpc: "reject" },
|
|
248
257
|
invoke: async ({ input, engine, principal }) => {
|
|
249
|
-
|
|
258
|
+
const storage = resolveAuthorizedStorage(engine, principal, storageBatchOperation);
|
|
259
|
+
await storageBatch(storage, input.operations.map(decodeBatchOperation));
|
|
250
260
|
return null;
|
|
251
261
|
}
|
|
252
262
|
}), storageConditionalBatchOperation = defineOperation({
|
|
@@ -293,9 +303,9 @@ export const storageGetOperation = defineOperation({
|
|
|
293
303
|
key: { kind: "path", pathParam: "key" },
|
|
294
304
|
value: { kind: "body", mediaType: "application/octet-stream" }
|
|
295
305
|
},
|
|
296
|
-
extractInput: async (request, pathParams) => ({
|
|
306
|
+
extractInput: async (request, pathParams, context) => ({
|
|
297
307
|
key: storageKeyFromPath(pathParams),
|
|
298
|
-
value:
|
|
308
|
+
value: await readRestBodyBounded(request, context)
|
|
299
309
|
}),
|
|
300
310
|
success: { kind: "empty", status: 204 },
|
|
301
311
|
shapeSuccess: createNoContentResponse,
|
|
@@ -338,7 +348,7 @@ export const storageGetOperation = defineOperation({
|
|
|
338
348
|
inputSources: {
|
|
339
349
|
operations: { kind: "body-field", bodyField: "operations" }
|
|
340
350
|
},
|
|
341
|
-
extractInput: async (request) => readJsonRequestBody(request),
|
|
351
|
+
extractInput: async (request, _pathParams, context) => readJsonRequestBody(request, context),
|
|
342
352
|
success: { kind: "empty", status: 204 },
|
|
343
353
|
shapeSuccess: createNoContentResponse,
|
|
344
354
|
shapeFault: shapeRestFault
|
|
@@ -351,7 +361,7 @@ export const storageGetOperation = defineOperation({
|
|
|
351
361
|
conditions: { kind: "body-field", bodyField: "conditions" },
|
|
352
362
|
operations: { kind: "body-field", bodyField: "operations" }
|
|
353
363
|
},
|
|
354
|
-
extractInput: async (request) => readJsonRequestBody(request),
|
|
364
|
+
extractInput: async (request, _pathParams, context) => readJsonRequestBody(request, context),
|
|
355
365
|
success: { kind: "json", status: 200 },
|
|
356
366
|
shapeSuccess: (output) => Response.json(output),
|
|
357
367
|
shapeFault: shapeRestFault
|
|
@@ -12,6 +12,6 @@ export type StreamWorkflowSseOutput = {
|
|
|
12
12
|
export declare const streamWorkflowSseOperation: import("../operation-catalog.ts").OperationDefinition<{
|
|
13
13
|
workflowId: string;
|
|
14
14
|
after?: unknown;
|
|
15
|
-
}, StreamWorkflowSseOutput>;
|
|
15
|
+
}, StreamWorkflowSseOutput, unknown>;
|
|
16
16
|
export declare const streamWorkflowSseRestBinding: UnknownRestBinding;
|
|
17
17
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { defineOperation } from "../operation-registry.js";
|
|
3
|
-
import {
|
|
3
|
+
import { readRestJsonBody } from "../rest-body.js";
|
|
4
|
+
import { isOperationFault, shapeRestFault } from "./operation-helpers.js";
|
|
4
5
|
const VALID_DECISIONS = [
|
|
5
6
|
"approved",
|
|
6
7
|
"rejected",
|
|
@@ -95,8 +96,10 @@ export const submitReviewDecisionRestBinding = {
|
|
|
95
96
|
feedback: { kind: "body-field", bodyField: "feedback" },
|
|
96
97
|
workflowId: { kind: "body-field", bodyField: "workflowId" }
|
|
97
98
|
},
|
|
98
|
-
extractInput: async (request, pathParams) => {
|
|
99
|
-
const body = await request
|
|
99
|
+
extractInput: async (request, pathParams, context) => {
|
|
100
|
+
const body = await readRestJsonBody(request, context).catch((error) => {
|
|
101
|
+
if (isOperationFault(error))
|
|
102
|
+
throw error;
|
|
100
103
|
throw Error("Invalid JSON body");
|
|
101
104
|
}), record = typeof body === "object" && body !== null && !Array.isArray(body) ? body : {};
|
|
102
105
|
return {
|
|
@@ -10,6 +10,6 @@ export declare const updateScheduleOperation: import("../operation-catalog.ts").
|
|
|
10
10
|
scheduleId: string;
|
|
11
11
|
cronExpression?: unknown;
|
|
12
12
|
every?: unknown;
|
|
13
|
-
}, null>;
|
|
13
|
+
}, null, unknown>;
|
|
14
14
|
export declare const updateScheduleRestBinding: UnknownRestBinding;
|
|
15
15
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { defineOperation } from "../operation-registry.js";
|
|
3
|
-
import {
|
|
3
|
+
import { readRestJsonBody } from "../rest-body.js";
|
|
4
|
+
import { invalidParamsFault, isOperationFault, shapeRestFault } from "./operation-helpers.js";
|
|
4
5
|
import { mapScheduleErrorToFault, validateScheduleInputCadence } from "./schedule-faults.js";
|
|
5
6
|
const updateScheduleInput = z.object({
|
|
6
7
|
scheduleId: z.string().min(1),
|
|
@@ -39,11 +40,13 @@ export const updateScheduleOperation = defineOperation({
|
|
|
39
40
|
cronExpression: { kind: "body-field", bodyField: "cronExpression" },
|
|
40
41
|
every: { kind: "body-field", bodyField: "every" }
|
|
41
42
|
},
|
|
42
|
-
extractInput: async (request, pathParams) => {
|
|
43
|
+
extractInput: async (request, pathParams, context) => {
|
|
43
44
|
let body;
|
|
44
45
|
try {
|
|
45
|
-
body = await request
|
|
46
|
-
} catch {
|
|
46
|
+
body = await readRestJsonBody(request, context);
|
|
47
|
+
} catch (error) {
|
|
48
|
+
if (isOperationFault(error))
|
|
49
|
+
throw error;
|
|
47
50
|
throw invalidParamsFault("Invalid JSON body");
|
|
48
51
|
}
|
|
49
52
|
if (typeof body !== "object" || body === null)
|