undici 7.12.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/README.md +11 -9
- package/docs/docs/api/ProxyAgent.md +1 -1
- package/docs/docs/api/SnapshotAgent.md +616 -0
- package/index.js +2 -0
- package/lib/api/readable.js +48 -26
- package/lib/core/util.js +0 -1
- package/lib/dispatcher/proxy-agent.js +67 -71
- package/lib/handler/redirect-handler.js +10 -0
- package/lib/interceptor/dump.js +2 -1
- package/lib/mock/mock-agent.js +10 -4
- package/lib/mock/snapshot-agent.js +333 -0
- package/lib/mock/snapshot-recorder.js +517 -0
- package/lib/web/fetch/body.js +0 -1
- package/lib/web/fetch/formdata-parser.js +0 -3
- package/lib/web/fetch/formdata.js +0 -4
- package/lib/web/webidl/index.js +1 -1
- package/package.json +1 -1
- package/types/agent.d.ts +0 -4
- package/types/client.d.ts +0 -2
- package/types/dispatcher.d.ts +0 -6
- package/types/h2c-client.d.ts +0 -2
- package/types/index.d.ts +3 -1
- package/types/mock-interceptor.d.ts +0 -1
- package/types/snapshot-agent.d.ts +107 -0
|
@@ -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 }
|