undici-types 7.12.0 → 7.14.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 +0 -4
- package/client.d.ts +0 -2
- package/dispatcher.d.ts +0 -6
- package/eventsource.d.ts +6 -1
- package/h2c-client.d.ts +0 -2
- package/index.d.ts +6 -1
- package/mock-interceptor.d.ts +0 -1
- package/package.json +1 -1
- package/snapshot-agent.d.ts +107 -0
package/agent.d.ts
CHANGED
|
@@ -22,14 +22,10 @@ declare namespace Agent {
|
|
|
22
22
|
export interface Options extends Pool.Options {
|
|
23
23
|
/** Default: `(origin, opts) => new Pool(origin, opts)`. */
|
|
24
24
|
factory?(origin: string | URL, opts: Object): Dispatcher;
|
|
25
|
-
/** Integer. Default: `0` */
|
|
26
|
-
maxRedirections?: number;
|
|
27
25
|
|
|
28
26
|
interceptors?: { Agent?: readonly Dispatcher.DispatchInterceptor[] } & Pool.Options['interceptors']
|
|
29
27
|
}
|
|
30
28
|
|
|
31
29
|
export interface DispatchOptions extends Dispatcher.DispatchOptions {
|
|
32
|
-
/** Integer. */
|
|
33
|
-
maxRedirections?: number;
|
|
34
30
|
}
|
|
35
31
|
}
|
package/client.d.ts
CHANGED
|
@@ -71,8 +71,6 @@ export declare namespace Client {
|
|
|
71
71
|
/** TODO */
|
|
72
72
|
maxCachedSessions?: number;
|
|
73
73
|
/** TODO */
|
|
74
|
-
maxRedirections?: number;
|
|
75
|
-
/** TODO */
|
|
76
74
|
connect?: Partial<buildConnector.BuildOptions> | buildConnector.connector;
|
|
77
75
|
/** TODO */
|
|
78
76
|
maxRequestsPerClient?: number;
|
package/dispatcher.d.ts
CHANGED
|
@@ -135,8 +135,6 @@ declare namespace Dispatcher {
|
|
|
135
135
|
signal?: AbortSignal | EventEmitter | null;
|
|
136
136
|
/** This argument parameter is passed through to `ConnectData` */
|
|
137
137
|
opaque?: TOpaque;
|
|
138
|
-
/** Default: 0 */
|
|
139
|
-
maxRedirections?: number;
|
|
140
138
|
/** Default: false */
|
|
141
139
|
redirectionLimitReached?: boolean;
|
|
142
140
|
/** Default: `null` */
|
|
@@ -147,8 +145,6 @@ declare namespace Dispatcher {
|
|
|
147
145
|
opaque?: TOpaque;
|
|
148
146
|
/** Default: `null` */
|
|
149
147
|
signal?: AbortSignal | EventEmitter | null;
|
|
150
|
-
/** Default: 0 */
|
|
151
|
-
maxRedirections?: number;
|
|
152
148
|
/** Default: false */
|
|
153
149
|
redirectionLimitReached?: boolean;
|
|
154
150
|
/** Default: `null` */
|
|
@@ -172,8 +168,6 @@ declare namespace Dispatcher {
|
|
|
172
168
|
protocol?: string;
|
|
173
169
|
/** Default: `null` */
|
|
174
170
|
signal?: AbortSignal | EventEmitter | null;
|
|
175
|
-
/** Default: 0 */
|
|
176
|
-
maxRedirections?: number;
|
|
177
171
|
/** Default: false */
|
|
178
172
|
redirectionLimitReached?: boolean;
|
|
179
173
|
/** Default: `null` */
|
package/eventsource.d.ts
CHANGED
|
@@ -56,6 +56,11 @@ export declare const EventSource: {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
interface EventSourceInit {
|
|
59
|
-
withCredentials?: boolean
|
|
59
|
+
withCredentials?: boolean
|
|
60
|
+
// @deprecated use `node.dispatcher` instead
|
|
60
61
|
dispatcher?: Dispatcher
|
|
62
|
+
node?: {
|
|
63
|
+
dispatcher?: Dispatcher
|
|
64
|
+
reconnectionTime?: number
|
|
65
|
+
}
|
|
61
66
|
}
|
package/h2c-client.d.ts
CHANGED
|
@@ -51,8 +51,6 @@ export declare namespace H2CClient {
|
|
|
51
51
|
/** TODO */
|
|
52
52
|
maxCachedSessions?: number;
|
|
53
53
|
/** TODO */
|
|
54
|
-
maxRedirections?: number;
|
|
55
|
-
/** TODO */
|
|
56
54
|
connect?: Omit<Partial<buildConnector.BuildOptions>, 'allowH2'> | buildConnector.connector;
|
|
57
55
|
/** TODO */
|
|
58
56
|
maxRequestsPerClient?: number;
|
package/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ import Agent from './agent'
|
|
|
13
13
|
import MockClient from './mock-client'
|
|
14
14
|
import MockPool from './mock-pool'
|
|
15
15
|
import MockAgent from './mock-agent'
|
|
16
|
+
import { SnapshotAgent } from './snapshot-agent'
|
|
16
17
|
import { MockCallHistory, MockCallHistoryLog } from './mock-call-history'
|
|
17
18
|
import mockErrors from './mock-errors'
|
|
18
19
|
import ProxyAgent from './proxy-agent'
|
|
@@ -33,7 +34,9 @@ export * from './content-type'
|
|
|
33
34
|
export * from './cache'
|
|
34
35
|
export { Interceptable } from './mock-interceptor'
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
declare function globalThisInstall (): void
|
|
38
|
+
|
|
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 }
|
|
37
40
|
export default Undici
|
|
38
41
|
|
|
39
42
|
declare namespace Undici {
|
|
@@ -58,6 +61,7 @@ declare namespace Undici {
|
|
|
58
61
|
const MockClient: typeof import('./mock-client').default
|
|
59
62
|
const MockPool: typeof import('./mock-pool').default
|
|
60
63
|
const MockAgent: typeof import('./mock-agent').default
|
|
64
|
+
const SnapshotAgent: typeof import('./snapshot-agent').SnapshotAgent
|
|
61
65
|
const MockCallHistory: typeof import('./mock-call-history').MockCallHistory
|
|
62
66
|
const MockCallHistoryLog: typeof import('./mock-call-history').MockCallHistoryLog
|
|
63
67
|
const mockErrors: typeof import('./mock-errors').default
|
|
@@ -72,4 +76,5 @@ declare namespace Undici {
|
|
|
72
76
|
MemoryCacheStore: typeof import('./cache-interceptor').default.MemoryCacheStore,
|
|
73
77
|
SqliteCacheStore: typeof import('./cache-interceptor').default.SqliteCacheStore
|
|
74
78
|
}
|
|
79
|
+
const install: typeof globalThisInstall
|
|
75
80
|
}
|
package/mock-interceptor.d.ts
CHANGED
|
@@ -69,7 +69,6 @@ declare namespace MockInterceptor {
|
|
|
69
69
|
headers?: Headers | Record<string, string>;
|
|
70
70
|
origin?: string;
|
|
71
71
|
body?: BodyInit | Dispatcher.DispatchOptions['body'] | null;
|
|
72
|
-
maxRedirections?: number;
|
|
73
72
|
}
|
|
74
73
|
|
|
75
74
|
export type MockResponseDataHandler<TData extends object = object> = (
|
package/package.json
CHANGED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import MockAgent from './mock-agent'
|
|
2
|
+
|
|
3
|
+
declare class SnapshotRecorder {
|
|
4
|
+
constructor (options?: SnapshotRecorder.Options)
|
|
5
|
+
|
|
6
|
+
record (requestOpts: any, response: any): Promise<void>
|
|
7
|
+
findSnapshot (requestOpts: any): SnapshotRecorder.Snapshot | undefined
|
|
8
|
+
loadSnapshots (filePath?: string): Promise<void>
|
|
9
|
+
saveSnapshots (filePath?: string): Promise<void>
|
|
10
|
+
clear (): void
|
|
11
|
+
getSnapshots (): SnapshotRecorder.Snapshot[]
|
|
12
|
+
size (): number
|
|
13
|
+
resetCallCounts (): void
|
|
14
|
+
deleteSnapshot (requestOpts: any): boolean
|
|
15
|
+
getSnapshotInfo (requestOpts: any): SnapshotRecorder.SnapshotInfo | null
|
|
16
|
+
replaceSnapshots (snapshotData: SnapshotRecorder.SnapshotData[]): void
|
|
17
|
+
destroy (): void
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare namespace SnapshotRecorder {
|
|
21
|
+
export interface Options {
|
|
22
|
+
snapshotPath?: string
|
|
23
|
+
mode?: 'record' | 'playback' | 'update'
|
|
24
|
+
maxSnapshots?: number
|
|
25
|
+
autoFlush?: boolean
|
|
26
|
+
flushInterval?: number
|
|
27
|
+
matchHeaders?: string[]
|
|
28
|
+
ignoreHeaders?: string[]
|
|
29
|
+
excludeHeaders?: string[]
|
|
30
|
+
matchBody?: boolean
|
|
31
|
+
matchQuery?: boolean
|
|
32
|
+
caseSensitive?: boolean
|
|
33
|
+
shouldRecord?: (requestOpts: any) => boolean
|
|
34
|
+
shouldPlayback?: (requestOpts: any) => boolean
|
|
35
|
+
excludeUrls?: (string | RegExp)[]
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface Snapshot {
|
|
39
|
+
request: {
|
|
40
|
+
method: string
|
|
41
|
+
url: string
|
|
42
|
+
headers: Record<string, string>
|
|
43
|
+
body?: string
|
|
44
|
+
}
|
|
45
|
+
responses: {
|
|
46
|
+
statusCode: number
|
|
47
|
+
headers: Record<string, string>
|
|
48
|
+
body: string
|
|
49
|
+
trailers: Record<string, string>
|
|
50
|
+
}[]
|
|
51
|
+
callCount: number
|
|
52
|
+
timestamp: string
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface SnapshotInfo {
|
|
56
|
+
hash: string
|
|
57
|
+
request: {
|
|
58
|
+
method: string
|
|
59
|
+
url: string
|
|
60
|
+
headers: Record<string, string>
|
|
61
|
+
body?: string
|
|
62
|
+
}
|
|
63
|
+
responseCount: number
|
|
64
|
+
callCount: number
|
|
65
|
+
timestamp: string
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface SnapshotData {
|
|
69
|
+
hash: string
|
|
70
|
+
snapshot: Snapshot
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
declare class SnapshotAgent extends MockAgent {
|
|
75
|
+
constructor (options?: SnapshotAgent.Options)
|
|
76
|
+
|
|
77
|
+
saveSnapshots (filePath?: string): Promise<void>
|
|
78
|
+
loadSnapshots (filePath?: string): Promise<void>
|
|
79
|
+
getRecorder (): SnapshotRecorder
|
|
80
|
+
getMode (): 'record' | 'playback' | 'update'
|
|
81
|
+
clearSnapshots (): void
|
|
82
|
+
resetCallCounts (): void
|
|
83
|
+
deleteSnapshot (requestOpts: any): boolean
|
|
84
|
+
getSnapshotInfo (requestOpts: any): SnapshotRecorder.SnapshotInfo | null
|
|
85
|
+
replaceSnapshots (snapshotData: SnapshotRecorder.SnapshotData[]): void
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
declare namespace SnapshotAgent {
|
|
89
|
+
export interface Options extends MockAgent.Options {
|
|
90
|
+
mode?: 'record' | 'playback' | 'update'
|
|
91
|
+
snapshotPath?: string
|
|
92
|
+
maxSnapshots?: number
|
|
93
|
+
autoFlush?: boolean
|
|
94
|
+
flushInterval?: number
|
|
95
|
+
matchHeaders?: string[]
|
|
96
|
+
ignoreHeaders?: string[]
|
|
97
|
+
excludeHeaders?: string[]
|
|
98
|
+
matchBody?: boolean
|
|
99
|
+
matchQuery?: boolean
|
|
100
|
+
caseSensitive?: boolean
|
|
101
|
+
shouldRecord?: (requestOpts: any) => boolean
|
|
102
|
+
shouldPlayback?: (requestOpts: any) => boolean
|
|
103
|
+
excludeUrls?: (string | RegExp)[]
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export { SnapshotAgent, SnapshotRecorder }
|