export type JobId = number; export type GetApiJobResultJobIdArgs = {job_id: JobId, header?: boolean | undefined, nullify_special?: boolean | undefined}; export type GetApiJobResultJobIdOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get job results * * GET /job/result/{job_id} */ export const getApiJobResultJobId = async (args: GetApiJobResultJobIdArgs, options?: GetApiJobResultJobIdOptions) => { const {baseUrl = "https://api.treasuredata.com/v3", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/*") if (args.header != null) query.append("header", String(args.header)) if (args.nullify_special != null) query.append("nullify_special", String(args.nullify_special)) if (ApiKeyAuth !== undefined) headers.set('authorization', `TD1 ${ApiKeyAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/job/result/${encodeURIComponent(String(args.job_id))}${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() };