import { type Transformer } from '@atproto-labs/pipe'; import { FetchError } from './fetch-error.js'; import { type Json } from './util.js'; export type ResponseTransformer = Transformer; export type ResponseMessageGetter = Transformer; export declare class FetchResponseError extends FetchError { readonly response: Response; constructor(response: Response, statusCode?: number, message?: string, options?: ErrorOptions); static from(response: Response, customMessage?: string | ResponseMessageGetter, statusCode?: number, options?: ErrorOptions): Promise; } export declare function peekJson(response: Response, maxSize?: number): Promise; export declare function checkLength(response: Response, maxBytes: number): number | undefined; export declare function extractLength(response: Response): number | undefined; export declare function extractMime(response: Response): string | undefined; /** * If the transformer results in an error, ensure that the response body is * consumed as, in some environments (Node 👀), the response will not * automatically be GC'd. * * @see {@link https://undici.nodejs.org/#/?id=garbage-collection} * @param [onCancellationError] - Callback to handle any async body cancelling * error. Defaults to logging the error. Do not use `null` if the request is * cloned. */ export declare function cancelBodyOnError(transformer: Transformer, onCancellationError?: null | ((err: unknown) => void)): (response: Response) => Promise; export declare function fetchOkProcessor(customMessage?: string | ResponseMessageGetter): ResponseTransformer; export declare function fetchOkTransformer(response: Response, customMessage?: string | ResponseMessageGetter): Promise; export declare function fetchMaxSizeProcessor(maxBytes: number): ResponseTransformer; export declare function fetchResponseMaxSizeChecker(response: Response, maxBytes: number): Response; export type MimeTypeCheckFn = (mimeType: string) => boolean; export type MimeTypeCheck = string | RegExp | MimeTypeCheckFn; export declare function fetchTypeProcessor(expectedMime: MimeTypeCheck, contentTypeRequired?: boolean): ResponseTransformer; export declare function fetchResponseTypeChecker(response: Response, isExpectedMime: MimeTypeCheckFn, contentTypeRequired?: boolean): Promise; export type ParsedJsonResponse = { response: Response; json: T; }; export declare function fetchResponseJsonTransformer(response: Response): Promise>; export declare function fetchJsonProcessor(expectedMime?: MimeTypeCheck, contentTypeRequired?: boolean): Transformer>; export type SyncValidationSchema = { parse(value: unknown, params?: P): S; }; export type AsyncValidationSchema = { parseAsync(value: unknown, params?: P): Promise; }; export declare function fetchJsonValidatorProcessor(schema: SyncValidationSchema | AsyncValidationSchema, params?: P): Transformer; /** @note Use {@link fetchJsonValidatorProcessor} instead */ export declare const fetchJsonZodProcessor: typeof fetchJsonValidatorProcessor; //# sourceMappingURL=fetch-response.d.ts.map