@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.
Files changed (129) hide show
  1. package/dist/AnomalyDetection.js +3 -1
  2. package/dist/AutoScaler.js +3 -1
  3. package/dist/BroadcastWorker.js +2 -1
  4. package/dist/CanaryController.js +2 -1
  5. package/dist/ChaosEngineering.js +3 -1
  6. package/dist/CircuitBreaker.js +1 -1
  7. package/dist/ClusterLock.d.ts +1 -1
  8. package/dist/ClusterLock.js +5 -1
  9. package/dist/ComplianceManager.d.ts +1 -1
  10. package/dist/ComplianceManager.js +4 -1
  11. package/dist/DatacenterOrchestrator.js +2 -1
  12. package/dist/DeadLetterQueue.d.ts +1 -1
  13. package/dist/DeadLetterQueue.js +3 -1
  14. package/dist/HealthMonitor.js +2 -1
  15. package/dist/MultiQueueWorker.js +3 -1
  16. package/dist/NotificationWorker.js +1 -1
  17. package/dist/Observability.js +3 -1
  18. package/dist/PluginManager.js +2 -1
  19. package/dist/PriorityQueue.d.ts +1 -1
  20. package/dist/PriorityQueue.js +2 -1
  21. package/dist/ResourceMonitor.js +3 -1
  22. package/dist/SLAMonitor.js +3 -1
  23. package/dist/WorkerFactory.d.ts +2 -2
  24. package/dist/WorkerFactory.js +8 -2
  25. package/dist/WorkerInit.js +3 -1
  26. package/dist/WorkerMetrics.d.ts +1 -1
  27. package/dist/WorkerMetrics.js +3 -1
  28. package/dist/WorkerRegistry.d.ts +1 -1
  29. package/dist/WorkerRegistry.js +2 -1
  30. package/dist/WorkerShutdown.js +1 -1
  31. package/dist/WorkerVersioning.js +2 -1
  32. package/dist/config/workerConfig.js +1 -1
  33. package/dist/createQueueWorker.js +11 -44
  34. package/dist/dashboard/workers-api.js +7 -3
  35. package/dist/helper/index.d.ts +6 -1
  36. package/dist/helper/index.js +51 -0
  37. package/dist/http/WorkerApiController.d.ts +1 -1
  38. package/dist/http/WorkerApiController.js +29 -4
  39. package/dist/http/WorkerController.d.ts +1 -1
  40. package/dist/http/WorkerController.js +4 -1
  41. package/dist/http/WorkerMonitoringService.js +2 -1
  42. package/dist/http/middleware/CustomValidation.d.ts +1 -1
  43. package/dist/http/middleware/CustomValidation.js +1 -1
  44. package/dist/http/middleware/DatacenterValidator.d.ts +1 -1
  45. package/dist/http/middleware/DatacenterValidator.js +1 -1
  46. package/dist/http/middleware/EditWorkerValidation.d.ts +1 -1
  47. package/dist/http/middleware/EditWorkerValidation.js +1 -1
  48. package/dist/http/middleware/FeaturesValidator.d.ts +1 -1
  49. package/dist/http/middleware/FeaturesValidator.js +1 -1
  50. package/dist/http/middleware/InfrastructureValidator.d.ts +1 -1
  51. package/dist/http/middleware/InfrastructureValidator.js +1 -1
  52. package/dist/http/middleware/OptionsValidator.d.ts +1 -1
  53. package/dist/http/middleware/OptionsValidator.js +1 -1
  54. package/dist/http/middleware/PayloadSanitizer.d.ts +1 -1
  55. package/dist/http/middleware/PayloadSanitizer.js +1 -1
  56. package/dist/http/middleware/ProcessorPathSanitizer.d.ts +1 -1
  57. package/dist/http/middleware/ProcessorPathSanitizer.js +2 -1
  58. package/dist/http/middleware/QueueNameSanitizer.d.ts +1 -1
  59. package/dist/http/middleware/QueueNameSanitizer.js +1 -1
  60. package/dist/http/middleware/ValidateDriver.d.ts +1 -1
  61. package/dist/http/middleware/VersionSanitizer.d.ts +1 -1
  62. package/dist/http/middleware/VersionSanitizer.js +1 -1
  63. package/dist/http/middleware/WorkerNameSanitizer.d.ts +1 -1
  64. package/dist/http/middleware/WorkerNameSanitizer.js +1 -1
  65. package/dist/http/middleware/WorkerValidationChain.d.ts +1 -1
  66. package/dist/http/middleware/WorkerValidationChain.js +1 -1
  67. package/dist/queueMonitorHistory.js +3 -1
  68. package/dist/routes/workers.d.ts +1 -1
  69. package/dist/routes/workers.js +4 -1
  70. package/dist/storage/WorkerStore.d.ts +2 -2
  71. package/dist/telemetry/api/TelemetryAPI.js +1 -1
  72. package/dist/telemetry/api/TelemetryMonitoringService.d.ts +1 -1
  73. package/dist/telemetry/api/TelemetryMonitoringService.js +2 -1
  74. package/dist/telemetry/index.d.ts +1 -1
  75. package/dist/telemetry/index.js +2 -1
  76. package/dist/ui/router/ui.d.ts +1 -1
  77. package/dist/ui/router/ui.js +6 -1
  78. package/package.json +1 -1
  79. package/src/AnomalyDetection.ts +4 -2
  80. package/src/AutoScaler.ts +3 -2
  81. package/src/BroadcastWorker.ts +2 -1
  82. package/src/CanaryController.ts +2 -1
  83. package/src/ChaosEngineering.ts +3 -1
  84. package/src/CircuitBreaker.ts +1 -1
  85. package/src/ClusterLock.ts +5 -8
  86. package/src/ComplianceManager.ts +4 -7
  87. package/src/DatacenterOrchestrator.ts +2 -1
  88. package/src/DeadLetterQueue.ts +3 -1
  89. package/src/HealthMonitor.ts +2 -1
  90. package/src/MultiQueueWorker.ts +3 -1
  91. package/src/NotificationWorker.ts +1 -1
  92. package/src/Observability.ts +3 -1
  93. package/src/PluginManager.ts +2 -1
  94. package/src/PriorityQueue.ts +3 -1
  95. package/src/ResourceMonitor.ts +3 -1
  96. package/src/SLAMonitor.ts +3 -1
  97. package/src/WorkerFactory.ts +13 -19
  98. package/src/WorkerInit.ts +3 -1
  99. package/src/WorkerMetrics.ts +3 -7
  100. package/src/WorkerRegistry.ts +3 -1
  101. package/src/WorkerShutdown.ts +1 -1
  102. package/src/WorkerVersioning.ts +2 -1
  103. package/src/config/workerConfig.ts +1 -1
  104. package/src/createQueueWorker.ts +12 -45
  105. package/src/dashboard/workers-api.ts +7 -3
  106. package/src/helper/index.ts +61 -1
  107. package/src/http/WorkerApiController.ts +38 -5
  108. package/src/http/WorkerController.ts +5 -8
  109. package/src/http/WorkerMonitoringService.ts +2 -1
  110. package/src/http/middleware/CustomValidation.ts +2 -1
  111. package/src/http/middleware/DatacenterValidator.ts +2 -1
  112. package/src/http/middleware/EditWorkerValidation.ts +2 -1
  113. package/src/http/middleware/FeaturesValidator.ts +2 -1
  114. package/src/http/middleware/InfrastructureValidator.ts +2 -1
  115. package/src/http/middleware/OptionsValidator.ts +2 -1
  116. package/src/http/middleware/PayloadSanitizer.ts +2 -1
  117. package/src/http/middleware/ProcessorPathSanitizer.ts +3 -7
  118. package/src/http/middleware/QueueNameSanitizer.ts +2 -1
  119. package/src/http/middleware/ValidateDriver.ts +1 -1
  120. package/src/http/middleware/VersionSanitizer.ts +2 -1
  121. package/src/http/middleware/WorkerNameSanitizer.ts +2 -1
  122. package/src/http/middleware/WorkerValidationChain.ts +2 -1
  123. package/src/queueMonitorHistory.ts +3 -1
  124. package/src/routes/workers.ts +5 -2
  125. package/src/storage/WorkerStore.ts +2 -2
  126. package/src/telemetry/api/TelemetryAPI.ts +1 -1
  127. package/src/telemetry/api/TelemetryMonitoringService.ts +3 -2
  128. package/src/telemetry/index.ts +3 -2
  129. package/src/ui/router/ui.ts +9 -11
