export type SystemAuditHashRequest = {input?: string | undefined}; export type CreateApiSysAuditHashPathArgs = {body: SystemAuditHashRequest}; export type CreateApiSysAuditHashPathOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * The hash of the given string via the given audit backend * * POST /sys/audit-hash/{path} */ export const createApiSysAuditHashPath = async (args: CreateApiSysAuditHashPathArgs, options: CreateApiSysAuditHashPathOptions) => { 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/audit-hash/${encodeURIComponent(String(args.path))}${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 };