/** * Wrapper around `pgsql-parser` that handles the reality that RLS predicates * appearing in `pg_get_expr(polqual, polrelid)` are fragments, not statements. * * We wrap the fragment in a `SELECT … WHERE ` so the parser accepts it, * then pull the `whereClause` out of the resulting AST. */ /** Opaque AST node — intentionally `unknown` to keep us loose against pgsql-parser upgrades. */ export type PgAstNode = unknown; export interface PolicyExpression { /** Original text (exactly as returned by pg_get_expr). */ text: string; /** Root AST node of the expression (not the wrapping SELECT). */ ast: PgAstNode; } export declare class PolicyParseError extends Error { readonly expr: string; readonly cause: unknown; constructor(expr: string, cause: unknown); } /** * Parse a policy expression fragment. * * `parse` from pgsql-parser v17 is async (it awaits a WASM load), so this * wrapper is async too. * * @param expr The text from `pg_get_expr(...)`. * @returns Parsed AST, or `null` if `expr` is null/empty. * @throws `PolicyParseError` on parse failure. */ export declare function parsePolicyExpression(expr: string | null): Promise;