UNPKG

supa-seed

Version:

A constraint-aware, framework-agnostic database seeding framework with deep PostgreSQL business logic discovery and MakerKit integration support

95 lines 2.94 kB
/** * Graceful Degradation System * Phase 6, Checkpoint F1 - Ensures system functionality even when AI services fail */ export interface ServiceHealth { serviceName: string; isHealthy: boolean; lastCheck: Date; consecutiveFailures: number; averageResponseTime: number; errorRate: number; lastError?: string; } export interface FallbackStrategy { serviceName: string; fallbackMethod: 'faker' | 'static' | 'cached' | 'simplified' | 'disabled'; priority: number; description: string; implementation: () => Promise<any>; } export interface CircuitBreakerConfig { failureThreshold: number; resetTimeoutMs: number; monitoringPeriodMs: number; halfOpenMaxCalls: number; } export declare class GracefulDegradation { private static serviceHealth; private static fallbackStrategies; private static circuitBreakers; private static degradationConfig; /** * Initialize graceful degradation system */ static initialize(): void; /** * Set circuit breaker configuration for a service */ static setCircuitBreakerConfig(serviceName: string, config: CircuitBreakerConfig): void; /** * Register a fallback strategy for a service */ static registerFallbackStrategy(operationName: string, strategy: FallbackStrategy): void; /** * Execute operation with graceful degradation */ static executeWithFallback<T>(serviceName: string, operationName: string, primaryOperation: () => Promise<T>, context?: Record<string, any>): Promise<T>; /** * Execute fallback strategy for an operation */ private static executeFallback; /** * Record successful operation */ private static recordSuccess; /** * Record failed operation */ private static recordFailure; /** * Check if circuit breaker is open */ private static isCircuitOpen; /** * Get or create service health record */ private static getOrCreateServiceHealth; /** * Get system degradation status */ static getDegradationStatus(): { services: Array<ServiceHealth & { circuitBreakerState: string; }>; activeFallbacks: string[]; systemHealth: 'healthy' | 'degraded' | 'critical'; recommendations: string[]; }; /** * Force reset circuit breaker */ static resetCircuitBreaker(serviceName: string): boolean; /** * Fallback implementations */ private static fakerFallback; private static staticTemplateFallback; private static simplifiedSchemaAnalysis; } /** * Decorator for automatic graceful degradation */ export declare function withGracefulDegradation(serviceName: string, operationName?: string): (target: any, propertyName: string, descriptor: PropertyDescriptor) => void; export default GracefulDegradation; //# sourceMappingURL=graceful-degradation.d.ts.map