UNPKG

rhombus-node-mcp

Version:
66 lines (65 loc) 2.4 kB
import { postApi } from "../network/network.js"; export async function getOrgAlarmStatus(requestModifiers, sessionId) { const res = await postApi({ route: "/alertmonitoring/orgStatus", body: {}, modifiers: requestModifiers, sessionId, }); if (res.error) { throw new Error(res.errorMsg ?? "Failed to get org alarm status"); } const statuses = res.locationStatuses ?? {}; return Object.entries(statuses).map(([locationUuid, status]) => ({ locationUuid, enabled: status?.enabled ?? undefined, enabledOnMs: status?.enabledOnMs ?? undefined, disabledOnMs: status?.disabledOnMs ?? undefined, notEnabledReason: status?.notEnabledReason ?? undefined, })); } export async function getAlertMonitoringThreatCases(startTimeMs, endTimeMs, maxResults, requestModifiers, sessionId) { const body = {}; if (startTimeMs) body.afterTimestampMs = startTimeMs; if (endTimeMs) body.beforeTimestampMs = endTimeMs; if (maxResults) body.maxResults = maxResults; const res = await postApi({ route: "/event/getAlertMonitoringThreatCases", body, modifiers: requestModifiers, sessionId, }); if (res.error) { throw new Error(res.errorMsg ?? "Failed to get threat cases"); } return (res.threatCases?.map(tc => ({ uuid: tc.uuid ?? undefined, status: tc.status ?? undefined, locationName: tc.locationName ?? undefined, locationUuid: tc.locationUuid ?? undefined, deviceUuid: tc.deviceUuid ?? undefined, createdAtMillis: tc.createdAtMillis ?? undefined, promptTitle: tc.promptTitle ?? undefined, })) ?? []); } export async function getLocationAlarmStatus(locationUuid, requestModifiers, sessionId) { const res = await postApi({ route: "/alertmonitoring/locationStatus", body: { locationUuid }, modifiers: requestModifiers, sessionId, }); if (res.error) { throw new Error(res.errorMsg ?? "Failed to get location alarm status"); } return { locationUuid, enabled: res.status?.enabled ?? undefined, enabledOnMs: res.status?.enabledOnMs ?? undefined, disabledOnMs: res.status?.disabledOnMs ?? undefined, notEnabledReason: res.status?.notEnabledReason ?? undefined, }; }