import { Transform } from 'node:stream'; export type TransformCallback = Parameters[0]; /** * Options for the AsyncBatchTransform */ export type AsyncBatchTransformOptions = { /** Number of records to accumulate before processing a batch. Default: 10 */ batchSize?: number; /** Max concurrent batch processing tasks. Default: 4 */ concurrencyLimit?: number; /** Arbitrary context passed to the processing function */ context?: TContext; /** The async function that processes a batch of records and returns results */ processBatch: (batch: TRecord[], context: TContext) => Promise; }; /** * A Transform stream that batches records and processes them asynchronously * in the main thread using a concurrency-limited queue. * * This replaces the worker_threads-based BatchWorker to solve the ClassFactory * registration issue: worker threads run in separate V8 isolates and don't * share the main thread's class registrations, causing CreateInstance() to * return null. Since the bottleneck is I/O (embedding API calls, vector DB * upserts), not CPU, worker threads provide no benefit here. */ export declare class AsyncBatchTransform, TContext = Record, TResult = TRecord> extends Transform { private readonly _batchSize; private readonly _concurrencyLimit; private readonly _context; private readonly _processBatch; private _buffer; private _queue; private _running; private _drainResolve; constructor(options: AsyncBatchTransformOptions); private _next; private _enqueue; /** Returns a Promise that resolves when all queued tasks have completed */ private _waitForDrain; _transform(chunk: TRecord, _encoding: BufferEncoding, callback: TransformCallback): void; _flush(callback: TransformCallback): void; private _processBatchAsync; } //# sourceMappingURL=AsyncBatchTransform.d.ts.map