import { toStaticParam, type Condition, type LiteralValue, type Parameter, type SimpleOperator } from '../../../zero-protocol/src/ast.ts'; import type { Schema } from '../../../zero-schema/src/builder/schema-builder.ts'; import type { AvailableRelationships, DestTableName, ExistsOptions, GetFilterType, NoCompoundTypeSelector, PullTableSchema, Query } from './query.ts'; export type ParameterReference = { [toStaticParam](): Parameter; }; /** * A factory function that creates a condition. This is used to create * complex conditions that can be passed to the `where` method of a query. * * @example * * ```ts * const condition: ExpressionFactory = ({and, cmp, or}) => * and( * cmp('name', '=', 'Alice'), * or(cmp('age', '>', 18), cmp('isStudent', '=', true)), * ); * * const query = z.query.user.where(condition); * ``` */ export interface ExpressionFactory { (eb: ExpressionBuilder): Condition; } export declare class ExpressionBuilder { #private; constructor(exists: (relationship: string, cb?: ((query: Query) => Query) | undefined, options?: ExistsOptions | undefined) => Condition); get eb(): this; cmp>, TOperator extends SimpleOperator>(field: TSelector, op: TOperator, value: GetFilterType, TSelector, TOperator> | ParameterReference): Condition; cmp>>(field: TSelector, value: GetFilterType, TSelector, '='> | ParameterReference): Condition; cmpLit(left: ParameterReference | LiteralValue, op: SimpleOperator, right: ParameterReference | LiteralValue): Condition; and: typeof and; or: typeof or; not: typeof not; exists: >(relationship: TRelationship, cb?: ((query: Query>) => Query) | undefined, options?: ExistsOptions | undefined) => Condition; } export declare function and(...conditions: (Condition | undefined)[]): Condition; export declare function or(...conditions: (Condition | undefined)[]): Condition; export declare function not(expression: Condition): Condition; export declare function cmp(field: string, opOrValue: SimpleOperator | ParameterReference | LiteralValue, value?: ParameterReference | LiteralValue): Condition; export declare const TRUE: Condition; export declare function simplifyCondition(c: Condition): Condition; export declare function flatten(type: 'and' | 'or', conditions: readonly Condition[]): Condition[]; declare const negateOperatorMap: { readonly EXISTS: "NOT EXISTS"; readonly "NOT EXISTS": "EXISTS"; readonly "=": "!="; readonly "!=": "="; readonly "<": ">="; readonly ">": "<="; readonly ">=": "<"; readonly "<=": ">"; readonly IN: "NOT IN"; readonly "NOT IN": "IN"; readonly LIKE: "NOT LIKE"; readonly "NOT LIKE": "LIKE"; readonly ILIKE: "NOT ILIKE"; readonly "NOT ILIKE": "ILIKE"; readonly IS: "IS NOT"; readonly "IS NOT": "IS"; }; export declare function negateOperator(op: OP): (typeof negateOperatorMap)[OP]; export {}; //# sourceMappingURL=expression.d.ts.map