@unito/integration-api 7.1.1 → 8.0.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/schemas/item.json +1 -1
- package/dist/schemas/itemSummary.json +1 -1
- package/dist/src/guards.js +14 -1
- package/dist/src/index.cjs +14 -1
- package/dist/src/types.d.ts +2 -2
- package/package.json +1 -1
package/dist/schemas/item.json
CHANGED
package/dist/src/guards.js
CHANGED
|
@@ -31,6 +31,7 @@ export function isUndefined(potentialUndefined) {
|
|
|
31
31
|
export function isItemSummary(potentialItemSummary) {
|
|
32
32
|
return (isObject(potentialItemSummary) &&
|
|
33
33
|
isString(potentialItemSummary['path']) &&
|
|
34
|
+
isString(potentialItemSummary['canonicalPath']) &&
|
|
34
35
|
(isUndefined(potentialItemSummary['fields']) || isObject(potentialItemSummary['fields'])) &&
|
|
35
36
|
(isUndefined(potentialItemSummary['relations']) ||
|
|
36
37
|
(Array.isArray(potentialItemSummary['relations']) && potentialItemSummary['relations'].every(isString))));
|
|
@@ -43,6 +44,7 @@ export function isItemSummary(potentialItemSummary) {
|
|
|
43
44
|
export function isItem(potentialItem) {
|
|
44
45
|
return (isObject(potentialItem) &&
|
|
45
46
|
isObject(potentialItem['fields']) &&
|
|
47
|
+
isString(potentialItem['canonicalPath']) &&
|
|
46
48
|
Array.isArray(potentialItem['relations']) &&
|
|
47
49
|
potentialItem['relations'].every((r) => isRelation(r)));
|
|
48
50
|
}
|
|
@@ -62,8 +64,19 @@ export function isRelationPointer(potentialRelationPointer) {
|
|
|
62
64
|
* @returns True if the value is a ReferenceRelation, false otherwise.
|
|
63
65
|
*/
|
|
64
66
|
export function isReferenceRelation(potentialReferenceRelation, options) {
|
|
67
|
+
if (!isObject(potentialReferenceRelation)) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
// breaking change introducing the name in the reference.
|
|
71
|
+
if ('name' in potentialReferenceRelation) {
|
|
72
|
+
return (isObject(potentialReferenceRelation) &&
|
|
73
|
+
isString(potentialReferenceRelation['name']) &&
|
|
74
|
+
isString(potentialReferenceRelation['path']) &&
|
|
75
|
+
isString(potentialReferenceRelation['label']) &&
|
|
76
|
+
isRelationSchemaOrSelf(potentialReferenceRelation['schema'], options));
|
|
77
|
+
}
|
|
78
|
+
// backward compatible check
|
|
65
79
|
return (isObject(potentialReferenceRelation) &&
|
|
66
|
-
isString(potentialReferenceRelation['name']) &&
|
|
67
80
|
isString(potentialReferenceRelation['path']) &&
|
|
68
81
|
isString(potentialReferenceRelation['label']) &&
|
|
69
82
|
isRelationSchemaOrSelf(potentialReferenceRelation['schema'], options));
|
package/dist/src/index.cjs
CHANGED
|
@@ -148,6 +148,7 @@ function isUndefined(potentialUndefined) {
|
|
|
148
148
|
function isItemSummary(potentialItemSummary) {
|
|
149
149
|
return (isObject(potentialItemSummary) &&
|
|
150
150
|
isString(potentialItemSummary['path']) &&
|
|
151
|
+
isString(potentialItemSummary['canonicalPath']) &&
|
|
151
152
|
(isUndefined(potentialItemSummary['fields']) || isObject(potentialItemSummary['fields'])) &&
|
|
152
153
|
(isUndefined(potentialItemSummary['relations']) ||
|
|
153
154
|
(Array.isArray(potentialItemSummary['relations']) && potentialItemSummary['relations'].every(isString))));
|
|
@@ -160,6 +161,7 @@ function isItemSummary(potentialItemSummary) {
|
|
|
160
161
|
function isItem(potentialItem) {
|
|
161
162
|
return (isObject(potentialItem) &&
|
|
162
163
|
isObject(potentialItem['fields']) &&
|
|
164
|
+
isString(potentialItem['canonicalPath']) &&
|
|
163
165
|
Array.isArray(potentialItem['relations']) &&
|
|
164
166
|
potentialItem['relations'].every((r) => isRelation(r)));
|
|
165
167
|
}
|
|
@@ -179,8 +181,19 @@ function isRelationPointer(potentialRelationPointer) {
|
|
|
179
181
|
* @returns True if the value is a ReferenceRelation, false otherwise.
|
|
180
182
|
*/
|
|
181
183
|
function isReferenceRelation(potentialReferenceRelation, options) {
|
|
184
|
+
if (!isObject(potentialReferenceRelation)) {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
// breaking change introducing the name in the reference.
|
|
188
|
+
if ('name' in potentialReferenceRelation) {
|
|
189
|
+
return (isObject(potentialReferenceRelation) &&
|
|
190
|
+
isString(potentialReferenceRelation['name']) &&
|
|
191
|
+
isString(potentialReferenceRelation['path']) &&
|
|
192
|
+
isString(potentialReferenceRelation['label']) &&
|
|
193
|
+
isRelationSchemaOrSelf(potentialReferenceRelation['schema'], options));
|
|
194
|
+
}
|
|
195
|
+
// backward compatible check
|
|
182
196
|
return (isObject(potentialReferenceRelation) &&
|
|
183
|
-
isString(potentialReferenceRelation['name']) &&
|
|
184
197
|
isString(potentialReferenceRelation['path']) &&
|
|
185
198
|
isString(potentialReferenceRelation['label']) &&
|
|
186
199
|
isRelationSchemaOrSelf(potentialReferenceRelation['schema'], options));
|
package/dist/src/types.d.ts
CHANGED
|
@@ -348,7 +348,7 @@ export interface Item<T extends RelationSchema | undefined = undefined> {
|
|
|
348
348
|
* The canonical path of the item. This is the path / id that uniquely identifies the item in a provider.
|
|
349
349
|
* Even if the item is moved in the graph, the canonical path should remain the same.
|
|
350
350
|
*/
|
|
351
|
-
canonicalPath
|
|
351
|
+
canonicalPath: string;
|
|
352
352
|
}
|
|
353
353
|
/**
|
|
354
354
|
* An ItemSummary is a constituent of a collection.
|
|
@@ -375,7 +375,7 @@ export interface ItemSummary<T extends RelationSchema | undefined = undefined> {
|
|
|
375
375
|
* The canonical path of the item. This is the path / id that uniquely identifies the item in a provider.
|
|
376
376
|
* Even if the item is moved in the graph, the canonical path should remain the same.
|
|
377
377
|
*/
|
|
378
|
-
canonicalPath
|
|
378
|
+
canonicalPath: string;
|
|
379
379
|
}
|
|
380
380
|
/**
|
|
381
381
|
* A BlobSummary contains a path to download the corresponding Blob.
|