14 lines
910 B
TypeScript
14 lines
910 B
TypeScript
import { speedProbeReadSchema } from "@mmapp/contracts"
|
|
import type { UptimeSpeedProbeRow } from "../db/schema.js"
|
|
const timestamp = (value: string | null) => value === null ? null : new Date(value).toISOString()
|
|
export function mapSpeedProbeRead(row: UptimeSpeedProbeRow) {
|
|
return speedProbeReadSchema.parse({
|
|
id: row.id, srcServerId: String(row.srcServerId), dstServerId: String(row.dstServerId),
|
|
srcInterface: row.srcInterface, dstInterface: row.dstInterface,
|
|
protocol: row.protocol, direction: row.direction, durationSec: String(row.durationSec), enabled: row.enabled,
|
|
lastRunAt: timestamp(row.lastRunAt), lastTxAvgMbps: row.lastTxAvgMbps, lastRxAvgMbps: row.lastRxAvgMbps,
|
|
lastStatus: row.lastStatus, lastError: row.lastError,
|
|
lastPingRttMs: row.lastPingRttMs, lastPingLossPct: row.lastPingLossPct, lastPingAt: timestamp(row.lastPingAt), lastPingError: row.lastPingError,
|
|
})
|
|
}
|