@memberjunction/actions-base 2.12.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/ActionEngine-Base.d.ts +145 -0
- package/dist/ActionEngine-Base.d.ts.map +1 -0
- package/dist/ActionEngine-Base.js +115 -0
- package/dist/ActionEngine-Base.js.map +1 -0
- package/dist/ActionEntity-Extended.d.ts +21 -0
- package/dist/ActionEntity-Extended.d.ts.map +1 -0
- package/dist/ActionEntity-Extended.js +62 -0
- package/dist/ActionEntity-Extended.js.map +1 -0
- package/dist/EntityActionEngine-Base.d.ts +122 -0
- package/dist/EntityActionEngine-Base.d.ts.map +1 -0
- package/dist/EntityActionEngine-Base.js +128 -0
- package/dist/EntityActionEngine-Base.js.map +1 -0
- package/dist/EntityActionEntity-Extended.d.ts +22 -0
- package/dist/EntityActionEntity-Extended.d.ts.map +1 -0
- package/dist/EntityActionEntity-Extended.js +62 -0
- package/dist/EntityActionEntity-Extended.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/package.json +26 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { BaseEngine, UserInfo } from "@memberjunction/core";
|
|
2
|
+
import { ActionEntity, ActionExecutionLogEntity, ActionFilterEntity, ActionLibraryEntity, ActionParamEntity, ActionResultCodeEntity } from "@memberjunction/core-entities";
|
|
3
|
+
import { ActionEntityExtended } from "./ActionEntity-Extended";
|
|
4
|
+
export declare class ActionLibrary {
|
|
5
|
+
LibraryName: string;
|
|
6
|
+
ItemsUsed: string[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Class that is used for passing around generated code includes properties such as the code itself and a description of what the code does.
|
|
10
|
+
*/
|
|
11
|
+
export declare class GeneratedCode {
|
|
12
|
+
/**
|
|
13
|
+
* Indicates if the code generation was successful or not.
|
|
14
|
+
*/
|
|
15
|
+
Success: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* The generated executable code
|
|
18
|
+
*/
|
|
19
|
+
Code: string;
|
|
20
|
+
/**
|
|
21
|
+
* List of libraries and library items used in the generated code
|
|
22
|
+
*/
|
|
23
|
+
LibrariesUsed: ActionLibrary[];
|
|
24
|
+
/**
|
|
25
|
+
* A description of the code used for documentation purposes
|
|
26
|
+
*/
|
|
27
|
+
Comments: string;
|
|
28
|
+
/**
|
|
29
|
+
* ErrorMessage if the code generation failed
|
|
30
|
+
*/
|
|
31
|
+
ErrorMessage?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Class that has the result of the individual action execution and used by the engine or other caller
|
|
35
|
+
*/
|
|
36
|
+
export declare class ActionResultSimple {
|
|
37
|
+
/**
|
|
38
|
+
* Indicates if the action was successful or not.
|
|
39
|
+
*/
|
|
40
|
+
Success: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* A string that indicates the strucutred output/results of the action
|
|
43
|
+
*/
|
|
44
|
+
ResultCode: string;
|
|
45
|
+
/**
|
|
46
|
+
* Optional, additional information about the result of the action
|
|
47
|
+
*/
|
|
48
|
+
Message?: string;
|
|
49
|
+
/**
|
|
50
|
+
* All parameters including inputs and outputs are provided here for convenience
|
|
51
|
+
*/
|
|
52
|
+
Params?: ActionParam[];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Class that has the result of a complete action execution, returned by the Run method of the ActionEngine.
|
|
56
|
+
*/
|
|
57
|
+
export declare class ActionResult {
|
|
58
|
+
/**
|
|
59
|
+
* Contains the parameters that were used to run the action as a convenience.
|
|
60
|
+
*/
|
|
61
|
+
RunParams: RunActionParams;
|
|
62
|
+
/**
|
|
63
|
+
* Indicates if the action was successful or not.
|
|
64
|
+
*/
|
|
65
|
+
Success: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* A code that indicates the outcome of the action. Will be one of the possible ResultCodes enumerated in the ActionResultCodeEntity
|
|
68
|
+
*/
|
|
69
|
+
Result?: ActionResultCodeEntity;
|
|
70
|
+
/**
|
|
71
|
+
* Whenever an action is executed a log entry is created. This log entry is stored in the database and can be used to track the execution of the action. This property contains the log entry object for the action that was run.
|
|
72
|
+
*/
|
|
73
|
+
LogEntry: ActionExecutionLogEntity;
|
|
74
|
+
/**
|
|
75
|
+
* Optional, a message an action can include that describes the outcome of the action. This is typically used to display a message to the user.
|
|
76
|
+
*/
|
|
77
|
+
Message?: string;
|
|
78
|
+
/**
|
|
79
|
+
* All parameters including inputs and outputs are provided here for convenience
|
|
80
|
+
*/
|
|
81
|
+
Params?: ActionParam[];
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Runtime parameter class that is used to pass key/value pairs in arrays to/from the action engine.
|
|
85
|
+
*/
|
|
86
|
+
export declare class ActionParam {
|
|
87
|
+
/**
|
|
88
|
+
* The name of the parameter
|
|
89
|
+
*/
|
|
90
|
+
Name: string;
|
|
91
|
+
/**
|
|
92
|
+
* The value of the parameter. This can be any type of object.
|
|
93
|
+
*/
|
|
94
|
+
Value: any;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Class that holds the parameters for an action to be run. This is passed to the Run method of an action.
|
|
98
|
+
*/
|
|
99
|
+
export declare class RunActionParams {
|
|
100
|
+
Action: ActionEntity;
|
|
101
|
+
ContextUser: UserInfo;
|
|
102
|
+
/**
|
|
103
|
+
* Optional, a list of filters that should be run before the action is executed.
|
|
104
|
+
*/
|
|
105
|
+
Filters: ActionFilterEntity[];
|
|
106
|
+
/**
|
|
107
|
+
* Optional, the input and output parameters as defined in the metadata for the action.
|
|
108
|
+
*/
|
|
109
|
+
Params: ActionParam[];
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Base class for Action metadata.
|
|
113
|
+
*/
|
|
114
|
+
export declare class ActionEngineBase extends BaseEngine<ActionEngineBase> {
|
|
115
|
+
private __coreCategoryName;
|
|
116
|
+
/**
|
|
117
|
+
* Returns the global instance of the class. This is a singleton class, so there is only one instance of it in the application. Do not directly create new instances of it, always use this method to get the instance.
|
|
118
|
+
*/
|
|
119
|
+
static get Instance(): ActionEngineBase;
|
|
120
|
+
private _Actions;
|
|
121
|
+
private _Filters;
|
|
122
|
+
private _Params;
|
|
123
|
+
private _ActionResultCodes;
|
|
124
|
+
private _ActionLibraries;
|
|
125
|
+
/**
|
|
126
|
+
* This method is called to configure the ActionEngine. It loads the metadata for the actions, filters, and result codes and caches them in the GlobalObjectStore. You must call this method before running any actions.
|
|
127
|
+
* If this method was previously run on the instance of the ActionEngine, it will return immediately without re-loading the metadata. If you want to force a reload of the metadata, you can pass true for the forceReload parameter.
|
|
128
|
+
* @param forceRefresh If true, the metadata will be loaded from the database even if it was previously loaded.
|
|
129
|
+
* @param contextUser If you are running the action on the server side you must pass this in, but it is not required in an environment where a user is authenticated directly, e.g. a browser or other client.
|
|
130
|
+
*/
|
|
131
|
+
Config(forceRefresh?: boolean, contextUser?: UserInfo): Promise<void>;
|
|
132
|
+
get Actions(): ActionEntityExtended[];
|
|
133
|
+
get ActionParams(): ActionParamEntity[];
|
|
134
|
+
get ActionFilters(): ActionFilterEntity[];
|
|
135
|
+
get ActionResultCodes(): ActionResultCodeEntity[];
|
|
136
|
+
get ActionLibraries(): ActionLibraryEntity[];
|
|
137
|
+
get CoreActions(): ActionEntityExtended[];
|
|
138
|
+
get NonCoreActions(): ActionEntityExtended[];
|
|
139
|
+
get CoreCategoryName(): string;
|
|
140
|
+
/**
|
|
141
|
+
* This method handles input validation. Subclasses can override this method to provide custom input validation.
|
|
142
|
+
*/
|
|
143
|
+
protected ValidateInputs(params: RunActionParams): Promise<boolean>;
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=ActionEngine-Base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionEngine-Base.d.ts","sourceRoot":"","sources":["../src/ActionEngine-Base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,sBAAs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,eAAe;IAClB,MAAM,EAAE,YAAY,CAAC;IACrB,WAAW,EAAE,QAAQ,CAAC;IAC7B;;OAEG;IACI,OAAO,EAAE,kBAAkB,EAAE,CAAC;IACrC;;OAEG;IACI,MAAM,EAAE,WAAW,EAAE,CAAC;CAC/B;AAGD;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,UAAU,CAAC,gBAAgB,CAAC;IAC/D,OAAO,CAAC,kBAAkB,CAAU;IAEpC;;OAEG;IACH,WAAkB,QAAQ,IAAI,gBAAgB,CAE7C;IAEA,OAAO,CAAC,QAAQ,CAAyB;IACzC,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,OAAO,CAAsB;IACrC,OAAO,CAAC,kBAAkB,CAA2B;IACrD,OAAO,CAAC,gBAAgB,CAAwB;IAEjD;;;;;OAKG;IACU,MAAM,CAAC,YAAY,GAAE,OAAe,EAAE,WAAW,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IA0BxF,IAAW,OAAO,IAAI,oBAAoB,EAAE,CAE3C;IACD,IAAW,YAAY,IAAI,iBAAiB,EAAE,CAE7C;IACD,IAAW,aAAa,IAAI,kBAAkB,EAAE,CAE/C;IACD,IAAW,iBAAiB,IAAI,sBAAsB,EAAE,CAEvD;IACD,IAAW,eAAe,IAAI,mBAAmB,EAAE,CAElD;IAED,IAAW,WAAW,IAAI,oBAAoB,EAAE,CAE/C;IACD,IAAW,cAAc,IAAI,oBAAoB,EAAE,CAElD;IAED,IAAW,gBAAgB,IAAI,MAAM,CAEpC;IAGF;;OAEG;cACa,cAAc,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC;CAG3E"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ActionEngineBase = exports.RunActionParams = exports.ActionParam = exports.ActionResult = exports.ActionResultSimple = exports.GeneratedCode = exports.ActionLibrary = void 0;
|
|
4
|
+
const core_1 = require("@memberjunction/core");
|
|
5
|
+
class ActionLibrary {
|
|
6
|
+
}
|
|
7
|
+
exports.ActionLibrary = ActionLibrary;
|
|
8
|
+
/**
|
|
9
|
+
* Class that is used for passing around generated code includes properties such as the code itself and a description of what the code does.
|
|
10
|
+
*/
|
|
11
|
+
class GeneratedCode {
|
|
12
|
+
}
|
|
13
|
+
exports.GeneratedCode = GeneratedCode;
|
|
14
|
+
/**
|
|
15
|
+
* Class that has the result of the individual action execution and used by the engine or other caller
|
|
16
|
+
*/
|
|
17
|
+
class ActionResultSimple {
|
|
18
|
+
}
|
|
19
|
+
exports.ActionResultSimple = ActionResultSimple;
|
|
20
|
+
/**
|
|
21
|
+
* Class that has the result of a complete action execution, returned by the Run method of the ActionEngine.
|
|
22
|
+
*/
|
|
23
|
+
class ActionResult {
|
|
24
|
+
}
|
|
25
|
+
exports.ActionResult = ActionResult;
|
|
26
|
+
/**
|
|
27
|
+
* Runtime parameter class that is used to pass key/value pairs in arrays to/from the action engine.
|
|
28
|
+
*/
|
|
29
|
+
class ActionParam {
|
|
30
|
+
}
|
|
31
|
+
exports.ActionParam = ActionParam;
|
|
32
|
+
/**
|
|
33
|
+
* Class that holds the parameters for an action to be run. This is passed to the Run method of an action.
|
|
34
|
+
*/
|
|
35
|
+
class RunActionParams {
|
|
36
|
+
}
|
|
37
|
+
exports.RunActionParams = RunActionParams;
|
|
38
|
+
/**
|
|
39
|
+
* Base class for Action metadata.
|
|
40
|
+
*/
|
|
41
|
+
class ActionEngineBase extends core_1.BaseEngine {
|
|
42
|
+
constructor() {
|
|
43
|
+
super(...arguments);
|
|
44
|
+
this.__coreCategoryName = '__mj';
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Returns the global instance of the class. This is a singleton class, so there is only one instance of it in the application. Do not directly create new instances of it, always use this method to get the instance.
|
|
48
|
+
*/
|
|
49
|
+
static get Instance() {
|
|
50
|
+
return super.getInstance("ActionEngineBase");
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* This method is called to configure the ActionEngine. It loads the metadata for the actions, filters, and result codes and caches them in the GlobalObjectStore. You must call this method before running any actions.
|
|
54
|
+
* If this method was previously run on the instance of the ActionEngine, it will return immediately without re-loading the metadata. If you want to force a reload of the metadata, you can pass true for the forceReload parameter.
|
|
55
|
+
* @param forceRefresh If true, the metadata will be loaded from the database even if it was previously loaded.
|
|
56
|
+
* @param contextUser If you are running the action on the server side you must pass this in, but it is not required in an environment where a user is authenticated directly, e.g. a browser or other client.
|
|
57
|
+
*/
|
|
58
|
+
async Config(forceRefresh = false, contextUser) {
|
|
59
|
+
const config = [
|
|
60
|
+
{
|
|
61
|
+
EntityName: 'Actions',
|
|
62
|
+
PropertyName: '_Actions'
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
EntityName: 'Action Filters',
|
|
66
|
+
PropertyName: '_Filters'
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
EntityName: 'Action Result Codes',
|
|
70
|
+
PropertyName: '_ActionResultCodes'
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
EntityName: 'Action Params',
|
|
74
|
+
PropertyName: '_Params'
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
EntityName: 'Action Libraries',
|
|
78
|
+
PropertyName: '_ActionLibraries'
|
|
79
|
+
}
|
|
80
|
+
];
|
|
81
|
+
await this.Load(config, forceRefresh, contextUser);
|
|
82
|
+
}
|
|
83
|
+
get Actions() {
|
|
84
|
+
return this._Actions;
|
|
85
|
+
}
|
|
86
|
+
get ActionParams() {
|
|
87
|
+
return this._Params;
|
|
88
|
+
}
|
|
89
|
+
get ActionFilters() {
|
|
90
|
+
return this._Filters;
|
|
91
|
+
}
|
|
92
|
+
get ActionResultCodes() {
|
|
93
|
+
return this._ActionResultCodes;
|
|
94
|
+
}
|
|
95
|
+
get ActionLibraries() {
|
|
96
|
+
return this._ActionLibraries;
|
|
97
|
+
}
|
|
98
|
+
get CoreActions() {
|
|
99
|
+
return this._Actions.filter((a) => a.IsCoreAction);
|
|
100
|
+
}
|
|
101
|
+
get NonCoreActions() {
|
|
102
|
+
return this._Actions.filter((a) => !a.IsCoreAction);
|
|
103
|
+
}
|
|
104
|
+
get CoreCategoryName() {
|
|
105
|
+
return this.__coreCategoryName;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* This method handles input validation. Subclasses can override this method to provide custom input validation.
|
|
109
|
+
*/
|
|
110
|
+
async ValidateInputs(params) {
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
exports.ActionEngineBase = ActionEngineBase;
|
|
115
|
+
//# sourceMappingURL=ActionEngine-Base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionEngine-Base.js","sourceRoot":"","sources":["../src/ActionEngine-Base.ts"],"names":[],"mappings":";;;AAAA,+CAA4D;AAK5D,MAAa,aAAa;CAGzB;AAHD,sCAGC;AAED;;GAEG;AACH,MAAa,aAAa;CAqBzB;AArBD,sCAqBC;AAED;;GAEG;AAEH,MAAa,kBAAkB;CAoB9B;AApBD,gDAoBC;AAED;;GAEG;AACH,MAAa,YAAY;CA8BxB;AA9BD,oCA8BC;AAED;;GAEG;AACH,MAAa,WAAW;CASvB;AATD,kCASC;AAED;;GAEG;AACH,MAAa,eAAe;CAW3B;AAXD,0CAWC;AAGD;;GAEG;AACH,MAAa,gBAAiB,SAAQ,iBAA4B;IAAlE;;QACW,uBAAkB,GAAG,MAAM,CAAC;IAiFvC,CAAC;IA/EE;;OAEG;IACI,MAAM,KAAK,QAAQ;QACvB,OAAO,KAAK,CAAC,WAAW,CAAmB,kBAAkB,CAAC,CAAC;IAClE,CAAC;IAQD;;;;;OAKG;IACI,KAAK,CAAC,MAAM,CAAC,eAAwB,KAAK,EAAE,WAAsB;QACtE,MAAM,MAAM,GAAG;YACZ;gBACM,UAAU,EAAE,SAAS;gBACrB,YAAY,EA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ryEntity, ActionParamEntity, ActionResultCodeEntity } from "@memberjunction/core-entities";
|
|
2
|
+
export declare class ActionEntityExtended extends ActionEntity {
|
|
3
|
+
/**
|
|
4
|
+
* Returns true if this action is a core MemberJunction framework action, false otherwise.
|
|
5
|
+
*/
|
|
6
|
+
get IsCoreAction(): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Generates a programatically friendly name for the name of the Action.
|
|
9
|
+
*/
|
|
10
|
+
get ProgrammaticName(): string;
|
|
11
|
+
private _resultCodes;
|
|
12
|
+
/**
|
|
13
|
+
* Provides a list of possible result codes for this action.
|
|
14
|
+
*/
|
|
15
|
+
get ResultCodes(): ActionResultCodeEntity[];
|
|
16
|
+
private _params;
|
|
17
|
+
get Params(): ActionParamEntity[];
|
|
18
|
+
private _libs;
|
|
19
|
+
get Libraries(): ActionLibraryEntity[];
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=ActionEntity-Extended.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionEntity-Extended.d.ts","sourceRoot":"","sources":["../src/ActionEntity-Extended.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAI7H,qBACa,oBAAqB,SAAQ,YAAY;IAClD;;OAEG;IACH,IAAW,YAAY,IAAI,OAAO,CAEjC;IAED;;OAEG;IACH,IAAW,gBAAgB,IAAI,MAAM,CAEpC;IAED,OAAO,CAAC,YAAY,CAAkC;IACtD;;OAEG;IACH,IAAW,WAAW,IAAI,sBAAsB,EAAE,CAMjD;IAED,OAAO,CAAC,OAAO,CAA6B;IAC5C,IAAW,MAAM,IAAI,iBAAiB,EAAE,CAMvC;IAED,OAAO,CAAC,KAAK,CAA+B;IAC5C,IAAW,SAAS,IAAI,mBAAmB,EAAE,CAM5C;CAGJ"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ActionEntityExtended = void 0;
|
|
10
|
+
const core_1 = require("@memberjunction/core");
|
|
11
|
+
const core_entities_1 = require("@memberjunction/core-entities");
|
|
12
|
+
const global_1 = require("@memberjunction/global");
|
|
13
|
+
const ActionEngine_Base_1 = require("./ActionEngine-Base");
|
|
14
|
+
let ActionEntityExtended = class ActionEntityExtended extends core_entities_1.ActionEntity {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
this._resultCodes = null;
|
|
18
|
+
this._params = null;
|
|
19
|
+
this._libs = null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Returns true if this action is a core MemberJunction framework action, false otherwise.
|
|
23
|
+
*/
|
|
24
|
+
get IsCoreAction() {
|
|
25
|
+
return this.Category?.trim().toLowerCase() === ActionEngine_Base_1.ActionEngineBase.Instance.CoreCategoryName.trim().toLowerCase();
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Generates a programatically friendly name for the name of the Action.
|
|
29
|
+
*/
|
|
30
|
+
get ProgrammaticName() {
|
|
31
|
+
return (0, core_1.CodeNameFromString)(this.Name);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Provides a list of possible result codes for this action.
|
|
35
|
+
*/
|
|
36
|
+
get ResultCodes() {
|
|
37
|
+
if (!this._resultCodes) {
|
|
38
|
+
// load the result codes
|
|
39
|
+
this._resultCodes = ActionEngine_Base_1.ActionEngineBase.Instance.ActionResultCodes.filter(c => c.ActionID === this.ID);
|
|
40
|
+
}
|
|
41
|
+
return this._resultCodes;
|
|
42
|
+
}
|
|
43
|
+
get Params() {
|
|
44
|
+
if (!this._params) {
|
|
45
|
+
// load the inputs
|
|
46
|
+
this._params = ActionEngine_Base_1.ActionEngineBase.Instance.ActionParams.filter(i => i.ActionID === this.ID);
|
|
47
|
+
}
|
|
48
|
+
return this._params;
|
|
49
|
+
}
|
|
50
|
+
get Libraries() {
|
|
51
|
+
if (!this._libs) {
|
|
52
|
+
// load the inputs
|
|
53
|
+
this._libs = ActionEngine_Base_1.ActionEngineBase.Instance.ActionLibraries.filter(l => l.ActionID === this.ID);
|
|
54
|
+
}
|
|
55
|
+
return this._libs;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
exports.ActionEntityExtended = ActionEntityExtended;
|
|
59
|
+
exports.ActionEntityExtended = ActionEntityExtended = __decorate([
|
|
60
|
+
(0, global_1.RegisterClass)(core_1.BaseEntity, 'Actions') // high priority make sure this class is used ahead of other things
|
|
61
|
+
], ActionEntityExtended);
|
|
62
|
+
//# sourceMappingURL=ActionEntity-Extended.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionEntity-Extended.js","sourceRoot":"","sources":["../src/ActionEntity-Extended.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+CAAsE;AACtE,iEAA6H;AAC7H,mDAAuD;AACvD,2DAAuD;AAGhD,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,4BAAY;IAA/C;;QAeK,iBAAY,GAA6B,IAAI,CAAC;QAY9C,YAAO,GAAwB,IAAI,CAAC;QASpC,UAAK,GAA0B,IAAI,CAAC;IAUhD,CAAC;IA7CG;;OAEG;IACH,IAAW,YAAY;QACnB,OAAO,IAAI,CAAC,QAAQ,EAAE,IAAI,EA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AAC,CAAC,mEAAmE;GAC5F,oBAAoB,CA8ChC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { BaseEngine, BaseEntity, UserInfo } from "@memberjunction/core";
|
|
2
|
+
import { ActionExecutionLogEntity, ActionResultCodeEntity, EntityActionFilterEntity, EntityActionInvocationEntity, EntityActionInvocationTypeEntity, EntityActionParamEntity } from "@memberjunction/core-entities";
|
|
3
|
+
import { ActionParam, RunActionParams } from "./ActionEngine-Base";
|
|
4
|
+
import { EntityActionEntityExtended } from "./EntityActionEntity-Extended";
|
|
5
|
+
/**
|
|
6
|
+
* Parameters type for invoking an entity action
|
|
7
|
+
*/
|
|
8
|
+
export declare class EntityActionInvocationParams {
|
|
9
|
+
/**
|
|
10
|
+
* The entity action to be invoked
|
|
11
|
+
*/
|
|
12
|
+
EntityAction: EntityActionEntityExtended;
|
|
13
|
+
/**
|
|
14
|
+
* The type of entity/action invocation to be performed
|
|
15
|
+
*/
|
|
16
|
+
InvocationType: EntityActionInvocationTypeEntity;
|
|
17
|
+
/**
|
|
18
|
+
* The user context for the invocation.
|
|
19
|
+
*/
|
|
20
|
+
ContextUser?: UserInfo;
|
|
21
|
+
/**
|
|
22
|
+
* If the invocation type is single record oriented, this parameter will be needed
|
|
23
|
+
*/
|
|
24
|
+
EntityObject?: BaseEntity;
|
|
25
|
+
/**
|
|
26
|
+
* If the invocation type is view-oriented, this parameter will be needed
|
|
27
|
+
*/
|
|
28
|
+
ViewID?: string;
|
|
29
|
+
/**
|
|
30
|
+
* If the invocation type is list-oriented, this parameter will be needed
|
|
31
|
+
*/
|
|
32
|
+
ListID?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Class that has the result of a complete action execution, returned by the Run method of the ActionEngine.
|
|
36
|
+
*/
|
|
37
|
+
export declare class EntityActionResult {
|
|
38
|
+
/**
|
|
39
|
+
* Contains the parameters that were used to run the action as a convenience.
|
|
40
|
+
*/
|
|
41
|
+
RunParams: RunActionParams;
|
|
42
|
+
/**
|
|
43
|
+
* Indicates if the action was successful or not.
|
|
44
|
+
*/
|
|
45
|
+
Success: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* A code that indicates the outcome of the action. Will be one of the possible ResultCodes enumerated in the ActionResultCodeEntity
|
|
48
|
+
*/
|
|
49
|
+
Result?: ActionResultCodeEntity;
|
|
50
|
+
/**
|
|
51
|
+
* Whenever an action is executed a log entry is created. This log entry is stored in the database and can be used to track the execution of the action. This property contains the log entry object for the action that was run.
|
|
52
|
+
*/
|
|
53
|
+
LogEntry: ActionExecutionLogEntity;
|
|
54
|
+
/**
|
|
55
|
+
* Optional, a message an action can include that describes the outcome of the action. This is typically used to display a message to the user.
|
|
56
|
+
*/
|
|
57
|
+
Message?: string;
|
|
58
|
+
/**
|
|
59
|
+
* All parameters including inputs and outputs are provided here for convenience
|
|
60
|
+
*/
|
|
61
|
+
Params?: ActionParam[];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The purpose of this class is to handle the invocation of actions for entities in all of the supported invocation contexts.
|
|
65
|
+
*/
|
|
66
|
+
export declare class EntityActionEngineBase extends BaseEngine<EntityActionEngineBase> {
|
|
67
|
+
static get Instance(): EntityActionEngineBase;
|
|
68
|
+
private _EntityActions;
|
|
69
|
+
private _EntityActionParams;
|
|
70
|
+
private _EntityActionInvocationTypes;
|
|
71
|
+
private _EntityActionFilters;
|
|
72
|
+
private _EntityActionInvocations;
|
|
73
|
+
/**
|
|
74
|
+
* This method is called to configure the ActionEngine. It loads the metadata for the actions, filters, and result codes and caches them in the GlobalObjectStore. You must call this method before running any actions.
|
|
75
|
+
* If this method was previously run on the instance of the ActionEngine, it will return immediately without re-loading the metadata. If you want to force a reload of the metadata, you can pass true for the forceReload parameter.
|
|
76
|
+
* @param forceRefresh If true, the metadata will be loaded from the database even if it was previously loaded.
|
|
77
|
+
* @param contextUser If you are running the action on the server side you must pass this in, but it is not required in an environment where a user is authenticated directly, e.g. a browser or other client.
|
|
78
|
+
*/
|
|
79
|
+
Config(forceRefresh?: boolean, contextUser?: UserInfo): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* List of all the EntityActionInvocationTypeEntity objects that are available for use in the system. Make sure you call Config() before any other methods on this class.
|
|
82
|
+
*/
|
|
83
|
+
get InvocationTypes(): EntityActionInvocationTypeEntity[];
|
|
84
|
+
/**
|
|
85
|
+
* List of all the EntityActionFilterEntity objects that are available for use in the system. Make sure you call Config() before any other methods on this class.
|
|
86
|
+
*/
|
|
87
|
+
get Filters(): EntityActionFilterEntity[];
|
|
88
|
+
/**
|
|
89
|
+
* List of all the EntityActionInvocationEntity objects that are available for use in the system. Make sure you call Config() before any other methods on this class.
|
|
90
|
+
*/
|
|
91
|
+
get Invocations(): EntityActionInvocationEntity[];
|
|
92
|
+
/**
|
|
93
|
+
* List of all the Entity Action objects that are available for use in the system. Make sure you call Config() before any other methods on this class.
|
|
94
|
+
*/
|
|
95
|
+
get EntityActions(): EntityActionEntityExtended[];
|
|
96
|
+
/**
|
|
97
|
+
* List of all of the Entity Action Params that are available for use in the system. Make sure you call Config() before any other methods on this class.
|
|
98
|
+
*/
|
|
99
|
+
get Params(): EntityActionParamEntity[];
|
|
100
|
+
/**
|
|
101
|
+
* Helper method to get the EntityActionEntityExtended object for a given entity name
|
|
102
|
+
* @param entityName
|
|
103
|
+
* @param status Optional, if provided will filter the results based on the status
|
|
104
|
+
* @returns
|
|
105
|
+
*/
|
|
106
|
+
GetActionsByEntityName(entityName: string, status?: 'Active' | 'Pending' | 'Disabled'): EntityActionEntityExtended[];
|
|
107
|
+
/**
|
|
108
|
+
* Helper method to get the EntityActionEntityExtended object for a given entity ID
|
|
109
|
+
* @param entityID
|
|
110
|
+
* @returns
|
|
111
|
+
*/
|
|
112
|
+
GetActionsByEntityID(entityID: string): EntityActionEntityExtended[];
|
|
113
|
+
/**
|
|
114
|
+
* Helper method to get the EntityActionEntityExtended object for a given entity name and invocation type
|
|
115
|
+
* @param entityName
|
|
116
|
+
* @param invocationType
|
|
117
|
+
* @param status Optional, if provided will filter the results based on the status
|
|
118
|
+
* @returns
|
|
119
|
+
*/
|
|
120
|
+
GetActionsByEntityNameAndInvocationType(entityName: string, invocationType: string, status?: 'Active' | 'Pending' | 'Disabled'): EntityActionEntityExtended[];
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=EntityActionEngine-Base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EntityActionEngine-Base.d.ts","sourceRoot":"","sources":["../src/EntityActionEngine-Base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA4B,UAAU,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAClG,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,4BAA4B,EAAE,gCAAgC,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACpN,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAE3E;;GAEG;AACH,qBAAa,4BAA4B;IACrC;;OAEG;IACI,YAAY,EAAE,0BAA0B,CAAC;IAEhD;;OAEG;IACI,cAAc,EAAE,gCAAgC,CAAC;IAExD;;OAEG;IACI,WAAW,CAAC,EAAE,QAAQ,CAAC;IAE9B;;OAEG;IACI,YAAY,CAAC,EAAE,UAAU,CAAC;IACjC;;OAEG;IACI,MAAM,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACI,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAID;;GAEG;AACH,qBAAa,kBAAkB;IAC3B;;OAEG;IACI,SAAS,EAAE,eAAe,CAAC;IAElC;;OAEG;IACI,OAAO,EAAE,OAAO,CAAC;IAExB;;OAEG;IACI,MAAM,CAAC,EAAE,sBAAsB,CAAC;IAEvC;;OAEG;IACI,QAAQ,EAAE,wBAAwB,CAAC;IAE1C;;OAEG;IAC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
|
3
|
+
exports.EntityActionEngineBase = exports.EntityActionResult = exports.EntityActionInvocationParams = void 0;
|
|
4
|
+
const core_1 = require("@memberjunction/core");
|
|
5
|
+
/**
|
|
6
|
+
* Parameters type for invoking an entity action
|
|
7
|
+
*/
|
|
8
|
+
class EntityActionInvocationParams {
|
|
9
|
+
}
|
|
10
|
+
exports.EntityActionInvocationParams = EntityActionInvocationParams;
|
|
11
|
+
/**
|
|
12
|
+
* Class that has the result of a complete action execution, returned by the Run method of the ActionEngine.
|
|
13
|
+
*/
|
|
14
|
+
class EntityActionResult {
|
|
15
|
+
}
|
|
16
|
+
exports.EntityActionResult = EntityActionResult;
|
|
17
|
+
/**
|
|
18
|
+
* The purpose of this class is to handle the invocation of actions for entities in all of the supported invocation contexts.
|
|
19
|
+
*/
|
|
20
|
+
class EntityActionEngineBase extends core_1.BaseEngine {
|
|
21
|
+
constructor() {
|
|
22
|
+
super(...arguments);
|
|
23
|
+
// internal instance properties used for the singleton pattern
|
|
24
|
+
this._EntityActions = [];
|
|
25
|
+
this._EntityActionParams = [];
|
|
26
|
+
this._EntityActionInvocationTypes = [];
|
|
27
|
+
this._EntityActionFilters = [];
|
|
28
|
+
this._EntityActionInvocations = [];
|
|
29
|
+
}
|
|
30
|
+
static get Instance() {
|
|
31
|
+
return super.getInstance("EntityActionEngineBase");
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* This method is called to configure the ActionEngine. It loads the metadata for the actions, filters, and result codes and caches them in the GlobalObjectStore. You must call this method before running any actions.
|
|
35
|
+
* If this method was previously run on the instance of the ActionEngine, it will return immediately without re-loading the metadata. If you want to force a reload of the metadata, you can pass true for the forceReload parameter.
|
|
36
|
+
* @param forceRefresh If true, the metadata will be loaded from the database even if it was previously loaded.
|
|
37
|
+
* @param contextUser If you are running the action on the server side you must pass this in, but it is not required in an environment where a user is authenticated directly, e.g. a browser or other client.
|
|
38
|
+
*/
|
|
39
|
+
async Config(forceRefresh = false, contextUser) {
|
|
40
|
+
const configs = [
|
|
41
|
+
{
|
|
42
|
+
EntityName: 'Entity Action Invocation Types',
|
|
43
|
+
PropertyName: '_EntityActionInvocationTypes'
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
EntityName: 'Entity Action Filters',
|
|
47
|
+
PropertyName: '_EntityActionFilters'
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
EntityName: 'Entity Action Invocations',
|
|
51
|
+
PropertyName: '_EntityActionInvocations'
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
EntityName: 'Entity Actions', // sub-class for this will handle dynamic loading of filters, invocations, and params when needed by callers of those read-only properties
|
|
55
|
+
PropertyName: '_EntityActions'
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
EntityName: 'Entity Action Params',
|
|
59
|
+
PropertyName: '_EntityActionParams'
|
|
60
|
+
}
|
|
61
|
+
];
|
|
62
|
+
await this.Load(configs, forceRefresh, contextUser);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* List of all the EntityActionInvocationTypeEntity objects that are available for use in the system. Make sure you call Config() before any other methods on this class.
|
|
66
|
+
*/
|
|
67
|
+
get InvocationTypes() {
|
|
68
|
+
return this._EntityActionInvocationTypes;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* List of all the EntityActionFilterEntity objects that are available for use in the system. Make sure you call Config() before any other methods on this class.
|
|
72
|
+
*/
|
|
73
|
+
get Filters() {
|
|
74
|
+
return this._EntityActionFilters;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* List of all the EntityActionInvocationEntity objects that are available for use in the system. Make sure you call Config() before any other methods on this class.
|
|
78
|
+
*/
|
|
79
|
+
get Invocations() {
|
|
80
|
+
return this._EntityActionInvocations;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* List of all the Entity Action objects that are available for use in the system. Make sure you call Config() before any other methods on this class.
|
|
84
|
+
*/
|
|
85
|
+
get EntityActions() {
|
|
86
|
+
return this._EntityActions;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* List of all of the Entity Action Params that are available for use in the system. Make sure you call Config() before any other methods on this class.
|
|
90
|
+
*/
|
|
91
|
+
get Params() {
|
|
92
|
+
return this._EntityActionParams;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Helper method to get the EntityActionEntityExtended object for a given entity name
|
|
96
|
+
* @param entityName
|
|
97
|
+
* @param status Optional, if provided will filter the results based on the status
|
|
98
|
+
* @returns
|
|
99
|
+
*/
|
|
100
|
+
GetActionsByEntityName(entityName, status) {
|
|
101
|
+
return this._EntityActions.filter(e => (!status || e.Status === status) && e.Entity.trim().toLowerCase() === entityName.trim().toLowerCase());
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Helper method to get the EntityActionEntityExtended object for a given entity ID
|
|
105
|
+
* @param entityID
|
|
106
|
+
* @returns
|
|
107
|
+
*/
|
|
108
|
+
GetActionsByEntityID(entityID) {
|
|
109
|
+
return this._EntityActions.filter(e => e.EntityID === entityID);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Helper method to get the EntityActionEntityExtended object for a given entity name and invocation type
|
|
113
|
+
* @param entityName
|
|
114
|
+
* @param invocationType
|
|
115
|
+
* @param status Optional, if provided will filter the results based on the status
|
|
116
|
+
* @returns
|
|
117
|
+
*/
|
|
118
|
+
GetActionsByEntityNameAndInvocationType(entityName, invocationType, status) {
|
|
119
|
+
const entityActions = this.GetActionsByEntityName(entityName, status);
|
|
120
|
+
// now extract the ones that have the right invocation type
|
|
121
|
+
return entityActions.filter(e => {
|
|
122
|
+
const invocations = e.Invocations.find(i => (!status || i.Status === status) && i.InvocationType.trim().toLowerCase() === invocationType.trim().toLowerCase());
|
|
123
|
+
return invocations ? true : false;
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.EntityActionEngineBase = EntityActionEngineBase;
|
|
128
|
+
//# sourceMappingURL=EntityActionEngine-Base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EntityActionEngine-Base.js","sourceRoot":"","sources":["../src/EntityActionEngine-Base.ts"],"names":[],"mappings":";;;AAAA,+CAAkG;AAKlG;;GAEG;AACH,MAAa,4BAA4B;CA4BxC;AA5BD,oEA4BC;AAID;;GAEG;AACH,MAAa,kBAAkB;CA8B7B;AA9BF,gDA8BE;AAEF;;GAEG;AACH,MAAa,sBAAuB,SAAQ,iBAAkC;IAA9E;;QAMI,8DAA8D;QACtD,mBAAc,GAAiC,EAAE,CAAC;QAClD,wBAAmB,GAA8B,EAAE,CAAC;QACpD,iCAA4B,GAAuC,EAAE,CAAC;QACtE,yBAAoB,GAA+B,EAAE,CAAC;QACtD,6BAAwB,GAAmC,EAAE,CAAC;IAwG1E,CAAC;IAlHU,MAAM,KAAK,QAAQ;QACtB,OAAO,KAAK,CAAC,WAAW,CAAyB,wBAAwB,CAAC,CAAC;IAC/E,CAAC;IAUD;;;;;OAKG;IACI,KAAK,CAAC,MAAM,CAAC,eAAwB,KAAK,EAAE,WAAsB;QACrE,MAAM,OAAO,GAAwC;YACjD;gBACI,UAAU,EAAE,gCAAgC;gBAC5C,YAAY,EAAE,8BAA8B;aAC/C;YACD;gBACI,UAAU,EAAE,uBAAuB;gBACnC,YAAY,EAAE,sBAAsB;aACvC;YACD;gBACI,UAAU,EAAE,2BAA2B;gBACvC,YAAY,EAAE,0BAA0B;aAC3C;YACD;gBACI,UAAU,EAAE,gBAAgB,EAAE,0IAA0I;gBACxK,YAAY,EAAE,gBAAgB;aACjC;YACD;gBACI,UAAU,EAAE,sBAAsB;gBAClC,YAAY,EAAE,qBAAqB;aACtC;SACJ,CAAC;QACF,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC;IACxD,CAAC;IAGD;;OAEG;IACH,IAAW,eAAe;QACtB,OAAO,IAAI,CAAC,4BAA4B,CAAC;IAC7C,CAAC;IA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K,cAAc,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAA;YAC9J,OAAO,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;QACtC,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAnHD,wDAmHC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { UserInfo } from "@memberjunction/core";
|
|
2
|
+
import { EntityActionEntity, EntityActionFilterEntity, EntityActionInvocationEntity, EntityActionParamEntity } from "@memberjunction/core-entities";
|
|
3
|
+
export declare class EntityActionEntityExtended extends EntityActionEntity {
|
|
4
|
+
private _filters;
|
|
5
|
+
private _invocations;
|
|
6
|
+
private _params;
|
|
7
|
+
/**
|
|
8
|
+
* Get the filters for this entity action
|
|
9
|
+
*/
|
|
10
|
+
get Filters(): EntityActionFilterEntity[];
|
|
11
|
+
/**
|
|
12
|
+
* Get the invocations for this entity action
|
|
13
|
+
*/
|
|
14
|
+
get Invocations(): EntityActionInvocationEntity[];
|
|
15
|
+
get Params(): EntityActionParamEntity[];
|
|
16
|
+
/**
|
|
17
|
+
* Override the base class Config in order to ensure that EntityActionEngine is configured
|
|
18
|
+
* @param contextUser
|
|
19
|
+
*/
|
|
20
|
+
Config(contextUser: UserInfo): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=EntityActionEntity-Extended.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EntityActionEntity-Extended.d.ts","sourceRoot":"","sources":["../src/EntityActionEntity-Extended.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,4BAA4B,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAIpJ,qBACa,0BAA2B,SAAQ,kBAAkB;IAC9D,OAAO,CAAC,QAAQ,CAAoC;IACpD,OAAO,CAAC,YAAY,CAAwC;IAC5D,OAAO,CAAC,OAAO,CAAmC;IAElD;;OAEG;IACH,IAAW,OAAO,IAAI,wBAAwB,EAAE,CAM/C;IAED;;OAEG;IACH,IAAW,WAAW,IAAI,4BAA4B,EAAE,CAMvD;IAED,IAAW,MAAM,IAAI,uBAAuB,EAAE,CAM7C;IAGD;;;OAGG;IACmB,MAAM,CAAC,WAAW,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAKrE"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.EntityActionEntityExtended = void 0;
|
|
10
|
+
const core_1 = require("@memberjunction/core");
|
|
11
|
+
const core_entities_1 = require("@memberjunction/core-entities");
|
|
12
|
+
const global_1 = require("@memberjunction/global");
|
|
13
|
+
const EntityActionEngine_Base_1 = require("./EntityActionEngine-Base");
|
|
14
|
+
let EntityActionEntityExtended = class EntityActionEntityExtended extends core_entities_1.EntityActionEntity {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
this._filters = null;
|
|
18
|
+
this._invocations = null;
|
|
19
|
+
this._params = null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get the filters for this entity action
|
|
23
|
+
*/
|
|
24
|
+
get Filters() {
|
|
25
|
+
if (!this._filters) {
|
|
26
|
+
// don't have the data loaded yet so get it from the EntityActionEngine
|
|
27
|
+
this._filters = EntityActionEngine_Base_1.EntityActionEngineBase.Instance.Filters?.filter(f => f.EntityActionID === this.ID) ?? [];
|
|
28
|
+
}
|
|
29
|
+
return this._filters;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Get the invocations for this entity action
|
|
33
|
+
*/
|
|
34
|
+
get Invocations() {
|
|
35
|
+
if (!this._invocations) {
|
|
36
|
+
// load the data from the EntityActionEngine
|
|
37
|
+
this._invocations = EntityActionEngine_Base_1.EntityActionEngineBase.Instance.Invocations?.filter(i => i.EntityActionID === this.ID) ?? [];
|
|
38
|
+
}
|
|
39
|
+
return this._invocations;
|
|
40
|
+
}
|
|
41
|
+
get Params() {
|
|
42
|
+
if (!this._params) {
|
|
43
|
+
// load the data from the EntityActionEngine
|
|
44
|
+
this._params = EntityActionEngine_Base_1.EntityActionEngineBase.Instance.Params?.filter(p => p.EntityActionID === this.ID) ?? [];
|
|
45
|
+
}
|
|
46
|
+
return this._params;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Override the base class Config in order to ensure that EntityActionEngine is configured
|
|
50
|
+
* @param contextUser
|
|
51
|
+
*/
|
|
52
|
+
async Config(contextUser) {
|
|
53
|
+
super.Config(contextUser);
|
|
54
|
+
EntityActionEngine_Base_1.EntityActionEngineBase.Instance.Config(false, contextUser); // do this withOUT an await because that will cause an deadlock due to circular situation, sometimes the EntityActinEngine.Config() is called by someone else first
|
|
55
|
+
// harmless to call it again here because it will not do anything extra if already in progress or done.
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
exports.EntityActionEntityExtended = EntityActionEntityExtended;
|
|
59
|
+
exports.EntityActionEntityExtended = EntityActionEntityExtended = __decorate([
|
|
60
|
+
(0, global_1.RegisterClass)(core_1.BaseEntity, 'Entity Actions')
|
|
61
|
+
], EntityActionEntityExtended);
|
|
62
|
+
//# sourceMappingURL=EntityActionEntity-Extended.js.map
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AAI,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;QAC3G,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAGD;;;OAGG;IACa,KAAK,CAAC,MAAM,CAAC,WAAqB;QAC9C,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAC1B,gDAAsB,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,mKAAmK;QACvK,uGAAuG;IACnK,CAAC;CACJ,CAAA;AA7CY,gEAA0B;qCAA1B,0BAA0B;IADtC,IAAA,sBAAa,EAAC,iBAAU,EAAE,gBAAgB,CAAC;GAC/B,0BAA0B,CA6CtC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AAExC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ActionEngine-Base"), exports);
|
|
18
|
+
__exportStar(require("./ActionEntity-Extended"), exports);
|
|
19
|
+
__exportStar(require("./EntityActionEngine-Base"), exports);
|
|
20
|
+
__exportStar(require("./EntityActionEntity-Extended"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,0DAAwC;AAExC,4DAA0C;AAC1C,gEAA8C"}
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@memberjunction/actions-base",
|
|
3
|
+
"version": "2.12.0",
|
|
4
|
+
"description": "Base Classes for MemberJunction Actions. This library is used on both server and network nodes.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"/dist"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"start": "ts-node-dev src/index.ts",
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
14
|
+
},
|
|
15
|
+
"author": "MemberJunction.com",
|
|
16
|
+
"license": "ISC",
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"ts-node-dev": "^2.0.0",
|
|
19
|
+
"typescript": "^5.4.5"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@memberjunction/global": "2.12.0",
|
|
23
|
+
"@memberjunction/core": "2.12.0",
|
|
24
|
+
"@memberjunction/core-entities": "2.12.0"
|
|
25
|
+
}
|
|
26
|
+
}
|