@zintrust/core 2.2.4 → 2.2.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/package.json +1 -1
- package/src/index.js +3 -3
- package/src/proxy/redis/RedisProxyActions.d.ts +3 -3
- package/src/proxy/redis/RedisProxyActions.d.ts.map +1 -1
- package/src/proxy/redis/RedisProxyActions.js +42 -18
- package/src/proxy/redis/RedisProxyServer.js +3 -3
- package/src/runtime/PluginAutoImports.d.ts.map +1 -1
- package/src/runtime/PluginAutoImports.js +52 -9
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @zintrust/core v2.2.
|
|
2
|
+
* @zintrust/core v2.2.5
|
|
3
3
|
*
|
|
4
4
|
* ZinTrust Framework - Production-Grade TypeScript Backend
|
|
5
5
|
* Built for performance, type safety, and exceptional developer experience
|
|
6
6
|
*
|
|
7
7
|
* Build Information:
|
|
8
|
-
* Built: 2026-05-28T17:
|
|
8
|
+
* Built: 2026-05-28T17:42:54.893Z
|
|
9
9
|
* Node: >=20.0.0
|
|
10
10
|
* License: MIT
|
|
11
11
|
*
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* Available at runtime for debugging and health checks
|
|
22
22
|
*/
|
|
23
23
|
export const ZINTRUST_VERSION = '0.1.41';
|
|
24
|
-
export const ZINTRUST_BUILD_DATE = '2026-05-28T17:
|
|
24
|
+
export const ZINTRUST_BUILD_DATE = '2026-05-28T17:42:54.858Z'; // Replaced during build
|
|
25
25
|
export { Application } from './boot/Application.js';
|
|
26
26
|
export { AwsSigV4 } from './common/index.js';
|
|
27
27
|
export { SignedRequest } from './security/SignedRequest.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { QueueDriver } from '@zintrust/queue-monitor/driver';
|
|
2
|
+
import type { Metrics } from '@zintrust/queue-monitor/metrics';
|
|
3
3
|
export type QueueMonitorContext = Readonly<{
|
|
4
4
|
driver: QueueDriver;
|
|
5
5
|
metrics: Metrics;
|
|
@@ -10,6 +10,6 @@ export type RedisProxyRedisConfig = Readonly<{
|
|
|
10
10
|
password: string;
|
|
11
11
|
db: number;
|
|
12
12
|
}>;
|
|
13
|
-
export declare const createQueueMonitorContext: (redis: RedisProxyRedisConfig) => QueueMonitorContext
|
|
13
|
+
export declare const createQueueMonitorContext: (redis: RedisProxyRedisConfig) => Promise<QueueMonitorContext>;
|
|
14
14
|
export declare const dispatchServiceCommand: (service: string, action: string, payload: Record<string, unknown>, queueMonitor: QueueMonitorContext) => Promise<unknown>;
|
|
15
15
|
//# sourceMappingURL=RedisProxyActions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RedisProxyActions.d.ts","sourceRoot":"","sources":["../../../../src/proxy/redis/RedisProxyActions.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"RedisProxyActions.d.ts","sourceRoot":"","sources":["../../../../src/proxy/redis/RedisProxyActions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAG/D,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC;IACzC,MAAM,EAAE,WAAW,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAAC;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC,CAAC;AA4BH,eAAO,MAAM,yBAAyB,GACpC,OAAO,qBAAqB,KAC3B,OAAO,CAAC,mBAAmB,CAU7B,CAAC;AAuIF,eAAO,MAAM,sBAAsB,GACjC,SAAS,MAAM,EACf,QAAQ,MAAM,EACd,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,cAAc,mBAAmB,KAChC,OAAO,CAAC,OAAO,CAUjB,CAAC"}
|
|
@@ -1,13 +1,27 @@
|
|
|
1
1
|
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import
|
|
7
|
-
|
|
2
|
+
const loadQueueMonitorDriverModule = async () => {
|
|
3
|
+
return import('@zintrust/queue-monitor/driver');
|
|
4
|
+
};
|
|
5
|
+
const loadQueueMonitorMetricsModule = async () => {
|
|
6
|
+
return import('@zintrust/queue-monitor/metrics');
|
|
7
|
+
};
|
|
8
|
+
const loadQueueMonitoringServiceModule = async () => {
|
|
9
|
+
return import('../../../packages/queue-monitor/src/QueueMonitoringService.js');
|
|
10
|
+
};
|
|
11
|
+
const loadWorkersApiModule = async () => {
|
|
12
|
+
return import('../../../packages/workers/src/dashboard/workers-api.js');
|
|
13
|
+
};
|
|
14
|
+
const loadWorkerFactoryModule = async () => {
|
|
15
|
+
return import('../../../packages/workers/src/WorkerFactory.js');
|
|
16
|
+
};
|
|
17
|
+
export const createQueueMonitorContext = async (redis) => {
|
|
18
|
+
const [driverModule, metricsModule] = await Promise.all([
|
|
19
|
+
loadQueueMonitorDriverModule(),
|
|
20
|
+
loadQueueMonitorMetricsModule(),
|
|
21
|
+
]);
|
|
8
22
|
return {
|
|
9
|
-
driver: createBullMQDriver(redis),
|
|
10
|
-
metrics: createMetrics(redis),
|
|
23
|
+
driver: driverModule.createBullMQDriver(redis),
|
|
24
|
+
metrics: metricsModule.createMetrics(redis),
|
|
11
25
|
};
|
|
12
26
|
};
|
|
13
27
|
const readString = (value) => {
|
|
@@ -38,16 +52,20 @@ const resolveWorkerPersistenceOverride = (payload) => {
|
|
|
38
52
|
};
|
|
39
53
|
const workerActionHandlers = {
|
|
40
54
|
getWorkers: async (payload) => {
|
|
41
|
-
|
|
55
|
+
const module = await loadWorkersApiModule();
|
|
56
|
+
return module.getWorkers(payload);
|
|
42
57
|
},
|
|
43
58
|
getWorkerDetails: async (payload) => {
|
|
44
|
-
|
|
59
|
+
const module = await loadWorkersApiModule();
|
|
60
|
+
return module.getWorkerDetails(readString(payload['name'] ?? payload['workerName']) ?? '', readString(payload['driver']));
|
|
45
61
|
},
|
|
46
62
|
toggleAutoStart: async (payload) => {
|
|
47
|
-
|
|
63
|
+
const module = await loadWorkersApiModule();
|
|
64
|
+
return module.toggleAutoStart(readString(payload['name'] ?? payload['workerName']) ?? '', readBoolean(payload['enabled']));
|
|
48
65
|
},
|
|
49
66
|
listPersistedRecords: async (payload) => {
|
|
50
|
-
|
|
67
|
+
const module = await loadWorkerFactoryModule();
|
|
68
|
+
return module.WorkerFactory.listPersistedRecords(resolveWorkerPersistenceOverride(payload), {
|
|
51
69
|
offset: readNumber(payload['offset']),
|
|
52
70
|
limit: readNumber(payload['limit']),
|
|
53
71
|
search: readString(payload['search']),
|
|
@@ -55,24 +73,30 @@ const workerActionHandlers = {
|
|
|
55
73
|
});
|
|
56
74
|
},
|
|
57
75
|
listFileBackedRecords: async () => {
|
|
58
|
-
|
|
76
|
+
const module = await loadWorkerFactoryModule();
|
|
77
|
+
return module.WorkerFactory.listFileBackedRecords();
|
|
59
78
|
},
|
|
60
79
|
getPersisted: async (payload) => {
|
|
61
|
-
|
|
80
|
+
const module = await loadWorkerFactoryModule();
|
|
81
|
+
return module.WorkerFactory.getPersisted(readString(payload['name'] ?? payload['workerName']) ?? '', resolveWorkerPersistenceOverride(payload));
|
|
62
82
|
},
|
|
63
83
|
getHealth: async (payload) => {
|
|
64
|
-
|
|
84
|
+
const module = await loadWorkerFactoryModule();
|
|
85
|
+
return module.WorkerFactory.getHealth(readString(payload['name'] ?? payload['workerName']) ?? '');
|
|
65
86
|
},
|
|
66
87
|
getMetrics: async (payload) => {
|
|
67
|
-
|
|
88
|
+
const module = await loadWorkerFactoryModule();
|
|
89
|
+
return module.WorkerFactory.getMetrics(readString(payload['name'] ?? payload['workerName']) ?? '');
|
|
68
90
|
},
|
|
69
91
|
};
|
|
70
92
|
const queueMonitorActionHandlers = {
|
|
71
93
|
getRecentJobsForQueue: async (payload, queueMonitor) => {
|
|
72
|
-
|
|
94
|
+
const module = await loadQueueMonitoringServiceModule();
|
|
95
|
+
return module.getRecentJobsForQueue(readString(payload['queue'] ?? payload['queueName']) ?? '', queueMonitor.metrics, queueMonitor.driver);
|
|
73
96
|
},
|
|
74
97
|
getRecentJobsForSelection: async (payload, queueMonitor) => {
|
|
75
|
-
|
|
98
|
+
const module = await loadQueueMonitoringServiceModule();
|
|
99
|
+
return module.getRecentJobsForSelection(readString(payload['queue'] ?? payload['queueName']) ?? '', queueMonitor.metrics, queueMonitor.driver, readQueueNames(payload['queueNames']));
|
|
76
100
|
},
|
|
77
101
|
};
|
|
78
102
|
const dispatchWorkerAction = async (action, payload) => {
|
|
@@ -254,8 +254,8 @@ const handleRedisHealth = async (config) => {
|
|
|
254
254
|
return { status: 503, body: { status: 'unhealthy', error: String(error) } };
|
|
255
255
|
}
|
|
256
256
|
};
|
|
257
|
-
const createBackend = (config) => {
|
|
258
|
-
const queueMonitor = createQueueMonitorContext(config.redis);
|
|
257
|
+
const createBackend = async (config) => {
|
|
258
|
+
const queueMonitor = await createQueueMonitorContext(config.redis);
|
|
259
259
|
return {
|
|
260
260
|
name: 'redis',
|
|
261
261
|
handle: async (request) => handleRedisRequest(request, config, queueMonitor),
|
|
@@ -307,7 +307,7 @@ const getScriptCacheClient = async (config) => {
|
|
|
307
307
|
export const RedisProxyServer = Object.freeze({
|
|
308
308
|
async start(overrides = {}) {
|
|
309
309
|
const config = resolveConfig(overrides);
|
|
310
|
-
const backend = createBackend(config);
|
|
310
|
+
const backend = await createBackend(config);
|
|
311
311
|
Logger.info('[RedisProxyServer] Starting Redis proxy', {
|
|
312
312
|
host: config.host,
|
|
313
313
|
port: config.port,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PluginAutoImports.d.ts","sourceRoot":"","sources":["../../../src/runtime/PluginAutoImports.ts"],"names":[],"mappings":"AAKA,OAAO,EAAmB,KAAK,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAEzF,KAAK,YAAY,GACb;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAChC;IACE,EAAE,EAAE,KAAK,CAAC;IACV,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,WAAW,GAAG,eAAe,CAAC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;
|
|
1
|
+
{"version":3,"file":"PluginAutoImports.d.ts","sourceRoot":"","sources":["../../../src/runtime/PluginAutoImports.ts"],"names":[],"mappings":"AAKA,OAAO,EAAmB,KAAK,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAEzF,KAAK,YAAY,GACb;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAChC;IACE,EAAE,EAAE,KAAK,CAAC;IACV,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,WAAW,GAAG,eAAe,CAAC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAgRN,eAAO,MAAM,iBAAiB;uCACY,uBAAuB,GAAY,OAAO,CAAC,YAAY,CAAC;IAkBhG;;;;;;OAMG;mCACkC,OAAO,CAAC,YAAY,CAAC;qCAgFnB,MAAM,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC;EAavE,CAAC"}
|
|
@@ -145,21 +145,52 @@ const importFromLocalFallback = async (specifier, fallback) => {
|
|
|
145
145
|
return getMissingPackageStatus(fallbackError, specifier);
|
|
146
146
|
}
|
|
147
147
|
};
|
|
148
|
+
const importFromFileContents = async (filePath, specifier) => {
|
|
149
|
+
try {
|
|
150
|
+
const summary = await importSpecifiers([{ filePath, specifier }]);
|
|
151
|
+
if (summary.loaded > 0) {
|
|
152
|
+
Logger.debug('[plugins] Loaded auto-import specifier from file contents', {
|
|
153
|
+
specifier,
|
|
154
|
+
filePath,
|
|
155
|
+
});
|
|
156
|
+
return 'loaded';
|
|
157
|
+
}
|
|
158
|
+
if (summary.missing > 0 && summary.failed === 0) {
|
|
159
|
+
return 'missing';
|
|
160
|
+
}
|
|
161
|
+
return 'failed';
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
return getMissingPackageStatus(error, specifier);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
148
167
|
const importSingleSpecifier = async (entry) => {
|
|
149
168
|
const target = entry.specifier.startsWith('.')
|
|
150
169
|
? resolveRelativeSpecifier(entry)
|
|
151
170
|
: entry.specifier;
|
|
152
|
-
|
|
153
|
-
await
|
|
154
|
-
|
|
155
|
-
|
|
171
|
+
if (target.endsWith('.ts')) {
|
|
172
|
+
const sourceLoad = await importFromFileContents(entry.filePath, entry.specifier);
|
|
173
|
+
if (sourceLoad !== 'failed') {
|
|
174
|
+
return sourceLoad;
|
|
175
|
+
}
|
|
156
176
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
177
|
+
else {
|
|
178
|
+
try {
|
|
179
|
+
await import(target);
|
|
180
|
+
Logger.debug('[plugins] Loaded auto-import specifier', { specifier: entry.specifier });
|
|
181
|
+
return 'loaded';
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
const fallback = resolveLocalPackageSpecifier(entry.specifier);
|
|
185
|
+
if (fallback !== null)
|
|
186
|
+
return importFromLocalFallback(entry.specifier, fallback);
|
|
187
|
+
return getMissingPackageStatus(error, entry.specifier);
|
|
188
|
+
}
|
|
162
189
|
}
|
|
190
|
+
const fallback = resolveLocalPackageSpecifier(entry.specifier);
|
|
191
|
+
if (fallback !== null)
|
|
192
|
+
return importFromLocalFallback(entry.specifier, fallback);
|
|
193
|
+
return 'failed';
|
|
163
194
|
};
|
|
164
195
|
const importSpecifiers = async (specifiers) => {
|
|
165
196
|
// Import all specifiers in parallel
|
|
@@ -225,6 +256,18 @@ export const PluginAutoImports = Object.freeze({
|
|
|
225
256
|
return { ok: false, reason: 'not-found' };
|
|
226
257
|
}
|
|
227
258
|
const tryImportCandidate = async (candidate) => {
|
|
259
|
+
if (candidate.endsWith('.ts')) {
|
|
260
|
+
const fallbackResult = await this.tryImportFromFileContents([candidate]);
|
|
261
|
+
if (fallbackResult.ok) {
|
|
262
|
+
return { ok: true, loadedPath: candidate };
|
|
263
|
+
}
|
|
264
|
+
return {
|
|
265
|
+
ok: false,
|
|
266
|
+
loadedPath: candidate,
|
|
267
|
+
reason: fallbackResult.reason,
|
|
268
|
+
errorMessage: fallbackResult.errorMessage,
|
|
269
|
+
};
|
|
270
|
+
}
|
|
228
271
|
try {
|
|
229
272
|
const url = pathToFileURL(candidate).href;
|
|
230
273
|
await import(url);
|