import { TimeoutAbort } from "./timeout/index.js"; export * from "./node.js"; export * from "./timeout/index.js"; /** * Interface defining options for managing timeouts in a fetch request. */ export interface TimeoutOptions { /** * Request timeout in milliseconds. This will set a maximum lifespan for the request. */ requestTimeout?: number | null; /** * Idle timeout in milliseconds. Resets each time data is received, aborting the request if no data is received within the specified duration. */ idleTimeout?: number | null; } /** * Class representing a response object with optional timeout management for its body stream. */ export declare class TimeoutResponse { private readonly response; private timeoutAbort?; private readonly createBody?; private _body?; /** * You should not new a `TimeoutResponse` on your own. */ constructor(response: Response, timeoutAbort?: TimeoutAbort | undefined, createBody?: (() => ReadableStream) | undefined); /** * Getter for response headers. */ get headers(): Headers; /** * Getter for the `ok` status of the response. */ get ok(): boolean; /** * Getter for whether the response was redirected. */ get redirected(): boolean; /** * Getter for the response status code. */ get status(): number; /** * Getter for the status text of the response. */ get statusText(): string; /** * Getter for the response type. */ get type(): ResponseType; /** * Getter for the response URL. */ get url(): string; /** * If you want to cancel the body, use this function instead of `body.cancel()` or `body.getReader().cancel()`. */ cancelBody(): Promise; /** * Getter for the body stream of the response. If `createBody` is provided, it will be used to create a body stream with timeout management. */ get body(): ReadableStream | null; /** * Getter for whether the body has already been used. */ get bodyUsed(): boolean; /** * Reads and returns the body content as a string. * * @returns {Promise} The body content in text form. */ text(): Promise; /** * Reads and parses the body content as JSON. * * @template T The expected JSON type. * @returns {Promise} The parsed JSON object. */ json(): Promise; } /** * Options for the fetch request, including request timeout and idle timeout. */ export type TimeoutRequestInit = Omit & TimeoutOptions & { duplex?: "half"; }; /** * A utility function to perform a fetch request with optional request and idle timeouts. * * @param {string | URL} input The URL or request input for the fetch. * @param {TimeoutRequestInit} [init] Options for the fetch request, including request timeout and idle timeout. * * @returns {Promise} A `TimeoutResponse` instance wrapping the fetch response. * * @throws {AbortError} If the request is aborted due to a timeout. */ export declare const timeoutFetch: (input: string | URL, init?: TimeoutRequestInit) => Promise; /** * Utility function to check if an error is of type `AbortError`. * * @param {Error} error The error to check. * * @returns {boolean} `true` if the error is an `AbortError`, otherwise `false`. */ export declare const isAbortError: (error: Error) => boolean;