@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.
- package/ai/docs-content.json +27 -15
- package/ai/rules/advanced.md +78 -1
- package/ai/rules/basic.md +73 -3
- package/ai/rules/react-dashboard.md +5 -1
- package/ai/skills/dataqueue-advanced/SKILL.md +181 -0
- package/ai/skills/dataqueue-core/SKILL.md +109 -3
- package/ai/skills/dataqueue-react/SKILL.md +19 -7
- package/dist/index.cjs +1168 -173
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +394 -13
- package/dist/index.d.ts +394 -13
- package/dist/index.js +1168 -173
- package/dist/index.js.map +1 -1
- package/migrations/1781200000005_add_retry_config_to_job_queue.sql +17 -0
- package/migrations/1781200000006_add_output_to_job_queue.sql +3 -0
- package/migrations/1781200000007_add_group_fields_to_job_queue.sql +16 -0
- package/package.json +1 -1
- package/src/backend.ts +37 -3
- package/src/backends/postgres.ts +458 -76
- package/src/backends/redis-scripts.ts +273 -37
- package/src/backends/redis.test.ts +753 -0
- package/src/backends/redis.ts +253 -15
- package/src/db-util.ts +1 -1
- package/src/index.test.ts +811 -12
- package/src/index.ts +106 -14
- package/src/processor.test.ts +18 -0
- package/src/processor.ts +147 -49
- package/src/queue.test.ts +584 -0
- package/src/queue.ts +22 -3
- package/src/supervisor.test.ts +340 -0
- package/src/supervisor.ts +177 -0
- package/src/types.ts +353 -3
|
@@ -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,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.
|
|
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
|
-
/**
|
|
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. */
|