/** * Detect Postgres connection strings that libpq refuses to parse. * * libpq splits a URI query parameter on the FIRST `=` and rejects any further * one in the same parameter: * * extra key/value separator "=" in URI query parameter: "options" * * That makes a URL like * * postgresql://u:p@h:5432/db?options=-c%20search_path=public&sslmode=disable * * unusable by every libpq caller — `pg_dump`/`pg_restore` behind * `rebase db backup|restore`, and a plain `psql "$DATABASE_URL"`. It is not a * version quirk: Postgres 15 through 18 all refuse it. * * `rebase init` generated exactly that string until 2026-08-18, and the failure * is invisible day to day because node-postgres parses URLs itself and accepts * it — so `rebase dev` and `rebase db push` work while backups do not. Fixing * the generator does nothing for projects that already exist, which is what * these functions are for: `rebase doctor` reads them off disk and reports. */ /** A query parameter whose value carries a literal `=`. */ export interface UnparseableParam { /** The parameter name, e.g. "options". */ name: string; /** The raw `name=value` text as it appears in the URL. */ raw: string; } /** * Return the query parameters libpq would reject, or an empty array. * * Deliberately not built on `new URL()`: that parser is happy to accept the * broken form (it splits on the first `=` and keeps the rest as the value), * so it cannot see the defect at all. The rule being checked is libpq's, and * it is about the raw text. */ export declare function findUnparseableParams(connectionString: string): UnparseableParam[]; /** * Percent-encode the offending `=` characters, leaving everything else byte for * byte as it was. * * Only the second and later `=` in a parameter are rewritten — the first is the * real separator. Nothing else is touched: re-serialising through `URL` would * also reorder parameters and turn spaces into `+`, which libpq does not decode, * so a "tidy up" would trade one unparseable string for another. */ export declare function encodeExtraEquals(connectionString: string): string; /** One connection string, found somewhere on disk, that libpq cannot parse. */ export interface LibpqUrlFinding { /** File it came from, relative to the project root. */ file: string; /** The variable holding it, e.g. "DATABASE_URL". */ variable: string; /** Parameter names libpq objects to. */ params: string[]; /** The same string with the offending `=` encoded. */ suggested: string; } /** * Scan one file's text for connection strings libpq would reject. * * Handles both shapes a scaffolded project uses, because both shipped with the * defect and a deployed stack is broken by the compose one alone: * * .env DATABASE_URL=postgresql://… * docker-compose.yml DATABASE_URL: postgresql://… */ export declare function scanTextForLibpqUrls(file: string, text: string): LibpqUrlFinding[];