@zintrust/workers 2.0.3 → 2.0.5
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/AnomalyDetection.js +3 -1
- package/dist/AutoScaler.js +3 -1
- package/dist/BroadcastWorker.js +2 -1
- package/dist/CanaryController.js +2 -1
- package/dist/ChaosEngineering.js +3 -1
- package/dist/CircuitBreaker.js +1 -1
- package/dist/ClusterLock.d.ts +1 -1
- package/dist/ClusterLock.js +5 -1
- package/dist/ComplianceManager.d.ts +1 -1
- package/dist/ComplianceManager.js +4 -1
- package/dist/DatacenterOrchestrator.js +2 -1
- package/dist/DeadLetterQueue.d.ts +1 -1
- package/dist/DeadLetterQueue.js +3 -1
- package/dist/HealthMonitor.js +2 -1
- package/dist/MultiQueueWorker.js +3 -1
- package/dist/NotificationWorker.js +1 -1
- package/dist/Observability.js +3 -1
- package/dist/PluginManager.js +2 -1
- package/dist/PriorityQueue.d.ts +1 -1
- package/dist/PriorityQueue.js +2 -1
- package/dist/ResourceMonitor.js +3 -1
- package/dist/SLAMonitor.js +3 -1
- package/dist/WorkerFactory.d.ts +2 -2
- package/dist/WorkerFactory.js +8 -2
- package/dist/WorkerInit.js +3 -1
- package/dist/WorkerMetrics.d.ts +1 -1
- package/dist/WorkerMetrics.js +3 -1
- package/dist/WorkerRegistry.d.ts +1 -1
- package/dist/WorkerRegistry.js +2 -1
- package/dist/WorkerShutdown.js +1 -1
- package/dist/WorkerVersioning.js +2 -1
- package/dist/config/workerConfig.js +1 -1
- package/dist/createQueueWorker.js +11 -44
- package/dist/dashboard/workers-api.js +7 -3
- package/dist/helper/index.d.ts +6 -1
- package/dist/helper/index.js +51 -0
- package/dist/http/WorkerApiController.d.ts +1 -1
- package/dist/http/WorkerApiController.js +29 -4
- package/dist/http/WorkerController.d.ts +1 -1
- package/dist/http/WorkerController.js +4 -1
- package/dist/http/WorkerMonitoringService.js +2 -1
- package/dist/http/middleware/CustomValidation.d.ts +1 -1
- package/dist/http/middleware/CustomValidation.js +1 -1
- package/dist/http/middleware/DatacenterValidator.d.ts +1 -1
- package/dist/http/middleware/DatacenterValidator.js +1 -1
- package/dist/http/middleware/EditWorkerValidation.d.ts +1 -1
- package/dist/http/middleware/EditWorkerValidation.js +1 -1
- package/dist/http/middleware/FeaturesValidator.d.ts +1 -1
- package/dist/http/middleware/FeaturesValidator.js +1 -1
- package/dist/http/middleware/InfrastructureValidator.d.ts +1 -1
- package/dist/http/middleware/InfrastructureValidator.js +1 -1
- package/dist/http/middleware/OptionsValidator.d.ts +1 -1
- package/dist/http/middleware/OptionsValidator.js +1 -1
- package/dist/http/middleware/PayloadSanitizer.d.ts +1 -1
- package/dist/http/middleware/PayloadSanitizer.js +1 -1
- package/dist/http/middleware/ProcessorPathSanitizer.d.ts +1 -1
- package/dist/http/middleware/ProcessorPathSanitizer.js +2 -1
- package/dist/http/middleware/QueueNameSanitizer.d.ts +1 -1
- package/dist/http/middleware/QueueNameSanitizer.js +1 -1
- package/dist/http/middleware/ValidateDriver.d.ts +1 -1
- package/dist/http/middleware/VersionSanitizer.d.ts +1 -1
- package/dist/http/middleware/VersionSanitizer.js +1 -1
- package/dist/http/middleware/WorkerNameSanitizer.d.ts +1 -1
- package/dist/http/middleware/WorkerNameSanitizer.js +1 -1
- package/dist/http/middleware/WorkerValidationChain.d.ts +1 -1
- package/dist/http/middleware/WorkerValidationChain.js +1 -1
- package/dist/queueMonitorHistory.js +3 -1
- package/dist/routes/workers.d.ts +1 -1
- package/dist/routes/workers.js +4 -1
- package/dist/storage/WorkerStore.d.ts +2 -2
- package/dist/telemetry/api/TelemetryAPI.js +1 -1
- package/dist/telemetry/api/TelemetryMonitoringService.d.ts +1 -1
- package/dist/telemetry/api/TelemetryMonitoringService.js +2 -1
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/telemetry/index.js +2 -1
- package/dist/ui/router/ui.d.ts +1 -1
- package/dist/ui/router/ui.js +6 -1
- package/package.json +1 -1
- package/src/AnomalyDetection.ts +4 -2
- package/src/AutoScaler.ts +3 -2
- package/src/BroadcastWorker.ts +2 -1
- package/src/CanaryController.ts +2 -1
- package/src/ChaosEngineering.ts +3 -1
- package/src/CircuitBreaker.ts +1 -1
- package/src/ClusterLock.ts +5 -8
- package/src/ComplianceManager.ts +4 -7
- package/src/DatacenterOrchestrator.ts +2 -1
- package/src/DeadLetterQueue.ts +3 -1
- package/src/HealthMonitor.ts +2 -1
- package/src/MultiQueueWorker.ts +3 -1
- package/src/NotificationWorker.ts +1 -1
- package/src/Observability.ts +3 -1
- package/src/PluginManager.ts +2 -1
- package/src/PriorityQueue.ts +3 -1
- package/src/ResourceMonitor.ts +3 -1
- package/src/SLAMonitor.ts +3 -1
- package/src/WorkerFactory.ts +13 -19
- package/src/WorkerInit.ts +3 -1
- package/src/WorkerMetrics.ts +3 -7
- package/src/WorkerRegistry.ts +3 -1
- package/src/WorkerShutdown.ts +1 -1
- package/src/WorkerVersioning.ts +2 -1
- package/src/config/workerConfig.ts +1 -1
- package/src/createQueueWorker.ts +12 -45
- package/src/dashboard/workers-api.ts +7 -3
- package/src/helper/index.ts +61 -1
- package/src/http/WorkerApiController.ts +38 -5
- package/src/http/WorkerController.ts +5 -8
- package/src/http/WorkerMonitoringService.ts +2 -1
- package/src/http/middleware/CustomValidation.ts +2 -1
- package/src/http/middleware/DatacenterValidator.ts +2 -1
- package/src/http/middleware/EditWorkerValidation.ts +2 -1
- package/src/http/middleware/FeaturesValidator.ts +2 -1
- package/src/http/middleware/InfrastructureValidator.ts +2 -1
- package/src/http/middleware/OptionsValidator.ts +2 -1
- package/src/http/middleware/PayloadSanitizer.ts +2 -1
- package/src/http/middleware/ProcessorPathSanitizer.ts +3 -7
- package/src/http/middleware/QueueNameSanitizer.ts +2 -1
- package/src/http/middleware/ValidateDriver.ts +1 -1
- package/src/http/middleware/VersionSanitizer.ts +2 -1
- package/src/http/middleware/WorkerNameSanitizer.ts +2 -1
- package/src/http/middleware/WorkerValidationChain.ts +2 -1
- package/src/queueMonitorHistory.ts +3 -1
- package/src/routes/workers.ts +5 -2
- package/src/storage/WorkerStore.ts +2 -2
- package/src/telemetry/api/TelemetryAPI.ts +1 -1
- package/src/telemetry/api/TelemetryMonitoringService.ts +3 -2
- package/src/telemetry/index.ts +3 -2
- package/src/ui/router/ui.ts +9 -11
package/src/SLAMonitor.ts
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { ErrorFactory
|
|
7
|
+
import { ErrorFactory } from '@zintrust/core/errors';
|
|
8
|
+
import { Logger } from '@zintrust/core/logger';
|
|
9
|
+
import { generateUuid } from '@zintrust/core/utils';
|
|
8
10
|
import { HealthMonitor, type HealthCheckResult } from './HealthMonitor';
|
|
9
11
|
import { WorkerMetrics, type MetricPoint, type MetricType } from './WorkerMetrics';
|
|
10
12
|
|
package/src/WorkerFactory.ts
CHANGED
|
@@ -5,31 +5,25 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import * as ZintrustCoreModule from '@zintrust/core';
|
|
8
|
+
import { Cloudflare, databaseConfig, Env, queueConfig, workersConfig } from '@zintrust/core/config';
|
|
9
|
+
import { useEnsureDbConnected, type IDatabase } from '@zintrust/core/database';
|
|
10
|
+
import { ErrorFactory } from '@zintrust/core/errors';
|
|
11
|
+
import { Logger } from '@zintrust/core/logger';
|
|
12
|
+
import { DatabaseConnectionRegistry, registerDatabasesFromRuntimeConfig } from '@zintrust/core/orm';
|
|
13
|
+
import { JobStateTracker } from '@zintrust/core/queue';
|
|
8
14
|
import {
|
|
9
|
-
|
|
10
|
-
ErrorFactory,
|
|
11
|
-
generateUuid,
|
|
15
|
+
createRedisConnection,
|
|
12
16
|
getBullMQSafeQueueName,
|
|
17
|
+
type RedisConfig,
|
|
18
|
+
} from '@zintrust/core/redis';
|
|
19
|
+
import {
|
|
20
|
+
generateUuid,
|
|
13
21
|
isFunction,
|
|
14
22
|
isNonEmptyString,
|
|
15
23
|
isObject,
|
|
16
|
-
JobStateTracker,
|
|
17
|
-
Logger,
|
|
18
|
-
NodeSingletons,
|
|
19
|
-
useEnsureDbConnected,
|
|
20
24
|
ZintrustLang,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
} from '@zintrust/core';
|
|
24
|
-
import {
|
|
25
|
-
Cloudflare,
|
|
26
|
-
createRedisConnection,
|
|
27
|
-
databaseConfig,
|
|
28
|
-
queueConfig,
|
|
29
|
-
workersConfig,
|
|
30
|
-
type RedisConfig,
|
|
31
|
-
} from '@zintrust/core/config';
|
|
32
|
-
import { DatabaseConnectionRegistry, registerDatabasesFromRuntimeConfig } from '@zintrust/core/orm';
|
|
25
|
+
} from '@zintrust/core/utils';
|
|
26
|
+
import { NodeSingletons, type WorkerStatus } from '@zintrust/core/workers';
|
|
33
27
|
import { Worker, type Job, type WorkerOptions } from 'bullmq';
|
|
34
28
|
import { AutoScaler, type AutoScalerConfig } from './AutoScaler';
|
|
35
29
|
import { CanaryController } from './CanaryController';
|
package/src/WorkerInit.ts
CHANGED
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
* - Ensures graceful startup and shutdown
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { Env
|
|
11
|
+
import { Env } from '@zintrust/core/config';
|
|
12
|
+
import { Logger } from '@zintrust/core/logger';
|
|
13
|
+
import { isObject } from '@zintrust/core/utils';
|
|
12
14
|
import { ResourceMonitor } from './ResourceMonitor';
|
|
13
15
|
import type { WorkerPersistenceConfig } from './WorkerFactory';
|
|
14
16
|
import { WorkerFactory } from './WorkerFactory';
|
package/src/WorkerMetrics.ts
CHANGED
|
@@ -4,13 +4,9 @@
|
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
RedisKeys,
|
|
11
|
-
createRedisConnection,
|
|
12
|
-
type RedisConfig,
|
|
13
|
-
} from '@zintrust/core';
|
|
7
|
+
import { ErrorFactory } from '@zintrust/core/errors';
|
|
8
|
+
import { Logger } from '@zintrust/core/logger';
|
|
9
|
+
import { RedisKeys, createRedisConnection, type RedisConfig } from '@zintrust/core/redis';
|
|
14
10
|
|
|
15
11
|
type RedisConnection = ReturnType<typeof createRedisConnection>;
|
|
16
12
|
type RedisPipeline = ReturnType<RedisConnection['pipeline']>;
|
package/src/WorkerRegistry.ts
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { ErrorFactory
|
|
7
|
+
import { ErrorFactory } from '@zintrust/core/errors';
|
|
8
|
+
import { Logger } from '@zintrust/core/logger';
|
|
9
|
+
import { type WorkerConfig, type WorkerStatus } from '@zintrust/core/workers';
|
|
8
10
|
import { AnomalyDetection } from './AnomalyDetection';
|
|
9
11
|
|
|
10
12
|
export type WorkerMetadata = {
|
package/src/WorkerShutdown.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Coordinates orderly shutdown of all worker modules and the WorkerFactory.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { Logger } from '@zintrust/core';
|
|
8
|
+
import { Logger } from '@zintrust/core/logger';
|
|
9
9
|
import { WorkerFactory } from './WorkerFactory';
|
|
10
10
|
|
|
11
11
|
// ============================================================================
|
package/src/WorkerVersioning.ts
CHANGED
package/src/createQueueWorker.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import { Env } from '@zintrust/core/config';
|
|
2
|
+
import { Logger } from '@zintrust/core/logger';
|
|
3
|
+
import type { BullMQPayload, QueueMessage } from '@zintrust/core/queue';
|
|
4
|
+
import { JobHeartbeatStore, JobStateTracker, Queue, TimeoutManager } from '@zintrust/core/queue';
|
|
5
|
+
import { SystemTraceBridge } from '@zintrust/core/trace';
|
|
4
6
|
import { recordQueueMonitorJob } from './queueMonitorHistory';
|
|
5
7
|
|
|
6
8
|
type QueueApi = Readonly<{
|
|
@@ -17,38 +19,6 @@ const TypedQueue = Queue as QueueApi;
|
|
|
17
19
|
const RETRY_BASE_DELAY_MS = 1000;
|
|
18
20
|
const RETRY_MAX_DELAY_MS = 30000;
|
|
19
21
|
|
|
20
|
-
const getJobStateTracker = (): unknown => {
|
|
21
|
-
try {
|
|
22
|
-
return (Core as Record<string, unknown>)['JobStateTracker'];
|
|
23
|
-
} catch {
|
|
24
|
-
return undefined;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const getJobHeartbeatStore = (): unknown => {
|
|
29
|
-
try {
|
|
30
|
-
return (Core as Record<string, unknown>)['JobHeartbeatStore'];
|
|
31
|
-
} catch {
|
|
32
|
-
return undefined;
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const getTimeoutManager = (): unknown => {
|
|
37
|
-
try {
|
|
38
|
-
return (Core as Record<string, unknown>)['TimeoutManager'];
|
|
39
|
-
} catch {
|
|
40
|
-
return undefined;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const getSystemTraceBridge = (): unknown => {
|
|
45
|
-
try {
|
|
46
|
-
return (Core as Record<string, unknown>)['SystemTraceBridge'];
|
|
47
|
-
} catch {
|
|
48
|
-
return undefined;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
22
|
const getEnvInt = (key: string, fallback: number): number => {
|
|
53
23
|
const getter = (Env as { getInt?: (name: string, defaultValue: number) => number }).getInt;
|
|
54
24
|
if (typeof getter === 'function') {
|
|
@@ -65,8 +35,7 @@ const getEnvInt = (key: string, fallback: number): number => {
|
|
|
65
35
|
};
|
|
66
36
|
|
|
67
37
|
const resolveQueueJobTimeoutMs = (): number => {
|
|
68
|
-
const
|
|
69
|
-
const tm = (timeoutManager ?? {}) as { getQueueJobTimeoutMs?: () => number };
|
|
38
|
+
const tm = (TimeoutManager ?? {}) as { getQueueJobTimeoutMs?: () => number };
|
|
70
39
|
if (typeof tm.getQueueJobTimeoutMs === 'function') {
|
|
71
40
|
return tm.getQueueJobTimeoutMs();
|
|
72
41
|
}
|
|
@@ -78,8 +47,7 @@ const runWithTimeout = async <T>(
|
|
|
78
47
|
timeoutMs: number,
|
|
79
48
|
operationName: string
|
|
80
49
|
): Promise<T> => {
|
|
81
|
-
const
|
|
82
|
-
const tm = (timeoutManager ?? {}) as {
|
|
50
|
+
const tm = (TimeoutManager ?? {}) as {
|
|
83
51
|
withTimeout?: <R>(
|
|
84
52
|
op: () => Promise<R>,
|
|
85
53
|
t: number,
|
|
@@ -94,8 +62,7 @@ const runWithTimeout = async <T>(
|
|
|
94
62
|
};
|
|
95
63
|
|
|
96
64
|
const isTimeoutError = (error: unknown): boolean => {
|
|
97
|
-
const
|
|
98
|
-
const tm = (timeoutManager ?? {}) as { isTimeoutError?: (value: unknown) => boolean };
|
|
65
|
+
const tm = (TimeoutManager ?? {}) as { isTimeoutError?: (value: unknown) => boolean };
|
|
99
66
|
if (typeof tm.isTimeoutError === 'function') {
|
|
100
67
|
return tm.isTimeoutError(error);
|
|
101
68
|
}
|
|
@@ -230,15 +197,15 @@ const getWorkerInstanceId = (): string | undefined => {
|
|
|
230
197
|
};
|
|
231
198
|
|
|
232
199
|
const getTrackerApi = (): TrackerApi => {
|
|
233
|
-
return (
|
|
200
|
+
return (JobStateTracker ?? {}) as TrackerApi;
|
|
234
201
|
};
|
|
235
202
|
|
|
236
203
|
const getHeartbeatStoreApi = (): HeartbeatStoreApi => {
|
|
237
|
-
return (
|
|
204
|
+
return (JobHeartbeatStore ?? {}) as HeartbeatStoreApi;
|
|
238
205
|
};
|
|
239
206
|
|
|
240
207
|
const emitJobProcessed = (name: string): void => {
|
|
241
|
-
const bridge = (
|
|
208
|
+
const bridge = (SystemTraceBridge ?? {}) as {
|
|
242
209
|
emitJobProcessed?: (jobName: string) => void;
|
|
243
210
|
};
|
|
244
211
|
|
|
@@ -246,7 +213,7 @@ const emitJobProcessed = (name: string): void => {
|
|
|
246
213
|
};
|
|
247
214
|
|
|
248
215
|
const emitJobFailed = (name: string, error: Error): void => {
|
|
249
|
-
const bridge = (
|
|
216
|
+
const bridge = (SystemTraceBridge ?? {}) as {
|
|
250
217
|
emitJobFailed?: (jobName: string, failure: Error) => void;
|
|
251
218
|
};
|
|
252
219
|
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { Env,
|
|
1
|
+
import { Env, queueConfig } from '@zintrust/core/config';
|
|
2
|
+
import { ErrorFactory } from '@zintrust/core/errors';
|
|
3
|
+
import { Logger } from '@zintrust/core/logger';
|
|
2
4
|
import { WorkerFactory } from '../WorkerFactory';
|
|
3
5
|
import { WorkerMetrics as WorkerMetricsManager } from '../WorkerMetrics';
|
|
4
6
|
import { WorkerRegistry } from '../WorkerRegistry';
|
|
7
|
+
import { maskInfrastructurePasswords } from '../helper';
|
|
5
8
|
import type { WorkerRecord } from '../storage/WorkerStore';
|
|
6
9
|
import type {
|
|
7
10
|
GetWorkersQuery,
|
|
@@ -613,8 +616,9 @@ async function getRedisQueueData(): Promise<QueueData> {
|
|
|
613
616
|
try {
|
|
614
617
|
// Use existing queue monitor infrastructure
|
|
615
618
|
const { QueueMonitor } = await import('@zintrust/queue-monitor');
|
|
619
|
+
const { queueConfig: FreshQeueConfig } = await import('@zintrust/core/config');
|
|
616
620
|
|
|
617
|
-
const redisConfig =
|
|
621
|
+
const redisConfig = FreshQeueConfig.drivers.redis;
|
|
618
622
|
if (redisConfig?.driver !== 'redis') {
|
|
619
623
|
throw ErrorFactory.createConfigError('Redis driver not configured');
|
|
620
624
|
}
|
|
@@ -909,7 +913,7 @@ function buildWorkerConfiguration(
|
|
|
909
913
|
activeStatus: persisted.activeStatus ?? true,
|
|
910
914
|
version: persisted.version ?? worker.version,
|
|
911
915
|
features: persisted.features ?? null,
|
|
912
|
-
infrastructure: persisted.infrastructure
|
|
916
|
+
infrastructure: maskInfrastructurePasswords(persisted.infrastructure),
|
|
913
917
|
datacenter: persisted.datacenter ?? null,
|
|
914
918
|
};
|
|
915
919
|
}
|
package/src/helper/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IRequest } from '@zintrust/core';
|
|
1
|
+
import type { IRequest } from '@zintrust/core/http';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Helper to get path parameter
|
|
@@ -9,3 +9,63 @@ export const getParam = (req: IRequest, key: string): string => {
|
|
|
9
9
|
const params = (req.params as Record<string, string> | undefined) ?? {};
|
|
10
10
|
return params[key] ?? '';
|
|
11
11
|
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Mask password in a record if present
|
|
15
|
+
*/
|
|
16
|
+
const maskPassword = (obj: Record<string, unknown>): void => {
|
|
17
|
+
if (typeof obj['password'] === 'string' && obj['password'].length > 0) {
|
|
18
|
+
obj['password'] = '******';
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Mask passwords in a nested connection object
|
|
24
|
+
*/
|
|
25
|
+
const maskConnectionPassword = (persistence: Record<string, unknown>): void => {
|
|
26
|
+
if (typeof persistence['connection'] === 'object' && persistence['connection'] !== null) {
|
|
27
|
+
const connection = { ...(persistence['connection'] as Record<string, unknown>) };
|
|
28
|
+
maskPassword(connection);
|
|
29
|
+
persistence['connection'] = connection;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Mask Redis password in infrastructure data
|
|
35
|
+
*/
|
|
36
|
+
const maskRedisPassword = (masked: Record<string, unknown>): void => {
|
|
37
|
+
if (typeof masked['redis'] === 'object' && masked['redis'] !== null) {
|
|
38
|
+
const redis = { ...(masked['redis'] as Record<string, unknown>) };
|
|
39
|
+
maskPassword(redis);
|
|
40
|
+
masked['redis'] = redis;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Mask persistence password in infrastructure data
|
|
46
|
+
*/
|
|
47
|
+
const maskPersistencePassword = (masked: Record<string, unknown>): void => {
|
|
48
|
+
if (typeof masked['persistence'] === 'object' && masked['persistence'] !== null) {
|
|
49
|
+
const persistence = { ...(masked['persistence'] as Record<string, unknown>) };
|
|
50
|
+
maskPassword(persistence);
|
|
51
|
+
maskConnectionPassword(persistence);
|
|
52
|
+
masked['persistence'] = persistence;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Mask sensitive password fields in infrastructure data
|
|
58
|
+
* This masks both Redis and database passwords to prevent them from being exposed in API responses
|
|
59
|
+
*/
|
|
60
|
+
export const maskInfrastructurePasswords = (
|
|
61
|
+
infrastructure: Record<string, unknown> | null | undefined
|
|
62
|
+
): Record<string, unknown> | null => {
|
|
63
|
+
if (!infrastructure) return null;
|
|
64
|
+
|
|
65
|
+
const masked = { ...infrastructure };
|
|
66
|
+
|
|
67
|
+
maskRedisPassword(masked);
|
|
68
|
+
maskPersistencePassword(masked);
|
|
69
|
+
|
|
70
|
+
return masked;
|
|
71
|
+
};
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* HTTP handlers for worker management API
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { IRequest, IResponse } from '@zintrust/core';
|
|
7
|
-
import { Logger } from '@zintrust/core';
|
|
6
|
+
import type { IRequest, IResponse } from '@zintrust/core/http';
|
|
7
|
+
import { Logger } from '@zintrust/core/logger';
|
|
8
8
|
import type {
|
|
9
9
|
GetWorkersQuery,
|
|
10
10
|
WorkerDriver,
|
|
@@ -13,7 +13,7 @@ import type {
|
|
|
13
13
|
WorkerStatus,
|
|
14
14
|
} from '../dashboard/types';
|
|
15
15
|
import { getWorkerDetails, getWorkers } from '../dashboard/workers-api';
|
|
16
|
-
import { getParam } from '../helper';
|
|
16
|
+
import { getParam, maskInfrastructurePasswords } from '../helper';
|
|
17
17
|
import { WorkerFactory } from '../WorkerFactory';
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -116,7 +116,28 @@ export const listWorkers = async (req: IRequest, res: IResponse): Promise<void>
|
|
|
116
116
|
};
|
|
117
117
|
|
|
118
118
|
const result = await getWorkers(queryParams);
|
|
119
|
-
|
|
119
|
+
|
|
120
|
+
// Mask passwords in infrastructure data for all workers
|
|
121
|
+
const maskedWorkers = result.workers.map((worker) => {
|
|
122
|
+
const maskedWorker = { ...worker };
|
|
123
|
+
if (maskedWorker.details?.configuration) {
|
|
124
|
+
maskedWorker.details = {
|
|
125
|
+
...maskedWorker.details,
|
|
126
|
+
configuration: {
|
|
127
|
+
...maskedWorker.details.configuration,
|
|
128
|
+
infrastructure: maskInfrastructurePasswords(
|
|
129
|
+
maskedWorker.details.configuration['infrastructure'] as Record<string, unknown> | null
|
|
130
|
+
),
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
return maskedWorker;
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
res.json({
|
|
138
|
+
...result,
|
|
139
|
+
workers: maskedWorkers,
|
|
140
|
+
});
|
|
120
141
|
} catch (error) {
|
|
121
142
|
Logger.error('Error fetching workers:', error);
|
|
122
143
|
res.status(500).json({
|
|
@@ -138,6 +159,8 @@ export const getWorkerDetailsHandler = async (req: IRequest, res: IResponse): Pr
|
|
|
138
159
|
}
|
|
139
160
|
const driver = getQueryParam(req.getQuery?.() || {}, 'driver');
|
|
140
161
|
const details = await getWorkerDetails(name, driver);
|
|
162
|
+
|
|
163
|
+
// Password masking is already applied in buildWorkerConfiguration
|
|
141
164
|
res.json(details);
|
|
142
165
|
} catch (error) {
|
|
143
166
|
if (error instanceof Error && error.message.includes('not found')) {
|
|
@@ -239,6 +262,7 @@ const getWorkerJsonHandler = async (req: IRequest, res: IResponse): Promise<void
|
|
|
239
262
|
});
|
|
240
263
|
}
|
|
241
264
|
|
|
265
|
+
// Mask passwords in infrastructure data (already applied in buildWorkerConfiguration)
|
|
242
266
|
return res.json({
|
|
243
267
|
success: true,
|
|
244
268
|
data: worker,
|
|
@@ -279,9 +303,17 @@ const getWorkerDriverDataHandler = async (req: IRequest, res: IResponse): Promis
|
|
|
279
303
|
});
|
|
280
304
|
}
|
|
281
305
|
|
|
306
|
+
// Mask passwords in infrastructure data
|
|
307
|
+
const maskedData = {
|
|
308
|
+
...persistedData,
|
|
309
|
+
infrastructure: maskInfrastructurePasswords(
|
|
310
|
+
persistedData['infrastructure'] as Record<string, unknown> | null
|
|
311
|
+
),
|
|
312
|
+
};
|
|
313
|
+
|
|
282
314
|
return res.json({
|
|
283
315
|
success: true,
|
|
284
|
-
data:
|
|
316
|
+
data: maskedData,
|
|
285
317
|
});
|
|
286
318
|
} catch (error) {
|
|
287
319
|
Logger.error('Failed to get worker driver data', error);
|
|
@@ -337,6 +369,7 @@ const updateWorkerJsonHandler = async (req: IRequest, res: IResponse): Promise<v
|
|
|
337
369
|
// In a real implementation, this would update the worker in the database
|
|
338
370
|
const updatedWorker = { ...existingWorker, ...workerData };
|
|
339
371
|
|
|
372
|
+
// Password masking is already applied in buildWorkerConfiguration via getWorkerDetails
|
|
340
373
|
return res.json({
|
|
341
374
|
success: true,
|
|
342
375
|
data: updatedWorker,
|
|
@@ -4,14 +4,11 @@
|
|
|
4
4
|
* HTTP handlers for worker management API
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
type IRequest,
|
|
13
|
-
type IResponse,
|
|
14
|
-
} from '@zintrust/core';
|
|
7
|
+
import { Cloudflare } from '@zintrust/core/cloudflare';
|
|
8
|
+
import { Env } from '@zintrust/core/config';
|
|
9
|
+
import type { IRequest, IResponse } from '@zintrust/core/http';
|
|
10
|
+
import { getValidatedBody } from '@zintrust/core/http';
|
|
11
|
+
import { Logger } from '@zintrust/core/logger';
|
|
15
12
|
import type { Job } from 'bullmq';
|
|
16
13
|
import { CanaryController } from '../CanaryController';
|
|
17
14
|
import { HealthMonitor } from '../HealthMonitor';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Logger
|
|
1
|
+
import { Logger } from '@zintrust/core/logger';
|
|
2
|
+
import { NodeSingletons, workersConfig } from '@zintrust/core/workers';
|
|
2
3
|
import { HealthMonitor } from '../HealthMonitor';
|
|
3
4
|
import { getWorkers } from '../dashboard/workers-api';
|
|
4
5
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IRequest, IResponse } from '@zintrust/core/http';
|
|
2
|
+
import { Logger } from '@zintrust/core/logger';
|
|
2
3
|
|
|
3
4
|
export type RouteHandler = (req: IRequest, res: IResponse) => Promise<void> | void;
|
|
4
5
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IRequest, IResponse } from '@zintrust/core/http';
|
|
2
|
+
import { Logger } from '@zintrust/core/logger';
|
|
2
3
|
|
|
3
4
|
export type RouteHandler = (req: IRequest, res: IResponse) => Promise<void> | void;
|
|
4
5
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IRequest, IResponse } from '@zintrust/core/http';
|
|
2
|
+
import { Logger } from '@zintrust/core/logger';
|
|
2
3
|
|
|
3
4
|
export type RouteHandler = (req: IRequest, res: IResponse) => Promise<void> | void;
|
|
4
5
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IRequest, IResponse } from '@zintrust/core/http';
|
|
2
|
+
import { Logger } from '@zintrust/core/logger';
|
|
2
3
|
|
|
3
4
|
export type RouteHandler = (req: IRequest, res: IResponse) => Promise<void> | void;
|
|
4
5
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IRequest, IResponse } from '@zintrust/core/http';
|
|
2
|
+
import { Logger } from '@zintrust/core/logger';
|
|
2
3
|
|
|
3
4
|
export type RouteHandler = (req: IRequest, res: IResponse) => Promise<void> | void;
|
|
4
5
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IRequest, IResponse } from '@zintrust/core/http';
|
|
2
|
+
import { Logger } from '@zintrust/core/logger';
|
|
2
3
|
|
|
3
4
|
export type RouteHandler = (req: IRequest, res: IResponse) => Promise<void> | void;
|
|
4
5
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IRequest, IResponse } from '@zintrust/core/http';
|
|
2
|
+
import { Logger } from '@zintrust/core/logger';
|
|
2
3
|
|
|
3
4
|
export type RouteHandler = (req: IRequest, res: IResponse) => Promise<void> | void;
|
|
4
5
|
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
workersConfig,
|
|
5
|
-
type IRequest,
|
|
6
|
-
type IResponse,
|
|
7
|
-
} from '@zintrust/core';
|
|
1
|
+
import type { IRequest, IResponse } from '@zintrust/core/http';
|
|
2
|
+
import { Logger } from '@zintrust/core/logger';
|
|
3
|
+
import { NodeSingletons, workersConfig } from '@zintrust/core/workers';
|
|
8
4
|
|
|
9
5
|
export type RouteHandler = (req: IRequest, res: IResponse) => Promise<void> | void;
|
|
10
6
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IRequest, IResponse } from '@zintrust/core/http';
|
|
2
|
+
import { Logger } from '@zintrust/core/logger';
|
|
2
3
|
|
|
3
4
|
export type RouteHandler = (req: IRequest, res: IResponse) => Promise<void> | void;
|
|
4
5
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Ensures the 'driver' query parameter is valid if present.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { IRequest, IResponse } from '@zintrust/core';
|
|
6
|
+
import type { IRequest, IResponse } from '@zintrust/core/http';
|
|
7
7
|
|
|
8
8
|
export type RouteHandler = (req: IRequest, res: IResponse) => Promise<void> | void;
|
|
9
9
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IRequest, IResponse } from '@zintrust/core/http';
|
|
2
|
+
import { Logger } from '@zintrust/core/logger';
|
|
2
3
|
|
|
3
4
|
export type RouteHandler = (req: IRequest, res: IResponse) => Promise<void> | void;
|
|
4
5
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IRequest, IResponse } from '@zintrust/core/http';
|
|
2
|
+
import { Logger } from '@zintrust/core/logger';
|
|
2
3
|
|
|
3
4
|
export type RouteHandler = (req: IRequest, res: IResponse) => Promise<void> | void;
|
|
4
5
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IRequest, IResponse } from '@zintrust/core/http';
|
|
2
|
+
import { Logger } from '@zintrust/core/logger';
|
|
2
3
|
|
|
3
4
|
export type RouteHandler = (req: IRequest, res: IResponse) => Promise<void> | void;
|
|
4
5
|
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { queueConfig } from '@zintrust/core/config';
|
|
2
|
+
import { Logger } from '@zintrust/core/logger';
|
|
3
|
+
import { isNonEmptyString, isObject } from '@zintrust/core/utils';
|
|
2
4
|
|
|
3
5
|
type QueueMonitorStatus = 'completed' | 'failed';
|
|
4
6
|
|
package/src/routes/workers.ts
CHANGED
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
* HTTP API for managing workers with dashboard functionality
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
6
|
+
import { Cloudflare } from '@zintrust/core/cloudflare';
|
|
7
|
+
import { Env } from '@zintrust/core/config';
|
|
8
|
+
import type { IRequest, IResponse, IRouter } from '@zintrust/core/http';
|
|
9
|
+
import { Router } from '@zintrust/core/http';
|
|
10
|
+
import { Logger } from '@zintrust/core/logger';
|
|
8
11
|
import { type WorkersDashboardUiOptions } from '../dashboard';
|
|
9
12
|
import { HealthMonitor } from '../HealthMonitor';
|
|
10
13
|
import { ValidationSchemas, withCustomValidation } from '../http/middleware/CustomValidation';
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Persistence layer for workers (memory, redis, db)
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type
|
|
7
|
-
import { type
|
|
6
|
+
import { type IDatabase } from '@zintrust/core/database';
|
|
7
|
+
import { type createRedisConnection } from '@zintrust/core/redis';
|
|
8
8
|
|
|
9
9
|
type RedisConnection = ReturnType<typeof createRedisConnection>;
|
|
10
10
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { IResponse } from '@zintrust/core';
|
|
2
|
-
import { Logger
|
|
1
|
+
import type { IResponse } from '@zintrust/core/http';
|
|
2
|
+
import { Logger } from '@zintrust/core/logger';
|
|
3
|
+
import { NodeSingletons } from '@zintrust/core/workers';
|
|
3
4
|
import type { createSnapshotBuilder, TelemetrySettings } from './TelemetryAPI';
|
|
4
5
|
|
|
5
6
|
export type TelemetrySnapshotData = {
|
package/src/telemetry/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { Env } from '@zintrust/core/config';
|
|
2
|
+
import type { IRequest, IResponse, IRouter, RouteOptions } from '@zintrust/core/http';
|
|
3
|
+
import { Router } from '@zintrust/core/http';
|
|
3
4
|
import type { TelemetrySettings } from './api/TelemetryAPI';
|
|
4
5
|
import { createSnapshotBuilder } from './api/TelemetryAPI';
|
|
5
6
|
import { teleStream } from './api/TelemetryMonitoringService';
|