export type Rules = {created_at: unknown, product_id: unknown, members_allowed: number, id: string}; export type PatchApiRulesArgs = {created_at?: unknown | undefined, product_id?: unknown | undefined, members_allowed?: unknown | undefined, id?: string | undefined, Prefer?: ('return=representation' | 'return=minimal' | 'return=none') | undefined, body: Rules}; export type PatchApiRulesOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * PATCH /rules */ export const patchApiRules = async (args: PatchApiRulesArgs, options?: PatchApiRulesOptions) => { const {baseUrl = "https://vnaabuozknwgxuvnfwjo.supabase.co:443", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.created_at != null) query.append("created_at", String(args.created_at)) if (args.product_id != null) query.append("product_id", String(args.product_id)) if (args.members_allowed != null) query.append("members_allowed", String(args.members_allowed)) if (args.id != null) query.append("id", String(args.id)) if (args.Prefer != null) headers.set("Prefer", String(args.Prefer)) const url = `${baseUrl.replace(/\/+$/, '')}/rules${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 };