@zintrust/workers 0.1.27

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 (178) hide show
  1. package/README.md +861 -0
  2. package/dist/AnomalyDetection.d.ts +102 -0
  3. package/dist/AnomalyDetection.js +321 -0
  4. package/dist/AutoScaler.d.ts +127 -0
  5. package/dist/AutoScaler.js +425 -0
  6. package/dist/BroadcastWorker.d.ts +21 -0
  7. package/dist/BroadcastWorker.js +24 -0
  8. package/dist/CanaryController.d.ts +103 -0
  9. package/dist/CanaryController.js +380 -0
  10. package/dist/ChaosEngineering.d.ts +79 -0
  11. package/dist/ChaosEngineering.js +216 -0
  12. package/dist/CircuitBreaker.d.ts +106 -0
  13. package/dist/CircuitBreaker.js +374 -0
  14. package/dist/ClusterLock.d.ts +90 -0
  15. package/dist/ClusterLock.js +385 -0
  16. package/dist/ComplianceManager.d.ts +177 -0
  17. package/dist/ComplianceManager.js +556 -0
  18. package/dist/DatacenterOrchestrator.d.ts +133 -0
  19. package/dist/DatacenterOrchestrator.js +404 -0
  20. package/dist/DeadLetterQueue.d.ts +122 -0
  21. package/dist/DeadLetterQueue.js +539 -0
  22. package/dist/HealthMonitor.d.ts +42 -0
  23. package/dist/HealthMonitor.js +301 -0
  24. package/dist/MultiQueueWorker.d.ts +89 -0
  25. package/dist/MultiQueueWorker.js +277 -0
  26. package/dist/NotificationWorker.d.ts +21 -0
  27. package/dist/NotificationWorker.js +23 -0
  28. package/dist/Observability.d.ts +153 -0
  29. package/dist/Observability.js +530 -0
  30. package/dist/PluginManager.d.ts +123 -0
  31. package/dist/PluginManager.js +392 -0
  32. package/dist/PriorityQueue.d.ts +117 -0
  33. package/dist/PriorityQueue.js +244 -0
  34. package/dist/ResourceMonitor.d.ts +164 -0
  35. package/dist/ResourceMonitor.js +605 -0
  36. package/dist/SLAMonitor.d.ts +110 -0
  37. package/dist/SLAMonitor.js +274 -0
  38. package/dist/WorkerFactory.d.ts +193 -0
  39. package/dist/WorkerFactory.js +1507 -0
  40. package/dist/WorkerInit.d.ts +85 -0
  41. package/dist/WorkerInit.js +223 -0
  42. package/dist/WorkerMetrics.d.ts +114 -0
  43. package/dist/WorkerMetrics.js +509 -0
  44. package/dist/WorkerRegistry.d.ts +145 -0
  45. package/dist/WorkerRegistry.js +319 -0
  46. package/dist/WorkerShutdown.d.ts +61 -0
  47. package/dist/WorkerShutdown.js +159 -0
  48. package/dist/WorkerVersioning.d.ts +107 -0
  49. package/dist/WorkerVersioning.js +300 -0
  50. package/dist/build-manifest.json +462 -0
  51. package/dist/config/workerConfig.d.ts +3 -0
  52. package/dist/config/workerConfig.js +19 -0
  53. package/dist/createQueueWorker.d.ts +23 -0
  54. package/dist/createQueueWorker.js +113 -0
  55. package/dist/dashboard/index.d.ts +1 -0
  56. package/dist/dashboard/index.js +1 -0
  57. package/dist/dashboard/types.d.ts +117 -0
  58. package/dist/dashboard/types.js +1 -0
  59. package/dist/dashboard/workers-api.d.ts +4 -0
  60. package/dist/dashboard/workers-api.js +638 -0
  61. package/dist/dashboard/workers-dashboard-ui.d.ts +3 -0
  62. package/dist/dashboard/workers-dashboard-ui.js +1026 -0
  63. package/dist/dashboard/workers-dashboard.d.ts +4 -0
  64. package/dist/dashboard/workers-dashboard.js +904 -0
  65. package/dist/helper/index.d.ts +5 -0
  66. package/dist/helper/index.js +10 -0
  67. package/dist/http/WorkerApiController.d.ts +38 -0
  68. package/dist/http/WorkerApiController.js +312 -0
  69. package/dist/http/WorkerController.d.ts +374 -0
  70. package/dist/http/WorkerController.js +1351 -0
  71. package/dist/http/middleware/CustomValidation.d.ts +92 -0
  72. package/dist/http/middleware/CustomValidation.js +270 -0
  73. package/dist/http/middleware/DatacenterValidator.d.ts +3 -0
  74. package/dist/http/middleware/DatacenterValidator.js +94 -0
  75. package/dist/http/middleware/EditWorkerValidation.d.ts +7 -0
  76. package/dist/http/middleware/EditWorkerValidation.js +55 -0
  77. package/dist/http/middleware/FeaturesValidator.d.ts +3 -0
  78. package/dist/http/middleware/FeaturesValidator.js +60 -0
  79. package/dist/http/middleware/InfrastructureValidator.d.ts +31 -0
  80. package/dist/http/middleware/InfrastructureValidator.js +226 -0
  81. package/dist/http/middleware/OptionsValidator.d.ts +3 -0
  82. package/dist/http/middleware/OptionsValidator.js +112 -0
  83. package/dist/http/middleware/PayloadSanitizer.d.ts +7 -0
  84. package/dist/http/middleware/PayloadSanitizer.js +42 -0
  85. package/dist/http/middleware/ProcessorPathSanitizer.d.ts +3 -0
  86. package/dist/http/middleware/ProcessorPathSanitizer.js +74 -0
  87. package/dist/http/middleware/QueueNameSanitizer.d.ts +3 -0
  88. package/dist/http/middleware/QueueNameSanitizer.js +45 -0
  89. package/dist/http/middleware/ValidateDriver.d.ts +7 -0
  90. package/dist/http/middleware/ValidateDriver.js +20 -0
  91. package/dist/http/middleware/VersionSanitizer.d.ts +3 -0
  92. package/dist/http/middleware/VersionSanitizer.js +25 -0
  93. package/dist/http/middleware/WorkerNameSanitizer.d.ts +3 -0
  94. package/dist/http/middleware/WorkerNameSanitizer.js +46 -0
  95. package/dist/http/middleware/WorkerValidationChain.d.ts +27 -0
  96. package/dist/http/middleware/WorkerValidationChain.js +185 -0
  97. package/dist/index.d.ts +46 -0
  98. package/dist/index.js +48 -0
  99. package/dist/routes/workers.d.ts +12 -0
  100. package/dist/routes/workers.js +81 -0
  101. package/dist/storage/WorkerStore.d.ts +45 -0
  102. package/dist/storage/WorkerStore.js +195 -0
  103. package/dist/type.d.ts +76 -0
  104. package/dist/type.js +1 -0
  105. package/dist/ui/router/ui.d.ts +3 -0
  106. package/dist/ui/router/ui.js +83 -0
  107. package/dist/ui/types/worker-ui.d.ts +229 -0
  108. package/dist/ui/types/worker-ui.js +5 -0
  109. package/package.json +53 -0
  110. package/src/AnomalyDetection.ts +434 -0
  111. package/src/AutoScaler.ts +654 -0
  112. package/src/BroadcastWorker.ts +34 -0
  113. package/src/CanaryController.ts +531 -0
  114. package/src/ChaosEngineering.ts +301 -0
  115. package/src/CircuitBreaker.ts +495 -0
  116. package/src/ClusterLock.ts +499 -0
  117. package/src/ComplianceManager.ts +815 -0
  118. package/src/DatacenterOrchestrator.ts +561 -0
  119. package/src/DeadLetterQueue.ts +733 -0
  120. package/src/HealthMonitor.ts +390 -0
  121. package/src/MultiQueueWorker.ts +431 -0
  122. package/src/NotificationWorker.ts +33 -0
  123. package/src/Observability.ts +696 -0
  124. package/src/PluginManager.ts +551 -0
  125. package/src/PriorityQueue.ts +351 -0
  126. package/src/ResourceMonitor.ts +769 -0
  127. package/src/SLAMonitor.ts +408 -0
  128. package/src/WorkerFactory.ts +2108 -0
  129. package/src/WorkerInit.ts +313 -0
  130. package/src/WorkerMetrics.ts +709 -0
  131. package/src/WorkerRegistry.ts +443 -0
  132. package/src/WorkerShutdown.ts +210 -0
  133. package/src/WorkerVersioning.ts +422 -0
  134. package/src/config/workerConfig.ts +25 -0
  135. package/src/createQueueWorker.ts +174 -0
  136. package/src/dashboard/index.ts +6 -0
  137. package/src/dashboard/types.ts +141 -0
  138. package/src/dashboard/workers-api.ts +785 -0
  139. package/src/dashboard/zintrust.svg +30 -0
  140. package/src/helper/index.ts +11 -0
  141. package/src/http/WorkerApiController.ts +369 -0
  142. package/src/http/WorkerController.ts +1512 -0
  143. package/src/http/middleware/CustomValidation.ts +360 -0
  144. package/src/http/middleware/DatacenterValidator.ts +124 -0
  145. package/src/http/middleware/EditWorkerValidation.ts +74 -0
  146. package/src/http/middleware/FeaturesValidator.ts +82 -0
  147. package/src/http/middleware/InfrastructureValidator.ts +295 -0
  148. package/src/http/middleware/OptionsValidator.ts +144 -0
  149. package/src/http/middleware/PayloadSanitizer.ts +52 -0
  150. package/src/http/middleware/ProcessorPathSanitizer.ts +86 -0
  151. package/src/http/middleware/QueueNameSanitizer.ts +55 -0
  152. package/src/http/middleware/ValidateDriver.ts +29 -0
  153. package/src/http/middleware/VersionSanitizer.ts +30 -0
  154. package/src/http/middleware/WorkerNameSanitizer.ts +56 -0
  155. package/src/http/middleware/WorkerValidationChain.ts +230 -0
  156. package/src/index.ts +98 -0
  157. package/src/routes/workers.ts +154 -0
  158. package/src/storage/WorkerStore.ts +240 -0
  159. package/src/type.ts +89 -0
  160. package/src/types/queue-monitor.d.ts +38 -0
  161. package/src/types/queue-redis.d.ts +38 -0
  162. package/src/ui/README.md +13 -0
  163. package/src/ui/components/JsonEditor.js +670 -0
  164. package/src/ui/components/JsonViewer.js +387 -0
  165. package/src/ui/components/WorkerCard.js +178 -0
  166. package/src/ui/components/WorkerExpandPanel.js +257 -0
  167. package/src/ui/components/fetcher.js +42 -0
  168. package/src/ui/components/sla-scorecard.js +32 -0
  169. package/src/ui/components/styles.css +30 -0
  170. package/src/ui/components/table-expander.js +34 -0
  171. package/src/ui/integration/worker-ui-integration.js +565 -0
  172. package/src/ui/router/ui.ts +99 -0
  173. package/src/ui/services/workerApi.js +240 -0
  174. package/src/ui/types/worker-ui.ts +283 -0
  175. package/src/ui/utils/jsonValidator.js +444 -0
  176. package/src/ui/workers/index.html +202 -0
  177. package/src/ui/workers/main.js +1781 -0
  178. package/src/ui/workers/styles.css +1350 -0
