undici-types 6.6.1 → 6.7.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/dispatcher.d.ts +1 -1
- package/fetch.d.ts +20 -21
- package/index.d.ts +2 -1
- package/package.json +1 -1
- package/retry-agent.d.ts +11 -0
- package/webidl.d.ts +6 -1
package/dispatcher.d.ts
CHANGED
|
@@ -100,7 +100,7 @@ declare namespace Dispatcher {
|
|
|
100
100
|
/** Default: `null` */
|
|
101
101
|
body?: string | Buffer | Uint8Array | Readable | null | FormData;
|
|
102
102
|
/** Default: `null` */
|
|
103
|
-
headers?: IncomingHttpHeaders | string[] | null;
|
|
103
|
+
headers?: IncomingHttpHeaders | string[] | Iterable<[string, string | string[] | undefined]> | null;
|
|
104
104
|
/** Query string params to be embedded in the request URL. Default: `null` */
|
|
105
105
|
query?: Record<string, any>;
|
|
106
106
|
/** 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`. */
|
package/fetch.d.ts
CHANGED
|
@@ -27,12 +27,29 @@ export type BodyInit =
|
|
|
27
27
|
| null
|
|
28
28
|
| string
|
|
29
29
|
|
|
30
|
-
export
|
|
30
|
+
export class BodyMixin {
|
|
31
31
|
readonly body: ReadableStream | null
|
|
32
32
|
readonly bodyUsed: boolean
|
|
33
33
|
|
|
34
34
|
readonly arrayBuffer: () => Promise<ArrayBuffer>
|
|
35
35
|
readonly blob: () => Promise<Blob>
|
|
36
|
+
/**
|
|
37
|
+
* @deprecated This method is not recommended for parsing multipart/form-data bodies in server environments.
|
|
38
|
+
* It is recommended to use a library such as [@fastify/busboy](https://www.npmjs.com/package/@fastify/busboy) as follows:
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```js
|
|
42
|
+
* import { Busboy } from '@fastify/busboy'
|
|
43
|
+
* import { Readable } from 'node:stream'
|
|
44
|
+
*
|
|
45
|
+
* const response = await fetch('...')
|
|
46
|
+
* const busboy = new Busboy({ headers: { 'content-type': response.headers.get('content-type') } })
|
|
47
|
+
*
|
|
48
|
+
* // handle events emitted from `busboy`
|
|
49
|
+
*
|
|
50
|
+
* Readable.fromWeb(response.body).pipe(busboy)
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
36
53
|
readonly formData: () => Promise<FormData>
|
|
37
54
|
readonly json: () => Promise<unknown>
|
|
38
55
|
readonly text: () => Promise<string>
|
|
@@ -135,7 +152,7 @@ export type RequestRedirect = 'error' | 'follow' | 'manual'
|
|
|
135
152
|
|
|
136
153
|
export type RequestDuplex = 'half'
|
|
137
154
|
|
|
138
|
-
export declare class Request
|
|
155
|
+
export declare class Request extends BodyMixin {
|
|
139
156
|
constructor (input: RequestInfo, init?: RequestInit)
|
|
140
157
|
|
|
141
158
|
readonly cache: RequestCache
|
|
@@ -153,15 +170,6 @@ export declare class Request implements BodyMixin {
|
|
|
153
170
|
readonly signal: AbortSignal
|
|
154
171
|
readonly duplex: RequestDuplex
|
|
155
172
|
|
|
156
|
-
readonly body: ReadableStream | null
|
|
157
|
-
readonly bodyUsed: boolean
|
|
158
|
-
|
|
159
|
-
readonly arrayBuffer: () => Promise<ArrayBuffer>
|
|
160
|
-
readonly blob: () => Promise<Blob>
|
|
161
|
-
readonly formData: () => Promise<FormData>
|
|
162
|
-
readonly json: () => Promise<unknown>
|
|
163
|
-
readonly text: () => Promise<string>
|
|
164
|
-
|
|
165
173
|
readonly clone: () => Request
|
|
166
174
|
}
|
|
167
175
|
|
|
@@ -181,7 +189,7 @@ export type ResponseType =
|
|
|
181
189
|
|
|
182
190
|
export type ResponseRedirectStatus = 301 | 302 | 303 | 307 | 308
|
|
183
191
|
|
|
184
|
-
export declare class Response
|
|
192
|
+
export declare class Response extends BodyMixin {
|
|
185
193
|
constructor (body?: BodyInit, init?: ResponseInit)
|
|
186
194
|
|
|
187
195
|
readonly headers: Headers
|
|
@@ -192,15 +200,6 @@ export declare class Response implements BodyMixin {
|
|
|
192
200
|
readonly url: string
|
|
193
201
|
readonly redirected: boolean
|
|
194
202
|
|
|
195
|
-
readonly body: ReadableStream | null
|
|
196
|
-
readonly bodyUsed: boolean
|
|
197
|
-
|
|
198
|
-
readonly arrayBuffer: () => Promise<ArrayBuffer>
|
|
199
|
-
readonly blob: () => Promise<Blob>
|
|
200
|
-
readonly formData: () => Promise<FormData>
|
|
201
|
-
readonly json: () => Promise<unknown>
|
|
202
|
-
readonly text: () => Promise<string>
|
|
203
|
-
|
|
204
203
|
readonly clone: () => Response
|
|
205
204
|
|
|
206
205
|
static error (): Response
|
package/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ import MockAgent from'./mock-agent'
|
|
|
15
15
|
import mockErrors from'./mock-errors'
|
|
16
16
|
import ProxyAgent from'./proxy-agent'
|
|
17
17
|
import RetryHandler from'./retry-handler'
|
|
18
|
+
import RetryAgent from'./retry-agent'
|
|
18
19
|
import { request, pipeline, stream, connect, upgrade } from './api'
|
|
19
20
|
|
|
20
21
|
export * from './util'
|
|
@@ -30,7 +31,7 @@ export * from './content-type'
|
|
|
30
31
|
export * from './cache'
|
|
31
32
|
export { Interceptable } from './mock-interceptor'
|
|
32
33
|
|
|
33
|
-
export { Dispatcher, BalancedPool, Pool, Client, buildConnector, errors, Agent, request, stream, pipeline, connect, upgrade, setGlobalDispatcher, getGlobalDispatcher, setGlobalOrigin, getGlobalOrigin, MockClient, MockPool, MockAgent, mockErrors, ProxyAgent, RedirectHandler, DecoratorHandler, RetryHandler }
|
|
34
|
+
export { Dispatcher, BalancedPool, Pool, Client, buildConnector, errors, Agent, request, stream, pipeline, connect, upgrade, setGlobalDispatcher, getGlobalDispatcher, setGlobalOrigin, getGlobalOrigin, MockClient, MockPool, MockAgent, mockErrors, ProxyAgent, RedirectHandler, DecoratorHandler, RetryHandler, RetryAgent }
|
|
34
35
|
export default Undici
|
|
35
36
|
|
|
36
37
|
declare namespace Undici {
|
package/package.json
CHANGED
package/retry-agent.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Agent from './agent'
|
|
2
|
+
import buildConnector from './connector';
|
|
3
|
+
import Dispatcher from './dispatcher'
|
|
4
|
+
import { IncomingHttpHeaders } from './header'
|
|
5
|
+
import RetryHandler from './retry-handler'
|
|
6
|
+
|
|
7
|
+
export default RetryAgent
|
|
8
|
+
|
|
9
|
+
declare class RetryAgent extends Dispatcher {
|
|
10
|
+
constructor(dispatcher: Dispatcher, options?: RetryHandler.RetryOptions)
|
|
11
|
+
}
|
package/webidl.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
type Converter<T> = (object: unknown) => T
|
|
7
7
|
|
|
8
|
-
type SequenceConverter<T> = (object: unknown) => T[]
|
|
8
|
+
type SequenceConverter<T> = (object: unknown, iterable?: IterableIterator<T>) => T[]
|
|
9
9
|
|
|
10
10
|
type RecordConverter<K extends string, V> = (object: unknown) => Record<K, V>
|
|
11
11
|
|
|
@@ -62,6 +62,11 @@ interface WebidlUtil {
|
|
|
62
62
|
* @see https://webidl.spec.whatwg.org/#abstract-opdef-converttoint
|
|
63
63
|
*/
|
|
64
64
|
IntegerPart (N: number): number
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Stringifies {@param V}
|
|
68
|
+
*/
|
|
69
|
+
Stringify (V: any): string
|
|
65
70
|
}
|
|
66
71
|
|
|
67
72
|
interface WebidlConverters {
|