@nest-native/jobs 0.1.0 → 0.2.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 +33 -5
- package/dist/dialects/mysql/index.d.ts +1 -0
- package/dist/dialects/mysql/index.js +1 -0
- package/dist/dialects/mysql/index.js.map +1 -1
- package/dist/dialects/mysql/schedule-store.d.ts +36 -0
- package/dist/dialects/mysql/schedule-store.js +185 -0
- package/dist/dialects/mysql/schedule-store.js.map +1 -0
- package/dist/dialects/mysql/schema.d.ts +274 -0
- package/dist/dialects/mysql/schema.js +31 -1
- package/dist/dialects/mysql/schema.js.map +1 -1
- package/dist/dialects/postgres/index.d.ts +1 -0
- package/dist/dialects/postgres/index.js +1 -0
- package/dist/dialects/postgres/index.js.map +1 -1
- package/dist/dialects/postgres/schedule-store.d.ts +22 -0
- package/dist/dialects/postgres/schedule-store.js +143 -0
- package/dist/dialects/postgres/schedule-store.js.map +1 -0
- package/dist/dialects/postgres/schema.d.ts +273 -0
- package/dist/dialects/postgres/schema.js +30 -1
- package/dist/dialects/postgres/schema.js.map +1 -1
- package/dist/dialects/sqlite/index.d.ts +1 -0
- package/dist/dialects/sqlite/index.js +2 -1
- package/dist/dialects/sqlite/index.js.map +1 -1
- package/dist/dialects/sqlite/schedule-store.d.ts +23 -0
- package/dist/dialects/sqlite/schedule-store.js +153 -0
- package/dist/dialects/sqlite/schedule-store.js.map +1 -0
- package/dist/dialects/sqlite/schema.d.ts +295 -0
- package/dist/dialects/sqlite/schema.js +32 -1
- package/dist/dialects/sqlite/schema.js.map +1 -1
- package/dist/errors.d.ts +10 -0
- package/dist/errors.js +15 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +137 -0
- package/dist/job-schedules.service.d.ts +44 -0
- package/dist/job-schedules.service.js +125 -0
- package/dist/job-schedules.service.js.map +1 -0
- package/dist/jobs-claimer.service.d.ts +16 -2
- package/dist/jobs-claimer.service.js +71 -2
- package/dist/jobs-claimer.service.js.map +1 -1
- package/dist/jobs.module.d.ts +3 -1
- package/dist/jobs.module.js +17 -2
- package/dist/jobs.module.js.map +1 -1
- package/dist/schedule-planner.d.ts +30 -0
- package/dist/schedule-planner.js +58 -0
- package/dist/schedule-planner.js.map +1 -0
- package/dist/testing/harness.js +2 -1
- package/dist/testing/harness.js.map +1 -1
- package/dist/tokens.d.ts +5 -0
- package/dist/tokens.js +6 -1
- package/dist/tokens.js.map +1 -1
- package/package.json +6 -4
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SqliteScheduleStore = void 0;
|
|
4
|
+
const node_crypto_1 = require("node:crypto");
|
|
5
|
+
const drizzle_orm_1 = require("drizzle-orm");
|
|
6
|
+
const schema_1 = require("./schema");
|
|
7
|
+
/**
|
|
8
|
+
* SQLite (better-sqlite3) schedule store. Like {@link SqliteJobStore}, every
|
|
9
|
+
* method runs **synchronously** — `upsert` returns the row directly so it
|
|
10
|
+
* composes inside a synchronous `@Transactional` body; the rest wrap their
|
|
11
|
+
* synchronous result in a resolved Promise.
|
|
12
|
+
*
|
|
13
|
+
* `claimAndEnqueue` runs the compare-and-swap on `next_run_at` and the
|
|
14
|
+
* occurrence insert in ONE synchronous transaction. The insert uses
|
|
15
|
+
* `ON CONFLICT DO NOTHING` on `(name, unique_key)` so an active occurrence
|
|
16
|
+
* with the schedule's `uniqueKey` suppresses the new one (the overlap guard)
|
|
17
|
+
* without poisoning the transaction — the schedule row still advances.
|
|
18
|
+
*/
|
|
19
|
+
class SqliteScheduleStore {
|
|
20
|
+
upsert(db, input) {
|
|
21
|
+
const nowIso = new Date().toISOString();
|
|
22
|
+
return db
|
|
23
|
+
.insert(schema_1.jobSchedules)
|
|
24
|
+
.values({
|
|
25
|
+
id: (0, node_crypto_1.randomUUID)(),
|
|
26
|
+
...input,
|
|
27
|
+
enabled: input.enabled ?? true,
|
|
28
|
+
lastEnqueuedAt: null,
|
|
29
|
+
lastError: null,
|
|
30
|
+
createdAt: nowIso,
|
|
31
|
+
updatedAt: nowIso,
|
|
32
|
+
})
|
|
33
|
+
.onConflictDoUpdate({
|
|
34
|
+
target: schema_1.jobSchedules.name,
|
|
35
|
+
// Updates keep id / createdAt / lastEnqueuedAt; a successful upsert
|
|
36
|
+
// clears any stale claim-time error. Two deliberate preservations
|
|
37
|
+
// make boot-time upserts safe: an omitted `enabled` (null) keeps the
|
|
38
|
+
// stored flag (ops kill switches survive redeploys), and the stored
|
|
39
|
+
// `next_run_at` survives while cron/timezone are unchanged (a pending
|
|
40
|
+
// catch-up is not skipped; the rhythm is not perturbed). `IS` is
|
|
41
|
+
// SQLite's null-safe equality.
|
|
42
|
+
set: {
|
|
43
|
+
nextRunAt: (0, drizzle_orm_1.sql) `CASE WHEN ${schema_1.jobSchedules.cron} = excluded.cron AND ${schema_1.jobSchedules.timezone} IS excluded.timezone AND ${schema_1.jobSchedules.nextRunAt} IS NOT NULL THEN ${schema_1.jobSchedules.nextRunAt} ELSE excluded.next_run_at END`,
|
|
44
|
+
jobName: input.jobName,
|
|
45
|
+
payload: input.payload,
|
|
46
|
+
cron: input.cron,
|
|
47
|
+
timezone: input.timezone,
|
|
48
|
+
maxAttempts: input.maxAttempts,
|
|
49
|
+
priority: input.priority,
|
|
50
|
+
uniqueKey: input.uniqueKey,
|
|
51
|
+
lastError: null,
|
|
52
|
+
updatedAt: nowIso,
|
|
53
|
+
...(input.enabled !== null && { enabled: input.enabled }),
|
|
54
|
+
},
|
|
55
|
+
})
|
|
56
|
+
.returning()
|
|
57
|
+
.get();
|
|
58
|
+
}
|
|
59
|
+
get(db, name) {
|
|
60
|
+
const row = db
|
|
61
|
+
.select()
|
|
62
|
+
.from(schema_1.jobSchedules)
|
|
63
|
+
.where((0, drizzle_orm_1.eq)(schema_1.jobSchedules.name, name))
|
|
64
|
+
.get();
|
|
65
|
+
return Promise.resolve(row);
|
|
66
|
+
}
|
|
67
|
+
list(db) {
|
|
68
|
+
return Promise.resolve(db
|
|
69
|
+
.select()
|
|
70
|
+
.from(schema_1.jobSchedules)
|
|
71
|
+
.orderBy((0, drizzle_orm_1.asc)(schema_1.jobSchedules.name))
|
|
72
|
+
.all());
|
|
73
|
+
}
|
|
74
|
+
remove(db, name) {
|
|
75
|
+
const result = db
|
|
76
|
+
.delete(schema_1.jobSchedules)
|
|
77
|
+
.where((0, drizzle_orm_1.eq)(schema_1.jobSchedules.name, name))
|
|
78
|
+
.run();
|
|
79
|
+
return Promise.resolve(result.changes > 0);
|
|
80
|
+
}
|
|
81
|
+
setEnabled(db, name, enabled, nextRunAt, expectedUpdatedAt) {
|
|
82
|
+
const rows = db
|
|
83
|
+
.update(schema_1.jobSchedules)
|
|
84
|
+
.set({ enabled, nextRunAt, updatedAt: new Date().toISOString() })
|
|
85
|
+
.where((0, drizzle_orm_1.and)((0, drizzle_orm_1.eq)(schema_1.jobSchedules.name, name),
|
|
86
|
+
// Optimistic guard: only write over the row version the caller read.
|
|
87
|
+
...(expectedUpdatedAt === undefined
|
|
88
|
+
? []
|
|
89
|
+
: [(0, drizzle_orm_1.eq)(schema_1.jobSchedules.updatedAt, expectedUpdatedAt)])))
|
|
90
|
+
.returning()
|
|
91
|
+
.all();
|
|
92
|
+
return Promise.resolve(rows[0]);
|
|
93
|
+
}
|
|
94
|
+
listDue(db, nowIso, limit) {
|
|
95
|
+
return Promise.resolve(db
|
|
96
|
+
.select()
|
|
97
|
+
.from(schema_1.jobSchedules)
|
|
98
|
+
.where((0, drizzle_orm_1.and)((0, drizzle_orm_1.eq)(schema_1.jobSchedules.enabled, true), (0, drizzle_orm_1.isNotNull)(schema_1.jobSchedules.nextRunAt), (0, drizzle_orm_1.lte)(schema_1.jobSchedules.nextRunAt, nowIso)))
|
|
99
|
+
.orderBy((0, drizzle_orm_1.asc)(schema_1.jobSchedules.nextRunAt))
|
|
100
|
+
.limit(limit)
|
|
101
|
+
.all());
|
|
102
|
+
}
|
|
103
|
+
claimAndEnqueue(db, claim) {
|
|
104
|
+
const result = db.transaction((tx) => {
|
|
105
|
+
const cas = tx
|
|
106
|
+
.update(schema_1.jobSchedules)
|
|
107
|
+
.set({
|
|
108
|
+
nextRunAt: claim.nextRunAt,
|
|
109
|
+
// A schedule with no future occurrence disables itself.
|
|
110
|
+
enabled: claim.nextRunAt !== null,
|
|
111
|
+
lastEnqueuedAt: claim.nowIso,
|
|
112
|
+
lastError: null,
|
|
113
|
+
updatedAt: claim.nowIso,
|
|
114
|
+
})
|
|
115
|
+
.where((0, drizzle_orm_1.and)((0, drizzle_orm_1.eq)(schema_1.jobSchedules.id, claim.id), (0, drizzle_orm_1.eq)(schema_1.jobSchedules.nextRunAt, claim.expectedNextRunAt), (0, drizzle_orm_1.eq)(schema_1.jobSchedules.enabled, true)))
|
|
116
|
+
.run();
|
|
117
|
+
if (cas.changes === 0) {
|
|
118
|
+
return { claimed: false, job: null };
|
|
119
|
+
}
|
|
120
|
+
const inserted = tx
|
|
121
|
+
.insert(schema_1.jobs)
|
|
122
|
+
.values({
|
|
123
|
+
id: (0, node_crypto_1.randomUUID)(),
|
|
124
|
+
name: claim.input.name,
|
|
125
|
+
payload: claim.input.payload,
|
|
126
|
+
status: 'pending',
|
|
127
|
+
maxAttempts: claim.input.maxAttempts ?? 10,
|
|
128
|
+
uniqueKey: claim.input.uniqueKey ?? null,
|
|
129
|
+
priority: claim.input.priority ?? 0,
|
|
130
|
+
availableAt: claim.nowIso,
|
|
131
|
+
createdAt: claim.nowIso,
|
|
132
|
+
})
|
|
133
|
+
.onConflictDoNothing({ target: [schema_1.jobs.name, schema_1.jobs.uniqueKey] })
|
|
134
|
+
.returning()
|
|
135
|
+
.all();
|
|
136
|
+
// An empty RETURNING means the overlap guard suppressed the insert (an
|
|
137
|
+
// occurrence with this (name, unique_key) is still active) — the
|
|
138
|
+
// schedule still advanced; there is just no new job.
|
|
139
|
+
return { claimed: true, job: inserted.length > 0 ? inserted[0] : null };
|
|
140
|
+
});
|
|
141
|
+
return Promise.resolve(result);
|
|
142
|
+
}
|
|
143
|
+
disable(db, id, lastError) {
|
|
144
|
+
db
|
|
145
|
+
.update(schema_1.jobSchedules)
|
|
146
|
+
.set({ enabled: false, lastError, updatedAt: new Date().toISOString() })
|
|
147
|
+
.where((0, drizzle_orm_1.eq)(schema_1.jobSchedules.id, id))
|
|
148
|
+
.run();
|
|
149
|
+
return Promise.resolve();
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
exports.SqliteScheduleStore = SqliteScheduleStore;
|
|
153
|
+
//# sourceMappingURL=schedule-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schedule-store.js","sourceRoot":"","sources":["../../../dialects/sqlite/schedule-store.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AACzC,6CAAgE;AAShE,qCAA8C;AAI9C;;;;;;;;;;;GAWG;AACH,MAAa,mBAAmB;IAC9B,MAAM,CAAC,EAAW,EAAE,KAA6B;QAC/C,MAAM,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QACxC,OAAQ,EAAS;aACd,MAAM,CAAC,qBAAY,CAAC;aACpB,MAAM,CAAC;YACN,EAAE,EAAE,IAAA,wBAAU,GAAE;YAChB,GAAG,KAAK;YACR,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,IAAI;YAC9B,cAAc,EAAE,IAAI;YACpB,SAAS,EAAE,IAAI;YACf,SAAS,EAAE,MAAM;YACjB,SAAS,EAAE,MAAM;SAClB,CAAC;aACD,kBAAkB,CAAC;YAClB,MAAM,EAAE,qBAAY,CAAC,IAAI;YACzB,oEAAoE;YACpE,kEAAkE;YAClE,qEAAqE;YACrE,oEAAoE;YACpE,sEAAsE;YACtE,iEAAiE;YACjE,+BAA+B;YAC/B,GAAG,EAAE;gBACH,SAAS,EAAE,IAAA,iBAAG,EAAA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AK,CAAC,KAAK,CAAC,SAAS,IAAI,IAAI;gBACxC,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,QAAQ,IAAI,CAAC;gBACnC,WAAW,EAAE,KAAK,CAAC,MAAM;gBACzB,SAAS,EAAE,KAAK,CAAC,MAAM;aACxB,CAAC;iBACD,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC,aAAI,CAAC,IAAI,EAAE,aAAI,CAAC,SAAS,CAAC,EAAE,CAAC;iBAC5D,SAAS,EAAE;iBACX,GAAG,EAAE,CAAC;YACT,uEAAuE;YACvE,iEAAiE;YACjE,qDAAqD;YACrD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC1E,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAED,OAAO,CAAC,EAAW,EAAE,EAAU,EAAE,SAAiB;QAC/C,EAAS;aACP,MAAM,CAAC,qBAAY,CAAC;aACpB,GAAG,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC;aACvE,KAAK,CAAC,IAAA,gBAAE,EAAC,qBAAY,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;aAC9B,GAAG,EAAE,CAAC;QACT,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;CACF;AArKD,kDAqKC"}
|
|
@@ -277,3 +277,298 @@ export declare const jobs: import("drizzle-orm/sqlite-core").SQLiteTableWithColu
|
|
|
277
277
|
};
|
|
278
278
|
dialect: "sqlite";
|
|
279
279
|
}>;
|
|
280
|
+
/**
|
|
281
|
+
* SQLite `job_schedules` table. Add it to your Drizzle schema (alongside
|
|
282
|
+
* `jobs`) and generate a migration with drizzle-kit — only needed when you
|
|
283
|
+
* opt in to schedules.
|
|
284
|
+
*
|
|
285
|
+
* `name` is the unique schedule identity (upserts key on it); the
|
|
286
|
+
* `(enabled, next_run_at)` index serves the claimer's due query. Timestamps
|
|
287
|
+
* are ISO-8601 strings, like every timestamp in this package.
|
|
288
|
+
*/
|
|
289
|
+
export declare const jobSchedules: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
|
|
290
|
+
name: "job_schedules";
|
|
291
|
+
schema: undefined;
|
|
292
|
+
columns: {
|
|
293
|
+
id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
294
|
+
name: "id";
|
|
295
|
+
tableName: "job_schedules";
|
|
296
|
+
dataType: "string";
|
|
297
|
+
columnType: "SQLiteText";
|
|
298
|
+
data: string;
|
|
299
|
+
driverParam: string;
|
|
300
|
+
notNull: true;
|
|
301
|
+
hasDefault: false;
|
|
302
|
+
isPrimaryKey: true;
|
|
303
|
+
isAutoincrement: false;
|
|
304
|
+
hasRuntimeDefault: false;
|
|
305
|
+
enumValues: [string, ...string[]];
|
|
306
|
+
baseColumn: never;
|
|
307
|
+
identity: undefined;
|
|
308
|
+
generated: undefined;
|
|
309
|
+
}, {}, {
|
|
310
|
+
length: number | undefined;
|
|
311
|
+
}>;
|
|
312
|
+
name: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
313
|
+
name: "name";
|
|
314
|
+
tableName: "job_schedules";
|
|
315
|
+
dataType: "string";
|
|
316
|
+
columnType: "SQLiteText";
|
|
317
|
+
data: string;
|
|
318
|
+
driverParam: string;
|
|
319
|
+
notNull: true;
|
|
320
|
+
hasDefault: false;
|
|
321
|
+
isPrimaryKey: false;
|
|
322
|
+
isAutoincrement: false;
|
|
323
|
+
hasRuntimeDefault: false;
|
|
324
|
+
enumValues: [string, ...string[]];
|
|
325
|
+
baseColumn: never;
|
|
326
|
+
identity: undefined;
|
|
327
|
+
generated: undefined;
|
|
328
|
+
}, {}, {
|
|
329
|
+
length: number | undefined;
|
|
330
|
+
}>;
|
|
331
|
+
jobName: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
332
|
+
name: "job_name";
|
|
333
|
+
tableName: "job_schedules";
|
|
334
|
+
dataType: "string";
|
|
335
|
+
columnType: "SQLiteText";
|
|
336
|
+
data: string;
|
|
337
|
+
driverParam: string;
|
|
338
|
+
notNull: true;
|
|
339
|
+
hasDefault: false;
|
|
340
|
+
isPrimaryKey: false;
|
|
341
|
+
isAutoincrement: false;
|
|
342
|
+
hasRuntimeDefault: false;
|
|
343
|
+
enumValues: [string, ...string[]];
|
|
344
|
+
baseColumn: never;
|
|
345
|
+
identity: undefined;
|
|
346
|
+
generated: undefined;
|
|
347
|
+
}, {}, {
|
|
348
|
+
length: number | undefined;
|
|
349
|
+
}>;
|
|
350
|
+
payload: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
351
|
+
name: "payload";
|
|
352
|
+
tableName: "job_schedules";
|
|
353
|
+
dataType: "json";
|
|
354
|
+
columnType: "SQLiteTextJson";
|
|
355
|
+
data: Record<string, unknown>;
|
|
356
|
+
driverParam: string;
|
|
357
|
+
notNull: true;
|
|
358
|
+
hasDefault: false;
|
|
359
|
+
isPrimaryKey: false;
|
|
360
|
+
isAutoincrement: false;
|
|
361
|
+
hasRuntimeDefault: false;
|
|
362
|
+
enumValues: undefined;
|
|
363
|
+
baseColumn: never;
|
|
364
|
+
identity: undefined;
|
|
365
|
+
generated: undefined;
|
|
366
|
+
}, {}, {
|
|
367
|
+
$type: Record<string, unknown>;
|
|
368
|
+
}>;
|
|
369
|
+
cron: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
370
|
+
name: "cron";
|
|
371
|
+
tableName: "job_schedules";
|
|
372
|
+
dataType: "string";
|
|
373
|
+
columnType: "SQLiteText";
|
|
374
|
+
data: string;
|
|
375
|
+
driverParam: string;
|
|
376
|
+
notNull: true;
|
|
377
|
+
hasDefault: false;
|
|
378
|
+
isPrimaryKey: false;
|
|
379
|
+
isAutoincrement: false;
|
|
380
|
+
hasRuntimeDefault: false;
|
|
381
|
+
enumValues: [string, ...string[]];
|
|
382
|
+
baseColumn: never;
|
|
383
|
+
identity: undefined;
|
|
384
|
+
generated: undefined;
|
|
385
|
+
}, {}, {
|
|
386
|
+
length: number | undefined;
|
|
387
|
+
}>;
|
|
388
|
+
timezone: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
389
|
+
name: "timezone";
|
|
390
|
+
tableName: "job_schedules";
|
|
391
|
+
dataType: "string";
|
|
392
|
+
columnType: "SQLiteText";
|
|
393
|
+
data: string;
|
|
394
|
+
driverParam: string;
|
|
395
|
+
notNull: false;
|
|
396
|
+
hasDefault: false;
|
|
397
|
+
isPrimaryKey: false;
|
|
398
|
+
isAutoincrement: false;
|
|
399
|
+
hasRuntimeDefault: false;
|
|
400
|
+
enumValues: [string, ...string[]];
|
|
401
|
+
baseColumn: never;
|
|
402
|
+
identity: undefined;
|
|
403
|
+
generated: undefined;
|
|
404
|
+
}, {}, {
|
|
405
|
+
length: number | undefined;
|
|
406
|
+
}>;
|
|
407
|
+
enabled: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
408
|
+
name: "enabled";
|
|
409
|
+
tableName: "job_schedules";
|
|
410
|
+
dataType: "boolean";
|
|
411
|
+
columnType: "SQLiteBoolean";
|
|
412
|
+
data: boolean;
|
|
413
|
+
driverParam: number;
|
|
414
|
+
notNull: true;
|
|
415
|
+
hasDefault: true;
|
|
416
|
+
isPrimaryKey: false;
|
|
417
|
+
isAutoincrement: false;
|
|
418
|
+
hasRuntimeDefault: false;
|
|
419
|
+
enumValues: undefined;
|
|
420
|
+
baseColumn: never;
|
|
421
|
+
identity: undefined;
|
|
422
|
+
generated: undefined;
|
|
423
|
+
}, {}, {}>;
|
|
424
|
+
nextRunAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
425
|
+
name: "next_run_at";
|
|
426
|
+
tableName: "job_schedules";
|
|
427
|
+
dataType: "string";
|
|
428
|
+
columnType: "SQLiteText";
|
|
429
|
+
data: string;
|
|
430
|
+
driverParam: string;
|
|
431
|
+
notNull: false;
|
|
432
|
+
hasDefault: false;
|
|
433
|
+
isPrimaryKey: false;
|
|
434
|
+
isAutoincrement: false;
|
|
435
|
+
hasRuntimeDefault: false;
|
|
436
|
+
enumValues: [string, ...string[]];
|
|
437
|
+
baseColumn: never;
|
|
438
|
+
identity: undefined;
|
|
439
|
+
generated: undefined;
|
|
440
|
+
}, {}, {
|
|
441
|
+
length: number | undefined;
|
|
442
|
+
}>;
|
|
443
|
+
maxAttempts: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
444
|
+
name: "max_attempts";
|
|
445
|
+
tableName: "job_schedules";
|
|
446
|
+
dataType: "number";
|
|
447
|
+
columnType: "SQLiteInteger";
|
|
448
|
+
data: number;
|
|
449
|
+
driverParam: number;
|
|
450
|
+
notNull: false;
|
|
451
|
+
hasDefault: false;
|
|
452
|
+
isPrimaryKey: false;
|
|
453
|
+
isAutoincrement: false;
|
|
454
|
+
hasRuntimeDefault: false;
|
|
455
|
+
enumValues: undefined;
|
|
456
|
+
baseColumn: never;
|
|
457
|
+
identity: undefined;
|
|
458
|
+
generated: undefined;
|
|
459
|
+
}, {}, {}>;
|
|
460
|
+
priority: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
461
|
+
name: "priority";
|
|
462
|
+
tableName: "job_schedules";
|
|
463
|
+
dataType: "number";
|
|
464
|
+
columnType: "SQLiteInteger";
|
|
465
|
+
data: number;
|
|
466
|
+
driverParam: number;
|
|
467
|
+
notNull: false;
|
|
468
|
+
hasDefault: false;
|
|
469
|
+
isPrimaryKey: false;
|
|
470
|
+
isAutoincrement: false;
|
|
471
|
+
hasRuntimeDefault: false;
|
|
472
|
+
enumValues: undefined;
|
|
473
|
+
baseColumn: never;
|
|
474
|
+
identity: undefined;
|
|
475
|
+
generated: undefined;
|
|
476
|
+
}, {}, {}>;
|
|
477
|
+
uniqueKey: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
478
|
+
name: "unique_key";
|
|
479
|
+
tableName: "job_schedules";
|
|
480
|
+
dataType: "string";
|
|
481
|
+
columnType: "SQLiteText";
|
|
482
|
+
data: string;
|
|
483
|
+
driverParam: string;
|
|
484
|
+
notNull: false;
|
|
485
|
+
hasDefault: false;
|
|
486
|
+
isPrimaryKey: false;
|
|
487
|
+
isAutoincrement: false;
|
|
488
|
+
hasRuntimeDefault: false;
|
|
489
|
+
enumValues: [string, ...string[]];
|
|
490
|
+
baseColumn: never;
|
|
491
|
+
identity: undefined;
|
|
492
|
+
generated: undefined;
|
|
493
|
+
}, {}, {
|
|
494
|
+
length: number | undefined;
|
|
495
|
+
}>;
|
|
496
|
+
lastEnqueuedAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
497
|
+
name: "last_enqueued_at";
|
|
498
|
+
tableName: "job_schedules";
|
|
499
|
+
dataType: "string";
|
|
500
|
+
columnType: "SQLiteText";
|
|
501
|
+
data: string;
|
|
502
|
+
driverParam: string;
|
|
503
|
+
notNull: false;
|
|
504
|
+
hasDefault: false;
|
|
505
|
+
isPrimaryKey: false;
|
|
506
|
+
isAutoincrement: false;
|
|
507
|
+
hasRuntimeDefault: false;
|
|
508
|
+
enumValues: [string, ...string[]];
|
|
509
|
+
baseColumn: never;
|
|
510
|
+
identity: undefined;
|
|
511
|
+
generated: undefined;
|
|
512
|
+
}, {}, {
|
|
513
|
+
length: number | undefined;
|
|
514
|
+
}>;
|
|
515
|
+
lastError: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
516
|
+
name: "last_error";
|
|
517
|
+
tableName: "job_schedules";
|
|
518
|
+
dataType: "string";
|
|
519
|
+
columnType: "SQLiteText";
|
|
520
|
+
data: string;
|
|
521
|
+
driverParam: string;
|
|
522
|
+
notNull: false;
|
|
523
|
+
hasDefault: false;
|
|
524
|
+
isPrimaryKey: false;
|
|
525
|
+
isAutoincrement: false;
|
|
526
|
+
hasRuntimeDefault: false;
|
|
527
|
+
enumValues: [string, ...string[]];
|
|
528
|
+
baseColumn: never;
|
|
529
|
+
identity: undefined;
|
|
530
|
+
generated: undefined;
|
|
531
|
+
}, {}, {
|
|
532
|
+
length: number | undefined;
|
|
533
|
+
}>;
|
|
534
|
+
createdAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
535
|
+
name: "created_at";
|
|
536
|
+
tableName: "job_schedules";
|
|
537
|
+
dataType: "string";
|
|
538
|
+
columnType: "SQLiteText";
|
|
539
|
+
data: string;
|
|
540
|
+
driverParam: string;
|
|
541
|
+
notNull: true;
|
|
542
|
+
hasDefault: false;
|
|
543
|
+
isPrimaryKey: false;
|
|
544
|
+
isAutoincrement: false;
|
|
545
|
+
hasRuntimeDefault: false;
|
|
546
|
+
enumValues: [string, ...string[]];
|
|
547
|
+
baseColumn: never;
|
|
548
|
+
identity: undefined;
|
|
549
|
+
generated: undefined;
|
|
550
|
+
}, {}, {
|
|
551
|
+
length: number | undefined;
|
|
552
|
+
}>;
|
|
553
|
+
updatedAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
554
|
+
name: "updated_at";
|
|
555
|
+
tableName: "job_schedules";
|
|
556
|
+
dataType: "string";
|
|
557
|
+
columnType: "SQLiteText";
|
|
558
|
+
data: string;
|
|
559
|
+
driverParam: string;
|
|
560
|
+
notNull: true;
|
|
561
|
+
hasDefault: false;
|
|
562
|
+
isPrimaryKey: false;
|
|
563
|
+
isAutoincrement: false;
|
|
564
|
+
hasRuntimeDefault: false;
|
|
565
|
+
enumValues: [string, ...string[]];
|
|
566
|
+
baseColumn: never;
|
|
567
|
+
identity: undefined;
|
|
568
|
+
generated: undefined;
|
|
569
|
+
}, {}, {
|
|
570
|
+
length: number | undefined;
|
|
571
|
+
}>;
|
|
572
|
+
};
|
|
573
|
+
dialect: "sqlite";
|
|
574
|
+
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.jobs = void 0;
|
|
3
|
+
exports.jobSchedules = exports.jobs = void 0;
|
|
4
4
|
const sqlite_core_1 = require("drizzle-orm/sqlite-core");
|
|
5
5
|
/**
|
|
6
6
|
* SQLite `jobs` table. Add it to your Drizzle schema and generate a migration
|
|
@@ -34,4 +34,35 @@ exports.jobs = (0, sqlite_core_1.sqliteTable)('jobs', {
|
|
|
34
34
|
(0, sqlite_core_1.uniqueIndex)('jobs_name_unique_key_unique').on(table.name, table.uniqueKey),
|
|
35
35
|
(0, sqlite_core_1.index)('jobs_status_available_idx').on(table.status, table.availableAt),
|
|
36
36
|
]);
|
|
37
|
+
/**
|
|
38
|
+
* SQLite `job_schedules` table. Add it to your Drizzle schema (alongside
|
|
39
|
+
* `jobs`) and generate a migration with drizzle-kit — only needed when you
|
|
40
|
+
* opt in to schedules.
|
|
41
|
+
*
|
|
42
|
+
* `name` is the unique schedule identity (upserts key on it); the
|
|
43
|
+
* `(enabled, next_run_at)` index serves the claimer's due query. Timestamps
|
|
44
|
+
* are ISO-8601 strings, like every timestamp in this package.
|
|
45
|
+
*/
|
|
46
|
+
exports.jobSchedules = (0, sqlite_core_1.sqliteTable)('job_schedules', {
|
|
47
|
+
id: (0, sqlite_core_1.text)('id').primaryKey(),
|
|
48
|
+
name: (0, sqlite_core_1.text)('name').notNull(),
|
|
49
|
+
jobName: (0, sqlite_core_1.text)('job_name').notNull(),
|
|
50
|
+
payload: (0, sqlite_core_1.text)('payload', { mode: 'json' })
|
|
51
|
+
.$type()
|
|
52
|
+
.notNull(),
|
|
53
|
+
cron: (0, sqlite_core_1.text)('cron').notNull(),
|
|
54
|
+
timezone: (0, sqlite_core_1.text)('timezone'),
|
|
55
|
+
enabled: (0, sqlite_core_1.integer)('enabled', { mode: 'boolean' }).notNull().default(true),
|
|
56
|
+
nextRunAt: (0, sqlite_core_1.text)('next_run_at'),
|
|
57
|
+
maxAttempts: (0, sqlite_core_1.integer)('max_attempts'),
|
|
58
|
+
priority: (0, sqlite_core_1.integer)('priority'),
|
|
59
|
+
uniqueKey: (0, sqlite_core_1.text)('unique_key'),
|
|
60
|
+
lastEnqueuedAt: (0, sqlite_core_1.text)('last_enqueued_at'),
|
|
61
|
+
lastError: (0, sqlite_core_1.text)('last_error'),
|
|
62
|
+
createdAt: (0, sqlite_core_1.text)('created_at').notNull(),
|
|
63
|
+
updatedAt: (0, sqlite_core_1.text)('updated_at').notNull(),
|
|
64
|
+
}, (table) => [
|
|
65
|
+
(0, sqlite_core_1.uniqueIndex)('job_schedules_name_unique').on(table.name),
|
|
66
|
+
(0, sqlite_core_1.index)('job_schedules_enabled_next_run_idx').on(table.enabled, table.nextRunAt),
|
|
67
|
+
]);
|
|
37
68
|
//# sourceMappingURL=schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../dialects/sqlite/schema.ts"],"names":[],"mappings":";;;AAAA,yDAMiC;AAGjC;;;;;;;;;;GAUG;AACU,QAAA,IAAI,GAAG,IAAA,yBAAW,EAC7B,MAAM,EACN;IACE,EAAE,EAAE,IAAA,kBAAI,EAAC,IAAI,CAAC,CAAC,UAAU,EAAE;IAC3B,IAAI,EAAE,IAAA,kBAAI,EAAC,MAAM,CAAC,CAAC,OAAO,EAAE;IAC5B,OAAO,EAAE,IAAA,kBAAI,EAAC,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;SACvC,KAAK,EAA2B;SAChC,OAAO,EAAE;IACZ,MAAM,EAAE,IAAA,kBAAI,EAAC,QAAQ,CAAC,CAAC,KAAK,EAAa,CAAC,OAAO,EAAE;IACnD,QAAQ,EAAE,IAAA,qBAAO,EAAC,UAAU,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAClD,WAAW,EAAE,IAAA,qBAAO,EAAC,cAAc,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CA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,OAAO,EAAE,IAAA,kBAAI,EAAC,UAAU,CAAC,CAAC,OAAO,EAAE;IACnC,OAAO,EAAE,IAAA,kBAAI,EAAC,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;SACvC,KAAK,EAA2B;SAChC,OAAO,EAAE;IACZ,IAAI,EAAE,IAAA,kBAAI,EAAC,MAAM,CAAC,CAAC,OAAO,EAAE;IAC5B,QAAQ,EAAE,IAAA,kBAAI,EAAC,UAAU,CAAC;IAC1B,OAAO,EAAE,IAAA,qBAAO,EAAC,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IACxE,SAAS,EAAE,IAAA,kBAAI,EAAC,aAAa,CAAC;IAC9B,WAAW,EAAE,IAAA,qBAAO,EAAC,cAAc,CAAC;IACpC,QAAQ,EAAE,IAAA,qBAAO,EAAC,UAAU,CAAC;IAC7B,SAAS,EAAE,IAAA,kBAAI,EAAC,YAAY,CAAC;IAC7B,cAAc,EAAE,IAAA,kBAAI,EAAC,kBAAkB,CAAC;IACxC,SAAS,EAAE,IAAA,kBAAI,EAAC,YAAY,CAAC;IAC7B,SAAS,EAAE,IAAA,kBAAI,EAAC,YAAY,CAAC,CAAC,OAAO,EAAE;IACvC,SAAS,EAAE,IAAA,kBAAI,EAAC,YAAY,CAAC,CAAC,OAAO,EAAE;CACxC,EACD,CAAC,KAAK,EAAE,EAAE,CAAC;IACT,IAAA,yBAAW,EAAC,2BAA2B,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;IACvD,IAAA,mBAAK,EAAC,oCAAoC,CAAC,CAAC,EAAE,CAC5C,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,SAAS,CAChB;CACF,CACF,CAAC"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -16,3 +16,13 @@ export declare class RetryableError extends Error {
|
|
|
16
16
|
export declare class PermanentError extends Error {
|
|
17
17
|
constructor(message: string);
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* A cron expression (or its timezone) that croner cannot parse. Thrown by
|
|
21
|
+
* `JobSchedulesService.upsert`/`setEnabled` at call time — invalid schedules
|
|
22
|
+
* never reach the table. If a row is corrupted behind the service's back
|
|
23
|
+
* (hand-edited SQL), the claimer catches this during its tick and disables
|
|
24
|
+
* the row instead of crashing the loop.
|
|
25
|
+
*/
|
|
26
|
+
export declare class InvalidScheduleError extends Error {
|
|
27
|
+
constructor(message: string);
|
|
28
|
+
}
|
package/dist/errors.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// dependency-free (no Nest, no Drizzle) so handlers, stores, and tests can all
|
|
4
4
|
// throw these without importing anything heavier than this module.
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.PermanentError = exports.RetryableError = void 0;
|
|
6
|
+
exports.InvalidScheduleError = exports.PermanentError = exports.RetryableError = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* Signals a transient failure: the job could not complete now but a later
|
|
9
9
|
* attempt may succeed. `delayMs`, when set, overrides the claimer's jittered
|
|
@@ -30,4 +30,18 @@ class PermanentError extends Error {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
exports.PermanentError = PermanentError;
|
|
33
|
+
/**
|
|
34
|
+
* A cron expression (or its timezone) that croner cannot parse. Thrown by
|
|
35
|
+
* `JobSchedulesService.upsert`/`setEnabled` at call time — invalid schedules
|
|
36
|
+
* never reach the table. If a row is corrupted behind the service's back
|
|
37
|
+
* (hand-edited SQL), the claimer catches this during its tick and disables
|
|
38
|
+
* the row instead of crashing the loop.
|
|
39
|
+
*/
|
|
40
|
+
class InvalidScheduleError extends Error {
|
|
41
|
+
constructor(message) {
|
|
42
|
+
super(message);
|
|
43
|
+
this.name = 'InvalidScheduleError';
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.InvalidScheduleError = InvalidScheduleError;
|
|
33
47
|
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../errors.ts"],"names":[],"mappings":";AAAA,6EAA6E;AAC7E,+EAA+E;AAC/E,mEAAmE;;;AAEnE;;;;;GAKG;AACH,MAAa,cAAe,SAAQ,KAAK;IACvC,YACE,OAAe,EACN,OAAgB;QAEzB,KAAK,CAAC,OAAO,CAAC,CAAC;QAFN,YAAO,GAAP,OAAO,CAAS;QAGzB,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF;AARD,wCAQC;AAED;;;;GAIG;AACH,MAAa,cAAe,SAAQ,KAAK;IACvC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF;AALD,wCAKC"}
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../errors.ts"],"names":[],"mappings":";AAAA,6EAA6E;AAC7E,+EAA+E;AAC/E,mEAAmE;;;AAEnE;;;;;GAKG;AACH,MAAa,cAAe,SAAQ,KAAK;IACvC,YACE,OAAe,EACN,OAAgB;QAEzB,KAAK,CAAC,OAAO,CAAC,CAAC;QAFN,YAAO,GAAP,OAAO,CAAS;QAGzB,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF;AARD,wCAQC;AAED;;;;GAIG;AACH,MAAa,cAAe,SAAQ,KAAK;IACvC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF;AALD,wCAKC;AAED;;;;;;GAMG;AACH,MAAa,oBAAqB,SAAQ,KAAK;IAC7C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AALD,oDAKC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ export * from './interfaces';
|
|
|
3
3
|
export * from './tokens';
|
|
4
4
|
export * from './enqueue-input';
|
|
5
5
|
export * from './job-handler.decorator';
|
|
6
|
+
export * from './job-schedules.service';
|
|
7
|
+
export * from './schedule-planner';
|
|
6
8
|
export * from './jobs-handler.explorer';
|
|
7
9
|
export * from './jobs.service';
|
|
8
10
|
export * from './jobs-claimer.service';
|
package/dist/index.js
CHANGED
|
@@ -22,6 +22,8 @@ __exportStar(require("./interfaces"), exports);
|
|
|
22
22
|
__exportStar(require("./tokens"), exports);
|
|
23
23
|
__exportStar(require("./enqueue-input"), exports);
|
|
24
24
|
__exportStar(require("./job-handler.decorator"), exports);
|
|
25
|
+
__exportStar(require("./job-schedules.service"), exports);
|
|
26
|
+
__exportStar(require("./schedule-planner"), exports);
|
|
25
27
|
__exportStar(require("./jobs-handler.explorer"), exports);
|
|
26
28
|
__exportStar(require("./jobs.service"), exports);
|
|
27
29
|
__exportStar(require("./jobs-claimer.service"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAyD;AACzD,0EAA0E;AAC1E,+EAA+E;AAC/E,2CAAyB;AACzB,+CAA6B;AAC7B,2CAAyB;AACzB,kDAAgC;AAChC,0DAAwC;AACxC,0DAAwC;AACxC,iDAA+B;AAC/B,yDAAuC;AACvC,gDAA8B;AAC9B,gDAA8B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAyD;AACzD,0EAA0E;AAC1E,+EAA+E;AAC/E,2CAAyB;AACzB,+CAA6B;AAC7B,2CAAyB;AACzB,kDAAgC;AAChC,0DAAwC;AACxC,0DAAwC;AACxC,qDAAmC;AACnC,0DAAwC;AACxC,iDAA+B;AAC/B,yDAAuC;AACvC,gDAA8B;AAC9B,gDAA8B"}
|