import { MetaType } from '../metaTypeCreator'; import { WhereFilterOp } from '../alias'; import { QueryConstraints, WhereConstraint, OrderByConstraint, CursorConstraint, LimitConstraint, OffsetConstraint, CursorType } from '../queryConstraints'; import { GeneralQuery } from '../refs'; import { LimitToLastConstraintLimitation } from './limit'; import { CursorConstraintLimitation } from './cursor'; import { OrderByConstraintLimitation, GetFirstOrderBy } from './orderBy'; import { GetFirstInequalityWhere, WhereConstraintLimitation } from './where'; import { InequalityOpStr } from './utils'; import { IsSame } from '../utils'; import { ErrorWhereOrderByAndInEquality } from '../error'; export type ValidateOrderByAndInequalityWhere = GetFirstInequalityWhere extends infer W ? W extends WhereConstraint ? GetFirstOrderBy extends infer O ? O extends OrderByConstraint ? IsSame extends true ? true : ErrorWhereOrderByAndInEquality : true : never : true : never; export type QueryConstraintLimitation, RestQCs extends QueryConstraints[], PreviousQCs extends QueryConstraints[], AllQCs extends QueryConstraints[]> = ValidateOrderByAndInequalityWhere extends string ? ValidateOrderByAndInequalityWhere[] : RestQCs extends [infer Head, ...infer Rest] ? Rest extends QueryConstraints[] ? [ Head extends LimitConstraint<'limit', number> | OffsetConstraint ? Head : Head extends OrderByConstraint ? OrderByConstraintLimitation : Head extends LimitConstraint<'limitToLast', number> ? LimitToLastConstraintLimitation : Head extends WhereConstraint ? WhereConstraintLimitation : Head extends CursorConstraint ? CursorConstraintLimitation : never, ...QueryConstraintLimitation ] : never[] : RestQCs;