2.48.0 • Published 5 months ago

@memberjunction/core-actions v2.48.0

Weekly downloads
-
License
ISC
Repository
-
Last release
5 months ago

@memberjunction/core-actions

The @memberjunction/core-actions library provides a collection of pre-built actions that are essential to the MemberJunction framework. These actions handle common operations like sending messages, detecting external changes, and vectorizing entities for AI processing.

Overview

This package contains both custom-built and generated actions that extend the MemberJunction Actions framework. It provides ready-to-use implementations for core functionality that many MemberJunction applications require.

Important Note

This library should only be imported on the server side. It contains server-specific dependencies and functionality that are not suitable for client-side applications.

Installation

npm install @memberjunction/core-actions

Available Actions

1. Send Single Message Action

Provides a simple wrapper around the MemberJunction Communication Framework to send single messages through various communication providers.

Class: SendSingleMessageAction
Registration Name: "Send Single Message"

Parameters:

  • Subject (string): The subject of the message
  • Body (string): The body content of the message
  • To (string): The recipient's address
  • From (string): The sender's address
  • Provider (string): The name of the Communication Provider to use
  • MessageType (string): The name of the Message Type within the provider

Example Usage:

import { SendSingleMessageAction } from '@memberjunction/core-actions';
import { ActionEngine } from '@memberjunction/actions';

// Execute the action through the Action Engine
const result = await ActionEngine.RunAction({
    ActionName: 'Send Single Message',
    Params: [
        { Name: 'Subject', Value: 'Welcome to MemberJunction' },
        { Name: 'Body', Value: 'Thank you for joining our platform!' },
        { Name: 'To', Value: 'user@example.com' },
        { Name: 'From', Value: 'noreply@memberjunction.com' },
        { Name: 'Provider', Value: 'SendGrid' },
        { Name: 'MessageType', Value: 'Email' }
    ],
    ContextUser: currentUser
});

if (result.Success) {
    console.log('Message sent successfully');
} else {
    console.error('Failed to send message:', result.Message);
}

2. Vectorize Entity Action

Enables vectorization of entity data for AI and machine learning operations. This action integrates with MemberJunction's AI vector synchronization system to create vector embeddings of entity records.

Class: VectorizeEntityAction
Registration Name: "Vectorize Entity"

Parameters:

  • EntityNames (string | string[]): Entity name(s) to vectorize. Can be:
    • A single entity name as a string
    • Multiple entity names as a comma-separated string
    • An array of entity names

Example Usage:

import { VectorizeEntityAction } from '@memberjunction/core-actions';
import { ActionEngine } from '@memberjunction/actions';

// Vectorize a single entity
const singleResult = await ActionEngine.RunAction({
    ActionName: 'Vectorize Entity',
    Params: [
        { Name: 'EntityNames', Value: 'Customers' }
    ],
    ContextUser: currentUser
});

// Vectorize multiple entities
const multiResult = await ActionEngine.RunAction({
    ActionName: 'Vectorize Entity',
    Params: [
        { Name: 'EntityNames', Value: 'Customers,Products,Orders' }
    ],
    ContextUser: currentUser
});

// Or using an array
const arrayResult = await ActionEngine.RunAction({
    ActionName: 'Vectorize Entity',
    Params: [
        { Name: 'EntityNames', Value: ['Customers', 'Products', 'Orders'] }
    ],
    ContextUser: currentUser
});

3. External Change Detection Action

Detects and replays changes from external systems that have modified data outside of the MemberJunction framework. This is crucial for maintaining data consistency when external systems directly modify the database.

Class: ExternalChangeDetectionAction
Registration Name: "Run External Change Detection"

Parameters:

  • EntityList (string, optional): Comma-separated list of entity names to check for changes. If not provided, all eligible entities will be processed.

Example Usage:

import { ExternalChangeDetectionAction } from '@memberjunction/core-actions';
import { ActionEngine } from '@memberjunction/actions';

// Check specific entities for changes
const specificResult = await ActionEngine.RunAction({
    ActionName: 'Run External Change Detection',
    Params: [
        { Name: 'EntityList', Value: 'Customers,Orders,Invoices' }
    ],
    ContextUser: currentUser
});

// Check all eligible entities
const allResult = await ActionEngine.RunAction({
    ActionName: 'Run External Change Detection',
    Params: [],
    ContextUser: currentUser
});

if (specificResult.Success) {
    console.log('External changes detected and replayed successfully');
} else {
    console.error('Change detection failed:', specificResult.Message);
}

Integration with MemberJunction Actions Framework

All actions in this package extend the BaseAction class from @memberjunction/actions and are automatically registered with the MemberJunction class factory system using the @RegisterClass decorator.

To use these actions, you typically interact with them through the ActionEngine rather than instantiating them directly:

