import { z } from "zod"; import type { ZodType } from "zod"; /** Default base URL, taken from the OpenAPI `servers` entry. */ export declare const DEFAULT_BASE_URL = "https://api.solidarity.tech/v1"; /** Configuration shared by every endpoint call. */ export interface ClientConfig { /** Bearer token used for the `Authorization` header. */ apiKey: string; /** Override the API base URL. Defaults to {@link DEFAULT_BASE_URL}. */ baseUrl?: string; /** * Override the `fetch` implementation. Defaults to the global `fetch`, * which is available in browsers, Node 18+, Bun, Deno and other runtimes. */ fetch?: typeof fetch; } type QueryValue = string | number | boolean | null | undefined | Array; /** Query string parameters. `undefined` and `null` values are omitted. */ export type QueryParams = Record; /** Result of a successful request whose body passed validation. */ export interface ApiSuccess { ok: true; status: number; data: T; error?: undefined; } /** A non-2xx response, a network failure, or a body that failed validation. */ export interface ApiFailure { ok: false; status: number; error: ApiError; /** The raw parsed body, when one was received. */ data: unknown; } /** * Every endpoint resolves to one of these instead of throwing, mirroring how * `fetch` surfaces HTTP errors as ordinary return values. */ export type ApiResult = ApiSuccess | ApiFailure; export type ApiError = /** The server replied with a non-2xx status. */ { type: "http"; status: number; message: string; body: unknown; } /** `fetch` rejected (DNS, connection, abort, etc.). */ | { type: "network"; message: string; cause: unknown; } /** The 2xx body did not match the expected zod schema. */ | { type: "validation"; message: string; issues: z.core.$ZodIssue[]; received: unknown; }; interface GetOptions { query?: QueryParams; schema?: ZodType; } interface WriteOptions { query?: QueryParams; body?: unknown; schema?: ZodType; } /** Shared GET helper. Omit `schema` to receive the raw body as `unknown`. */ export declare function apiGet(config: ClientConfig, path: string, options?: GetOptions): Promise>; /** Shared POST helper. Omit `schema` to receive the raw body as `unknown`. */ export declare function apiPost(config: ClientConfig, path: string, options?: WriteOptions): Promise>; /** Shared PUT helper. Omit `schema` to receive the raw body as `unknown`. */ export declare function apiPut(config: ClientConfig, path: string, options?: WriteOptions): Promise>; /** Shared DELETE helper. Omit `schema` to receive the raw body as `unknown`. */ export declare function apiDelete(config: ClientConfig, path: string, options?: WriteOptions): Promise>; export {};