@memberjunction/core 0.9.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 (55) hide show
  1. package/dist/generic/applicationInfo.d.ts +26 -0
  2. package/dist/generic/applicationInfo.js +57 -0
  3. package/dist/generic/applicationInfo.js.map +1 -0
  4. package/dist/generic/baseEntity.d.ts +88 -0
  5. package/dist/generic/baseEntity.js +450 -0
  6. package/dist/generic/baseEntity.js.map +1 -0
  7. package/dist/generic/baseInfo.d.ts +8 -0
  8. package/dist/generic/baseInfo.js +38 -0
  9. package/dist/generic/baseInfo.js.map +1 -0
  10. package/dist/generic/entityInfo.d.ts +340 -0
  11. package/dist/generic/entityInfo.js +647 -0
  12. package/dist/generic/entityInfo.js.map +1 -0
  13. package/dist/generic/interfaces.d.ts +235 -0
  14. package/dist/generic/interfaces.js +51 -0
  15. package/dist/generic/interfaces.js.map +1 -0
  16. package/dist/generic/logging.d.ts +4 -0
  17. package/dist/generic/logging.js +69 -0
  18. package/dist/generic/logging.js.map +1 -0
  19. package/dist/generic/metadata.d.ts +155 -0
  20. package/dist/generic/metadata.js +227 -0
  21. package/dist/generic/metadata.js.map +1 -0
  22. package/dist/generic/providerBase.d.ts +134 -0
  23. package/dist/generic/providerBase.js +517 -0
  24. package/dist/generic/providerBase.js.map +1 -0
  25. package/dist/generic/runReport.d.ts +11 -0
  26. package/dist/generic/runReport.js +27 -0
  27. package/dist/generic/runReport.js.map +1 -0
  28. package/dist/generic/runView.d.ts +106 -0
  29. package/dist/generic/runView.js +36 -0
  30. package/dist/generic/runView.js.map +1 -0
  31. package/dist/generic/securityInfo.d.ts +99 -0
  32. package/dist/generic/securityInfo.js +195 -0
  33. package/dist/generic/securityInfo.js.map +1 -0
  34. package/dist/generic/transactionGroup.d.ts +24 -0
  35. package/dist/generic/transactionGroup.js +79 -0
  36. package/dist/generic/transactionGroup.js.map +1 -0
  37. package/dist/generic/util.d.ts +4 -0
  38. package/dist/generic/util.js +100 -0
  39. package/dist/generic/util.js.map +1 -0
  40. package/dist/generic/viewInfo.d.ts +57 -0
  41. package/dist/generic/viewInfo.js +121 -0
  42. package/dist/generic/viewInfo.js.map +1 -0
  43. package/dist/index.d.ts +15 -0
  44. package/dist/index.js +80 -0
  45. package/dist/index.js.map +1 -0
  46. package/dist/views/UserViewEntityBase.d.ts +171 -0
  47. package/dist/views/UserViewEntityBase.js +466 -0
  48. package/dist/views/UserViewEntityBase.js.map +1 -0
  49. package/dist/views/runView.d.ts +106 -0
  50. package/dist/views/runView.js +36 -0
  51. package/dist/views/runView.js.map +1 -0
  52. package/dist/views/viewInfo.d.ts +0 -0
  53. package/dist/views/viewInfo.js +118 -0
  54. package/dist/views/viewInfo.js.map +1 -0
  55. package/package.json +24 -0
