agenda 5.0.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (358) hide show
  1. package/LICENSE.md +4 -0
  2. package/README.md +222 -1063
  3. package/dist/Job.d.ts +190 -0
  4. package/dist/Job.js +568 -0
  5. package/dist/Job.js.map +1 -0
  6. package/dist/JobProcessingQueue.d.ts +47 -0
  7. package/dist/JobProcessingQueue.js +101 -0
  8. package/dist/JobProcessingQueue.js.map +1 -0
  9. package/dist/JobProcessor.d.ts +70 -0
  10. package/dist/JobProcessor.js +458 -0
  11. package/dist/JobProcessor.js.map +1 -0
  12. package/dist/backends/index.d.ts +18 -0
  13. package/dist/backends/index.js +20 -0
  14. package/dist/backends/index.js.map +1 -0
  15. package/dist/decorators/Define.d.ts +33 -0
  16. package/dist/decorators/Define.js +44 -0
  17. package/dist/decorators/Define.js.map +1 -0
  18. package/dist/decorators/Every.d.ts +43 -0
  19. package/dist/decorators/Every.js +55 -0
  20. package/dist/decorators/Every.js.map +1 -0
  21. package/dist/decorators/JobsController.d.ts +43 -0
  22. package/dist/decorators/JobsController.js +37 -0
  23. package/dist/decorators/JobsController.js.map +1 -0
  24. package/dist/decorators/index.d.ts +41 -0
  25. package/dist/decorators/index.js +46 -0
  26. package/dist/decorators/index.js.map +1 -0
  27. package/dist/decorators/metadata.d.ts +50 -0
  28. package/dist/decorators/metadata.js +35 -0
  29. package/dist/decorators/metadata.js.map +1 -0
  30. package/dist/decorators/register.d.ts +52 -0
  31. package/dist/decorators/register.js +139 -0
  32. package/dist/decorators/register.js.map +1 -0
  33. package/dist/index.d.ts +359 -8
  34. package/dist/index.js +532 -20
  35. package/dist/index.js.map +1 -1
  36. package/dist/notifications/BaseNotificationChannel.d.ts +36 -0
  37. package/dist/notifications/BaseNotificationChannel.js +80 -0
  38. package/dist/notifications/BaseNotificationChannel.js.map +1 -0
  39. package/dist/notifications/InMemoryNotificationChannel.d.ts +12 -0
  40. package/dist/notifications/InMemoryNotificationChannel.js +26 -0
  41. package/dist/notifications/InMemoryNotificationChannel.js.map +1 -0
  42. package/dist/notifications/index.d.ts +2 -0
  43. package/dist/notifications/index.js +3 -0
  44. package/dist/notifications/index.js.map +1 -0
  45. package/dist/types/AgendaBackend.d.ts +53 -0
  46. package/dist/types/AgendaBackend.js +2 -0
  47. package/dist/types/AgendaBackend.js.map +1 -0
  48. package/dist/types/AgendaConfig.d.ts +9 -0
  49. package/dist/types/AgendaConfig.js +2 -0
  50. package/dist/types/AgendaConfig.js.map +1 -0
  51. package/dist/types/AgendaStatus.d.ts +32 -0
  52. package/dist/types/AgendaStatus.js +2 -0
  53. package/dist/types/AgendaStatus.js.map +1 -0
  54. package/dist/types/DbOptions.d.ts +4 -0
  55. package/dist/types/DbOptions.js +2 -0
  56. package/dist/types/DbOptions.js.map +1 -0
  57. package/dist/types/JobDefinition.d.ts +40 -0
  58. package/dist/types/JobDefinition.js +2 -0
  59. package/dist/types/JobDefinition.js.map +1 -0
  60. package/dist/types/JobParameters.d.ts +106 -0
  61. package/dist/types/JobParameters.js +17 -0
  62. package/dist/types/JobParameters.js.map +1 -0
  63. package/dist/types/JobQuery.d.ts +79 -0
  64. package/dist/types/JobQuery.js +33 -0
  65. package/dist/types/JobQuery.js.map +1 -0
  66. package/dist/types/JobRepository.d.ts +96 -0
  67. package/dist/types/JobRepository.js +2 -0
  68. package/dist/types/JobRepository.js.map +1 -0
  69. package/dist/types/NotificationChannel.d.ts +71 -0
  70. package/dist/types/NotificationChannel.js +2 -0
  71. package/dist/types/NotificationChannel.js.map +1 -0
  72. package/dist/utils/backoff.d.ts +152 -0
  73. package/dist/utils/backoff.js +167 -0
  74. package/dist/utils/backoff.js.map +1 -0
  75. package/dist/utils/dateConstraints.d.ts +48 -0
  76. package/dist/utils/dateConstraints.js +128 -0
  77. package/dist/utils/dateConstraints.js.map +1 -0
  78. package/dist/utils/isValidDate.d.ts +1 -0
  79. package/dist/utils/isValidDate.js +5 -0
  80. package/dist/utils/isValidDate.js.map +1 -0
  81. package/dist/utils/nextRunAt.d.ts +10 -0
  82. package/dist/utils/nextRunAt.js +110 -0
  83. package/dist/utils/nextRunAt.js.map +1 -0
  84. package/dist/utils/priority.d.ts +13 -0
  85. package/dist/utils/priority.js +20 -0
  86. package/dist/utils/priority.js.map +1 -0
  87. package/dist/utils/processEvery.d.ts +1 -0
  88. package/dist/utils/processEvery.js +7 -0
  89. package/dist/utils/processEvery.js.map +1 -0
  90. package/dist/utils/stack.d.ts +1 -0
  91. package/dist/utils/stack.js +18 -0
  92. package/dist/utils/stack.js.map +1 -0
  93. package/package.json +40 -76
  94. package/History.md +0 -617
  95. package/dist/agenda/cancel.d.ts +0 -11
  96. package/dist/agenda/cancel.d.ts.map +0 -1
  97. package/dist/agenda/cancel.js +0 -41
  98. package/dist/agenda/cancel.js.map +0 -1
  99. package/dist/agenda/close.d.ts +0 -17
  100. package/dist/agenda/close.d.ts.map +0 -1
  101. package/dist/agenda/close.js +0 -47
  102. package/dist/agenda/close.js.map +0 -1
  103. package/dist/agenda/create.d.ts +0 -11
  104. package/dist/agenda/create.d.ts.map +0 -1
  105. package/dist/agenda/create.js +0 -27
  106. package/dist/agenda/create.js.map +0 -1
  107. package/dist/agenda/database.d.ts +0 -20
  108. package/dist/agenda/database.d.ts.map +0 -1
  109. package/dist/agenda/database.js +0 -56
  110. package/dist/agenda/database.js.map +0 -1
  111. package/dist/agenda/db-init.d.ts +0 -11
  112. package/dist/agenda/db-init.d.ts.map +0 -1
  113. package/dist/agenda/db-init.js +0 -40
  114. package/dist/agenda/db-init.js.map +0 -1
  115. package/dist/agenda/default-concurrency.d.ts +0 -9
  116. package/dist/agenda/default-concurrency.d.ts.map +0 -1
  117. package/dist/agenda/default-concurrency.js +0 -21
  118. package/dist/agenda/default-concurrency.js.map +0 -1
  119. package/dist/agenda/default-lock-lifetime.d.ts +0 -10
  120. package/dist/agenda/default-lock-lifetime.d.ts.map +0 -1
  121. package/dist/agenda/default-lock-lifetime.js +0 -22
  122. package/dist/agenda/default-lock-lifetime.js.map +0 -1
  123. package/dist/agenda/default-lock-limit.d.ts +0 -10
  124. package/dist/agenda/default-lock-limit.d.ts.map +0 -1
  125. package/dist/agenda/default-lock-limit.js +0 -22
  126. package/dist/agenda/default-lock-limit.js.map +0 -1
  127. package/dist/agenda/define.d.ts +0 -45
  128. package/dist/agenda/define.d.ts.map +0 -1
  129. package/dist/agenda/define.js +0 -44
  130. package/dist/agenda/define.js.map +0 -1
  131. package/dist/agenda/disable.d.ts +0 -11
  132. package/dist/agenda/disable.d.ts.map +0 -1
  133. package/dist/agenda/disable.js +0 -42
  134. package/dist/agenda/disable.js.map +0 -1
  135. package/dist/agenda/drain.d.ts +0 -9
  136. package/dist/agenda/drain.d.ts.map +0 -1
  137. package/dist/agenda/drain.js +0 -46
  138. package/dist/agenda/drain.js.map +0 -1
  139. package/dist/agenda/enable.d.ts +0 -12
  140. package/dist/agenda/enable.d.ts.map +0 -1
  141. package/dist/agenda/enable.js +0 -43
  142. package/dist/agenda/enable.js.map +0 -1
  143. package/dist/agenda/every.d.ts +0 -15
  144. package/dist/agenda/every.d.ts.map +0 -1
  145. package/dist/agenda/every.js +0 -77
  146. package/dist/agenda/every.js.map +0 -1
  147. package/dist/agenda/find-and-lock-next-job.d.ts +0 -13
  148. package/dist/agenda/find-and-lock-next-job.d.ts.map +0 -1
  149. package/dist/agenda/find-and-lock-next-job.js +0 -75
  150. package/dist/agenda/find-and-lock-next-job.js.map +0 -1
  151. package/dist/agenda/has-mongo-protocol.d.ts +0 -7
  152. package/dist/agenda/has-mongo-protocol.d.ts.map +0 -1
  153. package/dist/agenda/has-mongo-protocol.js +0 -13
  154. package/dist/agenda/has-mongo-protocol.js.map +0 -1
  155. package/dist/agenda/index.d.ts +0 -130
  156. package/dist/agenda/index.d.ts.map +0 -1
  157. package/dist/agenda/index.js +0 -128
  158. package/dist/agenda/index.js.map +0 -1
  159. package/dist/agenda/job-processing-queue.d.ts +0 -18
  160. package/dist/agenda/job-processing-queue.d.ts.map +0 -1
  161. package/dist/agenda/job-processing-queue.js +0 -76
  162. package/dist/agenda/job-processing-queue.js.map +0 -1
  163. package/dist/agenda/jobs.d.ts +0 -15
  164. package/dist/agenda/jobs.d.ts.map +0 -1
  165. package/dist/agenda/jobs.js +0 -36
  166. package/dist/agenda/jobs.js.map +0 -1
  167. package/dist/agenda/lock-limit.d.ts +0 -9
  168. package/dist/agenda/lock-limit.d.ts.map +0 -1
  169. package/dist/agenda/lock-limit.js +0 -22
  170. package/dist/agenda/lock-limit.js.map +0 -1
  171. package/dist/agenda/max-concurrency.d.ts +0 -10
  172. package/dist/agenda/max-concurrency.d.ts.map +0 -1
  173. package/dist/agenda/max-concurrency.js +0 -22
  174. package/dist/agenda/max-concurrency.js.map +0 -1
  175. package/dist/agenda/mongo.d.ts +0 -12
  176. package/dist/agenda/mongo.d.ts.map +0 -1
  177. package/dist/agenda/mongo.js +0 -18
  178. package/dist/agenda/mongo.js.map +0 -1
  179. package/dist/agenda/name.d.ts +0 -9
  180. package/dist/agenda/name.d.ts.map +0 -1
  181. package/dist/agenda/name.js +0 -21
  182. package/dist/agenda/name.js.map +0 -1
  183. package/dist/agenda/now.d.ts +0 -11
  184. package/dist/agenda/now.d.ts.map +0 -1
  185. package/dist/agenda/now.js +0 -41
  186. package/dist/agenda/now.js.map +0 -1
  187. package/dist/agenda/process-every.d.ts +0 -9
  188. package/dist/agenda/process-every.d.ts.map +0 -1
  189. package/dist/agenda/process-every.js +0 -23
  190. package/dist/agenda/process-every.js.map +0 -1
  191. package/dist/agenda/purge.d.ts +0 -9
  192. package/dist/agenda/purge.d.ts.map +0 -1
  193. package/dist/agenda/purge.js +0 -33
  194. package/dist/agenda/purge.js.map +0 -1
  195. package/dist/agenda/save-job.d.ts +0 -11
  196. package/dist/agenda/save-job.d.ts.map +0 -1
  197. package/dist/agenda/save-job.js +0 -156
  198. package/dist/agenda/save-job.js.map +0 -1
  199. package/dist/agenda/schedule.d.ts +0 -14
  200. package/dist/agenda/schedule.d.ts.map +0 -1
  201. package/dist/agenda/schedule.js +0 -62
  202. package/dist/agenda/schedule.js.map +0 -1
  203. package/dist/agenda/sort.d.ts +0 -10
  204. package/dist/agenda/sort.d.ts.map +0 -1
  205. package/dist/agenda/sort.js +0 -22
  206. package/dist/agenda/sort.js.map +0 -1
  207. package/dist/agenda/start.d.ts +0 -10
  208. package/dist/agenda/start.d.ts.map +0 -1
  209. package/dist/agenda/start.js +0 -39
  210. package/dist/agenda/start.js.map +0 -1
  211. package/dist/agenda/stop.d.ts +0 -9
  212. package/dist/agenda/stop.d.ts.map +0 -1
  213. package/dist/agenda/stop.js +0 -57
  214. package/dist/agenda/stop.js.map +0 -1
  215. package/dist/cjs.d.ts +0 -2
  216. package/dist/cjs.d.ts.map +0 -1
  217. package/dist/cjs.js +0 -7
  218. package/dist/cjs.js.map +0 -1
  219. package/dist/index.d.ts.map +0 -1
  220. package/dist/job/compute-next-run-at.d.ts +0 -8
  221. package/dist/job/compute-next-run-at.d.ts.map +0 -1
  222. package/dist/job/compute-next-run-at.js +0 -162
  223. package/dist/job/compute-next-run-at.js.map +0 -1
  224. package/dist/job/disable.d.ts +0 -8
  225. package/dist/job/disable.d.ts.map +0 -1
  226. package/dist/job/disable.js +0 -14
  227. package/dist/job/disable.js.map +0 -1
  228. package/dist/job/enable.d.ts +0 -8
  229. package/dist/job/enable.d.ts.map +0 -1
  230. package/dist/job/enable.js +0 -14
  231. package/dist/job/enable.js.map +0 -1
  232. package/dist/job/fail.d.ts +0 -9
  233. package/dist/job/fail.d.ts.map +0 -1
  234. package/dist/job/fail.js +0 -28
  235. package/dist/job/fail.js.map +0 -1
  236. package/dist/job/index.d.ts +0 -142
  237. package/dist/job/index.d.ts.map +0 -1
  238. package/dist/job/index.js +0 -82
  239. package/dist/job/index.js.map +0 -1
  240. package/dist/job/is-running.d.ts +0 -12
  241. package/dist/job/is-running.d.ts.map +0 -1
  242. package/dist/job/is-running.js +0 -27
  243. package/dist/job/is-running.js.map +0 -1
  244. package/dist/job/priority.d.ts +0 -7
  245. package/dist/job/priority.d.ts.map +0 -1
  246. package/dist/job/priority.js +0 -14
  247. package/dist/job/priority.js.map +0 -1
  248. package/dist/job/remove.d.ts +0 -8
  249. package/dist/job/remove.d.ts.map +0 -1
  250. package/dist/job/remove.js +0 -24
  251. package/dist/job/remove.js.map +0 -1
  252. package/dist/job/repeat-at.d.ts +0 -9
  253. package/dist/job/repeat-at.d.ts.map +0 -1
  254. package/dist/job/repeat-at.js +0 -15
  255. package/dist/job/repeat-at.js.map +0 -1
  256. package/dist/job/repeat-every.d.ts +0 -17
  257. package/dist/job/repeat-every.d.ts.map +0 -1
  258. package/dist/job/repeat-every.js +0 -32
  259. package/dist/job/repeat-every.js.map +0 -1
  260. package/dist/job/run.d.ts +0 -8
  261. package/dist/job/run.d.ts.map +0 -1
  262. package/dist/job/run.js +0 -99
  263. package/dist/job/run.js.map +0 -1
  264. package/dist/job/save.d.ts +0 -9
  265. package/dist/job/save.d.ts.map +0 -1
  266. package/dist/job/save.js +0 -25
  267. package/dist/job/save.js.map +0 -1
  268. package/dist/job/schedule.d.ts +0 -9
  269. package/dist/job/schedule.d.ts.map +0 -1
  270. package/dist/job/schedule.js +0 -21
  271. package/dist/job/schedule.js.map +0 -1
  272. package/dist/job/set-shouldsaveresult.d.ts +0 -7
  273. package/dist/job/set-shouldsaveresult.d.ts.map +0 -1
  274. package/dist/job/set-shouldsaveresult.js +0 -13
  275. package/dist/job/set-shouldsaveresult.js.map +0 -1
  276. package/dist/job/to-json.d.ts +0 -9
  277. package/dist/job/to-json.d.ts.map +0 -1
  278. package/dist/job/to-json.js +0 -36
  279. package/dist/job/to-json.js.map +0 -1
  280. package/dist/job/touch.d.ts +0 -8
  281. package/dist/job/touch.d.ts.map +0 -1
  282. package/dist/job/touch.js +0 -25
  283. package/dist/job/touch.js.map +0 -1
  284. package/dist/job/unique.d.ts +0 -12
  285. package/dist/job/unique.d.ts.map +0 -1
  286. package/dist/job/unique.js +0 -17
  287. package/dist/job/unique.js.map +0 -1
  288. package/dist/utils/create-job.d.ts +0 -10
  289. package/dist/utils/create-job.d.ts.map +0 -1
  290. package/dist/utils/create-job.js +0 -16
  291. package/dist/utils/create-job.js.map +0 -1
  292. package/dist/utils/index.d.ts +0 -4
  293. package/dist/utils/index.d.ts.map +0 -1
  294. package/dist/utils/index.js +0 -16
  295. package/dist/utils/index.js.map +0 -1
  296. package/dist/utils/parse-priority.d.ts +0 -6
  297. package/dist/utils/parse-priority.d.ts.map +0 -1
  298. package/dist/utils/parse-priority.js +0 -35
  299. package/dist/utils/parse-priority.js.map +0 -1
  300. package/dist/utils/process-jobs.d.ts +0 -8
  301. package/dist/utils/process-jobs.d.ts.map +0 -1
  302. package/dist/utils/process-jobs.js +0 -308
  303. package/dist/utils/process-jobs.js.map +0 -1
  304. package/es.js +0 -1
  305. package/lib/agenda/cancel.ts +0 -28
  306. package/lib/agenda/close.ts +0 -37
  307. package/lib/agenda/create.ts +0 -22
  308. package/lib/agenda/database.ts +0 -63
  309. package/lib/agenda/db-init.ts +0 -45
  310. package/lib/agenda/default-concurrency.ts +0 -19
  311. package/lib/agenda/default-lock-lifetime.ts +0 -17
  312. package/lib/agenda/default-lock-limit.ts +0 -17
  313. package/lib/agenda/define.ts +0 -85
  314. package/lib/agenda/disable.ts +0 -28
  315. package/lib/agenda/drain.ts +0 -30
  316. package/lib/agenda/enable.ts +0 -29
  317. package/lib/agenda/every.ts +0 -86
  318. package/lib/agenda/find-and-lock-next-job.ts +0 -78
  319. package/lib/agenda/has-mongo-protocol.ts +0 -8
  320. package/lib/agenda/index.ts +0 -227
  321. package/lib/agenda/job-processing-queue.ts +0 -99
  322. package/lib/agenda/jobs.ts +0 -31
  323. package/lib/agenda/lock-limit.ts +0 -17
  324. package/lib/agenda/max-concurrency.ts +0 -20
  325. package/lib/agenda/mongo.ts +0 -21
  326. package/lib/agenda/name.ts +0 -16
  327. package/lib/agenda/now.ts +0 -31
  328. package/lib/agenda/process-every.ts +0 -18
  329. package/lib/agenda/purge.ts +0 -19
  330. package/lib/agenda/save-job.ts +0 -185
  331. package/lib/agenda/schedule.ts +0 -79
  332. package/lib/agenda/sort.ts +0 -17
  333. package/lib/agenda/start.ts +0 -30
  334. package/lib/agenda/stop.ts +0 -49
  335. package/lib/cjs.ts +0 -5
  336. package/lib/index.ts +0 -11
  337. package/lib/job/compute-next-run-at.ts +0 -191
  338. package/lib/job/disable.ts +0 -11
  339. package/lib/job/enable.ts +0 -11
  340. package/lib/job/fail.ts +0 -29
  341. package/lib/job/index.ts +0 -221
  342. package/lib/job/is-running.ts +0 -29
  343. package/lib/job/priority.ts +0 -11
  344. package/lib/job/remove.ts +0 -10
  345. package/lib/job/repeat-at.ts +0 -12
  346. package/lib/job/repeat-every.ts +0 -40
  347. package/lib/job/run.ts +0 -125
  348. package/lib/job/save.ts +0 -11
  349. package/lib/job/schedule.ts +0 -15
  350. package/lib/job/set-shouldsaveresult.ts +0 -10
  351. package/lib/job/to-json.ts +0 -36
  352. package/lib/job/touch.ts +0 -11
  353. package/lib/job/unique.ts +0 -18
  354. package/lib/utils/create-job.ts +0 -13
  355. package/lib/utils/index.ts +0 -3
  356. package/lib/utils/parse-priority.ts +0 -37
  357. package/lib/utils/process-jobs.ts +0 -379
  358. package/tsconfig.json +0 -72
