@queuedash/sdk 0.2.0 → 2.0.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/LICENSE +21 -0
- package/README.md +54 -52
- package/dist/client.d.ts +45 -7
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +347 -67
- package/dist/client.spec.d.ts +2 -0
- package/dist/client.spec.d.ts.map +1 -0
- package/dist/client.spec.js +809 -0
- package/dist/index.d.ts +2 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -8
- package/dist/types.d.ts +11 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +23 -7
- package/dist/integrations/bee.d.ts +0 -8
- package/dist/integrations/bee.d.ts.map +0 -1
- package/dist/integrations/bee.js +0 -43
- package/dist/integrations/bull.d.ts +0 -7
- package/dist/integrations/bull.d.ts.map +0 -1
- package/dist/integrations/bull.js +0 -46
- package/dist/integrations/bullmq.d.ts +0 -7
- package/dist/integrations/bullmq.d.ts.map +0 -1
- package/dist/integrations/bullmq.js +0 -47
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export { attachToBull } from "./integrations/bull";
|
|
4
|
-
export { attachToBeeQueue } from "./integrations/bee";
|
|
5
|
-
export type { QueueDashClientOptions, JobData, SyncResponse } from "./types";
|
|
1
|
+
export { Queuedash } from "./client";
|
|
2
|
+
export type { QueuedashOptions, JobData, SyncResponse } from "./types";
|
|
6
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,YAAY,EAAE,gBAAgB,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.Queuedash = void 0;
|
|
4
4
|
var client_1 = require("./client");
|
|
5
|
-
Object.defineProperty(exports, "
|
|
6
|
-
var bullmq_1 = require("./integrations/bullmq");
|
|
7
|
-
Object.defineProperty(exports, "attachToBullMQ", { enumerable: true, get: function () { return bullmq_1.attachToBullMQ; } });
|
|
8
|
-
var bull_1 = require("./integrations/bull");
|
|
9
|
-
Object.defineProperty(exports, "attachToBull", { enumerable: true, get: function () { return bull_1.attachToBull; } });
|
|
10
|
-
var bee_1 = require("./integrations/bee");
|
|
11
|
-
Object.defineProperty(exports, "attachToBeeQueue", { enumerable: true, get: function () { return bee_1.attachToBeeQueue; } });
|
|
5
|
+
Object.defineProperty(exports, "Queuedash", { enumerable: true, get: function () { return client_1.Queuedash; } });
|
package/dist/types.d.ts
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface QueuedashOptions {
|
|
2
|
+
/** Your Queuedash API key */
|
|
2
3
|
apiKey: string;
|
|
4
|
+
/** Override the API URL (defaults to https://sync.queuedash.com in production) */
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
/** Number of jobs to batch before syncing (default: 50) */
|
|
3
7
|
batchSize?: number;
|
|
8
|
+
/** How often to flush batched jobs in ms (default: 100) */
|
|
4
9
|
flushInterval?: number;
|
|
10
|
+
/** Max retry attempts for failed syncs (default: 5) */
|
|
5
11
|
maxRetries?: number;
|
|
12
|
+
/** HTTP request timeout in ms (default: 30000) */
|
|
6
13
|
requestTimeout?: number;
|
|
14
|
+
/** Max jobs to queue in memory (default: 10000) */
|
|
7
15
|
maxQueueSize?: number;
|
|
16
|
+
/** Custom error handler */
|
|
8
17
|
onError?: (error: Error) => void;
|
|
9
|
-
/** @internal - Not for public use. Override API URL for staging environments only. */
|
|
10
|
-
__dangerouslyOverrideApiUrl?: string;
|
|
11
18
|
}
|
|
12
19
|
export interface JobData {
|
|
13
20
|
jobId: string;
|
|
@@ -26,6 +33,7 @@ export interface JobData {
|
|
|
26
33
|
delay?: number | null;
|
|
27
34
|
timestamp?: number | null;
|
|
28
35
|
progress?: number | null;
|
|
36
|
+
status?: string;
|
|
29
37
|
}
|
|
30
38
|
export interface SyncResponse {
|
|
31
39
|
success: boolean;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,6BAA6B;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,kFAAkF;IAClF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2DAA2D;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,uDAAuD;IACvD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mDAAmD;IACnD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2BAA2B;IAC3B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,OAAO,EAAE,IAAI,CAAC;IACd,WAAW,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAC1B,UAAU,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@queuedash/sdk",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Queuedash SDK for real-time queue monitoring",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -13,15 +13,16 @@
|
|
|
13
13
|
"bullmq",
|
|
14
14
|
"bull",
|
|
15
15
|
"bee-queue",
|
|
16
|
+
"groupmq",
|
|
16
17
|
"monitoring",
|
|
17
18
|
"dashboard"
|
|
18
19
|
],
|
|
19
|
-
"author": "
|
|
20
|
+
"author": "Alex Budure",
|
|
20
21
|
"license": "MIT",
|
|
21
22
|
"peerDependencies": {
|
|
22
|
-
"
|
|
23
|
+
"bee-queue": ">=1.0.0",
|
|
23
24
|
"bull": ">=4.0.0",
|
|
24
|
-
"
|
|
25
|
+
"bullmq": ">=5.0.0"
|
|
25
26
|
},
|
|
26
27
|
"peerDependenciesMeta": {
|
|
27
28
|
"bullmq": {
|
|
@@ -35,10 +36,25 @@
|
|
|
35
36
|
}
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
|
-
"@
|
|
39
|
+
"@changesets/changelog-github": "^0.5.1",
|
|
40
|
+
"@changesets/cli": "^2.29.7",
|
|
41
|
+
"@types/jest": "^29.5.14",
|
|
42
|
+
"@types/node": "^22.14.0",
|
|
43
|
+
"bullmq": "^5.67.2",
|
|
44
|
+
"husky": "^9.1.7",
|
|
45
|
+
"jest": "^29.7.0",
|
|
46
|
+
"lint-staged": "^16.2.7",
|
|
47
|
+
"prettier": "^3.7.1",
|
|
48
|
+
"ts-jest": "^29.2.5",
|
|
39
49
|
"typescript": "^5.9.3"
|
|
40
50
|
},
|
|
41
51
|
"scripts": {
|
|
42
|
-
"build": "tsc"
|
|
52
|
+
"build": "tsc",
|
|
53
|
+
"test": "jest",
|
|
54
|
+
"test:watch": "jest --watch",
|
|
55
|
+
"test:cov": "jest --coverage",
|
|
56
|
+
"format": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"",
|
|
57
|
+
"release": "pnpm build && changeset publish",
|
|
58
|
+
"preinstall": "npx only-allow pnpm"
|
|
43
59
|
}
|
|
44
60
|
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { QueueDashClient } from "../client";
|
|
2
|
-
type BeeQueue = any;
|
|
3
|
-
/**
|
|
4
|
-
* Attach QueueDash monitoring to a Bee-Queue
|
|
5
|
-
*/
|
|
6
|
-
export declare function attachToBeeQueue(queue: BeeQueue, client: QueueDashClient): void;
|
|
7
|
-
export {};
|
|
8
|
-
//# sourceMappingURL=bee.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bee.d.ts","sourceRoot":"","sources":["../../src/integrations/bee.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAG5C,KAAK,QAAQ,GAAG,GAAG,CAAC;AAGpB;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,QAAQ,EACf,MAAM,EAAE,eAAe,GACtB,IAAI,CAwCN"}
|
package/dist/integrations/bee.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.attachToBeeQueue = attachToBeeQueue;
|
|
4
|
-
/**
|
|
5
|
-
* Attach QueueDash monitoring to a Bee-Queue
|
|
6
|
-
*/
|
|
7
|
-
function attachToBeeQueue(queue, client) {
|
|
8
|
-
const queueName = queue.name;
|
|
9
|
-
const extractJobData = (job) => {
|
|
10
|
-
return {
|
|
11
|
-
jobId: String(job.id),
|
|
12
|
-
name: "default", // Bee-Queue doesn't have job names
|
|
13
|
-
queueName,
|
|
14
|
-
data: job.data,
|
|
15
|
-
opts: job.options || {},
|
|
16
|
-
addedAt: job.options?.timestamp
|
|
17
|
-
? new Date(job.options.timestamp)
|
|
18
|
-
: new Date(),
|
|
19
|
-
processedAt: null,
|
|
20
|
-
finishedAt: null,
|
|
21
|
-
priority: null,
|
|
22
|
-
delay: job.options?.delay,
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
// Listen to queue events
|
|
26
|
-
queue.on("succeeded", (job) => {
|
|
27
|
-
const jobData = extractJobData(job);
|
|
28
|
-
jobData.finishedAt = new Date();
|
|
29
|
-
client.syncJob(jobData);
|
|
30
|
-
});
|
|
31
|
-
queue.on("failed", (job, err) => {
|
|
32
|
-
const jobData = extractJobData(job);
|
|
33
|
-
jobData.failedReason = err.message;
|
|
34
|
-
jobData.stacktrace = err.stack ? [err.stack] : undefined;
|
|
35
|
-
jobData.finishedAt = new Date();
|
|
36
|
-
client.syncJob(jobData);
|
|
37
|
-
});
|
|
38
|
-
queue.on("retrying", (job) => {
|
|
39
|
-
const jobData = extractJobData(job);
|
|
40
|
-
jobData.retriedAt = new Date();
|
|
41
|
-
client.syncJob(jobData);
|
|
42
|
-
});
|
|
43
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { QueueDashClient } from "../client";
|
|
2
|
-
import { type Queue as BullQueue } from "bull";
|
|
3
|
-
/**
|
|
4
|
-
* Attach QueueDash monitoring to a Bull queue
|
|
5
|
-
*/
|
|
6
|
-
export declare function attachToBull(queue: BullQueue, client: QueueDashClient): void;
|
|
7
|
-
//# sourceMappingURL=bull.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.attachToBull = attachToBull;
|
|
4
|
-
/**
|
|
5
|
-
* Attach QueueDash monitoring to a Bull queue
|
|
6
|
-
*/
|
|
7
|
-
function attachToBull(queue, client) {
|
|
8
|
-
const queueName = queue.name;
|
|
9
|
-
const extractJobData = (job) => {
|
|
10
|
-
return {
|
|
11
|
-
jobId: job.id,
|
|
12
|
-
name: job.name || "default",
|
|
13
|
-
queueName,
|
|
14
|
-
data: job.data,
|
|
15
|
-
// @ts-expect-error
|
|
16
|
-
opts: job.opts,
|
|
17
|
-
addedAt: new Date(job.timestamp),
|
|
18
|
-
processedAt: job.processedOn ? new Date(job.processedOn) : null,
|
|
19
|
-
finishedAt: job.finishedOn ? new Date(job.finishedOn) : null,
|
|
20
|
-
failedReason: job.failedReason,
|
|
21
|
-
stacktrace: job.stacktrace,
|
|
22
|
-
priority: job.opts?.priority,
|
|
23
|
-
delay: job.opts?.delay,
|
|
24
|
-
timestamp: job.timestamp,
|
|
25
|
-
progress: job.progress(),
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
// Listen to queue events
|
|
29
|
-
queue.on("global:completed", (job) => {
|
|
30
|
-
client.syncJob(extractJobData(job));
|
|
31
|
-
});
|
|
32
|
-
queue.on("global:failed", (job) => {
|
|
33
|
-
if (job) {
|
|
34
|
-
client.syncJob(extractJobData(job));
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
queue.on("active", (job) => {
|
|
38
|
-
client.syncJob(extractJobData(job));
|
|
39
|
-
});
|
|
40
|
-
queue.on("progress", (job) => {
|
|
41
|
-
client.syncJob(extractJobData(job));
|
|
42
|
-
});
|
|
43
|
-
queue.on("removed", (job) => {
|
|
44
|
-
client.syncJob(extractJobData(job));
|
|
45
|
-
});
|
|
46
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { QueueDashClient } from "../client";
|
|
2
|
-
import { type Queue as BullMQQueue, type QueueEvents } from "bullmq";
|
|
3
|
-
/**
|
|
4
|
-
* Attach QueueDash monitoring to a BullMQ queue
|
|
5
|
-
*/
|
|
6
|
-
export declare function attachToBullMQ(queue: BullMQQueue, events: QueueEvents, client: QueueDashClient): void;
|
|
7
|
-
//# sourceMappingURL=bullmq.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.attachToBullMQ = attachToBullMQ;
|
|
4
|
-
/**
|
|
5
|
-
* Attach QueueDash monitoring to a BullMQ queue
|
|
6
|
-
*/
|
|
7
|
-
function attachToBullMQ(queue, events, client) {
|
|
8
|
-
const queueName = queue.name;
|
|
9
|
-
const extractJobData = (job) => {
|
|
10
|
-
return {
|
|
11
|
-
jobId: job.id,
|
|
12
|
-
name: job.name,
|
|
13
|
-
queueName,
|
|
14
|
-
data: job.data,
|
|
15
|
-
// @ts-expect-error
|
|
16
|
-
opts: job.opts,
|
|
17
|
-
addedAt: new Date(job.timestamp),
|
|
18
|
-
processedAt: job.processedOn ? new Date(job.processedOn) : null,
|
|
19
|
-
finishedAt: job.finishedOn ? new Date(job.finishedOn) : null,
|
|
20
|
-
failedReason: job.failedReason,
|
|
21
|
-
stacktrace: job.stacktrace,
|
|
22
|
-
priority: job.opts?.priority,
|
|
23
|
-
delay: job.opts?.delay,
|
|
24
|
-
timestamp: job.timestamp,
|
|
25
|
-
progress: typeof job.progress === "number" ? job.progress : null,
|
|
26
|
-
};
|
|
27
|
-
};
|
|
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));
|
|
47
|
-
}
|