@ehegnes/wa-sqlite 2.0.0-beta.0

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.
Files changed (61) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +78 -0
  3. package/dist/wa-sqlite-async.mjs +2 -0
  4. package/dist/wa-sqlite-async.wasm +0 -0
  5. package/dist/wa-sqlite-jspi.mjs +2 -0
  6. package/dist/wa-sqlite-jspi.wasm +0 -0
  7. package/dist/wa-sqlite.mjs +2 -0
  8. package/dist/wa-sqlite.wasm +0 -0
  9. package/package.json +44 -0
  10. package/src/FacadeVFS.js +681 -0
  11. package/src/VFS.js +222 -0
  12. package/src/WebLocksMixin.js +411 -0
  13. package/src/examples/AccessHandlePoolVFS.js +458 -0
  14. package/src/examples/IDBBatchAtomicVFS.js +827 -0
  15. package/src/examples/IDBMirrorVFS.js +889 -0
  16. package/src/examples/LazyLock.js +90 -0
  17. package/src/examples/Lock.js +69 -0
  18. package/src/examples/MemoryAsyncVFS.js +100 -0
  19. package/src/examples/MemoryVFS.js +176 -0
  20. package/src/examples/OPFSAdaptiveVFS.js +437 -0
  21. package/src/examples/OPFSAnyContextVFS.js +300 -0
  22. package/src/examples/OPFSCoopSyncVFS.js +597 -0
  23. package/src/examples/OPFSPermutedVFS.js +1217 -0
  24. package/src/examples/OPFSWriteAheadVFS.js +960 -0
  25. package/src/examples/README.md +81 -0
  26. package/src/examples/WriteAhead.js +1174 -0
  27. package/src/examples/tag.js +82 -0
  28. package/src/sqlite-api.js +924 -0
  29. package/src/sqlite-constants.js +275 -0
  30. package/src/types/globals.d.ts +60 -0
  31. package/src/types/index.d.ts +1228 -0
  32. package/src/types/tsconfig.json +6 -0
  33. package/test/AccessHandlePoolVFS.test.js +27 -0
  34. package/test/IDBBatchAtomicVFS.test.js +97 -0
  35. package/test/IDBMirrorVFS.test.js +27 -0
  36. package/test/MemoryAsyncVFS.test.js +27 -0
  37. package/test/MemoryVFS.test.js +27 -0
  38. package/test/OPFSAdaptiveVFS.test.js +27 -0
  39. package/test/OPFSAnyContextVFS.test.js +27 -0
  40. package/test/OPFSCoopSyncVFS.test.js +27 -0
  41. package/test/OPFSWriteAheadVFS.test.js +27 -0
  42. package/test/TestContext.js +96 -0
  43. package/test/WebLocksMixin.test.js +521 -0
  44. package/test/api.test.js +49 -0
  45. package/test/api_exec.js +89 -0
  46. package/test/api_misc.js +63 -0
  47. package/test/api_statements.js +447 -0
  48. package/test/callbacks.test.js +581 -0
  49. package/test/data/idbv5.json +1 -0
  50. package/test/sql.test.js +64 -0
  51. package/test/sql_0001.js +49 -0
  52. package/test/sql_0002.js +52 -0
  53. package/test/sql_0003.js +83 -0
  54. package/test/sql_0004.js +81 -0
  55. package/test/sql_0005.js +76 -0
  56. package/test/test-worker.js +204 -0
  57. package/test/vfs_xAccess.js +2 -0
  58. package/test/vfs_xClose.js +52 -0
  59. package/test/vfs_xOpen.js +91 -0
  60. package/test/vfs_xRead.js +38 -0
  61. package/test/vfs_xWrite.js +36 -0
