@kinotic-ai/persistence 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,7 +8,7 @@ Instant, schema-driven data access for your Kinotic applications. `@kinotic-ai/p
8
8
 
9
9
  ## Why @kinotic-ai/persistence?
10
10
 
11
- - **Zero query boilerplate.** Decorate your TypeScript classes and the data layer is ready — no mappers, no repositories, no hand-written queries to maintain.
11
+ - **Zero query boilerplate.** Decorate your TypeScript classes and the data layer is ready.
12
12
  - **Search is a first-class feature.** Full-text search across your data is available immediately, as naturally as any other read operation.
13
13
  - **Built for scale.** Pagination, bulk operations, and cursor-based traversal handle large datasets without architectural changes.
14
14
  - **Multi-tenancy handled for you.** Data isolation between tenants is automatic — your application logic stays clean.
package/dist/index.cjs CHANGED
@@ -40,19 +40,41 @@ var __export = (target, all) => {
40
40
  // packages/persistence/src/index.ts
41
41
  var exports_src = {};
42
42
  __export(exports_src, {
43
+ Version: () => Version,
44
+ TimeReference: () => TimeReference,
45
+ Text: () => Text,
43
46
  TenantSpecificId: () => TenantSpecificId,
47
+ TenantId: () => TenantId,
48
+ Role: () => Role,
44
49
  QueryOptions: () => QueryOptions,
50
+ Query: () => Query,
45
51
  PrecisionType: () => PrecisionType,
52
+ PrecisionConfig: () => PrecisionConfig,
53
+ Precision: () => Precision,
54
+ Policy: () => Policy,
46
55
  PersistencePlugin: () => PersistencePlugin,
56
+ NotNull: () => NotNull,
57
+ NotIndexed: () => NotIndexed,
58
+ Nested: () => Nested,
47
59
  MultiTenancyType: () => MultiTenancyType,
48
60
  KinoticSingleton: () => import_core5.KinoticSingleton,
61
+ KinoticPersistenceDecorator: () => KinoticPersistenceDecorator,
49
62
  Kinotic: () => import_core5.Kinotic,
63
+ Id: () => Id,
64
+ Flattened: () => Flattened,
50
65
  EsIndexConfigurationData: () => EsIndexConfigurationData,
66
+ EsIndexConfiguration: () => EsIndexConfiguration,
51
67
  EntityType: () => EntityType,
52
68
  EntityServiceDecoratorsDecorator: () => EntityServiceDecoratorsDecorator,
69
+ EntityServiceDecorators: () => EntityServiceDecorators,
53
70
  EntityServiceDecorator: () => EntityServiceDecorator,
54
71
  EntityService: () => EntityService,
72
+ EntityConfig: () => EntityConfig,
73
+ Entity: () => Entity,
55
74
  EntitiesService: () => EntitiesService,
75
+ DiscriminatorConfig: () => DiscriminatorConfig,
76
+ Discriminator: () => Discriminator,
77
+ AutoGeneratedId: () => AutoGeneratedId,
56
78
  AdminEntityService: () => AdminEntityService,
57
79
  AdminEntitiesService: () => AdminEntitiesService
58
80
  });
@@ -73,37 +95,23 @@ class TenantSpecificId {
73
95
  this.tenantId = tenantId;
74
96
  }
75
97
  }
76
- // packages/persistence/src/api/idl/EntityServiceDecorator.ts
77
- var import_idl = require("@kinotic-ai/idl");
98
+ // packages/persistence/src/api/KinoticPersistenceDecorators.ts
99
+ var import_reflect_metadata = require("reflect-metadata");
78
100
 
79
- class EntityServiceDecorator extends import_idl.C3Decorator {
80
- }
81
- // packages/persistence/src/api/idl/EntityServiceDecoratorsDecorator.ts
82
- var import_idl2 = require("@kinotic-ai/idl");
83
-
84
- class EntityServiceDecoratorsDecorator extends import_idl2.C3Decorator {
85
- config;
86
- constructor() {
87
- super();
88
- this.type = "EntityServiceDecoratorsDecorator";
89
- }
90
- }
91
101
  // packages/persistence/src/api/idl/EntityType.ts
92
102
  var EntityType;
93
103
  ((EntityType2) => {
94
104
  EntityType2[EntityType2["TABLE"] = 0] = "TABLE";
95
105
  EntityType2[EntityType2["STREAM"] = 1] = "STREAM";
96
106
  })(EntityType ||= {});
97
- // packages/persistence/src/api/idl/EsIndexConfigurationData.ts
98
- class EsIndexConfigurationData {
99
- componentTemplates = [];
100
- }
107
+
101
108
  // packages/persistence/src/api/idl/MultiTenancyType.ts
102
109
  var MultiTenancyType;
103
110
  ((MultiTenancyType2) => {
104
111
  MultiTenancyType2[MultiTenancyType2["NONE"] = 0] = "NONE";
105
112
  MultiTenancyType2[MultiTenancyType2["SHARED"] = 1] = "SHARED";
106
113
  })(MultiTenancyType ||= {});
114
+
107
115
  // packages/persistence/src/api/idl/PrecisionType.ts
108
116
  var PrecisionType;
109
117
  ((PrecisionType2) => {
@@ -113,6 +121,119 @@ var PrecisionType;
113
121
  PrecisionType2[PrecisionType2["LONG"] = 3] = "LONG";
114
122
  PrecisionType2[PrecisionType2["SHORT"] = 4] = "SHORT";
115
123
  })(PrecisionType ||= {});
124
+
125
+ // packages/persistence/src/api/KinoticPersistenceDecorators.ts
126
+ var KinoticPersistenceDecorator;
127
+ ((KinoticPersistenceDecorator2) => {
128
+ KinoticPersistenceDecorator2["Entity"] = "__structures-entity__";
129
+ KinoticPersistenceDecorator2["Id"] = "__structures-id__";
130
+ KinoticPersistenceDecorator2["AutoGeneratedId"] = "__structures-auto-generated-id__";
131
+ KinoticPersistenceDecorator2["Flattened"] = "__structures-flattened__";
132
+ KinoticPersistenceDecorator2["Nested"] = "__structures-nested__";
133
+ KinoticPersistenceDecorator2["Text"] = "__structures-text__";
134
+ KinoticPersistenceDecorator2["NotNull"] = "__structures-notnull__";
135
+ KinoticPersistenceDecorator2["Precision"] = "__structures-precision__";
136
+ KinoticPersistenceDecorator2["Discriminator"] = "__structures-discriminator__";
137
+ KinoticPersistenceDecorator2["Query"] = "__structures-query__";
138
+ KinoticPersistenceDecorator2["EntityServiceDecorators"] = "__structures-entity-service-decorators__";
139
+ })(KinoticPersistenceDecorator ||= {});
140
+ function AutoGeneratedId(target, propertyKey) {
141
+ Reflect.defineMetadata("__structures-auto-generated-id__" /* AutoGeneratedId */, {}, target, propertyKey);
142
+ }
143
+
144
+ class DiscriminatorConfig {
145
+ propertyName;
146
+ constructor(propertyName) {
147
+ this.propertyName = propertyName;
148
+ }
149
+ }
150
+ function Discriminator(propertyName) {
151
+ return function(target, propertyKey) {
152
+ Reflect.defineMetadata("__structures-discriminator__" /* Discriminator */, new DiscriminatorConfig(propertyName), target, propertyKey);
153
+ };
154
+ }
155
+
156
+ class EntityConfig {
157
+ multiTenancyType;
158
+ entityType;
159
+ constructor(multiTenancyType, entityType = 0 /* TABLE */) {
160
+ this.multiTenancyType = multiTenancyType;
161
+ this.entityType = entityType;
162
+ }
163
+ }
164
+ function Entity(multiTenancyType = 0 /* NONE */, entityType = 0 /* TABLE */) {
165
+ return function(constructor) {
166
+ Reflect.defineMetadata("__structures-entity__" /* Entity */, new EntityConfig(multiTenancyType, entityType), constructor);
167
+ };
168
+ }
169
+ function EntityServiceDecorators(_config) {
170
+ return function(_constructor) {};
171
+ }
172
+ function EsIndexConfiguration(_value) {
173
+ return function(_constructor) {};
174
+ }
175
+ function Flattened(target, propertyKey) {
176
+ Reflect.defineMetadata("__structures-flattened__" /* Flattened */, {}, target, propertyKey);
177
+ }
178
+ function Id(target, propertyKey) {
179
+ Reflect.defineMetadata("__structures-id__" /* Id */, {}, target, propertyKey);
180
+ }
181
+ function Nested(target, propertyKey) {
182
+ Reflect.defineMetadata("__structures-nested__" /* Nested */, {}, target, propertyKey);
183
+ }
184
+ function NotIndexed(_target, _propertyKey) {}
185
+ function NotNull(target, propertyKey) {
186
+ Reflect.defineMetadata("__structures-notnull__" /* NotNull */, {}, target, propertyKey);
187
+ }
188
+ function Policy(_policies) {
189
+ return function(_target, _propertyKey, _descriptor) {};
190
+ }
191
+
192
+ class PrecisionConfig {
193
+ precisionType;
194
+ constructor(precisionType) {
195
+ this.precisionType = precisionType;
196
+ }
197
+ }
198
+ function Precision(precisionType = 2 /* INT */) {
199
+ return function(target, propertyKey) {
200
+ Reflect.defineMetadata("__structures-precision__" /* Precision */, new PrecisionConfig(precisionType), target, propertyKey);
201
+ };
202
+ }
203
+ function Query(statements) {
204
+ return function(target, key, descriptor) {
205
+ Reflect.defineMetadata("__structures-query__" /* Query */, statements, target, key);
206
+ return descriptor;
207
+ };
208
+ }
209
+ function Role(_roles) {
210
+ return function(_target, _propertyKey, _descriptor) {};
211
+ }
212
+ function Text(target, propertyKey) {
213
+ Reflect.defineMetadata("__structures-text__" /* Text */, {}, target, propertyKey);
214
+ }
215
+ function TimeReference(_target, _propertyKey) {}
216
+ function Version(_target, _propertyKey) {}
217
+ function TenantId(_target, _propertyKey) {}
218
+ // packages/persistence/src/api/idl/EntityServiceDecorator.ts
219
+ var import_idl = require("@kinotic-ai/idl");
220
+
221
+ class EntityServiceDecorator extends import_idl.C3Decorator {
222
+ }
223
+ // packages/persistence/src/api/idl/EntityServiceDecoratorsDecorator.ts
224
+ var import_idl2 = require("@kinotic-ai/idl");
225
+
226
+ class EntityServiceDecoratorsDecorator extends import_idl2.C3Decorator {
227
+ config;
228
+ constructor() {
229
+ super();
230
+ this.type = "EntityServiceDecoratorsDecorator";
231
+ }
232
+ }
233
+ // packages/persistence/src/api/idl/EsIndexConfigurationData.ts
234
+ class EsIndexConfigurationData {
235
+ componentTemplates = [];
236
+ }
116
237
  // packages/persistence/src/api/IEntitiesService.ts
117
238
  var import_core = require("@kinotic-ai/core");
118
239
 
@@ -233,64 +354,64 @@ class AdminEntitiesService {
233
354
  // packages/persistence/src/api/IEntityService.ts
234
355
  var import_core3 = require("@kinotic-ai/core");
235
356
  class EntityService {
236
- structureApplicationId;
237
- structureName;
238
- structureId;
357
+ entityApplicationId;
358
+ entityName;
359
+ entityId;
239
360
  entitiesService;
240
361
  constructor(structureApplicationId, structureName, entitiesService) {
241
- this.structureApplicationId = structureApplicationId;
242
- this.structureName = structureName;
243
- this.structureId = (structureApplicationId + "." + structureName).toLowerCase();
362
+ this.entityApplicationId = structureApplicationId;
363
+ this.entityName = structureName;
364
+ this.entityId = (structureApplicationId + "." + structureName).toLowerCase();
244
365
  this.entitiesService = entitiesService ?? new EntitiesService(import_core3.Kinotic);
245
366
  }
246
367
  async bulkSave(entities) {
247
368
  const entitiesToSave = await this.beforeBulkSaveOrUpdate(entities);
248
- return this.entitiesService.bulkSave(this.structureId, entitiesToSave);
369
+ return this.entitiesService.bulkSave(this.entityId, entitiesToSave);
249
370
  }
250
371
  async bulkUpdate(entities) {
251
372
  const entitiesToSave = await this.beforeBulkSaveOrUpdate(entities);
252
- return this.entitiesService.bulkUpdate(this.structureId, entitiesToSave);
373
+ return this.entitiesService.bulkUpdate(this.entityId, entitiesToSave);
253
374
  }
254
375
  count() {
255
- return this.entitiesService.count(this.structureId);
376
+ return this.entitiesService.count(this.entityId);
256
377
  }
257
378
  countByQuery(query) {
258
- return this.entitiesService.countByQuery(this.structureId, query);
379
+ return this.entitiesService.countByQuery(this.entityId, query);
259
380
  }
260
381
  deleteById(id) {
261
- return this.entitiesService.deleteById(this.structureId, id);
382
+ return this.entitiesService.deleteById(this.entityId, id);
262
383
  }
263
384
  deleteByQuery(query) {
264
- return this.entitiesService.deleteByQuery(this.structureId, query);
385
+ return this.entitiesService.deleteByQuery(this.entityId, query);
265
386
  }
266
387
  findAll(pageable) {
267
- return this.entitiesService.findAll(this.structureId, pageable);
388
+ return this.entitiesService.findAll(this.entityId, pageable);
268
389
  }
269
390
  findById(id) {
270
- return this.entitiesService.findById(this.structureId, id);
391
+ return this.entitiesService.findById(this.entityId, id);
271
392
  }
272
393
  findByIds(ids) {
273
- return this.entitiesService.findByIds(this.structureId, ids);
394
+ return this.entitiesService.findByIds(this.entityId, ids);
274
395
  }
275
396
  namedQuery(queryName, queryParameters) {
276
- return this.entitiesService.namedQuery(this.structureId, queryName, queryParameters);
397
+ return this.entitiesService.namedQuery(this.entityId, queryName, queryParameters);
277
398
  }
278
399
  namedQueryPage(queryName, queryParameters, pageable) {
279
- return this.entitiesService.namedQueryPage(this.structureId, queryName, queryParameters, pageable);
400
+ return this.entitiesService.namedQueryPage(this.entityId, queryName, queryParameters, pageable);
280
401
  }
281
402
  async save(entity) {
282
403
  const entityToSave = await this.beforeSaveOrUpdate(entity);
283
- return this.entitiesService.save(this.structureId, entityToSave);
404
+ return this.entitiesService.save(this.entityId, entityToSave);
284
405
  }
285
406
  search(searchText, pageable) {
286
- return this.entitiesService.search(this.structureId, searchText, pageable);
407
+ return this.entitiesService.search(this.entityId, searchText, pageable);
287
408
  }
288
409
  async syncIndex() {
289
- return this.entitiesService.syncIndex(this.structureId);
410
+ return this.entitiesService.syncIndex(this.entityId);
290
411
  }
291
412
  async update(entity) {
292
413
  const entityToSave = await this.beforeSaveOrUpdate(entity);
293
- return this.entitiesService.update(this.structureId, entityToSave);
414
+ return this.entitiesService.update(this.entityId, entityToSave);
294
415
  }
295
416
  async beforeBulkSaveOrUpdate(entities) {
296
417
  return Promise.resolve(entities);
@@ -302,45 +423,45 @@ class EntityService {
302
423
  // packages/persistence/src/api/IAdminEntityService.ts
303
424
  var import_core4 = require("@kinotic-ai/core");
304
425
  class AdminEntityService {
305
- structureApplicationId;
306
- structureName;
307
- structureId;
426
+ entityApplicationId;
427
+ entityName;
428
+ entityId;
308
429
  adminEntitiesService;
309
430
  constructor(structureApplicationId, structureName, adminEntitiesService) {
310
- this.structureApplicationId = structureApplicationId;
311
- this.structureName = structureName;
312
- this.structureId = (structureApplicationId + "." + structureName).toLowerCase();
431
+ this.entityApplicationId = structureApplicationId;
432
+ this.entityName = structureName;
433
+ this.entityId = (structureApplicationId + "." + structureName).toLowerCase();
313
434
  this.adminEntitiesService = adminEntitiesService ?? new AdminEntitiesService(import_core4.Kinotic);
314
435
  }
315
436
  count(tenantSelection) {
316
- return this.adminEntitiesService.count(this.structureId, tenantSelection);
437
+ return this.adminEntitiesService.count(this.entityId, tenantSelection);
317
438
  }
318
439
  countByQuery(query, tenantSelection) {
319
- return this.adminEntitiesService.countByQuery(this.structureId, query, tenantSelection);
440
+ return this.adminEntitiesService.countByQuery(this.entityId, query, tenantSelection);
320
441
  }
321
442
  deleteById(id) {
322
- return this.adminEntitiesService.deleteById(this.structureId, id);
443
+ return this.adminEntitiesService.deleteById(this.entityId, id);
323
444
  }
324
445
  deleteByQuery(query, tenantSelection) {
325
- return this.adminEntitiesService.deleteByQuery(this.structureId, query, tenantSelection);
446
+ return this.adminEntitiesService.deleteByQuery(this.entityId, query, tenantSelection);
326
447
  }
327
448
  findAll(tenantSelection, pageable) {
328
- return this.adminEntitiesService.findAll(this.structureId, tenantSelection, pageable);
449
+ return this.adminEntitiesService.findAll(this.entityId, tenantSelection, pageable);
329
450
  }
330
451
  findById(id) {
331
- return this.adminEntitiesService.findById(this.structureId, id);
452
+ return this.adminEntitiesService.findById(this.entityId, id);
332
453
  }
333
454
  findByIds(ids) {
334
- return this.adminEntitiesService.findByIds(this.structureId, ids);
455
+ return this.adminEntitiesService.findByIds(this.entityId, ids);
335
456
  }
336
457
  namedQuery(queryName, queryParameters) {
337
- return this.adminEntitiesService.namedQuery(this.structureId, queryName, queryParameters);
458
+ return this.adminEntitiesService.namedQuery(this.entityId, queryName, queryParameters);
338
459
  }
339
460
  namedQueryPage(queryName, queryParameters, pageable) {
340
- return this.adminEntitiesService.namedQueryPage(this.structureId, queryName, queryParameters, pageable);
461
+ return this.adminEntitiesService.namedQueryPage(this.entityId, queryName, queryParameters, pageable);
341
462
  }
342
463
  search(searchText, tenantSelection, pageable) {
343
- return this.adminEntitiesService.search(this.structureId, searchText, tenantSelection, pageable);
464
+ return this.adminEntitiesService.search(this.entityId, searchText, tenantSelection, pageable);
344
465
  }
345
466
  }
346
467
  // packages/persistence/src/api/PersistencePlugin.ts
package/dist/index.d.cts CHANGED
@@ -27,6 +27,64 @@ declare class TenantSpecificId {
27
27
  tenantId: string;
28
28
  constructor(entityId: string, tenantId: string);
29
29
  }
30
+ declare enum EntityType {
31
+ /**
32
+ * This is the default type of entity. It is a basic single table entity.
33
+ */
34
+ TABLE = 0,
35
+ /**
36
+ * This entity is a stream entity. It is used for streaming data.
37
+ */
38
+ STREAM = 1
39
+ }
40
+ /**
41
+ * Provides configuration for the Elasticsearch index.
42
+ * This can be used to override the default index settings and mappings used by Structures.
43
+ */
44
+ declare class EsIndexConfigurationData {
45
+ /**
46
+ * The Elasticsearch component templates to use when creating this index.
47
+ */
48
+ componentTemplates: string[];
49
+ }
50
+ /**
51
+ * MultiTenancyType is an enum that represents the different types of multi-tenancy that can be applied to an entity.
52
+ */
53
+ declare enum MultiTenancyType {
54
+ /**
55
+ * Default, no multi-tenancy
56
+ */
57
+ NONE = 0,
58
+ /**
59
+ * Shared table multi-tenancy
60
+ */
61
+ SHARED = 1
62
+ }
63
+ /**
64
+ * The {@link PrecisionType} enum is used to define the precision of a numeric field in the Continuum IDL.
65
+ */
66
+ declare enum PrecisionType {
67
+ /**
68
+ * A double-precision 64-bit IEEE 754 floating point number, restricted to finite values.
69
+ */
70
+ DOUBLE = 0,
71
+ /**
72
+ * A single-precision 32-bit IEEE 754 floating point number, restricted to finite values.
73
+ */
74
+ FLOAT = 1,
75
+ /**
76
+ * A signed 32-bit integer with a minimum value of -231 and a maximum value of 231-1.
77
+ */
78
+ INT = 2,
79
+ /**
80
+ * A signed 64-bit integer with a minimum value of -263 and a maximum value of 263-1.
81
+ */
82
+ LONG = 3,
83
+ /**
84
+ * A signed 16-bit integer with a minimum value of -32,768 and a maximum value of 32,767.
85
+ */
86
+ SHORT = 4
87
+ }
30
88
  import { C3Decorator } from "@kinotic-ai/idl";
31
89
  /**
32
90
  * This class denotes {@link C3Decorator} that can be applied to an {@link EntityService} using the {@link EntityServiceDecoratorsDecorator}
@@ -205,18 +263,18 @@ declare class EntitiesService implements IEntitiesService {
205
263
  */
206
264
  interface IEntityService<T> {
207
265
  /**
208
- * The applicationId of the structure this service is for
266
+ * The applicationId of the Entity this service is for
209
267
  */
210
- structureApplicationId: string;
268
+ entityApplicationId: string;
211
269
  /**
212
- * The name of the structure this service is for
270
+ * The name of the Entity this service is for
213
271
  */
214
- structureName: string;
272
+ entityName: string;
215
273
  /**
216
- * The id of the structure this service is for
274
+ * The id of the Entity this service is for
217
275
  * Which is the applicationId + '.' + name
218
276
  */
219
- structureId: string;
277
+ entityId: string;
220
278
  /**
221
279
  * Saves all given entities.
222
280
  * @param entities all the entities to save
@@ -334,9 +392,9 @@ interface IEntityService<T> {
334
392
  * It provides the basic CRUD operations for entities.
335
393
  */
336
394
  declare class EntityService<T> implements IEntityService<T> {
337
- structureApplicationId: string;
338
- structureName: string;
339
- structureId: string;
395
+ entityApplicationId: string;
396
+ entityName: string;
397
+ entityId: string;
340
398
  private readonly entitiesService;
341
399
  constructor(structureApplicationId: string, structureName: string, entitiesService?: IEntitiesService);
342
400
  bulkSave(entities: T[]): Promise<void>;
@@ -370,71 +428,88 @@ type DecoratedFunction = FilteredMethods<IEntityService<any>> | "allCreate" | "a
370
428
  * This is a map of method names to an array of decorators that should be applied to that method
371
429
  */
372
430
  type EntityServiceDecoratorsConfig = Partial<Record<DecoratedFunction, EntityServiceDecorator[]>>;
373
- import { C3Decorator as C3Decorator2 } from "@kinotic-ai/idl";
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
+ }
374
444
  /**
375
- * Provides a way to add decorators to an entity service
445
+ * Signifies that a property is an auto-generated ID for the entity.
376
446
  */
377
- declare class EntityServiceDecoratorsDecorator extends C3Decorator2 {
378
- config: EntityServiceDecoratorsConfig;
379
- constructor();
447
+ declare function AutoGeneratedId(target: any, propertyKey: string): void;
448
+ declare class DiscriminatorConfig {
449
+ propertyName: string;
450
+ constructor(propertyName: string);
380
451
  }
381
- declare enum EntityType {
382
- /**
383
- * This is the default type of entity. It is a basic single table entity.
384
- */
385
- TABLE = 0,
386
- /**
387
- * This entity is a stream entity. It is used for streaming data.
388
- */
389
- STREAM = 1
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);
390
462
  }
391
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
+ /**
392
476
  * Provides configuration for the Elasticsearch index.
393
477
  * This can be used to override the default index settings and mappings used by Structures.
394
478
  */
395
- declare class EsIndexConfigurationData {
396
- /**
397
- * The Elasticsearch component templates to use when creating this index.
398
- */
399
- componentTemplates: string[];
400
- }
479
+ declare function EsIndexConfiguration(_value: EsIndexConfigurationData): (_constructor: Function) => void;
480
+ declare function Flattened(target: any, propertyKey: string): void;
401
481
  /**
402
- * MultiTenancyType is an enum that represents the different types of multi-tenancy that can be applied to an entity.
482
+ * Signifies that a property is the ID of the entity.
403
483
  */
404
- declare enum MultiTenancyType {
405
- /**
406
- * Default, no multi-tenancy
407
- */
408
- NONE = 0,
409
- /**
410
- * Shared table multi-tenancy
411
- */
412
- SHARED = 1
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);
413
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;
414
500
  /**
415
- * The {@link PrecisionType} enum is used to define the precision of a numeric field in the Continuum IDL.
501
+ * This is used for data streams to signify the field that should be used as the time reference.
416
502
  */
417
- declare enum PrecisionType {
418
- /**
419
- * A double-precision 64-bit IEEE 754 floating point number, restricted to finite values.
420
- */
421
- DOUBLE = 0,
422
- /**
423
- * A single-precision 32-bit IEEE 754 floating point number, restricted to finite values.
424
- */
425
- FLOAT = 1,
426
- /**
427
- * A signed 32-bit integer with a minimum value of -231 and a maximum value of 231-1.
428
- */
429
- INT = 2,
430
- /**
431
- * A signed 64-bit integer with a minimum value of -263 and a maximum value of 263-1.
432
- */
433
- LONG = 3,
434
- /**
435
- * A signed 16-bit integer with a minimum value of -32,768 and a maximum value of 32,767.
436
- */
437
- SHORT = 4
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();
438
513
  }
439
514
  import { IKinotic as IKinotic2 } from "@kinotic-ai/core";
440
515
  import { IServiceProxy as IServiceProxy2, Page as Page2, Pageable as Pageable3, IterablePage as IterablePage3 } from "@kinotic-ai/core";
@@ -554,18 +629,18 @@ import { Pageable as Pageable4, IterablePage as IterablePage4 } from "@kinotic-a
554
629
  */
555
630
  interface IAdminEntityService<T> {
556
631
  /**
557
- * The application id of the structure this service is for
632
+ * The application id of the Entity this service is for
558
633
  */
559
- structureApplicationId: string;
634
+ entityApplicationId: string;
560
635
  /**
561
- * The name of the structure this service is for
636
+ * The name of the Entity this service is for
562
637
  */
563
- structureName: string;
638
+ entityName: string;
564
639
  /**
565
- * The id of the structure this service is for
640
+ * The id of the Entity this service is for
566
641
  * Which is the applicationId + '.' + name
567
642
  */
568
- structureId: string;
643
+ entityId: string;
569
644
  /**
570
645
  * Returns the number of entities available.
571
646
  *
@@ -652,9 +727,9 @@ interface IAdminEntityService<T> {
652
727
  * It provides the basic CRUD operations for entities with multi-tenancy support.
653
728
  */
654
729
  declare class AdminEntityService<T> implements IAdminEntityService<T> {
655
- structureApplicationId: string;
656
- structureName: string;
657
- structureId: string;
730
+ entityApplicationId: string;
731
+ entityName: string;
732
+ entityId: string;
658
733
  private readonly adminEntitiesService;
659
734
  constructor(structureApplicationId: string, structureName: string, adminEntitiesService?: IAdminEntitiesService);
660
735
  count(tenantSelection: TenantSelection): Promise<number>;
@@ -678,4 +753,4 @@ import { Kinotic, KinoticSingleton as KinoticSingleton2, IKinotic as IKinotic3,
678
753
  declare module "@kinotic-ai/core" {
679
754
  interface KinoticSingleton extends IPersistenceExtension {}
680
755
  }
681
- export { TenantSpecificId, TenantSelection, QueryParameter, QueryOptions, PrecisionType, PersistencePlugin, MultiTenancyType, KinoticSingleton2 as KinoticSingleton, KinoticPlugin2 as KinoticPlugin, Kinotic, IPersistenceExtension, IKinotic3 as IKinotic, IEntityService, IEntitiesService, IAdminEntityService, IAdminEntitiesService, EsIndexConfigurationData, EntityType, EntityServiceDecoratorsDecorator, EntityServiceDecoratorsConfig, EntityServiceDecorator, EntityService, EntitiesService, DecoratedFunction, AdminEntityService, AdminEntitiesService };
756
+ export { Version, TimeReference, Text, TenantSpecificId, TenantSelection, TenantId, Role, QueryParameter, QueryOptions, Query, PrecisionType, PrecisionConfig, Precision, Policy, PersistencePlugin, NotNull, NotIndexed, Nested, MultiTenancyType, KinoticSingleton2 as KinoticSingleton, KinoticPlugin2 as KinoticPlugin, KinoticPersistenceDecorator, Kinotic, Id, IPersistenceExtension, IKinotic3 as IKinotic, IEntityService, IEntitiesService, IAdminEntityService, IAdminEntitiesService, Flattened, EsIndexConfigurationData, EsIndexConfiguration, EntityType, EntityServiceDecoratorsDecorator, EntityServiceDecoratorsConfig, EntityServiceDecorators, EntityServiceDecorator, EntityService, EntityConfig, Entity, EntitiesService, DiscriminatorConfig, Discriminator, DecoratedFunction, AutoGeneratedId, AdminEntityService, AdminEntitiesService };
package/dist/index.d.ts CHANGED
@@ -27,6 +27,64 @@ declare class TenantSpecificId {
27
27
  tenantId: string;
28
28
  constructor(entityId: string, tenantId: string);
29
29
  }
30
+ declare enum EntityType {
31
+ /**
32
+ * This is the default type of entity. It is a basic single table entity.
33
+ */
34
+ TABLE = 0,
35
+ /**
36
+ * This entity is a stream entity. It is used for streaming data.
37
+ */
38
+ STREAM = 1
39
+ }
40
+ /**
41
+ * Provides configuration for the Elasticsearch index.
42
+ * This can be used to override the default index settings and mappings used by Structures.
43
+ */
44
+ declare class EsIndexConfigurationData {
45
+ /**
46
+ * The Elasticsearch component templates to use when creating this index.
47
+ */
48
+ componentTemplates: string[];
49
+ }
50
+ /**
51
+ * MultiTenancyType is an enum that represents the different types of multi-tenancy that can be applied to an entity.
52
+ */
53
+ declare enum MultiTenancyType {
54
+ /**
55
+ * Default, no multi-tenancy
56
+ */
57
+ NONE = 0,
58
+ /**
59
+ * Shared table multi-tenancy
60
+ */
61
+ SHARED = 1
62
+ }
63
+ /**
64
+ * The {@link PrecisionType} enum is used to define the precision of a numeric field in the Continuum IDL.
65
+ */
66
+ declare enum PrecisionType {
67
+ /**
68
+ * A double-precision 64-bit IEEE 754 floating point number, restricted to finite values.
69
+ */
70
+ DOUBLE = 0,
71
+ /**
72
+ * A single-precision 32-bit IEEE 754 floating point number, restricted to finite values.
73
+ */
74
+ FLOAT = 1,
75
+ /**
76
+ * A signed 32-bit integer with a minimum value of -231 and a maximum value of 231-1.
77
+ */
78
+ INT = 2,
79
+ /**
80
+ * A signed 64-bit integer with a minimum value of -263 and a maximum value of 263-1.
81
+ */
82
+ LONG = 3,
83
+ /**
84
+ * A signed 16-bit integer with a minimum value of -32,768 and a maximum value of 32,767.
85
+ */
86
+ SHORT = 4
87
+ }
30
88
  import { C3Decorator } from "@kinotic-ai/idl";
31
89
  /**
32
90
  * This class denotes {@link C3Decorator} that can be applied to an {@link EntityService} using the {@link EntityServiceDecoratorsDecorator}
@@ -205,18 +263,18 @@ declare class EntitiesService implements IEntitiesService {
205
263
  */
206
264
  interface IEntityService<T> {
207
265
  /**
208
- * The applicationId of the structure this service is for
266
+ * The applicationId of the Entity this service is for
209
267
  */
210
- structureApplicationId: string;
268
+ entityApplicationId: string;
211
269
  /**
212
- * The name of the structure this service is for
270
+ * The name of the Entity this service is for
213
271
  */
214
- structureName: string;
272
+ entityName: string;
215
273
  /**
216
- * The id of the structure this service is for
274
+ * The id of the Entity this service is for
217
275
  * Which is the applicationId + '.' + name
218
276
  */
219
- structureId: string;
277
+ entityId: string;
220
278
  /**
221
279
  * Saves all given entities.
222
280
  * @param entities all the entities to save
@@ -334,9 +392,9 @@ interface IEntityService<T> {
334
392
  * It provides the basic CRUD operations for entities.
335
393
  */
336
394
  declare class EntityService<T> implements IEntityService<T> {
337
- structureApplicationId: string;
338
- structureName: string;
339
- structureId: string;
395
+ entityApplicationId: string;
396
+ entityName: string;
397
+ entityId: string;
340
398
  private readonly entitiesService;
341
399
  constructor(structureApplicationId: string, structureName: string, entitiesService?: IEntitiesService);
342
400
  bulkSave(entities: T[]): Promise<void>;
@@ -370,71 +428,88 @@ type DecoratedFunction = FilteredMethods<IEntityService<any>> | "allCreate" | "a
370
428
  * This is a map of method names to an array of decorators that should be applied to that method
371
429
  */
372
430
  type EntityServiceDecoratorsConfig = Partial<Record<DecoratedFunction, EntityServiceDecorator[]>>;
373
- import { C3Decorator as C3Decorator2 } from "@kinotic-ai/idl";
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
+ }
374
444
  /**
375
- * Provides a way to add decorators to an entity service
445
+ * Signifies that a property is an auto-generated ID for the entity.
376
446
  */
377
- declare class EntityServiceDecoratorsDecorator extends C3Decorator2 {
378
- config: EntityServiceDecoratorsConfig;
379
- constructor();
447
+ declare function AutoGeneratedId(target: any, propertyKey: string): void;
448
+ declare class DiscriminatorConfig {
449
+ propertyName: string;
450
+ constructor(propertyName: string);
380
451
  }
381
- declare enum EntityType {
382
- /**
383
- * This is the default type of entity. It is a basic single table entity.
384
- */
385
- TABLE = 0,
386
- /**
387
- * This entity is a stream entity. It is used for streaming data.
388
- */
389
- STREAM = 1
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);
390
462
  }
391
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
+ /**
392
476
  * Provides configuration for the Elasticsearch index.
393
477
  * This can be used to override the default index settings and mappings used by Structures.
394
478
  */
395
- declare class EsIndexConfigurationData {
396
- /**
397
- * The Elasticsearch component templates to use when creating this index.
398
- */
399
- componentTemplates: string[];
400
- }
479
+ declare function EsIndexConfiguration(_value: EsIndexConfigurationData): (_constructor: Function) => void;
480
+ declare function Flattened(target: any, propertyKey: string): void;
401
481
  /**
402
- * MultiTenancyType is an enum that represents the different types of multi-tenancy that can be applied to an entity.
482
+ * Signifies that a property is the ID of the entity.
403
483
  */
404
- declare enum MultiTenancyType {
405
- /**
406
- * Default, no multi-tenancy
407
- */
408
- NONE = 0,
409
- /**
410
- * Shared table multi-tenancy
411
- */
412
- SHARED = 1
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);
413
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;
414
500
  /**
415
- * The {@link PrecisionType} enum is used to define the precision of a numeric field in the Continuum IDL.
501
+ * This is used for data streams to signify the field that should be used as the time reference.
416
502
  */
417
- declare enum PrecisionType {
418
- /**
419
- * A double-precision 64-bit IEEE 754 floating point number, restricted to finite values.
420
- */
421
- DOUBLE = 0,
422
- /**
423
- * A single-precision 32-bit IEEE 754 floating point number, restricted to finite values.
424
- */
425
- FLOAT = 1,
426
- /**
427
- * A signed 32-bit integer with a minimum value of -231 and a maximum value of 231-1.
428
- */
429
- INT = 2,
430
- /**
431
- * A signed 64-bit integer with a minimum value of -263 and a maximum value of 263-1.
432
- */
433
- LONG = 3,
434
- /**
435
- * A signed 16-bit integer with a minimum value of -32,768 and a maximum value of 32,767.
436
- */
437
- SHORT = 4
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();
438
513
  }
439
514
  import { IKinotic as IKinotic2 } from "@kinotic-ai/core";
440
515
  import { IServiceProxy as IServiceProxy2, Page as Page2, Pageable as Pageable3, IterablePage as IterablePage3 } from "@kinotic-ai/core";
@@ -554,18 +629,18 @@ import { Pageable as Pageable4, IterablePage as IterablePage4 } from "@kinotic-a
554
629
  */
555
630
  interface IAdminEntityService<T> {
556
631
  /**
557
- * The application id of the structure this service is for
632
+ * The application id of the Entity this service is for
558
633
  */
559
- structureApplicationId: string;
634
+ entityApplicationId: string;
560
635
  /**
561
- * The name of the structure this service is for
636
+ * The name of the Entity this service is for
562
637
  */
563
- structureName: string;
638
+ entityName: string;
564
639
  /**
565
- * The id of the structure this service is for
640
+ * The id of the Entity this service is for
566
641
  * Which is the applicationId + '.' + name
567
642
  */
568
- structureId: string;
643
+ entityId: string;
569
644
  /**
570
645
  * Returns the number of entities available.
571
646
  *
@@ -652,9 +727,9 @@ interface IAdminEntityService<T> {
652
727
  * It provides the basic CRUD operations for entities with multi-tenancy support.
653
728
  */
654
729
  declare class AdminEntityService<T> implements IAdminEntityService<T> {
655
- structureApplicationId: string;
656
- structureName: string;
657
- structureId: string;
730
+ entityApplicationId: string;
731
+ entityName: string;
732
+ entityId: string;
658
733
  private readonly adminEntitiesService;
659
734
  constructor(structureApplicationId: string, structureName: string, adminEntitiesService?: IAdminEntitiesService);
660
735
  count(tenantSelection: TenantSelection): Promise<number>;
@@ -678,4 +753,4 @@ import { Kinotic, KinoticSingleton as KinoticSingleton2, IKinotic as IKinotic3,
678
753
  declare module "@kinotic-ai/core" {
679
754
  interface KinoticSingleton extends IPersistenceExtension {}
680
755
  }
681
- export { TenantSpecificId, TenantSelection, QueryParameter, QueryOptions, PrecisionType, PersistencePlugin, MultiTenancyType, KinoticSingleton2 as KinoticSingleton, KinoticPlugin2 as KinoticPlugin, Kinotic, IPersistenceExtension, IKinotic3 as IKinotic, IEntityService, IEntitiesService, IAdminEntityService, IAdminEntitiesService, EsIndexConfigurationData, EntityType, EntityServiceDecoratorsDecorator, EntityServiceDecoratorsConfig, EntityServiceDecorator, EntityService, EntitiesService, DecoratedFunction, AdminEntityService, AdminEntitiesService };
756
+ export { Version, TimeReference, Text, TenantSpecificId, TenantSelection, TenantId, Role, QueryParameter, QueryOptions, Query, PrecisionType, PrecisionConfig, Precision, Policy, PersistencePlugin, NotNull, NotIndexed, Nested, MultiTenancyType, KinoticSingleton2 as KinoticSingleton, KinoticPlugin2 as KinoticPlugin, KinoticPersistenceDecorator, Kinotic, Id, IPersistenceExtension, IKinotic3 as IKinotic, IEntityService, IEntitiesService, IAdminEntityService, IAdminEntitiesService, Flattened, EsIndexConfigurationData, EsIndexConfiguration, EntityType, EntityServiceDecoratorsDecorator, EntityServiceDecoratorsConfig, EntityServiceDecorators, EntityServiceDecorator, EntityService, EntityConfig, Entity, EntitiesService, DiscriminatorConfig, Discriminator, DecoratedFunction, AutoGeneratedId, AdminEntityService, AdminEntitiesService };
package/dist/index.js CHANGED
@@ -13,37 +13,23 @@ class TenantSpecificId {
13
13
  this.tenantId = tenantId;
14
14
  }
15
15
  }
16
- // packages/persistence/src/api/idl/EntityServiceDecorator.ts
17
- import { C3Decorator } from "@kinotic-ai/idl";
16
+ // packages/persistence/src/api/KinoticPersistenceDecorators.ts
17
+ import"reflect-metadata";
18
18
 
19
- class EntityServiceDecorator extends C3Decorator {
20
- }
21
- // packages/persistence/src/api/idl/EntityServiceDecoratorsDecorator.ts
22
- import { C3Decorator as C3Decorator2 } from "@kinotic-ai/idl";
23
-
24
- class EntityServiceDecoratorsDecorator extends C3Decorator2 {
25
- config;
26
- constructor() {
27
- super();
28
- this.type = "EntityServiceDecoratorsDecorator";
29
- }
30
- }
31
19
  // packages/persistence/src/api/idl/EntityType.ts
32
20
  var EntityType;
33
21
  ((EntityType2) => {
34
22
  EntityType2[EntityType2["TABLE"] = 0] = "TABLE";
35
23
  EntityType2[EntityType2["STREAM"] = 1] = "STREAM";
36
24
  })(EntityType ||= {});
37
- // packages/persistence/src/api/idl/EsIndexConfigurationData.ts
38
- class EsIndexConfigurationData {
39
- componentTemplates = [];
40
- }
25
+
41
26
  // packages/persistence/src/api/idl/MultiTenancyType.ts
42
27
  var MultiTenancyType;
43
28
  ((MultiTenancyType2) => {
44
29
  MultiTenancyType2[MultiTenancyType2["NONE"] = 0] = "NONE";
45
30
  MultiTenancyType2[MultiTenancyType2["SHARED"] = 1] = "SHARED";
46
31
  })(MultiTenancyType ||= {});
32
+
47
33
  // packages/persistence/src/api/idl/PrecisionType.ts
48
34
  var PrecisionType;
49
35
  ((PrecisionType2) => {
@@ -53,6 +39,119 @@ var PrecisionType;
53
39
  PrecisionType2[PrecisionType2["LONG"] = 3] = "LONG";
54
40
  PrecisionType2[PrecisionType2["SHORT"] = 4] = "SHORT";
55
41
  })(PrecisionType ||= {});
42
+
43
+ // packages/persistence/src/api/KinoticPersistenceDecorators.ts
44
+ var KinoticPersistenceDecorator;
45
+ ((KinoticPersistenceDecorator2) => {
46
+ KinoticPersistenceDecorator2["Entity"] = "__structures-entity__";
47
+ KinoticPersistenceDecorator2["Id"] = "__structures-id__";
48
+ KinoticPersistenceDecorator2["AutoGeneratedId"] = "__structures-auto-generated-id__";
49
+ KinoticPersistenceDecorator2["Flattened"] = "__structures-flattened__";
50
+ KinoticPersistenceDecorator2["Nested"] = "__structures-nested__";
51
+ KinoticPersistenceDecorator2["Text"] = "__structures-text__";
52
+ KinoticPersistenceDecorator2["NotNull"] = "__structures-notnull__";
53
+ KinoticPersistenceDecorator2["Precision"] = "__structures-precision__";
54
+ KinoticPersistenceDecorator2["Discriminator"] = "__structures-discriminator__";
55
+ KinoticPersistenceDecorator2["Query"] = "__structures-query__";
56
+ KinoticPersistenceDecorator2["EntityServiceDecorators"] = "__structures-entity-service-decorators__";
57
+ })(KinoticPersistenceDecorator ||= {});
58
+ function AutoGeneratedId(target, propertyKey) {
59
+ Reflect.defineMetadata("__structures-auto-generated-id__" /* AutoGeneratedId */, {}, target, propertyKey);
60
+ }
61
+
62
+ class DiscriminatorConfig {
63
+ propertyName;
64
+ constructor(propertyName) {
65
+ this.propertyName = propertyName;
66
+ }
67
+ }
68
+ function Discriminator(propertyName) {
69
+ return function(target, propertyKey) {
70
+ Reflect.defineMetadata("__structures-discriminator__" /* Discriminator */, new DiscriminatorConfig(propertyName), target, propertyKey);
71
+ };
72
+ }
73
+
74
+ class EntityConfig {
75
+ multiTenancyType;
76
+ entityType;
77
+ constructor(multiTenancyType, entityType = 0 /* TABLE */) {
78
+ this.multiTenancyType = multiTenancyType;
79
+ this.entityType = entityType;
80
+ }
81
+ }
82
+ function Entity(multiTenancyType = 0 /* NONE */, entityType = 0 /* TABLE */) {
83
+ return function(constructor) {
84
+ Reflect.defineMetadata("__structures-entity__" /* Entity */, new EntityConfig(multiTenancyType, entityType), constructor);
85
+ };
86
+ }
87
+ function EntityServiceDecorators(_config) {
88
+ return function(_constructor) {};
89
+ }
90
+ function EsIndexConfiguration(_value) {
91
+ return function(_constructor) {};
92
+ }
93
+ function Flattened(target, propertyKey) {
94
+ Reflect.defineMetadata("__structures-flattened__" /* Flattened */, {}, target, propertyKey);
95
+ }
96
+ function Id(target, propertyKey) {
97
+ Reflect.defineMetadata("__structures-id__" /* Id */, {}, target, propertyKey);
98
+ }
99
+ function Nested(target, propertyKey) {
100
+ Reflect.defineMetadata("__structures-nested__" /* Nested */, {}, target, propertyKey);
101
+ }
102
+ function NotIndexed(_target, _propertyKey) {}
103
+ function NotNull(target, propertyKey) {
104
+ Reflect.defineMetadata("__structures-notnull__" /* NotNull */, {}, target, propertyKey);
105
+ }
106
+ function Policy(_policies) {
107
+ return function(_target, _propertyKey, _descriptor) {};
108
+ }
109
+
110
+ class PrecisionConfig {
111
+ precisionType;
112
+ constructor(precisionType) {
113
+ this.precisionType = precisionType;
114
+ }
115
+ }
116
+ function Precision(precisionType = 2 /* INT */) {
117
+ return function(target, propertyKey) {
118
+ Reflect.defineMetadata("__structures-precision__" /* Precision */, new PrecisionConfig(precisionType), target, propertyKey);
119
+ };
120
+ }
121
+ function Query(statements) {
122
+ return function(target, key, descriptor) {
123
+ Reflect.defineMetadata("__structures-query__" /* Query */, statements, target, key);
124
+ return descriptor;
125
+ };
126
+ }
127
+ function Role(_roles) {
128
+ return function(_target, _propertyKey, _descriptor) {};
129
+ }
130
+ function Text(target, propertyKey) {
131
+ Reflect.defineMetadata("__structures-text__" /* Text */, {}, target, propertyKey);
132
+ }
133
+ function TimeReference(_target, _propertyKey) {}
134
+ function Version(_target, _propertyKey) {}
135
+ function TenantId(_target, _propertyKey) {}
136
+ // packages/persistence/src/api/idl/EntityServiceDecorator.ts
137
+ import { C3Decorator } from "@kinotic-ai/idl";
138
+
139
+ class EntityServiceDecorator extends C3Decorator {
140
+ }
141
+ // packages/persistence/src/api/idl/EntityServiceDecoratorsDecorator.ts
142
+ import { C3Decorator as C3Decorator2 } from "@kinotic-ai/idl";
143
+
144
+ class EntityServiceDecoratorsDecorator extends C3Decorator2 {
145
+ config;
146
+ constructor() {
147
+ super();
148
+ this.type = "EntityServiceDecoratorsDecorator";
149
+ }
150
+ }
151
+ // packages/persistence/src/api/idl/EsIndexConfigurationData.ts
152
+ class EsIndexConfigurationData {
153
+ componentTemplates = [];
154
+ }
56
155
  // packages/persistence/src/api/IEntitiesService.ts
57
156
  import {
58
157
  FunctionalIterablePage
@@ -177,64 +276,64 @@ class AdminEntitiesService {
177
276
  // packages/persistence/src/api/IEntityService.ts
178
277
  import { Kinotic } from "@kinotic-ai/core";
179
278
  class EntityService {
180
- structureApplicationId;
181
- structureName;
182
- structureId;
279
+ entityApplicationId;
280
+ entityName;
281
+ entityId;
183
282
  entitiesService;
184
283
  constructor(structureApplicationId, structureName, entitiesService) {
185
- this.structureApplicationId = structureApplicationId;
186
- this.structureName = structureName;
187
- this.structureId = (structureApplicationId + "." + structureName).toLowerCase();
284
+ this.entityApplicationId = structureApplicationId;
285
+ this.entityName = structureName;
286
+ this.entityId = (structureApplicationId + "." + structureName).toLowerCase();
188
287
  this.entitiesService = entitiesService ?? new EntitiesService(Kinotic);
189
288
  }
190
289
  async bulkSave(entities) {
191
290
  const entitiesToSave = await this.beforeBulkSaveOrUpdate(entities);
192
- return this.entitiesService.bulkSave(this.structureId, entitiesToSave);
291
+ return this.entitiesService.bulkSave(this.entityId, entitiesToSave);
193
292
  }
194
293
  async bulkUpdate(entities) {
195
294
  const entitiesToSave = await this.beforeBulkSaveOrUpdate(entities);
196
- return this.entitiesService.bulkUpdate(this.structureId, entitiesToSave);
295
+ return this.entitiesService.bulkUpdate(this.entityId, entitiesToSave);
197
296
  }
198
297
  count() {
199
- return this.entitiesService.count(this.structureId);
298
+ return this.entitiesService.count(this.entityId);
200
299
  }
201
300
  countByQuery(query) {
202
- return this.entitiesService.countByQuery(this.structureId, query);
301
+ return this.entitiesService.countByQuery(this.entityId, query);
203
302
  }
204
303
  deleteById(id) {
205
- return this.entitiesService.deleteById(this.structureId, id);
304
+ return this.entitiesService.deleteById(this.entityId, id);
206
305
  }
207
306
  deleteByQuery(query) {
208
- return this.entitiesService.deleteByQuery(this.structureId, query);
307
+ return this.entitiesService.deleteByQuery(this.entityId, query);
209
308
  }
210
309
  findAll(pageable) {
211
- return this.entitiesService.findAll(this.structureId, pageable);
310
+ return this.entitiesService.findAll(this.entityId, pageable);
212
311
  }
213
312
  findById(id) {
214
- return this.entitiesService.findById(this.structureId, id);
313
+ return this.entitiesService.findById(this.entityId, id);
215
314
  }
216
315
  findByIds(ids) {
217
- return this.entitiesService.findByIds(this.structureId, ids);
316
+ return this.entitiesService.findByIds(this.entityId, ids);
218
317
  }
219
318
  namedQuery(queryName, queryParameters) {
220
- return this.entitiesService.namedQuery(this.structureId, queryName, queryParameters);
319
+ return this.entitiesService.namedQuery(this.entityId, queryName, queryParameters);
221
320
  }
222
321
  namedQueryPage(queryName, queryParameters, pageable) {
223
- return this.entitiesService.namedQueryPage(this.structureId, queryName, queryParameters, pageable);
322
+ return this.entitiesService.namedQueryPage(this.entityId, queryName, queryParameters, pageable);
224
323
  }
225
324
  async save(entity) {
226
325
  const entityToSave = await this.beforeSaveOrUpdate(entity);
227
- return this.entitiesService.save(this.structureId, entityToSave);
326
+ return this.entitiesService.save(this.entityId, entityToSave);
228
327
  }
229
328
  search(searchText, pageable) {
230
- return this.entitiesService.search(this.structureId, searchText, pageable);
329
+ return this.entitiesService.search(this.entityId, searchText, pageable);
231
330
  }
232
331
  async syncIndex() {
233
- return this.entitiesService.syncIndex(this.structureId);
332
+ return this.entitiesService.syncIndex(this.entityId);
234
333
  }
235
334
  async update(entity) {
236
335
  const entityToSave = await this.beforeSaveOrUpdate(entity);
237
- return this.entitiesService.update(this.structureId, entityToSave);
336
+ return this.entitiesService.update(this.entityId, entityToSave);
238
337
  }
239
338
  async beforeBulkSaveOrUpdate(entities) {
240
339
  return Promise.resolve(entities);
@@ -246,45 +345,45 @@ class EntityService {
246
345
  // packages/persistence/src/api/IAdminEntityService.ts
247
346
  import { Kinotic as Kinotic2 } from "@kinotic-ai/core";
248
347
  class AdminEntityService {
249
- structureApplicationId;
250
- structureName;
251
- structureId;
348
+ entityApplicationId;
349
+ entityName;
350
+ entityId;
252
351
  adminEntitiesService;
253
352
  constructor(structureApplicationId, structureName, adminEntitiesService) {
254
- this.structureApplicationId = structureApplicationId;
255
- this.structureName = structureName;
256
- this.structureId = (structureApplicationId + "." + structureName).toLowerCase();
353
+ this.entityApplicationId = structureApplicationId;
354
+ this.entityName = structureName;
355
+ this.entityId = (structureApplicationId + "." + structureName).toLowerCase();
257
356
  this.adminEntitiesService = adminEntitiesService ?? new AdminEntitiesService(Kinotic2);
258
357
  }
259
358
  count(tenantSelection) {
260
- return this.adminEntitiesService.count(this.structureId, tenantSelection);
359
+ return this.adminEntitiesService.count(this.entityId, tenantSelection);
261
360
  }
262
361
  countByQuery(query, tenantSelection) {
263
- return this.adminEntitiesService.countByQuery(this.structureId, query, tenantSelection);
362
+ return this.adminEntitiesService.countByQuery(this.entityId, query, tenantSelection);
264
363
  }
265
364
  deleteById(id) {
266
- return this.adminEntitiesService.deleteById(this.structureId, id);
365
+ return this.adminEntitiesService.deleteById(this.entityId, id);
267
366
  }
268
367
  deleteByQuery(query, tenantSelection) {
269
- return this.adminEntitiesService.deleteByQuery(this.structureId, query, tenantSelection);
368
+ return this.adminEntitiesService.deleteByQuery(this.entityId, query, tenantSelection);
270
369
  }
271
370
  findAll(tenantSelection, pageable) {
272
- return this.adminEntitiesService.findAll(this.structureId, tenantSelection, pageable);
371
+ return this.adminEntitiesService.findAll(this.entityId, tenantSelection, pageable);
273
372
  }
274
373
  findById(id) {
275
- return this.adminEntitiesService.findById(this.structureId, id);
374
+ return this.adminEntitiesService.findById(this.entityId, id);
276
375
  }
277
376
  findByIds(ids) {
278
- return this.adminEntitiesService.findByIds(this.structureId, ids);
377
+ return this.adminEntitiesService.findByIds(this.entityId, ids);
279
378
  }
280
379
  namedQuery(queryName, queryParameters) {
281
- return this.adminEntitiesService.namedQuery(this.structureId, queryName, queryParameters);
380
+ return this.adminEntitiesService.namedQuery(this.entityId, queryName, queryParameters);
282
381
  }
283
382
  namedQueryPage(queryName, queryParameters, pageable) {
284
- return this.adminEntitiesService.namedQueryPage(this.structureId, queryName, queryParameters, pageable);
383
+ return this.adminEntitiesService.namedQueryPage(this.entityId, queryName, queryParameters, pageable);
285
384
  }
286
385
  search(searchText, tenantSelection, pageable) {
287
- return this.adminEntitiesService.search(this.structureId, searchText, tenantSelection, pageable);
386
+ return this.adminEntitiesService.search(this.entityId, searchText, tenantSelection, pageable);
288
387
  }
289
388
  }
290
389
  // packages/persistence/src/api/PersistencePlugin.ts
@@ -300,19 +399,41 @@ var PersistencePlugin = {
300
399
  // packages/persistence/src/index.ts
301
400
  import { Kinotic as Kinotic3, KinoticSingleton } from "@kinotic-ai/core";
302
401
  export {
402
+ Version,
403
+ TimeReference,
404
+ Text,
303
405
  TenantSpecificId,
406
+ TenantId,
407
+ Role,
304
408
  QueryOptions,
409
+ Query,
305
410
  PrecisionType,
411
+ PrecisionConfig,
412
+ Precision,
413
+ Policy,
306
414
  PersistencePlugin,
415
+ NotNull,
416
+ NotIndexed,
417
+ Nested,
307
418
  MultiTenancyType,
308
419
  KinoticSingleton,
420
+ KinoticPersistenceDecorator,
309
421
  Kinotic3 as Kinotic,
422
+ Id,
423
+ Flattened,
310
424
  EsIndexConfigurationData,
425
+ EsIndexConfiguration,
311
426
  EntityType,
312
427
  EntityServiceDecoratorsDecorator,
428
+ EntityServiceDecorators,
313
429
  EntityServiceDecorator,
314
430
  EntityService,
431
+ EntityConfig,
432
+ Entity,
315
433
  EntitiesService,
434
+ DiscriminatorConfig,
435
+ Discriminator,
436
+ AutoGeneratedId,
316
437
  AdminEntityService,
317
438
  AdminEntitiesService
318
439
  };
package/package.json CHANGED
@@ -20,6 +20,7 @@
20
20
  },
21
21
  "./package.json": "./package.json"
22
22
  },
23
+ "homepage": "https://github.com/kinotic-ai/kinotic",
23
24
  "license": "Elastic License 2.0",
24
25
  "publishConfig": {
25
26
  "access": "public"
@@ -50,5 +51,5 @@
50
51
  "optional": true
51
52
  }
52
53
  },
53
- "version": "1.0.0"
54
+ "version": "1.0.2"
54
55
  }