import { toStaticParam, type Condition, type LiteralValue, type Parameter, type SimpleOperator } from '../../../zero-protocol/src/ast.ts';
import type { Schema as ZeroSchema } from '../../../zero-types/src/schema.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<User> = ({and, cmp, or}) =>
 *   and(
 *     cmp('name', '=', 'Alice'),
 *     or(cmp('age', '>', 18), cmp('isStudent', '=', true)),
 *   );
 *
 * const query = z.query.user.where(condition);
 * ```
 */
export interface ExpressionFactory<TTable extends keyof TSchema['tables'] & string, TSchema extends ZeroSchema> {
    (eb: ExpressionBuilder<TTable, TSchema>): Condition;
}
export declare class ExpressionBuilder<TTable extends keyof TSchema['tables'] & string, TSchema extends ZeroSchema> {
    #private;
    constructor(exists: (relationship: string, cb?: (query: Query<TTable, TSchema>) => Query<TTable, TSchema, any>, options?: ExistsOptions) => Condition);
    get eb(): this;
    cmp<TSelector extends NoCompoundTypeSelector<PullTableSchema<TTable, TSchema>>, TOperator extends SimpleOperator>(field: TSelector, op: TOperator, value: GetFilterType<PullTableSchema<TTable, TSchema>, TSelector, TOperator> | ParameterReference | undefined): Condition;
    cmp<TSelector extends NoCompoundTypeSelector<PullTableSchema<TTable, TSchema>>>(field: TSelector, value: GetFilterType<PullTableSchema<TTable, TSchema>, TSelector, '='> | ParameterReference | undefined): Condition;
    cmpLit(left: ParameterReference | LiteralValue | undefined, op: SimpleOperator, right: ParameterReference | LiteralValue | undefined): Condition;
    and: typeof and;
    or: typeof or;
    not: typeof not;
    exists: <TRelationship extends AvailableRelationships<TTable, TSchema>>(relationship: TRelationship, cb?: (query: Query<DestTableName<TTable, TSchema, TRelationship>, TSchema>) => Query<any, TSchema>, options?: ExistsOptions) => 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 | undefined, value?: ParameterReference | LiteralValue | undefined): 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 extends keyof typeof negateOperatorMap>(op: OP): (typeof negateOperatorMap)[OP];
export {};
//# sourceMappingURL=expression.d.ts.map