export type PluginPrivilege = {Name?: string | undefined, Description?: string | undefined, Value?: Array | undefined}; export type CreateApiPluginsPullArgs = {remote: string, name?: string | undefined, 'X-Registry-Auth'?: string | undefined, body: Array}; export type CreateApiPluginsPullOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Install a plugin * * POST /plugins/pull */ export const createApiPluginsPull = async (args: CreateApiPluginsPullArgs, options: CreateApiPluginsPullOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.remote != null) query.append("remote", String(args.remote)) if (args.name != null) query.append("name", String(args.name)) if (args['X-Registry-Auth'] != null) headers.set("X-Registry-Auth", String(args['X-Registry-Auth'])) const url = `${baseUrl.replace(/\/+$/, '')}/plugins/pull${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };