@olympeio/runtime-node 9.3.0 → 9.4.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.
Files changed (28) hide show
  1. package/import/dcInitConfig.json +1 -1
  2. package/import/olympe.dm/datamodel/00_bootstrap.newInst.json +1 -1
  3. package/import/olympe.dm/datamodel/00_bootstrap.newRel.json +1 -1
  4. package/import/olympe.dm/datamodel/01_primitives.newInst.json +1 -1
  5. package/import/olympe.dm/datamodel/01_primitives.newRel.json +1 -1
  6. package/import/olympe.dm/datamodel/02_permissions.newInst.json +1 -1
  7. package/import/olympe.dm/datamodel/02_permissions.newRel.json +1 -1
  8. package/import/olympe.dm/datamodel/03_file.newInst.json +1 -1
  9. package/import/olympe.dm/datamodel/03_file.newRel.json +1 -1
  10. package/import/olympe.dm/datamodel/04_modules.newInst.json +1 -1
  11. package/import/olympe.dm/datamodel/04_modules.newRel.json +1 -1
  12. package/import/olympe.dm/datamodel/05_permission_schema.newInst.json +1 -1
  13. package/import/olympe.dm/datamodel/05_permission_schema.newRel.json +1 -1
  14. package/import/olympe.dm/datamodel/05_permission_schema.updateInst.json +1 -1
  15. package/import/olympe.dm/datamodel/06_structure.newInst.json +1 -1
  16. package/import/olympe.dm/datamodel/06_structure.newRel.json +1 -1
  17. package/import/olympe.sc/datamodel/00_primordial.newInst.json +1 -1
  18. package/import/olympe.sc/datamodel/00_primordial.newRel.json +1 -1
  19. package/import/olympe.sc/datamodel/01_language.newInst.json +1 -1
  20. package/import/olympe.sc/datamodel/01_language.newRel.json +1 -1
  21. package/import/olympe.sc/datamodel/02_bricks.newInst.json +1 -1
  22. package/import/olympe.sc/datamodel/02_bricks.newRel.json +1 -1
  23. package/index.js +765 -832
  24. package/package.json +7 -10
  25. package/types/base.d.ts +22 -2
  26. package/types/cloud.d.ts +478 -50
  27. package/types/runtime.d.ts +6 -6
  28. package/types/utils.d.ts +47 -3
package/types/cloud.d.ts CHANGED
@@ -38,6 +38,8 @@ export class PropertyModel extends CloudObject {
38
38
  static typeRel: Relation<PropertyModel, CloudObject>;
39
39
  }
40
40
 
41
+ export type FollowRule = Property<number>;
42
+
41
43
  /**
42
44
  * A relation model defines a relation between two data types.
43
45
  * It defines what data types is the origin and the destination of the relation.
@@ -56,15 +58,15 @@ export class RelationModel extends CloudObject {
56
58
  /**
57
59
  * Property for the *dump* follow rule
58
60
  */
59
- static dumpFollowRuleProp: Property<number>;
61
+ static dumpFollowRuleProp: FollowRule;
60
62
  /**
61
63
  * Property for the *delete* follow rule
62
64
  */
63
- static deleteFollowRuleProp: Property<number>;
65
+ static deleteFollowRuleProp: FollowRule;
64
66
  /**
65
67
  * Property for the *runtime* follow rule
66
68
  */
67
- static runtimeFollowRuleProp: Property<number>;
69
+ static runtimeFollowRuleProp: FollowRule;
68
70
  }
69
71
 
70
72
  /**
@@ -103,41 +105,67 @@ export class ColorModel extends CloudObject {
103
105
  }
104
106
 
105
107
  /**
106
- * File with content as binary or string data
108
+ * File is the main class used to create business objects with a binary/string data content.
109
+ * It is a Data Type so can be extended and associated to a data source.
107
110
  */
