import { type RetryOptions } from "./retryWithBackoff.js"; /** * Result of a single batch operation */ export interface BatchResult { /** * Operation status */ status: "success" | "failed"; /** * Original item */ item: T; /** * Operation result (if successful) */ result?: R; /** * Error (if failed) */ error?: Error; } /** * Options for batch processing */ export interface BatchOptions { /** * Items to process */ items: T[]; /** * Number of items to process in each batch (default: 10) */ batchSize?: number; /** * Maximum number of concurrent operations within a batch (default: 5) */ maxConcurrent?: number; /** * Operation to perform on each item */ operation: (item: T) => Promise; /** * Callback invoked after each item completes (success or failure) * @param completed - Number of items completed so far * @param total - Total number of items */ onProgress?: (completed: number, total: number) => void; /** * Whether to continue processing if an item fails (default: true) */ continueOnError?: boolean; /** * Retry options for each operation */ retryOptions?: RetryOptions; } /** * Process items in controlled batches with retry support. * * Features: * - Controlled concurrency (max N operations in parallel) * - Batch processing (process items in groups) * - Automatic retry with exponential backoff * - Progress tracking * - Error isolation (one failure doesn't stop others) * * @param options - Batch processing options * @returns Array of results with status for each item * * @example * ```typescript * const results = await processBatch({ * items: entries, * batchSize: 10, * maxConcurrent: 5, * continueOnError: true, * retryOptions: { * maxRetries: 3, * retryableStatusCodes: [429, 503], * }, * onProgress: (completed, total) => { * console.log(`Progress: ${completed}/${total}`); * }, * operation: async (entry) => { * return await createEntry(entry); * }, * }); * * const successCount = results.filter(r => r.status === 'success').length; * const failCount = results.filter(r => r.status === 'failed').length; * ``` */ export declare function processBatch(options: BatchOptions): Promise>>; //# sourceMappingURL=concurrentBatch.d.ts.map