@zintrust/workers 0.4.96 → 0.5.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/DeadLetterQueue.js +3 -1
- package/dist/PriorityQueue.d.ts +1 -1
- package/dist/build-manifest.json +11 -11
- package/dist/createQueueWorker.js +2 -2
- package/dist/ui/types/worker-ui.d.ts +0 -6
- package/package.json +2 -2
- package/src/ClusterLock.ts +2 -2
- package/src/ComplianceManager.ts +4 -2
- package/src/DeadLetterQueue.ts +10 -8
- package/src/ResourceMonitor.ts +1 -1
- package/src/WorkerFactory.ts +3 -1
- package/src/WorkerMetrics.ts +8 -4
- package/src/createQueueWorker.ts +2 -2
- package/src/http/middleware/ProcessorPathSanitizer.ts +2 -2
- package/src/telemetry/index.ts +2 -2
- package/src/ui/types/worker-ui.ts +0 -8
package/dist/DeadLetterQueue.js
CHANGED
|
@@ -227,7 +227,9 @@ export const DeadLetterQueue = Object.freeze({
|
|
|
227
227
|
try {
|
|
228
228
|
const key = getDLQKey(queueName);
|
|
229
229
|
const entries = await redisClient.zrange(key, 0, -1);
|
|
230
|
-
const entry = entries
|
|
230
|
+
const entry = entries
|
|
231
|
+
.map((e) => JSON.parse(e))
|
|
232
|
+
.find((e) => e.id === jobId);
|
|
231
233
|
if (entry) {
|
|
232
234
|
await recordAuditEntry({
|
|
233
235
|
timestamp: new Date(),
|
package/dist/PriorityQueue.d.ts
CHANGED
|
@@ -61,7 +61,7 @@ export declare const PriorityQueue: Readonly<{
|
|
|
61
61
|
/**
|
|
62
62
|
* Get job by ID
|
|
63
63
|
*/
|
|
64
|
-
getJob(queueName: string, jobId: string): Promise<import("bullmq").Job<any, any, string
|
|
64
|
+
getJob(queueName: string, jobId: string): Promise<import("bullmq").Job<any, any, string> | undefined>;
|
|
65
65
|
/**
|
|
66
66
|
* Remove a job
|
|
67
67
|
*/
|
package/dist/build-manifest.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zintrust/workers",
|
|
3
|
-
"version": "0.4.
|
|
4
|
-
"buildDate": "2026-04-
|
|
3
|
+
"version": "0.4.99",
|
|
4
|
+
"buildDate": "2026-04-12T09:59:29.806Z",
|
|
5
5
|
"buildEnvironment": {
|
|
6
|
-
"node": "
|
|
6
|
+
"node": "v25.6.1",
|
|
7
7
|
"platform": "darwin",
|
|
8
8
|
"arch": "arm64"
|
|
9
9
|
},
|
|
10
10
|
"git": {
|
|
11
|
-
"commit": "
|
|
11
|
+
"commit": "e4f2797b",
|
|
12
12
|
"branch": "release"
|
|
13
13
|
},
|
|
14
14
|
"package": {
|
|
@@ -150,8 +150,8 @@
|
|
|
150
150
|
"sha256": "d94f1d15984d27903b2dbdf2134c5cb06bdaed6950a0c8355009651df2758600"
|
|
151
151
|
},
|
|
152
152
|
"PriorityQueue.d.ts": {
|
|
153
|
-
"size":
|
|
154
|
-
"sha256": "
|
|
153
|
+
"size": 3204,
|
|
154
|
+
"sha256": "c9bca520824e523f0e7d7f0f04be0e36de8375d5b9cc0319238f6d9460186df2"
|
|
155
155
|
},
|
|
156
156
|
"PriorityQueue.js": {
|
|
157
157
|
"size": 8718,
|
|
@@ -230,8 +230,8 @@
|
|
|
230
230
|
"sha256": "8af20d462270e7044c6ea983821f5b6e6ce8a5caf39b6e8fefff07c9a0bf071e"
|
|
231
231
|
},
|
|
232
232
|
"build-manifest.json": {
|
|
233
|
-
"size":
|
|
234
|
-
"sha256": "
|
|
233
|
+
"size": 19881,
|
|
234
|
+
"sha256": "cd17f42f0cf04c185545aab31d797074a1583ad0b0bf1285663979c4306be01a"
|
|
235
235
|
},
|
|
236
236
|
"config/workerConfig.d.ts": {
|
|
237
237
|
"size": 282,
|
|
@@ -246,8 +246,8 @@
|
|
|
246
246
|
"sha256": "dacd49f6c112eba439bdd9bb457eea90daedbf32efc381cd3189ce562fa5b0a8"
|
|
247
247
|
},
|
|
248
248
|
"createQueueWorker.js": {
|
|
249
|
-
"size":
|
|
250
|
-
"sha256": "
|
|
249
|
+
"size": 15570,
|
|
250
|
+
"sha256": "0b866df4075bcd6b3f866b2588c1367910db2e4b5fe8b96765a58bafd80ea16c"
|
|
251
251
|
},
|
|
252
252
|
"dashboard/index.d.ts": {
|
|
253
253
|
"size": 109,
|
|
@@ -415,7 +415,7 @@
|
|
|
415
415
|
},
|
|
416
416
|
"index.js": {
|
|
417
417
|
"size": 2337,
|
|
418
|
-
"sha256": "
|
|
418
|
+
"sha256": "24c7780170d8bef4e981b0a7fd755bf0fec572285221fd4dd5af82983603f457"
|
|
419
419
|
},
|
|
420
420
|
"queueMonitorHistory.d.ts": {
|
|
421
421
|
"size": 433,
|
|
@@ -114,10 +114,10 @@ const getWorkerInstanceId = () => {
|
|
|
114
114
|
: undefined;
|
|
115
115
|
};
|
|
116
116
|
const getTrackerApi = () => {
|
|
117
|
-
return (getJobStateTracker() ?? {})
|
|
117
|
+
return (getJobStateTracker() ?? {});
|
|
118
118
|
};
|
|
119
119
|
const getHeartbeatStoreApi = () => {
|
|
120
|
-
return (getJobHeartbeatStore() ?? {})
|
|
120
|
+
return (getJobHeartbeatStore() ?? {});
|
|
121
121
|
};
|
|
122
122
|
const emitJobProcessed = (name) => {
|
|
123
123
|
const bridge = (getSystemTraceBridge() ?? {});
|
|
@@ -17,9 +17,6 @@ declare global {
|
|
|
17
17
|
dataset: DOMStringMap;
|
|
18
18
|
}
|
|
19
19
|
type UIEventListener = (evt: Event) => void;
|
|
20
|
-
interface Event {
|
|
21
|
-
target: EventTarget | null;
|
|
22
|
-
}
|
|
23
20
|
interface Element {
|
|
24
21
|
querySelector(selector: string): Element | null;
|
|
25
22
|
}
|
|
@@ -61,9 +58,6 @@ export interface Element {
|
|
|
61
58
|
export interface EventTarget {
|
|
62
59
|
addEventListener(type: string, listener: UIEventListener): void;
|
|
63
60
|
}
|
|
64
|
-
export interface Event {
|
|
65
|
-
target: EventTarget | null;
|
|
66
|
-
}
|
|
67
61
|
export type UIEventListener = (evt: Event) => void;
|
|
68
62
|
export interface HTMLElement {
|
|
69
63
|
appendChild(node: Node): Node;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zintrust/workers",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Worker orchestration and background job management for ZinTrust.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -73,4 +73,4 @@
|
|
|
73
73
|
"prom-client": "^15.1.3",
|
|
74
74
|
"simple-statistics": "^7.8.9"
|
|
75
75
|
}
|
|
76
|
-
}
|
|
76
|
+
}
|
package/src/ClusterLock.ts
CHANGED
|
@@ -405,7 +405,7 @@ export const ClusterLock = Object.freeze({
|
|
|
405
405
|
const keys = await redisClient.keys(pattern);
|
|
406
406
|
|
|
407
407
|
const locks = await Promise.all(
|
|
408
|
-
keys.map(async (key) => {
|
|
408
|
+
(keys as string[]).map(async (key: string) => {
|
|
409
409
|
const owner = await redisClient?.get(key);
|
|
410
410
|
const lockKey = key.replace(LOCK_PREFIX, '');
|
|
411
411
|
const info = activeLocks.get(lockKey);
|
|
@@ -466,7 +466,7 @@ export const ClusterLock = Object.freeze({
|
|
|
466
466
|
// Get latest entries (highest scores = most recent timestamps)
|
|
467
467
|
const entries = await redisClient.zrevrange(auditKey, 0, limit - 1);
|
|
468
468
|
|
|
469
|
-
return entries.map((entry) => JSON.parse(entry) as AuditLogEntry);
|
|
469
|
+
return (entries as string[]).map((entry: string) => JSON.parse(entry) as AuditLogEntry);
|
|
470
470
|
} catch (error) {
|
|
471
471
|
Logger.error(`Error retrieving audit log for "${lockKey}"`, error);
|
|
472
472
|
return [];
|
package/src/ComplianceManager.ts
CHANGED
|
@@ -711,7 +711,7 @@ export const ComplianceManager = Object.freeze({
|
|
|
711
711
|
|
|
712
712
|
const logs = await redisClient.zrangebyscore(key, minScore, maxScore, 'LIMIT', 0, limit);
|
|
713
713
|
|
|
714
|
-
return logs.map((log) => JSON.parse(log) as ComplianceAuditLog);
|
|
714
|
+
return (logs as string[]).map((log: string) => JSON.parse(log) as ComplianceAuditLog);
|
|
715
715
|
} catch (error) {
|
|
716
716
|
Logger.error('Failed to retrieve audit logs', error);
|
|
717
717
|
return [];
|
|
@@ -740,7 +740,9 @@ export const ComplianceManager = Object.freeze({
|
|
|
740
740
|
const requestKeys = await client.keys(`${ACCESS_REQUEST_PREFIX}*`);
|
|
741
741
|
let pendingRequests = 0;
|
|
742
742
|
|
|
743
|
-
const requestEntries = await Promise.all(
|
|
743
|
+
const requestEntries = await Promise.all(
|
|
744
|
+
(requestKeys as string[]).map(async (key: string) => client.get(key))
|
|
745
|
+
);
|
|
744
746
|
|
|
745
747
|
requestEntries.forEach((requestJson) => {
|
|
746
748
|
if (requestJson !== null) {
|
package/src/DeadLetterQueue.ts
CHANGED
|
@@ -195,11 +195,11 @@ const cleanupOldEntries = async (): Promise<number> => {
|
|
|
195
195
|
const keys = await client.keys(pattern);
|
|
196
196
|
|
|
197
197
|
const cleanedCounts = await Promise.all(
|
|
198
|
-
keys.map(async (key) => {
|
|
198
|
+
(keys as string[]).map(async (key: string) => {
|
|
199
199
|
const oldEntries = await client.zrangebyscore(key, '-inf', cutoffTimestamp);
|
|
200
200
|
|
|
201
201
|
await Promise.all(
|
|
202
|
-
oldEntries.map(async (entryJson) => {
|
|
202
|
+
(oldEntries as string[]).map(async (entryJson: string) => {
|
|
203
203
|
const entry = JSON.parse(entryJson) as FailedJobEntry;
|
|
204
204
|
|
|
205
205
|
if (policy.anonymizeInsteadOfDelete) {
|
|
@@ -345,7 +345,9 @@ export const DeadLetterQueue = Object.freeze({
|
|
|
345
345
|
const key = getDLQKey(queueName);
|
|
346
346
|
const entries = await redisClient.zrange(key, 0, -1);
|
|
347
347
|
|
|
348
|
-
const entry = entries
|
|
348
|
+
const entry = (entries as string[])
|
|
349
|
+
.map((e: string) => JSON.parse(e) as FailedJobEntry)
|
|
350
|
+
.find((e: FailedJobEntry) => e.id === jobId);
|
|
349
351
|
|
|
350
352
|
if (entry) {
|
|
351
353
|
await recordAuditEntry({
|
|
@@ -390,7 +392,7 @@ export const DeadLetterQueue = Object.freeze({
|
|
|
390
392
|
// Get most recent failures first (highest scores)
|
|
391
393
|
const entries = await redisClient.zrevrange(key, 0, limit - 1);
|
|
392
394
|
|
|
393
|
-
return entries.map((e) => JSON.parse(e) as FailedJobEntry);
|
|
395
|
+
return (entries as string[]).map((e: string) => JSON.parse(e) as FailedJobEntry);
|
|
394
396
|
} catch (error) {
|
|
395
397
|
Logger.error(`Failed to get DLQ entries for queue: ${queueName}`, error);
|
|
396
398
|
return [];
|
|
@@ -577,7 +579,7 @@ export const DeadLetterQueue = Object.freeze({
|
|
|
577
579
|
const auditKey = getAuditKey(failedJobId);
|
|
578
580
|
const entries = await redisClient.zrevrange(auditKey, 0, limit - 1);
|
|
579
581
|
|
|
580
|
-
return entries.map((e) => JSON.parse(e) as ComplianceAuditEntry);
|
|
582
|
+
return (entries as string[]).map((e: string) => JSON.parse(e) as ComplianceAuditEntry);
|
|
581
583
|
} catch (error) {
|
|
582
584
|
Logger.error(`Failed to get audit log for: ${failedJobId}`, error);
|
|
583
585
|
return [];
|
|
@@ -598,13 +600,13 @@ export const DeadLetterQueue = Object.freeze({
|
|
|
598
600
|
const keys = await client.keys(pattern);
|
|
599
601
|
|
|
600
602
|
const entriesByQueue = await Promise.all(
|
|
601
|
-
keys.map(async (key) => {
|
|
603
|
+
(keys as string[]).map(async (key: string) => {
|
|
602
604
|
const queueName = key.replace(getDLQPrefix(), '');
|
|
603
605
|
const entries = await client.zrange(key, 0, -1);
|
|
604
606
|
return {
|
|
605
607
|
queueName,
|
|
606
608
|
count: entries.length,
|
|
607
|
-
entries: entries.map((e) => JSON.parse(e) as FailedJobEntry),
|
|
609
|
+
entries: (entries as string[]).map((e: string) => JSON.parse(e) as FailedJobEntry),
|
|
608
610
|
};
|
|
609
611
|
})
|
|
610
612
|
);
|
|
@@ -626,7 +628,7 @@ export const DeadLetterQueue = Object.freeze({
|
|
|
626
628
|
stats.totalFailed += count;
|
|
627
629
|
stats.byQueue[queueName] = count;
|
|
628
630
|
|
|
629
|
-
entries.forEach((entry) => {
|
|
631
|
+
entries.forEach((entry: FailedJobEntry) => {
|
|
630
632
|
stats.byWorker[entry.workerName] = (stats.byWorker[entry.workerName] || 0) + 1;
|
|
631
633
|
stats.byErrorType[entry.error.name] = (stats.byErrorType[entry.error.name] || 0) + 1;
|
|
632
634
|
|
package/src/ResourceMonitor.ts
CHANGED
|
@@ -222,7 +222,7 @@ const calculateCpuUsage = (): number => {
|
|
|
222
222
|
let totalIdle = 0;
|
|
223
223
|
let totalTick = 0;
|
|
224
224
|
|
|
225
|
-
cpus.forEach((cpu) => {
|
|
225
|
+
cpus.forEach((cpu: { times: Record<string, number> }) => {
|
|
226
226
|
for (const type in cpu.times) {
|
|
227
227
|
totalTick += cpu.times[type as keyof typeof cpu.times];
|
|
228
228
|
}
|
package/src/WorkerFactory.ts
CHANGED
|
@@ -1080,7 +1080,9 @@ const setCachedProcessor = (key: string, entry: CachedProcessor, maxSize: number
|
|
|
1080
1080
|
};
|
|
1081
1081
|
|
|
1082
1082
|
const isAllowedRemoteHost = (host: string): boolean => {
|
|
1083
|
-
const allowlist = getProcessorSpecConfig().remoteAllowlist
|
|
1083
|
+
const allowlist = (getProcessorSpecConfig().remoteAllowlist as readonly string[]).map(
|
|
1084
|
+
(value: string) => value.toLowerCase()
|
|
1085
|
+
);
|
|
1084
1086
|
return allowlist.includes(host.toLowerCase());
|
|
1085
1087
|
};
|
|
1086
1088
|
|
package/src/WorkerMetrics.ts
CHANGED
|
@@ -444,7 +444,9 @@ const WorkerMetrics = Object.freeze({
|
|
|
444
444
|
// Get data from sorted set
|
|
445
445
|
const results = await client.zrangebyscore(key, minScore, maxScore, 'LIMIT', 0, limit);
|
|
446
446
|
|
|
447
|
-
const points: MetricPoint[] = results
|
|
447
|
+
const points: MetricPoint[] = (results as string[]).map(
|
|
448
|
+
(data: string) => JSON.parse(data) as MetricPoint
|
|
449
|
+
);
|
|
448
450
|
|
|
449
451
|
return {
|
|
450
452
|
workerName,
|
|
@@ -629,7 +631,7 @@ const WorkerMetrics = Object.freeze({
|
|
|
629
631
|
|
|
630
632
|
const results = await client.zrangebyscore(key, startTime, now);
|
|
631
633
|
|
|
632
|
-
return results.map((data) => JSON.parse(data) as WorkerHealthScore);
|
|
634
|
+
return (results as string[]).map((data: string) => JSON.parse(data) as WorkerHealthScore);
|
|
633
635
|
} catch (error) {
|
|
634
636
|
Logger.error(`Error retrieving health history for ${workerName}`, error);
|
|
635
637
|
return [];
|
|
@@ -678,10 +680,12 @@ const WorkerMetrics = Object.freeze({
|
|
|
678
680
|
// Find all unique worker names from health keys
|
|
679
681
|
const pattern = `${RedisKeys.healthPrefix}*`;
|
|
680
682
|
const keys = await client.keys(pattern);
|
|
681
|
-
const workerNames = keys.map((key) =>
|
|
683
|
+
const workerNames = (keys as string[]).map((key: string) =>
|
|
684
|
+
key.replace(RedisKeys.healthPrefix, '')
|
|
685
|
+
);
|
|
682
686
|
|
|
683
687
|
const summaries = await Promise.all(
|
|
684
|
-
workerNames.map(async (workerName) => {
|
|
688
|
+
workerNames.map(async (workerName: string) => {
|
|
685
689
|
const now = new Date();
|
|
686
690
|
const oneHourAgo = new Date(now.getTime() - 60 * 60 * 1000);
|
|
687
691
|
|
package/src/createQueueWorker.ts
CHANGED
|
@@ -230,11 +230,11 @@ const getWorkerInstanceId = (): string | undefined => {
|
|
|
230
230
|
};
|
|
231
231
|
|
|
232
232
|
const getTrackerApi = (): TrackerApi => {
|
|
233
|
-
return (
|
|
233
|
+
return (getJobStateTracker() ?? {}) as TrackerApi;
|
|
234
234
|
};
|
|
235
235
|
|
|
236
236
|
const getHeartbeatStoreApi = (): HeartbeatStoreApi => {
|
|
237
|
-
return (
|
|
237
|
+
return (getJobHeartbeatStore() ?? {}) as HeartbeatStoreApi;
|
|
238
238
|
};
|
|
239
239
|
|
|
240
240
|
const emitJobProcessed = (name: string): void => {
|
|
@@ -20,8 +20,8 @@ const normalizeUrlSpec = (value: string): string => {
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
const isAllowedRemoteHost = (host: string): boolean => {
|
|
23
|
-
const allowlist = workersConfig.processorSpec.remoteAllowlist;
|
|
24
|
-
return allowlist.map((value) => value.toLowerCase()).includes(host.toLowerCase());
|
|
23
|
+
const allowlist = workersConfig.processorSpec.remoteAllowlist as readonly string[];
|
|
24
|
+
return allowlist.map((value: string) => value.toLowerCase()).includes(host.toLowerCase());
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
const decodeProcessorPath = (processor: string): string => {
|
package/src/telemetry/index.ts
CHANGED
|
@@ -72,7 +72,7 @@ function registerDashboardRoute(
|
|
|
72
72
|
Router.get(
|
|
73
73
|
router,
|
|
74
74
|
settings.basePath,
|
|
75
|
-
(_req, res) => {
|
|
75
|
+
(_req: IRequest, res: IResponse) => {
|
|
76
76
|
res.html(
|
|
77
77
|
getDashboardHtml({
|
|
78
78
|
basePath: settings.basePath,
|
|
@@ -95,7 +95,7 @@ function registerSummaryApi(
|
|
|
95
95
|
Router.get(
|
|
96
96
|
router,
|
|
97
97
|
`${settings.basePath}/api/summary`,
|
|
98
|
-
async (_req, res) => {
|
|
98
|
+
async (_req: IRequest, res: IResponse) => {
|
|
99
99
|
const snapshot = await buildSnapshot();
|
|
100
100
|
res.json(snapshot);
|
|
101
101
|
},
|
|
@@ -25,10 +25,6 @@ declare global {
|
|
|
25
25
|
// UIEventListener type for browser environment
|
|
26
26
|
type UIEventListener = (evt: Event) => void;
|
|
27
27
|
|
|
28
|
-
interface Event {
|
|
29
|
-
target: EventTarget | null;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
28
|
interface Element {
|
|
33
29
|
querySelector(selector: string): Element | null;
|
|
34
30
|
}
|
|
@@ -95,10 +91,6 @@ export interface EventTarget {
|
|
|
95
91
|
addEventListener(type: string, listener: UIEventListener): void;
|
|
96
92
|
}
|
|
97
93
|
|
|
98
|
-
export interface Event {
|
|
99
|
-
target: EventTarget | null;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
94
|
// UIEventListener type for browser environment
|
|
103
95
|
export type UIEventListener = (evt: Event) => void;
|
|
104
96
|
|