@olympeio/runtime-node 9.10.4 → 9.11.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/.Primordial.newInst.json +1 -1
- package/import/olympe.dm/datamodel/05_permission_schema.updateInst.json +1 -1
- package/import/olympe.sc/datamodel/01_language.newInst.json +1 -1
- package/index.js +988 -940
- package/package.json +3 -2
- package/types/composition.d.ts +122 -0
- package/types/data-connector.d.ts +356 -0
- package/types/{base.d.ts → data.d.ts} +168 -158
- package/types/index.d.ts +9 -3
- package/types/legacy.d.ts +2 -1
- package/types/models.d.ts +203 -0
- package/types/{utils.d.ts → other.d.ts} +158 -285
- package/types/query.d.ts +726 -0
- package/types/runtime.d.ts +49 -35
- package/types/service.d.ts +183 -0
- package/types/transaction-advanced.d.ts +34 -0
- package/types/transaction.d.ts +266 -0
- package/types/cloud.d.ts +0 -1726
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { Brick } from "./runtime";
|
|
2
|
+
import { CloudObject } from "./data"
|
|
3
|
+
import { FollowRule } from "./data-connector";
|
|
4
|
+
import { Property, Relation } from "./composition"
|
|
5
|
+
|
|
6
|
+
// -- Primitive types classes --
|
|
7
|
+
export class Color {
|
|
8
|
+
static create(r: number, g: number, b: number, a?: number): Color;
|
|
9
|
+
|
|
10
|
+
getRed(): number;
|
|
11
|
+
getGreen(): number;
|
|
12
|
+
getBlue(): number;
|
|
13
|
+
getAlpha(): number;
|
|
14
|
+
toRGBString(): string;
|
|
15
|
+
toHexString(): string;
|
|
16
|
+
equals(obj: any): boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
// --------------------------
|
|
21
|
+
// -- Primitive data types --
|
|
22
|
+
// --------------------------
|
|
23
|
+
/**
|
|
24
|
+
* A property model defines a property of a data type.
|
|
25
|
+
* A property is defined by its type and the model it defines a property for.
|
|
26
|
+
* */
|
|
27
|
+
export class PropertyModel extends CloudObject {
|
|
28
|
+
/**
|
|
29
|
+
* Relation from the property model to the data type (model)
|
|
30
|
+
* to which that property is attached.
|
|
31
|
+
*
|
|
32
|
+
* Example:
|
|
33
|
+
*
|
|
34
|
+
* ` myNumberPropertyModel --definingModelRel-> myDataTypeObject`
|
|
35
|
+
*/
|
|
36
|
+
static definingModelRel: Relation<PropertyModel, CloudObject>;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Relation from the `PropertyModel` to its type.
|
|
40
|
+
*
|
|
41
|
+
* Example :
|
|
42
|
+
*
|
|
43
|
+
* `myNumberPropertyModel --typeRel-> Number`
|
|
44
|
+
*/
|
|
45
|
+
static typeRel: Relation<PropertyModel, CloudObject>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* A relation model defines a relation between two data types.
|
|
50
|
+
* It defines what data types is the origin and the destination of the relation.
|
|
51
|
+
*
|
|
52
|
+
* It also defines follow rules properties on the relation.
|
|
53
|
+
* */
|
|
54
|
+
export class RelationModel extends CloudObject {
|
|
55
|
+
/**
|
|
56
|
+
* Relation from the origin data type to the RelationModel
|
|
57
|
+
* */
|
|
58
|
+
static originModelRel: Relation<RelationModel, CloudObject>;
|
|
59
|
+
/**
|
|
60
|
+
* Relation from a RelationModel to the destination data type
|
|
61
|
+
* */
|
|
62
|
+
static destinationModelRel: Relation<RelationModel, CloudObject>;
|
|
63
|
+
/**
|
|
64
|
+
* Property for the *dump* follow rule
|
|
65
|
+
*/
|
|
66
|
+
static dumpFollowRuleProp: FollowRule;
|
|
67
|
+
/**
|
|
68
|
+
* Property for the *delete* follow rule
|
|
69
|
+
*/
|
|
70
|
+
static deleteFollowRuleProp: FollowRule;
|
|
71
|
+
/**
|
|
72
|
+
* Property for the *runtime* follow rule
|
|
73
|
+
*/
|
|
74
|
+
static runtimeFollowRuleProp: FollowRule;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* StringModel represents a {@link PropertyModel} for a string property of a data type.
|
|
79
|
+
*/
|
|
80
|
+
export class StringModel extends CloudObject {
|
|
81
|
+
static valueProp: Property<string>;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* NumberModel represents a {@link PropertyModel} for a number property of a data type.
|
|
86
|
+
*/
|
|
87
|
+
export class NumberModel extends CloudObject {
|
|
88
|
+
static valueProp: Property<number>;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* BooleanModel represents a {@link PropertyModel} for a boolean property of a data type.
|
|
93
|
+
*/
|
|
94
|
+
export class BooleanModel extends CloudObject {
|
|
95
|
+
static valueProp: Property<boolean>;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* DatetimeModel represents a {@link PropertyModel} for a datetime property of a data type.
|
|
100
|
+
*/
|
|
101
|
+
export class DatetimeModel extends CloudObject {
|
|
102
|
+
static valueProp: Property<Date>;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* ColorModel represents a {@link PropertyModel} for a color property of a data type.
|
|
107
|
+
*/
|
|
108
|
+
export class ColorModel extends CloudObject {
|
|
109
|
+
static valueProp: Property<Color>;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* User object for authentication purposes
|
|
114
|
+
*/
|
|
115
|
+
export class User extends CloudObject {
|
|
116
|
+
static loginProp: Property<string>;
|
|
117
|
+
static saltProp: Property<string>;
|
|
118
|
+
static verifierProp: Property<string>;
|
|
119
|
+
static SAMLnameIdProp: Property<string>;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
// -------------------------
|
|
125
|
+
// -- Workflow data types --
|
|
126
|
+
// -------------------------
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* A `Workflow` is a sequence of {@link WorkflowState} in which instances of a model goes through.
|
|
130
|
+
* {@link WorkflowState} are linked by {@link WorkflowTransition} that can have an optional _process function_.
|
|
131
|
+
* The `Workflow` also historize the {@link WorkflowState} of the instance and optionally serialize the object itself in a {@link WorkflowObjectState}.
|
|
132
|
+
*/
|
|
133
|
+
export class Workflow extends CloudObject {
|
|
134
|
+
/** Is the instance serialization enabled or not */
|
|
135
|
+
static serializationEnabledProp: Property<boolean>;
|
|
136
|
+
/** The model to which the `Workflow` is associated */
|
|
137
|
+
static dataTypeRel: Relation<Workflow, CloudObject>;
|
|
138
|
+
/** The {@link WorkflowState} that are in the `Workflow` */
|
|
139
|
+
static statesRel: Relation<Workflow, WorkflowState>;
|
|
140
|
+
/** The initial {@link WorkflowState} of the `Workflow` */
|
|
141
|
+
static initialStateRel: Relation<Workflow, WorkflowState>;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* A `WorkflowState` defines a state in a {@link Workflow}.
|
|
146
|
+
*/
|
|
147
|
+
export class WorkflowState extends CloudObject { /* empty */ }
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* A `WorkflowTransition` defines a transition between 2 {@link WorkflowState}.
|
|
151
|
+
* It has a direction (`fromStateRel` to `toStateRel`) and can have an optional _process function_.
|
|
152
|
+
* The _process function_ (`processRefProp`) is automatically triggered when the transition occurs.
|
|
153
|
+
*/
|
|
154
|
+
export class WorkflowTransition extends CloudObject {
|
|
155
|
+
/**
|
|
156
|
+
* The `WorkflowTransition` optional _process function_.
|
|
157
|
+
* It has this signature: (ControlFlow, CloudObject, User, Map) -> (ControlFlow, ErrorFlow)
|
|
158
|
+
*/
|
|
159
|
+
static processRefProp: Property<Brick>;
|
|
160
|
+
/** The {@link WorkflowState} from which this transition starts */
|
|
161
|
+
static fromStateRel: Relation<WorkflowTransition, WorkflowState>;
|
|
162
|
+
/** The {@link WorkflowState} to which this transition ends */
|
|
163
|
+
static toStateRel: Relation<WorkflowTransition, WorkflowState>;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* A `WorkflowObjectState` represents the state of an instance at a certain point in time.
|
|
168
|
+
* It is automatically created when initializing a {@link Workflow} on an instance or when triggering a {@link WorkflowTransition}.
|
|
169
|
+
*/
|
|
170
|
+
export class WorkflowObjectState extends CloudObject {
|
|
171
|
+
/** The name of the {@link Workflow} associated */
|
|
172
|
+
static workflowProp: Property<string>;
|
|
173
|
+
/** The name of the {@link WorkflowState} */
|
|
174
|
+
static stateProp: Property<string>;
|
|
175
|
+
/** The name (login) of the {@link User} */
|
|
176
|
+
static assigneeProp: Property<string>;
|
|
177
|
+
/** The point in time of this object state */
|
|
178
|
+
static dateTimeProp: Property<Date>;
|
|
179
|
+
/** If the {@link Workflow} has serialization enabled, the object's property are saved here in JSON */
|
|
180
|
+
static serializedObjectProp: Property<string>;
|
|
181
|
+
/** The related instance this object state represents */
|
|
182
|
+
static objectRel: Relation<WorkflowObjectState, CloudObject>;
|
|
183
|
+
/** The related instance this object state represents. This relation only reference the current state */
|
|
184
|
+
static currentObjectRel: Relation<WorkflowObjectState, CloudObject>;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// -------------------------
|
|
188
|
+
// -- Theme data types --
|
|
189
|
+
// -------------------------
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Theme object describing the main visual properties used by components
|
|
193
|
+
*/
|
|
194
|
+
export class Theme extends CloudObject {
|
|
195
|
+
static nameProp: Property<string>;
|
|
196
|
+
static primaryColorProp: Property<string>;
|
|
197
|
+
static secondaryColorProp: Property<string>;
|
|
198
|
+
static errorColorProp: Property<string>;
|
|
199
|
+
static warningColorProp: Property<string>;
|
|
200
|
+
static infoColorProp: Property<string>;
|
|
201
|
+
static successColorProp: Property<string>;
|
|
202
|
+
static fontFamilyProp: Property<string>;
|
|
203
|
+
}
|
|
@@ -1,294 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
// **********************************
|
|
4
|
-
|
|
1
|
+
import { CloudObject } from "./data";
|
|
2
|
+
import { QueryResult } from "./query";
|
|
5
3
|
// @ts-ignore
|
|
6
|
-
import {Observable} from
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
import {Error} from 'es5';
|
|
9
|
-
import {Context} from "./base";
|
|
10
|
-
|
|
11
|
-
// -- Configuration --
|
|
12
|
-
export class Config {
|
|
13
|
-
/**
|
|
14
|
-
* Return the value of the specified parameter.
|
|
15
|
-
* Parameters can get their values from the oConfig.json file or be overridden from the URL / command that opened the application.
|
|
16
|
-
*
|
|
17
|
-
* @param id the parameter id
|
|
18
|
-
*/
|
|
19
|
-
static getParameter(id: string): unknown | undefined;
|
|
20
|
-
}
|
|
4
|
+
import { Observable } from "rxjs";
|
|
21
5
|
|
|
22
6
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
7
|
+
* Label of global properties used by convention through bricks and applications.
|
|
8
|
+
* Example of use:
|
|
9
|
+
*
|
|
10
|
+
* const transaction = context.get(TRANSACTION).
|
|
11
|
+
*
|
|
12
|
+
* The brick "Begin Transaction" push a transaction inside the context so it can be reused by other bricks before the "End Transaction" brick.
|
|
27
13
|
*/
|
|
28
|
-
export enum
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Health check and shutdown
|
|
35
|
-
export class Process {
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Static method to register a callback that is used to check the health status of the process.
|
|
39
|
-
* This is typically used by kubernetes environment to maintain backend healthy
|
|
40
|
-
*
|
|
41
|
-
* The callback must return a Promise which returns a string as valid message.
|
|
42
|
-
* The process is considered by the runtime as unhealthy if the promise is rejected.
|
|
43
|
-
*
|
|
44
|
-
* The options parameter can be used to specify the type of probe to register:
|
|
45
|
-
* - LIVENESS: used to check if the process is alive
|
|
46
|
-
* - READINESS: used to check if the process is ready to operate
|
|
47
|
-
* - ALL: used to check both liveness and readiness
|
|
48
|
-
*
|
|
49
|
-
* @param callback the callback executed each time the runtime check the health of the process.
|
|
50
|
-
* @param options options to specify the type of probe to register
|
|
51
|
-
*/
|
|
52
|
-
static onHealthCheck(callback: () => Promise<string>, options?: {type: ProbeType}): () => void;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Static method to register a callback called by the runtime when it receives the signal to be terminated.
|
|
56
|
-
* This is typically used to graceful shutdown some connections or drivers to external processes.
|
|
57
|
-
*
|
|
58
|
-
* The callback must return a Promise which is resolved when the shutdown process is done.
|
|
59
|
-
*
|
|
60
|
-
* @param callback the callback executed when the runtime terminates.
|
|
61
|
-
* @param shutdownId optional id to name the shutdown hook, mainly for debug purpose
|
|
62
|
-
*/
|
|
63
|
-
static onShutdown(callback: () => Promise<void>, shutdownId?: string): () => void;
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Static method that manually triggers a connection attempt to the server to go ONLINE.
|
|
67
|
-
* If you have called {@apilink Process.disconnect()} before, it will cancel the OFFLINE mode,
|
|
68
|
-
* next time the app will be opened, it will try to go ONLINE on its own.
|
|
69
|
-
*
|
|
70
|
-
* Returns a promise that resolves when the server connection is established. If it fails, the promise is rejected.
|
|
71
|
-
*/
|
|
72
|
-
static connect(): Promise<void>;
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Static method that manually close the connection to the server to go OFFLINE.
|
|
76
|
-
* Persists the offline status so the app restart offline after being closed.
|
|
77
|
-
* The only way to clean that status is to call {@apilink Process.connect()}.
|
|
78
|
-
*
|
|
79
|
-
* Returns a promise that resolves when the server connection is indeed disconnected and the state is OFFLINE.
|
|
80
|
-
* If the flag `offline.enabled` is not set to true, the promise is rejected.
|
|
81
|
-
*/
|
|
82
|
-
static disconnect(): Promise<void>;
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Static method that returns an observable on the connection state: the observable send TRUE if the process is considered
|
|
86
|
-
* as ONLINE and false if not.
|
|
87
|
-
*
|
|
88
|
-
* @param context the context of the brick to garbage collect the observable when not needed anymore.
|
|
89
|
-
*/
|
|
90
|
-
static isOnline(context: Context): Observable<boolean>;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// -- Primitive types classes --
|
|
94
|
-
export class Color {
|
|
95
|
-
static create(r: number, g: number, b: number, a?: number): Color;
|
|
96
|
-
|
|
97
|
-
getRed(): number;
|
|
98
|
-
getGreen(): number;
|
|
99
|
-
getBlue(): number;
|
|
100
|
-
getAlpha(): number;
|
|
101
|
-
toRGBString(): string;
|
|
102
|
-
toHexString(): string;
|
|
103
|
-
equals(obj: any): boolean;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Error type used to propagate errors through flows between bricks.
|
|
108
|
-
*/
|
|
109
|
-
export class ErrorFlow extends Error {
|
|
110
|
-
/**
|
|
111
|
-
* Create a new Error object to be sent in an error flow
|
|
112
|
-
*
|
|
113
|
-
* @param message the error message
|
|
114
|
-
* @param code the code associated to the error
|
|
115
|
-
*/
|
|
116
|
-
static create(message: string, code: number): ErrorFlow;
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Return the message of this error
|
|
120
|
-
*/
|
|
121
|
-
getMessage(): string;
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Return the code associated to this error
|
|
125
|
-
*/
|
|
126
|
-
getCode(): number;
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Return the stack with the hierarchy of bricks that run the one having thrown the error.
|
|
130
|
-
*/
|
|
131
|
-
getStack(): string;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Types of requests that can be received in a Service.
|
|
136
|
-
* This is used to know what method call on the request to answer the requester.
|
|
137
|
-
*/
|
|
138
|
-
export enum ServiceRequestType {
|
|
139
|
-
PUBLISH,
|
|
140
|
-
SEND,
|
|
141
|
-
GET,
|
|
142
|
-
SUBSCRIBE
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* A request consumed by a service.
|
|
147
|
-
*/
|
|
148
|
-
export class ServiceRequest {
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Get the requesting client's user tag.
|
|
152
|
-
*
|
|
153
|
-
* @return the user tag
|
|
154
|
-
*/
|
|
155
|
-
userTag(): Promise<string>;
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Return the type of this Service Request
|
|
159
|
-
*
|
|
160
|
-
* @return the type of this request.
|
|
161
|
-
*/
|
|
162
|
-
requestType(): ServiceRequestType;
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Get the request body.
|
|
166
|
-
*
|
|
167
|
-
* @return the request body
|
|
168
|
-
*/
|
|
169
|
-
body(): Object;
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Acknowledge the request. Used for SEND requests
|
|
173
|
-
*
|
|
174
|
-
* @return a Promise that completes once the ack is sent
|
|
175
|
-
*/
|
|
176
|
-
ack(): Promise<void>;
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Send a reply to the request with a content payload. Used for GET requests
|
|
180
|
-
*
|
|
181
|
-
* @param payload the payload of the reply
|
|
182
|
-
* @return a Promise that completes once the reply is sent
|
|
183
|
-
*/
|
|
184
|
-
reply(payload: Object): Promise<void>;
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Send the topic where the requester should listen to get notifications. Used for OBSERVE requests.
|
|
188
|
-
* The string returned by the Promise is the id of that subscription. It can be used in parallel with
|
|
189
|
-
* the {@apilink Service.setUnsubscriptionHandler} method of the service to execute instructions when a subscription is removed.
|
|
190
|
-
*
|
|
191
|
-
* @param topic the topic where the client should
|
|
192
|
-
* @return a Promise that completes once the consumer has started to the listen to notifications. The
|
|
193
|
-
*/
|
|
194
|
-
notifyOn(topic: string): Promise<string>;
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Reply to the request with and error.
|
|
198
|
-
*
|
|
199
|
-
* @param error the error to send
|
|
200
|
-
* @return a Promise that completes once the error is sent
|
|
201
|
-
*/
|
|
202
|
-
fail(error: Error): Promise<void>;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
interface ServiceConfig {
|
|
206
|
-
/**
|
|
207
|
-
* After how much time (in ms) the message must be considered as timeout by the service.
|
|
208
|
-
*/
|
|
209
|
-
timeout?: number
|
|
14
|
+
export enum GlobalProperties {
|
|
15
|
+
EDITION = '__editionMode',
|
|
16
|
+
PRODUCTION = '__production',
|
|
17
|
+
TRANSACTION = '__transaction'
|
|
210
18
|
}
|
|
211
19
|
|
|
212
|
-
interface SubscriptionServiceConfig extends ServiceConfig {
|
|
213
|
-
/**
|
|
214
|
-
* A callback to be called in case the subscription to the service is re-sent to the service (eg: after a reconnection).
|
|
215
|
-
*/
|
|
216
|
-
onRetry?: () => void;
|
|
217
|
-
}
|
|
218
20
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
export class Service {
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Create a new instance of the service with the specified id.
|
|
226
|
-
* It uses the context to make the lifecycle of the service related to the context one.
|
|
227
|
-
*
|
|
228
|
-
* @param serviceId the service id
|
|
229
|
-
* @param context the context of that service.
|
|
230
|
-
*/
|
|
231
|
-
constructor(serviceId: string, context: Context);
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Start and listen to incoming requests.
|
|
235
|
-
*/
|
|
236
|
-
listen(): Observable<ServiceRequest>;
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Set a function to be executed each time a subscription to that service is closed.
|
|
240
|
-
* The function receives the subscription id that has been closed.
|
|
241
|
-
* The subscription id is the one that has been set and returned by the {@apilink ServiceRequest.notifyOn} method.
|
|
242
|
-
*
|
|
243
|
-
* @param handler the handler function to be executed when a subscription is closed.
|
|
244
|
-
* @return this Service instance.
|
|
245
|
-
*/
|
|
246
|
-
setUnsubscriptionHandler(handler: (subId: string) => void): this
|
|
21
|
+
// **********************************
|
|
22
|
+
// Primitives
|
|
23
|
+
// **********************************
|
|
247
24
|
|
|
248
|
-
/**
|
|
249
|
-
* Stop the service.
|
|
250
|
-
*/
|
|
251
|
-
stop(): void
|
|
252
25
|
|
|
253
|
-
|
|
254
|
-
* Publish a message on the specified service without waiting for any acknowledge
|
|
255
|
-
*
|
|
256
|
-
* @param service the service id
|
|
257
|
-
* @param payload
|
|
258
|
-
*/
|
|
259
|
-
static publish(service: string, payload: Object): Promise<void>;
|
|
26
|
+
export type List<T> = Array<T> | (T extends CloudObject | CloudObject[] ? QueryResult<T> : never);
|
|
260
27
|
|
|
261
|
-
|
|
262
|
-
* Send a request to a {@apilink Service} and wait for an ack.
|
|
263
|
-
*
|
|
264
|
-
* @param service the service id
|
|
265
|
-
* @param payload the message payload, optional
|
|
266
|
-
* @param config optional parameters for the message
|
|
267
|
-
* @return a Promise that completes when the call has been executed
|
|
268
|
-
*/
|
|
269
|
-
static send(service: string, payload?: Object, config?: ServiceConfig): Promise<void>;
|
|
28
|
+
export type Class<T> = {new (): T};
|
|
270
29
|
|
|
271
|
-
/**
|
|
272
|
-
* Send a request to a {@apilink Service} and wait for a reply with a payload..
|
|
273
|
-
*
|
|
274
|
-
* @param service the service id
|
|
275
|
-
* @param payload the message payload
|
|
276
|
-
* @param config optional parameters for the message
|
|
277
|
-
* @return a Promise wrapping the resulting value
|
|
278
|
-
*/
|
|
279
|
-
static get(service: string, payload: Object, config?: ServiceConfig): Promise<Object>;
|
|
280
30
|
|
|
281
|
-
/**
|
|
282
|
-
* Send a request to a {@apilink Service} and subscribe to notifications published from that service.
|
|
283
|
-
*
|
|
284
|
-
* @param service the service id
|
|
285
|
-
* @param context the context used to link its lifecycle to this subscription
|
|
286
|
-
* @param payload the message payload, optional
|
|
287
|
-
* @param config optional parameters for the message
|
|
288
|
-
* @return an Observable emitting notifications
|
|
289
|
-
*/
|
|
290
|
-
static observe(service: string, context: Context, payload?: Object, config?: SubscriptionServiceConfig): Observable<Object>;
|
|
291
|
-
}
|
|
292
31
|
|
|
293
32
|
// -- Authentication --
|
|
294
33
|
|
|
@@ -332,21 +71,21 @@ export class Auth {
|
|
|
332
71
|
/**
|
|
333
72
|
* Return the current state of the authentication manager
|
|
334
73
|
*
|
|
335
|
-
* @deprecated use {@
|
|
74
|
+
* @deprecated use {@link Auth.isAuthenticated} instead
|
|
336
75
|
* @return the current state
|
|
337
76
|
*/
|
|
338
77
|
static getState(): AuthState;
|
|
339
78
|
|
|
340
79
|
/**
|
|
341
80
|
* Return the token currently used to identify the current session.
|
|
342
|
-
* @deprecated see {@
|
|
81
|
+
* @deprecated see {@link Auth.getUserToken}
|
|
343
82
|
* @return The current token
|
|
344
83
|
*/
|
|
345
84
|
static getToken(): string;
|
|
346
85
|
|
|
347
86
|
/**
|
|
348
87
|
* Return the IDP token (zipped & base64 encoded XML) for the current user.
|
|
349
|
-
* @deprecated use {@
|
|
88
|
+
* @deprecated use {@link Auth.getUserToken} instead
|
|
350
89
|
* @return The current IDP token
|
|
351
90
|
*/
|
|
352
91
|
static getIDPToken(): string;
|
|
@@ -390,7 +129,7 @@ export class Auth {
|
|
|
390
129
|
/**
|
|
391
130
|
* Refresh the session token to keep it alive.
|
|
392
131
|
*
|
|
393
|
-
* @deprecated use {@
|
|
132
|
+
* @deprecated use {@link Auth.refreshToken} instead
|
|
394
133
|
*/
|
|
395
134
|
static sendKeepAlive(): void;
|
|
396
135
|
|
|
@@ -417,7 +156,7 @@ export class Auth {
|
|
|
417
156
|
* Try to login using SAML protocol with the specified username and password.
|
|
418
157
|
* Returns a promise resolved when logged in or that catches an error if refused.
|
|
419
158
|
*
|
|
420
|
-
* @deprecated use {@
|
|
159
|
+
* @deprecated use {@link Auth.loginSSO} instead
|
|
421
160
|
* @throws {Error} If the provider's configuration is incorrect.
|
|
422
161
|
*/
|
|
423
162
|
static loginSAML(): Promise<void>;
|
|
@@ -426,7 +165,7 @@ export class Auth {
|
|
|
426
165
|
* Try to login using the configured OpenID Provider.
|
|
427
166
|
* Returns a promise resolved when logged in or that catches an error if the login is not valid.
|
|
428
167
|
*
|
|
429
|
-
* @deprecated use {@
|
|
168
|
+
* @deprecated use {@link Auth.loginSSO} instead
|
|
430
169
|
* @throws {Error} If the provider's configuration is incorrect.
|
|
431
170
|
*/
|
|
432
171
|
static loginOpenID(): Promise<void>;
|
|
@@ -533,3 +272,137 @@ declare type CacheStatus = {
|
|
|
533
272
|
processed: number,
|
|
534
273
|
}
|
|
535
274
|
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Softcoded application context
|
|
278
|
+
*
|
|
279
|
+
* Contexts have parents and children, they represent the lifecycle of bricks.
|
|
280
|
+
* They contain callbacks executed at specific time of the brick lifespan.
|
|
281
|
+
*
|
|
282
|
+
* Each time a brick is updated with new inputs, {@link Context.clear} is called,
|
|
283
|
+
* executing all callbacks registered with {@link Context.onClear}.
|
|
284
|
+
*
|
|
285
|
+
* When a brick is destroyed, {@link Context.destroy} is called,
|
|
286
|
+
* executing all callbacks registered with {@link Context.onClear} and {@link Context.onDestroy}
|
|
287
|
+
*/
|
|
288
|
+
export abstract class Context {
|
|
289
|
+
/**
|
|
290
|
+
* Destroy the current context. It destroys all children context attached to this one and clear their values.
|
|
291
|
+
* The context cannot be reused after calling this function.
|
|
292
|
+
*/
|
|
293
|
+
destroy(): void;
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Clear the current context: detach and destroys all children context.
|
|
297
|
+
* The context can be reused.
|
|
298
|
+
*/
|
|
299
|
+
clear(): void;
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Register a callback to execute when the context is destroyed. Return the callback id.
|
|
303
|
+
*
|
|
304
|
+
* @param callback the callback function
|
|
305
|
+
* @return the callback id
|
|
306
|
+
*/
|
|
307
|
+
onDestroy(callback: () => void): string;
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Remove a previously registered callback with {@link Context.onDestroy} method using its id.
|
|
311
|
+
*
|
|
312
|
+
* @param callbackId the id of the callback to unregister
|
|
313
|
+
*/
|
|
314
|
+
offDestroy(callbackId: string): boolean;
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Register a callback to execute every time the context is cleared.
|
|
318
|
+
* This happens every time the brick is refreshed with new inputs and during the brick destruction.
|
|
319
|
+
* Return the callback id.
|
|
320
|
+
*
|
|
321
|
+
* @param callback the callback function
|
|
322
|
+
* @return the callback id
|
|
323
|
+
*/
|
|
324
|
+
onClear(callback: () => void): string;
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Remove a previously registered callback with {@link Context.onClear} method using its id.
|
|
328
|
+
*
|
|
329
|
+
* @param id the id of the callback to unregister
|
|
330
|
+
*/
|
|
331
|
+
offClear(id: string): void;
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Whether the context is destroyed.
|
|
335
|
+
*/
|
|
336
|
+
isDestroyed(): boolean;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Types of probe that can be used to check the health of the process:
|
|
341
|
+
* - LIVENESS: used to check if the process is alive
|
|
342
|
+
* - READINESS: used to check if the process is ready to operate
|
|
343
|
+
* - ALL: used to check both liveness and readiness
|
|
344
|
+
*/
|
|
345
|
+
export enum ProbeType {
|
|
346
|
+
LIVENESS = 'liveness',
|
|
347
|
+
READINESS = 'readiness',
|
|
348
|
+
ALL = 'all'
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// Health check and shutdown
|
|
352
|
+
export class Process {
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Static method to register a callback that is used to check the health status of the process.
|
|
356
|
+
* This is typically used by kubernetes environment to maintain backend healthy
|
|
357
|
+
*
|
|
358
|
+
* The callback must return a Promise which returns a string as valid message.
|
|
359
|
+
* The process is considered by the runtime as unhealthy if the promise is rejected.
|
|
360
|
+
*
|
|
361
|
+
* The options parameter can be used to specify the type of probe to register:
|
|
362
|
+
* - LIVENESS: used to check if the process is alive
|
|
363
|
+
* - READINESS: used to check if the process is ready to operate
|
|
364
|
+
* - ALL: used to check both liveness and readiness
|
|
365
|
+
*
|
|
366
|
+
* @param callback the callback executed each time the runtime check the health of the process.
|
|
367
|
+
* @param options options to specify the type of probe to register
|
|
368
|
+
*/
|
|
369
|
+
static onHealthCheck(callback: () => Promise<string>, options?: {type: ProbeType}): () => void;
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Static method to register a callback called by the runtime when it receives the signal to be terminated.
|
|
373
|
+
* This is typically used to graceful shutdown some connections or drivers to external processes.
|
|
374
|
+
*
|
|
375
|
+
* The callback must return a Promise which is resolved when the shutdown process is done.
|
|
376
|
+
*
|
|
377
|
+
* @param callback the callback executed when the runtime terminates.
|
|
378
|
+
* @param shutdownId optional id to name the shutdown hook, mainly for debug purpose
|
|
379
|
+
*/
|
|
380
|
+
static onShutdown(callback: () => Promise<void>, shutdownId?: string): () => void;
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Static method that manually triggers a connection attempt to the server to go ONLINE.
|
|
384
|
+
* If you have called {@link Process.disconnect()} before, it will cancel the OFFLINE mode,
|
|
385
|
+
* next time the app will be opened, it will try to go ONLINE on its own.
|
|
386
|
+
*
|
|
387
|
+
* Returns a promise that resolves when the server connection is established. If it fails, the promise is rejected.
|
|
388
|
+
*/
|
|
389
|
+
static connect(): Promise<void>;
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Static method that manually close the connection to the server to go OFFLINE.
|
|
393
|
+
* Persists the offline status so the app restart offline after being closed.
|
|
394
|
+
* The only way to clean that status is to call {@link Process.connect()}.
|
|
395
|
+
*
|
|
396
|
+
* Returns a promise that resolves when the server connection is indeed disconnected and the state is OFFLINE.
|
|
397
|
+
* If the flag `offline.enabled` is not set to true, the promise is rejected.
|
|
398
|
+
*/
|
|
399
|
+
static disconnect(): Promise<void>;
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Static method that returns an observable on the connection state: the observable send TRUE if the process is considered
|
|
403
|
+
* as ONLINE and false if not.
|
|
404
|
+
*
|
|
405
|
+
* @param context the context of the brick to garbage collect the observable when not needed anymore.
|
|
406
|
+
*/
|
|
407
|
+
static isOnline(context: Context): Observable<boolean>;
|
|
408
|
+
}
|