@@ -0,0 +1,235 @@
1
+ import { BaseEntity } from "./baseEntity";
2
+ import { EntityInfo, RecordChange } from "./entityInfo";
3
+ import { ApplicationInfo } from "./applicationInfo";
4
+ import { RunViewParams } from "../views/runView";
5
+ import { AuditLogTypeInfo, AuthorizationInfo, RoleInfo, RowLevelSecurityFilterInfo, UserInfo } from "./securityInfo";
6
+ import { TransactionGroupBase } from "./transactionGroup";
7
+ import { RunReportParams } from "./runReport";
8
+ export declare class ProviderConfigDataBase {
9
+ private _includeSchemas;
10
+ private _excludeSchemas;
11
+ private _MJCoreSchemaName;
12
+ private _data;
13
+ get Data(): any;
14
+ get IncludeSchemas(): string[];
15
+ get MJCoreSchemaName(): string;
16
+ get ExcludeSchemas(): string[];
17
+ constructor(data: any, MJCoreScemaName?: string, includeSchemas?: string[], excludeSchemas?: string[]);
18
+ }
19
+ export declare class MetadataInfo {
20
+ ID: number;
21
+ Type: string;
22
+ UpdatedAt: Date;
23
+ }
24
+ export declare enum EntityDataProviderType {
25
+ Database = 1,
26
+ Network = 2
27
+ }
28
+ export interface IEntityDataProvider {
29
+ Config(configData: ProviderConfigDataBase): Promise<boolean>;
30
+ Load(entity: BaseEntity, RecordID: number, EntityRelationshipsToLoad: string[], user: UserInfo): Promise<{}>;
31
+ Save(entity: BaseEntity, user: UserInfo, options: EntitySaveOptions): Promise<{}>;
32
+ Delete(entity: BaseEntity, user: UserInfo): Promise<boolean>;
33
+ GetRecordChanges(entityName: string, recordId: number): Promise<RecordChange[]>;
34
+ get ProviderType(): EntityDataProviderType;
35
+ }
36
+ export declare class EntitySaveOptions {
37
+ IgnoreDirtyState: boolean;
38
+ SkipEntityAIActions?: boolean;
39
+ }
40
+ export declare class EntityRecordNameInput {
41
+ EntityName: string;
42
+ RecordID: number;
43
+ }
44
+ export declare class EntityRecordNameResult {
45
+ Success: boolean;
46
+ Status: string;
47
+ RecordID: number;
48
+ EntityName: string;
49
+ RecordName?: string;
50
+ }
51
+ export interface ILocalStorageProvider {
52
+ getItem(key: string): Promise<string | null>;
53
+ setItem(key: string, value: string): Promise<void>;
54
+ remove(key: string): Promise<void>;
55
+ }
56
+ export interface IMetadataProvider {
57
+ Config(configData: ProviderConfigDataBase): Promise<boolean>;
58
+ get Entities(): EntityInfo[];
59
+ get Applications(): ApplicationInfo[];
60
+ get CurrentUser(): UserInfo;
61
+ get Roles(): RoleInfo[];
62
+ get RowLevelSecurityFilters(): RowLevelSecurityFilterInfo[];
63
+ get AuditLogTypes(): AuditLogTypeInfo[];
64
+ get Authorizations(): AuthorizationInfo[];
65
+ get LatestRemoteMetadata(): MetadataInfo[];
66
+ get LatestLocalMetadata(): MetadataInfo[];
67
+ LocalMetadataObsolete(type?: string): boolean;
68
+ GetEntityObject(entityName: string, contextUser: UserInfo): Promise<BaseEntity>;
69
+ /**
70
+ * Returns the Name of the specific recordId for a given entityName. This is done by
71
+ * looking for the IsNameField within the EntityFields collection for a given entity.
72
+ * If no IsNameField is found, but a field called "Name" exists, that value is returned. Otherwise null returned
73
+ * @param entityName
74
+ * @param recordId
75
+ * @returns the name of the record
76
+ */
77
+ GetEntityRecordName(entityName: string, recordId: number): Promise<string>;
78
+ /**
79
+ * 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
80
+ * @param info
81
+ * @returns an array of EntityRecordNameResult objects
82
+ */
83
+ GetEntityRecordNames(info: EntityRecordNameInput[]): Promise<EntityRecordNameResult[]>;
84
+ GetRecordFavoriteStatus(userId: number, entityName: string, recordId: number): Promise<boolean>;
85
+ SetRecordFavoriteStatus(userId: number, entityName: string, recordId: number, isFavorite: boolean, contextUser: UserInfo): Promise<void>;
86
+ CreateTransactionGroup(): Promise<TransactionGroupBase>;
87
+ Refresh(): Promise<boolean>;
88
+ RefreshIfNeeded(): Promise<boolean>;
89
+ IsRefreshNeeded(): Promise<boolean>;
90
+ get LocalStorageProvider(): ILocalStorageProvider;
91
+ RefreshRemoteMetadataTimestamps(): Promise<boolean>;
92
+ SaveLocalMetadataToStorage(): Promise<void>;
93
+ /**
94
+ * Always retrieves data from the server - this method does NOT check cache. To use cached local values if available, call GetAndCacheDatasetByName() instead
95
+ * @param datasetName
96
+ * @param itemFilters
97
+ */
98
+ GetDatasetByName(datasetName: string, itemFilters?: DatasetItemFilterType[]): Promise<DatasetResultType>;
99
+ /**
100
+ * 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
101
+ * @param datasetName
102
+ * @param itemFilters
103
+ */
104
+ GetDatasetStatusByName(datasetName: string, itemFilters?: DatasetItemFilterType[]): Promise<DatasetStatusResultType>;
105
+ /**
106
+ * 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
107
+ * If itemFilters are provided, the combination of datasetName and the filters are used to determine a match in the cache
108
+ * @param datasetName
109
+ * @param itemFilters
110
+ */
111
+ GetAndCacheDatasetByName(datasetName: string, itemFilters?: DatasetItemFilterType[]): Promise<DatasetResultType>;
112
+ /**
113
+ * 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
114
+ * @param datasetName
115
+ * @param itemFilters
116
+ * @returns
117
+ */
118
+ IsDatasetCacheUpToDate(datasetName: string, itemFilters?: DatasetItemFilterType[]): Promise<boolean>;
119
+ /**
120
+ * This routine gets the local cached version of a given datasetName/itemFilters combination, it does NOT check the server status first.
121
+ * @param datasetName
122
+ * @param itemFilters
123
+ * @returns
124
+ */
125
+ GetCachedDataset(datasetName: string, itemFilters?: DatasetItemFilterType[]): Promise<DatasetResultType>;
126
+ /**
127
+ * 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
128
+ * @param datasetName
129
+ * @param itemFilters
130
+ * @param dataset
131
+ */
132
+ CacheDataset(datasetName: string, itemFilters: DatasetItemFilterType[], dataset: DatasetResultType): Promise<void>;
133
+ /**
134
+ * Determines if a given datasetName/itemFilters combination is cached locally or not
135
+ * @param datasetName
136
+ * @param itemFilters
137
+ * @returns
138
+ */
139
+ IsDatasetCached(datasetName: string, itemFilters?: DatasetItemFilterType[]): Promise<boolean>;
140
+ /**
141
+ * Creates a key for the given datasetName and itemFilters combination
142
+ * @param datasetName
143
+ * @param itemFilters
144
+ * @returns
145
+ */
146
+ GetDatasetCacheKey(datasetName: string, itemFilters?: DatasetItemFilterType[]): string;
147
+ /**
148
+ * 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
149
+ * @param datasetName
150
+ * @param itemFilters
151
+ */
152
+ ClearDatasetCache(datasetName: string, itemFilters?: DatasetItemFilterType[]): Promise<void>;
153
+ }
154
+ /**
155
+ * Result of a RunView() execution
156
+ */
157
+ export type RunViewResult = {
158
+ /**
159
+ * Was the view run successful or not
160
+ */
161
+ Success: boolean;
162
+ /**
163
+ * The array of records returned by the view, only valid if Success is true
164
+ */
165
+ Results: [];
166
+ /**
167
+ * The newly created UserViews.ID value - only provided if RunViewParams.SaveViewResults=true
168
+ */
169
+ UserViewRunID?: number;
170
+ /**
171
+ * Number of rows returned in the Results[] array
172
+ */
173
+ RowCount: number;
174
+ /**
175
+ * Total number of rows that match the view criteria, not just the number returned in the Results[] array
176
+ * This number will only be different when the view is configured to have a UserViewMaxRows value and the criteria of the view in question
177
+ * has more than that # of rows. Otherwise it will be the same value as RowCount.
178
+ */
179
+ TotalRowCount: number;
180
+ /**
181
+ * Time elapsed in executing the view (in milliseconds)
182
+ */
183
+ ExecutionTime: number;
184
+ /**
185
+ * If Success is false, this will contain a message describing the error condition.
186
+ */
187
+ ErrorMessage: string;
188
+ };
189
+ export interface IRunViewProvider {
190
+ Config(configData: ProviderConfigDataBase): Promise<boolean>;
191
+ RunView(params: RunViewParams, contextUser?: UserInfo): Promise<RunViewResult>;
192
+ }
193
+ export type RunReportResult = {
194
+ ReportID: number;
195
+ Success: boolean;
196
+ Results: any[];
197
+ RowCount: number;
198
+ ExecutionTime: number;
199
+ ErrorMessage: string;
200
+ };
201
+ export interface IRunReportProvider {
202
+ Config(configData: ProviderConfigDataBase): Promise<boolean>;
203
+ RunReport(params: RunReportParams, contextUser?: UserInfo): Promise<RunReportResult>;
204
+ }
205
+ export type DatasetResultType = {
206
+ DatasetID: number;
207
+ DatasetName: string;
208
+ Success: boolean;
209
+ Status: string;
210
+ LatestUpdateDate: Date;
211
+ Results: DatasetItemResultType[];
212
+ };
213
+ export type DatasetItemResultType = {
214
+ Code: string;
215
+ EntityName: string;
216
+ EntityID: number;
217
+ Results: any[];
218
+ };
219
+ export type DatasetItemFilterType = {
220
+ ItemCode: string;
221
+ Filter: string;
222
+ };
223
+ export type DatasetStatusResultType = {
224
+ DatasetID: number;
225
+ DatasetName: string;
226
+ Success: boolean;
227
+ Status: string;
228
+ LatestUpdateDate: Date;
229
+ EntityUpdateDates: DatasetStatusEntityUpdateDateType[];
230
+ };
231
+ export type DatasetStatusEntityUpdateDateType = {
232
+ EntityName: string;
233
+ EntityID: number;
234
+ UpdateDate: Date;
235
+ };
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EntityRecordNameResult = exports.EntityRecordNameInput = exports.EntitySaveOptions = exports.EntityDataProviderType = exports.MetadataInfo = exports.ProviderConfigDataBase = void 0;
4
+ class ProviderConfigDataBase {
5
+ get Data() {
6
+ return this._data;
7
+ }
8
+ get IncludeSchemas() {
9
+ return this._includeSchemas;
10
+ }
11
+ get MJCoreSchemaName() {
12
+ return this._MJCoreSchemaName;
13
+ }
14
+ get ExcludeSchemas() {
15
+ return this._excludeSchemas;
16
+ }
17
+ constructor(data, MJCoreScemaName = 'admin', includeSchemas, excludeSchemas) {
18
+ this._includeSchemas = [];
19
+ this._excludeSchemas = [];
20
+ this._MJCoreSchemaName = 'admin';
21
+ this._data = data;
22
+ this._MJCoreSchemaName = MJCoreScemaName;
23
+ if (includeSchemas)
24
+ this._includeSchemas = includeSchemas;
25
+ if (excludeSchemas)
26
+ this._excludeSchemas = excludeSchemas;
27
+ }
28
+ }
29
+ exports.ProviderConfigDataBase = ProviderConfigDataBase;
30
+ class MetadataInfo {
31
+ }
32
+ exports.MetadataInfo = MetadataInfo;
33
+ var EntityDataProviderType;
34
+ (function (EntityDataProviderType) {
35
+ EntityDataProviderType[EntityDataProviderType["Database"] = 1] = "Database";
36
+ EntityDataProviderType[EntityDataProviderType["Network"] = 2] = "Network";
37
+ })(EntityDataProviderType = exports.EntityDataProviderType || (exports.EntityDataProviderType = {}));
38
+ class EntitySaveOptions {
39
+ constructor() {
40
+ this.IgnoreDirtyState = false;
41
+ this.SkipEntityAIActions = false;
42
+ }
43
+ }
44
+ exports.EntitySaveOptions = EntitySaveOptions;
45
+ class EntityRecordNameInput {
46
+ }
47
+ exports.EntityRecordNameInput = EntityRecordNameInput;
48
+ class EntityRecordNameResult {
49
+ }
50
+ exports.EntityRecordNameResult = EntityRecordNameResult;
51
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/generic/interfaces.ts"],"names":[],"mappings":";;;AAQA,MAAa,sBAAsB;IAK/B,IAAW,IAAI;QACX,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IACD,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IACD,IAAW,gBAAgB;QACvB,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAClC,CAAC;IACD,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IACD,YAAY,IAAS,EAAE,kBAA0B,OAAO,EAAE,cAAyB,EAAE,cAAyB;QAhBtG,oBAAe,GAAa,EAAE,CAAC;QAC/B,oBAAe,GAAa,EAAE,CAAC;QAC/B,sBAAiB,GAAW,OAAO,CAAC;QAexC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,iBAAiB,GAAG,eAAe,CAAC;QACzC,IAAI,cAAc;YACd,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;QAC1C,IAAI,cAAc;YACd,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;IAC9C,CAAC;CACJ;AAzBD,wDAyBC;AAED,MAAa,YAAY;CAIxB;AAJD,oCAIC;AAED,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAC9B,2EAAY,CAAA;IACZ,yEAAW,CAAA;AACf,CAAC,EAHW,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAGjC;AAeD,MAAa,iBAAiB;IAA9B;QACI,qBAAgB,GAAY,KAAK,CAAC;QAClC,wBAAmB,GAAa,KAAK,CAAC;IAC1C,CAAC;CAAA;AAHD,8CAGC;AAED,MAAa,qBAAqB;CAGjC;AAHD,sDAGC;AAED,MAAa,sBAAsB;CAMjC;AANF,wDAME"}
@@ -0,0 +1,4 @@
1
+ export declare function LogError(message: any, logToFileName?: string, ...args: any[]): void;
2
+ export declare function LogStatus(message: any, logToFileName?: string, ...args: any[]): void;
3
+ export declare function GetProductionStatus(): boolean;
4
+ export declare function SetProductionStatus(isProduction: boolean): void;
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SetProductionStatus = exports.GetProductionStatus = exports.LogStatus = exports.LogError = void 0;
4
+ let fs;
5
+ if (runningOnNode()) {
6
+ try {
7
+ fs = require('fs');
8
+ }
9
+ catch (err) {
10
+ // shouldn't get here since we're checking for the node variables above, but have this
11
+ // try/catch block just in case.
12
+ // fs module is not available, normal in browser situation, we can't log to "Files" as that doesn't make sense in browser
13
+ }
14
+ }
15
+ function LogError(message, logToFileName = null, ...args) {
16
+ if (logToFileName !== null && logToFileName !== undefined && logToFileName.length >= 0)
17
+ logToFile(message, true, logToFileName, args);
18
+ else
19
+ logToConsole(message, true, args);
20
+ }
21
+ exports.LogError = LogError;
22
+ function LogStatus(message, logToFileName = null, ...args) {
23
+ if (logToFileName !== null && logToFileName !== undefined && logToFileName.length >= 0)
24
+ logToFile(message, false, logToFileName, args);
25
+ else
26
+ logToConsole(message, false, args);
27
+ }
28
+ exports.LogStatus = LogStatus;
29
+ function logToConsole(message, isError, ...args) {
30
+ if (isError) // always do console.error() for errors even in production
31
+ console.error(message, ...args);
32
+ else if (!GetProductionStatus()) // only do console.log() if we're not in production
33
+ console.log(message, ...args);
34
+ }
35
+ function logToFile(message, isError, logToFileName, ...args) {
36
+ if (fs === null || fs === undefined) {
37
+ console.error('Attempting to log to file, but fs module is not available, logging to console instead');
38
+ logToConsole(message, isError, args);
39
+ }
40
+ else
41
+ fs.appendFileSync(logToFileName, `${isError ? 'ERROR' : 'STATUS'} (${new Date()}: ${message}${args && args.length > 0 && args.join('').length > 0 ? '\n ARGS' + args.join('\n ') : ''}` + '\n');
42
+ }
43
+ let _productionStatus = null;
44
+ function GetProductionStatus() {
45
+ if (_productionStatus)
46
+ return _productionStatus;
47
+ else {
48
+ if (runningOnNode()) {
49
+ return (process.env.NODE_ENV === 'production');
50
+ }
51
+ else if (runningInBrowser()) {
52
+ // no status set if we get here, so return false, default to false to be safe and log stuff
53
+ // for debug scenarios on staging environments/etc.
54
+ return false;
55
+ }
56
+ }
57
+ }
58
+ exports.GetProductionStatus = GetProductionStatus;
59
+ function SetProductionStatus(isProduction) {
60
+ _productionStatus = isProduction;
61
+ }
62
+ exports.SetProductionStatus = SetProductionStatus;
63
+ function runningInBrowser() {
64
+ return (typeof window !== 'undefined' && window.location !== null);
65
+ }
66
+ function runningOnNode() {
67
+ return (typeof process !== 'undefined' && process.versions !== null && process.versions.node !== null);
68
+ }
69
+ //# sourceMappingURL=logging.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logging.js","sourceRoot":"","sources":["../../src/generic/logging.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,155 @@
1
+ import { DatasetItemFilterType, DatasetResultType, DatasetStatusResultType, EntityRecordNameInput, EntityRecordNameResult, ILocalStorageProvider, IMetadataProvider } from "./interfaces";
2
+ import { EntityInfo } 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
+ /**
8
+ * 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.
9
+ */
10
+ export declare class Metadata {
11
+ private static _globalProviderKey;
12
+ static get Provider(): IMetadataProvider;
13
+ static set Provider(value: IMetadataProvider);
14
+ /**
15
+ * Forces a refresh of all cached metadata.
16
+ * @returns
17
+ */
18
+ Refresh(): Promise<boolean>;
19
+ get Applications(): ApplicationInfo[];
20
+ get Entities(): EntityInfo[];
21
+ /**
22
+ * 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.
23
+ */
24
+ get CurrentUser(): UserInfo;
25
+ get Roles(): RoleInfo[];
26
+ get AuditLogTypes(): AuditLogTypeInfo[];
27
+ get Authorizations(): AuthorizationInfo[];
28
+ /**
29
+ * Helper function to return an Entity Name from a given Entity ID.
30
+ * @param entityName
31
+ * @returns
32
+ */
33
+ EntityIDFromName(entityName: string): number;
34
+ /**
35
+ * Helper function to return an Entity Name from an Entity ID
36
+ * @param entityID
37
+ * @returns
38
+ */
39
+ EntityNameFromID(entityID: number): string;
40
+ /**
41
+ * Returns true if the combination of userId/entityName/recordId has a favorite status on (meaning the user has marked the record as a "favorite" for easy access)
42
+ * @param userId
43
+ * @param entityName
44
+ * @param recordId
45
+ * @returns
46
+ */
47
+ GetRecordFavoriteStatus(userId: number, entityName: string, recordId: number): Promise<boolean>;
48
+ /**
49
+ * Sets the favorite status for a given user for a specific entityName/recordId
50
+ * @param userId
51
+ * @param entityName
52
+ * @param recordId
53
+ * @param isFavorite
54
+ * @param contextUser
55
+ */
56
+ SetRecordFavoriteStatus(userId: number, entityName: string, recordId: number, isFavorite: boolean, contextUser?: UserInfo): Promise<void>;
57
+ /**
58
+ * Returns a newly created instance of a sub-class of BaseEntity. The subclass depends on the class registrations for the
59
+ * requested entity. The class registrations are managed by the MJGlobal ClassFactory component.
60
+ * @param entityName - The name of the entity to create an instance of
61
+ * @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
62
+ * @returns - a newly created instance of a sub-class of BaseEntity. Remember you still to call Load() or NewRecord() to get going from there.
63
+ */
64
+ GetEntityObject(entityName: string, contextUser?: UserInfo): Promise<BaseEntity>;
65
+ /**
66
+ * Returns the Name of the specific recordId for a given entityName. This is done by
67
+ * looking for the IsNameField within the EntityFields collection for a given entity.
68
+ * If no IsNameField is found, but a field called "Name" exists, that value is returned. Otherwise null returned
69
+ * @param entityName
70
+ * @param recordId
71
+ * @returns the name of the record
72
+ */
73
+ GetEntityRecordName(entityName: string, recordId: number): Promise<string>;
74
+ /**
75
+ * 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
76
+ * @param info
77
+ * @returns an array of EntityRecordNameResult objects
78
+ */
79
+ GetEntityRecordNames(info: EntityRecordNameInput[]): Promise<EntityRecordNameResult[]>;
80
+ /**
81
+ * 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
82
+ * @returns
83
+ */
84
+ CreateTransactionGroup(): Promise<TransactionGroupBase>;
85
+ /**
86
+ * 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.
87
+ */
88
+ SaveLocalMetadataToStorage(): void;
89
+ /**
90
+ * Returns the local storage provider. This is used to store metadata locally on the client.
91
+ * @returns - the local storage provider
92
+ * @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.
93
+ */
94
+ get LocalStorageProvider(): ILocalStorageProvider;
95
+ /**
96
+ * 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
97
+ * @param datasetName
98
+ * @param itemFilters
99
+ */
100
+ GetDatasetStatusByName(datasetName: string, itemFilters?: DatasetItemFilterType[]): Promise<DatasetStatusResultType>;
101
+ /**
102
+ * Always retrieves data from the server - this method does NOT check cache. To use cached local values if available, call GetAndCacheDatasetByName() instead
103
+ * @param datasetName
104
+ * @param itemFilters
105
+ */
106
+ GetDatasetByName(datasetName: string, itemFilters?: DatasetItemFilterType[]): Promise<DatasetResultType>;
107
+ /**
108
+ * 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
109
+ * If itemFilters are provided, the combination of datasetName and the filters are used to determine a match in the cache
110
+ * @param datasetName
111
+ * @param itemFilters
112
+ */
113
+ GetAndCacheDatasetByName(datasetName: string, itemFilters?: DatasetItemFilterType[]): Promise<DatasetResultType>;
114
+ /**
115
+ * 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
116
+ * @param datasetName
117
+ * @param itemFilters
118
+ * @returns
119
+ */
120
+ IsDatasetCacheUpToDate(datasetName: string, itemFilters?: DatasetItemFilterType[]): Promise<boolean>;
121
+ /**
122
+ * This routine gets the local cached version of a given datasetName/itemFilters combination, it does NOT check the server status first.
123
+ * @param datasetName
124
+ * @param itemFilters
125
+ * @returns
126
+ */
127
+ GetCachedDataset(datasetName: string, itemFilters?: DatasetItemFilterType[]): Promise<DatasetResultType>;
128
+ /**
129
+ * 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
130
+ * @param datasetName
131
+ * @param itemFilters
132
+ * @param dataset
133
+ */
134
+ CacheDataset(datasetName: string, itemFilters: DatasetItemFilterType[], dataset: DatasetResultType): Promise<void>;
135
+ /**
136
+ * Determines if a given datasetName/itemFilters combination is cached locally or not
137
+ * @param datasetName
138
+ * @param itemFilters
139
+ * @returns
140
+ */
141
+ IsDatasetCached(datasetName: string, itemFilters?: DatasetItemFilterType[]): Promise<boolean>;
142
+ /**
143
+ * Creates a key for the given datasetName and itemFilters combination
144
+ * @param datasetName
145
+ * @param itemFilters
146
+ * @returns
147
+ */
148
+ GetDatasetCacheKey(datasetName: string, itemFilters?: DatasetItemFilterType[]): string;
149
+ /**
150
+ * 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
151
+ * @param datasetName
152
+ * @param itemFilters
153
+ */
154
+ ClearDatasetCache(datasetName: string, itemFilters?: DatasetItemFilterType[]): Promise<void>;
155
+ }