@unito/integration-api 4.2.1 → 4.2.2
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/src/index.cjs +14 -10
- package/dist/src/jsonPathHelpers.js +14 -10
- package/package.json +1 -1
package/dist/src/index.cjs
CHANGED
|
@@ -568,27 +568,31 @@ const fieldTypeCompatibilityMatrix = {
|
|
|
568
568
|
*/
|
|
569
569
|
function findRelationByJSONPath(item, query) {
|
|
570
570
|
const tokens = parseJSONPath(query);
|
|
571
|
-
const
|
|
571
|
+
const schemas = [];
|
|
572
572
|
let current = item;
|
|
573
573
|
for (const token of tokens) {
|
|
574
574
|
if (current === '__self') {
|
|
575
|
-
const
|
|
576
|
-
if (!
|
|
575
|
+
const previousSchema = schemas[schemas.length - 1];
|
|
576
|
+
if (!previousSchema) {
|
|
577
577
|
throw new Error(`Invalid use of __self`);
|
|
578
578
|
}
|
|
579
|
-
current =
|
|
579
|
+
current = previousSchema;
|
|
580
580
|
}
|
|
581
581
|
const result = applyToken(current, token);
|
|
582
|
-
if (
|
|
583
|
-
|
|
584
|
-
}
|
|
585
|
-
else if (isRelationSummary(result) && isRelationSchema(result.schema)) {
|
|
586
|
-
relations.push(result);
|
|
582
|
+
if (isObject(result) && isRelationSchema(result['schema'])) {
|
|
583
|
+
schemas.push(result['schema']);
|
|
587
584
|
}
|
|
588
585
|
current = result;
|
|
589
586
|
}
|
|
587
|
+
if (isRelation(current)) {
|
|
588
|
+
return current;
|
|
589
|
+
}
|
|
590
590
|
if (isReferenceRelation(current) || isRelationSummary(current)) {
|
|
591
|
-
|
|
591
|
+
const latestSchema = schemas[schemas.length - 1];
|
|
592
|
+
if (latestSchema === undefined) {
|
|
593
|
+
throw new Error(`No schema found for relation ${current.label}`);
|
|
594
|
+
}
|
|
595
|
+
return { ...current, schema: latestSchema };
|
|
592
596
|
}
|
|
593
597
|
return undefined;
|
|
594
598
|
}
|
|
@@ -4,27 +4,31 @@ import * as Api from './index.js';
|
|
|
4
4
|
*/
|
|
5
5
|
export function findRelationByJSONPath(item, query) {
|
|
6
6
|
const tokens = parseJSONPath(query);
|
|
7
|
-
const
|
|
7
|
+
const schemas = [];
|
|
8
8
|
let current = item;
|
|
9
9
|
for (const token of tokens) {
|
|
10
10
|
if (current === '__self') {
|
|
11
|
-
const
|
|
12
|
-
if (!
|
|
11
|
+
const previousSchema = schemas[schemas.length - 1];
|
|
12
|
+
if (!previousSchema) {
|
|
13
13
|
throw new Error(`Invalid use of __self`);
|
|
14
14
|
}
|
|
15
|
-
current =
|
|
15
|
+
current = previousSchema;
|
|
16
16
|
}
|
|
17
17
|
const result = applyToken(current, token);
|
|
18
|
-
if (Api.
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
else if (Api.isRelationSummary(result) && Api.isRelationSchema(result.schema)) {
|
|
22
|
-
relations.push(result);
|
|
18
|
+
if (Api.isObject(result) && Api.isRelationSchema(result['schema'])) {
|
|
19
|
+
schemas.push(result['schema']);
|
|
23
20
|
}
|
|
24
21
|
current = result;
|
|
25
22
|
}
|
|
23
|
+
if (Api.isRelation(current)) {
|
|
24
|
+
return current;
|
|
25
|
+
}
|
|
26
26
|
if (Api.isReferenceRelation(current) || Api.isRelationSummary(current)) {
|
|
27
|
-
|
|
27
|
+
const latestSchema = schemas[schemas.length - 1];
|
|
28
|
+
if (latestSchema === undefined) {
|
|
29
|
+
throw new Error(`No schema found for relation ${current.label}`);
|
|
30
|
+
}
|
|
31
|
+
return { ...current, schema: latestSchema };
|
|
28
32
|
}
|
|
29
33
|
return undefined;
|
|
30
34
|
}
|