@platforma-sdk/model 1.23.0 → 1.23.4
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 +1 -0
- package/dist/components/PFrameForGraphs.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +370 -346
- package/dist/index.mjs.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +3 -3
- package/src/components/PFrameForGraphs.test.ts +33 -1
- package/src/components/PFrameForGraphs.ts +47 -5
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const PlatformaSDKVersion = "1.23.
|
|
1
|
+
export declare const PlatformaSDKVersion = "1.23.4";
|
|
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.23.
|
|
3
|
+
"version": "1.23.4",
|
|
4
4
|
"description": "Platforma.bio SDK / Block Model",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"jest": "^29.7.0",
|
|
30
30
|
"@jest/globals": "^29.7.0",
|
|
31
31
|
"ts-jest": "^29.2.6",
|
|
32
|
-
"@platforma-
|
|
33
|
-
"@
|
|
32
|
+
"@milaboratories/platforma-build-configs": "1.0.2",
|
|
33
|
+
"@platforma-sdk/eslint-config": "1.0.1"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"type-check": "node ./scripts/save-package-version.cjs && tsc --noEmit --composite false",
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import {test, expect, describe} from '@jest/globals';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
enrichColumnsWithCompatible,
|
|
4
|
+
getAdditionalColumns,
|
|
5
|
+
IS_VIRTUAL_COLUMN,
|
|
6
|
+
LABEL_ANNOTATION
|
|
7
|
+
} from './PFrameForGraphs';
|
|
3
8
|
import {PColumn, PColumnSpec, PColumnValues, PObjectId} from "@milaboratories/pl-model-common";
|
|
4
9
|
import {TreeNodeAccessor} from "../render";
|
|
5
10
|
|
|
@@ -181,4 +186,31 @@ describe('PFrameForGraph', () => {
|
|
|
181
186
|
const enrichedColumns = enrichColumnsWithCompatible(columns, upstream);
|
|
182
187
|
expect(enrichedColumns.map((c) => c.id)).toEqual(['id1', 'id2', 'id3'])
|
|
183
188
|
})
|
|
189
|
+
|
|
190
|
+
test('Labels of added columns include added domains, but not include common domains', () => {
|
|
191
|
+
const columnSpec1: PColumnSpec = {
|
|
192
|
+
kind: 'PColumn',
|
|
193
|
+
name: 'column1',
|
|
194
|
+
valueType: 'Int',
|
|
195
|
+
axesSpec: [
|
|
196
|
+
{type: 'String', name: 'axis1', domain: {key0: 'commonDomain', key1: 'a', key2: 'c'}},
|
|
197
|
+
{type: 'String', name: 'axis1', domain: {key0: 'commonDomain', key1: 'b', key2: 'c'}},
|
|
198
|
+
]
|
|
199
|
+
}
|
|
200
|
+
const columnSpec2: PColumnSpec = {
|
|
201
|
+
kind: 'PColumn',
|
|
202
|
+
name: 'column2',
|
|
203
|
+
valueType: 'Int',
|
|
204
|
+
annotations: {[LABEL_ANNOTATION]: 'Label of column2'},
|
|
205
|
+
axesSpec: [{type: 'String', name: 'axis1', domain: {key0: 'commonDomain'}}]
|
|
206
|
+
}
|
|
207
|
+
const columns: PColumn<TreeNodeAccessor | PColumnValues>[] = [
|
|
208
|
+
{id: 'id1' as PObjectId, spec: columnSpec1, data: []},
|
|
209
|
+
{id: 'id2' as PObjectId, spec: columnSpec2, data: []}
|
|
210
|
+
] as PColumn<PColumnValues>[]
|
|
211
|
+
|
|
212
|
+
const additionalColumns = getAdditionalColumns(columns);
|
|
213
|
+
expect(additionalColumns[0].spec.annotations?.[LABEL_ANNOTATION]).toEqual('Label of column2 / a');
|
|
214
|
+
expect(additionalColumns[1].spec.annotations?.[LABEL_ANNOTATION]).toEqual('Label of column2 / b');
|
|
215
|
+
})
|
|
184
216
|
})
|
|
@@ -62,6 +62,7 @@ function checkCompatibility(
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
export const IS_VIRTUAL_COLUMN = 'pl7.app/graph/isVirtual'; // annotation for column duplicates with extended domains
|
|
65
|
+
export const LABEL_ANNOTATION = 'pl7.app/label';
|
|
65
66
|
|
|
66
67
|
/** Main column can have additional domains, if secondary column (meta-column) has all axes match main column axes
|
|
67
68
|
we can add its copy with missed domain fields for compatibility */
|
|
@@ -87,8 +88,52 @@ function getAdditionalColumnsForPair(
|
|
|
87
88
|
// all possible combinations of axes with added domains
|
|
88
89
|
const secondaryIdsVariants = getKeysCombinations(secondaryIdsOptions);
|
|
89
90
|
|
|
90
|
-
|
|
91
|
+
// sets of added to column domain fields
|
|
92
|
+
const allAddedDomainValues = new Set<string>();
|
|
93
|
+
const addedNotToAllVariantsDomainValues = new Set<string>();
|
|
94
|
+
const addedByVariantsDomainValues = secondaryIdsVariants.map(idsList => {
|
|
95
|
+
const addedSet = new Set<string>();
|
|
96
|
+
idsList.map((axisId, idx) => {
|
|
97
|
+
const d1 = secondaryColumn.spec.axesSpec[idx].domain;
|
|
98
|
+
const d2 = axisId.domain;
|
|
99
|
+
Object.entries(d2 ?? {}).forEach(([key, value]) => {
|
|
100
|
+
if (d1?.[key] === undefined) {
|
|
101
|
+
const item = JSON.stringify([key, value]);
|
|
102
|
+
addedSet.add(item);
|
|
103
|
+
allAddedDomainValues.add(item);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
return ({
|
|
107
|
+
...axisId,
|
|
108
|
+
annotations: secondaryColumn.spec.axesSpec[idx].annotations
|
|
109
|
+
})
|
|
110
|
+
});
|
|
111
|
+
return addedSet;
|
|
112
|
+
});
|
|
113
|
+
[...allAddedDomainValues].forEach(addedPart => {
|
|
114
|
+
if (addedByVariantsDomainValues.some(s => !s.has(addedPart))) {
|
|
115
|
+
addedNotToAllVariantsDomainValues.add(addedPart);
|
|
116
|
+
}
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
return secondaryIdsVariants.map((idsList, idx) => {
|
|
91
120
|
const id = colId(secondaryColumn.id, idsList.map(id => id.domain));
|
|
121
|
+
|
|
122
|
+
const label = secondaryColumn.spec.annotations?.[LABEL_ANNOTATION] ?? '';
|
|
123
|
+
const labelDomainPart = ([...addedByVariantsDomainValues[idx]])
|
|
124
|
+
.filter(str => addedNotToAllVariantsDomainValues.has(str))
|
|
125
|
+
.sort()
|
|
126
|
+
.map((v) => JSON.parse(v)?.[1]) // use in labels only domain values, but sort them by key to save the same order in all column variants
|
|
127
|
+
.join(' / ');
|
|
128
|
+
|
|
129
|
+
const annotations:Record<string, string> = {
|
|
130
|
+
...secondaryColumn.spec.annotations,
|
|
131
|
+
[IS_VIRTUAL_COLUMN]: 'true'
|
|
132
|
+
}
|
|
133
|
+
if (label || labelDomainPart) {
|
|
134
|
+
annotations[LABEL_ANNOTATION] = label && labelDomainPart ? label + ' / ' + labelDomainPart : label + labelDomainPart;
|
|
135
|
+
}
|
|
136
|
+
|
|
92
137
|
return {
|
|
93
138
|
id: id as PObjectId,
|
|
94
139
|
spec: {
|
|
@@ -97,10 +142,7 @@ function getAdditionalColumnsForPair(
|
|
|
97
142
|
...axisId,
|
|
98
143
|
annotations: secondaryColumn.spec.axesSpec[idx].annotations
|
|
99
144
|
})),
|
|
100
|
-
annotations
|
|
101
|
-
...secondaryColumn.spec.annotations,
|
|
102
|
-
[IS_VIRTUAL_COLUMN]: 'true'
|
|
103
|
-
}
|
|
145
|
+
annotations
|
|
104
146
|
},
|
|
105
147
|
data: secondaryColumn.data
|
|
106
148
|
};
|