@memberjunction/actions 1.4.1

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 (38) hide show
  1. package/dist/entity-actions/EntityActionEngine.d.ts +93 -0
  2. package/dist/entity-actions/EntityActionEngine.d.ts.map +1 -0
  3. package/dist/entity-actions/EntityActionEngine.js +134 -0
  4. package/dist/entity-actions/EntityActionEngine.js.map +1 -0
  5. package/dist/entity-actions/EntityActionEntity.server.d.ts +20 -0
  6. package/dist/entity-actions/EntityActionEntity.server.d.ts.map +1 -0
  7. package/dist/entity-actions/EntityActionEntity.server.js +54 -0
  8. package/dist/entity-actions/EntityActionEntity.server.js.map +1 -0
  9. package/dist/entity-actions/EntityActionInvocationTypes.d.ts +29 -0
  10. package/dist/entity-actions/EntityActionInvocationTypes.d.ts.map +1 -0
  11. package/dist/entity-actions/EntityActionInvocationTypes.js +108 -0
  12. package/dist/entity-actions/EntityActionInvocationTypes.js.map +1 -0
  13. package/dist/generic/ActionEngine.d.ts +161 -0
  14. package/dist/generic/ActionEngine.d.ts.map +1 -0
  15. package/dist/generic/ActionEngine.js +218 -0
  16. package/dist/generic/ActionEngine.js.map +1 -0
  17. package/dist/generic/ActionEntity.server.d.ts +50 -0
  18. package/dist/generic/ActionEntity.server.d.ts.map +1 -0
  19. package/dist/generic/ActionEntity.server.js +395 -0
  20. package/dist/generic/ActionEntity.server.js.map +1 -0
  21. package/dist/generic/BaseAction.d.ts +9 -0
  22. package/dist/generic/BaseAction.d.ts.map +1 -0
  23. package/dist/generic/BaseAction.js +13 -0
  24. package/dist/generic/BaseAction.js.map +1 -0
  25. package/dist/generic/BaseActionFilter.d.ts +20 -0
  26. package/dist/generic/BaseActionFilter.d.ts.map +1 -0
  27. package/dist/generic/BaseActionFilter.js +21 -0
  28. package/dist/generic/BaseActionFilter.js.map +1 -0
  29. package/dist/generic/test.d.ts +1 -0
  30. package/dist/generic/test.d.ts.map +1 -0
  31. package/dist/generic/test.js +73 -0
  32. package/dist/generic/test.js.map +1 -0
  33. package/dist/index.d.ts +8 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +24 -0
  36. package/dist/index.js.map +1 -0
  37. package/package.json +29 -0
  38. package/readme.md +6 -0
