undici-types 0.0.1 → 5.24.0-test.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/types/patch.d.ts DELETED
@@ -1,71 +0,0 @@
1
- /// <reference types="node" />
2
-
3
- // See https://github.com/nodejs/undici/issues/1740
4
-
5
- export type DOMException = typeof globalThis extends { DOMException: infer T }
6
- ? T
7
- : any
8
-
9
- export type EventTarget = typeof globalThis extends { EventTarget: infer T }
10
- ? T
11
- : {
12
- addEventListener(
13
- type: string,
14
- listener: any,
15
- options?: any,
16
- ): void
17
- dispatchEvent(event: Event): boolean
18
- removeEventListener(
19
- type: string,
20
- listener: any,
21
- options?: any | boolean,
22
- ): void
23
- }
24
-
25
- export type Event = typeof globalThis extends { Event: infer T }
26
- ? T
27
- : {
28
- readonly bubbles: boolean
29
- cancelBubble: () => void
30
- readonly cancelable: boolean
31
- readonly composed: boolean
32
- composedPath(): [EventTarget?]
33
- readonly currentTarget: EventTarget | null
34
- readonly defaultPrevented: boolean
35
- readonly eventPhase: 0 | 2
36
- readonly isTrusted: boolean
37
- preventDefault(): void
38
- returnValue: boolean
39
- readonly srcElement: EventTarget | null
40
- stopImmediatePropagation(): void
41
- stopPropagation(): void
42
- readonly target: EventTarget | null
43
- readonly timeStamp: number
44
- readonly type: string
45
- }
46
-
47
- export interface EventInit {
48
- bubbles?: boolean
49
- cancelable?: boolean
50
- composed?: boolean
51
- }
52
-
53
- export interface EventListenerOptions {
54
- capture?: boolean
55
- }
56
-
57
- export interface AddEventListenerOptions extends EventListenerOptions {
58
- once?: boolean
59
- passive?: boolean
60
- signal?: AbortSignal
61
- }
62
-
63
- export type EventListenerOrEventListenerObject = EventListener | EventListenerObject
64
-
65
- export interface EventListenerObject {
66
- handleEvent (object: Event): void
67
- }
68
-
69
- export interface EventListener {
70
- (evt: Event): void
71
- }
@@ -1,19 +0,0 @@
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
- }
package/types/pool.d.ts DELETED
@@ -1,28 +0,0 @@
1
- import Client from './client'
2
- import TPoolStats from './pool-stats'
3
- import { URL } from 'url'
4
- import Dispatcher from "./dispatcher";
5
-
6
- export default Pool
7
-
8
- declare class Pool extends Dispatcher {
9
- constructor(url: string | URL, options?: Pool.Options)
10
- /** `true` after `pool.close()` has been called. */
11
- closed: boolean;
12
- /** `true` after `pool.destroyed()` has been called or `pool.close()` has been called and the pool shutdown has completed. */
13
- destroyed: boolean;
14
- /** Aggregate stats for a Pool. */
15
- readonly stats: TPoolStats;
16
- }
17
-
18
- declare namespace Pool {
19
- export type PoolStats = TPoolStats;
20
- export interface Options extends Client.Options {
21
- /** Default: `(origin, opts) => new Client(origin, opts)`. */
22
- factory?(origin: URL, opts: object): Dispatcher;
23
- /** The max number of clients to create. `null` if no limit. Default `null`. */
24
- connections?: number | null;
25
-
26
- interceptors?: { Pool?: readonly Dispatcher.DispatchInterceptor[] } & Client.Options["interceptors"]
27
- }
28
- }
@@ -1,30 +0,0 @@
1
- import Agent from './agent'
2
- import buildConnector from './connector';
3
- import Client from './client'
4
- import Dispatcher from './dispatcher'
5
- import { IncomingHttpHeaders } from './header'
6
- import Pool from './pool'
7
-
8
- export default ProxyAgent
9
-
10
- declare class ProxyAgent extends Dispatcher {
11
- constructor(options: ProxyAgent.Options | string)
12
-
13
- dispatch(options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandlers): boolean;
14
- close(): Promise<void>;
15
- }
16
-
17
- declare namespace ProxyAgent {
18
- export interface Options extends Agent.Options {
19
- uri: string;
20
- /**
21
- * @deprecated use opts.token
22
- */
23
- auth?: string;
24
- token?: string;
25
- headers?: IncomingHttpHeaders;
26
- requestTls?: buildConnector.BuildOptions;
27
- proxyTls?: buildConnector.BuildOptions;
28
- clientFactory?(origin: URL, opts: object): Dispatcher;
29
- }
30
- }
@@ -1,61 +0,0 @@
1
- import { Readable } from "stream";
2
- import { Blob } from 'buffer'
3
-
4
- export default BodyReadable
5
-
6
- declare class BodyReadable extends Readable {
7
- constructor(
8
- resume?: (this: Readable, size: number) => void | null,
9
- abort?: () => void | null,
10
- contentType?: string
11
- )
12
-
13
- /** Consumes and returns the body as a string
14
- * https://fetch.spec.whatwg.org/#dom-body-text
15
- */
16
- text(): Promise<string>
17
-
18
- /** Consumes and returns the body as a JavaScript Object
19
- * https://fetch.spec.whatwg.org/#dom-body-json
20
- */
21
- json(): Promise<unknown>
22
-
23
- /** Consumes and returns the body as a Blob
24
- * https://fetch.spec.whatwg.org/#dom-body-blob
25
- */
26
- blob(): Promise<Blob>
27
-
28
- /** Consumes and returns the body as an ArrayBuffer
29
- * https://fetch.spec.whatwg.org/#dom-body-arraybuffer
30
- */
31
- arrayBuffer(): Promise<ArrayBuffer>
32
-
33
- /** Not implemented
34
- *
35
- * https://fetch.spec.whatwg.org/#dom-body-formdata
36
- */
37
- formData(): Promise<never>
38
-
39
- /** Returns true if the body is not null and the body has been consumed
40
- *
41
- * Otherwise, returns false
42
- *
43
- * https://fetch.spec.whatwg.org/#dom-body-bodyused
44
- */
45
- readonly bodyUsed: boolean
46
-
47
- /** Throws on node 16.6.0
48
- *
49
- * If body is null, it should return null as the body
50
- *
51
- * If body is not null, should return the body as a ReadableStream
52
- *
53
- * https://fetch.spec.whatwg.org/#dom-body-body
54
- */
55
- readonly body: never | undefined
56
-
57
- /** Dumps the response body by reading `limit` number of bytes.
58
- * @param opts.limit Number of bytes to read (optional) - Default: 262144
59
- */
60
- dump(opts?: { limit: number }): Promise<void>
61
- }
package/types/webidl.d.ts DELETED
@@ -1,220 +0,0 @@
1
- // These types are not exported, and are only used internally
2
-
3
- /**
4
- * Take in an unknown value and return one that is of type T
5
- */
6
- type Converter<T> = (object: unknown) => T
7
-
8
- type SequenceConverter<T> = (object: unknown) => T[]
9
-
10
- type RecordConverter<K extends string, V> = (object: unknown) => Record<K, V>
11
-
12
- interface ConvertToIntOpts {
13
- clamp?: boolean
14
- enforceRange?: boolean
15
- }
16
-
17
- interface WebidlErrors {
18
- exception (opts: { header: string, message: string }): TypeError
19
- /**
20
- * @description Throw 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 WebidlUtil {
38
- /**
39
- * @see https://tc39.es/ecma262/#sec-ecmascript-data-types-and-values
40
- */
41
- Type (object: unknown):
42
- | 'Undefined'
43
- | 'Boolean'
44
- | 'String'
45
- | 'Symbol'
46
- | 'Number'
47
- | 'BigInt'
48
- | 'Null'
49
- | 'Object'
50
-
51
- /**
52
- * @see https://webidl.spec.whatwg.org/#abstract-opdef-converttoint
53
- */
54
- ConvertToInt (
55
- V: unknown,
56
- bitLength: number,
57
- signedness: 'signed' | 'unsigned',
58
- opts?: ConvertToIntOpts
59
- ): number
60
-
61
- /**
62
- * @see https://webidl.spec.whatwg.org/#abstract-opdef-converttoint
63
- */
64
- IntegerPart (N: number): number
65
- }
66
-
67
- interface WebidlConverters {
68
- /**
69
- * @see https://webidl.spec.whatwg.org/#es-DOMString
70
- */
71
- DOMString (V: unknown, opts?: {
72
- legacyNullToEmptyString: boolean
73
- }): string
74
-
75
- /**
76
- * @see https://webidl.spec.whatwg.org/#es-ByteString
77
- */
78
- ByteString (V: unknown): string
79
-
80
- /**
81
- * @see https://webidl.spec.whatwg.org/#es-USVString
82
- */
83
- USVString (V: unknown): string
84
-
85
- /**
86
- * @see https://webidl.spec.whatwg.org/#es-boolean
87
- */
88
- boolean (V: unknown): boolean
89
-
90
- /**
91
- * @see https://webidl.spec.whatwg.org/#es-any
92
- */
93
- any <Value>(V: Value): Value
94
-
95
- /**
96
- * @see https://webidl.spec.whatwg.org/#es-long-long
97
- */
98
- ['long long'] (V: unknown): number
99
-
100
- /**
101
- * @see https://webidl.spec.whatwg.org/#es-unsigned-long-long
102
- */
103
- ['unsigned long long'] (V: unknown): number
104
-
105
- /**
106
- * @see https://webidl.spec.whatwg.org/#es-unsigned-long
107
- */
108
- ['unsigned long'] (V: unknown): number
109
-
110
- /**
111
- * @see https://webidl.spec.whatwg.org/#es-unsigned-short
112
- */
113
- ['unsigned short'] (V: unknown, opts?: ConvertToIntOpts): number
114
-
115
- /**
116
- * @see https://webidl.spec.whatwg.org/#idl-ArrayBuffer
117
- */
118
- ArrayBuffer (V: unknown): ArrayBufferLike
119
- ArrayBuffer (V: unknown, opts: { allowShared: false }): ArrayBuffer
120
-
121
- /**
122
- * @see https://webidl.spec.whatwg.org/#es-buffer-source-types
123
- */
124
- TypedArray (
125
- V: unknown,
126
- TypedArray: NodeJS.TypedArray | ArrayBufferLike
127
- ): NodeJS.TypedArray | ArrayBufferLike
128
- TypedArray (
129
- V: unknown,
130
- TypedArray: NodeJS.TypedArray | ArrayBufferLike,
131
- opts?: { allowShared: false }
132
- ): NodeJS.TypedArray | ArrayBuffer
133
-
134
- /**
135
- * @see https://webidl.spec.whatwg.org/#es-buffer-source-types
136
- */
137
- DataView (V: unknown, opts?: { allowShared: boolean }): DataView
138
-
139
- /**
140
- * @see https://webidl.spec.whatwg.org/#BufferSource
141
- */
142
- BufferSource (
143
- V: unknown,
144
- opts?: { allowShared: boolean }
145
- ): NodeJS.TypedArray | ArrayBufferLike | DataView
146
-
147
- ['sequence<ByteString>']: SequenceConverter<string>
148
-
149
- ['sequence<sequence<ByteString>>']: SequenceConverter<string[]>
150
-
151
- ['record<ByteString, ByteString>']: RecordConverter<string, string>
152
-
153
- [Key: string]: (...args: any[]) => unknown
154
- }
155
-
156
- export interface Webidl {
157
- errors: WebidlErrors
158
- util: WebidlUtil
159
- converters: WebidlConverters
160
-
161
- /**
162
- * @description Performs a brand-check on {@param V} to ensure it is a
163
- * {@param cls} object.
164
- */
165
- brandCheck <Interface>(V: unknown, cls: Interface, opts?: { strict?: boolean }): asserts V is Interface
166
-
167
- /**
168
- * @see https://webidl.spec.whatwg.org/#es-sequence
169
- * @description Convert a value, V, to a WebIDL sequence type.
170
- */
171
- sequenceConverter <Type>(C: Converter<Type>): SequenceConverter<Type>
172
-
173
- illegalConstructor (): never
174
-
175
- /**
176
- * @see https://webidl.spec.whatwg.org/#es-to-record
177
- * @description Convert a value, V, to a WebIDL record type.
178
- */
179
- recordConverter <K extends string, V>(
180
- keyConverter: Converter<K>,
181
- valueConverter: Converter<V>
182
- ): RecordConverter<K, V>
183
-
184
- /**
185
- * Similar to {@link Webidl.brandCheck} but allows skipping the check if third party
186
- * interfaces are allowed.
187
- */
188
- interfaceConverter <Interface>(cls: Interface): (
189
- V: unknown,
190
- opts?: { strict: boolean }
191
- ) => asserts V is typeof cls
192
-
193
- // TODO(@KhafraDev): a type could likely be implemented that can infer the return type
194
- // from the converters given?
195
- /**
196
- * Converts a value, V, to a WebIDL dictionary types. Allows limiting which keys are
197
- * allowed, values allowed, optional and required keys. Auto converts the value to
198
- * a type given a converter.
199
- */
200
- dictionaryConverter (converters: {
201
- key: string,
202
- defaultValue?: unknown,
203
- required?: boolean,
204
- converter: (...args: unknown[]) => unknown,
205
- allowedValues?: unknown[]
206
- }[]): (V: unknown) => Record<string, unknown>
207
-
208
- /**
209
- * @see https://webidl.spec.whatwg.org/#idl-nullable-type
210
- * @description allows a type, V, to be null
211
- */
212
- nullableConverter <T>(
213
- converter: Converter<T>
214
- ): (V: unknown) => ReturnType<typeof converter> | null
215
-
216
- argumentLengthCheck (args: { length: number }, min: number, context: {
217
- header: string
218
- message?: string
219
- }): void
220
- }
@@ -1,131 +0,0 @@
1
- /// <reference types="node" />
2
-
3
- import type { Blob } from 'buffer'
4
- import type { MessagePort } from 'worker_threads'
5
- import {
6
- EventTarget,
7
- Event,
8
- EventInit,
9
- EventListenerOptions,
10
- AddEventListenerOptions,
11
- EventListenerOrEventListenerObject
12
- } from './patch'
13
- import Dispatcher from './dispatcher'
14
- import { HeadersInit } from './fetch'
15
-
16
- export type BinaryType = 'blob' | 'arraybuffer'
17
-
18
- interface WebSocketEventMap {
19
- close: CloseEvent
20
- error: Event
21
- message: MessageEvent
22
- open: Event
23
- }
24
-
25
- interface WebSocket extends EventTarget {
26
- binaryType: BinaryType
27
-
28
- readonly bufferedAmount: number
29
- readonly extensions: string
30
-
31
- onclose: ((this: WebSocket, ev: WebSocketEventMap['close']) => any) | null
32
- onerror: ((this: WebSocket, ev: WebSocketEventMap['error']) => any) | null
33
- onmessage: ((this: WebSocket, ev: WebSocketEventMap['message']) => any) | null
34
- onopen: ((this: WebSocket, ev: WebSocketEventMap['open']) => any) | null
35
-
36
- readonly protocol: string
37
- readonly readyState: number
38
- readonly url: string
39
-
40
- close(code?: number, reason?: string): void
41
- send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void
42
-
43
- readonly CLOSED: number
44
- readonly CLOSING: number
45
- readonly CONNECTING: number
46
- readonly OPEN: number
47
-
48
- addEventListener<K extends keyof WebSocketEventMap>(
49
- type: K,
50
- listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any,
51
- options?: boolean | AddEventListenerOptions
52
- ): void
53
- addEventListener(
54
- type: string,
55
- listener: EventListenerOrEventListenerObject,
56
- options?: boolean | AddEventListenerOptions
57
- ): void
58
- removeEventListener<K extends keyof WebSocketEventMap>(
59
- type: K,
60
- listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any,
61
- options?: boolean | EventListenerOptions
62
- ): void
63
- removeEventListener(
64
- type: string,
65
- listener: EventListenerOrEventListenerObject,
66
- options?: boolean | EventListenerOptions
67
- ): void
68
- }
69
-
70
- export declare const WebSocket: {
71
- prototype: WebSocket
72
- new (url: string | URL, protocols?: string | string[] | WebSocketInit): WebSocket
73
- readonly CLOSED: number
74
- readonly CLOSING: number
75
- readonly CONNECTING: number
76
- readonly OPEN: number
77
- }
78
-
79
- interface CloseEventInit extends EventInit {
80
- code?: number
81
- reason?: string
82
- wasClean?: boolean
83
- }
84
-
85
- interface CloseEvent extends Event {
86
- readonly code: number
87
- readonly reason: string
88
- readonly wasClean: boolean
89
- }
90
-
91
- export declare const CloseEvent: {
92
- prototype: CloseEvent
93
- new (type: string, eventInitDict?: CloseEventInit): CloseEvent
94
- }
95
-
96
- interface MessageEventInit<T = any> extends EventInit {
97
- data?: T
98
- lastEventId?: string
99
- origin?: string
100
- ports?: (typeof MessagePort)[]
101
- source?: typeof MessagePort | null
102
- }
103
-
104
- interface MessageEvent<T = any> extends Event {
105
- readonly data: T
106
- readonly lastEventId: string
107
- readonly origin: string
108
- readonly ports: ReadonlyArray<typeof MessagePort>
109
- readonly source: typeof MessagePort | null
110
- initMessageEvent(
111
- type: string,
112
- bubbles?: boolean,
113
- cancelable?: boolean,
114
- data?: any,
115
- origin?: string,
116
- lastEventId?: string,
117
- source?: typeof MessagePort | null,
118
- ports?: (typeof MessagePort)[]
119
- ): void;
120
- }
121
-
122
- export declare const MessageEvent: {
123
- prototype: MessageEvent
124
- new<T>(type: string, eventInitDict?: MessageEventInit<T>): MessageEvent<T>
125
- }
126
-
127
- interface WebSocketInit {
128
- protocols?: string | string[],
129
- dispatcher?: Dispatcher,
130
- headers?: HeadersInit
131
- }