undici-types 7.9.0 → 7.11.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.
@@ -31,6 +31,15 @@ declare namespace DiagnosticsChannel {
31
31
  export interface RequestBodySentMessage {
32
32
  request: Request;
33
33
  }
34
+
35
+ export interface RequestBodyChunkSentMessage {
36
+ request: Request;
37
+ chunk: Uint8Array | string;
38
+ }
39
+ export interface RequestBodyChunkReceivedMessage {
40
+ request: Request;
41
+ chunk: Buffer;
42
+ }
34
43
  export interface RequestHeadersMessage {
35
44
  request: Request;
36
45
  response: Response;
package/dispatcher.d.ts CHANGED
@@ -97,7 +97,8 @@ declare class Dispatcher extends EventEmitter {
97
97
 
98
98
  declare namespace Dispatcher {
99
99
  export interface ComposedDispatcher extends Dispatcher {}
100
- export type DispatcherComposeInterceptor = (dispatch: Dispatcher['dispatch']) => Dispatcher['dispatch']
100
+ export type Dispatch = Dispatcher['dispatch']
101
+ export type DispatcherComposeInterceptor = (dispatch: Dispatch) => Dispatch
101
102
  export interface DispatchOptions {
102
103
  origin?: string | URL;
103
104
  path: string;
@@ -276,6 +277,6 @@ declare namespace Dispatcher {
276
277
  }
277
278
 
278
279
  export interface DispatchInterceptor {
279
- (dispatch: Dispatcher['dispatch']): Dispatcher['dispatch']
280
+ (dispatch: Dispatch): Dispatch
280
281
  }
281
282
  }
@@ -1,4 +1,5 @@
1
1
  import Agent from './agent'
2
+ import ProxyAgent from './proxy-agent'
2
3
  import Dispatcher from './dispatcher'
3
4
 
4
5
  export default EnvHttpProxyAgent
@@ -10,7 +11,7 @@ declare class EnvHttpProxyAgent extends Dispatcher {
10
11
  }
11
12
 
12
13
  declare namespace EnvHttpProxyAgent {
13
- export interface Options extends Agent.Options {
14
+ export interface Options extends Omit<ProxyAgent.Options, 'uri'> {
14
15
  /** Overrides the value of the HTTP_PROXY environment variable */
15
16
  httpProxy?: string;
16
17
  /** Overrides the value of the HTTPS_PROXY environment variable */
package/eventsource.d.ts CHANGED
@@ -18,9 +18,9 @@ interface EventSource extends EventTarget {
18
18
  readonly CLOSED: 2
19
19
  readonly CONNECTING: 0
20
20
  readonly OPEN: 1
21
- onerror: (this: EventSource, ev: ErrorEvent) => any
22
- onmessage: (this: EventSource, ev: MessageEvent) => any
23
- onopen: (this: EventSource, ev: Event) => any
21
+ onerror: ((this: EventSource, ev: ErrorEvent) => any) | null
22
+ onmessage: ((this: EventSource, ev: MessageEvent) => any) | null
23
+ onopen: ((this: EventSource, ev: Event) => any) | null
24
24
  readonly readyState: 0 | 1 | 2
25
25
  readonly url: string
26
26
  readonly withCredentials: boolean
package/fetch.d.ts CHANGED
@@ -33,6 +33,7 @@ export class BodyMixin {
33
33
 
34
34
  readonly arrayBuffer: () => Promise<ArrayBuffer>
35
35
  readonly blob: () => Promise<Blob>
36
+ readonly bytes: () => Promise<Uint8Array>
36
37
  /**
37
38
  * @deprecated This method is not recommended for parsing multipart/form-data bodies in server environments.
38
39
  * It is recommended to use a library such as [@fastify/busboy](https://www.npmjs.com/package/@fastify/busboy) as follows:
package/handlers.d.ts CHANGED
@@ -2,7 +2,7 @@ import Dispatcher from './dispatcher'
2
2
 
3
3
  export declare class RedirectHandler implements Dispatcher.DispatchHandler {
4
4
  constructor (
5
- dispatch: Dispatcher,
5
+ dispatch: Dispatcher.Dispatch,
6
6
  maxRedirections: number,
7
7
  opts: Dispatcher.DispatchOptions,
8
8
  handler: Dispatcher.DispatchHandler,
package/mock-client.d.ts CHANGED
@@ -14,6 +14,8 @@ declare class MockClient extends Client implements Interceptable {
14
14
  dispatch (options: Dispatcher.DispatchOptions, handlers: Dispatcher.DispatchHandler): boolean
15
15
  /** Closes the mock client and gracefully waits for enqueued requests to complete. */
16
16
  close (): Promise<void>
17
+ /** Clean up all the prepared mocks. */
18
+ cleanMocks (): void
17
19
  }
18
20
 
19
21
  declare namespace MockClient {
@@ -84,6 +84,8 @@ declare namespace MockInterceptor {
84
84
  interface Interceptable extends Dispatcher {
85
85
  /** Intercepts any matching requests that use the same origin as this mock client. */
86
86
  intercept(options: MockInterceptor.Options): MockInterceptor;
87
+ /** Clean up all the prepared mocks. */
88
+ cleanMocks (): void
87
89
  }
88
90
 
89
91
  export {
package/mock-pool.d.ts CHANGED
@@ -14,6 +14,8 @@ declare class MockPool extends Pool implements Interceptable {
14
14
  dispatch (options: Dispatcher.DispatchOptions, handlers: Dispatcher.DispatchHandler): boolean
15
15
  /** Closes the mock pool and gracefully waits for enqueued requests to complete. */
16
16
  close (): Promise<void>
17
+ /** Clean up all the prepared mocks. */
18
+ cleanMocks (): void
17
19
  }
18
20
 
19
21
  declare namespace MockPool {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "undici-types",
3
- "version": "7.9.0",
3
+ "version": "7.11.0",
4
4
  "description": "A stand-alone types package for Undici",
5
5
  "homepage": "https://undici.nodejs.org",
6
6
  "bugs": {
package/pool.d.ts CHANGED
@@ -33,6 +33,8 @@ declare namespace Pool {
33
33
  factory?(origin: URL, opts: object): Dispatcher;
34
34
  /** The max number of clients to create. `null` if no limit. Default `null`. */
35
35
  connections?: number | null;
36
+ /** The amount of time before a client is removed from the pool and closed. `null` if no time limit. Default `null` */
37
+ clientTtl?: number | null;
36
38
 
37
39
  interceptors?: { Pool?: readonly Dispatcher.DispatchInterceptor[] } & Client.Options['interceptors']
38
40
  }
package/proxy-agent.d.ts CHANGED
@@ -24,5 +24,6 @@ declare namespace ProxyAgent {
24
24
  requestTls?: buildConnector.BuildOptions;
25
25
  proxyTls?: buildConnector.BuildOptions;
26
26
  clientFactory?(origin: URL, opts: object): Dispatcher;
27
+ proxyTunnel?: boolean;
27
28
  }
28
29
  }
@@ -35,6 +35,15 @@ declare namespace RetryHandler {
35
35
  ) => void
36
36
 
37
37
  export interface RetryOptions {
38
+ /**
39
+ * If true, the retry handler will throw an error if the request fails,
40
+ * this will prevent the folling handlers from being called, and will destroy the socket.
41
+ *
42
+ * @type {boolean}
43
+ * @memberof RetryOptions
44
+ * @default true
45
+ */
46
+ throwOnError?: boolean;
38
47
  /**
39
48
  * Callback to be invoked on every retry iteration.
40
49
  * It receives the error, current state of the retry object and the options object
package/webidl.d.ts CHANGED
@@ -16,9 +16,12 @@ interface ConvertToIntOpts {
16
16
  }
17
17
 
18
18
  interface WebidlErrors {
19
+ /**
20
+ * @description Instantiate an error
21
+ */
19
22
  exception (opts: { header: string, message: string }): TypeError
20
23
  /**
21
- * @description Throw an error when conversion from one type to another has failed
24
+ * @description Instantiate an error when conversion from one type to another has failed
22
25
  */
23
26
  conversionFailed (opts: {
24
27
  prefix: string
@@ -75,7 +78,7 @@ interface WebidlUtil {
75
78
  ): number
76
79
 
77
80
  /**
78
- * @see https://webidl.spec.whatwg.org/#abstract-opdef-converttoint
81
+ * @see https://webidl.spec.whatwg.org/#abstract-opdef-integerpart
79
82
  */
80
83
  IntegerPart (N: number): number
81
84
 
@@ -182,20 +185,21 @@ interface WebidlConverters {
182
185
  [Key: string]: (...args: any[]) => unknown
183
186
  }
184
187
 
185
- type IsAssertion<T> = (arg: any) => arg is T
188
+ type WebidlIsFunction<T> = (arg: any) => arg is T
186
189
 
187
190
  interface WebidlIs {
188
- Request: IsAssertion<undici.Request>
189
- Response: IsAssertion<undici.Response>
190
- ReadableStream: IsAssertion<ReadableStream>
191
- Blob: IsAssertion<Blob>
192
- URLSearchParams: IsAssertion<URLSearchParams>
193
- File: IsAssertion<File>
194
- FormData: IsAssertion<undici.FormData>
195
- URL: IsAssertion<URL>
196
- WebSocketError: IsAssertion<undici.WebSocketError>
197
- AbortSignal: IsAssertion<AbortSignal>
198
- MessagePort: IsAssertion<MessagePort>
191
+ Request: WebidlIsFunction<undici.Request>
192
+ Response: WebidlIsFunction<undici.Response>
193
+ ReadableStream: WebidlIsFunction<ReadableStream>
194
+ Blob: WebidlIsFunction<Blob>
195
+ URLSearchParams: WebidlIsFunction<URLSearchParams>
196
+ File: WebidlIsFunction<File>
197
+ FormData: WebidlIsFunction<undici.FormData>
198
+ URL: WebidlIsFunction<URL>
199
+ WebSocketError: WebidlIsFunction<undici.WebSocketError>
200
+ AbortSignal: WebidlIsFunction<AbortSignal>
201
+ MessagePort: WebidlIsFunction<MessagePort>
202
+ USVString: WebidlIsFunction<string>
199
203
  }
200
204
 
201
205
  export interface Webidl {
@@ -233,7 +237,7 @@ export interface Webidl {
233
237
  * Similar to {@link Webidl.brandCheck} but allows skipping the check if third party
234
238
  * interfaces are allowed.
235
239
  */
236
- interfaceConverter <Interface>(typeCheck: IsAssertion<Interface>, name: string): (
240
+ interfaceConverter <Interface>(typeCheck: WebidlIsFunction<Interface>, name: string): (
237
241
  V: unknown,
238
242
  prefix: string,
239
243
  argument: string
package/websocket.d.ts CHANGED
@@ -136,7 +136,7 @@ interface ErrorEvent extends Event {
136
136
  readonly filename: string
137
137
  readonly lineno: number
138
138
  readonly colno: number
139
- readonly error: any
139
+ readonly error: Error
140
140
  }
141
141
 
142
142
  export declare const ErrorEvent: {