@olympeio/runtime-node 8.7.0 → 9.0.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.
- package/import/olympe.dm/datamodel/00_bootstrap.newInst.json +1 -1
- package/import/olympe.dm/datamodel/00_bootstrap.newRel.json +1 -1
- package/import/olympe.dm/datamodel/01_primitives.newInst.json +1 -1
- package/import/olympe.dm/datamodel/01_primitives.newRel.json +1 -1
- package/import/olympe.dm/datamodel/02_permissions.newInst.json +1 -1
- package/import/olympe.dm/datamodel/02_permissions.newRel.json +1 -1
- package/import/olympe.dm/datamodel/03_file.newInst.json +1 -1
- package/import/olympe.dm/datamodel/03_file.newRel.json +1 -1
- package/import/olympe.dm/datamodel/04_modules.newInst.json +1 -1
- package/import/olympe.dm/datamodel/04_modules.newRel.json +1 -1
- package/import/olympe.dm/datamodel/05_permission_schema.newInst.json +1 -1
- package/import/olympe.dm/datamodel/05_permission_schema.newRel.json +1 -1
- package/import/olympe.dm/datamodel/05_permission_schema.updateInst.json +1 -1
- package/import/olympe.dm/datamodel/06_structure.newInst.json +1 -1
- package/import/olympe.dm/datamodel/06_structure.newRel.json +1 -1
- package/import/olympe.sc/datamodel/00_primordial.newInst.json +1 -1
- package/import/olympe.sc/datamodel/00_primordial.newRel.json +1 -1
- package/import/olympe.sc/datamodel/01_language.newInst.json +1 -1
- package/import/olympe.sc/datamodel/01_language.newRel.json +1 -1
- package/import/olympe.sc/datamodel/02_bricks.newInst.json +1 -0
- package/import/olympe.sc/datamodel/02_bricks.newRel.json +1 -0
- package/index.js +792 -666
- package/package.json +7 -3
- package/types/base.d.ts +116 -0
- package/types/cloud.d.ts +303 -0
- package/types/index.d.ts +5 -0
- package/types/legacy.d.ts +281 -0
- package/types/runtime.d.ts +281 -0
- package/types/utils.d.ts +290 -0
- package/import/olympe.sc/datamodel/logic/01_functions.newInst.json +0 -1
- package/import/olympe.sc/datamodel/logic/01_functions.newRel.json +0 -1
- package/import/olympe.sc/datamodel/logic/02_actions.newInst.json +0 -1
- package/import/olympe.sc/datamodel/logic/02_actions.newRel.json +0 -1
- package/index.d.ts +0 -1174
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import Observable from 'rxjs';
|
|
3
|
+
import {CloudObject, Direction, HasTag, Property, Relation, Tag} from "./base";
|
|
4
|
+
import {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
|
+
/* ======================
|
|
38
|
+
DATACLOUD
|
|
39
|
+
====================== */
|
|
40
|
+
|
|
41
|
+
export type InstanceTag = Tag | Entry;
|
|
42
|
+
|
|
43
|
+
/** @deprecated */
|
|
44
|
+
export function instanceToTag(instance: InstanceTag): string;
|
|
45
|
+
/** @deprecated */
|
|
46
|
+
export function onDestroy(callback: () => void): string;
|
|
47
|
+
/** @deprecated */
|
|
48
|
+
export function offDestroy(id: string);
|
|
49
|
+
/** @deprecated */
|
|
50
|
+
export function registerSync(tag: string, brick: new () => Sync, ...args: any): Entry;
|
|
51
|
+
|
|
52
|
+
/** @deprecated */
|
|
53
|
+
export class Sync extends CloudObject {
|
|
54
|
+
/** @deprecated use static method {@link CloudObject#get} instead */
|
|
55
|
+
static getInstance(instance: InstanceTag): Sync;
|
|
56
|
+
/** @deprecated use static method {@link CloudObject#instancesOf} instead */
|
|
57
|
+
static getInstancesOf(model: InstanceTag): ListDef;
|
|
58
|
+
|
|
59
|
+
/** @deprecated use {@link CloudObject#name} instead */
|
|
60
|
+
getName(): string;
|
|
61
|
+
/** @deprecated use {@link CloudObject#observe} instead */
|
|
62
|
+
observeProperty<T>(property: Property<T>): Observable<T>;
|
|
63
|
+
/** @deprecated use {@link CloudObject#get} instead */
|
|
64
|
+
getProperty<T>(property: Property<T>): T | null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** @deprecated */
|
|
68
|
+
export class DBView {
|
|
69
|
+
static get(): DBView;
|
|
70
|
+
|
|
71
|
+
exist(tag: InstanceTag): boolean;
|
|
72
|
+
name(tag: InstanceTag): string;
|
|
73
|
+
model(tag: InstanceTag): string | null;
|
|
74
|
+
extension(tag: InstanceTag): string | null;
|
|
75
|
+
isModel(tag: InstanceTag): boolean;
|
|
76
|
+
instanceOf(tag: InstanceTag, modelTag: InstanceTag): boolean;
|
|
77
|
+
isPersisted(tag: InstanceTag): boolean;
|
|
78
|
+
getProperty<T>(tag: InstanceTag, property: Property<T>, ownOnly: boolean): T | null;
|
|
79
|
+
// @ts-ignore
|
|
80
|
+
getProperties(tag: InstanceTag, ownOnly: boolean): Map<string, any>;
|
|
81
|
+
getRelated(tag: InstanceTag, relation: Relation<any, any>): string[];
|
|
82
|
+
isRelated(tag: InstanceTag, relation: Relation<any, any>, related: InstanceTag): boolean;
|
|
83
|
+
getMultiRelated(startTag: InstanceTag, relations: Relation<any, any>[]): string[];
|
|
84
|
+
getUniqueRelated(tag: InstanceTag, relation: Relation<any, any>): string | null;
|
|
85
|
+
getRecursiveRelated(startTag: InstanceTag, relation: Relation<any, any>, endTag: InstanceTag): string[];
|
|
86
|
+
findRecursive(startTag: InstanceTag, relation: Relation<any, any>, predicate: (string) => boolean): string | null;
|
|
87
|
+
findRelated(startTag: InstanceTag, relations: Relation<any, any>[], predicate: (string) => boolean): string | null;
|
|
88
|
+
findAllRelated(startTag: InstanceTag, relations: Relation<any, any>[], predicate: (string) => boolean): string[];
|
|
89
|
+
getExtendedModels(modelTag: InstanceTag, endTag?: InstanceTag): string[];
|
|
90
|
+
isExtending(modelTag: InstanceTag, extendedTag: InstanceTag): boolean;
|
|
91
|
+
getInstances(modelTag: InstanceTag): string[];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** @deprecated */
|
|
95
|
+
export class ListDef {
|
|
96
|
+
constructor(root: InstanceTag, transformers?: Transformer | Transformer[]);
|
|
97
|
+
getBaseTag(): string;
|
|
98
|
+
onReady(callback: (list: ListDef) => void): string;
|
|
99
|
+
offReady(id: string);
|
|
100
|
+
observeFirst(): Observable<Sync>;
|
|
101
|
+
observeAt(rank: number): Observable<Sync>;
|
|
102
|
+
getCurrentAt(rank: number): Sync | null;
|
|
103
|
+
observeRank(id: string): Observable<number>;
|
|
104
|
+
getCurrentRank(id: string): number | null;
|
|
105
|
+
observeSize(): Observable<number>;
|
|
106
|
+
getCurrentSize(): number;
|
|
107
|
+
forEach(onAdd: (item: Sync, index: string, list: ListDef) => void, onRemove: (itemTag: string) => void);
|
|
108
|
+
forEachCurrentValue(callback: (item: Sync, index: string, list: ListDef) => void);
|
|
109
|
+
transform(...transformers: Transformer[]): ListDef;
|
|
110
|
+
union(otherListDef: ListDef): ListDef;
|
|
111
|
+
filter(predicate: ListDefPredicate): ListDef;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
/* *************************
|
|
116
|
+
Transformers
|
|
117
|
+
************************* */
|
|
118
|
+
declare abstract class Transformer { }
|
|
119
|
+
|
|
120
|
+
export namespace transformers {
|
|
121
|
+
/** @deprecated */
|
|
122
|
+
export class Related<O extends CloudObject, D extends CloudObject> extends Transformer {
|
|
123
|
+
constructor(relation: InstanceTag, direction: Direction);
|
|
124
|
+
getTag(): string;
|
|
125
|
+
getDirection(): Direction;
|
|
126
|
+
getInverse(): transformers.Related<D, O>;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** @deprecated */
|
|
130
|
+
export class RecursiveRelated extends Transformer {
|
|
131
|
+
constructor(relation: InstanceTag, direction: Direction, minHops: number, maxHops: number);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** @deprecated */
|
|
135
|
+
export class Distinct extends Transformer {
|
|
136
|
+
constructor();
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** @deprecated */
|
|
140
|
+
export class Filter extends Transformer {
|
|
141
|
+
constructor(predicate: ListDefPredicate);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** @deprecated */
|
|
145
|
+
export class Limit extends Transformer {
|
|
146
|
+
constructor(limit: number, offset: number);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** @deprecated */
|
|
150
|
+
export class Sort extends Transformer {
|
|
151
|
+
constructor(comparator: Comparator, ascending?: boolean);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** @deprecated */
|
|
155
|
+
export class Union extends Transformer {
|
|
156
|
+
constructor(base: ListDef | InstanceTag, ...transformers: Transformer[]);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/* *************************
|
|
161
|
+
Predicates
|
|
162
|
+
************************* */
|
|
163
|
+
/** @deprecated */
|
|
164
|
+
export abstract class ListDefPredicate {
|
|
165
|
+
static create(predicate: (object: Sync) => Observable<boolean>): ListDefPredicate;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export namespace predicates {
|
|
169
|
+
/** @deprecated */
|
|
170
|
+
export class And extends ListDefPredicate {
|
|
171
|
+
constructor(...predicates: ListDefPredicate[]);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** @deprecated */
|
|
175
|
+
export class Or extends ListDefPredicate {
|
|
176
|
+
constructor(...predicates: ListDefPredicate[]);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** @deprecated */
|
|
180
|
+
export class Not extends ListDefPredicate {
|
|
181
|
+
constructor(predicate: ListDefPredicate);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** @deprecated */
|
|
185
|
+
export class Equals extends ListDefPredicate {
|
|
186
|
+
constructor(left: ValueDef, right: ValueDef);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** @deprecated */
|
|
190
|
+
export class Contains extends ListDefPredicate {
|
|
191
|
+
constructor(source: ValueDef, value: ValueDef);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** @deprecated */
|
|
195
|
+
export class Greater extends ListDefPredicate {
|
|
196
|
+
constructor(left: ValueDef, right: ValueDef);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** @deprecated */
|
|
200
|
+
export class Smaller extends ListDefPredicate {
|
|
201
|
+
constructor(left: ValueDef, right: ValueDef);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** @deprecated */
|
|
205
|
+
export class HasRelated extends ListDefPredicate {
|
|
206
|
+
constructor(relations: InstanceTag[], directions: Direction[], tag?: InstanceTag);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/** @deprecated */
|
|
210
|
+
export class InstanceOf extends ListDefPredicate {
|
|
211
|
+
constructor(models: InstanceTag[]);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/** @deprecated */
|
|
215
|
+
export class Regex extends ListDefPredicate {
|
|
216
|
+
constructor(source: ValueDef, regex: string, caseSensitive?: boolean);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/* *************************
|
|
221
|
+
ValueDefs
|
|
222
|
+
************************* */
|
|
223
|
+
declare abstract class ValueDef { }
|
|
224
|
+
|
|
225
|
+
/** @deprecated */
|
|
226
|
+
export namespace valuedefs {
|
|
227
|
+
/** @deprecated */
|
|
228
|
+
export class BooleanProperty extends ValueDef {
|
|
229
|
+
constructor(property: Property<boolean>, transformers?: Transformer[], baseTag?: string);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/** @deprecated */
|
|
233
|
+
export class DateTimeProperty extends ValueDef {
|
|
234
|
+
constructor(property: Property<Date>, transformers?: Transformer[], baseTag?: string);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** @deprecated */
|
|
238
|
+
export class NumberProperty extends ValueDef {
|
|
239
|
+
constructor(property: Property<number>, transformers?: Transformer[], baseTag?: string);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/** @deprecated */
|
|
243
|
+
export class StringProperty extends ValueDef {
|
|
244
|
+
constructor(property: Property<string>, transformers?: Transformer[], baseTag?: string);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** @deprecated */
|
|
248
|
+
export class Tag extends ValueDef {
|
|
249
|
+
constructor();
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/** @deprecated */
|
|
253
|
+
export class Constant extends ValueDef {
|
|
254
|
+
constructor(value: any);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/* *************************
|
|
259
|
+
Comparator
|
|
260
|
+
************************* */
|
|
261
|
+
/** @deprecated */
|
|
262
|
+
export abstract class Comparator {
|
|
263
|
+
static create(comparator: (object1: Sync, object2: Sync) => Observable<number>): Comparator;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export namespace comparators {
|
|
267
|
+
/** @deprecated */
|
|
268
|
+
export class Number extends Comparator {
|
|
269
|
+
constructor(value: ValueDef);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/** @deprecated */
|
|
273
|
+
export class String extends Comparator {
|
|
274
|
+
constructor(value: ValueDef);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/** @deprecated */
|
|
278
|
+
export class DateTime extends Comparator {
|
|
279
|
+
constructor(value: ValueDef);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
@@ -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
|
+
|