/** * The one method every Postgres adapter needs. * * Injected rather than imported, so no Postgres driver becomes a dependency of this package. `pg`'s * `Pool` and `Client`, `@neondatabase/serverless`, PGlite, and anything else whose `query(text, * values)` resolves to `{ rows }` satisfy it directly. `postgres.js` uses tagged templates instead; * `fromPostgresJs(sql)` adapts it. * * Adapters only ever pass strings, numbers, and `null` as parameters, and cast them in SQL, so a * driver's own conversion of arrays, objects, and dates never changes what is stored. */ export interface PostgresLikeClient { /** Runs a parameterized statement. */ query(text: string, values?: unknown[]): Promise<{ rows: unknown[]; rowCount?: number | null; }>; } /** The part of a `postgres.js` instance the adapter needs. */ export interface PostgresJsLike { /** Runs raw SQL with parameters. */ unsafe(text: string, values?: never[]): PromiseLike & { count?: number; }>; } /** Adapts a `postgres.js` instance to the client contract. */ export declare function fromPostgresJs(sql: PostgresJsLike): PostgresLikeClient; /** A table name, optionally schema-qualified, quoted for SQL. Anything else is refused. */ export declare function quoteTable(name: string): string; /** An index or constraint name derived from a table, quoted. */ export declare function quoteDerived(table: string, suffix: string): string; /** * A jsonb value selected as `::text`. * * Adapters always select jsonb as text and parse it here. Drivers disagree about jsonb — some parse * it, some return text — and a parsed JSON string is indistinguishable from unparsed text, so * reading text everywhere is the only way to get the same value from every driver. */ export declare function fromJson(value: unknown): T; /** Runs migration statements one at a time, which every driver accepts. */ export declare function runStatements(client: PostgresLikeClient, statements: readonly string[]): Promise; /** Whether an error is Postgres refusing a duplicate key. */ export declare function isUniqueViolation(error: unknown): boolean;