import type { SocketTarget } from "./endpoints.ts"; /** * Options accepted by {@link downloadLog}: the connection target plus the raw token, an injectable `fetch` seam, and an optional abort signal. * * @property fetch - The fetch implementation to use. Defaults to the global `fetch`. Injected so the download flow is testable without a live server. * @property host - The hostname or IP of the homebridge-config-ui-x server. * @property port - The TCP port the server listens on. * @property signal - Optional abort signal forwarded to the underlying `fetch`. When it aborts, the in-flight request and the body reader are both cancelled so the * connection is released immediately rather than draining to completion in the background. A pre-aborted signal short-circuits the download before any * request is made (the platform `fetch` rejects synchronously). * @property tls - When `true`, use the secure (`https`) scheme; when `false` or omitted, plaintext (`http`). * @property token - The raw bearer token, sent as `Authorization: Bearer `. * * @category Log Client */ export interface DownloadLogOptions extends SocketTarget { readonly fetch?: typeof fetch; readonly signal?: AbortSignal; } /** * Download the entire Homebridge log file over REST and yield it as raw lines. * * Streams `GET /api/platform-tools/hb-service/log/download?colour=yes` through the shared {@link LogLineSplitter}, yielding each raw line (ANSI intact) as it becomes * available, and flushing the splitter at end-of-response so the file's final line is never stranded. The whole-file download is the deep-history channel: the server * exposes no tail/range parameter, so a caller that only wants the most recent N lines drains this iterable and retains the tail (e.g., via `takeLast`). * * When `options.signal` is supplied, the download is abortable: aborting the signal cancels the in-flight `fetch` and the body reader so the connection is released * immediately rather than draining in the background, and a pre-aborted signal short-circuits before any request is made. This is what lets the windowed hedge supersede * a speculative deep-history download the moment the socket seed is shown to cover the window. * * @param options - The connection target, the raw token, the injectable `fetch` seam, and the optional abort signal. See {@link DownloadLogOptions}. * * @returns An async iterable of raw log lines (escapes intact, terminators removed), in file order. * * @throws `Error` when the server returns a 400 (the log method is not file-backed, so there is no file to download - the message advises `--follow`), or any other * non-2xx status, or when the response carries no body. Propagates `options.signal`'s reason (typically an `HbpuAbortError`) when the signal aborts. * * @category Log Client */ export declare function downloadLog(options: DownloadLogOptions): AsyncIterable; //# sourceMappingURL=rest.d.ts.map