/** * Round-trip validation for the schema transform. * * After the transform deparses its mutated AST to SQL text, the emitted text * must parse back to an AST that is structurally identical to the AST we * deparsed (AST1 === AST2 after normalization). Any mismatch means the * deparser dropped or mangled something (e.g. array bounds on a DECLAREd * type), even though the output may still be syntactically valid SQL. * * Two comparisons are performed per file: * - the SQL-level parse tree (with volatile fields and function body strings * normalized — PL/pgSQL bodies are compared separately) * - each PL/pgSQL function body, compared in dehydrated form so both sides * go through the same hydrate -> dehydrate rendering */ import { firstDifference } from './round-trip-core'; export { firstDifference }; /** * Fortified, mutation-aware normalizer built on the shared round-trip core. * Beyond the upstream `cleanTree` (position stripping + body trimming), it * additionally sorts keys, drops lazily-created recfield datums, and replaces * DefElem "as" bodies with a sentinel (PL/pgSQL body fidelity is checked * separately via the dehydrated PL/pgSQL ASTs). */ export declare function normalizeParseTree(node: any): any; export interface CapturedAsts { sqlAst: any; plpgsqlAsts: any[]; } /** * Capture the normalized SQL parse tree and dehydrated PL/pgSQL function * ASTs from a transform context (as produced by plpgsql-parser's * transformSync callback). Call this AFTER mutating the context. */ export declare function captureTransformAsts(ctx: any): CapturedAsts; /** * Parse already-transformed SQL text and capture its ASTs the same way * capture_transform_asts does for the pre-deparse context, so the two * sides are directly comparable. */ export declare function captureAstsFromSql(sql: string): CapturedAsts; /** * Assert that the transformed AST (captured before deparse) matches the AST * obtained by re-parsing the emitted SQL. Throws with the first differing * path on mismatch. */ export declare function validateRoundTrip(before: CapturedAsts, transformedSql: string): void;