/** * Advanced query parser for search * * Supports: * - Boolean operators: AND, OR, NOT * - Field-specific search: status:in-progress, tag:api, priority:high * - Date range filters: created:>2025-11-01, created:2025-11-01..2025-11-15 * - Fuzzy matching: term~ * - Quoted phrases: "exact phrase" */ /** * Token types for the query lexer */ export type TokenType = 'TERM' | 'PHRASE' | 'FIELD' | 'AND' | 'OR' | 'NOT' | 'LPAREN' | 'RPAREN' | 'FUZZY' | 'EOF'; /** * A token from the lexer */ export interface Token { type: TokenType; value: string; position: number; } /** * AST node types */ export type ASTNodeType = 'AND' | 'OR' | 'NOT' | 'TERM' | 'PHRASE' | 'FIELD' | 'FUZZY'; /** * Abstract Syntax Tree node */ export interface ASTNode { type: ASTNodeType; value?: string; field?: string; left?: ASTNode; right?: ASTNode; children?: ASTNode[]; } /** * Parsed query result */ export interface ParsedQuery { ast: ASTNode | null; /** Plain text terms for simple matching */ terms: string[]; /** Field filters extracted from query */ fields: FieldFilter[]; /** Date range filters */ dateFilters: DateFilter[]; /** Fuzzy terms */ fuzzyTerms: string[]; /** Whether the query has advanced syntax */ hasAdvancedSyntax: boolean; /** Original query string */ originalQuery: string; /** Parse errors if any */ errors: string[]; } /** * Field filter (e.g., status:in-progress) */ export interface FieldFilter { field: string; value: string; /** Whether to match exactly or as substring */ exact: boolean; } /** * Date range filter */ export interface DateFilter { field: string; operator: '>' | '<' | '>=' | '<=' | '=' | 'range'; value: string; endValue?: string; } /** * Supported field prefixes for field-specific search */ export declare const SUPPORTED_FIELDS: readonly ["status", "tag", "tags", "priority", "assignee", "title", "name", "created", "updated"]; export type SupportedField = (typeof SUPPORTED_FIELDS)[number]; /** * Tokenize a query string */ export declare function tokenize(query: string): Token[]; /** * Parse a search query string into a structured query object * * @param query - The search query string * @returns Parsed query with AST, terms, filters, etc. */ export declare function parseQuery(query: string): ParsedQuery; /** * Calculate Levenshtein distance between two strings * Used for fuzzy matching */ export declare function levenshteinDistance(a: string, b: string): number; /** * Check if a term fuzzy matches a text * * @param term - The search term * @param text - The text to search in * @param maxDistance - Maximum edit distance (default: auto based on term length) * @returns True if the term fuzzy matches any word in the text */ export declare function fuzzyMatch(term: string, text: string, maxDistance?: number): boolean; /** * Generate search syntax help text */ export declare function getSearchSyntaxHelp(): string; //# sourceMappingURL=query-parser.d.ts.map