@idlebox/stripe-node-types 24.0.14-patch.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 (113) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +16 -0
  3. package/assert/strict.d.ts +5 -0
  4. package/assert.d.ts +1053 -0
  5. package/async_hooks.d.ts +621 -0
  6. package/buffer.buffer.d.ts +464 -0
  7. package/buffer.d.ts +1928 -0
  8. package/child_process.d.ts +1547 -0
  9. package/cluster.d.ts +576 -0
  10. package/compatibility/iterators.d.ts +22 -0
  11. package/console.d.ts +449 -0
  12. package/constants.d.ts +18 -0
  13. package/crypto.d.ts +4514 -0
  14. package/dgram.d.ts +597 -0
  15. package/diagnostics_channel.d.ts +576 -0
  16. package/dns/promises.d.ts +501 -0
  17. package/dns.d.ts +916 -0
  18. package/dom-events.d.ts +100 -0
  19. package/domain.d.ts +168 -0
  20. package/events.d.ts +927 -0
  21. package/fs/promises.d.ts +1278 -0
  22. package/fs.d.ts +4444 -0
  23. package/globals.d.ts +368 -0
  24. package/globals.typedarray.d.ts +23 -0
  25. package/http.d.ts +2044 -0
  26. package/http2.d.ts +2626 -0
  27. package/https.d.ts +543 -0
  28. package/index.d.ts +96 -0
  29. package/inspector.d.ts +3993 -0
  30. package/module.d.ts +866 -0
  31. package/my-shim.d.ts +57 -0
  32. package/net.d.ts +1030 -0
  33. package/os.d.ts +494 -0
  34. package/package.json +158 -0
  35. package/path.d.ts +189 -0
  36. package/perf_hooks.d.ts +968 -0
  37. package/process.d.ts +2016 -0
  38. package/punycode.d.ts +115 -0
  39. package/querystring.d.ts +150 -0
  40. package/readline/promises.d.ts +159 -0
  41. package/readline.d.ts +592 -0
  42. package/repl.d.ts +426 -0
  43. package/sea.d.ts +154 -0
  44. package/sqlite.d.ts +689 -0
  45. package/stream/consumers.d.ts +36 -0
  46. package/stream/promises.d.ts +88 -0
  47. package/stream/web.d.ts +616 -0
  48. package/stream.d.ts +1654 -0
  49. package/string_decoder.d.ts +65 -0
  50. package/test.d.ts +2216 -0
  51. package/timers/promises.d.ts +106 -0
  52. package/timers.d.ts +285 -0
  53. package/tls.d.ts +1211 -0
  54. package/trace_events.d.ts +195 -0
  55. package/ts5.1/compatibility/disposable.d.ts +13 -0
  56. package/ts5.1/index.d.ts +100 -0
  57. package/ts5.6/buffer.buffer.d.ts +461 -0
  58. package/ts5.6/compatibility/float16array.d.ts +72 -0
  59. package/ts5.6/globals.typedarray.d.ts +21 -0
  60. package/ts5.6/index.d.ts +98 -0
  61. package/ts5.7/compatibility/float16array.d.ts +73 -0
  62. package/ts5.7/index.d.ts +98 -0
  63. package/tty.d.ts +206 -0
  64. package/undici-types/LICENSE +22 -0
  65. package/undici-types/README.md +7 -0
  66. package/undici-types/agent.d.ts +32 -0
  67. package/undici-types/api.d.ts +44 -0
  68. package/undici-types/balanced-pool.d.ts +30 -0
  69. package/undici-types/cache-interceptor.d.ts +173 -0
  70. package/undici-types/cache.d.ts +37 -0
  71. package/undici-types/client.d.ts +108 -0
  72. package/undici-types/connector.d.ts +35 -0
  73. package/undici-types/content-type.d.ts +22 -0
  74. package/undici-types/cookies.d.ts +31 -0
  75. package/undici-types/diagnostics-channel.d.ts +67 -0
  76. package/undici-types/dispatcher.d.ts +282 -0
  77. package/undici-types/env-http-proxy-agent.d.ts +22 -0
  78. package/undici-types/errors.d.ts +172 -0
  79. package/undici-types/eventsource.d.ts +62 -0
  80. package/undici-types/fetch.d.ts +211 -0
  81. package/undici-types/formdata.d.ts +109 -0
  82. package/undici-types/global-dispatcher.d.ts +10 -0
  83. package/undici-types/global-origin.d.ts +8 -0
  84. package/undici-types/h2c-client.d.ts +76 -0
  85. package/undici-types/handlers.d.ts +16 -0
  86. package/undici-types/header.d.ts +161 -0
  87. package/undici-types/index.d.ts +76 -0
  88. package/undici-types/interceptors.d.ts +35 -0
  89. package/undici-types/mock-agent.d.ts +66 -0
  90. package/undici-types/mock-call-history.d.ts +112 -0
  91. package/undici-types/mock-client.d.ts +26 -0
  92. package/undici-types/mock-errors.d.ts +13 -0
  93. package/undici-types/mock-interceptor.d.ts +94 -0
  94. package/undici-types/mock-pool.d.ts +26 -0
  95. package/undici-types/package.json +55 -0
  96. package/undici-types/patch.d.ts +30 -0
  97. package/undici-types/pool-stats.d.ts +20 -0
  98. package/undici-types/pool.d.ts +40 -0
  99. package/undici-types/proxy-agent.d.ts +29 -0
  100. package/undici-types/readable.d.ts +69 -0
  101. package/undici-types/retry-agent.d.ts +9 -0
  102. package/undici-types/retry-handler.d.ts +117 -0
  103. package/undici-types/util.d.ts +19 -0
  104. package/undici-types/utility.d.ts +8 -0
  105. package/undici-types/webidl.d.ts +267 -0
  106. package/undici-types/websocket.d.ts +185 -0
  107. package/url.d.ts +1012 -0
  108. package/util.d.ts +2300 -0
  109. package/v8.d.ts +917 -0
  110. package/vm.d.ts +1034 -0
  111. package/wasi.d.ts +179 -0
  112. package/worker_threads.d.ts +773 -0
  113. package/zlib.d.ts +666 -0
