undici-types 8.1.0 → 8.3.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.
package/client.d.ts CHANGED
@@ -3,7 +3,7 @@ import Dispatcher from './dispatcher'
3
3
  import buildConnector from './connector'
4
4
  import TClientStats from './client-stats'
5
5
 
6
- type ClientConnectOptions = Omit<Dispatcher.ConnectOptions, 'origin'>
6
+ type ClientConnectOptions<TOpaque = null> = Omit<Dispatcher.ConnectOptions<TOpaque>, 'origin'>
7
7
 
8
8
  /**
9
9
  * A basic HTTP/1.1 client, mapped on top a single TCP/TLS connection. Pipelining is disabled by default.
@@ -20,12 +20,12 @@ export class Client extends Dispatcher {
20
20
  readonly stats: TClientStats
21
21
 
22
22
  // Override dispatcher APIs.
23
- override connect (
24
- options: ClientConnectOptions
25
- ): Promise<Dispatcher.ConnectData>
26
- override connect (
27
- options: ClientConnectOptions,
28
- callback: (err: Error | null, data: Dispatcher.ConnectData) => void
23
+ override connect<TOpaque = null> (
24
+ options: ClientConnectOptions<TOpaque>
25
+ ): Promise<Dispatcher.ConnectData<TOpaque>>
26
+ override connect<TOpaque = null> (
27
+ options: ClientConnectOptions<TOpaque>,
28
+ callback: (err: Error | null, data: Dispatcher.ConnectData<TOpaque>) => void
29
29
  ): void
30
30
  }
31
31
 
package/dispatcher.d.ts CHANGED
@@ -2,7 +2,7 @@ import { URL } from 'node:url'
2
2
  import { Duplex, Readable, Writable } from 'node:stream'
3
3
  import { EventEmitter } from 'node:events'
4
4
  import { Blob } from 'node:buffer'
5
- import { IncomingHttpHeaders } from './header'
5
+ import { IncomingHttpHeaders, OutgoingHttpHeaders } from './header'
6
6
  import BodyReadable from './readable'
7
7
  import { FormData } from './formdata'
8
8
  import Errors from './errors'
@@ -10,7 +10,7 @@ import { Autocomplete } from './utility'
10
10
 
11
11
  export default Dispatcher
12
12
 
13
- export type UndiciHeaders = Record<string, string | string[]> | IncomingHttpHeaders | string[] | Iterable<[string, string | string[] | undefined]> | null
13
+ export type UndiciHeaders = OutgoingHttpHeaders | string[] | Iterable<[string, string | string[] | undefined]> | null
14
14
 
15
15
  /** Dispatcher is the core API used to dispatch requests. */
