export type DownloadCrawlRawArchiveRequest = {source_ids?: Array | undefined}; export type CreateApiCrawlsCrawlIdRawArchiveArgs = {crawl_id: string, body: DownloadCrawlRawArchiveRequest}; export type CreateApiCrawlsCrawlIdRawArchiveOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download crawl raw files as a ZIP archive * * POST /crawls/{crawl_id}/raw-archive */ export const createApiCrawlsCrawlIdRawArchive = async (args: CreateApiCrawlsCrawlIdRawArchiveArgs, options?: CreateApiCrawlsCrawlIdRawArchiveOptions) => { const {baseUrl = "https://developer.qaip.com/api/v1", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/zip") if (ApiKeyAuth !== undefined) headers.set("x-api-key", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/crawls/${encodeURIComponent(String(args.crawl_id))}/raw-archive${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };