@memberjunction/core 0.9.165 → 0.9.166

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 (63) hide show
  1. package/dist/MJCore/src/generic/applicationInfo.d.ts +26 -0
  2. package/dist/MJCore/src/generic/applicationInfo.js +57 -0
  3. package/dist/MJCore/src/generic/applicationInfo.js.map +1 -0
  4. package/dist/MJCore/src/generic/baseEntity.d.ts +195 -0
  5. package/dist/MJCore/src/generic/baseEntity.js +674 -0
  6. package/dist/MJCore/src/generic/baseEntity.js.map +1 -0
  7. package/dist/MJCore/src/generic/baseInfo.d.ts +8 -0
  8. package/dist/MJCore/src/generic/baseInfo.js +38 -0
  9. package/dist/MJCore/src/generic/baseInfo.js.map +1 -0
  10. package/dist/MJCore/src/generic/entityInfo.d.ts +520 -0
  11. package/dist/MJCore/src/generic/entityInfo.js +801 -0
  12. package/dist/MJCore/src/generic/entityInfo.js.map +1 -0
  13. package/dist/MJCore/src/generic/interfaces.d.ts +288 -0
  14. package/dist/MJCore/src/generic/interfaces.js +50 -0
  15. package/dist/MJCore/src/generic/interfaces.js.map +1 -0
  16. package/dist/MJCore/src/generic/logging.d.ts +4 -0
  17. package/dist/MJCore/src/generic/logging.js +69 -0
  18. package/dist/MJCore/src/generic/logging.js.map +1 -0
  19. package/dist/MJCore/src/generic/metadata.d.ts +201 -0
  20. package/dist/MJCore/src/generic/metadata.js +312 -0
  21. package/dist/MJCore/src/generic/metadata.js.map +1 -0
  22. package/dist/MJCore/src/generic/providerBase.d.ts +183 -0
  23. package/dist/MJCore/src/generic/providerBase.js +640 -0
  24. package/dist/MJCore/src/generic/providerBase.js.map +1 -0
  25. package/dist/MJCore/src/generic/queryInfo.d.ts +64 -0
  26. package/dist/MJCore/src/generic/queryInfo.js +124 -0
  27. package/dist/MJCore/src/generic/queryInfo.js.map +1 -0
  28. package/dist/MJCore/src/generic/runQuery.d.ts +11 -0
  29. package/dist/MJCore/src/generic/runQuery.js +26 -0
  30. package/dist/MJCore/src/generic/runQuery.js.map +1 -0
  31. package/dist/MJCore/src/generic/runReport.d.ts +11 -0
  32. package/dist/MJCore/src/generic/runReport.js +27 -0
  33. package/dist/MJCore/src/generic/runReport.js.map +1 -0
  34. package/dist/MJCore/src/generic/securityInfo.d.ts +100 -0
  35. package/dist/MJCore/src/generic/securityInfo.js +194 -0
  36. package/dist/MJCore/src/generic/securityInfo.js.map +1 -0
  37. package/dist/MJCore/src/generic/transactionGroup.d.ts +24 -0
  38. package/dist/MJCore/src/generic/transactionGroup.js +79 -0
  39. package/dist/MJCore/src/generic/transactionGroup.js.map +1 -0
  40. package/dist/MJCore/src/generic/util.d.ts +16 -0
  41. package/dist/MJCore/src/generic/util.js +151 -0
  42. package/dist/MJCore/src/generic/util.js.map +1 -0
  43. package/dist/MJCore/src/index.d.ts +16 -0
  44. package/dist/MJCore/src/index.js +44 -0
  45. package/dist/MJCore/src/index.js.map +1 -0
  46. package/dist/MJCore/src/views/runView.d.ts +112 -0
  47. package/dist/MJCore/src/views/runView.js +63 -0
  48. package/dist/MJCore/src/views/runView.js.map +1 -0
  49. package/dist/MJCore/src/views/viewInfo.d.ts +59 -0
  50. package/dist/MJCore/src/views/viewInfo.js +121 -0
  51. package/dist/MJCore/src/views/viewInfo.js.map +1 -0
  52. package/dist/MJGlobal/src/ObjectCache.d.ts +26 -0
  53. package/dist/MJGlobal/src/ObjectCache.js +55 -0
  54. package/dist/MJGlobal/src/ObjectCache.js.map +1 -0
  55. package/dist/generic/interfaces.d.ts +2 -0
  56. package/dist/generic/interfaces.js.map +1 -1
  57. package/dist/generic/objectCache.d.ts +26 -0
  58. package/dist/generic/objectCache.js +55 -0
  59. package/dist/generic/objectCache.js.map +1 -0
  60. package/dist/generic/providerBase.d.ts +7 -0
  61. package/dist/generic/providerBase.js +9 -0
  62. package/dist/generic/providerBase.js.map +1 -1
  63. package/package.json +2 -2