@@ -3,7 +3,9 @@
3
3
  * Statistical anomaly detection with lightweight baselines
4
4
  * Sealed namespace for immutability
5
5
  */
6
- import { ErrorFactory, Logger, generateUuid } from '@zintrust/core';
6
+ import { ErrorFactory } from '@zintrust/core/errors';
7
+ import { Logger } from '@zintrust/core/logger';
8
+ import { generateUuid } from '@zintrust/core/utils';
7
9
  import { ResourceMonitor } from './ResourceMonitor.js';
8
10
  import { WorkerMetrics } from './WorkerMetrics.js';
9
11
  const configs = new Map();
@@ -3,7 +3,9 @@
3
3
  * Automatic worker scaling based on queue depth, resource usage, and cost optimization
4
4
  * Sealed namespace for immutability
5
5
  */
6
- import { ErrorFactory, Logger, workersConfig } from '@zintrust/core';
6
+ import { ErrorFactory } from '@zintrust/core/errors';
7
+ import { Logger } from '@zintrust/core/logger';
8
+ import { workersConfig } from '@zintrust/core/workers';
7
9
  // Internal state
8
10
  let config = null;
9
11
  let scalingInterval = null;
@@ -4,7 +4,8 @@
4
4
  * This worker dequeues broadcast messages and sends them using the Broadcast service.
