// raccha.ai TypeScript client — a thin openapi-fetch wrapper typed against
// the live OpenAPI spec (schema.d.ts, regenerated by sdk/generate.sh, never
// hand-edited).
//
// Deliberately NOT a generated file: openapi-fetch's whole point is that the
// client itself is a small, stable, hand-written wrapper — only the types
// are generated. See bundle-10's decided notes for why TS uses this pair
// instead of OpenAPI Generator's TS output.
import createClient from "openapi-fetch";
import type { paths } from "./schema.js";

export interface RacchaClientOptions {
  /** Base URL of the raccha.ai API. Defaults to the production origin. */
  baseUrl?: string;
  /**
   * Owner key returned by /auth/verify. Sent as `Authorization: Bearer
   * <ownerKey>` on every request. Omit for the two unauthenticated auth
   * routes.
   */
  ownerKey?: string;
}

export function createRacchaClient(options: RacchaClientOptions = {}) {
  const { baseUrl = "https://raccha.ai", ownerKey } = options;
  return createClient<paths>({
    baseUrl,
    headers: ownerKey ? { Authorization: `Bearer ${ownerKey}` } : undefined,
  });
}

export type { paths, components } from "./schema.js";