@@ -0,0 +1,240 @@
1
+ /**
2
+ * Worker Store
3
+ * Persistence layer for workers (memory, redis, db)
4
+ */
5
+
6
+ import type { IDatabase } from '@zintrust/core';
7
+ import type { Redis } from 'ioredis';
8
+
9
+ export type WorkerRecord = {
10
+ name: string;
11
+ queueName: string;
12
+ version: string | null;
13
+ status: string;
14
+ autoStart: boolean;
15
+ concurrency: number;
16
+ region: string | null;
17
+ processorPath?: string | null;
18
+ features?: Record<string, unknown> | null;
19
+ infrastructure?: Record<string, unknown> | null;
20
+ datacenter?: Record<string, unknown> | null;
21
+ createdAt: Date;
22
+ updatedAt: Date;
23
+ lastHealthCheck?: Date;
24
+ lastError?: string;
25
+ connectionState?: 'disconnected' | 'connecting' | 'connected' | 'error';
26
+ };
27
+
28
+ export type WorkerStore = {
29
+ init(): Promise<void>;
30
+ list(options?: { offset?: number; limit?: number; search?: string }): Promise<WorkerRecord[]>;
31
+ get(name: string): Promise<WorkerRecord | null>;
32
+ save(record: WorkerRecord): Promise<void>;
33
+ update(name: string, patch: Partial<WorkerRecord>): Promise<void>;
34
+ remove(name: string): Promise<void>;
35
+ };
36
+
37
+ const now = (): Date => new Date();
38
+
39
+ const mergeRecord = (current: WorkerRecord, patch: Partial<WorkerRecord>): WorkerRecord => ({
40
+ ...current,
41
+ ...patch,
42
+ updatedAt: patch.updatedAt ?? now(),
43
+ });
44
+
45
+ const serializeDbWorker = (record: WorkerRecord): Record<string, unknown> => ({
46
+ name: record.name,
47
+ queue_name: record.queueName,
48
+ version: record.version,
49
+ status: record.status,
50
+ auto_start: record.autoStart,
51
+ concurrency: record.concurrency,
52
+ region: record.region,
53
+ processor_path: record.processorPath ?? null,
54
+ features: record.features ? JSON.stringify(record.features) : null,
55
+ infrastructure: record.infrastructure ? JSON.stringify(record.infrastructure) : null,
56
+ datacenter: record.datacenter ? JSON.stringify(record.datacenter) : null,
57
+ created_at: record.createdAt,
58
+ updated_at: record.updatedAt,
59
+ last_health_check: record.lastHealthCheck ?? null,
60
+ last_error: record.lastError ?? null,
61
+ connection_state: record.connectionState ?? null,
62
+ });
63
+
64
+ const getHealthCheck = (row: Record<string, unknown>): Date | undefined => {
65
+ if (!row['last_health_check']) {
66
+ return undefined;
67
+ }
68
+ return row['last_health_check'] instanceof Date
69
+ ? row['last_health_check']
70
+ : new Date(String(row['last_health_check']));
71
+ };
72
+
73
+ const deserializeDbWorker = (row: Record<string, unknown>): WorkerRecord => {
74
+ const parseJson = (value: unknown): Record<string, unknown> | null => {
75
+ if (typeof value !== 'string' || value.trim() === '') return null;
76
+ try {
77
+ return JSON.parse(value) as Record<string, unknown>;
78
+ } catch {
79
+ return null;
80
+ }
81
+ };
82
+
83
+ return {
84
+ name: String(row['name'] ?? ''),
85
+ queueName: String(row['queue_name'] ?? ''),
86
+ version: row['version'] ? String(row['version']) : null,
87
+ status: String(row['status'] ?? 'unknown'),
88
+ autoStart: Boolean(row['auto_start'] ?? false),
89
+ concurrency: Number(row['concurrency'] ?? 0),
90
+ region: row['region'] ? String(row['region']) : null,
91
+ processorPath: row['processor_path'] ? String(row['processor_path']) : null,
92
+ features: parseJson(row['features']),
93
+ infrastructure: parseJson(row['infrastructure']),
94
+ datacenter: parseJson(row['datacenter']),
95
+ createdAt:
96
+ row['created_at'] instanceof Date ? row['created_at'] : new Date(String(row['created_at'])),
97
+ updatedAt:
98
+ row['updated_at'] instanceof Date ? row['updated_at'] : new Date(String(row['updated_at'])),
99
+ lastHealthCheck: getHealthCheck(row),
100
+ lastError: row['last_error'] ? String(row['last_error']) : undefined,
101
+ connectionState: row['connection_state']
102
+ ? (String(row['connection_state']) as 'disconnected' | 'connecting' | 'connected' | 'error')
103
+ : undefined,
104
+ };
105
+ };
106
+
107
+ export const InMemoryWorkerStore = Object.freeze({
108
+ create(): WorkerStore {
109
+ const store = new Map<string, WorkerRecord>();
110
+
111
+ return {
112
+ async init(): Promise<void> {
113
+ return undefined;
114
+ },
115
+ async list(options?: { offset?: number; limit?: number }): Promise<WorkerRecord[]> {
116
+ let values = Array.from(store.values());
117
+ if (options) {
118
+ const start = options.offset || 0;
119
+ const end = options.limit ? start + options.limit : undefined;
120
+ values = values.slice(start, end);
121
+ }
122
+ return values;
123
+ },
124
+ async get(name: string): Promise<WorkerRecord | null> {
125
+ return store.get(name) ?? null;
126
+ },
127
+ async save(record: WorkerRecord): Promise<void> {
128
+ store.set(record.name, record);
129
+ },
130
+ async update(name: string, patch: Partial<WorkerRecord>): Promise<void> {
131
+ const current = store.get(name);
132
+ if (!current) return;
133
+ store.set(name, mergeRecord(current, patch));
134
+ },
135
+ async remove(name: string): Promise<void> {
136
+ store.delete(name);
137
+ },
138
+ };
139
+ },
140
+ });
141
+
142
+ export const RedisWorkerStore = Object.freeze({
143
+ create(client: Redis, keyPrefix = 'workers:registry'): WorkerStore {
144
+ const key = keyPrefix;
145
+
146
+ const serialize = (record: WorkerRecord): string =>
147
+ JSON.stringify({
148
+ ...record,
149
+ createdAt: record.createdAt.toISOString(),
150
+ updatedAt: record.updatedAt.toISOString(),
151
+ });
152
+
153
+ const deserialize = (raw: string): WorkerRecord => {
154
+ const parsed = JSON.parse(raw) as Omit<WorkerRecord, 'createdAt' | 'updatedAt'> & {
155
+ createdAt: string;
156
+ updatedAt: string;
157
+ };
158
+ return {
159
+ ...parsed,
160
+ createdAt: new Date(parsed.createdAt),
161
+ updatedAt: new Date(parsed.updatedAt),
162
+ };
163
+ };
164
+
165
+ return {
166
+ async init(): Promise<void> {
167
+ return undefined;
168
+ },
169
+ async list(options?: { offset?: number; limit?: number }): Promise<WorkerRecord[]> {
170
+ const all = await client.hgetall(key);
171
+ let values = Object.values(all).map(deserialize);
172
+ values.sort((a, b) => a.name.localeCompare(b.name));
173
+ if (options) {
174
+ const start = options.offset || 0;
175
+ const end = options.limit ? start + options.limit : undefined;
176
+ values = values.slice(start, end);
177
+ }
178
+ return values;
179
+ },
180
+ async get(name: string): Promise<WorkerRecord | null> {
181
+ const raw = await client.hget(key, name);
182
+ return raw ? deserialize(raw) : null;
183
+ },
184
+ async save(record: WorkerRecord): Promise<void> {
185
+ await client.hset(key, record.name, serialize(record));
186
+ },
187
+ async update(name: string, patch: Partial<WorkerRecord>): Promise<void> {
188
+ const current = await this.get(name);
189
+ if (!current) return;
190
+ await client.hset(key, name, serialize(mergeRecord(current, patch)));
191
+ },
192
+ async remove(name: string): Promise<void> {
193
+ await client.hdel(key, name);
194
+ },
195
+ };
196
+ },
197
+ });
198
+
199
+ export const DbWorkerStore = Object.freeze({
200
+ create(db: IDatabase, table = 'zintrust_workers'): WorkerStore {
201
+ return {
202
+ async init(): Promise<void> {
203
+ return undefined;
204
+ },
205
+ async list(options?: { offset?: number; limit?: number }): Promise<WorkerRecord[]> {
206
+ const query = db.table(table);
207
+ if (options?.limit) query.limit(options.limit);
208
+ if (options?.offset) query.offset(options.offset);
209
+ const rows = await query.get<Record<string, unknown>>();
210
+ return rows.map(deserializeDbWorker);
211
+ },
212
+ async get(name: string): Promise<WorkerRecord | null> {
213
+ const row = await db.table(table).where('name', '=', name).first<Record<string, unknown>>();
214
+ return row ? deserializeDbWorker(row) : null;
215
+ },
216
+ async save(record: WorkerRecord): Promise<void> {
217
+ const existing = await db
218
+ .table(table)
219
+ .where('name', '=', record.name)
220
+ .first<Record<string, unknown>>();
221
+
222
+ if (existing) {
223
+ await db.table(table).where('name', '=', record.name).update(serializeDbWorker(record));
224
+ return;
225
+ }
226
+
227
+ await db.table(table).insert(serializeDbWorker(record));
228
+ },
229
+ async update(name: string, patch: Partial<WorkerRecord>): Promise<void> {
230
+ const current = await this.get(name);
231
+ if (!current) return;
232
+ const updated = mergeRecord(current, patch);
233
+ await db.table(table).where('name', '=', name).update(serializeDbWorker(updated));
234
+ },
235
+ async remove(name: string): Promise<void> {
236
+ await db.table(table).where('name', '=', name).delete();
237
+ },
238
+ };
239
+ },
240
+ });
package/src/type.ts ADDED
@@ -0,0 +1,89 @@
1
+ export interface WorkerType {
2
+ name: string;
3
+ queueName: string;
4
+ processor: string;
5
+ version: string;
6
+ options: Options;
7
+ infrastructure: Infrastructure;
8
+ features: Features;
9
+ datacenter: Datacenter;
10
+ }
11
+
12
+ export interface Options {
13
+ concurrency: number;
14
+ limiter: Limiter;
15
+ }
16
+
17
+ export interface Limiter {
18
+ max: number;
19
+ duration: number;
20
+ }
21
+
22
+ export interface Infrastructure {
23
+ persistence: Persistence;
24
+ redis: Redis;
25
+ deadLetterQueue: DeadLetterQueue;
26
+ compliance: Compliance;
27
+ observability: Observability;
28
+ autoScaler: AutoScaler;
29
+ }
30
+
31
+ export interface Persistence {
32
+ driver: string;
33
+ }
34
+
35
+ export interface Redis {
36
+ env: boolean;
37
+ host: string;
38
+ port: string;
39
+ db: string;
40
+ password: string;
41
+ }
42
+
43
+ export interface DeadLetterQueue {
44
+ policy: string;
45
+ }
46
+
47
+ export interface Compliance {
48
+ config: Config;
49
+ }
50
+
51
+ export interface Config {
52
+ retentionDays: number;
53
+ }
54
+
55
+ export interface Observability {
56
+ enabled: boolean;
57
+ }
58
+
59
+ export interface AutoScaler {
60
+ enabled: boolean;
61
+ minWorkers: number;
62
+ maxWorkers: number;
63
+ }
64
+
65
+ export interface Features {
66
+ clustering: boolean;
67
+ metrics: boolean;
68
+ autoScaling: boolean;
69
+ circuitBreaker: boolean;
70
+ deadLetterQueue: boolean;
71
+ resourceMonitoring: boolean;
72
+ compliance: boolean;
73
+ observability: boolean;
74
+ plugins: boolean;
75
+ versioning: boolean;
76
+ datacenterOrchestration: boolean;
77
+ }
78
+
79
+ export interface Datacenter {
80
+ primaryRegion: string;
81
+ secondaryRegions: string[];
82
+ affinityRules: AffinityRules;
83
+ }
84
+
85
+ export interface AffinityRules {
86
+ preferLocal: boolean;
87
+ maxLatency: number;
88
+ avoidRegions: string[];
89
+ }
@@ -0,0 +1,38 @@
1
+ declare module '@zintrust/queue-monitor' {
2
+ export type QueueCounts = {
3
+ waiting: number;
4
+ active: number;
5
+ completed: number;
6
+ failed: number;
7
+ delayed: number;
8
+ paused: number;
9
+ };
10
+
11
+ export type QueueMonitorSnapshot = {
12
+ status: 'ok';
13
+ startedAt: string;
14
+ queues: Array<{
15
+ name: string;
16
+ counts: QueueCounts;
17
+ }>;
18
+ };
19
+
20
+ export type QueueMonitorConfig = {
21
+ enabled?: boolean;
22
+ basePath?: string;
23
+ middleware?: ReadonlyArray<string>;
24
+ autoRefresh?: boolean;
25
+ refreshIntervalMs?: number;
26
+ redis: Record<string, unknown>;
27
+ };
28
+
29
+ export type QueueMonitorApi = {
30
+ getSnapshot: () => Promise<QueueMonitorSnapshot>;
31
+ };
32
+
33
+ export const QueueMonitor: Readonly<{
34
+ create: (config: QueueMonitorConfig) => QueueMonitorApi;
35
+ }>;
36
+
37
+ export default QueueMonitor;
38
+ }
@@ -0,0 +1,38 @@
1
+ declare module '@zintrust/queue-redis' {
2
+ export type QueueMessage<T = unknown> = {
3
+ id: string;
4
+ payload: T;
5
+ attempts: number;
6
+ };
7
+
8
+ export type RedisPublishClient = {
9
+ connect?: () => Promise<void>;
10
+ publish(channel: string, message: string): Promise<number>;
11
+ };
12
+
13
+ export const RedisQueue: {
14
+ enqueue: <T = unknown>(queue: string, payload: T) => Promise<string>;
15
+ dequeue: <T = unknown>(queue: string) => Promise<QueueMessage<T> | undefined>;
16
+ ack: (queue: string, id: string) => Promise<void>;
17
+ length: (queue: string) => Promise<number>;
18
+ drain: (queue: string) => Promise<void>;
19
+ };
20
+
21
+ export const BullMQRedisQueue: {
22
+ getQueue: (queueName: string) => unknown;
23
+ enqueue: <T = unknown>(queue: string, payload: T) => Promise<string>;
24
+ dequeue: <T = unknown>(queue: string) => Promise<QueueMessage<T> | undefined>;
25
+ ack: (queue: string, id: string) => Promise<void>;
26
+ length: (queue: string) => Promise<number>;
27
+ drain: (queue: string) => Promise<void>;
28
+ shutdown: () => Promise<void>;
29
+ closeQueue: (queueName: string) => Promise<void>;
30
+ getQueueNames: () => string[];
31
+ };
32
+
33
+ export const createRedisPublishClient: () => Promise<RedisPublishClient>;
34
+ export const resetPublishClient: () => void;
35
+
36
+ export const _ZINTRUST_QUEUE_REDIS_VERSION: string;
37
+ export const _ZINTRUST_QUEUE_REDIS_BUILD_DATE: string;
38
+ }
@@ -0,0 +1,13 @@
1
+ # @zintrust/ui
2
+
3
+ Vanilla-JS, framework-free UI components and static dashboard pages for ZinTrust.
4
+
5
+ Drop-in usage
6
+
7
+ - Serve files from `packages/ui/public/<page>/` or copy `packages/ui/src` to your static host.
8
+ - Include `styles.css` and `main.js` from the desired page and mount in any server-rendered HTML.
9
+
10
+ Contributing
11
+
12
+ - Implement shared components in `src/components/` and pages in `src/<page>/`.
13
+ - Keep components framework-agnostic and use ESM exports.