agenda-ts 1.6.9-beta.1 → 1.7.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 (131) hide show
  1. package/README.md +42 -49
  2. package/dist/agenda/cancel.d.ts +3 -0
  3. package/dist/agenda/cancel.js +21 -0
  4. package/dist/agenda/cancel.js.map +1 -0
  5. package/dist/agenda/close.d.ts +5 -0
  6. package/dist/agenda/close.js +25 -0
  7. package/dist/agenda/close.js.map +1 -0
  8. package/dist/agenda/count-jobs.d.ts +5 -0
  9. package/dist/agenda/count-jobs.js +12 -0
  10. package/dist/agenda/count-jobs.js.map +1 -0
  11. package/dist/agenda/create.d.ts +3 -0
  12. package/dist/agenda/create.js +31 -0
  13. package/dist/agenda/create.js.map +1 -0
  14. package/dist/agenda/database.d.ts +4 -0
  15. package/dist/agenda/database.js +33 -0
  16. package/dist/agenda/database.js.map +1 -0
  17. package/dist/agenda/db-init.d.ts +3 -0
  18. package/dist/agenda/db-init.js +34 -0
  19. package/dist/agenda/db-init.js.map +1 -0
  20. package/dist/agenda/default-concurrency.d.ts +3 -0
  21. package/dist/agenda/default-concurrency.js +13 -0
  22. package/dist/agenda/default-concurrency.js.map +1 -0
  23. package/dist/agenda/default-lock-lifetime.d.ts +3 -0
  24. package/dist/agenda/default-lock-lifetime.js +13 -0
  25. package/dist/agenda/default-lock-lifetime.js.map +1 -0
  26. package/dist/agenda/default-lock-limit.d.ts +3 -0
  27. package/dist/agenda/default-lock-limit.js +13 -0
  28. package/dist/agenda/default-lock-limit.js.map +1 -0
  29. package/dist/agenda/define.d.ts +23 -0
  30. package/dist/agenda/define.js +34 -0
  31. package/dist/agenda/define.js.map +1 -0
  32. package/dist/agenda/disable.d.ts +3 -0
  33. package/dist/agenda/disable.js +22 -0
  34. package/dist/agenda/disable.js.map +1 -0
  35. package/dist/agenda/drain.d.ts +2 -0
  36. package/dist/agenda/drain.js +26 -0
  37. package/dist/agenda/drain.js.map +1 -0
  38. package/dist/agenda/enable.d.ts +3 -0
  39. package/dist/agenda/enable.js +22 -0
  40. package/dist/agenda/enable.js.map +1 -0
  41. package/dist/agenda/every.d.ts +4 -0
  42. package/dist/agenda/every.js +37 -0
  43. package/dist/agenda/every.js.map +1 -0
  44. package/dist/agenda/find-and-lock-next-job.d.ts +3 -0
  45. package/dist/agenda/find-and-lock-next-job.js +43 -0
  46. package/dist/agenda/find-and-lock-next-job.js.map +1 -0
  47. package/dist/agenda/has-mongo-protocol.d.ts +1 -0
  48. package/dist/agenda/has-mongo-protocol.js +8 -0
  49. package/dist/agenda/has-mongo-protocol.js.map +1 -0
  50. package/dist/agenda/index.d.ts +115 -0
  51. package/dist/agenda/index.js +208 -0
  52. package/dist/agenda/index.js.map +1 -0
  53. package/dist/agenda/job-processing-queue.d.ts +11 -0
  54. package/dist/agenda/job-processing-queue.js +51 -0
  55. package/dist/agenda/job-processing-queue.js.map +1 -0
  56. package/dist/agenda/jobs.d.ts +6 -0
  57. package/dist/agenda/jobs.js +14 -0
  58. package/dist/agenda/jobs.js.map +1 -0
  59. package/dist/agenda/lock-limit.d.ts +3 -0
  60. package/dist/agenda/lock-limit.js +13 -0
  61. package/dist/agenda/lock-limit.js.map +1 -0
  62. package/dist/agenda/max-concurrency.d.ts +3 -0
  63. package/dist/agenda/max-concurrency.js +13 -0
  64. package/dist/agenda/max-concurrency.js.map +1 -0
  65. package/dist/agenda/mongo.d.ts +4 -0
  66. package/dist/agenda/mongo.js +10 -0
  67. package/dist/agenda/mongo.js.map +1 -0
  68. package/dist/agenda/name.d.ts +3 -0
  69. package/dist/agenda/name.js +13 -0
  70. package/dist/agenda/name.js.map +1 -0
  71. package/dist/agenda/now.d.ts +3 -0
  72. package/dist/agenda/now.js +21 -0
  73. package/dist/agenda/now.js.map +1 -0
  74. package/dist/agenda/process-every.d.ts +3 -0
  75. package/dist/agenda/process-every.js +14 -0
  76. package/dist/agenda/process-every.js.map +1 -0
  77. package/dist/agenda/purge.d.ts +2 -0
  78. package/dist/agenda/purge.js +13 -0
  79. package/dist/agenda/purge.js.map +1 -0
  80. package/dist/agenda/resume-on-restart.d.ts +3 -0
  81. package/dist/agenda/resume-on-restart.js +39 -0
  82. package/dist/agenda/resume-on-restart.js.map +1 -0
  83. package/dist/agenda/save-job.d.ts +4 -0
  84. package/dist/agenda/save-job.js +104 -0
  85. package/dist/agenda/save-job.js.map +1 -0
  86. package/dist/agenda/schedule.d.ts +4 -0
  87. package/dist/agenda/schedule.js +36 -0
  88. package/dist/agenda/schedule.js.map +1 -0
  89. package/dist/agenda/sort.d.ts +3 -0
  90. package/dist/agenda/sort.js +13 -0
  91. package/dist/agenda/sort.js.map +1 -0
  92. package/dist/agenda/start.d.ts +2 -0
  93. package/dist/agenda/start.js +19 -0
  94. package/dist/agenda/start.js.map +1 -0
  95. package/dist/agenda/stop.d.ts +2 -0
  96. package/dist/agenda/stop.js +38 -0
  97. package/dist/agenda/stop.js.map +1 -0
  98. package/dist/index.d.ts +5 -5
  99. package/dist/index.js +6 -6
  100. package/dist/index.js.map +1 -1
  101. package/dist/job/compute-next-run-at.js +1 -1
  102. package/dist/job/compute-next-run-at.js.map +1 -1
  103. package/dist/job/fail.js +1 -1
  104. package/dist/job/fail.js.map +1 -1
  105. package/dist/job/fetch-status.js +1 -1
  106. package/dist/job/fetch-status.js.map +1 -1
  107. package/dist/job/index.d.ts +3 -3
  108. package/dist/job/index.js +4 -4
  109. package/dist/job/index.js.map +1 -1
  110. package/dist/job/is-expired.js +1 -1
  111. package/dist/job/is-expired.js.map +1 -1
  112. package/dist/job/is-running.js +1 -2
  113. package/dist/job/is-running.js.map +1 -1
  114. package/dist/job/remove.js +1 -1
  115. package/dist/job/remove.js.map +1 -1
  116. package/dist/job/run.js +13 -13
  117. package/dist/job/run.js.map +1 -1
  118. package/dist/job/save.js +1 -1
  119. package/dist/job/save.js.map +1 -1
  120. package/dist/utils/create-job.d.ts +2 -2
  121. package/dist/utils/create-job.js +2 -2
  122. package/dist/utils/create-job.js.map +1 -1
  123. package/dist/utils/error.d.ts +1 -1
  124. package/dist/utils/error.js +3 -3
  125. package/dist/utils/error.js.map +1 -1
  126. package/dist/utils/parse-priority.js +1 -1
  127. package/dist/utils/parse-priority.js.map +1 -1
  128. package/dist/utils/process-jobs.d.ts +2 -2
  129. package/dist/utils/process-jobs.js +2 -2
  130. package/dist/utils/process-jobs.js.map +1 -1
  131. package/package.json +8 -8
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <p align="center">
2
- <img src="./pulse.png" width="100" alt="project-logo">
2
+ <img src="./agenda.png" width="100" alt="project-logo">
3
3
  </p>
