@milaboratories/pl-model-common 1.19.6 → 1.19.7
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/drivers/pframe/linker_columns.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +158 -153
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/drivers/pframe/linker_columns.test.ts +48 -0
- package/src/drivers/pframe/linker_columns.ts +14 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milaboratories/pl-model-common",
|
|
3
|
-
"version": "1.19.
|
|
3
|
+
"version": "1.19.7",
|
|
4
4
|
"description": "Platforma SDK Model",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"typescript": "~5.6.3",
|
|
27
27
|
"vite": "^6.3.5",
|
|
28
28
|
"vitest": "^2.1.9",
|
|
29
|
-
"@
|
|
30
|
-
"@
|
|
29
|
+
"@milaboratories/build-configs": "1.0.5",
|
|
30
|
+
"@platforma-sdk/eslint-config": "1.0.3"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"type-check": "tsc --noEmit --composite false",
|
|
@@ -104,6 +104,31 @@ describe('Linker columns', () => {
|
|
|
104
104
|
testCase({ from: [axis1], to: [axis4], expected: []});
|
|
105
105
|
});
|
|
106
106
|
|
|
107
|
+
test('Search in linker columns map with parents', () => {
|
|
108
|
+
const axisC = makeTestAxis({ name: 'c' });
|
|
109
|
+
const axisB = makeTestAxis({ name: 'b' });
|
|
110
|
+
const axisA = makeTestAxis({ name: 'a', parents: [axisB]});
|
|
111
|
+
|
|
112
|
+
const linkerMap = LinkerMap.fromColumns([
|
|
113
|
+
makeLinkerColumn({ name: 'abc', from: [axisA, axisB], to: [axisC] })
|
|
114
|
+
]);
|
|
115
|
+
|
|
116
|
+
let testCase = (params: {
|
|
117
|
+
from: AxisSpecNormalized[];
|
|
118
|
+
to: AxisSpecNormalized[];
|
|
119
|
+
expected: string[];
|
|
120
|
+
}) => {
|
|
121
|
+
const linkers = linkerMap.getLinkerColumnsForAxes({
|
|
122
|
+
from: params.from,
|
|
123
|
+
to: params.to,
|
|
124
|
+
throwWhenNoLinkExists: false,
|
|
125
|
+
});
|
|
126
|
+
expect(linkers.map(item => item.spec.name).sort()).toEqual(params.expected);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
testCase({ from: getNormalizedAxesList([axisA, axisB]), to: getNormalizedAxesList([axisC]), expected: ['abc'] });
|
|
130
|
+
})
|
|
131
|
+
|
|
107
132
|
test('Axis tree - without parents', () => {
|
|
108
133
|
const [axisA, axisB] = getNormalizedAxesList([
|
|
109
134
|
makeTestAxis({ name: 'a' }),
|
|
@@ -235,4 +260,27 @@ describe('Linker columns', () => {
|
|
|
235
260
|
expect(linkerMap.getReachableByLinkersAxesFromAxes([c2])).not.toHaveLength(0);
|
|
236
261
|
expect(linkerMap.getReachableByLinkersAxesFromAxes([c1])).not.toHaveLength(0);
|
|
237
262
|
})
|
|
263
|
+
|
|
264
|
+
test('Non-linkable axes', () => {
|
|
265
|
+
const axisA = makeTestAxis({ name: 'a' });
|
|
266
|
+
const axisB = makeTestAxis({ name: 'b' });
|
|
267
|
+
const axisC = makeTestAxis({ name: 'c', parents: [axisA, axisB] });
|
|
268
|
+
const axisD = makeTestAxis({ name: 'd' });
|
|
269
|
+
const axisE = makeTestAxis({ name: 'e' });
|
|
270
|
+
|
|
271
|
+
const axesList = getNormalizedAxesList([axisA, axisB, axisC, axisD, axisE]);
|
|
272
|
+
const linkerMap = LinkerMap.fromColumns([
|
|
273
|
+
makeLinkerColumn({ name: 'linker1', from: [axisA, axisB, axisC], to: [axisD] })
|
|
274
|
+
]);
|
|
275
|
+
|
|
276
|
+
expect(linkerMap.getNonLinkableAxes(
|
|
277
|
+
getNormalizedAxesList([axisA, axisB, axisC, axisD]),
|
|
278
|
+
getNormalizedAxesList([axisC, axisE])
|
|
279
|
+
).map(v => v.name)).toEqual(['e']);
|
|
280
|
+
|
|
281
|
+
expect(linkerMap.getNonLinkableAxes(
|
|
282
|
+
[],
|
|
283
|
+
getNormalizedAxesList([axisA, axisB, axisC, axisE])
|
|
284
|
+
).map(v => v.name)).toEqual(['a', 'b', 'c', 'e']);
|
|
285
|
+
})
|
|
238
286
|
});
|
|
@@ -167,7 +167,7 @@ export class LinkerMap implements LinkersData {
|
|
|
167
167
|
.flatMap((targetKey) => {
|
|
168
168
|
const linkers = startKeys
|
|
169
169
|
.map((startKey) => this.searchLinkerPath(startKey, targetKey))
|
|
170
|
-
.reduce((shortestPath, path) => shortestPath.length && shortestPath.length < path.length ? shortestPath : path,
|
|
170
|
+
.reduce((shortestPath, path) => (shortestPath.length && shortestPath.length < path.length) || !path.length ? shortestPath : path,
|
|
171
171
|
[] as PColumnIdAndSpec[])
|
|
172
172
|
.map((linker) => [linker.columnId, linker] as const);
|
|
173
173
|
if (!linkers.length && throwWhenNoLinkExists) {
|
|
@@ -196,12 +196,19 @@ export class LinkerMap implements LinkersData {
|
|
|
196
196
|
): AxisSpecNormalized[] {
|
|
197
197
|
const startKeys = sourceAxes.map(LinkerMap.getLinkerKeyFromAxisSpec);
|
|
198
198
|
// target keys contain all axes to be linked; if some of target axes has parents they must be in the key
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
199
|
+
const targetKeys = targetAxes.map(LinkerMap.getLinkerKeyFromAxisSpec);
|
|
200
|
+
|
|
201
|
+
const axes = Array.from(
|
|
202
|
+
new Map(
|
|
203
|
+
targetAxes
|
|
204
|
+
.filter((_targetAxis, idx) => {
|
|
205
|
+
const targetKey = targetKeys[idx];
|
|
206
|
+
return !startKeys.some((startKey) => this.searchLinkerPath(startKey, targetKey).length);
|
|
207
|
+
})
|
|
208
|
+
.flatMap((axis) => getArrayFromAxisTree(getAxesTree(axis)).map((axis) => [canonicalizeJson(getAxisId(axis)), axis])),
|
|
209
|
+
).values(),
|
|
210
|
+
);
|
|
211
|
+
return axes;
|
|
205
212
|
}
|
|
206
213
|
|
|
207
214
|
/** Get all axes that can be connected to sourceAxes by linkers */
|