@olympeio/runtime-node 9.5.0 → 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,6 +1,6 @@
1
1
  {
2
2
  "name": "@olympeio/runtime-node",
3
- "version": "9.5.0",
3
+ "version": "9.5.1",
4
4
  "description": "Olympe Node Runtime Environment",
5
5
  "types": "types/index.d.ts",
6
6
  "dependencies": {
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,8 +7,8 @@ import {PropertyModel, Query, QueryResult, QuerySingle, Source} from "./cloud";
7
7
  // **********************************
8
8
 
9
9
  /**
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`
10
+ * A InstanceOrTag can be either a `string`, a `HasTag` (CloudObject instance, Property, Relation, ...)
11
+ * or the class constructor for a `CloudObject`
12
12
  */
13
13
  export type InstanceOrTag = string | HasTag | typeof CloudObject;
14
14
 
@@ -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.
@@ -36,7 +36,7 @@ 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:**
@@ -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
  /**
@@ -288,7 +295,7 @@ 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
301
  observe<T>(context: Context, property: Property<T> | InstanceOrTag, waitForValue?: boolean): Observable<T>;
@@ -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`
package/types/cloud.d.ts CHANGED
@@ -5,7 +5,8 @@
5
5
  // *********************************************
6
6
 
7
7
  // @ts-ignore
8
- import Observable from 'rxjs';
8
+ import {Observable} from 'rxjs';
9
+ import {Readable} from 'stream';
9
10
  import {Context, CloudObject, Relation, Property, InstanceOrTag, Class} from "./base";
10
11
  import {Brick, BrickContext} from './runtime';
11
12
  import {Color} from "./utils";
@@ -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: InstanceOrTag, 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: InstanceOrTag, 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
@@ -875,13 +876,17 @@ export class QueryResult<T extends CloudObject | CloudObject[]> {
875
876
  concat(...others: QueryResult<T>[]): QueryResult<T>;
876
877
  }
877
878
 
878
- interface QueryOptions {
879
+ declare type QueryOptions = {
879
880
  cacheBucketName?: string; // Name of the cache bucket - if provided, it means that the query must be cached under this name
880
881
  }
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
+
882
887
  /**
883
888
  * A Query is an immutable object used to build queries on the datacloud. It is a graph query builder.
884
- * 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).
885
890
  * From there, it can follow relations between data types and filter results.
886
891
  *
887
892
  * Example:
@@ -974,9 +979,8 @@ export class Query<T extends CloudObject, R> {
974
979
  * @param rule Discriminate which relations to follow
975
980
  * @param source The tag of the source responsible for executing the query
976
981
  * @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.
978
982
  */
979
- static followRule<T extends InstanceOrTag>(ctx: Context, root: T, rule: FollowRule, source?: Source, options?: {storeInCacheDB?: boolean}): 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>>;
980
984
 
981
985
  /**
982
986
  * Instruct the query to follow a specified relation. This does not add any key-value pair to the result.
@@ -1197,10 +1201,9 @@ export class QuerySingle<T extends CloudObject> {
1197
1201
  /**
1198
1202
  * Execute the query single, see {@apilink Query.execute | Query.execute()}
1199
1203
  *
1200
- * @param context
1201
1204
  * @return promise containing the single result or `null`
1202
1205
  */
1203
- execute(context: Context): Promise<T | null>;
1206
+ execute(): Promise<T | null>;
1204
1207
 
1205
1208
  /**
1206
1209
  * Execute the query single on the local data cloud,
@@ -1361,7 +1364,7 @@ export class DataResult {
1361
1364
  static fromQuery(query: Query<CloudObject, any>): DataResult;
1362
1365
 
1363
1366
  /**
1364
- * 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.
1365
1368
  * @param tag The unique identifier of the object instance to create.
1366
1369
  * @param model The Data Type of the instance to create.
1367
1370
  * @param properties The properties to set on the instance.
@@ -1587,14 +1590,14 @@ export abstract class DataSource extends CloudObject {
1587
1590
 
1588
1591
  /**
1589
1592
  * Returns the tag of the data source.
1590
- * @return {string} tag of the data source.
1593
+ * @return tag of the data source.
1591
1594
  */
1592
1595
  getId(): string;
1593
1596
 
1594
1597
  /**
1595
1598
  * Retrieves the configuration value associated with the provided key in the data source oConfig.
1596
- * @param {string} key - Key to retrieve the configuration value for.
1597
- * @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.
1598
1601
  */
1599
1602
  getConfig(key: string): any;
1600
1603
 
@@ -1603,60 +1606,60 @@ export abstract class DataSource extends CloudObject {
1603
1606
  * It can also perform a health check to ensure the connection is active.
1604
1607
  * Subscribes to the {@apilink DataSource.observeDataTypes} observable to handle changes to the data types in the data source.
1605
1608
  *
1606
- * @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
1607
1610
  * @return A promise that resolves with void when initialization is complete. Reject if initialization did not complete.
1608
1611
  */
1609
- protected init(context): Promise<void>;
1612
+ protected init(context: BrickContext): Promise<void>;
1610
1613
 
1611
1614
  /**
1612
1615
  * Performs a health check on the data source, checking if the connection is alive.
1613
- * @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.
1614
1617
  */
1615
1618
  protected healthCheck(): Promise<void>;
1616
1619
 
1617
1620
  /**
1618
1621
  * Disconnects the data source.
1619
- * @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.
1620
1623
  */
1621
1624
  protected destroy(): Promise<void>;
1622
1625
 
1623
1626
  /**
1624
1627
  * Executes the provided {@apilink Query} once and returns a {@apilink DataResult}.
1625
- * @param {Query<CloudObject, any>} query - The {@apilink Query} object to execute.
1626
- * @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.
1627
1630
  */
1628
1631
  protected executeQuery(query: Query<CloudObject, any>): Promise<DataResult>;
1629
1632
 
1630
1633
  /**
1631
1634
  * Applies the provided {@apilink Operation} array to the data source as one transaction
1632
- * @param {Operation[]} transaction - The {@apilink Operation} array to apply.
1633
- * @param {?TransactionOptions} options
1634
- * @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.
1635
1638
  */
1636
1639
  protected applyTransaction(transaction: Operation[], options?: TransactionOptions): Promise<void>;
1637
1640
 
1638
1641
  /**
1639
1642
  * Uploads one file's content to the data source.
1640
- * @param {string} fileTag - The tag of the file.
1641
- * @param {string} dataType - The file data type
1642
- * @param {Uint8Array} binary - The binary data of the file.
1643
- * @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.
1644
1647
  */
1645
1648
  protected uploadFileContent(fileTag: string, dataType: string, binary: Uint8Array): Promise<void>;
1646
1649
 
1647
1650
  /**
1648
1651
  * Downloads one file's 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<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.
1652
1655
  */
1653
- protected downloadFileContent(fileTag: string, dataType: string): Promise<Uint8Array>;
1656
+ protected downloadFileContent(fileTag: string, dataType: string): Promise<Uint8Array | Readable>;
1654
1657
 
1655
1658
  /**
1656
1659
  * Deletes file content from the data source.
1657
- * @param {string} fileTag - The tag of the file.
1658
- * @param {string} dataType - The file data type
1659
- * @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.
1660
1663
  */
1661
1664
  protected deleteFileContent(fileTag: string, dataType: string): Promise<void>;
1662
1665
  }
package/types/legacy.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  // @ts-ignore
2
- import Observable from 'rxjs';
2
+ import {Observable} from 'rxjs';
3
3
  import {CloudObject, Direction, HasTag, Property, Relation, InstanceOrTag} from "./base";
4
4
  import {Brick, VisualBrick} from "./runtime";
5
5
  /**
@@ -2,8 +2,9 @@
2
2
  // Runtime classes
3
3
  // **********************************
4
4
  // @ts-ignore
5
- import Observable from 'rxjs';
5
+ import {Observable} from 'rxjs';
6
6
  import {CloudObject, Context, Property, InstanceOrTag} from "./base";
7
+ import {ErrorFlow} from "./utils";
7
8
 
8
9
  /**
9
10
  * Label of global properties used by convention through bricks and applications.
@@ -24,7 +25,7 @@ export class BrickContext extends Context {
24
25
  * Returns a boolean indicating whether a property has a value or not.
25
26
  *
26
27
  * @param key the property or key string
27
- * @param global [=false] whether the method checks parent contexts
28
+ * @param global whether the method checks parent contexts (Default = false)
28
29
  * @return whether `property` has a value or not
29
30
  */
30
31
  has<T>(key: string | Property<T>, global?: boolean): boolean;
@@ -33,7 +34,7 @@ export class BrickContext extends Context {
33
34
  * Return the current value of the specified property. If there is currently no value, return null.
34
35
  *
35
36
  * @param key the property or key string
36
- * @param global [=false] whether the method checks parent contexts
37
+ * @param global whether the method checks parent contexts (Default = false)
37
38
  * @return the current value
38
39
  */
39
40
  get<T>(key: string | Property<T>, global?: boolean): T | null;
@@ -45,8 +46,8 @@ export class BrickContext extends Context {
45
46
  * If `global` is set to TRUE (FALSE by default), it observes values coming from other contexts accessible from the current one.
46
47
  *
47
48
  * @param key the property or key string
48
- * @param waitForValue [=true] whether the observable should wait for a first value to get a value.
49
- * @param global [=false] whether to listen to a value coming from other contexts.
49
+ * @param waitForValue whether the observable should wait for a first value to get a value. (Default = true)
50
+ * @param global whether to listen to a value coming from other contexts. (Default = false)
50
51
  * @return the observable
51
52
  */
52
53
  observe<T>(key: string | Property<T>, waitForValue?: boolean, global?: boolean): Observable<T>;
@@ -56,7 +57,7 @@ export class BrickContext extends Context {
56
57
  * The promise is rejected if no value is set to the specified property before the destruction of this BrickContext.
57
58
  *
58
59
  * @param key the property
59
- * @param global [=false] whether the method checks parent contexts
60
+ * @param global whether the method checks parent contexts (Default = false)
60
61
  * @return a promise of the next value of property
61
62
  */
62
63
  waitFor<T>(key: string | Property<T>, global?: boolean): Promise<T>;
@@ -144,9 +145,10 @@ export class BrickContext extends Context {
144
145
  /**
145
146
  * Return the closest parent of a given type
146
147
  *
147
- * @param modelTag tag of the "type" of context you want to find in the parent tree
148
+ * @param selector the context selector
149
+ * @param selector.modelTag tag of the "type" of context you want to find in the parent tree
148
150
  */
149
- getClosest(modelTag: InstanceOrTag): BrickContext | null;
151
+ getClosest(selector: {modelTag: InstanceOrTag}): BrickContext | null;
150
152
 
151
153
  /**
152
154
  * Listen to the creation of the context with the specified id.
@@ -167,7 +169,7 @@ export class BrickContext extends Context {
167
169
  * @param brick the brick class
168
170
  * @param args Extra arguments
169
171
  */
170
- export function registerBrick(tag: string, brick: new () => Brick, ...args: any);
172
+ export function registerBrick(tag: string, brick: new () => Brick, ...args: any): void;
171
173
 
172
174
  export abstract class Brick extends CloudObject {
173
175
 
package/types/utils.d.ts CHANGED
@@ -3,7 +3,9 @@
3
3
  // **********************************
4
4
 
5
5
  // @ts-ignore
6
- import { BehaviorSubject, Observable } from "rxjs";
6
+ import {Observable} from 'rxjs';
7
+ // @ts-ignore
8
+ import {Error} from 'es5';
7
9
  import {Context} from "./base";
8
10
 
9
11
  // -- Configuration --
@@ -79,7 +81,7 @@ export class Color {
79
81
  getAlpha(): number;
80
82
  toRGBString(): string;
81
83
  toHexString(): string;
82
- equals(obj): boolean;
84
+ equals(obj: any): boolean;
83
85
  }
84
86
 
85
87
  /**
@@ -114,12 +116,12 @@ export class ErrorFlow extends Error {
114
116
  * Types of requests that can be received in a Service.
115
117
  * This is used to know what method call on the request to answer the requester.
116
118
  */
117
- export type ServiceRequestType = {
119
+ export enum ServiceRequestType {
118
120
  PUBLISH,
119
121
  SEND,
120
122
  GET,
121
123
  SUBSCRIBE
122
- };
124
+ }
123
125
 
124
126
  /**
125
127
  * A request consumed by a service.
@@ -436,7 +438,7 @@ export class Cache {
436
438
  /**
437
439
  * Return the list of cache ids saved in previous execute or observe
438
440
  */
439
- static getCacheEntriesList(): Observable<Array<string>>;
441
+ static getCacheEntries(): Observable<Array<string>>;
440
442
 
441
443
  /**
442
444
  * Clear the cached data related to this cache id. If not cache id provided => clear all cache ids
@@ -444,10 +446,10 @@ export class Cache {
444
446
  static clearCache(id?: string): Promise<void>;
445
447
 
446
448
  /**
447
- * Return an Observable which gets TRUE if the Cache is processing some queries
448
- * to keep the offline database up-to-date
449
+ * Return an Observable which returns the current processing status of the Cache layer.
450
+ * `processing` is set to TRUE if the Cache is processing some queries or downloading files to keep the offline database up-to-date
449
451
  */
450
- static isProcessing(): Observable<boolean>
452
+ static getProcessingStatus(): Observable<CacheStatus>
451
453
 
452
454
  /**
453
455
  * Return an Observable which emit a new value for each Error encountered when
@@ -500,3 +502,15 @@ declare enum AuthState {
500
502
  ERROR = 'error',
501
503
  AUTHENTICATED = 'authenticated'
502
504
  }
505
+
506
+ declare type CacheStatus = {
507
+ processing: boolean,
508
+ queries: {
509
+ total: number,
510
+ processed: number,
511
+ },
512
+ files: {
513
+ total: number,
514
+ processed: number,
515
+ }
516
+ }