@memberjunction/ai-vector-sync 1.8.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/index.d.ts +866 -5
  2. package/dist/index.js +4 -21
  3. package/dist/index.js.map +1 -1
  4. package/package.json +19 -14
  5. package/dist/config.d.ts +0 -13
  6. package/dist/config.d.ts.map +0 -1
  7. package/dist/config.js +0 -21
  8. package/dist/config.js.map +0 -1
  9. package/dist/constants.d.ts +0 -2
  10. package/dist/constants.d.ts.map +0 -1
  11. package/dist/constants.js +0 -5
  12. package/dist/constants.js.map +0 -1
  13. package/dist/db/db.d.ts +0 -4
  14. package/dist/db/db.d.ts.map +0 -1
  15. package/dist/db/db.js +0 -40
  16. package/dist/db/db.js.map +0 -1
  17. package/dist/db/dbAI.d.ts +0 -4
  18. package/dist/db/dbAI.d.ts.map +0 -1
  19. package/dist/db/dbAI.js +0 -18
  20. package/dist/db/dbAI.js.map +0 -1
  21. package/dist/generic/EntityDocumentTemplateParser.d.ts +0 -18
  22. package/dist/generic/EntityDocumentTemplateParser.d.ts.map +0 -1
  23. package/dist/generic/EntityDocumentTemplateParser.js +0 -145
  24. package/dist/generic/EntityDocumentTemplateParser.js.map +0 -1
  25. package/dist/generic/entitySyncConfig.types.d.ts +0 -11
  26. package/dist/generic/entitySyncConfig.types.d.ts.map +0 -1
  27. package/dist/generic/entitySyncConfig.types.js +0 -3
  28. package/dist/generic/entitySyncConfig.types.js.map +0 -1
  29. package/dist/generic/vectorSync.types.d.ts +0 -12
  30. package/dist/generic/vectorSync.types.d.ts.map +0 -1
  31. package/dist/generic/vectorSync.types.js +0 -3
  32. package/dist/generic/vectorSync.types.js.map +0 -1
  33. package/dist/index.d.ts.map +0 -1
  34. package/dist/models/EntityDocumentCache.d.ts +0 -19
  35. package/dist/models/EntityDocumentCache.d.ts.map +0 -1
  36. package/dist/models/EntityDocumentCache.js +0 -62
  37. package/dist/models/EntityDocumentCache.js.map +0 -1
  38. package/dist/models/entityVectorSync.d.ts +0 -26
  39. package/dist/models/entityVectorSync.d.ts.map +0 -1
  40. package/dist/models/entityVectorSync.js +0 -234
  41. package/dist/models/entityVectorSync.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,5 +1,866 @@
