export type ExportFormatEnum = 'csv' | 'txt' | 'json'; export type DomainURLsExportBody = {search?: (string | null) | undefined}; export type CreateApiSearchDomainDomainUrlsExportArgs = {domain: string, search?: (string | null) | undefined, format?: ExportFormatEnum | undefined, body: DomainURLsExportBody | null}; export type CreateApiSearchDomainDomainUrlsExportOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Export all URLs for a domain as CSV/TXT/JSON * * POST /search/domain/{domain}/urls/export */ export const createApiSearchDomainDomainUrlsExport = async (args: CreateApiSearchDomainDomainUrlsExportArgs, options?: CreateApiSearchDomainDomainUrlsExportOptions) => { const {baseUrl = "https://api.leakradar.io", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.search != null) query.append("search", String(args.search)) if (args.format != null) query.append("format", String(args.format)) if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/search/domain/${encodeURIComponent(String(args.domain))}/urls/export${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 undefined };