/** * Helpers for reading the facts rules care about out of the sql-parser-cst CST. * * All CST-shape knowledge lives here so that rules never touch raw node * internals and a parser upgrade only needs changes in one place. Nodes are * typed loosely (`any`) because the full CST union is large; the helpers below * are the typed, tested boundary around it. */ import type { ParsedStatement } from '../types'; type AnyNode = any; /** Resolve an identifier / quoted identifier / schema-qualified name to a string. */ export declare function identifierName(node: AnyNode): string | undefined; /** Statements that parsed successfully, narrowed to those with a CST node. */ export declare function parsedStatements(statements: ParsedStatement[]): Generator; }>; export interface AlterAction { statement: ParsedStatement; /** The table being altered. */ table: string | undefined; /** A single `alter_action_*` CST node. */ action: AnyNode; } /** Yield every action of every `ALTER TABLE` statement, flattened. */ export declare function alterActions(statements: ParsedStatement[]): Generator; export interface ColumnInfo { name: string | undefined; notNull: boolean; hasDefault: boolean; generated: boolean; primaryKey: boolean; } /** Read a `column_definition` node (from CREATE TABLE or ADD COLUMN). */ export declare function columnInfo(column: AnyNode): ColumnInfo; /** True if an `alter_action_alter_column` changes the column's data type. */ export declare function isSetDataType(action: AnyNode): boolean; /** True if a `SET DATA TYPE` action carries a `USING` conversion clause. */ export declare function hasUsingClause(action: AnyNode): boolean; /** True if an `alter_action_alter_column` is `SET NOT NULL`. */ export declare function isSetNotNull(action: AnyNode): boolean; export interface ConstraintInfo { /** `foreign_key`, `unique`, `check`, `primary_key`, or the raw type. */ kind: string; name: string | undefined; /** Columns the constraint covers (empty for CHECK). */ columns: string[]; /** Whether the constraint was added with `NOT VALID`. */ notValid: boolean; } /** Read an `alter_action_add_constraint` action, or null if it isn't one. */ export declare function addedConstraint(action: AnyNode): ConstraintInfo | null; /** Column names listed in a constraint's `(…)` column list. */ export declare function constraintColumns(constraint: AnyNode): string[]; /** * Names of tables created within this migration. Operations on a table created * in the same migration act on a brand-new (empty) table, so locking/validation * concerns don't apply — this lets rules skip them and avoid false alarms on the * very common "create table, then its indexes and foreign keys" pattern. */ export declare function createdTables(statements: ParsedStatement[]): Set; /** Column definitions of a `CREATE TABLE` statement. */ export declare function tableColumns(node: AnyNode): AnyNode[]; /** True if a column definition carries an explicit `NULL` (not `NOT NULL`). */ export declare function hasExplicitNull(column: AnyNode): boolean; /** Names of the columns dropped by a `DROP TABLE` (its target tables). */ export declare function droppedTables(node: AnyNode): string[]; export interface CreateIndexInfo { unique: boolean; concurrently: boolean; table: string | undefined; } export declare function createIndexInfo(node: AnyNode): CreateIndexInfo; export {}; //# sourceMappingURL=ast.d.ts.map