@memberjunction/actions-content-autotag 4.0.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +182 -150
  2. package/package.json +8 -8
package/README.md CHANGED
@@ -1,19 +1,10 @@
1
1
  # @memberjunction/actions-content-autotag
2
2
 
3
- Action classes that execute content autotagging and vectorization operations within the MemberJunction framework.
3
+ The `@memberjunction/actions-content-autotag` package provides a single MemberJunction action that combines content autotagging with entity vectorization. It automatically tags content from three source types -- local file systems, RSS feeds, and websites -- and then optionally creates vector embeddings for semantic search and AI-powered retrieval.
4
4
 
5
- ## Overview
5
+ For background on the MemberJunction Actions design philosophy (thin wrappers, direct service imports, composition over inheritance), see the [parent Actions CLAUDE.md](../CLAUDE.md).
6
6
 
7
- The `@memberjunction/actions-content-autotag` package provides an action class that combines content autotagging and vectorization capabilities. It automates the process of tagging content from various sources (local file system, RSS feeds, and websites) and then optionally vectorizing the tagged content for use in AI/ML applications.
8
-
9
- ## Purpose
10
-
11
- This package serves as a bridge between MemberJunction's content autotagging system and the action framework, allowing you to:
12
-
13
- - Automatically tag content from multiple sources (file system, RSS feeds, websites)
14
- - Vectorize tagged content for semantic search and AI applications
15
- - Execute both operations through a single, configurable action
16
- - Integrate content processing into automated workflows
7
+ **Server-side only** -- this package depends on Node.js APIs, database access, and server-side MJ infrastructure. Do not import it from Angular or other client-side code.
17
8
 
18
9
  ## Installation
19
10
 
@@ -21,202 +12,243 @@ This package serves as a bridge between MemberJunction's content autotagging sys
21
12
  npm install @memberjunction/actions-content-autotag
22
13
  ```
23
14
 
24
- ## Usage
25
-
26
- ### Basic Usage
27
-
28
- The package exports the `AutotagAndVectorizeContentAction` class, which can be executed through the MemberJunction action framework:
29
-
30
- ```typescript
31
- import { AutotagAndVectorizeContentAction } from '@memberjunction/actions-content-autotag';
32
- import { RunActionParams } from '@memberjunction/actions-base';
33
-
34
- // Configure the action parameters
35
- const actionParams: RunActionParams = {
36
- ActionName: 'Autotag And Vectorize Content',
37
- ContextUser: userInfo, // Your UserInfo instance
38
- Params: [
39
- {
40
- Name: 'Autotag',
41
- Value: 1 // Set to 1 to enable autotagging
42
- },
43
- {
44
- Name: 'Vectorize',
45
- Value: 1 // Set to 1 to enable vectorization
46
- },
47
- {
48
- Name: 'EntityNames',
49
- Value: 'Documents,Articles,BlogPosts' // Comma-separated list of entities to vectorize
50
- }
51
- ]
52
- };
15
+ This package is part of the MemberJunction monorepo. When working inside the monorepo, add the dependency to your package's `package.json` and run `npm install` at the repository root.
16
+
17
+ ## Architecture
18
+
19
+ The package contains a single action class that inherits from `VectorizeEntityAction` (in `@memberjunction/core-actions`) and adds an autotagging phase before the inherited vectorization logic. During the autotagging phase, three content-source processors from `@memberjunction/content-autotagging` are executed sequentially.
20
+
21
+ ```mermaid
22
+ graph TD
23
+ subgraph Package["@memberjunction/actions-content-autotag"]
24
+ direction TB
25
+ IDX["index.ts\n(re-exports action)"]
26
+ ACT["AutotagAndVectorize\nContentAction"]
27
+ end
28
+
29
+ subgraph Sources["Autotagging Sources"]
30
+ direction LR
31
+ FS["AutotagLocalFileSystem"]
32
+ RSS["AutotagRSSFeed"]
33
+ WEB["AutotagWebsite"]
34
+ end
35
+
36
+ subgraph Deps["Framework Packages"]
37
+ direction TB
38
+ VEC["VectorizeEntityAction\n@memberjunction/core-actions"]
39
+ BASE["BaseAction\n@memberjunction/actions"]
40
+ ABASE["@memberjunction/actions-base"]
41
+ CTAG["@memberjunction/content-autotagging"]
42
+ end
43
+
44
+ IDX --> ACT
45
+ ACT -->|extends| VEC
46
+ VEC -->|extends| BASE
47
+ BASE --> ABASE
48
+
49
+ ACT -->|autotagging phase| FS
50
+ ACT -->|autotagging phase| RSS
51
+ ACT -->|autotagging phase| WEB
52
+
53
+ FS -.-> CTAG
54
+ RSS -.-> CTAG
55
+ WEB -.-> CTAG
56
+
57
+ style Package fill:#2d6a9f,stroke:#1a4971,color:#fff
58
+ style Sources fill:#2d8659,stroke:#1a5c3a,color:#fff
59
+ style Deps fill:#7c5295,stroke:#563a6b,color:#fff
60
+ ```
53
61
 
