undici-types 7.5.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/dispatcher.d.ts +5 -3
- package/h2c-client.d.ts +75 -0
- package/index.d.ts +3 -1
- package/package.json +1 -1
- package/websocket.d.ts +1 -0
package/dispatcher.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ type AbortSignal = unknown
|
|
|
12
12
|
|
|
13
13
|
export default Dispatcher
|
|
14
14
|
|
|
15
|
+
export type UndiciHeaders = Record<string, string | string[]> | IncomingHttpHeaders | string[] | Iterable<[string, string | string[] | undefined]> | null
|
|
16
|
+
|
|
15
17
|
/** Dispatcher is the core API used to dispatch requests. */
|
|
16
18
|
declare class Dispatcher extends EventEmitter {
|
|
17
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. */
|
|
@@ -103,7 +105,7 @@ declare namespace Dispatcher {
|
|
|
103
105
|
/** Default: `null` */
|
|
104
106
|
body?: string | Buffer | Uint8Array | Readable | null | FormData;
|
|
105
107
|
/** Default: `null` */
|
|
106
|
-
headers?:
|
|
108
|
+
headers?: UndiciHeaders;
|
|
107
109
|
/** Query string params to be embedded in the request URL. Default: `null` */
|
|
108
110
|
query?: Record<string, any>;
|
|
109
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`. */
|
|
@@ -127,7 +129,7 @@ declare namespace Dispatcher {
|
|
|
127
129
|
origin: string | URL;
|
|
128
130
|
path: string;
|
|
129
131
|
/** Default: `null` */
|
|
130
|
-
headers?:
|
|
132
|
+
headers?: UndiciHeaders;
|
|
131
133
|
/** Default: `null` */
|
|
132
134
|
signal?: AbortSignal | EventEmitter | null;
|
|
133
135
|
/** This argument parameter is passed through to `ConnectData` */
|
|
@@ -164,7 +166,7 @@ declare namespace Dispatcher {
|
|
|
164
166
|
/** Default: `'GET'` */
|
|
165
167
|
method?: string;
|
|
166
168
|
/** Default: `null` */
|
|
167
|
-
headers?:
|
|
169
|
+
headers?: UndiciHeaders;
|
|
168
170
|
/** A string of comma separated protocols, in descending preference order. Default: `'Websocket'` */
|
|
169
171
|
protocol?: string;
|
|
170
172
|
/** Default: `null` */
|
package/h2c-client.d.ts
ADDED
|
@@ -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/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { RedirectHandler, DecoratorHandler } from './handlers'
|
|
|
6
6
|
|
|
7
7
|
import BalancedPool from './balanced-pool'
|
|
8
8
|
import Client from './client'
|
|
9
|
+
import H2CClient from './h2c-client'
|
|
9
10
|
import buildConnector from './connector'
|
|
10
11
|
import errors from './errors'
|
|
11
12
|
import Agent from './agent'
|
|
@@ -32,7 +33,7 @@ export * from './content-type'
|
|
|
32
33
|
export * from './cache'
|
|
33
34
|
export { Interceptable } from './mock-interceptor'
|
|
34
35
|
|
|
35
|
-
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 }
|
|
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 }
|
|
36
37
|
export default Undici
|
|
37
38
|
|
|
38
39
|
declare namespace Undici {
|
|
@@ -43,6 +44,7 @@ declare namespace Undici {
|
|
|
43
44
|
const RetryHandler: typeof import ('./retry-handler').default
|
|
44
45
|
const BalancedPool: typeof import('./balanced-pool').default
|
|
45
46
|
const Client: typeof import('./client').default
|
|
47
|
+
const H2CClient: typeof import('./h2c-client').default
|
|
46
48
|
const buildConnector: typeof import('./connector').default
|
|
47
49
|
const errors: typeof import('./errors').default
|
|
48
50
|
const Agent: typeof import('./agent').default
|
package/package.json
CHANGED