export type GetApiApiNamespaceRepositoryTreeTreeDownloadZipArgs = {namespace: string, repository: string, tree: string}; export type GetApiApiNamespaceRepositoryTreeTreeDownloadZipOptions = {baseUrl: string, cookieAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download Zip * * GET /api/{namespace}/{repository}/tree/{tree}/download/zip */ export const getApiApiNamespaceRepositoryTreeTreeDownloadZip = async (args: GetApiApiNamespaceRepositoryTreeTreeDownloadZipArgs, options: GetApiApiNamespaceRepositoryTreeTreeDownloadZipOptions) => { const {baseUrl, fetch: fetchFn = fetch, cookieAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/zip") if (cookieAuth !== undefined) cookies.push("gitarena-session=" + encodeURIComponent(cookieAuth)) const url = `${baseUrl.replace(/\/+$/, '')}/api/${encodeURIComponent(String(args.namespace))}/${encodeURIComponent(String(args.repository))}/tree/${encodeURIComponent(String(args.tree))}/download/zip${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() };