import { z } from "zod" const ruleSchema = z.object({ id: z.string().min(1), community: z.string(), communityName: z.string().optional(), action: z.enum(["route", "blackhole"]).optional(), gateway: z.string(), gatewayTunnelId: z.string(), description: z.string(), }) export const filterRulesSchema = z.array(ruleSchema).refine(rows => new Set(rows.map(r => r.id)).size === rows.length) export const filtersResponseSchema = z.object({ rulesets: z.array(z.object({ serverId: z.string().min(1), rules: filterRulesSchema })) .refine(rows => new Set(rows.map(r => r.serverId)).size === rows.length), live: z.boolean().optional(), stale: z.boolean().optional(), error: z.string().optional(), }) export const filtersMutationSchema = z.object({ ok: z.literal(true), rules: filterRulesSchema.optional() }) export const filtersGreResponseSchema = z.object({ tunnels: z.array(z.object({ id: z.string().min(1), serverId: z.string().min(1), name: z.string(), localAddress: z.string(), remoteAddress: z.string(), localInnerIp: z.string(), remoteInnerIp: z.string(), poolId: z.string(), ipsec: z.object({ secret: z.literal("") }).nullable(), mtu: z.number().int().nonnegative(), keepaliveInterval: z.number().int().nonnegative(), keepaliveRetries: z.number().int().nonnegative(), dscp: z.union([z.literal("inherit"), z.number().int().min(0).max(63)]), clampTcpMss: z.boolean(), allowFastPath: z.boolean(), comment: z.string(), enabled: z.boolean(), status: z.enum(["up", "down", "degraded"]), })).refine(rows => new Set(rows.map(r => r.id)).size === rows.length), }) export const filtersRecursiveResponseSchema = z.object({ routes: z.array(z.object({ id: z.string().min(1), dstAddress: z.string(), gateway: z.string(), distance: z.number().int().nonnegative(), routingTable: z.string(), comment: z.string(), disabled: z.boolean() })) .refine(rows => new Set(rows.map(r => r.id)).size === rows.length), stale: z.boolean().optional(), })