/** * Query Parser * * Parses advanced search queries with field filters, boolean operators, * comparisons, and date/time queries. * * @since v1.68.0 * * Query syntax: * - Basic: `luckperms` - search for term * - Exact phrase: `"luck perms"` - exact phrase match * - Field filter: `name:luck` `author:lucko` `source:modrinth` * - Status filter: `is:installed` `is:outdated` `is:healthy` * - Boolean: `luck AND perms` `luck OR vault` `luck NOT deprecated` * - Comparison: `downloads:>10000` `rating:>=4.5` `updated:<30d` * - Date/time: `updated:today` `created:this-week` `updated:2024-01-01..now` * - Sort: `sort:name` `sort:downloads:desc` */ /** * Token types in the query language */ export type TokenType = 'TERM' | 'PHRASE' | 'FIELD' | 'OPERATOR' | 'COMPARISON' | 'VALUE' | 'COLON' | 'LPAREN' | 'RPAREN' | 'EOF'; /** * A token from lexical analysis */ export interface Token { type: TokenType; value: string; position: number; } /** * Parsed query node types */ export type QueryNodeType = 'term' | 'phrase' | 'field' | 'comparison' | 'and' | 'or' | 'not' | 'group'; /** * Comparison operators */ export type ComparisonOp = '=' | '>' | '<' | '>=' | '<=' | '!='; /** * A node in the parsed query tree */ export interface QueryNode { type: QueryNodeType; value?: string; field?: string; operator?: ComparisonOp; children?: QueryNode[]; negated?: boolean; } /** * Known field names for autocomplete */ export declare const KNOWN_FIELDS: readonly ["name", "author", "version", "source", "category", "tag", "description"]; /** * Known status filters */ export declare const STATUS_FILTERS: readonly ["installed", "outdated", "healthy", "error", "favorite", "pinned", "deprecated", "disabled"]; /** * Known sort fields */ export declare const SORT_FIELDS: readonly ["name", "downloads", "updated", "rating", "health", "size"]; /** * Date shortcuts */ export declare const DATE_SHORTCUTS: Record number>; /** * Parse a duration string (e.g., "30d", "2w", "6h") */ export declare function parseDuration(value: string): number | null; /** * Parse a date value (shortcut, duration, or ISO date) */ export declare function parseDate(value: string): number | null; /** * Parse a size value (e.g., "1mb", "500kb") */ export declare function parseSize(value: string): number | null; /** * Tokenize a query string */ export declare function tokenize(query: string): Token[]; /** * Parse tokens into a query tree */ export declare function parse(tokens: Token[]): QueryNode; /** * Parsed query with metadata */ export interface ParsedQuery { /** The original query string */ original: string; /** Parsed query tree */ tree: QueryNode; /** Extracted terms for text search */ terms: string[]; /** Field filters */ filters: Array<{ field: string; value: string; operator: ComparisonOp; }>; /** Status filters (is:xxx) */ statusFilters: string[]; /** Sort specification */ sort?: { field: string; direction: 'asc' | 'desc'; }; /** Whether query has errors */ hasErrors: boolean; /** Error messages */ errors: string[]; } /** * Parse a query string into a structured query */ export declare function parseQuery(query: string): ParsedQuery; /** * Get autocomplete suggestions for a partial query */ export declare function getAutocompleteSuggestions(query: string, cursorPosition?: number): Array<{ text: string; description: string; }>; /** * Format a query tree back to a string */ export declare function formatQuery(node: QueryNode): string; //# sourceMappingURL=query-parser.d.ts.map