/** * Important: * --------------- * Model files should not use external imports except for other model files. * Other model files should also be imported directly not via their module * this can otherwise cause issue with ts-to-json-schema conversions in certain scenarios * */ import { DeviceAttributes, NodeAttributes, PropertyAttributes } from "./Base.model"; import { Primitive } from "./RXObject.model"; export const ConditionOperators = ['=' , '>' , '<' , '>=' , '<=' , '<>' , 'includes' , 'includesAny' , 'includesAll' , 'includesNone' , 'matchAlways'] as const; export type ConditionOperator = typeof ConditionOperators[number]; export interface ValueOperatorCondition { operator: ConditionOperator; value?: T | T[]; } export function isValueOperatorCondition(object: any): object is ValueOperatorCondition { return typeof object === 'object' && Object.prototype.hasOwnProperty.call(object, 'operator') && ConditionOperators.includes(object['operator']) ; } export type ValueCondition = T | T[] | ValueOperatorCondition; export type BaseRXObjectCondition = { [P in keyof T]?: ValueCondition; }; export type RXObjectQuery = Primitive | BaseRXObjectCondition | undefined | null; export interface Query { device?: DeviceQuery; node?: NodeQuery; property?: PropertyQuery; } export type DeviceQuery = RXObjectQuery; export type NodeQuery = RXObjectQuery; export type PropertyQuery = RXObjectQuery;