import { on as MigrationAdapter } from "./index-DcuMZ9kb.mjs"; import { Dialect } from "kysely"; //#region src/adapters/sqlite/adapter.d.ts /** * better-sqlite3-shaped database handle that `sqliteAdapter` consumes. * Mirrors the methods we actually use; both `new Database(...)` from * `better-sqlite3` and bun's `bun:sqlite` Database match structurally. * * better-sqlite3's API is synchronous — we wrap everything in `async` * to match the `MigrationAdapter` contract. No I/O actually awaits; * the wrapping is for shape compatibility. */ /** * `all` / `get` are deliberately NOT method-generic: better-sqlite3 * v12's own `Statement` methods are non-generic, so generic signatures * here would make a real `Database` instance structurally incompatible * (callers had to cast — same fix as `SqliteIntrospectDb`). Row typing * happens at the call sites via assertions instead. */ interface SqliteStatement { run(...params: readonly unknown[]): { changes: number; lastInsertRowid: number | bigint; }; all(...params: readonly unknown[]): unknown[]; get(...params: readonly unknown[]): unknown; } interface SqliteDatabaseLike { prepare(sql: string): SqliteStatement; exec(sql: string): unknown; close(): unknown; } interface SqliteAdapterOptions { /** * better-sqlite3 (or compatible) Database handle. Caller-owned — * the adapter's `close()` does NOT close the database because * adopters typically share a single handle across the migration * adapter and the KickDbClient. */ database: SqliteDatabaseLike; } /** * MigrationAdapter implementation backed by better-sqlite3. * * Lock semantics: single-row UPDATE WHERE locked_at IS NULL on * `kick_migrations_lock`. Only the row created by `ensureMigrationTables()` * exists, so the UPDATE either flips `locked_at` and returns * `changes=1` (we won) or matches zero rows (someone else holds it). * * Introspection: `introspect()` walks `sqlite_master` + `PRAGMA` via * {@link introspectSqlite}. Types come back as SQLite affinities (lossy * vs the code-first DSL), so it powers `kick db introspect` rather than * byte-exact drift detection. */ declare function sqliteAdapter(opts: SqliteAdapterOptions): MigrationAdapter; //#endregion //#region src/adapters/sqlite/dialect.d.ts interface SqliteDialectOptions { /** * better-sqlite3-compatible database handle. Both `new Database(...)` * from `better-sqlite3` and bun's `bun:sqlite` `Database` match * structurally (Bun is best-effort — same `.prepare()` shape, no * version assertion). */ database: SqliteDatabaseLike; } /** * Construct the dialect that `createDbClient({ dialect })` consumes. * * @example * ```ts * import { createDbClient } from '@forinda/kickjs-db' * import { sqliteDialect, sqliteAdapter } from '@forinda/kickjs-db/sqlite' * import Database from 'better-sqlite3' * * const database = new Database(':memory:') * * export const db = createDbClient({ * schema, * dialect: sqliteDialect({ database }), * }) * * export const migrationAdapter = sqliteAdapter({ database }) * ``` */ declare function sqliteDialect(opts: SqliteDialectOptions): Dialect; //#endregion export { SqliteAdapterOptions, SqliteDatabaseLike, SqliteDialectOptions, SqliteStatement, sqliteAdapter, sqliteDialect }; //# sourceMappingURL=sqlite.d.mts.map