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.
Files changed (582) hide show
  1. package/CHANGELOG.md +165 -0
  2. package/LEGACY.md +460 -0
  3. package/README.md +204 -349
  4. package/dist/ack-batcher.js +7 -67
  5. package/dist/canonical-manifest.json +934 -0
  6. package/dist/chunk-b967v3w3.js +79 -0
  7. package/dist/chunk-fekm0ma6.js +110 -0
  8. package/dist/chunk-jxkszwqp.js +573 -0
  9. package/dist/embedded.js +16510 -0
  10. package/dist/frame.js +14 -57
  11. package/dist/index.d.ts +1 -27
  12. package/dist/index.js +10953 -16
  13. package/dist/legacy.d.ts +1 -0
  14. package/dist/legacy.js +2081 -0
  15. package/dist/{ack-batcher.d.ts → types/sdk/typescript/src/ack-batcher.d.ts} +3 -3
  16. package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/aging.d.ts +2 -2
  17. package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/batch.d.ts +2 -2
  18. package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/bunqueue-api.d.ts +5 -5
  19. package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/bunqueue.d.ts +13 -13
  20. package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/circuit-breaker.d.ts +2 -2
  21. package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/dedup-debounce.d.ts +2 -2
  22. package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/dlq-rate-limit.d.ts +2 -2
  23. package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/rate-gate.d.ts +1 -1
  24. package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/retry.d.ts +1 -1
  25. package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/triggers.d.ts +3 -3
  26. package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/ttl.d.ts +1 -1
  27. package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/types.d.ts +4 -4
  28. package/dist/types/sdk/typescript/src/canonical-transport/bun-sqlite-types.d.ts +21 -0
  29. package/dist/{connection-pool.d.ts → types/sdk/typescript/src/connection-pool.d.ts} +1 -1
  30. package/dist/{connection-types.d.ts → types/sdk/typescript/src/connection-types.d.ts} +1 -1
  31. package/dist/{connection.d.ts → types/sdk/typescript/src/connection.d.ts} +6 -19
  32. package/dist/{errors.d.ts → types/sdk/typescript/src/errors.d.ts} +3 -0
  33. package/dist/types/sdk/typescript/src/flow-commit.d.ts +5 -0
  34. package/dist/types/sdk/typescript/src/flow-plan-legacy.d.ts +13 -0
  35. package/dist/types/sdk/typescript/src/flow-plan.d.ts +29 -0
  36. package/dist/{flow-types.d.ts → types/sdk/typescript/src/flow-types.d.ts} +7 -4
  37. package/dist/{flow.d.ts → types/sdk/typescript/src/flow.d.ts} +6 -10
  38. package/dist/{frame.d.ts → types/sdk/typescript/src/frame.d.ts} +1 -1
  39. package/dist/types/sdk/typescript/src/index.d.ts +10 -0
  40. package/dist/{job.d.ts → types/sdk/typescript/src/job.d.ts} +4 -3
  41. package/dist/types/sdk/typescript/src/legacy.d.ts +27 -0
  42. package/dist/{observability.d.ts → types/sdk/typescript/src/observability.d.ts} +14 -0
  43. package/dist/{queue-admin.d.ts → types/sdk/typescript/src/queue-admin.d.ts} +3 -4
  44. package/dist/{queue-control.d.ts → types/sdk/typescript/src/queue-control.d.ts} +5 -5
  45. package/dist/{queue-query.d.ts → types/sdk/typescript/src/queue-query.d.ts} +3 -3
  46. package/dist/{queue.d.ts → types/sdk/typescript/src/queue.d.ts} +8 -8
  47. package/dist/{responses.d.ts → types/sdk/typescript/src/responses.d.ts} +2 -2
  48. package/dist/types/sdk/typescript/src/serialization.d.ts +10 -0
  49. package/dist/{socket-factory.d.ts → types/sdk/typescript/src/socket-factory.d.ts} +1 -1
  50. package/dist/types/sdk/typescript/src/terminal-outcome.d.ts +8 -0
  51. package/dist/{types.d.ts → types/sdk/typescript/src/types.d.ts} +5 -2
  52. package/dist/{worker-base.d.ts → types/sdk/typescript/src/worker-base.d.ts} +6 -6
  53. package/dist/types/sdk/typescript/src/worker-slot-signal.d.ts +6 -0
  54. package/dist/{worker-types.d.ts → types/sdk/typescript/src/worker-types.d.ts} +3 -3
  55. package/dist/{worker.d.ts → types/sdk/typescript/src/worker.d.ts} +3 -2
  56. package/dist/types/src/application/background/dlq.d.ts +2 -0
  57. package/dist/types/src/application/background/lifecycle.d.ts +4 -0
  58. package/dist/types/src/application/background/recovery/active.d.ts +5 -0
  59. package/dist/types/src/application/background/recovery/index.d.ts +2 -0
  60. package/dist/types/src/application/background/recovery/pending.d.ts +3 -0
  61. package/dist/types/src/application/background/recovery/restore.d.ts +5 -0
  62. package/dist/types/src/application/background/recovery/shared.d.ts +6 -0
  63. package/dist/types/src/application/background/timeouts.d.ts +25 -0
  64. package/dist/types/src/application/backgroundTasks.d.ts +7 -0
  65. package/dist/types/src/application/cleanupTasks.d.ts +10 -0
  66. package/dist/types/src/application/clientOwnership.d.ts +65 -0
  67. package/dist/types/src/application/clientTracking.d.ts +40 -0
  68. package/dist/types/src/application/completedCleanup.d.ts +34 -0
  69. package/dist/types/src/application/completedRetry.d.ts +21 -0
  70. package/dist/types/src/application/contextFactory.d.ts +49 -0
  71. package/dist/types/src/application/dependencyCompletions.d.ts +63 -0
  72. package/dist/types/src/application/dependencyProcessor.d.ts +15 -0
  73. package/dist/types/src/application/dependencyResultTracker.d.ts +18 -0
  74. package/dist/types/src/application/dlqManager.d.ts +49 -0
  75. package/dist/types/src/application/dlqRetry.d.ts +12 -0
  76. package/dist/types/src/application/emptyQueueCleanup.d.ts +3 -0
  77. package/dist/types/src/application/eventsManager.d.ts +50 -0
  78. package/dist/types/src/application/flowFailureRecovery.d.ts +20 -0
  79. package/dist/types/src/application/flowParentBackpatch.d.ts +27 -0
  80. package/dist/types/src/application/jobLogsManager.d.ts +21 -0
  81. package/dist/types/src/application/latencyTracker.d.ts +39 -0
  82. package/dist/types/src/application/lockManager.d.ts +15 -0
  83. package/dist/types/src/application/lockOperations.d.ts +38 -0
  84. package/dist/types/src/application/metricsExporter.d.ts +27 -0
  85. package/dist/types/src/application/monitoringChecks.d.ts +36 -0
  86. package/dist/types/src/application/operations/ack/batch.d.ts +8 -0
  87. package/dist/types/src/application/operations/ack/completion.d.ts +3 -0
  88. package/dist/types/src/application/operations/ack/failure.d.ts +3 -0
  89. package/dist/types/src/application/operations/ack.d.ts +5 -0
  90. package/dist/types/src/application/operations/ackHelpers.d.ts +36 -0
  91. package/dist/types/src/application/operations/customId.d.ts +51 -0
  92. package/dist/types/src/application/operations/flowPush.d.ts +9 -0
  93. package/dist/types/src/application/operations/flowTopologyValidation.d.ts +3 -0
  94. package/dist/types/src/application/operations/flowValidation.d.ts +3 -0
  95. package/dist/types/src/application/operations/jobClaim.d.ts +17 -0
  96. package/dist/types/src/application/operations/jobManagement.d.ts +45 -0
  97. package/dist/types/src/application/operations/jobMoveOperations.d.ts +9 -0
  98. package/dist/types/src/application/operations/jobPromotion.d.ts +7 -0
  99. package/dist/types/src/application/operations/jobStateTransitions.d.ts +15 -0
  100. package/dist/types/src/application/operations/parentLink.d.ts +36 -0
  101. package/dist/types/src/application/operations/parentLinkInput.d.ts +8 -0
  102. package/dist/types/src/application/operations/pull.d.ts +20 -0
  103. package/dist/types/src/application/operations/pullFinalization.d.ts +6 -0
  104. package/dist/types/src/application/operations/pullStateTransition.d.ts +51 -0
  105. package/dist/types/src/application/operations/push.d.ts +13 -0
  106. package/dist/types/src/application/operations/pushAdmission.d.ts +36 -0
  107. package/dist/types/src/application/operations/pushBatch.d.ts +4 -0
  108. package/dist/types/src/application/operations/pushContext.d.ts +48 -0
  109. package/dist/types/src/application/operations/pushDeduplication.d.ts +42 -0
  110. package/dist/types/src/application/operations/pushInsert.d.ts +39 -0
  111. package/dist/types/src/application/operations/pushLocks.d.ts +15 -0
  112. package/dist/types/src/application/operations/query/collect.d.ts +12 -0
  113. package/dist/types/src/application/operations/query/jobLookup.d.ts +9 -0
  114. package/dist/types/src/application/operations/query/pagination.d.ts +8 -0
  115. package/dist/types/src/application/operations/query/state.d.ts +4 -0
  116. package/dist/types/src/application/operations/queryOperations.d.ts +5 -0
  117. package/dist/types/src/application/operations/queueControl.d.ts +50 -0
  118. package/dist/types/src/application/orphanRecovery.d.ts +25 -0
  119. package/dist/types/src/application/prometheusOperationalMetrics.d.ts +31 -0
  120. package/dist/types/src/application/queue-manager/ack.d.ts +23 -0
  121. package/dist/types/src/application/queue-manager/configuration.d.ts +27 -0
  122. package/dist/types/src/application/queue-manager/context.d.ts +5 -0
  123. package/dist/types/src/application/queue-manager/control.d.ts +20 -0
  124. package/dist/types/src/application/queue-manager/delivery.d.ts +33 -0
  125. package/dist/types/src/application/queue-manager/dependencies.d.ts +8 -0
  126. package/dist/types/src/application/queue-manager/dependency-runtime.d.ts +8 -0
  127. package/dist/types/src/application/queue-manager/flow-failures.d.ts +18 -0
  128. package/dist/types/src/application/queue-manager/flow-options.d.ts +8 -0
  129. package/dist/types/src/application/queue-manager/job-management.d.ts +17 -0
  130. package/dist/types/src/application/queue-manager/lifecycle.d.ts +4 -0
  131. package/dist/types/src/application/queue-manager/limits.d.ts +58 -0
  132. package/dist/types/src/application/queue-manager/locks.d.ts +21 -0
  133. package/dist/types/src/application/queue-manager/observability.d.ts +16 -0
  134. package/dist/types/src/application/queue-manager/queries.d.ts +24 -0
  135. package/dist/types/src/application/queue-manager/repeat.d.ts +4 -0
  136. package/dist/types/src/application/queue-manager/services.d.ts +19 -0
  137. package/dist/types/src/application/queue-manager/state.d.ts +98 -0
  138. package/dist/types/src/application/queue-manager/stats.d.ts +28 -0
  139. package/dist/types/src/application/queueManager.d.ts +5 -0
  140. package/dist/types/src/application/queueStatsAggregator.d.ts +23 -0
  141. package/dist/types/src/application/queueTelemetryJournal.d.ts +24 -0
  142. package/dist/types/src/application/repeatJobs.d.ts +7 -0
  143. package/dist/types/src/application/stallDetection.d.ts +26 -0
  144. package/dist/types/src/application/statsManager.d.ts +59 -0
  145. package/dist/types/src/application/taskErrorTracking.d.ts +22 -0
  146. package/dist/types/src/application/throughputTracker.d.ts +34 -0
  147. package/dist/types/src/application/types/ack.d.ts +136 -0
  148. package/dist/types/src/application/types/background.d.ts +18 -0
  149. package/dist/types/src/application/types/config.d.ts +41 -0
  150. package/dist/types/src/application/types/contextFactory.d.ts +89 -0
  151. package/dist/types/src/application/types/contexts.d.ts +117 -0
  152. package/dist/types/src/application/types/index.d.ts +7 -0
  153. package/dist/types/src/application/types/query.d.ts +23 -0
  154. package/dist/types/src/application/types/queueManager.d.ts +100 -0
  155. package/dist/types/src/application/webhookManager.d.ts +47 -0
  156. package/dist/types/src/application/workerManager.d.ts +61 -0
  157. package/dist/types/src/client/bunqueue/aging.d.ts +16 -0
  158. package/dist/types/src/client/bunqueue/batch.d.ts +16 -0
  159. package/dist/types/src/client/bunqueue/cancellation.d.ts +21 -0
  160. package/dist/types/src/client/bunqueue/circuitBreaker.d.ts +21 -0
  161. package/dist/types/src/client/bunqueue/dedupDebounce.d.ts +12 -0
  162. package/dist/types/src/client/bunqueue/dlqRateLimit.d.ts +26 -0
  163. package/dist/types/src/client/bunqueue/retry.d.ts +8 -0
  164. package/dist/types/src/client/bunqueue/runtime.d.ts +35 -0
  165. package/dist/types/src/client/bunqueue/triggers.d.ts +17 -0
  166. package/dist/types/src/client/bunqueue/ttl.d.ts +17 -0
  167. package/dist/types/src/client/bunqueue/types.d.ts +147 -0
  168. package/dist/types/src/client/bunqueue.d.ts +73 -0
  169. package/dist/types/src/client/dlqConversion.d.ts +5 -0
  170. package/dist/types/src/client/errors.d.ts +24 -0
  171. package/dist/types/src/client/events.d.ts +85 -0
  172. package/dist/types/src/client/flow.d.ts +70 -0
  173. package/dist/types/src/client/flowAtomic.d.ts +9 -0
  174. package/dist/types/src/client/flowJobCoreMethods.d.ts +28 -0
  175. package/dist/types/src/client/flowJobDependencies.d.ts +7 -0
  176. package/dist/types/src/client/flowJobFactory.d.ts +24 -0
  177. package/dist/types/src/client/flowJobMoveMethods.d.ts +16 -0
  178. package/dist/types/src/client/flowJobTypes.d.ts +29 -0
  179. package/dist/types/src/client/flowLegacyPlan.d.ts +16 -0
  180. package/dist/types/src/client/flowOptions.d.ts +10 -0
  181. package/dist/types/src/client/flowPlan.d.ts +16 -0
  182. package/dist/types/src/client/flowPush.d.ts +27 -0
  183. package/dist/types/src/client/flowReader.d.ts +10 -0
  184. package/dist/types/src/client/flowResults.d.ts +11 -0
  185. package/dist/types/src/client/flowTypes.d.ts +77 -0
  186. package/dist/types/src/client/forwarder.d.ts +75 -0
  187. package/dist/types/src/client/groupId.d.ts +1 -0
  188. package/dist/types/src/client/index.d.ts +46 -0
  189. package/dist/types/src/client/jobConversion.d.ts +10 -0
  190. package/dist/types/src/client/jobConversionHelpers.d.ts +28 -0
  191. package/dist/types/src/client/jobConversionTypes.d.ts +88 -0
  192. package/dist/types/src/client/jobDeduplication.d.ts +6 -0
  193. package/dist/types/src/client/jobHelpers.d.ts +31 -0
  194. package/dist/types/src/client/legacyConnectionOptions.d.ts +8 -0
  195. package/dist/types/src/client/manager.d.ts +15 -0
  196. package/dist/types/src/client/pro.d.ts +9 -0
  197. package/dist/types/src/client/queue/addBatcher.d.ts +59 -0
  198. package/dist/types/src/client/queue/bullmqCompat.d.ts +57 -0
  199. package/dist/types/src/client/queue/deduplication.d.ts +14 -0
  200. package/dist/types/src/client/queue/dlq.d.ts +61 -0
  201. package/dist/types/src/client/queue/dlqJobMethods.d.ts +9 -0
  202. package/dist/types/src/client/queue/dlqOps.d.ts +26 -0
  203. package/dist/types/src/client/queue/dlqStats.d.ts +3 -0
  204. package/dist/types/src/client/queue/failWire.d.ts +17 -0
  205. package/dist/types/src/client/queue/helpers.d.ts +19 -0
  206. package/dist/types/src/client/queue/job-proxy/dependencies.d.ts +9 -0
  207. package/dist/types/src/client/queue/job-proxy/reflection.d.ts +2 -0
  208. package/dist/types/src/client/queue/job-proxy/simple.d.ts +3 -0
  209. package/dist/types/src/client/queue/job-proxy/tcp.d.ts +4 -0
  210. package/dist/types/src/client/queue/jobMetadata.d.ts +10 -0
  211. package/dist/types/src/client/queue/jobMove.d.ts +32 -0
  212. package/dist/types/src/client/queue/jobProxy.d.ts +4 -0
  213. package/dist/types/src/client/queue/operations/add/bulk.d.ts +7 -0
  214. package/dist/types/src/client/queue/operations/add/payload.d.ts +25 -0
  215. package/dist/types/src/client/queue/operations/add/single.d.ts +3 -0
  216. package/dist/types/src/client/queue/operations/add.d.ts +2 -0
  217. package/dist/types/src/client/queue/operations/control.d.ts +42 -0
  218. package/dist/types/src/client/queue/operations/counts.d.ts +48 -0
  219. package/dist/types/src/client/queue/operations/groups.d.ts +24 -0
  220. package/dist/types/src/client/queue/operations/management.d.ts +51 -0
  221. package/dist/types/src/client/queue/operations/query.d.ts +50 -0
  222. package/dist/types/src/client/queue/operations/queryStates.d.ts +13 -0
  223. package/dist/types/src/client/queue/operations/queryTcpPages.d.ts +14 -0
  224. package/dist/types/src/client/queue/queue.d.ts +12 -0
  225. package/dist/types/src/client/queue/rateLimit.d.ts +46 -0
  226. package/dist/types/src/client/queue/runtime/compatibility.d.ts +13 -0
  227. package/dist/types/src/client/queue/runtime/configuration.d.ts +46 -0
  228. package/dist/types/src/client/queue/runtime/connection.d.ts +6 -0
  229. package/dist/types/src/client/queue/runtime/control.d.ts +41 -0
  230. package/dist/types/src/client/queue/runtime/queries.d.ts +66 -0
  231. package/dist/types/src/client/queue/runtime/scheduling.d.ts +33 -0
  232. package/dist/types/src/client/queue/runtime/state.d.ts +101 -0
  233. package/dist/types/src/client/queue/scheduler.d.ts +58 -0
  234. package/dist/types/src/client/queue/schedulerPagination.d.ts +7 -0
  235. package/dist/types/src/client/queue/stall.d.ts +20 -0
  236. package/dist/types/src/client/queue/types/add.d.ts +40 -0
  237. package/dist/types/src/client/queue/types/contexts.d.ts +33 -0
  238. package/dist/types/src/client/queue/types/index.d.ts +3 -0
  239. package/dist/types/src/client/queue/types/job.d.ts +50 -0
  240. package/dist/types/src/client/queue/types/runtime.d.ts +35 -0
  241. package/dist/types/src/client/queue/workers.d.ts +36 -0
  242. package/dist/types/src/client/queue-events/tcpSubscription.d.ts +23 -0
  243. package/dist/types/src/client/queue.d.ts +5 -0
  244. package/dist/types/src/client/queueGroup.d.ts +51 -0
  245. package/dist/types/src/client/resolveToken.d.ts +10 -0
  246. package/dist/types/src/client/sandboxed/index.d.ts +7 -0
  247. package/dist/types/src/client/sandboxed/queueOps.d.ts +24 -0
  248. package/dist/types/src/client/sandboxed/runtime/dispatch.d.ts +13 -0
  249. package/dist/types/src/client/sandboxed/runtime/lifecycle.d.ts +20 -0
  250. package/dist/types/src/client/sandboxed/runtime/log.d.ts +1 -0
  251. package/dist/types/src/client/sandboxed/runtime/pool.d.ts +11 -0
  252. package/dist/types/src/client/sandboxed/runtime/recovery.d.ts +11 -0
  253. package/dist/types/src/client/sandboxed/runtime/state.d.ts +39 -0
  254. package/dist/types/src/client/sandboxed/types/index.d.ts +2 -0
  255. package/dist/types/src/client/sandboxed/types/options.d.ts +27 -0
  256. package/dist/types/src/client/sandboxed/types/process.d.ts +39 -0
  257. package/dist/types/src/client/sandboxed/worker.d.ts +4 -0
  258. package/dist/types/src/client/sandboxed/wrapper.d.ts +12 -0
  259. package/dist/types/src/client/sandboxedWorker.d.ts +6 -0
  260. package/dist/types/src/client/tcp/client.d.ts +6 -0
  261. package/dist/types/src/client/tcp/commandQueue.d.ts +23 -0
  262. package/dist/types/src/client/tcp/connection.d.ts +4 -0
  263. package/dist/types/src/client/tcp/errors.d.ts +6 -0
  264. package/dist/types/src/client/tcp/health.d.ts +60 -0
  265. package/dist/types/src/client/tcp/index.d.ts +11 -0
  266. package/dist/types/src/client/tcp/reconnect.d.ts +47 -0
  267. package/dist/types/src/client/tcp/runtime/commands.d.ts +9 -0
  268. package/dist/types/src/client/tcp/runtime/connectivity.d.ts +13 -0
  269. package/dist/types/src/client/tcp/runtime/health.d.ts +14 -0
  270. package/dist/types/src/client/tcp/runtime/lifecycle.d.ts +8 -0
  271. package/dist/types/src/client/tcp/runtime/state.d.ts +50 -0
  272. package/dist/types/src/client/tcp/shared.d.ts +12 -0
  273. package/dist/types/src/client/tcp/transport.d.ts +18 -0
  274. package/dist/types/src/client/tcp/types/command.d.ts +9 -0
  275. package/dist/types/src/client/tcp/types/connection.d.ts +31 -0
  276. package/dist/types/src/client/tcp/types/index.d.ts +5 -0
  277. package/dist/types/src/client/tcp/types/socket.d.ts +8 -0
  278. package/dist/types/src/client/tcp/types/tls.d.ts +4 -0
  279. package/dist/types/src/client/tcp/types.d.ts +2 -0
  280. package/dist/types/src/client/tcpClient.d.ts +6 -0
  281. package/dist/types/src/client/tcpPool.d.ts +69 -0
  282. package/dist/types/src/client/types/connection.d.ts +30 -0
  283. package/dist/types/src/client/types/dlq.d.ts +45 -0
  284. package/dist/types/src/client/types/events.d.ts +54 -0
  285. package/dist/types/src/client/types/flow.d.ts +22 -0
  286. package/dist/types/src/client/types/index.d.ts +10 -0
  287. package/dist/types/src/client/types/job.d.ts +131 -0
  288. package/dist/types/src/client/types/metrics.d.ts +1 -0
  289. package/dist/types/src/client/types/options.d.ts +72 -0
  290. package/dist/types/src/client/types/worker.d.ts +54 -0
  291. package/dist/types/src/client/types.d.ts +2 -0
  292. package/dist/types/src/client/worker/ackBatcher.d.ts +55 -0
  293. package/dist/types/src/client/worker/ackFrontier.d.ts +21 -0
  294. package/dist/types/src/client/worker/ackOutcome.d.ts +8 -0
  295. package/dist/types/src/client/worker/batchExecution.d.ts +14 -0
  296. package/dist/types/src/client/worker/constants.d.ts +7 -0
  297. package/dist/types/src/client/worker/groupConcurrency.d.ts +49 -0
  298. package/dist/types/src/client/worker/handlers/completion.d.ts +29 -0
  299. package/dist/types/src/client/worker/handlers/dependencies.d.ts +11 -0
  300. package/dist/types/src/client/worker/handlers/mutations.d.ts +23 -0
  301. package/dist/types/src/client/worker/handlers/queries.d.ts +15 -0
  302. package/dist/types/src/client/worker/jobParser.d.ts +9 -0
  303. package/dist/types/src/client/worker/processor.d.ts +11 -0
  304. package/dist/types/src/client/worker/processorHandlers.d.ts +4 -0
  305. package/dist/types/src/client/worker/processorOutcome.d.ts +14 -0
  306. package/dist/types/src/client/worker/processorResult.d.ts +2 -0
  307. package/dist/types/src/client/worker/runtime/buffer.d.ts +8 -0
  308. package/dist/types/src/client/worker/runtime/control.d.ts +28 -0
  309. package/dist/types/src/client/worker/runtime/execution.d.ts +16 -0
  310. package/dist/types/src/client/worker/runtime/lifecycle.d.ts +7 -0
  311. package/dist/types/src/client/worker/runtime/manual.d.ts +10 -0
  312. package/dist/types/src/client/worker/runtime/options.d.ts +5 -0
  313. package/dist/types/src/client/worker/runtime/polling.d.ts +14 -0
  314. package/dist/types/src/client/worker/runtime/state.d.ts +121 -0
  315. package/dist/types/src/client/worker/types/index.d.ts +5 -0
  316. package/dist/types/src/client/worker/types/manual.d.ts +7 -0
  317. package/dist/types/src/client/worker/types/options.d.ts +26 -0
  318. package/dist/types/src/client/worker/types/outcome.d.ts +23 -0
  319. package/dist/types/src/client/worker/types/processor.d.ts +25 -0
  320. package/dist/types/src/client/worker/types/transport.d.ts +11 -0
  321. package/dist/types/src/client/worker/worker.d.ts +6 -0
  322. package/dist/types/src/client/worker/workerHeartbeat.d.ts +15 -0
  323. package/dist/types/src/client/worker/workerPull.d.ts +24 -0
  324. package/dist/types/src/client/worker/workerRateLimiter.d.ts +51 -0
  325. package/dist/types/src/client/worker.d.ts +6 -0
  326. package/dist/types/src/client/workflow/admission.d.ts +45 -0
  327. package/dist/types/src/client/workflow/clock.d.ts +60 -0
  328. package/dist/types/src/client/workflow/compensationChild.d.ts +33 -0
  329. package/dist/types/src/client/workflow/compensationClaim.d.ts +11 -0
  330. package/dist/types/src/client/workflow/compensationPass.d.ts +17 -0
  331. package/dist/types/src/client/workflow/compensationSupport.d.ts +24 -0
  332. package/dist/types/src/client/workflow/compensator.d.ts +34 -0
  333. package/dist/types/src/client/workflow/definitionGuard.d.ts +11 -0
  334. package/dist/types/src/client/workflow/emitter.d.ts +17 -0
  335. package/dist/types/src/client/workflow/engine.d.ts +66 -0
  336. package/dist/types/src/client/workflow/eventTypes.d.ts +44 -0
  337. package/dist/types/src/client/workflow/executionFence.d.ts +15 -0
  338. package/dist/types/src/client/workflow/executionTypes.d.ts +133 -0
  339. package/dist/types/src/client/workflow/executor.d.ts +52 -0
  340. package/dist/types/src/client/workflow/executorLifecycle.d.ts +19 -0
  341. package/dist/types/src/client/workflow/executorNodes.d.ts +18 -0
  342. package/dist/types/src/client/workflow/executorQueue.d.ts +9 -0
  343. package/dist/types/src/client/workflow/forEachRunner.d.ts +4 -0
  344. package/dist/types/src/client/workflow/identity.d.ts +48 -0
  345. package/dist/types/src/client/workflow/index.d.ts +23 -0
  346. package/dist/types/src/client/workflow/loops.d.ts +11 -0
  347. package/dist/types/src/client/workflow/mapRunner.d.ts +4 -0
  348. package/dist/types/src/client/workflow/recovery.d.ts +32 -0
  349. package/dist/types/src/client/workflow/rollbackControl.d.ts +37 -0
  350. package/dist/types/src/client/workflow/runner.d.ts +23 -0
  351. package/dist/types/src/client/workflow/runnerTiming.d.ts +14 -0
  352. package/dist/types/src/client/workflow/stepTypes.d.ts +171 -0
  353. package/dist/types/src/client/workflow/store.d.ts +83 -0
  354. package/dist/types/src/client/workflow/storeCodec.d.ts +7 -0
  355. package/dist/types/src/client/workflow/storeExecutionCodec.d.ts +11 -0
  356. package/dist/types/src/client/workflow/storeListing.d.ts +11 -0
  357. package/dist/types/src/client/workflow/storeMaintenance.d.ts +4 -0
  358. package/dist/types/src/client/workflow/storeSignals.d.ts +70 -0
  359. package/dist/types/src/client/workflow/subWorkflowRunner.d.ts +14 -0
  360. package/dist/types/src/client/workflow/types.d.ts +4 -0
  361. package/dist/types/src/client/workflow/unwindPlan.d.ts +87 -0
  362. package/dist/types/src/client/workflow/waitFor.d.ts +56 -0
  363. package/dist/types/src/client/workflow/workflow.d.ts +70 -0
  364. package/dist/types/src/client/workflow/workflowDecisions.d.ts +11 -0
  365. package/dist/types/src/client/workflow/workflowDefinition.d.ts +16 -0
  366. package/dist/types/src/client/workflow/workflowIntrospection.d.ts +5 -0
  367. package/dist/types/src/client/workflow/workflowValidation.d.ts +44 -0
  368. package/dist/types/src/config/index.d.ts +9 -0
  369. package/dist/types/src/config/loader.d.ts +7 -0
  370. package/dist/types/src/config/resolve.d.ts +59 -0
  371. package/dist/types/src/config/types.d.ts +88 -0
  372. package/dist/types/src/domain/job/constants.d.ts +14 -0
  373. package/dist/types/src/domain/job/create.d.ts +9 -0
  374. package/dist/types/src/domain/job/groupFifoOrder.d.ts +9 -0
  375. package/dist/types/src/domain/job/ids.d.ts +7 -0
  376. package/dist/types/src/domain/job/locks.d.ts +16 -0
  377. package/dist/types/src/domain/job/payload.d.ts +18 -0
  378. package/dist/types/src/domain/job/state.d.ts +23 -0
  379. package/dist/types/src/domain/job/terminal.d.ts +3 -0
  380. package/dist/types/src/domain/queue/dependencyTracker.d.ts +78 -0
  381. package/dist/types/src/domain/queue/dlqShard.d.ts +66 -0
  382. package/dist/types/src/domain/queue/groupLimiterManager.d.ts +30 -0
  383. package/dist/types/src/domain/queue/groupScheduler.d.ts +31 -0
  384. package/dist/types/src/domain/queue/groupSchedulerOrder.d.ts +6 -0
  385. package/dist/types/src/domain/queue/limiterManager.d.ts +68 -0
  386. package/dist/types/src/domain/queue/priorityQueue.d.ts +54 -0
  387. package/dist/types/src/domain/queue/priorityQueueOrder.d.ts +3 -0
  388. package/dist/types/src/domain/queue/shard/dependencies.d.ts +11 -0
  389. package/dist/types/src/domain/queue/shard/dlq.d.ts +26 -0
  390. package/dist/types/src/domain/queue/shard/keys.d.ts +19 -0
  391. package/dist/types/src/domain/queue/shard/lifecycle.d.ts +10 -0
  392. package/dist/types/src/domain/queue/shard/limits.d.ts +47 -0
  393. package/dist/types/src/domain/queue/shard/metrics.d.ts +32 -0
  394. package/dist/types/src/domain/queue/shard/state.d.ts +40 -0
  395. package/dist/types/src/domain/queue/shard.d.ts +7 -0
  396. package/dist/types/src/domain/queue/shardCounters.d.ts +35 -0
  397. package/dist/types/src/domain/queue/temporalIndex.d.ts +24 -0
  398. package/dist/types/src/domain/queue/temporalManager.d.ts +72 -0
  399. package/dist/types/src/domain/queue/uniqueKeyManager.d.ts +33 -0
  400. package/dist/types/src/domain/queue/waiterManager.d.ts +18 -0
  401. package/dist/types/src/domain/response/builders.d.ts +15 -0
  402. package/dist/types/src/domain/types/command.d.ts +2 -0
  403. package/dist/types/src/domain/types/commands/base.d.ts +5 -0
  404. package/dist/types/src/domain/types/commands/core.d.ts +107 -0
  405. package/dist/types/src/domain/types/commands/cron.d.ts +36 -0
  406. package/dist/types/src/domain/types/commands/dashboard.d.ts +13 -0
  407. package/dist/types/src/domain/types/commands/dlq.d.ts +44 -0
  408. package/dist/types/src/domain/types/commands/extended.d.ts +63 -0
  409. package/dist/types/src/domain/types/commands/index.d.ts +12 -0
  410. package/dist/types/src/domain/types/commands/limits.d.ts +108 -0
  411. package/dist/types/src/domain/types/commands/management.d.ts +73 -0
  412. package/dist/types/src/domain/types/commands/monitoring.d.ts +49 -0
  413. package/dist/types/src/domain/types/commands/protocol.d.ts +20 -0
  414. package/dist/types/src/domain/types/commands/query.d.ts +46 -0
  415. package/dist/types/src/domain/types/commands/union.d.ts +13 -0
  416. package/dist/types/src/domain/types/commands/workers.d.ts +39 -0
  417. package/dist/types/src/domain/types/cron.d.ts +89 -0
  418. package/dist/types/src/domain/types/deduplication.d.ts +43 -0
  419. package/dist/types/src/domain/types/dlq.d.ts +136 -0
  420. package/dist/types/src/domain/types/flow.d.ts +25 -0
  421. package/dist/types/src/domain/types/group.d.ts +26 -0
  422. package/dist/types/src/domain/types/job.d.ts +8 -0
  423. package/dist/types/src/domain/types/jobs/model.d.ts +150 -0
  424. package/dist/types/src/domain/types/metrics.d.ts +16 -0
  425. package/dist/types/src/domain/types/priorityQueue.d.ts +13 -0
  426. package/dist/types/src/domain/types/protocol.d.ts +5 -0
  427. package/dist/types/src/domain/types/queue.d.ts +110 -0
  428. package/dist/types/src/domain/types/response.d.ts +3 -0
  429. package/dist/types/src/domain/types/responses/model.d.ts +152 -0
  430. package/dist/types/src/domain/types/shard.d.ts +4 -0
  431. package/dist/types/src/domain/types/stall.d.ts +48 -0
  432. package/dist/types/src/domain/types/webhook.d.ts +42 -0
  433. package/dist/types/src/domain/types/worker.d.ts +40 -0
  434. package/dist/types/src/infrastructure/backup/backupTelemetry.d.ts +30 -0
  435. package/dist/types/src/infrastructure/backup/s3BackupConfig.d.ts +80 -0
  436. package/dist/types/src/infrastructure/cloud/types/config.d.ts +18 -0
  437. package/dist/types/src/infrastructure/cloud/types/event.d.ts +14 -0
  438. package/dist/types/src/infrastructure/cloud/types/snapshot.d.ts +52 -0
  439. package/dist/types/src/infrastructure/cloud/types/snapshotCore.d.ts +125 -0
  440. package/dist/types/src/infrastructure/cloud/types/snapshotJobs.d.ts +124 -0
  441. package/dist/types/src/infrastructure/cloud/types/snapshotTelemetry.d.ts +100 -0
  442. package/dist/types/src/infrastructure/cloud/types.d.ts +3 -0
  443. package/dist/types/src/infrastructure/persistence/batchInsert.d.ts +13 -0
  444. package/dist/types/src/infrastructure/persistence/completedJobCountSchema.d.ts +6 -0
  445. package/dist/types/src/infrastructure/persistence/dependencyCompletionSchema.d.ts +6 -0
  446. package/dist/types/src/infrastructure/persistence/dependencyCompletionStore.d.ts +40 -0
  447. package/dist/types/src/infrastructure/persistence/index.d.ts +5 -0
  448. package/dist/types/src/infrastructure/persistence/jobOptionsBlob.d.ts +19 -0
  449. package/dist/types/src/infrastructure/persistence/legacyNameMigration.d.ts +17 -0
  450. package/dist/types/src/infrastructure/persistence/migrationProgressSchema.d.ts +2 -0
  451. package/dist/types/src/infrastructure/persistence/migrations.d.ts +3 -0
  452. package/dist/types/src/infrastructure/persistence/schema.d.ts +8 -0
  453. package/dist/types/src/infrastructure/persistence/sqlite/admission.d.ts +9 -0
  454. package/dist/types/src/infrastructure/persistence/sqlite/completed.d.ts +17 -0
  455. package/dist/types/src/infrastructure/persistence/sqlite/control.d.ts +48 -0
  456. package/dist/types/src/infrastructure/persistence/sqlite/flows.d.ts +26 -0
  457. package/dist/types/src/infrastructure/persistence/sqlite/jobLifecycle.d.ts +17 -0
  458. package/dist/types/src/infrastructure/persistence/sqlite/jobs.d.ts +15 -0
  459. package/dist/types/src/infrastructure/persistence/sqlite/lifecycle.d.ts +6 -0
  460. package/dist/types/src/infrastructure/persistence/sqlite/mutations.d.ts +27 -0
  461. package/dist/types/src/infrastructure/persistence/sqlite/queries.d.ts +23 -0
  462. package/dist/types/src/infrastructure/persistence/sqlite/queueDeletionSql.d.ts +3 -0
  463. package/dist/types/src/infrastructure/persistence/sqlite/records.d.ts +24 -0
  464. package/dist/types/src/infrastructure/persistence/sqlite/state.d.ts +42 -0
  465. package/dist/types/src/infrastructure/persistence/sqlite/telemetry.d.ts +17 -0
  466. package/dist/types/src/infrastructure/persistence/sqlite/telemetryStore.d.ts +30 -0
  467. package/dist/types/src/infrastructure/persistence/sqlite/telemetryWrites.d.ts +47 -0
  468. package/dist/types/src/infrastructure/persistence/sqlite.d.ts +6 -0
  469. package/dist/types/src/infrastructure/persistence/sqliteBatch.d.ts +4 -0
  470. package/dist/types/src/infrastructure/persistence/sqliteMigration.d.ts +5 -0
  471. package/dist/types/src/infrastructure/persistence/sqliteSerializer.d.ts +50 -0
  472. package/dist/types/src/infrastructure/persistence/statements.d.ts +86 -0
  473. package/dist/types/src/infrastructure/persistence/types/admission.d.ts +8 -0
  474. package/dist/types/src/infrastructure/persistence/types/batch.d.ts +12 -0
  475. package/dist/types/src/infrastructure/persistence/types/sqlite.d.ts +27 -0
  476. package/dist/types/src/infrastructure/persistence/writeBuffer.d.ts +48 -0
  477. package/dist/types/src/infrastructure/persistence/writeBufferPending.d.ts +11 -0
  478. package/dist/types/src/infrastructure/scheduler/cron/execution.d.ts +12 -0
  479. package/dist/types/src/infrastructure/scheduler/cron/persisted.d.ts +5 -0
  480. package/dist/types/src/infrastructure/scheduler/cron/runtime.d.ts +31 -0
  481. package/dist/types/src/infrastructure/scheduler/cron/validation.d.ts +3 -0
  482. package/dist/types/src/infrastructure/scheduler/cronParser.d.ts +45 -0
  483. package/dist/types/src/infrastructure/scheduler/cronScheduler.d.ts +5 -0
  484. package/dist/types/src/infrastructure/scheduler/types/cronScheduler.d.ts +16 -0
  485. package/dist/types/src/infrastructure/server/protocol/commands.d.ts +8 -0
  486. package/dist/types/src/infrastructure/server/protocol/frameParser.d.ts +16 -0
  487. package/dist/types/src/infrastructure/server/protocol/lineBuffer.d.ts +6 -0
  488. package/dist/types/src/infrastructure/server/protocol/validation.d.ts +10 -0
  489. package/dist/types/src/infrastructure/server/protocol.d.ts +6 -0
  490. package/dist/types/src/infrastructure/server/socketWriteQueue.d.ts +66 -0
  491. package/dist/types/src/infrastructure/server/types/protocol.d.ts +4 -0
  492. package/dist/types/src/require-bun.d.ts +13 -0
  493. package/dist/types/src/shared/asyncLock.d.ts +13 -0
  494. package/dist/types/src/shared/boundedMap.d.ts +30 -0
  495. package/dist/types/src/shared/boundedSet.d.ts +26 -0
  496. package/dist/types/src/shared/hash.d.ts +30 -0
  497. package/dist/types/src/shared/histogram.d.ts +23 -0
  498. package/dist/types/src/shared/lock.d.ts +13 -0
  499. package/dist/types/src/shared/lockError.d.ts +3 -0
  500. package/dist/types/src/shared/lockTimeout.d.ts +2 -0
  501. package/dist/types/src/shared/logger.d.ts +48 -0
  502. package/dist/types/src/shared/lru.d.ts +9 -0
  503. package/dist/types/src/shared/lruMap.d.ts +42 -0
  504. package/dist/types/src/shared/lruSet.d.ts +36 -0
  505. package/dist/types/src/shared/minHeap.d.ts +43 -0
  506. package/dist/types/src/shared/msgpack.d.ts +3 -0
  507. package/dist/types/src/shared/pausedView.d.ts +19 -0
  508. package/dist/types/src/shared/rwLock.d.ts +22 -0
  509. package/dist/types/src/shared/serialization.d.ts +24 -0
  510. package/dist/types/src/shared/skipList.d.ts +97 -0
  511. package/dist/types/src/shared/skipListNodes.d.ts +6 -0
  512. package/dist/types/src/shared/storageHealth.d.ts +9 -0
  513. package/dist/types/src/shared/ttlMap.d.ts +81 -0
  514. package/dist/types/src/shared/types/lock.d.ts +7 -0
  515. package/dist/types/src/shared/types/skipList.d.ts +4 -0
  516. package/dist/types/src/shared/version.d.ts +4 -0
  517. package/dist/types/src/shared/webhookValidation.d.ts +6 -0
  518. package/package.json +27 -9
  519. package/src/ack-batcher.ts +8 -5
  520. package/src/bunqueue/bunqueue-api.ts +1 -1
  521. package/src/bunqueue/bunqueue.ts +2 -1
  522. package/src/canonical-transport/bun-sqlite-types.ts +22 -0
  523. package/src/canonical-transport/dlq.ts +12 -0
  524. package/src/canonical-transport/embedded.ts +55 -0
  525. package/src/canonical-transport/runtime.ts +49 -0
  526. package/src/canonical-transport/thread-worker.ts +83 -0
  527. package/src/canonical-transport/transport.ts +153 -0
  528. package/src/connection.ts +25 -30
  529. package/src/errors.ts +3 -0
  530. package/src/flow-commit.ts +45 -0
  531. package/src/flow-plan-legacy.ts +117 -0
  532. package/src/flow-plan.ts +209 -0
  533. package/src/flow-types.ts +4 -0
  534. package/src/flow.ts +31 -163
  535. package/src/frame.ts +5 -2
  536. package/src/index.ts +7 -75
  537. package/src/job.ts +43 -9
  538. package/src/legacy.ts +91 -0
  539. package/src/observability.ts +59 -1
  540. package/src/queue-admin.ts +5 -5
  541. package/src/queue-control.ts +8 -6
  542. package/src/queue.ts +10 -6
  543. package/src/serialization.ts +93 -0
  544. package/src/terminal-outcome.ts +58 -0
  545. package/src/types.ts +3 -6
  546. package/src/worker-base.ts +9 -6
  547. package/src/worker-slot-signal.ts +23 -0
  548. package/src/worker.ts +11 -5
  549. package/dist/backpressure.js +0 -39
  550. package/dist/bunqueue/aging.js +0 -53
  551. package/dist/bunqueue/batch.js +0 -60
  552. package/dist/bunqueue/bunqueue-api.js +0 -116
  553. package/dist/bunqueue/bunqueue.js +0 -194
  554. package/dist/bunqueue/cancellation.js +0 -48
  555. package/dist/bunqueue/circuit-breaker.js +0 -69
  556. package/dist/bunqueue/dedup-debounce.js +0 -37
  557. package/dist/bunqueue/dlq-rate-limit.js +0 -65
  558. package/dist/bunqueue/rate-gate.js +0 -61
  559. package/dist/bunqueue/retry.js +0 -56
  560. package/dist/bunqueue/triggers.js +0 -42
  561. package/dist/bunqueue/ttl.js +0 -31
  562. package/dist/bunqueue/types.js +0 -6
  563. package/dist/connection-pool.js +0 -60
  564. package/dist/connection-types.js +0 -2
  565. package/dist/connection.js +0 -281
  566. package/dist/errors.js +0 -25
  567. package/dist/flow-types.js +0 -2
  568. package/dist/flow.js +0 -212
  569. package/dist/job.js +0 -155
  570. package/dist/observability.js +0 -110
  571. package/dist/queue-admin.js +0 -158
  572. package/dist/queue-control.js +0 -107
  573. package/dist/queue-query.js +0 -187
  574. package/dist/queue.js +0 -92
  575. package/dist/responses.js +0 -10
  576. package/dist/socket-factory.js +0 -47
  577. package/dist/types.js +0 -50
  578. package/dist/worker-base.js +0 -159
  579. package/dist/worker-types.js +0 -5
  580. package/dist/worker.js +0 -211
  581. /package/dist/{backpressure.d.ts → types/sdk/typescript/src/backpressure.d.ts} +0 -0
  582. /package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/cancellation.d.ts +0 -0
@@ -0,0 +1,44 @@
1
+ import type { StepDefinition, WorkflowNode } from "./types.js";
2
+ /**
3
+ * Extract step definitions from an inline builder. Inline nodes run inside one
4
+ * `wf:step` job, so only plain steps have executable semantics there.
5
+ */
6
+ export declare function onlySteps(sub: {
7
+ nodes: readonly WorkflowNode[];
8
+ }, where: string, label?: string): StepDefinition[];
9
+ /** Why an event name cannot be used as a gate, or `null` when it can. */
10
+ export declare function unusableEventName(event: unknown): string | null;
11
+ /**
12
+ * A delivered signal is retained by event name rather than consumed, so two gates
13
+ * sharing a name would both be opened by one delivery.
14
+ */
15
+ export declare function assertNoDuplicateWaitFor(wf: {
16
+ name: string;
17
+ nodes: readonly {
18
+ type: string;
19
+ event?: string;
20
+ }[];
21
+ }): void;
22
+ type RegistrableWorkflow = {
23
+ name: string;
24
+ nodes: readonly WorkflowNode[];
25
+ getStepNames(): string[];
26
+ getIndexedStepNames(): string[];
27
+ };
28
+ /**
29
+ * Reject both engine namespace collisions and names colliding with the
30
+ * `name:index` records generated by loops.
31
+ */
32
+ export declare function assertNoIndexCollision(wf: RegistrableWorkflow): void;
33
+ /**
34
+ * `retry` is the total number of attempts. Zero/non-integral values would make the
35
+ * runner skip the handler and fabricate a failure record.
36
+ */
37
+ export declare function assertUsableRetry(step: string, retry: number | undefined): void;
38
+ /** Timeout values are finite milliseconds; zero deliberately means no forward bound. */
39
+ export declare function assertUsableTimeout(where: string, timeout: number | undefined): void;
40
+ /** Polling delays and child deadlines cannot be disabled or spin at zero. */
41
+ export declare function assertPositiveDuration(where: string, duration: number | undefined): void;
42
+ /** Loop limits must bound the number of body executions exactly. */
43
+ export declare function assertUsableIterations(where: string, maxIterations: number | undefined): void;
44
+ export {};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * bunqueue Configuration
3
+ * Global config file support with defineConfig helper
4
+ */
5
+ export { defineConfig } from "./types.js";
6
+ export type { BunqueueConfig } from "./types.js";
7
+ export { loadConfigFile } from "./loader.js";
8
+ export { resolveServerConfig, resolveCloudConfig, resolveBackupConfig, resolveTlsServerOptions, } from "./resolve.js";
9
+ export type { ResolvedConfig } from "./resolve.js";
@@ -0,0 +1,7 @@
1
+ /**
2
+ * bunqueue Config File Loader
3
+ * Auto-discovers and loads bunqueue.config.{ts,js,mjs}
4
+ */
5
+ import type { BunqueueConfig } from "./types.js";
6
+ /** Load config file from explicit path or auto-discover in CWD */
7
+ export declare function loadConfigFile(explicitPath?: string): Promise<BunqueueConfig | null>;
@@ -0,0 +1,59 @@
1
+ /**
2
+ * bunqueue Config Resolver
3
+ * Merges config file + env vars + defaults (config file wins)
4
+ */
5
+ import type { BunqueueConfig } from "./types.js";
6
+ import type { CloudConfig } from "../infrastructure/cloud/types.js";
7
+ import type { S3BackupConfig } from "../infrastructure/backup/s3BackupConfig.js";
8
+ /** Fully resolved server configuration */
9
+ export interface ResolvedConfig {
10
+ tcpPort: number;
11
+ httpPort: number;
12
+ hostname: string;
13
+ tcpSocketPath: string | undefined;
14
+ httpSocketPath: string | undefined;
15
+ tlsCertFile: string | undefined;
16
+ tlsKeyFile: string | undefined;
17
+ authTokens: string[];
18
+ dataPath: string | undefined;
19
+ storageDriver: 'memory' | 'sqlite' | 'postgres';
20
+ postgresUrl: string | undefined;
21
+ postgresNamespace: string;
22
+ postgresBrokerId: string | undefined;
23
+ postgresPoolSize: number;
24
+ postgresLeaseDurationMs: number;
25
+ postgresPollIntervalMs: number;
26
+ postgresStatementTimeoutMs: number;
27
+ postgresLockTimeoutMs: number;
28
+ postgresIdleTransactionTimeoutMs: number;
29
+ postgresMaxConcurrentOperations: number;
30
+ postgresMaxQueuedOperations: number;
31
+ postgresMaxSnapshotJobs: number;
32
+ postgresMaxSnapshotPayloadBytes: number;
33
+ maxCompletedJobs: number;
34
+ completedRetentionMs: number | null;
35
+ corsOrigins: string[];
36
+ requireAuthForMetrics: boolean;
37
+ maxPrometheusQueues: number;
38
+ s3BackupEnabled: boolean;
39
+ shutdownTimeoutMs: number;
40
+ statsIntervalMs: number;
41
+ }
42
+ /** Resolve server config: config file > env vars > defaults */
43
+ export declare function resolveServerConfig(fileConfig: BunqueueConfig | null): ResolvedConfig;
44
+ /**
45
+ * Resolve server TLS options from resolved config. Returns null when TLS is
46
+ * not configured; throws when only one of cert/key is set (fail fast at
47
+ * startup rather than serving plaintext when the operator expected TLS).
48
+ */
49
+ export declare function resolveTlsServerOptions(config: {
50
+ tlsCertFile?: string;
51
+ tlsKeyFile?: string;
52
+ }): {
53
+ certFile: string;
54
+ keyFile: string;
55
+ } | null;
56
+ /** Resolve cloud config: config file > env vars. Returns null if disabled. */
57
+ export declare function resolveCloudConfig(fileConfig: BunqueueConfig | null, dataPath?: string): CloudConfig | null;
58
+ /** Resolve S3 backup config: config file > env vars */
59
+ export declare function resolveBackupConfig(fileConfig: BunqueueConfig | null, databasePath: string): S3BackupConfig;
@@ -0,0 +1,88 @@
1
+ /**
2
+ * bunqueue Configuration Types
3
+ * Global configuration file interface and defineConfig helper
4
+ */
5
+ /** Global bunqueue configuration (all sections optional) */
6
+ export interface BunqueueConfig {
7
+ server?: {
8
+ tcpPort?: number;
9
+ httpPort?: number;
10
+ host?: string;
11
+ tcpSocketPath?: string;
12
+ httpSocketPath?: string;
13
+ /** Path to PEM certificate file — enables native TLS on TCP + HTTP (with tlsKeyFile) */
14
+ tlsCertFile?: string;
15
+ /** Path to PEM private key file — enables native TLS on TCP + HTTP (with tlsCertFile) */
16
+ tlsKeyFile?: string;
17
+ };
18
+ auth?: {
19
+ tokens?: string[];
20
+ requireAuthForMetrics?: boolean;
21
+ };
22
+ storage?: {
23
+ /** Persistence backend. Inferred from url/dataPath when omitted. */
24
+ driver?: 'memory' | 'sqlite' | 'postgres';
25
+ dataPath?: string;
26
+ /** PostgreSQL connection URL. Required when driver is postgres. */
27
+ url?: string;
28
+ /** Isolates independent bunqueue installations sharing one PostgreSQL database. */
29
+ namespace?: string;
30
+ /** Stable identifier for this broker process; generated automatically when omitted. */
31
+ brokerId?: string;
32
+ poolSize?: number;
33
+ leaseDurationMs?: number;
34
+ pollIntervalMs?: number;
35
+ statementTimeoutMs?: number;
36
+ lockTimeoutMs?: number;
37
+ idleTransactionTimeoutMs?: number;
38
+ maxConcurrentOperations?: number;
39
+ maxQueuedOperations?: number;
40
+ maxSnapshotJobs?: number;
41
+ maxSnapshotPayloadBytes?: number;
42
+ /** Hot in-memory completed-job window; this is not durable retention. */
43
+ maxCompletedJobs?: number;
44
+ /** Automatic age-based completed-job retention in milliseconds; null disables it. */
45
+ completedRetentionMs?: number | null;
46
+ };
47
+ telemetry?: {
48
+ /** Maximum queue label values exposed to Prometheus; zero disables per-queue series. */
49
+ maxPrometheusQueues?: number;
50
+ };
51
+ cors?: {
52
+ origins?: string[];
53
+ };
54
+ cloud?: {
55
+ url?: string;
56
+ apiKey?: string;
57
+ instanceId?: string;
58
+ };
59
+ backup?: {
60
+ enabled?: boolean;
61
+ bucket?: string;
62
+ accessKeyId?: string;
63
+ secretAccessKey?: string;
64
+ sessionToken?: string;
65
+ region?: string;
66
+ endpoint?: string;
67
+ virtualHostedStyle?: boolean;
68
+ interval?: number;
69
+ retention?: number;
70
+ prefix?: string;
71
+ };
72
+ timeouts?: {
73
+ shutdown?: number;
74
+ stats?: number;
75
+ worker?: number;
76
+ lock?: number;
77
+ };
78
+ webhooks?: {
79
+ maxRetries?: number;
80
+ retryDelay?: number;
81
+ };
82
+ logging?: {
83
+ level?: 'debug' | 'info' | 'warn' | 'error';
84
+ format?: 'text' | 'json';
85
+ };
86
+ }
87
+ /** Type-safe config helper for intellisense */
88
+ export declare function defineConfig(config: BunqueueConfig): BunqueueConfig;
@@ -0,0 +1,14 @@
1
+ export declare const DEFAULT_MAX_BACKOFF = 3600000;
2
+ export declare const MAX_TIMELINE_ENTRIES = 20;
3
+ export declare const DEFAULT_LOCK_TTL = 30000;
4
+ export declare const JOB_DEFAULTS: {
5
+ readonly priority: 0;
6
+ readonly maxAttempts: 3;
7
+ readonly backoff: 1000;
8
+ readonly lifo: false;
9
+ readonly removeOnComplete: false;
10
+ readonly removeOnFail: false;
11
+ readonly stackTraceLimit: 10;
12
+ };
13
+ /** Upper bound accepted for `backoff`, `backoff.delay` and `backoff.maxDelay` (24 hours). */
14
+ export declare const MAX_BACKOFF_DELAY = 86400000;
@@ -0,0 +1,9 @@
1
+ import type { Job, JobId, JobInput } from "../types/jobs/model.js";
2
+ /**
3
+ * Keep a caller-supplied retry-delay cap only when it is usable. Embedded and
4
+ * cron admission do not pass through the server validator, so a non-numeric,
5
+ * non-finite, negative or over-limit value is dropped and the default cap applies
6
+ * instead of turning the retry delay into NaN or an unbounded wait.
7
+ */
8
+ export declare function parseMaxDelay(value: unknown): number | undefined;
9
+ export declare function createJob(id: JobId, queue: string, input: JobInput, now?: number): Job;
@@ -0,0 +1,9 @@
1
+ import type { Job } from "../types/jobs/model.js";
2
+ /** Read the broker-internal admission order used by grouped FIFO lanes. */
3
+ export declare function getGroupFifoOrder(job: Job): bigint | null;
4
+ /** Stamp a stable order without exposing it through the public job protocol. */
5
+ export declare function setGroupFifoOrder(job: Job, order: bigint): void;
6
+ /** Preserve the hidden order when an immutable job replacement is created. */
7
+ export declare function copyGroupFifoOrder(source: Job, target: Job): void;
8
+ /** Restore a validated decimal order from SQLite extended options. */
9
+ export declare function restoreGroupFifoOrder(job: Job, stored: string | null): void;
@@ -0,0 +1,7 @@
1
+ import type { JobId, LockToken } from "../types/jobs/model.js";
2
+ export declare function isWellFormedJobId(id: string): boolean;
3
+ export declare function assertWellFormedJobId(id: string, name?: string): void;
4
+ export declare function jobId(id: string): JobId;
5
+ export declare function generateJobId(): JobId;
6
+ export declare function lockToken(token: string): LockToken;
7
+ export declare function generateLockToken(): LockToken;
@@ -0,0 +1,16 @@
1
+ import type { Job, JobId, JobLock } from "../types/jobs/model.js";
2
+ export declare function createJobLock(jobId: JobId, owner: string, ttl?: number, now?: number): JobLock;
3
+ export declare function isLockExpired(lock: JobLock, now?: number): boolean;
4
+ export declare function renewLock(lock: JobLock, newTtl?: number, now?: number): void;
5
+ /**
6
+ * True when `lock` was created for an earlier processing generation of `job`,
7
+ * that is, the job was pulled again after the lease was granted. Stall retry
8
+ * deliberately keeps the previous lease as a stale-outcome guard, so a lease in
9
+ * `jobLocks` is not necessarily the current one.
10
+ *
11
+ * Pull stamps `startedAt` from a clock read taken before the lease is created
12
+ * in the same delivery, so a lease from the current pull always has
13
+ * `createdAt >= startedAt`. The comparison is strict: a lease created in the
14
+ * same millisecond as the pull belongs to the current generation.
15
+ */
16
+ export declare function isLeaseFromEarlierGeneration(job: Pick<Job, 'startedAt'>, lock: Pick<JobLock, 'createdAt'>): boolean;
@@ -0,0 +1,18 @@
1
+ export interface JobPayloadSource {
2
+ readonly name?: unknown;
3
+ readonly data: unknown;
4
+ }
5
+ export interface NormalizedJobPayload {
6
+ readonly name: string;
7
+ readonly data: unknown;
8
+ readonly legacy: boolean;
9
+ }
10
+ /** Return the stable public validation error for an invalid job name. */
11
+ export declare function validateJobName(name: unknown): string | null;
12
+ /**
13
+ * Resolve a modern payload. A missing explicit name defaults without inspecting
14
+ * `data`, so direct QueueManager callers can use `data.name` as an ordinary key.
15
+ */
16
+ export declare function normalizeJobPayload(source: JobPayloadSource, fallback?: string): NormalizedJobPayload;
17
+ /** Decode a pre-2.8.56 wire or persistence envelope at a known legacy boundary. */
18
+ export declare function normalizeLegacyJobPayload(source: JobPayloadSource, fallback?: string): NormalizedJobPayload;
@@ -0,0 +1,23 @@
1
+ import type { Job } from "../types/jobs/model.js";
2
+ export declare function normalizeStacktrace(lines: readonly unknown[] | undefined, limit: number): string[] | null;
3
+ export declare function isDelayed(job: Job, now?: number): boolean;
4
+ export declare function isReady(job: Job, now?: number): boolean;
5
+ export declare function isExpired(job: Job, now?: number): boolean;
6
+ export declare function isTimedOut(job: Job, now?: number): boolean;
7
+ export declare function calculateBackoff(job: Job): number;
8
+ /**
9
+ * Wait applied when a processor throws `DelayedError`. It is always a positive
10
+ * finite number of milliseconds: DelayedError never counts an attempt, so a zero
11
+ * wait would let a processor that keeps throwing it re-pull the job in a tight
12
+ * loop with nothing to stop it.
13
+ *
14
+ * The base is the configured delay with no attempt growth and no jitter:
15
+ * `backoff.delay` for the object form, otherwise the numeric `backoff`. A base
16
+ * that is not a positive number (0, missing, negative or NaN) falls back to the
17
+ * 1000 ms default. The base is then capped at `backoff.maxDelay` when that is a
18
+ * positive finite number, otherwise at DEFAULT_MAX_BACKOFF. A `maxDelay` of 0
19
+ * means "retry failures immediately" and does not apply here, because
20
+ * DelayedError is not a failure: such a job waits its capped base delay.
21
+ */
22
+ export declare function calculateDelayedErrorDelay(job: Pick<Job, 'backoff' | 'backoffConfig'>): number;
23
+ export declare function canRetry(job: Job): boolean;
@@ -0,0 +1,3 @@
1
+ import type { Job } from "../types/job.js";
2
+ /** Return the most recent persisted processor failure for a job. */
3
+ export declare function lastFailedReason(job: Pick<Job, 'timeline'>): string | undefined;
@@ -0,0 +1,78 @@
1
+ /**
2
+ * DependencyTracker - Tracks job dependencies and parent-child relationships
3
+ */
4
+ import type { Job, JobId } from "../types/job.js";
5
+ /**
6
+ * Manages job dependency tracking for a shard
7
+ * Provides O(1) lookup when dependencies complete
8
+ */
9
+ export declare class DependencyTracker {
10
+ /** Jobs waiting for dependencies */
11
+ readonly waitingDeps: Map<JobId, Job>;
12
+ /**
13
+ * Reverse index: depId -> Set of jobIds waiting for that dependency
14
+ * Enables O(1) lookup when a dependency completes instead of O(n) scan
15
+ */
16
+ readonly dependencyIndex: Map<JobId, Set<JobId>>;
17
+ /** Parent jobs waiting for children to complete */
18
+ readonly waitingChildren: Map<JobId, Job>;
19
+ /**
20
+ * Register a job's dependencies in the reverse index
21
+ * Call when adding a job to waitingDeps
22
+ */
23
+ registerDependencies(jobId: JobId, dependsOn: JobId[]): void;
24
+ /**
25
+ * Unregister a job's dependencies from the reverse index
26
+ * Call when removing a job from waitingDeps
27
+ */
28
+ unregisterDependencies(jobId: JobId, dependsOn: JobId[]): void;
29
+ /**
30
+ * Get jobs waiting for a specific dependency - O(1)
31
+ */
32
+ getJobsWaitingFor(depId: JobId): Set<JobId> | undefined;
33
+ /**
34
+ * Add a job that is waiting for dependencies
35
+ */
36
+ addWaitingJob(job: Job): void;
37
+ /**
38
+ * Remove a job from waiting deps
39
+ */
40
+ removeWaitingJob(jobId: JobId): Job | undefined;
41
+ /**
42
+ * Get a job waiting for dependencies
43
+ */
44
+ getWaitingJob(jobId: JobId): Job | undefined;
45
+ /**
46
+ * Check if a job is waiting for dependencies
47
+ */
48
+ isWaiting(jobId: JobId): boolean;
49
+ /**
50
+ * Add a parent job waiting for children
51
+ */
52
+ addWaitingParent(job: Job): void;
53
+ /**
54
+ * Remove a parent job from waiting
55
+ */
56
+ removeWaitingParent(jobId: JobId): Job | undefined;
57
+ /**
58
+ * Remove every dependency-gated job owned by a queue.
59
+ * Returns the removed ids so the caller can purge global indexes and storage.
60
+ */
61
+ removeQueue(queue: string): JobId[];
62
+ /**
63
+ * Get a parent job waiting for children
64
+ */
65
+ getWaitingParent(jobId: JobId): Job | undefined;
66
+ /**
67
+ * Check if a parent is waiting for children
68
+ */
69
+ isParentWaiting(jobId: JobId): boolean;
70
+ /**
71
+ * Get counts for debugging
72
+ */
73
+ getCounts(): {
74
+ waitingDeps: number;
75
+ dependencyIndex: number;
76
+ waitingChildren: number;
77
+ };
78
+ }
@@ -0,0 +1,66 @@
1
+ /**
2
+ * DlqShard - Dead Letter Queue operations for a shard
3
+ */
4
+ import type { Job, JobId } from "../types/job.js";
5
+ import type { DlqEntry, DlqConfig, DlqFilter } from "../types/dlq.js";
6
+ import { FailureReason } from "../types/dlq.js";
7
+ import type { StallConfig } from "../types/stall.js";
8
+ /** Stats callback for counter updates */
9
+ export interface DlqStatsCallback {
10
+ incrementDlq(): void;
11
+ decrementDlq(count?: number): void;
12
+ onEvict?(entry: DlqEntry): void;
13
+ }
14
+ /**
15
+ * Manages Dead Letter Queue operations for a shard
16
+ */
17
+ export declare class DlqShard {
18
+ /** Dead letter queue by queue name */
19
+ private readonly dlq;
20
+ /** DLQ configuration per queue */
21
+ private readonly dlqConfig;
22
+ /** Stall configuration per queue */
23
+ private readonly stallConfig;
24
+ /** Stats callback for counter updates */
25
+ private readonly stats;
26
+ constructor(stats: DlqStatsCallback);
27
+ /** Get DLQ config for queue */
28
+ getConfig(queue: string): DlqConfig;
29
+ /** Set DLQ config for queue */
30
+ setConfig(queue: string, config: Partial<DlqConfig>): void;
31
+ /** Get stall config for queue */
32
+ getStallConfig(queue: string): StallConfig;
33
+ /** Set stall config for queue */
34
+ setStallConfig(queue: string, config: Partial<StallConfig>): void;
35
+ /** Add job to DLQ with full metadata */
36
+ add(job: Job, reason?: FailureReason, error?: string | null): DlqEntry;
37
+ /** Restore an existing DlqEntry (for recovery from persistence) */
38
+ restoreEntry(queue: string, entry: DlqEntry): void;
39
+ /** Get DLQ entries (raw) */
40
+ getEntries(queue: string): DlqEntry[];
41
+ /** Get DLQ jobs (for backward compatibility) */
42
+ getJobs(queue: string, count?: number): Job[];
43
+ /** Get DLQ entries with filter */
44
+ getFiltered(queue: string, filter: DlqFilter): DlqEntry[];
45
+ /** Remove entry from DLQ by job ID */
46
+ remove(queue: string, jobId: JobId): DlqEntry | null;
47
+ /** Remove every entry with the same job ID from one queue. */
48
+ removeAll(queue: string, jobId: JobId): DlqEntry[];
49
+ /** Get entries ready for auto-retry */
50
+ getAutoRetryEntries(queue: string, now?: number): DlqEntry[];
51
+ /** Get expired entries for cleanup */
52
+ getExpiredEntries(queue: string, now?: number): DlqEntry[];
53
+ /** Remove expired entries */
54
+ purgeExpired(queue: string, now?: number): number;
55
+ /** Clear DLQ for queue */
56
+ clear(queue: string): number;
57
+ /** Get DLQ count for queue */
58
+ getCount(queue: string): number;
59
+ /** Get all queue names with DLQ entries */
60
+ getQueueNames(): string[];
61
+ /** Get queue names with persisted DLQ or stall policy. */
62
+ getConfiguredQueueNames(): string[];
63
+ /** Delete queue data */
64
+ deleteQueue(queue: string): number;
65
+ private evictUntil;
66
+ }
@@ -0,0 +1,30 @@
1
+ import { type GroupPullOptions, type GroupRateLimitOverride } from "../types/group.js";
2
+ export interface GroupLimitStatus {
3
+ eligible: boolean;
4
+ retryAt: number | null;
5
+ }
6
+ /** Stored group overrides and broker-authoritative runtime rate windows. */
7
+ export declare class GroupLimiterManager {
8
+ private readonly rateOverrides;
9
+ private readonly concurrencyOverrides;
10
+ private readonly windows;
11
+ private readonly manualRateLimits;
12
+ private readonly paused;
13
+ status(queue: string, groupId: string, defaults: GroupPullOptions | undefined, active: number, now?: number): GroupLimitStatus;
14
+ acquire(queue: string, groupId: string, defaults: GroupPullOptions | undefined, active: number, now?: number): boolean;
15
+ setRateLimit(queue: string, groupId: string, max: number, duration: number): void;
16
+ getRateLimit(queue: string, groupId: string): GroupRateLimitOverride | null;
17
+ removeRateLimit(queue: string, groupId: string): number;
18
+ getRateLimitTtl(queue: string, groupId: string, maxJobs?: number, now?: number): number;
19
+ setConcurrency(queue: string, groupId: string, concurrency: number): void;
20
+ getConcurrency(queue: string, groupId: string): number | null;
21
+ removeConcurrency(queue: string, groupId: string): number;
22
+ pause(queue: string, groupId: string): boolean;
23
+ resume(queue: string, groupId: string): boolean;
24
+ isPaused(queue: string, groupId: string): boolean;
25
+ rateLimit(queue: string, groupId: string, duration: number, now?: number): void;
26
+ getQueueNames(): string[];
27
+ clearQueue(queue: string): void;
28
+ pruneExpiredWindows(now?: number): void;
29
+ private currentWindow;
30
+ }
@@ -0,0 +1,31 @@
1
+ import { type Job } from "../types/job.js";
2
+ export interface GroupEligibility {
3
+ eligible: boolean;
4
+ retryAt: number | null;
5
+ }
6
+ export interface GroupCandidate {
7
+ job: Job | null;
8
+ nextRunAt: number | null;
9
+ }
10
+ /** Lazy secondary ready/group indexes; the primary queue remains authoritative. */
11
+ export declare class GroupScheduler {
12
+ private readonly queues;
13
+ private nextFifoOrder;
14
+ assignFifoOrder(job: Job): void;
15
+ observeFifoOrder(job: Job): void;
16
+ insert(queue: string, job: Job, primaryJobs: () => readonly Job[], now?: number): boolean;
17
+ remove(queue: string, job: Job): boolean;
18
+ isActive(queue: string): boolean;
19
+ peek(queue: string, now: number, eligibility: (groupId: string) => GroupEligibility, affinity?: string | null): GroupCandidate;
20
+ advance(queue: string, groupId: string): void;
21
+ getGroupJobsCount(queue: string, groupId: string): number;
22
+ getGroupsJobsCount(queue: string): number;
23
+ clearQueue(queue: string): void;
24
+ private createState;
25
+ private insertTracked;
26
+ private promoteDue;
27
+ private insertReady;
28
+ private demoteReady;
29
+ private attachLane;
30
+ private detachLane;
31
+ }
@@ -0,0 +1,6 @@
1
+ import type { Job } from "../types/job.js";
2
+ import type { HeapEntry } from "../types/priorityQueue.js";
3
+ export declare function orderedGroupClone(job: Job, runAt?: number): Job;
4
+ export declare function nextGroupCheckAt(job: Job): number;
5
+ export declare function compareGroupFifoEntries(left: HeapEntry, right: HeapEntry): number;
6
+ export declare function compareGroupWakeEntries(left: HeapEntry, right: HeapEntry): number;
@@ -0,0 +1,68 @@
1
+ /**
2
+ * LimiterManager - Rate limiting and concurrency control
3
+ */
4
+ import { type QueueState } from "../types/queue.js";
5
+ /**
6
+ * Manages rate limiting and concurrency for queues
7
+ */
8
+ export declare class LimiterManager {
9
+ /** Queue state (pause, rate limit, concurrency) */
10
+ private readonly queueState;
11
+ /** Rate limiters per queue */
12
+ private readonly rateLimiters;
13
+ /** Concurrency limiters per queue */
14
+ private readonly concurrencyLimiters;
15
+ /** Get queue state */
16
+ getState(name: string): QueueState;
17
+ /** Check if queue is paused */
18
+ isPaused(name: string): boolean;
19
+ /** Pause queue */
20
+ pause(name: string): void;
21
+ /** Resume queue */
22
+ resume(name: string): void;
23
+ /**
24
+ * Set rate limit for queue.
25
+ * @param durationMs window the limit applies to (default 1000ms): `limit`
26
+ * tokens refill over `durationMs`. Non-finite or non-positive → default.
27
+ * @param ttlMs auto-expiry: the limit clears itself after this many ms
28
+ * (lazy, checked on acquire/read). Non-finite or non-positive → permanent.
29
+ */
30
+ setRateLimit(queue: string, limit: number, durationMs?: number, ttlMs?: number): void;
31
+ /** Clear rate limit */
32
+ clearRateLimit(queue: string): void;
33
+ /**
34
+ * Drop the rate limit if its TTL has elapsed. Lazy expiry: called from the
35
+ * acquire path and from limit reads, so no timer is needed and an expired
36
+ * limit can never throttle a pull.
37
+ */
38
+ expireRateLimitIfNeeded(queue: string, now?: number): void;
39
+ /** Try to acquire rate limit token */
40
+ tryAcquireRateLimit(queue: string): boolean;
41
+ /** Read the active rate-limit configuration after applying lazy expiry. */
42
+ getRateLimit(queue: string): {
43
+ max: number;
44
+ duration: number;
45
+ } | null;
46
+ /** Read the remaining temporary-limit TTL or token-bucket cooldown. */
47
+ getRateLimitTtl(queue: string, maxJobs?: number): number;
48
+ /** Set concurrency limit for queue */
49
+ setConcurrency(queue: string, limit: number): void;
50
+ /** Clear concurrency limit */
51
+ clearConcurrency(queue: string): void;
52
+ /** Try to acquire concurrency slot */
53
+ tryAcquireConcurrency(queue: string): boolean;
54
+ /** Release concurrency slot */
55
+ releaseConcurrency(queue: string): void;
56
+ /** Read the configured global concurrency limit. */
57
+ getConcurrency(queue: string): number | null;
58
+ /** Whether all configured global concurrency slots are currently occupied. */
59
+ isConcurrencyMaxed(queue: string): boolean;
60
+ /** Get all queue names with state */
61
+ getQueueNames(): string[];
62
+ /** Get queues whose state contains an explicit policy rather than read-created defaults. */
63
+ getConfiguredQueueNames(now?: number): string[];
64
+ /** Delete queue data */
65
+ deleteQueue(queue: string): void;
66
+ /** Get the underlying state map (for backward compatibility) */
67
+ getStateMap(): Map<string, QueueState>;
68
+ }
@@ -0,0 +1,54 @@
1
+ import type { Job, JobId } from "../types/job.js";
2
+ import type { HeapEntry } from "../types/priorityQueue.js";
3
+ export interface PriorityQueueHooks {
4
+ onInsert(job: Job): boolean;
5
+ onRemove(job: Job): boolean;
6
+ }
7
+ export type PriorityQueueComparator = (left: HeapEntry, right: HeapEntry) => number;
8
+ export type PriorityQueueOrder = (job: Job) => bigint | null;
9
+ /** Indexed map-backed 4-ary heap with O(log4 n) mutations and O(1) lookup. */
10
+ export declare class IndexedPriorityQueue {
11
+ private readonly hooks?;
12
+ private readonly compare;
13
+ private readonly order?;
14
+ private static readonly D;
15
+ private heap;
16
+ private readonly index;
17
+ private generation;
18
+ private hooksActive;
19
+ constructor(hooks?: PriorityQueueHooks | undefined, compare?: PriorityQueueComparator, order?: PriorityQueueOrder | undefined);
20
+ get size(): number;
21
+ get isEmpty(): boolean;
22
+ push(job: Job): void;
23
+ pop(): Job | null;
24
+ peek(): Job | null;
25
+ find(jobId: JobId): Job | null;
26
+ has(jobId: JobId): boolean;
27
+ remove(jobId: JobId): Job | null;
28
+ /** Update job priority - O(log n). Optionally update the LIFO tie-break flag. */
29
+ updatePriority(jobId: JobId, newPriority: number, newLifo?: boolean): boolean;
30
+ /** Update job runAt (for delay changes) - O(log n) */
31
+ updateRunAt(jobId: JobId, newRunAt: number): boolean;
32
+ values(): Job[];
33
+ clear(): void;
34
+ /**
35
+ * Get the ratio of stale entries in the heap
36
+ * Used to decide when to compact
37
+ */
38
+ getStaleRatio(): number;
39
+ /**
40
+ * Compact the heap by removing stale entries
41
+ * Call when stale ratio exceeds threshold (e.g., 20%)
42
+ * O(n) operation but reclaims memory and improves performance
43
+ */
44
+ compact(): void;
45
+ private heapify;
46
+ /** Check if compaction is needed (stale ratio > threshold) */
47
+ needsCompaction(threshold?: number): boolean;
48
+ private removeTop;
49
+ /** 4-ary bubbleUp: parent at floor((idx-1)/D) */
50
+ private bubbleUp;
51
+ /** 4-ary bubbleDown: children at D*idx+1 through D*idx+D */
52
+ private bubbleDown;
53
+ private swap;
54
+ }