import { ActionEngine } from '@memberjunction/actions';

// The actions are automatically registered when the module is loaded
const result = await ActionEngine.RunAction({
    ActionName: 'Action Name Here',
    Params: [...],
    ContextUser: user
});

Dependencies

This package depends on several core MemberJunction packages:

  • @memberjunction/global - Global utilities and class registration
  • @memberjunction/core - Core MemberJunction functionality
  • @memberjunction/core-entities - Entity definitions
  • @memberjunction/actions - Base action framework
  • @memberjunction/communication-engine - Communication framework
  • @memberjunction/external-change-detection - Change detection engine
  • @memberjunction/ai-vector-sync - AI vectorization functionality
  • @memberjunction/content-autotagging - Content tagging capabilities

Building and Development

To build this package:

# From the package directory
npm run build

# Or from the repository root using Turbo
turbo build --filter="@memberjunction/core-actions"

The package uses TypeScript and compiles to JavaScript with type definitions included.

Result Handling

All actions return an ActionResultSimple object with the following structure:

interface ActionResultSimple {
    Success: boolean;      // Whether the action completed successfully
    Message?: string;      // Error message or additional information
    ResultCode: string;    // Either "SUCCESS" or "FAILED"
}

Always check the Success property before proceeding with dependent operations.

Server-Side Only

This package contains server-side dependencies and should never be imported in client-side code. It relies on:

  • Database connections
  • File system access
  • Server-side API integrations
  • Heavy computational processes

For client-side action needs, refer to client-safe action packages in the MemberJunction ecosystem.

2.27.1

8 months ago

2.23.2

9 months ago

2.46.0

5 months ago

2.23.1

9 months ago

2.27.0

8 months ago

2.34.0

6 months ago

2.30.0

7 months ago

2.19.4

9 months ago

2.19.5

9 months ago

2.19.2

9 months ago

2.19.3

9 months ago

2.19.0

9 months ago

2.19.1

9 months ago

2.15.2

9 months ago

2.34.2

6 months ago

2.34.1

6 months ago

2.38.0

5 months ago

2.45.0

5 months ago

2.22.1

9 months ago

2.22.0

9 months ago

2.41.0

5 months ago

2.22.2

9 months ago

2.26.1

8 months ago

2.26.0

8 months ago

2.33.0

6 months ago

2.18.3

9 months ago

2.18.1

9 months ago

2.18.2

9 months ago

2.18.0

9 months ago

2.37.1

6 months ago

2.37.0

6 months ago

2.14.0

10 months ago

2.21.0

9 months ago

2.44.0

5 months ago

2.40.0

5 months ago

2.29.0

8 months ago

2.29.2

8 months ago

2.29.1

8 months ago

2.25.0

8 months ago

2.48.0

5 months ago

2.32.0

7 months ago

2.32.2

7 months ago

2.32.1

7 months ago

2.17.0

9 months ago

2.13.4

10 months ago

2.36.0

6 months ago

2.13.2

11 months ago

2.13.3

10 months ago

2.13.0

11 months ago

2.36.1

6 months ago

2.13.1

11 months ago

2.43.0

5 months ago

2.20.2

9 months ago

2.20.3

9 months ago

2.20.0

9 months ago

2.20.1

9 months ago

2.28.0

8 months ago

2.47.0

5 months ago

2.24.1

8 months ago

2.24.0

8 months ago

2.31.0

7 months ago

2.12.0

12 months ago

2.39.0

5 months ago

2.16.1

9 months ago

2.35.1

6 months ago

2.35.0

6 months ago

2.16.0

9 months ago

2.42.1

5 months ago

2.42.0

5 months ago

2.23.0

9 months ago

2.11.0

1 year ago

2.10.0

1 year ago

2.9.0

1 year ago

2.8.0

1 year ago

2.7.0

1 year ago

2.6.1

1 year ago

2.5.2

1 year ago

2.6.0

1 year ago

2.7.1

1 year ago

2.5.1

1 year ago

2.5.0

1 year ago

2.4.1

1 year ago

2.4.0

1 year ago

2.3.3

1 year ago

2.3.2

1 year ago

2.3.1

1 year ago

2.3.0

1 year ago

2.2.1

1 year ago

2.2.0

1 year ago

2.1.5

1 year ago

2.1.4

1 year ago

2.1.3

1 year ago

2.1.2

1 year ago

2.1.1

1 year ago

2.0.0

1 year ago

1.8.1

1 year ago

1.8.0

1 year ago

1.7.1

1 year ago

1.7.0

1 year ago

1.6.1

1 year ago

1.6.0

1 year ago

1.5.3

1 year ago

1.5.2

1 year ago

1.5.1

1 year ago

1.5.0

1 year ago

1.4.1

1 year ago