@platforma-sdk/model 1.28.0 → 1.28.1

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 +1 @@
1
- {"version":3,"file":"label.d.ts","sourceRoot":"","sources":["../../../src/render/util/label.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,gBAAgB,kBAAkB,CAAC;AAChD,eAAO,MAAM,gBAAgB,kBAAkB,CAAC;AAEhD,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI;IAChC,KAAK,EAAE,CAAC,CAAC;IACT,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,6CAA6C;IAC7C,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sHAAsH;IACtH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;EAKrB,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAGpD,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;WAAsB,CAAC;AACzC,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,KAAK,CAAC,CAAC;AAI1C,KAAK,mBAAmB,GAAG,WAAW,GAAG;IACvC,IAAI,EAAE,WAAW,CAAC;IAClB,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;CAC5B,CAAC;AAOF,wBAAgB,YAAY,CAAC,CAAC,EAC5B,MAAM,EAAE,CAAC,EAAE,EACX,aAAa,EAAE,CAAC,GAAG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BAAmB,EAC9C,GAAG,GAAE,kBAAuB,GAC3B,gBAAgB,CAAC,CAAC,CAAC,EAAE,CA6IvB"}
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const PlatformaSDKVersion = "1.28.0";
1
+ export declare const PlatformaSDKVersion = "1.28.1";
2
2
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platforma-sdk/model",
3
- "version": "1.28.0",
3
+ "version": "1.28.1",
4
4
  "description": "Platforma.bio SDK / Block Model",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",
@@ -31,8 +31,8 @@
31
31
  "jest": "^29.7.0",
32
32
  "@jest/globals": "^29.7.0",
33
33
  "ts-jest": "^29.2.6",
34
- "@milaboratories/platforma-build-configs": "1.0.3",
35
- "@platforma-sdk/eslint-config": "1.0.3"
34
+ "@platforma-sdk/eslint-config": "1.0.3",
35
+ "@milaboratories/platforma-build-configs": "1.0.3"
36
36
  },
37
37
  "scripts": {
38
38
  "type-check": "node ./scripts/save-package-version.cjs && tsc --noEmit --composite false",
@@ -82,6 +82,28 @@ test.each<{ name: string; traces: Trace[]; labels: string[] }>([
82
82
  ]
83
83
  ],
84
84
  labels: ['T1L1 / T2L1', 'T1L1 / T2L2', 'T1L2 / T2L2']
85
+ },
86
+ {
87
+ name: 'different importance and id',
88
+ traces: [
89
+ [{ type: 'sameType', importance: 10, id: 'id1', label: 'High importance' }],
90
+ [{ type: 'sameType', importance: 5, id: 'id2', label: 'Low importance' }]
91
+ ],
92
+ labels: ['High importance', 'Low importance']
93
+ },
94
+ {
95
+ name: 'mixed common and different entries',
96
+ traces: [
97
+ [
98
+ { type: 'commonType', importance: 1, id: 'common', label: 'Common entry' },
99
+ { type: 'uniqueType', importance: 10, id: 'id1', label: 'Unique entry 1' }
100
+ ],
101
+ [
102
+ { type: 'commonType', importance: 1, id: 'common', label: 'Common entry' },
103
+ { type: 'uniqueType', importance: 5, id: 'id2', label: 'Unique entry 2' }
104
+ ]
105
+ ],
106
+ labels: ['Unique entry 1', 'Unique entry 2']
85
107
  }
86
108
  ])('test label derivation: $name', ({ name, traces, labels }) => {
87
109
  expect(deriveLabels(tracesToSpecs(traces), (s) => s).map((r) => r.label)).toEqual(labels);
@@ -129,21 +129,30 @@ export function deriveLabels<T>(
129
129
  else secondaryTypes.push(typeName);
130
130
  }
131
131
 
132
- const calculate = (includedTypes: Set<string>) =>
133
- enrichedRecords.map((r) => {
134
- const labelSet = r.fullTrace
135
- .filter((fm) => includedTypes.has(fm.fullType))
132
+ const calculate = (includedTypes: Set<string>) => {
133
+ const result: RecordsWithLabel<T>[] = [];
134
+ for (let i = 0; i < enrichedRecords.length; i++) {
135
+ const r = enrichedRecords[i];
136
+ const includedTrace = r.fullTrace
137
+ .filter((fm) => includedTypes.has(fm.fullType));
138
+ if (includedTrace.length === 0)
139
+ return undefined;
140
+ const labelSet = includedTrace
136
141
  .map((fm) => fm.label);
137
142
  const sep = ops.separator ?? ' / ';
138
- return {
143
+ result.push({
139
144
  label: labelSet.join(sep),
140
145
  value: r.value,
141
- } satisfies RecordsWithLabel<T>;
142
- });
146
+ } satisfies RecordsWithLabel<T>);
147
+ }
148
+ return result;
149
+ };
143
150
 
144
151
  if (mainTypes.length === 0) {
145
152
  if (secondaryTypes.length !== 0) throw new Error('Assertion error.');
146
- return calculate(new Set(LabelTypeFull));
153
+ const result = calculate(new Set(LabelTypeFull));
154
+ if (result === undefined) throw new Error('Assertion error.');
155
+ return result;
147
156
  }
148
157
 
149
158
  //
@@ -164,6 +173,7 @@ export function deriveLabels<T>(
164
173
  currentSet.add(mainTypes[additinalType]);
165
174
 
166
175
  const candidateResult = calculate(currentSet);
176
+ if (candidateResult === undefined) continue; // one of the records has empty matching trace
167
177
 
168
178
  // checking if labels uniquely separate our records
169
179
  if (new Set(candidateResult.map((c) => c.label)).size === values.length) return candidateResult;
@@ -175,5 +185,7 @@ export function deriveLabels<T>(
175
185
  }
176
186
  }
177
187
 
178
- return calculate(new Set([...mainTypes, ...secondaryTypes]));
188
+ const result = calculate(new Set([...mainTypes, ...secondaryTypes]));
189
+ if (result === undefined) throw new Error('Assertion error.');
190
+ return result;
179
191
  }