@olympeio/runtime-node 8.7.2 → 9.0.2

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/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/02_bricks.newInst.json +1 -0
  21. package/import/olympe.sc/datamodel/02_bricks.newRel.json +1 -0
  22. package/index.js +792 -679
  23. package/package.json +7 -3
  24. package/types/base.d.ts +117 -0
  25. package/types/cloud.d.ts +303 -0
  26. package/types/index.d.ts +5 -0
  27. package/types/legacy.d.ts +284 -0
  28. package/types/runtime.d.ts +281 -0
  29. package/types/utils.d.ts +290 -0
  30. package/import/olympe.sc/datamodel/logic/01_functions.newInst.json +0 -1
  31. package/import/olympe.sc/datamodel/logic/01_functions.newRel.json +0 -1
  32. package/import/olympe.sc/datamodel/logic/02_actions.newInst.json +0 -1
  33. package/import/olympe.sc/datamodel/logic/02_actions.newRel.json +0 -1
  34. package/index.d.ts +0 -1181
package/index.d.ts DELETED
@@ -1,1181 +0,0 @@
1
- // @ts-ignore
2
- import { Observable } from "rxjs";
3
-
4
- /**
5
- * A client used to call remote services.
6
- */
7
- export class ServiceClient {
8
-
9
- /**
10
- * Send a request to a {@link CallService}.
11
- *
12
- * @param serviceId the service id
13
- * @param payload the message payload, optional
14
- * @return a Promise that completes when the call has been executed
15
- */
16
- static call(serviceId: string, payload?: Object): Promise<void>;
17
-
18
- /**
19
- * Get a value from a {@link GetService}.
20
- *
21
- * @param serviceId the service id
22
- * @param payload the message payload
23
- * @return a Promise wrapping the resulting value
24
- */
25
- static get(serviceId: string, payload: Object): Promise<Object>;
26
-
27
- /**
28
- * Observe values emitted by a {@link SubscribeService}.
29
- *
30
- * @param serviceId the service id
31
- * @param payload the message payload, optional
32
- * @return an Observable emitting values
33
- */
34
- static observe(serviceId: string, payload?: Object): Observable<Object>;
35
- }
36
-
37
- /**
38
- * A message consumed by a service.
39
- */
40
- export class ServiceMessage {
41
-
42
- /**
43
- * Get the requesting client's user tag.
44
- *
45
- * @return the user tag
46
- */
47
- userTag(): Promise<string>;
48
-
49
- /**
50
- * Get the request body.
51
- *
52
- * @return the request body
53
- */
54
- body(): Object;
55
-
56
- /**
57
- * Send an ack as response.
58
- *
59
- * @return a Promise that completes once the ack is sent
60
- */
61
- ack(): Promise<void>;
62
-
63
- /**
64
- * Send a reply message.
65
- *
66
- * @param payload the payload of the reply
67
- * @return a Promise that completes once the reply is sent
68
- */
69
- reply(payload: Object): Promise<void>;
70
-
71
- /**
72
- * Send an error message.
73
- *
74
- * @param error the error to send
75
- * @return a Promise that completes once the error is sent
76
- */
77
- fail(error: Error): Promise<void>;
78
- }
79
-
80
- /**
81
- * A service that processes requests.
82
- */
83
- export abstract class Service {
84
-
85
- /**
86
- * Create a new instance of the service.
87
- *
88
- * @param serviceId the service id
89
- */
90
- constructor(serviceId: string);
91
-
92
- /**
93
- * Start the service.
94
- */
95
- start(): Promise<void>;
96
-
97
- /**
98
- * Listen to incoming requests.
99
- */
100
- listen(): Observable<ServiceMessage>;
101
-
102
- /**
103
- * Stop the service.
104
- */
105
- stop(): Promise<void>;
106
- }
107
-
108
- /**
109
- * A service that retrieves a value upon request.
110
- */
111
- export class GetService extends Service { }
112
-
113
- /**
114
- * A service that executes remote procedures.
115
- */
116
- export class CallService extends Service { }
117
-
118
- /**
119
- * A service that allows clients to subscribe to updates.
120
- */
121
- export class SubscribeService extends Service {
122
-
123
- /**
124
- * Send a new notification to subscribers.
125
- *
126
- * @param payload the payload of the notification
127
- * @return a Promise that completes once the notification is sent
128
- */
129
- notify(payload: Object): Promise<void>;
130
- }
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
-
141
- /**
142
- * The context of a brick is the object that contains the brick state, controls the brick lifecycle and provides
143
- * an API to observe and set values of this brick's properties.
144
- */
145
- export class BrickContext {
146
-
147
- /**
148
- * Register a callback to execute when the context is destroyed. Return the callback id.
149
- *
150
- * @param callback the callback function
151
- * @return the callback id
152
- */
153
- onDestroy(callback: () => void): string;
154
-
155
- /**
156
- * Remove a previously registered callback with {@link BrickContext#onDestroy} method using its id.
157
- *
158
- * @param id the id of the callback to unregister
159
- */
160
- offDestroy(id: string): void;
161
-
162
- /**
163
- * Register a callback to execute every time the context is cleared.
164
- * This happens every time the brick is refreshed with new inputs and during the brick destruction.
165
- * Return the callback id.
166
- *
167
- * @param callback the callback function
168
- * @return the callback id
169
- */
170
- onClear(callback: () => void): string;
171
-
172
- /**
173
- * Remove a previously registered callback with {@link BrickContext#onClear} method using its id.
174
- *
175
- * @param id the id of the callback to unregister
176
- */
177
- offClear(id: string): void;
178
-
179
- /**
180
- * Destroy the current context. It destroys all children context attached to this one and clear their values.
181
- * The context cannot be reused after calling this function.
182
- */
183
- destroy(): void;
184
-
185
- /**
186
- * Clear the current context: detach and destroys all children context.
187
- * The context can be reused.
188
- */
189
- clear(): void;
190
-
191
- /**
192
- * Set the specified property value and propagate the update to anyone observing it.
193
- *
194
- * @param key the property or key string
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
205
- */
206
- trigger<T>(key: PropertyDescriptor<T> | string): this;
207
-
208
- /**
209
- * Clear the value of the specified property and propagate that event.
210
- *
211
- * @param key the property or key string
212
- */
213
- remove<T>(key: PropertyDescriptor<T> | string);
214
-
215
- /**
216
- * Return the current value of the specified property. If there is currently no value, return null.
217
- *
218
- * @param key the property or key string
219
- * @param global [=false] whether or not the method checks parent contexts
220
- * @return the current value
221
- */
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;
232
-
233
- /**
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.
265
- *
266
- * @param property the property
267
- * @param nullable whether or not the observable accept null values (when a value is removed from the context). False by default.
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
278
- */
279
- setParentElement(parent: Element): this;
280
-
281
- /**
282
- * Create and return a new context, child of the current one.
283
- * Mainly used to run other bricks within the current one (e.g.: the iterator of the brick For Each).
284
- *
285
- * @param debugName a name to give to the context for debugging purpose.
286
- */
287
- createChild(debugName?: string): BrickContext;
288
-
289
- /**
290
- * Return the context with the specified id if accessible (in the hierarchy) from this context.
291
- * Otherwise, return null.
292
- *
293
- * @param id the context id we want to retrieve
294
- */
295
- getOtherContext(id: string): BrickContext | null;
296
-
297
- /**
298
- * Listen to the creation of the context with the specified id.
299
- * Executes the callback when that context becomes accessible by this current context.
300
- * Return a function to unregister the listener.
301
- *
302
- * @param id the context id, which corresponds to the tag of the brick to be retrieved.
303
- * @param callback the function to execute when the specified brick context is available
304
- */
305
- onContext(id: string, callback: ($: BrickContext) => void): () => void;
306
-
307
- /**
308
- * Return the parent context if it exists.
309
- */
310
- getParent(): BrickContext | null;
311
-
312
- /**
313
- * Return the closest transaction from this context :
314
- * - look in its own transaction stack
315
- * - look in the transaction stack of its parents, recursively
316
- * - creates a new isolated transaction if no one is found.
317
- *
318
- * @return the transaction
319
- */
320
- getTransaction(): Transaction;
321
-
322
- /**
323
- * Get the last transaction from the stack of this context and releases it :
324
- * - if the transaction is isolated, then executes it
325
- * - otherwise, directly call the callback.
326
- *
327
- * The callback is called with 3 parameters:
328
- * - whether the transaction has been executed or not (boolean)
329
- * - whether the transaction succeed (always true if not executed) (boolean)
330
- * - when the transaction failed, the associated error message (string), null otherwise.
331
- *
332
- * @param callback the callback function
333
- */
334
- releaseTransaction(callback: (executed: boolean, success: boolean, errMsg?: string) => void);
335
-
336
- /**
337
- * Push the specified transaction on the transaction stack of this context.
338
- * This is essentially used for:
339
- * - Aggregate multiple operations on the same transaction with the [Begin]--[End] bricks from DRAW.
340
- * - Push a transaction from a hardcoded brick in CODE and aggregate operations on it from softcoded functions.
341
- *
342
- * @param transaction the transaction to push on the stack
343
- */
344
- pushTransaction(transaction: Transaction);
345
-
346
- /**
347
- * Remove and return the last added transaction from this context stack.
348
- * If there is no transaction on the stack, return null.
349
- *
350
- * @return the transaction if exists
351
- */
352
- popTransaction(): Transaction | null;
353
- }
354
-
355
- /**
356
- * @deprecated use {@link BrickContext} instead
357
- */
358
- export class Context extends BrickContext { }
359
-
360
- /**
361
- * Context of UI bricks with methods to get and observe properties.
362
- * @deprecated use {@link BrickContext} instead and override render method of VisualBrick.
363
- */
364
- export class UIContext extends BrickContext {
365
-
366
- /**
367
- * Return a Property to get, update and observe its value
368
- *
369
- * @deprecated use {@link BrickContext#get} instead
370
- * @param name The property name
371
- */
372
- getProperty<T>(name: string): Property<T> | null;
373
-
374
- /**
375
- * Return an Event to trigger or observe
376
- *
377
- * @deprecated use {@link BrickContext#trigger} instead
378
- * @param name The event name
379
- */
380
- getEvent(name: string): Event | null;
381
-
382
- /**
383
- * Observe multiple properties simultaneously.
384
- *
385
- * @deprecated use {@link BrickContext#observe} with the RXJS operator combineLatestWith.
386
- * @param properties list of properties to observe simultaneously
387
- */
388
- observeMany(...properties: string[]): Observable<any[]>;
389
- }
390
-
391
- /**
392
- * A property descriptor is an object that refers to the definition of a property
393
- */
394
- declare interface PropertyDescriptor<T> {
395
- /**
396
- * Get the property tag
397
- *
398
- * @return property tag
399
- */
400
- getTag(): string;
401
- }
402
-
403
- /**
404
- * A property allows a brick or a data object to store and provide a value under a specific identifier.
405
- *
406
- * @deprecated
407
- */
408
- declare interface Property<T> extends PropertyDescriptor<T> {
409
-
410
- /**
411
- * Get the property current value
412
- * @return property value
413
- */
414
- get(): T | null;
415
-
416
- /**
417
- * Get a RxJS observable to subscribe to changes of the property value.
418
- * @return observable on the property value
419
- */
420
- observe(): Observable<T>;
421
-
422
- /**
423
- * Update the property value.
424
- *
425
- * @param value the property value
426
- */
427
- set(value: T);
428
- }
429
-
430
- /**
431
- * Special brick property type that can be triggered.
432
- *
433
- * @deprecated
434
- */
435
- declare interface Event extends Property<number> {
436
-
437
- /**
438
- * Trigger the event.
439
- */
440
- trigger();
441
- }
442
-
443
- /**
444
- * The entry of a brick is a static object linked to the brick class itself that is used to make the link between the
445
- * code and the database. It stores tags linked to a specific brick :
446
- * - tag of the brick itself
447
- * - tags of properties that can be used as constants.
448
- */
449
- declare interface Entry {
450
-
451
- /**
452
- * Register a property on the brick with the specified tag.
453
- *
454
- * @param tag
455
- * @return the property descriptor
456
- */
457
- addProperty<T>(tag: string): PropertyDescriptor<T>;
458
-
459
- /**
460
- * Register a new relation type with the specified tag and direction
461
- *
462
- * @param tag
463
- * @param direction
464
- */
465
- addRelation(tag: string, direction: Direction): transformers.Related<any, any>;
466
- }
467
-
468
- /**
469
- * A brick is a modular piece of software. Bricks can be combined with each other to build a program.
470
- * Its lifecycle has 3 phases:
471
- * - initialisation: called whenever the brick is instantiated by its parent executor.
472
- * - updates: called whenever all the inputs of a brick have a value (default behaviour). This behaviour can be modified by overriding `configCoreUpdate`.
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.
476
- */
477
- export class Brick {
478
-
479
- /**
480
- * Static reference to the entry of that brick.
481
- */
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[];
493
-
494
- /**
495
- * Run the brick itself using the specified context.
496
- *
497
- * @param $ the brick context
498
- */
499
- run($: BrickContext);
500
-
501
- /**
502
- * Setup the brick and its context to listen to pipes and updates for its inputs and properties.
503
- * Typically used as the first instruction of the {@link Brick#run run} method.
504
- *
505
- * @param $ the brick context.
506
- */
507
- protected setup($: BrickContext);
508
-
509
- /**
510
- * Called when the brick starts its lifecycle and gets initialized.
511
- *
512
- * @param $ the brick context
513
- */
514
- protected init($: BrickContext);
515
-
516
- /**
517
- * Called when the brick ends its lifecycle and gets destroyed.
518
- *
519
- * @param $ the brick context
520
- */
521
- protected destroy($: BrickContext);
522
-
523
- /**
524
- * Called every time the context is cleared.
525
- *
526
- * @param $ the brick context
527
- */
528
- protected clear($: BrickContext);
529
-
530
- /**
531
- * Called whenever the conditions to update the brick are satisfied (as defined by method `configCoreUpdate`).
532
- * By default, a function updates whenever an input gets a new value, but only if all inputs have a value.
533
- *
534
- * @param $ the brick context
535
- * @param inputs array of input values
536
- * @param outputs array of output setter functions. A setter updates a specific output value of the brick.
537
- */
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>>;
547
-
548
- /**
549
- * Execute the `onUpdate` class method. The `clear` callback destroys the context of the previous update and invalidates previous inputs.
550
- * Override this method to change the function brick default behaviour.
551
- *
552
- * @deprecated
553
- * @param $ the brick context
554
- * @param runUpdate the function to call to update the brick
555
- * @param clear the function to clear previous run
556
- */
557
- protected setupUpdate($: BrickContext, runUpdate: (inputs: any[]) => void, clear: () => void);
558
-
559
- /**
560
- * @deprecated use {@link BrickContext#init} instead
561
- * @param $ the brick context
562
- */
563
- protected onInit($: BrickContext): void;
564
-
565
- /**
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.
570
- */
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;
578
- }
579
-
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 { }
585
-
586
- /**
587
- * A UI Brick aims to display something on the screen of a UI application.
588
- */
589
- export class VisualBrick extends Brick {
590
-
591
- /**
592
- * Return the list of properties tags as an ordered array
593
- */
594
- readonly getProperties: () => string[];
595
-
596
- /**
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.
616
- */
617
- protected updateParent(parent: Element, element: Element): () => void;
618
-
619
- /**
620
- * Called when the DOM Element associated to that brick has been added to the document and is ready to be drawn.
621
- *
622
- * @deprecated override {@link VisualBrick#render} and {@link VisualBrick#updateParent} instead.
623
- * @param $ the brick context
624
- * @param domElement the associated DOM Element
625
- */
626
- protected draw($: BrickContext, domElement: Element);
627
- }
628
-
629
- /**
630
- * @deprecated use {@link VisualBrick} instead
631
- */
632
- export class UIBrick extends VisualBrick { }
633
-
634
- /**
635
- * Static function that must be called for every brick used in an application.
636
- * It registers the brick code in the registry with the specified tag and return the Entry for that brick.
637
- *
638
- * @param tag the brick unique id
639
- * @param brick the brick class
640
- * @param args Extra arguments
641
- */
642
- export function registerBrick(tag: string, brick: new () => Brick, ...args: any): Entry;
643
-
644
- export class Config {
645
- /**
646
- * Returns the value associated to the specified parameter id. Returns undefined if the parameter does not exist.
647
- *
648
- * @param id the parameter id.
649
- */
650
- static getParameter(id: string): any | undefined;
651
- }
652
-
653
- declare type SRPData = {
654
- username: string,
655
- login: string
656
- salt: string,
657
- verifier: string
658
- }
659
-
660
- declare enum AuthState {
661
- INIT = 'init',
662
- DISCONNECTED = 'disconnected',
663
- GUEST = 'guest',
664
- AUTHENTICATING = 'authenticating',
665
- ERROR = 'error',
666
- AUTHENTICATED = 'authenticated'
667
- }
668
-
669
- /**
670
- * A static class that gathers all the required methods to handle the authentication and sessions with Olympe.
671
- */
672
- export class Auth {
673
-
674
- /**
675
- * Based on the username and password, it generates a salt and verifier to configure a SRP user
676
- *
677
- * @param username
678
- * @param password
679
- */
680
- static generateSRPData(username: string, password: string): SRPData;
681
-
682
- /**
683
- * Return the current state of the authentication manager
684
- */
685
- static getState(): AuthState;
686
-
687
- /**
688
- * Return the token currently used to identify the current session.
689
- */
690
- static getToken(): string;
691
-
692
- /**
693
- * Return the IDP token (zipped & base64 encoded XML) for the current user.
694
- */
695
- static getIDPToken(): string;
696
-
697
- /**
698
- * Return the tag of the current authenticated user.
699
- */
700
- static getCurrentUser(): string
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
-
708
- /**
709
- * Retrieve the user tag associated to the specified token
710
- *
711
- * @param token
712
- */
713
- static getUserFromToken(token: string): Promise<string>;
714
-
715
- /**
716
- * Refresh the session token to keep it alive.
717
- */
718
- static sendKeepAlive();
719
-
720
- /**
721
- * Try to login using SRP protocol with the specified username and password.
722
- * Returns a promise resolved when logged in or that catches an error if refused.
723
- *
724
- * @throws {Error} If the provider's configuration is incorrect.
725
- * @param username the username
726
- * @param password the password
727
- */
728
- static loginSRP(username: string, password: string): Promise<void>;
729
-
730
- /**
731
- * Try to login using SAML protocol with the specified username and password.
732
- * Returns a promise resolved when logged in or that catches an error if refused.
733
- *
734
- * @throws {Error} If the provider's configuration is incorrect.
735
- */
736
- static loginSAML(): Promise<void>;
737
-
738
- /**
739
- * Try to login using the specified token for the user.
740
- * Returns a promise resolved when logged in or that catches an error if the token is not valid.
741
- *
742
- * @param username the username
743
- * @param token the token
744
- */
745
- static loginToken(username: string, token: string): Promise<void>;
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
-
754
- /**
755
- * Log out the current user and invalidate its session token.
756
- * It returns a promise resolved when the operation is done.
757
- */
758
- static logout(): Promise<void>;
759
- }
760
-
761
- /**
762
- * Error type used to propagate errors through flows between bricks.
763
- */
764
- export class ErrorFlow {
765
- /**
766
- * Create a new Error object to be sent in an error flow
767
- *
768
- * @param message the error message
769
- * @param code the code associated to the error
770
- */
771
- static create(message: string, code: number): ErrorFlow;
772
-
773
- /**
774
- * Return the message of this error
775
- */
776
- getMessage(): string;
777
-
778
- /**
779
- * Return the code associated to this error
780
- */
781
- getCode(): number;
782
- }
783
-
784
- /* ======================
785
- DATACLOUD
786
- ====================== */
787
-
788
- export interface Relation<O extends Sync, D extends Sync> extends HasInstanceTag {
789
- getTag(): string;
790
- getDirection(): Direction;
791
- getInverse(): Relation<D, O>;
792
- }
793
-
794
- export class StringPrimitive extends Sync {
795
- static valueProp: PropertyDescriptor<string>;
796
- }
797
-
798
- export class NumberPrimitive extends Sync {
799
- static valueProp: PropertyDescriptor<number>;
800
- }
801
-
802
- export class BooleanPrimitive extends Sync {
803
- static valueProp: PropertyDescriptor<boolean>;
804
- }
805
-
806
- export class DatetimePrimitive extends Sync {
807
- static valueProp: PropertyDescriptor<Date>;
808
- }
809
-
810
- export class ColorPrimitive extends Sync {
811
- static valueProp: PropertyDescriptor<Color>;
812
- }
813
-
814
- export class Enum extends Sync {
815
- create(transaction: Transaction, name?: string): string;
816
- getValues(): ListDef;
817
- }
818
-
819
- export class EnumValue extends StringPrimitive {
820
- static create(transaction: Transaction, enumModel: InstanceTag, value: string, name?: string, rank?: number): string;
821
-
822
- static nameProp: PropertyDescriptor<string>;
823
- static valueProp: PropertyDescriptor<string>;
824
- static rankProp: PropertyDescriptor<number>;
825
- }
826
-
827
- export class File extends Sync {
828
- static nameProp: PropertyDescriptor<string>;
829
- static creationDateProp: PropertyDescriptor<Date>;
830
- static modificationDateProp: PropertyDescriptor<Date>;
831
- static mimeTypeProp: PropertyDescriptor<string>;
832
- static urlProp: PropertyDescriptor<string>;
833
-
834
- static createFile(model: InstanceTag, transaction: Transaction, name: string, content: ArrayBuffer, mimeType?: string, tag?: string): string;
835
- static createFileFromURL(model: InstanceTag, transaction: Transaction, name: string, url: string, mimeType?: string, tag?: string): string;
836
-
837
- getContentAsBinary(onSuccess: (content: ArrayBuffer) => void, onFailure?: (string) => void);
838
- getContentAsString(onSuccess: (content: string) => void, onFailure?: (string) => void);
839
- getContentUrl(onSuccess: (content: string) => void, onFailure?: () => void);
840
- saveAs(name: string);
841
- }
842
-
843
- export class User extends Sync {
844
- static loginProp: PropertyDescriptor<string>;
845
- static saltProp: PropertyDescriptor<string>;
846
- static verifierProp: PropertyDescriptor<string>;
847
- static SAMLNameIdProp: PropertyDescriptor<string>;
848
- }
849
-
850
- export class BusinessObject extends Sync {
851
- static nameProp: PropertyDescriptor<string>;
852
- static instanceRel: Relation<Sync, Sync>;
853
- static modelRel: Relation<Sync, Sync>;
854
- static containsRel: Relation<Sync, Sync>;
855
- static extendRel: Relation<Sync, Sync>;
856
- static extendedByRel: Relation<Sync, Sync>;
857
- static propertyRel: Relation<Sync, PropertyPrimitive>;
858
- }
859
-
860
- export class PropertyPrimitive extends Sync {
861
- static definingModelRel: Relation<PropertyPrimitive, BusinessObject>;
862
- static typeRel: Relation<PropertyPrimitive, Sync>;
863
- }
864
-
865
- export class RelationPrimitive extends Sync {
866
- static originModelRel: Relation<BusinessObject, RelationPrimitive>;
867
- static destinationModelRel: Relation<RelationPrimitive, BusinessObject>;
868
- }
869
-
870
- export class Color {
871
- static create(r: number, g: number, b: number, a?: number): Color;
872
-
873
- getRed(): number;
874
- getGreen(): number;
875
- getBlue(): number;
876
- getAlpha(): number;
877
- toRGBString(): string;
878
- toHexString(): string;
879
- equals(obj): boolean;
880
- }
881
-
882
- /** @deprecated */
883
- export class Parameter {
884
- constructor(id: string);
885
- }
886
-
887
- /** @deprecated */
888
- interface HasInstanceTag {
889
- getTag(): string;
890
- }
891
-
892
- export type InstanceTag = HasInstanceTag | string | (new () => Sync) | Entry;
893
-
894
- /** @deprecated */
895
- export function instanceToTag(instance: InstanceTag): string;
896
- /** @deprecated */
897
- export function onDestroy(callback: () => void): string;
898
- /** @deprecated */
899
- export function offDestroy(id: string);
900
- /** @deprecated */
901
- export function registerSync(tag: string, brick: new () => Sync, ...args: any): Entry;
902
-
903
- /** @deprecated */
904
- export class Sync implements HasInstanceTag {
905
- static getInstance(instance: InstanceTag): Sync;
906
- static getInstancesOf(model: InstanceTag): ListDef;
907
-
908
- getTag(): string;
909
- getModel(): Sync;
910
- getModelTag(): string;
911
- getName(): string;
912
- observeProperty<T>(property: Property<T>): Observable<T>;
913
- getProperty<T>(property: Property<T>): T | null;
914
- }
915
-
916
- /** @deprecated */
917
- export class DBView {
918
- static get(): DBView;
919
-
920
- exist(tag: InstanceTag): boolean;
921
- name(tag: InstanceTag): string;
922
- model(tag: InstanceTag): string | null;
923
- extension(tag: InstanceTag): string | null;
924
- isModel(tag: InstanceTag): boolean;
925
- instanceOf(tag: InstanceTag, modelTag: InstanceTag): boolean;
926
- isPersisted(tag: InstanceTag): boolean;
927
- getProperty<T>(tag: InstanceTag, property: Property<T>, ownOnly: boolean): T | null;
928
- // @ts-ignore
929
- getProperties(tag: InstanceTag, ownOnly: boolean): Map<string, any>;
930
- getRelated(tag: InstanceTag, relation: Relation<any, any>): string[];
931
- isRelated(tag: InstanceTag, relation: Relation<any, any>, related: InstanceTag): boolean;
932
- getMultiRelated(startTag: InstanceTag, relations: Relation<any, any>[]): string[];
933
- getUniqueRelated(tag: InstanceTag, relation: Relation<any, any>): string | null;
934
- getRecursiveRelated(startTag: InstanceTag, relation: Relation<any, any>, endTag: InstanceTag): string[];
935
- findRecursive(startTag: InstanceTag, relation: Relation<any, any>, predicate: (string) => boolean): string | null;
936
- findRelated(startTag: InstanceTag, relations: Relation<any, any>[], predicate: (string) => boolean): string | null;
937
- findAllRelated(startTag: InstanceTag, relations: Relation<any, any>[], predicate: (string) => boolean): string[];
938
- getExtendedModels(modelTag: InstanceTag, endTag?: InstanceTag): string[];
939
- isExtending(modelTag: InstanceTag, extendedTag: InstanceTag): boolean;
940
- getInstances(modelTag: InstanceTag): string[];
941
- }
942
-
943
- /** @deprecated */
944
- export class ListDef {
945
- constructor(root: InstanceTag, transformers?: Transformer | Transformer[]);
946
- getBaseTag(): string;
947
- onReady(callback: (list: ListDef) => void): string;
948
- offReady(id: string);
949
- observeFirst(): Observable<Sync>;
950
- observeAt(rank: number): Observable<Sync>;
951
- getCurrentAt(rank: number): Sync | null;
952
- observeRank(id: string): Observable<number>;
953
- getCurrentRank(id: string): number | null;
954
- observeSize(): Observable<number>;
955
- getCurrentSize(): number;
956
- forEach(onAdd: (item: Sync, index: string, list: ListDef) => void, onRemove: (itemTag: string) => void);
957
- forEachCurrentValue(callback: (item: Sync, index: string, list: ListDef) => void);
958
- transform(...transformers: Transformer[]): ListDef;
959
- union(otherListDef: ListDef): ListDef;
960
- filter(predicate: Predicate): ListDef;
961
- }
962
-
963
- /** @deprecated */
964
- export enum Direction {
965
- DESTINATION, ORIGIN
966
- }
967
-
968
- /** @deprecated */
969
- export enum FollowRule {
970
- NONE, DUMP, DELETE, RUNTIME
971
- }
972
-
973
- /* *************************
974
- Transformers
975
- ************************* */
976
- declare abstract class Transformer { }
977
-
978
- export namespace transformers {
979
- /** @deprecated */
980
- export class Related<O extends Sync, D extends Sync> extends Transformer implements Relation<O, D> {
981
- constructor(relation: InstanceTag, direction: Direction);
982
- getTag(): string;
983
- getDirection(): Direction;
984
- getInverse(): transformers.Related<D, O>;
985
- }
986
-
987
- /** @deprecated */
988
- export class RecursiveRelated extends Transformer {
989
- constructor(relation: InstanceTag, direction: Direction, minHops: number, maxHops: number);
990
- }
991
-
992
- /** @deprecated */
993
- export class Distinct extends Transformer {
994
- constructor();
995
- }
996
-
997
- /** @deprecated */
998
- export class Filter extends Transformer {
999
- constructor(predicate: Predicate);
1000
- }
1001
-
1002
- /** @deprecated */
1003
- export class Limit extends Transformer {
1004
- constructor(limit: number, offset: number);
1005
- }
1006
-
1007
- /** @deprecated */
1008
- export class Sort extends Transformer {
1009
- constructor(comparator: Comparator, ascending?: boolean);
1010
- }
1011
-
1012
- /** @deprecated */
1013
- export class Union extends Transformer {
1014
- constructor(base: ListDef | InstanceTag, ...transformers: Transformer[]);
1015
- }
1016
- }
1017
-
1018
- /* *************************
1019
- Predicates
1020
- ************************* */
1021
- /** @deprecated */
1022
- export abstract class Predicate {
1023
- static create(predicate: (object: Sync) => Observable<boolean>): Predicate;
1024
- }
1025
-
1026
- export namespace predicates {
1027
- /** @deprecated */
1028
- export class And extends Predicate {
1029
- constructor(...predicates: Predicate[]);
1030
- }
1031
-
1032
- /** @deprecated */
1033
- export class Or extends Predicate {
1034
- constructor(...predicates: Predicate[]);
1035
- }
1036
-
1037
- /** @deprecated */
1038
- export class Not extends Predicate {
1039
- constructor(predicate: Predicate);
1040
- }
1041
-
1042
- /** @deprecated */
1043
- export class Equals extends Predicate {
1044
- constructor(left: ValueDef, right: ValueDef);
1045
- }
1046
-
1047
- /** @deprecated */
1048
- export class Contains extends Predicate {
1049
- constructor(source: ValueDef, value: ValueDef);
1050
- }
1051
-
1052
- /** @deprecated */
1053
- export class Greater extends Predicate {
1054
- constructor(left: ValueDef, right: ValueDef);
1055
- }
1056
-
1057
- /** @deprecated */
1058
- export class Smaller extends Predicate {
1059
- constructor(left: ValueDef, right: ValueDef);
1060
- }
1061
-
1062
- /** @deprecated */
1063
- export class HasRelated extends Predicate {
1064
- constructor(relations: InstanceTag[], directions: Direction[], tag?: InstanceTag);
1065
- }
1066
-
1067
- /** @deprecated */
1068
- export class InstanceOf extends Predicate {
1069
- constructor(models: InstanceTag[]);
1070
- }
1071
-
1072
- /** @deprecated */
1073
- export class Regex extends Predicate {
1074
- constructor(source: ValueDef, regex: string, caseSensitive?: boolean);
1075
- }
1076
- }
1077
-
1078
- /* *************************
1079
- ValueDefs
1080
- ************************* */
1081
- declare abstract class ValueDef { }
1082
-
1083
- /** @deprecated */
1084
- export namespace valuedefs {
1085
- /** @deprecated */
1086
- export class BooleanProperty extends ValueDef {
1087
- constructor(property: Property<boolean>, transformers?: Transformer[], baseTag?: string);
1088
- }
1089
-
1090
- /** @deprecated */
1091
- export class DateTimeProperty extends ValueDef {
1092
- constructor(property: Property<Date>, transformers?: Transformer[], baseTag?: string);
1093
- }
1094
-
1095
- /** @deprecated */
1096
- export class NumberProperty extends ValueDef {
1097
- constructor(property: Property<number>, transformers?: Transformer[], baseTag?: string);
1098
- }
1099
-
1100
- /** @deprecated */
1101
- export class StringProperty extends ValueDef {
1102
- constructor(property: Property<string>, transformers?: Transformer[], baseTag?: string);
1103
- }
1104
-
1105
- /** @deprecated */
1106
- export class Tag extends ValueDef {
1107
- constructor();
1108
- }
1109
-
1110
- /** @deprecated */
1111
- export class Constant extends ValueDef {
1112
- constructor(value: any);
1113
- }
1114
- }
1115
-
1116
- /* *************************
1117
- Comparator
1118
- ************************* */
1119
- /** @deprecated */
1120
- export abstract class Comparator {
1121
- static create(comparator: (object1: Sync, object2: Sync) => Observable<number>): Comparator;
1122
- }
1123
-
1124
- export namespace comparators {
1125
- /** @deprecated */
1126
- export class Number extends Comparator {
1127
- constructor(value: ValueDef);
1128
- }
1129
-
1130
- /** @deprecated */
1131
- export class String extends Comparator {
1132
- constructor(value: ValueDef);
1133
- }
1134
-
1135
- /** @deprecated */
1136
- export class DateTime extends Comparator {
1137
- constructor(value: ValueDef);
1138
- }
1139
- }
1140
-
1141
- interface Operation { }
1142
-
1143
- export class BurstTransaction {
1144
- constructor();
1145
- push(object: InstanceTag, values: Observable<Map<string, any>>);
1146
- complete(): Promise<void>;
1147
- }
1148
-
1149
- /** @deprecated */
1150
- export class Transaction implements Operation {
1151
- constructor();
1152
-
1153
- getId(): string;
1154
- addOperation(operation: Operation): Operation;
1155
- persist(persist: boolean): this;
1156
- create(model: InstanceTag, tag?: string): CreateInstance;
1157
- persistInstance(tag: InstanceTag, persist?: boolean): CreateInstance;
1158
- delete(tag: InstanceTag, followRule?: FollowRule);
1159
- update<T>(instance: InstanceTag, property?: Property<T>, value?: T): UpdateInstance;
1160
- createRelation(relation: InstanceTag, from: InstanceTag, to: InstanceTag);
1161
- deleteRelation(relation: InstanceTag, from: InstanceTag, to: InstanceTag);
1162
- deleteAllRelations(relation: Relation<any, any>, origin: InstanceTag);
1163
- afterExecution(callback: (success: boolean, message?: string) => void);
1164
- execute(callback: (success: boolean, message?: string) => void);
1165
- executeAsLarge(callback: (success: boolean, message?: string) => void);
1166
- }
1167
-
1168
- /** @deprecated */
1169
- export class CreateInstance implements Operation, HasInstanceTag {
1170
- getTag(): string;
1171
- getModelTag(): string;
1172
- setProperty<T>(property: Property<T>, value: T): this;
1173
- persist(persist: boolean): this;
1174
- localSource();
1175
- }
1176
-
1177
- /** @deprecated */
1178
- export class UpdateInstance implements Operation, HasInstanceTag {
1179
- getTag(): string;
1180
- setProperty<T>(property: Property<T>, value: T): this;
1181
- }