import {z} from 'zod' export type GetApiApiV1EuaiactAccuracyAlertsAlertIdArgs = {alert_id: string, 'X-Org-ID'?: string | undefined}; export type GetApiApiV1EuaiactAccuracyAlertsAlertIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const accuracyAlert = z.object({id: z.string().optional(), org_id: z.string().optional(), model_id: z.string().optional(), alert_type: z.enum(["accuracy_degradation", "bias_detected"]).optional(), severity: z.enum(["info", "warning", "critical"]).optional(), title: z.string().optional(), description: z.string().optional(), metric_type: z.string().optional(), bias_category: z.string().optional(), current_value: z.number().optional(), threshold: z.number().optional(), triggered_at: z.string().optional(), acked_at: z.string().optional(), acked_by: z.string().optional(), resolved_at: z.string().optional(), resolved_by: z.string().optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Get an accuracy alert by ID * * GET /api/v1/euaiact/accuracy/alerts/{alert_id} */ export const getApiApiV1EuaiactAccuracyAlertsAlertId = async (args: GetApiApiV1EuaiactAccuracyAlertsAlertIdArgs, options?: GetApiApiV1EuaiactAccuracyAlertsAlertIdOptions) => { const {baseUrl = "https://orchestrator.getaxonflow.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args['X-Org-ID'] != null) headers.set("X-Org-ID", String(args['X-Org-ID'])) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/euaiact/accuracy/alerts/${encodeURIComponent(String(args.alert_id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(accuracyAlert, await res.json()) };