fix(ui): подтверждать операции рекурсивных маршрутов
This commit is contained in:
1 parent
79a8d95e7d
commit
f5fc9282e2
11 files changed
+364
-138
No files matched your search
@@ -0,0 +1,22 @@
|
||||
import { z } from "zod"
|
||||
import { vxlanServersSchema } from "@/lib/vxlan-response"
|
||||
export const recursiveServersSchema = vxlanServersSchema
|
||||
export const recursiveRowSchema = z.object({
|
||||
id: z.string().trim().min(1), dstAddress: z.string().trim().min(1), gateway: z.string().trim().min(1),
|
||||
distance: z.number().int().min(0).max(255), scope: z.number().int().min(0).max(255).nullable(),
|
||||
targetScope: z.number().int().min(0).max(255).nullable(), routingTable: z.string().trim().min(1),
|
||||
checkGateway: z.string(), comment: z.string(), disabled: z.boolean(), country: z.string(),
|
||||
})
|
||||
const rows = z.array(recursiveRowSchema).refine(rows => new Set(rows.map(row => row.id)).size === rows.length)
|
||||
export const recursiveReadSchema = z.object({
|
||||
serverId: z.number().int().positive(), routes: rows, live: z.boolean(), stale: z.boolean(), error: z.string().optional(),
|
||||
}).refine(data => data.live !== data.stale)
|
||||
export const recursiveReceiptSchema = z.object({
|
||||
ok: z.literal(true), serverId: z.number().int().positive(), routes: rows, pushedRoutes: z.number().int().nonnegative(),
|
||||
}).refine(data => data.pushedRoutes === data.routes.length)
|
||||
export const recursiveGatewaysSchema = z.object({
|
||||
serverId: z.number().int().positive(), gateways: z.array(z.object({
|
||||
id: z.string().min(1), name: z.string(), ip: z.string().min(1), status: z.enum(["up", "down"]),
|
||||
})).refine(rows => new Set(rows.map(row => row.id)).size === rows.length),
|
||||
})
|
||||
export type RecursiveRouteRow = z.infer<typeof recursiveRowSchema>
|
||||
Reference in new issue
Block a user