@kinotic-ai/persistence 1.0.10 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +47 -47
- package/dist/index.d.cts +256 -255
- package/dist/index.d.ts +256 -255
- package/dist/index.js +47 -47
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -90,10 +90,124 @@ import { C3Decorator } from "@kinotic-ai/idl";
|
|
|
90
90
|
* This class denotes {@link C3Decorator} that can be applied to an {@link EntityService} using the {@link EntityServiceDecoratorsDecorator}
|
|
91
91
|
*/
|
|
92
92
|
declare abstract class EntityServiceDecorator extends C3Decorator {}
|
|
93
|
-
import {
|
|
93
|
+
import { IEntityService } from "@/api/IEntityService";
|
|
94
|
+
type IfFunction<
|
|
95
|
+
T,
|
|
96
|
+
U
|
|
97
|
+
> = T extends (...args: any[]) => any ? U : never;
|
|
98
|
+
type MethodsOf<T> = { [K in keyof T] : IfFunction<T[K], K> }[keyof T];
|
|
99
|
+
type ExcludedMethods = "namedQuery" | "namedQueryPage";
|
|
100
|
+
type FilteredMethods<T> = Exclude<MethodsOf<T>, ExcludedMethods>;
|
|
101
|
+
type DecoratedFunction = FilteredMethods<IEntityService<any>> | "allCreate" | "allRead" | "allUpdate" | "allDelete";
|
|
102
|
+
/**
|
|
103
|
+
* Configuration for the {@link EntityServiceDecoratorsDecorator}
|
|
104
|
+
* This is a map of method names to an array of decorators that should be applied to that method
|
|
105
|
+
*/
|
|
106
|
+
type EntityServiceDecoratorsConfig = Partial<Record<DecoratedFunction, EntityServiceDecorator[]>>;
|
|
107
|
+
declare enum KinoticPersistenceDecorator {
|
|
108
|
+
Entity = "__structures-entity__",
|
|
109
|
+
Id = "__structures-id__",
|
|
110
|
+
AutoGeneratedId = "__structures-auto-generated-id__",
|
|
111
|
+
Flattened = "__structures-flattened__",
|
|
112
|
+
Nested = "__structures-nested__",
|
|
113
|
+
Text = "__structures-text__",
|
|
114
|
+
NotNull = "__structures-notnull__",
|
|
115
|
+
Precision = "__structures-precision__",
|
|
116
|
+
Discriminator = "__structures-discriminator__",
|
|
117
|
+
Query = "__structures-query__",
|
|
118
|
+
EntityServiceDecorators = "__structures-entity-service-decorators__"
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Signifies that a property is an auto-generated ID for the entity.
|
|
122
|
+
*/
|
|
123
|
+
declare function AutoGeneratedId(target: any, propertyKey: string): void;
|
|
124
|
+
declare class DiscriminatorConfig {
|
|
125
|
+
propertyName: string;
|
|
126
|
+
constructor(propertyName: string);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Signifies that a property is a discriminator for the entity.
|
|
130
|
+
* This is used to determine the type of the entity when deserializing from JSON.
|
|
131
|
+
* @param propertyName the name of the property to use as the discriminator
|
|
132
|
+
*/
|
|
133
|
+
declare function Discriminator(propertyName: string): (target: any, propertyKey: string) => void;
|
|
134
|
+
declare class EntityConfig {
|
|
135
|
+
multiTenancyType: MultiTenancyType;
|
|
136
|
+
entityType: EntityType;
|
|
137
|
+
constructor(multiTenancyType: MultiTenancyType, entityType?: EntityType);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Signifies that a class is a Structures Entity.
|
|
141
|
+
* This is required to define the class as an entity in the Structures framework.
|
|
142
|
+
* @param multiTenancyType the type of multi-tenancy to use for this entity
|
|
143
|
+
* @param entityType the type of entity to use for this entity
|
|
144
|
+
*/
|
|
145
|
+
declare function Entity(multiTenancyType?: MultiTenancyType, entityType?: EntityType): (constructor: Function) => void;
|
|
146
|
+
/**
|
|
147
|
+
* A class Decorator when applied to an Entity will configure Decorators to be applied to the EntityService
|
|
148
|
+
* @param config the {@link EntityServiceDecoratorsConfig} to use
|
|
149
|
+
*/
|
|
150
|
+
declare function EntityServiceDecorators(_config: EntityServiceDecoratorsConfig): (_constructor: Function) => void;
|
|
151
|
+
/**
|
|
152
|
+
* Provides configuration for the Elasticsearch index.
|
|
153
|
+
* This can be used to override the default index settings and mappings used by Structures.
|
|
154
|
+
*/
|
|
155
|
+
declare function EsIndexConfiguration(_value: EsIndexConfigurationData): (_constructor: Function) => void;
|
|
156
|
+
declare function Flattened(target: any, propertyKey: string): void;
|
|
157
|
+
/**
|
|
158
|
+
* Signifies that a property is the ID of the entity.
|
|
159
|
+
*/
|
|
160
|
+
declare function Id(target: any, propertyKey: string): void;
|
|
161
|
+
declare function Nested(target: any, propertyKey: string): void;
|
|
162
|
+
/**
|
|
163
|
+
* Signifies that a property is not indexed in Elasticsearch.
|
|
164
|
+
*/
|
|
165
|
+
declare function NotIndexed(_target: any, _propertyKey: string): void;
|
|
166
|
+
declare function NotNull(target: any, propertyKey: string): void;
|
|
167
|
+
declare function Policy(_policies: string[][]): (_target: any, _propertyKey?: string, _descriptor?: PropertyDescriptor) => void;
|
|
168
|
+
declare class PrecisionConfig {
|
|
169
|
+
precisionType: PrecisionType;
|
|
170
|
+
constructor(precisionType: PrecisionType);
|
|
171
|
+
}
|
|
172
|
+
declare function Precision(precisionType?: PrecisionType): (target: any, propertyKey: string) => void;
|
|
173
|
+
declare function Query(statements: string): (target: any, key: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
174
|
+
declare function Role(_roles: string[]): (_target: any, _propertyKey?: string, _descriptor?: PropertyDescriptor) => void;
|
|
175
|
+
declare function Text(target: any, propertyKey: string): void;
|
|
176
|
+
/**
|
|
177
|
+
* This is used for data streams to signify the field that should be used as the time reference.
|
|
178
|
+
*/
|
|
179
|
+
declare function TimeReference(_target: any, _propertyKey: string): void;
|
|
180
|
+
declare function Version(_target: any, _propertyKey: string): void;
|
|
181
|
+
declare function TenantId(_target: any, _propertyKey: string): void;
|
|
182
|
+
import { C3Decorator as C3Decorator2 } from "@kinotic-ai/idl";
|
|
183
|
+
/**
|
|
184
|
+
* Provides a way to add decorators to an entity service
|
|
185
|
+
*/
|
|
186
|
+
declare class EntityServiceDecoratorsDecorator extends C3Decorator2 {
|
|
187
|
+
config: EntityServiceDecoratorsConfig;
|
|
188
|
+
constructor();
|
|
189
|
+
}
|
|
190
|
+
declare class PolicyDecorator extends EntityServiceDecorator {
|
|
191
|
+
policies: string[][];
|
|
192
|
+
constructor(policies: string[][]);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Provides a mechanism to apply the @Policy decorator to an {@link EntityService}
|
|
196
|
+
* @param policies to be supplied
|
|
197
|
+
*/
|
|
198
|
+
declare function $Policy(policies: string[][]): PolicyDecorator;
|
|
199
|
+
declare class RoleDecorator extends EntityServiceDecorator {
|
|
200
|
+
roles: string[];
|
|
201
|
+
constructor(roles: string[]);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Provides a mechanism to apply the @Role decorator to an {@link EntityService}
|
|
205
|
+
* @param roles to be supplied
|
|
206
|
+
*/
|
|
207
|
+
declare function $Role(roles: string[]): RoleDecorator;
|
|
94
208
|
import { IKinotic } from "@kinotic-ai/core";
|
|
95
209
|
import { IServiceProxy, Page, Pageable, IterablePage } from "@kinotic-ai/core";
|
|
96
|
-
interface
|
|
210
|
+
interface IEntitiesRepository {
|
|
97
211
|
/**
|
|
98
212
|
* Saves all given entities.
|
|
99
213
|
* @param structureId the id of the structure to save the entities for
|
|
@@ -235,7 +349,7 @@ interface IEntitiesService {
|
|
|
235
349
|
*/
|
|
236
350
|
update<T>(structureId: string, entity: T): Promise<T>;
|
|
237
351
|
}
|
|
238
|
-
declare class
|
|
352
|
+
declare class EntitiesRepository implements IEntitiesRepository {
|
|
239
353
|
protected serviceProxy: IServiceProxy;
|
|
240
354
|
constructor(kinotic: IKinotic);
|
|
241
355
|
bulkSave<T>(structureId: string, entities: T[]): Promise<void>;
|
|
@@ -257,21 +371,133 @@ declare class EntitiesService implements IEntitiesService {
|
|
|
257
371
|
syncIndex(structureId: string): Promise<void>;
|
|
258
372
|
update<T>(structureId: string, entity: T): Promise<T>;
|
|
259
373
|
}
|
|
374
|
+
import { IKinotic as IKinotic2 } from "@kinotic-ai/core";
|
|
375
|
+
import { IServiceProxy as IServiceProxy2, Page as Page2, Pageable as Pageable2, IterablePage as IterablePage2 } from "@kinotic-ai/core";
|
|
376
|
+
type TenantSelection = string[];
|
|
377
|
+
interface IAdminEntitiesRepository {
|
|
378
|
+
/**
|
|
379
|
+
* Returns the number of entities available.
|
|
380
|
+
* @param structureId the id of the structure to count
|
|
381
|
+
* @param tenantSelection the list of tenants to use when retrieving the entity records
|
|
382
|
+
* @return {@link Promise} emitting the number of entities.
|
|
383
|
+
*/
|
|
384
|
+
count(structureId: string, tenantSelection: TenantSelection): Promise<number>;
|
|
385
|
+
/**
|
|
386
|
+
* Returns the number of entities available for the given query.
|
|
387
|
+
*
|
|
388
|
+
* @param structureId the id of the structure to save the entity for
|
|
389
|
+
* @param query the query used to limit result
|
|
390
|
+
* @param tenantSelection the list of tenants to use when retrieving the entity records
|
|
391
|
+
* @return Promise emitting the number of entities
|
|
392
|
+
*/
|
|
393
|
+
countByQuery(structureId: string, query: string, tenantSelection: TenantSelection): Promise<number>;
|
|
394
|
+
/**
|
|
395
|
+
* Deletes the entity with the given id.
|
|
396
|
+
*
|
|
397
|
+
* @param structureId the id of the structure to save the entity for
|
|
398
|
+
* @param id must not be {@literal null}
|
|
399
|
+
* @return {@link Promise} emitting when delete is complete
|
|
400
|
+
* @throws IllegalArgumentException in case the given {@literal id} is {@literal null}
|
|
401
|
+
*/
|
|
402
|
+
deleteById(structureId: string, id: TenantSpecificId): Promise<void>;
|
|
403
|
+
/**
|
|
404
|
+
* Deletes the entity with the given id.
|
|
405
|
+
*
|
|
406
|
+
* @param structureId the id of the structure to save the entity for
|
|
407
|
+
* @param query the query used to filter records to delete, must not be {@literal null}
|
|
408
|
+
* @param tenantSelection the list of tenants to use when deleting the entity records
|
|
409
|
+
* @return Promise signaling when operation has completed
|
|
410
|
+
* @throws Error in case the given {@literal query} is {@literal null}
|
|
411
|
+
*/
|
|
412
|
+
deleteByQuery(structureId: string, query: string, tenantSelection: TenantSelection): Promise<void>;
|
|
413
|
+
/**
|
|
414
|
+
* Returns a {@link IterablePage} of entities meeting the paging restriction provided in the {@link Pageable} object.
|
|
415
|
+
*
|
|
416
|
+
* @param structureId the id of the structure to save the entity for
|
|
417
|
+
* @param tenantSelection the list of tenants to use when retrieving the entity records
|
|
418
|
+
* @param pageable the page settings to be used
|
|
419
|
+
* @return a page of entities
|
|
420
|
+
*/
|
|
421
|
+
findAll<T>(structureId: string, tenantSelection: TenantSelection, pageable: Pageable2): Promise<IterablePage2<T>>;
|
|
422
|
+
/**
|
|
423
|
+
* Retrieves an entity by its id.
|
|
424
|
+
*
|
|
425
|
+
* @param structureId the id of the structure to save the entity for
|
|
426
|
+
* @param id must not be {@literal null}
|
|
427
|
+
* @return {@link Promise} with the entity with the given id or {@link Promise} emitting null if none found
|
|
428
|
+
* @throws IllegalArgumentException in case the given {@literal id} is {@literal null}
|
|
429
|
+
*/
|
|
430
|
+
findById<T>(structureId: string, id: TenantSpecificId): Promise<T>;
|
|
431
|
+
/**
|
|
432
|
+
* Retrieves a list of entities by their id.
|
|
433
|
+
*
|
|
434
|
+
* @param structureId the id of the structure to save the entity for
|
|
435
|
+
* @param ids must not be {@literal null}
|
|
436
|
+
* @return Promise emitting the entities with the given ids or Promise emitting null if none found
|
|
437
|
+
* @throws Error in case the given {@literal ids} is {@literal null}
|
|
438
|
+
*/
|
|
439
|
+
findByIds<T>(structureId: string, ids: TenantSpecificId[]): Promise<T[]>;
|
|
440
|
+
/**
|
|
441
|
+
* Executes a named query.
|
|
442
|
+
* @param structureId the id of the structure that this named query is defined for
|
|
443
|
+
* @param queryName the name of the function that defines the query
|
|
444
|
+
* @param parameters to pass to the query
|
|
445
|
+
* @returns Promise with the result of the query
|
|
446
|
+
*/
|
|
447
|
+
namedQuery<T>(structureId: string, queryName: string, parameters: QueryParameter[]): Promise<T>;
|
|
448
|
+
/**
|
|
449
|
+
* Executes a named query and returns a Page of results.
|
|
450
|
+
* @param structureId the id of the structure that this named query is defined for
|
|
451
|
+
* @param queryName the name of the function that defines the query
|
|
452
|
+
* @param parameters to pass to the query
|
|
453
|
+
* @param pageable the page settings to be used
|
|
454
|
+
* @returns Promise with the result of the query
|
|
455
|
+
*/
|
|
456
|
+
namedQueryPage<T>(structureId: string, queryName: string, parameters: QueryParameter[], pageable: Pageable2): Promise<IterablePage2<T>>;
|
|
457
|
+
/**
|
|
458
|
+
* Returns a {@link IterablePage} of entities matching the search text and paging restriction provided in the {@link Pageable} object.
|
|
459
|
+
*
|
|
460
|
+
* @param structureId the id of the structure to save the entity for
|
|
461
|
+
* @param searchText the text to search for entities for
|
|
462
|
+
* @param tenantSelection the list of tenants to use when retrieving the entity records
|
|
463
|
+
* @param pageable the page settings to be used
|
|
464
|
+
* @return a page of entities
|
|
465
|
+
*/
|
|
466
|
+
search<T>(structureId: string, searchText: string, tenantSelection: TenantSelection, pageable: Pageable2): Promise<IterablePage2<T>>;
|
|
467
|
+
}
|
|
468
|
+
declare class AdminEntitiesRepository implements IAdminEntitiesRepository {
|
|
469
|
+
protected serviceProxy: IServiceProxy2;
|
|
470
|
+
constructor(kinotic: IKinotic2);
|
|
471
|
+
count(structureId: string, tenantSelection: TenantSelection): Promise<number>;
|
|
472
|
+
countByQuery(structureId: string, query: string, tenantSelection: TenantSelection): Promise<number>;
|
|
473
|
+
deleteById(structureId: string, id: TenantSpecificId): Promise<void>;
|
|
474
|
+
deleteByQuery(structureId: string, query: string, tenantSelection: TenantSelection): Promise<void>;
|
|
475
|
+
findAll<T>(structureId: string, tenantSelection: TenantSelection, pageable: Pageable2): Promise<IterablePage2<T>>;
|
|
476
|
+
findAllSinglePage<T>(structureId: string, tenantSelection: TenantSelection, pageable: Pageable2): Promise<Page2<T>>;
|
|
477
|
+
findById<T>(structureId: string, id: TenantSpecificId): Promise<T>;
|
|
478
|
+
findByIds<T>(structureId: string, ids: TenantSpecificId[]): Promise<T[]>;
|
|
479
|
+
namedQuery<T>(structureId: string, queryName: string, parameters: QueryParameter[]): Promise<T>;
|
|
480
|
+
namedQueryPage<T>(structureId: string, queryName: string, parameters: QueryParameter[], pageable: Pageable2): Promise<IterablePage2<T>>;
|
|
481
|
+
namedQuerySinglePage<T>(structureId: string, queryName: string, parameters: QueryParameter[], pageable: Pageable2): Promise<Page2<T>>;
|
|
482
|
+
search<T>(structureId: string, searchText: string, tenantSelection: TenantSelection, pageable: Pageable2): Promise<IterablePage2<T>>;
|
|
483
|
+
searchSinglePage<T>(structureId: string, searchText: string, tenantSelection: TenantSelection, pageable: Pageable2): Promise<Page2<T>>;
|
|
484
|
+
}
|
|
485
|
+
import { Pageable as Pageable3, IterablePage as IterablePage3 } from "@kinotic-ai/core";
|
|
260
486
|
/**
|
|
261
|
-
* This is the base interface for all entity
|
|
487
|
+
* This is the base interface for all entity repositories.
|
|
262
488
|
* It provides the basic CRUD operations for entities.
|
|
263
489
|
*/
|
|
264
|
-
interface
|
|
490
|
+
interface IEntityRepository<T> {
|
|
265
491
|
/**
|
|
266
|
-
* The applicationId of the Entity this
|
|
492
|
+
* The applicationId of the Entity this repository is for
|
|
267
493
|
*/
|
|
268
494
|
entityApplicationId: string;
|
|
269
495
|
/**
|
|
270
|
-
* The name of the Entity this
|
|
496
|
+
* The name of the Entity this repository is for
|
|
271
497
|
*/
|
|
272
498
|
entityName: string;
|
|
273
499
|
/**
|
|
274
|
-
* The id of the Entity this
|
|
500
|
+
* The id of the Entity this repository is for
|
|
275
501
|
* Which is the applicationId + '.' + name
|
|
276
502
|
*/
|
|
277
503
|
entityId: string;
|
|
@@ -322,7 +548,7 @@ interface IEntityService<T> {
|
|
|
322
548
|
* @param pageable the page settings to be used
|
|
323
549
|
* @return a page of entities
|
|
324
550
|
*/
|
|
325
|
-
findAll(pageable:
|
|
551
|
+
findAll(pageable: Pageable3): Promise<IterablePage3<T>>;
|
|
326
552
|
/**
|
|
327
553
|
* Retrieves an entity by its id.
|
|
328
554
|
*
|
|
@@ -353,7 +579,7 @@ interface IEntityService<T> {
|
|
|
353
579
|
* @param pageable the page settings to be used
|
|
354
580
|
* @returns Promise with the result of the query
|
|
355
581
|
*/
|
|
356
|
-
namedQueryPage<U>(queryName: string, queryParameters: QueryParameter[], pageable:
|
|
582
|
+
namedQueryPage<U>(queryName: string, queryParameters: QueryParameter[], pageable: Pageable3): Promise<IterablePage3<U>>;
|
|
357
583
|
/**
|
|
358
584
|
* Saves a given entity. This will override all data if there is an existing entity with the same id.
|
|
359
585
|
* Use the returned instance for further operations as the save operation might have changed the entity instance.
|
|
@@ -370,7 +596,7 @@ interface IEntityService<T> {
|
|
|
370
596
|
* @param pageable the page settings to be used
|
|
371
597
|
* @return a page of entities
|
|
372
598
|
*/
|
|
373
|
-
search(searchText: string, pageable:
|
|
599
|
+
search(searchText: string, pageable: Pageable3): Promise<IterablePage3<T>>;
|
|
374
600
|
/**
|
|
375
601
|
* This operation makes all the recent writes immediately available for search.
|
|
376
602
|
* @return a Promise that resolves when the operation is complete
|
|
@@ -388,274 +614,49 @@ interface IEntityService<T> {
|
|
|
388
614
|
update(entity: T): Promise<T>;
|
|
389
615
|
}
|
|
390
616
|
/**
|
|
391
|
-
* This is the base class for all entity
|
|
617
|
+
* This is the base class for all entity repositories.
|
|
392
618
|
* It provides the basic CRUD operations for entities.
|
|
393
619
|
*/
|
|
394
|
-
declare class
|
|
620
|
+
declare class EntityRepository<T> implements IEntityRepository<T> {
|
|
395
621
|
entityApplicationId: string;
|
|
396
622
|
entityName: string;
|
|
397
623
|
entityId: string;
|
|
398
|
-
private readonly
|
|
399
|
-
constructor(structureApplicationId: string, structureName: string,
|
|
624
|
+
private readonly entitiesRepository;
|
|
625
|
+
constructor(structureApplicationId: string, structureName: string, entitiesRepository?: IEntitiesRepository);
|
|
400
626
|
bulkSave(entities: T[]): Promise<void>;
|
|
401
627
|
bulkUpdate(entities: T[]): Promise<void>;
|
|
402
628
|
count(): Promise<number>;
|
|
403
629
|
countByQuery(query: string): Promise<number>;
|
|
404
630
|
deleteById(id: string): Promise<void>;
|
|
405
631
|
deleteByQuery(query: string): Promise<void>;
|
|
406
|
-
findAll(pageable:
|
|
632
|
+
findAll(pageable: Pageable3): Promise<IterablePage3<T>>;
|
|
407
633
|
findById(id: string): Promise<T>;
|
|
408
634
|
findByIds(ids: string[]): Promise<T[]>;
|
|
409
635
|
namedQuery<U>(queryName: string, queryParameters: QueryParameter[]): Promise<U>;
|
|
410
|
-
namedQueryPage<U>(queryName: string, queryParameters: QueryParameter[], pageable:
|
|
636
|
+
namedQueryPage<U>(queryName: string, queryParameters: QueryParameter[], pageable: Pageable3): Promise<IterablePage3<U>>;
|
|
411
637
|
save(entity: T): Promise<T>;
|
|
412
|
-
search(searchText: string, pageable:
|
|
638
|
+
search(searchText: string, pageable: Pageable3): Promise<IterablePage3<T>>;
|
|
413
639
|
syncIndex(): Promise<void>;
|
|
414
640
|
update(entity: T): Promise<T>;
|
|
415
641
|
protected beforeBulkSaveOrUpdate(entities: T[]): Promise<T[]>;
|
|
416
642
|
protected beforeSaveOrUpdate(entity: T): Promise<T>;
|
|
417
643
|
}
|
|
418
|
-
type IfFunction<
|
|
419
|
-
T,
|
|
420
|
-
U
|
|
421
|
-
> = T extends (...args: any[]) => any ? U : never;
|
|
422
|
-
type MethodsOf<T> = { [K in keyof T] : IfFunction<T[K], K> }[keyof T];
|
|
423
|
-
type ExcludedMethods = "namedQuery" | "namedQueryPage";
|
|
424
|
-
type FilteredMethods<T> = Exclude<MethodsOf<T>, ExcludedMethods>;
|
|
425
|
-
type DecoratedFunction = FilteredMethods<IEntityService<any>> | "allCreate" | "allRead" | "allUpdate" | "allDelete";
|
|
426
|
-
/**
|
|
427
|
-
* Configuration for the {@link EntityServiceDecoratorsDecorator}
|
|
428
|
-
* This is a map of method names to an array of decorators that should be applied to that method
|
|
429
|
-
*/
|
|
430
|
-
type EntityServiceDecoratorsConfig = Partial<Record<DecoratedFunction, EntityServiceDecorator[]>>;
|
|
431
|
-
declare enum KinoticPersistenceDecorator {
|
|
432
|
-
Entity = "__structures-entity__",
|
|
433
|
-
Id = "__structures-id__",
|
|
434
|
-
AutoGeneratedId = "__structures-auto-generated-id__",
|
|
435
|
-
Flattened = "__structures-flattened__",
|
|
436
|
-
Nested = "__structures-nested__",
|
|
437
|
-
Text = "__structures-text__",
|
|
438
|
-
NotNull = "__structures-notnull__",
|
|
439
|
-
Precision = "__structures-precision__",
|
|
440
|
-
Discriminator = "__structures-discriminator__",
|
|
441
|
-
Query = "__structures-query__",
|
|
442
|
-
EntityServiceDecorators = "__structures-entity-service-decorators__"
|
|
443
|
-
}
|
|
444
|
-
/**
|
|
445
|
-
* Signifies that a property is an auto-generated ID for the entity.
|
|
446
|
-
*/
|
|
447
|
-
declare function AutoGeneratedId(target: any, propertyKey: string): void;
|
|
448
|
-
declare class DiscriminatorConfig {
|
|
449
|
-
propertyName: string;
|
|
450
|
-
constructor(propertyName: string);
|
|
451
|
-
}
|
|
452
|
-
/**
|
|
453
|
-
* Signifies that a property is a discriminator for the entity.
|
|
454
|
-
* This is used to determine the type of the entity when deserializing from JSON.
|
|
455
|
-
* @param propertyName the name of the property to use as the discriminator
|
|
456
|
-
*/
|
|
457
|
-
declare function Discriminator(propertyName: string): (target: any, propertyKey: string) => void;
|
|
458
|
-
declare class EntityConfig {
|
|
459
|
-
multiTenancyType: MultiTenancyType;
|
|
460
|
-
entityType: EntityType;
|
|
461
|
-
constructor(multiTenancyType: MultiTenancyType, entityType?: EntityType);
|
|
462
|
-
}
|
|
463
|
-
/**
|
|
464
|
-
* Signifies that a class is a Structures Entity.
|
|
465
|
-
* This is required to define the class as an entity in the Structures framework.
|
|
466
|
-
* @param multiTenancyType the type of multi-tenancy to use for this entity
|
|
467
|
-
* @param entityType the type of entity to use for this entity
|
|
468
|
-
*/
|
|
469
|
-
declare function Entity(multiTenancyType?: MultiTenancyType, entityType?: EntityType): (constructor: Function) => void;
|
|
470
|
-
/**
|
|
471
|
-
* A class Decorator when applied to an Entity will configure Decorators to be applied to the EntityService
|
|
472
|
-
* @param config the {@link EntityServiceDecoratorsConfig} to use
|
|
473
|
-
*/
|
|
474
|
-
declare function EntityServiceDecorators(_config: EntityServiceDecoratorsConfig): (_constructor: Function) => void;
|
|
475
|
-
/**
|
|
476
|
-
* Provides configuration for the Elasticsearch index.
|
|
477
|
-
* This can be used to override the default index settings and mappings used by Structures.
|
|
478
|
-
*/
|
|
479
|
-
declare function EsIndexConfiguration(_value: EsIndexConfigurationData): (_constructor: Function) => void;
|
|
480
|
-
declare function Flattened(target: any, propertyKey: string): void;
|
|
481
|
-
/**
|
|
482
|
-
* Signifies that a property is the ID of the entity.
|
|
483
|
-
*/
|
|
484
|
-
declare function Id(target: any, propertyKey: string): void;
|
|
485
|
-
declare function Nested(target: any, propertyKey: string): void;
|
|
486
|
-
/**
|
|
487
|
-
* Signifies that a property is not indexed in Elasticsearch.
|
|
488
|
-
*/
|
|
489
|
-
declare function NotIndexed(_target: any, _propertyKey: string): void;
|
|
490
|
-
declare function NotNull(target: any, propertyKey: string): void;
|
|
491
|
-
declare function Policy(_policies: string[][]): (_target: any, _propertyKey?: string, _descriptor?: PropertyDescriptor) => void;
|
|
492
|
-
declare class PrecisionConfig {
|
|
493
|
-
precisionType: PrecisionType;
|
|
494
|
-
constructor(precisionType: PrecisionType);
|
|
495
|
-
}
|
|
496
|
-
declare function Precision(precisionType?: PrecisionType): (target: any, propertyKey: string) => void;
|
|
497
|
-
declare function Query(statements: string): (target: any, key: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
498
|
-
declare function Role(_roles: string[]): (_target: any, _propertyKey?: string, _descriptor?: PropertyDescriptor) => void;
|
|
499
|
-
declare function Text(target: any, propertyKey: string): void;
|
|
500
|
-
/**
|
|
501
|
-
* This is used for data streams to signify the field that should be used as the time reference.
|
|
502
|
-
*/
|
|
503
|
-
declare function TimeReference(_target: any, _propertyKey: string): void;
|
|
504
|
-
declare function Version(_target: any, _propertyKey: string): void;
|
|
505
|
-
declare function TenantId(_target: any, _propertyKey: string): void;
|
|
506
|
-
import { C3Decorator as C3Decorator2 } from "@kinotic-ai/idl";
|
|
507
|
-
/**
|
|
508
|
-
* Provides a way to add decorators to an entity service
|
|
509
|
-
*/
|
|
510
|
-
declare class EntityServiceDecoratorsDecorator extends C3Decorator2 {
|
|
511
|
-
config: EntityServiceDecoratorsConfig;
|
|
512
|
-
constructor();
|
|
513
|
-
}
|
|
514
|
-
declare class PolicyDecorator extends EntityServiceDecorator {
|
|
515
|
-
policies: string[][];
|
|
516
|
-
constructor(policies: string[][]);
|
|
517
|
-
}
|
|
518
|
-
/**
|
|
519
|
-
* Provides a mechanism to apply the @Policy decorator to an {@link EntityService}
|
|
520
|
-
* @param policies to be supplied
|
|
521
|
-
*/
|
|
522
|
-
declare function $Policy(policies: string[][]): PolicyDecorator;
|
|
523
|
-
declare class RoleDecorator extends EntityServiceDecorator {
|
|
524
|
-
roles: string[];
|
|
525
|
-
constructor(roles: string[]);
|
|
526
|
-
}
|
|
527
|
-
/**
|
|
528
|
-
* Provides a mechanism to apply the @Role decorator to an {@link EntityService}
|
|
529
|
-
* @param roles to be supplied
|
|
530
|
-
*/
|
|
531
|
-
declare function $Role(roles: string[]): RoleDecorator;
|
|
532
|
-
import { IKinotic as IKinotic2 } from "@kinotic-ai/core";
|
|
533
|
-
import { IServiceProxy as IServiceProxy2, Page as Page2, Pageable as Pageable3, IterablePage as IterablePage3 } from "@kinotic-ai/core";
|
|
534
|
-
type TenantSelection = string[];
|
|
535
|
-
interface IAdminEntitiesService {
|
|
536
|
-
/**
|
|
537
|
-
* Returns the number of entities available.
|
|
538
|
-
* @param structureId the id of the structure to count
|
|
539
|
-
* @param tenantSelection the list of tenants to use when retrieving the entity records
|
|
540
|
-
* @return {@link Promise} emitting the number of entities.
|
|
541
|
-
*/
|
|
542
|
-
count(structureId: string, tenantSelection: TenantSelection): Promise<number>;
|
|
543
|
-
/**
|
|
544
|
-
* Returns the number of entities available for the given query.
|
|
545
|
-
*
|
|
546
|
-
* @param structureId the id of the structure to save the entity for
|
|
547
|
-
* @param query the query used to limit result
|
|
548
|
-
* @param tenantSelection the list of tenants to use when retrieving the entity records
|
|
549
|
-
* @return Promise emitting the number of entities
|
|
550
|
-
*/
|
|
551
|
-
countByQuery(structureId: string, query: string, tenantSelection: TenantSelection): Promise<number>;
|
|
552
|
-
/**
|
|
553
|
-
* Deletes the entity with the given id.
|
|
554
|
-
*
|
|
555
|
-
* @param structureId the id of the structure to save the entity for
|
|
556
|
-
* @param id must not be {@literal null}
|
|
557
|
-
* @return {@link Promise} emitting when delete is complete
|
|
558
|
-
* @throws IllegalArgumentException in case the given {@literal id} is {@literal null}
|
|
559
|
-
*/
|
|
560
|
-
deleteById(structureId: string, id: TenantSpecificId): Promise<void>;
|
|
561
|
-
/**
|
|
562
|
-
* Deletes the entity with the given id.
|
|
563
|
-
*
|
|
564
|
-
* @param structureId the id of the structure to save the entity for
|
|
565
|
-
* @param query the query used to filter records to delete, must not be {@literal null}
|
|
566
|
-
* @param tenantSelection the list of tenants to use when deleting the entity records
|
|
567
|
-
* @return Promise signaling when operation has completed
|
|
568
|
-
* @throws Error in case the given {@literal query} is {@literal null}
|
|
569
|
-
*/
|
|
570
|
-
deleteByQuery(structureId: string, query: string, tenantSelection: TenantSelection): Promise<void>;
|
|
571
|
-
/**
|
|
572
|
-
* Returns a {@link IterablePage} of entities meeting the paging restriction provided in the {@link Pageable} object.
|
|
573
|
-
*
|
|
574
|
-
* @param structureId the id of the structure to save the entity for
|
|
575
|
-
* @param tenantSelection the list of tenants to use when retrieving the entity records
|
|
576
|
-
* @param pageable the page settings to be used
|
|
577
|
-
* @return a page of entities
|
|
578
|
-
*/
|
|
579
|
-
findAll<T>(structureId: string, tenantSelection: TenantSelection, pageable: Pageable3): Promise<IterablePage3<T>>;
|
|
580
|
-
/**
|
|
581
|
-
* Retrieves an entity by its id.
|
|
582
|
-
*
|
|
583
|
-
* @param structureId the id of the structure to save the entity for
|
|
584
|
-
* @param id must not be {@literal null}
|
|
585
|
-
* @return {@link Promise} with the entity with the given id or {@link Promise} emitting null if none found
|
|
586
|
-
* @throws IllegalArgumentException in case the given {@literal id} is {@literal null}
|
|
587
|
-
*/
|
|
588
|
-
findById<T>(structureId: string, id: TenantSpecificId): Promise<T>;
|
|
589
|
-
/**
|
|
590
|
-
* Retrieves a list of entities by their id.
|
|
591
|
-
*
|
|
592
|
-
* @param structureId the id of the structure to save the entity for
|
|
593
|
-
* @param ids must not be {@literal null}
|
|
594
|
-
* @return Promise emitting the entities with the given ids or Promise emitting null if none found
|
|
595
|
-
* @throws Error in case the given {@literal ids} is {@literal null}
|
|
596
|
-
*/
|
|
597
|
-
findByIds<T>(structureId: string, ids: TenantSpecificId[]): Promise<T[]>;
|
|
598
|
-
/**
|
|
599
|
-
* Executes a named query.
|
|
600
|
-
* @param structureId the id of the structure that this named query is defined for
|
|
601
|
-
* @param queryName the name of the function that defines the query
|
|
602
|
-
* @param parameters to pass to the query
|
|
603
|
-
* @returns Promise with the result of the query
|
|
604
|
-
*/
|
|
605
|
-
namedQuery<T>(structureId: string, queryName: string, parameters: QueryParameter[]): Promise<T>;
|
|
606
|
-
/**
|
|
607
|
-
* Executes a named query and returns a Page of results.
|
|
608
|
-
* @param structureId the id of the structure that this named query is defined for
|
|
609
|
-
* @param queryName the name of the function that defines the query
|
|
610
|
-
* @param parameters to pass to the query
|
|
611
|
-
* @param pageable the page settings to be used
|
|
612
|
-
* @returns Promise with the result of the query
|
|
613
|
-
*/
|
|
614
|
-
namedQueryPage<T>(structureId: string, queryName: string, parameters: QueryParameter[], pageable: Pageable3): Promise<IterablePage3<T>>;
|
|
615
|
-
/**
|
|
616
|
-
* Returns a {@link IterablePage} of entities matching the search text and paging restriction provided in the {@link Pageable} object.
|
|
617
|
-
*
|
|
618
|
-
* @param structureId the id of the structure to save the entity for
|
|
619
|
-
* @param searchText the text to search for entities for
|
|
620
|
-
* @param tenantSelection the list of tenants to use when retrieving the entity records
|
|
621
|
-
* @param pageable the page settings to be used
|
|
622
|
-
* @return a page of entities
|
|
623
|
-
*/
|
|
624
|
-
search<T>(structureId: string, searchText: string, tenantSelection: TenantSelection, pageable: Pageable3): Promise<IterablePage3<T>>;
|
|
625
|
-
}
|
|
626
|
-
declare class AdminEntitiesService implements IAdminEntitiesService {
|
|
627
|
-
protected serviceProxy: IServiceProxy2;
|
|
628
|
-
constructor(kinotic: IKinotic2);
|
|
629
|
-
count(structureId: string, tenantSelection: TenantSelection): Promise<number>;
|
|
630
|
-
countByQuery(structureId: string, query: string, tenantSelection: TenantSelection): Promise<number>;
|
|
631
|
-
deleteById(structureId: string, id: TenantSpecificId): Promise<void>;
|
|
632
|
-
deleteByQuery(structureId: string, query: string, tenantSelection: TenantSelection): Promise<void>;
|
|
633
|
-
findAll<T>(structureId: string, tenantSelection: TenantSelection, pageable: Pageable3): Promise<IterablePage3<T>>;
|
|
634
|
-
findAllSinglePage<T>(structureId: string, tenantSelection: TenantSelection, pageable: Pageable3): Promise<Page2<T>>;
|
|
635
|
-
findById<T>(structureId: string, id: TenantSpecificId): Promise<T>;
|
|
636
|
-
findByIds<T>(structureId: string, ids: TenantSpecificId[]): Promise<T[]>;
|
|
637
|
-
namedQuery<T>(structureId: string, queryName: string, parameters: QueryParameter[]): Promise<T>;
|
|
638
|
-
namedQueryPage<T>(structureId: string, queryName: string, parameters: QueryParameter[], pageable: Pageable3): Promise<IterablePage3<T>>;
|
|
639
|
-
namedQuerySinglePage<T>(structureId: string, queryName: string, parameters: QueryParameter[], pageable: Pageable3): Promise<Page2<T>>;
|
|
640
|
-
search<T>(structureId: string, searchText: string, tenantSelection: TenantSelection, pageable: Pageable3): Promise<IterablePage3<T>>;
|
|
641
|
-
searchSinglePage<T>(structureId: string, searchText: string, tenantSelection: TenantSelection, pageable: Pageable3): Promise<Page2<T>>;
|
|
642
|
-
}
|
|
643
644
|
import { Pageable as Pageable4, IterablePage as IterablePage4 } from "@kinotic-ai/core";
|
|
644
645
|
/**
|
|
645
|
-
* This is the base interface for all admin entity
|
|
646
|
+
* This is the base interface for all admin entity repositories.
|
|
646
647
|
* It provides the basic CRUD operations for entities with multi-tenancy support.
|
|
647
648
|
*/
|
|
648
|
-
interface
|
|
649
|
+
interface IAdminEntityRepository<T> {
|
|
649
650
|
/**
|
|
650
|
-
* The application id of the Entity this
|
|
651
|
+
* The application id of the Entity this repository is for
|
|
651
652
|
*/
|
|
652
653
|
entityApplicationId: string;
|
|
653
654
|
/**
|
|
654
|
-
* The name of the Entity this
|
|
655
|
+
* The name of the Entity this repository is for
|
|
655
656
|
*/
|
|
656
657
|
entityName: string;
|
|
657
658
|
/**
|
|
658
|
-
* The id of the Entity this
|
|
659
|
+
* The id of the Entity this repository is for
|
|
659
660
|
* Which is the applicationId + '.' + name
|
|
660
661
|
*/
|
|
661
662
|
entityId: string;
|
|
@@ -741,15 +742,15 @@ interface IAdminEntityService<T> {
|
|
|
741
742
|
search(searchText: string, tenantSelection: TenantSelection, pageable: Pageable4): Promise<IterablePage4<T>>;
|
|
742
743
|
}
|
|
743
744
|
/**
|
|
744
|
-
* This is the base class for all admin entity
|
|
745
|
+
* This is the base class for all admin entity repositories.
|
|
745
746
|
* It provides the basic CRUD operations for entities with multi-tenancy support.
|
|
746
747
|
*/
|
|
747
|
-
declare class
|
|
748
|
+
declare class AdminEntityRepository<T> implements IAdminEntityRepository<T> {
|
|
748
749
|
entityApplicationId: string;
|
|
749
750
|
entityName: string;
|
|
750
751
|
entityId: string;
|
|
751
|
-
private readonly
|
|
752
|
-
constructor(structureApplicationId: string, structureName: string,
|
|
752
|
+
private readonly adminEntitiesRepository;
|
|
753
|
+
constructor(structureApplicationId: string, structureName: string, adminEntitiesRepository?: IAdminEntitiesRepository);
|
|
753
754
|
count(tenantSelection: TenantSelection): Promise<number>;
|
|
754
755
|
countByQuery(query: string, tenantSelection: TenantSelection): Promise<number>;
|
|
755
756
|
deleteById(id: TenantSpecificId): Promise<void>;
|
|
@@ -763,11 +764,11 @@ declare class AdminEntityService<T> implements IAdminEntityService<T> {
|
|
|
763
764
|
}
|
|
764
765
|
import { KinoticPlugin } from "@kinotic-ai/core";
|
|
765
766
|
interface IPersistenceExtension {
|
|
766
|
-
entities:
|
|
767
|
-
adminEntities:
|
|
767
|
+
entities: IEntitiesRepository;
|
|
768
|
+
adminEntities: IAdminEntitiesRepository;
|
|
768
769
|
}
|
|
769
770
|
declare const PersistencePlugin: KinoticPlugin<IPersistenceExtension>;
|
|
770
771
|
declare module "@kinotic-ai/core" {
|
|
771
772
|
interface KinoticSingleton extends IPersistenceExtension {}
|
|
772
773
|
}
|
|
773
|
-
export { Version, TimeReference, Text, TenantSpecificId, TenantSelection, TenantId, RoleDecorator, Role, QueryParameter, QueryOptions, Query, PrecisionType, PrecisionConfig, Precision, PolicyDecorator, Policy, PersistencePlugin, NotNull, NotIndexed, Nested, MultiTenancyType, KinoticPersistenceDecorator, Id, IPersistenceExtension,
|
|
774
|
+
export { Version, TimeReference, Text, TenantSpecificId, TenantSelection, TenantId, RoleDecorator, Role, QueryParameter, QueryOptions, Query, PrecisionType, PrecisionConfig, Precision, PolicyDecorator, Policy, PersistencePlugin, NotNull, NotIndexed, Nested, MultiTenancyType, KinoticPersistenceDecorator, Id, IPersistenceExtension, IEntityRepository, IEntitiesRepository, IAdminEntityRepository, IAdminEntitiesRepository, Flattened, EsIndexConfigurationData, EsIndexConfiguration, EntityType, EntityServiceDecoratorsDecorator, EntityServiceDecoratorsConfig, EntityServiceDecorators, EntityServiceDecorator, EntityRepository, EntityConfig, Entity, EntitiesRepository, DiscriminatorConfig, Discriminator, DecoratedFunction, AutoGeneratedId, AdminEntityRepository, AdminEntitiesRepository, $Role, $Policy };
|