@platforma-sdk/model 1.33.17 → 1.34.0

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.33.17";
1
+ export declare const PlatformaSDKVersion = "1.34.0";
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,YAAY,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,WAAW,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platforma-sdk/model",
3
- "version": "1.33.17",
3
+ "version": "1.34.0",
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.1",
25
- "@milaboratories/pl-model-common": "^1.15.5"
24
+ "@milaboratories/pl-model-common": "^1.15.5",
25
+ "@milaboratories/pl-error-like": "^1.12.1"
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
- "@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",
@@ -1,71 +1,56 @@
1
- import type {
2
- CanonicalizedJson,
3
- PColumn,
4
- PColumnIdAndSpec,
5
- PColumnKey,
6
- PColumnValues,
7
- PColumnValuesEntry,
8
- PObjectId,
9
- PTableColumnId,
10
- } from '@milaboratories/pl-model-common';
11
1
  import {
12
- canonicalizeJson,
13
2
  isPTableAbsent,
3
+ type PColumn,
4
+ type PColumnIdAndSpec,
5
+ type PColumnKey,
6
+ type PColumnValues,
7
+ type PObjectId,
8
+ type PTableColumnId,
9
+ uniquePlId,
14
10
  } from '@milaboratories/pl-model-common';
15
- import type { PlSelectionModel } from './PlSelectionModel';
16
-
17
- /** Canonicalized PTableColumnId JSON string */
18
- export type PTableColumnIdJson = CanonicalizedJson<PTableColumnId>;
19
-
20
- /** Encode `PTableColumnId` as canonicalized JSON string */
21
- export function stringifyPTableColumnId(
22
- id: PTableColumnId,
23
- ): PTableColumnIdJson {
24
- const type = id.type;
25
- switch (type) {
26
- case 'axis':
27
- return canonicalizeJson(id);
28
- case 'column':
29
- return canonicalizeJson(id);
30
- default:
31
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
32
- throw Error(`unsupported column type: ${type satisfies never}`);
33
- }
34
- }
11
+ import { type PlSelectionModel } from './PlSelectionModel';
35
12
 
36
13
  export type PColumnPredicate = (column: PColumnIdAndSpec) => boolean;
37
14
 
38
15
  export type PlMultiSequenceAlignmentModel = {
16
+ version?: number;
39
17
  sequenceColumnIds?: PObjectId[];
40
- labelColumnIds?: PTableColumnIdJson[];
18
+ labelColumnIds?: PTableColumnId[];
41
19
  };
42
20
 
43
- export function createRowSelectionColumn(
44
- columnId: PObjectId,
45
- rowSelectionModel: PlSelectionModel | undefined,
46
- label?: string,
47
- domain?: Record<string, string>,
48
- ): PColumn<PColumnValues> | undefined {
49
- if (!rowSelectionModel || rowSelectionModel.axesSpec.length === 0) {
50
- return undefined;
21
+ export function createRowSelectionColumn({
22
+ selection,
23
+ columnId = uniquePlId() as string as PObjectId,
24
+ label = 'Selection marker',
25
+ domain,
26
+ }: {
27
+ selection: PlSelectionModel | undefined;
28
+ columnId?: PObjectId;
29
+ label?: string;
30
+ domain?: Record<string, string>;
31
+ }): PColumn<PColumnValues> | undefined {
32
+ if (!selection?.axesSpec.length) {
33
+ return;
34
+ }
35
+ const data: PColumnValues = selection.selectedKeys
36
+ .filter((r): r is PColumnKey => r.every((v) => !isPTableAbsent(v)))
37
+ .map((r) => ({ key: r, val: 1 }));
38
+ if (!data.length) {
39
+ return;
51
40
  }
52
-
53
41
  return {
54
42
  id: columnId,
55
43
  spec: {
56
44
  kind: 'PColumn',
57
45
  valueType: 'Int',
58
46
  name: 'pl7.app/table/row-selection',
59
- axesSpec: rowSelectionModel.axesSpec,
60
- ...(domain && { domain }),
47
+ axesSpec: selection.axesSpec,
48
+ ...(domain && Object.keys(domain).length && { domain }),
61
49
  annotations: {
62
- 'pl7.app/label': label ?? 'Selected rows',
50
+ 'pl7.app/label': label,
63
51
  'pl7.app/discreteValues': '[1]',
64
52
  },
65
53
  },
66
- data: rowSelectionModel
67
- .selectedKeys
68
- .filter((r): r is PColumnKey => !r.some((v) => isPTableAbsent(v)))
69
- .map((r) => ({ key: r, val: 1 } satisfies PColumnValuesEntry)),
70
- } satisfies PColumn<PColumnValues>;
54
+ data,
55
+ };
71
56
  }