import {z} from 'zod' export type GetApiApiV1RbiAiSystemsArgs = {risk_category?: ('low' | 'medium' | 'high') | undefined, deployment_status?: ('development' | 'sandbox' | 'canary' | 'production' | 'deprecated') | undefined}; export type GetApiApiV1RbiAiSystemsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const rBIAISystem = z.object({id: z.string().optional(), org_id: z.string().optional(), system_id: z.string().optional(), system_name: z.string().optional(), system_version: z.string().optional(), description: z.string().optional(), risk_category: z.enum(["low", "medium", "high"]).optional(), deployment_status: z.enum(["development", "sandbox", "canary", "production", "deprecated"]).optional(), model_type: z.string().optional(), model_provider: z.string().optional(), use_case: z.string().optional(), board_approval_required: z.boolean().optional(), board_approval_status: z.enum(["not_required", "pending", "approved", "rejected", "revoked"]).optional(), last_validation_date: z.string().optional(), next_validation_due: z.string().optional(), created_at: z.string().optional(), updated_at: z.string().optional()}); export const getApiApiV1RbiAiSystemsResponse = z.array(rBIAISystem); 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 }; /** * List AI systems * * GET /api/v1/rbi/ai-systems */ export const getApiApiV1RbiAiSystems = async (args: GetApiApiV1RbiAiSystemsArgs, options?: GetApiApiV1RbiAiSystemsOptions) => { 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.risk_category != null) query.append("risk_category", String(args.risk_category)) if (args.deployment_status != null) query.append("deployment_status", String(args.deployment_status)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/rbi/ai-systems${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(getApiApiV1RbiAiSystemsResponse, await res.json()) };