import {z} from 'zod' export type GetApiOrganizationInvitationArgs = {created_at?: unknown | undefined, organization_id?: string | undefined, token?: unknown | undefined, invited_by_user_id?: string | undefined, organization_name?: unknown | undefined, updated_at?: unknown | undefined, id?: string | undefined, invitation_type?: unknown | undefined, email?: unknown | undefined, message?: unknown | undefined, organization_role?: unknown | undefined, select?: string | undefined, order?: string | undefined, Range?: string | undefined, 'Range-Unit'?: string | undefined, offset?: string | undefined, limit?: string | undefined, Prefer?: 'count=none' | undefined}; export type GetApiOrganizationInvitationOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const organizationInvitation = z.object({created_at: z.string(), organization_id: z.string(), token: z.string(), invited_by_user_id: z.string(), organization_name: z.string().optional(), updated_at: z.string(), id: z.string(), invitation_type: z.enum(["one_time", "24_hour"]), email: z.string().optional(), message: z.string().optional(), organization_role: z.enum(["owner", "member"])}); export const getApiOrganizationInvitationResponse = z.array(organizationInvitation); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * GET /organization_invitation */ export const getApiOrganizationInvitation = async (args: GetApiOrganizationInvitationArgs, options?: GetApiOrganizationInvitationOptions) => { const {baseUrl = "https://vnaabuozknwgxuvnfwjo.supabase.co:443", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.created_at != null) query.append("created_at", String(args.created_at)) if (args.organization_id != null) query.append("organization_id", String(args.organization_id)) if (args.token != null) query.append("token", String(args.token)) if (args.invited_by_user_id != null) query.append("invited_by_user_id", String(args.invited_by_user_id)) if (args.organization_name != null) query.append("organization_name", String(args.organization_name)) if (args.updated_at != null) query.append("updated_at", String(args.updated_at)) if (args.id != null) query.append("id", String(args.id)) if (args.invitation_type != null) query.append("invitation_type", String(args.invitation_type)) if (args.email != null) query.append("email", String(args.email)) if (args.message != null) query.append("message", String(args.message)) if (args.organization_role != null) query.append("organization_role", String(args.organization_role)) if (args.select != null) query.append("select", String(args.select)) if (args.order != null) query.append("order", String(args.order)) if (args.Range != null) headers.set("Range", String(args.Range)) if (args['Range-Unit'] != null) headers.set("Range-Unit", String(args['Range-Unit'])) if (args.offset != null) query.append("offset", String(args.offset)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.Prefer != null) headers.set("Prefer", String(args.Prefer)) const url = `${baseUrl.replace(/\/+$/, '')}/organization_invitation${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(getApiOrganizationInvitationResponse, await res.json()) };