import type { ID } from '../../common/types.js';
import type { WebhookDelivery, WebhookDeliveryStatus, CreateDeliveryOptions, UpdateDeliveryStatusOptions } from './types.js';
/**
 * Calculate next retry time with exponential backoff.
 *
 * Uses the formula: baseDelay * 2^(attempt - 1)
 * With a maximum delay cap to prevent extremely long waits.
 *
 * @param attempt - Current attempt number (1-based)
 * @param baseDelayMs - Base delay in milliseconds (default: 1000)
 * @param maxDelayMs - Maximum delay cap in milliseconds (default: 1 hour)
 * @returns Date when next retry should occur
 */
export declare function calculateNextRetryTime(attempt: number, baseDelayMs?: number, maxDelayMs?: number): Date;
/**
 * Repository for managing webhook delivery persistence.
 */
export declare class WebhookDeliveryRepository {
    private _db;
    /**
     * Get database instance (lazy initialization).
     */
    private get db();
    /**
     * Create a new delivery record.
     */
    createDelivery(data: CreateDeliveryOptions): Promise<WebhookDelivery>;
    /**
     * Update delivery status with details.
     */
    updateDeliveryStatus(id: ID, options: UpdateDeliveryStatusOptions): Promise<WebhookDelivery>;
    /**
     * Get delivery by ID.
     */
    getDeliveryById(id: ID): Promise<WebhookDelivery | null>;
    /**
     * Get delivery history for a webhook.
     */
    getDeliveryHistory(webhookId: ID, limit?: number): Promise<WebhookDelivery[]>;
    /**
     * Get pending retries that are due for processing.
     */
    getPendingRetries(limit?: number): Promise<WebhookDelivery[]>;
    /**
     * Get failed deliveries for a tenant.
     */
    getFailedDeliveries(tenantId: ID, limit?: number): Promise<WebhookDelivery[]>;
    /**
     * Get deliveries by tenant with pagination.
     */
    getDeliveriesByTenant(tenantId: ID, options?: {
        limit?: number;
        offset?: number;
        status?: WebhookDeliveryStatus;
    }): Promise<{
        items: WebhookDelivery[];
        hasMore: boolean;
    }>;
    /**
     * Mark a delivery for immediate replay.
     */
    markForReplay(id: ID): Promise<WebhookDelivery>;
    /**
     * Clean up old delivery records.
     */
    cleanupOldDeliveries(retentionDays: number): Promise<number>;
}
/**
 * Create webhook delivery repository instance
 */
export declare function createWebhookDeliveryRepository(): WebhookDeliveryRepository;
//# sourceMappingURL=delivery-repository.d.ts.map