UNPKG

hook-engine

Version:

Production-grade webhook engine with comprehensive adapter support, security, reliability, structured logging, and CLI tools.

54 lines (53 loc) 1.38 kB
import { WebhookEvent } from '../types/webhook'; import { HookEngineConfig } from '../types/config'; /** * Processing result interface */ export interface ProcessingResult { success: boolean; event?: WebhookEvent; error?: string; message: string; duration: number; attempts?: number; } /** * Main hook engine class */ export declare class HookEngine { private config; private errorHandler; private retryEngine; private storage; constructor(userConfig: Partial<HookEngineConfig>); /** * Process incoming webhook request */ processWebhook(req: any): Promise<ProcessingResult>; /** * Process webhook with custom business logic and retry */ processWebhookWithRetry(req: any, businessLogic: (event: WebhookEvent) => Promise<void>): Promise<ProcessingResult>; /** * Get engine statistics */ getStats(): { retry: { circuitBreakerState: "closed" | "open" | "half-open"; failureCount: number; retryBudget: number; budgetResetTime: Date; }; errors: Record<string, { count: number; lastOccurrence: number; }>; storage: any; }; /** * Shutdown the engine gracefully */ shutdown(): Promise<void>; private parseWebhookEvent; private determineSource; }