@types/node 22.4.2 → 22.5.1
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.
- node/README.md +1 -1
- node/http.d.ts +13 -0
- node/index.d.ts +1 -0
- node/inspector.d.ts +1060 -110
- node/package.json +2 -2
- node/path.d.ts +9 -0
- node/process.d.ts +37 -3
- node/sqlite.d.ts +213 -0
- node/worker_threads.d.ts +18 -0
node/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@types/node",
|
3
|
-
"version": "22.
|
3
|
+
"version": "22.5.1",
|
4
4
|
"description": "TypeScript definitions for node",
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
|
6
6
|
"license": "MIT",
|
@@ -212,6 +212,6 @@
|
|
212
212
|
"dependencies": {
|
213
213
|
"undici-types": "~6.19.2"
|
214
214
|
},
|
215
|
-
"typesPublisherContentHash": "
|
215
|
+
"typesPublisherContentHash": "68531658f8f892c98d6270ea1f2b8332049dafee094c65b9332cf6c1a860d36b",
|
216
216
|
"typeScriptVersion": "4.8"
|
217
217
|
}
|
node/path.d.ts
CHANGED
@@ -94,6 +94,15 @@ declare module "path" {
|
|
94
94
|
* @throws {TypeError} if any of the arguments is not a string.
|
95
95
|
*/
|
96
96
|
resolve(...paths: string[]): string;
|
97
|
+
/**
|
98
|
+
* The `path.matchesGlob()` method determines if `path` matches the `pattern`.
|
99
|
+
* @param path The path to glob-match against.
|
100
|
+
* @param pattern The glob to check the path against.
|
101
|
+
* @returns Whether or not the `path` matched the `pattern`.
|
102
|
+
* @throws {TypeError} if `path` or `pattern` are not strings.
|
103
|
+
* @since v22.5.0
|
104
|
+
*/
|
105
|
+
matchesGlob(path: string, pattern: string): boolean;
|
97
106
|
/**
|
98
107
|
* Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory.
|
99
108
|
*
|
node/process.d.ts
CHANGED
@@ -45,9 +45,8 @@ declare module "process" {
|
|
45
45
|
"node:https": typeof import("node:https");
|
46
46
|
"inspector": typeof import("inspector");
|
47
47
|
"node:inspector": typeof import("node:inspector");
|
48
|
-
|
49
|
-
|
50
|
-
// "node:inspector/promises": typeof import("node:inspector/promises");
|
48
|
+
"inspector/promises": typeof import("inspector/promises");
|
49
|
+
"node:inspector/promises": typeof import("node:inspector/promises");
|
51
50
|
"module": typeof import("module");
|
52
51
|
"node:module": typeof import("node:module");
|
53
52
|
"net": typeof import("net");
|
@@ -75,6 +74,7 @@ declare module "process" {
|
|
75
74
|
"repl": typeof import("repl");
|
76
75
|
"node:repl": typeof import("node:repl");
|
77
76
|
"node:sea": typeof import("node:sea");
|
77
|
+
"node:sqlite": typeof import("node:sqlite");
|
78
78
|
"stream": typeof import("stream");
|
79
79
|
"node:stream": typeof import("node:stream");
|
80
80
|
"stream/consumers": typeof import("stream/consumers");
|
@@ -893,6 +893,40 @@ declare module "process" {
|
|
893
893
|
* @since v0.11.8
|
894
894
|
*/
|
895
895
|
exitCode?: number | string | number | undefined;
|
896
|
+
finalization: {
|
897
|
+
/**
|
898
|
+
* This function registers a callback to be called when the process emits the `exit` event if the `ref` object was not garbage collected.
|
899
|
+
* If the object `ref` was garbage collected before the `exit` event is emitted, the callback will be removed from the finalization registry, and it will not be called on process exit.
|
900
|
+
*
|
901
|
+
* Inside the callback you can release the resources allocated by the `ref` object.
|
902
|
+
* Be aware that all limitations applied to the `beforeExit` event are also applied to the callback function,
|
903
|
+
* this means that there is a possibility that the callback will not be called under special circumstances.
|
904
|
+
*
|
905
|
+
* The idea of this function is to help you free up resources when the starts process exiting, but also let the object be garbage collected if it is no longer being used.
|
906
|
+
* @param ref The reference to the resource that is being tracked.
|
907
|
+
* @param callback The callback function to be called when the resource is finalized.
|
908
|
+
* @since v22.5.0
|
909
|
+
* @experimental
|
910
|
+
*/
|
911
|
+
register<T extends object>(ref: T, callback: (ref: T, event: "exit") => void): void;
|
912
|
+
/**
|
913
|
+
* This function behaves exactly like the `register`, except that the callback will be called when the process emits the `beforeExit` event if `ref` object was not garbage collected.
|
914
|
+
*
|
915
|
+
* Be aware that all limitations applied to the `beforeExit` event are also applied to the callback function, this means that there is a possibility that the callback will not be called under special circumstances.
|
916
|
+
* @param ref The reference to the resource that is being tracked.
|
917
|
+
* @param callback The callback function to be called when the resource is finalized.
|
918
|
+
* @since v22.5.0
|
919
|
+
* @experimental
|
920
|
+
*/
|
921
|
+
registerBeforeExit<T extends object>(ref: T, callback: (ref: T, event: "beforeExit") => void): void;
|
922
|
+
/**
|
923
|
+
* This function remove the register of the object from the finalization registry, so the callback will not be called anymore.
|
924
|
+
* @param ref The reference to the resource that was registered previously.
|
925
|
+
* @since v22.5.0
|
926
|
+
* @experimental
|
927
|
+
*/
|
928
|
+
unregister(ref: object): void;
|
929
|
+
};
|
896
930
|
/**
|
897
931
|
* The `process.getActiveResourcesInfo()` method returns an array of strings containing
|
898
932
|
* the types of the active resources that are currently keeping the event loop alive.
|
node/sqlite.d.ts
ADDED
@@ -0,0 +1,213 @@
|
|
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/v22.x/lib/sqlite.js)
|
44
|
+
*/
|
45
|
+
declare module "node:sqlite" {
|
46
|
+
interface DatabaseSyncOptions {
|
47
|
+
/**
|
48
|
+
* If `true`, the database is opened by the constructor.
|
49
|
+
* When this value is `false`, the database must be opened via the `open()` method.
|
50
|
+
*/
|
51
|
+
open?: boolean | undefined;
|
52
|
+
}
|
53
|
+
/**
|
54
|
+
* This class represents a single [connection](https://www.sqlite.org/c3ref/sqlite3.html) to a SQLite database. All APIs
|
55
|
+
* exposed by this class execute synchronously.
|
56
|
+
* @since v22.5.0
|
57
|
+
*/
|
58
|
+
class DatabaseSync {
|
59
|
+
/**
|
60
|
+
* Constructs a new `DatabaseSync` instance.
|
61
|
+
* @param location The location of the database.
|
62
|
+
* A SQLite database can be stored in a file or completely [in memory](https://www.sqlite.org/inmemorydb.html).
|
63
|
+
* To use a file-backed database, the location should be a file path.
|
64
|
+
* To use an in-memory database, the location should be the special name `':memory:'`.
|
65
|
+
* @param options Configuration options for the database connection.
|
66
|
+
*/
|
67
|
+
constructor(location: string, options?: DatabaseSyncOptions);
|
68
|
+
/**
|
69
|
+
* Closes the database connection. An exception is thrown if the database is not
|
70
|
+
* open. This method is a wrapper around [`sqlite3_close_v2()`](https://www.sqlite.org/c3ref/close.html).
|
71
|
+
* @since v22.5.0
|
72
|
+
*/
|
73
|
+
close(): void;
|
74
|
+
/**
|
75
|
+
* This method allows one or more SQL statements to be executed without returning
|
76
|
+
* any results. This method is useful when executing SQL statements read from a
|
77
|
+
* file. This method is a wrapper around [`sqlite3_exec()`](https://www.sqlite.org/c3ref/exec.html).
|
78
|
+
* @since v22.5.0
|
79
|
+
* @param sql A SQL string to execute.
|
80
|
+
*/
|
81
|
+
exec(sql: string): void;
|
82
|
+
/**
|
83
|
+
* Opens the database specified in the `location` argument of the `DatabaseSync`constructor. This method should only be used when the database is not opened via
|
84
|
+
* the constructor. An exception is thrown if the database is already open.
|
85
|
+
* @since v22.5.0
|
86
|
+
*/
|
87
|
+
open(): void;
|
88
|
+
/**
|
89
|
+
* Compiles a SQL statement into a [prepared statement](https://www.sqlite.org/c3ref/stmt.html). This method is a wrapper
|
90
|
+
* around [`sqlite3_prepare_v2()`](https://www.sqlite.org/c3ref/prepare.html).
|
91
|
+
* @since v22.5.0
|
92
|
+
* @param sql A SQL string to compile to a prepared statement.
|
93
|
+
* @return The prepared statement.
|
94
|
+
*/
|
95
|
+
prepare(sql: string): StatementSync;
|
96
|
+
}
|
97
|
+
type SupportedValueType = null | number | bigint | string | Uint8Array;
|
98
|
+
interface StatementResultingChanges {
|
99
|
+
/**
|
100
|
+
* The number of rows modified, inserted, or deleted by the most recently completed `INSERT`, `UPDATE`, or `DELETE` statement.
|
101
|
+
* This field is either a number or a `BigInt` depending on the prepared statement's configuration.
|
102
|
+
* This property is the result of [`sqlite3_changes64()`](https://www.sqlite.org/c3ref/changes.html).
|
103
|
+
*/
|
104
|
+
changes: number | bigint;
|
105
|
+
/**
|
106
|
+
* The most recently inserted rowid.
|
107
|
+
* This field is either a number or a `BigInt` depending on the prepared statement's configuration.
|
108
|
+
* This property is the result of [`sqlite3_last_insert_rowid()`](https://www.sqlite.org/c3ref/last_insert_rowid.html).
|
109
|
+
*/
|
110
|
+
lastInsertRowid: number | bigint;
|
111
|
+
}
|
112
|
+
/**
|
113
|
+
* This class represents a single [prepared statement](https://www.sqlite.org/c3ref/stmt.html). This class cannot be
|
114
|
+
* instantiated via its constructor. Instead, instances are created via the`database.prepare()` method. All APIs exposed by this class execute
|
115
|
+
* synchronously.
|
116
|
+
*
|
117
|
+
* A prepared statement is an efficient binary representation of the SQL used to
|
118
|
+
* create it. Prepared statements are parameterizable, and can be invoked multiple
|
119
|
+
* 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
|
120
|
+
* preferred
|
121
|
+
* over hand-crafted SQL strings when handling user input.
|
122
|
+
* @since v22.5.0
|
123
|
+
*/
|
124
|
+
class StatementSync {
|
125
|
+
private constructor();
|
126
|
+
/**
|
127
|
+
* This method executes a prepared statement and returns all results as an array of
|
128
|
+
* objects. If the prepared statement does not return any results, this method
|
129
|
+
* returns an empty array. The prepared statement [parameters are bound](https://www.sqlite.org/c3ref/bind_blob.html) using
|
130
|
+
* the values in `namedParameters` and `anonymousParameters`.
|
131
|
+
* @since v22.5.0
|
132
|
+
* @param namedParameters An optional object used to bind named parameters. The keys of this object are used to configure the mapping.
|
133
|
+
* @param anonymousParameters Zero or more values to bind to anonymous parameters.
|
134
|
+
* @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
|
135
|
+
* the row.
|
136
|
+
*/
|
137
|
+
all(...anonymousParameters: SupportedValueType[]): unknown[];
|
138
|
+
all(
|
139
|
+
namedParameters: Record<string, SupportedValueType>,
|
140
|
+
...anonymousParameters: SupportedValueType[]
|
141
|
+
): unknown[];
|
142
|
+
/**
|
143
|
+
* This method returns the source SQL of the prepared statement with parameter
|
144
|
+
* placeholders replaced by values. This method is a wrapper around [`sqlite3_expanded_sql()`](https://www.sqlite.org/c3ref/expanded_sql.html).
|
145
|
+
* @since v22.5.0
|
146
|
+
* @return The source SQL expanded to include parameter values.
|
147
|
+
*/
|
148
|
+
expandedSQL(): string;
|
149
|
+
/**
|
150
|
+
* This method executes a prepared statement and returns the first result as an
|
151
|
+
* object. If the prepared statement does not return any results, this method
|
152
|
+
* returns `undefined`. The prepared statement [parameters are bound](https://www.sqlite.org/c3ref/bind_blob.html) using the
|
153
|
+
* values in `namedParameters` and `anonymousParameters`.
|
154
|
+
* @since v22.5.0
|
155
|
+
* @param namedParameters An optional object used to bind named parameters. The keys of this object are used to configure the mapping.
|
156
|
+
* @param anonymousParameters Zero or more values to bind to anonymous parameters.
|
157
|
+
* @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
|
158
|
+
* rows were returned from the database then this method returns `undefined`.
|
159
|
+
*/
|
160
|
+
get(...anonymousParameters: SupportedValueType[]): unknown;
|
161
|
+
get(namedParameters: Record<string, SupportedValueType>, ...anonymousParameters: SupportedValueType[]): unknown;
|
162
|
+
/**
|
163
|
+
* This method executes a prepared statement and returns an object summarizing the
|
164
|
+
* resulting changes. The prepared statement [parameters are bound](https://www.sqlite.org/c3ref/bind_blob.html) using the
|
165
|
+
* values in `namedParameters` and `anonymousParameters`.
|
166
|
+
* @since v22.5.0
|
167
|
+
* @param namedParameters An optional object used to bind named parameters. The keys of this object are used to configure the mapping.
|
168
|
+
* @param anonymousParameters Zero or more values to bind to anonymous parameters.
|
169
|
+
*/
|
170
|
+
run(...anonymousParameters: SupportedValueType[]): StatementResultingChanges;
|
171
|
+
run(
|
172
|
+
namedParameters: Record<string, SupportedValueType>,
|
173
|
+
...anonymousParameters: SupportedValueType[]
|
174
|
+
): StatementResultingChanges;
|
175
|
+
/**
|
176
|
+
* The names of SQLite parameters begin with a prefix character. By default,`node:sqlite` requires that this prefix character is present when binding
|
177
|
+
* parameters. However, with the exception of dollar sign character, these
|
178
|
+
* prefix characters also require extra quoting when used in object keys.
|
179
|
+
*
|
180
|
+
* To improve ergonomics, this method can be used to also allow bare named
|
181
|
+
* parameters, which do not require the prefix character in JavaScript code. There
|
182
|
+
* are several caveats to be aware of when enabling bare named parameters:
|
183
|
+
*
|
184
|
+
* * The prefix character is still required in SQL.
|
185
|
+
* * The prefix character is still allowed in JavaScript. In fact, prefixed names
|
186
|
+
* will have slightly better binding performance.
|
187
|
+
* * Using ambiguous named parameters, such as `$k` and `@k`, in the same prepared
|
188
|
+
* statement will result in an exception as it cannot be determined how to bind
|
189
|
+
* a bare name.
|
190
|
+
* @since v22.5.0
|
191
|
+
* @param enabled Enables or disables support for binding named parameters without the prefix character.
|
192
|
+
*/
|
193
|
+
setAllowBareNamedParameters(enabled: boolean): void;
|
194
|
+
/**
|
195
|
+
* When reading from the database, SQLite `INTEGER`s are mapped to JavaScript
|
196
|
+
* numbers by default. However, SQLite `INTEGER`s can store values larger than
|
197
|
+
* JavaScript numbers are capable of representing. In such cases, this method can
|
198
|
+
* be used to read `INTEGER` data using JavaScript `BigInt`s. This method has no
|
199
|
+
* impact on database write operations where numbers and `BigInt`s are both
|
200
|
+
* supported at all times.
|
201
|
+
* @since v22.5.0
|
202
|
+
* @param enabled Enables or disables the use of `BigInt`s when reading `INTEGER` fields from the database.
|
203
|
+
*/
|
204
|
+
setReadBigInts(enabled: boolean): void;
|
205
|
+
/**
|
206
|
+
* This method returns the source SQL of the prepared statement. This method is a
|
207
|
+
* wrapper around [`sqlite3_sql()`](https://www.sqlite.org/c3ref/expanded_sql.html).
|
208
|
+
* @since v22.5.0
|
209
|
+
* @return The source SQL used to create this prepared statement.
|
210
|
+
*/
|
211
|
+
sourceSQL(): string;
|
212
|
+
}
|
213
|
+
}
|
node/worker_threads.d.ts
CHANGED
@@ -409,6 +409,24 @@ declare module "worker_threads" {
|
|
409
409
|
* @since v10.5.0
|
410
410
|
*/
|
411
411
|
postMessage(value: any, transferList?: readonly TransferListItem[]): void;
|
412
|
+
/**
|
413
|
+
* Sends a value to another worker, identified by its thread ID.
|
414
|
+
* @param threadId The target thread ID. If the thread ID is invalid, a `ERR_WORKER_MESSAGING_FAILED` error will be thrown.
|
415
|
+
* If the target thread ID is the current thread ID, a `ERR_WORKER_MESSAGING_SAME_THREAD` error will be thrown.
|
416
|
+
* @param value The value to send.
|
417
|
+
* @param transferList If one or more `MessagePort`-like objects are passed in value, a `transferList` is required for those items
|
418
|
+
* or `ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST` is thrown. See `port.postMessage()` for more information.
|
419
|
+
* @param timeout Time to wait for the message to be delivered in milliseconds. By default it's `undefined`, which means wait forever.
|
420
|
+
* If the operation times out, a `ERR_WORKER_MESSAGING_TIMEOUT` error is thrown.
|
421
|
+
* @since v22.5.0
|
422
|
+
*/
|
423
|
+
postMessageToThread(threadId: number, value: any, timeout?: number): Promise<void>;
|
424
|
+
postMessageToThread(
|
425
|
+
threadId: number,
|
426
|
+
value: any,
|
427
|
+
transferList: readonly TransferListItem[],
|
428
|
+
timeout?: number,
|
429
|
+
): Promise<void>;
|
412
430
|
/**
|
413
431
|
* Opposite of `unref()`, calling `ref()` on a previously `unref()`ed worker does _not_ let the program exit if it's the only active handle left (the default
|
414
432
|
* behavior). If the worker is `ref()`ed, calling `ref()` again has
|