1
- export * from './generic/vectorSync.types';
2
- export * from './generic/entitySyncConfig.types';
3
- export * from './models/entityVectorSync';
4
- export * from './generic/EntityDocumentTemplateParser';
5
- //# sourceMappingURL=index.d.ts.map
1
+ import { RunViewParams, BaseEntity, UserInfo, EntityField, EntityInfo } from '@memberjunction/core';
2
+ import { EmbedTextsResult, Embeddings } from '@memberjunction/ai';
3
+ import { VectorDBBase } from '@memberjunction/ai-vectordb';
4
+ import { VectorBase } from '@memberjunction/ai-vectors';
5
+ import { TemplateEntityExtended } from '@memberjunction/templates-base-types';
6
+
7
+ type VectorSyncRequest = {
8
+ entityID: string;
9
+ entityDocumentID?: string;
10
+ batchCount?: number;
11
+ options?: any;
12
+ };
13
+ type vectorSyncResponse = {
14
+ success: boolean;
15
+ status: string;
16
+ errorMessage: string;
17
+ };
18
+ type EmbeddingData = {
19
+ ID: number;
20
+ Vector: number[];
21
+ VectorID?: unknown;
22
+ EntityData: Record<string, any>;
23
+ __mj_recordID: unknown;
24
+ __mj_compositeKey?: unknown;
25
+ EntityDocument?: Record<string, unknown>;
26
+ TemplateContent?: string;
27
+ VectorIndexID?: unknown;
28
+ };
29
+
30
+ type EntitySyncConfig = {
31
+ EntityDocumentID: string;
32
+ Interval: number;
33
+ RunViewParams: RunViewParams;
34
+ IncludeInSync: boolean;
35
+ LastRunDate: string;
36
+ VectorIndexID: number;
37
+ VectorID: number;
38
+ };
39
+
40
+ /**
41
+ * AI Models - strongly typed entity sub-class
42
+ * * Schema: __mj
43
+ * * Base Table: AIModel
44
+ * * Base View: vwAIModels
45
+ * * @description Catalog of all AI Models configured in the system
46
+ * * Primary Key: ID
47
+ * @extends {BaseEntity}
48
+ * @class
49
+ * @public
50
+ */
51
+ declare class AIModelEntity extends BaseEntity {
52
+ /**
53
+ * Loads the AI Models record from the database
54
+ * @param ID: string - primary key value to load the AI Models record.
55
+ * @param EntityRelationshipsToLoad - (optional) the relationships to load
56
+ * @returns {Promise<boolean>} - true if successful, false otherwise
57
+ * @public
58
+ * @async
59
+ * @memberof AIModelEntity
60
+ * @method
61
+ * @override
62
+ */
63
+ Load(ID: string, EntityRelationshipsToLoad?: string[]): Promise<boolean>;
64
+ /**
65
+ * * Field Name: ID
66
+ * * Display Name: ID
67
+ * * SQL Data Type: uniqueidentifier
68
+ * * Default Value: newsequentialid()
69
+ */
70
+ get ID(): string;
71
+ /**
72
+ * * Field Name: Name
73
+ * * Display Name: Name
74
+ * * SQL Data Type: nvarchar(50)
75
+ */
76
+ get Name(): string;
77
+ set Name(value: string);
78
+ /**
79
+ * * Field Name: Description
80
+ * * Display Name: Description
81
+ * * SQL Data Type: nvarchar(MAX)
82
+ */
83
+ get Description(): string | null;
84
+ set Description(value: string | null);
85
+ /**
86
+ * * Field Name: Vendor
87
+ * * Display Name: Vendor
88
+ * * SQL Data Type: nvarchar(50)
89
+ */
90
+ get Vendor(): string | null;
91
+ set Vendor(value: string | null);
92
+ /**
93
+ * * Field Name: AIModelTypeID
94
+ * * Display Name: AI Model Type ID
95
+ * * SQL Data Type: uniqueidentifier
96
+ * * Related Entity/Foreign Key: AI Model Types (vwAIModelTypes.ID)
97
+ */
98
+ get AIModelTypeID(): string;
99
+ set AIModelTypeID(value: string);
100
+ /**
101
+ * * Field Name: PowerRank
102
+ * * Display Name: Power Rank
103
+ * * SQL Data Type: int
104
+ * * Description: A simplified power rank of each model for a given AI Model Type. For example, if we have GPT 3, GPT 3.5, and GPT 4, we would have a PowerRank of 1 for GPT3, 2 for GPT 3.5, and 3 for GPT 4. This can be used within model families like OpenAI or across all models. For example if you had Llama 2 in the mix which is similar to GPT 3.5 it would also have a PowerRank of 2. This can be used at runtime to pick the most/least powerful or compare model relative power.
105
+ */
106
+ get PowerRank(): number | null;
107
+ set PowerRank(value: number | null);
108
+ /**
109
+ * * Field Name: IsActive
110
+ * * Display Name: Is Active
111
+ * * SQL Data Type: bit
112
+ * * Default Value: 1
113
+ */
114
+ get IsActive(): boolean;
115
+ set IsActive(value: boolean);
116
+ /**
117
+ * * Field Name: DriverClass
118
+ * * Display Name: Driver Class
119
+ * * SQL Data Type: nvarchar(100)
120
+ */
121
+ get DriverClass(): string | null;
122
+ set DriverClass(value: string | null);
123
+ /**
124
+ * * Field Name: DriverImportPath
125
+ * * Display Name: Driver Import Path
126
+ * * SQL Data Type: nvarchar(255)
127
+ */
128
+ get DriverImportPath(): string | null;
129
+ set DriverImportPath(value: string | null);
130
+ /**
131
+ * * Field Name: APIName
132
+ * * Display Name: APIName
133
+ * * SQL Data Type: nvarchar(100)
134
+ * * Description: The name of the model to use with API calls which might differ from the Name, if APIName is not provided, Name will be used for API calls
135
+ */
136
+ get APIName(): string | null;
137
+ set APIName(value: string | null);
138
+ /**
139
+ * * Field Name: __mj_CreatedAt
140
+ * * Display Name: Created At
141
+ * * SQL Data Type: datetimeoffset
142
+ * * Default Value: getutcdate()
143
+ */
144
+ get __mj_CreatedAt(): Date;
145
+ /**
146
+ * * Field Name: __mj_UpdatedAt
147
+ * * Display Name: Updated At
148
+ * * SQL Data Type: datetimeoffset
149
+ * * Default Value: getutcdate()
150
+ */
151
+ get __mj_UpdatedAt(): Date;
152
+ /**
153
+ * * Field Name: AIModelType
154
+ * * Display Name: AIModel Type
155
+ * * SQL Data Type: nvarchar(50)
156
+ */
157
+ get AIModelType(): string;
158
+ }
159
+ /**
160
+ * Entity Documents - strongly typed entity sub-class
161
+ * * Schema: __mj
162
+ * * Base Table: EntityDocument
163
+ * * Base View: vwEntityDocuments
164
+ * * Primary Key: ID
165
+ * @extends {BaseEntity}
166
+ * @class
167
+ * @public
168
+ */
169
+ declare class EntityDocumentEntity extends BaseEntity {
170
+ /**
171
+ * Loads the Entity Documents record from the database
172
+ * @param ID: string - primary key value to load the Entity Documents record.
173
+ * @param EntityRelationshipsToLoad - (optional) the relationships to load
174
+ * @returns {Promise<boolean>} - true if successful, false otherwise
175
+ * @public
176
+ * @async
177
+ * @memberof EntityDocumentEntity
178
+ * @method
179
+ * @override
180
+ */
181
+ Load(ID: string, EntityRelationshipsToLoad?: string[]): Promise<boolean>;
182
+ /**
183
+ * Entity Documents - AllowDeleteAPI is set to 0 in the database. Delete is not allowed, so this method is generated to override the base class method and throw an error. To enable delete for this entity, set AllowDeleteAPI to 1 in the database.
184
+ * @public
185
+ * @method
186
+ * @override
187
+ * @memberof EntityDocumentEntity
188
+ * @throws {Error} - Delete is not allowed for Entity Documents, to enable it set AllowDeleteAPI to 1 in the database.
189
+ */
190
+ Delete(): Promise<boolean>;
191
+ /**
192
+ * * Field Name: ID
193
+ * * Display Name: ID
194
+ * * SQL Data Type: uniqueidentifier
195
+ * * Default Value: newsequentialid()
196
+ */
197
+ get ID(): string;
198
+ /**
199
+ * * Field Name: Name
200
+ * * Display Name: Name
201
+ * * SQL Data Type: nvarchar(250)
202
+ */
203
+ get Name(): string;
204
+ set Name(value: string);
205
+ /**
206
+ * * Field Name: TypeID
207
+ * * Display Name: Type ID
208
+ * * SQL Data Type: uniqueidentifier
209
+ * * Related Entity/Foreign Key: Entity Document Types (vwEntityDocumentTypes.ID)
210
+ */
211
+ get TypeID(): string;
212
+ set TypeID(value: string);
213
+ /**
214
+ * * Field Name: EntityID
215
+ * * Display Name: Entity ID
216
+ * * SQL Data Type: uniqueidentifier
217
+ * * Related Entity/Foreign Key: Entities (vwEntities.ID)
218
+ */
219
+ get EntityID(): string;
220
+ set EntityID(value: string);
221
+ /**
222
+ * * Field Name: VectorDatabaseID
223
+ * * Display Name: Vector Database ID
224
+ * * SQL Data Type: uniqueidentifier
225
+ * * Related Entity/Foreign Key: Vector Databases (vwVectorDatabases.ID)
226
+ */
227
+ get VectorDatabaseID(): string;
228
+ set VectorDatabaseID(value: string);
229
+ /**
230
+ * * Field Name: Status
231
+ * * Display Name: Status
232
+ * * SQL Data Type: nvarchar(15)
233
+ * * Default Value: Active
234
+ * * Value List Type: List
235
+ * * Possible Values
236
+ * * Active
237
+ * * Inactive
238
+ */
239
+ get Status(): 'Active' | 'Inactive';
240
+ set Status(value: 'Active' | 'Inactive');
241
+ /**
242
+ * * Field Name: TemplateID
243
+ * * Display Name: Template ID
244
+ * * SQL Data Type: uniqueidentifier
245
+ * * Related Entity/Foreign Key: Templates (vwTemplates.ID)
246
+ */
247
+ get TemplateID(): string;
248
+ set TemplateID(value: string);
249
+ /**
250
+ * * Field Name: AIModelID
251
+ * * Display Name: AIModel ID
252
+ * * SQL Data Type: uniqueidentifier
253
+ * * Related Entity/Foreign Key: AI Models (vwAIModels.ID)
254
+ */
255
+ get AIModelID(): string;
256
+ set AIModelID(value: string);
257
+ /**
258
+ * * Field Name: PotentialMatchThreshold
259
+ * * Display Name: Potential Match Threshold
260
+ * * SQL Data Type: numeric(12, 11)
261
+ * * Default Value: 1
262
+ * * Description: Value between 0 and 1 that determines what is considered a potential matching record. Value must be <= AbsoluteMatchThreshold. This is primarily used for duplicate detection but can be used for other applications as well where matching is relevant.
263
+ */
264
+ get PotentialMatchThreshold(): number;
265
+ set PotentialMatchThreshold(value: number);
266
+ /**
267
+ * * Field Name: AbsoluteMatchThreshold
268
+ * * Display Name: Absolute Match Threshold
269
+ * * SQL Data Type: numeric(12, 11)
270
+ * * Default Value: 1
271
+ * * Description: Value between 0 and 1 that determines what is considered an absolute matching record. Value must be >= PotentialMatchThreshold. This is primarily used for duplicate detection but can be used for other applications as well where matching is relevant.
272
+ */
273
+ get AbsoluteMatchThreshold(): number;
274
+ set AbsoluteMatchThreshold(value: number);
275
+ /**
276
+ * * Field Name: __mj_CreatedAt
277
+ * * Display Name: __mj _Created At
278
+ * * SQL Data Type: datetimeoffset
279
+ * * Default Value: getutcdate()
280
+ */
281
+ get __mj_CreatedAt(): Date;
282
+ /**
283
+ * * Field Name: __mj_UpdatedAt
284
+ * * Display Name: __mj _Updated At
285
+ * * SQL Data Type: datetimeoffset
286
+ * * Default Value: getutcdate()
287
+ */
288
+ get __mj_UpdatedAt(): Date;
289
+ /**
290
+ * * Field Name: Type
291
+ * * Display Name: Type
292
+ * * SQL Data Type: nvarchar(100)
293
+ */
294
+ get Type(): string;
295
+ /**
296
+ * * Field Name: Entity
297
+ * * Display Name: Entity
298
+ * * SQL Data Type: nvarchar(255)
299
+ */
300
+ get Entity(): string;
301
+ }
302
+ /**
303
+ * Template Contents - strongly typed entity sub-class
304
+ * * Schema: __mj
305
+ * * Base Table: TemplateContent
306
+ * * Base View: vwTemplateContents
307
+ * * @description Template content for different versions of a template for purposes like HTML/Text/etc
308
+ * * Primary Key: ID
309
+ * @extends {BaseEntity}
310
+ * @class
311
+ * @public
312
+ */
313
+ declare class TemplateContentEntity extends BaseEntity {
314
+ /**
315
+ * Loads the Template Contents record from the database
316
+ * @param ID: string - primary key value to load the Template Contents record.
317
+ * @param EntityRelationshipsToLoad - (optional) the relationships to load
318
+ * @returns {Promise<boolean>} - true if successful, false otherwise
319
+ * @public
320
+ * @async
321
+ * @memberof TemplateContentEntity
322
+ * @method
323
+ * @override
324
+ */
325
+ Load(ID: string, EntityRelationshipsToLoad?: string[]): Promise<boolean>;
326
+ /**
327
+ * Template Contents - AllowDeleteAPI is set to 0 in the database. Delete is not allowed, so this method is generated to override the base class method and throw an error. To enable delete for this entity, set AllowDeleteAPI to 1 in the database.
328
+ * @public
329
+ * @method
330
+ * @override
331
+ * @memberof TemplateContentEntity
332
+ * @throws {Error} - Delete is not allowed for Template Contents, to enable it set AllowDeleteAPI to 1 in the database.
333
+ */
334
+ Delete(): Promise<boolean>;
335
+ /**
336
+ * * Field Name: ID
337
+ * * Display Name: ID
338
+ * * SQL Data Type: uniqueidentifier
339
+ * * Default Value: newsequentialid()
340
+ */
341
+ get ID(): string;
342
+ /**
343
+ * * Field Name: TemplateID
344
+ * * Display Name: Template ID
345
+ * * SQL Data Type: uniqueidentifier
346
+ * * Related Entity/Foreign Key: Templates (vwTemplates.ID)
347
+ */
348
+ get TemplateID(): string;
349
+ set TemplateID(value: string);
350
+ /**
351
+ * * Field Name: TypeID
352
+ * * Display Name: Type ID
353
+ * * SQL Data Type: uniqueidentifier
354
+ * * Related Entity/Foreign Key: Template Content Types (vwTemplateContentTypes.ID)
355
+ */
356
+ get TypeID(): string;
357
+ set TypeID(value: string);
358
+ /**
359
+ * * Field Name: TemplateText
360
+ * * Display Name: Template Text
361
+ * * SQL Data Type: nvarchar(MAX)
362
+ * * Description: The actual text content for the template
363
+ */
364
+ get TemplateText(): string | null;
365
+ set TemplateText(value: string | null);
366
+ /**
367
+ * * Field Name: Priority
368
+ * * Display Name: Priority
369
+ * * SQL Data Type: int
370
+ * * Description: Priority of the content version, higher priority versions will be used ahead of lower priority versions for a given Type
371
+ */
372
+ get Priority(): number;
373
+ set Priority(value: number);
374
+ /**
375
+ * * Field Name: IsActive
376
+ * * Display Name: Is Active
377
+ * * SQL Data Type: bit
378
+ * * Default Value: 1
379
+ * * Description: Indicates whether the content is active or not. Use this to disable a particular Template Content item without having to remove it
380
+ */
381
+ get IsActive(): boolean;
382
+ set IsActive(value: boolean);
383
+ /**
384
+ * * Field Name: __mj_CreatedAt
385
+ * * Display Name: Created At
386
+ * * SQL Data Type: datetimeoffset
387
+ * * Default Value: getutcdate()
388
+ */
389
+ get __mj_CreatedAt(): Date;
390
+ /**
391
+ * * Field Name: __mj_UpdatedAt
392
+ * * Display Name: Updated At
393
+ * * SQL Data Type: datetimeoffset
394
+ * * Default Value: getutcdate()
395
+ */
396
+ get __mj_UpdatedAt(): Date;
397
+ /**
398
+ * * Field Name: Template
399
+ * * Display Name: Template
400
+ * * SQL Data Type: nvarchar(255)
401
+ */
402
+ get Template(): string;
403
+ /**
404
+ * * Field Name: Type
405
+ * * Display Name: Type
406
+ * * SQL Data Type: nvarchar(255)
407
+ */
408
+ get Type(): string;
409
+ }
410
+ /**
411
+ * Template Params - strongly typed entity sub-class
412
+ * * Schema: __mj
413
+ * * Base Table: TemplateParam
414
+ * * Base View: vwTemplateParams
415
+ * * @description Parameters allowed for use inside the template
416
+ * * Primary Key: ID
417
+ * @extends {BaseEntity}
418
+ * @class
419
+ * @public
420
+ */
421
+ declare class TemplateParamEntity extends BaseEntity {
422
+ /**
423
+ * Loads the Template Params record from the database
424
+ * @param ID: string - primary key value to load the Template Params record.
425
+ * @param EntityRelationshipsToLoad - (optional) the relationships to load
426
+ * @returns {Promise<boolean>} - true if successful, false otherwise
427
+ * @public
428
+ * @async
429
+ * @memberof TemplateParamEntity
430
+ * @method
431
+ * @override
432
+ */
433
+ Load(ID: string, EntityRelationshipsToLoad?: string[]): Promise<boolean>;
434
+ /**
435
+ * Template Params - AllowDeleteAPI is set to 0 in the database. Delete is not allowed, so this method is generated to override the base class method and throw an error. To enable delete for this entity, set AllowDeleteAPI to 1 in the database.
436
+ * @public
437
+ * @method
438
+ * @override
439
+ * @memberof TemplateParamEntity
440
+ * @throws {Error} - Delete is not allowed for Template Params, to enable it set AllowDeleteAPI to 1 in the database.
441
+ */
442
+ Delete(): Promise<boolean>;
443
+ /**
444
+ * * Field Name: ID
445
+ * * Display Name: ID
446
+ * * SQL Data Type: uniqueidentifier
447
+ * * Default Value: newsequentialid()
448
+ */
449
+ get ID(): string;
450
+ /**
451
+ * * Field Name: TemplateID
452
+ * * Display Name: Template ID
453
+ * * SQL Data Type: uniqueidentifier
454
+ * * Related Entity/Foreign Key: Templates (vwTemplates.ID)
455
+ */
456
+ get TemplateID(): string;
457
+ set TemplateID(value: string);
458
+ /**
459
+ * * Field Name: Name
460
+ * * Display Name: Name
461
+ * * SQL Data Type: nvarchar(255)
462
+ * * Description: Name of the parameter
463
+ */
464
+ get Name(): string;
465
+ set Name(value: string);
466
+ /**
467
+ * * Field Name: Description
468
+ * * Display Name: Description
469
+ * * SQL Data Type: nvarchar(MAX)
470
+ * * Description: Description of the parameter
471
+ */
472
+ get Description(): string | null;
473
+ set Description(value: string | null);
474
+ /**
475
+ * * Field Name: Type
476
+ * * Display Name: Type
477
+ * * SQL Data Type: nvarchar(20)
478
+ * * Default Value: Scalar
479
+ * * Value List Type: List
480
+ * * Possible Values
481
+ * * Scalar
482
+ * * Array
483
+ * * Object
484
+ * * Record
485
+ * * Entity
486
+ * * Description: Type of the parameter - Record is an individual record within the entity specified by EntityID. Entity means an entire Entity or an entity filtered by the LinkedParameterName/Field attributes and/or ExtraFilter. Object is any valid JSON object. Array and Scalar have their common meanings.
487
+ */
488
+ get Type(): 'Scalar' | 'Array' | 'Object' | 'Record' | 'Entity';
489
+ set Type(value: 'Scalar' | 'Array' | 'Object' | 'Record' | 'Entity');
490
+ /**
491
+ * * Field Name: DefaultValue
492
+ * * Display Name: Default Value
493
+ * * SQL Data Type: nvarchar(MAX)
494
+ * * Description: Default value of the parameter
495
+ */
496
+ get DefaultValue(): string | null;
497
+ set DefaultValue(value: string | null);
498
+ /**
499
+ * * Field Name: IsRequired
500
+ * * Display Name: Is Required
501
+ * * SQL Data Type: bit
502
+ * * Default Value: 0
503
+ */
504
+ get IsRequired(): boolean;
505
+ set IsRequired(value: boolean);
506
+ /**
507
+ * * Field Name: LinkedParameterName
508
+ * * Display Name: Linked Parameter Name
509
+ * * SQL Data Type: nvarchar(255)
510
+ * * Description: Only used when Type=Entity, this is used to link an Entity parameter with another parameter so that the rows in the Entity parameter can be filtered automatically based on the FKEY relationship between the Record and this Entity parameter. For example, if the Entity-based parameter is for an entity like Activities and there is another parameter of type Record for an entity like Contacts, in that situation the Activities Parameter would point to the Contacts parameter as the LinkedParameterName because we would filter down the Activities in each template render to only those linked to the Contact.
511
+ */
512
+ get LinkedParameterName(): string | null;
513
+ set LinkedParameterName(value: string | null);
514
+ /**
515
+ * * Field Name: LinkedParameterField
516
+ * * Display Name: Linked Parameter Field
517
+ * * SQL Data Type: nvarchar(500)
518
+ * * Description: If the LinkedParameterName is specified, this is an optional setting to specify the field within the LinkedParameter that will be used for filtering. This is only needed if there is more than one foreign key relationship between the Entity parameter and the Linked parameter, or if there is no defined foreign key in the database between the two entities.
519
+ */
520
+ get LinkedParameterField(): string | null;
521
+ set LinkedParameterField(value: string | null);
522
+ /**
523
+ * * Field Name: ExtraFilter
524
+ * * Display Name: Extra Filter
525
+ * * SQL Data Type: nvarchar(MAX)
526
+ * * Description: Only used when Type = Entity, used to specify an optional filter to reduce the set of rows that are returned for each of the templates being rendered.
527
+ */
528
+ get ExtraFilter(): string | null;
529
+ set ExtraFilter(value: string | null);
530
+ /**
531
+ * * Field Name: EntityID
532
+ * * Display Name: Entity ID
533
+ * * SQL Data Type: uniqueidentifier
534
+ * * Related Entity/Foreign Key: Entities (vwEntities.ID)
535
+ */
536
+ get EntityID(): string | null;
537
+ set EntityID(value: string | null);
538
+ /**
539
+ * * Field Name: RecordID
540
+ * * Display Name: Record ID
541
+ * * SQL Data Type: nvarchar(2000)
542
+ * * Description: Record ID, used only when Type is Record and a specific hardcoded record ID is desired, this is an uncommon use case, helpful for pulling in static types and metadata in some cases.
543
+ */
544
+ get RecordID(): string | null;
545
+ set RecordID(value: string | null);
546
+ /**
547
+ * * Field Name: __mj_CreatedAt
548
+ * * Display Name: Created At
549
+ * * SQL Data Type: datetimeoffset
550
+ * * Default Value: getutcdate()
551
+ */
552
+ get __mj_CreatedAt(): Date;
553
+ /**
554
+ * * Field Name: __mj_UpdatedAt
555
+ * * Display Name: Updated At
556
+ * * SQL Data Type: datetimeoffset
557
+ * * Default Value: getutcdate()
558
+ */
559
+ get __mj_UpdatedAt(): Date;
560
+ /**
561
+ * * Field Name: Template
562
+ * * Display Name: Template
563
+ * * SQL Data Type: nvarchar(255)
564
+ */
565
+ get Template(): string;
566
+ /**
567
+ * * Field Name: Entity
568
+ * * Display Name: Entity
569
+ * * SQL Data Type: nvarchar(255)
570
+ */
571
+ get Entity(): string | null;
572
+ }
573
+ /**
574
+ * Templates - strongly typed entity sub-class
575
+ * * Schema: __mj
576
+ * * Base Table: Template
577
+ * * Base View: vwTemplates
578
+ * * @description Templates are used for dynamic expansion of a static template with data from a given context. Templates can be used to create documents, messages and anything else that requires dynamic document creation merging together static text, data and lightweight logic
579
+ * * Primary Key: ID
580
+ * @extends {BaseEntity}
581
+ * @class
582
+ * @public
583
+ */
584
+ declare class TemplateEntity extends BaseEntity {
585
+ /**
586
+ * Loads the Templates record from the database
587
+ * @param ID: string - primary key value to load the Templates record.
588
+ * @param EntityRelationshipsToLoad - (optional) the relationships to load
589
+ * @returns {Promise<boolean>} - true if successful, false otherwise
590
+ * @public
591
+ * @async
592
+ * @memberof TemplateEntity
593
+ * @method
594
+ * @override
595
+ */
596
+ Load(ID: string, EntityRelationshipsToLoad?: string[]): Promise<boolean>;
597
+ /**
598
+ * Templates - AllowDeleteAPI is set to 0 in the database. Delete is not allowed, so this method is generated to override the base class method and throw an error. To enable delete for this entity, set AllowDeleteAPI to 1 in the database.
599
+ * @public
600
+ * @method
601
+ * @override
602
+ * @memberof TemplateEntity
603
+ * @throws {Error} - Delete is not allowed for Templates, to enable it set AllowDeleteAPI to 1 in the database.
604
+ */
605
+ Delete(): Promise<boolean>;
606
+ /**
607
+ * * Field Name: ID
608
+ * * Display Name: ID
609
+ * * SQL Data Type: uniqueidentifier
610
+ * * Default Value: newsequentialid()
611
+ */
612
+ get ID(): string;
613
+ /**
614
+ * * Field Name: Name
615
+ * * Display Name: Name
616
+ * * SQL Data Type: nvarchar(255)
617
+ * * Description: Name of the template
618
+ */
619
+ get Name(): string;
620
+ set Name(value: string);
621
+ /**
622
+ * * Field Name: Description
623
+ * * Display Name: Description
624
+ * * SQL Data Type: nvarchar(MAX)
625
+ * * Description: Description of the template
626
+ */
627
+ get Description(): string | null;
628
+ set Description(value: string | null);
629
+ /**
630
+ * * Field Name: CategoryID
631
+ * * Display Name: Category ID
632
+ * * SQL Data Type: uniqueidentifier
633
+ * * Related Entity/Foreign Key: Template Categories (vwTemplateCategories.ID)
634
+ */
635
+ get CategoryID(): string | null;
636
+ set CategoryID(value: string | null);
637
+ /**
638
+ * * Field Name: UserPrompt
639
+ * * Display Name: User Prompt
640
+ * * SQL Data Type: nvarchar(MAX)
641
+ * * Description: This prompt will be used by the AI to generate template content as requested by the user.
642
+ */
643
+ get UserPrompt(): string | null;
644
+ set UserPrompt(value: string | null);
645
+ /**
646
+ * * Field Name: UserID
647
+ * * Display Name: User ID
648
+ * * SQL Data Type: uniqueidentifier
649
+ * * Related Entity/Foreign Key: Users (vwUsers.ID)
650
+ */
651
+ get UserID(): string;
652
+ set UserID(value: string);
653
+ /**
654
+ * * Field Name: ActiveAt
655
+ * * Display Name: Active At
656
+ * * SQL Data Type: datetime
657
+ * * Description: Optional, if provided, this template will not be available for use until the specified date. Requires IsActive to be set to 1
658
+ */
659
+ get ActiveAt(): Date | null;
660
+ set ActiveAt(value: Date | null);
661
+ /**
662
+ * * Field Name: DisabledAt
663
+ * * Display Name: Disabled At
664
+ * * SQL Data Type: datetime
665
+ * * Description: Optional, if provided, this template will not be available for use after the specified date. If IsActive=0, this has no effect.
666
+ */
667
+ get DisabledAt(): Date | null;
668
+ set DisabledAt(value: Date | null);
669
+ /**
670
+ * * Field Name: IsActive
671
+ * * Display Name: Is Active
672
+ * * SQL Data Type: bit
673
+ * * Default Value: 1
674
+ * * Description: If set to 0, the template will be disabled regardless of the values in ActiveAt/DisabledAt.
675
+ */
676
+ get IsActive(): boolean;
677
+ set IsActive(value: boolean);
678
+ /**
679
+ * * Field Name: __mj_CreatedAt
680
+ * * Display Name: Created At
681
+ * * SQL Data Type: datetimeoffset
682
+ * * Default Value: getutcdate()
683
+ */
684
+ get __mj_CreatedAt(): Date;
685
+ /**
686
+ * * Field Name: __mj_UpdatedAt
687
+ * * Display Name: Updated At
688
+ * * SQL Data Type: datetimeoffset
689
+ * * Default Value: getutcdate()
690
+ */
691
+ get __mj_UpdatedAt(): Date;
692
+ /**
693
+ * * Field Name: Category
694
+ * * Display Name: Category
695
+ * * SQL Data Type: nvarchar(255)
696
+ */
697
+ get Category(): string | null;
698
+ /**
699
+ * * Field Name: User
700
+ * * Display Name: User
701
+ * * SQL Data Type: nvarchar(100)
702
+ */
703
+ get User(): string;
704
+ }
705
+ /**
706
+ * Vector Databases - strongly typed entity sub-class
707
+ * * Schema: __mj
708
+ * * Base Table: VectorDatabase
709
+ * * Base View: vwVectorDatabases
710
+ * * Primary Key: ID
711
+ * @extends {BaseEntity}
712
+ * @class
713
+ * @public
714
+ */
715
+ declare class VectorDatabaseEntity extends BaseEntity {
716
+ /**
717
+ * Loads the Vector Databases record from the database
718
+ * @param ID: string - primary key value to load the Vector Databases record.
719
+ * @param EntityRelationshipsToLoad - (optional) the relationships to load
720
+ * @returns {Promise<boolean>} - true if successful, false otherwise
721
+ * @public
722
+ * @async
723
+ * @memberof VectorDatabaseEntity
724
+ * @method
725
+ * @override
726
+ */
727
+ Load(ID: string, EntityRelationshipsToLoad?: string[]): Promise<boolean>;
728
+ /**
729
+ * Vector Databases - AllowDeleteAPI is set to 0 in the database. Delete is not allowed, so this method is generated to override the base class method and throw an error. To enable delete for this entity, set AllowDeleteAPI to 1 in the database.
730
+ * @public
731
+ * @method
732
+ * @override
733
+ * @memberof VectorDatabaseEntity
734
+ * @throws {Error} - Delete is not allowed for Vector Databases, to enable it set AllowDeleteAPI to 1 in the database.
735
+ */
736
+ Delete(): Promise<boolean>;
737
+ /**
738
+ * * Field Name: ID
739
+ * * Display Name: ID
740
+ * * SQL Data Type: uniqueidentifier
741
+ * * Default Value: newsequentialid()
742
+ */
743
+ get ID(): string;
744
+ /**
745
+ * * Field Name: Name
746
+ * * Display Name: Name
747
+ * * SQL Data Type: nvarchar(100)
748
+ */
749
+ get Name(): string;
750
+ set Name(value: string);
751
+ /**
752
+ * * Field Name: Description
753
+ * * Display Name: Description
754
+ * * SQL Data Type: nvarchar(MAX)
755
+ */
756
+ get Description(): string | null;
757
+ set Description(value: string | null);
758
+ /**
759
+ * * Field Name: DefaultURL
760
+ * * Display Name: Default URL
761
+ * * SQL Data Type: nvarchar(255)
762
+ */
763
+ get DefaultURL(): string | null;
764
+ set DefaultURL(value: string | null);
765
+ /**
766
+ * * Field Name: ClassKey
767
+ * * Display Name: Class Key
768
+ * * SQL Data Type: nvarchar(100)
769
+ */
770
+ get ClassKey(): string | null;
771
+ set ClassKey(value: string | null);
772
+ /**
773
+ * * Field Name: __mj_CreatedAt
774
+ * * Display Name: Created At
775
+ * * SQL Data Type: datetimeoffset
776
+ * * Default Value: getutcdate()
777
+ */
778
+ get __mj_CreatedAt(): Date;
779
+ /**
780
+ * * Field Name: __mj_UpdatedAt
781
+ * * Display Name: Updated At
782
+ * * SQL Data Type: datetimeoffset
783
+ * * Default Value: getutcdate()
784
+ */
785
+ get __mj_UpdatedAt(): Date;
786
+ }
787
+
788
+ type AnnotateWorkerContext = {
789
+ executionId: number;
790
+ entity: BaseEntity;
791
+ entityDocument: Record<string, unknown>;
792
+ template: TemplateEntityExtended;
793
+ templateContent: TemplateContentEntity;
794
+ embeddingDriverClass: string;
795
+ embeddingAPIKey: string;
796
+ delayTimeMS: number;
797
+ };
798
+ type ArchiveWorkerContext = {
799
+ executionId: number;
800
+ entity: BaseEntity;
801
+ entityDocument: EntityDocumentEntity;
802
+ vectorDBClassKey: string;
803
+ vectorDBAPIKey: string;
804
+ templateContent: TemplateContentEntity;
805
+ embeddings: EmbedTextsResult;
806
+ delayTimeMS: number;
807
+ };
808
+ type TemplateParamData = {
809
+ ParamName: string;
810
+ Data: BaseEntity[];
811
+ };
812
+ declare class EntityVectorSyncer extends VectorBase {
813
+ _startTime: Date;
814
+ _endTime: Date;
815
+ constructor();
816
+ Config(contextUser?: UserInfo): Promise<void>;
817
+ VectorizeEntity(request: VectorSyncRequest, contextUser?: UserInfo): Promise<any>;
818
+ CreateDefaultEntityDocument(EntityID: string, VectorDatabase: VectorDatabaseEntity, AIModel: AIModelEntity): Promise<EntityDocumentEntity>;
819
+ protected GetVectorDatabaseAndEmbeddingClassByEntityDocumentID(entityDocumentID: string, createDocumentIfNotFound?: boolean): Promise<{
820
+ embedding: Embeddings;
821
+ vectorDB: VectorDBBase;
822
+ vectorDBClassKey: string;
823
+ vectorDBAPIKey: string;
824
+ embeddingDriverClass: string;
825
+ embeddingAPIKey: string;
826
+ }>;
827
+ GetEntityDocument(EntityDocumentID: string): Promise<EntityDocumentEntity | null>;
828
+ GetEntityDocumentByName(EntityDocumentName: string, ContextUser?: UserInfo): Promise<EntityDocumentEntity | null>;
829
+ GetFirstActiveEntityDocumentForEntity(entityID: string): Promise<EntityDocumentEntity | null>;
830
+ GetActiveEntityDocuments(entityNames?: string[]): Promise<EntityDocumentEntity[]>;
831
+ private GetOrCreateVectorIndex;
832
+ protected CreateTemplateForEntityDocument(entityDocument: EntityDocumentEntity): Promise<TemplateEntity>;
833
+ protected BuildTemplateContent(entityFields: EntityField[]): string;
834
+ protected GetEntityFieldsForSimilaritySearch(entityID: string): Promise<EntityField[]>;
835
+ private chunkArray;
836
+ private convertPrimaryKeysToList;
837
+ private ConvertEntityFieldsToString;
838
+ private delay;
839
+ protected GetTemplateData(entity: EntityInfo, record: BaseEntity, template: TemplateEntityExtended, relatedData: TemplateParamData[]): Promise<{
840
+ [key: string]: any;
841
+ }>;
842
+ protected GetRelatedTemplateData(entity: EntityInfo, record: BaseEntity, templateParam: TemplateParamEntity): Promise<TemplateParamData | null>;
843
+ protected GetRelatedTemplateDataForBatch(entity: EntityInfo, records: BaseEntity[], template: TemplateEntityExtended): Promise<TemplateParamData[]>;
844
+ protected UpsertEntityRecordDocumentRecords(embeddingData: EmbeddingData, contextUser: UserInfo): Promise<void>;
845
+ protected ValidateTemplateContextParamAlignment(template: TemplateEntityExtended): boolean;
846
+ }
847
+
848
+ declare abstract class EntityDocumentTemplateParserBase {
849
+ static ClearCache(): void;
850
+ static CreateCacheKey(EntityID: string, EntityRecordPrimaryKey: string, Content: string): string;
851
+ protected static __cache: {
852
+ [key: string]: string;
853
+ };
854
+ protected static get _cache(): {
855
+ [key: string]: string;
856
+ };
857
+ Parse(Template: string, EntityID: string, EntityRecord: any, ContextUser: UserInfo): Promise<string>;
858
+ protected evalSingleArgument(argument: string, entityID: string, entityRecord: any, ContextUser: UserInfo): Promise<string>;
859
+ }
860
+
861
+ declare class EntityDocumentTemplateParser extends EntityDocumentTemplateParserBase {
862
+ static CreateInstance(): EntityDocumentTemplateParser;
863
+ protected Relationship(entityID: string, entityRecord: any, ContextUser: UserInfo, relationshipName: string, maxRows: number, entityDocumentName: string): Promise<string>;
864
+ }
865
+
866
+ export { type AnnotateWorkerContext, type ArchiveWorkerContext, type EmbeddingData, EntityDocumentTemplateParser, type EntitySyncConfig, EntityVectorSyncer, type TemplateParamData, type VectorSyncRequest, type vectorSyncResponse };