@nicnocquee/dataqueue 1.34.0 → 1.35.0-beta.20260224110011

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;
@@ -0,0 +1,16 @@
1
+ -- Up Migration: Add group metadata fields for group-based concurrency limits
2
+ ALTER TABLE job_queue
3
+ ADD COLUMN IF NOT EXISTS group_id VARCHAR(255),
4
+ ADD COLUMN IF NOT EXISTS group_tier VARCHAR(255);
5
+
6
+ -- Index for efficient active-group concurrency checks
7
+ CREATE INDEX IF NOT EXISTS idx_job_queue_processing_group_id
8
+ ON job_queue (group_id)
9
+ WHERE status = 'processing' AND group_id IS NOT NULL;
10
+
11
+ -- Down Migration
12
+ DROP INDEX IF EXISTS idx_job_queue_processing_group_id;
13
+
14
+ ALTER TABLE job_queue
15
+ DROP COLUMN IF EXISTS group_tier,
16
+ DROP COLUMN IF EXISTS group_id;
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.20260224110011",
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,
@@ -116,10 +146,11 @@ export interface QueueBackend {
116
146
  workerId: string,
117
147
  batchSize?: number,
118
148
  jobType?: string | string[],
149
+ groupConcurrency?: number,
119
150
  ): Promise<JobRecord<PayloadMap, T>[]>;
120
151
 
121
- /** Mark a job as completed. */
122
- completeJob(jobId: number): Promise<void>;
152
+ /** Mark a job as completed, optionally storing output data. */
153
+ completeJob(jobId: number, output?: unknown): Promise<void>;
123
154
 
124
155
  /** Mark a job as failed with error info and schedule retry. */
125
156
  failJob(
@@ -165,6 +196,9 @@ export interface QueueBackend {
165
196
  /** Update the progress percentage (0-100) for a job. */
166
197
  updateProgress(jobId: number, progress: number): Promise<void>;
167
198
 
199
+ /** Update the output data for a job. Best-effort: should not throw. */
200
+ updateOutput(jobId: number, output: unknown): Promise<void>;
201
+
168
202
  // ── Events ────────────────────────────────────────────────────────────
169
203
 
170
204
  /** Record a job event. Should not throw. */