@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.
@@ -3,7 +3,7 @@
3
3
  "title": "Item",
4
4
  "type": "object",
5
5
  "additionalProperties": false,
6
- "required": ["fields", "relations"],
6
+ "required": ["fields", "relations", "canonicalPath"],
7
7
  "properties": {
8
8
  "fields": {
9
9
  "type": "object",
@@ -3,7 +3,7 @@
3
3
  "title": "ItemSummary",
4
4
  "type": "object",
5
5
  "additionalProperties": false,
6
- "required": ["path"],
6
+ "required": ["path", "canonicalPath"],
7
7
  "properties": {
8
8
  "path": {
9
9
  "type": "string",
@@ -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));
@@ -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));
@@ -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?: string;
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?: string;
378
+ canonicalPath: string;
379
379
  }
380
380
  /**
381
381
  * A BlobSummary contains a path to download the corresponding Blob.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unito/integration-api",
3
- "version": "7.1.1",
3
+ "version": "8.0.0",
4
4
  "description": "The Unito Integration API",
5
5
  "type": "module",
6
6
  "types": "./dist/src/index.d.ts",