@kinotic-ai/persistence 5.0.0-beta.12 → 5.0.0-beta.13

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 CHANGED
@@ -45,14 +45,10 @@ __export(exports_src, {
45
45
  Text: () => Text,
46
46
  TenantSpecificId: () => TenantSpecificId,
47
47
  TenantId: () => TenantId,
48
- RoleDecorator: () => RoleDecorator,
49
- Role: () => Role,
50
48
  QueryOptions: () => QueryOptions,
51
49
  Query: () => Query,
52
50
  PrecisionType: () => PrecisionType,
53
51
  Precision: () => Precision,
54
- PolicyDecorator: () => PolicyDecorator,
55
- Policy: () => Policy,
56
52
  PersistencePlugin: () => PersistencePlugin,
57
53
  NotNull: () => NotNull,
58
54
  NotIndexed: () => NotIndexed,
@@ -63,9 +59,6 @@ __export(exports_src, {
63
59
  EsIndexConfigurationData: () => EsIndexConfigurationData,
64
60
  EsIndexConfiguration: () => EsIndexConfiguration,
65
61
  EntityType: () => EntityType,
66
- EntityServiceDecoratorsDecorator: () => EntityServiceDecoratorsDecorator,
67
- EntityServiceDecorators: () => EntityServiceDecorators,
68
- EntityServiceDecorator: () => EntityServiceDecorator,
69
62
  EntityRepository: () => EntityRepository,
70
63
  Entity: () => Entity,
71
64
  EntitiesRepository: () => EntitiesRepository,
@@ -74,9 +67,7 @@ __export(exports_src, {
74
67
  AutoGeneratedId: () => AutoGeneratedId,
75
68
  AdminEntityRepository: () => AdminEntityRepository,
76
69
  AdminEntitiesRepository: () => AdminEntitiesRepository,
77
- APP_API_ZONE: () => APP_API_ZONE,
78
- $Role: () => $Role,
79
- $Policy: () => $Policy
70
+ APP_API_ZONE: () => APP_API_ZONE
80
71
  });
81
72
  module.exports = __toCommonJS(exports_src);
82
73
 
@@ -128,9 +119,6 @@ function Discriminator(_propertyName) {
128
119
  function Entity(_multiTenancyType = 0 /* NONE */, _entityType = 0 /* TABLE */) {
129
120
  return function(_value, _context) {};
130
121
  }
131
- function EntityServiceDecorators(_config) {
132
- return function(_value, _context) {};
133
- }
134
122
  function EsIndexConfiguration(_value) {
135
123
  return function(_target, _context) {};
136
124
  }
@@ -139,65 +127,20 @@ function Id(_value, _context) {}
139
127
  function Nested(_value, _context) {}
140
128
  function NotIndexed(_value, _context) {}
141
129
  function NotNull(_value, _context) {}
142
- function Policy(_policies) {
143
- return function(_value, _context) {};
144
- }
145
130
  function Precision(_precisionType = 2 /* INT */) {
146
131
  return function(_value, _context) {};
147
132
  }
148
133
  function Query(_statements) {
149
134
  return function(_value, _context) {};
150
135
  }
151
- function Role(_roles) {
152
- return function(_value, _context) {};
153
- }
154
136
  function Text(_value, _context) {}
155
137
  function TimeReference(_value, _context) {}
156
138
  function Version(_value, _context) {}
157
139
  function TenantId(_value, _context) {}
158
- // packages/persistence/src/api/idl/EntityServiceDecorator.ts
159
- var import_idl = require("@kinotic-ai/idl");
160
-
161
- class EntityServiceDecorator extends import_idl.C3Decorator {
162
- }
163
- // packages/persistence/src/api/idl/EntityServiceDecoratorsDecorator.ts
164
- var import_idl2 = require("@kinotic-ai/idl");
165
-
166
- class EntityServiceDecoratorsDecorator extends import_idl2.C3Decorator {
167
- config;
168
- constructor() {
169
- super();
170
- this.type = "EntityServiceDecoratorsDecorator";
171
- }
172
- }
173
140
  // packages/persistence/src/api/idl/EsIndexConfigurationData.ts
174
141
  class EsIndexConfigurationData {
175
142
  componentTemplates = [];
176
143
  }
177
- // packages/persistence/src/api/idl/PolicyDecorator.ts
178
- class PolicyDecorator extends EntityServiceDecorator {
179
- policies;
180
- constructor(policies) {
181
- super();
182
- this.type = "PolicyDecorator";
183
- this.policies = policies;
184
- }
185
- }
186
- function $Policy(policies) {
187
- return new PolicyDecorator(policies);
188
- }
189
- // packages/persistence/src/api/idl/RoleDecorator.ts
190
- class RoleDecorator extends EntityServiceDecorator {
191
- roles;
192
- constructor(roles) {
193
- super();
194
- this.type = "RoleDecorator";
195
- this.roles = roles;
196
- }
197
- }
198
- function $Role(roles) {
199
- return new RoleDecorator(roles);
200
- }
201
144
  // packages/persistence/src/api/IEntitiesRepository.ts
202
145
  var import_core = require("@kinotic-ai/core");
203
146
  var APP_API_ZONE = "app-api";
package/dist/index.d.cts CHANGED
@@ -61,7 +61,7 @@ declare enum MultiTenancyType {
61
61
  SHARED = 1
62
62
  }
63
63
  /**
64
- * The {@link PrecisionType} enum is used to define the precision of a numeric field in the Continuum IDL.
64
+ * The {@link PrecisionType} enum is used to define the precision of a numeric field in the Kinotic IDL.
65
65
  */
66
66
  declare enum PrecisionType {
67
67
  /**
@@ -85,12 +85,53 @@ declare enum PrecisionType {
85
85
  */
86
86
  SHORT = 4
87
87
  }
88
- import { C3Decorator } from "@kinotic-ai/idl";
89
88
  /**
90
- * This class denotes {@link C3Decorator} that can be applied to an {@link EntityService} using the {@link EntityServiceDecoratorsDecorator}
89
+ * Signifies that a property is an auto-generated ID for the entity.
90
+ */
91
+ declare function AutoGeneratedId(_value: undefined, _context: ClassFieldDecoratorContext): void;
92
+ /**
93
+ * Signifies that a property holds a date, which is stored and queried as a date.
94
+ * The property is a string, or an array of strings, holding ISO-8601 dates such as `Date.prototype.toISOString()` returns.
95
+ */
96
+ declare function DateTime(_value: undefined, _context: ClassFieldDecoratorContext<unknown, string | readonly string[] | null | undefined>): void;
97
+ /**
98
+ * Signifies that a property is a discriminator for the entity.
99
+ * This is used to determine the type of the entity when deserializing from JSON.
100
+ * @param propertyName the name of the property to use as the discriminator
101
+ */
102
+ declare function Discriminator(_propertyName: string): (_value: undefined, _context: ClassFieldDecoratorContext) => void;
103
+ /**
104
+ * Signifies that a class is a Entity.
105
+ * This is required to define the class as an entity in the Kinotic framework.
106
+ * @param multiTenancyType the type of multi-tenancy to use for this entity
107
+ * @param entityType the type of entity to use for this entity
108
+ */
109
+ declare function Entity(_multiTenancyType?: MultiTenancyType, _entityType?: EntityType): (_value: Function, _context: ClassDecoratorContext<any>) => void;
110
+ /**
111
+ * Provides configuration for the Elasticsearch index.
112
+ * This can be used to override the default index settings and mappings used by Kinotic.
113
+ */
114
+ declare function EsIndexConfiguration(_value: EsIndexConfigurationData): (_target: Function, _context: ClassDecoratorContext<any>) => void;
115
+ declare function Flattened(_value: undefined, _context: ClassFieldDecoratorContext): void;
116
+ /**
117
+ * Signifies that a property is the ID of the entity.
118
+ */
119
+ declare function Id(_value: undefined, _context: ClassFieldDecoratorContext): void;
120
+ declare function Nested(_value: undefined, _context: ClassFieldDecoratorContext): void;
121
+ /**
122
+ * Signifies that a property is not indexed in Elasticsearch.
123
+ */
124
+ declare function NotIndexed(_value: undefined, _context: ClassFieldDecoratorContext): void;
125
+ declare function NotNull(_value: undefined, _context: ClassFieldDecoratorContext): void;
126
+ declare function Precision(_precisionType?: PrecisionType): (_value: undefined, _context: ClassFieldDecoratorContext) => void;
127
+ declare function Query(_statements: string): (_value: Function, _context: ClassMethodDecoratorContext) => void;
128
+ declare function Text(_value: undefined, _context: ClassFieldDecoratorContext): void;
129
+ /**
130
+ * This is used for data streams to signify the field that should be used as the time reference.
91
131
  */
92
- declare abstract class EntityServiceDecorator extends C3Decorator {}
93
- import { Pageable as Pageable2, IterablePage as IterablePage2 } from "@kinotic-ai/core";
132
+ declare function TimeReference(_value: undefined, _context: ClassFieldDecoratorContext): void;
133
+ declare function Version(_value: undefined, _context: ClassFieldDecoratorContext): void;
134
+ declare function TenantId(_value: undefined, _context: ClassFieldDecoratorContext): void;
94
135
  import { IKinotic } from "@kinotic-ai/core";
95
136
  import { IServiceProxy, Page, Pageable, IterablePage } from "@kinotic-ai/core";
96
137
  /**
@@ -262,6 +303,120 @@ declare class EntitiesRepository implements IEntitiesRepository {
262
303
  syncIndex(entityDefinitionId: string): Promise<void>;
263
304
  update<T>(entityDefinitionId: string, entity: T): Promise<T>;
264
305
  }
306
+ import { IKinotic as IKinotic2 } from "@kinotic-ai/core";
307
+ import { IServiceProxy as IServiceProxy2, Page as Page2, Pageable as Pageable2, IterablePage as IterablePage2 } from "@kinotic-ai/core";
308
+ type TenantSelection = string[];
309
+ interface IAdminEntitiesRepository {
310
+ /**
311
+ * Returns the number of entities available.
312
+ * @param structureId the id of the structure to count
313
+ * @param tenantSelection the list of tenants to use when retrieving the entity records
314
+ * @return {@link Promise} emitting the number of entities.
315
+ */
316
+ count(entityDefinitionId: string, tenantSelection: TenantSelection): Promise<number>;
317
+ /**
318
+ * Returns the number of entities available for the given query.
319
+ *
320
+ * @param entityDefinitionId the id of the structure to save the entity for
321
+ * @param query the query used to limit result
322
+ * @param tenantSelection the list of tenants to use when retrieving the entity records
323
+ * @return Promise emitting the number of entities
324
+ */
325
+ countByQuery(entityDefinitionId: string, query: string, tenantSelection: TenantSelection): Promise<number>;
326
+ /**
327
+ * Deletes the entity with the given id.
328
+ *
329
+ * @param entityDefinitionId the id of the structure to save the entity for
330
+ * @param id must not be {@literal null}
331
+ * @return {@link Promise} emitting when delete is complete
332
+ * @throws IllegalArgumentException in case the given {@literal id} is {@literal null}
333
+ */
334
+ deleteById(entityDefinitionId: string, id: TenantSpecificId): Promise<void>;
335
+ /**
336
+ * Deletes the entity with the given id.
337
+ *
338
+ * @param entityDefinitionId the id of the structure to save the entity for
339
+ * @param query the query used to filter records to delete, must not be {@literal null}
340
+ * @param tenantSelection the list of tenants to use when deleting the entity records
341
+ * @return Promise signaling when operation has completed
342
+ * @throws Error in case the given {@literal query} is {@literal null}
343
+ */
344
+ deleteByQuery(entityDefinitionId: string, query: string, tenantSelection: TenantSelection): Promise<void>;
345
+ /**
346
+ * Returns a {@link IterablePage} of entities meeting the paging restriction provided in the {@link Pageable} object.
347
+ *
348
+ * @param entityDefinitionId the id of the structure to save the entity for
349
+ * @param tenantSelection the list of tenants to use when retrieving the entity records
350
+ * @param pageable the page settings to be used
351
+ * @return a page of entities
352
+ */
353
+ findAll<T>(entityDefinitionId: string, tenantSelection: TenantSelection, pageable: Pageable2): Promise<IterablePage2<T>>;
354
+ /**
355
+ * Retrieves an entity by its id.
356
+ *
357
+ * @param entityDefinitionId the id of the structure to save the entity for
358
+ * @param id must not be {@literal null}
359
+ * @return {@link Promise} with the entity with the given id or {@link Promise} emitting null if none found
360
+ * @throws IllegalArgumentException in case the given {@literal id} is {@literal null}
361
+ */
362
+ findById<T>(entityDefinitionId: string, id: TenantSpecificId): Promise<T | null>;
363
+ /**
364
+ * Retrieves a list of entities by their id.
365
+ *
366
+ * @param entityDefinitionId the id of the structure to save the entity for
367
+ * @param ids must not be {@literal null}
368
+ * @return Promise emitting the entities with the given ids or Promise emitting null if none found
369
+ * @throws Error in case the given {@literal ids} is {@literal null}
370
+ */
371
+ findByIds<T>(entityDefinitionId: string, ids: TenantSpecificId[]): Promise<T[]>;
372
+ /**
373
+ * Executes a named query.
374
+ * @param entityDefinitionId the id of the structure that this named query is defined for
375
+ * @param queryName the name of the function that defines the query
376
+ * @param parameters to pass to the query
377
+ * @param tenantSelection the list of tenants to use when executing the query
378
+ * @returns Promise with the result of the query
379
+ */
380
+ namedQuery<T>(entityDefinitionId: string, queryName: string, parameters: QueryParameter[], tenantSelection: TenantSelection): Promise<T>;
381
+ /**
382
+ * Executes a named query and returns a Page of results.
383
+ * @param entityDefinitionId the id of the structure that this named query is defined for
384
+ * @param queryName the name of the function that defines the query
385
+ * @param parameters to pass to the query
386
+ * @param tenantSelection the list of tenants to use when executing the query
387
+ * @param pageable the page settings to be used
388
+ * @returns Promise with the result of the query
389
+ */
390
+ namedQueryPage<T>(entityDefinitionId: string, queryName: string, parameters: QueryParameter[], tenantSelection: TenantSelection, pageable: Pageable2): Promise<IterablePage2<T>>;
391
+ /**
392
+ * Returns a {@link IterablePage} of entities matching the search text and paging restriction provided in the {@link Pageable} object.
393
+ *
394
+ * @param entityDefinitionId the id of the structure to save the entity for
395
+ * @param searchText the text to search for entities for
396
+ * @param tenantSelection the list of tenants to use when retrieving the entity records
397
+ * @param pageable the page settings to be used
398
+ * @return a page of entities
399
+ */
400
+ search<T>(entityDefinitionId: string, searchText: string, tenantSelection: TenantSelection, pageable: Pageable2): Promise<IterablePage2<T>>;
401
+ }
402
+ declare class AdminEntitiesRepository implements IAdminEntitiesRepository {
403
+ protected serviceProxy: IServiceProxy2;
404
+ constructor(kinotic: IKinotic2);
405
+ count(entityDefinitionId: string, tenantSelection: TenantSelection): Promise<number>;
406
+ countByQuery(entityDefinitionId: string, query: string, tenantSelection: TenantSelection): Promise<number>;
407
+ deleteById(entityDefinitionId: string, id: TenantSpecificId): Promise<void>;
408
+ deleteByQuery(entityDefinitionId: string, query: string, tenantSelection: TenantSelection): Promise<void>;
409
+ findAll<T>(entityDefinitionId: string, tenantSelection: TenantSelection, pageable: Pageable2): Promise<IterablePage2<T>>;
410
+ findAllSinglePage<T>(entityDefinitionId: string, tenantSelection: TenantSelection, pageable: Pageable2): Promise<Page2<T>>;
411
+ findById<T>(entityDefinitionId: string, id: TenantSpecificId): Promise<T>;
412
+ findByIds<T>(entityDefinitionId: string, ids: TenantSpecificId[]): Promise<T[]>;
413
+ namedQuery<T>(entityDefinitionId: string, queryName: string, parameters: QueryParameter[], tenantSelection: TenantSelection): Promise<T>;
414
+ namedQueryPage<T>(entityDefinitionId: string, queryName: string, parameters: QueryParameter[], tenantSelection: TenantSelection, pageable: Pageable2): Promise<IterablePage2<T>>;
415
+ namedQuerySinglePage<T>(entityDefinitionId: string, queryName: string, parameters: QueryParameter[], tenantSelection: TenantSelection, pageable: Pageable2): Promise<Page2<T>>;
416
+ search<T>(entityDefinitionId: string, searchText: string, tenantSelection: TenantSelection, pageable: Pageable2): Promise<IterablePage2<T>>;
417
+ searchSinglePage<T>(entityDefinitionId: string, searchText: string, tenantSelection: TenantSelection, pageable: Pageable2): Promise<Page2<T>>;
418
+ }
419
+ import { Pageable as Pageable3, IterablePage as IterablePage3 } from "@kinotic-ai/core";
265
420
  /**
266
421
  * This is the base interface for all entity repositories.
267
422
  * It provides the basic CRUD operations for entities.
@@ -331,7 +486,7 @@ interface IEntityRepository<T> {
331
486
  * @param pageable the page settings to be used
332
487
  * @return a page of entities
333
488
  */
334
- findAll(pageable: Pageable2): Promise<IterablePage2<T>>;
489
+ findAll(pageable: Pageable3): Promise<IterablePage3<T>>;
335
490
  /**
336
491
  * Retrieves an entity by its id.
337
492
  *
@@ -362,7 +517,7 @@ interface IEntityRepository<T> {
362
517
  * @param pageable the page settings to be used
363
518
  * @returns Promise with the result of the query
364
519
  */
365
- namedQueryPage<U>(queryName: string, queryParameters: QueryParameter[], pageable: Pageable2): Promise<IterablePage2<U>>;
520
+ namedQueryPage<U>(queryName: string, queryParameters: QueryParameter[], pageable: Pageable3): Promise<IterablePage3<U>>;
366
521
  /**
367
522
  * Saves a given entity. This will override all data if there is an existing entity with the same id.
368
523
  * Use the returned instance for further operations as the save operation might have changed the entity instance.
@@ -379,7 +534,7 @@ interface IEntityRepository<T> {
379
534
  * @param pageable the page settings to be used
380
535
  * @return a page of entities
381
536
  */
382
- search(searchText: string, pageable: Pageable2): Promise<IterablePage2<T>>;
537
+ search(searchText: string, pageable: Pageable3): Promise<IterablePage3<T>>;
383
538
  /**
384
539
  * This operation makes all the recent writes immediately available for search.
385
540
  * @return a Promise that resolves when the operation is complete
@@ -413,224 +568,18 @@ declare class EntityRepository<T> implements IEntityRepository<T> {
413
568
  countByQuery(query: string): Promise<number>;
414
569
  deleteById(id: string): Promise<void>;
415
570
  deleteByQuery(query: string): Promise<void>;
416
- findAll(pageable: Pageable2): Promise<IterablePage2<T>>;
571
+ findAll(pageable: Pageable3): Promise<IterablePage3<T>>;
417
572
  findById(id: string): Promise<T | null>;
418
573
  findByIds(ids: string[]): Promise<T[]>;
419
574
  namedQuery<U>(queryName: string, queryParameters: QueryParameter[]): Promise<U>;
420
- namedQueryPage<U>(queryName: string, queryParameters: QueryParameter[], pageable: Pageable2): Promise<IterablePage2<U>>;
575
+ namedQueryPage<U>(queryName: string, queryParameters: QueryParameter[], pageable: Pageable3): Promise<IterablePage3<U>>;
421
576
  save(entity: T): Promise<T>;
422
- search(searchText: string, pageable: Pageable2): Promise<IterablePage2<T>>;
577
+ search(searchText: string, pageable: Pageable3): Promise<IterablePage3<T>>;
423
578
  syncIndex(): Promise<void>;
424
579
  update(entity: T): Promise<T>;
425
580
  protected beforeBulkSaveOrUpdate(entities: T[]): Promise<T[]>;
426
581
  protected beforeSaveOrUpdate(entity: T): Promise<T>;
427
582
  }
428
- type IfFunction<
429
- T,
430
- U
431
- > = T extends (...args: any[]) => any ? U : never;
432
- type MethodsOf<T> = { [K in keyof T] : IfFunction<T[K], K> }[keyof T];
433
- type ExcludedMethods = "namedQuery" | "namedQueryPage";
434
- type FilteredMethods<T> = Exclude<MethodsOf<T>, ExcludedMethods>;
435
- type DecoratedFunction = FilteredMethods<IEntityRepository<any>> | "allCreate" | "allRead" | "allUpdate" | "allDelete";
436
- /**
437
- * Configuration for the {@link EntityServiceDecoratorsDecorator}
438
- * This is a map of method names to an array of decorators that should be applied to that method
439
- */
440
- type EntityServiceDecoratorsConfig = Partial<Record<DecoratedFunction, EntityServiceDecorator[]>>;
441
- /**
442
- * Signifies that a property is an auto-generated ID for the entity.
443
- */
444
- declare function AutoGeneratedId(_value: undefined, _context: ClassFieldDecoratorContext): void;
445
- /**
446
- * Signifies that a property holds a date, which is stored and queried as a date.
447
- * The property is a string, or an array of strings, holding ISO-8601 dates such as `Date.prototype.toISOString()` returns.
448
- */
449
- declare function DateTime(_value: undefined, _context: ClassFieldDecoratorContext<unknown, string | readonly string[] | null | undefined>): void;
450
- /**
451
- * Signifies that a property is a discriminator for the entity.
452
- * This is used to determine the type of the entity when deserializing from JSON.
453
- * @param propertyName the name of the property to use as the discriminator
454
- */
455
- declare function Discriminator(_propertyName: string): (_value: undefined, _context: ClassFieldDecoratorContext) => void;
456
- /**
457
- * Signifies that a class is a Entity.
458
- * This is required to define the class as an entity in the Kinotic framework.
459
- * @param multiTenancyType the type of multi-tenancy to use for this entity
460
- * @param entityType the type of entity to use for this entity
461
- */
462
- declare function Entity(_multiTenancyType?: MultiTenancyType, _entityType?: EntityType): (_value: Function, _context: ClassDecoratorContext<any>) => void;
463
- /**
464
- * A class Decorator when applied to an Entity will configure Decorators to be applied to the EntityService
465
- * @param config the {@link EntityServiceDecoratorsConfig} to use
466
- */
467
- declare function EntityServiceDecorators(_config: EntityServiceDecoratorsConfig): (_value: Function, _context: ClassDecoratorContext<any>) => void;
468
- /**
469
- * Provides configuration for the Elasticsearch index.
470
- * This can be used to override the default index settings and mappings used by Kinotic.
471
- */
472
- declare function EsIndexConfiguration(_value: EsIndexConfigurationData): (_target: Function, _context: ClassDecoratorContext<any>) => void;
473
- declare function Flattened(_value: undefined, _context: ClassFieldDecoratorContext): void;
474
- /**
475
- * Signifies that a property is the ID of the entity.
476
- */
477
- declare function Id(_value: undefined, _context: ClassFieldDecoratorContext): void;
478
- declare function Nested(_value: undefined, _context: ClassFieldDecoratorContext): void;
479
- /**
480
- * Signifies that a property is not indexed in Elasticsearch.
481
- */
482
- declare function NotIndexed(_value: undefined, _context: ClassFieldDecoratorContext): void;
483
- declare function NotNull(_value: undefined, _context: ClassFieldDecoratorContext): void;
484
- declare function Policy(_policies: string[][]): (_value: unknown, _context: ClassDecoratorContext<any> | ClassFieldDecoratorContext | ClassMethodDecoratorContext) => void;
485
- declare function Precision(_precisionType?: PrecisionType): (_value: undefined, _context: ClassFieldDecoratorContext) => void;
486
- declare function Query(_statements: string): (_value: Function, _context: ClassMethodDecoratorContext) => void;
487
- declare function Role(_roles: string[]): (_value: unknown, _context: ClassDecoratorContext<any> | ClassFieldDecoratorContext | ClassMethodDecoratorContext) => void;
488
- declare function Text(_value: undefined, _context: ClassFieldDecoratorContext): void;
489
- /**
490
- * This is used for data streams to signify the field that should be used as the time reference.
491
- */
492
- declare function TimeReference(_value: undefined, _context: ClassFieldDecoratorContext): void;
493
- declare function Version(_value: undefined, _context: ClassFieldDecoratorContext): void;
494
- declare function TenantId(_value: undefined, _context: ClassFieldDecoratorContext): void;
495
- import { C3Decorator as C3Decorator2 } from "@kinotic-ai/idl";
496
- /**
497
- * Provides a way to add decorators to an entity service
498
- */
499
- declare class EntityServiceDecoratorsDecorator extends C3Decorator2 {
500
- config: EntityServiceDecoratorsConfig;
501
- constructor();
502
- }
503
- declare class PolicyDecorator extends EntityServiceDecorator {
504
- policies: string[][];
505
- constructor(policies: string[][]);
506
- }
507
- /**
508
- * Provides a mechanism to apply the @Policy decorator to an {@link EntityService}
509
- * @param policies to be supplied
510
- */
511
- declare function $Policy(policies: string[][]): PolicyDecorator;
512
- declare class RoleDecorator extends EntityServiceDecorator {
513
- roles: string[];
514
- constructor(roles: string[]);
515
- }
516
- /**
517
- * Provides a mechanism to apply the @Role decorator to an {@link EntityService}
518
- * @param roles to be supplied
519
- */
520
- declare function $Role(roles: string[]): RoleDecorator;
521
- import { IKinotic as IKinotic2 } from "@kinotic-ai/core";
522
- import { IServiceProxy as IServiceProxy2, Page as Page2, Pageable as Pageable3, IterablePage as IterablePage3 } from "@kinotic-ai/core";
523
- type TenantSelection = string[];
524
- interface IAdminEntitiesRepository {
525
- /**
526
- * Returns the number of entities available.
527
- * @param structureId the id of the structure to count
528
- * @param tenantSelection the list of tenants to use when retrieving the entity records
529
- * @return {@link Promise} emitting the number of entities.
530
- */
531
- count(entityDefinitionId: string, tenantSelection: TenantSelection): Promise<number>;
532
- /**
533
- * Returns the number of entities available for the given query.
534
- *
535
- * @param entityDefinitionId the id of the structure to save the entity for
536
- * @param query the query used to limit result
537
- * @param tenantSelection the list of tenants to use when retrieving the entity records
538
- * @return Promise emitting the number of entities
539
- */
540
- countByQuery(entityDefinitionId: string, query: string, tenantSelection: TenantSelection): Promise<number>;
541
- /**
542
- * Deletes the entity with the given id.
543
- *
544
- * @param entityDefinitionId the id of the structure to save the entity for
545
- * @param id must not be {@literal null}
546
- * @return {@link Promise} emitting when delete is complete
547
- * @throws IllegalArgumentException in case the given {@literal id} is {@literal null}
548
- */
549
- deleteById(entityDefinitionId: string, id: TenantSpecificId): Promise<void>;
550
- /**
551
- * Deletes the entity with the given id.
552
- *
553
- * @param entityDefinitionId the id of the structure to save the entity for
554
- * @param query the query used to filter records to delete, must not be {@literal null}
555
- * @param tenantSelection the list of tenants to use when deleting the entity records
556
- * @return Promise signaling when operation has completed
557
- * @throws Error in case the given {@literal query} is {@literal null}
558
- */
559
- deleteByQuery(entityDefinitionId: string, query: string, tenantSelection: TenantSelection): Promise<void>;
560
- /**
561
- * Returns a {@link IterablePage} of entities meeting the paging restriction provided in the {@link Pageable} object.
562
- *
563
- * @param entityDefinitionId the id of the structure to save the entity for
564
- * @param tenantSelection the list of tenants to use when retrieving the entity records
565
- * @param pageable the page settings to be used
566
- * @return a page of entities
567
- */
568
- findAll<T>(entityDefinitionId: string, tenantSelection: TenantSelection, pageable: Pageable3): Promise<IterablePage3<T>>;
569
- /**
570
- * Retrieves an entity by its id.
571
- *
572
- * @param entityDefinitionId the id of the structure to save the entity for
573
- * @param id must not be {@literal null}
574
- * @return {@link Promise} with the entity with the given id or {@link Promise} emitting null if none found
575
- * @throws IllegalArgumentException in case the given {@literal id} is {@literal null}
576
- */
577
- findById<T>(entityDefinitionId: string, id: TenantSpecificId): Promise<T | null>;
578
- /**
579
- * Retrieves a list of entities by their id.
580
- *
581
- * @param entityDefinitionId the id of the structure to save the entity for
582
- * @param ids must not be {@literal null}
583
- * @return Promise emitting the entities with the given ids or Promise emitting null if none found
584
- * @throws Error in case the given {@literal ids} is {@literal null}
585
- */
586
- findByIds<T>(entityDefinitionId: string, ids: TenantSpecificId[]): Promise<T[]>;
587
- /**
588
- * Executes a named query.
589
- * @param entityDefinitionId the id of the structure that this named query is defined for
590
- * @param queryName the name of the function that defines the query
591
- * @param parameters to pass to the query
592
- * @param tenantSelection the list of tenants to use when executing the query
593
- * @returns Promise with the result of the query
594
- */
595
- namedQuery<T>(entityDefinitionId: string, queryName: string, parameters: QueryParameter[], tenantSelection: TenantSelection): Promise<T>;
596
- /**
597
- * Executes a named query and returns a Page of results.
598
- * @param entityDefinitionId the id of the structure that this named query is defined for
599
- * @param queryName the name of the function that defines the query
600
- * @param parameters to pass to the query
601
- * @param tenantSelection the list of tenants to use when executing the query
602
- * @param pageable the page settings to be used
603
- * @returns Promise with the result of the query
604
- */
605
- namedQueryPage<T>(entityDefinitionId: string, queryName: string, parameters: QueryParameter[], tenantSelection: TenantSelection, pageable: Pageable3): Promise<IterablePage3<T>>;
606
- /**
607
- * Returns a {@link IterablePage} of entities matching the search text and paging restriction provided in the {@link Pageable} object.
608
- *
609
- * @param entityDefinitionId the id of the structure to save the entity for
610
- * @param searchText the text to search for entities for
611
- * @param tenantSelection the list of tenants to use when retrieving the entity records
612
- * @param pageable the page settings to be used
613
- * @return a page of entities
614
- */
615
- search<T>(entityDefinitionId: string, searchText: string, tenantSelection: TenantSelection, pageable: Pageable3): Promise<IterablePage3<T>>;
616
- }
617
- declare class AdminEntitiesRepository implements IAdminEntitiesRepository {
618
- protected serviceProxy: IServiceProxy2;
619
- constructor(kinotic: IKinotic2);
620
- count(entityDefinitionId: string, tenantSelection: TenantSelection): Promise<number>;
621
- countByQuery(entityDefinitionId: string, query: string, tenantSelection: TenantSelection): Promise<number>;
622
- deleteById(entityDefinitionId: string, id: TenantSpecificId): Promise<void>;
623
- deleteByQuery(entityDefinitionId: string, query: string, tenantSelection: TenantSelection): Promise<void>;
624
- findAll<T>(entityDefinitionId: string, tenantSelection: TenantSelection, pageable: Pageable3): Promise<IterablePage3<T>>;
625
- findAllSinglePage<T>(entityDefinitionId: string, tenantSelection: TenantSelection, pageable: Pageable3): Promise<Page2<T>>;
626
- findById<T>(entityDefinitionId: string, id: TenantSpecificId): Promise<T>;
627
- findByIds<T>(entityDefinitionId: string, ids: TenantSpecificId[]): Promise<T[]>;
628
- namedQuery<T>(entityDefinitionId: string, queryName: string, parameters: QueryParameter[], tenantSelection: TenantSelection): Promise<T>;
629
- namedQueryPage<T>(entityDefinitionId: string, queryName: string, parameters: QueryParameter[], tenantSelection: TenantSelection, pageable: Pageable3): Promise<IterablePage3<T>>;
630
- namedQuerySinglePage<T>(entityDefinitionId: string, queryName: string, parameters: QueryParameter[], tenantSelection: TenantSelection, pageable: Pageable3): Promise<Page2<T>>;
631
- search<T>(entityDefinitionId: string, searchText: string, tenantSelection: TenantSelection, pageable: Pageable3): Promise<IterablePage3<T>>;
632
- searchSinglePage<T>(entityDefinitionId: string, searchText: string, tenantSelection: TenantSelection, pageable: Pageable3): Promise<Page2<T>>;
633
- }
634
583
  import { Pageable as Pageable4, IterablePage as IterablePage4 } from "@kinotic-ai/core";
635
584
  /**
636
585
  * This is the base interface for all admin entity repositories.
@@ -768,4 +717,4 @@ declare const PersistencePlugin: KinoticPlugin<IPersistenceExtension>;
768
717
  declare module "@kinotic-ai/core" {
769
718
  interface KinoticSingleton extends IPersistenceExtension {}
770
719
  }
771
- export { Version, TimeReference, Text, TenantSpecificId, TenantSelection, TenantId, RoleDecorator, Role, QueryParameter, QueryOptions, Query, PrecisionType, Precision, PolicyDecorator, Policy, PersistencePlugin, NotNull, NotIndexed, Nested, MultiTenancyType, Id, IPersistenceExtension, IEntityRepository, IEntitiesRepository, IAdminEntityRepository, IAdminEntitiesRepository, Flattened, EsIndexConfigurationData, EsIndexConfiguration, EntityType, EntityServiceDecoratorsDecorator, EntityServiceDecoratorsConfig, EntityServiceDecorators, EntityServiceDecorator, EntityRepository, Entity, EntitiesRepository, Discriminator, DecoratedFunction, DateTime, AutoGeneratedId, AdminEntityRepository, AdminEntitiesRepository, APP_API_ZONE, $Role, $Policy };
720
+ export { Version, TimeReference, Text, TenantSpecificId, TenantSelection, TenantId, QueryParameter, QueryOptions, Query, PrecisionType, Precision, PersistencePlugin, NotNull, NotIndexed, Nested, MultiTenancyType, Id, IPersistenceExtension, IEntityRepository, IEntitiesRepository, IAdminEntityRepository, IAdminEntitiesRepository, Flattened, EsIndexConfigurationData, EsIndexConfiguration, EntityType, EntityRepository, Entity, EntitiesRepository, Discriminator, DateTime, AutoGeneratedId, AdminEntityRepository, AdminEntitiesRepository, APP_API_ZONE };
package/dist/index.d.ts CHANGED
@@ -61,7 +61,7 @@ declare enum MultiTenancyType {
61
61
  SHARED = 1
62
62
  }
63
63
  /**
64
- * The {@link PrecisionType} enum is used to define the precision of a numeric field in the Continuum IDL.
64
+ * The {@link PrecisionType} enum is used to define the precision of a numeric field in the Kinotic IDL.
65
65
  */
66
66
  declare enum PrecisionType {
67
67
  /**
@@ -85,12 +85,53 @@ declare enum PrecisionType {
85
85
  */
86
86
  SHORT = 4
87
87
  }
88
- import { C3Decorator } from "@kinotic-ai/idl";
89
88
  /**
90
- * This class denotes {@link C3Decorator} that can be applied to an {@link EntityService} using the {@link EntityServiceDecoratorsDecorator}
89
+ * Signifies that a property is an auto-generated ID for the entity.
90
+ */
91
+ declare function AutoGeneratedId(_value: undefined, _context: ClassFieldDecoratorContext): void;
92
+ /**
93
+ * Signifies that a property holds a date, which is stored and queried as a date.
94
+ * The property is a string, or an array of strings, holding ISO-8601 dates such as `Date.prototype.toISOString()` returns.
95
+ */
96
+ declare function DateTime(_value: undefined, _context: ClassFieldDecoratorContext<unknown, string | readonly string[] | null | undefined>): void;
97
+ /**
98
+ * Signifies that a property is a discriminator for the entity.
99
+ * This is used to determine the type of the entity when deserializing from JSON.
100
+ * @param propertyName the name of the property to use as the discriminator
101
+ */
102
+ declare function Discriminator(_propertyName: string): (_value: undefined, _context: ClassFieldDecoratorContext) => void;
103
+ /**
104
+ * Signifies that a class is a Entity.
105
+ * This is required to define the class as an entity in the Kinotic framework.
106
+ * @param multiTenancyType the type of multi-tenancy to use for this entity
107
+ * @param entityType the type of entity to use for this entity
108
+ */
109
+ declare function Entity(_multiTenancyType?: MultiTenancyType, _entityType?: EntityType): (_value: Function, _context: ClassDecoratorContext<any>) => void;
110
+ /**
111
+ * Provides configuration for the Elasticsearch index.
112
+ * This can be used to override the default index settings and mappings used by Kinotic.
113
+ */
114
+ declare function EsIndexConfiguration(_value: EsIndexConfigurationData): (_target: Function, _context: ClassDecoratorContext<any>) => void;
115
+ declare function Flattened(_value: undefined, _context: ClassFieldDecoratorContext): void;
116
+ /**
117
+ * Signifies that a property is the ID of the entity.
118
+ */
119
+ declare function Id(_value: undefined, _context: ClassFieldDecoratorContext): void;
120
+ declare function Nested(_value: undefined, _context: ClassFieldDecoratorContext): void;
121
+ /**
122
+ * Signifies that a property is not indexed in Elasticsearch.
123
+ */
124
+ declare function NotIndexed(_value: undefined, _context: ClassFieldDecoratorContext): void;
125
+ declare function NotNull(_value: undefined, _context: ClassFieldDecoratorContext): void;
126
+ declare function Precision(_precisionType?: PrecisionType): (_value: undefined, _context: ClassFieldDecoratorContext) => void;
127
+ declare function Query(_statements: string): (_value: Function, _context: ClassMethodDecoratorContext) => void;
128
+ declare function Text(_value: undefined, _context: ClassFieldDecoratorContext): void;
129
+ /**
130
+ * This is used for data streams to signify the field that should be used as the time reference.
91
131
  */
92
- declare abstract class EntityServiceDecorator extends C3Decorator {}
93
- import { Pageable as Pageable2, IterablePage as IterablePage2 } from "@kinotic-ai/core";
132
+ declare function TimeReference(_value: undefined, _context: ClassFieldDecoratorContext): void;
133
+ declare function Version(_value: undefined, _context: ClassFieldDecoratorContext): void;
134
+ declare function TenantId(_value: undefined, _context: ClassFieldDecoratorContext): void;
94
135
  import { IKinotic } from "@kinotic-ai/core";
95
136
  import { IServiceProxy, Page, Pageable, IterablePage } from "@kinotic-ai/core";
96
137
  /**
@@ -262,6 +303,120 @@ declare class EntitiesRepository implements IEntitiesRepository {
262
303
  syncIndex(entityDefinitionId: string): Promise<void>;
263
304
  update<T>(entityDefinitionId: string, entity: T): Promise<T>;
264
305
  }
306
+ import { IKinotic as IKinotic2 } from "@kinotic-ai/core";
307
+ import { IServiceProxy as IServiceProxy2, Page as Page2, Pageable as Pageable2, IterablePage as IterablePage2 } from "@kinotic-ai/core";
308
+ type TenantSelection = string[];
309
+ interface IAdminEntitiesRepository {
310
+ /**
311
+ * Returns the number of entities available.
312
+ * @param structureId the id of the structure to count
313
+ * @param tenantSelection the list of tenants to use when retrieving the entity records
314
+ * @return {@link Promise} emitting the number of entities.
315
+ */
316
+ count(entityDefinitionId: string, tenantSelection: TenantSelection): Promise<number>;
317
+ /**
318
+ * Returns the number of entities available for the given query.
319
+ *
320
+ * @param entityDefinitionId the id of the structure to save the entity for
321
+ * @param query the query used to limit result
322
+ * @param tenantSelection the list of tenants to use when retrieving the entity records
323
+ * @return Promise emitting the number of entities
324
+ */
325
+ countByQuery(entityDefinitionId: string, query: string, tenantSelection: TenantSelection): Promise<number>;
326
+ /**
327
+ * Deletes the entity with the given id.
328
+ *
329
+ * @param entityDefinitionId the id of the structure to save the entity for
330
+ * @param id must not be {@literal null}
331
+ * @return {@link Promise} emitting when delete is complete
332
+ * @throws IllegalArgumentException in case the given {@literal id} is {@literal null}
333
+ */
334
+ deleteById(entityDefinitionId: string, id: TenantSpecificId): Promise<void>;
335
+ /**
336
+ * Deletes the entity with the given id.
337
+ *
338
+ * @param entityDefinitionId the id of the structure to save the entity for
339
+ * @param query the query used to filter records to delete, must not be {@literal null}
340
+ * @param tenantSelection the list of tenants to use when deleting the entity records
341
+ * @return Promise signaling when operation has completed
342
+ * @throws Error in case the given {@literal query} is {@literal null}
343
+ */
344
+ deleteByQuery(entityDefinitionId: string, query: string, tenantSelection: TenantSelection): Promise<void>;
345
+ /**
346
+ * Returns a {@link IterablePage} of entities meeting the paging restriction provided in the {@link Pageable} object.
347
+ *
348
+ * @param entityDefinitionId the id of the structure to save the entity for
349
+ * @param tenantSelection the list of tenants to use when retrieving the entity records
350
+ * @param pageable the page settings to be used
351
+ * @return a page of entities
352
+ */
353
+ findAll<T>(entityDefinitionId: string, tenantSelection: TenantSelection, pageable: Pageable2): Promise<IterablePage2<T>>;
354
+ /**
355
+ * Retrieves an entity by its id.
356
+ *
357
+ * @param entityDefinitionId the id of the structure to save the entity for
358
+ * @param id must not be {@literal null}
359
+ * @return {@link Promise} with the entity with the given id or {@link Promise} emitting null if none found
360
+ * @throws IllegalArgumentException in case the given {@literal id} is {@literal null}
361
+ */
362
+ findById<T>(entityDefinitionId: string, id: TenantSpecificId): Promise<T | null>;
363
+ /**
364
+ * Retrieves a list of entities by their id.
365
+ *
366
+ * @param entityDefinitionId the id of the structure to save the entity for
367
+ * @param ids must not be {@literal null}
368
+ * @return Promise emitting the entities with the given ids or Promise emitting null if none found
369
+ * @throws Error in case the given {@literal ids} is {@literal null}
370
+ */
371
+ findByIds<T>(entityDefinitionId: string, ids: TenantSpecificId[]): Promise<T[]>;
372
+ /**
373
+ * Executes a named query.
374
+ * @param entityDefinitionId the id of the structure that this named query is defined for
375
+ * @param queryName the name of the function that defines the query
376
+ * @param parameters to pass to the query
377
+ * @param tenantSelection the list of tenants to use when executing the query
378
+ * @returns Promise with the result of the query
379
+ */
380
+ namedQuery<T>(entityDefinitionId: string, queryName: string, parameters: QueryParameter[], tenantSelection: TenantSelection): Promise<T>;
381
+ /**
382
+ * Executes a named query and returns a Page of results.
383
+ * @param entityDefinitionId the id of the structure that this named query is defined for
384
+ * @param queryName the name of the function that defines the query
385
+ * @param parameters to pass to the query
386
+ * @param tenantSelection the list of tenants to use when executing the query
387
+ * @param pageable the page settings to be used
388
+ * @returns Promise with the result of the query
389
+ */
390
+ namedQueryPage<T>(entityDefinitionId: string, queryName: string, parameters: QueryParameter[], tenantSelection: TenantSelection, pageable: Pageable2): Promise<IterablePage2<T>>;
391
+ /**
392
+ * Returns a {@link IterablePage} of entities matching the search text and paging restriction provided in the {@link Pageable} object.
393
+ *
394
+ * @param entityDefinitionId the id of the structure to save the entity for
395
+ * @param searchText the text to search for entities for
396
+ * @param tenantSelection the list of tenants to use when retrieving the entity records
397
+ * @param pageable the page settings to be used
398
+ * @return a page of entities
399
+ */
400
+ search<T>(entityDefinitionId: string, searchText: string, tenantSelection: TenantSelection, pageable: Pageable2): Promise<IterablePage2<T>>;
401
+ }
402
+ declare class AdminEntitiesRepository implements IAdminEntitiesRepository {
403
+ protected serviceProxy: IServiceProxy2;
404
+ constructor(kinotic: IKinotic2);
405
+ count(entityDefinitionId: string, tenantSelection: TenantSelection): Promise<number>;
406
+ countByQuery(entityDefinitionId: string, query: string, tenantSelection: TenantSelection): Promise<number>;
407
+ deleteById(entityDefinitionId: string, id: TenantSpecificId): Promise<void>;
408
+ deleteByQuery(entityDefinitionId: string, query: string, tenantSelection: TenantSelection): Promise<void>;
409
+ findAll<T>(entityDefinitionId: string, tenantSelection: TenantSelection, pageable: Pageable2): Promise<IterablePage2<T>>;
410
+ findAllSinglePage<T>(entityDefinitionId: string, tenantSelection: TenantSelection, pageable: Pageable2): Promise<Page2<T>>;
411
+ findById<T>(entityDefinitionId: string, id: TenantSpecificId): Promise<T>;
412
+ findByIds<T>(entityDefinitionId: string, ids: TenantSpecificId[]): Promise<T[]>;
413
+ namedQuery<T>(entityDefinitionId: string, queryName: string, parameters: QueryParameter[], tenantSelection: TenantSelection): Promise<T>;
414
+ namedQueryPage<T>(entityDefinitionId: string, queryName: string, parameters: QueryParameter[], tenantSelection: TenantSelection, pageable: Pageable2): Promise<IterablePage2<T>>;
415
+ namedQuerySinglePage<T>(entityDefinitionId: string, queryName: string, parameters: QueryParameter[], tenantSelection: TenantSelection, pageable: Pageable2): Promise<Page2<T>>;
416
+ search<T>(entityDefinitionId: string, searchText: string, tenantSelection: TenantSelection, pageable: Pageable2): Promise<IterablePage2<T>>;
417
+ searchSinglePage<T>(entityDefinitionId: string, searchText: string, tenantSelection: TenantSelection, pageable: Pageable2): Promise<Page2<T>>;
418
+ }
419
+ import { Pageable as Pageable3, IterablePage as IterablePage3 } from "@kinotic-ai/core";
265
420
  /**
266
421
  * This is the base interface for all entity repositories.
267
422
  * It provides the basic CRUD operations for entities.
@@ -331,7 +486,7 @@ interface IEntityRepository<T> {
331
486
  * @param pageable the page settings to be used
332
487
  * @return a page of entities
333
488
  */
334
- findAll(pageable: Pageable2): Promise<IterablePage2<T>>;
489
+ findAll(pageable: Pageable3): Promise<IterablePage3<T>>;
335
490
  /**
336
491
  * Retrieves an entity by its id.
337
492
  *
@@ -362,7 +517,7 @@ interface IEntityRepository<T> {
362
517
  * @param pageable the page settings to be used
363
518
  * @returns Promise with the result of the query
364
519
  */
365
- namedQueryPage<U>(queryName: string, queryParameters: QueryParameter[], pageable: Pageable2): Promise<IterablePage2<U>>;
520
+ namedQueryPage<U>(queryName: string, queryParameters: QueryParameter[], pageable: Pageable3): Promise<IterablePage3<U>>;
366
521
  /**
367
522
  * Saves a given entity. This will override all data if there is an existing entity with the same id.
368
523
  * Use the returned instance for further operations as the save operation might have changed the entity instance.
@@ -379,7 +534,7 @@ interface IEntityRepository<T> {
379
534
  * @param pageable the page settings to be used
380
535
  * @return a page of entities
381
536
  */
382
- search(searchText: string, pageable: Pageable2): Promise<IterablePage2<T>>;
537
+ search(searchText: string, pageable: Pageable3): Promise<IterablePage3<T>>;
383
538
  /**
384
539
  * This operation makes all the recent writes immediately available for search.
385
540
  * @return a Promise that resolves when the operation is complete
@@ -413,224 +568,18 @@ declare class EntityRepository<T> implements IEntityRepository<T> {
413
568
  countByQuery(query: string): Promise<number>;
414
569
  deleteById(id: string): Promise<void>;
415
570
  deleteByQuery(query: string): Promise<void>;
416
- findAll(pageable: Pageable2): Promise<IterablePage2<T>>;
571
+ findAll(pageable: Pageable3): Promise<IterablePage3<T>>;
417
572
  findById(id: string): Promise<T | null>;
418
573
  findByIds(ids: string[]): Promise<T[]>;
419
574
  namedQuery<U>(queryName: string, queryParameters: QueryParameter[]): Promise<U>;
420
- namedQueryPage<U>(queryName: string, queryParameters: QueryParameter[], pageable: Pageable2): Promise<IterablePage2<U>>;
575
+ namedQueryPage<U>(queryName: string, queryParameters: QueryParameter[], pageable: Pageable3): Promise<IterablePage3<U>>;
421
576
  save(entity: T): Promise<T>;
422
- search(searchText: string, pageable: Pageable2): Promise<IterablePage2<T>>;
577
+ search(searchText: string, pageable: Pageable3): Promise<IterablePage3<T>>;
423
578
  syncIndex(): Promise<void>;
424
579
  update(entity: T): Promise<T>;
425
580
  protected beforeBulkSaveOrUpdate(entities: T[]): Promise<T[]>;
426
581
  protected beforeSaveOrUpdate(entity: T): Promise<T>;
427
582
  }
428
- type IfFunction<
429
- T,
430
- U
431
- > = T extends (...args: any[]) => any ? U : never;
432
- type MethodsOf<T> = { [K in keyof T] : IfFunction<T[K], K> }[keyof T];
433
- type ExcludedMethods = "namedQuery" | "namedQueryPage";
434
- type FilteredMethods<T> = Exclude<MethodsOf<T>, ExcludedMethods>;
435
- type DecoratedFunction = FilteredMethods<IEntityRepository<any>> | "allCreate" | "allRead" | "allUpdate" | "allDelete";
436
- /**
437
- * Configuration for the {@link EntityServiceDecoratorsDecorator}
438
- * This is a map of method names to an array of decorators that should be applied to that method
439
- */
440
- type EntityServiceDecoratorsConfig = Partial<Record<DecoratedFunction, EntityServiceDecorator[]>>;
441
- /**
442
- * Signifies that a property is an auto-generated ID for the entity.
443
- */
444
- declare function AutoGeneratedId(_value: undefined, _context: ClassFieldDecoratorContext): void;
445
- /**
446
- * Signifies that a property holds a date, which is stored and queried as a date.
447
- * The property is a string, or an array of strings, holding ISO-8601 dates such as `Date.prototype.toISOString()` returns.
448
- */
449
- declare function DateTime(_value: undefined, _context: ClassFieldDecoratorContext<unknown, string | readonly string[] | null | undefined>): void;
450
- /**
451
- * Signifies that a property is a discriminator for the entity.
452
- * This is used to determine the type of the entity when deserializing from JSON.
453
- * @param propertyName the name of the property to use as the discriminator
454
- */
455
- declare function Discriminator(_propertyName: string): (_value: undefined, _context: ClassFieldDecoratorContext) => void;
456
- /**
457
- * Signifies that a class is a Entity.
458
- * This is required to define the class as an entity in the Kinotic framework.
459
- * @param multiTenancyType the type of multi-tenancy to use for this entity
460
- * @param entityType the type of entity to use for this entity
461
- */
462
- declare function Entity(_multiTenancyType?: MultiTenancyType, _entityType?: EntityType): (_value: Function, _context: ClassDecoratorContext<any>) => void;
463
- /**
464
- * A class Decorator when applied to an Entity will configure Decorators to be applied to the EntityService
465
- * @param config the {@link EntityServiceDecoratorsConfig} to use
466
- */
467
- declare function EntityServiceDecorators(_config: EntityServiceDecoratorsConfig): (_value: Function, _context: ClassDecoratorContext<any>) => void;
468
- /**
469
- * Provides configuration for the Elasticsearch index.
470
- * This can be used to override the default index settings and mappings used by Kinotic.
471
- */
472
- declare function EsIndexConfiguration(_value: EsIndexConfigurationData): (_target: Function, _context: ClassDecoratorContext<any>) => void;
473
- declare function Flattened(_value: undefined, _context: ClassFieldDecoratorContext): void;
474
- /**
475
- * Signifies that a property is the ID of the entity.
476
- */
477
- declare function Id(_value: undefined, _context: ClassFieldDecoratorContext): void;
478
- declare function Nested(_value: undefined, _context: ClassFieldDecoratorContext): void;
479
- /**
480
- * Signifies that a property is not indexed in Elasticsearch.
481
- */
482
- declare function NotIndexed(_value: undefined, _context: ClassFieldDecoratorContext): void;
483
- declare function NotNull(_value: undefined, _context: ClassFieldDecoratorContext): void;
484
- declare function Policy(_policies: string[][]): (_value: unknown, _context: ClassDecoratorContext<any> | ClassFieldDecoratorContext | ClassMethodDecoratorContext) => void;
485
- declare function Precision(_precisionType?: PrecisionType): (_value: undefined, _context: ClassFieldDecoratorContext) => void;
486
- declare function Query(_statements: string): (_value: Function, _context: ClassMethodDecoratorContext) => void;
487
- declare function Role(_roles: string[]): (_value: unknown, _context: ClassDecoratorContext<any> | ClassFieldDecoratorContext | ClassMethodDecoratorContext) => void;
488
- declare function Text(_value: undefined, _context: ClassFieldDecoratorContext): void;
489
- /**
490
- * This is used for data streams to signify the field that should be used as the time reference.
491
- */
492
- declare function TimeReference(_value: undefined, _context: ClassFieldDecoratorContext): void;
493
- declare function Version(_value: undefined, _context: ClassFieldDecoratorContext): void;
494
- declare function TenantId(_value: undefined, _context: ClassFieldDecoratorContext): void;
495
- import { C3Decorator as C3Decorator2 } from "@kinotic-ai/idl";
496
- /**
497
- * Provides a way to add decorators to an entity service
498
- */
499
- declare class EntityServiceDecoratorsDecorator extends C3Decorator2 {
500
- config: EntityServiceDecoratorsConfig;
501
- constructor();
502
- }
503
- declare class PolicyDecorator extends EntityServiceDecorator {
504
- policies: string[][];
505
- constructor(policies: string[][]);
506
- }
507
- /**
508
- * Provides a mechanism to apply the @Policy decorator to an {@link EntityService}
509
- * @param policies to be supplied
510
- */
511
- declare function $Policy(policies: string[][]): PolicyDecorator;
512
- declare class RoleDecorator extends EntityServiceDecorator {
513
- roles: string[];
514
- constructor(roles: string[]);
515
- }
516
- /**
517
- * Provides a mechanism to apply the @Role decorator to an {@link EntityService}
518
- * @param roles to be supplied
519
- */
520
- declare function $Role(roles: string[]): RoleDecorator;
521
- import { IKinotic as IKinotic2 } from "@kinotic-ai/core";
522
- import { IServiceProxy as IServiceProxy2, Page as Page2, Pageable as Pageable3, IterablePage as IterablePage3 } from "@kinotic-ai/core";
523
- type TenantSelection = string[];
524
- interface IAdminEntitiesRepository {
525
- /**
526
- * Returns the number of entities available.
527
- * @param structureId the id of the structure to count
528
- * @param tenantSelection the list of tenants to use when retrieving the entity records
529
- * @return {@link Promise} emitting the number of entities.
530
- */
531
- count(entityDefinitionId: string, tenantSelection: TenantSelection): Promise<number>;
532
- /**
533
- * Returns the number of entities available for the given query.
534
- *
535
- * @param entityDefinitionId the id of the structure to save the entity for
536
- * @param query the query used to limit result
537
- * @param tenantSelection the list of tenants to use when retrieving the entity records
538
- * @return Promise emitting the number of entities
539
- */
540
- countByQuery(entityDefinitionId: string, query: string, tenantSelection: TenantSelection): Promise<number>;
541
- /**
542
- * Deletes the entity with the given id.
543
- *
544
- * @param entityDefinitionId the id of the structure to save the entity for
545
- * @param id must not be {@literal null}
546
- * @return {@link Promise} emitting when delete is complete
547
- * @throws IllegalArgumentException in case the given {@literal id} is {@literal null}
548
- */
549
- deleteById(entityDefinitionId: string, id: TenantSpecificId): Promise<void>;
550
- /**
551
- * Deletes the entity with the given id.
552
- *
553
- * @param entityDefinitionId the id of the structure to save the entity for
554
- * @param query the query used to filter records to delete, must not be {@literal null}
555
- * @param tenantSelection the list of tenants to use when deleting the entity records
556
- * @return Promise signaling when operation has completed
557
- * @throws Error in case the given {@literal query} is {@literal null}
558
- */
559
- deleteByQuery(entityDefinitionId: string, query: string, tenantSelection: TenantSelection): Promise<void>;
560
- /**
561
- * Returns a {@link IterablePage} of entities meeting the paging restriction provided in the {@link Pageable} object.
562
- *
563
- * @param entityDefinitionId the id of the structure to save the entity for
564
- * @param tenantSelection the list of tenants to use when retrieving the entity records
565
- * @param pageable the page settings to be used
566
- * @return a page of entities
567
- */
568
- findAll<T>(entityDefinitionId: string, tenantSelection: TenantSelection, pageable: Pageable3): Promise<IterablePage3<T>>;
569
- /**
570
- * Retrieves an entity by its id.
571
- *
572
- * @param entityDefinitionId the id of the structure to save the entity for
573
- * @param id must not be {@literal null}
574
- * @return {@link Promise} with the entity with the given id or {@link Promise} emitting null if none found
575
- * @throws IllegalArgumentException in case the given {@literal id} is {@literal null}
576
- */
577
- findById<T>(entityDefinitionId: string, id: TenantSpecificId): Promise<T | null>;
578
- /**
579
- * Retrieves a list of entities by their id.
580
- *
581
- * @param entityDefinitionId the id of the structure to save the entity for
582
- * @param ids must not be {@literal null}
583
- * @return Promise emitting the entities with the given ids or Promise emitting null if none found
584
- * @throws Error in case the given {@literal ids} is {@literal null}
585
- */
586
- findByIds<T>(entityDefinitionId: string, ids: TenantSpecificId[]): Promise<T[]>;
587
- /**
588
- * Executes a named query.
589
- * @param entityDefinitionId the id of the structure that this named query is defined for
590
- * @param queryName the name of the function that defines the query
591
- * @param parameters to pass to the query
592
- * @param tenantSelection the list of tenants to use when executing the query
593
- * @returns Promise with the result of the query
594
- */
595
- namedQuery<T>(entityDefinitionId: string, queryName: string, parameters: QueryParameter[], tenantSelection: TenantSelection): Promise<T>;
596
- /**
597
- * Executes a named query and returns a Page of results.
598
- * @param entityDefinitionId the id of the structure that this named query is defined for
599
- * @param queryName the name of the function that defines the query
600
- * @param parameters to pass to the query
601
- * @param tenantSelection the list of tenants to use when executing the query
602
- * @param pageable the page settings to be used
603
- * @returns Promise with the result of the query
604
- */
605
- namedQueryPage<T>(entityDefinitionId: string, queryName: string, parameters: QueryParameter[], tenantSelection: TenantSelection, pageable: Pageable3): Promise<IterablePage3<T>>;
606
- /**
607
- * Returns a {@link IterablePage} of entities matching the search text and paging restriction provided in the {@link Pageable} object.
608
- *
609
- * @param entityDefinitionId the id of the structure to save the entity for
610
- * @param searchText the text to search for entities for
611
- * @param tenantSelection the list of tenants to use when retrieving the entity records
612
- * @param pageable the page settings to be used
613
- * @return a page of entities
614
- */
615
- search<T>(entityDefinitionId: string, searchText: string, tenantSelection: TenantSelection, pageable: Pageable3): Promise<IterablePage3<T>>;
616
- }
617
- declare class AdminEntitiesRepository implements IAdminEntitiesRepository {
618
- protected serviceProxy: IServiceProxy2;
619
- constructor(kinotic: IKinotic2);
620
- count(entityDefinitionId: string, tenantSelection: TenantSelection): Promise<number>;
621
- countByQuery(entityDefinitionId: string, query: string, tenantSelection: TenantSelection): Promise<number>;
622
- deleteById(entityDefinitionId: string, id: TenantSpecificId): Promise<void>;
623
- deleteByQuery(entityDefinitionId: string, query: string, tenantSelection: TenantSelection): Promise<void>;
624
- findAll<T>(entityDefinitionId: string, tenantSelection: TenantSelection, pageable: Pageable3): Promise<IterablePage3<T>>;
625
- findAllSinglePage<T>(entityDefinitionId: string, tenantSelection: TenantSelection, pageable: Pageable3): Promise<Page2<T>>;
626
- findById<T>(entityDefinitionId: string, id: TenantSpecificId): Promise<T>;
627
- findByIds<T>(entityDefinitionId: string, ids: TenantSpecificId[]): Promise<T[]>;
628
- namedQuery<T>(entityDefinitionId: string, queryName: string, parameters: QueryParameter[], tenantSelection: TenantSelection): Promise<T>;
629
- namedQueryPage<T>(entityDefinitionId: string, queryName: string, parameters: QueryParameter[], tenantSelection: TenantSelection, pageable: Pageable3): Promise<IterablePage3<T>>;
630
- namedQuerySinglePage<T>(entityDefinitionId: string, queryName: string, parameters: QueryParameter[], tenantSelection: TenantSelection, pageable: Pageable3): Promise<Page2<T>>;
631
- search<T>(entityDefinitionId: string, searchText: string, tenantSelection: TenantSelection, pageable: Pageable3): Promise<IterablePage3<T>>;
632
- searchSinglePage<T>(entityDefinitionId: string, searchText: string, tenantSelection: TenantSelection, pageable: Pageable3): Promise<Page2<T>>;
633
- }
634
583
  import { Pageable as Pageable4, IterablePage as IterablePage4 } from "@kinotic-ai/core";
635
584
  /**
636
585
  * This is the base interface for all admin entity repositories.
@@ -768,4 +717,4 @@ declare const PersistencePlugin: KinoticPlugin<IPersistenceExtension>;
768
717
  declare module "@kinotic-ai/core" {
769
718
  interface KinoticSingleton extends IPersistenceExtension {}
770
719
  }
771
- export { Version, TimeReference, Text, TenantSpecificId, TenantSelection, TenantId, RoleDecorator, Role, QueryParameter, QueryOptions, Query, PrecisionType, Precision, PolicyDecorator, Policy, PersistencePlugin, NotNull, NotIndexed, Nested, MultiTenancyType, Id, IPersistenceExtension, IEntityRepository, IEntitiesRepository, IAdminEntityRepository, IAdminEntitiesRepository, Flattened, EsIndexConfigurationData, EsIndexConfiguration, EntityType, EntityServiceDecoratorsDecorator, EntityServiceDecoratorsConfig, EntityServiceDecorators, EntityServiceDecorator, EntityRepository, Entity, EntitiesRepository, Discriminator, DecoratedFunction, DateTime, AutoGeneratedId, AdminEntityRepository, AdminEntitiesRepository, APP_API_ZONE, $Role, $Policy };
720
+ export { Version, TimeReference, Text, TenantSpecificId, TenantSelection, TenantId, QueryParameter, QueryOptions, Query, PrecisionType, Precision, PersistencePlugin, NotNull, NotIndexed, Nested, MultiTenancyType, Id, IPersistenceExtension, IEntityRepository, IEntitiesRepository, IAdminEntityRepository, IAdminEntitiesRepository, Flattened, EsIndexConfigurationData, EsIndexConfiguration, EntityType, EntityRepository, Entity, EntitiesRepository, Discriminator, DateTime, AutoGeneratedId, AdminEntityRepository, AdminEntitiesRepository, APP_API_ZONE };
package/dist/index.js CHANGED
@@ -46,9 +46,6 @@ function Discriminator(_propertyName) {
46
46
  function Entity(_multiTenancyType = 0 /* NONE */, _entityType = 0 /* TABLE */) {
47
47
  return function(_value, _context) {};
48
48
  }
49
- function EntityServiceDecorators(_config) {
50
- return function(_value, _context) {};
51
- }
52
49
  function EsIndexConfiguration(_value) {
53
50
  return function(_target, _context) {};
54
51
  }
@@ -57,65 +54,20 @@ function Id(_value, _context) {}
57
54
  function Nested(_value, _context) {}
58
55
  function NotIndexed(_value, _context) {}
59
56
  function NotNull(_value, _context) {}
60
- function Policy(_policies) {
61
- return function(_value, _context) {};
62
- }
63
57
  function Precision(_precisionType = 2 /* INT */) {
64
58
  return function(_value, _context) {};
65
59
  }
66
60
  function Query(_statements) {
67
61
  return function(_value, _context) {};
68
62
  }
69
- function Role(_roles) {
70
- return function(_value, _context) {};
71
- }
72
63
  function Text(_value, _context) {}
73
64
  function TimeReference(_value, _context) {}
74
65
  function Version(_value, _context) {}
75
66
  function TenantId(_value, _context) {}
76
- // packages/persistence/src/api/idl/EntityServiceDecorator.ts
77
- import { C3Decorator } from "@kinotic-ai/idl";
78
-
79
- class EntityServiceDecorator extends C3Decorator {
80
- }
81
- // packages/persistence/src/api/idl/EntityServiceDecoratorsDecorator.ts
82
- import { C3Decorator as C3Decorator2 } from "@kinotic-ai/idl";
83
-
84
- class EntityServiceDecoratorsDecorator extends C3Decorator2 {
85
- config;
86
- constructor() {
87
- super();
88
- this.type = "EntityServiceDecoratorsDecorator";
89
- }
90
- }
91
67
  // packages/persistence/src/api/idl/EsIndexConfigurationData.ts
92
68
  class EsIndexConfigurationData {
93
69
  componentTemplates = [];
94
70
  }
95
- // packages/persistence/src/api/idl/PolicyDecorator.ts
96
- class PolicyDecorator extends EntityServiceDecorator {
97
- policies;
98
- constructor(policies) {
99
- super();
100
- this.type = "PolicyDecorator";
101
- this.policies = policies;
102
- }
103
- }
104
- function $Policy(policies) {
105
- return new PolicyDecorator(policies);
106
- }
107
- // packages/persistence/src/api/idl/RoleDecorator.ts
108
- class RoleDecorator extends EntityServiceDecorator {
109
- roles;
110
- constructor(roles) {
111
- super();
112
- this.type = "RoleDecorator";
113
- this.roles = roles;
114
- }
115
- }
116
- function $Role(roles) {
117
- return new RoleDecorator(roles);
118
- }
119
71
  // packages/persistence/src/api/IEntitiesRepository.ts
120
72
  import {
121
73
  FunctionalIterablePage
@@ -370,14 +322,10 @@ export {
370
322
  Text,
371
323
  TenantSpecificId,
372
324
  TenantId,
373
- RoleDecorator,
374
- Role,
375
325
  QueryOptions,
376
326
  Query,
377
327
  PrecisionType,
378
328
  Precision,
379
- PolicyDecorator,
380
- Policy,
381
329
  PersistencePlugin,
382
330
  NotNull,
383
331
  NotIndexed,
@@ -388,9 +336,6 @@ export {
388
336
  EsIndexConfigurationData,
389
337
  EsIndexConfiguration,
390
338
  EntityType,
391
- EntityServiceDecoratorsDecorator,
392
- EntityServiceDecorators,
393
- EntityServiceDecorator,
394
339
  EntityRepository,
395
340
  Entity,
396
341
  EntitiesRepository,
@@ -399,7 +344,5 @@ export {
399
344
  AutoGeneratedId,
400
345
  AdminEntityRepository,
401
346
  AdminEntitiesRepository,
402
- APP_API_ZONE,
403
- $Role,
404
- $Policy
347
+ APP_API_ZONE
405
348
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kinotic-ai/persistence",
3
- "version": "5.0.0-beta.12",
3
+ "version": "5.0.0-beta.13",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -37,14 +37,14 @@
37
37
  "coverage": "bun test --coverage --pass-with-no-tests"
38
38
  },
39
39
  "peerDependencies": {
40
- "@kinotic-ai/core": "^5.0.0-beta.17"
40
+ "@kinotic-ai/core": "^5.0.0-beta.20"
41
41
  },
42
42
  "dependencies": {
43
- "@kinotic-ai/idl": "5.0.0-beta.1",
43
+ "@kinotic-ai/idl": "5.0.0-beta.2",
44
44
  "rxjs": "^7.8.2"
45
45
  },
46
46
  "devDependencies": {
47
- "@kinotic-ai/core": "5.0.0-beta.17",
47
+ "@kinotic-ai/core": "5.0.0-beta.20",
48
48
  "@types/node": "^25.3.2",
49
49
  "tslib": "^2.8.1",
50
50
  "typescript": "^5.9.3"