@platforma-sdk/model 1.30.3 → 1.30.11

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.3";
1
+ export declare const PlatformaSDKVersion = "1.30.11";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,WAAW,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,YAAY,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platforma-sdk/model",
3
- "version": "1.30.3",
3
+ "version": "1.30.11",
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
- "@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",
@@ -1,4 +1,5 @@
1
1
  import type {
2
+ AxisId,
2
3
  AxisSpec,
3
4
  CanonicalizedJson,
4
5
  DataInfo,
@@ -365,7 +366,39 @@ export function getMatchingLabelColumns(
365
366
  columns: PColumnIdAndSpec[],
366
367
  allLabelColumns: PColumn<TreeNodeAccessor | DataInfo<TreeNodeAccessor>>[],
367
368
  ): PColumn<TreeNodeAccessor | DataInfo<TreeNodeAccessor>>[] {
368
- const colId = (id: PObjectId, domain?: Record<string, string>) => {
369
+ // split input columns into label and value columns
370
+ const inputLabelColumns: typeof columns = [];
371
+ const inputValueColumns: typeof columns = [];
372
+ for (const column of columns) {
373
+ if (isLabelColumn(column.spec)) {
374
+ inputLabelColumns.push(column);
375
+ } else {
376
+ inputValueColumns.push(column);
377
+ }
378
+ }
379
+
380
+ // collect distinct axes of value columns
381
+ const unlabeledAxes: AxisId[] = [];
382
+ for (const column of inputValueColumns) {
383
+ for (const axis of column.spec.axesSpec) {
384
+ const axisId = getAxisId(axis);
385
+ if (!unlabeledAxes.some((id) => matchAxisId(id, axisId))) {
386
+ unlabeledAxes.push(axisId);
387
+ }
388
+ }
389
+ }
390
+
391
+ // remove axes matched by input label columns
392
+ for (const labelColumn of inputLabelColumns) {
393
+ const labelAxisId = getAxisId(labelColumn.spec.axesSpec[0]);
394
+ const labelMatch = unlabeledAxes.findIndex((axisId) => matchAxisId(axisId, labelAxisId));
395
+ if (labelMatch !== -1) {
396
+ unlabeledAxes.splice(labelMatch, 1);
397
+ }
398
+ }
399
+
400
+ // warning: changing this id will break backward compatibility
401
+ const colId = (id: PObjectId, domain?: Record<string, string>): PObjectId => {
369
402
  let wid = id.toString();
370
403
  if (domain) {
371
404
  for (const k in domain) {
@@ -373,39 +406,35 @@ export function getMatchingLabelColumns(
373
406
  wid += domain[k];
374
407
  }
375
408
  }
376
- return wid;
409
+ return wid as PObjectId;
377
410
  };
378
411
 
379
- const labelColumns = new Map<string, typeof allLabelColumns[number]>();
380
- for (const col of columns) {
381
- for (const axis of col.spec.axesSpec) {
382
- const axisId = getAxisId(axis);
383
- for (const labelColumn of allLabelColumns) {
384
- const labelAxis = labelColumn.spec.axesSpec[0];
385
- const labelAxisId = getAxisId(labelColumn.spec.axesSpec[0]);
386
- if (matchAxisId(axisId, labelAxisId)) {
387
- const dataDomainLen = Object.keys(axisId.domain ?? {}).length;
388
- const labelDomainLen = Object.keys(labelAxisId.domain ?? {}).length;
389
- if (dataDomainLen > labelDomainLen) {
390
- const id = colId(labelColumn.id, axisId.domain);
391
-
392
- labelColumns.set(id, {
393
- id: id as PObjectId,
394
- spec: {
395
- ...labelColumn.spec,
396
- axesSpec: [{ ...axisId, annotations: labelAxis.annotations }],
397
- },
398
- data: labelColumn.data,
399
- });
400
- } else {
401
- labelColumns.set(colId(labelColumn.id), labelColumn);
402
- }
403
- }
412
+ // search label columns for unmatched axes
413
+ const labelColumns: typeof allLabelColumns = [];
414
+ for (const labelColumn of allLabelColumns) {
415
+ const labelAxis = labelColumn.spec.axesSpec[0];
416
+ const labelAxisId = getAxisId(labelAxis);
417
+ const labelMatch = unlabeledAxes.findIndex((axisId) => matchAxisId(axisId, labelAxisId));
418
+ if (labelMatch !== -1) {
419
+ const axisId = unlabeledAxes[labelMatch];
420
+ const dataDomainLen = Object.keys(axisId.domain ?? {}).length;
421
+ const labelDomainLen = Object.keys(labelAxis.domain ?? {}).length;
422
+ if (dataDomainLen > labelDomainLen) {
423
+ labelColumns.push({
424
+ id: colId(labelColumn.id, axisId.domain),
425
+ spec: {
426
+ ...labelColumn.spec,
427
+ axesSpec: [{ ...axisId, annotations: labelAxis.annotations }],
428
+ },
429
+ data: labelColumn.data,
430
+ });
431
+ } else {
432
+ labelColumns.push(labelColumn);
404
433
  }
434
+ unlabeledAxes.splice(labelMatch, 1);
405
435
  }
406
436
  }
407
-
408
- return [...labelColumns.values()];
437
+ return labelColumns;
409
438
  }
410
439
 
411
440
  /** Check if all columns are computed */
package/src/version.ts ADDED
@@ -0,0 +1 @@
1
+ export const PlatformaSDKVersion = '1.30.11';