import { t as ErrorResponse } from "./schema-DKqL09oQ.mjs"; import { T as GetResponseOutput, a as App, c as ApplyAppPrefix, f as BaseRoutes, s as ApplyAppDataPrefix, v as GetAppRoutes, y as GetRequestParamsInput } from "./types-BvjPE9EM.mjs"; //#region src/client.d.ts /** * Type-safe client based on routes defined server-side. */ interface AppClient { fetch(method: TMethod, route: TRoute, inputs: GetRequestParamsInput): Promise>; fetch(method: string, route: TRoute, inputs: GetRequestParamsInput): Promise>; } /** * Creates a type-safe client based on the server-side app. This is only useful * if your frontend is in the same TypeScript project as your backend, and you * can reference it's types in the frontend. * * If that's not the case, generate your client using the OpenAPI docs. * * @example * ```ts * // Server-side: * import { createApp } from "@aklinker1/zeta"; * * const app = createApp(); * export type App = typeof app; * * // Client-side: * import type { App } from "../server"; * // ^^^^ MAKE SURE TO ONLY IMPORT THE TYPE HERE * * const client = createAppClient(); * ``` */ declare function createAppClient(options?: CreateAppClientOptions): AppClient>; /** * Helper for converting an `App` to the routes it exposes. */ type GetClientRoutes = TApp extends App ? ApplyAppDataPrefix["routes"] : never; /** * Thrown by the client when the response is not OK. When an `HttpError` is * thrown server-side, this is the error throw client-side. */ declare class RequestError extends Error { status: number; response: ErrorResponse; constructor(message: string, status: number, response: ErrorResponse, options?: ErrorOptions); } /** * Helper for converting an `App` type to `AppClient`. */ type GetAppClient = App extends { prefix: string; } ? GetAppClient> : AppClient extends BaseRoutes ? GetAppRoutes : never>; /** * Configure the client's behavior. */ type CreateAppClientOptions = { fetch?: typeof fetch; /** * Base URL used when making requests. * @default location.origin */ baseUrl?: string; /** * List of headers to send on every request. * @default {} */ headers?: Record; }; //#endregion export { AppClient, CreateAppClientOptions, GetAppClient, GetClientRoutes, RequestError, createAppClient };