// Thin API client for the operator/admin UI. export interface ConfigField { key: string; label: string; type: "string" | "number" | "boolean" | "host" | "port" | "secret" | "select"; required: boolean; default?: string | number | boolean; options?: { value: string; label: string }[]; help?: string; } export interface CatalogEntry { id: string; label: string; description: string; transports: string[]; configFields: ConfigField[]; } export type DeviceCategory = "access" | "reader" | "camera" | "printer"; export type Catalog = Record; export async function fetchCatalog(): Promise { const res = await fetch("/api/setup/catalog"); if (!res.ok) throw new Error(`catalog: ${res.status}`); return res.json() as Promise; } export interface AssignBody { lane: number; category: DeviceCategory; driverId: string; config: Record; } export async function assignDevice(token: string, body: AssignBody): Promise { const res = await fetch("/api/setup/assign", { method: "POST", headers: { "content-type": "application/json", authorization: `Bearer ${token}` }, body: JSON.stringify(body), }); if (!res.ok) { const msg = (await res.json().catch(() => ({}))) as { error?: string }; throw new Error(msg.error ?? `assign: ${res.status}`); } return res.json(); }