export type GetApiApiUserActionsArgs = {startDate: string, endDate: string, paginate?: number | undefined}; export type GetApiApiUserActionsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Get user actions * * GET /api/user-actions */ export const getApiApiUserActions = async (args: GetApiApiUserActionsArgs, options: GetApiApiUserActionsOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.startDate != null) query.append("startDate", String(args.startDate)) if (args.endDate != null) query.append("endDate", String(args.endDate)) if (args.paginate != null) query.append("paginate", String(args.paginate)) const url = `${baseUrl.replace(/\/+$/, '')}/api/user-actions${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 };