export type CustomPrimData = {category: string, type: string}; export type BodySetPrimMetadata = {metadata: CustomPrimData, prim_path: string}; export type UpdateApiPrimsMetadataArgs = {body: BodySetPrimMetadata}; export type UpdateApiPrimsMetadataOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Set Prim Metadata * * PUT /prims/metadata */ export const updateApiPrimsMetadata = async (args: UpdateApiPrimsMetadataArgs, options: UpdateApiPrimsMetadataOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/prims/metadata${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 };