import { C as Contribuyente, N as NcfQueryResult } from './index-KNOaUG34.js'; interface RetryOptions { /** Número máximo de reintentos (por defecto: 2) */ maxRetries: number; /** Delay base en milisegundos (por defecto: 500) */ baseDelayMs: number; /** Delay máximo en milisegundos (por defecto: 10000) */ maxDelayMs: number; } /** * Determina si un error es reintentable. * * - DgiiConnectionError: siempre reintentable * - DgiiServiceError con statusCode >= 500: reintentable * - DgiiNotFoundError: nunca reintentable (resultado de negocio) * - DgiiServiceError con 403/4xx: nunca reintentable */ declare function isRetryableError(error: unknown): boolean; /** * Ejecuta una función con reintentos y backoff exponencial * con jitter completo. * * Fórmula: delay = random(0, min(maxDelay, baseDelay * 2^attempt)) */ declare function withRetry(fn: () => Promise, options?: RetryOptions): Promise; interface CircuitBreakerOptions { /** Fallos consecutivos para abrir el circuito (por defecto: 5) */ failureThreshold: number; /** Tiempo en ms antes de probar de nuevo (por defecto: 60000) */ recoveryTimeoutMs: number; /** Éxitos consecutivos en HALF_OPEN para cerrar (por defecto: 2) */ successThreshold: number; } type CircuitState = 'CLOSED' | 'OPEN' | 'HALF_OPEN'; /** * Circuit breaker basado en fallos consecutivos. * * - CLOSED: operación normal, se cuentan fallos consecutivos * - OPEN: rechaza inmediatamente, espera recoveryTimeoutMs * - HALF_OPEN: permite llamadas de prueba, cierra después * de successThreshold éxitos consecutivos */ declare class ConsecutiveBreaker { private _state; private _failures; private _successes; private _lastFailureTime; private readonly _options; constructor(options?: Partial); get state(): CircuitState; execute(fn: () => Promise): Promise; reset(): void; private _onSuccess; private _onFailure; } interface ClientOptions { /** Tiempo de espera en milisegundos (por defecto: 15000) */ timeout?: number; /** Habilitar fallback a SOAP (por defecto: true) */ soapFallback?: boolean; /** Opciones de reintentos */ retry?: Partial; /** Opciones del circuit breaker */ circuitBreaker?: Partial; } /** * Cliente resiliente para consultas a la DGII. * * Usa web scraping como estrategia principal y SOAP como * fallback (con circuit breaker y reintentos automáticos). */ declare class DgiiClient { private readonly _scraping; private readonly _soap; private readonly _scrapingBreaker; private readonly _soapBreaker; private readonly _retryOptions; private readonly _soapFallback; constructor(options?: ClientOptions); /** * Consulta datos de un contribuyente por RNC o cédula. */ getContribuyente(rnc: string): Promise; /** * Valida un comprobante fiscal (NCF) contra la DGII. */ getNCF(rnc: string, ncf: string): Promise; private _executeWithFallback; } export { type CircuitBreakerOptions, type ClientOptions, ConsecutiveBreaker, DgiiClient, type RetryOptions, isRetryableError, withRetry };