diff --git a/server/types/shared.ts b/server/types/shared.ts index 4b61d15..b1676bb 100644 --- a/server/types/shared.ts +++ b/server/types/shared.ts @@ -19,6 +19,10 @@ export function isArray(arg: unknown, isT: TypeGuard): arg is Array { return true; } +export function isMap(arg: unknown): arg is Map { + return arg instanceof Map; +} + export function isString(arg: unknown): arg is string { return typeof arg === "string" } @@ -333,8 +337,20 @@ export interface NodesFilter { hasKey?: boolean; hasCoords?: boolean; monitoringState?: MonitoringState; + site?: Site; + domain?: Domain; + onlineState?: OnlineState; } +export const NODES_FILTER_FIELDS = { + hasKey: Boolean, + hasCoords: Boolean, + monitoringState: MonitoringState, + site: String, + domain: String, + onlineState: OnlineState, +}; + export function isNodesFilter(arg: unknown): arg is NodesFilter { if (!isObject(arg)) { return false; @@ -343,6 +359,9 @@ export function isNodesFilter(arg: unknown): arg is NodesFilter { return ( isOptional(filter.hasKey, isBoolean) && isOptional(filter.hasCoords, isBoolean) && - isOptional(filter.monitoringState, isMonitoringState) + isOptional(filter.monitoringState, isMonitoringState) && + isOptional(filter.site, isSite) && + isOptional(filter.domain, isDomain) && + isOptional(filter.onlineState, isOnlineState) ); }