@memberjunction/global 2.112.0 → 2.113.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 (117) hide show
  1. package/package.json +1 -1
  2. package/dist/Core.d.ts +0 -29
  3. package/dist/Core.d.ts.map +0 -1
  4. package/dist/Core.js +0 -58
  5. package/dist/Core.js.map +0 -1
  6. package/dist/generic/QueryCache.d.ts +0 -85
  7. package/dist/generic/QueryCache.d.ts.map +0 -1
  8. package/dist/generic/QueryCache.js +0 -198
  9. package/dist/generic/QueryCache.js.map +0 -1
  10. package/dist/generic/QueryCacheConfig.d.ts +0 -72
  11. package/dist/generic/QueryCacheConfig.d.ts.map +0 -1
  12. package/dist/generic/QueryCacheConfig.js +0 -3
  13. package/dist/generic/QueryCacheConfig.js.map +0 -1
  14. package/dist/generic/applicationInfo.d.ts +0 -138
  15. package/dist/generic/applicationInfo.d.ts.map +0 -1
  16. package/dist/generic/applicationInfo.js +0 -177
  17. package/dist/generic/applicationInfo.js.map +0 -1
  18. package/dist/generic/authEvaluator.d.ts +0 -25
  19. package/dist/generic/authEvaluator.d.ts.map +0 -1
  20. package/dist/generic/authEvaluator.js +0 -49
  21. package/dist/generic/authEvaluator.js.map +0 -1
  22. package/dist/generic/authTypes.d.ts +0 -193
  23. package/dist/generic/authTypes.d.ts.map +0 -1
  24. package/dist/generic/authTypes.js +0 -19
  25. package/dist/generic/authTypes.js.map +0 -1
  26. package/dist/generic/baseEngine.d.ts +0 -260
  27. package/dist/generic/baseEngine.d.ts.map +0 -1
  28. package/dist/generic/baseEngine.js +0 -510
  29. package/dist/generic/baseEngine.js.map +0 -1
  30. package/dist/generic/baseEntity.d.ts +0 -691
  31. package/dist/generic/baseEntity.d.ts.map +0 -1
  32. package/dist/generic/baseEntity.js +0 -1688
  33. package/dist/generic/baseEntity.js.map +0 -1
  34. package/dist/generic/baseInfo.d.ts +0 -24
  35. package/dist/generic/baseInfo.d.ts.map +0 -1
  36. package/dist/generic/baseInfo.js +0 -53
  37. package/dist/generic/baseInfo.js.map +0 -1
  38. package/dist/generic/compositeKey.d.ts +0 -206
  39. package/dist/generic/compositeKey.d.ts.map +0 -1
  40. package/dist/generic/compositeKey.js +0 -412
  41. package/dist/generic/compositeKey.js.map +0 -1
  42. package/dist/generic/databaseProviderBase.d.ts +0 -46
  43. package/dist/generic/databaseProviderBase.d.ts.map +0 -1
  44. package/dist/generic/databaseProviderBase.js +0 -14
  45. package/dist/generic/databaseProviderBase.js.map +0 -1
  46. package/dist/generic/entityInfo.d.ts +0 -983
  47. package/dist/generic/entityInfo.d.ts.map +0 -1
  48. package/dist/generic/entityInfo.js +0 -1401
  49. package/dist/generic/entityInfo.js.map +0 -1
  50. package/dist/generic/explorerNavigationItem.d.ts +0 -20
  51. package/dist/generic/explorerNavigationItem.d.ts.map +0 -1
  52. package/dist/generic/explorerNavigationItem.js +0 -29
  53. package/dist/generic/explorerNavigationItem.js.map +0 -1
  54. package/dist/generic/interfaces.d.ts +0 -610
  55. package/dist/generic/interfaces.d.ts.map +0 -1
  56. package/dist/generic/interfaces.js +0 -211
  57. package/dist/generic/interfaces.js.map +0 -1
  58. package/dist/generic/libraryInfo.d.ts +0 -40
  59. package/dist/generic/libraryInfo.d.ts.map +0 -1
  60. package/dist/generic/libraryInfo.js +0 -56
  61. package/dist/generic/libraryInfo.js.map +0 -1
  62. package/dist/generic/logging.d.ts +0 -179
  63. package/dist/generic/logging.d.ts.map +0 -1
  64. package/dist/generic/logging.js +0 -382
  65. package/dist/generic/logging.js.map +0 -1
  66. package/dist/generic/metadata.d.ts +0 -305
  67. package/dist/generic/metadata.d.ts.map +0 -1
  68. package/dist/generic/metadata.js +0 -454
  69. package/dist/generic/metadata.js.map +0 -1
  70. package/dist/generic/metadataUtil.d.ts +0 -8
  71. package/dist/generic/metadataUtil.d.ts.map +0 -1
  72. package/dist/generic/metadataUtil.js +0 -36
  73. package/dist/generic/metadataUtil.js.map +0 -1
  74. package/dist/generic/providerBase.d.ts +0 -546
  75. package/dist/generic/providerBase.d.ts.map +0 -1
  76. package/dist/generic/providerBase.js +0 -999
  77. package/dist/generic/providerBase.js.map +0 -1
  78. package/dist/generic/queryInfo.d.ts +0 -460
  79. package/dist/generic/queryInfo.d.ts.map +0 -1
  80. package/dist/generic/queryInfo.js +0 -633
  81. package/dist/generic/queryInfo.js.map +0 -1
  82. package/dist/generic/querySQLFilters.d.ts +0 -54
  83. package/dist/generic/querySQLFilters.d.ts.map +0 -1
  84. package/dist/generic/querySQLFilters.js +0 -84
  85. package/dist/generic/querySQLFilters.js.map +0 -1
  86. package/dist/generic/runQuery.d.ts +0 -96
  87. package/dist/generic/runQuery.d.ts.map +0 -1
  88. package/dist/generic/runQuery.js +0 -66
  89. package/dist/generic/runQuery.js.map +0 -1
  90. package/dist/generic/runQuerySQLFilterImplementations.d.ts +0 -51
  91. package/dist/generic/runQuerySQLFilterImplementations.d.ts.map +0 -1
  92. package/dist/generic/runQuerySQLFilterImplementations.js +0 -238
  93. package/dist/generic/runQuerySQLFilterImplementations.js.map +0 -1
  94. package/dist/generic/runReport.d.ts +0 -25
  95. package/dist/generic/runReport.d.ts.map +0 -1
  96. package/dist/generic/runReport.js +0 -42
  97. package/dist/generic/runReport.js.map +0 -1
  98. package/dist/generic/securityInfo.d.ts +0 -355
  99. package/dist/generic/securityInfo.d.ts.map +0 -1
  100. package/dist/generic/securityInfo.js +0 -425
  101. package/dist/generic/securityInfo.js.map +0 -1
  102. package/dist/generic/transactionGroup.d.ts +0 -184
  103. package/dist/generic/transactionGroup.d.ts.map +0 -1
  104. package/dist/generic/transactionGroup.js +0 -357
  105. package/dist/generic/transactionGroup.js.map +0 -1
  106. package/dist/generic/util.d.ts +0 -81
  107. package/dist/generic/util.d.ts.map +0 -1
  108. package/dist/generic/util.js +0 -301
  109. package/dist/generic/util.js.map +0 -1
  110. package/dist/views/runView.d.ts +0 -150
  111. package/dist/views/runView.d.ts.map +0 -1
  112. package/dist/views/runView.js +0 -100
  113. package/dist/views/runView.js.map +0 -1
  114. package/dist/views/viewInfo.d.ts +0 -121
  115. package/dist/views/viewInfo.d.ts.map +0 -1
  116. package/dist/views/viewInfo.js +0 -182
  117. package/dist/views/viewInfo.js.map +0 -1