@@ -0,0 +1,26 @@
1
+ import { BaseInfo } from './baseInfo';
2
+ import { EntityInfo } from './entityInfo';
3
+ import { IMetadataProvider } from './interfaces';
4
+ export declare class ApplicationEntityInfo extends BaseInfo {
5
+ ApplicationName: string;
6
+ EntityID: number;
7
+ Sequence: number;
8
+ DefaultForNewUser: boolean;
9
+ Application: string;
10
+ Entity: string;
11
+ EntityBaseTable: string;
12
+ EntityCodeName: string;
13
+ EntityClassName: string;
14
+ EntityBaseTableCodeName: string;
15
+ private _EntityInfo;
16
+ get EntityInfo(): EntityInfo;
17
+ _setEntity(entity: EntityInfo): void;
18
+ constructor(initData?: any);
19
+ }
20
+ export declare class ApplicationInfo extends BaseInfo {
21
+ Name: string;
22
+ Description: string;
23
+ private _ApplicationEntities;
24
+ get ApplicationEntities(): ApplicationEntityInfo[];
25
+ constructor(md: IMetadataProvider, initData?: any);
26
+ }
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApplicationInfo = exports.ApplicationEntityInfo = void 0;
4
+ const baseInfo_1 = require("./baseInfo");
5
+ class ApplicationEntityInfo extends baseInfo_1.BaseInfo {
6
+ get EntityInfo() {
7
+ return this._EntityInfo;
8
+ }
9
+ _setEntity(entity) {
10
+ this._EntityInfo = entity;
11
+ }
12
+ constructor(initData = null) {
13
+ super();
14
+ this.ApplicationName = null;
15
+ this.EntityID = null;
16
+ this.Sequence = null;
17
+ this.DefaultForNewUser = null;
18
+ this.Application = null;
19
+ this.Entity = null;
20
+ this.EntityBaseTable = null;
21
+ this.EntityCodeName = null;
22
+ this.EntityClassName = null;
23
+ this.EntityBaseTableCodeName = null;
24
+ this._EntityInfo = null;
25
+ this.copyInitData(initData);
26
+ }
27
+ }
28
+ exports.ApplicationEntityInfo = ApplicationEntityInfo;
29
+ class ApplicationInfo extends baseInfo_1.BaseInfo {
30
+ get ApplicationEntities() {
31
+ return this._ApplicationEntities;
32
+ }
33
+ constructor(md, initData = null) {
34
+ super();
35
+ this.Name = null;
36
+ this.Description = null;
37
+ this._ApplicationEntities = [];
38
+ this.copyInitData(initData);
39
+ if (initData) {
40
+ let ae = initData.ApplicationEntities || initData._ApplicationEntities;
41
+ if (ae) {
42
+ const mdEntities = md.Entities;
43
+ this._ApplicationEntities = [];
44
+ for (let i = 0; i < ae.length; i++) {
45
+ //
46
+ const aei = new ApplicationEntityInfo(ae[i]);
47
+ this._ApplicationEntities.push(aei);
48
+ const match = mdEntities.find(e => e.ID == ae[i].EntityID);
49
+ if (match)
50
+ aei._setEntity(match);
51
+ }
52
+ }
53
+ }
54
+ }
55
+ }
56
+ exports.ApplicationInfo = ApplicationInfo;
57
+ //# sourceMappingURL=applicationInfo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applicationInfo.js","sourceRoot":"","sources":["../../../../src/generic/applicationInfo.ts"],"names":[],"mappings":";;;AAAA,yCAAqC;AAIrC,MAAa,qBAAsB,SAAQ,mBAAQ;IAa/C,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,WAAW,CAAA;IAC3B,CAAC;IAED,UAAU,CAAC,MAAkB;QACzB,IAAI,CAAC,WAAW,GAAG,MAAM,CAAA;IAC7B,CAAC;IAED,YAAa,WAAgB,IAAI;QAC7B,KAAK,EAAE,CAAA;QArBX,oBAAe,GAAW,IAAI,CAAA;QAC9B,aAAQ,GAAW,IAAI,CAAA;QACvB,aAAQ,GAAW,IAAI,CAAA;QACvB,sBAAiB,GAAY,IAAI,CAAA;QACjC,gBAAW,GAAW,IAAI,CAAA;QAC1B,WAAM,GAAW,IAAI,CAAA;QACrB,oBAAe,GAAW,IAAI,CAAA;QAC9B,mBAAc,GAAW,IAAI,CAAA;QAC7B,oBAAe,GAAW,IAAI,CAAA;QAC9B,4BAAuB,GAAW,IAAI,CAAA;QAE9B,gBAAW,GAAe,IAAI,CAAA;QAWlC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAA;IAC/B,CAAC;CACJ;AAzBD,sDAyBC;AAED,MAAa,eAAgB,SAAQ,mBAAQ;IAKzC,IAAW,mBAAmB;QAC1B,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACrC,CAAC;IAED,YAAa,EAAqB,EAAE,WAAgB,IAAI;QACpD,KAAK,EAAE,CAAA;QATX,SAAI,GAAW,IAAI,CAAA;QACnB,gBAAW,GAAW,IAAI,CAAA;QAElB,yBAAoB,GAA4B,EAAE,CAAA;QAOtD,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAA;QAC3B,IAAI,QAAQ,EAAE,CAAC;YACX,IAAI,EAAE,GAAG,QAAQ,CAAC,mBAAmB,IAAI,QAAQ,CAAC,oBAAoB,CAAC;YACvE,IAAI,EAAE,EAAE,CAAC;gBACL,MAAM,UAAU,GAAG,EAAE,CAAC,QAAQ,CAAC;gBAC/B,IAAI,CAAC,oBAAoB,GAAG,EAAE,CAAC;gBAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;oBACjC,GAAG;oBACH,MAAM,GAAG,GAAG,IAAI,qBAAqB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;oBAC5C,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;oBAEnC,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;oBAC1D,IAAI,KAAK;wBACL,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;gBAC7B,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;CAEJ;AA9BD,0CA8BC"}
@@ -0,0 +1,195 @@
1
+ import { EntityFieldInfo, EntityInfo, EntityFieldTSType, EntityPermissionType, RecordChange, ValidationResult, EntityRelationshipInfo, PrimaryKeyValue } from './entityInfo';
2
+ import { EntitySaveOptions, IEntityDataProvider } from './interfaces';
3
+ import { UserInfo } from './securityInfo';
4
+ import { TransactionGroupBase } from './transactionGroup';
5
+ export declare class EntityField {
6
+ private _entityFieldInfo;
7
+ private _OldValue;
8
+ private _Value;
9
+ private _NeverSet;
10
+ get Name(): string;
11
+ get FieldType(): EntityFieldTSType;
12
+ get SQLType(): string;
13
+ get IsPrimaryKey(): boolean;
14
+ get NeedsQuotes(): boolean;
15
+ /**
16
+ * Removes spaces from the field name and returns the result.
17
+ */
18
+ get CodeName(): string;
19
+ get IsUnique(): boolean;
20
+ get Value(): any;
21
+ get ReadOnly(): boolean;
22
+ get EntityFieldInfo(): EntityFieldInfo;
23
+ set Value(value: any);
24
+ get Dirty(): boolean;
25
+ FormatValue(decimals?: number, currency?: string): string;
26
+ Validate(): ValidationResult;
27
+ constructor(fieldInfo: EntityFieldInfo, Value?: any);
28
+ ResetOldValue(): void;
29
+ get OldValue(): any;
30
+ }
31
+ export declare class DataObjectRelatedEntityParam {
32
+ relatedEntityName: string;
33
+ filter?: string;
34
+ }
35
+ export declare class DataObjectParams {
36
+ oldValues: boolean;
37
+ omitNullValues: boolean;
38
+ omitEmptyStrings: boolean;
39
+ excludeFields: string[];
40
+ includeRelatedEntityData: boolean;
41
+ relatedEntityList: DataObjectRelatedEntityParam[];
42
+ }
43
+ export declare class BaseEntityAIActionParams {
44
+ name: string;
45
+ actionId: number;
46
+ modelId: number;
47
+ systemPrompt: string;
48
+ userMessage: string;
49
+ result: any;
50
+ }
51
+ export declare abstract class BaseEntity {
52
+ private _EntityInfo;
53
+ private _Fields;
54
+ private _recordLoaded;
55
+ private _contextCurrentUser;
56
+ private _transactionGroup;
57
+ constructor(Entity: EntityInfo);
58
+ /**
59
+ * 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.
60
+ */
61
+ get IsSaved(): boolean;
62
+ get TransactionGroup(): TransactionGroupBase;
63
+ set TransactionGroup(group: TransactionGroupBase);
64
+ get EntityInfo(): EntityInfo;
65
+ get Fields(): EntityField[];
66
+ GetFieldByName(fieldName: string): EntityField;
67
+ get Dirty(): boolean;
68
+ get PrimaryKey(): EntityField;
69
+ get PrimaryKeys(): EntityField[];
70
+ get RecordLoaded(): boolean;
71
+ /**
72
+ * Sets the value of a given field. If the field doesn't exist, nothing happens.
73
+ * @param FieldName
74
+ * @param Value
75
+ */
76
+ Set(FieldName: string, Value: any): void;
77
+ /**
78
+ * 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.
79
+ * @param FieldName
80
+ * @returns
81
+ */
82
+ Get(FieldName: string): any;
83
+ /**
84
+ * 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)
85
+ * @param object
86
+ * @param ignoreNonExistentFields
87
+ */
88
+ SetMany(object: any, ignoreNonExistentFields?: boolean): void;
89
+ GetAll(oldValues?: boolean): {};
90
+ /**
91
+ * 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.
92
+ * @param params
93
+ * @param minifyJSON
94
+ * @returns
95
+ */
96
+ GetDataObjectJSON(params: DataObjectParams, minifyJSON?: boolean): Promise<string>;
97
+ /**
98
+ * 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
99
+ * 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.
100
+ * @param params
101
+ * @returns
102
+ */
103
+ GetDataObject(params: DataObjectParams): Promise<any>;
104
+ GetRelatedEntityData(re: EntityRelationshipInfo, filter?: string): Promise<any[]>;
105
+ private init;
106
+ /**
107
+ * This method will copy the values from the other entity object into the current one. This is useful for things like cloning a record.
108
+ * 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.
109
+ * @param other
110
+ * @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
111
+ */
112
+ CopyFrom(other: BaseEntity, includePrimaryKeys?: boolean): boolean;
113
+ set ContextCurrentUser(user: UserInfo);
114
+ get ContextCurrentUser(): UserInfo;
115
+ /**
116
+ * This method will create a new state for the object that is equivalent to a new record including default values.
117
+ * @returns
118
+ */
119
+ NewRecord(): boolean;
120
+ /**
121
+ * Saves the current state of the object to the database. Uses the active provider to handle the actual saving of the record. If the record is new, it will be created, if it already exists, it will be updated.
122
+ * @param options
123
+ * @returns
124
+ */
125
+ Save(options?: EntitySaveOptions): Promise<boolean>;
126
+ protected get ActiveUser(): UserInfo;
127
+ /**
128
+ * Utility method that returns true if the given permission being checked is enabled for the current user, and false if not.
129
+ * @param type
130
+ * @param throwError
131
+ * @returns
132
+ */
133
+ CheckPermissions(type: EntityPermissionType, throwError: boolean): boolean;
134
+ protected ThrowPermissionError(u: UserInfo, type: EntityPermissionType, additionalInfoMessage: string): void;
135
+ /**
136
+ * 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.
137
+ * @returns
138
+ */
139
+ Revert(): boolean;
140
+ /**
141
+ * * 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
142
+ * call this method to load your records.
143
+ * * 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.
144
+ * @param PrimaryKeyValues 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}.
145
+ * *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.
146
+ * @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.
147
+ * @returns true if success, false otherwise
148
+ */
149
+ InnerLoad(PrimaryKeyValues: PrimaryKeyValue[], EntityRelationshipsToLoad?: string[]): Promise<boolean>;
150
+ protected ValidatePrimaryKeyArray(PrimaryKeyValues: PrimaryKeyValue[]): void;
151
+ /**
152
+ * This method is meant to be used only in situations where you are sure that the data you are loading is current in the database. MAKE SURE YOU ARE PASSING IN ALL FIELDS.
153
+ * The Dirty flags and other internal state will assume what is loading from the data parameter you pass in is equivalent to what is in the database. Generally speaking, you should use Load() instead of this method. The main use case(s) where this makes sense are:
154
+ * (1) On the server if you are pulling data you know is fresh from say the result of another DB operation
155
+ * (2) If on any tier you run a fresh RunView result, that gives you data from the database, you can then instantiate objects via Metadata.GetEntityObject() and then use this with the result from the RunView call
156
+ * *** Note: for the #2 use case, when you call the RunView Object RunView() method with the ResultType='entity_object', you'll get an array of BaseEntity-derived objects instead of simple objects, that functionality utilizes this method
157
+ * @param data
158
+ * @returns
159
+ */
160
+ LoadFromData(data: any): boolean;
161
+ /**
162
+ * 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
163
+ * override or wrap this base class method to add other logic for validation.
164
+ * @returns
165
+ */
166
+ Validate(): ValidationResult;
167
+ /**
168
+ * 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.
169
+ * @returns
170
+ */
171
+ Delete(): Promise<boolean>;
172
+ /**
173
+ * Called before an Action is executed by the AI Engine
174
+ * This is intended to be overriden by subclass as needed, these methods called at the right time by the execution context
175
+ */
176
+ BeforeEntityAIAction(params: BaseEntityAIActionParams): Promise<boolean>;
177
+ /**
178
+ * Called after an Action is executed by the AI Engine
179
+ */
180
+ AfterEntityAIAction(params: BaseEntityAIActionParams): Promise<boolean>;
181
+ private static _globalProviderKey;
182
+ static get Provider(): IEntityDataProvider;
183
+ static set Provider(value: IEntityDataProvider);
184
+ /**
185
+ * Returns a list of changes made to this record, over time. Keep in mind this is only going to return valid data if you have the TrackRecordChanges bit set to 1 on the entity you're working with.
186
+ */
187
+ get RecordChanges(): Promise<RecordChange[]>;
188
+ /**
189
+ * Static Utility method to get RecordChanges for a given entityName/PrimaryKeyValue combination
190
+ * @param entityName
191
+ * @param PrimaryKeyValue
192
+ * @returns
193
+ */
194
+ static GetRecordChanges(entityName: string, PrimaryKeyValue: any): Promise<RecordChange[]>;
195
+ }