@olympeio/runtime-web 9.4.4 → 9.5.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 (34) hide show
  1. package/import/olympe.dm/datamodel/01_primitives.newInst.json +1 -1
  2. package/import/olympe.dm/datamodel/05_permission_schema.updateInst.json +1 -1
  3. package/import/olympe.dm/datamodel/06_structure.newInst.json +1 -1
  4. package/import/olympe.dm/datamodel/06_structure.newRel.json +1 -1
  5. package/import/olympe.sc/datamodel/00_primordial.newInst.json +1 -1
  6. package/import/olympe.sc/datamodel/00_primordial.newRel.json +1 -1
  7. package/import/olympe.sc/datamodel/01_language.newInst.json +1 -1
  8. package/import/olympe.sc/datamodel/01_language.newRel.json +1 -1
  9. package/import/olympe.sc/datamodel/02_bricks.newInst.json +1 -1
  10. package/import/olympe.sc/datamodel/02_bricks.newRel.json +1 -1
  11. package/import/olympe.sc.ui/datamodel/01_primordial_ui_models.newInst.json +1 -1
  12. package/import/olympe.sc.ui/datamodel/01_primordial_ui_models.newRel.json +1 -1
  13. package/import/olympe.sc.ui/datamodel/02_ui_components.newInst.json +1 -1
  14. package/import/olympe.sc.ui/datamodel/02_ui_components.newRel.json +1 -1
  15. package/import/olympe.sc.ui/datamodel/03_categories.newInst.json +1 -0
  16. package/import/olympe.sc.ui/datamodel/03_categories.newRel.json +1 -0
  17. package/import/olympe.sc.ui/datamodel/{07_primordial_items.newInst.json → 06_primordial_items.newInst.json} +1 -1
  18. package/import/olympe.sc.ui/datamodel/{07_primordial_items.newRel.json → 06_primordial_items.newRel.json} +1 -1
  19. package/index.js +1652 -1578
  20. package/package.json +1 -1
  21. package/service_worker.js +38 -0
  22. package/types/base.d.ts +16 -16
  23. package/types/cloud.d.ts +53 -56
  24. package/types/legacy.d.ts +2 -2
  25. package/types/runtime.d.ts +10 -2
  26. package/types/utils.d.ts +99 -3
  27. package/import/olympe.sc.ui/datamodel/03_ui_functions.newInst.json +0 -1
  28. package/import/olympe.sc.ui/datamodel/03_ui_functions.newRel.json +0 -1
  29. package/import/olympe.sc.ui/datamodel/04_categories.newInst.json +0 -1
  30. package/import/olympe.sc.ui/datamodel/04_categories.newRel.json +0 -1
  31. /package/import/olympe.sc.ui/datamodel/{05_default_theme.newInst.json → 04_default_theme.newInst.json} +0 -0
  32. /package/import/olympe.sc.ui/datamodel/{05_default_theme.newRel.json → 04_default_theme.newRel.json} +0 -0
  33. /package/import/olympe.sc.ui/datamodel/{06_draw_metadata.newInst.json → 05_draw_metadata.newInst.json} +0 -0
  34. /package/import/olympe.sc.ui/datamodel/{06_draw_metadata.newRel.json → 05_draw_metadata.newRel.json} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@olympeio/runtime-web",
3
- "version": "9.4.4",
3
+ "version": "9.5.0",
4
4
  "description": "Olympe Web Runtime Environment",
5
5
  "types": "types/index.d.ts",
