@memberjunction/global 2.111.0 → 2.112.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.
- package/dist/Core.d.ts +29 -0
- package/dist/Core.d.ts.map +1 -0
- package/dist/Core.js +58 -0
- package/dist/Core.js.map +1 -0
- package/dist/generic/QueryCache.d.ts +85 -0
- package/dist/generic/QueryCache.d.ts.map +1 -0
- package/dist/generic/QueryCache.js +198 -0
- package/dist/generic/QueryCache.js.map +1 -0
- package/dist/generic/QueryCacheConfig.d.ts +72 -0
- package/dist/generic/QueryCacheConfig.d.ts.map +1 -0
- package/dist/generic/QueryCacheConfig.js +3 -0
- package/dist/generic/QueryCacheConfig.js.map +1 -0
- package/dist/generic/applicationInfo.d.ts +138 -0
- package/dist/generic/applicationInfo.d.ts.map +1 -0
- package/dist/generic/applicationInfo.js +177 -0
- package/dist/generic/applicationInfo.js.map +1 -0
- package/dist/generic/authEvaluator.d.ts +25 -0
- package/dist/generic/authEvaluator.d.ts.map +1 -0
- package/dist/generic/authEvaluator.js +49 -0
- package/dist/generic/authEvaluator.js.map +1 -0
- package/dist/generic/authTypes.d.ts +193 -0
- package/dist/generic/authTypes.d.ts.map +1 -0
- package/dist/generic/authTypes.js +19 -0
- package/dist/generic/authTypes.js.map +1 -0
- package/dist/generic/baseEngine.d.ts +260 -0
- package/dist/generic/baseEngine.d.ts.map +1 -0
- package/dist/generic/baseEngine.js +510 -0
- package/dist/generic/baseEngine.js.map +1 -0
- package/dist/generic/baseEntity.d.ts +691 -0
- package/dist/generic/baseEntity.d.ts.map +1 -0
- package/dist/generic/baseEntity.js +1688 -0
- package/dist/generic/baseEntity.js.map +1 -0
- package/dist/generic/baseInfo.d.ts +24 -0
- package/dist/generic/baseInfo.d.ts.map +1 -0
- package/dist/generic/baseInfo.js +53 -0
- package/dist/generic/baseInfo.js.map +1 -0
- package/dist/generic/compositeKey.d.ts +206 -0
- package/dist/generic/compositeKey.d.ts.map +1 -0
- package/dist/generic/compositeKey.js +412 -0
- package/dist/generic/compositeKey.js.map +1 -0
- package/dist/generic/databaseProviderBase.d.ts +46 -0
- package/dist/generic/databaseProviderBase.d.ts.map +1 -0
- package/dist/generic/databaseProviderBase.js +14 -0
- package/dist/generic/databaseProviderBase.js.map +1 -0
- package/dist/generic/entityInfo.d.ts +983 -0
- package/dist/generic/entityInfo.d.ts.map +1 -0
- package/dist/generic/entityInfo.js +1401 -0
- package/dist/generic/entityInfo.js.map +1 -0
- package/dist/generic/explorerNavigationItem.d.ts +20 -0
- package/dist/generic/explorerNavigationItem.d.ts.map +1 -0
- package/dist/generic/explorerNavigationItem.js +29 -0
- package/dist/generic/explorerNavigationItem.js.map +1 -0
- package/dist/generic/interfaces.d.ts +610 -0
- package/dist/generic/interfaces.d.ts.map +1 -0
- package/dist/generic/interfaces.js +211 -0
- package/dist/generic/interfaces.js.map +1 -0
- package/dist/generic/libraryInfo.d.ts +40 -0
- package/dist/generic/libraryInfo.d.ts.map +1 -0
- package/dist/generic/libraryInfo.js +56 -0
- package/dist/generic/libraryInfo.js.map +1 -0
- package/dist/generic/logging.d.ts +179 -0
- package/dist/generic/logging.d.ts.map +1 -0
- package/dist/generic/logging.js +382 -0
- package/dist/generic/logging.js.map +1 -0
- package/dist/generic/metadata.d.ts +305 -0
- package/dist/generic/metadata.d.ts.map +1 -0
- package/dist/generic/metadata.js +454 -0
- package/dist/generic/metadata.js.map +1 -0
- package/dist/generic/metadataUtil.d.ts +8 -0
- package/dist/generic/metadataUtil.d.ts.map +1 -0
- package/dist/generic/metadataUtil.js +36 -0
- package/dist/generic/metadataUtil.js.map +1 -0
- package/dist/generic/providerBase.d.ts +546 -0
- package/dist/generic/providerBase.d.ts.map +1 -0
- package/dist/generic/providerBase.js +999 -0
- package/dist/generic/providerBase.js.map +1 -0
- package/dist/generic/queryInfo.d.ts +460 -0
- package/dist/generic/queryInfo.d.ts.map +1 -0
- package/dist/generic/queryInfo.js +633 -0
- package/dist/generic/queryInfo.js.map +1 -0
- package/dist/generic/querySQLFilters.d.ts +54 -0
- package/dist/generic/querySQLFilters.d.ts.map +1 -0
- package/dist/generic/querySQLFilters.js +84 -0
- package/dist/generic/querySQLFilters.js.map +1 -0
- package/dist/generic/runQuery.d.ts +96 -0
- package/dist/generic/runQuery.d.ts.map +1 -0
- package/dist/generic/runQuery.js +66 -0
- package/dist/generic/runQuery.js.map +1 -0
- package/dist/generic/runQuerySQLFilterImplementations.d.ts +51 -0
- package/dist/generic/runQuerySQLFilterImplementations.d.ts.map +1 -0
- package/dist/generic/runQuerySQLFilterImplementations.js +238 -0
- package/dist/generic/runQuerySQLFilterImplementations.js.map +1 -0
- package/dist/generic/runReport.d.ts +25 -0
- package/dist/generic/runReport.d.ts.map +1 -0
- package/dist/generic/runReport.js +42 -0
- package/dist/generic/runReport.js.map +1 -0
- package/dist/generic/securityInfo.d.ts +355 -0
- package/dist/generic/securityInfo.d.ts.map +1 -0
- package/dist/generic/securityInfo.js +425 -0
- package/dist/generic/securityInfo.js.map +1 -0
- package/dist/generic/transactionGroup.d.ts +184 -0
- package/dist/generic/transactionGroup.d.ts.map +1 -0
- package/dist/generic/transactionGroup.js +357 -0
- package/dist/generic/transactionGroup.js.map +1 -0
- package/dist/generic/util.d.ts +81 -0
- package/dist/generic/util.d.ts.map +1 -0
- package/dist/generic/util.js +301 -0
- package/dist/generic/util.js.map +1 -0
- package/dist/views/runView.d.ts +150 -0
- package/dist/views/runView.d.ts.map +1 -0
- package/dist/views/runView.js +100 -0
- package/dist/views/runView.js.map +1 -0
- package/dist/views/viewInfo.d.ts +121 -0
- package/dist/views/viewInfo.d.ts.map +1 -0
- package/dist/views/viewInfo.js +182 -0
- package/dist/views/viewInfo.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Metadata = void 0;
|
|
4
|
+
const securityInfo_1 = require("./securityInfo");
|
|
5
|
+
const logging_1 = require("./logging");
|
|
6
|
+
const compositeKey_1 = require("./compositeKey");
|
|
7
|
+
const runView_1 = require("../views/runView");
|
|
8
|
+
const Global_1 = require("../Global");
|
|
9
|
+
/**
|
|
10
|
+
* Class used to access a wide array of MemberJunction metadata, to instantiate derived classes of BaseEntity for record access and manipulation and more. This class uses a provider model where different providers transparently plug-in to implement the functionality needed based on where the code is running. The provider in use is generally not of any importance to users of the class and code can be written indepdenent of tier/provider.
|
|
11
|
+
*/
|
|
12
|
+
class Metadata {
|
|
13
|
+
/**
|
|
14
|
+
* When an application initializes, the Provider package that is being used for that application will handle setting the provider globally via this static property.
|
|
15
|
+
* This is done so that the provider can be accessed from anywhere in the application without having to pass it around. This pattern is used sparingly in MJ.
|
|
16
|
+
*/
|
|
17
|
+
static get Provider() {
|
|
18
|
+
const g = Global_1.MJGlobal.Instance.GetGlobalObjectStore();
|
|
19
|
+
if (g)
|
|
20
|
+
return g[Metadata._globalProviderKey];
|
|
21
|
+
else
|
|
22
|
+
throw new Error('No global object store, so we cant get the static provider');
|
|
23
|
+
}
|
|
24
|
+
static set Provider(value) {
|
|
25
|
+
const g = Global_1.MJGlobal.Instance.GetGlobalObjectStore();
|
|
26
|
+
if (g)
|
|
27
|
+
g[Metadata._globalProviderKey] = value;
|
|
28
|
+
else
|
|
29
|
+
throw new Error('No global object store, so we cant set the static provider');
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Forces a refresh of all cached metadata.
|
|
33
|
+
* @returns
|
|
34
|
+
*/
|
|
35
|
+
async Refresh(providerToUse) {
|
|
36
|
+
return await Metadata.Provider.Refresh(providerToUse);
|
|
37
|
+
}
|
|
38
|
+
get ProviderType() {
|
|
39
|
+
return Metadata.Provider.ProviderType;
|
|
40
|
+
}
|
|
41
|
+
get Applications() {
|
|
42
|
+
return Metadata.Provider.Applications;
|
|
43
|
+
}
|
|
44
|
+
get Entities() {
|
|
45
|
+
return Metadata.Provider.Entities;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Helper method to find an entity by name in a case insensitive manner.
|
|
49
|
+
* @param entityName
|
|
50
|
+
*/
|
|
51
|
+
EntityByName(entityName) {
|
|
52
|
+
if (!entityName || typeof entityName !== 'string' || entityName.trim().length === 0) {
|
|
53
|
+
throw new Error('EntityByName: entityName must be a non-empty string');
|
|
54
|
+
}
|
|
55
|
+
return this.Entities.find((e) => e.Name.toLowerCase().trim() === entityName.toLowerCase().trim());
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Helper method to find an entity by ID
|
|
59
|
+
* @param entityID
|
|
60
|
+
* @returns
|
|
61
|
+
*/
|
|
62
|
+
EntityByID(entityID) {
|
|
63
|
+
return this.Entities.find((e) => e.ID === entityID);
|
|
64
|
+
}
|
|
65
|
+
get Queries() {
|
|
66
|
+
return Metadata.Provider.Queries;
|
|
67
|
+
}
|
|
68
|
+
get QueryFields() {
|
|
69
|
+
return Metadata.Provider.QueryFields;
|
|
70
|
+
}
|
|
71
|
+
get QueryCategories() {
|
|
72
|
+
return Metadata.Provider.QueryCategories;
|
|
73
|
+
}
|
|
74
|
+
get QueryPermissions() {
|
|
75
|
+
return Metadata.Provider.QueryPermissions;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Returns the current user, if known. In some execution environments, mainly on server tiers like in a node.js environment, there won't be a "current user" known to Metadata since the Metadata instance is shared across all requests. In this situation you should determine the current user from the server context where you get the user payload and find the user from the UserCache.
|
|
79
|
+
*/
|
|
80
|
+
get CurrentUser() {
|
|
81
|
+
return Metadata.Provider.CurrentUser;
|
|
82
|
+
}
|
|
83
|
+
get Roles() {
|
|
84
|
+
return Metadata.Provider.Roles;
|
|
85
|
+
}
|
|
86
|
+
get AuditLogTypes() {
|
|
87
|
+
return Metadata.Provider.AuditLogTypes;
|
|
88
|
+
}
|
|
89
|
+
get Authorizations() {
|
|
90
|
+
return Metadata.Provider.Authorizations;
|
|
91
|
+
}
|
|
92
|
+
get Libraries() {
|
|
93
|
+
return Metadata.Provider.Libraries;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Returns all of the ExplorerNavigationItems that are visible to the user, sorted by Sequence. Filtered by the IsActive bit.
|
|
97
|
+
*/
|
|
98
|
+
get VisibleExplorerNavigationItems() {
|
|
99
|
+
return Metadata.Provider.VisibleExplorerNavigationItems;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Returns all of the ExplorerNavigationItems, including those that are not visible. This is useful for admin tools and other places where you need to see all of the navigation items, not just the ones that are visible to the user.
|
|
103
|
+
*/
|
|
104
|
+
get AllExplorerNavigationItems() {
|
|
105
|
+
return Metadata.Provider.AllExplorerNavigationItems;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Helper function to return an Entity Name from a given Entity ID.
|
|
109
|
+
* @param entityName
|
|
110
|
+
* @returns
|
|
111
|
+
*/
|
|
112
|
+
EntityIDFromName(entityName) {
|
|
113
|
+
let entity = this.Entities.find((e) => e.Name == entityName);
|
|
114
|
+
if (entity != null)
|
|
115
|
+
return entity.ID;
|
|
116
|
+
else
|
|
117
|
+
throw new Error(`Entity ${entityName} not found`);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Helper function to return an Entity Name from an Entity ID
|
|
121
|
+
* @param entityID
|
|
122
|
+
* @returns
|
|
123
|
+
*/
|
|
124
|
+
EntityNameFromID(entityID) {
|
|
125
|
+
let entity = this.Entities.find((e) => e.ID == entityID);
|
|
126
|
+
if (entity) {
|
|
127
|
+
return entity.Name;
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
(0, logging_1.LogError)(`Entity ID: ${entityID} not found`);
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Helper function to return an EntityInfo from an Entity ID
|
|
136
|
+
* @param entityID
|
|
137
|
+
*/
|
|
138
|
+
EntityFromEntityID(entityID) {
|
|
139
|
+
let entity = this.Entities.find((e) => e.ID == entityID);
|
|
140
|
+
if (entity) {
|
|
141
|
+
return entity;
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
(0, logging_1.LogError)(`Entity ID: ${entityID} not found`);
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Returns true if the combination of userId/entityName/KeyValuePairs has a favorite status on (meaning the user has marked the record as a "favorite" for easy access)
|
|
150
|
+
* @param userId
|
|
151
|
+
* @param entityName
|
|
152
|
+
* @param primaryKey
|
|
153
|
+
* @returns
|
|
154
|
+
*/
|
|
155
|
+
async GetRecordFavoriteStatus(userId, entityName, primaryKey, contextUser) {
|
|
156
|
+
return await Metadata.Provider.GetRecordFavoriteStatus(userId, entityName, primaryKey, contextUser);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Returns an array of records representing the list of changes made to a record. This functionality only works
|
|
160
|
+
* if an entity has TrackRecordChanges = 1, which is the default for most entities. If TrackRecordChanges = 0, this method will return an empty array.
|
|
161
|
+
*
|
|
162
|
+
* This method is defined in the @memberjunction/global package, which is lower level in the dependency
|
|
163
|
+
* hierarchy than the @memberjunction/core-entities package where the RecordChangeEntity class is defined.
|
|
164
|
+
* For this reason, we are not using the RecordChangeEntity class here, but rather returning a generic type T.
|
|
165
|
+
* When you call this method, you can specify the type T to be the RecordChangeEntity class or any other class that matches the structure of the record changes.
|
|
166
|
+
* For example:
|
|
167
|
+
* ```typescript
|
|
168
|
+
* const md = new Metadata();
|
|
169
|
+
* const changes: RecordChangeEntity[] = await md.GetRecordChanges<RecordChangeEntity>('MyEntity', myPrimaryKey);
|
|
170
|
+
* ```
|
|
171
|
+
* @param entityName
|
|
172
|
+
* @param primaryKey
|
|
173
|
+
* @param contextUser
|
|
174
|
+
* @returns
|
|
175
|
+
*/
|
|
176
|
+
async GetRecordChanges(entityName, primaryKey, contextUser) {
|
|
177
|
+
try {
|
|
178
|
+
const e = this.EntityByName(entityName);
|
|
179
|
+
if (!e) {
|
|
180
|
+
throw new Error(`Entity ${entityName} not found`);
|
|
181
|
+
}
|
|
182
|
+
if (!e.TrackRecordChanges) {
|
|
183
|
+
(0, logging_1.LogStatus)(`GetRecordChanges called for entity ${entityName} with primary key ${primaryKey.ToConcatenatedString()} but TrackRecordChanges is not enabled, returning empty array.`);
|
|
184
|
+
return []; // Return empty array if TrackRecordChanges is not enabled
|
|
185
|
+
}
|
|
186
|
+
const rv = new runView_1.RunView();
|
|
187
|
+
const result = await rv.RunView({
|
|
188
|
+
EntityName: 'Record Changes',
|
|
189
|
+
ExtraFilter: `Entity='${entityName}' AND RecordID='${primaryKey.ToConcatenatedString()}'`,
|
|
190
|
+
OrderBy: 'ChangedAt DESC',
|
|
191
|
+
}, contextUser);
|
|
192
|
+
if (result.Success) {
|
|
193
|
+
return result.Results;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
catch (e) {
|
|
197
|
+
(0, logging_1.LogError)(`GetRecordChanges failed for entityName: ${entityName} and primaryKey: ${primaryKey}. Error: ${e.message}`);
|
|
198
|
+
throw e;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Sets the favorite status for a given user for a specific entityName/KeyValuePairs
|
|
203
|
+
* @param userId
|
|
204
|
+
* @param entityName
|
|
205
|
+
* @param primaryKey
|
|
206
|
+
* @param isFavorite
|
|
207
|
+
* @param contextUser
|
|
208
|
+
*/
|
|
209
|
+
async SetRecordFavoriteStatus(userId, entityName, primaryKey, isFavorite, contextUser = null) {
|
|
210
|
+
await Metadata.Provider.SetRecordFavoriteStatus(userId, entityName, primaryKey, isFavorite, contextUser);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Returns a list of dependencies - records that are linked to the specified Entity/Primary Key Value combination. A dependency is as defined by the relationships in the database. The MemberJunction metadata that is used
|
|
214
|
+
* for this simply reflects the foreign key relationships that exist in the database. The CodeGen tool is what detects all of the relationships and generates the metadata that is used by MemberJunction. The metadata in question
|
|
215
|
+
* is within the EntityField table and specifically the RelatedEntity and RelatedEntityField columns. In turn, this method uses that metadata and queries the database to determine the dependencies. To get the list of entity dependencies
|
|
216
|
+
* you can use the utility method GetEntityDependencies(), which doesn't check for dependencies on a specific record, but rather gets the metadata in one shot that can be used for dependency checking.
|
|
217
|
+
* @param entityName the name of the entity to check
|
|
218
|
+
* @param primaryKey the primary key value to check
|
|
219
|
+
*/
|
|
220
|
+
async GetRecordDependencies(entityName, primaryKey) {
|
|
221
|
+
return await Metadata.Provider.GetRecordDependencies(entityName, primaryKey);
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Returns a list of record IDs that are possible duplicates of the specified record.
|
|
225
|
+
*
|
|
226
|
+
* @param params object containing many properties used in fetching records and determining which ones to return
|
|
227
|
+
*/
|
|
228
|
+
async GetRecordDuplicates(params, contextUser) {
|
|
229
|
+
return await Metadata.Provider.GetRecordDuplicates(params, contextUser);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Returns a list of entity dependencies, basically metadata that tells you the links to this entity from all other entities.
|
|
233
|
+
* @param entityName
|
|
234
|
+
* @returns
|
|
235
|
+
*/
|
|
236
|
+
async GetEntityDependencies(entityName) {
|
|
237
|
+
return await Metadata.Provider.GetEntityDependencies(entityName);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* This method will merge two or more records based on the request provided. The RecordMergeRequest type you pass in specifies the record that will survive the merge, the records to merge into the surviving record, and an optional field map that can update values in the surviving record, if desired. The process followed is:
|
|
241
|
+
* 1. The surviving record is loaded and fields are updated from the field map, if provided, and the record is saved. If a FieldMap not provided within the request object, this step is skipped.
|
|
242
|
+
* 2. For each of the records that will be merged INTO the surviving record, we call the GetEntityDependencies() method and get a list of all other records in the database are linked to the record to be deleted. We then go through each of those dependencies and update the link to point to the SurvivingRecordKeyValuePair and save the record.
|
|
243
|
+
* 3. The record to be deleted is then deleted.
|
|
244
|
+
*
|
|
245
|
+
* The return value from this method contains detailed information about the execution of the process. In addition, all attempted merges are logged in the RecordMergeLog and RecordMergeDeletionLog tables.
|
|
246
|
+
*
|
|
247
|
+
* IMPORTANT NOTE: This functionality ASSUMES that you are calling BEGIN TRANS and COMMIT TRANS/ROLLBACK TRANS outside of the work being done inside if you are on the database server side (not on the client side). The reason is that many API servers that use this object infrastructure have transaction wrappers for each individual API request
|
|
248
|
+
* so we are not doing BEGIN/COMMIT/ROLLBACK within this functionality. If you are using this on the client side, you don't need to do anything extra, the server side, however, must wrap this with begin/commit/rollback statements to the database server.
|
|
249
|
+
* If you're using MJAPI/MJServer this is done for you automatically.
|
|
250
|
+
*
|
|
251
|
+
* @param request
|
|
252
|
+
* @returns
|
|
253
|
+
*/
|
|
254
|
+
async MergeRecords(request, contextUser, options) {
|
|
255
|
+
const e = this.EntityByName(request.EntityName);
|
|
256
|
+
if (e.AllowRecordMerge)
|
|
257
|
+
return await Metadata.Provider.MergeRecords(request, contextUser, options);
|
|
258
|
+
else
|
|
259
|
+
throw new Error(`Entity ${request.EntityName} does not allow record merging, check the AllowRecordMerge property in the entity metadata`);
|
|
260
|
+
}
|
|
261
|
+
async GetEntityObject(entityName, loadKeyOrContextUser, contextUser) {
|
|
262
|
+
// validate that entityName is not null, undefined and IS a string > 0 length
|
|
263
|
+
if (!entityName || typeof entityName !== 'string' || entityName.trim().length === 0) {
|
|
264
|
+
throw new Error('GetEntityObject: entityName must be a non-empty string');
|
|
265
|
+
}
|
|
266
|
+
// Determine which overload was called
|
|
267
|
+
let actualLoadKey;
|
|
268
|
+
let actualContextUser;
|
|
269
|
+
if (loadKeyOrContextUser instanceof compositeKey_1.CompositeKey) {
|
|
270
|
+
// Second overload: entityName, loadKey, contextUser
|
|
271
|
+
actualLoadKey = loadKeyOrContextUser;
|
|
272
|
+
actualContextUser = contextUser;
|
|
273
|
+
}
|
|
274
|
+
else if (contextUser !== undefined) {
|
|
275
|
+
// Second overload with null/undefined loadKey: entityName, null/undefined, contextUser
|
|
276
|
+
actualLoadKey = undefined;
|
|
277
|
+
actualContextUser = contextUser;
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
// First overload: entityName, contextUser
|
|
281
|
+
actualContextUser = loadKeyOrContextUser;
|
|
282
|
+
}
|
|
283
|
+
// validate that contextUser is either null/undefined or a UserInfo object
|
|
284
|
+
if (actualContextUser) {
|
|
285
|
+
// contextUser has been specified. We need to make sure the shape of the object
|
|
286
|
+
// is correct to allow objects that are not true instances of UserInfo but have the
|
|
287
|
+
// same shape - e.g. duck typing
|
|
288
|
+
if (!(actualContextUser instanceof securityInfo_1.UserInfo)) {
|
|
289
|
+
const u = actualContextUser;
|
|
290
|
+
if (u && u.ID && u.Name && u.Email && u.UserRoles) {
|
|
291
|
+
// we have a UserInfo-like object, so we can use it
|
|
292
|
+
actualContextUser = new securityInfo_1.UserInfo(Metadata.Provider, u);
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
throw new Error('GetEntityObject: contextUser must be null/undefined, a UserInfo instance, or an object that has the same shape as UserInfo, notably having the following properties: ID, Name, Email, and UserRoles');
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return await Metadata.Provider.GetEntityObject(entityName, actualLoadKey, actualContextUser);
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Returns the Name of the specific KeyValuePairs for a given entityName. This is done by
|
|
303
|
+
* looking for the IsNameField within the EntityFields collection for a given entity.
|
|
304
|
+
* If no IsNameField is found, but a field called "Name" exists, that value is returned. Otherwise null returned
|
|
305
|
+
* @param entityName
|
|
306
|
+
* @param primaryKey
|
|
307
|
+
* @returns the name of the record
|
|
308
|
+
*/
|
|
309
|
+
async GetEntityRecordName(entityName, primaryKey, contextUser) {
|
|
310
|
+
let result = primaryKey.Validate();
|
|
311
|
+
if (!result.IsValid) {
|
|
312
|
+
throw new Error(result.ErrorMessage);
|
|
313
|
+
}
|
|
314
|
+
return await Metadata.Provider.GetEntityRecordName(entityName, primaryKey, contextUser);
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Returns one or more record names using the same logic as GetEntityRecordName, but for multiple records at once - more efficient to use this method if you need to get multiple record names at once
|
|
318
|
+
* @param info
|
|
319
|
+
* @returns an array of EntityRecordNameResult objects
|
|
320
|
+
*/
|
|
321
|
+
async GetEntityRecordNames(info, contextUser) {
|
|
322
|
+
// valiate to make sure we don't have any null primary keys being sent in
|
|
323
|
+
for (let i = 0; i < info.length; i++) {
|
|
324
|
+
if (!info[i].CompositeKey.KeyValuePairs || info[i].CompositeKey.KeyValuePairs.length == 0) {
|
|
325
|
+
throw new Error('GetEntityRecordNames: KeyValuePairs cannot be null or empty. It is for item ' + i.toString() + ' in the input array.');
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
// check each primary key value to make sure it's not null
|
|
329
|
+
for (let j = 0; j < info[i].CompositeKey.KeyValuePairs.length; j++) {
|
|
330
|
+
if (!info[i].CompositeKey.KeyValuePairs[j] || !info[i].CompositeKey.KeyValuePairs[j].Value) {
|
|
331
|
+
throw new Error('GetEntityRecordNames: KeyValuePairs cannot contain null values. FieldName: ' +
|
|
332
|
+
info[i].CompositeKey.KeyValuePairs[j]?.FieldName);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
return await Metadata.Provider.GetEntityRecordNames(info, contextUser);
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Creates a new TransactionGroup which can be used to bundle multiple database changes for BaseEntity derived classes to be processed as a single database transaction
|
|
341
|
+
* @returns
|
|
342
|
+
*/
|
|
343
|
+
async CreateTransactionGroup() {
|
|
344
|
+
return await Metadata.Provider.CreateTransactionGroup();
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Saves all the in-memory metadata to be updated in the local persistent storage method (which varies by provider). This generally shouldn't need to be called externally but is available to force an update to local storage as desired.
|
|
348
|
+
*/
|
|
349
|
+
async SaveLocalMetadataToStorage() {
|
|
350
|
+
await Metadata.Provider.SaveLocalMetadataToStorage();
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Removes all the metadata from the local persistent storage method (which varies by provider). This generally shouldn't need to be called externally but is available to force an complete removal of local metadata in storage.
|
|
354
|
+
* NOTE: this does not remove Datasets, for removing datasets, use ClearDatasetCache()
|
|
355
|
+
*/
|
|
356
|
+
async RemoveLocalMetadataFromStorage() {
|
|
357
|
+
await Metadata.Provider.RemoveLocalMetadataFromStorage();
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Returns the local storage provider. This is used to store metadata locally on the client.
|
|
361
|
+
* @returns - the local storage provider
|
|
362
|
+
* @remarks - Use this for storing any type of data on the client. The Provider implements the storage mechanism which is persistent whenever possible, but in some cases purely in memory if local persistence is not available. Keep in mind that you must ensure that keys are unique so prefix all of your keys with something unique to avoid collisions.
|
|
363
|
+
*/
|
|
364
|
+
get LocalStorageProvider() {
|
|
365
|
+
return Metadata.Provider.LocalStorageProvider;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Retrieves the date status information for a dataset and all its items from the server. This method will match the datasetName and itemFilters to the server's dataset and item filters to determine a match
|
|
369
|
+
* @param datasetName
|
|
370
|
+
* @param itemFilters
|
|
371
|
+
*/
|
|
372
|
+
async GetDatasetStatusByName(datasetName, itemFilters, contextUser, providerToUse) {
|
|
373
|
+
return Metadata.Provider.GetDatasetStatusByName(datasetName, itemFilters, contextUser, providerToUse);
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Always retrieves data from the server - this method does NOT check cache. To use cached local values if available, call GetAndCacheDatasetByName() instead
|
|
377
|
+
* @param datasetName
|
|
378
|
+
* @param itemFilters
|
|
379
|
+
*/
|
|
380
|
+
async GetDatasetByName(datasetName, itemFilters, contextUser, providerToUse) {
|
|
381
|
+
return Metadata.Provider.GetDatasetByName(datasetName, itemFilters, contextUser, providerToUse);
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Gets a dataset by name, if required, and caches it in a format available to the client (e.g. IndexedDB, LocalStorage, File, etc). The cache method is Provider specific
|
|
385
|
+
* If itemFilters are provided, the combination of datasetName and the filters are used to determine a match in the cache
|
|
386
|
+
* @param datasetName
|
|
387
|
+
* @param itemFilters
|
|
388
|
+
*/
|
|
389
|
+
async GetAndCacheDatasetByName(datasetName, itemFilters, contextUser) {
|
|
390
|
+
return Metadata.Provider.GetAndCacheDatasetByName(datasetName, itemFilters, contextUser);
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* This routine checks to see if the local cache version of a given datasetName/itemFilters combination is up to date with the server or not
|
|
394
|
+
* @param datasetName
|
|
395
|
+
* @param itemFilters
|
|
396
|
+
* @returns
|
|
397
|
+
*/
|
|
398
|
+
async IsDatasetCacheUpToDate(datasetName, itemFilters) {
|
|
399
|
+
return Metadata.Provider.IsDatasetCacheUpToDate(datasetName, itemFilters);
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* This routine gets the local cached version of a given datasetName/itemFilters combination, it does NOT check the server status first.
|
|
403
|
+
* @param datasetName
|
|
404
|
+
* @param itemFilters
|
|
405
|
+
* @returns
|
|
406
|
+
*/
|
|
407
|
+
async GetCachedDataset(datasetName, itemFilters) {
|
|
408
|
+
return Metadata.Provider.GetCachedDataset(datasetName, itemFilters);
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Stores a dataset in the local cache. If itemFilters are provided, the combination of datasetName and the filters are used to build a key and determine a match in the cache
|
|
412
|
+
* @param datasetName
|
|
413
|
+
* @param itemFilters
|
|
414
|
+
* @param dataset
|
|
415
|
+
*/
|
|
416
|
+
async CacheDataset(datasetName, itemFilters, dataset) {
|
|
417
|
+
return Metadata.Provider.CacheDataset(datasetName, itemFilters, dataset);
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Determines if a given datasetName/itemFilters combination is cached locally or not
|
|
421
|
+
* @param datasetName
|
|
422
|
+
* @param itemFilters
|
|
423
|
+
* @returns
|
|
424
|
+
*/
|
|
425
|
+
async IsDatasetCached(datasetName, itemFilters) {
|
|
426
|
+
return Metadata.Provider.IsDatasetCached(datasetName, itemFilters);
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Creates a key for the given datasetName and itemFilters combination
|
|
430
|
+
* @param datasetName
|
|
431
|
+
* @param itemFilters
|
|
432
|
+
* @returns
|
|
433
|
+
*/
|
|
434
|
+
GetDatasetCacheKey(datasetName, itemFilters) {
|
|
435
|
+
return Metadata.Provider.GetDatasetCacheKey(datasetName, itemFilters);
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* If the specified datasetName is cached, this method will clear the cache. If itemFilters are provided, the combination of datasetName and the filters are used to determine a match in the cache
|
|
439
|
+
* @param datasetName
|
|
440
|
+
* @param itemFilters
|
|
441
|
+
*/
|
|
442
|
+
async ClearDatasetCache(datasetName, itemFilters) {
|
|
443
|
+
return Metadata.Provider.ClearDatasetCache(datasetName, itemFilters);
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Provides access the configuration object that was initially provided to configure the provider
|
|
447
|
+
*/
|
|
448
|
+
get ConfigData() {
|
|
449
|
+
return Metadata.Provider.ConfigData;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
exports.Metadata = Metadata;
|
|
453
|
+
Metadata._globalProviderKey = 'MJ_MetadataProvider';
|
|
454
|
+
//# sourceMappingURL=metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../src/generic/metadata.ts"],"names":[],"mappings":";;;AAiBA,iDAAyF;AAGzF,uCAAgD;AAEhD,iDAA8C;AAE9C,8CAA2C;AAC3C,sCAAqC;AAErC;;GAEG;AACH,MAAa,QAAQ;IAEnB;;;OAGG;IACI,MAAM,KAAK,QAAQ;QACxB,MAAM,CAAC,GAAG,iBAAQ,CAAC,QAAQ,CAAC,oBAAoB,EA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AC,CAAC;IACtE,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,YAAY,CAAC,WAAmB,EAAE,WAAoC,EAAE,OAA0B;QAC7G,OAAO,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;IAC3E,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,eAAe,CAAC,WAAmB,EAAE,WAAqC;QACrF,OAAO,QAAQ,CAAC,QAAQ,CAAC,eAAe,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IACrE,CAAC;IAED;;;;;OAKG;IACI,kBAAkB,CAAC,WAAmB,EAAE,WAAqC;QAClF,OAAO,QAAQ,CAAC,QAAQ,CAAC,kBAAkB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IACxE,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,iBAAiB,CAAC,WAAmB,EAAE,WAAqC;QACvF,OAAO,QAAQ,CAAC,QAAQ,CAAC,iBAAiB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IACvE,CAAC;IAED;;OAEG;IACH,IAAI,UAAU;QACZ,OAAO,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC;IACtC,CAAC;;AAzjBH,4BA0jBC;AAzjBgB,2BAAkB,GAAW,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IMetadataProvider } from "./interfaces";
|
|
2
|
+
/**
|
|
3
|
+
* This function is used to get the entity name from the schema.view string
|
|
4
|
+
* @param schemaAndView - this string contains the combined schema name and base view name, for example: "dbo.vwMyView"
|
|
5
|
+
* @param provider - optional, if you want to use a different provider than the default one
|
|
6
|
+
*/
|
|
7
|
+
export declare function GetEntityNameFromSchemaAndViewString(schemaAndView: string, provider?: IMetadataProvider): string | null;
|
|
8
|
+
//# sourceMappingURL=metadataUtil.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadataUtil.d.ts","sourceRoot":"","sources":["../../src/generic/metadataUtil.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGjD;;;;GAIG;AACH,wBAAgB,oCAAoC,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CA0BvH"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetEntityNameFromSchemaAndViewString = void 0;
|
|
4
|
+
const metadata_1 = require("./metadata");
|
|
5
|
+
/**
|
|
6
|
+
* This function is used to get the entity name from the schema.view string
|
|
7
|
+
* @param schemaAndView - this string contains the combined schema name and base view name, for example: "dbo.vwMyView"
|
|
8
|
+
* @param provider - optional, if you want to use a different provider than the default one
|
|
9
|
+
*/
|
|
10
|
+
function GetEntityNameFromSchemaAndViewString(schemaAndView, provider) {
|
|
11
|
+
const p = provider || new metadata_1.Metadata();
|
|
12
|
+
// check to see if the view has a . in it, that would mean it has schema and view name, SHOULD always have that
|
|
13
|
+
let schema = '', view = '';
|
|
14
|
+
if (schemaAndView.indexOf('.') === -1) {
|
|
15
|
+
view = schemaAndView.trim().toLowerCase();
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
schema = schemaAndView.split('.')[0].trim().toLowerCase();
|
|
19
|
+
view = schemaAndView.split('.')[1].trim().toLowerCase();
|
|
20
|
+
}
|
|
21
|
+
const e = p.Entities.filter((x) => x.BaseView.trim().toLowerCase() === view && (schema === '' || x.SchemaName.trim().toLowerCase() === schema)); // try to find the entity even if we don't have the schema name. AI should include it in schema.view syntax but if it doesn't we'll try to find
|
|
22
|
+
if (e && e.length === 1) {
|
|
23
|
+
return e[0].Name;
|
|
24
|
+
}
|
|
25
|
+
else if (!e || e.length === 0) {
|
|
26
|
+
console.warn(`Could not find entity for the specified DrillDownView: ${schemaAndView}`);
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
else if (e && e.length > 1) {
|
|
30
|
+
console.warn(`Found more than one entity for the specified DrillDownView: ${schemaAndView}`);
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
exports.GetEntityNameFromSchemaAndViewString = GetEntityNameFromSchemaAndViewString;
|
|
36
|
+
//# sourceMappingURL=metadataUtil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadataUtil.js","sourceRoot":"","sources":["../../src/generic/metadataUtil.ts"],"names":[],"mappings":";;;AACA,yCAAsC;AAEtC;;;;GAIG;AACH,SAAgB,oCAAoC,CAAC,aAAqB,EAAE,QAA4B;IACpG,MAAM,CAAC,GAAG,QAAQ,IAAI,IAAI,mBAAQ,EAAE,CAAC;IACrC,+GAA+G;IAC/G,IAAI,MAAM,GAAG,EAAE,EAAE,IAAI,GAAG,EAAE,CAAC;IAC3B,IAAI,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QACpC,IAAI,GAAG,aAAa,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC9C,CAAC;SACI,CAAC;QACF,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAC1D,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC5D,CAAC;IACD,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,MAAM,CACvB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,IAAI,IAAI,CAAC,MAAM,KAAK,EAAE,IAAI,CAAC,CAAC,UAAU,CAAC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