@mulutime/plugin-sdk
Version:
SDK for developing MuluTime booking platform plugins
155 lines • 4.69 kB
TypeScript
import { PluginContext, EventAction, ScheduledAction, APIAction, LifecycleAction } from '../types';
import { EventActionHandler } from './event-handler';
import { ScheduledActionHandler } from './scheduled-handler';
import { APIActionHandler } from './api-handler';
import { LifecycleActionHandler } from './lifecycle-handler';
export interface ActionRegistryOptions {
enableEventHandling?: boolean;
enableScheduledActions?: boolean;
enableAPIActions?: boolean;
enableLifecycleActions?: boolean;
eventHandlerOptions?: any;
scheduledHandlerOptions?: any;
apiHandlerOptions?: any;
lifecycleHandlerOptions?: any;
}
export interface PluginActions {
eventActions?: EventAction[];
scheduledActions?: ScheduledAction[];
apiActions?: APIAction[];
lifecycleActions?: LifecycleAction;
}
export interface ActionStats {
plugins: number;
eventActions: number;
scheduledActions: number;
apiActions: number;
lifecycleActions: number;
totalExecutions: number;
}
export declare class ActionRegistry {
private eventHandler;
private scheduledHandler;
private apiHandler;
private lifecycleHandler;
private registeredPlugins;
private options;
constructor(options?: ActionRegistryOptions);
/**
* Register all actions for a plugin
*/
registerPlugin(pluginId: string, actions: PluginActions): void;
/**
* Unregister all actions for a plugin
*/
unregisterPlugin(pluginId: string): void;
/**
* Register a single event action
*/
registerEventAction(pluginId: string, action: EventAction): void;
/**
* Register a single scheduled action
*/
registerScheduledAction(pluginId: string, action: ScheduledAction): void;
/**
* Register a single API action
*/
registerAPIAction(pluginId: string, action: APIAction): void;
/**
* Register lifecycle actions
*/
registerLifecycleActions(pluginId: string, actions: LifecycleAction): void;
/**
* Get the event handler
*/
getEventHandler(): EventActionHandler;
/**
* Get the scheduled action handler
*/
getScheduledHandler(): ScheduledActionHandler;
/**
* Get the API action handler
*/
getAPIHandler(): APIActionHandler;
/**
* Get the lifecycle action handler
*/
getLifecycleHandler(): LifecycleActionHandler;
/**
* Get actions for a specific plugin
*/
getPluginActions(pluginId: string): PluginActions | undefined;
/**
* Get all registered plugins
*/
getRegisteredPlugins(): string[];
/**
* Check if a plugin is registered
*/
isPluginRegistered(pluginId: string): boolean;
/**
* Enable a plugin's scheduled actions
*/
enablePluginScheduledActions(pluginId: string, context: PluginContext): void;
/**
* Disable a plugin's scheduled actions
*/
disablePluginScheduledActions(pluginId: string): void;
/**
* Execute a scheduled action immediately
*/
executeScheduledActionNow(pluginId: string, actionName: string, context: PluginContext): Promise<void>;
/**
* Get comprehensive statistics
*/
getStats(): ActionStats;
/**
* Get detailed statistics for a specific plugin
*/
getPluginStats(pluginId: string): {
eventActions: number;
scheduledActions: number;
apiActions: number;
hasLifecycleActions: boolean;
scheduledExecutions: number;
apiExecutions: number;
lifecycleExecutions: number;
};
/**
* Validate plugin actions before registration
*/
validatePluginActions(pluginId: string, actions: PluginActions): {
valid: boolean;
errors: string[];
warnings: string[];
};
/**
* Clear all registered actions
*/
clear(): void;
/**
* Start all scheduled actions for all plugins
*/
startAllScheduledActions(context: PluginContext): void;
/**
* Stop all scheduled actions
*/
stopAllScheduledActions(): void;
/**
* Get health status of the action registry
*/
getHealthStatus(): {
status: 'healthy' | 'degraded' | 'unhealthy';
details: {
eventHandler: string;
scheduledHandler: string;
apiHandler: string;
lifecycleHandler: string;
};
registeredPlugins: number;
lastError?: string;
};
}
export declare function createActionRegistry(options?: ActionRegistryOptions): ActionRegistry;
export declare function extractAllActions(pluginClass: any): PluginActions;
//# sourceMappingURL=action-registry.d.ts.map