undici-types 6.21.0 → 7.8.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/fetch.d.ts CHANGED
@@ -6,7 +6,7 @@ import { Blob } from 'buffer'
6
6
  import { URL, URLSearchParams } from 'url'
7
7
  import { ReadableStream } from 'stream/web'
8
8
  import { FormData } from './formdata'
9
-
9
+ import { HeaderRecord } from './header'
10
10
  import Dispatcher from './dispatcher'
11
11
 
12
12
  export type RequestInfo = string | URL | Request
@@ -36,17 +36,17 @@ export class BodyMixin {
36
36
  /**
37
37
  * @deprecated This method is not recommended for parsing multipart/form-data bodies in server environments.
38
38
  * It is recommended to use a library such as [@fastify/busboy](https://www.npmjs.com/package/@fastify/busboy) as follows:
39
- *
39
+ *
40
40
  * @example
41
41
  * ```js
42
42
  * import { Busboy } from '@fastify/busboy'
43
43
  * import { Readable } from 'node:stream'
44
- *
44
+ *
45
45
  * const response = await fetch('...')
46
46
  * const busboy = new Busboy({ headers: { 'content-type': response.headers.get('content-type') } })
47
- *
47
+ *
48
48
  * // handle events emitted from `busboy`
49
- *
49
+ *
50
50
  * Readable.fromWeb(response.body).pipe(busboy)
51
51
  * ```
52
52
  */
@@ -67,7 +67,7 @@ export interface SpecIterable<T> {
67
67
  [Symbol.iterator](): SpecIterator<T>;
68
68
  }
69
69
 
70
- export type HeadersInit = string[][] | Record<string, string | ReadonlyArray<string>> | Headers
70
+ export type HeadersInit = [string, string][] | HeaderRecord | Headers
71
71
 
72
72
  export declare class Headers implements SpecIterable<[string, string]> {
73
73
  constructor (init?: HeadersInit)
@@ -119,20 +119,21 @@ type RequestDestination =
119
119
  | 'xslt'
120
120
 
121
121
  export interface RequestInit {
122
- method?: string
123
- keepalive?: boolean
124
- headers?: HeadersInit
125
122
  body?: BodyInit | null
126
- redirect?: RequestRedirect
127
- integrity?: string
128
- signal?: AbortSignal | null
123
+ cache?: RequestCache
129
124
  credentials?: RequestCredentials
125
+ dispatcher?: Dispatcher
126
+ duplex?: RequestDuplex
127
+ headers?: HeadersInit
128
+ integrity?: string
129
+ keepalive?: boolean
130
+ method?: string
130
131
  mode?: RequestMode
132
+ redirect?: RequestRedirect
131
133
  referrer?: string
132
134
  referrerPolicy?: ReferrerPolicy
135
+ signal?: AbortSignal | null
133
136
  window?: null
134
- dispatcher?: Dispatcher
135
- duplex?: RequestDuplex
136
137
  }
137
138
 
138
139
  export type ReferrerPolicy =
@@ -144,7 +145,7 @@ export type ReferrerPolicy =
144
145
  | 'same-origin'
145
146
  | 'strict-origin'
146
147
  | 'strict-origin-when-cross-origin'
147
- | 'unsafe-url';
148
+ | 'unsafe-url'
148
149
 
149
150
  export type RequestMode = 'cors' | 'navigate' | 'no-cors' | 'same-origin'
150
151
 
@@ -204,6 +205,6 @@ export declare class Response extends BodyMixin {
204
205
  readonly clone: () => Response
205
206
 
206
207
  static error (): Response
207
- static json(data: any, init?: ResponseInit): Response
208
+ static json (data: any, init?: ResponseInit): Response
208
209
  static redirect (url: string | URL, status: ResponseRedirectStatus): Response
209
210
  }
package/formdata.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  // Based on https://github.com/octet-stream/form-data/blob/2d0f0dc371517444ce1f22cdde13f51995d0953a/lib/FormData.ts (MIT)
2
2
  /// <reference types="node" />
3
3
 
4
- import { File } from './file'
4
+ import { File } from 'buffer'
5
5
  import { SpecIterableIterator } from './fetch'
6
6
 
7
7
  /**
@@ -24,7 +24,7 @@ export declare class FormData {
24
24
  or [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File). If none of these are specified the value is converted to a string.
25
25
  * @param fileName The filename reported to the server, when a Blob or File is passed as the second parameter. The default filename for Blob objects is "blob". The default filename for File objects is the file's filename.
26
26
  */
27
- append(name: string, value: unknown, fileName?: string): void
27
+ append (name: string, value: unknown, fileName?: string): void
28
28
 
29
29
  /**
30
30
  * Set a new value for an existing key inside FormData,
@@ -36,7 +36,7 @@ export declare class FormData {
36
36
  * @param fileName The filename reported to the server, when a Blob or File is passed as the second parameter. The default filename for Blob objects is "blob". The default filename for File objects is the file's filename.
37
37
  *
38
38
  */
39
- set(name: string, value: unknown, fileName?: string): void
39
+ set (name: string, value: unknown, fileName?: string): void
40
40
 
41
41
  /**
42
42
  * Returns the first value associated with a given key from within a `FormData` object.
@@ -46,7 +46,7 @@ export declare class FormData {
46
46
  *
47
47
  * @returns A `FormDataEntryValue` containing the value. If the key doesn't exist, the method returns null.
48
48
  */
49
- get(name: string): FormDataEntryValue | null
49
+ get (name: string): FormDataEntryValue | null
50
50
 
51
51
  /**
52
52
  * Returns all the values associated with a given key from within a `FormData` object.
@@ -55,7 +55,7 @@ export declare class FormData {
55
55
  *
56
56
  * @returns An array of `FormDataEntryValue` whose key matches the value passed in the `name` parameter. If the key doesn't exist, the method returns an empty list.
57
57
  */
58
- getAll(name: string): FormDataEntryValue[]
58
+ getAll (name: string): FormDataEntryValue[]
59
59
 
60
60
  /**
61
61
  * Returns a boolean stating whether a `FormData` object contains a certain key.
@@ -64,14 +64,14 @@ export declare class FormData {
64
64
  *
65
65
  * @return A boolean value.
66
66
  */
67
- has(name: string): boolean
67
+ has (name: string): boolean
68
68
 
69
69
  /**
70
70
  * Deletes a key and its value(s) from a `FormData` object.
71
71
  *
72
72
  * @param name The name of the key you want to delete.
73
73
  */
74
- delete(name: string): void
74
+ delete (name: string): void
75
75
 
76
76
  /**
77
77
  * Executes given callback function for each field of the FormData instance
@@ -1,9 +1,9 @@
1
- import Dispatcher from "./dispatcher";
1
+ import Dispatcher from './dispatcher'
2
+
3
+ declare function setGlobalDispatcher<DispatcherImplementation extends Dispatcher> (dispatcher: DispatcherImplementation): void
4
+ declare function getGlobalDispatcher (): Dispatcher
2
5
 
3
6
  export {
4
7
  getGlobalDispatcher,
5
8
  setGlobalDispatcher
6
9
  }
7
-
8
- declare function setGlobalDispatcher<DispatcherImplementation extends Dispatcher>(dispatcher: DispatcherImplementation): void;
9
- declare function getGlobalDispatcher(): Dispatcher;
@@ -1,7 +1,7 @@
1
+ declare function setGlobalOrigin (origin: string | URL | undefined): void
2
+ declare function getGlobalOrigin (): URL | undefined
3
+
1
4
  export {
2
- setGlobalOrigin,
3
- getGlobalOrigin
5
+ setGlobalOrigin,
6
+ getGlobalOrigin
4
7
  }
5
-
6
- declare function setGlobalOrigin(origin: string | URL | undefined): void;
7
- declare function getGlobalOrigin(): URL | undefined;
@@ -0,0 +1,75 @@
1
+ import { URL } from 'url'
2
+ import Dispatcher from './dispatcher'
3
+ import buildConnector from './connector'
4
+
5
+ type H2ClientOptions = Omit<Dispatcher.ConnectOptions, 'origin'>
6
+
7
+ /**
8
+ * A basic H2C client, mapped on top a single TCP connection. Pipelining is disabled by default.
9
+ */
10
+ export class H2CClient extends Dispatcher {
11
+ constructor (url: string | URL, options?: H2CClient.Options)
12
+ /** Property to get and set the pipelining factor. */
13
+ pipelining: number
14
+ /** `true` after `client.close()` has been called. */
15
+ closed: boolean
16
+ /** `true` after `client.destroyed()` has been called or `client.close()` has been called and the client shutdown has completed. */
17
+ destroyed: boolean
18
+
19
+ // Override dispatcher APIs.
20
+ override connect (
21
+ options: H2ClientOptions
22
+ ): Promise<Dispatcher.ConnectData>
23
+ override connect (
24
+ options: H2ClientOptions,
25
+ callback: (err: Error | null, data: Dispatcher.ConnectData) => void
26
+ ): void
27
+ }
28
+
29
+ export declare namespace H2CClient {
30
+ export interface Options {
31
+ /** The maximum length of request headers in bytes. Default: Node.js' `--max-http-header-size` or `16384` (16KiB). */
32
+ maxHeaderSize?: number;
33
+ /** The amount of time, in milliseconds, the parser will wait to receive the complete HTTP headers (Node 14 and above only). Default: `300e3` milliseconds (300s). */
34
+ headersTimeout?: number;
35
+ /** TODO */
36
+ connectTimeout?: number;
37
+ /** The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Default: `300e3` milliseconds (300s). */
38
+ bodyTimeout?: number;
39
+ /** the timeout, in milliseconds, after which a socket without active requests will time out. Monitors time between activity on a connected socket. This value may be overridden by *keep-alive* hints from the server. Default: `4e3` milliseconds (4s). */
40
+ keepAliveTimeout?: number;
41
+ /** the maximum allowed `idleTimeout`, in milliseconds, when overridden by *keep-alive* hints from the server. Default: `600e3` milliseconds (10min). */
42
+ keepAliveMaxTimeout?: number;
43
+ /** A number of milliseconds subtracted from server *keep-alive* hints when overriding `idleTimeout` to account for timing inaccuracies caused by e.g. transport latency. Default: `1e3` milliseconds (1s). */
44
+ keepAliveTimeoutThreshold?: number;
45
+ /** TODO */
46
+ socketPath?: string;
47
+ /** The amount of concurrent requests to be sent over the single TCP/TLS connection according to [RFC7230](https://tools.ietf.org/html/rfc7230#section-6.3.2). Default: `1`. */
48
+ pipelining?: number;
49
+ /** If `true`, an error is thrown when the request content-length header doesn't match the length of the request body. Default: `true`. */
50
+ strictContentLength?: boolean;
51
+ /** TODO */
52
+ maxCachedSessions?: number;
53
+ /** TODO */
54
+ maxRedirections?: number;
55
+ /** TODO */
56
+ connect?: Omit<Partial<buildConnector.BuildOptions>, 'allowH2'> | buildConnector.connector;
57
+ /** TODO */
58
+ maxRequestsPerClient?: number;
59
+ /** TODO */
60
+ localAddress?: string;
61
+ /** Max response body size in bytes, -1 is disabled */
62
+ maxResponseSize?: number;
63
+ /** Enables a family autodetection algorithm that loosely implements section 5 of RFC 8305. */
64
+ autoSelectFamily?: boolean;
65
+ /** The amount of time in milliseconds to wait for a connection attempt to finish before trying the next address when using the `autoSelectFamily` option. */
66
+ autoSelectFamilyAttemptTimeout?: number;
67
+ /**
68
+ * @description Dictates the maximum number of concurrent streams for a single H2 session. It can be overridden by a SETTINGS remote frame.
69
+ * @default 100
70
+ */
71
+ maxConcurrentStreams?: number
72
+ }
73
+ }
74
+
75
+ export default H2CClient
package/handlers.d.ts CHANGED
@@ -1,15 +1,15 @@
1
- import Dispatcher from "./dispatcher";
1
+ import Dispatcher from './dispatcher'
2
2
 
3
- export declare class RedirectHandler implements Dispatcher.DispatchHandlers {
4
- constructor(
3
+ export declare class RedirectHandler implements Dispatcher.DispatchHandler {
4
+ constructor (
5
5
  dispatch: Dispatcher,
6
6
  maxRedirections: number,
7
7
  opts: Dispatcher.DispatchOptions,
8
- handler: Dispatcher.DispatchHandlers,
8
+ handler: Dispatcher.DispatchHandler,
9
9
  redirectionLimitReached: boolean
10
- );
10
+ )
11
11
  }
12
12
 
13
- export declare class DecoratorHandler implements Dispatcher.DispatchHandlers {
14
- constructor(handler: Dispatcher.DispatchHandlers);
13
+ export declare class DecoratorHandler implements Dispatcher.DispatchHandler {
14
+ constructor (handler: Dispatcher.DispatchHandler)
15
15
  }
package/header.d.ts CHANGED
@@ -1,4 +1,160 @@
1
+ import { Autocomplete } from './utility'
2
+
1
3
  /**
2
4
  * The header type declaration of `undici`.
3
5
  */
4
- export type IncomingHttpHeaders = Record<string, string | string[] | undefined>;
6
+ export type IncomingHttpHeaders = Record<string, string | string[] | undefined>
7
+
8
+ type HeaderNames = Autocomplete<
9
+ | 'Accept'
10
+ | 'Accept-CH'
11
+ | 'Accept-Charset'
12
+ | 'Accept-Encoding'
13
+ | 'Accept-Language'
14
+ | 'Accept-Patch'
15
+ | 'Accept-Post'
16
+ | 'Accept-Ranges'
17
+ | 'Access-Control-Allow-Credentials'
18
+ | 'Access-Control-Allow-Headers'
19
+ | 'Access-Control-Allow-Methods'
20
+ | 'Access-Control-Allow-Origin'
21
+ | 'Access-Control-Expose-Headers'
22
+ | 'Access-Control-Max-Age'
23
+ | 'Access-Control-Request-Headers'
24
+ | 'Access-Control-Request-Method'
25
+ | 'Age'
26
+ | 'Allow'
27
+ | 'Alt-Svc'
28
+ | 'Alt-Used'
29
+ | 'Authorization'
30
+ | 'Cache-Control'
31
+ | 'Clear-Site-Data'
32
+ | 'Connection'
33
+ | 'Content-Disposition'
34
+ | 'Content-Encoding'
35
+ | 'Content-Language'
36
+ | 'Content-Length'
37
+ | 'Content-Location'
38
+ | 'Content-Range'
39
+ | 'Content-Security-Policy'
40
+ | 'Content-Security-Policy-Report-Only'
41
+ | 'Content-Type'
42
+ | 'Cookie'
43
+ | 'Cross-Origin-Embedder-Policy'
44
+ | 'Cross-Origin-Opener-Policy'
45
+ | 'Cross-Origin-Resource-Policy'
46
+ | 'Date'
47
+ | 'Device-Memory'
48
+ | 'ETag'
49
+ | 'Expect'
50
+ | 'Expect-CT'
51
+ | 'Expires'
52
+ | 'Forwarded'
53
+ | 'From'
54
+ | 'Host'
55
+ | 'If-Match'
56
+ | 'If-Modified-Since'
57
+ | 'If-None-Match'
58
+ | 'If-Range'
59
+ | 'If-Unmodified-Since'
60
+ | 'Keep-Alive'
61
+ | 'Last-Modified'
62
+ | 'Link'
63
+ | 'Location'
64
+ | 'Max-Forwards'
65
+ | 'Origin'
66
+ | 'Permissions-Policy'
67
+ | 'Priority'
68
+ | 'Proxy-Authenticate'
69
+ | 'Proxy-Authorization'
70
+ | 'Range'
71
+ | 'Referer'
72
+ | 'Referrer-Policy'
73
+ | 'Retry-After'
74
+ | 'Sec-Fetch-Dest'
75
+ | 'Sec-Fetch-Mode'
76
+ | 'Sec-Fetch-Site'
77
+ | 'Sec-Fetch-User'
78
+ | 'Sec-Purpose'
79
+ | 'Sec-WebSocket-Accept'
80
+ | 'Server'
81
+ | 'Server-Timing'
82
+ | 'Service-Worker-Navigation-Preload'
83
+ | 'Set-Cookie'
84
+ | 'SourceMap'
85
+ | 'Strict-Transport-Security'
86
+ | 'TE'
87
+ | 'Timing-Allow-Origin'
88
+ | 'Trailer'
89
+ | 'Transfer-Encoding'
90
+ | 'Upgrade'
91
+ | 'Upgrade-Insecure-Requests'
92
+ | 'User-Agent'
93
+ | 'Vary'
94
+ | 'Via'
95
+ | 'WWW-Authenticate'
96
+ | 'X-Content-Type-Options'
97
+ | 'X-Frame-Options'
98
+ >
99
+
100
+ type IANARegisteredMimeType = Autocomplete<
101
+ | 'audio/aac'
102
+ | 'video/x-msvideo'
103
+ | 'image/avif'
104
+ | 'video/av1'
105
+ | 'application/octet-stream'
106
+ | 'image/bmp'
107
+ | 'text/css'
108
+ | 'text/csv'
109
+ | 'application/vnd.ms-fontobject'
110
+ | 'application/epub+zip'
111
+ | 'image/gif'
112
+ | 'application/gzip'
113
+ | 'text/html'
114
+ | 'image/x-icon'
115
+ | 'text/calendar'
116
+ | 'image/jpeg'
117
+ | 'text/javascript'
118
+ | 'application/json'
119
+ | 'application/ld+json'
120
+ | 'audio/x-midi'
121
+ | 'audio/mpeg'
122
+ | 'video/mp4'
123
+ | 'video/mpeg'
124
+ | 'audio/ogg'
125
+ | 'video/ogg'
126
+ | 'application/ogg'
127
+ | 'audio/opus'
128
+ | 'font/otf'
129
+ | 'application/pdf'
130
+ | 'image/png'
131
+ | 'application/rtf'
132
+ | 'image/svg+xml'
133
+ | 'image/tiff'
134
+ | 'video/mp2t'
135
+ | 'font/ttf'
136
+ | 'text/plain'
137
+ | 'application/wasm'
138
+ | 'video/webm'
139
+ | 'audio/webm'
140
+ | 'image/webp'
141
+ | 'font/woff'
142
+ | 'font/woff2'
143
+ | 'application/xhtml+xml'
144
+ | 'application/xml'
145
+ | 'application/zip'
146
+ | 'video/3gpp'
147
+ | 'video/3gpp2'
148
+ | 'model/gltf+json'
149
+ | 'model/gltf-binary'
150
+ >
151
+
152
+ type KnownHeaderValues = {
153
+ 'content-type': IANARegisteredMimeType
154
+ }
155
+
156
+ export type HeaderRecord = {
157
+ [K in HeaderNames | Lowercase<HeaderNames>]?: Lowercase<K> extends keyof KnownHeaderValues
158
+ ? KnownHeaderValues[Lowercase<K>]
159
+ : string
160
+ }
package/index.d.ts CHANGED
@@ -1,22 +1,24 @@
1
- import Dispatcher from'./dispatcher'
1
+ import Dispatcher from './dispatcher'
2
2
  import { setGlobalDispatcher, getGlobalDispatcher } from './global-dispatcher'
3
3
  import { setGlobalOrigin, getGlobalOrigin } from './global-origin'
4
- import Pool from'./pool'
4
+ import Pool from './pool'
5
5
  import { RedirectHandler, DecoratorHandler } from './handlers'
6
6
 
7
7
  import BalancedPool from './balanced-pool'
8
- import Client from'./client'
9
- import buildConnector from'./connector'
10
- import errors from'./errors'
11
- import Agent from'./agent'
12
- import MockClient from'./mock-client'
13
- import MockPool from'./mock-pool'
14
- import MockAgent from'./mock-agent'
15
- import mockErrors from'./mock-errors'
16
- import ProxyAgent from'./proxy-agent'
8
+ import Client from './client'
9
+ import H2CClient from './h2c-client'
10
+ import buildConnector from './connector'
11
+ import errors from './errors'
12
+ import Agent from './agent'
13
+ import MockClient from './mock-client'
14
+ import MockPool from './mock-pool'
15
+ import MockAgent from './mock-agent'
16
+ import { MockCallHistory, MockCallHistoryLog } from './mock-call-history'
17
+ import mockErrors from './mock-errors'
18
+ import ProxyAgent from './proxy-agent'
17
19
  import EnvHttpProxyAgent from './env-http-proxy-agent'
18
- import RetryHandler from'./retry-handler'
19
- import RetryAgent from'./retry-agent'
20
+ import RetryHandler from './retry-handler'
21
+ import RetryAgent from './retry-agent'
20
22
  import { request, pipeline, stream, connect, upgrade } from './api'
21
23
  import interceptors from './interceptors'
22
24
 
@@ -24,8 +26,6 @@ export * from './util'
24
26
  export * from './cookies'
25
27
  export * from './eventsource'
26
28
  export * from './fetch'
27
- export * from './file'
28
- export * from './filereader'
29
29
  export * from './formdata'
30
30
  export * from './diagnostics-channel'
31
31
  export * from './websocket'
@@ -33,39 +33,43 @@ export * from './content-type'
33
33
  export * from './cache'
34
34
  export { Interceptable } from './mock-interceptor'
35
35
 
36
- export { Dispatcher, BalancedPool, Pool, Client, buildConnector, errors, Agent, request, stream, pipeline, connect, upgrade, setGlobalDispatcher, getGlobalDispatcher, setGlobalOrigin, getGlobalOrigin, interceptors, MockClient, MockPool, MockAgent, mockErrors, ProxyAgent, EnvHttpProxyAgent, RedirectHandler, DecoratorHandler, RetryHandler, RetryAgent }
36
+ export { Dispatcher, BalancedPool, Pool, Client, buildConnector, errors, Agent, request, stream, pipeline, connect, upgrade, setGlobalDispatcher, getGlobalDispatcher, setGlobalOrigin, getGlobalOrigin, interceptors, MockClient, MockPool, MockAgent, MockCallHistory, MockCallHistoryLog, mockErrors, ProxyAgent, EnvHttpProxyAgent, RedirectHandler, DecoratorHandler, RetryHandler, RetryAgent, H2CClient }
37
37
  export default Undici
38
38
 
39
39
  declare namespace Undici {
40
- var Dispatcher: typeof import('./dispatcher').default
41
- var Pool: typeof import('./pool').default;
42
- var RedirectHandler: typeof import ('./handlers').RedirectHandler
43
- var DecoratorHandler: typeof import ('./handlers').DecoratorHandler
44
- var RetryHandler: typeof import ('./retry-handler').default
45
- var createRedirectInterceptor: typeof import ('./interceptors').default.createRedirectInterceptor
46
- var BalancedPool: typeof import('./balanced-pool').default;
47
- var Client: typeof import('./client').default;
48
- var buildConnector: typeof import('./connector').default;
49
- var errors: typeof import('./errors').default;
50
- var Agent: typeof import('./agent').default;
51
- var setGlobalDispatcher: typeof import('./global-dispatcher').setGlobalDispatcher;
52
- var getGlobalDispatcher: typeof import('./global-dispatcher').getGlobalDispatcher;
53
- var request: typeof import('./api').request;
54
- var stream: typeof import('./api').stream;
55
- var pipeline: typeof import('./api').pipeline;
56
- var connect: typeof import('./api').connect;
57
- var upgrade: typeof import('./api').upgrade;
58
- var MockClient: typeof import('./mock-client').default;
59
- var MockPool: typeof import('./mock-pool').default;
60
- var MockAgent: typeof import('./mock-agent').default;
61
- var mockErrors: typeof import('./mock-errors').default;
62
- var fetch: typeof import('./fetch').fetch;
63
- var Headers: typeof import('./fetch').Headers;
64
- var Response: typeof import('./fetch').Response;
65
- var Request: typeof import('./fetch').Request;
66
- var FormData: typeof import('./formdata').FormData;
67
- var File: typeof import('./file').File;
68
- var FileReader: typeof import('./filereader').FileReader;
69
- var caches: typeof import('./cache').caches;
70
- var interceptors: typeof import('./interceptors').default;
40
+ const Dispatcher: typeof import('./dispatcher').default
41
+ const Pool: typeof import('./pool').default
42
+ const RedirectHandler: typeof import ('./handlers').RedirectHandler
43
+ const DecoratorHandler: typeof import ('./handlers').DecoratorHandler
44
+ const RetryHandler: typeof import ('./retry-handler').default
45
+ const BalancedPool: typeof import('./balanced-pool').default
46
+ const Client: typeof import('./client').default
47
+ const H2CClient: typeof import('./h2c-client').default
48
+ const buildConnector: typeof import('./connector').default
49
+ const errors: typeof import('./errors').default
50
+ const Agent: typeof import('./agent').default
51
+ const setGlobalDispatcher: typeof import('./global-dispatcher').setGlobalDispatcher
52
+ const getGlobalDispatcher: typeof import('./global-dispatcher').getGlobalDispatcher
53
+ const request: typeof import('./api').request
54
+ const stream: typeof import('./api').stream
55
+ const pipeline: typeof import('./api').pipeline
56
+ const connect: typeof import('./api').connect
57
+ const upgrade: typeof import('./api').upgrade
58
+ const MockClient: typeof import('./mock-client').default
59
+ const MockPool: typeof import('./mock-pool').default
60
+ const MockAgent: typeof import('./mock-agent').default
61
+ const MockCallHistory: typeof import('./mock-call-history').MockCallHistory
62
+ const MockCallHistoryLog: typeof import('./mock-call-history').MockCallHistoryLog
63
+ const mockErrors: typeof import('./mock-errors').default
64
+ const fetch: typeof import('./fetch').fetch
65
+ const Headers: typeof import('./fetch').Headers
66
+ const Response: typeof import('./fetch').Response
67
+ const Request: typeof import('./fetch').Request
68
+ const FormData: typeof import('./formdata').FormData
69
+ const caches: typeof import('./cache').caches
70
+ const interceptors: typeof import('./interceptors').default
71
+ const cacheStores: {
72
+ MemoryCacheStore: typeof import('./cache-interceptor').default.MemoryCacheStore,
73
+ SqliteCacheStore: typeof import('./cache-interceptor').default.SqliteCacheStore
74
+ }
71
75
  }
package/interceptors.d.ts CHANGED
@@ -1,17 +1,34 @@
1
- import Dispatcher from "./dispatcher";
2
- import RetryHandler from "./retry-handler";
1
+ import CacheHandler from './cache-interceptor'
2
+ import Dispatcher from './dispatcher'
3
+ import RetryHandler from './retry-handler'
4
+ import { LookupOptions } from 'node:dns'
3
5
 
4
- export default Interceptors;
6
+ export default Interceptors
5
7
 
6
8
  declare namespace Interceptors {
7
9
  export type DumpInterceptorOpts = { maxSize?: number }
8
10
  export type RetryInterceptorOpts = RetryHandler.RetryOptions
9
11
  export type RedirectInterceptorOpts = { maxRedirections?: number }
12
+
10
13
  export type ResponseErrorInterceptorOpts = { throwOnError: boolean }
14
+ export type CacheInterceptorOpts = CacheHandler.CacheOptions
15
+
16
+ // DNS interceptor
17
+ export type DNSInterceptorRecord = { address: string, ttl: number, family: 4 | 6 }
18
+ export type DNSInterceptorOriginRecords = { 4: { ips: DNSInterceptorRecord[] } | null, 6: { ips: DNSInterceptorRecord[] } | null }
19
+ export type DNSInterceptorOpts = {
20
+ maxTTL?: number
21
+ maxItems?: number
22
+ lookup?: (hostname: string, options: LookupOptions, callback: (err: NodeJS.ErrnoException | null, addresses: DNSInterceptorRecord[]) => void) => void
23
+ pick?: (origin: URL, records: DNSInterceptorOriginRecords, affinity: 4 | 6) => DNSInterceptorRecord
24
+ dualStack?: boolean
25
+ affinity?: 4 | 6
26
+ }
11
27
 
12
- export function createRedirectInterceptor(opts: RedirectInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
13
- export function dump(opts?: DumpInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
14
- export function retry(opts?: RetryInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
15
- export function redirect(opts?: RedirectInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
16
- export function responseError(opts?: ResponseErrorInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
28
+ export function dump (opts?: DumpInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
29
+ export function retry (opts?: RetryInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
30
+ export function redirect (opts?: RedirectInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
31
+ export function responseError (opts?: ResponseErrorInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
32
+ export function dns (opts?: DNSInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
33
+ export function cache (opts?: CacheInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
17
34
  }