import { SchemaDefinition } from '@korajs/core'; import { S as StorageAdapter, T as Transaction, a as TransactionOptions, M as MigrationPlan } from '../types-BVVjCckP.js'; import '@korajs/core/lite'; /** * Storage adapter backed by better-sqlite3 for Node.js environments. * Used for testing and server-side usage. * * @example * ```typescript * import { BetterSqlite3Adapter } from '@korajs/store/better-sqlite3' * * const adapter = new BetterSqlite3Adapter(':memory:') * ``` */ declare class BetterSqlite3Adapter implements StorageAdapter { private readonly path; private db; private readonly statements; private statementsDb; /** * Serializes transactions. better-sqlite3 is synchronous, but our * `transaction()` is async and yields the event loop at each `await` inside * the callback. Without this mutex, a transaction started while another is * mid-flight (e.g. a relayed remote operation applied during a local write) * issues a nested `BEGIN`, which SQLite rejects, and the operation is lost. */ private readonly txMutex; /** * @param path - Database file path, or ':memory:' for in-memory database */ constructor(path?: string); open(schema: SchemaDefinition): Promise; /** Native SQLite has no journaled-commit cost to avoid: staging is opt-in (see `StorageAdapter.prefersStaging`). */ readonly prefersStaging = false; /** A scratch in-memory database for staged replication (see `StorageAdapter`). */ createStagingAdapter(): Promise; close(): Promise; /** * Non-transactional write. Takes the same mutex as {@link transaction} so it * never lands inside another caller's open transaction, where a rollback of * that transaction would silently discard it (STORE-8). Code running inside a * transaction callback must use the `tx` handle, never this method. */ execute(sql: string, params?: unknown[]): Promise; /** * Non-transactional read. Waits for any open transaction to finish so a reader * never observes another caller's uncommitted (possibly rolled-back) rows * (STORE-8). Inside a transaction callback, read through the `tx` handle. */ query(sql: string, params?: unknown[]): Promise; transaction(fn: (tx: Transaction) => Promise, options?: TransactionOptions): Promise; migrate(from: number, to: number, migration: MigrationPlan): Promise; /** * A prepared statement for `sql`, cached by its text (bounded, least recently * used evicted). Preparing dominated the write path: every local or remote write * runs the same handful of statements. SQLite re-prepares a cached statement * itself when the schema changes. */ private statement; private getDb; } export { BetterSqlite3Adapter };