@tradejs/infra 3.1.8-beta.207 → 3.1.8-beta.210
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/{chunk-JLVCBKE3.mjs → chunk-NN4CAPDW.mjs} +97 -5
- package/dist/redis.d.mts +10 -6
- package/dist/redis.d.ts +10 -6
- package/dist/redis.js +100 -5
- package/dist/redis.mjs +7 -1
- package/dist/runtimeControls.d.mts +28 -0
- package/dist/runtimeControls.d.ts +28 -0
- package/dist/{runtimeStrategyReleases.js → runtimeControls.js} +141 -266
- package/dist/runtimeControls.mjs +133 -0
- package/dist/runtimeHeartbeats.d.mts +6 -0
- package/dist/runtimeHeartbeats.d.ts +6 -0
- package/dist/{runtimeDeployments.js → runtimeHeartbeats.js} +12 -181
- package/dist/runtimeHeartbeats.mjs +37 -0
- package/dist/runtimeStrategyConfigs.js +1 -5
- package/dist/runtimeStrategyConfigs.mjs +1 -1
- package/dist/strategyReleaseEvidence.js +1 -1
- package/dist/strategyReleaseEvidence.mjs +1 -1
- package/dist/tradingAccounts.js +1 -5
- package/dist/tradingAccounts.mjs +1 -1
- package/dist/userSettings.js +1 -5
- package/dist/userSettings.mjs +1 -1
- package/package.json +10 -10
- package/dist/runtimeDeployments.d.mts +0 -11
- package/dist/runtimeDeployments.d.ts +0 -11
- package/dist/runtimeDeployments.mjs +0 -134
- package/dist/runtimeStrategyReleases.d.mts +0 -26
- package/dist/runtimeStrategyReleases.d.ts +0 -26
- package/dist/runtimeStrategyReleases.mjs +0 -196
|
@@ -231,9 +231,67 @@ var getData = async (key, fallback = []) => {
|
|
|
231
231
|
return fallback;
|
|
232
232
|
}
|
|
233
233
|
};
|
|
234
|
+
var requireReadyRedis = async () => {
|
|
235
|
+
if (redisUnavailable) {
|
|
236
|
+
throw new Error("Redis is unavailable");
|
|
237
|
+
}
|
|
238
|
+
const redis = await getReadyRedis();
|
|
239
|
+
if (!redis) {
|
|
240
|
+
throw new Error("Redis is unavailable");
|
|
241
|
+
}
|
|
242
|
+
return redis;
|
|
243
|
+
};
|
|
244
|
+
var parseJsonStrict = (key, raw) => {
|
|
245
|
+
try {
|
|
246
|
+
return JSON.parse(raw);
|
|
247
|
+
} catch (error) {
|
|
248
|
+
throw new Error(`Invalid JSON stored at ${key}`, { cause: error });
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
var getDataStrict = async (key) => {
|
|
252
|
+
const redis = await requireReadyRedis();
|
|
253
|
+
try {
|
|
254
|
+
const raw = toResultString(await redis.call("JSON.GET", key));
|
|
255
|
+
return raw == null ? null : parseJsonStrict(key, raw);
|
|
256
|
+
} catch (error) {
|
|
257
|
+
if (error instanceof Error && isRedisConnectivityError(error)) {
|
|
258
|
+
markRedisUnavailable(error);
|
|
259
|
+
throw error;
|
|
260
|
+
}
|
|
261
|
+
if (error instanceof Error && error.message.startsWith("Invalid JSON")) {
|
|
262
|
+
throw error;
|
|
263
|
+
}
|
|
264
|
+
logger.log(
|
|
265
|
+
"error",
|
|
266
|
+
"failed strict JSON.GET %s: %s (fallback to GET)",
|
|
267
|
+
key,
|
|
268
|
+
String(error)
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
try {
|
|
272
|
+
const raw = await redis.get(key);
|
|
273
|
+
return raw == null ? null : parseJsonStrict(key, raw);
|
|
274
|
+
} catch (error) {
|
|
275
|
+
if (error instanceof Error && isRedisConnectivityError(error)) {
|
|
276
|
+
markRedisUnavailable(error);
|
|
277
|
+
}
|
|
278
|
+
throw error;
|
|
279
|
+
}
|
|
280
|
+
};
|
|
234
281
|
var delKey = async (key) => {
|
|
235
282
|
return delKeyWithOptions(key);
|
|
236
283
|
};
|
|
284
|
+
var delKeyStrict = async (key) => {
|
|
285
|
+
const redis = await requireReadyRedis();
|
|
286
|
+
try {
|
|
287
|
+
return await redis.del(key) === 1;
|
|
288
|
+
} catch (error) {
|
|
289
|
+
if (error instanceof Error && isRedisConnectivityError(error)) {
|
|
290
|
+
markRedisUnavailable(error);
|
|
291
|
+
}
|
|
292
|
+
throw error;
|
|
293
|
+
}
|
|
294
|
+
};
|
|
237
295
|
var RedisWriteBlockedError = class extends Error {
|
|
238
296
|
constructor(message) {
|
|
239
297
|
super(message);
|
|
@@ -301,6 +359,41 @@ var setData = async (key, data, options = {}) => {
|
|
|
301
359
|
}
|
|
302
360
|
}
|
|
303
361
|
};
|
|
362
|
+
var setDataStrict = async (key, data, options = {}) => {
|
|
363
|
+
const { expire } = { ...DEFAULT_OPTIONS, ...options };
|
|
364
|
+
const redis = await requireReadyRedis();
|
|
365
|
+
const value = toJson(data);
|
|
366
|
+
try {
|
|
367
|
+
await redis.call("JSON.SET", key, "$", value);
|
|
368
|
+
if (expire) {
|
|
369
|
+
await redis.expire(key, expire);
|
|
370
|
+
}
|
|
371
|
+
return;
|
|
372
|
+
} catch (error) {
|
|
373
|
+
if (error instanceof Error && isRedisConnectivityError(error)) {
|
|
374
|
+
markRedisUnavailable(error);
|
|
375
|
+
throw error;
|
|
376
|
+
}
|
|
377
|
+
logger.log(
|
|
378
|
+
"error",
|
|
379
|
+
"failed strict JSON.SET %s: %s (fallback to SET)",
|
|
380
|
+
key,
|
|
381
|
+
String(error)
|
|
382
|
+
);
|
|
383
|
+
}
|
|
384
|
+
try {
|
|
385
|
+
if (expire) {
|
|
386
|
+
await redis.set(key, value, "EX", expire);
|
|
387
|
+
} else {
|
|
388
|
+
await redis.set(key, value);
|
|
389
|
+
}
|
|
390
|
+
} catch (error) {
|
|
391
|
+
if (error instanceof Error && isRedisConnectivityError(error)) {
|
|
392
|
+
markRedisUnavailable(error);
|
|
393
|
+
}
|
|
394
|
+
throw error;
|
|
395
|
+
}
|
|
396
|
+
};
|
|
304
397
|
var setDataIfAbsent = async (key, data) => {
|
|
305
398
|
if (redisUnavailable) return false;
|
|
306
399
|
const redis = await getReadyRedis();
|
|
@@ -508,18 +601,14 @@ var redisKeys = {
|
|
|
508
601
|
user: (userName) => `users:index:${userName}`,
|
|
509
602
|
tradingAccounts: (userName) => `users:${userName}:trading-accounts:`,
|
|
510
603
|
tradingAccount: (userName, accountId) => `users:${userName}:trading-accounts:${accountId}`,
|
|
511
|
-
runtimeDeployments: (userName) => `users:${userName}:runtime:deployments:`,
|
|
512
|
-
runtimeDeployment: (userName, deploymentId) => `users:${userName}:runtime:deployments:${deploymentId}`,
|
|
513
604
|
runtimeDeploymentHeartbeat: (userName, deploymentId) => `users:${userName}:runtime:deployments:${deploymentId}:heartbeat`,
|
|
605
|
+
runtimeControls: (userName) => `users:${userName}:runtime:controls`,
|
|
514
606
|
bots: (userName) => `users:${userName}:bots`,
|
|
515
607
|
botsPrefix: () => "users:",
|
|
516
608
|
bot: (userName, botId) => `users:${userName}:bots:${botId}`,
|
|
517
609
|
backtestConfig: (userName, config) => `users:${userName}:backtests:configs:${config}`,
|
|
518
610
|
strategies: (userName) => `users:${userName}:strategies`,
|
|
519
611
|
strategyConfig: (userName, strategyName, configId = "config") => `users:${userName}:strategies:${strategyName}:${configId}`,
|
|
520
|
-
runtimeStrategyReleases: (userName, strategyName) => `users:${userName}:strategies:${strategyName}:releases:`,
|
|
521
|
-
runtimeStrategyRelease: (userName, strategyName, releaseVersion) => `users:${userName}:strategies:${strategyName}:releases:${releaseVersion}`,
|
|
522
|
-
runtimeStrategyReleaseSequence: (userName, strategyName) => `users:${userName}:strategies:${strategyName}:release-seq`,
|
|
523
612
|
runtimeStrategyControlEvents: (userName) => `users:${userName}:runtime:strategy-control-events:`,
|
|
524
613
|
runtimeStrategyControlEvent: (userName, eventId) => `users:${userName}:runtime:strategy-control-events:${eventId}`,
|
|
525
614
|
strategyResults: (userName, strategyName) => `users:${userName}:strategies:${strategyName}:results`,
|
|
@@ -583,10 +672,13 @@ export {
|
|
|
583
672
|
publishData,
|
|
584
673
|
getKeys,
|
|
585
674
|
getData,
|
|
675
|
+
getDataStrict,
|
|
586
676
|
delKey,
|
|
677
|
+
delKeyStrict,
|
|
587
678
|
RedisWriteBlockedError,
|
|
588
679
|
delKeyWithOptions,
|
|
589
680
|
setData,
|
|
681
|
+
setDataStrict,
|
|
590
682
|
setDataIfAbsent,
|
|
591
683
|
incrementKey,
|
|
592
684
|
setHashJsonField,
|
package/dist/redis.d.mts
CHANGED
|
@@ -13,12 +13,20 @@ interface DelKeyOptions {
|
|
|
13
13
|
}
|
|
14
14
|
declare const getKeys: (prefix: string) => Promise<string[]>;
|
|
15
15
|
declare const getData: (key: string, fallback?: any) => Promise<any>;
|
|
16
|
+
/**
|
|
17
|
+
* Reads durable operational state without treating a Redis outage or malformed
|
|
18
|
+
* JSON as a missing key. Use this for fail-closed controls, not cache reads.
|
|
19
|
+
*/
|
|
20
|
+
declare const getDataStrict: (key: string) => Promise<unknown | null>;
|
|
16
21
|
declare const delKey: (key: string) => Promise<boolean>;
|
|
22
|
+
declare const delKeyStrict: (key: string) => Promise<boolean>;
|
|
17
23
|
declare class RedisWriteBlockedError extends Error {
|
|
18
24
|
constructor(message: string);
|
|
19
25
|
}
|
|
20
26
|
declare const delKeyWithOptions: (key: string, options?: DelKeyOptions) => Promise<boolean>;
|
|
21
27
|
declare const setData: <T>(key: string, data: T, options?: Options) => Promise<void>;
|
|
28
|
+
/** Writes durable operational state and surfaces every write failure. */
|
|
29
|
+
declare const setDataStrict: <T>(key: string, data: T, options?: Options) => Promise<void>;
|
|
22
30
|
/** Writes a JSON value only when the key does not exist. */
|
|
23
31
|
declare const setDataIfAbsent: <T>(key: string, data: T) => Promise<boolean>;
|
|
24
32
|
declare const incrementKey: (key: string) => Promise<number>;
|
|
@@ -38,18 +46,14 @@ declare const redisKeys: {
|
|
|
38
46
|
user: (userName: string) => string;
|
|
39
47
|
tradingAccounts: (userName: string) => string;
|
|
40
48
|
tradingAccount: (userName: string, accountId: string) => string;
|
|
41
|
-
runtimeDeployments: (userName: string) => string;
|
|
42
|
-
runtimeDeployment: (userName: string, deploymentId: string) => string;
|
|
43
49
|
runtimeDeploymentHeartbeat: (userName: string, deploymentId: string) => string;
|
|
50
|
+
runtimeControls: (userName: string) => string;
|
|
44
51
|
bots: (userName: string) => string;
|
|
45
52
|
botsPrefix: () => string;
|
|
46
53
|
bot: (userName: string, botId: string) => string;
|
|
47
54
|
backtestConfig: (userName: string, config: string) => string;
|
|
48
55
|
strategies: (userName: string) => string;
|
|
49
56
|
strategyConfig: (userName: string, strategyName: string, configId?: string) => string;
|
|
50
|
-
runtimeStrategyReleases: (userName: string, strategyName: string) => string;
|
|
51
|
-
runtimeStrategyRelease: (userName: string, strategyName: string, releaseVersion: number) => string;
|
|
52
|
-
runtimeStrategyReleaseSequence: (userName: string, strategyName: string) => string;
|
|
53
57
|
runtimeStrategyControlEvents: (userName: string) => string;
|
|
54
58
|
runtimeStrategyControlEvent: (userName: string, eventId: string) => string;
|
|
55
59
|
strategyResults: (userName: string, strategyName: string) => string;
|
|
@@ -108,4 +112,4 @@ declare const redisKeys: {
|
|
|
108
112
|
mlResult: (strategyName: string, signalId: string) => string;
|
|
109
113
|
};
|
|
110
114
|
|
|
111
|
-
export { RedisWriteBlockedError, closeRedisConnection, consumeScreenshotSessionToken, createScreenshotSessionToken, delKey, delKeyWithOptions, getData, getHashData, getHashJsonField, getHashJsonValues, getKeys, incrHashFields, incrementKey, publishData, redisKeys, setData, setDataIfAbsent, setHashJsonField, setHashJsonFields };
|
|
115
|
+
export { RedisWriteBlockedError, closeRedisConnection, consumeScreenshotSessionToken, createScreenshotSessionToken, delKey, delKeyStrict, delKeyWithOptions, getData, getDataStrict, getHashData, getHashJsonField, getHashJsonValues, getKeys, incrHashFields, incrementKey, publishData, redisKeys, setData, setDataIfAbsent, setDataStrict, setHashJsonField, setHashJsonFields };
|
package/dist/redis.d.ts
CHANGED
|
@@ -13,12 +13,20 @@ interface DelKeyOptions {
|
|
|
13
13
|
}
|
|
14
14
|
declare const getKeys: (prefix: string) => Promise<string[]>;
|
|
15
15
|
declare const getData: (key: string, fallback?: any) => Promise<any>;
|
|
16
|
+
/**
|
|
17
|
+
* Reads durable operational state without treating a Redis outage or malformed
|
|
18
|
+
* JSON as a missing key. Use this for fail-closed controls, not cache reads.
|
|
19
|
+
*/
|
|
20
|
+
declare const getDataStrict: (key: string) => Promise<unknown | null>;
|
|
16
21
|
declare const delKey: (key: string) => Promise<boolean>;
|
|
22
|
+
declare const delKeyStrict: (key: string) => Promise<boolean>;
|
|
17
23
|
declare class RedisWriteBlockedError extends Error {
|
|
18
24
|
constructor(message: string);
|
|
19
25
|
}
|
|
20
26
|
declare const delKeyWithOptions: (key: string, options?: DelKeyOptions) => Promise<boolean>;
|
|
21
27
|
declare const setData: <T>(key: string, data: T, options?: Options) => Promise<void>;
|
|
28
|
+
/** Writes durable operational state and surfaces every write failure. */
|
|
29
|
+
declare const setDataStrict: <T>(key: string, data: T, options?: Options) => Promise<void>;
|
|
22
30
|
/** Writes a JSON value only when the key does not exist. */
|
|
23
31
|
declare const setDataIfAbsent: <T>(key: string, data: T) => Promise<boolean>;
|
|
24
32
|
declare const incrementKey: (key: string) => Promise<number>;
|
|
@@ -38,18 +46,14 @@ declare const redisKeys: {
|
|
|
38
46
|
user: (userName: string) => string;
|
|
39
47
|
tradingAccounts: (userName: string) => string;
|
|
40
48
|
tradingAccount: (userName: string, accountId: string) => string;
|
|
41
|
-
runtimeDeployments: (userName: string) => string;
|
|
42
|
-
runtimeDeployment: (userName: string, deploymentId: string) => string;
|
|
43
49
|
runtimeDeploymentHeartbeat: (userName: string, deploymentId: string) => string;
|
|
50
|
+
runtimeControls: (userName: string) => string;
|
|
44
51
|
bots: (userName: string) => string;
|
|
45
52
|
botsPrefix: () => string;
|
|
46
53
|
bot: (userName: string, botId: string) => string;
|
|
47
54
|
backtestConfig: (userName: string, config: string) => string;
|
|
48
55
|
strategies: (userName: string) => string;
|
|
49
56
|
strategyConfig: (userName: string, strategyName: string, configId?: string) => string;
|
|
50
|
-
runtimeStrategyReleases: (userName: string, strategyName: string) => string;
|
|
51
|
-
runtimeStrategyRelease: (userName: string, strategyName: string, releaseVersion: number) => string;
|
|
52
|
-
runtimeStrategyReleaseSequence: (userName: string, strategyName: string) => string;
|
|
53
57
|
runtimeStrategyControlEvents: (userName: string) => string;
|
|
54
58
|
runtimeStrategyControlEvent: (userName: string, eventId: string) => string;
|
|
55
59
|
strategyResults: (userName: string, strategyName: string) => string;
|
|
@@ -108,4 +112,4 @@ declare const redisKeys: {
|
|
|
108
112
|
mlResult: (strategyName: string, signalId: string) => string;
|
|
109
113
|
};
|
|
110
114
|
|
|
111
|
-
export { RedisWriteBlockedError, closeRedisConnection, consumeScreenshotSessionToken, createScreenshotSessionToken, delKey, delKeyWithOptions, getData, getHashData, getHashJsonField, getHashJsonValues, getKeys, incrHashFields, incrementKey, publishData, redisKeys, setData, setDataIfAbsent, setHashJsonField, setHashJsonFields };
|
|
115
|
+
export { RedisWriteBlockedError, closeRedisConnection, consumeScreenshotSessionToken, createScreenshotSessionToken, delKey, delKeyStrict, delKeyWithOptions, getData, getDataStrict, getHashData, getHashJsonField, getHashJsonValues, getKeys, incrHashFields, incrementKey, publishData, redisKeys, setData, setDataIfAbsent, setDataStrict, setHashJsonField, setHashJsonFields };
|
package/dist/redis.js
CHANGED
|
@@ -35,8 +35,10 @@ __export(redis_exports, {
|
|
|
35
35
|
consumeScreenshotSessionToken: () => consumeScreenshotSessionToken,
|
|
36
36
|
createScreenshotSessionToken: () => createScreenshotSessionToken,
|
|
37
37
|
delKey: () => delKey,
|
|
38
|
+
delKeyStrict: () => delKeyStrict,
|
|
38
39
|
delKeyWithOptions: () => delKeyWithOptions,
|
|
39
40
|
getData: () => getData,
|
|
41
|
+
getDataStrict: () => getDataStrict,
|
|
40
42
|
getHashData: () => getHashData,
|
|
41
43
|
getHashJsonField: () => getHashJsonField,
|
|
42
44
|
getHashJsonValues: () => getHashJsonValues,
|
|
@@ -47,6 +49,7 @@ __export(redis_exports, {
|
|
|
47
49
|
redisKeys: () => redisKeys,
|
|
48
50
|
setData: () => setData,
|
|
49
51
|
setDataIfAbsent: () => setDataIfAbsent,
|
|
52
|
+
setDataStrict: () => setDataStrict,
|
|
50
53
|
setHashJsonField: () => setHashJsonField,
|
|
51
54
|
setHashJsonFields: () => setHashJsonFields
|
|
52
55
|
});
|
|
@@ -283,9 +286,67 @@ var getData = async (key, fallback = []) => {
|
|
|
283
286
|
return fallback;
|
|
284
287
|
}
|
|
285
288
|
};
|
|
289
|
+
var requireReadyRedis = async () => {
|
|
290
|
+
if (redisUnavailable) {
|
|
291
|
+
throw new Error("Redis is unavailable");
|
|
292
|
+
}
|
|
293
|
+
const redis = await getReadyRedis();
|
|
294
|
+
if (!redis) {
|
|
295
|
+
throw new Error("Redis is unavailable");
|
|
296
|
+
}
|
|
297
|
+
return redis;
|
|
298
|
+
};
|
|
299
|
+
var parseJsonStrict = (key, raw) => {
|
|
300
|
+
try {
|
|
301
|
+
return JSON.parse(raw);
|
|
302
|
+
} catch (error) {
|
|
303
|
+
throw new Error(`Invalid JSON stored at ${key}`, { cause: error });
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
var getDataStrict = async (key) => {
|
|
307
|
+
const redis = await requireReadyRedis();
|
|
308
|
+
try {
|
|
309
|
+
const raw = toResultString(await redis.call("JSON.GET", key));
|
|
310
|
+
return raw == null ? null : parseJsonStrict(key, raw);
|
|
311
|
+
} catch (error) {
|
|
312
|
+
if (error instanceof Error && isRedisConnectivityError(error)) {
|
|
313
|
+
markRedisUnavailable(error);
|
|
314
|
+
throw error;
|
|
315
|
+
}
|
|
316
|
+
if (error instanceof Error && error.message.startsWith("Invalid JSON")) {
|
|
317
|
+
throw error;
|
|
318
|
+
}
|
|
319
|
+
logger.log(
|
|
320
|
+
"error",
|
|
321
|
+
"failed strict JSON.GET %s: %s (fallback to GET)",
|
|
322
|
+
key,
|
|
323
|
+
String(error)
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
try {
|
|
327
|
+
const raw = await redis.get(key);
|
|
328
|
+
return raw == null ? null : parseJsonStrict(key, raw);
|
|
329
|
+
} catch (error) {
|
|
330
|
+
if (error instanceof Error && isRedisConnectivityError(error)) {
|
|
331
|
+
markRedisUnavailable(error);
|
|
332
|
+
}
|
|
333
|
+
throw error;
|
|
334
|
+
}
|
|
335
|
+
};
|
|
286
336
|
var delKey = async (key) => {
|
|
287
337
|
return delKeyWithOptions(key);
|
|
288
338
|
};
|
|
339
|
+
var delKeyStrict = async (key) => {
|
|
340
|
+
const redis = await requireReadyRedis();
|
|
341
|
+
try {
|
|
342
|
+
return await redis.del(key) === 1;
|
|
343
|
+
} catch (error) {
|
|
344
|
+
if (error instanceof Error && isRedisConnectivityError(error)) {
|
|
345
|
+
markRedisUnavailable(error);
|
|
346
|
+
}
|
|
347
|
+
throw error;
|
|
348
|
+
}
|
|
349
|
+
};
|
|
289
350
|
var RedisWriteBlockedError = class extends Error {
|
|
290
351
|
constructor(message) {
|
|
291
352
|
super(message);
|
|
@@ -353,6 +414,41 @@ var setData = async (key, data, options = {}) => {
|
|
|
353
414
|
}
|
|
354
415
|
}
|
|
355
416
|
};
|
|
417
|
+
var setDataStrict = async (key, data, options = {}) => {
|
|
418
|
+
const { expire } = { ...DEFAULT_OPTIONS, ...options };
|
|
419
|
+
const redis = await requireReadyRedis();
|
|
420
|
+
const value = toJson(data);
|
|
421
|
+
try {
|
|
422
|
+
await redis.call("JSON.SET", key, "$", value);
|
|
423
|
+
if (expire) {
|
|
424
|
+
await redis.expire(key, expire);
|
|
425
|
+
}
|
|
426
|
+
return;
|
|
427
|
+
} catch (error) {
|
|
428
|
+
if (error instanceof Error && isRedisConnectivityError(error)) {
|
|
429
|
+
markRedisUnavailable(error);
|
|
430
|
+
throw error;
|
|
431
|
+
}
|
|
432
|
+
logger.log(
|
|
433
|
+
"error",
|
|
434
|
+
"failed strict JSON.SET %s: %s (fallback to SET)",
|
|
435
|
+
key,
|
|
436
|
+
String(error)
|
|
437
|
+
);
|
|
438
|
+
}
|
|
439
|
+
try {
|
|
440
|
+
if (expire) {
|
|
441
|
+
await redis.set(key, value, "EX", expire);
|
|
442
|
+
} else {
|
|
443
|
+
await redis.set(key, value);
|
|
444
|
+
}
|
|
445
|
+
} catch (error) {
|
|
446
|
+
if (error instanceof Error && isRedisConnectivityError(error)) {
|
|
447
|
+
markRedisUnavailable(error);
|
|
448
|
+
}
|
|
449
|
+
throw error;
|
|
450
|
+
}
|
|
451
|
+
};
|
|
356
452
|
var setDataIfAbsent = async (key, data) => {
|
|
357
453
|
if (redisUnavailable) return false;
|
|
358
454
|
const redis = await getReadyRedis();
|
|
@@ -560,18 +656,14 @@ var redisKeys = {
|
|
|
560
656
|
user: (userName) => `users:index:${userName}`,
|
|
561
657
|
tradingAccounts: (userName) => `users:${userName}:trading-accounts:`,
|
|
562
658
|
tradingAccount: (userName, accountId) => `users:${userName}:trading-accounts:${accountId}`,
|
|
563
|
-
runtimeDeployments: (userName) => `users:${userName}:runtime:deployments:`,
|
|
564
|
-
runtimeDeployment: (userName, deploymentId) => `users:${userName}:runtime:deployments:${deploymentId}`,
|
|
565
659
|
runtimeDeploymentHeartbeat: (userName, deploymentId) => `users:${userName}:runtime:deployments:${deploymentId}:heartbeat`,
|
|
660
|
+
runtimeControls: (userName) => `users:${userName}:runtime:controls`,
|
|
566
661
|
bots: (userName) => `users:${userName}:bots`,
|
|
567
662
|
botsPrefix: () => "users:",
|
|
568
663
|
bot: (userName, botId) => `users:${userName}:bots:${botId}`,
|
|
569
664
|
backtestConfig: (userName, config) => `users:${userName}:backtests:configs:${config}`,
|
|
570
665
|
strategies: (userName) => `users:${userName}:strategies`,
|
|
571
666
|
strategyConfig: (userName, strategyName, configId = "config") => `users:${userName}:strategies:${strategyName}:${configId}`,
|
|
572
|
-
runtimeStrategyReleases: (userName, strategyName) => `users:${userName}:strategies:${strategyName}:releases:`,
|
|
573
|
-
runtimeStrategyRelease: (userName, strategyName, releaseVersion) => `users:${userName}:strategies:${strategyName}:releases:${releaseVersion}`,
|
|
574
|
-
runtimeStrategyReleaseSequence: (userName, strategyName) => `users:${userName}:strategies:${strategyName}:release-seq`,
|
|
575
667
|
runtimeStrategyControlEvents: (userName) => `users:${userName}:runtime:strategy-control-events:`,
|
|
576
668
|
runtimeStrategyControlEvent: (userName, eventId) => `users:${userName}:runtime:strategy-control-events:${eventId}`,
|
|
577
669
|
strategyResults: (userName, strategyName) => `users:${userName}:strategies:${strategyName}:results`,
|
|
@@ -636,8 +728,10 @@ var redisKeys = {
|
|
|
636
728
|
consumeScreenshotSessionToken,
|
|
637
729
|
createScreenshotSessionToken,
|
|
638
730
|
delKey,
|
|
731
|
+
delKeyStrict,
|
|
639
732
|
delKeyWithOptions,
|
|
640
733
|
getData,
|
|
734
|
+
getDataStrict,
|
|
641
735
|
getHashData,
|
|
642
736
|
getHashJsonField,
|
|
643
737
|
getHashJsonValues,
|
|
@@ -648,6 +742,7 @@ var redisKeys = {
|
|
|
648
742
|
redisKeys,
|
|
649
743
|
setData,
|
|
650
744
|
setDataIfAbsent,
|
|
745
|
+
setDataStrict,
|
|
651
746
|
setHashJsonField,
|
|
652
747
|
setHashJsonFields
|
|
653
748
|
});
|
package/dist/redis.mjs
CHANGED
|
@@ -4,8 +4,10 @@ import {
|
|
|
4
4
|
consumeScreenshotSessionToken,
|
|
5
5
|
createScreenshotSessionToken,
|
|
6
6
|
delKey,
|
|
7
|
+
delKeyStrict,
|
|
7
8
|
delKeyWithOptions,
|
|
8
9
|
getData,
|
|
10
|
+
getDataStrict,
|
|
9
11
|
getHashData,
|
|
10
12
|
getHashJsonField,
|
|
11
13
|
getHashJsonValues,
|
|
@@ -16,17 +18,20 @@ import {
|
|
|
16
18
|
redisKeys,
|
|
17
19
|
setData,
|
|
18
20
|
setDataIfAbsent,
|
|
21
|
+
setDataStrict,
|
|
19
22
|
setHashJsonField,
|
|
20
23
|
setHashJsonFields
|
|
21
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-NN4CAPDW.mjs";
|
|
22
25
|
export {
|
|
23
26
|
RedisWriteBlockedError,
|
|
24
27
|
closeRedisConnection,
|
|
25
28
|
consumeScreenshotSessionToken,
|
|
26
29
|
createScreenshotSessionToken,
|
|
27
30
|
delKey,
|
|
31
|
+
delKeyStrict,
|
|
28
32
|
delKeyWithOptions,
|
|
29
33
|
getData,
|
|
34
|
+
getDataStrict,
|
|
30
35
|
getHashData,
|
|
31
36
|
getHashJsonField,
|
|
32
37
|
getHashJsonValues,
|
|
@@ -37,6 +42,7 @@ export {
|
|
|
37
42
|
redisKeys,
|
|
38
43
|
setData,
|
|
39
44
|
setDataIfAbsent,
|
|
45
|
+
setDataStrict,
|
|
40
46
|
setHashJsonField,
|
|
41
47
|
setHashJsonFields
|
|
42
48
|
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { RuntimeControls, RuntimeStrategyControlState, RuntimeStrategyControlEvent } from '@tradejs/types';
|
|
2
|
+
|
|
3
|
+
declare const emptyRuntimeControls: () => RuntimeControls;
|
|
4
|
+
declare const verifyRuntimeControls: (value: unknown) => RuntimeControls;
|
|
5
|
+
declare const getRuntimeControls: (userName: string) => Promise<RuntimeControls>;
|
|
6
|
+
declare const pauseRuntimeStrategy: ({ userName, deploymentId, strategyName, updatedBy, updatedAt, }: {
|
|
7
|
+
userName: string;
|
|
8
|
+
deploymentId: string;
|
|
9
|
+
strategyName: string;
|
|
10
|
+
updatedBy: string;
|
|
11
|
+
updatedAt?: string;
|
|
12
|
+
}) => Promise<RuntimeControls>;
|
|
13
|
+
declare const resumeRuntimeStrategy: ({ userName, deploymentId, strategyName, }: {
|
|
14
|
+
userName: string;
|
|
15
|
+
deploymentId: string;
|
|
16
|
+
strategyName: string;
|
|
17
|
+
}) => Promise<RuntimeControls>;
|
|
18
|
+
declare const recordRuntimeStrategyControlEvent: ({ userName, deploymentId, strategyName, version, previousState, nextState, createdBy, }: {
|
|
19
|
+
userName: string;
|
|
20
|
+
deploymentId: string;
|
|
21
|
+
strategyName: string;
|
|
22
|
+
version: number;
|
|
23
|
+
previousState: RuntimeStrategyControlState;
|
|
24
|
+
nextState: RuntimeStrategyControlState;
|
|
25
|
+
createdBy: string;
|
|
26
|
+
}) => Promise<RuntimeStrategyControlEvent>;
|
|
27
|
+
|
|
28
|
+
export { emptyRuntimeControls, getRuntimeControls, pauseRuntimeStrategy, recordRuntimeStrategyControlEvent, resumeRuntimeStrategy, verifyRuntimeControls };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { RuntimeControls, RuntimeStrategyControlState, RuntimeStrategyControlEvent } from '@tradejs/types';
|
|
2
|
+
|
|
3
|
+
declare const emptyRuntimeControls: () => RuntimeControls;
|
|
4
|
+
declare const verifyRuntimeControls: (value: unknown) => RuntimeControls;
|
|
5
|
+
declare const getRuntimeControls: (userName: string) => Promise<RuntimeControls>;
|
|
6
|
+
declare const pauseRuntimeStrategy: ({ userName, deploymentId, strategyName, updatedBy, updatedAt, }: {
|
|
7
|
+
userName: string;
|
|
8
|
+
deploymentId: string;
|
|
9
|
+
strategyName: string;
|
|
10
|
+
updatedBy: string;
|
|
11
|
+
updatedAt?: string;
|
|
12
|
+
}) => Promise<RuntimeControls>;
|
|
13
|
+
declare const resumeRuntimeStrategy: ({ userName, deploymentId, strategyName, }: {
|
|
14
|
+
userName: string;
|
|
15
|
+
deploymentId: string;
|
|
16
|
+
strategyName: string;
|
|
17
|
+
}) => Promise<RuntimeControls>;
|
|
18
|
+
declare const recordRuntimeStrategyControlEvent: ({ userName, deploymentId, strategyName, version, previousState, nextState, createdBy, }: {
|
|
19
|
+
userName: string;
|
|
20
|
+
deploymentId: string;
|
|
21
|
+
strategyName: string;
|
|
22
|
+
version: number;
|
|
23
|
+
previousState: RuntimeStrategyControlState;
|
|
24
|
+
nextState: RuntimeStrategyControlState;
|
|
25
|
+
createdBy: string;
|
|
26
|
+
}) => Promise<RuntimeStrategyControlEvent>;
|
|
27
|
+
|
|
28
|
+
export { emptyRuntimeControls, getRuntimeControls, pauseRuntimeStrategy, recordRuntimeStrategyControlEvent, resumeRuntimeStrategy, verifyRuntimeControls };
|