54
- // Execute the action
55
- const action = new AutotagAndVectorizeContentAction();
56
- const result = await action.RunAction(actionParams);
62
+ ### Inheritance Chain
57
63
 
58
- if (result.Success) {
59
- console.log('Content autotagging and vectorization completed successfully');
60
- } else {
61
- console.error('Action failed:', result.Message);
62
- }
63
- ```
64
+ `AutotagAndVectorizeContentAction` extends `VectorizeEntityAction` rather than `BaseAction` directly. When the `Vectorize` parameter is enabled, the action delegates to `super.InternalRunAction()` to perform entity vectorization via the `EntityVectorSyncer` from `@memberjunction/ai-vector-sync`.
64
65
 
65
- ### Registration with Action Framework
66
+ ### Registration
66
67
 
67
- The action is automatically registered with the MemberJunction action framework using the `@RegisterClass` decorator. It can be invoked by name:
68
+ The action is registered with the MJ class factory using:
68
69
 
69
70
  ```typescript
70
- import { ActionEngine } from '@memberjunction/actions';
71
+ @RegisterClass(BaseAction, "__AutotagAndVectorizeContent")
72
+ ```
71
73
 
72
- const actionEngine = new ActionEngine();
73
- const result = await actionEngine.RunAction({
74
- ActionName: 'Autotag And Vectorize Content',
75
- ContextUser: userInfo,
76
- Params: [
77
- { Name: 'Autotag', Value: 1 },
78
- { Name: 'Vectorize', Value: 1 },
79
- { Name: 'EntityNames', Value: 'Documents' }
80
- ]
81
- });
74
+ This makes it discoverable at runtime by AI agents, workflow engines, and the `ActionEngineServer`.
75
+
76
+ ## Execution Flow
77
+
78
+ ```mermaid
79
+ sequenceDiagram
80
+ participant Caller as Caller (Agent / Workflow)
81
+ participant Engine as ActionEngineServer
82
+ participant Action as AutotagAndVectorize<br/>ContentAction
83
+ participant FS as AutotagLocalFileSystem
84
+ participant RSS as AutotagRSSFeed
85
+ participant Web as AutotagWebsite
86
+ participant Vec as VectorizeEntityAction<br/>(super)
87
+
88
+ Caller->>Engine: RunAction({ ActionName, Params, ContextUser })
89
+ Engine->>Action: InternalRunAction(params)
90
+
91
+ alt Autotag = 1
92
+ Action->>FS: Autotag(contextUser)
93
+ FS-->>Action: complete
94
+ Action->>RSS: Autotag(contextUser)
95
+ RSS-->>Action: complete
96
+ Action->>Web: Autotag(contextUser)
97
+ Web-->>Action: complete
98
+ end
99
+
100
+ alt Vectorize = 1
101
+ Action->>Vec: super.InternalRunAction(params)
102
+ Vec-->>Action: complete
103
+ end
104
+
105
+ Action-->>Engine: { Success, ResultCode }
106
+ Engine-->>Caller: ActionResult
82
107
  ```
83
108
 
84
- ## API Documentation
109
+ ## API Reference
85
110
 
86
111
  ### AutotagAndVectorizeContentAction
87
112
 
88
- The main action class that performs content autotagging and vectorization.
113
+ The single exported action class. Extends `VectorizeEntityAction` from `@memberjunction/core-actions`.
89
114
 
90
- #### Parameters
115
+ #### Action Parameters
91
116
 
92
117
  | Parameter | Type | Required | Description |
93
- |-----------|------|----------|-------------|
94
- | `Autotag` | `number` | Yes | Set to `1` to enable autotagging, `0` to disable |
95
- | `Vectorize` | `number` | Yes | Set to `1` to enable vectorization, `0` to disable |
96
- | `EntityNames` | `string` | No* | Comma-separated list of entity names to vectorize (*Required if `Vectorize` is `1`) |
118
+ |---|---|---|---|
119
+ | `Autotag` | `number` | Yes | Set to `1` to run the autotagging phase, `0` to skip |
120
+ | `Vectorize` | `number` | Yes | Set to `1` to run the vectorization phase, `0` to skip |
121
+ | `EntityNames` | `string` | When `Vectorize = 1` | Comma-separated list of entity names to vectorize (passed to parent `VectorizeEntityAction`) |
97
122
 
98
123
  #### Return Value
99
124
 
100
- Returns an `ActionResultSimple` object:
101
-
102
- ```typescript
103
- interface ActionResultSimple {
104
- Success: boolean;
105
- Message?: string;
106
- ResultCode: string;
107
- }
108
- ```
109
-
110
- - `Success`: `true` if the action completed successfully
111
- - `Message`: Error message if the action failed
112
- - `ResultCode`: `"SUCCESS"` or `"FAILED"`
125
+ Returns an `ActionResultSimple` with:
113
126
 
114
- ### LoadAutotagAndVectorizeContentAction
127
+ | Property | Type | Description |
128
+ |---|---|---|
129
+ | `Success` | `boolean` | `true` if both enabled phases completed without errors |
130
+ | `Message` | `string` | Error details if the action failed |
131
+ | `ResultCode` | `string` | `"SUCCESS"` or `"FAILED"` |
115
132
 
116
- A utility function that ensures the action class is included in the final bundle:
133
+ #### Autotagging Phase
117
134
 
118
- ```typescript
119
- import { LoadAutotagAndVectorizeContentAction } from '@memberjunction/actions-content-autotag';
135
+ When `Autotag = 1`, three content-source processors execute sequentially:
120
136
 
