export type HeadApiUploadFileIdArgs = {'Tus-Resumable': string}; export type HeadApiUploadFileIdOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get upload progress * * HEAD /upload/{FileId} */ export const headApiUploadFileId = async (args: HeadApiUploadFileIdArgs, options?: HeadApiUploadFileIdOptions) => { const {baseUrl = "https://docs.bimtrackapp.co", fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args['Tus-Resumable'] != null) headers.set("Tus-Resumable", String(args['Tus-Resumable'])) if (Bearer !== undefined) headers.set("Authorization", Bearer) const url = `${baseUrl.replace(/\/+$/, '')}/upload/${encodeURIComponent(String(args.FileId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "HEAD", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };