@kinotic-ai/persistence 1.0.1 → 1.0.3

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");
78
-
79
- class EntityServiceDecorator extends import_idl.C3Decorator {
80
- }
81
- // packages/persistence/src/api/idl/EntityServiceDecoratorsDecorator.ts
82
- var import_idl2 = require("@kinotic-ai/idl");
98
+ // packages/persistence/src/api/KinoticPersistenceDecorators.ts
99
+ var import_reflect_metadata = require("reflect-metadata");
83
100
 
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
 
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}
@@ -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";
@@ -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}
@@ -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";
@@ -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";
18
-
19
- class EntityServiceDecorator extends C3Decorator {
20
- }
21
- // packages/persistence/src/api/idl/EntityServiceDecoratorsDecorator.ts
22
- import { C3Decorator as C3Decorator2 } from "@kinotic-ai/idl";
16
+ // packages/persistence/src/api/KinoticPersistenceDecorators.ts
17
+ import"reflect-metadata";
23
18
 
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
@@ -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.1"
54
+ "version": "1.0.3"
54
55
  }