bullmq 1.58.0 → 1.59.3

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 (383) hide show
  1. package/dist/bullmq.d.ts +1839 -0
  2. package/dist/{classes → cjs/classes}/backoffs.d.ts +0 -0
  3. package/dist/{classes → cjs/classes}/backoffs.js +0 -0
  4. package/dist/cjs/classes/backoffs.js.map +1 -0
  5. package/dist/{classes → cjs/classes}/child-pool.d.ts +0 -0
  6. package/dist/{classes → cjs/classes}/child-pool.js +1 -1
  7. package/dist/cjs/classes/child-pool.js.map +1 -0
  8. package/dist/{classes → cjs/classes}/child-processor.d.ts +0 -0
  9. package/dist/{classes → cjs/classes}/child-processor.js +0 -0
  10. package/dist/cjs/classes/child-processor.js.map +1 -0
  11. package/dist/{classes → cjs/classes}/compat.d.ts +0 -0
  12. package/dist/{classes → cjs/classes}/compat.js +0 -0
  13. package/dist/cjs/classes/compat.js.map +1 -0
  14. package/dist/{classes → cjs/classes}/flow-producer.d.ts +0 -0
  15. package/dist/{classes → cjs/classes}/flow-producer.js +0 -0
  16. package/dist/cjs/classes/flow-producer.js.map +1 -0
  17. package/dist/{classes → cjs/classes}/index.d.ts +0 -0
  18. package/dist/{classes → cjs/classes}/index.js +0 -0
  19. package/dist/cjs/classes/index.js.map +1 -0
  20. package/dist/{classes → cjs/classes}/job.d.ts +0 -0
  21. package/dist/{classes → cjs/classes}/job.js +0 -0
  22. package/dist/cjs/classes/job.js.map +1 -0
  23. package/dist/{classes → cjs/classes}/master.d.ts +0 -0
  24. package/dist/{classes → cjs/classes}/master.js +0 -0
  25. package/dist/cjs/classes/master.js.map +1 -0
  26. package/dist/{classes → cjs/classes}/process-utils.d.ts +0 -0
  27. package/dist/{classes → cjs/classes}/process-utils.js +0 -0
  28. package/dist/cjs/classes/process-utils.js.map +1 -0
  29. package/dist/{classes → cjs/classes}/queue-base.d.ts +0 -0
  30. package/dist/{classes → cjs/classes}/queue-base.js +0 -0
  31. package/dist/cjs/classes/queue-base.js.map +1 -0
  32. package/dist/{classes → cjs/classes}/queue-events.d.ts +0 -0
  33. package/dist/{classes → cjs/classes}/queue-events.js +0 -0
  34. package/dist/cjs/classes/queue-events.js.map +1 -0
  35. package/dist/{classes → cjs/classes}/queue-getters.d.ts +0 -0
  36. package/dist/{classes → cjs/classes}/queue-getters.js +0 -0
  37. package/dist/cjs/classes/queue-getters.js.map +1 -0
  38. package/dist/{classes → cjs/classes}/queue-keys.d.ts +0 -0
  39. package/dist/{classes → cjs/classes}/queue-keys.js +0 -0
  40. package/dist/cjs/classes/queue-keys.js.map +1 -0
  41. package/dist/{classes → cjs/classes}/queue-scheduler.d.ts +0 -0
  42. package/dist/{classes → cjs/classes}/queue-scheduler.js +0 -0
  43. package/dist/cjs/classes/queue-scheduler.js.map +1 -0
  44. package/dist/{classes → cjs/classes}/queue.d.ts +0 -0
  45. package/dist/{classes → cjs/classes}/queue.js +0 -0
  46. package/dist/cjs/classes/queue.js.map +1 -0
  47. package/dist/{classes → cjs/classes}/redis-connection.d.ts +0 -0
  48. package/dist/{classes → cjs/classes}/redis-connection.js +3 -3
  49. package/dist/cjs/classes/redis-connection.js.map +1 -0
  50. package/dist/{classes → cjs/classes}/repeat.d.ts +0 -0
  51. package/dist/{classes → cjs/classes}/repeat.js +0 -0
  52. package/dist/cjs/classes/repeat.js.map +1 -0
  53. package/dist/{classes → cjs/classes}/sandbox.d.ts +0 -0
  54. package/dist/{classes → cjs/classes}/sandbox.js +0 -0
  55. package/dist/cjs/classes/sandbox.js.map +1 -0
  56. package/dist/{classes → cjs/classes}/scripts.d.ts +0 -0
  57. package/dist/{classes → cjs/classes}/scripts.js +0 -0
  58. package/dist/cjs/classes/scripts.js.map +1 -0
  59. package/dist/{classes → cjs/classes}/timer-manager.d.ts +0 -0
  60. package/dist/{classes → cjs/classes}/timer-manager.js +0 -0
  61. package/dist/cjs/classes/timer-manager.js.map +1 -0
  62. package/dist/{classes → cjs/classes}/worker.d.ts +0 -0
  63. package/dist/{classes → cjs/classes}/worker.js +4 -10
  64. package/dist/cjs/classes/worker.js.map +1 -0
  65. package/dist/{commands → cjs/commands}/addJob-9.lua +0 -0
  66. package/dist/{commands → cjs/commands}/changeDelay-4.lua +0 -0
  67. package/dist/{commands → cjs/commands}/cleanJobsInSet-2.lua +0 -0
  68. package/dist/{commands → cjs/commands}/drain-4.lua +0 -0
  69. package/dist/{commands → cjs/commands}/extendLock-2.lua +0 -0
  70. package/dist/{commands → cjs/commands}/getState-7.lua +0 -0
  71. package/dist/{commands → cjs/commands}/getStateV2-7.lua +0 -0
  72. package/dist/{commands → cjs/commands}/includes/destructureJobKey.lua +0 -0
  73. package/dist/{commands → cjs/commands}/includes/updateParentDepsIfNeeded.lua +0 -0
  74. package/dist/{commands → cjs/commands}/index.d.ts +0 -0
  75. package/dist/{commands → cjs/commands}/index.js +0 -0
  76. package/dist/cjs/commands/index.js.map +1 -0
  77. package/dist/{commands → cjs/commands}/isFinished-3.lua +0 -0
  78. package/dist/{commands → cjs/commands}/isJobInList-1.lua +0 -0
  79. package/dist/{commands → cjs/commands}/moveStalledJobsToWait-8.lua +0 -0
  80. package/dist/{commands → cjs/commands}/moveToActive-8.lua +0 -0
  81. package/dist/{commands → cjs/commands}/moveToDelayed-5.lua +0 -0
  82. package/dist/{commands → cjs/commands}/moveToFinished-8.lua +0 -0
  83. package/dist/{commands → cjs/commands}/moveToWaitingChildren-4.lua +0 -0
  84. package/dist/{commands → cjs/commands}/obliterate-2.lua +0 -0
  85. package/dist/{commands → cjs/commands}/pause-4.lua +0 -0
  86. package/dist/{commands → cjs/commands}/promote-5.lua +0 -0
  87. package/dist/{commands → cjs/commands}/releaseLock-1.lua +0 -0
  88. package/dist/{commands → cjs/commands}/removeJob-1.lua +0 -0
  89. package/dist/{commands → cjs/commands}/removeRepeatable-2.lua +0 -0
  90. package/dist/{commands → cjs/commands}/reprocessJob-4.lua +0 -0
  91. package/dist/{commands → cjs/commands}/retryJob-4.lua +0 -0
  92. package/dist/{commands → cjs/commands}/script-loader.d.ts +0 -0
  93. package/dist/{commands → cjs/commands}/script-loader.js +0 -0
  94. package/dist/cjs/commands/script-loader.js.map +1 -0
  95. package/dist/{commands → cjs/commands}/takeLock-1.lua +0 -0
  96. package/dist/{commands → cjs/commands}/updateDelaySet-7.lua +0 -0
  97. package/dist/{commands → cjs/commands}/updateProgress-2.lua +0 -0
  98. package/dist/{enums → cjs/enums}/error-codes.enum.d.ts +0 -0
  99. package/dist/{enums → cjs/enums}/error-codes.enum.js +0 -0
  100. package/dist/cjs/enums/error-codes.enum.js.map +1 -0
  101. package/dist/{enums → cjs/enums}/index.d.ts +0 -0
  102. package/dist/{enums → cjs/enums}/index.js +0 -0
  103. package/dist/{enums → cjs/enums}/index.js.map +1 -1
  104. package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
  105. package/dist/{index.js → cjs/index.js} +0 -0
  106. package/dist/cjs/index.js.map +1 -0
  107. package/dist/{interfaces → cjs/interfaces}/advanced-options.d.ts +0 -0
  108. package/dist/{interfaces → cjs/interfaces}/advanced-options.js +0 -0
  109. package/dist/cjs/interfaces/advanced-options.js.map +1 -0
  110. package/dist/{interfaces → cjs/interfaces}/backoff-options.d.ts +0 -0
  111. package/dist/{interfaces → cjs/interfaces}/backoff-options.js +0 -0
  112. package/dist/cjs/interfaces/backoff-options.js.map +1 -0
  113. package/dist/{interfaces → cjs/interfaces}/child-command.d.ts +0 -0
  114. package/dist/{interfaces → cjs/interfaces}/child-command.js +0 -0
  115. package/dist/cjs/interfaces/child-command.js.map +1 -0
  116. package/dist/{interfaces → cjs/interfaces}/child-message.d.ts +0 -0
  117. package/dist/{interfaces → cjs/interfaces}/child-message.js +0 -0
  118. package/dist/cjs/interfaces/child-message.js.map +1 -0
  119. package/dist/{interfaces → cjs/interfaces}/connection.d.ts +0 -0
  120. package/dist/{interfaces → cjs/interfaces}/connection.js +0 -0
  121. package/dist/cjs/interfaces/connection.js.map +1 -0
  122. package/dist/{interfaces → cjs/interfaces}/flow-job.d.ts +0 -0
  123. package/dist/{interfaces → cjs/interfaces}/flow-job.js +0 -0
  124. package/dist/{interfaces → cjs/interfaces}/flow-job.js.map +1 -1
  125. package/dist/{interfaces → cjs/interfaces}/index.d.ts +0 -0
  126. package/dist/{interfaces → cjs/interfaces}/index.js +0 -0
  127. package/dist/cjs/interfaces/index.js.map +1 -0
  128. package/dist/{interfaces → cjs/interfaces}/jobs-options.d.ts +0 -0
  129. package/dist/{interfaces → cjs/interfaces}/jobs-options.js +0 -0
  130. package/dist/cjs/interfaces/jobs-options.js.map +1 -0
  131. package/dist/{interfaces → cjs/interfaces}/parent-command.d.ts +0 -0
  132. package/dist/{interfaces → cjs/interfaces}/parent-command.js +0 -0
  133. package/dist/cjs/interfaces/parent-command.js.map +1 -0
  134. package/dist/{interfaces → cjs/interfaces}/parent-message.d.ts +0 -0
  135. package/dist/{interfaces → cjs/interfaces}/parent-message.js +0 -0
  136. package/dist/cjs/interfaces/parent-message.js.map +1 -0
  137. package/dist/{interfaces → cjs/interfaces}/parent.d.ts +0 -0
  138. package/dist/{interfaces → cjs/interfaces}/parent.js +0 -0
  139. package/dist/{interfaces → cjs/interfaces}/parent.js.map +1 -1
  140. package/dist/{interfaces → cjs/interfaces}/queue-options.d.ts +0 -0
  141. package/dist/{interfaces → cjs/interfaces}/queue-options.js +0 -0
  142. package/dist/cjs/interfaces/queue-options.js.map +1 -0
  143. package/dist/{interfaces → cjs/interfaces}/queue-scheduler-options.d.ts +0 -0
  144. package/dist/{interfaces → cjs/interfaces}/queue-scheduler-options.js +0 -0
  145. package/dist/cjs/interfaces/queue-scheduler-options.js.map +1 -0
  146. package/dist/{interfaces → cjs/interfaces}/rate-limiter-options.d.ts +0 -0
  147. package/dist/{interfaces → cjs/interfaces}/rate-limiter-options.js +0 -0
  148. package/dist/cjs/interfaces/rate-limiter-options.js.map +1 -0
  149. package/dist/{interfaces → cjs/interfaces}/redis-options.d.ts +0 -0
  150. package/dist/{interfaces → cjs/interfaces}/redis-options.js +0 -0
  151. package/dist/cjs/interfaces/redis-options.js.map +1 -0
  152. package/dist/{interfaces → cjs/interfaces}/redis-streams.d.ts +0 -0
  153. package/dist/{interfaces → cjs/interfaces}/redis-streams.js +0 -0
  154. package/dist/cjs/interfaces/redis-streams.js.map +1 -0
  155. package/dist/{interfaces → cjs/interfaces}/repeat-options.d.ts +0 -0
  156. package/dist/{interfaces → cjs/interfaces}/repeat-options.js +0 -0
  157. package/dist/cjs/interfaces/repeat-options.js.map +1 -0
  158. package/dist/{interfaces → cjs/interfaces}/sandboxed-job-processor.d.ts +0 -0
  159. package/dist/{interfaces → cjs/interfaces}/sandboxed-job-processor.js +0 -0
  160. package/dist/cjs/interfaces/sandboxed-job-processor.js.map +1 -0
  161. package/dist/{interfaces → cjs/interfaces}/sandboxed-job.d.ts +0 -0
  162. package/dist/{interfaces → cjs/interfaces}/sandboxed-job.js +0 -0
  163. package/dist/cjs/interfaces/sandboxed-job.js.map +1 -0
  164. package/dist/{interfaces → cjs/interfaces}/worker-options.d.ts +0 -0
  165. package/dist/{interfaces → cjs/interfaces}/worker-options.js +0 -0
  166. package/dist/cjs/interfaces/worker-options.js.map +1 -0
  167. package/dist/{utils.d.ts → cjs/utils.d.ts} +0 -0
  168. package/dist/{utils.js → cjs/utils.js} +0 -0
  169. package/dist/cjs/utils.js.map +1 -0
  170. package/dist/esm/classes/backoffs.d.ts +15 -0
  171. package/dist/esm/classes/backoffs.js +44 -0
  172. package/dist/esm/classes/backoffs.js.map +1 -0
  173. package/dist/esm/classes/child-pool.d.ts +22 -0
  174. package/dist/esm/classes/child-pool.js +125 -0
  175. package/dist/esm/classes/child-pool.js.map +1 -0
  176. package/dist/esm/classes/child-processor.d.ts +24 -0
  177. package/dist/esm/classes/child-processor.js +165 -0
  178. package/dist/esm/classes/child-processor.js.map +1 -0
  179. package/dist/esm/classes/compat.d.ts +316 -0
  180. package/dist/esm/classes/compat.js +674 -0
  181. package/dist/esm/classes/compat.js.map +1 -0
  182. package/dist/esm/classes/flow-producer.d.ts +148 -0
  183. package/dist/esm/classes/flow-producer.js +228 -0
  184. package/dist/esm/classes/flow-producer.js.map +1 -0
  185. package/dist/esm/classes/index.d.ts +14 -0
  186. package/dist/esm/classes/index.js +15 -0
  187. package/dist/esm/classes/index.js.map +1 -0
  188. package/dist/esm/classes/job.d.ts +338 -0
  189. package/dist/esm/classes/job.js +623 -0
  190. package/dist/esm/classes/job.js.map +1 -0
  191. package/dist/esm/classes/master.d.ts +1 -0
  192. package/dist/esm/classes/master.js +35 -0
  193. package/dist/esm/classes/master.js.map +1 -0
  194. package/dist/esm/classes/process-utils.d.ts +7 -0
  195. package/dist/esm/classes/process-utils.js +31 -0
  196. package/dist/esm/classes/process-utils.js.map +1 -0
  197. package/dist/esm/classes/queue-base.d.ts +22 -0
  198. package/dist/esm/classes/queue-base.js +62 -0
  199. package/dist/esm/classes/queue-base.js.map +1 -0
  200. package/dist/esm/classes/queue-events.d.ts +153 -0
  201. package/dist/esm/classes/queue-events.js +108 -0
  202. package/dist/esm/classes/queue-events.js.map +1 -0
  203. package/dist/esm/classes/queue-getters.d.ts +54 -0
  204. package/dist/esm/classes/queue-getters.js +207 -0
  205. package/dist/esm/classes/queue-getters.js.map +1 -0
  206. package/dist/esm/classes/queue-keys.d.ts +10 -0
  207. package/dist/esm/classes/queue-keys.js +40 -0
  208. package/dist/esm/classes/queue-keys.js.map +1 -0
  209. package/dist/esm/classes/queue-scheduler.d.ts +35 -0
  210. package/dist/esm/classes/queue-scheduler.js +156 -0
  211. package/dist/esm/classes/queue-scheduler.js.map +1 -0
  212. package/dist/esm/classes/queue.d.ts +143 -0
  213. package/dist/esm/classes/queue.js +195 -0
  214. package/dist/esm/classes/queue.js.map +1 -0
  215. package/dist/esm/classes/redis-connection.d.ts +28 -0
  216. package/dist/esm/classes/redis-connection.js +164 -0
  217. package/dist/esm/classes/redis-connection.js.map +1 -0
  218. package/dist/esm/classes/repeat.d.ts +20 -0
  219. package/dist/esm/classes/repeat.js +140 -0
  220. package/dist/esm/classes/repeat.js.map +1 -0
  221. package/dist/esm/classes/sandbox.d.ts +4 -0
  222. package/dist/esm/classes/sandbox.js +56 -0
  223. package/dist/esm/classes/sandbox.js.map +1 -0
  224. package/dist/esm/classes/scripts.d.ts +82 -0
  225. package/dist/esm/classes/scripts.js +510 -0
  226. package/dist/esm/classes/scripts.js.map +1 -0
  227. package/dist/esm/classes/timer-manager.d.ts +17 -0
  228. package/dist/esm/classes/timer-manager.js +47 -0
  229. package/dist/esm/classes/timer-manager.js.map +1 -0
  230. package/dist/esm/classes/worker.d.ts +168 -0
  231. package/dist/esm/classes/worker.js +463 -0
  232. package/dist/esm/classes/worker.js.map +1 -0
  233. package/dist/esm/commands/addJob-9.lua +179 -0
  234. package/dist/esm/commands/changeDelay-4.lua +41 -0
  235. package/dist/esm/commands/cleanJobsInSet-2.lua +65 -0
  236. package/dist/esm/commands/drain-4.lua +36 -0
  237. package/dist/esm/commands/extendLock-2.lua +23 -0
  238. package/dist/esm/commands/getState-7.lua +63 -0
  239. package/dist/esm/commands/getStateV2-7.lua +51 -0
  240. package/dist/esm/commands/includes/destructureJobKey.lua +12 -0
  241. package/dist/esm/commands/includes/updateParentDepsIfNeeded.lua +19 -0
  242. package/dist/esm/commands/index.d.ts +4 -0
  243. package/dist/esm/commands/index.js +5 -0
  244. package/dist/esm/commands/index.js.map +1 -0
  245. package/dist/esm/commands/isFinished-3.lua +48 -0
  246. package/dist/esm/commands/isJobInList-1.lua +20 -0
  247. package/dist/esm/commands/moveStalledJobsToWait-8.lua +112 -0
  248. package/dist/esm/commands/moveToActive-8.lua +100 -0
  249. package/dist/esm/commands/moveToDelayed-5.lua +45 -0
  250. package/dist/esm/commands/moveToFinished-8.lua +159 -0
  251. package/dist/esm/commands/moveToWaitingChildren-4.lua +60 -0
  252. package/dist/esm/commands/obliterate-2.lua +129 -0
  253. package/dist/esm/commands/pause-4.lua +27 -0
  254. package/dist/esm/commands/promote-5.lua +54 -0
  255. package/dist/esm/commands/releaseLock-1.lua +19 -0
  256. package/dist/esm/commands/removeJob-1.lua +115 -0
  257. package/dist/esm/commands/removeRepeatable-2.lua +23 -0
  258. package/dist/esm/commands/reprocessJob-4.lua +32 -0
  259. package/dist/esm/commands/retryJob-4.lua +34 -0
  260. package/dist/esm/commands/script-loader.d.ts +120 -0
  261. package/dist/esm/commands/script-loader.js +395 -0
  262. package/dist/esm/commands/script-loader.js.map +1 -0
  263. package/dist/esm/commands/takeLock-1.lua +17 -0
  264. package/dist/esm/commands/updateDelaySet-7.lua +73 -0
  265. package/dist/esm/commands/updateProgress-2.lua +15 -0
  266. package/dist/esm/enums/error-codes.enum.d.ts +7 -0
  267. package/dist/esm/enums/error-codes.enum.js +9 -0
  268. package/dist/esm/enums/error-codes.enum.js.map +1 -0
  269. package/dist/esm/enums/index.d.ts +1 -0
  270. package/dist/esm/enums/index.js +2 -0
  271. package/dist/esm/enums/index.js.map +1 -0
  272. package/dist/esm/index.d.ts +5 -0
  273. package/dist/esm/index.js +6 -0
  274. package/dist/esm/index.js.map +1 -0
  275. package/dist/esm/interfaces/advanced-options.d.ts +6 -0
  276. package/dist/esm/interfaces/advanced-options.js +2 -0
  277. package/dist/esm/interfaces/advanced-options.js.map +1 -0
  278. package/dist/esm/interfaces/backoff-options.d.ts +15 -0
  279. package/dist/esm/interfaces/backoff-options.js +2 -0
  280. package/dist/esm/interfaces/backoff-options.js.map +1 -0
  281. package/dist/esm/interfaces/child-command.d.ts +5 -0
  282. package/dist/esm/interfaces/child-command.js +7 -0
  283. package/dist/esm/interfaces/child-command.js.map +1 -0
  284. package/dist/esm/interfaces/child-message.d.ts +6 -0
  285. package/dist/esm/interfaces/child-message.js +2 -0
  286. package/dist/esm/interfaces/child-message.js.map +1 -0
  287. package/dist/esm/interfaces/connection.d.ts +8 -0
  288. package/dist/esm/interfaces/connection.js +2 -0
  289. package/dist/esm/interfaces/connection.js.map +1 -0
  290. package/dist/esm/interfaces/flow-job.d.ts +14 -0
  291. package/dist/esm/interfaces/flow-job.js +2 -0
  292. package/dist/esm/interfaces/flow-job.js.map +1 -0
  293. package/dist/esm/interfaces/index.d.ts +19 -0
  294. package/dist/esm/interfaces/index.js +20 -0
  295. package/dist/esm/interfaces/index.js.map +1 -0
  296. package/dist/esm/interfaces/jobs-options.d.ts +91 -0
  297. package/dist/esm/interfaces/jobs-options.js +2 -0
  298. package/dist/esm/interfaces/jobs-options.js.map +1 -0
  299. package/dist/esm/interfaces/parent-command.d.ts +9 -0
  300. package/dist/esm/interfaces/parent-command.js +11 -0
  301. package/dist/esm/interfaces/parent-command.js.map +1 -0
  302. package/dist/esm/interfaces/parent-message.d.ts +8 -0
  303. package/dist/esm/interfaces/parent-message.js +2 -0
  304. package/dist/esm/interfaces/parent-message.js.map +1 -0
  305. package/dist/esm/interfaces/parent.d.ts +11 -0
  306. package/dist/esm/interfaces/parent.js +2 -0
  307. package/dist/esm/interfaces/parent.js.map +1 -0
  308. package/dist/esm/interfaces/queue-options.d.ts +72 -0
  309. package/dist/esm/interfaces/queue-options.js +6 -0
  310. package/dist/esm/interfaces/queue-options.js.map +1 -0
  311. package/dist/esm/interfaces/queue-scheduler-options.d.ts +23 -0
  312. package/dist/esm/interfaces/queue-scheduler-options.js +2 -0
  313. package/dist/esm/interfaces/queue-scheduler-options.js.map +1 -0
  314. package/dist/esm/interfaces/rate-limiter-options.d.ts +30 -0
  315. package/dist/esm/interfaces/rate-limiter-options.js +2 -0
  316. package/dist/esm/interfaces/rate-limiter-options.js.map +1 -0
  317. package/dist/esm/interfaces/redis-options.d.ts +5 -0
  318. package/dist/esm/interfaces/redis-options.js +2 -0
  319. package/dist/esm/interfaces/redis-options.js.map +1 -0
  320. package/dist/esm/interfaces/redis-streams.d.ts +4 -0
  321. package/dist/esm/interfaces/redis-streams.js +2 -0
  322. package/dist/esm/interfaces/redis-streams.js.map +1 -0
  323. package/dist/esm/interfaces/repeat-options.d.ts +44 -0
  324. package/dist/esm/interfaces/repeat-options.js +2 -0
  325. package/dist/esm/interfaces/repeat-options.js.map +1 -0
  326. package/dist/esm/interfaces/sandboxed-job-processor.d.ts +5 -0
  327. package/dist/esm/interfaces/sandboxed-job-processor.js +2 -0
  328. package/dist/esm/interfaces/sandboxed-job-processor.js.map +1 -0
  329. package/dist/esm/interfaces/sandboxed-job.d.ts +13 -0
  330. package/dist/esm/interfaces/sandboxed-job.js +2 -0
  331. package/dist/esm/interfaces/sandboxed-job.js.map +1 -0
  332. package/dist/esm/interfaces/worker-options.d.ts +32 -0
  333. package/dist/esm/interfaces/worker-options.js +2 -0
  334. package/dist/esm/interfaces/worker-options.js.map +1 -0
  335. package/dist/esm/tsdoc-metadata.json +11 -0
  336. package/dist/esm/utils.d.ts +29 -0
  337. package/dist/esm/utils.js +124 -0
  338. package/dist/esm/utils.js.map +1 -0
  339. package/package.json +13 -10
  340. package/dist/classes/backoffs.js.map +0 -1
  341. package/dist/classes/child-pool.js.map +0 -1
  342. package/dist/classes/child-processor.js.map +0 -1
  343. package/dist/classes/compat.js.map +0 -1
  344. package/dist/classes/flow-producer.js.map +0 -1
  345. package/dist/classes/index.js.map +0 -1
  346. package/dist/classes/job.js.map +0 -1
  347. package/dist/classes/master.js.map +0 -1
  348. package/dist/classes/process-utils.js.map +0 -1
  349. package/dist/classes/queue-base.js.map +0 -1
  350. package/dist/classes/queue-events.js.map +0 -1
  351. package/dist/classes/queue-getters.js.map +0 -1
  352. package/dist/classes/queue-keys.js.map +0 -1
  353. package/dist/classes/queue-scheduler.js.map +0 -1
  354. package/dist/classes/queue.js.map +0 -1
  355. package/dist/classes/redis-connection.js.map +0 -1
  356. package/dist/classes/repeat.js.map +0 -1
  357. package/dist/classes/sandbox.js.map +0 -1
  358. package/dist/classes/scripts.js.map +0 -1
  359. package/dist/classes/timer-manager.js.map +0 -1
  360. package/dist/classes/worker.js.map +0 -1
  361. package/dist/commands/index.js.map +0 -1
  362. package/dist/commands/script-loader.js.map +0 -1
  363. package/dist/enums/error-codes.enum.js.map +0 -1
  364. package/dist/index.js.map +0 -1
  365. package/dist/interfaces/advanced-options.js.map +0 -1
  366. package/dist/interfaces/backoff-options.js.map +0 -1
  367. package/dist/interfaces/child-command.js.map +0 -1
  368. package/dist/interfaces/child-message.js.map +0 -1
  369. package/dist/interfaces/connection.js.map +0 -1
  370. package/dist/interfaces/index.js.map +0 -1
  371. package/dist/interfaces/jobs-options.js.map +0 -1
  372. package/dist/interfaces/parent-command.js.map +0 -1
  373. package/dist/interfaces/parent-message.js.map +0 -1
  374. package/dist/interfaces/queue-options.js.map +0 -1
  375. package/dist/interfaces/queue-scheduler-options.js.map +0 -1
  376. package/dist/interfaces/rate-limiter-options.js.map +0 -1
  377. package/dist/interfaces/redis-options.js.map +0 -1
  378. package/dist/interfaces/redis-streams.js.map +0 -1
  379. package/dist/interfaces/repeat-options.js.map +0 -1
  380. package/dist/interfaces/sandboxed-job-processor.js.map +0 -1
  381. package/dist/interfaces/sandboxed-job.js.map +0 -1
  382. package/dist/interfaces/worker-options.js.map +0 -1
  383. package/dist/utils.js.map +0 -1