6
6
  "dependencies": {
@@ -0,0 +1,38 @@
1
+
2
+ ;(function(root, factory) {
3
+ if (typeof define === 'function' && define.amd) {
4
+ // AMD
5
+ define(['exports'], factory);
6
+ } else if (typeof exports === 'object') {
7
+ // CommonJS
8
+ factory(module.exports);
9
+ } else {
10
+ // Other
11
+ factory(root);
12
+ }
13
+ }(this, function(exports) {
14
+ // Expose libraries (if any)
15
+ if (typeof libs === 'object' && libs instanceof Map) {
16
+ for (const [name, lib] of libs.entries()) {
17
+ eval(`var ${name} = lib;`);
18
+ }
19
+ libs.clear(); // We do not need this map anymore
20
+ }
21
+ (function() {
22
+ "use strict";
23
+
24
+ function f(a){function b(c){return a.next(c)}function h(c){return a.throw(c)}return new Promise(function(c,g){function d(e){e.done?c(e.value):Promise.resolve(e.value).then(b,h).then(d,g)}d(a.next())})}function k(a,...b){a.g>l||console.debug('[SW]',...b)}function m(a){k(a,'Fetching required resources');n(a).then(b=>b.addAll(p)).catch(b=>{a.error('Failed to cache the required resources',b)})}
25
+ function q(a){k(a,'Start intercepting fetch requests');const b=d=>f(function*(){const e=yield(yield n(a)).match(d);return e?e:Response.error()}()),h=(d,e)=>{const z=e.clone();n(a).then(r=>r.put(d,z)).catch(r=>{a.error('Failed to store a response in cache',r)})},c=d=>fetch(d).then(e=>{h(d,e);k(a,'Network first response',e);return e}).catch(()=>{k(a,'Network not responding, attempting to respond with cache');return b(d)}),g=d=>b(d).then(e=>{k(a,'Cache first response',e);return e}).catch(()=>{k(a,'Cache miss, attempting to respond with network');
26
+ return fetch(d).then(e=>{h(d,e)}).catch(()=>Response.error())});self.addEventListener('fetch',d=>f(function*(){k(a,'Intercepting request',d.request.method,d.request.url);var e=d.request;'GET'!==e.method?(t(a,'Ignoring Non-GET request'),e=!0):e.headers.has('X-Source-Origin')?(t(a,'Ignoring request containing "X-Source-Origin" header'),e=!0):e=!1;e?(k(a,'Ignore interception, proceed with network'),d.respondWith(fetch(d.request))):d.respondWith(a.h===u?c(d.request):g(d.request))}()))}
27
+ function v(a){return f(function*(){k(a,'Clearing other cache version');const b=yield caches.keys();return Promise.all(b.filter(h=>{const [c,g]=h.split(':');return g===a.i&&c!==a.version}).map(h=>caches.delete(h)))}())}function w(a,b){const [h,c]=b.data.split(/:(.*)/);k(a,'Handling message from client',h,c);b=b.source.id;(b?clients.get(b):Promise.resolve(null)).then(g=>{g||k(a,'Missing clientId or client not found');x(a,g,h,c)})}
28
+ function n(a){return f(function*(){return caches.open(`${a.version}:${a.i}`)}())}function t(a,...b){a.g>y||console.debug('[SW]',...b)}function A(a,b,h,c){b?(k(a,'Posting message to client',h,c),b.postMessage(`${h.toString()}:${c}`)):k(a,'Ignoring message with missing client',b)}
29
+ function x(a,b,h,c){switch(h){case B.toString():k(a,'Handling ADD_URL_TO_CACHE message',c);if(!a.j){t(a,'Cache is not enabled: ignoring message');A(a,b,C,c);break}n(a).then(g=>g.match(c).then(d=>[g,d])).then(([g,d])=>{d?t(a,'Already cached, skip'):(t(a,'Not yet in the cache, adding',c),g.addAll([c]).then(()=>{}).catch(e=>{a.error('Failed to add resource in the cache',c,'with error',e)}));A(a,b,D,c)}).catch(g=>{a.error('Failed to add resource in the cache',g);A(a,b,C,c)});break;case E.toString():k(a,
30
+ 'Handling SET_CACHE_STRATEGY message',c);if(c===F.toString())a.h=F,k(a,'Applied Cache-first strategy');else if(c===u.toString())a.h=u,k(a,'Applied Network-first strategy');else{a.info('Unknown cache strategy',c);A(a,b,G,`Unknown cache strategy: ${c}`);break}A(a,b,H,c);break;default:a.info('Unknown incoming message',`${h}:${c}`)}}
31
+ class I{constructor(){var a=J.get('version'),b=J.get('appName'),h=K,c=L;this.version=a;this.i=b;this.g=c;this.j=h;this.h=u;k(this,'Initializing Service Worker with',a,b,c);this.j&&(m(this),q(this));self.addEventListener('install',()=>{k(this,'Installing with version',a,b)});self.addEventListener('activate',g=>{k(this,'Activating with version',a,b);g.waitUntil(v(this))});self.addEventListener('message',g=>{k(this,'Received message',g);w(this,g)});self.skipWaiting().then(()=>{})}info(...a){this.g>M||
32
+ console.info('[SW]',...a)}error(...a){this.g>N||console.error('[SW]',...a)}}var p=['/','/index.html','/version.json','/oConfig.json','/images/spinner_dark_bg_big.gif'],B=0,D=1,C=2,E=3,H=3,G=4,F=0,u=1,y=0,l=1,M=3,N=5;const J=(new URL(self.location)).searchParams,K='true'===J.get('cacheEnabled'),L=parseInt(J.get('logging.sw'),10);new I;
33
+
34
+
35
+ }.bind(this))();
36
+ return exports;
37
+ }.bind(this)));
38
+
package/types/base.d.ts CHANGED
@@ -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, ...)
11
- * or the class constructor for a `CloudObject`
10
+ * An InstanceOrTag is an alias for types that represent a CloudObject.
11
+ * It can be either a `string`, a `HasTag` (CloudObject instance, Property, Relation, ...) 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
 
