@kinotic-ai/persistence 1.0.0-beta.0 → 1.0.0-beta.2
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/README.md +65 -0
- package/dist/index.cjs +357 -0
- package/dist/index.d.cts +681 -0
- package/dist/index.d.ts +681 -0
- package/dist/index.js +318 -0
- package/package.json +2 -2
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,681 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a query parameter for a named query.
|
|
3
|
+
*/
|
|
4
|
+
type QueryParameter = {
|
|
5
|
+
key: string;
|
|
6
|
+
value: any;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Options for a Named Query
|
|
10
|
+
*/
|
|
11
|
+
declare class QueryOptions {
|
|
12
|
+
timeZone: string;
|
|
13
|
+
requestTimeout: number;
|
|
14
|
+
pageTimeout: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* An identifier that can be used to find a Entity for a specific id and tenant
|
|
18
|
+
*/
|
|
19
|
+
declare class TenantSpecificId {
|
|
20
|
+
/**
|
|
21
|
+
* The id of the entity
|
|
22
|
+
*/
|
|
23
|
+
entityId: string;
|
|
24
|
+
/**
|
|
25
|
+
* The id of the tenant
|
|
26
|
+
*/
|
|
27
|
+
tenantId: string;
|
|
28
|
+
constructor(entityId: string, tenantId: string);
|
|
29
|
+
}
|
|
30
|
+
import { C3Decorator } from "@kinotic-ai/idl";
|
|
31
|
+
/**
|
|
32
|
+
* This class denotes {@link C3Decorator} that can be applied to an {@link EntityService} using the {@link EntityServiceDecoratorsDecorator}
|
|
33
|
+
*/
|
|
34
|
+
declare abstract class EntityServiceDecorator extends C3Decorator {}
|
|
35
|
+
import { Pageable as Pageable2, IterablePage as IterablePage2 } from "@kinotic-ai/core";
|
|
36
|
+
import { IKinotic } from "@kinotic-ai/core";
|
|
37
|
+
import { IServiceProxy, Page, Pageable, IterablePage } from "@kinotic-ai/core";
|
|
38
|
+
interface IEntitiesService {
|
|
39
|
+
/**
|
|
40
|
+
* Saves all given entities.
|
|
41
|
+
* @param structureId the id of the structure to save the entities for
|
|
42
|
+
* @param entities all the entities to save
|
|
43
|
+
* @return Promise that will complete when all entities have been saved
|
|
44
|
+
*/
|
|
45
|
+
bulkSave<T>(structureId: string, entities: T[]): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Updates all given entities.
|
|
48
|
+
* @param structureId the id of the structure to update the entities for
|
|
49
|
+
* @param entities all the entities to save
|
|
50
|
+
* @return Promise that will complete when all entities have been saved
|
|
51
|
+
*/
|
|
52
|
+
bulkUpdate<T>(structureId: string, entities: T[]): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Returns the number of entities available.
|
|
55
|
+
* @param structureId the id of the structure to count
|
|
56
|
+
* @return {@link Promise} emitting the number of entities.
|
|
57
|
+
*/
|
|
58
|
+
count(structureId: string): Promise<number>;
|
|
59
|
+
/**
|
|
60
|
+
* Returns the number of entities available for the given query.
|
|
61
|
+
*
|
|
62
|
+
* @param structureId the id of the structure to save the entity for
|
|
63
|
+
* @param query the query used to limit result
|
|
64
|
+
* @return Promise emitting the number of entities
|
|
65
|
+
*/
|
|
66
|
+
countByQuery(structureId: string, query: string): Promise<number>;
|
|
67
|
+
/**
|
|
68
|
+
* Deletes the entity with the given id.
|
|
69
|
+
*
|
|
70
|
+
* @param structureId the id of the structure to save the entity for
|
|
71
|
+
* @param id must not be {@literal null}
|
|
72
|
+
* @return {@link Promise} emitting when delete is complete
|
|
73
|
+
* @throws IllegalArgumentException in case the given {@literal id} is {@literal null}
|
|
74
|
+
*/
|
|
75
|
+
deleteById(structureId: string, id: string): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Deletes the entity with the given id.
|
|
78
|
+
*
|
|
79
|
+
* @param structureId the id of the structure to save the entity for
|
|
80
|
+
* @param query the query used to filter records to delete, must not be {@literal null}
|
|
81
|
+
* @return Promise signaling when operation has completed
|
|
82
|
+
* @throws Error in case the given {@literal query} is {@literal null}
|
|
83
|
+
*/
|
|
84
|
+
deleteByQuery(structureId: string, query: string): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Returns a {@link IterablePage} of entities meeting the paging restriction provided in the {@link Pageable} object.
|
|
87
|
+
*
|
|
88
|
+
* @param structureId the id of the structure to save the entity for
|
|
89
|
+
* @param pageable the page settings to be used
|
|
90
|
+
* @return a page of entities
|
|
91
|
+
*/
|
|
92
|
+
findAll<T>(structureId: string, pageable: Pageable): Promise<IterablePage<T>>;
|
|
93
|
+
/**
|
|
94
|
+
* Returns a single {@link Page} of entities meeting the paging restriction provided in the {@link Pageable} object.
|
|
95
|
+
* @param structureId the id of the structure to save the entity for
|
|
96
|
+
* @param pageable the page settings to be used
|
|
97
|
+
*/
|
|
98
|
+
findAllSinglePage<T>(structureId: string, pageable: Pageable): Promise<Page<T>>;
|
|
99
|
+
/**
|
|
100
|
+
* Retrieves an entity by its id.
|
|
101
|
+
*
|
|
102
|
+
* @param structureId the id of the structure to save the entity for
|
|
103
|
+
* @param id must not be {@literal null}
|
|
104
|
+
* @return {@link Promise} with the entity with the given id or {@link Promise} emitting null if none found
|
|
105
|
+
* @throws IllegalArgumentException in case the given {@literal id} is {@literal null}
|
|
106
|
+
*/
|
|
107
|
+
findById<T>(structureId: string, id: string): Promise<T>;
|
|
108
|
+
/**
|
|
109
|
+
* Retrieves a list of entities by their id.
|
|
110
|
+
*
|
|
111
|
+
* @param structureId the id of the structure to save the entity for
|
|
112
|
+
* @param ids must not be {@literal null}
|
|
113
|
+
* @return Promise emitting the entities with the given ids or Promise emitting null if none found
|
|
114
|
+
* @throws Error in case the given {@literal ids} is {@literal null}
|
|
115
|
+
*/
|
|
116
|
+
findByIds<T>(structureId: string, ids: string[]): Promise<T[]>;
|
|
117
|
+
/**
|
|
118
|
+
* Executes a named query.
|
|
119
|
+
* @param structureId the id of the structure that this named query is defined for
|
|
120
|
+
* @param queryName the name of the function that defines the query
|
|
121
|
+
* @param parameters to pass to the query
|
|
122
|
+
* @returns Promise with the result of the query
|
|
123
|
+
*/
|
|
124
|
+
namedQuery<T>(structureId: string, queryName: string, parameters: QueryParameter[]): Promise<T>;
|
|
125
|
+
/**
|
|
126
|
+
* Executes a named query and returns a Page of results.
|
|
127
|
+
* @param structureId the id of the structure that this named query is defined for
|
|
128
|
+
* @param queryName the name of the function that defines the query
|
|
129
|
+
* @param parameters to pass to the query
|
|
130
|
+
* @param pageable the page settings to be used
|
|
131
|
+
* @returns Promise with the result of the query
|
|
132
|
+
*/
|
|
133
|
+
namedQueryPage<T>(structureId: string, queryName: string, parameters: QueryParameter[], pageable: Pageable): Promise<IterablePage<T>>;
|
|
134
|
+
/**
|
|
135
|
+
* Saves a given entity. Use the returned instance for further operations as the save operation might have changed the
|
|
136
|
+
* entity instance completely.
|
|
137
|
+
*
|
|
138
|
+
* @param structureId the id of the structure to save the entity for
|
|
139
|
+
* @param entity must not be {@literal null}
|
|
140
|
+
* @return {@link Promise} emitting the saved entity
|
|
141
|
+
* @throws IllegalArgumentException in case the given {@literal entity} is {@literal null}
|
|
142
|
+
*/
|
|
143
|
+
save<T>(structureId: string, entity: T): Promise<T>;
|
|
144
|
+
/**
|
|
145
|
+
* Returns a {@link IterablePage} of entities matching the search text and paging restriction provided in the {@link Pageable} object.
|
|
146
|
+
*
|
|
147
|
+
* @param structureId the id of the structure to save the entity for
|
|
148
|
+
* @param searchText the text to search for entities for
|
|
149
|
+
* @param pageable the page settings to be used
|
|
150
|
+
* @return a page of entities
|
|
151
|
+
*/
|
|
152
|
+
search<T>(structureId: string, searchText: string, pageable: Pageable): Promise<IterablePage<T>>;
|
|
153
|
+
/**
|
|
154
|
+
* Returns a single {@link Page} of entities matching the search text and paging restriction provided in the {@link Pageable} object.
|
|
155
|
+
*
|
|
156
|
+
* @param structureId the id of the structure to save the entity for
|
|
157
|
+
* @param searchText the text to search for entities for
|
|
158
|
+
* @param pageable the page settings to be used
|
|
159
|
+
* @return a page of entities
|
|
160
|
+
*/
|
|
161
|
+
searchSinglePage<T>(structureId: string, searchText: string, pageable: Pageable): Promise<Page<T>>;
|
|
162
|
+
/**
|
|
163
|
+
* This operation makes all the recent writes immediately available for search.
|
|
164
|
+
* @param structureId the id of the structure to sync the index for.
|
|
165
|
+
* @return a Promise that resolves when the operation is complete
|
|
166
|
+
*/
|
|
167
|
+
syncIndex(structureId: string): Promise<void>;
|
|
168
|
+
/**
|
|
169
|
+
* Updates a given entity. This will only override the fields that are present in the given entity.
|
|
170
|
+
* If any fields are not present in the given entity data, they will not be changed.
|
|
171
|
+
* If the entity does not exist, it will be created.
|
|
172
|
+
*
|
|
173
|
+
* @param structureId the id of the structure to update the entity for
|
|
174
|
+
* @param entity must not be {@literal null}
|
|
175
|
+
* @return Promise emitting the saved entity
|
|
176
|
+
* @throws Error in case the given {@literal entity} is {@literal null}
|
|
177
|
+
*/
|
|
178
|
+
update<T>(structureId: string, entity: T): Promise<T>;
|
|
179
|
+
}
|
|
180
|
+
declare class EntitiesService implements IEntitiesService {
|
|
181
|
+
protected serviceProxy: IServiceProxy;
|
|
182
|
+
constructor(kinotic: IKinotic);
|
|
183
|
+
bulkSave<T>(structureId: string, entities: T[]): Promise<void>;
|
|
184
|
+
bulkUpdate<T>(structureId: string, entities: T[]): Promise<void>;
|
|
185
|
+
count(structureId: string): Promise<number>;
|
|
186
|
+
countByQuery(structureId: string, query: string): Promise<number>;
|
|
187
|
+
deleteById(structureId: string, id: string): Promise<void>;
|
|
188
|
+
deleteByQuery(structureId: string, query: string): Promise<void>;
|
|
189
|
+
findAll<T>(structureId: string, pageable: Pageable): Promise<IterablePage<T>>;
|
|
190
|
+
findAllSinglePage<T>(structureId: string, pageable: Pageable): Promise<Page<T>>;
|
|
191
|
+
findById<T>(structureId: string, id: string): Promise<T>;
|
|
192
|
+
findByIds<T>(structureId: string, ids: string[]): Promise<T[]>;
|
|
193
|
+
namedQuery<T>(structureId: string, queryName: string, parameters: QueryParameter[]): Promise<T>;
|
|
194
|
+
namedQueryPage<T>(structureId: string, queryName: string, parameters: QueryParameter[], pageable: Pageable): Promise<IterablePage<T>>;
|
|
195
|
+
namedQuerySinglePage<T>(structureId: string, queryName: string, parameters: QueryParameter[], pageable: Pageable): Promise<Page<T>>;
|
|
196
|
+
save<T>(structureId: string, entity: T): Promise<T>;
|
|
197
|
+
search<T>(structureId: string, searchText: string, pageable: Pageable): Promise<IterablePage<T>>;
|
|
198
|
+
searchSinglePage<T>(structureId: string, searchText: string, pageable: Pageable): Promise<Page<T>>;
|
|
199
|
+
syncIndex(structureId: string): Promise<void>;
|
|
200
|
+
update<T>(structureId: string, entity: T): Promise<T>;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* This is the base interface for all entity services.
|
|
204
|
+
* It provides the basic CRUD operations for entities.
|
|
205
|
+
*/
|
|
206
|
+
interface IEntityService<T> {
|
|
207
|
+
/**
|
|
208
|
+
* The applicationId of the structure this service is for
|
|
209
|
+
*/
|
|
210
|
+
structureApplicationId: string;
|
|
211
|
+
/**
|
|
212
|
+
* The name of the structure this service is for
|
|
213
|
+
*/
|
|
214
|
+
structureName: string;
|
|
215
|
+
/**
|
|
216
|
+
* The id of the structure this service is for
|
|
217
|
+
* Which is the applicationId + '.' + name
|
|
218
|
+
*/
|
|
219
|
+
structureId: string;
|
|
220
|
+
/**
|
|
221
|
+
* Saves all given entities.
|
|
222
|
+
* @param entities all the entities to save
|
|
223
|
+
* @return Promise that will complete when all entities have been saved
|
|
224
|
+
*/
|
|
225
|
+
bulkSave(entities: T[]): Promise<void>;
|
|
226
|
+
/**
|
|
227
|
+
* Updates all given entities.
|
|
228
|
+
* @param entities all the entities to save
|
|
229
|
+
* @return Promise that will complete when all entities have been saved
|
|
230
|
+
*/
|
|
231
|
+
bulkUpdate(entities: T[]): Promise<void>;
|
|
232
|
+
/**
|
|
233
|
+
* Returns the number of entities available.
|
|
234
|
+
*
|
|
235
|
+
* @return Promise emitting the number of entities
|
|
236
|
+
*/
|
|
237
|
+
count(): Promise<number>;
|
|
238
|
+
/**
|
|
239
|
+
* Returns the number of entities available for the given query.
|
|
240
|
+
*
|
|
241
|
+
* @param query the query used to limit result
|
|
242
|
+
* @return Promise emitting the number of entities
|
|
243
|
+
*/
|
|
244
|
+
countByQuery(query: string): Promise<number>;
|
|
245
|
+
/**
|
|
246
|
+
* Deletes the entity with the given id.
|
|
247
|
+
*
|
|
248
|
+
* @param id must not be {@literal null}
|
|
249
|
+
* @return Promise signaling when operation has completed
|
|
250
|
+
* @throws Error in case the given {@literal id} is {@literal null}
|
|
251
|
+
*/
|
|
252
|
+
deleteById(id: string): Promise<void>;
|
|
253
|
+
/**
|
|
254
|
+
* Deletes the entity with the given id.
|
|
255
|
+
*
|
|
256
|
+
* @param query the query used to filter records to delete, must not be {@literal null}
|
|
257
|
+
* @return Promise signaling when operation has completed
|
|
258
|
+
* @throws Error in case the given {@literal query} is {@literal null}
|
|
259
|
+
*/
|
|
260
|
+
deleteByQuery(query: string): Promise<void>;
|
|
261
|
+
/**
|
|
262
|
+
* Returns a {@link Page} of entities meeting the paging restriction provided in the {@link Pageable} object.
|
|
263
|
+
*
|
|
264
|
+
* @param pageable the page settings to be used
|
|
265
|
+
* @return a page of entities
|
|
266
|
+
*/
|
|
267
|
+
findAll(pageable: Pageable2): Promise<IterablePage2<T>>;
|
|
268
|
+
/**
|
|
269
|
+
* Retrieves an entity by its id.
|
|
270
|
+
*
|
|
271
|
+
* @param id must not be {@literal null}
|
|
272
|
+
* @return Promise emitting the entity with the given id or Promise emitting null if none found
|
|
273
|
+
* @throws Error in case the given {@literal id} is {@literal null}
|
|
274
|
+
*/
|
|
275
|
+
findById(id: string): Promise<T>;
|
|
276
|
+
/**
|
|
277
|
+
* Retrieves a list of entities by their id.
|
|
278
|
+
*
|
|
279
|
+
* @param ids must not be {@literal null}
|
|
280
|
+
* @return Promise emitting the entities with the given ids or Promise emitting null if none found
|
|
281
|
+
* @throws Error in case the given {@literal ids} is {@literal null}
|
|
282
|
+
*/
|
|
283
|
+
findByIds(ids: string[]): Promise<T[]>;
|
|
284
|
+
/**
|
|
285
|
+
* Executes a named query.
|
|
286
|
+
* @param queryName the name of the function that defines the query
|
|
287
|
+
* @param queryParameters to pass to the query
|
|
288
|
+
* @returns Promise with the result of the query
|
|
289
|
+
*/
|
|
290
|
+
namedQuery<U>(queryName: string, queryParameters: QueryParameter[]): Promise<U>;
|
|
291
|
+
/**
|
|
292
|
+
* Executes a named query and returns a Page of results.
|
|
293
|
+
* @param queryName the name of the function that defines the query
|
|
294
|
+
* @param queryParameters to pass to the query
|
|
295
|
+
* @param pageable the page settings to be used
|
|
296
|
+
* @returns Promise with the result of the query
|
|
297
|
+
*/
|
|
298
|
+
namedQueryPage<U>(queryName: string, queryParameters: QueryParameter[], pageable: Pageable2): Promise<IterablePage2<U>>;
|
|
299
|
+
/**
|
|
300
|
+
* Saves a given entity. This will override all data if there is an existing entity with the same id.
|
|
301
|
+
* Use the returned instance for further operations as the save operation might have changed the entity instance.
|
|
302
|
+
*
|
|
303
|
+
* @param entity must not be {@literal null}
|
|
304
|
+
* @return Promise emitting the saved entity
|
|
305
|
+
* @throws Error in case the given {@literal entity} is {@literal null}
|
|
306
|
+
*/
|
|
307
|
+
save(entity: T): Promise<T>;
|
|
308
|
+
/**
|
|
309
|
+
* Returns a {@link Page} of entities matching the search text and paging restriction provided in the {@link Pageable} object.
|
|
310
|
+
*
|
|
311
|
+
* @param searchText the text to search for entities for
|
|
312
|
+
* @param pageable the page settings to be used
|
|
313
|
+
* @return a page of entities
|
|
314
|
+
*/
|
|
315
|
+
search(searchText: string, pageable: Pageable2): Promise<IterablePage2<T>>;
|
|
316
|
+
/**
|
|
317
|
+
* This operation makes all the recent writes immediately available for search.
|
|
318
|
+
* @return a Promise that resolves when the operation is complete
|
|
319
|
+
*/
|
|
320
|
+
syncIndex(): Promise<void>;
|
|
321
|
+
/**
|
|
322
|
+
* Updates a given entity. This will only override the fields that are present in the given entity.
|
|
323
|
+
* If any fields are not present in the given entity data they will not be changed.
|
|
324
|
+
* If the entity does not exist it will be created.
|
|
325
|
+
*
|
|
326
|
+
* @param entity must not be {@literal null}
|
|
327
|
+
* @return Promise emitting the saved entity
|
|
328
|
+
* @throws Error in case the given {@literal entity} is {@literal null}
|
|
329
|
+
*/
|
|
330
|
+
update(entity: T): Promise<T>;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* This is the base class for all entity services.
|
|
334
|
+
* It provides the basic CRUD operations for entities.
|
|
335
|
+
*/
|
|
336
|
+
declare class EntityService<T> implements IEntityService<T> {
|
|
337
|
+
structureApplicationId: string;
|
|
338
|
+
structureName: string;
|
|
339
|
+
structureId: string;
|
|
340
|
+
private readonly entitiesService;
|
|
341
|
+
constructor(structureApplicationId: string, structureName: string, entitiesService?: IEntitiesService);
|
|
342
|
+
bulkSave(entities: T[]): Promise<void>;
|
|
343
|
+
bulkUpdate(entities: T[]): Promise<void>;
|
|
344
|
+
count(): Promise<number>;
|
|
345
|
+
countByQuery(query: string): Promise<number>;
|
|
346
|
+
deleteById(id: string): Promise<void>;
|
|
347
|
+
deleteByQuery(query: string): Promise<void>;
|
|
348
|
+
findAll(pageable: Pageable2): Promise<IterablePage2<T>>;
|
|
349
|
+
findById(id: string): Promise<T>;
|
|
350
|
+
findByIds(ids: string[]): Promise<T[]>;
|
|
351
|
+
namedQuery<U>(queryName: string, queryParameters: QueryParameter[]): Promise<U>;
|
|
352
|
+
namedQueryPage<U>(queryName: string, queryParameters: QueryParameter[], pageable: Pageable2): Promise<IterablePage2<U>>;
|
|
353
|
+
save(entity: T): Promise<T>;
|
|
354
|
+
search(searchText: string, pageable: Pageable2): Promise<IterablePage2<T>>;
|
|
355
|
+
syncIndex(): Promise<void>;
|
|
356
|
+
update(entity: T): Promise<T>;
|
|
357
|
+
protected beforeBulkSaveOrUpdate(entities: T[]): Promise<T[]>;
|
|
358
|
+
protected beforeSaveOrUpdate(entity: T): Promise<T>;
|
|
359
|
+
}
|
|
360
|
+
type IfFunction<
|
|
361
|
+
T,
|
|
362
|
+
U
|
|
363
|
+
> = T extends (...args: any[]) => any ? U : never;
|
|
364
|
+
type MethodsOf<T> = { [K in keyof T] : IfFunction<T[K], K> }[keyof T];
|
|
365
|
+
type ExcludedMethods = "namedQuery" | "namedQueryPage";
|
|
366
|
+
type FilteredMethods<T> = Exclude<MethodsOf<T>, ExcludedMethods>;
|
|
367
|
+
type DecoratedFunction = FilteredMethods<IEntityService<any>> | "allCreate" | "allRead" | "allUpdate" | "allDelete";
|
|
368
|
+
/**
|
|
369
|
+
* Configuration for the {@link EntityServiceDecoratorsDecorator}
|
|
370
|
+
* This is a map of method names to an array of decorators that should be applied to that method
|
|
371
|
+
*/
|
|
372
|
+
type EntityServiceDecoratorsConfig = Partial<Record<DecoratedFunction, EntityServiceDecorator[]>>;
|
|
373
|
+
import { C3Decorator as C3Decorator2 } from "@kinotic-ai/idl";
|
|
374
|
+
/**
|
|
375
|
+
* Provides a way to add decorators to an entity service
|
|
376
|
+
*/
|
|
377
|
+
declare class EntityServiceDecoratorsDecorator extends C3Decorator2 {
|
|
378
|
+
config: EntityServiceDecoratorsConfig;
|
|
379
|
+
constructor();
|
|
380
|
+
}
|
|
381
|
+
declare enum EntityType {
|
|
382
|
+
/**
|
|
383
|
+
* This is the default type of entity. It is a basic single table entity.
|
|
384
|
+
*/
|
|
385
|
+
TABLE = 0,
|
|
386
|
+
/**
|
|
387
|
+
* This entity is a stream entity. It is used for streaming data.
|
|
388
|
+
*/
|
|
389
|
+
STREAM = 1
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Provides configuration for the Elasticsearch index.
|
|
393
|
+
* This can be used to override the default index settings and mappings used by Structures.
|
|
394
|
+
*/
|
|
395
|
+
declare class EsIndexConfigurationData {
|
|
396
|
+
/**
|
|
397
|
+
* The Elasticsearch component templates to use when creating this index.
|
|
398
|
+
*/
|
|
399
|
+
componentTemplates: string[];
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* MultiTenancyType is an enum that represents the different types of multi-tenancy that can be applied to an entity.
|
|
403
|
+
*/
|
|
404
|
+
declare enum MultiTenancyType {
|
|
405
|
+
/**
|
|
406
|
+
* Default, no multi-tenancy
|
|
407
|
+
*/
|
|
408
|
+
NONE = 0,
|
|
409
|
+
/**
|
|
410
|
+
* Shared table multi-tenancy
|
|
411
|
+
*/
|
|
412
|
+
SHARED = 1
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* The {@link PrecisionType} enum is used to define the precision of a numeric field in the Continuum IDL.
|
|
416
|
+
*/
|
|
417
|
+
declare enum PrecisionType {
|
|
418
|
+
/**
|
|
419
|
+
* A double-precision 64-bit IEEE 754 floating point number, restricted to finite values.
|
|
420
|
+
*/
|
|
421
|
+
DOUBLE = 0,
|
|
422
|
+
/**
|
|
423
|
+
* A single-precision 32-bit IEEE 754 floating point number, restricted to finite values.
|
|
424
|
+
*/
|
|
425
|
+
FLOAT = 1,
|
|
426
|
+
/**
|
|
427
|
+
* A signed 32-bit integer with a minimum value of -231 and a maximum value of 231-1.
|
|
428
|
+
*/
|
|
429
|
+
INT = 2,
|
|
430
|
+
/**
|
|
431
|
+
* A signed 64-bit integer with a minimum value of -263 and a maximum value of 263-1.
|
|
432
|
+
*/
|
|
433
|
+
LONG = 3,
|
|
434
|
+
/**
|
|
435
|
+
* A signed 16-bit integer with a minimum value of -32,768 and a maximum value of 32,767.
|
|
436
|
+
*/
|
|
437
|
+
SHORT = 4
|
|
438
|
+
}
|
|
439
|
+
import { IKinotic as IKinotic2 } from "@kinotic-ai/core";
|
|
440
|
+
import { IServiceProxy as IServiceProxy2, Page as Page2, Pageable as Pageable3, IterablePage as IterablePage3 } from "@kinotic-ai/core";
|
|
441
|
+
type TenantSelection = string[];
|
|
442
|
+
interface IAdminEntitiesService {
|
|
443
|
+
/**
|
|
444
|
+
* Returns the number of entities available.
|
|
445
|
+
* @param structureId the id of the structure to count
|
|
446
|
+
* @param tenantSelection the list of tenants to use when retrieving the entity records
|
|
447
|
+
* @return {@link Promise} emitting the number of entities.
|
|
448
|
+
*/
|
|
449
|
+
count(structureId: string, tenantSelection: TenantSelection): Promise<number>;
|
|
450
|
+
/**
|
|
451
|
+
* Returns the number of entities available for the given query.
|
|
452
|
+
*
|
|
453
|
+
* @param structureId the id of the structure to save the entity for
|
|
454
|
+
* @param query the query used to limit result
|
|
455
|
+
* @param tenantSelection the list of tenants to use when retrieving the entity records
|
|
456
|
+
* @return Promise emitting the number of entities
|
|
457
|
+
*/
|
|
458
|
+
countByQuery(structureId: string, query: string, tenantSelection: TenantSelection): Promise<number>;
|
|
459
|
+
/**
|
|
460
|
+
* Deletes the entity with the given id.
|
|
461
|
+
*
|
|
462
|
+
* @param structureId the id of the structure to save the entity for
|
|
463
|
+
* @param id must not be {@literal null}
|
|
464
|
+
* @return {@link Promise} emitting when delete is complete
|
|
465
|
+
* @throws IllegalArgumentException in case the given {@literal id} is {@literal null}
|
|
466
|
+
*/
|
|
467
|
+
deleteById(structureId: string, id: TenantSpecificId): Promise<void>;
|
|
468
|
+
/**
|
|
469
|
+
* Deletes the entity with the given id.
|
|
470
|
+
*
|
|
471
|
+
* @param structureId the id of the structure to save the entity for
|
|
472
|
+
* @param query the query used to filter records to delete, must not be {@literal null}
|
|
473
|
+
* @param tenantSelection the list of tenants to use when deleting the entity records
|
|
474
|
+
* @return Promise signaling when operation has completed
|
|
475
|
+
* @throws Error in case the given {@literal query} is {@literal null}
|
|
476
|
+
*/
|
|
477
|
+
deleteByQuery(structureId: string, query: string, tenantSelection: TenantSelection): Promise<void>;
|
|
478
|
+
/**
|
|
479
|
+
* Returns a {@link IterablePage} of entities meeting the paging restriction provided in the {@link Pageable} object.
|
|
480
|
+
*
|
|
481
|
+
* @param structureId the id of the structure to save the entity for
|
|
482
|
+
* @param tenantSelection the list of tenants to use when retrieving the entity records
|
|
483
|
+
* @param pageable the page settings to be used
|
|
484
|
+
* @return a page of entities
|
|
485
|
+
*/
|
|
486
|
+
findAll<T>(structureId: string, tenantSelection: TenantSelection, pageable: Pageable3): Promise<IterablePage3<T>>;
|
|
487
|
+
/**
|
|
488
|
+
* Retrieves an entity by its id.
|
|
489
|
+
*
|
|
490
|
+
* @param structureId the id of the structure to save the entity for
|
|
491
|
+
* @param id must not be {@literal null}
|
|
492
|
+
* @return {@link Promise} with the entity with the given id or {@link Promise} emitting null if none found
|
|
493
|
+
* @throws IllegalArgumentException in case the given {@literal id} is {@literal null}
|
|
494
|
+
*/
|
|
495
|
+
findById<T>(structureId: string, id: TenantSpecificId): Promise<T>;
|
|
496
|
+
/**
|
|
497
|
+
* Retrieves a list of entities by their id.
|
|
498
|
+
*
|
|
499
|
+
* @param structureId the id of the structure to save the entity for
|
|
500
|
+
* @param ids must not be {@literal null}
|
|
501
|
+
* @return Promise emitting the entities with the given ids or Promise emitting null if none found
|
|
502
|
+
* @throws Error in case the given {@literal ids} is {@literal null}
|
|
503
|
+
*/
|
|
504
|
+
findByIds<T>(structureId: string, ids: TenantSpecificId[]): Promise<T[]>;
|
|
505
|
+
/**
|
|
506
|
+
* Executes a named query.
|
|
507
|
+
* @param structureId the id of the structure that this named query is defined for
|
|
508
|
+
* @param queryName the name of the function that defines the query
|
|
509
|
+
* @param parameters to pass to the query
|
|
510
|
+
* @returns Promise with the result of the query
|
|
511
|
+
*/
|
|
512
|
+
namedQuery<T>(structureId: string, queryName: string, parameters: QueryParameter[]): Promise<T>;
|
|
513
|
+
/**
|
|
514
|
+
* Executes a named query and returns a Page of results.
|
|
515
|
+
* @param structureId the id of the structure that this named query is defined for
|
|
516
|
+
* @param queryName the name of the function that defines the query
|
|
517
|
+
* @param parameters to pass to the query
|
|
518
|
+
* @param pageable the page settings to be used
|
|
519
|
+
* @returns Promise with the result of the query
|
|
520
|
+
*/
|
|
521
|
+
namedQueryPage<T>(structureId: string, queryName: string, parameters: QueryParameter[], pageable: Pageable3): Promise<IterablePage3<T>>;
|
|
522
|
+
/**
|
|
523
|
+
* Returns a {@link IterablePage} of entities matching the search text and paging restriction provided in the {@link Pageable} object.
|
|
524
|
+
*
|
|
525
|
+
* @param structureId the id of the structure to save the entity for
|
|
526
|
+
* @param searchText the text to search for entities for
|
|
527
|
+
* @param tenantSelection the list of tenants to use when retrieving the entity records
|
|
528
|
+
* @param pageable the page settings to be used
|
|
529
|
+
* @return a page of entities
|
|
530
|
+
*/
|
|
531
|
+
search<T>(structureId: string, searchText: string, tenantSelection: TenantSelection, pageable: Pageable3): Promise<IterablePage3<T>>;
|
|
532
|
+
}
|
|
533
|
+
declare class AdminEntitiesService implements IAdminEntitiesService {
|
|
534
|
+
protected serviceProxy: IServiceProxy2;
|
|
535
|
+
constructor(kinotic: IKinotic2);
|
|
536
|
+
count(structureId: string, tenantSelection: TenantSelection): Promise<number>;
|
|
537
|
+
countByQuery(structureId: string, query: string, tenantSelection: TenantSelection): Promise<number>;
|
|
538
|
+
deleteById(structureId: string, id: TenantSpecificId): Promise<void>;
|
|
539
|
+
deleteByQuery(structureId: string, query: string, tenantSelection: TenantSelection): Promise<void>;
|
|
540
|
+
findAll<T>(structureId: string, tenantSelection: TenantSelection, pageable: Pageable3): Promise<IterablePage3<T>>;
|
|
541
|
+
findAllSinglePage<T>(structureId: string, tenantSelection: TenantSelection, pageable: Pageable3): Promise<Page2<T>>;
|
|
542
|
+
findById<T>(structureId: string, id: TenantSpecificId): Promise<T>;
|
|
543
|
+
findByIds<T>(structureId: string, ids: TenantSpecificId[]): Promise<T[]>;
|
|
544
|
+
namedQuery<T>(structureId: string, queryName: string, parameters: QueryParameter[]): Promise<T>;
|
|
545
|
+
namedQueryPage<T>(structureId: string, queryName: string, parameters: QueryParameter[], pageable: Pageable3): Promise<IterablePage3<T>>;
|
|
546
|
+
namedQuerySinglePage<T>(structureId: string, queryName: string, parameters: QueryParameter[], pageable: Pageable3): Promise<Page2<T>>;
|
|
547
|
+
search<T>(structureId: string, searchText: string, tenantSelection: TenantSelection, pageable: Pageable3): Promise<IterablePage3<T>>;
|
|
548
|
+
searchSinglePage<T>(structureId: string, searchText: string, tenantSelection: TenantSelection, pageable: Pageable3): Promise<Page2<T>>;
|
|
549
|
+
}
|
|
550
|
+
import { Pageable as Pageable4, IterablePage as IterablePage4 } from "@kinotic-ai/core";
|
|
551
|
+
/**
|
|
552
|
+
* This is the base interface for all admin entity services.
|
|
553
|
+
* It provides the basic CRUD operations for entities with multi-tenancy support.
|
|
554
|
+
*/
|
|
555
|
+
interface IAdminEntityService<T> {
|
|
556
|
+
/**
|
|
557
|
+
* The application id of the structure this service is for
|
|
558
|
+
*/
|
|
559
|
+
structureApplicationId: string;
|
|
560
|
+
/**
|
|
561
|
+
* The name of the structure this service is for
|
|
562
|
+
*/
|
|
563
|
+
structureName: string;
|
|
564
|
+
/**
|
|
565
|
+
* The id of the structure this service is for
|
|
566
|
+
* Which is the applicationId + '.' + name
|
|
567
|
+
*/
|
|
568
|
+
structureId: string;
|
|
569
|
+
/**
|
|
570
|
+
* Returns the number of entities available.
|
|
571
|
+
*
|
|
572
|
+
* @param tenantSelection the list of tenants to use when retrieving the entity records
|
|
573
|
+
* @return Promise emitting the number of entities
|
|
574
|
+
*/
|
|
575
|
+
count(tenantSelection: TenantSelection): Promise<number>;
|
|
576
|
+
/**
|
|
577
|
+
* Returns the number of entities available for the given query.
|
|
578
|
+
*
|
|
579
|
+
* @param query the query used to limit result
|
|
580
|
+
* @param tenantSelection the list of tenants to use when retrieving the entity records
|
|
581
|
+
* @return Promise emitting the number of entities
|
|
582
|
+
*/
|
|
583
|
+
countByQuery(query: string, tenantSelection: TenantSelection): Promise<number>;
|
|
584
|
+
/**
|
|
585
|
+
* Deletes the entity with the given id.
|
|
586
|
+
*
|
|
587
|
+
* @param id must not be {@literal null}
|
|
588
|
+
* @return Promise signaling when operation has completed
|
|
589
|
+
* @throws Error in case the given {@literal id} is {@literal null}
|
|
590
|
+
*/
|
|
591
|
+
deleteById(id: TenantSpecificId): Promise<void>;
|
|
592
|
+
/**
|
|
593
|
+
* Deletes the entity with the given id.
|
|
594
|
+
*
|
|
595
|
+
* @param query the query used to filter records to delete, must not be {@literal null}
|
|
596
|
+
* @param tenantSelection the list of tenants to use when deleting the entity records
|
|
597
|
+
* @return Promise signaling when operation has completed
|
|
598
|
+
* @throws Error in case the given {@literal query} is {@literal null}
|
|
599
|
+
*/
|
|
600
|
+
deleteByQuery(query: string, tenantSelection: TenantSelection): Promise<void>;
|
|
601
|
+
/**
|
|
602
|
+
* Returns a {@link Page} of entities meeting the paging restriction provided in the {@link Pageable} object.
|
|
603
|
+
*
|
|
604
|
+
* @param tenantSelection the list of tenants to use when retrieving the entity records
|
|
605
|
+
* @param pageable the page settings to be used
|
|
606
|
+
* @return a page of entities
|
|
607
|
+
*/
|
|
608
|
+
findAll(tenantSelection: TenantSelection, pageable: Pageable4): Promise<IterablePage4<T>>;
|
|
609
|
+
/**
|
|
610
|
+
* Retrieves an entity by its id.
|
|
611
|
+
*
|
|
612
|
+
* @param id must not be {@literal null}
|
|
613
|
+
* @return Promise emitting the entity with the given id or Promise emitting null if none found
|
|
614
|
+
* @throws Error in case the given {@literal id} is {@literal null}
|
|
615
|
+
*/
|
|
616
|
+
findById(id: TenantSpecificId): Promise<T>;
|
|
617
|
+
/**
|
|
618
|
+
* Retrieves a list of entities by their id.
|
|
619
|
+
*
|
|
620
|
+
* @param ids must not be {@literal null}
|
|
621
|
+
* @return Promise emitting the entities with the given ids or Promise emitting null if none found
|
|
622
|
+
* @throws Error in case the given {@literal ids} is {@literal null}
|
|
623
|
+
*/
|
|
624
|
+
findByIds(ids: TenantSpecificId[]): Promise<T[]>;
|
|
625
|
+
/**
|
|
626
|
+
* Executes a named query.
|
|
627
|
+
* @param queryName the name of the function that defines the query
|
|
628
|
+
* @param queryParameters to pass to the query
|
|
629
|
+
* @returns Promise with the result of the query
|
|
630
|
+
*/
|
|
631
|
+
namedQuery<U>(queryName: string, queryParameters: QueryParameter[]): Promise<U>;
|
|
632
|
+
/**
|
|
633
|
+
* Executes a named query and returns a Page of results.
|
|
634
|
+
* @param queryName the name of the function that defines the query
|
|
635
|
+
* @param queryParameters to pass to the query
|
|
636
|
+
* @param pageable the page settings to be used
|
|
637
|
+
* @returns Promise with the result of the query
|
|
638
|
+
*/
|
|
639
|
+
namedQueryPage<U>(queryName: string, queryParameters: QueryParameter[], pageable: Pageable4): Promise<IterablePage4<U>>;
|
|
640
|
+
/**
|
|
641
|
+
* Returns a {@link Page} of entities matching the search text and paging restriction provided in the {@link Pageable} object.
|
|
642
|
+
*
|
|
643
|
+
* @param searchText the text to search for entities for
|
|
644
|
+
* @param tenantSelection the list of tenants to use when retrieving the entity records
|
|
645
|
+
* @param pageable the page settings to be used
|
|
646
|
+
* @return a page of entities
|
|
647
|
+
*/
|
|
648
|
+
search(searchText: string, tenantSelection: TenantSelection, pageable: Pageable4): Promise<IterablePage4<T>>;
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* This is the base class for all admin entity services.
|
|
652
|
+
* It provides the basic CRUD operations for entities with multi-tenancy support.
|
|
653
|
+
*/
|
|
654
|
+
declare class AdminEntityService<T> implements IAdminEntityService<T> {
|
|
655
|
+
structureApplicationId: string;
|
|
656
|
+
structureName: string;
|
|
657
|
+
structureId: string;
|
|
658
|
+
private readonly adminEntitiesService;
|
|
659
|
+
constructor(structureApplicationId: string, structureName: string, adminEntitiesService?: IAdminEntitiesService);
|
|
660
|
+
count(tenantSelection: TenantSelection): Promise<number>;
|
|
661
|
+
countByQuery(query: string, tenantSelection: TenantSelection): Promise<number>;
|
|
662
|
+
deleteById(id: TenantSpecificId): Promise<void>;
|
|
663
|
+
deleteByQuery(query: string, tenantSelection: TenantSelection): Promise<void>;
|
|
664
|
+
findAll(tenantSelection: TenantSelection, pageable: Pageable4): Promise<IterablePage4<T>>;
|
|
665
|
+
findById(id: TenantSpecificId): Promise<T>;
|
|
666
|
+
findByIds(ids: TenantSpecificId[]): Promise<T[]>;
|
|
667
|
+
namedQuery<U>(queryName: string, queryParameters: QueryParameter[]): Promise<U>;
|
|
668
|
+
namedQueryPage<U>(queryName: string, queryParameters: QueryParameter[], pageable: Pageable4): Promise<IterablePage4<U>>;
|
|
669
|
+
search(searchText: string, tenantSelection: TenantSelection, pageable: Pageable4): Promise<IterablePage4<T>>;
|
|
670
|
+
}
|
|
671
|
+
import { KinoticPlugin } from "@kinotic-ai/core";
|
|
672
|
+
interface IPersistenceExtension {
|
|
673
|
+
entities: IEntitiesService;
|
|
674
|
+
adminEntities: IAdminEntitiesService;
|
|
675
|
+
}
|
|
676
|
+
declare const PersistencePlugin: KinoticPlugin<IPersistenceExtension>;
|
|
677
|
+
import { Kinotic, KinoticSingleton as KinoticSingleton2, IKinotic as IKinotic3, KinoticPlugin as KinoticPlugin2 } from "@kinotic-ai/core";
|
|
678
|
+
declare module "@kinotic-ai/core" {
|
|
679
|
+
interface KinoticSingleton extends IPersistenceExtension {}
|
|
680
|
+
}
|
|
681
|
+
export { TenantSpecificId, TenantSelection, QueryParameter, QueryOptions, PrecisionType, PersistencePlugin, MultiTenancyType, KinoticSingleton2 as KinoticSingleton, KinoticPlugin2 as KinoticPlugin, Kinotic, IPersistenceExtension, IKinotic3 as IKinotic, IEntityService, IEntitiesService, IAdminEntityService, IAdminEntitiesService, EsIndexConfigurationData, EntityType, EntityServiceDecoratorsDecorator, EntityServiceDecoratorsConfig, EntityServiceDecorator, EntityService, EntitiesService, DecoratedFunction, AdminEntityService, AdminEntitiesService };
|