@platforma-sdk/model 1.29.12 → 1.29.13
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/components/PFrameForGraphs.d.ts.map +1 -1
- package/dist/components/PlDataTable.d.ts +2 -4
- package/dist/components/PlDataTable.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +333 -319
- package/dist/index.mjs.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +5 -5
- package/src/components/PFrameForGraphs.test.ts +37 -0
- package/src/components/PFrameForGraphs.ts +21 -7
- package/src/components/PlDataTable.ts +13 -6
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const PlatformaSDKVersion = "1.29.
|
|
1
|
+
export declare const PlatformaSDKVersion = "1.29.13";
|
|
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.
|
|
3
|
+
"version": "1.29.13",
|
|
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-
|
|
25
|
-
"@milaboratories/pl-
|
|
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-
|
|
35
|
-
"@
|
|
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
|
|
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
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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
|
-
|
|
195
|
+
secondaryColumnsBySpec.set(spec, secondaryColumn);
|
|
183
196
|
break;
|
|
184
197
|
}
|
|
185
198
|
}
|
|
186
199
|
}
|
|
187
|
-
|
|
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 =
|
|
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
|
-
|
|
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 */
|