@olympeio/runtime-node 9.3.1 → 9.4.1
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/import/dcInitConfig.json +1 -1
- package/import/olympe.dm/datamodel/00_bootstrap.newInst.json +1 -1
- package/import/olympe.dm/datamodel/00_bootstrap.newRel.json +1 -1
- package/import/olympe.dm/datamodel/01_primitives.newInst.json +1 -1
- package/import/olympe.dm/datamodel/01_primitives.newRel.json +1 -1
- package/import/olympe.dm/datamodel/02_permissions.newInst.json +1 -1
- package/import/olympe.dm/datamodel/02_permissions.newRel.json +1 -1
- package/import/olympe.dm/datamodel/03_file.newInst.json +1 -1
- package/import/olympe.dm/datamodel/03_file.newRel.json +1 -1
- package/import/olympe.dm/datamodel/04_modules.newInst.json +1 -1
- package/import/olympe.dm/datamodel/04_modules.newRel.json +1 -1
- package/import/olympe.dm/datamodel/05_permission_schema.newInst.json +1 -1
- package/import/olympe.dm/datamodel/05_permission_schema.newRel.json +1 -1
- package/import/olympe.dm/datamodel/05_permission_schema.updateInst.json +1 -1
- package/import/olympe.dm/datamodel/06_structure.newInst.json +1 -1
- package/import/olympe.dm/datamodel/06_structure.newRel.json +1 -1
- package/import/olympe.sc/datamodel/00_primordial.newInst.json +1 -1
- package/import/olympe.sc/datamodel/00_primordial.newRel.json +1 -1
- package/import/olympe.sc/datamodel/01_language.newInst.json +1 -1
- package/import/olympe.sc/datamodel/01_language.newRel.json +1 -1
- package/import/olympe.sc/datamodel/02_bricks.newInst.json +1 -1
- package/import/olympe.sc/datamodel/02_bricks.newRel.json +1 -1
- package/index.js +770 -832
- package/package.json +7 -10
- package/types/base.d.ts +22 -2
- package/types/cloud.d.ts +458 -44
- package/types/runtime.d.ts +4 -3
- package/types/utils.d.ts +86 -5
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:
|
|
61
|
+
static dumpFollowRuleProp: FollowRule;
|
|
60
62
|
/**
|
|
61
63
|
* Property for the *delete* follow rule
|
|
62
64
|
*/
|
|
63
|
-
static deleteFollowRuleProp:
|
|
65
|
+
static deleteFollowRuleProp: FollowRule;
|
|
64
66
|
/**
|
|
65
67
|
* Property for the *runtime* follow rule
|
|
66
68
|
*/
|
|
67
|
-
static runtimeFollowRuleProp:
|
|
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
|
|
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 (
|
|
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?:
|
|
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 (
|
|
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?:
|
|
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 (
|
|
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?:
|
|
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.
|
|
478
|
-
* 2.
|
|
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:
|
|
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
|
|
@@ -551,6 +578,27 @@ 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
|
+
|
|
554
602
|
/**
|
|
555
603
|
* A transaction result is the object received after a transaction has been executed successfully.
|
|
556
604
|
* It provides information about what has been done.
|
|
@@ -622,7 +670,7 @@ export class QueryResult<T extends CloudObject | CloudObject[]> {
|
|
|
622
670
|
static empty(): QueryResult<any>;
|
|
623
671
|
|
|
624
672
|
/**
|
|
625
|
-
* Symbol iterator for `for
|
|
673
|
+
* Symbol iterator for `for…in` syntactic sugar
|
|
626
674
|
*
|
|
627
675
|
* @return iterator over the key-values pairs of this `QueryResult`
|
|
628
676
|
*/
|
|
@@ -904,18 +952,29 @@ export class Query<T extends CloudObject, R> {
|
|
|
904
952
|
* @param source optional source of the data to answer the query
|
|
905
953
|
* @return an empty Query whose starting point is defined by a single `CloudObject`
|
|
906
954
|
*/
|
|
907
|
-
static from<T extends Tag>(tag: T, source?:
|
|
955
|
+
static from<T extends Tag>(tag: T, source?: Source): Query<T extends CloudObject ? T : CloudObject, never>;
|
|
908
956
|
|
|
909
957
|
/**
|
|
910
|
-
* 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.
|
|
911
960
|
*
|
|
912
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.
|
|
913
963
|
* @param source optional source of the data to answer the query
|
|
914
964
|
* A source can be the orchestrator ('server'), local ('self') or
|
|
915
965
|
* an external data source (Tag of a `DBConnectorTag`)
|
|
916
966
|
* @return a new query object starting from model instances
|
|
917
967
|
*/
|
|
918
|
-
static instancesOf<T extends Tag>(model: Class<T> | Tag, source?:
|
|
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>>;
|
|
919
978
|
|
|
920
979
|
/**
|
|
921
980
|
* Instruct the query to follow a specified relation. This does not add any key-value pair to the result.
|
|
@@ -928,9 +987,10 @@ export class Query<T extends CloudObject, R> {
|
|
|
928
987
|
* ```
|
|
929
988
|
*
|
|
930
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.
|
|
931
991
|
* @return a new query object
|
|
932
992
|
*/
|
|
933
|
-
follow<D extends CloudObject>(relation: Relation<T, D
|
|
993
|
+
follow<D extends CloudObject>(relation: Relation<T, D>, optional?: boolean): Query<D, R>;
|
|
934
994
|
|
|
935
995
|
/**
|
|
936
996
|
* Follow a relation recursively, see {@apilink Query.follow}.
|
|
@@ -939,9 +999,44 @@ export class Query<T extends CloudObject, R> {
|
|
|
939
999
|
*
|
|
940
1000
|
* @param relation relation to follow recursively, specifies type and direction
|
|
941
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.
|
|
942
1003
|
* @return a new query object
|
|
943
1004
|
*/
|
|
944
|
-
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>;
|
|
945
1040
|
|
|
946
1041
|
/**
|
|
947
1042
|
* Add the current working set of nodes to the result.
|
|
@@ -1026,6 +1121,11 @@ export class Query<T extends CloudObject, R> {
|
|
|
1026
1121
|
*/
|
|
1027
1122
|
sortBy(property: Property<any>, order?: Order): Query<T, R>;
|
|
1028
1123
|
|
|
1124
|
+
/**
|
|
1125
|
+
* @return the query transformed as a tree of QueryPart. To be used by Data Source.
|
|
1126
|
+
*/
|
|
1127
|
+
parse(): RootQueryPart;
|
|
1128
|
+
|
|
1029
1129
|
/**
|
|
1030
1130
|
* Execute the query asynchronously on the datacloud and deletes it afterwards.
|
|
1031
1131
|
* In other words, one cannot call execute twice on the same `Query`.
|
|
@@ -1119,6 +1219,14 @@ export class QuerySingle<T extends CloudObject> {
|
|
|
1119
1219
|
* ```
|
|
1120
1220
|
*/
|
|
1121
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
|
+
|
|
1122
1230
|
/**
|
|
1123
1231
|
* Create a predicate matching a specified property to a specified value.
|
|
1124
1232
|
*
|
|
@@ -1133,7 +1241,7 @@ export class Predicate {
|
|
|
1133
1241
|
*
|
|
1134
1242
|
* @param property the string property to use for filtering
|
|
1135
1243
|
* @param value the value the string property must match
|
|
1136
|
-
* @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
|
|
1137
1245
|
* @return new Predicate with the contains string operation
|
|
1138
1246
|
*/
|
|
1139
1247
|
static contains(property: Property<string>, value: string, caseSensitive?: boolean): Predicate;
|
|
@@ -1143,7 +1251,7 @@ export class Predicate {
|
|
|
1143
1251
|
*
|
|
1144
1252
|
* @param property the string property to use for filtering
|
|
1145
1253
|
* @param value the regex the string property must match
|
|
1146
|
-
* @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
|
|
1147
1255
|
* @return new Predicate with the match regex operation
|
|
1148
1256
|
*/
|
|
1149
1257
|
static regex(property: Property<string>, value: RegExp, caseSensitive?: boolean): Predicate;
|
|
@@ -1168,6 +1276,16 @@ export class Predicate {
|
|
|
1168
1276
|
*/
|
|
1169
1277
|
static smallerThan(property: Property<number>, value: number, strict?: boolean): Predicate;
|
|
1170
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
|
+
|
|
1171
1289
|
/**
|
|
1172
1290
|
* Create a predicate matching a specified number property to a number property lower bound
|
|
1173
1291
|
*
|
|
@@ -1214,32 +1332,328 @@ export class Predicate {
|
|
|
1214
1332
|
}
|
|
1215
1333
|
|
|
1216
1334
|
/**
|
|
1217
|
-
*
|
|
1218
|
-
*
|
|
1219
|
-
* A path is defined by a list of relations, and an object match the predicate if and only if the patch can be followed
|
|
1220
|
-
* to a destination (which might be specified)
|
|
1335
|
+
* The sorting order for a {@apilink QueryPart}.
|
|
1221
1336
|
*/
|
|
1222
|
-
export
|
|
1223
|
-
|
|
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 {
|
|
1224
1353
|
|
|
1225
1354
|
/**
|
|
1226
|
-
*
|
|
1227
|
-
*
|
|
1228
|
-
* @
|
|
1229
|
-
* @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.
|
|
1230
1358
|
*/
|
|
1231
|
-
|
|
1359
|
+
static fromQuery(query: Query<CloudObject, any>): DataResult;
|
|
1232
1360
|
|
|
1233
1361
|
/**
|
|
1234
|
-
*
|
|
1235
|
-
*
|
|
1236
|
-
* @param
|
|
1237
|
-
* @
|
|
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.
|
|
1238
1367
|
*/
|
|
1239
|
-
|
|
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;
|
|
1240
1378
|
}
|
|
1241
1379
|
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
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>;
|
|
1245
1659
|
}
|