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 UpdateApiItemsItemnameArgs = {'Accept-Language'?: string | undefined, itemname: string, body: GroupItemDTO}; export type UpdateApiItemsItemnameOptions = {baseUrl: string, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Adds a new item to the registry or updates the existing item. * * PUT /items/{itemname} */ export const updateApiItemsItemname = async (args: UpdateApiItemsItemnameArgs, options: UpdateApiItemsItemnameOptions) => { 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 (args['Accept-Language'] != null) headers.set("Accept-Language", String(args['Accept-Language'])) if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/items/${encodeURIComponent(String(args.itemname))}${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() };