fix(api): сохранять каталог пинг-проб атомарно
This commit is contained in:
1 parent
9c22fa8a68
commit
53c1bfbd3b
15 files changed
+243
-122
No files matched your search
@@ -15,3 +15,5 @@ export * from "./ospf-optimizer.js"
|
||||
export * from "./evobgp.js"
|
||||
|
||||
export * from "./uptime-speed.js"
|
||||
|
||||
export * from "./uptime-probes.js"
|
||||
@@ -0,0 +1,12 @@
|
||||
import { z } from "zod"
|
||||
const serverId = z.union([z.number(), z.string().regex(/^[1-9][0-9]*$/).transform(Number)]).pipe(z.number().int().positive().max(Number.MAX_SAFE_INTEGER))
|
||||
const interval = z.union([z.number(), z.string().regex(/^[0-9]+$/).transform(Number), z.literal("").transform(() => 0), z.null().transform(() => 0)]).pipe(z.number().int().min(0).max(2147483647))
|
||||
export const pingProbeWriteSchema = z.object({
|
||||
id: z.string().trim().min(1), srcServerId: serverId,
|
||||
srcInterface: z.string().trim().default(""), name: z.string().trim().min(1), target: z.string().trim().min(1),
|
||||
filter: z.string().trim().transform(value => value || "—").default("—"), enabled: z.boolean(),
|
||||
showOnDashboard: z.boolean().optional(), intervalSec: interval.optional(),
|
||||
})
|
||||
export const pingProbesWriteSchema = z.object({ probes: z.array(pingProbeWriteSchema).refine(rows => new Set(rows.map(row => row.id)).size === rows.length, "Повторный ID Ping-пробы") })
|
||||
export const probeCatalogSavedSchema = z.object({ ok: z.literal(true), warning: z.string().min(1).optional() })
|
||||
export type PingProbeWrite = z.infer<typeof pingProbeWriteSchema>
|
||||
Reference in new issue
Block a user