@@ -32,7 +32,7 @@ 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.
@@ -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.
@@ -277,7 +277,7 @@ export abstract class CloudObject implements HasTag {
277
277
  * @param property property or property's tag
278
278
  * @return property value
279
279
  */
280
- get<T>(property: Property<T> | Tag): T | null;
280
+ get<T>(property: Property<T> | InstanceOrTag): T | null;
281
281
 
282
282
  /**
283
283
  * Get an observable to the current value of the specified property for this `CloudObject` instance.
@@ -291,7 +291,7 @@ export abstract class CloudObject implements HasTag {
291
291
  * @param waitForValue [=true] whether the observable wait for a first value to get a value.
292
292
  * @return Observable of property values
293
293
  */
294
- observe<T>(context: Context, property: Property<T> | Tag, waitForValue?: boolean): Observable<T>;
294
+ observe<T>(context: Context, property: Property<T> | InstanceOrTag, waitForValue?: boolean): Observable<T>;
295
295
 
296
296
  /**
297
297
  * Get an observable to pair [property, value] for this `CloudObject` instance.
@@ -379,7 +379,7 @@ interface RelationConstructor {
379
379
  * @param tag tag of the relation to create
380
380
  * @param direction whether the relation points to the origin or destination
381
381
  */
382
- new(tag: Tag, direction?: Direction): Relation<CloudObject, CloudObject>;
382
+ new(tag: InstanceOrTag, direction?: Direction): Relation<CloudObject, CloudObject>;
383
383
 
384
384
  /**
385
385
  * Create a relation between two CloudObject classes
@@ -388,7 +388,7 @@ interface RelationConstructor {
388
388
  * @param origin origin class of the relation
389
389
  * @param destination destination class of the relation
390
390
  */
391
- new<O extends CloudObject, D extends CloudObject>(tag: Tag, direction?: Direction, origin?: Class<O>, destination?: Class<D>): Relation<O, D>;
391
+ new<O extends CloudObject, D extends CloudObject>(tag: InstanceOrTag, direction?: Direction, origin?: Class<O>, destination?: Class<D>): Relation<O, D>;
392
392
  }
393
393
 
394
394
  /**
@@ -440,7 +440,7 @@ export interface Relation<O extends CloudObject, D extends CloudObject> extends
440
440
  * @param tag tag of the DataType
441
441
  * @param object `CloudObject` constructor
442
442
  */
443
- export function register(tag: Tag, object: typeof CloudObject): void;
443
+ export function register(tag: InstanceOrTag, object: typeof CloudObject): void;
444
444
 
445
445
  /**
446
446
  * Create a constant property object which has the specified tag and type to be used in coded bricks.
@@ -449,7 +449,7 @@ export function register(tag: Tag, object: typeof CloudObject): void;
449
449
  * @param type type the property holds values of
450
450
  * @return newly defined property
451
451
  */
452
- export function defineProperty<T>(tag: Tag, type?: Class<T>): Property<T>;
452
+ export function defineProperty<T>(tag: InstanceOrTag, type?: Class<T>): Property<T>;
453
453
 
