/** * davepi HTTP client used by the React hooks. * * Mirrors the contract of `client/davepi-runtime.ts` in the davepi backend * but inlined here so this package does not depend on davepi being a * peer dep. Once davepi publishes its runtime as a standalone npm package * we can swap to consuming it directly. */ declare class DavepiError extends Error { status: number; code: string; details?: unknown; constructor(status: number, code: string, message: string, details?: unknown); } interface ListParams { filter?: Record; page?: number; sort?: string; q?: string; include?: string[]; includeDeleted?: boolean; } interface ListResponse { results: T[]; totalResults: number; page: number; perPage: number; totalPages?: number; nextPage?: number; prevPage?: number; } interface DavepiClientOptions { baseUrl: string; getToken?: () => string | Promise | undefined; /** * Hook called when a request returns 401. Should attempt a refresh and * return the new bearer token, or undefined to signal logout. Receives * the original request descriptor so the caller can decide whether to * skip refresh (e.g. don't refresh the refresh request itself). */ onUnauthorized?: () => Promise; fetch?: typeof fetch; headers?: Record; } interface DavepiClient { baseUrl: string; request(req: RequestDescriptor): Promise; list(path: string, params?: ListParams): Promise>; get(path: string, id: string, include?: string[]): Promise; create(path: string, body: unknown): Promise; update(path: string, id: string, body: unknown): Promise; remove(path: string, id: string): Promise<{ acknowledged: boolean; }>; fetchJson(input: string, init?: RequestInit): Promise; } interface RequestDescriptor { method: string; path: string; query?: Record; body?: unknown; headers?: Record; /** Set true to skip auto-401 refresh (used by the refresh call itself). */ skipRefresh?: boolean; } declare function createDavepiClient(opts: DavepiClientOptions): DavepiClient; export { type DavepiClient as D, type ListParams as L, type DavepiClientOptions as a, DavepiError as b, type ListResponse as c, createDavepiClient as d };