@platforma-sdk/model 1.30.11 → 1.30.21

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/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const PlatformaSDKVersion = "1.30.11";
1
+ export declare const PlatformaSDKVersion = "1.30.21";
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.30.11",
3
+ "version": "1.30.21",
4
4
  "description": "Platforma.bio SDK / Block Model",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",
@@ -21,7 +21,7 @@
21
21
  "utility-types": "^3.11.0",
22
22
  "canonicalize": "~2.1.0",
23
23
  "zod": "~3.23.8",
24
- "@milaboratories/pl-model-common": "^1.14.0",
24
+ "@milaboratories/pl-model-common": "^1.14.1",
25
25
  "@milaboratories/pl-error-like": "^1.12.1"
26
26
  },
27
27
  "devDependencies": {
@@ -1,12 +1,14 @@
1
1
  import type {
2
2
  AxisId,
3
3
  CanonicalizedJson,
4
+ DataInfo,
4
5
  PColumn,
6
+ PColumnSpec,
5
7
  PColumnSpecId,
6
8
  PColumnValues,
7
9
  PFrameHandle,
8
10
  PObjectId,
9
- ValueType } from '@milaboratories/pl-model-common';
11
+ } from '@milaboratories/pl-model-common';
10
12
  import {
11
13
  canonicalizeJson,
12
14
  getAxisId,
@@ -49,21 +51,21 @@ function getKeysCombinations(idsLists: AxisId[][]) {
49
51
 
50
52
  /** Check if axes of secondary column are exactly in axes of main column */
51
53
  function checkFullCompatibility(
52
- mainColumn: PColumn<TreeNodeAccessor | PColumnValues>,
53
- secondaryColumn: PColumn<TreeNodeAccessor | PColumnValues>,
54
+ mainColumn: PColumnSpec,
55
+ secondaryColumn: PColumnSpec,
54
56
  ): boolean {
55
- const mainAxesIds = mainColumn.spec.axesSpec.map(getAxisId);
56
- const secondaryAxesIds = secondaryColumn.spec.axesSpec.map(getAxisId);
57
+ const mainAxesIds = mainColumn.axesSpec.map(getAxisId);
58
+ const secondaryAxesIds = secondaryColumn.axesSpec.map(getAxisId);
57
59
  return secondaryAxesIds.every((id) => mainAxesIds.some((mainId) => matchAxisId(mainId, id) && matchAxisId(id, mainId)));
58
60
  }
59
61
 
60
62
  /** Check if axes of secondary column are in axes of main column, but they can have compatible difference in domains */
61
63
  function checkCompatibility(
62
- mainColumn: PColumn<TreeNodeAccessor | PColumnValues>,
63
- secondaryColumn: PColumn<TreeNodeAccessor | PColumnValues>,
64
+ mainColumn: PColumnSpec,
65
+ secondaryColumn: PColumnSpec,
64
66
  ): boolean {
65
- const mainAxesIds = mainColumn.spec.axesSpec.map(getAxisId);
66
- const secondaryAxesIds = secondaryColumn.spec.axesSpec.map(getAxisId);
67
+ const mainAxesIds = mainColumn.axesSpec.map(getAxisId);
68
+ const secondaryAxesIds = secondaryColumn.axesSpec.map(getAxisId);
67
69
  return secondaryAxesIds.every((id) => mainAxesIds.some((mainId) => matchAxisId(mainId, id)));
68
70
  }
69
71
 
@@ -73,17 +75,17 @@ export const LABEL_ANNOTATION = 'pl7.app/label';
73
75
  /** Main column can have additional domains, if secondary column (meta-column) has all axes match main column axes
74
76
  we can add its copy with missed domain fields for compatibility */
75
77
  function getAdditionalColumnsForPair(
76
- mainColumn: PColumn<TreeNodeAccessor | PColumnValues>,
77
- secondaryColumn: PColumn<TreeNodeAccessor | PColumnValues>,
78
- ): PColumn<TreeNodeAccessor | PColumnValues>[] {
78
+ mainColumn: PColumn<TreeNodeAccessor | DataInfo<TreeNodeAccessor> | PColumnValues>,
79
+ secondaryColumn: PColumn<TreeNodeAccessor | DataInfo<TreeNodeAccessor> | PColumnValues>,
80
+ ): PColumn<TreeNodeAccessor | DataInfo<TreeNodeAccessor> | PColumnValues>[] {
79
81
  const mainAxesIds = mainColumn.spec.axesSpec.map(getAxisId);
80
82
  const secondaryAxesIds = secondaryColumn.spec.axesSpec.map(getAxisId);
81
83
 
82
- const isFullCompatible = checkFullCompatibility(mainColumn, secondaryColumn);
84
+ const isFullCompatible = checkFullCompatibility(mainColumn.spec, secondaryColumn.spec);
83
85
  if (isFullCompatible) { // in this case it isn't necessary to add more columns
84
86
  return [];
85
87
  }
86
- const isCompatible = checkCompatibility(mainColumn, secondaryColumn);
88
+ const isCompatible = checkCompatibility(mainColumn.spec, secondaryColumn.spec);
87
89
  if (!isCompatible) { // in this case it is impossible to add some compatible column
88
90
  return [];
89
91
  }
@@ -155,8 +157,10 @@ function getAdditionalColumnsForPair(
155
157
  });
156
158
  }
157
159
 
158
- export function getAdditionalColumns(columns: PColumn<TreeNodeAccessor | PColumnValues>[]): PColumn<TreeNodeAccessor | PColumnValues>[] {
159
- const additionalColumns: PColumn<TreeNodeAccessor | PColumnValues>[] = [];
160
+ export function getAdditionalColumns(
161
+ columns: PColumn<TreeNodeAccessor | DataInfo<TreeNodeAccessor> | PColumnValues>[],
162
+ ): PColumn<TreeNodeAccessor | DataInfo<TreeNodeAccessor> | PColumnValues>[] {
163
+ const additionalColumns: PColumn<TreeNodeAccessor | DataInfo<TreeNodeAccessor> | PColumnValues>[] = [];
160
164
  for (let i = 0; i < columns.length; i++) {
161
165
  for (let j = i + 1; j < columns.length; j++) {
162
166
  const column1 = columns[i];
@@ -173,9 +177,9 @@ export function getAdditionalColumns(columns: PColumn<TreeNodeAccessor | PColumn
173
177
  }
174
178
 
175
179
  export function enrichColumnsWithCompatible(
176
- mainColumns: PColumn<TreeNodeAccessor | PColumnValues>[],
177
- secondaryColumns: PColumn<TreeNodeAccessor | PColumnValues>[],
178
- ): PColumn<TreeNodeAccessor | PColumnValues>[] {
180
+ mainColumns: PColumn<TreeNodeAccessor | DataInfo<TreeNodeAccessor> | PColumnValues>[],
181
+ secondaryColumns: PColumn<TreeNodeAccessor | DataInfo<TreeNodeAccessor> | PColumnValues>[],
182
+ ): PColumn<TreeNodeAccessor | DataInfo<TreeNodeAccessor> | PColumnValues>[] {
179
183
  const mainColumnsIds = new Set<PObjectId>();
180
184
  const mainColumnsBySpec = new Map<CanonicalizedJson<PColumnSpecId>, typeof mainColumns[number]>();
181
185
  mainColumns.forEach((column) => {
@@ -191,7 +195,7 @@ export function enrichColumnsWithCompatible(
191
195
  if (mainColumnsBySpec.has(spec)) continue;
192
196
 
193
197
  for (const mainColumn of mainColumnsBySpec.values()) {
194
- if (checkCompatibility(mainColumn, secondaryColumn)) {
198
+ if (checkCompatibility(mainColumn.spec, secondaryColumn.spec)) {
195
199
  secondaryColumnsBySpec.set(spec, secondaryColumn);
196
200
  break;
197
201
  }
@@ -201,26 +205,16 @@ export function enrichColumnsWithCompatible(
201
205
  return [...mainColumnsBySpec.values(), ...secondaryColumnsBySpec.values()];
202
206
  }
203
207
 
204
- const VALUE_TYPES: ValueType[] = [
205
- 'Int',
206
- 'Long',
207
- 'Float',
208
- 'Double',
209
- 'String',
210
- 'Bytes',
211
- ];
212
-
213
208
  export function createPFrameForGraphs<A, U>(
214
209
  ctx: RenderCtx<A, U>,
215
- blockColumns?: PColumn<TreeNodeAccessor | PColumnValues>[],
210
+ blockColumns: PColumn<TreeNodeAccessor | DataInfo<TreeNodeAccessor> | PColumnValues>[] | undefined,
216
211
  ): PFrameHandle | undefined {
217
- if (blockColumns === undefined) return undefined;
212
+ if (!blockColumns) return undefined;
218
213
 
219
214
  const upstreamColumns = ctx.resultPool
220
215
  .getData()
221
216
  .entries.map((v) => v.obj)
222
- .filter(isPColumn)
223
- .filter((column) => VALUE_TYPES.includes(column.spec.valueType));
217
+ .filter(isPColumn);
224
218
 
225
219
  const columnsWithCompatibleFromUpstream = enrichColumnsWithCompatible(blockColumns, upstreamColumns);
226
220
 
@@ -25,7 +25,7 @@ export const TraceEntry = z.object({
25
25
  label: z.string(),
26
26
  });
27
27
  export type TraceEntry = z.infer<typeof TraceEntry>;
28
- type FullTraceEntry = TraceEntry & { fullType: string; occurenceIndex: number };
28
+ type FullTraceEntry = TraceEntry & { fullType: string; occurrenceIndex: number };
29
29
 
30
30
  export const Trace = z.array(TraceEntry);
31
31
  export type Trace = z.infer<typeof Trace>;
@@ -50,7 +50,7 @@ export function deriveLabels<T>(
50
50
  ): RecordsWithLabel<T>[] {
51
51
  const importances = new Map<string, number>();
52
52
 
53
- // number of times certain type occured among all of the
53
+ // number of times certain type occurred among all of the
54
54
  const numberOfRecordsWithType = new Map<string, number>();
55
55
 
56
56
  const enrichedRecords = values.map((value) => {
@@ -88,13 +88,13 @@ export function deriveLabels<T>(
88
88
 
89
89
  const fullTrace: FullTrace = [];
90
90
 
91
- const occurences = new Map<string, number>();
91
+ const occurrences = new Map<string, number>();
92
92
  for (let i = trace.length - 1; i >= 0; --i) {
93
93
  const { type: typeName } = trace[i];
94
94
  const importance = trace[i].importance ?? 0;
95
- const occurenceIndex = (occurences.get(typeName) ?? 0) + 1;
96
- occurences.set(typeName, occurenceIndex);
97
- const fullType = `${typeName}@${occurenceIndex}`;
95
+ const occurrenceIndex = (occurrences.get(typeName) ?? 0) + 1;
96
+ occurrences.set(typeName, occurrenceIndex);
97
+ const fullType = `${typeName}@${occurrenceIndex}`;
98
98
  numberOfRecordsWithType.set(fullType, (numberOfRecordsWithType.get(fullType) ?? 0) + 1);
99
99
  importances.set(
100
100
  fullType,
@@ -103,7 +103,7 @@ export function deriveLabels<T>(
103
103
  importance - (trace.length - i) * DistancePenalty,
104
104
  ),
105
105
  );
106
- fullTrace.push({ ...trace[i], fullType, occurenceIndex });
106
+ fullTrace.push({ ...trace[i], fullType, occurrenceIndex: occurrenceIndex });
107
107
  }
108
108
  fullTrace.reverse();
109
109
  return {
@@ -160,27 +160,27 @@ export function deriveLabels<T>(
160
160
  // * *
161
161
  // T0 T1 T2 T3 T4 T5
162
162
  // *
163
- // additinalType = 3
163
+ // additionalType = 3
164
164
  //
165
165
  // Resulting set: T0, T1, T3
166
166
  //
167
167
  let includedTypes = 0;
168
- let additinalType = 0;
168
+ let additionalType = 0;
169
169
  while (includedTypes < mainTypes.length) {
170
170
  const currentSet = new Set<string>();
171
171
  if (ops.includeNativeLabel) currentSet.add(LabelTypeFull);
172
172
  for (let i = 0; i < includedTypes; ++i) currentSet.add(mainTypes[i]);
173
- currentSet.add(mainTypes[additinalType]);
173
+ currentSet.add(mainTypes[additionalType]);
174
174
 
175
175
  const candidateResult = calculate(currentSet);
176
176
 
177
177
  // checking if labels uniquely separate our records
178
178
  if (candidateResult !== undefined && new Set(candidateResult.map((c) => c.label)).size === values.length) return candidateResult;
179
179
 
180
- additinalType++;
181
- if (additinalType >= mainTypes.length) {
180
+ additionalType++;
181
+ if (additionalType >= mainTypes.length) {
182
182
  includedTypes++;
183
- additinalType = includedTypes;
183
+ additionalType = includedTypes;
184
184
  }
185
185
  }
186
186
 
package/src/version.ts DELETED
@@ -1 +0,0 @@
1
- export const PlatformaSDKVersion = '1.30.11';