UNPKG

phonic

Version:

[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2FPhonic-Co%2Fphonic-node) [![npm shield](htt

41 lines (40 loc) 1.45 kB
import { APIResponse } from "./APIResponse.js"; import { Supplier } from "./Supplier.js"; export type FetchFunction = <R = unknown>(args: Fetcher.Args) => Promise<APIResponse<R, Fetcher.Error>>; export declare namespace Fetcher { interface Args { url: string; method: string; contentType?: string; headers?: Record<string, string | Supplier<string | null | undefined> | null | undefined>; queryParameters?: Record<string, unknown>; body?: unknown; timeoutMs?: number; maxRetries?: number; withCredentials?: boolean; abortSignal?: AbortSignal; requestType?: "json" | "file" | "bytes"; responseType?: "json" | "blob" | "sse" | "streaming" | "text" | "arrayBuffer" | "binary-response"; duplex?: "half"; } type Error = FailedStatusCodeError | NonJsonError | TimeoutError | UnknownError; interface FailedStatusCodeError { reason: "status-code"; statusCode: number; body: unknown; } interface NonJsonError { reason: "non-json"; statusCode: number; rawBody: string; } interface TimeoutError { reason: "timeout"; } interface UnknownError { reason: "unknown"; errorMessage: string; } } export declare function fetcherImpl<R = unknown>(args: Fetcher.Args): Promise<APIResponse<R, Fetcher.Error>>; export declare const fetcher: FetchFunction;