@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
@@ -0,0 +1,621 @@
1
+ /**
2
+ * We strongly discourage the use of the `async_hooks` API.
3
+ * Other APIs that can cover most of its use cases include:
4
+ *
5
+ * * [`AsyncLocalStorage`](https://nodejs.org/docs/latest-v24.x/api/async_context.html#class-asynclocalstorage) tracks async context
6
+ * * [`process.getActiveResourcesInfo()`](https://nodejs.org/docs/latest-v24.x/api/process.html#processgetactiveresourcesinfo) tracks active resources
7
+ *
8
+ * The `node:async_hooks` module provides an API to track asynchronous resources.
9
+ * It can be accessed using:
10
+ *
11
+ * ```js
12
+ * import async_hooks from 'node:async_hooks';
13
+ * ```
14
+ * @experimental
15
+ * @see [source](https://github.com/nodejs/node/blob/v24.x/lib/async_hooks.js)
16
+ */
17
+
18
+ declare module "node:async_hooks" {
19
+ /**
20
+ * ```js
21
+ * import { executionAsyncId } from 'node:async_hooks';
22
+ * import fs from 'node:fs';
23
+ *
24
+ * console.log(executionAsyncId()); // 1 - bootstrap
25
+ * const path = '.';
26
+ * fs.open(path, 'r', (err, fd) => {
27
+ * console.log(executionAsyncId()); // 6 - open()
28
+ * });
29
+ * ```
30
+ *
31
+ * The ID returned from `executionAsyncId()` is related to execution timing, not
32
+ * causality (which is covered by `triggerAsyncId()`):
33
+ *
34
+ * ```js
35
+ * const server = net.createServer((conn) => {
36
+ * // Returns the ID of the server, not of the new connection, because the
37
+ * // callback runs in the execution scope of the server's MakeCallback().
38
+ * async_hooks.executionAsyncId();
39
+ *
40
+ * }).listen(port, () => {
41
+ * // Returns the ID of a TickObject (process.nextTick()) because all
42
+ * // callbacks passed to .listen() are wrapped in a nextTick().
43
+ * async_hooks.executionAsyncId();
44
+ * });
45
+ * ```
46
+ *
47
+ * Promise contexts may not get precise `executionAsyncIds` by default.
48
+ * See the section on [promise execution tracking](https://nodejs.org/docs/latest-v24.x/api/async_hooks.html#promise-execution-tracking).
49
+ * @since v8.1.0
50
+ * @return The `asyncId` of the current execution context. Useful to track when something calls.
51
+ */
52
+ function executionAsyncId(): number;
53
+ /**
54
+ * Resource objects returned by `executionAsyncResource()` are most often internal
55
+ * Node.js handle objects with undocumented APIs. Using any functions or properties
56
+ * on the object is likely to crash your application and should be avoided.
57
+ *
58
+ * Using `executionAsyncResource()` in the top-level execution context will
59
+ * return an empty object as there is no handle or request object to use,
60
+ * but having an object representing the top-level can be helpful.
61
+ *
62
+ * ```js
63
+ * import { open } from 'node:fs';
64
+ * import { executionAsyncId, executionAsyncResource } from 'node:async_hooks';
65
+ *
66
+ * console.log(executionAsyncId(), executionAsyncResource()); // 1 {}
67
+ * open(new URL(import.meta.url), 'r', (err, fd) => {
68
+ * console.log(executionAsyncId(), executionAsyncResource()); // 7 FSReqWrap
69
+ * });
70
+ * ```
71
+ *
72
+ * This can be used to implement continuation local storage without the
73
+ * use of a tracking `Map` to store the metadata:
74
+ *
75
+ * ```js
76
+ * import { createServer } from 'node:http';
77
+ * import {
78
+ * executionAsyncId,
79
+ * executionAsyncResource,
80
+ * createHook,
81
+ * } from 'node:async_hooks';
82
+ * const sym = Symbol('state'); // Private symbol to avoid pollution
83
+ *
84
+ * createHook({
85
+ * init(asyncId, type, triggerAsyncId, resource) {
86
+ * const cr = executionAsyncResource();
87
+ * if (cr) {
88
+ * resource[sym] = cr[sym];
89
+ * }
90
+ * },
91
+ * }).enable();
92
+ *
93
+ * const server = createServer((req, res) => {
94
+ * executionAsyncResource()[sym] = { state: req.url };
95
+ * setTimeout(function() {
96
+ * res.end(JSON.stringify(executionAsyncResource()[sym]));
97
+ * }, 100);
98
+ * }).listen(3000);
99
+ * ```
100
+ * @since v13.9.0, v12.17.0
101
+ * @return The resource representing the current execution. Useful to store data within the resource.
102
+ */
103
+ function executionAsyncResource(): object;
104
+ /**
105
+ * ```js
106
+ * const server = net.createServer((conn) => {
107
+ * // The resource that caused (or triggered) this callback to be called
108
+ * // was that of the new connection. Thus the return value of triggerAsyncId()
109
+ * // is the asyncId of "conn".
110
+ * async_hooks.triggerAsyncId();
111
+ *
112
+ * }).listen(port, () => {
113
+ * // Even though all callbacks passed to .listen() are wrapped in a nextTick()
114
+ * // the callback itself exists because the call to the server's .listen()
115
+ * // was made. So the return value would be the ID of the server.
116
+ * async_hooks.triggerAsyncId();
117
+ * });
118
+ * ```
119
+ *
120
+ * Promise contexts may not get valid `triggerAsyncId`s by default. See
121
+ * the section on [promise execution tracking](https://nodejs.org/docs/latest-v24.x/api/async_hooks.html#promise-execution-tracking).
122
+ * @return The ID of the resource responsible for calling the callback that is currently being executed.
123
+ */
124
+ function triggerAsyncId(): number;
125
+ interface HookCallbacks {
126
+ /**
127
+ * Called when a class is constructed that has the possibility to emit an asynchronous event.
128
+ * @param asyncId A unique ID for the async resource
129
+ * @param type The type of the async resource
130
+ * @param triggerAsyncId The unique ID of the async resource in whose execution context this async resource was created
131
+ * @param resource Reference to the resource representing the async operation, needs to be released during destroy
132
+ */
133
+ init?(asyncId: number, type: string, triggerAsyncId: number, resource: object): void;
134
+ /**
135
+ * When an asynchronous operation is initiated or completes a callback is called to notify the user.
136
+ * The before callback is called just before said callback is executed.
137
+ * @param asyncId the unique identifier assigned to the resource about to execute the callback.
138
+ */
139
+ before?(asyncId: number): void;
140
+ /**
141
+ * Called immediately after the callback specified in `before` is completed.
142
+ *
143
+ * If an uncaught exception occurs during execution of the callback, then `after` will run after the `'uncaughtException'` event is emitted or a `domain`'s handler runs.
144
+ * @param asyncId the unique identifier assigned to the resource which has executed the callback.
145
+ */
146
+ after?(asyncId: number): void;
147
+ /**
148
+ * Called when a promise has resolve() called. This may not be in the same execution id
149
+ * as the promise itself.
150
+ * @param asyncId the unique id for the promise that was resolve()d.
151
+ */
152
+ promiseResolve?(asyncId: number): void;
153
+ /**
154
+ * Called after the resource corresponding to asyncId is destroyed
155
+ * @param asyncId a unique ID for the async resource
156
+ */
157
+ destroy?(asyncId: number): void;
158
+ }
159
+ interface AsyncHook {
160
+ /**
161
+ * Enable the callbacks for a given AsyncHook instance. If no callbacks are provided enabling is a noop.
162
+ */
163
+ enable(): this;
164
+ /**
165
+ * Disable the callbacks for a given AsyncHook instance from the global pool of AsyncHook callbacks to be executed. Once a hook has been disabled it will not be called again until enabled.
166
+ */
167
+ disable(): this;
168
+ }
169
+ /**
170
+ * Registers functions to be called for different lifetime events of each async
171
+ * operation.
172
+ *
173
+ * The callbacks `init()`/`before()`/`after()`/`destroy()` are called for the
174
+ * respective asynchronous event during a resource's lifetime.
175
+ *
176
+ * All callbacks are optional. For example, if only resource cleanup needs to
177
+ * be tracked, then only the `destroy` callback needs to be passed. The
178
+ * specifics of all functions that can be passed to `callbacks` is in the `Hook Callbacks` section.
179
+ *
180
+ * ```js
181
+ * import { createHook } from 'node:async_hooks';
182
+ *
183
+ * const asyncHook = createHook({
184
+ * init(asyncId, type, triggerAsyncId, resource) { },
185
+ * destroy(asyncId) { },
186
+ * });
187
+ * ```
188
+ *
189
+ * The callbacks will be inherited via the prototype chain:
190
+ *
191
+ * ```js
192
+ * class MyAsyncCallbacks {
193
+ * init(asyncId, type, triggerAsyncId, resource) { }
194
+ * destroy(asyncId) {}
195
+ * }
196
+ *
197
+ * class MyAddedCallbacks extends MyAsyncCallbacks {
198
+ * before(asyncId) { }
199
+ * after(asyncId) { }
200
+ * }
201
+ *
202
+ * const asyncHook = async_hooks.createHook(new MyAddedCallbacks());
203
+ * ```
204
+ *
205
+ * Because promises are asynchronous resources whose lifecycle is tracked
206
+ * via the async hooks mechanism, the `init()`, `before()`, `after()`, and`destroy()` callbacks _must not_ be async functions that return promises.
207
+ * @since v8.1.0
208
+ * @param callbacks The `Hook Callbacks` to register
209
+ * @return Instance used for disabling and enabling hooks
210
+ */
211
+ function createHook(callbacks: HookCallbacks): AsyncHook;
212
+ interface AsyncResourceOptions {
213
+ /**
214
+ * The ID of the execution context that created this async event.
215
+ * @default executionAsyncId()
216
+ */
217
+ triggerAsyncId?: number | undefined;
218
+ /**
219
+ * Disables automatic `emitDestroy` when the object is garbage collected.
220
+ * This usually does not need to be set (even if `emitDestroy` is called
221
+ * manually), unless the resource's `asyncId` is retrieved and the
222
+ * sensitive API's `emitDestroy` is called with it.
223
+ * @default false
224
+ */
225
+ requireManualDestroy?: boolean | undefined;
226
+ }
227
+ /**
228
+ * The class `AsyncResource` is designed to be extended by the embedder's async
229
+ * resources. Using this, users can easily trigger the lifetime events of their
230
+ * own resources.
231
+ *
232
+ * The `init` hook will trigger when an `AsyncResource` is instantiated.
233
+ *
234
+ * The following is an overview of the `AsyncResource` API.
235
+ *
236
+ * ```js
237
+ * import { AsyncResource, executionAsyncId } from 'node:async_hooks';
238
+ *
239
+ * // AsyncResource() is meant to be extended. Instantiating a
240
+ * // new AsyncResource() also triggers init. If triggerAsyncId is omitted then
241
+ * // async_hook.executionAsyncId() is used.
242
+ * const asyncResource = new AsyncResource(
243
+ * type, { triggerAsyncId: executionAsyncId(), requireManualDestroy: false },
244
+ * );
245
+ *
246
+ * // Run a function in the execution context of the resource. This will
247
+ * // * establish the context of the resource
248
+ * // * trigger the AsyncHooks before callbacks
249
+ * // * call the provided function `fn` with the supplied arguments
250
+ * // * trigger the AsyncHooks after callbacks
251
+ * // * restore the original execution context
252
+ * asyncResource.runInAsyncScope(fn, thisArg, ...args);
253
+ *
254
+ * // Call AsyncHooks destroy callbacks.
255
+ * asyncResource.emitDestroy();
256
+ *
257
+ * // Return the unique ID assigned to the AsyncResource instance.
258
+ * asyncResource.asyncId();
259
+ *
260
+ * // Return the trigger ID for the AsyncResource instance.
261
+ * asyncResource.triggerAsyncId();
262
+ * ```
263
+ */
264
+ class AsyncResource {
265
+ /**
266
+ * AsyncResource() is meant to be extended. Instantiating a
267
+ * new AsyncResource() also triggers init. If triggerAsyncId is omitted then
268
+ * async_hook.executionAsyncId() is used.
269
+ * @param type The type of async event.
270
+ * @param triggerAsyncId The ID of the execution context that created
271
+ * this async event (default: `executionAsyncId()`), or an
272
+ * AsyncResourceOptions object (since v9.3.0)
273
+ */
274
+ constructor(type: string, triggerAsyncId?: number | AsyncResourceOptions);
275
+ /**
276
+ * Binds the given function to the current execution context.
277
+ * @since v14.8.0, v12.19.0
278
+ * @param fn The function to bind to the current execution context.
279
+ * @param type An optional name to associate with the underlying `AsyncResource`.
280
+ */
281
+ static bind<Func extends (this: ThisArg, ...args: any[]) => any, ThisArg>(
282
+ fn: Func,
283
+ type?: string,
284
+ thisArg?: ThisArg,
285
+ ): Func;
286
+ /**
287
+ * Binds the given function to execute to this `AsyncResource`'s scope.
288
+ * @since v14.8.0, v12.19.0
289
+ * @param fn The function to bind to the current `AsyncResource`.
290
+ */
291
+ bind<Func extends (...args: any[]) => any>(fn: Func): Func;
292
+ /**
293
+ * Call the provided function with the provided arguments in the execution context
294
+ * of the async resource. This will establish the context, trigger the AsyncHooks
295
+ * before callbacks, call the function, trigger the AsyncHooks after callbacks, and
296
+ * then restore the original execution context.
297
+ * @since v9.6.0
298
+ * @param fn The function to call in the execution context of this async resource.
299
+ * @param thisArg The receiver to be used for the function call.
300
+ * @param args Optional arguments to pass to the function.
301
+ */
302
+ runInAsyncScope<This, Result>(
303
+ fn: (this: This, ...args: any[]) => Result,
304
+ thisArg?: This,
305
+ ...args: any[]
306
+ ): Result;
307
+ /**
308
+ * Call all `destroy` hooks. This should only ever be called once. An error will
309
+ * be thrown if it is called more than once. This **must** be manually called. If
310
+ * the resource is left to be collected by the GC then the `destroy` hooks will
311
+ * never be called.
312
+ * @return A reference to `asyncResource`.
313
+ */
314
+ emitDestroy(): this;
315
+ /**
316
+ * @return The unique `asyncId` assigned to the resource.
317
+ */
318
+ asyncId(): number;
319
+ /**
320
+ * @return The same `triggerAsyncId` that is passed to the `AsyncResource` constructor.
321
+ */
322
+ triggerAsyncId(): number;
323
+ }
324
+ interface AsyncLocalStorageOptions {
325
+ /**
326
+ * The default value to be used when no store is provided.
327
+ */
328
+ defaultValue?: any;
329
+ /**
330
+ * A name for the `AsyncLocalStorage` value.
331
+ */
332
+ name?: string | undefined;
333
+ }
334
+ /**
335
+ * This class creates stores that stay coherent through asynchronous operations.
336
+ *
337
+ * While you can create your own implementation on top of the `node:async_hooks` module, `AsyncLocalStorage` should be preferred as it is a performant and memory
338
+ * safe implementation that involves significant optimizations that are non-obvious
339
+ * to implement.
340
+ *
341
+ * The following example uses `AsyncLocalStorage` to build a simple logger
342
+ * that assigns IDs to incoming HTTP requests and includes them in messages
343
+ * logged within each request.
344
+ *
345
+ * ```js
346
+ * import http from 'node:http';
347
+ * import { AsyncLocalStorage } from 'node:async_hooks';
348
+ *
349
+ * const asyncLocalStorage = new AsyncLocalStorage();
350
+ *
351
+ * function logWithId(msg) {
352
+ * const id = asyncLocalStorage.getStore();
353
+ * console.log(`${id !== undefined ? id : '-'}:`, msg);
354
+ * }
355
+ *
356
+ * let idSeq = 0;
357
+ * http.createServer((req, res) => {
358
+ * asyncLocalStorage.run(idSeq++, () => {
359
+ * logWithId('start');
360
+ * // Imagine any chain of async operations here
361
+ * setImmediate(() => {
362
+ * logWithId('finish');
363
+ * res.end();
364
+ * });
365
+ * });
366
+ * }).listen(8080);
367
+ *
368
+ * http.get('http://localhost:8080');
369
+ * http.get('http://localhost:8080');
370
+ * // Prints:
371
+ * // 0: start
372
+ * // 0: finish
373
+ * // 1: start
374
+ * // 1: finish
375
+ * ```
376
+ *
377
+ * Each instance of `AsyncLocalStorage` maintains an independent storage context.
378
+ * Multiple instances can safely exist simultaneously without risk of interfering
379
+ * with each other's data.
380
+ * @since v13.10.0, v12.17.0
381
+ */
382
+ class AsyncLocalStorage<T> {
383
+ /**
384
+ * Creates a new instance of `AsyncLocalStorage`. Store is only provided within a
385
+ * `run()` call or after an `enterWith()` call.
386
+ */
387
+ constructor(options?: AsyncLocalStorageOptions);
388
+ /**
389
+ * Binds the given function to the current execution context.
390
+ * @since v19.8.0
391
+ * @param fn The function to bind to the current execution context.
392
+ * @return A new function that calls `fn` within the captured execution context.
393
+ */
394
+ static bind<Func extends (...args: any[]) => any>(fn: Func): Func;
395
+ /**
396
+ * Captures the current execution context and returns a function that accepts a
397
+ * function as an argument. Whenever the returned function is called, it
398
+ * calls the function passed to it within the captured context.
399
+ *
400
+ * ```js
401
+ * const asyncLocalStorage = new AsyncLocalStorage();
402
+ * const runInAsyncScope = asyncLocalStorage.run(123, () => AsyncLocalStorage.snapshot());
403
+ * const result = asyncLocalStorage.run(321, () => runInAsyncScope(() => asyncLocalStorage.getStore()));
404
+ * console.log(result); // returns 123
405
+ * ```
406
+ *
407
+ * AsyncLocalStorage.snapshot() can replace the use of AsyncResource for simple
408
+ * async context tracking purposes, for example:
409
+ *
410
+ * ```js
411
+ * class Foo {
412
+ * #runInAsyncScope = AsyncLocalStorage.snapshot();
413
+ *
414
+ * get() { return this.#runInAsyncScope(() => asyncLocalStorage.getStore()); }
415
+ * }
416
+ *
417
+ * const foo = asyncLocalStorage.run(123, () => new Foo());
418
+ * console.log(asyncLocalStorage.run(321, () => foo.get())); // returns 123
419
+ * ```
420
+ * @since v19.8.0
421
+ * @return A new function with the signature `(fn: (...args) : R, ...args) : R`.
422
+ */
423
+ static snapshot(): <R, TArgs extends any[]>(fn: (...args: TArgs) => R, ...args: TArgs) => R;
424
+ /**
425
+ * Disables the instance of `AsyncLocalStorage`. All subsequent calls
426
+ * to `asyncLocalStorage.getStore()` will return `undefined` until `asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()` is called again.
427
+ *
428
+ * When calling `asyncLocalStorage.disable()`, all current contexts linked to the
429
+ * instance will be exited.
430
+ *
431
+ * Calling `asyncLocalStorage.disable()` is required before the `asyncLocalStorage` can be garbage collected. This does not apply to stores
432
+ * provided by the `asyncLocalStorage`, as those objects are garbage collected
433
+ * along with the corresponding async resources.
434
+ *
435
+ * Use this method when the `asyncLocalStorage` is not in use anymore
436
+ * in the current process.
437
+ * @since v13.10.0, v12.17.0
438
+ * @experimental
439
+ */
440
+ disable(): void;
441
+ /**
442
+ * Returns the current store.
443
+ * If called outside of an asynchronous context initialized by
444
+ * calling `asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()`, it
445
+ * returns `undefined`.
446
+ * @since v13.10.0, v12.17.0
447
+ */
448
+ getStore(): T | undefined;
449
+ /**
450
+ * The name of the `AsyncLocalStorage` instance if provided.
451
+ * @since v24.0.0
452
+ */
453
+ readonly name: string;
454
+ /**
455
+ * Runs a function synchronously within a context and returns its
456
+ * return value. The store is not accessible outside of the callback function.
457
+ * The store is accessible to any asynchronous operations created within the
458
+ * callback.
459
+ *
460
+ * The optional `args` are passed to the callback function.
461
+ *
462
+ * If the callback function throws an error, the error is thrown by `run()` too.
463
+ * The stacktrace is not impacted by this call and the context is exited.
464
+ *
465
+ * Example:
466
+ *
467
+ * ```js
468
+ * const store = { id: 2 };
469
+ * try {
470
+ * asyncLocalStorage.run(store, () => {
471
+ * asyncLocalStorage.getStore(); // Returns the store object
472
+ * setTimeout(() => {
473
+ * asyncLocalStorage.getStore(); // Returns the store object
474
+ * }, 200);
475
+ * throw new Error();
476
+ * });
477
+ * } catch (e) {
478
+ * asyncLocalStorage.getStore(); // Returns undefined
479
+ * // The error will be caught here
480
+ * }
481
+ * ```
482
+ * @since v13.10.0, v12.17.0
483
+ */
484
+ run<R>(store: T, callback: () => R): R;
485
+ run<R, TArgs extends any[]>(store: T, callback: (...args: TArgs) => R, ...args: TArgs): R;
486
+ /**
487
+ * Runs a function synchronously outside of a context and returns its
488
+ * return value. The store is not accessible within the callback function or
489
+ * the asynchronous operations created within the callback. Any `getStore()` call done within the callback function will always return `undefined`.
490
+ *
491
+ * The optional `args` are passed to the callback function.
492
+ *
493
+ * If the callback function throws an error, the error is thrown by `exit()` too.
494
+ * The stacktrace is not impacted by this call and the context is re-entered.
495
+ *
496
+ * Example:
497
+ *
498
+ * ```js
499
+ * // Within a call to run
500
+ * try {
501
+ * asyncLocalStorage.getStore(); // Returns the store object or value
502
+ * asyncLocalStorage.exit(() => {
503
+ * asyncLocalStorage.getStore(); // Returns undefined
504
+ * throw new Error();
505
+ * });
506
+ * } catch (e) {
507
+ * asyncLocalStorage.getStore(); // Returns the same object or value
508
+ * // The error will be caught here
509
+ * }
510
+ * ```
511
+ * @since v13.10.0, v12.17.0
512
+ * @experimental
513
+ */
514
+ exit<R, TArgs extends any[]>(callback: (...args: TArgs) => R, ...args: TArgs): R;
515
+ /**
516
+ * Transitions into the context for the remainder of the current
517
+ * synchronous execution and then persists the store through any following
518
+ * asynchronous calls.
519
+ *
520
+ * Example:
521
+ *
522
+ * ```js
523
+ * const store = { id: 1 };
524
+ * // Replaces previous store with the given store object
525
+ * asyncLocalStorage.enterWith(store);
526
+ * asyncLocalStorage.getStore(); // Returns the store object
527
+ * someAsyncOperation(() => {
528
+ * asyncLocalStorage.getStore(); // Returns the same object
529
+ * });
530
+ * ```
531
+ *
532
+ * This transition will continue for the _entire_ synchronous execution.
533
+ * This means that if, for example, the context is entered within an event
534
+ * handler subsequent event handlers will also run within that context unless
535
+ * specifically bound to another context with an `AsyncResource`. That is why `run()` should be preferred over `enterWith()` unless there are strong reasons
536
+ * to use the latter method.
537
+ *
538
+ * ```js
539
+ * const store = { id: 1 };
540
+ *
541
+ * emitter.on('my-event', () => {
542
+ * asyncLocalStorage.enterWith(store);
543
+ * });
544
+ * emitter.on('my-event', () => {
545
+ * asyncLocalStorage.getStore(); // Returns the same object
546
+ * });
547
+ *
548
+ * asyncLocalStorage.getStore(); // Returns undefined
549
+ * emitter.emit('my-event');
550
+ * asyncLocalStorage.getStore(); // Returns the same object
551
+ * ```
552
+ * @since v13.11.0, v12.17.0
553
+ * @experimental
554
+ */
555
+ enterWith(store: T): void;
556
+ }
557
+ /**
558
+ * @since v17.2.0, v16.14.0
559
+ * @return A map of provider types to the corresponding numeric id.
560
+ * This map contains all the event types that might be emitted by the `async_hooks.init()` event.
561
+ */
562
+ namespace asyncWrapProviders {
563
+ const NONE: number;
564
+ const DIRHANDLE: number;
565
+ const DNSCHANNEL: number;
566
+ const ELDHISTOGRAM: number;
567
+ const FILEHANDLE: number;
568
+ const FILEHANDLECLOSEREQ: number;
569
+ const FIXEDSIZEBLOBCOPY: number;
570
+ const FSEVENTWRAP: number;
571
+ const FSREQCALLBACK: number;
572
+ const FSREQPROMISE: number;
573
+ const GETADDRINFOREQWRAP: number;
574
+ const GETNAMEINFOREQWRAP: number;
575
+ const HEAPSNAPSHOT: number;
576
+ const HTTP2SESSION: number;
577
+ const HTTP2STREAM: number;
578
+ const HTTP2PING: number;
579
+ const HTTP2SETTINGS: number;
580
+ const HTTPINCOMINGMESSAGE: number;
581
+ const HTTPCLIENTREQUEST: number;
582
+ const JSSTREAM: number;
583
+ const JSUDPWRAP: number;
584
+ const MESSAGEPORT: number;
585
+ const PIPECONNECTWRAP: number;
586
+ const PIPESERVERWRAP: number;
587
+ const PIPEWRAP: number;
588
+ const PROCESSWRAP: number;
589
+ const PROMISE: number;
590
+ const QUERYWRAP: number;
591
+ const SHUTDOWNWRAP: number;
592
+ const SIGNALWRAP: number;
593
+ const STATWATCHER: number;
594
+ const STREAMPIPE: number;
595
+ const TCPCONNECTWRAP: number;
596
+ const TCPSERVERWRAP: number;
597
+ const TCPWRAP: number;
598
+ const TTYWRAP: number;
599
+ const UDPSENDWRAP: number;
600
+ const UDPWRAP: number;
601
+ const SIGINTWATCHDOG: number;
602
+ const WORKER: number;
603
+ const WORKERHEAPSNAPSHOT: number;
604
+ const WRITEWRAP: number;
605
+ const ZLIB: number;
606
+ const CHECKPRIMEREQUEST: number;
607
+ const PBKDF2REQUEST: number;
608
+ const KEYPAIRGENREQUEST: number;
609
+ const KEYGENREQUEST: number;
610
+ const KEYEXPORTREQUEST: number;
611
+ const CIPHERREQUEST: number;
612
+ const DERIVEBITSREQUEST: number;
613
+ const HASHREQUEST: number;
614
+ const RANDOMBYTESREQUEST: number;
615
+ const RANDOMPRIMEREQUEST: number;
616
+ const SCRYPTREQUEST: number;
617
+ const SIGNREQUEST: number;
618
+ const TLSWRAP: number;
619
+ const VERIFYREQUEST: number;
620
+ }
621
+ }