undici-types 7.11.0 → 7.13.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 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/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,7 @@ export * from './content-type'
33
34
  export * from './cache'
34
35
  export { Interceptable } from './mock-interceptor'
35
36
 
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 }
37
+ 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 }
37
38
  export default Undici
38
39
 
39
40
  declare namespace Undici {
@@ -58,6 +59,7 @@ declare namespace Undici {
58
59
  const MockClient: typeof import('./mock-client').default
59
60
  const MockPool: typeof import('./mock-pool').default
60
61
  const MockAgent: typeof import('./mock-agent').default
62
+ const SnapshotAgent: typeof import('./snapshot-agent').SnapshotAgent
61
63
  const MockCallHistory: typeof import('./mock-call-history').MockCallHistory
62
64
  const MockCallHistoryLog: typeof import('./mock-call-history').MockCallHistoryLog
63
65
  const mockErrors: typeof import('./mock-errors').default
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "undici-types",
3
- "version": "7.11.0",
3
+ "version": "7.13.0",
4
4
  "description": "A stand-alone types package for Undici",
5
5
  "homepage": "https://undici.nodejs.org",
6
6
  "bugs": {
@@ -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 }
package/webidl.d.ts CHANGED
@@ -182,6 +182,16 @@ interface WebidlConverters {
182
182
 
183
183
  ['record<ByteString, ByteString>']: RecordConverter<string, string>
184
184
 
185
+ /**
186
+ * @see https://fetch.spec.whatwg.org/#requestinfo
187
+ */
188
+ RequestInfo (V: unknown): undici.Request | string
189
+
190
+ /**
191
+ * @see https://fetch.spec.whatwg.org/#requestinit
192
+ */
193
+ RequestInit (V: unknown): undici.RequestInit
194
+
185
195
  [Key: string]: (...args: any[]) => unknown
186
196
  }
187
197
 
package/websocket.d.ts CHANGED
@@ -182,3 +182,5 @@ export declare const WebSocketError: {
182
182
  prototype: WebSocketError
183
183
  new (type: string, init?: WebSocketCloseInfo): WebSocketError
184
184
  }
185
+
186
+ export declare const ping: (ws: WebSocket, body?: Buffer) => void