import { ObjectWritable, ObjectWritableOptions, WriteCallback, BatchData } from "batchjs"; /** * @interface * Options for the AbstractBatchEntityWriterStream. * @extends ObjectWritableOptions */ export interface AbstractBatchEntityWriterStreamOptions extends ObjectWritableOptions { batchSize: number; } /** * @class * Class that enable to implement classes to write data in batches of a specified size in different types of data storage. * @extends ObjectWritable * @template T */ export declare abstract class AbstractBatchEntityWriterStream extends ObjectWritable { protected buffer: BatchData; private readonly batchSize; /** * @constructor * @param {AbstractBatchEntityWriterStreamOptions} options - The options for the AbstractBatchEntityWriterStream. * @param [options.batchSize] {number} - The maximum number of elements in a batch. */ constructor(options: AbstractBatchEntityWriterStreamOptions); /** * A method to write data to the stream, push the chunk to the buffer, and execute the callback. * * @param {T} chunk - The data chunk to write to the stream. * @param {BufferEncoding} encoding - The encoding of the data. * @param {WriteCallback} callback - The callback function to be executed after writing the data. */ _write(chunk: T, encoding: BufferEncoding, callback: WriteCallback): void; /** * Finalizes the stream by pushing remaining data batches, handling errors, * and executing the final callback. * * @param {WriteCallback} callback - The callback function to be executed after finalizing the stream. * @return {Promise} This function does not return anything. */ _final(callback: WriteCallback): void; /** * Creates a batch of data from the buffer and flushes it to the storage. * * @private * @returns {Promise} */ private _flush; /** * Writes a batch of data to the storage. This method should be implemented * by subclasses to define the specific logic for writing a batch of data. * * @protected * @abstract * @param {BatchData} chunk - The batch of data to write to the storage. * @returns {Promise} A promise that resolves when the batch is successfully written. * The promise should be rejected if there is an error during writing. */ protected abstract batchWrite(chunk: BatchData): Promise; }