5
5
  * Use with Queue.dequeue() in a background process or cron job.
6
6
  */
7
- import { Broadcast, isArray, isNonEmptyString, Logger } from '@zintrust/core';
7
+ import { Logger } from '@zintrust/core/logger';
8
+ import { Broadcast, isArray, isNonEmptyString } from '@zintrust/core/utils';
8
9
  import { createQueueWorker } from './createQueueWorker.js';
9
10
  const resolveQueuedBroadcastChannels = (payload) => {
10
11
  if (isArray(payload.channels)) {
@@ -3,7 +3,8 @@
3
3
  * Gradual rollout with traffic percentage control and automatic rollback
4
4
  * Sealed namespace for immutability
5
5
  */
6
- import { ErrorFactory, Logger } from '@zintrust/core';
6
+ import { ErrorFactory } from '@zintrust/core/errors';
7
+ import { Logger } from '@zintrust/core/logger';
7
8
  import { CircuitBreaker } from './CircuitBreaker.js';
8
9
  // Internal state
9
10
  const canaryDeployments = new Map();
@@ -3,7 +3,9 @@
3
3
  * Controlled fault injection experiments for worker resilience testing
4
4
  * Sealed namespace for immutability
5
5
  */
6
- import { ErrorFactory, Logger, generateUuid } from '@zintrust/core';
6
+ import { ErrorFactory } from '@zintrust/core/errors';
7
+ import { Logger } from '@zintrust/core/logger';
8
+ import { generateUuid } from '@zintrust/core/utils';
7
9
  import { CircuitBreaker } from './CircuitBreaker.js';
8
10
  import { Observability } from './Observability.js';
9
11
  import { ResourceMonitor } from './ResourceMonitor.js';
@@ -3,7 +3,7 @@
3
3
  * Fault tolerance with version tracking and automatic recovery
4
4
  * Sealed namespace for immutability
5
5
  */
6
- import { Logger } from '@zintrust/core';
6
+ import { Logger } from '@zintrust/core/logger';
7
7
  // Internal state
8
8
  const circuits = new Map();
9
9
  const eventHistory = new Map();
@@ -3,7 +3,7 @@
3
3
  * Distributed locking using Redis for multi-instance worker coordination
4
4
  * Sealed namespace for immutability
5
5
  */
6
- import { type RedisConfig } from '@zintrust/core';
6
+ import { type RedisConfig } from '@zintrust/core/redis';
7
7
  export type LockAcquisitionOptions = {
8
8
  lockKey: string;
9
9
  ttl: number;
@@ -3,7 +3,11 @@
3
3
  * Distributed locking using Redis for multi-instance worker coordination
4
4
  * Sealed namespace for immutability
5
5
  */
6
- import { Cloudflare, ErrorFactory, Logger, createRedisConnection, generateUuid, } from '@zintrust/core';
6
+ import { Cloudflare } from '@zintrust/core/cloudflare';
7
+ import { ErrorFactory } from '@zintrust/core/errors';
8
+ import { Logger } from '@zintrust/core/logger';
9
+ import { createRedisConnection } from '@zintrust/core/redis';
10
+ import { generateUuid } from '@zintrust/core/utils';
7
11
  let INSTANCE_ID = '';
8
12
  const createInstanceId = () => {
9
13
  const workers = Cloudflare.getWorkersEnv() !== null;
@@ -3,7 +3,7 @@
3
3
  * GDPR, HIPAA, and SOC2 compliance enforcement
4
4
  * Sealed namespace for immutability
5
5
  */
6
- import { type RedisConfig } from '@zintrust/core';
6
+ import { type RedisConfig } from '@zintrust/core/redis';
7
7
  export type ComplianceStandard = 'gdpr' | 'hipaa' | 'soc2';
8
8
  export type DataClassification = 'public' | 'internal' | 'confidential' | 'restricted';
9
9
  export type ComplianceConfig = {
@@ -3,7 +3,10 @@
3
3
  * GDPR, HIPAA, and SOC2 compliance enforcement
4
4
  * Sealed namespace for immutability
5
5
  */
6
- import { ErrorFactory, Logger, NodeSingletons, createRedisConnection, } from '@zintrust/core';
6
+ import { ErrorFactory } from '@zintrust/core/errors';
7
+ import { Logger } from '@zintrust/core/logger';
8
+ import { createRedisConnection } from '@zintrust/core/redis';
9
+ import { NodeSingletons } from '@zintrust/core/workers';
7
10
  // Access NodeSingletons lazily to avoid initialization errors in test environments
8
11
  const getCrypto = () => {
9
12
  if (!NodeSingletons) {
@@ -3,7 +3,8 @@
3
3
  * Multi-datacenter worker coordination with region affinity and failover
4
4
  * Sealed namespace for immutability
5
5
  */
6
- import { ErrorFactory, Logger } from '@zintrust/core';
6
+ import { ErrorFactory } from '@zintrust/core/errors';
7
+ import { Logger } from '@zintrust/core/logger';
7
8
  import { ClusterLock } from './ClusterLock.js';
8
9
  // Internal state
9
10
  const regions = new Map();
@@ -3,7 +3,7 @@
3
3
  * Failed job handling with compliance tracking (GDPR/HIPAA/SOC2)
4
4
  * Sealed namespace for immutability
5
5
  */
6
- import { type RedisConfig } from '@zintrust/core';
6
+ import { type RedisConfig } from '@zintrust/core/redis';
7
7
  export type FailedJobEntry = {
8
8
  id: string;
9
9
  queueName: string;
@@ -3,7 +3,9 @@
3
3
  * Failed job handling with compliance tracking (GDPR/HIPAA/SOC2)
4
4
  * Sealed namespace for immutability
5
5
  */
6
- import { ErrorFactory, Logger, createRedisConnection } from '@zintrust/core';
6
+ import { ErrorFactory } from '@zintrust/core/errors';
7
+ import { Logger } from '@zintrust/core/logger';
8
+ import { createRedisConnection } from '@zintrust/core/redis';
7
9
  import { keyPrefixFor } from './config/workerConfig.js';
8
10
  // Redis key prefixes - using workers package prefix system
9
11
  const getDLQPrefix = () => {
@@ -1,4 +1,5 @@
1
- import { ErrorFactory, Logger } from '@zintrust/core';
1
+ import { ErrorFactory } from '@zintrust/core/errors';
2
+ import { Logger } from '@zintrust/core/logger';
2
3
  import { WorkerCreationStatus, WorkerFactory } from './WorkerFactory.js';
3
4
  const DEFAULT_CONFIG = {
4
5
  enabled: true,
@@ -3,7 +3,9 @@
3
3
  * Enable workers to process multiple queues with different priorities
4
4
  * Sealed namespace for immutability
5
5
  */
6
- import { ErrorFactory, Logger, ShutdownTrace } from '@zintrust/core';
6
+ import { ErrorFactory } from '@zintrust/core/errors';
7
+ import { Logger } from '@zintrust/core/logger';
8
+ import { ShutdownTrace } from '@zintrust/core/workers';
7
9
  import { Worker } from 'bullmq';
8
10
  import { PriorityQueue } from './PriorityQueue.js';
9
11
  // Internal state
@@ -4,7 +4,7 @@
4
4
  * This worker dequeues notification messages and sends them using the Notification service.
5
5
  * Use with Queue.dequeue() in a background process or cron job.
6
6
  */
7
- import { Notification } from '@zintrust/core';
7
+ import { Notification } from '@zintrust/core/mail';
8
8
  import { createQueueWorker } from './createQueueWorker.js';
9
9
  export const NotificationWorker = Object.freeze({
10
10
  ...createQueueWorker({
@@ -3,7 +3,9 @@
3
3
  * Integrations for Prometheus, OpenTelemetry, and Datadog
4
4
  * Sealed namespace for immutability
5
5
  */
6
- import { ErrorFactory, Logger, generateUuid } from '@zintrust/core';
6
+ import { ErrorFactory } from '@zintrust/core/errors';
7
+ import { Logger } from '@zintrust/core/logger';
8
+ import { generateUuid } from '@zintrust/core/utils';
7
9
  // Internal state
8
10
  let config = null;
9
11
  // Prometheus state
@@ -3,7 +3,8 @@
3
3
  * Extensible plugin system with lifecycle hooks
4
4
  * Sealed namespace for immutability
5
5
  */
6
- import { ErrorFactory, Logger } from '@zintrust/core';
6
+ import { ErrorFactory } from '@zintrust/core/errors';
7
+ import { Logger } from '@zintrust/core/logger';
7
8
  // Internal state
8
9
  const plugins = new Map();
9
10
  const hookExecutionHistory = [];
@@ -3,7 +3,7 @@
3
3
  * BullMQ priority levels with datacenter affinity
4
4
  * Sealed namespace for immutability
5
5
  */
6
- import { type RedisConfig } from '@zintrust/core';
6
+ import type { RedisConfig } from '@zintrust/core/redis';
7
7
  import type { Queue } from 'bullmq';
8
8
  export type PriorityLevel = 'critical' | 'high' | 'normal' | 'low';
9
9
  export type JobPriority = {
@@ -3,7 +3,8 @@
3
3
  * BullMQ priority levels with datacenter affinity
4
4
  * Sealed namespace for immutability
5
5
  */
6
- import { ErrorFactory, Logger } from '@zintrust/core';
6
+ import { ErrorFactory } from '@zintrust/core/errors';
7
+ import { Logger } from '@zintrust/core/logger';
7
8
  // Priority mappings
8
9
  const PRIORITY_VALUES = {
9
10
  critical: 10,
@@ -3,7 +3,9 @@
3
3
  * Real-time resource tracking with cost calculation
4
4
  * Sealed namespace for immutability
5
5
  */
6
- import { Env, Logger, NodeSingletons } from '@zintrust/core';
6
+ import { Env } from '@zintrust/core/config';
7
+ import { Logger } from '@zintrust/core/logger';
8
+ import { NodeSingletons } from '@zintrust/core/workers';
7
9
  const getOsModule = () => NodeSingletons?.os ?? null;
8
10
  const safeTotalMemory = () => {
9
11
  const os = getOsModule();
@@ -3,7 +3,9 @@
3
3
  * SLA compliance checks and violation tracking for workers
4
4
  * Sealed namespace for immutability
5
5
  */
6
- import { ErrorFactory, Logger, generateUuid } from '@zintrust/core';
6
+ import { ErrorFactory } from '@zintrust/core/errors';
7
+ import { Logger } from '@zintrust/core/logger';
8
+ import { generateUuid } from '@zintrust/core/utils';
7
9
  import { HealthMonitor } from './HealthMonitor.js';
8
10
  import { WorkerMetrics } from './WorkerMetrics.js';
9
11
  const slaConfigs = new Map();
@@ -3,8 +3,8 @@
3
3
  * Central factory for creating workers with all advanced features
4
4
  * Sealed namespace for immutability
5
5
  */
6
- import { type IDatabase } from '@zintrust/core';
7
- import { type RedisConfig } from '@zintrust/core/config';
6
+ import { type IDatabase } from '@zintrust/core/database';
7
+ import { type RedisConfig } from '@zintrust/core/redis';
8
8
  import { Worker, type Job, type WorkerOptions } from 'bullmq';
9
9
  import { type AutoScalerConfig } from './AutoScaler';
10
10
  import { type ComplianceConfig } from './ComplianceManager';
@@ -4,9 +4,15 @@
4
4
  * Sealed namespace for immutability
5
5
  */
6
6
  import * as ZintrustCoreModule from '@zintrust/core';
7
- import { Env, ErrorFactory, generateUuid, getBullMQSafeQueueName, isFunction, isNonEmptyString, isObject, JobStateTracker, Logger, NodeSingletons, useEnsureDbConnected, ZintrustLang, } from '@zintrust/core';
8
- import { Cloudflare, createRedisConnection, databaseConfig, queueConfig, workersConfig, } from '@zintrust/core/config';
7
+ import { Cloudflare, databaseConfig, Env, queueConfig, workersConfig } from '@zintrust/core/config';
8
+ import { useEnsureDbConnected } from '@zintrust/core/database';
9
+ import { ErrorFactory } from '@zintrust/core/errors';
10
+ import { Logger } from '@zintrust/core/logger';
9
11
  import { DatabaseConnectionRegistry, registerDatabasesFromRuntimeConfig } from '@zintrust/core/orm';
12
+ import { JobStateTracker } from '@zintrust/core/queue';
13
+ import { createRedisConnection, getBullMQSafeQueueName, } from '@zintrust/core/redis';
14
+ import { generateUuid, isFunction, isNonEmptyString, isObject, ZintrustLang, } from '@zintrust/core/utils';
15
+ import { NodeSingletons } from '@zintrust/core/workers';
10
16
  import { Worker } from 'bullmq';
11
17
  import { AutoScaler } from './AutoScaler.js';
12
18
  import { CanaryController } from './CanaryController.js';
@@ -7,7 +7,9 @@
7
7
  * - Sets up auto-scaling and health checks
8
8
  * - Ensures graceful startup and shutdown
9
9
  */
10
- import { Env, isObject, Logger } from '@zintrust/core';
10
+ import { Env } from '@zintrust/core/config';
11
+ import { Logger } from '@zintrust/core/logger';
12
+ import { isObject } from '@zintrust/core/utils';
11
13
  import { ResourceMonitor } from './ResourceMonitor.js';
12
14
  import { WorkerFactory } from './WorkerFactory.js';
13
15
  import { WorkerShutdown } from './WorkerShutdown.js';
@@ -3,7 +3,7 @@
3
3
  * Time-series metrics persistence with Redis Sorted Sets
4
4
  * Sealed namespace for immutability
5
5
  */
6
- import { type RedisConfig } from '@zintrust/core';
6
+ import { type RedisConfig } from '@zintrust/core/redis';
7
7
  export type MetricType = 'processed' | 'errors' | 'duration' | 'memory' | 'cpu' | 'queue-size' | 'active-jobs' | 'waiting-jobs' | 'delayed-jobs' | 'failed-jobs' | 'completed-jobs';
8
8
  export type MetricGranularity = 'hourly' | 'daily' | 'monthly';
9
9
  export type MetricPoint = {
@@ -3,7 +3,9 @@
3
3
  * Time-series metrics persistence with Redis Sorted Sets
4
4
  * Sealed namespace for immutability
5
5
  */
6
- import { ErrorFactory, Logger, RedisKeys, createRedisConnection, } from '@zintrust/core';
6
+ import { ErrorFactory } from '@zintrust/core/errors';
7
+ import { Logger } from '@zintrust/core/logger';
8
+ import { RedisKeys, createRedisConnection } from '@zintrust/core/redis';
7
9
  // Retention periods (in seconds)
8
10
  const RETENTION = {
9
11
  hourly: 7 * 24 * 60 * 60, // 7 days
@@ -3,7 +3,7 @@
3
3
  * Central registry for all background workers with lifecycle management
4
4
  * Sealed namespace for immutability
5
5
  */
6
- import { type WorkerConfig, type WorkerStatus } from '@zintrust/core';
6
+ import { type WorkerConfig, type WorkerStatus } from '@zintrust/core/workers';
7
7
  export type WorkerMetadata = {
8
8
  name: string;
9
9
  status: WorkerStatus;
@@ -3,7 +3,8 @@
3
3
  * Central registry for all background workers with lifecycle management
4
4
  * Sealed namespace for immutability
5
5
  */
6
- import { ErrorFactory, Logger } from '@zintrust/core';
6
+ import { ErrorFactory } from '@zintrust/core/errors';
7
+ import { Logger } from '@zintrust/core/logger';
7
8
  import { AnomalyDetection } from './AnomalyDetection.js';
8
9
  // Internal storage
9
10
  const workers = new Map();
@@ -4,7 +4,7 @@
4
4
  * Centralized graceful shutdown handling for the worker management system.
5
5
  * Coordinates orderly shutdown of all worker modules and the WorkerFactory.
6
6
  */
7
- import { Logger } from '@zintrust/core';
7
+ import { Logger } from '@zintrust/core/logger';
8
8
  import { WorkerFactory } from './WorkerFactory.js';
9
9
  // ============================================================================
10
10
  // Implementation
@@ -3,7 +3,8 @@
3
3
  * Semantic versioning support for workers with backward compatibility
4
4
  * Sealed namespace for immutability
5
5
  */
6
- import { ErrorFactory, Logger } from '@zintrust/core';
6
+ import { ErrorFactory } from '@zintrust/core/errors';
7
+ import { Logger } from '@zintrust/core/logger';
7
8
  // Internal state
8
9
  const workerVersions = new Map();
9
10
  const versionAliases = new Map(); // 'latest', 'stable', etc. -> version string
@@ -1,4 +1,4 @@
1
- import { Env, appConfig } from '@zintrust/core';
1
+ import { appConfig, Env } from '@zintrust/core/config';
2
2
  const normalizeBaseUrl = (value) => {
3
3
  let end = value.length;
4
4
  while (end > 0 && value.charAt(end - 1) === '/') {
@@ -1,41 +1,11 @@
1
- import * as Core from '@zintrust/core';
2
- import { Env, Logger, Queue } from '@zintrust/core';
1
+ import { Env } from '@zintrust/core/config';
2
+ import { Logger } from '@zintrust/core/logger';
3
+ import { JobHeartbeatStore, JobStateTracker, Queue, TimeoutManager } from '@zintrust/core/queue';
4
+ import { SystemTraceBridge } from '@zintrust/core/trace';
3
5
  import { recordQueueMonitorJob } from './queueMonitorHistory.js';
4
6
  const TypedQueue = Queue;
5
7
  const RETRY_BASE_DELAY_MS = 1000;
6
8
  const RETRY_MAX_DELAY_MS = 30000;
7
- const getJobStateTracker = () => {
8
- try {
9
- return Core['JobStateTracker'];
10
- }
11
- catch {
12
- return undefined;
13
- }
14
- };
15
- const getJobHeartbeatStore = () => {
16
- try {
17
- return Core['JobHeartbeatStore'];
18
- }
19
- catch {
20
- return undefined;
21
- }
22
- };
23
- const getTimeoutManager = () => {
24
- try {
25
- return Core['TimeoutManager'];
26
- }
27
- catch {
28
- return undefined;
29
- }
30
- };
31
- const getSystemTraceBridge = () => {
32
- try {
33
- return Core['SystemTraceBridge'];
34
- }
35
- catch {
36
- return undefined;
37
- }
38
- };
39
9
  const getEnvInt = (key, fallback) => {
40
10
  const getter = Env.getInt;
41
11
  if (typeof getter === 'function') {
@@ -52,24 +22,21 @@ const getEnvInt = (key, fallback) => {
52
22
  return fallback;
53
23
  };
54
24
  const resolveQueueJobTimeoutMs = () => {
55
- const timeoutManager = getTimeoutManager();
56
- const tm = (timeoutManager ?? {});
25
+ const tm = (TimeoutManager ?? {});
57
26
  if (typeof tm.getQueueJobTimeoutMs === 'function') {
58
27
  return tm.getQueueJobTimeoutMs();
59
28
  }
60
29
  return Math.max(1000, getEnvInt('QUEUE_JOB_TIMEOUT', 60) * 1000);
61
30
  };
62
31
  const runWithTimeout = async (operation, timeoutMs, operationName) => {
63
- const timeoutManager = getTimeoutManager();
64
- const tm = (timeoutManager ?? {});
32
+ const tm = (TimeoutManager ?? {});
65
33
  if (typeof tm.withTimeout === 'function') {
66
34
  return tm.withTimeout(operation, timeoutMs, operationName);
67
35
  }
68
36
  return operation();
69
37
  };
70
38
  const isTimeoutError = (error) => {
71
- const timeoutManager = getTimeoutManager();
72
- const tm = (timeoutManager ?? {});
39
+ const tm = (TimeoutManager ?? {});
73
40
  if (typeof tm.isTimeoutError === 'function') {
74
41
  return tm.isTimeoutError(error);
75
42
  }
@@ -114,17 +81,17 @@ const getWorkerInstanceId = () => {
114
81
  : undefined;
115
82
  };
116
83
  const getTrackerApi = () => {
117
- return (getJobStateTracker() ?? {});
84
+ return (JobStateTracker ?? {});
118
85
  };
119
86
  const getHeartbeatStoreApi = () => {
120
- return (getJobHeartbeatStore() ?? {});
87
+ return (JobHeartbeatStore ?? {});
121
88
  };
122
89
  const emitJobProcessed = (name) => {
123
- const bridge = (getSystemTraceBridge() ?? {});
90
+ const bridge = (SystemTraceBridge ?? {});
124
91
  bridge.emitJobProcessed?.(name);
125
92
  };
126
93
  const emitJobFailed = (name, error) => {
127
- const bridge = (getSystemTraceBridge() ?? {});
94
+ const bridge = (SystemTraceBridge ?? {});
128
95
  bridge.emitJobFailed?.(name, error);
129
96
  };
130
97
  const removeHeartbeatIfSupported = async (queueName, jobId) => {
@@ -1,7 +1,10 @@
1
- import { Env, ErrorFactory, Logger, queueConfig } from '@zintrust/core/runtime';
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.js';
3
5
  import { WorkerMetrics as WorkerMetricsManager } from '../WorkerMetrics.js';
4
6
  import { WorkerRegistry } from '../WorkerRegistry.js';
7
+ import { maskInfrastructurePasswords } from '../helper/index.js';
5
8
  const DEFAULT_PAGE_SIZE = 100;
6
9
  const MAX_PAGE_SIZE = 200;
7
10
  // Helper for timeout handling
@@ -464,7 +467,8 @@ async function getRedisQueueData() {
464
467
  try {
465
468
  // Use existing queue monitor infrastructure
466
469
  const { QueueMonitor } = await import('@zintrust/queue-monitor');
467
- const redisConfig = queueConfig.drivers.redis;
470
+ const { queueConfig: FreshQeueConfig } = await import('@zintrust/core/config');
471
+ const redisConfig = FreshQeueConfig.drivers.redis;
468
472
  if (redisConfig?.driver !== 'redis') {
469
473
  throw ErrorFactory.createConfigError('Redis driver not configured');
470
474
  }
@@ -704,7 +708,7 @@ function buildWorkerConfiguration(worker, persisted) {
704
708
  activeStatus: persisted.activeStatus ?? true,
705
709
  version: persisted.version ?? worker.version,
706
710
  features: persisted.features ?? null,
707
- infrastructure: persisted.infrastructure ?? null,
711
+ infrastructure: maskInfrastructurePasswords(persisted.infrastructure),
708
712
  datacenter: persisted.datacenter ?? null,
709
713
  };
710
714
  }
@@ -1,5 +1,10 @@
1
- import type { IRequest } from '@zintrust/core';
1
+ import type { IRequest } from '@zintrust/core/http';
2
2
  /**
3
3
  * Helper to get path parameter
4
4
  */
5
5
  export declare const getParam: (req: IRequest, key: string) => string;
6
+ /**
7
+ * Mask sensitive password fields in infrastructure data
8
+ * This masks both Redis and database passwords to prevent them from being exposed in API responses
9
+ */
10
+ export declare const maskInfrastructurePasswords: (infrastructure: Record<string, unknown> | null | undefined) => Record<string, unknown> | null;
@@ -8,3 +8,54 @@ export const getParam = (req, key) => {
8
8
  const params = req.params ?? {};
9
9
  return params[key] ?? '';
10
10
  };
11
+ /**
12
+ * Mask password in a record if present
13
+ */
14
+ const maskPassword = (obj) => {
15
+ if (typeof obj['password'] === 'string' && obj['password'].length > 0) {
16
+ obj['password'] = '******';
17
+ }
18
+ };
19
+ /**
20
+ * Mask passwords in a nested connection object
21
+ */
22
+ const maskConnectionPassword = (persistence) => {
23
+ if (typeof persistence['connection'] === 'object' && persistence['connection'] !== null) {
24
+ const connection = { ...persistence['connection'] };
25
+ maskPassword(connection);
26
+ persistence['connection'] = connection;
27
+ }
28
+ };
29
+ /**
30
+ * Mask Redis password in infrastructure data
31
+ */
32
+ const maskRedisPassword = (masked) => {
33
+ if (typeof masked['redis'] === 'object' && masked['redis'] !== null) {
34
+ const redis = { ...masked['redis'] };
35
+ maskPassword(redis);
36
+ masked['redis'] = redis;
37
+ }
38
+ };
39
+ /**
40
+ * Mask persistence password in infrastructure data
41
+ */
42
+ const maskPersistencePassword = (masked) => {
43
+ if (typeof masked['persistence'] === 'object' && masked['persistence'] !== null) {
44
+ const persistence = { ...masked['persistence'] };
45
+ maskPassword(persistence);
46
+ maskConnectionPassword(persistence);
47
+ masked['persistence'] = persistence;
48
+ }
49
+ };
50
+ /**
51
+ * Mask sensitive password fields in infrastructure data
52
+ * This masks both Redis and database passwords to prevent them from being exposed in API responses
53
+ */
54
+ export const maskInfrastructurePasswords = (infrastructure) => {
55
+ if (!infrastructure)
56
+ return null;
57
+ const masked = { ...infrastructure };
58
+ maskRedisPassword(masked);
59
+ maskPersistencePassword(masked);
60
+ return masked;
61
+ };
@@ -2,7 +2,7 @@
2
2
  * Worker API Controller
3
3
  * HTTP handlers for worker management API
4
4
  */
5
- import type { IRequest, IResponse } from '@zintrust/core';
5
+ import type { IRequest, IResponse } from '@zintrust/core/http';
6
6
  /**
7
7
  * GET /api/workers - List workers with pagination, filtering, and sorting
8
8
  */