export type GetApiApiUsersArgs = {offset?: number | undefined, size?: number | undefined, cursor?: string | undefined, sample?: string | undefined, term?: string | undefined, page?: number | undefined, exact?: boolean | undefined}; export type GetApiApiUsersOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Retrieve a collection of users. * * GET /api/users */ export const getApiApiUsers = async (args: GetApiApiUsersArgs, options: GetApiApiUsersOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.offset != null) query.append("offset", String(args.offset)) if (args.size != null) query.append("size", String(args.size)) if (args.cursor != null) query.append("cursor", String(args.cursor)) if (args.sample != null) query.append("sample", String(args.sample)) if (args.term != null) query.append("term", String(args.term)) if (args.page != null) query.append("page", String(args.page)) if (args.exact != null) query.append("exact", String(args.exact)) const url = `${baseUrl.replace(/\/+$/, '')}/api/users${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 undefined };