export type UpdateApiApiV0ComponentsComponentIdSchematicArgs = {component_id: string, vc_id: string, body: {[key: string]: unknown}}; export type UpdateApiApiV0ComponentsComponentIdSchematicOptions = {baseUrl: string, HTTPBearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Bulk-replace schematic + pid grounding * * PUT /api/v0/components/{component_id}/schematic */ export const updateApiApiV0ComponentsComponentIdSchematic = async (args: UpdateApiApiV0ComponentsComponentIdSchematicArgs, options: UpdateApiApiV0ComponentsComponentIdSchematicOptions) => { 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${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 };