121
- // Call this function during application initialization
122
- LoadAutotagAndVectorizeContentAction();
123
- ```
137
+ 1. **AutotagLocalFileSystem** -- processes files from configured local directories
138
+ 2. **AutotagRSSFeed** -- processes articles from configured RSS feed URLs
139
+ 3. **AutotagWebsite** -- crawls and processes content from configured websites
124
140
 
125
- ## How It Works
126
-
127
- 1. **Autotagging Phase**: When enabled, the action executes three autotagging operations in sequence:
128
- - `AutotagLocalFileSystem`: Processes files from configured local directories
129
- - `AutotagRSSFeed`: Processes content from configured RSS feeds
130
- - `AutotagWebsite`: Processes content from configured websites
131
-
132
- 2. **Vectorization Phase**: When enabled, the action:
133
- - Inherits functionality from `VectorizeEntityAction`
134
- - Processes the specified entities from the `EntityNames` parameter
135
- - Creates vector embeddings for the content using configured AI models
136
-
137
- ## Dependencies
141
+ Each processor reads its configuration from MemberJunction Content Source metadata. See `@memberjunction/content-autotagging` for source configuration details.
138
142
 
139
- This package depends on several MemberJunction packages:
143
+ #### Vectorization Phase
140
144
 
141
- - `@memberjunction/global`: Core global utilities and registration system
142
- - `@memberjunction/core`: Core MemberJunction functionality
143
- - `@memberjunction/core-entities`: Entity definitions and management
144
- - `@memberjunction/actions`: Base action framework
145
- - `@memberjunction/core-actions`: Core action implementations including `VectorizeEntityAction`
146
- - `@memberjunction/content-autotagging`: Content autotagging implementations
145
+ When `Vectorize = 1`, the action calls `super.InternalRunAction(params)` which delegates to `VectorizeEntityAction`. That action parses the `EntityNames` parameter, looks up associated Entity Documents, and uses `EntityVectorSyncer` from `@memberjunction/ai-vector-sync` to create vector embeddings.
147
146
 
148
- ## Configuration
147
+ ## Usage Examples
149
148
 
150
- The autotagging sources (file paths, RSS feeds, websites) are configured through the respective autotagging classes. Refer to the `@memberjunction/content-autotagging` package documentation for detailed configuration options.
149
+ ### Autotag and Vectorize (Full Pipeline)
151
150
 
152
- ## Error Handling
153
-
154
- The action implements comprehensive error handling:
155
-
156
- - Missing required parameters throw an error before processing begins
157
- - Any errors during autotagging or vectorization are caught and returned in the result
158
- - The action returns a failed result with the error message rather than throwing exceptions
159
-
160
- ## Integration with MemberJunction
161
-
162
- This action integrates seamlessly with:
163
-
164
- - **Action Framework**: Registered as a named action that can be invoked programmatically or through workflows
165
- - **Entity System**: Works with MemberJunction entities for vectorization
166
- - **AI/Vector System**: Leverages the MemberJunction AI vector synchronization for embedding generation
167
- - **User Context**: Respects user permissions and context throughout execution
151
+ ```typescript
152
+ import { ActionEngineServer } from '@memberjunction/actions';
168
153
 
