import { PGlite } from '@dotdo/pglite'; export { PGlite } from '@dotdo/pglite'; import { T as Transport, R as Row, Q as QueryResult, a as TransactionOptions } from '../types-YTdPe6Qz.cjs'; import '@dotdo/postgres-shared/errors'; /** * PGLite Transport for postgres.do * * Provides a local PostgreSQL implementation using PGLite WASM * that can be used as a transport layer for the postgres.do client. * * @example * ```typescript * import { postgres } from 'postgres.do' * import { createPGLiteTransport, PGLite } from 'postgres.do/pglite' * * // Create a PGLite instance (in-memory) * const pglite = new PGLite() * await pglite.waitReady * * // Create a postgres.do client with PGLite transport * const sql = postgres({ transport: createPGLiteTransport(pglite) }) * * // Use like normal postgres.do client * const users = await sql`SELECT * FROM users` * ``` */ /** * PGLite transport configuration */ interface PGLiteTransportConfig { /** * The PGLite instance to use for queries */ pglite: PGlite; /** * Whether to automatically initialize the PGLite instance * Default: true */ autoInit?: boolean; } /** * PGLite Transport implementation * * Provides a Transport interface compatible with the postgres.do client * that uses PGLite WASM for local PostgreSQL execution. */ declare class PGLiteTransport implements Transport { private pglite; private autoInit; private initialized; constructor(config: PGLiteTransportConfig); /** * Ensure PGLite is ready before executing queries */ private ensureReady; /** * Execute a SQL query with optional parameters */ query(sql: string, params?: unknown[]): Promise>; /** * Execute multiple queries in a transaction */ transaction(queries: Array<{ sql: string; params?: unknown[]; }>, options?: TransactionOptions): Promise; /** * Close the PGLite connection */ close(): Promise; /** * Check if the transport is connected (PGLite is always connected when initialized) */ isConnected(): boolean; /** * Get the underlying PGLite instance */ getPGLite(): PGlite; /** * Extract the SQL command type from a query string */ private extractCommand; } /** * Create a PGLite transport from a PGLite instance * * @param pglite - The PGLite instance to use * @param options - Optional configuration * @returns A Transport implementation using PGLite * * @example * ```typescript * import { PGlite } from '@dotdo/pglite' * import { createPGLiteTransport } from 'postgres.do/pglite' * * const pglite = new PGlite() * const transport = createPGLiteTransport(pglite) * ``` */ declare function createPGLiteTransport(pglite: PGlite, options?: Omit): PGLiteTransport; /** * Create a postgres.do-compatible SQL function backed by PGLite * * This provides a convenient way to use PGLite with the postgres.do API * * @param pgliteOrOptions - PGLite instance or PGLite options * @returns A postgres.do SQL tagged template function * * @example * ```typescript * import { createPGLiteSql } from 'postgres.do/pglite' * * // With existing PGLite instance * const pglite = new PGlite() * const sql = await createPGLiteSql(pglite) * * // Execute queries using postgres.do API * const users = await sql`SELECT * FROM users WHERE id = ${userId}` * ``` */ declare function createPGLiteSql(pglite: PGlite): Promise; /** * PGLite-backed SQL interface */ interface PGLiteSql { /** * Execute a SQL query using tagged template literal */ (strings: TemplateStringsArray, ...values: unknown[]): Promise; /** * Execute raw SQL */ unsafe(query: string, params?: unknown[]): Promise; /** * Begin a transaction */ begin(fn: (sql: PGLiteTransactionSql) => Promise, options?: TransactionOptions): Promise; /** * Create a savepoint (only valid in transactions) */ savepoint(fn: (sql: PGLiteTransactionSql) => Promise): Promise; /** * End the connection */ end(): Promise; /** * Reserve a connection */ reserve(): Promise; /** * Options for Drizzle compatibility */ options: { parsers: Record unknown>; serializers: Record string>; }; /** * The underlying transport */ transport: PGLiteTransport; /** * The underlying PGLite instance */ pglite: PGlite; } /** * Transaction-scoped SQL interface */ interface PGLiteTransactionSql { /** * Execute a SQL query using tagged template literal */ (strings: TemplateStringsArray, ...values: unknown[]): Promise; /** * Execute raw SQL */ unsafe(query: string, params?: unknown[]): Promise; /** * Create a savepoint within the transaction */ savepoint(fn: (sql: PGLiteTransactionSql) => Promise): Promise; /** * Options for Drizzle compatibility */ options: { parsers: Record unknown>; serializers: Record string>; }; } /** * Reserved connection SQL interface */ interface PGLiteReservedSql extends PGLiteSql { /** * Release the reserved connection */ release(): Promise; } export { type PGLiteReservedSql, type PGLiteSql, type PGLiteTransactionSql, PGLiteTransport, type PGLiteTransportConfig, createPGLiteSql, createPGLiteTransport };