UNPKG

@spaik/mcp-server-roi

Version:

MCP server for AI ROI prediction and tracking with Monte Carlo simulations

84 lines 2.79 kB
import { PostgrestError } from '@supabase/supabase-js'; export declare enum ErrorCode { TRANSACTION_FAILED = "TRANSACTION_FAILED", CONSTRAINT_VIOLATION = "CONSTRAINT_VIOLATION", FOREIGN_KEY_VIOLATION = "FOREIGN_KEY_VIOLATION", UNIQUE_VIOLATION = "UNIQUE_VIOLATION", VALIDATION_FAILED = "VALIDATION_FAILED", INVALID_INPUT = "INVALID_INPUT", MISSING_REQUIRED_FIELD = "MISSING_REQUIRED_FIELD", PROJECT_NOT_FOUND = "PROJECT_NOT_FOUND", INSUFFICIENT_DATA = "INSUFFICIENT_DATA", CALCULATION_ERROR = "CALCULATION_ERROR", UNKNOWN_ERROR = "UNKNOWN_ERROR", TIMEOUT_ERROR = "TIMEOUT_ERROR", NETWORK_ERROR = "NETWORK_ERROR" } export declare class ROIError extends Error { code: ErrorCode; details?: any | undefined; originalError?: Error | undefined; constructor(code: ErrorCode, message: string, details?: any | undefined, originalError?: Error | undefined); toJSON(): { code: ErrorCode; message: string; details: any; timestamp: string; }; } export declare class TransactionError extends ROIError { rollbackRequired: boolean; constructor(message: string, rollbackRequired?: boolean, details?: any, originalError?: Error); } export declare class ValidationError extends ROIError { fields: Array<{ field: string; message: string; }>; constructor(message: string, fields: Array<{ field: string; message: string; }>, details?: any); } /** * Converts Supabase/PostgreSQL errors to ROIError */ export declare function handleDatabaseError(error: PostgrestError | Error): ROIError; /** * Error recovery strategies */ export interface RecoveryStrategy { canRecover: (error: ROIError) => boolean; recover: (error: ROIError, context?: any) => Promise<any>; } export declare class ErrorRecovery { private strategies; register(code: ErrorCode, strategy: RecoveryStrategy): void; tryRecover(error: ROIError, context?: any): Promise<any>; } export declare const errorRecovery: ErrorRecovery; /** * Wraps an async function with error handling and optional recovery */ export declare function withErrorHandling<T extends (...args: any[]) => Promise<any>>(fn: T, options?: { errorTransform?: (error: Error) => ROIError; enableRecovery?: boolean; recoveryContext?: any; }): T; /** * Transaction rollback helper */ export interface RollbackAction { description: string; execute: () => Promise<void>; } export declare class TransactionRollback { private actions; add(action: RollbackAction): void; execute(): Promise<void>; } /** * Logs errors with context for debugging */ export declare function logError(error: Error | ROIError, context?: any): void; //# sourceMappingURL=error-handler.d.ts.map