UNPKG

@mulutime/plugin-sdk

Version:

SDK for developing MuluTime booking platform plugins

125 lines 3.8 kB
import { PluginContext, SystemEventPayload, APIRequest, APIResponse, ValidationResult } from '../types'; import { ActionRegistry } from './action-registry'; export interface ActionExecutorOptions { enableMetrics?: boolean; enableTracing?: boolean; maxConcurrentExecutions?: number; executionTimeout?: number; } export interface ActionExecutionMetrics { totalExecutions: number; successfulExecutions: number; failedExecutions: number; averageExecutionTime: number; executionsByType: { event: number; scheduled: number; api: number; lifecycle: number; }; recentExecutions: ActionExecutionLog[]; } export interface ActionExecutionLog { id: string; type: 'event' | 'scheduled' | 'api' | 'lifecycle'; pluginId: string; actionIdentifier: string; timestamp: Date; duration: number; success: boolean; error?: string; metadata?: Record<string, any>; } export declare class ActionExecutor { private registry; private options; private executionLogs; private activeExecutions; constructor(registry: ActionRegistry, options?: ActionExecutorOptions); /** * Execute event actions for a system event */ executeEventActions(event: SystemEventPayload, context: PluginContext): Promise<void>; /** * Execute a scheduled action */ executeScheduledAction(pluginId: string, actionName: string, context: PluginContext): Promise<void>; /** * Execute an API action */ executeAPIAction(method: string, path: string, request: APIRequest, context: PluginContext): Promise<APIResponse>; /** * Execute a lifecycle action */ executeLifecycleAction(pluginId: string, actionType: 'install' | 'uninstall' | 'update' | 'enable' | 'disable', context: PluginContext, metadata?: { oldVersion?: string; }): Promise<void>; /** * Validate plugin configuration */ validatePluginConfig(pluginId: string, config: Record<string, any>): Promise<ValidationResult>; /** * Execute an action with metrics collection and error handling */ private executeWithMetrics; /** * Execute a function with timeout */ private executeWithTimeout; /** * Generate a unique execution ID */ private generateExecutionId; /** * Log execution metrics */ private logExecution; /** * Get execution metrics */ getMetrics(): ActionExecutionMetrics; /** * Get execution logs for a specific plugin */ getPluginExecutionLogs(pluginId: string, limit?: number): ActionExecutionLog[]; /** * Get currently active executions */ getActiveExecutions(): Array<{ id: string; startTime: Date; duration: number; }>; /** * Cancel an active execution (if possible) */ cancelExecution(executionId: string): Promise<boolean>; /** * Get action executor health status */ getHealthStatus(): { status: 'healthy' | 'degraded' | 'unhealthy'; activeExecutions: number; maxConcurrentExecutions: number; recentErrorRate: number; averageExecutionTime: number; }; /** * Clear execution logs and reset metrics */ clearMetrics(): void; /** * Start scheduled actions for all registered plugins */ startScheduledActions(context: PluginContext): void; /** * Stop all scheduled actions */ stopScheduledActions(): void; /** * Get the underlying action registry */ getActionRegistry(): ActionRegistry; } export declare function createActionExecutor(registry: ActionRegistry, options?: ActionExecutorOptions): ActionExecutor; //# sourceMappingURL=action-executor.d.ts.map