import { MigrationConfig } from 'drizzle-orm/migrator'; import { entityKind } from 'drizzle-orm/entity'; import { Logger } from 'drizzle-orm/logger'; import { PgDatabase } from 'drizzle-orm/pg-core/db'; import { Assume, DrizzleConfig } from 'drizzle-orm/utils'; import { R as Row, j as TransactionSql, S as Sql } from './types-YTdPe6Qz.js'; import { PgDialect } from 'drizzle-orm/pg-core/dialect'; import { PgTransaction } from 'drizzle-orm/pg-core'; import { SelectedFieldsOrdered } from 'drizzle-orm/pg-core/query-builders/select.types'; import { PgQueryResultHKT, PgSession, PreparedQueryConfig, PgPreparedQuery, PgTransactionConfig } from 'drizzle-orm/pg-core/session'; import { TablesRelationalConfig, RelationalSchemaConfig } from 'drizzle-orm/relations'; import { Query } from 'drizzle-orm/sql/sql'; /** * Drizzle ORM Session for postgres.do * * This module provides the session layer that connects Drizzle ORM * to the postgres.do client. It implements the PgSession interface * required by Drizzle's PostgreSQL dialect. */ /** * PostgresDO-compatible client interface * * This interface represents the client that Drizzle will use to execute queries. * It's compatible with both the main Sql client and transaction clients. */ interface PostgresDoClient { /** * Execute raw SQL query with parameters */ unsafe(query: string, params?: unknown[]): Promise; /** * Begin a transaction (only on main client) */ begin?(fn: (sql: TransactionSql) => Promise, options?: { isolationLevel?: string; readOnly?: boolean; deferrable?: boolean; }): Promise; /** * Create a savepoint within a transaction (only on transaction client) */ savepoint?(fn: (sql: TransactionSql) => Promise): Promise; /** * Client options (for type parser configuration) */ options?: { parsers?: Record unknown>; serializers?: Record string>; }; } /** * Prepared query implementation for postgres.do * * This class handles the execution of prepared queries through * the postgres.do client's unsafe() method. */ declare class PostgresDoPreparedQuery extends PgPreparedQuery { private client; private queryString; private params; private logger; private fields; private _isResponseInArrayMode; private customResultMapper?; static readonly [entityKind]: string; constructor(client: PostgresDoClient, queryString: string, params: unknown[], logger: Logger, fields: SelectedFieldsOrdered | undefined, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: unknown[][]) => T["execute"]) | undefined); /** * Execute the prepared query with placeholder values */ execute(placeholderValues?: Record): Promise; /** * Get all rows as objects */ all(placeholderValues?: Record): Promise; /** @internal */ isResponseInArrayMode(): boolean; } /** * Session options for postgres.do */ interface PostgresDoSessionOptions { logger?: Logger; } /** * Drizzle ORM Session for postgres.do * * This class implements the PgSession interface and provides * the bridge between Drizzle's query builders and the postgres.do client. */ declare class PostgresDoSession, TSchema extends TablesRelationalConfig> extends PgSession { private schema; options: PostgresDoSessionOptions; static readonly [entityKind]: string; logger: Logger; client: PostgresDoClient; constructor(client: PostgresDoClient, dialect: PgDialect, schema: RelationalSchemaConfig | undefined, options?: PostgresDoSessionOptions); /** * Prepare a query for execution */ prepareQuery(query: Query, fields: SelectedFieldsOrdered | undefined, _name: string | undefined, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => T['execute']): PgPreparedQuery; /** * Execute a raw query and return values */ query(query: string, params: unknown[]): Promise; /** * Execute a raw query and return objects */ queryObjects(query: string, params: unknown[]): Promise; /** * Execute a transaction */ transaction(transaction: (tx: PostgresDoTransaction) => Promise, config?: PgTransactionConfig): Promise; } /** * Transaction implementation for postgres.do * * This class provides nested transaction support through savepoints. */ declare class PostgresDoTransaction, TSchema extends TablesRelationalConfig> extends PgTransaction { /** @internal */ readonly session: PostgresDoSession; static readonly [entityKind]: string; constructor(dialect: PgDialect, /** @internal */ session: PostgresDoSession, schema: RelationalSchemaConfig | undefined, nestedIndex?: number); /** * Create a nested transaction using savepoints */ transaction(transaction: (tx: PostgresDoTransaction) => Promise): Promise; } /** * Query result HKT for postgres.do * * This type defines the shape of query results returned by the adapter. */ interface PostgresDoQueryResultHKT extends PgQueryResultHKT { readonly $brand: 'PgQueryResultHKT'; readonly row: unknown; type: Assume[]; } /** * Drizzle ORM Driver for postgres.do * * This module provides the main entry point for using Drizzle ORM * with postgres.do. It creates a Drizzle database instance that * uses the postgres.do client for query execution. * * @example * ```typescript * import { drizzle } from 'postgres.do/drizzle' * import postgres from 'postgres.do' * import * as schema from './schema' * * const sql = postgres('postgres://db.postgres.do/mydb') * const db = drizzle(sql, { schema }) * * // Full type safety! * const users = await db.select().from(schema.users) * ``` */ /** * Driver options for postgres.do */ interface PostgresDoDriverOptions { logger?: Logger; } /** * Drizzle Database class for postgres.do * * This class extends PgDatabase with postgres.do-specific functionality. */ declare class PostgresDoDatabase = Record> extends PgDatabase { static readonly [entityKind]: string; } /** * Create a Drizzle ORM instance for postgres.do * * This function creates a Drizzle database instance that uses the * postgres.do client for query execution. It supports all Drizzle * features including schemas, relations, and type-safe queries. * * @param client - The postgres.do SQL client * @param config - Optional Drizzle configuration * @returns A Drizzle database instance * * @example Basic usage * ```typescript * import { drizzle } from 'postgres.do/drizzle' * import postgres from 'postgres.do' * * const sql = postgres('postgres://db.postgres.do/mydb') * const db = drizzle(sql) * * const users = await db.select().from(users) * ``` * * @example With schema for type safety * ```typescript * import { drizzle } from 'postgres.do/drizzle' * import postgres from 'postgres.do' * import * as schema from './schema' * * const sql = postgres('postgres://db.postgres.do/mydb') * const db = drizzle(sql, { schema }) * * // Full type inference * const result = await db.query.users.findMany({ * with: { posts: true } * }) * ``` * * @example With logging * ```typescript * import { drizzle } from 'postgres.do/drizzle' * import postgres from 'postgres.do' * * const sql = postgres('postgres://db.postgres.do/mydb') * const db = drizzle(sql, { logger: true }) * ``` */ declare function drizzle = Record, TClient extends Sql = Sql>(client: TClient, config?: DrizzleConfig): PostgresDoDatabase & { $client: TClient; }; declare function drizzle = Record, TClient extends Sql = Sql>(config: DrizzleConfig & { client: TClient; }): PostgresDoDatabase & { $client: TClient; }; declare namespace drizzle { var mock: = Record>(config?: DrizzleConfig) => PostgresDoDatabase & { $client: "$client is not available on drizzle.mock()"; }; } /** * Drizzle ORM Migrator for postgres.do * * This module provides migration support for Drizzle ORM with postgres.do. * It uses Drizzle's built-in migration system to apply schema changes. * * @example * ```typescript * import { drizzle } from 'postgres.do/drizzle' * import { migrate } from 'postgres.do/drizzle/migrator' * import postgres from 'postgres.do' * * const sql = postgres('postgres://db.postgres.do/mydb') * const db = drizzle(sql) * * // Run migrations * await migrate(db, { migrationsFolder: './drizzle' }) * ``` */ /** * Run database migrations * * This function applies all pending migrations to the database. * It reads migration files from the specified folder and executes * them in order. * * @param db - The Drizzle database instance * @param config - Migration configuration * * @example * ```typescript * import { migrate } from 'postgres.do/drizzle/migrator' * * await migrate(db, { * migrationsFolder: './drizzle', * migrationsTable: '__drizzle_migrations', // optional * }) * ``` */ declare function migrate>(db: PostgresDoDatabase, config: MigrationConfig): Promise; export { PostgresDoDatabase as P, type PostgresDoDriverOptions as a, PostgresDoSession as b, PostgresDoPreparedQuery as c, drizzle as d, PostgresDoTransaction as e, type PostgresDoClient as f, type PostgresDoSessionOptions as g, type PostgresDoQueryResultHKT as h, migrate as m };