@types/node 22.15.33 → 22.19.2

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 (79) hide show
  1. node v22.19/README.md +15 -0
  2. node v22.19/assert/strict.d.ts +111 -0
  3. {node v22.15 → node v22.19}/assert.d.ts +119 -95
  4. {node v22.15 → node v22.19}/buffer.buffer.d.ts +9 -0
  5. {node v22.15 → node v22.19}/buffer.d.ts +14 -6
  6. {node v22.15 → node v22.19}/child_process.d.ts +89 -162
  7. {node v22.15 → node v22.19}/cluster.d.ts +4 -5
  8. {node v22.15 → node v22.19}/crypto.d.ts +203 -167
  9. {node v22.15 → node v22.19}/dgram.d.ts +9 -8
  10. {node v22.15 → node v22.19}/dns/promises.d.ts +11 -10
  11. {node v22.15 → node v22.19}/dns.d.ts +24 -20
  12. {node v22.15 → node v22.19}/events.d.ts +80 -35
  13. {node v22.15 → node v22.19}/fs/promises.d.ts +78 -56
  14. {node v22.15 → node v22.19}/fs.d.ts +153 -129
  15. node v22.19/globals.d.ts +172 -0
  16. node v22.19/globals.typedarray.d.ts +38 -0
  17. {node v22.15 → node v22.19}/http.d.ts +140 -35
  18. {node v22.15 → node v22.19}/http2.d.ts +45 -26
  19. {node v22.15 → node v22.19}/https.d.ts +96 -62
  20. {node v22.15 → node v22.19}/index.d.ts +7 -2
  21. node v22.19/inspector.d.ts +253 -0
  22. node v22.15/inspector.d.ts → node v22.19/inspector.generated.d.ts +880 -830
  23. {node v22.15 → node v22.19}/module.d.ts +70 -13
  24. {node v22.15 → node v22.19}/net.d.ts +33 -11
  25. {node v22.15 → node v22.19}/os.d.ts +14 -3
  26. {node v22.15 → node v22.19}/package.json +3 -83
  27. {node v22.15 → node v22.19}/path.d.ts +1 -1
  28. {node v22.15 → node v22.19}/perf_hooks.d.ts +6 -8
  29. {node v22.15 → node v22.19}/process.d.ts +34 -27
  30. {node v22.15 → node v22.19}/readline/promises.d.ts +1 -2
  31. {node v22.15 → node v22.19}/repl.d.ts +3 -5
  32. {node v22.15 → node v22.19}/sqlite.d.ts +219 -6
  33. {node v22.15 → node v22.19}/stream/consumers.d.ts +2 -2
  34. {node v22.15 → node v22.19}/stream/web.d.ts +8 -0
  35. {node v22.15 → node v22.19}/stream.d.ts +29 -33
  36. {node v22.15 → node v22.19}/string_decoder.d.ts +2 -2
  37. node v22.19/test.d.ts +2162 -0
  38. {node v22.15 → node v22.19}/tls.d.ts +122 -66
  39. {node v22.15 → node v22.19}/ts5.6/buffer.buffer.d.ts +10 -2
  40. node v22.19/ts5.6/globals.typedarray.d.ts +34 -0
  41. {node v22.15 → node v22.19}/ts5.6/index.d.ts +7 -2
  42. {node v22.15 → node v22.19}/url.d.ts +21 -9
  43. {node v22.15 → node v22.19}/util.d.ts +32 -10
  44. {node v22.15 → node v22.19}/v8.d.ts +33 -35
  45. {node v22.15 → node v22.19}/vm.d.ts +21 -50
  46. {node v22.15 → node v22.19}/wasi.d.ts +1 -1
  47. node v22.19/web-globals/abortcontroller.d.ts +34 -0
  48. node v22.19/web-globals/domexception.d.ts +68 -0
  49. node v22.15/dom-events.d.ts → node v22.19/web-globals/events.d.ts +49 -51
  50. node v22.19/web-globals/fetch.d.ts +46 -0
  51. node v22.19/web-globals/navigator.d.ts +22 -0
  52. node v22.19/web-globals/storage.d.ts +24 -0
  53. {node v22.15 → node v22.19}/worker_threads.d.ts +93 -67
  54. {node v22.15 → node v22.19}/zlib.d.ts +39 -26
  55. node v22.15/README.md +0 -15
  56. node v22.15/assert/strict.d.ts +0 -8
  57. node v22.15/globals.d.ts +0 -364
  58. node v22.15/globals.typedarray.d.ts +0 -21
  59. node v22.15/test.d.ts +0 -2278
  60. node v22.15/ts5.6/globals.typedarray.d.ts +0 -19
  61. {node v22.15 → node v22.19}/LICENSE +0 -0
  62. {node v22.15 → node v22.19}/async_hooks.d.ts +1 -1
  63. {node v22.15 → node v22.19}/compatibility/disposable.d.ts +0 -0
  64. {node v22.15 → node v22.19}/compatibility/index.d.ts +0 -0
  65. {node v22.15 → node v22.19}/compatibility/indexable.d.ts +0 -0
  66. {node v22.15 → node v22.19}/compatibility/iterators.d.ts +0 -0
  67. {node v22.15 → node v22.19}/console.d.ts +0 -0
  68. {node v22.15 → node v22.19}/constants.d.ts +0 -0
  69. {node v22.15 → node v22.19}/diagnostics_channel.d.ts +0 -0
  70. {node v22.15 → node v22.19}/domain.d.ts +0 -0
  71. {node v22.15 → node v22.19}/punycode.d.ts +0 -0
  72. {node v22.15 → node v22.19}/querystring.d.ts +0 -0
  73. {node v22.15 → node v22.19}/readline.d.ts +0 -0
  74. {node v22.15 → node v22.19}/sea.d.ts +0 -0
  75. {node v22.15 → node v22.19}/stream/promises.d.ts +0 -0
  76. {node v22.15 → node v22.19}/timers/promises.d.ts +0 -0
  77. {node v22.15 → node v22.19}/timers.d.ts +0 -0
  78. {node v22.15 → node v22.19}/trace_events.d.ts +0 -0
  79. {node v22.15 → node v22.19}/tty.d.ts +0 -0
