@olympeio/runtime-web 9.1.0-dev → 9.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.
package/types/cloud.d.ts CHANGED
@@ -7,87 +7,306 @@
7
7
  // @ts-ignore
8
8
  import Observable from 'rxjs';
9
9
  import {Context, CloudObject, Relation, Property, Tag, Class} from "./base";
10
- import { BrickContext } from './runtime';
10
+ import {Brick, BrickContext} from './runtime';
11
11
  import {Color} from "./utils";
12
12
 
13
13
  // --------------------------
14
14
  // -- Primitive data types --
15
15
  // --------------------------
16
+ /**
17
+ * A property model defines a property of a data type.
18
+ * A property is defined by its type and the model it defines a property for.
19
+ * */
16
20
  export class PropertyModel extends CloudObject {
21
+ /**
22
+ * Relation from the property model to the data type (model)
23
+ * to which that property is attached.
24
+ *
25
+ * Example:
26
+ *
27
+ * ` myNumberPropertyModel --definingModelRel-> myDataTypeObject`
28
+ */
17
29
  static definingModelRel: Relation<PropertyModel, CloudObject>;
30
+
31
+ /**
32
+ * Relation from the `PropertyModel` to its type.
33
+ *
34
+ * Example :
35
+ *
36
+ * `myNumberPropertyModel --typeRel-> Number`
37
+ */
18
38
  static typeRel: Relation<PropertyModel, CloudObject>;
19
39
  }
20
40
 
41
+ /**
42
+ * A relation model defines a relation between two data types.
43
+ * It defines what data types is the origin and the destination of the relation.
44
+ *
45
+ * It also defines follow rules properties on the relation.
46
+ * */
21
47
  export class RelationModel extends CloudObject {
48
+ /**
49
+ * Relation from the origin data type to the RelationModel
50
+ * */
22
51
  static originModelRel: Relation<CloudObject, RelationModel>;
52
+ /**
53
+ * Relation from a RelationModel to the destination data type
54
+ * */
23
55
  static destinationModelRel: Relation<RelationModel, CloudObject>;
56
+ /**
57
+ * Property for the *dump* follow rule
58
+ */
24
59
  static dumpFollowRuleProp: Property<number>;
60
+ /**
61
+ * Property for the *delete* follow rule
62
+ */
25
63
  static deleteFollowRuleProp: Property<number>;
64
+ /**
65
+ * Property for the *runtime* follow rule
66
+ */
26
67
  static runtimeFollowRuleProp: Property<number>;
27
68
  }
28
69
 
70
+ /**
71
+ * StringModel represents a {@link PropertyModel} for a string property of a data type.
72
+ */
29
73
  export class StringModel extends CloudObject {
30
74
  static valueProp: Property<string>;
31
75
  }
32
76
 
77
+ /**
78
+ * NumberModel represents a {@link PropertyModel} for a number property of a data type.
79
+ */
33
80
  export class NumberModel extends CloudObject {
34
81
  static valueProp: Property<number>;
35
82
  }
36
83
 
84
+ /**
85
+ * BooleanModel represents a {@link PropertyModel} for a boolean property of a data type.
86
+ */
37
87
  export class BooleanModel extends CloudObject {
38
88
  static valueProp: Property<boolean>;
39
89
  }
40
90
 
91
+ /**
92
+ * DatetimeModel represents a {@link PropertyModel} for a datetime property of a data type.
93
+ */
41
94
  export class DatetimeModel extends CloudObject {
42
95
  static valueProp: Property<Date>;
43
96
  }
44
97
 
98
+ /**
99
+ * ColorModel represents a {@link PropertyModel} for a color property of a data type.
100
+ */
45
101
  export class ColorModel extends CloudObject {
46
102
  static valueProp: Property<Color>;
47
103
  }
48
104
 
105
+ /**
106
+ * File with content as binary or string data
107
+ */
49
108
  export class File extends CloudObject {
109
+
50
110
  static nameProp: Property<string>;
51
111
  static creationDateProp: Property<Date>;
52
112
  static modificationDateProp: Property<Date>;
53
113
  static mimeTypeProp: Property<string>;
54
114
  static urlProp: Property<string>;
115
+
116
+ /**
117
+ * Create a `File` from its content
118
+ *
119
+ * @param transaction transaction in which to create the file
120
+ * @param name filename
121
+ * @param content byte content of the file
122
+ * @param mimeType optional mime type of the file
123
+ * @param source optional source where file will be stored ('server', 'self' or DBConnector tag)
124
+ * @param tag optional tag for the file
125
+ * @return tag string of the file
126
+ */
55
127
  static createFromContent(transaction: Transaction, name: string, content: ArrayBuffer, mimeType?: string, source?: string, tag?: string): string;
128
+
129
+ /**
130
+ * Create a `File` from a specified URL
131
+ *
132
+ * @param transaction transaction in which to create the file
133
+ * @param name filename
134
+ * @param url url to retrieve content from
135
+ * @param mimeType optional mime type of the file
136
+ * @param source optional source where file will be stored ('server', 'self' or DBConnector tag)
137
+ * @param tag optional tag for the file
138
+ * @return tag string of the file
139
+ */
56
140
  static createFromURL(transaction: Transaction, name: string, url: string, mimeType?: string, source?: string, tag?: string): string;
57
141
 
142
+ /**
143
+ * Retrieve content from this file asynchronously
144
+ *
145
+ * @param onSuccess callback to execute when byte content has been retrieved successfully
146
+ * @param onFailure callback to execute when content retrieval has failed
147
+ */
58
148
  getContentAsBinary(onSuccess: (content: ArrayBuffer) => void, onFailure?: (string) => void): void;
149
+
150
+ /**
151
+ * Retrieve string content from this file asynchronously
152
+ *
153
+ * @param onSuccess callback to execute when string content has been retrieved successfully
154
+ * @param onFailure callback to execute when content retrieval has failed
155
+ */
59
156
  getContentAsString(onSuccess: (content: string) => void, onFailure?: (string) => void): void;
157
+
158
+ /**
159
+ * Retrieve string content from URL asynchronously
160
+ *
161
+ * @param onSuccess callback to execute when content has been retrieved successfully
162
+ * @param onFailure callback to execute when content retrieval has failed
163
+ */
60
164
  getContentUrl(onSuccess: (content: string) => void, onFailure?: () => void): void;
165
+
166
+ /**
167
+ * Save this file with specified name
168
+ *
169
+ * @param name filename
170
+ */
61
171
  saveAs(name: string): void;
62
172
  }
63
173
 