454
454
  /**
455
455
  * Create a constant relation object between two specified DataTypes.
@@ -462,7 +462,7 @@ export function defineProperty<T>(tag: Tag, type?: Class<T>): Property<T>;
462
462
  * @param direction direction of the relation, pointing towards origin or destination. Default is `DESTINATION`
463
463
  * @return newly defined relation
464
464
  */
465
- export function defineRelation<O extends CloudObject, D extends CloudObject>(tag: Tag, origin?: Class<O>, destination?: Class<D>, direction?: Direction): Relation<O, D>;
465
+ export function defineRelation<O extends CloudObject, D extends CloudObject>(tag: InstanceOrTag, origin?: Class<O>, destination?: Class<D>, direction?: Direction): Relation<O, D>;
466
466
  /**
467
467
  * Create a constant relation object between two generic `CloudObjects`
468
468
  *
@@ -472,7 +472,7 @@ export function defineRelation<O extends CloudObject, D extends CloudObject>(tag
472
472
  * @param direction direction of the relation, pointing towards origin or destination. Default is `DESTINATION`
473
473
  * @return newly defined relation
474
474
  */
475
- export function defineRelation(tag: Tag, direction?: Direction): Relation<CloudObject, CloudObject>;
475
+ export function defineRelation(tag: InstanceOrTag, direction?: Direction): Relation<CloudObject, CloudObject>;
476
476
 
477
477
  /**
478
478
  * Returns a constant object corresponding to the specified relation going to the opposite direction
package/types/cloud.d.ts CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  // @ts-ignore
8
8
  import Observable from 'rxjs';
9
- import {Context, CloudObject, Relation, Property, Tag, Class} from "./base";
9
+ import {Context, CloudObject, Relation, Property, InstanceOrTag, Class} from "./base";
10
10
  import {Brick, BrickContext} from './runtime';
11
11
  import {Color} from "./utils";
12
12
 
@@ -128,7 +128,7 @@ export class File extends CloudObject {
128
128
  * @param content byte content of the file
129
129
  * @param mimeType optional mime type of the file
130
130
  */
131
- static setContent(transaction: Transaction, file: Tag, name: string, content: Uint8Array | ArrayBuffer, mimeType?: string);
131
+ static setContent(transaction: Transaction, file: InstanceOrTag, name: string, content: Uint8Array | ArrayBuffer, mimeType?: string);
132
132
 
133
133
  /**
134
134
  * Set the content of a `File` from a specified URL
@@ -138,7 +138,7 @@ export class File extends CloudObject {
138
138
  * @param url url to retrieve content from
139
139
  * @param mimeType optional mime type of the file
140
140
  */
141
- static setURLContent(transaction: Transaction, file: Tag, name: string, url: string, mimeType?: string);
141
+ static setURLContent(transaction: Transaction, file: InstanceOrTag, name: string, url: string, mimeType?: string);
142
142
 
143
143
  /**
144
144
  * @deprecated Please use {@apilink File.setContent}
@@ -246,7 +246,7 @@ export class EnumValue extends CloudObject {
246
246
  * @param name name of the `EnumValue`
247
247
  * @param rank position of the `EnumValue` in the `Enum`
248
248
  */
249
- static createValue(transaction: Transaction, enumModel: Tag, value: string, name?: string, rank?: number): string;
249
+ static createValue(transaction: Transaction, enumModel: InstanceOrTag, value: string, name?: string, rank?: number): string;
250
250
 
251
251
  /**
252
252
  * Name property for an EnumValue
@@ -410,7 +410,7 @@ export class Transaction {
410
410
  * @param tag optional tag of the instance to be created and must be unique
411
411
  * @return the tag of the instance to be created
412
412
  */
413
- create(model: Tag, properties?: Map<Tag, any>, source?: Source, tag?: string): string;
413
+ create(model: InstanceOrTag, properties?: Map<InstanceOrTag, any>, source?: Source, tag?: string): string;
414
414
 
415
415
  /**
416
416
  * Update the property of an instance
@@ -420,7 +420,7 @@ export class Transaction {
420
420
  * @param value the value of the property to be updated to
421
421
  * @return this transaction
422
422
  */
423
- update<T>(instance: Tag, property?: Property<T>, value?: T): this;
423
+ update<T>(instance: InstanceOrTag, property?: Property<T>, value?: T): this;
424
424
 
