UNPKG

@react-awesome-query-builder/sql

Version:
83 lines (82 loc) 2.16 kB
import { Func, RuleValue, SqlImportFunc, ValueSource } from "@react-awesome-query-builder/core"; import type { LocationRange } from "node-sql-parser"; declare module "node-sql-parser" { interface BaseExpr { parentheses?: boolean; } interface BinaryExpr extends BaseExpr { type: "binary_expr"; operator: string; left: Logic; right: Logic; loc?: LocationRange; } interface ConjExpr extends BaseExpr { type: "binary_expr"; operator: "AND" | "OR"; left: Logic; right: Logic; loc?: LocationRange; } interface UnaryExpr extends BaseExpr { type: "unary_expr"; operator: string; expr: Logic; } type AnyExpr = BinaryExpr | ConjExpr | UnaryExpr | ExprList; type Logic = AnyExpr | ExpressionValue; } export interface Conv { conjunctions: Record<string, string>; operators: Record<string, string[]>; opFuncs: Record<string, SqlImportFunc[]>; valueFuncs: Record<string, SqlImportFunc[]>; } export interface Meta { errors: string[]; warnings: string[]; convertedObj?: OutSelect; opKey?: string; funcKey?: string; widgetKey?: string; outType?: "op" | "func" | "value"; } export interface OutLogic { parentheses?: boolean; not?: boolean; conj?: string; children?: OutLogic[]; ternaryChildren?: [OutLogic | undefined, OutLogic][]; field?: string; table?: string; value?: any; values?: any[]; valueType?: string; oneValueType?: string; operator?: string; func?: string; _type?: string; unit?: string; } export interface OutSelect { where?: OutLogic; select?: OutLogic; } export interface ValueObj { valueType?: string; value: RuleValue; valueSrc: ValueSource; valueError?: string; _maybeValueType?: string; } export type FuncArgsObj = Record<string, ValueObj>; export interface FuncWithArgsObj { func: string; funcConfig?: Func | null; args: FuncArgsObj; } export interface OperatorObj { operator: string; children: Array<any>; operatorOptions?: Record<string, any>; }