174
+ /**
175
+ * User object for authentication purposes
176
+ */
64
177
  export class User extends CloudObject {
65
178
  static loginProp: Property<string>;
66
179
  static saltProp: Property<string>;
67
180
  static verifierProp: Property<string>;
68
- static SAMLNameIdProp: Property<string>;
181
+ static SAMLnameIdProp: Property<string>;
69
182
  }
70
183
 
184
+ /**
185
+ * An Enum is an ordered list of string key-values mappings
186
+ */
71
187
  export class Enum extends CloudObject {
188
+ /**
189
+ * Create an empty `Enum?` without any value
190
+ *
191
+ * See {@link EnumValue#createValue} to create values for an Enum.
192
+ *
193
+ * @param transaction transaction in which to create the Enum
194
+ * @param name optional name of the Enum
195
+ * @return string tag of the Enum object
196
+ */
72
197
  create(transaction: Transaction, name?: string): string;
198
+
199
+ /**
200
+ * Get the values defined for this `Enum`
201
+ */
73
202
  getValues(): QueryResult<EnumValue>;
74
203
  }
75
204
 
205
+ /**
206
+ * An `EnumValue` is a single value part of an `Enum`.
207
+ * It has a `string` name, a rank (its position in the Enum list).
208
+ *
209
+ * The values for `EnumValue` are always stringified.
210
+ */
76
211
  export class EnumValue extends CloudObject {
212
+ /**
213
+ * Add a `EnumValue` to a specified `Enum`
214
+ *
215
+ * @param transaction transaction in which to add the EnumValue to the Enum
216
+ * @param enumModel `EnumModel` containing the specified `EnumValue`
217
+ * @param value value of the `EnumValue`
218
+ * @param name name of the `EnumValue`
219
+ * @param rank position of the `EnumValue` in the `Enum`
220
+ */
77
221
  static createValue(transaction: Transaction, enumModel: Tag, value: string, name?: string, rank?: number): string;
78
222
 
223
+ /**
224
+ * Name property for an EnumValue
225
+ */
79
226
  static nameProp: Property<string>;
227
+ /**
228
+ * Value property for an EnumValue
229
+ */
80
230
  static valueProp: Property<string>;
231
+ /**
232
+ * Rank property for an EnumValue
233
+ */
81
234
  static rankProp: Property<number>;
82
235
  }
83
236
 
237
+ // -------------------------
238
+ // -- Workflow data types --
239
+ // -------------------------
240
+
241
+ /**
242
+ * A `Workflow` is a sequence of {@link WorkflowState} in which instances of a model goes through.
243
+ * {@link WorkflowState} are linked by {@link WorkflowTransition} that can have an optional _process function_.
244
+ * The `Workflow` also historize the {@link WorkflowState} of the instance and optionally serialize the object itself in a {@link WorkflowObjectState}.
245
+ */
246
+ export class Workflow extends CloudObject {
247
+ /** Is the instance serialization enabled or not */
248
+ static serializationEnabledProp: Property<boolean>;
249
+ /** The model to which the `Workflow` is associated */
250
+ static dataTypeRel: Relation<Workflow, CloudObject>;
251
+ /** The {@link WorkflowState} that are in the `Workflow` */
252
+ static statesRel: Relation<Workflow, WorkflowState>;
253
+ /** The initial {@link WorkflowState} of the `Workflow` */
254
+ static initialStateRel: Relation<Workflow, WorkflowState>;
255
+ }
256
+
257
+ /**
258
+ * A `WorkflowState` defines a state in a {@link Workflow}.
259
+ */
260
+ export class WorkflowState extends CloudObject { /* empty */ }
261
+
262
+ /**
263
+ * A `WorkflowTransition` defines a transition between 2 {@link WorkflowState}.
264
+ * It has a direction (`fromStateRel` to `toStateRel`) and can have an optional _process function_.
265
+ * The _process function_ (`processRefProp`) is automatically triggered when the transition occurs.
266
+ */
267
+ export class WorkflowTransition extends CloudObject {
268
+ /**
269
+ * The `WorkflowTransition` optional _process function_.
270
+ * It has this signature: (ControlFlow, CloudObject, User, Map) -> (ControlFlow, ErrorFlow)
271
+ */
272
+ static processRefProp: Property<Brick>;
273
+ /** The {@link WorkflowState} from which this transition starts */
274
+ static fromStateRel: Relation<WorkflowTransition, WorkflowState>;
275
+ /** The {@link WorkflowState} to which this transition ends */
276
+ static toStateRel: Relation<WorkflowTransition, WorkflowState>;
277
+ }
278
+
279
+ /**
280
+ * A `WorkflowObjectState` represents the state of an instance at a certain point in time.
281
+ * It is automatically created when initializing a {@link Workflow} on an instance or when triggering a {@link WorkflowTransition}.
282
+ */
283
+ export class WorkflowObjectState extends CloudObject {
284
+ /** The name of the {@link Workflow} associated */
285
+ static workflowProp: Property<string>;
286
+ /** The name of the {@link WorkflowState} */
287
+ static stateProp: Property<string>;
288
+ /** The name (login) of the {@link User} */
289
+ static assigneeProp: Property<string>;
290
+ /** The point in time of this object state */
291
+ static dateTimeProp: Property<Date>;
292
+ /** If the {@link Workflow} has serialization enabled, the object's property are saved here in JSON */
293
+ static serializedObjectProp: Property<string>;
294
+ /** The related instance this object state represents */
295
+ static objectRel: Relation<WorkflowObjectState, CloudObject>;
296
+ /** The related instance this object state represents. This relation only reference the current state */
297
+ static currentObjectRel: Relation<WorkflowObjectState, CloudObject>;
298
+ }
299
+
84
300
  // ---------------------------
85
301
  // -- Database transactions --
86
302
  // ---------------------------
87
303
 
