bunqueue-client 0.1.9 → 0.2.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/CHANGELOG.md +150 -0
- package/LEGACY.md +460 -0
- package/README.md +204 -349
- package/dist/ack-batcher.js +7 -67
- package/dist/canonical-manifest.json +930 -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 +16418 -0
- package/dist/frame.js +14 -57
- package/dist/index.d.ts +1 -27
- package/dist/index.js +10905 -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/clientTracking.d.ts +44 -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 +43 -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/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 +96 -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 +10 -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 +87 -0
- package/dist/types/src/application/types/contexts.d.ts +114 -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 +98 -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 +74 -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 +70 -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 +12 -0
- package/dist/types/src/domain/job/create.d.ts +2 -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 +4 -0
- package/dist/types/src/domain/job/payload.d.ts +18 -0
- package/dist/types/src/domain/job/state.d.ts +8 -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 +110 -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 +91 -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 +153 -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,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured Logger
|
|
3
|
+
* JSON-formatted logging for production environments
|
|
4
|
+
*/
|
|
5
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
6
|
+
export interface LogEntry {
|
|
7
|
+
timestamp: string;
|
|
8
|
+
level: LogLevel;
|
|
9
|
+
component: string;
|
|
10
|
+
message: string;
|
|
11
|
+
reqId?: string;
|
|
12
|
+
data?: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
/** Logger class for structured logging */
|
|
15
|
+
export declare class Logger {
|
|
16
|
+
private readonly component;
|
|
17
|
+
private static jsonMode;
|
|
18
|
+
private static level;
|
|
19
|
+
constructor(component: string);
|
|
20
|
+
/** Enable JSON output mode */
|
|
21
|
+
static enableJsonMode(): void;
|
|
22
|
+
/** Disable JSON output mode (use human-readable) */
|
|
23
|
+
static disableJsonMode(): void;
|
|
24
|
+
/** Set minimum log level */
|
|
25
|
+
static setLevel(level: LogLevel): void;
|
|
26
|
+
debug(message: string, data?: Record<string, unknown>): void;
|
|
27
|
+
/** Emit debug diagnostics on stderr while preserving level filtering. */
|
|
28
|
+
debugToStderr(message: string, data?: Record<string, unknown>): void;
|
|
29
|
+
info(message: string, data?: Record<string, unknown>): void;
|
|
30
|
+
/** Emit informational diagnostics on stderr without inflating their severity. */
|
|
31
|
+
infoToStderr(message: string, data?: Record<string, unknown>): void;
|
|
32
|
+
warn(message: string, data?: Record<string, unknown>): void;
|
|
33
|
+
error(message: string, data?: Record<string, unknown>): void;
|
|
34
|
+
private log;
|
|
35
|
+
}
|
|
36
|
+
/** Create a logger for a component */
|
|
37
|
+
export declare function createLogger(component: string): Logger;
|
|
38
|
+
/** Global loggers */
|
|
39
|
+
export declare const serverLog: Logger;
|
|
40
|
+
export declare const tcpLog: Logger;
|
|
41
|
+
export declare const httpLog: Logger;
|
|
42
|
+
export declare const wsLog: Logger;
|
|
43
|
+
export declare const cronLog: Logger;
|
|
44
|
+
export declare const statsLog: Logger;
|
|
45
|
+
export declare const storageLog: Logger;
|
|
46
|
+
export declare const queueLog: Logger;
|
|
47
|
+
export declare const webhookLog: Logger;
|
|
48
|
+
export declare const backupLog: Logger;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LRU (Least Recently Used) Cache implementations
|
|
3
|
+
* Bounded collections with automatic eviction
|
|
4
|
+
*/
|
|
5
|
+
export { type MapLike, LRUMap } from "./lruMap.js";
|
|
6
|
+
export { type SetLike, LRUSet } from "./lruSet.js";
|
|
7
|
+
export { BoundedSet } from "./boundedSet.js";
|
|
8
|
+
export { BoundedMap } from "./boundedMap.js";
|
|
9
|
+
export { TTLMap } from "./ttlMap.js";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LRU Map - Map with automatic least-recently-used eviction
|
|
3
|
+
*/
|
|
4
|
+
/** Map-like interface for LRU compatibility */
|
|
5
|
+
export interface MapLike<K, V> {
|
|
6
|
+
get(key: K): V | undefined;
|
|
7
|
+
set(key: K, value: V): void;
|
|
8
|
+
has(key: K): boolean;
|
|
9
|
+
delete(key: K): boolean;
|
|
10
|
+
clear(): void;
|
|
11
|
+
readonly size: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* LRU Map - automatically evicts least recently used entries
|
|
15
|
+
* Optimized with doubly-linked list for O(1) move-to-front
|
|
16
|
+
* without delete+re-insert overhead
|
|
17
|
+
*/
|
|
18
|
+
export declare class LRUMap<K, V> implements MapLike<K, V> {
|
|
19
|
+
private readonly cache;
|
|
20
|
+
private readonly maxSize;
|
|
21
|
+
private readonly onEvict?;
|
|
22
|
+
private head;
|
|
23
|
+
private tail;
|
|
24
|
+
constructor(maxSize: number, onEvict?: (key: K, value: V) => void);
|
|
25
|
+
/** Move node to front (most recently used) - O(1) */
|
|
26
|
+
private moveToFront;
|
|
27
|
+
/** Remove node from list - O(1) */
|
|
28
|
+
private removeNode;
|
|
29
|
+
/** Add node to front - O(1) */
|
|
30
|
+
private addToFront;
|
|
31
|
+
get(key: K): V | undefined;
|
|
32
|
+
set(key: K, value: V): void;
|
|
33
|
+
has(key: K): boolean;
|
|
34
|
+
delete(key: K): boolean;
|
|
35
|
+
clear(): void;
|
|
36
|
+
get size(): number;
|
|
37
|
+
keys(): IterableIterator<K>;
|
|
38
|
+
values(): IterableIterator<V>;
|
|
39
|
+
entries(): IterableIterator<[K, V]>;
|
|
40
|
+
forEach(callback: (value: V, key: K) => void): void;
|
|
41
|
+
[Symbol.iterator](): IterableIterator<[K, V]>;
|
|
42
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LRU Set - Set with automatic least-recently-used eviction
|
|
3
|
+
*/
|
|
4
|
+
/** Set-like interface for LRU compatibility */
|
|
5
|
+
export interface SetLike<T> {
|
|
6
|
+
add(value: T): void;
|
|
7
|
+
has(value: T): boolean;
|
|
8
|
+
delete(value: T): boolean;
|
|
9
|
+
clear(): void;
|
|
10
|
+
readonly size: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* LRU Set - automatically evicts least recently used entries
|
|
14
|
+
* Optimized with doubly-linked list for O(1) move-to-front
|
|
15
|
+
*/
|
|
16
|
+
export declare class LRUSet<T> implements SetLike<T> {
|
|
17
|
+
private readonly cache;
|
|
18
|
+
private readonly maxSize;
|
|
19
|
+
private readonly onEvict?;
|
|
20
|
+
private head;
|
|
21
|
+
private tail;
|
|
22
|
+
constructor(maxSize: number, onEvict?: (value: T) => void);
|
|
23
|
+
/** Move node to front - O(1) */
|
|
24
|
+
private moveToFront;
|
|
25
|
+
/** Remove node from list - O(1) */
|
|
26
|
+
private removeNode;
|
|
27
|
+
/** Add node to front - O(1) */
|
|
28
|
+
private addToFront;
|
|
29
|
+
add(value: T): void;
|
|
30
|
+
has(value: T): boolean;
|
|
31
|
+
delete(value: T): boolean;
|
|
32
|
+
clear(): void;
|
|
33
|
+
get size(): number;
|
|
34
|
+
values(): IterableIterator<T>;
|
|
35
|
+
[Symbol.iterator](): IterableIterator<T>;
|
|
36
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic Min-Heap implementation with 4-ary branching
|
|
3
|
+
* 4-ary heap provides better cache locality than binary heap:
|
|
4
|
+
* - Children are stored closer together in memory
|
|
5
|
+
* - Reduces cache misses during bubbleDown (most frequent operation)
|
|
6
|
+
* - 4 comparisons per level vs 2, but fewer levels to traverse
|
|
7
|
+
*
|
|
8
|
+
* O(log₄ n) push/pop, O(1) peek
|
|
9
|
+
*/
|
|
10
|
+
export declare class MinHeap<T> {
|
|
11
|
+
private heap;
|
|
12
|
+
private readonly compare;
|
|
13
|
+
/** Branching factor - 4 provides optimal cache performance on modern CPUs */
|
|
14
|
+
private static readonly D;
|
|
15
|
+
/**
|
|
16
|
+
* Create a min-heap with custom comparator
|
|
17
|
+
* @param compare Returns negative if a < b, positive if a > b, 0 if equal
|
|
18
|
+
*/
|
|
19
|
+
constructor(compare: (a: T, b: T) => number);
|
|
20
|
+
/** Get current size */
|
|
21
|
+
get size(): number;
|
|
22
|
+
/** Check if empty */
|
|
23
|
+
get isEmpty(): boolean;
|
|
24
|
+
/** Push item - O(log n) */
|
|
25
|
+
push(item: T): void;
|
|
26
|
+
/** Pop minimum item - O(log n) */
|
|
27
|
+
pop(): T | undefined;
|
|
28
|
+
/** Peek at minimum without removing - O(1) */
|
|
29
|
+
peek(): T | undefined;
|
|
30
|
+
/** Clear the heap */
|
|
31
|
+
clear(): void;
|
|
32
|
+
/** Get all items (for iteration) */
|
|
33
|
+
toArray(): T[];
|
|
34
|
+
/** Rebuild heap from array - O(n) */
|
|
35
|
+
buildFrom(items: T[]): void;
|
|
36
|
+
/** Remove item by predicate - O(n) */
|
|
37
|
+
removeWhere(predicate: (item: T) => boolean): T | undefined;
|
|
38
|
+
/** 4-ary bubbleUp: parent at floor((idx-1)/4) */
|
|
39
|
+
private bubbleUp;
|
|
40
|
+
/** 4-ary bubbleDown: children at D*idx+1 through D*idx+D */
|
|
41
|
+
private bubbleDown;
|
|
42
|
+
private swap;
|
|
43
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BullMQ paused-view counts (#92).
|
|
3
|
+
*
|
|
4
|
+
* When a queue is paused, none of its ready jobs (waiting + prioritized) can be
|
|
5
|
+
* pulled, so they are reported under `paused` — and NOT in their own buckets, to
|
|
6
|
+
* avoid double-counting a single job. This mirrors the per-state lists, where a
|
|
7
|
+
* paused queue lists those jobs under `paused` and returns nothing for `waiting`
|
|
8
|
+
* / `prioritized`. Delayed and active jobs keep their own state.
|
|
9
|
+
*
|
|
10
|
+
* Single source of truth shared by every count surface that exposes the BullMQ
|
|
11
|
+
* `getJobCounts` shape (client SDK, TCP handler, dashboard detail), so they can
|
|
12
|
+
* never drift apart.
|
|
13
|
+
*/
|
|
14
|
+
export interface PausedDerivedCounts {
|
|
15
|
+
waiting: number;
|
|
16
|
+
prioritized: number;
|
|
17
|
+
paused: number;
|
|
18
|
+
}
|
|
19
|
+
export declare function pausedView(waiting: number, prioritized: number, isPaused: boolean): PausedDerivedCounts;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Writer-priority read/write lock with FIFO writer handoff. */
|
|
2
|
+
import type { LockGuard } from "./types/lock.js";
|
|
3
|
+
export declare class RWLock {
|
|
4
|
+
private readers;
|
|
5
|
+
private writer;
|
|
6
|
+
private writerWaiting;
|
|
7
|
+
private readonly readerQueue;
|
|
8
|
+
private readonly writerQueue;
|
|
9
|
+
acquireRead(timeoutMs?: number): Promise<LockGuard>;
|
|
10
|
+
acquireWrite(timeoutMs?: number): Promise<LockGuard>;
|
|
11
|
+
getState(): {
|
|
12
|
+
readers: number;
|
|
13
|
+
writer: boolean;
|
|
14
|
+
writerWaiting: number;
|
|
15
|
+
};
|
|
16
|
+
private createWaiter;
|
|
17
|
+
private drain;
|
|
18
|
+
private takeWriter;
|
|
19
|
+
private grantReaders;
|
|
20
|
+
private createReadGuard;
|
|
21
|
+
private createWriteGuard;
|
|
22
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serialization utilities
|
|
3
|
+
* Handle BigInt and other special types for JSON serialization
|
|
4
|
+
*/
|
|
5
|
+
import type { Job } from "../domain/types/job.js";
|
|
6
|
+
/** Compare Unicode text in the same code-point order as SQLite BINARY UTF-8 text. */
|
|
7
|
+
export declare function compareSqliteBinaryText(left: string, right: string): number;
|
|
8
|
+
/**
|
|
9
|
+
* Serialize a Job for JSON output
|
|
10
|
+
* Converts BigInt IDs to strings
|
|
11
|
+
*/
|
|
12
|
+
export declare function serializeJob(job: Job): Record<string, unknown>;
|
|
13
|
+
/**
|
|
14
|
+
* Serialize multiple jobs
|
|
15
|
+
*/
|
|
16
|
+
export declare function serializeJobs(jobs: Job[]): Record<string, unknown>[];
|
|
17
|
+
/**
|
|
18
|
+
* Custom JSON replacer for BigInt
|
|
19
|
+
*/
|
|
20
|
+
export declare function bigIntReplacer(_key: string, value: unknown): unknown;
|
|
21
|
+
/**
|
|
22
|
+
* Stringify with BigInt support
|
|
23
|
+
*/
|
|
24
|
+
export declare function jsonStringify(value: unknown): string;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skip List with O(log n) operations
|
|
3
|
+
* - insert: O(log n)
|
|
4
|
+
* - delete: O(log n)
|
|
5
|
+
* - search: O(log n)
|
|
6
|
+
* - range query: O(log n + k) where k = results
|
|
7
|
+
*/
|
|
8
|
+
export declare class SkipList<T> {
|
|
9
|
+
private readonly maxLevel;
|
|
10
|
+
private readonly probability;
|
|
11
|
+
private readonly compare;
|
|
12
|
+
private readonly equals?;
|
|
13
|
+
private head;
|
|
14
|
+
private level;
|
|
15
|
+
private _size;
|
|
16
|
+
/**
|
|
17
|
+
* Create a skip list
|
|
18
|
+
* @param compare Comparator function (negative if a < b, positive if a > b, 0 if equal)
|
|
19
|
+
* @param maxLevel Maximum level (default 16, supports ~65k elements efficiently)
|
|
20
|
+
* @param probability Level promotion probability (default 0.5)
|
|
21
|
+
* @param equals Optional equality function for duplicate detection. If provided,
|
|
22
|
+
* duplicates where equals returns true are skipped during insert.
|
|
23
|
+
* If not provided, multiple entries with same comparator result are allowed.
|
|
24
|
+
*/
|
|
25
|
+
constructor(compare: (a: T, b: T) => number, maxLevel?: number, probability?: number, equals?: (a: T, b: T) => boolean);
|
|
26
|
+
/** Current number of elements */
|
|
27
|
+
get size(): number;
|
|
28
|
+
/** Check if empty */
|
|
29
|
+
get isEmpty(): boolean;
|
|
30
|
+
/** Generate random level for new node */
|
|
31
|
+
private randomLevel;
|
|
32
|
+
/**
|
|
33
|
+
* Insert value - O(log n)
|
|
34
|
+
* If an equals function was provided to the constructor, duplicates
|
|
35
|
+
* (where equals returns true) are skipped. Otherwise, multiple entries
|
|
36
|
+
* with the same comparator result are allowed (sorted multiset behavior).
|
|
37
|
+
* @returns true if inserted, false if duplicate was skipped
|
|
38
|
+
*/
|
|
39
|
+
insert(value: T): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Delete value - O(log n)
|
|
42
|
+
* @returns true if found and deleted
|
|
43
|
+
*/
|
|
44
|
+
delete(value: T): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Delete by predicate - O(n) worst case, but typically O(log n + k)
|
|
47
|
+
* Useful when you need to match by a subset of fields
|
|
48
|
+
*/
|
|
49
|
+
deleteWhere(predicate: (value: T) => boolean): T | null;
|
|
50
|
+
/**
|
|
51
|
+
* Find exact value - O(log n)
|
|
52
|
+
*/
|
|
53
|
+
find(value: T): T | null;
|
|
54
|
+
/**
|
|
55
|
+
* Check if value exists - O(log n)
|
|
56
|
+
*/
|
|
57
|
+
has(value: T): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Get first (minimum) element - O(1)
|
|
60
|
+
*/
|
|
61
|
+
first(): T | null;
|
|
62
|
+
/**
|
|
63
|
+
* Remove and return first element - O(log n)
|
|
64
|
+
*/
|
|
65
|
+
shift(): T | null;
|
|
66
|
+
/**
|
|
67
|
+
* Range query: get all values where comparator returns <= 0
|
|
68
|
+
* O(log n + k) where k = number of results
|
|
69
|
+
* @param maxValue Upper bound (inclusive)
|
|
70
|
+
* @param limit Maximum number of results
|
|
71
|
+
*/
|
|
72
|
+
rangeUntil(maxValue: T, limit?: number): T[];
|
|
73
|
+
/**
|
|
74
|
+
* Get all values where predicate is true, starting from first
|
|
75
|
+
* Stops at first false (assumes sorted order matches predicate)
|
|
76
|
+
* O(k) where k = matching results
|
|
77
|
+
*/
|
|
78
|
+
takeWhile(predicate: (value: T) => boolean, limit?: number): T[];
|
|
79
|
+
/**
|
|
80
|
+
* Iterate all values in order
|
|
81
|
+
*/
|
|
82
|
+
values(): Generator<T>;
|
|
83
|
+
/**
|
|
84
|
+
* Convert to array
|
|
85
|
+
*/
|
|
86
|
+
toArray(): T[];
|
|
87
|
+
/**
|
|
88
|
+
* Clear all elements
|
|
89
|
+
*/
|
|
90
|
+
clear(): void;
|
|
91
|
+
/**
|
|
92
|
+
* Filter and remove elements matching predicate
|
|
93
|
+
* Returns removed elements
|
|
94
|
+
* O(n) but removes in-place
|
|
95
|
+
*/
|
|
96
|
+
removeAll(predicate: (value: T) => boolean): T[];
|
|
97
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SkipNode } from "./types/skipList.js";
|
|
2
|
+
export declare function randomSkipLevel(probability: number, maxLevel: number): number;
|
|
3
|
+
export declare function createSkipHead<T>(maxLevel: number): SkipNode<T>;
|
|
4
|
+
export declare function collectSkipRange<T>(first: SkipNode<T> | null, predicate: (value: T) => boolean, limit?: number): T[];
|
|
5
|
+
export declare function iterateSkipValues<T>(first: SkipNode<T> | null): Generator<T>;
|
|
6
|
+
export declare function removeMatchingSkipValues<T>(first: SkipNode<T> | null, predicate: (value: T) => boolean, remove: (value: T) => void): T[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface StorageHealthStatus {
|
|
2
|
+
readonly diskFull: boolean;
|
|
3
|
+
readonly error: string | null;
|
|
4
|
+
readonly since: number | null;
|
|
5
|
+
}
|
|
6
|
+
/** A storage error is degraded even when the underlying failure is not a full disk. */
|
|
7
|
+
export declare function isStorageDegraded(status: StorageHealthStatus): boolean;
|
|
8
|
+
/** Project internal health into a client-safe copy without mutating runtime diagnostics. */
|
|
9
|
+
export declare function clientStorageStatus(status: StorageHealthStatus): StorageHealthStatus;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TTL Map - entries expire after timeout
|
|
3
|
+
* Optimized with MinHeap for O(log n) insert and O(k) cleanup
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* TTL Map - entries expire after timeout
|
|
7
|
+
* Optimized with MinHeap for O(log n) insert and O(k) cleanup
|
|
8
|
+
*
|
|
9
|
+
* IMPORTANT: You MUST call stop() when done with this instance to prevent memory leaks.
|
|
10
|
+
* The cleanup interval will keep running until stop() is called, preventing the instance
|
|
11
|
+
* from being garbage collected.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const map = new TTLMap<string, number>(60_000); // 60s TTL
|
|
16
|
+
* try {
|
|
17
|
+
* map.set('key', 123);
|
|
18
|
+
* // use map...
|
|
19
|
+
* } finally {
|
|
20
|
+
* map.stop(); // REQUIRED: stops cleanup interval
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* Memory leak prevention:
|
|
25
|
+
* - Each heap entry stores (expiresAt, key)
|
|
26
|
+
* - During cleanup, we verify the key still exists in cache AND has matching expiresAt
|
|
27
|
+
* - Stale entries (deleted keys or updated TTLs) are skipped and removed from heap
|
|
28
|
+
* - Periodic compaction rebuilds heap when stale ratio exceeds threshold
|
|
29
|
+
*/
|
|
30
|
+
export declare class TTLMap<K, V> {
|
|
31
|
+
private readonly cache;
|
|
32
|
+
private readonly ttlMs;
|
|
33
|
+
private cleanupInterval;
|
|
34
|
+
/**
|
|
35
|
+
* Expiry heap: MinHeap of (expiresAt, key) for efficient cleanup
|
|
36
|
+
* O(log n) insert instead of O(n) with array splice
|
|
37
|
+
*/
|
|
38
|
+
private readonly expiryHeap;
|
|
39
|
+
/** Count of stale entries in heap (deleted or updated keys) */
|
|
40
|
+
private staleCount;
|
|
41
|
+
/** Rebuild heap when stale entries exceed this ratio of heap size */
|
|
42
|
+
private static readonly COMPACTION_THRESHOLD;
|
|
43
|
+
/** Minimum heap size before considering compaction (avoid frequent rebuilds for small heaps) */
|
|
44
|
+
private static readonly MIN_COMPACTION_SIZE;
|
|
45
|
+
/**
|
|
46
|
+
* Create a new TTLMap instance.
|
|
47
|
+
*
|
|
48
|
+
* @param ttlMs - Default time-to-live for entries in milliseconds
|
|
49
|
+
* @param cleanupIntervalMs - Interval between cleanup runs (default: 60000ms / 1 minute).
|
|
50
|
+
* Lower values = more frequent cleanup but higher CPU usage.
|
|
51
|
+
* Set based on expected entry volume and TTL duration.
|
|
52
|
+
*/
|
|
53
|
+
constructor(ttlMs: number, cleanupIntervalMs?: number);
|
|
54
|
+
private startCleanup;
|
|
55
|
+
/** O(k log n) cleanup where k = expired entries */
|
|
56
|
+
private cleanup;
|
|
57
|
+
/**
|
|
58
|
+
* Rebuild heap if stale entry ratio exceeds threshold
|
|
59
|
+
* This prevents unbounded heap growth from delete() and set() updates
|
|
60
|
+
*/
|
|
61
|
+
private maybeCompact;
|
|
62
|
+
/** Rebuild heap with only valid entries - O(n log n) */
|
|
63
|
+
private rebuildHeap;
|
|
64
|
+
get(key: K): V | undefined;
|
|
65
|
+
/** O(log n) insert with MinHeap instead of O(n) with array splice */
|
|
66
|
+
set(key: K, value: V, ttlMs?: number): void;
|
|
67
|
+
has(key: K): boolean;
|
|
68
|
+
delete(key: K): boolean;
|
|
69
|
+
clear(): void;
|
|
70
|
+
/**
|
|
71
|
+
* Stop the cleanup interval. MUST be called when done with this instance
|
|
72
|
+
* to prevent memory leaks. The interval keeps a reference to the instance,
|
|
73
|
+
* preventing garbage collection until stop() is called.
|
|
74
|
+
*/
|
|
75
|
+
stop(): void;
|
|
76
|
+
get size(): number;
|
|
77
|
+
/** Get heap size (for debugging/monitoring) */
|
|
78
|
+
get heapSize(): number;
|
|
79
|
+
/** Get count of stale heap entries (for debugging/monitoring) */
|
|
80
|
+
get staleEntryCount(): number;
|
|
81
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Webhook URL Validation
|
|
3
|
+
* SSRF prevention for webhook URLs — shared between server handlers and embedded SDK
|
|
4
|
+
*/
|
|
5
|
+
/** Validate webhook URL to prevent SSRF. Returns error message or null if valid. */
|
|
6
|
+
export declare function validateWebhookUrl(url: string): string | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bunqueue-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Cross-runtime TypeScript client for the bunqueue job queue server — Node.js, Bun, Deno and Cloudflare Workers",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -11,12 +11,17 @@
|
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"import": "./dist/index.js"
|
|
13
13
|
},
|
|
14
|
+
"./legacy": {
|
|
15
|
+
"types": "./dist/legacy.d.ts",
|
|
16
|
+
"import": "./dist/legacy.js"
|
|
17
|
+
},
|
|
14
18
|
"./package.json": "./package.json"
|
|
15
19
|
},
|
|
16
20
|
"files": [
|
|
17
21
|
"dist",
|
|
18
22
|
"src",
|
|
19
23
|
"README.md",
|
|
24
|
+
"LEGACY.md",
|
|
20
25
|
"CHANGELOG.md",
|
|
21
26
|
"LICENSE"
|
|
22
27
|
],
|
|
@@ -24,14 +29,22 @@
|
|
|
24
29
|
"node": ">=20"
|
|
25
30
|
},
|
|
26
31
|
"scripts": {
|
|
27
|
-
"build": "
|
|
32
|
+
"build": "bun ../../scripts/build-portable-client.ts && bun ../../scripts/check-client-parity.ts",
|
|
28
33
|
"prepublishOnly": "bun run build",
|
|
29
34
|
"test": "bun tests/e2e.ts",
|
|
35
|
+
"test:parity": "bun ../../scripts/check-client-parity.ts && BUNQUEUE_EMBEDDED=1 bun test ../../test/typescript-client-parity.test.ts ../../test/client-parity-*.test.ts ../../test/tcp-parity-*.test.ts",
|
|
36
|
+
"test:canonical": "bun tests/canonical-queue.mjs && bun tests/canonical-worker.mjs",
|
|
37
|
+
"test:shared-contract": "BUNQUEUE_EMBEDDED=1 bun test --parallel=4 --preload ../../scripts/client-parity/preload.ts ../../test/docs-queue-guide ../../test/docs-worker-guide ../../test/docs-quickstart.test.ts",
|
|
38
|
+
"test:property": "bun test tests/flow-plan.property.test.ts tests/flow-identity.property.test.ts tests/flow-plan.validation.test.ts tests/flow-plan.limits.test.ts tests/flow-plan.contract.test.ts tests/flow-commit.test.ts tests/worker-slot-signal.test.ts",
|
|
30
39
|
"test:integration": "bun tests/integration.ts",
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
40
|
+
"test:soak": "bun tests/soak.ts",
|
|
41
|
+
"lint": "oxlint src tests",
|
|
42
|
+
"lint:fix": "oxlint --fix src tests",
|
|
43
|
+
"format": "oxfmt --write src tests",
|
|
44
|
+
"format:check": "oxfmt --check src tests",
|
|
45
|
+
"check:oxc": "bun run lint && bun run format:check",
|
|
46
|
+
"check": "bun run check:oxc",
|
|
47
|
+
"test:workers": "cd tests/workers && bun install --frozen-lockfile && cd ../.. && bun pm pack --destination tests/workers && cd tests/workers && mv bunqueue-client-*.tgz bunqueue-client.tgz && rm -rf node_modules/bunqueue-client && mkdir -p node_modules/bunqueue-client && tar -xzf bunqueue-client.tgz -C node_modules/bunqueue-client --strip-components=1 && node run.mjs"
|
|
35
48
|
},
|
|
36
49
|
"keywords": [
|
|
37
50
|
"queue",
|
|
@@ -49,8 +62,13 @@
|
|
|
49
62
|
"msgpackr": "^1.11.8"
|
|
50
63
|
},
|
|
51
64
|
"devDependencies": {
|
|
52
|
-
"
|
|
53
|
-
"@types/node": "
|
|
65
|
+
"@types/node-20": "npm:@types/node@20.19.43",
|
|
66
|
+
"@types/node-22": "npm:@types/node@22.20.4",
|
|
67
|
+
"fast-check": "4.9.0",
|
|
68
|
+
"oxfmt": "0.64.0",
|
|
69
|
+
"oxlint": "1.79.0",
|
|
70
|
+
"oxlint-tsgolint": "7.0.2001",
|
|
71
|
+
"typescript": "^5.7.0"
|
|
54
72
|
},
|
|
55
73
|
"author": "Egeo Minotti",
|
|
56
74
|
"homepage": "https://bunqueue.dev/guide/sdks/",
|
|
@@ -63,4 +81,4 @@
|
|
|
63
81
|
"url": "https://github.com/egeominotti/bunqueue/issues"
|
|
64
82
|
},
|
|
65
83
|
"sideEffects": false
|
|
66
|
-
}
|
|
84
|
+
}
|
package/src/ack-batcher.ts
CHANGED
|
@@ -10,13 +10,14 @@
|
|
|
10
10
|
|
|
11
11
|
import type { Connection } from './connection.js';
|
|
12
12
|
import { compact } from './frame.js';
|
|
13
|
+
import { ignoredAckIndices } from './terminal-outcome.js';
|
|
13
14
|
|
|
14
15
|
export interface AckItem {
|
|
15
16
|
id: string;
|
|
16
17
|
token: string;
|
|
17
18
|
result: unknown;
|
|
18
|
-
/**
|
|
19
|
-
onSettled: (err?: unknown) => void;
|
|
19
|
+
/** `applied` is defined only after a successful, authoritative response. */
|
|
20
|
+
onSettled: (err?: unknown, applied?: boolean) => void;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
export class AckBatcher {
|
|
@@ -52,8 +53,9 @@ export class AckBatcher {
|
|
|
52
53
|
// a throwing callback can neither be re-invoked with an error (double
|
|
53
54
|
// settle) nor starve the remaining items of their callback.
|
|
54
55
|
let error: unknown;
|
|
56
|
+
let ignoredIndices: ReadonlySet<number> = new Set();
|
|
55
57
|
try {
|
|
56
|
-
await this.connection.call(
|
|
58
|
+
const response = await this.connection.call(
|
|
57
59
|
compact({
|
|
58
60
|
cmd: 'ACKB',
|
|
59
61
|
ids: batch.map((b) => b.id),
|
|
@@ -61,12 +63,13 @@ export class AckBatcher {
|
|
|
61
63
|
results: batch.map((b) => b.result),
|
|
62
64
|
}) as { cmd: string }
|
|
63
65
|
);
|
|
66
|
+
ignoredIndices = ignoredAckIndices(response.data, batch);
|
|
64
67
|
} catch (err) {
|
|
65
68
|
error = err ?? new Error('ACKB failed');
|
|
66
69
|
}
|
|
67
|
-
for (
|
|
70
|
+
for (let index = 0; index < batch.length; index++) {
|
|
68
71
|
try {
|
|
69
|
-
|
|
72
|
+
batch[index].onSettled(error, error === undefined ? !ignoredIndices.has(index) : undefined);
|
|
70
73
|
} catch {
|
|
71
74
|
// A callback error (e.g. an unhandled 'error' emit in the worker)
|
|
72
75
|
// must never prevent the other items from settling.
|
|
@@ -11,7 +11,7 @@ import type { DlqFilter, DlqStats } from './dlq-rate-limit.js';
|
|
|
11
11
|
import type { CircuitState, TriggerRule } from './types.js';
|
|
12
12
|
|
|
13
13
|
type Raw = Record<string, unknown>;
|
|
14
|
-
//
|
|
14
|
+
// oxlint-disable-next-line typescript/no-explicit-any -- mixin context needs the erased generic instance
|
|
15
15
|
type Ctx = Bunqueue<any, any>;
|
|
16
16
|
|
|
17
17
|
export const bunqueueApi = {
|
package/src/bunqueue/bunqueue.ts
CHANGED
|
@@ -26,7 +26,7 @@ import type { BunqueueMiddleware, BunqueueOptions } from './types.js';
|
|
|
26
26
|
|
|
27
27
|
type Raw = Record<string, unknown>;
|
|
28
28
|
|
|
29
|
-
//
|
|
29
|
+
// oxlint-disable-next-line typescript/no-unsafe-declaration-merging -- prototype-mixin composition installs the BunqueueApi methods with Object.assign below
|
|
30
30
|
export class Bunqueue<T = unknown, R = unknown> {
|
|
31
31
|
readonly name: string;
|
|
32
32
|
readonly queue: Queue<T>;
|
|
@@ -219,6 +219,7 @@ export class Bunqueue<T = unknown, R = unknown> {
|
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
+
// oxlint-disable-next-line typescript/no-empty-object-type -- declaration merging exposes the methods installed below
|
|
222
223
|
export interface Bunqueue<T = unknown, R = unknown> extends BunqueueApi<T, R> {}
|
|
223
224
|
|
|
224
225
|
Object.assign(Bunqueue.prototype, bunqueueApi);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Declaration-only stand-in for Bun's `bun:sqlite` module in the published
|
|
3
|
+
* type graph. The embedded engine runs only under Bun; the portable build
|
|
4
|
+
* points engine declarations here so Node, Deno and Workers consumers never
|
|
5
|
+
* need Bun's global type declarations. Nothing imports this at runtime.
|
|
6
|
+
*/
|
|
7
|
+
export interface Statement {
|
|
8
|
+
run(...parameters: unknown[]): unknown;
|
|
9
|
+
get(...parameters: unknown[]): unknown;
|
|
10
|
+
all(...parameters: unknown[]): unknown[];
|
|
11
|
+
values(...parameters: unknown[]): unknown[][];
|
|
12
|
+
finalize(): void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface Database {
|
|
16
|
+
prepare(sql: string): Statement;
|
|
17
|
+
query(sql: string): Statement;
|
|
18
|
+
run(sql: string, ...parameters: unknown[]): unknown;
|
|
19
|
+
exec(sql: string, ...parameters: unknown[]): unknown;
|
|
20
|
+
transaction<T extends (...parameters: never[]) => unknown>(run: T): T;
|
|
21
|
+
close(throwOnError?: boolean): void;
|
|
22
|
+
}
|