@@ -0,0 +1,1839 @@
1
+ /// <reference types="node" />
2
+
3
+ import { ChildProcess } from 'child_process';
4
+ import { Cluster } from 'ioredis';
5
+ import { ClusterOptions } from 'ioredis';
6
+ import { EventEmitter } from 'events';
7
+ import { Pipeline } from 'ioredis';
8
+ import { Redis } from 'ioredis';
9
+ import { RedisOptions as RedisOptions_2 } from 'ioredis';
10
+
11
+ export declare interface AddChildrenOpts {
12
+ multi: Pipeline;
13
+ nodes: FlowJob[];
14
+ parent: {
15
+ parentOpts: {
16
+ id: string;
17
+ queue: string;
18
+ };
19
+ parentDependenciesKey: string;
20
+ };
21
+ queuesOpts?: FlowQueuesOpts;
22
+ }
23
+
24
+ export declare interface AddNodeOpts {
25
+ multi: Pipeline;
26
+ node: FlowJob;
27
+ parent?: {
28
+ parentOpts: {
29
+ id: string;
30
+ queue: string;
31
+ };
32
+ parentDependenciesKey: string;
33
+ };
34
+ /**
35
+ * Queues options that will be applied in each node depending on queue name presence.
36
+ */
37
+ queuesOpts?: FlowQueuesOpts;
38
+ }
39
+
40
+ export declare interface AdvancedOptions {
41
+ /**
42
+ * A set of custom backoff strategies keyed by name.
43
+ */
44
+ backoffStrategies?: {};
45
+ }
46
+
47
+ export declare function array2obj(arr: string[]): Record<string, string>;
48
+
49
+ export declare type BackoffFunction = (attemptsMade?: number, err?: Error, job?: Job) => number;
50
+
51
+ /**
52
+ * Settings for backing off failed jobs.
53
+ *
54
+ * @see {@link https://docs.bullmq.io/guide/retrying-failing-jobs}
55
+ */
56
+ export declare interface BackoffOptions {
57
+ /**
58
+ * Name of the backoff strategy.
59
+ */
60
+ type: string;
61
+ /**
62
+ * Delay in milliseconds.
63
+ */
64
+ delay?: number;
65
+ }
66
+
67
+ export declare class Backoffs {
68
+ static builtinStrategies: BuiltInStrategies;
69
+ static normalize(backoff: number | BackoffOptions): BackoffOptions;
70
+ static calculate(backoff: BackoffOptions, attemptsMade: number, customStrategies: Strategies, err: Error, job: Job): number;
71
+ }
72
+
73
+ declare interface BuiltInStrategies {
74
+ [index: string]: (delay: number) => BackoffFunction;
75
+ }
76
+
77
+ export declare type BulkJobOptions = Omit<JobsOptions, 'repeat'>;
78
+
79
+ export declare enum ChildCommand {
80
+ Init = 0,
81
+ Start = 1,
82
+ Stop = 2
83
+ }
84
+
85
+ export declare interface ChildMessage {
86
+ cmd: ParentCommand;
87
+ value?: any;
88
+ err?: Error;
89
+ }
90
+
91
+ export declare class ChildPool {
92
+ private masterFile;
93
+ retained: {
94
+ [key: number]: ChildProcessExt;
95
+ };
96
+ free: {
97
+ [key: string]: ChildProcessExt[];
98
+ };
99
+ constructor(masterFile?: string);
100
+ retain(processFile: string): Promise<ChildProcessExt>;
101
+ release(child: ChildProcessExt): void;
102
+ remove(child: ChildProcessExt): void;
103
+ kill(child: ChildProcess, signal?: 'SIGTERM' | 'SIGKILL'): Promise<void>;
104
+ clean(): Promise<void>;
105
+ getFree(id: string): ChildProcessExt[];
106
+ getAllFree(): ChildProcessExt[];
107
+ }
108
+
109
+ export declare interface ChildProcessExt extends ChildProcess {
110
+ processFile?: string;
111
+ }
112
+
113
+ export declare const childSend: (proc: NodeJS.Process, msg: ChildMessage) => Promise<void>;
114
+
115
+ export declare const clientCommandMessageReg: RegExp;
116
+
117
+ export declare enum ClientType {
118
+ blocking = "blocking",
119
+ normal = "normal"
120
+ }
121
+
122
+ export declare interface Command {
123
+ name: string;
124
+ options: {
125
+ numberOfKeys: number;
126
+ lua: string;
127
+ };
128
+ }
129
+
130
+ export declare type ConnectionOptions = RedisOptions | Redis | Cluster;
131
+
132
+ export declare function delay(ms: number): Promise<void>;
133
+
134
+ export declare const DELAY_TIME_1 = 100;
135
+
136
+ export declare const DELAY_TIME_5 = 5000;
137
+
138
+ export declare interface DependenciesOpts {
139
+ processed?: {
140
+ cursor?: number;
141
+ count?: number;
142
+ };
143
+ unprocessed?: {
144
+ cursor?: number;
145
+ count?: number;
146
+ };
147
+ }
148
+
149
+ export declare type EntryId = string;
150
+
151
+ export declare type EntryRaw = [EntryId, string[]];
152
+
153
+ export declare enum ErrorCodes {
154
+ JobNotExist = -1,
155
+ JobLockNotExist = -2,
156
+ JobNotInState = -3,
157
+ JobPendingDependencies = -4,
158
+ ParentJobNotExist = -5
159
+ }
160
+
161
+ export declare const errorObject: {
162
+ [index: string]: any;
163
+ };
164
+
165
+ export declare interface FlowJob {
166
+ name: string;
167
+ queueName: string;
168
+ data?: any;
169
+ prefix?: string;
170
+ opts?: Omit<JobsOptions, 'parent' | 'repeat'>;
171
+ children?: FlowJob[];
172
+ }
173
+
174
+ export declare interface FlowOpts {
175
+ queuesOptions: FlowQueuesOpts;
176
+ }
177
+
178
+ /**
179
+ * This class allows to add jobs with dependencies between them in such
180
+ * a way that it is possible to build complex flows.
181
+ * Note: A flow is a tree-like structure of jobs that depend on each other.
182
+ * Whenever the children of a given parent are completed, the parent
183
+ * will be processed, being able to access the children's result data.
184
+ * All Jobs can be in different queues, either children or parents,
185
+ */
186
+ export declare class FlowProducer extends EventEmitter {
187
+ opts: QueueBaseOptions;
188
+ toKey: (name: string, type: string) => string;
189
+ keys: KeysMap;
190
+ closing: Promise<void>;
191
+ queueKeys: QueueKeys;
192
+ protected connection: RedisConnection;
193
+ constructor(opts?: QueueBaseOptions);
194
+ /**
195
+ * Adds a flow.
196
+ *
197
+ * This call would be atomic, either it fails and no jobs will
198
+ * be added to the queues, or it succeeds and all jobs will be added.
199
+ *
200
+ * @param flow - an object with a tree-like structure where children jobs
201
+ * will be processed before their parents.
202
+ * @param opts - options that will be applied to the flow object.
203
+ */
204
+ add(flow: FlowJob, opts?: FlowOpts): Promise<JobNode>;
205
+ /**
206
+ * Get a flow.
207
+ *
208
+ * @param opts - an object with options for getting a JobNode.
209
+ */
210
+ getFlow(opts: NodeOpts): Promise<JobNode>;
211
+ get client(): Promise<RedisClient>;
212
+ /**
213
+ * Adds multiple flows.
214
+ *
215
+ * A flow is a tree-like structure of jobs that depend on each other.
216
+ * Whenever the children of a given parent are completed, the parent
217
+ * will be processed, being able to access the children's result data.
218
+ *
219
+ * All Jobs can be in different queues, either children or parents,
220
+ * however this call would be atomic, either it fails and no jobs will
221
+ * be added to the queues, or it succeeds and all jobs will be added.
222
+ *
223
+ * @param flows - an array of objects with a tree-like structure where children jobs
224
+ * will be processed before their parents.
225
+ */
226
+ addBulk(flows: FlowJob[]): Promise<JobNode[]>;
227
+ /**
228
+ * Add a node (job) of a flow to the queue. This method will recursively
229
+ * add all its children as well. Note that a given job can potentially be
230
+ * a parent and a child job at the same time depending on where it is located
231
+ * in the tree hierarchy.
232
+ *
233
+ * @param multi - ioredis pipeline
234
+ * @param node - the node representing a job to be added to some queue
235
+ * @param parent - parent data sent to children to create the "links" to their parent
236
+ * @returns
237
+ */
238
+ private addNode;
239
+ /**
240
+ * Adds nodes (jobs) of multiple flows to the queue. This method will recursively
241
+ * add all its children as well. Note that a given job can potentially be
242
+ * a parent and a child job at the same time depending on where it is located
243
+ * in the tree hierarchy.
244
+ *
245
+ * @param multi - ioredis pipeline
246
+ * @param nodes - the nodes representing jobs to be added to some queue
247
+ * @returns
248
+ */
249
+ private addNodes;
250
+ private getNode;
251
+ private addChildren;
252
+ private getChildren;
253
+ /**
254
+ * Helper factory method that creates a queue-like object
255
+ * required to create jobs in any queue.
256
+ *
257
+ * @param node -
258
+ * @param queueKeys -
259
+ * @returns
260
+ */
261
+ private queueFromNode;
262
+ close(): Promise<void>;
263
+ disconnect(): Promise<void>;
264
+ }
265
+
266
+ export declare type FlowQueuesOpts = Record<string, Omit<QueueOptions, 'connection' | 'prefix'>>;
267
+
268
+ export declare interface GetNextJobOptions {
269
+ block?: boolean;
270
+ }
271
+
272
+ export declare function getParentKey(opts: {
273
+ id: string;
274
+ queue: string;
275
+ }): string;
276
+
277
+ export declare interface IConnection extends EventEmitter {
278
+ waitUntilReady(): Promise<boolean>;
279
+ client: Promise<RedisClient>;
280
+ }
281
+
282
+ export declare function isEmpty(obj: object): boolean;
283
+
284
+ export declare function isNotConnectionError(error: Error): boolean;
285
+
286
+ export declare function isRedisInstance(obj: any): boolean;
287
+
288
+ export declare class Job<DataType = any, ReturnType = any, NameType extends string = string> {
289
+ protected queue: MinimalQueue;
290
+ /**
291
+ * The name of the Job
292
+ */
293
+ name: NameType;
294
+ /**
295
+ * The payload for this job.
296
+ */
297
+ data: DataType;
298
+ /**
299
+ * The options object for this job.
300
+ */
301
+ opts: JobsOptions;
302
+ id?: string;
303
+ /**
304
+ * The progress a job has performed so far.
305
+ * @defaultValue 0
306
+ */
307
+ progress: number | object;
308
+ /**
309
+ * The value returned by the processor when processing this job.
310
+ * @defaultValue null
311
+ */
312
+ returnvalue: ReturnType;
313
+ /**
314
+ * Stacktrace for the error (for failed jobs).
315
+ * @defaultValue null
316
+ */
317
+ stacktrace: string[];
318
+ /**
319
+ * Timestamp when the job was created (unless overridden with job options).
320
+ */
321
+ timestamp: number;
322
+ /**
323
+ * Number of attempts after the job has failed.
324
+ * @defaultValue 0
325
+ */
326
+ attemptsMade: number;
327
+ /**
328
+ * Reason for failing.
329
+ */
330
+ failedReason: string;
331
+ /**
332
+ * Timestamp for when the job finished (completed or failed).
333
+ */
334
+ finishedOn?: number;
335
+ /**
336
+ * Timestamp for when the job was processed.
337
+ */
338
+ processedOn?: number;
339
+ /**
340
+ * Fully qualified key (including the queue prefix) pointing to the parent of this job.
341
+ */
342
+ parentKey?: string;
343
+ parent?: {
344
+ id: string;
345
+ queueKey: string;
346
+ };
347
+ protected toKey: (type: string) => string;
348
+ private discarded;
349
+ constructor(queue: MinimalQueue,
350
+ /**
351
+ * The name of the Job
352
+ */
353
+ name: NameType,
354
+ /**
355
+ * The payload for this job.
356
+ */
357
+ data: DataType,
358
+ /**
359
+ * The options object for this job.
360
+ */
361
+ opts?: JobsOptions, id?: string);
362
+ /**
363
+ * Creates a new job and adds it to the queue.
364
+ *
365
+ * @param queue - the queue where to add the job.
366
+ * @param name - the name of the job.
367
+ * @param data - the payload of the job.
368
+ * @param opts - the options bag for this job.
369
+ * @returns
370
+ */
371
+ static create<T = any, R = any, N extends string = string>(queue: MinimalQueue, name: N, data: T, opts?: JobsOptions): Promise<Job<T, R, N>>;
372
+ /**
373
+ * Creates a bulk of jobs and adds them atomically to the given queue.
374
+ *
375
+ * @param queue -the queue were to add the jobs.
376
+ * @param jobs - an array of jobs to be added to the queue.
377
+ * @returns
378
+ */
379
+ static createBulk<T = any, R = any, N extends string = string>(queue: MinimalQueue, jobs: {
380
+ name: N;
381
+ data: T;
382
+ opts?: BulkJobOptions;
383
+ }[]): Promise<Job<T, R, N>[]>;
384
+ /**
385
+ * Instantiates a Job from a JobJsonRaw object (coming from a deserialized JSON object)
386
+ *
387
+ * @param queue - the queue where the job belongs to.
388
+ * @param json - the plain object containing the job.
389
+ * @param jobId - an optional job id (overrides the id coming from the JSON object)
390
+ * @returns
391
+ */
392
+ static fromJSON(queue: MinimalQueue, json: JobJsonRaw, jobId?: string): Job<any, any, string>;
393
+ /**
394
+ * Fetches a Job from the queue given the passed job id.
395
+ *
396
+ * @param queue - the queue where the job belongs to.
397
+ * @param jobId - the job id.
398
+ * @returns
399
+ */
400
+ static fromId(queue: MinimalQueue, jobId: string): Promise<Job | undefined>;
401
+ toJSON(): Omit<this, "queue">;
402
+ /**
403
+ * Prepares a job to be serialized for storage in Redis.
404
+ * @returns
405
+ */
406
+ asJSON(): JobJson;
407
+ /**
408
+ * Updates a job's data
409
+ *
410
+ * @param data - the data that will replace the current jobs data.
411
+ */
412
+ update(data: DataType): Promise<void>;
413
+ /**
414
+ * Updates a job's progress
415
+ *
416
+ * @param progress - number or object to be saved as progress.
417
+ */
418
+ updateProgress(progress: number | object): Promise<void>;
419
+ /**
420
+ * Logs one row of log data.
421
+ *
422
+ * @param logRow - string with log data to be logged.
423
+ */
424
+ log(logRow: string): Promise<number>;
425
+ /**
426
+ * Completely remove the job from the queue.
427
+ * Note, this call will throw an exception if the job
428
+ * is being processed when the call is performed.
429
+ */
430
+ remove(): Promise<void>;
431
+ /**
432
+ * Extend the lock for this job.
433
+ *
434
+ * @param token - unique token for the lock
435
+ * @param duration - lock duration in milliseconds
436
+ */
437
+ extendLock(token: string, duration: number): Promise<number>;
438
+ /**
439
+ * Moves a job to the completed queue.
440
+ * Returned job to be used with Queue.prototype.nextJobFromJobData.
441
+ *
442
+ * @param returnValue - The jobs success message.
443
+ * @param token - Worker token used to acquire completed job.
444
+ * @param fetchNext - True when wanting to fetch the next job.
445
+ * @returns Returns the jobData of the next job in the waiting queue.
446
+ */
447
+ moveToCompleted(returnValue: ReturnType, token: string, fetchNext?: boolean): Promise<JobData | []>;
448
+ /**
449
+ * Moves a job to the failed queue.
450
+ *
451
+ * @param err - the jobs error message.
452
+ * @param token - token to check job is locked by current worker
453
+ * @param fetchNext - true when wanting to fetch the next job
454
+ * @returns void
455
+ */
456
+ moveToFailed(err: Error, token: string, fetchNext?: boolean): Promise<void>;
457
+ /**
458
+ * @returns true if the job has completed.
459
+ */
460
+ isCompleted(): Promise<boolean>;
461
+ /**
462
+ * @returns true if the job has failed.
463
+ */
464
+ isFailed(): Promise<boolean>;
465
+ /**
466
+ * @returns true if the job is delayed.
467
+ */
468
+ isDelayed(): Promise<boolean>;
469
+ /**
470
+ * @returns true if the job is waiting for children.
471
+ */
472
+ isWaitingChildren(): Promise<boolean>;
473
+ /**
474
+ * @returns true of the job is active.
475
+ */
476
+ isActive(): Promise<boolean>;
477
+ /**
478
+ * @returns true if the job is waiting.
479
+ */
480
+ isWaiting(): Promise<boolean>;
481
+ get queueName(): string;
482
+ /**
483
+ * Get current state.
484
+ *
485
+ * @returns Returns one of these values:
486
+ * 'completed', 'failed', 'delayed', 'active', 'waiting', 'waiting-children', 'unknown'.
487
+ */
488
+ getState(): Promise<string>;
489
+ /**
490
+ * Change delay of a delayed job.
491
+ *
492
+ * @param delay - milliseconds to be added to current time.
493
+ * @returns void
494
+ */
495
+ changeDelay(delay: number): Promise<void>;
496
+ /**
497
+ * Get this jobs children result values if any.
498
+ *
499
+ * @returns Object mapping children job keys with their values.
500
+ */
501
+ getChildrenValues<CT = any>(): Promise<{
502
+ [jobKey: string]: CT;
503
+ }>;
504
+ /**
505
+ * Get children job keys if this job is a parent and has children.
506
+ *
507
+ * @returns dependencies separated by processed and unprocessed.
508
+ */
509
+ getDependencies(opts?: DependenciesOpts): Promise<{
510
+ nextProcessedCursor?: number;
511
+ processed?: Record<string, any>;
512
+ nextUnprocessedCursor?: number;
513
+ unprocessed?: string[];
514
+ }>;
515
+ /**
516
+ * Get children job counts if this job is a parent and has children.
517
+ *
518
+ * @returns dependencies count separated by processed and unprocessed.
519
+ */
520
+ getDependenciesCount(opts?: {
521
+ processed?: boolean;
522
+ unprocessed?: boolean;
523
+ }): Promise<{
524
+ processed?: number;
525
+ unprocessed?: number;
526
+ }>;
527
+ /**
528
+ * Returns a promise the resolves when the job has finished. (completed or failed).
529
+ */
530
+ waitUntilFinished(queueEvents: QueueEvents, ttl?: number): Promise<ReturnType>;
531
+ /**
532
+ * Moves the job to the delay set.
533
+ *
534
+ * @param timestamp - timestamp where the job should be moved back to "wait"
535
+ * @returns
536
+ */
537
+ moveToDelayed(timestamp: number): Promise<void>;
538
+ /**
539
+ * Moves the job to the waiting-children set.
540
+ *
541
+ * @param token - Token to check job is locked by current worker
542
+ * @param opts - The options bag for moving a job to waiting-children.
543
+ * @returns true if the job was moved
544
+ */
545
+ moveToWaitingChildren(token: string, opts?: MoveToChildrenOpts): Promise<boolean | Error>;
546
+ /**
547
+ * Promotes a delayed job so that it starts to be processed as soon as possible.
548
+ */
549
+ promote(): Promise<void>;
550
+ /**
551
+ * Attempts to retry the job. Only a job that has failed can be retried.
552
+ *
553
+ * @returns If resolved and return code is 1, then the queue emits a waiting event
554
+ * otherwise the operation was not a success and throw the corresponding error. If the promise
555
+ * rejects, it indicates that the script failed to execute
556
+ */
557
+ retry(state?: 'completed' | 'failed'): Promise<void>;
558
+ /**
559
+ * Marks a job to not be retried if it fails (even if attempts has been configured)
560
+ */
561
+ discard(): void;
562
+ private isInZSet;
563
+ private isInList;
564
+ /**
565
+ * Adds the job to Redis.
566
+ *
567
+ * @param client -
568
+ * @param parentOpts -
569
+ * @returns
570
+ */
571
+ addJob(client: RedisClient, parentOpts?: ParentOpts): Promise<string>;
572
+ private saveAttempt;
573
+ }
574
+
575
+ export declare type JobData = [JobJsonRaw | number, string?];
576
+
577
+ export declare function jobIdForGroup(jobOpts: JobsOptions, data: any, queueOpts: QueueOptions): string;
578
+
579
+ export declare interface JobJson {
580
+ id: string;
581
+ name: string;
582
+ data: string;
583
+ opts: JobsOptions;
584
+ progress: number | object;
585
+ attemptsMade: number;
586
+ finishedOn?: number;
587
+ processedOn?: number;
588
+ timestamp: number;
589
+ failedReason: string;
590
+ stacktrace: string;
591
+ returnvalue: string;
592
+ parentKey?: string;
593
+ }
594
+
595
+ export declare interface JobJsonRaw {
596
+ id: string;
597
+ name: string;
598
+ data: string;
599
+ opts: string;
600
+ progress: string;
601
+ attemptsMade: string;
602
+ finishedOn?: string;
603
+ processedOn?: string;
604
+ timestamp: string;
605
+ failedReason: string;
606
+ stacktrace: string[];
607
+ returnvalue: string;
608
+ parentKey?: string;
609
+ parent?: string;
610
+ }
611
+
612
+ export declare interface JobNode {
613
+ job: Job;
614
+ children?: JobNode[];
615
+ }
616
+
617
+ export declare interface JobsOptions {
618
+ /**
619
+ * Timestamp when the job was created. Defaults to `Date.now()`.
620
+ */
621
+ timestamp?: number;
622
+ /**
623
+ * Ranges from 1 (highest priority) to MAX_INT (lowest priority). Note that
624
+ * using priorities has a slight impact on performance,
625
+ * so do not use it if not required.
626
+ */
627
+ priority?: number;
628
+ /**
629
+ * An amount of milliseconds to wait until this job can be processed.
630
+ * Note that for accurate delays, worker and producers
631
+ * should have their clocks synchronized.
632
+ * @defaultValue 0
633
+ */
634
+ delay?: number;
635
+ /**
636
+ * The total number of attempts to try the job until it completes.
637
+ * @defaultValue 0
638
+ */
639
+ attempts?: number;
640
+ /**
641
+ * Repeat this job, for example based on a `cron` schedule.
642
+ */
643
+ repeat?: RepeatOptions;
644
+ /**
645
+ * Rate limiter key to use if rate limiter enabled.
646
+ *
647
+ * @see {@link https://docs.bullmq.io/guide/rate-limiting}
648
+ */
649
+ rateLimiterKey?: string;
650
+ /**
651
+ * Backoff setting for automatic retries if the job fails
652
+ */
653
+ backoff?: number | BackoffOptions;
654
+ /**
655
+ * If true, adds the job to the right of the queue instead of the left (default false)
656
+ *
657
+ * @see {@link https://docs.bullmq.io/guide/jobs/lifo}
658
+ */
659
+ lifo?: boolean;
660
+ /**
661
+ * The number of milliseconds after which the job should be
662
+ * fail with a timeout error.
663
+ */
664
+ timeout?: number;
665
+ /**
666
+ * Override the job ID - by default, the job ID is a unique
667
+ * integer, but you can use this setting to override it.
668
+ * If you use this option, it is up to you to ensure the
669
+ * jobId is unique. If you attempt to add a job with an id that
670
+ * already exists, it will not be added.
671
+ */
672
+ jobId?: string;
673
+ /**
674
+ * If true, removes the job when it successfully completes
675
+ * When given an number, it specifies the maximum amount of
676
+ * jobs to keep.
677
+ * Default behavior is to keep the job in the completed set.
678
+ */
679
+ removeOnComplete?: boolean | number;
680
+ /**
681
+ * If true, removes the job when it fails after all attempts.
682
+ * When given an number, it specifies the maximum amount of
683
+ * jobs to keep.
684
+ */
685
+ removeOnFail?: boolean | number;
686
+ /**
687
+ * Limits the amount of stack trace lines that will be recorded in the stacktrace.
688
+ */
689
+ stackTraceLimit?: number;
690
+ /**
691
+ *
692
+ */
693
+ parent?: {
694
+ id: string;
695
+ queue: string;
696
+ };
697
+ /**
698
+ * Internal property used by repeatable jobs.
699
+ */
700
+ prevMillis?: number;
701
+ /**
702
+ * Limits the size in bytes of the job's data payload (as a JSON serialized string).
703
+ */
704
+ sizeLimit?: number;
705
+ }
706
+
707
+ declare type KeysMap = {
708
+ [index in string]: string;
709
+ };
710
+
711
+ /**
712
+ * Checks the size of string for ascii/non-ascii characters
713
+ * @see https://stackoverflow.com/a/23318053/1347170
714
+ * @param str -
715
+ */
716
+ export declare function lengthInUtf8Bytes(str: string): number;
717
+
718
+ export declare type MinimalQueue = Pick<QueueBase, 'name' | 'client' | 'toKey' | 'keys' | 'opts' | 'closing' | 'waitUntilReady' | 'removeListener' | 'emit' | 'on' | 'redisVersion'>;
719
+
720
+ export declare interface MoveToChildrenOpts {
721
+ timestamp?: number;
722
+ child?: {
723
+ id: string;
724
+ queue: string;
725
+ };
726
+ }
727
+
728
+ export declare interface NodeOpts {
729
+ /**
730
+ * Root job queue name.
731
+ */
732
+ queueName: string;
733
+ /**
734
+ * Prefix included in job key.
735
+ */
736
+ prefix?: string;
737
+ /**
738
+ * Root job id.
739
+ */
740
+ id: string;
741
+ /**
742
+ * Maximum depth or levels to visit in the tree.
743
+ */
744
+ depth?: number;
745
+ /**
746
+ * Maximum quantity of children per type (processed, unprocessed).
747
+ */
748
+ maxChildren?: number;
749
+ }
750
+
751
+ /**
752
+ * Describes the parent for a Job.
753
+ */
754
+ export declare interface Parent<T> {
755
+ name: string;
756
+ prefix?: string;
757
+ queue?: string;
758
+ data?: T;
759
+ opts?: JobsOptions;
760
+ }
761
+
762
+ export declare enum ParentCommand {
763
+ InitFailed = 0,
764
+ InitCompleted = 1,
765
+ Completed = 2,
766
+ Failed = 3,
767
+ Error = 4,
768
+ Progress = 5,
769
+ Log = 6
770
+ }
771
+
772
+ export declare interface ParentMessage {
773
+ cmd: ChildCommand;
774
+ value?: any;
775
+ err?: Error;
776
+ job?: JobJson;
777
+ }
778
+
779
+ export declare type ParentOpts = {
780
+ waitChildrenKey?: string;
781
+ parentDependenciesKey?: string;
782
+ parentKey?: string;
783
+ };
784
+
785
+ export declare const parentSend: (child: ChildProcess, msg: ParentMessage) => Promise<void>;
786
+
787
+ /**
788
+ * An async function that receives `Job`s and handles them.
789
+ */
790
+ export declare type Processor<T = any, R = any, N extends string = string> = (job: Job<T, R, N>, token?: string) => Promise<R>;
791
+
792
+ /**
793
+ * Queue
794
+ *
795
+ * This class provides methods to add jobs to a queue and some othe high-level
796
+ * administration such as pausing or deleting queues.
797
+ *
798
+ */
799
+ export declare class Queue<DataType = any, ResultType = any, NameType extends string = string> extends QueueGetters implements QueueDeclaration<DataType, ResultType, NameType> {
800
+ token: string;
801
+ jobsOpts: JobsOptions;
802
+ limiter: {
803
+ groupKey: string;
804
+ };
805
+ private _repeat;
806
+ constructor(name: string, opts?: QueueOptions, Connection?: typeof RedisConnection);
807
+ /**
808
+ * Returns this instance current default job options.
809
+ */
810
+ get defaultJobOptions(): JobsOptions;
811
+ get repeat(): Promise<Repeat>;
812
+ /**
813
+ * Adds a new job to the queue.
814
+ *
815
+ * @param name - Name of the job to be added to the queue,.
816
+ * @param data - Arbitrary data to append to the job.
817
+ * @param opts - Job options that affects how the job is going to be processed.
818
+ */
819
+ add(name: NameType, data: DataType, opts?: JobsOptions): Promise<Job<DataType, ResultType, NameType>>;
820
+ /**
821
+ * Adds an array of jobs to the queue.
822
+ *
823
+ * @param jobs - The array of jobs to add to the queue. Each job is defined by 3
824
+ * properties, 'name', 'data' and 'opts'. They follow the same signature as 'Queue.add'.
825
+ */
826
+ addBulk(jobs: {
827
+ name: NameType;
828
+ data: DataType;
829
+ opts?: BulkJobOptions;
830
+ }[]): Promise<Job<DataType, any, NameType>[]>;
831
+ /**
832
+ * Pauses the processing of this queue globally.
833
+ *
834
+ * We use an atomic RENAME operation on the wait queue. Since
835
+ * we have blocking calls with BRPOPLPUSH on the wait queue, as long as the queue
836
+ * is renamed to 'paused', no new jobs will be processed (the current ones
837
+ * will run until finalized).
838
+ *
839
+ * Adding jobs requires a LUA script to check first if the paused list exist
840
+ * and in that case it will add it there instead of the wait list.
841
+ */
842
+ pause(): Promise<void>;
843
+ /**
844
+ * Resumes the processing of this queue globally.
845
+ *
846
+ * The method reverses the pause operation by resuming the processing of the
847
+ * queue.
848
+ */
849
+ resume(): Promise<void>;
850
+ /**
851
+ * Returns true if the queue is currently paused.
852
+ */
853
+ isPaused(): Promise<boolean>;
854
+ /**
855
+ * Get all repeatable meta jobs.
856
+ *
857
+ * @param start - Offset of first job to return.
858
+ * @param end - Offset of last job to return.
859
+ * @param asc - Determine the order in which jobs are returned based on their
860
+ * next execution time.
861
+ */
862
+ getRepeatableJobs(start?: number, end?: number, asc?: boolean): Promise<{
863
+ key: string;
864
+ name: string;
865
+ id: string;
866
+ endDate: number;
867
+ tz: string;
868
+ cron: string;
869
+ next: number;
870
+ }[]>;
871
+ removeRepeatable(name: NameType, repeatOpts: RepeatOptions, jobId?: string): Promise<void>;
872
+ removeRepeatableByKey(key: string): Promise<void>;
873
+ /**
874
+ * Removes the given job from the queue as well as all its
875
+ * dependencies.
876
+ *
877
+ * @param jobId - The id of the job to remove
878
+ * @returns 1 if it managed to remove the job or 0 if the job or
879
+ * any of its dependencies was locked.
880
+ */
881
+ remove(jobId: string): Promise<number>;
882
+ /**
883
+ * Drains the queue, i.e., removes all jobs that are waiting
884
+ * or delayed, but not active, completed or failed.
885
+ *
886
+ * @param delayed - Pass true if it should also clean the
887
+ * delayed jobs.
888
+ */
889
+ drain(delayed?: boolean): Promise<void>;
890
+ /**
891
+ * Cleans jobs from a queue. Similar to drain but keeps jobs within a certain
892
+ * grace period.
893
+ *
894
+ * @param grace - The grace period
895
+ * @param The - Max number of jobs to clean
896
+ * @param {string} [type=completed] - The type of job to clean
897
+ * Possible values are completed, wait, active, paused, delayed, failed. Defaults to completed.
898
+ * @returns Id jobs from the deleted records
899
+ */
900
+ clean(grace: number, limit: number, type?: 'completed' | 'wait' | 'active' | 'paused' | 'delayed' | 'failed'): Promise<string[]>;
901
+ /**
902
+ * Completely destroys the queue and all of its contents irreversibly.
903
+ * This method will the *pause* the queue and requires that there are no
904
+ * active jobs. It is possible to bypass this requirement, i.e. not
905
+ * having active jobs using the "force" option.
906
+ *
907
+ * Note: This operation requires to iterate on all the jobs stored in the queue
908
+ * and can be slow for very large queues.
909
+ *
910
+ * @param { { force: boolean, count: number }} opts. Use force = true to force obliteration even
911
+ * with active jobs in the queue. Use count with the maximum number of deleted keys per iteration,
912
+ * 1000 is the default.
913
+ */
914
+ obliterate(opts?: {
915
+ force?: boolean;
916
+ count?: number;
917
+ }): Promise<void>;
918
+ /**
919
+ * Trim the event stream to an approximately maxLength.
920
+ *
921
+ * @param maxLength -
922
+ */
923
+ trimEvents(maxLength: number): Promise<number>;
924
+ }
925
+
926
+ export declare class QueueBase extends EventEmitter {
927
+ readonly name: string;
928
+ opts: QueueBaseOptions;
929
+ toKey: (type: string) => string;
930
+ keys: KeysMap;
931
+ closing: Promise<void>;
932
+ protected connection: RedisConnection;
933
+ constructor(name: string, opts?: QueueBaseOptions, Connection?: typeof RedisConnection);
934
+ get client(): Promise<RedisClient>;
935
+ get redisVersion(): string;
936
+ emit(event: string | symbol, ...args: any[]): boolean;
937
+ waitUntilReady(): Promise<RedisClient>;
938
+ protected base64Name(): string;
939
+ protected clientName(): string;
940
+ close(): Promise<void>;
941
+ disconnect(): Promise<void>;
942
+ }
943
+
944
+ /**
945
+ * Base Queue options
946
+ */
947
+ export declare interface QueueBaseOptions {
948
+ /**
949
+ * Options for connecting to a Redis instance.
950
+ */
951
+ connection?: ConnectionOptions;
952
+ /**
953
+ * Specify if the connection is shared.
954
+ */
955
+ sharedConnection?: boolean;
956
+ /**
957
+ * Prefix for all queue keys.
958
+ */
959
+ prefix?: string;
960
+ }
961
+
962
+ export declare interface QueueDeclaration<DataType, ResultType, NameType extends string> {
963
+ on(event: 'cleaned', listener: (jobs: string[], type: string) => void): this;
964
+ on(event: 'waiting', listener: (job: Job<DataType, ResultType, NameType>) => void): this;
965
+ on(event: string, listener: Function): this;
966
+ }
967
+
968
+ /**
969
+ * The QueueEvents class is used for listening to the global events
970
+ * emitted by a given queue.
971
+ *
972
+ * This class requires a dedicated redis connection.
973
+ *
974
+ */
975
+ export declare class QueueEvents extends QueueBase {
976
+ private running;
977
+ emit<U extends keyof QueueEventsListener>(event: U, ...args: Parameters<QueueEventsListener[U]>): boolean;
978
+ off<U extends keyof QueueEventsListener>(eventName: U, listener: QueueEventsListener[U]): this;
979
+ on<U extends keyof QueueEventsListener>(event: U, listener: QueueEventsListener[U]): this;
980
+ once<U extends keyof QueueEventsListener>(event: U, listener: QueueEventsListener[U]): this;
981
+ constructor(name: string, { connection, autorun, ...opts }?: QueueEventsOptions, Connection?: typeof RedisConnection);
982
+ run(): Promise<void>;
983
+ private consumeEvents;
984
+ close(): Promise<void>;
985
+ }
986
+
987
+ export declare interface QueueEventsListener {
988
+ /**
989
+ * Listen to 'active' event.
990
+ *
991
+ * This event is triggered when a job enters the 'active' state.
992
+ */
993
+ active: (args: {
994
+ jobId: string;
995
+ prev?: string;
996
+ }, id: string) => void;
997
+ /**
998
+ * Listen to 'added' event.
999
+ *
1000
+ * This event is triggered when a job is created.
1001
+ */
1002
+ added: (args: {
1003
+ jobId: string;
1004
+ name: string;
1005
+ data: string;
1006
+ opts: string;
1007
+ }, id: string) => void;
1008
+ /**
1009
+ * Listen to 'cleaned' event.
1010
+ *
1011
+ * This event is triggered when a cleaned method is triggered.
1012
+ */
1013
+ cleaned: (args: {
1014
+ count: string;
1015
+ }, id: string) => void;
1016
+ /**
1017
+ * Listen to 'completed' event.
1018
+ *
1019
+ * This event is triggered when a job has successfully completed.
1020
+ */
1021
+ completed: (args: {
1022
+ jobId: string;
1023
+ returnvalue: string;
1024
+ prev?: string;
1025
+ }, id: string) => void;
1026
+ /**
1027
+ * Listen to 'delayed' event.
1028
+ *
1029
+ * This event is triggered when a job is delayed.
1030
+ */
1031
+ delayed: (args: {
1032
+ jobId: string;
1033
+ delay: number;
1034
+ }, id: string) => void;
1035
+ /**
1036
+ * Listen to 'drained' event.
1037
+ *
1038
+ * This event is triggered when the queue has drained the waiting list.
1039
+ * Note that there could still be delayed jobs waiting their timers to expire
1040
+ * and this event will still be triggered as long as the waiting list has emptied.
1041
+ */
1042
+ drained: (id: string) => void;
1043
+ /**
1044
+ * Listen to 'error' event.
1045
+ *
1046
+ * This event is triggered when an exception is thrown.
1047
+ */
1048
+ error: (args: Error) => void;
1049
+ /**
1050
+ * Listen to 'failed' event.
1051
+ *
1052
+ * This event is triggered when a job has thrown an exception.
1053
+ */
1054
+ failed: (args: {
1055
+ jobId: string;
1056
+ failedReason: string;
1057
+ prev?: string;
1058
+ }, id: string) => void;
1059
+ /**
1060
+ * Listen to 'paused' event.
1061
+ *
1062
+ * This event is triggered when a queue is paused.
1063
+ */
1064
+ paused: (args: {}, id: string) => void;
1065
+ /**
1066
+ * Listen to 'progress' event.
1067
+ *
1068
+ * This event is triggered when a job updates it progress, i.e. the
1069
+ * Job##updateProgress() method is called. This is useful to notify
1070
+ * progress or any other data from within a processor to the rest of the
1071
+ * world.
1072
+ */
1073
+ progress: (args: {
1074
+ jobId: string;
1075
+ data: number | object;
1076
+ }, id: string) => void;
1077
+ /**
1078
+ * Listen to 'removed' event.
1079
+ *
1080
+ * This event is triggered when a job has been manually
1081
+ * removed from the queue.
1082
+ */
1083
+ removed: (args: {
1084
+ jobId: string;
1085
+ }, id: string) => void;
1086
+ /**
1087
+ * Listen to 'resumed' event.
1088
+ *
1089
+ * This event is triggered when a queue is resumed.
1090
+ */
1091
+ resumed: (args: {}, id: string) => void;
1092
+ /**
1093
+ * Listen to 'stalled' event.
1094
+ *
1095
+ * This event is triggered when a job has been moved from 'active' back
1096
+ * to 'waiting'/'failed' due to the processor not being able to renew
1097
+ * the lock on the said job.
1098
+ */
1099
+ stalled: (args: {
1100
+ jobId: string;
1101
+ }, id: string) => void;
1102
+ /**
1103
+ * Listen to 'waiting' event.
1104
+ *
1105
+ * This event is triggered when a job enters the 'waiting' state.
1106
+ */
1107
+ waiting: (args: {
1108
+ jobId: string;
1109
+ }, id: string) => void;
1110
+ /**
1111
+ * Listen to 'waiting-children' event.
1112
+ *
1113
+ * This event is triggered when a job enters the 'waiting-children' state.
1114
+ */
1115
+ 'waiting-children': (args: {
1116
+ jobId: string;
1117
+ }, id: string) => void;
1118
+ }
1119
+
1120
+ /**
1121
+ * Options for QueueEvents
1122
+ */
1123
+ export declare interface QueueEventsOptions extends QueueBaseOptions {
1124
+ /**
1125
+ * Condition to start listening to events at instance creation.
1126
+ */
1127
+ autorun?: boolean;
1128
+ /**
1129
+ * Last event Id. If provided it is possible to continue
1130
+ * consuming events from a known Id instead of from the last
1131
+ * produced event.
1132
+ */
1133
+ lastEventId?: string;
1134
+ /**
1135
+ * Timeout for the blocking XREAD call to the events stream.
1136
+ */
1137
+ blockingTimeout?: number;
1138
+ }
1139
+
1140
+ export declare class QueueGetters extends QueueBase {
1141
+ getJob(jobId: string): Promise<Job | undefined>;
1142
+ private commandByType;
1143
+ /**
1144
+ Returns the number of jobs waiting to be processed.
1145
+ */
1146
+ count(): Promise<number>;
1147
+ /**
1148
+ * Job counts by type
1149
+ *
1150
+ * Queue#getJobCountByTypes('completed') => completed count
1151
+ * Queue#getJobCountByTypes('completed,failed') => completed + failed count
1152
+ * Queue#getJobCountByTypes('completed', 'failed') => completed + failed count
1153
+ * Queue#getJobCountByTypes('completed', 'waiting', 'failed') => completed + waiting + failed count
1154
+ */
1155
+ getJobCountByTypes(...types: string[]): Promise<number>;
1156
+ /**
1157
+ * Returns the job counts for each type specified or every list/set in the queue by default.
1158
+ *
1159
+ * @returns An object, key (type) and value (count)
1160
+ */
1161
+ getJobCounts(...types: string[]): Promise<{
1162
+ [index: string]: number;
1163
+ }>;
1164
+ getCompletedCount(): Promise<number>;
1165
+ getFailedCount(): Promise<number>;
1166
+ getDelayedCount(): Promise<number>;
1167
+ getActiveCount(): Promise<number>;
1168
+ getWaitingCount(): Promise<number>;
1169
+ getWaitingChildrenCount(): Promise<number>;
1170
+ getWaiting(start?: number, end?: number): Promise<Job<any, any, string>[]>;
1171
+ getWaitingChildren(start?: number, end?: number): Promise<Job<any, any, string>[]>;
1172
+ getActive(start?: number, end?: number): Promise<Job<any, any, string>[]>;
1173
+ getDelayed(start?: number, end?: number): Promise<Job<any, any, string>[]>;
1174
+ getCompleted(start?: number, end?: number): Promise<Job<any, any, string>[]>;
1175
+ getFailed(start?: number, end?: number): Promise<Job<any, any, string>[]>;
1176
+ getRanges(types: string[], start?: number, end?: number, asc?: boolean): Promise<any[]>;
1177
+ getJobs(types: string[] | string, start?: number, end?: number, asc?: boolean): Promise<Job<any, any, string>[]>;
1178
+ getJobLogs(jobId: string, start?: number, end?: number, asc?: boolean): Promise<{
1179
+ logs: [string];
1180
+ count: number;
1181
+ }>;
1182
+ /**
1183
+ * Get worker list related to the queue.
1184
+ *
1185
+ * @returns - Returns an array with workers info.
1186
+ */
1187
+ getWorkers(): Promise<{
1188
+ [index: string]: string;
1189
+ }[]>;
1190
+ private parseClientList;
1191
+ }
1192
+
1193
+ declare class QueueKeys {
1194
+ readonly prefix: string;
1195
+ constructor(prefix?: string);
1196
+ getKeys(name: string): KeysMap;
1197
+ toKey(name: string, type: string): string;
1198
+ getPrefixedQueueName(name: string): string;
1199
+ }
1200
+
1201
+ /**
1202
+ * Options for the Queue class.
1203
+ */
1204
+ export declare interface QueueOptions extends QueueBaseOptions {
1205
+ defaultJobOptions?: JobsOptions;
1206
+ /**
1207
+ * Options for the rate limiter.
1208
+ */
1209
+ limiter?: {
1210
+ /**
1211
+ * Group key to be used by the limiter when
1212
+ * limiting by group keys.
1213
+ */
1214
+ groupKey: string;
1215
+ };
1216
+ /**
1217
+ * Options for the streams used internally in BullMQ.
1218
+ */
1219
+ streams?: {
1220
+ /**
1221
+ * Options for the events stream.
1222
+ */
1223
+ events: {
1224
+ /**
1225
+ * Max approximated length for streams. Default is 10 000 events.
1226
+ */
1227
+ maxLen: number;
1228
+ };
1229
+ };
1230
+ }
1231
+
1232
+ /**
1233
+ * This class is just used for some automatic bookkeeping of the queue,
1234
+ * such as updating the delay set as well as moving stalled jobs back
1235
+ * to the waiting list.
1236
+ *
1237
+ * Jobs are checked for stallness once every "visibility window" seconds.
1238
+ * Jobs are then marked as candidates for being stalled, in the next check,
1239
+ * the candidates are marked as stalled and moved to wait.
1240
+ * Workers need to clean the candidate list with the jobs that they are working
1241
+ * on, failing to update the list results in the job ending being stalled.
1242
+ *
1243
+ * This class requires a dedicated redis connection, and at least one is needed
1244
+ * to be running at a given time, otherwise delays, stalled jobs, retries, repeatable
1245
+ * jobs, etc, will not work correctly or at all.
1246
+ *
1247
+ */
1248
+ export declare class QueueScheduler extends QueueBase implements QueueSchedulerDeclaration {
1249
+ private nextTimestamp;
1250
+ private isBlocked;
1251
+ private running;
1252
+ constructor(name: string, { connection, autorun, ...opts }?: QueueSchedulerOptions);
1253
+ run(): Promise<void>;
1254
+ isRunning(): boolean;
1255
+ private readDelayedData;
1256
+ private updateDelaySet;
1257
+ private moveStalledJobsToWait;
1258
+ close(): Promise<void>;
1259
+ }
1260
+
1261
+ export declare interface QueueSchedulerDeclaration {
1262
+ on(event: 'stalled', listener: (jobId: string, prev: string) => void): this;
1263
+ on(event: 'failed', listener: (jobId: string, failedReason: Error, prev: string) => void): this;
1264
+ on(event: string, listener: Function): this;
1265
+ }
1266
+
1267
+ /**
1268
+ * Options for customizing the behaviour of the scheduler.
1269
+ *
1270
+ * @see {@link https://docs.bullmq.io/guide/jobs/stalled}
1271
+ * @see {@link https://docs.bullmq.io/guide/queuescheduler}
1272
+ */
1273
+ export declare interface QueueSchedulerOptions extends QueueBaseOptions {
1274
+ /**
1275
+ * Condition to start scheduler at instance creation.
1276
+ */
1277
+ autorun?: boolean;
1278
+ /**
1279
+ * Amount of times a job can be recovered from a stalled state
1280
+ * to the `wait` state. If this is exceeded, the job is moved
1281
+ * to `failed`.
1282
+ */
1283
+ maxStalledCount?: number;
1284
+ /**
1285
+ * Number of milliseconds between stallness checks.
1286
+ */
1287
+ stalledInterval?: number;
1288
+ }
1289
+
1290
+ export declare interface RateLimiterOptions {
1291
+ /**
1292
+ * Max number of jobs to process in the time period
1293
+ * specified in `duration`.
1294
+ */
1295
+ max: number;
1296
+ /**
1297
+ * Time in milliseconds. During this time, a maximum
1298
+ * of `max` jobs will be processed.
1299
+ */
1300
+ duration: number;
1301
+ /**
1302
+ * It is possible to define a rate limiter based on group keys,
1303
+ * for example you may want to have a rate limiter per customer
1304
+ * instead of a global rate limiter for all customers
1305
+ *
1306
+ * @see {@link https://docs.bullmq.io/guide/rate-limiting}
1307
+ */
1308
+ groupKey?: string;
1309
+ /**
1310
+ * This option enables a heuristic so that when a queue is heavily
1311
+ * rete limited, it delays the workers so that they do not try
1312
+ * to pick jobs when there is no point in doing so.
1313
+ * Note: It is not recommended to use this option when using
1314
+ * groupKeys unless you have a big amount of workers since
1315
+ * you may be delaying workers that could pick jobs in groups that
1316
+ * have not been rate limited.
1317
+ */
1318
+ workerDelay?: boolean;
1319
+ }
1320
+
1321
+ export declare function raw2jobData(raw: any[]): [JobJsonRaw | number, string?] | [];
1322
+
1323
+ export declare type RedisClient = Redis | Cluster;
1324
+
1325
+ export declare class RedisConnection extends EventEmitter {
1326
+ private readonly opts?;
1327
+ private readonly shared;
1328
+ static minimumVersion: string;
1329
+ protected _client: RedisClient;
1330
+ private initializing;
1331
+ private closing;
1332
+ private version;
1333
+ private handleClientError;
1334
+ constructor(opts?: ConnectionOptions, shared?: boolean);
1335
+ private checkOptions;
1336
+ /**
1337
+ * Waits for a redis client to be ready.
1338
+ * @param redis - client
1339
+ */
1340
+ static waitUntilReady(client: RedisClient): Promise<void>;
1341
+ get client(): Promise<RedisClient>;
1342
+ protected loadCommands(): Promise<void>;
1343
+ private init;
1344
+ disconnect(): Promise<void>;
1345
+ reconnect(): Promise<void>;
1346
+ close(): Promise<void>;
1347
+ private getRedisVersion;
1348
+ get redisVersion(): string;
1349
+ }
1350
+
1351
+ export declare type RedisOptions = (RedisOptions_2 | ClusterOptions) & {
1352
+ skipVersionCheck?: boolean;
1353
+ };
1354
+
1355
+ export declare function removeAllQueueData(client: RedisClient, queueName: string, prefix?: string): Promise<void | boolean>;
1356
+
1357
+ export declare class Repeat extends QueueBase {
1358
+ addNextRepeatableJob<T = any, R = any, N extends string = string>(name: N, data: T, opts: JobsOptions, skipCheckExists?: boolean): Promise<Job<T, R, N>>;
1359
+ private createNextJob;
1360
+ removeRepeatable(name: string, repeat: RepeatOptions, jobId?: string): Promise<void>;
1361
+ removeRepeatableByKey(repeatJobKey: string): Promise<void>;
1362
+ private keyToData;
1363
+ getRepeatableJobs(start?: number, end?: number, asc?: boolean): Promise<{
1364
+ key: string;
1365
+ name: string;
1366
+ id: string;
1367
+ endDate: number;
1368
+ tz: string;
1369
+ cron: string;
1370
+ next: number;
1371
+ }[]>;
1372
+ getRepeatableCount(): Promise<number>;
1373
+ }
1374
+
1375
+ /**
1376
+ * Settings for repeatable jobs
1377
+ *
1378
+ * @see {@link https://docs.bullmq.io/guide/jobs/repeatable}
1379
+ */
1380
+ export declare interface RepeatOptions {
1381
+ /**
1382
+ * A cron pattern
1383
+ */
1384
+ cron?: string;
1385
+ /**
1386
+ * Timezone
1387
+ */
1388
+ tz?: string;
1389
+ /**
1390
+ * Start date when the repeat job should start repeating (only with `cron`).
1391
+ */
1392
+ startDate?: Date | string | number;
1393
+ /**
1394
+ * End date when the repeat job should stop repeating.
1395
+ */
1396
+ endDate?: Date | string | number;
1397
+ /**
1398
+ * Number of times the job should repeat at max.
1399
+ */
1400
+ limit?: number;
1401
+ /**
1402
+ * Repeat after this amount of milliseconds
1403
+ * (`cron` setting cannot be used together with this setting.)
1404
+ */
1405
+ every?: number;
1406
+ /**
1407
+ * Repeated job should start right now
1408
+ * ( work only with every settings)
1409
+ */
1410
+ immediately?: boolean;
1411
+ /**
1412
+ * The start value for the repeat iteration count.
1413
+ */
1414
+ count?: number;
1415
+ prevMillis?: number;
1416
+ offset?: number;
1417
+ jobId?: string;
1418
+ }
1419
+
1420
+ /**
1421
+ * @see {@link https://docs.bullmq.io/guide/workers/sandboxed-processors}
1422
+ */
1423
+ export declare interface SandboxedJob<T = any, R = any> extends Omit<JobJson, 'data' | 'opts' | 'progress' | 'returnValue'> {
1424
+ data: T;
1425
+ opts: JobsOptions;
1426
+ progress: (() => object | number) | ((value: object | number) => Promise<void>);
1427
+ updateProgress: (value: object | number) => Promise<void>;
1428
+ log: (row: any) => void;
1429
+ returnValue: R;
1430
+ }
1431
+
1432
+ /**
1433
+ * @see {@link https://docs.bullmq.io/guide/workers/sandboxed-processors}
1434
+ */
1435
+ export declare type SandboxedJobProcessor<T = any, R = any> = ((job: SandboxedJob<T, R>) => R | PromiseLike<R>) | ((job: SandboxedJob<T, R>, callback: (error: unknown, result: R) => void) => void);
1436
+
1437
+ /**
1438
+ * Lua script loader with include support
1439
+ */
1440
+ export declare class ScriptLoader {
1441
+ /**
1442
+ * Map an alias to a path
1443
+ */
1444
+ private pathMapper;
1445
+ private clientScripts;
1446
+ /**
1447
+ * Cache commands by dir
1448
+ */
1449
+ private commandCache;
1450
+ private rootPath;
1451
+ constructor();
1452
+ /**
1453
+ * Add a script path mapping. Allows includes of the form "<includes>/utils.lua" where `includes` is a user
1454
+ * defined path
1455
+ * @param name - the name of the mapping. Note: do not include angle brackets
1456
+ * @param mappedPath - if a relative path is passed, it's relative to the *caller* of this function.
1457
+ * Mapped paths are also accepted, e.g. "~/server/scripts/lua" or "<base>/includes"
1458
+ */
1459
+ addPathMapping(name: string, mappedPath: string): void;
1460
+ /**
1461
+ * Resolve the script path considering path mappings
1462
+ * @param scriptName - the name of the script
1463
+ * @param stack - the include stack, for nicer errors
1464
+ */
1465
+ resolvePath(scriptName: string, stack?: string[]): string;
1466
+ /**
1467
+ * Recursively collect all scripts included in a file
1468
+ * @param file - the parent file
1469
+ * @param cache - a cache for file metadata to increase efficiency. Since a file can be included
1470
+ * multiple times, we make sure to load it only once.
1471
+ * @param stack - internal stack to prevent circular references
1472
+ */
1473
+ private resolveDependencies;
1474
+ /**
1475
+ * Parse a (top-level) lua script
1476
+ * @param filename - the full path to the script
1477
+ * @param content - the content of the script
1478
+ * @param cache - cache
1479
+ */
1480
+ parseScript(filename: string, content: string, cache?: Map<string, ScriptMetadata>): Promise<ScriptMetadata>;
1481
+ /**
1482
+ * Construct the final version of a file by interpolating its includes in dependency order.
1483
+ * @param file - the file whose content we want to construct
1484
+ * @param processed - a cache to keep track of which includes have already been processed
1485
+ */
1486
+ interpolate(file: ScriptMetadata, processed?: Set<string>): string;
1487
+ loadCommand(filename: string, cache?: Map<string, ScriptMetadata>): Promise<Command>;
1488
+ /**
1489
+ * Load redis lua scripts.
1490
+ * The name of the script must have the following format:
1491
+ *
1492
+ * cmdName-numKeys.lua
1493
+ *
1494
+ * cmdName must be in camel case format.
1495
+ *
1496
+ * For example:
1497
+ * moveToFinish-3.lua
1498
+ *
1499
+ */
1500
+ loadScripts(dir?: string, cache?: Map<string, ScriptMetadata>): Promise<Command[]>;
1501
+ /**
1502
+ * Attach all lua scripts in a given directory to a client instance
1503
+ * @param client - redis client to attach script to
1504
+ * @param pathname - the path to the directory containing the scripts
1505
+ */
1506
+ load(client: RedisClient, pathname: string): Promise<void>;
1507
+ /**
1508
+ * Clears the command cache
1509
+ */
1510
+ clearCache(): void;
1511
+ }
1512
+
1513
+ export declare const scriptLoader: ScriptLoader;
1514
+
1515
+ export declare class ScriptLoaderError extends Error {
1516
+ readonly path: string;
1517
+ /**
1518
+ * The include stack
1519
+ */
1520
+ readonly includes: string[];
1521
+ readonly line: number;
1522
+ readonly position: number;
1523
+ constructor(message: string, path: string, stack?: string[], line?: number, position?: number);
1524
+ }
1525
+
1526
+ /**
1527
+ * Script metadata
1528
+ */
1529
+ export declare interface ScriptMetadata {
1530
+ /**
1531
+ * Name of the script
1532
+ */
1533
+ name: string;
1534
+ numberOfKeys?: number;
1535
+ /**
1536
+ * The path to the script. For includes, this is the normalized path,
1537
+ * whereas it may not be normalized for the top-level parent
1538
+ */
1539
+ path: string;
1540
+ /**
1541
+ * The raw script content
1542
+ */
1543
+ content: string;
1544
+ /**
1545
+ * A hash of the normalized path for easy replacement in the parent
1546
+ */
1547
+ token: string;
1548
+ /**
1549
+ * Metadata on the scripts that this script includes
1550
+ */
1551
+ includes: ScriptMetadata[];
1552
+ }
1553
+
1554
+ export declare class Scripts {
1555
+ static isJobInList(queue: MinimalQueue, listKey: string, jobId: string): Promise<boolean>;
1556
+ static addJob(client: RedisClient, queue: MinimalQueue, job: JobJson, opts: JobsOptions, jobId: string, parentOpts?: ParentOpts): Promise<string>;
1557
+ static pause(queue: MinimalQueue, pause: boolean): Promise<void>;
1558
+ static removeRepeatableArgs(queue: MinimalQueue, repeatJobId: string, repeatJobKey: string): string[];
1559
+ static removeRepeatable(queue: MinimalQueue, repeatJobId: string, repeatJobKey: string): Promise<void>;
1560
+ static remove(queue: MinimalQueue, jobId: string): Promise<number>;
1561
+ static extendLock(queue: MinimalQueue, jobId: string, token: string, duration: number): Promise<number>;
1562
+ static updateProgress(queue: MinimalQueue, job: Job, progress: number | object): Promise<void>;
1563
+ static moveToFinishedArgs(queue: MinimalQueue, job: Job, val: any, propVal: string, shouldRemove: boolean | number, target: string, token: string, fetchNext?: boolean): string[];
1564
+ private static moveToFinished;
1565
+ static finishedErrors(code: number, jobId: string, command: string, state?: string): Error;
1566
+ static drainArgs(queue: MinimalQueue, delayed: boolean): string[];
1567
+ static drain(queue: MinimalQueue, delayed: boolean): Promise<void>;
1568
+ static moveToCompleted(queue: MinimalQueue, job: Job, returnvalue: any, removeOnComplete: boolean | number, token: string, fetchNext: boolean): Promise<JobData | []>;
1569
+ static moveToFailedArgs(queue: MinimalQueue, job: Job, failedReason: string, removeOnFailed: boolean | number, token: string, fetchNext?: boolean): string[];
1570
+ static isFinished(queue: MinimalQueue, jobId: string, returnValue?: boolean): Promise<number | [number, string]>;
1571
+ static getState(queue: MinimalQueue, jobId: string): Promise<string>;
1572
+ static changeDelay(queue: MinimalQueue, jobId: string, delay: number): Promise<void>;
1573
+ static changeDelayArgs(queue: MinimalQueue, jobId: string, timestamp: number): string[];
1574
+ static moveToDelayedArgs(queue: MinimalQueue, jobId: string, timestamp: number): string[];
1575
+ static moveToWaitingChildrenArgs(queue: MinimalQueue, jobId: string, token: string, opts?: MoveToChildrenOpts): string[];
1576
+ static moveToDelayed(queue: MinimalQueue, jobId: string, timestamp: number): Promise<void>;
1577
+ /**
1578
+ * Move parent job to waiting-children state.
1579
+ *
1580
+ * @returns true if job is successfully moved, false if there are pending dependencies.
1581
+ * @throws JobNotExist
1582
+ * This exception is thrown if jobId is missing.
1583
+ * @throws JobLockNotExist
1584
+ * This exception is thrown if job lock is missing.
1585
+ * @throws JobNotInState
1586
+ * This exception is thrown if job is not in active state.
1587
+ */
1588
+ static moveToWaitingChildren(queue: MinimalQueue, jobId: string, token: string, opts?: MoveToChildrenOpts): Promise<boolean>;
1589
+ /**
1590
+ * Remove jobs in a specific state.
1591
+ *
1592
+ * @returns Id jobs from the deleted records.
1593
+ */
1594
+ static cleanJobsInSet(queue: MinimalQueue, set: string, timestamp: number, limit?: number): Promise<string[]>;
1595
+ static retryJobArgs(queue: MinimalQueue, job: Job): string[];
1596
+ /**
1597
+ * Attempts to reprocess a job
1598
+ *
1599
+ * @param job -
1600
+ * @param {Object} options
1601
+ * @param {String} options.state The expected job state. If the job is not found
1602
+ * on the provided state, then it's not reprocessed. Supported states: 'failed', 'completed'
1603
+ *
1604
+ * @returns Returns a promise that evaluates to a return code:
1605
+ * 1 means the operation was a success
1606
+ * 0 means the job does not exist
1607
+ * -1 means the job is currently locked and can't be retried.
1608
+ * -2 means the job was not found in the expected set
1609
+ */
1610
+ static reprocessJob(queue: MinimalQueue, job: Job, state: 'failed' | 'completed'): Promise<void>;
1611
+ static moveToActive<T, R, N extends string>(worker: Worker_2<T, R, N>, token: string, jobId?: string): Promise<[] | [number | JobJsonRaw, string?]>;
1612
+ static updateDelaySet(queue: MinimalQueue, delayedTimestamp: number): Promise<any>;
1613
+ static promote(queue: MinimalQueue, jobId: string): Promise<any>;
1614
+ static moveStalledJobsToWait(queue: QueueScheduler): Promise<any>;
1615
+ static obliterate(queue: MinimalQueue, opts: {
1616
+ force: boolean;
1617
+ count: number;
1618
+ }): Promise<number>;
1619
+ }
1620
+
1621
+ export declare interface Strategies {
1622
+ [index: string]: BackoffFunction;
1623
+ }
1624
+
1625
+ export declare type StreamName = string;
1626
+
1627
+ export declare type StreamReadRaw = [StreamName, EntryRaw[]][];
1628
+
1629
+ /**
1630
+ * Keeps track on timers created with setTimeout to help clearTimeout
1631
+ * for all timers when no more delayed actions needed
1632
+ */
1633
+ declare class TimerManager {
1634
+ private readonly timers;
1635
+ /**
1636
+ * Creates a new timer and returns its ID.
1637
+ *
1638
+ * @param name Readable name for the timer
1639
+ * @param delay Delay in milliseconds
1640
+ * @param fn callback function that is executed after the timer expires
1641
+ */
1642
+ setTimer(name: string, delay: number, fn: Function): string;
1643
+ clearTimer(id: string): void;
1644
+ clearAllTimers(): void;
1645
+ }
1646
+
1647
+ export declare function tryCatch(fn: (...args: any) => any, ctx: any, args: any[]): any;
1648
+
1649
+ /**
1650
+ *
1651
+ * This class represents a worker that is able to process jobs from the queue.
1652
+ * As soon as the class is instantiated it will start processing jobs.
1653
+ *
1654
+ */
1655
+ declare class Worker_2<DataType = any, ResultType = any, NameType extends string = string> extends QueueBase {
1656
+ opts: WorkerOptions_2;
1657
+ private drained;
1658
+ private waiting;
1659
+ private running;
1660
+ private blockTimeout;
1661
+ protected processFn: Processor<DataType, ResultType, NameType>;
1662
+ private resumeWorker;
1663
+ protected paused: Promise<void>;
1664
+ private _repeat;
1665
+ private childPool;
1666
+ protected timerManager: TimerManager;
1667
+ private blockingConnection;
1668
+ private processing;
1669
+ constructor(name: string, processor?: string | Processor<DataType, ResultType, NameType>, opts?: WorkerOptions_2, Connection?: typeof RedisConnection);
1670
+ emit<U extends keyof WorkerListener>(event: U, ...args: Parameters<WorkerListener[U]>): boolean;
1671
+ off<U extends keyof WorkerListener>(eventName: U, listener: WorkerListener[U]): this;
1672
+ on<U extends keyof WorkerListener>(event: U, listener: WorkerListener[U]): this;
1673
+ once<U extends keyof WorkerListener>(event: U, listener: WorkerListener[U]): this;
1674
+ protected callProcessJob(job: Job<DataType, ResultType, NameType>, token: string): Promise<ResultType>;
1675
+ protected createJob(data: JobJsonRaw, jobId: string): Job<any, any, string>;
1676
+ /**
1677
+ *
1678
+ * Waits until the worker is ready to start processing jobs.
1679
+ * In general only useful when writing tests.
1680
+ *
1681
+ */
1682
+ waitUntilReady(): Promise<RedisClient>;
1683
+ get repeat(): Promise<Repeat>;
1684
+ run(): Promise<any[]>;
1685
+ /**
1686
+ * Returns a promise that resolves to the next job in queue.
1687
+ * @param token - worker token to be assigned to retrieved job
1688
+ * @returns a Job or undefined if no job was available in the queue.
1689
+ */
1690
+ getNextJob(token: string, { block }?: GetNextJobOptions): Promise<Job<any, any, string>>;
1691
+ protected moveToActive(token: string, jobId?: string): Promise<Job<any, any, string>>;
1692
+ private waitForJob;
1693
+ /**
1694
+ *
1695
+ * This function is exposed only for testing purposes.
1696
+ */
1697
+ delay(): Promise<void>;
1698
+ protected nextJobFromJobData(jobData?: JobJsonRaw | number, jobId?: string): Promise<Job<any, any, string>>;
1699
+ processJob(job: Job<DataType, ResultType, NameType>, token: string): Promise<void | Job<any, any, string>>;
1700
+ /**
1701
+ *
1702
+ * Pauses the processing of this queue only for this worker.
1703
+ */
1704
+ pause(doNotWaitActive?: boolean): Promise<void>;
1705
+ /**
1706
+ *
1707
+ * Resumes processing of this worker (if paused).
1708
+ */
1709
+ resume(): void;
1710
+ /**
1711
+ *
1712
+ * Checks if worker is paused.
1713
+ *
1714
+ * @returns true if worker is paused, false otherwise.
1715
+ */
1716
+ isPaused(): boolean;
1717
+ /**
1718
+ *
1719
+ * Checks if worker is currently running.
1720
+ *
1721
+ * @returns true if worker is running, false otherwise.
1722
+ */
1723
+ isRunning(): boolean;
1724
+ /**
1725
+ *
1726
+ * Closes the worker and related redis connections.
1727
+ *
1728
+ * This method waits for current jobs to finalize before returning.
1729
+ *
1730
+ * @param force - Use force boolean parameter if you do not want to wait for
1731
+ * current jobs to be processed.
1732
+ *
1733
+ * @returns Promise that resolves when the worker has been closed.
1734
+ */
1735
+ close(force?: boolean): Promise<void>;
1736
+ /**
1737
+ * Returns a promise that resolves when active jobs are cleared
1738
+ *
1739
+ * @returns
1740
+ */
1741
+ private whenCurrentJobsFinished;
1742
+ private retryIfFailed;
1743
+ }
1744
+ export { Worker_2 as Worker }
1745
+
1746
+ export declare interface WorkerListener {
1747
+ /**
1748
+ * Listen to 'active' event.
1749
+ *
1750
+ * This event is triggered when a job enters the 'active' state.
1751
+ */
1752
+ active: (job: Job, prev: string) => void;
1753
+ /**
1754
+ * Listen to 'closing' event.
1755
+ *
1756
+ * This event is triggered when the worker is closed.
1757
+ */
1758
+ closed: () => void;
1759
+ /**
1760
+ * Listen to 'closing' event.
1761
+ *
1762
+ * This event is triggered when the worker is closing.
1763
+ */
1764
+ closing: (msg: string) => void;
1765
+ /**
1766
+ * Listen to 'completed' event.
1767
+ *
1768
+ * This event is triggered when a job has successfully completed.
1769
+ */
1770
+ completed: (job: Job, result: any, prev: string) => void;
1771
+ /**
1772
+ * Listen to 'drained' event.
1773
+ *
1774
+ * This event is triggered when the queue has drained the waiting list.
1775
+ * Note that there could still be delayed jobs waiting their timers to expire
1776
+ * and this event will still be triggered as long as the waiting list has emptied.
1777
+ */
1778
+ drained: () => void;
1779
+ /**
1780
+ * Listen to 'error' event.
1781
+ *
1782
+ * This event is triggered when an error is throw.
1783
+ */
1784
+ error: (failedReason: Error) => void;
1785
+ /**
1786
+ * Listen to 'failed' event.
1787
+ *
1788
+ * This event is triggered when a job has thrown an exception.
1789
+ */
1790
+ failed: (job: Job, error: Error, prev: string) => void;
1791
+ /**
1792
+ * Listen to 'paused' event.
1793
+ *
1794
+ * This event is triggered when the queue is paused.
1795
+ */
1796
+ paused: () => void;
1797
+ /**
1798
+ * Listen to 'progress' event.
1799
+ *
1800
+ * This event is triggered when a job updates it progress, i.e. the
1801
+ * Job##updateProgress() method is called. This is useful to notify
1802
+ * progress or any other data from within a processor to the rest of the
1803
+ * world.
1804
+ */
1805
+ progress: (job: Job, progress: number | object) => void;
1806
+ /**
1807
+ * Listen to 'resumed' event.
1808
+ *
1809
+ * This event is triggered when the queue is resumed.
1810
+ */
1811
+ resumed: () => void;
1812
+ }
1813
+
1814
+ declare interface WorkerOptions_2 extends QueueBaseOptions {
1815
+ /**
1816
+ * Condition to start processor at instance creation.
1817
+ */
1818
+ autorun?: boolean;
1819
+ /**
1820
+ * Amount of jobs that a single worker is allowed to work on
1821
+ * in parallel.
1822
+ *
1823
+ * @see {@link https://docs.bullmq.io/guide/workers/concurrency}
1824
+ */
1825
+ concurrency?: number;
1826
+ /**
1827
+ * @see {@link https://docs.bullmq.io/guide/rate-limiting}
1828
+ */
1829
+ limiter?: RateLimiterOptions;
1830
+ skipDelayCheck?: boolean;
1831
+ drainDelay?: number;
1832
+ lockDuration?: number;
1833
+ lockRenewTime?: number;
1834
+ runRetryDelay?: number;
1835
+ settings?: AdvancedOptions;
1836
+ }
1837
+ export { WorkerOptions_2 as WorkerOptions }
1838
+
1839
+ export { }