@@ -0,0 +1,139 @@
1
+ import { getControllerMetadata, isJobsController } from './metadata.js';
2
+ /**
3
+ * Error thrown when attempting to register an invalid jobs controller
4
+ */
5
+ export class JobsRegistrationError extends Error {
6
+ constructor(message) {
7
+ super(message);
8
+ this.name = 'JobsRegistrationError';
9
+ }
10
+ }
11
+ /**
12
+ * Register job handlers from decorated class instances with an Agenda instance.
13
+ *
14
+ * This function reads the metadata from classes decorated with `@JobsController`
15
+ * and registers their methods as job handlers.
16
+ *
17
+ * @param agenda - The Agenda instance to register jobs with
18
+ * @param instances - Array of instantiated job controller classes
19
+ * @throws {JobsRegistrationError} If a class is not decorated with @JobsController
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * import { Agenda, registerJobs } from 'agenda';
24
+ * import { MongoBackend } from '@agendajs/mongo-backend';
25
+ * import { EmailJobs } from './jobs/email';
26
+ * import { ReportJobs } from './jobs/reports';
27
+ *
28
+ * const agenda = new Agenda({
29
+ * backend: new MongoBackend({ address: 'mongodb://localhost/agenda' })
30
+ * });
31
+ *
32
+ * // Create instances (can inject dependencies via constructor)
33
+ * const emailJobs = new EmailJobs(emailService);
34
+ * const reportJobs = new ReportJobs(reportService);
35
+ *
36
+ * // Register all job handlers
37
+ * registerJobs(agenda, [emailJobs, reportJobs]);
38
+ *
39
+ * await agenda.start();
40
+ * ```
41
+ */
42
+ export function registerJobs(agenda, instances) {
43
+ const pendingEveryJobs = [];
44
+ for (const instance of instances) {
45
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- instance.constructor is typed as Function
46
+ const constructor = instance.constructor;
47
+ // Validate that the class is decorated
48
+ if (!isJobsController(constructor)) {
49
+ throw new JobsRegistrationError(`Class "${constructor.name}" is not decorated with @JobsController. ` +
50
+ 'Make sure to add @JobsController() decorator to your class.');
51
+ }
52
+ const metadata = getControllerMetadata(constructor);
53
+ if (!metadata) {
54
+ continue;
55
+ }
56
+ registerJobsFromMetadata(agenda, instance, metadata, pendingEveryJobs);
57
+ }
58
+ // Schedule @Every jobs after agenda starts
59
+ if (pendingEveryJobs.length > 0) {
60
+ scheduleEveryJobsOnReady(agenda, pendingEveryJobs);
61
+ }
62
+ }
63
+ /**
64
+ * Register jobs from a single controller's metadata
65
+ */
66
+ function registerJobsFromMetadata(agenda, instance, metadata, pendingEveryJobs) {
67
+ const namespace = metadata.namespace;
68
+ for (const [methodName, jobMeta] of metadata.jobs) {
69
+ const jobName = buildJobName(namespace, jobMeta.options.name || methodName);
70
+ // Bind the method to the instance
71
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Dynamic method access requires any
72
+ const handler = instance[methodName].bind(instance);
73
+ // Create an async wrapper that matches Agenda's expected signature
74
+ const wrappedHandler = async (job) => {
75
+ await handler(job);
76
+ };
77
+ // Register the job definition with Agenda
78
+ agenda.define(jobName, wrappedHandler, {
79
+ concurrency: jobMeta.options.concurrency,
80
+ lockLifetime: jobMeta.options.lockLifetime,
81
+ lockLimit: jobMeta.options.lockLimit,
82
+ priority: jobMeta.options.priority
83
+ });
84
+ // Queue @Every jobs for scheduling after start
85
+ if (jobMeta.type === 'every' && jobMeta.interval !== undefined) {
86
+ pendingEveryJobs.push({
87
+ jobName,
88
+ interval: jobMeta.interval,
89
+ options: jobMeta.options
90
+ });
91
+ }
92
+ }
93
+ }
94
+ /**
95
+ * Build the full job name with optional namespace prefix
96
+ */
97
+ function buildJobName(namespace, name) {
98
+ return namespace ? `${namespace}.${name}` : name;
99
+ }
100
+ /**
101
+ * Schedule @Every jobs when Agenda emits the 'ready' event
102
+ */
103
+ function scheduleEveryJobsOnReady(agenda, pendingJobs) {
104
+ const scheduleJobs = async () => {
105
+ for (const pending of pendingJobs) {
106
+ await agenda.every(pending.interval, pending.jobName, undefined, {
107
+ timezone: pending.options.timezone,
108
+ skipImmediate: pending.options.skipImmediate
109
+ });
110
+ }
111
+ };
112
+ // If agenda is already started, schedule immediately
113
+ // Otherwise, wait for the 'ready' event
114
+ agenda.once('ready', () => {
115
+ scheduleJobs().catch(err => {
116
+ agenda.emit('error', err);
117
+ });
118
+ });
119
+ }
120
+ /**
121
+ * Get information about registered jobs from decorated classes.
122
+ * Useful for debugging and introspection.
123
+ *
124
+ * @param instances - Array of job controller instances
125
+ * @returns Array of job registration info
126
+ */
127
+ export function getRegisteredJobsInfo(instances) {
128
+ return instances.map(instance => {
129
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- instance.constructor is typed as Function
130
+ const constructor = instance.constructor;
131
+ const metadata = getControllerMetadata(constructor);
132
+ return {
133
+ className: constructor.name,
134
+ namespace: metadata?.namespace,
135
+ jobs: metadata ? Array.from(metadata.jobs.values()) : []
136
+ };
137
+ });
138
+ }
139
+ //# sourceMappingURL=register.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.js","sourceRoot":"","sources":["../../src/decorators/register.ts"],"names":[],"mappings":"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"}
package/dist/index.d.ts CHANGED
@@ -1,8 +1,359 @@
1
- export * from "./agenda";
2
- export * from "./job";
3
- export { DefineOptions, JobPriority, Processor } from "./agenda/define";
4
- export { JobOptions } from "./job/repeat-every";
5
- import { Agenda } from "./agenda";
6
- export { Agenda };
7
- export default Agenda;
8
- //# sourceMappingURL=index.d.ts.map
1
+ import { EventEmitter } from 'events';
2
+ import { ForkOptions } from 'child_process';
3
+ import type { JobDefinition } from './types/JobDefinition.js';
4
+ import type { AgendaConfig } from './types/AgendaConfig.js';
5
+ import type { AgendaBackend } from './types/AgendaBackend.js';
6
+ import type { NotificationChannel } from './types/NotificationChannel.js';
7
+ import type { JobRepository } from './types/JobRepository.js';
8
+ import type { AgendaStatus } from './types/AgendaStatus.js';
9
+ import type { JobsQueryOptions, JobsResult, JobsOverview } from './types/JobQuery.js';
10
+ import type { RemoveJobsOptions } from './types/JobRepository.js';
11
+ import { Job, JobWithId } from './Job.js';
12
+ import { JobPriority } from './utils/priority.js';
13
+ /**
14
+ * Agenda configuration options
15
+ */
16
+ export interface AgendaOptions {
17
+ /** Unified backend for storage and optionally notifications */
18
+ backend: AgendaBackend;
19
+ /** Name to identify this agenda instance */
20
+ name?: string;
21
+ /** Default number of concurrent jobs per job type */
22
+ defaultConcurrency?: number;
23
+ /** How often to poll for new jobs (string like '5 seconds' or milliseconds) */
24
+ processEvery?: string | number;
25
+ /** Maximum number of concurrent jobs globally */
26
+ maxConcurrency?: number;
27
+ /** Default max locked jobs per job type */
28
+ defaultLockLimit?: number;
29
+ /** Global max locked jobs */
30
+ lockLimit?: number;
31
+ /** Default lock lifetime in milliseconds */
32
+ defaultLockLifetime?: number;
33
+ /** Fork helper configuration for sandboxed workers */
34
+ forkHelper?: {
35
+ path: string;
36
+ options?: ForkOptions;
37
+ };
38
+ /** Whether this is a forked worker instance */
39
+ forkedWorker?: boolean;
40
+ /**
41
+ * Override notification channel from backend.
42
+ * Use this to mix storage from one system with notifications from another.
43
+ * e.g., MongoDB storage + Redis notifications
44
+ */
45
+ notificationChannel?: NotificationChannel;
46
+ }
47
+ /**
48
+ * Details provided when a job is scheduled for retry
49
+ */
50
+ export interface RetryDetails {
51
+ /** The retry attempt number (1-based) */
52
+ attempt: number;
53
+ /** Delay in milliseconds before the retry */
54
+ delay: number;
55
+ /** When the retry will be executed */
56
+ nextRunAt: Date;
57
+ /** The error that caused the failure */
58
+ error: Error;
59
+ }
60
+ /**
61
+ * Event names that Agenda emits
62
+ */
63
+ export type AgendaEventName = 'ready' | 'error' | 'fail' | 'success' | 'start' | 'complete' | 'retry' | 'retry exhausted' | `fail:${string}` | `success:${string}` | `start:${string}` | `complete:${string}` | `retry:${string}` | `retry exhausted:${string}`;
64
+ /**
65
+ * @class
66
+ */
67
+ export declare class Agenda extends EventEmitter {
68
+ readonly attrs: AgendaConfig;
69
+ readonly forkedWorker?: boolean;
70
+ readonly forkHelper?: {
71
+ path: string;
72
+ options?: ForkOptions;
73
+ };
74
+ private backend;
75
+ db: JobRepository;
76
+ private notificationChannel?;
77
+ on(event: 'ready', listener: () => void): this;
78
+ on(event: 'error', listener: (error: Error) => void): this;
79
+ on(event: 'fail', listener: (error: Error, job: JobWithId) => void): this;
80
+ on(event: 'success', listener: (job: JobWithId) => void): this;
81
+ on(event: 'start', listener: (job: JobWithId) => void): this;
82
+ on(event: 'complete', listener: (job: JobWithId) => void): this;
83
+ on(event: 'retry', listener: (job: JobWithId, details: RetryDetails) => void): this;
84
+ on(event: 'retry exhausted', listener: (error: Error, job: JobWithId) => void): this;
85
+ on(event: `fail:${string}`, listener: (error: Error, job: JobWithId) => void): this;
86
+ on(event: `success:${string}`, listener: (job: JobWithId) => void): this;
87
+ on(event: `start:${string}`, listener: (job: JobWithId) => void): this;
88
+ on(event: `complete:${string}`, listener: (job: JobWithId) => void): this;
89
+ on(event: `retry:${string}`, listener: (job: JobWithId, details: RetryDetails) => void): this;
90
+ on(event: `retry exhausted:${string}`, listener: (error: Error, job: JobWithId) => void): this;
91
+ readonly definitions: {
92
+ [name: string]: JobDefinition;
93
+ };
94
+ private jobProcessor?;
95
+ readonly ready: Promise<void>;
96
+ isActiveJobProcessor(): boolean;
97
+ runForkedJob(jobId: string): Promise<void>;
98
+ getRunningStats(fullDetails?: boolean): Promise<AgendaStatus>;
99
+ /**
100
+ * @param config - Agenda configuration with backend
101
+ * @param cb - Optional callback after Agenda is ready
102
+ */
103
+ constructor(config: AgendaOptions, cb?: (error?: Error) => void);
104
+ /**
105
+ * Cancels any jobs matching the passed options, and removes them from the database.
106
+ * @param options Options for which jobs to cancel
107
+ */
108
+ cancel(options: RemoveJobsOptions): Promise<number>;
109
+ /**
110
+ * Disables any jobs matching the passed options, preventing them from being run.
111
+ * @param options Options for which jobs to disable
112
+ * @returns Number of jobs disabled
113
+ */
114
+ disable(options: RemoveJobsOptions): Promise<number>;
115
+ /**
116
+ * Enables any jobs matching the passed options, allowing them to be run.
117
+ * @param options Options for which jobs to enable
118
+ * @returns Number of jobs enabled
119
+ */
120
+ enable(options: RemoveJobsOptions): Promise<number>;
121
+ /**
122
+ * Set name of queue
123
+ * @param name
124
+ */
125
+ name(name: string): Agenda;
126
+ /**
127
+ * Set the time how often the job processor checks for new jobs to process
128
+ * @param time
129
+ */
130
+ processEvery(time: string | number): Agenda;
131
+ /**
132
+ * Set the concurrency for jobs (globally), type does not matter
133
+ * @param num
134
+ */
135
+ maxConcurrency(num: number): Agenda;
136
+ /**
137
+ * Set the default concurrency for each job
138
+ * @param num number of max concurrency
139
+ */
140
+ defaultConcurrency(num: number): Agenda;
141
+ /**
142
+ * Set the default amount jobs that are allowed to be locked at one time (GLOBAL)
143
+ * @param num
144
+ */
145
+ lockLimit(num: number): Agenda;
146
+ /**
147
+ * Set default lock limit per job type
148
+ * @param num
149
+ */
150
+ defaultLockLimit(num: number): Agenda;
151
+ /**
152
+ * Set the default lock time (in ms)
153
+ * Default is 10 * 60 * 1000 ms (10 minutes)
154
+ * @param ms
155
+ */
156
+ defaultLockLifetime(ms: number): Agenda;
157
+ /**
158
+ * Set a notification channel for real-time job notifications
159
+ * @param channel - The notification channel implementation
160
+ */
161
+ notifyVia(channel: NotificationChannel): Agenda;
162
+ /**
163
+ * Check if a notification channel is configured
164
+ */
165
+ hasNotificationChannel(): boolean;
166
+ /**
167
+ * Publish a job notification to the notification channel
168
+ * @internal
169
+ */
170
+ publishJobNotification(job: Job): Promise<void>;
171
+ /**
172
+ * Query jobs with database-agnostic options.
173
+ * Returns jobs with computed states and supports filtering by state.
174
+ *
175
+ * @param options - Query options (name, state, search, pagination)
176
+ * @returns Jobs with computed states and total count
177
+ */
178
+ queryJobs(options?: JobsQueryOptions): Promise<JobsResult>;
179
+ /**
180
+ * Get overview statistics for jobs grouped by name.
181
+ * Returns counts of jobs in each state for each job name.
182
+ *
183
+ * @returns Array of job overviews with state counts
184
+ */
185
+ getJobsOverview(): Promise<JobsOverview[]>;
186
+ /**
187
+ * Removes all jobs from queue
188
+ * @note: Only use after defining your jobs
189
+ */
190
+ purge(): Promise<number>;
191
+ /**
192
+ * Setup definition for job
193
+ * Method is used by consumers of lib to setup their functions
194
+ * BREAKING CHANGE in v4: options moved from 2nd to 3rd parameter!
195
+ * @param name
196
+ * @param processor
197
+ * @param options
198
+ */
199
+ define<DATA = any>(name: string, processor: (agendaJob: Job<DATA>, done: (error?: Error) => void) => void, options?: Partial<Pick<JobDefinition, 'lockLimit' | 'lockLifetime' | 'concurrency' | 'backoff'>> & {
200
+ priority?: JobPriority;
201
+ }): void;
202
+ define<DATA = any>(name: string, processor: (agendaJob: Job<DATA>) => Promise<void>, options?: Partial<Pick<JobDefinition, 'lockLimit' | 'lockLifetime' | 'concurrency' | 'backoff'>> & {
203
+ priority?: JobPriority;
204
+ }): void;
205
+ /**
206
+ * Internal helper method that uses createJob to create jobs for an array of names
207
+ * @param names - Job names to schedule
208
+ * @param createJob - Factory function to create each job
209
+ * @returns Array of created jobs
210
+ */
211
+ private createJobs;
212
+ /**
213
+ * Given a name and some data, create a new job
214
+ * @param name
215
+ */
216
+ create(name: string): Job<void>;
217
+ create<DATA = unknown>(name: string, data: DATA): Job<DATA>;
218
+ /**
219
+ * Creates a scheduled job with given interval and name/names of the job to run
220
+ * @param interval
221
+ * @param names
222
+ * @param data
223
+ * @param options
224
+ */
225
+ every(interval: string | number, names: string[], data?: undefined, options?: {
226
+ timezone?: string;
227
+ skipImmediate?: boolean;
228
+ forkMode?: boolean;
229
+ startDate?: Date | string;
230
+ endDate?: Date | string;
231
+ skipDays?: number[];
232
+ }): Promise<Job<void>[]>;
233
+ every(interval: string | number, name: string, data?: undefined, options?: {
234
+ timezone?: string;
235
+ skipImmediate?: boolean;
236
+ forkMode?: boolean;
237
+ startDate?: Date | string;
238
+ endDate?: Date | string;
239
+ skipDays?: number[];
240
+ }): Promise<Job<void>>;
241
+ every<DATA = unknown>(interval: string | number, names: string[], data: DATA, options?: {
242
+ timezone?: string;
243
+ skipImmediate?: boolean;
244
+ forkMode?: boolean;
245
+ startDate?: Date | string;
246
+ endDate?: Date | string;
247
+ skipDays?: number[];
248
+ }): Promise<Job<DATA>[]>;
249
+ every<DATA = unknown>(interval: string | number, name: string, data: DATA, options?: {
250
+ timezone?: string;
251
+ skipImmediate?: boolean;
252
+ forkMode?: boolean;
253
+ startDate?: Date | string;
254
+ endDate?: Date | string;
255
+ skipDays?: number[];
256
+ }): Promise<Job<DATA>>;
257
+ /**
258
+ * Schedule a job or jobs at a specific time
259
+ * @param when
260
+ * @param names
261
+ * @param data
262
+ * @param options
263
+ */
264
+ schedule<DATA = void>(when: string | Date, names: string[], data?: undefined, options?: {
265
+ startDate?: Date | string;
266
+ endDate?: Date | string;
267
+ skipDays?: number[];
268
+ }): Promise<Job<DATA>[]>;
269
+ schedule<DATA = void>(when: string | Date, names: string, data?: undefined, options?: {
270
+ startDate?: Date | string;
271
+ endDate?: Date | string;
272
+ skipDays?: number[];
273
+ }): Promise<Job<DATA>>;
274
+ schedule<DATA = unknown>(when: string | Date, names: string[], data: DATA, options?: {
275
+ startDate?: Date | string;
276
+ endDate?: Date | string;
277
+ skipDays?: number[];
278
+ }): Promise<Job<DATA>[]>;
279
+ schedule<DATA = unknown>(when: string | Date, name: string, data: DATA, options?: {
280
+ startDate?: Date | string;
281
+ endDate?: Date | string;
282
+ skipDays?: number[];
283
+ }): Promise<Job<DATA>>;
284
+ /**
285
+ * Create a job for this exact moment
286
+ * @param name
287
+ */
288
+ now<DATA = void>(name: string): Promise<Job<DATA>>;
289
+ now<DATA = unknown>(name: string, data: DATA): Promise<Job<DATA>>;
290
+ /**
291
+ * Create a debounced job that combines rapid submissions into a single execution.
292
+ * Requires a unique key to identify which jobs should be debounced together.
293
+ *
294
+ * @param name - Job name
295
+ * @param data - Job data
296
+ * @param uniqueKey - Unique constraint to identify jobs (e.g., { 'data.userId': 123 })
297
+ * @param debounceMs - Debounce delay in milliseconds
298
+ * @param options - Optional debounce options (maxWait, strategy)
299
+ *
300
+ * @example
301
+ * ```ts
302
+ * // Debounce search index updates by entity type
303
+ * await agenda.nowDebounced(
304
+ * 'updateSearchIndex',
305
+ * { entityType: 'products' },
306
+ * { 'data.entityType': 'products' },
307
+ * 2000
308
+ * );
309
+ *
310
+ * // With maxWait to guarantee execution within 30s
311
+ * await agenda.nowDebounced(
312
+ * 'syncUser',
313
+ * { userId: 123 },
314
+ * { 'data.userId': 123 },
315
+ * 5000,
316
+ * { maxWait: 30000 }
317
+ * );
318
+ * ```
319
+ */
320
+ nowDebounced<DATA = unknown>(name: string, data: DATA, uniqueKey: Record<string, unknown>, debounceMs: number, options?: {
321
+ maxWait?: number;
322
+ strategy?: 'trailing' | 'leading';
323
+ }): Promise<Job<DATA>>;
324
+ /**
325
+ * Starts processing jobs using processJobs() methods, storing an interval ID
326
+ * This method will only resolve if a db has been set up beforehand.
327
+ */
328
+ start(): Promise<void>;
329
+ /**
330
+ * Clear the interval that processes the jobs and unlocks all currently locked jobs
331
+ * @param closeConnection - Whether to close the database connection.
332
+ * Defaults to backend.ownsConnection (true if backend created the connection,
333
+ * false if connection was passed in by user).
334
+ */
335
+ stop(closeConnection?: boolean): Promise<void>;
336
+ /**
337
+ * Waits for all currently running jobs to finish before stopping.
338
+ * This allows for a graceful shutdown where jobs complete their work.
339
+ * Unlike stop(), this method waits for running jobs to complete instead of unlocking them.
340
+ * @param closeConnection - Whether to close the database connection.
341
+ * Defaults to backend.ownsConnection (true if backend created the connection,
342
+ * false if connection was passed in by user).
343
+ */
344
+ drain(closeConnection?: boolean): Promise<void>;
345
+ }
346
+ export * from './types/AgendaConfig.js';
347
+ export * from './types/JobDefinition.js';
348
+ export * from './types/JobParameters.js';
349
+ export * from './types/DbOptions.js';
350
+ export * from './Job.js';
351
+ export * from './types/JobQuery.js';
352
+ export * from './types/JobRepository.js';
353
+ export * from './types/NotificationChannel.js';
354
+ export * from './types/AgendaBackend.js';
355
+ export * from './types/AgendaStatus.js';
356
+ export * from './notifications/index.js';
357
+ export { applyAllDateConstraints, applyDateRangeConstraints, applySkipDays, shouldSkipDay, isWithinDateRange } from './utils/dateConstraints.js';
358
+ export * from './decorators/index.js';
359
+ export { backoffStrategies, constant, linear, exponential, combine, when, type BackoffStrategy, type BackoffContext, type BackoffOptions, type ExponentialBackoffOptions, type LinearBackoffOptions } from './utils/backoff.js';