import type { Transport } from "./transport"; /** * Client interface for invoking custom backend functions. * * Custom functions are Hono route files auto-mounted by the Rebase backend * at `/api/functions/{name}`. The `FunctionsClient` wraps the shared * transport so callers never need to manually construct URLs or inject * auth tokens. * * @example * ```ts * const result = await client.functions.invoke<{ job: Job }>('extract-job', { * url: 'https://example.com/posting', * html: htmlContent, * }); * ``` */ export interface FunctionsClient { /** * Invoke a custom backend function by name. * * @typeParam T - Expected shape of the response payload. * @param name - Function name (the filename without extension, e.g. `"extract-job"`). * @param payload - Optional JSON-serialisable body sent as `POST`. * @param options - Optional overrides (HTTP method, sub-path, extra headers). * @returns The parsed JSON response from the function. */ invoke(name: string, payload?: unknown, options?: FunctionInvokeOptions): Promise; } export type { FunctionInvokeOptions } from "@rebasepro/types"; import type { FunctionInvokeOptions } from "@rebasepro/types"; /** * Create a `FunctionsClient` backed by the given transport. * * The transport already handles: * - Base URL resolution * - JWT injection via `Authorization: Bearer` * - 401 retry / `onUnauthorized` flow * - Consistent error throwing via `RebaseApiError` * * @internal */ export declare function createFunctionsClient(transport: Transport): FunctionsClient;