@queuedash/sdk 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/dist/client.d.ts +4 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +30 -0
- package/dist/integrations/bull.d.ts +1 -2
- package/dist/integrations/bull.d.ts.map +1 -1
- package/dist/integrations/bull.js +4 -3
- package/dist/integrations/bullmq.d.ts +2 -3
- package/dist/integrations/bullmq.d.ts.map +1 -1
- package/dist/integrations/bullmq.js +22 -21
- package/package.json +2 -2
package/dist/client.d.ts
CHANGED
|
@@ -17,6 +17,10 @@ export declare class QueueDashClient {
|
|
|
17
17
|
private circuitBreakerResetTimer?;
|
|
18
18
|
private syncingJobIds;
|
|
19
19
|
constructor(options: QueueDashClientOptions);
|
|
20
|
+
/**
|
|
21
|
+
* Delete a job (soft delete in QueueDash)
|
|
22
|
+
*/
|
|
23
|
+
deleteJob(jobId: string, queueName: string): Promise<void>;
|
|
20
24
|
/**
|
|
21
25
|
* Queue a job for syncing
|
|
22
26
|
*/
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,sBAAsB,EAAgB,MAAM,SAAS,CAAC;AAExE,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,OAAO,CAAC,CAAyB;IAEzC,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,UAAU,CAAC,CAAiB;IACpC,OAAO,CAAC,UAAU,CAA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K,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAqCvE;;OAEG;IACI,OAAO,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI;IA8BlC;;OAEG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAyGnC,OAAO,CAAC,kBAAkB;IAoB1B,OAAO,CAAC,MAAM;IASd;;OAEG;IACU,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAUlC,OAAO,CAAC,eAAe;IAavB,OAAO,CAAC,qBAAqB;CAkB9B"}
|
package/dist/client.js
CHANGED
|
@@ -30,6 +30,36 @@ class QueueDashClient {
|
|
|
30
30
|
// Graceful shutdown handlers
|
|
31
31
|
this.setupShutdownHandlers();
|
|
32
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Delete a job (soft delete in QueueDash)
|
|
35
|
+
*/
|
|
36
|
+
async deleteJob(jobId, queueName) {
|
|
37
|
+
try {
|
|
38
|
+
const controller = new AbortController();
|
|
39
|
+
const timeoutId = setTimeout(() => controller.abort(), this.requestTimeout);
|
|
40
|
+
const response = await fetch(`${this.apiUrl}/api/v1/jobs/${encodeURIComponent(jobId)}?queueName=${encodeURIComponent(queueName)}`, {
|
|
41
|
+
method: "DELETE",
|
|
42
|
+
headers: {
|
|
43
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
44
|
+
},
|
|
45
|
+
signal: controller.signal,
|
|
46
|
+
});
|
|
47
|
+
clearTimeout(timeoutId);
|
|
48
|
+
if (!response.ok) {
|
|
49
|
+
const errorText = await response.text();
|
|
50
|
+
throw new Error(`HTTP ${response.status}: ${errorText}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
55
|
+
if (this.onError) {
|
|
56
|
+
this.onError(new Error(`Failed to delete job ${jobId}: ${err.message}`));
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
console.error(`QueueDash: Failed to delete job ${jobId}`, err);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
33
63
|
/**
|
|
34
64
|
* Queue a job for syncing
|
|
35
65
|
*/
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { QueueDashClient } from "../client";
|
|
2
|
-
type BullQueue
|
|
2
|
+
import { type Queue as BullQueue } from "bull";
|
|
3
3
|
/**
|
|
4
4
|
* Attach QueueDash monitoring to a Bull queue
|
|
5
5
|
*/
|
|
6
6
|
export declare function attachToBull(queue: BullQueue, client: QueueDashClient): void;
|
|
7
|
-
export {};
|
|
8
7
|
//# sourceMappingURL=bull.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bull.d.ts","sourceRoot":"","sources":["../../src/integrations/bull.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"bull.d.ts","sourceRoot":"","sources":["../../src/integrations/bull.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,EAAE,KAAK,KAAK,IAAI,SAAS,EAAuB,MAAM,MAAM,CAAC;AAEpE;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,GAAG,IAAI,CA6C5E"}
|
|
@@ -12,6 +12,7 @@ function attachToBull(queue, client) {
|
|
|
12
12
|
name: job.name || "default",
|
|
13
13
|
queueName,
|
|
14
14
|
data: job.data,
|
|
15
|
+
// @ts-expect-error
|
|
15
16
|
opts: job.opts,
|
|
16
17
|
addedAt: new Date(job.timestamp),
|
|
17
18
|
processedAt: job.processedOn ? new Date(job.processedOn) : null,
|
|
@@ -21,14 +22,14 @@ function attachToBull(queue, client) {
|
|
|
21
22
|
priority: job.opts?.priority,
|
|
22
23
|
delay: job.opts?.delay,
|
|
23
24
|
timestamp: job.timestamp,
|
|
24
|
-
progress: job.
|
|
25
|
+
progress: job.progress(),
|
|
25
26
|
};
|
|
26
27
|
};
|
|
27
28
|
// Listen to queue events
|
|
28
|
-
queue.on("completed", (job) => {
|
|
29
|
+
queue.on("global:completed", (job) => {
|
|
29
30
|
client.syncJob(extractJobData(job));
|
|
30
31
|
});
|
|
31
|
-
queue.on("failed", (job) => {
|
|
32
|
+
queue.on("global:failed", (job) => {
|
|
32
33
|
if (job) {
|
|
33
34
|
client.syncJob(extractJobData(job));
|
|
34
35
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { QueueDashClient } from "../client";
|
|
2
|
-
type BullMQQueue
|
|
2
|
+
import { type Queue as BullMQQueue, type QueueEvents } from "bullmq";
|
|
3
3
|
/**
|
|
4
4
|
* Attach QueueDash monitoring to a BullMQ queue
|
|
5
5
|
*/
|
|
6
|
-
export declare function attachToBullMQ(queue: BullMQQueue, client: QueueDashClient): void;
|
|
7
|
-
export {};
|
|
6
|
+
export declare function attachToBullMQ(queue: BullMQQueue, events: QueueEvents, client: QueueDashClient): void;
|
|
8
7
|
//# sourceMappingURL=bullmq.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bullmq.d.ts","sourceRoot":"","sources":["../../src/integrations/bullmq.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"bullmq.d.ts","sourceRoot":"","sources":["../../src/integrations/bullmq.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,EACL,KAAK,KAAK,IAAI,WAAW,EAEzB,KAAK,WAAW,EACjB,MAAM,QAAQ,CAAC;AAEhB;;GAEG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,eAAe,GACtB,IAAI,CA2CN"}
|
|
@@ -4,7 +4,7 @@ exports.attachToBullMQ = attachToBullMQ;
|
|
|
4
4
|
/**
|
|
5
5
|
* Attach QueueDash monitoring to a BullMQ queue
|
|
6
6
|
*/
|
|
7
|
-
function attachToBullMQ(queue, client) {
|
|
7
|
+
function attachToBullMQ(queue, events, client) {
|
|
8
8
|
const queueName = queue.name;
|
|
9
9
|
const extractJobData = (job) => {
|
|
10
10
|
return {
|
|
@@ -12,35 +12,36 @@ function attachToBullMQ(queue, client) {
|
|
|
12
12
|
name: job.name,
|
|
13
13
|
queueName,
|
|
14
14
|
data: job.data,
|
|
15
|
+
// @ts-expect-error
|
|
15
16
|
opts: job.opts,
|
|
16
17
|
addedAt: new Date(job.timestamp),
|
|
17
18
|
processedAt: job.processedOn ? new Date(job.processedOn) : null,
|
|
18
19
|
finishedAt: job.finishedOn ? new Date(job.finishedOn) : null,
|
|
19
20
|
failedReason: job.failedReason,
|
|
20
21
|
stacktrace: job.stacktrace,
|
|
21
|
-
retriedAt: job.retriedAt ? new Date(job.retriedAt) : null,
|
|
22
22
|
priority: job.opts?.priority,
|
|
23
23
|
delay: job.opts?.delay,
|
|
24
24
|
timestamp: job.timestamp,
|
|
25
|
-
progress: job.progress
|
|
25
|
+
progress: typeof job.progress === "number" ? job.progress : null,
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
});
|
|
28
|
+
const syncJobById = (jobId) => {
|
|
29
|
+
queue.getJob(jobId).then((job) => {
|
|
30
|
+
if (job) {
|
|
31
|
+
client.syncJob(extractJobData(job));
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
events.on("waiting", async ({ jobId }) => syncJobById(jobId));
|
|
36
|
+
events.on("progress", async ({ jobId }) => syncJobById(jobId));
|
|
37
|
+
events.on("completed", async ({ jobId }) => syncJobById(jobId));
|
|
38
|
+
events.on("failed", async ({ jobId }) => syncJobById(jobId));
|
|
39
|
+
events.on("waiting-children", async ({ jobId }) => syncJobById(jobId));
|
|
40
|
+
events.on("added", async ({ jobId }) => syncJobById(jobId));
|
|
41
|
+
events.on("active", async ({ jobId }) => syncJobById(jobId));
|
|
42
|
+
events.on("delayed", async ({ jobId }) => syncJobById(jobId));
|
|
43
|
+
events.on("deduplicated", async ({ jobId }) => syncJobById(jobId));
|
|
44
|
+
events.on("removed", async ({ jobId }) => client.deleteJob(jobId, queueName));
|
|
45
|
+
events.on("stalled", async ({ jobId }) => syncJobById(jobId));
|
|
46
|
+
events.on("retries-exhausted", async ({ jobId }) => syncJobById(jobId));
|
|
46
47
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@queuedash/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "QueueDash SDK for real-time queue monitoring",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"author": "QueueDash",
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"bullmq": ">=
|
|
22
|
+
"bullmq": ">=5.0.0",
|
|
23
23
|
"bull": ">=4.0.0",
|
|
24
24
|
"bee-queue": ">=1.0.0"
|
|
25
25
|
},
|