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.
@@ -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 }