c455395 ←95e88f6antonApr 9, 2026 api

edit TODO.md via macOS

− deleted list item GitHub mirror for submission: https://github.com/sublimates/...
✎ modified list item todo: PR to obsidianmd/obsidian-releases adding entry to com...
✎ modified list item automated validation + manual review by Obsidian team
✎ modified list item todo: README with screenshots, description, setup instructio...
− deleted heading setup GitHub mirror
✎ modified list item GitHub live mirror: https://github.com/sublimates/obsidian —...
− deleted list item push current code (excluding node_modules)
− deleted list item set up a workflow to mirror from sublimated.com to GitHub (m...
✎ modified list item todo: GitHub release workflow for plugin submission (main.js...
M /sublimated/undefined +1 -7
123 unmodified lines
124
125## submission
126
127- source of truth: https://sublimated.com/sublimated/code/obsidian
128- GitHub mirror for submission: https://github.com/sublimates/obsidian — required for Obsidian community plugins. keep sublimated.com as primary, push to GitHub for releases
129- PR to obsidianmd/obsidian-releases adding entry to community-plugins.json
130- automated validation + manual review
131- README with screenshots, description, setup instructions
128- GitHub live mirror: https://github.com/sublimates/obsidian — live-synced from sublimated.com
129- todo: PR to obsidianmd/obsidian-releases adding entry to community-plugins.json
130- todo: GitHub release workflow for plugin submission (main.js, manifest.json, styles.css as release assets)
131- todo: README with screenshots, description, setup instructions
132- automated validation + manual review by Obsidian team
133
133### setup GitHub mirror
134
135- create repo at https://github.com/sublimates/obsidian
136- push current code (excluding node_modules)
137- set up a workflow to mirror from sublimated.com to GitHub (manual push or automated)
138- add GitHub release workflow for Obsidian plugin submission (main.js, manifest.json, styles.css as release assets)
139
134## promotion
135
136- r/ObsidianMD
137- Obsidian Forum "Share & showcase"
3 unmodified lines
A /sublimated/undefined +49 -0
1{
2 "name": "builtin-modules",
3 "version": "4.0.0",
4 "description": "A static list of the Node.js builtin modules from the latest Node.js version",
5 "license": "MIT",
6 "repository": "sindresorhus/builtin-modules",
7 "funding": "https://github.com/sponsors/sindresorhus",
8 "author": {
9 "name": "Sindre Sorhus",
10 "email": "sindresorhus@gmail.com",
11 "url": "https://sindresorhus.com"
12 },
13 "type": "module",
14 "exports": {
15 "types": "./index.d.ts",
16 "default": "./index.js"
17 },
18 "sideEffects": false,
19 "engines": {
20 "node": ">=18.20"
21 },
22 "scripts": {
23 "//test": "xo && ava && tsd",
24 "test": "ava && tsd",
25 "make": "node make.js"
26 },
27 "files": [
28 "index.js",
29 "index.d.ts",
30 "builtin-modules.json"
31 ],
32 "keywords": [
33 "builtin",
34 "built-in",
35 "builtins",
36 "node",
37 "modules",
38 "core",
39 "bundled",
40 "list",
41 "array",
42 "names"
43 ],
44 "devDependencies": {
45 "ava": "^6.1.2",
46 "tsd": "^0.31.0",
47 "xo": "^0.58.0"
48 }
49}
A /sublimated/undefined +55 -0
1[
2 "assert",
3 "assert/strict",
4 "async_hooks",
5 "buffer",
6 "child_process",
7 "cluster",
8 "console",
9 "constants",
10 "crypto",
11 "dgram",
12 "diagnostics_channel",
13 "dns",
14 "dns/promises",
15 "domain",
16 "events",
17 "fs",
18 "fs/promises",
19 "http",
20 "http2",
21 "https",
22 "inspector",
23 "inspector/promises",
24 "module",
25 "net",
26 "os",
27 "path",
28 "path/posix",
29 "path/win32",
30 "perf_hooks",
31 "process",
32 "punycode",
33 "querystring",
34 "readline",
35 "readline/promises",
36 "repl",
37 "stream",
38 "stream/consumers",
39 "stream/promises",
40 "stream/web",
41 "string_decoder",
42 "timers",
43 "timers/promises",
44 "tls",
45 "trace_events",
46 "tty",
47 "url",
48 "util",
49 "util/types",
50 "v8",
51 "vm",
52 "wasi",
53 "worker_threads",
54 "zlib"
55]
A /sublimated/undefined +9 -0
1MIT License
2
3Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
4
5Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
7The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
9THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
A /sublimated/undefined +32 -0
1# builtin-modules
2
3> A static list of the Node.js builtin modules from the latest Node.js version
4
5The list is just a [JSON file](builtin-modules.json) and can be used anywhere.
6
7## Install
8
9```sh
10npm install builtin-modules
11```
12
13## Usage
14
15```js
16import builtinModules from 'builtin-modules';
17
18console.log(builtinModules);
19//=> ['assert', 'buffer', …]
20```
21
22## Tip
23
24To get a list from the current Node.js version, use the built-in API:
25
26```js
27import {builtinModules} from 'node:module';
28```
29
30## Related
31
32- [is-builtin-module](https://github.com/sindresorhus/is-builtin-module) - Check if a string matches the name of a Node.js builtin module
A /sublimated/undefined +3 -0
1import builtinModules from './builtin-modules.json' with {type: 'json'};
2
3export default builtinModules;
A /sublimated/undefined +209 -0
1// based on https://github.com/Ethan-Arrowood/undici-fetch/blob/249269714db874351589d2d364a0645d5160ae71/index.d.ts (MIT license)
2// and https://github.com/node-fetch/node-fetch/blob/914ce6be5ec67a8bab63d68510aabf07cb818b6d/index.d.ts (MIT license)
3/// <reference types="node" />
4
5import { Blob } from 'buffer'
6import { URL, URLSearchParams } from 'url'
7import { ReadableStream } from 'stream/web'
8import { FormData } from './formdata'
9
10import Dispatcher from './dispatcher'
11
12export type RequestInfo = string | URL | Request
13
14export declare function fetch (
15 input: RequestInfo,
16 init?: RequestInit
17): Promise<Response>
18
19export type BodyInit =
20 | ArrayBuffer
21 | AsyncIterable<Uint8Array>
22 | Blob
23 | FormData
24 | Iterable<Uint8Array>
25 | NodeJS.ArrayBufferView
26 | URLSearchParams
27 | null
28 | string
29
30export class BodyMixin {
31 readonly body: ReadableStream | null
32 readonly bodyUsed: boolean
33
34 readonly arrayBuffer: () => Promise<ArrayBuffer>
35 readonly blob: () => Promise<Blob>
36 /**
37 * @deprecated This method is not recommended for parsing multipart/form-data bodies in server environments.
38 * It is recommended to use a library such as [@fastify/busboy](https://www.npmjs.com/package/@fastify/busboy) as follows:
39 *
40 * @example
41 * ```js
42 * import { Busboy } from '@fastify/busboy'
43 * import { Readable } from 'node:stream'
44 *
45 * const response = await fetch('...')
46 * const busboy = new Busboy({ headers: { 'content-type': response.headers.get('content-type') } })
47 *
48 * // handle events emitted from `busboy`
49 *
50 * Readable.fromWeb(response.body).pipe(busboy)
51 * ```
52 */
53 readonly formData: () => Promise<FormData>
54 readonly json: () => Promise<unknown>
55 readonly text: () => Promise<string>
56}
57
58export interface SpecIterator<T, TReturn = any, TNext = undefined> {
59 next(...args: [] | [TNext]): IteratorResult<T, TReturn>;
60}
61
62export interface SpecIterableIterator<T> extends SpecIterator<T> {
63 [Symbol.iterator](): SpecIterableIterator<T>;
64}
65
66export interface SpecIterable<T> {
67 [Symbol.iterator](): SpecIterator<T>;
68}
69
70export type HeadersInit = string[][] | Record<string, string | ReadonlyArray<string>> | Headers
71
72export declare class Headers implements SpecIterable<[string, string]> {
73 constructor (init?: HeadersInit)
74 readonly append: (name: string, value: string) => void
75 readonly delete: (name: string) => void
76 readonly get: (name: string) => string | null
77 readonly has: (name: string) => boolean
78 readonly set: (name: string, value: string) => void
79 readonly getSetCookie: () => string[]
80 readonly forEach: (
81 callbackfn: (value: string, key: string, iterable: Headers) => void,
82 thisArg?: unknown
83 ) => void
84
85 readonly keys: () => SpecIterableIterator<string>
86 readonly values: () => SpecIterableIterator<string>
87 readonly entries: () => SpecIterableIterator<[string, string]>
88 readonly [Symbol.iterator]: () => SpecIterableIterator<[string, string]>
89}
90
91export type RequestCache =
92 | 'default'
93 | 'force-cache'
94 | 'no-cache'
95 | 'no-store'
96 | 'only-if-cached'
97 | 'reload'
98
99export type RequestCredentials = 'omit' | 'include' | 'same-origin'
100
101type RequestDestination =
102 | ''
103 | 'audio'
104 | 'audioworklet'
105 | 'document'
106 | 'embed'
107 | 'font'
108 | 'image'
109 | 'manifest'
110 | 'object'
111 | 'paintworklet'
112 | 'report'
113 | 'script'
114 | 'sharedworker'
115 | 'style'
116 | 'track'
117 | 'video'
118 | 'worker'
119 | 'xslt'
120
121export interface RequestInit {
122 method?: string
123 keepalive?: boolean
124 headers?: HeadersInit
125 body?: BodyInit | null
126 redirect?: RequestRedirect
127 integrity?: string
128 signal?: AbortSignal | null
129 credentials?: RequestCredentials
130 mode?: RequestMode
131 referrer?: string
132 referrerPolicy?: ReferrerPolicy
133 window?: null
134 dispatcher?: Dispatcher
135 duplex?: RequestDuplex
136}
137
138export type ReferrerPolicy =
139 | ''
140 | 'no-referrer'
141 | 'no-referrer-when-downgrade'
142 | 'origin'
143 | 'origin-when-cross-origin'
144 | 'same-origin'
145 | 'strict-origin'
146 | 'strict-origin-when-cross-origin'
147 | 'unsafe-url';
148
149export type RequestMode = 'cors' | 'navigate' | 'no-cors' | 'same-origin'
150
151export type RequestRedirect = 'error' | 'follow' | 'manual'
152
153export type RequestDuplex = 'half'
154
155export declare class Request extends BodyMixin {
156 constructor (input: RequestInfo, init?: RequestInit)
157
158 readonly cache: RequestCache
159 readonly credentials: RequestCredentials
160 readonly destination: RequestDestination
161 readonly headers: Headers
162 readonly integrity: string
163 readonly method: string
164 readonly mode: RequestMode
165 readonly redirect: RequestRedirect
166 readonly referrer: string
167 readonly referrerPolicy: ReferrerPolicy
168 readonly url: string
169
170 readonly keepalive: boolean
171 readonly signal: AbortSignal
172 readonly duplex: RequestDuplex
173
174 readonly clone: () => Request
175}
176
177export interface ResponseInit {
178 readonly status?: number
179 readonly statusText?: string
180 readonly headers?: HeadersInit
181}
182
183export type ResponseType =
184 | 'basic'
185 | 'cors'
186 | 'default'
187 | 'error'
188 | 'opaque'
189 | 'opaqueredirect'
190
191export type ResponseRedirectStatus = 301 | 302 | 303 | 307 | 308
192
193export declare class Response extends BodyMixin {
194 constructor (body?: BodyInit, init?: ResponseInit)
195
196 readonly headers: Headers
197 readonly ok: boolean
198 readonly status: number
199 readonly statusText: string
200 readonly type: ResponseType
201 readonly url: string
202 readonly redirected: boolean
203
204 readonly clone: () => Response
205
206 static error (): Response
207 static json(data: any, init?: ResponseInit): Response
208 static redirect (url: string | URL, status: ResponseRedirectStatus): Response
209}
A /sublimated/undefined +71 -0
1import Dispatcher from'./dispatcher'
2import { setGlobalDispatcher, getGlobalDispatcher } from './global-dispatcher'
3import { setGlobalOrigin, getGlobalOrigin } from './global-origin'
4import Pool from'./pool'
5import { RedirectHandler, DecoratorHandler } from './handlers'
6
7import BalancedPool from './balanced-pool'
8import Client from'./client'
9import buildConnector from'./connector'
10import errors from'./errors'
11import Agent from'./agent'
12import MockClient from'./mock-client'
13import MockPool from'./mock-pool'
14import MockAgent from'./mock-agent'
15import mockErrors from'./mock-errors'
16import ProxyAgent from'./proxy-agent'
17import EnvHttpProxyAgent from './env-http-proxy-agent'
18import RetryHandler from'./retry-handler'
19import RetryAgent from'./retry-agent'
20import { request, pipeline, stream, connect, upgrade } from './api'
21import interceptors from './interceptors'
22
23export * from './util'
24export * from './cookies'
25export * from './eventsource'
26export * from './fetch'
27export * from './file'
28export * from './filereader'
29export * from './formdata'
30export * from './diagnostics-channel'
31export * from './websocket'
32export * from './content-type'
33export * from './cache'
34export { Interceptable } from './mock-interceptor'
35
36export { 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 }
37export default Undici
38
39declare namespace Undici {
40 var Dispatcher: typeof import('./dispatcher').default
41 var Pool: typeof import('./pool').default;
42 var RedirectHandler: typeof import ('./handlers').RedirectHandler
43 var DecoratorHandler: typeof import ('./handlers').DecoratorHandler
44 var RetryHandler: typeof import ('./retry-handler').default
45 var createRedirectInterceptor: typeof import ('./interceptors').default.createRedirectInterceptor
46 var BalancedPool: typeof import('./balanced-pool').default;
47 var Client: typeof import('./client').default;
48 var buildConnector: typeof import('./connector').default;
49 var errors: typeof import('./errors').default;
50 var Agent: typeof import('./agent').default;
51 var setGlobalDispatcher: typeof import('./global-dispatcher').setGlobalDispatcher;
52 var getGlobalDispatcher: typeof import('./global-dispatcher').getGlobalDispatcher;
53 var request: typeof import('./api').request;
54 var stream: typeof import('./api').stream;
55 var pipeline: typeof import('./api').pipeline;
56 var connect: typeof import('./api').connect;
57 var upgrade: typeof import('./api').upgrade;
58 var MockClient: typeof import('./mock-client').default;
59 var MockPool: typeof import('./mock-pool').default;
60 var MockAgent: typeof import('./mock-agent').default;
61 var mockErrors: typeof import('./mock-errors').default;
62 var fetch: typeof import('./fetch').fetch;
63 var Headers: typeof import('./fetch').Headers;
64 var Response: typeof import('./fetch').Response;
65 var Request: typeof import('./fetch').Request;
66 var FormData: typeof import('./formdata').FormData;
67 var File: typeof import('./file').File;
68 var FileReader: typeof import('./filereader').FileReader;
69 var caches: typeof import('./cache').caches;
70 var interceptors: typeof import('./interceptors').default;
71}
A /sublimated/undefined +54 -0
1/// <reference types="node" />
2
3import { Blob } from 'buffer'
4import { DOMException, EventInit } from './patch'
5
6export declare class FileReader {
7 __proto__: EventTarget & FileReader
8
9 constructor ()
10
11 readAsArrayBuffer (blob: Blob): void
12 readAsBinaryString (blob: Blob): void
13 readAsText (blob: Blob, encoding?: string): void
14 readAsDataURL (blob: Blob): void
15
16 abort (): void
17
18 static readonly EMPTY = 0
19 static readonly LOADING = 1
20 static readonly DONE = 2
21
22 readonly EMPTY = 0
23 readonly LOADING = 1
24 readonly DONE = 2
25
26 readonly readyState: number
27
28 readonly result: string | ArrayBuffer | null
29
30 readonly error: DOMException | null
31
32 onloadstart: null | ((this: FileReader, event: ProgressEvent) => void)
33 onprogress: null | ((this: FileReader, event: ProgressEvent) => void)
34 onload: null | ((this: FileReader, event: ProgressEvent) => void)
35 onabort: null | ((this: FileReader, event: ProgressEvent) => void)
36 onerror: null | ((this: FileReader, event: ProgressEvent) => void)
37 onloadend: null | ((this: FileReader, event: ProgressEvent) => void)
38}
39
40export interface ProgressEventInit extends EventInit {
41 lengthComputable?: boolean
42 loaded?: number
43 total?: number
44}
45
46export declare class ProgressEvent {
47 __proto__: Event & ProgressEvent
48
49 constructor (type: string, eventInitDict?: ProgressEventInit)
50
51 readonly lengthComputable: boolean
52 readonly loaded: number
53 readonly total: number
54}
A /sublimated/undefined +50 -0
1import Agent from './agent'
2import Dispatcher from './dispatcher'
3import { Interceptable, MockInterceptor } from './mock-interceptor'
4import MockDispatch = MockInterceptor.MockDispatch;
5
6export default MockAgent
7
8interface PendingInterceptor extends MockDispatch {
9 origin: string;
10}
11
12/** A mocked Agent class that implements the Agent API. It allows one to intercept HTTP requests made through undici and return mocked responses instead. */
13declare class MockAgent<TMockAgentOptions extends MockAgent.Options = MockAgent.Options> extends Dispatcher {
14 constructor(options?: MockAgent.Options)
15 /** 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. */
16 get<TInterceptable extends Interceptable>(origin: string): TInterceptable;
17 get<TInterceptable extends Interceptable>(origin: RegExp): TInterceptable;
18 get<TInterceptable extends Interceptable>(origin: ((origin: string) => boolean)): TInterceptable;
19 /** Dispatches a mocked request. */
20 dispatch(options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandlers): boolean;
21 /** Closes the mock agent and waits for registered mock pools and clients to also close before resolving. */
22 close(): Promise<void>;
23 /** Disables mocking in MockAgent. */
24 deactivate(): void;
25 /** 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. */
26 activate(): void;
27 /** Define host matchers so only matching requests that aren't intercepted by the mock dispatchers will be attempted. */
28 enableNetConnect(): void;
29 enableNetConnect(host: string): void;
30 enableNetConnect(host: RegExp): void;
31 enableNetConnect(host: ((host: string) => boolean)): void;
32 /** Causes all requests to throw when requests are not matched in a MockAgent intercept. */
33 disableNetConnect(): void;
34 pendingInterceptors(): PendingInterceptor[];
35 assertNoPendingInterceptors(options?: {
36 pendingInterceptorsFormatter?: PendingInterceptorsFormatter;
37 }): void;
38}
39
40interface PendingInterceptorsFormatter {
41 format(pendingInterceptors: readonly PendingInterceptor[]): string;
42}
43
44declare namespace MockAgent {
45 /** MockAgent options. */
46 export interface Options extends Agent.Options {
47 /** A custom agent to be encapsulated by the MockAgent. */
48 agent?: Agent;
49 }
50}
A /sublimated/undefined +228 -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 */
6type Converter<T> = (object: unknown) => T
7
8type SequenceConverter<T> = (object: unknown, iterable?: IterableIterator<T>) => T[]
9
10type RecordConverter<K extends string, V> = (object: unknown) => Record<K, V>
11
12interface ConvertToIntOpts {
13 clamp?: boolean
14 enforceRange?: boolean
15}
16
17interface 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
37interface 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 * Stringifies {@param V}
68 */
69 Stringify (V: any): string
70
71 /**
72 * Mark a value as uncloneable for Node.js.
73 * This is only effective in some newer Node.js versions.
74 */
75 markAsUncloneable (V: any): void
76}
77
78interface WebidlConverters {
79 /**
80 * @see https://webidl.spec.whatwg.org/#es-DOMString
81 */
82 DOMString (V: unknown, prefix: string, argument: string, opts?: {
83 legacyNullToEmptyString: boolean
84 }): string
85
86 /**
87 * @see https://webidl.spec.whatwg.org/#es-ByteString
88 */
89 ByteString (V: unknown, prefix: string, argument: string): string
90
91 /**
92 * @see https://webidl.spec.whatwg.org/#es-USVString
93 */
94 USVString (V: unknown): string
95
96 /**
97 * @see https://webidl.spec.whatwg.org/#es-boolean
98 */
99 boolean (V: unknown): boolean
100
101 /**
102 * @see https://webidl.spec.whatwg.org/#es-any
103 */
104 any <Value>(V: Value): Value
105
106 /**
107 * @see https://webidl.spec.whatwg.org/#es-long-long
108 */
109 ['long long'] (V: unknown): number
110
111 /**
112 * @see https://webidl.spec.whatwg.org/#es-unsigned-long-long
113 */
114 ['unsigned long long'] (V: unknown): number
115
116 /**
117 * @see https://webidl.spec.whatwg.org/#es-unsigned-long
118 */
119 ['unsigned long'] (V: unknown): number
120
121 /**
122 * @see https://webidl.spec.whatwg.org/#es-unsigned-short
123 */
124 ['unsigned short'] (V: unknown, opts?: ConvertToIntOpts): number
125
126 /**
127 * @see https://webidl.spec.whatwg.org/#idl-ArrayBuffer
128 */
129 ArrayBuffer (V: unknown): ArrayBufferLike
130 ArrayBuffer (V: unknown, opts: { allowShared: false }): ArrayBuffer
131
132 /**
133 * @see https://webidl.spec.whatwg.org/#es-buffer-source-types
134 */
135 TypedArray (
136 V: unknown,
137 TypedArray: NodeJS.TypedArray | ArrayBufferLike
138 ): NodeJS.TypedArray | ArrayBufferLike
139 TypedArray (
140 V: unknown,
141 TypedArray: NodeJS.TypedArray | ArrayBufferLike,
142 opts?: { allowShared: false }
143 ): NodeJS.TypedArray | ArrayBuffer
144
145 /**
146 * @see https://webidl.spec.whatwg.org/#es-buffer-source-types
147 */
148 DataView (V: unknown, opts?: { allowShared: boolean }): DataView
149
150 /**
151 * @see https://webidl.spec.whatwg.org/#BufferSource
152 */
153 BufferSource (
154 V: unknown,
155 opts?: { allowShared: boolean }
156 ): NodeJS.TypedArray | ArrayBufferLike | DataView
157
158 ['sequence<ByteString>']: SequenceConverter<string>
159
160 ['sequence<sequence<ByteString>>']: SequenceConverter<string[]>
161
162 ['record<ByteString, ByteString>']: RecordConverter<string, string>
163
164 [Key: string]: (...args: any[]) => unknown
165}
166
167export interface Webidl {
168 errors: WebidlErrors
169 util: WebidlUtil
170 converters: WebidlConverters
171
172 /**
173 * @description Performs a brand-check on {@param V} to ensure it is a
174 * {@param cls} object.
175 */
176 brandCheck <Interface>(V: unknown, cls: Interface, opts?: { strict?: boolean }): asserts V is Interface
177
178 /**
179 * @see https://webidl.spec.whatwg.org/#es-sequence
180 * @description Convert a value, V, to a WebIDL sequence type.
181 */
182 sequenceConverter <Type>(C: Converter<Type>): SequenceConverter<Type>
183
184 illegalConstructor (): never
185
186 /**
187 * @see https://webidl.spec.whatwg.org/#es-to-record
188 * @description Convert a value, V, to a WebIDL record type.
189 */
190 recordConverter <K extends string, V>(
191 keyConverter: Converter<K>,
192 valueConverter: Converter<V>
193 ): RecordConverter<K, V>
194
195 /**
196 * Similar to {@link Webidl.brandCheck} but allows skipping the check if third party
197 * interfaces are allowed.
198 */
199 interfaceConverter <Interface>(cls: Interface): (
200 V: unknown,
201 opts?: { strict: boolean }
202 ) => asserts V is typeof cls
203
204 // TODO(@KhafraDev): a type could likely be implemented that can infer the return type
205 // from the converters given?
206 /**
207 * Converts a value, V, to a WebIDL dictionary types. Allows limiting which keys are
208 * allowed, values allowed, optional and required keys. Auto converts the value to
209 * a type given a converter.
210 */
211 dictionaryConverter (converters: {
212 key: string,
213 defaultValue?: () => unknown,
214 required?: boolean,
215 converter: (...args: unknown[]) => unknown,
216 allowedValues?: unknown[]
217 }[]): (V: unknown) => Record<string, unknown>
218
219 /**
220 * @see https://webidl.spec.whatwg.org/#idl-nullable-type
221 * @description allows a type, V, to be null
222 */
223 nullableConverter <T>(
224 converter: Converter<T>
225 ): (V: unknown) => ReturnType<typeof converter> | null
226
227 argumentLengthCheck (args: { length: number }, min: number, context: string): void
228}
A /sublimated/undefined +29 -0
1import Pool from './pool'
2import Dispatcher from './dispatcher'
3import { URL } from 'url'
4
5export default BalancedPool
6
7type BalancedPoolConnectOptions = Omit<Dispatcher.ConnectOptions, "origin">;
8
9declare class BalancedPool extends Dispatcher {
10 constructor(url: string | string[] | URL | URL[], options?: Pool.Options);
11
12 addUpstream(upstream: string | URL): BalancedPool;
13 removeUpstream(upstream: string | URL): BalancedPool;
14 upstreams: Array<string>;
15
16 /** `true` after `pool.close()` has been called. */
17 closed: boolean;
18 /** `true` after `pool.destroyed()` has been called or `pool.close()` has been called and the pool shutdown has completed. */
19 destroyed: boolean;
20
21 // Override dispatcher APIs.
22 override connect(
23 options: BalancedPoolConnectOptions
24 ): Promise<Dispatcher.ConnectData>;
25 override connect(
26 options: BalancedPoolConnectOptions,
27 callback: (err: Error | null, data: Dispatcher.ConnectData) => void
28 ): void;
29}
A /sublimated/undefined +19 -0
1import Pool from "./pool"
2
3export default PoolStats
4
5declare 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}
A /sublimated/undefined +7 -0
1export {
2 setGlobalOrigin,
3 getGlobalOrigin
4}
5
6declare function setGlobalOrigin(origin: string | URL | undefined): void;
7declare function getGlobalOrigin(): URL | undefined;
A /sublimated/undefined +149 -0
1import { IncomingHttpHeaders } from "./header";
2import Client from './client'
3
4export default Errors
5
6declare namespace Errors {
7 export class UndiciError extends Error {
8 name: string;
9 code: string;
10 }
11
12 /** Connect timeout error. */
13 export class ConnectTimeoutError extends UndiciError {
14 name: 'ConnectTimeoutError';
15 code: 'UND_ERR_CONNECT_TIMEOUT';
16 }
17
18 /** A header exceeds the `headersTimeout` option. */
19 export class HeadersTimeoutError extends UndiciError {
20 name: 'HeadersTimeoutError';
21 code: 'UND_ERR_HEADERS_TIMEOUT';
22 }
23
24 /** Headers overflow error. */
25 export class HeadersOverflowError extends UndiciError {
26 name: 'HeadersOverflowError'
27 code: 'UND_ERR_HEADERS_OVERFLOW'
28 }
29
30 /** A body exceeds the `bodyTimeout` option. */
31 export class BodyTimeoutError extends UndiciError {
32 name: 'BodyTimeoutError';
33 code: 'UND_ERR_BODY_TIMEOUT';
34 }
35
36 export class ResponseStatusCodeError extends UndiciError {
37 constructor (
38 message?: string,
39 statusCode?: number,
40 headers?: IncomingHttpHeaders | string[] | null,
41 body?: null | Record<string, any> | string
42 );
43 name: 'ResponseStatusCodeError';
44 code: 'UND_ERR_RESPONSE_STATUS_CODE';
45 body: null | Record<string, any> | string
46 status: number
47 statusCode: number
48 headers: IncomingHttpHeaders | string[] | null;
49 }
50
51 /** Passed an invalid argument. */
52 export class InvalidArgumentError extends UndiciError {
53 name: 'InvalidArgumentError';
54 code: 'UND_ERR_INVALID_ARG';
55 }
56
57 /** Returned an invalid value. */
58 export class InvalidReturnValueError extends UndiciError {
59 name: 'InvalidReturnValueError';
60 code: 'UND_ERR_INVALID_RETURN_VALUE';
61 }
62
63 /** The request has been aborted by the user. */
64 export class RequestAbortedError extends UndiciError {
65 name: 'AbortError';
66 code: 'UND_ERR_ABORTED';
67 }
68
69 /** Expected error with reason. */
70 export class InformationalError extends UndiciError {
71 name: 'InformationalError';
72 code: 'UND_ERR_INFO';
73 }
74
75 /** Request body length does not match content-length header. */
76 export class RequestContentLengthMismatchError extends UndiciError {
77 name: 'RequestContentLengthMismatchError';
78 code: 'UND_ERR_REQ_CONTENT_LENGTH_MISMATCH';
79 }
80
81 /** Response body length does not match content-length header. */
82 export class ResponseContentLengthMismatchError extends UndiciError {
83 name: 'ResponseContentLengthMismatchError';
84 code: 'UND_ERR_RES_CONTENT_LENGTH_MISMATCH';
85 }
86
87 /** Trying to use a destroyed client. */
88 export class ClientDestroyedError extends UndiciError {
89 name: 'ClientDestroyedError';
90 code: 'UND_ERR_DESTROYED';
91 }
92
93 /** Trying to use a closed client. */
94 export class ClientClosedError extends UndiciError {
95 name: 'ClientClosedError';
96 code: 'UND_ERR_CLOSED';
97 }
98
99 /** There is an error with the socket. */
100 export class SocketError extends UndiciError {
101 name: 'SocketError';
102 code: 'UND_ERR_SOCKET';
103 socket: Client.SocketInfo | null
104 }
105
106 /** Encountered unsupported functionality. */
107 export class NotSupportedError extends UndiciError {
108 name: 'NotSupportedError';
109 code: 'UND_ERR_NOT_SUPPORTED';
110 }
111
112 /** No upstream has been added to the BalancedPool. */
113 export class BalancedPoolMissingUpstreamError extends UndiciError {
114 name: 'MissingUpstreamError';
115 code: 'UND_ERR_BPL_MISSING_UPSTREAM';
116 }
117
118 export class HTTPParserError extends UndiciError {
119 name: 'HTTPParserError';
120 code: string;
121 }
122
123 /** The response exceed the length allowed. */
124 export class ResponseExceededMaxSizeError extends UndiciError {
125 name: 'ResponseExceededMaxSizeError';
126 code: 'UND_ERR_RES_EXCEEDED_MAX_SIZE';
127 }
128
129 export class RequestRetryError extends UndiciError {
130 constructor (
131 message: string,
132 statusCode: number,
133 headers?: IncomingHttpHeaders | string[] | null,
134 body?: null | Record<string, any> | string
135 );
136 name: 'RequestRetryError';
137 code: 'UND_ERR_REQ_RETRY';
138 statusCode: number;
139 data: {
140 count: number;
141 };
142 headers: Record<string, string | string[]>;
143 }
144
145 export class SecureProxyConnectionError extends UndiciError {
146 name: 'SecureProxyConnectionError';
147 code: 'UND_ERR_PRX_TLS';
148 }
149}
A /sublimated/undefined +12 -0
1import Errors from './errors'
2
3export default MockErrors
4
5declare namespace MockErrors {
6 /** The request does not match any registered mock dispatches. */
7 export class MockNotMatchedError extends Errors.UndiciError {
8 constructor(message?: string);
9 name: 'MockNotMatchedError';
10 code: 'UND_MOCK_ERR_MOCK_NOT_MATCHED';
11 }
12}
A /sublimated/undefined +39 -0
1import Client from './client'
2import TPoolStats from './pool-stats'
3import { URL } from 'url'
4import Dispatcher from "./dispatcher";
5
6export default Pool
7
8type PoolConnectOptions = Omit<Dispatcher.ConnectOptions, "origin">;
9
10declare class Pool extends Dispatcher {
11 constructor(url: string | URL, options?: Pool.Options)
12 /** `true` after `pool.close()` has been called. */
13 closed: boolean;
14 /** `true` after `pool.destroyed()` has been called or `pool.close()` has been called and the pool shutdown has completed. */
15 destroyed: boolean;
16 /** Aggregate stats for a Pool. */
17 readonly stats: TPoolStats;
18
19 // Override dispatcher APIs.
20 override connect(
21 options: PoolConnectOptions
22 ): Promise<Dispatcher.ConnectData>;
23 override connect(
24 options: PoolConnectOptions,
25 callback: (err: Error | null, data: Dispatcher.ConnectData) => void
26 ): void;
27}
28
29declare namespace Pool {
30 export type PoolStats = TPoolStats;
31 export interface Options extends Client.Options {
32 /** Default: `(origin, opts) => new Client(origin, opts)`. */
33 factory?(origin: URL, opts: object): Dispatcher;
34 /** The max number of clients to create. `null` if no limit. Default `null`. */
35 connections?: number | null;
36
37 interceptors?: { Pool?: readonly Dispatcher.DispatchInterceptor[] } & Client.Options["interceptors"]
38 }
39}
A /sublimated/undefined +65 -0
1import { Readable } from "stream";
2import { Blob } from 'buffer'
3
4export default BodyReadable
5
6declare 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 Uint8Array
29 * https://fetch.spec.whatwg.org/#dom-body-bytes
30 */
31 bytes(): Promise<Uint8Array>
32
33 /** Consumes and returns the body as an ArrayBuffer
34 * https://fetch.spec.whatwg.org/#dom-body-arraybuffer
35 */
36 arrayBuffer(): Promise<ArrayBuffer>
37
38 /** Not implemented
39 *
40 * https://fetch.spec.whatwg.org/#dom-body-formdata
41 */
42 formData(): Promise<never>
43
44 /** Returns true if the body is not null and the body has been consumed
45 *
46 * Otherwise, returns false
47 *
48 * https://fetch.spec.whatwg.org/#dom-body-bodyused
49 */
50 readonly bodyUsed: boolean
51
52 /**
53 * If body is null, it should return null as the body
54 *
55 * If body is not null, should return the body as a ReadableStream
56 *
57 * https://fetch.spec.whatwg.org/#dom-body-body
58 */
59 readonly body: never | undefined
60
61 /** Dumps the response body by reading `limit` number of bytes.
62 * @param opts.limit Number of bytes to read (optional) - Default: 262144
63 */
64 dump(opts?: { limit: number }): Promise<void>
65}
A /sublimated/undefined +8 -0
1import Dispatcher from './dispatcher'
2import RetryHandler from './retry-handler'
3
4export default RetryAgent
5
6declare class RetryAgent extends Dispatcher {
7 constructor(dispatcher: Dispatcher, options?: RetryHandler.RetryOptions)
8}
A /sublimated/undefined +36 -0
1import type { RequestInfo, Response, Request } from './fetch'
2
3export interface CacheStorage {
4 match (request: RequestInfo, options?: MultiCacheQueryOptions): Promise<Response | undefined>,
5 has (cacheName: string): Promise<boolean>,
6 open (cacheName: string): Promise<Cache>,
7 delete (cacheName: string): Promise<boolean>,
8 keys (): Promise<string[]>
9}
10
11declare const CacheStorage: {
12 prototype: CacheStorage
13 new(): CacheStorage
14}
15
16export interface Cache {
17 match (request: RequestInfo, options?: CacheQueryOptions): Promise<Response | undefined>,
18 matchAll (request?: RequestInfo, options?: CacheQueryOptions): Promise<readonly Response[]>,
19 add (request: RequestInfo): Promise<undefined>,
20 addAll (requests: RequestInfo[]): Promise<undefined>,
21 put (request: RequestInfo, response: Response): Promise<undefined>,
22 delete (request: RequestInfo, options?: CacheQueryOptions): Promise<boolean>,
23 keys (request?: RequestInfo, options?: CacheQueryOptions): Promise<readonly Request[]>
24}
25
26export interface CacheQueryOptions {
27 ignoreSearch?: boolean,
28 ignoreMethod?: boolean,
29 ignoreVary?: boolean
30}
31
32export interface MultiCacheQueryOptions extends CacheQueryOptions {
33 cacheName?: string
34}
35
36export declare const caches: CacheStorage
A /sublimated/undefined +108 -0
1// Based on https://github.com/octet-stream/form-data/blob/2d0f0dc371517444ce1f22cdde13f51995d0953a/lib/FormData.ts (MIT)
2/// <reference types="node" />
3
4import { File } from './file'
5import { SpecIterableIterator } from './fetch'
6
7/**
8 * A `string` or `File` that represents a single value from a set of `FormData` key-value pairs.
9 */
10declare type FormDataEntryValue = string | File
11
12/**
13 * Provides a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent using fetch().
14 */
15export declare class FormData {
16 /**
17 * Appends a new value onto an existing key inside a FormData object,
18 * or adds the key if it does not already exist.
19 *
20 * The difference between `set()` and `append()` is that if the specified key already exists, `set()` will overwrite all existing values with the new one, whereas `append()` will append the new value onto the end of the existing set of values.
21 *
22 * @param name The name of the field whose data is contained in `value`.
23 * @param value The field's value. This can be [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob)
24 or [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File). If none of these are specified the value is converted to a string.
25 * @param fileName The filename reported to the server, when a Blob or File is passed as the second parameter. The default filename for Blob objects is "blob". The default filename for File objects is the file's filename.
26 */
27 append(name: string, value: unknown, fileName?: string): void
28
29 /**
30 * Set a new value for an existing key inside FormData,
31 * or add the new field if it does not already exist.
32 *
33 * @param name The name of the field whose data is contained in `value`.
34 * @param value The field's value. This can be [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob)
35 or [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File). If none of these are specified the value is converted to a string.
36 * @param fileName The filename reported to the server, when a Blob or File is passed as the second parameter. The default filename for Blob objects is "blob". The default filename for File objects is the file's filename.
37 *
38 */
39 set(name: string, value: unknown, fileName?: string): void
40
41 /**
42 * Returns the first value associated with a given key from within a `FormData` object.
43 * If you expect multiple values and want all of them, use the `getAll()` method instead.
44 *
45 * @param {string} name A name of the value you want to retrieve.
46 *
47 * @returns A `FormDataEntryValue` containing the value. If the key doesn't exist, the method returns null.
48 */
49 get(name: string): FormDataEntryValue | null
50
51 /**
52 * Returns all the values associated with a given key from within a `FormData` object.
53 *
54 * @param {string} name A name of the value you want to retrieve.
55 *
56 * @returns An array of `FormDataEntryValue` whose key matches the value passed in the `name` parameter. If the key doesn't exist, the method returns an empty list.
57 */
58 getAll(name: string): FormDataEntryValue[]
59
60 /**
61 * Returns a boolean stating whether a `FormData` object contains a certain key.
62 *
63 * @param name A string representing the name of the key you want to test for.
64 *
65 * @return A boolean value.
66 */
67 has(name: string): boolean
68
69 /**
70 * Deletes a key and its value(s) from a `FormData` object.
71 *
72 * @param name The name of the key you want to delete.
73 */
74 delete(name: string): void
75
76 /**
77 * Executes given callback function for each field of the FormData instance
78 */
79 forEach: (
80 callbackfn: (value: FormDataEntryValue, key: string, iterable: FormData) => void,
81 thisArg?: unknown
82 ) => void
83
84 /**
85 * Returns an [`iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) allowing to go through all keys contained in this `FormData` object.
86 * Each key is a `string`.
87 */
88 keys: () => SpecIterableIterator<string>
89
90 /**
91 * Returns an [`iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) allowing to go through all values contained in this object `FormData` object.
92 * Each value is a [`FormDataValue`](https://developer.mozilla.org/en-US/docs/Web/API/FormDataEntryValue).
93 */
94 values: () => SpecIterableIterator<FormDataEntryValue>
95
96 /**
97 * Returns an [`iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) allowing to go through the `FormData` key/value pairs.
98 * The key of each pair is a string; the value is a [`FormDataValue`](https://developer.mozilla.org/en-US/docs/Web/API/FormDataEntryValue).
99 */
100 entries: () => SpecIterableIterator<[string, FormDataEntryValue]>
101
102 /**
103 * An alias for FormData#entries()
104 */
105 [Symbol.iterator]: () => SpecIterableIterator<[string, FormDataEntryValue]>
106
107 readonly [Symbol.toStringTag]: string
108}
A /sublimated/undefined +150 -0
1/// <reference types="node" />
2
3import type { Blob } from 'buffer'
4import type { MessagePort } from 'worker_threads'
5import {
6 EventInit,
7 EventListenerOptions,
8 AddEventListenerOptions,
9 EventListenerOrEventListenerObject
10} from './patch'
11import Dispatcher from './dispatcher'
12import { HeadersInit } from './fetch'
13
14export type BinaryType = 'blob' | 'arraybuffer'
15
16interface WebSocketEventMap {
17 close: CloseEvent
18 error: ErrorEvent
19 message: MessageEvent
20 open: Event
21}
22
23interface WebSocket extends EventTarget {
24 binaryType: BinaryType
25
26 readonly bufferedAmount: number
27 readonly extensions: string
28
29 onclose: ((this: WebSocket, ev: WebSocketEventMap['close']) => any) | null
30 onerror: ((this: WebSocket, ev: WebSocketEventMap['error']) => any) | null
31 onmessage: ((this: WebSocket, ev: WebSocketEventMap['message']) => any) | null
32 onopen: ((this: WebSocket, ev: WebSocketEventMap['open']) => any) | null
33
34 readonly protocol: string
35 readonly readyState: number
36 readonly url: string
37
38 close(code?: number, reason?: string): void
39 send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void
40
41 readonly CLOSED: number
42 readonly CLOSING: number
43 readonly CONNECTING: number
44 readonly OPEN: number
45
46 addEventListener<K extends keyof WebSocketEventMap>(
47 type: K,
48 listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any,
49 options?: boolean | AddEventListenerOptions
50 ): void
51 addEventListener(
52 type: string,
53 listener: EventListenerOrEventListenerObject,
54 options?: boolean | AddEventListenerOptions
55 ): void
56 removeEventListener<K extends keyof WebSocketEventMap>(
57 type: K,
58 listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any,
59 options?: boolean | EventListenerOptions
60 ): void
61 removeEventListener(
62 type: string,
63 listener: EventListenerOrEventListenerObject,
64 options?: boolean | EventListenerOptions
65 ): void
66}
67
68export declare const WebSocket: {
69 prototype: WebSocket
70 new (url: string | URL, protocols?: string | string[] | WebSocketInit): WebSocket
71 readonly CLOSED: number
72 readonly CLOSING: number
73 readonly CONNECTING: number
74 readonly OPEN: number
75}
76
77interface CloseEventInit extends EventInit {
78 code?: number
79 reason?: string
80 wasClean?: boolean
81}
82
83interface CloseEvent extends Event {
84 readonly code: number
85 readonly reason: string
86 readonly wasClean: boolean
87}
88
89export declare const CloseEvent: {
90 prototype: CloseEvent
91 new (type: string, eventInitDict?: CloseEventInit): CloseEvent
92}
93
94interface MessageEventInit<T = any> extends EventInit {
95 data?: T
96 lastEventId?: string
97 origin?: string
98 ports?: (typeof MessagePort)[]
99 source?: typeof MessagePort | null
100}
101
102interface MessageEvent<T = any> extends Event {
103 readonly data: T
104 readonly lastEventId: string
105 readonly origin: string
106 readonly ports: ReadonlyArray<typeof MessagePort>
107 readonly source: typeof MessagePort | null
108 initMessageEvent(
109 type: string,
110 bubbles?: boolean,
111 cancelable?: boolean,
112 data?: any,
113 origin?: string,
114 lastEventId?: string,
115 source?: typeof MessagePort | null,
116 ports?: (typeof MessagePort)[]
117 ): void;
118}
119
120export declare const MessageEvent: {
121 prototype: MessageEvent
122 new<T>(type: string, eventInitDict?: MessageEventInit<T>): MessageEvent<T>
123}
124
125interface ErrorEventInit extends EventInit {
126 message?: string
127 filename?: string
128 lineno?: number
129 colno?: number
130 error?: any
131}
132
133interface ErrorEvent extends Event {
134 readonly message: string
135 readonly filename: string
136 readonly lineno: number
137 readonly colno: number
138 readonly error: any
139}
140
141export declare const ErrorEvent: {
142 prototype: ErrorEvent
143 new (type: string, eventInitDict?: ErrorEventInit): ErrorEvent
144}
145
146interface WebSocketInit {
147 protocols?: string | string[],
148 dispatcher?: Dispatcher,
149 headers?: HeadersInit
150}
A /sublimated/undefined +25 -0
1import Client from './client'
2import Dispatcher from './dispatcher'
3import MockAgent from './mock-agent'
4import { MockInterceptor, Interceptable } from './mock-interceptor'
5
6export default MockClient
7
8/** MockClient extends the Client API and allows one to mock requests. */
9declare class MockClient extends Client implements Interceptable {
10 constructor(origin: string, options: MockClient.Options);
11 /** Intercepts any matching requests that use the same origin as this mock client. */
12 intercept(options: MockInterceptor.Options): MockInterceptor;
13 /** Dispatches a mocked request. */
14 dispatch(options: Dispatcher.DispatchOptions, handlers: Dispatcher.DispatchHandlers): boolean;
15 /** Closes the mock client and gracefully waits for enqueued requests to complete. */
16 close(): Promise<void>;
17}
18
19declare namespace MockClient {
20 /** MockClient options. */
21 export interface Options extends Client.Options {
22 /** The agent to associate this MockClient with. */
23 agent: MockAgent;
24 }
25}
A /sublimated/undefined +55 -0
1{
2 "name": "undici-types",
3 "version": "6.21.0",
4 "description": "A stand-alone types package for Undici",
5 "homepage": "https://undici.nodejs.org",
6 "bugs": {
7 "url": "https://github.com/nodejs/undici/issues"
8 },
9 "repository": {
10 "type": "git",
11 "url": "git+https://github.com/nodejs/undici.git"
12 },
13 "license": "MIT",
14 "types": "index.d.ts",
15 "files": [
16 "*.d.ts"
17 ],
18 "contributors": [
19 {
20 "name": "Daniele Belardi",
21 "url": "https://github.com/dnlup",
22 "author": true
23 },
24 {
25 "name": "Ethan Arrowood",
26 "url": "https://github.com/ethan-arrowood",
27 "author": true
28 },
29 {
30 "name": "Matteo Collina",
31 "url": "https://github.com/mcollina",
32 "author": true
33 },
34 {
35 "name": "Matthew Aitken",
36 "url": "https://github.com/KhafraDev",
37 "author": true
38 },
39 {
40 "name": "Robert Nagy",
41 "url": "https://github.com/ronag",
42 "author": true
43 },
44 {
45 "name": "Szymon Marczak",
46 "url": "https://github.com/szmarczak",
47 "author": true
48 },
49 {
50 "name": "Tomas Della Vedova",
51 "url": "https://github.com/delvedor",
52 "author": true
53 }
54 ]
55}
A /sublimated/undefined +17 -0
1import Dispatcher from "./dispatcher";
2import RetryHandler from "./retry-handler";
3
4export default Interceptors;
5
6declare namespace Interceptors {
7 export type DumpInterceptorOpts = { maxSize?: number }
8 export type RetryInterceptorOpts = RetryHandler.RetryOptions
9 export type RedirectInterceptorOpts = { maxRedirections?: number }
10 export type ResponseErrorInterceptorOpts = { throwOnError: boolean }
11
12 export function createRedirectInterceptor(opts: RedirectInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
13 export function dump(opts?: DumpInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
14 export function retry(opts?: RetryInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
15 export function redirect(opts?: RedirectInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
16 export function responseError(opts?: ResponseErrorInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
17}
A /sublimated/undefined +28 -0
1/// <reference types="node" />
2
3import type { Headers } from './fetch'
4
5export interface Cookie {
6 name: string
7 value: string
8 expires?: Date | number
9 maxAge?: number
10 domain?: string
11 path?: string
12 secure?: boolean
13 httpOnly?: boolean
14 sameSite?: 'Strict' | 'Lax' | 'None'
15 unparsed?: string[]
16}
17
18export function deleteCookie (
19 headers: Headers,
20 name: string,
21 attributes?: { name?: string, domain?: string }
22): void
23
24export function getCookies (headers: Headers): Record<string, string>
25
26export function getSetCookies (headers: Headers): Cookie[]
27
28export function setCookie (headers: Headers, cookie: Cookie): void
A /sublimated/undefined +25 -0
1import Pool from './pool'
2import MockAgent from './mock-agent'
3import { Interceptable, MockInterceptor } from './mock-interceptor'
4import Dispatcher from './dispatcher'
5
6export default MockPool
7
8/** MockPool extends the Pool API and allows one to mock requests. */
9declare class MockPool extends Pool implements Interceptable {
10 constructor(origin: string, options: MockPool.Options);
11 /** Intercepts any matching requests that use the same origin as this mock pool. */
12 intercept(options: MockInterceptor.Options): MockInterceptor;
13 /** Dispatches a mocked request. */
14 dispatch(options: Dispatcher.DispatchOptions, handlers: Dispatcher.DispatchHandlers): boolean;
15 /** Closes the mock pool and gracefully waits for enqueued requests to complete. */
16 close(): Promise<void>;
17}
18
19declare namespace MockPool {
20 /** MockPool options. */
21 export interface Options extends Pool.Options {
22 /** The agent to associate this MockPool with. */
23 agent: MockAgent;
24 }
25}
A /sublimated/undefined +18 -0
1export namespace util {
2 /**
3 * Retrieves a header name and returns its lowercase value.
4 * @param value Header name
5 */
6 export function headerNameToString(value: string | Buffer): string;
7
8 /**
9 * Receives a header object and returns the parsed value.
10 * @param headers Header object
11 * @param obj Object to specify a proxy object. Used to assign parsed values.
12 * @returns If `obj` is specified, it is equivalent to `obj`.
13 */
14 export function parseHeaders(
15 headers: (Buffer | string | (Buffer | string)[])[],
16 obj?: Record<string, string | string[]>
17 ): Record<string, string | string[]>;
18}
A /sublimated/undefined +93 -0
1import { IncomingHttpHeaders } from './header'
2import Dispatcher from './dispatcher';
3import { BodyInit, Headers } from './fetch'
4
5export {
6 Interceptable,
7 MockInterceptor,
8 MockScope
9}
10
11/** The scope associated with a mock dispatch. */
12declare class MockScope<TData extends object = object> {
13 constructor(mockDispatch: MockInterceptor.MockDispatch<TData>);
14 /** Delay a reply by a set amount of time in ms. */
15 delay(waitInMs: number): MockScope<TData>;
16 /** Persist the defined mock data for the associated reply. It will return the defined mock data indefinitely. */
17 persist(): MockScope<TData>;
18 /** Define a reply for a set amount of matching requests. */
19 times(repeatTimes: number): MockScope<TData>;
20}
21
22/** The interceptor for a Mock. */
23declare class MockInterceptor {
24 constructor(options: MockInterceptor.Options, mockDispatches: MockInterceptor.MockDispatch[]);
25 /** Mock an undici request with the defined reply. */
26 reply<TData extends object = object>(replyOptionsCallback: MockInterceptor.MockReplyOptionsCallback<TData>): MockScope<TData>;
27 reply<TData extends object = object>(
28 statusCode: number,
29 data?: TData | Buffer | string | MockInterceptor.MockResponseDataHandler<TData>,
30 responseOptions?: MockInterceptor.MockResponseOptions
31 ): MockScope<TData>;
32 /** Mock an undici request by throwing the defined reply error. */
33 replyWithError<TError extends Error = Error>(error: TError): MockScope;
34 /** Set default reply headers on the interceptor for subsequent mocked replies. */
35 defaultReplyHeaders(headers: IncomingHttpHeaders): MockInterceptor;
36 /** Set default reply trailers on the interceptor for subsequent mocked replies. */
37 defaultReplyTrailers(trailers: Record<string, string>): MockInterceptor;
38 /** Set automatically calculated content-length header on subsequent mocked replies. */
39 replyContentLength(): MockInterceptor;
40}
41
42declare namespace MockInterceptor {
43 /** MockInterceptor options. */
44 export interface Options {
45 /** Path to intercept on. */
46 path: string | RegExp | ((path: string) => boolean);
47 /** Method to intercept on. Defaults to GET. */
48 method?: string | RegExp | ((method: string) => boolean);
49 /** Body to intercept on. */
50 body?: string | RegExp | ((body: string) => boolean);
51 /** Headers to intercept on. */
52 headers?: Record<string, string | RegExp | ((body: string) => boolean)> | ((headers: Record<string, string>) => boolean);
53 /** Query params to intercept on */
54 query?: Record<string, any>;
55 }
56 export interface MockDispatch<TData extends object = object, TError extends Error = Error> extends Options {
57 times: number | null;
58 persist: boolean;
59 consumed: boolean;
60 data: MockDispatchData<TData, TError>;
61 }
62 export interface MockDispatchData<TData extends object = object, TError extends Error = Error> extends MockResponseOptions {
63 error: TError | null;
64 statusCode?: number;
65 data?: TData | string;
66 }
67 export interface MockResponseOptions {
68 headers?: IncomingHttpHeaders;
69 trailers?: Record<string, string>;
70 }
71
72 export interface MockResponseCallbackOptions {
73 path: string;
74 method: string;
75 headers?: Headers | Record<string, string>;
76 origin?: string;
77 body?: BodyInit | Dispatcher.DispatchOptions['body'] | null;
78 maxRedirections?: number;
79 }
80
81 export type MockResponseDataHandler<TData extends object = object> = (
82 opts: MockResponseCallbackOptions
83 ) => TData | Buffer | string;
84
85 export type MockReplyOptionsCallback<TData extends object = object> = (
86 opts: MockResponseCallbackOptions
87 ) => { statusCode: number, data?: TData | Buffer | string, responseOptions?: MockResponseOptions }
88}
89
90interface Interceptable extends Dispatcher {
91 /** Intercepts any matching requests that use the same origin as this mock client. */
92 intercept(options: MockInterceptor.Options): MockInterceptor;
93}
A /sublimated/undefined +9 -0
1import Dispatcher from "./dispatcher";
2
3export {
4 getGlobalDispatcher,
5 setGlobalDispatcher
6}
7
8declare function setGlobalDispatcher<DispatcherImplementation extends Dispatcher>(dispatcher: DispatcherImplementation): void;
9declare function getGlobalDispatcher(): Dispatcher;
A /sublimated/undefined +31 -0
1import { URL } from 'url'
2import Pool from './pool'
3import Dispatcher from "./dispatcher";
4
5export default Agent
6
7declare class Agent extends Dispatcher{
8 constructor(opts?: Agent.Options)
9 /** `true` after `dispatcher.close()` has been called. */
10 closed: boolean;
11 /** `true` after `dispatcher.destroyed()` has been called or `dispatcher.close()` has been called and the dispatcher shutdown has completed. */
12 destroyed: boolean;
13 /** Dispatches a request. */
14 dispatch(options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandlers): boolean;
15}
16
17declare namespace Agent {
18 export interface Options extends Pool.Options {
19 /** Default: `(origin, opts) => new Pool(origin, opts)`. */
20 factory?(origin: string | URL, opts: Object): Dispatcher;
21 /** Integer. Default: `0` */
22 maxRedirections?: number;
23
24 interceptors?: { Agent?: readonly Dispatcher.DispatchInterceptor[] } & Pool.Options["interceptors"]
25 }
26
27 export interface DispatchOptions extends Dispatcher.DispatchOptions {
28 /** Integer. */
29 maxRedirections?: number;
30 }
31}
A /sublimated/undefined +116 -0
1import Dispatcher from "./dispatcher";
2
3export default RetryHandler;
4
5declare class RetryHandler implements Dispatcher.DispatchHandlers {
6 constructor(
7 options: Dispatcher.DispatchOptions & {
8 retryOptions?: RetryHandler.RetryOptions;
9 },
10 retryHandlers: RetryHandler.RetryHandlers
11 );
12}
13
14declare namespace RetryHandler {
15 export type RetryState = { counter: number; };
16
17 export type RetryContext = {
18 state: RetryState;
19 opts: Dispatcher.DispatchOptions & {
20 retryOptions?: RetryHandler.RetryOptions;
21 };
22 }
23
24 export type OnRetryCallback = (result?: Error | null) => void;
25
26 export type RetryCallback = (
27 err: Error,
28 context: {
29 state: RetryState;
30 opts: Dispatcher.DispatchOptions & {
31 retryOptions?: RetryHandler.RetryOptions;
32 };
33 },
34 callback: OnRetryCallback
35 ) => number | null;
36
37 export interface RetryOptions {
38 /**
39 * Callback to be invoked on every retry iteration.
40 * It receives the error, current state of the retry object and the options object
41 * passed when instantiating the retry handler.
42 *
43 * @type {RetryCallback}
44 * @memberof RetryOptions
45 */
46 retry?: RetryCallback;
47 /**
48 * Maximum number of retries to allow.
49 *
50 * @type {number}
51 * @memberof RetryOptions
52 * @default 5
53 */
54 maxRetries?: number;
55 /**
56 * Max number of milliseconds allow between retries
57 *
58 * @type {number}
59 * @memberof RetryOptions
60 * @default 30000
61 */
62 maxTimeout?: number;
63 /**
64 * Initial number of milliseconds to wait before retrying for the first time.
65 *
66 * @type {number}
67 * @memberof RetryOptions
68 * @default 500
69 */
70 minTimeout?: number;
71 /**
72 * Factior to multiply the timeout factor between retries.
73 *
74 * @type {number}
75 * @memberof RetryOptions
76 * @default 2
77 */
78 timeoutFactor?: number;
79 /**
80 * It enables to automatically infer timeout between retries based on the `Retry-After` header.
81 *
82 * @type {boolean}
83 * @memberof RetryOptions
84 * @default true
85 */
86 retryAfter?: boolean;
87 /**
88 * HTTP methods to retry.
89 *
90 * @type {Dispatcher.HttpMethod[]}
91 * @memberof RetryOptions
92 * @default ['GET', 'HEAD', 'OPTIONS', 'PUT', 'DELETE', 'TRACE'],
93 */
94 methods?: Dispatcher.HttpMethod[];
95 /**
96 * Error codes to be retried. e.g. `ECONNRESET`, `ENOTFOUND`, `ETIMEDOUT`, `ECONNREFUSED`, etc.
97 *
98 * @type {string[]}
99 * @default ['ECONNRESET','ECONNREFUSED','ENOTFOUND','ENETDOWN','ENETUNREACH','EHOSTDOWN','EHOSTUNREACH','EPIPE']
100 */
101 errorCodes?: string[];
102 /**
103 * HTTP status codes to be retried.
104 *
105 * @type {number[]}
106 * @memberof RetryOptions
107 * @default [500, 502, 503, 504, 429],
108 */
109 statusCodes?: number[];
110 }
111
112 export interface RetryHandlers {
113 dispatch: Dispatcher["dispatch"];
114 handler: Dispatcher.DispatchHandlers;
115 }
116}
A /sublimated/undefined +34 -0
1import { TLSSocket, ConnectionOptions } from 'tls'
2import { IpcNetConnectOpts, Socket, TcpNetConnectOpts } from 'net'
3
4export default buildConnector
5declare function buildConnector (options?: buildConnector.BuildOptions): buildConnector.connector
6
7declare namespace buildConnector {
8 export type BuildOptions = (ConnectionOptions | TcpNetConnectOpts | IpcNetConnectOpts) & {
9 allowH2?: boolean;
10 maxCachedSessions?: number | null;
11 socketPath?: string | null;
12 timeout?: number | null;
13 port?: number;
14 keepAlive?: boolean | null;
15 keepAliveInitialDelay?: number | null;
16 }
17
18 export interface Options {
19 hostname: string
20 host?: string
21 protocol: string
22 port: string
23 servername?: string
24 localAddress?: string | null
25 httpSocket?: Socket
26 }
27
28 export type Callback = (...args: CallbackArgs) => void
29 type CallbackArgs = [null, Socket | TLSSocket] | [Error, null]
30
31 export interface connector {
32 (options: buildConnector.Options, callback: buildConnector.Callback): void
33 }
34}
A /sublimated/undefined +21 -0
1import Agent from './agent'
2import Dispatcher from './dispatcher'
3
4export default EnvHttpProxyAgent
5
6declare class EnvHttpProxyAgent extends Dispatcher {
7 constructor(opts?: EnvHttpProxyAgent.Options)
8
9 dispatch(options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandlers): boolean;
10}
11
12declare namespace EnvHttpProxyAgent {
13 export interface Options extends Agent.Options {
14 /** Overrides the value of the HTTP_PROXY environment variable */
15 httpProxy?: string;
16 /** Overrides the value of the HTTPS_PROXY environment variable */
17 httpsProxy?: string;
18 /** Overrides the value of the NO_PROXY environment variable */
19 noProxy?: string;
20 }
21}
A /sublimated/undefined +6 -0
1# undici-types
2
3This package is a dual-publish of the [undici](https://www.npmjs.com/package/undici) library types. The `undici` package **still contains types**. This package is for users who _only_ need undici types (such as for `@types/node`). It is published alongside every release of `undici`, so you can always use the same version.
4
5- [GitHub nodejs/undici](https://github.com/nodejs/undici)
6- [Undici Documentation](https://undici.nodejs.org/#/)
A /sublimated/undefined +21 -0
1/// <reference types="node" />
2
3interface MIMEType {
4 type: string
5 subtype: string
6 parameters: Map<string, string>
7 essence: string
8}
9
10/**
11 * Parse a string to a {@link MIMEType} object. Returns `failure` if the string
12 * couldn't be parsed.
13 * @see https://mimesniff.spec.whatwg.org/#parse-a-mime-type
14 */
15export function parseMIMEType (input: string): 'failure' | MIMEType
16
17/**
18 * Convert a MIMEType object to a string.
19 * @see https://mimesniff.spec.whatwg.org/#serialize-a-mime-type
20 */
21export function serializeAMimeType (mimeType: MIMEType): string
A /sublimated/undefined +15 -0
1import Dispatcher from "./dispatcher";
2
3export declare class RedirectHandler implements Dispatcher.DispatchHandlers {
4 constructor(
5 dispatch: Dispatcher,
6 maxRedirections: number,
7 opts: Dispatcher.DispatchOptions,
8 handler: Dispatcher.DispatchHandlers,
9 redirectionLimitReached: boolean
10 );
11}
12
13export declare class DecoratorHandler implements Dispatcher.DispatchHandlers {
14 constructor(handler: Dispatcher.DispatchHandlers);
15}
A /sublimated/undefined +28 -0
1import Agent from './agent'
2import buildConnector from './connector';
3import Dispatcher from './dispatcher'
4import { IncomingHttpHeaders } from './header'
5
6export default ProxyAgent
7
8declare class ProxyAgent extends Dispatcher {
9 constructor(options: ProxyAgent.Options | string)
10
11 dispatch(options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandlers): boolean;
12 close(): Promise<void>;
13}
14
15declare namespace ProxyAgent {
16 export interface Options extends Agent.Options {
17 uri: string;
18 /**
19 * @deprecated use opts.token
20 */
21 auth?: string;
22 token?: string;
23 headers?: IncomingHttpHeaders;
24 requestTls?: buildConnector.BuildOptions;
25 proxyTls?: buildConnector.BuildOptions;
26 clientFactory?(origin: URL, opts: object): Dispatcher;
27 }
28}
A /sublimated/undefined +108 -0
1import { URL } from 'url'
2import { TlsOptions } from 'tls'
3import Dispatcher from './dispatcher'
4import buildConnector from "./connector";
5
6type ClientConnectOptions = Omit<Dispatcher.ConnectOptions, "origin">;
7
8/**
9 * A basic HTTP/1.1 client, mapped on top a single TCP/TLS connection. Pipelining is disabled by default.
10 */
11export class Client extends Dispatcher {
12 constructor(url: string | URL, options?: Client.Options);
13 /** Property to get and set the pipelining factor. */
14 pipelining: number;
15 /** `true` after `client.close()` has been called. */
16 closed: boolean;
17 /** `true` after `client.destroyed()` has been called or `client.close()` has been called and the client shutdown has completed. */
18 destroyed: boolean;
19
20 // Override dispatcher APIs.
21 override connect(
22 options: ClientConnectOptions
23 ): Promise<Dispatcher.ConnectData>;
24 override connect(
25 options: ClientConnectOptions,
26 callback: (err: Error | null, data: Dispatcher.ConnectData) => void
27 ): void;
28}
29
30export declare namespace Client {
31 export interface OptionsInterceptors {
32 Client: readonly Dispatcher.DispatchInterceptor[];
33 }
34 export interface Options {
35 /** TODO */
36 interceptors?: OptionsInterceptors;
37 /** The maximum length of request headers in bytes. Default: Node.js' `--max-http-header-size` or `16384` (16KiB). */
38 maxHeaderSize?: number;
39 /** The amount of time, in milliseconds, the parser will wait to receive the complete HTTP headers (Node 14 and above only). Default: `300e3` milliseconds (300s). */
40 headersTimeout?: number;
41 /** @deprecated unsupported socketTimeout, use headersTimeout & bodyTimeout instead */
42 socketTimeout?: never;
43 /** @deprecated unsupported requestTimeout, use headersTimeout & bodyTimeout instead */
44 requestTimeout?: never;
45 /** TODO */
46 connectTimeout?: number;
47 /** The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Default: `300e3` milliseconds (300s). */
48 bodyTimeout?: number;
49 /** @deprecated unsupported idleTimeout, use keepAliveTimeout instead */
50 idleTimeout?: never;
51 /** @deprecated unsupported keepAlive, use pipelining=0 instead */
52 keepAlive?: never;
53 /** the timeout, in milliseconds, after which a socket without active requests will time out. Monitors time between activity on a connected socket. This value may be overridden by *keep-alive* hints from the server. Default: `4e3` milliseconds (4s). */
54 keepAliveTimeout?: number;
55 /** @deprecated unsupported maxKeepAliveTimeout, use keepAliveMaxTimeout instead */
56 maxKeepAliveTimeout?: never;
57 /** the maximum allowed `idleTimeout`, in milliseconds, when overridden by *keep-alive* hints from the server. Default: `600e3` milliseconds (10min). */
58 keepAliveMaxTimeout?: number;
59 /** A number of milliseconds subtracted from server *keep-alive* hints when overriding `idleTimeout` to account for timing inaccuracies caused by e.g. transport latency. Default: `1e3` milliseconds (1s). */
60 keepAliveTimeoutThreshold?: number;
61 /** TODO */
62 socketPath?: string;
63 /** The amount of concurrent requests to be sent over the single TCP/TLS connection according to [RFC7230](https://tools.ietf.org/html/rfc7230#section-6.3.2). Default: `1`. */
64 pipelining?: number;
65 /** @deprecated use the connect option instead */
66 tls?: never;
67 /** If `true`, an error is thrown when the request content-length header doesn't match the length of the request body. Default: `true`. */
68 strictContentLength?: boolean;
69 /** TODO */
70 maxCachedSessions?: number;
71 /** TODO */
72 maxRedirections?: number;
73 /** TODO */
74 connect?: buildConnector.BuildOptions | buildConnector.connector;
75 /** TODO */
76 maxRequestsPerClient?: number;
77 /** TODO */
78 localAddress?: string;
79 /** Max response body size in bytes, -1 is disabled */
80 maxResponseSize?: number;
81 /** Enables a family autodetection algorithm that loosely implements section 5 of RFC 8305. */
82 autoSelectFamily?: boolean;
83 /** The amount of time in milliseconds to wait for a connection attempt to finish before trying the next address when using the `autoSelectFamily` option. */
84 autoSelectFamilyAttemptTimeout?: number;
85 /**
86 * @description Enables support for H2 if the server has assigned bigger priority to it through ALPN negotiation.
87 * @default false
88 */
89 allowH2?: boolean;
90 /**
91 * @description Dictates the maximum number of concurrent streams for a single H2 session. It can be overridden by a SETTINGS remote frame.
92 * @default 100
93 */
94 maxConcurrentStreams?: number
95 }
96 export interface SocketInfo {
97 localAddress?: string
98 localPort?: number
99 remoteAddress?: string
100 remotePort?: number
101 remoteFamily?: string
102 timeout?: number
103 bytesWritten?: number
104 bytesRead?: number
105 }
106}
107
108export default Client;
A /sublimated/undefined +66 -0
1import { Socket } from "net";
2import { URL } from "url";
3import Connector from "./connector";
4import Dispatcher from "./dispatcher";
5
6declare namespace DiagnosticsChannel {
7 interface Request {
8 origin?: string | URL;
9 completed: boolean;
10 method?: Dispatcher.HttpMethod;
11 path: string;
12 headers: any;
13 }
14 interface Response {
15 statusCode: number;
16 statusText: string;
17 headers: Array<Buffer>;
18 }
19 type Error = unknown;
20 interface ConnectParams {
21 host: URL["host"];
22 hostname: URL["hostname"];
23 protocol: URL["protocol"];
24 port: URL["port"];
25 servername: string | null;
26 }
27 type Connector = Connector.connector;
28 export interface RequestCreateMessage {
29 request: Request;
30 }
31 export interface RequestBodySentMessage {
32 request: Request;
33 }
34 export interface RequestHeadersMessage {
35 request: Request;
36 response: Response;
37 }
38 export interface RequestTrailersMessage {
39 request: Request;
40 trailers: Array<Buffer>;
41 }
42 export interface RequestErrorMessage {
43 request: Request;
44 error: Error;
45 }
46 export interface ClientSendHeadersMessage {
47 request: Request;
48 headers: string;
49 socket: Socket;
50 }
51 export interface ClientBeforeConnectMessage {
52 connectParams: ConnectParams;
53 connector: Connector;
54 }
55 export interface ClientConnectedMessage {
56 socket: Socket;
57 connectParams: ConnectParams;
58 connector: Connector;
59 }
60 export interface ClientConnectErrorMessage {
61 error: Error;
62 socket: Socket;
63 connectParams: ConnectParams;
64 connector: Connector;
65 }
66}
A /sublimated/undefined +256 -0
1import { URL } from 'url'
2import { Duplex, Readable, Writable } from 'stream'
3import { EventEmitter } from 'events'
4import { Blob } from 'buffer'
5import { IncomingHttpHeaders } from './header'
6import BodyReadable from './readable'
7import { FormData } from './formdata'
8import Errors from './errors'
9
10type AbortSignal = unknown;
11
12export default Dispatcher
13
14/** Dispatcher is the core API used to dispatch requests. */
15declare class Dispatcher extends EventEmitter {
16 /** 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. */
17 dispatch(options: Dispatcher.DispatchOptions, handler: Dispatcher.DispatchHandlers): boolean;
18 /** Starts two-way communications with the requested resource. */
19 connect(options: Dispatcher.ConnectOptions): Promise<Dispatcher.ConnectData>;
20 connect(options: Dispatcher.ConnectOptions, callback: (err: Error | null, data: Dispatcher.ConnectData) => void): void;
21 /** Compose a chain of dispatchers */
22 compose(dispatchers: Dispatcher.DispatcherComposeInterceptor[]): Dispatcher.ComposedDispatcher;
23 compose(...dispatchers: Dispatcher.DispatcherComposeInterceptor[]): Dispatcher.ComposedDispatcher;
24 /** Performs an HTTP request. */
25 request(options: Dispatcher.RequestOptions): Promise<Dispatcher.ResponseData>;
26 request(options: Dispatcher.RequestOptions, callback: (err: Error | null, data: Dispatcher.ResponseData) => void): void;
27 /** For easy use with `stream.pipeline`. */
28 pipeline(options: Dispatcher.PipelineOptions, handler: Dispatcher.PipelineHandler): Duplex;
29 /** A faster version of `Dispatcher.request`. */
30 stream(options: Dispatcher.RequestOptions, factory: Dispatcher.StreamFactory): Promise<Dispatcher.StreamData>;
31 stream(options: Dispatcher.RequestOptions, factory: Dispatcher.StreamFactory, callback: (err: Error | null, data: Dispatcher.StreamData) => void): void;
32 /** Upgrade to a different protocol. */
33 upgrade(options: Dispatcher.UpgradeOptions): Promise<Dispatcher.UpgradeData>;
34 upgrade(options: Dispatcher.UpgradeOptions, callback: (err: Error | null, data: Dispatcher.UpgradeData) => void): void;
35 /** Closes the client and gracefully waits for enqueued requests to complete before invoking the callback (or returning a promise if no callback is provided). */
36 close(): Promise<void>;
37 close(callback: () => void): void;
38 /** 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. */
39 destroy(): Promise<void>;
40 destroy(err: Error | null): Promise<void>;
41 destroy(callback: () => void): void;
42 destroy(err: Error | null, callback: () => void): void;
43
44 on(eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this;
45 on(eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
46 on(eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
47 on(eventName: 'drain', callback: (origin: URL) => void): this;
48
49
50 once(eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this;
51 once(eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
52 once(eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
53 once(eventName: 'drain', callback: (origin: URL) => void): this;
54
55
56 off(eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this;
57 off(eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
58 off(eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
59 off(eventName: 'drain', callback: (origin: URL) => void): this;
60
61
62 addListener(eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this;
63 addListener(eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
64 addListener(eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
65 addListener(eventName: 'drain', callback: (origin: URL) => void): this;
66
67 removeListener(eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this;
68 removeListener(eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
69 removeListener(eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
70 removeListener(eventName: 'drain', callback: (origin: URL) => void): this;
71
72 prependListener(eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this;
73 prependListener(eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
74 prependListener(eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
75 prependListener(eventName: 'drain', callback: (origin: URL) => void): this;
76
77 prependOnceListener(eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this;
78 prependOnceListener(eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
79 prependOnceListener(eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
80 prependOnceListener(eventName: 'drain', callback: (origin: URL) => void): this;
81
82 listeners(eventName: 'connect'): ((origin: URL, targets: readonly Dispatcher[]) => void)[]
83 listeners(eventName: 'disconnect'): ((origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
84 listeners(eventName: 'connectionError'): ((origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
85 listeners(eventName: 'drain'): ((origin: URL) => void)[];
86
87 rawListeners(eventName: 'connect'): ((origin: URL, targets: readonly Dispatcher[]) => void)[]
88 rawListeners(eventName: 'disconnect'): ((origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
89 rawListeners(eventName: 'connectionError'): ((origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
90 rawListeners(eventName: 'drain'): ((origin: URL) => void)[];
91
92 emit(eventName: 'connect', origin: URL, targets: readonly Dispatcher[]): boolean;
93 emit(eventName: 'disconnect', origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError): boolean;
94 emit(eventName: 'connectionError', origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError): boolean;
95 emit(eventName: 'drain', origin: URL): boolean;
96}
97
98declare namespace Dispatcher {
99 export interface ComposedDispatcher extends Dispatcher {}
100 export type DispatcherComposeInterceptor = (dispatch: Dispatcher['dispatch']) => Dispatcher['dispatch'];
101 export interface DispatchOptions {
102 origin?: string | URL;
103 path: string;
104 method: HttpMethod;
105 /** Default: `null` */
106 body?: string | Buffer | Uint8Array | Readable | null | FormData;
107 /** Default: `null` */
108 headers?: IncomingHttpHeaders | string[] | Iterable<[string, string | string[] | undefined]> | null;
109 /** Query string params to be embedded in the request URL. Default: `null` */
110 query?: Record<string, any>;
111 /** 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`. */
112 idempotent?: boolean;
113 /** 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. */
114 blocking?: boolean;
115 /** Upgrade the request. Should be used to specify the kind of upgrade i.e. `'Websocket'`. Default: `method === 'CONNECT' || null`. */
116 upgrade?: boolean | string | null;
117 /** The amount of time, in milliseconds, the parser will wait to receive the complete HTTP headers. Defaults to 300 seconds. */
118 headersTimeout?: number | null;
119 /** The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use 0 to disable it entirely. Defaults to 300 seconds. */
120 bodyTimeout?: number | null;
121 /** Whether the request should stablish a keep-alive or not. Default `false` */
122 reset?: boolean;
123 /** Whether Undici should throw an error upon receiving a 4xx or 5xx response from the server. Defaults to false */
124 throwOnError?: boolean;
125 /** For H2, it appends the expect: 100-continue header, and halts the request body until a 100-continue is received from the remote server*/
126 expectContinue?: boolean;
127 }
128 export interface ConnectOptions {
129 origin: string | URL;
130 path: string;
131 /** Default: `null` */
132 headers?: IncomingHttpHeaders | string[] | null;
133 /** Default: `null` */
134 signal?: AbortSignal | EventEmitter | null;
135 /** This argument parameter is passed through to `ConnectData` */
136 opaque?: unknown;
137 /** Default: 0 */
138 maxRedirections?: number;
139 /** Default: false */
140 redirectionLimitReached?: boolean;
141 /** Default: `null` */
142 responseHeader?: 'raw' | null;
143 }
144 export interface RequestOptions extends DispatchOptions {
145 /** Default: `null` */
146 opaque?: unknown;
147 /** Default: `null` */
148 signal?: AbortSignal | EventEmitter | null;
149 /** Default: 0 */
150 maxRedirections?: number;
151 /** Default: false */
152 redirectionLimitReached?: boolean;
153 /** Default: `null` */
154 onInfo?: (info: { statusCode: number, headers: Record<string, string | string[]> }) => void;
155 /** Default: `null` */
156 responseHeader?: 'raw' | null;
157 /** Default: `64 KiB` */
158 highWaterMark?: number;
159 }
160 export interface PipelineOptions extends RequestOptions {
161 /** `true` if the `handler` will return an object stream. Default: `false` */
162 objectMode?: boolean;
163 }
164 export interface UpgradeOptions {
165 path: string;
166 /** Default: `'GET'` */
167 method?: string;
168 /** Default: `null` */
169 headers?: IncomingHttpHeaders | string[] | null;
170 /** A string of comma separated protocols, in descending preference order. Default: `'Websocket'` */
171 protocol?: string;
172 /** Default: `null` */
173 signal?: AbortSignal | EventEmitter | null;
174 /** Default: 0 */
175 maxRedirections?: number;
176 /** Default: false */
177 redirectionLimitReached?: boolean;
178 /** Default: `null` */
179 responseHeader?: 'raw' | null;
180 }
181 export interface ConnectData {
182 statusCode: number;
183 headers: IncomingHttpHeaders;
184 socket: Duplex;
185 opaque: unknown;
186 }
187 export interface ResponseData {
188 statusCode: number;
189 headers: IncomingHttpHeaders;
190 body: BodyReadable & BodyMixin;
191 trailers: Record<string, string>;
192 opaque: unknown;
193 context: object;
194 }
195 export interface PipelineHandlerData {
196 statusCode: number;
197 headers: IncomingHttpHeaders;
198 opaque: unknown;
199 body: BodyReadable;
200 context: object;
201 }
202 export interface StreamData {
203 opaque: unknown;
204 trailers: Record<string, string>;
205 }
206 export interface UpgradeData {
207 headers: IncomingHttpHeaders;
208 socket: Duplex;
209 opaque: unknown;
210 }
211 export interface StreamFactoryData {
212 statusCode: number;
213 headers: IncomingHttpHeaders;
214 opaque: unknown;
215 context: object;
216 }
217 export type StreamFactory = (data: StreamFactoryData) => Writable;
218 export interface DispatchHandlers {
219 /** 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. */
220 onConnect?(abort: (err?: Error) => void): void;
221 /** Invoked when an error has occurred. */
222 onError?(err: Error): void;
223 /** Invoked when request is upgraded either due to a `Upgrade` header or `CONNECT` method. */
224 onUpgrade?(statusCode: number, headers: Buffer[] | string[] | null, socket: Duplex): void;
225 /** Invoked when response is received, before headers have been read. **/
226 onResponseStarted?(): void;
227 /** Invoked when statusCode and headers have been received. May be invoked multiple times due to 1xx informational headers. */
228 onHeaders?(statusCode: number, headers: Buffer[], resume: () => void, statusText: string): boolean;
229 /** Invoked when response payload data is received. */
230 onData?(chunk: Buffer): boolean;
231 /** Invoked when response payload and trailers have been received and the request has completed. */
232 onComplete?(trailers: string[] | null): void;
233 /** Invoked when a body chunk is sent to the server. May be invoked multiple times for chunked requests */
234 onBodySent?(chunkSize: number, totalBytesSent: number): void;
235 }
236 export type PipelineHandler = (data: PipelineHandlerData) => Readable;
237 export type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH';
238
239 /**
240 * @link https://fetch.spec.whatwg.org/#body-mixin
241 */
242 interface BodyMixin {
243 readonly body?: never;
244 readonly bodyUsed: boolean;
245 arrayBuffer(): Promise<ArrayBuffer>;
246 blob(): Promise<Blob>;
247 bytes(): Promise<Uint8Array>;
248 formData(): Promise<never>;
249 json(): Promise<unknown>;
250 text(): Promise<string>;
251 }
252
253 export interface DispatchInterceptor {
254 (dispatch: Dispatcher['dispatch']): Dispatcher['dispatch']
255 }
256}
A /sublimated/undefined +43 -0
1import { URL, UrlObject } from 'url'
2import { Duplex } from 'stream'
3import Dispatcher from './dispatcher'
4
5export {
6 request,
7 stream,
8 pipeline,
9 connect,
10 upgrade,
11}
12
13/** Performs an HTTP request. */
14declare function request(
15 url: string | URL | UrlObject,
16 options?: { dispatcher?: Dispatcher } & Omit<Dispatcher.RequestOptions, 'origin' | 'path' | 'method'> & Partial<Pick<Dispatcher.RequestOptions, 'method'>>,
17): Promise<Dispatcher.ResponseData>;
18
19/** A faster version of `request`. */
20declare function stream(
21 url: string | URL | UrlObject,
22 options: { dispatcher?: Dispatcher } & Omit<Dispatcher.RequestOptions, 'origin' | 'path'>,
23 factory: Dispatcher.StreamFactory
24): Promise<Dispatcher.StreamData>;
25
26/** For easy use with `stream.pipeline`. */
27declare function pipeline(
28 url: string | URL | UrlObject,
29 options: { dispatcher?: Dispatcher } & Omit<Dispatcher.PipelineOptions, 'origin' | 'path'>,
30 handler: Dispatcher.PipelineHandler
31): Duplex;
32
33/** Starts two-way communications with the requested resource. */
34declare function connect(
35 url: string | URL | UrlObject,
36 options?: { dispatcher?: Dispatcher } & Omit<Dispatcher.ConnectOptions, 'origin' | 'path'>
37): Promise<Dispatcher.ConnectData>;
38
39/** Upgrade to a different protocol. */
40declare function upgrade(
41 url: string | URL | UrlObject,
42 options?: { dispatcher?: Dispatcher } & Omit<Dispatcher.UpgradeOptions, 'origin' | 'path'>
43): Promise<Dispatcher.UpgradeData>;
A /sublimated/undefined +61 -0
1import { MessageEvent, ErrorEvent } from './websocket'
2import Dispatcher from './dispatcher'
3
4import {
5 EventListenerOptions,
6 AddEventListenerOptions,
7 EventListenerOrEventListenerObject
8} from './patch'
9
10interface EventSourceEventMap {
11 error: ErrorEvent
12 message: MessageEvent
13 open: Event
14}
15
16interface EventSource extends EventTarget {
17 close(): void
18 readonly CLOSED: 2
19 readonly CONNECTING: 0
20 readonly OPEN: 1
21 onerror: (this: EventSource, ev: ErrorEvent) => any
22 onmessage: (this: EventSource, ev: MessageEvent) => any
23 onopen: (this: EventSource, ev: Event) => any
24 readonly readyState: 0 | 1 | 2
25 readonly url: string
26 readonly withCredentials: boolean
27
28 addEventListener<K extends keyof EventSourceEventMap>(
29 type: K,
30 listener: (this: EventSource, ev: EventSourceEventMap[K]) => any,
31 options?: boolean | AddEventListenerOptions
32 ): void
33 addEventListener(
34 type: string,
35 listener: EventListenerOrEventListenerObject,
36 options?: boolean | AddEventListenerOptions
37 ): void
38 removeEventListener<K extends keyof EventSourceEventMap>(
39 type: K,
40 listener: (this: EventSource, ev: EventSourceEventMap[K]) => any,
41 options?: boolean | EventListenerOptions
42 ): void
43 removeEventListener(
44 type: string,
45 listener: EventListenerOrEventListenerObject,
46 options?: boolean | EventListenerOptions
47 ): void
48}
49
50export declare const EventSource: {
51 prototype: EventSource
52 new (url: string | URL, init?: EventSourceInit): EventSource
53 readonly CLOSED: 2
54 readonly CONNECTING: 0
55 readonly OPEN: 1
56}
57
58interface EventSourceInit {
59 withCredentials?: boolean,
60 dispatcher?: Dispatcher
61}
A /sublimated/undefined +4 -0
1/**
2 * The header type declaration of `undici`.
3 */
4export type IncomingHttpHeaders = Record<string, string | string[] | undefined>;
A /sublimated/undefined +33 -0
1/// <reference types="node" />
2
3// See https://github.com/nodejs/undici/issues/1740
4
5export type DOMException = typeof globalThis extends { DOMException: infer T }
6 ? T
7 : any
8
9export interface EventInit {
10 bubbles?: boolean
11 cancelable?: boolean
12 composed?: boolean
13}
14
15export interface EventListenerOptions {
16 capture?: boolean
17}
18
19export interface AddEventListenerOptions extends EventListenerOptions {
20 once?: boolean
21 passive?: boolean
22 signal?: AbortSignal
23}
24
25export type EventListenerOrEventListenerObject = EventListener | EventListenerObject
26
27export interface EventListenerObject {
28 handleEvent (object: Event): void
29}
30
31export interface EventListener {
32 (evt: Event): void
33}
A /sublimated/undefined +39 -0
1// Based on https://github.com/octet-stream/form-data/blob/2d0f0dc371517444ce1f22cdde13f51995d0953a/lib/File.ts (MIT)
2/// <reference types="node" />
3
4import { Blob } from 'buffer'
5
6export interface BlobPropertyBag {
7 type?: string
8 endings?: 'native' | 'transparent'
9}
10
11export interface FilePropertyBag extends BlobPropertyBag {
12 /**
13 * 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.
14 */
15 lastModified?: number
16}
17
18export declare class File extends Blob {
19 /**
20 * Creates a new File instance.
21 *
22 * @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).
23 * @param fileName The name of the file.
24 * @param options An options object containing optional attributes for the file.
25 */
26 constructor(fileBits: ReadonlyArray<string | NodeJS.ArrayBufferView | Blob>, fileName: string, options?: FilePropertyBag)
27
28 /**
29 * Name of the file referenced by the File object.
30 */
31 readonly name: string
32
33 /**
34 * 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.
35 */
36 readonly lastModified: number
37
38 readonly [Symbol.toStringTag]: string
39}