@olympeio/runtime-node 8.6.2 → 8.7.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.
Files changed (26) hide show
  1. package/import/olympe.dm/datamodel/00_bootstrap.newInst.json +1 -1
  2. package/import/olympe.dm/datamodel/00_bootstrap.newRel.json +1 -1
  3. package/import/olympe.dm/datamodel/01_primitives.newInst.json +1 -1
  4. package/import/olympe.dm/datamodel/01_primitives.newRel.json +1 -1
  5. package/import/olympe.dm/datamodel/02_permissions.newInst.json +1 -1
  6. package/import/olympe.dm/datamodel/02_permissions.newRel.json +1 -1
  7. package/import/olympe.dm/datamodel/03_file.newInst.json +1 -1
  8. package/import/olympe.dm/datamodel/03_file.newRel.json +1 -1
  9. package/import/olympe.dm/datamodel/04_modules.newInst.json +1 -1
  10. package/import/olympe.dm/datamodel/04_modules.newRel.json +1 -1
  11. package/import/olympe.dm/datamodel/05_permission_schema.newInst.json +1 -1
  12. package/import/olympe.dm/datamodel/05_permission_schema.newRel.json +1 -1
  13. package/import/olympe.dm/datamodel/05_permission_schema.updateInst.json +1 -1
  14. package/import/olympe.dm/datamodel/06_structure.newInst.json +1 -1
  15. package/import/olympe.dm/datamodel/06_structure.newRel.json +1 -1
  16. package/import/olympe.sc/datamodel/00_primordial.newInst.json +1 -1
  17. package/import/olympe.sc/datamodel/00_primordial.newRel.json +1 -1
  18. package/import/olympe.sc/datamodel/01_language.newInst.json +1 -1
  19. package/import/olympe.sc/datamodel/01_language.newRel.json +1 -1
  20. package/import/olympe.sc/datamodel/logic/01_functions.newInst.json +1 -1
  21. package/import/olympe.sc/datamodel/logic/01_functions.newRel.json +1 -1
  22. package/import/olympe.sc/datamodel/logic/02_actions.newInst.json +1 -1
  23. package/import/olympe.sc/datamodel/logic/02_actions.newRel.json +1 -1
  24. package/index.d.ts +212 -70
  25. package/index.js +678 -843
  26. package/package.json +4 -5
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  // @ts-ignore
2
- import {Observable} from "rxjs";
2
+ import { Observable } from "rxjs";
3
3
 
4
4
  /**
5
5
  * A client used to call remote services.
@@ -108,12 +108,12 @@ export abstract class Service {
108
108
  /**
109
109
  * A service that retrieves a value upon request.
110
110
  */
111
- export class GetService extends Service {}
111
+ export class GetService extends Service { }
112
112
 
113
113
  /**
114
114
  * A service that executes remote procedures.
115
115
  */
116
- export class CallService extends Service {}
116
+ export class CallService extends Service { }
117
117
 
118
118
  /**
119
119
  * A service that allows clients to subscribe to updates.
@@ -129,11 +129,20 @@ export class SubscribeService extends Service {
129
129
  notify(payload: Object): Promise<void>;
130
130
  }
131
131
 
132
+ /**
133
+ * List of general properties keys used by the runtime engine to set specific values on BrickContexts
134
+ */
135
+ export enum GlobalProperties {
136
+ TRANSACTION = '__transaction',
137
+ PRODUCTION = '__production',
138
+ EDITION = '__editionMode'
139
+ }
140
+
132
141
  /**
133
142
  * The context of a brick is the object that contains the brick state, controls the brick lifecycle and provides
134
143
  * an API to observe and set values of this brick's properties.
135
144
  */
