bunqueue-client 0.1.9 → 0.2.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/CHANGELOG.md +165 -0
- package/LEGACY.md +460 -0
- package/README.md +204 -349
- package/dist/ack-batcher.js +7 -67
- package/dist/canonical-manifest.json +934 -0
- package/dist/chunk-b967v3w3.js +79 -0
- package/dist/chunk-fekm0ma6.js +110 -0
- package/dist/chunk-jxkszwqp.js +573 -0
- package/dist/embedded.js +16510 -0
- package/dist/frame.js +14 -57
- package/dist/index.d.ts +1 -27
- package/dist/index.js +10953 -16
- package/dist/legacy.d.ts +1 -0
- package/dist/legacy.js +2081 -0
- package/dist/{ack-batcher.d.ts → types/sdk/typescript/src/ack-batcher.d.ts} +3 -3
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/aging.d.ts +2 -2
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/batch.d.ts +2 -2
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/bunqueue-api.d.ts +5 -5
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/bunqueue.d.ts +13 -13
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/circuit-breaker.d.ts +2 -2
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/dedup-debounce.d.ts +2 -2
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/dlq-rate-limit.d.ts +2 -2
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/rate-gate.d.ts +1 -1
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/retry.d.ts +1 -1
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/triggers.d.ts +3 -3
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/ttl.d.ts +1 -1
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/types.d.ts +4 -4
- package/dist/types/sdk/typescript/src/canonical-transport/bun-sqlite-types.d.ts +21 -0
- package/dist/{connection-pool.d.ts → types/sdk/typescript/src/connection-pool.d.ts} +1 -1
- package/dist/{connection-types.d.ts → types/sdk/typescript/src/connection-types.d.ts} +1 -1
- package/dist/{connection.d.ts → types/sdk/typescript/src/connection.d.ts} +6 -19
- package/dist/{errors.d.ts → types/sdk/typescript/src/errors.d.ts} +3 -0
- package/dist/types/sdk/typescript/src/flow-commit.d.ts +5 -0
- package/dist/types/sdk/typescript/src/flow-plan-legacy.d.ts +13 -0
- package/dist/types/sdk/typescript/src/flow-plan.d.ts +29 -0
- package/dist/{flow-types.d.ts → types/sdk/typescript/src/flow-types.d.ts} +7 -4
- package/dist/{flow.d.ts → types/sdk/typescript/src/flow.d.ts} +6 -10
- package/dist/{frame.d.ts → types/sdk/typescript/src/frame.d.ts} +1 -1
- package/dist/types/sdk/typescript/src/index.d.ts +10 -0
- package/dist/{job.d.ts → types/sdk/typescript/src/job.d.ts} +4 -3
- package/dist/types/sdk/typescript/src/legacy.d.ts +27 -0
- package/dist/{observability.d.ts → types/sdk/typescript/src/observability.d.ts} +14 -0
- package/dist/{queue-admin.d.ts → types/sdk/typescript/src/queue-admin.d.ts} +3 -4
- package/dist/{queue-control.d.ts → types/sdk/typescript/src/queue-control.d.ts} +5 -5
- package/dist/{queue-query.d.ts → types/sdk/typescript/src/queue-query.d.ts} +3 -3
- package/dist/{queue.d.ts → types/sdk/typescript/src/queue.d.ts} +8 -8
- package/dist/{responses.d.ts → types/sdk/typescript/src/responses.d.ts} +2 -2
- package/dist/types/sdk/typescript/src/serialization.d.ts +10 -0
- package/dist/{socket-factory.d.ts → types/sdk/typescript/src/socket-factory.d.ts} +1 -1
- package/dist/types/sdk/typescript/src/terminal-outcome.d.ts +8 -0
- package/dist/{types.d.ts → types/sdk/typescript/src/types.d.ts} +5 -2
- package/dist/{worker-base.d.ts → types/sdk/typescript/src/worker-base.d.ts} +6 -6
- package/dist/types/sdk/typescript/src/worker-slot-signal.d.ts +6 -0
- package/dist/{worker-types.d.ts → types/sdk/typescript/src/worker-types.d.ts} +3 -3
- package/dist/{worker.d.ts → types/sdk/typescript/src/worker.d.ts} +3 -2
- package/dist/types/src/application/background/dlq.d.ts +2 -0
- package/dist/types/src/application/background/lifecycle.d.ts +4 -0
- package/dist/types/src/application/background/recovery/active.d.ts +5 -0
- package/dist/types/src/application/background/recovery/index.d.ts +2 -0
- package/dist/types/src/application/background/recovery/pending.d.ts +3 -0
- package/dist/types/src/application/background/recovery/restore.d.ts +5 -0
- package/dist/types/src/application/background/recovery/shared.d.ts +6 -0
- package/dist/types/src/application/background/timeouts.d.ts +25 -0
- package/dist/types/src/application/backgroundTasks.d.ts +7 -0
- package/dist/types/src/application/cleanupTasks.d.ts +10 -0
- package/dist/types/src/application/clientOwnership.d.ts +65 -0
- package/dist/types/src/application/clientTracking.d.ts +40 -0
- package/dist/types/src/application/completedCleanup.d.ts +34 -0
- package/dist/types/src/application/completedRetry.d.ts +21 -0
- package/dist/types/src/application/contextFactory.d.ts +49 -0
- package/dist/types/src/application/dependencyCompletions.d.ts +63 -0
- package/dist/types/src/application/dependencyProcessor.d.ts +15 -0
- package/dist/types/src/application/dependencyResultTracker.d.ts +18 -0
- package/dist/types/src/application/dlqManager.d.ts +49 -0
- package/dist/types/src/application/dlqRetry.d.ts +12 -0
- package/dist/types/src/application/emptyQueueCleanup.d.ts +3 -0
- package/dist/types/src/application/eventsManager.d.ts +50 -0
- package/dist/types/src/application/flowFailureRecovery.d.ts +20 -0
- package/dist/types/src/application/flowParentBackpatch.d.ts +27 -0
- package/dist/types/src/application/jobLogsManager.d.ts +21 -0
- package/dist/types/src/application/latencyTracker.d.ts +39 -0
- package/dist/types/src/application/lockManager.d.ts +15 -0
- package/dist/types/src/application/lockOperations.d.ts +38 -0
- package/dist/types/src/application/metricsExporter.d.ts +27 -0
- package/dist/types/src/application/monitoringChecks.d.ts +36 -0
- package/dist/types/src/application/operations/ack/batch.d.ts +8 -0
- package/dist/types/src/application/operations/ack/completion.d.ts +3 -0
- package/dist/types/src/application/operations/ack/failure.d.ts +3 -0
- package/dist/types/src/application/operations/ack.d.ts +5 -0
- package/dist/types/src/application/operations/ackHelpers.d.ts +36 -0
- package/dist/types/src/application/operations/customId.d.ts +51 -0
- package/dist/types/src/application/operations/flowPush.d.ts +9 -0
- package/dist/types/src/application/operations/flowTopologyValidation.d.ts +3 -0
- package/dist/types/src/application/operations/flowValidation.d.ts +3 -0
- package/dist/types/src/application/operations/jobClaim.d.ts +17 -0
- package/dist/types/src/application/operations/jobManagement.d.ts +45 -0
- package/dist/types/src/application/operations/jobMoveOperations.d.ts +9 -0
- package/dist/types/src/application/operations/jobPromotion.d.ts +7 -0
- package/dist/types/src/application/operations/jobStateTransitions.d.ts +15 -0
- package/dist/types/src/application/operations/parentLink.d.ts +36 -0
- package/dist/types/src/application/operations/parentLinkInput.d.ts +8 -0
- package/dist/types/src/application/operations/pull.d.ts +20 -0
- package/dist/types/src/application/operations/pullFinalization.d.ts +6 -0
- package/dist/types/src/application/operations/pullStateTransition.d.ts +51 -0
- package/dist/types/src/application/operations/push.d.ts +13 -0
- package/dist/types/src/application/operations/pushAdmission.d.ts +36 -0
- package/dist/types/src/application/operations/pushBatch.d.ts +4 -0
- package/dist/types/src/application/operations/pushContext.d.ts +48 -0
- package/dist/types/src/application/operations/pushDeduplication.d.ts +42 -0
- package/dist/types/src/application/operations/pushInsert.d.ts +39 -0
- package/dist/types/src/application/operations/pushLocks.d.ts +15 -0
- package/dist/types/src/application/operations/query/collect.d.ts +12 -0
- package/dist/types/src/application/operations/query/jobLookup.d.ts +9 -0
- package/dist/types/src/application/operations/query/pagination.d.ts +8 -0
- package/dist/types/src/application/operations/query/state.d.ts +4 -0
- package/dist/types/src/application/operations/queryOperations.d.ts +5 -0
- package/dist/types/src/application/operations/queueControl.d.ts +50 -0
- package/dist/types/src/application/orphanRecovery.d.ts +25 -0
- package/dist/types/src/application/prometheusOperationalMetrics.d.ts +31 -0
- package/dist/types/src/application/queue-manager/ack.d.ts +23 -0
- package/dist/types/src/application/queue-manager/configuration.d.ts +27 -0
- package/dist/types/src/application/queue-manager/context.d.ts +5 -0
- package/dist/types/src/application/queue-manager/control.d.ts +20 -0
- package/dist/types/src/application/queue-manager/delivery.d.ts +33 -0
- package/dist/types/src/application/queue-manager/dependencies.d.ts +8 -0
- package/dist/types/src/application/queue-manager/dependency-runtime.d.ts +8 -0
- package/dist/types/src/application/queue-manager/flow-failures.d.ts +18 -0
- package/dist/types/src/application/queue-manager/flow-options.d.ts +8 -0
- package/dist/types/src/application/queue-manager/job-management.d.ts +17 -0
- package/dist/types/src/application/queue-manager/lifecycle.d.ts +4 -0
- package/dist/types/src/application/queue-manager/limits.d.ts +58 -0
- package/dist/types/src/application/queue-manager/locks.d.ts +21 -0
- package/dist/types/src/application/queue-manager/observability.d.ts +16 -0
- package/dist/types/src/application/queue-manager/queries.d.ts +24 -0
- package/dist/types/src/application/queue-manager/repeat.d.ts +4 -0
- package/dist/types/src/application/queue-manager/services.d.ts +19 -0
- package/dist/types/src/application/queue-manager/state.d.ts +98 -0
- package/dist/types/src/application/queue-manager/stats.d.ts +28 -0
- package/dist/types/src/application/queueManager.d.ts +5 -0
- package/dist/types/src/application/queueStatsAggregator.d.ts +23 -0
- package/dist/types/src/application/queueTelemetryJournal.d.ts +24 -0
- package/dist/types/src/application/repeatJobs.d.ts +7 -0
- package/dist/types/src/application/stallDetection.d.ts +26 -0
- package/dist/types/src/application/statsManager.d.ts +59 -0
- package/dist/types/src/application/taskErrorTracking.d.ts +22 -0
- package/dist/types/src/application/throughputTracker.d.ts +34 -0
- package/dist/types/src/application/types/ack.d.ts +136 -0
- package/dist/types/src/application/types/background.d.ts +18 -0
- package/dist/types/src/application/types/config.d.ts +41 -0
- package/dist/types/src/application/types/contextFactory.d.ts +89 -0
- package/dist/types/src/application/types/contexts.d.ts +117 -0
- package/dist/types/src/application/types/index.d.ts +7 -0
- package/dist/types/src/application/types/query.d.ts +23 -0
- package/dist/types/src/application/types/queueManager.d.ts +100 -0
- package/dist/types/src/application/webhookManager.d.ts +47 -0
- package/dist/types/src/application/workerManager.d.ts +61 -0
- package/dist/types/src/client/bunqueue/aging.d.ts +16 -0
- package/dist/types/src/client/bunqueue/batch.d.ts +16 -0
- package/dist/types/src/client/bunqueue/cancellation.d.ts +21 -0
- package/dist/types/src/client/bunqueue/circuitBreaker.d.ts +21 -0
- package/dist/types/src/client/bunqueue/dedupDebounce.d.ts +12 -0
- package/dist/types/src/client/bunqueue/dlqRateLimit.d.ts +26 -0
- package/dist/types/src/client/bunqueue/retry.d.ts +8 -0
- package/dist/types/src/client/bunqueue/runtime.d.ts +35 -0
- package/dist/types/src/client/bunqueue/triggers.d.ts +17 -0
- package/dist/types/src/client/bunqueue/ttl.d.ts +17 -0
- package/dist/types/src/client/bunqueue/types.d.ts +147 -0
- package/dist/types/src/client/bunqueue.d.ts +73 -0
- package/dist/types/src/client/dlqConversion.d.ts +5 -0
- package/dist/types/src/client/errors.d.ts +24 -0
- package/dist/types/src/client/events.d.ts +85 -0
- package/dist/types/src/client/flow.d.ts +70 -0
- package/dist/types/src/client/flowAtomic.d.ts +9 -0
- package/dist/types/src/client/flowJobCoreMethods.d.ts +28 -0
- package/dist/types/src/client/flowJobDependencies.d.ts +7 -0
- package/dist/types/src/client/flowJobFactory.d.ts +24 -0
- package/dist/types/src/client/flowJobMoveMethods.d.ts +16 -0
- package/dist/types/src/client/flowJobTypes.d.ts +29 -0
- package/dist/types/src/client/flowLegacyPlan.d.ts +16 -0
- package/dist/types/src/client/flowOptions.d.ts +10 -0
- package/dist/types/src/client/flowPlan.d.ts +16 -0
- package/dist/types/src/client/flowPush.d.ts +27 -0
- package/dist/types/src/client/flowReader.d.ts +10 -0
- package/dist/types/src/client/flowResults.d.ts +11 -0
- package/dist/types/src/client/flowTypes.d.ts +77 -0
- package/dist/types/src/client/forwarder.d.ts +75 -0
- package/dist/types/src/client/groupId.d.ts +1 -0
- package/dist/types/src/client/index.d.ts +46 -0
- package/dist/types/src/client/jobConversion.d.ts +10 -0
- package/dist/types/src/client/jobConversionHelpers.d.ts +28 -0
- package/dist/types/src/client/jobConversionTypes.d.ts +88 -0
- package/dist/types/src/client/jobDeduplication.d.ts +6 -0
- package/dist/types/src/client/jobHelpers.d.ts +31 -0
- package/dist/types/src/client/legacyConnectionOptions.d.ts +8 -0
- package/dist/types/src/client/manager.d.ts +15 -0
- package/dist/types/src/client/pro.d.ts +9 -0
- package/dist/types/src/client/queue/addBatcher.d.ts +59 -0
- package/dist/types/src/client/queue/bullmqCompat.d.ts +57 -0
- package/dist/types/src/client/queue/deduplication.d.ts +14 -0
- package/dist/types/src/client/queue/dlq.d.ts +61 -0
- package/dist/types/src/client/queue/dlqJobMethods.d.ts +9 -0
- package/dist/types/src/client/queue/dlqOps.d.ts +26 -0
- package/dist/types/src/client/queue/dlqStats.d.ts +3 -0
- package/dist/types/src/client/queue/failWire.d.ts +17 -0
- package/dist/types/src/client/queue/helpers.d.ts +19 -0
- package/dist/types/src/client/queue/job-proxy/dependencies.d.ts +9 -0
- package/dist/types/src/client/queue/job-proxy/reflection.d.ts +2 -0
- package/dist/types/src/client/queue/job-proxy/simple.d.ts +3 -0
- package/dist/types/src/client/queue/job-proxy/tcp.d.ts +4 -0
- package/dist/types/src/client/queue/jobMetadata.d.ts +10 -0
- package/dist/types/src/client/queue/jobMove.d.ts +32 -0
- package/dist/types/src/client/queue/jobProxy.d.ts +4 -0
- package/dist/types/src/client/queue/operations/add/bulk.d.ts +7 -0
- package/dist/types/src/client/queue/operations/add/payload.d.ts +25 -0
- package/dist/types/src/client/queue/operations/add/single.d.ts +3 -0
- package/dist/types/src/client/queue/operations/add.d.ts +2 -0
- package/dist/types/src/client/queue/operations/control.d.ts +42 -0
- package/dist/types/src/client/queue/operations/counts.d.ts +48 -0
- package/dist/types/src/client/queue/operations/groups.d.ts +24 -0
- package/dist/types/src/client/queue/operations/management.d.ts +51 -0
- package/dist/types/src/client/queue/operations/query.d.ts +50 -0
- package/dist/types/src/client/queue/operations/queryStates.d.ts +13 -0
- package/dist/types/src/client/queue/operations/queryTcpPages.d.ts +14 -0
- package/dist/types/src/client/queue/queue.d.ts +12 -0
- package/dist/types/src/client/queue/rateLimit.d.ts +46 -0
- package/dist/types/src/client/queue/runtime/compatibility.d.ts +13 -0
- package/dist/types/src/client/queue/runtime/configuration.d.ts +46 -0
- package/dist/types/src/client/queue/runtime/connection.d.ts +6 -0
- package/dist/types/src/client/queue/runtime/control.d.ts +41 -0
- package/dist/types/src/client/queue/runtime/queries.d.ts +66 -0
- package/dist/types/src/client/queue/runtime/scheduling.d.ts +33 -0
- package/dist/types/src/client/queue/runtime/state.d.ts +101 -0
- package/dist/types/src/client/queue/scheduler.d.ts +58 -0
- package/dist/types/src/client/queue/schedulerPagination.d.ts +7 -0
- package/dist/types/src/client/queue/stall.d.ts +20 -0
- package/dist/types/src/client/queue/types/add.d.ts +40 -0
- package/dist/types/src/client/queue/types/contexts.d.ts +33 -0
- package/dist/types/src/client/queue/types/index.d.ts +3 -0
- package/dist/types/src/client/queue/types/job.d.ts +50 -0
- package/dist/types/src/client/queue/types/runtime.d.ts +35 -0
- package/dist/types/src/client/queue/workers.d.ts +36 -0
- package/dist/types/src/client/queue-events/tcpSubscription.d.ts +23 -0
- package/dist/types/src/client/queue.d.ts +5 -0
- package/dist/types/src/client/queueGroup.d.ts +51 -0
- package/dist/types/src/client/resolveToken.d.ts +10 -0
- package/dist/types/src/client/sandboxed/index.d.ts +7 -0
- package/dist/types/src/client/sandboxed/queueOps.d.ts +24 -0
- package/dist/types/src/client/sandboxed/runtime/dispatch.d.ts +13 -0
- package/dist/types/src/client/sandboxed/runtime/lifecycle.d.ts +20 -0
- package/dist/types/src/client/sandboxed/runtime/log.d.ts +1 -0
- package/dist/types/src/client/sandboxed/runtime/pool.d.ts +11 -0
- package/dist/types/src/client/sandboxed/runtime/recovery.d.ts +11 -0
- package/dist/types/src/client/sandboxed/runtime/state.d.ts +39 -0
- package/dist/types/src/client/sandboxed/types/index.d.ts +2 -0
- package/dist/types/src/client/sandboxed/types/options.d.ts +27 -0
- package/dist/types/src/client/sandboxed/types/process.d.ts +39 -0
- package/dist/types/src/client/sandboxed/worker.d.ts +4 -0
- package/dist/types/src/client/sandboxed/wrapper.d.ts +12 -0
- package/dist/types/src/client/sandboxedWorker.d.ts +6 -0
- package/dist/types/src/client/tcp/client.d.ts +6 -0
- package/dist/types/src/client/tcp/commandQueue.d.ts +23 -0
- package/dist/types/src/client/tcp/connection.d.ts +4 -0
- package/dist/types/src/client/tcp/errors.d.ts +6 -0
- package/dist/types/src/client/tcp/health.d.ts +60 -0
- package/dist/types/src/client/tcp/index.d.ts +11 -0
- package/dist/types/src/client/tcp/reconnect.d.ts +47 -0
- package/dist/types/src/client/tcp/runtime/commands.d.ts +9 -0
- package/dist/types/src/client/tcp/runtime/connectivity.d.ts +13 -0
- package/dist/types/src/client/tcp/runtime/health.d.ts +14 -0
- package/dist/types/src/client/tcp/runtime/lifecycle.d.ts +8 -0
- package/dist/types/src/client/tcp/runtime/state.d.ts +50 -0
- package/dist/types/src/client/tcp/shared.d.ts +12 -0
- package/dist/types/src/client/tcp/transport.d.ts +18 -0
- package/dist/types/src/client/tcp/types/command.d.ts +9 -0
- package/dist/types/src/client/tcp/types/connection.d.ts +31 -0
- package/dist/types/src/client/tcp/types/index.d.ts +5 -0
- package/dist/types/src/client/tcp/types/socket.d.ts +8 -0
- package/dist/types/src/client/tcp/types/tls.d.ts +4 -0
- package/dist/types/src/client/tcp/types.d.ts +2 -0
- package/dist/types/src/client/tcpClient.d.ts +6 -0
- package/dist/types/src/client/tcpPool.d.ts +69 -0
- package/dist/types/src/client/types/connection.d.ts +30 -0
- package/dist/types/src/client/types/dlq.d.ts +45 -0
- package/dist/types/src/client/types/events.d.ts +54 -0
- package/dist/types/src/client/types/flow.d.ts +22 -0
- package/dist/types/src/client/types/index.d.ts +10 -0
- package/dist/types/src/client/types/job.d.ts +131 -0
- package/dist/types/src/client/types/metrics.d.ts +1 -0
- package/dist/types/src/client/types/options.d.ts +72 -0
- package/dist/types/src/client/types/worker.d.ts +54 -0
- package/dist/types/src/client/types.d.ts +2 -0
- package/dist/types/src/client/worker/ackBatcher.d.ts +55 -0
- package/dist/types/src/client/worker/ackFrontier.d.ts +21 -0
- package/dist/types/src/client/worker/ackOutcome.d.ts +8 -0
- package/dist/types/src/client/worker/batchExecution.d.ts +14 -0
- package/dist/types/src/client/worker/constants.d.ts +7 -0
- package/dist/types/src/client/worker/groupConcurrency.d.ts +49 -0
- package/dist/types/src/client/worker/handlers/completion.d.ts +29 -0
- package/dist/types/src/client/worker/handlers/dependencies.d.ts +11 -0
- package/dist/types/src/client/worker/handlers/mutations.d.ts +23 -0
- package/dist/types/src/client/worker/handlers/queries.d.ts +15 -0
- package/dist/types/src/client/worker/jobParser.d.ts +9 -0
- package/dist/types/src/client/worker/processor.d.ts +11 -0
- package/dist/types/src/client/worker/processorHandlers.d.ts +4 -0
- package/dist/types/src/client/worker/processorOutcome.d.ts +14 -0
- package/dist/types/src/client/worker/processorResult.d.ts +2 -0
- package/dist/types/src/client/worker/runtime/buffer.d.ts +8 -0
- package/dist/types/src/client/worker/runtime/control.d.ts +28 -0
- package/dist/types/src/client/worker/runtime/execution.d.ts +16 -0
- package/dist/types/src/client/worker/runtime/lifecycle.d.ts +7 -0
- package/dist/types/src/client/worker/runtime/manual.d.ts +10 -0
- package/dist/types/src/client/worker/runtime/options.d.ts +5 -0
- package/dist/types/src/client/worker/runtime/polling.d.ts +14 -0
- package/dist/types/src/client/worker/runtime/state.d.ts +121 -0
- package/dist/types/src/client/worker/types/index.d.ts +5 -0
- package/dist/types/src/client/worker/types/manual.d.ts +7 -0
- package/dist/types/src/client/worker/types/options.d.ts +26 -0
- package/dist/types/src/client/worker/types/outcome.d.ts +23 -0
- package/dist/types/src/client/worker/types/processor.d.ts +25 -0
- package/dist/types/src/client/worker/types/transport.d.ts +11 -0
- package/dist/types/src/client/worker/worker.d.ts +6 -0
- package/dist/types/src/client/worker/workerHeartbeat.d.ts +15 -0
- package/dist/types/src/client/worker/workerPull.d.ts +24 -0
- package/dist/types/src/client/worker/workerRateLimiter.d.ts +51 -0
- package/dist/types/src/client/worker.d.ts +6 -0
- package/dist/types/src/client/workflow/admission.d.ts +45 -0
- package/dist/types/src/client/workflow/clock.d.ts +60 -0
- package/dist/types/src/client/workflow/compensationChild.d.ts +33 -0
- package/dist/types/src/client/workflow/compensationClaim.d.ts +11 -0
- package/dist/types/src/client/workflow/compensationPass.d.ts +17 -0
- package/dist/types/src/client/workflow/compensationSupport.d.ts +24 -0
- package/dist/types/src/client/workflow/compensator.d.ts +34 -0
- package/dist/types/src/client/workflow/definitionGuard.d.ts +11 -0
- package/dist/types/src/client/workflow/emitter.d.ts +17 -0
- package/dist/types/src/client/workflow/engine.d.ts +66 -0
- package/dist/types/src/client/workflow/eventTypes.d.ts +44 -0
- package/dist/types/src/client/workflow/executionFence.d.ts +15 -0
- package/dist/types/src/client/workflow/executionTypes.d.ts +133 -0
- package/dist/types/src/client/workflow/executor.d.ts +52 -0
- package/dist/types/src/client/workflow/executorLifecycle.d.ts +19 -0
- package/dist/types/src/client/workflow/executorNodes.d.ts +18 -0
- package/dist/types/src/client/workflow/executorQueue.d.ts +9 -0
- package/dist/types/src/client/workflow/forEachRunner.d.ts +4 -0
- package/dist/types/src/client/workflow/identity.d.ts +48 -0
- package/dist/types/src/client/workflow/index.d.ts +23 -0
- package/dist/types/src/client/workflow/loops.d.ts +11 -0
- package/dist/types/src/client/workflow/mapRunner.d.ts +4 -0
- package/dist/types/src/client/workflow/recovery.d.ts +32 -0
- package/dist/types/src/client/workflow/rollbackControl.d.ts +37 -0
- package/dist/types/src/client/workflow/runner.d.ts +23 -0
- package/dist/types/src/client/workflow/runnerTiming.d.ts +14 -0
- package/dist/types/src/client/workflow/stepTypes.d.ts +171 -0
- package/dist/types/src/client/workflow/store.d.ts +83 -0
- package/dist/types/src/client/workflow/storeCodec.d.ts +7 -0
- package/dist/types/src/client/workflow/storeExecutionCodec.d.ts +11 -0
- package/dist/types/src/client/workflow/storeListing.d.ts +11 -0
- package/dist/types/src/client/workflow/storeMaintenance.d.ts +4 -0
- package/dist/types/src/client/workflow/storeSignals.d.ts +70 -0
- package/dist/types/src/client/workflow/subWorkflowRunner.d.ts +14 -0
- package/dist/types/src/client/workflow/types.d.ts +4 -0
- package/dist/types/src/client/workflow/unwindPlan.d.ts +87 -0
- package/dist/types/src/client/workflow/waitFor.d.ts +56 -0
- package/dist/types/src/client/workflow/workflow.d.ts +70 -0
- package/dist/types/src/client/workflow/workflowDecisions.d.ts +11 -0
- package/dist/types/src/client/workflow/workflowDefinition.d.ts +16 -0
- package/dist/types/src/client/workflow/workflowIntrospection.d.ts +5 -0
- package/dist/types/src/client/workflow/workflowValidation.d.ts +44 -0
- package/dist/types/src/config/index.d.ts +9 -0
- package/dist/types/src/config/loader.d.ts +7 -0
- package/dist/types/src/config/resolve.d.ts +59 -0
- package/dist/types/src/config/types.d.ts +88 -0
- package/dist/types/src/domain/job/constants.d.ts +14 -0
- package/dist/types/src/domain/job/create.d.ts +9 -0
- package/dist/types/src/domain/job/groupFifoOrder.d.ts +9 -0
- package/dist/types/src/domain/job/ids.d.ts +7 -0
- package/dist/types/src/domain/job/locks.d.ts +16 -0
- package/dist/types/src/domain/job/payload.d.ts +18 -0
- package/dist/types/src/domain/job/state.d.ts +23 -0
- package/dist/types/src/domain/job/terminal.d.ts +3 -0
- package/dist/types/src/domain/queue/dependencyTracker.d.ts +78 -0
- package/dist/types/src/domain/queue/dlqShard.d.ts +66 -0
- package/dist/types/src/domain/queue/groupLimiterManager.d.ts +30 -0
- package/dist/types/src/domain/queue/groupScheduler.d.ts +31 -0
- package/dist/types/src/domain/queue/groupSchedulerOrder.d.ts +6 -0
- package/dist/types/src/domain/queue/limiterManager.d.ts +68 -0
- package/dist/types/src/domain/queue/priorityQueue.d.ts +54 -0
- package/dist/types/src/domain/queue/priorityQueueOrder.d.ts +3 -0
- package/dist/types/src/domain/queue/shard/dependencies.d.ts +11 -0
- package/dist/types/src/domain/queue/shard/dlq.d.ts +26 -0
- package/dist/types/src/domain/queue/shard/keys.d.ts +19 -0
- package/dist/types/src/domain/queue/shard/lifecycle.d.ts +10 -0
- package/dist/types/src/domain/queue/shard/limits.d.ts +47 -0
- package/dist/types/src/domain/queue/shard/metrics.d.ts +32 -0
- package/dist/types/src/domain/queue/shard/state.d.ts +40 -0
- package/dist/types/src/domain/queue/shard.d.ts +7 -0
- package/dist/types/src/domain/queue/shardCounters.d.ts +35 -0
- package/dist/types/src/domain/queue/temporalIndex.d.ts +24 -0
- package/dist/types/src/domain/queue/temporalManager.d.ts +72 -0
- package/dist/types/src/domain/queue/uniqueKeyManager.d.ts +33 -0
- package/dist/types/src/domain/queue/waiterManager.d.ts +18 -0
- package/dist/types/src/domain/response/builders.d.ts +15 -0
- package/dist/types/src/domain/types/command.d.ts +2 -0
- package/dist/types/src/domain/types/commands/base.d.ts +5 -0
- package/dist/types/src/domain/types/commands/core.d.ts +107 -0
- package/dist/types/src/domain/types/commands/cron.d.ts +36 -0
- package/dist/types/src/domain/types/commands/dashboard.d.ts +13 -0
- package/dist/types/src/domain/types/commands/dlq.d.ts +44 -0
- package/dist/types/src/domain/types/commands/extended.d.ts +63 -0
- package/dist/types/src/domain/types/commands/index.d.ts +12 -0
- package/dist/types/src/domain/types/commands/limits.d.ts +108 -0
- package/dist/types/src/domain/types/commands/management.d.ts +73 -0
- package/dist/types/src/domain/types/commands/monitoring.d.ts +49 -0
- package/dist/types/src/domain/types/commands/protocol.d.ts +20 -0
- package/dist/types/src/domain/types/commands/query.d.ts +46 -0
- package/dist/types/src/domain/types/commands/union.d.ts +13 -0
- package/dist/types/src/domain/types/commands/workers.d.ts +39 -0
- package/dist/types/src/domain/types/cron.d.ts +89 -0
- package/dist/types/src/domain/types/deduplication.d.ts +43 -0
- package/dist/types/src/domain/types/dlq.d.ts +136 -0
- package/dist/types/src/domain/types/flow.d.ts +25 -0
- package/dist/types/src/domain/types/group.d.ts +26 -0
- package/dist/types/src/domain/types/job.d.ts +8 -0
- package/dist/types/src/domain/types/jobs/model.d.ts +150 -0
- package/dist/types/src/domain/types/metrics.d.ts +16 -0
- package/dist/types/src/domain/types/priorityQueue.d.ts +13 -0
- package/dist/types/src/domain/types/protocol.d.ts +5 -0
- package/dist/types/src/domain/types/queue.d.ts +110 -0
- package/dist/types/src/domain/types/response.d.ts +3 -0
- package/dist/types/src/domain/types/responses/model.d.ts +152 -0
- package/dist/types/src/domain/types/shard.d.ts +4 -0
- package/dist/types/src/domain/types/stall.d.ts +48 -0
- package/dist/types/src/domain/types/webhook.d.ts +42 -0
- package/dist/types/src/domain/types/worker.d.ts +40 -0
- package/dist/types/src/infrastructure/backup/backupTelemetry.d.ts +30 -0
- package/dist/types/src/infrastructure/backup/s3BackupConfig.d.ts +80 -0
- package/dist/types/src/infrastructure/cloud/types/config.d.ts +18 -0
- package/dist/types/src/infrastructure/cloud/types/event.d.ts +14 -0
- package/dist/types/src/infrastructure/cloud/types/snapshot.d.ts +52 -0
- package/dist/types/src/infrastructure/cloud/types/snapshotCore.d.ts +125 -0
- package/dist/types/src/infrastructure/cloud/types/snapshotJobs.d.ts +124 -0
- package/dist/types/src/infrastructure/cloud/types/snapshotTelemetry.d.ts +100 -0
- package/dist/types/src/infrastructure/cloud/types.d.ts +3 -0
- package/dist/types/src/infrastructure/persistence/batchInsert.d.ts +13 -0
- package/dist/types/src/infrastructure/persistence/completedJobCountSchema.d.ts +6 -0
- package/dist/types/src/infrastructure/persistence/dependencyCompletionSchema.d.ts +6 -0
- package/dist/types/src/infrastructure/persistence/dependencyCompletionStore.d.ts +40 -0
- package/dist/types/src/infrastructure/persistence/index.d.ts +5 -0
- package/dist/types/src/infrastructure/persistence/jobOptionsBlob.d.ts +19 -0
- package/dist/types/src/infrastructure/persistence/legacyNameMigration.d.ts +17 -0
- package/dist/types/src/infrastructure/persistence/migrationProgressSchema.d.ts +2 -0
- package/dist/types/src/infrastructure/persistence/migrations.d.ts +3 -0
- package/dist/types/src/infrastructure/persistence/schema.d.ts +8 -0
- package/dist/types/src/infrastructure/persistence/sqlite/admission.d.ts +9 -0
- package/dist/types/src/infrastructure/persistence/sqlite/completed.d.ts +17 -0
- package/dist/types/src/infrastructure/persistence/sqlite/control.d.ts +48 -0
- package/dist/types/src/infrastructure/persistence/sqlite/flows.d.ts +26 -0
- package/dist/types/src/infrastructure/persistence/sqlite/jobLifecycle.d.ts +17 -0
- package/dist/types/src/infrastructure/persistence/sqlite/jobs.d.ts +15 -0
- package/dist/types/src/infrastructure/persistence/sqlite/lifecycle.d.ts +6 -0
- package/dist/types/src/infrastructure/persistence/sqlite/mutations.d.ts +27 -0
- package/dist/types/src/infrastructure/persistence/sqlite/queries.d.ts +23 -0
- package/dist/types/src/infrastructure/persistence/sqlite/queueDeletionSql.d.ts +3 -0
- package/dist/types/src/infrastructure/persistence/sqlite/records.d.ts +24 -0
- package/dist/types/src/infrastructure/persistence/sqlite/state.d.ts +42 -0
- package/dist/types/src/infrastructure/persistence/sqlite/telemetry.d.ts +17 -0
- package/dist/types/src/infrastructure/persistence/sqlite/telemetryStore.d.ts +30 -0
- package/dist/types/src/infrastructure/persistence/sqlite/telemetryWrites.d.ts +47 -0
- package/dist/types/src/infrastructure/persistence/sqlite.d.ts +6 -0
- package/dist/types/src/infrastructure/persistence/sqliteBatch.d.ts +4 -0
- package/dist/types/src/infrastructure/persistence/sqliteMigration.d.ts +5 -0
- package/dist/types/src/infrastructure/persistence/sqliteSerializer.d.ts +50 -0
- package/dist/types/src/infrastructure/persistence/statements.d.ts +86 -0
- package/dist/types/src/infrastructure/persistence/types/admission.d.ts +8 -0
- package/dist/types/src/infrastructure/persistence/types/batch.d.ts +12 -0
- package/dist/types/src/infrastructure/persistence/types/sqlite.d.ts +27 -0
- package/dist/types/src/infrastructure/persistence/writeBuffer.d.ts +48 -0
- package/dist/types/src/infrastructure/persistence/writeBufferPending.d.ts +11 -0
- package/dist/types/src/infrastructure/scheduler/cron/execution.d.ts +12 -0
- package/dist/types/src/infrastructure/scheduler/cron/persisted.d.ts +5 -0
- package/dist/types/src/infrastructure/scheduler/cron/runtime.d.ts +31 -0
- package/dist/types/src/infrastructure/scheduler/cron/validation.d.ts +3 -0
- package/dist/types/src/infrastructure/scheduler/cronParser.d.ts +45 -0
- package/dist/types/src/infrastructure/scheduler/cronScheduler.d.ts +5 -0
- package/dist/types/src/infrastructure/scheduler/types/cronScheduler.d.ts +16 -0
- package/dist/types/src/infrastructure/server/protocol/commands.d.ts +8 -0
- package/dist/types/src/infrastructure/server/protocol/frameParser.d.ts +16 -0
- package/dist/types/src/infrastructure/server/protocol/lineBuffer.d.ts +6 -0
- package/dist/types/src/infrastructure/server/protocol/validation.d.ts +10 -0
- package/dist/types/src/infrastructure/server/protocol.d.ts +6 -0
- package/dist/types/src/infrastructure/server/socketWriteQueue.d.ts +66 -0
- package/dist/types/src/infrastructure/server/types/protocol.d.ts +4 -0
- package/dist/types/src/require-bun.d.ts +13 -0
- package/dist/types/src/shared/asyncLock.d.ts +13 -0
- package/dist/types/src/shared/boundedMap.d.ts +30 -0
- package/dist/types/src/shared/boundedSet.d.ts +26 -0
- package/dist/types/src/shared/hash.d.ts +30 -0
- package/dist/types/src/shared/histogram.d.ts +23 -0
- package/dist/types/src/shared/lock.d.ts +13 -0
- package/dist/types/src/shared/lockError.d.ts +3 -0
- package/dist/types/src/shared/lockTimeout.d.ts +2 -0
- package/dist/types/src/shared/logger.d.ts +48 -0
- package/dist/types/src/shared/lru.d.ts +9 -0
- package/dist/types/src/shared/lruMap.d.ts +42 -0
- package/dist/types/src/shared/lruSet.d.ts +36 -0
- package/dist/types/src/shared/minHeap.d.ts +43 -0
- package/dist/types/src/shared/msgpack.d.ts +3 -0
- package/dist/types/src/shared/pausedView.d.ts +19 -0
- package/dist/types/src/shared/rwLock.d.ts +22 -0
- package/dist/types/src/shared/serialization.d.ts +24 -0
- package/dist/types/src/shared/skipList.d.ts +97 -0
- package/dist/types/src/shared/skipListNodes.d.ts +6 -0
- package/dist/types/src/shared/storageHealth.d.ts +9 -0
- package/dist/types/src/shared/ttlMap.d.ts +81 -0
- package/dist/types/src/shared/types/lock.d.ts +7 -0
- package/dist/types/src/shared/types/skipList.d.ts +4 -0
- package/dist/types/src/shared/version.d.ts +4 -0
- package/dist/types/src/shared/webhookValidation.d.ts +6 -0
- package/package.json +27 -9
- package/src/ack-batcher.ts +8 -5
- package/src/bunqueue/bunqueue-api.ts +1 -1
- package/src/bunqueue/bunqueue.ts +2 -1
- package/src/canonical-transport/bun-sqlite-types.ts +22 -0
- package/src/canonical-transport/dlq.ts +12 -0
- package/src/canonical-transport/embedded.ts +55 -0
- package/src/canonical-transport/runtime.ts +49 -0
- package/src/canonical-transport/thread-worker.ts +83 -0
- package/src/canonical-transport/transport.ts +153 -0
- package/src/connection.ts +25 -30
- package/src/errors.ts +3 -0
- package/src/flow-commit.ts +45 -0
- package/src/flow-plan-legacy.ts +117 -0
- package/src/flow-plan.ts +209 -0
- package/src/flow-types.ts +4 -0
- package/src/flow.ts +31 -163
- package/src/frame.ts +5 -2
- package/src/index.ts +7 -75
- package/src/job.ts +43 -9
- package/src/legacy.ts +91 -0
- package/src/observability.ts +59 -1
- package/src/queue-admin.ts +5 -5
- package/src/queue-control.ts +8 -6
- package/src/queue.ts +10 -6
- package/src/serialization.ts +93 -0
- package/src/terminal-outcome.ts +58 -0
- package/src/types.ts +3 -6
- package/src/worker-base.ts +9 -6
- package/src/worker-slot-signal.ts +23 -0
- package/src/worker.ts +11 -5
- package/dist/backpressure.js +0 -39
- package/dist/bunqueue/aging.js +0 -53
- package/dist/bunqueue/batch.js +0 -60
- package/dist/bunqueue/bunqueue-api.js +0 -116
- package/dist/bunqueue/bunqueue.js +0 -194
- package/dist/bunqueue/cancellation.js +0 -48
- package/dist/bunqueue/circuit-breaker.js +0 -69
- package/dist/bunqueue/dedup-debounce.js +0 -37
- package/dist/bunqueue/dlq-rate-limit.js +0 -65
- package/dist/bunqueue/rate-gate.js +0 -61
- package/dist/bunqueue/retry.js +0 -56
- package/dist/bunqueue/triggers.js +0 -42
- package/dist/bunqueue/ttl.js +0 -31
- package/dist/bunqueue/types.js +0 -6
- package/dist/connection-pool.js +0 -60
- package/dist/connection-types.js +0 -2
- package/dist/connection.js +0 -281
- package/dist/errors.js +0 -25
- package/dist/flow-types.js +0 -2
- package/dist/flow.js +0 -212
- package/dist/job.js +0 -155
- package/dist/observability.js +0 -110
- package/dist/queue-admin.js +0 -158
- package/dist/queue-control.js +0 -107
- package/dist/queue-query.js +0 -187
- package/dist/queue.js +0 -92
- package/dist/responses.js +0 -10
- package/dist/socket-factory.js +0 -47
- package/dist/types.js +0 -50
- package/dist/worker-base.js +0 -159
- package/dist/worker-types.js +0 -5
- package/dist/worker.js +0 -211
- /package/dist/{backpressure.d.ts → types/sdk/typescript/src/backpressure.d.ts} +0 -0
- /package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/cancellation.d.ts +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Pure record selection and context construction for saga compensation. */
|
|
2
|
+
import { buildContext } from "./runner.js";
|
|
3
|
+
import type { CompensationStatus, Execution, StepRecord } from "./types.js";
|
|
4
|
+
import type { Workflow } from "./workflow.js";
|
|
5
|
+
/**
|
|
6
|
+
* Eligible records in reverse start order. Failed records are included because their
|
|
7
|
+
* external effect may have succeeded before its response was lost.
|
|
8
|
+
*/
|
|
9
|
+
export declare function unwindSet(exec: Execution, wf: Workflow): [string, StepRecord][];
|
|
10
|
+
export declare function settle(record: StepRecord, status: CompensationStatus, error?: string): void;
|
|
11
|
+
/**
|
|
12
|
+
* Rebind a loop's bare step name to this occurrence and restore forEach item metadata.
|
|
13
|
+
*/
|
|
14
|
+
export declare function compensationContext(exec: Execution, baseCtx: ReturnType<typeof buildContext>, name: string, record: StepRecord): {
|
|
15
|
+
steps: {
|
|
16
|
+
[x: string]: unknown;
|
|
17
|
+
};
|
|
18
|
+
idempotencyKey: string;
|
|
19
|
+
forwardIdempotencyKey: string | undefined;
|
|
20
|
+
input: unknown;
|
|
21
|
+
signals: Readonly<Record<string, unknown>>;
|
|
22
|
+
executionId: string;
|
|
23
|
+
signal?: AbortSignal;
|
|
24
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public saga-compensation entry points.
|
|
3
|
+
*
|
|
4
|
+
* A pass is checkpointed per step, halts on an uncertain reversal, and is protected
|
|
5
|
+
* from overlapping in-process drivers. The execution mechanics live in
|
|
6
|
+
* compensationPass.ts; record selection lives in compensationSupport.ts.
|
|
7
|
+
*/
|
|
8
|
+
import type { LostCompensationClaim } from "./compensationClaim.js";
|
|
9
|
+
import type { WorkflowEmitter } from "./emitter.js";
|
|
10
|
+
import type { WorkflowStore } from "./store.js";
|
|
11
|
+
import type { Execution } from "./types.js";
|
|
12
|
+
import type { Workflow } from "./workflow.js";
|
|
13
|
+
export { AbandonedCompensationError, CommittedChildError } from "./compensationChild.js";
|
|
14
|
+
/** Sentinel thrown when an execution deliberately parks for a signal. */
|
|
15
|
+
export declare class WaitForSignalError extends Error {
|
|
16
|
+
readonly event: string;
|
|
17
|
+
constructor(event: string);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* This is not a distributed lock. It prevents two local recovery/operator paths from
|
|
21
|
+
* reading the same unsettled snapshot and issuing the same reversal twice. A losing
|
|
22
|
+
* recovery path receives the current owner's completion latch and can retry safely.
|
|
23
|
+
*/
|
|
24
|
+
export type UnwindOutcome = 'ran' | LostCompensationClaim;
|
|
25
|
+
/** Run compensation handlers in reverse start order for every eligible step. */
|
|
26
|
+
export declare function runCompensation(exec: Execution, wf: Workflow, store: WorkflowStore, emitter: WorkflowEmitter | null, workflows?: Map<string, Workflow>, opts?: {
|
|
27
|
+
retryFailed?: boolean;
|
|
28
|
+
assertActive?: () => void;
|
|
29
|
+
}): Promise<UnwindOutcome>;
|
|
30
|
+
/**
|
|
31
|
+
* Give up on a parked unwind and record an explicit skipped outcome for every
|
|
32
|
+
* remaining eligible step.
|
|
33
|
+
*/
|
|
34
|
+
export declare function abandonCompensation(exec: Execution, wf: Workflow, store: WorkflowStore, emitter: WorkflowEmitter | null, assertActive?: () => void): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Runtime guard binding persisted executions to one sealed workflow graph. */
|
|
2
|
+
import type { Execution } from "./types.js";
|
|
3
|
+
import type { Workflow } from "./workflow.js";
|
|
4
|
+
export declare class WorkflowDefinitionMismatchError extends Error {
|
|
5
|
+
constructor(executionId: string, workflowName: string);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Legacy rows have no hash; bind them once to the currently registered graph. New rows
|
|
9
|
+
* always arrive pre-bound by startExecution.
|
|
10
|
+
*/
|
|
11
|
+
export declare function bindExecutionDefinition(exec: Execution, workflow: Workflow, update: (exec: Execution) => void): void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WorkflowEmitter - Typed event system for workflow observability
|
|
3
|
+
*/
|
|
4
|
+
import type { WorkflowEventType, StepEvent, WorkflowLifecycleEvent, WorkflowEventListener, ExecutionState } from "./types.js";
|
|
5
|
+
export declare class WorkflowEmitter {
|
|
6
|
+
private readonly listeners;
|
|
7
|
+
private readonly globalListeners;
|
|
8
|
+
on(type: WorkflowEventType, listener: WorkflowEventListener): this;
|
|
9
|
+
onAny(listener: WorkflowEventListener): this;
|
|
10
|
+
off(type: WorkflowEventType, listener: WorkflowEventListener): this;
|
|
11
|
+
offAny(listener: WorkflowEventListener): this;
|
|
12
|
+
emitStep(type: 'step:started' | 'step:completed' | 'step:failed' | 'step:retry' | 'compensation:started' | 'compensation:completed' | 'compensation:failed' | 'compensation:skipped', executionId: string, workflowName: string, stepName: string, extra?: Partial<Omit<StepEvent, 'type' | 'executionId' | 'workflowName' | 'timestamp' | 'stepName'>>): void;
|
|
13
|
+
emitWorkflow(type: 'workflow:started' | 'workflow:completed' | 'workflow:failed' | 'workflow:compensating' | 'workflow:waiting', executionId: string, workflowName: string, state: ExecutionState, extra?: Partial<Omit<WorkflowLifecycleEvent, 'type' | 'executionId' | 'workflowName' | 'timestamp' | 'state'>>): void;
|
|
14
|
+
emitSignal(type: 'signal:received' | 'signal:timeout', executionId: string, workflowName: string, event: string, payload?: unknown): void;
|
|
15
|
+
removeAllListeners(): void;
|
|
16
|
+
private dispatch;
|
|
17
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engine - Public facade for the workflow engine
|
|
3
|
+
* Manages lifecycle of internal Queue, Worker, and Store.
|
|
4
|
+
*/
|
|
5
|
+
import type { Workflow } from "./workflow.js";
|
|
6
|
+
import type { EngineOptions, RunHandle, Execution, ExecutionState, ExecutionListOptions, RecoverResult, WorkflowEventType, WorkflowEventListener } from "./types.js";
|
|
7
|
+
export declare class Engine {
|
|
8
|
+
private readonly queue;
|
|
9
|
+
private readonly worker;
|
|
10
|
+
private readonly store;
|
|
11
|
+
private readonly executor;
|
|
12
|
+
private readonly emitter;
|
|
13
|
+
constructor(opts?: EngineOptions);
|
|
14
|
+
/** Register a workflow definition */
|
|
15
|
+
register(workflow: Workflow): this;
|
|
16
|
+
/** Start a new workflow execution */
|
|
17
|
+
start(workflowName: string, input?: unknown): Promise<RunHandle>;
|
|
18
|
+
/** Get execution state by ID */
|
|
19
|
+
getExecution(id: string): Execution | null;
|
|
20
|
+
/** List executions with optional filters */
|
|
21
|
+
listExecutions(workflowName?: string, state?: ExecutionState, options?: ExecutionListOptions): Execution[];
|
|
22
|
+
/**
|
|
23
|
+
* Retry the compensation that parked a `compensation-stuck` run and continue the
|
|
24
|
+
* unwind. Use once the cause of the failed reversal has been fixed.
|
|
25
|
+
*/
|
|
26
|
+
resumeCompensation(executionId: string): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Abandon a parked unwind: the steps still un-compensated are recorded as skipped
|
|
29
|
+
* and the run becomes terminal. Partial, but explicitly so.
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* `async` on purpose, even though the work is synchronous: `resumeCompensation` is
|
|
33
|
+
* async, and an operator writing recovery code under pressure reaches for
|
|
34
|
+
* `Promise.allSettled([resume(id), abandon(id)])`. With a sync throw that expression
|
|
35
|
+
* throws before `allSettled` is ever called, so the defensive form is the one that
|
|
36
|
+
* blows up. Matching the sibling costs nothing while the API is experimental.
|
|
37
|
+
*/
|
|
38
|
+
abandonCompensation(executionId: string): Promise<void>;
|
|
39
|
+
/** Send a signal to a waiting execution */
|
|
40
|
+
signal(executionId: string, event: string, payload?: unknown): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Recover orphaned executions after a crash/restart.
|
|
43
|
+
* - 'running' executions: re-enqueued at their current step
|
|
44
|
+
* - 'waiting' executions: timeout timers re-armed (or resumed if signal arrived)
|
|
45
|
+
* - 'compensating' executions: compensation re-run (handlers must be idempotent)
|
|
46
|
+
*/
|
|
47
|
+
recover(): Promise<RecoverResult>;
|
|
48
|
+
/** Subscribe to a specific workflow event type */
|
|
49
|
+
on(type: WorkflowEventType, listener: WorkflowEventListener): this;
|
|
50
|
+
/** Subscribe to all workflow events */
|
|
51
|
+
onAny(listener: WorkflowEventListener): this;
|
|
52
|
+
/** Unsubscribe from a specific event type */
|
|
53
|
+
off(type: WorkflowEventType, listener: WorkflowEventListener): this;
|
|
54
|
+
/** Unsubscribe a catch-all listener */
|
|
55
|
+
offAny(listener: WorkflowEventListener): this;
|
|
56
|
+
/** Subscribe to all events for a specific execution */
|
|
57
|
+
subscribe(executionId: string, callback: WorkflowEventListener): () => void;
|
|
58
|
+
/** Remove old completed/failed executions */
|
|
59
|
+
cleanup(maxAgeMs: number, states?: ExecutionState[]): number;
|
|
60
|
+
/** Archive old executions to a separate table */
|
|
61
|
+
archive(maxAgeMs: number, states?: ExecutionState[]): number;
|
|
62
|
+
/** Get archived execution count */
|
|
63
|
+
getArchivedCount(): number;
|
|
64
|
+
/** Shut down the engine */
|
|
65
|
+
close(force?: boolean): Promise<void>;
|
|
66
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** Workflow event and engine configuration types. */
|
|
2
|
+
import type { ConnectionOptions } from "../types.js";
|
|
3
|
+
import type { ExecutionState } from "./executionTypes.js";
|
|
4
|
+
/** All workflow event types */
|
|
5
|
+
export type WorkflowEventType = 'step:started' | 'step:completed' | 'step:failed' | 'step:retry' | 'workflow:started' | 'workflow:completed' | 'workflow:failed' | 'workflow:compensating' | 'workflow:waiting' | 'signal:received' | 'signal:timeout' | 'compensation:started' | 'compensation:completed' | 'compensation:failed' | 'compensation:skipped';
|
|
6
|
+
/** Base event payload */
|
|
7
|
+
export interface WorkflowEvent {
|
|
8
|
+
type: WorkflowEventType;
|
|
9
|
+
executionId: string;
|
|
10
|
+
workflowName: string;
|
|
11
|
+
timestamp: number;
|
|
12
|
+
}
|
|
13
|
+
/** Step-level event payload */
|
|
14
|
+
export interface StepEvent extends WorkflowEvent {
|
|
15
|
+
stepName: string;
|
|
16
|
+
result?: unknown;
|
|
17
|
+
error?: string;
|
|
18
|
+
attempt?: number;
|
|
19
|
+
maxAttempts?: number;
|
|
20
|
+
}
|
|
21
|
+
/** Workflow lifecycle event payload */
|
|
22
|
+
export interface WorkflowLifecycleEvent extends WorkflowEvent {
|
|
23
|
+
state: ExecutionState;
|
|
24
|
+
input?: unknown;
|
|
25
|
+
}
|
|
26
|
+
/** Signal event payload */
|
|
27
|
+
export interface SignalEvent extends WorkflowEvent {
|
|
28
|
+
event: string;
|
|
29
|
+
payload?: unknown;
|
|
30
|
+
}
|
|
31
|
+
/** Event listener function */
|
|
32
|
+
export type WorkflowEventListener = (event: WorkflowEvent | StepEvent | WorkflowLifecycleEvent | SignalEvent) => void;
|
|
33
|
+
/** Engine configuration */
|
|
34
|
+
export interface EngineOptions {
|
|
35
|
+
embedded?: boolean;
|
|
36
|
+
dataPath?: string;
|
|
37
|
+
connection?: ConnectionOptions;
|
|
38
|
+
/** Internal queue name (default: __wf:steps) */
|
|
39
|
+
queueName?: string;
|
|
40
|
+
/** Worker concurrency (default: 5) */
|
|
41
|
+
concurrency?: number;
|
|
42
|
+
/** Global event listener for observability */
|
|
43
|
+
onEvent?: WorkflowEventListener;
|
|
44
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Lifecycle fence shared by every asynchronous workflow execution path. */
|
|
2
|
+
/** Internal control-flow signal used to abandon work owned by a closed Engine. */
|
|
3
|
+
export declare class WorkflowExecutionClosedError extends Error {
|
|
4
|
+
constructor();
|
|
5
|
+
}
|
|
6
|
+
export declare function isWorkflowExecutionClosed(error: unknown): boolean;
|
|
7
|
+
/** A graceful close leaves this active; only close(true) aborts in-flight control flow. */
|
|
8
|
+
export declare class WorkflowExecutionFence {
|
|
9
|
+
private readonly controller;
|
|
10
|
+
readonly assertActive: () => void;
|
|
11
|
+
isActive(): boolean;
|
|
12
|
+
close(force: boolean): void;
|
|
13
|
+
}
|
|
14
|
+
/** Default for isolated runner tests that do not own an Engine lifecycle. */
|
|
15
|
+
export declare const assertWorkflowActive: () => void;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/** Persisted workflow execution, step outcome, and store coordination types. */
|
|
2
|
+
/** Execution state */
|
|
3
|
+
export type ExecutionState = 'running' | 'waiting' | 'completed' | 'failed' | 'compensating'
|
|
4
|
+
/**
|
|
5
|
+
* A compensation failed definitively and the unwind stopped. Deliberately NOT
|
|
6
|
+
* terminal: the run parks until an operator retries or abandons the unwind.
|
|
7
|
+
*/
|
|
8
|
+
| 'compensation-stuck';
|
|
9
|
+
/** What the engine did after a failure, independently of the failure reason. */
|
|
10
|
+
export type RollbackStatus =
|
|
11
|
+
/** Every eligible step was compensated successfully. */
|
|
12
|
+
'completed'
|
|
13
|
+
/** The unwind ran past the pivot cutoff or had nothing left to do. */
|
|
14
|
+
| 'not-applicable'
|
|
15
|
+
/** A compensation failed definitively; remaining reversals were not attempted. */
|
|
16
|
+
| 'stuck';
|
|
17
|
+
/** Step execution state */
|
|
18
|
+
export type StepState = 'pending' | 'running' | 'completed' | 'failed';
|
|
19
|
+
/** Terminal outcome of one step's rollback. */
|
|
20
|
+
export type CompensationStatus = 'compensated' | 'compensation-failed' | 'compensation-skipped';
|
|
21
|
+
export interface CompensationOutcome {
|
|
22
|
+
status: CompensationStatus;
|
|
23
|
+
at: number;
|
|
24
|
+
/** Why it failed, or why it was skipped. */
|
|
25
|
+
error?: string;
|
|
26
|
+
}
|
|
27
|
+
/** Record of a step's execution */
|
|
28
|
+
export interface StepRecord {
|
|
29
|
+
status: StepState;
|
|
30
|
+
result?: unknown;
|
|
31
|
+
error?: string;
|
|
32
|
+
startedAt?: number;
|
|
33
|
+
completedAt?: number;
|
|
34
|
+
attempts?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Whether this step declared a compensate handler when it ran. This survives a
|
|
37
|
+
* deployment that removes or renames the definition.
|
|
38
|
+
*/
|
|
39
|
+
compensatable?: boolean;
|
|
40
|
+
/** forEach iteration item — persisted so compensation can restore __item */
|
|
41
|
+
loopItem?: unknown;
|
|
42
|
+
/** forEach iteration index — persisted so compensation can restore __index */
|
|
43
|
+
loopIndex?: number;
|
|
44
|
+
/** Exactly one terminal compensation outcome for every eligible step. */
|
|
45
|
+
compensation?: CompensationOutcome;
|
|
46
|
+
/** Idempotency key of the forward execution, persisted before the body runs. */
|
|
47
|
+
idempotencyKey?: string;
|
|
48
|
+
/** Child execution owned by a sub-workflow record. */
|
|
49
|
+
childExecutionId?: string;
|
|
50
|
+
/** Occurrence of this step name within the run — loops reuse a single name. */
|
|
51
|
+
occurrence?: number;
|
|
52
|
+
}
|
|
53
|
+
/** Full persisted execution state */
|
|
54
|
+
export interface Execution {
|
|
55
|
+
id: string;
|
|
56
|
+
workflowName: string;
|
|
57
|
+
state: ExecutionState;
|
|
58
|
+
input: unknown;
|
|
59
|
+
steps: Record<string, StepRecord>;
|
|
60
|
+
currentNodeIndex: number;
|
|
61
|
+
/** Flattened names selected by resolved branch paths. */
|
|
62
|
+
resolvedSteps?: string[];
|
|
63
|
+
/** Durable results of control-flow decisions, keyed by node/iteration identity. */
|
|
64
|
+
decisions?: Record<string, unknown>;
|
|
65
|
+
/** Structural identity of the sealed workflow definition that started this run. */
|
|
66
|
+
definitionHash?: string;
|
|
67
|
+
/** What happened to the rollback. Independent of `failureReason`. */
|
|
68
|
+
rollbackStatus?: RollbackStatus;
|
|
69
|
+
/** Why the run failed. Independent of `rollbackStatus`. */
|
|
70
|
+
failureReason?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Node index at which `.pivot()` committed. Once set, backward recovery is off for
|
|
73
|
+
* the whole saga and recovery is forward-only.
|
|
74
|
+
*/
|
|
75
|
+
committedAt?: number;
|
|
76
|
+
signals: Record<string, unknown>;
|
|
77
|
+
/** Parent execution that owns this sub-workflow child. */
|
|
78
|
+
parentExecutionId?: string;
|
|
79
|
+
createdAt: number;
|
|
80
|
+
updatedAt: number;
|
|
81
|
+
}
|
|
82
|
+
/** Handle returned from engine.start() */
|
|
83
|
+
export interface RunHandle {
|
|
84
|
+
id: string;
|
|
85
|
+
workflowName: string;
|
|
86
|
+
}
|
|
87
|
+
/** Stable, bounded pagination for execution listings. */
|
|
88
|
+
export interface ExecutionListOptions {
|
|
89
|
+
/** Page size. Defaults to 100 and is capped at 1000. */
|
|
90
|
+
limit?: number;
|
|
91
|
+
/** Number of rows to skip in the deterministic createdAt/id order. */
|
|
92
|
+
offset?: number;
|
|
93
|
+
}
|
|
94
|
+
/** Internal job data for step execution */
|
|
95
|
+
export interface StepJobData {
|
|
96
|
+
executionId: string;
|
|
97
|
+
workflowName: string;
|
|
98
|
+
nodeIndex: number;
|
|
99
|
+
}
|
|
100
|
+
/** Result of engine.recover() */
|
|
101
|
+
export interface RecoverResult {
|
|
102
|
+
/** Number of running executions re-enqueued */
|
|
103
|
+
running: number;
|
|
104
|
+
/** Number of waiting executions with re-armed timers */
|
|
105
|
+
waiting: number;
|
|
106
|
+
/** Number of compensating executions re-run */
|
|
107
|
+
compensating: number;
|
|
108
|
+
/** Total recovered */
|
|
109
|
+
total: number;
|
|
110
|
+
}
|
|
111
|
+
/** Result of WorkflowStore.recordSignal() */
|
|
112
|
+
export interface SignalOutcome {
|
|
113
|
+
/** Whether the execution row exists */
|
|
114
|
+
found: boolean;
|
|
115
|
+
/** True for the single caller that claimed the resume of a parked run */
|
|
116
|
+
resumed: boolean;
|
|
117
|
+
workflowName: string;
|
|
118
|
+
currentNodeIndex: number;
|
|
119
|
+
}
|
|
120
|
+
/** Result of WorkflowStore.parkForSignal() */
|
|
121
|
+
export interface ParkOutcome {
|
|
122
|
+
/** The awaited signal was already recorded — advance instead of parking */
|
|
123
|
+
signalPresent: boolean;
|
|
124
|
+
/** This caller transitioned the run to 'waiting' */
|
|
125
|
+
parked: boolean;
|
|
126
|
+
/** Signals as persisted, for refreshing a stale in-memory snapshot */
|
|
127
|
+
signals: Record<string, unknown>;
|
|
128
|
+
}
|
|
129
|
+
/** Options for cleanup */
|
|
130
|
+
export interface CleanupOptions {
|
|
131
|
+
maxAge: number;
|
|
132
|
+
states?: ExecutionState[];
|
|
133
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** WorkflowExecutor - Core execution logic */
|
|
2
|
+
import type { Queue } from "../queue/queue.js";
|
|
3
|
+
import type { Workflow } from "./workflow.js";
|
|
4
|
+
import type { WorkflowStore } from "./store.js";
|
|
5
|
+
import type { WorkflowEmitter } from "./emitter.js";
|
|
6
|
+
import type { Execution, ExecutionListOptions, StepJobData, RunHandle, RecoverResult } from "./types.js";
|
|
7
|
+
export declare class WorkflowExecutor {
|
|
8
|
+
private readonly store;
|
|
9
|
+
private readonly queue;
|
|
10
|
+
private readonly emitter;
|
|
11
|
+
private readonly workflows;
|
|
12
|
+
private readonly timeoutTimers;
|
|
13
|
+
private readonly fence;
|
|
14
|
+
/**
|
|
15
|
+
* Release every armed waitFor timer. The engine owns the executor's lifetime, so
|
|
16
|
+
* `Engine.close()` must call this: an armed timer would otherwise fire into a
|
|
17
|
+
* closing queue, and a caller that keeps the process alive after closing one engine
|
|
18
|
+
* has no other handle on them.
|
|
19
|
+
*/
|
|
20
|
+
close(force?: boolean): void;
|
|
21
|
+
private readonly updateFn;
|
|
22
|
+
constructor(store: WorkflowStore, queue: Queue, emitter?: WorkflowEmitter | null);
|
|
23
|
+
register(workflow: Workflow): void;
|
|
24
|
+
start(workflowName: string, input: unknown, parentExecutionId?: string): Promise<RunHandle>;
|
|
25
|
+
/**
|
|
26
|
+
* Nodes this process is currently executing, keyed `<execution>:<nodeIndex>`.
|
|
27
|
+
*
|
|
28
|
+
* The cursor rejects stale jobs but not two overlapping deliveries for the current
|
|
29
|
+
* node. This process-local claim drops that overlap. Queue-level dedup is unsuitable:
|
|
30
|
+
* a retained ID can swallow a legitimate recovery enqueue and wedge the run.
|
|
31
|
+
*/
|
|
32
|
+
private readonly nodesInFlight;
|
|
33
|
+
processStep(data: StepJobData): Promise<unknown>;
|
|
34
|
+
private runNode;
|
|
35
|
+
signal(executionId: string, event: string, payload: unknown): Promise<void>;
|
|
36
|
+
private get lifecycleDeps();
|
|
37
|
+
/** Retry the compensation that parked the run, then finish the unwind. */
|
|
38
|
+
resumeCompensation(executionId: string): Promise<void>;
|
|
39
|
+
/** Give up on a parked unwind, recording the outstanding steps as skipped. */
|
|
40
|
+
abandonCompensation(executionId: string): void;
|
|
41
|
+
private get rollbackDeps();
|
|
42
|
+
getExecution(id: string): Execution | null;
|
|
43
|
+
listExecutions(wfName?: string, state?: Execution['state'], options?: ExecutionListOptions): Execution[];
|
|
44
|
+
private get nodeDeps();
|
|
45
|
+
private advance;
|
|
46
|
+
private enqueue;
|
|
47
|
+
private get waitForDeps();
|
|
48
|
+
private scheduleTimeoutCheck;
|
|
49
|
+
private compensate;
|
|
50
|
+
/** Recover orphaned executions after a crash/restart */
|
|
51
|
+
recover(): Promise<RecoverResult>;
|
|
52
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Durable start and signal publication for WorkflowExecutor. */
|
|
2
|
+
import type { Queue } from "../queue/queue.js";
|
|
3
|
+
import { type TimerHandle } from "./clock.js";
|
|
4
|
+
import type { WorkflowEmitter } from "./emitter.js";
|
|
5
|
+
import type { WorkflowStore } from "./store.js";
|
|
6
|
+
import type { Execution, RunHandle } from "./types.js";
|
|
7
|
+
import type { Workflow } from "./workflow.js";
|
|
8
|
+
interface LifecycleDeps {
|
|
9
|
+
store: WorkflowStore;
|
|
10
|
+
queue: Queue;
|
|
11
|
+
workflows: ReadonlyMap<string, Workflow>;
|
|
12
|
+
emitter: WorkflowEmitter | null;
|
|
13
|
+
timers: Map<string, TimerHandle>;
|
|
14
|
+
enqueue: (exec: Execution) => Promise<void>;
|
|
15
|
+
assertActive: () => void;
|
|
16
|
+
}
|
|
17
|
+
export declare function startExecution(deps: LifecycleDeps, workflowName: string, input: unknown, parentExecutionId?: string): Promise<RunHandle>;
|
|
18
|
+
export declare function signalExecution(deps: LifecycleDeps, executionId: string, event: string, payload: unknown): Promise<void>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Workflow node dispatch, split from the executor's lifecycle orchestration. */
|
|
2
|
+
import type { WorkflowEmitter } from "./emitter.js";
|
|
3
|
+
import type { WorkflowStore } from "./store.js";
|
|
4
|
+
import type { Execution, RunHandle, WorkflowNode } from "./types.js";
|
|
5
|
+
import { type WaitForDeps } from "./waitFor.js";
|
|
6
|
+
import type { Workflow } from "./workflow.js";
|
|
7
|
+
interface NodeExecutionDeps {
|
|
8
|
+
store: WorkflowStore;
|
|
9
|
+
emitter: WorkflowEmitter | null;
|
|
10
|
+
updateFn: (exec: Execution) => void;
|
|
11
|
+
advance: (exec: Execution, nextIdx: number, workflow: Workflow) => Promise<void>;
|
|
12
|
+
start: (name: string, input: unknown, parentId: string) => Promise<RunHandle>;
|
|
13
|
+
enqueue: (exec: Execution) => Promise<void>;
|
|
14
|
+
waitFor: WaitForDeps;
|
|
15
|
+
assertActive: () => void;
|
|
16
|
+
}
|
|
17
|
+
export declare function executeWorkflowNode(deps: NodeExecutionDeps, exec: Execution, node: WorkflowNode, idx: number, wf: Workflow): Promise<void>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Durable workflow-node publication shared by execution and recovery. */
|
|
2
|
+
import type { Queue } from "../queue/queue.js";
|
|
3
|
+
import type { Execution } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Publish one node without a deterministic job ID. The cursor and in-flight guards
|
|
6
|
+
* discard overlapping duplicates, while queue-level dedup could suppress a legitimate
|
|
7
|
+
* re-enqueue after recovery and wedge the execution permanently.
|
|
8
|
+
*/
|
|
9
|
+
export declare function enqueueWorkflowStep(queue: Queue, exec: Execution, assertActive: () => void): Promise<void>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Durable forEach execution, split from conditional loop runners. */
|
|
2
|
+
import type { Execution, ForEachDefinition } from "./types.js";
|
|
3
|
+
import type { WorkflowEmitter } from "./emitter.js";
|
|
4
|
+
export declare function executeForEach(def: ForEachDefinition, exec: Execution, emitter: WorkflowEmitter | null, updateFn: (exec: Execution) => void, assertActive?: () => void): Promise<void>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Idempotency identity for saga steps.
|
|
3
|
+
*
|
|
4
|
+
* The key is a function of (run, step name, occurrence, direction) and deliberately
|
|
5
|
+
* NOT of the attempt number. That is the single most common way to get this wrong:
|
|
6
|
+
* derive it from the attempt and every automatic retry asks the provider for a
|
|
7
|
+
* brand-new charge instead of being deduplicated into the first one.
|
|
8
|
+
*
|
|
9
|
+
* The three retry semantics collapse into two key behaviours:
|
|
10
|
+
*
|
|
11
|
+
* automatic retry after a transient error -> SAME key (we do not know whether the
|
|
12
|
+
* crash-and-resume of the same run -> SAME key effect landed; we want dedup)
|
|
13
|
+
* a different run of the same logic -> different key (different run id)
|
|
14
|
+
*
|
|
15
|
+
* `occurrence` exists because loop bodies reuse one step name. It is taken from the
|
|
16
|
+
* loop's iteration index rather than a running counter precisely so that it stays
|
|
17
|
+
* stable when a resumed loop replays its earlier iterations: replaying iteration 2
|
|
18
|
+
* must present the key iteration 2 already used, or the provider bills twice.
|
|
19
|
+
*/
|
|
20
|
+
export type Direction = 'forward' | 'compensate';
|
|
21
|
+
/** Opaque 128-bit execution identity, deterministic under the simulated clock. */
|
|
22
|
+
export declare function newExecutionId(): string;
|
|
23
|
+
export declare function idempotencyKey(runId: string, stepName: string, occurrence: number, direction: Direction): string;
|
|
24
|
+
/**
|
|
25
|
+
* A loop iteration record is `<step>:<digits>` and nothing else.
|
|
26
|
+
*
|
|
27
|
+
* Three separate defects came from treating "contains a colon" as the test: a step
|
|
28
|
+
* legitimately named `charge:extra` was resolved to a loop body called `charge`, was
|
|
29
|
+
* dropped from the unwind set, and had its compensate context rebound to another
|
|
30
|
+
* step's result. A colon is a legal character in a user-chosen step name; only the
|
|
31
|
+
* numeric suffix this engine appends is structural.
|
|
32
|
+
*/
|
|
33
|
+
export declare const LOOP_ITERATION_SUFFIX: RegExp;
|
|
34
|
+
/** Is `name` an iteration record of the loop body step `base`? */
|
|
35
|
+
export declare function isIterationOf(name: string, base: string): boolean;
|
|
36
|
+
/** `charge:2` -> `charge`; `charge:extra` -> `charge:extra` (not an iteration). */
|
|
37
|
+
export declare function loopBaseName(name: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* A human-readable description of anything that was thrown.
|
|
40
|
+
*
|
|
41
|
+
* `String(err)` is what this replaced, and for the shape an HTTP client throws most
|
|
42
|
+
* often, a structured object, it yields `"[object Object]"`. That string was then
|
|
43
|
+
* persisted as the diagnostic on a run parked in `compensation-stuck`, which is the
|
|
44
|
+
* state that exists so an operator has something to act on. They were handed a
|
|
45
|
+
* sentence that says nothing about a refund that did not go through
|
|
46
|
+
* (`test/repro-workflow-operator-signal.test.ts`).
|
|
47
|
+
*/
|
|
48
|
+
export declare function describeError(err: unknown): string;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* bunqueue Workflow Engine
|
|
3
|
+
*
|
|
4
|
+
* Lightweight workflow orchestration built on top of bunqueue.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { Workflow, Engine } from 'bunqueue/workflow';
|
|
9
|
+
*
|
|
10
|
+
* const flow = new Workflow('onboarding')
|
|
11
|
+
* .step('create', async (ctx) => { ... })
|
|
12
|
+
* .step('notify', async (ctx) => { ... });
|
|
13
|
+
*
|
|
14
|
+
* const engine = new Engine({ embedded: true });
|
|
15
|
+
* engine.register(flow);
|
|
16
|
+
* const run = await engine.start('onboarding', { email: 'user@test.com' });
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
import "../../require-bun.js";
|
|
20
|
+
export { Workflow } from "./workflow.js";
|
|
21
|
+
export { Engine } from "./engine.js";
|
|
22
|
+
export { WorkflowEmitter } from "./emitter.js";
|
|
23
|
+
export type { StepContext, StepHandler, TypedStepHandler, CompensateHandler, TypedCompensateHandler, StepOptions, SchemaLike, Execution, ExecutionState, ExecutionListOptions, StepState, StepRecord, RollbackStatus, CompensationStatus, CompensationOutcome, BranchCondition, WorkflowNode, EngineOptions, RunHandle, ParallelDefinition, SubWorkflowInputMapper, SubWorkflowOptions, LoopCondition, ForEachItemsExtractor, MapTransformFn, LoopDefinition, ForEachDefinition, MapDefinition, RecoverResult, CleanupOptions, WorkflowEventType, WorkflowEvent, StepEvent, WorkflowLifecycleEvent, SignalEvent, WorkflowEventListener, } from "./types.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loop execution logic for the Workflow Engine.
|
|
3
|
+
*/
|
|
4
|
+
import type { Execution, LoopDefinition } from "./types.js";
|
|
5
|
+
import type { WorkflowEmitter } from "./emitter.js";
|
|
6
|
+
export { executeMap } from "./mapRunner.js";
|
|
7
|
+
export { executeForEach } from "./forEachRunner.js";
|
|
8
|
+
/** Execute a doUntil loop: run steps, then check condition. Repeat until condition returns true. */
|
|
9
|
+
export declare function executeDoUntil(def: LoopDefinition, exec: Execution, emitter: WorkflowEmitter | null, updateFn: (exec: Execution) => void, assertActive?: () => void): Promise<void>;
|
|
10
|
+
/** Execute a doWhile loop: check condition first, then run steps. Repeat while condition is true. */
|
|
11
|
+
export declare function executeDoWhile(def: LoopDefinition, exec: Execution, emitter: WorkflowEmitter | null, updateFn: (exec: Execution) => void, assertActive?: () => void): Promise<void>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { WorkflowEmitter } from "./emitter.js";
|
|
2
|
+
import type { Execution, MapDefinition } from "./types.js";
|
|
3
|
+
/** Execute a map node with the same durable lifecycle signals as a regular step. */
|
|
4
|
+
export declare function executeMap(def: MapDefinition, exec: Execution, emitter: WorkflowEmitter | null, updateFn: (exec: Execution) => void, assertActive?: () => void): Promise<void>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recovery logic for orphaned workflow executions after crash/restart
|
|
3
|
+
*
|
|
4
|
+
* Handles three states:
|
|
5
|
+
* - 'running': re-enqueue the step at currentNodeIndex
|
|
6
|
+
* - 'waiting': re-arm timeout timer or resume if signal already arrived
|
|
7
|
+
* - 'compensating': re-run compensation from the beginning (must be idempotent)
|
|
8
|
+
*/
|
|
9
|
+
import type { Queue } from "../queue/queue.js";
|
|
10
|
+
import type { Workflow } from "./workflow.js";
|
|
11
|
+
import type { WorkflowStore } from "./store.js";
|
|
12
|
+
import type { WorkflowEmitter } from "./emitter.js";
|
|
13
|
+
import type { RecoverResult } from "./types.js";
|
|
14
|
+
import { type TimerHandle } from "./clock.js";
|
|
15
|
+
export interface RecoverDeps {
|
|
16
|
+
store: WorkflowStore;
|
|
17
|
+
queue: Queue;
|
|
18
|
+
workflows: Map<string, Workflow>;
|
|
19
|
+
emitter: WorkflowEmitter | null;
|
|
20
|
+
timeoutTimers: Map<string, TimerHandle>;
|
|
21
|
+
scheduleTimeoutCheck: (id: string, wfName: string, nodeIdx: number, ms: number) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Nodes this engine is executing right now. Recovery consults it for the same reason
|
|
24
|
+
* the `compensating` branch consults the unwind claim: re-enqueueing a node that is
|
|
25
|
+
* already in flight produces a job the admission check will reject, and counting it
|
|
26
|
+
* as a recovery reports work that did not happen. A step running without a bound is
|
|
27
|
+
* the ordinary way to reach this.
|
|
28
|
+
*/
|
|
29
|
+
nodesInFlight: ReadonlySet<string>;
|
|
30
|
+
assertActive: () => void;
|
|
31
|
+
}
|
|
32
|
+
export declare function recoverExecutions(deps: RecoverDeps): Promise<RecoverResult>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Operator actions on a parked unwind.
|
|
3
|
+
*
|
|
4
|
+
* A `compensation-stuck` run is waiting for a human decision, which is why the state
|
|
5
|
+
* is not terminal: the engine has done everything it safely can, and the remaining
|
|
6
|
+
* choice, was the reversal fixed or do we accept a partial rollback, is not one it can
|
|
7
|
+
* make. Both exits are explicit, and both leave the execution record saying exactly
|
|
8
|
+
* what happened.
|
|
9
|
+
*/
|
|
10
|
+
import type { Workflow } from "./workflow.js";
|
|
11
|
+
import type { WorkflowStore } from "./store.js";
|
|
12
|
+
import type { WorkflowEmitter } from "./emitter.js";
|
|
13
|
+
export interface RollbackDeps {
|
|
14
|
+
store: WorkflowStore;
|
|
15
|
+
emitter: WorkflowEmitter | null;
|
|
16
|
+
workflows: Map<string, Workflow>;
|
|
17
|
+
assertActive: () => void;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Retry the compensation that parked the run, then carry on with the rest.
|
|
21
|
+
*
|
|
22
|
+
* The retry is asked for with a FLAG rather than by clearing the failed outcome first.
|
|
23
|
+
* Clearing worked, and it cost more than it bought: it wiped the operator's
|
|
24
|
+
* `compensation-failed` record in memory and persisted that wipe BEFORE running
|
|
25
|
+
* anything, so a resume that then met a failing store left a run whose durable row had
|
|
26
|
+
* lost the very diagnostic the operator was acting on, sitting in `compensating` and
|
|
27
|
+
* therefore handed back by `listRecoverable()` at every subsequent startup. Guarding
|
|
28
|
+
* that needed a deep snapshot, a restore path, and a second write which could itself
|
|
29
|
+
* throw and mask the original error.
|
|
30
|
+
*
|
|
31
|
+
* None of that machinery is needed if nothing is destroyed in the first place. The
|
|
32
|
+
* record stays until a real outcome replaces it, and a store that fails simply leaves
|
|
33
|
+
* the parked run exactly as the operator found it.
|
|
34
|
+
*/
|
|
35
|
+
export declare function resumeCompensation(deps: RollbackDeps, executionId: string): Promise<void>;
|
|
36
|
+
/** Accept a partial rollback: the outstanding steps are recorded as skipped. */
|
|
37
|
+
export declare function abandonParkedCompensation(deps: RollbackDeps, executionId: string): void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WorkflowRunner - Step execution with retry, parallel execution, sub-workflow dispatch
|
|
3
|
+
*/
|
|
4
|
+
import type { StepDefinition, StepContext, Execution } from "./types.js";
|
|
5
|
+
import type { Workflow } from "./workflow.js";
|
|
6
|
+
import type { WorkflowEmitter } from "./emitter.js";
|
|
7
|
+
export { runWithTimeout } from "./runnerTiming.js";
|
|
8
|
+
export { executeSubWorkflow } from "./subWorkflowRunner.js";
|
|
9
|
+
/** Engine hooks a step needs; they always travel together. */
|
|
10
|
+
export interface StepHooks {
|
|
11
|
+
emitter: WorkflowEmitter | null;
|
|
12
|
+
updateFn: (exec: Execution) => void;
|
|
13
|
+
assertActive?: () => void;
|
|
14
|
+
}
|
|
15
|
+
export { isWorkflowExecutionClosed, WorkflowExecutionClosedError } from "./executionFence.js";
|
|
16
|
+
/** Execute a step with retry logic and exponential backoff */
|
|
17
|
+
export declare function executeStepWithRetry(def: StepDefinition, ctx: StepContext, exec: Execution, hooks: StepHooks, occurrence?: number): Promise<void>;
|
|
18
|
+
/** Execute multiple steps in parallel via Promise.allSettled */
|
|
19
|
+
export declare function executeParallelSteps(steps: StepDefinition[], ctx: StepContext, exec: Execution, hooks: StepHooks): Promise<void>;
|
|
20
|
+
/** Find a step definition by name across all node types */
|
|
21
|
+
export declare function findStepDef(wf: Workflow, name: string): StepDefinition | null;
|
|
22
|
+
/** Build a StepContext from the current execution state */
|
|
23
|
+
export declare function buildContext(exec: Execution): StepContext;
|