agenda 4.4.0 → 5.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.
- package/README.md +20 -8
- package/dist/agenda/create.d.ts +2 -2
- package/dist/agenda/create.d.ts.map +1 -1
- package/dist/agenda/create.js.map +1 -1
- package/dist/agenda/define.d.ts +2 -2
- package/dist/agenda/define.d.ts.map +1 -1
- package/dist/agenda/define.js.map +1 -1
- package/dist/agenda/every.d.ts +2 -1
- package/dist/agenda/every.d.ts.map +1 -1
- package/dist/agenda/every.js +1 -1
- package/dist/agenda/every.js.map +1 -1
- package/dist/agenda/find-and-lock-next-job.d.ts.map +1 -1
- package/dist/agenda/find-and-lock-next-job.js +3 -4
- package/dist/agenda/find-and-lock-next-job.js.map +1 -1
- package/dist/agenda/now.d.ts +2 -2
- package/dist/agenda/now.d.ts.map +1 -1
- package/dist/agenda/now.js.map +1 -1
- package/dist/agenda/schedule.d.ts +3 -3
- package/dist/agenda/schedule.d.ts.map +1 -1
- package/dist/agenda/schedule.js.map +1 -1
- package/dist/job/compute-next-run-at.js +2 -2
- package/dist/job/compute-next-run-at.js.map +1 -1
- package/dist/job/index.d.ts +6 -3
- package/dist/job/index.d.ts.map +1 -1
- package/dist/job/index.js.map +1 -1
- package/lib/agenda/cancel.ts +28 -0
- package/lib/agenda/close.ts +37 -0
- package/lib/agenda/create.ts +22 -0
- package/lib/agenda/database.ts +63 -0
- package/lib/agenda/db-init.ts +45 -0
- package/lib/agenda/default-concurrency.ts +19 -0
- package/lib/agenda/default-lock-lifetime.ts +17 -0
- package/lib/agenda/default-lock-limit.ts +17 -0
- package/lib/agenda/define.ts +85 -0
- package/lib/agenda/disable.ts +28 -0
- package/lib/agenda/drain.ts +30 -0
- package/lib/agenda/enable.ts +29 -0
- package/lib/agenda/every.ts +86 -0
- package/lib/agenda/find-and-lock-next-job.ts +78 -0
- package/lib/agenda/has-mongo-protocol.ts +8 -0
- package/lib/agenda/index.ts +227 -0
- package/lib/agenda/job-processing-queue.ts +99 -0
- package/lib/agenda/jobs.ts +31 -0
- package/lib/agenda/lock-limit.ts +17 -0
- package/lib/agenda/max-concurrency.ts +20 -0
- package/lib/agenda/mongo.ts +21 -0
- package/lib/agenda/name.ts +16 -0
- package/lib/agenda/now.ts +31 -0
- package/lib/agenda/process-every.ts +18 -0
- package/lib/agenda/purge.ts +19 -0
- package/lib/agenda/save-job.ts +185 -0
- package/lib/agenda/schedule.ts +79 -0
- package/lib/agenda/sort.ts +17 -0
- package/lib/agenda/start.ts +30 -0
- package/lib/agenda/stop.ts +49 -0
- package/lib/cjs.ts +5 -0
- package/lib/index.ts +11 -0
- package/lib/job/compute-next-run-at.ts +191 -0
- package/lib/job/disable.ts +11 -0
- package/lib/job/enable.ts +11 -0
- package/lib/job/fail.ts +29 -0
- package/lib/job/index.ts +221 -0
- package/lib/job/is-running.ts +29 -0
- package/lib/job/priority.ts +11 -0
- package/lib/job/remove.ts +10 -0
- package/lib/job/repeat-at.ts +12 -0
- package/lib/job/repeat-every.ts +40 -0
- package/lib/job/run.ts +125 -0
- package/lib/job/save.ts +11 -0
- package/lib/job/schedule.ts +15 -0
- package/lib/job/set-shouldsaveresult.ts +10 -0
- package/lib/job/to-json.ts +36 -0
- package/lib/job/touch.ts +11 -0
- package/lib/job/unique.ts +18 -0
- package/lib/utils/create-job.ts +13 -0
- package/lib/utils/index.ts +3 -0
- package/lib/utils/parse-priority.ts +37 -0
- package/lib/utils/process-jobs.ts +379 -0
- package/package.json +13 -11
- package/tsconfig.json +72 -0
package/README.md
CHANGED
|
@@ -45,10 +45,6 @@ _Kudos for making the comparison chart goes to [Bull](https://www.npmjs.com/pack
|
|
|
45
45
|
|
|
46
46
|
# Installation
|
|
47
47
|
|
|
48
|
-
### Notice
|
|
49
|
-
|
|
50
|
-
In order to support new MongoDB 5.0 and mongodb node.js driver/package the next release (5.x.x) of Agenda will be major. The required node version will become >=12. The mongodb dependency version will become >=3.2.
|
|
51
|
-
|
|
52
48
|
Install via NPM
|
|
53
49
|
|
|
54
50
|
npm install agenda
|
|
@@ -67,11 +63,27 @@ For Typescript, Webpack or other module imports, use `agenda/es` entrypoint:
|
|
|
67
63
|
e.g.
|
|
68
64
|
|
|
69
65
|
```ts
|
|
70
|
-
import {
|
|
71
|
-
|
|
66
|
+
import Agenda, { Job, JobAttributesData } from 'agenda'
|
|
67
|
+
|
|
68
|
+
const mongoConnectionString = "mongodb://127.0.0.1/agenda";
|
|
69
|
+
const agenda = new Agenda({ db: { address: mongoConnectionString } });
|
|
72
70
|
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
interface CreateContact extends JobAttributesData {
|
|
72
|
+
contactDetails: Contact // app-specific type
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
agenda.define<CreateContact>('CREATE CONTACT', async (job: Job<CreateContact>) => {
|
|
76
|
+
const contactDetails = job.attrs.data.contactDetails; // type Contact
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
agenda.now<CreateContact>('CREATE CONTACT', {
|
|
80
|
+
contactDetails: {...} // required attr
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
agenda.schedule<CreateContact>('in 5 minutes', 'CREATE CONTACT', {
|
|
84
|
+
contactDetails: {...} // required attr
|
|
85
|
+
})
|
|
86
|
+
```
|
|
75
87
|
|
|
76
88
|
# Example Usage
|
|
77
89
|
|
package/dist/agenda/create.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Job } from "../job";
|
|
1
|
+
import { Job, JobAttributesData } from "../job";
|
|
2
2
|
import { Agenda } from ".";
|
|
3
3
|
/**
|
|
4
4
|
* Given a name and some data, create a new job
|
|
@@ -7,5 +7,5 @@ import { Agenda } from ".";
|
|
|
7
7
|
* @param name name of job
|
|
8
8
|
* @param data data to set for job
|
|
9
9
|
*/
|
|
10
|
-
export declare const create: (this: Agenda, name: string, data:
|
|
10
|
+
export declare const create: <T extends JobAttributesData>(this: Agenda, name: string, data: T) => Job;
|
|
11
11
|
//# sourceMappingURL=create.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../lib/agenda/create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../lib/agenda/create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAI3B;;;;;;GAMG;AACH,eAAO,MAAM,MAAM,sCAAgD,MAAM,QAAQ,MAAM,cAAY,GAQlG,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../lib/agenda/create.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAmC;AACnC,
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../lib/agenda/create.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAmC;AACnC,gCAAgD;AAGhD,MAAM,KAAK,GAAG,eAAc,CAAC,eAAe,CAAC,CAAC;AAE9C;;;;;;GAMG;AACI,MAAM,MAAM,GAAG,UAAqD,IAAY,EAAE,IAAO;IAC9F,KAAK,CAAC,6BAA6B,EAAE,IAAI,CAAC,CAAC;IAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC;QACtC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,QAAQ;QAClC,CAAC,CAAC,CAAC,CAAC;IACN,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,CAAA;IAC5G,MAAM,GAAG,GAAG,IAAI,SAAG,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9F,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AARW,QAAA,MAAM,UAQjB"}
|
package/dist/agenda/define.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export interface DefineOptions {
|
|
|
31
31
|
*/
|
|
32
32
|
shouldSaveResult?: boolean;
|
|
33
33
|
}
|
|
34
|
-
export declare type Processor = ((job: Job) => Promise<void>) | ((job: Job
|
|
34
|
+
export declare type Processor<T> = ((job: Job<T>) => Promise<void>) | ((job: Job<T>, done: () => void) => void);
|
|
35
35
|
/**
|
|
36
36
|
* Setup definition for job
|
|
37
37
|
* Method is used by consumers of lib to setup their functions
|
|
@@ -41,5 +41,5 @@ export declare type Processor = ((job: Job) => Promise<void>) | ((job: Job, done
|
|
|
41
41
|
* @param options options for job to run
|
|
42
42
|
* @param [processor] function to be called to run actual job
|
|
43
43
|
*/
|
|
44
|
-
export declare const define: (this: Agenda, name: string, options: DefineOptions | Processor
|
|
44
|
+
export declare const define: <T>(this: Agenda, name: string, options: DefineOptions | Processor<T>, processor?: Processor<T> | undefined) => void;
|
|
45
45
|
//# sourceMappingURL=define.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../../lib/agenda/define.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAE3B,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAI7B,oBAAY,WAAW;IACrB,OAAO,KAAK;IACZ,IAAI,KAAK;IACT,MAAM,IAAI;IACV,GAAG,MAAM;IACT,MAAM,MAAM;CACb;AAED,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,QAAQ,CAAC,EAAE,WAAW,CAAC;IAEvB;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,oBAAY,SAAS,
|
|
1
|
+
{"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../../lib/agenda/define.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAE3B,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAI7B,oBAAY,WAAW;IACrB,OAAO,KAAK;IACZ,IAAI,KAAK;IACT,MAAM,IAAI;IACV,GAAG,MAAM;IACT,MAAM,MAAM;CACb;AAED,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,QAAQ,CAAC,EAAE,WAAW,CAAC;IAEvB;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,oBAAY,SAAS,CAAC,CAAC,IACnB,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,GAChC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC,CAAC;AAE9C;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM,YACX,MAAM,QACN,MAAM,kFAGX,IAuBF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define.js","sourceRoot":"","sources":["../../lib/agenda/define.ts"],"names":[],"mappings":";;;;;;AACA,kDAAmC;AAGnC,MAAM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AAK;KACvE,CAAC;IACF,KAAK,CACH,+CAA+C,EAC/C,IAAI,EACJ,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CACxB,CAAC;AACJ,CAAC,CAAC;AA5BW,QAAA,MAAM,UA4BjB"}
|
package/dist/agenda/every.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Agenda } from ".";
|
|
2
|
+
import { JobAttributesData } from "../job";
|
|
2
3
|
import { JobOptions } from "../job/repeat-every";
|
|
3
4
|
/**
|
|
4
5
|
* Creates a scheduled job with given interval and name/names of the job to run
|
|
@@ -10,5 +11,5 @@ import { JobOptions } from "../job/repeat-every";
|
|
|
10
11
|
* @param options - options to run job for
|
|
11
12
|
* @returns Job/s created. Resolves when schedule fails or passes
|
|
12
13
|
*/
|
|
13
|
-
export declare const every: (this: Agenda, interval: string, names: string | string[], data?:
|
|
14
|
+
export declare const every: <T extends JobAttributesData>(this: Agenda, interval: string, names: string | string[], data?: T | undefined, options?: JobOptions | undefined) => Promise<any>;
|
|
14
15
|
//# sourceMappingURL=every.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"every.d.ts","sourceRoot":"","sources":["../../lib/agenda/every.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"every.d.ts","sourceRoot":"","sources":["../../lib/agenda/every.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAC3B,OAAO,EAAO,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAIjD;;;;;;;;;GASG;AACH,eAAO,MAAM,KAAK,sCACV,MAAM,YACF,MAAM,SACT,MAAM,GAAG,MAAM,EAAE,6DAGvB,QAAQ,GAAG,CA8Db,CAAC"}
|
package/dist/agenda/every.js
CHANGED
|
@@ -36,7 +36,7 @@ const every = function (interval, names, data, options) {
|
|
|
36
36
|
* @returns instance of job
|
|
37
37
|
*/
|
|
38
38
|
const createJob = (interval, name, data, options) => __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
const job = this.create(name, data);
|
|
39
|
+
const job = this.create(name, data || {});
|
|
40
40
|
job.attrs.type = "single";
|
|
41
41
|
job.repeatEvery(interval, options);
|
|
42
42
|
return job.save();
|
package/dist/agenda/every.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"every.js","sourceRoot":"","sources":["../../lib/agenda/every.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAAmC;AAKnC,MAAM,KAAK,GAAG,eAAc,CAAC,cAAc,CAAC,CAAC;AAE7C;;;;;;;;;GASG;AACI,MAAM,KAAK,GAAG,UAEnB,QAAgB,EAChB,KAAwB,EACxB,
|
|
1
|
+
{"version":3,"file":"every.js","sourceRoot":"","sources":["../../lib/agenda/every.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAAmC;AAKnC,MAAM,KAAK,GAAG,eAAc,CAAC,cAAc,CAAC,CAAC;AAE7C;;;;;;;;;GASG;AACI,MAAM,KAAK,GAAG,UAEnB,QAAgB,EAChB,KAAwB,EACxB,IAAQ,EACR,OAAoB;;QAEpB;;;;;;;WAOG;QACH,MAAM,SAAS,GAAG,CAChB,QAAgB,EAChB,IAAY,EACZ,IAAQ,EACR,OAAoB,EACN,EAAE;YAChB,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;YAE1C,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,QAAQ,CAAC;YAC1B,GAAG,CAAC,WAAW,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YACnC,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC;QACpB,CAAC,CAAA,CAAC;QAEF;;;;;;;WAOG;QACH,MAAM,UAAU,GAAG,CACjB,QAAgB,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AE,GAAG,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"find-and-lock-next-job.d.ts","sourceRoot":"","sources":["../../lib/agenda/find-and-lock-next-job.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAC3B,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAK7B;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,SACvB,MAAM,WACH,MAAM,cACH,GAAG,KACd,QAAQ,GAAG,GAAG,SAAS,CAwDzB,CAAC"}
|
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.findAndLockNextJob = void 0;
|
|
16
16
|
const debug_1 = __importDefault(require("debug"));
|
|
17
17
|
const utils_1 = require("../utils");
|
|
18
|
+
const mongodb_1 = require("mongodb");
|
|
18
19
|
const debug = debug_1.default("agenda:internal:_findAndLockNextJob");
|
|
19
20
|
/**
|
|
20
21
|
* Find and lock jobs
|
|
@@ -58,11 +59,9 @@ const findAndLockNextJob = function (jobName, definition) {
|
|
|
58
59
|
* Query used to affect what gets returned
|
|
59
60
|
* @type {{returnOriginal: boolean, sort: object}}
|
|
60
61
|
*/
|
|
61
|
-
const JOB_RETURN_QUERY = { returnDocument:
|
|
62
|
+
const JOB_RETURN_QUERY = { returnDocument: mongodb_1.ReturnDocument.AFTER, sort: this._sort };
|
|
62
63
|
// Find ONE and ONLY ONE job and set the 'lockedAt' time so that job begins to be processed
|
|
63
|
-
const result = yield this._collection.findOneAndUpdate(JOB_PROCESS_WHERE_QUERY, JOB_PROCESS_SET_QUERY,
|
|
64
|
-
// @ts-ignore
|
|
65
|
-
JOB_RETURN_QUERY);
|
|
64
|
+
const result = yield this._collection.findOneAndUpdate(JOB_PROCESS_WHERE_QUERY, JOB_PROCESS_SET_QUERY, JOB_RETURN_QUERY);
|
|
66
65
|
let job = undefined;
|
|
67
66
|
if (result.value) {
|
|
68
67
|
debug("found a job available to lock, creating a new job on Agenda with id [%s]", result.value._id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-and-lock-next-job.js","sourceRoot":"","sources":["../../lib/agenda/find-and-lock-next-job.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAAmC;AACnC,oCAAqC;
|
|
1
|
+
{"version":3,"file":"find-and-lock-next-job.js","sourceRoot":"","sources":["../../lib/agenda/find-and-lock-next-job.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAAmC;AACnC,oCAAqC;AAGrC,qCAAyC;AAEzC,MAAM,KAAK,GAAG,eAAc,CAAC,qCAAqC,CAAC,CAAC;AAEpE;;;;;;;;GAQG;AACI,MAAM,kBAAkB,GAAG,UAEhC,OAAe,EACf,UAAe;;QAEf,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,YAAY,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;QAC9E,KAAK,CAAC,qCAAqC,EAAE,OAAO,CAAC,CAAC;QAEtD,MAAM,uBAAuB,GAAG;YAC9B,IAAI,EAAE;gBACJ;oBACE,IAAI,EAAE,OAAO;oBACb,QAAQ,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;iBACxB;gBACD;oBACE,GAAG,EAAE;wBACH;4BACE,QAAQ,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;4BACvB,SAAS,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE;yBACtC;wBACD;4BACE,QAAQ,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE;yBACjC;qBACF;iBACF;aACF;SACF,CAAC;QAEF;;;WAGG;QACH,MAAM,qBAAqB,GAAG,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,CAAC;QAE1D;;;WAGG;QACH,MAAM,gBAAgB,GAAG,EAAE,cAAc,EAAE,wBAAc,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;QAEpF,2FAA2F;QAC3F,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,gBAAgB,CACpD,uBAAuB,EACvB,qBAAqB,EACrB,gBAAgB,CACjB,CAAC;QAEF,IAAI,GAAG,GAAoB,SAAS,CAAC;QACrC,IAAI,MAAM,CAAC,KAAK,EAAE;YAChB,KAAK,CACH,0EAA0E,EAC1E,MAAM,CAAC,KAAK,CAAC,GAAG,CACjB,CAAC;YAEF,aAAa;YACb,GAAG,GAAG,iBAAS,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;SACrC;QAED,OAAO,GAAG,CAAC;IACb,CAAC;CAAA,CAAC;AA5DW,QAAA,kBAAkB,sBA4D7B"}
|
package/dist/agenda/now.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Agenda } from ".";
|
|
2
|
-
import { Job } from "../job";
|
|
2
|
+
import { Job, JobAttributesData } from "../job";
|
|
3
3
|
/**
|
|
4
4
|
* Create a job for this exact moment
|
|
5
5
|
* @name Agenda#now
|
|
@@ -7,5 +7,5 @@ import { Job } from "../job";
|
|
|
7
7
|
* @param name name of job to schedule
|
|
8
8
|
* @param data data to pass to job
|
|
9
9
|
*/
|
|
10
|
-
export declare const now: (this: Agenda, name: string, data:
|
|
10
|
+
export declare const now: <T extends JobAttributesData>(this: Agenda, name: string, data: T) => Promise<Job>;
|
|
11
11
|
//# sourceMappingURL=now.d.ts.map
|
package/dist/agenda/now.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"now.d.ts","sourceRoot":"","sources":["../../lib/agenda/now.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAC3B,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"now.d.ts","sourceRoot":"","sources":["../../lib/agenda/now.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAC3B,OAAO,EAAE,GAAG,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAIhD;;;;;;GAMG;AACH,eAAO,MAAM,GAAG,sCACR,MAAM,QACN,MAAM,cAEX,QAAQ,GAAG,CAab,CAAC"}
|
package/dist/agenda/now.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"now.js","sourceRoot":"","sources":["../../lib/agenda/now.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAAmC;AAInC,MAAM,KAAK,GAAG,eAAc,CAAC,YAAY,CAAC,CAAC;AAE3C;;;;;;GAMG;AACI,MAAM,GAAG,GAAG,UAEjB,IAAY,EACZ,
|
|
1
|
+
{"version":3,"file":"now.js","sourceRoot":"","sources":["../../lib/agenda/now.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAAmC;AAInC,MAAM,KAAK,GAAG,eAAc,CAAC,YAAY,CAAC,CAAC;AAE3C;;;;;;GAMG;AACI,MAAM,GAAG,GAAG,UAEjB,IAAY,EACZ,IAAO;;QAEP,KAAK,CAAC,0BAA0B,EAAE,IAAI,CAAC,CAAC;QACxC,IAAI;YACF,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAEpC,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;YACzB,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;YAEjB,OAAO,GAAG,CAAC;SACZ;QAAC,OAAO,KAAK,EAAE;YACd,KAAK,CAAC,oDAAoD,CAAC,CAAC;YAC5D,MAAM,KAAK,CAAC;SACb;IACH,CAAC;CAAA,CAAC;AAjBW,QAAA,GAAG,OAiBd"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Agenda } from ".";
|
|
2
|
-
import { Job } from "../job";
|
|
2
|
+
import { Job, JobAttributesData } from "../job";
|
|
3
3
|
/**
|
|
4
4
|
* Schedule a job or jobs at a specific time
|
|
5
5
|
* @name Agenda#schedule
|
|
@@ -9,6 +9,6 @@ import { Job } from "../job";
|
|
|
9
9
|
* @param data data to send to job
|
|
10
10
|
* @returns job or jobs created
|
|
11
11
|
*/
|
|
12
|
-
export declare function schedule(this: Agenda, when: string | Date, names: string, data:
|
|
13
|
-
export declare function schedule(this: Agenda, when: string | Date, names: string[], data:
|
|
12
|
+
export declare function schedule<T extends JobAttributesData>(this: Agenda, when: string | Date, names: string, data: T): Promise<Job>;
|
|
13
|
+
export declare function schedule<T extends JobAttributesData>(this: Agenda, when: string | Date, names: string[], data: T): Promise<Job[]>;
|
|
14
14
|
//# sourceMappingURL=schedule.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../lib/agenda/schedule.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAC3B,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../lib/agenda/schedule.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAC3B,OAAO,EAAE,GAAG,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAIhD;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,iBAAiB,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;AAC/H,wBAAgB,QAAQ,CAAC,CAAC,SAAS,iBAAiB,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schedule.js","sourceRoot":"","sources":["../../lib/agenda/schedule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAAmC;AAInC,MAAM,KAAK,GAAG,eAAc,CAAC,iBAAiB,CAAC,CAAC;AAahD,SAAgB,QAAQ,CAEtB,IAAmB,EACnB,KAAwB,EACxB,
|
|
1
|
+
{"version":3,"file":"schedule.js","sourceRoot":"","sources":["../../lib/agenda/schedule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAAmC;AAInC,MAAM,KAAK,GAAG,eAAc,CAAC,iBAAiB,CAAC,CAAC;AAahD,SAAgB,QAAQ,CAEtB,IAAmB,EACnB,KAAwB,EACxB,IAAO;IAEP;;;;;;OAMG;IACH,MAAM,SAAS,GAAG,CAChB,IAAmB,EACnB,IAAY,EACZ,IAAS,EACK,EAAE;QAChB,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAEpC,MAAM,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;QAEhC,OAAO,GAAG,CAAC;IACb,CAAC,CAAA,CAAC;IAEF;;;;;;OAMG;IACH,MAAM,UAAU,GAAG,CACjB,IAAmB,EACnB,KAAe,EACf,IAAS,EACO,EAAE;QAClB,IAAI;YACF,MAAM,aAAa,GAAwB,EAAE,CAAC;YAC9C,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;YACrE,KAAK,CAAC,kEAAkE,CAAC,CAAC;YAC1E,OAAO,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;SACnC;QAAC,OAAO,KAAK,EAAE;YACd,KAAK,CACH,2EAA2E,CAC5E,CAAC;YACF,MAAM,KAAK,CAAC;SACb;IACH,CAAC,CAAA,CAAC;IAEF,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,KAAK,CAAC,mCAAmC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QACxD,OAAO,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;KACrC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACxB,KAAK,CAAC,+BAA+B,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QACpD,OAAO,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;KACtC;IAED,MAAM,IAAI,SAAS,CAAC,yCAAyC,CAAC,CAAA;AAChE,CAAC;AA7DD,4BA6DC;AAAA,CAAC"}
|
|
@@ -75,7 +75,7 @@ const computeNextRunAt = function () {
|
|
|
75
75
|
// If start date is present, check if the nextDate should be larger or equal to startDate. If not set startDate as nextDate
|
|
76
76
|
if (startDate) {
|
|
77
77
|
startDate = moment_timezone_1.default
|
|
78
|
-
.tz(moment_timezone_1.default(startDate).format("YYYY-MM-DD"), timezone)
|
|
78
|
+
.tz(moment_timezone_1.default(startDate).format("YYYY-MM-DD HH:mm"), timezone)
|
|
79
79
|
.toDate();
|
|
80
80
|
if (startDate > nextDate) {
|
|
81
81
|
cronOptions.currentDate = startDate;
|
|
@@ -93,7 +93,7 @@ const computeNextRunAt = function () {
|
|
|
93
93
|
// If endDate is less than the nextDate, set nextDate to null to stop the job from running further
|
|
94
94
|
if (endDate) {
|
|
95
95
|
const endDateDate = moment_timezone_1.default
|
|
96
|
-
.tz(moment_timezone_1.default(endDate).format("YYYY-MM-DD"), timezone)
|
|
96
|
+
.tz(moment_timezone_1.default(endDate).format("YYYY-MM-DD HH:mm"), timezone)
|
|
97
97
|
.toDate();
|
|
98
98
|
if (nextDate > endDateDate) {
|
|
99
99
|
nextDate = null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compute-next-run-at.js","sourceRoot":"","sources":["../../lib/job/compute-next-run-at.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,oDAAsC;AACtC,oEAA2C;AAC3C,kDAAmC;AACnC,sEAAqC;AACrC,mBAAmB;AACnB,sDAA2B;AAE3B,MAAM,KAAK,GAAG,eAAc,CAAC,YAAY,CAAC,CAAC;AAE3C;;;;GAIG;AACI,MAAM,gBAAgB,GAAG;IAC9B,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC;IAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC;IAC3C,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;IAChC,MAAM,iBAAiB,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,IAAI,IAAI,IAAI,EAAE,CAAC;IAC7D,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC;IAEjC,MAAM,eAAe,GAAG,CAAC,IAAU,EAAiB,EAAE;QACpD,MAAM,KAAK,GAAkB,yBAAM,CAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,QAAQ,EAAE;YACZ,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;SACpB;QAED,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IAEF;;OAEG;IACH,MAAM,mBAAmB,GAAG,GAAG,EAAE;;QAC/B,KAAK,CACH,8CAA8C,EAC9C,IAAI,CAAC,KAAK,CAAC,IAAI,EACf,IAAI,CAAC,KAAK,CAAC,GAAG,EACd,QAAQ,CACT,CAAC;QACF,MAAM,OAAO,GAAG,IAAI,IAAI,EAAE,CAAC;QAC3B,IAAI,OAAO,GAAS,IAAI,CAAC,KAAK,CAAC,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+B,EAC/B,IAAI,CAAC,KAAK,CAAC,IAAI,EACf,IAAI,CAAC,KAAK,CAAC,GAAG,EACd,MAAA,IAAI,CAAC,KAAK,CAAC,SAAS,0CAAE,WAAW,EAAE,CACpC,CAAC;SACH;aAAM;YACL,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,iBAAI,CAAC,QAAQ,CAAC,CAAC;YACtC,KAAK,CACH,+BAA+B,EAC/B,IAAI,CAAC,KAAK,CAAC,IAAI,EACf,IAAI,CAAC,KAAK,CAAC,GAAG,EACd,MAAA,IAAI,CAAC,KAAK,CAAC,SAAS,0CAAE,WAAW,EAAE,CACpC,CAAC;SACH;IACH,CAAC,CAAC;IAEF,IAAI,QAAQ,EAAE;QACZ,mBAAmB,EAAE,CAAC;KACvB;SAAM,IAAI,QAAQ,EAAE;QACnB,mBAAmB,EAAE,CAAC;KACvB;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AA/KW,QAAA,gBAAgB,oBA+K3B"}
|
package/dist/job/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ import { touch } from "./touch";
|
|
|
16
16
|
import { setShouldSaveResult } from "./set-shouldsaveresult";
|
|
17
17
|
import { Agenda } from "../agenda";
|
|
18
18
|
import * as mongodb from "mongodb";
|
|
19
|
+
declare type Modify<T, R> = Omit<T, keyof R> & R;
|
|
19
20
|
export interface JobAttributesData {
|
|
20
21
|
[key: string]: any;
|
|
21
22
|
}
|
|
@@ -23,7 +24,7 @@ export interface JobAttributes<T extends JobAttributesData = JobAttributesData>
|
|
|
23
24
|
/**
|
|
24
25
|
* The record identity.
|
|
25
26
|
*/
|
|
26
|
-
_id
|
|
27
|
+
_id: mongodb.ObjectId;
|
|
27
28
|
agenda: Agenda;
|
|
28
29
|
/**
|
|
29
30
|
* The type of the job (single|normal).
|
|
@@ -52,7 +53,7 @@ export interface JobAttributes<T extends JobAttributesData = JobAttributesData>
|
|
|
52
53
|
/**
|
|
53
54
|
* The job details.
|
|
54
55
|
*/
|
|
55
|
-
data
|
|
56
|
+
data: T;
|
|
56
57
|
unique?: any;
|
|
57
58
|
uniqueOpts?: {
|
|
58
59
|
insertOnly: boolean;
|
|
@@ -133,7 +134,9 @@ declare class Job<T extends JobAttributesData = JobAttributesData> {
|
|
|
133
134
|
remove: typeof remove;
|
|
134
135
|
touch: typeof touch;
|
|
135
136
|
setShouldSaveResult: typeof setShouldSaveResult;
|
|
136
|
-
constructor(options: JobAttributes<T
|
|
137
|
+
constructor(options: Modify<JobAttributes<T>, {
|
|
138
|
+
_id?: mongodb.ObjectId;
|
|
139
|
+
}>);
|
|
137
140
|
}
|
|
138
141
|
export { Job };
|
|
139
142
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/job/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/job/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,MAAM,EA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AAC,EAAE;QAAE,GAAG,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC;KAAE,CAAC;CAkC3E;AAmBD,OAAO,EAAE,GAAG,EAAE,CAAC"}
|
package/dist/job/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/job/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,uCAAmC;AACnC,+DAAyD;AACzD,iDAA6C;AAC7C,2CAAuC;AACvC,uCAAoC;AACpC,qCAAkC;AAClC,qCAAkC;AAClC,yCAAsC;AACtC,yCAAsC;AACtC,iCAA8B;AAC9B,+BAA4B;AAC5B,6CAAyC;AACzC,iCAA8B;AAC9B,qCAAkC;AAClC,mCAAgC;AAChC,iEAA6D;AAC7D,oCAAyC;AAEzC,6CAA+C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/job/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,uCAAmC;AACnC,+DAAyD;AACzD,iDAA6C;AAC7C,2CAAuC;AACvC,uCAAoC;AACpC,qCAAkC;AAClC,qCAAkC;AAClC,yCAAsC;AACtC,yCAAsC;AACtC,iCAA8B;AAC9B,+BAA4B;AAC5B,6CAAyC;AACzC,iCAA8B;AAC9B,qCAAkC;AAClC,mCAAgC;AAChC,iEAA6D;AAC7D,oCAAyC;AAEzC,6CAA+C;AAmH/C;;;;;GAKG;AACH,MAAM,GAAG;IA4BP,YAAY,OAA8D;QACxE,MAAM,KAAuC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,EAApD,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,OAA2B,EAAtB,IAAI,cAAlC,+BAAoC,CAAgB,CAAC;QAE3D,uBAAuB;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,eAAe;QACf,IAAI,CAAC,QAAQ;YACX,IAAI,CAAC,QAAQ,KAAK,SAAS;gBACzB,CAAC,C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C;AAClC,GAAG,CAAC,SAAS,CAAC,IAAI,GAAG,WAAI,CAAC;AAC1B,GAAG,CAAC,SAAS,CAAC,GAAG,GAAG,SAAG,CAAC;AACxB,GAAG,CAAC,SAAS,CAAC,SAAS,GAAG,sBAAS,CAAC;AACpC,GAAG,CAAC,SAAS,CAAC,IAAI,GAAG,WAAI,CAAC;AAC1B,GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,eAAM,CAAC;AAC9B,GAAG,CAAC,SAAS,CAAC,KAAK,GAAG,aAAK,CAAC;AAC5B,GAAG,CAAC,SAAS,CAAC,mBAAmB,GAAG,0CAAmB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Agenda } from ".";
|
|
2
|
+
import createDebugger from "debug";
|
|
3
|
+
import { Document, Filter } from "mongodb";
|
|
4
|
+
|
|
5
|
+
const debug = createDebugger("agenda:cancel");
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Cancels any jobs matching the passed MongoDB query, and removes them from the database.
|
|
9
|
+
* @name Agenda#cancel
|
|
10
|
+
* @function
|
|
11
|
+
* @param query MongoDB query to use when cancelling
|
|
12
|
+
* @caller client code, Agenda.purge(), Job.remove()
|
|
13
|
+
*/
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
+
export const cancel = async function (
|
|
16
|
+
this: Agenda,
|
|
17
|
+
query: Filter<Document>
|
|
18
|
+
): Promise<number | undefined> {
|
|
19
|
+
debug("attempting to cancel all Agenda jobs", query);
|
|
20
|
+
try {
|
|
21
|
+
const { deletedCount } = await this._collection.deleteMany(query);
|
|
22
|
+
debug("%s jobs cancelled", deletedCount);
|
|
23
|
+
return deletedCount;
|
|
24
|
+
} catch (error) {
|
|
25
|
+
debug("error trying to delete jobs from MongoDB");
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Agenda } from ".";
|
|
2
|
+
import createDebugger from "debug";
|
|
3
|
+
|
|
4
|
+
const debug = createDebugger("agenda:close");
|
|
5
|
+
|
|
6
|
+
/** Close the db and it's underlying connections
|
|
7
|
+
* Only works if agenda was instantiated without preconfigured mongoDb instance.
|
|
8
|
+
* If the mongoDb instance was supplied during instantiation or via agenda.mongo, this function will do nothing and return agenda anyway.
|
|
9
|
+
* @name Agenda#close
|
|
10
|
+
* @function
|
|
11
|
+
* @param [option] {{ force: boolean }} Force close, emitting no events
|
|
12
|
+
*
|
|
13
|
+
*
|
|
14
|
+
* @caller client code
|
|
15
|
+
*
|
|
16
|
+
* @link https://mongodb.github.io/node-mongodb-native/2.0/api/Db.html#close
|
|
17
|
+
*/
|
|
18
|
+
export const close = async function (
|
|
19
|
+
this: Agenda,
|
|
20
|
+
option?: { force: boolean }
|
|
21
|
+
): Promise<Agenda> {
|
|
22
|
+
debug("close db connection for this agenda instance");
|
|
23
|
+
const closeOptions = {
|
|
24
|
+
force: false,
|
|
25
|
+
...option,
|
|
26
|
+
};
|
|
27
|
+
try {
|
|
28
|
+
if (this._db) {
|
|
29
|
+
await this._db.close(closeOptions.force);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return this;
|
|
33
|
+
} catch (error) {
|
|
34
|
+
debug("error trying to close db connection to");
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import createDebugger from "debug";
|
|
2
|
+
import { Job, JobAttributesData } from "../job";
|
|
3
|
+
import { Agenda } from ".";
|
|
4
|
+
|
|
5
|
+
const debug = createDebugger("agenda:create");
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Given a name and some data, create a new job
|
|
9
|
+
* @name Agenda#create
|
|
10
|
+
* @function
|
|
11
|
+
* @param name name of job
|
|
12
|
+
* @param data data to set for job
|
|
13
|
+
*/
|
|
14
|
+
export const create = function<T extends JobAttributesData> (this: Agenda, name: string, data: T): Job {
|
|
15
|
+
debug("Agenda.create(%s, [Object])", name);
|
|
16
|
+
const priority = this._definitions[name]
|
|
17
|
+
? this._definitions[name].priority
|
|
18
|
+
: 0;
|
|
19
|
+
const shouldSaveResult = this._definitions[name] ? this._definitions[name].shouldSaveResult || false : false
|
|
20
|
+
const job = new Job({ name, data, type: "normal", priority, shouldSaveResult, agenda: this });
|
|
21
|
+
return job;
|
|
22
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import createDebugger from "debug";
|
|
2
|
+
import { AnyError, Collection, MongoClient, MongoClientOptions } from "mongodb";
|
|
3
|
+
import { Agenda } from ".";
|
|
4
|
+
import { hasMongoProtocol } from "./has-mongo-protocol";
|
|
5
|
+
|
|
6
|
+
const debug = createDebugger("agenda:database");
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Connect to the spec'd MongoDB server and database.
|
|
10
|
+
*
|
|
11
|
+
* NOTE:
|
|
12
|
+
* If `url` includes auth details then `options` must specify: { 'uri_decode_auth': true }. This does Auth on
|
|
13
|
+
* the specified database, not the Admin database. If you are using Auth on the Admin DB and not on the Agenda DB,
|
|
14
|
+
* then you need to authenticate against the Admin DB and then pass the MongoDB instance into the constructor
|
|
15
|
+
* or use Agenda.mongo(). If your app already has a MongoDB connection then use that. ie. specify config.mongo in
|
|
16
|
+
* the constructor or use Agenda.mongo().
|
|
17
|
+
* @name Agenda#database
|
|
18
|
+
* @function
|
|
19
|
+
* @param url MongoDB server URI
|
|
20
|
+
* @param [collection] name of collection to use. Defaults to `agendaJobs`
|
|
21
|
+
* @param [options] options for connecting
|
|
22
|
+
* @param [cb] callback of MongoDB connection
|
|
23
|
+
*/
|
|
24
|
+
export const database = function (
|
|
25
|
+
this: Agenda,
|
|
26
|
+
url: string,
|
|
27
|
+
collection?: string,
|
|
28
|
+
options: MongoClientOptions = {},
|
|
29
|
+
cb?: (error: AnyError | undefined, collection: Collection<any> | null) => void
|
|
30
|
+
): Agenda | void {
|
|
31
|
+
if (!hasMongoProtocol(url)) {
|
|
32
|
+
url = "mongodb://" + url;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
collection = collection || "agendaJobs";
|
|
36
|
+
|
|
37
|
+
MongoClient.connect(url, options, (error, client) => {
|
|
38
|
+
if (error) {
|
|
39
|
+
debug("error connecting to MongoDB using collection: [%s]", collection);
|
|
40
|
+
if (cb) {
|
|
41
|
+
cb(error, null);
|
|
42
|
+
} else {
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
debug(
|
|
50
|
+
"successful connection to MongoDB using collection: [%s]",
|
|
51
|
+
collection
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
if (client) {
|
|
55
|
+
this._db = client;
|
|
56
|
+
this._mdb = client.db();
|
|
57
|
+
this.db_init(collection, cb);
|
|
58
|
+
} else {
|
|
59
|
+
throw new Error("Mongo Client is undefined");
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
return this;
|
|
63
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import createDebugger from "debug";
|
|
2
|
+
import { AnyError, Collection } from "mongodb";
|
|
3
|
+
import { Agenda } from ".";
|
|
4
|
+
|
|
5
|
+
const debug = createDebugger("agenda:db_init");
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Setup and initialize the collection used to manage Jobs.
|
|
9
|
+
* @name Agenda#dbInit
|
|
10
|
+
* @function
|
|
11
|
+
* @param collection name or undefined for default 'agendaJobs'
|
|
12
|
+
* @param [cb] called when the db is initialized
|
|
13
|
+
*/
|
|
14
|
+
export const dbInit = function (
|
|
15
|
+
this: Agenda,
|
|
16
|
+
collection = "agendaJobs",
|
|
17
|
+
cb?: (error: AnyError | undefined, collection: Collection<any> | null) => void
|
|
18
|
+
): void {
|
|
19
|
+
debug("init database collection using name [%s]", collection);
|
|
20
|
+
this._collection = this._mdb.collection(collection);
|
|
21
|
+
if (this._disableAutoIndex) {
|
|
22
|
+
debug("skipping auto index creation");
|
|
23
|
+
this.emit("ready");
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
debug("attempting index creation");
|
|
28
|
+
this._collection.createIndex(
|
|
29
|
+
this._indices,
|
|
30
|
+
{ name: "findAndLockNextJobIndex" },
|
|
31
|
+
(error) => {
|
|
32
|
+
if (error) {
|
|
33
|
+
debug("index creation failed");
|
|
34
|
+
this.emit("error", error);
|
|
35
|
+
} else {
|
|
36
|
+
debug("index creation success");
|
|
37
|
+
this.emit("ready");
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (cb) {
|
|
41
|
+
cb(error, this._collection);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Agenda } from ".";
|
|
2
|
+
import createDebugger from "debug";
|
|
3
|
+
|
|
4
|
+
const debug = createDebugger("agenda:defaultConcurrency");
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Set the default concurrency for each job
|
|
8
|
+
* @name Agenda#defaultConcurrency
|
|
9
|
+
* @function
|
|
10
|
+
* @param concurrency default concurrency
|
|
11
|
+
*/
|
|
12
|
+
export const defaultConcurrency = function (
|
|
13
|
+
this: Agenda,
|
|
14
|
+
concurrency: number
|
|
15
|
+
): Agenda {
|
|
16
|
+
debug("Agenda.defaultConcurrency(%d)", concurrency);
|
|
17
|
+
this._defaultConcurrency = concurrency;
|
|
18
|
+
return this;
|
|
19
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Agenda } from ".";
|
|
2
|
+
import createDebugger from "debug";
|
|
3
|
+
|
|
4
|
+
const debug = createDebugger("agenda:defaultLockLifetime");
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Set the default lock time (in ms)
|
|
8
|
+
* Default is 10 * 60 * 1000 ms (10 minutes)
|
|
9
|
+
* @name Agenda#defaultLockLifetime
|
|
10
|
+
* @function
|
|
11
|
+
* @param {Number} ms time in ms to set default lock
|
|
12
|
+
*/
|
|
13
|
+
export const defaultLockLifetime = function (this: Agenda, ms: number): Agenda {
|
|
14
|
+
debug("Agenda.defaultLockLifetime(%d)", ms);
|
|
15
|
+
this._defaultLockLifetime = ms;
|
|
16
|
+
return this;
|
|
17
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Agenda } from ".";
|
|
2
|
+
import createDebugger from "debug";
|
|
3
|
+
|
|
4
|
+
const debug = createDebugger("agenda:defaultLockLimit");
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Set default lock limit per job type
|
|
8
|
+
* @name Agenda#defaultLockLimit
|
|
9
|
+
* @function
|
|
10
|
+
* @param {Number} num Lock limit per job
|
|
11
|
+
* @returns {Agenda} agenda instance
|
|
12
|
+
*/
|
|
13
|
+
export const defaultLockLimit = function (this: Agenda, times: number): Agenda {
|
|
14
|
+
debug("Agenda.defaultLockLimit(%d)", times);
|
|
15
|
+
this._defaultLockLimit = times;
|
|
16
|
+
return this;
|
|
17
|
+
};
|