type PassiveChannelStatusSnapshot = { configured?: boolean; running?: boolean; lastStartAt?: number | null; lastStopAt?: number | null; lastError?: string | null; probe?: unknown; lastProbeAt?: number | null; }; type TrafficStatusSnapshot = { lastInboundAt?: number | null; lastOutboundAt?: number | null; }; export function buildPassiveChannelStatusSummary( snapshot: PassiveChannelStatusSnapshot, extra?: TExtra, ) { return { configured: snapshot.configured ?? false, ...(extra ?? ({} as TExtra)), running: snapshot.running ?? false, lastStartAt: snapshot.lastStartAt ?? null, lastStopAt: snapshot.lastStopAt ?? null, lastError: snapshot.lastError ?? null, }; } export function buildPassiveProbedChannelStatusSummary( snapshot: PassiveChannelStatusSnapshot, extra?: TExtra, ) { return { ...buildPassiveChannelStatusSummary(snapshot, extra), probe: snapshot.probe, lastProbeAt: snapshot.lastProbeAt ?? null, }; } export function buildTrafficStatusSummary( snapshot?: TSnapshot | null, ) { return { lastInboundAt: snapshot?.lastInboundAt ?? null, lastOutboundAt: snapshot?.lastOutboundAt ?? null, }; }