@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/import/olympe.dm/datamodel/00_bootstrap.newInst.json +1 -1
- package/import/olympe.dm/datamodel/05_permission_schema.updateInst.json +1 -1
- package/import/olympe.dm/datamodel/06_structure.newInst.json +1 -1
- package/import/olympe.sc/datamodel/01_language.newInst.json +1 -1
- package/import/olympe.sc/datamodel/01_language.newRel.json +1 -1
- package/import/olympe.sc/datamodel/02_bricks.newInst.json +1 -1
- package/import/olympe.sc/datamodel/02_bricks.newRel.json +1 -1
- package/index.js +882 -790
- package/package.json +1 -2
- package/types/base.d.ts +33 -20
- package/types/cloud.d.ts +76 -65
- package/types/legacy.d.ts +3 -3
- package/types/runtime.d.ts +20 -10
- package/types/utils.d.ts +116 -6
package/types/runtime.d.ts
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
// Runtime classes
|
|
3
3
|
// **********************************
|
|
4
4
|
// @ts-ignore
|
|
5
|
-
import Observable from 'rxjs';
|
|
6
|
-
import {CloudObject, Context, Property,
|
|
5
|
+
import {Observable} from 'rxjs';
|
|
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
|
|
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
|
|
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
|
|
49
|
-
* @param global
|
|
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
|
|
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>;
|
|
@@ -94,6 +95,14 @@ export class BrickContext extends Context {
|
|
|
94
95
|
*/
|
|
95
96
|
trigger<T>(key: string | Property<T>): this;
|
|
96
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Throw the specified error to this context. The error will be propagated until it finds an error handler.
|
|
100
|
+
*
|
|
101
|
+
* @param error the error to throw and propagate in the contexts hierarchy
|
|
102
|
+
* @return this context
|
|
103
|
+
*/
|
|
104
|
+
throw(error: ErrorFlow | Error | string): this;
|
|
105
|
+
|
|
97
106
|
/**
|
|
98
107
|
* Run a runnable property and returns its context.
|
|
99
108
|
*
|
|
@@ -136,9 +145,10 @@ export class BrickContext extends Context {
|
|
|
136
145
|
/**
|
|
137
146
|
* Return the closest parent of a given type
|
|
138
147
|
*
|
|
139
|
-
* @param
|
|
148
|
+
* @param selector the context selector
|
|
149
|
+
* @param selector.modelTag tag of the "type" of context you want to find in the parent tree
|
|
140
150
|
*/
|
|
141
|
-
getClosest(modelTag:
|
|
151
|
+
getClosest(selector: {modelTag: InstanceOrTag}): BrickContext | null;
|
|
142
152
|
|
|
143
153
|
/**
|
|
144
154
|
* Listen to the creation of the context with the specified id.
|
|
@@ -159,7 +169,7 @@ export class BrickContext extends Context {
|
|
|
159
169
|
* @param brick the brick class
|
|
160
170
|
* @param args Extra arguments
|
|
161
171
|
*/
|
|
162
|
-
export function registerBrick(tag: string, brick: new () => Brick, ...args: any);
|
|
172
|
+
export function registerBrick(tag: string, brick: new () => Brick, ...args: any): void;
|
|
163
173
|
|
|
164
174
|
export abstract class Brick extends CloudObject {
|
|
165
175
|
|
package/types/utils.d.ts
CHANGED
|
@@ -3,14 +3,16 @@
|
|
|
3
3
|
// **********************************
|
|
4
4
|
|
|
5
5
|
// @ts-ignore
|
|
6
|
-
import {Observable} from
|
|
6
|
+
import {Observable} from 'rxjs';
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
import {Error} from 'es5';
|
|
7
9
|
import {Context} from "./base";
|
|
8
10
|
|
|
9
11
|
// -- Configuration --
|
|
10
12
|
export class Config {
|
|
11
13
|
/**
|
|
12
14
|
* Return the value of the specified parameter.
|
|
13
|
-
* Parameters can get their values from the oConfig.json file or be
|
|
15
|
+
* Parameters can get their values from the oConfig.json file or be overridden from the URL / command that opened the application.
|
|
14
16
|
*
|
|
15
17
|
* @param id the parameter id
|
|
16
18
|
*/
|
|
@@ -40,6 +42,33 @@ export class Process {
|
|
|
40
42
|
* @param callback the callback executed when the runtime terminates.
|
|
41
43
|
*/
|
|
42
44
|
static onShutdown(callback: () => Promise<void>): () => void;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Static method that manually triggers a connection attempt to the server to go ONLINE.
|
|
48
|
+
* If you have called {@apilink Process.disconnect()} before, it will cancel the OFFLINE mode,
|
|
49
|
+
* next time the app will be opened, it will try to go ONLINE on its own.
|
|
50
|
+
*
|
|
51
|
+
* Returns a promise that resolves when the server connection is established. If it fails, the promise is rejected.
|
|
52
|
+
*/
|
|
53
|
+
static connect(): Promise<void>;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Static method that manually close the connection to the server to go OFFLINE.
|
|
57
|
+
* Persists the offline status so the app restart offline after being closed.
|
|
58
|
+
* The only way to clean that status is to call {@apilink Process.connect()}.
|
|
59
|
+
*
|
|
60
|
+
* Returns a promise that resolves when the server connection is indeed disconnected and the state is OFFLINE.
|
|
61
|
+
* If the flag `offline.enabled` is not set to true, the promise is rejected.
|
|
62
|
+
*/
|
|
63
|
+
static disconnect(): Promise<void>;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Static method that returns an observable on the connection state: the observable send TRUE if the process is considered
|
|
67
|
+
* as ONLINE and false if not.
|
|
68
|
+
*
|
|
69
|
+
* @param context the context of the brick to garbage collect the observable when not needed anymore.
|
|
70
|
+
*/
|
|
71
|
+
static isOnline(context: Context): Observable<boolean>;
|
|
43
72
|
}
|
|
44
73
|
|
|
45
74
|
// -- Primitive types classes --
|
|
@@ -52,13 +81,13 @@ export class Color {
|
|
|
52
81
|
getAlpha(): number;
|
|
53
82
|
toRGBString(): string;
|
|
54
83
|
toHexString(): string;
|
|
55
|
-
equals(obj): boolean;
|
|
84
|
+
equals(obj: any): boolean;
|
|
56
85
|
}
|
|
57
86
|
|
|
58
87
|
/**
|
|
59
88
|
* Error type used to propagate errors through flows between bricks.
|
|
60
89
|
*/
|
|
61
|
-
export class ErrorFlow {
|
|
90
|
+
export class ErrorFlow extends Error {
|
|
62
91
|
/**
|
|
63
92
|
* Create a new Error object to be sent in an error flow
|
|
64
93
|
*
|
|
@@ -76,18 +105,23 @@ export class ErrorFlow {
|
|
|
76
105
|
* Return the code associated to this error
|
|
77
106
|
*/
|
|
78
107
|
getCode(): number;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Return the stack with the hierarchy of bricks that run the one having thrown the error.
|
|
111
|
+
*/
|
|
112
|
+
getStack(): string;
|
|
79
113
|
}
|
|
80
114
|
|
|
81
115
|
/**
|
|
82
116
|
* Types of requests that can be received in a Service.
|
|
83
117
|
* This is used to know what method call on the request to answer the requester.
|
|
84
118
|
*/
|
|
85
|
-
export
|
|
119
|
+
export enum ServiceRequestType {
|
|
86
120
|
PUBLISH,
|
|
87
121
|
SEND,
|
|
88
122
|
GET,
|
|
89
123
|
SUBSCRIBE
|
|
90
|
-
}
|
|
124
|
+
}
|
|
91
125
|
|
|
92
126
|
/**
|
|
93
127
|
* A request consumed by a service.
|
|
@@ -278,6 +312,8 @@ export class Auth {
|
|
|
278
312
|
|
|
279
313
|
/**
|
|
280
314
|
* Return the current state of the authentication manager
|
|
315
|
+
*
|
|
316
|
+
* @deprecated use {@apilink Auth.isAuthenticated} instead
|
|
281
317
|
* @return the current state
|
|
282
318
|
*/
|
|
283
319
|
static getState(): AuthState;
|
|
@@ -304,6 +340,14 @@ export class Auth {
|
|
|
304
340
|
*/
|
|
305
341
|
static refreshToken(): Promise<void>;
|
|
306
342
|
|
|
343
|
+
/**
|
|
344
|
+
* Returns an `Observable` that is updated each time the authentication status changes.
|
|
345
|
+
* If the user is authenticated, gets true, otherwise (e.g. Guest) get false.
|
|
346
|
+
* @param context The brick context
|
|
347
|
+
* @return An `Observable`
|
|
348
|
+
*/
|
|
349
|
+
static isAuthenticated(context: Context): Observable<boolean>
|
|
350
|
+
|
|
307
351
|
/**
|
|
308
352
|
* Returns an `Observable` that is updated each time the user tag changes.
|
|
309
353
|
* @param context The brick context
|
|
@@ -389,6 +433,60 @@ export class Auth {
|
|
|
389
433
|
static logout(): Promise<void>;
|
|
390
434
|
}
|
|
391
435
|
|
|
436
|
+
export class Cache {
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Return the list of cache ids saved in previous execute or observe
|
|
440
|
+
*/
|
|
441
|
+
static getCacheEntries(): Observable<Array<string>>;
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Clear the cached data related to this cache id. If not cache id provided => clear all cache ids
|
|
445
|
+
*/
|
|
446
|
+
static clearCache(id?: string): Promise<void>;
|
|
447
|
+
|
|
448
|
+
/**
|
|
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
|
|
451
|
+
*/
|
|
452
|
+
static getProcessingStatus(): Observable<CacheStatus>
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Return an Observable which emit a new value for each Error encountered when
|
|
456
|
+
* processing data results asynchronously
|
|
457
|
+
*/
|
|
458
|
+
static getProcessingErrors(): Observable<boolean>
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* Return an observable which gets TRUE if one or more changes must be
|
|
462
|
+
* synced with remoted database
|
|
463
|
+
*
|
|
464
|
+
*/
|
|
465
|
+
static hasPendingChanges(): Observable<boolean>;
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Sync the local changes made offline with the online data source
|
|
469
|
+
* Returns an observable in the form [nbChanges, nbSyncedChanges]
|
|
470
|
+
*/
|
|
471
|
+
static synchroniseChanges(): Observable<[number, number]>;
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* Return a string containing all changes and there related files. This method can be used to "backup" pending changes
|
|
475
|
+
* at any point in time before a synchronisation
|
|
476
|
+
*/
|
|
477
|
+
static getPendingChanges(): Promise<string>;
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Clear the list of pending changes without applying or syncing them.
|
|
481
|
+
*/
|
|
482
|
+
static clearPendingChanges(): Promise<void>;
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* Load the given pending changes into the local offline database
|
|
486
|
+
*/
|
|
487
|
+
static loadPendingChanges(data: string): Promise<void>;
|
|
488
|
+
}
|
|
489
|
+
|
|
392
490
|
declare type SRPData = {
|
|
393
491
|
username: string,
|
|
394
492
|
login: string
|
|
@@ -404,3 +502,15 @@ declare enum AuthState {
|
|
|
404
502
|
ERROR = 'error',
|
|
405
503
|
AUTHENTICATED = 'authenticated'
|
|
406
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
|
+
}
|