feat: generate frontend status metadata contract

This commit is contained in:
sjg
2026-08-01 22:27:35 +02:00
parent f87289b129
commit ddb33b6ff3
6 changed files with 38 additions and 25 deletions
@@ -1640,7 +1640,7 @@ async function responseJsonUnknown(response) {
return await response.json();
}
function isAppUpdate(value) {
return isRecord2(value) && (value.status === void 0 || isRecord2(value.status));
return isRecord2(value) && typeof value.clients === "number" && typeof value.audio_clients === "number" && typeof value.rigctl_clients === "number" && Array.isArray(value.remotes) && value.remotes.every((remote) => typeof remote === "string") && typeof value.show_sdr_gain_control === "boolean" && typeof value.initial_map_zoom === "number" && typeof value.spectrum_coverage_margin_hz === "number" && typeof value.spectrum_usable_span_ratio === "number" && typeof value.bandplan_enabled === "boolean" && typeof value.bandplan_region === "string" && typeof value.decode_history_retention_min === "number" && typeof value.server_connected === "boolean" && isRigSnapshot(value);
}
function isAudioStreamInfo(value) {
return isRecord2(value) && typeof value.sample_rate === "number" && typeof value.channels === "number";
@@ -4767,7 +4767,7 @@ async function pollFreshSnapshot() {
const resp = await fetch(statusUrl, { cache: "no-store" });
if (!resp.ok) return;
const data = await responseJsonUnknown(resp);
if (!isRigSnapshot(data)) return;
if (!isAppUpdate(data)) return;
render(data);
void refreshRigList();
lastEventAt = Date.now();