@olympeio/runtime-node 9.0.3 → 9.1.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/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/01_language.newInst.json +1 -1
- package/import/olympe.sc/datamodel/01_language.newRel.json +1 -1
- package/index.js +795 -780
- package/package.json +1 -1
- package/types/base.d.ts +49 -14
- package/types/cloud.d.ts +79 -18
- package/types/utils.d.ts +0 -15
package/package.json
CHANGED
package/types/base.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @ts-ignore
|
|
2
2
|
import Observable from 'rxjs';
|
|
3
|
-
import {
|
|
3
|
+
import {PropertyModel, Query, QueryResult, QuerySingle} from "./cloud";
|
|
4
4
|
|
|
5
5
|
// **********************************
|
|
6
6
|
// Primitives
|
|
@@ -13,7 +13,7 @@ declare type Class<T> = { new(): T };
|
|
|
13
13
|
*/
|
|
14
14
|
export type Tag = string | HasTag | Class<CloudObject>;
|
|
15
15
|
|
|
16
|
-
export type List<T> = Array<T> | QueryResult<T
|
|
16
|
+
export type List<T> = Array<T> | (T extends CloudObject | CloudObject[] ? QueryResult<T> : never);
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Generates a unique olympe tag used to identify `CloudObjects`
|
|
@@ -141,7 +141,7 @@ export abstract class CloudObject implements HasTag {
|
|
|
141
141
|
* @param model data type to get instances of
|
|
142
142
|
* @return A query starting from the instances of the specified model.
|
|
143
143
|
*/
|
|
144
|
-
static instancesOf<T extends CloudObject>(model: Tag): Query<T,
|
|
144
|
+
static instancesOf<T extends CloudObject>(model: Class<T> | Tag): Query<T, never>;
|
|
145
145
|
|
|
146
146
|
/**
|
|
147
147
|
* Get the CloudObject whose tag is specified.
|
|
@@ -206,7 +206,7 @@ export abstract class CloudObject implements HasTag {
|
|
|
206
206
|
*
|
|
207
207
|
* @return a query starting at this `CloudObject` instance
|
|
208
208
|
*/
|
|
209
|
-
query(): Query<this,
|
|
209
|
+
query(): Query<this, never>;
|
|
210
210
|
|
|
211
211
|
/**
|
|
212
212
|
* Return the persistence state of this instance.
|
|
@@ -234,7 +234,7 @@ export abstract class CloudObject implements HasTag {
|
|
|
234
234
|
* @param relation the relation to follow from the starting instance (`this`)
|
|
235
235
|
* @return query starting from `this` and following the relation `relation` as first step of the query
|
|
236
236
|
*/
|
|
237
|
-
follow<D extends CloudObject>(relation: Relation<this, D>): Query<D,
|
|
237
|
+
follow<D extends CloudObject>(relation: Relation<this, D>): Query<D, never>;
|
|
238
238
|
|
|
239
239
|
/**
|
|
240
240
|
* Start a `querySingle` from this instance that follows 0..1 relations
|
|
@@ -261,12 +261,32 @@ export abstract class CloudObject implements HasTag {
|
|
|
261
261
|
*
|
|
262
262
|
* The observable gets the new value each time the property gets updated in the datacloud.
|
|
263
263
|
* The observable gets completed automatically once the specified context is [cleared]{@link Context#onClear}.
|
|
264
|
+
* 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.
|
|
264
265
|
*
|
|
265
266
|
* @param context [context]{@link Context} to which the Observable is attached
|
|
266
267
|
* @param property property or property's tag to observe
|
|
268
|
+
* @param waitForValue [=true] whether the observable wait for a first value to get a value.
|
|
267
269
|
* @return Observable of property values
|
|
268
270
|
*/
|
|
269
|
-
observe<T>(context: Context, property: Property<T> | Tag): Observable<T>;
|
|
271
|
+
observe<T>(context: Context, property: Property<T> | Tag, waitForValue?: boolean): Observable<T>;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Get an observable to pair [property, value] for this `CloudObject` instance.
|
|
275
|
+
*
|
|
276
|
+
* 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 [cleared]{@link Context#onClear}.
|
|
278
|
+
*
|
|
279
|
+
* @param context [context]{@link Context} to which the Observable is attached
|
|
280
|
+
* @return Observable of property values
|
|
281
|
+
*/
|
|
282
|
+
observeProperties<T>(context: Context): Observable<[Property<T>, T]>;
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Create a Javascript object from this CloudObject current state.
|
|
286
|
+
* @param namesAsKey If true, use the property name instead of the property tag as keys of the generated object.
|
|
287
|
+
* @param inheritedProperties If false, do not including inherited property. By default, it includes them.
|
|
288
|
+
*/
|
|
289
|
+
toObject(namesAsKey?: boolean, inheritedProperties?: boolean): Object;
|
|
270
290
|
|
|
271
291
|
// Properties and Relations
|
|
272
292
|
/**
|
|
@@ -330,13 +350,14 @@ export enum Direction {
|
|
|
330
350
|
DESTINATION = '>'
|
|
331
351
|
}
|
|
332
352
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
353
|
+
interface RelationConstructor {
|
|
354
|
+
/**
|
|
355
|
+
* Create a relation between two CloudObject classes
|
|
356
|
+
* @param tag tag of the relation to create
|
|
357
|
+
* @param direction whether the relation points to the origin or destination
|
|
358
|
+
*/
|
|
359
|
+
new(tag: Tag, direction?: Direction): Relation<CloudObject, CloudObject>;
|
|
360
|
+
|
|
340
361
|
/**
|
|
341
362
|
* Create a relation between two CloudObject classes
|
|
342
363
|
* @param tag tag of the relation to create
|
|
@@ -344,7 +365,21 @@ export class Relation<O extends CloudObject, D extends CloudObject> implements H
|
|
|
344
365
|
* @param origin origin class of the relation
|
|
345
366
|
* @param destination destination class of the relation
|
|
346
367
|
*/
|
|
347
|
-
|
|
368
|
+
new<O extends CloudObject, D extends CloudObject>(tag: Tag, direction?: Direction, origin?: Class<O>, destination?: Class<D>): Relation<O, D>;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Global variable, constructor of class Relation.
|
|
373
|
+
*/
|
|
374
|
+
export declare const Relation: RelationConstructor;
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Relations can be defined between from a `CloudObject` to another, for example between two data types.
|
|
378
|
+
* Relations are directed and have two types: the origin type, the destination type.
|
|
379
|
+
*
|
|
380
|
+
* Defining a relation between two data types means that instances of these data types can be related with that relation.
|
|
381
|
+
*/
|
|
382
|
+
export interface Relation<O extends CloudObject, D extends CloudObject> extends HasTag {
|
|
348
383
|
|
|
349
384
|
/**
|
|
350
385
|
* @return tag of the relation
|
package/types/cloud.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// @ts-ignore
|
|
8
8
|
import Observable from 'rxjs';
|
|
9
9
|
import {Context, CloudObject, Relation, Property, Tag, Class} from "./base";
|
|
10
|
-
import {BrickContext} from './runtime';
|
|
10
|
+
import {Brick, BrickContext} from './runtime';
|
|
11
11
|
import {Color} from "./utils";
|
|
12
12
|
|
|
13
13
|
// --------------------------
|
|
@@ -178,7 +178,7 @@ export class User extends CloudObject {
|
|
|
178
178
|
static loginProp: Property<string>;
|
|
179
179
|
static saltProp: Property<string>;
|
|
180
180
|
static verifierProp: Property<string>;
|
|
181
|
-
static
|
|
181
|
+
static SAMLnameIdProp: Property<string>;
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
/**
|
|
@@ -234,6 +234,69 @@ export class EnumValue extends CloudObject {
|
|
|
234
234
|
static rankProp: Property<number>;
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
+
// -------------------------
|
|
238
|
+
// -- Workflow data types --
|
|
239
|
+
// -------------------------
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* A `Workflow` is a sequence of {@link WorkflowState} in which instances of a model goes through.
|
|
243
|
+
* {@link WorkflowState} are linked by {@link WorkflowTransition} that can have an optional _process function_.
|
|
244
|
+
* The `Workflow` also historize the {@link WorkflowState} of the instance and optionally serialize the object itself in a {@link WorkflowObjectState}.
|
|
245
|
+
*/
|
|
246
|
+
export class Workflow extends CloudObject {
|
|
247
|
+
/** Is the instance serialization enabled or not */
|
|
248
|
+
static serializationEnabledProp: Property<boolean>;
|
|
249
|
+
/** The model to which the `Workflow` is associated */
|
|
250
|
+
static dataTypeRel: Relation<Workflow, CloudObject>;
|
|
251
|
+
/** The {@link WorkflowState} that are in the `Workflow` */
|
|
252
|
+
static statesRel: Relation<Workflow, WorkflowState>;
|
|
253
|
+
/** The initial {@link WorkflowState} of the `Workflow` */
|
|
254
|
+
static initialStateRel: Relation<Workflow, WorkflowState>;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* A `WorkflowState` defines a state in a {@link Workflow}.
|
|
259
|
+
*/
|
|
260
|
+
export class WorkflowState extends CloudObject { /* empty */ }
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* A `WorkflowTransition` defines a transition between 2 {@link WorkflowState}.
|
|
264
|
+
* It has a direction (`fromStateRel` to `toStateRel`) and can have an optional _process function_.
|
|
265
|
+
* The _process function_ (`processRefProp`) is automatically triggered when the transition occurs.
|
|
266
|
+
*/
|
|
267
|
+
export class WorkflowTransition extends CloudObject {
|
|
268
|
+
/**
|
|
269
|
+
* The `WorkflowTransition` optional _process function_.
|
|
270
|
+
* It has this signature: (ControlFlow, CloudObject, User, Map) -> (ControlFlow, ErrorFlow)
|
|
271
|
+
*/
|
|
272
|
+
static processRefProp: Property<Brick>;
|
|
273
|
+
/** The {@link WorkflowState} from which this transition starts */
|
|
274
|
+
static fromStateRel: Relation<WorkflowTransition, WorkflowState>;
|
|
275
|
+
/** The {@link WorkflowState} to which this transition ends */
|
|
276
|
+
static toStateRel: Relation<WorkflowTransition, WorkflowState>;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* A `WorkflowObjectState` represents the state of an instance at a certain point in time.
|
|
281
|
+
* It is automatically created when initializing a {@link Workflow} on an instance or when triggering a {@link WorkflowTransition}.
|
|
282
|
+
*/
|
|
283
|
+
export class WorkflowObjectState extends CloudObject {
|
|
284
|
+
/** The name of the {@link Workflow} associated */
|
|
285
|
+
static workflowProp: Property<string>;
|
|
286
|
+
/** The name of the {@link WorkflowState} */
|
|
287
|
+
static stateProp: Property<string>;
|
|
288
|
+
/** The name (login) of the {@link User} */
|
|
289
|
+
static assigneeProp: Property<string>;
|
|
290
|
+
/** The point in time of this object state */
|
|
291
|
+
static dateTimeProp: Property<Date>;
|
|
292
|
+
/** If the {@link Workflow} has serialization enabled, the object's property are saved here in JSON */
|
|
293
|
+
static serializedObjectProp: Property<string>;
|
|
294
|
+
/** The related instance this object state represents */
|
|
295
|
+
static objectRel: Relation<WorkflowObjectState, CloudObject>;
|
|
296
|
+
/** The related instance this object state represents. This relation only reference the current state */
|
|
297
|
+
static currentObjectRel: Relation<WorkflowObjectState, CloudObject>;
|
|
298
|
+
}
|
|
299
|
+
|
|
237
300
|
// ---------------------------
|
|
238
301
|
// -- Database transactions --
|
|
239
302
|
// ---------------------------
|
|
@@ -503,7 +566,6 @@ export class BurstTransaction {
|
|
|
503
566
|
// ----------------------
|
|
504
567
|
// -- Database queries --
|
|
505
568
|
// ----------------------
|
|
506
|
-
type Empty = [];
|
|
507
569
|
|
|
508
570
|
/**
|
|
509
571
|
* A QueryResult is a list of key-value pairs that has been generated as a result of a `Query`.
|
|
@@ -521,7 +583,7 @@ type Empty = [];
|
|
|
521
583
|
*
|
|
522
584
|
* A QueryResult can be easily manipulated and transformed to a standard Array.
|
|
523
585
|
*/
|
|
524
|
-
export class QueryResult<T> {
|
|
586
|
+
export class QueryResult<T extends CloudObject | CloudObject[]> {
|
|
525
587
|
/**
|
|
526
588
|
*@return empty `QueryResult`
|
|
527
589
|
*/
|
|
@@ -578,7 +640,6 @@ export class QueryResult<T> {
|
|
|
578
640
|
*
|
|
579
641
|
* @param key the value to search for
|
|
580
642
|
* @return true if the value `key` is found
|
|
581
|
-
* @TODO why T, it's CloudObjects
|
|
582
643
|
*/
|
|
583
644
|
has(key: T | string): boolean;
|
|
584
645
|
|
|
@@ -591,7 +652,6 @@ export class QueryResult<T> {
|
|
|
591
652
|
*
|
|
592
653
|
* @param key the value to find the index of
|
|
593
654
|
* @return index of the argument value or -1 if the value is not found
|
|
594
|
-
* TODO why T, it's CloudObjects
|
|
595
655
|
*/
|
|
596
656
|
indexOf(key: T | string): number;
|
|
597
657
|
|
|
@@ -676,7 +736,7 @@ export class QueryResult<T> {
|
|
|
676
736
|
* @param predicate filter {@link Predicate}
|
|
677
737
|
* @return array of matching values
|
|
678
738
|
*/
|
|
679
|
-
filter(predicate: (entry: T) => boolean): T[];
|
|
739
|
+
filter(predicate: (entry: T, index: number) => boolean): T[];
|
|
680
740
|
|
|
681
741
|
/**
|
|
682
742
|
* Returns the first value matching the predicate, `null` otherwise.
|
|
@@ -687,14 +747,14 @@ export class QueryResult<T> {
|
|
|
687
747
|
* @param predicate
|
|
688
748
|
* @return the first value evaluating to true or `null`
|
|
689
749
|
*/
|
|
690
|
-
find(predicate: (entry: T) => boolean): T | null;
|
|
750
|
+
find(predicate: (entry: T, index: number) => boolean): T | null;
|
|
691
751
|
|
|
692
752
|
/**
|
|
693
753
|
* Execute the specified callback function for each value of this `QueryResult`
|
|
694
754
|
*
|
|
695
755
|
* @param callback
|
|
696
756
|
*/
|
|
697
|
-
forEach(callback: (entry: T) => void): void;
|
|
757
|
+
forEach(callback: (entry: T, index: number) => void): void;
|
|
698
758
|
|
|
699
759
|
/**
|
|
700
760
|
* Execute the specified callback function for each value of this `QueryResult`.
|
|
@@ -703,7 +763,7 @@ export class QueryResult<T> {
|
|
|
703
763
|
* @param callback
|
|
704
764
|
* @return new array of transformed values
|
|
705
765
|
*/
|
|
706
|
-
map<S>(callback: (entry: T) => S): S[];
|
|
766
|
+
map<S>(callback: (entry: T, index: number) => S): S[];
|
|
707
767
|
|
|
708
768
|
/**
|
|
709
769
|
* Return a sorted copy of this QueryResult.
|
|
@@ -726,7 +786,7 @@ export class QueryResult<T> {
|
|
|
726
786
|
* @param initial initial value of the accumulator
|
|
727
787
|
* @return accumulated result applying the `reducer` function iteratively
|
|
728
788
|
*/
|
|
729
|
-
reduce<S>(reducer: (accumulator: S, entry: T) => S, initial: S): S;
|
|
789
|
+
reduce<S>(reducer: (accumulator: S, entry: T, index: number) => S, initial: S): S;
|
|
730
790
|
|
|
731
791
|
/**
|
|
732
792
|
* Return a new QueryResult that contains the concatenation of two or more QueryResults.
|
|
@@ -803,15 +863,16 @@ export class QueryResult<T> {
|
|
|
803
863
|
* - observe(): it runs the query on the datacloud and subscribes to updates. It returns an Observable which provides a new QueryResult every time the result changes.
|
|
804
864
|
* - executeFromCache(): it runs the query on the *local* datacloud which may be incomplete view of the datacloud (it is the local cache). It is executed synchronously.
|
|
805
865
|
*/
|
|
806
|
-
export class Query<T extends CloudObject, R
|
|
866
|
+
export class Query<T extends CloudObject, R> {
|
|
807
867
|
|
|
808
868
|
/**
|
|
809
869
|
* Create a query starting from the `CloudObject` specified tag
|
|
810
870
|
*
|
|
811
871
|
* @param tag tag of the `CloudObject` the query is starting from
|
|
872
|
+
* @param source optional source of the data to answer the query
|
|
812
873
|
* @return an empty Query whose starting point is defined by a single `CloudObject`
|
|
813
874
|
*/
|
|
814
|
-
static from<T extends
|
|
875
|
+
static from<T extends Tag>(tag: T, source?: string): Query<T extends CloudObject ? T : CloudObject, never>;
|
|
815
876
|
|
|
816
877
|
/**
|
|
817
878
|
* Create a query starting from the instances of the specified model
|
|
@@ -822,7 +883,7 @@ export class Query<T extends CloudObject, R extends any[]> {
|
|
|
822
883
|
* an external data source ('<DBConnectorTag>')
|
|
823
884
|
* @return a new query object starting from model instances
|
|
824
885
|
*/
|
|
825
|
-
static instancesOf<T extends
|
|
886
|
+
static instancesOf<T extends Tag>(model: Class<T> | Tag, source?: string): Query<T extends CloudObject ? T : CloudObject, never>;
|
|
826
887
|
|
|
827
888
|
/**
|
|
828
889
|
* Instruct the query to follow a specified relation. This does not add any key-value pair to the result.
|
|
@@ -865,7 +926,7 @@ export class Query<T extends CloudObject, R extends any[]> {
|
|
|
865
926
|
*
|
|
866
927
|
* @return a new query object with the current level flagged to be returned.
|
|
867
928
|
*/
|
|
868
|
-
andReturn(): Query<T, [...R, T]>;
|
|
929
|
+
andReturn(): Query<T, R extends never ? T : R extends CloudObject[] ? [...R, T] : [R, T]>;
|
|
869
930
|
|
|
870
931
|
/**
|
|
871
932
|
* Define a filter operation on the current working set of nodes.
|
|
@@ -941,7 +1002,7 @@ export class Query<T extends CloudObject, R extends any[]> {
|
|
|
941
1002
|
* one has to provide a context that won't be destroyed before the query has a result.
|
|
942
1003
|
* @return promise resolving to query result or failing otherwise.
|
|
943
1004
|
*/
|
|
944
|
-
execute(context: Context): Promise<QueryResult<R>>;
|
|
1005
|
+
execute(context: Context): Promise<QueryResult<R extends never ? T : R extends CloudObject | CloudObject[] ? R : never>>;
|
|
945
1006
|
|
|
946
1007
|
/**
|
|
947
1008
|
* Get an observable to the current value of the QueryResult for this Query instance.
|
|
@@ -953,7 +1014,7 @@ export class Query<T extends CloudObject, R extends any[]> {
|
|
|
953
1014
|
* @param context [context]{@link Context} to which the Observable is attached
|
|
954
1015
|
* @return Observable of QueryResult values
|
|
955
1016
|
*/
|
|
956
|
-
observe(context: Context): Observable<QueryResult<R>>;
|
|
1017
|
+
observe(context: Context): Observable<QueryResult<R extends never ? T : R extends CloudObject | CloudObject[] ? R : never>>;
|
|
957
1018
|
|
|
958
1019
|
/**
|
|
959
1020
|
* Execute synchronously the query on the local datacloud cache.
|
|
@@ -961,7 +1022,7 @@ export class Query<T extends CloudObject, R extends any[]> {
|
|
|
961
1022
|
*
|
|
962
1023
|
* @return query result of the execution on the local cache
|
|
963
1024
|
*/
|
|
964
|
-
executeFromCache(): QueryResult<R>;
|
|
1025
|
+
executeFromCache(): QueryResult<R extends never ? T : R extends CloudObject | CloudObject[] ? R : never>;
|
|
965
1026
|
}
|
|
966
1027
|
|
|
967
1028
|
/**
|
package/types/utils.d.ts
CHANGED
|
@@ -65,11 +65,6 @@ export class ServiceRequest {
|
|
|
65
65
|
*/
|
|
66
66
|
userTag(): Promise<string>;
|
|
67
67
|
|
|
68
|
-
/**
|
|
69
|
-
* @return the type of the request
|
|
70
|
-
*/
|
|
71
|
-
getType(): RequestType;
|
|
72
|
-
|
|
73
68
|
/**
|
|
74
69
|
* Get the request body.
|
|
75
70
|
*
|
|
@@ -170,16 +165,6 @@ export class Service {
|
|
|
170
165
|
static observe(service: string, context: Context, payload?: Object): Observable<Object>;
|
|
171
166
|
}
|
|
172
167
|
|
|
173
|
-
/**
|
|
174
|
-
* Possible types of request coming for services.
|
|
175
|
-
*/
|
|
176
|
-
export enum RequestType {
|
|
177
|
-
SEND,
|
|
178
|
-
GET,
|
|
179
|
-
PUBLISH,
|
|
180
|
-
SUBSCRIBE
|
|
181
|
-
}
|
|
182
|
-
|
|
183
168
|
// -- Authentication --
|
|
184
169
|
/**
|
|
185
170
|
* A static class that gathers all the required methods to handle the authentication and sessions with Olympe.
|