@@ -0,0 +1,1228 @@
1
+ /**
2
+ * This is a WebAssembly build of SQLite with experimental support for
3
+ * writing SQLite virtual file systems and modules (for virtual tables)
4
+ * in Javascript. Also see the
5
+ * [GitHub repository](https://github.com/rhashimoto/wa-sqlite) and the
6
+ * [online demo](https://rhashimoto.github.io/wa-sqlite/demo/).
7
+ * @module
8
+ */
9
+
10
+ /**
11
+ * Javascript types that SQLite can use
12
+ *
13
+ * C integer and floating-point types both map to/from Javascript `number`.
14
+ * Blob data can be provided to SQLite as `Uint8Array` or `number[]` (with
15
+ * each element converted to a byte); SQLite always returns blob data as
16
+ * `Uint8Array`
17
+ */
18
+ type SQLiteCompatibleType = number|string|Uint8Array|Array<number>|bigint|null;
19
+
20
+ /**
21
+ * SQLite Virtual File System object
22
+ *
23
+ * Objects with this interface can be passed to {@link SQLiteAPI.vfs_register}
24
+ * to define a new filesystem.
25
+ *
26
+ * There are [synchronous](https://github.com/rhashimoto/wa-sqlite/blob/master/src/examples/MemoryVFS.js)
27
+ * and [asynchronous](https://github.com/rhashimoto/wa-sqlite/blob/master/src/examples/MemoryAsyncVFS.js)
28
+ * example VFS classes in the repository.
29
+ *
30
+ * @see https://sqlite.org/vfs.html
31
+ * @see https://sqlite.org/c3ref/io_methods.html
32
+ */
33
+ declare interface SQLiteVFS {
34
+ /** Maximum length of a file path in UTF-8 bytes (default 64) */
35
+ mxPathname?: number;
36
+
37
+ name: string;
38
+
39
+ close(): void|Promise<void>;
40
+ isReady(): boolean|Promise<boolean>;
41
+ hasAsyncMethod(methodName: string): boolean;
42
+
43
+ /** @see https://sqlite.org/c3ref/vfs.html */
44
+ xOpen(
45
+ pVfs: number,
46
+ zName: number,
47
+ pFile: number,
48
+ flags: number,
49
+ pOutFlags: number
50
+ ): number|Promise<number>;
51
+
52
+ /** @see https://sqlite.org/c3ref/vfs.html */
53
+ xDelete(pVfs: number, zName: number, syncDir: number): number|Promise<number>;
54
+
55
+ /** @see https://sqlite.org/c3ref/vfs.html */
56
+ xAccess(
57
+ pVfs: number,
58
+ zName: number,
59
+ flags: number,
60
+ pResOut: number
61
+ ): number|Promise<number>;
62
+
63
+ /** @see https://sqlite.org/c3ref/vfs.html */
64
+ xFullPathname(
65
+ pVfs: number,
66
+ zName: number,
67
+ nOut: number,
68
+ zOut: number
69
+ ): number|Promise<number>;
70
+
71
+ /** @see https://sqlite.org/c3ref/vfs.html */
72
+ xGetLastError(
73
+ pVfs: number,
74
+ nBuf: number,
75
+ zBuf: number
76
+ ): number|Promise<number>;
77
+
78
+ /** @see https://sqlite.org/c3ref/io_methods.html */
79
+ xClose(pFile: number): number|Promise<number>;
80
+
81
+ /** @see https://sqlite.org/c3ref/io_methods.html */
82
+ xRead(
83
+ pFile: number,
84
+ pData: number,
85
+ iAmt: number,
86
+ iOffsetLo: number,
87
+ iOffsetHi: number
88
+ ): number|Promise<number>;
89
+
90
+ /** @see https://sqlite.org/c3ref/io_methods.html */
91
+ xWrite(
92
+ pFile: number,
93
+ pData: number,
94
+ iAmt: number,
95
+ iOffsetLo: number,
96
+ iOffsetHi: number
97
+ ): number|Promise<number>;
98
+
99
+ /** @see https://sqlite.org/c3ref/io_methods.html */
100
+ xTruncate(pFile: number, sizeLo: number, sizeHi: number): number|Promise<number>;
101
+
102
+ /** @see https://sqlite.org/c3ref/io_methods.html */
103
+ xSync(pFile: number, flags: number): number|Promise<number>;
104
+
105
+ /** @see https://sqlite.org/c3ref/io_methods.html */
106
+ xFileSize(
107
+ pFile: number,
108
+ pSize: number
109
+ ): number|Promise<number>;
110
+
111
+ /** @see https://sqlite.org/c3ref/io_methods.html */
112
+ xLock(pFile: number, lockType: number): number|Promise<number>;
113
+
114
+ /** @see https://sqlite.org/c3ref/io_methods.html */
115
+ xUnlock(pFile: number, lockType: number): number|Promise<number>;
116
+
117
+ /** @see https://sqlite.org/c3ref/io_methods.html */
118
+ xCheckReservedLock(
119
+ pFile: number,
120
+ pResOut: number
121
+ ): number|Promise<number>;
122
+
123
+ /** @see https://sqlite.org/c3ref/io_methods.html */
124
+ xFileControl(
125
+ pFile: number,
126
+ op: number,
127
+ pArg: number
128
+ ): number|Promise<number>;
129
+
130
+ /** @see https://sqlite.org/c3ref/io_methods.html */
131
+ xSectorSize(pFile: number): number|Promise<number>;
132
+
133
+ /** @see https://sqlite.org/c3ref/io_methods.html */
134
+ xDeviceCharacteristics(pFile: number): number|Promise<number>;
135
+ }
136
+
137
+ /**
138
+ * Options object argument for {@link SQLiteAPI.statements}
139
+ */
140
+ declare interface SQLitePrepareOptions {
141
+ /**
142
+ * Statement handles prepared and yielded by {@link SQLiteAPI.statements}
143
+ * are normally valid only within the scope of an iteration.
144
+ * Set `unscoped` to `true` to give iterated statements an arbitrary
145
+ * lifetime.
146
+ */
147
+ unscoped?: boolean;
148
+
149
+ /**
150
+ * SQLITE_PREPARE_* flags
151
+ * @see https://sqlite.org/c3ref/c_prepare_dont_log.html#sqlitepreparepersistent
152
+ */
153
+ flags?: number;
154
+ }
155
+
156
+ /**
157
+ * Javascript wrappers for the SQLite C API (plus a few convenience functions)
158
+ *
159
+ * Function signatures have been slightly modified to be more
160
+ * Javascript-friendly. For the C functions that return an error code,
161
+ * the corresponding Javascript wrapper will throw an exception with a
162
+ * `code` property on an error.
163
+ *
164
+ * Note that a few functions return a Promise in order to accomodate
165
+ * either a synchronous or asynchronous SQLite build, generally those
166
+ * involved with opening/closing a database or executing a statement.
167
+ *
168
+ * To create an instance of the API, follow these steps:
169
+ *
170
+ * ```javascript
171
+ * // Import an ES6 module factory function from one of the
172
+ * // package builds, either 'wa-sqlite.mjs' (synchronous) or
173
+ * // 'wa-sqlite-async.mjs' (asynchronous). You should only
174
+ * // use the asynchronous build if you plan to use an
175
+ * // asynchronous VFS or module.
176
+ * import SQLiteESMFactory from 'wa-sqlite/dist/wa-sqlite.mjs';
177
+ *
178
+ * // Import the Javascript API wrappers.
179
+ * import * as SQLite from 'wa-sqlite';
180
+ *
181
+ * // Use an async function to simplify Promise handling.
182
+ * (async function() {
183
+ * // Invoke the ES6 module factory to create the SQLite
184
+ * // Emscripten module. This will fetch and compile the
185
+ * // .wasm file.
186
+ * const module = await SQLiteESMFactory();
187
+ *
188
+ * // Use the module to build the API instance.
189
+ * const sqlite3 = SQLite.Factory(module);
190
+ *
191
+ * // Use the API to open and access a database.
192
+ * const db = await sqlite3.open_v2('myDB');
193
+ * ...
194
+ * })();
195
+ * ```
196
+ *
197
+ * @see https://sqlite.org/c3ref/funclist.html
198
+ */
199
+ declare interface SQLiteAPI {
200
+ /**
201
+ * Bind a collection of values to a statement
202
+ *
203
+ * This convenience function binds values from either an array or object
204
+ * to a prepared statement with placeholder parameters.
205
+ *
206
+ * Array example using numbered parameters (numbering is implicit in
207
+ * this example):
208
+ * ```
209
+ * const sql = 'INSERT INTO tbl VALUES (?, ?, ?)';
210
+ * for await (const stmt of sqlite3.statements(db, sql) {
211
+ * sqlite3.bind_collection(stmt, [42, 'hello', null]);
212
+ * ...
213
+ * }
214
+ * ```
215
+ *
216
+ * Object example using named parameters (':', '@', or '$' prefixes
217
+ * are allowed):
218
+ * ```
219
+ * const sql = 'INSERT INTO tbl VALUES (?, ?, ?)';
220
+ * for await (const stmt of sqlite3.statements(db, sql) {
221
+ * sqlite3.bind_collection(stmt, {
222
+ * '@foo': 42,
223
+ * '@bar': 'hello',
224
+ * '@baz': null,
225
+ * });
226
+ * ...
227
+ * }
228
+ * ```
229
+ *
230
+ * Note that SQLite bindings are indexed beginning with 1, but when
231
+ * binding values from an array `a` the values begin with `a[0]`.
232
+ * @param stmt prepared statement pointer
233
+ * @param bindings
234
+ * @returns `SQLITE_OK` (throws exception on error)
235
+ */
236
+ bind_collection(
237
+ stmt: number,
238
+ bindings: {[index: string]: SQLiteCompatibleType|null}|Array<SQLiteCompatibleType|null>
239
+ ): number;
240
+
241
+ /**
242
+ * Bind value to prepared statement
243
+ *
244
+ * This convenience function calls the appropriate `bind_*` function
245
+ * based on the type of `value`. Note that binding indices begin with 1.
246
+ * @param stmt prepared statement pointer
247
+ * @param i binding index
248
+ * @param value
249
+ * @returns `SQLITE_OK` (throws exception on error)
250
+ */
251
+ bind(stmt: number, i: number, value: SQLiteCompatibleType|null): number;
252
+
253
+ /**
254
+ * Bind blob to prepared statement parameter
255
+ *
256
+ * Note that binding indices begin with 1.
257
+ * @see https://www.sqlite.org/c3ref/bind_blob.html
258
+ * @param stmt prepared statement pointer
259
+ * @param i binding index
260
+ * @param value
261
+ * @returns `SQLITE_OK` (throws exception on error)
262
+ */
263
+ bind_blob(stmt: number, i: number, value: Uint8Array|Array<number>): number;
264
+
265
+ /**
266
+ * Bind number to prepared statement parameter
267
+ *
268
+ * Note that binding indices begin with 1.
269
+ * @see https://www.sqlite.org/c3ref/bind_blob.html
270
+ * @param stmt prepared statement pointer
271
+ * @param i binding index
272
+ * @param value
273
+ * @returns `SQLITE_OK` (throws exception on error)
274
+ */
275
+ bind_double(stmt: number, i: number, value: number): number;
276
+
277
+ /**
278
+ * Bind number to prepared statement parameter
279
+ *
280
+ * Note that binding indices begin with 1.
281
+ * @see https://www.sqlite.org/c3ref/bind_blob.html
282
+ * @param stmt prepared statement pointer
283
+ * @param i binding index
284
+ * @param value
285
+ * @returns `SQLITE_OK` (throws exception on error)
286
+ */
287
+ bind_int(stmt: number, i: number, value: number): number;
288
+
289
+ /**
290
+ * Bind number to prepared statement parameter
291
+ *
292
+ * Note that binding indices begin with 1.
293
+ * @see https://www.sqlite.org/c3ref/bind_blob.html
294
+ * @param stmt prepared statement pointer
295
+ * @param i binding index
296
+ * @param value
297
+ * @returns `SQLITE_OK` (throws exception on error)
298
+ */
299
+ bind_int64(stmt: number, i: number, value: bigint): number;
300
+
301
+ /**
302
+ * Bind null to prepared statement
303
+ *
304
+ * Note that binding indices begin with 1.
305
+ * @see https://www.sqlite.org/c3ref/bind_blob.html
306
+ * @param stmt prepared statement pointer
307
+ * @param i binding index
308
+ * @returns `SQLITE_OK` (throws exception on error)
309
+ */
310
+ bind_null(stmt: number, i: number): number;
311
+
312
+ /**
313
+ * Get number of bound parameters
314
+ * @see https://www.sqlite.org/c3ref/bind_parameter_count.html
315
+ * @param stmt prepared statement pointer
316
+ * @returns number of statement binding locations
317
+ */
318
+ bind_parameter_count(stmt: number): number;
319
+
320
+ /**
321
+ * Get name of bound parameter
322
+ *
323
+ * Note that binding indices begin with 1.
324
+ * @see https://www.sqlite.org/c3ref/bind_parameter_name.html
325
+ * @param stmt prepared statement pointer
326
+ * @param i binding index
327
+ * @returns binding name
328
+ */
329
+ bind_parameter_name(stmt: number, i: number): string;
330
+
331
+ /**
332
+ * Bind string to prepared statement
333
+ *
334
+ * Note that binding indices begin with 1.
335
+ * @see https://www.sqlite.org/c3ref/bind_blob.html
336
+ * @param stmt prepared statement pointer
337
+ * @param i binding index
338
+ * @param value
339
+ * @returns `SQLITE_OK` (throws exception on error)
340
+ */
341
+ bind_text(stmt: number, i: number, value: string): number;
342
+
343
+ /**
344
+ * Get count of rows modified by last insert/update
345
+ * @see https://www.sqlite.org/c3ref/changes.html
346
+ * @param db database pointer
347
+ * @returns number of rows modified
348
+ */
349
+ changes(db): number;
350
+
351
+ /**
352
+ * Reset all bindings on a prepared statement.
353
+ * @see https://www.sqlite.org/c3ref/clear_bindings.html
354
+ * @param stmt prepared statement pointer
355
+ * @returns `SQLITE_OK` (throws exception on error)
356
+ */
357
+ clear_bindings(stmt: number): number;
358
+
359
+ /**
360
+ * Close database connection
361
+ * @see https://www.sqlite.org/c3ref/close.html
362
+ * @param db database pointer
363
+ * @returns `SQLITE_OK` (throws exception on error)
364
+ */
365
+ close(db): Promise<number>;
366
+
367
+ /**
368
+ * Call the appropriate `column_*` function based on the column type
369
+ *
370
+ * The type is determined by calling {@link column_type}, which may
371
+ * not match the type declared in `CREATE TABLE`. Note that if the column
372
+ * value is a blob then as with `column_blob` the result may be invalid
373
+ * after the next SQLite call; copy if it needs to be retained.
374
+ *
375
+ * Integer values are returned as Number if within the min/max safe
376
+ * integer bounds, otherwise they are returned as BigInt.
377
+ * @param stmt prepared statement pointer
378
+ * @param i column index
379
+ * @returns column value
380
+ */
381
+ column(stmt: number, i: number): SQLiteCompatibleType;
382
+
383
+ /**
384
+ * Extract a column value from a row after a prepared statment {@link step}
385
+ *
386
+ * The contents of the returned buffer may be invalid after the
387
+ * next SQLite call. Make a copy of the data (e.g. with `.slice()`)
388
+ * if longer retention is required.
389
+ * @see https://www.sqlite.org/c3ref/column_blob.html
390
+ * @param stmt prepared statement pointer
391
+ * @param i column index
392
+ * @returns column value
393
+ */
394
+ column_blob(stmt: number, i: number): Uint8Array;
395
+
396
+ /**
397
+ * Get storage size for column text or blob
398
+ * @see https://www.sqlite.org/c3ref/column_blob.html
399
+ * @param stmt prepared statement pointer
400
+ * @param i column index
401
+ * @returns number of bytes in column text or blob
402
+ */
403
+ column_bytes(stmt: number, i: number): number;
404
+
405
+ /**
406
+ * Get number of columns for a prepared statement
407
+ * @see https://www.sqlite.org/c3ref/column_blob.html
408
+ * @param stmt prepared statement pointer
409
+ * @returns number of columns
410
+ */
411
+ column_count(stmt: number): number;
412
+
413
+ /**
414
+ * Extract a column value from a row after a prepared statment {@link step}
415
+ * @see https://www.sqlite.org/c3ref/column_blob.html
416
+ * @param stmt prepared statement pointer
417
+ * @param i column index
418
+ * @returns column value
419
+ */
420
+ column_double(stmt: number, i: number): number;
421
+
422
+ /**
423
+ * Extract a column value from a row after a prepared statment {@link step}
424
+ * @see https://www.sqlite.org/c3ref/column_blob.html
425
+ * @param stmt prepared statement pointer
426
+ * @param i column index
427
+ * @returns column value
428
+ */
429
+ column_int(stmt: number, i: number): number;
430
+
431
+ /**
432
+ * Extract a column value from a row after a prepared statment {@link step}
433
+ * @see https://www.sqlite.org/c3ref/column_blob.html
434
+ * @param stmt prepared statement pointer
435
+ * @param i column index
436
+ * @returns column value
437
+ */
438
+ column_int64(stmt: number, i: number): bigint;
439
+
440
+ /**
441
+ * Get a column name for a prepared statement
442
+ * @see https://www.sqlite.org/c3ref/column_blob.html
443
+ * @param stmt prepared statement pointer
444
+ * @param i column index
445
+ * @returns column name
446
+ */
447
+ column_name(stmt: number, i: number): string;
448
+
449
+ /**
450
+ * Get names for all columns of a prepared statement
451
+ *
452
+ * This is a convenience function that calls {@link column_count} and
453
+ * {@link column_name}.
454
+ * @param stmt
455
+ * @returns array of column names
456
+ */
457
+ column_names(stmt: number): Array<string>;
458
+
459
+ /**
460
+ * Extract a column value from a row after a prepared statment {@link step}
461
+ * @see https://www.sqlite.org/c3ref/column_blob.html
462
+ * @param stmt prepared statement pointer
463
+ * @param i column index
464
+ * @returns column value
465
+ */
466
+ column_text(stmt: number, i: number): string;
467
+
468
+ /**
469
+ * Get column type for a prepared statement
470
+ *
471
+ * Note that this type may not match the type declared in `CREATE TABLE`.
472
+ * @see https://www.sqlite.org/c3ref/column_blob.html
473
+ * @param stmt prepared statement pointer
474
+ * @param i column index
475
+ * @returns enumeration value for type
476
+ */
477
+ column_type(stmt: number, i: number): number;
478
+
479
+ /**
480
+ * Register a commit hook
481
+ *
482
+ * @see https://www.sqlite.org/c3ref/commit_hook.html
483
+ *
484
+ * @param db database pointer
485
+ * @param callback If a non-zero value is returned, commit is converted into
486
+ * a rollback; disables callback when null
487
+ */
488
+ commit_hook(
489
+ db: number,
490
+ callback: (() => number) | null): void;
491
+
492
+ /**
493
+ * Create or redefine SQL functions
494
+ *
495
+ * The application data passed is ignored. Use closures instead.
496
+ *
497
+ * If any callback function returns a Promise, that function must
498
+ * be declared `async`, i.e. it must allow use of `await`.
499
+ * @see https://sqlite.org/c3ref/create_function.html
500
+ * @param db database pointer
501
+ * @param zFunctionName
502
+ * @param nArg number of function arguments
503
+ * @param eTextRep text encoding (and other flags)
504
+ * @param pApp application data (ignored)
505
+ * @param xFunc
506
+ * @param xStep
507
+ * @param xFinal
508
+ * @returns `SQLITE_OK` (throws exception on error)
509
+ */
510
+ create_function(
511
+ db: number,
512
+ zFunctionName: string,
513
+ nArg: number,
514
+ eTextRep: number,
515
+ pApp: number,
516
+ xFunc?: (context: number, values: Uint32Array) => void|Promise<void>,
517
+ xStep?: (context: number, values: Uint32Array) => void|Promise<void>,
518
+ xFinal?: (context: number) => void|Promise<void>): number;
519
+
520
+ /**
521
+ * Get number of columns in current row of a prepared statement
522
+ * @see https://www.sqlite.org/c3ref/data_count.html
523
+ * @param stmt prepared statement pointer
524
+ * @returns number of columns
525
+ */
526
+ data_count(stmt: number): number;
527
+
528
+ /**
529
+ * One-step query execution interface
530
+ *
531
+ * The implementation of this function uses {@link row}, which makes a
532
+ * copy of blobs and returns BigInt for integers outside the safe integer
533
+ * bounds for Number.
534
+ * @see https://www.sqlite.org/c3ref/exec.html
535
+ * @param db database pointer
536
+ * @param zSQL queries
537
+ * @param callback called for each output row
538
+ * @returns Promise resolving to `SQLITE_OK` (rejects on error)
539
+ */
540
+ exec(
541
+ db: number,
542
+ zSQL: string,
543
+ callback?: (row: Array<SQLiteCompatibleType|null>, columns: string[]) => void
544
+ ): Promise<number>;
545
+
546
+ /**
547
+ * Destroy a prepared statement object compiled by {@link statements}
548
+ * with the `unscoped` option set to `true`
549
+ *
550
+ * This function does *not* throw on error.
551
+ * @see https://www.sqlite.org/c3ref/finalize.html
552
+ * @param stmt prepared statement pointer
553
+ * @returns Promise resolving to `SQLITE_OK` or error status
554
+ */
555
+ finalize(stmt: number): Promise<number>;
556
+
557
+ /**
558
+ * Test for autocommit mode
559
+ * @see https://sqlite.org/c3ref/get_autocommit.html
560
+ * @param db database pointer
561
+ * @returns Non-zero if autocommit mode is on, zero otherwise
562
+ */
563
+ get_autocommit(db: number): number;
564
+
565
+ /**
566
+ * Get SQLite library version
567
+ * @see https://www.sqlite.org/c3ref/libversion.html
568
+ * @returns version string, e.g. '3.35.5'
569
+ */
570
+ libversion(): string;
571
+
572
+ /**
573
+ * Get SQLite library version
574
+ * @see https://www.sqlite.org/c3ref/libversion.html
575
+ * @returns version number, e.g. 3035005
576
+ */
577
+ libversion_number(): number
578
+
579
+ /**
580
+ * Set a usage limit on a connection.
581
+ * @see https://www.sqlite.org/c3ref/limit.html
582
+ * @param db database pointer
583
+ * @param id limit category
584
+ * @param newVal
585
+ * @returns previous setting
586
+ */
587
+ limit(
588
+ db: number,
589
+ id: number,
590
+ newVal: number): number;
591
+
592
+ /**
593
+ * Opening a new database connection.
594
+ *
595
+ * Note that this function differs from the C API in that it
596
+ * returns the Promise-wrapped database pointer (instead of a
597
+ * result code).
598
+ * @see https://sqlite.org/c3ref/open.html
599
+ * @param zFilename
600
+ * @param iFlags `SQLite.SQLITE_OPEN_CREATE | SQLite.SQLITE_OPEN_READWRITE` (0x6) if omitted
601
+ * @param zVfs VFS name
602
+ * @returns Promise-wrapped database pointer.
603
+ */
604
+ open_v2(
605
+ zFilename: string,
606
+ iFlags?: number,
607
+ zVfs?: string
608
+ ): Promise<number>;
609
+
610
+ /**
611
+ * Specify callback to be invoked between long-running queries
612
+ *
613
+ * The application data passed is ignored. Use closures instead.
614
+ *
615
+ * If any callback function returns a Promise, that function must
616
+ * be declared `async`, i.e. it must allow use of `await`.
617
+ * @param db database pointer
618
+ * @param nProgressOps target number of database operations between handler invocations
619
+ * @param handler
620
+ * @param userData
621
+ */
622
+ progress_handler(db: number, nProgressOps: number, handler: (userData: any) => number|Promise<number>, userData);
623
+
624
+ /**
625
+ * Reset a prepared statement object
626
+ * @see https://www.sqlite.org/c3ref/reset.html
627
+ * @param stmt prepared statement pointer
628
+ * @returns Promise-wrapped `SQLITE_OK` (rejects on error)
629
+ */
630
+ reset(stmt: number): Promise<number>;
631
+
632
+ /**
633
+ * Convenience function to call `result_*` based of the type of `value`
634
+ * @param context context pointer
635
+ * @param value
636
+ */
637
+ result(context: number, value: (SQLiteCompatibleType|number[])|null): void;
638
+
639
+ /**
640
+ * Set the result of a function or vtable column
641
+ * @see https://sqlite.org/c3ref/result_blob.html
642
+ * @param context context pointer
643
+ * @param value
644
+ */
645
+ result_blob(context: number, value: Uint8Array|number[]): void;
646
+
647
+ /**
648
+ * Set the result of a function or vtable column
649
+ * @see https://sqlite.org/c3ref/result_blob.html
650
+ * @param context context pointer
651
+ * @param value
652
+ */
653
+ result_double(context: number, value: number): void;
654
+
655
+ /**
656
+ * Set the result of a function or vtable column
657
+ * @see https://sqlite.org/c3ref/result_blob.html
658
+ * @param context context pointer
659
+ * @param value
660
+ */
661
+ result_int(context: number, value: number): void;
662
+
663
+ /**
664
+ * Set the result of a function or vtable column
665
+ * @see https://sqlite.org/c3ref/result_blob.html
666
+ * @param context context pointer
667
+ * @param value
668
+ */
669
+ result_int64(context: number, value: bigint): void;
670
+
671
+ /**
672
+ * Set the result of a function or vtable column
673
+ * @see https://sqlite.org/c3ref/result_blob.html
674
+ * @param context context pointer
675
+ */
676
+ result_null(context: number): void;
677
+
678
+ /**
679
+ * Set the result of a function or vtable column
680
+ * @see https://sqlite.org/c3ref/result_blob.html
681
+ * @param context context pointer
682
+ * @param value
683
+ */
684
+ result_text(context: number, value: string): void;
685
+
686
+ /**
687
+ * Get all column data for a row from a prepared statement step
688
+ *
689
+ * This convenience function will return a copy of any blob, unlike
690
+ * {@link column_blob} which returns a value referencing volatile WASM
691
+ * memory with short validity. Like {@link column}, it will return a
692
+ * BigInt for integers outside the safe integer bounds for Number.
693
+ * @param stmt prepared statement pointer
694
+ * @returns row data
695
+ */
696
+ row(stmt: number): Array<SQLiteCompatibleType|null>;
697
+
698
+ /**
699
+ * Register a callback function that is invoked to authorize certain SQL statement actions.
700
+ * @see https://www.sqlite.org/c3ref/set_authorizer.html
701
+ * @param db database pointer
702
+ * @param authFunction
703
+ * @param userData
704
+ */
705
+ set_authorizer(
706
+ db: number,
707
+ authFunction: (userData: any, iActionCode: number, param3: string|null, param4: string|null, param5: string|null, param6: string|null) => number|Promise<number>,
708
+ userData: any): number;
709
+
710
+ /**
711
+ * Get statement SQL
712
+ * @see https://www.sqlite.org/c3ref/expanded_sql.html
713
+ * @param stmt prepared statement pointer
714
+ * @returns SQL
715
+ */
716
+ sql(stmt: number): string;
717
+
718
+ /**
719
+ * SQL statement iterator
720
+ *
721
+ * This function manages statement compilation by creating an async
722
+ * iterator that yields a prepared statement handle on each iteration.
723
+ * It is typically used with a `for await` loop (in an async function),
724
+ * like this:
725
+ * ```javascript
726
+ * // Compile one statement on each iteration of this loop.
727
+ * for await (const stmt of sqlite3.statements(db, sql)) {
728
+ * // Bind parameters here if using SQLite placeholders.
729
+ *
730
+ * // Execute the statement with this loop.
731
+ * while (await sqlite3.step(stmt) === SQLite.SQLITE_ROW) {
732
+ * // Collect row data here.
733
+ * }
734
+ *
735
+ * // Change bindings, reset, and execute again if desired.
736
+ * }
737
+ * ```
738
+ *
739
+ * By default, the lifetime of a yielded prepared statement is managed
740
+ * automatically by the iterator, ending at the end of each iteration.
741
+ * {@link finalize} should *not* be called on a statement provided by
742
+ * the iterator unless the `unscoped` option is set to `true` (that
743
+ * option is provided for applications that wish to manage statement
744
+ * lifetimes manually).
745
+ *
746
+ * If using the iterator manually, i.e. by calling its `next`
747
+ * method, be sure to call the `return` method if iteration
748
+ * is abandoned before completion (`for await` and other implicit
749
+ * traversals provided by Javascript do this automatically)
750
+ * to ensure that all allocated resources are released.
751
+ * @see https://www.sqlite.org/c3ref/prepare.html
752
+ * @param db database pointer
753
+ * @param sql
754
+ * @param options
755
+ */
756
+ statements(db: number, sql: string, options?: SQLitePrepareOptions): AsyncIterable<number>;
757
+
758
+ /**
759
+ * Evaluate an SQL statement
760
+ * @see https://www.sqlite.org/c3ref/step.html
761
+ * @param stmt prepared statement pointer
762
+ * @returns Promise resolving to `SQLITE_ROW` or `SQLITE_DONE`
763
+ * (rejects on error)
764
+ */
765
+ step(stmt: number): Promise<number>;
766
+
767
+ /**
768
+ * Register an update hook
769
+ *
770
+ * The callback is invoked whenever a row is updated, inserted, or deleted
771
+ * in a rowid table on this connection.
772
+ * @see https://www.sqlite.org/c3ref/update_hook.html
773
+ *
774
+ * updateType is one of:
775
+ * - SQLITE_DELETE: 9
776
+ * - SQLITE_INSERT: 18
777
+ * - SQLITE_UPDATE: 23
778
+ * @see https://www.sqlite.org/c3ref/c_alter_table.html
779
+ *
780
+ * @param db database pointer
781
+ * @param callback
782
+ */
783
+ update_hook(
784
+ db: number,
785
+ callback: (updateType: number, dbName: string|null, tblName: string|null, rowid: bigint) => void): void;
786
+
787
+ /**
788
+ * Extract a value from `sqlite3_value`
789
+ *
790
+ * This is a convenience function that calls the appropriate `value_*`
791
+ * function based on its type. Note that if the value is a blob then as
792
+ * with `value_blob` the result may be invalid after the next SQLite call.
793
+ *
794
+ * Integer values are returned as Number if within the min/max safe
795
+ * integer bounds, otherwise they are returned as BigInt.
796
+ * @param pValue `sqlite3_value` pointer
797
+ * @returns value
798
+ */
799
+ value(pValue: number): SQLiteCompatibleType;
800
+
801
+ /**
802
+ * Extract a value from `sqlite3_value`
803
+ *
804
+ * The contents of the returned buffer may be invalid after the
805
+ * next SQLite call. Make a copy of the data (e.g. with `.slice()`)
806
+ * if longer retention is required.
807
+ * @see https://sqlite.org/c3ref/value_blob.html
808
+ * @param pValue `sqlite3_value` pointer
809
+ * @returns value
810
+ */
811
+ value_blob(pValue: number): Uint8Array;
812
+
813
+ /**
814
+ * Get blob or text size for value
815
+ * @see https://sqlite.org/c3ref/value_blob.html
816
+ * @param pValue `sqlite3_value` pointer
817
+ * @returns size
818
+ */
819
+ value_bytes(pValue: number): number;
820
+
821
+ /**
822
+ * Extract a value from `sqlite3_value`
823
+ * @see https://sqlite.org/c3ref/value_blob.html
824
+ * @param pValue `sqlite3_value` pointer
825
+ * @returns value
826
+ */
827
+ value_double(pValue: number): number;
828
+
829
+ /**
830
+ * Extract a value from `sqlite3_value`
831
+ * @see https://sqlite.org/c3ref/value_blob.html
832
+ * @param pValue `sqlite3_value` pointer
833
+ * @returns value
834
+ */
835
+ value_int(pValue: number): number;
836
+
837
+ /**
838
+ * Extract a value from `sqlite3_value`
839
+ * @see https://sqlite.org/c3ref/value_blob.html
840
+ * @param pValue `sqlite3_value` pointer
841
+ * @returns value
842
+ */
843
+ value_int64(pValue: number): bigint;
844
+
845
+ /**
846
+ * Extract a value from `sqlite3_value`
847
+ * @see https://sqlite.org/c3ref/value_blob.html
848
+ * @param pValue `sqlite3_value` pointer
849
+ * @returns value
850
+ */
851
+ value_text(pValue: number): string;
852
+
853
+ /**
854
+ * Get type of `sqlite3_value`
855
+ * @see https://sqlite.org/c3ref/value_blob.html
856
+ * @param pValue `sqlite3_value` pointer
857
+ * @returns enumeration value for type
858
+ */
859
+ value_type(pValue: number): number;
860
+
861
+ /**
862
+ * Register a new Virtual File System.
863
+ *
864
+ * @see https://www.sqlite.org/c3ref/vfs_find.html
865
+ * @param vfs VFS object
866
+ * @param makeDefault
867
+ * @returns `SQLITE_OK` (throws exception on error)
868
+ */
869
+ vfs_register(vfs: SQLiteVFS, makeDefault?: boolean): number;
870
+ }
871
+
872
+ /** @ignore */
873
+ declare module 'wa-sqlite/src/sqlite-constants.js' {
874
+ export const SQLITE_OK: 0;
875
+ export const SQLITE_ERROR: 1;
876
+ export const SQLITE_INTERNAL: 2;
877
+ export const SQLITE_PERM: 3;
878
+ export const SQLITE_ABORT: 4;
879
+ export const SQLITE_BUSY: 5;
880
+ export const SQLITE_LOCKED: 6;
881
+ export const SQLITE_NOMEM: 7;
882
+ export const SQLITE_READONLY: 8;
883
+ export const SQLITE_INTERRUPT: 9;
884
+ export const SQLITE_IOERR: 10;
885
+ export const SQLITE_CORRUPT: 11;
886
+ export const SQLITE_NOTFOUND: 12;
887
+ export const SQLITE_FULL: 13;
888
+ export const SQLITE_CANTOPEN: 14;
889
+ export const SQLITE_PROTOCOL: 15;
890
+ export const SQLITE_EMPTY: 16;
891
+ export const SQLITE_SCHEMA: 17;
892
+ export const SQLITE_TOOBIG: 18;
893
+ export const SQLITE_CONSTRAINT: 19;
894
+ export const SQLITE_MISMATCH: 20;
895
+ export const SQLITE_MISUSE: 21;
896
+ export const SQLITE_NOLFS: 22;
897
+ export const SQLITE_AUTH: 23;
898
+ export const SQLITE_FORMAT: 24;
899
+ export const SQLITE_RANGE: 25;
900
+ export const SQLITE_NOTADB: 26;
901
+ export const SQLITE_NOTICE: 27;
902
+ export const SQLITE_WARNING: 28;
903
+ export const SQLITE_ROW: 100;
904
+ export const SQLITE_DONE: 101;
905
+ export const SQLITE_IOERR_ACCESS: 3338;
906
+ export const SQLITE_IOERR_CHECKRESERVEDLOCK: 3594;
907
+ export const SQLITE_IOERR_CLOSE: 4106;
908
+ export const SQLITE_IOERR_DATA: 8202;
909
+ export const SQLITE_IOERR_DELETE: 2570;
910
+ export const SQLITE_IOERR_DELETE_NOENT: 5898;
911
+ export const SQLITE_IOERR_DIR_FSYNC: 1290;
912
+ export const SQLITE_IOERR_FSTAT: 1802;
913
+ export const SQLITE_IOERR_FSYNC: 1034;
914
+ export const SQLITE_IOERR_GETTEMPPATH: 6410;
915
+ export const SQLITE_IOERR_LOCK: 3850;
916
+ export const SQLITE_IOERR_NOMEM: 3082;
917
+ export const SQLITE_IOERR_READ: 266;
918
+ export const SQLITE_IOERR_RDLOCK: 2314;
919
+ export const SQLITE_IOERR_SEEK: 5642;
920
+ export const SQLITE_IOERR_SHORT_READ: 522;
921
+ export const SQLITE_IOERR_TRUNCATE: 1546;
922
+ export const SQLITE_IOERR_UNLOCK: 2058;
923
+ export const SQLITE_IOERR_VNODE: 6922;
924
+ export const SQLITE_IOERR_WRITE: 778;
925
+ export const SQLITE_IOERR_BEGIN_ATOMIC: 7434;
926
+ export const SQLITE_IOERR_COMMIT_ATOMIC: 7690;
927
+ export const SQLITE_IOERR_ROLLBACK_ATOMIC: 7946;
928
+ export const SQLITE_CONSTRAINT_CHECK: 275;
929
+ export const SQLITE_CONSTRAINT_COMMITHOOK: 531;
930
+ export const SQLITE_CONSTRAINT_FOREIGNKEY: 787;
931
+ export const SQLITE_CONSTRAINT_FUNCTION: 1043;
932
+ export const SQLITE_CONSTRAINT_NOTNULL: 1299;
933
+ export const SQLITE_CONSTRAINT_PINNED: 2835;
934
+ export const SQLITE_CONSTRAINT_PRIMARYKEY: 1555;
935
+ export const SQLITE_CONSTRAINT_ROWID: 2579;
936
+ export const SQLITE_CONSTRAINT_TRIGGER: 1811;
937
+ export const SQLITE_CONSTRAINT_UNIQUE: 2067;
938
+ export const SQLITE_CONSTRAINT_VTAB: 2323;
939
+ export const SQLITE_OPEN_READONLY: 1;
940
+ export const SQLITE_OPEN_READWRITE: 2;
941
+ export const SQLITE_OPEN_CREATE: 4;
942
+ export const SQLITE_OPEN_DELETEONCLOSE: 8;
943
+ export const SQLITE_OPEN_EXCLUSIVE: 16;
944
+ export const SQLITE_OPEN_AUTOPROXY: 32;
945
+ export const SQLITE_OPEN_URI: 64;
946
+ export const SQLITE_OPEN_MEMORY: 128;
947
+ export const SQLITE_OPEN_MAIN_DB: 256;
948
+ export const SQLITE_OPEN_TEMP_DB: 512;
949
+ export const SQLITE_OPEN_TRANSIENT_DB: 1024;
950
+ export const SQLITE_OPEN_MAIN_JOURNAL: 2048;
951
+ export const SQLITE_OPEN_TEMP_JOURNAL: 4096;
952
+ export const SQLITE_OPEN_SUBJOURNAL: 8192;
953
+ export const SQLITE_OPEN_SUPER_JOURNAL: 16384;
954
+ export const SQLITE_OPEN_NOMUTEX: 32768;
955
+ export const SQLITE_OPEN_FULLMUTEX: 65536;
956
+ export const SQLITE_OPEN_SHAREDCACHE: 131072;
957
+ export const SQLITE_OPEN_PRIVATECACHE: 262144;
958
+ export const SQLITE_OPEN_WAL: 524288;
959
+ export const SQLITE_OPEN_NOFOLLOW: 16777216;
960
+ export const SQLITE_LOCK_NONE: 0;
961
+ export const SQLITE_LOCK_SHARED: 1;
962
+ export const SQLITE_LOCK_RESERVED: 2;
963
+ export const SQLITE_LOCK_PENDING: 3;
964
+ export const SQLITE_LOCK_EXCLUSIVE: 4;
965
+ export const SQLITE_IOCAP_ATOMIC: 1;
966
+ export const SQLITE_IOCAP_ATOMIC512: 2;
967
+ export const SQLITE_IOCAP_ATOMIC1K: 4;
968
+ export const SQLITE_IOCAP_ATOMIC2K: 8;
969
+ export const SQLITE_IOCAP_ATOMIC4K: 16;
970
+ export const SQLITE_IOCAP_ATOMIC8K: 32;
971
+ export const SQLITE_IOCAP_ATOMIC16K: 64;
972
+ export const SQLITE_IOCAP_ATOMIC32K: 128;
973
+ export const SQLITE_IOCAP_ATOMIC64K: 256;
974
+ export const SQLITE_IOCAP_SAFE_APPEND: 512;
975
+ export const SQLITE_IOCAP_SEQUENTIAL: 1024;
976
+ export const SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN: 2048;
977
+ export const SQLITE_IOCAP_POWERSAFE_OVERWRITE: 4096;
978
+ export const SQLITE_IOCAP_IMMUTABLE: 8192;
979
+ export const SQLITE_IOCAP_BATCH_ATOMIC: 16384;
980
+ export const SQLITE_ACCESS_EXISTS: 0;
981
+ export const SQLITE_ACCESS_READWRITE: 1;
982
+ export const SQLITE_ACCESS_READ: 2;
983
+ export const SQLITE_FCNTL_LOCKSTATE: 1;
984
+ export const SQLITE_FCNTL_GET_LOCKPROXYFILE: 2;
985
+ export const SQLITE_FCNTL_SET_LOCKPROXYFILE: 3;
986
+ export const SQLITE_FCNTL_LAST_ERRNO: 4;
987
+ export const SQLITE_FCNTL_SIZE_HINT: 5;
988
+ export const SQLITE_FCNTL_CHUNK_SIZE: 6;
989
+ export const SQLITE_FCNTL_FILE_POINTER: 7;
990
+ export const SQLITE_FCNTL_SYNC_OMITTED: 8;
991
+ export const SQLITE_FCNTL_WIN32_AV_RETRY: 9;
992
+ export const SQLITE_FCNTL_PERSIST_WAL: 10;
993
+ export const SQLITE_FCNTL_OVERWRITE: 11;
994
+ export const SQLITE_FCNTL_VFSNAME: 12;
995
+ export const SQLITE_FCNTL_POWERSAFE_OVERWRITE: 13;
996
+ export const SQLITE_FCNTL_PRAGMA: 14;
997
+ export const SQLITE_FCNTL_BUSYHANDLER: 15;
998
+ export const SQLITE_FCNTL_TEMPFILENAME: 16;
999
+ export const SQLITE_FCNTL_MMAP_SIZE: 18;
1000
+ export const SQLITE_FCNTL_TRACE: 19;
1001
+ export const SQLITE_FCNTL_HAS_MOVED: 20;
1002
+ export const SQLITE_FCNTL_SYNC: 21;
1003
+ export const SQLITE_FCNTL_COMMIT_PHASETWO: 22;
1004
+ export const SQLITE_FCNTL_WIN32_SET_HANDLE: 23;
1005
+ export const SQLITE_FCNTL_WAL_BLOCK: 24;
1006
+ export const SQLITE_FCNTL_ZIPVFS: 25;
1007
+ export const SQLITE_FCNTL_RBU: 26;
1008
+ export const SQLITE_FCNTL_VFS_POINTER: 27;
1009
+ export const SQLITE_FCNTL_JOURNAL_POINTER: 28;
1010
+ export const SQLITE_FCNTL_WIN32_GET_HANDLE: 29;
1011
+ export const SQLITE_FCNTL_PDB: 30;
1012
+ export const SQLITE_FCNTL_BEGIN_ATOMIC_WRITE: 31;
1013
+ export const SQLITE_FCNTL_COMMIT_ATOMIC_WRITE: 32;
1014
+ export const SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE: 33;
1015
+ export const SQLITE_FCNTL_LOCK_TIMEOUT: 34;
1016
+ export const SQLITE_FCNTL_DATA_VERSION: 35;
1017
+ export const SQLITE_FCNTL_SIZE_LIMIT: 36;
1018
+ export const SQLITE_FCNTL_CKPT_DONE: 37;
1019
+ export const SQLITE_FCNTL_RESERVE_BYTES: 38;
1020
+ export const SQLITE_FCNTL_CKPT_START: 39;
1021
+ export const SQLITE_INTEGER: 1;
1022
+ export const SQLITE_FLOAT: 2;
1023
+ export const SQLITE_TEXT: 3;
1024
+ export const SQLITE_BLOB: 4;
1025
+ export const SQLITE_NULL: 5;
1026
+ export const SQLITE_STATIC: 0;
1027
+ export const SQLITE_TRANSIENT: -1;
1028
+ export const SQLITE_UTF8: 1;
1029
+ export const SQLITE_UTF16LE: 2;
1030
+ export const SQLITE_UTF16BE: 3;
1031
+ export const SQLITE_UTF16: 4;
1032
+ export const SQLITE_INDEX_CONSTRAINT_EQ: 2;
1033
+ export const SQLITE_INDEX_CONSTRAINT_GT: 4;
1034
+ export const SQLITE_INDEX_CONSTRAINT_LE: 8;
1035
+ export const SQLITE_INDEX_CONSTRAINT_LT: 16;
1036
+ export const SQLITE_INDEX_CONSTRAINT_GE: 32;
1037
+ export const SQLITE_INDEX_CONSTRAINT_MATCH: 64;
1038
+ export const SQLITE_INDEX_CONSTRAINT_LIKE: 65;
1039
+ export const SQLITE_INDEX_CONSTRAINT_GLOB: 66;
1040
+ export const SQLITE_INDEX_CONSTRAINT_REGEXP: 67;
1041
+ export const SQLITE_INDEX_CONSTRAINT_NE: 68;
1042
+ export const SQLITE_INDEX_CONSTRAINT_ISNOT: 69;
1043
+ export const SQLITE_INDEX_CONSTRAINT_ISNOTNULL: 70;
1044
+ export const SQLITE_INDEX_CONSTRAINT_ISNULL: 71;
1045
+ export const SQLITE_INDEX_CONSTRAINT_IS: 72;
1046
+ export const SQLITE_INDEX_CONSTRAINT_FUNCTION: 150;
1047
+ export const SQLITE_INDEX_SCAN_UNIQUE: 1;
1048
+ export const SQLITE_DETERMINISTIC: 0x000000800;
1049
+ export const SQLITE_DIRECTONLY: 0x000080000;
1050
+ export const SQLITE_SUBTYPE: 0x000100000;
1051
+ export const SQLITE_INNOCUOUS: 0x000200000;
1052
+ export const SQLITE_SYNC_NORMAL: 0x00002;
1053
+ export const SQLITE_SYNC_FULL: 0x00003;
1054
+ export const SQLITE_SYNC_DATAONLY: 0x00010;
1055
+ export const SQLITE_CREATE_INDEX: 1;
1056
+ export const SQLITE_CREATE_TABLE: 2;
1057
+ export const SQLITE_CREATE_TEMP_INDEX: 3;
1058
+ export const SQLITE_CREATE_TEMP_TABLE: 4;
1059
+ export const SQLITE_CREATE_TEMP_TRIGGER: 5;
1060
+ export const SQLITE_CREATE_TEMP_VIEW: 6;
1061
+ export const SQLITE_CREATE_TRIGGER: 7;
1062
+ export const SQLITE_CREATE_VIEW: 8;
1063
+ export const SQLITE_DELETE: 9;
1064
+ export const SQLITE_DROP_INDEX: 10;
1065
+ export const SQLITE_DROP_TABLE: 11;
1066
+ export const SQLITE_DROP_TEMP_INDEX: 12;
1067
+ export const SQLITE_DROP_TEMP_TABLE: 13;
1068
+ export const SQLITE_DROP_TEMP_TRIGGER: 14;
1069
+ export const SQLITE_DROP_TEMP_VIEW: 15;
1070
+ export const SQLITE_DROP_TRIGGER: 16;
1071
+ export const SQLITE_DROP_VIEW: 17;
1072
+ export const SQLITE_INSERT: 18;
1073
+ export const SQLITE_PRAGMA: 19;
1074
+ export const SQLITE_READ: 20;
1075
+ export const SQLITE_SELECT: 21;
1076
+ export const SQLITE_TRANSACTION: 22;
1077
+ export const SQLITE_UPDATE: 23;
1078
+ export const SQLITE_ATTACH: 24;
1079
+ export const SQLITE_DETACH: 25;
1080
+ export const SQLITE_ALTER_TABLE: 26;
1081
+ export const SQLITE_REINDEX: 27;
1082
+ export const SQLITE_ANALYZE: 28;
1083
+ export const SQLITE_CREATE_VTABLE: 29;
1084
+ export const SQLITE_DROP_VTABLE: 30;
1085
+ export const SQLITE_FUNCTION: 31;
1086
+ export const SQLITE_SAVEPOINT: 32;
1087
+ export const SQLITE_COPY: 0;
1088
+ export const SQLITE_RECURSIVE: 33;
1089
+ export const SQLITE_DENY: 1;
1090
+ export const SQLITE_IGNORE: 2;
1091
+ export const SQLITE_LIMIT_LENGTH: 0;
1092
+ export const SQLITE_LIMIT_SQL_LENGTH: 1;
1093
+ export const SQLITE_LIMIT_COLUMN: 2;
1094
+ export const SQLITE_LIMIT_EXPR_DEPTH: 3;
1095
+ export const SQLITE_LIMIT_COMPOUND_SELECT: 4;
1096
+ export const SQLITE_LIMIT_VDBE_OP: 5;
1097
+ export const SQLITE_LIMIT_FUNCTION_ARG: 6;
1098
+ export const SQLITE_LIMIT_ATTACHED: 7;
1099
+ export const SQLITE_LIMIT_LIKE_PATTERN_LENGTH: 8;
1100
+ export const SQLITE_LIMIT_VARIABLE_NUMBER: 9;
1101
+ export const SQLITE_LIMIT_TRIGGER_DEPTH: 10;
1102
+ export const SQLITE_LIMIT_WORKER_THREADS: 11;
1103
+ export const SQLITE_PREPARE_PERSISTENT: 0x01;
1104
+ export const SQLITE_PREPARE_NORMALIZED: 0x02;
1105
+ export const SQLITE_PREPARE_NO_VTAB: 0x04;
1106
+ }
1107
+
1108
+ declare module 'wa-sqlite' {
1109
+ export * from 'wa-sqlite/src/sqlite-constants.js';
1110
+
1111
+ /**
1112
+ * @ignore
1113
+ * Builds a Javascript API from the Emscripten module. This API is still
1114
+ * low-level and closely corresponds to the C API exported by the module,
1115
+ * but differs in some specifics like throwing exceptions on errors.
1116
+ * @param {*} Module SQLite module
1117
+ * @returns {SQLiteAPI}
1118
+ */
1119
+ export function Factory(Module: any): SQLiteAPI;
1120
+
1121
+ export class SQLiteError extends Error {
1122
+ constructor(message: any, code: any);
1123
+ code: any;
1124
+ }
1125
+ }
1126
+
1127
+ /** @ignore */
1128
+ declare module 'wa-sqlite/dist/wa-sqlite.mjs' {
1129
+ function ModuleFactory(config?: object): Promise<any>;
1130
+ export = ModuleFactory;
1131
+ }
1132
+
1133
+ /** @ignore */
1134
+ declare module 'wa-sqlite/dist/wa-sqlite-async.mjs' {
1135
+ function ModuleFactory(config?: object): Promise<any>;
1136
+ export = ModuleFactory;
1137
+ }
1138
+
1139
+ /** @ignore */
1140
+ declare module 'wa-sqlite/src/VFS.js' {
1141
+ export * from 'wa-sqlite/src/sqlite-constants.js';
1142
+
1143
+ export class Base implements SQLiteVFS {
1144
+ name: string;
1145
+ mxPathname: number;
1146
+ _module: object;
1147
+
1148
+ constructor(name: string, module: object);
1149
+
1150
+ close(): void | Promise<void>;
1151
+ isReady(): boolean | Promise<boolean>;
1152
+ hasAsyncMethod(methodName: string): boolean;
1153
+
1154
+ xOpen(
1155
+ pVfs: number,
1156
+ zName: number,
1157
+ pFile: number,
1158
+ flags: number,
1159
+ pOutFlags: number
1160
+ ): number | Promise<number>;
1161
+ xDelete(pVfs: number, zName: number, syncDir: number): number | Promise<number>;
1162
+ xAccess(
1163
+ pVfs: number,
1164
+ zName: number,
1165
+ flags: number,
1166
+ pResOut: number
1167
+ ): number | Promise<number>;
1168
+ xFullPathname(
1169
+ pVfs: number,
1170
+ zName: number,
1171
+ nOut: number,
1172
+ zOut: number
1173
+ ): number | Promise<number>;
1174
+ xGetLastError(
1175
+ pVfs: number,
1176
+ nBuf: number,
1177
+ zBuf: number
1178
+ ): number | Promise<number>;
1179
+ xClose(pFile: number): number | Promise<number>;
1180
+ xRead(
1181
+ pFile: number,
1182
+ pData: number,
1183
+ iAmt: number,
1184
+ iOffsetLo: number,
1185
+ iOffsetHi: number
1186
+ ): number | Promise<number>;
1187
+ xWrite(
1188
+ pFile: number,
1189
+ pData: number,
1190
+ iAmt: number,
1191
+ iOffsetLo: number,
1192
+ iOffsetHi: number
1193
+ ): number | Promise<number>;
1194
+ xTruncate(pFile: number, sizeLo: number, sizeHi: number): number | Promise<number>;
1195
+ xSync(pFile: number, flags: number): number | Promise<number>;
1196
+ xFileSize(pFile: number, pSize: number): number | Promise<number>;
1197
+ xLock(pFile: number, lockType: number): number | Promise<number>;
1198
+ xUnlock(pFile: number, lockType: number): number | Promise<number>;
1199
+ xCheckReservedLock(pFile: number, pResOut: number): number | Promise<number>;
1200
+ xFileControl(pFile: number, op: number, pArg: number): number | Promise<number>;
1201
+ xSectorSize(pFile: number): number | Promise<number>;
1202
+ xDeviceCharacteristics(pFile: number): number | Promise<number>;
1203
+ }
1204
+ }
1205
+
1206
+ /** @ignore */
1207
+ declare module 'wa-sqlite/src/examples/tag.js' {
1208
+ /**
1209
+ * @ignore
1210
+ * Template tag builder. This function creates a tag with an API and
1211
+ * database from the same module, then the tag can be used like this:
1212
+ * ```
1213
+ * const sql = tag(sqlite3, db);
1214
+ * const results = await sql`
1215
+ * SELECT 1 + 1;
1216
+ * SELECT 6 * 7;
1217
+ * `;
1218
+ * ```
1219
+ * The returned Promise value contains an array of results for each
1220
+ * SQL statement that produces output. Each result is an object with
1221
+ * properties `columns` (array of names) and `rows` (array of array
1222
+ * of values).
1223
+ * @param {SQLiteAPI} sqlite3
1224
+ * @param {number} db
1225
+ * @returns {function(TemplateStringsArray, ...any): Promise<object[]>}
1226
+ */
1227
+ export function tag(sqlite3: any, db: number): (arg0: TemplateStringsArray, ...args: any[]) => Promise<object[]>;
1228
+ }