export type GetApiApiV1DatasetsDatasetIdDownloadArgs = {dataset_id: string, fileFormat?: ('csv' | 'json' | 'jsonl' | 'parquet') | undefined}; export type GetApiApiV1DatasetsDatasetIdDownloadOptions = {baseUrl: string, bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download the processed dataset * * GET /api/v1/datasets/{dataset_id}/download */ export const getApiApiV1DatasetsDatasetIdDownload = async (args: GetApiApiV1DatasetsDatasetIdDownloadArgs, options: GetApiApiV1DatasetsDatasetIdDownloadOptions) => { const {baseUrl, fetch: fetchFn = fetch, bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/octet-stream") if (args.fileFormat != null) query.append("fileFormat", String(args.fileFormat)) if (bearer !== undefined) headers.set('authorization', `Bearer ${bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/datasets/${encodeURIComponent(String(args.dataset_id))}/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.blob() };