@unito/integration-api 7.0.1 → 7.1.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.
@@ -49,7 +49,14 @@
49
49
  }
50
50
  },
51
51
  "reference": {
52
- "$ref": "https://unito.io/integration_api/referenceRelation.schema.json"
52
+ "oneOf": [
53
+ {
54
+ "$ref": "https://unito.io/integration_api/referenceRelation.schema.json"
55
+ },
56
+ {
57
+ "$ref": "https://unito.io/integration_api/relationPointer.schema.json"
58
+ }
59
+ ]
53
60
  },
54
61
  "info": {
55
62
  "type": "string"
@@ -0,0 +1,20 @@
1
+ {
2
+ "$id": "https://unito.io/integration_api/relationPointer.schema.json",
3
+ "title": "RelationPointer",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": ["itemPath", "relationName"],
7
+ "properties": {
8
+ "itemPath": {
9
+ "type": "string",
10
+ "format": "uri-reference",
11
+ "pattern": "^\/.*$"
12
+ },
13
+ "relationName": {
14
+ "type": "string",
15
+ "pattern": "^[a-zA-Z0-9_-]*$",
16
+ "minLength": 1,
17
+ "maxLength": 100
18
+ }
19
+ }
20
+ }
@@ -29,6 +29,12 @@ export declare function isItemSummary(potentialItemSummary: unknown): potentialI
29
29
  * @returns True if the value is an Item, false otherwise.
30
30
  */
31
31
  export declare function isItem(potentialItem: unknown): potentialItem is Api.Item;
32
+ /**
33
+ * Checks if the input is an Api.RelationPointer object.
34
+ * @param potentialRelationPointer - The value to check.
35
+ * @returns True if the value is a RelationPointer, false otherwise.
36
+ */
37
+ export declare function isRelationPointer(potentialRelationPointer: unknown): potentialRelationPointer is Api.RelationPointer;
32
38
  /**
33
39
  * Checks if the input is an Api.ReferenceRelation object.
34
40
  * @param potentialReferenceRelation - The value to check.
@@ -46,6 +46,16 @@ export function isItem(potentialItem) {
46
46
  Array.isArray(potentialItem['relations']) &&
47
47
  potentialItem['relations'].every(isRelation));
48
48
  }
49
+ /**
50
+ * Checks if the input is an Api.RelationPointer object.
51
+ * @param potentialRelationPointer - The value to check.
52
+ * @returns True if the value is a RelationPointer, false otherwise.
53
+ */
54
+ export function isRelationPointer(potentialRelationPointer) {
55
+ return (isObject(potentialRelationPointer) &&
56
+ isString(potentialRelationPointer['itemPath']) &&
57
+ isString(potentialRelationPointer['relationName']));
58
+ }
49
59
  /**
50
60
  * Checks if the input is an Api.ReferenceRelation object.
51
61
  * @param potentialReferenceRelation - The value to check.
@@ -163,6 +163,16 @@ function isItem(potentialItem) {
163
163
  Array.isArray(potentialItem['relations']) &&
164
164
  potentialItem['relations'].every(isRelation));
165
165
  }
166
+ /**
167
+ * Checks if the input is an Api.RelationPointer object.
168
+ * @param potentialRelationPointer - The value to check.
169
+ * @returns True if the value is a RelationPointer, false otherwise.
170
+ */
171
+ function isRelationPointer(potentialRelationPointer) {
172
+ return (isObject(potentialRelationPointer) &&
173
+ isString(potentialRelationPointer['itemPath']) &&
174
+ isString(potentialRelationPointer['relationName']));
175
+ }
166
176
  /**
167
177
  * Checks if the input is an Api.ReferenceRelation object.
168
178
  * @param potentialReferenceRelation - The value to check.
@@ -828,6 +838,7 @@ exports.isItemSummary = isItemSummary;
828
838
  exports.isObject = isObject;
829
839
  exports.isReferenceRelation = isReferenceRelation;
830
840
  exports.isRelation = isRelation;
841
+ exports.isRelationPointer = isRelationPointer;
831
842
  exports.isRelationSchema = isRelationSchema;
832
843
  exports.isRelationSchemaOrSelf = isRelationSchemaOrSelf;
833
844
  exports.isRelationSummary = isRelationSummary;
@@ -146,19 +146,33 @@ export interface BlobFieldSchema extends AbstractFieldSchema {
146
146
  interface UserReferenceFieldSchema extends AbstractFieldSchema {
147
147
  semantic: typeof Semantics.USER;
148
148
  type: typeof FieldValueTypes.REFERENCE;
149
- reference: ReferenceRelation;
149
+ reference: ReferenceRelation | RelationPointer;
150
150
  }
151
151
  interface ParentReferenceFieldSchema extends AbstractFieldSchema {
152
152
  semantic: typeof Semantics.PARENT;
153
153
  type: typeof FieldValueTypes.REFERENCE;
154
- reference: ReferenceRelation;
154
+ reference: ReferenceRelation | RelationPointer;
155
155
  }
156
156
  interface UnconstrainedReferenceFieldSchema extends AbstractFieldSchema {
157
157
  semantic?: never;
158
158
  type: typeof FieldValueTypes.REFERENCE;
159
- reference: ReferenceRelation;
159
+ reference: ReferenceRelation | RelationPointer;
160
160
  }
161
161
  export type ReferenceFieldSchema = UserReferenceFieldSchema | ParentReferenceFieldSchema | UnconstrainedReferenceFieldSchema;
162
+ /**
163
+ * A RelationPointer points to an existing relation elsewhere in the graph,
164
+ * avoiding the need to redeclare its schema inline.
165
+ */
166
+ export interface RelationPointer {
167
+ /**
168
+ * The path of the item that owns the target relation.
169
+ */
170
+ itemPath: string;
171
+ /**
172
+ * The name of the relation on that item.
173
+ */
174
+ relationName: string;
175
+ }
162
176
  /**
163
177
  * A ReferenceRelation describes a relation that can be used in a ReferenceFieldSchema.
164
178
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unito/integration-api",
3
- "version": "7.0.1",
3
+ "version": "7.1.0",
4
4
  "description": "The Unito Integration API",
5
5
  "type": "module",
6
6
  "types": "./dist/src/index.d.ts",