import { QueryDef, QueryTarget, Operator, QueryByAliasObj } from './query.js';
import { BasedQueryResponse } from './BasedIterable.js';
import { Search } from './search/index.js';
import { OnData, OnError, OnClose } from './subscription/index.js';
import { DbClient } from '../index.js';
import { LangName } from '@based/schema';
import { FilterAst, FilterBranchFn, FilterOpts } from './filter/types.js';
export { QueryByAliasObj };
export type SelectFn = (field: string) => BasedDbReferenceQuery;
export type BranchInclude = (select: SelectFn) => any;
export type QueryCommand = {
    method: string;
    args: any[];
};
export declare class QueryBranch<T> {
    db: DbClient;
    def: QueryDef;
    queryCommands: QueryCommand[];
    constructor(db: DbClient, def?: QueryDef);
    sort(field: string, order?: 'asc' | 'desc'): T;
    filter<O extends Operator>(field: string, operator?: O | boolean, value?: any, opts?: FilterOpts<O>): T;
    filterBatch(f: FilterAst): this;
    search(query: string, ...fields: Search[]): T;
    search(query: ArrayBufferView, field: string, opts?: Omit<FilterOpts, 'lowerCase'>): T;
    groupBy(field: string): T;
    count(field?: string): T;
    sum(...fields: (string | string[])[]): T;
    or(fn: FilterBranchFn): T;
    or(field: string, operator?: Operator | boolean, value?: any, opts?: FilterOpts): T;
    range(start: number, end?: number): T;
    include(...fields: (string | BranchInclude | string[])[]): T;
}
export declare class BasedDbReferenceQuery extends QueryBranch<BasedDbReferenceQuery> {
}
declare class GetPromise extends Promise<BasedQueryResponse> {
    toObject(): Promise<any>;
    toJSON(): Promise<string>;
    inspect(depth?: number, raw?: boolean): GetPromise;
}
export declare class BasedDbQuery extends QueryBranch<BasedDbQuery> {
    #private;
    skipValidation: boolean;
    target: QueryTarget;
    constructor(db: DbClient, type: string, rawTarget?: QueryByAliasObj | number | Uint32Array | (QueryByAliasObj | number)[], skipValidation?: boolean);
    reset(): void;
    id: number;
    get(): GetPromise;
    buffer: Uint8Array;
    register(): void;
    locale(locale: LangName): this;
    subscribe(onData: OnData, onError?: OnError): OnClose;
    _getSync(dbCtxExternal: any): BasedQueryResponse;
}
