export type BoundingBox = {x0: number, y0: number, x1: number, y1: number, dpi?: number | undefined, class_name?: (string | null) | undefined, text?: (string | null) | undefined, confidence?: (number | null) | undefined}; export type LegendEntry = {id: string, name: string, class: string, subtype?: (string | null) | undefined, source_bbox?: (BoundingBox | null) | undefined, source_node_id?: (string | null) | undefined, source_crop_url?: (string | null) | undefined, confidence?: number | undefined, cfihos_tag_class_code?: (string | null) | undefined, cfihos_equipment_class_code?: (string | null) | undefined, cfihos_version?: (string | null) | undefined, cfihos_source?: ('deterministic_map' | 'name_match' | 'isa_letter_code' | 'llm' | 'template_applied' | 'user_pinned' | null) | undefined, cfihos_confidence?: (number | null) | undefined}; export type ReplaceLegendRequest = {legend: Array}; export type UpdateApiApiV0ComponentsComponentIdSchematicLegendArgs = {component_id: string, vc_id: string, body: ReplaceLegendRequest}; export type UpdateApiApiV0ComponentsComponentIdSchematicLegendOptions = {baseUrl: string, HTTPBearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Replace the per-document legend * * PUT /api/v0/components/{component_id}/schematic/legend */ export const updateApiApiV0ComponentsComponentIdSchematicLegend = async (args: UpdateApiApiV0ComponentsComponentIdSchematicLegendArgs, options: UpdateApiApiV0ComponentsComponentIdSchematicLegendOptions) => { const {baseUrl, fetch: fetchFn = fetch, HTTPBearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.vc_id != null) query.append("vc_id", String(args.vc_id)) if (HTTPBearer !== undefined) headers.set('authorization', `Bearer ${HTTPBearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v0/components/${encodeURIComponent(String(args.component_id))}/schematic/legend${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };