export type Theme = 'light' | 'dark' | 'system'; export type PinnedAppsSchema = {team_id: string, app_ids: Array}; export type UpdatePreferencesSchema = {selected_team?: string | undefined, theme?: Theme | undefined, expanded_nav?: boolean | undefined, eligible_for_onboarding_flow?: boolean | undefined, pinned_apps?: Array | undefined}; export type PatchApiApiV3UserPreferencesArgs = {body: UpdatePreferencesSchema}; export type PatchApiApiV3UserPreferencesOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update preferences for the authenticated user * * PATCH /api/v3/user/preferences */ export const patchApiApiV3UserPreferences = async (args: PatchApiApiV3UserPreferencesArgs, options?: PatchApiApiV3UserPreferencesOptions) => { const {baseUrl = "https://codemagic.io", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (apiKey !== undefined) headers.set("x-auth-token", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/api/v3/user/preferences${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 };