export type GetApiApiSkillsNamePackageArgs = {name: string, expert_id?: (string | null) | undefined}; export type GetApiApiSkillsNamePackageOptions = {baseUrl: string, HTTPBearerJWT?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download a copilot skill as a zipped package * * GET /api/skills/{name}/package */ export const getApiApiSkillsNamePackage = async (args: GetApiApiSkillsNamePackageArgs, options: GetApiApiSkillsNamePackageOptions) => { const {baseUrl, fetch: fetchFn = fetch, HTTPBearerJWT} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/zip") if (args.expert_id != null) query.append("expert_id", String(args.expert_id)) if (HTTPBearerJWT !== undefined) headers.set('authorization', `Bearer ${HTTPBearerJWT}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/skills/${encodeURIComponent(String(args.name))}/package${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() };