@olympeio/runtime-node 9.2.2 → 9.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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.sc/datamodel/01_language.newInst.json +1 -1
- package/import/olympe.sc/datamodel/01_language.newRel.json +1 -1
- package/index.js +820 -808
- package/package.json +1 -1
- package/types/base.d.ts +33 -30
- package/types/cloud.d.ts +68 -54
- package/types/legacy.d.ts +9 -9
- package/types/runtime.d.ts +11 -12
- package/types/utils.d.ts +36 -6
package/package.json
CHANGED
package/types/base.d.ts
CHANGED
|
@@ -6,15 +6,16 @@ import {PropertyModel, Query, QueryResult, QuerySingle} from "./cloud";
|
|
|
6
6
|
// Primitives
|
|
7
7
|
// **********************************
|
|
8
8
|
|
|
9
|
-
declare type Class<T> = { new(): T };
|
|
10
9
|
/**
|
|
11
10
|
* A Tag can be either a `string`, a `HasTag` (CloudObject instance, Property, Relation, ...)
|
|
12
11
|
* or the class constructor for a `CloudObject`
|
|
13
12
|
*/
|
|
14
|
-
export type Tag = string | HasTag |
|
|
13
|
+
export type Tag = string | HasTag | typeof CloudObject;
|
|
15
14
|
|
|
16
15
|
export type List<T> = Array<T> | (T extends CloudObject | CloudObject[] ? QueryResult<T> : never);
|
|
17
16
|
|
|
17
|
+
export type Class<T> = {new (): T};
|
|
18
|
+
|
|
18
19
|
/**
|
|
19
20
|
* Generates a unique olympe tag used to identify `CloudObjects`
|
|
20
21
|
*
|
|
@@ -50,11 +51,11 @@ export interface HasTag {
|
|
|
50
51
|
* Contexts have parents and children, they represent the lifecycle of bricks.
|
|
51
52
|
* They contain callbacks executed at specific time of the brick lifespan.
|
|
52
53
|
*
|
|
53
|
-
* Each time a brick is updated with new inputs, {@
|
|
54
|
-
* executing all callbacks registered with {@
|
|
54
|
+
* Each time a brick is updated with new inputs, {@apilink Context.clear} is called,
|
|
55
|
+
* executing all callbacks registered with {@apilink Context.onClear}.
|
|
55
56
|
*
|
|
56
|
-
* When a brick is destroyed, {@
|
|
57
|
-
* executing all callbacks registered with {@
|
|
57
|
+
* When a brick is destroyed, {@apilink Context.destroy} is called,
|
|
58
|
+
* executing all callbacks registered with {@apilink Context.onClear} and {@apilink Context.onDestroy}
|
|
58
59
|
*/
|
|
59
60
|
export abstract class Context {
|
|
60
61
|
/**
|
|
@@ -78,7 +79,7 @@ export abstract class Context {
|
|
|
78
79
|
onDestroy(callback: () => void): string;
|
|
79
80
|
|
|
80
81
|
/**
|
|
81
|
-
* Remove a previously registered callback with {@
|
|
82
|
+
* Remove a previously registered callback with {@apilink Context.onDestroy} method using its id.
|
|
82
83
|
*
|
|
83
84
|
* @param callbackId the id of the callback to unregister
|
|
84
85
|
*/
|
|
@@ -95,7 +96,7 @@ export abstract class Context {
|
|
|
95
96
|
onClear(callback: () => void): string;
|
|
96
97
|
|
|
97
98
|
/**
|
|
98
|
-
* Remove a previously registered callback with {@
|
|
99
|
+
* Remove a previously registered callback with {@apilink Context.onClear} method using its id.
|
|
99
100
|
*
|
|
100
101
|
* @param id the id of the callback to unregister
|
|
101
102
|
*/
|
|
@@ -107,18 +108,18 @@ export abstract class Context {
|
|
|
107
108
|
* In essence, it represents a remote reference to an object in the data cloud.
|
|
108
109
|
* It is identified by its unique ID, or tag. From a `CloudObject` you can access related `CloudObjects`.
|
|
109
110
|
*
|
|
110
|
-
* A `CloudObject` can be instantiated via the
|
|
111
|
+
* A `CloudObject` can be instantiated via the {@apilink Tag} of its model, and it can be instantiated multiple times with different properties values.
|
|
111
112
|
* *Data types* defined in DRAW are such `CloudObjects`, instances of Data types are also `CloudObjects`.
|
|
112
113
|
*
|
|
113
114
|
* **Example:**
|
|
114
115
|
* ```javascript
|
|
115
|
-
* const dcObject =
|
|
116
|
+
* const dcObject = CloudObject.get(tag);
|
|
116
117
|
* ```
|
|
117
118
|
*/
|
|
118
119
|
export abstract class CloudObject implements HasTag {
|
|
119
120
|
/**
|
|
120
121
|
* The attributes of a CloudObject are called properties. Properties can be of different types,
|
|
121
|
-
* e.g. `Property<string>`, `Property<number>`, Property<Date>`.
|
|
122
|
+
* e.g. `Property<string>`, `Property<number>`, `Property<Date>`.
|
|
122
123
|
*
|
|
123
124
|
* If a `Person` `CloudObject` has an `age` property, all the instances of `Person` can access
|
|
124
125
|
* the `age` property using the same tag, the tag of the `age` property. This method returns all
|
|
@@ -129,7 +130,7 @@ export abstract class CloudObject implements HasTag {
|
|
|
129
130
|
static getProperties(): Property<any>[];
|
|
130
131
|
|
|
131
132
|
/**
|
|
132
|
-
* Return all the relations whose origin OR destination is the
|
|
133
|
+
* Return all the relations whose origin OR destination is the {@apilink CloudObject} associated to this class.
|
|
133
134
|
*
|
|
134
135
|
* @return All relations defined on the current data type. It can be the destination or the origin of the relations.
|
|
135
136
|
*/
|
|
@@ -147,8 +148,9 @@ export abstract class CloudObject implements HasTag {
|
|
|
147
148
|
* Get the CloudObject whose tag is specified.
|
|
148
149
|
*
|
|
149
150
|
* This only works if the `CloudObject` is already present in the local datacloud cache.
|
|
150
|
-
* (NB: you can use a {@
|
|
151
|
+
* (NB: you can use a {@apilink Query} to retrieve a distant {@apilink CloudObject})
|
|
151
152
|
*
|
|
153
|
+
* @static
|
|
152
154
|
* @param tag tag of the `CloudObject`
|
|
153
155
|
* @return `CloudObject` specified by the tag
|
|
154
156
|
*/
|
|
@@ -161,6 +163,7 @@ export abstract class CloudObject implements HasTag {
|
|
|
161
163
|
*
|
|
162
164
|
* @param properties mappings of (propertyTag -> propertyValue)
|
|
163
165
|
* @param model tag of the model of the `CloudObject` you want to create.
|
|
166
|
+
* @param source
|
|
164
167
|
* @return newly created `CloudObject`
|
|
165
168
|
*/
|
|
166
169
|
static createWith<T>(this: Class<T>, properties: Map<Tag, any>, model?: Tag, source?: string): T;
|
|
@@ -223,7 +226,7 @@ export abstract class CloudObject implements HasTag {
|
|
|
223
226
|
/**
|
|
224
227
|
* Start a query from this instance and follow the relation given as argument.
|
|
225
228
|
* The query starts from this single instance, and follows a relation to an arbitrary
|
|
226
|
-
* number of destination instances. See
|
|
229
|
+
* number of destination instances. See {@apilink Query.follow | Query.follow(relation)}
|
|
227
230
|
*
|
|
228
231
|
* The following are equivalent:
|
|
229
232
|
* ```javascript
|
|
@@ -249,7 +252,7 @@ export abstract class CloudObject implements HasTag {
|
|
|
249
252
|
|
|
250
253
|
// Properties getters
|
|
251
254
|
/**
|
|
252
|
-
* Get the current value of the specified property for this
|
|
255
|
+
* Get the current value of the specified property for this {@apilink CloudObject} instance
|
|
253
256
|
*
|
|
254
257
|
* @param property property or property's tag
|
|
255
258
|
* @return property value
|
|
@@ -260,10 +263,10 @@ export abstract class CloudObject implements HasTag {
|
|
|
260
263
|
* Get an observable to the current value of the specified property for this `CloudObject` instance.
|
|
261
264
|
*
|
|
262
265
|
* The observable gets the new value each time the property gets updated in the datacloud.
|
|
263
|
-
* The observable gets completed automatically once the specified context is
|
|
266
|
+
* The observable gets completed automatically once the specified context is {@apilink Context.onClear | cleared}.
|
|
264
267
|
* If `waitForValue` is set to FALSE (TRUE by default), the first value received by the observable is null if there is no value at call time.
|
|
265
268
|
*
|
|
266
|
-
* @param context
|
|
269
|
+
* @param context context to which the Observable is attached
|
|
267
270
|
* @param property property or property's tag to observe
|
|
268
271
|
* @param waitForValue [=true] whether the observable wait for a first value to get a value.
|
|
269
272
|
* @return Observable of property values
|
|
@@ -274,9 +277,9 @@ export abstract class CloudObject implements HasTag {
|
|
|
274
277
|
* Get an observable to pair [property, value] for this `CloudObject` instance.
|
|
275
278
|
*
|
|
276
279
|
* The observable gets the new value each time any property gets updated in the datacloud.
|
|
277
|
-
* The observable gets completed automatically once the specified context is
|
|
280
|
+
* The observable gets completed automatically once the specified context is {@apilink Context.onClear | cleared}.
|
|
278
281
|
*
|
|
279
|
-
* @param context
|
|
282
|
+
* @param context Context to which the Observable will be attached
|
|
280
283
|
* @return Observable of property values
|
|
281
284
|
*/
|
|
282
285
|
observeProperties<T>(context: Context): Observable<[Property<T>, T]>;
|
|
@@ -296,12 +299,12 @@ export abstract class CloudObject implements HasTag {
|
|
|
296
299
|
|
|
297
300
|
/**
|
|
298
301
|
* Relation between a `CloudObject`and its model
|
|
299
|
-
* instance --modelRel-> model
|
|
302
|
+
* `instance --modelRel-> model`
|
|
300
303
|
*/
|
|
301
304
|
static modelRel: Relation<CloudObject, CloudObject>;
|
|
302
305
|
|
|
303
306
|
/**
|
|
304
|
-
* Inverse relation of {@
|
|
307
|
+
* Inverse relation of {@apilink modelRel} between a model and its instances
|
|
305
308
|
* Equivalent to `modelRel.getInverse()`
|
|
306
309
|
*/
|
|
307
310
|
static instancesRel: Relation<CloudObject, CloudObject>;
|
|
@@ -310,12 +313,12 @@ export abstract class CloudObject implements HasTag {
|
|
|
310
313
|
* from another `CloudObject` model to mimic their behaviour.
|
|
311
314
|
*
|
|
312
315
|
* Relation from a model to the CloudObject model it extends.
|
|
313
|
-
* A --extendRel-> B
|
|
316
|
+
* `A --extendRel-> B`
|
|
314
317
|
* A inherits B's properties and relations.
|
|
315
318
|
*/
|
|
316
319
|
static extendRel: Relation<CloudObject, CloudObject>;
|
|
317
320
|
/**
|
|
318
|
-
* Inverse relation of {@
|
|
321
|
+
* Inverse relation of {@apilink extendRel}
|
|
319
322
|
*/
|
|
320
323
|
static extendedByRel: Relation<CloudObject, CloudObject>;
|
|
321
324
|
/**
|
|
@@ -337,15 +340,15 @@ export abstract class CloudObject implements HasTag {
|
|
|
337
340
|
export interface Property<T> extends HasTag {}
|
|
338
341
|
|
|
339
342
|
/**
|
|
340
|
-
* Relations are directed from A
|
|
343
|
+
* Relations are directed from A to B and can be followed in either direction.
|
|
341
344
|
*/
|
|
342
345
|
export enum Direction {
|
|
343
346
|
/**
|
|
344
|
-
* For relation A
|
|
347
|
+
* For relation A to B, go to A, the origin
|
|
345
348
|
*/
|
|
346
349
|
ORIGIN = '<',
|
|
347
350
|
/**
|
|
348
|
-
* For relation A
|
|
351
|
+
* For relation A to B, go to B, the destination
|
|
349
352
|
*/
|
|
350
353
|
DESTINATION = '>'
|
|
351
354
|
}
|
|
@@ -412,12 +415,12 @@ export interface Relation<O extends CloudObject, D extends CloudObject> extends
|
|
|
412
415
|
*
|
|
413
416
|
* This creates the link between a class and an DataType in the database.
|
|
414
417
|
* Once this link is created, all the instances of the DataType (model)
|
|
415
|
-
* are instantiated as JS objects using the specified class (see
|
|
418
|
+
* are instantiated as JS objects using the specified class (see {@apilink CloudObject.get})
|
|
416
419
|
*
|
|
417
420
|
* @param tag tag of the DataType
|
|
418
421
|
* @param object `CloudObject` constructor
|
|
419
422
|
*/
|
|
420
|
-
export function register(tag: Tag, object:
|
|
423
|
+
export function register(tag: Tag, object: typeof CloudObject): void;
|
|
421
424
|
|
|
422
425
|
/**
|
|
423
426
|
* Create a constant property object which has the specified tag and type to be used in coded bricks.
|
|
@@ -431,7 +434,7 @@ export function defineProperty<T>(tag: Tag, type?: Class<T>): Property<T>;
|
|
|
431
434
|
/**
|
|
432
435
|
* Create a constant relation object between two specified DataTypes.
|
|
433
436
|
*
|
|
434
|
-
* That constant is used especially to create queries see
|
|
437
|
+
* That constant is used especially to create queries see {@apilink Query.follow | Query.follow(relation)}
|
|
435
438
|
*
|
|
436
439
|
* @param tag tag of the relation
|
|
437
440
|
* @param origin origin DataType of the relation
|
|
@@ -443,7 +446,7 @@ export function defineRelation<O extends CloudObject, D extends CloudObject>(tag
|
|
|
443
446
|
/**
|
|
444
447
|
* Create a constant relation object between two generic `CloudObjects`
|
|
445
448
|
*
|
|
446
|
-
* That constant is used especially to create queries see
|
|
449
|
+
* That constant is used especially to create queries see {@apilink Query.follow | Query.follow(relation)}
|
|
447
450
|
*
|
|
448
451
|
* @param tag tag of the relation
|
|
449
452
|
* @param direction direction of the relation, pointing towards origin or destination. Default is `DESTINATION`
|
package/types/cloud.d.ts
CHANGED
|
@@ -48,7 +48,7 @@ export class RelationModel extends CloudObject {
|
|
|
48
48
|
/**
|
|
49
49
|
* Relation from the origin data type to the RelationModel
|
|
50
50
|
* */
|
|
51
|
-
static originModelRel: Relation<
|
|
51
|
+
static originModelRel: Relation<RelationModel, CloudObject>;
|
|
52
52
|
/**
|
|
53
53
|
* Relation from a RelationModel to the destination data type
|
|
54
54
|
* */
|
|
@@ -68,35 +68,35 @@ export class RelationModel extends CloudObject {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
|
-
* StringModel represents a {@
|
|
71
|
+
* StringModel represents a {@apilink PropertyModel} for a string property of a data type.
|
|
72
72
|
*/
|
|
73
73
|
export class StringModel extends CloudObject {
|
|
74
74
|
static valueProp: Property<string>;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
/**
|
|
78
|
-
* NumberModel represents a {@
|
|
78
|
+
* NumberModel represents a {@apilink PropertyModel} for a number property of a data type.
|
|
79
79
|
*/
|
|
80
80
|
export class NumberModel extends CloudObject {
|
|
81
81
|
static valueProp: Property<number>;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
/**
|
|
85
|
-
* BooleanModel represents a {@
|
|
85
|
+
* BooleanModel represents a {@apilink PropertyModel} for a boolean property of a data type.
|
|
86
86
|
*/
|
|
87
87
|
export class BooleanModel extends CloudObject {
|
|
88
88
|
static valueProp: Property<boolean>;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
|
-
* DatetimeModel represents a {@
|
|
92
|
+
* DatetimeModel represents a {@apilink PropertyModel} for a datetime property of a data type.
|
|
93
93
|
*/
|
|
94
94
|
export class DatetimeModel extends CloudObject {
|
|
95
95
|
static valueProp: Property<Date>;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
|
-
* ColorModel represents a {@
|
|
99
|
+
* ColorModel represents a {@apilink PropertyModel} for a color property of a data type.
|
|
100
100
|
*/
|
|
101
101
|
export class ColorModel extends CloudObject {
|
|
102
102
|
static valueProp: Property<Color>;
|
|
@@ -188,7 +188,7 @@ export class Enum extends CloudObject {
|
|
|
188
188
|
/**
|
|
189
189
|
* Create an empty `Enum?` without any value
|
|
190
190
|
*
|
|
191
|
-
* See {@
|
|
191
|
+
* See {@apilink EnumValue.createValue} to create values for an Enum.
|
|
192
192
|
*
|
|
193
193
|
* @param transaction transaction in which to create the Enum
|
|
194
194
|
* @param name optional name of the Enum
|
|
@@ -239,28 +239,28 @@ export class EnumValue extends CloudObject {
|
|
|
239
239
|
// -------------------------
|
|
240
240
|
|
|
241
241
|
/**
|
|
242
|
-
* A `Workflow` is a sequence of {@
|
|
243
|
-
* {@
|
|
244
|
-
* The `Workflow` also historize the {@
|
|
242
|
+
* A `Workflow` is a sequence of {@apilink WorkflowState} in which instances of a model goes through.
|
|
243
|
+
* {@apilink WorkflowState} are linked by {@apilink WorkflowTransition} that can have an optional _process function_.
|
|
244
|
+
* The `Workflow` also historize the {@apilink WorkflowState} of the instance and optionally serialize the object itself in a {@apilink WorkflowObjectState}.
|
|
245
245
|
*/
|
|
246
246
|
export class Workflow extends CloudObject {
|
|
247
247
|
/** Is the instance serialization enabled or not */
|
|
248
248
|
static serializationEnabledProp: Property<boolean>;
|
|
249
249
|
/** The model to which the `Workflow` is associated */
|
|
250
250
|
static dataTypeRel: Relation<Workflow, CloudObject>;
|
|
251
|
-
/** The {@
|
|
251
|
+
/** The {@apilink WorkflowState} that are in the `Workflow` */
|
|
252
252
|
static statesRel: Relation<Workflow, WorkflowState>;
|
|
253
|
-
/** The initial {@
|
|
253
|
+
/** The initial {@apilink WorkflowState} of the `Workflow` */
|
|
254
254
|
static initialStateRel: Relation<Workflow, WorkflowState>;
|
|
255
255
|
}
|
|
256
256
|
|
|
257
257
|
/**
|
|
258
|
-
* A `WorkflowState` defines a state in a {@
|
|
258
|
+
* A `WorkflowState` defines a state in a {@apilink Workflow}.
|
|
259
259
|
*/
|
|
260
260
|
export class WorkflowState extends CloudObject { /* empty */ }
|
|
261
261
|
|
|
262
262
|
/**
|
|
263
|
-
* A `WorkflowTransition` defines a transition between 2 {@
|
|
263
|
+
* A `WorkflowTransition` defines a transition between 2 {@apilink WorkflowState}.
|
|
264
264
|
* It has a direction (`fromStateRel` to `toStateRel`) and can have an optional _process function_.
|
|
265
265
|
* The _process function_ (`processRefProp`) is automatically triggered when the transition occurs.
|
|
266
266
|
*/
|
|
@@ -270,26 +270,26 @@ export class WorkflowTransition extends CloudObject {
|
|
|
270
270
|
* It has this signature: (ControlFlow, CloudObject, User, Map) -> (ControlFlow, ErrorFlow)
|
|
271
271
|
*/
|
|
272
272
|
static processRefProp: Property<Brick>;
|
|
273
|
-
/** The {@
|
|
273
|
+
/** The {@apilink WorkflowState} from which this transition starts */
|
|
274
274
|
static fromStateRel: Relation<WorkflowTransition, WorkflowState>;
|
|
275
|
-
/** The {@
|
|
275
|
+
/** The {@apilink WorkflowState} to which this transition ends */
|
|
276
276
|
static toStateRel: Relation<WorkflowTransition, WorkflowState>;
|
|
277
277
|
}
|
|
278
278
|
|
|
279
279
|
/**
|
|
280
280
|
* A `WorkflowObjectState` represents the state of an instance at a certain point in time.
|
|
281
|
-
* It is automatically created when initializing a {@
|
|
281
|
+
* It is automatically created when initializing a {@apilink Workflow} on an instance or when triggering a {@apilink WorkflowTransition}.
|
|
282
282
|
*/
|
|
283
283
|
export class WorkflowObjectState extends CloudObject {
|
|
284
|
-
/** The name of the {@
|
|
284
|
+
/** The name of the {@apilink Workflow} associated */
|
|
285
285
|
static workflowProp: Property<string>;
|
|
286
|
-
/** The name of the {@
|
|
286
|
+
/** The name of the {@apilink WorkflowState} */
|
|
287
287
|
static stateProp: Property<string>;
|
|
288
|
-
/** The name (login) of the {@
|
|
288
|
+
/** The name (login) of the {@apilink User} */
|
|
289
289
|
static assigneeProp: Property<string>;
|
|
290
290
|
/** The point in time of this object state */
|
|
291
291
|
static dateTimeProp: Property<Date>;
|
|
292
|
-
/** If the {@
|
|
292
|
+
/** If the {@apilink Workflow} has serialization enabled, the object's property are saved here in JSON */
|
|
293
293
|
static serializedObjectProp: Property<string>;
|
|
294
294
|
/** The related instance this object state represents */
|
|
295
295
|
static objectRel: Relation<WorkflowObjectState, CloudObject>;
|
|
@@ -373,7 +373,7 @@ export class Transaction {
|
|
|
373
373
|
* A custom map can specify property values for the instance.
|
|
374
374
|
*
|
|
375
375
|
* A source can be the orchestrator ('server'), local ('self') or
|
|
376
|
-
* an external data source (
|
|
376
|
+
* an external data source (tag of DBConnector). The source is where
|
|
377
377
|
* the object is persisted and its true value outside local scopes.
|
|
378
378
|
*
|
|
379
379
|
* @param model tag of the model of the instance to be created
|
|
@@ -398,7 +398,7 @@ export class Transaction {
|
|
|
398
398
|
* Update multiple properties of a single instance
|
|
399
399
|
*
|
|
400
400
|
* @param instance tag of the instance to be updated
|
|
401
|
-
* @param properties
|
|
401
|
+
* @param properties map of properties to update
|
|
402
402
|
* @return this transaction
|
|
403
403
|
*/
|
|
404
404
|
multiUpdate(instance: Tag, properties: Map<Tag, any>): this;
|
|
@@ -476,7 +476,7 @@ export class Transaction {
|
|
|
476
476
|
* `source` can be specified as :
|
|
477
477
|
* 1. the orchestrator ('server'),
|
|
478
478
|
* 2. local ('self') or
|
|
479
|
-
* 3. an external data source (
|
|
479
|
+
* 3. an external data source (Tag of a `DBConnector`)
|
|
480
480
|
*
|
|
481
481
|
* The source of a data object is where the object is persisted.
|
|
482
482
|
*
|
|
@@ -516,21 +516,21 @@ export class Transaction {
|
|
|
516
516
|
afterExecution(callback: (success: boolean, message?: string) => void): this;
|
|
517
517
|
|
|
518
518
|
/**
|
|
519
|
-
* Execute atomically the transaction at the
|
|
519
|
+
* Execute atomically the transaction at the data sources. Return the transaction result if succeeds.
|
|
520
520
|
*
|
|
521
|
-
* @return promise resolving if the transaction succeeds,
|
|
521
|
+
* @return promise resolving with the corresponding TransactionResult if the transaction succeeds,
|
|
522
522
|
* rejecting if the transaction fails
|
|
523
523
|
*/
|
|
524
|
-
execute(): Promise<
|
|
524
|
+
execute(): Promise<TransactionResult>;
|
|
525
525
|
|
|
526
526
|
/**
|
|
527
|
-
* Execute atomically a transaction at the source
|
|
527
|
+
* Execute atomically a transaction at the data source and returns the transaction result if succeeds.
|
|
528
528
|
* The `large` mode sends the transaction over HTTP
|
|
529
529
|
*
|
|
530
|
-
* @return promise resolving if the transaction succeeds,
|
|
530
|
+
* @return promise resolving with the corresponding TransactionResult if the transaction succeeds,
|
|
531
531
|
* rejecting if the transaction fails.
|
|
532
532
|
*/
|
|
533
|
-
executeAsLarge(): Promise<
|
|
533
|
+
executeAsLarge(): Promise<TransactionResult>;
|
|
534
534
|
|
|
535
535
|
/**
|
|
536
536
|
* Start a transaction using an existing transaction in the provided context
|
|
@@ -551,6 +551,20 @@ export class Transaction {
|
|
|
551
551
|
static process($: BrickContext, transaction: Transaction): Promise<boolean>;
|
|
552
552
|
}
|
|
553
553
|
|
|
554
|
+
/**
|
|
555
|
+
* A transaction result is the object received after a transaction has been executed successfully.
|
|
556
|
+
* It provides information about what has been done.
|
|
557
|
+
*/
|
|
558
|
+
export class TransactionResult {
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* Return the ordered list of CloudObjects created in this transaction.
|
|
562
|
+
*
|
|
563
|
+
* @return the list of CloudObjects instances
|
|
564
|
+
*/
|
|
565
|
+
getCreatedObjects(): CloudObject[];
|
|
566
|
+
}
|
|
567
|
+
|
|
554
568
|
/**
|
|
555
569
|
* BurstTransactions are designed to continuously apply high rates of updates on properties (FIFO ordering).
|
|
556
570
|
* The only operation supported by BurstTransactions is to update properties of an instance.
|
|
@@ -569,14 +583,14 @@ export class BurstTransaction {
|
|
|
569
583
|
* Push all property values from specified Observable to update specified object
|
|
570
584
|
*
|
|
571
585
|
* @param object the object to update
|
|
572
|
-
* @param values observable
|
|
586
|
+
* @param values observable mapping properties to new values
|
|
573
587
|
*/
|
|
574
588
|
push<T>(object: CloudObject, values: Observable<Map<Property<T>, T>>): void;
|
|
575
589
|
|
|
576
590
|
/**
|
|
577
591
|
* Commit and close the burst transaction
|
|
578
592
|
*
|
|
579
|
-
* @return Promise
|
|
593
|
+
* @return A `Promise` completing with commit success/failure
|
|
580
594
|
*/
|
|
581
595
|
complete(): Promise<void>;
|
|
582
596
|
}
|
|
@@ -590,7 +604,7 @@ export class BurstTransaction {
|
|
|
590
604
|
* It contains the result of a query at a specific time.
|
|
591
605
|
*
|
|
592
606
|
* The keys are tags (e.g. `myTag`) that correspond to a `CloudObject` (e.g. `myCloudObject`).
|
|
593
|
-
* When the {@
|
|
607
|
+
* When the {@apilink Query} contains more than one {@apilink Query.andReturn Query.andReturn()} clause,
|
|
594
608
|
* keys are composite tags (e.g. `'tag1.tag2.tag3'`) and values are tuples of `CloudObjects` (e.g. `[cloudObj1, cloudObj2, cloudObj3]`).
|
|
595
609
|
* Such a QueryResult can be obtained via:
|
|
596
610
|
* ```javascript
|
|
@@ -697,7 +711,7 @@ export class QueryResult<T extends CloudObject | CloudObject[]> {
|
|
|
697
711
|
getAt(index: number): T | null;
|
|
698
712
|
|
|
699
713
|
/**
|
|
700
|
-
* Returns an array equivalent to
|
|
714
|
+
* Returns an array equivalent to {@apilink QueryResult.toArray | this.toArray().push(...object)}
|
|
701
715
|
*
|
|
702
716
|
* This operation returns a new array and does not modify this QueryResult.
|
|
703
717
|
*
|
|
@@ -709,7 +723,7 @@ export class QueryResult<T extends CloudObject | CloudObject[]> {
|
|
|
709
723
|
/**
|
|
710
724
|
* Returns the QueryResult values as an array whose last value has been removed.
|
|
711
725
|
*
|
|
712
|
-
* If
|
|
726
|
+
* If {@apilink QueryResult.size} is 0 or 1, this method returns an empty array.
|
|
713
727
|
*
|
|
714
728
|
* This operation returns a new array and does not modify this QueryResult.
|
|
715
729
|
*
|
|
@@ -720,7 +734,7 @@ export class QueryResult<T extends CloudObject | CloudObject[]> {
|
|
|
720
734
|
/**
|
|
721
735
|
* Returns the QueryResult values as an array whose first value has been removed.
|
|
722
736
|
*
|
|
723
|
-
* If
|
|
737
|
+
* If {@apilink QueryResult.size} is 0 or 1, this method returns an empty array.
|
|
724
738
|
*
|
|
725
739
|
* This operation returns a new array and does not modify this QueryResult.
|
|
726
740
|
*
|
|
@@ -732,7 +746,7 @@ export class QueryResult<T extends CloudObject | CloudObject[]> {
|
|
|
732
746
|
* Returns the new values added since the last `QueryResult` update.
|
|
733
747
|
* In other words, `getAdded` returns the new values that exists in this query result, but did not in the previous query result pushed by the Observable.
|
|
734
748
|
*
|
|
735
|
-
* This applies only when
|
|
749
|
+
* This applies only when {@apilink Query.observe | observing} a {@apilink Query}.
|
|
736
750
|
*
|
|
737
751
|
* @return values added
|
|
738
752
|
*/
|
|
@@ -742,7 +756,7 @@ export class QueryResult<T extends CloudObject | CloudObject[]> {
|
|
|
742
756
|
* Returns the keys of values removed since the last `QueryResult` update.
|
|
743
757
|
* In other words, `getRemoved` returns the old values that existed in the previous query result, but are no longer present in this query result pushed by the Observable.
|
|
744
758
|
*
|
|
745
|
-
* This applies only when
|
|
759
|
+
* This applies only when {@apilink Query.observe | observing} a {@apilink Query}.
|
|
746
760
|
*
|
|
747
761
|
* @return keys of the removed values
|
|
748
762
|
*/
|
|
@@ -751,7 +765,7 @@ export class QueryResult<T extends CloudObject | CloudObject[]> {
|
|
|
751
765
|
/**
|
|
752
766
|
* Returns an array containing the values matching the provided filter predicate.
|
|
753
767
|
*
|
|
754
|
-
* @param predicate filter {@
|
|
768
|
+
* @param predicate filter {@apilink Predicate}
|
|
755
769
|
* @return array of matching values
|
|
756
770
|
*/
|
|
757
771
|
filter(predicate: (entry: T, index: number) => boolean): T[];
|
|
@@ -798,7 +812,7 @@ export class QueryResult<T extends CloudObject | CloudObject[]> {
|
|
|
798
812
|
/**
|
|
799
813
|
* Return a reduced value for this QueryResult.
|
|
800
814
|
*
|
|
801
|
-
* The specified `reducer` callback reduces the QueryResult values
|
|
815
|
+
* The specified `reducer` callback reduces the QueryResult values. Similar to `Array.reduce()`.
|
|
802
816
|
*
|
|
803
817
|
* @param reducer callback
|
|
804
818
|
* @param initial initial value of the accumulator
|
|
@@ -813,8 +827,8 @@ export class QueryResult<T extends CloudObject | CloudObject[]> {
|
|
|
813
827
|
*
|
|
814
828
|
* - the keys of the QueryResults are concatenated
|
|
815
829
|
* - the values of the QueryResults are concatenated
|
|
816
|
-
* - the arrays returned by {@
|
|
817
|
-
* - the arrays returned by {@
|
|
830
|
+
* - the arrays returned by {@apilink QueryResult.getAdded} are concatenated
|
|
831
|
+
* - the arrays returned by {@apilink QueryResult.getRemoved} are concatenated
|
|
818
832
|
*
|
|
819
833
|
* Example : ```javascript
|
|
820
834
|
* const result1 = Query.fromInstances(myModel1).executeFromCache();
|
|
@@ -898,14 +912,14 @@ export class Query<T extends CloudObject, R> {
|
|
|
898
912
|
* @param model tag/class of the model to find the instances of
|
|
899
913
|
* @param source optional source of the data to answer the query
|
|
900
914
|
* A source can be the orchestrator ('server'), local ('self') or
|
|
901
|
-
* an external data source (
|
|
915
|
+
* an external data source (Tag of a `DBConnectorTag`)
|
|
902
916
|
* @return a new query object starting from model instances
|
|
903
917
|
*/
|
|
904
918
|
static instancesOf<T extends Tag>(model: Class<T> | Tag, source?: string): Query<T extends CloudObject ? T : CloudObject, never>;
|
|
905
919
|
|
|
906
920
|
/**
|
|
907
921
|
* Instruct the query to follow a specified relation. This does not add any key-value pair to the result.
|
|
908
|
-
* (see {@
|
|
922
|
+
* (see {@apilink Query.andReturn}). This operation defines a new step in the path defined by our graph query.
|
|
909
923
|
*
|
|
910
924
|
* Example:
|
|
911
925
|
* Find the model of a single object.
|
|
@@ -919,7 +933,7 @@ export class Query<T extends CloudObject, R> {
|
|
|
919
933
|
follow<D extends CloudObject>(relation: Relation<T, D>): Query<D, R>;
|
|
920
934
|
|
|
921
935
|
/**
|
|
922
|
-
* Follow a relation recursively, see {@
|
|
936
|
+
* Follow a relation recursively, see {@apilink Query.follow}.
|
|
923
937
|
* The relation that is followed is automatically recursively followed.
|
|
924
938
|
* All nodes that are recursively followed are part of the same step in the path defined by this graph query.
|
|
925
939
|
*
|
|
@@ -948,7 +962,7 @@ export class Query<T extends CloudObject, R> {
|
|
|
948
962
|
|
|
949
963
|
/**
|
|
950
964
|
* Define a filter operation on the current working set of nodes.
|
|
951
|
-
* It filters out instances that don't match the given {@
|
|
965
|
+
* It filters out instances that don't match the given {@apilink Predicate}
|
|
952
966
|
*
|
|
953
967
|
* @param predicate
|
|
954
968
|
* @return a new query object with the new filter operation
|
|
@@ -1007,7 +1021,7 @@ export class Query<T extends CloudObject, R> {
|
|
|
1007
1021
|
* ascending order.
|
|
1008
1022
|
*
|
|
1009
1023
|
* @param property the property used for sorting
|
|
1010
|
-
* @param order optional
|
|
1024
|
+
* @param order optional {@apilink Order.ASC} (default) or {@apilink Order.DESC} order
|
|
1011
1025
|
* @return new query with sort operation
|
|
1012
1026
|
*/
|
|
1013
1027
|
sortBy(property: Property<any>, order?: Order): Query<T, R>;
|
|
@@ -1027,9 +1041,9 @@ export class Query<T extends CloudObject, R> {
|
|
|
1027
1041
|
*
|
|
1028
1042
|
* The observable gets the new value each time data modification in the datacloud changes the result of the query.
|
|
1029
1043
|
*
|
|
1030
|
-
* The observable gets completed automatically once the specified context is
|
|
1044
|
+
* The observable gets completed automatically once the specified context is {@apilink Context.onClear | cleared}.
|
|
1031
1045
|
*
|
|
1032
|
-
* @param context
|
|
1046
|
+
* @param context {@apilink Context} to which the Observable is attached
|
|
1033
1047
|
* @return Observable of QueryResult values
|
|
1034
1048
|
*/
|
|
1035
1049
|
observe(context: Context): Observable<QueryResult<R extends never ? T : R extends CloudObject | CloudObject[] ? R : never>>;
|
|
@@ -1054,7 +1068,7 @@ export class Query<T extends CloudObject, R> {
|
|
|
1054
1068
|
export class QuerySingle<T extends CloudObject> {
|
|
1055
1069
|
/**
|
|
1056
1070
|
* Create a `query single` from a single node.
|
|
1057
|
-
* See
|
|
1071
|
+
* See {@apilink Query.from}
|
|
1058
1072
|
*
|
|
1059
1073
|
* @param object starting node for the graph query single
|
|
1060
1074
|
* @return new query single only accepting 0..1 relations
|
|
@@ -1063,7 +1077,7 @@ export class QuerySingle<T extends CloudObject> {
|
|
|
1063
1077
|
|
|
1064
1078
|
/**
|
|
1065
1079
|
* Follow a 0..1 relation
|
|
1066
|
-
* See
|
|
1080
|
+
* See {@apilink Query.follow | Query.follow()}
|
|
1067
1081
|
*
|
|
1068
1082
|
* @param relation relation to next node
|
|
1069
1083
|
* @return new query single with follow operation
|
|
@@ -1071,7 +1085,7 @@ export class QuerySingle<T extends CloudObject> {
|
|
|
1071
1085
|
follow<D extends CloudObject>(relation: Relation<T, D>): QuerySingle<D>;
|
|
1072
1086
|
|
|
1073
1087
|
/**
|
|
1074
|
-
* See
|
|
1088
|
+
* See {@apilink Query.cast | Query.cast()}
|
|
1075
1089
|
*
|
|
1076
1090
|
* @param type the new type
|
|
1077
1091
|
* @return query single on a node of the specified type
|
|
@@ -1079,7 +1093,7 @@ export class QuerySingle<T extends CloudObject> {
|
|
|
1079
1093
|
cast<S extends CloudObject>(type: Class<S>): QuerySingle<S>;
|
|
1080
1094
|
|
|
1081
1095
|
/**
|
|
1082
|
-
* Execute the query single, see
|
|
1096
|
+
* Execute the query single, see {@apilink Query.execute | Query.execute()}
|
|
1083
1097
|
*
|
|
1084
1098
|
* @param context
|
|
1085
1099
|
* @return promise containing the single result or `null`
|
|
@@ -1088,7 +1102,7 @@ export class QuerySingle<T extends CloudObject> {
|
|
|
1088
1102
|
|
|
1089
1103
|
/**
|
|
1090
1104
|
* Execute the query single on the local data cloud,
|
|
1091
|
-
* see
|
|
1105
|
+
* see {@apilink Query.executeFromCache | Query.executeFromCache()}
|
|
1092
1106
|
*
|
|
1093
1107
|
* @return single result value or `null`
|
|
1094
1108
|
*/
|