169
- ## Best Practices
154
+ const engine = ActionEngineServer.Instance;
170
155
 
171
- 1. **Parameter Validation**: Always provide both `Autotag` and `Vectorize` parameters, even if setting one to `0`
172
- 2. **Entity Selection**: Only specify entities in `EntityNames` that have been configured for vectorization
173
- 3. **Performance**: Consider the volume of content when running both operations together
174
- 4. **Monitoring**: Check console logs for progress updates during execution
175
- 5. **Error Recovery**: Implement retry logic for failed operations in production environments
156
+ const result = await engine.RunAction({
157
+ ActionName: '__AutotagAndVectorizeContent',
158
+ Params: [
159
+ { Name: 'Autotag', Value: 1 },
160
+ { Name: 'Vectorize', Value: 1 },
161
+ { Name: 'EntityNames', Value: 'Documents,Articles,KnowledgeBase' }
162
+ ],
163
+ ContextUser: currentUser
164
+ });
176
165
 
177
- ## Examples
166
+ if (result.Success) {
167
+ console.log('Content autotagging and vectorization completed successfully');
168
+ } else {
169
+ console.error('Action failed:', result.Message);
170
+ }
171
+ ```
178
172
 
179
173
  ### Autotag Only
180
174
 
181
175
  ```typescript
