declare interface JSONStreamOptions { /** Maximum size in bytes for a single SSE line. Defaults to 8192. */ maxBuffer?: number; /** A custom string that, when received as a data payload, terminates the stream. */ donePrefix?: string; /** Whether to parse the JSON data payload. If false, outputs strings. Defaults to true. */ parseData?: boolean; /** * How to handle lines that exceed maxBuffer. * - 'skip': Reset buffer and skip the line (default, resilient). * - 'throw': Immediately throw a RangeError to signal a protocol violation. */ onBufferOverflow?: "skip" | "throw"; /** * How to handle payloads that are not valid JSON. * - 'skip': Log a warning and skip the payload (default). * - 'throw': Terminate the stream with a TypeError. */ onParseError?: "skip" | "throw"; } /** * A TransformStream that parses Server-Sent Events (SSE) with JSON payloads. * This implementation is designed for high-security and high-throughput environments. * * CORE PRINCIPLES: * - Security: Fails fast on malformed input, never leaks data in errors, and zeroes out * its internal buffer upon completion to prevent data exposure. * - Performance: Operates with zero allocations and zero-copy operations during * the transformation of each chunk, making it highly memory-efficient. * - Robustness: Handles various line endings, buffer overflows, and invalid JSON * gracefully according to the configured options. */ export declare class JSONStreamTransformer extends TransformStream { constructor(options?: JSONStreamOptions); } /** * A robust fetch wrapper with built-in retry, backoff, and streaming capabilities. * * @template T The expected type of the response data. * @param {string | URL} url The URL to fetch. * @param {StrettoOptions} [options] The options object for configuring the fetch request. * @returns {Promise>} A promise that resolves to a StrettoStreamableResponse. */ declare function stretto(url: string | URL, options?: StrettoOptions): Promise>; export default stretto; /** Configuration options for a Stretto request. */ declare interface StrettoOptions extends Omit { /** The maximum number of retry attempts. Defaults to 3. */ retries?: number; /** The timeout in milliseconds for the entire request, including retries. Defaults to 30000. */ timeout?: number; /** * A function that calculates the backoff delay before a retry. * @param {number} attempt The current retry attempt number. */ backoffStrategy?: (attempt: number) => number; /** * A function to determine if a request should be retried. * @param {unknown} error The error caught during the fetch attempt. * @param {Response} [response] The response object if the request completed. */ retryOn?: (error: unknown, response?: Response) => boolean; /** Set to true to enable response streaming. Defaults to false. */ stream?: boolean; /** An array of TransformStream instances to pipe the response through. */ transformers?: TransformStream[]; /** An optional AbortSignal to allow for external cancellation of the request. */ signal?: AbortSignal; } /** The Response object, augmented with async iterable capabilities. */ declare type StrettoStreamableResponse = Response & AsyncIterable; export { }