@nanobpm/nano-agent-graph-engine 0.0.0-stage → 0.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +20 -0
- package/.claude-plugin/plugin.json +21 -0
- package/.mcp.json +8 -0
- package/README.md +525 -2
- package/dist/cli.js +55815 -0
- package/dist/explorer-app.html +196 -0
- package/dist/explorer.html +196 -0
- package/dist/guide.md +147 -0
- package/dist/index.js +1256 -0
- package/dist/layout-thread.js +12806 -0
- package/dist/nanobpmn_engine_bg.wasm +0 -0
- package/dist/step-thread.js +55 -0
- package/dist/typecheck/agent-graph-engine/agents.d.ts +120 -0
- package/dist/typecheck/agent-graph-engine/index.d.ts +124 -0
- package/dist/typecheck/agent-graph-engine/input.d.ts +57 -0
- package/dist/typecheck/agent-graph-engine/paths.d.ts +35 -0
- package/dist/typecheck/lib.decorators.d.ts +384 -0
- package/dist/typecheck/lib.decorators.legacy.d.ts +22 -0
- package/dist/typecheck/lib.es2015.collection.d.ts +147 -0
- package/dist/typecheck/lib.es2015.core.d.ts +597 -0
- package/dist/typecheck/lib.es2015.d.ts +28 -0
- package/dist/typecheck/lib.es2015.generator.d.ts +77 -0
- package/dist/typecheck/lib.es2015.iterable.d.ts +605 -0
- package/dist/typecheck/lib.es2015.promise.d.ts +81 -0
- package/dist/typecheck/lib.es2015.proxy.d.ts +128 -0
- package/dist/typecheck/lib.es2015.reflect.d.ts +144 -0
- package/dist/typecheck/lib.es2015.symbol.d.ts +46 -0
- package/dist/typecheck/lib.es2015.symbol.wellknown.d.ts +326 -0
- package/dist/typecheck/lib.es2016.array.include.d.ts +116 -0
- package/dist/typecheck/lib.es2016.d.ts +21 -0
- package/dist/typecheck/lib.es2016.full.d.ts +23 -0
- package/dist/typecheck/lib.es2016.intl.d.ts +31 -0
- package/dist/typecheck/lib.es2017.arraybuffer.d.ts +21 -0
- package/dist/typecheck/lib.es2017.d.ts +26 -0
- package/dist/typecheck/lib.es2017.date.d.ts +31 -0
- package/dist/typecheck/lib.es2017.full.d.ts +23 -0
- package/dist/typecheck/lib.es2017.intl.d.ts +44 -0
- package/dist/typecheck/lib.es2017.object.d.ts +49 -0
- package/dist/typecheck/lib.es2017.sharedmemory.d.ts +135 -0
- package/dist/typecheck/lib.es2017.string.d.ts +45 -0
- package/dist/typecheck/lib.es2017.typedarrays.d.ts +53 -0
- package/dist/typecheck/lib.es2018.asyncgenerator.d.ts +77 -0
- package/dist/typecheck/lib.es2018.asynciterable.d.ts +53 -0
- package/dist/typecheck/lib.es2018.d.ts +24 -0
- package/dist/typecheck/lib.es2018.full.d.ts +24 -0
- package/dist/typecheck/lib.es2018.intl.d.ts +83 -0
- package/dist/typecheck/lib.es2018.promise.d.ts +30 -0
- package/dist/typecheck/lib.es2018.regexp.d.ts +37 -0
- package/dist/typecheck/lib.es2019.array.d.ts +79 -0
- package/dist/typecheck/lib.es2019.d.ts +24 -0
- package/dist/typecheck/lib.es2019.full.d.ts +24 -0
- package/dist/typecheck/lib.es2019.intl.d.ts +23 -0
- package/dist/typecheck/lib.es2019.object.d.ts +33 -0
- package/dist/typecheck/lib.es2019.string.d.ts +37 -0
- package/dist/typecheck/lib.es2019.symbol.d.ts +24 -0
- package/dist/typecheck/lib.es2020.bigint.d.ts +765 -0
- package/dist/typecheck/lib.es2020.d.ts +27 -0
- package/dist/typecheck/lib.es2020.date.d.ts +42 -0
- package/dist/typecheck/lib.es2020.full.d.ts +24 -0
- package/dist/typecheck/lib.es2020.intl.d.ts +474 -0
- package/dist/typecheck/lib.es2020.number.d.ts +28 -0
- package/dist/typecheck/lib.es2020.promise.d.ts +47 -0
- package/dist/typecheck/lib.es2020.sharedmemory.d.ts +99 -0
- package/dist/typecheck/lib.es2020.string.d.ts +44 -0
- package/dist/typecheck/lib.es2020.symbol.wellknown.d.ts +41 -0
- package/dist/typecheck/lib.es2021.d.ts +23 -0
- package/dist/typecheck/lib.es2021.full.d.ts +24 -0
- package/dist/typecheck/lib.es2021.intl.d.ts +166 -0
- package/dist/typecheck/lib.es2021.promise.d.ts +48 -0
- package/dist/typecheck/lib.es2021.string.d.ts +33 -0
- package/dist/typecheck/lib.es2021.weakref.d.ts +78 -0
- package/dist/typecheck/lib.es2022.array.d.ts +121 -0
- package/dist/typecheck/lib.es2022.d.ts +25 -0
- package/dist/typecheck/lib.es2022.error.d.ts +75 -0
- package/dist/typecheck/lib.es2022.full.d.ts +24 -0
- package/dist/typecheck/lib.es2022.intl.d.ts +145 -0
- package/dist/typecheck/lib.es2022.object.d.ts +26 -0
- package/dist/typecheck/lib.es2022.regexp.d.ts +39 -0
- package/dist/typecheck/lib.es2022.string.d.ts +25 -0
- package/dist/typecheck/lib.es2023.array.d.ts +924 -0
- package/dist/typecheck/lib.es2023.collection.d.ts +21 -0
- package/dist/typecheck/lib.es2023.d.ts +22 -0
- package/dist/typecheck/lib.es2023.full.d.ts +24 -0
- package/dist/typecheck/lib.es2023.intl.d.ts +56 -0
- package/dist/typecheck/lib.es2024.arraybuffer.d.ts +65 -0
- package/dist/typecheck/lib.es2024.collection.d.ts +29 -0
- package/dist/typecheck/lib.es2024.d.ts +26 -0
- package/dist/typecheck/lib.es2024.full.d.ts +24 -0
- package/dist/typecheck/lib.es2024.object.d.ts +29 -0
- package/dist/typecheck/lib.es2024.promise.d.ts +35 -0
- package/dist/typecheck/lib.es2024.regexp.d.ts +25 -0
- package/dist/typecheck/lib.es2024.sharedmemory.d.ts +68 -0
- package/dist/typecheck/lib.es2024.string.d.ts +29 -0
- package/dist/typecheck/lib.es5.d.ts +4601 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/client.d.ts +169 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/declarative.d.ts +366 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/envelope.d.ts +77 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/imperative.d.ts +32 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/index.d.ts +14 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/io-mapping.d.ts +32 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/layout.d.ts +22 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/boundary.d.ts +63 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/branch.d.ts +11 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/break.d.ts +8 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/continue.d.ts +8 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/end.d.ts +40 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/forEach.d.ts +24 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/human.d.ts +44 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/index.d.ts +15 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/loop.d.ts +9 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/parallel.d.ts +9 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/race.d.ts +54 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/registry.d.ts +33 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/run.d.ts +12 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/signal.d.ts +11 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/switch.d.ts +11 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/task.d.ts +82 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/timer.d.ts +9 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/test-support/diff.d.ts +8 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/test-support/index.d.ts +8 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/test-support/normalize.d.ts +19 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/test-support/parity.d.ts +28 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/test-support/xml.d.ts +17 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/types.d.ts +146 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/worker.d.ts +92 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/xml.d.ts +14 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/package.json +65 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/src/bpmn-auto-layout.d.ts +10 -0
- package/dist/typecheck/node_modules/@types/node/assert/strict.d.ts +68 -0
- package/dist/typecheck/node_modules/@types/node/assert.d.ts +1077 -0
- package/dist/typecheck/node_modules/@types/node/async_hooks.d.ts +711 -0
- package/dist/typecheck/node_modules/@types/node/buffer.buffer.d.ts +471 -0
- package/dist/typecheck/node_modules/@types/node/buffer.d.ts +1800 -0
- package/dist/typecheck/node_modules/@types/node/child_process.d.ts +1361 -0
- package/dist/typecheck/node_modules/@types/node/cluster.d.ts +432 -0
- package/dist/typecheck/node_modules/@types/node/console.d.ts +93 -0
- package/dist/typecheck/node_modules/@types/node/constants.d.ts +14 -0
- package/dist/typecheck/node_modules/@types/node/crypto.d.ts +3964 -0
- package/dist/typecheck/node_modules/@types/node/dgram.d.ts +652 -0
- package/dist/typecheck/node_modules/@types/node/diagnostics_channel.d.ts +794 -0
- package/dist/typecheck/node_modules/@types/node/dns/promises.d.ts +497 -0
- package/dist/typecheck/node_modules/@types/node/dns.d.ts +876 -0
- package/dist/typecheck/node_modules/@types/node/domain.d.ts +150 -0
- package/dist/typecheck/node_modules/@types/node/events.d.ts +1008 -0
- package/dist/typecheck/node_modules/@types/node/ffi.d.ts +500 -0
- package/dist/typecheck/node_modules/@types/node/fs/promises.d.ts +1477 -0
- package/dist/typecheck/node_modules/@types/node/fs.d.ts +4803 -0
- package/dist/typecheck/node_modules/@types/node/globals.d.ts +150 -0
- package/dist/typecheck/node_modules/@types/node/globals.typedarray.d.ts +101 -0
- package/dist/typecheck/node_modules/@types/node/http.d.ts +2218 -0
- package/dist/typecheck/node_modules/@types/node/http2.d.ts +2498 -0
- package/dist/typecheck/node_modules/@types/node/https.d.ts +400 -0
- package/dist/typecheck/node_modules/@types/node/index.d.ts +116 -0
- package/dist/typecheck/node_modules/@types/node/inspector/promises.d.ts +35 -0
- package/dist/typecheck/node_modules/@types/node/inspector.d.ts +265 -0
- package/dist/typecheck/node_modules/@types/node/inspector.generated.d.ts +4406 -0
- package/dist/typecheck/node_modules/@types/node/module.d.ts +726 -0
- package/dist/typecheck/node_modules/@types/node/net.d.ts +1074 -0
- package/dist/typecheck/node_modules/@types/node/os.d.ts +498 -0
- package/dist/typecheck/node_modules/@types/node/package.json +140 -0
- package/dist/typecheck/node_modules/@types/node/path/posix.d.ts +8 -0
- package/dist/typecheck/node_modules/@types/node/path/win32.d.ts +8 -0
- package/dist/typecheck/node_modules/@types/node/path.d.ts +178 -0
- package/dist/typecheck/node_modules/@types/node/perf_hooks.d.ts +617 -0
- package/dist/typecheck/node_modules/@types/node/process.d.ts +2269 -0
- package/dist/typecheck/node_modules/@types/node/punycode.d.ts +89 -0
- package/dist/typecheck/node_modules/@types/node/querystring.d.ts +139 -0
- package/dist/typecheck/node_modules/@types/node/quic.d.ts +2191 -0
- package/dist/typecheck/node_modules/@types/node/readline/promises.d.ts +158 -0
- package/dist/typecheck/node_modules/@types/node/readline.d.ts +508 -0
- package/dist/typecheck/node_modules/@types/node/repl.d.ts +420 -0
- package/dist/typecheck/node_modules/@types/node/sea.d.ts +47 -0
- package/dist/typecheck/node_modules/@types/node/sqlite.d.ts +1140 -0
- package/dist/typecheck/node_modules/@types/node/stream/consumers.d.ts +114 -0
- package/dist/typecheck/node_modules/@types/node/stream/iter.d.ts +449 -0
- package/dist/typecheck/node_modules/@types/node/stream/promises.d.ts +211 -0
- package/dist/typecheck/node_modules/@types/node/stream/web.d.ts +320 -0
- package/dist/typecheck/node_modules/@types/node/stream.d.ts +1806 -0
- package/dist/typecheck/node_modules/@types/node/string_decoder.d.ts +27 -0
- package/dist/typecheck/node_modules/@types/node/test/reporters.d.ts +60 -0
- package/dist/typecheck/node_modules/@types/node/test.d.ts +2558 -0
- package/dist/typecheck/node_modules/@types/node/timers/promises.d.ts +93 -0
- package/dist/typecheck/node_modules/@types/node/timers.d.ts +149 -0
- package/dist/typecheck/node_modules/@types/node/tls.d.ts +1232 -0
- package/dist/typecheck/node_modules/@types/node/trace_events.d.ts +103 -0
- package/dist/typecheck/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +467 -0
- package/dist/typecheck/node_modules/@types/node/ts5.6/compatibility/float16array.d.ts +71 -0
- package/dist/typecheck/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +36 -0
- package/dist/typecheck/node_modules/@types/node/ts5.6/index.d.ts +118 -0
- package/dist/typecheck/node_modules/@types/node/ts5.7/compatibility/float16array.d.ts +72 -0
- package/dist/typecheck/node_modules/@types/node/ts5.7/index.d.ts +118 -0
- package/dist/typecheck/node_modules/@types/node/tty.d.ts +226 -0
- package/dist/typecheck/node_modules/@types/node/url.d.ts +556 -0
- package/dist/typecheck/node_modules/@types/node/util/types.d.ts +558 -0
- package/dist/typecheck/node_modules/@types/node/util.d.ts +1680 -0
- package/dist/typecheck/node_modules/@types/node/v8.d.ts +1059 -0
- package/dist/typecheck/node_modules/@types/node/vfs.d.ts +211 -0
- package/dist/typecheck/node_modules/@types/node/vm.d.ts +1137 -0
- package/dist/typecheck/node_modules/@types/node/wasi.d.ts +131 -0
- package/dist/typecheck/node_modules/@types/node/web-globals/abortcontroller.d.ts +59 -0
- package/dist/typecheck/node_modules/@types/node/web-globals/blob.d.ts +23 -0
- package/dist/typecheck/node_modules/@types/node/web-globals/console.d.ts +9 -0
- package/dist/typecheck/node_modules/@types/node/web-globals/crypto.d.ts +39 -0
- package/dist/typecheck/node_modules/@types/node/web-globals/domexception.d.ts +83 -0
- package/dist/typecheck/node_modules/@types/node/web-globals/encoding.d.ts +11 -0
- package/dist/typecheck/node_modules/@types/node/web-globals/events.d.ts +106 -0
- package/dist/typecheck/node_modules/@types/node/web-globals/fetch.d.ts +69 -0
- package/dist/typecheck/node_modules/@types/node/web-globals/importmeta.d.ts +13 -0
- package/dist/typecheck/node_modules/@types/node/web-globals/messaging.d.ts +23 -0
- package/dist/typecheck/node_modules/@types/node/web-globals/navigator.d.ts +25 -0
- package/dist/typecheck/node_modules/@types/node/web-globals/performance.d.ts +45 -0
- package/dist/typecheck/node_modules/@types/node/web-globals/storage.d.ts +24 -0
- package/dist/typecheck/node_modules/@types/node/web-globals/streams.d.ts +119 -0
- package/dist/typecheck/node_modules/@types/node/web-globals/timers.d.ts +44 -0
- package/dist/typecheck/node_modules/@types/node/web-globals/url.d.ts +24 -0
- package/dist/typecheck/node_modules/@types/node/worker_threads.d.ts +672 -0
- package/dist/typecheck/node_modules/@types/node/zlib/iter.d.ts +131 -0
- package/dist/typecheck/node_modules/@types/node/zlib.d.ts +1364 -0
- package/dist/typecheck/node_modules/undici-types/agent.d.ts +30 -0
- package/dist/typecheck/node_modules/undici-types/api.d.ts +43 -0
- package/dist/typecheck/node_modules/undici-types/balanced-pool.d.ts +30 -0
- package/dist/typecheck/node_modules/undici-types/cache-interceptor.d.ts +179 -0
- package/dist/typecheck/node_modules/undici-types/cache.d.ts +36 -0
- package/dist/typecheck/node_modules/undici-types/client-stats.d.ts +15 -0
- package/dist/typecheck/node_modules/undici-types/client.d.ts +134 -0
- package/dist/typecheck/node_modules/undici-types/connector.d.ts +37 -0
- package/dist/typecheck/node_modules/undici-types/content-type.d.ts +21 -0
- package/dist/typecheck/node_modules/undici-types/cookies.d.ts +30 -0
- package/dist/typecheck/node_modules/undici-types/diagnostics-channel.d.ts +74 -0
- package/dist/typecheck/node_modules/undici-types/dispatcher.d.ts +253 -0
- package/dist/typecheck/node_modules/undici-types/dispatcher1-wrapper.d.ts +7 -0
- package/dist/typecheck/node_modules/undici-types/env-http-proxy-agent.d.ts +22 -0
- package/dist/typecheck/node_modules/undici-types/errors.d.ts +187 -0
- package/dist/typecheck/node_modules/undici-types/eventsource.d.ts +66 -0
- package/dist/typecheck/node_modules/undici-types/fetch.d.ts +235 -0
- package/dist/typecheck/node_modules/undici-types/formdata.d.ts +108 -0
- package/dist/typecheck/node_modules/undici-types/global-dispatcher.d.ts +9 -0
- package/dist/typecheck/node_modules/undici-types/global-origin.d.ts +7 -0
- package/dist/typecheck/node_modules/undici-types/h2c-client.d.ts +73 -0
- package/dist/typecheck/node_modules/undici-types/handlers.d.ts +16 -0
- package/dist/typecheck/node_modules/undici-types/header.d.ts +165 -0
- package/dist/typecheck/node_modules/undici-types/index.d.ts +93 -0
- package/dist/typecheck/node_modules/undici-types/interceptors.d.ts +80 -0
- package/dist/typecheck/node_modules/undici-types/mock-agent.d.ts +68 -0
- package/dist/typecheck/node_modules/undici-types/mock-call-history.d.ts +111 -0
- package/dist/typecheck/node_modules/undici-types/mock-client.d.ts +27 -0
- package/dist/typecheck/node_modules/undici-types/mock-errors.d.ts +12 -0
- package/dist/typecheck/node_modules/undici-types/mock-interceptor.d.ts +98 -0
- package/dist/typecheck/node_modules/undici-types/mock-pool.d.ts +27 -0
- package/dist/typecheck/node_modules/undici-types/package.json +55 -0
- package/dist/typecheck/node_modules/undici-types/patch.d.ts +29 -0
- package/dist/typecheck/node_modules/undici-types/pool-stats.d.ts +19 -0
- package/dist/typecheck/node_modules/undici-types/pool.d.ts +39 -0
- package/dist/typecheck/node_modules/undici-types/proxy-agent.d.ts +36 -0
- package/dist/typecheck/node_modules/undici-types/readable.d.ts +68 -0
- package/dist/typecheck/node_modules/undici-types/retry-agent.d.ts +8 -0
- package/dist/typecheck/node_modules/undici-types/retry-handler.d.ts +125 -0
- package/dist/typecheck/node_modules/undici-types/round-robin-pool.d.ts +39 -0
- package/dist/typecheck/node_modules/undici-types/snapshot-agent.d.ts +113 -0
- package/dist/typecheck/node_modules/undici-types/socks5-proxy-agent.d.ts +25 -0
- package/dist/typecheck/node_modules/undici-types/util.d.ts +18 -0
- package/dist/typecheck/node_modules/undici-types/utility.d.ts +7 -0
- package/dist/typecheck/node_modules/undici-types/webidl.d.ts +346 -0
- package/dist/typecheck/node_modules/undici-types/websocket.d.ts +188 -0
- package/dist/typecheck/ts.cjs +446 -0
- package/hooks/hooks.json +30 -0
- package/hooks/mod.js +461 -0
- package/package.json +80 -4
- package/skills/agent-graph/SKILL.md +47 -0
- package/skills/agent-graph-authoring/SKILL.md +147 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { URL } from 'node:url'
|
|
2
|
+
import Pool from './pool'
|
|
3
|
+
import Dispatcher from './dispatcher'
|
|
4
|
+
import TClientStats from './client-stats'
|
|
5
|
+
import TPoolStats from './pool-stats'
|
|
6
|
+
|
|
7
|
+
export default Agent
|
|
8
|
+
|
|
9
|
+
declare class Agent extends Dispatcher {
|
|
10
|
+
constructor (opts?: Agent.Options)
|
|
11
|
+
/** `true` after `dispatcher.close()` has been called. */
|
|
12
|
+
closed: boolean
|
|
13
|
+
/** `true` after `dispatcher.destroyed()` has been called or `dispatcher.close()` has been called and the dispatcher shutdown has completed. */
|
|
14
|
+
destroyed: boolean
|
|
15
|
+
/** Dispatches a request. */
|
|
16
|
+
dispatch (options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandler): boolean
|
|
17
|
+
/** Aggregate stats for a Agent by origin. */
|
|
18
|
+
readonly stats: Record<string, TClientStats | TPoolStats>
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare namespace Agent {
|
|
22
|
+
export interface Options extends Pool.Options {
|
|
23
|
+
/** Default: `(origin, opts) => new Pool(origin, opts)`. */
|
|
24
|
+
factory?(origin: string | URL, opts: Object): Dispatcher;
|
|
25
|
+
maxOrigins?: number
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface DispatchOptions extends Dispatcher.DispatchOptions {
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { URL, UrlObject } from 'node:url'
|
|
2
|
+
import { Duplex } from 'node:stream'
|
|
3
|
+
import Dispatcher from './dispatcher'
|
|
4
|
+
|
|
5
|
+
/** Performs an HTTP request. */
|
|
6
|
+
declare function request<TOpaque = null> (
|
|
7
|
+
url: string | URL | UrlObject,
|
|
8
|
+
options?: { dispatcher?: Dispatcher } & Omit<Dispatcher.RequestOptions<TOpaque>, 'origin' | 'path' | 'method'> & Partial<Pick<Dispatcher.RequestOptions, 'method'>>,
|
|
9
|
+
): Promise<Dispatcher.ResponseData<TOpaque>>
|
|
10
|
+
|
|
11
|
+
/** A faster version of `request`. */
|
|
12
|
+
declare function stream<TOpaque = null> (
|
|
13
|
+
url: string | URL | UrlObject,
|
|
14
|
+
options: { dispatcher?: Dispatcher } & Omit<Dispatcher.RequestOptions<TOpaque>, 'origin' | 'path'>,
|
|
15
|
+
factory: Dispatcher.StreamFactory<TOpaque>
|
|
16
|
+
): Promise<Dispatcher.StreamData<TOpaque>>
|
|
17
|
+
|
|
18
|
+
/** For easy use with `stream.pipeline`. */
|
|
19
|
+
declare function pipeline<TOpaque = null> (
|
|
20
|
+
url: string | URL | UrlObject,
|
|
21
|
+
options: { dispatcher?: Dispatcher } & Omit<Dispatcher.PipelineOptions<TOpaque>, 'origin' | 'path'>,
|
|
22
|
+
handler: Dispatcher.PipelineHandler<TOpaque>
|
|
23
|
+
): Duplex
|
|
24
|
+
|
|
25
|
+
/** Starts two-way communications with the requested resource. */
|
|
26
|
+
declare function connect<TOpaque = null> (
|
|
27
|
+
url: string | URL | UrlObject,
|
|
28
|
+
options?: { dispatcher?: Dispatcher } & Omit<Dispatcher.ConnectOptions<TOpaque>, 'origin' | 'path'>
|
|
29
|
+
): Promise<Dispatcher.ConnectData<TOpaque>>
|
|
30
|
+
|
|
31
|
+
/** Upgrade to a different protocol. */
|
|
32
|
+
declare function upgrade (
|
|
33
|
+
url: string | URL | UrlObject,
|
|
34
|
+
options?: { dispatcher?: Dispatcher } & Omit<Dispatcher.UpgradeOptions, 'origin' | 'path'>
|
|
35
|
+
): Promise<Dispatcher.UpgradeData>
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
request,
|
|
39
|
+
stream,
|
|
40
|
+
pipeline,
|
|
41
|
+
connect,
|
|
42
|
+
upgrade
|
|
43
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import Pool from './pool'
|
|
2
|
+
import Dispatcher from './dispatcher'
|
|
3
|
+
import { URL } from 'node:url'
|
|
4
|
+
|
|
5
|
+
export default BalancedPool
|
|
6
|
+
|
|
7
|
+
type BalancedPoolConnectOptions = Omit<Dispatcher.ConnectOptions, 'origin'>
|
|
8
|
+
|
|
9
|
+
declare class BalancedPool extends Dispatcher {
|
|
10
|
+
constructor (url: string | string[] | URL | URL[], options?: Pool.Options)
|
|
11
|
+
|
|
12
|
+
addUpstream (upstream: string | URL): BalancedPool
|
|
13
|
+
removeUpstream (upstream: string | URL): BalancedPool
|
|
14
|
+
getUpstream (upstream: string | URL): Pool | undefined
|
|
15
|
+
upstreams: Array<string>
|
|
16
|
+
|
|
17
|
+
/** `true` after `pool.close()` has been called. */
|
|
18
|
+
closed: boolean
|
|
19
|
+
/** `true` after `pool.destroyed()` has been called or `pool.close()` has been called and the pool shutdown has completed. */
|
|
20
|
+
destroyed: boolean
|
|
21
|
+
|
|
22
|
+
// Override dispatcher APIs.
|
|
23
|
+
override connect (
|
|
24
|
+
options: BalancedPoolConnectOptions
|
|
25
|
+
): Promise<Dispatcher.ConnectData>
|
|
26
|
+
override connect (
|
|
27
|
+
options: BalancedPoolConnectOptions,
|
|
28
|
+
callback: (err: Error | null, data: Dispatcher.ConnectData) => void
|
|
29
|
+
): void
|
|
30
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { Readable, Writable } from 'node:stream'
|
|
2
|
+
|
|
3
|
+
export default CacheHandler
|
|
4
|
+
|
|
5
|
+
declare namespace CacheHandler {
|
|
6
|
+
export type CacheMethods = 'GET' | 'HEAD' | 'OPTIONS' | 'TRACE'
|
|
7
|
+
|
|
8
|
+
export interface CacheHandlerOptions {
|
|
9
|
+
store: CacheStore
|
|
10
|
+
|
|
11
|
+
cacheByDefault?: number
|
|
12
|
+
|
|
13
|
+
type?: CacheOptions['type']
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface CacheOptions {
|
|
17
|
+
store?: CacheStore
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The methods to cache
|
|
21
|
+
* Note we can only cache safe methods. Unsafe methods (i.e. PUT, POST)
|
|
22
|
+
* invalidate the cache for a origin.
|
|
23
|
+
* @see https://www.rfc-editor.org/rfc/rfc9111.html#name-invalidating-stored-respons
|
|
24
|
+
* @see https://www.rfc-editor.org/rfc/rfc9110#section-9.2.1
|
|
25
|
+
*/
|
|
26
|
+
methods?: CacheMethods[]
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* RFC9111 allows for caching responses that we aren't explicitly told to
|
|
30
|
+
* cache or to not cache.
|
|
31
|
+
* @see https://www.rfc-editor.org/rfc/rfc9111.html#section-3-5
|
|
32
|
+
* @default undefined
|
|
33
|
+
*/
|
|
34
|
+
cacheByDefault?: number
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* TODO docs
|
|
38
|
+
* @default 'shared'
|
|
39
|
+
*/
|
|
40
|
+
type?: 'shared' | 'private'
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Array of origins to cache. Only requests to these origins will be cached.
|
|
44
|
+
* Supports strings (case insensitive) and RegExp patterns.
|
|
45
|
+
* @default undefined (cache all origins)
|
|
46
|
+
*/
|
|
47
|
+
origins?: (string | RegExp)[]
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface CacheControlDirectives {
|
|
51
|
+
'max-stale'?: number;
|
|
52
|
+
'min-fresh'?: number;
|
|
53
|
+
'max-age'?: number;
|
|
54
|
+
's-maxage'?: number;
|
|
55
|
+
'stale-while-revalidate'?: number;
|
|
56
|
+
'stale-if-error'?: number;
|
|
57
|
+
public?: true;
|
|
58
|
+
private?: true | string[];
|
|
59
|
+
'no-store'?: true;
|
|
60
|
+
'no-cache'?: true | string[];
|
|
61
|
+
'must-revalidate'?: true;
|
|
62
|
+
'proxy-revalidate'?: true;
|
|
63
|
+
immutable?: true;
|
|
64
|
+
'no-transform'?: true;
|
|
65
|
+
'must-understand'?: true;
|
|
66
|
+
'only-if-cached'?: true;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface CacheKey {
|
|
70
|
+
origin: string
|
|
71
|
+
method: string
|
|
72
|
+
path: string
|
|
73
|
+
headers?: Record<string, string | string[]>
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface CacheValue {
|
|
77
|
+
statusCode: number
|
|
78
|
+
statusMessage: string
|
|
79
|
+
headers: Record<string, string | string[]>
|
|
80
|
+
vary?: Record<string, string | string[] | null>
|
|
81
|
+
etag?: string
|
|
82
|
+
cacheControlDirectives?: CacheControlDirectives
|
|
83
|
+
cachedAt: number
|
|
84
|
+
staleAt: number
|
|
85
|
+
deleteAt: number
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface DeleteByUri {
|
|
89
|
+
origin: string
|
|
90
|
+
method: string
|
|
91
|
+
path: string
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
type GetResult = {
|
|
95
|
+
statusCode: number
|
|
96
|
+
statusMessage: string
|
|
97
|
+
headers: Record<string, string | string[]>
|
|
98
|
+
vary?: Record<string, string | string[] | null>
|
|
99
|
+
etag?: string
|
|
100
|
+
body?: Readable | Iterable<Buffer> | AsyncIterable<Buffer> | Buffer | Iterable<string> | AsyncIterable<string> | string
|
|
101
|
+
cacheControlDirectives: CacheControlDirectives,
|
|
102
|
+
cachedAt: number
|
|
103
|
+
staleAt: number
|
|
104
|
+
deleteAt: number
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Underlying storage provider for cached responses
|
|
109
|
+
*/
|
|
110
|
+
export interface CacheStore {
|
|
111
|
+
get(key: CacheKey): GetResult | Promise<GetResult | undefined> | undefined
|
|
112
|
+
|
|
113
|
+
createWriteStream(key: CacheKey, val: CacheValue): Writable | undefined
|
|
114
|
+
|
|
115
|
+
delete(key: CacheKey): void | Promise<void>
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface MemoryCacheStoreOpts {
|
|
119
|
+
/**
|
|
120
|
+
* @default Infinity
|
|
121
|
+
*/
|
|
122
|
+
maxCount?: number
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* @default Infinity
|
|
126
|
+
*/
|
|
127
|
+
maxSize?: number
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* @default Infinity
|
|
131
|
+
*/
|
|
132
|
+
maxEntrySize?: number
|
|
133
|
+
|
|
134
|
+
errorCallback?: (err: Error) => void
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export class MemoryCacheStore implements CacheStore {
|
|
138
|
+
constructor (opts?: MemoryCacheStoreOpts)
|
|
139
|
+
|
|
140
|
+
get (key: CacheKey): GetResult | Promise<GetResult | undefined> | undefined
|
|
141
|
+
|
|
142
|
+
createWriteStream (key: CacheKey, value: CacheValue): Writable | undefined
|
|
143
|
+
|
|
144
|
+
delete (key: CacheKey): void | Promise<void>
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export interface SqliteCacheStoreOpts {
|
|
148
|
+
/**
|
|
149
|
+
* Location of the database
|
|
150
|
+
* @default ':memory:'
|
|
151
|
+
*/
|
|
152
|
+
location?: string
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* @default Infinity
|
|
156
|
+
*/
|
|
157
|
+
maxCount?: number
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* @default Infinity
|
|
161
|
+
*/
|
|
162
|
+
maxEntrySize?: number
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export class SqliteCacheStore implements CacheStore {
|
|
166
|
+
constructor (opts?: SqliteCacheStoreOpts)
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Closes the connection to the database
|
|
170
|
+
*/
|
|
171
|
+
close (): void
|
|
172
|
+
|
|
173
|
+
get (key: CacheKey): GetResult | Promise<GetResult | undefined> | undefined
|
|
174
|
+
|
|
175
|
+
createWriteStream (key: CacheKey, value: CacheValue): Writable | undefined
|
|
176
|
+
|
|
177
|
+
delete (key: CacheKey): void | Promise<void>
|
|
178
|
+
}
|
|
179
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { RequestInfo, Response, Request } from './fetch'
|
|
2
|
+
|
|
3
|
+
export interface CacheStorage {
|
|
4
|
+
match (request: RequestInfo, options?: MultiCacheQueryOptions): Promise<Response | undefined>,
|
|
5
|
+
has (cacheName: string): Promise<boolean>,
|
|
6
|
+
open (cacheName: string): Promise<Cache>,
|
|
7
|
+
delete (cacheName: string): Promise<boolean>,
|
|
8
|
+
keys (): Promise<string[]>
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
declare const CacheStorage: {
|
|
12
|
+
prototype: CacheStorage
|
|
13
|
+
new(): CacheStorage
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface Cache {
|
|
17
|
+
match (request: RequestInfo, options?: CacheQueryOptions): Promise<Response | undefined>,
|
|
18
|
+
matchAll (request?: RequestInfo, options?: CacheQueryOptions): Promise<readonly Response[]>,
|
|
19
|
+
add (request: RequestInfo): Promise<undefined>,
|
|
20
|
+
addAll (requests: RequestInfo[]): Promise<undefined>,
|
|
21
|
+
put (request: RequestInfo, response: Response): Promise<undefined>,
|
|
22
|
+
delete (request: RequestInfo, options?: CacheQueryOptions): Promise<boolean>,
|
|
23
|
+
keys (request?: RequestInfo, options?: CacheQueryOptions): Promise<readonly Request[]>
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface CacheQueryOptions {
|
|
27
|
+
ignoreSearch?: boolean,
|
|
28
|
+
ignoreMethod?: boolean,
|
|
29
|
+
ignoreVary?: boolean
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface MultiCacheQueryOptions extends CacheQueryOptions {
|
|
33
|
+
cacheName?: string
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export declare const caches: CacheStorage
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Client from './client'
|
|
2
|
+
|
|
3
|
+
export default ClientStats
|
|
4
|
+
|
|
5
|
+
declare class ClientStats {
|
|
6
|
+
constructor (pool: Client)
|
|
7
|
+
/** If socket has open connection. */
|
|
8
|
+
connected: boolean
|
|
9
|
+
/** Number of open socket connections in this client that do not have an active request. */
|
|
10
|
+
pending: number
|
|
11
|
+
/** Number of currently active requests of this client. */
|
|
12
|
+
running: number
|
|
13
|
+
/** Number of active, pending, or queued requests of this client. */
|
|
14
|
+
size: number
|
|
15
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { URL } from 'node:url'
|
|
2
|
+
import Dispatcher from './dispatcher'
|
|
3
|
+
import buildConnector from './connector'
|
|
4
|
+
import TClientStats from './client-stats'
|
|
5
|
+
|
|
6
|
+
type ClientConnectOptions<TOpaque = null> = Omit<Dispatcher.ConnectOptions<TOpaque>, 'origin'>
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A basic HTTP/1.1 client, mapped on top a single TCP/TLS connection. Pipelining is disabled by default.
|
|
10
|
+
*/
|
|
11
|
+
export class Client extends Dispatcher {
|
|
12
|
+
constructor (url: string | URL, options?: Client.Options)
|
|
13
|
+
/** Property to get and set the pipelining factor. */
|
|
14
|
+
pipelining: number
|
|
15
|
+
/** `true` after `client.close()` has been called. */
|
|
16
|
+
closed: boolean
|
|
17
|
+
/** `true` after `client.destroyed()` has been called or `client.close()` has been called and the client shutdown has completed. */
|
|
18
|
+
destroyed: boolean
|
|
19
|
+
/** Aggregate stats for a Client. */
|
|
20
|
+
readonly stats: TClientStats
|
|
21
|
+
|
|
22
|
+
// Override dispatcher APIs.
|
|
23
|
+
override connect<TOpaque = null> (
|
|
24
|
+
options: ClientConnectOptions<TOpaque>
|
|
25
|
+
): Promise<Dispatcher.ConnectData<TOpaque>>
|
|
26
|
+
override connect<TOpaque = null> (
|
|
27
|
+
options: ClientConnectOptions<TOpaque>,
|
|
28
|
+
callback: (err: Error | null, data: Dispatcher.ConnectData<TOpaque>) => void
|
|
29
|
+
): void
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export declare namespace Client {
|
|
33
|
+
export interface Options {
|
|
34
|
+
/** The maximum length of request headers in bytes. Default: Node.js' `--max-http-header-size` or `16384` (16KiB). */
|
|
35
|
+
maxHeaderSize?: number;
|
|
36
|
+
/** 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). HTTP/1.1 parser timeouts are not guaranteed to fire with exact millisecond precision: delays up to 1000ms use native timers, while larger delays use lower-overhead fast timers with a target resolution around 500ms. */
|
|
37
|
+
headersTimeout?: number;
|
|
38
|
+
/** @deprecated unsupported socketTimeout, use headersTimeout & bodyTimeout instead */
|
|
39
|
+
socketTimeout?: never;
|
|
40
|
+
/** @deprecated unsupported requestTimeout, use headersTimeout & bodyTimeout instead */
|
|
41
|
+
requestTimeout?: never;
|
|
42
|
+
/** The timeout for establishing a socket connection, in milliseconds. Use `0` to disable it entirely. Default: `10e3` milliseconds (10s). */
|
|
43
|
+
connectTimeout?: number;
|
|
44
|
+
/** 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). HTTP/1.1 parser timeouts are not guaranteed to fire with exact millisecond precision: delays up to 1000ms use native timers, while larger delays use lower-overhead fast timers with a target resolution around 500ms. */
|
|
45
|
+
bodyTimeout?: number;
|
|
46
|
+
/** @deprecated unsupported idleTimeout, use keepAliveTimeout instead */
|
|
47
|
+
idleTimeout?: never;
|
|
48
|
+
/** @deprecated unsupported keepAlive, use pipelining=0 instead */
|
|
49
|
+
keepAlive?: never;
|
|
50
|
+
/** 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). */
|
|
51
|
+
keepAliveTimeout?: number;
|
|
52
|
+
/** @deprecated unsupported maxKeepAliveTimeout, use keepAliveMaxTimeout instead */
|
|
53
|
+
maxKeepAliveTimeout?: never;
|
|
54
|
+
/** the maximum allowed `idleTimeout`, in milliseconds, when overridden by *keep-alive* hints from the server. Default: `600e3` milliseconds (10min). */
|
|
55
|
+
keepAliveMaxTimeout?: number;
|
|
56
|
+
/** 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). */
|
|
57
|
+
keepAliveTimeoutThreshold?: number;
|
|
58
|
+
/** An IPC endpoint, either a Unix domain socket or Windows named pipe. Default: `null`. */
|
|
59
|
+
socketPath?: string;
|
|
60
|
+
/** 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). Only enable values greater than `1` when the remote server is trusted. Default: `1`. */
|
|
61
|
+
pipelining?: number;
|
|
62
|
+
/** @deprecated use the connect option instead */
|
|
63
|
+
tls?: never;
|
|
64
|
+
/** If `true`, an error is thrown when the request content-length header doesn't match the length of the request body. Default: `true`. */
|
|
65
|
+
strictContentLength?: boolean;
|
|
66
|
+
/** Maximum number of TLS cached sessions used by the built-in connector. Use `0` to disable TLS session caching. Default: `100`. */
|
|
67
|
+
maxCachedSessions?: number;
|
|
68
|
+
/** Connector options passed to `buildConnector`, or a custom connector function. Default: `null`. */
|
|
69
|
+
connect?: Partial<buildConnector.BuildOptions> | buildConnector.connector;
|
|
70
|
+
/** The maximum number of requests to send over a single connection before it is reset. Use `0` to disable this limit. Default: `null`. */
|
|
71
|
+
maxRequestsPerClient?: number;
|
|
72
|
+
/** Local IP address the socket should connect from. */
|
|
73
|
+
localAddress?: string;
|
|
74
|
+
/** Max response body size in bytes, -1 is disabled */
|
|
75
|
+
maxResponseSize?: number;
|
|
76
|
+
/** WebSocket-specific options */
|
|
77
|
+
webSocket?: Client.WebSocketOptions;
|
|
78
|
+
/** Enables a family autodetection algorithm that loosely implements section 5 of RFC 8305. */
|
|
79
|
+
autoSelectFamily?: boolean;
|
|
80
|
+
/** The amount of time in milliseconds to wait for a connection attempt to finish before trying the next address when using the `autoSelectFamily` option. */
|
|
81
|
+
autoSelectFamilyAttemptTimeout?: number;
|
|
82
|
+
/**
|
|
83
|
+
* @description Enables support for H2 if the server has assigned bigger priority to it through ALPN negotiation.
|
|
84
|
+
* @default true
|
|
85
|
+
*/
|
|
86
|
+
allowH2?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* @description Dictates the maximum number of concurrent streams for a single H2 session. It can be overridden by a SETTINGS remote frame.
|
|
89
|
+
* @default 100
|
|
90
|
+
*/
|
|
91
|
+
maxConcurrentStreams?: number;
|
|
92
|
+
/**
|
|
93
|
+
* @description Sets the HTTP/2 stream-level flow-control window size (SETTINGS_INITIAL_WINDOW_SIZE).
|
|
94
|
+
* @default 262144
|
|
95
|
+
*/
|
|
96
|
+
initialWindowSize?: number;
|
|
97
|
+
/**
|
|
98
|
+
* @description Sets the HTTP/2 connection-level flow-control window size (ClientHttp2Session.setLocalWindowSize).
|
|
99
|
+
* @default 524288
|
|
100
|
+
*/
|
|
101
|
+
connectionWindowSize?: number;
|
|
102
|
+
/**
|
|
103
|
+
* @description Time interval between PING frames dispatch
|
|
104
|
+
* @default 60000
|
|
105
|
+
*/
|
|
106
|
+
pingInterval?: number;
|
|
107
|
+
}
|
|
108
|
+
export interface SocketInfo {
|
|
109
|
+
localAddress?: string
|
|
110
|
+
localPort?: number
|
|
111
|
+
remoteAddress?: string
|
|
112
|
+
remotePort?: number
|
|
113
|
+
remoteFamily?: string
|
|
114
|
+
timeout?: number
|
|
115
|
+
bytesWritten?: number
|
|
116
|
+
bytesRead?: number
|
|
117
|
+
}
|
|
118
|
+
export interface WebSocketOptions {
|
|
119
|
+
/**
|
|
120
|
+
* Maximum number of fragments in a message. Set to 0 to disable the limit.
|
|
121
|
+
* @default 131072
|
|
122
|
+
*/
|
|
123
|
+
maxFragments?: number;
|
|
124
|
+
/**
|
|
125
|
+
* Maximum allowed payload size in bytes for WebSocket messages.
|
|
126
|
+
* Applied to uncompressed messages, compressed frame payloads, and decompressed (permessage-deflate) messages.
|
|
127
|
+
* Set to 0 to disable the limit.
|
|
128
|
+
* @default 134217728 (128 MB)
|
|
129
|
+
*/
|
|
130
|
+
maxPayloadSize?: number;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export default Client
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { TLSSocket, ConnectionOptions } from 'node:tls'
|
|
2
|
+
import { IpcNetConnectOpts, Socket, TcpNetConnectOpts } from 'node:net'
|
|
3
|
+
|
|
4
|
+
export default buildConnector
|
|
5
|
+
declare function buildConnector (options?: buildConnector.BuildOptions): buildConnector.connector
|
|
6
|
+
|
|
7
|
+
declare namespace buildConnector {
|
|
8
|
+
export type BuildOptions = (ConnectionOptions | TcpNetConnectOpts | IpcNetConnectOpts) & {
|
|
9
|
+
allowH2?: boolean;
|
|
10
|
+
preferH2?: boolean;
|
|
11
|
+
maxCachedSessions?: number | null;
|
|
12
|
+
socketPath?: string | null;
|
|
13
|
+
timeout?: number | null;
|
|
14
|
+
port?: number;
|
|
15
|
+
keepAlive?: boolean | null;
|
|
16
|
+
keepAliveInitialDelay?: number | null;
|
|
17
|
+
typeOfService?: number | null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface Options {
|
|
21
|
+
hostname: string
|
|
22
|
+
host?: string
|
|
23
|
+
protocol: string
|
|
24
|
+
port: string
|
|
25
|
+
servername?: string
|
|
26
|
+
localAddress?: string | null
|
|
27
|
+
socketPath?: string | null
|
|
28
|
+
httpSocket?: Socket
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type Callback = (...args: CallbackArgs) => void
|
|
32
|
+
type CallbackArgs = [null, Socket | TLSSocket] | [Error, null]
|
|
33
|
+
|
|
34
|
+
export interface connector {
|
|
35
|
+
(options: buildConnector.Options, callback: buildConnector.Callback): void
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
|
|
3
|
+
interface MIMEType {
|
|
4
|
+
type: string
|
|
5
|
+
subtype: string
|
|
6
|
+
parameters: Map<string, string>
|
|
7
|
+
essence: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Parse a string to a {@link MIMEType} object. Returns `failure` if the string
|
|
12
|
+
* couldn't be parsed.
|
|
13
|
+
* @see https://mimesniff.spec.whatwg.org/#parse-a-mime-type
|
|
14
|
+
*/
|
|
15
|
+
export function parseMIMEType (input: string): 'failure' | MIMEType
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Convert a MIMEType object to a string.
|
|
19
|
+
* @see https://mimesniff.spec.whatwg.org/#serialize-a-mime-type
|
|
20
|
+
*/
|
|
21
|
+
export function serializeAMimeType (mimeType: MIMEType): string
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
|
|
3
|
+
import type { Headers } from './fetch'
|
|
4
|
+
|
|
5
|
+
export interface Cookie {
|
|
6
|
+
name: string
|
|
7
|
+
value: string
|
|
8
|
+
expires?: Date | number
|
|
9
|
+
maxAge?: number
|
|
10
|
+
domain?: string
|
|
11
|
+
path?: string
|
|
12
|
+
secure?: boolean
|
|
13
|
+
httpOnly?: boolean
|
|
14
|
+
sameSite?: 'Strict' | 'Lax' | 'None'
|
|
15
|
+
unparsed?: string[]
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function deleteCookie (
|
|
19
|
+
headers: Headers,
|
|
20
|
+
name: string,
|
|
21
|
+
attributes?: { path?: string, domain?: string }
|
|
22
|
+
): void
|
|
23
|
+
|
|
24
|
+
export function getCookies (headers: Headers): Record<string, string>
|
|
25
|
+
|
|
26
|
+
export function getSetCookies (headers: Headers): Cookie[]
|
|
27
|
+
|
|
28
|
+
export function setCookie (headers: Headers, cookie: Cookie): void
|
|
29
|
+
|
|
30
|
+
export function parseCookie (cookie: string): Cookie | null
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Socket } from 'node:net'
|
|
2
|
+
import { URL } from 'node:url'
|
|
3
|
+
import buildConnector from './connector'
|
|
4
|
+
import Dispatcher from './dispatcher'
|
|
5
|
+
|
|
6
|
+
declare namespace DiagnosticsChannel {
|
|
7
|
+
interface Request {
|
|
8
|
+
origin?: string | URL;
|
|
9
|
+
completed: boolean;
|
|
10
|
+
method?: Dispatcher.HttpMethod;
|
|
11
|
+
path: string;
|
|
12
|
+
headers: any;
|
|
13
|
+
}
|
|
14
|
+
interface Response {
|
|
15
|
+
statusCode: number;
|
|
16
|
+
statusText: string;
|
|
17
|
+
headers: Array<Buffer>;
|
|
18
|
+
}
|
|
19
|
+
interface ConnectParams {
|
|
20
|
+
host: URL['host'];
|
|
21
|
+
hostname: URL['hostname'];
|
|
22
|
+
protocol: URL['protocol'];
|
|
23
|
+
port: URL['port'];
|
|
24
|
+
servername: string | null;
|
|
25
|
+
}
|
|
26
|
+
type Connector = buildConnector.connector
|
|
27
|
+
export interface RequestCreateMessage {
|
|
28
|
+
request: Request;
|
|
29
|
+
}
|
|
30
|
+
export interface RequestBodySentMessage {
|
|
31
|
+
request: Request;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface RequestBodyChunkSentMessage {
|
|
35
|
+
request: Request;
|
|
36
|
+
chunk: Uint8Array | string;
|
|
37
|
+
}
|
|
38
|
+
export interface RequestBodyChunkReceivedMessage {
|
|
39
|
+
request: Request;
|
|
40
|
+
chunk: Buffer;
|
|
41
|
+
}
|
|
42
|
+
export interface RequestHeadersMessage {
|
|
43
|
+
request: Request;
|
|
44
|
+
response: Response;
|
|
45
|
+
}
|
|
46
|
+
export interface RequestTrailersMessage {
|
|
47
|
+
request: Request;
|
|
48
|
+
trailers: Array<Buffer>;
|
|
49
|
+
}
|
|
50
|
+
export interface RequestErrorMessage {
|
|
51
|
+
request: Request;
|
|
52
|
+
error: Error;
|
|
53
|
+
}
|
|
54
|
+
export interface ClientSendHeadersMessage {
|
|
55
|
+
request: Request;
|
|
56
|
+
headers: string;
|
|
57
|
+
socket: Socket;
|
|
58
|
+
}
|
|
59
|
+
export interface ClientBeforeConnectMessage {
|
|
60
|
+
connectParams: ConnectParams;
|
|
61
|
+
connector: Connector;
|
|
62
|
+
}
|
|
63
|
+
export interface ClientConnectedMessage {
|
|
64
|
+
socket: Socket;
|
|
65
|
+
connectParams: ConnectParams;
|
|
66
|
+
connector: Connector;
|
|
67
|
+
}
|
|
68
|
+
export interface ClientConnectErrorMessage {
|
|
69
|
+
error: Error;
|
|
70
|
+
socket: Socket;
|
|
71
|
+
connectParams: ConnectParams;
|
|
72
|
+
connector: Connector;
|
|
73
|
+
}
|
|
74
|
+
}
|