@nicnocquee/dataqueue 1.24.0 → 1.26.0-beta.20260223195940
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 +44 -0
- package/ai/build-docs-content.ts +96 -0
- package/ai/build-llms-full.ts +42 -0
- package/ai/docs-content.json +278 -0
- package/ai/rules/advanced.md +132 -0
- package/ai/rules/basic.md +159 -0
- package/ai/rules/react-dashboard.md +83 -0
- package/ai/skills/dataqueue-advanced/SKILL.md +320 -0
- package/ai/skills/dataqueue-core/SKILL.md +234 -0
- package/ai/skills/dataqueue-react/SKILL.md +189 -0
- package/dist/cli.cjs +1149 -14
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.d.cts +66 -1
- package/dist/cli.d.ts +66 -1
- package/dist/cli.js +1146 -13
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +4630 -928
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1033 -15
- package/dist/index.d.ts +1033 -15
- package/dist/index.js +4626 -929
- package/dist/index.js.map +1 -1
- package/dist/mcp-server.cjs +186 -0
- package/dist/mcp-server.cjs.map +1 -0
- package/dist/mcp-server.d.cts +32 -0
- package/dist/mcp-server.d.ts +32 -0
- package/dist/mcp-server.js +175 -0
- package/dist/mcp-server.js.map +1 -0
- package/migrations/1751131910825_add_timeout_seconds_to_job_queue.sql +2 -2
- package/migrations/1751186053000_add_job_events_table.sql +12 -8
- package/migrations/1751984773000_add_tags_to_job_queue.sql +1 -1
- package/migrations/1765809419000_add_force_kill_on_timeout_to_job_queue.sql +1 -1
- package/migrations/1771100000000_add_idempotency_key_to_job_queue.sql +7 -0
- package/migrations/1781200000000_add_wait_support.sql +12 -0
- package/migrations/1781200000001_create_waitpoints_table.sql +18 -0
- package/migrations/1781200000002_add_performance_indexes.sql +34 -0
- package/migrations/1781200000003_add_progress_to_job_queue.sql +7 -0
- package/migrations/1781200000004_create_cron_schedules_table.sql +33 -0
- package/migrations/1781200000005_add_retry_config_to_job_queue.sql +17 -0
- package/package.json +40 -23
- package/src/backend.ts +328 -0
- package/src/backends/postgres.ts +2040 -0
- package/src/backends/redis-scripts.ts +865 -0
- package/src/backends/redis.test.ts +1906 -0
- package/src/backends/redis.ts +1792 -0
- package/src/cli.test.ts +82 -6
- package/src/cli.ts +73 -10
- package/src/cron.test.ts +126 -0
- package/src/cron.ts +40 -0
- package/src/db-util.ts +4 -2
- package/src/index.test.ts +688 -1
- package/src/index.ts +277 -39
- package/src/init-command.test.ts +449 -0
- package/src/init-command.ts +709 -0
- package/src/install-mcp-command.test.ts +216 -0
- package/src/install-mcp-command.ts +185 -0
- package/src/install-rules-command.test.ts +218 -0
- package/src/install-rules-command.ts +233 -0
- package/src/install-skills-command.test.ts +176 -0
- package/src/install-skills-command.ts +124 -0
- package/src/mcp-server.test.ts +162 -0
- package/src/mcp-server.ts +231 -0
- package/src/processor.test.ts +559 -18
- package/src/processor.ts +456 -49
- package/src/queue.test.ts +682 -6
- package/src/queue.ts +135 -944
- package/src/supervisor.test.ts +340 -0
- package/src/supervisor.ts +162 -0
- package/src/test-util.ts +32 -0
- package/src/types.ts +726 -17
- package/src/wait.test.ts +698 -0
- package/LICENSE +0 -21
package/src/types.ts
CHANGED
|
@@ -1,8 +1,33 @@
|
|
|
1
|
-
import { Pool } from 'pg';
|
|
2
|
-
|
|
3
1
|
// Utility type for job type keys
|
|
4
2
|
export type JobType<PayloadMap> = keyof PayloadMap & string;
|
|
5
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Abstract database client interface for transactional job creation.
|
|
6
|
+
* Compatible with `pg.Pool`, `pg.PoolClient`, `pg.Client`, or any object
|
|
7
|
+
* that exposes a `.query()` method matching the `pg` signature.
|
|
8
|
+
*/
|
|
9
|
+
export interface DatabaseClient {
|
|
10
|
+
query(
|
|
11
|
+
text: string,
|
|
12
|
+
values?: any[],
|
|
13
|
+
): Promise<{ rows: any[]; rowCount: number | null }>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Options for `addJob()` beyond the job itself.
|
|
18
|
+
* Use `db` to insert the job within an existing database transaction.
|
|
19
|
+
*/
|
|
20
|
+
export interface AddJobOptions {
|
|
21
|
+
/**
|
|
22
|
+
* An external database client (e.g., a `pg.PoolClient` inside a transaction).
|
|
23
|
+
* When provided, the INSERT runs on this client instead of the internal pool,
|
|
24
|
+
* so the job is part of the caller's transaction.
|
|
25
|
+
*
|
|
26
|
+
* **PostgreSQL only.** Throws if used with the Redis backend.
|
|
27
|
+
*/
|
|
28
|
+
db?: DatabaseClient;
|
|
29
|
+
}
|
|
30
|
+
|
|
6
31
|
export interface JobOptions<PayloadMap, T extends JobType<PayloadMap>> {
|
|
7
32
|
jobType: T;
|
|
8
33
|
payload: PayloadMap[T];
|
|
@@ -63,6 +88,38 @@ export interface JobOptions<PayloadMap, T extends JobType<PayloadMap>> {
|
|
|
63
88
|
* Tags for this job. Used for grouping, searching, or batch operations.
|
|
64
89
|
*/
|
|
65
90
|
tags?: string[];
|
|
91
|
+
/**
|
|
92
|
+
* Optional idempotency key. When provided, ensures that only one job exists for a given key.
|
|
93
|
+
* If a job with the same idempotency key already exists, `addJob` returns the existing job's ID
|
|
94
|
+
* instead of creating a duplicate.
|
|
95
|
+
*
|
|
96
|
+
* Useful for preventing duplicate jobs caused by retries, double-clicks, webhook replays,
|
|
97
|
+
* or serverless function re-invocations.
|
|
98
|
+
*
|
|
99
|
+
* The key is unique across the entire `job_queue` table regardless of job status.
|
|
100
|
+
* Once a key exists, it cannot be reused until the job is cleaned up (via `cleanupOldJobs`).
|
|
101
|
+
*/
|
|
102
|
+
idempotencyKey?: string;
|
|
103
|
+
/**
|
|
104
|
+
* Base delay between retries in seconds. When `retryBackoff` is true (the default),
|
|
105
|
+
* this is the base for exponential backoff: `retryDelay * 2^attempts`.
|
|
106
|
+
* When `retryBackoff` is false, retries use this fixed delay.
|
|
107
|
+
* @default 60
|
|
108
|
+
*/
|
|
109
|
+
retryDelay?: number;
|
|
110
|
+
/**
|
|
111
|
+
* Whether to use exponential backoff for retries. When true, delay doubles
|
|
112
|
+
* with each attempt and includes jitter to prevent thundering herd.
|
|
113
|
+
* When false, a fixed `retryDelay` is used between every retry.
|
|
114
|
+
* @default true
|
|
115
|
+
*/
|
|
116
|
+
retryBackoff?: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Maximum delay between retries in seconds. Caps the exponential backoff
|
|
119
|
+
* so retries never wait longer than this value. Only meaningful when
|
|
120
|
+
* `retryBackoff` is true. No limit when omitted.
|
|
121
|
+
*/
|
|
122
|
+
retryDelayMax?: number;
|
|
66
123
|
}
|
|
67
124
|
|
|
68
125
|
/**
|
|
@@ -86,6 +143,8 @@ export enum JobEventType {
|
|
|
86
143
|
Cancelled = 'cancelled',
|
|
87
144
|
Retried = 'retried',
|
|
88
145
|
Edited = 'edited',
|
|
146
|
+
Prolonged = 'prolonged',
|
|
147
|
+
Waiting = 'waiting',
|
|
89
148
|
}
|
|
90
149
|
|
|
91
150
|
export interface JobEvent {
|
|
@@ -107,7 +166,8 @@ export type JobStatus =
|
|
|
107
166
|
| 'processing'
|
|
108
167
|
| 'completed'
|
|
109
168
|
| 'failed'
|
|
110
|
-
| 'cancelled'
|
|
169
|
+
| 'cancelled'
|
|
170
|
+
| 'waiting';
|
|
111
171
|
|
|
112
172
|
export interface JobRecord<PayloadMap, T extends JobType<PayloadMap>> {
|
|
113
173
|
id: number;
|
|
@@ -162,11 +222,223 @@ export interface JobRecord<PayloadMap, T extends JobType<PayloadMap>> {
|
|
|
162
222
|
* Tags for this job. Used for grouping, searching, or batch operations.
|
|
163
223
|
*/
|
|
164
224
|
tags?: string[];
|
|
225
|
+
/**
|
|
226
|
+
* The idempotency key for this job, if one was provided when the job was created.
|
|
227
|
+
*/
|
|
228
|
+
idempotencyKey?: string | null;
|
|
229
|
+
/**
|
|
230
|
+
* The time the job is waiting until (for time-based waits).
|
|
231
|
+
*/
|
|
232
|
+
waitUntil?: Date | null;
|
|
233
|
+
/**
|
|
234
|
+
* The waitpoint token ID the job is waiting for (for token-based waits).
|
|
235
|
+
*/
|
|
236
|
+
waitTokenId?: string | null;
|
|
237
|
+
/**
|
|
238
|
+
* Step data for the job. Stores completed step results for replay on re-invocation.
|
|
239
|
+
*/
|
|
240
|
+
stepData?: Record<string, any>;
|
|
241
|
+
/**
|
|
242
|
+
* Progress percentage for the job (0-100), or null if no progress has been reported.
|
|
243
|
+
* Updated by the handler via `ctx.setProgress(percent)`.
|
|
244
|
+
*/
|
|
245
|
+
progress?: number | null;
|
|
246
|
+
/**
|
|
247
|
+
* Base delay between retries in seconds, or null if using legacy default.
|
|
248
|
+
*/
|
|
249
|
+
retryDelay?: number | null;
|
|
250
|
+
/**
|
|
251
|
+
* Whether exponential backoff is enabled for retries, or null if using legacy default.
|
|
252
|
+
*/
|
|
253
|
+
retryBackoff?: boolean | null;
|
|
254
|
+
/**
|
|
255
|
+
* Maximum delay cap for retries in seconds, or null if no cap.
|
|
256
|
+
*/
|
|
257
|
+
retryDelayMax?: number | null;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Callback registered via `onTimeout`. Invoked when the timeout fires, before the AbortSignal is triggered.
|
|
262
|
+
* Return a number (ms) to extend the timeout, or return nothing to let the timeout proceed.
|
|
263
|
+
*/
|
|
264
|
+
export type OnTimeoutCallback = () => number | void | undefined;
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Context object passed to job handlers as the third argument.
|
|
268
|
+
* Provides mechanisms to extend the job's timeout while it's running,
|
|
269
|
+
* as well as step tracking and wait capabilities.
|
|
270
|
+
*/
|
|
271
|
+
export interface JobContext {
|
|
272
|
+
/**
|
|
273
|
+
* Proactively reset the timeout deadline.
|
|
274
|
+
* - If `ms` is provided, sets the deadline to `ms` milliseconds from now.
|
|
275
|
+
* - If omitted, resets the deadline to the original `timeoutMs` from now (heartbeat-style).
|
|
276
|
+
* - No-op if the job has no timeout set or if `forceKillOnTimeout` is true.
|
|
277
|
+
*/
|
|
278
|
+
prolong: (ms?: number) => void;
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Register a callback that is invoked when the timeout fires, **before** the AbortSignal is triggered.
|
|
282
|
+
* - If the callback returns a number > 0, the timeout is reset to that many ms from now.
|
|
283
|
+
* - If the callback returns `undefined`, `null`, `0`, or a negative number, the timeout proceeds normally.
|
|
284
|
+
* - The callback may be invoked multiple times if the job keeps extending.
|
|
285
|
+
* - Only one callback can be registered; subsequent calls replace the previous one.
|
|
286
|
+
* - No-op if the job has no timeout set or if `forceKillOnTimeout` is true.
|
|
287
|
+
*/
|
|
288
|
+
onTimeout: (callback: OnTimeoutCallback) => void;
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Execute a named step with memoization. If the step was already completed
|
|
292
|
+
* in a previous invocation (e.g., before a wait), the cached result is returned
|
|
293
|
+
* without re-executing the function.
|
|
294
|
+
*
|
|
295
|
+
* Step names must be unique within a handler and stable across re-invocations.
|
|
296
|
+
*
|
|
297
|
+
* @param stepName - A unique identifier for this step.
|
|
298
|
+
* @param fn - The function to execute. Its return value is cached.
|
|
299
|
+
* @returns The result of the step (from cache or fresh execution).
|
|
300
|
+
*/
|
|
301
|
+
run: <T>(stepName: string, fn: () => Promise<T>) => Promise<T>;
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Wait for a specified duration before continuing execution.
|
|
305
|
+
* The job will be paused and resumed after the duration elapses.
|
|
306
|
+
*
|
|
307
|
+
* When this is called, the handler throws a WaitSignal internally.
|
|
308
|
+
* The job is set to 'waiting' status and will be re-invoked after the
|
|
309
|
+
* specified duration. All steps completed via `ctx.run()` before this
|
|
310
|
+
* call will be replayed from cache on re-invocation.
|
|
311
|
+
*
|
|
312
|
+
* @param duration - The duration to wait (e.g., `{ hours: 1 }`, `{ days: 7 }`).
|
|
313
|
+
*/
|
|
314
|
+
waitFor: (duration: WaitDuration) => Promise<void>;
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Wait until a specific date/time before continuing execution.
|
|
318
|
+
* The job will be paused and resumed at (or after) the specified date.
|
|
319
|
+
*
|
|
320
|
+
* @param date - The date to wait until.
|
|
321
|
+
*/
|
|
322
|
+
waitUntil: (date: Date) => Promise<void>;
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Create a waitpoint token. The token can be completed externally
|
|
326
|
+
* (by calling `jobQueue.completeToken()`) to resume a waiting job.
|
|
327
|
+
*
|
|
328
|
+
* Tokens can be created inside handlers or outside (via `jobQueue.createToken()`).
|
|
329
|
+
*
|
|
330
|
+
* @param options - Optional token configuration (timeout, tags).
|
|
331
|
+
* @returns A token object with `id` that can be passed to `waitForToken()`.
|
|
332
|
+
*/
|
|
333
|
+
createToken: (options?: CreateTokenOptions) => Promise<WaitToken>;
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Wait for a waitpoint token to be completed by an external signal.
|
|
337
|
+
* The job will be paused until `jobQueue.completeToken(tokenId, data)` is called
|
|
338
|
+
* or the token times out.
|
|
339
|
+
*
|
|
340
|
+
* @param tokenId - The ID of the token to wait for.
|
|
341
|
+
* @returns A result object indicating success or timeout.
|
|
342
|
+
*/
|
|
343
|
+
waitForToken: <T = any>(tokenId: string) => Promise<WaitTokenResult<T>>;
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Report progress for this job (0-100).
|
|
347
|
+
* The value is persisted to the database and can be read by clients
|
|
348
|
+
* via `getJob()` or the React SDK's `useJob()` hook.
|
|
349
|
+
*
|
|
350
|
+
* @param percent - Progress percentage (0-100). Values are rounded to the nearest integer.
|
|
351
|
+
* @throws If percent is outside the 0-100 range.
|
|
352
|
+
*/
|
|
353
|
+
setProgress: (percent: number) => Promise<void>;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Duration specification for `ctx.waitFor()`.
|
|
358
|
+
* At least one field must be provided. Fields are additive.
|
|
359
|
+
*/
|
|
360
|
+
export interface WaitDuration {
|
|
361
|
+
seconds?: number;
|
|
362
|
+
minutes?: number;
|
|
363
|
+
hours?: number;
|
|
364
|
+
days?: number;
|
|
365
|
+
weeks?: number;
|
|
366
|
+
months?: number;
|
|
367
|
+
years?: number;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Options for creating a waitpoint token.
|
|
372
|
+
*/
|
|
373
|
+
export interface CreateTokenOptions {
|
|
374
|
+
/**
|
|
375
|
+
* Maximum time to wait for the token to be completed.
|
|
376
|
+
* Accepts a duration string like '10m', '1h', '24h', '7d'.
|
|
377
|
+
* If not provided, the token has no timeout.
|
|
378
|
+
*/
|
|
379
|
+
timeout?: string;
|
|
380
|
+
/**
|
|
381
|
+
* Tags to attach to the token for filtering.
|
|
382
|
+
*/
|
|
383
|
+
tags?: string[];
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* A waitpoint token returned by `ctx.createToken()`.
|
|
388
|
+
*/
|
|
389
|
+
export interface WaitToken {
|
|
390
|
+
/** The unique token ID. */
|
|
391
|
+
id: string;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Result of `ctx.waitForToken()`.
|
|
396
|
+
*/
|
|
397
|
+
export type WaitTokenResult<T = any> =
|
|
398
|
+
| { ok: true; output: T }
|
|
399
|
+
| { ok: false; error: string };
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Internal signal thrown by wait methods to pause handler execution.
|
|
403
|
+
* This is not a real error -- the processor catches it and transitions the job to 'waiting' status.
|
|
404
|
+
*/
|
|
405
|
+
export class WaitSignal extends Error {
|
|
406
|
+
readonly isWaitSignal = true;
|
|
407
|
+
|
|
408
|
+
constructor(
|
|
409
|
+
public readonly type: 'duration' | 'date' | 'token',
|
|
410
|
+
public readonly waitUntil: Date | undefined,
|
|
411
|
+
public readonly tokenId: string | undefined,
|
|
412
|
+
public readonly stepData: Record<string, any>,
|
|
413
|
+
) {
|
|
414
|
+
super('WaitSignal');
|
|
415
|
+
this.name = 'WaitSignal';
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Status of a waitpoint token.
|
|
421
|
+
*/
|
|
422
|
+
export type WaitpointStatus = 'waiting' | 'completed' | 'timed_out';
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* A waitpoint record from the database.
|
|
426
|
+
*/
|
|
427
|
+
export interface WaitpointRecord {
|
|
428
|
+
id: string;
|
|
429
|
+
jobId: number | null;
|
|
430
|
+
status: WaitpointStatus;
|
|
431
|
+
output: any;
|
|
432
|
+
timeoutAt: Date | null;
|
|
433
|
+
createdAt: Date;
|
|
434
|
+
completedAt: Date | null;
|
|
435
|
+
tags: string[] | null;
|
|
165
436
|
}
|
|
166
437
|
|
|
167
438
|
export type JobHandler<PayloadMap, T extends keyof PayloadMap> = (
|
|
168
439
|
payload: PayloadMap[T],
|
|
169
440
|
signal: AbortSignal,
|
|
441
|
+
ctx: JobContext,
|
|
170
442
|
) => Promise<void>;
|
|
171
443
|
|
|
172
444
|
export type JobHandlers<PayloadMap> = {
|
|
@@ -214,8 +486,18 @@ export interface Processor {
|
|
|
214
486
|
startInBackground: () => void;
|
|
215
487
|
/**
|
|
216
488
|
* Stop the job processor that runs in the background.
|
|
489
|
+
* Does not wait for in-flight jobs to complete.
|
|
217
490
|
*/
|
|
218
491
|
stop: () => void;
|
|
492
|
+
/**
|
|
493
|
+
* Stop the job processor and wait for all in-flight jobs to complete.
|
|
494
|
+
* Useful for graceful shutdown (e.g., SIGTERM handling).
|
|
495
|
+
* No new batches will be started after calling this method.
|
|
496
|
+
*
|
|
497
|
+
* @param timeoutMs - Maximum time to wait for in-flight jobs (default: 30000ms).
|
|
498
|
+
* If jobs don't complete within this time, the promise resolves anyway.
|
|
499
|
+
*/
|
|
500
|
+
stopAndDrain: (timeoutMs?: number) => Promise<void>;
|
|
219
501
|
/**
|
|
220
502
|
* Check if the job processor is running.
|
|
221
503
|
*/
|
|
@@ -229,6 +511,91 @@ export interface Processor {
|
|
|
229
511
|
start: () => Promise<number>;
|
|
230
512
|
}
|
|
231
513
|
|
|
514
|
+
export interface SupervisorOptions {
|
|
515
|
+
/**
|
|
516
|
+
* How often the maintenance loop runs, in milliseconds.
|
|
517
|
+
* @default 60000 (1 minute)
|
|
518
|
+
*/
|
|
519
|
+
intervalMs?: number;
|
|
520
|
+
/**
|
|
521
|
+
* Reclaim jobs stuck in `processing` longer than this many minutes.
|
|
522
|
+
* @default 10
|
|
523
|
+
*/
|
|
524
|
+
stuckJobsTimeoutMinutes?: number;
|
|
525
|
+
/**
|
|
526
|
+
* Auto-delete completed jobs older than this many days. Set to 0 to disable.
|
|
527
|
+
* @default 30
|
|
528
|
+
*/
|
|
529
|
+
cleanupJobsDaysToKeep?: number;
|
|
530
|
+
/**
|
|
531
|
+
* Auto-delete job events older than this many days. Set to 0 to disable.
|
|
532
|
+
* @default 30
|
|
533
|
+
*/
|
|
534
|
+
cleanupEventsDaysToKeep?: number;
|
|
535
|
+
/**
|
|
536
|
+
* Batch size for cleanup deletions.
|
|
537
|
+
* @default 1000
|
|
538
|
+
*/
|
|
539
|
+
cleanupBatchSize?: number;
|
|
540
|
+
/**
|
|
541
|
+
* Whether to reclaim stuck jobs each cycle.
|
|
542
|
+
* @default true
|
|
543
|
+
*/
|
|
544
|
+
reclaimStuckJobs?: boolean;
|
|
545
|
+
/**
|
|
546
|
+
* Whether to expire timed-out waitpoint tokens each cycle.
|
|
547
|
+
* @default true
|
|
548
|
+
*/
|
|
549
|
+
expireTimedOutTokens?: boolean;
|
|
550
|
+
/**
|
|
551
|
+
* Called when a maintenance task throws. One failure does not block other tasks.
|
|
552
|
+
* @default console.error
|
|
553
|
+
*/
|
|
554
|
+
onError?: (error: Error) => void;
|
|
555
|
+
/** Enable verbose logging. */
|
|
556
|
+
verbose?: boolean;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
export interface SupervisorRunResult {
|
|
560
|
+
/** Number of stuck jobs reclaimed back to pending. */
|
|
561
|
+
reclaimedJobs: number;
|
|
562
|
+
/** Number of old completed jobs deleted. */
|
|
563
|
+
cleanedUpJobs: number;
|
|
564
|
+
/** Number of old job events deleted. */
|
|
565
|
+
cleanedUpEvents: number;
|
|
566
|
+
/** Number of timed-out waitpoint tokens expired. */
|
|
567
|
+
expiredTokens: number;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
export interface Supervisor {
|
|
571
|
+
/**
|
|
572
|
+
* Run all maintenance tasks once and return the results.
|
|
573
|
+
* Ideal for serverless or cron-triggered invocations.
|
|
574
|
+
*/
|
|
575
|
+
start: () => Promise<SupervisorRunResult>;
|
|
576
|
+
/**
|
|
577
|
+
* Start the maintenance loop in the background.
|
|
578
|
+
* Runs every `intervalMs` milliseconds (default: 60 000).
|
|
579
|
+
* Call `stop()` or `stopAndDrain()` to halt the loop.
|
|
580
|
+
*/
|
|
581
|
+
startInBackground: () => void;
|
|
582
|
+
/**
|
|
583
|
+
* Stop the background maintenance loop immediately.
|
|
584
|
+
* Does not wait for an in-flight maintenance run to complete.
|
|
585
|
+
*/
|
|
586
|
+
stop: () => void;
|
|
587
|
+
/**
|
|
588
|
+
* Stop the background loop and wait for the current maintenance run
|
|
589
|
+
* (if any) to finish before resolving.
|
|
590
|
+
*
|
|
591
|
+
* @param timeoutMs - Maximum time to wait (default: 30 000 ms).
|
|
592
|
+
* If the run does not finish within this time the promise resolves anyway.
|
|
593
|
+
*/
|
|
594
|
+
stopAndDrain: (timeoutMs?: number) => Promise<void>;
|
|
595
|
+
/** Whether the background maintenance loop is currently running. */
|
|
596
|
+
isRunning: () => boolean;
|
|
597
|
+
}
|
|
598
|
+
|
|
232
599
|
export interface DatabaseSSLConfig {
|
|
233
600
|
/**
|
|
234
601
|
* CA certificate as PEM string or file path. If the value starts with 'file://', it will be loaded from file, otherwise treated as PEM string.
|
|
@@ -248,8 +615,16 @@ export interface DatabaseSSLConfig {
|
|
|
248
615
|
rejectUnauthorized?: boolean;
|
|
249
616
|
}
|
|
250
617
|
|
|
251
|
-
|
|
252
|
-
|
|
618
|
+
/**
|
|
619
|
+
* Configuration for PostgreSQL backend (default).
|
|
620
|
+
* Backward-compatible: omitting `backend` defaults to 'postgres'.
|
|
621
|
+
*
|
|
622
|
+
* Provide either `databaseConfig` (the library creates a pool) or `pool`
|
|
623
|
+
* (bring your own `pg.Pool`). At least one must be set.
|
|
624
|
+
*/
|
|
625
|
+
export interface PostgresJobQueueConfig {
|
|
626
|
+
backend?: 'postgres';
|
|
627
|
+
databaseConfig?: {
|
|
253
628
|
connectionString?: string;
|
|
254
629
|
host?: string;
|
|
255
630
|
port?: number;
|
|
@@ -257,19 +632,217 @@ export interface JobQueueConfig {
|
|
|
257
632
|
user?: string;
|
|
258
633
|
password?: string;
|
|
259
634
|
ssl?: DatabaseSSLConfig;
|
|
635
|
+
/**
|
|
636
|
+
* Maximum number of clients in the pool (default: 10).
|
|
637
|
+
* Increase when running multiple processors in the same process.
|
|
638
|
+
*/
|
|
639
|
+
max?: number;
|
|
640
|
+
/**
|
|
641
|
+
* Minimum number of idle clients in the pool (default: 0).
|
|
642
|
+
*/
|
|
643
|
+
min?: number;
|
|
644
|
+
/**
|
|
645
|
+
* Milliseconds a client must sit idle before being closed (default: 10000).
|
|
646
|
+
*/
|
|
647
|
+
idleTimeoutMillis?: number;
|
|
648
|
+
/**
|
|
649
|
+
* Milliseconds to wait for a connection before throwing (default: 0, no timeout).
|
|
650
|
+
*/
|
|
651
|
+
connectionTimeoutMillis?: number;
|
|
652
|
+
};
|
|
653
|
+
/**
|
|
654
|
+
* Bring your own `pg.Pool` instance. When provided, `databaseConfig` is
|
|
655
|
+
* ignored and the library will not close the pool on shutdown.
|
|
656
|
+
*/
|
|
657
|
+
pool?: import('pg').Pool;
|
|
658
|
+
verbose?: boolean;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* TLS configuration for the Redis connection.
|
|
663
|
+
*/
|
|
664
|
+
export interface RedisTLSConfig {
|
|
665
|
+
ca?: string;
|
|
666
|
+
cert?: string;
|
|
667
|
+
key?: string;
|
|
668
|
+
rejectUnauthorized?: boolean;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* Configuration for Redis backend.
|
|
673
|
+
*
|
|
674
|
+
* Provide either `redisConfig` (the library creates an ioredis client) or
|
|
675
|
+
* `client` (bring your own ioredis instance). At least one must be set.
|
|
676
|
+
*/
|
|
677
|
+
export interface RedisJobQueueConfig {
|
|
678
|
+
backend: 'redis';
|
|
679
|
+
redisConfig?: {
|
|
680
|
+
/** Redis URL (e.g. redis://localhost:6379) */
|
|
681
|
+
url?: string;
|
|
682
|
+
host?: string;
|
|
683
|
+
port?: number;
|
|
684
|
+
password?: string;
|
|
685
|
+
/** Redis database number (default: 0) */
|
|
686
|
+
db?: number;
|
|
687
|
+
tls?: RedisTLSConfig;
|
|
688
|
+
/**
|
|
689
|
+
* Key prefix for all Redis keys (default: 'dq:').
|
|
690
|
+
* Useful to namespace multiple queues in the same Redis instance.
|
|
691
|
+
*/
|
|
692
|
+
keyPrefix?: string;
|
|
260
693
|
};
|
|
694
|
+
/**
|
|
695
|
+
* Bring your own ioredis client instance. When provided, `redisConfig` is
|
|
696
|
+
* ignored and the library will not close the client on shutdown.
|
|
697
|
+
* Use `keyPrefix` to set the key namespace (default: 'dq:').
|
|
698
|
+
*/
|
|
699
|
+
client?: unknown;
|
|
700
|
+
/**
|
|
701
|
+
* Key prefix when using an external `client`. Ignored when `redisConfig` is used
|
|
702
|
+
* (set `redisConfig.keyPrefix` instead). Default: 'dq:'.
|
|
703
|
+
*/
|
|
704
|
+
keyPrefix?: string;
|
|
261
705
|
verbose?: boolean;
|
|
262
706
|
}
|
|
263
707
|
|
|
708
|
+
/**
|
|
709
|
+
* Job queue configuration — discriminated union.
|
|
710
|
+
* If `backend` is omitted, PostgreSQL is used.
|
|
711
|
+
*/
|
|
712
|
+
export type JobQueueConfig = PostgresJobQueueConfig | RedisJobQueueConfig;
|
|
713
|
+
|
|
714
|
+
/** @deprecated Use JobQueueConfig instead. Alias kept for backward compat. */
|
|
715
|
+
export type JobQueueConfigLegacy = PostgresJobQueueConfig;
|
|
716
|
+
|
|
264
717
|
export type TagQueryMode = 'exact' | 'all' | 'any' | 'none';
|
|
265
718
|
|
|
719
|
+
// ── Cron schedule types ──────────────────────────────────────────────
|
|
720
|
+
|
|
721
|
+
/**
|
|
722
|
+
* Status of a cron schedule.
|
|
723
|
+
*/
|
|
724
|
+
export type CronScheduleStatus = 'active' | 'paused';
|
|
725
|
+
|
|
726
|
+
/**
|
|
727
|
+
* Options for creating a recurring cron schedule.
|
|
728
|
+
* Each schedule defines a recurring job that is automatically enqueued
|
|
729
|
+
* when its cron expression matches.
|
|
730
|
+
*/
|
|
731
|
+
export interface CronScheduleOptions<
|
|
732
|
+
PayloadMap,
|
|
733
|
+
T extends JobType<PayloadMap>,
|
|
734
|
+
> {
|
|
735
|
+
/** Unique human-readable name for the schedule. */
|
|
736
|
+
scheduleName: string;
|
|
737
|
+
/** Standard cron expression (5 fields, e.g. "0 * * * *"). */
|
|
738
|
+
cronExpression: string;
|
|
739
|
+
/** Job type from the PayloadMap. */
|
|
740
|
+
jobType: T;
|
|
741
|
+
/** Payload for each job instance. */
|
|
742
|
+
payload: PayloadMap[T];
|
|
743
|
+
/** Maximum retry attempts for each job instance (default: 3). */
|
|
744
|
+
maxAttempts?: number;
|
|
745
|
+
/** Priority for each job instance (default: 0). */
|
|
746
|
+
priority?: number;
|
|
747
|
+
/** Timeout in milliseconds for each job instance. */
|
|
748
|
+
timeoutMs?: number;
|
|
749
|
+
/** Whether to force-kill the job on timeout (default: false). */
|
|
750
|
+
forceKillOnTimeout?: boolean;
|
|
751
|
+
/** Tags for each job instance. */
|
|
752
|
+
tags?: string[];
|
|
753
|
+
/** IANA timezone string for cron evaluation (default: "UTC"). */
|
|
754
|
+
timezone?: string;
|
|
755
|
+
/**
|
|
756
|
+
* Whether to allow overlapping job instances (default: false).
|
|
757
|
+
* When false, a new job will not be enqueued if the previous instance
|
|
758
|
+
* is still pending, processing, or waiting.
|
|
759
|
+
*/
|
|
760
|
+
allowOverlap?: boolean;
|
|
761
|
+
/** Base delay between retries in seconds for each job instance (default: 60). */
|
|
762
|
+
retryDelay?: number;
|
|
763
|
+
/** Whether to use exponential backoff for retries (default: true). */
|
|
764
|
+
retryBackoff?: boolean;
|
|
765
|
+
/** Maximum delay cap for retries in seconds. */
|
|
766
|
+
retryDelayMax?: number;
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
* A persisted cron schedule record.
|
|
771
|
+
*/
|
|
772
|
+
export interface CronScheduleRecord {
|
|
773
|
+
id: number;
|
|
774
|
+
scheduleName: string;
|
|
775
|
+
cronExpression: string;
|
|
776
|
+
jobType: string;
|
|
777
|
+
payload: any;
|
|
778
|
+
maxAttempts: number;
|
|
779
|
+
priority: number;
|
|
780
|
+
timeoutMs: number | null;
|
|
781
|
+
forceKillOnTimeout: boolean;
|
|
782
|
+
tags: string[] | undefined;
|
|
783
|
+
timezone: string;
|
|
784
|
+
allowOverlap: boolean;
|
|
785
|
+
status: CronScheduleStatus;
|
|
786
|
+
lastEnqueuedAt: Date | null;
|
|
787
|
+
lastJobId: number | null;
|
|
788
|
+
nextRunAt: Date | null;
|
|
789
|
+
createdAt: Date;
|
|
790
|
+
updatedAt: Date;
|
|
791
|
+
retryDelay: number | null;
|
|
792
|
+
retryBackoff: boolean | null;
|
|
793
|
+
retryDelayMax: number | null;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
/**
|
|
797
|
+
* Options for editing an existing cron schedule.
|
|
798
|
+
* All fields are optional; only provided fields are updated.
|
|
799
|
+
*/
|
|
800
|
+
export interface EditCronScheduleOptions {
|
|
801
|
+
cronExpression?: string;
|
|
802
|
+
payload?: any;
|
|
803
|
+
maxAttempts?: number;
|
|
804
|
+
priority?: number;
|
|
805
|
+
timeoutMs?: number | null;
|
|
806
|
+
forceKillOnTimeout?: boolean;
|
|
807
|
+
tags?: string[] | null;
|
|
808
|
+
timezone?: string;
|
|
809
|
+
allowOverlap?: boolean;
|
|
810
|
+
retryDelay?: number | null;
|
|
811
|
+
retryBackoff?: boolean | null;
|
|
812
|
+
retryDelayMax?: number | null;
|
|
813
|
+
}
|
|
814
|
+
|
|
266
815
|
export interface JobQueue<PayloadMap> {
|
|
267
816
|
/**
|
|
268
817
|
* Add a job to the job queue.
|
|
818
|
+
*
|
|
819
|
+
* @param job - The job to enqueue.
|
|
820
|
+
* @param options - Optional. Pass `{ db }` with an external database client
|
|
821
|
+
* to insert the job within an existing transaction (PostgreSQL only).
|
|
269
822
|
*/
|
|
270
823
|
addJob: <T extends JobType<PayloadMap>>(
|
|
271
824
|
job: JobOptions<PayloadMap, T>,
|
|
825
|
+
options?: AddJobOptions,
|
|
272
826
|
) => Promise<number>;
|
|
827
|
+
/**
|
|
828
|
+
* Add multiple jobs to the queue in a single operation.
|
|
829
|
+
*
|
|
830
|
+
* More efficient than calling `addJob` in a loop because it batches the
|
|
831
|
+
* INSERT into a single database round-trip (PostgreSQL) or a single
|
|
832
|
+
* atomic Lua script (Redis).
|
|
833
|
+
*
|
|
834
|
+
* Returns an array of job IDs in the same order as the input array.
|
|
835
|
+
* Each job may independently have an `idempotencyKey`; duplicates
|
|
836
|
+
* resolve to the existing job's ID without creating a new row.
|
|
837
|
+
*
|
|
838
|
+
* @param jobs - Array of jobs to enqueue.
|
|
839
|
+
* @param options - Optional. Pass `{ db }` with an external database client
|
|
840
|
+
* to insert the jobs within an existing transaction (PostgreSQL only).
|
|
841
|
+
*/
|
|
842
|
+
addJobs: <T extends JobType<PayloadMap>>(
|
|
843
|
+
jobs: JobOptions<PayloadMap, T>[],
|
|
844
|
+
options?: AddJobOptions,
|
|
845
|
+
) => Promise<number[]>;
|
|
273
846
|
/**
|
|
274
847
|
* Get a job by its ID.
|
|
275
848
|
*/
|
|
@@ -310,16 +883,25 @@ export interface JobQueue<PayloadMap> {
|
|
|
310
883
|
offset?: number,
|
|
311
884
|
) => Promise<JobRecord<PayloadMap, T>[]>;
|
|
312
885
|
/**
|
|
313
|
-
* Get jobs by filters.
|
|
314
|
-
|
|
315
|
-
*
|
|
886
|
+
* Get jobs by filters, with pagination support.
|
|
887
|
+
* - Use `cursor` for efficient keyset pagination (recommended for large datasets).
|
|
888
|
+
* - Use `limit` and `offset` for traditional pagination.
|
|
889
|
+
* - Do not combine `cursor` with `offset`.
|
|
316
890
|
*/
|
|
317
|
-
getJobs: <T extends JobType<PayloadMap>>(
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
891
|
+
getJobs: <T extends JobType<PayloadMap>>(
|
|
892
|
+
filters?: {
|
|
893
|
+
jobType?: string;
|
|
894
|
+
priority?: number;
|
|
895
|
+
runAt?:
|
|
896
|
+
| Date
|
|
897
|
+
| { gt?: Date; gte?: Date; lt?: Date; lte?: Date; eq?: Date };
|
|
898
|
+
tags?: { values: string[]; mode?: TagQueryMode };
|
|
899
|
+
/** Cursor for keyset pagination. Only return jobs with id < cursor. */
|
|
900
|
+
cursor?: number;
|
|
901
|
+
},
|
|
902
|
+
limit?: number,
|
|
903
|
+
offset?: number,
|
|
904
|
+
) => Promise<JobRecord<PayloadMap, T>[]>;
|
|
323
905
|
/**
|
|
324
906
|
* Retry a job given its ID.
|
|
325
907
|
* - This will set the job status back to 'pending', clear the locked_at and locked_by, and allow it to be picked up by other workers.
|
|
@@ -327,8 +909,21 @@ export interface JobQueue<PayloadMap> {
|
|
|
327
909
|
retryJob: (jobId: number) => Promise<void>;
|
|
328
910
|
/**
|
|
329
911
|
* Cleanup jobs that are older than the specified number of days.
|
|
912
|
+
* Deletes in batches for scale safety.
|
|
913
|
+
* @param daysToKeep - Number of days to retain completed jobs (default 30).
|
|
914
|
+
* @param batchSize - Number of rows to delete per batch (default 1000 for PostgreSQL, 200 for Redis).
|
|
330
915
|
*/
|
|
331
|
-
cleanupOldJobs: (daysToKeep?: number) => Promise<number>;
|
|
916
|
+
cleanupOldJobs: (daysToKeep?: number, batchSize?: number) => Promise<number>;
|
|
917
|
+
/**
|
|
918
|
+
* Cleanup job events that are older than the specified number of days.
|
|
919
|
+
* Deletes in batches for scale safety.
|
|
920
|
+
* @param daysToKeep - Number of days to retain events (default 30).
|
|
921
|
+
* @param batchSize - Number of rows to delete per batch (default 1000).
|
|
922
|
+
*/
|
|
923
|
+
cleanupOldJobEvents: (
|
|
924
|
+
daysToKeep?: number,
|
|
925
|
+
batchSize?: number,
|
|
926
|
+
) => Promise<number>;
|
|
332
927
|
/**
|
|
333
928
|
* Cancel a job given its ID.
|
|
334
929
|
* - This will set the job status to 'cancelled' and clear the locked_at and locked_by.
|
|
@@ -402,12 +997,126 @@ export interface JobQueue<PayloadMap> {
|
|
|
402
997
|
options?: ProcessorOptions,
|
|
403
998
|
) => Processor;
|
|
404
999
|
|
|
1000
|
+
/**
|
|
1001
|
+
* Create a background supervisor that automatically reclaims stuck jobs,
|
|
1002
|
+
* cleans up old completed jobs/events, and expires timed-out waitpoint
|
|
1003
|
+
* tokens on a configurable interval.
|
|
1004
|
+
*/
|
|
1005
|
+
createSupervisor: (options?: SupervisorOptions) => Supervisor;
|
|
1006
|
+
|
|
405
1007
|
/**
|
|
406
1008
|
* Get the job events for a job.
|
|
407
1009
|
*/
|
|
408
1010
|
getJobEvents: (jobId: number) => Promise<JobEvent[]>;
|
|
1011
|
+
|
|
1012
|
+
/**
|
|
1013
|
+
* Create a waitpoint token.
|
|
1014
|
+
* Tokens can be completed externally to resume a waiting job.
|
|
1015
|
+
* Can be called outside of handlers (e.g., from an API route).
|
|
1016
|
+
*
|
|
1017
|
+
* @param options - Optional token configuration (timeout, tags).
|
|
1018
|
+
* @returns A token object with `id`.
|
|
1019
|
+
*/
|
|
1020
|
+
createToken: (options?: CreateTokenOptions) => Promise<WaitToken>;
|
|
1021
|
+
|
|
1022
|
+
/**
|
|
1023
|
+
* Complete a waitpoint token, resuming the associated waiting job.
|
|
1024
|
+
* Can be called from anywhere (API routes, external services, etc.).
|
|
1025
|
+
*
|
|
1026
|
+
* @param tokenId - The ID of the token to complete.
|
|
1027
|
+
* @param data - Optional data to pass to the waiting handler.
|
|
1028
|
+
*/
|
|
1029
|
+
completeToken: (tokenId: string, data?: any) => Promise<void>;
|
|
1030
|
+
|
|
1031
|
+
/**
|
|
1032
|
+
* Retrieve a waitpoint token by its ID.
|
|
1033
|
+
*
|
|
1034
|
+
* @param tokenId - The ID of the token to retrieve.
|
|
1035
|
+
* @returns The token record, or null if not found.
|
|
1036
|
+
*/
|
|
1037
|
+
getToken: (tokenId: string) => Promise<WaitpointRecord | null>;
|
|
1038
|
+
|
|
1039
|
+
/**
|
|
1040
|
+
* Expire timed-out waitpoint tokens and resume their associated jobs.
|
|
1041
|
+
* Call this periodically (e.g., alongside `reclaimStuckJobs`).
|
|
1042
|
+
*
|
|
1043
|
+
* @returns The number of tokens that were expired.
|
|
1044
|
+
*/
|
|
1045
|
+
expireTimedOutTokens: () => Promise<number>;
|
|
1046
|
+
|
|
1047
|
+
// ── Cron schedule operations ────────────────────────────────────────
|
|
1048
|
+
|
|
1049
|
+
/**
|
|
1050
|
+
* Add a recurring cron schedule. The processor automatically enqueues
|
|
1051
|
+
* due cron jobs before each batch, so no manual triggering is needed.
|
|
1052
|
+
*
|
|
1053
|
+
* @returns The ID of the created schedule.
|
|
1054
|
+
* @throws If the cron expression is invalid or the schedule name is already taken.
|
|
1055
|
+
*/
|
|
1056
|
+
addCronJob: <T extends JobType<PayloadMap>>(
|
|
1057
|
+
options: CronScheduleOptions<PayloadMap, T>,
|
|
1058
|
+
) => Promise<number>;
|
|
1059
|
+
|
|
1060
|
+
/**
|
|
1061
|
+
* Get a cron schedule by its ID.
|
|
1062
|
+
*/
|
|
1063
|
+
getCronJob: (id: number) => Promise<CronScheduleRecord | null>;
|
|
1064
|
+
|
|
1065
|
+
/**
|
|
1066
|
+
* Get a cron schedule by its unique name.
|
|
1067
|
+
*/
|
|
1068
|
+
getCronJobByName: (name: string) => Promise<CronScheduleRecord | null>;
|
|
1069
|
+
|
|
1070
|
+
/**
|
|
1071
|
+
* List all cron schedules, optionally filtered by status.
|
|
1072
|
+
*/
|
|
1073
|
+
listCronJobs: (status?: CronScheduleStatus) => Promise<CronScheduleRecord[]>;
|
|
1074
|
+
|
|
1075
|
+
/**
|
|
1076
|
+
* Remove a cron schedule by its ID. Does not cancel any already-enqueued jobs.
|
|
1077
|
+
*/
|
|
1078
|
+
removeCronJob: (id: number) => Promise<void>;
|
|
1079
|
+
|
|
1080
|
+
/**
|
|
1081
|
+
* Pause a cron schedule. Paused schedules are skipped by `enqueueDueCronJobs()`.
|
|
1082
|
+
*/
|
|
1083
|
+
pauseCronJob: (id: number) => Promise<void>;
|
|
1084
|
+
|
|
1085
|
+
/**
|
|
1086
|
+
* Resume a paused cron schedule.
|
|
1087
|
+
*/
|
|
1088
|
+
resumeCronJob: (id: number) => Promise<void>;
|
|
1089
|
+
|
|
1090
|
+
/**
|
|
1091
|
+
* Edit an existing cron schedule. Only provided fields are updated.
|
|
1092
|
+
* If `cronExpression` or `timezone` changes, `nextRunAt` is recalculated.
|
|
1093
|
+
*/
|
|
1094
|
+
editCronJob: (id: number, updates: EditCronScheduleOptions) => Promise<void>;
|
|
1095
|
+
|
|
1096
|
+
/**
|
|
1097
|
+
* Check all active cron schedules and enqueue jobs for any whose
|
|
1098
|
+
* `nextRunAt` has passed. When `allowOverlap` is false (the default),
|
|
1099
|
+
* a new job is not enqueued if the previous instance is still
|
|
1100
|
+
* pending, processing, or waiting.
|
|
1101
|
+
*
|
|
1102
|
+
* **Note:** The processor calls this automatically before each batch,
|
|
1103
|
+
* so you typically do not need to call it yourself. It is exposed for
|
|
1104
|
+
* manual use in tests or one-off scripts.
|
|
1105
|
+
*
|
|
1106
|
+
* @returns The number of jobs that were enqueued.
|
|
1107
|
+
*/
|
|
1108
|
+
enqueueDueCronJobs: () => Promise<number>;
|
|
1109
|
+
|
|
1110
|
+
// ── Advanced access ───────────────────────────────────────────────────
|
|
1111
|
+
|
|
1112
|
+
/**
|
|
1113
|
+
* Get the PostgreSQL database pool.
|
|
1114
|
+
* Throws if the backend is not PostgreSQL.
|
|
1115
|
+
*/
|
|
1116
|
+
getPool: () => import('pg').Pool;
|
|
409
1117
|
/**
|
|
410
|
-
* Get the
|
|
1118
|
+
* Get the Redis client instance (ioredis).
|
|
1119
|
+
* Throws if the backend is not Redis.
|
|
411
1120
|
*/
|
|
412
|
-
|
|
1121
|
+
getRedisClient: () => unknown;
|
|
413
1122
|
}
|