export type CreateApiPluginsNameEnableArgs = {name: string, timeout?: number | undefined}; export type CreateApiPluginsNameEnableOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Enable a plugin * * POST /plugins/{name}/enable */ export const createApiPluginsNameEnable = async (args: CreateApiPluginsNameEnableArgs, options: CreateApiPluginsNameEnableOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.timeout != null) query.append("timeout", String(args.timeout)) const url = `${baseUrl.replace(/\/+$/, '')}/plugins/${encodeURIComponent(String(args.name))}/enable${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };