import {z} from 'zod' export type GetApiApiV1OverridesIdArgs = {id: string, 'X-Tenant-ID': string}; export type GetApiApiV1OverridesIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const overrideDetail = z.object({id: z.string(), policy_id: z.string(), policy_type: z.string(), tenant_id: z.string().optional(), org_id: z.string(), organization_id: z.string(), action_override: z.string().optional(), enabled_override: z.boolean().optional(), override_reason: z.string(), expires_at: z.string().optional(), tool_signature: z.string().optional(), created_by: z.string(), created_at: z.string(), revoked_at: z.string().optional(), revoked_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 a policy override * * GET /api/v1/overrides/{id} */ export const getApiApiV1OverridesId = async (args: GetApiApiV1OverridesIdArgs, options?: GetApiApiV1OverridesIdOptions) => { 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-Tenant-ID'] != null) headers.set("X-Tenant-ID", String(args['X-Tenant-ID'])) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/overrides/${encodeURIComponent(String(args.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(overrideDetail, await res.json()) };