@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
@@ -0,0 +1,284 @@
1
+ // @ts-ignore
2
+ import Observable from 'rxjs';
3
+ import {CloudObject, Direction, HasTag, Property, Relation, Tag} from "./base";
4
+ import {Brick, VisualBrick} from "./runtime";
5
+ /**
6
+ * The entry of a brick is a static object linked to the brick class itself that is used to make the link between the
7
+ * code and the database. It stores tags linked to a specific brick :
8
+ * - tag of the brick itself
9
+ * - tags of properties that can be used as constants.
10
+ *
11
+ * @deprecated
12
+ */
13
+ declare interface Entry extends HasTag {
14
+
15
+ /**
16
+ * Register a property on the brick with the specified tag.
17
+ *
18
+ * @deprecated use {@link defineProperty} instead
19
+ * @param tag
20
+ * @return the property descriptor
21
+ */
22
+ addProperty<T>(tag: string): Property<T>;
23
+
24
+ /**
25
+ * Register a new relation type with the specified tag and direction
26
+ *
27
+ * @deprecated use {@link defineRelation} instead
28
+ * @param tag
29
+ * @param direction
30
+ */
31
+ addRelation(tag: string, direction: Direction): transformers.Related<any, any>;
32
+ }
33
+
34
+ /** @deprecated use {@link VisualBrick} instead */
35
+ export class UIBrick extends VisualBrick {}
36
+
37
+ /** @deprecated use {@link Brick} instead */
38
+ export type FunctionBrick = Brick;
39
+
40
+ /* ======================
41
+ DATACLOUD
42
+ ====================== */
43
+
44
+ export type InstanceTag = Tag | Entry;
45
+
46
+ /** @deprecated */
47
+ export function instanceToTag(instance: InstanceTag): string;
48
+ /** @deprecated */
49
+ export function onDestroy(callback: () => void): string;
50
+ /** @deprecated */
51
+ export function offDestroy(id: string);
52
+ /** @deprecated */
53
+ export function registerSync(tag: string, brick: new () => Sync, ...args: any): Entry;
54
+
55
+ /** @deprecated */
56
+ export class Sync extends CloudObject {
57
+ /** @deprecated use static method {@link CloudObject#get} instead */
58
+ static getInstance(instance: InstanceTag): Sync;
59
+ /** @deprecated use static method {@link CloudObject#instancesOf} instead */
60
+ static getInstancesOf(model: InstanceTag): ListDef;
61
+
62
+ /** @deprecated use {@link CloudObject#name} instead */
63
+ getName(): string;
64
+ /** @deprecated use {@link CloudObject#observe} instead */
65
+ observeProperty<T>(property: Property<T>): Observable<T>;
66
+ /** @deprecated use {@link CloudObject#get} instead */
67
+ getProperty<T>(property: Property<T>): T | null;
68
+ }
69
+
70
+ /** @deprecated */
71
+ export class DBView {
72
+ static get(): DBView;
73
+
74
+ exist(tag: InstanceTag): boolean;
75
+ name(tag: InstanceTag): string;
76
+ model(tag: InstanceTag): string | null;
77
+ extension(tag: InstanceTag): string | null;
78
+ isModel(tag: InstanceTag): boolean;
79
+ instanceOf(tag: InstanceTag, modelTag: InstanceTag): boolean;
80
+ isPersisted(tag: InstanceTag): boolean;
81
+ getProperty<T>(tag: InstanceTag, property: Property<T>, ownOnly?: boolean): T | null;
82
+ // @ts-ignore
83
+ getProperties(tag: InstanceTag, ownOnly?: boolean): Map<string, any>;
84
+ getRelated(tag: InstanceTag, relation: Relation<any, any>): string[];
85
+ isRelated(tag: InstanceTag, relation: Relation<any, any>, related: InstanceTag): boolean;
86
+ getMultiRelated(startTag: InstanceTag, relations: Relation<any, any>[]): string[];
87
+ getUniqueRelated(tag: InstanceTag, relation: Relation<any, any>): string | null;
88
+ getRecursiveRelated(startTag: InstanceTag, relation: Relation<any, any>, endTag: InstanceTag): string[];
89
+ findRecursive(startTag: InstanceTag, relation: Relation<any, any>, predicate: (string) => boolean): string | null;
90
+ findRelated(startTag: InstanceTag, relations: Relation<any, any>[], predicate: (string) => boolean): string | null;
91
+ findAllRelated(startTag: InstanceTag, relations: Relation<any, any>[], predicate: (string) => boolean): string[];
92
+ getExtendedModels(modelTag: InstanceTag, endTag?: InstanceTag): string[];
93
+ isExtending(modelTag: InstanceTag, extendedTag: InstanceTag): boolean;
94
+ getInstances(modelTag: InstanceTag): string[];
95
+ }
96
+
97
+ /** @deprecated */
98
+ export class ListDef {
99
+ constructor(root: InstanceTag, transformers?: Transformer | Transformer[]);
100
+ getBaseTag(): string;
101
+ onReady(callback: (list: ListDef) => void): string;
102
+ offReady(id: string);
103
+ observeFirst(): Observable<Sync>;
104
+ observeAt(rank: number): Observable<Sync>;
105
+ getCurrentAt(rank: number): Sync | null;
106
+ observeRank(id: string): Observable<number>;
107
+ getCurrentRank(id: string): number | null;
108
+ observeSize(): Observable<number>;
109
+ getCurrentSize(): number;
110
+ forEach(onAdd: (item: Sync, index: string, list: ListDef) => void, onRemove: (itemTag: string) => void);
111
+ forEachCurrentValue(callback: (item: Sync, index: string, list: ListDef) => void);
112
+ transform(...transformers: Transformer[]): ListDef;
113
+ union(otherListDef: ListDef): ListDef;
114
+ filter(predicate: ListDefPredicate): ListDef;
115
+ }
116
+
117
+
118
+ /* *************************
119
+ Transformers
120
+ ************************* */
121
+ declare abstract class Transformer { }
122
+
123
+ export namespace transformers {
124
+ /** @deprecated */
125
+ export class Related<O extends CloudObject, D extends CloudObject> extends Transformer {
126
+ constructor(relation: InstanceTag, direction: Direction);
127
+ getTag(): string;
128
+ getDirection(): Direction;
129
+ getInverse(): transformers.Related<D, O>;
130
+ }
131
+
132
+ /** @deprecated */
133
+ export class RecursiveRelated extends Transformer {
134
+ constructor(relation: InstanceTag, direction: Direction, minHops: number, maxHops: number);
135
+ }
136
+
137
+ /** @deprecated */
138
+ export class Distinct extends Transformer {
139
+ constructor();
140
+ }
141
+
142
+ /** @deprecated */
143
+ export class Filter extends Transformer {
144
+ constructor(predicate: ListDefPredicate);
145
+ }
146
+
147
+ /** @deprecated */
148
+ export class Limit extends Transformer {
149
+ constructor(limit: number, offset: number);
150
+ }
151
+
152
+ /** @deprecated */
153
+ export class Sort extends Transformer {
154
+ constructor(comparator: Comparator, ascending?: boolean);
155
+ }
156
+
157
+ /** @deprecated */
158
+ export class Union extends Transformer {
159
+ constructor(base: ListDef | InstanceTag, ...transformers: Transformer[]);
160
+ }
161
+ }
162
+
163
+ /* *************************
164
+ Predicates
165
+ ************************* */
166
+ /** @deprecated */
167
+ export abstract class ListDefPredicate {
168
+ static create(predicate: (object: Sync) => Observable<boolean>): ListDefPredicate;
169
+ }
170
+
171
+ export namespace predicates {
172
+ /** @deprecated */
173
+ export class And extends ListDefPredicate {
174
+ constructor(...predicates: ListDefPredicate[]);
175
+ }
176
+
177
+ /** @deprecated */
178
+ export class Or extends ListDefPredicate {
179
+ constructor(...predicates: ListDefPredicate[]);
180
+ }
181
+
182
+ /** @deprecated */
183
+ export class Not extends ListDefPredicate {
184
+ constructor(predicate: ListDefPredicate);
185
+ }
186
+
187
+ /** @deprecated */
188
+ export class Equals extends ListDefPredicate {
189
+ constructor(left: ValueDef, right: ValueDef);
190
+ }
191
+
192
+ /** @deprecated */
193
+ export class Contains extends ListDefPredicate {
194
+ constructor(source: ValueDef, value: ValueDef);
195
+ }
196
+
197
+ /** @deprecated */
198
+ export class Greater extends ListDefPredicate {
199
+ constructor(left: ValueDef, right: ValueDef);
200
+ }
201
+
202
+ /** @deprecated */
203
+ export class Smaller extends ListDefPredicate {
204
+ constructor(left: ValueDef, right: ValueDef);
205
+ }
206
+
207
+ /** @deprecated */
208
+ export class HasRelated extends ListDefPredicate {
209
+ constructor(relations: InstanceTag[], directions: Direction[], tag?: InstanceTag);
210
+ }
211
+
212
+ /** @deprecated */
213
+ export class InstanceOf extends ListDefPredicate {
214
+ constructor(models: InstanceTag[]);
215
+ }
216
+
217
+ /** @deprecated */
218
+ export class Regex extends ListDefPredicate {
219
+ constructor(source: ValueDef, regex: string, caseSensitive?: boolean);
220
+ }
221
+ }
222
+
223
+ /* *************************
224
+ ValueDefs
225
+ ************************* */
226
+ declare abstract class ValueDef { }
227
+
228
+ /** @deprecated */
229
+ export namespace valuedefs {
230
+ /** @deprecated */
231
+ export class BooleanProperty extends ValueDef {
232
+ constructor(property: Property<boolean>, transformers?: Transformer[], baseTag?: string);
233
+ }
234
+
235
+ /** @deprecated */
236
+ export class DateTimeProperty extends ValueDef {
237
+ constructor(property: Property<Date>, transformers?: Transformer[], baseTag?: string);
238
+ }
239
+
240
+ /** @deprecated */
241
+ export class NumberProperty extends ValueDef {
242
+ constructor(property: Property<number>, transformers?: Transformer[], baseTag?: string);
243
+ }
244
+
245
+ /** @deprecated */
246
+ export class StringProperty extends ValueDef {
247
+ constructor(property: Property<string>, transformers?: Transformer[], baseTag?: string);
248
+ }
249
+
250
+ /** @deprecated */
251
+ export class Tag extends ValueDef {
252
+ constructor();
253
+ }
254
+
255
+ /** @deprecated */
256
+ export class Constant extends ValueDef {
257
+ constructor(value: any);
258
+ }
259
+ }
260
+
261
+ /* *************************
262
+ Comparator
263
+ ************************* */
264
+ /** @deprecated */
265
+ export abstract class Comparator {
266
+ static create(comparator: (object1: Sync, object2: Sync) => Observable<number>): Comparator;
267
+ }
268
+
269
+ export namespace comparators {
270
+ /** @deprecated */
271
+ export class Number extends Comparator {
272
+ constructor(value: ValueDef);
273
+ }
274
+
275
+ /** @deprecated */
276
+ export class String extends Comparator {
277
+ constructor(value: ValueDef);
278
+ }
279
+
280
+ /** @deprecated */
281
+ export class DateTime extends Comparator {
282
+ constructor(value: ValueDef);
283
+ }
284
+ }
@@ -0,0 +1,281 @@
1
+ // **********************************
2
+ // Runtime classes
3
+ // **********************************
4
+ // @ts-ignore
5
+ import Observable from 'rxjs';
6
+ import {CloudObject, Context, Property} from "./base";
7
+ import {Entry} from "./legacy";
8
+
9
+ /**
10
+ * Label of global properties used by convention through bricks and applications.
11
+ * Example of use:
12
+ *
13
+ * const transaction = context.get(TRANSACTION).
14
+ *
15
+ * The brick "Begin Transaction" push a transaction inside the context so it can be reused by other bricks before the "End Transaction" brick.
16
+ */
17
+ export enum GlobalProperties {
18
+ EDITION_MODE = '__editionMode',
19
+ PRODUCTION = '__production',
20
+ TRANSACTION = '__transaction'
21
+ }
22
+
23
+ export class BrickContext extends Context {
24
+ /**
25
+ * Returns a boolean indicating whether a property has a value or not.
26
+ *
27
+ * @param key the property or key string
28
+ * @param global [=false] whether or not the method checks parent contexts
29
+ * @return whether `property` has a value or not
30
+ */
31
+ has<T>(key: string | Property<T>, global?: boolean): boolean;
32
+
33
+ /**
34
+ * Return the current value of the specified property. If there is currently no value, return null.
35
+ *
36
+ * @param key the property or key string
37
+ * @param global [=false] whether or not the method checks parent contexts
38
+ * @return the current value
39
+ */
40
+ get<T>(key: string | Property<T>, global?: boolean): T | null;
41
+
42
+ /**
43
+ * Return an observable to subscribe to value updates of the specified property.
44
+ * If `waitForValue` is set to FALSE (TRUE by default), the first value received by the observable is null
45
+ * if there is no value at subscription time.
46
+ * If `global` is set to TRUE (FALSE by default), it observes values coming from other contexts accessible from the current one.
47
+ *
48
+ * @param key the property or key string
49
+ * @param waitForValue [=true] whether or not the observable wait for a first value to get a value.
50
+ * @param global [=false] whether or not listen to a value coming from other contexts.
51
+ * @return the observable
52
+ */
53
+ observe<T>(key: string | Property<T>, waitForValue?: boolean, global?: boolean): Observable<T>;
54
+
55
+ /**
56
+ * Wait for the property to get a new value, wrapped in a promise.
57
+ *
58
+ * @param key the property
59
+ * @param global [=false] whether or not the method checks parent contexts
60
+ * @return a promise of the next value of property
61
+ */
62
+ waitFor<T>(key: string | Property<T>, global?: boolean): Promise<T>;
63
+
64
+ /**
65
+ * Set the specified property value and propagate the update to anyone observing it.
66
+ *
67
+ * @param key the property or key string
68
+ * @param value the new value to set
69
+ * @return this
70
+ */
71
+ set<T>(key: string | Property<T>, value: T): this;
72
+
73
+ /**
74
+ * Clear the value of the specified property and propagate that event.
75
+ *
76
+ * @param key the property or key string
77
+ */
78
+ remove<T>(key: string | Property<T>): boolean;
79
+
80
+ /**
81
+ * Subscribe to the specified observable and set its values to the context with the provided key.
82
+ *
83
+ * @param key the key used to set the values coming from the observable
84
+ * @param observable the observable providing values
85
+ * @return this context
86
+ */
87
+ repeat<T>(key: string | Property<T>, observable: Observable<T>): this;
88
+
89
+ /**
90
+ * Trigger the specified event and propagate the update to anyone observing it.
91
+ *
92
+ * @param key the event or key event
93
+ * @return this
94
+ */
95
+ trigger<T>(key: string | Property<T>): this;
96
+
97
+ /**
98
+ * Run a runnable property and returns its context.
99
+ *
100
+ * @param key the runnable property or the runnable itself
101
+ * @return the child context or null if the runner was not found
102
+ */
103
+ runner<T>(key: string | Property<T> | Brick): BrickContext | null;
104
+
105
+ /**
106
+ * Set the parent element for visual brick to be rendered.
107
+ *
108
+ * @param parent the parent container
109
+ * @return this
110
+ */
111
+ setParentElement(parent: Element): this;
112
+
113
+ /**
114
+ * Create and return a new context, child of the current one.
115
+ * Mainly used to run other bricks within the current one (e.g.: the iterator of the brick For Each).
116
+ *
117
+ * @param debugName a name to give to the context for debugging purpose.
118
+ */
119
+ createChild(debugName?: string): BrickContext;
120
+
121
+
122
+ // Methods to get other contexts accessible form this specific one.
123
+ /**
124
+ * Return the context with the specified id if accessible (in the hierarchy) from this context.
125
+ * Otherwise, return null.
126
+ *
127
+ * @param id the context id we want to retrieve
128
+ */
129
+ getOtherContext(id: string): BrickContext | null;
130
+
131
+ /**
132
+ * Return the parent context if it exists.
133
+ */
134
+ getParent(): BrickContext | null;
135
+
136
+ /**
137
+ * Listen to the creation of the context with the specified id.
138
+ * Executes the callback when that context becomes accessible by this current context.
139
+ * Return a function to unregister the listener.
140
+ *
141
+ * @param id the context id, which corresponds to the tag of the brick to be retrieved.
142
+ * @param callback the function to execute when the specified brick context is available
143
+ */
144
+ onContext(id: string, callback: (context: BrickContext) => void): () => void;
145
+ }
146
+
147
+ /**
148
+ * Static function that must be called for every brick used in an application.
149
+ * It registers the brick code in the registry with the specified tag and return the Entry for that brick.
150
+ *
151
+ * @param tag the brick unique id
152
+ * @param brick the brick class
153
+ * @param args Extra arguments
154
+ */
155
+ export function registerBrick(tag: string, brick: new () => Brick, ...args: any);
156
+
157
+ export abstract class Brick extends CloudObject {
158
+
159
+ /**
160
+ * Return the list of inputs tags as an ordered array.
161
+ */
162
+ readonly getInputs: () => string[];
163
+
164
+ /**
165
+ * Return the list of outputs tags as an ordered array
166
+ */
167
+ readonly getOutputs: () => string[];
168
+
169
+ /**
170
+ * Run the brick itself using the specified context.
171
+ *
172
+ * @param $ the brick context
173
+ */
174
+ run($: BrickContext) : void;
175
+
176
+ /**
177
+ * Called when the brick starts its lifecycle and gets initialized.
178
+ *
179
+ * @param $ the brick context
180
+ */
181
+ protected init($: BrickContext): void;
182
+
183
+ /**
184
+ * Observe the context to define when the brick `update` method should be called.
185
+ *
186
+ * @param $ the brick context
187
+ * @return an observable that emit a value anytime the brick `update` method should be called.
188
+ */
189
+ protected setupExecution($: BrickContext): Observable<any>;
190
+
191
+ /**
192
+ * Called whenever the conditions to update the brick are satisfied (as defined by method `configCoreUpdate`).
193
+ * By default, a function updates whenever an input gets a new value, but only if all inputs have a value.
194
+ *
195
+ * @param $ the brick context
196
+ * @param inputs array of input values
197
+ * @param outputs array of output setter functions. A setter updates a specific output value of the brick.
198
+ */
199
+ protected update($: BrickContext, inputs: any[], outputs: ((any) => void)[]): void;
200
+
201
+ /**
202
+ * Called every time the context is cleared.
203
+ *
204
+ * @param $ the brick context
205
+ */
206
+ protected clear($: BrickContext): void;
207
+
208
+ /**
209
+ * Called when the brick ends its lifecycle and gets destroyed.
210
+ *
211
+ * @param $ the brick context
212
+ */
213
+ protected destroy($: BrickContext): void;
214
+
215
+ /**
216
+ * @deprecated use {@link BrickContext#init} instead
217
+ * @param $ the brick context
218
+ */
219
+ protected onInit($: BrickContext): void;
220
+
221
+ /**
222
+ * @deprecated use {@link BrickContext#update} instead
223
+ * @param $ the brick context
224
+ * @param inputs array of input values
225
+ * @param outputs array of output setter functions.
226
+ */
227
+ protected onUpdate($: BrickContext, inputs: Array<any>, outputs: Array<(value: any) => void>): void;
228
+
229
+ /**
230
+ * @deprecated use {@link BrickContext#destroy} instead
231
+ * @param $ the brick context
232
+ */
233
+ protected onDestroy($: BrickContext): void;
234
+ }
235
+
236
+
237
+ export abstract class ActionBrick extends Brick { }
238
+
239
+ // **********************
240
+ // Runtime Visual classes
241
+ // **********************
242
+
243
+ export abstract class VisualBrick extends Brick {
244
+ /**
245
+ * Return the list of properties tags as an ordered array
246
+ */
247
+ readonly getProperties: () => string[];
248
+
249
+ /**
250
+ * Attach the `element` rendered by `render()` to its `parent` (in the DOM).
251
+ * Must return the function to clear the parent from that element.
252
+ * That function is called just before the next call to updateParent.
253
+ *
254
+ * If the `render()` method returns null, only the clear function of previous call to `updateParent()` will be called.
255
+ *
256
+ * @param parent the parent element
257
+ * @param element the element to attach
258
+ * @return the function to clear the element from its parent.
259
+ */
260
+ protected updateParent(parent: Element, element: Element): () => void;
261
+
262
+ /**
263
+ * Render an element for the given `context`.
264
+ * Can return `null` if no element is rendered.
265
+ *
266
+ * @param $ the brick context
267
+ * @param properties property values that have been s
268
+ * @return the rendered element
269
+ */
270
+ protected render($: BrickContext, properties: any[]): Element | null;
271
+
272
+ /**
273
+ * Called when the DOM Element associated to that brick has been added to the document and is ready to be drawn.
274
+ *
275
+ * @deprecated override {@link VisualBrick#render} and {@link VisualBrick#updateParent} instead.
276
+ * @param $ the brick context
277
+ * @param domElement the associated DOM Element
278
+ */
279
+ protected draw($: BrickContext, domElement: Element);
280
+ }
281
+