@memberjunction/actions-bizapps-lms
Version:
LMS system integration actions for MemberJunction
104 lines • 4.07 kB
TypeScript
import { ActionParam, ActionResultSimple } from '@memberjunction/actions-base';
import { BaseAction } from '@memberjunction/actions';
import { UserInfo } from '@memberjunction/core';
import { MJCompanyIntegrationEntity } from '@memberjunction/core-entities';
/**
* Base class for all LMS-related actions.
* Provides common functionality and patterns for interacting with Learning Management Systems.
*/
export declare abstract class BaseLMSAction extends BaseAction {
/**
* The LMS provider this action is designed for (e.g., 'LearnWorlds', 'Moodle', etc.)
*/
protected abstract lmsProvider: string;
/**
* The integration name to look up in the Integration entity
*/
protected abstract integrationName: string;
/**
* Cached company integration for the current execution
*/
private _companyIntegration;
/**
* Common LMS parameters that many actions will need
*/
protected getCommonLMSParams(): ActionParam[];
/**
* Validates that a string is a valid UUID format to prevent SQL injection.
*/
private static readonly uuidRegex;
/**
* Validates that a string is a valid UUID format to prevent SQL injection.
* Exposed as a reusable helper for subclasses to validate CompanyID, UserID, etc.
*/
protected validateUUID(value: string, paramName: string): string;
/**
* Validates that an integration name contains only safe characters (alphanumeric, spaces, hyphens, underscores).
*/
private validateIntegrationName;
/**
* Gets the company integration record for the specified company and LMS
*/
protected getCompanyIntegration(companyId: string, contextUser: UserInfo): Promise<MJCompanyIntegrationEntity>;
/**
* Gets credentials from environment variables
* Format: BIZAPPS_{PROVIDER}_{COMPANY_ID}_{CREDENTIAL_TYPE}
* Example: BIZAPPS_LEARNWORLDS_12345_API_KEY
*/
protected getCredentialFromEnv(companyId: string, credentialType: string): string | undefined;
/**
* Gets API credentials - first tries environment variables, then falls back to database
*/
protected getAPICredentials(integration: MJCompanyIntegrationEntity): Promise<{
apiKey?: string;
apiSecret?: string;
accessToken?: string;
}>;
/**
* Gets the base URL for API calls
*/
protected getAPIBaseURL(integration: MJCompanyIntegrationEntity): Promise<string>;
/**
* Helper to get parameter value from an ActionParam array
*/
protected getParamValue(params: ActionParam[], paramName: string): unknown;
/**
* Standard date format for LMS systems (ISO 8601)
*/
protected formatLMSDate(date: Date): string;
/**
* Parse date from LMS format
*/
protected parseLMSDate(dateString: string): Date;
/**
* Calculate progress percentage
*/
protected calculateProgressPercentage(completed: number, total: number): number;
/**
* Format duration in seconds to human readable format
*/
protected formatDuration(seconds: number): string;
/**
* Helper to build consistent error messages for LMS operations
*/
protected buildLMSErrorMessage(operation: string, details: string, systemError?: Error | string | {
message?: string;
}): string;
/**
* Common enrollment status mapping
*/
protected mapEnrollmentStatus(status: string): 'active' | 'completed' | 'expired' | 'suspended' | 'unknown';
/**
* Helper to set an output parameter, creating it if it doesn't exist
*/
protected setOutputParam(params: ActionParam[], name: string, value: unknown): void;
/**
* Build a standard success ActionResultSimple
*/
protected buildSuccessResult(message: string, params?: ActionParam[]): ActionResultSimple;
/**
* Build a standard error ActionResultSimple
*/
protected buildErrorResult(code: string, message: string, params?: ActionParam[]): ActionResultSimple;
}
//# sourceMappingURL=base-lms.action.d.ts.map