import type { ApiResponse, RetryPolicy } from '@struktoai/mirage-core/core/api/client'; import type { ByteWindow } from '@struktoai/mirage-core/utils/ranges'; export declare const RETRY: RetryPolicy; /** A Hub call that answered with a status the caller cannot use. */ export declare class HfHubError extends Error { /** * The Hub's `X-Error-Code`, '' when it sent none. The status alone cannot * tell its refusals apart: a missing repository, a missing revision and a * missing file are all 404, and only this header says which * (`RepoNotFound` / `RevisionNotFound` / `EntryNotFound`). */ readonly errorCode: string; constructor(message: string, status: number, errorCode?: string); readonly status: number; } /** * Auth and accept headers for one Hub call. * * An anonymous call is a first-class case here, unlike GitHub's: the Hub * serves every public repo without a token, so a mount with no credential * reads normally and only the write path needs one. */ export declare function hubHeaders(token: string | undefined): Record; /** The /api URL for one repository-scoped endpoint. */ export declare function apiUrl(endpoint: string, repoType: string, repoId: string, suffix: string): string; /** * The content URL for one file at one revision. * * The path is percent-encoded per segment: a Hub repo may hold a file whose * name carries a space or a "#", and pasting it raw truncates the URL at the * fragment. */ /** * The web URL of a repository, which is what the CLI echoes. * * A model sits at the origin root and the other two kinds sit under a * plural segment, the same split `resolveUrl` walks. */ /** * One revision, encoded as a single URL path segment. * * A git ref may hold a slash (`feature/foo`, `refs/pr/1`), and every Hub * route reads the segment after the verb as the whole revision, so an * unencoded one splits: `/tree/feature/foo` names revision `feature` and * subtree `foo`. The extra replace is what makes this identical to * python's `quote(revision, safe="")`, which encodes the four characters * `encodeURIComponent` leaves alone. */ export declare function revSegment(revision: string): string; export declare function repoUrl(endpoint: string, repoType: string, repoId: string): string; export declare function resolveUrl(endpoint: string, repoType: string, repoId: string, revision: string, path: string): string; /** * Map a failing Hub response to the backend's own error. * * The Hub reports its reason in an `X-Error-Message` header as well as in the * body, and the header is the one that survives a HEAD, so it is preferred. */ export declare function errorOf(response: Response, text: string): Error; export declare function hubGet(token: string | undefined, url: string, params?: Record): Promise; /** One GET retaining status and headers, which tree pagination reads. */ export declare function hubGetResponse(token: string | undefined, url: string, params?: Record): Promise; export declare function hubPost(token: string | undefined, url: string, body: unknown, params?: Record): Promise; /** One arbitrary JSON call, for the endpoints that are not GET or POST. */ export declare function hubRequest(token: string | undefined, method: string, url: string, body: unknown, params?: Record): Promise; /** One newline-delimited-JSON POST, which is the commit endpoint's shape. */ export declare function hubPostNdjson(token: string | undefined, url: string, payload: Uint8Array, params?: Record): Promise; /** * Fetch file content, optionally a byte window of it. * * `/resolve` answers a redirect to the CDN and fetch follows it, carrying the * Range along, so a window costs no extra round trip. */ export declare function hubBytes(token: string | undefined, url: string, window?: ByteWindow): Promise; /** * Stream file content without holding it whole in memory. * * Not routed through `apiRequest`: that reads the body to completion before * returning, which is the opposite of what a stream is for. */ export declare function hubStream(token: string | undefined, url: string): AsyncIterable; //# sourceMappingURL=client.d.ts.map