@olympeio/runtime-node 9.4.5 → 9.5.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/package.json CHANGED
@@ -1,13 +1,12 @@
1
1
  {
2
2
  "name": "@olympeio/runtime-node",
3
- "version": "9.4.5",
3
+ "version": "9.5.1",
4
4
  "description": "Olympe Node Runtime Environment",
5
5
  "types": "types/index.d.ts",
6
6
  "dependencies": {
7
7
  "ws": "~8.11.0",
8
8
  "bufferutil": "~4.0.7",
9
9
  "utf-8-validate": "~5.0.10",
10
- "lowdb": "~1.0.0",
11
10
  "rxjs": "7.8.1",
12
11
  "fastify": "~3.29.4"
13
12
  },
package/types/base.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  // @ts-ignore
2
- import Observable from 'rxjs';
2
+ import {Observable} from 'rxjs';
3
3
  import {PropertyModel, Query, QueryResult, QuerySingle, Source} from "./cloud";
4
4
 
5
5
  // **********************************
@@ -7,10 +7,10 @@ import {PropertyModel, Query, QueryResult, QuerySingle, Source} from "./cloud";
7
7
  // **********************************
8
8
 
9
9
  /**
10
- * A Tag can be either a `string`, a `HasTag` (CloudObject instance, Property, Relation, ...)
10
+ * A InstanceOrTag can be either a `string`, a `HasTag` (CloudObject instance, Property, Relation, ...)
11
11
  * or the class constructor for a `CloudObject`
12
12
  */
13
- export type Tag = string | HasTag | typeof CloudObject;
13
+ export type InstanceOrTag = string | HasTag | typeof CloudObject;
14
14
 
15
15
  export type List<T> = Array<T> | (T extends CloudObject | CloudObject[] ? QueryResult<T> : never);
16
16
 
@@ -24,7 +24,7 @@ export type Class<T> = {new (): T};
24
24
  export function generateTag(): string;
25
25
 
26
26
  /**
27
- * Get the unique identifier of the specified Tag as a string
27
+ * Get the unique identifier of the specified InstanceOrTag as a string
28
28
  *
29
29
  * If the given tag is a `CloudObject` instance, the tag of that instance is returned.
30
30
  * If a class constructor is given, the tag of the corresponding `CloudObject` is returned.
@@ -32,11 +32,11 @@ export function generateTag(): string;
32
32
  * @param tag
33
33
  * @return string tag of given input
34
34
  */
35
- export function tagToString(tag: Tag): string;
35
+ export function tagToString(tag: InstanceOrTag): string;
36
36
 
37
37
  /**
38
38
  * The HasTag interface defines objects that have a tag.
39
- * The tag of these objects must be returned by the override method: `getTag()`
39
+ * The tag of these objects must be returned by the overridden method: `getTag()`
40
40
  */
41
41
  export interface HasTag {
42
42
  /**
@@ -113,7 +113,7 @@ export abstract class Context {
113
113
  * In essence, it represents a remote reference to an object in the data cloud.
114
114
  * It is identified by its unique ID, or tag. From a `CloudObject` you can access related `CloudObjects`.
115
115
  *
116
- * A `CloudObject` can be instantiated via the {@apilink Tag} of its model, and it can be instantiated multiple times with different properties values.
116
+ * A `CloudObject` can be instantiated via the {@apilink InstanceOrTag} of its model, and it can be instantiated multiple times with different properties values.
117
117
  * *Data types* defined in DRAW are such `CloudObjects`, instances of Data types are also `CloudObjects`.
118
118
  *
119
119
  * **Example:**
@@ -147,7 +147,7 @@ export abstract class CloudObject implements HasTag {
147
147
  * @param model data type to get instances of
148
148
  * @return A query starting from the instances of the specified model.
149
149
  */
150
- static instancesOf<T extends CloudObject>(model: Class<T> | Tag): Query<T, never>;
150
+ static instancesOf<T extends CloudObject>(model: Class<T> | InstanceOrTag): Query<T, never>;
151
151
 
152
152
  /**
153
153
  * Get the CloudObject whose tag is specified.
@@ -159,7 +159,7 @@ export abstract class CloudObject implements HasTag {
159
159
  * @param tag tag of the `CloudObject`
160
160
  * @return `CloudObject` specified by the tag
161
161
  */
162
- static get<T extends CloudObject>(tag: Tag): T;
162
+ static get<T extends CloudObject>(tag: InstanceOrTag): T;
163
163
 
164
164
  /**
165
165
  * Checks whether a `CloudObject` exists or not.
@@ -168,7 +168,7 @@ export abstract class CloudObject implements HasTag {
168
168
  * @param tag tag of the `CloudObject`
169
169
  * @return `true` if `tag` is valid and references a CloudObject.
170
170
  */
171
- static exists(tag: Tag): boolean;
171
+ static exists(tag: InstanceOrTag): boolean;
172
172
 
173
173
  /**
174
174
  * Create an instance of the specified data type (or `model`)
@@ -181,7 +181,7 @@ export abstract class CloudObject implements HasTag {
181
181
  * @param source
182
182
  * @return newly created `CloudObject`
183
183
  */
184
- static createWith<T>(this: Class<T>, properties: Map<Tag, any>, model?: Tag, source?: Source): T;
184
+ static createWith<T>(this: Class<T>, properties: Map<InstanceOrTag, any>, model?: InstanceOrTag, source?: Source): T;
185
185
 
186
186
  /**
187
187
  * Get this `CloudObject` class as a `CloudObject` instance.
@@ -241,6 +241,13 @@ export abstract class CloudObject implements HasTag {
241
241
  * @return a boolean indicating if this object is persisted in a non-volatile way.
242
242
  */
243
243
  isPersisted(): boolean;
244
+
245
+ /**
246
+ * Compare this CloudObject and the given one and return whether they are identical or not.
247
+ *
248
+ * @param object the object to compare
249
+ * @return true if the specified object is the same CloudObject
250
+ */
244
251
  equals(object: any): boolean;
245
252
 
246
253
  /**
@@ -277,7 +284,7 @@ export abstract class CloudObject implements HasTag {
277
284
  * @param property property or property's tag
278
285
  * @return property value
279
286
  */
280
- get<T>(property: Property<T> | Tag): T | null;
287
+ get<T>(property: Property<T> | InstanceOrTag): T | null;
281
288
 
282
289
  /**
283
290
  * Get an observable to the current value of the specified property for this `CloudObject` instance.
@@ -288,10 +295,10 @@ export abstract class CloudObject implements HasTag {
288
295
  *
289
296
  * @param context context to which the Observable is attached
290
297
  * @param property property or property's tag to observe
291
- * @param waitForValue [=true] whether the observable wait for a first value to get a value.
298
+ * @param waitForValue whether the observable wait for a first value to get a value. (Default = true)
292
299
  * @return Observable of property values
293
300
  */
294
- observe<T>(context: Context, property: Property<T> | Tag, waitForValue?: boolean): Observable<T>;
301
+ observe<T>(context: Context, property: Property<T> | InstanceOrTag, waitForValue?: boolean): Observable<T>;
295
302
 
296
303
  /**
297
304
  * Get an observable to pair [property, value] for this `CloudObject` instance.
@@ -311,6 +318,12 @@ export abstract class CloudObject implements HasTag {
311
318
  */
312
319
  toObject(namesAsKey?: boolean, inheritedProperties?: boolean): Object;
313
320
 
321
+ /**
322
+ * Create a Javascript object from this CloudObject current state, including its tag and property values.
323
+ * It provides the same result as {@apiLink CloudObject#toObject | toObject} called with nameAsKey = true and inheritedProperties = false.
324
+ */
325
+ toJSON(): Object;
326
+
314
327
  // Properties and Relations
315
328
  /**
316
329
  * Name property for all `CloudObjects`
@@ -379,7 +392,7 @@ interface RelationConstructor {
379
392
  * @param tag tag of the relation to create
380
393
  * @param direction whether the relation points to the origin or destination
381
394
  */
382
- new(tag: Tag, direction?: Direction): Relation<CloudObject, CloudObject>;
395
+ new(tag: InstanceOrTag, direction?: Direction): Relation<CloudObject, CloudObject>;
383
396
 
384
397
  /**
385
398
  * Create a relation between two CloudObject classes
@@ -388,7 +401,7 @@ interface RelationConstructor {
388
401
  * @param origin origin class of the relation
389
402
  * @param destination destination class of the relation
390
403
  */
391
- new<O extends CloudObject, D extends CloudObject>(tag: Tag, direction?: Direction, origin?: Class<O>, destination?: Class<D>): Relation<O, D>;
404
+ new<O extends CloudObject, D extends CloudObject>(tag: InstanceOrTag, direction?: Direction, origin?: Class<O>, destination?: Class<D>): Relation<O, D>;
392
405
  }
393
406
 
394
407
  /**
@@ -440,7 +453,7 @@ export interface Relation<O extends CloudObject, D extends CloudObject> extends
440
453
  * @param tag tag of the DataType
441
454
  * @param object `CloudObject` constructor
442
455
  */
443
- export function register(tag: Tag, object: typeof CloudObject): void;
456
+ export function register(tag: InstanceOrTag, object: typeof CloudObject): void;
444
457
 
445
458
  /**
446
459
  * Create a constant property object which has the specified tag and type to be used in coded bricks.
@@ -449,7 +462,7 @@ export function register(tag: Tag, object: typeof CloudObject): void;
449
462
  * @param type type the property holds values of
450
463
  * @return newly defined property
451
464
  */
452
- export function defineProperty<T>(tag: Tag, type?: Class<T>): Property<T>;
465
+ export function defineProperty<T>(tag: InstanceOrTag, type?: Class<T>): Property<T>;
453
466
 
454
467
  /**
455
468
  * Create a constant relation object between two specified DataTypes.
@@ -462,7 +475,7 @@ export function defineProperty<T>(tag: Tag, type?: Class<T>): Property<T>;
462
475
  * @param direction direction of the relation, pointing towards origin or destination. Default is `DESTINATION`
463
476
  * @return newly defined relation
464
477
  */
465
- export function defineRelation<O extends CloudObject, D extends CloudObject>(tag: Tag, origin?: Class<O>, destination?: Class<D>, direction?: Direction): Relation<O, D>;
478
+ export function defineRelation<O extends CloudObject, D extends CloudObject>(tag: InstanceOrTag, origin?: Class<O>, destination?: Class<D>, direction?: Direction): Relation<O, D>;
466
479
  /**
467
480
  * Create a constant relation object between two generic `CloudObjects`
468
481
  *
@@ -472,7 +485,7 @@ export function defineRelation<O extends CloudObject, D extends CloudObject>(tag
472
485
  * @param direction direction of the relation, pointing towards origin or destination. Default is `DESTINATION`
473
486
  * @return newly defined relation
474
487
  */
475
- export function defineRelation(tag: Tag, direction?: Direction): Relation<CloudObject, CloudObject>;
488
+ export function defineRelation(tag: InstanceOrTag, direction?: Direction): Relation<CloudObject, CloudObject>;
476
489
 
477
490
  /**
478
491
  * Returns a constant object corresponding to the specified relation going to the opposite direction
package/types/cloud.d.ts CHANGED
@@ -5,8 +5,9 @@
5
5
  // *********************************************
6
6
 
7
7
  // @ts-ignore
8
- import Observable from 'rxjs';
9
- import {Context, CloudObject, Relation, Property, Tag, Class} from "./base";
8
+ import {Observable} from 'rxjs';
9
+ import {Readable} from 'stream';
10
+ import {Context, CloudObject, Relation, Property, InstanceOrTag, Class} from "./base";
10
11
  import {Brick, BrickContext} from './runtime';
11
12
  import {Color} from "./utils";
12
13
 
@@ -128,7 +129,7 @@ export class File extends CloudObject {
128
129
  * @param content byte content of the file
129
130
  * @param mimeType optional mime type of the file
130
131
  */
131
- static setContent(transaction: Transaction, file: Tag, name: string, content: Uint8Array | ArrayBuffer, mimeType?: string);
132
+ static setContent(transaction: Transaction, file: InstanceOrTag, name: string, content: Uint8Array | ArrayBuffer, mimeType?: string): void;
132
133
 
133
134
  /**
134
135
  * Set the content of a `File` from a specified URL
@@ -138,7 +139,7 @@ export class File extends CloudObject {
138
139
  * @param url url to retrieve content from
139
140
  * @param mimeType optional mime type of the file
140
141
  */
141
- static setURLContent(transaction: Transaction, file: Tag, name: string, url: string, mimeType?: string);
142
+ static setURLContent(transaction: Transaction, file: InstanceOrTag, name: string, url: string, mimeType?: string): void;
142
143
 
143
144
  /**
144
145
  * @deprecated Please use {@apilink File.setContent}
@@ -173,7 +174,7 @@ export class File extends CloudObject {
173
174
  * @param onSuccess callback to execute when byte content has been retrieved successfully
174
175
  * @param onFailure callback to execute when content retrieval has failed
175
176
  */
176
- getContentAsBinary(onSuccess: (content: ArrayBuffer) => void, onFailure?: (string) => void): void;
177
+ getContentAsBinary(onSuccess: (content: ArrayBuffer) => void, onFailure?: (errMsg: string) => void): void;
177
178
 
178
179
  /**
179
180
  * Retrieve string content from this file asynchronously
@@ -181,7 +182,7 @@ export class File extends CloudObject {
181
182
  * @param onSuccess callback to execute when string content has been retrieved successfully
182
183
  * @param onFailure callback to execute when content retrieval has failed
183
184
  */
184
- getContentAsString(onSuccess: (content: string) => void, onFailure?: (string) => void): void;
185
+ getContentAsString(onSuccess: (content: string) => void, onFailure?: (errMsg: string) => void): void;
185
186
 
186
187
  /**
187
188
  * Retrieve string content from URL asynchronously
@@ -246,7 +247,7 @@ export class EnumValue extends CloudObject {
246
247
  * @param name name of the `EnumValue`
247
248
  * @param rank position of the `EnumValue` in the `Enum`
248
249
  */
249
- static createValue(transaction: Transaction, enumModel: Tag, value: string, name?: string, rank?: number): string;
250
+ static createValue(transaction: Transaction, enumModel: InstanceOrTag, value: string, name?: string, rank?: number): string;
250
251
 
251
252
  /**
252
253
  * Name property for an EnumValue
@@ -410,7 +411,7 @@ export class Transaction {
410
411
  * @param tag optional tag of the instance to be created and must be unique
411
412
  * @return the tag of the instance to be created
412
413
  */
413
- create(model: Tag, properties?: Map<Tag, any>, source?: Source, tag?: string): string;
414
+ create(model: InstanceOrTag, properties?: Map<InstanceOrTag, any>, source?: Source, tag?: string): string;
414
415
 
415
416
  /**
416
417
  * Update the property of an instance
@@ -420,7 +421,7 @@ export class Transaction {
420
421
  * @param value the value of the property to be updated to
421
422
  * @return this transaction
422
423
  */
423
- update<T>(instance: Tag, property?: Property<T>, value?: T): this;
424
+ update<T>(instance: InstanceOrTag, property?: Property<T>, value?: T): this;
424
425
 
425
426
  /**
426
427
  * Update multiple properties of a single instance
@@ -429,7 +430,7 @@ export class Transaction {
429
430
  * @param properties map of properties to update
430
431
  * @return this transaction
431
432
  */
432
- multiUpdate(instance: Tag, properties: Map<Tag, any>): this;
433
+ multiUpdate(instance: InstanceOrTag, properties: Map<InstanceOrTag, any>): this;
433
434
 
434
435
  /**
435
436
  * Delete an instance
@@ -437,7 +438,7 @@ export class Transaction {
437
438
  * @param instance tag of the instance to be deleted
438
439
  * @return this transaction
439
440
  */
440
- delete(instance: Tag): this;
441
+ delete(instance: InstanceOrTag): this;
441
442
 
442
443
  /**
443
444
  * Create relation between two instances
@@ -447,7 +448,7 @@ export class Transaction {
447
448
  * @param to tag ofo the DESTINATION instance of the relation
448
449
  * @return this transaction with the create relation operation registered
449
450
  */
450
- createRelation(relation: Tag, from: Tag, to: Tag): this;
451
+ createRelation(relation: InstanceOrTag, from: InstanceOrTag, to: InstanceOrTag): this;
451
452
 
452
453
  /**
453
454
  * Delete a relation between two specified instances.
@@ -459,7 +460,7 @@ export class Transaction {
459
460
  * @param to destination instance tag
460
461
  * @return this transaction
461
462
  */
462
- deleteRelation(relation: Tag, from: Tag, to: Tag): this;
463
+ deleteRelation(relation: InstanceOrTag, from: InstanceOrTag, to: InstanceOrTag): this;
463
464
 
464
465
  /**
465
466
  * Delete any number of the relation starting from specified node.
@@ -478,25 +479,27 @@ export class Transaction {
478
479
  * @param relation deleted relation, indicates relation tag *and* direction
479
480
  * @param origin starting node
480
481
  */
481
- deleteAllRelations(relation: Relation<any, any>, origin: Tag): this;
482
+ deleteAllRelations(relation: Relation<any, any>, origin: InstanceOrTag): this;
482
483
 
483
484
  /**
484
- * Change the persistence mode of all instances in this transaction
485
+ * Set the specified instance to be persisted or not in this transaction.
486
+ * Default value of persist is true.
485
487
  *
486
- * @param persist whether instances are persisted outside
487
- * the local datacloud
488
+ * @param instance the instance to be persisted
489
+ * @param persist determine if the specified instance should be persisted or not (true by default).
488
490
  * @return this transaction
489
491
  */
490
- persist(persist?: boolean): this;
492
+ persist(instance: InstanceOrTag, persist?: boolean): this;
491
493
 
492
494
  /**
493
495
  * Change the persistence mode for a single instance in this transaction
494
496
  *
497
+ * @deprecated use {@apilink Transaction.persist} instead
495
498
  * @param instance the instance to be persisted
496
499
  * @param persist the persisting mode
497
500
  * @return this transaction
498
501
  */
499
- persistInstance(instance: Tag, persist?: boolean): this;
502
+ persistInstance(instance: InstanceOrTag, persist?: boolean): this;
500
503
 
501
504
  /**
502
505
  * Change the source of all instances created in this transaction
@@ -522,7 +525,7 @@ export class Transaction {
522
525
  * @param tag the instance to find the model of
523
526
  * @return the tag of the model of the given instance
524
527
  */
525
- model(tag: Tag): string | null;
528
+ model(tag: InstanceOrTag): string | null;
526
529
 
527
530
  /**
528
531
  * Add all operations of another transaction into this transaction
@@ -873,9 +876,17 @@ export class QueryResult<T extends CloudObject | CloudObject[]> {
873
876
  concat(...others: QueryResult<T>[]): QueryResult<T>;
874
877
  }
875
878
 
879
+ declare type QueryOptions = {
880
+ cacheBucketName?: string; // Name of the cache bucket - if provided, it means that the query must be cached under this name
881
+ }
882
+
883
+ declare type ImplicitQueryOption = {
884
+ storeInCacheDB?: boolean // indicates if this follow rule query must be cached in browser DB (IndexedDB) for potential offline use. Default is false.
885
+ }
886
+
876
887
  /**
877
888
  * A Query is an immutable object used to build queries on the datacloud. It is a graph query builder.
878
- * It starts from an `origin` Tag (typically, the `Tag` of a data type or of an instance).
889
+ * It starts from an `origin` InstanceOrTag (typically, the `InstanceOrTag` of a data type or of an instance).
879
890
  * From there, it can follow relations between data types and filter results.
880
891
  *
881
892
  * Example:
@@ -934,7 +945,7 @@ export class Query<T extends CloudObject, R> {
934
945
  * @param source optional source of the data to answer the query
935
946
  * @return an empty Query whose starting point is defined by a single `CloudObject`
936
947
  */
937
- static from<T extends Tag>(tag: T, source?: Source): Query<T extends CloudObject ? T : CloudObject, never>;
948
+ static from<T extends InstanceOrTag>(tag: T, source?: Source): Query<T extends CloudObject ? T : CloudObject, never>;
938
949
 
939
950
  /**
940
951
  * Create a query starting from the `CloudObject` specified tag.
@@ -946,7 +957,7 @@ export class Query<T extends CloudObject, R> {
946
957
  * @param source optional source of the data to answer the query
947
958
  * @return an empty Query whose starting point is defined by a single `CloudObject`
948
959
  */
949
- static fromTag<T extends CloudObject>(tag: string, dataType: Class<T> | Tag, source?: Source): Query<T, never>;
960
+ static fromTag<T extends CloudObject>(tag: string, dataType: Class<T> | InstanceOrTag, source?: Source): Query<T, never>;
950
961
 
951
962
  /**
952
963
  * Create a query starting from the instances of the specified model. By default, it does include the instances of
@@ -959,7 +970,7 @@ export class Query<T extends CloudObject, R> {
959
970
  * an external data source (Tag of a `DBConnectorTag`)
960
971
  * @return a new query object starting from model instances
961
972
  */
962
- static instancesOf<T extends Tag>(model: Class<T> | Tag, includeInheritance?: boolean, source?: Source): Query<T extends CloudObject ? T : CloudObject, never>;
973
+ static instancesOf<T extends InstanceOrTag>(model: Class<T> | InstanceOrTag, includeInheritance?: boolean, source?: Source): Query<T extends CloudObject ? T : CloudObject, never>;
963
974
 
964
975
  /**
965
976
  * Create a query starting from a specific root instance, then following relations based on a rule constraint.
@@ -967,8 +978,9 @@ export class Query<T extends CloudObject, R> {
967
978
  * @param root Starting point of the query. See `root` of {@apilink RootQueryPart}
968
979
  * @param rule Discriminate which relations to follow
969
980
  * @param source The tag of the source responsible for executing the query
981
+ * @param options options
970
982
  */
971
- static followRule<T extends Tag>(ctx: Context, root: T, rule: FollowRule, source?: Source): Observable<QueryResult<T extends CloudObject ? T : CloudObject>>;
983
+ static followRule<T extends InstanceOrTag>(ctx: Context, root: T, rule: FollowRule, source?: Source, options?: ImplicitQueryOption): Observable<QueryResult<T extends CloudObject ? T : CloudObject>>;
972
984
 
973
985
  /**
974
986
  * Instruct the query to follow a specified relation. This does not add any key-value pair to the result.
@@ -1121,14 +1133,13 @@ export class Query<T extends CloudObject, R> {
1121
1133
  parse(): RootQueryPart;
1122
1134
 
1123
1135
  /**
1124
- * Execute the query asynchronously on the datacloud and deletes it afterwards.
1136
+ * Execute the query asynchronously on the datacloud and deletes it afterward.
1125
1137
  * In other words, one cannot call execute twice on the same `Query`.
1126
1138
  *
1127
- * @param context context in which the query must be executed. As this is an asynchronous operation,
1128
- * one has to provide a context that won't be destroyed before the query has a result.
1139
+ * @param options options
1129
1140
  * @return promise resolving to query result or failing otherwise.
1130
1141
  */
1131
- execute(context: Context): Promise<QueryResult<R extends never ? T : R extends CloudObject | CloudObject[] ? R : never>>;
1142
+ execute(options?: QueryOptions): Promise<QueryResult<R extends never ? T : R extends CloudObject | CloudObject[] ? R : never>>;
1132
1143
 
1133
1144
  /**
1134
1145
  * Get an observable to the current value of the QueryResult for this Query instance.
@@ -1138,9 +1149,10 @@ export class Query<T extends CloudObject, R> {
1138
1149
  * The observable gets completed automatically once the specified context is {@apilink Context.onClear | cleared}.
1139
1150
  *
1140
1151
  * @param context {@apilink Context} to which the Observable is attached
1152
+ * @param options options
1141
1153
  * @return Observable of QueryResult values
1142
1154
  */
1143
- observe(context: Context): Observable<QueryResult<R extends never ? T : R extends CloudObject | CloudObject[] ? R : never>>;
1155
+ observe(context: Context, options?: QueryOptions): Observable<QueryResult<R extends never ? T : R extends CloudObject | CloudObject[] ? R : never>>;
1144
1156
 
1145
1157
  /**
1146
1158
  * Execute synchronously the query on the local datacloud cache.
@@ -1167,7 +1179,7 @@ export class QuerySingle<T extends CloudObject> {
1167
1179
  * @param object starting node for the graph query single
1168
1180
  * @return new query single only accepting 0..1 relations
1169
1181
  */
1170
- static from<T extends CloudObject>(object: Tag): QuerySingle<T>;
1182
+ static from<T extends CloudObject>(object: InstanceOrTag): QuerySingle<T>;
1171
1183
 
1172
1184
  /**
1173
1185
  * Follow a 0..1 relation
@@ -1189,10 +1201,9 @@ export class QuerySingle<T extends CloudObject> {
1189
1201
  /**
1190
1202
  * Execute the query single, see {@apilink Query.execute | Query.execute()}
1191
1203
  *
1192
- * @param context
1193
1204
  * @return promise containing the single result or `null`
1194
1205
  */
1195
- execute(context: Context): Promise<T | null>;
1206
+ execute(): Promise<T | null>;
1196
1207
 
1197
1208
  /**
1198
1209
  * Execute the query single on the local data cloud,
@@ -1219,7 +1230,7 @@ export class Predicate {
1219
1230
  *
1220
1231
  * @param tags the object or unique identifier (tag) of the objects to look for.
1221
1232
  */
1222
- static in(...tags: Tag[]): Predicate;
1233
+ static in(...tags: InstanceOrTag[]): Predicate;
1223
1234
 
1224
1235
  /**
1225
1236
  * Create a predicate matching a specified property to a specified value.
@@ -1235,7 +1246,7 @@ export class Predicate {
1235
1246
  *
1236
1247
  * @param property the string property to use for filtering
1237
1248
  * @param value the value the string property must match
1238
- * @param caseSensitive if the match must pay attention to case sensitivity, default value is false
1249
+ * @param caseSensitive if the match must pay attention to case sensitivity, default value is true
1239
1250
  * @return new Predicate with the contains string operation
1240
1251
  */
1241
1252
  static contains(property: Property<string>, value: string, caseSensitive?: boolean): Predicate;
@@ -1244,11 +1255,11 @@ export class Predicate {
1244
1255
  * Create a predicate matching a specified string property to a regular expression.
1245
1256
  *
1246
1257
  * @param property the string property to use for filtering
1247
- * @param value the regex the string property must match
1248
- * @param caseSensitive if the match must pay attention to case sensitivity, default value is false
1258
+ * @param value the regex or pattern the string property must match
1259
+ * @param caseSensitive if the match must pay attention to case sensitivity, default value is true
1249
1260
  * @return new Predicate with the match regex operation
1250
1261
  */
1251
- static regex(property: Property<string>, value: RegExp, caseSensitive?: boolean): Predicate;
1262
+ static regex(property: Property<string>, value: RegExp | string, caseSensitive?: boolean): Predicate;
1252
1263
 
1253
1264
  /**
1254
1265
  * Create a predicate matching a specified number property to a numerical lower bound
@@ -1278,7 +1289,7 @@ export class Predicate {
1278
1289
  * @param extend should the predicate also match against inherited models
1279
1290
  * @return new Predicate
1280
1291
  */
1281
- static instanceOf(expectedModel: Tag, extend: boolean): Predicate;
1292
+ static instanceOf(expectedModel: InstanceOrTag, extend: boolean): Predicate;
1282
1293
 
1283
1294
  /**
1284
1295
  * Create a predicate matching a specified number property to a number property lower bound
@@ -1353,13 +1364,13 @@ export class DataResult {
1353
1364
  static fromQuery(query: Query<CloudObject, any>): DataResult;
1354
1365
 
1355
1366
  /**
1356
- * Create a new Data Type instance with the specified {@apilink Tag}, Data Type and properties.
1367
+ * Create a new Data Type instance with the specified {@apilink InstanceOrTag}, Data Type and properties.
1357
1368
  * @param tag The unique identifier of the object instance to create.
1358
1369
  * @param model The Data Type of the instance to create.
1359
1370
  * @param properties The properties to set on the instance.
1360
1371
  * @return This {@apilink DataResult} instance.
1361
1372
  */
1362
- create(tag: Tag, model: Tag, properties?: Map<Tag, any>): this;
1373
+ create(tag: InstanceOrTag, model: InstanceOrTag, properties?: Map<InstanceOrTag, any>): this;
1363
1374
 
1364
1375
  /**
1365
1376
  * Create a relation between two instances with the specified {@apilink Relation}, `from`, and `to` instance tags.
@@ -1368,7 +1379,7 @@ export class DataResult {
1368
1379
  * @param to The unique identifier of the destination instance.
1369
1380
  * @return This {@apilink DataResult} instance.
1370
1381
  */
1371
- createRelation(relation: Tag, from: Tag, to: Tag): this;
1382
+ createRelation(relation: InstanceOrTag, from: InstanceOrTag, to: InstanceOrTag): this;
1372
1383
  }
1373
1384
 
1374
1385
  /**
@@ -1579,14 +1590,14 @@ export abstract class DataSource extends CloudObject {
1579
1590
 
1580
1591
  /**
1581
1592
  * Returns the tag of the data source.
1582
- * @return {string} tag of the data source.
1593
+ * @return tag of the data source.
1583
1594
  */
1584
1595
  getId(): string;
1585
1596
 
1586
1597
  /**
1587
1598
  * Retrieves the configuration value associated with the provided key in the data source oConfig.
1588
- * @param {string} key - Key to retrieve the configuration value for.
1589
- * @return {*} The configuration value associated with the provided key.
1599
+ * @param key - Key to retrieve the configuration value for.
1600
+ * @return The configuration value associated with the provided key.
1590
1601
  */
1591
1602
  getConfig(key: string): any;
1592
1603
 
@@ -1595,60 +1606,60 @@ export abstract class DataSource extends CloudObject {
1595
1606
  * It can also perform a health check to ensure the connection is active.
1596
1607
  * Subscribes to the {@apilink DataSource.observeDataTypes} observable to handle changes to the data types in the data source.
1597
1608
  *
1598
- * @param {!Context} context a context with the same livecycle as the Data Source
1609
+ * @param context a context with the same livecycle as the Data Source
1599
1610
  * @return A promise that resolves with void when initialization is complete. Reject if initialization did not complete.
1600
1611
  */
1601
- protected init(context): Promise<void>;
1612
+ protected init(context: BrickContext): Promise<void>;
1602
1613
 
1603
1614
  /**
1604
1615
  * Performs a health check on the data source, checking if the connection is alive.
1605
- * @return {Promise<void>} A Promise that resolves when the health check is completed successfully, rejects otherwise.
1616
+ * @return A Promise that resolves when the health check is completed successfully, rejects otherwise.
1606
1617
  */
1607
1618
  protected healthCheck(): Promise<void>;
1608
1619
 
1609
1620
  /**
1610
1621
  * Disconnects the data source.
1611
- * @return {Promise<void>} A Promise that resolves when the data source is destroyed.
1622
+ * @return A Promise that resolves when the data source is destroyed.
1612
1623
  */
1613
1624
  protected destroy(): Promise<void>;
1614
1625
 
1615
1626
  /**
1616
1627
  * Executes the provided {@apilink Query} once and returns a {@apilink DataResult}.
1617
- * @param {Query<CloudObject, any>} query - The {@apilink Query} object to execute.
1618
- * @return {Promise<DataResult>} A Promise that resolves with the {@apilink DataResult} object.
1628
+ * @param query - The {@apilink Query} object to execute.
1629
+ * @return A Promise that resolves with the {@apilink DataResult} object.
1619
1630
  */
1620
1631
  protected executeQuery(query: Query<CloudObject, any>): Promise<DataResult>;
1621
1632
 
1622
1633
  /**
1623
1634
  * Applies the provided {@apilink Operation} array to the data source as one transaction
1624
- * @param {Operation[]} transaction - The {@apilink Operation} array to apply.
1625
- * @param {?TransactionOptions} options
1626
- * @return {Promise<void>} A Promise that resolves when the transaction is completed. Rejects when the transaction fails.
1635
+ * @param transaction - The {@apilink Operation} array to apply.
1636
+ * @param options the options
1637
+ * @return A Promise that resolves when the transaction is completed. Rejects when the transaction fails.
1627
1638
  */
1628
1639
  protected applyTransaction(transaction: Operation[], options?: TransactionOptions): Promise<void>;
1629
1640
 
1630
1641
  /**
1631
1642
  * Uploads one file's content to the data source.
1632
- * @param {string} fileTag - The tag of the file.
1633
- * @param {string} dataType - The file data type
1634
- * @param {Uint8Array} binary - The binary data of the file.
1635
- * @return {Promise<void>} A Promise that resolves when the file content is uploaded. Rejects otherwise.
1643
+ * @param fileTag - The tag of the file.
1644
+ * @param dataType - The file data type
1645
+ * @param binary - The binary data of the file.
1646
+ * @return A Promise that resolves when the file content is uploaded. Rejects otherwise.
1636
1647
  */
1637
1648
  protected uploadFileContent(fileTag: string, dataType: string, binary: Uint8Array): Promise<void>;
1638
1649
 
1639
1650
  /**
1640
1651
  * Downloads one file's content from the data source.
1641
- * @param {string} fileTag - The tag of the file.
1642
- * @param {string} dataType - The file data type
1643
- * @return {Promise<Uint8Array>} A Promise that resolves with the binary data of the file as a Uint8Array. Rejects otherwise.
1652
+ * @param fileTag - The tag of the file.
1653
+ * @param dataType - The file data type
1654
+ * @return A Promise that resolves with the binary data of the file as an Uint8Array or a node Readable Stream. Rejects otherwise.
1644
1655
  */
1645
- protected downloadFileContent(fileTag: string, dataType: string): Promise<Uint8Array>;
1656
+ protected downloadFileContent(fileTag: string, dataType: string): Promise<Uint8Array | Readable>;
1646
1657
 
1647
1658
  /**
1648
1659
  * Deletes file content from the data source.
1649
- * @param {string} fileTag - The tag of the file.
1650
- * @param {string} dataType - The file data type
1651
- * @return {Promise<void>} A Promise that resolves when the file content is successfully deleted. Rejects otherwise.
1660
+ * @param fileTag - The tag of the file.
1661
+ * @param dataType - The file data type
1662
+ * @return A Promise that resolves when the file content is successfully deleted. Rejects otherwise.
1652
1663
  */
1653
1664
  protected deleteFileContent(fileTag: string, dataType: string): Promise<void>;
1654
1665
  }
package/types/legacy.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  // @ts-ignore
2
- import Observable from 'rxjs';
3
- import {CloudObject, Direction, HasTag, Property, Relation, Tag} from "./base";
2
+ import {Observable} from 'rxjs';
3
+ import {CloudObject, Direction, HasTag, Property, Relation, InstanceOrTag} from "./base";
4
4
  import {Brick, VisualBrick} from "./runtime";
5
5
  /**
6
6
  * The entry of a brick is a static object linked to the brick class itself that is used to make the link between the
@@ -41,7 +41,7 @@ export type FunctionBrick = Brick;
41
41
  DATACLOUD
42
42
  ====================== */
43
43
 
44
- export type InstanceTag = Tag | Entry;
44
+ export type InstanceTag = InstanceOrTag | Entry;
45
45
 
46
46
  /** @deprecated */
47
47
  export function instanceToTag(instance: InstanceTag): string;