@nextlyhq/adapter-sqlite 0.0.2-alpha.67 → 0.0.2-alpha.69

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,49 +1,11 @@
1
- import { DrizzleAdapter } from '@nextlyhq/adapter-drizzle';
2
- import { SqliteAdapterConfig, PoolStats, SqlParam, TransactionContext, TransactionOptions, DatabaseCapabilities, InsertOptions, DatabaseError } from '@nextlyhq/adapter-drizzle/types';
3
- export { AdapterLogger, BaseAdapterConfig, DatabaseCapabilities, DatabaseError, DatabaseErrorKind, DeleteOptions, InsertOptions, JoinSpec, OrderBySpec, PoolStats, SelectOptions, SqlParam, SqliteAdapterConfig, TransactionContext, TransactionOptions, UpdateOptions, UpsertOptions, WhereClause, WhereCondition, WhereOperator } from '@nextlyhq/adapter-drizzle/types';
4
- import { AnyRelations } from 'drizzle-orm';
5
- import { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3';
6
-
7
- /**
8
- * @nextlyhq/adapter-sqlite
9
- *
10
- * SQLite database adapter for Nextly.
11
- * Extends DrizzleAdapter from @nextlyhq/adapter-drizzle to provide SQLite-specific functionality.
12
- *
13
- * @remarks
14
- * This adapter uses the better-sqlite3 package for database connectivity and provides:
15
- * - Synchronous API wrapped for async interface compatibility
16
- * - Transactions the adapter runs itself (BEGIN IMMEDIATE / COMMIT / ROLLBACK), with nested calls run as savepoints
17
- * - CRUD operations with RETURNING clause support (SQLite 3.35+)
18
- * - WAL mode for better concurrent read performance
19
- * - In-memory and file-based database support
20
- *
21
- * @example
22
- * ```typescript
23
- * import { createSqliteAdapter } from '@nextlyhq/adapter-sqlite';
24
- *
25
- * const adapter = createSqliteAdapter({
26
- * url: 'file:./data/app.db',
27
- * });
28
- *
29
- * await adapter.connect();
30
- *
31
- * // Query data
32
- * const users = await adapter.select('users', {
33
- * where: { and: [{ column: 'status', op: '=', value: 'active' }] },
34
- * limit: 10,
35
- * });
36
- *
37
- * await adapter.disconnect();
38
- * ```
39
- *
40
- * @packageDocumentation
41
- */
42
-
1
+ import { DrizzleAdapter } from "@nextlyhq/adapter-drizzle";
2
+ import { AdapterLogger, BaseAdapterConfig, DatabaseCapabilities, DatabaseError, DatabaseErrorKind, DeleteOptions, InsertOptions, JoinSpec, OrderBySpec, PoolStats, SelectOptions, SqlParam, SqliteAdapterConfig, TransactionContext, TransactionOptions, UpdateOptions, UpsertOptions, WhereClause, WhereCondition, WhereOperator } from "@nextlyhq/adapter-drizzle/types";
3
+ import { AnyRelations } from "drizzle-orm";
4
+ import { BetterSQLite3Database } from "drizzle-orm/better-sqlite3";
43
5
  /**
44
6
  * Package version
45
7
  */
46
- declare const VERSION = "0.1.0";
8
+ export declare const VERSION = "0.1.0";
47
9
  /**
48
10
  * SQLite database adapter for Nextly.
49
11
  *
@@ -69,272 +31,274 @@ declare const VERSION = "0.1.0";
69
31
  * await adapter.connect();
70
32
  * ```
71
33
  */
72
- declare class SqliteAdapter extends DrizzleAdapter {
73
- private drizzleByRelations;
74
- private drizzleBare;
75
- /**
76
- * The database dialect - always 'sqlite' for this adapter.
77
- */
78
- readonly dialect: "sqlite";
79
- /**
80
- * Adapter configuration.
81
- */
82
- protected readonly config: SqliteAdapterConfig;
83
- /**
84
- * better-sqlite3 Database instance.
85
- */
86
- private db;
87
- /**
88
- * Connection state flag.
89
- */
90
- private connected;
91
- /**
92
- * Serialization queue for concurrent `transaction()` calls.
93
- *
94
- * better-sqlite3 is synchronous, single-connection, and rejects nested
95
- * `BEGIN` with "cannot start a transaction within a transaction".
96
- * When two `await adapter.transaction(...)` calls overlap (e.g. a bulk
97
- * mutation calling `Promise.allSettled` with N per-row updates), the
98
- * second one tries to BEGIN while the first is still open and the
99
- * driver throws.
100
- *
101
- * Postgres/MySQL avoid this by allocating a fresh client/connection
102
- * per transaction from a pool — there is no equivalent for
103
- * better-sqlite3, so we serialize at the JS layer instead. Every
104
- * `transaction()` invocation chains onto this promise; only one
105
- * BEGIN→COMMIT/ROLLBACK section runs at any moment, preserving
106
- * write-isolation semantics that callers expect from a transactional
107
- * adapter.
108
- *
109
- * Performance impact is the natural floor: SQLite already serializes
110
- * writers at the file-lock level, so the queue removes failed-call
111
- * surface area without changing the achievable concurrency.
112
- */
113
- private transactionQueue;
114
- /**
115
- * The transaction the current async chain is running inside, if any.
116
- *
117
- * A `transaction()` call made from INSIDE a transaction's work — a store
118
- * writing on behalf of the caller, a plugin's write inside its own
119
- * `ctx.db.transaction` — used to queue behind the very transaction that
120
- * was waiting for it, and neither ever settled: that hung every later
121
- * transaction on the instance too. Such a call now runs as a SAVEPOINT of
122
- * the active transaction instead, so it commits or rolls back with it and
123
- * its own failure undoes only its own part.
124
- */
125
- private readonly transactionScope;
126
- /**
127
- * Creates a new SQLite adapter instance.
128
- *
129
- * @param config - Adapter configuration
130
- */
131
- constructor(config: SqliteAdapterConfig);
132
- /**
133
- * Connect to the SQLite database.
134
- *
135
- * @remarks
136
- * This method initializes the database connection. For SQLite, this
137
- * opens the database file or creates an in-memory database.
138
- * Also configures WAL mode and foreign keys based on config.
139
- *
140
- * @throws {DatabaseError} If connection fails
141
- */
142
- connect(): Promise<void>;
143
- /**
144
- * Disconnect from the SQLite database.
145
- *
146
- * @remarks
147
- * This method closes the database connection and releases resources.
148
- */
149
- disconnect(): Promise<void>;
150
- /**
151
- * Check if connected to the database.
152
- */
153
- isConnected(): boolean;
154
- /**
155
- * Get connection pool statistics.
156
- *
157
- * @remarks
158
- * SQLite doesn't use connection pooling, so this returns null.
159
- * The database is single-file with a single connection.
160
- */
161
- getPoolStats(): PoolStats | null;
162
- /**
163
- * Execute a raw SQL query.
164
- *
165
- * @param sql - SQL query string with $1, $2 placeholders (converted to ? for SQLite)
166
- * @param params - Query parameters
167
- * @returns Query results
168
- *
169
- * @throws {DatabaseError} If query execution fails
170
- */
171
- executeQuery<T = unknown>(sql: string, params?: SqlParam[]): Promise<T[]>;
172
- /**
173
- * Execute work within a transaction.
174
- *
175
- * @param work - Function containing transactional operations
176
- * @param options - Transaction options (isolation level not fully supported in SQLite)
177
- * @returns Result of the work function
178
- *
179
- * @remarks
180
- * The adapter manages the transaction itself, because better-sqlite3's
181
- * `db.transaction()` does not take async work: it runs `BEGIN IMMEDIATE`,
182
- * then `COMMIT` when `work` resolves or `ROLLBACK` when it throws.
183
- * - Top-level calls run one at a time.
184
- * - A call made inside an open transaction's work joins it as a savepoint
185
- * (`SAVEPOINT` / `RELEASE` / `ROLLBACK TO`).
186
- * - Nested calls of one scope run one at a time.
187
- * - A call made later from a savepoint that has already released joins the
188
- * innermost scope still open.
189
- * - Nested work started and not awaited finishes before the enclosing scope
190
- * commits or rolls back.
191
- *
192
- * Note: SQLite uses DEFERRED, IMMEDIATE, or EXCLUSIVE transaction modes
193
- * rather than isolation levels. This adapter uses IMMEDIATE.
194
- */
195
- transaction<T>(work: (tx: TransactionContext) => Promise<T>, _options?: TransactionOptions): Promise<T>;
196
- /**
197
- * Hold `effect` until the transaction enclosing this async context commits,
198
- * or run it now when none does.
199
- *
200
- * The effect belongs to the scope this async context runs in, even one
201
- * that has already released or rolled back: a service whose own
202
- * transaction nested as a savepoint registers from its caller's scope once
203
- * that savepoint has released, and the change is undoable for as long as
204
- * any scope around it is. The outermost transaction runs the effect once
205
- * its COMMIT succeeds, unless a scope between the effect's scope and the
206
- * outermost transaction rolled back, and drops every effect on ROLLBACK or
207
- * a failed COMMIT. A context whose outermost transaction has already
208
- * finished is outside any transaction, so its effect runs now, unless what
209
- * it announces was undone and it has run no transaction since.
210
- */
211
- afterCommit(effect: () => unknown, onDeferredFailure?: (error: unknown) => void): Promise<void>;
212
- /**
213
- * `effect`, bound to the async context it is registered from.
214
- *
215
- * A held effect runs after the outermost COMMIT, from the code that ran the
216
- * outermost transaction, so without this it sees that code's context rather
217
- * than its own: whatever its caller pinned around the write is gone. That
218
- * includes who is calling. A scope pinned for a scoped API key lost there
219
- * leaves a hook's nested call judged by the key's owner instead of the key,
220
- * and a person's frame lost there leaves the hook told of nobody.
221
- *
222
- * The adapter's own transaction scope is the one store it leaves: the
223
- * effect runs once that transaction has finished, outside it, as an effect
224
- * held to the outermost commit always has.
225
- */
226
- private inRegisteringContext;
227
- /**
228
- * Run the effects a committed transaction held, in order. A failure is
229
- * reported, never thrown: the change is durable, and reporting the
230
- * transaction as failed would invite a retry of something already done.
231
- */
232
- private runHeldEffects;
233
- /** Hand a held effect's failure to its reporter, or to the adapter's log. */
234
- private reportHeldEffectFailure;
235
- /**
236
- * Whether a `transaction()` call made here would join an open transaction
237
- * as a savepoint. On SQLite it would: the connection is the only one, so a
238
- * transaction open on it encloses whatever the async chain that opened it
239
- * starts.
240
- */
241
- inTransaction(): boolean;
242
- /**
243
- * Whether the calling async flow is inside a transaction that has not
244
- * finished, judged from the transaction this flow was started inside,
245
- * never from the connection: another request's open transaction answers
246
- * false here, where its own `transaction()` queues behind that one.
247
- *
248
- * A flow started inside a transaction, even inside a savepoint that has
249
- * since released, stays inside it until its outermost transaction has
250
- * committed or rolled back: until then whatever it writes on the one
251
- * connection lands in that transaction.
252
- */
253
- transactionOpenInFlow(): boolean;
254
- /**
255
- * The scope a `transaction()` call made here nests in, or none when it
256
- * opens a transaction of its own.
257
- *
258
- * A call made later from inside a savepoint that has since released runs
259
- * inside the innermost scope open on the connection. Queued on an enclosing
260
- * scope, or on the instance, it would wait behind the scope running there,
261
- * which may be the one awaiting it. Savepoints on one connection form a
262
- * stack, so whatever opens now is inside that innermost scope anyway; when
263
- * none is open the call queues on the instance.
264
- *
265
- * The innermost open scope need not be related to the call. When it is a
266
- * sibling savepoint that later rolls back, the call's write rolls back with
267
- * it, although the call itself already resolved. Waiting for an unrelated
268
- * scope instead could wait on the very scope that awaits the call.
269
- */
270
- private nestingScope;
271
- /**
272
- * Run `work` as a savepoint of the active transaction: released when it
273
- * resolves, rolled back to when it throws.
274
- */
275
- private runSavepoint;
276
- /**
277
- * Inner transaction body. Kept private so callers always go through
278
- * the serialized `transaction()` queue above and the BEGIN/COMMIT
279
- * pair is never invoked outside of it.
280
- */
281
- private runTransaction;
282
- /**
283
- * Get SQLite database capabilities.
284
- *
285
- * @remarks
286
- * SQLite capabilities:
287
- * - JSON support (not JSONB)
288
- * - No arrays
289
- * - No native ILIKE
290
- * - RETURNING clause (3.35+)
291
- * - Savepoints supported
292
- * - ON CONFLICT supported
293
- */
294
- getCapabilities(): DatabaseCapabilities;
295
- /**
296
- * Override insertMany for bulk insert optimization.
297
- *
298
- * @remarks
299
- * Uses a single multi-row INSERT statement for better performance.
300
- */
301
- insertMany<T = unknown>(table: string, data: Record<string, unknown>[], options?: InsertOptions): Promise<T[]>;
302
- /**
303
- * Ensures database is connected and returns it.
304
- *
305
- * @throws {DatabaseError} If not connected
306
- */
307
- private ensureDb;
308
- /**
309
- * Return the typed Drizzle instance for SQLite.
310
- * Guarded for server-only usage and requires an active connection.
311
- *
312
- * @param schema - Optional schema for relational queries (db.query.*)
313
- * @returns Drizzle ORM instance wrapping the better-sqlite3 connection
314
- * @throws {Error} If called in browser or not connected
315
- */
316
- getDrizzle<T = BetterSQLite3Database<AnyRelations>>(relations?: AnyRelations): T;
317
- /**
318
- * Convert $1, $2 placeholders to ? for better-sqlite3.
319
- *
320
- * @param sql - SQL with PostgreSQL-style placeholders
321
- * @returns SQL with ? placeholders
322
- */
323
- private convertPlaceholders;
324
- /**
325
- * Creates a TransactionContext for the given database connection.
326
- */
327
- /** A table-level `primaryKey({ columns })`, read through the SQLite table config. */
328
- protected compositePrimaryKey(tableObj: Record<string, unknown>): object[];
329
- private createTransactionContext;
330
- /**
331
- * Classifies a SQLite error into a DatabaseError.
332
- *
333
- * @param error - Original error from better-sqlite3
334
- * @param sql - SQL statement that caused the error (optional)
335
- * @returns DatabaseError with proper classification
336
- */
337
- protected classifyError(error: unknown, sql?: string): DatabaseError;
34
+ export declare class SqliteAdapter extends DrizzleAdapter {
35
+ private drizzleByRelations;
36
+ private drizzleBare;
37
+ /**
38
+ * The database dialect - always 'sqlite' for this adapter.
39
+ */
40
+ readonly dialect: "sqlite";
41
+ /**
42
+ * Adapter configuration.
43
+ */
44
+ protected readonly config: SqliteAdapterConfig;
45
+ /**
46
+ * better-sqlite3 Database instance.
47
+ */
48
+ private db;
49
+ /**
50
+ * Connection state flag.
51
+ */
52
+ private connected;
53
+ /**
54
+ * Serialization queue for concurrent `transaction()` calls.
55
+ *
56
+ * better-sqlite3 is synchronous, single-connection, and rejects nested
57
+ * `BEGIN` with "cannot start a transaction within a transaction".
58
+ * When two `await adapter.transaction(...)` calls overlap (e.g. a bulk
59
+ * mutation calling `Promise.allSettled` with N per-row updates), the
60
+ * second one tries to BEGIN while the first is still open and the
61
+ * driver throws.
62
+ *
63
+ * Postgres/MySQL avoid this by allocating a fresh client/connection
64
+ * per transaction from a pool — there is no equivalent for
65
+ * better-sqlite3, so we serialize at the JS layer instead. Every
66
+ * `transaction()` invocation chains onto this promise; only one
67
+ * BEGIN→COMMIT/ROLLBACK section runs at any moment, preserving
68
+ * write-isolation semantics that callers expect from a transactional
69
+ * adapter.
70
+ *
71
+ * Performance impact is the natural floor: SQLite already serializes
72
+ * writers at the file-lock level, so the queue removes failed-call
73
+ * surface area without changing the achievable concurrency.
74
+ */
75
+ private transactionQueue;
76
+ /**
77
+ * The transaction the current async chain is running inside, if any.
78
+ *
79
+ * A `transaction()` call made from INSIDE a transaction's work — a store
80
+ * writing on behalf of the caller, a plugin's write inside its own
81
+ * `ctx.db.transaction` — used to queue behind the very transaction that
82
+ * was waiting for it, and neither ever settled: that hung every later
83
+ * transaction on the instance too. Such a call now runs as a SAVEPOINT of
84
+ * the active transaction instead, so it commits or rolls back with it and
85
+ * its own failure undoes only its own part.
86
+ */
87
+ private readonly transactionScope;
88
+ /**
89
+ * Creates a new SQLite adapter instance.
90
+ *
91
+ * @param config - Adapter configuration
92
+ */
93
+ constructor(config: SqliteAdapterConfig);
94
+ /**
95
+ * Connect to the SQLite database.
96
+ *
97
+ * @remarks
98
+ * This method initializes the database connection. For SQLite, this
99
+ * opens the database file or creates an in-memory database.
100
+ * Also configures WAL mode and foreign keys based on config.
101
+ *
102
+ * @throws {DatabaseError} If connection fails
103
+ */
104
+ connect(): Promise<void>;
105
+ /**
106
+ * Disconnect from the SQLite database.
107
+ *
108
+ * @remarks
109
+ * This method closes the database connection and releases resources.
110
+ */
111
+ disconnect(): Promise<void>;
112
+ /**
113
+ * Check if connected to the database.
114
+ */
115
+ isConnected(): boolean;
116
+ /**
117
+ * Get connection pool statistics.
118
+ *
119
+ * @remarks
120
+ * SQLite doesn't use connection pooling, so this returns null.
121
+ * The database is single-file with a single connection.
122
+ */
123
+ getPoolStats(): PoolStats | null;
124
+ /**
125
+ * Execute a raw SQL query.
126
+ *
127
+ * @param sql - SQL query string with $1, $2 placeholders (converted to ? for SQLite)
128
+ * @param params - Query parameters
129
+ * @returns Query results
130
+ *
131
+ * @throws {DatabaseError} If query execution fails
132
+ */
133
+ executeQuery<T = unknown>(sql: string, params?: SqlParam[]): Promise<T[]>;
134
+ /**
135
+ * Execute work within a transaction.
136
+ *
137
+ * @param work - Function containing transactional operations
138
+ * @param options - Transaction options (isolation level not fully supported in SQLite)
139
+ * @returns Result of the work function
140
+ *
141
+ * @remarks
142
+ * The adapter manages the transaction itself, because better-sqlite3's
143
+ * `db.transaction()` does not take async work: it runs `BEGIN IMMEDIATE`,
144
+ * then `COMMIT` when `work` resolves or `ROLLBACK` when it throws.
145
+ * - Top-level calls run one at a time.
146
+ * - A call made inside an open transaction's work joins it as a savepoint
147
+ * (`SAVEPOINT` / `RELEASE` / `ROLLBACK TO`).
148
+ * - Nested calls of one scope run one at a time.
149
+ * - A call made later from a savepoint that has already released joins the
150
+ * innermost scope still open.
151
+ * - Nested work started and not awaited finishes before the enclosing scope
152
+ * commits or rolls back.
153
+ *
154
+ * Note: SQLite uses DEFERRED, IMMEDIATE, or EXCLUSIVE transaction modes
155
+ * rather than isolation levels. This adapter uses IMMEDIATE.
156
+ */
157
+ /** How long a transaction waits for the connection: `pool.connectionTimeoutMs`. */
158
+ private transactionWaitMs;
159
+ transaction<T>(work: (tx: TransactionContext) => Promise<T>, _options?: TransactionOptions): Promise<T>;
160
+ /**
161
+ * Hold `effect` until the transaction enclosing this async context commits,
162
+ * or run it now when none does.
163
+ *
164
+ * The effect belongs to the scope this async context runs in, even one
165
+ * that has already released or rolled back: a service whose own
166
+ * transaction nested as a savepoint registers from its caller's scope once
167
+ * that savepoint has released, and the change is undoable for as long as
168
+ * any scope around it is. The outermost transaction runs the effect once
169
+ * its COMMIT succeeds, unless a scope between the effect's scope and the
170
+ * outermost transaction rolled back, and drops every effect on ROLLBACK or
171
+ * a failed COMMIT. A context whose outermost transaction has already
172
+ * finished is outside any transaction, so its effect runs now, unless what
173
+ * it announces was undone and it has run no transaction since.
174
+ */
175
+ override afterCommit(effect: () => unknown, onDeferredFailure?: (error: unknown) => void): Promise<void>;
176
+ /**
177
+ * `effect`, bound to the async context it is registered from.
178
+ *
179
+ * A held effect runs after the outermost COMMIT, from the code that ran the
180
+ * outermost transaction, so without this it sees that code's context rather
181
+ * than its own: whatever its caller pinned around the write is gone. That
182
+ * includes who is calling. A scope pinned for a scoped API key lost there
183
+ * leaves a hook's nested call judged by the key's owner instead of the key,
184
+ * and a person's frame lost there leaves the hook told of nobody.
185
+ *
186
+ * The adapter's own transaction scope is the one store it leaves: the
187
+ * effect runs once that transaction has finished, outside it, as an effect
188
+ * held to the outermost commit always has.
189
+ */
190
+ private inRegisteringContext;
191
+ /**
192
+ * Run the effects a committed transaction held, in order. A failure is
193
+ * reported, never thrown: the change is durable, and reporting the
194
+ * transaction as failed would invite a retry of something already done.
195
+ */
196
+ private runHeldEffects;
197
+ /** Hand a held effect's failure to its reporter, or to the adapter's log. */
198
+ private reportHeldEffectFailure;
199
+ /**
200
+ * Whether a `transaction()` call made here would join an open transaction
201
+ * as a savepoint. On SQLite it would: the connection is the only one, so a
202
+ * transaction open on it encloses whatever the async chain that opened it
203
+ * starts.
204
+ */
205
+ override inTransaction(): boolean;
206
+ /**
207
+ * Whether the calling async flow is inside a transaction that has not
208
+ * finished, judged from the transaction this flow was started inside,
209
+ * never from the connection: another request's open transaction answers
210
+ * false here, where its own `transaction()` queues behind that one.
211
+ *
212
+ * A flow started inside a transaction, even inside a savepoint that has
213
+ * since released, stays inside it until its outermost transaction has
214
+ * committed or rolled back: until then whatever it writes on the one
215
+ * connection lands in that transaction.
216
+ */
217
+ override transactionOpenInFlow(): boolean;
218
+ /**
219
+ * The scope a `transaction()` call made here nests in, or none when it
220
+ * opens a transaction of its own.
221
+ *
222
+ * A call made later from inside a savepoint that has since released runs
223
+ * inside the innermost scope open on the connection. Queued on an enclosing
224
+ * scope, or on the instance, it would wait behind the scope running there,
225
+ * which may be the one awaiting it. Savepoints on one connection form a
226
+ * stack, so whatever opens now is inside that innermost scope anyway; when
227
+ * none is open the call queues on the instance.
228
+ *
229
+ * The innermost open scope need not be related to the call. When it is a
230
+ * sibling savepoint that later rolls back, the call's write rolls back with
231
+ * it, although the call itself already resolved. Waiting for an unrelated
232
+ * scope instead could wait on the very scope that awaits the call.
233
+ */
234
+ private nestingScope;
235
+ /**
236
+ * Run `work` as a savepoint of the active transaction: released when it
237
+ * resolves, rolled back to when it throws.
238
+ */
239
+ private runSavepoint;
240
+ /**
241
+ * Inner transaction body. Kept private so callers always go through
242
+ * the serialized `transaction()` queue above and the BEGIN/COMMIT
243
+ * pair is never invoked outside of it.
244
+ */
245
+ private runTransaction;
246
+ /**
247
+ * Get SQLite database capabilities.
248
+ *
249
+ * @remarks
250
+ * SQLite capabilities:
251
+ * - JSON support (not JSONB)
252
+ * - No arrays
253
+ * - No native ILIKE
254
+ * - RETURNING clause (3.35+)
255
+ * - Savepoints supported
256
+ * - ON CONFLICT supported
257
+ */
258
+ getCapabilities(): DatabaseCapabilities;
259
+ /**
260
+ * Override insertMany for bulk insert optimization.
261
+ *
262
+ * @remarks
263
+ * Uses a single multi-row INSERT statement for better performance.
264
+ */
265
+ override insertMany<T = unknown>(table: string, data: Record<string, unknown>[], options?: InsertOptions): Promise<T[]>;
266
+ /**
267
+ * Ensures database is connected and returns it.
268
+ *
269
+ * @throws {DatabaseError} If not connected
270
+ */
271
+ private ensureDb;
272
+ /**
273
+ * Return the typed Drizzle instance for SQLite.
274
+ * Guarded for server-only usage and requires an active connection.
275
+ *
276
+ * @param schema - Optional schema for relational queries (db.query.*)
277
+ * @returns Drizzle ORM instance wrapping the better-sqlite3 connection
278
+ * @throws {Error} If called in browser or not connected
279
+ */
280
+ getDrizzle<T = BetterSQLite3Database<AnyRelations>>(relations?: AnyRelations): T;
281
+ /**
282
+ * Convert $1, $2 placeholders to ? for better-sqlite3.
283
+ *
284
+ * @param sql - SQL with PostgreSQL-style placeholders
285
+ * @returns SQL with ? placeholders
286
+ */
287
+ private convertPlaceholders;
288
+ /**
289
+ * Creates a TransactionContext for the given database connection.
290
+ */
291
+ /** A table-level `primaryKey({ columns })`, read through the SQLite table config. */
292
+ protected override compositePrimaryKey(tableObj: Record<string, unknown>): object[];
293
+ private createTransactionContext;
294
+ /**
295
+ * Classifies a SQLite error into a DatabaseError.
296
+ *
297
+ * @param error - Original error from better-sqlite3
298
+ * @param sql - SQL statement that caused the error (optional)
299
+ * @returns DatabaseError with proper classification
300
+ */
301
+ protected override classifyError(error: unknown, sql?: string): DatabaseError;
338
302
  }
339
303
  /**
340
304
  * Create a SQLite database adapter.
@@ -368,7 +332,7 @@ declare class SqliteAdapter extends DrizzleAdapter {
368
332
  * await adapter.connect();
369
333
  * ```
370
334
  */
371
- declare function createSqliteAdapter(config: SqliteAdapterConfig): SqliteAdapter;
335
+ export declare function createSqliteAdapter(config: SqliteAdapterConfig): SqliteAdapter;
372
336
  /**
373
337
  * Type guard to check if a value is a SqliteAdapter.
374
338
  *
@@ -383,6 +347,6 @@ declare function createSqliteAdapter(config: SqliteAdapterConfig): SqliteAdapter
383
347
  * }
384
348
  * ```
385
349
  */
386
- declare function isSqliteAdapter(value: unknown): value is SqliteAdapter;
387
-
388
- export { SqliteAdapter, VERSION, createSqliteAdapter, isSqliteAdapter };
350
+ export declare function isSqliteAdapter(value: unknown): value is SqliteAdapter;
351
+ export type { AdapterLogger, BaseAdapterConfig, DatabaseCapabilities, DatabaseError, DatabaseErrorKind, DeleteOptions, InsertOptions, JoinSpec, OrderBySpec, PoolStats, SelectOptions, SqlParam, SqliteAdapterConfig, TransactionContext, TransactionOptions, UpdateOptions, UpsertOptions, WhereClause, WhereCondition, WhereOperator };
352
+ //# sourceMappingURL=index.d.cts.map