import { PlainObject } from '@xh/hoist/core'; import type { FetchException, NdjsonFetchOptions, NdjsonResult } from '../FetchService'; import { StringInterner } from './StringInterner'; /** * Decodes a streamed NDJSON Response body into parsed records - implementation helper * for {@link FetchService.fetchNdjson}, which remains the public entry point and injects all * service-level concerns via constructor arguments. Implements {@link NdjsonResult} and is * returned to callers directly. * * @internal */ export declare class NdjsonResultImpl implements NdjsonResult { private response; private interner; private enrichError; /** Marker written by hoist-core's `renderNdjson` when a stream fails after committing. */ private static readonly POISON; /** Parsed data records - see {@link NdjsonResult.lines}. */ readonly lines: AsyncGenerator; /** Leading metadata record - see {@link NdjsonResult.meta}. */ readonly meta: Promise | null; /** * Settles when streaming has finished - resolving after complete consumption or early * termination by the consumer, rejecting on a streaming-phase failure. Request-phase * failures are not reported here - see {@link whenCompleteAsync}, which covers both phases. */ private completion; private onComplete; constructor(response: Promise, opts: NdjsonFetchOptions, interner: StringInterner, enrichError: (cause: any, response: Response) => FetchException); /** * Resolves once the request has completed and its stream has been fully consumed (or the * consumer exited early) - rejects on a failure in either phase. Use to track the full * lifetime of the stream, e.g. for spanning and telemetry. */ whenCompleteAsync(): Promise; /** * Await the pending request, then stream its body one record at a time - wrapping any * failure raised while reading or parsing the stream via the configured `enrichError`. * * Settles `completion` on exit - see that property for its exact semantics. */ private stream; /** * Read an NDJSON Response body incrementally, yielding parsed records as they arrive off * the network. Each line is parsed with native JSON.parse, partial trailing lines are * carried across chunk boundaries, and no more than one network chunk of raw text is * buffered. * * Note the final-buffer parse below doubles as truncation detection - a stream cut short by * a server-side failure ends with an unparseable line (see fetchNdjson) and throws here. */ private records; /** * Delegate to the remaining stream once the eagerly-read meta record has settled. */ private linesAfterMeta; }