@tradejs/infra 3.1.28-beta.254 → 3.1.28-beta.255

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.
@@ -1,9 +1,10 @@
1
- import { RuntimeDeploymentCompositionEvent, RuntimeDeployment } from '@tradejs/types';
1
+ import { RuntimeDeploymentCompositionEvent, RuntimeDeployment, RuntimeDeploymentCompositionEventStrategy } from '@tradejs/types';
2
2
 
3
3
  declare const isRuntimeDeploymentCompositionEvent: (value: unknown) => value is RuntimeDeploymentCompositionEvent;
4
- declare const observeRuntimeDeploymentComposition: ({ userName, deployment, observedAt, }: {
4
+ declare const observeRuntimeDeploymentComposition: ({ userName, deployment, strategies, observedAt, }: {
5
5
  userName: string;
6
6
  deployment: RuntimeDeployment;
7
+ strategies: Array<Required<RuntimeDeploymentCompositionEventStrategy>>;
7
8
  observedAt?: number;
8
9
  }) => Promise<RuntimeDeploymentCompositionEvent | null>;
9
10
  declare const loadRuntimeDeploymentCompositionEvents: (userName: string, deploymentId: string) => Promise<RuntimeDeploymentCompositionEvent[]>;
@@ -1,9 +1,10 @@
1
- import { RuntimeDeploymentCompositionEvent, RuntimeDeployment } from '@tradejs/types';
1
+ import { RuntimeDeploymentCompositionEvent, RuntimeDeployment, RuntimeDeploymentCompositionEventStrategy } from '@tradejs/types';
2
2
 
3
3
  declare const isRuntimeDeploymentCompositionEvent: (value: unknown) => value is RuntimeDeploymentCompositionEvent;
4
- declare const observeRuntimeDeploymentComposition: ({ userName, deployment, observedAt, }: {
4
+ declare const observeRuntimeDeploymentComposition: ({ userName, deployment, strategies, observedAt, }: {
5
5
  userName: string;
6
6
  deployment: RuntimeDeployment;
7
+ strategies: Array<Required<RuntimeDeploymentCompositionEventStrategy>>;
7
8
  observedAt?: number;
8
9
  }) => Promise<RuntimeDeploymentCompositionEvent | null>;
9
10
  declare const loadRuntimeDeploymentCompositionEvents: (userName: string, deploymentId: string) => Promise<RuntimeDeploymentCompositionEvent[]>;
@@ -372,8 +372,13 @@ var isRuntimeDeploymentCompositionEvent = (value) => {
372
372
  const strategyNames = /* @__PURE__ */ new Set();
373
373
  for (const strategy of value.strategies) {
374
374
  if (!isRecord(strategy) || Object.keys(strategy).some(
375
- (key) => !["strategyName", "strategyRevision"].includes(key)
376
- ) || typeof strategy.strategyName !== "string" || !strategy.strategyName.trim() || strategyNames.has(strategy.strategyName) || typeof strategy.strategyRevision !== "string" || !/^sr1:[a-f0-9]{16}$/.test(strategy.strategyRevision)) {
375
+ (key) => ![
376
+ "strategyName",
377
+ "strategyRevision",
378
+ "strategyPackage",
379
+ "strategyPackageVersion"
380
+ ].includes(key)
381
+ ) || typeof strategy.strategyName !== "string" || !strategy.strategyName.trim() || strategyNames.has(strategy.strategyName) || typeof strategy.strategyRevision !== "string" || !/^sr1:[a-f0-9]{16}$/.test(strategy.strategyRevision) || strategy.strategyPackage !== void 0 && (typeof strategy.strategyPackage !== "string" || !strategy.strategyPackage.trim()) || strategy.strategyPackageVersion !== void 0 && (typeof strategy.strategyPackageVersion !== "string" || !strategy.strategyPackageVersion.trim()) || strategy.strategyPackage === void 0 !== (strategy.strategyPackageVersion === void 0)) {
377
382
  return false;
378
383
  }
379
384
  strategyNames.add(strategy.strategyName);
@@ -383,6 +388,7 @@ var isRuntimeDeploymentCompositionEvent = (value) => {
383
388
  var observeRuntimeDeploymentComposition = async ({
384
389
  userName,
385
390
  deployment,
391
+ strategies,
386
392
  observedAt = Date.now()
387
393
  }) => {
388
394
  if (!Number.isFinite(observedAt) || observedAt < 0) {
@@ -394,7 +400,9 @@ var observeRuntimeDeploymentComposition = async ({
394
400
  deploymentId
395
401
  );
396
402
  const current = await getData(stateKey, null);
397
- if (isRuntimeDeploymentCompositionEvent(current) && current.deploymentId === deploymentId && current.deploymentCompositionId === deployment.deploymentCompositionId) {
403
+ if (isRuntimeDeploymentCompositionEvent(current) && current.deploymentId === deploymentId && current.deploymentCompositionId === deployment.deploymentCompositionId && current.strategies.every(
404
+ (strategy) => strategy.strategyPackage !== void 0 && strategy.strategyPackageVersion !== void 0
405
+ )) {
398
406
  return null;
399
407
  }
400
408
  const event = {
@@ -403,10 +411,19 @@ var observeRuntimeDeploymentComposition = async ({
403
411
  deploymentId,
404
412
  deploymentCompositionId: deployment.deploymentCompositionId,
405
413
  observedAt,
406
- strategies: deployment.strategies.map(({ strategyName, strategyRevision }) => ({
407
- strategyName,
408
- strategyRevision
409
- })).sort(
414
+ strategies: strategies.map(
415
+ ({
416
+ strategyName,
417
+ strategyRevision,
418
+ strategyPackage,
419
+ strategyPackageVersion
420
+ }) => ({
421
+ strategyName,
422
+ strategyRevision,
423
+ strategyPackage,
424
+ strategyPackageVersion
425
+ })
426
+ ).sort(
410
427
  (left, right) => left.strategyName.localeCompare(right.strategyName)
411
428
  )
412
429
  };
@@ -32,8 +32,13 @@ var isRuntimeDeploymentCompositionEvent = (value) => {
32
32
  const strategyNames = /* @__PURE__ */ new Set();
33
33
  for (const strategy of value.strategies) {
34
34
  if (!isRecord(strategy) || Object.keys(strategy).some(
35
- (key) => !["strategyName", "strategyRevision"].includes(key)
36
- ) || typeof strategy.strategyName !== "string" || !strategy.strategyName.trim() || strategyNames.has(strategy.strategyName) || typeof strategy.strategyRevision !== "string" || !/^sr1:[a-f0-9]{16}$/.test(strategy.strategyRevision)) {
35
+ (key) => ![
36
+ "strategyName",
37
+ "strategyRevision",
38
+ "strategyPackage",
39
+ "strategyPackageVersion"
40
+ ].includes(key)
41
+ ) || typeof strategy.strategyName !== "string" || !strategy.strategyName.trim() || strategyNames.has(strategy.strategyName) || typeof strategy.strategyRevision !== "string" || !/^sr1:[a-f0-9]{16}$/.test(strategy.strategyRevision) || strategy.strategyPackage !== void 0 && (typeof strategy.strategyPackage !== "string" || !strategy.strategyPackage.trim()) || strategy.strategyPackageVersion !== void 0 && (typeof strategy.strategyPackageVersion !== "string" || !strategy.strategyPackageVersion.trim()) || strategy.strategyPackage === void 0 !== (strategy.strategyPackageVersion === void 0)) {
37
42
  return false;
38
43
  }
39
44
  strategyNames.add(strategy.strategyName);
@@ -43,6 +48,7 @@ var isRuntimeDeploymentCompositionEvent = (value) => {
43
48
  var observeRuntimeDeploymentComposition = async ({
44
49
  userName,
45
50
  deployment,
51
+ strategies,
46
52
  observedAt = Date.now()
47
53
  }) => {
48
54
  if (!Number.isFinite(observedAt) || observedAt < 0) {
@@ -54,7 +60,9 @@ var observeRuntimeDeploymentComposition = async ({
54
60
  deploymentId
55
61
  );
56
62
  const current = await getData(stateKey, null);
57
- if (isRuntimeDeploymentCompositionEvent(current) && current.deploymentId === deploymentId && current.deploymentCompositionId === deployment.deploymentCompositionId) {
63
+ if (isRuntimeDeploymentCompositionEvent(current) && current.deploymentId === deploymentId && current.deploymentCompositionId === deployment.deploymentCompositionId && current.strategies.every(
64
+ (strategy) => strategy.strategyPackage !== void 0 && strategy.strategyPackageVersion !== void 0
65
+ )) {
58
66
  return null;
59
67
  }
60
68
  const event = {
@@ -63,10 +71,19 @@ var observeRuntimeDeploymentComposition = async ({
63
71
  deploymentId,
64
72
  deploymentCompositionId: deployment.deploymentCompositionId,
65
73
  observedAt,
66
- strategies: deployment.strategies.map(({ strategyName, strategyRevision }) => ({
67
- strategyName,
68
- strategyRevision
69
- })).sort(
74
+ strategies: strategies.map(
75
+ ({
76
+ strategyName,
77
+ strategyRevision,
78
+ strategyPackage,
79
+ strategyPackageVersion
80
+ }) => ({
81
+ strategyName,
82
+ strategyRevision,
83
+ strategyPackage,
84
+ strategyPackageVersion
85
+ })
86
+ ).sort(
70
87
  (left, right) => left.strategyName.localeCompare(right.strategyName)
71
88
  )
72
89
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tradejs/infra",
3
- "version": "3.1.28-beta.254",
3
+ "version": "3.1.28-beta.255",
4
4
  "description": "MIT-licensed server infrastructure adapters for TradeJS: Redis, Timescale, ML, logging, and IO.",
5
5
  "keywords": [
6
6
  "tradejs",
@@ -135,7 +135,7 @@
135
135
  "dependencies": {
136
136
  "@grpc/grpc-js": "^1.14.4",
137
137
  "@grpc/proto-loader": "^0.8.1",
138
- "@tradejs/types": "^3.1.28-beta.254",
138
+ "@tradejs/types": "^3.1.28-beta.255",
139
139
  "chalk": "4.1.2",
140
140
  "date-fns": "^3.6.0",
141
141
  "ioredis": "5.11.1",