fix(api): сохранить неизвестные значения истории скорости

This commit is contained in:
Denozordec committed 2026-10-04 05:19:34 +07:00
1 parent e5ff69e243
commit a558412a27
13 files changed
+119 -70

No files matched your search

+2
View File
@@ -13,3 +13,5 @@ export * from "./statistics.js"
export * from "./ospf-optimizer.js"
export * from "./evobgp.js"
export * from "./uptime-speed.js"
+17
View File
@@ -0,0 +1,17 @@
import { z } from "zod"
const rate = z.number().finite().nonnegative().nullable()
export const speedHistoryRunSchema = z.object({
id:z.string().min(1), probeId:z.string().nullable().optional(),
srcServerId:z.string().regex(/^[1-9][0-9]*$/), dstServerId:z.string().regex(/^[1-9][0-9]*$/),
srcInterface:z.string(), dstInterface:z.string(),
protocol:z.enum(["tcp","udp"]), direction:z.enum(["transmit","receive","both"]), durationSec:z.number().int().positive(),
txAvgMbps:rate, rxAvgMbps:rate, status:z.enum(["done","error"]), error:z.string().nullable().optional(),
createdAt:z.string().datetime({offset:true}),
srcAddress:z.string().nullable().optional(),dstAddress:z.string().nullable().optional(),
srcInterfaceAddress:z.string().nullable().optional(),dstInterfaceAddress:z.string().nullable().optional(),
afterBtPing:z.object({rttMs:rate,lossPct:z.number().finite().min(0).max(100).nullable(),error:z.string().nullable()}).nullable().optional(),
})
export const speedHistoryResponseSchema=z.object({runs:z.array(speedHistoryRunSchema).superRefine((rows,ctx)=>{
const ids=new Set<string>();for(const row of rows){if(ids.has(row.id))ctx.addIssue({code:"custom",message:"Повторный ID истории скорости"});ids.add(row.id)}
})})
export type SpeedHistoryRun=z.infer<typeof speedHistoryRunSchema>