4
4
  <p align="center">
5
5
  <h1 align="center">AGENDA-TS</h1>
@@ -13,6 +13,7 @@
13
13
  <img src="https://img.shields.io/github/languages/top/meabed/agenda-ts?style=default&color=24E0A4" alt="repo-top-language">
14
14
  <img src="https://img.shields.io/github/languages/count/meabed/agenda-ts?style=default&color=24E0A4" alt="repo-language-count">
15
15
  <p>
16
+
16
17
  <p align="center">
17
18
  <!-- default option, no dependency badges. -->
18
19
  </p>
@@ -46,9 +47,9 @@ Agenda-TS is a modern TypeScript fork of the [Agenda](https://github.com/agenda/
46
47
 
47
48
  <br/>
48
49
 
49
- #### Related Projects
50
- - [agenda-ts](https://github.com/meabed/agenda-ts) - Modern MongoDB-powered job scheduler for Node.js
51
- - [nestjs-agenda-ts](https://github.com/meabed/nestjs-agenda-ts) - official NestJS module for Agenda-TS.
50
+ > This package is forked version from [pulse](https://github.com/pulsecron/pulse/)
51
+ >
52
+ > It has been updated, fixed few bugs, actively adding features and updated dependencies and codebase to the latest packages
52
53
 
53
54
  ---
54
55
 
@@ -56,9 +57,9 @@ Agenda-TS is a modern TypeScript fork of the [Agenda](https://github.com/agenda/
56
57
  <br/>
57
58
 
58
59
 
59
- ## Unique Features in Agenda-TS
60
+ ## Unique Features in Agenda
60
61
 
61
- - **Latest MongoDB Driver Support**: Agenda-TS is fully compatible with the latest MongoDB driver, ensuring users can take advantage of the most current database features and enhancements.
62
+ - **Latest MongoDB Driver Support**: Agenda is fully compatible with the latest MongoDB driver, ensuring users can take advantage of the most current database features and enhancements.
62
63
  - **Resume Incomplete Tasks After System Restart**: When the system restarts, Agenda-TS resumes incomplete tasks that were in progress or queued for execution, providing seamless continuation without manual intervention.
63
64
  - **Retry Failed Tasks**: Agenda-TS offers retry mechanisms using exponential and fixed backoff strategies with configurable attempts, ensuring efficient retries of failed tasks without overwhelming the system.
64
65
  - **Continuous Maintenance**: As an open-source project actively maintained, Agenda-TS is consistently improved, providing users with reliable updates and support.
@@ -71,7 +72,7 @@ Agenda-TS is a modern TypeScript fork of the [Agenda](https://github.com/agenda/
71
72
  ## Repository Structure
72
73
 
73
74
  ```sh
74
- └── agenda-ts/
75
+ └── agenda/
75
76
  ├── LICENSE
76
77
  ├── README.md
77
78
  ├── es.js
@@ -83,7 +84,7 @@ Agenda-TS is a modern TypeScript fork of the [Agenda](https://github.com/agenda/
83
84
  │ ├── cjs.ts
84
85
  │ ├── index.ts
85
86
  │ ├── job
86
- │ ├── pulse
87
+ │ ├── agenda
87
88
  │ └── utils
88
89
  ├── tsconfig.eslint.json
89
90
  └── tsconfig.json
@@ -95,40 +96,40 @@ Agenda-TS is a modern TypeScript fork of the [Agenda](https://github.com/agenda/
95
96
 
96
97
  ## Modules
97
98
 
98
- <details closed><summary>src.pulse</summary>
99
+ <details closed><summary>src.agenda</summary>
99
100
 
100
101
  | File | Summary |
101
102
  | --- | --- |
102
- | [has-mongo-protocol.ts](https://github.com/meabed/agenda-ts/blob/master/src/pulse/has-mongo-protocol.ts) | HasMongoProtocol establishes a function that evaluates if a given URL string contains a valid MongoDB connection protocol, contributing to the repositorys ability to handle and verify database connections. |
103
- | [default-concurrency.ts](https://github.com/meabed/agenda-ts/blob/master/src/pulse/default-concurrency.ts) | Sets the default concurrency for each job within the Agendta-TS open-source project by modifying the internal state. It contributes to the task scheduling and management functionalities in the project. |
104
- | [name.ts](https://github.com/meabed/agenda-ts/blob/master/src/pulse/name.ts) | Sets the name of a queue within the Agendta object in the parent repositorys architecture. It utilizes debugging for traceability and maintains the flow architecture by returning the Agendta instance after the name assignment. |
105
- | [drain.ts](https://github.com/meabed/agenda-ts/blob/master/src/pulse/drain.ts) | Drain.ts serves a crucial role in the Agendta module, enabling the cancellation of ongoing job processes. It ensures that all running jobs get completed before terminating the processing interval, promoting an efficient and orderly execution flow in the application. |
106
- | [enable.ts](https://github.com/meabed/agenda-ts/blob/master/src/pulse/enable.ts) | Enables specific jobs within the Agendta module by toggling the disabled flag to false. Utilizes MongoDB queries to precisely select matching jobs, aspiring to enhance the flexibility and robustness of job execution. Returns the count of jobs successfully enabled, aiding in operational tracking. |
107
- | [schedule.ts](https://github.com/meabed/agenda-ts/blob/master/src/pulse/schedule.ts) | Schedule.ts within the Agenda directory facilitates job scheduling for specific timings. Through this module, users can assign an array of job names to be executed at a specified time, along with associated data. Multiple jobs can be created at once, enhancing the efficiency of task management in the repository. |
108
- | [default-lock-lifetime.ts](https://github.com/meabed/agenda-ts/blob/master/src/pulse/default-lock-lifetime.ts) | Establishes the default lock lifetime in an Agendta application. It allows setting the default lock time in milliseconds, providing flexibility in managing task execution timelines. This is a critical feature for handling concurrency control in Agendta's job processing system. |
109
- | [db-init.ts](https://github.com/meabed/agenda-ts/blob/master/src/pulse/db-init.ts) | Establishes and initializes the database collection for job management in the Agendta-TS open-source project. It also includes optional index creation functionality, providing efficient job searching within the database. Notifiers for success or errors make the process transparent and manageable. |
110
- | [process-every.ts](https://github.com/meabed/agenda-ts/blob/master/src/pulse/process-every.ts) | ProcessEvery sets a default interval for an Agendta objects processing time. It leverages human-readable time intervals to determine the frequency of certain operations within the agenda directory of the repository. This function returns the updated Agendta object. |
111
- | [disable.ts](https://github.com/meabed/agenda-ts/blob/master/src/pulse/disable.ts) | Disables selected jobs in the Agendta application by applying a MongoDB filter query. The function returns the number of successfully disabled job instances, providing enhanced control over task execution. |
112
- | [jobs.ts](https://github.com/meabed/agenda-ts/blob/master/src/pulse/jobs.ts) | Within the Agendta-TS repository, the jobs.ts script from the src/pulse directory performs a crucial task. It retrieves all jobs matching a certain query from a MongoDB collection, with options for sorting, limiting and skipping results, transforming these into job objects before returning. |
113
- | [start.ts](https://github.com/meabed/agenda-ts/blob/master/src/pulse/start.ts) | Start.ts initializes job processing for the Agendta module. It validates system readiness before periodically processing tasks using the processJobs method from the utils directory. The method ensures job execution regularity and guarantees uninterrupted operation, provided a database is set beforehand. |
114
- | [every.ts](https://github.com/meabed/agenda-ts/blob/master/src/pulse/every.ts) | Within the agendta directory, every.ts establishes a regular job execution framework. It enables job scheduling at specified intervals, handling singular and multiple job names. Pertinent debugging information for scheduled job processes is also provided by this module. |
115
- | [max-concurrency.ts](https://github.com/meabed/agenda-ts/blob/master/src/pulse/max-concurrency.ts) | MaxConcurrency controls job execution in the Agendta system by globally setting the maximum concurrency value, thereby optimizing task management. It directly interacts with the core Agendta framework, ensuring that job execution does not exceed the defined threshold, enhancing overall process efficiency. |
116
- | [purge.ts](https://github.com/meabed/agenda-ts/blob/master/src/pulse/purge.ts) | Purge.ts, within the agenda subdirectory, provides functionality to remove all jobs from the queue in the Agenda application. It exports an asynchronous function that cancels undefined jobs, ensuring only defined jobs remain. The function's outcome is confirmed with success or failure notifications. |
117
- | [now.ts](https://github.com/meabed/agenda-ts/blob/master/src/pulse/now.ts) | Establishes a function within the Agenda module, designed to create a job task instantly. This function, named now, accepts job details, schedules it for the current time, saves the job into the system, and handles potential creation errors. |
118
- | [default-lock-limit.ts](https://github.com/meabed/agenda-ts/blob/master/src/pulse/default-lock-limit.ts) | Defines the maximum number of locks per job type in the Agenda system. It establishes a default limit, with each instance adjustable per user needs. The limit optimizes concurrent task handling, enhancing overall application performance. |
119
- | [stop.ts](https://github.com/meabed/agenda-ts/blob/master/src/pulse/stop.ts) | Stop.ts within the Agenda sub-directory is responsible for terminating the process of job execution. It achieves this by unlocking jobs that were locked for processing, allowing them to be re-run or accessed, and by clearing the job execution interval, effectively stopping further job processing. |
120
- | [database.ts](https://github.com/meabed/agenda-ts/blob/master/src/pulse/database.ts) | Database.ts, located in the src/pulse directory, establishes a connection to a specified MongoDB server. It features the flexibility to use an existing MongoDB connection, customize collection names, and handle connection errors. Ultimately, this file integrates MongoDB into the broader Agenda architecture. |
121
- | [sort.ts](https://github.com/meabed/agenda-ts/blob/master/src/pulse/sort.ts) | Sort.ts orchestrates the sorting functionality within the Agenda component, allowing users to customize their queries for job searches. It primarily manages the rules for prioritizing and scheduling jobs, with the default being jobs sorted by their next run time and priority. |
122
- | [mongo.ts](https://github.com/meabed/agenda-ts/blob/master/src/pulse/mongo.ts) | Mongo.ts integrates MongoDB with the Agenda application, enabling the establishment of database connections. It provides a method to inject MongoClient instance, specify the collection, and handle database initialization errors through callbacks. |
123
- | [cancel.ts](https://github.com/meabed/agenda-ts/blob/master/src/pulse/cancel.ts) | Cancel.ts facilitates the termination of specific Agenda jobs based on a provided MongoDB query, effectively removing them from the database. These cancellations can be initiated by the client code, the Agenda.purge() function, or the Job.remove() function. |
124
- | [index.ts](https://github.com/meabed/agenda-ts/blob/master/src/pulse/index.ts) | Agenda, the heart of the repository, manages a queue of jobs in a MongoDB collection. This task scheduling system facilitates job creation, scheduling, locking, and execution, handling concurrency defaults, lock limits, and durations. Moreover, it supports optional configuration and customization parameters. |
125
- | [define.ts](https://github.com/meabed/agenda-ts/blob/master/src/pulse/define.ts) | Defines job parameters and execution procedures in the Agenda library. Users can configure concurrency, locking, priority, lifetime, and result persistence for a named job. Job definitions are stored and debugged for future execution within the Agendta system. |
126
- | [create.ts](https://github.com/meabed/agenda-ts/blob/master/src/pulse/create.ts) | Creates new jobs within the Agendta module of the repository. This piece of code initializes these jobs with given names and data, also setting specific attributes such as priority and whether to save results based on predefined definitions. |
127
- | [find-and-lock-next-job.ts](https://github.com/meabed/agenda-ts/blob/master/src/pulse/find-and-lock-next-job.ts) | Unlocks and processes queued jobs within the Agenda-TS repository. In the find-and-lock-next-job file, the function identifies a specific job based on its name, locks it for execution, and returns the job status. This operation ensures efficient management of tasks within the system. |
128
- | [job-processing-queue.ts](https://github.com/meabed/agenda-ts/blob/master/src/pulse/job-processing-queue.ts) | JobProcessingQueue, as part of the larger Agenda-TS repository, manages job processing through an internal queue. It offers capabilities like job insertion in a specific order, popping jobs without concurrency checks, and identifying the next job eligible for processing whose execution isnt blocked by concurrency. |
129
- | [lock-limit.ts](https://github.com/meabed/agenda-ts/blob/master/src/pulse/lock-limit.ts) | LockLimit sets a global upper limit on the number of jobs that can be simultaneously locked within the Agenda system, ensuring efficient task execution without resource overstretching. Its essential for maintaining concurrency control in the broader repository architecture. |
130
- | [close.ts](https://github.com/meabed/agenda-ts/blob/master/src/pulse/close.ts) | Agenda/close.ts secures the main functionality of closing database connections within the Agenda-TS project. It incorporates a provision for forcefully closing connections and handles exceptions that might arise during this process. The feature is specifically adapted for MongoDB databases that havent been preconfigured. |
131
- | [save-job.ts](https://github.com/meabed/agenda-ts/blob/master/src/pulse/save-job.ts) | <code>► INSERT-TEXT-HERE</code> |
103
+ | [has-mongo-protocol.ts](https://github.com/meabed/agenda-ts/blob/master/src/agenda/has-mongo-protocol.ts) | HasMongoProtocol establishes a function that evaluates if a given URL string contains a valid MongoDB connection protocol, contributing to the repositorys ability to handle and verify database connections. |
104
+ | [default-concurrency.ts](https://github.com/meabed/agenda-ts/blob/master/src/agenda/default-concurrency.ts) | Sets the default concurrency for each job within the Agendta-TS open-source project by modifying the internal state. It contributes to the task scheduling and management functionalities in the project. |
105
+ | [name.ts](https://github.com/meabed/agenda-ts/blob/master/src/agenda/name.ts) | Sets the name of a queue within the Agendta object in the parent repositorys architecture. It utilizes debugging for traceability and maintains the flow architecture by returning the Agendta instance after the name assignment. |
106
+ | [drain.ts](https://github.com/meabed/agenda-ts/blob/master/src/agenda/drain.ts) | Drain.ts serves a crucial role in the Agendta module, enabling the cancellation of ongoing job processes. It ensures that all running jobs get completed before terminating the processing interval, promoting an efficient and orderly execution flow in the application. |
107
+ | [enable.ts](https://github.com/meabed/agenda-ts/blob/master/src/agenda/enable.ts) | Enables specific jobs within the Agendta module by toggling the disabled flag to false. Utilizes MongoDB queries to precisely select matching jobs, aspiring to enhance the flexibility and robustness of job execution. Returns the count of jobs successfully enabled, aiding in operational tracking. |
108
+ | [schedule.ts](https://github.com/meabed/agenda-ts/blob/master/src/agenda/schedule.ts) | Schedule.ts within the Agenda directory facilitates job scheduling for specific timings. Through this module, users can assign an array of job names to be executed at a specified time, along with associated data. Multiple jobs can be created at once, enhancing the efficiency of task management in the repository. |
109
+ | [default-lock-lifetime.ts](https://github.com/meabed/agenda-ts/blob/master/src/agenda/default-lock-lifetime.ts) | Establishes the default lock lifetime in an Agendta application. It allows setting the default lock time in milliseconds, providing flexibility in managing task execution timelines. This is a critical feature for handling concurrency control in Agendta's job processing system. |
110
+ | [db-init.ts](https://github.com/meabed/agenda-ts/blob/master/src/agenda/db-init.ts) | Establishes and initializes the database collection for job management in the Agendta-TS open-source project. It also includes optional index creation functionality, providing efficient job searching within the database. Notifiers for success or errors make the process transparent and manageable. |
111
+ | [process-every.ts](https://github.com/meabed/agenda-ts/blob/master/src/agenda/process-every.ts) | ProcessEvery sets a default interval for an Agendta objects processing time. It leverages human-readable time intervals to determine the frequency of certain operations within the agenda directory of the repository. This function returns the updated Agendta object. |
112
+ | [disable.ts](https://github.com/meabed/agenda-ts/blob/master/src/agenda/disable.ts) | Disables selected jobs in the Agendta application by applying a MongoDB filter query. The function returns the number of successfully disabled job instances, providing enhanced control over task execution. |
113
+ | [jobs.ts](https://github.com/meabed/agenda-ts/blob/master/src/agenda/jobs.ts) | Within the Agendta-TS repository, the jobs.ts script from the src/agenda directory performs a crucial task. It retrieves all jobs matching a certain query from a MongoDB collection, with options for sorting, limiting and skipping results, transforming these into job objects before returning. |
114
+ | [start.ts](https://github.com/meabed/agenda-ts/blob/master/src/agenda/start.ts) | Start.ts initializes job processing for the Agendta module. It validates system readiness before periodically processing tasks using the processJobs method from the utils directory. The method ensures job execution regularity and guarantees uninterrupted operation, provided a database is set beforehand. |
115
+ | [every.ts](https://github.com/meabed/agenda-ts/blob/master/src/agenda/every.ts) | Within the agendta directory, every.ts establishes a regular job execution framework. It enables job scheduling at specified intervals, handling singular and multiple job names. Pertinent debugging information for scheduled job processes is also provided by this module. |
116
+ | [max-concurrency.ts](https://github.com/meabed/agenda-ts/blob/master/src/agenda/max-concurrency.ts) | MaxConcurrency controls job execution in the Agendta system by globally setting the maximum concurrency value, thereby optimizing task management. It directly interacts with the core Agendta framework, ensuring that job execution does not exceed the defined threshold, enhancing overall process efficiency. |
117
+ | [purge.ts](https://github.com/meabed/agenda-ts/blob/master/src/agenda/purge.ts) | Purge.ts, within the agenda subdirectory, provides functionality to remove all jobs from the queue in the Agenda application. It exports an asynchronous function that cancels undefined jobs, ensuring only defined jobs remain. The function's outcome is confirmed with success or failure notifications. |
118
+ | [now.ts](https://github.com/meabed/agenda-ts/blob/master/src/agenda/now.ts) | Establishes a function within the Agenda module, designed to create a job task instantly. This function, named now, accepts job details, schedules it for the current time, saves the job into the system, and handles potential creation errors. |
119
+ | [default-lock-limit.ts](https://github.com/meabed/agenda-ts/blob/master/src/agenda/default-lock-limit.ts) | Defines the maximum number of locks per job type in the Agenda system. It establishes a default limit, with each instance adjustable per user needs. The limit optimizes concurrent task handling, enhancing overall application performance. |
120
+ | [stop.ts](https://github.com/meabed/agenda-ts/blob/master/src/agenda/stop.ts) | Stop.ts within the Agenda sub-directory is responsible for terminating the process of job execution. It achieves this by unlocking jobs that were locked for processing, allowing them to be re-run or accessed, and by clearing the job execution interval, effectively stopping further job processing. |
121
+ | [database.ts](https://github.com/meabed/agenda-ts/blob/master/src/agenda/database.ts) | Database.ts, located in the src/agenda directory, establishes a connection to a specified MongoDB server. It features the flexibility to use an existing MongoDB connection, customize collection names, and handle connection errors. Ultimately, this file integrates MongoDB into the broader Agenda architecture. |
122
+ | [sort.ts](https://github.com/meabed/agenda-ts/blob/master/src/agenda/sort.ts) | Sort.ts orchestrates the sorting functionality within the Agenda component, allowing users to customize their queries for job searches. It primarily manages the rules for prioritizing and scheduling jobs, with the default being jobs sorted by their next run time and priority. |
123
+ | [mongo.ts](https://github.com/meabed/agenda-ts/blob/master/src/agenda/mongo.ts) | Mongo.ts integrates MongoDB with the Agenda application, enabling the establishment of database connections. It provides a method to inject MongoClient instance, specify the collection, and handle database initialization errors through callbacks. |
124
+ | [cancel.ts](https://github.com/meabed/agenda-ts/blob/master/src/agenda/cancel.ts) | Cancel.ts facilitates the termination of specific Agenda jobs based on a provided MongoDB query, effectively removing them from the database. These cancellations can be initiated by the client code, the Agenda.purge() function, or the Job.remove() function. |
125
+ | [index.ts](https://github.com/meabed/agenda-ts/blob/master/src/agenda/index.ts) | Agenda, the heart of the repository, manages a queue of jobs in a MongoDB collection. This task scheduling system facilitates job creation, scheduling, locking, and execution, handling concurrency defaults, lock limits, and durations. Moreover, it supports optional configuration and customization parameters. |
126
+ | [define.ts](https://github.com/meabed/agenda-ts/blob/master/src/agenda/define.ts) | Defines job parameters and execution procedures in the Agenda library. Users can configure concurrency, locking, priority, lifetime, and result persistence for a named job. Job definitions are stored and debugged for future execution within the Agendta system. |
127
+ | [create.ts](https://github.com/meabed/agenda-ts/blob/master/src/agenda/create.ts) | Creates new jobs within the Agendta module of the repository. This piece of code initializes these jobs with given names and data, also setting specific attributes such as priority and whether to save results based on predefined definitions. |
128
+ | [find-and-lock-next-job.ts](https://github.com/meabed/agenda-ts/blob/master/src/agenda/find-and-lock-next-job.ts) | Unlocks and processes queued jobs within the Agenda-TS repository. In the find-and-lock-next-job file, the function identifies a specific job based on its name, locks it for execution, and returns the job status. This operation ensures efficient management of tasks within the system. |
129
+ | [job-processing-queue.ts](https://github.com/meabed/agenda-ts/blob/master/src/agenda/job-processing-queue.ts) | JobProcessingQueue, as part of the larger Agenda-TS repository, manages job processing through an internal queue. It offers capabilities like job insertion in a specific order, popping jobs without concurrency checks, and identifying the next job eligible for processing whose execution isnt blocked by concurrency. |
130
+ | [lock-limit.ts](https://github.com/meabed/agenda-ts/blob/master/src/agenda/lock-limit.ts) | LockLimit sets a global upper limit on the number of jobs that can be simultaneously locked within the Agenda system, ensuring efficient task execution without resource overstretching. Its essential for maintaining concurrency control in the broader repository architecture. |
131
+ | [close.ts](https://github.com/meabed/agenda-ts/blob/master/src/agenda/close.ts) | Agenda/close.ts secures the main functionality of closing database connections within the Agenda-TS project. It incorporates a provision for forcefully closing connections and handles exceptions that might arise during this process. The feature is specifically adapted for MongoDB databases that havent been preconfigured. |
132
+ | [save-job.ts](https://github.com/meabed/agenda-ts/blob/master/src/agenda/save-job.ts) | <code>► INSERT-TEXT-HERE</code> |
132
133
 
133
134
  </details>
134
135
 
@@ -230,7 +231,7 @@ agenda.define('delete old users', async (job) => {
230
231
  /**
231
232
  * Example of defining a job with options
232
233
  */
233
- pulse.define(
234
+ agenda.define(
234
235
  'send email report',
235
236
  async (job) => {
236
237
  const { to } = job.attrs.data;
@@ -286,7 +287,7 @@ function time() {
286
287
 
287
288
  - [X] **Add Support for Latest Mongoose Version(8.x.x)**: Upgrade Agenda-TS to be fully compatible with the latest version of Mongoose. This will enable Agenda-TS to leverage the newest features and improvements in Mongoose, ensuring better performance, stability, and security for applications that rely on MongoDB through Mongoose.
288
289
  - [X] **Refactoring to Modern TypeScript Syntax**: Undertake a comprehensive refactor of the codebase to utilize modern TypeScript features and syntax. This refactoring will improve code readability, maintainability, and make it easier for new contributors to understand and contribute to the project.
289
- - [X] **Resolving Issues in Existing Agenda Projects**: Actively address and resolve outstanding issues within the original Agenda project. This initiative not only aids the community by improving the legacy codebase but also informs the development of Pulse by identifying and addressing past challenges.
290
+ - [X] **Resolving Issues in Existing Agenda Projects**: Actively address and resolve outstanding issues within the original Agenda project. This initiative not only aids the community by improving the legacy codebase but also informs the development of Agenda by identifying and addressing past challenges.
290
291
  - [ ] **Rewrite Test Code**: Revamp our testing suite to increase coverage and ensure tests are up-to-date with modern testing practices. This rewrite aims to enhance test reliability and efficiency, facilitating smoother development and deployment cycles.
291
292
  - [X] **Rewrite Documentation**: Completely revise and update the documentation to reflect all new changes and features, ensure clarity of information, and improve navigation and readability for developers. This effort will include new getting started guides, API documentation, and use case examples to facilitate easier adoption and implementation by users.
292
293
  ---
@@ -343,11 +344,3 @@ Contributions are welcome! Here are several ways you can contribute:
343
344
  ## License
344
345
 
345
346
  This project is protected under the [MIT](https://github.com/meabed/agenda-ts?tab=MIT-1-ov-file#readme) License. For more details, refer to the [LICENSE](https://github.com/meabed/agenda-ts?tab=MIT-1-ov-file#readme) file.
346
-
347
- ---
348
- <br/>
349
- <br/>
350
-
351
-
352
- ## Acknowledgments
353
- - Agenda-TS is maintained by [Mohamed Meabed](https://github.com/meabed) and was forked from the [Agenda](https://github.com/agenda/agenda) project.
@@ -0,0 +1,3 @@
1
+ import { Document, Filter } from 'mongodb';
2
+ export type CancelMethod = (query: Filter<Document>) => Promise<number | undefined>;
3
+ export declare const cancel: CancelMethod;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cancel = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const debug_1 = tslib_1.__importDefault(require("debug"));
6
+ const debug = (0, debug_1.default)('agenda:cancel');
7
+ const cancel = async function (query) {
8
+ debug('attempting to cancel all Agenda jobs', query);
9
+ try {
10
+ const { deletedCount } = await this._collection.deleteMany(query);
11
+ this.emit('cancel', deletedCount);
12
+ debug('%s jobs cancelled', deletedCount);
13
+ return deletedCount;
14
+ }
15
+ catch (error) {
16
+ debug('error trying to delete jobs from MongoDB');
17
+ throw error;
18
+ }
19
+ };
20
+ exports.cancel = cancel;
21
+ //# sourceMappingURL=cancel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cancel.js","sourceRoot":"","sources":["../../src/agenda/cancel.ts"],"names":[],"mappings":";;;;AAAA,0DAAmC;AAInC,MAAM,KAAK,GAAG,IAAA,eAAc,EAAC,eAAe,CAAC,CAAC;AAWvC,MAAM,MAAM,GAAiB,KAAK,WAAyB,KAAK;IACrE,KAAK,CAAC,sCAAsC,EAAE,KAAK,CAAC,CAAC;IACrD,IAAI,CAAC;QACH,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAClE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAElC,KAAK,CAAC,mBAAmB,EAAE,YAAY,CAAC,CAAC;QACzC,OAAO,YAAY,CAAC;IACtB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAClD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC;AAZW,QAAA,MAAM,UAYjB"}
@@ -0,0 +1,5 @@
1
+ import { Agenda } from '.';
2
+ export type CloseMethod = (option?: {
3
+ force: boolean;
4
+ }) => Promise<Agenda>;
5
+ export declare const close: CloseMethod;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.close = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const debug_1 = tslib_1.__importDefault(require("debug"));
6
+ const debug = (0, debug_1.default)('agenda:close');
7
+ const close = async function (option) {
8
+ debug('close db connection for this agenda instance');
9
+ const closeOptions = {
10
+ force: false,
11
+ ...option,
12
+ };
13
+ try {
14
+ if (this._db) {
15
+ await this._db.close(closeOptions.force);
16
+ }
17
+ return this;
18
+ }
19
+ catch (error) {
20
+ debug('error trying to close db connection to');
21
+ throw error;
22
+ }
23
+ };
24
+ exports.close = close;
25
+ //# sourceMappingURL=close.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"close.js","sourceRoot":"","sources":["../../src/agenda/close.ts"],"names":[],"mappings":";;;;AAAA,0DAAmC;AAGnC,MAAM,KAAK,GAAG,IAAA,eAAc,EAAC,cAAc,CAAC,CAAC;AAgBtC,MAAM,KAAK,GAAgB,KAAK,WAAyB,MAAO;IACrE,KAAK,CAAC,8CAA8C,CAAC,CAAC;IACtD,MAAM,YAAY,GAAG;QACnB,KAAK,EAAE,KAAK;QACZ,GAAG,MAAM;KACV,CAAC;IACF,IAAI,CAAC;QACH,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;YACb,MAAM,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QAC3C,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,KAAK,CAAC,wCAAwC,CAAC,CAAC;QAChD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC;AAhBW,QAAA,KAAK,SAgBhB"}
@@ -0,0 +1,5 @@
1
+ import { CountDocumentsOptions, Filter } from 'mongodb';
2
+ import { Agenda } from '.';
3
+ export declare const countJobsRepo: (this: Agenda, query?: {}, options?: {}) => Promise<number>;
4
+ export type CountJobsMethod = (query?: Filter<any>, options?: CountDocumentsOptions | undefined) => Promise<number>;
5
+ export declare const countJobs: (this: Agenda, query?: {}, options?: {}) => Promise<number>;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.countJobs = exports.countJobsRepo = void 0;
4
+ const countJobsRepo = async function (query = {}, options = {}) {
5
+ return await this._collection.countDocuments(query, options);
6
+ };
7
+ exports.countJobsRepo = countJobsRepo;
8
+ const countJobs = async function (query = {}, options = {}) {
9
+ return await this._collection.countDocuments(query, options);
10
+ };
11
+ exports.countJobs = countJobs;
12
+ //# sourceMappingURL=count-jobs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"count-jobs.js","sourceRoot":"","sources":["../../src/agenda/count-jobs.ts"],"names":[],"mappings":";;;AAGO,MAAM,aAAa,GAAG,KAAK,WAAyB,KAAK,GAAG,EAAE,EAAE,OAAO,GAAG,EAAE;IACjF,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AAC/D,CAAC,CAAC;AAFW,QAAA,aAAa,iBAExB;AAWK,MAAM,SAAS,GAAG,KAAK,WAAyB,KAAK,GAAG,EAAE,EAAE,OAAO,GAAG,EAAE;IAC7E,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AAC/D,CAAC,CAAC;AAFW,QAAA,SAAS,aAEpB"}
@@ -0,0 +1,3 @@
1
+ import { Job, JobAttributesData } from '../job';
2
+ export type CreateMethod = <T extends JobAttributesData>(name: string, data: T) => Job<T>;
3
+ export declare const create: CreateMethod;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.create = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const debug_1 = tslib_1.__importDefault(require("debug"));
6
+ const job_1 = require("../job");
7
+ const debug = (0, debug_1.default)('agenda:create');
8
+ const create = function (name, data) {
9
+ debug('Agenda.create(%s, [Object])', name);
10
+ const priority = this._definitions[name] ? this._definitions[name].priority : 0;
11
+ const shouldSaveResult = this._definitions[name] ? this._definitions[name].shouldSaveResult || false : false;
12
+ const attempts = this._definitions[name] ? this._definitions[name].attempts || 0 : 0;
13
+ const backoff = attempts
14
+ ? this._definitions[name]
15
+ ? this._definitions[name].backoff || { type: 'exponential', delay: 1000 }
16
+ : { type: 'exponential', delay: 1000 }
17
+ : undefined;
18
+ const job = new job_1.Job({
19
+ name,
20
+ data,
21
+ type: 'normal',
22
+ priority,
23
+ shouldSaveResult,
24
+ attempts,
25
+ backoff,
26
+ agenda: this,
27
+ });
28
+ return job;
29
+ };
30
+ exports.create = create;
31
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/agenda/create.ts"],"names":[],"mappings":";;;;AAAA,0DAAmC;AAEnC,gCAAgD;AAEhD,MAAM,KAAK,GAAG,IAAA,eAAc,EAAC,eAAe,CAAC,CAAC;AAUvC,MAAM,MAAM,GAAiB,UAAwB,IAAI,EAAE,IAAI;IACpE,KAAK,CAAC,6BAA6B,EAAE,IAAI,CAAC,CAAC;IAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAChF,MAAM,gBAAgB,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,gBAAgB,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;IAC7G,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACrF,MAAM,OAAO,GAAG,QAAQ;QACtB,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC;YACvB,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,OAAO,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,IAAI,EAAE;YACzE,CAAC,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,IAAI,EAAE;QACxC,CAAC,CAAC,SAAS,CAAC;IAEd,MAAM,GAAG,GAAG,IAAI,SAAG,CAAC;QAClB,IAAI;QACJ,IAAI;QACJ,IAAI,EAAE,QAAQ;QACd,QAAQ;QACR,gBAAgB;QAChB,QAAQ;QACR,OAAO;QACP,MAAM,EAAE,IAAI;KACb,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAvBW,QAAA,MAAM,UAuBjB"}
@@ -0,0 +1,4 @@
1
+ import { AnyError, Collection, MongoClientOptions } from 'mongodb';
2
+ import { Agenda } from '.';
3
+ export type DatabaseMethod = (this: Agenda, url: string, collection?: string, options?: MongoClientOptions, cb?: (error: AnyError | undefined, collection: Collection<any> | null) => void) => Promise<Agenda | void>;
4
+ export declare const database: DatabaseMethod;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.database = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const debug_1 = tslib_1.__importDefault(require("debug"));
6
+ const mongodb_1 = require("mongodb");
7
+ const utils_1 = require("../utils");
8
+ const has_mongo_protocol_1 = require("./has-mongo-protocol");
9
+ const debug = (0, debug_1.default)('agenda:database');
10
+ const database = async function (url, collection, options = {}, cb) {
11
+ if (!(0, has_mongo_protocol_1.hasMongoProtocol)(url)) {
12
+ url = 'mongodb://' + url;
13
+ }
14
+ collection = collection || 'agendaJobs';
15
+ const client = await mongodb_1.MongoClient.connect(url, options).catch((error) => {
16
+ debug('error connecting to MongoDB using collection: [%s]', collection);
17
+ if (cb) {
18
+ cb(error, null);
19
+ }
20
+ else {
21
+ throw new utils_1.BaseError(error);
22
+ }
23
+ });
24
+ if (!client) {
25
+ throw new utils_1.BaseError('Mongo Client is undefined');
26
+ }
27
+ this._db = client;
28
+ this._mdb = client.db();
29
+ this.dbInit(collection, cb);
30
+ return this;
31
+ };
32
+ exports.database = database;
33
+ //# sourceMappingURL=database.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"database.js","sourceRoot":"","sources":["../../src/agenda/database.ts"],"names":[],"mappings":";;;;AAAA,0DAAmC;AACnC,qCAAgF;AAEhF,oCAAqC;AACrC,6DAAwD;AAExD,MAAM,KAAK,GAAG,IAAA,eAAc,EAAC,iBAAiB,CAAC,CAAC;AA0BzC,MAAM,QAAQ,GAAmB,KAAK,WAAyB,GAAG,EAAE,UAAW,EAAE,OAAO,GAAG,EAAE,EAAE,EAAG;IACvG,IAAI,CAAC,IAAA,qCAAgB,EAAC,GAAG,CAAC,EAAE,CAAC;QAC3B,GAAG,GAAG,YAAY,GAAG,GAAG,CAAC;IAC3B,CAAC;IAED,UAAU,GAAG,UAAU,IAAI,YAAY,CAAC;IAExC,MAAM,MAAM,GAAG,MAAM,qBAAW,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QACrE,KAAK,CAAC,oDAAoD,EAAE,UAAU,CAAC,CAAC;QACxE,IAAI,EAAE,EAAE,CAAC;YACP,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAClB,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,iBAAS,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,iBAAS,CAAC,2BAA2B,CAAC,CAAC;IACnD,CAAC;IAED,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC;IAClB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,EAAE,EAAE,CAAC;IACxB,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAC5B,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAxBW,QAAA,QAAQ,YAwBnB"}
@@ -0,0 +1,3 @@
1
+ import { AnyError, Collection } from 'mongodb';
2
+ export type DbInitMethod = (collection?: string, cb?: (error: AnyError | undefined, collection: Collection<any> | null) => void) => void;
3
+ export declare const dbInit: DbInitMethod;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dbInit = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const debug_1 = tslib_1.__importDefault(require("debug"));
6
+ const debug = (0, debug_1.default)('agenda:db_init');
7
+ const dbInit = function (collection = 'agendaJobs', cb) {
8
+ debug('init database collection using name [%s]', collection);
9
+ this._collection = this._mdb.collection(collection);
10
+ if (this._resumeOnRestart) {
11
+ this.resumeOnRestart(this._resumeOnRestart);
12
+ }
13
+ if (this._disableAutoIndex) {
14
+ debug('skipping auto index creation');
15
+ this.emit('ready');
16
+ return;
17
+ }
18
+ debug('attempting index creation');
19
+ this._collection
20
+ .createIndex(this._indices, { name: 'findAndLockNextJobIndex' })
21
+ .then(() => {
22
+ debug('index creation success');
23
+ this.emit('ready');
24
+ })
25
+ .catch((error) => {
26
+ debug('index creation failed');
27
+ this.emit('error', error);
28
+ if (cb) {
29
+ cb(error, this._collection);
30
+ }
31
+ });
32
+ };
33
+ exports.dbInit = dbInit;
34
+ //# sourceMappingURL=db-init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"db-init.js","sourceRoot":"","sources":["../../src/agenda/db-init.ts"],"names":[],"mappings":";;;;AAAA,0DAAmC;AAInC,MAAM,KAAK,GAAG,IAAA,eAAc,EAAC,gBAAgB,CAAC,CAAC;AAcxC,MAAM,MAAM,GAAiB,UAAwB,UAAU,GAAG,YAAY,EAAE,EAAG;IACxF,KAAK,CAAC,0CAA0C,EAAE,UAAU,CAAC,CAAC;IAC9D,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAEpD,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC1B,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAC9C,CAAC;IAED,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC3B,KAAK,CAAC,8BAA8B,CAAC,CAAC;QACtC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnB,OAAO;IACT,CAAC;IAED,KAAK,CAAC,2BAA2B,CAAC,CAAC;IACnC,IAAI,CAAC,WAAW;SACb,WAAW,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,yBAAyB,EAAE,CAAC;SAC/D,IAAI,CAAC,GAAG,EAAE;QACT,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAChC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QACf,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAC/B,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC1B,IAAI,EAAE,EAAE,CAAC;YACP,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AA5BW,QAAA,MAAM,UA4BjB"}
@@ -0,0 +1,3 @@
1
+ import { Agenda } from '.';
2
+ export type DefaultConcurrencyMethod = (concurrency: number) => Agenda;
3
+ export declare const defaultConcurrency: DefaultConcurrencyMethod;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultConcurrency = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const debug_1 = tslib_1.__importDefault(require("debug"));
6
+ const debug = (0, debug_1.default)('agenda:defaultConcurrency');
7
+ const defaultConcurrency = function (concurrency) {
8
+ debug('Agenda.defaultConcurrency(%d)', concurrency);
9
+ this._defaultConcurrency = concurrency;
10
+ return this;
11
+ };
12
+ exports.defaultConcurrency = defaultConcurrency;
13
+ //# sourceMappingURL=default-concurrency.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-concurrency.js","sourceRoot":"","sources":["../../src/agenda/default-concurrency.ts"],"names":[],"mappings":";;;;AAAA,0DAAmC;AAGnC,MAAM,KAAK,GAAG,IAAA,eAAc,EAAC,2BAA2B,CAAC,CAAC;AASnD,MAAM,kBAAkB,GAA6B,UAAwB,WAAW;IAC7F,KAAK,CAAC,+BAA+B,EAAE,WAAW,CAAC,CAAC;IACpD,IAAI,CAAC,mBAAmB,GAAG,WAAW,CAAC;IACvC,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAJW,QAAA,kBAAkB,sBAI7B"}
@@ -0,0 +1,3 @@
1
+ import { Agenda } from '.';
2
+ export type DefaultLockLifetimeMethod = (ms: number) => Agenda;
3
+ export declare const defaultLockLifetime: DefaultLockLifetimeMethod;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultLockLifetime = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const debug_1 = tslib_1.__importDefault(require("debug"));
6
+ const debug = (0, debug_1.default)('agenda:defaultLockLifetime');
7
+ const defaultLockLifetime = function (ms) {
8
+ debug('Agenda.defaultLockLifetime(%d)', ms);
9
+ this._defaultLockLifetime = ms;
10
+ return this;
11
+ };
12
+ exports.defaultLockLifetime = defaultLockLifetime;
13
+ //# sourceMappingURL=default-lock-lifetime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-lock-lifetime.js","sourceRoot":"","sources":["../../src/agenda/default-lock-lifetime.ts"],"names":[],"mappings":";;;;AAAA,0DAAmC;AAGnC,MAAM,KAAK,GAAG,IAAA,eAAc,EAAC,4BAA4B,CAAC,CAAC;AAWpD,MAAM,mBAAmB,GAA8B,UAAwB,EAAE;IACtF,KAAK,CAAC,gCAAgC,EAAE,EAAE,CAAC,CAAC;IAC5C,IAAI,CAAC,oBAAoB,GAAG,EAAE,CAAC;IAC/B,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAJW,QAAA,mBAAmB,uBAI9B"}
@@ -0,0 +1,3 @@
1
+ import { Agenda } from '.';
2
+ export type DefaultLockLimitMethod = (times: number) => Agenda;
3
+ export declare const defaultLockLimit: DefaultLockLimitMethod;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultLockLimit = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const debug_1 = tslib_1.__importDefault(require("debug"));
6
+ const debug = (0, debug_1.default)('agenda:defaultLockLimit');
7
+ const defaultLockLimit = function (times) {
8
+ debug('Agenda.defaultLockLimit(%d)', times);
9
+ this._defaultLockLimit = times;
10
+ return this;
11
+ };
12
+ exports.defaultLockLimit = defaultLockLimit;
13
+ //# sourceMappingURL=default-lock-limit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-lock-limit.js","sourceRoot":"","sources":["../../src/agenda/default-lock-limit.ts"],"names":[],"mappings":";;;;AAAA,0DAAmC;AAGnC,MAAM,KAAK,GAAG,IAAA,eAAc,EAAC,yBAAyB,CAAC,CAAC;AAUjD,MAAM,gBAAgB,GAA2B,UAAwB,KAAK;IACnF,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;IAC5C,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC;IAC/B,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAJW,QAAA,gBAAgB,oBAI3B"}
@@ -0,0 +1,23 @@
1
+ import { Job, JobAttributesData } from '../job';
2
+ export declare enum JobPriority {
3
+ highest = 20,
4
+ high = 10,
5
+ normal = 0,
6
+ low = -10,
7
+ lowest = -20
8
+ }
9
+ export interface DefineOptions {
10
+ concurrency?: number;
11
+ lockLimit?: number;
12
+ lockLifetime?: number;
13
+ priority?: keyof typeof JobPriority;
14
+ shouldSaveResult?: boolean;
15
+ attempts?: number;
16
+ backoff?: {
17
+ type: 'exponential' | 'fixed';
18
+ delay: number;
19
+ };
20
+ }
21
+ export type Processor<T extends JobAttributesData> = (job: Job<T>, done: (error?: Error, result?: unknown) => void) => unknown | Promise<unknown>;
22
+ export type DefineMethod = <T extends JobAttributesData>(name: string, processor: Processor<T>, options?: DefineOptions) => void;
23
+ export declare const define: DefineMethod;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.define = exports.JobPriority = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const debug_1 = tslib_1.__importDefault(require("debug"));
6
+ const debug = (0, debug_1.default)('agenda:define');
7
+ var JobPriority;
8
+ (function (JobPriority) {
9
+ JobPriority[JobPriority["highest"] = 20] = "highest";
10
+ JobPriority[JobPriority["high"] = 10] = "high";
11
+ JobPriority[JobPriority["normal"] = 0] = "normal";
12
+ JobPriority[JobPriority["low"] = -10] = "low";
13
+ JobPriority[JobPriority["lowest"] = -20] = "lowest";
14
+ })(JobPriority || (exports.JobPriority = JobPriority = {}));
15
+ const define = function (name, processor, options) {
16
+ this._definitions[name] = {
17
+ fn: processor,
18
+ concurrency: options?.concurrency || this._defaultConcurrency,
19
+ lockLimit: options?.lockLimit || this._defaultLockLimit,
20
+ priority: options?.priority || JobPriority.normal,
21
+ lockLifetime: options?.lockLifetime || this._defaultLockLifetime,
22
+ running: 0,
23
+ locked: 0,
24
+ shouldSaveResult: options?.shouldSaveResult || false,
25
+ attempts: options?.attempts || 0,
26
+ backoff: options?.attempts && {
27
+ type: options?.backoff?.type || 'exponential',
28
+ delay: options?.backoff?.delay || 1000,
29
+ },
30
+ };
31
+ debug('job [%s] defined with following options: \n%O', name, this._definitions[name]);
32
+ };
33
+ exports.define = define;
34
+ //# sourceMappingURL=define.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define.js","sourceRoot":"","sources":["../../src/agenda/define.ts"],"names":[],"mappings":";;;;AAAA,0DAAmC;AAInC,MAAM,KAAK,GAAG,IAAA,eAAc,EAAC,eAAe,CAAC,CAAC;AAE9C,IAAY,WAMX;AAND,WAAY,WAAW;IACrB,oDAAY,CAAA;IACZ,8CAAS,CAAA;IACT,iDAAU,CAAA;IACV,6CAAS,CAAA;IACT,mDAAY,CAAA;AACd,CAAC,EANW,WAAW,2BAAX,WAAW,QAMtB;AA2EM,MAAM,MAAM,GAAiB,UAAwB,IAAI,EAAE,SAAS,EAAE,OAAQ;IACnF,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG;QACxB,EAAE,EAAE,SAAS;QACb,WAAW,EAAE,OAAO,EAAE,WAAW,IAAI,IAAI,CAAC,mBAAmB;QAC7D,SAAS,EAAE,OAAO,EAAE,SAAS,IAAI,IAAI,CAAC,iBAAiB;QACvD,QAAQ,EAAE,OAAO,EAAE,QAAQ,IAAI,WAAW,CAAC,MAAM;QACjD,YAAY,EAAE,OAAO,EAAE,YAAY,IAAI,IAAI,CAAC,oBAAoB;QAChE,OAAO,EAAE,CAAC;QACV,MAAM,EAAE,CAAC;QACT,gBAAgB,EAAE,OAAO,EAAE,gBAAgB,IAAI,KAAK;QACpD,QAAQ,EAAE,OAAO,EAAE,QAAQ,IAAI,CAAC;QAChC,OAAO,EAAE,OAAO,EAAE,QAAQ,IAAI;YAC5B,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,IAAI,aAAa;YAC7C,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,IAAI,IAAI;SACvC;KACF,CAAC;IAEF,KAAK,CAAC,+CAA+C,EAAE,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;AACxF,CAAC,CAAC;AAlBW,QAAA,MAAM,UAkBjB"}
@@ -0,0 +1,3 @@
1
+ import { Filter } from 'mongodb';
2
+ export type DisableMethod = (query?: Filter<unknown>) => Promise<number>;
3
+ export declare const disable: DisableMethod;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.disable = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const debug_1 = tslib_1.__importDefault(require("debug"));
6
+ const debug = (0, debug_1.default)('agenda:disable');
7
+ const disable = async function (query = {}) {
8
+ debug('attempting to disable all jobs matching query', query);
9
+ try {
10
+ const { modifiedCount } = await this._collection.updateMany(query, {
11
+ $set: { disabled: true },
12
+ });
13
+ debug('%s jobs disabled');
14
+ return modifiedCount;
15
+ }
16
+ catch (error) {
17
+ debug('error trying to mark jobs as `disabled`');
18
+ throw error;
19
+ }
20
+ };
21
+ exports.disable = disable;
22
+ //# sourceMappingURL=disable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"disable.js","sourceRoot":"","sources":["../../src/agenda/disable.ts"],"names":[],"mappings":";;;;AAAA,0DAAmC;AAGnC,MAAM,KAAK,GAAG,IAAA,eAAc,EAAC,gBAAgB,CAAC,CAAC;AAUxC,MAAM,OAAO,GAAkB,KAAK,WAAyB,KAAK,GAAG,EAAE;IAC5E,KAAK,CAAC,+CAA+C,EAAE,KAAK,CAAC,CAAC;IAC9D,IAAI,CAAC;QACH,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,KAAK,EAAE;YACjE,IAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;SACzB,CAAC,CAAC;QACH,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAC1B,OAAO,aAAa,CAAC;IACvB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,KAAK,CAAC,yCAAyC,CAAC,CAAC;QACjD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC;AAZW,QAAA,OAAO,WAYlB"}
@@ -0,0 +1,2 @@
1
+ export type DrainMethod = () => Promise<void>;
2
+ export declare const drain: DrainMethod;