182
- const result = await action.RunAction({
183
- ActionName: 'Autotag And Vectorize Content',
184
- ContextUser: userInfo,
176
+ const result = await engine.RunAction({
177
+ ActionName: '__AutotagAndVectorizeContent',
185
178
  Params: [
186
179
  { Name: 'Autotag', Value: 1 },
187
180
  { Name: 'Vectorize', Value: 0 }
188
- ]
181
+ ],
182
+ ContextUser: currentUser
189
183
  });
190
184
  ```
191
185
 
192
186
  ### Vectorize Only
193
187
 
194
188
  ```typescript
195
- const result = await action.RunAction({
196
- ActionName: 'Autotag And Vectorize Content',
197
- ContextUser: userInfo,
189
+ const result = await engine.RunAction({
190
+ ActionName: '__AutotagAndVectorizeContent',
198
191
  Params: [
199
192
  { Name: 'Autotag', Value: 0 },
200
193
  { Name: 'Vectorize', Value: 1 },
201
- { Name: 'EntityNames', Value: 'Documents,KnowledgeBase' }
202
- ]
194
+ { Name: 'EntityNames', Value: 'Documents' }
195
+ ],
196
+ ContextUser: currentUser
203
197
  });
204
198
  ```
205
199
 
206
- ### Full Pipeline
200
+ ### Direct Class Instantiation
201
+
202
+ While action execution through the engine is preferred, the class can also be used directly:
207
203
 
208
204
  ```typescript
205
+ import { AutotagAndVectorizeContentAction } from '@memberjunction/actions-content-autotag';
206
+
207
+ const action = new AutotagAndVectorizeContentAction();
209
208
  const result = await action.RunAction({
210
- ActionName: 'Autotag And Vectorize Content',
211
- ContextUser: userInfo,
209
+ ActionName: '__AutotagAndVectorizeContent',
210
+ ContextUser: currentUser,
212
211
  Params: [
213
212
  { Name: 'Autotag', Value: 1 },
214
213
  { Name: 'Vectorize', Value: 1 },
215
- { Name: 'EntityNames', Value: 'Documents,Articles,BlogPosts,KnowledgeBase' }
214
+ { Name: 'EntityNames', Value: 'Documents,Articles' }
216
215
  ]
217
216
  });
218
217
  ```
219
218
 
220
- ## License
219
+ ## Error Handling
220
+
221
+ The action catches all errors during execution and returns them in the result object rather than throwing exceptions:
222
+
223
+ - **Missing parameters**: Throws an error if either `Autotag` or `Vectorize` params are not provided
224
+ - **Processing errors**: Any error during autotagging or vectorization is caught and returned with `Success: false` and `ResultCode: "FAILED"`
225
+ - **Partial execution**: If autotagging succeeds but vectorization fails (or vice versa), the error from the failing phase is returned
226
+
227
+ ## Dependencies
228
+
229
+ ### MemberJunction Packages
230
+
231
+ | Package | Purpose |
232
+ |---|---|
233
+ | `@memberjunction/actions` | `BaseAction` base class (transitive via `VectorizeEntityAction`) |
234
+ | `@memberjunction/actions-base` | `ActionResultSimple`, `RunActionParams`, `ActionParam` type definitions |
235
+ | `@memberjunction/core` | Core MJ framework, `UserInfo`, metadata access |
236
+ | `@memberjunction/core-actions` | `VectorizeEntityAction` parent class |
237
+ | `@memberjunction/core-entities` | Entity type definitions |
238
+ | `@memberjunction/content-autotagging` | `AutotagLocalFileSystem`, `AutotagRSSFeed`, `AutotagWebsite` processors |
239
+ | `@memberjunction/global` | `RegisterClass` decorator for MJ class factory registration |
240
+
241
+ ### Third-Party Libraries
242
+
243
+ | Library | Purpose |
244
+ |---|---|
245
+ | `axios` | HTTP requests (used by content source processors) |
246
+
247
+ ## Related Packages
221
248
 
222
- ISC
249
+ - **[@memberjunction/core-actions](../CoreActions/README.md)** -- Contains `VectorizeEntityAction` (the parent class) and 100+ other core actions
250
+ - **[@memberjunction/actions-base](../Base/README.md)** -- Shared types and metadata engine
251
+ - **[@memberjunction/actions](../Engine/README.md)** -- Server-side action execution engine and `BaseAction`
252
+ - **[@memberjunction/content-autotagging](../../ContentAutotagging/)** -- Content source processors and autotagging engine
253
+ - **[@memberjunction/ai-vector-sync](../../AI/Vectors/Sync/)** -- Vector embedding synchronization used by the vectorization phase
254
+ - **[Parent Actions CLAUDE.md](../CLAUDE.md)** -- Design philosophy and development guidelines for all action packages
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@memberjunction/actions-content-autotag",
3
3
  "type": "module",
4
- "version": "4.0.0",
4
+ "version": "4.1.0",
5
5
  "description": "Action classes that execute the content autotagging and vectorization actions.",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -20,13 +20,13 @@
20
20
  "typescript": "^5.9.3"
21
21
  },
22
22
  "dependencies": {
23
- "@memberjunction/actions": "4.0.0",
24
- "@memberjunction/actions-base": "4.0.0",
25
- "@memberjunction/content-autotagging": "4.0.0",
26
- "@memberjunction/core": "4.0.0",
27
- "@memberjunction/core-actions": "4.0.0",
28
- "@memberjunction/core-entities": "4.0.0",
29
- "@memberjunction/global": "4.0.0",
23
+ "@memberjunction/actions": "4.1.0",
24
+ "@memberjunction/actions-base": "4.1.0",
25
+ "@memberjunction/content-autotagging": "4.1.0",
26
+ "@memberjunction/core": "4.1.0",
27
+ "@memberjunction/core-actions": "4.1.0",
28
+ "@memberjunction/core-entities": "4.1.0",
29
+ "@memberjunction/global": "4.1.0",
30
30
  "axios": "^1.13.4"
31
31
  },
32
32
  "repository": {