import { Filter, OrderBy, SelectOptions } from './database'; import { Node as AST } from './parser/ast'; import { Field, SimpleField, Model as TableModel } from './schema'; import { Document } from './types'; import { DialectEncoder } from './engine'; import { ViewModel } from './view'; type Model = TableModel | ViewModel; export interface AliasEntry { name: string; model: Model; } export interface SelectQuery { fields: string; tables: string; where?: string; orderBy?: string; groupBy?: string; having?: string; } export declare class Context { private counter; aliasMap: { [key: string]: AliasEntry; }; fieldMap: FieldMap; constructor(); getAliasForBuilder(builder: QueryBuilder): { alias: string; seen: boolean; }; getAlias(model: Model, field: Field, names: string[]): { alias: string; seen: boolean; }; } type FieldEntry = { expr: string; name?: string; skip?: boolean; }; type HavingContext = { fieldMap: { [key: string]: FieldEntry; }; }; export declare const AND = "and"; export declare const OR = "or"; export declare const NOT = "not"; export declare const LT = "lt"; export declare const LE = "le"; export declare const GE = "ge"; export declare const GT = "gt"; export declare const NE = "ne"; export declare const IN = "in"; export declare const NOT_IN = "notIn"; export declare const LIKE = "like"; export declare const ILIKE = "ilike"; export declare const NULL = "null"; export declare const SOME = "some"; export declare const NONE = "none"; export type OperatorMap = { [key: string]: string; }; export declare const CONTAINS = "contains"; export declare const EQ = "eq"; export type JsonOperatorSyntax = 'explicit' | 'suffix' | 'both'; export interface JsonFilterOptions { operatorSyntax?: JsonOperatorSyntax; operatorDelimiter?: '_' | '__'; } type ResolvedJsonFilterOptions = Required; export declare class QueryBuilder { model: Model; field?: Field; parent?: QueryBuilder; dialect: DialectEncoder; context: Context; alias: string; skipJoin?: boolean; froms?: string[]; having?: HavingContext; operatorMap: OperatorMap; jsonOptions: ResolvedJsonFilterOptions; getFroms(): string[] | undefined; constructor(model: Model | QueryBuilder, dialect: DialectEncoder | Field, operatorMap?: OperatorMap, jsonOptions?: JsonFilterOptions); where(args: Filter): string; private or; private prefix; private and; private expr; private listExpr; private jsonWhere; private classifyJsonObject; private jsonSplitKey; private isJsonOperator; private jsonPath; private validateJsonSegment; private jsonLeaf; private jsonCompare; private jsonNull; private jsonContains; private jsonExtract; private buildPathString; private escapeJsonScalar; _extendFilter(filter: Filter, orderBy: OrderBy): Filter; _resolveField(fullpath: string, flat?: boolean): { column: string; alias?: string; }; _pushField(fields: FieldEntry[], path: string): string; _prefix(path: string, escapedField: string): string; _select(name: string | SimpleField | Document | AST[], { where: filter, orderBy, groupBy, having }: SelectOptions): SelectQuery; select(name: string | SimpleField | Document | string[], { where, orderBy, groupBy, raw, filterThunk, having, }: SelectOptions & { filterThunk?: (builder: QueryBuilder) => string; }): string; encodeField(name: string | SimpleField): string; private _join; private _in; private exists; private escape; private escapeId; splitKey(arg: string): string[]; } export declare function encodeFilter(args: Filter, model: Model, escape: DialectEncoder, operatorMap?: OperatorMap, jsonOptions?: JsonFilterOptions): string; export declare function plainify(value: unknown): unknown; export declare class FieldMap { prefix: string; map2: { [key: string]: string; }; map: { [key: string]: { alias?: string; path: string; }; }; count: number; constructor(prefix?: string); add(path: string, alias?: string): string; get(name: string): { alias?: string; path: string; }; } export {};