@memberjunction/core 1.7.0 → 1.8.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/generic/baseEngine.d.ts +104 -6
- package/dist/generic/baseEngine.d.ts.map +1 -1
- package/dist/generic/baseEngine.js +173 -13
- package/dist/generic/baseEngine.js.map +1 -1
- package/dist/generic/baseEntity.d.ts +17 -2
- package/dist/generic/baseEntity.d.ts.map +1 -1
- package/dist/generic/baseEntity.js +42 -8
- package/dist/generic/baseEntity.js.map +1 -1
- package/dist/generic/baseInfo.d.ts +0 -3
- package/dist/generic/baseInfo.d.ts.map +1 -1
- package/dist/generic/baseInfo.js +3 -34
- package/dist/generic/baseInfo.js.map +1 -1
- package/dist/generic/compositeKey.d.ts +35 -4
- package/dist/generic/compositeKey.d.ts.map +1 -1
- package/dist/generic/compositeKey.js +62 -12
- package/dist/generic/compositeKey.js.map +1 -1
- package/dist/generic/entityInfo.d.ts +44 -15
- package/dist/generic/entityInfo.d.ts.map +1 -1
- package/dist/generic/entityInfo.js +60 -18
- package/dist/generic/entityInfo.js.map +1 -1
- package/dist/generic/logging.d.ts +28 -32
- package/dist/generic/logging.d.ts.map +1 -1
- package/dist/generic/logging.js +65 -36
- package/dist/generic/logging.js.map +1 -1
- package/dist/generic/providerBase.d.ts +15 -0
- package/dist/generic/providerBase.d.ts.map +1 -1
- package/dist/generic/securityInfo.d.ts +12 -12
- package/dist/generic/securityInfo.d.ts.map +1 -1
- package/dist/generic/securityInfo.js +12 -12
- package/dist/generic/securityInfo.js.map +1 -1
- package/dist/generic/transactionGroup.d.ts +26 -0
- package/dist/generic/transactionGroup.d.ts.map +1 -1
- package/dist/generic/transactionGroup.js +62 -1
- package/dist/generic/transactionGroup.js.map +1 -1
- package/dist/generic/util.d.ts +25 -0
- package/dist/generic/util.d.ts.map +1 -1
- package/dist/generic/util.js +66 -1
- package/dist/generic/util.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,26 +1,55 @@
|
|
|
1
1
|
import { BaseSingleton } from "@memberjunction/global";
|
|
2
2
|
import { BehaviorSubject } from "rxjs";
|
|
3
3
|
import { UserInfo } from "./securityInfo";
|
|
4
|
+
import { DatasetItemFilterType } from "./interfaces";
|
|
5
|
+
import { BaseInfo } from "./baseInfo";
|
|
4
6
|
/**
|
|
5
7
|
* Property configuration for the BaseEngine class to automatically load/set properties on the class.
|
|
6
8
|
*/
|
|
7
|
-
export
|
|
9
|
+
export declare class BaseEnginePropertyConfig extends BaseInfo {
|
|
10
|
+
/**
|
|
11
|
+
* The type of item to load, either 'entity' or 'dataset', defaults to 'entity'
|
|
12
|
+
*/
|
|
13
|
+
Type: 'entity' | 'dataset';
|
|
8
14
|
/**
|
|
9
15
|
* The name of the property in the class instance
|
|
10
16
|
*/
|
|
11
17
|
PropertyName: string;
|
|
12
18
|
/**
|
|
13
|
-
* The entity name to load from the database
|
|
19
|
+
* The entity name to load from the database, required if Type is 'entity'
|
|
20
|
+
*/
|
|
21
|
+
EntityName?: string;
|
|
22
|
+
/**
|
|
23
|
+
* The dataset name to load from the database, required if Type is 'dataset'
|
|
14
24
|
*/
|
|
15
|
-
|
|
25
|
+
DatasetName?: string;
|
|
16
26
|
/**
|
|
17
|
-
* Optional, filters to apply to the data load
|
|
27
|
+
* Optional, filters to apply to the data load, applies only when type is 'entity'. Use DatasetItemFilters for dataset filters.
|
|
18
28
|
*/
|
|
19
29
|
Filter?: string;
|
|
20
30
|
/**
|
|
21
|
-
* Optional,
|
|
31
|
+
* Optional, filters to apply to each item in a dataset, only applies when type is 'dataset' and is optional in those cases.
|
|
32
|
+
*/
|
|
33
|
+
DatasetItemFilters?: DatasetItemFilterType[];
|
|
34
|
+
/**
|
|
35
|
+
* Optional, only used if Type is 'dataset', specifies how to handle the results of the dataset load. Defaults to 'single_property' if not specified. When set to 'single_property', the entire dataset is set to the property specified by PropertyName.
|
|
36
|
+
* When set to 'individual_properties', each item in the dataset is set to a property on the object with the name of the item's key plus the item's Code name.
|
|
37
|
+
* For example, if the item's key is 'Demo' and the item's Code name is 'FirstItem', the property set on the object would be 'Demo_FirstItem'.
|
|
38
|
+
*/
|
|
39
|
+
DatasetResultHandling?: 'single_property' | 'individual_properties';
|
|
40
|
+
/**
|
|
41
|
+
* Optional, order by clause to apply to the data load, only applies when type is 'entity'
|
|
22
42
|
*/
|
|
23
43
|
OrderBy?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Optional, expiration time in milliseconds
|
|
46
|
+
*/
|
|
47
|
+
Expiration?: number;
|
|
48
|
+
/**
|
|
49
|
+
* Optional, whether to add the result to the object, defaults to true if not specified
|
|
50
|
+
*/
|
|
51
|
+
AddToObject?: boolean;
|
|
52
|
+
constructor(init?: Partial<BaseEnginePropertyConfig>);
|
|
24
53
|
}
|
|
25
54
|
/**
|
|
26
55
|
* Abstract base class for any engine-style class which executes work on behalf of a caller typically using a provider-style architecture with plug-ins. This base class
|
|
@@ -31,6 +60,10 @@ export declare abstract class BaseEngine<T> extends BaseSingleton<T> {
|
|
|
31
60
|
private _loaded;
|
|
32
61
|
private _loadingSubject;
|
|
33
62
|
private _contextUser;
|
|
63
|
+
private _metadataConfigs;
|
|
64
|
+
private _dynamicConfigs;
|
|
65
|
+
private _dataMap;
|
|
66
|
+
private _expirationTimers;
|
|
34
67
|
/**
|
|
35
68
|
* Configures the engine by loading metadata from the database.
|
|
36
69
|
*/
|
|
@@ -42,14 +75,79 @@ export declare abstract class BaseEngine<T> extends BaseSingleton<T> {
|
|
|
42
75
|
* @param contextUser
|
|
43
76
|
* @returns
|
|
44
77
|
*/
|
|
45
|
-
protected Load(configs: BaseEnginePropertyConfig[], forceRefresh?: boolean, contextUser?: UserInfo): Promise<void>;
|
|
78
|
+
protected Load(configs: Partial<BaseEnginePropertyConfig>[], forceRefresh?: boolean, contextUser?: UserInfo): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Utility method to upgrade an object to a BaseEnginePropertyConfig object.
|
|
81
|
+
* @param obj
|
|
82
|
+
* @returns
|
|
83
|
+
*/
|
|
84
|
+
protected UpgradeObjectToConfig(obj: any): BaseEnginePropertyConfig;
|
|
85
|
+
/**
|
|
86
|
+
* Loads the specified metadata configurations.
|
|
87
|
+
* @param configs - The metadata configurations to load
|
|
88
|
+
* @param contextUser - The context user information
|
|
89
|
+
*/
|
|
90
|
+
protected LoadConfigs(configs: Partial<BaseEnginePropertyConfig>[], contextUser: UserInfo): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Loads a single metadata configuration.
|
|
93
|
+
* @param config - The metadata configuration to load
|
|
94
|
+
* @param contextUser - The context user information
|
|
95
|
+
*/
|
|
96
|
+
protected LoadSingleConfig(config: BaseEnginePropertyConfig, contextUser: UserInfo): Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Handles the process of loading a single config of type 'entity'.
|
|
99
|
+
* @param config
|
|
100
|
+
* @param contextUser
|
|
101
|
+
*/
|
|
102
|
+
protected LoadSingleEntityConfig(config: BaseEnginePropertyConfig, contextUser: UserInfo): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Handles the process of loading a single config of type 'dataset'.
|
|
105
|
+
* @param config
|
|
106
|
+
* @param contextUser
|
|
107
|
+
*/
|
|
108
|
+
protected LoadSingleDatasetConfig(config: BaseEnginePropertyConfig, contextUser: UserInfo): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Sets an expiration timer for a metadata property.
|
|
111
|
+
* @param propertyName - The name of the property
|
|
112
|
+
* @param expiration - The expiration time in milliseconds
|
|
113
|
+
*/
|
|
114
|
+
private SetExpirationTimer;
|
|
115
|
+
/**
|
|
116
|
+
* Adds a dynamic metadata configuration at runtime.
|
|
117
|
+
* @param config - The metadata configuration to add
|
|
118
|
+
* @param contextUser - The context user information
|
|
119
|
+
*/
|
|
120
|
+
AddDynamicConfig(config: BaseEnginePropertyConfig, contextUser?: UserInfo): Promise<void>;
|
|
121
|
+
/**
|
|
122
|
+
* Removes a dynamic metadata configuration at runtime.
|
|
123
|
+
* @param propertyName - The name of the property to remove
|
|
124
|
+
*/
|
|
125
|
+
RemoveDynamicConfig(propertyName: string): void;
|
|
126
|
+
/**
|
|
127
|
+
* Refreshes a specific item.
|
|
128
|
+
* @param propertyName - The name of the property to refresh
|
|
129
|
+
*/
|
|
130
|
+
RefreshItem(propertyName: string): Promise<void>;
|
|
131
|
+
/**
|
|
132
|
+
* Refreshes all items
|
|
133
|
+
*/
|
|
134
|
+
RefreshAllItems(): Promise<void>;
|
|
46
135
|
/**
|
|
47
136
|
* Subclasses can override this method to perform additional loading tasks
|
|
48
137
|
* @param contextUser
|
|
49
138
|
*/
|
|
50
139
|
protected AdditionalLoading(contextUser?: UserInfo): Promise<void>;
|
|
140
|
+
/**
|
|
141
|
+
* Returns true if the data has been loaded, false otherwise.
|
|
142
|
+
*/
|
|
51
143
|
get Loaded(): boolean;
|
|
144
|
+
/**
|
|
145
|
+
* Returns the loading subject. You can call await Config() and after Config() comes back as true that means you're loaded. However you can also directly subscribe to this subject to get updates on the loading status.
|
|
146
|
+
*/
|
|
52
147
|
get LoadingSubject(): BehaviorSubject<boolean>;
|
|
148
|
+
/**
|
|
149
|
+
* Returns the context user set for the object, this is set via the Config() method.
|
|
150
|
+
*/
|
|
53
151
|
get ContextUser(): UserInfo;
|
|
54
152
|
/**
|
|
55
153
|
* Helper method for sub-classes to have a single line of code that will make sure the data is loaded before proceeding and will throw an error if not loaded.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseEngine.d.ts","sourceRoot":"","sources":["../../src/generic/baseEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI1C;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"baseEngine.d.ts","sourceRoot":"","sources":["../../src/generic/baseEngine.ts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IAAI,OAAO,CAE3B;IAED;;OAEG;IACH,IAAW,cAAc,IAAI,eAAe,CAAC,OAAO,CAAC,CAEpD;IAED;;OAEG;IACH,IAAW,WAAW,IAAI,QAAQ,CAEjC;IAED;;OAEG;IACH,SAAS,CAAC,mBAAmB;CAIhC"}
|
|
@@ -1,10 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseEngine = void 0;
|
|
3
|
+
exports.BaseEngine = exports.BaseEnginePropertyConfig = void 0;
|
|
4
4
|
const global_1 = require("@memberjunction/global");
|
|
5
5
|
const rxjs_1 = require("rxjs");
|
|
6
6
|
const runView_1 = require("../views/runView");
|
|
7
7
|
const logging_1 = require("./logging");
|
|
8
|
+
const metadata_1 = require("./metadata");
|
|
9
|
+
const interfaces_1 = require("./interfaces");
|
|
10
|
+
const baseInfo_1 = require("./baseInfo");
|
|
11
|
+
/**
|
|
12
|
+
* Property configuration for the BaseEngine class to automatically load/set properties on the class.
|
|
13
|
+
*/
|
|
14
|
+
class BaseEnginePropertyConfig extends baseInfo_1.BaseInfo {
|
|
15
|
+
constructor(init) {
|
|
16
|
+
super();
|
|
17
|
+
/**
|
|
18
|
+
* The type of item to load, either 'entity' or 'dataset', defaults to 'entity'
|
|
19
|
+
*/
|
|
20
|
+
this.Type = 'entity';
|
|
21
|
+
/**
|
|
22
|
+
* Optional, only used if Type is 'dataset', specifies how to handle the results of the dataset load. Defaults to 'single_property' if not specified. When set to 'single_property', the entire dataset is set to the property specified by PropertyName.
|
|
23
|
+
* When set to 'individual_properties', each item in the dataset is set to a property on the object with the name of the item's key plus the item's Code name.
|
|
24
|
+
* For example, if the item's key is 'Demo' and the item's Code name is 'FirstItem', the property set on the object would be 'Demo_FirstItem'.
|
|
25
|
+
*/
|
|
26
|
+
this.DatasetResultHandling = 'single_property';
|
|
27
|
+
// now copy the values from init to this object
|
|
28
|
+
if (init)
|
|
29
|
+
Object.assign(this, init);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.BaseEnginePropertyConfig = BaseEnginePropertyConfig;
|
|
8
33
|
/**
|
|
9
34
|
* Abstract base class for any engine-style class which executes work on behalf of a caller typically using a provider-style architecture with plug-ins. This base class
|
|
10
35
|
* provides a mechanism for loading metadata from the database and caching it for use by the engine. Subclasses must implement the Config abstract method and within that
|
|
@@ -15,6 +40,10 @@ class BaseEngine extends global_1.BaseSingleton {
|
|
|
15
40
|
super(...arguments);
|
|
16
41
|
this._loaded = false;
|
|
17
42
|
this._loadingSubject = new rxjs_1.BehaviorSubject(false);
|
|
43
|
+
this._metadataConfigs = [];
|
|
44
|
+
this._dynamicConfigs = new Map();
|
|
45
|
+
this._dataMap = new Map();
|
|
46
|
+
this._expirationTimers = new Map();
|
|
18
47
|
}
|
|
19
48
|
/**
|
|
20
49
|
* This method should be called by sub-classes to load up their specific metadata requirements. For more complex metadata
|
|
@@ -24,6 +53,8 @@ class BaseEngine extends global_1.BaseSingleton {
|
|
|
24
53
|
* @returns
|
|
25
54
|
*/
|
|
26
55
|
async Load(configs, forceRefresh = false, contextUser) {
|
|
56
|
+
if (metadata_1.Metadata.Provider.ProviderType === interfaces_1.ProviderType.Database && !contextUser)
|
|
57
|
+
throw new Error('For server-side use of all engine classes, you must provide the contextUser parameter');
|
|
27
58
|
if (this._loadingSubject.value) {
|
|
28
59
|
return new Promise((resolve) => {
|
|
29
60
|
const subscription = this._loadingSubject.subscribe((loading) => {
|
|
@@ -38,18 +69,7 @@ class BaseEngine extends global_1.BaseSingleton {
|
|
|
38
69
|
this._loadingSubject.next(true);
|
|
39
70
|
try {
|
|
40
71
|
this._contextUser = contextUser;
|
|
41
|
-
|
|
42
|
-
for (const config of configs) {
|
|
43
|
-
const result = await rv.RunView({
|
|
44
|
-
EntityName: config.EntityName,
|
|
45
|
-
ResultType: 'entity_object',
|
|
46
|
-
ExtraFilter: config.Filter,
|
|
47
|
-
OrderBy: config.OrderBy
|
|
48
|
-
}, contextUser);
|
|
49
|
-
if (result.Success) {
|
|
50
|
-
this[config.PropertyName] = result.Results;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
72
|
+
await this.LoadConfigs(configs, contextUser);
|
|
53
73
|
await this.AdditionalLoading(contextUser); // Call the additional loading method
|
|
54
74
|
this._loaded = true;
|
|
55
75
|
}
|
|
@@ -61,6 +81,137 @@ class BaseEngine extends global_1.BaseSingleton {
|
|
|
61
81
|
}
|
|
62
82
|
}
|
|
63
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Utility method to upgrade an object to a BaseEnginePropertyConfig object.
|
|
86
|
+
* @param obj
|
|
87
|
+
* @returns
|
|
88
|
+
*/
|
|
89
|
+
UpgradeObjectToConfig(obj) {
|
|
90
|
+
// if obj is not already an instance of BaseEnginePropertyConfig, create one
|
|
91
|
+
if (obj instanceof BaseEnginePropertyConfig)
|
|
92
|
+
return obj;
|
|
93
|
+
else
|
|
94
|
+
return new BaseEnginePropertyConfig(obj);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Loads the specified metadata configurations.
|
|
98
|
+
* @param configs - The metadata configurations to load
|
|
99
|
+
* @param contextUser - The context user information
|
|
100
|
+
*/
|
|
101
|
+
async LoadConfigs(configs, contextUser) {
|
|
102
|
+
this._metadataConfigs = configs.map(c => this.UpgradeObjectToConfig(c));
|
|
103
|
+
await Promise.all(this._metadataConfigs.map(c => this.LoadSingleConfig(c, contextUser)));
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Loads a single metadata configuration.
|
|
107
|
+
* @param config - The metadata configuration to load
|
|
108
|
+
* @param contextUser - The context user information
|
|
109
|
+
*/
|
|
110
|
+
async LoadSingleConfig(config, contextUser) {
|
|
111
|
+
if (config.Type === 'dataset')
|
|
112
|
+
return await this.LoadSingleDatasetConfig(config, contextUser);
|
|
113
|
+
else
|
|
114
|
+
return await this.LoadSingleEntityConfig(config, contextUser);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Handles the process of loading a single config of type 'entity'.
|
|
118
|
+
* @param config
|
|
119
|
+
* @param contextUser
|
|
120
|
+
*/
|
|
121
|
+
async LoadSingleEntityConfig(config, contextUser) {
|
|
122
|
+
const rv = new runView_1.RunView();
|
|
123
|
+
const result = await rv.RunView({
|
|
124
|
+
EntityName: config.EntityName,
|
|
125
|
+
ResultType: 'entity_object',
|
|
126
|
+
ExtraFilter: config.Filter,
|
|
127
|
+
OrderBy: config.OrderBy
|
|
128
|
+
}, contextUser);
|
|
129
|
+
if (result.Success) {
|
|
130
|
+
if (config.AddToObject !== false) {
|
|
131
|
+
this[config.PropertyName] = result.Results;
|
|
132
|
+
}
|
|
133
|
+
this._dataMap.set(config.PropertyName, { entityName: config.EntityName, data: result.Results });
|
|
134
|
+
if (config.Expiration) {
|
|
135
|
+
this.SetExpirationTimer(config.PropertyName, config.Expiration);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Handles the process of loading a single config of type 'dataset'.
|
|
141
|
+
* @param config
|
|
142
|
+
* @param contextUser
|
|
143
|
+
*/
|
|
144
|
+
async LoadSingleDatasetConfig(config, contextUser) {
|
|
145
|
+
const md = new metadata_1.Metadata();
|
|
146
|
+
const result = await md.GetAndCacheDatasetByName(config.DatasetName, config.DatasetItemFilters);
|
|
147
|
+
if (result.Success) {
|
|
148
|
+
if (config.AddToObject !== false) {
|
|
149
|
+
if (config.DatasetResultHandling === 'single_property') {
|
|
150
|
+
this[config.PropertyName] = result.Results;
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
// explode out the items within the DS into individual properties
|
|
154
|
+
for (const item of result.Results) {
|
|
155
|
+
this[`${config.PropertyName}_${item.Code}`] = item.Results;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
this._dataMap.set(config.PropertyName, { datasetName: config.DatasetName, data: result.Results });
|
|
160
|
+
if (config.Expiration) {
|
|
161
|
+
this.SetExpirationTimer(config.PropertyName, config.Expiration);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Sets an expiration timer for a metadata property.
|
|
167
|
+
* @param propertyName - The name of the property
|
|
168
|
+
* @param expiration - The expiration time in milliseconds
|
|
169
|
+
*/
|
|
170
|
+
SetExpirationTimer(propertyName, expiration) {
|
|
171
|
+
if (this._expirationTimers.has(propertyName)) {
|
|
172
|
+
clearTimeout(this._expirationTimers.get(propertyName));
|
|
173
|
+
}
|
|
174
|
+
const timer = setTimeout(() => this.RefreshItem(propertyName), expiration);
|
|
175
|
+
this._expirationTimers.set(propertyName, timer);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Adds a dynamic metadata configuration at runtime.
|
|
179
|
+
* @param config - The metadata configuration to add
|
|
180
|
+
* @param contextUser - The context user information
|
|
181
|
+
*/
|
|
182
|
+
async AddDynamicConfig(config, contextUser) {
|
|
183
|
+
const c = this.UpgradeObjectToConfig(config);
|
|
184
|
+
this._dynamicConfigs.set(c.PropertyName, c);
|
|
185
|
+
await this.LoadSingleConfig(c, contextUser || this._contextUser);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Removes a dynamic metadata configuration at runtime.
|
|
189
|
+
* @param propertyName - The name of the property to remove
|
|
190
|
+
*/
|
|
191
|
+
RemoveDynamicConfig(propertyName) {
|
|
192
|
+
this._dynamicConfigs.delete(propertyName);
|
|
193
|
+
this._dataMap.delete(propertyName);
|
|
194
|
+
if (this._expirationTimers.has(propertyName)) {
|
|
195
|
+
clearTimeout(this._expirationTimers.get(propertyName));
|
|
196
|
+
this._expirationTimers.delete(propertyName);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Refreshes a specific item.
|
|
201
|
+
* @param propertyName - The name of the property to refresh
|
|
202
|
+
*/
|
|
203
|
+
async RefreshItem(propertyName) {
|
|
204
|
+
const config = this._metadataConfigs.find(c => c.PropertyName === propertyName) || this._dynamicConfigs.get(propertyName);
|
|
205
|
+
if (config) {
|
|
206
|
+
await this.LoadSingleConfig(config, this._contextUser);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Refreshes all items
|
|
211
|
+
*/
|
|
212
|
+
async RefreshAllItems() {
|
|
213
|
+
await this.LoadConfigs([...this._metadataConfigs, ...Array.from(this._dynamicConfigs.values())], this._contextUser);
|
|
214
|
+
}
|
|
64
215
|
/**
|
|
65
216
|
* Subclasses can override this method to perform additional loading tasks
|
|
66
217
|
* @param contextUser
|
|
@@ -68,12 +219,21 @@ class BaseEngine extends global_1.BaseSingleton {
|
|
|
68
219
|
async AdditionalLoading(contextUser) {
|
|
69
220
|
// Subclasses can override this method to perform additional loading tasks
|
|
70
221
|
}
|
|
222
|
+
/**
|
|
223
|
+
* Returns true if the data has been loaded, false otherwise.
|
|
224
|
+
*/
|
|
71
225
|
get Loaded() {
|
|
72
226
|
return this._loaded;
|
|
73
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* Returns the loading subject. You can call await Config() and after Config() comes back as true that means you're loaded. However you can also directly subscribe to this subject to get updates on the loading status.
|
|
230
|
+
*/
|
|
74
231
|
get LoadingSubject() {
|
|
75
232
|
return this._loadingSubject;
|
|
76
233
|
}
|
|
234
|
+
/**
|
|
235
|
+
* Returns the context user set for the object, this is set via the Config() method.
|
|
236
|
+
*/
|
|
77
237
|
get ContextUser() {
|
|
78
238
|
return this._contextUser;
|
|
79
239
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseEngine.js","sourceRoot":"","sources":["../../src/generic/baseEngine.ts"],"names":[],"mappings":";;;AAAA,mDAAuD;AACvD,+BAAuC;AAEvC,8CAA2C;AAC3C,uCAAqC;
|
|
1
|
+
{"version":3,"file":"baseEngine.js","sourceRoot":"","sources":["../../src/generic/baseEngine.ts"],"names":[],"mappings":";;;AAAA,mDAAuD;AACvD,+BAAuC;A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xB,MAAM,IAAI,CAAC,WAAW,CAAC,CAAC,GAAG,IAAI,CAAC,gBAAgB,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IACxH,CAAC;IAED;;;OAGG;IACO,KAAK,CAAC,iBAAiB,CAAC,WAAsB;QACpD,0EAA0E;IAC9E,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IAED;;OAEG;IACO,mBAAmB;QACzB,IAAI,CAAC,IAAI,CAAC,MAAM;YACZ,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;IACjE,CAAC;CACJ;AAxOD,gCAwOC"}
|
|
@@ -132,7 +132,10 @@ export declare class BaseEntityResult {
|
|
|
132
132
|
* Event type that is used to raise events and provided structured callbacks for any caller that is interested in registering for events.
|
|
133
133
|
*/
|
|
134
134
|
export declare class BaseEntityEvent {
|
|
135
|
-
|
|
135
|
+
/**
|
|
136
|
+
* The type of event that is being raised. transaction_ready is used to indicate that a transaction is ready to be submitted for execution. The TransactionGroup class uses this to know that all async preprocessing is done and it can now submit the transaction.
|
|
137
|
+
*/
|
|
138
|
+
type: 'new_record' | 'save' | 'delete' | 'transaction_ready' | 'other';
|
|
136
139
|
payload: any;
|
|
137
140
|
baseEntity: BaseEntity;
|
|
138
141
|
}
|
|
@@ -156,10 +159,22 @@ export declare abstract class BaseEntity {
|
|
|
156
159
|
* @returns
|
|
157
160
|
*/
|
|
158
161
|
RegisterEventHandler(callback: (event: BaseEntityEvent) => void): Subscription;
|
|
162
|
+
/**
|
|
163
|
+
* If the entity object has a TransactionGroup associated with it, the TransactionGroup will be notified that we are doing some transaction pre-processing so that the TransactionGroup can
|
|
164
|
+
* properly wait for those pre-processing steps to complete before submitting the transaction. This method should generally NOT be called by anyone other than a provider that is handling
|
|
165
|
+
* the tier-specific processing for the entity object.
|
|
166
|
+
*/
|
|
167
|
+
RegisterTransactionPreprocessing(): void;
|
|
168
|
+
/**
|
|
169
|
+
* Raises the transaction_ready event. This is used to indicate that the entity object is ready to be submitted for transaction processing. This is used by the TransactionGroup class to know when all async preprocessing is
|
|
170
|
+
* done and it can submit the transaction. This is an internal method and shouldn't be used by sub-classes or external callers in most cases. It is primarily used by Provider classes who are handling the tier-specific processing
|
|
171
|
+
* for the entity object.
|
|
172
|
+
*/
|
|
173
|
+
RaiseReadyForTransaction(): void;
|
|
159
174
|
/**
|
|
160
175
|
* Used for raising events within the BaseEntity and can be used by sub-classes to raise events that are specific to the entity.
|
|
161
176
|
*/
|
|
162
|
-
protected RaiseEvent(type: 'new_record' | 'save' | 'delete' | 'other', payload: any): void;
|
|
177
|
+
protected RaiseEvent(type: 'new_record' | 'save' | 'delete' | 'transaction_ready' | 'other', payload: any): void;
|
|
163
178
|
/**
|
|
164
179
|
* This method MUST be called right after the class is instantiated to provide an async/await pair for any asynchronous operations a given entity needs to do when it is first
|
|
165
180
|
* created/configured. When you call Metadata/Provider GetEntityObject() this is done automatically for you. In nearly all cases you should go through GetEntityObject() anyway
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseEntity.d.ts","sourceRoot":"","sources":["../../src/generic/baseEntity.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,YAAY,EAAuB,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACjL,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAG3F,OAAO,EAAE,QAAQ,EAAE,MAAM,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,EAMpD;IAED;;OAEG;IACH,IAAW,aAAa,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAOlD;IAED;;;;;OAKG;WACiB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;CAiBhH"}
|
|
@@ -279,6 +279,24 @@ class BaseEntity {
|
|
|
279
279
|
RegisterEventHandler(callback) {
|
|
280
280
|
return this._eventSubject.asObservable().subscribe(callback);
|
|
281
281
|
}
|
|
282
|
+
/**
|
|
283
|
+
* If the entity object has a TransactionGroup associated with it, the TransactionGroup will be notified that we are doing some transaction pre-processing so that the TransactionGroup can
|
|
284
|
+
* properly wait for those pre-processing steps to complete before submitting the transaction. This method should generally NOT be called by anyone other than a provider that is handling
|
|
285
|
+
* the tier-specific processing for the entity object.
|
|
286
|
+
*/
|
|
287
|
+
RegisterTransactionPreprocessing() {
|
|
288
|
+
if (this.TransactionGroup) {
|
|
289
|
+
this.TransactionGroup.RegisterPreprocessing(this);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Raises the transaction_ready event. This is used to indicate that the entity object is ready to be submitted for transaction processing. This is used by the TransactionGroup class to know when all async preprocessing is
|
|
294
|
+
* done and it can submit the transaction. This is an internal method and shouldn't be used by sub-classes or external callers in most cases. It is primarily used by Provider classes who are handling the tier-specific processing
|
|
295
|
+
* for the entity object.
|
|
296
|
+
*/
|
|
297
|
+
RaiseReadyForTransaction() {
|
|
298
|
+
this.RaiseEvent('transaction_ready', null);
|
|
299
|
+
}
|
|
282
300
|
/**
|
|
283
301
|
* Used for raising events within the BaseEntity and can be used by sub-classes to raise events that are specific to the entity.
|
|
284
302
|
*/
|
|
@@ -674,20 +692,36 @@ class BaseEntity {
|
|
|
674
692
|
// first check if the AllowCreateAPI/AllowUpdateAPI/AllowDeleteAPI settings are flipped on for the entity in question
|
|
675
693
|
switch (type) {
|
|
676
694
|
case entityInfo_1.EntityPermissionType.Create:
|
|
677
|
-
if (!this.EntityInfo.AllowCreateAPI)
|
|
678
|
-
|
|
695
|
+
if (!this.EntityInfo.AllowCreateAPI) {
|
|
696
|
+
if (throwError)
|
|
697
|
+
throw new Error(`Create API is disabled for ${this.EntityInfo.Name}`);
|
|
698
|
+
else
|
|
699
|
+
return false;
|
|
700
|
+
}
|
|
679
701
|
break;
|
|
680
702
|
case entityInfo_1.EntityPermissionType.Update:
|
|
681
|
-
if (!this.EntityInfo.AllowUpdateAPI)
|
|
682
|
-
|
|
703
|
+
if (!this.EntityInfo.AllowUpdateAPI) {
|
|
704
|
+
if (throwError)
|
|
705
|
+
throw new Error(`Update API is disabled for ${this.EntityInfo.Name}`);
|
|
706
|
+
else
|
|
707
|
+
return false;
|
|
708
|
+
}
|
|
683
709
|
break;
|
|
684
710
|
case entityInfo_1.EntityPermissionType.Delete:
|
|
685
|
-
if (!this.EntityInfo.AllowDeleteAPI)
|
|
686
|
-
|
|
711
|
+
if (!this.EntityInfo.AllowDeleteAPI) {
|
|
712
|
+
if (throwError)
|
|
713
|
+
throw new Error(`Delete API is disabled for ${this.EntityInfo.Name}`);
|
|
714
|
+
else
|
|
715
|
+
return false;
|
|
716
|
+
}
|
|
687
717
|
break;
|
|
688
718
|
case entityInfo_1.EntityPermissionType.Read:
|
|
689
|
-
if (!this.EntityInfo.IncludeInAPI)
|
|
690
|
-
|
|
719
|
+
if (!this.EntityInfo.IncludeInAPI) {
|
|
720
|
+
if (throwError)
|
|
721
|
+
throw new Error(`API is disabled for ${this.EntityInfo.Name}`);
|
|
722
|
+
else
|
|
723
|
+
return false;
|
|
724
|
+
}
|
|
691
725
|
break;
|
|
692
726
|
}
|
|
693
727
|
const permissions = this.EntityInfo.GetUserPermisions(u);
|