@olympeio/runtime-node 8.7.1 → 9.0.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/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 +796 -678
- 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 -1181
package/package.json
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olympeio/runtime-node",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.1",
|
|
4
4
|
"description": "Olympe Node Runtime Environment",
|
|
5
|
-
"types": "index.d.ts",
|
|
5
|
+
"types": "types/index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"ws": "~8.2.3",
|
|
8
8
|
"bufferutil": "~4.0.5",
|
|
9
9
|
"utf-8-validate": "~5.0.7",
|
|
10
10
|
"cross-blob": "~2.0.0",
|
|
11
11
|
"lowdb": "~1.0.0",
|
|
12
|
-
"rxjs": "
|
|
12
|
+
"rxjs": "7.5.4",
|
|
13
|
+
"knex": "1.0.3",
|
|
14
|
+
"pg": "8.7.3",
|
|
15
|
+
"fastify": "~3.27.0",
|
|
16
|
+
"fastify-cors": "~6.0.2"
|
|
13
17
|
},
|
|
14
18
|
"dcInitConfig": "import/dcInitConfig.json",
|
|
15
19
|
"author": "Olympe S.A. <dev@olympe.ch>",
|
package/types/base.d.ts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import Observable from 'rxjs';
|
|
3
|
+
import {Empty, PropertyModel, Query, QueryResult, QuerySingle} from "./cloud";
|
|
4
|
+
|
|
5
|
+
// **********************************
|
|
6
|
+
// Primitives
|
|
7
|
+
// **********************************
|
|
8
|
+
|
|
9
|
+
declare type Class<T> = { new (): T };
|
|
10
|
+
|
|
11
|
+
export type Tag = string | HasTag | Class<CloudObject>;
|
|
12
|
+
export type List<T> = Array<T> | QueryResult<T>;
|
|
13
|
+
|
|
14
|
+
export function generateTag(): string;
|
|
15
|
+
export function tagToString(tag: Tag): string;
|
|
16
|
+
|
|
17
|
+
export interface HasTag {
|
|
18
|
+
getTag(): string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export abstract class Context {
|
|
22
|
+
/**
|
|
23
|
+
* Destroy the current context. It destroys all children context attached to this one and clear their values.
|
|
24
|
+
* The context cannot be reused after calling this function.
|
|
25
|
+
*/
|
|
26
|
+
destroy(): void;
|
|
27
|
+
/**
|
|
28
|
+
* Clear the current context: detach and destroys all children context.
|
|
29
|
+
* The context can be reused.
|
|
30
|
+
*/
|
|
31
|
+
clear(): void;
|
|
32
|
+
/**
|
|
33
|
+
* Register a callback to execute when the context is destroyed. Return the callback id.
|
|
34
|
+
*
|
|
35
|
+
* @param callback the callback function
|
|
36
|
+
* @return the callback id
|
|
37
|
+
*/
|
|
38
|
+
onDestroy(callback: () => void): string;
|
|
39
|
+
/**
|
|
40
|
+
* Remove a previously registered callback with {@link Context#onDestroy} method using its id.
|
|
41
|
+
*
|
|
42
|
+
* @param callbackId the id of the callback to unregister
|
|
43
|
+
*/
|
|
44
|
+
offDestroy(callbackId: string): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Register a callback to execute every time the context is cleared.
|
|
47
|
+
* This happens every time the brick is refreshed with new inputs and during the brick destruction.
|
|
48
|
+
* Return the callback id.
|
|
49
|
+
*
|
|
50
|
+
* @param callback the callback function
|
|
51
|
+
* @return the callback id
|
|
52
|
+
*/
|
|
53
|
+
onClear(callback: () => void): string;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Remove a previously registered callback with {@link Context#onClear} method using its id.
|
|
57
|
+
*
|
|
58
|
+
* @param id the id of the callback to unregister
|
|
59
|
+
*/
|
|
60
|
+
offClear(id: string): void;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export abstract class CloudObject implements HasTag {
|
|
64
|
+
static getProperties(): Property<any>[];
|
|
65
|
+
static getRelations<O extends CloudObject, D extends CloudObject>(this: Class<O>): Relation<O, D>[];
|
|
66
|
+
static instancesOf<T extends CloudObject>(this: Class<T>): Query<T, Empty>;
|
|
67
|
+
|
|
68
|
+
static get<T extends CloudObject>(tag: Tag): T;
|
|
69
|
+
static createWith<T>(this: Class<T>, properties: Map<Tag, any>, model?: Tag): T;
|
|
70
|
+
static asInstance<T>(this: Class<T>): T;
|
|
71
|
+
|
|
72
|
+
getTag(): string;
|
|
73
|
+
name(): string;
|
|
74
|
+
getModelTag(): string;
|
|
75
|
+
getModel(): CloudObject;
|
|
76
|
+
query(): Query<this, Empty>;
|
|
77
|
+
isPersisted(): boolean;
|
|
78
|
+
|
|
79
|
+
follow<D extends CloudObject>(relation: Relation<this, D>): Query<D, Empty>;
|
|
80
|
+
followSingle<D extends CloudObject>(relation: Relation<this, D>): QuerySingle<D>;
|
|
81
|
+
|
|
82
|
+
// Properties getters
|
|
83
|
+
get<T>(property: Property<T>): T | null;
|
|
84
|
+
observe<T>(context: Context, property: Property<T>): Observable<T>;
|
|
85
|
+
|
|
86
|
+
// Properties and Relations
|
|
87
|
+
static nameProp: Property<string>;
|
|
88
|
+
static instanceRel: Relation<CloudObject, CloudObject>;
|
|
89
|
+
static modelRel: Relation<CloudObject, CloudObject>;
|
|
90
|
+
static containsRel: Relation<CloudObject, CloudObject>;
|
|
91
|
+
static extendRel: Relation<CloudObject, CloudObject>;
|
|
92
|
+
static extendedByRel: Relation<CloudObject, CloudObject>;
|
|
93
|
+
static propertyRel: Relation<CloudObject, PropertyModel>;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface Property<T> extends HasTag {}
|
|
97
|
+
|
|
98
|
+
export enum Direction {
|
|
99
|
+
ORIGIN = '<',
|
|
100
|
+
DESTINATION = '>'
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export class Relation<O extends CloudObject, D extends CloudObject> implements HasTag {
|
|
104
|
+
constructor(tag: Tag, direction?: Direction, origin?: Class<O>, destination?: Class<D>);
|
|
105
|
+
getTag(): string;
|
|
106
|
+
getDirection(): Direction;
|
|
107
|
+
type(): Class<D>;
|
|
108
|
+
originType(): Class<O>;
|
|
109
|
+
getInverse(): Relation<D, O>;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function register(tag: Tag, object: Class<CloudObject>): void;
|
|
113
|
+
export function defineProperty<T>(tag: Tag, type?: Class<T>): Property<T>;
|
|
114
|
+
export function defineRelation<O extends CloudObject, D extends CloudObject>(tag: Tag, origin?: Class<O>, destination?: Class<D>, direction?: Direction): Relation<O, D>;
|
|
115
|
+
export function defineRelation(tag: Tag, direction?: Direction): Relation<CloudObject, CloudObject>;
|
|
116
|
+
export function defineInverseRelation<O extends CloudObject, D extends CloudObject>(relation: Relation<O, D>): Relation<D, O>;
|
package/types/cloud.d.ts
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
// *********************************************
|
|
2
|
+
//
|
|
3
|
+
// Olympe Data cloud objects Public API
|
|
4
|
+
//
|
|
5
|
+
// *********************************************
|
|
6
|
+
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
import Observable from 'rxjs';
|
|
9
|
+
import {Context, CloudObject, Relation, Property, Tag, Class} from "./base";
|
|
10
|
+
import { BrickContext } from './runtime';
|
|
11
|
+
import {Color} from "./utils";
|
|
12
|
+
|
|
13
|
+
// --------------------------
|
|
14
|
+
// -- Primitive data types --
|
|
15
|
+
// --------------------------
|
|
16
|
+
export class PropertyModel extends CloudObject {
|
|
17
|
+
static definingModelRel: Relation<PropertyModel, CloudObject>;
|
|
18
|
+
static typeRel: Relation<PropertyModel, CloudObject>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export class RelationModel extends CloudObject {
|
|
22
|
+
static originModelRel: Relation<CloudObject, RelationModel>;
|
|
23
|
+
static destinationModelRel: Relation<RelationModel, CloudObject>;
|
|
24
|
+
static dumpFollowRuleProp: Property<number>;
|
|
25
|
+
static deleteFollowRuleProp: Property<number>;
|
|
26
|
+
static runtimeFollowRuleProp: Property<number>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export class StringModel extends CloudObject {
|
|
30
|
+
static valueProp: Property<string>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export class NumberModel extends CloudObject {
|
|
34
|
+
static valueProp: Property<number>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export class BooleanModel extends CloudObject {
|
|
38
|
+
static valueProp: Property<boolean>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export class DatetimeModel extends CloudObject {
|
|
42
|
+
static valueProp: Property<Date>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export class ColorModel extends CloudObject {
|
|
46
|
+
static valueProp: Property<Color>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export class File extends CloudObject {
|
|
50
|
+
static nameProp: Property<string>;
|
|
51
|
+
static creationDateProp: Property<Date>;
|
|
52
|
+
static modificationDateProp: Property<Date>;
|
|
53
|
+
static mimeTypeProp: Property<string>;
|
|
54
|
+
static urlProp: Property<string>;
|
|
55
|
+
static createFromContent(transaction: Transaction, name: string, content: ArrayBuffer, mimeType?: string, source?: string, tag?: string): string;
|
|
56
|
+
static createFromURL(transaction: Transaction, name: string, url: string, mimeType?: string, source?: string, tag?: string): string;
|
|
57
|
+
|
|
58
|
+
getContentAsBinary(onSuccess: (content: ArrayBuffer) => void, onFailure?: (string) => void): void;
|
|
59
|
+
getContentAsString(onSuccess: (content: string) => void, onFailure?: (string) => void): void;
|
|
60
|
+
getContentUrl(onSuccess: (content: string) => void, onFailure?: () => void): void;
|
|
61
|
+
saveAs(name: string): void;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export class User extends CloudObject {
|
|
65
|
+
static loginProp: Property<string>;
|
|
66
|
+
static saltProp: Property<string>;
|
|
67
|
+
static verifierProp: Property<string>;
|
|
68
|
+
static SAMLNameIdProp: Property<string>;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export class Enum extends CloudObject {
|
|
72
|
+
create(transaction: Transaction, name?: string): string;
|
|
73
|
+
getValues(): QueryResult<EnumValue>;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export class EnumValue extends CloudObject {
|
|
77
|
+
static createValue(transaction: Transaction, enumModel: Tag, value: string, name?: string, rank?: number): string;
|
|
78
|
+
|
|
79
|
+
static nameProp: Property<string>;
|
|
80
|
+
static valueProp: Property<string>;
|
|
81
|
+
static rankProp: Property<number>;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// ---------------------------
|
|
85
|
+
// -- Database transactions --
|
|
86
|
+
// ---------------------------
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Transactions are the unique way to apply a list of operations to the datacloud.
|
|
90
|
+
* A transaction can be merged into another transaction to be executed as a single set of operations.
|
|
91
|
+
*
|
|
92
|
+
* There are 5 types of basic operations :
|
|
93
|
+
* - Create instance: create a node in the database with specified properties.
|
|
94
|
+
* - Update instance property: update an existing node in the database.
|
|
95
|
+
* - Delete instance: delete a node from the database. Delete only works if all the relations are removed too. Cascade delete can be activated.
|
|
96
|
+
* - Create relation: create a relation of a specific type between 2 existing node.
|
|
97
|
+
* - Delete relation: remove the specified relation between 2 specified nodes.
|
|
98
|
+
*
|
|
99
|
+
* Classical transactions are executed using "execute()" method. The transaction size is limited but real-time but
|
|
100
|
+
* all the changes applied on data "observed" by queries will be notified.
|
|
101
|
+
*
|
|
102
|
+
* Transactions with big set of operations (batch updates) can be executed using "executeAsLarge()" method. However no notification will be generated.
|
|
103
|
+
*
|
|
104
|
+
* Callbacks can be registered on transaction using "afterExecution()" method. They are executed once the transaction is applied.
|
|
105
|
+
*
|
|
106
|
+
* Concurrency transactions do not guarantee their execution order.
|
|
107
|
+
*/
|
|
108
|
+
export class Transaction {
|
|
109
|
+
constructor(persist?: boolean);
|
|
110
|
+
|
|
111
|
+
getId(): string;
|
|
112
|
+
|
|
113
|
+
// Operations
|
|
114
|
+
create(model: Tag, properties?: Map<Tag, any>, source?: string, tag?: string): string;
|
|
115
|
+
update<T>(instance: Tag, property?: Property<T>, value?: T): this;
|
|
116
|
+
multiUpdate(instance: Tag, properties: Map<string, any>): this;
|
|
117
|
+
delete(instance: Tag): this;
|
|
118
|
+
createRelation(relation: Tag, from: Tag, to: Tag): this;
|
|
119
|
+
deleteRelation(relation: Tag, from: Tag, to: Tag): this;
|
|
120
|
+
deleteAllRelations(relation: Relation<any, any>, origin: Tag): this;
|
|
121
|
+
|
|
122
|
+
// Change persistence of instances
|
|
123
|
+
persist(persist?: boolean): this;
|
|
124
|
+
persistInstance(instance: Tag, persist?: boolean): this;
|
|
125
|
+
|
|
126
|
+
// Set source of all instances created in this transaction
|
|
127
|
+
setSource(source: string): this;
|
|
128
|
+
model(tag: Tag): string;
|
|
129
|
+
|
|
130
|
+
merge(otherTransaction: Transaction): this;
|
|
131
|
+
|
|
132
|
+
// Execution methods
|
|
133
|
+
afterExecution(callback: (success: boolean, message?: string) => void): this;
|
|
134
|
+
execute(): Promise<void>;
|
|
135
|
+
executeAsLarge(): Promise<void>;
|
|
136
|
+
|
|
137
|
+
// Begin/End shared transaction helpers
|
|
138
|
+
static from($: BrickContext): Transaction;
|
|
139
|
+
static process($: BrickContext, transaction: Transaction): Promise<boolean>;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* BurstTransactions are designed to apply updates of properties continuously with the matter of the order.
|
|
144
|
+
* The only operation supported by BurstTransactions is to update properties of an instance.
|
|
145
|
+
*
|
|
146
|
+
* Unlike classical Transactions, a burst transaction preserves the order of update operations and
|
|
147
|
+
* is designed to handle many updates per second for smooth shared animations.
|
|
148
|
+
*
|
|
149
|
+
* Example of use:
|
|
150
|
+
* A marker representing a red dot on the screen which coordinate properties are controlled by motion sensors of an IoT device
|
|
151
|
+
* should use BurstTransaction instead of a bunch of continuous classical Transaction to have fluid movements on the screen.
|
|
152
|
+
*/
|
|
153
|
+
export class BurstTransaction {
|
|
154
|
+
constructor();
|
|
155
|
+
|
|
156
|
+
// Push all the property values from the specified Observable to update the specified object.
|
|
157
|
+
push<T>(object: CloudObject, values: Observable<Map<Property<T>, T>>): void;
|
|
158
|
+
|
|
159
|
+
// Commit and close the burst transaction.
|
|
160
|
+
complete(): Promise<void>;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// ----------------------
|
|
164
|
+
// -- Database queries --
|
|
165
|
+
// ----------------------
|
|
166
|
+
type Empty = [];
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* A CloudArray (type: QueryResult) is a array of tuple of CloudObjects that has been generated by a Query. It contains the result of a query at a specific time.
|
|
170
|
+
*
|
|
171
|
+
* When a query is subscribed, it generates multiple CloudArrays along time and got via an observable.
|
|
172
|
+
* Difference between CloudArrays from a Query is accessible using methods getAdded() and getRemoved().
|
|
173
|
+
*
|
|
174
|
+
* A CloudArray can be easily manipulated and transformed to a standard Array.
|
|
175
|
+
*
|
|
176
|
+
* Keys of CloudObject tuples follow the rule: 'tag1.tag2.tag3' : [cloudObj1, cloudObj2, cloudObj3]
|
|
177
|
+
*/
|
|
178
|
+
export class QueryResult<T> {
|
|
179
|
+
static empty(): QueryResult<any>;
|
|
180
|
+
|
|
181
|
+
[Symbol.iterator](): IterableIterator<[string, T]>;
|
|
182
|
+
entries(): IterableIterator<[string, T]>;
|
|
183
|
+
values(): IterableIterator<T>
|
|
184
|
+
keys(): IterableIterator<string>
|
|
185
|
+
|
|
186
|
+
toArray(): T[];
|
|
187
|
+
size(): number;
|
|
188
|
+
has(key: T | string): boolean;
|
|
189
|
+
indexOf(key: T | string): number;
|
|
190
|
+
get(key: string): T | null;
|
|
191
|
+
getFirst(): T | null;
|
|
192
|
+
getAt(index: number): T | null;
|
|
193
|
+
|
|
194
|
+
push(...object: T[]): T[];
|
|
195
|
+
pop(): T[];
|
|
196
|
+
shift(): T[];
|
|
197
|
+
|
|
198
|
+
// Gives the difference between last cloud array => what instances added, and what where removed.
|
|
199
|
+
getAdded(): T[];
|
|
200
|
+
getRemoved(): string[] | string[][];
|
|
201
|
+
|
|
202
|
+
filter(predicate: (entry: T) => boolean): T[];
|
|
203
|
+
find(predicate: (entry: T) => boolean): T | null;
|
|
204
|
+
|
|
205
|
+
forEach(callback: (entry: T) => void): void;
|
|
206
|
+
map<S>(callback: (entry: T) => S): S[];
|
|
207
|
+
sort(comparator: (b1: T, b2: T) => number): QueryResult<T>;
|
|
208
|
+
reduce<S>(reducer: (accumulator: S, entry: T) => S, initial: S): S;
|
|
209
|
+
concat(...others: QueryResult<T>[]): QueryResult<T>;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* A Query is an immutable object used to build queries on the datacloud. It is a graph query builder.
|
|
214
|
+
* Starting from an origin Tag (CloudObject or its unique id), it follows specified relations:
|
|
215
|
+
*
|
|
216
|
+
* origin --a--> X --b--> Y --c--> Z
|
|
217
|
+
*
|
|
218
|
+
* At each level, "andReturn()" method can be called to add the current level to the result.
|
|
219
|
+
* Example:
|
|
220
|
+
*
|
|
221
|
+
* Query.from(origin)
|
|
222
|
+
* .follow(a).andReturn()
|
|
223
|
+
* .follow(b)
|
|
224
|
+
* .follow(c).andReturn()
|
|
225
|
+
* .execute();
|
|
226
|
+
*
|
|
227
|
+
* This will return a Promise of a of tuple [X, Z]: Promise<CloudArray<[X, Z]>>.
|
|
228
|
+
*
|
|
229
|
+
* A query can be executed with 3 different ways:
|
|
230
|
+
* - execute(): it runs the query on the datacloud and return the result as a QueryResult.
|
|
231
|
+
* - 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.
|
|
232
|
+
* - 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.
|
|
233
|
+
*/
|
|
234
|
+
export class Query<T extends CloudObject, R extends any[]> {
|
|
235
|
+
static from<T extends CloudObject>(tag: Tag): Query<T, Empty>;
|
|
236
|
+
static instancesOf<T extends CloudObject>(model: Class<T>, source?: string): Query<T, Empty>;
|
|
237
|
+
|
|
238
|
+
follow<D extends CloudObject>(relation: Relation<T, D>): Query<D, R>; //
|
|
239
|
+
followRecursively<D extends CloudObject>(relation: Relation<T, D>, includeSelf?: boolean): Query<D, R>;
|
|
240
|
+
|
|
241
|
+
andReturn(): Query<T, [...R, T]>; // Add the current level of the query to the result. (Listdefs only support the last level to be returned).
|
|
242
|
+
|
|
243
|
+
filter(predicate: Predicate): Query<T, R>;
|
|
244
|
+
cast<S extends CloudObject>(type: Class<S>): Query<S, R>;
|
|
245
|
+
|
|
246
|
+
// Methods for which only the last call matters
|
|
247
|
+
limit(max: number, offset?: number): Query<T, R>;
|
|
248
|
+
sortBy(property: Property<any>, order?: Order): Query<T, R>;
|
|
249
|
+
|
|
250
|
+
execute(context: Context): Promise<QueryResult<R>>; // Execute the query on the datacloud (as a listdef) and deletes it afterwards.
|
|
251
|
+
observe(context: Context): Observable<QueryResult<R>>; // Generate a subscription and get a new CloudArray for every update.
|
|
252
|
+
|
|
253
|
+
executeFromCache(): QueryResult<R>; // Execute the query locally, using the DBView.
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* A QuerySingle is a Query which follows relations that should be unique between CloudObjects (0..1 and 1..1 cardinalities).
|
|
258
|
+
* It returns the CloudObjects related to the origin, following the specified relation(s).
|
|
259
|
+
*
|
|
260
|
+
* It acts as a syntactic sugar to avoid having a CloudArray and get the first value.
|
|
261
|
+
*
|
|
262
|
+
* A QuerySingle is immutable.
|
|
263
|
+
*/
|
|
264
|
+
export class QuerySingle<T extends CloudObject> {
|
|
265
|
+
static from<T extends CloudObject>(object: Tag): QuerySingle<T>;
|
|
266
|
+
|
|
267
|
+
follow<D extends CloudObject>(relation: Relation<T, D>): QuerySingle<D>;
|
|
268
|
+
cast<S extends CloudObject>(type: Class<S>): QuerySingle<S>;
|
|
269
|
+
|
|
270
|
+
execute(context: Context): Promise<T | null>; // Execute the query on the datacloud (as a listdef) and deletes it afterwards.
|
|
271
|
+
|
|
272
|
+
executeFromCache(): T | null; // Execute the query locally, using the DBView.
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Predicates are used to filter queries.
|
|
277
|
+
*/
|
|
278
|
+
export class Predicate {
|
|
279
|
+
static equals<T>(property: Property<T>, value: T): Predicate;
|
|
280
|
+
static contains(property: Property<string>, value: string, caseSensitive?: boolean): Predicate;
|
|
281
|
+
static regex(property: Property<string>, value: RegExp, caseSensitive?: boolean): Predicate;
|
|
282
|
+
|
|
283
|
+
static greaterThan(property: Property<number>, value: number, strict?: boolean): Predicate;
|
|
284
|
+
static smallerThan(property: Property<number>, value: number, strict?: boolean): Predicate;
|
|
285
|
+
|
|
286
|
+
static greaterThan(property1: Property<number>, property2: Property<number>, strict?: boolean): Predicate;
|
|
287
|
+
static smallerThan(property1: Property<number>, property2: Property<number>, strict?: boolean): Predicate;
|
|
288
|
+
|
|
289
|
+
static and(...predicates: Predicate[]): Predicate;
|
|
290
|
+
static or(...predicates: Predicate[]): Predicate;
|
|
291
|
+
static not(predicate: Predicate): Predicate;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
export class RelatedTo extends Predicate {
|
|
295
|
+
constructor(destination?: Tag);
|
|
296
|
+
follow(relation: Relation<any, any>): RelatedTo;
|
|
297
|
+
followRecursive(relation: Relation<any, any>): RelatedTo;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export enum Order {
|
|
301
|
+
ASC,
|
|
302
|
+
DESC
|
|
303
|
+
}
|