@sapphire/plugin-scheduled-tasks 7.1.2 → 7.1.3-next.2fd57eb.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.
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
2
13
|
var _ScheduledTaskHandler_internalClient;
|
|
3
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
15
|
exports.ScheduledTaskHandler = void 0;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
16
|
const framework_1 = require("@sapphire/framework");
|
|
7
17
|
const stopwatch_1 = require("@sapphire/stopwatch");
|
|
8
18
|
const bullmq_1 = require("bullmq");
|
|
@@ -25,16 +35,16 @@ class ScheduledTaskHandler {
|
|
|
25
35
|
this.queue = options?.queue ?? 'scheduled-tasks';
|
|
26
36
|
this.options = options?.bull ?? {};
|
|
27
37
|
const connectResult = framework_1.Result.from(() => {
|
|
28
|
-
|
|
38
|
+
__classPrivateFieldSet(this, _ScheduledTaskHandler_internalClient, new bullmq_1.Queue(this.queue, this.options), "f");
|
|
29
39
|
new bullmq_1.Worker(this.queue, async (job) => this.run(job?.name, job?.data), { connection: this.options.connection });
|
|
30
40
|
});
|
|
31
41
|
connectResult.inspectErr((error) => framework_1.container.client.emit(ScheduledTaskEvents_1.ScheduledTaskEvents.ScheduledTaskStrategyConnectError, error));
|
|
32
42
|
}
|
|
33
43
|
get client() {
|
|
34
|
-
return
|
|
44
|
+
return __classPrivateFieldGet(this, _ScheduledTaskHandler_internalClient, "f");
|
|
35
45
|
}
|
|
36
46
|
create(task, payload, options) {
|
|
37
|
-
if (!
|
|
47
|
+
if (!__classPrivateFieldGet(this, _ScheduledTaskHandler_internalClient, "f")) {
|
|
38
48
|
return;
|
|
39
49
|
}
|
|
40
50
|
if (typeof options === 'number') {
|
|
@@ -59,7 +69,7 @@ class ScheduledTaskHandler {
|
|
|
59
69
|
}
|
|
60
70
|
};
|
|
61
71
|
}
|
|
62
|
-
return
|
|
72
|
+
return __classPrivateFieldGet(this, _ScheduledTaskHandler_internalClient, "f").add(task, payload ?? null, jobOptions);
|
|
63
73
|
}
|
|
64
74
|
async createRepeated(tasks) {
|
|
65
75
|
const { store } = this;
|
|
@@ -83,7 +93,7 @@ class ScheduledTaskHandler {
|
|
|
83
93
|
}
|
|
84
94
|
}
|
|
85
95
|
async delete(id) {
|
|
86
|
-
if (!
|
|
96
|
+
if (!__classPrivateFieldGet(this, _ScheduledTaskHandler_internalClient, "f")) {
|
|
87
97
|
return;
|
|
88
98
|
}
|
|
89
99
|
const job = await this.get(id);
|
|
@@ -91,23 +101,23 @@ class ScheduledTaskHandler {
|
|
|
91
101
|
}
|
|
92
102
|
list(options) {
|
|
93
103
|
const { types, start, end, asc } = options;
|
|
94
|
-
if (!
|
|
104
|
+
if (!__classPrivateFieldGet(this, _ScheduledTaskHandler_internalClient, "f")) {
|
|
95
105
|
return;
|
|
96
106
|
}
|
|
97
|
-
return
|
|
107
|
+
return __classPrivateFieldGet(this, _ScheduledTaskHandler_internalClient, "f").getJobs(types, start, end, asc);
|
|
98
108
|
}
|
|
99
109
|
listRepeated(options) {
|
|
100
110
|
const { start, end, asc } = options;
|
|
101
|
-
if (!
|
|
111
|
+
if (!__classPrivateFieldGet(this, _ScheduledTaskHandler_internalClient, "f")) {
|
|
102
112
|
return;
|
|
103
113
|
}
|
|
104
|
-
return
|
|
114
|
+
return __classPrivateFieldGet(this, _ScheduledTaskHandler_internalClient, "f").getRepeatableJobs(start, end, asc);
|
|
105
115
|
}
|
|
106
116
|
get(id) {
|
|
107
|
-
if (!
|
|
117
|
+
if (!__classPrivateFieldGet(this, _ScheduledTaskHandler_internalClient, "f")) {
|
|
108
118
|
return;
|
|
109
119
|
}
|
|
110
|
-
return
|
|
120
|
+
return __classPrivateFieldGet(this, _ScheduledTaskHandler_internalClient, "f").getJob(id);
|
|
111
121
|
}
|
|
112
122
|
async run(task, payload) {
|
|
113
123
|
const piece = this.store.get(task);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScheduledTaskHandler.js","sourceRoot":"","sources":["../../src/lib/ScheduledTaskHandler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScheduledTaskHandler.js","sourceRoot":"","sources":["../../src/lib/ScheduledTaskHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mDAAwD;AACxD,mDAAgD;AAChD,mCAA+F;AAE/F,qEAAkE;AAalE,MAAa,oBAAoB;IAKhC,YAAmB,OAAqC;QAJxC;;;;;WAAsB;QACtB;;;;;WAAc;QAC9B,+CAAqC,IAAI,EAAC;QAGzC,IAAI,CAAC,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,iBAAiB,CAAC;QACjD,IAAI,CAAC,OAAO,GAAG,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC;QAEnC,MAAM,aAAa,GAAG,kBAAM,CAAC,IAAI,CAAC,GAAG,EAAE;YACtC,uBAAA,IAAI,wCA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AAE,aAAa,EAAE,QAAQ,CAAC,CAAC;YAExG,OAAO,QAAQ,CAAC;QACjB,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,qBAAS,CAAC,MAAM,CAAC,IAAI,CAAC,yCAAmB,CAAC,kBAAkB,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;QAElH,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEpC,qBAAS,CAAC,MAAM,CAAC,IAAI,CAAC,yCAAmB,CAAC,qBAAqB,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAEvF,OAAO,KAAK,CAAC;IACd,CAAC;IAED,IAAY,KAAK;QAChB,OAAO,qBAAS,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAkC,CAAC;IACxF,CAAC;CACD;AArJD,oDAqJC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScheduledTaskTypes.js","sourceRoot":"","sources":["../../../src/lib/types/ScheduledTaskTypes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScheduledTaskTypes.js","sourceRoot":"","sources":["../../../src/lib/types/ScheduledTaskTypes.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sapphire/plugin-scheduled-tasks",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.3-next.2fd57eb.0",
|
|
4
4
|
"description": "Plugin for @sapphire/framework to have scheduled tasks",
|
|
5
5
|
"author": "@sapphire",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@favware/cliff-jumper": "^2.1.1",
|
|
45
45
|
"gen-esm-wrapper": "^1.1.3",
|
|
46
|
-
"typedoc": "^0.
|
|
46
|
+
"typedoc": "^0.25.0",
|
|
47
47
|
"typedoc-json-parser": "^8.2.0",
|
|
48
|
-
"typescript": "^5.
|
|
48
|
+
"typescript": "^5.2.2"
|
|
49
49
|
},
|
|
50
50
|
"repository": {
|
|
51
51
|
"type": "git",
|