@kinotic-ai/core 1.0.0-beta.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/dist/index.cjs +2596 -0
- package/dist/index.d.cts +1159 -0
- package/dist/index.d.ts +1159 -0
- package/dist/index.js +2565 -0
- package/package.json +75 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ConnectHeaders to use during connection to the kinoitc server
|
|
3
|
+
* These headers will be sent as part of the STOMP CONNECT frame
|
|
4
|
+
* This is typically used for authentication information, but any data can be sent
|
|
5
|
+
*/
|
|
6
|
+
declare class ConnectHeaders {
|
|
7
|
+
[key: string]: string;
|
|
8
|
+
}
|
|
9
|
+
declare class ServerInfo {
|
|
10
|
+
host: string;
|
|
11
|
+
port?: number | null;
|
|
12
|
+
useSSL?: boolean | null;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* ConnectionInfo provides the information needed to connect to the kinoitc server
|
|
16
|
+
*/
|
|
17
|
+
declare class ConnectionInfo extends ServerInfo {
|
|
18
|
+
/**
|
|
19
|
+
* The headers to send during the connection to the kinoitc server.
|
|
20
|
+
* If a function is provided, it will be called to get the headers each time the connection is established.
|
|
21
|
+
* This is useful for providing dynamic headers, such as a JWT token that expires.
|
|
22
|
+
*/
|
|
23
|
+
connectHeaders?: ConnectHeaders | (() => Promise<ConnectHeaders>);
|
|
24
|
+
/**
|
|
25
|
+
* The maximum number of connection attempts to make during the {@link IEventBus} initial connection request.
|
|
26
|
+
* If the limit is reached the {@link IEventBus} will return an error to the caller of {@link IEventBus#connect}
|
|
27
|
+
* Set to 0, undefined, or null to try forever
|
|
28
|
+
*/
|
|
29
|
+
maxConnectionAttempts?: number | null;
|
|
30
|
+
/**
|
|
31
|
+
* If true, the session will not be kept alive after the connection is established and then disrupted.
|
|
32
|
+
* If false, the session will be kept alive after the connection is established and then disrupted, for a period of time.
|
|
33
|
+
*/
|
|
34
|
+
disableStickySession?: boolean | null;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Instances of this interface have a unique id (identity) and are therefore "Identifiable"
|
|
38
|
+
* Created by navid on 2/3/20
|
|
39
|
+
*/
|
|
40
|
+
interface Identifiable<T> {
|
|
41
|
+
id: T | null;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Created by Navíd Mitchell 🤪on 6/16/23.
|
|
45
|
+
*/
|
|
46
|
+
interface IParticipant extends Identifiable<string> {
|
|
47
|
+
/**
|
|
48
|
+
* The identity of the participant
|
|
49
|
+
*
|
|
50
|
+
* @return the identity of the participant
|
|
51
|
+
*/
|
|
52
|
+
id: string;
|
|
53
|
+
/**
|
|
54
|
+
* The tenant that the participant belongs to
|
|
55
|
+
*
|
|
56
|
+
* @return the tenant or null if not using multi-tenancy
|
|
57
|
+
*/
|
|
58
|
+
tenantId?: string | null;
|
|
59
|
+
/**
|
|
60
|
+
* Metadata is a map of key value pairs that can be used to store additional information about a participant
|
|
61
|
+
*
|
|
62
|
+
* @return a map of key value pairs
|
|
63
|
+
*/
|
|
64
|
+
metadata: Map<string, string>;
|
|
65
|
+
/**
|
|
66
|
+
* Roles are a list of strings that can be used to authorize a participant to perform certain actions
|
|
67
|
+
*
|
|
68
|
+
* @return a list of roles
|
|
69
|
+
*/
|
|
70
|
+
roles: string[];
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Created by Navid Mitchell on 6/2/20
|
|
74
|
+
*/
|
|
75
|
+
declare class Participant implements IParticipant {
|
|
76
|
+
id: string;
|
|
77
|
+
tenantId?: string | null;
|
|
78
|
+
metadata: Map<string, string>;
|
|
79
|
+
roles: string[];
|
|
80
|
+
constructor(id: string, tenantId?: string, metadata?: Map<string, string>, roles?: string[]);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Contains information about the connection that was established
|
|
84
|
+
*/
|
|
85
|
+
declare class ConnectedInfo {
|
|
86
|
+
sessionId: string;
|
|
87
|
+
replyToId: string;
|
|
88
|
+
participant: Participant;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* A page is a sublist of a list of objects.
|
|
92
|
+
* @author Navid Mitchell
|
|
93
|
+
*/
|
|
94
|
+
interface Page<T> {
|
|
95
|
+
/**
|
|
96
|
+
* @return the total number of elements or null or undefined if not known.
|
|
97
|
+
*/
|
|
98
|
+
readonly totalElements: number | null | undefined;
|
|
99
|
+
/**
|
|
100
|
+
* The cursor to be used for subsequent retrieval of data.
|
|
101
|
+
* @return an opaque string representation of the cursor, or null if this is the last page, or undefined if cursor paging is not being used.
|
|
102
|
+
*/
|
|
103
|
+
readonly cursor: string | null | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* @return the page content as {@link Array} or null or undefined if no data is available.
|
|
106
|
+
*/
|
|
107
|
+
readonly content: T[] | null | undefined;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Enumeration for sort directions.
|
|
111
|
+
*
|
|
112
|
+
* Adapted from the Spring Data Commons Package
|
|
113
|
+
*
|
|
114
|
+
* @author Oliver Gierke
|
|
115
|
+
* @author Navid Mitchell
|
|
116
|
+
*/
|
|
117
|
+
declare enum Direction {
|
|
118
|
+
ASC = "ASC",
|
|
119
|
+
DESC = "DESC"
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Enumeration for null handling hints that can be used in {@link Order} expressions.
|
|
123
|
+
*
|
|
124
|
+
* Adapted from the Spring Data Commons Package
|
|
125
|
+
*
|
|
126
|
+
* @author Thomas Darimont
|
|
127
|
+
* @author Navid Mitchell
|
|
128
|
+
* @since 1.8
|
|
129
|
+
*/
|
|
130
|
+
declare enum NullHandling {
|
|
131
|
+
/**
|
|
132
|
+
* Lets the data store decide what to do with nulls.
|
|
133
|
+
*/
|
|
134
|
+
NATIVE = "NATIVE",
|
|
135
|
+
/**
|
|
136
|
+
* A hint to the used data store to order entries with null values before non-null entries.
|
|
137
|
+
*/
|
|
138
|
+
NULLS_FIRST = "NULLS_FIRST",
|
|
139
|
+
/**
|
|
140
|
+
* A hint to the used data store to order entries with null values after non-null entries.
|
|
141
|
+
*/
|
|
142
|
+
NULLS_LAST = "NULLS_LAST"
|
|
143
|
+
}
|
|
144
|
+
declare class Order {
|
|
145
|
+
property: string;
|
|
146
|
+
direction: Direction;
|
|
147
|
+
nullHandling: NullHandling;
|
|
148
|
+
constructor(property: string, direction: Direction | null);
|
|
149
|
+
/**
|
|
150
|
+
* Returns whether sorting for this property shall be ascending.
|
|
151
|
+
*/
|
|
152
|
+
isAscending(): boolean;
|
|
153
|
+
/**
|
|
154
|
+
* Returns whether sorting for this property shall be descending.
|
|
155
|
+
*/
|
|
156
|
+
isDescending(): boolean;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Sort option for queries. You have to provide at least a list of properties to sort for that must not include
|
|
160
|
+
* {@literal null} or empty strings. The direction defaults to {@link Sort#DEFAULT_DIRECTION}.
|
|
161
|
+
*
|
|
162
|
+
* Adapted from the Spring Data Commons Package
|
|
163
|
+
*
|
|
164
|
+
* @author Oliver Gierke
|
|
165
|
+
* @author Thomas Darimont
|
|
166
|
+
* @author Mark Paluch
|
|
167
|
+
* @author Navid Mitchell
|
|
168
|
+
*/
|
|
169
|
+
declare class Sort {
|
|
170
|
+
orders: Order[];
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Abstract interface for pagination information.
|
|
174
|
+
*
|
|
175
|
+
* Adapted from the Spring Data Commons Package
|
|
176
|
+
*
|
|
177
|
+
* @author Oliver Gierke
|
|
178
|
+
* @author Navid Mitchell
|
|
179
|
+
*/
|
|
180
|
+
declare abstract class Pageable {
|
|
181
|
+
/**
|
|
182
|
+
* Returns the sorting parameters (optional).
|
|
183
|
+
*/
|
|
184
|
+
sort?: Sort | null | undefined;
|
|
185
|
+
/**
|
|
186
|
+
* Returns the number of items to be returned.
|
|
187
|
+
*/
|
|
188
|
+
pageSize: number;
|
|
189
|
+
/**
|
|
190
|
+
* Creates a {@link Pageable} that uses Offset based pagination.
|
|
191
|
+
* @param pageNumber zero based page index.
|
|
192
|
+
* @param pageSize the size of the page to be returned.
|
|
193
|
+
* @param sort the sorting parameters (optional).
|
|
194
|
+
*/
|
|
195
|
+
static create(pageNumber: number, pageSize: number, sort?: Sort | null): OffsetPageable;
|
|
196
|
+
/**
|
|
197
|
+
* Creates a {@link Pageable} that uses Cursor based pagination.
|
|
198
|
+
* @param cursor the cursor to be used for subsequent retrieval of data, or null if this is the first page.
|
|
199
|
+
* @param pageSize the size of the page to be returned.
|
|
200
|
+
* @param sort the sorting parameters (optional).
|
|
201
|
+
*/
|
|
202
|
+
static createWithCursor(cursor: string | null, pageSize: number, sort?: Sort | null): CursorPageable;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Implementation of {@link Pageable} that uses Offset based pagination.
|
|
206
|
+
*/
|
|
207
|
+
declare class OffsetPageable extends Pageable {
|
|
208
|
+
/**
|
|
209
|
+
* Returns the page to be returned.
|
|
210
|
+
*/
|
|
211
|
+
pageNumber: number;
|
|
212
|
+
/**
|
|
213
|
+
* Creates a {@link Pageable} that uses Offset based pagination.
|
|
214
|
+
* @param pageNumber zero based page index.
|
|
215
|
+
* @param pageSize the size of the page to be returned.
|
|
216
|
+
* @param sort the sorting parameters (optional).
|
|
217
|
+
*/
|
|
218
|
+
constructor(pageNumber: number, pageSize: number, sort?: Sort | null);
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Implementation of {@link Pageable} that uses Cursor based pagination.
|
|
222
|
+
*/
|
|
223
|
+
declare class CursorPageable extends Pageable {
|
|
224
|
+
/**
|
|
225
|
+
* The cursor to be used for subsequent retrieval of data, or null if this is the first page.
|
|
226
|
+
*/
|
|
227
|
+
cursor: string | null;
|
|
228
|
+
/**
|
|
229
|
+
* Creates a {@link Pageable} that uses Cursor based pagination.
|
|
230
|
+
* @param cursor the cursor to be used for subsequent retrieval of data, or null if this is the first page.
|
|
231
|
+
* @param pageSize the size of the page to be returned.
|
|
232
|
+
* @param sort the sorting parameters (optional).
|
|
233
|
+
*/
|
|
234
|
+
constructor(cursor: string | null, pageSize: number, sort?: Sort | null);
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* {@link IDataSource} provides an abstract way to retrieve data from various sources
|
|
238
|
+
*/
|
|
239
|
+
interface IDataSource<T> {
|
|
240
|
+
/**
|
|
241
|
+
* Returns a {@link Page} of entities meeting the paging restriction provided in the {@code Pageable} object.
|
|
242
|
+
*
|
|
243
|
+
* @param pageable the page settings to be used
|
|
244
|
+
* @return a {@link Promise} emitting the page of entities
|
|
245
|
+
*/
|
|
246
|
+
findAll(pageable: Pageable): Promise<IterablePage<T>>;
|
|
247
|
+
/**
|
|
248
|
+
* Returns a {@link Page} of entities matching the search text and paging restriction provided in the {@code Pageable} object.
|
|
249
|
+
*
|
|
250
|
+
* @param searchText the text to search for entities for
|
|
251
|
+
* @param pageable the page settings to be used
|
|
252
|
+
* @return a {@link Promise} emitting the page of entities
|
|
253
|
+
*/
|
|
254
|
+
search(searchText: string, pageable: Pageable): Promise<IterablePage<T>>;
|
|
255
|
+
}
|
|
256
|
+
interface IEditableDataSource<T extends Identifiable<string>> extends IDataSource<T> {
|
|
257
|
+
/**
|
|
258
|
+
* Creates a new entity if one does not already exist for the given id
|
|
259
|
+
* @param entity to create if one does not already exist
|
|
260
|
+
* @return a {@link Promise} containing the new entity or an error if an exception occurred
|
|
261
|
+
*/
|
|
262
|
+
create(entity: T): Promise<T>;
|
|
263
|
+
/**
|
|
264
|
+
* Saves a given entity. Use the returned instance for further operations as the save operation might have changed the
|
|
265
|
+
* entity instance completely.
|
|
266
|
+
*
|
|
267
|
+
* @param entity must not be {@literal null}.
|
|
268
|
+
* @return a {@link Promise} emitting the saved entity.
|
|
269
|
+
* @throws Error in case the given {@literal entity} is {@literal null}.
|
|
270
|
+
*/
|
|
271
|
+
save(entity: T): Promise<T>;
|
|
272
|
+
/**
|
|
273
|
+
* Retrieves an entity by its id.
|
|
274
|
+
*
|
|
275
|
+
* @param id must not be {@literal null}.
|
|
276
|
+
* @return a {@link Promise} emitting the entity with the given id or {@link Promise#empty()} if none found.
|
|
277
|
+
* @throws IllegalArgumentException in case the given {@literal identity} is {@literal null}.
|
|
278
|
+
*/
|
|
279
|
+
findById(id: string): Promise<T>;
|
|
280
|
+
/**
|
|
281
|
+
* Deletes the entity with the given id.
|
|
282
|
+
*
|
|
283
|
+
* @param id must not be {@literal null}.
|
|
284
|
+
* @return a {@link Promise} signaling when operation has completed.
|
|
285
|
+
* @throws IllegalArgumentException in case the given {@literal identity} is {@literal null}.
|
|
286
|
+
*/
|
|
287
|
+
deleteById(id: string): Promise<void>;
|
|
288
|
+
/**
|
|
289
|
+
* Returns a {@link Page} of entities not in the ids list and meeting the paging restriction provided in the {@code Pageable} object.
|
|
290
|
+
*
|
|
291
|
+
* @param ids not to be returned in the Page
|
|
292
|
+
* @param pageable the page settings to be used
|
|
293
|
+
* @return a {@link Promise} emitting the page of entities
|
|
294
|
+
*/
|
|
295
|
+
findByIdNotIn(ids: string[], pageable: Pageable): Promise<Page<Identifiable<string>>>;
|
|
296
|
+
}
|
|
297
|
+
declare class DataSourceUtils {
|
|
298
|
+
static instanceOfEditableDataSource(datasource: IDataSource<any> | IEditableDataSource<any>): datasource is IEditableDataSource<any>;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* A {@link ICrudServiceProxy} is a proxy for a remote CRUD service
|
|
302
|
+
*/
|
|
303
|
+
interface ICrudServiceProxy<T extends Identifiable<string>> extends IEditableDataSource<T> {
|
|
304
|
+
/**
|
|
305
|
+
* Creates a new entity if one does not already exist for the given id
|
|
306
|
+
* @param entity to create if one does not already exist
|
|
307
|
+
* @return a {@link Promise} containing the new entity or an error if an exception occurred
|
|
308
|
+
*/
|
|
309
|
+
create(entity: T): Promise<T>;
|
|
310
|
+
/**
|
|
311
|
+
* Saves a given entity. Use the returned instance for further operations as the save operation might have changed the
|
|
312
|
+
* entity instance completely.
|
|
313
|
+
*
|
|
314
|
+
* @param entity must not be {@literal null}.
|
|
315
|
+
* @return a {@link Promise} emitting the saved entity.
|
|
316
|
+
* @throws Error in case the given {@literal entity} is {@literal null}.
|
|
317
|
+
*/
|
|
318
|
+
save(entity: T): Promise<T>;
|
|
319
|
+
/**
|
|
320
|
+
* Retrieves an entity by its id.
|
|
321
|
+
*
|
|
322
|
+
* @param id must not be {@literal null}.
|
|
323
|
+
* @return a {@link Promise} emitting the entity with the given id or {@link Promise#empty()} if none found.
|
|
324
|
+
* @throws IllegalArgumentException in case the given {@literal identity} is {@literal null}.
|
|
325
|
+
*/
|
|
326
|
+
findById(id: string): Promise<T>;
|
|
327
|
+
/**s
|
|
328
|
+
* Returns the number of entities available.
|
|
329
|
+
*
|
|
330
|
+
* @return a {@link Promise} emitting the number of entities.
|
|
331
|
+
*/
|
|
332
|
+
count(): Promise<number>;
|
|
333
|
+
/**
|
|
334
|
+
* Deletes the entity with the given id.
|
|
335
|
+
*
|
|
336
|
+
* @param id must not be {@literal null}.
|
|
337
|
+
* @return a {@link Promise} signaling when operation has completed.
|
|
338
|
+
* @throws IllegalArgumentException in case the given {@literal identity} is {@literal null}.
|
|
339
|
+
*/
|
|
340
|
+
deleteById(id: string): Promise<void>;
|
|
341
|
+
/**
|
|
342
|
+
* Returns a {@link Page} of entities meeting the paging restriction provided in the {@code Pageable} object.
|
|
343
|
+
*
|
|
344
|
+
* @param pageable the page settings to be used
|
|
345
|
+
* @return a {@link Promise} emitting the page of entities
|
|
346
|
+
*/
|
|
347
|
+
findAll(pageable: Pageable): Promise<IterablePage<T>>;
|
|
348
|
+
/**
|
|
349
|
+
* Returns a {@link Page} of entities not in the ids list and meeting the paging restriction provided in the {@code Pageable} object.
|
|
350
|
+
*
|
|
351
|
+
* @param ids not to be returned in the Page
|
|
352
|
+
* @param pageable the page settings to be used
|
|
353
|
+
* @return a {@link Promise} emitting the page of entities
|
|
354
|
+
*/
|
|
355
|
+
findByIdNotIn(ids: string[], pageable: Pageable): Promise<Page<Identifiable<string>>>;
|
|
356
|
+
/**
|
|
357
|
+
* Returns a {@link Page} of entities matching the search text and paging restriction provided in the {@code Pageable} object.
|
|
358
|
+
*
|
|
359
|
+
* @param searchText the text to search for entities for
|
|
360
|
+
* @param pageable the page settings to be used
|
|
361
|
+
* @return a {@link Promise} emitting the page of entities
|
|
362
|
+
*/
|
|
363
|
+
search(searchText: string, pageable: Pageable): Promise<IterablePage<T>>;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Produces {@link ICrudServiceProxy} Proxies for a known remote CRUD service
|
|
367
|
+
*/
|
|
368
|
+
interface ICrudServiceProxyFactory {
|
|
369
|
+
/**
|
|
370
|
+
* Produces a {@link ICrudServiceProxy} for the given serviceIdentifier
|
|
371
|
+
* @param serviceIdentifier the service identifier to produce a proxy for
|
|
372
|
+
*/
|
|
373
|
+
crudServiceProxy<T extends Identifiable<string>>(serviceIdentifier: string): ICrudServiceProxy<T>;
|
|
374
|
+
}
|
|
375
|
+
import { Optional } from "typescript-optional";
|
|
376
|
+
import { Observable } from "rxjs";
|
|
377
|
+
/**
|
|
378
|
+
* Base error class for all Kinoitc errors
|
|
379
|
+
*/
|
|
380
|
+
declare class KinoticError extends Error {
|
|
381
|
+
constructor(message: string);
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Part of the low level portion of kinoitc representing data to be processed
|
|
385
|
+
*
|
|
386
|
+
* This is similar to a Stomp Frame but with more required information and no control plane semantics.
|
|
387
|
+
*
|
|
388
|
+
*
|
|
389
|
+
* Created by Navid Mitchell on 2019-01-04.
|
|
390
|
+
*/
|
|
391
|
+
interface IEvent {
|
|
392
|
+
/**
|
|
393
|
+
* The cri that specifies where the event should be routed
|
|
394
|
+
*/
|
|
395
|
+
cri: string;
|
|
396
|
+
/**
|
|
397
|
+
* Any headers defined for this event.
|
|
398
|
+
* This will usually contain all the fields above as well since they are typically wrappers around expected header values.
|
|
399
|
+
*/
|
|
400
|
+
headers: Map<string, string>;
|
|
401
|
+
/**
|
|
402
|
+
* The event payload. The payload depends on the type the payload is encoded into a media format which is specified by the contentType attribute (e.g. application/json).
|
|
403
|
+
*/
|
|
404
|
+
data: Optional<Uint8Array>;
|
|
405
|
+
/**
|
|
406
|
+
* @return the data property as a UTF-8 encoded string
|
|
407
|
+
*/
|
|
408
|
+
getDataString(): string;
|
|
409
|
+
/**
|
|
410
|
+
* Gets the value for the header with the given key
|
|
411
|
+
* @param key to get the header value for
|
|
412
|
+
* @return the header value or undefined if there is no header for the key
|
|
413
|
+
*/
|
|
414
|
+
getHeader(key: string): string | undefined;
|
|
415
|
+
/**
|
|
416
|
+
* Tests if a header for the given key exists
|
|
417
|
+
* @param key to check if exists as a header
|
|
418
|
+
* @return true if the header for the key exists false if not
|
|
419
|
+
*/
|
|
420
|
+
hasHeader(key: string): boolean;
|
|
421
|
+
/**
|
|
422
|
+
* Removes the header from the headers map
|
|
423
|
+
* @param key to remove
|
|
424
|
+
* @return true if an element in the headers map object existed and has been removed, or false if the element does not exist
|
|
425
|
+
*/
|
|
426
|
+
removeHeader(key: string): boolean;
|
|
427
|
+
/**
|
|
428
|
+
* Sets the data property from the given string value
|
|
429
|
+
* @param data
|
|
430
|
+
*/
|
|
431
|
+
setDataString(data: string): void;
|
|
432
|
+
/**
|
|
433
|
+
* Sets the header into the headers map
|
|
434
|
+
* @param key the key to use
|
|
435
|
+
* @param value the value to use
|
|
436
|
+
*/
|
|
437
|
+
setHeader(key: string, value: string): void;
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Part of the low level portion of kinoitc representing a connection to a kinoitc server
|
|
441
|
+
* This is similar to a Stomp Client but with more required information and no control plane semantics.
|
|
442
|
+
*
|
|
443
|
+
* Created by Navid Mitchell on 2019-01-04.
|
|
444
|
+
*/
|
|
445
|
+
interface IEventBus {
|
|
446
|
+
/**
|
|
447
|
+
* Any errors emitted by this observable will be fatal and the connection will be closed.
|
|
448
|
+
* You will need to resolve the problem and reconnect.
|
|
449
|
+
*/
|
|
450
|
+
fatalErrors: Observable<KinoticError>;
|
|
451
|
+
/**
|
|
452
|
+
* The {@link ServerInfo} used when connecting, if connected or null
|
|
453
|
+
*/
|
|
454
|
+
serverInfo: ServerInfo | null;
|
|
455
|
+
/**
|
|
456
|
+
* Requests a connection to the given Stomp url
|
|
457
|
+
* @param connectionInfo provides the information needed to connect to the kinoitc server
|
|
458
|
+
* @return Promise containing the result of the initial connection attempt
|
|
459
|
+
*/
|
|
460
|
+
connect(connectionInfo: ConnectionInfo): Promise<ConnectedInfo>;
|
|
461
|
+
/**
|
|
462
|
+
* Disconnects the client from the server
|
|
463
|
+
* This will clear any subscriptions and close the connection
|
|
464
|
+
* @param force if true then the connection will be closed immediately without sending a disconnect frame
|
|
465
|
+
* When this mode is used, the actual Websocket may linger for a while
|
|
466
|
+
* and the broker may not realize that the connection is no longer in use.
|
|
467
|
+
*
|
|
468
|
+
* @return Promise containing the result of the disconnect attempt
|
|
469
|
+
*/
|
|
470
|
+
disconnect(force?: boolean): Promise<void>;
|
|
471
|
+
/**
|
|
472
|
+
* Determines if the connection is connected.
|
|
473
|
+
* This means that there is an open connection to the Kinoitc server
|
|
474
|
+
* @return true if the connection is active false if not
|
|
475
|
+
*/
|
|
476
|
+
isConnected(): boolean;
|
|
477
|
+
/**
|
|
478
|
+
* Determines if the connection is active.
|
|
479
|
+
* This means {@link IEventBus#connect()} was called and was successful. The underlying connection may not be established yet.
|
|
480
|
+
* If this is true and {@link IEventBus#isConnected} is false messages sent will be queued
|
|
481
|
+
* @return true if the connection is active false if not
|
|
482
|
+
*/
|
|
483
|
+
isConnectionActive(): boolean;
|
|
484
|
+
/**
|
|
485
|
+
* Starts a local event bus server to listen for incoming connections
|
|
486
|
+
* NOTE: Not all implementations will support this
|
|
487
|
+
* @param serverInfo to listen on
|
|
488
|
+
*/
|
|
489
|
+
listen(serverInfo: ServerInfo): Promise<void>;
|
|
490
|
+
/**
|
|
491
|
+
* Creates a subscription for all {@link IEvent}'s for the given destination
|
|
492
|
+
* @param cri to subscribe to
|
|
493
|
+
*/
|
|
494
|
+
observe(cri: string): Observable<IEvent>;
|
|
495
|
+
/**
|
|
496
|
+
* Sends an {@link IEvent} expecting a response
|
|
497
|
+
* All response correlation will be handled internally
|
|
498
|
+
* @param event to send as the request
|
|
499
|
+
* @return a Promise that will resolve when the response is received
|
|
500
|
+
*/
|
|
501
|
+
request(event: IEvent): Promise<IEvent>;
|
|
502
|
+
/**
|
|
503
|
+
* Sends an {@link IEvent} expecting multiple responses
|
|
504
|
+
* All response correlation will be handled internally
|
|
505
|
+
* @param event to send as the request
|
|
506
|
+
* @param sendControlEvents if true then control events will be sent to the server when changes to the returned to Observable are requested
|
|
507
|
+
* @return an {@link Observable<IEvent} that will provide the response stream
|
|
508
|
+
* NOTE: the naming here is similar to RSocket https://www.baeldung.com/rsocket#3-requeststream
|
|
509
|
+
*/
|
|
510
|
+
requestStream(event: IEvent, sendControlEvents: boolean): Observable<IEvent>;
|
|
511
|
+
/**
|
|
512
|
+
* Send a single {@link IEvent} to the connected server
|
|
513
|
+
* @param event to send
|
|
514
|
+
*/
|
|
515
|
+
send(event: IEvent): void;
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Constants used within {@link IEvent}'s to control the flow of events
|
|
519
|
+
* Header that start with __ will always be persisted between messages
|
|
520
|
+
*/
|
|
521
|
+
declare enum EventConstants {
|
|
522
|
+
CONTENT_TYPE_HEADER = "content-type",
|
|
523
|
+
CONTENT_LENGTH_HEADER = "content-length",
|
|
524
|
+
REPLY_TO_HEADER = "reply-to",
|
|
525
|
+
/**
|
|
526
|
+
* This is the replyToId that will be supplied by the client, which will be used when sending replies to the client.
|
|
527
|
+
*/
|
|
528
|
+
REPLY_TO_ID_HEADER = "reply-to-id",
|
|
529
|
+
/**
|
|
530
|
+
* Header provided by the sever on connection to represent the user's session id
|
|
531
|
+
*/
|
|
532
|
+
SESSION_HEADER = "session",
|
|
533
|
+
/**
|
|
534
|
+
* Header provided by the server on connection to provide the {@link ConnectionInfo} as a JSON string
|
|
535
|
+
*/
|
|
536
|
+
CONNECTED_INFO_HEADER = "connected-info",
|
|
537
|
+
/**
|
|
538
|
+
* Header provided by the client on connection request to represent that the server
|
|
539
|
+
* should not keep the session alive after any network disconnection.
|
|
540
|
+
*/
|
|
541
|
+
DISABLE_STICKY_SESSION_HEADER = "disable-sticky-session",
|
|
542
|
+
/**
|
|
543
|
+
* Correlates a response with a given request
|
|
544
|
+
* Headers that start with __ will always be persisted between messages
|
|
545
|
+
*/
|
|
546
|
+
CORRELATION_ID_HEADER = "__correlation-id",
|
|
547
|
+
/**
|
|
548
|
+
* Denotes that something caused an error. Will contain a brief message about the error
|
|
549
|
+
*/
|
|
550
|
+
ERROR_HEADER = "error",
|
|
551
|
+
/**
|
|
552
|
+
* Denotes the completion of an event stream. The value typically will contain the reason for completion.
|
|
553
|
+
*/
|
|
554
|
+
COMPLETE_HEADER = "complete",
|
|
555
|
+
/**
|
|
556
|
+
* Denotes the event is a control plane event. These are used for internal coordination.
|
|
557
|
+
*/
|
|
558
|
+
CONTROL_HEADER = "control",
|
|
559
|
+
/**
|
|
560
|
+
* Stream is complete, no further values will be sent.
|
|
561
|
+
*/
|
|
562
|
+
CONTROL_VALUE_COMPLETE = "complete",
|
|
563
|
+
CONTROL_VALUE_CANCEL = "cancel",
|
|
564
|
+
CONTROL_VALUE_SUSPEND = "suspend",
|
|
565
|
+
CONTROL_VALUE_RESUME = "resume",
|
|
566
|
+
SERVICE_DESTINATION_PREFIX = "srv://",
|
|
567
|
+
SERVICE_DESTINATION_SCHEME = "srv",
|
|
568
|
+
STREAM_DESTINATION_PREFIX = "stream://",
|
|
569
|
+
STREAM_DESTINATION_SCHEME = "stream",
|
|
570
|
+
CONTENT_JSON = "application/json",
|
|
571
|
+
CONTENT_TEXT = "text/plain",
|
|
572
|
+
/**
|
|
573
|
+
* The traceparent HTTP header field identifies the incoming request in a tracing system. It has four fields:
|
|
574
|
+
*
|
|
575
|
+
* version
|
|
576
|
+
* trace-id
|
|
577
|
+
* parent-id
|
|
578
|
+
* trace-flags
|
|
579
|
+
* @see https://www.w3.org/TR/trace-context/#traceparent-header
|
|
580
|
+
*/
|
|
581
|
+
TRACEPARENT_HEADER = "traceparent",
|
|
582
|
+
/**
|
|
583
|
+
* The main purpose of the tracestate header is to provide additional vendor-specific trace identification information across different distributed tracing systems and is a companion header for the traceparent field. It also conveys information about the request’s position in multiple distributed tracing graphs.
|
|
584
|
+
* @see https://www.w3.org/TR/trace-context/#tracestate-header
|
|
585
|
+
*/
|
|
586
|
+
TRACESTATE_HEADER = "tracestate"
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* Interface for the service context, extendable by users for type-safe context data.
|
|
590
|
+
*
|
|
591
|
+
* @author Navid Mitchell 🤝Grok
|
|
592
|
+
* @since 3/25/2025
|
|
593
|
+
*/
|
|
594
|
+
interface ServiceContext {
|
|
595
|
+
[key: string]: any;
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* Interface for interceptors that create or modify the ServiceContext before service method invocation.
|
|
599
|
+
*
|
|
600
|
+
* @author Navid Mitchell 🤝Grok
|
|
601
|
+
* @since 3/25/2025
|
|
602
|
+
*/
|
|
603
|
+
interface ContextInterceptor<T extends ServiceContext> {
|
|
604
|
+
intercept(event: IEvent, context: T): Promise<T> | T;
|
|
605
|
+
}
|
|
606
|
+
/**
|
|
607
|
+
* `CRI` is a Kinoitc Resource Identifier used by Kinoitc to route requests appropriately.
|
|
608
|
+
*
|
|
609
|
+
* The `CRI` is a URI where the parts are named differently for clarity as to their purpose within Kinoitc.
|
|
610
|
+
*
|
|
611
|
+
* Will be in a format as follows where anything surrounded with `[]` is optional:
|
|
612
|
+
*
|
|
613
|
+
* scheme://[scope@]resourceName[/path][#version]
|
|
614
|
+
*
|
|
615
|
+
* NOTE: If scope needs to be used to identify a sub-scope, it will follow the form `scope = scope:sub-scope`.
|
|
616
|
+
*
|
|
617
|
+
* This format can have varied meanings based upon the scheme used.
|
|
618
|
+
*
|
|
619
|
+
* @author Navid Mitchell
|
|
620
|
+
* @since 3/25/25
|
|
621
|
+
*/
|
|
622
|
+
interface CRI {
|
|
623
|
+
/**
|
|
624
|
+
* The scheme for this `CRI`.
|
|
625
|
+
*
|
|
626
|
+
* @returns a string containing the scheme
|
|
627
|
+
*/
|
|
628
|
+
scheme(): string;
|
|
629
|
+
/**
|
|
630
|
+
* The scope for this `CRI` or `null` if not provided.
|
|
631
|
+
*
|
|
632
|
+
* This is useful to narrow down the `CRI`. This could be something like a user id, device id, or a node id.
|
|
633
|
+
*
|
|
634
|
+
* @returns a string containing the scope if provided or `null` if not set
|
|
635
|
+
*/
|
|
636
|
+
scope(): string | null;
|
|
637
|
+
/**
|
|
638
|
+
* @returns `true` if the `scope` is set
|
|
639
|
+
*/
|
|
640
|
+
hasScope(): boolean;
|
|
641
|
+
/**
|
|
642
|
+
* The name of the resource represented by this `CRI`.
|
|
643
|
+
*
|
|
644
|
+
* In the case of a `srv` `CRI`, this will be the service name.
|
|
645
|
+
* In the case of a `stream` `CRI`, this will be the name of the event type that the stream expects.
|
|
646
|
+
*
|
|
647
|
+
* For the following CRI, `resourceName` would be the portion specified by `resourceName`:
|
|
648
|
+
*
|
|
649
|
+
* `scheme://[scope@]resourceName/path`
|
|
650
|
+
*
|
|
651
|
+
* @returns the string containing the name of this resource
|
|
652
|
+
*/
|
|
653
|
+
resourceName(): string;
|
|
654
|
+
/**
|
|
655
|
+
* This is a version for the resource or `null` if not provided.
|
|
656
|
+
*
|
|
657
|
+
* @returns a string containing the version if provided or `null` if not set
|
|
658
|
+
*/
|
|
659
|
+
version(): string | null;
|
|
660
|
+
/**
|
|
661
|
+
* @returns `true` if the `version` is set
|
|
662
|
+
*/
|
|
663
|
+
hasVersion(): boolean;
|
|
664
|
+
/**
|
|
665
|
+
* The path for this `CRI`, without a leading `/`.
|
|
666
|
+
*
|
|
667
|
+
* For the following CRI, `path` would be the portion specified by `path`:
|
|
668
|
+
*
|
|
669
|
+
* `scheme://[scope@]resourceName/path`
|
|
670
|
+
*
|
|
671
|
+
* @returns the path string if provided or `null` if not set
|
|
672
|
+
*/
|
|
673
|
+
path(): string | null;
|
|
674
|
+
/**
|
|
675
|
+
* @returns `true` if the `path` is set
|
|
676
|
+
*/
|
|
677
|
+
hasPath(): boolean;
|
|
678
|
+
/**
|
|
679
|
+
* Base Resource is a portion of the fully qualified `CRI` containing the following:
|
|
680
|
+
*
|
|
681
|
+
* `scheme://[scope@]resourceName`
|
|
682
|
+
*
|
|
683
|
+
* @returns string containing the baseResource
|
|
684
|
+
*/
|
|
685
|
+
baseResource(): string;
|
|
686
|
+
/**
|
|
687
|
+
* The fully qualified value for this `CRI`.
|
|
688
|
+
*
|
|
689
|
+
* @returns the fully qualified `CRI` as a string
|
|
690
|
+
*/
|
|
691
|
+
raw(): string;
|
|
692
|
+
}
|
|
693
|
+
/**
|
|
694
|
+
* Creates a new `CRI` from a raw string.
|
|
695
|
+
*
|
|
696
|
+
* @param rawUrc the raw string
|
|
697
|
+
* @returns the newly created `CRI`
|
|
698
|
+
*/
|
|
699
|
+
declare function createCRI(rawUrc: string): CRI;
|
|
700
|
+
/**
|
|
701
|
+
* Creates a new `CRI` from scheme and resourceName.
|
|
702
|
+
*
|
|
703
|
+
* @param scheme the scheme
|
|
704
|
+
* @param resourceName the resource name
|
|
705
|
+
* @returns the newly created `CRI`
|
|
706
|
+
*/
|
|
707
|
+
declare function createCRI(scheme: string, resourceName: string): CRI;
|
|
708
|
+
/**
|
|
709
|
+
* Creates a new `CRI` from scheme, scope, and resourceName.
|
|
710
|
+
*
|
|
711
|
+
* @param scheme the scheme
|
|
712
|
+
* @param scope the scope
|
|
713
|
+
* @param resourceName the resource name
|
|
714
|
+
* @returns the newly created `CRI`
|
|
715
|
+
*/
|
|
716
|
+
declare function createCRI(scheme: string, scope: string | null, resourceName: string): CRI;
|
|
717
|
+
/**
|
|
718
|
+
* Creates a new `CRI` from all provided values.
|
|
719
|
+
*
|
|
720
|
+
* @param scheme the scheme
|
|
721
|
+
* @param scope the scope
|
|
722
|
+
* @param resourceName the resource name
|
|
723
|
+
* @param path the path
|
|
724
|
+
* @param version the version
|
|
725
|
+
* @returns the newly created `CRI`
|
|
726
|
+
*/
|
|
727
|
+
declare function createCRI(scheme: string, scope: string | null, resourceName: string, path: string | null, version: string | null): CRI;
|
|
728
|
+
declare class ServiceIdentifier {
|
|
729
|
+
namespace: string;
|
|
730
|
+
name: string;
|
|
731
|
+
scope?: string;
|
|
732
|
+
version?: string;
|
|
733
|
+
private _cri;
|
|
734
|
+
constructor(namespace: string, name: string);
|
|
735
|
+
/**
|
|
736
|
+
* Returns the qualified name for this {@link ServiceIdentifier}
|
|
737
|
+
* This is the namespace.name
|
|
738
|
+
* @return string containing the qualified name
|
|
739
|
+
*/
|
|
740
|
+
qualifiedName(): string;
|
|
741
|
+
/**
|
|
742
|
+
* The {@link CRI} that represents this {@link ServiceIdentifier}
|
|
743
|
+
* @return the cri for this {@link ServiceIdentifier}
|
|
744
|
+
*/
|
|
745
|
+
cri(): CRI;
|
|
746
|
+
}
|
|
747
|
+
import { Observable as Observable2 } from "rxjs";
|
|
748
|
+
/**
|
|
749
|
+
* Provides an interface to allow the {@link IServiceProxy} creator the ability to have fine grain control of the outgoing {@link IEvent}
|
|
750
|
+
*/
|
|
751
|
+
interface IEventFactory {
|
|
752
|
+
create(cri: string, args: any[] | null | undefined): IEvent;
|
|
753
|
+
}
|
|
754
|
+
/**
|
|
755
|
+
* {@link IServiceProxy} provides the ability to access a remote service
|
|
756
|
+
*
|
|
757
|
+
* Created by navid on 2019-04-18.
|
|
758
|
+
*/
|
|
759
|
+
interface IServiceProxy {
|
|
760
|
+
/**
|
|
761
|
+
* The remote id of the service that this proxy is for
|
|
762
|
+
*/
|
|
763
|
+
serviceIdentifier: string;
|
|
764
|
+
/**
|
|
765
|
+
* Provides functionality to invoke the remote service that returns a single result
|
|
766
|
+
* @param methodIdentifier of the service method to invoke
|
|
767
|
+
* @param args to pass to the service invocation
|
|
768
|
+
* @param scope string or undefined or null, if not undefined or null this is used to determine which service instance rpc requests should be routed to.
|
|
769
|
+
* @param eventFactory IEventFactory or undefined or null, if not undefined or null this is the {@link IEventFactory} to use when creating {@link IEvent}'s to send
|
|
770
|
+
* @return a {@link Promise} that will resolve to the result from the invocation
|
|
771
|
+
*/
|
|
772
|
+
invoke(methodIdentifier: string, args?: any[] | null | undefined, scope?: string | null | undefined, eventFactory?: IEventFactory | null | undefined): Promise<any>;
|
|
773
|
+
/**
|
|
774
|
+
* Provides functionality to invoke the remote service that returns a stream of results
|
|
775
|
+
* @param methodIdentifier of the service method to invoke
|
|
776
|
+
* @param args to pass to the service invocation
|
|
777
|
+
* @param scope string or undefined or null, if not undefined or null this is used to determine which service instance rpc requests should be routed to.
|
|
778
|
+
* @param eventFactory IEventFactory or undefined or null, if not undefined or null this is the {@link IEventFactory} to use when creating {@link IEvent}'s to send
|
|
779
|
+
* @return a {@link Observable} that will resolve to the result from the invocation
|
|
780
|
+
*/
|
|
781
|
+
invokeStream(methodIdentifier: string, args?: any[] | null | undefined, scope?: string | null | undefined, eventFactory?: IEventFactory | null | undefined): Observable2<any>;
|
|
782
|
+
}
|
|
783
|
+
/**
|
|
784
|
+
* Provides the functionality to register services as well as create proxies for those services
|
|
785
|
+
*
|
|
786
|
+
* Created by Navid Mitchell on 2019-02-08.
|
|
787
|
+
*/
|
|
788
|
+
interface IServiceRegistry {
|
|
789
|
+
/**
|
|
790
|
+
* Creates a new service proxy that can be used to access the desired service.
|
|
791
|
+
* @param serviceIdentifier the identifier of the service to be accessed
|
|
792
|
+
* @return the {@link IServiceProxy} that can be used to access the service
|
|
793
|
+
*/
|
|
794
|
+
serviceProxy(serviceIdentifier: string): IServiceProxy;
|
|
795
|
+
/**
|
|
796
|
+
* Registers a new service with the service registry.
|
|
797
|
+
* This will allow the service to be accessed remotely.
|
|
798
|
+
*
|
|
799
|
+
* @param serviceIdentifier identifies the service to be registered
|
|
800
|
+
* @param service to use invoke when the service is called
|
|
801
|
+
*/
|
|
802
|
+
register(serviceIdentifier: ServiceIdentifier, service: any): void;
|
|
803
|
+
/**
|
|
804
|
+
* Unregisters a service with the service registry.
|
|
805
|
+
* This will remove the service from the registry, and it will no longer be accessible remotely.
|
|
806
|
+
*
|
|
807
|
+
* @param serviceIdentifier identifies the service to be unregistered
|
|
808
|
+
*/
|
|
809
|
+
unRegister(serviceIdentifier: ServiceIdentifier): void;
|
|
810
|
+
/**
|
|
811
|
+
* Registers a {@link ContextInterceptor} that will be used to modify the {@link ServiceContext} before the service method is invoked.
|
|
812
|
+
* This allows for custom context data to be added or modified before the service method is called.
|
|
813
|
+
*
|
|
814
|
+
* @param interceptor the {@link ContextInterceptor} to register
|
|
815
|
+
*/
|
|
816
|
+
registerContextInterceptor<T extends ServiceContext>(interceptor: ContextInterceptor<T> | null): void;
|
|
817
|
+
}
|
|
818
|
+
/**
|
|
819
|
+
* Default implementation of {@link ICrudServiceProxyFactory}
|
|
820
|
+
*/
|
|
821
|
+
declare class CrudServiceProxyFactory implements ICrudServiceProxyFactory {
|
|
822
|
+
private serviceRegistry;
|
|
823
|
+
constructor(serviceRegistry: IServiceRegistry);
|
|
824
|
+
crudServiceProxy<T extends Identifiable<string>>(serviceIdentifier: string): ICrudServiceProxy<T>;
|
|
825
|
+
}
|
|
826
|
+
/**
|
|
827
|
+
* An implementation of a {@link IEventFactory} which uses JSON content
|
|
828
|
+
*/
|
|
829
|
+
declare class JsonEventFactory implements IEventFactory {
|
|
830
|
+
create(cri: string, args: any[] | null | undefined): IEvent;
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* An implementation of a {@link IEventFactory} which uses text content
|
|
834
|
+
*/
|
|
835
|
+
declare class TextEventFactory implements IEventFactory {
|
|
836
|
+
create(cri: string, args: any[] | null | undefined): IEvent;
|
|
837
|
+
}
|
|
838
|
+
/**
|
|
839
|
+
* The default implementation of {@link IServiceRegistry}
|
|
840
|
+
*/
|
|
841
|
+
declare class ServiceRegistry implements IServiceRegistry {
|
|
842
|
+
private _eventBus;
|
|
843
|
+
private supervisors;
|
|
844
|
+
private contextInterceptor;
|
|
845
|
+
private debugLogger;
|
|
846
|
+
constructor(eventBus: IEventBus);
|
|
847
|
+
set eventBus(eventBus: IEventBus);
|
|
848
|
+
get eventBus(): IEventBus;
|
|
849
|
+
serviceProxy(serviceIdentifier: string): IServiceProxy;
|
|
850
|
+
register(serviceIdentifier: ServiceIdentifier, service: any): void;
|
|
851
|
+
unRegister(serviceIdentifier: ServiceIdentifier): void;
|
|
852
|
+
registerContextInterceptor<T extends ServiceContext>(interceptor: ContextInterceptor<T> | null): void;
|
|
853
|
+
}
|
|
854
|
+
interface IKinotic {
|
|
855
|
+
serviceRegistry: IServiceRegistry;
|
|
856
|
+
crudServiceProxyFactory: CrudServiceProxyFactory;
|
|
857
|
+
eventBus: IEventBus;
|
|
858
|
+
/**
|
|
859
|
+
* Requests a connection to the given Stomp url
|
|
860
|
+
* @param connectionInfo provides the information needed to connect to the kinoitc server
|
|
861
|
+
* @return Promise containing the result of the initial connection attempt
|
|
862
|
+
*/
|
|
863
|
+
connect(connectionInfo: ConnectionInfo): Promise<ConnectedInfo>;
|
|
864
|
+
/**
|
|
865
|
+
* Disconnects the client from the server
|
|
866
|
+
* This will clear any subscriptions and close the connection
|
|
867
|
+
*/
|
|
868
|
+
disconnect(force?: boolean): Promise<void>;
|
|
869
|
+
/**
|
|
870
|
+
* Creates a new service proxy that can be used to access the desired service.
|
|
871
|
+
* @param serviceIdentifier the identifier of the service to be accessed
|
|
872
|
+
* @return the {@link IServiceProxy} that can be used to access the service
|
|
873
|
+
*/
|
|
874
|
+
serviceProxy(serviceIdentifier: string): IServiceProxy;
|
|
875
|
+
/**
|
|
876
|
+
* Returns a {@link ICrudServiceProxy} for the given service identifier
|
|
877
|
+
* @param serviceIdentifier the identifier of the service to be accessed
|
|
878
|
+
*/
|
|
879
|
+
crudServiceProxy<T extends Identifiable<string>>(serviceIdentifier: string): ICrudServiceProxy<T>;
|
|
880
|
+
}
|
|
881
|
+
/**
|
|
882
|
+
* Provides a simplified way to connect to Kinotic and access services.
|
|
883
|
+
* All methods use a single connection to the Kinotic Services
|
|
884
|
+
*/
|
|
885
|
+
declare class KinoticSingleton implements IKinotic {
|
|
886
|
+
/**
|
|
887
|
+
* The {@link IEventBus} that is used to communicate with the Kinotic server
|
|
888
|
+
*/
|
|
889
|
+
private _eventBus;
|
|
890
|
+
/**
|
|
891
|
+
* The {@link ServiceRegistry} that is used to manage the services that are available
|
|
892
|
+
*/
|
|
893
|
+
readonly serviceRegistry: ServiceRegistry;
|
|
894
|
+
/**
|
|
895
|
+
* The {@link CrudServiceProxyFactory} that is used to create {@link ICrudServiceProxy} instances
|
|
896
|
+
*/
|
|
897
|
+
readonly crudServiceProxyFactory: CrudServiceProxyFactory;
|
|
898
|
+
constructor();
|
|
899
|
+
get eventBus(): IEventBus;
|
|
900
|
+
set eventBus(eventBus: IEventBus);
|
|
901
|
+
/**
|
|
902
|
+
* Requests a connection to the given Stomp url
|
|
903
|
+
* @param connectionInfo provides the information needed to connect to the kinoitc server
|
|
904
|
+
* @return Promise containing the result of the initial connection attempt
|
|
905
|
+
*/
|
|
906
|
+
connect(connectionInfo: ConnectionInfo): Promise<ConnectedInfo>;
|
|
907
|
+
/**
|
|
908
|
+
* Disconnects the client from the server
|
|
909
|
+
* This will clear any subscriptions and close the connection
|
|
910
|
+
*/
|
|
911
|
+
disconnect(force?: boolean): Promise<void>;
|
|
912
|
+
/**
|
|
913
|
+
* Creates a new service proxy that can be used to access the desired service.
|
|
914
|
+
* @param serviceIdentifier the identifier of the service to be accessed
|
|
915
|
+
* @return the {@link IServiceProxy} that can be used to access the service
|
|
916
|
+
*/
|
|
917
|
+
serviceProxy(serviceIdentifier: string): IServiceProxy;
|
|
918
|
+
/**
|
|
919
|
+
* Returns a {@link ICrudServiceProxy} for the given service identifier
|
|
920
|
+
* @param serviceIdentifier the identifier of the service to be accessed
|
|
921
|
+
*/
|
|
922
|
+
crudServiceProxy<T extends Identifiable<string>>(serviceIdentifier: string): ICrudServiceProxy<T>;
|
|
923
|
+
}
|
|
924
|
+
/**
|
|
925
|
+
* The default {@link IKinotic} instance that can be used to access Kinotic services
|
|
926
|
+
*/
|
|
927
|
+
declare const Kinotic: IKinotic;
|
|
928
|
+
declare const CONTEXT_METADATA_KEY: unique symbol;
|
|
929
|
+
declare function Scope(target: any, propertyKey: string, descriptor?: PropertyDescriptor): void;
|
|
930
|
+
declare function Version(version: string): (target: Function) => void;
|
|
931
|
+
declare function Context(): (target: any, propertyKey: string, parameterIndex: number) => void;
|
|
932
|
+
declare function Publish(namespace: string, name?: string): (target: Function) => any;
|
|
933
|
+
declare enum LogLevel {
|
|
934
|
+
TRACE = "TRACE",
|
|
935
|
+
DEBUG = "DEBUG",
|
|
936
|
+
INFO = "INFO",
|
|
937
|
+
WARN = "WARN",
|
|
938
|
+
ERROR = "ERROR",
|
|
939
|
+
FATAL = "FATAL",
|
|
940
|
+
OFF = "OFF"
|
|
941
|
+
}
|
|
942
|
+
declare class LoggerLevelsDescriptor {
|
|
943
|
+
configuredLevel?: LogLevel;
|
|
944
|
+
}
|
|
945
|
+
declare class GroupLoggerLevelsDescriptor extends LoggerLevelsDescriptor {
|
|
946
|
+
members: string[];
|
|
947
|
+
}
|
|
948
|
+
declare class SingleLoggerLevelsDescriptor extends LoggerLevelsDescriptor {
|
|
949
|
+
effectiveLevel?: LogLevel;
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* Description of loggers
|
|
953
|
+
*/
|
|
954
|
+
declare class LoggersDescriptor {
|
|
955
|
+
levels: LogLevel[];
|
|
956
|
+
loggerLevels: Map<string, SingleLoggerLevelsDescriptor>;
|
|
957
|
+
groups: Map<string, GroupLoggerLevelsDescriptor>;
|
|
958
|
+
}
|
|
959
|
+
/**
|
|
960
|
+
* Provides the ability to manage loggers
|
|
961
|
+
*/
|
|
962
|
+
interface ILogManager {
|
|
963
|
+
/**
|
|
964
|
+
* @param nodeId the kinoitc node to get the LoggersDescriptor from
|
|
965
|
+
* @return a {@link LoggersDescriptor} containing all the loggers and their levels
|
|
966
|
+
*/
|
|
967
|
+
loggers(nodeId: string): Promise<LoggersDescriptor>;
|
|
968
|
+
/**
|
|
969
|
+
* @param nodeId the kinoitc node to get the LoggerLevelsDescriptor from
|
|
970
|
+
* @param name the name of the logger to get
|
|
971
|
+
* @return a {@link LoggerLevelsDescriptor} containing the logger and its levels
|
|
972
|
+
*/
|
|
973
|
+
loggerLevels(nodeId: string, name: string): Promise<LoggerLevelsDescriptor>;
|
|
974
|
+
/**
|
|
975
|
+
* Configures the log level for the logger with the given name
|
|
976
|
+
* @param nodeId the kinoitc node to set the log level on
|
|
977
|
+
* @param name the name of the logger to set
|
|
978
|
+
* @param level the {@link LogLevel} to set for the logger with the given name
|
|
979
|
+
*/
|
|
980
|
+
configureLogLevel(nodeId: string, name: string, level: LogLevel): Promise<void>;
|
|
981
|
+
}
|
|
982
|
+
declare class LogManager implements ILogManager {
|
|
983
|
+
private readonly serviceProxy;
|
|
984
|
+
constructor();
|
|
985
|
+
loggers(nodeId: string): Promise<LoggersDescriptor>;
|
|
986
|
+
loggerLevels(nodeId: string, name: string): Promise<LoggerLevelsDescriptor>;
|
|
987
|
+
configureLogLevel(nodeId: string, name: string, level: LogLevel): Promise<void>;
|
|
988
|
+
}
|
|
989
|
+
declare const logManager: ILogManager;
|
|
990
|
+
declare class AuthenticationError extends KinoticError {
|
|
991
|
+
constructor(message: string);
|
|
992
|
+
}
|
|
993
|
+
declare class AuthorizationError extends KinoticError {
|
|
994
|
+
constructor(message: string);
|
|
995
|
+
}
|
|
996
|
+
/**
|
|
997
|
+
* Some common constants used for the {@link Participant} and {@link Participant#getMetadata()}
|
|
998
|
+
* Created by navid on 2/3/20
|
|
999
|
+
*/
|
|
1000
|
+
declare class ParticipantConstants {
|
|
1001
|
+
static readonly PARTICIPANT_TYPE_METADATA_KEY: string;
|
|
1002
|
+
static readonly PARTICIPANT_TYPE_DEVICE: string;
|
|
1003
|
+
static readonly PARTICIPANT_TYPE_CLI: string;
|
|
1004
|
+
static readonly PARTICIPANT_TYPE_USER: string;
|
|
1005
|
+
static readonly PARTICIPANT_TYPE_NODE: string;
|
|
1006
|
+
static readonly CLI_PARTICIPANT_ID: string;
|
|
1007
|
+
}
|
|
1008
|
+
/**
|
|
1009
|
+
* Default implementation of the `CRI` interface.
|
|
1010
|
+
*
|
|
1011
|
+
* @author Navid Mitchell
|
|
1012
|
+
* @since 3/25/25
|
|
1013
|
+
*/
|
|
1014
|
+
declare class DefaultCRI implements CRI {
|
|
1015
|
+
private readonly _scheme;
|
|
1016
|
+
private readonly _scope;
|
|
1017
|
+
private readonly _resourceName;
|
|
1018
|
+
private readonly _path;
|
|
1019
|
+
private readonly _version;
|
|
1020
|
+
private readonly _raw;
|
|
1021
|
+
constructor(rawCRI: string);
|
|
1022
|
+
constructor(scheme: string, scope: string | null, resourceName: string, path: string | null, version: string | null);
|
|
1023
|
+
scheme(): string;
|
|
1024
|
+
scope(): string | null;
|
|
1025
|
+
hasScope(): boolean;
|
|
1026
|
+
resourceName(): string;
|
|
1027
|
+
version(): string | null;
|
|
1028
|
+
hasVersion(): boolean;
|
|
1029
|
+
path(): string | null;
|
|
1030
|
+
hasPath(): boolean;
|
|
1031
|
+
baseResource(): string;
|
|
1032
|
+
raw(): string;
|
|
1033
|
+
equals(other: any): boolean;
|
|
1034
|
+
hashCode(): number;
|
|
1035
|
+
toString(): string;
|
|
1036
|
+
private static parseRaw;
|
|
1037
|
+
private static buildRaw;
|
|
1038
|
+
}
|
|
1039
|
+
import { Observable as Observable3 } from "rxjs";
|
|
1040
|
+
import { Optional as Optional2 } from "typescript-optional";
|
|
1041
|
+
/**
|
|
1042
|
+
* Default IEvent implementation
|
|
1043
|
+
*/
|
|
1044
|
+
declare class Event implements IEvent {
|
|
1045
|
+
cri: string;
|
|
1046
|
+
headers: Map<string, string>;
|
|
1047
|
+
data: Optional2<Uint8Array>;
|
|
1048
|
+
constructor(cri: string, headers?: Map<string, string>, data?: Uint8Array);
|
|
1049
|
+
getHeader(key: string): string | undefined;
|
|
1050
|
+
hasHeader(key: string): boolean;
|
|
1051
|
+
setHeader(key: string, value: string): void;
|
|
1052
|
+
removeHeader(key: string): boolean;
|
|
1053
|
+
setDataString(data: string): void;
|
|
1054
|
+
getDataString(): string;
|
|
1055
|
+
}
|
|
1056
|
+
/**
|
|
1057
|
+
* Default implementation of {@link IEventBus}
|
|
1058
|
+
*/
|
|
1059
|
+
declare class EventBus implements IEventBus {
|
|
1060
|
+
fatalErrors: Observable3<Error>;
|
|
1061
|
+
serverInfo: ServerInfo | null;
|
|
1062
|
+
private stompConnectionManager;
|
|
1063
|
+
private replyToCri;
|
|
1064
|
+
private requestRepliesObservable;
|
|
1065
|
+
private requestRepliesSubject;
|
|
1066
|
+
private requestRepliesSubscription;
|
|
1067
|
+
private errorSubject;
|
|
1068
|
+
private errorSubjectSubscription;
|
|
1069
|
+
constructor();
|
|
1070
|
+
isConnectionActive(): boolean;
|
|
1071
|
+
isConnected(): boolean;
|
|
1072
|
+
connect(connectionInfo: ConnectionInfo): Promise<ConnectedInfo>;
|
|
1073
|
+
disconnect(force?: boolean): Promise<void>;
|
|
1074
|
+
send(event: IEvent): void;
|
|
1075
|
+
request(event: IEvent): Promise<IEvent>;
|
|
1076
|
+
requestStream(event: IEvent, sendControlEvents?: boolean): Observable3<IEvent>;
|
|
1077
|
+
listen(_serverInfo: ServerInfo): Promise<void>;
|
|
1078
|
+
observe(cri: string): Observable3<IEvent>;
|
|
1079
|
+
private cleanup;
|
|
1080
|
+
/**
|
|
1081
|
+
* Creates the proper error to return if this.stompConnectionManager?.rxStomp is not available on a send request
|
|
1082
|
+
*/
|
|
1083
|
+
private createSendUnavailableError;
|
|
1084
|
+
/**
|
|
1085
|
+
* This is an internal impl of observe that creates a cold observable.
|
|
1086
|
+
* The public variants transform this to some type of hot observable depending on the need
|
|
1087
|
+
* @param cri to observe
|
|
1088
|
+
* @return the cold {@link Observable<IEvent>} for the given destination
|
|
1089
|
+
*/
|
|
1090
|
+
private _observe;
|
|
1091
|
+
}
|
|
1092
|
+
declare enum StreamOperation {
|
|
1093
|
+
EXISTING = "EXISTING",
|
|
1094
|
+
UPDATE = "UPDATE",
|
|
1095
|
+
REMOVE = "REMOVE"
|
|
1096
|
+
}
|
|
1097
|
+
/**
|
|
1098
|
+
* Holder for domain objects that will be returned as a stream of changes to a data set
|
|
1099
|
+
*
|
|
1100
|
+
* Created by Navid Mitchell on 6/3/20
|
|
1101
|
+
*/
|
|
1102
|
+
declare class StreamData<
|
|
1103
|
+
I,
|
|
1104
|
+
T
|
|
1105
|
+
> implements Identifiable<I> {
|
|
1106
|
+
streamOperation: StreamOperation;
|
|
1107
|
+
id: I;
|
|
1108
|
+
value: T;
|
|
1109
|
+
constructor(streamOperation: StreamOperation, id: I, value: T);
|
|
1110
|
+
isSet(): boolean;
|
|
1111
|
+
}
|
|
1112
|
+
/**
|
|
1113
|
+
* Defines a page that is also an async iterator.
|
|
1114
|
+
* This allows for easy iteration over all pages of a result set.
|
|
1115
|
+
*/
|
|
1116
|
+
interface IterablePage<T> extends Page<T>, AsyncIterableIterator<IterablePage<T>> {
|
|
1117
|
+
/**
|
|
1118
|
+
* @return true if this is the last page, false otherwise.
|
|
1119
|
+
*/
|
|
1120
|
+
isLastPage(): boolean;
|
|
1121
|
+
/**
|
|
1122
|
+
* @return true if this page has content, false otherwise.
|
|
1123
|
+
*/
|
|
1124
|
+
hasContent(): boolean;
|
|
1125
|
+
}
|
|
1126
|
+
declare abstract class AbstractIterablePage<T> implements IterablePage<T> {
|
|
1127
|
+
private readonly pageable;
|
|
1128
|
+
private currentPage;
|
|
1129
|
+
private firstPage;
|
|
1130
|
+
protected constructor(pageable: Pageable, page: Page<T>);
|
|
1131
|
+
next(): Promise<IteratorResult<IterablePage<T>>>;
|
|
1132
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<IterablePage<T>>;
|
|
1133
|
+
hasContent(): boolean;
|
|
1134
|
+
isLastPage(): boolean;
|
|
1135
|
+
private isOffsetPageable;
|
|
1136
|
+
get totalElements(): number | null | undefined;
|
|
1137
|
+
get cursor(): string | null | undefined;
|
|
1138
|
+
get content(): T[] | null | undefined;
|
|
1139
|
+
}
|
|
1140
|
+
declare class CrudServiceProxy<T extends Identifiable<string>> implements ICrudServiceProxy<T> {
|
|
1141
|
+
protected serviceProxy: IServiceProxy;
|
|
1142
|
+
constructor(serviceProxy: IServiceProxy);
|
|
1143
|
+
count(): Promise<number>;
|
|
1144
|
+
create(entity: T): Promise<T>;
|
|
1145
|
+
deleteById(id: string): Promise<void>;
|
|
1146
|
+
findAll(pageable: Pageable): Promise<IterablePage<T>>;
|
|
1147
|
+
findAllSinglePage(pageable: Pageable): Promise<Page<T>>;
|
|
1148
|
+
findById(id: string): Promise<T>;
|
|
1149
|
+
save(entity: T): Promise<T>;
|
|
1150
|
+
findByIdNotIn(ids: string[], page: Pageable): Promise<Page<Identifiable<string>>>;
|
|
1151
|
+
search(searchText: string, pageable: Pageable): Promise<IterablePage<T>>;
|
|
1152
|
+
searchSinglePage(searchText: string, pageable: Pageable): Promise<Page<T>>;
|
|
1153
|
+
}
|
|
1154
|
+
declare class FunctionalIterablePage<T> extends AbstractIterablePage<T> {
|
|
1155
|
+
private readonly pageFunction;
|
|
1156
|
+
constructor(pageable: Pageable, page: Page<T>, pageFunction: (pageable: Pageable) => Promise<Page<T>>);
|
|
1157
|
+
protected findNext(pageable: Pageable): Promise<Page<T>>;
|
|
1158
|
+
}
|
|
1159
|
+
export { logManager, createCRI, Version, TextEventFactory, StreamOperation, StreamData, Sort, SingleLoggerLevelsDescriptor, ServiceRegistry, ServiceContext, ServerInfo, Scope, Publish, ParticipantConstants, Participant, Pageable, Page, Order, OffsetPageable, NullHandling, LoggersDescriptor, LoggerLevelsDescriptor, LogManager, LogLevel, KinoticSingleton, KinoticError, Kinotic, JsonEventFactory, IterablePage, Identifiable, IServiceRegistry, IServiceProxy, IParticipant, ILogManager, IEventFactory, IEventBus, IEvent, IEditableDataSource, IDataSource, ICrudServiceProxyFactory, ICrudServiceProxy, GroupLoggerLevelsDescriptor, FunctionalIterablePage, EventConstants, EventBus, Event, Direction, DefaultCRI, DataSourceUtils, CursorPageable, CrudServiceProxyFactory, CrudServiceProxy, ContextInterceptor, Context, ConnectionInfo, ConnectedInfo, ConnectHeaders, CRI, CONTEXT_METADATA_KEY, AuthorizationError, AuthenticationError, AbstractIterablePage };
|