import type { SqlClient, SetupOptions, PgFileSystemOptions } from "../../core/types.js"; import { PgFileSystem as CorePgFileSystem } from "../../core/filesystem.js"; import type postgres from "postgres"; export { FsQuotaError } from "../../core/types.js"; export type { VersionDiffCountOptions, VersionDiffOptions, VersionDiffStreamOptions, WorkspaceUsage, WorkspaceUsageOptions, } from "../../core/types.js"; export interface PostgresClientOptions { /** * Send queries as named prepared statements. Off by default. * * postgres.js runs an unprepared parameterized query as two round-trips (a * Describe to learn the parameter types, then the execute); a prepared one * is described once per connection and then takes one round-trip. Against * a remote database this roughly halves the latency of every filesystem * call, and repeated statements also skip planning. * * Leave it off behind a transaction-mode pooler that doesn't support * prepared statements (PgBouncer before 1.21, or without * `max_prepared_statements`). A connection created with * `postgres(url, { prepare: false })` stays unprepared either way. * * Statements binding more than 32 parameters always run unprepared: those * are batch inserts whose text varies with the batch size, and postgres.js * keeps every prepared statement for the connection's lifetime. */ prepare?: boolean; } /** * Creates a SqlClient backed by a postgres.js connection. * * @example * ```ts * import postgres from "postgres"; * import { createPostgresClient } from "bash-gres/postgres"; * * const sql = postgres("postgres://localhost:5432/mydb"); * const client = createPostgresClient(sql); * // or, when no transaction-mode pooler sits in between: * const fast = createPostgresClient(sql, { prepare: true }); * ``` */ export declare function createPostgresClient = Record>(sql: postgres.Sql, options?: PostgresClientOptions): SqlClient; /** * postgres.js-native setup: accepts a postgres.js `sql` instance directly. * * @example * ```ts * import postgres from "postgres"; * import { setup } from "bash-gres/postgres"; * * const sql = postgres("postgres://localhost:5432/mydb"); * await setup(sql); * ``` */ export declare function setup = Record>(sql: postgres.Sql, options?: SetupOptions): Promise; export type PostgresPgFileSystemOptions = Record> = Omit & PostgresClientOptions & { db: postgres.Sql; }; /** * PgFileSystem that accepts a postgres.js `sql` instance directly. * * @example * ```ts * import postgres from "postgres"; * import { PgFileSystem } from "bash-gres/postgres"; * * const sql = postgres("postgres://localhost:5432/mydb"); * const fs = new PgFileSystem({ db: sql, workspaceId: "ws-1" }); * ``` * * `prepare: true` opts into prepared statements (see `PostgresClientOptions`); * forks and `versioned()` children inherit it. */ export declare class PgFileSystem extends CorePgFileSystem { constructor(options: PostgresPgFileSystemOptions); } //# sourceMappingURL=index.d.ts.map