425
425
  /**
426
426
  * Update multiple properties of a single instance
@@ -429,7 +429,7 @@ export class Transaction {
429
429
  * @param properties map of properties to update
430
430
  * @return this transaction
431
431
  */
432
- multiUpdate(instance: Tag, properties: Map<Tag, any>): this;
432
+ multiUpdate(instance: InstanceOrTag, properties: Map<InstanceOrTag, any>): this;
433
433
 
434
434
  /**
435
435
  * Delete an instance
@@ -437,7 +437,7 @@ export class Transaction {
437
437
  * @param instance tag of the instance to be deleted
438
438
  * @return this transaction
439
439
  */
440
- delete(instance: Tag): this;
440
+ delete(instance: InstanceOrTag): this;
441
441
 
442
442
  /**
443
443
  * Create relation between two instances
@@ -447,7 +447,7 @@ export class Transaction {
447
447
  * @param to tag ofo the DESTINATION instance of the relation
448
448
  * @return this transaction with the create relation operation registered
449
449
  */
450
- createRelation(relation: Tag, from: Tag, to: Tag): this;
450
+ createRelation(relation: InstanceOrTag, from: InstanceOrTag, to: InstanceOrTag): this;
451
451
 
452
452
  /**
453
453
  * Delete a relation between two specified instances.
@@ -459,7 +459,7 @@ export class Transaction {
459
459
  * @param to destination instance tag
460
460
  * @return this transaction
461
461
  */
462
- deleteRelation(relation: Tag, from: Tag, to: Tag): this;
462
+ deleteRelation(relation: InstanceOrTag, from: InstanceOrTag, to: InstanceOrTag): this;
463
463
 
464
464
  /**
465
465
  * Delete any number of the relation starting from specified node.
@@ -478,25 +478,27 @@ export class Transaction {
478
478
  * @param relation deleted relation, indicates relation tag *and* direction
479
479
  * @param origin starting node
480
480
  */
481
- deleteAllRelations(relation: Relation<any, any>, origin: Tag): this;
481
+ deleteAllRelations(relation: Relation<any, any>, origin: InstanceOrTag): this;
482
482
 
483
483
  /**
484
- * Change the persistence mode of all instances in this transaction
484
+ * Set the specified instance to be persisted or not in this transaction.
485
+ * Default value of persist is true.
485
486
  *
486
- * @param persist whether instances are persisted outside
487
- * the local datacloud
487
+ * @param instance the instance to be persisted
488
+ * @param persist determine if the specified instance should be persisted or not (true by default).
488
489
  * @return this transaction
489
490
  */
490
- persist(persist?: boolean): this;
491
+ persist(instance: InstanceOrTag, persist?: boolean): this;
491
492
 
492
493
  /**
493
494
  * Change the persistence mode for a single instance in this transaction
494
495
  *
496
+ * @deprecated use {@apilink Transaction.persist} instead
495
497
  * @param instance the instance to be persisted
496
498
  * @param persist the persisting mode
497
499
  * @return this transaction
498
500
  */
499
- persistInstance(instance: Tag, persist?: boolean): this;
501
+ persistInstance(instance: InstanceOrTag, persist?: boolean): this;
500
502
 
501
503
  /**
502
504
  * Change the source of all instances created in this transaction
@@ -522,7 +524,7 @@ export class Transaction {
522
524
  * @param tag the instance to find the model of
523
525
  * @return the tag of the model of the given instance
524
526
  */
525
- model(tag: Tag): string | null;
527
+ model(tag: InstanceOrTag): string | null;
526
528
 
527
529
  /**
528
530
  * Add all operations of another transaction into this transaction
@@ -790,26 +792,6 @@ export class QueryResult<T extends CloudObject | CloudObject[]> {
790
792
  */
791
793
  shift(): T[];
792
794
 
