@unito/integration-api 4.1.4 → 4.1.6
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/types.d.ts
CHANGED
|
@@ -257,16 +257,18 @@ export declare const OperatorTypes: {
|
|
|
257
257
|
readonly IS_NOT_NULL: "!";
|
|
258
258
|
};
|
|
259
259
|
export type OperatorType = (typeof OperatorTypes)[keyof typeof OperatorTypes];
|
|
260
|
+
/**
|
|
261
|
+
* A FieldValues holds the values for various fields.
|
|
262
|
+
*/
|
|
263
|
+
export type FieldValues<T extends FieldSchema[] | undefined = undefined> = Record<T extends FieldSchema[] ? T[number]['name'] : string, unknown>;
|
|
260
264
|
/**
|
|
261
265
|
* An Item represents a syncable entity. It has fields of its own as well as relations to other items.
|
|
262
266
|
*/
|
|
263
|
-
export interface Item {
|
|
267
|
+
export interface Item<T extends RelationSchema | undefined = undefined> {
|
|
264
268
|
/**
|
|
265
269
|
* The fields and values of the item.
|
|
266
270
|
*/
|
|
267
|
-
fields:
|
|
268
|
-
[k: string]: unknown;
|
|
269
|
-
};
|
|
271
|
+
fields: T extends RelationSchema ? FieldValues<T['fields']> : FieldValues;
|
|
270
272
|
/**
|
|
271
273
|
* The relations of the item
|
|
272
274
|
*/
|
|
@@ -281,7 +283,7 @@ export interface Item {
|
|
|
281
283
|
* An ItemSummary is a constituent of a collection.
|
|
282
284
|
* It links to an item, and can contain additional item information upon request.
|
|
283
285
|
*/
|
|
284
|
-
export interface ItemSummary {
|
|
286
|
+
export interface ItemSummary<T extends RelationSchema | undefined = undefined> {
|
|
285
287
|
/**
|
|
286
288
|
* Link to this specific item.
|
|
287
289
|
*/
|
|
@@ -289,9 +291,7 @@ export interface ItemSummary {
|
|
|
289
291
|
/**
|
|
290
292
|
* Optional list of requested fields and their values.
|
|
291
293
|
*/
|
|
292
|
-
fields?:
|
|
293
|
-
[k: string]: unknown;
|
|
294
|
-
};
|
|
294
|
+
fields?: Partial<FieldValues<T extends RelationSchema ? T['fields'] : undefined>>;
|
|
295
295
|
/**
|
|
296
296
|
* The shape of the request parameters.
|
|
297
297
|
*/
|
|
@@ -299,9 +299,7 @@ export interface ItemSummary {
|
|
|
299
299
|
/**
|
|
300
300
|
* Optional list of relation paths.
|
|
301
301
|
*/
|
|
302
|
-
relations?:
|
|
303
|
-
[k: string]: string;
|
|
304
|
-
};
|
|
302
|
+
relations?: Partial<Record<T extends RelationSchema ? T['relations'] extends NonNullable<RelationSchema['relations']> ? T['relations'][number]['name'] : never : string, string>>;
|
|
305
303
|
/**
|
|
306
304
|
* The canonical path of the item. This is the path / id that uniquely identifies the item in a provider.
|
|
307
305
|
* Even if the item is moved in the graph, the canonical path should remain the same.
|