16
16
  declare class Dispatcher extends EventEmitter {
@@ -121,8 +121,6 @@ declare namespace Dispatcher {
121
121
  bodyTimeout?: number | null;
122
122
  /** Whether the request should stablish a keep-alive or not. Default `false` */
123
123
  reset?: boolean;
124
- /** Whether Undici should throw an error upon receiving a 4xx or 5xx response from the server. Defaults to false */
125
- throwOnError?: boolean;
126
124
  /** For H2, it appends the expect: 100-continue header, and halts the request body until a 100-continue is received from the remote server */
127
125
  expectContinue?: boolean;
128
126
  }
@@ -210,8 +208,8 @@ declare namespace Dispatcher {
210
208
  get aborted(): boolean
211
209
  get paused(): boolean
212
210
  get reason(): Error | null
213
- rawHeaders?: Buffer[] | string[] | null
214
- rawTrailers?: Buffer[] | string[] | null
211
+ rawHeaders?: Buffer[] | string[] | IncomingHttpHeaders | null
212
+ rawTrailers?: Buffer[] | string[] | IncomingHttpHeaders | null
215
213
  abort(reason: Error): void
216
214
  pause(): void
217
215
  resume(): void
package/formdata.d.ts CHANGED
@@ -4,12 +4,6 @@
4
4
  import { File } from 'node:buffer'
5
5
  import { SpecIterableIterator } from './fetch'
6
6
 
7
- declare module 'node:buffer' {
8
- interface File {
9
- readonly [Symbol.toStringTag]: string
10
- }
11
- }
12
-
13
7
  /**
14
8
  * A `string` or `File` that represents a single value from a set of `FormData` key-value pairs.
15
9
  */
package/header.d.ts CHANGED
@@ -5,6 +5,11 @@ import { Autocomplete } from './utility'
5
5
  */
6
6
  export type IncomingHttpHeaders = Record<string, string | string[] | undefined>
7
7
 
8
+ /**
9
+ * The header type declaration of `undici` for outgoing requests.
10
+ */
11
+ export type OutgoingHttpHeaders = Record<string, number | string | string[] | undefined>
12
+
8
13
  type HeaderNames = Autocomplete<
9
14
  | 'Accept'
10
15
  | 'Accept-CH'
package/interceptors.d.ts CHANGED
@@ -8,7 +8,7 @@ export default Interceptors
8
8
  declare namespace Interceptors {
9
9
  export type DumpInterceptorOpts = { maxSize?: number }
10
10
  export type RetryInterceptorOpts = RetryHandler.RetryOptions
11
- export type RedirectInterceptorOpts = { maxRedirections?: number }
11
+ export type RedirectInterceptorOpts = { maxRedirections?: number, throwOnMaxRedirect?: boolean }
12
12
  export type DecompressInterceptorOpts = {
13
13
  skipErrorResponses?: boolean
14
14
  skipStatusCodes?: number[]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "undici-types",
3
- "version": "8.1.0",
3
+ "version": "8.3.0",
4
4
  "description": "A stand-alone types package for Undici",
5
5
  "homepage": "https://undici.nodejs.org",
6
6
  "bugs": {
package/proxy-agent.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import Agent from './agent'
2
2
  import buildConnector from './connector'
3
3
  import Dispatcher from './dispatcher'
4
- import { IncomingHttpHeaders } from './header'
4
+ import { OutgoingHttpHeaders } from './header'
5
5
 
6
6
  export default ProxyAgent
7
7
 
@@ -20,7 +20,7 @@ declare namespace ProxyAgent {
20
20
  */
21
21
  auth?: string;
22
22
  token?: string;
23
- headers?: IncomingHttpHeaders;
23
+ headers?: OutgoingHttpHeaders;
24
24
  requestTls?: buildConnector.BuildOptions;
25
25
  proxyTls?: buildConnector.BuildOptions;
26
26
  clientFactory?(origin: URL, opts: object): Dispatcher;
@@ -30,7 +30,9 @@ declare namespace SnapshotRecorder {
30
30
  ignoreHeaders?: string[]
31
31
  excludeHeaders?: string[]
32
32
  matchBody?: boolean
33
+ normalizeBody?: (body: string | Buffer | null | undefined) => string
33
34
  matchQuery?: boolean
35
+ normalizeQuery?: (query: URLSearchParams) => string
34
36
  caseSensitive?: boolean
35
37
  shouldRecord?: (requestOpts: any) => boolean
36
38
  shouldPlayback?: (requestOpts: any) => boolean
@@ -98,7 +100,9 @@ declare namespace SnapshotAgent {
98
100
  ignoreHeaders?: string[]
99
101
  excludeHeaders?: string[]
100
102
  matchBody?: boolean
103
+ normalizeBody?: (body: string | Buffer | null | undefined) => string
101
104
  matchQuery?: boolean
105
+ normalizeQuery?: (query: URLSearchParams) => string
102
106
  caseSensitive?: boolean
103
107
  shouldRecord?: (requestOpts: any) => boolean
104
108
  shouldPlayback?: (requestOpts: any) => boolean
@@ -1,6 +1,6 @@
1
1
  import Dispatcher from './dispatcher'
2
2
  import buildConnector from './connector'
3
- import { IncomingHttpHeaders } from './header'
3
+ import { OutgoingHttpHeaders } from './header'
4
4
  import Pool from './pool'
5
5
 
6
6
  export default Socks5ProxyAgent
@@ -12,7 +12,7 @@ declare class Socks5ProxyAgent extends Dispatcher {
12
12
  declare namespace Socks5ProxyAgent {
13
13
  export interface Options extends Pool.Options {
14
14
  /** Additional headers to send with the proxy connection */
15
- headers?: IncomingHttpHeaders;
15
+ headers?: OutgoingHttpHeaders;
16
16
  /** SOCKS5 proxy username for authentication */
17
17
  username?: string;
18
18
  /** SOCKS5 proxy password for authentication */