export type RESTUserConfig = {fullname: string, password?: string | undefined, new_password?: string | undefined, pwd_profile: string, email?: string | undefined, role?: string | undefined, timeout?: number | undefined, locale?: string | undefined, role_domains?: ({role?: string | undefined, domains?: Array | undefined}) | undefined}; export type RESTUserConfigData = {config: RESTUserConfig}; export type PatchApiUserFullnameArgs = {'X-Auth-Token': string, fullname: string, body: RESTUserConfigData}; export type PatchApiUserFullnameOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Update user * * PATCH /user/{fullname} */ export const patchApiUserFullname = async (args: PatchApiUserFullnameArgs, options: PatchApiUserFullnameOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['X-Auth-Token'] != null) headers.set("X-Auth-Token", String(args['X-Auth-Token'])) const url = `${baseUrl.replace(/\/+$/, '')}/user/${encodeURIComponent(String(args.fullname))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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 };