bunqueue 2.8.49 → 2.8.51

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 (149) hide show
  1. package/README.md +62 -9
  2. package/dist/application/backgroundTasks.js +21 -4
  3. package/dist/application/cleanupTasks.js +7 -3
  4. package/dist/application/contextFactory.d.ts +6 -3
  5. package/dist/application/contextFactory.js +8 -0
  6. package/dist/application/dependencyCompletions.d.ts +53 -0
  7. package/dist/application/dependencyCompletions.js +123 -0
  8. package/dist/application/dependencyProcessor.d.ts +5 -0
  9. package/dist/application/dependencyProcessor.js +25 -13
  10. package/dist/application/flowFailureRecovery.d.ts +20 -0
  11. package/dist/application/flowFailureRecovery.js +94 -0
  12. package/dist/application/flowParentBackpatch.d.ts +27 -0
  13. package/dist/application/flowParentBackpatch.js +120 -0
  14. package/dist/application/operations/ack.d.ts +6 -3
  15. package/dist/application/operations/ack.js +36 -10
  16. package/dist/application/operations/ackHelpers.d.ts +5 -4
  17. package/dist/application/operations/ackHelpers.js +4 -10
  18. package/dist/application/operations/customId.d.ts +3 -0
  19. package/dist/application/operations/customId.js +10 -0
  20. package/dist/application/operations/flowPush.d.ts +9 -0
  21. package/dist/application/operations/flowPush.js +112 -0
  22. package/dist/application/operations/flowTopologyValidation.d.ts +3 -0
  23. package/dist/application/operations/flowTopologyValidation.js +101 -0
  24. package/dist/application/operations/flowValidation.d.ts +3 -0
  25. package/dist/application/operations/flowValidation.js +166 -0
  26. package/dist/application/operations/jobManagement.d.ts +3 -0
  27. package/dist/application/operations/jobManagement.js +10 -4
  28. package/dist/application/operations/push.d.ts +6 -1
  29. package/dist/application/operations/push.js +2 -2
  30. package/dist/application/operations/pushInsert.d.ts +11 -2
  31. package/dist/application/operations/pushInsert.js +20 -8
  32. package/dist/application/operations/pushLocks.d.ts +1 -0
  33. package/dist/application/operations/pushLocks.js +5 -1
  34. package/dist/application/operations/queryOperations.js +7 -6
  35. package/dist/application/queueManager.d.ts +7 -0
  36. package/dist/application/queueManager.js +261 -67
  37. package/dist/application/types.d.ts +3 -1
  38. package/dist/cli/commandRouter.d.ts +1 -1
  39. package/dist/client/flow.d.ts +3 -6
  40. package/dist/client/flow.js +71 -210
  41. package/dist/client/flowAtomic.d.ts +9 -0
  42. package/dist/client/flowAtomic.js +24 -0
  43. package/dist/client/flowJobCoreMethods.d.ts +28 -0
  44. package/dist/client/flowJobCoreMethods.js +151 -0
  45. package/dist/client/flowJobDependencies.d.ts +7 -0
  46. package/dist/client/flowJobDependencies.js +64 -0
  47. package/dist/client/flowJobFactory.d.ts +11 -24
  48. package/dist/client/flowJobFactory.js +91 -360
  49. package/dist/client/flowJobMoveMethods.d.ts +16 -0
  50. package/dist/client/flowJobMoveMethods.js +112 -0
  51. package/dist/client/flowJobTypes.d.ts +29 -0
  52. package/dist/client/flowJobTypes.js +6 -0
  53. package/dist/client/flowLegacyPlan.d.ts +16 -0
  54. package/dist/client/flowLegacyPlan.js +118 -0
  55. package/dist/client/flowOptions.d.ts +10 -0
  56. package/dist/client/flowOptions.js +44 -0
  57. package/dist/client/flowPlan.d.ts +16 -0
  58. package/dist/client/flowPlan.js +101 -0
  59. package/dist/client/flowPush.js +4 -1
  60. package/dist/client/flowReader.d.ts +10 -0
  61. package/dist/client/flowReader.js +147 -0
  62. package/dist/client/flowTypes.d.ts +2 -2
  63. package/dist/client/jobHelpers.js +2 -0
  64. package/dist/client/workflow/clock.d.ts +3 -1
  65. package/dist/client/workflow/clock.js +18 -1
  66. package/dist/client/workflow/compensationChild.d.ts +30 -0
  67. package/dist/client/workflow/compensationChild.js +65 -0
  68. package/dist/client/workflow/compensationPass.d.ts +16 -0
  69. package/dist/client/workflow/compensationPass.js +96 -0
  70. package/dist/client/workflow/compensationSupport.d.ts +24 -0
  71. package/dist/client/workflow/compensationSupport.js +57 -0
  72. package/dist/client/workflow/compensator.d.ts +11 -50
  73. package/dist/client/workflow/compensator.js +22 -374
  74. package/dist/client/workflow/definitionGuard.d.ts +11 -0
  75. package/dist/client/workflow/definitionGuard.js +22 -0
  76. package/dist/client/workflow/engine.d.ts +2 -2
  77. package/dist/client/workflow/engine.js +8 -8
  78. package/dist/client/workflow/eventTypes.d.ts +44 -0
  79. package/dist/client/workflow/eventTypes.js +2 -0
  80. package/dist/client/workflow/executionTypes.d.ts +133 -0
  81. package/dist/client/workflow/executionTypes.js +2 -0
  82. package/dist/client/workflow/executor.d.ts +4 -17
  83. package/dist/client/workflow/executor.js +50 -208
  84. package/dist/client/workflow/executorLifecycle.d.ts +18 -0
  85. package/dist/client/workflow/executorLifecycle.js +69 -0
  86. package/dist/client/workflow/executorNodes.d.ts +17 -0
  87. package/dist/client/workflow/executorNodes.js +138 -0
  88. package/dist/client/workflow/identity.d.ts +2 -0
  89. package/dist/client/workflow/identity.js +8 -0
  90. package/dist/client/workflow/index.d.ts +1 -1
  91. package/dist/client/workflow/loops.d.ts +3 -5
  92. package/dist/client/workflow/loops.js +25 -23
  93. package/dist/client/workflow/mapRunner.d.ts +4 -0
  94. package/dist/client/workflow/mapRunner.js +45 -0
  95. package/dist/client/workflow/recovery.js +10 -3
  96. package/dist/client/workflow/runner.d.ts +2 -21
  97. package/dist/client/workflow/runner.js +39 -104
  98. package/dist/client/workflow/runnerTiming.d.ts +14 -0
  99. package/dist/client/workflow/runnerTiming.js +66 -0
  100. package/dist/client/workflow/stepTypes.d.ts +171 -0
  101. package/dist/client/workflow/stepTypes.js +3 -0
  102. package/dist/client/workflow/store.d.ts +17 -17
  103. package/dist/client/workflow/store.js +65 -100
  104. package/dist/client/workflow/storeExecutionCodec.d.ts +11 -0
  105. package/dist/client/workflow/storeExecutionCodec.js +34 -0
  106. package/dist/client/workflow/storeListing.d.ts +11 -0
  107. package/dist/client/workflow/storeListing.js +45 -0
  108. package/dist/client/workflow/storeMaintenance.d.ts +4 -0
  109. package/dist/client/workflow/storeMaintenance.js +40 -0
  110. package/dist/client/workflow/storeSignals.d.ts +9 -0
  111. package/dist/client/workflow/storeSignals.js +38 -2
  112. package/dist/client/workflow/subWorkflowRunner.d.ts +13 -0
  113. package/dist/client/workflow/subWorkflowRunner.js +40 -0
  114. package/dist/client/workflow/types.d.ts +4 -356
  115. package/dist/client/workflow/types.js +1 -3
  116. package/dist/client/workflow/waitFor.js +39 -26
  117. package/dist/client/workflow/workflow.d.ts +16 -59
  118. package/dist/client/workflow/workflow.js +53 -179
  119. package/dist/client/workflow/workflowDecisions.d.ts +11 -0
  120. package/dist/client/workflow/workflowDecisions.js +27 -0
  121. package/dist/client/workflow/workflowDefinition.d.ts +16 -0
  122. package/dist/client/workflow/workflowDefinition.js +123 -0
  123. package/dist/client/workflow/workflowIntrospection.d.ts +5 -0
  124. package/dist/client/workflow/workflowIntrospection.js +46 -0
  125. package/dist/client/workflow/workflowValidation.d.ts +44 -0
  126. package/dist/client/workflow/workflowValidation.js +143 -0
  127. package/dist/domain/types/command.d.ts +7 -1
  128. package/dist/domain/types/flow.d.ts +25 -0
  129. package/dist/domain/types/flow.js +1 -0
  130. package/dist/infrastructure/persistence/dependencyCompletionSchema.d.ts +6 -0
  131. package/dist/infrastructure/persistence/dependencyCompletionSchema.js +16 -0
  132. package/dist/infrastructure/persistence/dependencyCompletionStore.d.ts +38 -0
  133. package/dist/infrastructure/persistence/dependencyCompletionStore.js +105 -0
  134. package/dist/infrastructure/persistence/schema.d.ts +2 -5
  135. package/dist/infrastructure/persistence/schema.js +57 -3
  136. package/dist/infrastructure/persistence/sqlite.d.ts +35 -0
  137. package/dist/infrastructure/persistence/sqlite.js +238 -12
  138. package/dist/infrastructure/persistence/sqliteBatch.js +10 -4
  139. package/dist/infrastructure/persistence/sqliteSerializer.d.ts +5 -0
  140. package/dist/infrastructure/persistence/sqliteSerializer.js +28 -5
  141. package/dist/infrastructure/persistence/statements.d.ts +4 -0
  142. package/dist/infrastructure/persistence/statements.js +8 -2
  143. package/dist/infrastructure/server/handlerRoutes.js +3 -0
  144. package/dist/infrastructure/server/handlers/advanced.js +2 -2
  145. package/dist/infrastructure/server/handlers/flow.d.ts +7 -0
  146. package/dist/infrastructure/server/handlers/flow.js +11 -0
  147. package/dist/infrastructure/server/handlers/index.d.ts +1 -0
  148. package/dist/infrastructure/server/handlers/index.js +1 -0
  149. package/package.json +4 -2
