@nicnocquee/dataqueue 1.34.0 → 1.35.0-beta.20260224075710

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.
@@ -0,0 +1,17 @@
1
+ -- Up Migration
2
+ ALTER TABLE job_queue ADD COLUMN IF NOT EXISTS retry_delay INT;
3
+ ALTER TABLE job_queue ADD COLUMN IF NOT EXISTS retry_backoff BOOLEAN;
4
+ ALTER TABLE job_queue ADD COLUMN IF NOT EXISTS retry_delay_max INT;
5
+
6
+ ALTER TABLE cron_schedules ADD COLUMN IF NOT EXISTS retry_delay INT;
7
+ ALTER TABLE cron_schedules ADD COLUMN IF NOT EXISTS retry_backoff BOOLEAN;
8
+ ALTER TABLE cron_schedules ADD COLUMN IF NOT EXISTS retry_delay_max INT;
9
+
10
+ -- Down Migration
11
+ ALTER TABLE job_queue DROP COLUMN IF EXISTS retry_delay;
12
+ ALTER TABLE job_queue DROP COLUMN IF EXISTS retry_backoff;
13
+ ALTER TABLE job_queue DROP COLUMN IF EXISTS retry_delay_max;
14
+
15
+ ALTER TABLE cron_schedules DROP COLUMN IF EXISTS retry_delay;
16
+ ALTER TABLE cron_schedules DROP COLUMN IF EXISTS retry_backoff;
17
+ ALTER TABLE cron_schedules DROP COLUMN IF EXISTS retry_delay_max;
@@ -0,0 +1,3 @@
1
+ -- Add output column to job_queue for storing handler results as JSONB.
2
+ -- Up Migration
3
+ ALTER TABLE job_queue ADD COLUMN IF NOT EXISTS output JSONB DEFAULT NULL;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nicnocquee/dataqueue",
3
- "version": "1.34.0",
3
+ "version": "1.35.0-beta.20260224075710",
4
4
  "description": "PostgreSQL or Redis-backed job queue for Node.js applications with support for serverless environments",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/src/backend.ts CHANGED
@@ -11,6 +11,7 @@ import {
11
11
  EditCronScheduleOptions,
12
12
  WaitpointRecord,
13
13
  CreateTokenOptions,
14
+ AddJobOptions,
14
15
  } from './types.js';
15
16
 
16
17
  /**
@@ -39,6 +40,9 @@ export interface JobUpdates {
39
40
  runAt?: Date | null;
40
41
  timeoutMs?: number | null;
41
42
  tags?: string[] | null;
43
+ retryDelay?: number | null;
44
+ retryBackoff?: boolean | null;
45
+ retryDelayMax?: number | null;
42
46
  }
43
47
 
44
48
  /**
@@ -58,6 +62,9 @@ export interface CronScheduleInput {
58
62
  timezone: string;
59
63
  allowOverlap: boolean;
60
64
  nextRunAt: Date | null;
65
+ retryDelay: number | null;
66
+ retryBackoff: boolean | null;
67
+ retryDelayMax: number | null;
61
68
  }
62
69
 
63
70
  /**
@@ -68,11 +75,34 @@ export interface CronScheduleInput {
68
75
  export interface QueueBackend {
69
76
  // ── Job CRUD ──────────────────────────────────────────────────────────
70
77
 
71
- /** Add a job and return its numeric ID. */
78
+ /**
79
+ * Add a job and return its numeric ID.
80
+ *
81
+ * @param job - Job configuration.
82
+ * @param options - Optional. Pass `{ db }` to run the INSERT on an external
83
+ * client (e.g., inside a transaction). PostgreSQL only.
84
+ */
72
85
  addJob<PayloadMap, T extends JobType<PayloadMap>>(
73
86
  job: JobOptions<PayloadMap, T>,
87
+ options?: AddJobOptions,
74
88
  ): Promise<number>;
75
89
 
90
+ /**
91
+ * Add multiple jobs in a single operation and return their IDs.
92
+ *
93
+ * IDs are returned in the same order as the input array.
94
+ * Each job may independently have an `idempotencyKey`; duplicates
95
+ * resolve to the existing job's ID without creating a new row.
96
+ *
97
+ * @param jobs - Array of job configurations.
98
+ * @param options - Optional. Pass `{ db }` to run the INSERTs on an external
99
+ * client (e.g., inside a transaction). PostgreSQL only.
100
+ */
101
+ addJobs<PayloadMap, T extends JobType<PayloadMap>>(
102
+ jobs: JobOptions<PayloadMap, T>[],
103
+ options?: AddJobOptions,
104
+ ): Promise<number[]>;
105
+
76
106
  /** Get a single job by ID, or null if not found. */
77
107
  getJob<PayloadMap, T extends JobType<PayloadMap>>(
78
108
  id: number,
@@ -118,8 +148,8 @@ export interface QueueBackend {
118
148
  jobType?: string | string[],
119
149
  ): Promise<JobRecord<PayloadMap, T>[]>;
120
150
 
121
- /** Mark a job as completed. */
122
- completeJob(jobId: number): Promise<void>;
151
+ /** Mark a job as completed, optionally storing output data. */
152
+ completeJob(jobId: number, output?: unknown): Promise<void>;
123
153
 
124
154
  /** Mark a job as failed with error info and schedule retry. */
125
155
  failJob(
@@ -165,6 +195,9 @@ export interface QueueBackend {
165
195
  /** Update the progress percentage (0-100) for a job. */
166
196
  updateProgress(jobId: number, progress: number): Promise<void>;
167
197
 
198
+ /** Update the output data for a job. Best-effort: should not throw. */
199
+ updateOutput(jobId: number, output: unknown): Promise<void>;
200
+
168
201
  // ── Events ────────────────────────────────────────────────────────────
169
202
 
170
203
  /** Record a job event. Should not throw. */