Leon4gr45 commited on
Commit
f1ba308
·
verified ·
1 Parent(s): 59df6b2

Upload folder using huggingface_hub (part 18)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. node_modules/undici-types/LICENSE +21 -0
  2. node_modules/undici-types/README.md +6 -0
  3. node_modules/undici-types/agent.d.ts +32 -0
  4. node_modules/undici-types/api.d.ts +43 -0
  5. node_modules/undici-types/balanced-pool.d.ts +30 -0
  6. node_modules/undici-types/cache-interceptor.d.ts +179 -0
  7. node_modules/undici-types/cache.d.ts +36 -0
  8. node_modules/undici-types/client-stats.d.ts +15 -0
  9. node_modules/undici-types/client.d.ts +123 -0
  10. node_modules/undici-types/connector.d.ts +36 -0
  11. node_modules/undici-types/content-type.d.ts +21 -0
  12. node_modules/undici-types/cookies.d.ts +30 -0
  13. node_modules/undici-types/diagnostics-channel.d.ts +74 -0
  14. node_modules/undici-types/dispatcher.d.ts +279 -0
  15. node_modules/undici-types/env-http-proxy-agent.d.ts +22 -0
  16. node_modules/undici-types/errors.d.ts +177 -0
  17. node_modules/undici-types/eventsource.d.ts +66 -0
  18. node_modules/undici-types/fetch.d.ts +211 -0
  19. node_modules/undici-types/formdata.d.ts +108 -0
  20. node_modules/undici-types/global-dispatcher.d.ts +9 -0
  21. node_modules/undici-types/global-origin.d.ts +7 -0
  22. node_modules/undici-types/h2c-client.d.ts +73 -0
  23. node_modules/undici-types/handlers.d.ts +15 -0
  24. node_modules/undici-types/header.d.ts +160 -0
  25. node_modules/undici-types/index.d.ts +91 -0
  26. node_modules/undici-types/interceptors.d.ts +80 -0
  27. node_modules/undici-types/mock-agent.d.ts +68 -0
  28. node_modules/undici-types/mock-call-history.d.ts +111 -0
  29. node_modules/undici-types/mock-client.d.ts +27 -0
  30. node_modules/undici-types/mock-errors.d.ts +12 -0
  31. node_modules/undici-types/mock-interceptor.d.ts +94 -0
  32. node_modules/undici-types/mock-pool.d.ts +27 -0
  33. node_modules/undici-types/package.json +55 -0
  34. node_modules/undici-types/patch.d.ts +29 -0
  35. node_modules/undici-types/pool-stats.d.ts +19 -0
  36. node_modules/undici-types/pool.d.ts +41 -0
  37. node_modules/undici-types/proxy-agent.d.ts +29 -0
  38. node_modules/undici-types/readable.d.ts +68 -0
  39. node_modules/undici-types/retry-agent.d.ts +8 -0
  40. node_modules/undici-types/retry-handler.d.ts +125 -0
  41. node_modules/undici-types/round-robin-pool.d.ts +41 -0
  42. node_modules/undici-types/snapshot-agent.d.ts +109 -0
  43. node_modules/undici-types/socks5-proxy-agent.d.ts +25 -0
  44. node_modules/undici-types/util.d.ts +18 -0
  45. node_modules/undici-types/utility.d.ts +7 -0
  46. node_modules/undici-types/webidl.d.ts +347 -0
  47. node_modules/undici-types/websocket.d.ts +188 -0
  48. node_modules/undici/docs/docs/best-practices/undici-vs-builtin-fetch.md +224 -0
  49. node_modules/undici/docs/docs/best-practices/writing-tests.md +63 -0
  50. node_modules/undici/index-fetch.js +65 -0
