export type GetApiApiV1TestsDownloadArgs = {projectId: number}; export type GetApiApiV1TestsDownloadOptions = {baseUrl?: string | undefined, cookieAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download tests * * GET /api/v1/tests/download * * Also accepts auth: bearerAuth */ export const getApiApiV1TestsDownload = async (args: GetApiApiV1TestsDownloadArgs, options?: GetApiApiV1TestsDownloadOptions) => { const {baseUrl = "http://localhost:3000", fetch: fetchFn = fetch, cookieAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/csv") if (args.projectId != null) query.append("projectId", String(args.projectId)) if (cookieAuth !== undefined) cookies.push("user_session=" + encodeURIComponent(cookieAuth)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/tests/download${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.text() };