793
- /**
794
- * Returns the new values added since the last `QueryResult` update.
795
- * In other words, `getAdded` returns the new values that exists in this query result, but did not in the previous query result pushed by the Observable.
796
- *
797
- * This applies only when {@apilink Query.observe | observing} a {@apilink Query}.
798
- *
799
- * @return values added
800
- */
801
- getAdded(): T[];
802
-
803
- /**
804
- * Returns the keys of values removed since the last `QueryResult` update.
805
- * In other words, `getRemoved` returns the old values that existed in the previous query result, but are no longer present in this query result pushed by the Observable.
806
- *
807
- * This applies only when {@apilink Query.observe | observing} a {@apilink Query}.
808
- *
809
- * @return keys of the removed values
810
- */
811
- getRemoved(): string[] | string[][];
812
-
813
795
  /**
814
796
  * Returns an array containing the values matching the provided filter predicate.
815
797
  *
@@ -893,6 +875,10 @@ export class QueryResult<T extends CloudObject | CloudObject[]> {
893
875
  concat(...others: QueryResult<T>[]): QueryResult<T>;
894
876
  }
895
877
 
878
+ interface QueryOptions {
879
+ cacheBucketName?: string; // Name of the cache bucket - if provided, it means that the query must be cached under this name
880
+ }
881
+
896
882
  /**
897
883
  * A Query is an immutable object used to build queries on the datacloud. It is a graph query builder.
898
884
  * It starts from an `origin` Tag (typically, the `Tag` of a data type or of an instance).
@@ -954,7 +940,7 @@ export class Query<T extends CloudObject, R> {
954
940
  * @param source optional source of the data to answer the query
955
941
  * @return an empty Query whose starting point is defined by a single `CloudObject`
956
942
  */
957
- static from<T extends Tag>(tag: T, source?: Source): Query<T extends CloudObject ? T : CloudObject, never>;
943
+ static from<T extends InstanceOrTag>(tag: T, source?: Source): Query<T extends CloudObject ? T : CloudObject, never>;
958
944
 
959
945
  /**
960
946
  * Create a query starting from the `CloudObject` specified tag.
@@ -966,7 +952,7 @@ export class Query<T extends CloudObject, R> {
966
952
  * @param source optional source of the data to answer the query
967
953
  * @return an empty Query whose starting point is defined by a single `CloudObject`
968
954
  */
969
- static fromTag<T extends CloudObject>(tag: string, dataType: Class<T> | Tag, source?: Source): Query<T, never>;
955
+ static fromTag<T extends CloudObject>(tag: string, dataType: Class<T> | InstanceOrTag, source?: Source): Query<T, never>;
970
956
 
971
957
  /**
972
958
  * Create a query starting from the instances of the specified model. By default, it does include the instances of
@@ -979,7 +965,7 @@ export class Query<T extends CloudObject, R> {
979
965
  * an external data source (Tag of a `DBConnectorTag`)
980
966
  * @return a new query object starting from model instances
981
967
  */
982
- static instancesOf<T extends Tag>(model: Class<T> | Tag, includeInheritance?: boolean, source?: Source): Query<T extends CloudObject ? T : CloudObject, never>;
968
+ static instancesOf<T extends InstanceOrTag>(model: Class<T> | InstanceOrTag, includeInheritance?: boolean, source?: Source): Query<T extends CloudObject ? T : CloudObject, never>;
983
969
 
984
970
  /**
985
971
  * Create a query starting from a specific root instance, then following relations based on a rule constraint.
@@ -987,8 +973,10 @@ export class Query<T extends CloudObject, R> {
987
973
  * @param root Starting point of the query. See `root` of {@apilink RootQueryPart}
988
974
  * @param rule Discriminate which relations to follow
989
975
  * @param source The tag of the source responsible for executing the query
976
+ * @param options options
977
+ * @param options.storeInCacheDB indicates if this follow rule query must be cached in browser DB (IndexedDB) for potential offline use. Default is false.
990
978
  */
991
- static followRule<T extends Tag>(ctx: Context, root: T, rule: FollowRule, source?: Source): Observable<QueryResult<T extends CloudObject ? T : CloudObject>>;
979
+ static followRule<T extends InstanceOrTag>(ctx: Context, root: T, rule: FollowRule, source?: Source, options?: {storeInCacheDB?: boolean}): Observable<QueryResult<T extends CloudObject ? T : CloudObject>>;
992
980
 