node_modules/undici-types/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) Matteo Collina and Undici contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
node_modules/undici-types/README.md ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ # undici-types
2
+
3
+ This package is a dual-publish of the [undici](https://www.npmjs.com/package/undici) library types. The `undici` package **still contains types**. This package is for users who _only_ need undici types (such as for `@types/node`). It is published alongside every release of `undici`, so you can always use the same version.
4
+
5
+ - [GitHub nodejs/undici](https://github.com/nodejs/undici)
6
+ - [Undici Documentation](https://undici.nodejs.org/#/)
node_modules/undici-types/agent.d.ts ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { URL } from 'node:url'
2
+ import Pool from './pool'
3
+ import Dispatcher from './dispatcher'
4
+ import TClientStats from './client-stats'
5
+ import TPoolStats from './pool-stats'
6
+
7
+ export default Agent
8
+
9
+ declare class Agent extends Dispatcher {
10
+ constructor (opts?: Agent.Options)
11
+ /** `true` after `dispatcher.close()` has been called. */
12
+ closed: boolean
13
+ /** `true` after `dispatcher.destroyed()` has been called or `dispatcher.close()` has been called and the dispatcher shutdown has completed. */
14
+ destroyed: boolean
15
+ /** Dispatches a request. */
16
+ dispatch (options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandler): boolean
17
+ /** Aggregate stats for a Agent by origin. */
18
+ readonly stats: Record<string, TClientStats | TPoolStats>
19
+ }
20
+
21
+ declare namespace Agent {
22
+ export interface Options extends Pool.Options {
23
+ /** Default: `(origin, opts) => new Pool(origin, opts)`. */
24
+ factory?(origin: string | URL, opts: Object): Dispatcher;
25
+
26
+ interceptors?: { Agent?: readonly Dispatcher.DispatchInterceptor[] } & Pool.Options['interceptors']
27
+ maxOrigins?: number
28
+ }
29
+
30
+ export interface DispatchOptions extends Dispatcher.DispatchOptions {
31
+ }
32
+ }
node_modules/undici-types/api.d.ts ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { URL, UrlObject } from 'node:url'
2
+ import { Duplex } from 'node:stream'
3
+ import Dispatcher from './dispatcher'
4
+
5
+ /** Performs an HTTP request. */
6
+ declare function request<TOpaque = null> (
7
+ url: string | URL | UrlObject,
8
+ options?: { dispatcher?: Dispatcher } & Omit<Dispatcher.RequestOptions<TOpaque>, 'origin' | 'path' | 'method'> & Partial<Pick<Dispatcher.RequestOptions, 'method'>>,
9
+ ): Promise<Dispatcher.ResponseData<TOpaque>>
10
+
11
+ /** A faster version of `request`. */
12
+ declare function stream<TOpaque = null> (
13
+ url: string | URL | UrlObject,
14
+ options: { dispatcher?: Dispatcher } & Omit<Dispatcher.RequestOptions<TOpaque>, 'origin' | 'path'>,
15
+ factory: Dispatcher.StreamFactory<TOpaque>
16
+ ): Promise<Dispatcher.StreamData<TOpaque>>
17
+
18
+ /** For easy use with `stream.pipeline`. */
19
+ declare function pipeline<TOpaque = null> (
20
+ url: string | URL | UrlObject,
21
+ options: { dispatcher?: Dispatcher } & Omit<Dispatcher.PipelineOptions<TOpaque>, 'origin' | 'path'>,
22
+ handler: Dispatcher.PipelineHandler<TOpaque>
23
+ ): Duplex
24
+
25
+ /** Starts two-way communications with the requested resource. */
26
+ declare function connect<TOpaque = null> (
27
+ url: string | URL | UrlObject,
28
+ options?: { dispatcher?: Dispatcher } & Omit<Dispatcher.ConnectOptions<TOpaque>, 'origin' | 'path'>
29
+ ): Promise<Dispatcher.ConnectData<TOpaque>>
30
+
31
+ /** Upgrade to a different protocol. */
32
+ declare function upgrade (
33
+ url: string | URL | UrlObject,
34
+ options?: { dispatcher?: Dispatcher } & Omit<Dispatcher.UpgradeOptions, 'origin' | 'path'>
35
+ ): Promise<Dispatcher.UpgradeData>
36
+
37
+ export {
38
+ request,
39
+ stream,
40
+ pipeline,
41
+ connect,
42
+ upgrade
43
+ }
node_modules/undici-types/balanced-pool.d.ts ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Pool from './pool'
2
+ import Dispatcher from './dispatcher'
3
+ import { URL } from 'node:url'
4
+
5
+ export default BalancedPool
6
+
7
+ type BalancedPoolConnectOptions = Omit<Dispatcher.ConnectOptions, 'origin'>
8
+
9
+ declare class BalancedPool extends Dispatcher {
10
+ constructor (url: string | string[] | URL | URL[], options?: Pool.Options)
11
+
12
+ addUpstream (upstream: string | URL): BalancedPool
13
+ removeUpstream (upstream: string | URL): BalancedPool
14
+ getUpstream (upstream: string | URL): Pool | undefined
15
+ upstreams: Array<string>
16
+
17
+ /** `true` after `pool.close()` has been called. */
18
+ closed: boolean
19
+ /** `true` after `pool.destroyed()` has been called or `pool.close()` has been called and the pool shutdown has completed. */
20
+ destroyed: boolean
21
+
22
+ // Override dispatcher APIs.
23
+ override connect (
24
+ options: BalancedPoolConnectOptions
25
+ ): Promise<Dispatcher.ConnectData>
26
+ override connect (
27
+ options: BalancedPoolConnectOptions,
28
+ callback: (err: Error | null, data: Dispatcher.ConnectData) => void
29
+ ): void
30
+ }
node_modules/undici-types/cache-interceptor.d.ts ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { Readable, Writable } from 'node:stream'
2
+
3
+ export default CacheHandler
4
+
5
+ declare namespace CacheHandler {
6
+ export type CacheMethods = 'GET' | 'HEAD' | 'OPTIONS' | 'TRACE'
7
+
8
+ export interface CacheHandlerOptions {
9
+ store: CacheStore
10
+
11
+ cacheByDefault?: number
12
+
13
+ type?: CacheOptions['type']
14
+ }
15
+
16
+ export interface CacheOptions {
17
+ store?: CacheStore
18
+
19
+ /**
20
+ * The methods to cache
21
+ * Note we can only cache safe methods. Unsafe methods (i.e. PUT, POST)
22
+ * invalidate the cache for a origin.
23
+ * @see https://www.rfc-editor.org/rfc/rfc9111.html#name-invalidating-stored-respons
24
+ * @see https://www.rfc-editor.org/rfc/rfc9110#section-9.2.1
25
+ */
26
+ methods?: CacheMethods[]
27
+
28
+ /**
29
+ * RFC9111 allows for caching responses that we aren't explicitly told to
30
+ * cache or to not cache.
31
+ * @see https://www.rfc-editor.org/rfc/rfc9111.html#section-3-5
32
+ * @default undefined
33
+ */
34
+ cacheByDefault?: number
35
+
36
+ /**
37
+ * TODO docs
38
+ * @default 'shared'
39
+ */
40
+ type?: 'shared' | 'private'
41
+
42
+ /**
43
+ * Array of origins to cache. Only requests to these origins will be cached.
44
+ * Supports strings (case insensitive) and RegExp patterns.
45
+ * @default undefined (cache all origins)
46
+ */
47
+ origins?: (string | RegExp)[]
48
+ }
49
+
50
+ export interface CacheControlDirectives {
51
+ 'max-stale'?: number;
52
+ 'min-fresh'?: number;
53
+ 'max-age'?: number;
54
+ 's-maxage'?: number;
55
+ 'stale-while-revalidate'?: number;
56
+ 'stale-if-error'?: number;
57
+ public?: true;
58
+ private?: true | string[];
59
+ 'no-store'?: true;
60
+ 'no-cache'?: true | string[];
61
+ 'must-revalidate'?: true;
62
+ 'proxy-revalidate'?: true;
63
+ immutable?: true;
64
+ 'no-transform'?: true;
65
+ 'must-understand'?: true;
66
+ 'only-if-cached'?: true;
67
+ }
68
+
69
+ export interface CacheKey {
70
+ origin: string
71
+ method: string
72
+ path: string
73
+ headers?: Record<string, string | string[]>
74
+ }
75
+
76
+ export interface CacheValue {
77
+ statusCode: number
78
+ statusMessage: string
79
+ headers: Record<string, string | string[]>
80
+ vary?: Record<string, string | string[] | null>
81
+ etag?: string
82
+ cacheControlDirectives?: CacheControlDirectives
83
+ cachedAt: number
84
+ staleAt: number
85
+ deleteAt: number
86
+ }
87
+
88
+ export interface DeleteByUri {
89
+ origin: string
90
+ method: string
91
+ path: string
92
+ }
93
+
94
+ type GetResult = {
95
+ statusCode: number
96
+ statusMessage: string
97
+ headers: Record<string, string | string[]>
98
+ vary?: Record<string, string | string[] | null>
99
+ etag?: string
100
+ body?: Readable | Iterable<Buffer> | AsyncIterable<Buffer> | Buffer | Iterable<string> | AsyncIterable<string> | string
101
+ cacheControlDirectives: CacheControlDirectives,
102
+ cachedAt: number
103
+ staleAt: number
104
+ deleteAt: number
105
+ }
106
+
107
+ /**
108
+ * Underlying storage provider for cached responses
109
+ */
110
+ export interface CacheStore {
111
+ get(key: CacheKey): GetResult | Promise<GetResult | undefined> | undefined
112
+
113
+ createWriteStream(key: CacheKey, val: CacheValue): Writable | undefined
114
+
115
+ delete(key: CacheKey): void | Promise<void>
116
+ }
117
+
118
+ export interface MemoryCacheStoreOpts {
119
+ /**
120
+ * @default Infinity
121
+ */
122
+ maxCount?: number
123
+
124
+ /**
125
+ * @default Infinity
126
+ */
127
+ maxSize?: number
128
+
129
+ /**
130
+ * @default Infinity
131
+ */
132
+ maxEntrySize?: number
133
+
134
+ errorCallback?: (err: Error) => void
135
+ }
136
+
137
+ export class MemoryCacheStore implements CacheStore {
138
+ constructor (opts?: MemoryCacheStoreOpts)
139
+
140
+ get (key: CacheKey): GetResult | Promise<GetResult | undefined> | undefined
141
+
142
+ createWriteStream (key: CacheKey, value: CacheValue): Writable | undefined
143
+
144
+ delete (key: CacheKey): void | Promise<void>
145
+ }
146
+
147
+ export interface SqliteCacheStoreOpts {
148
+ /**
149
+ * Location of the database
150
+ * @default ':memory:'
151
+ */
152
+ location?: string
153
+
154
+ /**
155
+ * @default Infinity
156
+ */
157
+ maxCount?: number
158
+
159
+ /**
160
+ * @default Infinity
161
+ */
162
+ maxEntrySize?: number
163
+ }
164
+
165
+ export class SqliteCacheStore implements CacheStore {
166
+ constructor (opts?: SqliteCacheStoreOpts)
167
+
168
+ /**
169
+ * Closes the connection to the database
170
+ */
171
+ close (): void
172
+
173
+ get (key: CacheKey): GetResult | Promise<GetResult | undefined> | undefined
174
+
175
+ createWriteStream (key: CacheKey, value: CacheValue): Writable | undefined
176
+
177
+ delete (key: CacheKey): void | Promise<void>
178
+ }
179
+ }
node_modules/undici-types/cache.d.ts ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { RequestInfo, Response, Request } from './fetch'
2
+
3
+ export interface CacheStorage {
4
+ match (request: RequestInfo, options?: MultiCacheQueryOptions): Promise<Response | undefined>,
5
+ has (cacheName: string): Promise<boolean>,
6
+ open (cacheName: string): Promise<Cache>,
7
+ delete (cacheName: string): Promise<boolean>,
8
+ keys (): Promise<string[]>
9
+ }
10
+
11
+ declare const CacheStorage: {
12
+ prototype: CacheStorage
13
+ new(): CacheStorage
14
+ }
15
+
16
+ export interface Cache {
17
+ match (request: RequestInfo, options?: CacheQueryOptions): Promise<Response | undefined>,
18
+ matchAll (request?: RequestInfo, options?: CacheQueryOptions): Promise<readonly Response[]>,
19
+ add (request: RequestInfo): Promise<undefined>,
20
+ addAll (requests: RequestInfo[]): Promise<undefined>,
21
+ put (request: RequestInfo, response: Response): Promise<undefined>,
22
+ delete (request: RequestInfo, options?: CacheQueryOptions): Promise<boolean>,
23
+ keys (request?: RequestInfo, options?: CacheQueryOptions): Promise<readonly Request[]>
24
+ }
25
+
26
+ export interface CacheQueryOptions {
27
+ ignoreSearch?: boolean,
28
+ ignoreMethod?: boolean,
29
+ ignoreVary?: boolean
30
+ }
31
+
32
+ export interface MultiCacheQueryOptions extends CacheQueryOptions {
33
+ cacheName?: string
34
+ }
35
+
36
+ export declare const caches: CacheStorage
node_modules/undici-types/client-stats.d.ts ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Client from './client'
2
+
3
+ export default ClientStats
4
+
5
+ declare class ClientStats {
6
+ constructor (pool: Client)
7
+ /** If socket has open connection. */
8
+ connected: boolean
9
+ /** Number of open socket connections in this client that do not have an active request. */
10
+ pending: number
11
+ /** Number of currently active requests of this client. */
12
+ running: number
13
+ /** Number of active, pending, or queued requests of this client. */
14
+ size: number
15
+ }
node_modules/undici-types/client.d.ts ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { URL } from 'node:url'
2
+ import Dispatcher from './dispatcher'
3
+ import buildConnector from './connector'
4
+ import TClientStats from './client-stats'
5
+
6
+ type ClientConnectOptions = Omit<Dispatcher.ConnectOptions, 'origin'>
7
+
8
+ /**
9
+ * A basic HTTP/1.1 client, mapped on top a single TCP/TLS connection. Pipelining is disabled by default.
10
+ */
11
+ export class Client extends Dispatcher {
12
+ constructor (url: string | URL, options?: Client.Options)
13
+ /** Property to get and set the pipelining factor. */
14
+ pipelining: number
15
+ /** `true` after `client.close()` has been called. */
16
+ closed: boolean
17
+ /** `true` after `client.destroyed()` has been called or `client.close()` has been called and the client shutdown has completed. */
18
+ destroyed: boolean
19
+ /** Aggregate stats for a Client. */
20
+ readonly stats: TClientStats
21
+
22
+ // Override dispatcher APIs.
23
+ override connect (
24
+ options: ClientConnectOptions
25
+ ): Promise<Dispatcher.ConnectData>
26
+ override connect (
27
+ options: ClientConnectOptions,
28
+ callback: (err: Error | null, data: Dispatcher.ConnectData) => void
29
+ ): void
30
+ }
31
+
32
+ export declare namespace Client {
33
+ export interface OptionsInterceptors {
34
+ Client: readonly Dispatcher.DispatchInterceptor[];
35
+ }
36
+ export interface Options {
37
+ /** TODO */
38
+ interceptors?: OptionsInterceptors;
39
+ /** The maximum length of request headers in bytes. Default: Node.js' `--max-http-header-size` or `16384` (16KiB). */
40
+ maxHeaderSize?: number;
41
+ /** 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). */
42
+ headersTimeout?: number;
43
+ /** @deprecated unsupported socketTimeout, use headersTimeout & bodyTimeout instead */
44
+ socketTimeout?: never;
45
+ /** @deprecated unsupported requestTimeout, use headersTimeout & bodyTimeout instead */
46
+ requestTimeout?: never;
47
+ /** TODO */
48
+ connectTimeout?: number;
49
+ /** 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). */
50
+ bodyTimeout?: number;
51
+ /** @deprecated unsupported idleTimeout, use keepAliveTimeout instead */
52
+ idleTimeout?: never;
53
+ /** @deprecated unsupported keepAlive, use pipelining=0 instead */
54
+ keepAlive?: never;
55
+ /** 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). */
56
+ keepAliveTimeout?: number;
57
+ /** @deprecated unsupported maxKeepAliveTimeout, use keepAliveMaxTimeout instead */
58
+ maxKeepAliveTimeout?: never;
59
+ /** the maximum allowed `idleTimeout`, in milliseconds, when overridden by *keep-alive* hints from the server. Default: `600e3` milliseconds (10min). */
60
+ keepAliveMaxTimeout?: number;
61
+ /** 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). */
62
+ keepAliveTimeoutThreshold?: number;
63
+ /** TODO */
64
+ socketPath?: string;
65
+ /** 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`. */
66
+ pipelining?: number;
67
+ /** @deprecated use the connect option instead */
68
+ tls?: never;
69
+ /** If `true`, an error is thrown when the request content-length header doesn't match the length of the request body. Default: `true`. */
70
+ strictContentLength?: boolean;
71
+ /** TODO */
72
+ maxCachedSessions?: number;
73
+ /** TODO */
74
+ connect?: Partial<buildConnector.BuildOptions> | buildConnector.connector;
75
+ /** TODO */
76
+ maxRequestsPerClient?: number;
77
+ /** TODO */
78
+ localAddress?: string;
79
+ /** Max response body size in bytes, -1 is disabled */
80
+ maxResponseSize?: number;
81
+ /** Enables a family autodetection algorithm that loosely implements section 5 of RFC 8305. */
82
+ autoSelectFamily?: boolean;
83
+ /** The amount of time in milliseconds to wait for a connection attempt to finish before trying the next address when using the `autoSelectFamily` option. */
84
+ autoSelectFamilyAttemptTimeout?: number;
85
+ /**
86
+ * @description Enables support for H2 if the server has assigned bigger priority to it through ALPN negotiation.
87
+ * @default false
88
+ */
89
+ allowH2?: boolean;
90
+ /**
91
+ * @description Dictates the maximum number of concurrent streams for a single H2 session. It can be overridden by a SETTINGS remote frame.
92
+ * @default 100
93
+ */
94
+ maxConcurrentStreams?: number;
95
+ /**
96
+ * @description Sets the HTTP/2 stream-level flow-control window size (SETTINGS_INITIAL_WINDOW_SIZE).
97
+ * @default 262144
98
+ */
99
+ initialWindowSize?: number;
100
+ /**
101
+ * @description Sets the HTTP/2 connection-level flow-control window size (ClientHttp2Session.setLocalWindowSize).
102
+ * @default 524288
103
+ */
104
+ connectionWindowSize?: number;
105
+ /**
106
+ * @description Time interval between PING frames dispatch
107
+ * @default 60000
108
+ */
109
+ pingInterval?: number;
110
+ }
111
+ export interface SocketInfo {
112
+ localAddress?: string
113
+ localPort?: number
114
+ remoteAddress?: string
115
+ remotePort?: number
116
+ remoteFamily?: string
117
+ timeout?: number
118
+ bytesWritten?: number
119
+ bytesRead?: number
120
+ }
121
+ }
122
+
123
+ export default Client
node_modules/undici-types/connector.d.ts ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { TLSSocket, ConnectionOptions } from 'node:tls'
2
+ import { IpcNetConnectOpts, Socket, TcpNetConnectOpts } from 'node:net'
3
+
4
+ export default buildConnector
5
+ declare function buildConnector (options?: buildConnector.BuildOptions): buildConnector.connector
6
+
7
+ declare namespace buildConnector {
8
+ export type BuildOptions = (ConnectionOptions | TcpNetConnectOpts | IpcNetConnectOpts) & {
9
+ allowH2?: boolean;
10
+ maxCachedSessions?: number | null;
11
+ socketPath?: string | null;
12
+ timeout?: number | null;
13
+ port?: number;
14
+ keepAlive?: boolean | null;
15
+ keepAliveInitialDelay?: number | null;
16
+ typeOfService?: number | null;
17
+ }
18
+
19
+ export interface Options {
20
+ hostname: string
21
+ host?: string
22
+ protocol: string
23
+ port: string
24
+ servername?: string
25
+ localAddress?: string | null
26
+ socketPath?: string | null
27
+ httpSocket?: Socket
28
+ }
29
+
30
+ export type Callback = (...args: CallbackArgs) => void
31
+ type CallbackArgs = [null, Socket | TLSSocket] | [Error, null]
32
+
33
+ export interface connector {
34
+ (options: buildConnector.Options, callback: buildConnector.Callback): void
35
+ }
36
+ }
node_modules/undici-types/content-type.d.ts ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /// <reference types="node" />
2
+
3
+ interface MIMEType {
4
+ type: string
5
+ subtype: string
6
+ parameters: Map<string, string>
7
+ essence: string
8
+ }
9
+
10
+ /**
11
+ * Parse a string to a {@link MIMEType} object. Returns `failure` if the string
12
+ * couldn't be parsed.
13
+ * @see https://mimesniff.spec.whatwg.org/#parse-a-mime-type
14
+ */
15
+ export function parseMIMEType (input: string): 'failure' | MIMEType
16
+
17
+ /**
18
+ * Convert a MIMEType object to a string.
19
+ * @see https://mimesniff.spec.whatwg.org/#serialize-a-mime-type
20
+ */
21
+ export function serializeAMimeType (mimeType: MIMEType): string
node_modules/undici-types/cookies.d.ts ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /// <reference types="node" />
2
+
3
+ import type { Headers } from './fetch'
4
+
5
+ export interface Cookie {
6
+ name: string
7
+ value: string
8
+ expires?: Date | number
9
+ maxAge?: number
10
+ domain?: string
11
+ path?: string
12
+ secure?: boolean
13
+ httpOnly?: boolean
14
+ sameSite?: 'Strict' | 'Lax' | 'None'
15
+ unparsed?: string[]
16
+ }
17
+
18
+ export function deleteCookie (
19
+ headers: Headers,
20
+ name: string,
21
+ attributes?: { name?: string, domain?: string }
22
+ ): void
23
+
24
+ export function getCookies (headers: Headers): Record<string, string>
25
+
26
+ export function getSetCookies (headers: Headers): Cookie[]
27
+
28
+ export function setCookie (headers: Headers, cookie: Cookie): void
29
+
30
+ export function parseCookie (cookie: string): Cookie | null
node_modules/undici-types/diagnostics-channel.d.ts ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { Socket } from 'node:net'
2
+ import { URL } from 'node:url'
3
+ import buildConnector from './connector'
4
+ import Dispatcher from './dispatcher'
5
+
6
+ declare namespace DiagnosticsChannel {
7
+ interface Request {
8
+ origin?: string | URL;
9
+ completed: boolean;
10
+ method?: Dispatcher.HttpMethod;
11
+ path: string;
12
+ headers: any;
13
+ }
14
+ interface Response {
15
+ statusCode: number;
16
+ statusText: string;
17
+ headers: Array<Buffer>;
18
+ }
19
+ interface ConnectParams {
20
+ host: URL['host'];
21
+ hostname: URL['hostname'];
22
+ protocol: URL['protocol'];
23
+ port: URL['port'];
24
+ servername: string | null;
25
+ }
26
+ type Connector = buildConnector.connector
27
+ export interface RequestCreateMessage {
28
+ request: Request;
29
+ }
30
+ export interface RequestBodySentMessage {
31
+ request: Request;
32
+ }
33
+
34
+ export interface RequestBodyChunkSentMessage {
35
+ request: Request;
36
+ chunk: Uint8Array | string;
37
+ }
38
+ export interface RequestBodyChunkReceivedMessage {
39
+ request: Request;
40
+ chunk: Buffer;
41
+ }
42
+ export interface RequestHeadersMessage {
43
+ request: Request;
44
+ response: Response;
45
+ }
46
+ export interface RequestTrailersMessage {
47
+ request: Request;
48
+ trailers: Array<Buffer>;
49
+ }
50
+ export interface RequestErrorMessage {
51
+ request: Request;
52
+ error: Error;
53
+ }
54
+ export interface ClientSendHeadersMessage {
55
+ request: Request;
56
+ headers: string;
57
+ socket: Socket;
58
+ }
59
+ export interface ClientBeforeConnectMessage {
60
+ connectParams: ConnectParams;
61
+ connector: Connector;
62
+ }
63
+ export interface ClientConnectedMessage {
64
+ socket: Socket;
65
+ connectParams: ConnectParams;
66
+ connector: Connector;
67
+ }
68
+ export interface ClientConnectErrorMessage {
69
+ error: Error;
70
+ socket: Socket;
71
+ connectParams: ConnectParams;
72
+ connector: Connector;
73
+ }
74
+ }
node_modules/undici-types/dispatcher.d.ts ADDED
@@ -0,0 +1,279 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { URL } from 'node:url'
2
+ import { Duplex, Readable, Writable } from 'node:stream'
3
+ import { EventEmitter } from 'node:events'
4
+ import { Blob } from 'node:buffer'
5
+ import { IncomingHttpHeaders } from './header'
6
+ import BodyReadable from './readable'
7
+ import { FormData } from './formdata'
8
+ import Errors from './errors'
9
+ import { Autocomplete } from './utility'
10
+
11
+ type AbortSignal = unknown
12
+
13
+ export default Dispatcher
14
+
15
+ export type UndiciHeaders = Record<string, string | string[]> | IncomingHttpHeaders | string[] | Iterable<[string, string | string[] | undefined]> | null
16
+
17
+ /** Dispatcher is the core API used to dispatch requests. */
18
+ declare class Dispatcher extends EventEmitter {
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. */
20
+ dispatch (options: Dispatcher.DispatchOptions, handler: Dispatcher.DispatchHandler): boolean
21
+ /** Starts two-way communications with the requested resource. */
22
+ connect<TOpaque = null>(options: Dispatcher.ConnectOptions<TOpaque>, callback: (err: Error | null, data: Dispatcher.ConnectData<TOpaque>) => void): void
23
+ connect<TOpaque = null>(options: Dispatcher.ConnectOptions<TOpaque>): Promise<Dispatcher.ConnectData<TOpaque>>
24
+ /** Compose a chain of dispatchers */
25
+ compose (dispatchers: Dispatcher.DispatcherComposeInterceptor[]): Dispatcher.ComposedDispatcher
26
+ compose (...dispatchers: Dispatcher.DispatcherComposeInterceptor[]): Dispatcher.ComposedDispatcher
27
+ /** Performs an HTTP request. */
28
+ request<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>, callback: (err: Error | null, data: Dispatcher.ResponseData<TOpaque>) => void): void
29
+ request<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>): Promise<Dispatcher.ResponseData<TOpaque>>
30
+ /** For easy use with `stream.pipeline`. */
31
+ pipeline<TOpaque = null>(options: Dispatcher.PipelineOptions<TOpaque>, handler: Dispatcher.PipelineHandler<TOpaque>): Duplex
32
+ /** A faster version of `Dispatcher.request`. */
33
+ stream<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>, factory: Dispatcher.StreamFactory<TOpaque>, callback: (err: Error | null, data: Dispatcher.StreamData<TOpaque>) => void): void
34
+ stream<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>, factory: Dispatcher.StreamFactory<TOpaque>): Promise<Dispatcher.StreamData<TOpaque>>
35
+ /** Upgrade to a different protocol. */
36
+ upgrade (options: Dispatcher.UpgradeOptions, callback: (err: Error | null, data: Dispatcher.UpgradeData) => void): void
37
+ upgrade (options: Dispatcher.UpgradeOptions): Promise<Dispatcher.UpgradeData>
38
+ /** Closes the client and gracefully waits for enqueued requests to complete before invoking the callback (or returning a promise if no callback is provided). */
39
+ close (callback: () => void): void
40
+ close (): Promise<void>
41
+ /** Destroy the client abruptly with the given err. All the pending and running requests will be asynchronously aborted and error. Waits until socket is closed before invoking the callback (or returning a promise if no callback is provided). Since this operation is asynchronously dispatched there might still be some progress on dispatched requests. */
42
+ destroy (err: Error | null, callback: () => void): void
43
+ destroy (callback: () => void): void
44
+ destroy (err: Error | null): Promise<void>
45
+ destroy (): Promise<void>
46
+
47
+ on (eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this
48
+ on (eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
49
+ on (eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
50
+ on (eventName: 'drain', callback: (origin: URL) => void): this
51
+
52
+ once (eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this
53
+ once (eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
54
+ once (eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
55
+ once (eventName: 'drain', callback: (origin: URL) => void): this
56
+
57
+ off (eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this
58
+ off (eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
59
+ off (eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
60
+ off (eventName: 'drain', callback: (origin: URL) => void): this
61
+
62
+ addListener (eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this
63
+ addListener (eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
64
+ addListener (eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
65
+ addListener (eventName: 'drain', callback: (origin: URL) => void): this
66
+
67
+ removeListener (eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this
68
+ removeListener (eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
69
+ removeListener (eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
70
+ removeListener (eventName: 'drain', callback: (origin: URL) => void): this
71
+
72
+ prependListener (eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this
73
+ prependListener (eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
74
+ prependListener (eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
75
+ prependListener (eventName: 'drain', callback: (origin: URL) => void): this
76
+
77
+ prependOnceListener (eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this
78
+ prependOnceListener (eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
79
+ prependOnceListener (eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
80
+ prependOnceListener (eventName: 'drain', callback: (origin: URL) => void): this
81
+
82
+ listeners (eventName: 'connect'): ((origin: URL, targets: readonly Dispatcher[]) => void)[]
83
+ listeners (eventName: 'disconnect'): ((origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[]
84
+ listeners (eventName: 'connectionError'): ((origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[]
85
+ listeners (eventName: 'drain'): ((origin: URL) => void)[]
86
+
87
+ rawListeners (eventName: 'connect'): ((origin: URL, targets: readonly Dispatcher[]) => void)[]
88
+ rawListeners (eventName: 'disconnect'): ((origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[]
89
+ rawListeners (eventName: 'connectionError'): ((origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[]
90
+ rawListeners (eventName: 'drain'): ((origin: URL) => void)[]
91
+
92
+ emit (eventName: 'connect', origin: URL, targets: readonly Dispatcher[]): boolean
93
+ emit (eventName: 'disconnect', origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError): boolean
94
+ emit (eventName: 'connectionError', origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError): boolean
95
+ emit (eventName: 'drain', origin: URL): boolean
96
+ }
97
+
98
+ declare namespace Dispatcher {
99
+ export interface ComposedDispatcher extends Dispatcher { }
100
+ export type Dispatch = Dispatcher['dispatch']
101
+ export type DispatcherComposeInterceptor = (dispatch: Dispatch) => Dispatch
102
+ export interface DispatchOptions {
103
+ origin?: string | URL;
104
+ path: string;
105
+ method: HttpMethod;
106
+ /** Default: `null` */
107
+ body?: string | Buffer | Uint8Array | Readable | null | FormData;
108
+ /** Default: `null` */
109
+ headers?: UndiciHeaders;
110
+ /** Query string params to be embedded in the request URL. Default: `null` */
111
+ query?: Record<string, any>;
112
+ /** 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`. */
113
+ idempotent?: boolean;
114
+ /** Whether the response is expected to take a long time and would end up blocking the pipeline. When this is set to `true` further pipelining will be avoided on the same connection until headers have been received. Defaults to `method !== 'HEAD'`. */
115
+ blocking?: boolean;
116
+ /** The IP Type of Service (ToS) value for the request socket. Must be an integer between 0 and 255. Default: `0` */
117
+ typeOfService?: number | null;
118
+ /** Upgrade the request. Should be used to specify the kind of upgrade i.e. `'Websocket'`. Default: `method === 'CONNECT' || null`. */
119
+ upgrade?: boolean | string | null;
120
+ /** The amount of time, in milliseconds, the parser will wait to receive the complete HTTP headers. Defaults to 300 seconds. */
121
+ headersTimeout?: number | null;
122
+ /** The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use 0 to disable it entirely. Defaults to 300 seconds. */
123
+ bodyTimeout?: number | null;
124
+ /** Whether the request should stablish a keep-alive or not. Default `false` */
125
+ reset?: boolean;
126
+ /** Whether Undici should throw an error upon receiving a 4xx or 5xx response from the server. Defaults to false */
127
+ throwOnError?: boolean;
128
+ /** For H2, it appends the expect: 100-continue header, and halts the request body until a 100-continue is received from the remote server */
129
+ expectContinue?: boolean;
130
+ }
131
+ export interface ConnectOptions<TOpaque = null> {
132
+ origin: string | URL;
133
+ path: string;
134
+ /** Default: `null` */
135
+ headers?: UndiciHeaders;
136
+ /** Default: `null` */
137
+ signal?: AbortSignal | EventEmitter | null;
138
+ /** This argument parameter is passed through to `ConnectData` */
139
+ opaque?: TOpaque;
140
+ /** Default: false */
141
+ redirectionLimitReached?: boolean;
142
+ /** Default: `null` */
143
+ responseHeaders?: 'raw' | null;
144
+ }
145
+ export interface RequestOptions<TOpaque = null> extends DispatchOptions {
146
+ /** Default: `null` */
147
+ opaque?: TOpaque;
148
+ /** Default: `null` */
149
+ signal?: AbortSignal | EventEmitter | null;
150
+ /** Default: false */
151
+ redirectionLimitReached?: boolean;
152
+ /** Default: `null` */
153
+ onInfo?: (info: { statusCode: number, headers: Record<string, string | string[]> }) => void;
154
+ /** Default: `null` */
155
+ responseHeaders?: 'raw' | null;
156
+ /** Default: `64 KiB` */
157
+ highWaterMark?: number;
158
+ }
159
+ export interface PipelineOptions<TOpaque = null> extends RequestOptions<TOpaque> {
160
+ /** `true` if the `handler` will return an object stream. Default: `false` */
161
+ objectMode?: boolean;
162
+ }
163
+ export interface UpgradeOptions {
164
+ path: string;
165
+ /** Default: `'GET'` */
166
+ method?: string;
167
+ /** Default: `null` */
168
+ headers?: UndiciHeaders;
169
+ /** A string of comma separated protocols, in descending preference order. Default: `'Websocket'` */
170
+ protocol?: string;
171
+ /** Default: `null` */
172
+ signal?: AbortSignal | EventEmitter | null;
173
+ /** Default: false */
174
+ redirectionLimitReached?: boolean;
175
+ /** Default: `null` */
176
+ responseHeaders?: 'raw' | null;
177
+ }
178
+ export interface ConnectData<TOpaque = null> {
179
+ statusCode: number;
180
+ headers: IncomingHttpHeaders;
181
+ socket: Duplex;
182
+ opaque: TOpaque;
183
+ }
184
+ export interface ResponseData<TOpaque = null> {
185
+ statusCode: number;
186
+ statusText: string;
187
+ headers: IncomingHttpHeaders;
188
+ body: BodyReadable & BodyMixin;
189
+ trailers: Record<string, string>;
190
+ opaque: TOpaque;
191
+ context: object;
192
+ }
193
+ export interface PipelineHandlerData<TOpaque = null> {
194
+ statusCode: number;
195
+ headers: IncomingHttpHeaders;
196
+ opaque: TOpaque;
197
+ body: BodyReadable;
198
+ context: object;
199
+ }
200
+ export interface StreamData<TOpaque = null> {
201
+ opaque: TOpaque;
202
+ trailers: Record<string, string>;
203
+ }
204
+ export interface UpgradeData<TOpaque = null> {
205
+ headers: IncomingHttpHeaders;
206
+ socket: Duplex;
207
+ opaque: TOpaque;
208
+ }
209
+ export interface StreamFactoryData<TOpaque = null> {
210
+ statusCode: number;
211
+ headers: IncomingHttpHeaders;
212
+ opaque: TOpaque;
213
+ context: object;
214
+ }
215
+ export type StreamFactory<TOpaque = null> = (data: StreamFactoryData<TOpaque>) => Writable
216
+
217
+ export interface DispatchController {
218
+ get aborted(): boolean
219
+ get paused(): boolean
220
+ get reason(): Error | null
221
+ abort(reason: Error): void
222
+ pause(): void
223
+ resume(): void
224
+ }
225
+
226
+ export interface DispatchHandler {
227
+ onRequestStart?(controller: DispatchController, context: any): void;
228
+ onRequestUpgrade?(controller: DispatchController, statusCode: number, headers: IncomingHttpHeaders, socket: Duplex): void;
229
+ onResponseStart?(controller: DispatchController, statusCode: number, headers: IncomingHttpHeaders, statusMessage?: string): void;
230
+ onResponseData?(controller: DispatchController, chunk: Buffer): void;
231
+ onResponseEnd?(controller: DispatchController, trailers: IncomingHttpHeaders): void;
232
+ onResponseError?(controller: DispatchController, error: Error): void;
233
+
234
+ /** Invoked before request is dispatched on socket. May be invoked multiple times when a request is retried when the request at the head of the pipeline fails. */
235
+ /** @deprecated */
236
+ onConnect?(abort: (err?: Error) => void): void;
237
+ /** Invoked when an error has occurred. */
238
+ /** @deprecated */
239
+ onError?(err: Error): void;
240
+ /** Invoked when request is upgraded either due to a `Upgrade` header or `CONNECT` method. */
241
+ /** @deprecated */
242
+ onUpgrade?(statusCode: number, headers: Buffer[] | string[] | null, socket: Duplex): void;
243
+ /** Invoked when response is received, before headers have been read. **/
244
+ /** @deprecated */
245
+ onResponseStarted?(): void;
246
+ /** Invoked when statusCode and headers have been received. May be invoked multiple times due to 1xx informational headers. */
247
+ /** @deprecated */
248
+ onHeaders?(statusCode: number, headers: Buffer[], resume: () => void, statusText: string): boolean;
249
+ /** Invoked when response payload data is received. */
250
+ /** @deprecated */
251
+ onData?(chunk: Buffer): boolean;
252
+ /** Invoked when response payload and trailers have been received and the request has completed. */
253
+ /** @deprecated */
254
+ onComplete?(trailers: string[] | null): void;
255
+ /** Invoked when a body chunk is sent to the server. May be invoked multiple times for chunked requests */
256
+ /** @deprecated */
257
+ onBodySent?(chunkSize: number, totalBytesSent: number): void;
258
+ }
259
+ export type PipelineHandler<TOpaque = null> = (data: PipelineHandlerData<TOpaque>) => Readable
260
+ export type HttpMethod = Autocomplete<'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH'>
261
+
262
+ /**
263
+ * @link https://fetch.spec.whatwg.org/#body-mixin
264
+ */
265
+ interface BodyMixin {
266
+ readonly body?: never;
267
+ readonly bodyUsed: boolean;
268
+ arrayBuffer(): Promise<ArrayBuffer>;
269
+ blob(): Promise<Blob>;
270
+ bytes(): Promise<Uint8Array>;
271
+ formData(): Promise<never>;
272
+ json(): Promise<unknown>;
273
+ text(): Promise<string>;
274
+ }
275
+
276
+ export interface DispatchInterceptor {
277
+ (dispatch: Dispatch): Dispatch
278
+ }
279
+ }
node_modules/undici-types/env-http-proxy-agent.d.ts ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Agent from './agent'
2
+ import ProxyAgent from './proxy-agent'
3
+ import Dispatcher from './dispatcher'
4
+
5
+ export default EnvHttpProxyAgent
6
+
7
+ declare class EnvHttpProxyAgent extends Dispatcher {
8
+ constructor (opts?: EnvHttpProxyAgent.Options)
9
+
10
+ dispatch (options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandler): boolean
11
+ }
12
+
13
+ declare namespace EnvHttpProxyAgent {
14
+ export interface Options extends Omit<ProxyAgent.Options, 'uri'> {
15
+ /** Overrides the value of the HTTP_PROXY environment variable */
16
+ httpProxy?: string;
17
+ /** Overrides the value of the HTTPS_PROXY environment variable */
18
+ httpsProxy?: string;
19
+ /** Overrides the value of the NO_PROXY environment variable */
20
+ noProxy?: string;
21
+ }
22
+ }
node_modules/undici-types/errors.d.ts ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { IncomingHttpHeaders } from './header'
2
+ import Client from './client'
3
+
4
+ export default Errors
5
+
6
+ declare namespace Errors {
7
+ export class UndiciError extends Error {
8
+ name: string
9
+ code: string
10
+ }
11
+
12
+ /** Connect timeout error. */
13
+ export class ConnectTimeoutError extends UndiciError {
14
+ name: 'ConnectTimeoutError'
15
+ code: 'UND_ERR_CONNECT_TIMEOUT'
16
+ }
17
+
18
+ /** A header exceeds the `headersTimeout` option. */
19
+ export class HeadersTimeoutError extends UndiciError {
20
+ name: 'HeadersTimeoutError'
21
+ code: 'UND_ERR_HEADERS_TIMEOUT'
22
+ }
23
+
24
+ /** Headers overflow error. */
25
+ export class HeadersOverflowError extends UndiciError {
26
+ name: 'HeadersOverflowError'
27
+ code: 'UND_ERR_HEADERS_OVERFLOW'
28
+ }
29
+
30
+ /** A body exceeds the `bodyTimeout` option. */
31
+ export class BodyTimeoutError extends UndiciError {
32
+ name: 'BodyTimeoutError'
33
+ code: 'UND_ERR_BODY_TIMEOUT'
34
+ }
35
+
36
+ export class ResponseError extends UndiciError {
37
+ constructor (
38
+ message: string,
39
+ code: number,
40
+ options: {
41
+ headers?: IncomingHttpHeaders | string[] | null,
42
+ body?: null | Record<string, any> | string
43
+ }
44
+ )
45
+ name: 'ResponseError'
46
+ code: 'UND_ERR_RESPONSE'
47
+ statusCode: number
48
+ body: null | Record<string, any> | string
49
+ headers: IncomingHttpHeaders | string[] | null
50
+ }
51
+
52
+ /** Passed an invalid argument. */
53
+ export class InvalidArgumentError extends UndiciError {
54
+ name: 'InvalidArgumentError'
55
+ code: 'UND_ERR_INVALID_ARG'
56
+ }
57
+
58
+ /** Returned an invalid value. */
59
+ export class InvalidReturnValueError extends UndiciError {
60
+ name: 'InvalidReturnValueError'
61
+ code: 'UND_ERR_INVALID_RETURN_VALUE'
62
+ }
63
+
64
+ /** The request has been aborted by the user. */
65
+ export class RequestAbortedError extends UndiciError {
66
+ name: 'AbortError'
67
+ code: 'UND_ERR_ABORTED'
68
+ }
69
+
70
+ /** Expected error with reason. */
71
+ export class InformationalError extends UndiciError {
72
+ name: 'InformationalError'
73
+ code: 'UND_ERR_INFO'
74
+ }
75
+
76
+ /** Request body length does not match content-length header. */
77
+ export class RequestContentLengthMismatchError extends UndiciError {
78
+ name: 'RequestContentLengthMismatchError'
79
+ code: 'UND_ERR_REQ_CONTENT_LENGTH_MISMATCH'
80
+ }
81
+
82
+ /** Response body length does not match content-length header. */
83
+ export class ResponseContentLengthMismatchError extends UndiciError {
84
+ name: 'ResponseContentLengthMismatchError'
85
+ code: 'UND_ERR_RES_CONTENT_LENGTH_MISMATCH'
86
+ }
87
+
88
+ /** Trying to use a destroyed client. */
89
+ export class ClientDestroyedError extends UndiciError {
90
+ name: 'ClientDestroyedError'
91
+ code: 'UND_ERR_DESTROYED'
92
+ }
93
+
94
+ /** Trying to use a closed client. */
95
+ export class ClientClosedError extends UndiciError {
96
+ name: 'ClientClosedError'
97
+ code: 'UND_ERR_CLOSED'
98
+ }
99
+
100
+ /** There is an error with the socket. */
101
+ export class SocketError extends UndiciError {
102
+ name: 'SocketError'
103
+ code: 'UND_ERR_SOCKET'
104
+ socket: Client.SocketInfo | null
105
+ }
106
+
107
+ /** Encountered unsupported functionality. */
108
+ export class NotSupportedError extends UndiciError {
109
+ name: 'NotSupportedError'
110
+ code: 'UND_ERR_NOT_SUPPORTED'
111
+ }
112
+
113
+ /** No upstream has been added to the BalancedPool. */
114
+ export class BalancedPoolMissingUpstreamError extends UndiciError {
115
+ name: 'MissingUpstreamError'
116
+ code: 'UND_ERR_BPL_MISSING_UPSTREAM'
117
+ }
118
+
119
+ export class HTTPParserError extends UndiciError {
120
+ name: 'HTTPParserError'
121
+ code: string
122
+ }
123
+
124
+ /** The response exceed the length allowed. */
125
+ export class ResponseExceededMaxSizeError extends UndiciError {
126
+ name: 'ResponseExceededMaxSizeError'
127
+ code: 'UND_ERR_RES_EXCEEDED_MAX_SIZE'
128
+ }
129
+
130
+ export class RequestRetryError extends UndiciError {
131
+ constructor (
132
+ message: string,
133
+ statusCode: number,
134
+ headers?: IncomingHttpHeaders | string[] | null,
135
+ body?: null | Record<string, any> | string
136
+ )
137
+ name: 'RequestRetryError'
138
+ code: 'UND_ERR_REQ_RETRY'
139
+ statusCode: number
140
+ data: {
141
+ count: number;
142
+ }
143
+
144
+ headers: Record<string, string | string[]>
145
+ }
146
+
147
+ export class SecureProxyConnectionError extends UndiciError {
148
+ constructor (
149
+ cause?: Error,
150
+ message?: string,
151
+ options?: Record<any, any>
152
+ )
153
+ name: 'SecureProxyConnectionError'
154
+ code: 'UND_ERR_PRX_TLS'
155
+ }
156
+
157
+ export class MaxOriginsReachedError extends UndiciError {
158
+ name: 'MaxOriginsReachedError'
159
+ code: 'UND_ERR_MAX_ORIGINS_REACHED'
160
+ }
161
+
162
+ /** SOCKS5 proxy related error. */
163
+ export class Socks5ProxyError extends UndiciError {
164
+ constructor (
165
+ message?: string,
166
+ code?: string
167
+ )
168
+ name: 'Socks5ProxyError'
169
+ code: string
170
+ }
171
+
172
+ /** WebSocket decompressed message exceeded maximum size. */
173
+ export class MessageSizeExceededError extends UndiciError {
174
+ name: 'MessageSizeExceededError'
175
+ code: 'UND_ERR_WS_MESSAGE_SIZE_EXCEEDED'
176
+ }
177
+ }
node_modules/undici-types/eventsource.d.ts ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { MessageEvent, ErrorEvent } from './websocket'
2
+ import Dispatcher from './dispatcher'
3
+
4
+ import {
5
+ EventListenerOptions,
6
+ AddEventListenerOptions,
7
+ EventListenerOrEventListenerObject
8
+ } from './patch'
9
+
10
+ interface EventSourceEventMap {
11
+ error: ErrorEvent
12
+ message: MessageEvent
13
+ open: Event
14
+ }
15
+
16
+ interface EventSource extends EventTarget {
17
+ close(): void
18
+ readonly CLOSED: 2
19
+ readonly CONNECTING: 0
20
+ readonly OPEN: 1
21
+ onerror: ((this: EventSource, ev: ErrorEvent) => any) | null
22
+ onmessage: ((this: EventSource, ev: MessageEvent) => any) | null
23
+ onopen: ((this: EventSource, ev: Event) => any) | null
24
+ readonly readyState: 0 | 1 | 2
25
+ readonly url: string
26
+ readonly withCredentials: boolean
27
+
28
+ addEventListener<K extends keyof EventSourceEventMap>(
29
+ type: K,
30
+ listener: (this: EventSource, ev: EventSourceEventMap[K]) => any,
31
+ options?: boolean | AddEventListenerOptions
32
+ ): void
33
+ addEventListener(
34
+ type: string,
35
+ listener: EventListenerOrEventListenerObject,
36
+ options?: boolean | AddEventListenerOptions
37
+ ): void
38
+ removeEventListener<K extends keyof EventSourceEventMap>(
39
+ type: K,
40
+ listener: (this: EventSource, ev: EventSourceEventMap[K]) => any,
41
+ options?: boolean | EventListenerOptions
42
+ ): void
43
+ removeEventListener(
44
+ type: string,
45
+ listener: EventListenerOrEventListenerObject,
46
+ options?: boolean | EventListenerOptions
47
+ ): void
48
+ }
49
+
50
+ export declare const EventSource: {
51
+ prototype: EventSource
52
+ new (url: string | URL, init?: EventSourceInit): EventSource
53
+ readonly CLOSED: 2
54
+ readonly CONNECTING: 0
55
+ readonly OPEN: 1
56
+ }
57
+
58
+ interface EventSourceInit {
59
+ withCredentials?: boolean
60
+ // @deprecated use `node.dispatcher` instead
61
+ dispatcher?: Dispatcher
62
+ node?: {
63
+ dispatcher?: Dispatcher
64
+ reconnectionTime?: number
65
+ }
66
+ }
node_modules/undici-types/fetch.d.ts ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // based on https://github.com/Ethan-Arrowood/undici-fetch/blob/249269714db874351589d2d364a0645d5160ae71/index.d.ts (MIT license)
2
+ // and https://github.com/node-fetch/node-fetch/blob/914ce6be5ec67a8bab63d68510aabf07cb818b6d/index.d.ts (MIT license)
3
+ /// <reference types="node" />
4
+
5
+ import { Blob } from 'node:buffer'
6
+ import { URL, URLSearchParams } from 'node:url'
7
+ import { ReadableStream } from 'node:stream/web'
8
+ import { FormData } from './formdata'
9
+ import { HeaderRecord } from './header'
10
+ import Dispatcher from './dispatcher'
11
+
12
+ export type RequestInfo = string | URL | Request
13
+
14
+ export declare function fetch (
15
+ input: RequestInfo,
16
+ init?: RequestInit
17
+ ): Promise<Response>
18
+
19
+ export type BodyInit =
20
+ | ArrayBuffer
21
+ | AsyncIterable<Uint8Array>
22
+ | Blob
23
+ | FormData
24
+ | Iterable<Uint8Array>
25
+ | NodeJS.ArrayBufferView
26
+ | URLSearchParams
27
+ | null
28
+ | string
29
+
30
+ export class BodyMixin {
31
+ readonly body: ReadableStream | null
32
+ readonly bodyUsed: boolean
33
+
34
+ readonly arrayBuffer: () => Promise<ArrayBuffer>
35
+ readonly blob: () => Promise<Blob>
36
+ readonly bytes: () => Promise<Uint8Array>
37
+ /**
38
+ * @deprecated This method is not recommended for parsing multipart/form-data bodies in server environments.
39
+ * It is recommended to use a library such as [@fastify/busboy](https://www.npmjs.com/package/@fastify/busboy) as follows:
40
+ *
41
+ * @example
42
+ * ```js
43
+ * import { Busboy } from '@fastify/busboy'
44
+ * import { Readable } from 'node:stream'
45
+ *
46
+ * const response = await fetch('...')
47
+ * const busboy = new Busboy({ headers: { 'content-type': response.headers.get('content-type') } })
48
+ *
49
+ * // handle events emitted from `busboy`
50
+ *
51
+ * Readable.fromWeb(response.body).pipe(busboy)
52
+ * ```
53
+ */
54
+ readonly formData: () => Promise<FormData>
55
+ readonly json: () => Promise<unknown>
56
+ readonly text: () => Promise<string>
57
+ }
58
+
59
+ export interface SpecIterator<T, TReturn = any, TNext = undefined> {
60
+ next(...args: [] | [TNext]): IteratorResult<T, TReturn>;
61
+ }
62
+
63
+ export interface SpecIterableIterator<T> extends SpecIterator<T> {
64
+ [Symbol.iterator](): SpecIterableIterator<T>;
65
+ }
66
+
67
+ export interface SpecIterable<T> {
68
+ [Symbol.iterator](): SpecIterator<T>;
69
+ }
70
+
71
+ export type HeadersInit = [string, string][] | HeaderRecord | Headers
72
+
73
+ export declare class Headers implements SpecIterable<[string, string]> {
74
+ constructor (init?: HeadersInit)
75
+ readonly append: (name: string, value: string) => void
76
+ readonly delete: (name: string) => void
77
+ readonly get: (name: string) => string | null
78
+ readonly has: (name: string) => boolean
79
+ readonly set: (name: string, value: string) => void
80
+ readonly getSetCookie: () => string[]
81
+ readonly forEach: (
82
+ callbackfn: (value: string, key: string, iterable: Headers) => void,
83
+ thisArg?: unknown
84
+ ) => void
85
+
86
+ readonly keys: () => SpecIterableIterator<string>
87
+ readonly values: () => SpecIterableIterator<string>
88
+ readonly entries: () => SpecIterableIterator<[string, string]>
89
+ readonly [Symbol.iterator]: () => SpecIterableIterator<[string, string]>
90
+ }
91
+
92
+ export type RequestCache =
93
+ | 'default'
94
+ | 'force-cache'
95
+ | 'no-cache'
96
+ | 'no-store'
97
+ | 'only-if-cached'
98
+ | 'reload'
99
+
100
+ export type RequestCredentials = 'omit' | 'include' | 'same-origin'
101
+
102
+ type RequestDestination =
103
+ | ''
104
+ | 'audio'
105
+ | 'audioworklet'
106
+ | 'document'
107
+ | 'embed'
108
+ | 'font'
109
+ | 'image'
110
+ | 'manifest'
111
+ | 'object'
112
+ | 'paintworklet'
113
+ | 'report'
114
+ | 'script'
115
+ | 'sharedworker'
116
+ | 'style'
117
+ | 'track'
118
+ | 'video'
119
+ | 'worker'
120
+ | 'xslt'
121
+
122
+ export interface RequestInit {
123
+ body?: BodyInit | null
124
+ cache?: RequestCache
125
+ credentials?: RequestCredentials
126
+ dispatcher?: Dispatcher
127
+ duplex?: RequestDuplex
128
+ headers?: HeadersInit
129
+ integrity?: string
130
+ keepalive?: boolean
131
+ method?: string
132
+ mode?: RequestMode
133
+ redirect?: RequestRedirect
134
+ referrer?: string
135
+ referrerPolicy?: ReferrerPolicy
136
+ signal?: AbortSignal | null
137
+ window?: null
138
+ }
139
+
140
+ export type ReferrerPolicy =
141
+ | ''
142
+ | 'no-referrer'
143
+ | 'no-referrer-when-downgrade'
144
+ | 'origin'
145
+ | 'origin-when-cross-origin'
146
+ | 'same-origin'
147
+ | 'strict-origin'
148
+ | 'strict-origin-when-cross-origin'
149
+ | 'unsafe-url'
150
+
151
+ export type RequestMode = 'cors' | 'navigate' | 'no-cors' | 'same-origin'
152
+
153
+ export type RequestRedirect = 'error' | 'follow' | 'manual'
154
+
155
+ export type RequestDuplex = 'half'
156
+
157
+ export declare class Request extends BodyMixin {
158
+ constructor (input: RequestInfo, init?: RequestInit)
159
+
160
+ readonly cache: RequestCache
161
+ readonly credentials: RequestCredentials
162
+ readonly destination: RequestDestination
163
+ readonly headers: Headers
164
+ readonly integrity: string
165
+ readonly method: string
166
+ readonly mode: RequestMode
167
+ readonly redirect: RequestRedirect
168
+ readonly referrer: string
169
+ readonly referrerPolicy: ReferrerPolicy
170
+ readonly url: string
171
+
172
+ readonly keepalive: boolean
173
+ readonly signal: AbortSignal
174
+ readonly duplex: RequestDuplex
175
+
176
+ readonly clone: () => Request
177
+ }
178
+
179
+ export interface ResponseInit {
180
+ readonly status?: number
181
+ readonly statusText?: string
182
+ readonly headers?: HeadersInit
183
+ }
184
+
185
+ export type ResponseType =
186
+ | 'basic'
187
+ | 'cors'
188
+ | 'default'
189
+ | 'error'
190
+ | 'opaque'
191
+ | 'opaqueredirect'
192
+
193
+ export type ResponseRedirectStatus = 301 | 302 | 303 | 307 | 308
194
+
195
+ export declare class Response extends BodyMixin {
196
+ constructor (body?: BodyInit, init?: ResponseInit)
197
+
198
+ readonly headers: Headers
199
+ readonly ok: boolean
200
+ readonly status: number
201
+ readonly statusText: string
202
+ readonly type: ResponseType
203
+ readonly url: string
204
+ readonly redirected: boolean
205
+
206
+ readonly clone: () => Response
207
+
208
+ static error (): Response
209
+ static json (data: any, init?: ResponseInit): Response
210
+ static redirect (url: string | URL, status?: ResponseRedirectStatus): Response
211
+ }
node_modules/undici-types/formdata.d.ts ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Based on https://github.com/octet-stream/form-data/blob/2d0f0dc371517444ce1f22cdde13f51995d0953a/lib/FormData.ts (MIT)
2
+ /// <reference types="node" />
3
+
4
+ import { File } from 'node:buffer'
5
+ import { SpecIterableIterator } from './fetch'
6
+
7
+ /**
8
+ * A `string` or `File` that represents a single value from a set of `FormData` key-value pairs.
9
+ */
10
+ declare type FormDataEntryValue = string | File
11
+
12
+ /**
13
+ * Provides a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent using fetch().
14
+ */
15
+ export declare class FormData {
16
+ /**
17
+ * Appends a new value onto an existing key inside a FormData object,
18
+ * or adds the key if it does not already exist.
19
+ *
20
+ * The difference between `set()` and `append()` is that if the specified key already exists, `set()` will overwrite all existing values with the new one, whereas `append()` will append the new value onto the end of the existing set of values.
21
+ *
22
+ * @param name The name of the field whose data is contained in `value`.
23
+ * @param value The field's value. This can be [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob)
24
+ or [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File). If none of these are specified the value is converted to a string.
25
+ * @param fileName The filename reported to the server, when a Blob or File is passed as the second parameter. The default filename for Blob objects is "blob". The default filename for File objects is the file's filename.
26
+ */
27
+ append (name: string, value: unknown, fileName?: string): void
28
+
29
+ /**
30
+ * Set a new value for an existing key inside FormData,
31
+ * or add the new field if it does not already exist.
32
+ *
33
+ * @param name The name of the field whose data is contained in `value`.
34
+ * @param value The field's value. This can be [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob)
35
+ or [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File). If none of these are specified the value is converted to a string.
36
+ * @param fileName The filename reported to the server, when a Blob or File is passed as the second parameter. The default filename for Blob objects is "blob". The default filename for File objects is the file's filename.
37
+ *
38
+ */
39
+ set (name: string, value: unknown, fileName?: string): void
40
+
41
+ /**
42
+ * Returns the first value associated with a given key from within a `FormData` object.
43
+ * If you expect multiple values and want all of them, use the `getAll()` method instead.
44
+ *
45
+ * @param {string} name A name of the value you want to retrieve.
46
+ *
47
+ * @returns A `FormDataEntryValue` containing the value. If the key doesn't exist, the method returns null.
48
+ */
49
+ get (name: string): FormDataEntryValue | null
50
+
51
+ /**
52
+ * Returns all the values associated with a given key from within a `FormData` object.
53
+ *
54
+ * @param {string} name A name of the value you want to retrieve.
55
+ *
56
+ * @returns An array of `FormDataEntryValue` whose key matches the value passed in the `name` parameter. If the key doesn't exist, the method returns an empty list.
57
+ */
58
+ getAll (name: string): FormDataEntryValue[]
59
+
60
+ /**
61
+ * Returns a boolean stating whether a `FormData` object contains a certain key.
62
+ *
63
+ * @param name A string representing the name of the key you want to test for.
64
+ *
65
+ * @return A boolean value.
66
+ */
67
+ has (name: string): boolean
68
+
69
+ /**
70
+ * Deletes a key and its value(s) from a `FormData` object.
71
+ *
72
+ * @param name The name of the key you want to delete.
73
+ */
74
+ delete (name: string): void
75
+
76
+ /**
77
+ * Executes given callback function for each field of the FormData instance
78
+ */
79
+ forEach: (
80
+ callbackfn: (value: FormDataEntryValue, key: string, iterable: FormData) => void,
81
+ thisArg?: unknown
82
+ ) => void
83
+
84
+ /**
85
+ * Returns an [`iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) allowing to go through all keys contained in this `FormData` object.
86
+ * Each key is a `string`.
87
+ */
88
+ keys: () => SpecIterableIterator<string>
89
+
90
+ /**
91
+ * Returns an [`iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) allowing to go through all values contained in this object `FormData` object.
92
+ * Each value is a [`FormDataValue`](https://developer.mozilla.org/en-US/docs/Web/API/FormDataEntryValue).
93
+ */
94
+ values: () => SpecIterableIterator<FormDataEntryValue>
95
+
96
+ /**
97
+ * Returns an [`iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) allowing to go through the `FormData` key/value pairs.
98
+ * The key of each pair is a string; the value is a [`FormDataValue`](https://developer.mozilla.org/en-US/docs/Web/API/FormDataEntryValue).
99
+ */
100
+ entries: () => SpecIterableIterator<[string, FormDataEntryValue]>
101
+
102
+ /**
103
+ * An alias for FormData#entries()
104
+ */
105
+ [Symbol.iterator]: () => SpecIterableIterator<[string, FormDataEntryValue]>
106
+
107
+ readonly [Symbol.toStringTag]: string
108
+ }
node_modules/undici-types/global-dispatcher.d.ts ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import Dispatcher from './dispatcher'
2
+
3
+ declare function setGlobalDispatcher<DispatcherImplementation extends Dispatcher> (dispatcher: DispatcherImplementation): void
4
+ declare function getGlobalDispatcher (): Dispatcher
5
+
6
+ export {
7
+ getGlobalDispatcher,
8
+ setGlobalDispatcher
9
+ }
node_modules/undici-types/global-origin.d.ts ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ declare function setGlobalOrigin (origin: string | URL | undefined): void
2
+ declare function getGlobalOrigin (): URL | undefined
3
+
4
+ export {
5
+ setGlobalOrigin,
6
+ getGlobalOrigin
7
+ }
node_modules/undici-types/h2c-client.d.ts ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { URL } from 'node: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
+ connect?: Omit<Partial<buildConnector.BuildOptions>, 'allowH2'> | buildConnector.connector;
55
+ /** TODO */
56
+ maxRequestsPerClient?: number;
57
+ /** TODO */
58
+ localAddress?: string;
59
+ /** Max response body size in bytes, -1 is disabled */
60
+ maxResponseSize?: number;
61
+ /** Enables a family autodetection algorithm that loosely implements section 5 of RFC 8305. */
62
+ autoSelectFamily?: boolean;
63
+ /** The amount of time in milliseconds to wait for a connection attempt to finish before trying the next address when using the `autoSelectFamily` option. */
64
+ autoSelectFamilyAttemptTimeout?: number;
65
+ /**
66
+ * @description Dictates the maximum number of concurrent streams for a single H2 session. It can be overridden by a SETTINGS remote frame.
67
+ * @default 100
68
+ */
69
+ maxConcurrentStreams?: number
70
+ }
71
+ }
72
+
73
+ export default H2CClient
node_modules/undici-types/handlers.d.ts ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Dispatcher from './dispatcher'
2
+
3
+ export declare class RedirectHandler implements Dispatcher.DispatchHandler {
4
+ constructor (
5
+ dispatch: Dispatcher.Dispatch,
6
+ maxRedirections: number,
7
+ opts: Dispatcher.DispatchOptions,
8
+ handler: Dispatcher.DispatchHandler,
9
+ redirectionLimitReached: boolean
10
+ )
11
+ }
12
+
13
+ export declare class DecoratorHandler implements Dispatcher.DispatchHandler {
14
+ constructor (handler: Dispatcher.DispatchHandler)
15
+ }
node_modules/undici-types/header.d.ts ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { Autocomplete } from './utility'
2
+
3
+ /**
4
+ * The header type declaration of `undici`.
5
+ */
6
+ export type IncomingHttpHeaders = Record<string, string | string[] | undefined>
7
+
8
+ type HeaderNames = Autocomplete<
9
+ | 'Accept'
10
+ | 'Accept-CH'
11
+ | 'Accept-Charset'
12
+ | 'Accept-Encoding'
13
+ | 'Accept-Language'
14
+ | 'Accept-Patch'
15
+ | 'Accept-Post'
16
+ | 'Accept-Ranges'
17
+ | 'Access-Control-Allow-Credentials'
18
+ | 'Access-Control-Allow-Headers'
19
+ | 'Access-Control-Allow-Methods'
20
+ | 'Access-Control-Allow-Origin'
21
+ | 'Access-Control-Expose-Headers'
22
+ | 'Access-Control-Max-Age'
23
+ | 'Access-Control-Request-Headers'
24
+ | 'Access-Control-Request-Method'
25
+ | 'Age'
26
+ | 'Allow'
27
+ | 'Alt-Svc'
28
+ | 'Alt-Used'
29
+ | 'Authorization'
30
+ | 'Cache-Control'
31
+ | 'Clear-Site-Data'
32
+ | 'Connection'
33
+ | 'Content-Disposition'
34
+ | 'Content-Encoding'
35
+ | 'Content-Language'
36
+ | 'Content-Length'
37
+ | 'Content-Location'
38
+ | 'Content-Range'
39
+ | 'Content-Security-Policy'
40
+ | 'Content-Security-Policy-Report-Only'
41
+ | 'Content-Type'
42
+ | 'Cookie'
43
+ | 'Cross-Origin-Embedder-Policy'
44
+ | 'Cross-Origin-Opener-Policy'
45
+ | 'Cross-Origin-Resource-Policy'
46
+ | 'Date'
47
+ | 'Device-Memory'
48
+ | 'ETag'
49
+ | 'Expect'
50
+ | 'Expect-CT'
51
+ | 'Expires'
52
+ | 'Forwarded'
53
+ | 'From'
54
+ | 'Host'
55
+ | 'If-Match'
56
+ | 'If-Modified-Since'
57
+ | 'If-None-Match'
58
+ | 'If-Range'
59
+ | 'If-Unmodified-Since'
60
+ | 'Keep-Alive'
61
+ | 'Last-Modified'
62
+ | 'Link'
63
+ | 'Location'
64
+ | 'Max-Forwards'
65
+ | 'Origin'
66
+ | 'Permissions-Policy'
67
+ | 'Priority'
68
+ | 'Proxy-Authenticate'
69
+ | 'Proxy-Authorization'
70
+ | 'Range'
71
+ | 'Referer'
72
+ | 'Referrer-Policy'
73
+ | 'Retry-After'
74
+ | 'Sec-Fetch-Dest'
75
+ | 'Sec-Fetch-Mode'
76
+ | 'Sec-Fetch-Site'
77
+ | 'Sec-Fetch-User'
78
+ | 'Sec-Purpose'
79
+ | 'Sec-WebSocket-Accept'
80
+ | 'Server'
81
+ | 'Server-Timing'
82
+ | 'Service-Worker-Navigation-Preload'
83
+ | 'Set-Cookie'
84
+ | 'SourceMap'
85
+ | 'Strict-Transport-Security'
86
+ | 'TE'
87
+ | 'Timing-Allow-Origin'
88
+ | 'Trailer'
89
+ | 'Transfer-Encoding'
90
+ | 'Upgrade'
91
+ | 'Upgrade-Insecure-Requests'
92
+ | 'User-Agent'
93
+ | 'Vary'
94
+ | 'Via'
95
+ | 'WWW-Authenticate'
96
+ | 'X-Content-Type-Options'
97
+ | 'X-Frame-Options'
98
+ >
99
+
100
+ type IANARegisteredMimeType = Autocomplete<
101
+ | 'audio/aac'
102
+ | 'video/x-msvideo'
103
+ | 'image/avif'
104
+ | 'video/av1'
105
+ | 'application/octet-stream'
106
+ | 'image/bmp'
107
+ | 'text/css'
108
+ | 'text/csv'
109
+ | 'application/vnd.ms-fontobject'
110
+ | 'application/epub+zip'
111
+ | 'image/gif'
112
+ | 'application/gzip'
113
+ | 'text/html'
114
+ | 'image/x-icon'
115
+ | 'text/calendar'
116
+ | 'image/jpeg'
117
+ | 'text/javascript'
118
+ | 'application/json'
119
+ | 'application/ld+json'
120
+ | 'audio/x-midi'
121
+ | 'audio/mpeg'
122
+ | 'video/mp4'
123
+ | 'video/mpeg'
124
+ | 'audio/ogg'
125
+ | 'video/ogg'
126
+ | 'application/ogg'
127
+ | 'audio/opus'
128
+ | 'font/otf'
129
+ | 'application/pdf'
130
+ | 'image/png'
131
+ | 'application/rtf'
132
+ | 'image/svg+xml'
133
+ | 'image/tiff'
134
+ | 'video/mp2t'
135
+ | 'font/ttf'
136
+ | 'text/plain'
137
+ | 'application/wasm'
138
+ | 'video/webm'
139
+ | 'audio/webm'
140
+ | 'image/webp'
141
+ | 'font/woff'
142
+ | 'font/woff2'
143
+ | 'application/xhtml+xml'
144
+ | 'application/xml'
145
+ | 'application/zip'
146
+ | 'video/3gpp'
147
+ | 'video/3gpp2'
148
+ | 'model/gltf+json'
149
+ | 'model/gltf-binary'
150
+ >
151
+
152
+ type KnownHeaderValues = {
153
+ 'content-type': IANARegisteredMimeType
154
+ }
155
+
156
+ export type HeaderRecord = {
157
+ [K in HeaderNames | Lowercase<HeaderNames>]?: Lowercase<K> extends keyof KnownHeaderValues
158
+ ? KnownHeaderValues[Lowercase<K>]
159
+ : string
160
+ }
node_modules/undici-types/index.d.ts ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Dispatcher from './dispatcher'
2
+ import { setGlobalDispatcher, getGlobalDispatcher } from './global-dispatcher'
3
+ import { setGlobalOrigin, getGlobalOrigin } from './global-origin'
4
+ import Pool from './pool'
5
+ import { RedirectHandler, DecoratorHandler } from './handlers'
6
+
7
+ import BalancedPool from './balanced-pool'
8
+ import RoundRobinPool from './round-robin-pool'
9
+ import Client from './client'
10
+ import H2CClient from './h2c-client'
11
+ import buildConnector from './connector'
12
+ import errors from './errors'
13
+ import Agent from './agent'
14
+ import MockClient from './mock-client'
15
+ import MockPool from './mock-pool'
16
+ import MockAgent from './mock-agent'
17
+ import { SnapshotAgent } from './snapshot-agent'
18
+ import { MockCallHistory, MockCallHistoryLog } from './mock-call-history'
19
+ import mockErrors from './mock-errors'
20
+ import ProxyAgent from './proxy-agent'
21
+ import Socks5ProxyAgent from './socks5-proxy-agent'
22
+ import EnvHttpProxyAgent from './env-http-proxy-agent'
23
+ import RetryHandler from './retry-handler'
24
+ import RetryAgent from './retry-agent'
25
+ import { request, pipeline, stream, connect, upgrade } from './api'
26
+ import interceptors from './interceptors'
27
+
28
+ import CacheInterceptor from './cache-interceptor'
29
+ declare const cacheStores: {
30
+ MemoryCacheStore: typeof CacheInterceptor.MemoryCacheStore;
31
+ SqliteCacheStore: typeof CacheInterceptor.SqliteCacheStore;
32
+ }
33
+
34
+ export * from './util'
35
+ export * from './cookies'
36
+ export * from './eventsource'
37
+ export * from './fetch'
38
+ export * from './formdata'
39
+ export * from './diagnostics-channel'
40
+ export * from './websocket'
41
+ export * from './content-type'
42
+ export * from './cache'
43
+ export { Interceptable } from './mock-interceptor'
44
+
45
+ declare function globalThisInstall (): void
46
+
47
+ export { Dispatcher, BalancedPool, RoundRobinPool, Pool, Client, buildConnector, errors, Agent, request, stream, pipeline, connect, upgrade, setGlobalDispatcher, getGlobalDispatcher, setGlobalOrigin, getGlobalOrigin, interceptors, cacheStores, MockClient, MockPool, MockAgent, SnapshotAgent, MockCallHistory, MockCallHistoryLog, mockErrors, ProxyAgent, Socks5ProxyAgent, EnvHttpProxyAgent, RedirectHandler, DecoratorHandler, RetryHandler, RetryAgent, H2CClient, globalThisInstall as install }
48
+ export default Undici
49
+
50
+ declare namespace Undici {
51
+ const Dispatcher: typeof import('./dispatcher').default
52
+ const Pool: typeof import('./pool').default
53
+ const RedirectHandler: typeof import ('./handlers').RedirectHandler
54
+ const DecoratorHandler: typeof import ('./handlers').DecoratorHandler
55
+ const RetryHandler: typeof import ('./retry-handler').default
56
+ const BalancedPool: typeof import('./balanced-pool').default
57
+ const RoundRobinPool: typeof import('./round-robin-pool').default
58
+ const Client: typeof import('./client').default
59
+ const H2CClient: typeof import('./h2c-client').default
60
+ const buildConnector: typeof import('./connector').default
61
+ const errors: typeof import('./errors').default
62
+ const Agent: typeof import('./agent').default
63
+ const setGlobalDispatcher: typeof import('./global-dispatcher').setGlobalDispatcher
64
+ const getGlobalDispatcher: typeof import('./global-dispatcher').getGlobalDispatcher
65
+ const request: typeof import('./api').request
66
+ const stream: typeof import('./api').stream
67
+ const pipeline: typeof import('./api').pipeline
68
+ const connect: typeof import('./api').connect
69
+ const upgrade: typeof import('./api').upgrade
70
+ const MockClient: typeof import('./mock-client').default
71
+ const MockPool: typeof import('./mock-pool').default
72
+ const MockAgent: typeof import('./mock-agent').default
73
+ const SnapshotAgent: typeof import('./snapshot-agent').SnapshotAgent
74
+ const MockCallHistory: typeof import('./mock-call-history').MockCallHistory
75
+ const MockCallHistoryLog: typeof import('./mock-call-history').MockCallHistoryLog
76
+ const mockErrors: typeof import('./mock-errors').default
77
+ const ProxyAgent: typeof import('./proxy-agent').default
78
+ const Socks5ProxyAgent: typeof import('./socks5-proxy-agent').default
79
+ const fetch: typeof import('./fetch').fetch
80
+ const Headers: typeof import('./fetch').Headers
81
+ const Response: typeof import('./fetch').Response
82
+ const Request: typeof import('./fetch').Request
83
+ const FormData: typeof import('./formdata').FormData
84
+ const caches: typeof import('./cache').caches
85
+ const interceptors: typeof import('./interceptors').default
86
+ const cacheStores: {
87
+ MemoryCacheStore: typeof import('./cache-interceptor').default.MemoryCacheStore,
88
+ SqliteCacheStore: typeof import('./cache-interceptor').default.SqliteCacheStore
89
+ }
90
+ const install: typeof globalThisInstall
91
+ }
node_modules/undici-types/interceptors.d.ts ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import CacheHandler from './cache-interceptor'
2
+ import Dispatcher from './dispatcher'
3
+ import RetryHandler from './retry-handler'
4
+ import { LookupOptions } from 'node:dns'
5
+
6
+ export default Interceptors
7
+
8
+ declare namespace Interceptors {
9
+ export type DumpInterceptorOpts = { maxSize?: number }
10
+ export type RetryInterceptorOpts = RetryHandler.RetryOptions
11
+ export type RedirectInterceptorOpts = { maxRedirections?: number }
12
+ export type DecompressInterceptorOpts = {
13
+ skipErrorResponses?: boolean
14
+ skipStatusCodes?: number[]
15
+ }
16
+
17
+ export type ResponseErrorInterceptorOpts = { throwOnError: boolean }
18
+ export type CacheInterceptorOpts = CacheHandler.CacheOptions
19
+
20
+ // DNS interceptor
21
+ export type DNSInterceptorRecord = { address: string, ttl: number, family: 4 | 6 }
22
+ export type DNSInterceptorOriginRecords = { records: { 4: { ips: DNSInterceptorRecord[] } | null, 6: { ips: DNSInterceptorRecord[] } | null } }
23
+ export type DNSStorage = {
24
+ size: number
25
+ get(origin: string): DNSInterceptorOriginRecords | null
26
+ set(origin: string, records: DNSInterceptorOriginRecords | null, options: { ttl: number }): void
27
+ delete(origin: string): void
28
+ full(): boolean
29
+ }
30
+ export type DNSInterceptorOpts = {
31
+ maxTTL?: number
32
+ maxItems?: number
33
+ lookup?: (origin: URL, options: LookupOptions, callback: (err: NodeJS.ErrnoException | null, addresses: DNSInterceptorRecord[]) => void) => void
34
+ pick?: (origin: URL, records: DNSInterceptorOriginRecords, affinity: 4 | 6) => DNSInterceptorRecord
35
+ dualStack?: boolean
36
+ affinity?: 4 | 6
37
+ storage?: DNSStorage
38
+ }
39
+
40
+ // Deduplicate interceptor
41
+ export type DeduplicateMethods = 'GET' | 'HEAD' | 'OPTIONS' | 'TRACE'
42
+ export type DeduplicateInterceptorOpts = {
43
+ /**
44
+ * The HTTP methods to deduplicate.
45
+ * Note: Only safe HTTP methods can be deduplicated.
46
+ * @default ['GET']
47
+ */
48
+ methods?: DeduplicateMethods[]
49
+ /**
50
+ * Header names that, if present in a request, will cause the request to skip deduplication.
51
+ * Header name matching is case-insensitive.
52
+ * @default []
53
+ */
54
+ skipHeaderNames?: string[]
55
+ /**
56
+ * Header names to exclude from the deduplication key.
57
+ * Requests with different values for these headers will still be deduplicated together.
58
+ * Useful for headers like `x-request-id` that vary per request but shouldn't affect deduplication.
59
+ * Header name matching is case-insensitive.
60
+ * @default []
61
+ */
62
+ excludeHeaderNames?: string[]
63
+ /**
64
+ * Maximum bytes buffered per paused waiting deduplicated handler.
65
+ * If a waiting handler remains paused and exceeds this threshold,
66
+ * it is failed with an abort error to prevent unbounded memory growth.
67
+ * @default 5 * 1024 * 1024
68
+ */
69
+ maxBufferSize?: number
70
+ }
71
+
72
+ export function dump (opts?: DumpInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
73
+ export function retry (opts?: RetryInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
74
+ export function redirect (opts?: RedirectInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
75
+ export function decompress (opts?: DecompressInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
76
+ export function responseError (opts?: ResponseErrorInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
77
+ export function dns (opts?: DNSInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
78
+ export function cache (opts?: CacheInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
79
+ export function deduplicate (opts?: DeduplicateInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
80
+ }
node_modules/undici-types/mock-agent.d.ts ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Agent from './agent'
2
+ import Dispatcher from './dispatcher'
3
+ import { Interceptable, MockInterceptor } from './mock-interceptor'
4
+ import MockDispatch = MockInterceptor.MockDispatch
5
+ import { MockCallHistory } from './mock-call-history'
6
+
7
+ export default MockAgent
8
+
9
+ interface PendingInterceptor extends MockDispatch {
10
+ origin: string;
11
+ }
12
+
13
+ /** A mocked Agent class that implements the Agent API. It allows one to intercept HTTP requests made through undici and return mocked responses instead. */
14
+ declare class MockAgent<TMockAgentOptions extends MockAgent.Options = MockAgent.Options> extends Dispatcher {
15
+ constructor (options?: TMockAgentOptions)
16
+ /** Creates and retrieves mock Dispatcher instances which can then be used to intercept HTTP requests. If the number of connections on the mock agent is set to 1, a MockClient instance is returned. Otherwise a MockPool instance is returned. */
17
+ get<TInterceptable extends Interceptable>(origin: string): TInterceptable
18
+ get<TInterceptable extends Interceptable>(origin: RegExp): TInterceptable
19
+ get<TInterceptable extends Interceptable>(origin: ((origin: string) => boolean)): TInterceptable
20
+ /** Dispatches a mocked request. */
21
+ dispatch (options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandler): boolean
22
+ /** Closes the mock agent and waits for registered mock pools and clients to also close before resolving. */
23
+ close (): Promise<void>
24
+ /** Disables mocking in MockAgent. */
25
+ deactivate (): void
26
+ /** Enables mocking in a MockAgent instance. When instantiated, a MockAgent is automatically activated. Therefore, this method is only effective after `MockAgent.deactivate` has been called. */
27
+ activate (): void
28
+ /** Define host matchers so only matching requests that aren't intercepted by the mock dispatchers will be attempted. */
29
+ enableNetConnect (): void
30
+ enableNetConnect (host: string): void
31
+ enableNetConnect (host: RegExp): void
32
+ enableNetConnect (host: ((host: string) => boolean)): void
33
+ /** Causes all requests to throw when requests are not matched in a MockAgent intercept. */
34
+ disableNetConnect (): void
35
+ /** get call history. returns the MockAgent call history or undefined if the option is not enabled. */
36
+ getCallHistory (): MockCallHistory | undefined
37
+ /** clear every call history. Any MockCallHistoryLog will be deleted on the MockCallHistory instance */
38
+ clearCallHistory (): void
39
+ /** Enable call history. Any subsequence calls will then be registered. */
40
+ enableCallHistory (): this
41
+ /** Disable call history. Any subsequence calls will then not be registered. */
42
+ disableCallHistory (): this
43
+ pendingInterceptors (): PendingInterceptor[]
44
+ assertNoPendingInterceptors (options?: {
45
+ pendingInterceptorsFormatter?: PendingInterceptorsFormatter;
46
+ }): void
47
+ }
48
+
49
+ interface PendingInterceptorsFormatter {
50
+ format(pendingInterceptors: readonly PendingInterceptor[]): string;
51
+ }
52
+
53
+ declare namespace MockAgent {
54
+ /** MockAgent options. */
55
+ export interface Options extends Agent.Options {
56
+ /** A custom agent to be encapsulated by the MockAgent. */
57
+ agent?: Dispatcher;
58
+
59
+ /** Ignore trailing slashes in the path */
60
+ ignoreTrailingSlash?: boolean;
61
+
62
+ /** Accept URLs with search parameters using non standard syntaxes. default false */
63
+ acceptNonStandardSearchParameters?: boolean;
64
+
65
+ /** Enable call history. you can either call MockAgent.enableCallHistory(). default false */
66
+ enableCallHistory?: boolean
67
+ }
68
+ }
node_modules/undici-types/mock-call-history.d.ts ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Dispatcher from './dispatcher'
2
+
3
+ declare namespace MockCallHistoryLog {
4
+ /** request's configuration properties */
5
+ export type MockCallHistoryLogProperties = 'protocol' | 'host' | 'port' | 'origin' | 'path' | 'hash' | 'fullUrl' | 'method' | 'searchParams' | 'body' | 'headers'
6
+ }
7
+
8
+ /** a log reflecting request configuration */
9
+ declare class MockCallHistoryLog {
10
+ constructor (requestInit: Dispatcher.DispatchOptions)
11
+ /** protocol used. ie. 'https:' or 'http:' etc... */
12
+ protocol: string
13
+ /** request's host. */
14
+ host: string
15
+ /** request's port. */
16
+ port: string
17
+ /** request's origin. ie. https://localhost:3000. */
18
+ origin: string
19
+ /** path. never contains searchParams. */
20
+ path: string
21
+ /** request's hash. */
22
+ hash: string
23
+ /** the full url requested. */
24
+ fullUrl: string
25
+ /** request's method. */
26
+ method: string
27
+ /** search params. */
28
+ searchParams: Record<string, string>
29
+ /** request's body */
30
+ body: string | null | undefined
31
+ /** request's headers */
32
+ headers: Record<string, string | string[]> | null | undefined
33
+
34
+ /** returns an Map of property / value pair */
35
+ toMap (): Map<MockCallHistoryLog.MockCallHistoryLogProperties, string | Record<string, string | string[]> | null | undefined>
36
+
37
+ /** returns a string computed with all key value pair */
38
+ toString (): string
39
+ }
40
+
41
+ declare namespace MockCallHistory {
42
+ export type FilterCallsOperator = 'AND' | 'OR'
43
+
44
+ /** modify the filtering behavior */
45
+ export interface FilterCallsOptions {
46
+ /** the operator to apply when filtering. 'OR' will adds any MockCallHistoryLog matching any criteria given. 'AND' will adds only MockCallHistoryLog matching every criteria given. (default 'OR') */
47
+ operator?: FilterCallsOperator | Lowercase<FilterCallsOperator>
48
+ }
49
+ /** a function to be executed for filtering MockCallHistoryLog */
50
+ export type FilterCallsFunctionCriteria = (log: MockCallHistoryLog) => boolean
51
+
52
+ /** parameter to filter MockCallHistoryLog */
53
+ export type FilterCallsParameter = string | RegExp | undefined | null
54
+
55
+ /** an object to execute multiple filtering at once */
56
+ export interface FilterCallsObjectCriteria extends Record<string, FilterCallsParameter> {
57
+ /** filter by request protocol. ie https: */
58
+ protocol?: FilterCallsParameter;
59
+ /** filter by request host. */
60
+ host?: FilterCallsParameter;
61
+ /** filter by request port. */
62
+ port?: FilterCallsParameter;
63
+ /** filter by request origin. */
64
+ origin?: FilterCallsParameter;
65
+ /** filter by request path. */
66
+ path?: FilterCallsParameter;
67
+ /** filter by request hash. */
68
+ hash?: FilterCallsParameter;
69
+ /** filter by request fullUrl. */
70
+ fullUrl?: FilterCallsParameter;
71
+ /** filter by request method. */
72
+ method?: FilterCallsParameter;
73
+ }
74
+ }
75
+
76
+ /** a call history to track requests configuration */
77
+ declare class MockCallHistory {
78
+ constructor (name: string)
79
+ /** returns an array of MockCallHistoryLog. */
80
+ calls (): Array<MockCallHistoryLog>
81
+ /** returns the first MockCallHistoryLog */
82
+ firstCall (): MockCallHistoryLog | undefined
83
+ /** returns the last MockCallHistoryLog. */
84
+ lastCall (): MockCallHistoryLog | undefined
85
+ /** returns the nth MockCallHistoryLog. */
86
+ nthCall (position: number): MockCallHistoryLog | undefined
87
+ /** return all MockCallHistoryLog matching any of criteria given. if an object is used with multiple properties, you can change the operator to apply during filtering on options */
88
+ filterCalls (criteria: MockCallHistory.FilterCallsFunctionCriteria | MockCallHistory.FilterCallsObjectCriteria | RegExp, options?: MockCallHistory.FilterCallsOptions): Array<MockCallHistoryLog>
89
+ /** return all MockCallHistoryLog matching the given protocol. if a string is given, it is matched with includes */
90
+ filterCallsByProtocol (protocol: MockCallHistory.FilterCallsParameter): Array<MockCallHistoryLog>
91
+ /** return all MockCallHistoryLog matching the given host. if a string is given, it is matched with includes */
92
+ filterCallsByHost (host: MockCallHistory.FilterCallsParameter): Array<MockCallHistoryLog>
93
+ /** return all MockCallHistoryLog matching the given port. if a string is given, it is matched with includes */
94
+ filterCallsByPort (port: MockCallHistory.FilterCallsParameter): Array<MockCallHistoryLog>
95
+ /** return all MockCallHistoryLog matching the given origin. if a string is given, it is matched with includes */
96
+ filterCallsByOrigin (origin: MockCallHistory.FilterCallsParameter): Array<MockCallHistoryLog>
97
+ /** return all MockCallHistoryLog matching the given path. if a string is given, it is matched with includes */
98
+ filterCallsByPath (path: MockCallHistory.FilterCallsParameter): Array<MockCallHistoryLog>
99
+ /** return all MockCallHistoryLog matching the given hash. if a string is given, it is matched with includes */
100
+ filterCallsByHash (hash: MockCallHistory.FilterCallsParameter): Array<MockCallHistoryLog>
101
+ /** return all MockCallHistoryLog matching the given fullUrl. if a string is given, it is matched with includes */
102
+ filterCallsByFullUrl (fullUrl: MockCallHistory.FilterCallsParameter): Array<MockCallHistoryLog>
103
+ /** return all MockCallHistoryLog matching the given method. if a string is given, it is matched with includes */
104
+ filterCallsByMethod (method: MockCallHistory.FilterCallsParameter): Array<MockCallHistoryLog>
105
+ /** clear all MockCallHistoryLog on this MockCallHistory. */
106
+ clear (): void
107
+ /** use it with for..of loop or spread operator */
108
+ [Symbol.iterator]: () => Generator<MockCallHistoryLog>
109
+ }
110
+
111
+ export { MockCallHistoryLog, MockCallHistory }
node_modules/undici-types/mock-client.d.ts ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Client from './client'
2
+ import Dispatcher from './dispatcher'
3
+ import MockAgent from './mock-agent'
4
+ import { MockInterceptor, Interceptable } from './mock-interceptor'
5
+
6
+ export default MockClient
7
+
8
+ /** MockClient extends the Client API and allows one to mock requests. */
9
+ declare class MockClient extends Client implements Interceptable {
10
+ constructor (origin: string, options: MockClient.Options)
11
+ /** Intercepts any matching requests that use the same origin as this mock client. */
12
+ intercept (options: MockInterceptor.Options): MockInterceptor
13
+ /** Dispatches a mocked request. */
14
+ dispatch (options: Dispatcher.DispatchOptions, handlers: Dispatcher.DispatchHandler): boolean
15
+ /** Closes the mock client and gracefully waits for enqueued requests to complete. */
16
+ close (): Promise<void>
17
+ /** Clean up all the prepared mocks. */
18
+ cleanMocks (): void
19
+ }
20
+
21
+ declare namespace MockClient {
22
+ /** MockClient options. */
23
+ export interface Options extends Client.Options {
24
+ /** The agent to associate this MockClient with. */
25
+ agent: MockAgent;
26
+ }
27
+ }
node_modules/undici-types/mock-errors.d.ts ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Errors from './errors'
2
+
3
+ export default MockErrors
4
+
5
+ declare namespace MockErrors {
6
+ /** The request does not match any registered mock dispatches. */
7
+ export class MockNotMatchedError extends Errors.UndiciError {
8
+ constructor (message?: string)
9
+ name: 'MockNotMatchedError'
10
+ code: 'UND_MOCK_ERR_MOCK_NOT_MATCHED'
11
+ }
12
+ }
node_modules/undici-types/mock-interceptor.d.ts ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { IncomingHttpHeaders } from './header'
2
+ import Dispatcher from './dispatcher'
3
+ import { BodyInit, Headers } from './fetch'
4
+
5
+ /** The scope associated with a mock dispatch. */
6
+ declare class MockScope<TData extends object = object> {
7
+ constructor (mockDispatch: MockInterceptor.MockDispatch<TData>)
8
+ /** Delay a reply by a set amount of time in ms. */
9
+ delay (waitInMs: number): MockScope<TData>
10
+ /** Persist the defined mock data for the associated reply. It will return the defined mock data indefinitely. */
11
+ persist (): MockScope<TData>
12
+ /** Define a reply for a set amount of matching requests. */
13
+ times (repeatTimes: number): MockScope<TData>
14
+ }
15
+
16
+ /** The interceptor for a Mock. */
17
+ declare class MockInterceptor {
18
+ constructor (options: MockInterceptor.Options, mockDispatches: MockInterceptor.MockDispatch[])
19
+ /** Mock an undici request with the defined reply. */
20
+ reply<TData extends object = object>(replyOptionsCallback: MockInterceptor.MockReplyOptionsCallback<TData>): MockScope<TData>
21
+ reply<TData extends object = object>(
22
+ statusCode: number,
23
+ data?: TData | Buffer | string | MockInterceptor.MockResponseDataHandler<TData>,
24
+ responseOptions?: MockInterceptor.MockResponseOptions
25
+ ): MockScope<TData>
26
+ /** Mock an undici request by throwing the defined reply error. */
27
+ replyWithError<TError extends Error = Error>(error: TError): MockScope
28
+ /** Set default reply headers on the interceptor for subsequent mocked replies. */
29
+ defaultReplyHeaders (headers: IncomingHttpHeaders): MockInterceptor
30
+ /** Set default reply trailers on the interceptor for subsequent mocked replies. */
31
+ defaultReplyTrailers (trailers: Record<string, string>): MockInterceptor
32
+ /** Set automatically calculated content-length header on subsequent mocked replies. */
33
+ replyContentLength (): MockInterceptor
34
+ }
35
+
36
+ declare namespace MockInterceptor {
37
+ /** MockInterceptor options. */
38
+ export interface Options {
39
+ /** Path to intercept on. */
40
+ path: string | RegExp | ((path: string) => boolean);
41
+ /** Method to intercept on. Defaults to GET. */
42
+ method?: string | RegExp | ((method: string) => boolean);
43
+ /** Body to intercept on. */
44
+ body?: string | RegExp | ((body: string) => boolean);
45
+ /** Headers to intercept on. */
46
+ headers?: Record<string, string | RegExp | ((body: string) => boolean)> | ((headers: Record<string, string>) => boolean);
47
+ /** Query params to intercept on */
48
+ query?: Record<string, any>;
49
+ }
50
+ export interface MockDispatch<TData extends object = object, TError extends Error = Error> extends Options {
51
+ times: number | null;
52
+ persist: boolean;
53
+ consumed: boolean;
54
+ data: MockDispatchData<TData, TError>;
55
+ }
56
+ export interface MockDispatchData<TData extends object = object, TError extends Error = Error> extends MockResponseOptions {
57
+ error: TError | null;
58
+ statusCode?: number;
59
+ data?: TData | string;
60
+ }
61
+ export interface MockResponseOptions {
62
+ headers?: IncomingHttpHeaders;
63
+ trailers?: Record<string, string>;
64
+ }
65
+
66
+ export interface MockResponseCallbackOptions {
67
+ path: string;
68
+ method: string;
69
+ headers?: Headers | Record<string, string>;
70
+ origin?: string;
71
+ body?: BodyInit | Dispatcher.DispatchOptions['body'] | null;
72
+ }
73
+
74
+ export type MockResponseDataHandler<TData extends object = object> = (
75
+ opts: MockResponseCallbackOptions
76
+ ) => TData | Buffer | string
77
+
78
+ export type MockReplyOptionsCallback<TData extends object = object> = (
79
+ opts: MockResponseCallbackOptions
80
+ ) => { statusCode: number, data?: TData | Buffer | string, responseOptions?: MockResponseOptions }
81
+ }
82
+
83
+ interface Interceptable extends Dispatcher {
84
+ /** Intercepts any matching requests that use the same origin as this mock client. */
85
+ intercept(options: MockInterceptor.Options): MockInterceptor;
86
+ /** Clean up all the prepared mocks. */
87
+ cleanMocks (): void
88
+ }
89
+
90
+ export {
91
+ Interceptable,
92
+ MockInterceptor,
93
+ MockScope
94
+ }
node_modules/undici-types/mock-pool.d.ts ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Pool from './pool'
2
+ import MockAgent from './mock-agent'
3
+ import { Interceptable, MockInterceptor } from './mock-interceptor'
4
+ import Dispatcher from './dispatcher'
5
+
6
+ export default MockPool
7
+
8
+ /** MockPool extends the Pool API and allows one to mock requests. */
9
+ declare class MockPool extends Pool implements Interceptable {
10
+ constructor (origin: string, options: MockPool.Options)
11
+ /** Intercepts any matching requests that use the same origin as this mock pool. */
12
+ intercept (options: MockInterceptor.Options): MockInterceptor
13
+ /** Dispatches a mocked request. */
14
+ dispatch (options: Dispatcher.DispatchOptions, handlers: Dispatcher.DispatchHandler): boolean
15
+ /** Closes the mock pool and gracefully waits for enqueued requests to complete. */
16
+ close (): Promise<void>
17
+ /** Clean up all the prepared mocks. */
18
+ cleanMocks (): void
19
+ }
20
+
21
+ declare namespace MockPool {
22
+ /** MockPool options. */
23
+ export interface Options extends Pool.Options {
24
+ /** The agent to associate this MockPool with. */
25
+ agent: MockAgent;
26
+ }
27
+ }
node_modules/undici-types/package.json ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "undici-types",
3
+ "version": "7.24.6",
4
+ "description": "A stand-alone types package for Undici",
5
+ "homepage": "https://undici.nodejs.org",
6
+ "bugs": {
7
+ "url": "https://github.com/nodejs/undici/issues"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/nodejs/undici.git"
12
+ },
13
+ "license": "MIT",
14
+ "types": "index.d.ts",
15
+ "files": [
16
+ "*.d.ts"
17
+ ],
18
+ "contributors": [
19
+ {
20
+ "name": "Daniele Belardi",
21
+ "url": "https://github.com/dnlup",
22
+ "author": true
23
+ },
24
+ {
25
+ "name": "Ethan Arrowood",
26
+ "url": "https://github.com/ethan-arrowood",
27
+ "author": true
28
+ },
29
+ {
30
+ "name": "Matteo Collina",
31
+ "url": "https://github.com/mcollina",
32
+ "author": true
33
+ },
34
+ {
35
+ "name": "Matthew Aitken",
36
+ "url": "https://github.com/KhafraDev",
37
+ "author": true
38
+ },
39
+ {
40
+ "name": "Robert Nagy",
41
+ "url": "https://github.com/ronag",
42
+ "author": true
43
+ },
44
+ {
45
+ "name": "Szymon Marczak",
46
+ "url": "https://github.com/szmarczak",
47
+ "author": true
48
+ },
49
+ {
50
+ "name": "Tomas Della Vedova",
51
+ "url": "https://github.com/delvedor",
52
+ "author": true
53
+ }
54
+ ]
55
+ }
node_modules/undici-types/patch.d.ts ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /// <reference types="node" />
2
+
3
+ // See https://github.com/nodejs/undici/issues/1740
4
+
5
+ export interface EventInit {
6
+ bubbles?: boolean
7
+ cancelable?: boolean
8
+ composed?: boolean
9
+ }
10
+
11
+ export interface EventListenerOptions {
12
+ capture?: boolean
13
+ }
14
+
15
+ export interface AddEventListenerOptions extends EventListenerOptions {
16
+ once?: boolean
17
+ passive?: boolean
18
+ signal?: AbortSignal
19
+ }
20
+
21
+ export type EventListenerOrEventListenerObject = EventListener | EventListenerObject
22
+
23
+ export interface EventListenerObject {
24
+ handleEvent (object: Event): void
25
+ }
26
+
27
+ export interface EventListener {
28
+ (evt: Event): void
29
+ }
node_modules/undici-types/pool-stats.d.ts ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Pool from './pool'
2
+
3
+ export default PoolStats
4
+
5
+ declare class PoolStats {
6
+ constructor (pool: Pool)
7
+ /** Number of open socket connections in this pool. */
8
+ connected: number
9
+ /** Number of open socket connections in this pool that do not have an active request. */
10
+ free: number
11
+ /** Number of pending requests across all clients in this pool. */
12
+ pending: number
13
+ /** Number of queued requests across all clients in this pool. */
14
+ queued: number
15
+ /** Number of currently active requests across all clients in this pool. */
16
+ running: number
17
+ /** Number of active, pending, or queued requests across all clients in this pool. */
18
+ size: number
19
+ }
node_modules/undici-types/pool.d.ts ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Client from './client'
2
+ import TPoolStats from './pool-stats'
3
+ import { URL } from 'node:url'
4
+ import Dispatcher from './dispatcher'
5
+
6
+ export default Pool
7
+
8
+ type PoolConnectOptions = Omit<Dispatcher.ConnectOptions, 'origin'>
9
+
10
+ declare class Pool extends Dispatcher {
11
+ constructor (url: string | URL, options?: Pool.Options)
12
+ /** `true` after `pool.close()` has been called. */
13
+ closed: boolean
14
+ /** `true` after `pool.destroyed()` has been called or `pool.close()` has been called and the pool shutdown has completed. */
15
+ destroyed: boolean
16
+ /** Aggregate stats for a Pool. */
17
+ readonly stats: TPoolStats
18
+
19
+ // Override dispatcher APIs.
20
+ override connect (
21
+ options: PoolConnectOptions
22
+ ): Promise<Dispatcher.ConnectData>
23
+ override connect (
24
+ options: PoolConnectOptions,
25
+ callback: (err: Error | null, data: Dispatcher.ConnectData) => void
26
+ ): void
27
+ }
28
+
29
+ declare namespace Pool {
30
+ export type PoolStats = TPoolStats
31
+ export interface Options extends Client.Options {
32
+ /** Default: `(origin, opts) => new Client(origin, opts)`. */
33
+ factory?(origin: URL, opts: object): Dispatcher;
34
+ /** The max number of clients to create. `null` if no limit. Default `null`. */
35
+ connections?: number | null;
36
+ /** The amount of time before a client is removed from the pool and closed. `null` if no time limit. Default `null` */
37
+ clientTtl?: number | null;
38
+
39
+ interceptors?: { Pool?: readonly Dispatcher.DispatchInterceptor[] } & Client.Options['interceptors']
40
+ }
41
+ }
node_modules/undici-types/proxy-agent.d.ts ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Agent from './agent'
2
+ import buildConnector from './connector'
3
+ import Dispatcher from './dispatcher'
4
+ import { IncomingHttpHeaders } from './header'
5
+
6
+ export default ProxyAgent
7
+
8
+ declare class ProxyAgent extends Dispatcher {
9
+ constructor (options: ProxyAgent.Options | string)
10
+
11
+ dispatch (options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandler): boolean
12
+ close (): Promise<void>
13
+ }
14
+
15
+ declare namespace ProxyAgent {
16
+ export interface Options extends Agent.Options {
17
+ uri: string;
18
+ /**
19
+ * @deprecated use opts.token
20
+ */
21
+ auth?: string;
22
+ token?: string;
23
+ headers?: IncomingHttpHeaders;
24
+ requestTls?: buildConnector.BuildOptions;
25
+ proxyTls?: buildConnector.BuildOptions;
26
+ clientFactory?(origin: URL, opts: object): Dispatcher;
27
+ proxyTunnel?: boolean;
28
+ }
29
+ }
node_modules/undici-types/readable.d.ts ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { Readable } from 'node:stream'
2
+ import { Blob } from 'node:buffer'
3
+
4
+ export default BodyReadable
5
+
6
+ declare class BodyReadable extends Readable {
7
+ constructor (opts: {
8
+ resume: (this: Readable, size: number) => void | null;
9
+ abort: () => void | null;
10
+ contentType?: string;
11
+ contentLength?: number;
12
+ highWaterMark?: number;
13
+ })
14
+
15
+ /** Consumes and returns the body as a string
16
+ * https://fetch.spec.whatwg.org/#dom-body-text
17
+ */
18
+ text (): Promise<string>
19
+
20
+ /** Consumes and returns the body as a JavaScript Object
21
+ * https://fetch.spec.whatwg.org/#dom-body-json
22
+ */
23
+ json (): Promise<unknown>
24
+
25
+ /** Consumes and returns the body as a Blob
26
+ * https://fetch.spec.whatwg.org/#dom-body-blob
27
+ */
28
+ blob (): Promise<Blob>
29
+
30
+ /** Consumes and returns the body as an Uint8Array
31
+ * https://fetch.spec.whatwg.org/#dom-body-bytes
32
+ */
33
+ bytes (): Promise<Uint8Array>
34
+
35
+ /** Consumes and returns the body as an ArrayBuffer
36
+ * https://fetch.spec.whatwg.org/#dom-body-arraybuffer
37
+ */
38
+ arrayBuffer (): Promise<ArrayBuffer>
39
+
40
+ /** Not implemented
41
+ *
42
+ * https://fetch.spec.whatwg.org/#dom-body-formdata
43
+ */
44
+ formData (): Promise<never>
45
+
46
+ /** Returns true if the body is not null and the body has been consumed
47
+ *
48
+ * Otherwise, returns false
49
+ *
50
+ * https://fetch.spec.whatwg.org/#dom-body-bodyused
51
+ */
52
+ readonly bodyUsed: boolean
53
+
54
+ /**
55
+ * If body is null, it should return null as the body
56
+ *
57
+ * If body is not null, should return the body as a ReadableStream
58
+ *
59
+ * https://fetch.spec.whatwg.org/#dom-body-body
60
+ */
61
+ readonly body: never | undefined
62
+
63
+ /** Dumps the response body by reading `limit` number of bytes.
64
+ * @param opts.limit Number of bytes to read (optional) - Default: 131072
65
+ * @param opts.signal AbortSignal to cancel the operation (optional)
66
+ */
67
+ dump (opts?: { limit: number; signal?: AbortSignal }): Promise<void>
68
+ }
node_modules/undici-types/retry-agent.d.ts ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ import Dispatcher from './dispatcher'
2
+ import RetryHandler from './retry-handler'
3
+
4
+ export default RetryAgent
5
+
6
+ declare class RetryAgent extends Dispatcher {
7
+ constructor (dispatcher: Dispatcher, options?: RetryHandler.RetryOptions)
8
+ }
node_modules/undici-types/retry-handler.d.ts ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Dispatcher from './dispatcher'
2
+
3
+ export default RetryHandler
4
+
5
+ declare class RetryHandler implements Dispatcher.DispatchHandler {
6
+ constructor (
7
+ options: Dispatcher.DispatchOptions & {
8
+ retryOptions?: RetryHandler.RetryOptions;
9
+ },
10
+ retryHandlers: RetryHandler.RetryHandlers
11
+ )
12
+ }
13
+
14
+ declare namespace RetryHandler {
15
+ export type RetryState = { counter: number; }
16
+
17
+ export type RetryContext = {
18
+ state: RetryState;
19
+ opts: Dispatcher.DispatchOptions & {
20
+ retryOptions?: RetryHandler.RetryOptions;
21
+ };
22
+ }
23
+
24
+ export type OnRetryCallback = (result?: Error | null) => void
25
+
26
+ export type RetryCallback = (
27
+ err: Error,
28
+ context: {
29
+ state: RetryState;
30
+ opts: Dispatcher.DispatchOptions & {
31
+ retryOptions?: RetryHandler.RetryOptions;
32
+ };
33
+ },
34
+ callback: OnRetryCallback
35
+ ) => void
36
+
37
+ export interface RetryOptions {
38
+ /**
39
+ * If true, the retry handler will throw an error if the request fails,
40
+ * this will prevent the folling handlers from being called, and will destroy the socket.
41
+ *
42
+ * @type {boolean}
43
+ * @memberof RetryOptions
44
+ * @default true
45
+ */
46
+ throwOnError?: boolean;
47
+ /**
48
+ * Callback to be invoked on every retry iteration.
49
+ * It receives the error, current state of the retry object and the options object
50
+ * passed when instantiating the retry handler.
51
+ *
52
+ * @type {RetryCallback}
53
+ * @memberof RetryOptions
54
+ */
55
+ retry?: RetryCallback;
56
+ /**
57
+ * Maximum number of retries to allow.
58
+ *
59
+ * @type {number}
60
+ * @memberof RetryOptions
61
+ * @default 5
62
+ */
63
+ maxRetries?: number;
64
+ /**
65
+ * Max number of milliseconds allow between retries
66
+ *
67
+ * @type {number}
68
+ * @memberof RetryOptions
69
+ * @default 30000
70
+ */
71
+ maxTimeout?: number;
72
+ /**
73
+ * Initial number of milliseconds to wait before retrying for the first time.
74
+ *
75
+ * @type {number}
76
+ * @memberof RetryOptions
77
+ * @default 500
78
+ */
79
+ minTimeout?: number;
80
+ /**
81
+ * Factior to multiply the timeout factor between retries.
82
+ *
83
+ * @type {number}
84
+ * @memberof RetryOptions
85
+ * @default 2
86
+ */
87
+ timeoutFactor?: number;
88
+ /**
89
+ * It enables to automatically infer timeout between retries based on the `Retry-After` header.
90
+ *
91
+ * @type {boolean}
92
+ * @memberof RetryOptions
93
+ * @default true
94
+ */
95
+ retryAfter?: boolean;
96
+ /**
97
+ * HTTP methods to retry.
98
+ *
99
+ * @type {Dispatcher.HttpMethod[]}
100
+ * @memberof RetryOptions
101
+ * @default ['GET', 'HEAD', 'OPTIONS', 'PUT', 'DELETE', 'TRACE'],
102
+ */
103
+ methods?: Dispatcher.HttpMethod[];
104
+ /**
105
+ * Error codes to be retried. e.g. `ECONNRESET`, `ENOTFOUND`, `ETIMEDOUT`, `ECONNREFUSED`, etc.
106
+ *
107
+ * @type {string[]}
108
+ * @default ['ECONNRESET','ECONNREFUSED','ENOTFOUND','ENETDOWN','ENETUNREACH','EHOSTDOWN','EHOSTUNREACH','EPIPE']
109
+ */
110
+ errorCodes?: string[];
111
+ /**
112
+ * HTTP status codes to be retried.
113
+ *
114
+ * @type {number[]}
115
+ * @memberof RetryOptions
116
+ * @default [500, 502, 503, 504, 429],
117
+ */
118
+ statusCodes?: number[];
119
+ }
120
+
121
+ export interface RetryHandlers {
122
+ dispatch: Dispatcher['dispatch'];
123
+ handler: Dispatcher.DispatchHandler;
124
+ }
125
+ }
node_modules/undici-types/round-robin-pool.d.ts ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Client from './client'
2
+ import TPoolStats from './pool-stats'
3
+ import { URL } from 'node:url'
4
+ import Dispatcher from './dispatcher'
5
+
6
+ export default RoundRobinPool
7
+
8
+ type RoundRobinPoolConnectOptions = Omit<Dispatcher.ConnectOptions, 'origin'>
9
+
10
+ declare class RoundRobinPool extends Dispatcher {
11
+ constructor (url: string | URL, options?: RoundRobinPool.Options)
12
+ /** `true` after `pool.close()` has been called. */
13
+ closed: boolean
14
+ /** `true` after `pool.destroyed()` has been called or `pool.close()` has been called and the pool shutdown has completed. */
15
+ destroyed: boolean
16
+ /** Aggregate stats for a RoundRobinPool. */
17
+ readonly stats: TPoolStats
18
+
19
+ // Override dispatcher APIs.
20
+ override connect (
21
+ options: RoundRobinPoolConnectOptions
22
+ ): Promise<Dispatcher.ConnectData>
23
+ override connect (
24
+ options: RoundRobinPoolConnectOptions,
25
+ callback: (err: Error | null, data: Dispatcher.ConnectData) => void
26
+ ): void
27
+ }
28
+
29
+ declare namespace RoundRobinPool {
30
+ export type RoundRobinPoolStats = TPoolStats
31
+ export interface Options extends Client.Options {
32
+ /** Default: `(origin, opts) => new Client(origin, opts)`. */
33
+ factory?(origin: URL, opts: object): Dispatcher;
34
+ /** The max number of clients to create. `null` if no limit. Default `null`. */
35
+ connections?: number | null;
36
+ /** The amount of time before a client is removed from the pool and closed. `null` if no time limit. Default `null` */
37
+ clientTtl?: number | null;
38
+
39
+ interceptors?: { RoundRobinPool?: readonly Dispatcher.DispatchInterceptor[] } & Client.Options['interceptors']
40
+ }
41
+ }
node_modules/undici-types/snapshot-agent.d.ts ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ type SnapshotRecorderMode = 'record' | 'playback' | 'update'
22
+
23
+ export interface Options {
24
+ snapshotPath?: string
25
+ mode?: SnapshotRecorderMode
26
+ maxSnapshots?: number
27
+ autoFlush?: boolean
28
+ flushInterval?: number
29
+ matchHeaders?: string[]
30
+ ignoreHeaders?: string[]
31
+ excludeHeaders?: string[]
32
+ matchBody?: boolean
33
+ matchQuery?: boolean
34
+ caseSensitive?: boolean
35
+ shouldRecord?: (requestOpts: any) => boolean
36
+ shouldPlayback?: (requestOpts: any) => boolean
37
+ excludeUrls?: (string | RegExp)[]
38
+ }
39
+
40
+ export interface Snapshot {
41
+ request: {
42
+ method: string
43
+ url: string
44
+ headers: Record<string, string>
45
+ body?: string
46
+ }
47
+ responses: {
48
+ statusCode: number
49
+ headers: Record<string, string>
50
+ body: string
51
+ trailers: Record<string, string>
52
+ }[]
53
+ callCount: number
54
+ timestamp: string
55
+ }
56
+
57
+ export interface SnapshotInfo {
58
+ hash: string
59
+ request: {
60
+ method: string
61
+ url: string
62
+ headers: Record<string, string>
63
+ body?: string
64
+ }
65
+ responseCount: number
66
+ callCount: number
67
+ timestamp: string
68
+ }
69
+
70
+ export interface SnapshotData {
71
+ hash: string
72
+ snapshot: Snapshot
73
+ }
74
+ }
75
+
76
+ declare class SnapshotAgent extends MockAgent {
77
+ constructor (options?: SnapshotAgent.Options)
78
+
79
+ saveSnapshots (filePath?: string): Promise<void>
80
+ loadSnapshots (filePath?: string): Promise<void>
81
+ getRecorder (): SnapshotRecorder
82
+ getMode (): SnapshotRecorder.SnapshotRecorderMode
83
+ clearSnapshots (): void
84
+ resetCallCounts (): void
85
+ deleteSnapshot (requestOpts: any): boolean
86
+ getSnapshotInfo (requestOpts: any): SnapshotRecorder.SnapshotInfo | null
87
+ replaceSnapshots (snapshotData: SnapshotRecorder.SnapshotData[]): void
88
+ }
89
+
90
+ declare namespace SnapshotAgent {
91
+ export interface Options extends MockAgent.Options {
92
+ mode?: SnapshotRecorder.SnapshotRecorderMode
93
+ snapshotPath?: string
94
+ maxSnapshots?: number
95
+ autoFlush?: boolean
96
+ flushInterval?: number
97
+ matchHeaders?: string[]
98
+ ignoreHeaders?: string[]
99
+ excludeHeaders?: string[]
100
+ matchBody?: boolean
101
+ matchQuery?: boolean
102
+ caseSensitive?: boolean
103
+ shouldRecord?: (requestOpts: any) => boolean
104
+ shouldPlayback?: (requestOpts: any) => boolean
105
+ excludeUrls?: (string | RegExp)[]
106
+ }
107
+ }
108
+
109
+ export { SnapshotAgent, SnapshotRecorder }
node_modules/undici-types/socks5-proxy-agent.d.ts ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Dispatcher from './dispatcher'
2
+ import buildConnector from './connector'
3
+ import { IncomingHttpHeaders } from './header'
4
+ import Pool from './pool'
5
+
6
+ export default Socks5ProxyAgent
7
+
8
+ declare class Socks5ProxyAgent extends Dispatcher {
9
+ constructor (proxyUrl: string | URL, options?: Socks5ProxyAgent.Options)
10
+ }
11
+
12
+ declare namespace Socks5ProxyAgent {
13
+ export interface Options extends Pool.Options {
14
+ /** Additional headers to send with the proxy connection */
15
+ headers?: IncomingHttpHeaders;
16
+ /** SOCKS5 proxy username for authentication */
17
+ username?: string;
18
+ /** SOCKS5 proxy password for authentication */
19
+ password?: string;
20
+ /** Custom connector function for proxy connection */
21
+ connect?: buildConnector.connector;
22
+ /** TLS options for the proxy connection (for SOCKS5 over TLS) */
23
+ proxyTls?: buildConnector.BuildOptions;
24
+ }
25
+ }
node_modules/undici-types/util.d.ts ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export namespace util {
2
+ /**
3
+ * Retrieves a header name and returns its lowercase value.
4
+ * @param value Header name
5
+ */
6
+ export function headerNameToString (value: string | Buffer): string
7
+
8
+ /**
9
+ * Receives a header object and returns the parsed value.
10
+ * @param headers Header object
11
+ * @param obj Object to specify a proxy object. Used to assign parsed values.
12
+ * @returns If `obj` is specified, it is equivalent to `obj`.
13
+ */
14
+ export function parseHeaders (
15
+ headers: (Buffer | string | (Buffer | string)[])[],
16
+ obj?: Record<string, string | string[]>
17
+ ): Record<string, string | string[]>
18
+ }
node_modules/undici-types/utility.d.ts ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ type AutocompletePrimitiveBaseType<T> =
2
+ T extends string ? string :
3
+ T extends number ? number :
4
+ T extends boolean ? boolean :
5
+ never
6
+
7
+ export type Autocomplete<T> = T | (AutocompletePrimitiveBaseType<T> & Record<never, never>)
node_modules/undici-types/webidl.d.ts ADDED
@@ -0,0 +1,347 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // These types are not exported, and are only used internally
2
+ import { BufferSource } from 'node:stream/web'
3
+ import * as undici from './index'
4
+
5
+ /**
6
+ * Take in an unknown value and return one that is of type T
7
+ */
8
+ type Converter<T> = (object: unknown) => T
9
+
10
+ type SequenceConverter<T> = (object: unknown, iterable?: IterableIterator<T>) => T[]
11
+
12
+ type RecordConverter<K extends string, V> = (object: unknown) => Record<K, V>
13
+
14
+ interface WebidlErrors {
15
+ /**
16
+ * @description Instantiate an error
17
+ */
18
+ exception (opts: { header: string, message: string }): TypeError
19
+ /**
20
+ * @description Instantiate an error when conversion from one type to another has failed
21
+ */
22
+ conversionFailed (opts: {
23
+ prefix: string
24
+ argument: string
25
+ types: string[]
26
+ }): TypeError
27
+ /**
28
+ * @description Throw an error when an invalid argument is provided
29
+ */
30
+ invalidArgument (opts: {
31
+ prefix: string
32
+ value: string
33
+ type: string
34
+ }): TypeError
35
+ }
36
+
37
+ interface WebIDLTypes {
38
+ UNDEFINED: 1,
39
+ BOOLEAN: 2,
40
+ STRING: 3,
41
+ SYMBOL: 4,
42
+ NUMBER: 5,
43
+ BIGINT: 6,
44
+ NULL: 7
45
+ OBJECT: 8
46
+ }
47
+
48
+ interface WebidlUtil {
49
+ /**
50
+ * @see https://tc39.es/ecma262/#sec-ecmascript-data-types-and-values
51
+ */
52
+ Type (object: unknown): WebIDLTypes[keyof WebIDLTypes]
53
+
54
+ TypeValueToString (o: unknown):
55
+ | 'Undefined'
56
+ | 'Boolean'
57
+ | 'String'
58
+ | 'Symbol'
59
+ | 'Number'
60
+ | 'BigInt'
61
+ | 'Null'
62
+ | 'Object'
63
+
64
+ Types: WebIDLTypes
65
+
66
+ /**
67
+ * @see https://webidl.spec.whatwg.org/#abstract-opdef-converttoint
68
+ */
69
+ ConvertToInt (
70
+ V: unknown,
71
+ bitLength: number,
72
+ signedness: 'signed' | 'unsigned',
73
+ flags?: number
74
+ ): number
75
+
76
+ /**
77
+ * @see https://webidl.spec.whatwg.org/#abstract-opdef-integerpart
78
+ */
79
+ IntegerPart (N: number): number
80
+
81
+ /**
82
+ * Stringifies {@param V}
83
+ */
84
+ Stringify (V: any): string
85
+
86
+ MakeTypeAssertion <I>(I: I): (arg: any) => arg is I
87
+
88
+ /**
89
+ * Mark a value as uncloneable for Node.js.
90
+ * This is only effective in some newer Node.js versions.
91
+ */
92
+ markAsUncloneable (V: any): void
93
+
94
+ IsResizableArrayBuffer (V: ArrayBufferLike): boolean
95
+
96
+ HasFlag (flag: number, attributes: number): boolean
97
+
98
+ /**
99
+ * @see https://webidl.spec.whatwg.org/#dfn-get-buffer-source-copy
100
+ */
101
+ getCopyOfBytesHeldByBufferSource (bufferSource: BufferSource): Uint8Array
102
+ }
103
+
104
+ interface WebidlConverters {
105
+ /**
106
+ * @see https://webidl.spec.whatwg.org/#es-DOMString
107
+ */
108
+ DOMString (V: unknown, prefix: string, argument: string, flags?: number): string
109
+
110
+ /**
111
+ * @see https://webidl.spec.whatwg.org/#es-ByteString
112
+ */
113
+ ByteString (V: unknown, prefix: string, argument: string): string
114
+
115
+ /**
116
+ * @see https://webidl.spec.whatwg.org/#es-USVString
117
+ */
118
+ USVString (V: unknown): string
119
+
120
+ /**
121
+ * @see https://webidl.spec.whatwg.org/#es-boolean
122
+ */
123
+ boolean (V: unknown): boolean
124
+
125
+ /**
126
+ * @see https://webidl.spec.whatwg.org/#es-any
127
+ */
128
+ any <Value>(V: Value): Value
129
+
130
+ /**
131
+ * @see https://webidl.spec.whatwg.org/#es-long-long
132
+ */
133
+ ['long long'] (V: unknown): number
134
+
135
+ /**
136
+ * @see https://webidl.spec.whatwg.org/#es-unsigned-long-long
137
+ */
138
+ ['unsigned long long'] (V: unknown): number
139
+
140
+ /**
141
+ * @see https://webidl.spec.whatwg.org/#es-unsigned-long
142
+ */
143
+ ['unsigned long'] (V: unknown): number
144
+
145
+ /**
146
+ * @see https://webidl.spec.whatwg.org/#es-unsigned-short
147
+ */
148
+ ['unsigned short'] (V: unknown, flags?: number): number
149
+
150
+ /**
151
+ * @see https://webidl.spec.whatwg.org/#idl-ArrayBuffer
152
+ */
153
+ ArrayBuffer (
154
+ V: unknown,
155
+ prefix: string,
156
+ argument: string,
157
+ options?: { allowResizable: boolean }
158
+ ): ArrayBuffer
159
+
160
+ /**
161
+ * @see https://webidl.spec.whatwg.org/#idl-SharedArrayBuffer
162
+ */
163
+ SharedArrayBuffer (
164
+ V: unknown,
165
+ prefix: string,
166
+ argument: string,
167
+ options?: { allowResizable: boolean }
168
+ ): SharedArrayBuffer
169
+
170
+ /**
171
+ * @see https://webidl.spec.whatwg.org/#es-buffer-source-types
172
+ */
173
+ TypedArray (
174
+ V: unknown,
175
+ T: new () => NodeJS.TypedArray,
176
+ prefix: string,
177
+ argument: string,
178
+ flags?: number
179
+ ): NodeJS.TypedArray
180
+
181
+ /**
182
+ * @see https://webidl.spec.whatwg.org/#es-buffer-source-types
183
+ */
184
+ DataView (
185
+ V: unknown,
186
+ prefix: string,
187
+ argument: string,
188
+ flags?: number
189
+ ): DataView
190
+
191
+ /**
192
+ * @see https://webidl.spec.whatwg.org/#es-buffer-source-types
193
+ */
194
+ ArrayBufferView (
195
+ V: unknown,
196
+ prefix: string,
197
+ argument: string,
198
+ flags?: number
199
+ ): NodeJS.ArrayBufferView
200
+
201
+ /**
202
+ * @see https://webidl.spec.whatwg.org/#BufferSource
203
+ */
204
+ BufferSource (
205
+ V: unknown,
206
+ prefix: string,
207
+ argument: string,
208
+ flags?: number
209
+ ): ArrayBuffer | NodeJS.ArrayBufferView
210
+
211
+ /**
212
+ * @see https://webidl.spec.whatwg.org/#AllowSharedBufferSource
213
+ */
214
+ AllowSharedBufferSource (
215
+ V: unknown,
216
+ prefix: string,
217
+ argument: string,
218
+ flags?: number
219
+ ): ArrayBuffer | SharedArrayBuffer | NodeJS.ArrayBufferView
220
+
221
+ ['sequence<ByteString>']: SequenceConverter<string>
222
+
223
+ ['sequence<sequence<ByteString>>']: SequenceConverter<string[]>
224
+
225
+ ['record<ByteString, ByteString>']: RecordConverter<string, string>
226
+
227
+ /**
228
+ * @see https://fetch.spec.whatwg.org/#requestinfo
229
+ */
230
+ RequestInfo (V: unknown): undici.Request | string
231
+
232
+ /**
233
+ * @see https://fetch.spec.whatwg.org/#requestinit
234
+ */
235
+ RequestInit (V: unknown): undici.RequestInit
236
+
237
+ /**
238
+ * @see https://html.spec.whatwg.org/multipage/webappapis.html#eventhandlernonnull
239
+ */
240
+ EventHandlerNonNull (V: unknown): Function | null
241
+
242
+ WebSocketStreamWrite (V: unknown): ArrayBuffer | NodeJS.TypedArray | string
243
+
244
+ [Key: string]: (...args: any[]) => unknown
245
+ }
246
+
247
+ type WebidlIsFunction<T> = (arg: any) => arg is T
248
+
249
+ interface WebidlIs {
250
+ Request: WebidlIsFunction<undici.Request>
251
+ Response: WebidlIsFunction<undici.Response>
252
+ ReadableStream: WebidlIsFunction<ReadableStream>
253
+ Blob: WebidlIsFunction<Blob>
254
+ URLSearchParams: WebidlIsFunction<URLSearchParams>
255
+ File: WebidlIsFunction<File>
256
+ FormData: WebidlIsFunction<undici.FormData>
257
+ URL: WebidlIsFunction<URL>
258
+ WebSocketError: WebidlIsFunction<undici.WebSocketError>
259
+ AbortSignal: WebidlIsFunction<AbortSignal>
260
+ MessagePort: WebidlIsFunction<MessagePort>
261
+ USVString: WebidlIsFunction<string>
262
+ /**
263
+ * @see https://webidl.spec.whatwg.org/#BufferSource
264
+ */
265
+ BufferSource: WebidlIsFunction<ArrayBuffer | NodeJS.TypedArray>
266
+ }
267
+
268
+ export interface Webidl {
269
+ errors: WebidlErrors
270
+ util: WebidlUtil
271
+ converters: WebidlConverters
272
+ is: WebidlIs
273
+ attributes: WebIDLExtendedAttributes
274
+
275
+ /**
276
+ * @description Performs a brand-check on {@param V} to ensure it is a
277
+ * {@param cls} object.
278
+ */
279
+ brandCheck <Interface extends new () => unknown>(V: unknown, cls: Interface): asserts V is Interface
280
+
281
+ brandCheckMultiple <Interfaces extends (new () => unknown)[]> (list: Interfaces): (V: any) => asserts V is Interfaces[number]
282
+
283
+ /**
284
+ * @see https://webidl.spec.whatwg.org/#es-sequence
285
+ * @description Convert a value, V, to a WebIDL sequence type.
286
+ */
287
+ sequenceConverter <Type>(C: Converter<Type>): SequenceConverter<Type>
288
+
289
+ illegalConstructor (): never
290
+
291
+ /**
292
+ * @see https://webidl.spec.whatwg.org/#es-to-record
293
+ * @description Convert a value, V, to a WebIDL record type.
294
+ */
295
+ recordConverter <K extends string, V>(
296
+ keyConverter: Converter<K>,
297
+ valueConverter: Converter<V>
298
+ ): RecordConverter<K, V>
299
+
300
+ /**
301
+ * Similar to {@link Webidl.brandCheck} but allows skipping the check if third party
302
+ * interfaces are allowed.
303
+ */
304
+ interfaceConverter <Interface>(typeCheck: WebidlIsFunction<Interface>, name: string): (
305
+ V: unknown,
306
+ prefix: string,
307
+ argument: string
308
+ ) => asserts V is Interface
309
+
310
+ // TODO(@KhafraDev): a type could likely be implemented that can infer the return type
311
+ // from the converters given?
312
+ /**
313
+ * Converts a value, V, to a WebIDL dictionary types. Allows limiting which keys are
314
+ * allowed, values allowed, optional and required keys. Auto converts the value to
315
+ * a type given a converter.
316
+ */
317
+ dictionaryConverter (converters: {
318
+ key: string,
319
+ defaultValue?: () => unknown,
320
+ required?: boolean,
321
+ converter: (...args: unknown[]) => unknown,
322
+ allowedValues?: unknown[]
323
+ }[]): (V: unknown) => Record<string, unknown>
324
+
325
+ /**
326
+ * @see https://webidl.spec.whatwg.org/#idl-nullable-type
327
+ * @description allows a type, V, to be null
328
+ */
329
+ nullableConverter <T>(
330
+ converter: Converter<T>
331
+ ): (V: unknown) => ReturnType<typeof converter> | null
332
+
333
+ argumentLengthCheck (args: { length: number }, min: number, context: string): void
334
+ }
335
+
336
+ interface WebIDLExtendedAttributes {
337
+ /** https://webidl.spec.whatwg.org/#Clamp */
338
+ Clamp: number
339
+ /** https://webidl.spec.whatwg.org/#EnforceRange */
340
+ EnforceRange: number
341
+ /** https://webidl.spec.whatwg.org/#AllowShared */
342
+ AllowShared: number
343
+ /** https://webidl.spec.whatwg.org/#AllowResizable */
344
+ AllowResizable: number
345
+ /** https://webidl.spec.whatwg.org/#LegacyNullToEmptyString */
346
+ LegacyNullToEmptyString: number
347
+ }
node_modules/undici-types/websocket.d.ts ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /// <reference types="node" />
2
+
3
+ import type { Blob } from 'node:buffer'
4
+ import type { ReadableStream, WritableStream } from 'node:stream/web'
5
+ import type { MessagePort } from 'node:worker_threads'
6
+ import {
7
+ EventInit,
8
+ EventListenerOptions,
9
+ AddEventListenerOptions,
10
+ EventListenerOrEventListenerObject
11
+ } from './patch'
12
+ import Dispatcher from './dispatcher'
13
+ import { HeadersInit } from './fetch'
14
+
15
+ export type BinaryType = 'blob' | 'arraybuffer'
16
+
17
+ interface WebSocketEventMap {
18
+ close: CloseEvent
19
+ error: ErrorEvent
20
+ message: MessageEvent
21
+ open: Event
22
+ }
23
+
24
+ interface WebSocket extends EventTarget {
25
+ binaryType: BinaryType
26
+
27
+ readonly bufferedAmount: number
28
+ readonly extensions: string
29
+
30
+ onclose: ((this: WebSocket, ev: WebSocketEventMap['close']) => any) | null
31
+ onerror: ((this: WebSocket, ev: WebSocketEventMap['error']) => any) | null
32
+ onmessage: ((this: WebSocket, ev: WebSocketEventMap['message']) => any) | null
33
+ onopen: ((this: WebSocket, ev: WebSocketEventMap['open']) => any) | null
34
+
35
+ readonly protocol: string
36
+ readonly readyState: number
37
+ readonly url: string
38
+
39
+ close(code?: number, reason?: string): void
40
+ send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void
41
+
42
+ readonly CLOSED: number
43
+ readonly CLOSING: number
44
+ readonly CONNECTING: number
45
+ readonly OPEN: number
46
+
47
+ addEventListener<K extends keyof WebSocketEventMap>(
48
+ type: K,
49
+ listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any,
50
+ options?: boolean | AddEventListenerOptions
51
+ ): void
52
+ addEventListener(
53
+ type: string,
54
+ listener: EventListenerOrEventListenerObject,
55
+ options?: boolean | AddEventListenerOptions
56
+ ): void
57
+ removeEventListener<K extends keyof WebSocketEventMap>(
58
+ type: K,
59
+ listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any,
60
+ options?: boolean | EventListenerOptions
61
+ ): void
62
+ removeEventListener(
63
+ type: string,
64
+ listener: EventListenerOrEventListenerObject,
65
+ options?: boolean | EventListenerOptions
66
+ ): void
67
+ }
68
+
69
+ export declare const WebSocket: {
70
+ prototype: WebSocket
71
+ new (url: string | URL, protocols?: string | string[] | WebSocketInit): WebSocket
72
+ readonly CLOSED: number
73
+ readonly CLOSING: number
74
+ readonly CONNECTING: number
75
+ readonly OPEN: number
76
+ }
77
+
78
+ interface CloseEventInit extends EventInit {
79
+ code?: number
80
+ reason?: string
81
+ wasClean?: boolean
82
+ }
83
+
84
+ interface CloseEvent extends Event {
85
+ readonly code: number
86
+ readonly reason: string
87
+ readonly wasClean: boolean
88
+ }
89
+
90
+ export declare const CloseEvent: {
91
+ prototype: CloseEvent
92
+ new (type: string, eventInitDict?: CloseEventInit): CloseEvent
93
+ }
94
+
95
+ interface MessageEventInit<T = any> extends EventInit {
96
+ data?: T
97
+ lastEventId?: string
98
+ origin?: string
99
+ ports?: MessagePort[]
100
+ source?: MessagePort | null
101
+ }
102
+
103
+ interface MessageEvent<T = any> extends Event {
104
+ readonly data: T
105
+ readonly lastEventId: string
106
+ readonly origin: string
107
+ readonly ports: readonly MessagePort[]
108
+ readonly source: MessagePort | null
109
+ initMessageEvent(
110
+ type: string,
111
+ bubbles?: boolean,
112
+ cancelable?: boolean,
113
+ data?: any,
114
+ origin?: string,
115
+ lastEventId?: string,
116
+ source?: MessagePort | null,
117
+ ports?: MessagePort[]
118
+ ): void;
119
+ }
120
+
121
+ export declare const MessageEvent: {
122
+ prototype: MessageEvent
123
+ new<T>(type: string, eventInitDict?: MessageEventInit<T>): MessageEvent<T>
124
+ }
125
+
126
+ interface ErrorEventInit extends EventInit {
127
+ message?: string
128
+ filename?: string
129
+ lineno?: number
130
+ colno?: number
131
+ error?: any
132
+ }
133
+
134
+ interface ErrorEvent extends Event {
135
+ readonly message: string
136
+ readonly filename: string
137
+ readonly lineno: number
138
+ readonly colno: number
139
+ readonly error: Error
140
+ }
141
+
142
+ export declare const ErrorEvent: {
143
+ prototype: ErrorEvent
144
+ new (type: string, eventInitDict?: ErrorEventInit): ErrorEvent
145
+ }
146
+
147
+ interface WebSocketInit {
148
+ protocols?: string | string[],
149
+ dispatcher?: Dispatcher,
150
+ headers?: HeadersInit
151
+ }
152
+
153
+ interface WebSocketStreamOptions {
154
+ protocols?: string | string[]
155
+ signal?: AbortSignal
156
+ }
157
+
158
+ interface WebSocketCloseInfo {
159
+ closeCode: number
160
+ reason: string
161
+ }
162
+
163
+ interface WebSocketStream {
164
+ closed: Promise<WebSocketCloseInfo>
165
+ opened: Promise<{
166
+ extensions: string
167
+ protocol: string
168
+ readable: ReadableStream
169
+ writable: WritableStream
170
+ }>
171
+ url: string
172
+
173
+ close(options?: Partial<WebSocketCloseInfo>): void
174
+ }
175
+
176
+ export declare const WebSocketStream: {
177
+ prototype: WebSocketStream
178
+ new (url: string | URL, options?: WebSocketStreamOptions): WebSocketStream
179
+ }
180
+
181
+ interface WebSocketError extends Event, WebSocketCloseInfo {}
182
+
183
+ export declare const WebSocketError: {
184
+ prototype: WebSocketError
185
+ new (type: string, init?: WebSocketCloseInfo): WebSocketError
186
+ }
187
+
188
+ export declare const ping: (ws: WebSocket, body?: Buffer) => void
node_modules/undici/docs/docs/best-practices/undici-vs-builtin-fetch.md ADDED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Undici Module vs. Node.js Built-in Fetch
2
+
3
+ Node.js has shipped a built-in `fetch()` implementation powered by undici since
4
+ Node.js v18. This guide explains the relationship between the `undici` npm
5
+ package and the built-in `fetch`, and when you should install one versus relying
6
+ on the other.
7
+
8
+ ## Background
9
+
10
+ The `fetch()`, `Request`, `Response`, `Headers`, and `FormData` globals in
11
+ Node.js v18+ are provided by a version of undici that is bundled into Node.js
12
+ itself. You can check which version is bundled with:
13
+
14
+ ```js
15
+ console.log(process.versions.undici); // e.g., "7.5.0"
16
+ ```
17
+
18
+ When you install undici from npm, you get the full library with all of its
19
+ additional APIs, and potentially a newer release than what your Node.js version
20
+ bundles.
21
+
22
+ ## Keep `fetch` and `FormData` from the same implementation
23
+
24
+ When you send a `FormData` body, keep `fetch` and `FormData` together from the
25
+ same implementation.
26
+
27
+ Use one of these patterns:
28
+
29
+ ### Built-in globals
30
+
31
+ ```js
32
+ const body = new FormData()
33
+ body.set('name', 'some')
34
+ body.set('someOtherProperty', '8000')
35
+
36
+ await fetch('https://example.com', {
37
+ method: 'POST',
38
+ body
39
+ })
40
+ ```
41
+
42
+ ### `undici` module imports
43
+
44
+ ```js
45
+ import { fetch, FormData } from 'undici'
46
+
47
+ const body = new FormData()
48
+ body.set('name', 'some')
49
+ body.set('someOtherProperty', '8000')
50
+
51
+ await fetch('https://example.com', {
52
+ method: 'POST',
53
+ body
54
+ })
55
+ ```
56
+
57
+ ### `undici.install()` globals
58
+
59
+ If you want the installed `undici` package to provide the globals, call
60
+ [`install()`](/docs/api/GlobalInstallation.md):
61
+
62
+ ```js
63
+ import { install } from 'undici'
64
+
65
+ install()
66
+
67
+ const body = new FormData()
68
+ body.set('name', 'some')
69
+ body.set('someOtherProperty', '8000')
70
+
71
+ await fetch('https://example.com', {
72
+ method: 'POST',
73
+ body
74
+ })
75
+ ```
76
+
77
+ `install()` replaces the global `fetch`, `Headers`, `Response`, `Request`, and
78
+ `FormData` implementations with undici's versions, and also installs undici's
79
+ `WebSocket`, `CloseEvent`, `ErrorEvent`, `MessageEvent`, and `EventSource`
80
+ globals.
81
+
82
+ Avoid mixing implementations in the same request, for example:
83
+
84
+ ```js
85
+ import { fetch } from 'undici'
86
+
87
+ const body = new FormData()
88
+
89
+ await fetch('https://example.com', {
90
+ method: 'POST',
91
+ body
92
+ })
93
+ ```
94
+
95
+ ```js
96
+ import { FormData } from 'undici'
97
+
98
+ const body = new FormData()
99
+
100
+ await fetch('https://example.com', {
101
+ method: 'POST',
102
+ body
103
+ })
104
+ ```
105
+
106
+ Those combinations may behave differently across Node.js and undici versions.
107
+ Using matching pairs keeps multipart handling predictable.
108
+
109
+ ## When you do NOT need to install undici
110
+
111
+ If all of the following are true, you can rely on the built-in globals and skip
112
+ adding undici to your dependencies:
113
+
114
+ - You only need the standard Fetch API (`fetch`, `Request`, `Response`,
115
+ `Headers`, `FormData`).
116
+ - You are running Node.js v18 or later.
117
+ - You do not depend on features or bug fixes introduced in a version of undici
118
+ newer than the one bundled with your Node.js release.
119
+ - You want zero additional runtime dependencies.
120
+ - You want cross-platform interoperability with browsers and other runtimes
121
+ (Deno, Bun, Cloudflare Workers, etc.) using the same Fetch API surface.
122
+
123
+ This is common in applications that make straightforward HTTP requests or in
124
+ libraries that target multiple JavaScript runtimes.
125
+
126
+ ## When you SHOULD install undici
127
+
128
+ Install undici from npm when you need capabilities beyond the standard Fetch API:
129
+
130
+ ### Advanced HTTP APIs
131
+
132
+ undici exposes `request`, `stream`, `pipeline`, and `connect` methods that
133
+ provide lower-level control and significantly better performance than `fetch`:
134
+
135
+ ```js
136
+ import { request } from 'undici';
137
+
138
+ const { statusCode, headers, body } = await request('https://example.com');
139
+ const data = await body.json();
140
+ ```
141
+
142
+ ### Connection pooling and dispatchers
143
+
144
+ `Client`, `Pool`, `BalancedPool`, `Agent`, and their configuration options
145
+ let you manage connection lifecycle, keep-alive behavior, pipelining depth,
146
+ and concurrency limits:
147
+
148
+ ```js
149
+ import { Pool } from 'undici';
150
+
151
+ const pool = new Pool('https://example.com', { connections: 10 });
152
+ const { body } = await pool.request({ path: '/', method: 'GET' });
153
+ ```
154
+
155
+ ### Proxy support
156
+
157
+ `ProxyAgent` and `EnvHttpProxyAgent` handle HTTP(S) proxying. Note that
158
+ Node.js v22.21.0+ and v24.0.0+ support environment-variable-based proxy
159
+ configuration for the built-in `fetch` via the `--use-env-proxy` flag (or
160
+ `NODE_USE_ENV_PROXY=1`). However, undici's `ProxyAgent` still provides
161
+ programmatic control through the dispatcher API:
162
+
163
+ ```js
164
+ import { ProxyAgent, fetch } from 'undici';
165
+
166
+ const proxyAgent = new ProxyAgent('https://my-proxy.example.com:8080');
167
+ const response = await fetch('https://example.com', { dispatcher: proxyAgent });
168
+ ```
169
+
170
+ ### Testing and mocking
171
+
172
+ `MockAgent`, `MockClient`, and `MockPool` let you intercept and mock HTTP
173
+ requests without patching globals or depending on external libraries:
174
+
175
+ ```js
176
+ import { MockAgent, setGlobalDispatcher, fetch } from 'undici';
177
+
178
+ const mockAgent = new MockAgent();
179
+ setGlobalDispatcher(mockAgent);
180
+
181
+ const pool = mockAgent.get('https://example.com');
182
+ pool.intercept({ path: '/api' }).reply(200, { message: 'mocked' });
183
+ ```
184
+
185
+ ### Interceptors and middleware
186
+
187
+ Custom dispatchers and interceptors (retry, redirect, cache, DNS) give you
188
+ fine-grained control over how requests are processed.
189
+
190
+ ### Newer version than what Node.js bundles
191
+
192
+ The npm package often includes features, performance improvements, and bug fixes
193
+ that have not yet landed in a Node.js release. If you need a specific fix or
194
+ feature, you can install a newer version directly.
195
+
196
+ ## Version compatibility
197
+
198
+ | Node.js version | Bundled undici version | Notes |
199
+ |---|---|---|
200
+ | v18.x | ~5.x | `fetch` is experimental (behind `--experimental-fetch` in early v18) |
201
+ | v20.x | ~6.x | `fetch` is stable |
202
+ | v22.x | ~6.x / ~7.x | `fetch` is stable |
203
+ | v24.x | ~7.x | `fetch` is stable; env-proxy support via `--use-env-proxy` |
204
+
205
+ You can always check the exact bundled version at runtime with
206
+ `process.versions.undici`.
207
+
208
+ Installing undici from npm does not replace the built-in globals. If you want
209
+ your installed version to replace the global `fetch` and related classes, use
210
+ [`install()`](/docs/api/GlobalInstallation.md). Otherwise, import `fetch`
211
+ directly from `'undici'`:
212
+
213
+ ```js
214
+ import { fetch } from 'undici' // uses your installed version, not the built-in
215
+ ```
216
+
217
+ ## Further reading
218
+
219
+ - [API Reference: Fetch](/docs/api/Fetch.md)
220
+ - [API Reference: Client](/docs/api/Client.md)
221
+ - [API Reference: Pool](/docs/api/Pool.md)
222
+ - [API Reference: ProxyAgent](/docs/api/ProxyAgent.md)
223
+ - [API Reference: MockAgent](/docs/api/MockAgent.md)
224
+ - [API Reference: Global Installation](/docs/api/GlobalInstallation.md)
node_modules/undici/docs/docs/best-practices/writing-tests.md ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Writing tests
2
+
3
+ Undici is tuned for a production use case and its default will keep
4
+ a socket open for a few seconds after an HTTP request is completed to
5
+ remove the overhead of opening up a new socket. These settings that makes
6
+ Undici shine in production are not a good fit for using Undici in automated
7
+ tests, as it will result in longer execution times.
8
+
9
+ The following are good defaults that will keep the socket open for only 10ms:
10
+
11
+ ```js
12
+ import { request, setGlobalDispatcher, Agent } from 'undici'
13
+
14
+ const agent = new Agent({
15
+ keepAliveTimeout: 10, // milliseconds
16
+ keepAliveMaxTimeout: 10 // milliseconds
17
+ })
18
+
19
+ setGlobalDispatcher(agent)
20
+ ```
21
+
22
+ ## Guarding against unexpected disconnects
23
+
24
+ Undici's `Client` automatically reconnects after a socket error. This means
25
+ a test can silently disconnect, reconnect, and still pass. Unfortunately,
26
+ this could mask bugs like unexpected parser errors or protocol violations.
27
+ To catch these silent reconnections, add a disconnect guard after creating
28
+ a `Client`:
29
+
30
+ ```js
31
+ const { Client } = require('undici')
32
+ const { test, after } = require('node:test')
33
+ const { tspl } = require('@matteo.collina/tspl')
34
+
35
+ test('example with disconnect guard', async (t) => {
36
+ t = tspl(t, { plan: 1 })
37
+
38
+ const client = new Client('http://localhost:3000')
39
+ after(() => client.close())
40
+
41
+ client.on('disconnect', () => {
42
+ if (!client.closed && !client.destroyed) {
43
+ t.fail('unexpected disconnect')
44
+ }
45
+ })
46
+
47
+ // ... test logic ...
48
+ })
49
+ ```
50
+
51
+ `client.close()` and `client.destroy()` both emit `'disconnect'` events, but
52
+ those are expected. The guard only fails when a disconnect happens during the
53
+ active test (i.e., `!client.closed && !client.destroyed` is true).
54
+
55
+ Skip the guard for tests where a disconnect is expected behavior, such as:
56
+
57
+ - Signal aborts (`signal.emit('abort')`, `ac.abort()`)
58
+ - Server-side destruction (`res.destroy()`, `req.socket.destroy()`)
59
+ - Client-side body destruction mid-stream (`data.body.destroy()`)
60
+ - Timeout errors (`HeadersTimeoutError`, `BodyTimeoutError`)
61
+ - Successful upgrades (the socket is detached from the `Client`)
62
+ - Retry/reconnect tests where the disconnect triggers the retry
63
+ - HTTP parser errors from malformed responses (`HTTPParserError`)
node_modules/undici/index-fetch.js ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const { getGlobalDispatcher, setGlobalDispatcher } = require('./lib/global')
4
+ const EnvHttpProxyAgent = require('./lib/dispatcher/env-http-proxy-agent')
5
+ const fetchImpl = require('./lib/web/fetch').fetch
6
+
7
+ // Capture __filename at module load time for stack trace augmentation.
8
+ // This may be undefined when bundled in environments like Node.js internals.
9
+ const currentFilename = typeof __filename !== 'undefined' ? __filename : undefined
10
+
11
+ function appendFetchStackTrace (err, filename) {
12
+ if (!err || typeof err !== 'object') {
13
+ return
14
+ }
15
+
16
+ const stack = typeof err.stack === 'string' ? err.stack : ''
17
+ const normalizedFilename = filename.replace(/\\/g, '/')
18
+
19
+ if (stack && (stack.includes(filename) || stack.includes(normalizedFilename))) {
20
+ return
21
+ }
22
+
23
+ const capture = {}
24
+ Error.captureStackTrace(capture, appendFetchStackTrace)
25
+
26
+ if (!capture.stack) {
27
+ return
28
+ }
29
+
30
+ const captureLines = capture.stack.split('\n').slice(1).join('\n')
31
+
32
+ err.stack = stack ? `${stack}\n${captureLines}` : capture.stack
33
+ }
34
+
35
+ module.exports.fetch = function fetch (init, options = undefined) {
36
+ return fetchImpl(init, options).catch(err => {
37
+ if (currentFilename) {
38
+ appendFetchStackTrace(err, currentFilename)
39
+ } else if (err && typeof err === 'object') {
40
+ Error.captureStackTrace(err, module.exports.fetch)
41
+ }
42
+ throw err
43
+ })
44
+ }
45
+ module.exports.FormData = require('./lib/web/fetch/formdata').FormData
46
+ module.exports.Headers = require('./lib/web/fetch/headers').Headers
47
+ module.exports.Response = require('./lib/web/fetch/response').Response
48
+ module.exports.Request = require('./lib/web/fetch/request').Request
49
+
50
+ const { CloseEvent, ErrorEvent, MessageEvent, createFastMessageEvent } = require('./lib/web/websocket/events')
51
+ module.exports.WebSocket = require('./lib/web/websocket/websocket').WebSocket
52
+ module.exports.CloseEvent = CloseEvent
53
+ module.exports.ErrorEvent = ErrorEvent
54
+ module.exports.MessageEvent = MessageEvent
55
+ module.exports.createFastMessageEvent = createFastMessageEvent
56
+
57
+ module.exports.EventSource = require('./lib/web/eventsource/eventsource').EventSource
58
+
59
+ const api = require('./lib/api')
60
+ const Dispatcher = require('./lib/dispatcher/dispatcher')
61
+ Object.assign(Dispatcher.prototype, api)
62
+ // Expose the fetch implementation to be enabled in Node.js core via a flag
63
+ module.exports.EnvHttpProxyAgent = EnvHttpProxyAgent
64
+ module.exports.getGlobalDispatcher = getGlobalDispatcher
65
+ module.exports.setGlobalDispatcher = setGlobalDispatcher