/** * SQL to Tessio Session Query Converter * Converts SQL queries to EventHorizon.createSession() parameters */ export type ComparisonOperator = 'lt' | '<' | 'eq' | '==' | '=' | 'gt' | '>' | 'gte' | '>=' | 'lte' | '<=' | 'ne' | '!=' | 'in' | 'notin' | 'like' | '~' | '!~' | 'between'; export type AggregatorType = 'sum' | 'avg' | 'max' | 'min' | 'count' | 'expression'; export type ColumnType = 'string' | 'text' | 'number' | 'date' | 'boolean' | 'object'; export type FilterValue = string | number | boolean | Date | null | Array; export type ColumnValue = string | number | boolean | Function | null; export interface FilterDef { field: string; comparison: ComparisonOperator | string; value: FilterValue; } export interface SortDef { field: string; direction: 'asc' | 'desc'; } export interface ColumnDef { name: string; primaryKey?: boolean; secondaryKey?: boolean; columnType?: ColumnType; value?: ColumnValue; defaultValue?: ColumnValue; expression?: string; aggregator?: AggregatorType; resolve?: ResolveConfig; } export interface GroupByDef { dataIndex: string; } export interface ResolveConfig { underlyingField: string; childrenTable?: string; session?: CreateSessionParameters; valueField?: string; displayField: string; } export interface SubSessionConfig { [key: string]: CreateSessionParameters; } export interface CreateSessionParameters { id?: string; table: string | CreateSessionParameters; columns?: ColumnDef[]; filter?: FilterDef[]; sort?: SortDef[]; groupBy?: GroupByDef[]; start?: number; limit?: number; offset?: number; includeLeafs?: boolean; subSessions?: SubSessionConfig; } export interface SqlParseResult { sessionConfig: CreateSessionParameters; warnings: string[]; unsupportedFeatures: string[]; } export interface JoinInfo { type: 'INNER' | 'LEFT' | 'RIGHT' | 'FULL'; table: string; alias?: string; on: string; } export declare class SqlToTessioConverter { private warnings; private unsupportedFeatures; private subQueryCounter; /** * Convert a SQL query to Tessio session parameters * * Key Features: * - Supports nested table structures for proper WHERE + GROUP BY handling * - Applies filters before aggregation to avoid architectural limitations * - Converts SQL aggregation functions to Tessio aggregators * - Handles subqueries as SubSessions where possible */ convertSql(sql: string): SqlParseResult; /** * Normalize SQL query for parsing */ private normalizeSql; /** * Preprocess SQL to extract and replace subqueries with placeholders */ private preprocessSubqueries; /** * Find subqueries in SQL with proper parentheses matching */ private findSubqueries; /** * Check if a subquery is correlated (references outer query tables) */ private isCorrelatedSubquery; /** * Extract table names and aliases from SQL */ private extractTableReferences; /** * Parse SQL into components */ private parseSql; /** * Build session configuration from parsed SQL */ private buildSessionConfig; /** * Parse SELECT clause into columns */ private parseSelectClause; /** * Split SELECT columns while respecting function parentheses */ private splitSelectColumns; /** * Parse WHERE clause into filters */ private parseWhereClause; /** * Parse a single condition into a filter */ private parseCondition; /** * Parse value from SQL to appropriate JavaScript type */ private parseValue; /** * Parse ORDER BY clause */ private parseOrderByClause; /** * Parse GROUP BY clause */ private parseGroupByClause; /** * Add aggregation columns based on SELECT clause */ private addAggregationColumns; /** * Handle JOINs by converting them to SubSessions where possible */ private handleJoins; /** * Handle subqueries by creating appropriate subSessions and resolve configurations */ private handleSubqueries; /** * Split clause by logical operator while respecting parentheses */ private splitByLogicalOperator; /** * Check if a string represents a simple field name */ private isSimpleField; /** * Convert SQL expression to JavaScript expression */ private convertSqlExpression; /** * Generate usage examples and documentation */ generateExample(sql: string): string; } /** * Utility function to convert SQL to Tessio session config */ export declare function sqlToTessio(sql: string): SqlParseResult; /** * Utility function to generate conversion examples */ export declare function sqlToTessioExample(sql: string): string;