export type GetApiEtcPackagesGroupNameVersionZipArgs = {group: string, name: string, version: string}; export type GetApiEtcPackagesGroupNameVersionZipOptions = {baseUrl: string, aemAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * GET /etc/packages/{group}/{name}-{version}.zip */ export const getApiEtcPackagesGroupNameVersionZip = async (args: GetApiEtcPackagesGroupNameVersionZipArgs, options: GetApiEtcPackagesGroupNameVersionZipOptions) => { const {baseUrl, fetch: fetchFn = fetch, aemAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/octet-stream") if (aemAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${aemAuth.username}:${aemAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/etc/packages/${encodeURIComponent(String(args.group))}/${encodeURIComponent(String(args.name))}-${encodeURIComponent(String(args.version))}.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() };