@mj-biz-apps/common-actions 5.4.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.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=action_subclasses.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action_subclasses.d.ts","sourceRoot":"","sources":["../../src/generated/action_subclasses.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=action_subclasses.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action_subclasses.js","sourceRoot":"","sources":["../../src/generated/action_subclasses.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export * from './generated/action_subclasses.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,+BAA+B,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from './generated/action_subclasses.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,+BAA+B,CAAC"}
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@mj-biz-apps/common-actions",
3
+ "type": "module",
4
+ "version": "5.4.0",
5
+ "description": "Generated action subclasses maintained by the CodeGen utility.",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "files": [
12
+ "/dist"
13
+ ],
14
+ "scripts": {
15
+ "start": "ts-node-dev src/index.ts",
16
+ "build": "tsc && tsc-alias -f",
17
+ "test": "echo \"No tests configured yet\""
18
+ },
19
+ "author": "MemberJunction.com",
20
+ "license": "ISC",
21
+ "devDependencies": {
22
+ "ts-node-dev": "^2.0.0",
23
+ "typescript": "^5.9.3"
24
+ },
25
+ "dependencies": {
26
+ "@memberjunction/actions-base": "5.8.0",
27
+ "@memberjunction/actions": "5.8.0",
28
+ "@memberjunction/global": "5.8.0",
29
+ "@memberjunction/core": "5.8.0",
30
+ "@memberjunction/core-entities": "5.8.0",
31
+ "@memberjunction/core-entities-server": "5.8.0",
32
+ "@memberjunction/ai": "5.8.0",
33
+ "@memberjunction/aiengine": "5.8.0",
34
+ "zod": "~3.24.4"
35
+ },
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "https://github.com/MemberJunction/bizapps-common"
39
+ }
40
+ }
package/readme.md ADDED
@@ -0,0 +1,168 @@
1
+ # @memberjunction/generated-actions
2
+
3
+ This package contains automatically generated BaseAction subclasses for actions defined in the MemberJunction framework outside of the core MJ framework. These classes are maintained by the MemberJunction CodeGen tool and provide a foundation for implementing custom business logic through the MJ Actions system.
4
+
5
+ ## Overview
6
+
7
+ The MemberJunction Actions framework provides a flexible system for executing business logic in response to various triggers. This package contains the generated action classes that extend the base `BaseAction` class from `@memberjunction/actions`, allowing developers to implement custom behavior while leveraging MJ's metadata-driven architecture.
8
+
9
+ ## Purpose
10
+
11
+ - **Code Generation**: All classes in this package are automatically generated by the MJ CodeGen tool based on action metadata stored in the database
12
+ - **Type Safety**: Provides strongly-typed action implementations with proper TypeScript support
13
+ - **Extensibility**: Generated classes can be further subclassed to add custom business logic
14
+ - **Server-Side Only**: These actions are designed to run exclusively on the server side for security and performance
15
+
16
+ ## Installation
17
+
18
+ This package is typically included as part of a MemberJunction server-side application. Since it's marked as private, it's not published to npm and should be used within the MJ monorepo:
19
+
20
+ ```bash
21
+ # From the MJ monorepo root
22
+ npm install
23
+
24
+ # Build the package
25
+ npm run build --filter=mj_generatedactions
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ ### Basic Usage
31
+
32
+ Import the generated actions in your server-side code:
33
+
34
+ ```typescript
35
+ import { LoadGeneratedActions } from 'mj_generatedactions';
36
+
37
+ // Load all generated actions to ensure they're registered with the ClassFactory
38
+ LoadGeneratedActions();
39
+ ```
40
+
41
+ ### Extending Generated Actions
42
+
43
+ While the generated action classes provide the base implementation, you can create custom subclasses to add specific business logic:
44
+
45
+ ```typescript
46
+ import { RegisterClass } from '@memberjunction/global';
47
+ import { ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
48
+ import { YourGeneratedAction } from 'mj_generatedactions';
49
+
50
+ @RegisterClass(YourCustomAction, 'YourActionName')
51
+ export class YourCustomAction extends YourGeneratedAction {
52
+ protected async InternalRunAction(params: RunActionParams): Promise<ActionResultSimple> {
53
+ // Add your custom logic here
54
+ const result = await super.InternalRunAction(params);
55
+
56
+ // Additional processing
57
+ console.log('Custom action executed:', params);
58
+
59
+ return result;
60
+ }
61
+ }
62
+ ```
63
+
64
+ ### Action Execution
65
+
66
+ Actions are typically executed through the MemberJunction ActionEngine:
67
+
68
+ ```typescript
69
+ import { ActionEngine } from '@memberjunction/actions';
70
+
71
+ const engine = new ActionEngine();
72
+ const result = await engine.RunAction({
73
+ ActionName: 'YourActionName',
74
+ Params: {
75
+ // Your action parameters
76
+ }
77
+ });
78
+
79
+ if (result.Success) {
80
+ console.log('Action completed successfully:', result.ResultCode);
81
+ } else {
82
+ console.error('Action failed:', result.Message);
83
+ }
84
+ ```
85
+
86
+ ## API Documentation
87
+
88
+ ### LoadGeneratedActions()
89
+
90
+ A utility function that ensures all generated action classes are loaded and registered with the MemberJunction ClassFactory. This prevents tree-shaking from removing the generated classes during bundling.
91
+
92
+ **Usage:**
93
+ ```typescript
94
+ LoadGeneratedActions();
95
+ ```
96
+
97
+ **Note:** This function should be called during application initialization to ensure all actions are available for use.
98
+
99
+ ## Dependencies
100
+
101
+ - `@memberjunction/actions`: Base action framework and utilities
102
+ - `@memberjunction/global`: Global utilities including ClassFactory for registration
103
+ - `@memberjunction/core`: Core MJ functionality
104
+ - `@memberjunction/core-entities`: Entity definitions and metadata
105
+ - `@memberjunction/ai`: AI-related functionality
106
+ - `@memberjunction/aiengine`: AI engine implementation
107
+ - `zod`: Schema validation library
108
+
109
+ ## Integration with MJ Framework
110
+
111
+ This package integrates seamlessly with other MemberJunction packages:
112
+
113
+ 1. **Metadata-Driven**: Actions are defined in the MJ metadata database and generated automatically
114
+ 2. **Entity Actions**: Can be triggered by entity events (create, update, delete)
115
+ 3. **Scheduled Actions**: Can be scheduled for periodic execution
116
+ 4. **AI Integration**: Can leverage AI capabilities through the AI packages
117
+
118
+ ## Build and Development
119
+
120
+ ### Building
121
+
122
+ ```bash
123
+ # Build the package
124
+ cd packages/GeneratedActions
125
+ npm run build
126
+ ```
127
+
128
+ ### Generated Code
129
+
130
+ All generated code is placed in `src/generated/` and should not be manually modified. The CodeGen tool will overwrite these files during regeneration.
131
+
132
+ ### Development Workflow
133
+
134
+ 1. Define actions in the MJ metadata database
135
+ 2. Run the CodeGen tool to generate/update action classes
136
+ 3. Create custom subclasses as needed for specific business logic
137
+ 4. Register custom classes with appropriate action names
138
+ 5. Deploy and test on the server
139
+
140
+ ## Important Notes
141
+
142
+ - **Server-Side Only**: This library must only be imported and used on the server side for security reasons
143
+ - **Do Not Modify Generated Code**: Files in `src/generated/` are automatically maintained and will be overwritten
144
+ - **Custom Logic**: Always extend generated classes rather than modifying them directly
145
+ - **Registration**: Ensure custom action classes are properly registered with `@RegisterClass` decorator
146
+ - **Type Safety**: Leverage TypeScript's type system for compile-time safety
147
+
148
+ ## Troubleshooting
149
+
150
+ ### Actions Not Found
151
+
152
+ If actions are not being recognized:
153
+ 1. Ensure `LoadGeneratedActions()` is called during initialization
154
+ 2. Verify the action is defined in the metadata database
155
+ 3. Check that CodeGen has been run recently
156
+ 4. Confirm custom classes are properly registered
157
+
158
+ ### Build Issues
159
+
160
+ If experiencing build problems:
161
+ 1. Ensure all dependencies are installed at the monorepo root
162
+ 2. Run `npm run build` from the package directory
163
+ 3. Check for TypeScript compilation errors
164
+ 4. Verify the generated code is up to date
165
+
166
+ ## License
167
+
168
+ ISC - See LICENSE file in the repository root for details.