export type SystemConfigUiHeadersRequest = {multivalue?: boolean | undefined, values?: Array | undefined}; export type CreateApiSysConfigUiHeadersHeaderArgs = {body: SystemConfigUiHeadersRequest}; export type CreateApiSysConfigUiHeadersHeaderOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Configure the values to be returned for the UI header. * * POST /sys/config/ui/headers/{header} */ export const createApiSysConfigUiHeadersHeader = async (args: CreateApiSysConfigUiHeadersHeaderArgs, options: CreateApiSysConfigUiHeadersHeaderOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/sys/config/ui/headers/${encodeURIComponent(String(args.header))}${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 };