export type PatchApiApiChatSessionPrefsArgs = {body: Record}; export type PatchApiApiChatSessionPrefsOptions = {baseUrl: string, sessionCookie?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update chat session preference * * PATCH /api/chat/session-prefs * * Also accepts auth: apiKey */ export const patchApiApiChatSessionPrefs = async (args: PatchApiApiChatSessionPrefsArgs, options: PatchApiApiChatSessionPrefsOptions) => { const {baseUrl, fetch: fetchFn = fetch, sessionCookie} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (sessionCookie !== undefined) cookies.push("__Host-mc-session=" + encodeURIComponent(sessionCookie)) const url = `${baseUrl.replace(/\/+$/, '')}/api/chat/session-prefs${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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 };