993
981
  /**
994
982
  * Instruct the query to follow a specified relation. This does not add any key-value pair to the result.
@@ -1141,14 +1129,13 @@ export class Query<T extends CloudObject, R> {
1141
1129
  parse(): RootQueryPart;
1142
1130
 
1143
1131
  /**
1144
- * Execute the query asynchronously on the datacloud and deletes it afterwards.
1132
+ * Execute the query asynchronously on the datacloud and deletes it afterward.
1145
1133
  * In other words, one cannot call execute twice on the same `Query`.
1146
1134
  *
1147
- * @param context context in which the query must be executed. As this is an asynchronous operation,
1148
- * one has to provide a context that won't be destroyed before the query has a result.
1135
+ * @param options options
1149
1136
  * @return promise resolving to query result or failing otherwise.
1150
1137
  */
1151
- execute(context: Context): Promise<QueryResult<R extends never ? T : R extends CloudObject | CloudObject[] ? R : never>>;
1138
+ execute(options?: QueryOptions): Promise<QueryResult<R extends never ? T : R extends CloudObject | CloudObject[] ? R : never>>;
1152
1139
 
1153
1140
  /**
1154
1141
  * Get an observable to the current value of the QueryResult for this Query instance.
@@ -1158,9 +1145,10 @@ export class Query<T extends CloudObject, R> {
1158
1145
  * The observable gets completed automatically once the specified context is {@apilink Context.onClear | cleared}.
1159
1146
  *
1160
1147
  * @param context {@apilink Context} to which the Observable is attached
1148
+ * @param options options
1161
1149
  * @return Observable of QueryResult values
1162
1150
  */
1163
- observe(context: Context): Observable<QueryResult<R extends never ? T : R extends CloudObject | CloudObject[] ? R : never>>;
1151
+ observe(context: Context, options?: QueryOptions): Observable<QueryResult<R extends never ? T : R extends CloudObject | CloudObject[] ? R : never>>;
1164
1152
 
1165
1153
  /**
1166
1154
  * Execute synchronously the query on the local datacloud cache.
@@ -1187,7 +1175,7 @@ export class QuerySingle<T extends CloudObject> {
1187
1175
  * @param object starting node for the graph query single
1188
1176
  * @return new query single only accepting 0..1 relations
1189
1177
  */
1190
- static from<T extends CloudObject>(object: Tag): QuerySingle<T>;
1178
+ static from<T extends CloudObject>(object: InstanceOrTag): QuerySingle<T>;
1191
1179
 
1192
1180
  /**
1193
1181
  * Follow a 0..1 relation
@@ -1239,7 +1227,7 @@ export class Predicate {
1239
1227
  *
1240
1228
  * @param tags the object or unique identifier (tag) of the objects to look for.
1241
1229
  */
1242
- static in(...tags: Tag[]): Predicate;
1230
+ static in(...tags: InstanceOrTag[]): Predicate;
1243
1231
 
1244
1232
  /**
1245
1233
  * Create a predicate matching a specified property to a specified value.
@@ -1255,7 +1243,7 @@ export class Predicate {
1255
1243
  *
1256
1244
  * @param property the string property to use for filtering
1257
1245
  * @param value the value the string property must match
1258
- * @param caseSensitive if the match must pay attention to case sensitivity, default value is false
1246
+ * @param caseSensitive if the match must pay attention to case sensitivity, default value is true
1259
1247
  * @return new Predicate with the contains string operation
1260
1248
  */
1261
1249
  static contains(property: Property<string>, value: string, caseSensitive?: boolean): Predicate;