@@ -0,0 +1,93 @@
1
+ import { BaseEngine, BaseEntity, UserInfo } from "@memberjunction/core";
2
+ import { EntityActionFilterEntity, EntityActionInvocationEntity, EntityActionInvocationTypeEntity } from "@memberjunction/core-entities";
3
+ import { EntityActionEntityServer } from "./EntityActionEntity.server";
4
+ import { ActionResult } from "../generic/ActionEngine";
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: EntityActionEntityServer;
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?: number;
29
+ /**
30
+ * If the invocation type is list-oriented, this parameter will be needed
31
+ */
32
+ ListID?: number;
33
+ }
34
+ /**
35
+ * The purpose of this class is to handle the invocation of actions for entities in all of the supported invocation contexts.
36
+ */
37
+ export declare class EntityActionEngine extends BaseEngine<EntityActionEngine> {
38
+ private constructor();
39
+ static get Instance(): EntityActionEngine;
40
+ private _EntityActions;
41
+ private _EntityActionInvocationTypes;
42
+ private _EntityActionFilters;
43
+ private _EntityActionInvocations;
44
+ /**
45
+ * 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.
46
+ * 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.
47
+ * @param forceRefresh If true, the metadata will be loaded from the database even if it was previously loaded.
48
+ * @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.
49
+ */
50
+ Config(forceRefresh?: boolean, contextUser?: UserInfo): Promise<void>;
51
+ /**
52
+ * 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.
53
+ */
54
+ get InvocationTypes(): EntityActionInvocationTypeEntity[];
55
+ /**
56
+ * 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.
57
+ */
58
+ get Filters(): EntityActionFilterEntity[];
59
+ /**
60
+ * 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.
61
+ */
62
+ get Invocations(): EntityActionInvocationEntity[];
63
+ /**
64
+ * 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.
65
+ */
66
+ get EntityActions(): EntityActionEntityServer[];
67
+ /**
68
+ * Helper method to get the EntityActionEntityServer object for a given entity name
69
+ * @param entityName
70
+ * @returns
71
+ */
72
+ GetActionsByEntityName(entityName: string): EntityActionEntityServer[];
73
+ /**
74
+ * Helper method to get the EntityActionEntityServer object for a given entity ID
75
+ * @param entityID
76
+ * @returns
77
+ */
78
+ GetActionsByEntityID(entityID: number): EntityActionEntityServer[];
79
+ /**
80
+ * Helper method to get the EntityActionEntityServer object for a given entity name and invocation type
81
+ * @param entityName
82
+ * @param invocationType
83
+ * @returns
84
+ */
85
+ GetActionsByEntityNameAndInvocationType(entityName: string, invocationType: string): EntityActionEntityServer[];
86
+ /**
87
+ * Method will invoke an action given the provided parameters. The method will return true if the action was successfully invoked, false otherwise.
88
+ * @param params Parameters for the action invocation
89
+ * @returns
90
+ */
91
+ RunEntityAction(params: EntityActionInvocationParams): Promise<ActionResult>;
92
+ }
93
+ //# sourceMappingURL=EntityActionEngine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EntityActionEngine.d.ts","s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,EAAE,CAErD;IAED;;;;OAIG;IACI,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,wBAAwB,EAAE;IAI7E;;;;OAIG;IACI,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,wBAAwB,EAAE;IAIzE;;;;;OAKG;IACI,uCAAuC,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,wBAAwB,EAAE;IAStH;;;;OAIG;IACU,eAAe,CAAC,MAAM,EAAE,4BAA4B,GAAG,OAAO,CAAC,YAAY,CAAC;CAsB5F"}
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EntityActionEngine = exports.EntityActionInvocationParams = void 0;
4
+ const core_1 = require("@memberjunction/core");
5
+ const global_1 = require("@memberjunction/global");
6
+ const EntityActionInvocationTypes_1 = require("./EntityActionInvocationTypes");
7
+ /**
8
+ * Parameters type for invoking an entity action
9
+ */
10
+ class EntityActionInvocationParams {
11
+ }
12
+ exports.EntityActionInvocationParams = EntityActionInvocationParams;
13
+ /**
14
+ * The purpose of this class is to handle the invocation of actions for entities in all of the supported invocation contexts.
15
+ */
16
+ class EntityActionEngine extends core_1.BaseEngine {
17
+ constructor() {
18
+ super('MJ_EntityAction_Metadata');
19
+ // internal instance properties used for the singleton pattern
20
+ this._EntityActions = [];
21
+ this._EntityActionInvocationTypes = [];
22
+ this._EntityActionFilters = [];
23
+ this._EntityActionInvocations = [];
24
+ }
25
+ static get Instance() {
26
+ return super.getInstance('MJ_EntityAction_Metadata');
27
+ }
28
+ /**
29
+ * 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.
30
+ * 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.
31
+ * @param forceRefresh If true, the metadata will be loaded from the database even if it was previously loaded.
32
+ * @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.
33
+ */
34
+ async Config(forceRefresh = false, contextUser) {
35
+ const configs = [
36
+ {
37
+ EntityName: 'Entity Action Invocation Types',
38
+ PropertyName: '_EntityActionInvocationTypes'
39
+ },
40
+ {
41
+ EntityName: 'Entity Action Filters',
42
+ PropertyName: '_EntityActionFilters'
43
+ },
44
+ {
45
+ EntityName: 'Entity Action Invocations',
46
+ PropertyName: '_EntityActionInvocations'
47
+ },
48
+ {
49
+ EntityName: 'Entity Actions',
50
+ PropertyName: '_EntityActions'
51
+ }
52
+ ];
53
+ await this.Load(configs, forceRefresh, contextUser);
54
+ }
55
+ /**
56
+ * 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.
57
+ */
58
+ get InvocationTypes() {
59
+ return this._EntityActionInvocationTypes;
60
+ }
61
+ /**
62
+ * 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.
63
+ */
64
+ get Filters() {
65
+ return this._EntityActionFilters;
66
+ }
67
+ /**
68
+ * 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.
69
+ */
70
+ get Invocations() {
71
+ return this._EntityActionInvocations;
72
+ }
73
+ /**
74
+ * 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.
75
+ */
76
+ get EntityActions() {
77
+ return this._EntityActions;
78
+ }
79
+ /**
80
+ * Helper method to get the EntityActionEntityServer object for a given entity name
81
+ * @param entityName
82
+ * @returns
83
+ */
84
+ GetActionsByEntityName(entityName) {
85
+ return this._EntityActions.filter(e => e.Entity.trim().toLowerCase() === entityName.trim().toLowerCase());
86
+ }
87
+ /**
88
+ * Helper method to get the EntityActionEntityServer object for a given entity ID
89
+ * @param entityID
90
+ * @returns
91
+ */
92
+ GetActionsByEntityID(entityID) {
93
+ return this._EntityActions.filter(e => e.EntityID === entityID);
94
+ }
95
+ /**
96
+ * Helper method to get the EntityActionEntityServer object for a given entity name and invocation type
97
+ * @param entityName
98
+ * @param invocationType
99
+ * @returns
100
+ */
101
+ GetActionsByEntityNameAndInvocationType(entityName, invocationType) {
102
+ const entityActions = this.GetActionsByEntityName(entityName);
103
+ // now extract the ones that have the right invocation type
104
+ return entityActions.filter(e => {
105
+ const invocations = e.Invocations.find(i => i.InvocationType.trim().toLowerCase() === invocationType.trim().toLowerCase());
106
+ return invocations ? true : false;
107
+ });
108
+ }
109
+ /**
110
+ * Method will invoke an action given the provided parameters. The method will return true if the action was successfully invoked, false otherwise.
111
+ * @param params Parameters for the action invocation
112
+ * @returns
113
+ */
114
+ async RunEntityAction(params) {
115
+ /*
116
+ Logic for invoking an Entity Action:
117
+ 1) Validate the params, making sure that we have the right stuff
118
+ 2) Switch based on the invocation type to execute the right logic
119
+ */
120
+ if (!params.EntityAction)
121
+ throw new Error('EntityAction is required for invocation');
122
+ // now get the right object based on the invocation type
123
+ if (!params.InvocationType)
124
+ throw new Error('Invalid invocation type provided');
125
+ // now we have the invocation type, use the name as the key for ClassFactory create instance to get what we need
126
+ const invocationInstance = global_1.MJGlobal.Instance.ClassFactory.CreateInstance(EntityActionInvocationTypes_1.EntityActionInvocationBase, params.InvocationType.Name);
127
+ if (!invocationInstance)
128
+ throw new Error('Error creating instance of invocation type');
129
+ // now we have the instance, invoke the action
130
+ return invocationInstance.InvokeAction(params);
131
+ }
132
+ }
133
+ exports.EntityActionEngine = EntityActionEngine;
134
+ //# sourceMappingURL=EntityActionEngine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EntityActionEngine.js","sourceRoot":"","sources":["../../src/entity-actions/EntityActionEngine.ts"],"names":[],"mappings":";;;AAAA,+CAAkG;AAElG,mDAAkD;AAElD,+EAA2E;AAG3E;;GAEG;AACH,MAAa,4BAA4B;CA4BxC;AA5BD,oEA4BC;AAGD;;GAEG;AACH,MAAa,kBAAmB,SAAQ,iBAA8B;IAClE;QACI,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAQtC,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,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IACnD,CAAC;CAEJ;AApID,gDAoIC"}
@@ -0,0 +1,20 @@
1
+ import { UserInfo } from "@memberjunction/core";
2
+ import { EntityActionEntity, EntityActionFilterEntity, EntityActionInvocationEntity } from "@memberjunction/core-entities";
3
+ export declare class EntityActionEntityServer extends EntityActionEntity {
4
+ private _filters;
5
+ private _invocations;
6
+ /**
7
+ * Get the filters for this entity action
8
+ */
9
+ get Filters(): EntityActionFilterEntity[];
10
+ /**
11
+ * Get the invocations for this entity action
12
+ */
13
+ get Invocations(): EntityActionInvocationEntity[];
14
+ /**
15
+ * Override the base class Config in order to ensure that EntityActionEngine is configured
16
+ * @param contextUser
17
+ */
18
+ Config(contextUser: UserInfo): Promise<void>;
19
+ }
20
+ //# sourceMappingURL=EntityActionEntity.server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EntityActionEntity.server.d.ts","sourceRoot":"","sources":["../../src/entity-actions/EntityActionEntity.server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAI3H,qBACa,wBAAyB,SAAQ,kBAAkB;IAC5D,OAAO,CAAC,QAAQ,CAAoC;IACpD,OAAO,CAAC,YAAY,CAAwC;IAE5D;;OAEG;IACH,IAAW,OAAO,IAAI,wBAAwB,EAAE,CAM/C;IAED;;OAEG;IACH,IAAW,WAAW,IAAI,4BAA4B,EAAE,CAMvD;IAGD;;;OAGG;IACmB,MAAM,CAAC,WAAW,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAKrE"}
@@ -0,0 +1,54 @@
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.EntityActionEntityServer = 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_1 = require("./EntityActionEngine");
14
+ let EntityActionEntityServer = class EntityActionEntityServer extends core_entities_1.EntityActionEntity {
15
+ constructor() {
16
+ super(...arguments);
17
+ this._filters = null;
18
+ this._invocations = null;
19
+ }
20
+ /**
21
+ * Get the filters for this entity action
22
+ */
23
+ get Filters() {
24
+ if (!this._filters) {
25
+ // don't have the data loaded yet so get it from the EntityActionEngine
26
+ this._filters = EntityActionEngine_1.EntityActionEngine.Instance.Filters?.filter(f => f.EntityActionID === this.ID) ?? [];
27
+ }
28
+ return this._filters;
29
+ }
30
+ /**
31
+ * Get the invocations for this entity action
32
+ */
33
+ get Invocations() {
34
+ if (!this._invocations) {
35
+ // load the data from the EntityActionEngine
36
+ this._invocations = EntityActionEngine_1.EntityActionEngine.Instance.Invocations?.filter(i => i.EntityActionID === this.ID) ?? [];
37
+ }
38
+ return this._invocations;
39
+ }
40
+ /**
41
+ * Override the base class Config in order to ensure that EntityActionEngine is configured
42
+ * @param contextUser
43
+ */
44
+ async Config(contextUser) {
45
+ super.Config(contextUser);
46
+ EntityActionEngine_1.EntityActionEngine.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
47
+ // harmless to call it again here because it will not do anything extra if already in progress or done.
48
+ }
49
+ };
50
+ exports.EntityActionEntityServer = EntityActionEntityServer;
51
+ exports.EntityActionEntityServer = EntityActionEntityServer = __decorate([
52
+ (0, global_1.RegisterClass)(core_1.BaseEntity, 'Entity Actions')
53
+ ], EntityActionEntityServer);
54
+ //# sourceMappingURL=EntityActionEntity.server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EntityActionEntity.server.js","sourceRoot":"","sources":["../../src/entity-actions/EntityActionEntity.server.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+CAA4D;AAC5D,iEAA2H;AAC3H,mDAAuD;AACvD,6DAA0D;AAGnD,IAAM,wBAAwB,GAA9B,MAAM,wBAAyB,SAAQ,kCAAkB;IAAzD;;QACK,aAAQ,GAA+B,IAAI,CAAC;QAC5C,iBAAY,GAAmC,IAAI,CAAC;IAkChE,CAAC;IAhCG;;OAEG;IACH,IAAW,OAAO;QACd,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACjB,uEAAuE;YACvE,IAAI,CAAC,QAAQ,GAAG,uCAAkB,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,KAAK,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;QACzG,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,IAAW,WAAW;QAClB,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YACrB,4CAA4C;YAC5C,IAAI,CAAC,YAAY,GAAG,uCAAkB,CAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,KAAK,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;QACjH,CAAC;QACD,OAAO,IAAI,CAAC,YAAY,CAAA;IAC5B,CAAC;IAGD;;;OAGG;IACa,KAAK,CAAC,MAAM,CAAC,WAAqB;QAC9C,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAC1B,uCAAkB,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,mKAAmK;QACnK,uGAAuG;IACnK,CAAC;CACJ,CAAA;AApCY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,sBAAa,EAAC,iBAAU,EAAE,gBAAgB,CAAC;GAC/B,wBAAwB,CAoCpC"}
@@ -0,0 +1,29 @@
1
+ import { EntityActionInvocationParams } from "./EntityActionEngine";
2
+ import { ActionResult } from "../generic/ActionEngine";
3
+ import { ActionParamEntity } from "@memberjunction/core-entities";
4
+ /**
5
+ * Base class for invocation of any entity action invocation type
6
+ */
7
+ export declare abstract class EntityActionInvocationBase {
8
+ abstract InvokeAction(params: EntityActionInvocationParams): Promise<ActionResult>;
9
+ /**
10
+ * Case insensitive helper method to find a param by valueType
11
+ * @param allParams
12
+ * @param valueType
13
+ */
14
+ FindParam(allParams: ActionParamEntity[], valueType: "Scalar" | "Simple Object" | "BaseEntity Sub-Class" | "Other"): ActionParamEntity;
15
+ }
16
+ /**
17
+ * Base class for invocation of any entity action invocation type that is single record oriented
18
+ */
19
+ export declare class EntityActionInvocationSingleRecord extends EntityActionInvocationBase {
20
+ ValidateParams(params: EntityActionInvocationParams): Promise<boolean>;
21
+ InvokeAction(params: EntityActionInvocationParams): Promise<ActionResult>;
22
+ }
23
+ /**
24
+ * This class handles the invocation type of Validate and uses Entity Actions to validate a record and provide the results back to the caller
25
+ */
26
+ export declare class EntityActionInvocationValidate extends EntityActionInvocationSingleRecord {
27
+ InvokeAction(params: EntityActionInvocationParams): Promise<ActionResult>;
28
+ }
29
+ //# sourceMappingURL=EntityActionInvocationTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EntityActionInvocationTypes.d.ts","sourceRoot":"","sources":["../../src/entity-actions/EntityActionInvocationTypes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAA6B,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE;;GAEG;AACH,8BAAsB,0BAA0B;aAC5B,YAAY,CAAC,MAAM,EAAE,4BAA4B,GAAG,OAAO,CAAC,YAAY,CAAC;IAEzF;;;;OAIG;IACI,SAAS,CAAC,SAAS,EAAE,iBAAiB,EAAE,EAAE,SAAS,EAAE,QAAQ,GAAG,eAAe,GAAG,sBAAsB,GAAG,OAAO,GAAG,iBAAiB;CAGhJ;AAED;;GAEG;AACH,qBAOa,kCAAmC,SAAQ,0BAA0B;IACjE,cAAc,CAAC,MAAM,EAAE,4BAA4B,GAAG,OAAO,CAAC,OAAO,CAAC;IAQtE,YAAY,CAAC,MAAM,EAAE,4BAA4B,GAAG,OAAO,CAAC,YAAY,CAAC;CA+BzF;AAED;;GAEG;AACH,qBACa,8BAA+B,SAAQ,kCAAkC;IAC5D,YAAY,CAAC,MAAM,EAAE,4BAA4B,GAAG,OAAO,CAAC,YAAY,CAAC;CA4BlG"}
@@ -0,0 +1,108 @@
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.EntityActionInvocationValidate = exports.EntityActionInvocationSingleRecord = exports.EntityActionInvocationBase = void 0;
10
+ const global_1 = require("@memberjunction/global");
11
+ const ActionEngine_1 = require("../generic/ActionEngine");
12
+ /**
13
+ * Base class for invocation of any entity action invocation type
14
+ */
15
+ class EntityActionInvocationBase {
16
+ /**
17
+ * Case insensitive helper method to find a param by valueType
18
+ * @param allParams
19
+ * @param valueType
20
+ */
21
+ FindParam(allParams, valueType) {
22
+ return allParams.find(p => p.ValueType.trim().toLowerCase() === valueType.trim().toLowerCase());
23
+ }
24
+ }
25
+ exports.EntityActionInvocationBase = EntityActionInvocationBase;
26
+ /**
27
+ * Base class for invocation of any entity action invocation type that is single record oriented
28
+ */
29
+ let EntityActionInvocationSingleRecord = class EntityActionInvocationSingleRecord extends EntityActionInvocationBase {
30
+ async ValidateParams(params) {
31
+ // for this type of invocation we need to validate that the EntityObject is not null
32
+ if (!params.EntityObject) {
33
+ throw new Error('EntityObject is required for single record invocation - Create/Read/Update/Delete');
34
+ }
35
+ return true;
36
+ }
37
+ async InvokeAction(params) {
38
+ // for this type of invocation we need to validate that the EntityObject is not null
39
+ if (this.ValidateParams(params)) {
40
+ // now do the work
41
+ // get the class that is derived from BaseAction for the Action Name
42
+ await ActionEngine_1.ActionEngine.Instance.Config(false, params.ContextUser);
43
+ const action = ActionEngine_1.ActionEngine.Instance.Actions.find(a => a.ID === params.EntityAction.ActionID);
44
+ const param = this.FindParam(action.Params, 'BaseEntity Sub-Class'); // find the base entity sub-class param
45
+ const internalParams = [{
46
+ Name: param.Name, // parameter could be named anything, but we know it's the base entity sub-class so we are using it here
47
+ Value: params.EntityObject
48
+ }];
49
+ const result = await ActionEngine_1.ActionEngine.Instance.RunAction({
50
+ Action: action,
51
+ ContextUser: params.ContextUser,
52
+ Filters: params.EntityAction.Filters.map(f => {
53
+ const filter = ActionEngine_1.ActionEngine.Instance.ActionFilters.find(fi => fi.ID === f.ActionFilterID);
54
+ return filter;
55
+ }),
56
+ Params: internalParams
57
+ });
58
+ return result;
59
+ }
60
+ else
61
+ return null;
62
+ }
63
+ };
64
+ exports.EntityActionInvocationSingleRecord = EntityActionInvocationSingleRecord;
65
+ exports.EntityActionInvocationSingleRecord = EntityActionInvocationSingleRecord = __decorate([
66
+ (0, global_1.RegisterClass)(EntityActionInvocationBase, 'Read'),
67
+ (0, global_1.RegisterClass)(EntityActionInvocationBase, 'BeforeCreate'),
68
+ (0, global_1.RegisterClass)(EntityActionInvocationBase, 'BeforeUpdate'),
69
+ (0, global_1.RegisterClass)(EntityActionInvocationBase, 'BeforeDelete'),
70
+ (0, global_1.RegisterClass)(EntityActionInvocationBase, 'AfterCreate'),
71
+ (0, global_1.RegisterClass)(EntityActionInvocationBase, 'AfterUpdate'),
72
+ (0, global_1.RegisterClass)(EntityActionInvocationBase, 'AfterDelete')
73
+ ], EntityActionInvocationSingleRecord);
74
+ /**
75
+ * This class handles the invocation type of Validate and uses Entity Actions to validate a record and provide the results back to the caller
76
+ */
77
+ let EntityActionInvocationValidate = class EntityActionInvocationValidate extends EntityActionInvocationSingleRecord {
78
+ async InvokeAction(params) {
79
+ // for this type of invocation we need to validate that the EntityObject is not null
80
+ if (this.ValidateParams(params)) {
81
+ // make sure the action engine is good to go, the below won't do anything if it was already configured
82
+ await ActionEngine_1.ActionEngine.Instance.Config(false, params.ContextUser);
83
+ const action = ActionEngine_1.ActionEngine.Instance.Actions.find(a => a.ID === params.EntityAction.ActionID);
84
+ const param = this.FindParam(action.Params, 'BaseEntity Sub-Class'); // find the base entity sub-class param
85
+ const internalParams = [{
86
+ Name: param.Name, // parameter could be named anything, but we know it's the base entity sub-class so we are using it here
87
+ Value: params.EntityObject
88
+ }];
89
+ const result = await ActionEngine_1.ActionEngine.Instance.RunAction({
90
+ Action: action,
91
+ ContextUser: params.ContextUser,
92
+ Filters: params.EntityAction.Filters.map(f => {
93
+ const filter = ActionEngine_1.ActionEngine.Instance.ActionFilters.find(fi => fi.ID === f.ActionFilterID);
94
+ return filter;
95
+ }),
96
+ Params: internalParams
97
+ });
98
+ return result;
99
+ }
100
+ else
101
+ return null;
102
+ }
103
+ };
104
+ exports.EntityActionInvocationValidate = EntityActionInvocationValidate;
105
+ exports.EntityActionInvocationValidate = EntityActionInvocationValidate = __decorate([
106
+ (0, global_1.RegisterClass)(EntityActionInvocationBase, 'Validate')
107
+ ], EntityActionInvocationValidate);
108
+ //# sourceMappingURL=EntityActionInvocationTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EntityActionInvocationTypes.js","sourceRoot":"","sources":["../../src/entity-actions/EntityActionInvocationTypes.ts"],"names":[],"mappings":";;;;;;;;;AAAA,mDAAuD;AAEvD,0DAAkF;AAGlF;;GAEG;AACH,MAAsB,0BAA0B;IAG5C;;;;OAIG;IACI,SAAS,CAAC,SAA8B,EAAE,SAAwE;QACrH,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,SAAS,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;IACpG,CAAC;CACJ;AAXD,gEAWC;AAED;;GAEG;AAQI,IAAM,kCAAkC,GAAxC,MAAM,kCAAmC,SAAQ,0BAA0B;IACvE,KAAK,CAAC,cAAc,CAAC,MAAoC;QAC5D,oFAAoF;QACpF,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,mFAAmF,CAAC,CAAC;QACzG,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,MAAoC;QAC1D,oFAAoF;QACpF,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;YAC9B,kBAAkB;YAClB,oEAAoE;YACpE,MAAM,2BAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;YAE9D,MAAM,MAAM,GAAG,2BAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;YAC9F,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,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AAA,sBAAa,EAAC,0BAA0B,EAAE,UAAU,CAAC;GACzC,8BAA8B,CA6B1C"}
@@ -0,0 +1,161 @@
1
+ import { BaseEngine, UserInfo } from "@memberjunction/core";
2
+ import { ActionEntity, ActionExecutionLogEntity, ActionFilterEntity, ActionLibraryEntity, ActionParamEntity, ActionResultCodeEntity } from "@memberjunction/core-entities";
3
+ import { ActionEntityServerEntity } from "./ActionEntity.server";
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
+ * Generic class for holding parameters for an action for both inputs and outputs
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 executing actions. This class can be sub-classed if desired if you would like to modify the logic across ALL actions. To do so, sub-class this class and use the
113
+ * @RegisterClass decorator from the @memberjunction/global package to register your sub-class with the ClassFactory. This will cause your sub-class to be used instead of this base class when the Metadata object insantiates the ActionEngine.
114
+ */
115
+ export declare class ActionEngine extends BaseEngine<ActionEngine> {
116
+ private __coreCategoryName;
117
+ private constructor();
118
+ /**
119
+ * 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.
120
+ */
121
+ static get Instance(): ActionEngine;
122
+ private _Actions;
123
+ private _Filters;
124
+ private _Params;
125
+ private _ActionResultCodes;
126
+ private _ActionLibraries;
127
+ /**
128
+ * 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.
129
+ * 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.
130
+ * @param forceRefresh If true, the metadata will be loaded from the database even if it was previously loaded.
131
+ * @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.
132
+ */
133
+ Config(forceRefresh?: boolean, contextUser?: UserInfo): Promise<void>;
134
+ get Actions(): ActionEntityServerEntity[];
135
+ get ActionParams(): ActionParamEntity[];
136
+ get ActionFilters(): ActionFilterEntity[];
137
+ get ActionResultCodes(): ActionResultCodeEntity[];
138
+ get ActionLibraries(): ActionLibraryEntity[];
139
+ get CoreActions(): ActionEntityServerEntity[];
140
+ get NonCoreActions(): ActionEntityServerEntity[];
141
+ get CoreCategoryName(): string;
142
+ RunAction(params: RunActionParams): Promise<ActionResult>;
143
+ /**
144
+ * This method handles input validation. Subclasses can override this method to provide custom input validation.
145
+ */
146
+ protected ValidateInputs(params: RunActionParams): Promise<boolean>;
147
+ /**
148
+ * This method runs any filters for the action. Subclasses can override this method to provide custom filter logic.
149
+ */
150
+ protected RunFilters(params: RunActionParams): Promise<boolean>;
151
+ /**
152
+ * This method runs a single filter. Subclasses can override this method to provide custom filter logic.
153
+ * @param filter
154
+ */
155
+ protected RunSingleFilter(params: RunActionParams, filter: ActionFilterEntity): Promise<boolean>;
156
+ protected InternalRunAction(params: RunActionParams): Promise<ActionResult>;
157
+ protected StartActionLog(params: RunActionParams, saveRecord?: boolean): Promise<ActionExecutionLogEntity>;
158
+ protected EndActionLog(logEntity: ActionExecutionLogEntity, params: RunActionParams, result: ActionResult): Promise<void>;
159
+ protected StartAndEndActionLog(params: RunActionParams, result: ActionResult): Promise<ActionExecutionLogEntity>;
160
+ }
161
+ //# sourceMappingURL=ActionEngine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActionEngine.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