@@ -1,4 +1,6 @@
1
1
  declare module "process" {
2
+ import { Control, MessageOptions, SendHandle } from "node:child_process";
3
+ import { PathLike } from "node:fs";
2
4
  import * as tty from "node:tty";
3
5
  import { Worker } from "node:worker_threads";
4
6
 
@@ -231,8 +233,9 @@ declare module "process" {
231
233
  */
232
234
  readonly tls_sni: boolean;
233
235
  /**
234
- * A value that is `"strip"` if Node.js is run with `--experimental-strip-types`,
235
- * `"transform"` if Node.js is run with `--experimental-transform-types`, and `false` otherwise.
236
+ * A value that is `"strip"` by default,
237
+ * `"transform"` if Node.js is run with `--experimental-transform-types`, and `false` if
238
+ * Node.js is run with `--no-experimental-strip-types`.
236
239
  * @since v22.10.0
237
240
  */
238
241
  readonly typescript: "strip" | "transform" | false;
@@ -331,7 +334,7 @@ declare module "process" {
331
334
  */
332
335
  type UnhandledRejectionListener = (reason: unknown, promise: Promise<unknown>) => void;
333
336
  type WarningListener = (warning: Error) => void;
334
- type MessageListener = (message: unknown, sendHandle: unknown) => void;
337
+ type MessageListener = (message: unknown, sendHandle: SendHandle) => void;
335
338
  type SignalsListener = (signal: Signals) => void;
336
339
  type MultipleResolveListener = (
337
340
  type: MultipleResolveType,
@@ -347,7 +350,7 @@ declare module "process" {
347
350
  /**
348
351
  * Can be used to change the default timezone at runtime
349
352
  */
350
- TZ?: string;
353
+ TZ?: string | undefined;
351
354
  }
352
355
  interface HRTime {
353
356
  /**
@@ -991,7 +994,7 @@ declare module "process" {
991
994
  * @since v0.1.13
992
995
  * @param [code=0] The exit code. For string type, only integer strings (e.g.,'1') are allowed.
993
996
  */
994
- exit(code?: number | string | null | undefined): never;
997
+ exit(code?: number | string | null): never;
995
998
  /**
996
999
  * A number which will be the process exit code, when the process either
997
1000
  * exits gracefully, or is exited via {@link exit} without specifying
@@ -1002,7 +1005,7 @@ declare module "process" {
1002
1005
  * @default undefined
1003
1006
  * @since v0.11.8
1004
1007
  */
1005
- exitCode?: number | string | number | undefined;
1008
+ exitCode: number | string | null | undefined;
1006
1009
  finalization: {
1007
1010
  /**
1008
1011
  * This function registers a callback to be called when the process emits the `exit` event if the `ref` object was not garbage collected.
@@ -1466,7 +1469,7 @@ declare module "process" {
1466
1469
  * @since v20.12.0
1467
1470
  * @param path The path to the .env file
1468
1471
  */
1469
- loadEnvFile(path?: string | URL | Buffer): void;
1472
+ loadEnvFile(path?: PathLike): void;
1470
1473
  /**
1471
1474
  * The `process.pid` property returns the PID of the process.
1472
1475
  *
@@ -1490,6 +1493,18 @@ declare module "process" {
1490
1493
  * @since v9.2.0, v8.10.0, v6.13.0
1491
1494
  */
1492
1495
  readonly ppid: number;
1496
+ /**
1497
+ * The `process.threadCpuUsage()` method returns the user and system CPU time usage of
1498
+ * the current worker thread, in an object with properties `user` and `system`, whose
1499
+ * values are microsecond values (millionth of a second).
1500
+ *
1501
+ * The result of a previous call to `process.threadCpuUsage()` can be passed as the
1502
+ * argument to the function, to get a diff reading.
1503
+ * @since v22.19.0
1504
+ * @param previousValue A previous return value from calling
1505
+ * `process.threadCpuUsage()`
1506
+ */
1507
+ threadCpuUsage(previousValue?: CpuUsage): CpuUsage;
1493
1508
  /**
1494
1509
  * The `process.title` property returns the current process title (i.e. returns
1495
1510
  * the current value of `ps`). Assigning a new value to `process.title` modifies
@@ -1556,7 +1571,7 @@ declare module "process" {
1556
1571
  * @since v0.1.17
1557
1572
  * @deprecated Since v14.0.0 - Use `main` instead.
1558
1573
  */
1559
- mainModule?: Module | undefined;
1574
+ mainModule?: Module;
1560
1575
  memoryUsage: MemoryUsageFn;
1561
1576
  /**
1562
1577
  * Gets the amount of memory available to the process (in bytes) based on
@@ -1566,13 +1581,11 @@ declare module "process" {
1566
1581
  * See [`uv_get_constrained_memory`](https://docs.libuv.org/en/v1.x/misc.html#c.uv_get_constrained_memory) for more
1567
1582
  * information.
1568
1583
  * @since v19.6.0, v18.15.0
1569
- * @experimental
1570
1584
  */
1571
1585
  constrainedMemory(): number;
1572
1586
  /**
1573
1587
  * Gets the amount of free memory that is still available to the process (in bytes).
1574
1588
  * See [`uv_get_available_memory`](https://nodejs.org/docs/latest-v22.x/api/process.html#processavailablememory) for more information.
1575
- * @experimental
1576
1589
  * @since v20.13.0
1577
1590
  */
1578
1591
  availableMemory(): number;
@@ -1750,18 +1763,7 @@ declare module "process" {
1750
1763
  * If no IPC channel exists, this property is undefined.
1751
1764
  * @since v7.1.0
1752
1765
  */
1753
- channel?: {
1754
- /**
1755
- * This method makes the IPC channel keep the event loop of the process running if .unref() has been called before.
1756
- * @since v7.1.0
1757
- */
1758
- ref(): void;
1759
- /**
1760
- * This method makes the IPC channel not keep the event loop of the process running, and lets it finish even while the channel is open.
1761
- * @since v7.1.0
1762
- */
1763
- unref(): void;
1764
- };
1766
+ channel?: Control;
1765
1767
  /**
1766
1768
  * If Node.js is spawned with an IPC channel, the `process.send()` method can be
1767
1769
  * used to send messages to the parent process. Messages will be received as a `'message'` event on the parent's `ChildProcess` object.
@@ -1775,10 +1777,8 @@ declare module "process" {
1775
1777
  */
1776
1778
  send?(
1777
1779
  message: any,
1778
- sendHandle?: any,
1779
- options?: {
1780
- keepOpen?: boolean | undefined;
1781
- },
1780
+ sendHandle?: SendHandle,
1781
+ options?: MessageOptions,
1782
1782
  callback?: (error: Error | null) => void,
1783
1783
  ): boolean;
1784
1784
  /**
@@ -1970,6 +1970,7 @@ declare module "process" {
1970
1970
  addListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
1971
1971
  addListener(event: "warning", listener: WarningListener): this;
1972
1972
  addListener(event: "message", listener: MessageListener): this;
1973
+ addListener(event: "workerMessage", listener: (value: any, source: number) => void): this;
1973
1974
  addListener(event: Signals, listener: SignalsListener): this;
1974
1975
  addListener(event: "multipleResolves", listener: MultipleResolveListener): this;
1975
1976
  addListener(event: "worker", listener: WorkerListener): this;
@@ -1981,7 +1982,8 @@ declare module "process" {
1981
1982
  emit(event: "uncaughtExceptionMonitor", error: Error): boolean;
1982
1983
  emit(event: "unhandledRejection", reason: unknown, promise: Promise<unknown>): boolean;
1983
1984
  emit(event: "warning", warning: Error): boolean;
1984
- emit(event: "message", message: unknown, sendHandle: unknown): this;
1985
+ emit(event: "message", message: unknown, sendHandle: SendHandle): this;
1986
+ emit(event: "workerMessage", value: any, source: number): this;
1985
1987
  emit(event: Signals, signal?: Signals): boolean;
1986
1988
  emit(
1987
1989
  event: "multipleResolves",
@@ -2002,6 +2004,7 @@ declare module "process" {
2002
2004
  on(event: Signals, listener: SignalsListener): this;
2003
2005
  on(event: "multipleResolves", listener: MultipleResolveListener): this;
2004
2006
  on(event: "worker", listener: WorkerListener): this;
2007
+ on(event: "workerMessage", listener: (value: any, source: number) => void): this;
2005
2008
  on(event: string | symbol, listener: (...args: any[]) => void): this;
2006
2009
  once(event: "beforeExit", listener: BeforeExitListener): this;
2007
2010
  once(event: "disconnect", listener: DisconnectListener): this;
@@ -2015,6 +2018,7 @@ declare module "process" {
2015
2018
  once(event: Signals, listener: SignalsListener): this;
2016
2019
  once(event: "multipleResolves", listener: MultipleResolveListener): this;
2017
2020
  once(event: "worker", listener: WorkerListener): this;
2021
+ once(event: "workerMessage", listener: (value: any, source: number) => void): this;
2018
2022
  once(event: string | symbol, listener: (...args: any[]) => void): this;
2019
2023
  prependListener(event: "beforeExit", listener: BeforeExitListener): this;
2020
2024
  prependListener(event: "disconnect", listener: DisconnectListener): this;
@@ -2025,6 +2029,7 @@ declare module "process" {
2025
2029
  prependListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
2026
2030
  prependListener(event: "warning", listener: WarningListener): this;
2027
2031
  prependListener(event: "message", listener: MessageListener): this;
2032
+ prependListener(event: "workerMessage", listener: (value: any, source: number) => void): this;
2028
2033
  prependListener(event: Signals, listener: SignalsListener): this;
2029
2034
  prependListener(event: "multipleResolves", listener: MultipleResolveListener): this;
2030
2035
  prependListener(event: "worker", listener: WorkerListener): this;
@@ -2037,6 +2042,7 @@ declare module "process" {
2037
2042
  prependOnceListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
2038
2043
  prependOnceListener(event: "warning", listener: WarningListener): this;
2039
2044
  prependOnceListener(event: "message", listener: MessageListener): this;
2045
+ prependOnceListener(event: "workerMessage", listener: (value: any, source: number) => void): this;
2040
2046
  prependOnceListener(event: Signals, listener: SignalsListener): this;
2041
2047
  prependOnceListener(event: "multipleResolves", listener: MultipleResolveListener): this;
2042
2048
  prependOnceListener(event: "worker", listener: WorkerListener): this;
@@ -2049,6 +2055,7 @@ declare module "process" {
2049
2055
  listeners(event: "unhandledRejection"): UnhandledRejectionListener[];
2050
2056
  listeners(event: "warning"): WarningListener[];
2051
2057
  listeners(event: "message"): MessageListener[];
2058
+ listeners(event: "workerMessage"): ((value: any, source: number) => void)[];
2052
2059
  listeners(event: Signals): SignalsListener[];
2053
2060
  listeners(event: "multipleResolves"): MultipleResolveListener[];
2054
2061
  listeners(event: "worker"): WorkerListener[];
@@ -1,6 +1,5 @@
1
1
  /**
2
2
  * @since v17.0.0
3
- * @experimental
4
3
  */
5
4
  declare module "readline/promises" {
6
5
  import { Abortable } from "node:events";
@@ -65,7 +64,7 @@ declare module "readline/promises" {
65
64
  constructor(
66
65
  stream: NodeJS.WritableStream,
67
66
  options?: {
68
- autoCommit?: boolean;
67
+ autoCommit?: boolean | undefined;
69
68
  },
70
69
  );
71
70
  /**
@@ -37,12 +37,10 @@ declare module "repl" {
37
37
  terminal?: boolean | undefined;
38
38
  /**
39
39
  * The function to be used when evaluating each given line of input.
40
- * Default: an async wrapper for the JavaScript `eval()` function. An `eval` function can
40
+ * **Default:** an async wrapper for the JavaScript `eval()` function. An `eval` function can
41
41
  * error with `repl.Recoverable` to indicate the input was incomplete and prompt for
42
- * additional lines.
43
- *
44
- * @see https://nodejs.org/dist/latest-v22.x/docs/api/repl.html#repl_default_evaluation
45
- * @see https://nodejs.org/dist/latest-v22.x/docs/api/repl.html#repl_custom_evaluation_functions
42
+ * additional lines. See the [custom evaluation functions](https://nodejs.org/dist/latest-v22.x/docs/api/repl.html#custom-evaluation-functions)
43
+ * section for more details.
46
44
  */
47
45
  eval?: REPLEval | undefined;
48
46
  /**
@@ -43,10 +43,9 @@
43
43
  * @see [source](https://github.com/nodejs/node/blob/v22.x/lib/sqlite.js)
44
44
  */
45
45
  declare module "node:sqlite" {
46
+ import { PathLike } from "node:fs";
46
47
  type SQLInputValue = null | number | bigint | string | NodeJS.ArrayBufferView;
47
- type SQLOutputValue = null | number | bigint | string | Uint8Array;
48
- /** @deprecated Use `SQLInputValue` or `SQLOutputValue` instead. */
49
- type SupportedValueType = SQLOutputValue;
48
+ type SQLOutputValue = null | number | bigint | string | NodeJS.NonSharedUint8Array;
50
49
  interface DatabaseSyncOptions {
51
50
  /**
52
51
  * If `true`, the database is opened by the constructor. When
@@ -89,6 +88,41 @@ declare module "node:sqlite" {
89
88
  * @default false
90
89
  */
91
90
  allowExtension?: boolean | undefined;
91
+ /**
92
+ * The [busy timeout](https://sqlite.org/c3ref/busy_timeout.html) in milliseconds. This is the maximum amount of
93
+ * time that SQLite will wait for a database lock to be released before
94
+ * returning an error.
95
+ * @since v22.16.0
96
+ * @default 0
97
+ */
98
+ timeout?: number | undefined;
99
+ /**
100
+ * If `true`, integer fields are read as JavaScript `BigInt` values. If `false`,
101
+ * integer fields are read as JavaScript numbers.
102
+ * @since v22.18.0
103
+ * @default false
104
+ */
105
+ readBigInts?: boolean | undefined;
106
+ /**
107
+ * If `true`, query results are returned as arrays instead of objects.
108
+ * @since v22.18.0
109
+ * @default false
110
+ */
111
+ returnArrays?: boolean | undefined;
112
+ /**
113
+ * If `true`, allows binding named parameters without the prefix
114
+ * character (e.g., `foo` instead of `:foo`).
115
+ * @since v22.18.0
116
+ * @default true
117
+ */
118
+ allowBareNamedParameters?: boolean | undefined;
119
+ /**
120
+ * If `true`, unknown named parameters are ignored when binding.
121
+ * If `false`, an exception is thrown for unknown named parameters.
122
+ * @since v22.18.0
123
+ * @default false
124
+ */
125
+ allowUnknownNamedParameters?: boolean | undefined;
92
126
  }
93
127
  interface CreateSessionOptions {
94
128
  /**
@@ -166,6 +200,31 @@ declare module "node:sqlite" {
166
200
  */
167
201
  varargs?: boolean | undefined;
168
202
  }
203
+ interface AggregateOptions<T extends SQLInputValue = SQLInputValue> extends FunctionOptions {
204
+ /**
205
+ * The identity value for the aggregation function. This value is used when the aggregation
206
+ * function is initialized. When a `Function` is passed the identity will be its return value.
207
+ */
208
+ start: T | (() => T);
209
+ /**
210
+ * The function to call for each row in the aggregation. The
211
+ * function receives the current state and the row value. The return value of
212
+ * this function should be the new state.
213
+ */
214
+ step: (accumulator: T, ...args: SQLOutputValue[]) => T;
215
+ /**
216
+ * The function to call to get the result of the
217
+ * aggregation. The function receives the final state and should return the
218
+ * result of the aggregation.
219
+ */
220
+ result?: ((accumulator: T) => SQLInputValue) | undefined;
221
+ /**
222
+ * When this function is provided, the `aggregate` method will work as a window function.
223
+ * The function receives the current state and the dropped row value. The return value of this function should be the
224
+ * new state.
225
+ */
226
+ inverse?: ((accumulator: T, ...args: SQLOutputValue[]) => T) | undefined;
227
+ }
169
228
  /**
170
229
  * This class represents a single [connection](https://www.sqlite.org/c3ref/sqlite3.html) to a SQLite database. All APIs
171
230
  * exposed by this class execute synchronously.
@@ -180,7 +239,39 @@ declare module "node:sqlite" {
180
239
  * To use an in-memory database, the path should be the special name `':memory:'`.
181
240
  * @param options Configuration options for the database connection.
182
241
  */
183
- constructor(path: string | Buffer | URL, options?: DatabaseSyncOptions);
242
+ constructor(path: PathLike, options?: DatabaseSyncOptions);
243
+ /**
244
+ * Registers a new aggregate function with the SQLite database. This method is a wrapper around
245
+ * [`sqlite3_create_window_function()`](https://www.sqlite.org/c3ref/create_function.html).
246
+ *
247
+ * When used as a window function, the `result` function will be called multiple times.
248
+ *
249
+ * ```js
250
+ * import { DatabaseSync } from 'node:sqlite';
251
+ *
252
+ * const db = new DatabaseSync(':memory:');
253
+ * db.exec(`
254
+ * CREATE TABLE t3(x, y);
255
+ * INSERT INTO t3 VALUES ('a', 4),
256
+ * ('b', 5),
257
+ * ('c', 3),
258
+ * ('d', 8),
259
+ * ('e', 1);
260
+ * `);
261
+ *
262
+ * db.aggregate('sumint', {
263
+ * start: 0,
264
+ * step: (acc, value) => acc + value,
265
+ * });
266
+ *
267
+ * db.prepare('SELECT sumint(y) as total FROM t3').get(); // { total: 21 }
268
+ * ```
269
+ * @since v22.16.0
270
+ * @param name The name of the SQLite function to create.
271
+ * @param options Function configuration settings.
272
+ */
273
+ aggregate(name: string, options: AggregateOptions): void;
274
+ aggregate<T extends SQLInputValue>(name: string, options: AggregateOptions<T>): void;
184
275
  /**
185
276
  * Closes the database connection. An exception is thrown if the database is not
186
277
  * open. This method is a wrapper around [`sqlite3_close_v2()`](https://www.sqlite.org/c3ref/close.html).
@@ -203,6 +294,15 @@ declare module "node:sqlite" {
203
294
  * @param allow Whether to allow loading extensions.
204
295
  */
205
296
  enableLoadExtension(allow: boolean): void;
297
+ /**
298
+ * This method is a wrapper around [`sqlite3_db_filename()`](https://sqlite.org/c3ref/db_filename.html)
299
+ * @since v22.16.0
300
+ * @param dbName Name of the database. This can be `'main'` (the default primary database) or any other
301
+ * database that has been added with [`ATTACH DATABASE`](https://www.sqlite.org/lang_attach.html) **Default:** `'main'`.
302
+ * @returns The location of the database file. When using an in-memory database,
303
+ * this method returns null.
304
+ */
305
+ location(dbName?: string): string | null;
206
306
  /**
207
307
  * This method allows one or more SQL statements to be executed without returning
208
308
  * any results. This method is useful when executing SQL statements read from a
@@ -234,6 +334,12 @@ declare module "node:sqlite" {
234
334
  * @since v22.15.0
235
335
  */
236
336
  readonly isOpen: boolean;
337
+ /**
338
+ * Whether the database is currently within a transaction. This method
339
+ * is a wrapper around [`sqlite3_get_autocommit()`](https://sqlite.org/c3ref/get_autocommit.html).
340
+ * @since v22.16.0
341
+ */
342
+ readonly isTransaction: boolean;
237
343
  /**
238
344
  * 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
239
345
  * the constructor. An exception is thrown if the database is already open.
@@ -304,7 +410,7 @@ declare module "node:sqlite" {
304
410
  * @returns Binary changeset that can be applied to other databases.
305
411
  * @since v22.12.0
306
412
  */
307
- changeset(): Uint8Array;
413
+ changeset(): NodeJS.NonSharedUint8Array;
308
414
  /**
309
415
  * Similar to the method above, but generates a more compact patchset. See
310
416
  * [Changesets and Patchsets](https://www.sqlite.org/sessionintro.html#changesets_and_patchsets)
@@ -314,7 +420,7 @@ declare module "node:sqlite" {
314
420
  * @returns Binary patchset that can be applied to other databases.
315
421
  * @since v22.12.0
316
422
  */
317
- patchset(): Uint8Array;
423
+ patchset(): NodeJS.NonSharedUint8Array;
318
424
  /**
319
425
  * Closes the session. An exception is thrown if the database or the session is not open. This method is a
320
426
  * wrapper around
@@ -322,6 +428,38 @@ declare module "node:sqlite" {
322
428
  */
323
429
  close(): void;
324
430
  }
431
+ interface StatementColumnMetadata {
432
+ /**
433
+ * The unaliased name of the column in the origin
434
+ * table, or `null` if the column is the result of an expression or subquery.
435
+ * This property is the result of [`sqlite3_column_origin_name()`](https://www.sqlite.org/c3ref/column_database_name.html).
436
+ */
437
+ column: string | null;
438
+ /**
439
+ * The unaliased name of the origin database, or
440
+ * `null` if the column is the result of an expression or subquery. This
441
+ * property is the result of [`sqlite3_column_database_name()`](https://www.sqlite.org/c3ref/column_database_name.html).
442
+ */
443
+ database: string | null;
444
+ /**
445
+ * The name assigned to the column in the result set of a
446
+ * `SELECT` statement. This property is the result of
447
+ * [`sqlite3_column_name()`](https://www.sqlite.org/c3ref/column_name.html).
448
+ */
449
+ name: string;
450
+ /**
451
+ * The unaliased name of the origin table, or `null` if
452
+ * the column is the result of an expression or subquery. This property is the
453
+ * result of [`sqlite3_column_table_name()`](https://www.sqlite.org/c3ref/column_database_name.html).
454
+ */
455
+ table: string | null;
456
+ /**
457
+ * The declared data type of the column, or `null` if the
458
+ * column is the result of an expression or subquery. This property is the
459
+ * result of [`sqlite3_column_decltype()`](https://www.sqlite.org/c3ref/column_decltype.html).
460
+ */
461
+ type: string | null;
462
+ }
325
463
  interface StatementResultingChanges {
326
464
  /**
327
465
  * The number of rows modified, inserted, or deleted by the most recently completed `INSERT`, `UPDATE`, or `DELETE` statement.
@@ -366,6 +504,14 @@ declare module "node:sqlite" {
366
504
  namedParameters: Record<string, SQLInputValue>,
367
505
  ...anonymousParameters: SQLInputValue[]
368
506
  ): Record<string, SQLOutputValue>[];
507
+ /**
508
+ * This method is used to retrieve information about the columns returned by the
509
+ * prepared statement.
510
+ * @since v22.16.0
511
+ * @returns An array of objects. Each object corresponds to a column
512
+ * in the prepared statement, and contains the following properties:
513
+ */
514
+ columns(): StatementColumnMetadata[];
369
515
  /**
370
516
  * The source SQL text of the prepared statement with parameter
371
517
  * placeholders replaced by the values that were used during the most recent
@@ -447,6 +593,13 @@ declare module "node:sqlite" {
447
593
  * @param enabled Enables or disables support for unknown named parameters.
448
594
  */
449
595
  setAllowUnknownNamedParameters(enabled: boolean): void;
596
+ /**
597
+ * When enabled, query results returned by the `all()`, `get()`, and `iterate()` methods will be returned as arrays instead
598
+ * of objects.
599
+ * @since v22.16.0
600
+ * @param enabled Enables or disables the return of query results as arrays.
601
+ */
602
+ setReturnArrays(enabled: boolean): void;
450
603
  /**
451
604
  * When reading from the database, SQLite `INTEGER`s are mapped to JavaScript
452
605
  * numbers by default. However, SQLite `INTEGER`s can store values larger than
@@ -465,6 +618,66 @@ declare module "node:sqlite" {
465
618
  */
466
619
  readonly sourceSQL: string;
467
620
  }
621
+ interface BackupOptions {
622
+ /**
623
+ * Name of the source database. This can be `'main'` (the default primary database) or any other
624
+ * database that have been added with [`ATTACH DATABASE`](https://www.sqlite.org/lang_attach.html)
625
+ * @default 'main'
626
+ */
627
+ source?: string | undefined;
628
+ /**
629
+ * Name of the target database. This can be `'main'` (the default primary database) or any other
630
+ * database that have been added with [`ATTACH DATABASE`](https://www.sqlite.org/lang_attach.html)
631
+ * @default 'main'
632
+ */
633
+ target?: string | undefined;
634
+ /**
635
+ * Number of pages to be transmitted in each batch of the backup.
636
+ * @default 100
637
+ */
638
+ rate?: number | undefined;
639
+ /**
640
+ * Callback function that will be called with the number of pages copied and the total number of
641
+ * pages.
642
+ */
643
+ progress?: ((progressInfo: BackupProgressInfo) => void) | undefined;
644
+ }
645
+ interface BackupProgressInfo {
646
+ totalPages: number;
647
+ remainingPages: number;
648
+ }
649
+ /**
650
+ * This method makes a database backup. This method abstracts the
651
+ * [`sqlite3_backup_init()`](https://www.sqlite.org/c3ref/backup_finish.html#sqlite3backupinit),
652
+ * [`sqlite3_backup_step()`](https://www.sqlite.org/c3ref/backup_finish.html#sqlite3backupstep)
653
+ * and [`sqlite3_backup_finish()`](https://www.sqlite.org/c3ref/backup_finish.html#sqlite3backupfinish) functions.
654
+ *
655
+ * The backed-up database can be used normally during the backup process. Mutations coming from the same connection - same
656
+ * `DatabaseSync` - object will be reflected in the backup right away. However, mutations from other connections will cause
657
+ * the backup process to restart.
658
+ *
659
+ * ```js
660
+ * import { backup, DatabaseSync } from 'node:sqlite';
661
+ *
662
+ * const sourceDb = new DatabaseSync('source.db');
663
+ * const totalPagesTransferred = await backup(sourceDb, 'backup.db', {
664
+ * rate: 1, // Copy one page at a time.
665
+ * progress: ({ totalPages, remainingPages }) => {
666
+ * console.log('Backup in progress', { totalPages, remainingPages });
667
+ * },
668
+ * });
669
+ *
670
+ * console.log('Backup completed', totalPagesTransferred);
671
+ * ```
672
+ * @since v22.16.0
673
+ * @param sourceDb The database to backup. The source database must be open.
674
+ * @param path The path where the backup will be created. If the file already exists,
675
+ * the contents will be overwritten.
676
+ * @param options Optional configuration for the backup. The
677
+ * following properties are supported:
678
+ * @returns A promise that resolves when the backup is completed and rejects if an error occurs.
679
+ */
680
+ function backup(sourceDb: DatabaseSync, path: PathLike, options?: BackupOptions): Promise<void>;
468
681
  /**
469
682
  * @since v22.13.0
470
683
  */
@@ -4,7 +4,7 @@
4
4
  * @since v16.7.0
5
5
  */
6
6
  declare module "stream/consumers" {
7
- import { Blob as NodeBlob } from "node:buffer";
7
+ import { Blob as NodeBlob, NonSharedBuffer } from "node:buffer";
8
8
  import { ReadableStream as WebReadableStream } from "node:stream/web";
9
9
  /**
10
10
  * @since v16.7.0
@@ -20,7 +20,7 @@ declare module "stream/consumers" {
20
20
  * @since v16.7.0
21
21
  * @returns Fulfills with a `Buffer` containing the full contents of the stream.
22
22
  */
23
- function buffer(stream: WebReadableStream | NodeJS.ReadableStream | AsyncIterable<any>): Promise<Buffer>;
23
+ function buffer(stream: WebReadableStream | NodeJS.ReadableStream | AsyncIterable<any>): Promise<NonSharedBuffer>;
24
24
  /**
25
25
  * @since v16.7.0
26
26
  * @returns Fulfills with the contents of the stream parsed as a
@@ -6,6 +6,8 @@ type _CountQueuingStrategy = typeof globalThis extends { onmessage: any } ? {}
6
6
  : import("stream/web").CountQueuingStrategy;
7
7
  type _DecompressionStream = typeof globalThis extends { onmessage: any; ReportingObserver: any } ? {}
8
8
  : import("stream/web").DecompressionStream;
9
+ type _QueuingStrategy<T = any> = typeof globalThis extends { onmessage: any } ? {}
10
+ : import("stream/web").QueuingStrategy<T>;
9
11
  type _ReadableByteStreamController = typeof globalThis extends { onmessage: any } ? {}
10
12
  : import("stream/web").ReadableByteStreamController;
11
13
  type _ReadableStream<R = any> = typeof globalThis extends { onmessage: any } ? {}
@@ -143,6 +145,9 @@ declare module "stream/web" {
143
145
  interface TransformerTransformCallback<I, O> {
144
146
  (chunk: I, controller: TransformStreamDefaultController<O>): void | PromiseLike<void>;
145
147
  }
148
+ interface TransformerCancelCallback {
149
+ (reason: any): void | PromiseLike<void>;
150
+ }
146
151
  interface UnderlyingByteSource {
147
152
  autoAllocateChunkSize?: number;
148
153
  cancel?: ReadableStreamErrorCallback;
@@ -261,6 +266,7 @@ declare module "stream/web" {
261
266
  readableType?: undefined;
262
267
  start?: TransformerStartCallback<O>;
263
268
  transform?: TransformerTransformCallback<I, O>;
269
+ cancel?: TransformerCancelCallback;
264
270
  writableType?: undefined;
265
271
  }
266
272
  interface TransformStream<I = any, O = any> {
@@ -483,6 +489,8 @@ declare module "stream/web" {
483
489
  }
484
490
  : typeof import("stream/web").DecompressionStream;
485
491
 
492
+ interface QueuingStrategy<T = any> extends _QueuingStrategy<T> {}
493
+
486
494
  interface ReadableByteStreamController extends _ReadableByteStreamController {}
487
495
  /**
488
496
  * `ReadableByteStreamController` class is a global reference for `import { ReadableByteStreamController } from 'node:stream/web'`.