import { type SqliteRemoteDatabase } from 'drizzle-orm/sqlite-proxy'; import type { Database } from 'bun:sqlite'; import type { AnyRelations, EmptyRelations } from 'drizzle-orm'; import type { SQLiteTable } from 'drizzle-orm/sqlite-core'; export type SqlStatementMetadata = { table: string; publicTable: string; kind: 'delete' | 'insert' | 'update' | 'upsert'; }; export type SQLiteQueryFormat = { relationships: Record; singular: boolean; }; export type SQLiteExecResult = { changes: number; }; export type SQLiteStatement = { sql: string; params?: readonly unknown[]; metadata?: SqlStatementMetadata; }; export type SQLiteTransactionExecutor = { exec(sql: string, params?: readonly unknown[], metadata?: SqlStatementMetadata): SQLiteExecResult | Promise; /** * every statement in one call to the storage owner, in order, as one * atomic step. a remote owner holds its writer across each round trip, so a * list sent one statement at a time holds it for the whole exchange. */ execMany(statements: readonly SQLiteStatement[]): SQLiteExecResult[] | Promise; query = Record>(sql: string, params?: readonly unknown[]): Row[] | Promise; queryAst(ast: unknown, format: SQLiteQueryFormat, queryName?: string): Result | Promise; }; export type SQLiteTransactionProvider = (work: (executor: SQLiteTransactionExecutor) => Value | Promise) => Promise; export type SQLiteSchema = Record; export type CreateSQLiteDatabaseOptions = { schema: TSchema; relations?: TRelations; transactionProvider: SQLiteTransactionProvider; }; export type SQLiteDatabaseTransaction = { executor: SQLiteTransactionExecutor; drizzle: SqliteRemoteDatabase; }; export type SQLiteDatabase = { transaction(work: (transaction: SQLiteDatabaseTransaction) => Value | Promise): Promise; }; /** * Creates Drizzle only after the storage owner has started its transaction. * The sqlite-proxy driver is used solely to turn its query callbacks into * typed Drizzle operations; it never owns BEGIN or COMMIT. */ export declare function createSQLiteDatabase(options: CreateSQLiteDatabaseOptions): SQLiteDatabase; export declare function createSQLiteDrizzle(executor: SQLiteTransactionExecutor, options: Pick, 'relations' | 'schema'>): SqliteRemoteDatabase; export type CreateBunSQLiteExecutorOptions = { database: Database; queryAst(ast: unknown, format: SQLiteQueryFormat, queryName?: string): Result | Promise; safeIntegers?: boolean; }; export declare function createBunSQLiteExecutor({ database, queryAst, safeIntegers, }: CreateBunSQLiteExecutorOptions): SQLiteTransactionExecutor; export type CreateBunSQLiteTransactionProviderOptions = CreateBunSQLiteExecutorOptions; /** * Bun's synchronous driver needs its own native transaction boundary. Remote * and Durable Object hosts pass their protected callback directly to * createSQLiteDatabase instead. */ export declare function createBunSQLiteTransactionProvider({ database, queryAst, safeIntegers, }: CreateBunSQLiteTransactionProviderOptions): SQLiteTransactionProvider; //# sourceMappingURL=sqlite.d.ts.map