108
111
  export class File extends CloudObject {
109
112
 
113
+ /**
114
+ * @deprecated because conflict with {@apilink CloudObject.nameProp}. Use {@apilink File.fileNameProp} instead.
115
+ */
110
116
  static nameProp: Property<string>;
117
+ static fileNameProp: Property<string>;
111
118
  static creationDateProp: Property<Date>;
112
119
  static modificationDateProp: Property<Date>;
113
120
  static mimeTypeProp: Property<string>;
114
121
  static urlProp: Property<string>;
115
122
 
116
123
  /**
124
+ * Set the binary content of a specified file
125
+ * @param transaction transaction in which to create the file
126
+ * @param file tag of the file
127
+ * @param name file name
128
+ * @param content byte content of the file
129
+ * @param mimeType optional mime type of the file
130
+ */
131
+ static setContent(transaction: Transaction, file: Tag, name: string, content: ArrayBuffer, mimeType?: string);
132
+
133
+ /**
134
+ * Set the content of a `File` from a specified URL
135
+ * @param transaction transaction in which to create the file
136
+ * @param file tag of the file
137
+ * @param name filename
138
+ * @param url url to retrieve content from
139
+ * @param mimeType optional mime type of the file
140
+ */
141
+ static setURLContent(transaction: Transaction, file: Tag, name: string, url: string, mimeType?: string);
142
+
143
+ /**
144
+ * @deprecated Please use {@apilink File.setContent}
117
145
  * Create a `File` from its content
118
146
  *
119
147
  * @param transaction transaction in which to create the file
120
148
  * @param name filename
121
149
  * @param content byte content of the file
122
150
  * @param mimeType optional mime type of the file
123
- * @param source optional source where file will be stored ('server', 'self' or DBConnector tag)
151
+ * @param source optional source where file will be stored ({@apilink {PredefinedDataSource}} or DBConnector tag)
124
152
  * @param tag optional tag for the file
125
153
  * @return tag string of the file
126
154
  */
127
- static createFromContent(transaction: Transaction, name: string, content: ArrayBuffer, mimeType?: string, source?: string, tag?: string): string;
155
+ static createFromContent(transaction: Transaction, name: string, content: ArrayBuffer, mimeType?: string, source?: Source, tag?: string): string;
128
156
 
129
157
  /**
158
+ * @deprecated Please use {@apilink File.setURLContent}
130
159
  * Create a `File` from a specified URL
131
- *
132
160
  * @param transaction transaction in which to create the file
133
161
  * @param name filename
134
162
  * @param url url to retrieve content from
135
163
  * @param mimeType optional mime type of the file
136
- * @param source optional source where file will be stored ('server', 'self' or DBConnector tag)
164
+ * @param source optional source where file will be stored ({@apilink {PredefinedDataSource}} or DBConnector tag)
137
165
  * @param tag optional tag for the file
138
166
  * @return tag string of the file
139
167
  */
140
- static createFromURL(transaction: Transaction, name: string, url: string, mimeType?: string, source?: string, tag?: string): string;
168
+ static createFromURL(transaction: Transaction, name: string, url: string, mimeType?: string, source?: Source, tag?: string): string;
141
169
 
142
170
  /**
143
171
  * Retrieve content from this file asynchronously
@@ -336,7 +364,7 @@ export class Theme extends CloudObject {
336
364
  * In most cases, we apply the Transactions operations using the "execute()" method. The transaction size is limited but in real-time.
337
365
  * It notifies observers of the data in real-time.
338
366
  *
339
- * Larger transactions with big set of operations (batch updates) must be executed using "executeAsLarge()" method. However no notification will be generated.
367
+ * Larger transactions with big set of operations (batch updates) must be executed using "executeAsLarge()" method. However, no notification will be generated.
340
368
  *
341
369
  * Callbacks can be registered on transaction using "afterExecution()" method. They are executed once the transaction is applied.
342
370
  *
@@ -372,7 +400,7 @@ export class Transaction {
372
400
  *
373
401
  * A custom map can specify property values for the instance.
374
402
  *
375
- * A source can be the orchestrator ('server'), local ('self') or
403
+ * A source can be the orchestrator ({@apilink {PredefinedDataSource.SERVER}}), local ({@apilink {PredefinedDataSource.SELF}}) or
376
404
  * an external data source (tag of DBConnector). The source is where
377
405
  * the object is persisted and its true value outside local scopes.
378
406
  *
@@ -382,7 +410,7 @@ export class Transaction {
382
410
  * @param tag optional tag of the instance to be created and must be unique
383
411
  * @return the tag of the instance to be created
384
412
  */
385
- create(model: Tag, properties?: Map<Tag, any>, source?: string, tag?: string): string;
413
+ create(model: Tag, properties?: Map<Tag, any>, source?: Source, tag?: string): string;
386
414
 
387
415
  /**
388
416
  * Update the property of an instance
@@ -474,9 +502,8 @@ export class Transaction {
474
502
  * Change the source of all instances created in this transaction
475
503
  *
476
504
  * `source` can be specified as :
477
- * 1. the orchestrator ('server'),
478
- * 2. local ('self') or
479
- * 3. an external data source (Tag of a `DBConnector`)
505
+ * 1. a predefined source type {@apilink {PredefinedDataSource}}
506
+ * 2. an external data source (Tag of a `DBConnector`)
480
507
  *
481
508
  * The source of a data object is where the object is persisted.
482
509
  *
@@ -485,7 +512,7 @@ export class Transaction {
485
512
  * @param source the new source for instances
486
513
  * @return this transaction
487
514
  */
488
- setSource(source: string): this;
515
+ setSource(source: Source): this;
489
516
 
490
517
  /**
491
518
  * Retrieve the tag of the model of the instance tag
@@ -495,7 +522,7 @@ export class Transaction {
495
522
  * @param tag the instance to find the model of
496
523
  * @return the tag of the model of the given instance
497
524
  */
498
- model(tag: Tag): string;
525
+ model(tag: Tag): string | null;
499
526
 
500
527
  /**
501
528
  * Add all operations of another transaction into this transaction
@@ -516,21 +543,21 @@ export class Transaction {
516
543
  afterExecution(callback: (success: boolean, message?: string) => void): this;
517
544
 
518
545
  /**
519
- * Execute atomically the transaction at the source
546
+ * Execute atomically the transaction at the data sources. Return the transaction result if succeeds.
520
547
  *
521
- * @return promise resolving if the transaction succeeds,
548
+ * @return promise resolving with the corresponding TransactionResult if the transaction succeeds,
522
549
  * rejecting if the transaction fails
523
550
  */
524
- execute(): Promise<void>;
551
+ execute(): Promise<TransactionResult>;
525
552
 
526
553
  /**
527
- * Execute atomically a transaction at the source
554
+ * Execute atomically a transaction at the data source and returns the transaction result if succeeds.
528
555
  * The `large` mode sends the transaction over HTTP
529
556
  *
530
- * @return promise resolving if the transaction succeeds,
557
+ * @return promise resolving with the corresponding TransactionResult if the transaction succeeds,
531
558
  * rejecting if the transaction fails.
532
559
  */
533
- executeAsLarge(): Promise<void>;
560
+ executeAsLarge(): Promise<TransactionResult>;
534
561
 
535
562
  /**
536
563
  * Start a transaction using an existing transaction in the provided context
@@ -551,6 +578,41 @@ export class Transaction {
551
578
  static process($: BrickContext, transaction: Transaction): Promise<boolean>;
552
579
  }
553
580
 
581
+ /**
582
+ * Predefined data sources that can be used for {@apilink Transaction.setSource}.
583
+ */
584
+ export enum PredefinedDataSource {
585
+ /**
586
+ * Local DataSource. By using this source, objects are not persisted
587
+ */
588
+ SELF = 'self',
589
+ /**
590
+ * Embedded Graph Database
591
+ */
592
+ SERVER = 'server'
593
+ }
594
+
595
+ /**
596
+ * When manipulating CloudObjects, sometimes it is required to manually set the data source of that object.
597
+ * `Source` determines where the object comes from: what data source is the owner of the object across the ecosystem.
598
+ */
599
+
600
+ export type Source = PredefinedDataSource | string;
601
+
602
+ /**
603
+ * A transaction result is the object received after a transaction has been executed successfully.
604
+ * It provides information about what has been done.
605
+ */
606
+ export class TransactionResult {
607
+
608
+ /**
609
+ * Return the ordered list of CloudObjects created in this transaction.
610
+ *
611
+ * @return the list of CloudObjects instances
612
+ */
613
+ getCreatedObjects(): CloudObject[];
614
+ }
615
+
554
616
  /**
555
617
  * BurstTransactions are designed to continuously apply high rates of updates on properties (FIFO ordering).
556
618
  * The only operation supported by BurstTransactions is to update properties of an instance.
@@ -608,7 +670,7 @@ export class QueryResult<T extends CloudObject | CloudObject[]> {
608
670
  static empty(): QueryResult<any>;
609
671
 
610
672
  /**
611
- * Symbol iterator for `for..in` syntactic sugar
673
+ * Symbol iterator for `forin` syntactic sugar
612
674
  *
613
675
  * @return iterator over the key-values pairs of this `QueryResult`
614
676
  */
@@ -890,18 +952,29 @@ export class Query<T extends CloudObject, R> {
890
952
  * @param source optional source of the data to answer the query
891
953
  * @return an empty Query whose starting point is defined by a single `CloudObject`
892
954
  */
893
- static from<T extends Tag>(tag: T, source?: string): Query<T extends CloudObject ? T : CloudObject, never>;
955
+ static from<T extends Tag>(tag: T, source?: Source): Query<T extends CloudObject ? T : CloudObject, never>;
894
956
 
895
957
  /**
896
- * Create a query starting from the instances of the specified model
958
+ * Create a query starting from the instances of the specified model. By default, it does include the instances of
959
+ * the models that inherit from the given one.
897
960
  *
898
961
  * @param model tag/class of the model to find the instances of
962
+ * @param includeInheritance if set to false, the result will not include instances of models that inherit from the given model.
899
963
  * @param source optional source of the data to answer the query
900
964
  * A source can be the orchestrator ('server'), local ('self') or
901
965
  * an external data source (Tag of a `DBConnectorTag`)
902
966
  * @return a new query object starting from model instances
903
967
  */
904
- static instancesOf<T extends Tag>(model: Class<T> | Tag, source?: string): Query<T extends CloudObject ? T : CloudObject, never>;
968
+ static instancesOf<T extends Tag>(model: Class<T> | Tag, includeInheritance?: boolean, source?: Source): Query<T extends CloudObject ? T : CloudObject, never>;
969
+
970
+ /**
971
+ * Create a query starting from a specific root instance, then following relations based on a rule constraint.
972
+ * @param ctx Context in which the {@apilink Query} is observed
973
+ * @param root Starting point of the query. See `root` of {@apilink RootQueryPart}
974
+ * @param rule Discriminate which relations to follow
975
+ * @param source The tag of the source responsible for executing the query
976
+ */
977
+ static followRule<T extends Tag>(ctx: Context, root: T, rule: FollowRule, source?: Source): Observable<QueryResult<T extends CloudObject ? T : CloudObject>>;
905
978
 
906
979
  /**
907
980
  * Instruct the query to follow a specified relation. This does not add any key-value pair to the result.
@@ -914,9 +987,10 @@ export class Query<T extends CloudObject, R> {
914
987
  * ```
915
988
  *
916
989
  * @param relation relation to follow, specifies type and direction
990
+ * @param optional whether or not the relation creates a mandatory path in the graph to be part of the result.
917
991
  * @return a new query object
918
992
  */
919
- follow<D extends CloudObject>(relation: Relation<T, D>): Query<D, R>;
993
+ follow<D extends CloudObject>(relation: Relation<T, D>, optional?: boolean): Query<D, R>;
920
994
 
921
995
  /**
922
996
  * Follow a relation recursively, see {@apilink Query.follow}.
@@ -925,9 +999,44 @@ export class Query<T extends CloudObject, R> {
925
999
  *
926
1000
  * @param relation relation to follow recursively, specifies type and direction
927
1001
  * @param includeSelf if a starting node includes itself when the relation loops on itself
1002
+ * @param optional whether or not the relation creates a mandatory path in the graph to be part of the result.
928
1003
  * @return a new query object
929
1004
  */
930
- followRecursively<D extends CloudObject>(relation: Relation<T, D>, includeSelf?: boolean): Query<D, R>;
1005
+ followRecursively<D extends CloudObject>(relation: Relation<T, D>, includeSelf?: boolean, optional?: boolean): Query<D, R>;
1006
+
1007
+ /**
1008
+ * The Query.back() function is used to move the cursor of a query backwards to the previous level.
1009
+ * This allows the query to start from the place where it was before a Query.follow() call,
1010
+ * but with a different relation. The `times` parameter is optional and specifies the number of steps to go back.
1011
+ * If hops is not specified, the default value of 1 is used.
1012
+ * If a value <= 0 is specified, the output query is the same as the input query.
1013
+ *
1014
+ * Example:
1015
+ * const people = [
1016
+ * { name: "Alice", children: ["Bob", "Carol"], siblings: ["David"] },
1017
+ * { name: "Bob", children: ["Emily"], siblings: ["Alice", "Carol", "David"] },
1018
+ * { name: "Carol", children: ["Frank"], siblings: ["Alice", "Bob", "David"] },
1019
+ * { name: "David", children: ["Greg"], siblings: ["Alice", "Bob", "Carol"] },
1020
+ * { name: "Emily", children: [], siblings: [] },
1021
+ * { name: "Frank", children: [], siblings: [] },
1022
+ * { name: "Greg", children: [], siblings: [] }
1023
+ * ];
1024
+ *
1025
+ * // Create a new query starting from Alice
1026
+ * const aliceQuery = Query.from("Alice");
1027
+ *
1028
+ * // Follow the "children" relation to get Alice's children (Bob, Carol)
1029
+ * const aliceChildrenQuery = aliceQuery.follow("children").andReturn();
1030
+ *
1031
+ * // Go back to the previous level and follow the "siblings" relation to get Alice's siblings (David)
1032
+ * const aliceSiblingsQuery = aliceChildrenQuery.back().follow("siblings").andReturn();
1033
+ *
1034
+ * // Execute the query, the output is:
1035
+ * Output: [ { sibling: 'David', child: 'Bob' }, { sibling: 'David', child: 'Carol' } ]
1036
+ * @param times
1037
+ * @return {!Query}
1038
+ */
1039
+ back(times?: number): Query<CloudObject, R>;
931
1040
 
932
1041
  /**
933
1042
  * Add the current working set of nodes to the result.
@@ -1012,6 +1121,11 @@ export class Query<T extends CloudObject, R> {
1012
1121
  */
1013
1122
  sortBy(property: Property<any>, order?: Order): Query<T, R>;
1014
1123
 
1124
+ /**
1125
+ * @return the query transformed as a tree of QueryPart. To be used by Data Source.
1126
+ */
1127
+ parse(): RootQueryPart;
1128
+
1015
1129
  /**
1016
1130
  * Execute the query asynchronously on the datacloud and deletes it afterwards.
1017
1131
  * In other words, one cannot call execute twice on the same `Query`.
@@ -1105,6 +1219,14 @@ export class QuerySingle<T extends CloudObject> {
1105
1219
  * ```
1106
1220
  */
1107
1221
  export class Predicate {
1222
+
1223
+ /**
1224
+ * Create a predicate to match the specified object(s).
1225
+ *
1226
+ * @param tags the object or unique identifier (tag) of the objects to look for.
1227
+ */
1228
+ static in(...tags: Tag[]): Predicate;
1229
+
1108
1230
  /**
1109
1231
  * Create a predicate matching a specified property to a specified value.
1110
1232
  *
@@ -1119,7 +1241,7 @@ export class Predicate {
1119
1241
  *
1120
1242
  * @param property the string property to use for filtering
1121
1243
  * @param value the value the string property must match
1122
- * @param caseSensitive if the match must pay attention to case sensitivity
1244
+ * @param caseSensitive if the match must pay attention to case sensitivity, default value is false
1123
1245
  * @return new Predicate with the contains string operation
1124
1246
  */
1125
1247
  static contains(property: Property<string>, value: string, caseSensitive?: boolean): Predicate;
@@ -1129,7 +1251,7 @@ export class Predicate {
1129
1251
  *
1130
1252
  * @param property the string property to use for filtering
1131
1253
  * @param value the regex the string property must match
1132
- * @param caseSensitive if the match must pay attention to case sensitivity
1254
+ * @param caseSensitive if the match must pay attention to case sensitivity, default value is false
1133
1255
  * @return new Predicate with the match regex operation
1134
1256
  */
1135
1257
  static regex(property: Property<string>, value: RegExp, caseSensitive?: boolean): Predicate;
@@ -1154,6 +1276,16 @@ export class Predicate {
1154
1276
  */
1155
1277
  static smallerThan(property: Property<number>, value: number, strict?: boolean): Predicate;
1156
1278
 
1279
+ /**
1280
+ * Create a predicate matching the expected model. If extend=true, the predicate will match
1281
+ * against inherited models as well
1282
+ *
1283
+ * @param expectedModel the expected model
1284
+ * @param extend should the predicate also match against inherited models
1285
+ * @return new Predicate
1286
+ */
1287
+ static instanceOf(expectedModel: Tag, extend: boolean): Predicate;
1288
+
1157
1289
  /**
1158
1290
  * Create a predicate matching a specified number property to a number property lower bound
1159
1291
  *
@@ -1200,32 +1332,328 @@ export class Predicate {
1200
1332
  }
1201
1333
 
1202
1334
  /**
1203
- * Specific predicate class creator for filtering based on relations between objects
1204
- *
1205
- * A path is defined by a list of relations, and an object match the predicate if and only if the patch can be followed
1206
- * to a destination (which might be specified)
1335
+ * The sorting order for a {@apilink QueryPart}.
1207
1336
  */
1208
- export class RelatedTo extends Predicate {
1209
- constructor(destination?: Tag);
1337
+ export enum Order {
1338
+ /**
1339
+ * Ascending order.
1340
+ */
1341
+ ASC,
1342
+ /**
1343
+ * Descending order.
1344
+ */
1345
+ DESC
1346
+ }
1347
+
1348
+ /**
1349
+ * A class representing the necessary operations to create the result of a query in the client database
1350
+ * that emitted the query.
1351
+ */
1352
+ export class DataResult {
1210
1353
 
1211
1354
  /**
1212
- * Adds a relation to the path the RelatedTo predicate must match
1213
- *
1214
- * @param relation relation to add to the path
1215
- * @return new RelatedTo predicate with additional relation to match in the path
1355
+ * Create a new {@apilink DataResult} instance from the specified {@apilink Query}.
1356
+ * @param query The {@apilink Query} to create a {@apilink DataResult} from.
1357
+ * @return A new {@apilink DataResult} instance.
1216
1358
  */
1217
- follow(relation: Relation<any, any>): RelatedTo;
1359
+ static fromQuery(query: Query<CloudObject, any>): DataResult;
1218
1360
 
1219
1361
  /**
1220
- * Adds a relation that can be followed recursively in the path for the RelatedTo predicate
1221
- *
1222
- * @param relation relation to add to the path that can be followed recursively
1223
- * @return new RelatedTo predicate with additional relation that can be matched recursively in the path
1362
+ * Create a new Data Type instance with the specified {@apilink Tag}, Data Type and properties.
1363
+ * @param tag The unique identifier of the object instance to create.
1364
+ * @param model The Data Type of the instance to create.
1365
+ * @param properties The properties to set on the instance.
1366
+ * @return This {@apilink DataResult} instance.
1224
1367
  */
1225
- followRecursive(relation: Relation<any, any>): RelatedTo;
1368
+ create(tag: Tag, model: Tag, properties?: Map<Tag, any>): this;
1369
+
1370
+ /**
1371
+ * Create a relation between two instances with the specified {@apilink Relation}, `from`, and `to` instance tags.
1372
+ * @param relation The type of relation to create.
1373
+ * @param from The unique identifier of the source instance.
1374
+ * @param to The unique identifier of the destination instance.
1375
+ * @return This {@apilink DataResult} instance.
1376
+ */
1377
+ createRelation(relation: Tag, from: Tag, to: Tag): this;
1226
1378
  }
1227
1379
 
1228
- export enum Order {
1229
- ASC,
1230
- DESC
1380
+ /**
1381
+ * Represents an operation that can be performed regarding data type instances.
1382
+ */
1383
+ export type Operation =
1384
+ {
1385
+ /** Creates a new instance of a data type with the given properties. */
1386
+ type: 'CREATE',
1387
+ /** The tag of the new instance. */
1388
+ object: string,
1389
+ /** The data type tag of the instance being created. */
1390
+ model: string,
1391
+ /** A map that maps the tag of a property to a new/updated value.
1392
+ * You may need to parse this value to store it in your data source (e.g. JS date)
1393
+ * */
1394
+ properties?: Map<string, any>
1395
+ } |
1396
+ {
1397
+ /** Updates an existing instance of a data type with the given properties. */
1398
+ type: 'UPDATE',
1399
+ /** The tag of the instance being updated. */
1400
+ object: string,
1401
+ /** The data type tag of the instance being updated. */
1402
+ model: string,
1403
+ /** A map that maps the tag of a property to a new/updated value.
1404
+ * You may need to parse this value to store it in your data source (e.g. JS date)
1405
+ * */
1406
+ properties: Map<string, any>
1407
+ } |
1408
+ {
1409
+ /** Deletes an existing instance of a data type. */
1410
+ type: 'DELETE',
1411
+ /** The tag of the instance being deleted. */
1412
+ object: string,
1413
+ /** The data type tag of the instance being deleted. */
1414
+ model: string
1415
+ } |
1416
+ {
1417
+ /** Creates a new relation between two instances of a data type. */
1418
+ type: 'CREATE_RELATION',
1419
+ /** The tag of the relation being created. */
1420
+ relation: string,
1421
+ /** The tag of the starting instance. */
1422
+ from: string,
1423
+ /** The tag of the ending instance. */
1424
+ to: string,
1425
+ /** The data type tag of the starting instance. */
1426
+ fromModel: string,
1427
+ /** The data type tag of the ending instance. */
1428
+ toModel: string
1429
+ } |
1430
+ {
1431
+ /** Deletes an existing relation between two instances of a data type. */
1432
+ type: 'DELETE_RELATION',
1433
+ /** The tag of the relation being deleted. */
1434
+ relation: string,
1435
+ /** The tag of the starting instance. */
1436
+ from: string,
1437
+ /** The tag of the ending instance. */
1438
+ to: string,
1439
+ /** The data type tag of the starting instance. */
1440
+ fromModel: string,
1441
+ /** The data type tag of the ending instance. */
1442
+ toModel: string
1443
+ };
1444
+ /**
1445
+ * Details for a predicate from the OLYMPE query API
1446
+ */
1447
+ export type ParsedPredicate =
1448
+ {
1449
+ /** Checks if the instance has any of the specified tags. */
1450
+ name: 'IS',
1451
+ /** An array of tags to check against. */
1452
+ tags: string[]
1453
+ } |
1454
+ {
1455
+ /** Checks if a string type property contains a specific string value. */
1456
+ name: 'CONTAINS',
1457
+ /** The tag of the property being checked. */
1458
+ property: string,
1459
+ /** The value being searched for. */
1460
+ value: string,
1461
+ /** Whether the search should be case-sensitive or not. */
1462
+ caseSensitive: boolean
1463
+ } |
1464
+ {
1465
+ /** Checks if a property equals a specific value. */
1466
+ name: 'EQUALS',
1467
+ /** The tag of the property being checked. */
1468
+ property: string,
1469
+ /** The value being compared to. */
1470
+ value: any
1471
+ } |
1472
+ {
1473
+ /** Checks if a property is greater than or less than a specific value. */
1474
+ name: 'INEQUALITY_OPERATOR',
1475
+ /** The tag of the property being compared. */
1476
+ property: string,
1477
+ /** The value being compared to. */
1478
+ value: any,
1479
+ /** The operator being used in the comparison (e.g. "<", ">"). */
1480
+ operator: string,
1481
+ /** Whether the comparison should be strict (e.g. "<" vs. "<="). */
1482
+ strict: boolean
1483
+ } |
1484
+ {
1485
+ /** Negates a predicate. */
1486
+ name: 'NOT',
1487
+ /** The predicate being negated. */
1488
+ predicate: ParsedPredicate
1489
+ } |
1490
+ {
1491
+ /** Checks if a property matches a regular expression pattern. */
1492
+ name: 'REGEX',
1493
+ /** The tag of the property being checked. */
1494
+ property: string,
1495
+ /** The regular expression pattern being matched. */
1496
+ pattern: string,
1497
+ /** Whether the matching should be case-sensitive or not. */
1498
+ caseSensitive: boolean
1499
+ };
1500
+
1501
+ /**
1502
+ * The first part of a {@apilink Query}.
1503
+ * It breaks down the starting point of the query.
1504
+ */
1505
+ export interface RootQueryPart extends QueryPart {
1506
+ /**
1507
+ * The tag of the starting point of a query built using {@apilink Query.from()}
1508
+ * It is the tag of the instance where the first relation followed using {@apilink Query.follow()} starts from.
1509
+ * For queries on instances of a data type, started with {@apilink Query.instancesOf()}, this will be null.
1510
+ */
1511
+ root?: string
1512
+ /**
1513
+ * The tag of the Data Type of the instance(s) determining the starting point of the query.
1514
+ * It is the tag of the Data Type provided to {@apilink Query.instancesOf()}, or the Data Type of the root instance provided
1515
+ * to {@apilink Query.from()}
1516
+ */
1517
+ dataType: string
1518
+ /**
1519
+ * Specifies whether instances of the data types inheriting from the root data type should be included in the query or not.
1520
+ * It is always `false` if `root` is specified.
1521
+ */
1522
+ inheritance: boolean
1523
+ /**
1524
+ * Limits the number of results retrieved by the query.
1525
+ */
1526
+ limit: number
1527
+ /**
1528
+ * Skips a specified number of results retrieved by the query.
1529
+ */
1530
+ offset: number
1531
+ }
1532
+
1533
+ /**
1534
+ * A part of a {@apilink Query} that specifies a relationship to traverse.
1535
+ */
1536
+ export interface QueryPart {
1537
+ /**
1538
+ * Determines whether the relationship should be traversed recursively and whether the starting object should be included.
1539
+ * `false`: Traverse the relationship once.
1540
+ * `'EXCLUDE_SELF'`: Traverse the relationship recursively, excluding the starting object.
1541
+ * `'INCLUDE_SELF'`: Traverse the relationship recursively, including the starting object.
1542
+ */
1543
+ recursive: false | 'EXCLUDE_SELF' | 'INCLUDE_SELF',
1544
+ /**
1545
+ * Specifies a relationship to traverse in the query.
1546
+ */
1547
+ relation: Relation<any, any>
1548
+ /**
1549
+ * Determines whether the relationship this part specifies is optional or not to traverse.
1550
+ * If `true`, result tuples may have a null if this relationship can not be followed from some data objects.
1551
+ * If `false`, all result tuples must contain this relationship.
1552
+ */
1553
+ optional: boolean,
1554
+ /**
1555
+ * Determines whether the related objects should be included in the result tuples.
1556
+ * If `true`, related objects will be included.
1557
+ * If `false`, the related objects are not included.
1558
+ * This does not impact whether the relationship is `optional` to be traversed.
1559
+ */
1560
+ returned: boolean,
1561
+ /**
1562
+ * Specify if the instances obtained by following the relation should satisfy some condition
1563
+ * See {@apilink ParsedPredicate}
1564
+ */
1565
+ filter: ParsedPredicate[][],
1566
+ /**
1567
+ * Set a sorting order on the result tuples according to the related objects.
1568
+ * It will sort using native order of the type of the property.
1569
+ * For multiple parts with sort information, the latest part will prevail.
1570
+ */
1571
+ sort?: {property: Property<any>, order: Order}
1572
+ /**
1573
+ * Returns the remaining {@apilink QueryPart}s of the query, empty if no {@apilink QueryPart}s are left.
1574
+ */
1575
+ next: QueryPart[]
1576
+ }
1577
+ /**
1578
+ * Represents a data source that can be used to retrieve, manipulate and store data outside the Olympe application environment.
1579
+ * This class provides several methods for performing CRUD (create, read, update, delete) operations on data,
1580
+ * as well as file upload and download functionality.
1581
+ * @abstract
1582
+ * @extends {@apilink CloudObject}
1583
+ */
1584
+ export abstract class DataSource extends CloudObject {
1585
+
1586
+ /**
1587
+ * Returns the tag of the data source.
1588
+ * @return {string} tag of the data source.
1589
+ */
1590
+ getId(): string;
1591
+
1592
+ /**
1593
+ * Retrieves the configuration value associated with the provided key in the data source oConfig.
1594
+ * @param {string} key - Key to retrieve the configuration value for.
1595
+ * @return {*} The configuration value associated with the provided key.
1596
+ */
1597
+ getConfig(key: string): any;
1598
+
1599
+ /**
1600
+ * Initializes the data source connection with custom parameters provided in oConfig.
1601
+ * It can also perform a health check to ensure the connection is active.
1602
+ * Subscribes to the {@apilink DataSource.observeDataTypes} observable to handle changes to the data types in the data source.
1603
+ *
1604
+ * @param {!Context} context a context with the same livecycle as the Data Source
1605
+ * @return A promise that resolves with void when initialization is complete. Reject if initialization did not complete.
1606
+ */
1607
+ protected init(context): Promise<void>;
1608
+
1609
+ /**
1610
+ * Performs a health check on the data source, checking if the connection is alive.
1611
+ * @return {Promise<void>} A Promise that resolves when the health check is completed successfully, rejects otherwise.
1612
+ */
1613
+ protected healthCheck(): Promise<void>;
1614
+
1615
+ /**
1616
+ * Disconnects the data source.
1617
+ * @return {Promise<void>} A Promise that resolves when the data source is destroyed.
1618
+ */
1619
+ protected destroy(): Promise<void>;
1620
+
1621
+ /**
1622
+ * Executes the provided {@apilink Query} once and returns a {@apilink DataResult}.
1623
+ * @param {Query<CloudObject, any>} query - The {@apilink Query} object to execute.
1624
+ * @return {Promise<DataResult>} A Promise that resolves with the {@apilink DataResult} object.
1625
+ */
1626
+ protected executeQuery(query: Query<CloudObject, any>): Promise<DataResult>;
1627
+
1628
+ /**
1629
+ * Applies the provided {@apilink Operation} array to the data source as one transaction
1630
+ * @param {Operation[]} transaction - The {@apilink Operation} array to apply.
1631
+ * @return {Promise<void>} A Promise that resolves when the transaction is completed. Rejects when the transaction fails.
1632
+ */
1633
+ protected applyTransaction(transaction: Operation[]): Promise<void>;
1634
+
1635
+ /**
1636
+ * Uploads one file's content to the data source.
1637
+ * @param {string} fileTag - The tag of the file.
1638
+ * @param {string} dataType - The file data type
1639
+ * @param {Uint8Array} binary - The binary data of the file.
1640
+ * @return {Promise<void>} A Promise that resolves when the file content is uploaded. Rejects otherwise.
1641
+ */
1642
+ protected uploadFileContent(fileTag: string, dataType: string, binary: Uint8Array): Promise<void>;
1643
+
1644
+ /**
1645
+ * Downloads one file's content from the data source.
1646
+ * @param {string} fileTag - The tag of the file.
1647
+ * @param {string} dataType - The file data type
1648
+ * @return {Promise<Uint8Array>} A Promise that resolves with the binary data of the file as a Uint8Array. Rejects otherwise.
1649
+ */
1650
+ protected downloadFileContent(fileTag: string, dataType: string): Promise<Uint8Array>;
1651
+
1652
+ /**
1653
+ * Deletes file content from the data source.
1654
+ * @param {string} fileTag - The tag of the file.
1655
+ * @param {string} dataType - The file data type
1656
+ * @return {Promise<void>} A Promise that resolves when the file content is successfully deleted. Rejects otherwise.
1657
+ */
1658
+ protected deleteFileContent(fileTag: string, dataType: string): Promise<void>;
1231
1659
  }