@@ -1,691 +0,0 @@
1
- import { EntityFieldInfo, EntityInfo, EntityFieldTSType, EntityPermissionType, RecordChange, EntityRelationshipInfo } from './entityInfo';
2
- import { EntityDeleteOptions, EntitySaveOptions, IEntityDataProvider, IRunQueryProvider, IRunReportProvider, IRunViewProvider, SimpleEmbeddingResult } from './interfaces';
3
- import { UserInfo } from './securityInfo';
4
- import { TransactionGroupBase } from './transactionGroup';
5
- import { CompositeKey, FieldValueCollection } from './compositeKey';
6
- import { Subscription } from 'rxjs';
7
- import { z } from 'zod';
8
- import { ValidationResult } from '../ValidationTypes';
9
- /**
10
- * Represents a field in an instance of the BaseEntity class. This class is used to store the value of the field, dirty state, as well as other run-time information about the field. The class encapsulates the underlying field metadata and exposes some of the more commonly
11
- * used properties from the entity field metadata.
12
- */
13
- export declare class EntityField {
14
- /**
15
- * Static object containing the value ranges for various SQL number types.
16
- * This is used to validate the value of the field when it is set or validated.
17
- */
18
- static readonly SQLTypeValueRanges: {
19
- int: {
20
- min: number;
21
- max: number;
22
- };
23
- bigint: {
24
- min: number;
25
- max: number;
26
- };
27
- smallint: {
28
- min: number;
29
- max: number;
30
- };
31
- tinyint: {
32
- min: number;
33
- max: number;
34
- };
35
- decimal: {
36
- min: number;
37
- max: number;
38
- };
39
- numeric: {
40
- min: number;
41
- max: number;
42
- };
43
- float: {
44
- min: number;
45
- max: number;
46
- };
47
- real: {
48
- min: number;
49
- max: number;
50
- };
51
- money: {
52
- min: number;
53
- max: number;
54
- };
55
- };
56
- /**
57
- * Indicates whether the active status of the field should be asserted when accessing or setting the value.
58
- * Starts off as false and turns to true after contructor is done doing all its setup work. Internally, this can be
59
- * temporarily turned off to allow for legacy fields to be created without asserting the active status.
60
- */
61
- private _assertActiveStatusRequired;
62
- private _entityFieldInfo;
63
- private _OldValue;
64
- private _Value;
65
- private _NeverSet;
66
- get Name(): string;
67
- get FieldType(): EntityFieldTSType;
68
- get SQLType(): string;
69
- get IsPrimaryKey(): boolean;
70
- get NeedsQuotes(): boolean;
71
- /**
72
- * Removes spaces from the field name and returns the result.
73
- */
74
- get CodeName(): string;
75
- get IsUnique(): boolean;
76
- /**
77
- * Returns the current value of the field.
78
- */
79
- get Value(): any;
80
- get ReadOnly(): boolean;
81
- get EntityFieldInfo(): EntityFieldInfo;
82
- /**
83
- * Returns true if the field is a uniqueidentifier in the database.
84
- */
85
- get IsUniqueIdentifier(): boolean;
86
- /**
87
- * Returns true if the field has a default value set
88
- */
89
- get HasDefaultValue(): boolean;
90
- /**
91
- * Sets the value of the field. If the field is read only, nothing happens. If the field is not read only, the value is set and the internal representation of the dirty flag is flipped if the value is different from the old value.
92
- */
93
- set Value(value: any);
94
- /**
95
- * Resets the NeverSet flag - this is generally an internal method but is available when working with read only fields (mainly primary key fields) to allow them
96
- * to be set/changed once after the object is created. This is useful for scenarios where you want to set a read only field
97
- * after the object is created, but only once. This is typically used in the BaseEntity class when loading an entity from an array of values or the DB and reusing an existing object.
98
- */
99
- ResetNeverSetFlag(): void;
100
- /**
101
- * Returns true if the field is dirty, false otherwise. A field is considered dirty if the value is different from the old value. If the field is read only, it is never dirty.
102
- */
103
- get Dirty(): boolean;
104
- /**
105
- * Helper method to convert a value to boolean for comparison purposes.
106
- * Treats truthy values as true regardless of data type.
107
- */
108
- private convertToBoolean;
109
- /**
110
- * Helper method to check if a SQL type is numeric.
111
- */
112
- private isNumericType;
113
- /**
114
- * Helper method to convert a value to number for comparison purposes.
115
- */
116
- private convertToNumber;
117
- /**
118
- * Convenience method to format the value of the field. This method calls the static method on EntityFieldInfo to do the actual formatting.
119
- * @param decimals
120
- * @param currency
121
- * @returns
122
- */
123
- FormatValue(decimals?: number, currency?: string): string;
124
- /**
125
- * Validates the current value of the field. If the field is read only, or if the field is marked to skip validation, nothing happens.
126
- * If the field is not read only, and the field is not marked to skip validation, the value is checked against the validation rules defined in the metadata for the field.
127
- * @returns
128
- */
129
- Validate(): ValidationResult;
130
- constructor(fieldInfo: EntityFieldInfo, Value?: any);
131
- /**
132
- * This method will set the internal Old Value which is used to track dirty state, to the current value of the field. This effectively resets the dirty state of the field to false. Use this method sparingly.
133
- */
134
- ResetOldValue(): void;
135
- /**
136
- * This property temporarily will set the active status assertions for this particular instance of EntityField.
137
- * It is temporary because other behaviors in the class instance could reset this value for example calling
138
- * ResetOldValue() or another caller setting this property to another value.
139
- */
140
- get ActiveStatusAssertions(): boolean;
141
- set ActiveStatusAssertions(value: boolean);
142
- /**
143
- * Returns the old value of the field. This is the value that was set when the field was last loaded from the database.
144
- */
145
- get OldValue(): any;
146
- }
147
- export declare class DataObjectRelatedEntityParam {
148
- relatedEntityName: string;
149
- filter?: string;
150
- maxRecords?: number;
151
- }
152
- export declare class DataObjectParams {
153
- oldValues: boolean;
154
- omitNullValues: boolean;
155
- omitEmptyStrings: boolean;
156
- excludeFields: string[];
157
- includeRelatedEntityData: boolean;
158
- relatedEntityList: DataObjectRelatedEntityParam[];
159
- constructor(oldValues?: boolean, omitNullValues?: boolean, omitEmptyStrings?: boolean, excludeFields?: string[], includeRelatedEntityData?: boolean, relatedEntityList?: DataObjectRelatedEntityParam[]);
160
- }
161
- export declare class BaseEntityAIActionParams {
162
- name: string;
163
- actionId: string;
164
- modelId: string;
165
- systemPrompt: string;
166
- userMessage: string;
167
- result: any;
168
- }
169
- /**
170
- * Used for storing the result of a Save or Delete or other transactional operation within a BaseEntity
171
- */
172
- export declare class BaseEntityResult {
173
- /**
174
- * True if successful, false otherwise
175
- */
176
- Success: boolean;
177
- /**
178
- * The type of operation that was performed
179
- */
180
- Type: 'create' | 'update' | 'delete';
181
- /**
182
- * A message for an end user
183
- */
184
- Message: string;
185
- /**
186
- * Optional, a structured error object with additional information
187
- */
188
- Error?: any;
189
- /**
190
- * Optional, a list of structured error objects with additional information
191
- */
192
- Errors?: any[];
193
- /**
194
- * A copy of the values of the entity object BEFORE the operation was performed
195
- */
196
- OriginalValues: {
197
- FieldName: string;
198
- Value: any;
199
- }[];
200
- /**
201
- * A copy of the values of the entity object AFTER the operation was performed
202
- */
203
- NewValues: {
204
- FieldName: string;
205
- Value: any;
206
- }[];
207
- /**
208
- * Timestamp when the operation started
209
- */
210
- StartedAt: Date;
211
- /**
212
- * Timestamp when the operation ended
213
- */
214
- EndedAt: Date;
215
- constructor(success?: boolean, message?: string, type?: 'create' | 'update' | 'delete');
216
- /**
217
- * Returns a complete message that includes the Message property (if present), the Error property (if present), and any Errors array items (if present).
218
- */
219
- get CompleteMessage(): string;
220
- }
221
- /**
222
- * Event type that is used to raise events and provided structured callbacks for any caller that is interested in registering for events.
223
- * This type is also used for whenever a BaseEntity instance raises an event with MJGlobal.
224
- */
225
- export declare class BaseEntityEvent {
226
- /**
227
- * The type of event that is being raised. transaction_ready is used to indicate that a transaction is ready to be submitted for execution. The TransactionGroup class uses this to know that all async preprocessing is done and it can now submit the transaction.
228
- */
229
- type: 'new_record' | 'save' | 'delete' | 'transaction_ready' | 'other';
230
- /**
231
- * If type === 'save' this property can either be 'create' or 'update' to indicate the type of save operation that was performed.
232
- */
233
- saveSubType?: 'create' | 'update';
234
- /**
235
- * Any payload that is associated with the event. This can be any type of object and is used to pass additional information about the event.
236
- */
237
- payload: any;
238
- /**
239
- * The BaseEntity object that is raising the event.
240
- */
241
- baseEntity: BaseEntity;
242
- }
243
- /**
244
- * Base class used for all entity objects. This class is abstract and is sub-classes for each particular entity using the CodeGen tool. This class provides the basic functionality for loading, saving, and validating entity objects.
245
- */
246
- export declare abstract class BaseEntity<T = unknown> {
247
- private _EntityInfo;
248
- private _Fields;
249
- private _recordLoaded;
250
- private _contextCurrentUser;
251
- private _transactionGroup;
252
- private _eventSubject;
253
- private _resultHistory;
254
- private _provider;
255
- private _everSaved;
256
- constructor(Entity: EntityInfo, Provider?: IEntityDataProvider | null);
257
- /**
258
- * Returns this provider to be used for a given instance of a BaseEntity derived subclass. If the provider is not set, the BaseEntity.Provider is returned.
259
- */
260
- get ProviderToUse(): IEntityDataProvider;
261
- /**
262
- * Returns the RunViewProvider to be used for a given instance of a BaseEntity derived subclass.
263
- */
264
- get RunViewProviderToUse(): IRunViewProvider;
265
- /**
266
- * Returns the RunQueryProvider to be used for a given instance of a BaseEntity derived subclass.
267
- */
268
- get RunQueryProviderToUse(): IRunQueryProvider;
269
- /**
270
- * Returns the RunReportProvider to be used for a given instance of a BaseEntity derived subclass.
271
- */
272
- get RunReportProviderToUse(): IRunReportProvider;
273
- /**
274
- * This method can be used to register a callback for events that will be raised by the instance of the BaseEntity object. The callback will be called with a
275
- * BaseEntityEvent object that contains the type of event and any payload that is associated with the event. Subclasses of the BaseEntity can define their
276
- * own event types and payloads as needed.
277
- * @param callback
278
- * @returns
279
- */
280
- RegisterEventHandler(callback: (event: BaseEntityEvent) => void): Subscription;
281
- /**
282
- * If the entity object has a TransactionGroup associated with it, the TransactionGroup will be notified that we are doing some transaction pre-processing so that the TransactionGroup can
283
- * properly wait for those pre-processing steps to complete before submitting the transaction. This method should generally NOT be called by anyone other than a provider that is handling
284
- * the tier-specific processing for the entity object.
285
- */
286
- RegisterTransactionPreprocessing(): void;
287
- /**
288
- * Raises the transaction_ready event. This is used to indicate that the entity object is ready to be submitted for transaction processing. This is used by the TransactionGroup class to know when all async preprocessing is
289
- * done and it can submit the transaction. This is an internal method and shouldn't be used by sub-classes or external callers in most cases. It is primarily used by Provider classes who are handling the tier-specific processing
290
- * for the entity object.
291
- */
292
- RaiseReadyForTransaction(): void;
293
- private static _baseEventCode;
294
- /**
295
- * When a BaseEntity class raises an event with MJGlobal, the eventCode property is set to this value. This is used to identify events that are raised by BaseEntity objects.
296
- * Any MJGlobal event that is raised by a BaseEntity class will use a BaseEntityEvent type as the args parameter
297
- */
298
- static get BaseEventCode(): string;
299
- /**
300
- * Used for raising events within the BaseEntity and can be used by sub-classes to raise events that are specific to the entity.
301
- */
302
- protected RaiseEvent(type: BaseEntityEvent["type"], payload: any, saveSubType?: BaseEntityEvent["saveSubType"]): void;
303
- /**
304
- * This method MUST be called right after the class is instantiated to provide an async/await pair for any asynchronous operations a given entity needs to do when it is first
305
- * created/configured. When you call Metadata/Provider GetEntityObject() this is done automatically for you. In nearly all cases you should go through GetEntityObject() anyway
306
- * and not ever directly instantiate a BaseEntity derived class.
307
- */
308
- Config(contextUser: UserInfo): Promise<void>;
309
- /**
310
- * Returns true if the record has been saved to the database, false otherwise. This is a useful property to check to determine if the record is a "New Record" or an existing one.
311
- */
312
- get IsSaved(): boolean;
313
- /**
314
- * Transaction Groups are used to group multiple transactions into a single ATOMic transaction in a database. They are also useful even in situations with ATOMicity is less important but you want
315
- * to submit a group of changes to the API server in a single network call.
316
- */
317
- get TransactionGroup(): TransactionGroupBase;
318
- set TransactionGroup(group: TransactionGroupBase);
319
- /**
320
- * The result history shows the history of the attempted transactions (Save and Delete) for this particular entity object. This is useful for tracking the results of operations on the entity object.
321
- */
322
- get ResultHistory(): BaseEntityResult[];
323
- /**
324
- * Returns the most recent result from the result history. If there are no results in the history, this method will return null.
325
- */
326
- get LatestResult(): BaseEntityResult;
327
- /**
328
- * Access to the underlying metadata for the entity object.
329
- */
330
- get EntityInfo(): EntityInfo;
331
- get Fields(): EntityField[];
332
- /**
333
- * Convenience method to access a field by name. This method is case-insensitive and will return null if the field is not found. You can do the same thing with more fine tune controlled by accessing the Fields property directly.
334
- * @param fieldName
335
- * @returns
336
- */
337
- GetFieldByName(fieldName: string): EntityField | null;
338
- /**
339
- * Returns true if the object is Dirty, meaning something has changed since it was last saved to the database, and false otherwise. For new records, this will always return true.
340
- */
341
- get Dirty(): boolean;
342
- /**
343
- * Returns an array of all primary key fields for the entity. If the entity has a composite primary key, this method will return an array of all primary key fields.
344
- * If the entity has a single primary key, this method will return an array with a single field in it.
345
- */
346
- get PrimaryKeys(): EntityField[];
347
- private _compositeKey;
348
- /**
349
- * Returns the primary key for the record. The CompositeKey class is a multi-valued key that can have any number of key/value pairs within it. Always traverse the full
350
- * set of key/value pairs to get the full primary key for the record.
351
- */
352
- get PrimaryKey(): CompositeKey;
353
- /**
354
- * Helper method to return just the first Primary Key
355
- */
356
- get FirstPrimaryKey(): EntityField;
357
- /**
358
- * Returns true if the record has been loaded from the database, false otherwise. This is useful to check to see if the record is in a "New Record" state or not.
359
- */
360
- get RecordLoaded(): boolean;
361
- /**
362
- * Sets the value of a given field. If the field doesn't exist, nothing happens.
363
- * The field's type is used to convert the value to the appropriate type.
364
- * @param FieldName
365
- * @param Value
366
- */
367
- Set(FieldName: string, Value: any): void;
368
- /**
369
- * Returns the value of the field with the given name. If the field is a date, and the value is a string, it will be converted to a date object.
370
- * @param FieldName
371
- * @returns
372
- */
373
- Get(FieldName: string): any;
374
- /**
375
- * NOTE: Do not call this method directly. Use the {@link From} method instead
376
- *
377
- * Sets any number of values on the entity object from the object passed in. The properties of the object being passed in must either match the field name (in most cases) or the CodeName (which is only different from field name if field name has spaces in it)
378
- * @param object
379
- * @param ignoreNonExistentFields - if set to true, fields that don't exist on the entity object will be ignored, if false, an error will be thrown if a field doesn't exist
380
- * @param replaceOldValues - if set to true, the old values of the fields will be reset to the values provided in the object parameter, if false, they will be left alone
381
- * @param ignoreActiveStatusAssertions - if set to true, the active status assertions for the fields will be ignored, if false, an error will be thrown if a field is not active. Defaults to false.
382
- */
383
- SetMany(object: any, ignoreNonExistentFields?: boolean, replaceOldValues?: boolean, ignoreActiveStatusAssertions?: boolean): void;
384
- /**
385
- * NOTE: Do not call this method directly. Use the {@link To} method instead
386
- *
387
- * Utility method to create an object and return it with properties in the newly created and returned object for each field in the entity object. This is useful for scenarios where you need to be able to persist the data
388
- * in a format to send to a network call, save to a file or database, etc. This method will return an object with properties that match the field names of the entity object.
389
- * @param oldValues When set to true, the old values of the fields will be returned instead of the current values.
390
- * @param onlyDirtyFields When set to true, only the fields that are dirty will be returned.
391
- * @returns
392
- */
393
- GetAll(oldValues?: boolean, onlyDirtyFields?: boolean): any;
394
- /**
395
- * Returns a partial object that contains only the fields that have changed since the last time the record was saved. This is useful for scenarios where you want to send only the changes to the server or to a client.
396
- * It is also helpful for quickly finding the fields that are "dirty".
397
- * @returns
398
- */
399
- GetChangesSinceLastSave(): Partial<T>;
400
- /**
401
- * This utility method calls GetDataObject() internally and formats the result as a JSON string. If you want to get the data as an object instead of a string, call GetDataObject() directly.
402
- * @param params
403
- * @param minifyJSON
404
- * @returns
405
- */
406
- GetDataObjectJSON(params?: DataObjectParams, minifyJSON?: boolean): Promise<string>;
407
- /**
408
- * This utility method generates a completely new object that has properties that map to the fields and values in the entity at the time it is called. It is a copy, NOT a link, so any changes
409
- * made to the object after calling this method will NOT be reflected in the object that is returned. This is useful for things like sending data to a client, or for use in a view model.
410
- * @param params
411
- * @returns
412
- */
413
- GetDataObject(params?: DataObjectParams): Promise<any>;
414
- GetRelatedEntityData(re: EntityRelationshipInfo, filter?: string, maxRecords?: number): Promise<any[]>;
415
- GetRelatedEntityDataExt(re: EntityRelationshipInfo, filter?: string, maxRecords?: number): Promise<{
416
- Data: any[];
417
- TotalRowCount: number;
418
- }>;
419
- private init;
420
- /**
421
- * This method will copy the values from the other entity object into the current one. This is useful for things like cloning a record.
422
- * This method will ONLY copy values for fields that exist in the current entity object. If the other object has fields that don't exist in the current object, they will be ignored.
423
- * @param other - the other entity object to copy values from
424
- * @param includePrimaryKeys - if true, the primary keys will be copied as well, if false, they will be ignored, defaults to false and generally you want to leave it that way
425
- * @param replaceOldValues - if true, the old values of the fields will be reset to the values provided in the other parameter, if false, they will be left alone, defaults to false and generally you want to leave it that way
426
- */
427
- CopyFrom(other: BaseEntity, includePrimaryKeys?: boolean, replaceOldValues?: boolean): boolean;
428
- /**
429
- * The ContextCurrentUser is a property used to manually set the "current" user for scenarios, primarily on the server side, where the user changes per request. For situations where there is no global CurrentUser in the Metadata.Provider,
430
- * you MUST set this property to the user you want to use for the current operation. If you used Metadata.GetEntityObject() to get the entity object, this property will be set automatically for you as that method has a parameter that can
431
- * be provided for the ContextCurrentUser.
432
- */
433
- set ContextCurrentUser(user: UserInfo);
434
- get ContextCurrentUser(): UserInfo;
435
- /**
436
- * This method will create a new state for the object that is equivalent to a new record including default values.
437
- * @param newValues - optional parameter to set the values of the fields to something other than the default values. The expected parameter is an object that has properties that map to field names in this entity.
438
- * This is the same as creating a NewRecord and then using SetMany(), but it is a convenience/helper approach.
439
- * @returns
440
- */
441
- NewRecord(newValues?: FieldValueCollection): boolean;
442
- private _pendingSave$;
443
- /**
444
- * Saves the current state of the object to the database. Uses the active provider to handle the actual saving of the record.
445
- * If the record is new, it will be created, if it already exists, it will be updated.
446
- *
447
- * Debounces multiple calls so that if Save() is called again while a save is in progress,
448
- * the second call will simply receive the same result as the first.
449
- *
450
- * @param options
451
- * @returns Promise<boolean>
452
- */
453
- Save(options?: EntitySaveOptions): Promise<boolean>;
454
- /**
455
- * Private, internal method to handle saving the current state of the object to the database. This method is called by the public facing Save() method
456
- * and is debounced to prevent multiple calls from being executed simultaneously.
457
- * @param options
458
- * @returns
459
- */
460
- private _InnerSave;
461
- private finalizeSave;
462
- /**
463
- * Internal helper method for the class and sub-classes - used to easily get the Active User which is either the ContextCurrentUser, if defined, or the Metadata.Provider.CurrentUser if not.
464
- */
465
- protected get ActiveUser(): UserInfo;
466
- /**
467
- * Utility method that returns true if the given permission being checked is enabled for the current user, and false if not.
468
- * @param type
469
- * @param throwError
470
- * @returns
471
- */
472
- CheckPermissions(type: EntityPermissionType, throwError: boolean): boolean;
473
- protected ThrowPermissionError(u: UserInfo, type: EntityPermissionType, additionalInfoMessage: string): void;
474
- /**
475
- * This method will revert the internal state of the object back to what it was when it was last saved, or if never saved, from when it was intially loaded from the database. This is useful if you want to offer a user an "undo" type of feature in a UI.
476
- * @returns
477
- */
478
- Revert(): boolean;
479
- /**
480
- * * This method loads a single record from the database. Make sure you first get the correct BaseEntity sub-class for your entity by calling Metadata.GetEntityObject() first. From there, you can
481
- * call this method to load your records.
482
- * * NOTE: You should not be calling this method directly from outside of a sub-class in most cases. You will use the auto-generated sub-classes that have overriden versions of this method that blow out the primary keys into individual parameters. This is much easier to program against.
483
- * @param CompositeKey Wrapper that holds an array of objects that contain the field name and value for the primary key of the record you want to load. For example, if you have a table called "Customers" with a primary key of "ID", you would pass in an array with a single object like this: {FieldName: "ID", Value: 1234}.
484
- * *If you had a composite primary key, you would pass in an array with multiple objects, one for each field in the primary key. You may ONLY pass in the primary key fields, no other fields are allowed.
485
- * @param EntityRelationshipsToLoad Optional, you can specify the names of the relationships to load up. This is an expensive operation as it loads up an array of the related entity objects for the main record, so use it sparingly.
486
- * @returns true if success, false otherwise
487
- */
488
- InnerLoad(CompositeKey: CompositeKey, EntityRelationshipsToLoad?: string[]): Promise<boolean>;
489
- /**
490
- * Loads entity data from a plain object, typically from database query results.
491
- *
492
- * This method is meant to be used only in situations where you are sure that the data you are loading
493
- * is current in the database. MAKE SURE YOU ARE PASSING IN ALL FIELDS. The Dirty flags and other internal
494
- * state will assume what is loading from the data parameter you pass in is equivalent to what is in the database.
495
- *
496
- * @remarks
497
- * Generally speaking, you should use Load() instead of this method. The main use cases where this makes sense are:
498
- * 1. On the server if you are pulling data you know is fresh from the result of another DB operation
499
- * 2. If on any tier you run a fresh RunView result that gives you data from the database
500
- * 3. When the RunView Object RunView() method is called with ResultType='entity_object'
501
- *
502
- * **Important for Subclasses**: As of v2.53.0, this method is now async to support subclasses that need to
503
- * perform additional asynchronous loading operations (e.g., loading related data, fetching additional metadata).
504
- *
505
- * Subclasses that need to perform additional loading should override BOTH this method AND Load() to ensure
506
- * consistent behavior regardless of how the entity is populated. This is because these two methods have
507
- * different execution paths:
508
- * - Load() fetches data from the network/database and then calls provider-specific loading
509
- * - LoadFromData() is called when data is already available (e.g., from RunView results)
510
- *
511
- * @example
512
- * ```typescript
513
- * // Subclass implementation
514
- * public override async LoadFromData(data: any, replaceOldValues: boolean = false): Promise<boolean> {
515
- * const result = await super.LoadFromData(data, replaceOldValues);
516
- * if (result) {
517
- * // Perform additional async loading here
518
- * await this.LoadRelatedData();
519
- * await this.LoadMetadata();
520
- * }
521
- * return result;
522
- * }
523
- *
524
- * // Don't forget to also override Load() for consistency, unless you INTEND to have different behavior
525
- * // for Load() vs LoadFromData()
526
- * public override async Load(ID: string, EntityRelationshipsToLoad: string[] = null): Promise<boolean> {
527
- * const result = await super.Load(ID, EntityRelationshipsToLoad);
528
- * if (result) {
529
- * // Same additional loading as in LoadFromData
530
- * await this.LoadRelatedData();
531
- * await this.LoadMetadata();
532
- * }
533
- * return result;
534
- * }
535
- * ```
536
- *
537
- * @param data - A simple object that has properties that match the field names of the entity object
538
- * @param replaceOldValues - If true, the old values of the fields will be set to the values provided
539
- * in the data parameter; if false, they will be left alone
540
- * @returns Promise<boolean> - Returns true if the load was successful
541
- */
542
- LoadFromData(data: any, _replaceOldValues?: boolean): Promise<boolean>;
543
- /**
544
- * This method is used automatically within Save() and is used to determine if the state of the object is valid relative to the validation rules that are defined in metadata. In addition, sub-classes can
545
- * override or wrap this base class method to add other logic for validation.
546
- *
547
- * @returns ValidationResult The validation result
548
- */
549
- Validate(): ValidationResult;
550
- /**
551
- * Default value for whether async validation should be skipped.
552
- * Subclasses can override this property to enable async validation by default.
553
- * When the options object is passed to Save(), and it includes a value for the
554
- * SkipAsyncValidation property, that value will take precedence over this default.
555
- *
556
- * @see {@link Save}
557
- *
558
- * @protected
559
- */
560
- get DefaultSkipAsyncValidation(): boolean;
561
- /**
562
- * Asynchronous validation method that can be overridden by subclasses to add custom async validation logic.
563
- * This method is automatically called by Save() AFTER the synchronous Validate() passes.
564
- *
565
- * IMPORTANT:
566
- * 1. This should NEVER be called INSTEAD of the synchronous Validate() method
567
- * 2. This is meant to be overridden by subclasses that need to perform async validations
568
- * 3. The base implementation just returns success - no actual validation is performed
569
- *
570
- * Subclasses should override this to add complex validations that require database queries
571
- * or other async operations that cannot be performed in the synchronous Validate() method.
572
- *
573
- * @returns Promise<ValidationResult> A promise that resolves to the validation result
574
- */
575
- ValidateAsync(): Promise<ValidationResult>;
576
- /**
577
- * This method deletes a record from the database. You must call Load() first in order to load the context of the record you are deleting.
578
- * @returns
579
- */
580
- Delete(options?: EntityDeleteOptions): Promise<boolean>;
581
- /**
582
- * Called before an Action is executed by the AI Engine
583
- * This is intended to be overriden by subclass as needed, these methods called at the right time by the execution context
584
- */
585
- BeforeEntityAIAction(params: BaseEntityAIActionParams): Promise<boolean>;
586
- /**
587
- * Called after an Action is executed by the AI Engine
588
- */
589
- AfterEntityAIAction(params: BaseEntityAIActionParams): Promise<boolean>;
590
- private static _globalProviderKey;
591
- /**
592
- * Static property to get/set the IEntityDataProvider that is used by all BaseEntity objects. This is a global setting that is used by all BaseEntity objects. It can be overriden for a given BaseEntity object instance by passing in a provider to the
593
- * constructor of the BaseEntity object. Typically, a provider will pass itself into BaseEntity objects it creates to create a tight coupling between the provider and the BaseEntity objects it creates. This allows multiple concurrent
594
- * connections to exist in the same process space without interfering with each other.
595
- */
596
- static get Provider(): IEntityDataProvider;
597
- static set Provider(value: IEntityDataProvider);
598
- /**
599
- * Returns a list of changes made to this record, over time. Only works if TrackRecordChanges bit set to 1 on the entity you're working with.
600
- */
601
- get RecordChanges(): Promise<RecordChange[]>;
602
- /**
603
- * Static Utility method to get RecordChanges for a given entityName/KeyValuePair combination
604
- * @param entityName
605
- * @returns
606
- */
607
- static GetRecordChanges(entityName: string, primaryKey: CompositeKey, provider?: IEntityDataProvider | null): Promise<RecordChange[]>;
608
- /**
609
- * Strongly-typed wrapper for the {@link SetMany} method.
610
- * @oaram data - the data to set on the entity object
611
- * @param schema - the zod schema to validate the data against
612
- */
613
- From<K extends z.AnyZodObject>(data: unknown, schema?: z.infer<K>): boolean;
614
- /**
615
- * Strongly-typed wrapper for the {@link GetAll} method
616
- * @param schema - the zod schema to validate the data against
617
- */
618
- To<K extends z.AnyZodObject>(schema?: K): z.infer<K> | null;
619
- /**
620
- * Generates vector embeddings for multiple text fields by their field names.
621
- * Processes fields in parallel for better performance.
622
- * @param fields - Array of field configurations specifying source text field, target vector field, and model ID field names
623
- * @returns Promise that resolves to true if all embeddings were generated successfully, false if any failed
624
- */
625
- protected GenerateEmbeddingsByFieldName(fields: Array<{
626
- fieldName: string;
627
- vectorFieldName: string;
628
- modelFieldName: string;
629
- }>): Promise<boolean>;
630
- /**
631
- * Generates a vector embedding for a single text field identified by field name.
632
- * Retrieves the field objects and delegates to GenerateEmbedding method.
633
- * @param fieldName - Name of the text field to generate embedding from
634
- * @param vectorFieldName - Name of the field to store the vector embedding
635
- * @param modelFieldName - Name of the field to store the model ID used for embedding
636
- * @returns Promise that resolves to true if embedding was generated successfully, false otherwise
637
- */
638
- protected GenerateEmbeddingByFieldName(fieldName: string, vectorFieldName: string, modelFieldName: string): Promise<boolean>;
639
- /**
640
- * Generates vector embeddings for multiple text fields using EntityField objects.
641
- * Processes fields in parallel for better performance.
642
- * @param fields - Array of field configurations with EntityField objects for source, vector, and model fields
643
- * @returns Promise that resolves to true if all embeddings were generated successfully, false if any failed
644
- */
645
- protected GenerateEmbeddings(fields: Array<{
646
- field: EntityField;
647
- vectorField: EntityField;
648
- modelField: EntityField;
649
- }>): Promise<boolean>;
650
- /**
651
- * Generates a vector embedding for a single text field using AI engine.
652
- * Only generates embeddings for new records or when the source field has changed.
653
- * Stores both the vector embedding and the model ID used to generate it.
654
- * @param field - The EntityField containing the text to embed
655
- * @param vectorField - The EntityField to store the generated vector embedding (as JSON string)
656
- * @param modelField - The EntityField to store the ID of the AI model used
657
- * @returns Promise that resolves to true if embedding was generated successfully, false otherwise
658
- */
659
- protected GenerateEmbedding(field: EntityField, vectorField: EntityField, modelField: EntityField): Promise<boolean>;
660
- /**
661
- * In the BaseEntity class this method is not implemented. This method shoudl be implemented only in
662
- * **server-side** sub-classes only by calling AIEngine or other methods to generate embeddings for a given
663
- * piece of text provided. Subclasses that override this method to implement embedding support should also
664
- * override @see SupportsEmbedTextLocal and return true
665
- * @param textToEmbed
666
- */
667
- protected EmbedTextLocal(textToEmbed: string): Promise<SimpleEmbeddingResult>;
668
- /**
669
- * Specifies if the current object supports the @see EmbedTextLocal method or not - useful to know before calling it for conditional
670
- * code that has fallbacks as needed. BaseEntity does not implement this method but server-side sub-classes often do, but it is not mandatory for
671
- * any sub-class.
672
- * @returns
673
- */
674
- SupportsEmbedTextLocal(): boolean;
675
- /**
676
- * private storage for vectors that might be used for this entity, typically in association with individual fields
677
- * however it is possible for the string in the map to be any unique key relative to the object so you could have vectors
678
- * that embed multiple fields if desired.
679
- */
680
- private _vectors;
681
- /**
682
- * Utility storage for vector embeddings that represent the active record. Each string in the Map can be any unique key relative to the object so you can
683
- * use this to track vectors associated with
684
- */
685
- get Vectors(): Map<string, number[]>;
686
- /**
687
- * Resets the vector embeddings for this entity to an empty state.
688
- */
689
- ResetVectors(): void;
690
- }
691
- //# sourceMappingURL=baseEntity.d.ts.map