88
304
  /**
89
305
  * Transactions are the unique way to apply a list of operations to the datacloud.
90
- * A transaction can be merged into another transaction to be executed as a single set of operations.
306
+ * A transaction can be merged into another transaction so that both are executed as a single set of operations.
307
+ *
308
+ * All the operations for a transaction are executed atomically. Either all operations succeed, or none is applied.
309
+ *
91
310
  *
92
311
  * There are 5 types of basic operations :
93
312
  * - Create instance: create a node in the database with specified properties.
@@ -96,51 +315,226 @@ export class EnumValue extends CloudObject {
96
315
  * - Create relation: create a relation of a specific type between 2 existing node.
97
316
  * - Delete relation: remove the specified relation between 2 specified nodes.
98
317
  *
99
- * Classical transactions are executed using "execute()" method. The transaction size is limited but real-time but
100
- * all the changes applied on data "observed" by queries will be notified.
318
+ * In most cases, we apply the Transactions operations using the "execute()" method. The transaction size is limited but in real-time.
319
+ * It notifies observers of the data in real-time.
101
320
  *
102
- * Transactions with big set of operations (batch updates) can be executed using "executeAsLarge()" method. However no notification will be generated.
321
+ * Larger transactions with big set of operations (batch updates) must be executed using "executeAsLarge()" method. However no notification will be generated.
103
322
  *
104
323
  * Callbacks can be registered on transaction using "afterExecution()" method. They are executed once the transaction is applied.
105
324
  *
325
+ * Example of transaction:
326
+ *
327
+ * ```javascript
328
+ * const tx = new Transaction(true);
329
+ * const myNewInstanceTag = tx.create(<myModelTag>);
330
+ * tx.update(myNewInstanceTag, <myPropertyTag>, <myPropertyValue>)
331
+ * .execute()
332
+ * .then(() => {
333
+ * // success tx case
334
+ * })
335
+ * .catch((err) => {
336
+ * // error during tx case
337
+ * })
338
+ * ```
339
+ *
106
340
  * Concurrency transactions do not guarantee their execution order.
107
341
  */
108
342
  export class Transaction {
109
343
  constructor(persist?: boolean);
110
344
 
345
+ /**
346
+ * Get the transaction id attached to this transaction
347
+ * @return this transaction id
348
+ */
111
349
  getId(): string;
112
350
 
113
351
  // Operations
352
+ /**
353
+ * Create a new instance.
354
+ *
355
+ * A custom map can specify property values for the instance.
356
+ *
357
+ * A source can be the orchestrator ('server'), local ('self') or
358
+ * an external data source ('<DBConnectorTag>'). The source is where
359
+ * the object is persisted and its true value outside local scopes.
360
+ *
361
+ * @param model tag of the model of the instance to be created
362
+ * @param properties custom map from tag to their value for properties of the instance to be created
363
+ * @param source optional source of the instance
364
+ * @param tag optional tag of the instance to be created and must be unique
365
+ * @return the tag of the instance to be created
366
+ */
114
367
  create(model: Tag, properties?: Map<Tag, any>, source?: string, tag?: string): string;
368
+
369
+ /**
370
+ * Update the property of an instance
371
+ *
372
+ * @param instance tag of the instance to be updated
373
+ * @param property the property to be updated
374
+ * @param value the value of the property to be updated to
375
+ * @return this transaction
376
+ */
115
377
  update<T>(instance: Tag, property?: Property<T>, value?: T): this;
116
- multiUpdate(instance: Tag, properties: Map<string, any>): this;
378
+
379
+ /**
380
+ * Update multiple properties of a single instance
381
+ *
382
+ * @param instance tag of the instance to be updated
383
+ * @param properties (<propertyTag>, <propertyValue>) map to update properties
384
+ * @return this transaction
385
+ */
386
+ multiUpdate(instance: Tag, properties: Map<Tag, any>): this;
387
+
388
+ /**
389
+ * Delete an instance
390
+ *
391
+ * @param instance tag of the instance to be deleted
392
+ * @return this transaction
393
+ */
117
394
  delete(instance: Tag): this;
395
+
396
+ /**
397
+ * Create relation between two instances
398
+ *
399
+ * @param relation tag of the relation to be created
400
+ * @param from tag of the ORIGIN instance of the relation
401
+ * @param to tag ofo the DESTINATION instance of the relation
402
+ * @return this transaction with the create relation operation registered
403
+ */
118
404
  createRelation(relation: Tag, from: Tag, to: Tag): this;
405
+
406
+ /**
407
+ * Delete a relation between two specified instances.
408
+ *
409
+ * The relation is only deleted for the relation parameter direction.
410
+ *
411
+ * @param relation tag of the relation to be deleted
412
+ * @param from origin instance tag
413
+ * @param to destination instance tag
414
+ * @return this transaction
415
+ */
119
416
  deleteRelation(relation: Tag, from: Tag, to: Tag): this;
417
+
418
+ /**
419
+ * Delete any number of the relation starting from specified node.
420
+ *
421
+ * The specified node might be the origin or (exclusive) the destination of the relation.
422
+ *
423
+ * For the relations :
424
+ * ```
425
+ * - a - [rel1] -> b,
426
+ * - c - [inverseRel(rel1)] -> a,
427
+ * - a - [rel1] -> d,
428
+ * - a - [rel2] -> d
429
+ * ```
430
+ * `tx.deleteAllRelation(rel1, a)` will remove the first and third relations
431
+ *
432
+ * @param relation deleted relation, indicates relation tag *and* direction
433
+ * @param origin starting node
434
+ */
120
435
  deleteAllRelations(relation: Relation<any, any>, origin: Tag): this;
121
436
 
122
- // Change persistence of instances
437
+ /**
438
+ * Change the persistence mode of all instances in this transaction
439
+ *
440
+ * @param persist whether instances are persisted outside
441
+ * the local datacloud
442
+ * @return this transaction
443
+ */
123
444
  persist(persist?: boolean): this;
445
+
446
+ /**
447
+ * Change the persistence mode for a single instance in this transaction
448
+ *
449
+ * @param instance the instance to be persisted
450
+ * @param persist the persisting mode
451
+ * @return this transaction
452
+ */
124
453
  persistInstance(instance: Tag, persist?: boolean): this;
125
454
 
126
- // Set source of all instances created in this transaction
455
+ /**
456
+ * Change the source of all instances created in this transaction
457
+ *
458
+ * `source` can be specified as :
459
+ * 1. the orchestrator ('server'),
460
+ * 2. local ('self') or
461
+ * 3. an external data source ('<DBConnectorTag>')
462
+ *
463
+ * The source of a data object is where the object is persisted.
464
+ *
465
+ * By default, the `source` is the default source configured in the project.
466
+ *
467
+ * @param source the new source for instances
468
+ * @return this transaction
469
+ */
127
470
  setSource(source: string): this;
471
+
472
+ /**
473
+ * Retrieve the tag of the model of the instance tag
474
+ * from the created instances in this transaction
475
+ * or from the local database.
476
+ *
477
+ * @param tag the instance to find the model of
478
+ * @return the tag of the model of the given instance
479
+ */
128
480
  model(tag: Tag): string;
129
481
 
482
+ /**
483
+ * Add all operations of another transaction into this transaction
484
+ *
485
+ * @param otherTransaction the other transaction to add operations from
486
+ * @return this transaction
487
+ */
130
488
  merge(otherTransaction: Transaction): this;
131
489
 
132
490
  // Execution methods
491
+ /**
492
+ * Set a callback to be executed after all the operations
493
+ * in the transaction were executed successfully
494
+ *
495
+ * @param callback the callback to be executed
496
+ * @return this transaction
497
+ */
133
498
  afterExecution(callback: (success: boolean, message?: string) => void): this;
499
+
500
+ /**
501
+ * Execute atomically the transaction at the source
502
+ *
503
+ * @return promise resolving if the transaction succeeds,
504
+ * rejecting if the transaction fails
505
+ */
134
506
  execute(): Promise<void>;
507
+
508
+ /**
509
+ * Execute atomically a transaction at the source
510
+ * The `large` mode sends the transaction over HTTP
511
+ *
512
+ * @return promise resolving if the transaction succeeds,
513
+ * rejecting if the transaction fails.
514
+ */
135
515
  executeAsLarge(): Promise<void>;
136
516
 
137
- // Begin/End shared transaction helpers
517
+ /**
518
+ * Start a transaction using an existing transaction in the provided context
519
+ * or a new one if there is none.
520
+ *
521
+ * @param $ context in which the transaction executes
522
+ * @return transaction
523
+ */
138
524
  static from($: BrickContext): Transaction;
525
+
526
+ /**
527
+ * Execute a given transaction if there is no open transaction in the context.
528
+ *
529
+ * @param $ context
530
+ * @param transaction transaction to process
531
+ * @return boolean indicating if the argument transaction has been processed
532
+ */
139
533
  static process($: BrickContext, transaction: Transaction): Promise<boolean>;
140
534
  }
