* health check

* Update Dockerfile

* simplifying the deployment

* Update Bot.js

makes the find team command public

* test (#9)

* Dev (#7)

* health check

* Update Dockerfile

* simplifying the deployment

* Dev (#8)

* health check

* Update Dockerfile

* simplifying the deployment

* Update Bot.js

makes the find team command public

* Update PlayerService.js

* massive update????

could break stuff

* Update Bot.js

update
This commit is contained in:
VinceC
2025-07-07 21:38:19 -05:00
committed by GitHub
parent 0c86148835
commit 3453be6947
1742 changed files with 28844 additions and 67711 deletions

14
node_modules/undici-types/agent.d.ts generated vendored
View File

@@ -1,17 +1,17 @@
import { URL } from 'url'
import Pool from './pool'
import Dispatcher from "./dispatcher";
import Dispatcher from './dispatcher'
export default Agent
declare class Agent extends Dispatcher{
constructor(opts?: Agent.Options)
declare class Agent extends Dispatcher {
constructor (opts?: Agent.Options)
/** `true` after `dispatcher.close()` has been called. */
closed: boolean;
closed: boolean
/** `true` after `dispatcher.destroyed()` has been called or `dispatcher.close()` has been called and the dispatcher shutdown has completed. */
destroyed: boolean;
destroyed: boolean
/** Dispatches a request. */
dispatch(options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandlers): boolean;
dispatch (options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandler): boolean
}
declare namespace Agent {
@@ -21,7 +21,7 @@ declare namespace Agent {
/** Integer. Default: `0` */
maxRedirections?: number;
interceptors?: { Agent?: readonly Dispatcher.DispatchInterceptor[] } & Pool.Options["interceptors"]
interceptors?: { Agent?: readonly Dispatcher.DispatchInterceptor[] } & Pool.Options['interceptors']
}
export interface DispatchOptions extends Dispatcher.DispatchOptions {

66
node_modules/undici-types/api.d.ts generated vendored
View File

@@ -2,42 +2,42 @@ import { URL, UrlObject } from 'url'
import { Duplex } from 'stream'
import Dispatcher from './dispatcher'
/** Performs an HTTP request. */
declare function request<TOpaque = null> (
url: string | URL | UrlObject,
options?: { dispatcher?: Dispatcher } & Omit<Dispatcher.RequestOptions<TOpaque>, 'origin' | 'path' | 'method'> & Partial<Pick<Dispatcher.RequestOptions, 'method'>>,
): Promise<Dispatcher.ResponseData<TOpaque>>
/** A faster version of `request`. */
declare function stream<TOpaque = null> (
url: string | URL | UrlObject,
options: { dispatcher?: Dispatcher } & Omit<Dispatcher.RequestOptions<TOpaque>, 'origin' | 'path'>,
factory: Dispatcher.StreamFactory<TOpaque>
): Promise<Dispatcher.StreamData<TOpaque>>
/** For easy use with `stream.pipeline`. */
declare function pipeline<TOpaque = null> (
url: string | URL | UrlObject,
options: { dispatcher?: Dispatcher } & Omit<Dispatcher.PipelineOptions<TOpaque>, 'origin' | 'path'>,
handler: Dispatcher.PipelineHandler<TOpaque>
): Duplex
/** Starts two-way communications with the requested resource. */
declare function connect<TOpaque = null> (
url: string | URL | UrlObject,
options?: { dispatcher?: Dispatcher } & Omit<Dispatcher.ConnectOptions<TOpaque>, 'origin' | 'path'>
): Promise<Dispatcher.ConnectData<TOpaque>>
/** Upgrade to a different protocol. */
declare function upgrade (
url: string | URL | UrlObject,
options?: { dispatcher?: Dispatcher } & Omit<Dispatcher.UpgradeOptions, 'origin' | 'path'>
): Promise<Dispatcher.UpgradeData>
export {
request,
stream,
pipeline,
connect,
upgrade,
upgrade
}
/** Performs an HTTP request. */
declare function request(
url: string | URL | UrlObject,
options?: { dispatcher?: Dispatcher } & Omit<Dispatcher.RequestOptions, 'origin' | 'path' | 'method'> & Partial<Pick<Dispatcher.RequestOptions, 'method'>>,
): Promise<Dispatcher.ResponseData>;
/** A faster version of `request`. */
declare function stream(
url: string | URL | UrlObject,
options: { dispatcher?: Dispatcher } & Omit<Dispatcher.RequestOptions, 'origin' | 'path'>,
factory: Dispatcher.StreamFactory
): Promise<Dispatcher.StreamData>;
/** For easy use with `stream.pipeline`. */
declare function pipeline(
url: string | URL | UrlObject,
options: { dispatcher?: Dispatcher } & Omit<Dispatcher.PipelineOptions, 'origin' | 'path'>,
handler: Dispatcher.PipelineHandler
): Duplex;
/** Starts two-way communications with the requested resource. */
declare function connect(
url: string | URL | UrlObject,
options?: { dispatcher?: Dispatcher } & Omit<Dispatcher.ConnectOptions, 'origin' | 'path'>
): Promise<Dispatcher.ConnectData>;
/** Upgrade to a different protocol. */
declare function upgrade(
url: string | URL | UrlObject,
options?: { dispatcher?: Dispatcher } & Omit<Dispatcher.UpgradeOptions, 'origin' | 'path'>
): Promise<Dispatcher.UpgradeData>;

View File

@@ -4,26 +4,26 @@ import { URL } from 'url'
export default BalancedPool
type BalancedPoolConnectOptions = Omit<Dispatcher.ConnectOptions, "origin">;
type BalancedPoolConnectOptions = Omit<Dispatcher.ConnectOptions, 'origin'>
declare class BalancedPool extends Dispatcher {
constructor(url: string | string[] | URL | URL[], options?: Pool.Options);
constructor (url: string | string[] | URL | URL[], options?: Pool.Options)
addUpstream(upstream: string | URL): BalancedPool;
removeUpstream(upstream: string | URL): BalancedPool;
upstreams: Array<string>;
addUpstream (upstream: string | URL): BalancedPool
removeUpstream (upstream: string | URL): BalancedPool
upstreams: Array<string>
/** `true` after `pool.close()` has been called. */
closed: boolean;
closed: boolean
/** `true` after `pool.destroyed()` has been called or `pool.close()` has been called and the pool shutdown has completed. */
destroyed: boolean;
destroyed: boolean
// Override dispatcher APIs.
override connect(
override connect (
options: BalancedPoolConnectOptions
): Promise<Dispatcher.ConnectData>;
override connect(
): Promise<Dispatcher.ConnectData>
override connect (
options: BalancedPoolConnectOptions,
callback: (err: Error | null, data: Dispatcher.ConnectData) => void
): void;
): void
}

View File

@@ -1,30 +1,29 @@
import { URL } from 'url'
import { TlsOptions } from 'tls'
import Dispatcher from './dispatcher'
import buildConnector from "./connector";
import buildConnector from './connector'
type ClientConnectOptions = Omit<Dispatcher.ConnectOptions, "origin">;
type ClientConnectOptions = Omit<Dispatcher.ConnectOptions, 'origin'>
/**
* A basic HTTP/1.1 client, mapped on top a single TCP/TLS connection. Pipelining is disabled by default.
*/
export class Client extends Dispatcher {
constructor(url: string | URL, options?: Client.Options);
constructor (url: string | URL, options?: Client.Options)
/** Property to get and set the pipelining factor. */
pipelining: number;
pipelining: number
/** `true` after `client.close()` has been called. */
closed: boolean;
closed: boolean
/** `true` after `client.destroyed()` has been called or `client.close()` has been called and the client shutdown has completed. */
destroyed: boolean;
destroyed: boolean
// Override dispatcher APIs.
override connect(
override connect (
options: ClientConnectOptions
): Promise<Dispatcher.ConnectData>;
override connect(
): Promise<Dispatcher.ConnectData>
override connect (
options: ClientConnectOptions,
callback: (err: Error | null, data: Dispatcher.ConnectData) => void
): void;
): void
}
export declare namespace Client {
@@ -71,7 +70,7 @@ export declare namespace Client {
/** TODO */
maxRedirections?: number;
/** TODO */
connect?: buildConnector.BuildOptions | buildConnector.connector;
connect?: Partial<buildConnector.BuildOptions> | buildConnector.connector;
/** TODO */
maxRequestsPerClient?: number;
/** TODO */
@@ -105,4 +104,4 @@ export declare namespace Client {
}
}
export default Client;
export default Client

View File

@@ -26,3 +26,5 @@ export function getCookies (headers: Headers): Record<string, string>
export function getSetCookies (headers: Headers): Cookie[]
export function setCookie (headers: Headers, cookie: Cookie): void
export function parseCookie (cookie: string): Cookie | null

View File

@@ -1,7 +1,7 @@
import { Socket } from "net";
import { URL } from "url";
import Connector from "./connector";
import Dispatcher from "./dispatcher";
import { Socket } from 'net'
import { URL } from 'url'
import buildConnector from './connector'
import Dispatcher from './dispatcher'
declare namespace DiagnosticsChannel {
interface Request {
@@ -16,15 +16,15 @@ declare namespace DiagnosticsChannel {
statusText: string;
headers: Array<Buffer>;
}
type Error = unknown;
type Error = unknown
interface ConnectParams {
host: URL["host"];
hostname: URL["hostname"];
protocol: URL["protocol"];
port: URL["port"];
host: URL['host'];
hostname: URL['hostname'];
protocol: URL['protocol'];
port: URL['port'];
servername: string | null;
}
type Connector = Connector.connector;
type Connector = buildConnector.connector
export interface RequestCreateMessage {
request: Request;
}

View File

@@ -6,98 +6,98 @@ import { IncomingHttpHeaders } from './header'
import BodyReadable from './readable'
import { FormData } from './formdata'
import Errors from './errors'
import { Autocomplete } from './utility'
type AbortSignal = unknown;
type AbortSignal = unknown
export default Dispatcher
export type UndiciHeaders = Record<string, string | string[]> | IncomingHttpHeaders | string[] | Iterable<[string, string | string[] | undefined]> | null
/** Dispatcher is the core API used to dispatch requests. */
declare class Dispatcher extends EventEmitter {
/** 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. */
dispatch(options: Dispatcher.DispatchOptions, handler: Dispatcher.DispatchHandlers): boolean;
dispatch (options: Dispatcher.DispatchOptions, handler: Dispatcher.DispatchHandler): boolean
/** Starts two-way communications with the requested resource. */
connect(options: Dispatcher.ConnectOptions): Promise<Dispatcher.ConnectData>;
connect(options: Dispatcher.ConnectOptions, callback: (err: Error | null, data: Dispatcher.ConnectData) => void): void;
connect<TOpaque = null>(options: Dispatcher.ConnectOptions<TOpaque>): Promise<Dispatcher.ConnectData<TOpaque>>
connect<TOpaque = null>(options: Dispatcher.ConnectOptions<TOpaque>, callback: (err: Error | null, data: Dispatcher.ConnectData<TOpaque>) => void): void
/** Compose a chain of dispatchers */
compose(dispatchers: Dispatcher.DispatcherComposeInterceptor[]): Dispatcher.ComposedDispatcher;
compose(...dispatchers: Dispatcher.DispatcherComposeInterceptor[]): Dispatcher.ComposedDispatcher;
compose (dispatchers: Dispatcher.DispatcherComposeInterceptor[]): Dispatcher.ComposedDispatcher
compose (...dispatchers: Dispatcher.DispatcherComposeInterceptor[]): Dispatcher.ComposedDispatcher
/** Performs an HTTP request. */
request(options: Dispatcher.RequestOptions): Promise<Dispatcher.ResponseData>;
request(options: Dispatcher.RequestOptions, callback: (err: Error | null, data: Dispatcher.ResponseData) => void): void;
request<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>): Promise<Dispatcher.ResponseData<TOpaque>>
request<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>, callback: (err: Error | null, data: Dispatcher.ResponseData<TOpaque>) => void): void
/** For easy use with `stream.pipeline`. */
pipeline(options: Dispatcher.PipelineOptions, handler: Dispatcher.PipelineHandler): Duplex;
pipeline<TOpaque = null>(options: Dispatcher.PipelineOptions<TOpaque>, handler: Dispatcher.PipelineHandler<TOpaque>): Duplex
/** A faster version of `Dispatcher.request`. */
stream(options: Dispatcher.RequestOptions, factory: Dispatcher.StreamFactory): Promise<Dispatcher.StreamData>;
stream(options: Dispatcher.RequestOptions, factory: Dispatcher.StreamFactory, callback: (err: Error | null, data: Dispatcher.StreamData) => void): void;
stream<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>, factory: Dispatcher.StreamFactory<TOpaque>): Promise<Dispatcher.StreamData<TOpaque>>
stream<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>, factory: Dispatcher.StreamFactory<TOpaque>, callback: (err: Error | null, data: Dispatcher.StreamData<TOpaque>) => void): void
/** Upgrade to a different protocol. */
upgrade(options: Dispatcher.UpgradeOptions): Promise<Dispatcher.UpgradeData>;
upgrade(options: Dispatcher.UpgradeOptions, callback: (err: Error | null, data: Dispatcher.UpgradeData) => void): void;
upgrade (options: Dispatcher.UpgradeOptions): Promise<Dispatcher.UpgradeData>
upgrade (options: Dispatcher.UpgradeOptions, callback: (err: Error | null, data: Dispatcher.UpgradeData) => void): void
/** Closes the client and gracefully waits for enqueued requests to complete before invoking the callback (or returning a promise if no callback is provided). */
close(): Promise<void>;
close(callback: () => void): void;
close (): Promise<void>
close (callback: () => void): void
/** 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. */
destroy(): Promise<void>;
destroy(err: Error | null): Promise<void>;
destroy(callback: () => void): void;
destroy(err: Error | null, callback: () => void): void;
destroy (): Promise<void>
destroy (err: Error | null): Promise<void>
destroy (callback: () => void): void
destroy (err: Error | null, callback: () => void): void
on(eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this;
on(eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
on(eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
on(eventName: 'drain', callback: (origin: URL) => void): this;
on (eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this
on (eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
on (eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
on (eventName: 'drain', callback: (origin: URL) => void): this
once (eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this
once (eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
once (eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
once (eventName: 'drain', callback: (origin: URL) => void): this
once(eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this;
once(eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
once(eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
once(eventName: 'drain', callback: (origin: URL) => void): this;
off (eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this
off (eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
off (eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
off (eventName: 'drain', callback: (origin: URL) => void): this
addListener (eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this
addListener (eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
addListener (eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
addListener (eventName: 'drain', callback: (origin: URL) => void): this
off(eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this;
off(eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
off(eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
off(eventName: 'drain', callback: (origin: URL) => void): this;
removeListener (eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this
removeListener (eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
removeListener (eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
removeListener (eventName: 'drain', callback: (origin: URL) => void): this
prependListener (eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this
prependListener (eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
prependListener (eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
prependListener (eventName: 'drain', callback: (origin: URL) => void): this
addListener(eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this;
addListener(eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
addListener(eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
addListener(eventName: 'drain', callback: (origin: URL) => void): this;
prependOnceListener (eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this
prependOnceListener (eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
prependOnceListener (eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
prependOnceListener (eventName: 'drain', callback: (origin: URL) => void): this
removeListener(eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this;
removeListener(eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
removeListener(eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
removeListener(eventName: 'drain', callback: (origin: URL) => void): this;
listeners (eventName: 'connect'): ((origin: URL, targets: readonly Dispatcher[]) => void)[]
listeners (eventName: 'disconnect'): ((origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[]
listeners (eventName: 'connectionError'): ((origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[]
listeners (eventName: 'drain'): ((origin: URL) => void)[]
prependListener(eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this;
prependListener(eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
prependListener(eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
prependListener(eventName: 'drain', callback: (origin: URL) => void): this;
rawListeners (eventName: 'connect'): ((origin: URL, targets: readonly Dispatcher[]) => void)[]
rawListeners (eventName: 'disconnect'): ((origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[]
rawListeners (eventName: 'connectionError'): ((origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[]
rawListeners (eventName: 'drain'): ((origin: URL) => void)[]
prependOnceListener(eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this;
prependOnceListener(eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
prependOnceListener(eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
prependOnceListener(eventName: 'drain', callback: (origin: URL) => void): this;
listeners(eventName: 'connect'): ((origin: URL, targets: readonly Dispatcher[]) => void)[]
listeners(eventName: 'disconnect'): ((origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
listeners(eventName: 'connectionError'): ((origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
listeners(eventName: 'drain'): ((origin: URL) => void)[];
rawListeners(eventName: 'connect'): ((origin: URL, targets: readonly Dispatcher[]) => void)[]
rawListeners(eventName: 'disconnect'): ((origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
rawListeners(eventName: 'connectionError'): ((origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
rawListeners(eventName: 'drain'): ((origin: URL) => void)[];
emit(eventName: 'connect', origin: URL, targets: readonly Dispatcher[]): boolean;
emit(eventName: 'disconnect', origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError): boolean;
emit(eventName: 'connectionError', origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError): boolean;
emit(eventName: 'drain', origin: URL): boolean;
emit (eventName: 'connect', origin: URL, targets: readonly Dispatcher[]): boolean
emit (eventName: 'disconnect', origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError): boolean
emit (eventName: 'connectionError', origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError): boolean
emit (eventName: 'drain', origin: URL): boolean
}
declare namespace Dispatcher {
export interface ComposedDispatcher extends Dispatcher {}
export type DispatcherComposeInterceptor = (dispatch: Dispatcher['dispatch']) => Dispatcher['dispatch'];
export type DispatcherComposeInterceptor = (dispatch: Dispatcher['dispatch']) => Dispatcher['dispatch']
export interface DispatchOptions {
origin?: string | URL;
path: string;
@@ -105,12 +105,12 @@ declare namespace Dispatcher {
/** Default: `null` */
body?: string | Buffer | Uint8Array | Readable | null | FormData;
/** Default: `null` */
headers?: IncomingHttpHeaders | string[] | Iterable<[string, string | string[] | undefined]> | null;
headers?: UndiciHeaders;
/** Query string params to be embedded in the request URL. Default: `null` */
query?: Record<string, any>;
/** 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`. */
idempotent?: boolean;
/** 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. */
/** 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'`. */
blocking?: boolean;
/** Upgrade the request. Should be used to specify the kind of upgrade i.e. `'Websocket'`. Default: `method === 'CONNECT' || null`. */
upgrade?: boolean | string | null;
@@ -122,28 +122,28 @@ declare namespace Dispatcher {
reset?: boolean;
/** Whether Undici should throw an error upon receiving a 4xx or 5xx response from the server. Defaults to false */
throwOnError?: boolean;
/** For H2, it appends the expect: 100-continue header, and halts the request body until a 100-continue is received from the remote server*/
/** For H2, it appends the expect: 100-continue header, and halts the request body until a 100-continue is received from the remote server */
expectContinue?: boolean;
}
export interface ConnectOptions {
export interface ConnectOptions<TOpaque = null> {
origin: string | URL;
path: string;
/** Default: `null` */
headers?: IncomingHttpHeaders | string[] | null;
headers?: UndiciHeaders;
/** Default: `null` */
signal?: AbortSignal | EventEmitter | null;
/** This argument parameter is passed through to `ConnectData` */
opaque?: unknown;
opaque?: TOpaque;
/** Default: 0 */
maxRedirections?: number;
/** Default: false */
redirectionLimitReached?: boolean;
/** Default: `null` */
responseHeader?: 'raw' | null;
responseHeaders?: 'raw' | null;
}
export interface RequestOptions extends DispatchOptions {
export interface RequestOptions<TOpaque = null> extends DispatchOptions {
/** Default: `null` */
opaque?: unknown;
opaque?: TOpaque;
/** Default: `null` */
signal?: AbortSignal | EventEmitter | null;
/** Default: 0 */
@@ -153,11 +153,11 @@ declare namespace Dispatcher {
/** Default: `null` */
onInfo?: (info: { statusCode: number, headers: Record<string, string | string[]> }) => void;
/** Default: `null` */
responseHeader?: 'raw' | null;
responseHeaders?: 'raw' | null;
/** Default: `64 KiB` */
highWaterMark?: number;
}
export interface PipelineOptions extends RequestOptions {
export interface PipelineOptions<TOpaque = null> extends RequestOptions<TOpaque> {
/** `true` if the `handler` will return an object stream. Default: `false` */
objectMode?: boolean;
}
@@ -166,7 +166,7 @@ declare namespace Dispatcher {
/** Default: `'GET'` */
method?: string;
/** Default: `null` */
headers?: IncomingHttpHeaders | string[] | null;
headers?: UndiciHeaders;
/** A string of comma separated protocols, in descending preference order. Default: `'Websocket'` */
protocol?: string;
/** Default: `null` */
@@ -176,65 +176,90 @@ declare namespace Dispatcher {
/** Default: false */
redirectionLimitReached?: boolean;
/** Default: `null` */
responseHeader?: 'raw' | null;
responseHeaders?: 'raw' | null;
}
export interface ConnectData {
export interface ConnectData<TOpaque = null> {
statusCode: number;
headers: IncomingHttpHeaders;
socket: Duplex;
opaque: unknown;
opaque: TOpaque;
}
export interface ResponseData {
export interface ResponseData<TOpaque = null> {
statusCode: number;
headers: IncomingHttpHeaders;
body: BodyReadable & BodyMixin;
trailers: Record<string, string>;
opaque: unknown;
opaque: TOpaque;
context: object;
}
export interface PipelineHandlerData {
export interface PipelineHandlerData<TOpaque = null> {
statusCode: number;
headers: IncomingHttpHeaders;
opaque: unknown;
opaque: TOpaque;
body: BodyReadable;
context: object;
}
export interface StreamData {
opaque: unknown;
export interface StreamData<TOpaque = null> {
opaque: TOpaque;
trailers: Record<string, string>;
}
export interface UpgradeData {
export interface UpgradeData<TOpaque = null> {
headers: IncomingHttpHeaders;
socket: Duplex;
opaque: unknown;
opaque: TOpaque;
}
export interface StreamFactoryData {
export interface StreamFactoryData<TOpaque = null> {
statusCode: number;
headers: IncomingHttpHeaders;
opaque: unknown;
opaque: TOpaque;
context: object;
}
export type StreamFactory = (data: StreamFactoryData) => Writable;
export interface DispatchHandlers {
export type StreamFactory<TOpaque = null> = (data: StreamFactoryData<TOpaque>) => Writable
export interface DispatchController {
get aborted () : boolean
get paused () : boolean
get reason () : Error | null
abort (reason: Error): void
pause(): void
resume(): void
}
export interface DispatchHandler {
onRequestStart?(controller: DispatchController, context: any): void;
onRequestUpgrade?(controller: DispatchController, statusCode: number, headers: IncomingHttpHeaders, socket: Duplex): void;
onResponseStart?(controller: DispatchController, statusCode: number, headers: IncomingHttpHeaders, statusMessage?: string): void;
onResponseData?(controller: DispatchController, chunk: Buffer): void;
onResponseEnd?(controller: DispatchController, trailers: IncomingHttpHeaders): void;
onResponseError?(controller: DispatchController, error: Error): void;
/** 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. */
/** @deprecated */
onConnect?(abort: (err?: Error) => void): void;
/** Invoked when an error has occurred. */
/** @deprecated */
onError?(err: Error): void;
/** Invoked when request is upgraded either due to a `Upgrade` header or `CONNECT` method. */
/** @deprecated */
onUpgrade?(statusCode: number, headers: Buffer[] | string[] | null, socket: Duplex): void;
/** Invoked when response is received, before headers have been read. **/
/** @deprecated */
onResponseStarted?(): void;
/** Invoked when statusCode and headers have been received. May be invoked multiple times due to 1xx informational headers. */
/** @deprecated */
onHeaders?(statusCode: number, headers: Buffer[], resume: () => void, statusText: string): boolean;
/** Invoked when response payload data is received. */
/** @deprecated */
onData?(chunk: Buffer): boolean;
/** Invoked when response payload and trailers have been received and the request has completed. */
/** @deprecated */
onComplete?(trailers: string[] | null): void;
/** Invoked when a body chunk is sent to the server. May be invoked multiple times for chunked requests */
/** @deprecated */
onBodySent?(chunkSize: number, totalBytesSent: number): void;
}
export type PipelineHandler = (data: PipelineHandlerData) => Readable;
export type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH';
export type PipelineHandler<TOpaque = null> = (data: PipelineHandlerData<TOpaque>) => Readable
export type HttpMethod = Autocomplete<'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH'>
/**
* @link https://fetch.spec.whatwg.org/#body-mixin
@@ -244,6 +269,7 @@ declare namespace Dispatcher {
readonly bodyUsed: boolean;
arrayBuffer(): Promise<ArrayBuffer>;
blob(): Promise<Blob>;
bytes(): Promise<Uint8Array>;
formData(): Promise<never>;
json(): Promise<unknown>;
text(): Promise<string>;

View File

@@ -4,9 +4,9 @@ import Dispatcher from './dispatcher'
export default EnvHttpProxyAgent
declare class EnvHttpProxyAgent extends Dispatcher {
constructor(opts?: EnvHttpProxyAgent.Options)
constructor (opts?: EnvHttpProxyAgent.Options)
dispatch(options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandlers): boolean;
dispatch (options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandler): boolean
}
declare namespace EnvHttpProxyAgent {

116
node_modules/undici-types/errors.d.ts generated vendored
View File

@@ -1,24 +1,24 @@
import { IncomingHttpHeaders } from "./header";
import { IncomingHttpHeaders } from './header'
import Client from './client'
export default Errors
declare namespace Errors {
export class UndiciError extends Error {
name: string;
code: string;
name: string
code: string
}
/** Connect timeout error. */
export class ConnectTimeoutError extends UndiciError {
name: 'ConnectTimeoutError';
code: 'UND_ERR_CONNECT_TIMEOUT';
name: 'ConnectTimeoutError'
code: 'UND_ERR_CONNECT_TIMEOUT'
}
/** A header exceeds the `headersTimeout` option. */
export class HeadersTimeoutError extends UndiciError {
name: 'HeadersTimeoutError';
code: 'UND_ERR_HEADERS_TIMEOUT';
name: 'HeadersTimeoutError'
code: 'UND_ERR_HEADERS_TIMEOUT'
}
/** Headers overflow error. */
@@ -29,8 +29,24 @@ declare namespace Errors {
/** A body exceeds the `bodyTimeout` option. */
export class BodyTimeoutError extends UndiciError {
name: 'BodyTimeoutError';
code: 'UND_ERR_BODY_TIMEOUT';
name: 'BodyTimeoutError'
code: 'UND_ERR_BODY_TIMEOUT'
}
export class ResponseError extends UndiciError {
constructor (
message: string,
code: number,
options: {
headers?: IncomingHttpHeaders | string[] | null,
body?: null | Record<string, any> | string
}
)
name: 'ResponseError'
code: 'UND_ERR_RESPONSE'
statusCode: number
body: null | Record<string, any> | string
headers: IncomingHttpHeaders | string[] | null
}
export class ResponseStatusCodeError extends UndiciError {
@@ -39,91 +55,91 @@ declare namespace Errors {
statusCode?: number,
headers?: IncomingHttpHeaders | string[] | null,
body?: null | Record<string, any> | string
);
name: 'ResponseStatusCodeError';
code: 'UND_ERR_RESPONSE_STATUS_CODE';
)
name: 'ResponseStatusCodeError'
code: 'UND_ERR_RESPONSE_STATUS_CODE'
body: null | Record<string, any> | string
status: number
statusCode: number
headers: IncomingHttpHeaders | string[] | null;
headers: IncomingHttpHeaders | string[] | null
}
/** Passed an invalid argument. */
export class InvalidArgumentError extends UndiciError {
name: 'InvalidArgumentError';
code: 'UND_ERR_INVALID_ARG';
name: 'InvalidArgumentError'
code: 'UND_ERR_INVALID_ARG'
}
/** Returned an invalid value. */
export class InvalidReturnValueError extends UndiciError {
name: 'InvalidReturnValueError';
code: 'UND_ERR_INVALID_RETURN_VALUE';
name: 'InvalidReturnValueError'
code: 'UND_ERR_INVALID_RETURN_VALUE'
}
/** The request has been aborted by the user. */
export class RequestAbortedError extends UndiciError {
name: 'AbortError';
code: 'UND_ERR_ABORTED';
name: 'AbortError'
code: 'UND_ERR_ABORTED'
}
/** Expected error with reason. */
export class InformationalError extends UndiciError {
name: 'InformationalError';
code: 'UND_ERR_INFO';
name: 'InformationalError'
code: 'UND_ERR_INFO'
}
/** Request body length does not match content-length header. */
export class RequestContentLengthMismatchError extends UndiciError {
name: 'RequestContentLengthMismatchError';
code: 'UND_ERR_REQ_CONTENT_LENGTH_MISMATCH';
name: 'RequestContentLengthMismatchError'
code: 'UND_ERR_REQ_CONTENT_LENGTH_MISMATCH'
}
/** Response body length does not match content-length header. */
export class ResponseContentLengthMismatchError extends UndiciError {
name: 'ResponseContentLengthMismatchError';
code: 'UND_ERR_RES_CONTENT_LENGTH_MISMATCH';
name: 'ResponseContentLengthMismatchError'
code: 'UND_ERR_RES_CONTENT_LENGTH_MISMATCH'
}
/** Trying to use a destroyed client. */
export class ClientDestroyedError extends UndiciError {
name: 'ClientDestroyedError';
code: 'UND_ERR_DESTROYED';
name: 'ClientDestroyedError'
code: 'UND_ERR_DESTROYED'
}
/** Trying to use a closed client. */
export class ClientClosedError extends UndiciError {
name: 'ClientClosedError';
code: 'UND_ERR_CLOSED';
name: 'ClientClosedError'
code: 'UND_ERR_CLOSED'
}
/** There is an error with the socket. */
export class SocketError extends UndiciError {
name: 'SocketError';
code: 'UND_ERR_SOCKET';
name: 'SocketError'
code: 'UND_ERR_SOCKET'
socket: Client.SocketInfo | null
}
/** Encountered unsupported functionality. */
export class NotSupportedError extends UndiciError {
name: 'NotSupportedError';
code: 'UND_ERR_NOT_SUPPORTED';
name: 'NotSupportedError'
code: 'UND_ERR_NOT_SUPPORTED'
}
/** No upstream has been added to the BalancedPool. */
export class BalancedPoolMissingUpstreamError extends UndiciError {
name: 'MissingUpstreamError';
code: 'UND_ERR_BPL_MISSING_UPSTREAM';
name: 'MissingUpstreamError'
code: 'UND_ERR_BPL_MISSING_UPSTREAM'
}
export class HTTPParserError extends UndiciError {
name: 'HTTPParserError';
code: string;
name: 'HTTPParserError'
code: string
}
/** The response exceed the length allowed. */
export class ResponseExceededMaxSizeError extends UndiciError {
name: 'ResponseExceededMaxSizeError';
code: 'UND_ERR_RES_EXCEEDED_MAX_SIZE';
name: 'ResponseExceededMaxSizeError'
code: 'UND_ERR_RES_EXCEEDED_MAX_SIZE'
}
export class RequestRetryError extends UndiciError {
@@ -132,18 +148,24 @@ declare namespace Errors {
statusCode: number,
headers?: IncomingHttpHeaders | string[] | null,
body?: null | Record<string, any> | string
);
name: 'RequestRetryError';
code: 'UND_ERR_REQ_RETRY';
statusCode: number;
)
name: 'RequestRetryError'
code: 'UND_ERR_REQ_RETRY'
statusCode: number
data: {
count: number;
};
headers: Record<string, string | string[]>;
}
headers: Record<string, string | string[]>
}
export class SecureProxyConnectionError extends UndiciError {
name: 'SecureProxyConnectionError';
code: 'UND_ERR_PRX_TLS';
constructor (
cause?: Error,
message?: string,
options?: Record<any, any>
)
name: 'SecureProxyConnectionError'
code: 'UND_ERR_PRX_TLS'
}
}

View File

@@ -2,8 +2,6 @@ import { MessageEvent, ErrorEvent } from './websocket'
import Dispatcher from './dispatcher'
import {
EventTarget,
Event,
EventListenerOptions,
AddEventListenerOptions,
EventListenerOrEventListenerObject

37
node_modules/undici-types/fetch.d.ts generated vendored
View File

@@ -6,7 +6,7 @@ import { Blob } from 'buffer'
import { URL, URLSearchParams } from 'url'
import { ReadableStream } from 'stream/web'
import { FormData } from './formdata'
import { HeaderRecord } from './header'
import Dispatcher from './dispatcher'
export type RequestInfo = string | URL | Request
@@ -36,17 +36,17 @@ export class BodyMixin {
/**
* @deprecated This method is not recommended for parsing multipart/form-data bodies in server environments.
* It is recommended to use a library such as [@fastify/busboy](https://www.npmjs.com/package/@fastify/busboy) as follows:
*
*
* @example
* ```js
* import { Busboy } from '@fastify/busboy'
* import { Readable } from 'node:stream'
*
*
* const response = await fetch('...')
* const busboy = new Busboy({ headers: { 'content-type': response.headers.get('content-type') } })
*
*
* // handle events emitted from `busboy`
*
*
* Readable.fromWeb(response.body).pipe(busboy)
* ```
*/
@@ -67,7 +67,7 @@ export interface SpecIterable<T> {
[Symbol.iterator](): SpecIterator<T>;
}
export type HeadersInit = string[][] | Record<string, string | ReadonlyArray<string>> | Headers
export type HeadersInit = [string, string][] | HeaderRecord | Headers
export declare class Headers implements SpecIterable<[string, string]> {
constructor (init?: HeadersInit)
@@ -119,20 +119,21 @@ type RequestDestination =
| 'xslt'
export interface RequestInit {
method?: string
keepalive?: boolean
headers?: HeadersInit
body?: BodyInit | null
redirect?: RequestRedirect
integrity?: string
signal?: AbortSignal | null
cache?: RequestCache
credentials?: RequestCredentials
mode?: RequestMode
referrer?: string
referrerPolicy?: ReferrerPolicy
window?: null
dispatcher?: Dispatcher
duplex?: RequestDuplex
headers?: HeadersInit
integrity?: string
keepalive?: boolean
method?: string
mode?: RequestMode
redirect?: RequestRedirect
referrer?: string
referrerPolicy?: ReferrerPolicy
signal?: AbortSignal | null
window?: null
}
export type ReferrerPolicy =
@@ -144,7 +145,7 @@ export type ReferrerPolicy =
| 'same-origin'
| 'strict-origin'
| 'strict-origin-when-cross-origin'
| 'unsafe-url';
| 'unsafe-url'
export type RequestMode = 'cors' | 'navigate' | 'no-cors' | 'same-origin'
@@ -204,6 +205,6 @@ export declare class Response extends BodyMixin {
readonly clone: () => Response
static error (): Response
static json(data: any, init?: ResponseInit): Response
static json (data: any, init?: ResponseInit): Response
static redirect (url: string | URL, status: ResponseRedirectStatus): Response
}

39
node_modules/undici-types/file.d.ts generated vendored
View File

@@ -1,39 +0,0 @@
// Based on https://github.com/octet-stream/form-data/blob/2d0f0dc371517444ce1f22cdde13f51995d0953a/lib/File.ts (MIT)
/// <reference types="node" />
import { Blob } from 'buffer'
export interface BlobPropertyBag {
type?: string
endings?: 'native' | 'transparent'
}
export interface FilePropertyBag extends BlobPropertyBag {
/**
* The last modified date of the file as the number of milliseconds since the Unix epoch (January 1, 1970 at midnight). Files without a known last modified date return the current date.
*/
lastModified?: number
}
export declare class File extends Blob {
/**
* Creates a new File instance.
*
* @param fileBits An `Array` strings, or [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer), [`ArrayBufferView`](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView), [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) objects, or a mix of any of such objects, that will be put inside the [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File).
* @param fileName The name of the file.
* @param options An options object containing optional attributes for the file.
*/
constructor(fileBits: ReadonlyArray<string | NodeJS.ArrayBufferView | Blob>, fileName: string, options?: FilePropertyBag)
/**
* Name of the file referenced by the File object.
*/
readonly name: string
/**
* The last modified date of the file as the number of milliseconds since the Unix epoch (January 1, 1970 at midnight). Files without a known last modified date return the current date.
*/
readonly lastModified: number
readonly [Symbol.toStringTag]: string
}

View File

@@ -1,54 +0,0 @@
/// <reference types="node" />
import { Blob } from 'buffer'
import { DOMException, Event, EventInit, EventTarget } from './patch'
export declare class FileReader {
__proto__: EventTarget & FileReader
constructor ()
readAsArrayBuffer (blob: Blob): void
readAsBinaryString (blob: Blob): void
readAsText (blob: Blob, encoding?: string): void
readAsDataURL (blob: Blob): void
abort (): void
static readonly EMPTY = 0
static readonly LOADING = 1
static readonly DONE = 2
readonly EMPTY = 0
readonly LOADING = 1
readonly DONE = 2
readonly readyState: number
readonly result: string | ArrayBuffer | null
readonly error: DOMException | null
onloadstart: null | ((this: FileReader, event: ProgressEvent) => void)
onprogress: null | ((this: FileReader, event: ProgressEvent) => void)
onload: null | ((this: FileReader, event: ProgressEvent) => void)
onabort: null | ((this: FileReader, event: ProgressEvent) => void)
onerror: null | ((this: FileReader, event: ProgressEvent) => void)
onloadend: null | ((this: FileReader, event: ProgressEvent) => void)
}
export interface ProgressEventInit extends EventInit {
lengthComputable?: boolean
loaded?: number
total?: number
}
export declare class ProgressEvent {
__proto__: Event & ProgressEvent
constructor (type: string, eventInitDict?: ProgressEventInit)
readonly lengthComputable: boolean
readonly loaded: number
readonly total: number
}

View File

@@ -1,7 +1,7 @@
// Based on https://github.com/octet-stream/form-data/blob/2d0f0dc371517444ce1f22cdde13f51995d0953a/lib/FormData.ts (MIT)
/// <reference types="node" />
import { File } from './file'
import { File } from 'buffer'
import { SpecIterableIterator } from './fetch'
/**
@@ -24,7 +24,7 @@ export declare class FormData {
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.
* @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.
*/
append(name: string, value: unknown, fileName?: string): void
append (name: string, value: unknown, fileName?: string): void
/**
* Set a new value for an existing key inside FormData,
@@ -36,7 +36,7 @@ export declare class FormData {
* @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.
*
*/
set(name: string, value: unknown, fileName?: string): void
set (name: string, value: unknown, fileName?: string): void
/**
* Returns the first value associated with a given key from within a `FormData` object.
@@ -46,7 +46,7 @@ export declare class FormData {
*
* @returns A `FormDataEntryValue` containing the value. If the key doesn't exist, the method returns null.
*/
get(name: string): FormDataEntryValue | null
get (name: string): FormDataEntryValue | null
/**
* Returns all the values associated with a given key from within a `FormData` object.
@@ -55,7 +55,7 @@ export declare class FormData {
*
* @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.
*/
getAll(name: string): FormDataEntryValue[]
getAll (name: string): FormDataEntryValue[]
/**
* Returns a boolean stating whether a `FormData` object contains a certain key.
@@ -64,14 +64,14 @@ export declare class FormData {
*
* @return A boolean value.
*/
has(name: string): boolean
has (name: string): boolean
/**
* Deletes a key and its value(s) from a `FormData` object.
*
* @param name The name of the key you want to delete.
*/
delete(name: string): void
delete (name: string): void
/**
* Executes given callback function for each field of the FormData instance

View File

@@ -1,9 +1,9 @@
import Dispatcher from "./dispatcher";
import Dispatcher from './dispatcher'
declare function setGlobalDispatcher<DispatcherImplementation extends Dispatcher> (dispatcher: DispatcherImplementation): void
declare function getGlobalDispatcher (): Dispatcher
export {
getGlobalDispatcher,
setGlobalDispatcher
}
declare function setGlobalDispatcher<DispatcherImplementation extends Dispatcher>(dispatcher: DispatcherImplementation): void;
declare function getGlobalDispatcher(): Dispatcher;

View File

@@ -1,7 +1,7 @@
declare function setGlobalOrigin (origin: string | URL | undefined): void
declare function getGlobalOrigin (): URL | undefined
export {
setGlobalOrigin,
getGlobalOrigin
setGlobalOrigin,
getGlobalOrigin
}
declare function setGlobalOrigin(origin: string | URL | undefined): void;
declare function getGlobalOrigin(): URL | undefined;

View File

@@ -1,15 +1,15 @@
import Dispatcher from "./dispatcher";
import Dispatcher from './dispatcher'
export declare class RedirectHandler implements Dispatcher.DispatchHandlers {
constructor(
export declare class RedirectHandler implements Dispatcher.DispatchHandler {
constructor (
dispatch: Dispatcher,
maxRedirections: number,
opts: Dispatcher.DispatchOptions,
handler: Dispatcher.DispatchHandlers,
handler: Dispatcher.DispatchHandler,
redirectionLimitReached: boolean
);
)
}
export declare class DecoratorHandler implements Dispatcher.DispatchHandlers {
constructor(handler: Dispatcher.DispatchHandlers);
export declare class DecoratorHandler implements Dispatcher.DispatchHandler {
constructor (handler: Dispatcher.DispatchHandler)
}

158
node_modules/undici-types/header.d.ts generated vendored
View File

@@ -1,4 +1,160 @@
import { Autocomplete } from './utility'
/**
* The header type declaration of `undici`.
*/
export type IncomingHttpHeaders = Record<string, string | string[] | undefined>;
export type IncomingHttpHeaders = Record<string, string | string[] | undefined>
type HeaderNames = Autocomplete<
| 'Accept'
| 'Accept-CH'
| 'Accept-Charset'
| 'Accept-Encoding'
| 'Accept-Language'
| 'Accept-Patch'
| 'Accept-Post'
| 'Accept-Ranges'
| 'Access-Control-Allow-Credentials'
| 'Access-Control-Allow-Headers'
| 'Access-Control-Allow-Methods'
| 'Access-Control-Allow-Origin'
| 'Access-Control-Expose-Headers'
| 'Access-Control-Max-Age'
| 'Access-Control-Request-Headers'
| 'Access-Control-Request-Method'
| 'Age'
| 'Allow'
| 'Alt-Svc'
| 'Alt-Used'
| 'Authorization'
| 'Cache-Control'
| 'Clear-Site-Data'
| 'Connection'
| 'Content-Disposition'
| 'Content-Encoding'
| 'Content-Language'
| 'Content-Length'
| 'Content-Location'
| 'Content-Range'
| 'Content-Security-Policy'
| 'Content-Security-Policy-Report-Only'
| 'Content-Type'
| 'Cookie'
| 'Cross-Origin-Embedder-Policy'
| 'Cross-Origin-Opener-Policy'
| 'Cross-Origin-Resource-Policy'
| 'Date'
| 'Device-Memory'
| 'ETag'
| 'Expect'
| 'Expect-CT'
| 'Expires'
| 'Forwarded'
| 'From'
| 'Host'
| 'If-Match'
| 'If-Modified-Since'
| 'If-None-Match'
| 'If-Range'
| 'If-Unmodified-Since'
| 'Keep-Alive'
| 'Last-Modified'
| 'Link'
| 'Location'
| 'Max-Forwards'
| 'Origin'
| 'Permissions-Policy'
| 'Priority'
| 'Proxy-Authenticate'
| 'Proxy-Authorization'
| 'Range'
| 'Referer'
| 'Referrer-Policy'
| 'Retry-After'
| 'Sec-Fetch-Dest'
| 'Sec-Fetch-Mode'
| 'Sec-Fetch-Site'
| 'Sec-Fetch-User'
| 'Sec-Purpose'
| 'Sec-WebSocket-Accept'
| 'Server'
| 'Server-Timing'
| 'Service-Worker-Navigation-Preload'
| 'Set-Cookie'
| 'SourceMap'
| 'Strict-Transport-Security'
| 'TE'
| 'Timing-Allow-Origin'
| 'Trailer'
| 'Transfer-Encoding'
| 'Upgrade'
| 'Upgrade-Insecure-Requests'
| 'User-Agent'
| 'Vary'
| 'Via'
| 'WWW-Authenticate'
| 'X-Content-Type-Options'
| 'X-Frame-Options'
>
type IANARegisteredMimeType = Autocomplete<
| 'audio/aac'
| 'video/x-msvideo'
| 'image/avif'
| 'video/av1'
| 'application/octet-stream'
| 'image/bmp'
| 'text/css'
| 'text/csv'
| 'application/vnd.ms-fontobject'
| 'application/epub+zip'
| 'image/gif'
| 'application/gzip'
| 'text/html'
| 'image/x-icon'
| 'text/calendar'
| 'image/jpeg'
| 'text/javascript'
| 'application/json'
| 'application/ld+json'
| 'audio/x-midi'
| 'audio/mpeg'
| 'video/mp4'
| 'video/mpeg'
| 'audio/ogg'
| 'video/ogg'
| 'application/ogg'
| 'audio/opus'
| 'font/otf'
| 'application/pdf'
| 'image/png'
| 'application/rtf'
| 'image/svg+xml'
| 'image/tiff'
| 'video/mp2t'
| 'font/ttf'
| 'text/plain'
| 'application/wasm'
| 'video/webm'
| 'audio/webm'
| 'image/webp'
| 'font/woff'
| 'font/woff2'
| 'application/xhtml+xml'
| 'application/xml'
| 'application/zip'
| 'video/3gpp'
| 'video/3gpp2'
| 'model/gltf+json'
| 'model/gltf-binary'
>
type KnownHeaderValues = {
'content-type': IANARegisteredMimeType
}
export type HeaderRecord = {
[K in HeaderNames | Lowercase<HeaderNames>]?: Lowercase<K> extends keyof KnownHeaderValues
? KnownHeaderValues[Lowercase<K>]
: string
}

98
node_modules/undici-types/index.d.ts generated vendored
View File

@@ -1,22 +1,24 @@
import Dispatcher from'./dispatcher'
import Dispatcher from './dispatcher'
import { setGlobalDispatcher, getGlobalDispatcher } from './global-dispatcher'
import { setGlobalOrigin, getGlobalOrigin } from './global-origin'
import Pool from'./pool'
import Pool from './pool'
import { RedirectHandler, DecoratorHandler } from './handlers'
import BalancedPool from './balanced-pool'
import Client from'./client'
import buildConnector from'./connector'
import errors from'./errors'
import Agent from'./agent'
import MockClient from'./mock-client'
import MockPool from'./mock-pool'
import MockAgent from'./mock-agent'
import mockErrors from'./mock-errors'
import ProxyAgent from'./proxy-agent'
import Client from './client'
import H2CClient from './h2c-client'
import buildConnector from './connector'
import errors from './errors'
import Agent from './agent'
import MockClient from './mock-client'
import MockPool from './mock-pool'
import MockAgent from './mock-agent'
import { MockCallHistory, MockCallHistoryLog } from './mock-call-history'
import mockErrors from './mock-errors'
import ProxyAgent from './proxy-agent'
import EnvHttpProxyAgent from './env-http-proxy-agent'
import RetryHandler from'./retry-handler'
import RetryAgent from'./retry-agent'
import RetryHandler from './retry-handler'
import RetryAgent from './retry-agent'
import { request, pipeline, stream, connect, upgrade } from './api'
import interceptors from './interceptors'
@@ -24,8 +26,6 @@ export * from './util'
export * from './cookies'
export * from './eventsource'
export * from './fetch'
export * from './file'
export * from './filereader'
export * from './formdata'
export * from './diagnostics-channel'
export * from './websocket'
@@ -33,39 +33,43 @@ export * from './content-type'
export * from './cache'
export { Interceptable } from './mock-interceptor'
export { Dispatcher, BalancedPool, Pool, Client, buildConnector, errors, Agent, request, stream, pipeline, connect, upgrade, setGlobalDispatcher, getGlobalDispatcher, setGlobalOrigin, getGlobalOrigin, interceptors, MockClient, MockPool, MockAgent, mockErrors, ProxyAgent, EnvHttpProxyAgent, RedirectHandler, DecoratorHandler, RetryHandler, RetryAgent }
export { Dispatcher, BalancedPool, Pool, Client, buildConnector, errors, Agent, request, stream, pipeline, connect, upgrade, setGlobalDispatcher, getGlobalDispatcher, setGlobalOrigin, getGlobalOrigin, interceptors, MockClient, MockPool, MockAgent, MockCallHistory, MockCallHistoryLog, mockErrors, ProxyAgent, EnvHttpProxyAgent, RedirectHandler, DecoratorHandler, RetryHandler, RetryAgent, H2CClient }
export default Undici
declare namespace Undici {
var Dispatcher: typeof import('./dispatcher').default
var Pool: typeof import('./pool').default;
var RedirectHandler: typeof import ('./handlers').RedirectHandler
var DecoratorHandler: typeof import ('./handlers').DecoratorHandler
var RetryHandler: typeof import ('./retry-handler').default
var createRedirectInterceptor: typeof import ('./interceptors').default.createRedirectInterceptor
var BalancedPool: typeof import('./balanced-pool').default;
var Client: typeof import('./client').default;
var buildConnector: typeof import('./connector').default;
var errors: typeof import('./errors').default;
var Agent: typeof import('./agent').default;
var setGlobalDispatcher: typeof import('./global-dispatcher').setGlobalDispatcher;
var getGlobalDispatcher: typeof import('./global-dispatcher').getGlobalDispatcher;
var request: typeof import('./api').request;
var stream: typeof import('./api').stream;
var pipeline: typeof import('./api').pipeline;
var connect: typeof import('./api').connect;
var upgrade: typeof import('./api').upgrade;
var MockClient: typeof import('./mock-client').default;
var MockPool: typeof import('./mock-pool').default;
var MockAgent: typeof import('./mock-agent').default;
var mockErrors: typeof import('./mock-errors').default;
var fetch: typeof import('./fetch').fetch;
var Headers: typeof import('./fetch').Headers;
var Response: typeof import('./fetch').Response;
var Request: typeof import('./fetch').Request;
var FormData: typeof import('./formdata').FormData;
var File: typeof import('./file').File;
var FileReader: typeof import('./filereader').FileReader;
var caches: typeof import('./cache').caches;
var interceptors: typeof import('./interceptors').default;
const Dispatcher: typeof import('./dispatcher').default
const Pool: typeof import('./pool').default
const RedirectHandler: typeof import ('./handlers').RedirectHandler
const DecoratorHandler: typeof import ('./handlers').DecoratorHandler
const RetryHandler: typeof import ('./retry-handler').default
const BalancedPool: typeof import('./balanced-pool').default
const Client: typeof import('./client').default
const H2CClient: typeof import('./h2c-client').default
const buildConnector: typeof import('./connector').default
const errors: typeof import('./errors').default
const Agent: typeof import('./agent').default
const setGlobalDispatcher: typeof import('./global-dispatcher').setGlobalDispatcher
const getGlobalDispatcher: typeof import('./global-dispatcher').getGlobalDispatcher
const request: typeof import('./api').request
const stream: typeof import('./api').stream
const pipeline: typeof import('./api').pipeline
const connect: typeof import('./api').connect
const upgrade: typeof import('./api').upgrade
const MockClient: typeof import('./mock-client').default
const MockPool: typeof import('./mock-pool').default
const MockAgent: typeof import('./mock-agent').default
const MockCallHistory: typeof import('./mock-call-history').MockCallHistory
const MockCallHistoryLog: typeof import('./mock-call-history').MockCallHistoryLog
const mockErrors: typeof import('./mock-errors').default
const fetch: typeof import('./fetch').fetch
const Headers: typeof import('./fetch').Headers
const Response: typeof import('./fetch').Response
const Request: typeof import('./fetch').Request
const FormData: typeof import('./formdata').FormData
const caches: typeof import('./cache').caches
const interceptors: typeof import('./interceptors').default
const cacheStores: {
MemoryCacheStore: typeof import('./cache-interceptor').default.MemoryCacheStore,
SqliteCacheStore: typeof import('./cache-interceptor').default.SqliteCacheStore
}
}

View File

@@ -1,15 +1,34 @@
import Dispatcher from "./dispatcher";
import RetryHandler from "./retry-handler";
import CacheHandler from './cache-interceptor'
import Dispatcher from './dispatcher'
import RetryHandler from './retry-handler'
import { LookupOptions } from 'node:dns'
export default Interceptors;
export default Interceptors
declare namespace Interceptors {
export type DumpInterceptorOpts = { maxSize?: number }
export type RetryInterceptorOpts = RetryHandler.RetryOptions
export type RedirectInterceptorOpts = { maxRedirections?: number }
export function createRedirectInterceptor(opts: RedirectInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
export function dump(opts?: DumpInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
export function retry(opts?: RetryInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
export function redirect(opts?: RedirectInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
export type ResponseErrorInterceptorOpts = { throwOnError: boolean }
export type CacheInterceptorOpts = CacheHandler.CacheOptions
// DNS interceptor
export type DNSInterceptorRecord = { address: string, ttl: number, family: 4 | 6 }
export type DNSInterceptorOriginRecords = { 4: { ips: DNSInterceptorRecord[] } | null, 6: { ips: DNSInterceptorRecord[] } | null }
export type DNSInterceptorOpts = {
maxTTL?: number
maxItems?: number
lookup?: (hostname: string, options: LookupOptions, callback: (err: NodeJS.ErrnoException | null, addresses: DNSInterceptorRecord[]) => void) => void
pick?: (origin: URL, records: DNSInterceptorOriginRecords, affinity: 4 | 6) => DNSInterceptorRecord
dualStack?: boolean
affinity?: 4 | 6
}
export function dump (opts?: DumpInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
export function retry (opts?: RetryInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
export function redirect (opts?: RedirectInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
export function responseError (opts?: ResponseErrorInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
export function dns (opts?: DNSInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
export function cache (opts?: CacheInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
}

View File

@@ -1,7 +1,8 @@
import Agent from './agent'
import Dispatcher from './dispatcher'
import { Interceptable, MockInterceptor } from './mock-interceptor'
import MockDispatch = MockInterceptor.MockDispatch;
import MockDispatch = MockInterceptor.MockDispatch
import { MockCallHistory } from './mock-call-history'
export default MockAgent
@@ -11,30 +12,38 @@ interface PendingInterceptor extends MockDispatch {
/** A mocked Agent class that implements the Agent API. It allows one to intercept HTTP requests made through undici and return mocked responses instead. */
declare class MockAgent<TMockAgentOptions extends MockAgent.Options = MockAgent.Options> extends Dispatcher {
constructor(options?: MockAgent.Options)
constructor (options?: TMockAgentOptions)
/** 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. */
get<TInterceptable extends Interceptable>(origin: string): TInterceptable;
get<TInterceptable extends Interceptable>(origin: RegExp): TInterceptable;
get<TInterceptable extends Interceptable>(origin: ((origin: string) => boolean)): TInterceptable;
get<TInterceptable extends Interceptable>(origin: string): TInterceptable
get<TInterceptable extends Interceptable>(origin: RegExp): TInterceptable
get<TInterceptable extends Interceptable>(origin: ((origin: string) => boolean)): TInterceptable
/** Dispatches a mocked request. */
dispatch(options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandlers): boolean;
dispatch (options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandler): boolean
/** Closes the mock agent and waits for registered mock pools and clients to also close before resolving. */
close(): Promise<void>;
close (): Promise<void>
/** Disables mocking in MockAgent. */
deactivate(): void;
deactivate (): void
/** 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. */
activate(): void;
activate (): void
/** Define host matchers so only matching requests that aren't intercepted by the mock dispatchers will be attempted. */
enableNetConnect(): void;
enableNetConnect(host: string): void;
enableNetConnect(host: RegExp): void;
enableNetConnect(host: ((host: string) => boolean)): void;
enableNetConnect (): void
enableNetConnect (host: string): void
enableNetConnect (host: RegExp): void
enableNetConnect (host: ((host: string) => boolean)): void
/** Causes all requests to throw when requests are not matched in a MockAgent intercept. */
disableNetConnect(): void;
pendingInterceptors(): PendingInterceptor[];
assertNoPendingInterceptors(options?: {
disableNetConnect (): void
/** get call history. returns the MockAgent call history or undefined if the option is not enabled. */
getCallHistory (): MockCallHistory | undefined
/** clear every call history. Any MockCallHistoryLog will be deleted on the MockCallHistory instance */
clearCallHistory (): void
/** Enable call history. Any subsequence calls will then be registered. */
enableCallHistory (): this
/** Disable call history. Any subsequence calls will then not be registered. */
disableCallHistory (): this
pendingInterceptors (): PendingInterceptor[]
assertNoPendingInterceptors (options?: {
pendingInterceptorsFormatter?: PendingInterceptorsFormatter;
}): void;
}): void
}
interface PendingInterceptorsFormatter {
@@ -45,6 +54,12 @@ declare namespace MockAgent {
/** MockAgent options. */
export interface Options extends Agent.Options {
/** A custom agent to be encapsulated by the MockAgent. */
agent?: Agent;
agent?: Dispatcher;
/** Ignore trailing slashes in the path */
ignoreTrailingSlash?: boolean;
/** Enable call history. you can either call MockAgent.enableCallHistory(). default false */
enableCallHistory?: boolean
}
}

View File

@@ -7,13 +7,13 @@ export default MockClient
/** MockClient extends the Client API and allows one to mock requests. */
declare class MockClient extends Client implements Interceptable {
constructor(origin: string, options: MockClient.Options);
constructor (origin: string, options: MockClient.Options)
/** Intercepts any matching requests that use the same origin as this mock client. */
intercept(options: MockInterceptor.Options): MockInterceptor;
intercept (options: MockInterceptor.Options): MockInterceptor
/** Dispatches a mocked request. */
dispatch(options: Dispatcher.DispatchOptions, handlers: Dispatcher.DispatchHandlers): boolean;
dispatch (options: Dispatcher.DispatchOptions, handlers: Dispatcher.DispatchHandler): boolean
/** Closes the mock client and gracefully waits for enqueued requests to complete. */
close(): Promise<void>;
close (): Promise<void>
}
declare namespace MockClient {

View File

@@ -5,8 +5,8 @@ export default MockErrors
declare namespace MockErrors {
/** The request does not match any registered mock dispatches. */
export class MockNotMatchedError extends Errors.UndiciError {
constructor(message?: string);
name: 'MockNotMatchedError';
code: 'UND_MOCK_ERR_MOCK_NOT_MATCHED';
constructor (message?: string)
name: 'MockNotMatchedError'
code: 'UND_MOCK_ERR_MOCK_NOT_MATCHED'
}
}

View File

@@ -1,42 +1,36 @@
import { IncomingHttpHeaders } from './header'
import Dispatcher from './dispatcher';
import Dispatcher from './dispatcher'
import { BodyInit, Headers } from './fetch'
export {
Interceptable,
MockInterceptor,
MockScope
}
/** The scope associated with a mock dispatch. */
declare class MockScope<TData extends object = object> {
constructor(mockDispatch: MockInterceptor.MockDispatch<TData>);
constructor (mockDispatch: MockInterceptor.MockDispatch<TData>)
/** Delay a reply by a set amount of time in ms. */
delay(waitInMs: number): MockScope<TData>;
delay (waitInMs: number): MockScope<TData>
/** Persist the defined mock data for the associated reply. It will return the defined mock data indefinitely. */
persist(): MockScope<TData>;
persist (): MockScope<TData>
/** Define a reply for a set amount of matching requests. */
times(repeatTimes: number): MockScope<TData>;
times (repeatTimes: number): MockScope<TData>
}
/** The interceptor for a Mock. */
declare class MockInterceptor {
constructor(options: MockInterceptor.Options, mockDispatches: MockInterceptor.MockDispatch[]);
constructor (options: MockInterceptor.Options, mockDispatches: MockInterceptor.MockDispatch[])
/** Mock an undici request with the defined reply. */
reply<TData extends object = object>(replyOptionsCallback: MockInterceptor.MockReplyOptionsCallback<TData>): MockScope<TData>;
reply<TData extends object = object>(replyOptionsCallback: MockInterceptor.MockReplyOptionsCallback<TData>): MockScope<TData>
reply<TData extends object = object>(
statusCode: number,
data?: TData | Buffer | string | MockInterceptor.MockResponseDataHandler<TData>,
responseOptions?: MockInterceptor.MockResponseOptions
): MockScope<TData>;
): MockScope<TData>
/** Mock an undici request by throwing the defined reply error. */
replyWithError<TError extends Error = Error>(error: TError): MockScope;
replyWithError<TError extends Error = Error>(error: TError): MockScope
/** Set default reply headers on the interceptor for subsequent mocked replies. */
defaultReplyHeaders(headers: IncomingHttpHeaders): MockInterceptor;
defaultReplyHeaders (headers: IncomingHttpHeaders): MockInterceptor
/** Set default reply trailers on the interceptor for subsequent mocked replies. */
defaultReplyTrailers(trailers: Record<string, string>): MockInterceptor;
defaultReplyTrailers (trailers: Record<string, string>): MockInterceptor
/** Set automatically calculated content-length header on subsequent mocked replies. */
replyContentLength(): MockInterceptor;
replyContentLength (): MockInterceptor
}
declare namespace MockInterceptor {
@@ -80,7 +74,7 @@ declare namespace MockInterceptor {
export type MockResponseDataHandler<TData extends object = object> = (
opts: MockResponseCallbackOptions
) => TData | Buffer | string;
) => TData | Buffer | string
export type MockReplyOptionsCallback<TData extends object = object> = (
opts: MockResponseCallbackOptions
@@ -91,3 +85,9 @@ interface Interceptable extends Dispatcher {
/** Intercepts any matching requests that use the same origin as this mock client. */
intercept(options: MockInterceptor.Options): MockInterceptor;
}
export {
Interceptable,
MockInterceptor,
MockScope
}

View File

@@ -7,13 +7,13 @@ export default MockPool
/** MockPool extends the Pool API and allows one to mock requests. */
declare class MockPool extends Pool implements Interceptable {
constructor(origin: string, options: MockPool.Options);
constructor (origin: string, options: MockPool.Options)
/** Intercepts any matching requests that use the same origin as this mock pool. */
intercept(options: MockInterceptor.Options): MockInterceptor;
intercept (options: MockInterceptor.Options): MockInterceptor
/** Dispatches a mocked request. */
dispatch(options: Dispatcher.DispatchOptions, handlers: Dispatcher.DispatchHandlers): boolean;
dispatch (options: Dispatcher.DispatchOptions, handlers: Dispatcher.DispatchHandler): boolean
/** Closes the mock pool and gracefully waits for enqueued requests to complete. */
close(): Promise<void>;
close (): Promise<void>
}
declare namespace MockPool {

View File

@@ -1,6 +1,6 @@
{
"name": "undici-types",
"version": "6.19.8",
"version": "7.8.0",
"description": "A stand-alone types package for Undici",
"homepage": "https://undici.nodejs.org",
"bugs": {

42
node_modules/undici-types/patch.d.ts generated vendored
View File

@@ -2,48 +2,6 @@
// See https://github.com/nodejs/undici/issues/1740
export type DOMException = typeof globalThis extends { DOMException: infer T }
? T
: any
export type EventTarget = typeof globalThis extends { EventTarget: infer T }
? T
: {
addEventListener(
type: string,
listener: any,
options?: any,
): void
dispatchEvent(event: Event): boolean
removeEventListener(
type: string,
listener: any,
options?: any | boolean,
): void
}
export type Event = typeof globalThis extends { Event: infer T }
? T
: {
readonly bubbles: boolean
cancelBubble: () => void
readonly cancelable: boolean
readonly composed: boolean
composedPath(): [EventTarget?]
readonly currentTarget: EventTarget | null
readonly defaultPrevented: boolean
readonly eventPhase: 0 | 2
readonly isTrusted: boolean
preventDefault(): void
returnValue: boolean
readonly srcElement: EventTarget | null
stopImmediatePropagation(): void
stopPropagation(): void
readonly target: EventTarget | null
readonly timeStamp: number
readonly type: string
}
export interface EventInit {
bubbles?: boolean
cancelable?: boolean

View File

@@ -1,19 +1,19 @@
import Pool from "./pool"
import Pool from './pool'
export default PoolStats
declare class PoolStats {
constructor(pool: Pool);
constructor (pool: Pool)
/** Number of open socket connections in this pool. */
connected: number;
connected: number
/** Number of open socket connections in this pool that do not have an active request. */
free: number;
free: number
/** Number of pending requests across all clients in this pool. */
pending: number;
pending: number
/** Number of queued requests across all clients in this pool. */
queued: number;
queued: number
/** Number of currently active requests across all clients in this pool. */
running: number;
running: number
/** Number of active, pending, or queued requests across all clients in this pool. */
size: number;
size: number
}

24
node_modules/undici-types/pool.d.ts generated vendored
View File

@@ -1,39 +1,39 @@
import Client from './client'
import TPoolStats from './pool-stats'
import { URL } from 'url'
import Dispatcher from "./dispatcher";
import Dispatcher from './dispatcher'
export default Pool
type PoolConnectOptions = Omit<Dispatcher.ConnectOptions, "origin">;
type PoolConnectOptions = Omit<Dispatcher.ConnectOptions, 'origin'>
declare class Pool extends Dispatcher {
constructor(url: string | URL, options?: Pool.Options)
constructor (url: string | URL, options?: Pool.Options)
/** `true` after `pool.close()` has been called. */
closed: boolean;
closed: boolean
/** `true` after `pool.destroyed()` has been called or `pool.close()` has been called and the pool shutdown has completed. */
destroyed: boolean;
destroyed: boolean
/** Aggregate stats for a Pool. */
readonly stats: TPoolStats;
readonly stats: TPoolStats
// Override dispatcher APIs.
override connect(
override connect (
options: PoolConnectOptions
): Promise<Dispatcher.ConnectData>;
override connect(
): Promise<Dispatcher.ConnectData>
override connect (
options: PoolConnectOptions,
callback: (err: Error | null, data: Dispatcher.ConnectData) => void
): void;
): void
}
declare namespace Pool {
export type PoolStats = TPoolStats;
export type PoolStats = TPoolStats
export interface Options extends Client.Options {
/** Default: `(origin, opts) => new Client(origin, opts)`. */
factory?(origin: URL, opts: object): Dispatcher;
/** The max number of clients to create. `null` if no limit. Default `null`. */
connections?: number | null;
interceptors?: { Pool?: readonly Dispatcher.DispatchInterceptor[] } & Client.Options["interceptors"]
interceptors?: { Pool?: readonly Dispatcher.DispatchInterceptor[] } & Client.Options['interceptors']
}
}

View File

@@ -1,15 +1,15 @@
import Agent from './agent'
import buildConnector from './connector';
import buildConnector from './connector'
import Dispatcher from './dispatcher'
import { IncomingHttpHeaders } from './header'
export default ProxyAgent
declare class ProxyAgent extends Dispatcher {
constructor(options: ProxyAgent.Options | string)
constructor (options: ProxyAgent.Options | string)
dispatch(options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandlers): boolean;
close(): Promise<void>;
dispatch (options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandler): boolean
close (): Promise<void>
}
declare namespace ProxyAgent {

View File

@@ -1,40 +1,47 @@
import { Readable } from "stream";
import { Readable } from 'stream'
import { Blob } from 'buffer'
export default BodyReadable
declare class BodyReadable extends Readable {
constructor(
resume?: (this: Readable, size: number) => void | null,
abort?: () => void | null,
contentType?: string
)
constructor (opts: {
resume: (this: Readable, size: number) => void | null;
abort: () => void | null;
contentType?: string;
contentLength?: number;
highWaterMark?: number;
})
/** Consumes and returns the body as a string
* https://fetch.spec.whatwg.org/#dom-body-text
*/
text(): Promise<string>
text (): Promise<string>
/** Consumes and returns the body as a JavaScript Object
* https://fetch.spec.whatwg.org/#dom-body-json
*/
json(): Promise<unknown>
json (): Promise<unknown>
/** Consumes and returns the body as a Blob
* https://fetch.spec.whatwg.org/#dom-body-blob
*/
blob(): Promise<Blob>
blob (): Promise<Blob>
/** Consumes and returns the body as an Uint8Array
* https://fetch.spec.whatwg.org/#dom-body-bytes
*/
bytes (): Promise<Uint8Array>
/** Consumes and returns the body as an ArrayBuffer
* https://fetch.spec.whatwg.org/#dom-body-arraybuffer
*/
arrayBuffer(): Promise<ArrayBuffer>
arrayBuffer (): Promise<ArrayBuffer>
/** Not implemented
*
* https://fetch.spec.whatwg.org/#dom-body-formdata
*/
formData(): Promise<never>
formData (): Promise<never>
/** Returns true if the body is not null and the body has been consumed
*
@@ -44,7 +51,7 @@ declare class BodyReadable extends Readable {
*/
readonly bodyUsed: boolean
/**
/**
* If body is null, it should return null as the body
*
* If body is not null, should return the body as a ReadableStream
@@ -54,7 +61,8 @@ declare class BodyReadable extends Readable {
readonly body: never | undefined
/** Dumps the response body by reading `limit` number of bytes.
* @param opts.limit Number of bytes to read (optional) - Default: 262144
* @param opts.limit Number of bytes to read (optional) - Default: 131072
* @param opts.signal AbortSignal to cancel the operation (optional)
*/
dump(opts?: { limit: number }): Promise<void>
dump (opts?: { limit: number; signal?: AbortSignal }): Promise<void>
}

View File

@@ -4,5 +4,5 @@ import RetryHandler from './retry-handler'
export default RetryAgent
declare class RetryAgent extends Dispatcher {
constructor(dispatcher: Dispatcher, options?: RetryHandler.RetryOptions)
constructor (dispatcher: Dispatcher, options?: RetryHandler.RetryOptions)
}

View File

@@ -1,18 +1,18 @@
import Dispatcher from "./dispatcher";
import Dispatcher from './dispatcher'
export default RetryHandler;
export default RetryHandler
declare class RetryHandler implements Dispatcher.DispatchHandlers {
constructor(
declare class RetryHandler implements Dispatcher.DispatchHandler {
constructor (
options: Dispatcher.DispatchOptions & {
retryOptions?: RetryHandler.RetryOptions;
},
retryHandlers: RetryHandler.RetryHandlers
);
)
}
declare namespace RetryHandler {
export type RetryState = { counter: number; };
export type RetryState = { counter: number; }
export type RetryContext = {
state: RetryState;
@@ -21,7 +21,7 @@ declare namespace RetryHandler {
};
}
export type OnRetryCallback = (result?: Error | null) => void;
export type OnRetryCallback = (result?: Error | null) => void
export type RetryCallback = (
err: Error,
@@ -32,7 +32,7 @@ declare namespace RetryHandler {
};
},
callback: OnRetryCallback
) => number | null;
) => void
export interface RetryOptions {
/**
@@ -110,7 +110,7 @@ declare namespace RetryHandler {
}
export interface RetryHandlers {
dispatch: Dispatcher["dispatch"];
handler: Dispatcher.DispatchHandlers;
dispatch: Dispatcher['dispatch'];
handler: Dispatcher.DispatchHandler;
}
}

View File

@@ -3,7 +3,7 @@ export namespace util {
* Retrieves a header name and returns its lowercase value.
* @param value Header name
*/
export function headerNameToString(value: string | Buffer): string;
export function headerNameToString (value: string | Buffer): string
/**
* Receives a header object and returns the parsed value.
@@ -11,8 +11,8 @@ export namespace util {
* @param obj Object to specify a proxy object. Used to assign parsed values.
* @returns If `obj` is specified, it is equivalent to `obj`.
*/
export function parseHeaders(
export function parseHeaders (
headers: (Buffer | string | (Buffer | string)[])[],
obj?: Record<string, string | string[]>
): Record<string, string | string[]>;
): Record<string, string | string[]>
}

View File

@@ -1,4 +1,5 @@
// These types are not exported, and are only used internally
import * as undici from './index'
/**
* Take in an unknown value and return one that is of type T
@@ -34,11 +35,24 @@ interface WebidlErrors {
}): TypeError
}
interface WebIDLTypes {
UNDEFINED: 1,
BOOLEAN: 2,
STRING: 3,
SYMBOL: 4,
NUMBER: 5,
BIGINT: 6,
NULL: 7
OBJECT: 8
}
interface WebidlUtil {
/**
* @see https://tc39.es/ecma262/#sec-ecmascript-data-types-and-values
*/
Type (object: unknown):
Type (object: unknown): WebIDLTypes[keyof WebIDLTypes]
TypeValueToString (o: unknown):
| 'Undefined'
| 'Boolean'
| 'String'
@@ -48,6 +62,8 @@ interface WebidlUtil {
| 'Null'
| 'Object'
Types: WebIDLTypes
/**
* @see https://webidl.spec.whatwg.org/#abstract-opdef-converttoint
*/
@@ -67,6 +83,14 @@ interface WebidlUtil {
* Stringifies {@param V}
*/
Stringify (V: any): string
MakeTypeAssertion <I>(I: I): (arg: any) => arg is I
/**
* Mark a value as uncloneable for Node.js.
* This is only effective in some newer Node.js versions.
*/
markAsUncloneable (V: any): void
}
interface WebidlConverters {
@@ -150,7 +174,7 @@ interface WebidlConverters {
): NodeJS.TypedArray | ArrayBufferLike | DataView
['sequence<ByteString>']: SequenceConverter<string>
['sequence<sequence<ByteString>>']: SequenceConverter<string[]>
['record<ByteString, ByteString>']: RecordConverter<string, string>
@@ -158,16 +182,35 @@ interface WebidlConverters {
[Key: string]: (...args: any[]) => unknown
}
type IsAssertion<T> = (arg: any) => arg is T
interface WebidlIs {
Request: IsAssertion<undici.Request>
Response: IsAssertion<undici.Response>
ReadableStream: IsAssertion<ReadableStream>
Blob: IsAssertion<Blob>
URLSearchParams: IsAssertion<URLSearchParams>
File: IsAssertion<File>
FormData: IsAssertion<undici.FormData>
URL: IsAssertion<URL>
WebSocketError: IsAssertion<undici.WebSocketError>
AbortSignal: IsAssertion<AbortSignal>
MessagePort: IsAssertion<MessagePort>
}
export interface Webidl {
errors: WebidlErrors
util: WebidlUtil
converters: WebidlConverters
is: WebidlIs
/**
* @description Performs a brand-check on {@param V} to ensure it is a
* {@param cls} object.
*/
brandCheck <Interface>(V: unknown, cls: Interface, opts?: { strict?: boolean }): asserts V is Interface
brandCheck <Interface extends new () => unknown>(V: unknown, cls: Interface): asserts V is Interface
brandCheckMultiple <Interfaces extends (new () => unknown)[]> (list: Interfaces): (V: any) => asserts V is Interfaces[number]
/**
* @see https://webidl.spec.whatwg.org/#es-sequence
@@ -190,10 +233,11 @@ export interface Webidl {
* Similar to {@link Webidl.brandCheck} but allows skipping the check if third party
* interfaces are allowed.
*/
interfaceConverter <Interface>(cls: Interface): (
interfaceConverter <Interface>(typeCheck: IsAssertion<Interface>, name: string): (
V: unknown,
opts?: { strict: boolean }
) => asserts V is typeof cls
prefix: string,
argument: string
) => asserts V is Interface
// TODO(@KhafraDev): a type could likely be implemented that can infer the return type
// from the converters given?

View File

@@ -1,10 +1,9 @@
/// <reference types="node" />
import type { Blob } from 'buffer'
import type { ReadableStream, WritableStream } from 'stream/web'
import type { MessagePort } from 'worker_threads'
import {
EventTarget,
Event,
EventInit,
EventListenerOptions,
AddEventListenerOptions,
@@ -24,7 +23,7 @@ interface WebSocketEventMap {
interface WebSocket extends EventTarget {
binaryType: BinaryType
readonly bufferedAmount: number
readonly extensions: string
@@ -150,3 +149,36 @@ interface WebSocketInit {
dispatcher?: Dispatcher,
headers?: HeadersInit
}
interface WebSocketStreamOptions {
protocols?: string | string[]
signal?: AbortSignal
}
interface WebSocketCloseInfo {
closeCode: number
reason: string
}
interface WebSocketStream {
closed: Promise<WebSocketCloseInfo>
opened: Promise<{
extensions: string
protocol: string
readable: ReadableStream
writable: WritableStream
}>
url: string
}
export declare const WebSocketStream: {
prototype: WebSocketStream
new (url: string | URL, options?: WebSocketStreamOptions): WebSocketStream
}
interface WebSocketError extends Event, WebSocketCloseInfo {}
export declare const WebSocketError: {
prototype: WebSocketError
new (type: string, init?: WebSocketCloseInfo): WebSocketError
}