package/sqlite.d.ts ADDED
@@ -0,0 +1,689 @@
1
+ /**
2
+ * The `node:sqlite` module facilitates working with SQLite databases.
3
+ * To access it:
4
+ *
5
+ * ```js
6
+ * import sqlite from 'node:sqlite';
7
+ * ```
8
+ *
9
+ * This module is only available under the `node:` scheme. The following will not
10
+ * work:
11
+ *
12
+ * ```js
13
+ * import sqlite from 'sqlite';
14
+ * ```
15
+ *
16
+ * The following example shows the basic usage of the `node:sqlite` module to open
17
+ * an in-memory database, write data to the database, and then read the data back.
18
+ *
19
+ * ```js
20
+ * import { DatabaseSync } from 'node:sqlite';
21
+ * const database = new DatabaseSync(':memory:');
22
+ *
23
+ * // Execute SQL statements from strings.
24
+ * database.exec(`
25
+ * CREATE TABLE data(
26
+ * key INTEGER PRIMARY KEY,
27
+ * value TEXT
28
+ * ) STRICT
29
+ * `);
30
+ * // Create a prepared statement to insert data into the database.
31
+ * const insert = database.prepare('INSERT INTO data (key, value) VALUES (?, ?)');
32
+ * // Execute the prepared statement with bound values.
33
+ * insert.run(1, 'hello');
34
+ * insert.run(2, 'world');
35
+ * // Create a prepared statement to read data from the database.
36
+ * const query = database.prepare('SELECT * FROM data ORDER BY key');
37
+ * // Execute the prepared statement and log the result set.
38
+ * console.log(query.all());
39
+ * // Prints: [ { key: 1, value: 'hello' }, { key: 2, value: 'world' } ]
40
+ * ```
41
+ * @since v22.5.0
42
+ * @experimental
43
+ * @see [source](https://github.com/nodejs/node/blob/v24.x/lib/sqlite.js)
44
+ */
45
+
46
+ declare module "node:sqlite" {
47
+ type SQLInputValue = null | number | bigint | string | NodeJS.ArrayBufferView;
48
+ type SQLOutputValue = null | number | bigint | string | Uint8Array;
49
+ /** @deprecated Use `SQLInputValue` or `SQLOutputValue` instead. */
50
+ type SupportedValueType = SQLOutputValue;
51
+ interface DatabaseSyncOptions {
52
+ /**
53
+ * If `true`, the database is opened by the constructor. When
54
+ * this value is `false`, the database must be opened via the `open()` method.
55
+ * @since v22.5.0
56
+ * @default true
57
+ */
58
+ open?: boolean | undefined;
59
+ /**
60
+ * If `true`, foreign key constraints
61
+ * are enabled. This is recommended but can be disabled for compatibility with
62
+ * legacy database schemas. The enforcement of foreign key constraints can be
63
+ * enabled and disabled after opening the database using
64
+ * [`PRAGMA foreign_keys`](https://www.sqlite.org/pragma.html#pragma_foreign_keys).
65
+ * @since v22.10.0
66
+ * @default true
67
+ */
68
+ enableForeignKeyConstraints?: boolean | undefined;
69
+ /**
70
+ * If `true`, SQLite will accept
71
+ * [double-quoted string literals](https://www.sqlite.org/quirks.html#dblquote).
72
+ * This is not recommended but can be
73
+ * enabled for compatibility with legacy database schemas.
74
+ * @since v22.10.0
75
+ * @default false
76
+ */
77
+ enableDoubleQuotedStringLiterals?: boolean | undefined;
78
+ /**
79
+ * If `true`, the database is opened in read-only mode.
80
+ * If the database does not exist, opening it will fail.
81
+ * @since v22.12.0
82
+ * @default false
83
+ */
84
+ readOnly?: boolean | undefined;
85
+ /**
86
+ * If `true`, the `loadExtension` SQL function
87
+ * and the `loadExtension()` method are enabled.
88
+ * You can call `enableLoadExtension(false)` later to disable this feature.
89
+ * @since v22.13.0
90
+ * @default false
91
+ */
92
+ allowExtension?: boolean | undefined;
93
+ /**
94
+ * The [busy timeout](https://sqlite.org/c3ref/busy_timeout.html) in milliseconds. This is the maximum amount of
95
+ * time that SQLite will wait for a database lock to be released before
96
+ * returning an error.
97
+ * @since v24.0.0
98
+ * @default 0
99
+ */
100
+ timeout?: number | undefined;
101
+ }
102
+ interface CreateSessionOptions {
103
+ /**
104
+ * A specific table to track changes for. By default, changes to all tables are tracked.
105
+ * @since v22.12.0
106
+ */
107
+ table?: string | undefined;
108
+ /**
109
+ * Name of the database to track. This is useful when multiple databases have been added using
110
+ * [`ATTACH DATABASE`](https://www.sqlite.org/lang_attach.html).
111
+ * @since v22.12.0
112
+ * @default 'main'
113
+ */
114
+ db?: string | undefined;
115
+ }
116
+ interface ApplyChangesetOptions {
117
+ /**
118
+ * Skip changes that, when targeted table name is supplied to this function, return a truthy value.
119
+ * By default, all changes are attempted.
120
+ * @since v22.12.0
121
+ */
122
+ filter?: ((tableName: string) => boolean) | undefined;
123
+ /**
124
+ * A function that determines how to handle conflicts. The function receives one argument,
125
+ * which can be one of the following values:
126
+ *
127
+ * * `SQLITE_CHANGESET_DATA`: A `DELETE` or `UPDATE` change does not contain the expected "before" values.
128
+ * * `SQLITE_CHANGESET_NOTFOUND`: A row matching the primary key of the `DELETE` or `UPDATE` change does not exist.
129
+ * * `SQLITE_CHANGESET_CONFLICT`: An `INSERT` change results in a duplicate primary key.
130
+ * * `SQLITE_CHANGESET_FOREIGN_KEY`: Applying a change would result in a foreign key violation.
131
+ * * `SQLITE_CHANGESET_CONSTRAINT`: Applying a change results in a `UNIQUE`, `CHECK`, or `NOT NULL` constraint
132
+ * violation.
133
+ *
134
+ * The function should return one of the following values:
135
+ *
136
+ * * `SQLITE_CHANGESET_OMIT`: Omit conflicting changes.
137
+ * * `SQLITE_CHANGESET_REPLACE`: Replace existing values with conflicting changes (only valid with
138
+ `SQLITE_CHANGESET_DATA` or `SQLITE_CHANGESET_CONFLICT` conflicts).
139
+ * * `SQLITE_CHANGESET_ABORT`: Abort on conflict and roll back the database.
140
+ *
141
+ * When an error is thrown in the conflict handler or when any other value is returned from the handler,
142
+ * applying the changeset is aborted and the database is rolled back.
143
+ *
144
+ * **Default**: A function that returns `SQLITE_CHANGESET_ABORT`.
145
+ * @since v22.12.0
146
+ */
147
+ onConflict?: ((conflictType: number) => number) | undefined;
148
+ }
149
+ interface FunctionOptions {
150
+ /**
151
+ * If `true`, the [`SQLITE_DETERMINISTIC`](https://www.sqlite.org/c3ref/c_deterministic.html) flag is
152
+ * set on the created function.
153
+ * @default false
154
+ */
155
+ deterministic?: boolean | undefined;
156
+ /**
157
+ * If `true`, the [`SQLITE_DIRECTONLY`](https://www.sqlite.org/c3ref/c_directonly.html) flag is set on
158
+ * the created function.
159
+ * @default false
160
+ */
161
+ directOnly?: boolean | undefined;
162
+ /**
163
+ * If `true`, integer arguments to `function`
164
+ * are converted to `BigInt`s. If `false`, integer arguments are passed as
165
+ * JavaScript numbers.
166
+ * @default false
167
+ */
168
+ useBigIntArguments?: boolean | undefined;
169
+ /**
170
+ * If `true`, `function` may be invoked with any number of
171
+ * arguments (between zero and
172
+ * [`SQLITE_MAX_FUNCTION_ARG`](https://www.sqlite.org/limits.html#max_function_arg)). If `false`,
173
+ * `function` must be invoked with exactly `function.length` arguments.
174
+ * @default false
175
+ */
176
+ varargs?: boolean | undefined;
177
+ }
178
+ interface AggregateOptions<T extends SQLInputValue = SQLInputValue> extends FunctionOptions {
179
+ /**
180
+ * The identity value for the aggregation function. This value is used when the aggregation
181
+ * function is initialized. When a `Function` is passed the identity will be its return value.
182
+ */
183
+ start: T | (() => T);
184
+ /**
185
+ * The function to call for each row in the aggregation. The
186
+ * function receives the current state and the row value. The return value of
187
+ * this function should be the new state.
188
+ */
189
+ step: (accumulator: T, ...args: SQLOutputValue[]) => T;
190
+ /**
191
+ * The function to call to get the result of the
192
+ * aggregation. The function receives the final state and should return the
193
+ * result of the aggregation.
194
+ */
195
+ result?: ((accumulator: T) => SQLInputValue) | undefined;
196
+ /**
197
+ * When this function is provided, the `aggregate` method will work as a window function.
198
+ * The function receives the current state and the dropped row value. The return value of this function should be the
199
+ * new state.
200
+ */
201
+ inverse?: ((accumulator: T, ...args: SQLOutputValue[]) => T) | undefined;
202
+ }
203
+ /**
204
+ * This class represents a single [connection](https://www.sqlite.org/c3ref/sqlite3.html) to a SQLite database. All APIs
205
+ * exposed by this class execute synchronously.
206
+ * @since v22.5.0
207
+ */
208
+ class DatabaseSync implements Disposable {
209
+ /**
210
+ * Constructs a new `DatabaseSync` instance.
211
+ * @param path The path of the database.
212
+ * A SQLite database can be stored in a file or completely [in memory](https://www.sqlite.org/inmemorydb.html).
213
+ * To use a file-backed database, the path should be a file path.
214
+ * To use an in-memory database, the path should be the special name `':memory:'`.
215
+ * @param options Configuration options for the database connection.
216
+ */
217
+ constructor(path: string | Buffer | URL, options?: DatabaseSyncOptions);
218
+ /**
219
+ * Registers a new aggregate function with the SQLite database. This method is a wrapper around
220
+ * [`sqlite3_create_window_function()`](https://www.sqlite.org/c3ref/create_function.html).
221
+ *
222
+ * When used as a window function, the `result` function will be called multiple times.
223
+ *
224
+ * ```js
225
+ * import { DatabaseSync } from 'node:sqlite';
226
+ *
227
+ * const db = new DatabaseSync(':memory:');
228
+ * db.exec(`
229
+ * CREATE TABLE t3(x, y);
230
+ * INSERT INTO t3 VALUES ('a', 4),
231
+ * ('b', 5),
232
+ * ('c', 3),
233
+ * ('d', 8),
234
+ * ('e', 1);
235
+ * `);
236
+ *
237
+ * db.aggregate('sumint', {
238
+ * start: 0,
239
+ * step: (acc, value) => acc + value,
240
+ * });
241
+ *
242
+ * db.prepare('SELECT sumint(y) as total FROM t3').get(); // { total: 21 }
243
+ * ```
244
+ * @since v24.0.0
245
+ * @param name The name of the SQLite function to create.
246
+ * @param options Function configuration settings.
247
+ */
248
+ aggregate(name: string, options: AggregateOptions): void;
249
+ aggregate<T extends SQLInputValue>(name: string, options: AggregateOptions<T>): void;
250
+ /**
251
+ * Closes the database connection. An exception is thrown if the database is not
252
+ * open. This method is a wrapper around [`sqlite3_close_v2()`](https://www.sqlite.org/c3ref/close.html).
253
+ * @since v22.5.0
254
+ */
255
+ close(): void;
256
+ /**
257
+ * Loads a shared library into the database connection. This method is a wrapper
258
+ * around [`sqlite3_load_extension()`](https://www.sqlite.org/c3ref/load_extension.html). It is required to enable the
259
+ * `allowExtension` option when constructing the `DatabaseSync` instance.
260
+ * @since v22.13.0
261
+ * @param path The path to the shared library to load.
262
+ */
263
+ loadExtension(path: string): void;
264
+ /**
265
+ * Enables or disables the `loadExtension` SQL function, and the `loadExtension()`
266
+ * method. When `allowExtension` is `false` when constructing, you cannot enable
267
+ * loading extensions for security reasons.
268
+ * @since v22.13.0
269
+ * @param allow Whether to allow loading extensions.
270
+ */
271
+ enableLoadExtension(allow: boolean): void;
272
+ /**
273
+ * This method is a wrapper around [`sqlite3_db_filename()`](https://sqlite.org/c3ref/db_filename.html)
274
+ * @since v24.0.0
275
+ * @param dbName Name of the database. This can be `'main'` (the default primary database) or any other
276
+ * database that has been added with [`ATTACH DATABASE`](https://www.sqlite.org/lang_attach.html) **Default:** `'main'`.
277
+ * @returns The location of the database file. When using an in-memory database,
278
+ * this method returns null.
279
+ */
280
+ location(dbName?: string): string | null;
281
+ /**
282
+ * This method allows one or more SQL statements to be executed without returning
283
+ * any results. This method is useful when executing SQL statements read from a
284
+ * file. This method is a wrapper around [`sqlite3_exec()`](https://www.sqlite.org/c3ref/exec.html).
285
+ * @since v22.5.0
286
+ * @param sql A SQL string to execute.
287
+ */
288
+ exec(sql: string): void;
289
+ /**
290
+ * This method is used to create SQLite user-defined functions. This method is a
291
+ * wrapper around [`sqlite3_create_function_v2()`](https://www.sqlite.org/c3ref/create_function.html).
292
+ * @since v22.13.0
293
+ * @param name The name of the SQLite function to create.
294
+ * @param options Optional configuration settings for the function.
295
+ * @param func The JavaScript function to call when the SQLite
296
+ * function is invoked. The return value of this function should be a valid
297
+ * SQLite data type: see
298
+ * [Type conversion between JavaScript and SQLite](https://nodejs.org/docs/latest-v24.x/api/sqlite.html#type-conversion-between-javascript-and-sqlite).
299
+ * The result defaults to `NULL` if the return value is `undefined`.
300
+ */
301
+ function(
302
+ name: string,
303
+ options: FunctionOptions,
304
+ func: (...args: SQLOutputValue[]) => SQLInputValue,
305
+ ): void;
306
+ function(name: string, func: (...args: SQLOutputValue[]) => SQLInputValue): void;
307
+ /**
308
+ * Whether the database is currently open or not.
309
+ * @since v22.15.0
310
+ */
311
+ readonly isOpen: boolean;
312
+ /**
313
+ * Whether the database is currently within a transaction. This method
314
+ * is a wrapper around [`sqlite3_get_autocommit()`](https://sqlite.org/c3ref/get_autocommit.html).
315
+ * @since v24.0.0
316
+ */
317
+ readonly isTransaction: boolean;
318
+ /**
319
+ * Opens the database specified in the `path` argument of the `DatabaseSync`constructor. This method should only be used when the database is not opened via
320
+ * the constructor. An exception is thrown if the database is already open.
321
+ * @since v22.5.0
322
+ */
323
+ open(): void;
324
+ /**
325
+ * Compiles a SQL statement into a [prepared statement](https://www.sqlite.org/c3ref/stmt.html). This method is a wrapper
326
+ * around [`sqlite3_prepare_v2()`](https://www.sqlite.org/c3ref/prepare.html).
327
+ * @since v22.5.0
328
+ * @param sql A SQL string to compile to a prepared statement.
329
+ * @return The prepared statement.
330
+ */
331
+ prepare(sql: string): StatementSync;
332
+ /**
333
+ * Creates and attaches a session to the database. This method is a wrapper around
334
+ * [`sqlite3session_create()`](https://www.sqlite.org/session/sqlite3session_create.html) and
335
+ * [`sqlite3session_attach()`](https://www.sqlite.org/session/sqlite3session_attach.html).
336
+ * @param options The configuration options for the session.
337
+ * @returns A session handle.
338
+ * @since v22.12.0
339
+ */
340
+ createSession(options?: CreateSessionOptions): Session;
341
+ /**
342
+ * An exception is thrown if the database is not
343
+ * open. This method is a wrapper around
344
+ * [`sqlite3changeset_apply()`](https://www.sqlite.org/session/sqlite3changeset_apply.html).
345
+ *
346
+ * ```js
347
+ * const sourceDb = new DatabaseSync(':memory:');
348
+ * const targetDb = new DatabaseSync(':memory:');
349
+ *
350
+ * sourceDb.exec('CREATE TABLE data(key INTEGER PRIMARY KEY, value TEXT)');
351
+ * targetDb.exec('CREATE TABLE data(key INTEGER PRIMARY KEY, value TEXT)');
352
+ *
353
+ * const session = sourceDb.createSession();
354
+ *
355
+ * const insert = sourceDb.prepare('INSERT INTO data (key, value) VALUES (?, ?)');
356
+ * insert.run(1, 'hello');
357
+ * insert.run(2, 'world');
358
+ *
359
+ * const changeset = session.changeset();
360
+ * targetDb.applyChangeset(changeset);
361
+ * // Now that the changeset has been applied, targetDb contains the same data as sourceDb.
362
+ * ```
363
+ * @param changeset A binary changeset or patchset.
364
+ * @param options The configuration options for how the changes will be applied.
365
+ * @returns Whether the changeset was applied successfully without being aborted.
366
+ * @since v22.12.0
367
+ */
368
+ applyChangeset(changeset: Uint8Array, options?: ApplyChangesetOptions): boolean;
369
+ /**
370
+ * Closes the database connection. If the database connection is already closed
371
+ * then this is a no-op.
372
+ * @since v22.15.0
373
+ * @experimental
374
+ */
375
+ [Symbol.dispose](): void;
376
+ }
377
+ /**
378
+ * @since v22.12.0
379
+ */
380
+ interface Session {
381
+ /**
382
+ * Retrieves a changeset containing all changes since the changeset was created. Can be called multiple times.
383
+ * An exception is thrown if the database or the session is not open. This method is a wrapper around
384
+ * [`sqlite3session_changeset()`](https://www.sqlite.org/session/sqlite3session_changeset.html).
385
+ * @returns Binary changeset that can be applied to other databases.
386
+ * @since v22.12.0
387
+ */
388
+ changeset(): Uint8Array;
389
+ /**
390
+ * Similar to the method above, but generates a more compact patchset. See
391
+ * [Changesets and Patchsets](https://www.sqlite.org/sessionintro.html#changesets_and_patchsets)
392
+ * in the documentation of SQLite. An exception is thrown if the database or the session is not open. This method is a
393
+ * wrapper around
394
+ * [`sqlite3session_patchset()`](https://www.sqlite.org/session/sqlite3session_patchset.html).
395
+ * @returns Binary patchset that can be applied to other databases.
396
+ * @since v22.12.0
397
+ */
398
+ patchset(): Uint8Array;
399
+ /**
400
+ * Closes the session. An exception is thrown if the database or the session is not open. This method is a
401
+ * wrapper around
402
+ * [`sqlite3session_delete()`](https://www.sqlite.org/session/sqlite3session_delete.html).
403
+ */
404
+ close(): void;
405
+ }
406
+ interface StatementColumnMetadata {
407
+ /**
408
+ * The unaliased name of the column in the origin
409
+ * table, or `null` if the column is the result of an expression or subquery.
410
+ * This property is the result of [`sqlite3_column_origin_name()`](https://www.sqlite.org/c3ref/column_database_name.html).
411
+ */
412
+ column: string | null;
413
+ /**
414
+ * The unaliased name of the origin database, or
415
+ * `null` if the column is the result of an expression or subquery. This
416
+ * property is the result of [`sqlite3_column_database_name()`](https://www.sqlite.org/c3ref/column_database_name.html).
417
+ */
418
+ database: string | null;
419
+ /**
420
+ * The name assigned to the column in the result set of a
421
+ * `SELECT` statement. This property is the result of
422
+ * [`sqlite3_column_name()`](https://www.sqlite.org/c3ref/column_name.html).
423
+ */
424
+ name: string;
425
+ /**
426
+ * The unaliased name of the origin table, or `null` if
427
+ * the column is the result of an expression or subquery. This property is the
428
+ * result of [`sqlite3_column_table_name()`](https://www.sqlite.org/c3ref/column_database_name.html).
429
+ */
430
+ table: string | null;
431
+ /**
432
+ * The declared data type of the column, or `null` if the
433
+ * column is the result of an expression or subquery. This property is the
434
+ * result of [`sqlite3_column_decltype()`](https://www.sqlite.org/c3ref/column_decltype.html).
435
+ */
436
+ type: string | null;
437
+ }
438
+ interface StatementResultingChanges {
439
+ /**
440
+ * The number of rows modified, inserted, or deleted by the most recently completed `INSERT`, `UPDATE`, or `DELETE` statement.
441
+ * This field is either a number or a `BigInt` depending on the prepared statement's configuration.
442
+ * This property is the result of [`sqlite3_changes64()`](https://www.sqlite.org/c3ref/changes.html).
443
+ */
444
+ changes: number | bigint;
445
+ /**
446
+ * The most recently inserted rowid.
447
+ * This field is either a number or a `BigInt` depending on the prepared statement's configuration.
448
+ * This property is the result of [`sqlite3_last_insert_rowid()`](https://www.sqlite.org/c3ref/last_insert_rowid.html).
449
+ */
450
+ lastInsertRowid: number | bigint;
451
+ }
452
+ /**
453
+ * This class represents a single [prepared statement](https://www.sqlite.org/c3ref/stmt.html). This class cannot be
454
+ * instantiated via its constructor. Instead, instances are created via the`database.prepare()` method. All APIs exposed by this class execute
455
+ * synchronously.
456
+ *
457
+ * A prepared statement is an efficient binary representation of the SQL used to
458
+ * create it. Prepared statements are parameterizable, and can be invoked multiple
459
+ * times with different bound values. Parameters also offer protection against [SQL injection](https://en.wikipedia.org/wiki/SQL_injection) attacks. For these reasons, prepared statements are
460
+ * preferred
461
+ * over hand-crafted SQL strings when handling user input.
462
+ * @since v22.5.0
463
+ */
464
+ class StatementSync {
465
+ private constructor();
466
+ /**
467
+ * This method executes a prepared statement and returns all results as an array of
468
+ * objects. If the prepared statement does not return any results, this method
469
+ * returns an empty array. The prepared statement [parameters are bound](https://www.sqlite.org/c3ref/bind_blob.html) using
470
+ * the values in `namedParameters` and `anonymousParameters`.
471
+ * @since v22.5.0
472
+ * @param namedParameters An optional object used to bind named parameters. The keys of this object are used to configure the mapping.
473
+ * @param anonymousParameters Zero or more values to bind to anonymous parameters.
474
+ * @return An array of objects. Each object corresponds to a row returned by executing the prepared statement. The keys and values of each object correspond to the column names and values of
475
+ * the row.
476
+ */
477
+ all(...anonymousParameters: SQLInputValue[]): Record<string, SQLOutputValue>[];
478
+ all(
479
+ namedParameters: Record<string, SQLInputValue>,
480
+ ...anonymousParameters: SQLInputValue[]
481
+ ): Record<string, SQLOutputValue>[];
482
+ /**
483
+ * This method is used to retrieve information about the columns returned by the
484
+ * prepared statement.
485
+ * @since v23.11.0
486
+ * @returns An array of objects. Each object corresponds to a column
487
+ * in the prepared statement, and contains the following properties:
488
+ */
489
+ columns(): StatementColumnMetadata[];
490
+ /**
491
+ * The source SQL text of the prepared statement with parameter
492
+ * placeholders replaced by the values that were used during the most recent
493
+ * execution of this prepared statement. This property is a wrapper around
494
+ * [`sqlite3_expanded_sql()`](https://www.sqlite.org/c3ref/expanded_sql.html).
495
+ * @since v22.5.0
496
+ */
497
+ readonly expandedSQL: string;
498
+ /**
499
+ * This method executes a prepared statement and returns the first result as an
500
+ * object. If the prepared statement does not return any results, this method
501
+ * returns `undefined`. The prepared statement [parameters are bound](https://www.sqlite.org/c3ref/bind_blob.html) using the
502
+ * values in `namedParameters` and `anonymousParameters`.
503
+ * @since v22.5.0
504
+ * @param namedParameters An optional object used to bind named parameters. The keys of this object are used to configure the mapping.
505
+ * @param anonymousParameters Zero or more values to bind to anonymous parameters.
506
+ * @return An object corresponding to the first row returned by executing the prepared statement. The keys and values of the object correspond to the column names and values of the row. If no
507
+ * rows were returned from the database then this method returns `undefined`.
508
+ */
509
+ get(...anonymousParameters: SQLInputValue[]): Record<string, SQLOutputValue> | undefined;
510
+ get(
511
+ namedParameters: Record<string, SQLInputValue>,
512
+ ...anonymousParameters: SQLInputValue[]
513
+ ): Record<string, SQLOutputValue> | undefined;
514
+ /**
515
+ * This method executes a prepared statement and returns an iterator of
516
+ * objects. If the prepared statement does not return any results, this method
517
+ * returns an empty iterator. The prepared statement [parameters are bound](https://www.sqlite.org/c3ref/bind_blob.html) using
518
+ * the values in `namedParameters` and `anonymousParameters`.
519
+ * @since v22.13.0
520
+ * @param namedParameters An optional object used to bind named parameters.
521
+ * The keys of this object are used to configure the mapping.
522
+ * @param anonymousParameters Zero or more values to bind to anonymous parameters.
523
+ * @returns An iterable iterator of objects. Each object corresponds to a row
524
+ * returned by executing the prepared statement. The keys and values of each
525
+ * object correspond to the column names and values of the row.
526
+ */
527
+ iterate(...anonymousParameters: SQLInputValue[]): NodeJS.Iterator<Record<string, SQLOutputValue>>;
528
+ iterate(
529
+ namedParameters: Record<string, SQLInputValue>,
530
+ ...anonymousParameters: SQLInputValue[]
531
+ ): NodeJS.Iterator<Record<string, SQLOutputValue>>;
532
+ /**
533
+ * This method executes a prepared statement and returns an object summarizing the
534
+ * resulting changes. The prepared statement [parameters are bound](https://www.sqlite.org/c3ref/bind_blob.html) using the
535
+ * values in `namedParameters` and `anonymousParameters`.
536
+ * @since v22.5.0
537
+ * @param namedParameters An optional object used to bind named parameters. The keys of this object are used to configure the mapping.
538
+ * @param anonymousParameters Zero or more values to bind to anonymous parameters.
539
+ */
540
+ run(...anonymousParameters: SQLInputValue[]): StatementResultingChanges;
541
+ run(
542
+ namedParameters: Record<string, SQLInputValue>,
543
+ ...anonymousParameters: SQLInputValue[]
544
+ ): StatementResultingChanges;
545
+ /**
546
+ * The names of SQLite parameters begin with a prefix character. By default,`node:sqlite` requires that this prefix character is present when binding
547
+ * parameters. However, with the exception of dollar sign character, these
548
+ * prefix characters also require extra quoting when used in object keys.
549
+ *
550
+ * To improve ergonomics, this method can be used to also allow bare named
551
+ * parameters, which do not require the prefix character in JavaScript code. There
552
+ * are several caveats to be aware of when enabling bare named parameters:
553
+ *
554
+ * * The prefix character is still required in SQL.
555
+ * * The prefix character is still allowed in JavaScript. In fact, prefixed names
556
+ * will have slightly better binding performance.
557
+ * * Using ambiguous named parameters, such as `$k` and `@k`, in the same prepared
558
+ * statement will result in an exception as it cannot be determined how to bind
559
+ * a bare name.
560
+ * @since v22.5.0
561
+ * @param enabled Enables or disables support for binding named parameters without the prefix character.
562
+ */
563
+ setAllowBareNamedParameters(enabled: boolean): void;
564
+ /**
565
+ * By default, if an unknown name is encountered while binding parameters, an
566
+ * exception is thrown. This method allows unknown named parameters to be ignored.
567
+ * @since v22.15.0
568
+ * @param enabled Enables or disables support for unknown named parameters.
569
+ */
570
+ setAllowUnknownNamedParameters(enabled: boolean): void;
571
+ /**
572
+ * When reading from the database, SQLite `INTEGER`s are mapped to JavaScript
573
+ * numbers by default. However, SQLite `INTEGER`s can store values larger than
574
+ * JavaScript numbers are capable of representing. In such cases, this method can
575
+ * be used to read `INTEGER` data using JavaScript `BigInt`s. This method has no
576
+ * impact on database write operations where numbers and `BigInt`s are both
577
+ * supported at all times.
578
+ * @since v22.5.0
579
+ * @param enabled Enables or disables the use of `BigInt`s when reading `INTEGER` fields from the database.
580
+ */
581
+ setReadBigInts(enabled: boolean): void;
582
+ /**
583
+ * The source SQL text of the prepared statement. This property is a
584
+ * wrapper around [`sqlite3_sql()`](https://www.sqlite.org/c3ref/expanded_sql.html).
585
+ * @since v22.5.0
586
+ */
587
+ readonly sourceSQL: string;
588
+ }
589
+ interface BackupOptions {
590
+ /**
591
+ * Name of the source database. This can be `'main'` (the default primary database) or any other
592
+ * database that have been added with [`ATTACH DATABASE`](https://www.sqlite.org/lang_attach.html)
593
+ * @default 'main'
594
+ */
595
+ source?: string | undefined;
596
+ /**
597
+ * Name of the target database. This can be `'main'` (the default primary database) or any other
598
+ * database that have been added with [`ATTACH DATABASE`](https://www.sqlite.org/lang_attach.html)
599
+ * @default 'main'
600
+ */
601
+ target?: string | undefined;
602
+ /**
603
+ * Number of pages to be transmitted in each batch of the backup.
604
+ * @default 100
605
+ */
606
+ rate?: number | undefined;
607
+ /**
608
+ * Callback function that will be called with the number of pages copied and the total number of
609
+ * pages.
610
+ */
611
+ progress?: ((progressInfo: BackupProgressInfo) => void) | undefined;
612
+ }
613
+ interface BackupProgressInfo {
614
+ totalPages: number;
615
+ remainingPages: number;
616
+ }
617
+ /**
618
+ * This method makes a database backup. This method abstracts the
619
+ * [`sqlite3_backup_init()`](https://www.sqlite.org/c3ref/backup_finish.html#sqlite3backupinit),
620
+ * [`sqlite3_backup_step()`](https://www.sqlite.org/c3ref/backup_finish.html#sqlite3backupstep)
621
+ * and [`sqlite3_backup_finish()`](https://www.sqlite.org/c3ref/backup_finish.html#sqlite3backupfinish) functions.
622
+ *
623
+ * The backed-up database can be used normally during the backup process. Mutations coming from the same connection - same
624
+ * `DatabaseSync` - object will be reflected in the backup right away. However, mutations from other connections will cause
625
+ * the backup process to restart.
626
+ *
627
+ * ```js
628
+ * import { backup, DatabaseSync } from 'node:sqlite';
629
+ *
630
+ * const sourceDb = new DatabaseSync('source.db');
631
+ * const totalPagesTransferred = await backup(sourceDb, 'backup.db', {
632
+ * rate: 1, // Copy one page at a time.
633
+ * progress: ({ totalPages, remainingPages }) => {
634
+ * console.log('Backup in progress', { totalPages, remainingPages });
635
+ * },
636
+ * });
637
+ *
638
+ * console.log('Backup completed', totalPagesTransferred);
639
+ * ```
640
+ * @since v23.8.0
641
+ * @param sourceDb The database to backup. The source database must be open.
642
+ * @param path The path where the backup will be created. If the file already exists,
643
+ * the contents will be overwritten.
644
+ * @param options Optional configuration for the backup. The
645
+ * following properties are supported:
646
+ * @returns A promise that resolves when the backup is completed and rejects if an error occurs.
647
+ */
648
+ function backup(sourceDb: DatabaseSync, path: string | Buffer | URL, options?: BackupOptions): Promise<void>;
649
+ /**
650
+ * @since v22.13.0
651
+ */
652
+ namespace constants {
653
+ /**
654
+ * The conflict handler is invoked with this constant when processing a DELETE or UPDATE change if a row with the required PRIMARY KEY fields is present in the database, but one or more other (non primary-key) fields modified by the update do not contain the expected "before" values.
655
+ * @since v22.14.0
656
+ */
657
+ const SQLITE_CHANGESET_DATA: number;
658
+ /**
659
+ * The conflict handler is invoked with this constant when processing a DELETE or UPDATE change if a row with the required PRIMARY KEY fields is not present in the database.
660
+ * @since v22.14.0
661
+ */
662
+ const SQLITE_CHANGESET_NOTFOUND: number;
663
+ /**
664
+ * This constant is passed to the conflict handler while processing an INSERT change if the operation would result in duplicate primary key values.
665
+ * @since v22.14.0
666
+ */
667
+ const SQLITE_CHANGESET_CONFLICT: number;
668
+ /**
669
+ * If foreign key handling is enabled, and applying a changeset leaves the database in a state containing foreign key violations, the conflict handler is invoked with this constant exactly once before the changeset is committed. If the conflict handler returns `SQLITE_CHANGESET_OMIT`, the changes, including those that caused the foreign key constraint violation, are committed. Or, if it returns `SQLITE_CHANGESET_ABORT`, the changeset is rolled back.
670
+ * @since v22.14.0
671
+ */
672
+ const SQLITE_CHANGESET_FOREIGN_KEY: number;
673
+ /**
674
+ * Conflicting changes are omitted.
675
+ * @since v22.12.0
676
+ */
677
+ const SQLITE_CHANGESET_OMIT: number;
678
+ /**
679
+ * Conflicting changes replace existing values. Note that this value can only be returned when the type of conflict is either `SQLITE_CHANGESET_DATA` or `SQLITE_CHANGESET_CONFLICT`.
680
+ * @since v22.12.0
681
+ */
682
+ const SQLITE_CHANGESET_REPLACE: number;
683
+ /**
684
+ * Abort when a change encounters a conflict and roll back database.
685
+ * @since v22.12.0
686
+ */
687
+ const SQLITE_CHANGESET_ABORT: number;
688
+ }
689
+ }