@nexusts/schedule 0.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.
- package/README.md +41 -0
- package/dist/index.js +870 -0
- package/dist/index.js.map +15 -0
- package/package.json +31 -0
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# @nexusts/schedule
|
|
2
|
+
|
|
3
|
+
> **NexusTS** — Bun-native fullstack framework
|
|
4
|
+
|
|
5
|
+
## Description
|
|
6
|
+
|
|
7
|
+
Cron scheduling (@Cron / @Interval / @Timeout).
|
|
8
|
+
|
|
9
|
+
In-tree cron parser (no `cron` / `node-cron` peer dep). Decorator-based.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
This module is part of the NexusTS monorepo. Each module is published as its own npm package under the `@nexusts/` scope.
|
|
14
|
+
|
|
15
|
+
Most apps start with just the core:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
bun add @nexusts/core reflect-metadata zod hono
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Then add this module only if you need it:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
bun add @nexusts/schedule
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Peer dependencies
|
|
28
|
+
|
|
29
|
+
None. This module is fully self-contained.
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import { /* public API */ } from "@nexusts/schedule";
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
See the [user guide](../../docs/user-guide/schedule.md) and the [example app](../../examples/) for a working demo.
|
|
38
|
+
|
|
39
|
+
## License
|
|
40
|
+
|
|
41
|
+
MIT — see the root [LICENSE](../../LICENSE).
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,870 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var __legacyDecorateClassTS = function(decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
5
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
6
|
+
else
|
|
7
|
+
for (var i = decorators.length - 1;i >= 0; i--)
|
|
8
|
+
if (d = decorators[i])
|
|
9
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
10
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11
|
+
};
|
|
12
|
+
var __legacyDecorateParamTS = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
13
|
+
var __legacyMetadataTS = (k, v) => {
|
|
14
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
15
|
+
return Reflect.metadata(k, v);
|
|
16
|
+
};
|
|
17
|
+
// packages/schedule/src/cron-parser.ts
|
|
18
|
+
var FIELD_RANGES = [
|
|
19
|
+
[0, 59],
|
|
20
|
+
[0, 23],
|
|
21
|
+
[1, 31],
|
|
22
|
+
[1, 12],
|
|
23
|
+
[0, 7]
|
|
24
|
+
];
|
|
25
|
+
var FIELD_NAMES = {
|
|
26
|
+
JAN: 1,
|
|
27
|
+
FEB: 2,
|
|
28
|
+
MAR: 3,
|
|
29
|
+
APR: 4,
|
|
30
|
+
MAY: 5,
|
|
31
|
+
JUN: 6,
|
|
32
|
+
JUL: 7,
|
|
33
|
+
AUG: 8,
|
|
34
|
+
SEP: 9,
|
|
35
|
+
OCT: 10,
|
|
36
|
+
NOV: 11,
|
|
37
|
+
DEC: 12,
|
|
38
|
+
SUN: 0,
|
|
39
|
+
MON: 1,
|
|
40
|
+
TUE: 2,
|
|
41
|
+
WED: 3,
|
|
42
|
+
THU: 4,
|
|
43
|
+
FRI: 5,
|
|
44
|
+
SAT: 6
|
|
45
|
+
};
|
|
46
|
+
var ALIASES = {
|
|
47
|
+
"@yearly": "0 0 1 1 *",
|
|
48
|
+
"@annually": "0 0 1 1 *",
|
|
49
|
+
"@monthly": "0 0 1 * *",
|
|
50
|
+
"@weekly": "0 0 * * 0",
|
|
51
|
+
"@daily": "0 0 * * *",
|
|
52
|
+
"@midnight": "0 0 * * *",
|
|
53
|
+
"@hourly": "0 * * * *"
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
class CronField {
|
|
57
|
+
values;
|
|
58
|
+
constructor(field, range) {
|
|
59
|
+
this.values = parseField(field, range);
|
|
60
|
+
}
|
|
61
|
+
contains(n) {
|
|
62
|
+
return this.values.has(n);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
class CronExpression {
|
|
67
|
+
fields;
|
|
68
|
+
hasSeconds;
|
|
69
|
+
constructor(raw) {
|
|
70
|
+
const expanded = expandAlias(raw);
|
|
71
|
+
const every = expandEvery(expanded);
|
|
72
|
+
if (every) {
|
|
73
|
+
this.hasSeconds = true;
|
|
74
|
+
this.fields = everyToFields(every);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const parts = expanded.trim().split(/\s+/);
|
|
78
|
+
if (parts.length === 5) {
|
|
79
|
+
this.hasSeconds = false;
|
|
80
|
+
this.fields = parts.map((p, i) => new CronField(p, FIELD_RANGES[i]));
|
|
81
|
+
} else if (parts.length === 6) {
|
|
82
|
+
this.hasSeconds = true;
|
|
83
|
+
const sec = [0, 59];
|
|
84
|
+
this.fields = [
|
|
85
|
+
new CronField(parts[0], sec),
|
|
86
|
+
...parts.slice(1).map((p, i) => new CronField(p, FIELD_RANGES[i]))
|
|
87
|
+
];
|
|
88
|
+
} else {
|
|
89
|
+
throw new Error(`Invalid cron expression: "${raw}" (expected 5 or 6 fields, got ${parts.length})`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
next(from, maxYears = 5) {
|
|
93
|
+
const cap = new Date(from.getTime() + maxYears * 365 * 24 * 60 * 60 * 1000);
|
|
94
|
+
let cur = new Date(from.getTime() + 1000);
|
|
95
|
+
cur.setMilliseconds(0);
|
|
96
|
+
let safety = 0;
|
|
97
|
+
while (cur <= cap) {
|
|
98
|
+
if (this.matches(cur)) {
|
|
99
|
+
return cur;
|
|
100
|
+
}
|
|
101
|
+
if (!this.fields[this.hasSeconds ? 4 : 3].contains(cur.getMonth() + 1)) {
|
|
102
|
+
cur = new Date(cur.getFullYear(), cur.getMonth() + 1, 1, 0, 0, 0, 0);
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
const domIdx = this.hasSeconds ? 3 : 2;
|
|
106
|
+
const domField = this.fields[domIdx];
|
|
107
|
+
if (!domField.contains(cur.getDate())) {
|
|
108
|
+
const sortedDays = [...domField.values].sort((a, b) => a - b);
|
|
109
|
+
const nextDay = sortedDays.find((d) => d >= cur.getDate());
|
|
110
|
+
if (nextDay !== undefined) {
|
|
111
|
+
cur = new Date(cur.getFullYear(), cur.getMonth(), nextDay, 0, 0, 0, 0);
|
|
112
|
+
} else {
|
|
113
|
+
cur = new Date(cur.getFullYear(), cur.getMonth() + 1, sortedDays[0], 0, 0, 0, 0);
|
|
114
|
+
}
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
if (!this.fields[this.hasSeconds ? 2 : 1].contains(cur.getHours())) {
|
|
118
|
+
cur = new Date(cur.getFullYear(), cur.getMonth(), cur.getDate(), cur.getHours() + 1, 0, 0, 0);
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
if (!this.fields[this.hasSeconds ? 1 : 0].contains(cur.getMinutes())) {
|
|
122
|
+
cur = new Date(cur.getFullYear(), cur.getMonth(), cur.getDate(), cur.getHours(), cur.getMinutes() + 1, 0, 0);
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (this.hasSeconds && !this.fields[0].contains(cur.getSeconds())) {
|
|
126
|
+
cur = new Date(cur.getTime() + 1000);
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
cur = new Date(cur.getTime() + 1000);
|
|
130
|
+
if (++safety > 1e6)
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
matches(d) {
|
|
136
|
+
const fields = this.hasSeconds ? [
|
|
137
|
+
d.getSeconds(),
|
|
138
|
+
d.getMinutes(),
|
|
139
|
+
d.getHours(),
|
|
140
|
+
d.getDate(),
|
|
141
|
+
d.getMonth() + 1,
|
|
142
|
+
d.getDay()
|
|
143
|
+
] : [
|
|
144
|
+
d.getMinutes(),
|
|
145
|
+
d.getHours(),
|
|
146
|
+
d.getDate(),
|
|
147
|
+
d.getMonth() + 1,
|
|
148
|
+
d.getDay()
|
|
149
|
+
];
|
|
150
|
+
const domField = this.fields[this.hasSeconds ? 3 : 2];
|
|
151
|
+
const dowField = this.fields[this.hasSeconds ? 4 : 3];
|
|
152
|
+
const isWildDom = domField.values.size === FIELD_RANGES[2][1];
|
|
153
|
+
const isWildDow = dowField.values.size === FIELD_RANGES[4][1] + 1;
|
|
154
|
+
const dayMatch = isWildDom || isWildDow ? domField.contains(d.getDate()) || dowField.contains(d.getDay()) : domField.contains(d.getDate()) || dowField.contains(d.getDay());
|
|
155
|
+
for (let i = 0;i < this.fields.length; i++) {
|
|
156
|
+
if (i === (this.hasSeconds ? 3 : 2))
|
|
157
|
+
continue;
|
|
158
|
+
if (!this.fields[i].contains(fields[i]))
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
return dayMatch;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function expandAlias(raw) {
|
|
165
|
+
const trimmed = raw.trim();
|
|
166
|
+
const alias = ALIASES[trimmed.toLowerCase()];
|
|
167
|
+
return alias ?? trimmed;
|
|
168
|
+
}
|
|
169
|
+
function expandEvery(raw) {
|
|
170
|
+
const m = /^@every\s+(\d+)\s*(s|m|h|d)?$/i.exec(raw.trim());
|
|
171
|
+
if (!m)
|
|
172
|
+
return null;
|
|
173
|
+
const n = Number(m[1]);
|
|
174
|
+
const unit = (m[2] ?? "s").toLowerCase();
|
|
175
|
+
switch (unit) {
|
|
176
|
+
case "s":
|
|
177
|
+
return n * 1000;
|
|
178
|
+
case "m":
|
|
179
|
+
return n * 60 * 1000;
|
|
180
|
+
case "h":
|
|
181
|
+
return n * 60 * 60 * 1000;
|
|
182
|
+
case "d":
|
|
183
|
+
return n * 24 * 60 * 60 * 1000;
|
|
184
|
+
}
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
function everyToFields(intervalMs) {
|
|
188
|
+
const seconds = Math.floor(intervalMs / 1000);
|
|
189
|
+
if (seconds < 60) {
|
|
190
|
+
if (60 % seconds === 0) {
|
|
191
|
+
return [
|
|
192
|
+
new CronField(`*/${seconds}`, [0, 59]),
|
|
193
|
+
new CronField("*", [0, 59]),
|
|
194
|
+
new CronField("*", [0, 23]),
|
|
195
|
+
new CronField("*", [1, 31]),
|
|
196
|
+
new CronField("*", [1, 12]),
|
|
197
|
+
new CronField("*", [0, 7])
|
|
198
|
+
];
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return [
|
|
202
|
+
new CronField("0", [0, 59]),
|
|
203
|
+
new CronField("*", [0, 59]),
|
|
204
|
+
new CronField("*", [0, 23]),
|
|
205
|
+
new CronField("*", [1, 31]),
|
|
206
|
+
new CronField("*", [1, 12]),
|
|
207
|
+
new CronField("*", [0, 7])
|
|
208
|
+
];
|
|
209
|
+
}
|
|
210
|
+
function parseField(field, range) {
|
|
211
|
+
const out = new Set;
|
|
212
|
+
const [lo, hi] = range;
|
|
213
|
+
const parts = field.split(",");
|
|
214
|
+
for (const partRaw of parts) {
|
|
215
|
+
const part = partRaw.trim();
|
|
216
|
+
const stepMatch = /^(.+?)\/(\d+)$/.exec(part);
|
|
217
|
+
let base = part;
|
|
218
|
+
let step = 1;
|
|
219
|
+
if (stepMatch) {
|
|
220
|
+
base = stepMatch[1];
|
|
221
|
+
step = Number(stepMatch[2]);
|
|
222
|
+
}
|
|
223
|
+
let start;
|
|
224
|
+
let end;
|
|
225
|
+
if (base === "*") {
|
|
226
|
+
start = lo;
|
|
227
|
+
end = hi;
|
|
228
|
+
} else if (base.includes("-")) {
|
|
229
|
+
const [a, b] = base.split("-").map((s) => resolveValue(s, lo, hi));
|
|
230
|
+
start = a;
|
|
231
|
+
end = b;
|
|
232
|
+
} else {
|
|
233
|
+
const v = resolveValue(base, lo, hi);
|
|
234
|
+
start = v;
|
|
235
|
+
end = stepMatch ? hi : v;
|
|
236
|
+
}
|
|
237
|
+
if (start > end) {
|
|
238
|
+
throw new Error(`Invalid range in cron field: "${part}"`);
|
|
239
|
+
}
|
|
240
|
+
for (let i = start;i <= end; i += step) {
|
|
241
|
+
out.add(i);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return out;
|
|
245
|
+
}
|
|
246
|
+
function resolveValue(token, lo, hi) {
|
|
247
|
+
const t = token.trim();
|
|
248
|
+
if (t === "*")
|
|
249
|
+
return lo;
|
|
250
|
+
const named = FIELD_NAMES[t.toUpperCase()];
|
|
251
|
+
if (named !== undefined)
|
|
252
|
+
return named;
|
|
253
|
+
const n = Number(t);
|
|
254
|
+
if (Number.isNaN(n)) {
|
|
255
|
+
throw new Error(`Invalid cron field value: "${token}"`);
|
|
256
|
+
}
|
|
257
|
+
if (n < lo || n > hi) {
|
|
258
|
+
throw new Error(`Cron value ${n} out of range [${lo}, ${hi}]`);
|
|
259
|
+
}
|
|
260
|
+
return n;
|
|
261
|
+
}
|
|
262
|
+
function parseCron(expression) {
|
|
263
|
+
return new CronExpression(expression);
|
|
264
|
+
}
|
|
265
|
+
function nextCron(expression, from = new Date) {
|
|
266
|
+
return parseCron(expression).next(from);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// packages/schedule/src/backends/memory.ts
|
|
270
|
+
class MemorySchedulesBackend {
|
|
271
|
+
#tasks = new Map;
|
|
272
|
+
#byName = new Map;
|
|
273
|
+
#listeners = new Set;
|
|
274
|
+
#tickHandle = null;
|
|
275
|
+
#tickMs;
|
|
276
|
+
#maxDriftMs;
|
|
277
|
+
#defaultTimezone = undefined;
|
|
278
|
+
#nextId = 1;
|
|
279
|
+
constructor(options = {}) {
|
|
280
|
+
this.#tickMs = options.tickMs ?? 1000;
|
|
281
|
+
this.#maxDriftMs = options.maxDriftMs ?? 60000;
|
|
282
|
+
this.#defaultTimezone = options.defaultTimezone;
|
|
283
|
+
}
|
|
284
|
+
addCron(name, expression, handler, options = {}) {
|
|
285
|
+
const id = this.#allocateId();
|
|
286
|
+
const next = nextCron(expression, options.runOnInit ? new Date(Date.now() - 1000) : new Date);
|
|
287
|
+
const task = {
|
|
288
|
+
id,
|
|
289
|
+
name,
|
|
290
|
+
kind: "cron",
|
|
291
|
+
expression,
|
|
292
|
+
nextRunAt: next?.getTime() ?? Date.now() + 60000,
|
|
293
|
+
invocations: 0,
|
|
294
|
+
status: "running",
|
|
295
|
+
handler
|
|
296
|
+
};
|
|
297
|
+
this.#tasks.set(id, task);
|
|
298
|
+
this.#byName.set(name, id);
|
|
299
|
+
this.#emit({
|
|
300
|
+
kind: "task:registered",
|
|
301
|
+
id,
|
|
302
|
+
name,
|
|
303
|
+
taskKind: "cron",
|
|
304
|
+
expression
|
|
305
|
+
});
|
|
306
|
+
return id;
|
|
307
|
+
}
|
|
308
|
+
addInterval(name, ms, handler) {
|
|
309
|
+
const id = this.#allocateId();
|
|
310
|
+
const task = {
|
|
311
|
+
id,
|
|
312
|
+
name,
|
|
313
|
+
kind: "interval",
|
|
314
|
+
expression: `${ms}ms`,
|
|
315
|
+
nextRunAt: Date.now() + ms,
|
|
316
|
+
invocations: 0,
|
|
317
|
+
status: "running",
|
|
318
|
+
handler
|
|
319
|
+
};
|
|
320
|
+
task.timer = setInterval(() => this.#runTask(id), ms);
|
|
321
|
+
this.#tasks.set(id, task);
|
|
322
|
+
this.#byName.set(name, id);
|
|
323
|
+
this.#emit({
|
|
324
|
+
kind: "task:registered",
|
|
325
|
+
id,
|
|
326
|
+
name,
|
|
327
|
+
taskKind: "interval",
|
|
328
|
+
expression: `${ms}ms`
|
|
329
|
+
});
|
|
330
|
+
return id;
|
|
331
|
+
}
|
|
332
|
+
addTimeout(name, ms, handler) {
|
|
333
|
+
const id = this.#allocateId();
|
|
334
|
+
const task = {
|
|
335
|
+
id,
|
|
336
|
+
name,
|
|
337
|
+
kind: "timeout",
|
|
338
|
+
expression: `${ms}ms`,
|
|
339
|
+
nextRunAt: Date.now() + ms,
|
|
340
|
+
invocations: 0,
|
|
341
|
+
status: "running",
|
|
342
|
+
handler
|
|
343
|
+
};
|
|
344
|
+
task.timer = setTimeout(() => this.#runOnceAndRemove(id), ms);
|
|
345
|
+
this.#tasks.set(id, task);
|
|
346
|
+
this.#byName.set(name, id);
|
|
347
|
+
this.#emit({
|
|
348
|
+
kind: "task:registered",
|
|
349
|
+
id,
|
|
350
|
+
name,
|
|
351
|
+
taskKind: "timeout",
|
|
352
|
+
expression: `${ms}ms`
|
|
353
|
+
});
|
|
354
|
+
return id;
|
|
355
|
+
}
|
|
356
|
+
delete(idOrName) {
|
|
357
|
+
const id = this.#resolveId(idOrName);
|
|
358
|
+
if (!id)
|
|
359
|
+
return false;
|
|
360
|
+
const task = this.#tasks.get(id);
|
|
361
|
+
if (!task)
|
|
362
|
+
return false;
|
|
363
|
+
this.#clearTimer(task);
|
|
364
|
+
this.#tasks.delete(id);
|
|
365
|
+
this.#byName.delete(task.name);
|
|
366
|
+
this.#emit({ kind: "task:deleted", id });
|
|
367
|
+
return true;
|
|
368
|
+
}
|
|
369
|
+
list() {
|
|
370
|
+
return [...this.#tasks.values()].map((t) => this.#toPublic(t));
|
|
371
|
+
}
|
|
372
|
+
get(idOrName) {
|
|
373
|
+
const id = this.#resolveId(idOrName);
|
|
374
|
+
if (!id)
|
|
375
|
+
return;
|
|
376
|
+
const task = this.#tasks.get(id);
|
|
377
|
+
return task ? this.#toPublic(task) : undefined;
|
|
378
|
+
}
|
|
379
|
+
pause(idOrName) {
|
|
380
|
+
const id = this.#resolveId(idOrName);
|
|
381
|
+
if (!id)
|
|
382
|
+
return false;
|
|
383
|
+
const task = this.#tasks.get(id);
|
|
384
|
+
if (!task)
|
|
385
|
+
return false;
|
|
386
|
+
this.#clearTimer(task);
|
|
387
|
+
task.status = "paused";
|
|
388
|
+
this.#emit({ kind: "task:paused", id });
|
|
389
|
+
return true;
|
|
390
|
+
}
|
|
391
|
+
resume(idOrName) {
|
|
392
|
+
const id = this.#resolveId(idOrName);
|
|
393
|
+
if (!id)
|
|
394
|
+
return false;
|
|
395
|
+
const task = this.#tasks.get(id);
|
|
396
|
+
if (!task)
|
|
397
|
+
return false;
|
|
398
|
+
if (task.kind === "interval" && !task.timer) {
|
|
399
|
+
task.timer = setInterval(() => this.#runTask(id), Number(task.expression.replace("ms", "")));
|
|
400
|
+
}
|
|
401
|
+
task.status = "running";
|
|
402
|
+
this.#emit({ kind: "task:resumed", id });
|
|
403
|
+
return true;
|
|
404
|
+
}
|
|
405
|
+
async stop() {
|
|
406
|
+
for (const task of this.#tasks.values()) {
|
|
407
|
+
this.#clearTimer(task);
|
|
408
|
+
}
|
|
409
|
+
this.#tasks.clear();
|
|
410
|
+
this.#byName.clear();
|
|
411
|
+
if (this.#tickHandle)
|
|
412
|
+
clearInterval(this.#tickHandle);
|
|
413
|
+
this.#tickHandle = null;
|
|
414
|
+
}
|
|
415
|
+
on(listener) {
|
|
416
|
+
this.#listeners.add(listener);
|
|
417
|
+
return () => this.#listeners.delete(listener);
|
|
418
|
+
}
|
|
419
|
+
start() {
|
|
420
|
+
if (this.#tickHandle)
|
|
421
|
+
return;
|
|
422
|
+
this.#tickHandle = setInterval(() => this.#tick(), this.#tickMs);
|
|
423
|
+
const handle = this.#tickHandle;
|
|
424
|
+
if (typeof handle.unref === "function")
|
|
425
|
+
handle.unref();
|
|
426
|
+
}
|
|
427
|
+
#allocateId() {
|
|
428
|
+
return `sched-${this.#nextId++}`;
|
|
429
|
+
}
|
|
430
|
+
#resolveId(idOrName) {
|
|
431
|
+
if (this.#tasks.has(idOrName))
|
|
432
|
+
return idOrName;
|
|
433
|
+
return this.#byName.get(idOrName) ?? null;
|
|
434
|
+
}
|
|
435
|
+
#toPublic(t) {
|
|
436
|
+
const public_ = {
|
|
437
|
+
id: t.id,
|
|
438
|
+
name: t.name,
|
|
439
|
+
kind: t.kind,
|
|
440
|
+
expression: t.expression,
|
|
441
|
+
status: t.status,
|
|
442
|
+
invocations: t.invocations
|
|
443
|
+
};
|
|
444
|
+
if (t.lastRunAt !== undefined) {
|
|
445
|
+
public_.lastRunAt = new Date(t.lastRunAt).toISOString();
|
|
446
|
+
}
|
|
447
|
+
public_.nextRunAt = new Date(t.nextRunAt).toISOString();
|
|
448
|
+
if (t.lastError !== undefined)
|
|
449
|
+
public_.lastError = t.lastError;
|
|
450
|
+
return public_;
|
|
451
|
+
}
|
|
452
|
+
#clearTimer(task) {
|
|
453
|
+
if (task.timer) {
|
|
454
|
+
clearInterval(task.timer);
|
|
455
|
+
clearTimeout(task.timer);
|
|
456
|
+
task.timer = undefined;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
#tick() {
|
|
460
|
+
const now = Date.now();
|
|
461
|
+
for (const [id, task] of this.#tasks) {
|
|
462
|
+
if (task.status !== "running")
|
|
463
|
+
continue;
|
|
464
|
+
if (task.kind !== "cron")
|
|
465
|
+
continue;
|
|
466
|
+
if (task.nextRunAt > now)
|
|
467
|
+
continue;
|
|
468
|
+
this.#runTask(id);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
async#runTask(id) {
|
|
472
|
+
const task = this.#tasks.get(id);
|
|
473
|
+
if (!task)
|
|
474
|
+
return;
|
|
475
|
+
const startedAt = new Date;
|
|
476
|
+
this.#emit({
|
|
477
|
+
kind: "task:invoked",
|
|
478
|
+
id,
|
|
479
|
+
name: task.name,
|
|
480
|
+
startedAt: startedAt.toISOString()
|
|
481
|
+
});
|
|
482
|
+
const start = Date.now();
|
|
483
|
+
try {
|
|
484
|
+
const result = await task.handler();
|
|
485
|
+
task.invocations++;
|
|
486
|
+
task.lastRunAt = start;
|
|
487
|
+
task.lastError = undefined;
|
|
488
|
+
this.#emit({
|
|
489
|
+
kind: "task:completed",
|
|
490
|
+
id,
|
|
491
|
+
name: task.name,
|
|
492
|
+
durationMs: Date.now() - start,
|
|
493
|
+
returnvalue: result
|
|
494
|
+
});
|
|
495
|
+
} catch (err) {
|
|
496
|
+
task.invocations++;
|
|
497
|
+
task.lastRunAt = start;
|
|
498
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
499
|
+
task.lastError = error.message;
|
|
500
|
+
this.#emit({ kind: "task:failed", id, name: task.name, error });
|
|
501
|
+
} finally {
|
|
502
|
+
if (task.kind === "cron" && task.status === "running") {
|
|
503
|
+
const next = nextCron(task.expression, new Date);
|
|
504
|
+
if (next) {
|
|
505
|
+
const drift = next.getTime() - Date.now();
|
|
506
|
+
task.nextRunAt = drift > this.#maxDriftMs ? Date.now() + 60000 : next.getTime();
|
|
507
|
+
} else {
|
|
508
|
+
task.nextRunAt = Date.now() + 60000;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
#runOnceAndRemove(id) {
|
|
514
|
+
this.#runTask(id);
|
|
515
|
+
const task = this.#tasks.get(id);
|
|
516
|
+
if (task) {
|
|
517
|
+
this.#tasks.delete(id);
|
|
518
|
+
this.#byName.delete(task.name);
|
|
519
|
+
this.#emit({ kind: "task:deleted", id });
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
#emit(event) {
|
|
523
|
+
for (const l of this.#listeners) {
|
|
524
|
+
Promise.resolve(l(event));
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
// packages/schedule/src/backends/cloudflare.ts
|
|
529
|
+
class CloudflareSchedulesBackend {
|
|
530
|
+
#tasks = new Map;
|
|
531
|
+
#byName = new Map;
|
|
532
|
+
#listeners = new Set;
|
|
533
|
+
#nextId = 1;
|
|
534
|
+
#validate;
|
|
535
|
+
constructor(options = {}) {
|
|
536
|
+
this.#validate = options.validateAgainstTrigger ?? true;
|
|
537
|
+
}
|
|
538
|
+
addCron(name, expression, handler, options = {}) {
|
|
539
|
+
const id = `sched-${this.#nextId++}`;
|
|
540
|
+
this.#tasks.set(id, { id, name, expression, handler, options });
|
|
541
|
+
this.#byName.set(name, id);
|
|
542
|
+
this.#emit({
|
|
543
|
+
kind: "task:registered",
|
|
544
|
+
id,
|
|
545
|
+
name,
|
|
546
|
+
taskKind: "cron",
|
|
547
|
+
expression
|
|
548
|
+
});
|
|
549
|
+
return id;
|
|
550
|
+
}
|
|
551
|
+
addInterval() {
|
|
552
|
+
throw new Error("[schedule/cloudflare] setInterval is not supported on Workers. " + "Use @Cron with a short interval or use the memory backend for in-process scheduling.");
|
|
553
|
+
}
|
|
554
|
+
addTimeout() {
|
|
555
|
+
throw new Error("[schedule/cloudflare] setTimeout is not supported on Workers. " + 'Use @Cron with a delay (e.g. "@every 30s") or run the work from a request handler.');
|
|
556
|
+
}
|
|
557
|
+
delete(idOrName) {
|
|
558
|
+
const id = this.#resolveId(idOrName);
|
|
559
|
+
if (!id)
|
|
560
|
+
return false;
|
|
561
|
+
const task = this.#tasks.get(id);
|
|
562
|
+
if (!task)
|
|
563
|
+
return false;
|
|
564
|
+
this.#tasks.delete(id);
|
|
565
|
+
this.#byName.delete(task.name);
|
|
566
|
+
this.#emit({ kind: "task:deleted", id });
|
|
567
|
+
return true;
|
|
568
|
+
}
|
|
569
|
+
list() {
|
|
570
|
+
return [...this.#tasks.values()].map((t) => ({
|
|
571
|
+
id: t.id,
|
|
572
|
+
name: t.name,
|
|
573
|
+
kind: "cron",
|
|
574
|
+
expression: t.expression,
|
|
575
|
+
status: "running",
|
|
576
|
+
invocations: 0
|
|
577
|
+
}));
|
|
578
|
+
}
|
|
579
|
+
get(idOrName) {
|
|
580
|
+
const id = this.#resolveId(idOrName);
|
|
581
|
+
if (!id)
|
|
582
|
+
return;
|
|
583
|
+
const t = this.#tasks.get(id);
|
|
584
|
+
return t ? {
|
|
585
|
+
id: t.id,
|
|
586
|
+
name: t.name,
|
|
587
|
+
kind: "cron",
|
|
588
|
+
expression: t.expression,
|
|
589
|
+
status: "running",
|
|
590
|
+
invocations: 0
|
|
591
|
+
} : undefined;
|
|
592
|
+
}
|
|
593
|
+
pause() {
|
|
594
|
+
return false;
|
|
595
|
+
}
|
|
596
|
+
resume() {
|
|
597
|
+
return false;
|
|
598
|
+
}
|
|
599
|
+
async stop() {
|
|
600
|
+
this.#tasks.clear();
|
|
601
|
+
this.#byName.clear();
|
|
602
|
+
}
|
|
603
|
+
on(listener) {
|
|
604
|
+
this.#listeners.add(listener);
|
|
605
|
+
return () => this.#listeners.delete(listener);
|
|
606
|
+
}
|
|
607
|
+
scheduledHandler() {
|
|
608
|
+
return async (event) => {
|
|
609
|
+
for (const task of this.#tasks.values()) {
|
|
610
|
+
if (this.#validate && task.expression !== event.cron)
|
|
611
|
+
continue;
|
|
612
|
+
await this.#dispatch(task, event);
|
|
613
|
+
}
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
async#dispatch(task, event) {
|
|
617
|
+
const startedAt = new Date;
|
|
618
|
+
this.#emit({
|
|
619
|
+
kind: "task:invoked",
|
|
620
|
+
id: task.id,
|
|
621
|
+
name: task.name,
|
|
622
|
+
startedAt: startedAt.toISOString()
|
|
623
|
+
});
|
|
624
|
+
try {
|
|
625
|
+
const result = await task.handler();
|
|
626
|
+
this.#emit({
|
|
627
|
+
kind: "task:completed",
|
|
628
|
+
id: task.id,
|
|
629
|
+
name: task.name,
|
|
630
|
+
durationMs: Date.now() - startedAt.getTime(),
|
|
631
|
+
returnvalue: result
|
|
632
|
+
});
|
|
633
|
+
} catch (err) {
|
|
634
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
635
|
+
this.#emit({ kind: "task:failed", id: task.id, name: task.name, error });
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
#resolveId(idOrName) {
|
|
639
|
+
if (this.#tasks.has(idOrName))
|
|
640
|
+
return idOrName;
|
|
641
|
+
return this.#byName.get(idOrName) ?? null;
|
|
642
|
+
}
|
|
643
|
+
#emit(event) {
|
|
644
|
+
for (const l of this.#listeners) {
|
|
645
|
+
Promise.resolve(l(event));
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
// packages/schedule/src/schedule.service.ts
|
|
650
|
+
import { Inject, Injectable } from "@nexusts/core/src/decorators/index.js";
|
|
651
|
+
class ScheduleService {
|
|
652
|
+
config;
|
|
653
|
+
static TOKEN = Symbol.for("nexus:ScheduleService");
|
|
654
|
+
registry;
|
|
655
|
+
#listeners = new Set;
|
|
656
|
+
#started = false;
|
|
657
|
+
#memoryBackend = null;
|
|
658
|
+
constructor(config = {}) {
|
|
659
|
+
this.config = config;
|
|
660
|
+
this.registry = this.#createBackend(config);
|
|
661
|
+
}
|
|
662
|
+
addCron(expression, handler, options = {}) {
|
|
663
|
+
const name = options.name ?? `cron-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
|
|
664
|
+
return this.registry.addCron(name, expression, handler, options);
|
|
665
|
+
}
|
|
666
|
+
addInterval(milliseconds, handler, name) {
|
|
667
|
+
return this.registry.addInterval(name ?? `interval-${Date.now()}`, milliseconds, handler);
|
|
668
|
+
}
|
|
669
|
+
addTimeout(milliseconds, handler, name) {
|
|
670
|
+
return this.registry.addTimeout(name ?? `timeout-${Date.now()}`, milliseconds, handler);
|
|
671
|
+
}
|
|
672
|
+
list() {
|
|
673
|
+
return this.registry.list();
|
|
674
|
+
}
|
|
675
|
+
get(idOrName) {
|
|
676
|
+
return this.registry.get(idOrName);
|
|
677
|
+
}
|
|
678
|
+
pause(idOrName) {
|
|
679
|
+
return this.registry.pause(idOrName);
|
|
680
|
+
}
|
|
681
|
+
resume(idOrName) {
|
|
682
|
+
return this.registry.resume(idOrName);
|
|
683
|
+
}
|
|
684
|
+
delete(idOrName) {
|
|
685
|
+
return this.registry.delete(idOrName);
|
|
686
|
+
}
|
|
687
|
+
on(listener) {
|
|
688
|
+
this.#listeners.add(listener);
|
|
689
|
+
return () => this.#listeners.delete(listener);
|
|
690
|
+
}
|
|
691
|
+
start() {
|
|
692
|
+
if (this.#started)
|
|
693
|
+
return;
|
|
694
|
+
this.#started = true;
|
|
695
|
+
if (this.#memoryBackend) {
|
|
696
|
+
this.#memoryBackend.start();
|
|
697
|
+
}
|
|
698
|
+
this.registry.on((event) => this.#broadcast(event));
|
|
699
|
+
}
|
|
700
|
+
async stop() {
|
|
701
|
+
if (!this.#started)
|
|
702
|
+
return;
|
|
703
|
+
this.#started = false;
|
|
704
|
+
await this.registry.stop();
|
|
705
|
+
}
|
|
706
|
+
getMemoryBackend() {
|
|
707
|
+
return this.#memoryBackend;
|
|
708
|
+
}
|
|
709
|
+
getCloudflareBackend() {
|
|
710
|
+
return this.registry instanceof CloudflareSchedulesBackend ? this.registry : null;
|
|
711
|
+
}
|
|
712
|
+
#createBackend(config) {
|
|
713
|
+
switch (config.backend ?? "memory") {
|
|
714
|
+
case "memory": {
|
|
715
|
+
const backend = new MemorySchedulesBackend({
|
|
716
|
+
tickMs: config.memory?.tickMs ?? 1000,
|
|
717
|
+
maxDriftMs: config.memory?.maxDriftMs,
|
|
718
|
+
defaultTimezone: config.defaultTimezone
|
|
719
|
+
});
|
|
720
|
+
this.#memoryBackend = backend;
|
|
721
|
+
return backend;
|
|
722
|
+
}
|
|
723
|
+
case "cloudflare":
|
|
724
|
+
return new CloudflareSchedulesBackend;
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
#broadcast(event) {
|
|
728
|
+
for (const l of this.#listeners) {
|
|
729
|
+
Promise.resolve(l(event));
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
ScheduleService = __legacyDecorateClassTS([
|
|
734
|
+
Injectable(),
|
|
735
|
+
__legacyDecorateParamTS(0, Inject("SCHEDULE_CONFIG")),
|
|
736
|
+
__legacyMetadataTS("design:paramtypes", [
|
|
737
|
+
typeof ScheduleConfig === "undefined" ? Object : ScheduleConfig
|
|
738
|
+
])
|
|
739
|
+
], ScheduleService);
|
|
740
|
+
// packages/schedule/src/schedule.module.ts
|
|
741
|
+
import"reflect-metadata";
|
|
742
|
+
import { Module } from "@nexusts/core/decorators/module.js";
|
|
743
|
+
class ScheduleModule {
|
|
744
|
+
static forRoot(config = {}) {
|
|
745
|
+
class ConfiguredScheduleModule {
|
|
746
|
+
}
|
|
747
|
+
ConfiguredScheduleModule = __legacyDecorateClassTS([
|
|
748
|
+
Module({
|
|
749
|
+
providers: [
|
|
750
|
+
ScheduleService,
|
|
751
|
+
{ provide: ScheduleService.TOKEN, useExisting: ScheduleService },
|
|
752
|
+
{ provide: "SCHEDULE_CONFIG", useValue: config }
|
|
753
|
+
],
|
|
754
|
+
exports: [ScheduleService, ScheduleService.TOKEN]
|
|
755
|
+
})
|
|
756
|
+
], ConfiguredScheduleModule);
|
|
757
|
+
Object.defineProperty(ConfiguredScheduleModule, "name", {
|
|
758
|
+
value: "ConfiguredScheduleModule"
|
|
759
|
+
});
|
|
760
|
+
return ConfiguredScheduleModule;
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
ScheduleModule = __legacyDecorateClassTS([
|
|
764
|
+
Module({
|
|
765
|
+
providers: [
|
|
766
|
+
ScheduleService,
|
|
767
|
+
{ provide: ScheduleService.TOKEN, useExisting: ScheduleService }
|
|
768
|
+
],
|
|
769
|
+
exports: [ScheduleService, ScheduleService.TOKEN]
|
|
770
|
+
})
|
|
771
|
+
], ScheduleModule);
|
|
772
|
+
// packages/schedule/src/decorators/cron.ts
|
|
773
|
+
import"reflect-metadata";
|
|
774
|
+
var CRON_META = "nexus:schedule:cron";
|
|
775
|
+
var INTERVAL_META = "nexus:schedule:interval";
|
|
776
|
+
var TIMEOUT_META = "nexus:schedule:timeout";
|
|
777
|
+
function Cron(expression, options = {}) {
|
|
778
|
+
return (target, propertyKey, descriptor) => {
|
|
779
|
+
if (!descriptor || typeof descriptor.value !== "function") {
|
|
780
|
+
throw new Error("@Cron can only decorate methods.");
|
|
781
|
+
}
|
|
782
|
+
const ctor = target.constructor;
|
|
783
|
+
const hooks = Reflect.getMetadata(CRON_META, ctor) ?? [];
|
|
784
|
+
hooks.push({ method: String(propertyKey), expression, options });
|
|
785
|
+
Reflect.defineMetadata(CRON_META, hooks, ctor);
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
function Interval(milliseconds, name) {
|
|
789
|
+
return (target, propertyKey, descriptor) => {
|
|
790
|
+
if (!descriptor || typeof descriptor.value !== "function") {
|
|
791
|
+
throw new Error("@Interval can only decorate methods.");
|
|
792
|
+
}
|
|
793
|
+
const ctor = target.constructor;
|
|
794
|
+
const hooks = Reflect.getMetadata(INTERVAL_META, ctor) ?? [];
|
|
795
|
+
hooks.push({ method: String(propertyKey), milliseconds, name });
|
|
796
|
+
Reflect.defineMetadata(INTERVAL_META, hooks, ctor);
|
|
797
|
+
};
|
|
798
|
+
}
|
|
799
|
+
function Timeout(milliseconds, name) {
|
|
800
|
+
return (target, propertyKey, descriptor) => {
|
|
801
|
+
if (!descriptor || typeof descriptor.value !== "function") {
|
|
802
|
+
throw new Error("@Timeout can only decorate methods.");
|
|
803
|
+
}
|
|
804
|
+
const ctor = target.constructor;
|
|
805
|
+
const hooks = Reflect.getMetadata(TIMEOUT_META, ctor) ?? [];
|
|
806
|
+
hooks.push({ method: String(propertyKey), milliseconds, name });
|
|
807
|
+
Reflect.defineMetadata(TIMEOUT_META, hooks, ctor);
|
|
808
|
+
};
|
|
809
|
+
}
|
|
810
|
+
function getCronHooks(target) {
|
|
811
|
+
const ctor = target.constructor ?? target;
|
|
812
|
+
return Reflect.getMetadata(CRON_META, ctor) ?? [];
|
|
813
|
+
}
|
|
814
|
+
function getIntervalHooks(target) {
|
|
815
|
+
const ctor = target.constructor ?? target;
|
|
816
|
+
return Reflect.getMetadata(INTERVAL_META, ctor) ?? [];
|
|
817
|
+
}
|
|
818
|
+
function getTimeoutHooks(target) {
|
|
819
|
+
const ctor = target.constructor ?? target;
|
|
820
|
+
return Reflect.getMetadata(TIMEOUT_META, ctor) ?? [];
|
|
821
|
+
}
|
|
822
|
+
async function scanForSchedulers(instance, service) {
|
|
823
|
+
const ids = [];
|
|
824
|
+
for (const h of getCronHooks(instance)) {
|
|
825
|
+
const fn = instance[h.method];
|
|
826
|
+
if (typeof fn !== "function")
|
|
827
|
+
continue;
|
|
828
|
+
const id = service.addCron(h.expression, fn.bind(instance), {
|
|
829
|
+
...h.options,
|
|
830
|
+
name: h.options.name ?? `${instance.constructor.name}.${h.method}`
|
|
831
|
+
});
|
|
832
|
+
ids.push(id);
|
|
833
|
+
}
|
|
834
|
+
for (const h of getIntervalHooks(instance)) {
|
|
835
|
+
const fn = instance[h.method];
|
|
836
|
+
if (typeof fn !== "function")
|
|
837
|
+
continue;
|
|
838
|
+
const id = service.addInterval(h.milliseconds, fn.bind(instance), h.name ?? `${instance.constructor.name}.${h.method}`);
|
|
839
|
+
ids.push(id);
|
|
840
|
+
}
|
|
841
|
+
for (const h of getTimeoutHooks(instance)) {
|
|
842
|
+
const fn = instance[h.method];
|
|
843
|
+
if (typeof fn !== "function")
|
|
844
|
+
continue;
|
|
845
|
+
const id = service.addTimeout(h.milliseconds, fn.bind(instance), h.name ?? `${instance.constructor.name}.${h.method}`);
|
|
846
|
+
ids.push(id);
|
|
847
|
+
}
|
|
848
|
+
return ids;
|
|
849
|
+
}
|
|
850
|
+
export {
|
|
851
|
+
scanForSchedulers,
|
|
852
|
+
parseCron,
|
|
853
|
+
nextCron,
|
|
854
|
+
getTimeoutHooks,
|
|
855
|
+
getIntervalHooks,
|
|
856
|
+
getCronHooks,
|
|
857
|
+
Timeout,
|
|
858
|
+
ScheduleService,
|
|
859
|
+
ScheduleModule,
|
|
860
|
+
MemorySchedulesBackend,
|
|
861
|
+
Interval,
|
|
862
|
+
CronField,
|
|
863
|
+
CronExpression as CronExpressionClass,
|
|
864
|
+
CronExpression as CronExpr,
|
|
865
|
+
Cron,
|
|
866
|
+
CloudflareSchedulesBackend
|
|
867
|
+
};
|
|
868
|
+
|
|
869
|
+
//# debugId=5FC679DEFC3E1FEA64756E2164756E21
|
|
870
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/cron-parser.ts", "../src/backends/memory.ts", "../src/backends/cloudflare.ts", "../src/schedule.service.ts", "../src/schedule.module.ts", "../src/decorators/cron.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Cron expression parser + next-run calculator.\n *\n * Supports the standard 5-field crontab syntax, an optional 6-field\n * variant (with seconds), common aliases, and \"@every <duration>\".\n *\n * * * * * * every minute\n * 0 * * * * every hour\n * star-slash-15 every 15m\n * 0 9 * * 1-5 9am on weekdays\n * 0 0 1 * * first of the month\n * 30 14 1 4 * Apr 1st at 14:30\n * @yearly @annually 0 0 1 1 *\n * @monthly 0 0 1 * *\n * @weekly 0 0 * * 0\n * @daily @midnight 0 0 * * *\n * @hourly 0 * * * *\n * @every 1h30m every 90 minutes\n *\n * Field names (JAN, FEB, SUN, MON, ...) are accepted case-insensitively.\n */\n\nconst FIELD_RANGES: Array<[number, number]> = [\n\t[0, 59], // minute\n\t[0, 23], // hour\n\t[1, 31], // day of month\n\t[1, 12], // month\n\t[0, 7], // day of week (0 or 7 = Sunday)\n];\n\nconst FIELD_NAMES: Record<string, number> = {\n\tJAN: 1,\n\tFEB: 2,\n\tMAR: 3,\n\tAPR: 4,\n\tMAY: 5,\n\tJUN: 6,\n\tJUL: 7,\n\tAUG: 8,\n\tSEP: 9,\n\tOCT: 10,\n\tNOV: 11,\n\tDEC: 12,\n\tSUN: 0,\n\tMON: 1,\n\tTUE: 2,\n\tWED: 3,\n\tTHU: 4,\n\tFRI: 5,\n\tSAT: 6,\n};\n\nconst ALIASES: Record<string, string> = {\n\t\"@yearly\": \"0 0 1 1 *\",\n\t\"@annually\": \"0 0 1 1 *\",\n\t\"@monthly\": \"0 0 1 * *\",\n\t\"@weekly\": \"0 0 * * 0\",\n\t\"@daily\": \"0 0 * * *\",\n\t\"@midnight\": \"0 0 * * *\",\n\t\"@hourly\": \"0 * * * *\",\n};\n\n/** A single field expanded into a set of allowed numeric values. */\nexport class CronField {\n\treadonly values: Set<number>;\n\n\tconstructor(field: string, range: [number, number]) {\n\t\tthis.values = parseField(field, range);\n\t}\n\n\tcontains(n: number): boolean {\n\t\treturn this.values.has(n);\n\t}\n}\n\n/** A fully-parsed cron expression. */\nexport class CronExpression {\n\treadonly fields: CronField[]; // 5 or 6 entries\n\treadonly hasSeconds: boolean;\n\n\tconstructor(raw: string) {\n\t\tconst expanded = expandAlias(raw);\n\t\tconst every = expandEvery(expanded);\n\n\t\tif (every) {\n\t\t\t// \"@every Nd|Nh|Nm|Ns\" → uniform interval\n\t\t\tthis.hasSeconds = true;\n\t\t\tthis.fields = everyToFields(every);\n\t\t\treturn;\n\t\t}\n\n\t\tconst parts = expanded.trim().split(/\\s+/);\n\t\tif (parts.length === 5) {\n\t\t\tthis.hasSeconds = false;\n\t\t\tthis.fields = parts.map((p, i) => new CronField(p, FIELD_RANGES[i]!));\n\t\t} else if (parts.length === 6) {\n\t\t\tthis.hasSeconds = true;\n\t\t\tconst sec: [number, number] = [0, 59];\n\t\t\tthis.fields = [\n\t\t\t\tnew CronField(parts[0]!, sec),\n\t\t\t\t...parts.slice(1).map((p, i) => new CronField(p, FIELD_RANGES[i]!)),\n\t\t\t];\n\t\t} else {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid cron expression: \"${raw}\" (expected 5 or 6 fields, got ${parts.length})`,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Return the next Date at or after `from` that matches this\n\t * expression. Returns null if no match is found within `maxYears`\n\t * (default 5) — which would indicate a misconfigured expression.\n\t */\n\tnext(from: Date, maxYears = 5): Date | null {\n\t\tconst cap = new Date(from.getTime() + maxYears * 365 * 24 * 60 * 60 * 1000);\n\t\tlet cur = new Date(from.getTime() + 1000);\n\t\tcur.setMilliseconds(0);\n\n\t\t// Brute-force: step minute-by-minute, but skip ahead when a\n\t\t// higher-order field doesn't match. For most crons this is\n\t\t// fast enough; for very sparse crons we use a forwarder.\n\t\tlet safety = 0;\n\t\twhile (cur <= cap) {\n\t\t\tif (this.matches(cur)) {\n\t\t\t\treturn cur;\n\t\t\t}\n\t\t\t// Fast-forward: if the month doesn't match, jump to next month.\n\t\t\tif (!this.fields[this.hasSeconds ? 4 : 3]!.contains(cur.getMonth() + 1)) {\n\t\t\t\tcur = new Date(cur.getFullYear(), cur.getMonth() + 1, 1, 0, 0, 0, 0);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// If day-of-month is restricted and current day doesn't match,\n\t\t\t// jump to next month at the first allowed day.\n\t\t\tconst domIdx = this.hasSeconds ? 3 : 2;\n\t\t\tconst domField = this.fields[domIdx]!;\n\t\t\tif (!domField.contains(cur.getDate())) {\n\t\t\t\t// Find the first allowed day in the set, or jump to next month.\n\t\t\t\tconst sortedDays = [...domField.values].sort((a, b) => a - b);\n\t\t\t\tconst nextDay = sortedDays.find((d) => d >= cur.getDate());\n\t\t\t\tif (nextDay !== undefined) {\n\t\t\t\t\tcur = new Date(\n\t\t\t\t\t\tcur.getFullYear(),\n\t\t\t\t\t\tcur.getMonth(),\n\t\t\t\t\t\tnextDay,\n\t\t\t\t\t\t0,\n\t\t\t\t\t\t0,\n\t\t\t\t\t\t0,\n\t\t\t\t\t\t0,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tcur = new Date(\n\t\t\t\t\t\tcur.getFullYear(),\n\t\t\t\t\t\tcur.getMonth() + 1,\n\t\t\t\t\t\tsortedDays[0]!,\n\t\t\t\t\t\t0,\n\t\t\t\t\t\t0,\n\t\t\t\t\t\t0,\n\t\t\t\t\t\t0,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// If the hour doesn't match, jump to next hour.\n\t\t\tif (!this.fields[this.hasSeconds ? 2 : 1]!.contains(cur.getHours())) {\n\t\t\t\tcur = new Date(\n\t\t\t\t\tcur.getFullYear(),\n\t\t\t\t\tcur.getMonth(),\n\t\t\t\t\tcur.getDate(),\n\t\t\t\t\tcur.getHours() + 1,\n\t\t\t\t\t0,\n\t\t\t\t\t0,\n\t\t\t\t\t0,\n\t\t\t\t);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// If the minute doesn't match, jump to next minute.\n\t\t\tif (!this.fields[this.hasSeconds ? 1 : 0]!.contains(cur.getMinutes())) {\n\t\t\t\tcur = new Date(\n\t\t\t\t\tcur.getFullYear(),\n\t\t\t\t\tcur.getMonth(),\n\t\t\t\t\tcur.getDate(),\n\t\t\t\t\tcur.getHours(),\n\t\t\t\t\tcur.getMinutes() + 1,\n\t\t\t\t\t0,\n\t\t\t\t\t0,\n\t\t\t\t);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// If seconds field exists and doesn't match, jump to next second.\n\t\t\tif (this.hasSeconds && !this.fields[0]!.contains(cur.getSeconds())) {\n\t\t\t\tcur = new Date(cur.getTime() + 1000);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// Fallback: step 1 second (shouldn't normally hit).\n\t\t\tcur = new Date(cur.getTime() + 1000);\n\t\t\tif (++safety > 1_000_000) return null;\n\t\t}\n\t\treturn null;\n\t}\n\n\tprivate matches(d: Date): boolean {\n\t\tconst fields = this.hasSeconds\n\t\t\t? [\n\t\t\t\t\td.getSeconds(),\n\t\t\t\t\td.getMinutes(),\n\t\t\t\t\td.getHours(),\n\t\t\t\t\td.getDate(),\n\t\t\t\t\td.getMonth() + 1,\n\t\t\t\t\td.getDay(),\n\t\t\t\t]\n\t\t\t: [\n\t\t\t\t\td.getMinutes(),\n\t\t\t\t\td.getHours(),\n\t\t\t\t\td.getDate(),\n\t\t\t\t\td.getMonth() + 1,\n\t\t\t\t\td.getDay(),\n\t\t\t\t];\n\t\t// Day-of-week in crontab: 0 = Sunday. Day-of-month is OR'd with\n\t\t// day-of-week when both are restricted (standard crontab behavior).\n\t\tconst domField = this.fields[this.hasSeconds ? 3 : 2]!;\n\t\tconst dowField = this.fields[this.hasSeconds ? 4 : 3]!;\n\t\tconst isWildDom = domField.values.size === FIELD_RANGES[2]![1]!;\n\t\tconst isWildDow = dowField.values.size === FIELD_RANGES[4]![1]! + 1;\n\t\tconst dayMatch =\n\t\t\tisWildDom || isWildDow\n\t\t\t\t? domField.contains(d.getDate()) || dowField.contains(d.getDay())\n\t\t\t\t: domField.contains(d.getDate()) || dowField.contains(d.getDay());\n\n\t\tfor (let i = 0; i < this.fields.length; i++) {\n\t\t\tif (i === (this.hasSeconds ? 3 : 2)) continue;\n\t\t\tif (!this.fields[i]!.contains(fields[i]!)) return false;\n\t\t}\n\t\treturn dayMatch;\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// Internal helpers\n// ---------------------------------------------------------------------------\n\nfunction expandAlias(raw: string): string {\n\tconst trimmed = raw.trim();\n\tconst alias = ALIASES[trimmed.toLowerCase()];\n\treturn alias ?? trimmed;\n}\n\nfunction expandEvery(raw: string): number | null {\n\tconst m = /^@every\\s+(\\d+)\\s*(s|m|h|d)?$/i.exec(raw.trim());\n\tif (!m) return null;\n\tconst n = Number(m[1]);\n\tconst unit = (m[2] ?? \"s\").toLowerCase();\n\tswitch (unit) {\n\t\tcase \"s\":\n\t\t\treturn n * 1000;\n\t\tcase \"m\":\n\t\t\treturn n * 60 * 1000;\n\t\tcase \"h\":\n\t\t\treturn n * 60 * 60 * 1000;\n\t\tcase \"d\":\n\t\t\treturn n * 24 * 60 * 60 * 1000;\n\t}\n\treturn null;\n}\n\nfunction everyToFields(intervalMs: number): CronField[] {\n\t// Generate a 6-field expression that fires every `intervalMs`\n\t// starting from the next round minute.\n\tconst seconds = Math.floor(intervalMs / 1000);\n\tif (seconds < 60) {\n\t\t// fire every N seconds (only if it divides 60)\n\t\tif (60 % seconds === 0) {\n\t\t\treturn [\n\t\t\t\tnew CronField(`*/${seconds}`, [0, 59]),\n\t\t\t\tnew CronField(\"*\", [0, 59]),\n\t\t\t\tnew CronField(\"*\", [0, 23]),\n\t\t\t\tnew CronField(\"*\", [1, 31]),\n\t\t\t\tnew CronField(\"*\", [1, 12]),\n\t\t\t\tnew CronField(\"*\", [0, 7]),\n\t\t\t];\n\t\t}\n\t}\n\t// Otherwise just allow every minute; the registry layer handles\n\t// throttling via setInterval.\n\treturn [\n\t\tnew CronField(\"0\", [0, 59]),\n\t\tnew CronField(\"*\", [0, 59]),\n\t\tnew CronField(\"*\", [0, 23]),\n\t\tnew CronField(\"*\", [1, 31]),\n\t\tnew CronField(\"*\", [1, 12]),\n\t\tnew CronField(\"*\", [0, 7]),\n\t];\n}\n\nfunction parseField(field: string, range: [number, number]): Set<number> {\n\tconst out = new Set<number>();\n\tconst [lo, hi] = range;\n\tconst parts = field.split(\",\");\n\tfor (const partRaw of parts) {\n\t\tconst part = partRaw.trim();\n\t\t// step: e.g. \"*/2\" or \"0-30/2\"\n\t\tconst stepMatch = /^(.+?)\\/(\\d+)$/.exec(part);\n\t\tlet base = part;\n\t\tlet step = 1;\n\t\tif (stepMatch) {\n\t\t\tbase = stepMatch[1]!;\n\t\t\tstep = Number(stepMatch[2]);\n\t\t}\n\t\tlet start: number;\n\t\tlet end: number;\n\t\tif (base === \"*\") {\n\t\t\tstart = lo;\n\t\t\tend = hi;\n\t\t} else if (base.includes(\"-\")) {\n\t\t\tconst [a, b] = base.split(\"-\").map((s) => resolveValue(s, lo, hi));\n\t\t\tstart = a;\n\t\t\tend = b;\n\t\t} else {\n\t\t\tconst v = resolveValue(base, lo, hi);\n\t\t\tstart = v;\n\t\t\tend = stepMatch ? hi : v;\n\t\t}\n\t\tif (start > end) {\n\t\t\tthrow new Error(`Invalid range in cron field: \"${part}\"`);\n\t\t}\n\t\tfor (let i = start; i <= end; i += step) {\n\t\t\tout.add(i);\n\t\t}\n\t}\n\treturn out;\n}\n\nfunction resolveValue(token: string, lo: number, hi: number): number {\n\tconst t = token.trim();\n\tif (t === \"*\") return lo;\n\tconst named = FIELD_NAMES[t.toUpperCase()];\n\tif (named !== undefined) return named;\n\tconst n = Number(t);\n\tif (Number.isNaN(n)) {\n\t\tthrow new Error(`Invalid cron field value: \"${token}\"`);\n\t}\n\tif (n < lo || n > hi) {\n\t\tthrow new Error(`Cron value ${n} out of range [${lo}, ${hi}]`);\n\t}\n\treturn n;\n}\n\n/**\n * Parse a cron expression. Throws on invalid syntax. The returned\n * object can be queried for the next match (`expr.next(new Date())`).\n */\nexport function parseCron(expression: string): CronExpression {\n\treturn new CronExpression(expression);\n}\n\n/** Convenience: return the next Date matching `expression` after `from`. */\nexport function nextCron(\n\texpression: string,\n\tfrom: Date = new Date(),\n): Date | null {\n\treturn parseCron(expression).next(from);\n}\n",
|
|
6
|
+
"/**\n * In-process scheduler backend.\n *\n * Runs on a single setInterval tick (default 1s) and dispatches due\n * tasks. Honors cron expressions via `CronExpression.next()`, fixed\n * intervals via `setInterval`, and one-shot delays via `setTimeout`.\n *\n * Use for Bun / Node long-running servers. For Cloudflare Workers,\n * use the dedicated `CloudflareSchedulesBackend` which integrates\n * with Cron Triggers.\n */\n\nimport type {\n\tScheduleRegistry,\n\tScheduleHandler,\n\tScheduledTask,\n\tCronExpression,\n\tCronOptions,\n\tScheduleEvent,\n\tScheduleEventListener,\n\tTaskKind,\n} from \"../types.js\";\nimport { CronExpression as CronExpr, nextCron } from \"../cron-parser.js\";\n\ninterface InternalTask {\n\tid: string;\n\tname: string;\n\tkind: TaskKind;\n\texpression: string;\n\t/** Next run time (epoch ms). */\n\tnextRunAt: number;\n\t/** Last run time (epoch ms). */\n\tlastRunAt?: number;\n\tinvocations: number;\n\tlastError?: string;\n\tstatus: \"running\" | \"stopped\" | \"paused\";\n\thandler: ScheduleHandler;\n\t/** Interval handle for `interval` / `timeout` tasks. */\n\ttimer?: ReturnType<typeof setInterval> | ReturnType<typeof setTimeout>;\n}\n\nexport interface MemoryBackendOptions {\n\t/** Tick interval in ms. Default: 1000. */\n\ttickMs?: number;\n\t/** Default cron timezone. */\n\tdefaultTimezone?: string;\n\t/** Skip tasks that fall behind by more than this many ms. Default: 60_000. */\n\tmaxDriftMs?: number;\n}\n\nexport class MemorySchedulesBackend implements ScheduleRegistry {\n\t#tasks = new Map<string, InternalTask>();\n\t#byName = new Map<string, string>(); // name → id\n\t#listeners = new Set<ScheduleEventListener>();\n\t#tickHandle: ReturnType<typeof setInterval> | null = null;\n\t#tickMs: number;\n\t#maxDriftMs: number;\n\t#defaultTimezone: string | undefined = undefined;\n\t#nextId = 1;\n\n\tconstructor(options: MemoryBackendOptions = {}) {\n\t\tthis.#tickMs = options.tickMs ?? 1000;\n\t\tthis.#maxDriftMs = options.maxDriftMs ?? 60_000;\n\t\tthis.#defaultTimezone = options.defaultTimezone;\n\t}\n\n\t// ===========================================================================\n\t// Public API\n\t// ===========================================================================\n\n\taddCron(\n\t\tname: string,\n\t\texpression: CronExpression,\n\t\thandler: ScheduleHandler,\n\t\toptions: CronOptions = {},\n\t): string {\n\t\tconst id = this.#allocateId();\n\t\tconst next = nextCron(\n\t\t\texpression,\n\t\t\toptions.runOnInit ? new Date(Date.now() - 1000) : new Date(),\n\t\t);\n\t\tconst task: InternalTask = {\n\t\t\tid,\n\t\t\tname,\n\t\t\tkind: \"cron\",\n\t\t\texpression,\n\t\t\tnextRunAt: next?.getTime() ?? Date.now() + 60_000,\n\t\t\tinvocations: 0,\n\t\t\tstatus: \"running\",\n\t\t\thandler,\n\t\t};\n\t\tthis.#tasks.set(id, task);\n\t\tthis.#byName.set(name, id);\n\t\tthis.#emit({\n\t\t\tkind: \"task:registered\",\n\t\t\tid,\n\t\t\tname,\n\t\t\ttaskKind: \"cron\",\n\t\t\texpression,\n\t\t});\n\t\treturn id;\n\t}\n\n\taddInterval(name: string, ms: number, handler: ScheduleHandler): string {\n\t\tconst id = this.#allocateId();\n\t\tconst task: InternalTask = {\n\t\t\tid,\n\t\t\tname,\n\t\t\tkind: \"interval\",\n\t\t\texpression: `${ms}ms`,\n\t\t\tnextRunAt: Date.now() + ms,\n\t\t\tinvocations: 0,\n\t\t\tstatus: \"running\",\n\t\t\thandler,\n\t\t};\n\t\ttask.timer = setInterval(() => this.#runTask(id), ms);\n\t\tthis.#tasks.set(id, task);\n\t\tthis.#byName.set(name, id);\n\t\tthis.#emit({\n\t\t\tkind: \"task:registered\",\n\t\t\tid,\n\t\t\tname,\n\t\t\ttaskKind: \"interval\",\n\t\t\texpression: `${ms}ms`,\n\t\t});\n\t\treturn id;\n\t}\n\n\taddTimeout(name: string, ms: number, handler: ScheduleHandler): string {\n\t\tconst id = this.#allocateId();\n\t\tconst task: InternalTask = {\n\t\t\tid,\n\t\t\tname,\n\t\t\tkind: \"timeout\",\n\t\t\texpression: `${ms}ms`,\n\t\t\tnextRunAt: Date.now() + ms,\n\t\t\tinvocations: 0,\n\t\t\tstatus: \"running\",\n\t\t\thandler,\n\t\t};\n\t\ttask.timer = setTimeout(() => this.#runOnceAndRemove(id), ms);\n\t\tthis.#tasks.set(id, task);\n\t\tthis.#byName.set(name, id);\n\t\tthis.#emit({\n\t\t\tkind: \"task:registered\",\n\t\t\tid,\n\t\t\tname,\n\t\t\ttaskKind: \"timeout\",\n\t\t\texpression: `${ms}ms`,\n\t\t});\n\t\treturn id;\n\t}\n\n\tdelete(idOrName: string): boolean {\n\t\tconst id = this.#resolveId(idOrName);\n\t\tif (!id) return false;\n\t\tconst task = this.#tasks.get(id);\n\t\tif (!task) return false;\n\t\tthis.#clearTimer(task);\n\t\tthis.#tasks.delete(id);\n\t\tthis.#byName.delete(task.name);\n\t\tthis.#emit({ kind: \"task:deleted\", id });\n\t\treturn true;\n\t}\n\n\tlist(): ScheduledTask[] {\n\t\treturn [...this.#tasks.values()].map((t) => this.#toPublic(t));\n\t}\n\n\tget(idOrName: string): ScheduledTask | undefined {\n\t\tconst id = this.#resolveId(idOrName);\n\t\tif (!id) return undefined;\n\t\tconst task = this.#tasks.get(id);\n\t\treturn task ? this.#toPublic(task) : undefined;\n\t}\n\n\tpause(idOrName: string): boolean {\n\t\tconst id = this.#resolveId(idOrName);\n\t\tif (!id) return false;\n\t\tconst task = this.#tasks.get(id);\n\t\tif (!task) return false;\n\t\tthis.#clearTimer(task);\n\t\ttask.status = \"paused\";\n\t\tthis.#emit({ kind: \"task:paused\", id });\n\t\treturn true;\n\t}\n\n\tresume(idOrName: string): boolean {\n\t\tconst id = this.#resolveId(idOrName);\n\t\tif (!id) return false;\n\t\tconst task = this.#tasks.get(id);\n\t\tif (!task) return false;\n\t\tif (task.kind === \"interval\" && !task.timer) {\n\t\t\ttask.timer = setInterval(\n\t\t\t\t() => this.#runTask(id),\n\t\t\t\tNumber(task.expression.replace(\"ms\", \"\")),\n\t\t\t);\n\t\t}\n\t\ttask.status = \"running\";\n\t\tthis.#emit({ kind: \"task:resumed\", id });\n\t\treturn true;\n\t}\n\n\tasync stop(): Promise<void> {\n\t\tfor (const task of this.#tasks.values()) {\n\t\t\tthis.#clearTimer(task);\n\t\t}\n\t\tthis.#tasks.clear();\n\t\tthis.#byName.clear();\n\t\tif (this.#tickHandle) clearInterval(this.#tickHandle);\n\t\tthis.#tickHandle = null;\n\t}\n\n\t// ===========================================================================\n\t// Events\n\t// ===========================================================================\n\n\ton(listener: ScheduleEventListener): () => void {\n\t\tthis.#listeners.add(listener);\n\t\treturn () => this.#listeners.delete(listener);\n\t}\n\n\t// ===========================================================================\n\t// Lifecycle\n\t// ===========================================================================\n\n\t/** Start the tick loop. Idempotent. */\n\tstart(): void {\n\t\tif (this.#tickHandle) return;\n\t\tthis.#tickHandle = setInterval(() => this.#tick(), this.#tickMs);\n\t\t// Don't keep Node alive just for the tick.\n\t\tconst handle = this.#tickHandle as unknown as { unref?: () => void };\n\t\tif (typeof handle.unref === \"function\") handle.unref();\n\t}\n\n\t// ===========================================================================\n\t// Internal\n\t// ===========================================================================\n\n\t#allocateId(): string {\n\t\treturn `sched-${this.#nextId++}`;\n\t}\n\n\t#resolveId(idOrName: string): string | null {\n\t\tif (this.#tasks.has(idOrName)) return idOrName;\n\t\treturn this.#byName.get(idOrName) ?? null;\n\t}\n\n\t#toPublic(t: InternalTask): ScheduledTask {\n\t\tconst public_: ScheduledTask = {\n\t\t\tid: t.id,\n\t\t\tname: t.name,\n\t\t\tkind: t.kind,\n\t\t\texpression: t.expression,\n\t\t\tstatus: t.status,\n\t\t\tinvocations: t.invocations,\n\t\t};\n\t\tif (t.lastRunAt !== undefined) {\n\t\t\tpublic_.lastRunAt = new Date(t.lastRunAt).toISOString();\n\t\t}\n\t\tpublic_.nextRunAt = new Date(t.nextRunAt).toISOString();\n\t\tif (t.lastError !== undefined) public_.lastError = t.lastError;\n\t\treturn public_;\n\t}\n\n\t#clearTimer(task: InternalTask): void {\n\t\tif (task.timer) {\n\t\t\tclearInterval(task.timer as ReturnType<typeof setInterval>);\n\t\t\tclearTimeout(task.timer as ReturnType<typeof setTimeout>);\n\t\t\ttask.timer = undefined;\n\t\t}\n\t}\n\n\t#tick(): void {\n\t\tconst now = Date.now();\n\t\tfor (const [id, task] of this.#tasks) {\n\t\t\tif (task.status !== \"running\") continue;\n\t\t\tif (task.kind !== \"cron\") continue; // intervals/timeouts fire via their own timer\n\t\t\tif (task.nextRunAt > now) continue;\n\t\t\tvoid this.#runTask(id);\n\t\t}\n\t}\n\n\tasync #runTask(id: string): Promise<void> {\n\t\tconst task = this.#tasks.get(id);\n\t\tif (!task) return;\n\t\tconst startedAt = new Date();\n\t\tthis.#emit({\n\t\t\tkind: \"task:invoked\",\n\t\t\tid,\n\t\t\tname: task.name,\n\t\t\tstartedAt: startedAt.toISOString(),\n\t\t});\n\t\tconst start = Date.now();\n\t\ttry {\n\t\t\tconst result = await task.handler();\n\t\t\ttask.invocations++;\n\t\t\ttask.lastRunAt = start;\n\t\t\ttask.lastError = undefined;\n\t\t\tthis.#emit({\n\t\t\t\tkind: \"task:completed\",\n\t\t\t\tid,\n\t\t\t\tname: task.name,\n\t\t\t\tdurationMs: Date.now() - start,\n\t\t\t\treturnvalue: result,\n\t\t\t});\n\t\t} catch (err) {\n\t\t\ttask.invocations++;\n\t\t\ttask.lastRunAt = start;\n\t\t\tconst error = err instanceof Error ? err : new Error(String(err));\n\t\t\ttask.lastError = error.message;\n\t\t\tthis.#emit({ kind: \"task:failed\", id, name: task.name, error });\n\t\t} finally {\n\t\t\t// Schedule the next cron run.\n\t\t\tif (task.kind === \"cron\" && task.status === \"running\") {\n\t\t\t\tconst next = nextCron(task.expression, new Date());\n\t\t\t\tif (next) {\n\t\t\t\t\tconst drift = next.getTime() - Date.now();\n\t\t\t\t\ttask.nextRunAt =\n\t\t\t\t\t\tdrift > this.#maxDriftMs ? Date.now() + 60_000 : next.getTime();\n\t\t\t\t} else {\n\t\t\t\t\ttask.nextRunAt = Date.now() + 60_000;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t#runOnceAndRemove(id: string): void {\n\t\tvoid this.#runTask(id);\n\t\tconst task = this.#tasks.get(id);\n\t\tif (task) {\n\t\t\tthis.#tasks.delete(id);\n\t\t\tthis.#byName.delete(task.name);\n\t\t\tthis.#emit({ kind: \"task:deleted\", id });\n\t\t}\n\t}\n\n\t#emit(event: ScheduleEvent): void {\n\t\tfor (const l of this.#listeners) {\n\t\t\tvoid Promise.resolve(l(event));\n\t\t}\n\t}\n}\n\n// Re-export the parser's CronExpression class for users who want to\n// parse expressions manually.\nexport { CronExpr };\n",
|
|
7
|
+
"/**\n * Cloudflare Cron Triggers backend.\n *\n * Cloudflare Cron Triggers are configured in `wrangler.toml`:\n *\n * [[triggers.crons]]\n * cron = \"every 15m (your expression)\"\n *\n * The trigger fires a Worker's `scheduled(event, env, ctx)` handler.\n * We dispatch that to the registered task by name.\n *\n * This backend is a **registration-only facade**: tasks are stored\n * locally (so `nx route:list`-style introspection works), but the\n * actual scheduling is at the platform level. The worker's `scheduled`\n * export calls `dispatch(event)` to run the matching task.\n */\n\nimport type {\n\tScheduleRegistry,\n\tScheduleHandler,\n\tScheduledTask,\n\tCronExpression,\n\tCronOptions,\n\tScheduleEvent,\n\tScheduleEventListener,\n} from \"../types.js\";\n\ninterface InternalTask {\n\tid: string;\n\tname: string;\n\texpression: string;\n\thandler: ScheduleHandler;\n\toptions: CronOptions;\n}\n\n/** Shape of the Worker's `scheduled` event. Mirrors `cloudflare-types`. */\nexport interface CloudflareScheduledEvent {\n\tcron: string;\n\t/** ISO timestamp of when the trigger fired. */\n\tscheduledTime: Date | number;\n}\n\nexport interface CloudflareSchedulesOptions {\n\t/** Validate that registered expressions match the wrangler.toml trigger. Default: true. */\n\tvalidateAgainstTrigger?: boolean;\n}\n\nexport class CloudflareSchedulesBackend implements ScheduleRegistry {\n\t#tasks = new Map<string, InternalTask>();\n\t#byName = new Map<string, string>();\n\t#listeners = new Set<ScheduleEventListener>();\n\t#nextId = 1;\n\t#validate: boolean;\n\n\tconstructor(options: CloudflareSchedulesOptions = {}) {\n\t\tthis.#validate = options.validateAgainstTrigger ?? true;\n\t}\n\n\taddCron(\n\t\tname: string,\n\t\texpression: CronExpression,\n\t\thandler: ScheduleHandler,\n\t\toptions: CronOptions = {},\n\t): string {\n\t\tconst id = `sched-${this.#nextId++}`;\n\t\tthis.#tasks.set(id, { id, name, expression, handler, options });\n\t\tthis.#byName.set(name, id);\n\t\tthis.#emit({\n\t\t\tkind: \"task:registered\",\n\t\t\tid,\n\t\t\tname,\n\t\t\ttaskKind: \"cron\",\n\t\t\texpression,\n\t\t});\n\t\treturn id;\n\t}\n\n\taddInterval(): string {\n\t\tthrow new Error(\n\t\t\t\"[schedule/cloudflare] setInterval is not supported on Workers. \" +\n\t\t\t\t\"Use @Cron with a short interval or use the memory backend for in-process scheduling.\",\n\t\t);\n\t}\n\n\taddTimeout(): string {\n\t\tthrow new Error(\n\t\t\t\"[schedule/cloudflare] setTimeout is not supported on Workers. \" +\n\t\t\t\t'Use @Cron with a delay (e.g. \"@every 30s\") or run the work from a request handler.',\n\t\t);\n\t}\n\n\tdelete(idOrName: string): boolean {\n\t\tconst id = this.#resolveId(idOrName);\n\t\tif (!id) return false;\n\t\tconst task = this.#tasks.get(id);\n\t\tif (!task) return false;\n\t\tthis.#tasks.delete(id);\n\t\tthis.#byName.delete(task.name);\n\t\tthis.#emit({ kind: \"task:deleted\", id });\n\t\treturn true;\n\t}\n\n\tlist(): ScheduledTask[] {\n\t\treturn [...this.#tasks.values()].map((t) => ({\n\t\t\tid: t.id,\n\t\t\tname: t.name,\n\t\t\tkind: \"cron\",\n\t\t\texpression: t.expression,\n\t\t\tstatus: \"running\",\n\t\t\tinvocations: 0,\n\t\t}));\n\t}\n\n\tget(idOrName: string): ScheduledTask | undefined {\n\t\tconst id = this.#resolveId(idOrName);\n\t\tif (!id) return undefined;\n\t\tconst t = this.#tasks.get(id);\n\t\treturn t\n\t\t\t? {\n\t\t\t\t\tid: t.id,\n\t\t\t\t\tname: t.name,\n\t\t\t\t\tkind: \"cron\",\n\t\t\t\t\texpression: t.expression,\n\t\t\t\t\tstatus: \"running\",\n\t\t\t\t\tinvocations: 0,\n\t\t\t\t}\n\t\t\t: undefined;\n\t}\n\n\tpause(): boolean {\n\t\t// No-op — Cloudflare controls the trigger. Edit wrangler.toml to disable.\n\t\treturn false;\n\t}\n\n\tresume(): boolean {\n\t\treturn false;\n\t}\n\n\tasync stop(): Promise<void> {\n\t\tthis.#tasks.clear();\n\t\tthis.#byName.clear();\n\t}\n\n\t// ===========================================================================\n\t// Events\n\t// ===========================================================================\n\n\ton(listener: ScheduleEventListener): () => void {\n\t\tthis.#listeners.add(listener);\n\t\treturn () => this.#listeners.delete(listener);\n\t}\n\n\t// ===========================================================================\n\t// Worker integration\n\t// ===========================================================================\n\n\t/**\n\t * Return the Worker's `scheduled()` handler. Mount it in the\n\t * default export:\n\t *\n\t * export default {\n\t * fetch: app.fetch,\n\t * scheduled: backend.scheduledHandler(),\n\t * };\n\t *\n\t * The handler dispatches based on the trigger's cron expression\n\t * (or, when validation is disabled, by event ordering).\n\t */\n\tscheduledHandler(): (event: CloudflareScheduledEvent) => Promise<void> {\n\t\treturn async (event) => {\n\t\t\tfor (const task of this.#tasks.values()) {\n\t\t\t\tif (this.#validate && task.expression !== event.cron) continue;\n\t\t\t\tawait this.#dispatch(task, event);\n\t\t\t}\n\t\t};\n\t}\n\n\tasync #dispatch(\n\t\ttask: InternalTask,\n\t\tevent: CloudflareScheduledEvent,\n\t): Promise<void> {\n\t\tconst startedAt = new Date();\n\t\tthis.#emit({\n\t\t\tkind: \"task:invoked\",\n\t\t\tid: task.id,\n\t\t\tname: task.name,\n\t\t\tstartedAt: startedAt.toISOString(),\n\t\t});\n\t\ttry {\n\t\t\tconst result = await task.handler();\n\t\t\tthis.#emit({\n\t\t\t\tkind: \"task:completed\",\n\t\t\t\tid: task.id,\n\t\t\t\tname: task.name,\n\t\t\t\tdurationMs: Date.now() - startedAt.getTime(),\n\t\t\t\treturnvalue: result,\n\t\t\t});\n\t\t} catch (err) {\n\t\t\tconst error = err instanceof Error ? err : new Error(String(err));\n\t\t\tthis.#emit({ kind: \"task:failed\", id: task.id, name: task.name, error });\n\t\t}\n\t\tvoid event; // (kept for future event-based logic)\n\t}\n\n\t// ===========================================================================\n\t// Internal\n\t// ===========================================================================\n\n\t#resolveId(idOrName: string): string | null {\n\t\tif (this.#tasks.has(idOrName)) return idOrName;\n\t\treturn this.#byName.get(idOrName) ?? null;\n\t}\n\n\t#emit(event: ScheduleEvent): void {\n\t\tfor (const l of this.#listeners) {\n\t\t\tvoid Promise.resolve(l(event));\n\t\t}\n\t}\n}\n",
|
|
8
|
+
"/**\n * `ScheduleService` — DI-friendly facade over a `ScheduleRegistry`.\n *\n * Mirrors the `@nestjs/schedule` API for familiarity. Controllers and\n * services can:\n * - Inject this and call `addCron / addInterval / addTimeout` to\n * schedule dynamically.\n * - Inject this and call `list / get / pause / resume / delete` to\n * introspect or mutate registered tasks.\n *\n * For static registration, use the `@Cron`, `@Interval`, `@Timeout`\n * decorators plus `ScheduleModule.scanForSchedulers(instance)`.\n */\n\nimport { Inject, Injectable } from '@nexusts/core/src/decorators/index.js';\nimport type {\n\tScheduleRegistry,\n\tScheduleConfig,\n\tCronExpression,\n\tCronOptions,\n\tScheduledTask,\n\tScheduleHandler,\n\tScheduleEvent,\n\tScheduleEventListener,\n} from './types.js';\nimport {\n\tMemorySchedulesBackend,\n\tCloudflareSchedulesBackend,\n} from './backends/index.js';\n\n@Injectable()\nexport class ScheduleService {\n\t/** DI token — use with `@Inject(ScheduleService.TOKEN)`. */\n\tstatic readonly TOKEN = Symbol.for('nexus:ScheduleService');\n\n\treadonly registry: ScheduleRegistry;\n\t#listeners = new Set<ScheduleEventListener>();\n\t#started = false;\n\t#memoryBackend: MemorySchedulesBackend | null = null;\n\n\tconstructor(@Inject('SCHEDULE_CONFIG') private readonly config: ScheduleConfig = {}) {\n\t\tthis.registry = this.#createBackend(config);\n\t}\n\n\t// ===========================================================================\n\t// Static-style API (used by @Cron / @Interval / @Timeout decorators)\n\t// ===========================================================================\n\n\t/**\n\t * Schedule a cron task. Returns the assigned task id.\n\t */\n\taddCron(\n\t\texpression: CronExpression,\n\t\thandler: ScheduleHandler,\n\t\toptions: CronOptions & { name?: string } = {},\n\t): string {\n\t\tconst name = options.name ?? `cron-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;\n\t\treturn this.registry.addCron(name, expression, handler, options);\n\t}\n\n\taddInterval(milliseconds: number, handler: ScheduleHandler, name?: string): string {\n\t\treturn this.registry.addInterval(name ?? `interval-${Date.now()}`, milliseconds, handler);\n\t}\n\n\taddTimeout(milliseconds: number, handler: ScheduleHandler, name?: string): string {\n\t\treturn this.registry.addTimeout(name ?? `timeout-${Date.now()}`, milliseconds, handler);\n\t}\n\n\t// ===========================================================================\n\t// Introspection / mutation\n\t// ===========================================================================\n\n\tlist(): ScheduledTask[] {\n\t\treturn this.registry.list();\n\t}\n\n\tget(idOrName: string): ScheduledTask | undefined {\n\t\treturn this.registry.get(idOrName);\n\t}\n\n\tpause(idOrName: string): boolean {\n\t\treturn this.registry.pause(idOrName);\n\t}\n\n\tresume(idOrName: string): boolean {\n\t\treturn this.registry.resume(idOrName);\n\t}\n\n\tdelete(idOrName: string): boolean {\n\t\treturn this.registry.delete(idOrName);\n\t}\n\n\t// ===========================================================================\n\t// Events\n\t// ===========================================================================\n\n\ton(listener: ScheduleEventListener): () => void {\n\t\tthis.#listeners.add(listener);\n\t\treturn () => this.#listeners.delete(listener);\n\t}\n\n\t// ===========================================================================\n\t// Lifecycle\n\t// ===========================================================================\n\n\t/** Start the in-process scheduler tick. Idempotent. */\n\tstart(): void {\n\t\tif (this.#started) return;\n\t\tthis.#started = true;\n\t\tif (this.#memoryBackend) {\n\t\t\tthis.#memoryBackend.start();\n\t\t}\n\t\t// Bridge backend events.\n\t\tthis.registry.on((event) => this.#broadcast(event));\n\t}\n\n\tasync stop(): Promise<void> {\n\t\tif (!this.#started) return;\n\t\tthis.#started = false;\n\t\tawait this.registry.stop();\n\t}\n\n\t/**\n\t * Get the underlying in-process backend (for tests / `nx dev`).\n\t * Returns null when the configured backend isn't memory.\n\t */\n\tgetMemoryBackend(): MemorySchedulesBackend | null {\n\t\treturn this.#memoryBackend;\n\t}\n\n\t/**\n\t * Get the underlying Cloudflare backend (for Workers). Returns\n\t * null when the configured backend isn't Cloudflare.\n\t */\n\tgetCloudflareBackend(): CloudflareSchedulesBackend | null {\n\t\treturn this.registry instanceof CloudflareSchedulesBackend ? this.registry : null;\n\t}\n\n\t// ===========================================================================\n\t// Internal\n\t// ===========================================================================\n\n\t#createBackend(config: ScheduleConfig): ScheduleRegistry {\n\t\tswitch (config.backend ?? 'memory') {\n\t\t\tcase 'memory': {\n\t\t\t\tconst backend = new MemorySchedulesBackend({\n\t\t\t\t\ttickMs: config.memory?.tickMs ?? 1000,\n\t\t\t\t\tmaxDriftMs: config.memory?.maxDriftMs,\n\t\t\t\t\tdefaultTimezone: config.defaultTimezone,\n\t\t\t\t});\n\t\t\t\tthis.#memoryBackend = backend;\n\t\t\t\treturn backend;\n\t\t\t}\n\t\t\tcase 'cloudflare':\n\t\t\t\treturn new CloudflareSchedulesBackend();\n\t\t}\n\t}\n\n\t#broadcast(event: ScheduleEvent): void {\n\t\tfor (const l of this.#listeners) {\n\t\t\tvoid Promise.resolve(l(event));\n\t\t}\n\t}\n}",
|
|
9
|
+
"/**\n * `ScheduleModule` — drop-in module for adding scheduled tasks to a\n * NexusTS app.\n *\n * Usage:\n * // src/app/app.module.ts\n * @Module({\n * imports: [\n * ScheduleModule.forRoot({\n * backend: 'memory', // or 'cloudflare'\n * defaultTimezone: 'UTC',\n * }),\n * ],\n * })\n * export class AppModule {}\n *\n * // any service\n * @Injectable()\n * class CleanupWorker {\n * constructor(@Inject(ScheduleService.TOKEN) private schedule: ScheduleService) {}\n *\n * @Cron('0 * * * *') // every hour\n * async hourly() {\n * // ...\n * }\n * }\n *\n * // bootstrap\n * const app = new Application(AppModule);\n * const schedule = app.container.resolve(ScheduleService);\n * await scanForSchedulers(worker, schedule);\n * schedule.start();\n */\n\nimport \"reflect-metadata\";\nimport { Module } from \"@nexusts/core/decorators/module.js\";\nimport { ScheduleService } from \"./schedule.service.js\";\nimport type { ScheduleConfig } from \"./types.js\";\n\n@Module({\n\tproviders: [\n\t\tScheduleService,\n\t\t{ provide: ScheduleService.TOKEN, useExisting: ScheduleService },\n\t],\n\texports: [ScheduleService, ScheduleService.TOKEN],\n})\nexport class ScheduleModule {\n\t/**\n\t * Build a configured `ScheduleModule` class.\n\t */\n\tstatic forRoot(config: ScheduleConfig = {}) {\n\t\t@Module({\n\t\t\tproviders: [\n\t\t\t\tScheduleService,\n\t\t\t\t{ provide: ScheduleService.TOKEN, useExisting: ScheduleService },\n\t\t\t\t{ provide: \"SCHEDULE_CONFIG\", useValue: config },\n\t\t\t],\n\t\t\texports: [ScheduleService, ScheduleService.TOKEN],\n\t\t})\n\t\tclass ConfiguredScheduleModule {}\n\n\t\tObject.defineProperty(ConfiguredScheduleModule, \"name\", {\n\t\t\tvalue: \"ConfiguredScheduleModule\",\n\t\t});\n\n\t\treturn ConfiguredScheduleModule;\n\t}\n}\n",
|
|
10
|
+
"/**\n * `@Cron(expression)` — schedule a method as a cron task.\n *\n * Mirrors `@nestjs/schedule`'s decorator. The decorated method runs\n * on the cron schedule; pair it with `ScheduleModule.scanForSchedulers`\n * to register at boot.\n *\n * Usage:\n * @Injectable()\n * class CleanupWorker {\n * constructor(@Inject(ScheduleService.TOKEN) private schedule: ScheduleService) {}\n *\n * @Cron('0 * * * *') // every hour\n * async hourly() {\n * // ...\n * }\n *\n * @Cron('@daily', { timezone: 'UTC' })\n * async dailyDigest() {\n * // ...\n * }\n * }\n *\n * // src/app/main.ts\n * const app = new Application(AppModule);\n * const schedule = app.container.resolve(ScheduleService);\n * for (const instance of getInjectables(app)) {\n * await schedule.scanForSchedulers(instance);\n * }\n * schedule.start();\n */\n\nimport \"reflect-metadata\";\nimport type { ScheduleService } from \"../schedule.service.js\";\nimport type { CronExpression, CronOptions, ScheduleHandler } from \"../types.js\";\n\nconst CRON_META = \"nexus:schedule:cron\";\nconst INTERVAL_META = \"nexus:schedule:interval\";\nconst TIMEOUT_META = \"nexus:schedule:timeout\";\n\n/**\n * Schedule the decorated method as a cron task.\n */\nexport function Cron(\n\texpression: CronExpression,\n\toptions: CronOptions = {},\n): MethodDecorator {\n\treturn (target, propertyKey, descriptor) => {\n\t\tif (!descriptor || typeof descriptor.value !== \"function\") {\n\t\t\tthrow new Error(\"@Cron can only decorate methods.\");\n\t\t}\n\t\tconst ctor = target.constructor as object;\n\t\tconst hooks: Array<{\n\t\t\tmethod: string;\n\t\t\texpression: CronExpression;\n\t\t\toptions: CronOptions;\n\t\t}> =\n\t\t\t(Reflect.getMetadata(CRON_META, ctor) as\n\t\t\t\t| Array<{\n\t\t\t\t\t\tmethod: string;\n\t\t\t\t\t\texpression: CronExpression;\n\t\t\t\t\t\toptions: CronOptions;\n\t\t\t\t }>\n\t\t\t\t| undefined) ?? [];\n\t\thooks.push({ method: String(propertyKey), expression, options });\n\t\tReflect.defineMetadata(CRON_META, hooks, ctor);\n\t};\n}\n\n/**\n * Schedule the decorated method to run every `milliseconds`.\n */\nexport function Interval(milliseconds: number, name?: string): MethodDecorator {\n\treturn (target, propertyKey, descriptor) => {\n\t\tif (!descriptor || typeof descriptor.value !== \"function\") {\n\t\t\tthrow new Error(\"@Interval can only decorate methods.\");\n\t\t}\n\t\tconst ctor = target.constructor as object;\n\t\tconst hooks: Array<{\n\t\t\tmethod: string;\n\t\t\tmilliseconds: number;\n\t\t\tname?: string;\n\t\t}> =\n\t\t\t(Reflect.getMetadata(INTERVAL_META, ctor) as\n\t\t\t\t| Array<{ method: string; milliseconds: number; name?: string }>\n\t\t\t\t| undefined) ?? [];\n\t\thooks.push({ method: String(propertyKey), milliseconds, name });\n\t\tReflect.defineMetadata(INTERVAL_META, hooks, ctor);\n\t};\n}\n\n/**\n * Schedule the decorated method to run once after `milliseconds`.\n */\nexport function Timeout(milliseconds: number, name?: string): MethodDecorator {\n\treturn (target, propertyKey, descriptor) => {\n\t\tif (!descriptor || typeof descriptor.value !== \"function\") {\n\t\t\tthrow new Error(\"@Timeout can only decorate methods.\");\n\t\t}\n\t\tconst ctor = target.constructor as object;\n\t\tconst hooks: Array<{\n\t\t\tmethod: string;\n\t\t\tmilliseconds: number;\n\t\t\tname?: string;\n\t\t}> =\n\t\t\t(Reflect.getMetadata(TIMEOUT_META, ctor) as\n\t\t\t\t| Array<{ method: string; milliseconds: number; name?: string }>\n\t\t\t\t| undefined) ?? [];\n\t\thooks.push({ method: String(propertyKey), milliseconds, name });\n\t\tReflect.defineMetadata(TIMEOUT_META, hooks, ctor);\n\t};\n}\n\n/**\n * Get the cron hooks declared on a class.\n */\nexport function getCronHooks(\n\ttarget: unknown,\n): Array<{ method: string; expression: CronExpression; options: CronOptions }> {\n\tconst ctor =\n\t\t(target as { constructor?: object }).constructor ?? (target as object);\n\treturn (\n\t\t(Reflect.getMetadata(CRON_META, ctor) as\n\t\t\t| Array<{\n\t\t\t\t\tmethod: string;\n\t\t\t\t\texpression: CronExpression;\n\t\t\t\t\toptions: CronOptions;\n\t\t\t }>\n\t\t\t| undefined) ?? []\n\t);\n}\n\nexport function getIntervalHooks(\n\ttarget: unknown,\n): Array<{ method: string; milliseconds: number; name?: string }> {\n\tconst ctor =\n\t\t(target as { constructor?: object }).constructor ?? (target as object);\n\treturn (\n\t\t(Reflect.getMetadata(INTERVAL_META, ctor) as\n\t\t\t| Array<{ method: string; milliseconds: number; name?: string }>\n\t\t\t| undefined) ?? []\n\t);\n}\n\nexport function getTimeoutHooks(\n\ttarget: unknown,\n): Array<{ method: string; milliseconds: number; name?: string }> {\n\tconst ctor =\n\t\t(target as { constructor?: object }).constructor ?? (target as object);\n\treturn (\n\t\t(Reflect.getMetadata(TIMEOUT_META, ctor) as\n\t\t\t| Array<{ method: string; milliseconds: number; name?: string }>\n\t\t\t| undefined) ?? []\n\t);\n}\n\n/**\n * Scan an instance for `@Cron` / `@Interval` / `@Timeout` hooks and\n * register them with the `ScheduleService`.\n */\nexport async function scanForSchedulers(\n\tinstance: object,\n\tservice: ScheduleService,\n): Promise<string[]> {\n\tconst ids: string[] = [];\n\n\tfor (const h of getCronHooks(instance)) {\n\t\tconst fn = (instance as Record<string, unknown>)[h.method] as\n\t\t\t| ScheduleHandler\n\t\t\t| undefined;\n\t\tif (typeof fn !== \"function\") continue;\n\t\tconst id = service.addCron(h.expression, fn.bind(instance), {\n\t\t\t...h.options,\n\t\t\tname: h.options.name ?? `${instance.constructor.name}.${h.method}`,\n\t\t});\n\t\tids.push(id);\n\t}\n\n\tfor (const h of getIntervalHooks(instance)) {\n\t\tconst fn = (instance as Record<string, unknown>)[h.method] as\n\t\t\t| ScheduleHandler\n\t\t\t| undefined;\n\t\tif (typeof fn !== \"function\") continue;\n\t\tconst id = service.addInterval(\n\t\t\th.milliseconds,\n\t\t\tfn.bind(instance),\n\t\t\th.name ?? `${instance.constructor.name}.${h.method}`,\n\t\t);\n\t\tids.push(id);\n\t}\n\n\tfor (const h of getTimeoutHooks(instance)) {\n\t\tconst fn = (instance as Record<string, unknown>)[h.method] as\n\t\t\t| ScheduleHandler\n\t\t\t| undefined;\n\t\tif (typeof fn !== \"function\") continue;\n\t\tconst id = service.addTimeout(\n\t\t\th.milliseconds,\n\t\t\tfn.bind(instance),\n\t\t\th.name ?? `${instance.constructor.name}.${h.method}`,\n\t\t);\n\t\tids.push(id);\n\t}\n\n\treturn ids;\n}\n\n// Re-export for convenience.\nexport type { ScheduleService };\n"
|
|
11
|
+
],
|
|
12
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAsBA,IAAM,eAAwC;AAAA,EAC7C,CAAC,GAAG,EAAE;AAAA,EACN,CAAC,GAAG,EAAE;AAAA,EACN,CAAC,GAAG,EAAE;AAAA,EACN,CAAC,GAAG,EAAE;AAAA,EACN,CAAC,GAAG,CAAC;AACN;AAEA,IAAM,cAAsC;AAAA,EAC3C,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AACN;AAEA,IAAM,UAAkC;AAAA,EACvC,WAAW;AAAA,EACX,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,UAAU;AAAA,EACV,aAAa;AAAA,EACb,WAAW;AACZ;AAAA;AAGO,MAAM,UAAU;AAAA,EACb;AAAA,EAET,WAAW,CAAC,OAAe,OAAyB;AAAA,IACnD,KAAK,SAAS,WAAW,OA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AAA,MACL,MAAM,EAAE,QAAQ,QAAQ,GAAG,SAAS,YAAY,QAAQ,EAAE;AAAA,IAC3D,CAAC;AAAA,IACD,IAAI,KAAK,EAAE;AAAA,EACZ;AAAA,EAEA,WAAW,KAAK,iBAAiB,QAAQ,GAAG;AAAA,IAC3C,MAAM,KAAM,SAAqC,EAAE;AAAA,IAGnD,IAAI,OAAO,OAAO;AAAA,MAAY;AAAA,IAC9B,MAAM,KAAK,QAAQ,YAClB,EAAE,cACF,GAAG,KAAK,QAAQ,GAChB,EAAE,QAAQ,GAAG,SAAS,YAAY,QAAQ,EAAE,QAC7C;AAAA,IACA,IAAI,KAAK,EAAE;AAAA,EACZ;AAAA,EAEA,WAAW,KAAK,gBAAgB,QAAQ,GAAG;AAAA,IAC1C,MAAM,KAAM,SAAqC,EAAE;AAAA,IAGnD,IAAI,OAAO,OAAO;AAAA,MAAY;AAAA,IAC9B,MAAM,KAAK,QAAQ,WAClB,EAAE,cACF,GAAG,KAAK,QAAQ,GAChB,EAAE,QAAQ,GAAG,SAAS,YAAY,QAAQ,EAAE,QAC7C;AAAA,IACA,IAAI,KAAK,EAAE;AAAA,EACZ;AAAA,EAEA,OAAO;AAAA;",
|
|
13
|
+
"debugId": "5FC679DEFC3E1FEA64756E2164756E21",
|
|
14
|
+
"names": []
|
|
15
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nexusts/schedule",
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"description": "Cron scheduling (@Cron / @Interval / @Timeout)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "bun run ../../build.ts"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"nexusts",
|
|
24
|
+
"framework",
|
|
25
|
+
"bun"
|
|
26
|
+
],
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@nexusts/core": "^0.7.0"
|
|
30
|
+
}
|
|
31
|
+
}
|