import { z } from "zod";

/**
 * Persisted provider shape shared by the server store and browser API clients.
 *
 * Keep this module free of filesystem and process-level imports so client code
 * can validate API responses without pulling the provider store into the bundle.
 */
export const ProviderConfigSchema = z.object({
  id: z.string(),
  name: z.string(),
  apiKey: z.string(),
  model: z.string().optional(),
  models: z.array(z.string()).min(1),
  format: z.enum(["anthropic", "openai"]).optional(),
  baseUrl: z.string().optional(),
  anthropicBaseUrl: z.string().optional(),
  openaiBaseUrl: z.string().optional(),
  authHeader: z.enum(["bearer", "x-api-key"]).optional().default("bearer"),
  apiDocsUrl: z.string().optional(),
  source: z.enum(["company", "personal"]).optional(),
  createdAt: z.string(),
  updatedAt: z.string(),
});

export type ProviderConfig = z.infer<typeof ProviderConfigSchema>;
