import type { FactoryOptions, ForwardSource } from './base.ts'; /** * A function that produces a fresh readable stream each time it is called. A * forward reader invokes it once up front, and again on every re-acquisition, so * it is also the seam for per-acquisition customization (a freshly minted auth * token, a new `AbortSignal`, etc.). */ export type ReadableProducer = () => NodeJS.ReadableStream | ReadableStream | Promise>; export interface ReadableOptions extends FactoryOptions { /** Known total length, if any. Forwarded to the engine so it can skip rediscovering the end. */ size?: number; /** Transform applied to every (re)acquired stream, e.g. `s => s.pipeThrough(new DecompressionStream('gzip'))`. */ decode?: (raw: ReadableStream) => ReadableStream; /** * What a later query that must re-read from an earlier offset does. Defaults * to `'forbid'`. The three settings trade resident memory for re-read ability: * - `'forbid'`: a single forward pass; a rewind throws {@link ForwardReplayError}. * - `'replay'`: re-acquire the stream from the start. Only safe when the * producer is idempotent (yields the same bytes each call). No extra memory. * - `'buffer'`: snapshot the whole stream into memory on first read, enabling * random access at O(n) resident memory. */ rewind?: 'forbid' | 'replay' | 'buffer'; } export interface HttpRequestOptions extends Omit { /** Merged into every `fetch` (headers, credentials, signal, etc.). */ init?: RequestInit; } /** * A forward-only source backed by a re-openable readable stream. `produce` is * called to acquire each pass: once up front, and again on a rewind when * `rewind: 'replay'` is set. A plain `Readable` instance cannot be re-streamed, * so pass a thunk (`() => createReadStream(path)`), not a live stream. * * Because every cursor operation is an independent scan from the start, a single * forward pass serves exactly one query; a second query (or `hop` then `get`) * rewinds. By default that throws {@link ForwardReplayError}; opt into * `rewind: 'replay'` (idempotent producer) or `rewind: 'buffer'` (in-memory * snapshot) for multi-query access. */ export declare function fromReadable(produce: ReadableProducer, options?: ReadableOptions): ForwardSource; /** * A forward-only source over an HTTP request (GET is default), streamed in a single pass. A * convenience wrapper around {@link fromReadable} whose producer re-fetches `url` * (reusing `init`, so auth headers, credentials, and an `AbortSignal` survive * each acquisition). For repeated or random access over HTTP, prefer the seekable * {@link fromHttpRange}. */ export declare function fromHttpRequest(url: string, options?: HttpRequestOptions): ForwardSource;