export type PatchApiApiJsFolderArgs = {folder: string, body: BodyInit}; export type PatchApiApiJsFolderOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * PATCH /api/js/{folder} */ export const patchApiApiJsFolder = async (args: PatchApiApiJsFolderArgs, options: PatchApiApiJsFolderOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/api/js/${encodeURIComponent(String(args.folder))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", headers, body: args.body}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return (await res.json()) as unknown };