More types refactoring.
This commit is contained in:
parent
29be32907c
commit
3590ba048d
|
@ -19,6 +19,10 @@ export function isArray<T>(arg: unknown, isT: TypeGuard<T>): arg is Array<T> {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isMap(arg: unknown): arg is Map<any, any> {
|
||||||
|
return arg instanceof Map;
|
||||||
|
}
|
||||||
|
|
||||||
export function isString(arg: unknown): arg is string {
|
export function isString(arg: unknown): arg is string {
|
||||||
return typeof arg === "string"
|
return typeof arg === "string"
|
||||||
}
|
}
|
||||||
|
@ -333,8 +337,20 @@ export interface NodesFilter {
|
||||||
hasKey?: boolean;
|
hasKey?: boolean;
|
||||||
hasCoords?: boolean;
|
hasCoords?: boolean;
|
||||||
monitoringState?: MonitoringState;
|
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 {
|
export function isNodesFilter(arg: unknown): arg is NodesFilter {
|
||||||
if (!isObject(arg)) {
|
if (!isObject(arg)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -343,6 +359,9 @@ export function isNodesFilter(arg: unknown): arg is NodesFilter {
|
||||||
return (
|
return (
|
||||||
isOptional(filter.hasKey, isBoolean) &&
|
isOptional(filter.hasKey, isBoolean) &&
|
||||||
isOptional(filter.hasCoords, 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)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue