@memberjunction/core 0.9.166 → 0.9.167

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 (66) hide show
  1. package/dist/generic/interfaces.d.ts +0 -2
  2. package/dist/generic/interfaces.js.map +1 -1
  3. package/dist/generic/providerBase.d.ts +0 -7
  4. package/dist/generic/providerBase.js +1 -11
  5. package/dist/generic/providerBase.js.map +1 -1
  6. package/package.json +1 -1
  7. package/dist/MJCore/src/generic/applicationInfo.d.ts +0 -26
  8. package/dist/MJCore/src/generic/applicationInfo.js +0 -57
  9. package/dist/MJCore/src/generic/applicationInfo.js.map +0 -1
  10. package/dist/MJCore/src/generic/baseEntity.d.ts +0 -195
  11. package/dist/MJCore/src/generic/baseEntity.js +0 -674
  12. package/dist/MJCore/src/generic/baseEntity.js.map +0 -1
  13. package/dist/MJCore/src/generic/baseInfo.d.ts +0 -8
  14. package/dist/MJCore/src/generic/baseInfo.js +0 -38
  15. package/dist/MJCore/src/generic/baseInfo.js.map +0 -1
  16. package/dist/MJCore/src/generic/entityInfo.d.ts +0 -520
  17. package/dist/MJCore/src/generic/entityInfo.js +0 -801
  18. package/dist/MJCore/src/generic/entityInfo.js.map +0 -1
  19. package/dist/MJCore/src/generic/interfaces.d.ts +0 -288
  20. package/dist/MJCore/src/generic/interfaces.js +0 -50
  21. package/dist/MJCore/src/generic/interfaces.js.map +0 -1
  22. package/dist/MJCore/src/generic/logging.d.ts +0 -4
  23. package/dist/MJCore/src/generic/logging.js +0 -69
  24. package/dist/MJCore/src/generic/logging.js.map +0 -1
  25. package/dist/MJCore/src/generic/metadata.d.ts +0 -201
  26. package/dist/MJCore/src/generic/metadata.js +0 -312
  27. package/dist/MJCore/src/generic/metadata.js.map +0 -1
  28. package/dist/MJCore/src/generic/providerBase.d.ts +0 -183
  29. package/dist/MJCore/src/generic/providerBase.js +0 -640
  30. package/dist/MJCore/src/generic/providerBase.js.map +0 -1
  31. package/dist/MJCore/src/generic/queryInfo.d.ts +0 -64
  32. package/dist/MJCore/src/generic/queryInfo.js +0 -124
  33. package/dist/MJCore/src/generic/queryInfo.js.map +0 -1
  34. package/dist/MJCore/src/generic/runQuery.d.ts +0 -11
  35. package/dist/MJCore/src/generic/runQuery.js +0 -26
  36. package/dist/MJCore/src/generic/runQuery.js.map +0 -1
  37. package/dist/MJCore/src/generic/runReport.d.ts +0 -11
  38. package/dist/MJCore/src/generic/runReport.js +0 -27
  39. package/dist/MJCore/src/generic/runReport.js.map +0 -1
  40. package/dist/MJCore/src/generic/securityInfo.d.ts +0 -100
  41. package/dist/MJCore/src/generic/securityInfo.js +0 -194
  42. package/dist/MJCore/src/generic/securityInfo.js.map +0 -1
  43. package/dist/MJCore/src/generic/transactionGroup.d.ts +0 -24
  44. package/dist/MJCore/src/generic/transactionGroup.js +0 -79
  45. package/dist/MJCore/src/generic/transactionGroup.js.map +0 -1
  46. package/dist/MJCore/src/generic/util.d.ts +0 -16
  47. package/dist/MJCore/src/generic/util.js +0 -151
  48. package/dist/MJCore/src/generic/util.js.map +0 -1
  49. package/dist/MJCore/src/index.d.ts +0 -16
  50. package/dist/MJCore/src/index.js +0 -44
  51. package/dist/MJCore/src/index.js.map +0 -1
  52. package/dist/MJCore/src/views/runView.d.ts +0 -112
  53. package/dist/MJCore/src/views/runView.js +0 -63
  54. package/dist/MJCore/src/views/runView.js.map +0 -1
  55. package/dist/MJCore/src/views/viewInfo.d.ts +0 -59
  56. package/dist/MJCore/src/views/viewInfo.js +0 -121
  57. package/dist/MJCore/src/views/viewInfo.js.map +0 -1
  58. package/dist/MJGlobal/src/ObjectCache.d.ts +0 -26
  59. package/dist/MJGlobal/src/ObjectCache.js +0 -55
  60. package/dist/MJGlobal/src/ObjectCache.js.map +0 -1
  61. package/dist/generic/objectCache.d.ts +0 -26
  62. package/dist/generic/objectCache.js +0 -55
  63. package/dist/generic/objectCache.js.map +0 -1
  64. package/dist/generic/viewInfo.d.ts +0 -59
  65. package/dist/generic/viewInfo.js +0 -121
  66. package/dist/generic/viewInfo.js.map +0 -1
