export interface Equals { $eq: T; } export interface GreaterThan { $gt: number; } export interface GreaterThanOrEqual { $gte: number; } export interface In { $in: T[]; } export interface LessThan { $lt: number; } export interface LessThanOrEqual { $lte: number; } export interface NotEqual { $ne: T; } export interface NotIn { $nin: Array; } export interface And { $and: ValueQuery[]; } export interface Not { $not: ValueQuery; } export interface Nor { $nor: ValueQuery[]; } export interface Or { $or: ValueQuery[]; } export interface Exists { $exists: boolean; } export interface Regex { $regex: RegExp; } type ComparisonQueryOperator = Equals | NotEqual | (T extends number ? GreaterThan | GreaterThanOrEqual | LessThan | LessThanOrEqual : never); type ElementQueryOperator = Exists; type EvaluationQueryOperator = T extends string ? Regex : never; export type LogicalQueryOperator = And | Nor | Or | Not; export type SetOperators = In | NotIn; export type ValueComparisonQuery = ComparisonQueryOperator | ElementQueryOperator | EvaluationQueryOperator; export type QueryOperators = LogicalQueryOperator | SetOperators | ValueComparisonQuery; export type ValueQuery = { [P in keyof T]?: QueryOperators | ValueQuery; } | QueryOperators; export {};