undici-types 7.10.0 → 7.12.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.10.0",
3
+ "version": "7.12.0",
4
4
  "description": "A stand-alone types package for Undici",
5
5
  "homepage": "https://undici.nodejs.org",
6
6
  "bugs": {
@@ -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
 
@@ -179,23 +182,34 @@ interface WebidlConverters {
179
182
 
180
183
  ['record<ByteString, ByteString>']: RecordConverter<string, string>
181
184
 
185
+ /**
186
+ * @see https://fetch.spec.whatwg.org/#requestinfo
187
+ */
188
+ RequestInfo (V: unknown): undici.Request | string
189
+
190
+ /**
191
+ * @see https://fetch.spec.whatwg.org/#requestinit
192
+ */
193
+ RequestInit (V: unknown): undici.RequestInit
194
+
182
195
  [Key: string]: (...args: any[]) => unknown
183
196
  }
184
197
 
185
- type IsAssertion<T> = (arg: any) => arg is T
198
+ type WebidlIsFunction<T> = (arg: any) => arg is T
186
199
 
187
200
  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>
201
+ Request: WebidlIsFunction<undici.Request>
202
+ Response: WebidlIsFunction<undici.Response>
203
+ ReadableStream: WebidlIsFunction<ReadableStream>
204
+ Blob: WebidlIsFunction<Blob>
205
+ URLSearchParams: WebidlIsFunction<URLSearchParams>
206
+ File: WebidlIsFunction<File>
207
+ FormData: WebidlIsFunction<undici.FormData>
208
+ URL: WebidlIsFunction<URL>
209
+ WebSocketError: WebidlIsFunction<undici.WebSocketError>
210
+ AbortSignal: WebidlIsFunction<AbortSignal>
211
+ MessagePort: WebidlIsFunction<MessagePort>
212
+ USVString: WebidlIsFunction<string>
199
213
  }
200
214
 
201
215
  export interface Webidl {
@@ -233,7 +247,7 @@ export interface Webidl {
233
247
  * Similar to {@link Webidl.brandCheck} but allows skipping the check if third party
234
248
  * interfaces are allowed.
235
249
  */
236
- interfaceConverter <Interface>(typeCheck: IsAssertion<Interface>, name: string): (
250
+ interfaceConverter <Interface>(typeCheck: WebidlIsFunction<Interface>, name: string): (
237
251
  V: unknown,
238
252
  prefix: string,
239
253
  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: {
@@ -182,3 +182,5 @@ export declare const WebSocketError: {
182
182
  prototype: WebSocketError
183
183
  new (type: string, init?: WebSocketCloseInfo): WebSocketError
184
184
  }
185
+
186
+ export declare const ping: (ws: WebSocket, body?: Buffer) => void