export type GetApiApiCardsArgs = {deleted: boolean, page?: number | undefined, size?: number | undefined, sort?: Array | undefined}; export type GetApiApiCardsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * getAllCards * * GET /api/cards */ export const getApiApiCards = async (args: GetApiApiCardsArgs, options: GetApiApiCardsOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*/*") if (args.deleted != null) query.append("deleted", String(args.deleted)) if (args.page != null) query.append("page", String(args.page)) if (args.size != null) query.append("size", String(args.size)) for (const item of args.sort ?? []) query.append("sort", String(item)) const url = `${baseUrl.replace(/\/+$/, '')}/api/cards${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 res.blob() };