export type GroupFunctionDTO = {name?: string | undefined, params?: Array | undefined}; export type GroupItemDTO = {type?: string | undefined, name?: string | undefined, label?: string | undefined, category?: string | undefined, tags?: Array | undefined, groupNames?: Array | undefined, groupType?: string | undefined, function?: GroupFunctionDTO | undefined}; export type UpdateApiItemsArgs = {body: Array}; export type UpdateApiItemsOptions = {baseUrl: string, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Adds a list of items to the registry or updates the existing items. * * PUT /items */ export const updateApiItems = async (args: UpdateApiItemsArgs, options: UpdateApiItemsOptions) => { const {baseUrl, fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/items${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 res.blob() };