@@ -15,12 +15,14 @@ export const SQL_STATEMENTS = {
15
15
  id, queue, data, priority, created_at, run_at, attempts,
16
16
  max_attempts, backoff, ttl, timeout, unique_key, custom_id,
17
17
  depends_on, parent_id, children_ids, tags, state, lifo, group_id,
18
- remove_on_complete, remove_on_fail, stall_timeout, stall_count, timeline
18
+ remove_on_complete, remove_on_fail, fail_parent_on_failure,
19
+ remove_dependency_on_failure, continue_parent_on_failure,
20
+ ignore_dependency_on_failure, stall_timeout, stall_count, timeline
19
21
  ) VALUES (
20
22
  ?, ?, ?, ?, ?, ?, ?,
21
23
  ?, ?, ?, ?, ?, ?,
22
24
  ?, ?, ?, ?, ?, ?, ?,
23
- ?, ?, ?, ?, ?
25
+ ?, ?, ?, ?, ?, ?, ?, ?, ?
24
26
  )
25
27
  ON CONFLICT(id) DO UPDATE SET
26
28
  queue=excluded.queue, data=excluded.data, priority=excluded.priority,
@@ -30,6 +32,10 @@ export const SQL_STATEMENTS = {
30
32
  depends_on=excluded.depends_on, parent_id=excluded.parent_id, children_ids=excluded.children_ids,
31
33
  tags=excluded.tags, state=excluded.state, lifo=excluded.lifo, group_id=excluded.group_id,
32
34
  remove_on_complete=excluded.remove_on_complete, remove_on_fail=excluded.remove_on_fail,
35
+ fail_parent_on_failure=excluded.fail_parent_on_failure,
36
+ remove_dependency_on_failure=excluded.remove_dependency_on_failure,
37
+ continue_parent_on_failure=excluded.continue_parent_on_failure,
38
+ ignore_dependency_on_failure=excluded.ignore_dependency_on_failure,
33
39
  stall_timeout=excluded.stall_timeout, stall_count=excluded.stall_count,
34
40
  timeline=excluded.timeline,
35
41
  -- Per-execution columns are NOT in the INSERT column list, so excluded.<col>
@@ -3,6 +3,7 @@
3
3
  */
4
4
  // Import handlers
5
5
  import { handlePush, handlePushBatch, handlePull, handlePullBatch, handleAck, handleAckBatch, handleFail, } from './handlers/core';
6
+ import { handlePushFlow } from './handlers/flow';
6
7
  import { handleGetJob, handleGetState, handleGetResult, handleGetJobCounts, handleGetCountsPerPriority, handleGetJobByCustomId, handleGetJobs, handleGetChildrenValues, } from './handlers/query';
7
8
  import { handleCancel, handleProgress, handleGetProgress, handlePause, handleResume, handleDrain, handleStats, handleMetrics, handleStorageStatus, } from './handlers/management';
8
9
  import { handleDlq, handleRetryDlq, handlePurgeDlq, handleRetryCompleted } from './handlers/dlq';
@@ -18,6 +19,8 @@ export async function routeCoreCommand(cmd, ctx, reqId) {
18
19
  return handlePush(cmd, ctx, reqId);
19
20
  case 'PUSHB':
20
21
  return handlePushBatch(cmd, ctx, reqId);
22
+ case 'PUSHF':
23
+ return handlePushFlow(cmd, ctx, reqId);
21
24
  case 'PULL':
22
25
  return handlePull(cmd, ctx, reqId);
23
26
  case 'PULLB':
@@ -78,8 +78,8 @@ export async function handleUpdateParent(cmd, ctx, reqId) {
78
78
  await ctx.queueManager.updateJobParent(jobId(cmd.childId), jobId(cmd.parentId));
79
79
  return resp.ok(undefined, reqId);
80
80
  }
81
- catch {
82
- return resp.error('Failed to update parent', reqId);
81
+ catch (error) {
82
+ return resp.error(error instanceof Error ? error.message : 'Failed to update parent', reqId);
83
83
  }
84
84
  }
85
85
  /** Handle MoveToDelayed command */
@@ -0,0 +1,7 @@
1
+ import type { Command } from '../../../domain/types/command';
2
+ import type { Response } from '../../../domain/types/response';
3
+ import type { HandlerContext } from '../types';
4
+ /** Commit the whole graph in one broker operation; validation happens pre-mutation. */
5
+ export declare function handlePushFlow(cmd: Extract<Command, {
6
+ cmd: 'PUSHF';
7
+ }>, ctx: HandlerContext, reqId?: string): Promise<Response>;
@@ -0,0 +1,11 @@
1
+ import * as resp from '../../../domain/types/response';
2
+ /** Commit the whole graph in one broker operation; validation happens pre-mutation. */
3
+ export async function handlePushFlow(cmd, ctx, reqId) {
4
+ try {
5
+ const result = await ctx.queueManager.pushFlow({ jobs: cmd.jobs });
6
+ return resp.data(result, reqId);
7
+ }
8
+ catch (error) {
9
+ return resp.error(error instanceof Error ? error.message : String(error), reqId);
10
+ }
11
+ }
@@ -2,6 +2,7 @@
2
2
  * Handler barrel export
3
3
  */
4
4
  export * from './core';
5
+ export * from './flow';
5
6
  export * from './query';
6
7
  export * from './management';
7
8
  export * from './dashboard';
@@ -2,6 +2,7 @@
2
2
  * Handler barrel export
3
3
  */
4
4
  export * from './core';
5
+ export * from './flow';
5
6
  export * from './query';
6
7
  export * from './management';
7
8
  export * from './dashboard';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunqueue",
3
- "version": "2.8.49",
3
+ "version": "2.8.51",
4
4
  "description": "High-performance job queue for Bun & AI agents. SQLite persistence, cron scheduling, priorities, retries, DLQ, webhooks, native MCP server. Zero external infrastructure.",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
@@ -59,13 +59,15 @@
59
59
  "docs:api": "bun run scripts/build-api-reference.ts",
60
60
  "check:docs-data": "bun run scripts/check-docs-data.ts",
61
61
  "test": "BUNQUEUE_EMBEDDED=1 bun test",
62
- "test:model": "BUNQUEUE_EMBEDDED=1 bun test test/model-based/queue-model.test.ts test/model-based/workflow-model.test.ts test/model-based/backup-model.test.ts test/model-based/monitoring-model.test.ts test/model-based/enterprise-telemetry-model.test.ts",
62
+ "test:model": "BUNQUEUE_EMBEDDED=1 bun test test/model-based/queue-model.test.ts test/model-based/workflow-model.test.ts test/model-based/flow-producer-model.test.ts test/model-based/backup-model.test.ts test/model-based/monitoring-model.test.ts test/model-based/enterprise-telemetry-model.test.ts",
63
63
  "test:sandbox": "bun run scripts/test-sandbox.ts",
64
64
  "test:sandbox:sdk": "bun run scripts/test-sdk-sandbox.ts",
65
65
  "bench": "bun run bench/comprehensive.ts",
66
66
  "bench:tcp": "bun run bench/tcp-bench.ts",
67
67
  "bench:autobatch": "bun run bench/local-autobatch.ts",
68
68
  "bench:pushbulk": "bun run bench/pushbulk-delta.ts",
69
+ "bench:workflow": "bun run bench/workflow-engine.ts",
70
+ "bench:workflow:scale": "bun run bench/workflow-engine/scale.ts",
69
71
  "bench:joblist": "bun run bench/job-list-perf.ts",
70
72
  "bench:compare": "bun run bench/comparison/run.ts",
71
73
  "lint": "biome lint src",