@platforma-sdk/model 1.29.12 → 1.29.14

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.
@@ -25,9 +25,8 @@ export type PColumnKeyList = {
25
25
  /** Returns a list of all partition keys appeared in the p-column */
26
26
  export declare function getPartitionKeysList(acc: TreeNodeAccessor | undefined): PColumnKeyList | undefined;
27
27
  /** Returns an array of unique partition keys for each column: the i-th element in the resulting 2d array contains all unique values of i-th partition axis. */
28
- export declare function getUniquePartitionKeys(acc: undefined): undefined;
29
28
  export declare function getUniquePartitionKeys(acc: DataInfoEntries<unknown>): (string | number)[][];
30
- export declare function getUniquePartitionKeys(acc: TreeNodeAccessor): (string | number)[][] | undefined;
29
+ export declare function getUniquePartitionKeys(acc: DataInfoEntries<unknown> | TreeNodeAccessor | undefined): (string | number)[][] | undefined;
31
30
  /**
32
31
  * Parses the PColumn data from a TreeNodeAccessor into a DataInfoEntries structure.
33
32
  * Returns undefined if any required data is missing.
@@ -1 +1 @@
1
- {"version":3,"file":"pcolumn_data.d.ts","sourceRoot":"","sources":["../../../src/render/util/pcolumn_data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AACpD,OAAO,EAKL,KAAK,gCAAgC,EACrC,KAAK,eAAe,EACpB,KAAK,8BAA8B,EAEnC,KAAK,UAAU,EAChB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAI/C,eAAO,MAAM,eAAe,QAA6B,CAAC;AAC1D,eAAO,MAAM,2BAA2B,QAAyC,CAAC;AAElF,eAAO,MAAM,mBAAmB,QAAiC,CAAC;AAClE,eAAO,MAAM,qBAAqB,QAAmC,CAAC;AAGtE,eAAO,MAAM,yBAAyB,QAAqC,CAAC;AAC5E,eAAO,MAAM,2BAA2B,QAAuC,CAAC;AAEhF,MAAM,MAAM,uBAAuB,CAAC,CAAC,IAAI;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eAAe,CAAC,gBAAgB,CAAC,GAAG,QAAQ,CAAC,gBAAgB,CAAC,GAAG,SAAS,GAC5I,eAAe,CAAC,gBAAgB,CAAC,GAAG,SAAS,CAQ5C"}
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const PlatformaSDKVersion = "1.29.12";
1
+ export declare const PlatformaSDKVersion = "1.29.14";
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.29.12",
3
+ "version": "1.29.14",
4
4
  "description": "Platforma.bio SDK / Block Model",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",
@@ -21,8 +21,8 @@
21
21
  "utility-types": "^3.11.0",
22
22
  "canonicalize": "~2.1.0",
23
23
  "zod": "~3.23.8",
24
- "@milaboratories/pl-error-like": "^1.12.0",
25
- "@milaboratories/pl-model-common": "^1.13.6"
24
+ "@milaboratories/pl-model-common": "^1.13.7",
25
+ "@milaboratories/pl-error-like": "^1.12.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "typescript": "~5.5.4",
@@ -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
- "@platforma-sdk/eslint-config": "1.0.3",
35
- "@milaboratories/platforma-build-configs": "1.0.3"
34
+ "@milaboratories/platforma-build-configs": "1.0.3",
35
+ "@platforma-sdk/eslint-config": "1.0.3"
36
36
  },
37
37
  "scripts": {
38
38
  "type-check": "node ./scripts/save-package-version.cjs && tsc --noEmit --composite false",
@@ -187,6 +187,43 @@ describe('PFrameForGraph', () => {
187
187
  expect(enrichedColumns.map((c) => c.id)).toEqual(['id1', 'id2', 'id3'])
188
188
  })
189
189
 
190
+ test('enrichColumnsWithCompatibleMetadata doesn\'t add column with identical spec', () => {
191
+ const columnSpec1: PColumnSpec = {
192
+ kind: 'PColumn',
193
+ name: 'column1',
194
+ valueType: 'Int',
195
+ axesSpec: [
196
+ {type: 'String', name: 'axis1', domain: {key1: 'a'}},
197
+ {type: 'String', name: 'axis2', domain: {key1: 'b'}},
198
+ ]
199
+ };
200
+ const metaColumnSpec1: PColumnSpec = {
201
+ kind: 'PColumn',
202
+ name: 'metadata1',
203
+ valueType: 'Int',
204
+ axesSpec: [{type: 'String', name: 'axis1'}]
205
+ };
206
+ const metaColumnSpec2: PColumnSpec = {
207
+ kind: 'PColumn',
208
+ name: 'metadata2',
209
+ valueType: 'String',
210
+ axesSpec: [{type: 'String', name: 'axis1', domain: {key1: 'a'}}]
211
+ };
212
+
213
+ const columns: PColumn<TreeNodeAccessor | PColumnValues>[] = [
214
+ {id: 'id1' as PObjectId, spec: columnSpec1, data: []},
215
+ ] as PColumn<PColumnValues>[];
216
+ const upstream: PColumn<TreeNodeAccessor | PColumnValues>[] = [
217
+ {id: 'id2' as PObjectId, spec: columnSpec1, data: []},
218
+ {id: 'id3' as PObjectId, spec: metaColumnSpec1, data: []},
219
+ {id: 'id4' as PObjectId, spec: metaColumnSpec2, data: []},
220
+ ] as PColumn<PColumnValues>[];
221
+
222
+ const enrichedColumns = enrichColumnsWithCompatible(columns, upstream);
223
+ expect(enrichedColumns.map((c) => c.id)).toEqual(['id1', 'id3', 'id4'])
224
+ })
225
+
226
+
190
227
  test('Labels of added columns include added domains, but not include common domains', () => {
191
228
  const columnSpec1: PColumnSpec = {
192
229
  kind: 'PColumn',
@@ -1,12 +1,16 @@
1
1
  import type {
2
2
  AxisId,
3
+ CanonicalizedJson,
3
4
  PColumn,
5
+ PColumnSpecId,
4
6
  PColumnValues,
5
7
  PFrameHandle,
6
8
  PObjectId,
7
9
  ValueType } from '@milaboratories/pl-model-common';
8
10
  import {
11
+ canonicalizeJson,
9
12
  getAxisId,
13
+ getPColumnSpecId,
10
14
  isPColumn,
11
15
  matchAxisId,
12
16
  } from '@milaboratories/pl-model-common';
@@ -172,19 +176,29 @@ export function enrichColumnsWithCompatible(
172
176
  mainColumns: PColumn<TreeNodeAccessor | PColumnValues>[],
173
177
  secondaryColumns: PColumn<TreeNodeAccessor | PColumnValues>[],
174
178
  ): PColumn<TreeNodeAccessor | PColumnValues>[] {
175
- const result = [...mainColumns];
179
+ const mainColumnsIds = new Set<PObjectId>();
180
+ const mainColumnsBySpec = new Map<CanonicalizedJson<PColumnSpecId>, typeof mainColumns[number]>();
181
+ mainColumns.forEach((column) => {
182
+ mainColumnsIds.add(column.id);
183
+ mainColumnsBySpec.set(canonicalizeJson(getPColumnSpecId(column.spec)), column);
184
+ });
185
+
186
+ const secondaryColumnsBySpec = new Map<CanonicalizedJson<PColumnSpecId>, typeof secondaryColumns[number]>();
176
187
  for (const secondaryColumn of secondaryColumns) {
177
- for (const mainColumn of mainColumns) {
178
- if (mainColumn.id === secondaryColumn.id) {
179
- break;
180
- }
188
+ if (mainColumnsIds.has(secondaryColumn.id)) continue;
189
+
190
+ const spec = canonicalizeJson(getPColumnSpecId(secondaryColumn.spec));
191
+ if (mainColumnsBySpec.has(spec)) continue;
192
+
193
+ for (const mainColumn of mainColumnsBySpec.values()) {
181
194
  if (checkCompatibility(mainColumn, secondaryColumn)) {
182
- result.push(secondaryColumn);
195
+ secondaryColumnsBySpec.set(spec, secondaryColumn);
183
196
  break;
184
197
  }
185
198
  }
186
199
  }
187
- return result;
200
+
201
+ return [...mainColumnsBySpec.values(), ...secondaryColumnsBySpec.values()];
188
202
  }
189
203
 
190
204
  const VALUE_TYPES: ValueType[] = [
@@ -1,5 +1,6 @@
1
1
  import type {
2
2
  AxisSpec,
3
+ CanonicalizedJson,
3
4
  DataInfo,
4
5
  JoinEntry,
5
6
  PColumn,
@@ -15,19 +16,25 @@ import type {
15
16
  PTableRecordSingleValueFilterV2,
16
17
  PTableSorting,
17
18
  } from '@milaboratories/pl-model-common';
18
- import { getAxisId, getColumnIdAndSpec, matchAxisId } from '@milaboratories/pl-model-common';
19
+ import { canonicalizeJson, getAxisId, getColumnIdAndSpec, matchAxisId } from '@milaboratories/pl-model-common';
19
20
  import type { AxisLabelProvider, ColumnProvider, RenderCtx } from '../render';
20
21
  import { PColumnCollection, TreeNodeAccessor } from '../render';
21
- import canonicalize from 'canonicalize';
22
22
 
23
23
  /** Canonicalized PTableColumnSpec JSON string */
24
- export type PTableColumnSpecJson = string & {
25
- __json_canonicalized: PTableColumnSpec;
26
- };
24
+ export type PTableColumnSpecJson = CanonicalizedJson<PTableColumnSpec>;
27
25
 
28
26
  /** Encode `PTableColumnId` as canonicalized JSON string */
29
27
  export function strinfigyPTableColumnId(spec: PTableColumnSpec): PTableColumnSpecJson {
30
- return canonicalize(spec)! as PTableColumnSpecJson;
28
+ const type = spec.type;
29
+ switch (type) {
30
+ case 'axis':
31
+ return canonicalizeJson(spec);
32
+ case 'column':
33
+ return canonicalizeJson(spec);
34
+ default:
35
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
36
+ throw Error(`unsupported column type: ${type satisfies never}`);
37
+ }
31
38
  }
32
39
 
33
40
  /** Parse `PTableColumnId` from JSON string */
@@ -215,9 +215,8 @@ function getUniquePartitionKeysForDataEntries(list: DataInfoEntries<unknown>): (
215
215
  }
216
216
 
217
217
  /** Returns an array of unique partition keys for each column: the i-th element in the resulting 2d array contains all unique values of i-th partition axis. */
218
- export function getUniquePartitionKeys(acc: undefined): undefined;
219
218
  export function getUniquePartitionKeys(acc: DataInfoEntries<unknown>): (string | number)[][];
220
- export function getUniquePartitionKeys(acc: TreeNodeAccessor): (string | number)[][] | undefined;
219
+ export function getUniquePartitionKeys(acc: DataInfoEntries<unknown> | TreeNodeAccessor | undefined): (string | number)[][] | undefined;
221
220
  export function getUniquePartitionKeys(
222
221
  acc: TreeNodeAccessor | DataInfoEntries<unknown> | undefined,
223
222
  ): (string | number)[][] | undefined {