/** * Boolean filter expression parsed from a single `filter=` query parameter. * * Grammar (precedence: NOT > AND > OR), case-insensitive keywords: * expr := or * or := and (OR and)* * and := not (AND not)* * not := NOT not | primary * primary := '(' expr ')' | leaf * leaf := column '=' value // value uses the existing $op:operand syntax * * Tokens are whitespace-delimited; `(` and `)` are punctuation. A value containing * whitespace or a `(` `)` must be quoted with `"` or `'`. Inside a quoted value a backslash * escapes a following quote or backslash (`\"`, `\'`, `\\`); any other backslash is literal. */ export type FilterExpression = { type: 'and'; children: FilterExpression[]; } | { type: 'or'; children: FilterExpression[]; } | { type: 'not'; child: FilterExpression; } | { type: 'leaf'; column: string; value: string; }; /** * Default cap on the number of nodes (leaves, AND/OR/NOT operators, and parenthesised * groups) a single `filter=` expression may contain. Because the parser is recursive, an * unbounded expression is a denial-of-service vector: a deeply nested or very wide payload * can exhaust the call stack or blow up the generated SQL. 100 nodes comfortably covers any * realistic query while keeping the parse cheap. Override per-endpoint via * `PaginateConfig.filterExpressionMaxComplexity`. */ export declare const DEFAULT_FILTER_EXPRESSION_MAX_COMPLEXITY = 100; /** Filter expression with negation pushed onto the leaves, so only AND/OR groups remain. */ export type NormalizedFilterExpression = { type: 'and'; children: NormalizedFilterExpression[]; } | { type: 'or'; children: NormalizedFilterExpression[]; } | { type: 'leaf'; column: string; value: string; negated: boolean; }; export declare function parseFilterExpression(input: string, maxComplexity?: number): FilterExpression; /** * Parses a `filter=` expression and returns the column of every leaf term (duplicates included, * in source order). Used to discover which columns a request references so depth-based allowlisting * (`PaginateConfig.allowDepth`) can consider them without enumerating each one. */ export declare function collectFilterExpressionColumns(input: string, maxComplexity?: number): string[]; /** Pushes every NOT down onto the leaves via De Morgan, leaving only AND/OR groups. */ export declare function normalizeFilterExpression(node: FilterExpression, negated?: boolean): NormalizedFilterExpression;