mirror of https://github.com/openclaw/openclaw.git
49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
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<TExtra extends object>(
|
|
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<TExtra extends object>(
|
|
snapshot: PassiveChannelStatusSnapshot,
|
|
extra?: TExtra,
|
|
) {
|
|
return {
|
|
...buildPassiveChannelStatusSummary(snapshot, extra),
|
|
probe: snapshot.probe,
|
|
lastProbeAt: snapshot.lastProbeAt ?? null,
|
|
};
|
|
}
|
|
|
|
export function buildTrafficStatusSummary<TSnapshot extends TrafficStatusSnapshot>(
|
|
snapshot?: TSnapshot | null,
|
|
) {
|
|
return {
|
|
lastInboundAt: snapshot?.lastInboundAt ?? null,
|
|
lastOutboundAt: snapshot?.lastOutboundAt ?? null,
|
|
};
|
|
}
|