141
535
 
142
536
  /**
143
- * BurstTransactions are designed to apply updates of properties continuously with the matter of the order.
537
+ * BurstTransactions are designed to continuously apply high rates of updates on properties (FIFO ordering).
144
538
  * The only operation supported by BurstTransactions is to update properties of an instance.
145
539
  *
146
540
  * Unlike classical Transactions, a burst transaction preserves the order of update operations and
@@ -153,147 +547,663 @@ export class Transaction {
153
547
  export class BurstTransaction {
154
548
  constructor();
155
549
 
156
- // Push all the property values from the specified Observable to update the specified object.
550
+ /**
551
+ * Push all property values from specified Observable to update specified object
552
+ *
553
+ * @param object the object to update
554
+ * @param values observable of a `Map<Property<T>, T>` mapping properties to new values
555
+ */
157
556
  push<T>(object: CloudObject, values: Observable<Map<Property<T>, T>>): void;
158
557
 
159
- // Commit and close the burst transaction.
558
+ /**
559
+ * Commit and close the burst transaction
560
+ *
561
+ * @return Promise<void> completing with commit success/failure
562
+ */
160
563
  complete(): Promise<void>;
161
564
  }
162
565
 
163
566
  // ----------------------
164
567
  // -- Database queries --
165
568
  // ----------------------
166
- type Empty = [];
167
569
 
168
570
  /**
169
- * A CloudArray (type: QueryResult) is a array of tuple of CloudObjects that has been generated by a Query. It contains the result of a query at a specific time.
571
+ * A QueryResult is a list of key-value pairs that has been generated as a result of a `Query`.
572
+ * It contains the result of a query at a specific time.
170
573
  *
171
- * When a query is subscribed, it generates multiple CloudArrays along time and got via an observable.
172
- * Difference between CloudArrays from a Query is accessible using methods getAdded() and getRemoved().
574
+ * The keys are tags (e.g. `myTag`) that correspond to a `CloudObject` (e.g. `myCloudObject`).
575
+ * When the {@link Query} contains more than one [Query.andReturn()]{@link Query#andReturn} clause,
576
+ * keys are composite tags (e.g. `'tag1.tag2.tag3'`) and values are tuples of `CloudObjects` (e.g. `[cloudObj1, cloudObj2, cloudObj3]`).
577
+ * Such a QueryResult can be obtained via:
578
+ * ```javascript
579
+ * Query.instancesOf(myModel1).andReturn.follow(myRelation1).andReturn.follow(myRelation2).andReturn().execute().
580
+ * ```
173
581
  *
174
- * A CloudArray can be easily manipulated and transformed to a standard Array.
582
+ * When a query is subscribed, the returned observable generates multiple QueryResults over time.
175
583
  *
176
- * Keys of CloudObject tuples follow the rule: 'tag1.tag2.tag3' : [cloudObj1, cloudObj2, cloudObj3]
584
+ * A QueryResult can be easily manipulated and transformed to a standard Array.
177
585
  */