136
- export class Context {
145
+ export class BrickContext {
137
146
 
138
147
  /**
139
148
  * Register a callback to execute when the context is destroyed. Return the callback id.
@@ -144,7 +153,7 @@ export class Context {
144
153
  onDestroy(callback: () => void): string;
145
154
 
146
155
  /**
147
- * Remove a previously registered callback with {@link Context#onDestroy} method using its id.
156
+ * Remove a previously registered callback with {@link BrickContext#onDestroy} method using its id.
148
157
  *
149
158
  * @param id the id of the callback to unregister
150
159
  */
@@ -161,7 +170,7 @@ export class Context {
161
170
  onClear(callback: () => void): string;
162
171
 
163
172
  /**
164
- * Remove a previously registered callback with {@link Context#onClear} method using its id.
173
+ * Remove a previously registered callback with {@link BrickContext#onClear} method using its id.
165
174
  *
166
175
  * @param id the id of the callback to unregister
167
176
  */
@@ -182,34 +191,92 @@ export class Context {
182
191
  /**
183
192
  * Set the specified property value and propagate the update to anyone observing it.
184
193
  *
185
- * @param property the property
194
+ * @param key the property or key string
186
195
  * @param value the new value to set
196
+ * @return this
197
+ */
198
+ set<T>(key: PropertyDescriptor<T> | string, value: any): this;
199
+
200
+ /**
201
+ * Trigger the specified event and propagate the update to anyone observing it.
202
+ *
203
+ * @param key the event or key event
204
+ * @return this
187
205
  */
188
- set<T>(property: PropertyDescriptor<T> | string, value: any);
206
+ trigger<T>(key: PropertyDescriptor<T> | string): this;
189
207
 
190
208
  /**
191
209
  * Clear the value of the specified property and propagate that event.
192
210
  *
193
- * @param property the property
211
+ * @param key the property or key string
194
212
  */
195
- remove<T>(property: PropertyDescriptor<T> | string);
213
+ remove<T>(key: PropertyDescriptor<T> | string);
196
214
 
197
215
  /**
198
216
  * Return the current value of the specified property. If there is currently no value, return null.
199
217
  *
200
- * @param property the property
218
+ * @param key the property or key string
219
+ * @param global [=false] whether or not the method checks parent contexts
201
220
  * @return the current value
202
221
  */
203
- get<T>(property: PropertyDescriptor<T> | string): T | null;
222
+ get<T>(key: PropertyDescriptor<T> | string, global?: boolean): T | null;
223
+
224
+ /**
225
+ * Returns a boolean indicating whether a property has a value or not.
226
+ *
227
+ * @param key the property or key string
228
+ * @param global [=false] whether or not the method checks parent contexts
229
+ * @return whether `property` has a value or not
230
+ */
231
+ has<T>(key: PropertyDescriptor<T> | string, global?: boolean): boolean;
204
232
 
205
233
  /**
206
234
  * Return an observable to subscribe to value updates of the specified property.
235
+ * If `waitForValue` is set to FALSE (TRUE by default), the first value received by the observable is null
236
+ * if there is no value at subscription time.
237
+ * If `global` is set to TRUE (FALSE by default), it observes values coming from other contexts accessible from the current one.
238
+ *
239
+ * @param key the property or key string
240
+ * @param waitForValue [=true] whether or not the observable wait for a first value to get a value.
241
+ * @param global [=false] whether or not listen to a value coming from other contexts.
242
+ * @return the observable
243
+ */
244
+ observe<T>(key: PropertyDescriptor<T> | string, waitForValue?: boolean, global?: boolean): Observable<T>;
245
+
246
+ /**
247
+ * Subscribe to the specified observable and set its values to the context with the provided key.
248
+ *
249
+ * @param key the key used to set the values coming from the observable
250
+ * @param observable the observable providing values
251
+ * @return this context
252
+ */
253
+ repeat<T>(key: PropertyDescriptor<T> | string, observable:Observable<T>): this;
254
+
255
+ /**
256
+ * Run a runnable property and returns its context.
257
+ *
258
+ * @param property the runnable property or the runnable itself
259
+ * @return the child context or null if the runner was not found
260
+ */
261
+ runner<T>(property: PropertyDescriptor<T> | string | Brick): BrickContext | null;
262
+
263
+ /**
264
+ * Wait for the property to get a new value, wrapped in a promise.
207
265
  *
208
266
  * @param property the property
209
267
  * @param nullable whether or not the observable accept null values (when a value is removed from the context). False by default.
210
- * @return an observable
268
+ * @param global [=false] whether or not the method checks parent contexts
269
+ * @return a promise of the next value of property
270
+ */
271
+ waitFor<T>(property: PropertyDescriptor<T> | string, nullable?: boolean, global?: boolean): Promise<T>;
272
+
273
+ /**
274
+ * Set the parent element for visual brick to be rendered.
275
+ *
276
+ * @param parent the parent container
277
+ * @return this
211
278
  */
212
- observe<T>(property: PropertyDescriptor<T> | string, nullable?: boolean): Observable<T>;
279
+ setParentElement(parent: Element): this;
213
280
 
214
281
  /**
215
282
  * Create and return a new context, child of the current one.
@@ -217,7 +284,7 @@ export class Context {
217
284
  *
218
285
  * @param debugName a name to give to the context for debugging purpose.
219
286
  */
220
- createChild(debugName?: string): Context;
287
+ createChild(debugName?: string): BrickContext;
221
288
 
222
289
  /**
223
290
  * Return the context with the specified id if accessible (in the hierarchy) from this context.
@@ -225,7 +292,7 @@ export class Context {
225
292
  *
226
293
  * @param id the context id we want to retrieve
227
294
  */
228
- getOtherContext(id: string): Context | null;
295
+ getOtherContext(id: string): BrickContext | null;
229
296
 
230
297
  /**
231
298
  * Listen to the creation of the context with the specified id.
@@ -235,12 +302,12 @@ export class Context {
235
302
  * @param id the context id, which corresponds to the tag of the brick to be retrieved.
236
303
  * @param callback the function to execute when the specified brick context is available
237
304
  */
238
- onContext(id: string, callback: (context: Context) => void): () => void;
305
+ onContext(id: string, callback: ($: BrickContext) => void): () => void;
239
306
 
240
307
  /**
241
308
  * Return the parent context if it exists.
242
309
  */
243
- getParent(): Context | null;
310
+ getParent(): BrickContext | null;
244
311
 
245
312
  /**
246
313
  * Return the closest transaction from this context :
@@ -285,14 +352,21 @@ export class Context {
285
352
  popTransaction(): Transaction | null;
286
353
  }
287
354
 
355
+ /**
356
+ * @deprecated use {@link BrickContext} instead
357
+ */
358
+ export class Context extends BrickContext { }
359
+
288
360
  /**
289
361
  * Context of UI bricks with methods to get and observe properties.
362
+ * @deprecated use {@link BrickContext} instead and override render method of VisualBrick.
290
363
  */
291
- export class UIContext extends Context {
364
+ export class UIContext extends BrickContext {
292
365
 
293
366
  /**
294
367
  * Return a Property to get, update and observe its value
295
368
  *
369
+ * @deprecated use {@link BrickContext#get} instead
296
370
  * @param name The property name
297
371
  */
298
372
  getProperty<T>(name: string): Property<T> | null;
@@ -300,6 +374,7 @@ export class UIContext extends Context {
300
374
  /**
301
375
  * Return an Event to trigger or observe
302
376
  *
377
+ * @deprecated use {@link BrickContext#trigger} instead
303
378
  * @param name The event name
304
379
  */
305
380
  getEvent(name: string): Event | null;
@@ -307,17 +382,10 @@ export class UIContext extends Context {
307
382
  /**
308
383
  * Observe multiple properties simultaneously.
309
384
  *
385
+ * @deprecated use {@link BrickContext#observe} with the RXJS operator combineLatestWith.
310
386
  * @param properties list of properties to observe simultaneously
311
387
  */
312
388
  observeMany(...properties: string[]): Observable<any[]>;
313
-
314
- /**
315
- * Create and return a new UIContext, child of the current one.
316
- * Mainly used to run other bricks within the current one (e.g.: a list renderer).
317
- *
318
- * @param debugName a name to give to the context for debugging purpose.
319
- */
320
- createChild(debugName?: string): UIContext;
321
389
  }
322
390
 
323
391
  /**
@@ -334,6 +402,8 @@ declare interface PropertyDescriptor<T> {
334
402
 
335
403
  /**
336
404
  * A property allows a brick or a data object to store and provide a value under a specific identifier.
405
+ *
406
+ * @deprecated
337
407
  */
338
408
  declare interface Property<T> extends PropertyDescriptor<T> {
339
409
 
@@ -359,6 +429,8 @@ declare interface Property<T> extends PropertyDescriptor<T> {
359
429
 
360
430
  /**
361
431
  * Special brick property type that can be triggered.
432
+ *
433
+ * @deprecated
362
434
  */
363
435
  declare interface Event extends Property<number> {
364
436
 
@@ -399,109 +471,166 @@ declare interface Entry {
399
471
  * - initialisation: called whenever the brick is instantiated by its parent executor.
400
472
  * - updates: called whenever all the inputs of a brick have a value (default behaviour). This behaviour can be modified by overriding `configCoreUpdate`.
401
473
  * - destruction: when the parent executor starts to destroy itself, the brick destroys itself too.
474
+ *
475
+ * A headless brick that executes its core code every time an input gets a value.
402
476
  */
403
- declare class Brick {
477
+ export class Brick {
478
+
404
479
  /**
405
480
  * Static reference to the entry of that brick.
406
481
  */
407
- public static readonly entry:Entry;
482
+ public static readonly entry: Entry;
483
+
484
+ /**
485
+ * Return the list of inputs tags as an ordered array.
486
+ */
487
+ readonly getInputs: () => string[];
488
+
489
+ /**
490
+ * Return the list of outputs tags as an ordered array
491
+ */
492
+ readonly getOutputs: () => string[];
408
493
 
409
494
  /**
410
495
  * Run the brick itself using the specified context.
411
496
  *
412
- * @param context the brick context
497
+ * @param $ the brick context
413
498
  */
414
- run(context: Context);
499
+ run($: BrickContext);
415
500
 
416
501
  /**
417
502
  * Setup the brick and its context to listen to pipes and updates for its inputs and properties.
418
503
  * Typically used as the first instruction of the {@link Brick#run run} method.
419
504
  *
420
- * @param context the brick context.
505
+ * @param $ the brick context.
421
506
  */
422
- protected setup(context: Context);
507
+ protected setup($: BrickContext);
423
508
 
424
509
  /**
425
510
  * Called when the brick starts its lifecycle and gets initialized.
426
511
  *
427
- * @param context the brick context
512
+ * @param $ the brick context
428
513
  */
429
- protected onInit(context: Context);
514
+ protected init($: BrickContext);
430
515
 
431
516
  /**
432
517
  * Called when the brick ends its lifecycle and gets destroyed.
433
518
  *
434
- * @param context the brick context
519
+ * @param $ the brick context
435
520
  */
436
- protected onDestroy(context: Context);
437
- }
521
+ protected destroy($: BrickContext);
438
522
 
439
- /**
440
- * A headless brick that executes its core code every time an input gets a value.
441
- */
442
- export class FunctionBrick extends Brick {
523
+ /**
524
+ * Called every time the context is cleared.
525
+ *
526
+ * @param $ the brick context
527
+ */
528
+ protected clear($: BrickContext);
443
529
 
444
530
  /**
445
531
  * Called whenever the conditions to update the brick are satisfied (as defined by method `configCoreUpdate`).
446
532
  * By default, a function updates whenever an input gets a new value, but only if all inputs have a value.
447
533
  *
448
- * @param context the brick context
534
+ * @param $ the brick context
449
535
  * @param inputs array of input values
450
536
  * @param outputs array of output setter functions. A setter updates a specific output value of the brick.
451
537
  */
452
- protected onUpdate(context: Context, inputs: Array<any>, outputs: Array<(value: any) => void>);
538
+ protected update($: BrickContext, inputs: Array<any>, outputs: Array<(value: any) => void>): void;
539
+
540
+ /**
541
+ * Observe the context to define when the brick `update` method should be called.
542
+ *
543
+ * @param $ the brick context
544
+ * @return an observable that emit a value anytime the brick `update` method should be called.
545
+ */
546
+ protected setupExecution($: BrickContext): Observable<Array<any>>;
453
547
 
454
548
  /**
455
549
  * Execute the `onUpdate` class method. The `clear` callback destroys the context of the previous update and invalidates previous inputs.
456
550
  * Override this method to change the function brick default behaviour.
457
551
  *
458
- * @param context the brick context
552
+ * @deprecated
553
+ * @param $ the brick context
459
554
  * @param runUpdate the function to call to update the brick
460
555
  * @param clear the function to clear previous run
461
556
  */
462
- protected setupUpdate(context: Context, runUpdate: (inputs: any[]) => void, clear: () => void);
557
+ protected setupUpdate($: BrickContext, runUpdate: (inputs: any[]) => void, clear: () => void);
463
558
 
464
559
  /**
465
- * Return the list of inputs tags as an ordered array.
560
+ * @deprecated use {@link BrickContext#init} instead
561
+ * @param $ the brick context
466
562
  */
467
- readonly getInputs: () => string[];
563
+ protected onInit($: BrickContext): void;
468
564
 
469
565
  /**
470
- * Return the list of outputs tags as an ordered array
566
+ * @deprecated use {@link BrickContext#init} instead
567
+ * @param $ the brick context
568
+ * @param inputs array of input values
569
+ * @param outputs array of output setter functions.
471
570
  */
472
- readonly getOutputs: () => string[];
571
+ protected onUpdate($: BrickContext, inputs: Array<any>, outputs: Array<(value: any) => void>): void;
572
+
573
+ /**
574
+ * @deprecated use {@link BrickContext#init} instead
575
+ * @param $ the brick context
576
+ */
577
+ protected onDestroy($: BrickContext): void;
473
578
  }
474
579
 
475
- /**
476
- * A headless brick whose update is triggered by an event (control flow). Unlike a `FunctionBrick`, an `ActionBrick` updates on each incoming event, even if an input still has no value.
477
- * An `ActionBrick` also provides a specific output to forward the control flow (event).
478
- */
479
- export class ActionBrick extends FunctionBrick {}
580
+ /**
581
+ * A headless brick whose update is triggered by an event (control flow). Unlike a `FunctionBrick`, an `ActionBrick` updates on each incoming event, even if an input still has no value.
582
+ * An `ActionBrick` also provides a specific output to forward the control flow (event).
583
+ */
584
+ export class ActionBrick extends Brick { }
480
585
 
481
586
  /**
482
587
  * A UI Brick aims to display something on the screen of a UI application.
483
588
  */
484
- export class UIBrick extends Brick {
589
+ export class VisualBrick extends Brick {
485
590
 
486
591
  /**
487
- * @override
592
+ * Return the list of properties tags as an ordered array
488
593
  */
489
- protected onInit(context: UIContext);
594
+ readonly getProperties: () => string[];
490
595
 
491
596
  /**
492
- * @override
597
+ * Render an element for the given `context`.
598
+ * Can return `null` if no element is rendered.
599
+ *
600
+ * @param $ the brick context
601
+ * @param properties property values that have been s
602
+ * @return the rendered element
603
+ */
604
+ protected render($: BrickContext, properties: any[]): Element | null;
605
+
606
+ /**
607
+ * Attach the `element` rendered by `render()` to its `parent` (in the DOM).
608
+ * Must return the function to clear the parent from that element.
609
+ * That function is called just before the next call to updateParent.
610
+ *
611
+ * If the `render()` method returns null, only the clear function of previous call to `updateParent()` will be called.
612
+ *
613
+ * @param parent the parent element
614
+ * @param element the element to attach
615
+ * @return the function to clear the element from its parent.
493
616
  */
494
- protected onDestroy(context: UIContext);
617
+ protected updateParent(parent: Element, element: Element): () => void;
495
618
 
496
619
  /**
497
620
  * Called when the DOM Element associated to that brick has been added to the document and is ready to be drawn.
498
621
  *
499
- * @param context the brick context
622
+ * @deprecated override {@link VisualBrick#render} and {@link VisualBrick#updateParent} instead.
623
+ * @param $ the brick context
500
624
  * @param domElement the associated DOM Element
501
625
  */
502
- draw(context: UIContext, domElement:Element);
626
+ protected draw($: BrickContext, domElement: Element);
503
627
  }
504
628
 
629
+ /**
630
+ * @deprecated use {@link VisualBrick} instead
631
+ */
632
+ export class UIBrick extends VisualBrick { }
633
+
505
634
  /**
506
635
  * Static function that must be called for every brick used in an application.
507
636
  * It registers the brick code in the registry with the specified tag and return the Entry for that brick.
@@ -561,15 +690,21 @@ export class Auth {
561
690
  static getToken(): string;
562
691
 
563
692
  /**
564
- * Return the SAML token (zipped & base64 encoded XML) for the current user.
693
+ * Return the IDP token (zipped & base64 encoded XML) for the current user.
565
694
  */
566
- static getSAMLToken(): string;
695
+ static getIDPToken(): string;
567
696
 
568
697
  /**
569
698
  * Return the tag of the current authenticated user.
570
699
  */
571
700
  static getCurrentUser(): string
572
701
 
702
+ /**
703
+ * Returns an Observable that is updated each time the user tag changes.
704
+ * @param {Context} context The brick context
705
+ */
706
+ static observeUser(context: Context): Observable<string>
707
+
573
708
  /**
574
709
  * Retrieve the user tag associated to the specified token
575
710
  *
@@ -586,6 +721,7 @@ export class Auth {
586
721
  * Try to login using SRP protocol with the specified username and password.
587
722
  * Returns a promise resolved when logged in or that catches an error if refused.
588
723
  *
724
+ * @throws {Error} If the provider's configuration is incorrect.
589
725
  * @param username the username
590
726
  * @param password the password
591
727
  */
@@ -595,10 +731,9 @@ export class Auth {
595
731
  * Try to login using SAML protocol with the specified username and password.
596
732
  * Returns a promise resolved when logged in or that catches an error if refused.
597
733
  *
598
- * @param username the username
599
- * @param password the password
734
+ * @throws {Error} If the provider's configuration is incorrect.
600
735
  */
601
- static loginSAML(username: string, password: string): Promise<void>;
736
+ static loginSAML(): Promise<void>;
602
737
 
603
738
  /**
604
739
  * Try to login using the specified token for the user.
@@ -609,6 +744,13 @@ export class Auth {
609
744
  */
610
745
  static loginToken(username: string, token: string): Promise<void>;
611
746
 
747
+ /**
748
+ * Try to login using the configured OpenID Provider.
749
+ * Returns a promise resolved when logged in or that catches an error if the login is not valid.
750
+ * @throws {Error} If the provider's configuration is incorrect.
751
+ */
752
+ static loginOpenID(): Promise<void>;
753
+
612
754
  /**
613
755
  * Log out the current user and invalidate its session token.
614
756
  * It returns a promise resolved when the operation is done.
@@ -831,7 +973,7 @@ export enum FollowRule {
831
973
  /* *************************
832
974
  Transformers
833
975
  ************************* */
834
- declare abstract class Transformer {}
976
+ declare abstract class Transformer { }
835
977
 
836
978
  export namespace transformers {
837
979
  /** @deprecated */
@@ -936,7 +1078,7 @@ export namespace predicates {
936
1078
  /* *************************
937
1079
  ValueDefs
938
1080
  ************************* */
939
- declare abstract class ValueDef {}
1081
+ declare abstract class ValueDef { }
940
1082
 
941
1083
  /** @deprecated */
942
1084
  export namespace valuedefs {
@@ -996,7 +1138,7 @@ export namespace comparators {
996
1138
  }
997
1139
  }
998
1140
 
999
- interface Operation {}
1141
+ interface Operation { }
1000
1142
 
1001
1143
  export class BurstTransaction {
1002
1144
  constructor();