undici-types 5.24.0-test.2 → 5.24.0-test.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "undici-types",
3
- "version": "5.24.0-test.2",
3
+ "version": "5.24.0-test.5",
4
4
  "description": "A stand-alone types package for Undici",
5
5
  "homepage": "https://undici.nodejs.org",
6
6
  "bugs": {
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) Matteo Collina and Undici contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
package/README.md DELETED
@@ -1,442 +0,0 @@
1
- # undici
2
-
3
- [![Node CI](https://github.com/nodejs/undici/actions/workflows/nodejs.yml/badge.svg)](https://github.com/nodejs/undici/actions/workflows/nodejs.yml) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/) [![npm version](https://badge.fury.io/js/undici.svg)](https://badge.fury.io/js/undici) [![codecov](https://codecov.io/gh/nodejs/undici/branch/main/graph/badge.svg?token=yZL6LtXkOA)](https://codecov.io/gh/nodejs/undici)
4
-
5
- An HTTP/1.1 client, written from scratch for Node.js.
6
-
7
- > Undici means eleven in Italian. 1.1 -> 11 -> Eleven -> Undici.
8
- It is also a Stranger Things reference.
9
-
10
- Have a question about using Undici? Open a [Q&A Discussion](https://github.com/nodejs/undici/discussions/new) or join our official OpenJS [Slack](https://openjs-foundation.slack.com/archives/C01QF9Q31QD) channel.
11
-
12
- ## Install
13
-
14
- ```
15
- npm i undici
16
- ```
17
-
18
- ## Benchmarks
19
-
20
- The benchmark is a simple `hello world` [example](benchmarks/benchmark.js) using a
21
- number of unix sockets (connections) with a pipelining depth of 10 running on Node 20.6.0.
22
-
23
- ### Connections 1
24
-
25
-
26
- | Tests | Samples | Result | Tolerance | Difference with slowest |
27
- |---------------------|---------|---------------|-----------|-------------------------|
28
- | http - no keepalive | 15 | 5.32 req/sec | ± 2.61 % | - |
29
- | http - keepalive | 10 | 5.35 req/sec | ± 2.47 % | + 0.44 % |
30
- | undici - fetch | 15 | 41.85 req/sec | ± 2.49 % | + 686.04 % |
31
- | undici - pipeline | 40 | 50.36 req/sec | ± 2.77 % | + 845.92 % |
32
- | undici - stream | 15 | 60.58 req/sec | ± 2.75 % | + 1037.72 % |
33
- | undici - request | 10 | 61.19 req/sec | ± 2.60 % | + 1049.24 % |
34
- | undici - dispatch | 20 | 64.84 req/sec | ± 2.81 % | + 1117.81 % |
35
-
36
-
37
- ### Connections 50
38
-
39
- | Tests | Samples | Result | Tolerance | Difference with slowest |
40
- |---------------------|---------|------------------|-----------|-------------------------|
41
- | undici - fetch | 30 | 2107.19 req/sec | ± 2.69 % | - |
42
- | http - no keepalive | 10 | 2698.90 req/sec | ± 2.68 % | + 28.08 % |
43
- | http - keepalive | 10 | 4639.49 req/sec | ± 2.55 % | + 120.17 % |
44
- | undici - pipeline | 40 | 6123.33 req/sec | ± 2.97 % | + 190.59 % |
45
- | undici - stream | 50 | 9426.51 req/sec | ± 2.92 % | + 347.35 % |
46
- | undici - request | 10 | 10162.88 req/sec | ± 2.13 % | + 382.29 % |
47
- | undici - dispatch | 50 | 11191.11 req/sec | ± 2.98 % | + 431.09 % |
48
-
49
-
50
- ## Quick Start
51
-
52
- ```js
53
- import { request } from 'undici'
54
-
55
- const {
56
- statusCode,
57
- headers,
58
- trailers,
59
- body
60
- } = await request('http://localhost:3000/foo')
61
-
62
- console.log('response received', statusCode)
63
- console.log('headers', headers)
64
-
65
- for await (const data of body) {
66
- console.log('data', data)
67
- }
68
-
69
- console.log('trailers', trailers)
70
- ```
71
-
72
- ## Body Mixins
73
-
74
- The `body` mixins are the most common way to format the request/response body. Mixins include:
75
-
76
- - [`.formData()`](https://fetch.spec.whatwg.org/#dom-body-formdata)
77
- - [`.json()`](https://fetch.spec.whatwg.org/#dom-body-json)
78
- - [`.text()`](https://fetch.spec.whatwg.org/#dom-body-text)
79
-
80
- Example usage:
81
-
82
- ```js
83
- import { request } from 'undici'
84
-
85
- const {
86
- statusCode,
87
- headers,
88
- trailers,
89
- body
90
- } = await request('http://localhost:3000/foo')
91
-
92
- console.log('response received', statusCode)
93
- console.log('headers', headers)
94
- console.log('data', await body.json())
95
- console.log('trailers', trailers)
96
- ```
97
-
98
- _Note: Once a mixin has been called then the body cannot be reused, thus calling additional mixins on `.body`, e.g. `.body.json(); .body.text()` will result in an error `TypeError: unusable` being thrown and returned through the `Promise` rejection._
99
-
100
- Should you need to access the `body` in plain-text after using a mixin, the best practice is to use the `.text()` mixin first and then manually parse the text to the desired format.
101
-
102
- For more information about their behavior, please reference the body mixin from the [Fetch Standard](https://fetch.spec.whatwg.org/#body-mixin).
103
-
104
- ## Common API Methods
105
-
106
- This section documents our most commonly used API methods. Additional APIs are documented in their own files within the [docs](./docs/) folder and are accessible via the navigation list on the left side of the docs site.
107
-
108
- ### `undici.request([url, options]): Promise`
109
-
110
- Arguments:
111
-
112
- * **url** `string | URL | UrlObject`
113
- * **options** [`RequestOptions`](./docs/api/Dispatcher.md#parameter-requestoptions)
114
- * **dispatcher** `Dispatcher` - Default: [getGlobalDispatcher](#undicigetglobaldispatcher)
115
- * **method** `String` - Default: `PUT` if `options.body`, otherwise `GET`
116
- * **maxRedirections** `Integer` - Default: `0`
117
-
118
- Returns a promise with the result of the `Dispatcher.request` method.
119
-
120
- Calls `options.dispatcher.request(options)`.
121
-
122
- See [Dispatcher.request](./docs/api/Dispatcher.md#dispatcherrequestoptions-callback) for more details.
123
-
124
- ### `undici.stream([url, options, ]factory): Promise`
125
-
126
- Arguments:
127
-
128
- * **url** `string | URL | UrlObject`
129
- * **options** [`StreamOptions`](./docs/api/Dispatcher.md#parameter-streamoptions)
130
- * **dispatcher** `Dispatcher` - Default: [getGlobalDispatcher](#undicigetglobaldispatcher)
131
- * **method** `String` - Default: `PUT` if `options.body`, otherwise `GET`
132
- * **maxRedirections** `Integer` - Default: `0`
133
- * **factory** `Dispatcher.stream.factory`
134
-
135
- Returns a promise with the result of the `Dispatcher.stream` method.
136
-
137
- Calls `options.dispatcher.stream(options, factory)`.
138
-
139
- See [Dispatcher.stream](docs/api/Dispatcher.md#dispatcherstreamoptions-factory-callback) for more details.
140
-
141
- ### `undici.pipeline([url, options, ]handler): Duplex`
142
-
143
- Arguments:
144
-
145
- * **url** `string | URL | UrlObject`
146
- * **options** [`PipelineOptions`](docs/api/Dispatcher.md#parameter-pipelineoptions)
147
- * **dispatcher** `Dispatcher` - Default: [getGlobalDispatcher](#undicigetglobaldispatcher)
148
- * **method** `String` - Default: `PUT` if `options.body`, otherwise `GET`
149
- * **maxRedirections** `Integer` - Default: `0`
150
- * **handler** `Dispatcher.pipeline.handler`
151
-
152
- Returns: `stream.Duplex`
153
-
154
- Calls `options.dispatch.pipeline(options, handler)`.
155
-
156
- See [Dispatcher.pipeline](docs/api/Dispatcher.md#dispatcherpipelineoptions-handler) for more details.
157
-
158
- ### `undici.connect([url, options]): Promise`
159
-
160
- Starts two-way communications with the requested resource using [HTTP CONNECT](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/CONNECT).
161
-
162
- Arguments:
163
-
164
- * **url** `string | URL | UrlObject`
165
- * **options** [`ConnectOptions`](docs/api/Dispatcher.md#parameter-connectoptions)
166
- * **dispatcher** `Dispatcher` - Default: [getGlobalDispatcher](#undicigetglobaldispatcher)
167
- * **maxRedirections** `Integer` - Default: `0`
168
- * **callback** `(err: Error | null, data: ConnectData | null) => void` (optional)
169
-
170
- Returns a promise with the result of the `Dispatcher.connect` method.
171
-
172
- Calls `options.dispatch.connect(options)`.
173
-
174
- See [Dispatcher.connect](docs/api/Dispatcher.md#dispatcherconnectoptions-callback) for more details.
175
-
176
- ### `undici.fetch(input[, init]): Promise`
177
-
178
- Implements [fetch](https://fetch.spec.whatwg.org/#fetch-method).
179
-
180
- * https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch
181
- * https://fetch.spec.whatwg.org/#fetch-method
182
-
183
- Only supported on Node 16.8+.
184
-
185
- Basic usage example:
186
-
187
- ```js
188
- import { fetch } from 'undici'
189
-
190
-
191
- const res = await fetch('https://example.com')
192
- const json = await res.json()
193
- console.log(json)
194
- ```
195
-
196
- You can pass an optional dispatcher to `fetch` as:
197
-
198
- ```js
199
- import { fetch, Agent } from 'undici'
200
-
201
- const res = await fetch('https://example.com', {
202
- // Mocks are also supported
203
- dispatcher: new Agent({
204
- keepAliveTimeout: 10,
205
- keepAliveMaxTimeout: 10
206
- })
207
- })
208
- const json = await res.json()
209
- console.log(json)
210
- ```
211
-
212
- #### `request.body`
213
-
214
- A body can be of the following types:
215
-
216
- - ArrayBuffer
217
- - ArrayBufferView
218
- - AsyncIterables
219
- - Blob
220
- - Iterables
221
- - String
222
- - URLSearchParams
223
- - FormData
224
-
225
- In this implementation of fetch, ```request.body``` now accepts ```Async Iterables```. It is not present in the [Fetch Standard.](https://fetch.spec.whatwg.org)
226
-
227
- ```js
228
- import { fetch } from 'undici'
229
-
230
- const data = {
231
- async *[Symbol.asyncIterator]() {
232
- yield 'hello'
233
- yield 'world'
234
- },
235
- }
236
-
237
- await fetch('https://example.com', { body: data, method: 'POST', duplex: 'half' })
238
- ```
239
-
240
- #### `request.duplex`
241
-
242
- - half
243
-
244
- In this implementation of fetch, `request.duplex` must be set if `request.body` is `ReadableStream` or `Async Iterables`. And fetch requests are currently always be full duplex. More detail refer to [Fetch Standard.](https://fetch.spec.whatwg.org/#dom-requestinit-duplex)
245
-
246
- #### `response.body`
247
-
248
- Nodejs has two kinds of streams: [web streams](https://nodejs.org/dist/latest-v16.x/docs/api/webstreams.html), which follow the API of the WHATWG web standard found in browsers, and an older Node-specific [streams API](https://nodejs.org/api/stream.html). `response.body` returns a readable web stream. If you would prefer to work with a Node stream you can convert a web stream using `.fromWeb()`.
249
-
250
- ```js
251
- import { fetch } from 'undici'
252
- import { Readable } from 'node:stream'
253
-
254
- const response = await fetch('https://example.com')
255
- const readableWebStream = response.body
256
- const readableNodeStream = Readable.fromWeb(readableWebStream)
257
- ```
258
-
259
- #### Specification Compliance
260
-
261
- This section documents parts of the [Fetch Standard](https://fetch.spec.whatwg.org) that Undici does
262
- not support or does not fully implement.
263
-
264
- ##### Garbage Collection
265
-
266
- * https://fetch.spec.whatwg.org/#garbage-collection
267
-
268
- The [Fetch Standard](https://fetch.spec.whatwg.org) allows users to skip consuming the response body by relying on
269
- [garbage collection](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memory_Management#garbage_collection) to release connection resources. Undici does not do the same. Therefore, it is important to always either consume or cancel the response body.
270
-
271
- Garbage collection in Node is less aggressive and deterministic
272
- (due to the lack of clear idle periods that browsers have through the rendering refresh rate)
273
- which means that leaving the release of connection resources to the garbage collector can lead
274
- to excessive connection usage, reduced performance (due to less connection re-use), and even
275
- stalls or deadlocks when running out of connections.
276
-
277
- ```js
278
- // Do
279
- const headers = await fetch(url)
280
- .then(async res => {
281
- for await (const chunk of res.body) {
282
- // force consumption of body
283
- }
284
- return res.headers
285
- })
286
-
287
- // Do not
288
- const headers = await fetch(url)
289
- .then(res => res.headers)
290
- ```
291
-
292
- However, if you want to get only headers, it might be better to use `HEAD` request method. Usage of this method will obviate the need for consumption or cancelling of the response body. See [MDN - HTTP - HTTP request methods - HEAD](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD) for more details.
293
-
294
- ```js
295
- const headers = await fetch(url, { method: 'HEAD' })
296
- .then(res => res.headers)
297
- ```
298
-
299
- ##### Forbidden and Safelisted Header Names
300
-
301
- * https://fetch.spec.whatwg.org/#cors-safelisted-response-header-name
302
- * https://fetch.spec.whatwg.org/#forbidden-header-name
303
- * https://fetch.spec.whatwg.org/#forbidden-response-header-name
304
- * https://github.com/wintercg/fetch/issues/6
305
-
306
- The [Fetch Standard](https://fetch.spec.whatwg.org) requires implementations to exclude certain headers from requests and responses. In browser environments, some headers are forbidden so the user agent remains in full control over them. In Undici, these constraints are removed to give more control to the user.
307
-
308
- ### `undici.upgrade([url, options]): Promise`
309
-
310
- Upgrade to a different protocol. See [MDN - HTTP - Protocol upgrade mechanism](https://developer.mozilla.org/en-US/docs/Web/HTTP/Protocol_upgrade_mechanism) for more details.
311
-
312
- Arguments:
313
-
314
- * **url** `string | URL | UrlObject`
315
- * **options** [`UpgradeOptions`](docs/api/Dispatcher.md#parameter-upgradeoptions)
316
- * **dispatcher** `Dispatcher` - Default: [getGlobalDispatcher](#undicigetglobaldispatcher)
317
- * **maxRedirections** `Integer` - Default: `0`
318
- * **callback** `(error: Error | null, data: UpgradeData) => void` (optional)
319
-
320
- Returns a promise with the result of the `Dispatcher.upgrade` method.
321
-
322
- Calls `options.dispatcher.upgrade(options)`.
323
-
324
- See [Dispatcher.upgrade](docs/api/Dispatcher.md#dispatcherupgradeoptions-callback) for more details.
325
-
326
- ### `undici.setGlobalDispatcher(dispatcher)`
327
-
328
- * dispatcher `Dispatcher`
329
-
330
- Sets the global dispatcher used by Common API Methods.
331
-
332
- ### `undici.getGlobalDispatcher()`
333
-
334
- Gets the global dispatcher used by Common API Methods.
335
-
336
- Returns: `Dispatcher`
337
-
338
- ### `undici.setGlobalOrigin(origin)`
339
-
340
- * origin `string | URL | undefined`
341
-
342
- Sets the global origin used in `fetch`.
343
-
344
- If `undefined` is passed, the global origin will be reset. This will cause `Response.redirect`, `new Request()`, and `fetch` to throw an error when a relative path is passed.
345
-
346
- ```js
347
- setGlobalOrigin('http://localhost:3000')
348
-
349
- const response = await fetch('/api/ping')
350
-
351
- console.log(response.url) // http://localhost:3000/api/ping
352
- ```
353
-
354
- ### `undici.getGlobalOrigin()`
355
-
356
- Gets the global origin used in `fetch`.
357
-
358
- Returns: `URL`
359
-
360
- ### `UrlObject`
361
-
362
- * **port** `string | number` (optional)
363
- * **path** `string` (optional)
364
- * **pathname** `string` (optional)
365
- * **hostname** `string` (optional)
366
- * **origin** `string` (optional)
367
- * **protocol** `string` (optional)
368
- * **search** `string` (optional)
369
-
370
- ## Specification Compliance
371
-
372
- This section documents parts of the HTTP/1.1 specification that Undici does
373
- not support or does not fully implement.
374
-
375
- ### Expect
376
-
377
- Undici does not support the `Expect` request header field. The request
378
- body is always immediately sent and the `100 Continue` response will be
379
- ignored.
380
-
381
- Refs: https://tools.ietf.org/html/rfc7231#section-5.1.1
382
-
383
- ### Pipelining
384
-
385
- Undici will only use pipelining if configured with a `pipelining` factor
386
- greater than `1`.
387
-
388
- Undici always assumes that connections are persistent and will immediately
389
- pipeline requests, without checking whether the connection is persistent.
390
- Hence, automatic fallback to HTTP/1.0 or HTTP/1.1 without pipelining is
391
- not supported.
392
-
393
- Undici will immediately pipeline when retrying requests after a failed
394
- connection. However, Undici will not retry the first remaining requests in
395
- the prior pipeline and instead error the corresponding callback/promise/stream.
396
-
397
- Undici will abort all running requests in the pipeline when any of them are
398
- aborted.
399
-
400
- * Refs: https://tools.ietf.org/html/rfc2616#section-8.1.2.2
401
- * Refs: https://tools.ietf.org/html/rfc7230#section-6.3.2
402
-
403
- ### Manual Redirect
404
-
405
- Since it is not possible to manually follow an HTTP redirect on the server-side,
406
- Undici returns the actual response instead of an `opaqueredirect` filtered one
407
- when invoked with a `manual` redirect. This aligns `fetch()` with the other
408
- implementations in Deno and Cloudflare Workers.
409
-
410
- Refs: https://fetch.spec.whatwg.org/#atomic-http-redirect-handling
411
-
412
- ## Workarounds
413
-
414
- ### Network address family autoselection.
415
-
416
- If you experience problem when connecting to a remote server that is resolved by your DNS servers to a IPv6 (AAAA record)
417
- first, there are chances that your local router or ISP might have problem connecting to IPv6 networks. In that case
418
- undici will throw an error with code `UND_ERR_CONNECT_TIMEOUT`.
419
-
420
- If the target server resolves to both a IPv6 and IPv4 (A records) address and you are using a compatible Node version
421
- (18.3.0 and above), you can fix the problem by providing the `autoSelectFamily` option (support by both `undici.request`
422
- and `undici.Agent`) which will enable the family autoselection algorithm when establishing the connection.
423
-
424
- ## Collaborators
425
-
426
- * [__Daniele Belardi__](https://github.com/dnlup), <https://www.npmjs.com/~dnlup>
427
- * [__Ethan Arrowood__](https://github.com/ethan-arrowood), <https://www.npmjs.com/~ethan_arrowood>
428
- * [__Matteo Collina__](https://github.com/mcollina), <https://www.npmjs.com/~matteo.collina>
429
- * [__Matthew Aitken__](https://github.com/KhafraDev), <https://www.npmjs.com/~khaf>
430
- * [__Robert Nagy__](https://github.com/ronag), <https://www.npmjs.com/~ronag>
431
- * [__Szymon Marczak__](https://github.com/szmarczak), <https://www.npmjs.com/~szmarczak>
432
- * [__Tomas Della Vedova__](https://github.com/delvedor), <https://www.npmjs.com/~delvedor>
433
-
434
- ### Releasers
435
-
436
- * [__Ethan Arrowood__](https://github.com/ethan-arrowood), <https://www.npmjs.com/~ethan_arrowood>
437
- * [__Matteo Collina__](https://github.com/mcollina), <https://www.npmjs.com/~matteo.collina>
438
- * [__Robert Nagy__](https://github.com/ronag), <https://www.npmjs.com/~ronag>
439
-
440
- ## License
441
-
442
- MIT
package/index.d.ts DELETED
@@ -1,57 +0,0 @@
1
- import Dispatcher from'./types/dispatcher'
2
- import { setGlobalDispatcher, getGlobalDispatcher } from './types/global-dispatcher'
3
- import { setGlobalOrigin, getGlobalOrigin } from './types/global-origin'
4
- import Pool from'./types/pool'
5
- import { RedirectHandler, DecoratorHandler } from './types/handlers'
6
-
7
- import BalancedPool from './types/balanced-pool'
8
- import Client from'./types/client'
9
- import buildConnector from'./types/connector'
10
- import errors from'./types/errors'
11
- import Agent from'./types/agent'
12
- import MockClient from'./types/mock-client'
13
- import MockPool from'./types/mock-pool'
14
- import MockAgent from'./types/mock-agent'
15
- import mockErrors from'./types/mock-errors'
16
- import ProxyAgent from'./types/proxy-agent'
17
- import { request, pipeline, stream, connect, upgrade } from './types/api'
18
-
19
- export * from './types/cookies'
20
- export * from './types/fetch'
21
- export * from './types/file'
22
- export * from './types/filereader'
23
- export * from './types/formdata'
24
- export * from './types/diagnostics-channel'
25
- export * from './types/websocket'
26
- export * from './types/content-type'
27
- export * from './types/cache'
28
- export { Interceptable } from './types/mock-interceptor'
29
-
30
- export { Dispatcher, BalancedPool, Pool, Client, buildConnector, errors, Agent, request, stream, pipeline, connect, upgrade, setGlobalDispatcher, getGlobalDispatcher, setGlobalOrigin, getGlobalOrigin, MockClient, MockPool, MockAgent, mockErrors, ProxyAgent, RedirectHandler, DecoratorHandler }
31
- export default Undici
32
-
33
- declare namespace Undici {
34
- var Dispatcher: typeof import('./types/dispatcher').default
35
- var Pool: typeof import('./types/pool').default;
36
- var RedirectHandler: typeof import ('./types/handlers').RedirectHandler
37
- var DecoratorHandler: typeof import ('./types/handlers').DecoratorHandler
38
- var createRedirectInterceptor: typeof import ('./types/interceptors').createRedirectInterceptor
39
- var BalancedPool: typeof import('./types/balanced-pool').default;
40
- var Client: typeof import('./types/client').default;
41
- var buildConnector: typeof import('./types/connector').default;
42
- var errors: typeof import('./types/errors').default;
43
- var Agent: typeof import('./types/agent').default;
44
- var setGlobalDispatcher: typeof import('./types/global-dispatcher').setGlobalDispatcher;
45
- var getGlobalDispatcher: typeof import('./types/global-dispatcher').getGlobalDispatcher;
46
- var request: typeof import('./types/api').request;
47
- var stream: typeof import('./types/api').stream;
48
- var pipeline: typeof import('./types/api').pipeline;
49
- var connect: typeof import('./types/api').connect;
50
- var upgrade: typeof import('./types/api').upgrade;
51
- var MockClient: typeof import('./types/mock-client').default;
52
- var MockPool: typeof import('./types/mock-pool').default;
53
- var MockAgent: typeof import('./types/mock-agent').default;
54
- var mockErrors: typeof import('./types/mock-errors').default;
55
- var fetch: typeof import('./types/fetch').fetch;
56
- var caches: typeof import('./types/cache').caches;
57
- }
package/types/agent.d.ts DELETED
@@ -1,31 +0,0 @@
1
- import { URL } from 'url'
2
- import Pool from './pool'
3
- import Dispatcher from "./dispatcher";
4
-
5
- export default Agent
6
-
7
- declare class Agent extends Dispatcher{
8
- constructor(opts?: Agent.Options)
9
- /** `true` after `dispatcher.close()` has been called. */
10
- closed: boolean;
11
- /** `true` after `dispatcher.destroyed()` has been called or `dispatcher.close()` has been called and the dispatcher shutdown has completed. */
12
- destroyed: boolean;
13
- /** Dispatches a request. */
14
- dispatch(options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandlers): boolean;
15
- }
16
-
17
- declare namespace Agent {
18
- export interface Options extends Pool.Options {
19
- /** Default: `(origin, opts) => new Pool(origin, opts)`. */
20
- factory?(origin: URL, opts: Object): Dispatcher;
21
- /** Integer. Default: `0` */
22
- maxRedirections?: number;
23
-
24
- interceptors?: { Agent?: readonly Dispatcher.DispatchInterceptor[] } & Pool.Options["interceptors"]
25
- }
26
-
27
- export interface DispatchOptions extends Dispatcher.DispatchOptions {
28
- /** Integer. */
29
- maxRedirections?: number;
30
- }
31
- }
package/types/api.d.ts DELETED
@@ -1,43 +0,0 @@
1
- import { URL, UrlObject } from 'url'
2
- import { Duplex } from 'stream'
3
- import Dispatcher from './dispatcher'
4
-
5
- export {
6
- request,
7
- stream,
8
- pipeline,
9
- connect,
10
- upgrade,
11
- }
12
-
13
- /** Performs an HTTP request. */
14
- declare function request(
15
- url: string | URL | UrlObject,
16
- options?: { dispatcher?: Dispatcher } & Omit<Dispatcher.RequestOptions, 'origin' | 'path' | 'method'> & Partial<Pick<Dispatcher.RequestOptions, 'method'>>,
17
- ): Promise<Dispatcher.ResponseData>;
18
-
19
- /** A faster version of `request`. */
20
- declare function stream(
21
- url: string | URL | UrlObject,
22
- options: { dispatcher?: Dispatcher } & Omit<Dispatcher.RequestOptions, 'origin' | 'path'>,
23
- factory: Dispatcher.StreamFactory
24
- ): Promise<Dispatcher.StreamData>;
25
-
26
- /** For easy use with `stream.pipeline`. */
27
- declare function pipeline(
28
- url: string | URL | UrlObject,
29
- options: { dispatcher?: Dispatcher } & Omit<Dispatcher.PipelineOptions, 'origin' | 'path'>,
30
- handler: Dispatcher.PipelineHandler
31
- ): Duplex;
32
-
33
- /** Starts two-way communications with the requested resource. */
34
- declare function connect(
35
- url: string | URL | UrlObject,
36
- options?: { dispatcher?: Dispatcher } & Omit<Dispatcher.ConnectOptions, 'origin' | 'path'>
37
- ): Promise<Dispatcher.ConnectData>;
38
-
39
- /** Upgrade to a different protocol. */
40
- declare function upgrade(
41
- url: string | URL | UrlObject,
42
- options?: { dispatcher?: Dispatcher } & Omit<Dispatcher.UpgradeOptions, 'origin' | 'path'>
43
- ): Promise<Dispatcher.UpgradeData>;
@@ -1,18 +0,0 @@
1
- import Pool from './pool'
2
- import Dispatcher from './dispatcher'
3
- import { URL } from 'url'
4
-
5
- export default BalancedPool
6
-
7
- declare class BalancedPool extends Dispatcher {
8
- constructor(url: string | string[] | URL | URL[], options?: Pool.Options);
9
-
10
- addUpstream(upstream: string | URL): BalancedPool;
11
- removeUpstream(upstream: string | URL): BalancedPool;
12
- upstreams: Array<string>;
13
-
14
- /** `true` after `pool.close()` has been called. */
15
- closed: boolean;
16
- /** `true` after `pool.destroyed()` has been called or `pool.close()` has been called and the pool shutdown has completed. */
17
- destroyed: boolean;
18
- }
package/types/cache.d.ts DELETED
@@ -1,36 +0,0 @@
1
- import type { RequestInfo, Response, Request } from './fetch'
2
-
3
- export interface CacheStorage {
4
- match (request: RequestInfo, options?: MultiCacheQueryOptions): Promise<Response | undefined>,
5
- has (cacheName: string): Promise<boolean>,
6
- open (cacheName: string): Promise<Cache>,
7
- delete (cacheName: string): Promise<boolean>,
8
- keys (): Promise<string[]>
9
- }
10
-
11
- declare const CacheStorage: {
12
- prototype: CacheStorage
13
- new(): CacheStorage
14
- }
15
-
16
- export interface Cache {
17
- match (request: RequestInfo, options?: CacheQueryOptions): Promise<Response | undefined>,
18
- matchAll (request?: RequestInfo, options?: CacheQueryOptions): Promise<readonly Response[]>,
19
- add (request: RequestInfo): Promise<undefined>,
20
- addAll (requests: RequestInfo[]): Promise<undefined>,
21
- put (request: RequestInfo, response: Response): Promise<undefined>,
22
- delete (request: RequestInfo, options?: CacheQueryOptions): Promise<boolean>,
23
- keys (request?: RequestInfo, options?: CacheQueryOptions): Promise<readonly Request[]>
24
- }
25
-
26
- export interface CacheQueryOptions {
27
- ignoreSearch?: boolean,
28
- ignoreMethod?: boolean,
29
- ignoreVary?: boolean
30
- }
31
-
32
- export interface MultiCacheQueryOptions extends CacheQueryOptions {
33
- cacheName?: string
34
- }
35
-
36
- export declare const caches: CacheStorage