import {z} from 'zod' export type GetApiApiV1EuaiactExportArgs = {'X-Org-ID'?: string | undefined, limit?: number | undefined, offset?: number | undefined}; export type GetApiApiV1EuaiactExportOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const eUAIActExport = z.object({id: z.string().optional(), org_id: z.string().optional(), status: z.enum(["pending", "processing", "completed", "failed"]).optional(), export_type: z.enum(["full_audit", "conformity_evidence", "hitl_summary", "decision_chain", "policy_violations", "accuracy_metrics"]).optional(), format: z.enum(["json", "xml", "csv"]).optional(), created_at: z.string().optional(), started_at: z.string().nullable().optional(), completed_at: z.string().nullable().optional(), date_from: z.string().optional(), date_to: z.string().optional(), download_url: z.string().nullable().optional(), storage_type: z.enum(["local", "s3", "gcs", "azure"]).optional(), storage_key: z.string().nullable().optional(), file_path: z.string().nullable().optional(), file_size: z.number().int().optional(), record_count: z.number().int().optional(), progress: z.number().optional(), error_message: z.string().nullable().optional(), created_by: z.string().optional()}); export const getApiApiV1EuaiactExportResponse = z.object({exports: z.array(eUAIActExport).optional(), total: z.number().int().optional(), limit: z.number().int().optional(), offset: z.number().int().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 }; /** * List exports * * GET /api/v1/euaiact/export */ export const getApiApiV1EuaiactExport = async (args: GetApiApiV1EuaiactExportArgs, options?: GetApiApiV1EuaiactExportOptions) => { 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'])) if (args.limit != null) query.append("limit", String(args.limit)) if (args.offset != null) query.append("offset", String(args.offset)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/euaiact/export${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(getApiApiV1EuaiactExportResponse, await res.json()) };