/** * SQL Mode 2 — Types * * All types for the SQL execution engine. */ export type SqlMode2Dialect = 'mysql' | 'postgresql' | 'mariadb' | 'sqlite' | 'bigquery'; export interface SqlOptions { /** Parameterized query values — supports both MySQL (?) and PostgreSQL ($1) style */ params?: unknown[]; /** SQL dialect for the parser — default: 'mysql' */ dialect?: SqlMode2Dialect; /** Returns results AND full execution plan */ explain?: boolean; /** SQL backends only — bypasses Mode 2, passes SQL directly to native driver */ raw?: boolean; } export interface SqlMode2Result { data: Record[]; plan?: ExplainPlan; } export interface ExplainPlan { phases: number; dependencies: DependencyInfo[]; pipelines: PipelineInfo[]; parallel: boolean; durationMs: number; } export interface DependencyInfo { type: 'subquery' | 'cte' | 'insert-select'; collection: string; pipeline: Record[]; resultCount: number; } export interface PipelineInfo { collection: string; stages: Record[]; } export type SqlStatementType = 'select' | 'insert' | 'update' | 'delete' | 'transaction'; export interface ExecutionPlan { type: SqlStatementType; collection: string; dependencies: Dependency[]; pipelines: PipelineDef[]; parallel: boolean; isAggregate: boolean; isTransaction: boolean; statements?: ParsedStatement[]; writeOps?: WriteOperation[]; } export interface Dependency { id: string; type: 'subquery' | 'cte' | 'insert-select'; collection: string; pipeline: Record[]; injectAs: 'in' | 'nin' | 'exists' | 'not-exists' | 'cte-result' | 'scalar'; targetField?: string; dependsOn?: string[]; } export interface PipelineDef { collection: string; stages: Record[]; } export interface WriteOperation { type: 'insertOne' | 'insertMany' | 'updateOne' | 'updateMany' | 'deleteOne' | 'deleteMany'; collection: string; document?: Record; documents?: Record[]; filter?: Record; update?: Record; /** Columns requested by RETURNING clause (INSERT ... RETURNING col1, col2) */ returning?: string[]; } export interface ParsedStatement { sql: string; type: SqlStatementType; } export interface TableRef { table: string; alias?: string; } export interface ColumnRef { field: string; table?: string; alias?: string; expr?: unknown; } export interface JoinCondition { localField: string; foreignField: string; } export interface JoinInfo { type: 'inner' | 'left' | 'right' | 'full' | 'cross'; table: string; alias?: string; localField: string; foreignField: string; /** Multi-condition ON clauses (when present, use pipeline-form $lookup) */ conditions?: JoinCondition[]; } export interface AggregateField { func: string; field: string; alias: string; distinct?: boolean; } export interface WindowSpec { func: string; field?: string; alias: string; partitionBy?: string[]; orderBy?: Array<{ field: string; direction: 1 | -1; }>; offset?: number; } export interface SqlErrorInfo { code: string; message: string; fix: string; sql: string; } //# sourceMappingURL=types.d.ts.map