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/agent.d.ts +7 -7
- package/api.d.ts +24 -24
- package/balanced-pool.d.ts +11 -11
- package/cache-interceptor.d.ts +172 -0
- package/client.d.ts +12 -13
- package/cookies.d.ts +2 -0
- package/diagnostics-channel.d.ts +10 -10
- package/dispatcher.d.ts +117 -92
- package/env-http-proxy-agent.d.ts +2 -2
- package/errors.d.ts +69 -47
- package/fetch.d.ts +17 -16
- package/formdata.d.ts +7 -7
- package/global-dispatcher.d.ts +4 -4
- package/global-origin.d.ts +5 -5
- package/h2c-client.d.ts +75 -0
- package/handlers.d.ts +7 -7
- package/header.d.ts +157 -1
- package/index.d.ts +51 -47
- package/interceptors.d.ts +25 -8
- package/mock-agent.d.ts +33 -18
- package/mock-call-history.d.ts +111 -0
- package/mock-client.d.ts +4 -4
- package/mock-errors.d.ts +3 -3
- package/mock-interceptor.d.ts +19 -19
- package/mock-pool.d.ts +4 -4
- package/package.json +1 -1
- package/patch.d.ts +0 -4
- package/pool-stats.d.ts +8 -8
- package/pool.d.ts +12 -12
- package/proxy-agent.d.ts +4 -4
- package/readable.d.ts +18 -15
- package/retry-agent.d.ts +1 -1
- package/retry-handler.d.ts +10 -10
- package/util.d.ts +3 -3
- package/utility.d.ts +7 -0
- package/webidl.d.ts +44 -6
- package/websocket.d.ts +35 -1
- package/file.d.ts +0 -39
- package/filereader.d.ts +0 -54
package/dispatcher.d.ts
CHANGED
|
@@ -6,98 +6,98 @@ import { IncomingHttpHeaders } from './header'
|
|
|
6
6
|
import BodyReadable from './readable'
|
|
7
7
|
import { FormData } from './formdata'
|
|
8
8
|
import Errors from './errors'
|
|
9
|
+
import { Autocomplete } from './utility'
|
|
9
10
|
|
|
10
|
-
type AbortSignal = unknown
|
|
11
|
+
type AbortSignal = unknown
|
|
11
12
|
|
|
12
13
|
export default Dispatcher
|
|
13
14
|
|
|
15
|
+
export type UndiciHeaders = Record<string, string | string[]> | IncomingHttpHeaders | string[] | Iterable<[string, string | string[] | undefined]> | null
|
|
16
|
+
|
|
14
17
|
/** Dispatcher is the core API used to dispatch requests. */
|
|
15
18
|
declare class Dispatcher extends EventEmitter {
|
|
16
19
|
/** Dispatches a request. This API is expected to evolve through semver-major versions and is less stable than the preceding higher level APIs. It is primarily intended for library developers who implement higher level APIs on top of this. */
|
|
17
|
-
dispatch(options: Dispatcher.DispatchOptions, handler: Dispatcher.
|
|
20
|
+
dispatch (options: Dispatcher.DispatchOptions, handler: Dispatcher.DispatchHandler): boolean
|
|
18
21
|
/** Starts two-way communications with the requested resource. */
|
|
19
|
-
connect(options: Dispatcher.ConnectOptions): Promise<Dispatcher.ConnectData
|
|
20
|
-
connect(options: Dispatcher.ConnectOptions
|
|
22
|
+
connect<TOpaque = null>(options: Dispatcher.ConnectOptions<TOpaque>): Promise<Dispatcher.ConnectData<TOpaque>>
|
|
23
|
+
connect<TOpaque = null>(options: Dispatcher.ConnectOptions<TOpaque>, callback: (err: Error | null, data: Dispatcher.ConnectData<TOpaque>) => void): void
|
|
21
24
|
/** Compose a chain of dispatchers */
|
|
22
|
-
compose(dispatchers: Dispatcher.DispatcherComposeInterceptor[]): Dispatcher.ComposedDispatcher
|
|
23
|
-
compose(...dispatchers: Dispatcher.DispatcherComposeInterceptor[]): Dispatcher.ComposedDispatcher
|
|
25
|
+
compose (dispatchers: Dispatcher.DispatcherComposeInterceptor[]): Dispatcher.ComposedDispatcher
|
|
26
|
+
compose (...dispatchers: Dispatcher.DispatcherComposeInterceptor[]): Dispatcher.ComposedDispatcher
|
|
24
27
|
/** Performs an HTTP request. */
|
|
25
|
-
request(options: Dispatcher.RequestOptions): Promise<Dispatcher.ResponseData
|
|
26
|
-
request(options: Dispatcher.RequestOptions
|
|
28
|
+
request<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>): Promise<Dispatcher.ResponseData<TOpaque>>
|
|
29
|
+
request<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>, callback: (err: Error | null, data: Dispatcher.ResponseData<TOpaque>) => void): void
|
|
27
30
|
/** For easy use with `stream.pipeline`. */
|
|
28
|
-
pipeline(options: Dispatcher.PipelineOptions
|
|
31
|
+
pipeline<TOpaque = null>(options: Dispatcher.PipelineOptions<TOpaque>, handler: Dispatcher.PipelineHandler<TOpaque>): Duplex
|
|
29
32
|
/** A faster version of `Dispatcher.request`. */
|
|
30
|
-
stream(options: Dispatcher.RequestOptions
|
|
31
|
-
stream(options: Dispatcher.RequestOptions
|
|
33
|
+
stream<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>, factory: Dispatcher.StreamFactory<TOpaque>): Promise<Dispatcher.StreamData<TOpaque>>
|
|
34
|
+
stream<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>, factory: Dispatcher.StreamFactory<TOpaque>, callback: (err: Error | null, data: Dispatcher.StreamData<TOpaque>) => void): void
|
|
32
35
|
/** Upgrade to a different protocol. */
|
|
33
|
-
upgrade(options: Dispatcher.UpgradeOptions): Promise<Dispatcher.UpgradeData
|
|
34
|
-
upgrade(options: Dispatcher.UpgradeOptions, callback: (err: Error | null, data: Dispatcher.UpgradeData) => void): void
|
|
36
|
+
upgrade (options: Dispatcher.UpgradeOptions): Promise<Dispatcher.UpgradeData>
|
|
37
|
+
upgrade (options: Dispatcher.UpgradeOptions, callback: (err: Error | null, data: Dispatcher.UpgradeData) => void): void
|
|
35
38
|
/** Closes the client and gracefully waits for enqueued requests to complete before invoking the callback (or returning a promise if no callback is provided). */
|
|
36
|
-
close(): Promise<void
|
|
37
|
-
close(callback: () => void): void
|
|
39
|
+
close (): Promise<void>
|
|
40
|
+
close (callback: () => void): void
|
|
38
41
|
/** Destroy the client abruptly with the given err. All the pending and running requests will be asynchronously aborted and error. Waits until socket is closed before invoking the callback (or returning a promise if no callback is provided). Since this operation is asynchronously dispatched there might still be some progress on dispatched requests. */
|
|
39
|
-
destroy(): Promise<void
|
|
40
|
-
destroy(err: Error | null): Promise<void
|
|
41
|
-
destroy(callback: () => void): void
|
|
42
|
-
destroy(err: Error | null, callback: () => void): void
|
|
43
|
-
|
|
44
|
-
on(eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this;
|
|
45
|
-
on(eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
|
|
46
|
-
on(eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
|
|
47
|
-
on(eventName: 'drain', callback: (origin: URL) => void): this;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
once(eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this;
|
|
51
|
-
once(eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
|
|
52
|
-
once(eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
|
|
53
|
-
once(eventName: 'drain', callback: (origin: URL) => void): this;
|
|
42
|
+
destroy (): Promise<void>
|
|
43
|
+
destroy (err: Error | null): Promise<void>
|
|
44
|
+
destroy (callback: () => void): void
|
|
45
|
+
destroy (err: Error | null, callback: () => void): void
|
|
54
46
|
|
|
47
|
+
on (eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this
|
|
48
|
+
on (eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
49
|
+
on (eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
50
|
+
on (eventName: 'drain', callback: (origin: URL) => void): this
|
|
55
51
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
once (eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this
|
|
53
|
+
once (eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
54
|
+
once (eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
55
|
+
once (eventName: 'drain', callback: (origin: URL) => void): this
|
|
60
56
|
|
|
57
|
+
off (eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this
|
|
58
|
+
off (eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
59
|
+
off (eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
60
|
+
off (eventName: 'drain', callback: (origin: URL) => void): this
|
|
61
61
|
|
|
62
|
-
addListener(eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this
|
|
63
|
-
addListener(eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
64
|
-
addListener(eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
65
|
-
addListener(eventName: 'drain', callback: (origin: URL) => void): this
|
|
62
|
+
addListener (eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this
|
|
63
|
+
addListener (eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
64
|
+
addListener (eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
65
|
+
addListener (eventName: 'drain', callback: (origin: URL) => void): this
|
|
66
66
|
|
|
67
|
-
removeListener(eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this
|
|
68
|
-
removeListener(eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
69
|
-
removeListener(eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
70
|
-
removeListener(eventName: 'drain', callback: (origin: URL) => void): this
|
|
67
|
+
removeListener (eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this
|
|
68
|
+
removeListener (eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
69
|
+
removeListener (eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
70
|
+
removeListener (eventName: 'drain', callback: (origin: URL) => void): this
|
|
71
71
|
|
|
72
|
-
prependListener(eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this
|
|
73
|
-
prependListener(eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
74
|
-
prependListener(eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
75
|
-
prependListener(eventName: 'drain', callback: (origin: URL) => void): this
|
|
72
|
+
prependListener (eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this
|
|
73
|
+
prependListener (eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
74
|
+
prependListener (eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
75
|
+
prependListener (eventName: 'drain', callback: (origin: URL) => void): this
|
|
76
76
|
|
|
77
|
-
prependOnceListener(eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this
|
|
78
|
-
prependOnceListener(eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
79
|
-
prependOnceListener(eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
80
|
-
prependOnceListener(eventName: 'drain', callback: (origin: URL) => void): this
|
|
77
|
+
prependOnceListener (eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this
|
|
78
|
+
prependOnceListener (eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
79
|
+
prependOnceListener (eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
80
|
+
prependOnceListener (eventName: 'drain', callback: (origin: URL) => void): this
|
|
81
81
|
|
|
82
|
-
listeners(eventName: 'connect'): ((origin: URL, targets: readonly Dispatcher[]) => void)[]
|
|
83
|
-
listeners(eventName: 'disconnect'): ((origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[]
|
|
84
|
-
listeners(eventName: 'connectionError'): ((origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[]
|
|
85
|
-
listeners(eventName: 'drain'): ((origin: URL) => void)[]
|
|
82
|
+
listeners (eventName: 'connect'): ((origin: URL, targets: readonly Dispatcher[]) => void)[]
|
|
83
|
+
listeners (eventName: 'disconnect'): ((origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[]
|
|
84
|
+
listeners (eventName: 'connectionError'): ((origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[]
|
|
85
|
+
listeners (eventName: 'drain'): ((origin: URL) => void)[]
|
|
86
86
|
|
|
87
|
-
rawListeners(eventName: 'connect'): ((origin: URL, targets: readonly Dispatcher[]) => void)[]
|
|
88
|
-
rawListeners(eventName: 'disconnect'): ((origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[]
|
|
89
|
-
rawListeners(eventName: 'connectionError'): ((origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[]
|
|
90
|
-
rawListeners(eventName: 'drain'): ((origin: URL) => void)[]
|
|
87
|
+
rawListeners (eventName: 'connect'): ((origin: URL, targets: readonly Dispatcher[]) => void)[]
|
|
88
|
+
rawListeners (eventName: 'disconnect'): ((origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[]
|
|
89
|
+
rawListeners (eventName: 'connectionError'): ((origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[]
|
|
90
|
+
rawListeners (eventName: 'drain'): ((origin: URL) => void)[]
|
|
91
91
|
|
|
92
|
-
emit(eventName: 'connect', origin: URL, targets: readonly Dispatcher[]): boolean
|
|
93
|
-
emit(eventName: 'disconnect', origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError): boolean
|
|
94
|
-
emit(eventName: 'connectionError', origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError): boolean
|
|
95
|
-
emit(eventName: 'drain', origin: URL): boolean
|
|
92
|
+
emit (eventName: 'connect', origin: URL, targets: readonly Dispatcher[]): boolean
|
|
93
|
+
emit (eventName: 'disconnect', origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError): boolean
|
|
94
|
+
emit (eventName: 'connectionError', origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError): boolean
|
|
95
|
+
emit (eventName: 'drain', origin: URL): boolean
|
|
96
96
|
}
|
|
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 DispatcherComposeInterceptor = (dispatch: Dispatcher['dispatch']) => Dispatcher['dispatch']
|
|
101
101
|
export interface DispatchOptions {
|
|
102
102
|
origin?: string | URL;
|
|
103
103
|
path: string;
|
|
@@ -105,12 +105,12 @@ declare namespace Dispatcher {
|
|
|
105
105
|
/** Default: `null` */
|
|
106
106
|
body?: string | Buffer | Uint8Array | Readable | null | FormData;
|
|
107
107
|
/** Default: `null` */
|
|
108
|
-
headers?:
|
|
108
|
+
headers?: UndiciHeaders;
|
|
109
109
|
/** Query string params to be embedded in the request URL. Default: `null` */
|
|
110
110
|
query?: Record<string, any>;
|
|
111
111
|
/** Whether the requests can be safely retried or not. If `false` the request won't be sent until all preceding requests in the pipeline have completed. Default: `true` if `method` is `HEAD` or `GET`. */
|
|
112
112
|
idempotent?: boolean;
|
|
113
|
-
/** Whether the response is expected to take a long time and would end up blocking the pipeline. When this is set to `true` further pipelining will be avoided on the same connection until headers have been received. */
|
|
113
|
+
/** Whether the response is expected to take a long time and would end up blocking the pipeline. When this is set to `true` further pipelining will be avoided on the same connection until headers have been received. Defaults to `method !== 'HEAD'`. */
|
|
114
114
|
blocking?: boolean;
|
|
115
115
|
/** Upgrade the request. Should be used to specify the kind of upgrade i.e. `'Websocket'`. Default: `method === 'CONNECT' || null`. */
|
|
116
116
|
upgrade?: boolean | string | null;
|
|
@@ -122,28 +122,28 @@ declare namespace Dispatcher {
|
|
|
122
122
|
reset?: boolean;
|
|
123
123
|
/** Whether Undici should throw an error upon receiving a 4xx or 5xx response from the server. Defaults to false */
|
|
124
124
|
throwOnError?: boolean;
|
|
125
|
-
/** For H2, it appends the expect: 100-continue header, and halts the request body until a 100-continue is received from the remote server*/
|
|
125
|
+
/** For H2, it appends the expect: 100-continue header, and halts the request body until a 100-continue is received from the remote server */
|
|
126
126
|
expectContinue?: boolean;
|
|
127
127
|
}
|
|
128
|
-
export interface ConnectOptions {
|
|
128
|
+
export interface ConnectOptions<TOpaque = null> {
|
|
129
129
|
origin: string | URL;
|
|
130
130
|
path: string;
|
|
131
131
|
/** Default: `null` */
|
|
132
|
-
headers?:
|
|
132
|
+
headers?: UndiciHeaders;
|
|
133
133
|
/** Default: `null` */
|
|
134
134
|
signal?: AbortSignal | EventEmitter | null;
|
|
135
135
|
/** This argument parameter is passed through to `ConnectData` */
|
|
136
|
-
opaque?:
|
|
136
|
+
opaque?: TOpaque;
|
|
137
137
|
/** Default: 0 */
|
|
138
138
|
maxRedirections?: number;
|
|
139
139
|
/** Default: false */
|
|
140
140
|
redirectionLimitReached?: boolean;
|
|
141
141
|
/** Default: `null` */
|
|
142
|
-
|
|
142
|
+
responseHeaders?: 'raw' | null;
|
|
143
143
|
}
|
|
144
|
-
export interface RequestOptions extends DispatchOptions {
|
|
144
|
+
export interface RequestOptions<TOpaque = null> extends DispatchOptions {
|
|
145
145
|
/** Default: `null` */
|
|
146
|
-
opaque?:
|
|
146
|
+
opaque?: TOpaque;
|
|
147
147
|
/** Default: `null` */
|
|
148
148
|
signal?: AbortSignal | EventEmitter | null;
|
|
149
149
|
/** Default: 0 */
|
|
@@ -153,11 +153,11 @@ declare namespace Dispatcher {
|
|
|
153
153
|
/** Default: `null` */
|
|
154
154
|
onInfo?: (info: { statusCode: number, headers: Record<string, string | string[]> }) => void;
|
|
155
155
|
/** Default: `null` */
|
|
156
|
-
|
|
156
|
+
responseHeaders?: 'raw' | null;
|
|
157
157
|
/** Default: `64 KiB` */
|
|
158
158
|
highWaterMark?: number;
|
|
159
159
|
}
|
|
160
|
-
export interface PipelineOptions extends RequestOptions {
|
|
160
|
+
export interface PipelineOptions<TOpaque = null> extends RequestOptions<TOpaque> {
|
|
161
161
|
/** `true` if the `handler` will return an object stream. Default: `false` */
|
|
162
162
|
objectMode?: boolean;
|
|
163
163
|
}
|
|
@@ -166,7 +166,7 @@ declare namespace Dispatcher {
|
|
|
166
166
|
/** Default: `'GET'` */
|
|
167
167
|
method?: string;
|
|
168
168
|
/** Default: `null` */
|
|
169
|
-
headers?:
|
|
169
|
+
headers?: UndiciHeaders;
|
|
170
170
|
/** A string of comma separated protocols, in descending preference order. Default: `'Websocket'` */
|
|
171
171
|
protocol?: string;
|
|
172
172
|
/** Default: `null` */
|
|
@@ -176,65 +176,90 @@ declare namespace Dispatcher {
|
|
|
176
176
|
/** Default: false */
|
|
177
177
|
redirectionLimitReached?: boolean;
|
|
178
178
|
/** Default: `null` */
|
|
179
|
-
|
|
179
|
+
responseHeaders?: 'raw' | null;
|
|
180
180
|
}
|
|
181
|
-
export interface ConnectData {
|
|
181
|
+
export interface ConnectData<TOpaque = null> {
|
|
182
182
|
statusCode: number;
|
|
183
183
|
headers: IncomingHttpHeaders;
|
|
184
184
|
socket: Duplex;
|
|
185
|
-
opaque:
|
|
185
|
+
opaque: TOpaque;
|
|
186
186
|
}
|
|
187
|
-
export interface ResponseData {
|
|
187
|
+
export interface ResponseData<TOpaque = null> {
|
|
188
188
|
statusCode: number;
|
|
189
189
|
headers: IncomingHttpHeaders;
|
|
190
190
|
body: BodyReadable & BodyMixin;
|
|
191
191
|
trailers: Record<string, string>;
|
|
192
|
-
opaque:
|
|
192
|
+
opaque: TOpaque;
|
|
193
193
|
context: object;
|
|
194
194
|
}
|
|
195
|
-
export interface PipelineHandlerData {
|
|
195
|
+
export interface PipelineHandlerData<TOpaque = null> {
|
|
196
196
|
statusCode: number;
|
|
197
197
|
headers: IncomingHttpHeaders;
|
|
198
|
-
opaque:
|
|
198
|
+
opaque: TOpaque;
|
|
199
199
|
body: BodyReadable;
|
|
200
200
|
context: object;
|
|
201
201
|
}
|
|
202
|
-
export interface StreamData {
|
|
203
|
-
opaque:
|
|
202
|
+
export interface StreamData<TOpaque = null> {
|
|
203
|
+
opaque: TOpaque;
|
|
204
204
|
trailers: Record<string, string>;
|
|
205
205
|
}
|
|
206
|
-
export interface UpgradeData {
|
|
206
|
+
export interface UpgradeData<TOpaque = null> {
|
|
207
207
|
headers: IncomingHttpHeaders;
|
|
208
208
|
socket: Duplex;
|
|
209
|
-
opaque:
|
|
209
|
+
opaque: TOpaque;
|
|
210
210
|
}
|
|
211
|
-
export interface StreamFactoryData {
|
|
211
|
+
export interface StreamFactoryData<TOpaque = null> {
|
|
212
212
|
statusCode: number;
|
|
213
213
|
headers: IncomingHttpHeaders;
|
|
214
|
-
opaque:
|
|
214
|
+
opaque: TOpaque;
|
|
215
215
|
context: object;
|
|
216
216
|
}
|
|
217
|
-
export type StreamFactory = (data: StreamFactoryData) => Writable
|
|
218
|
-
|
|
217
|
+
export type StreamFactory<TOpaque = null> = (data: StreamFactoryData<TOpaque>) => Writable
|
|
218
|
+
|
|
219
|
+
export interface DispatchController {
|
|
220
|
+
get aborted () : boolean
|
|
221
|
+
get paused () : boolean
|
|
222
|
+
get reason () : Error | null
|
|
223
|
+
abort (reason: Error): void
|
|
224
|
+
pause(): void
|
|
225
|
+
resume(): void
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export interface DispatchHandler {
|
|
229
|
+
onRequestStart?(controller: DispatchController, context: any): void;
|
|
230
|
+
onRequestUpgrade?(controller: DispatchController, statusCode: number, headers: IncomingHttpHeaders, socket: Duplex): void;
|
|
231
|
+
onResponseStart?(controller: DispatchController, statusCode: number, headers: IncomingHttpHeaders, statusMessage?: string): void;
|
|
232
|
+
onResponseData?(controller: DispatchController, chunk: Buffer): void;
|
|
233
|
+
onResponseEnd?(controller: DispatchController, trailers: IncomingHttpHeaders): void;
|
|
234
|
+
onResponseError?(controller: DispatchController, error: Error): void;
|
|
235
|
+
|
|
219
236
|
/** Invoked before request is dispatched on socket. May be invoked multiple times when a request is retried when the request at the head of the pipeline fails. */
|
|
237
|
+
/** @deprecated */
|
|
220
238
|
onConnect?(abort: (err?: Error) => void): void;
|
|
221
239
|
/** Invoked when an error has occurred. */
|
|
240
|
+
/** @deprecated */
|
|
222
241
|
onError?(err: Error): void;
|
|
223
242
|
/** Invoked when request is upgraded either due to a `Upgrade` header or `CONNECT` method. */
|
|
243
|
+
/** @deprecated */
|
|
224
244
|
onUpgrade?(statusCode: number, headers: Buffer[] | string[] | null, socket: Duplex): void;
|
|
225
245
|
/** Invoked when response is received, before headers have been read. **/
|
|
246
|
+
/** @deprecated */
|
|
226
247
|
onResponseStarted?(): void;
|
|
227
248
|
/** Invoked when statusCode and headers have been received. May be invoked multiple times due to 1xx informational headers. */
|
|
249
|
+
/** @deprecated */
|
|
228
250
|
onHeaders?(statusCode: number, headers: Buffer[], resume: () => void, statusText: string): boolean;
|
|
229
251
|
/** Invoked when response payload data is received. */
|
|
252
|
+
/** @deprecated */
|
|
230
253
|
onData?(chunk: Buffer): boolean;
|
|
231
254
|
/** Invoked when response payload and trailers have been received and the request has completed. */
|
|
255
|
+
/** @deprecated */
|
|
232
256
|
onComplete?(trailers: string[] | null): void;
|
|
233
257
|
/** Invoked when a body chunk is sent to the server. May be invoked multiple times for chunked requests */
|
|
258
|
+
/** @deprecated */
|
|
234
259
|
onBodySent?(chunkSize: number, totalBytesSent: number): void;
|
|
235
260
|
}
|
|
236
|
-
export type PipelineHandler = (data: PipelineHandlerData) => Readable
|
|
237
|
-
export type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH'
|
|
261
|
+
export type PipelineHandler<TOpaque = null> = (data: PipelineHandlerData<TOpaque>) => Readable
|
|
262
|
+
export type HttpMethod = Autocomplete<'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH'>
|
|
238
263
|
|
|
239
264
|
/**
|
|
240
265
|
* @link https://fetch.spec.whatwg.org/#body-mixin
|
|
@@ -4,9 +4,9 @@ import Dispatcher from './dispatcher'
|
|
|
4
4
|
export default EnvHttpProxyAgent
|
|
5
5
|
|
|
6
6
|
declare class EnvHttpProxyAgent extends Dispatcher {
|
|
7
|
-
constructor(opts?: EnvHttpProxyAgent.Options)
|
|
7
|
+
constructor (opts?: EnvHttpProxyAgent.Options)
|
|
8
8
|
|
|
9
|
-
dispatch(options: Agent.DispatchOptions, handler: Dispatcher.
|
|
9
|
+
dispatch (options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandler): boolean
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
declare namespace EnvHttpProxyAgent {
|
package/errors.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { IncomingHttpHeaders } from
|
|
1
|
+
import { IncomingHttpHeaders } from './header'
|
|
2
2
|
import Client from './client'
|
|
3
3
|
|
|
4
4
|
export default Errors
|
|
5
5
|
|
|
6
6
|
declare namespace Errors {
|
|
7
7
|
export class UndiciError extends Error {
|
|
8
|
-
name: string
|
|
9
|
-
code: string
|
|
8
|
+
name: string
|
|
9
|
+
code: string
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
/** Connect timeout error. */
|
|
13
13
|
export class ConnectTimeoutError extends UndiciError {
|
|
14
|
-
name: 'ConnectTimeoutError'
|
|
15
|
-
code: 'UND_ERR_CONNECT_TIMEOUT'
|
|
14
|
+
name: 'ConnectTimeoutError'
|
|
15
|
+
code: 'UND_ERR_CONNECT_TIMEOUT'
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/** A header exceeds the `headersTimeout` option. */
|
|
19
19
|
export class HeadersTimeoutError extends UndiciError {
|
|
20
|
-
name: 'HeadersTimeoutError'
|
|
21
|
-
code: 'UND_ERR_HEADERS_TIMEOUT'
|
|
20
|
+
name: 'HeadersTimeoutError'
|
|
21
|
+
code: 'UND_ERR_HEADERS_TIMEOUT'
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/** Headers overflow error. */
|
|
@@ -29,8 +29,24 @@ declare namespace Errors {
|
|
|
29
29
|
|
|
30
30
|
/** A body exceeds the `bodyTimeout` option. */
|
|
31
31
|
export class BodyTimeoutError extends UndiciError {
|
|
32
|
-
name: 'BodyTimeoutError'
|
|
33
|
-
code: 'UND_ERR_BODY_TIMEOUT'
|
|
32
|
+
name: 'BodyTimeoutError'
|
|
33
|
+
code: 'UND_ERR_BODY_TIMEOUT'
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export class ResponseError extends UndiciError {
|
|
37
|
+
constructor (
|
|
38
|
+
message: string,
|
|
39
|
+
code: number,
|
|
40
|
+
options: {
|
|
41
|
+
headers?: IncomingHttpHeaders | string[] | null,
|
|
42
|
+
body?: null | Record<string, any> | string
|
|
43
|
+
}
|
|
44
|
+
)
|
|
45
|
+
name: 'ResponseError'
|
|
46
|
+
code: 'UND_ERR_RESPONSE'
|
|
47
|
+
statusCode: number
|
|
48
|
+
body: null | Record<string, any> | string
|
|
49
|
+
headers: IncomingHttpHeaders | string[] | null
|
|
34
50
|
}
|
|
35
51
|
|
|
36
52
|
export class ResponseStatusCodeError extends UndiciError {
|
|
@@ -39,91 +55,91 @@ declare namespace Errors {
|
|
|
39
55
|
statusCode?: number,
|
|
40
56
|
headers?: IncomingHttpHeaders | string[] | null,
|
|
41
57
|
body?: null | Record<string, any> | string
|
|
42
|
-
)
|
|
43
|
-
name: 'ResponseStatusCodeError'
|
|
44
|
-
code: 'UND_ERR_RESPONSE_STATUS_CODE'
|
|
58
|
+
)
|
|
59
|
+
name: 'ResponseStatusCodeError'
|
|
60
|
+
code: 'UND_ERR_RESPONSE_STATUS_CODE'
|
|
45
61
|
body: null | Record<string, any> | string
|
|
46
62
|
status: number
|
|
47
63
|
statusCode: number
|
|
48
|
-
headers: IncomingHttpHeaders | string[] | null
|
|
64
|
+
headers: IncomingHttpHeaders | string[] | null
|
|
49
65
|
}
|
|
50
66
|
|
|
51
67
|
/** Passed an invalid argument. */
|
|
52
68
|
export class InvalidArgumentError extends UndiciError {
|
|
53
|
-
name: 'InvalidArgumentError'
|
|
54
|
-
code: 'UND_ERR_INVALID_ARG'
|
|
69
|
+
name: 'InvalidArgumentError'
|
|
70
|
+
code: 'UND_ERR_INVALID_ARG'
|
|
55
71
|
}
|
|
56
72
|
|
|
57
73
|
/** Returned an invalid value. */
|
|
58
74
|
export class InvalidReturnValueError extends UndiciError {
|
|
59
|
-
name: 'InvalidReturnValueError'
|
|
60
|
-
code: 'UND_ERR_INVALID_RETURN_VALUE'
|
|
75
|
+
name: 'InvalidReturnValueError'
|
|
76
|
+
code: 'UND_ERR_INVALID_RETURN_VALUE'
|
|
61
77
|
}
|
|
62
78
|
|
|
63
79
|
/** The request has been aborted by the user. */
|
|
64
80
|
export class RequestAbortedError extends UndiciError {
|
|
65
|
-
name: 'AbortError'
|
|
66
|
-
code: 'UND_ERR_ABORTED'
|
|
81
|
+
name: 'AbortError'
|
|
82
|
+
code: 'UND_ERR_ABORTED'
|
|
67
83
|
}
|
|
68
84
|
|
|
69
85
|
/** Expected error with reason. */
|
|
70
86
|
export class InformationalError extends UndiciError {
|
|
71
|
-
name: 'InformationalError'
|
|
72
|
-
code: 'UND_ERR_INFO'
|
|
87
|
+
name: 'InformationalError'
|
|
88
|
+
code: 'UND_ERR_INFO'
|
|
73
89
|
}
|
|
74
90
|
|
|
75
91
|
/** Request body length does not match content-length header. */
|
|
76
92
|
export class RequestContentLengthMismatchError extends UndiciError {
|
|
77
|
-
name: 'RequestContentLengthMismatchError'
|
|
78
|
-
code: 'UND_ERR_REQ_CONTENT_LENGTH_MISMATCH'
|
|
93
|
+
name: 'RequestContentLengthMismatchError'
|
|
94
|
+
code: 'UND_ERR_REQ_CONTENT_LENGTH_MISMATCH'
|
|
79
95
|
}
|
|
80
96
|
|
|
81
97
|
/** Response body length does not match content-length header. */
|
|
82
98
|
export class ResponseContentLengthMismatchError extends UndiciError {
|
|
83
|
-
name: 'ResponseContentLengthMismatchError'
|
|
84
|
-
code: 'UND_ERR_RES_CONTENT_LENGTH_MISMATCH'
|
|
99
|
+
name: 'ResponseContentLengthMismatchError'
|
|
100
|
+
code: 'UND_ERR_RES_CONTENT_LENGTH_MISMATCH'
|
|
85
101
|
}
|
|
86
102
|
|
|
87
103
|
/** Trying to use a destroyed client. */
|
|
88
104
|
export class ClientDestroyedError extends UndiciError {
|
|
89
|
-
name: 'ClientDestroyedError'
|
|
90
|
-
code: 'UND_ERR_DESTROYED'
|
|
105
|
+
name: 'ClientDestroyedError'
|
|
106
|
+
code: 'UND_ERR_DESTROYED'
|
|
91
107
|
}
|
|
92
108
|
|
|
93
109
|
/** Trying to use a closed client. */
|
|
94
110
|
export class ClientClosedError extends UndiciError {
|
|
95
|
-
name: 'ClientClosedError'
|
|
96
|
-
code: 'UND_ERR_CLOSED'
|
|
111
|
+
name: 'ClientClosedError'
|
|
112
|
+
code: 'UND_ERR_CLOSED'
|
|
97
113
|
}
|
|
98
114
|
|
|
99
115
|
/** There is an error with the socket. */
|
|
100
116
|
export class SocketError extends UndiciError {
|
|
101
|
-
name: 'SocketError'
|
|
102
|
-
code: 'UND_ERR_SOCKET'
|
|
117
|
+
name: 'SocketError'
|
|
118
|
+
code: 'UND_ERR_SOCKET'
|
|
103
119
|
socket: Client.SocketInfo | null
|
|
104
120
|
}
|
|
105
121
|
|
|
106
122
|
/** Encountered unsupported functionality. */
|
|
107
123
|
export class NotSupportedError extends UndiciError {
|
|
108
|
-
name: 'NotSupportedError'
|
|
109
|
-
code: 'UND_ERR_NOT_SUPPORTED'
|
|
124
|
+
name: 'NotSupportedError'
|
|
125
|
+
code: 'UND_ERR_NOT_SUPPORTED'
|
|
110
126
|
}
|
|
111
127
|
|
|
112
128
|
/** No upstream has been added to the BalancedPool. */
|
|
113
129
|
export class BalancedPoolMissingUpstreamError extends UndiciError {
|
|
114
|
-
name: 'MissingUpstreamError'
|
|
115
|
-
code: 'UND_ERR_BPL_MISSING_UPSTREAM'
|
|
130
|
+
name: 'MissingUpstreamError'
|
|
131
|
+
code: 'UND_ERR_BPL_MISSING_UPSTREAM'
|
|
116
132
|
}
|
|
117
133
|
|
|
118
134
|
export class HTTPParserError extends UndiciError {
|
|
119
|
-
name: 'HTTPParserError'
|
|
120
|
-
code: string
|
|
135
|
+
name: 'HTTPParserError'
|
|
136
|
+
code: string
|
|
121
137
|
}
|
|
122
138
|
|
|
123
139
|
/** The response exceed the length allowed. */
|
|
124
140
|
export class ResponseExceededMaxSizeError extends UndiciError {
|
|
125
|
-
name: 'ResponseExceededMaxSizeError'
|
|
126
|
-
code: 'UND_ERR_RES_EXCEEDED_MAX_SIZE'
|
|
141
|
+
name: 'ResponseExceededMaxSizeError'
|
|
142
|
+
code: 'UND_ERR_RES_EXCEEDED_MAX_SIZE'
|
|
127
143
|
}
|
|
128
144
|
|
|
129
145
|
export class RequestRetryError extends UndiciError {
|
|
@@ -132,18 +148,24 @@ declare namespace Errors {
|
|
|
132
148
|
statusCode: number,
|
|
133
149
|
headers?: IncomingHttpHeaders | string[] | null,
|
|
134
150
|
body?: null | Record<string, any> | string
|
|
135
|
-
)
|
|
136
|
-
name: 'RequestRetryError'
|
|
137
|
-
code: 'UND_ERR_REQ_RETRY'
|
|
138
|
-
statusCode: number
|
|
151
|
+
)
|
|
152
|
+
name: 'RequestRetryError'
|
|
153
|
+
code: 'UND_ERR_REQ_RETRY'
|
|
154
|
+
statusCode: number
|
|
139
155
|
data: {
|
|
140
156
|
count: number;
|
|
141
|
-
}
|
|
142
|
-
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
headers: Record<string, string | string[]>
|
|
143
160
|
}
|
|
144
161
|
|
|
145
162
|
export class SecureProxyConnectionError extends UndiciError {
|
|
146
|
-
|
|
147
|
-
|
|
163
|
+
constructor (
|
|
164
|
+
cause?: Error,
|
|
165
|
+
message?: string,
|
|
166
|
+
options?: Record<any, any>
|
|
167
|
+
)
|
|
168
|
+
name: 'SecureProxyConnectionError'
|
|
169
|
+
code: 'UND_ERR_PRX_TLS'
|
|
148
170
|
}
|
|
149
171
|
}
|