@@ -1264,11 +1252,11 @@ export class Predicate {
1264
1252
  * Create a predicate matching a specified string property to a regular expression.
1265
1253
  *
1266
1254
  * @param property the string property to use for filtering
1267
- * @param value the regex the string property must match
1268
- * @param caseSensitive if the match must pay attention to case sensitivity, default value is false
1255
+ * @param value the regex or pattern the string property must match
1256
+ * @param caseSensitive if the match must pay attention to case sensitivity, default value is true
1269
1257
  * @return new Predicate with the match regex operation
1270
1258
  */
1271
- static regex(property: Property<string>, value: RegExp, caseSensitive?: boolean): Predicate;
1259
+ static regex(property: Property<string>, value: RegExp | string, caseSensitive?: boolean): Predicate;
1272
1260
 
1273
1261
  /**
1274
1262
  * Create a predicate matching a specified number property to a numerical lower bound
@@ -1298,7 +1286,7 @@ export class Predicate {
1298
1286
  * @param extend should the predicate also match against inherited models
1299
1287
  * @return new Predicate
1300
1288
  */
1301
- static instanceOf(expectedModel: Tag, extend: boolean): Predicate;
1289
+ static instanceOf(expectedModel: InstanceOrTag, extend: boolean): Predicate;
1302
1290
 
1303
1291
  /**
1304
1292
  * Create a predicate matching a specified number property to a number property lower bound
@@ -1379,7 +1367,7 @@ export class DataResult {
1379
1367
  * @param properties The properties to set on the instance.
1380
1368
  * @return This {@apilink DataResult} instance.
1381
1369
  */
1382
- create(tag: Tag, model: Tag, properties?: Map<Tag, any>): this;
1370
+ create(tag: InstanceOrTag, model: InstanceOrTag, properties?: Map<InstanceOrTag, any>): this;
1383
1371
 
1384
1372
  /**
1385
1373
  * Create a relation between two instances with the specified {@apilink Relation}, `from`, and `to` instance tags.
@@ -1388,7 +1376,7 @@ export class DataResult {
1388
1376
  * @param to The unique identifier of the destination instance.
1389
1377
  * @return This {@apilink DataResult} instance.
1390
1378
  */
1391
- createRelation(relation: Tag, from: Tag, to: Tag): this;
1379
+ createRelation(relation: InstanceOrTag, from: InstanceOrTag, to: InstanceOrTag): this;
1392
1380
  }
1393
1381
 
1394
1382
  /**
@@ -1642,9 +1630,10 @@ export abstract class DataSource extends CloudObject {
1642
1630
  /**
1643
1631
  * Applies the provided {@apilink Operation} array to the data source as one transaction
1644
1632
  * @param {Operation[]} transaction - The {@apilink Operation} array to apply.
1633
+ * @param {?TransactionOptions} options
1645
1634
  * @return {Promise<void>} A Promise that resolves when the transaction is completed. Rejects when the transaction fails.
1646
1635
  */
1647
- protected applyTransaction(transaction: Operation[]): Promise<void>;
1636
+ protected applyTransaction(transaction: Operation[], options?: TransactionOptions): Promise<void>;
1648
1637
 
1649
1638
  /**
1650
1639
  * Uploads one file's content to the data source.
@@ -1671,3 +1660,11 @@ export abstract class DataSource extends CloudObject {
1671
1660
  */
1672
1661
  protected deleteFileContent(fileTag: string, dataType: string): Promise<void>;
1673
1662
  }
1663
+
1664
+ /**
1665
+ * Additional options for transactions to be processed by a data source.
1666
+ * - batch: if true, it means that the transaction has been executed using the {@apilink Transaction.executeAsLarge()} function.
1667
+ */
1668
+ export type TransactionOptions = {
1669
+ batch: boolean
1670
+ };
package/types/legacy.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  // @ts-ignore
2
2
  import Observable from 'rxjs';
3
- import {CloudObject, Direction, HasTag, Property, Relation, Tag} from "./base";
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;
@@ -3,7 +3,7 @@
3
3
  // **********************************
4
4
  // @ts-ignore
5
5
  import Observable from 'rxjs';
6
- import {CloudObject, Context, Property, Tag} from "./base";
6
+ import {CloudObject, Context, Property, InstanceOrTag} from "./base";
7
7
 
8
8
  /**
9
9
  * Label of global properties used by convention through bricks and applications.
@@ -94,6 +94,14 @@ export class BrickContext extends Context {
94
94
  */
95
95
  trigger<T>(key: string | Property<T>): this;
96
96
 
97
+ /**
98
+ * Throw the specified error to this context. The error will be propagated until it finds an error handler.
99
+ *
100
+ * @param error the error to throw and propagate in the contexts hierarchy
101
+ * @return this context
102
+ */
103
+ throw(error: ErrorFlow | Error | string): this;
104
+
97
105
  /**
98
106
  * Run a runnable property and returns its context.
99
107
  *
@@ -138,7 +146,7 @@ export class BrickContext extends Context {
138
146
  *
139
147
  * @param modelTag tag of the "type" of context you want to find in the parent tree
140
148
  */
141
- getClosest(modelTag: Tag): BrickContext | null;
149
+ getClosest(modelTag: InstanceOrTag): BrickContext | null;
142
150
 
143
151
  /**
144
152
  * Listen to the creation of the context with the specified id.