undici-types 7.16.0 → 7.18.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 +1 -1
- package/api.d.ts +2 -2
- package/balanced-pool.d.ts +2 -1
- package/cache-interceptor.d.ts +1 -0
- package/client.d.ts +1 -1
- package/connector.d.ts +2 -2
- package/diagnostics-channel.d.ts +2 -2
- package/dispatcher.d.ts +12 -12
- package/fetch.d.ts +4 -4
- package/formdata.d.ts +1 -1
- package/h2c-client.d.ts +1 -1
- package/index.d.ts +9 -1
- package/interceptors.d.ts +36 -2
- package/package.json +1 -1
- package/pool.d.ts +1 -1
- package/readable.d.ts +2 -2
- package/round-robin-pool.d.ts +41 -0
- package/websocket.d.ts +9 -9
package/agent.d.ts
CHANGED
package/api.d.ts
CHANGED
package/balanced-pool.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Pool from './pool'
|
|
2
2
|
import Dispatcher from './dispatcher'
|
|
3
|
-
import { URL } from 'url'
|
|
3
|
+
import { URL } from 'node:url'
|
|
4
4
|
|
|
5
5
|
export default BalancedPool
|
|
6
6
|
|
|
@@ -11,6 +11,7 @@ declare class BalancedPool extends Dispatcher {
|
|
|
11
11
|
|
|
12
12
|
addUpstream (upstream: string | URL): BalancedPool
|
|
13
13
|
removeUpstream (upstream: string | URL): BalancedPool
|
|
14
|
+
getUpstream (upstream: string | URL): Pool | undefined
|
|
14
15
|
upstreams: Array<string>
|
|
15
16
|
|
|
16
17
|
/** `true` after `pool.close()` has been called. */
|
package/cache-interceptor.d.ts
CHANGED
package/client.d.ts
CHANGED
package/connector.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TLSSocket, ConnectionOptions } from 'tls'
|
|
2
|
-
import { IpcNetConnectOpts, Socket, TcpNetConnectOpts } from 'net'
|
|
1
|
+
import { TLSSocket, ConnectionOptions } from 'node:tls'
|
|
2
|
+
import { IpcNetConnectOpts, Socket, TcpNetConnectOpts } from 'node:net'
|
|
3
3
|
|
|
4
4
|
export default buildConnector
|
|
5
5
|
declare function buildConnector (options?: buildConnector.BuildOptions): buildConnector.connector
|
package/diagnostics-channel.d.ts
CHANGED
package/dispatcher.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { URL } from 'url'
|
|
2
|
-
import { Duplex, Readable, Writable } from 'stream'
|
|
3
|
-
import { EventEmitter } from 'events'
|
|
4
|
-
import { Blob } from 'buffer'
|
|
1
|
+
import { URL } from 'node:url'
|
|
2
|
+
import { Duplex, Readable, Writable } from 'node:stream'
|
|
3
|
+
import { EventEmitter } from 'node:events'
|
|
4
|
+
import { Blob } from 'node:buffer'
|
|
5
5
|
import { IncomingHttpHeaders } from './header'
|
|
6
6
|
import BodyReadable from './readable'
|
|
7
7
|
import { FormData } from './formdata'
|
|
@@ -19,30 +19,30 @@ declare class Dispatcher extends EventEmitter {
|
|
|
19
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. */
|
|
20
20
|
dispatch (options: Dispatcher.DispatchOptions, handler: Dispatcher.DispatchHandler): boolean
|
|
21
21
|
/** Starts two-way communications with the requested resource. */
|
|
22
|
-
connect<TOpaque = null>(options: Dispatcher.ConnectOptions<TOpaque>): Promise<Dispatcher.ConnectData<TOpaque>>
|
|
23
22
|
connect<TOpaque = null>(options: Dispatcher.ConnectOptions<TOpaque>, callback: (err: Error | null, data: Dispatcher.ConnectData<TOpaque>) => void): void
|
|
23
|
+
connect<TOpaque = null>(options: Dispatcher.ConnectOptions<TOpaque>): Promise<Dispatcher.ConnectData<TOpaque>>
|
|
24
24
|
/** Compose a chain of dispatchers */
|
|
25
25
|
compose (dispatchers: Dispatcher.DispatcherComposeInterceptor[]): Dispatcher.ComposedDispatcher
|
|
26
26
|
compose (...dispatchers: Dispatcher.DispatcherComposeInterceptor[]): Dispatcher.ComposedDispatcher
|
|
27
27
|
/** Performs an HTTP request. */
|
|
28
|
-
request<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>): Promise<Dispatcher.ResponseData<TOpaque>>
|
|
29
28
|
request<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>, callback: (err: Error | null, data: Dispatcher.ResponseData<TOpaque>) => void): void
|
|
29
|
+
request<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>): Promise<Dispatcher.ResponseData<TOpaque>>
|
|
30
30
|
/** For easy use with `stream.pipeline`. */
|
|
31
31
|
pipeline<TOpaque = null>(options: Dispatcher.PipelineOptions<TOpaque>, handler: Dispatcher.PipelineHandler<TOpaque>): Duplex
|
|
32
32
|
/** A faster version of `Dispatcher.request`. */
|
|
33
|
-
stream<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>, factory: Dispatcher.StreamFactory<TOpaque>): Promise<Dispatcher.StreamData<TOpaque>>
|
|
34
33
|
stream<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>, factory: Dispatcher.StreamFactory<TOpaque>, callback: (err: Error | null, data: Dispatcher.StreamData<TOpaque>) => void): void
|
|
34
|
+
stream<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>, factory: Dispatcher.StreamFactory<TOpaque>): Promise<Dispatcher.StreamData<TOpaque>>
|
|
35
35
|
/** Upgrade to a different protocol. */
|
|
36
|
-
upgrade (options: Dispatcher.UpgradeOptions): Promise<Dispatcher.UpgradeData>
|
|
37
36
|
upgrade (options: Dispatcher.UpgradeOptions, callback: (err: Error | null, data: Dispatcher.UpgradeData) => void): void
|
|
37
|
+
upgrade (options: Dispatcher.UpgradeOptions): Promise<Dispatcher.UpgradeData>
|
|
38
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). */
|
|
39
|
-
close (): Promise<void>
|
|
40
39
|
close (callback: () => void): void
|
|
40
|
+
close (): Promise<void>
|
|
41
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. */
|
|
42
|
-
destroy (): Promise<void>
|
|
43
|
-
destroy (err: Error | null): Promise<void>
|
|
44
|
-
destroy (callback: () => void): void
|
|
45
42
|
destroy (err: Error | null, callback: () => void): void
|
|
43
|
+
destroy (callback: () => void): void
|
|
44
|
+
destroy (err: Error | null): Promise<void>
|
|
45
|
+
destroy (): Promise<void>
|
|
46
46
|
|
|
47
47
|
on (eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this
|
|
48
48
|
on (eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
package/fetch.d.ts
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// and https://github.com/node-fetch/node-fetch/blob/914ce6be5ec67a8bab63d68510aabf07cb818b6d/index.d.ts (MIT license)
|
|
3
3
|
/// <reference types="node" />
|
|
4
4
|
|
|
5
|
-
import { Blob } from 'buffer'
|
|
6
|
-
import { URL, URLSearchParams } from 'url'
|
|
7
|
-
import { ReadableStream } from 'stream/web'
|
|
5
|
+
import { Blob } from 'node:buffer'
|
|
6
|
+
import { URL, URLSearchParams } from 'node:url'
|
|
7
|
+
import { ReadableStream } from 'node:stream/web'
|
|
8
8
|
import { FormData } from './formdata'
|
|
9
9
|
import { HeaderRecord } from './header'
|
|
10
10
|
import Dispatcher from './dispatcher'
|
|
@@ -207,5 +207,5 @@ export declare class Response extends BodyMixin {
|
|
|
207
207
|
|
|
208
208
|
static error (): Response
|
|
209
209
|
static json (data: any, init?: ResponseInit): Response
|
|
210
|
-
static redirect (url: string | URL, status
|
|
210
|
+
static redirect (url: string | URL, status?: ResponseRedirectStatus): Response
|
|
211
211
|
}
|
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 'buffer'
|
|
4
|
+
import { File } from 'node:buffer'
|
|
5
5
|
import { SpecIterableIterator } from './fetch'
|
|
6
6
|
|
|
7
7
|
/**
|
package/h2c-client.d.ts
CHANGED
package/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import Pool from './pool'
|
|
|
5
5
|
import { RedirectHandler, DecoratorHandler } from './handlers'
|
|
6
6
|
|
|
7
7
|
import BalancedPool from './balanced-pool'
|
|
8
|
+
import RoundRobinPool from './round-robin-pool'
|
|
8
9
|
import Client from './client'
|
|
9
10
|
import H2CClient from './h2c-client'
|
|
10
11
|
import buildConnector from './connector'
|
|
@@ -23,6 +24,12 @@ import RetryAgent from './retry-agent'
|
|
|
23
24
|
import { request, pipeline, stream, connect, upgrade } from './api'
|
|
24
25
|
import interceptors from './interceptors'
|
|
25
26
|
|
|
27
|
+
import CacheInterceptor from './cache-interceptor'
|
|
28
|
+
declare const cacheStores: {
|
|
29
|
+
MemoryCacheStore: typeof CacheInterceptor.MemoryCacheStore;
|
|
30
|
+
SqliteCacheStore: typeof CacheInterceptor.SqliteCacheStore;
|
|
31
|
+
}
|
|
32
|
+
|
|
26
33
|
export * from './util'
|
|
27
34
|
export * from './cookies'
|
|
28
35
|
export * from './eventsource'
|
|
@@ -36,7 +43,7 @@ export { Interceptable } from './mock-interceptor'
|
|
|
36
43
|
|
|
37
44
|
declare function globalThisInstall (): void
|
|
38
45
|
|
|
39
|
-
export { Dispatcher, BalancedPool, Pool, Client, buildConnector, errors, Agent, request, stream, pipeline, connect, upgrade, setGlobalDispatcher, getGlobalDispatcher, setGlobalOrigin, getGlobalOrigin, interceptors, MockClient, MockPool, MockAgent, SnapshotAgent, MockCallHistory, MockCallHistoryLog, mockErrors, ProxyAgent, EnvHttpProxyAgent, RedirectHandler, DecoratorHandler, RetryHandler, RetryAgent, H2CClient, globalThisInstall as install }
|
|
46
|
+
export { Dispatcher, BalancedPool, RoundRobinPool, Pool, Client, buildConnector, errors, Agent, request, stream, pipeline, connect, upgrade, setGlobalDispatcher, getGlobalDispatcher, setGlobalOrigin, getGlobalOrigin, interceptors, cacheStores, MockClient, MockPool, MockAgent, SnapshotAgent, MockCallHistory, MockCallHistoryLog, mockErrors, ProxyAgent, EnvHttpProxyAgent, RedirectHandler, DecoratorHandler, RetryHandler, RetryAgent, H2CClient, globalThisInstall as install }
|
|
40
47
|
export default Undici
|
|
41
48
|
|
|
42
49
|
declare namespace Undici {
|
|
@@ -46,6 +53,7 @@ declare namespace Undici {
|
|
|
46
53
|
const DecoratorHandler: typeof import ('./handlers').DecoratorHandler
|
|
47
54
|
const RetryHandler: typeof import ('./retry-handler').default
|
|
48
55
|
const BalancedPool: typeof import('./balanced-pool').default
|
|
56
|
+
const RoundRobinPool: typeof import('./round-robin-pool').default
|
|
49
57
|
const Client: typeof import('./client').default
|
|
50
58
|
const H2CClient: typeof import('./h2c-client').default
|
|
51
59
|
const buildConnector: typeof import('./connector').default
|
package/interceptors.d.ts
CHANGED
|
@@ -19,14 +19,47 @@ declare namespace Interceptors {
|
|
|
19
19
|
|
|
20
20
|
// DNS interceptor
|
|
21
21
|
export type DNSInterceptorRecord = { address: string, ttl: number, family: 4 | 6 }
|
|
22
|
-
export type DNSInterceptorOriginRecords = { 4: { ips: DNSInterceptorRecord[] } | null, 6: { ips: DNSInterceptorRecord[] } | null }
|
|
22
|
+
export type DNSInterceptorOriginRecords = { records: { 4: { ips: DNSInterceptorRecord[] } | null, 6: { ips: DNSInterceptorRecord[] } | null } }
|
|
23
|
+
export type DNSStorage = {
|
|
24
|
+
size: number
|
|
25
|
+
get(origin: string): DNSInterceptorOriginRecords | null
|
|
26
|
+
set(origin: string, records: DNSInterceptorOriginRecords | null, options: { ttl: number }): void
|
|
27
|
+
delete(origin: string): void
|
|
28
|
+
full(): boolean
|
|
29
|
+
}
|
|
23
30
|
export type DNSInterceptorOpts = {
|
|
24
31
|
maxTTL?: number
|
|
25
32
|
maxItems?: number
|
|
26
|
-
lookup?: (
|
|
33
|
+
lookup?: (origin: URL, options: LookupOptions, callback: (err: NodeJS.ErrnoException | null, addresses: DNSInterceptorRecord[]) => void) => void
|
|
27
34
|
pick?: (origin: URL, records: DNSInterceptorOriginRecords, affinity: 4 | 6) => DNSInterceptorRecord
|
|
28
35
|
dualStack?: boolean
|
|
29
36
|
affinity?: 4 | 6
|
|
37
|
+
storage?: DNSStorage
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Deduplicate interceptor
|
|
41
|
+
export type DeduplicateMethods = 'GET' | 'HEAD' | 'OPTIONS' | 'TRACE'
|
|
42
|
+
export type DeduplicateInterceptorOpts = {
|
|
43
|
+
/**
|
|
44
|
+
* The HTTP methods to deduplicate.
|
|
45
|
+
* Note: Only safe HTTP methods can be deduplicated.
|
|
46
|
+
* @default ['GET']
|
|
47
|
+
*/
|
|
48
|
+
methods?: DeduplicateMethods[]
|
|
49
|
+
/**
|
|
50
|
+
* Header names that, if present in a request, will cause the request to skip deduplication.
|
|
51
|
+
* Header name matching is case-insensitive.
|
|
52
|
+
* @default []
|
|
53
|
+
*/
|
|
54
|
+
skipHeaderNames?: string[]
|
|
55
|
+
/**
|
|
56
|
+
* Header names to exclude from the deduplication key.
|
|
57
|
+
* Requests with different values for these headers will still be deduplicated together.
|
|
58
|
+
* Useful for headers like `x-request-id` that vary per request but shouldn't affect deduplication.
|
|
59
|
+
* Header name matching is case-insensitive.
|
|
60
|
+
* @default []
|
|
61
|
+
*/
|
|
62
|
+
excludeHeaderNames?: string[]
|
|
30
63
|
}
|
|
31
64
|
|
|
32
65
|
export function dump (opts?: DumpInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
|
|
@@ -36,4 +69,5 @@ declare namespace Interceptors {
|
|
|
36
69
|
export function responseError (opts?: ResponseErrorInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
|
|
37
70
|
export function dns (opts?: DNSInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
|
|
38
71
|
export function cache (opts?: CacheInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
|
|
72
|
+
export function deduplicate (opts?: DeduplicateInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
|
|
39
73
|
}
|
package/package.json
CHANGED
package/pool.d.ts
CHANGED
package/readable.d.ts
CHANGED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import Client from './client'
|
|
2
|
+
import TPoolStats from './pool-stats'
|
|
3
|
+
import { URL } from 'node:url'
|
|
4
|
+
import Dispatcher from './dispatcher'
|
|
5
|
+
|
|
6
|
+
export default RoundRobinPool
|
|
7
|
+
|
|
8
|
+
type RoundRobinPoolConnectOptions = Omit<Dispatcher.ConnectOptions, 'origin'>
|
|
9
|
+
|
|
10
|
+
declare class RoundRobinPool extends Dispatcher {
|
|
11
|
+
constructor (url: string | URL, options?: RoundRobinPool.Options)
|
|
12
|
+
/** `true` after `pool.close()` has been called. */
|
|
13
|
+
closed: boolean
|
|
14
|
+
/** `true` after `pool.destroyed()` has been called or `pool.close()` has been called and the pool shutdown has completed. */
|
|
15
|
+
destroyed: boolean
|
|
16
|
+
/** Aggregate stats for a RoundRobinPool. */
|
|
17
|
+
readonly stats: TPoolStats
|
|
18
|
+
|
|
19
|
+
// Override dispatcher APIs.
|
|
20
|
+
override connect (
|
|
21
|
+
options: RoundRobinPoolConnectOptions
|
|
22
|
+
): Promise<Dispatcher.ConnectData>
|
|
23
|
+
override connect (
|
|
24
|
+
options: RoundRobinPoolConnectOptions,
|
|
25
|
+
callback: (err: Error | null, data: Dispatcher.ConnectData) => void
|
|
26
|
+
): void
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare namespace RoundRobinPool {
|
|
30
|
+
export type RoundRobinPoolStats = TPoolStats
|
|
31
|
+
export interface Options extends Client.Options {
|
|
32
|
+
/** Default: `(origin, opts) => new Client(origin, opts)`. */
|
|
33
|
+
factory?(origin: URL, opts: object): Dispatcher;
|
|
34
|
+
/** The max number of clients to create. `null` if no limit. Default `null`. */
|
|
35
|
+
connections?: number | null;
|
|
36
|
+
/** The amount of time before a client is removed from the pool and closed. `null` if no time limit. Default `null` */
|
|
37
|
+
clientTtl?: number | null;
|
|
38
|
+
|
|
39
|
+
interceptors?: { RoundRobinPool?: readonly Dispatcher.DispatchInterceptor[] } & Client.Options['interceptors']
|
|
40
|
+
}
|
|
41
|
+
}
|
package/websocket.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
|
|
3
|
-
import type { Blob } from 'buffer'
|
|
4
|
-
import type { ReadableStream, WritableStream } from 'stream/web'
|
|
5
|
-
import type { MessagePort } from 'worker_threads'
|
|
3
|
+
import type { Blob } from 'node:buffer'
|
|
4
|
+
import type { ReadableStream, WritableStream } from 'node:stream/web'
|
|
5
|
+
import type { MessagePort } from 'node:worker_threads'
|
|
6
6
|
import {
|
|
7
7
|
EventInit,
|
|
8
8
|
EventListenerOptions,
|
|
@@ -96,16 +96,16 @@ interface MessageEventInit<T = any> extends EventInit {
|
|
|
96
96
|
data?: T
|
|
97
97
|
lastEventId?: string
|
|
98
98
|
origin?: string
|
|
99
|
-
ports?:
|
|
100
|
-
source?:
|
|
99
|
+
ports?: MessagePort[]
|
|
100
|
+
source?: MessagePort | null
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
interface MessageEvent<T = any> extends Event {
|
|
104
104
|
readonly data: T
|
|
105
105
|
readonly lastEventId: string
|
|
106
106
|
readonly origin: string
|
|
107
|
-
readonly ports:
|
|
108
|
-
readonly source:
|
|
107
|
+
readonly ports: readonly MessagePort[]
|
|
108
|
+
readonly source: MessagePort | null
|
|
109
109
|
initMessageEvent(
|
|
110
110
|
type: string,
|
|
111
111
|
bubbles?: boolean,
|
|
@@ -113,8 +113,8 @@ interface MessageEvent<T = any> extends Event {
|
|
|
113
113
|
data?: any,
|
|
114
114
|
origin?: string,
|
|
115
115
|
lastEventId?: string,
|
|
116
|
-
source?:
|
|
117
|
-
ports?:
|
|
116
|
+
source?: MessagePort | null,
|
|
117
|
+
ports?: MessagePort[]
|
|
118
118
|
): void;
|
|
119
119
|
}
|
|
120
120
|
|