@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,576 @@
1
+ /**
2
+ * The `node:diagnostics_channel` module provides an API to create named channels
3
+ * to report arbitrary message data for diagnostics purposes.
4
+ *
5
+ * It can be accessed using:
6
+ *
7
+ * ```js
8
+ * import diagnostics_channel from 'node:diagnostics_channel';
9
+ * ```
10
+ *
11
+ * It is intended that a module writer wanting to report diagnostics messages
12
+ * will create one or many top-level channels to report messages through.
13
+ * Channels may also be acquired at runtime but it is not encouraged
14
+ * due to the additional overhead of doing so. Channels may be exported for
15
+ * convenience, but as long as the name is known it can be acquired anywhere.
16
+ *
17
+ * If you intend for your module to produce diagnostics data for others to
18
+ * consume it is recommended that you include documentation of what named
19
+ * channels are used along with the shape of the message data. Channel names
20
+ * should generally include the module name to avoid collisions with data from
21
+ * other modules.
22
+ * @since v15.1.0, v14.17.0
23
+ * @see [source](https://github.com/nodejs/node/blob/v24.x/lib/diagnostics_channel.js)
24
+ */
25
+
26
+ declare module "node:diagnostics_channel" {
27
+ import { AsyncLocalStorage } from 'node:async_hooks';
28
+ /**
29
+ * Check if there are active subscribers to the named channel. This is helpful if
30
+ * the message you want to send might be expensive to prepare.
31
+ *
32
+ * This API is optional but helpful when trying to publish messages from very
33
+ * performance-sensitive code.
34
+ *
35
+ * ```js
36
+ * import diagnostics_channel from 'node:diagnostics_channel';
37
+ *
38
+ * if (diagnostics_channel.hasSubscribers('my-channel')) {
39
+ * // There are subscribers, prepare and publish message
40
+ * }
41
+ * ```
42
+ * @since v15.1.0, v14.17.0
43
+ * @param name The channel name
44
+ * @return If there are active subscribers
45
+ */
46
+ function hasSubscribers(name: string | symbol): boolean;
47
+ /**
48
+ * This is the primary entry-point for anyone wanting to publish to a named
49
+ * channel. It produces a channel object which is optimized to reduce overhead at
50
+ * publish time as much as possible.
51
+ *
52
+ * ```js
53
+ * import diagnostics_channel from 'node:diagnostics_channel';
54
+ *
55
+ * const channel = diagnostics_channel.channel('my-channel');
56
+ * ```
57
+ * @since v15.1.0, v14.17.0
58
+ * @param name The channel name
59
+ * @return The named channel object
60
+ */
61
+ function channel(name: string | symbol): Channel;
62
+ type ChannelListener = (message: unknown, name: string | symbol) => void;
63
+ /**
64
+ * Register a message handler to subscribe to this channel. This message handler
65
+ * will be run synchronously whenever a message is published to the channel. Any
66
+ * errors thrown in the message handler will trigger an `'uncaughtException'`.
67
+ *
68
+ * ```js
69
+ * import diagnostics_channel from 'node:diagnostics_channel';
70
+ *
71
+ * diagnostics_channel.subscribe('my-channel', (message, name) => {
72
+ * // Received data
73
+ * });
74
+ * ```
75
+ * @since v18.7.0, v16.17.0
76
+ * @param name The channel name
77
+ * @param onMessage The handler to receive channel messages
78
+ */
79
+ function subscribe(name: string | symbol, onMessage: ChannelListener): void;
80
+ /**
81
+ * Remove a message handler previously registered to this channel with {@link subscribe}.
82
+ *
83
+ * ```js
84
+ * import diagnostics_channel from 'node:diagnostics_channel';
85
+ *
86
+ * function onMessage(message, name) {
87
+ * // Received data
88
+ * }
89
+ *
90
+ * diagnostics_channel.subscribe('my-channel', onMessage);
91
+ *
92
+ * diagnostics_channel.unsubscribe('my-channel', onMessage);
93
+ * ```
94
+ * @since v18.7.0, v16.17.0
95
+ * @param name The channel name
96
+ * @param onMessage The previous subscribed handler to remove
97
+ * @return `true` if the handler was found, `false` otherwise.
98
+ */
99
+ function unsubscribe(name: string | symbol, onMessage: ChannelListener): boolean;
100
+ /**
101
+ * Creates a `TracingChannel` wrapper for the given `TracingChannel Channels`. If a name is given, the corresponding tracing
102
+ * channels will be created in the form of `tracing:${name}:${eventType}` where `eventType` corresponds to the types of `TracingChannel Channels`.
103
+ *
104
+ * ```js
105
+ * import diagnostics_channel from 'node:diagnostics_channel';
106
+ *
107
+ * const channelsByName = diagnostics_channel.tracingChannel('my-channel');
108
+ *
109
+ * // or...
110
+ *
111
+ * const channelsByCollection = diagnostics_channel.tracingChannel({
112
+ * start: diagnostics_channel.channel('tracing:my-channel:start'),
113
+ * end: diagnostics_channel.channel('tracing:my-channel:end'),
114
+ * asyncStart: diagnostics_channel.channel('tracing:my-channel:asyncStart'),
115
+ * asyncEnd: diagnostics_channel.channel('tracing:my-channel:asyncEnd'),
116
+ * error: diagnostics_channel.channel('tracing:my-channel:error'),
117
+ * });
118
+ * ```
119
+ * @since v19.9.0
120
+ * @experimental
121
+ * @param nameOrChannels Channel name or object containing all the `TracingChannel Channels`
122
+ * @return Collection of channels to trace with
123
+ */
124
+ function tracingChannel<
125
+ StoreType = unknown,
126
+ ContextType extends object = StoreType extends object ? StoreType : object,
127
+ >(
128
+ nameOrChannels: string | TracingChannelCollection<StoreType, ContextType>,
129
+ ): TracingChannel<StoreType, ContextType>;
130
+ /**
131
+ * The class `Channel` represents an individual named channel within the data
132
+ * pipeline. It is used to track subscribers and to publish messages when there
133
+ * are subscribers present. It exists as a separate object to avoid channel
134
+ * lookups at publish time, enabling very fast publish speeds and allowing
135
+ * for heavy use while incurring very minimal cost. Channels are created with {@link channel}, constructing a channel directly
136
+ * with `new Channel(name)` is not supported.
137
+ * @since v15.1.0, v14.17.0
138
+ */
139
+ class Channel<StoreType = unknown, ContextType = StoreType> {
140
+ readonly name: string | symbol;
141
+ /**
142
+ * Check if there are active subscribers to this channel. This is helpful if
143
+ * the message you want to send might be expensive to prepare.
144
+ *
145
+ * This API is optional but helpful when trying to publish messages from very
146
+ * performance-sensitive code.
147
+ *
148
+ * ```js
149
+ * import diagnostics_channel from 'node:diagnostics_channel';
150
+ *
151
+ * const channel = diagnostics_channel.channel('my-channel');
152
+ *
153
+ * if (channel.hasSubscribers) {
154
+ * // There are subscribers, prepare and publish message
155
+ * }
156
+ * ```
157
+ * @since v15.1.0, v14.17.0
158
+ */
159
+ readonly hasSubscribers: boolean;
160
+ private constructor(name: string | symbol);
161
+ /**
162
+ * Publish a message to any subscribers to the channel. This will trigger
163
+ * message handlers synchronously so they will execute within the same context.
164
+ *
165
+ * ```js
166
+ * import diagnostics_channel from 'node:diagnostics_channel';
167
+ *
168
+ * const channel = diagnostics_channel.channel('my-channel');
169
+ *
170
+ * channel.publish({
171
+ * some: 'message',
172
+ * });
173
+ * ```
174
+ * @since v15.1.0, v14.17.0
175
+ * @param message The message to send to the channel subscribers
176
+ */
177
+ publish(message: unknown): void;
178
+ /**
179
+ * Register a message handler to subscribe to this channel. This message handler
180
+ * will be run synchronously whenever a message is published to the channel. Any
181
+ * errors thrown in the message handler will trigger an `'uncaughtException'`.
182
+ *
183
+ * ```js
184
+ * import diagnostics_channel from 'node:diagnostics_channel';
185
+ *
186
+ * const channel = diagnostics_channel.channel('my-channel');
187
+ *
188
+ * channel.subscribe((message, name) => {
189
+ * // Received data
190
+ * });
191
+ * ```
192
+ * @since v15.1.0, v14.17.0
193
+ * @deprecated Since v18.7.0,v16.17.0 - Use {@link subscribe(name, onMessage)}
194
+ * @param onMessage The handler to receive channel messages
195
+ */
196
+ subscribe(onMessage: ChannelListener): void;
197
+ /**
198
+ * Remove a message handler previously registered to this channel with `channel.subscribe(onMessage)`.
199
+ *
200
+ * ```js
201
+ * import diagnostics_channel from 'node:diagnostics_channel';
202
+ *
203
+ * const channel = diagnostics_channel.channel('my-channel');
204
+ *
205
+ * function onMessage(message, name) {
206
+ * // Received data
207
+ * }
208
+ *
209
+ * channel.subscribe(onMessage);
210
+ *
211
+ * channel.unsubscribe(onMessage);
212
+ * ```
213
+ * @since v15.1.0, v14.17.0
214
+ * @deprecated Since v18.7.0,v16.17.0 - Use {@link unsubscribe(name, onMessage)}
215
+ * @param onMessage The previous subscribed handler to remove
216
+ * @return `true` if the handler was found, `false` otherwise.
217
+ */
218
+ unsubscribe(onMessage: ChannelListener): void;
219
+ /**
220
+ * When `channel.runStores(context, ...)` is called, the given context data
221
+ * will be applied to any store bound to the channel. If the store has already been
222
+ * bound the previous `transform` function will be replaced with the new one.
223
+ * The `transform` function may be omitted to set the given context data as the
224
+ * context directly.
225
+ *
226
+ * ```js
227
+ * import diagnostics_channel from 'node:diagnostics_channel';
228
+ * import { AsyncLocalStorage } from 'node:async_hooks';
229
+ *
230
+ * const store = new AsyncLocalStorage();
231
+ *
232
+ * const channel = diagnostics_channel.channel('my-channel');
233
+ *
234
+ * channel.bindStore(store, (data) => {
235
+ * return { data };
236
+ * });
237
+ * ```
238
+ * @since v19.9.0
239
+ * @experimental
240
+ * @param store The store to which to bind the context data
241
+ * @param transform Transform context data before setting the store context
242
+ */
243
+ bindStore(store: AsyncLocalStorage<StoreType>, transform?: (context: ContextType) => StoreType): void;
244
+ /**
245
+ * Remove a message handler previously registered to this channel with `channel.bindStore(store)`.
246
+ *
247
+ * ```js
248
+ * import diagnostics_channel from 'node:diagnostics_channel';
249
+ * import { AsyncLocalStorage } from 'node:async_hooks';
250
+ *
251
+ * const store = new AsyncLocalStorage();
252
+ *
253
+ * const channel = diagnostics_channel.channel('my-channel');
254
+ *
255
+ * channel.bindStore(store);
256
+ * channel.unbindStore(store);
257
+ * ```
258
+ * @since v19.9.0
259
+ * @experimental
260
+ * @param store The store to unbind from the channel.
261
+ * @return `true` if the store was found, `false` otherwise.
262
+ */
263
+ unbindStore(store: AsyncLocalStorage<StoreType>): boolean;
264
+ /**
265
+ * Applies the given data to any AsyncLocalStorage instances bound to the channel
266
+ * for the duration of the given function, then publishes to the channel within
267
+ * the scope of that data is applied to the stores.
268
+ *
269
+ * If a transform function was given to `channel.bindStore(store)` it will be
270
+ * applied to transform the message data before it becomes the context value for
271
+ * the store. The prior storage context is accessible from within the transform
272
+ * function in cases where context linking is required.
273
+ *
274
+ * The context applied to the store should be accessible in any async code which
275
+ * continues from execution which began during the given function, however
276
+ * there are some situations in which `context loss` may occur.
277
+ *
278
+ * ```js
279
+ * import diagnostics_channel from 'node:diagnostics_channel';
280
+ * import { AsyncLocalStorage } from 'node:async_hooks';
281
+ *
282
+ * const store = new AsyncLocalStorage();
283
+ *
284
+ * const channel = diagnostics_channel.channel('my-channel');
285
+ *
286
+ * channel.bindStore(store, (message) => {
287
+ * const parent = store.getStore();
288
+ * return new Span(message, parent);
289
+ * });
290
+ * channel.runStores({ some: 'message' }, () => {
291
+ * store.getStore(); // Span({ some: 'message' })
292
+ * });
293
+ * ```
294
+ * @since v19.9.0
295
+ * @experimental
296
+ * @param context Message to send to subscribers and bind to stores
297
+ * @param fn Handler to run within the entered storage context
298
+ * @param thisArg The receiver to be used for the function call.
299
+ * @param args Optional arguments to pass to the function.
300
+ */
301
+ runStores<ThisArg = any, Args extends any[] = any[], Result = any>(
302
+ context: ContextType,
303
+ fn: (this: ThisArg, ...args: Args) => Result,
304
+ thisArg?: ThisArg,
305
+ ...args: Args
306
+ ): Result;
307
+ }
308
+ interface TracingChannelSubscribers<ContextType extends object> {
309
+ start: (message: ContextType) => void;
310
+ end: (
311
+ message: ContextType & {
312
+ error?: unknown;
313
+ result?: unknown;
314
+ },
315
+ ) => void;
316
+ asyncStart: (
317
+ message: ContextType & {
318
+ error?: unknown;
319
+ result?: unknown;
320
+ },
321
+ ) => void;
322
+ asyncEnd: (
323
+ message: ContextType & {
324
+ error?: unknown;
325
+ result?: unknown;
326
+ },
327
+ ) => void;
328
+ error: (
329
+ message: ContextType & {
330
+ error: unknown;
331
+ },
332
+ ) => void;
333
+ }
334
+ interface TracingChannelCollection<StoreType = unknown, ContextType = StoreType> {
335
+ start: Channel<StoreType, ContextType>;
336
+ end: Channel<StoreType, ContextType>;
337
+ asyncStart: Channel<StoreType, ContextType>;
338
+ asyncEnd: Channel<StoreType, ContextType>;
339
+ error: Channel<StoreType, ContextType>;
340
+ }
341
+ /**
342
+ * The class `TracingChannel` is a collection of `TracingChannel Channels` which
343
+ * together express a single traceable action. It is used to formalize and
344
+ * simplify the process of producing events for tracing application flow. {@link tracingChannel} is used to construct a `TracingChannel`. As with `Channel` it is recommended to create and reuse a
345
+ * single `TracingChannel` at the top-level of the file rather than creating them
346
+ * dynamically.
347
+ * @since v19.9.0
348
+ * @experimental
349
+ */
350
+ class TracingChannel<StoreType = unknown, ContextType extends object = {}> implements TracingChannelCollection {
351
+ start: Channel<StoreType, ContextType>;
352
+ end: Channel<StoreType, ContextType>;
353
+ asyncStart: Channel<StoreType, ContextType>;
354
+ asyncEnd: Channel<StoreType, ContextType>;
355
+ error: Channel<StoreType, ContextType>;
356
+ /**
357
+ * Helper to subscribe a collection of functions to the corresponding channels.
358
+ * This is the same as calling `channel.subscribe(onMessage)` on each channel
359
+ * individually.
360
+ *
361
+ * ```js
362
+ * import diagnostics_channel from 'node:diagnostics_channel';
363
+ *
364
+ * const channels = diagnostics_channel.tracingChannel('my-channel');
365
+ *
366
+ * channels.subscribe({
367
+ * start(message) {
368
+ * // Handle start message
369
+ * },
370
+ * end(message) {
371
+ * // Handle end message
372
+ * },
373
+ * asyncStart(message) {
374
+ * // Handle asyncStart message
375
+ * },
376
+ * asyncEnd(message) {
377
+ * // Handle asyncEnd message
378
+ * },
379
+ * error(message) {
380
+ * // Handle error message
381
+ * },
382
+ * });
383
+ * ```
384
+ * @since v19.9.0
385
+ * @experimental
386
+ * @param subscribers Set of `TracingChannel Channels` subscribers
387
+ */
388
+ subscribe(subscribers: TracingChannelSubscribers<ContextType>): void;
389
+ /**
390
+ * Helper to unsubscribe a collection of functions from the corresponding channels.
391
+ * This is the same as calling `channel.unsubscribe(onMessage)` on each channel
392
+ * individually.
393
+ *
394
+ * ```js
395
+ * import diagnostics_channel from 'node:diagnostics_channel';
396
+ *
397
+ * const channels = diagnostics_channel.tracingChannel('my-channel');
398
+ *
399
+ * channels.unsubscribe({
400
+ * start(message) {
401
+ * // Handle start message
402
+ * },
403
+ * end(message) {
404
+ * // Handle end message
405
+ * },
406
+ * asyncStart(message) {
407
+ * // Handle asyncStart message
408
+ * },
409
+ * asyncEnd(message) {
410
+ * // Handle asyncEnd message
411
+ * },
412
+ * error(message) {
413
+ * // Handle error message
414
+ * },
415
+ * });
416
+ * ```
417
+ * @since v19.9.0
418
+ * @experimental
419
+ * @param subscribers Set of `TracingChannel Channels` subscribers
420
+ * @return `true` if all handlers were successfully unsubscribed, and `false` otherwise.
421
+ */
422
+ unsubscribe(subscribers: TracingChannelSubscribers<ContextType>): void;
423
+ /**
424
+ * Trace a synchronous function call. This will always produce a `start event` and `end event` around the execution and may produce an `error event` if the given function throws an error.
425
+ * This will run the given function using `channel.runStores(context, ...)` on the `start` channel which ensures all
426
+ * events should have any bound stores set to match this trace context.
427
+ *
428
+ * To ensure only correct trace graphs are formed, events will only be published if subscribers are present prior to starting the trace. Subscriptions
429
+ * which are added after the trace begins will not receive future events from that trace, only future traces will be seen.
430
+ *
431
+ * ```js
432
+ * import diagnostics_channel from 'node:diagnostics_channel';
433
+ *
434
+ * const channels = diagnostics_channel.tracingChannel('my-channel');
435
+ *
436
+ * channels.traceSync(() => {
437
+ * // Do something
438
+ * }, {
439
+ * some: 'thing',
440
+ * });
441
+ * ```
442
+ * @since v19.9.0
443
+ * @experimental
444
+ * @param fn Function to wrap a trace around
445
+ * @param context Shared object to correlate events through
446
+ * @param thisArg The receiver to be used for the function call
447
+ * @param args Optional arguments to pass to the function
448
+ * @return The return value of the given function
449
+ */
450
+ traceSync<ThisArg = any, Args extends any[] = any[], Result = any>(
451
+ fn: (this: ThisArg, ...args: Args) => Result,
452
+ context?: ContextType,
453
+ thisArg?: ThisArg,
454
+ ...args: Args
455
+ ): Result;
456
+ /**
457
+ * Trace a promise-returning function call. This will always produce a `start event` and `end event` around the synchronous portion of the
458
+ * function execution, and will produce an `asyncStart event` and `asyncEnd event` when a promise continuation is reached. It may also
459
+ * produce an `error event` if the given function throws an error or the
460
+ * returned promise rejects. This will run the given function using `channel.runStores(context, ...)` on the `start` channel which ensures all
461
+ * events should have any bound stores set to match this trace context.
462
+ *
463
+ * To ensure only correct trace graphs are formed, events will only be published if subscribers are present prior to starting the trace. Subscriptions
464
+ * which are added after the trace begins will not receive future events from that trace, only future traces will be seen.
465
+ *
466
+ * ```js
467
+ * import diagnostics_channel from 'node:diagnostics_channel';
468
+ *
469
+ * const channels = diagnostics_channel.tracingChannel('my-channel');
470
+ *
471
+ * channels.tracePromise(async () => {
472
+ * // Do something
473
+ * }, {
474
+ * some: 'thing',
475
+ * });
476
+ * ```
477
+ * @since v19.9.0
478
+ * @experimental
479
+ * @param fn Promise-returning function to wrap a trace around
480
+ * @param context Shared object to correlate trace events through
481
+ * @param thisArg The receiver to be used for the function call
482
+ * @param args Optional arguments to pass to the function
483
+ * @return Chained from promise returned by the given function
484
+ */
485
+ tracePromise<ThisArg = any, Args extends any[] = any[], Result = any>(
486
+ fn: (this: ThisArg, ...args: Args) => Promise<Result>,
487
+ context?: ContextType,
488
+ thisArg?: ThisArg,
489
+ ...args: Args
490
+ ): Promise<Result>;
491
+ /**
492
+ * Trace a callback-receiving function call. This will always produce a `start event` and `end event` around the synchronous portion of the
493
+ * function execution, and will produce a `asyncStart event` and `asyncEnd event` around the callback execution. It may also produce an `error event` if the given function throws an error or
494
+ * the returned
495
+ * promise rejects. This will run the given function using `channel.runStores(context, ...)` on the `start` channel which ensures all
496
+ * events should have any bound stores set to match this trace context.
497
+ *
498
+ * The `position` will be -1 by default to indicate the final argument should
499
+ * be used as the callback.
500
+ *
501
+ * ```js
502
+ * import diagnostics_channel from 'node:diagnostics_channel';
503
+ *
504
+ * const channels = diagnostics_channel.tracingChannel('my-channel');
505
+ *
506
+ * channels.traceCallback((arg1, callback) => {
507
+ * // Do something
508
+ * callback(null, 'result');
509
+ * }, 1, {
510
+ * some: 'thing',
511
+ * }, thisArg, arg1, callback);
512
+ * ```
513
+ *
514
+ * The callback will also be run with `channel.runStores(context, ...)` which
515
+ * enables context loss recovery in some cases.
516
+ *
517
+ * To ensure only correct trace graphs are formed, events will only be published if subscribers are present prior to starting the trace. Subscriptions
518
+ * which are added after the trace begins will not receive future events from that trace, only future traces will be seen.
519
+ *
520
+ * ```js
521
+ * import diagnostics_channel from 'node:diagnostics_channel';
522
+ * import { AsyncLocalStorage } from 'node:async_hooks';
523
+ *
524
+ * const channels = diagnostics_channel.tracingChannel('my-channel');
525
+ * const myStore = new AsyncLocalStorage();
526
+ *
527
+ * // The start channel sets the initial store data to something
528
+ * // and stores that store data value on the trace context object
529
+ * channels.start.bindStore(myStore, (data) => {
530
+ * const span = new Span(data);
531
+ * data.span = span;
532
+ * return span;
533
+ * });
534
+ *
535
+ * // Then asyncStart can restore from that data it stored previously
536
+ * channels.asyncStart.bindStore(myStore, (data) => {
537
+ * return data.span;
538
+ * });
539
+ * ```
540
+ * @since v19.9.0
541
+ * @experimental
542
+ * @param fn callback using function to wrap a trace around
543
+ * @param position Zero-indexed argument position of expected callback
544
+ * @param context Shared object to correlate trace events through
545
+ * @param thisArg The receiver to be used for the function call
546
+ * @param args Optional arguments to pass to the function
547
+ * @return The return value of the given function
548
+ */
549
+ traceCallback<ThisArg = any, Args extends any[] = any[], Result = any>(
550
+ fn: (this: ThisArg, ...args: Args) => Result,
551
+ position?: number,
552
+ context?: ContextType,
553
+ thisArg?: ThisArg,
554
+ ...args: Args
555
+ ): Result;
556
+ /**
557
+ * `true` if any of the individual channels has a subscriber, `false` if not.
558
+ *
559
+ * This is a helper method available on a {@link TracingChannel} instance to check
560
+ * if any of the [TracingChannel Channels](https://nodejs.org/api/diagnostics_channel.html#tracingchannel-channels) have subscribers.
561
+ * A `true` is returned if any of them have at least one subscriber, a `false` is returned otherwise.
562
+ *
563
+ * ```js
564
+ * const diagnostics_channel = require('node:diagnostics_channel');
565
+ *
566
+ * const channels = diagnostics_channel.tracingChannel('my-channel');
567
+ *
568
+ * if (channels.hasSubscribers) {
569
+ * // Do something
570
+ * }
571
+ * ```
572
+ * @since v22.0.0, v20.13.0
573
+ */
574
+ readonly hasSubscribers: boolean;
575
+ }
576
+ }