UNPKG

@re-shell/cli

Version:

Full-stack development platform uniting microservices and microfrontends. Build complete applications with .NET (ASP.NET Core Web API, Minimal API), Java (Spring Boot, Quarkus, Micronaut, Vert.x), Rust (Actix-Web, Warp, Rocket, Axum), Python (FastAPI, Dja

128 lines (127 loc) 4.49 kB
import { EventEmitter } from 'events'; export declare enum HookType { CLI_INIT = "cli:init", CLI_EXIT = "cli:exit", CLI_ERROR = "cli:error", COMMAND_BEFORE = "command:before", COMMAND_AFTER = "command:after", COMMAND_ERROR = "command:error", COMMAND_REGISTER = "command:register", WORKSPACE_CREATE = "workspace:create", WORKSPACE_UPDATE = "workspace:update", WORKSPACE_DELETE = "workspace:delete", WORKSPACE_BUILD = "workspace:build", FILE_CHANGE = "file:change", FILE_CREATE = "file:create", FILE_DELETE = "file:delete", FILE_WATCH = "file:watch", BUILD_START = "build:start", BUILD_END = "build:end", BUILD_ERROR = "build:error", BUILD_SUCCESS = "build:success", PLUGIN_LOAD = "plugin:load", PLUGIN_ACTIVATE = "plugin:activate", PLUGIN_DEACTIVATE = "plugin:deactivate", CONFIG_LOAD = "config:load", CONFIG_SAVE = "config:save", CONFIG_VALIDATE = "config:validate", CUSTOM = "custom" } export declare enum HookPriority { HIGHEST = 1, HIGH = 25, NORMAL = 50, LOW = 75, LOWEST = 100 } export interface HookHandler { id: string; pluginName: string; handler: Function; priority: HookPriority; once?: boolean; condition?: (data: any) => boolean; description?: string; metadata?: Record<string, any>; } export interface HookContext { hookType: HookType; pluginName: string; timestamp: number; data: any; result?: any; error?: Error; aborted?: boolean; metadata?: Record<string, any>; } export interface HookResult { success: boolean; results: any[]; errors: Array<{ pluginName: string; error: Error; }>; aborted: boolean; executionTime: number; context: HookContext; } export interface HookRegistrationOptions { priority?: HookPriority; once?: boolean; condition?: (data: any) => boolean; description?: string; metadata?: Record<string, any>; } export interface HookMiddleware { name: string; before?: (context: HookContext) => Promise<void> | void; after?: (context: HookContext, result: any) => Promise<void> | void; error?: (context: HookContext, error: Error) => Promise<void> | void; } export declare class PluginHookSystem extends EventEmitter { private hooks; private middleware; private executionStats; private isEnabled; private debugMode; constructor(options?: { debugMode?: boolean; }); private initializeBuiltinHooks; register(hookType: HookType | string, handler: Function, pluginName: string, options?: HookRegistrationOptions): string; unregister(hookType: HookType | string, handlerId: string): boolean; unregisterAll(pluginName: string): number; execute(hookType: HookType | string, data?: any): Promise<HookResult>; executeSync(hookType: HookType | string, data?: any): any[]; addMiddleware(middleware: HookMiddleware): void; removeMiddleware(name: string): boolean; private executeMiddleware; getHooks(hookType?: HookType | string): Map<HookType, HookHandler[]> | HookHandler[]; getPluginHooks(pluginName: string): HookHandler[]; getStats(): any; private updateExecutionStats; private generateHandlerId; setEnabled(enabled: boolean): void; setDebugMode(debug: boolean): void; clear(): void; createPluginScope(pluginName: string): PluginHookAPI; } export declare class PluginHookAPI { private hookSystem; private pluginName; constructor(hookSystem: PluginHookSystem, pluginName: string); register(hookType: HookType | string, handler: Function, options?: HookRegistrationOptions): string; unregister(hookType: HookType | string, handlerId: string): boolean; execute(hookType: HookType | string, data?: any): Promise<HookResult>; executeSync(hookType: HookType | string, data?: any): any[]; getHooks(): HookHandler[]; registerCustomHook(name: string): string; onCommand(command: string, handler: Function, options?: HookRegistrationOptions): string; onFileChange(pattern: RegExp | string, handler: Function, options?: HookRegistrationOptions): string; onWorkspaceBuild(workspace: string, handler: Function, options?: HookRegistrationOptions): string; } export declare function createHookSystem(options?: { debugMode?: boolean; }): PluginHookSystem; export declare function isValidHookType(hookType: string): boolean; export { HookType as BuiltinHooks };