@olympeio/runtime-node 8.6.1 → 8.7.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 (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 +205 -70
  25. package/index.js +668 -844
  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,91 @@ 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
201
219
  * @return the current value
202
220
  */
203
- get<T>(property: PropertyDescriptor<T> | string): T | null;
221
+ get<T>(key: PropertyDescriptor<T> | string): T | null;
222
+
223
+ /**
224
+ * Returns a boolean indicating whether a property has a value or not.
225
+ *
226
+ * @param key the property or key string
227
+ * @param global [=false] whether or not the method checks parent contexts
228
+ * @return whether `property` has a value or not
229
+ */
230
+ has<T>(key: PropertyDescriptor<T> | string, global?: boolean): boolean;
204
231
 
205
232
  /**
206
233
  * Return an observable to subscribe to value updates of the specified property.
234
+ * If `waitForValue` is set to FALSE (TRUE by default), the first value received by the observable is null
235
+ * if there is no value at subscription time.
236
+ * If `global` is set to TRUE (FALSE by default), it observes values coming from other contexts accessible from the current one.
237
+ *
238
+ * @param key the property or key string
239
+ * @param waitForValue [=true] whether or not the observable wait for a first value to get a value.
240
+ * @param global [=false] whether or not listen to a value coming from other contexts.
241
+ * @return the observable
242
+ */
243
+ observe<T>(key: PropertyDescriptor<T> | string, waitForValue?: boolean, global?: boolean): Observable<T>;
244
+
245
+ /**
246
+ * Subscribe to the specified observable and set its values to the context with the provided key.
247
+ *
248
+ * @param key the key used to set the values coming from the observable
249
+ * @param observable the observable providing values
250
+ * @return this context
251
+ */
252
+ repeat<T>(key: PropertyDescriptor<T> | string, observable:Observable<T>): this;
253
+
254
+ /**
255
+ * Run a runnable property and returns its context.
256
+ *
257
+ * @param property the runnable property or the runnable itself
258
+ * @return the child context or null if the runner was not found
259
+ */
260
+ runner<T>(property: PropertyDescriptor<T> | string | Brick): BrickContext | null;
261
+
262
+ /**
263
+ * Wait for the property to get a new value, wrapped in a promise.
207
264
  *
208
265
  * @param property the property
209
266
  * @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
267
+ * @param global [=false] whether or not the method checks parent contexts
268
+ * @return a promise of the next value of property
211
269
  */
212
- observe<T>(property: PropertyDescriptor<T> | string, nullable?: boolean): Observable<T>;
270
+ waitFor<T>(property: PropertyDescriptor<T> | string, nullable?: boolean, global?: boolean): Promise<T>;
271
+
272
+ /**
273
+ * Set the parent element for visual brick to be rendered.
274
+ *
275
+ * @param parent the parent container
276
+ * @return this
277
+ */
278
+ setParentElement(parent: Element): this;
213
279
 
214
280
  /**
215
281
  * Create and return a new context, child of the current one.
@@ -217,7 +283,7 @@ export class Context {
217
283
  *
218
284
  * @param debugName a name to give to the context for debugging purpose.
219
285
  */
220
- createChild(debugName?: string): Context;
286
+ createChild(debugName?: string): BrickContext;
221
287
 
222
288
  /**
223
289
  * Return the context with the specified id if accessible (in the hierarchy) from this context.
@@ -225,7 +291,7 @@ export class Context {
225
291
  *
226
292
  * @param id the context id we want to retrieve
227
293
  */
228
- getOtherContext(id: string): Context | null;
294
+ getOtherContext(id: string): BrickContext | null;
229
295
 
230
296
  /**
231
297
  * Listen to the creation of the context with the specified id.
@@ -235,12 +301,12 @@ export class Context {
235
301
  * @param id the context id, which corresponds to the tag of the brick to be retrieved.
236
302
  * @param callback the function to execute when the specified brick context is available
237
303
  */
238
- onContext(id: string, callback: (context: Context) => void): () => void;
304
+ onContext(id: string, callback: ($: BrickContext) => void): () => void;
239
305
 
240
306
  /**
241
307
  * Return the parent context if it exists.
242
308
  */
243
- getParent(): Context | null;
309
+ getParent(): BrickContext | null;
244
310
 
245
311
  /**
246
312
  * Return the closest transaction from this context :
@@ -285,14 +351,21 @@ export class Context {
285
351
  popTransaction(): Transaction | null;
286
352
  }
287
353
 
354
+ /**
355
+ * @deprecated use {@link BrickContext} instead
356
+ */
357
+ export class Context extends BrickContext { }
358
+
288
359
  /**
289
360
  * Context of UI bricks with methods to get and observe properties.
361
+ * @deprecated use {@link BrickContext} instead and override render method of VisualBrick.
290
362
  */
291
- export class UIContext extends Context {
363
+ export class UIContext extends BrickContext {
292
364
 
293
365
  /**
294
366
  * Return a Property to get, update and observe its value
295
367
  *
368
+ * @deprecated use {@link BrickContext#get} instead
296
369
  * @param name The property name
297
370
  */
298
371
  getProperty<T>(name: string): Property<T> | null;
@@ -300,6 +373,7 @@ export class UIContext extends Context {
300
373
  /**
301
374
  * Return an Event to trigger or observe
302
375
  *
376
+ * @deprecated use {@link BrickContext#trigger} instead
303
377
  * @param name The event name
304
378
  */
305
379
  getEvent(name: string): Event | null;
@@ -307,17 +381,10 @@ export class UIContext extends Context {
307
381
  /**
308
382
  * Observe multiple properties simultaneously.
309
383
  *
384
+ * @deprecated use {@link BrickContext#observe} with the RXJS operator combineLatestWith.
310
385
  * @param properties list of properties to observe simultaneously
311
386
  */
312
387
  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
388
  }
322
389
 
323
390
  /**
@@ -334,6 +401,8 @@ declare interface PropertyDescriptor<T> {
334
401
 
335
402
  /**
336
403
  * A property allows a brick or a data object to store and provide a value under a specific identifier.
404
+ *
405
+ * @deprecated
337
406
  */
338
407
  declare interface Property<T> extends PropertyDescriptor<T> {
339
408
 
@@ -359,6 +428,8 @@ declare interface Property<T> extends PropertyDescriptor<T> {
359
428
 
360
429
  /**
361
430
  * Special brick property type that can be triggered.
431
+ *
432
+ * @deprecated
362
433
  */
363
434
  declare interface Event extends Property<number> {
364
435
 
@@ -399,109 +470,166 @@ declare interface Entry {
399
470
  * - initialisation: called whenever the brick is instantiated by its parent executor.
400
471
  * - updates: called whenever all the inputs of a brick have a value (default behaviour). This behaviour can be modified by overriding `configCoreUpdate`.
401
472
  * - destruction: when the parent executor starts to destroy itself, the brick destroys itself too.
473
+ *
474
+ * A headless brick that executes its core code every time an input gets a value.
402
475
  */
403
- declare class Brick {
476
+ export class Brick {
477
+
404
478
  /**
405
479
  * Static reference to the entry of that brick.
406
480
  */
407
- public static readonly entry:Entry;
481
+ public static readonly entry: Entry;
482
+
483
+ /**
484
+ * Return the list of inputs tags as an ordered array.
485
+ */
486
+ readonly getInputs: () => string[];
487
+
488
+ /**
489
+ * Return the list of outputs tags as an ordered array
490
+ */
491
+ readonly getOutputs: () => string[];
408
492
 
409
493
  /**
410
494
  * Run the brick itself using the specified context.
411
495
  *
412
- * @param context the brick context
496
+ * @param $ the brick context
413
497
  */
414
- run(context: Context);
498
+ run($: BrickContext);
415
499
 
416
500
  /**
417
501
  * Setup the brick and its context to listen to pipes and updates for its inputs and properties.
418
502
  * Typically used as the first instruction of the {@link Brick#run run} method.
419
503
  *
420
- * @param context the brick context.
504
+ * @param $ the brick context.
421
505
  */
422
- protected setup(context: Context);
506
+ protected setup($: BrickContext);
423
507
 
424
508
  /**
425
509
  * Called when the brick starts its lifecycle and gets initialized.
426
510
  *
427
- * @param context the brick context
511
+ * @param $ the brick context
428
512
  */
429
- protected onInit(context: Context);
513
+ protected init($: BrickContext);
430
514
 
431
515
  /**
432
516
  * Called when the brick ends its lifecycle and gets destroyed.
433
517
  *
434
- * @param context the brick context
518
+ * @param $ the brick context
435
519
  */
436
- protected onDestroy(context: Context);
437
- }
520
+ protected destroy($: BrickContext);
438
521
 
439
- /**
440
- * A headless brick that executes its core code every time an input gets a value.
441
- */
442
- export class FunctionBrick extends Brick {
522
+ /**
523
+ * Called every time the context is cleared.
524
+ *
525
+ * @param $ the brick context
526
+ */
527
+ protected clear($: BrickContext);
443
528
 
444
529
  /**
445
530
  * Called whenever the conditions to update the brick are satisfied (as defined by method `configCoreUpdate`).
446
531
  * By default, a function updates whenever an input gets a new value, but only if all inputs have a value.
447
532
  *
448
- * @param context the brick context
533
+ * @param $ the brick context
449
534
  * @param inputs array of input values
450
535
  * @param outputs array of output setter functions. A setter updates a specific output value of the brick.
451
536
  */
452
- protected onUpdate(context: Context, inputs: Array<any>, outputs: Array<(value: any) => void>);
537
+ protected update($: BrickContext, inputs: Array<any>, outputs: Array<(value: any) => void>): void;
538
+
539
+ /**
540
+ * Observe the context to define when the brick `update` method should be called.
541
+ *
542
+ * @param $ the brick context
543
+ * @return an observable that emit a value anytime the brick `update` method should be called.
544
+ */
545
+ protected setupExecution($: BrickContext): Observable<Array<any>>;
453
546
 
454
547
  /**
455
548
  * Execute the `onUpdate` class method. The `clear` callback destroys the context of the previous update and invalidates previous inputs.
456
549
  * Override this method to change the function brick default behaviour.
457
550
  *
458
- * @param context the brick context
551
+ * @deprecated
552
+ * @param $ the brick context
459
553
  * @param runUpdate the function to call to update the brick
460
554
  * @param clear the function to clear previous run
461
555
  */
462
- protected setupUpdate(context: Context, runUpdate: (inputs: any[]) => void, clear: () => void);
556
+ protected setupUpdate($: BrickContext, runUpdate: (inputs: any[]) => void, clear: () => void);
463
557
 
464
558
  /**
465
- * Return the list of inputs tags as an ordered array.
559
+ * @deprecated use {@link BrickContext#init} instead
560
+ * @param $ the brick context
466
561
  */
467
- readonly getInputs: () => string[];
562
+ protected onInit($: BrickContext): void;
468
563
 
469
564
  /**
470
- * Return the list of outputs tags as an ordered array
565
+ * @deprecated use {@link BrickContext#init} instead
566
+ * @param $ the brick context
567
+ * @param inputs array of input values
568
+ * @param outputs array of output setter functions.
471
569
  */
472
- readonly getOutputs: () => string[];
570
+ protected onUpdate($: BrickContext, inputs: Array<any>, outputs: Array<(value: any) => void>): void;
571
+
572
+ /**
573
+ * @deprecated use {@link BrickContext#init} instead
574
+ * @param $ the brick context
575
+ */
576
+ protected onDestroy($: BrickContext): void;
473
577
  }
474
578
 
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 {}
579
+ /**
580
+ * 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.
581
+ * An `ActionBrick` also provides a specific output to forward the control flow (event).
582
+ */
583
+ export class ActionBrick extends Brick { }
480
584
 
481
585
  /**
482
586
  * A UI Brick aims to display something on the screen of a UI application.
483
587
  */
484
- export class UIBrick extends Brick {
588
+ export class VisualBrick extends Brick {
589
+
590
+ /**
591
+ * Return the list of properties tags as an ordered array
592
+ */
593
+ readonly getProperties: () => string[];
485
594
 
486
595
  /**
487
- * @override
596
+ * Render an element for the given `context`.
597
+ * Can return `null` if no element is rendered.
598
+ *
599
+ * @param $ the brick context
600
+ * @param properties property values that have been s
601
+ * @return the rendered element
488
602
  */
489
- protected onInit(context: UIContext);
603
+ protected render($: BrickContext, properties: any[]): Element | null;
490
604
 
491
605
  /**
492
- * @override
606
+ * Attach the `element` rendered by `render()` to its `parent` (in the DOM).
607
+ * Must return the function to clear the parent from that element.
608
+ * That function is called just before the next call to updateParent.
609
+ *
610
+ * If the `render()` method returns null, only the clear function of previous call to `updateParent()` will be called.
611
+ *
612
+ * @param parent the parent element
613
+ * @param element the element to attach
614
+ * @return the function to clear the element from its parent.
493
615
  */
494
- protected onDestroy(context: UIContext);
616
+ protected updateParent(parent: Element, element: Element): () => void;
495
617
 
496
618
  /**
497
619
  * Called when the DOM Element associated to that brick has been added to the document and is ready to be drawn.
498
620
  *
499
- * @param context the brick context
621
+ * @deprecated override {@link VisualBrick#render} and {@link VisualBrick#updateParent} instead.
622
+ * @param $ the brick context
500
623
  * @param domElement the associated DOM Element
501
624
  */
502
- draw(context: UIContext, domElement:Element);
625
+ protected draw($: BrickContext, domElement: Element);
503
626
  }
504
627
 
628
+ /**
629
+ * @deprecated use {@link VisualBrick} instead
630
+ */
631
+ export class UIBrick extends VisualBrick { }
632
+
505
633
  /**
506
634
  * Static function that must be called for every brick used in an application.
507
635
  * It registers the brick code in the registry with the specified tag and return the Entry for that brick.
@@ -561,9 +689,9 @@ export class Auth {
561
689
  static getToken(): string;
562
690
 
563
691
  /**
564
- * Return the SAML token (zipped & base64 encoded XML) for the current user.
692
+ * Return the IDP token (zipped & base64 encoded XML) for the current user.
565
693
  */
566
- static getSAMLToken(): string;
694
+ static getIDPToken(): string;
567
695
 
568
696
  /**
569
697
  * Return the tag of the current authenticated user.
@@ -586,6 +714,7 @@ export class Auth {
586
714
  * Try to login using SRP protocol with the specified username and password.
587
715
  * Returns a promise resolved when logged in or that catches an error if refused.
588
716
  *
717
+ * @throws {Error} If the provider's configuration is incorrect.
589
718
  * @param username the username
590
719
  * @param password the password
591
720
  */
@@ -595,10 +724,9 @@ export class Auth {
595
724
  * Try to login using SAML protocol with the specified username and password.
596
725
  * Returns a promise resolved when logged in or that catches an error if refused.
597
726
  *
598
- * @param username the username
599
- * @param password the password
727
+ * @throws {Error} If the provider's configuration is incorrect.
600
728
  */
601
- static loginSAML(username: string, password: string): Promise<void>;
729
+ static loginSAML(): Promise<void>;
602
730
 
603
731
  /**
604
732
  * Try to login using the specified token for the user.
@@ -609,6 +737,13 @@ export class Auth {
609
737
  */
610
738
  static loginToken(username: string, token: string): Promise<void>;
611
739
 
740
+ /**
741
+ * Try to login using the configured OpenID Provider.
742
+ * Returns a promise resolved when logged in or that catches an error if the login is not valid.
743
+ * @throws {Error} If the provider's configuration is incorrect.
744
+ */
745
+ static loginOpenID(): Promise<void>;
746
+
612
747
  /**
613
748
  * Log out the current user and invalidate its session token.
614
749
  * It returns a promise resolved when the operation is done.
@@ -831,7 +966,7 @@ export enum FollowRule {
831
966
  /* *************************
832
967
  Transformers
833
968
  ************************* */
834
- declare abstract class Transformer {}
969
+ declare abstract class Transformer { }
835
970
 
836
971
  export namespace transformers {
837
972
  /** @deprecated */
@@ -936,7 +1071,7 @@ export namespace predicates {
936
1071
  /* *************************
937
1072
  ValueDefs
938
1073
  ************************* */
939
- declare abstract class ValueDef {}
1074
+ declare abstract class ValueDef { }
940
1075
 
941
1076
  /** @deprecated */
942
1077
  export namespace valuedefs {
@@ -996,7 +1131,7 @@ export namespace comparators {
996
1131
  }
997
1132
  }
998
1133
 
999
- interface Operation {}
1134
+ interface Operation { }
1000
1135
 
1001
1136
  export class BurstTransaction {
1002
1137
  constructor();