@@ -1,201 +0,0 @@
1
- import { DatasetItemFilterType, DatasetResultType, DatasetStatusResultType, EntityRecordNameInput, EntityRecordNameResult, ILocalStorageProvider, IMetadataProvider, ProviderConfigDataBase, ProviderType } from "./interfaces";
2
- import { EntityDependency, EntityInfo, PrimaryKeyValue, RecordDependency, RecordMergeRequest, RecordMergeResult } from "./entityInfo";
3
- import { ApplicationInfo } from "./applicationInfo";
4
- import { BaseEntity } from "./baseEntity";
5
- import { AuditLogTypeInfo, AuthorizationInfo, RoleInfo, UserInfo } from "./securityInfo";
6
- import { TransactionGroupBase } from "./transactionGroup";
7
- import { QueryCategoryInfo, QueryFieldInfo, QueryInfo, QueryPermissionInfo } from "./queryInfo";
8
- /**
9
- * 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.
10
- */
11
- export declare class Metadata {
12
- private static _globalProviderKey;
13
- static get Provider(): IMetadataProvider;
14
- static set Provider(value: IMetadataProvider);
15
- /**
16
- * Forces a refresh of all cached metadata.
17
- * @returns
18
- */
19
- Refresh(): Promise<boolean>;
20
- get ProviderType(): ProviderType;
21
- get Applications(): ApplicationInfo[];
22
- get Entities(): EntityInfo[];
23
- get Queries(): QueryInfo[];
24
- get QueryFields(): QueryFieldInfo[];
25
- get QueryCategories(): QueryCategoryInfo[];
26
- get QueryPermissions(): QueryPermissionInfo[];
27
- /**
28
- * 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.
29
- */
30
- get CurrentUser(): UserInfo;
31
- get Roles(): RoleInfo[];
32
- get AuditLogTypes(): AuditLogTypeInfo[];
33
- get Authorizations(): AuthorizationInfo[];
34
- /**
35
- * Helper function to return an Entity Name from a given Entity ID.
36
- * @param entityName
37
- * @returns
38
- */
39
- EntityIDFromName(entityName: string): number;
40
- /**
41
- * Helper function to return an Entity Name from an Entity ID
42
- * @param entityID
43
- * @returns
44
- */
45
- EntityNameFromID(entityID: number): string;
46
- /**
47
- * Returns true if the combination of userId/entityName/primaryKeyValues has a favorite status on (meaning the user has marked the record as a "favorite" for easy access)
48
- * @param userId
49
- * @param entityName
50
- * @param primaryKeyValues
51
- * @returns
52
- */
53
- GetRecordFavoriteStatus(userId: number, entityName: string, primaryKeyValues: PrimaryKeyValue[]): Promise<boolean>;
54
- /**
55
- * Sets the favorite status for a given user for a specific entityName/primaryKeyValues
56
- * @param userId
57
- * @param entityName
58
- * @param primaryKeyValues
59
- * @param isFavorite
60
- * @param contextUser
61
- */
62
- SetRecordFavoriteStatus(userId: number, entityName: string, primaryKeyValues: PrimaryKeyValue[], isFavorite: boolean, contextUser?: UserInfo): Promise<void>;
63
- /**
64
- * 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
65
- * 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
66
- * 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
67
- * 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.
68
- * @param entityName the name of the entity to check
69
- * @param primaryKeyValue the primary key value to check
70
- */
71
- GetRecordDependencies(entityName: string, primaryKeyValues: PrimaryKeyValue[]): Promise<RecordDependency[]>;
72
- /**
73
- * Returns a list of entity dependencies, basically metadata that tells you the links to this entity from all other entities.
74
- * @param entityName
75
- * @returns
76
- */
77
- GetEntityDependencies(entityName: string): Promise<EntityDependency[]>;
78
- /**
79
- * 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:
80
- * 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.
81
- * 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 SurvivingRecordPrimaryKeyValue and save the record.
82
- * 3. The record to be deleted is then deleted.
83
- *
84
- * 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.
85
- *
86
- * 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
87
- * 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.
88
- * If you're using MJAPI/MJServer this is done for you automatically.
89
- *
90
- * @param request
91
- * @returns
92
- */
93
- MergeRecords(request: RecordMergeRequest, contextUser?: UserInfo): Promise<RecordMergeResult>;
94
- /**
95
- * Returns a newly created instance of a sub-class of BaseEntity. The subclass depends on the class registrations for the
96
- * requested entity. The class registrations are managed by the MJGlobal ClassFactory component.
97
- * @param entityName - The name of the entity to create an instance of
98
- * @param contextUser - The user to use for context. If null, the current user is used. This is mainly used on the server side, for browser based applications generally the context will be known
99
- * @returns - a newly created instance of a sub-class of BaseEntity. Remember you still to call Load() or NewRecord() to get going from there.
100
- */
101
- GetEntityObject<T extends BaseEntity>(entityName: string, contextUser?: UserInfo): Promise<T>;
102
- /**
103
- * Returns the Name of the specific primaryKeyValues for a given entityName. This is done by
104
- * looking for the IsNameField within the EntityFields collection for a given entity.
105
- * If no IsNameField is found, but a field called "Name" exists, that value is returned. Otherwise null returned
106
- * @param entityName
107
- * @param primaryKeyValues
108
- * @returns the name of the record
109
- */
110
- GetEntityRecordName(entityName: string, primaryKeyValues: PrimaryKeyValue[]): Promise<string>;
111
- /**
112
- * 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
113
- * @param info
114
- * @returns an array of EntityRecordNameResult objects
115
- */
116
- GetEntityRecordNames(info: EntityRecordNameInput[]): Promise<EntityRecordNameResult[]>;
117
- /**
118
- * 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
119
- * @returns
120
- */
121
- CreateTransactionGroup(): Promise<TransactionGroupBase>;
122
- /**
123
- * 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.
124
- */
125
- SaveLocalMetadataToStorage(): Promise<void>;
126
- /**
127
- * 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.
128
- * NOTE: this does not remove Datasets, for removing datasets, use ClearDatasetCache()
129
- */
130
- RemoveLocalMetadataFromStorage(): Promise<void>;
131
- /**
132
- * Returns the local storage provider. This is used to store metadata locally on the client.
133
- * @returns - the local storage provider
134
- * @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.
135
- */
136
- get LocalStorageProvider(): ILocalStorageProvider;
137
- /**
138
- * 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
139
- * @param datasetName
140
- * @param itemFilters
141
- */
142
- GetDatasetStatusByName(datasetName: string, itemFilters?: DatasetItemFilterType[]): Promise<DatasetStatusResultType>;
143
- /**
144
- * Always retrieves data from the server - this method does NOT check cache. To use cached local values if available, call GetAndCacheDatasetByName() instead
145
- * @param datasetName
146
- * @param itemFilters
147
- */
148
- GetDatasetByName(datasetName: string, itemFilters?: DatasetItemFilterType[]): Promise<DatasetResultType>;
149
- /**
150
- * Gets a database 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
151
- * If itemFilters are provided, the combination of datasetName and the filters are used to determine a match in the cache
152
- * @param datasetName
153
- * @param itemFilters
154
- */
155
- GetAndCacheDatasetByName(datasetName: string, itemFilters?: DatasetItemFilterType[]): Promise<DatasetResultType>;
156
- /**
157
- * 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
158
- * @param datasetName
159
- * @param itemFilters
160
- * @returns
161
- */
162
- IsDatasetCacheUpToDate(datasetName: string, itemFilters?: DatasetItemFilterType[]): Promise<boolean>;
163
- /**
164
- * This routine gets the local cached version of a given datasetName/itemFilters combination, it does NOT check the server status first.
165
- * @param datasetName
166
- * @param itemFilters
167
- * @returns
168
- */
169
- GetCachedDataset(datasetName: string, itemFilters?: DatasetItemFilterType[]): Promise<DatasetResultType>;
170
- /**
171
- * 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
172
- * @param datasetName
173
- * @param itemFilters
174
- * @param dataset
175
- */
176
- CacheDataset(datasetName: string, itemFilters: DatasetItemFilterType[], dataset: DatasetResultType): Promise<void>;
177
- /**
178
- * Determines if a given datasetName/itemFilters combination is cached locally or not
179
- * @param datasetName
180
- * @param itemFilters
181
- * @returns
182
- */
183
- IsDatasetCached(datasetName: string, itemFilters?: DatasetItemFilterType[]): Promise<boolean>;
184
- /**
185
- * Creates a key for the given datasetName and itemFilters combination
186
- * @param datasetName
187
- * @param itemFilters
188
- * @returns
189
- */
190
- GetDatasetCacheKey(datasetName: string, itemFilters?: DatasetItemFilterType[]): string;
191
- /**
192
- * 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
193
- * @param datasetName
194
- * @param itemFilters
195
- */
196
- ClearDatasetCache(datasetName: string, itemFilters?: DatasetItemFilterType[]): Promise<void>;
197
- /**
198
- * Provides access the configuration object that was initially provided to configure the provider
199
- */
200
- get ConfigData(): ProviderConfigDataBase;
201
- }
@@ -1,312 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Metadata = void 0;
4
- const global_1 = require("@memberjunction/global");
5
- /**
6
- * 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.
7
- */
8
- class Metadata {
9
- static get Provider() {
10
- const g = global_1.MJGlobal.Instance.GetGlobalObjectStore();
11
- if (g)
12
- return g[Metadata._globalProviderKey];
13
- else
14
- throw new Error('No global object store, so we cant get the static provider');
15
- }
16
- static set Provider(value) {
17
- const g = global_1.MJGlobal.Instance.GetGlobalObjectStore();
18
- if (g)
19
- g[Metadata._globalProviderKey] = value;
20
- else
21
- throw new Error('No global object store, so we cant set the static provider');
22
- }
23
- /**
24
- * Forces a refresh of all cached metadata.
25
- * @returns
26
- */
27
- async Refresh() {
28
- return await Metadata.Provider.Refresh();
29
- }
30
- get ProviderType() {
31
- return Metadata.Provider.ProviderType;
32
- }
33
- get Applications() {
34
- return Metadata.Provider.Applications;
35
- }
36
- get Entities() {
37
- return Metadata.Provider.Entities;
38
- }
39
- get Queries() {
40
- return Metadata.Provider.Queries;
41
- }
42
- get QueryFields() {
43
- return Metadata.Provider.QueryFields;
44
- }
45
- get QueryCategories() {
46
- return Metadata.Provider.QueryCategories;
47
- }
48
- get QueryPermissions() {
49
- return Metadata.Provider.QueryPermissions;
50
- }
51
- /**
52
- * 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.
53
- */
54
- get CurrentUser() {
55
- return Metadata.Provider.CurrentUser;
56
- }
57
- get Roles() {
58
- return Metadata.Provider.Roles;
59
- }
60
- get AuditLogTypes() {
61
- return Metadata.Provider.AuditLogTypes;
62
- }
63
- get Authorizations() {
64
- return Metadata.Provider.Authorizations;
65
- }
66
- /**
67
- * Helper function to return an Entity Name from a given Entity ID.
68
- * @param entityName
69
- * @returns
70
- */
71
- EntityIDFromName(entityName) {
72
- let entity = this.Entities.find(e => e.Name == entityName);
73
- if (entity != null)
74
- return entity.ID;
75
- else
76
- throw new Error(`Entity ${entityName} not found`);
77
- }
78
- /**
79
- * Helper function to return an Entity Name from an Entity ID
80
- * @param entityID
81
- * @returns
82
- */
83
- EntityNameFromID(entityID) {
84
- let entity = this.Entities.find(e => e.ID == entityID);
85
- if (entity != null)
86
- return entity.Name;
87
- else
88
- throw new Error(`Entity ID: ${entityID} not found`);
89
- }
90
- /**
91
- * Returns true if the combination of userId/entityName/primaryKeyValues has a favorite status on (meaning the user has marked the record as a "favorite" for easy access)
92
- * @param userId
93
- * @param entityName
94
- * @param primaryKeyValues
95
- * @returns
96
- */
97
- async GetRecordFavoriteStatus(userId, entityName, primaryKeyValues) {
98
- return await Metadata.Provider.GetRecordFavoriteStatus(userId, entityName, primaryKeyValues);
99
- }
100
- /**
101
- * Sets the favorite status for a given user for a specific entityName/primaryKeyValues
102
- * @param userId
103
- * @param entityName
104
- * @param primaryKeyValues
105
- * @param isFavorite
106
- * @param contextUser
107
- */
108
- async SetRecordFavoriteStatus(userId, entityName, primaryKeyValues, isFavorite, contextUser = null) {
109
- await Metadata.Provider.SetRecordFavoriteStatus(userId, entityName, primaryKeyValues, isFavorite, contextUser);
110
- }
111
- /**
112
- * 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
113
- * 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
114
- * 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
115
- * 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.
116
- * @param entityName the name of the entity to check
117
- * @param primaryKeyValue the primary key value to check
118
- */
119
- async GetRecordDependencies(entityName, primaryKeyValues) {
120
- return await Metadata.Provider.GetRecordDependencies(entityName, primaryKeyValues);
121
- }
122
- /**
123
- * Returns a list of entity dependencies, basically metadata that tells you the links to this entity from all other entities.
124
- * @param entityName
125
- * @returns
126
- */
127
- async GetEntityDependencies(entityName) {
128
- return await Metadata.Provider.GetEntityDependencies(entityName);
129
- }
130
- /**
131
- * 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:
132
- * 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.
133
- * 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 SurvivingRecordPrimaryKeyValue and save the record.
134
- * 3. The record to be deleted is then deleted.
135
- *
136
- * 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.
137
- *
138
- * 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
139
- * 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.
140
- * If you're using MJAPI/MJServer this is done for you automatically.
141
- *
142
- * @param request
143
- * @returns
144
- */
145
- async MergeRecords(request, contextUser) {
146
- return await Metadata.Provider.MergeRecords(request, contextUser);
147
- }
148
- /**
149
- * Returns a newly created instance of a sub-class of BaseEntity. The subclass depends on the class registrations for the
150
- * requested entity. The class registrations are managed by the MJGlobal ClassFactory component.
151
- * @param entityName - The name of the entity to create an instance of
152
- * @param contextUser - The user to use for context. If null, the current user is used. This is mainly used on the server side, for browser based applications generally the context will be known
153
- * @returns - a newly created instance of a sub-class of BaseEntity. Remember you still to call Load() or NewRecord() to get going from there.
154
- */
155
- async GetEntityObject(entityName, contextUser = null) {
156
- return await Metadata.Provider.GetEntityObject(entityName, contextUser);
157
- }
158
- /**
159
- * Returns the Name of the specific primaryKeyValues for a given entityName. This is done by
160
- * looking for the IsNameField within the EntityFields collection for a given entity.
161
- * If no IsNameField is found, but a field called "Name" exists, that value is returned. Otherwise null returned
162
- * @param entityName
163
- * @param primaryKeyValues
164
- * @returns the name of the record
165
- */
166
- async GetEntityRecordName(entityName, primaryKeyValues) {
167
- // check each primary key value to make sure it's not null
168
- for (let j = 0; j < primaryKeyValues.length; j++) {
169
- if (!primaryKeyValues[j] || !primaryKeyValues[j].Value) {
170
- throw new Error('GetEntityRecordName: primaryKeyValues cannot contain null values. FieldName: ' + primaryKeyValues[j]?.FieldName);
171
- }
172
- }
173
- return await Metadata.Provider.GetEntityRecordName(entityName, primaryKeyValues);
174
- }
175
- /**
176
- * 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
177
- * @param info
178
- * @returns an array of EntityRecordNameResult objects
179
- */
180
- async GetEntityRecordNames(info) {
181
- // valiate to make sure we don't have any null primary keys being sent in
182
- for (let i = 0; i < info.length; i++) {
183
- if (!info[i].PrimaryKeyValues || info[i].PrimaryKeyValues.length == 0) {
184
- throw new Error('GetEntityRecordNames: PrimaryKeyValues cannot be null or empty. It is for item ' + i.toString() + ' in the input array.');
185
- }
186
- else {
187
- // check each primary key value to make sure it's not null
188
- for (let j = 0; j < info[i].PrimaryKeyValues.length; j++) {
189
- if (!info[i].PrimaryKeyValues[j] || !info[i].PrimaryKeyValues[j].Value) {
190
- throw new Error('GetEntityRecordNames: PrimaryKeyValues cannot contain null values. FieldName: ' + info[i].PrimaryKeyValues[j]?.FieldName);
191
- }
192
- }
193
- }
194
- }
195
- return await Metadata.Provider.GetEntityRecordNames(info);
196
- }
197
- /**
198
- * 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
199
- * @returns
200
- */
201
- async CreateTransactionGroup() {
202
- return await Metadata.Provider.CreateTransactionGroup();
203
- }
204
- /**
205
- * 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.
206
- */
207
- async SaveLocalMetadataToStorage() {
208
- await Metadata.Provider.SaveLocalMetadataToStorage();
209
- }
210
- /**
211
- * 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.
212
- * NOTE: this does not remove Datasets, for removing datasets, use ClearDatasetCache()
213
- */
214
- async RemoveLocalMetadataFromStorage() {
215
- await Metadata.Provider.RemoveLocalMetadataFromStorage();
216
- }
217
- /**
218
- * Returns the local storage provider. This is used to store metadata locally on the client.
219
- * @returns - the local storage provider
220
- * @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.
221
- */
222
- get LocalStorageProvider() {
223
- return Metadata.Provider.LocalStorageProvider;
224
- }
225
- /**
226
- * 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
227
- * @param datasetName
228
- * @param itemFilters
229
- */
230
- async GetDatasetStatusByName(datasetName, itemFilters) {
231
- return Metadata.Provider.GetDatasetStatusByName(datasetName, itemFilters);
232
- }
233
- /**
234
- * Always retrieves data from the server - this method does NOT check cache. To use cached local values if available, call GetAndCacheDatasetByName() instead
235
- * @param datasetName
236
- * @param itemFilters
237
- */
238
- async GetDatasetByName(datasetName, itemFilters) {
239
- return Metadata.Provider.GetDatasetByName(datasetName, itemFilters);
240
- }
241
- /**
242
- * Gets a database 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
243
- * If itemFilters are provided, the combination of datasetName and the filters are used to determine a match in the cache
244
- * @param datasetName
245
- * @param itemFilters
246
- */
247
- async GetAndCacheDatasetByName(datasetName, itemFilters) {
248
- return Metadata.Provider.GetAndCacheDatasetByName(datasetName, itemFilters);
249
- }
250
- /**
251
- * 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
252
- * @param datasetName
253
- * @param itemFilters
254
- * @returns
255
- */
256
- async IsDatasetCacheUpToDate(datasetName, itemFilters) {
257
- return Metadata.Provider.IsDatasetCacheUpToDate(datasetName, itemFilters);
258
- }
259
- /**
260
- * This routine gets the local cached version of a given datasetName/itemFilters combination, it does NOT check the server status first.
261
- * @param datasetName
262
- * @param itemFilters
263
- * @returns
264
- */
265
- async GetCachedDataset(datasetName, itemFilters) {
266
- return Metadata.Provider.GetCachedDataset(datasetName, itemFilters);
267
- }
268
- /**
269
- * 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
270
- * @param datasetName
271
- * @param itemFilters
272
- * @param dataset
273
- */
274
- async CacheDataset(datasetName, itemFilters, dataset) {
275
- return Metadata.Provider.CacheDataset(datasetName, itemFilters, dataset);
276
- }
277
- /**
278
- * Determines if a given datasetName/itemFilters combination is cached locally or not
279
- * @param datasetName
280
- * @param itemFilters
281
- * @returns
282
- */
283
- async IsDatasetCached(datasetName, itemFilters) {
284
- return Metadata.Provider.IsDatasetCached(datasetName, itemFilters);
285
- }
286
- /**
287
- * Creates a key for the given datasetName and itemFilters combination
288
- * @param datasetName
289
- * @param itemFilters
290
- * @returns
291
- */
292
- GetDatasetCacheKey(datasetName, itemFilters) {
293
- return Metadata.Provider.GetDatasetCacheKey(datasetName, itemFilters);
294
- }
295
- /**
296
- * 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
297
- * @param datasetName
298
- * @param itemFilters
299
- */
300
- async ClearDatasetCache(datasetName, itemFilters) {
301
- return Metadata.Provider.ClearDatasetCache(datasetName, itemFilters);
302
- }
303
- /**
304
- * Provides access the configuration object that was initially provided to configure the provider
305
- */
306
- get ConfigData() {
307
- return Metadata.Provider.ConfigData;
308
- }
309
- }
310
- exports.Metadata = Metadata;
311
- Metadata._globalProviderKey = 'MJ_MetadataProvider';
312
- //# sourceMappingURL=metadata.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../../../src/generic/metadata.ts"],"names":[],"mappings":";;;AAMA,mDAAkD;AAGlD;;GAEG;AACH,MAAa,QAAQ;IAEV,MAAM,KAAK,QAAQ;QACtB,MAAM,CAAC,GAAG,iBAAQ,CAAC,QAAQ,CAAC,oBAAoB,EAAE,CAAC;QACnD,IAAI,CAAC;YACD,OAAO,CAAC,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;;YAEtC,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IACtF,CAAC;IACM,MAAM,KAAK,QAAQ,CAAC,KAAwB;QAC/C,MAAM,CAAC,GAAG,iBAAQ,CAAC,QAAQ,CAAC,oBAAoB,EAAE,CAAC;QACnD,IAAI,CAAC;YACD,CAAC,CAAC,QAAQ,CAAC,kBAAkB,CAAC,GAAG,KAAK,CAAC;;YAEvC,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IACtF,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,OAAO;QAChB,OAAO,MAAM,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;IAC7C,CAAC;IAED,IAAW,YAAY;QACnB,OAAO,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC;IAC1C,CAAC;IAED,IAAW,YAAY;QACnB,OAAO,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC;IAC1C,CAAC;IAED,IAAW,QAAQ;QACf,OAAO,QAAQ,CAAC,QAAQ,CAA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