178
- export class QueryResult<T> {
586
+ export class QueryResult<T extends CloudObject | CloudObject[]> {
587
+ /**
588
+ *@return empty `QueryResult`
589
+ */
179
590
  static empty(): QueryResult<any>;
180
591
 
592
+ /**
593
+ * Symbol iterator for `for..in` syntactic sugar
594
+ *
595
+ * @return iterator over the key-values pairs of this `QueryResult`
596
+ */
181
597
  [Symbol.iterator](): IterableIterator<[string, T]>;
598
+
599
+ /**
600
+ * Get an iterable iterator over the key-value pairs of this `QueryResult`
601
+ *
602
+ * @return iterator
603
+ */
182
604
  entries(): IterableIterator<[string, T]>;
605
+
606
+ /**
607
+ * Get an iterable iterator over the values of this `QueryResult`
608
+ *
609
+ * @return iterator
610
+ */
183
611
  values(): IterableIterator<T>
612
+
613
+ /**
614
+ * Get an iterable iterator over the keys of this `QueryResult`
615
+ *
616
+ * @return iterator
617
+ */
184
618
  keys(): IterableIterator<string>
185
619
 
620
+ /**
621
+ * Get an array containing the values of this `QueryResult`
622
+ *
623
+ * @return array of this `QueryResult`'s values
624
+ */
186
625
  toArray(): T[];
626
+
627
+ /**
628
+ * Get the number of key-value pairs this `QueryResult` contains
629
+ *
630
+ * @return size of this `QueryResult`
631
+ */
187
632
  size(): number;
633
+
634
+ /**
635
+ * Check whether a key / value is contained in this `QueryResult`.
636
+ *
637
+ * Returns true if the cloud array contains an element with the specified key.
638
+ *
639
+ * If no corresponding key is found, returns true if the cloud array contains an element with the specified value.
640
+ *
641
+ * @param key the value to search for
642
+ * @return true if the value `key` is found
643
+ */
188
644
  has(key: T | string): boolean;
645
+
646
+ /**
647
+ * Get index of a value in the keys or values of this `QueryResult`.
648
+ *
649
+ * If the key is a string, retrieve the index from the `string` keys of this `QueryResult`.
650
+ *
651
+ * If the key is not a string, get the index from the `CloudObject` tuples
652
+ *
653
+ * @param key the value to find the index of
654
+ * @return index of the argument value or -1 if the value is not found
655
+ */
189
656
  indexOf(key: T | string): number;
657
+
658
+ /**
659
+ * Get the value corresponding to a given key
660
+ *
661
+ * @param key tag or composite tag
662
+ * @return matching tuple or `null`
663
+ */
190
664
  get(key: string): T | null;
665
+
666
+ /**
667
+ * Get the first value
668
+ *
669
+ * @return first value or `null` if empty
670
+ */
191
671
  getFirst(): T | null;
672
+
673
+ /**
674
+ * Get the value at the specified index
675
+ *
676
+ * @param index
677
+ * @return value at position `index` or `null` if index is out of bounds
678
+ */
192
679
  getAt(index: number): T | null;
193
680
 
681
+ /**
682
+ * Returns an array equivalent to [this.toArray().push(...object)]{@link toArray}
683
+ *
684
+ * This operation returns a new array and does not modify this QueryResult.
685
+ *
686
+ * @param object new values to push in the values array.
687
+ * @return new values array with new elements appended
688
+ */
194
689
  push(...object: T[]): T[];
690
+
691
+ /**
692
+ * Returns the QueryResult values as an array whose last value has been removed.
693
+ *
694
+ * If [QueryResult.size()]{@link size} is 0 or 1, this method returns an empty array.
695
+ *
696
+ * This operation returns a new array and does not modify this QueryResult.
697
+ *
698
+ * @return new values array with last element removed
699
+ */
195
700
  pop(): T[];
701
+
702
+ /**
703
+ * Returns the QueryResult values as an array whose first value has been removed.
704
+ *
705
+ * If [QueryResult.size()]{@link size} is 0 or 1, this method returns an empty array.
706
+ *
707
+ * This operation returns a new array and does not modify this QueryResult.
708
+ *
709
+ * @return new values array with first element removed
710
+ */
196
711
  shift(): T[];
197
712
 
198
- // Gives the difference between last cloud array => what instances added, and what where removed.
713
+ /**
714
+ * Returns the new values added since the last `QueryResult` update.
715
+ * In other words, `getAdded` returns the new values that exists in this query result, but did not in the previous query result pushed by the Observable.
716
+ *
717
+ * This applies only when *observing* a [Query]{@link Query#observe}.
718
+ *
719
+ * @return values added
720
+ */
199
721
  getAdded(): T[];
722
+
723
+ /**
724
+ * Returns the keys of values removed since the last `QueryResult` update.
725
+ * In other words, `getRemoved` returns the old values that existed in the previous query result, but are no longer present in this query result pushed by the Observable.
726
+ *
727
+ * This applies only when *observing* a [Query]{@link Query#observe}.
728
+ *
729
+ * @return keys of the removed values
730
+ */
200
731
  getRemoved(): string[] | string[][];
201
732
 
202
- filter(predicate: (entry: T) => boolean): T[];
203
- find(predicate: (entry: T) => boolean): T | null;
733
+ /**
734
+ * Returns an array containing the values matching the provided filter predicate.
735
+ *
736
+ * @param predicate filter {@link Predicate}
737
+ * @return array of matching values
738
+ */
739
+ filter(predicate: (entry: T, index: number) => boolean): T[];
740
+
741
+ /**
742
+ * Returns the first value matching the predicate, `null` otherwise.
743
+ *
744
+ * `find` calls `predicate` once for each element of the array until it returns true.
745
+ * If such an element is found, find immediately returns that element value.
746
+ *
747
+ * @param predicate
748
+ * @return the first value evaluating to true or `null`
749
+ */
750
+ find(predicate: (entry: T, index: number) => boolean): T | null;
751
+
752
+ /**
753
+ * Execute the specified callback function for each value of this `QueryResult`
754
+ *
755
+ * @param callback
756
+ */
757
+ forEach(callback: (entry: T, index: number) => void): void;
204
758
 
205
- forEach(callback: (entry: T) => void): void;
206
- map<S>(callback: (entry: T) => S): S[];
759
+ /**
760
+ * Execute the specified callback function for each value of this `QueryResult`.
761
+ * It returns a new array that contains the results of the callback execution.
762
+ *
763
+ * @param callback
764
+ * @return new array of transformed values
765
+ */
766
+ map<S>(callback: (entry: T, index: number) => S): S[];
767
+
768
+ /**
769
+ * Return a sorted copy of this QueryResult.
770
+ *
771
+ * The specified `comparator` used to determine the order of the QueryResult key-value pairs.
772
+ * It compares two QueryResult values and should return a negative number if the first value shall be present before the second, zero if they're at the same position, and a positive
773
+ * number otherwise.
774
+ *
775
+ * @param comparator comparator returning a negative, zero or positive number
776
+ * @return sorted copy of this QueryResult
777
+ */
207
778
  sort(comparator: (b1: T, b2: T) => number): QueryResult<T>;
208
- reduce<S>(reducer: (accumulator: S, entry: T) => S, initial: S): S;
779
+
780
+ /**
781
+ * Return a reduced value for this QueryResult.
782
+ *
783
+ * The specified `reducer` callback reduces the QueryResult values as [reduce]{@link Array#reduce}
784
+ *
785
+ * @param reducer callback
786
+ * @param initial initial value of the accumulator
787
+ * @return accumulated result applying the `reducer` function iteratively
788
+ */
789
+ reduce<S>(reducer: (accumulator: S, entry: T, index: number) => S, initial: S): S;
790
+
791
+ /**
792
+ * Return a new QueryResult that contains the concatenation of two or more QueryResults.
793
+ *
794
+ * Concatenating two QueryResults results in a new QueryResult with the following:
795
+ *
796
+ * - the keys of the QueryResults are concatenated
797
+ * - the values of the QueryResults are concatenated
798
+ * - the arrays returned by {@link getAdded} are concatenated
799
+ * - the arrays returned by {@link getRemoved} are concatenated
800
+ *
801
+ * Example : ```javascript
802
+ * const result1 = Query.fromInstances(myModel1).executeFromCache();
803
+ * // result1 is {tag1: cloudObj1, tag2: cloudObj2}
804
+ * const result2 = Query.fromInstances(myModel2).executeFromCache();
805
+ * // result2 is {tag3: cloudObj3}
806
+ * const concatenatedResult = result2.concat(result1);
807
+ * // concatenatedResult is {tag3: cloudObj3, tag1: cloudObj1, tag2: cloudObj2}
808
+ * ```
809
+ *
810
+ * @param others QueryResults to append to this `QueryResult`
811
+ * @return concatenated query results
812
+ */
209
813
  concat(...others: QueryResult<T>[]): QueryResult<T>;
210
814
  }
211
815
 
212
816
  /**
213
817
  * A Query is an immutable object used to build queries on the datacloud. It is a graph query builder.
214
- * Starting from an origin Tag (CloudObject or its unique id), it follows specified relations:
818
+ * It starts from an `origin` Tag (typically, the `Tag` of a data type or of an instance).
819
+ * From there, it can follow relations between data types and filter results.
215
820
  *
216
- * origin --a--> X --b--> Y --c--> Z
821
+ * Example:
822
+ *
823
+ * `origin --a--> X --b--> Y --c--> Z`
217
824
  *
218
- * At each level, "andReturn()" method can be called to add the current level to the result.
219
825
  * Example:
220
826
  *
827
+ * ```javascript
828
+ * Query.from(origin)
829
+ * .follow(a)
830
+ * .execute();
831
+ * ```
832
+ * This will return a Promise of a QueryResult whose values are of type X: `Promise<QueryResult<X>>`.
833
+ *
834
+ * A query defines a starting working set of nodes and operations that will mutate it.
835
+ * From our example,the working set is first the `origin` graph node. Then the `follow`
836
+ * operations create a new working set only containing the nodes related to the origin through relation *`a`*.
837
+ *
838
+ * Multiple relations can be followed at once to create the equivalent of JOIN operations in relational databases.
839
+ * ```javascript
221
840
  * Query.from(origin)
222
841
  * .follow(a).andReturn()
223
842
  * .follow(b)
224
843
  * .follow(c).andReturn()
225
844
  * .execute();
845
+ * ```
846
+ * The next operation defines a working set containing the nodes related
847
+ * through relation *`b`* to nodes that are related through relation *`a`* to the origin.
848
+ * A similar operation is defined for relation `c`.
849
+ * At each level, "andReturn()" method can be called to add the current level to the result.
850
+ * This will return a Promise of a QueryResult whose values are of type [X, Z]: `Promise<QueryResult<[X, Z]>>`.
851
+ *
852
+ * Out of the 4 working sets created, only the second and fourth are flagged to be returned and part of the result.
853
+ * But the operations in the middle impact this result: e.g.,
854
+ * all returned tuples (t1, t2) are object that have an intermediate `i` of type Y.
855
+ * such that `t1 --b-> i --c-> t2` but the `i` was not flagged to be returned.
856
+ *
857
+ * Queries define a path from a starting point following a specific list of relations.
858
+ * As explained with our example, only nodes part of a full path can be returned.
226
859
  *
227
- * This will return a Promise of a of tuple [X, Z]: Promise<CloudArray<[X, Z]>>.
228
860
  *
229
861
  * A query can be executed with 3 different ways:
230
862
  * - execute(): it runs the query on the datacloud and return the result as a QueryResult.
231
863
  * - observe(): it runs the query on the datacloud and subscribes to updates. It returns an Observable which provides a new QueryResult every time the result changes.
232
864
  * - executeFromCache(): it runs the query on the *local* datacloud which may be incomplete view of the datacloud (it is the local cache). It is executed synchronously.
233
865
  */
234
- export class Query<T extends CloudObject, R extends any[]> {
235
- static from<T extends CloudObject>(tag: Tag): Query<T, Empty>;
236
- static instancesOf<T extends CloudObject>(model: Class<T>, source?: string): Query<T, Empty>;
866
+ export class Query<T extends CloudObject, R> {
237
867
 
238
- follow<D extends CloudObject>(relation: Relation<T, D>): Query<D, R>; //
868
+ /**
869
+ * Create a query starting from the `CloudObject` specified tag
870
+ *
871
+ * @param tag tag of the `CloudObject` the query is starting from
872
+ * @param source optional source of the data to answer the query
873
+ * @return an empty Query whose starting point is defined by a single `CloudObject`
874
+ */
875
+ static from<T extends Tag>(tag: T, source?: string): Query<T extends CloudObject ? T : CloudObject, never>;
876
+
877
+ /**
878
+ * Create a query starting from the instances of the specified model
879
+ *
880
+ * @param model tag/class of the model to find the instances of
881
+ * @param source optional source of the data to answer the query
882
+ * A source can be the orchestrator ('server'), local ('self') or
883
+ * an external data source ('<DBConnectorTag>')
884
+ * @return a new query object starting from model instances
885
+ */
886
+ static instancesOf<T extends Tag>(model: Class<T> | Tag, source?: string): Query<T extends CloudObject ? T : CloudObject, never>;
887
+
888
+ /**
889
+ * Instruct the query to follow a specified relation. This does not add any key-value pair to the result.
890
+ * (see {@link andReturn}). This operation defines a new step in the path defined by our graph query.
891
+ *
892
+ * Example:
893
+ * Find the model of a single object.
894
+ * ```javascript
895
+ * Query.from(myTag).follow(CloudObject.modelRel).andReturn()
896
+ * ```
897
+ *
898
+ * @param relation relation to follow, specifies type and direction
899
+ * @return a new query object
900
+ */
901
+ follow<D extends CloudObject>(relation: Relation<T, D>): Query<D, R>;
902
+
903
+ /**
904
+ * Follow a relation recursively, see {@link follow}.
905
+ * The relation that is followed is automatically recursively followed.
906
+ * All nodes that are recursively followed are part of the same step in the path defined by this graph query.
907
+ *
908
+ * @param relation relation to follow recursively, specifies type and direction
909
+ * @param includeSelf if a starting node includes itself when the relation loops on itself
910
+ * @return a new query object
911
+ */
239
912
  followRecursively<D extends CloudObject>(relation: Relation<T, D>, includeSelf?: boolean): Query<D, R>;
240
913
 
241
- andReturn(): Query<T, [...R, T]>; // Add the current level of the query to the result. (Listdefs only support the last level to be returned).
914
+ /**
915
+ * Add the current working set of nodes to the result.
916
+ *
917
+ * Example:
918
+ * Query returning the instances of a model and the model itself
919
+ * ```javascript
920
+ * Query
921
+ * .from(myModelTag).andReturn()
922
+ * .follow(CloudObject.modelRel.getInverse()).andReturn()
923
+ * .execute();
924
+ * ```
925
+ * The result tuples are [modelCloudObject, instance1], [modelCloudObject, instance2], ...
926
+ *
927
+ * @return a new query object with the current level flagged to be returned.
928
+ */
929
+ andReturn(): Query<T, R extends never ? T : R extends CloudObject[] ? [...R, T] : [R, T]>;
242
930
 
931
+ /**
932
+ * Define a filter operation on the current working set of nodes.
933
+ * It filters out instances that don't match the given {@link Predicate}
934
+ *
935
+ * @param predicate
936
+ * @return a new query object with the new filter operation
937
+ */
243
938
  filter(predicate: Predicate): Query<T, R>;
939
+
940
+ /**
941
+ * Cast the type of the instances in the current working set of nodes
942
+ *
943
+ * @param type cast type for `CloudObjects`
944
+ * @return the
945
+ */
244
946
  cast<S extends CloudObject>(type: Class<S>): Query<S, R>;
245
947
 
246
- // Methods for which only the last call matters
948
+ /**
949
+ * Set the maximum number of tuples the executed query will return with an optional offset.
950
+ *
951
+ * Only the last call to limit matters.
952
+ *
953
+ * Example :
954
+ * ```javascript
955
+ * const queryLimited = query.limit(50).follow(myRel2).limit(100, 200).follow(myRel1);
956
+ * // is equivalent to
957
+ * const queryLimited2 = query.follow(myRel2).follow(myRel1).limit(100, 200);
958
+ * ```
959
+ * `queryLimited`, when executed, will return at most the 200th to the 299th (included) results.
960
+ *
961
+ * @param max maximum number of tuple to fetch from the final result
962
+ * @param offset number of skipped tuples for the final result
963
+ * @return new query with limit operation
964
+ */
247
965
  limit(max: number, offset?: number): Query<T, R>;
966
+
967
+ /**
968
+ * Sort the result tuples according to a property of a data type with a specified order.
969
+ **
970
+ * For the sortBy operator to be properly defined, the following must be true:
971
+ * - the property is defined on the instances that will be used for sorting.
972
+ * - the instances on which the sorting property is defined must be part of the result,
973
+ * i.e., `andReturn()` has been called before `sortBy()`.
974
+ *
975
+ * Only the last call to `sortBy` matters as it will be the last comparator set on the query.
976
+ * You should remove previous calls to `sortBy` for the same query.
977
+ *
978
+ * Example :
979
+ * ```javascript
980
+ * const sortQuery = Query
981
+ * .fromInstances(myModel1).andReturn()
982
+ * .sortBy(nameProperty)
983
+ * .follow(rel1).andReturn()
984
+ * .execute();
985
+ * ```
986
+ * This query fetches instances of a model, flags them as first element of result tuples.
987
+ * Then the query follows a relation to other instances and return them as second element of the result tuples.
988
+ * `sortBy` will sort the results according to the `nameProperty` of the first element in the result tuples in
989
+ * ascending order.
990
+ *
991
+ * @param property the property used for sorting
992
+ * @param order optional [Order.ASC]{@link Order#ASC} (default) or [Order.DESC]{@link Order#DESC} order
993
+ * @return new query with sort operation
994
+ */
248
995
  sortBy(property: Property<any>, order?: Order): Query<T, R>;
249
996
 
250
- execute(context: Context): Promise<QueryResult<R>>; // Execute the query on the datacloud (as a listdef) and deletes it afterwards.
251
- observe(context: Context): Observable<QueryResult<R>>; // Generate a subscription and get a new CloudArray for every update.
997
+ /**
998
+ * Execute the query asynchronously on the datacloud and deletes it afterwards.
999
+ * In other words, one cannot call execute twice on the same `Query`.
1000
+ *
1001
+ * @param context context in which the query must be executed. As this is an asynchronous operation,
1002
+ * one has to provide a context that won't be destroyed before the query has a result.
1003
+ * @return promise resolving to query result or failing otherwise.
1004
+ */
1005
+ execute(context: Context): Promise<QueryResult<R extends never ? T : R extends CloudObject | CloudObject[] ? R : never>>;
1006
+
1007
+ /**
1008
+ * Get an observable to the current value of the QueryResult for this Query instance.
1009
+ *
1010
+ * The observable gets the new value each time data modification in the datacloud changes the result of the query.
1011
+ *
1012
+ * The observable gets completed automatically once the specified context is [cleared]{@link Context#onClear}.
1013
+ *
1014
+ * @param context [context]{@link Context} to which the Observable is attached
1015
+ * @return Observable of QueryResult values
1016
+ */
1017
+ observe(context: Context): Observable<QueryResult<R extends never ? T : R extends CloudObject | CloudObject[] ? R : never>>;
252
1018
 
253
- executeFromCache(): QueryResult<R>; // Execute the query locally, using the DBView.
1019
+ /**
1020
+ * Execute synchronously the query on the local datacloud cache.
1021
+ * `executeFromCache` can only be called once on a given `Query`.
1022
+ *
1023
+ * @return query result of the execution on the local cache
1024
+ */
1025
+ executeFromCache(): QueryResult<R extends never ? T : R extends CloudObject | CloudObject[] ? R : never>;
254
1026
  }
255
1027
 
256
1028
  /**
257
- * A QuerySingle is a Query which follows relations that should be unique between CloudObjects (0..1 and 1..1 cardinalities).
258
- * It returns the CloudObjects related to the origin, following the specified relation(s).
1029
+ * A QuerySingle is a Query which follows relations that should be unique between data types (0..1 and 1..1 cardinalities).
1030
+ * It returns the instance related to the origin, following the specified relation(s).
259
1031
  *
260
- * It acts as a syntactic sugar to avoid having a CloudArray and get the first value.
1032
+ * It acts as a syntactic sugar to avoid having a query result structure and get the first value out of it.
261
1033
  *
262
1034
  * A QuerySingle is immutable.
263
1035
  */
264
1036
  export class QuerySingle<T extends CloudObject> {
1037
+ /**
1038
+ * Create a `query single` from a single node.
1039
+ * See [Query.from]{@link Query#from}
1040
+ *
1041
+ * @param object starting node for the graph query single
1042
+ * @return new query single only accepting 0..1 relations
1043
+ */
265
1044
  static from<T extends CloudObject>(object: Tag): QuerySingle<T>;
266
1045
 
1046
+ /**
1047
+ * Follow a 0..1 relation
1048
+ * See [Query.follow()]{@link Query#follow}
1049
+ *
1050
+ * @param relation relation to next node
1051
+ * @return new query single with follow operation
1052
+ */
267
1053
  follow<D extends CloudObject>(relation: Relation<T, D>): QuerySingle<D>;
1054
+
1055
+ /**
1056
+ * See [Query.cast()]{@link Query#cast}
1057
+ *
1058
+ * @param type the new type
1059
+ * @return query single on a node of the specified type
1060
+ */
268
1061
  cast<S extends CloudObject>(type: Class<S>): QuerySingle<S>;
269
1062
 
270
- execute(context: Context): Promise<T | null>; // Execute the query on the datacloud (as a listdef) and deletes it afterwards.
1063
+ /**
1064
+ * Execute the query single, see [Query.execute()]{@link Query#execute}
1065
+ *
1066
+ * @param context
1067
+ * @return promise containing the single result or `null`
1068
+ */
1069
+ execute(context: Context): Promise<T | null>;
271
1070
 
272
- executeFromCache(): T | null; // Execute the query locally, using the DBView.
1071
+ /**
1072
+ * Execute the query single on the local data cloud,
1073
+ * see [Query.executeFromCache()]{@link Query#executeFromCache}
1074
+ *
1075
+ * @return single result value or `null`
1076
+ */
1077
+ executeFromCache(): T | null;
273
1078
  }
274
1079
 
275
1080
  /**
276
1081
  * Predicates are used to filter queries.
1082
+ *
1083
+ * Example:
1084
+ * ```javascript
1085
+ * const predicate = Predicate.equals(myNumberProperty, 1);
1086
+ * const filteredQuery = Query.instancesOf(myModel).filter(predicate).andReturn();
1087
+ * ```
277
1088
  */
278
1089
  export class Predicate {
1090
+ /**
1091
+ * Create a predicate matching a specified property to a specified value.
1092
+ *
1093
+ * @param property the property to use for filtering
1094
+ * @param value the value the property must match
1095
+ * @return new Predicate with the equals operation
1096
+ */
279
1097
  static equals<T>(property: Property<T>, value: T): Predicate;
1098
+
1099
+ /**
1100
+ * Create a predicate matching a specified string property to a specified string.
1101
+ *
1102
+ * @param property the string property to use for filtering
1103
+ * @param value the value the string property must match
1104
+ * @param caseSensitive if the match must pay attention to case sensitivity
1105
+ * @return new Predicate with the contains string operation
1106
+ */
280
1107
  static contains(property: Property<string>, value: string, caseSensitive?: boolean): Predicate;
1108
+
1109
+ /**
1110
+ * Create a predicate matching a specified string property to a regular expression.
1111
+ *
1112
+ * @param property the string property to use for filtering
1113
+ * @param value the regex the string property must match
1114
+ * @param caseSensitive if the match must pay attention to case sensitivity
1115
+ * @return new Predicate with the match regex operation
1116
+ */
281
1117
  static regex(property: Property<string>, value: RegExp, caseSensitive?: boolean): Predicate;
282
1118
 
1119
+ /**
1120
+ * Create a predicate matching a specified number property to a numerical lower bound
1121
+ *
1122
+ * @param property the number property to user for filtering
1123
+ * @param value the lower bound
1124
+ * @param strict if the inequality is strict or not
1125
+ * @return new Predicate with the greaterThan mathematical operation
1126
+ */
283
1127
  static greaterThan(property: Property<number>, value: number, strict?: boolean): Predicate;
1128
+
1129
+ /**
1130
+ * Create a predicate matching a specified number property to a numerical upper bound
1131
+ *
1132
+ * @param property the number property to user for filtering
1133
+ * @param value the upper bound
1134
+ * @param strict if the inequality is strict or not
1135
+ * @return new Predicate with the smallerThan mathematical operation
1136
+ */
284
1137
  static smallerThan(property: Property<number>, value: number, strict?: boolean): Predicate;
285
1138
 
1139
+ /**
1140
+ * Create a predicate matching a specified number property to a number property lower bound
1141
+ *
1142
+ * @param property1 the number property to user for filtering
1143
+ * @param property2 the lower bound number property
1144
+ * @param strict if the inequality is strict or not
1145
+ * @return new Predicate with the greaterThan mathematical operation
1146
+ */
286
1147
  static greaterThan(property1: Property<number>, property2: Property<number>, strict?: boolean): Predicate;
1148
+
1149
+ /**
1150
+ * Create a predicate matching a specified number property to a number property upper bound
1151
+ *
1152
+ * @param property1 the number property to user for filtering
1153
+ * @param property2 the upper bound number property
1154
+ * @param strict if the inequality is strict or not
1155
+ * @return new Predicate with the smallerThan mathematical operation
1156
+ */
287
1157
  static smallerThan(property1: Property<number>, property2: Property<number>, strict?: boolean): Predicate;
288
1158
 
1159
+ /**
1160
+ * Create an AND composite predicate matching a specified set of predicates
1161
+ *
1162
+ * @param predicates list of predicates to match
1163
+ * @return new Predicate that should match all specified predicates
1164
+ */
289
1165
  static and(...predicates: Predicate[]): Predicate;
1166
+
1167
+ /**
1168
+ * Create an OR composite predicate matching a specified set of predicates
1169
+ *
1170
+ * @param predicates list of predicates to match
1171
+ * @return new Predicate that should match at least one specified predicate
1172
+ */
290
1173
  static or(...predicates: Predicate[]): Predicate;
1174
+
1175
+ /**
1176
+ * Create a NOT predicate matching the opposite of a specified predicate
1177
+ *
1178
+ * @param predicate the predicate to inverse
1179
+ * @return new Predicate that match when the specified predicate does not
1180
+ */
291
1181
  static not(predicate: Predicate): Predicate;
292
1182
  }
293
1183
 
1184
+ /**
1185
+ * Specific predicate class creator for filtering based on relations between objects
1186
+ *
1187
+ * A path is defined by a list of relations, and an object match the predicate if and only if the patch can be followed
1188
+ * to a destination (which might be specified)
1189
+ */
294
1190
  export class RelatedTo extends Predicate {
295
1191
  constructor(destination?: Tag);
1192
+
1193
+ /**
1194
+ * Adds a relation to the path the RelatedTo predicate must match
1195
+ *
1196
+ * @param relation relation to add to the path
1197
+ * @return new RelatedTo predicate with additional relation to match in the path
1198
+ */
296
1199
  follow(relation: Relation<any, any>): RelatedTo;
1200
+
1201
+ /**
1202
+ * Adds a relation that can be followed recursively in the path for the RelatedTo predicate
1203
+ *
1204
+ * @param relation relation to add to the path that can be followed recursively
1205
+ * @return new RelatedTo predicate with additional relation that can be matched recursively in the path
1206
+ */
297
1207
  followRecursive(relation: Relation<any, any>): RelatedTo;
298
1208
  }
299
1209