/** * ASTDialectAdapter — dialect-specific node-sql-parser AST field shapes. * * The only AST field that genuinely varies in shape between dialects is the * row cap: SQL Server uses `root.top`, PostgreSQL / MySQL use `root.limit`. * Each adapter encapsulates the read/write/clear logic for its dialect's row * cap. Everything else (CTEs, set-ops, ORDER BY, SELECT INTO, FOR JSON/XML) * has an identical AST shape across dialects and is handled directly by * SQLParser — no adapter needed. * * Internal to @memberjunction/sql-parser. The adapters themselves are NOT * exported; consumers see only the dialect-neutral {@link RowCapInfo} return * type and the resolver. This keeps node-sql-parser's AST shape knowledge * confined to this one file. */ import type { SQLParserDialect } from '@memberjunction/sql-dialect'; /** * Dialect-neutral description of a row cap found on a SELECT statement. * * There is deliberately no TOP/LIMIT naming — consumers don't need to know * which syntax form produced the cap. The explicit `form` discriminant keeps * narrowing robust: a future variant cannot silently break an `in`-based guard. */ export type RowCapInfo = /** Numeric cap — comparable against a requested row limit. */ { form: 'numeric'; value: number; offset: number | null; } /** Percentage cap (SQL Server `TOP N PERCENT`) — a fraction, not a row count. */ | { form: 'percent'; } /** Non-numeric expression (`TOP (@var)`, `LIMIT $1`) — not statically known. */ | { form: 'opaque'; }; /** * Encapsulates one dialect's row-cap AST field shape. An instance of SQLParser * binds exactly one dialect and therefore one adapter, so a TOP-form AST is * never read/written through a LIMIT-form adapter (and vice versa). */ export interface ASTDialectAdapter { /** Read the outermost row cap from an AST root node, or null when none. */ ReadRowCap(root: Record): RowCapInfo | null; /** Write a numeric row cap onto an AST root node (preserving any OFFSET). */ WriteRowCap(root: Record, cap: number): void; /** Remove the row cap from an AST root node. */ ClearRowCap(root: Record): void; } /** * Resolves the AST adapter for a dialect. Throws when none is registered — * a developer error (a dialect was added to sql-dialect without a matching * adapter here). */ export declare function getASTDialectAdapter(dialect: SQLParserDialect): ASTDialectAdapter; //# sourceMappingURL=ASTDialectAdapter.d.ts.map