UNPKG

@statezero/core

Version:

The type-safe frontend client for StateZero - connect directly to your backend models with zero boilerplate

71 lines (70 loc) 1.97 kB
/** * Minimal type definitions for field lookups. * * @template T * @typedef {Object.<string, any>} FieldLookup */ /** * Minimal type definitions for object lookups. * * @template T * @typedef {Object.<string, any>} ObjectLookup */ /** * Django-specific Q helper type. * * A QCondition is either a partial object of type T or a combination * of partial field and object lookups. * * @template T * @typedef {Partial<T> | (Partial<FieldLookup<T>> & Partial<ObjectLookup<T>>)} QCondition */ /** * Django-specific Q helper type representing a logical grouping of conditions. * * @template T * @typedef {Object} QObject * @property {'AND'|'OR'} operator - The logical operator. * @property {Array<QCondition<T>|QObject<T>>} conditions - An array of conditions or nested Q objects. */ /** * Creates a Q object for combining conditions. * * @template T * @param {'AND'|'OR'} operator - The operator to combine conditions. * @param {...(QCondition<T>|QObject<T>)} conditions - The conditions to combine. * @returns {QObject<T>} The combined Q object. */ export function Q<T>(operator: "AND" | "OR", ...conditions: (QCondition<T> | QObject<T>)[]): QObject<T>; /** * Minimal type definitions for field lookups. */ export type FieldLookup<T> = { [x: string]: any; }; /** * Minimal type definitions for object lookups. */ export type ObjectLookup<T> = { [x: string]: any; }; /** * Django-specific Q helper type. * * A QCondition is either a partial object of type T or a combination * of partial field and object lookups. */ export type QCondition<T> = Partial<T> | (Partial<FieldLookup<T>> & Partial<ObjectLookup<T>>); /** * Django-specific Q helper type representing a logical grouping of conditions. */ export type QObject<T> = { /** * - The logical operator. */ operator: "AND" | "OR"; /** * - An array of conditions or nested Q objects. */ conditions: Array<QCondition<T> | QObject<T>>; };