import { z } from "zod"; import type { ApiType } from "../types.js"; import type { ClientTransport } from "./client.js"; import type { FetcherRequest } from "./fetcher.js"; export { determineIfIsFetcherError, type FetcherError, FetcherRequestErrorClass, getErrorWithReasonErrorMessage, } from "./error.js"; export type FetcherOrigin = { name: string; version?: string; }; export type FetcherDependencies = { baseUrl: string; workspaceUuid?: string; appUuid?: string; getAccessToken?: (refresh?: boolean) => Promise; accessToken?: string; origin?: FetcherOrigin; /** * Optional transport overrides forwarded to the HTTP client, e.g. a * proxy-tunneling `fetch` supplied by Node callers behind a proxy. */ transport?: ClientTransport; /** * Retry a 401 once with a freshly renewed token. Off by default: a caller * that handles 401 itself (the web app signs the user out, or redirects) * must keep seeing the response the server actually sent, and a forced * renewal there has side effects of its own. * * Worth turning on where the token's claims can go stale between sign-ins, * as they do for the long-lived CLI session. */ retryOnUnauthorized?: boolean; }; export type { ClientTransport }; export type FetcherUploadFilePayload = { formData: FormData; onProgress: (progressPercentage: number) => void; onComplete: (payload: { uuid?: string; s3Filename: string; contentType: string; name: string; }) => void; onError: () => void; }; export declare const zodFetcherUploadFileErrorReason: z.ZodEnum<{ noFile: "noFile"; }>; export type FetcherBlobRequest = { endpoint: string; params?: Record; forceTokenRefresh?: boolean; withoutWorkspace?: boolean; }; export type Fetcher = { baseUrl: string; /** * Transport config (e.g. a proxy-tunneling `fetch`) passed at build time. * Exposed so consumers (e.g. workspaceManagement multipart uploads) reuse * the same transport for their own requests to third-party hosts (S3 * presigned URLs). Undefined in browser builds. */ transport: ClientTransport | undefined; uploadFile: (url: string, { formData, onProgress, onComplete, onError }: FetcherUploadFilePayload) => Promise; fetch(request: FetcherRequest & { replaceNullByUndefined: false; }): Promise; fetch(request: FetcherRequest & { replaceNullByUndefined?: true | undefined; }): Promise>; /** * GET binary content as a `Blob`. Goes through the same Bearer + * workspace + origin auth pipeline as `fetch`, which we cannot * delegate to `` / `` (those don't accept * custom headers). Errors flow through the shared `fromFetcherError` * normalizer so callers can `try/catch` consistently. */ fetchBlob: (request: FetcherBlobRequest) => Promise; }; export declare const buildFetcher: (dependencies: FetcherDependencies) => Fetcher; //# sourceMappingURL=index.d.ts.map