monitor-transfer-dsh 0.0.0-stage → 0.1.2

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.
Files changed (367) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +51 -2
  3. package/cordis.patch.yml +4 -0
  4. package/lib/client.js +381 -0
  5. package/lib/index.js +267 -0
  6. package/package.json +67 -3
  7. package/skill/SKILL.md +48 -0
  8. package/skill/tools/node_modules/.package-lock.json +163 -0
  9. package/skill/tools/node_modules/pg/LICENSE +21 -0
  10. package/skill/tools/node_modules/pg/README.md +96 -0
  11. package/skill/tools/node_modules/pg/esm/index.mjs +20 -0
  12. package/skill/tools/node_modules/pg/lib/client.js +846 -0
  13. package/skill/tools/node_modules/pg/lib/connection-parameters.js +184 -0
  14. package/skill/tools/node_modules/pg/lib/connection.js +250 -0
  15. package/skill/tools/node_modules/pg/lib/crypto/cert-signatures.js +122 -0
  16. package/skill/tools/node_modules/pg/lib/crypto/sasl.js +262 -0
  17. package/skill/tools/node_modules/pg/lib/crypto/utils.js +89 -0
  18. package/skill/tools/node_modules/pg/lib/defaults.js +94 -0
  19. package/skill/tools/node_modules/pg/lib/index.js +73 -0
  20. package/skill/tools/node_modules/pg/lib/native/client.js +428 -0
  21. package/skill/tools/node_modules/pg/lib/native/index.js +2 -0
  22. package/skill/tools/node_modules/pg/lib/native/query.js +167 -0
  23. package/skill/tools/node_modules/pg/lib/query.js +263 -0
  24. package/skill/tools/node_modules/pg/lib/result.js +109 -0
  25. package/skill/tools/node_modules/pg/lib/stream.js +83 -0
  26. package/skill/tools/node_modules/pg/lib/type-overrides.js +35 -0
  27. package/skill/tools/node_modules/pg/lib/utils.js +225 -0
  28. package/skill/tools/node_modules/pg/package.json +76 -0
  29. package/skill/tools/node_modules/pg-cloudflare/LICENSE +21 -0
  30. package/skill/tools/node_modules/pg-cloudflare/README.md +112 -0
  31. package/skill/tools/node_modules/pg-cloudflare/dist/empty.d.ts +2 -0
  32. package/skill/tools/node_modules/pg-cloudflare/dist/empty.js +6 -0
  33. package/skill/tools/node_modules/pg-cloudflare/dist/empty.js.map +1 -0
  34. package/skill/tools/node_modules/pg-cloudflare/dist/index.d.ts +29 -0
  35. package/skill/tools/node_modules/pg-cloudflare/dist/index.js +171 -0
  36. package/skill/tools/node_modules/pg-cloudflare/dist/index.js.map +1 -0
  37. package/skill/tools/node_modules/pg-cloudflare/esm/index.mjs +3 -0
  38. package/skill/tools/node_modules/pg-cloudflare/package.json +39 -0
  39. package/skill/tools/node_modules/pg-cloudflare/src/empty.ts +3 -0
  40. package/skill/tools/node_modules/pg-cloudflare/src/index.ts +187 -0
  41. package/skill/tools/node_modules/pg-cloudflare/src/types.d.ts +25 -0
  42. package/skill/tools/node_modules/pg-connection-string/LICENSE +21 -0
  43. package/skill/tools/node_modules/pg-connection-string/README.md +105 -0
  44. package/skill/tools/node_modules/pg-connection-string/esm/index.mjs +8 -0
  45. package/skill/tools/node_modules/pg-connection-string/index.d.ts +37 -0
  46. package/skill/tools/node_modules/pg-connection-string/index.js +237 -0
  47. package/skill/tools/node_modules/pg-connection-string/package.json +51 -0
  48. package/skill/tools/node_modules/pg-int8/LICENSE +13 -0
  49. package/skill/tools/node_modules/pg-int8/README.md +16 -0
  50. package/skill/tools/node_modules/pg-int8/index.js +100 -0
  51. package/skill/tools/node_modules/pg-int8/package.json +24 -0
  52. package/skill/tools/node_modules/pg-pool/LICENSE +21 -0
  53. package/skill/tools/node_modules/pg-pool/README.md +357 -0
  54. package/skill/tools/node_modules/pg-pool/esm/index.mjs +5 -0
  55. package/skill/tools/node_modules/pg-pool/index.js +517 -0
  56. package/skill/tools/node_modules/pg-pool/package.json +51 -0
  57. package/skill/tools/node_modules/pg-protocol/LICENSE +21 -0
  58. package/skill/tools/node_modules/pg-protocol/README.md +3 -0
  59. package/skill/tools/node_modules/pg-protocol/dist/b.d.ts +1 -0
  60. package/skill/tools/node_modules/pg-protocol/dist/b.js +23 -0
  61. package/skill/tools/node_modules/pg-protocol/dist/b.js.map +1 -0
  62. package/skill/tools/node_modules/pg-protocol/dist/buffer-reader.d.ts +14 -0
  63. package/skill/tools/node_modules/pg-protocol/dist/buffer-reader.js +55 -0
  64. package/skill/tools/node_modules/pg-protocol/dist/buffer-reader.js.map +1 -0
  65. package/skill/tools/node_modules/pg-protocol/dist/buffer-writer.d.ts +21 -0
  66. package/skill/tools/node_modules/pg-protocol/dist/buffer-writer.js +113 -0
  67. package/skill/tools/node_modules/pg-protocol/dist/buffer-writer.js.map +1 -0
  68. package/skill/tools/node_modules/pg-protocol/dist/inbound-parser.test.d.ts +1 -0
  69. package/skill/tools/node_modules/pg-protocol/dist/inbound-parser.test.js +538 -0
  70. package/skill/tools/node_modules/pg-protocol/dist/inbound-parser.test.js.map +1 -0
  71. package/skill/tools/node_modules/pg-protocol/dist/index.d.ts +5 -0
  72. package/skill/tools/node_modules/pg-protocol/dist/index.js +15 -0
  73. package/skill/tools/node_modules/pg-protocol/dist/index.js.map +1 -0
  74. package/skill/tools/node_modules/pg-protocol/dist/messages.d.ts +161 -0
  75. package/skill/tools/node_modules/pg-protocol/dist/messages.js +160 -0
  76. package/skill/tools/node_modules/pg-protocol/dist/messages.js.map +1 -0
  77. package/skill/tools/node_modules/pg-protocol/dist/outbound-serializer.test.d.ts +1 -0
  78. package/skill/tools/node_modules/pg-protocol/dist/outbound-serializer.test.js +325 -0
  79. package/skill/tools/node_modules/pg-protocol/dist/outbound-serializer.test.js.map +1 -0
  80. package/skill/tools/node_modules/pg-protocol/dist/parser.d.ts +22 -0
  81. package/skill/tools/node_modules/pg-protocol/dist/parser.js +325 -0
  82. package/skill/tools/node_modules/pg-protocol/dist/parser.js.map +1 -0
  83. package/skill/tools/node_modules/pg-protocol/dist/serializer.d.ts +42 -0
  84. package/skill/tools/node_modules/pg-protocol/dist/serializer.js +198 -0
  85. package/skill/tools/node_modules/pg-protocol/dist/serializer.js.map +1 -0
  86. package/skill/tools/node_modules/pg-protocol/esm/index.js +11 -0
  87. package/skill/tools/node_modules/pg-protocol/package.json +44 -0
  88. package/skill/tools/node_modules/pg-protocol/src/b.ts +25 -0
  89. package/skill/tools/node_modules/pg-protocol/src/buffer-reader.ts +58 -0
  90. package/skill/tools/node_modules/pg-protocol/src/buffer-writer.ts +120 -0
  91. package/skill/tools/node_modules/pg-protocol/src/inbound-parser.test.ts +585 -0
  92. package/skill/tools/node_modules/pg-protocol/src/index.ts +11 -0
  93. package/skill/tools/node_modules/pg-protocol/src/messages.ts +262 -0
  94. package/skill/tools/node_modules/pg-protocol/src/outbound-serializer.test.ts +356 -0
  95. package/skill/tools/node_modules/pg-protocol/src/parser.ts +414 -0
  96. package/skill/tools/node_modules/pg-protocol/src/serializer.ts +286 -0
  97. package/skill/tools/node_modules/pg-protocol/src/testing/buffer-list.ts +67 -0
  98. package/skill/tools/node_modules/pg-protocol/src/testing/test-buffers.ts +166 -0
  99. package/skill/tools/node_modules/pg-types/.travis.yml +7 -0
  100. package/skill/tools/node_modules/pg-types/Makefile +14 -0
  101. package/skill/tools/node_modules/pg-types/README.md +75 -0
  102. package/skill/tools/node_modules/pg-types/index.d.ts +137 -0
  103. package/skill/tools/node_modules/pg-types/index.js +47 -0
  104. package/skill/tools/node_modules/pg-types/index.test-d.ts +21 -0
  105. package/skill/tools/node_modules/pg-types/lib/arrayParser.js +11 -0
  106. package/skill/tools/node_modules/pg-types/lib/binaryParsers.js +257 -0
  107. package/skill/tools/node_modules/pg-types/lib/builtins.js +73 -0
  108. package/skill/tools/node_modules/pg-types/lib/textParsers.js +215 -0
  109. package/skill/tools/node_modules/pg-types/package.json +42 -0
  110. package/skill/tools/node_modules/pg-types/test/index.js +24 -0
  111. package/skill/tools/node_modules/pg-types/test/types.js +597 -0
  112. package/skill/tools/node_modules/pgpass/README.md +74 -0
  113. package/skill/tools/node_modules/pgpass/lib/helper.js +233 -0
  114. package/skill/tools/node_modules/pgpass/lib/index.js +23 -0
  115. package/skill/tools/node_modules/pgpass/package.json +41 -0
  116. package/skill/tools/node_modules/postgres-array/index.d.ts +4 -0
  117. package/skill/tools/node_modules/postgres-array/index.js +97 -0
  118. package/skill/tools/node_modules/postgres-array/license +21 -0
  119. package/skill/tools/node_modules/postgres-array/package.json +35 -0
  120. package/skill/tools/node_modules/postgres-array/readme.md +43 -0
  121. package/skill/tools/node_modules/postgres-bytea/index.js +33 -0
  122. package/skill/tools/node_modules/postgres-bytea/license +21 -0
  123. package/skill/tools/node_modules/postgres-bytea/package.json +34 -0
  124. package/skill/tools/node_modules/postgres-bytea/readme.md +34 -0
  125. package/skill/tools/node_modules/postgres-date/index.js +116 -0
  126. package/skill/tools/node_modules/postgres-date/license +21 -0
  127. package/skill/tools/node_modules/postgres-date/package.json +33 -0
  128. package/skill/tools/node_modules/postgres-date/readme.md +49 -0
  129. package/skill/tools/node_modules/postgres-interval/index.d.ts +20 -0
  130. package/skill/tools/node_modules/postgres-interval/index.js +125 -0
  131. package/skill/tools/node_modules/postgres-interval/license +21 -0
  132. package/skill/tools/node_modules/postgres-interval/package.json +36 -0
  133. package/skill/tools/node_modules/postgres-interval/readme.md +48 -0
  134. package/skill/tools/node_modules/split2/LICENSE +13 -0
  135. package/skill/tools/node_modules/split2/README.md +85 -0
  136. package/skill/tools/node_modules/split2/bench.js +27 -0
  137. package/skill/tools/node_modules/split2/index.js +141 -0
  138. package/skill/tools/node_modules/split2/package.json +39 -0
  139. package/skill/tools/node_modules/split2/test.js +409 -0
  140. package/skill/tools/node_modules/undici/LICENSE +21 -0
  141. package/skill/tools/node_modules/undici/README.md +828 -0
  142. package/skill/tools/node_modules/undici/docs/docs/api/Agent.md +291 -0
  143. package/skill/tools/node_modules/undici/docs/docs/api/BalancedPool.md +297 -0
  144. package/skill/tools/node_modules/undici/docs/docs/api/CacheStorage.md +188 -0
  145. package/skill/tools/node_modules/undici/docs/docs/api/CacheStore.md +375 -0
  146. package/skill/tools/node_modules/undici/docs/docs/api/Client.md +538 -0
  147. package/skill/tools/node_modules/undici/docs/docs/api/ClientStats.md +93 -0
  148. package/skill/tools/node_modules/undici/docs/docs/api/Connector.md +198 -0
  149. package/skill/tools/node_modules/undici/docs/docs/api/ContentType.md +97 -0
  150. package/skill/tools/node_modules/undici/docs/docs/api/Cookies.md +179 -0
  151. package/skill/tools/node_modules/undici/docs/docs/api/Debug.md +78 -0
  152. package/skill/tools/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +518 -0
  153. package/skill/tools/node_modules/undici/docs/docs/api/Dispatcher.md +842 -0
  154. package/skill/tools/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +171 -0
  155. package/skill/tools/node_modules/undici/docs/docs/api/Errors.md +624 -0
  156. package/skill/tools/node_modules/undici/docs/docs/api/EventSource.md +358 -0
  157. package/skill/tools/node_modules/undici/docs/docs/api/Fetch.md +721 -0
  158. package/skill/tools/node_modules/undici/docs/docs/api/GlobalInstallation.md +121 -0
  159. package/skill/tools/node_modules/undici/docs/docs/api/H2CClient.md +386 -0
  160. package/skill/tools/node_modules/undici/docs/docs/api/Interceptors.md +439 -0
  161. package/skill/tools/node_modules/undici/docs/docs/api/MockAgent.md +622 -0
  162. package/skill/tools/node_modules/undici/docs/docs/api/MockCallHistory.md +371 -0
  163. package/skill/tools/node_modules/undici/docs/docs/api/MockCallHistoryLog.md +206 -0
  164. package/skill/tools/node_modules/undici/docs/docs/api/MockClient.md +199 -0
  165. package/skill/tools/node_modules/undici/docs/docs/api/MockErrors.md +63 -0
  166. package/skill/tools/node_modules/undici/docs/docs/api/MockPool.md +618 -0
  167. package/skill/tools/node_modules/undici/docs/docs/api/Pool.md +278 -0
  168. package/skill/tools/node_modules/undici/docs/docs/api/PoolStats.md +141 -0
  169. package/skill/tools/node_modules/undici/docs/docs/api/ProxyAgent.md +248 -0
  170. package/skill/tools/node_modules/undici/docs/docs/api/RedirectHandler.md +279 -0
  171. package/skill/tools/node_modules/undici/docs/docs/api/RetryAgent.md +136 -0
  172. package/skill/tools/node_modules/undici/docs/docs/api/RetryHandler.md +200 -0
  173. package/skill/tools/node_modules/undici/docs/docs/api/RoundRobinPool.md +239 -0
  174. package/skill/tools/node_modules/undici/docs/docs/api/SnapshotAgent.md +361 -0
  175. package/skill/tools/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +256 -0
  176. package/skill/tools/node_modules/undici/docs/docs/api/Util.md +82 -0
  177. package/skill/tools/node_modules/undici/docs/docs/api/WebSocket.md +536 -0
  178. package/skill/tools/node_modules/undici/docs/docs/api/api-lifecycle.md +159 -0
  179. package/skill/tools/node_modules/undici/docs/docs/best-practices/client-certificate.md +66 -0
  180. package/skill/tools/node_modules/undici/docs/docs/best-practices/crawling.md +60 -0
  181. package/skill/tools/node_modules/undici/docs/docs/best-practices/migrating-from-v7-to-v8.md +233 -0
  182. package/skill/tools/node_modules/undici/docs/docs/best-practices/mocking-request.md +192 -0
  183. package/skill/tools/node_modules/undici/docs/docs/best-practices/proxy.md +129 -0
  184. package/skill/tools/node_modules/undici/docs/docs/best-practices/undici-vs-builtin-fetch.md +226 -0
  185. package/skill/tools/node_modules/undici/docs/docs/best-practices/writing-tests.md +65 -0
  186. package/skill/tools/node_modules/undici/docs/docs/getting-started.md +281 -0
  187. package/skill/tools/node_modules/undici/docs/docs/index.md +793 -0
  188. package/skill/tools/node_modules/undici/docs/docs/site.json +125 -0
  189. package/skill/tools/node_modules/undici/docs/docs/type-map.json +79 -0
  190. package/skill/tools/node_modules/undici/index-fetch.js +65 -0
  191. package/skill/tools/node_modules/undici/index.d.ts +3 -0
  192. package/skill/tools/node_modules/undici/index.js +236 -0
  193. package/skill/tools/node_modules/undici/lib/api/abort-signal.js +59 -0
  194. package/skill/tools/node_modules/undici/lib/api/api-connect.js +112 -0
  195. package/skill/tools/node_modules/undici/lib/api/api-pipeline.js +265 -0
  196. package/skill/tools/node_modules/undici/lib/api/api-request.js +244 -0
  197. package/skill/tools/node_modules/undici/lib/api/api-stream.js +270 -0
  198. package/skill/tools/node_modules/undici/lib/api/api-upgrade.js +121 -0
  199. package/skill/tools/node_modules/undici/lib/api/index.js +7 -0
  200. package/skill/tools/node_modules/undici/lib/api/readable.js +615 -0
  201. package/skill/tools/node_modules/undici/lib/cache/memory-cache-store.js +314 -0
  202. package/skill/tools/node_modules/undici/lib/cache/sqlite-cache-store.js +593 -0
  203. package/skill/tools/node_modules/undici/lib/core/connect.js +198 -0
  204. package/skill/tools/node_modules/undici/lib/core/constants.js +131 -0
  205. package/skill/tools/node_modules/undici/lib/core/diagnostics.js +227 -0
  206. package/skill/tools/node_modules/undici/lib/core/errors.js +534 -0
  207. package/skill/tools/node_modules/undici/lib/core/request.js +582 -0
  208. package/skill/tools/node_modules/undici/lib/core/socks5-client.js +422 -0
  209. package/skill/tools/node_modules/undici/lib/core/socks5-utils.js +212 -0
  210. package/skill/tools/node_modules/undici/lib/core/symbols.js +81 -0
  211. package/skill/tools/node_modules/undici/lib/core/tree.js +160 -0
  212. package/skill/tools/node_modules/undici/lib/core/util.js +1035 -0
  213. package/skill/tools/node_modules/undici/lib/dispatcher/agent.js +181 -0
  214. package/skill/tools/node_modules/undici/lib/dispatcher/balanced-pool.js +217 -0
  215. package/skill/tools/node_modules/undici/lib/dispatcher/client-h1.js +1846 -0
  216. package/skill/tools/node_modules/undici/lib/dispatcher/client-h2.js +1989 -0
  217. package/skill/tools/node_modules/undici/lib/dispatcher/client.js +749 -0
  218. package/skill/tools/node_modules/undici/lib/dispatcher/dispatcher-base.js +198 -0
  219. package/skill/tools/node_modules/undici/lib/dispatcher/dispatcher.js +58 -0
  220. package/skill/tools/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +127 -0
  221. package/skill/tools/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +190 -0
  222. package/skill/tools/node_modules/undici/lib/dispatcher/fixed-queue.js +135 -0
  223. package/skill/tools/node_modules/undici/lib/dispatcher/h2c-client.js +51 -0
  224. package/skill/tools/node_modules/undici/lib/dispatcher/parser-h1.js +1065 -0
  225. package/skill/tools/node_modules/undici/lib/dispatcher/pool-base.js +347 -0
  226. package/skill/tools/node_modules/undici/lib/dispatcher/pool.js +229 -0
  227. package/skill/tools/node_modules/undici/lib/dispatcher/proxy-agent.js +418 -0
  228. package/skill/tools/node_modules/undici/lib/dispatcher/retry-agent.js +48 -0
  229. package/skill/tools/node_modules/undici/lib/dispatcher/round-robin-pool.js +169 -0
  230. package/skill/tools/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +350 -0
  231. package/skill/tools/node_modules/undici/lib/encoding/index.js +33 -0
  232. package/skill/tools/node_modules/undici/lib/global.js +82 -0
  233. package/skill/tools/node_modules/undici/lib/handler/cache-handler.js +1222 -0
  234. package/skill/tools/node_modules/undici/lib/handler/cache-revalidation-handler.js +134 -0
  235. package/skill/tools/node_modules/undici/lib/handler/decorator-handler.js +76 -0
  236. package/skill/tools/node_modules/undici/lib/handler/deduplication-handler.js +540 -0
  237. package/skill/tools/node_modules/undici/lib/handler/redirect-handler.js +284 -0
  238. package/skill/tools/node_modules/undici/lib/handler/retry-handler.js +686 -0
  239. package/skill/tools/node_modules/undici/lib/interceptor/cache.js +771 -0
  240. package/skill/tools/node_modules/undici/lib/interceptor/decompress.js +574 -0
  241. package/skill/tools/node_modules/undici/lib/interceptor/deduplicate.js +118 -0
  242. package/skill/tools/node_modules/undici/lib/interceptor/dns.js +593 -0
  243. package/skill/tools/node_modules/undici/lib/interceptor/dump.js +99 -0
  244. package/skill/tools/node_modules/undici/lib/interceptor/redirect.js +21 -0
  245. package/skill/tools/node_modules/undici/lib/interceptor/response-error.js +139 -0
  246. package/skill/tools/node_modules/undici/lib/interceptor/retry.js +19 -0
  247. package/skill/tools/node_modules/undici/lib/llhttp/constants.d.ts +195 -0
  248. package/skill/tools/node_modules/undici/lib/llhttp/constants.js +531 -0
  249. package/skill/tools/node_modules/undici/lib/llhttp/llhttp-wasm.js +15 -0
  250. package/skill/tools/node_modules/undici/lib/llhttp/llhttp_simd-wasm.js +15 -0
  251. package/skill/tools/node_modules/undici/lib/llhttp/utils.d.ts +2 -0
  252. package/skill/tools/node_modules/undici/lib/llhttp/utils.js +12 -0
  253. package/skill/tools/node_modules/undici/lib/milo/LICENSE.md +7 -0
  254. package/skill/tools/node_modules/undici/lib/milo/no-simd.js +1002 -0
  255. package/skill/tools/node_modules/undici/lib/milo/simd.js +1002 -0
  256. package/skill/tools/node_modules/undici/lib/mock/mock-agent.js +255 -0
  257. package/skill/tools/node_modules/undici/lib/mock/mock-call-history.js +248 -0
  258. package/skill/tools/node_modules/undici/lib/mock/mock-client.js +68 -0
  259. package/skill/tools/node_modules/undici/lib/mock/mock-errors.js +29 -0
  260. package/skill/tools/node_modules/undici/lib/mock/mock-interceptor.js +227 -0
  261. package/skill/tools/node_modules/undici/lib/mock/mock-pool.js +68 -0
  262. package/skill/tools/node_modules/undici/lib/mock/mock-symbols.js +32 -0
  263. package/skill/tools/node_modules/undici/lib/mock/mock-utils.js +730 -0
  264. package/skill/tools/node_modules/undici/lib/mock/pending-interceptors-formatter.js +43 -0
  265. package/skill/tools/node_modules/undici/lib/mock/snapshot-agent.js +371 -0
  266. package/skill/tools/node_modules/undici/lib/mock/snapshot-recorder.js +624 -0
  267. package/skill/tools/node_modules/undici/lib/mock/snapshot-utils.js +159 -0
  268. package/skill/tools/node_modules/undici/lib/util/cache.js +764 -0
  269. package/skill/tools/node_modules/undici/lib/util/date.js +670 -0
  270. package/skill/tools/node_modules/undici/lib/util/runtime-features.js +93 -0
  271. package/skill/tools/node_modules/undici/lib/util/stats.js +32 -0
  272. package/skill/tools/node_modules/undici/lib/util/timers.js +425 -0
  273. package/skill/tools/node_modules/undici/lib/web/cache/cache.js +871 -0
  274. package/skill/tools/node_modules/undici/lib/web/cache/cachestorage.js +158 -0
  275. package/skill/tools/node_modules/undici/lib/web/cache/util.js +45 -0
  276. package/skill/tools/node_modules/undici/lib/web/cookies/constants.js +12 -0
  277. package/skill/tools/node_modules/undici/lib/web/cookies/index.js +211 -0
  278. package/skill/tools/node_modules/undici/lib/web/cookies/parse.js +318 -0
  279. package/skill/tools/node_modules/undici/lib/web/cookies/util.js +371 -0
  280. package/skill/tools/node_modules/undici/lib/web/eventsource/eventsource-stream.js +575 -0
  281. package/skill/tools/node_modules/undici/lib/web/eventsource/eventsource.js +547 -0
  282. package/skill/tools/node_modules/undici/lib/web/eventsource/util.js +60 -0
  283. package/skill/tools/node_modules/undici/lib/web/fetch/LICENSE +21 -0
  284. package/skill/tools/node_modules/undici/lib/web/fetch/body.js +583 -0
  285. package/skill/tools/node_modules/undici/lib/web/fetch/constants.js +131 -0
  286. package/skill/tools/node_modules/undici/lib/web/fetch/data-url.js +596 -0
  287. package/skill/tools/node_modules/undici/lib/web/fetch/formdata-parser.js +594 -0
  288. package/skill/tools/node_modules/undici/lib/web/fetch/formdata.js +272 -0
  289. package/skill/tools/node_modules/undici/lib/web/fetch/global.js +40 -0
  290. package/skill/tools/node_modules/undici/lib/web/fetch/headers.js +722 -0
  291. package/skill/tools/node_modules/undici/lib/web/fetch/index.js +2451 -0
  292. package/skill/tools/node_modules/undici/lib/web/fetch/request.js +1117 -0
  293. package/skill/tools/node_modules/undici/lib/web/fetch/response.js +638 -0
  294. package/skill/tools/node_modules/undici/lib/web/fetch/util.js +1530 -0
  295. package/skill/tools/node_modules/undici/lib/web/infra/index.js +244 -0
  296. package/skill/tools/node_modules/undici/lib/web/subresource-integrity/Readme.md +9 -0
  297. package/skill/tools/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +307 -0
  298. package/skill/tools/node_modules/undici/lib/web/webidl/index.js +992 -0
  299. package/skill/tools/node_modules/undici/lib/web/websocket/connection.js +350 -0
  300. package/skill/tools/node_modules/undici/lib/web/websocket/constants.js +126 -0
  301. package/skill/tools/node_modules/undici/lib/web/websocket/events.js +348 -0
  302. package/skill/tools/node_modules/undici/lib/web/websocket/frame.js +127 -0
  303. package/skill/tools/node_modules/undici/lib/web/websocket/permessage-deflate.js +105 -0
  304. package/skill/tools/node_modules/undici/lib/web/websocket/receiver.js +530 -0
  305. package/skill/tools/node_modules/undici/lib/web/websocket/sender.js +109 -0
  306. package/skill/tools/node_modules/undici/lib/web/websocket/stream/websocketerror.js +107 -0
  307. package/skill/tools/node_modules/undici/lib/web/websocket/stream/websocketstream.js +511 -0
  308. package/skill/tools/node_modules/undici/lib/web/websocket/util.js +347 -0
  309. package/skill/tools/node_modules/undici/lib/web/websocket/websocket.js +783 -0
  310. package/skill/tools/node_modules/undici/package.json +154 -0
  311. package/skill/tools/node_modules/undici/scripts/strip-comments.js +10 -0
  312. package/skill/tools/node_modules/undici/types/README.md +6 -0
  313. package/skill/tools/node_modules/undici/types/agent.d.ts +30 -0
  314. package/skill/tools/node_modules/undici/types/api.d.ts +43 -0
  315. package/skill/tools/node_modules/undici/types/balanced-pool.d.ts +30 -0
  316. package/skill/tools/node_modules/undici/types/cache-interceptor.d.ts +189 -0
  317. package/skill/tools/node_modules/undici/types/cache.d.ts +36 -0
  318. package/skill/tools/node_modules/undici/types/client-stats.d.ts +15 -0
  319. package/skill/tools/node_modules/undici/types/client.d.ts +190 -0
  320. package/skill/tools/node_modules/undici/types/connector.d.ts +37 -0
  321. package/skill/tools/node_modules/undici/types/content-type.d.ts +21 -0
  322. package/skill/tools/node_modules/undici/types/cookies.d.ts +30 -0
  323. package/skill/tools/node_modules/undici/types/diagnostics-channel.d.ts +75 -0
  324. package/skill/tools/node_modules/undici/types/dispatcher.d.ts +253 -0
  325. package/skill/tools/node_modules/undici/types/dispatcher1-wrapper.d.ts +7 -0
  326. package/skill/tools/node_modules/undici/types/env-http-proxy-agent.d.ts +22 -0
  327. package/skill/tools/node_modules/undici/types/errors.d.ts +202 -0
  328. package/skill/tools/node_modules/undici/types/eventsource.d.ts +66 -0
  329. package/skill/tools/node_modules/undici/types/fetch.d.ts +235 -0
  330. package/skill/tools/node_modules/undici/types/formdata.d.ts +108 -0
  331. package/skill/tools/node_modules/undici/types/global-dispatcher.d.ts +9 -0
  332. package/skill/tools/node_modules/undici/types/global-origin.d.ts +7 -0
  333. package/skill/tools/node_modules/undici/types/h2c-client.d.ts +73 -0
  334. package/skill/tools/node_modules/undici/types/handlers.d.ts +16 -0
  335. package/skill/tools/node_modules/undici/types/header.d.ts +165 -0
  336. package/skill/tools/node_modules/undici/types/index.d.ts +93 -0
  337. package/skill/tools/node_modules/undici/types/interceptors.d.ts +87 -0
  338. package/skill/tools/node_modules/undici/types/mock-agent.d.ts +69 -0
  339. package/skill/tools/node_modules/undici/types/mock-call-history.d.ts +111 -0
  340. package/skill/tools/node_modules/undici/types/mock-client.d.ts +27 -0
  341. package/skill/tools/node_modules/undici/types/mock-errors.d.ts +12 -0
  342. package/skill/tools/node_modules/undici/types/mock-interceptor.d.ts +98 -0
  343. package/skill/tools/node_modules/undici/types/mock-pool.d.ts +27 -0
  344. package/skill/tools/node_modules/undici/types/patch.d.ts +29 -0
  345. package/skill/tools/node_modules/undici/types/pool-stats.d.ts +19 -0
  346. package/skill/tools/node_modules/undici/types/pool.d.ts +39 -0
  347. package/skill/tools/node_modules/undici/types/proxy-agent.d.ts +36 -0
  348. package/skill/tools/node_modules/undici/types/readable.d.ts +68 -0
  349. package/skill/tools/node_modules/undici/types/retry-agent.d.ts +8 -0
  350. package/skill/tools/node_modules/undici/types/retry-handler.d.ts +125 -0
  351. package/skill/tools/node_modules/undici/types/round-robin-pool.d.ts +39 -0
  352. package/skill/tools/node_modules/undici/types/snapshot-agent.d.ts +113 -0
  353. package/skill/tools/node_modules/undici/types/socks5-proxy-agent.d.ts +27 -0
  354. package/skill/tools/node_modules/undici/types/util.d.ts +18 -0
  355. package/skill/tools/node_modules/undici/types/utility.d.ts +7 -0
  356. package/skill/tools/node_modules/undici/types/webidl.d.ts +352 -0
  357. package/skill/tools/node_modules/undici/types/websocket.d.ts +188 -0
  358. package/skill/tools/node_modules/xtend/.jshintrc +30 -0
  359. package/skill/tools/node_modules/xtend/LICENSE +20 -0
  360. package/skill/tools/node_modules/xtend/README.md +32 -0
  361. package/skill/tools/node_modules/xtend/immutable.js +19 -0
  362. package/skill/tools/node_modules/xtend/mutable.js +17 -0
  363. package/skill/tools/node_modules/xtend/package.json +55 -0
  364. package/skill/tools/node_modules/xtend/test.js +103 -0
  365. package/skill/tools/package-lock.json +172 -0
  366. package/skill/tools/package.json +9 -0
  367. package/skill/tools/transfer_core.js +414 -0
@@ -0,0 +1,842 @@
1
+ # Dispatcher
2
+
3
+ <!--introduced_in=v4.0.0-->
4
+
5
+ <!--type=module-->
6
+
7
+ <!-- source_link=lib/dispatcher/dispatcher.js -->
8
+
9
+ > Stability: 2 - Stable
10
+
11
+ `Dispatcher` is the core abstraction used to dispatch HTTP requests in undici.
12
+ It extends [`EventEmitter`][] and defines the low-level [`dispatch()`][] contract
13
+ along with the higher-level [`request()`][], [`stream()`][], [`pipeline()`][],
14
+ [`connect()`][], and [`upgrade()`][] methods that every concrete dispatcher
15
+ provides.
16
+
17
+ `Dispatcher` itself is abstract: its [`dispatch()`][], [`close()`][], and
18
+ [`destroy()`][] methods throw `Error: not implemented`. Concrete dispatchers such
19
+ as [`Client`][], [`Pool`][], [`BalancedPool`][], and [`Agent`][] implement the
20
+ contract and are what application code instantiates. Requests are not guaranteed
21
+ to be dispatched in the order in which they are invoked.
22
+
23
+ ```mjs
24
+ import { Dispatcher, Agent } from 'undici'
25
+
26
+ const dispatcher = new Agent()
27
+ console.log(dispatcher instanceof Dispatcher) // true
28
+ ```
29
+
30
+ ## Class: `Dispatcher`
31
+
32
+ <!-- YAML
33
+ added: v4.0.0
34
+ -->
35
+
36
+ * Extends: {EventEmitter}
37
+
38
+ Base dispatcher class. Concrete dispatchers extend it and implement the
39
+ [`dispatch()`][] method on which the other request helpers are built.
40
+
41
+ ### `dispatcher.close([callback])`
42
+
43
+ <!-- YAML
44
+ added: v4.0.0
45
+ -->
46
+
47
+ * `callback` {Function} (optional) Invoked once the dispatcher is closed.
48
+ * `error` {Error|null}
49
+ * Returns: {Promise} A `Promise` is returned only when `callback` is omitted. It
50
+ resolves with `void` once the dispatcher is closed.
51
+
52
+ Closes the dispatcher and gracefully waits for enqueued requests to complete
53
+ before resolving or invoking `callback`.
54
+
55
+ ```mjs
56
+ import { createServer } from 'node:http'
57
+ import { Client } from 'undici'
58
+ import { once } from 'node:events'
59
+
60
+ const server = createServer((request, response) => {
61
+ response.end('undici')
62
+ }).listen()
63
+
64
+ await once(server, 'listening')
65
+
66
+ const client = new Client(`http://localhost:${server.address().port}`)
67
+
68
+ try {
69
+ const { body } = await client.request({ path: '/', method: 'GET' })
70
+ body.setEncoding('utf8')
71
+ body.on('data', console.log)
72
+ } catch (error) {}
73
+
74
+ await client.close()
75
+
76
+ console.log('Client closed')
77
+ server.close()
78
+ ```
79
+
80
+ ### `dispatcher.connect(options[, callback])`
81
+
82
+ <!-- YAML
83
+ added: v4.0.0
84
+ -->
85
+
86
+ * `options` {Object}
87
+ * `origin` {string|URL} The origin to connect to.
88
+ * `path` {string} The request path.
89
+ * `headers` {UndiciHeaders} Request headers. **Default:** `null`.
90
+ * `signal` {AbortSignal|EventEmitter|null} A signal used to abort the request.
91
+ **Default:** `null`.
92
+ * `opaque` {any} An opaque value passed through to the returned `ConnectData`.
93
+ * `responseHeaders` {string|null} Set to `'raw'` to return the response headers
94
+ as a raw array instead of an object. **Default:** `null`.
95
+ * `callback` {Function} (optional) Invoked when the connection is established.
96
+ * `error` {Error|null}
97
+ * `data` {Object}
98
+ * `statusCode` {number}
99
+ * `headers` {Object} The response headers.
100
+ * `socket` {Duplex} The established socket.
101
+ * `opaque` {any} The `opaque` value passed in `options`.
102
+ * Returns: {Promise} A `Promise` is returned only when `callback` is omitted. It
103
+ resolves with the `data` object described above.
104
+
105
+ Starts two-way communications with the requested resource using the
106
+ [HTTP `CONNECT`][] method.
107
+
108
+ ```mjs
109
+ import { createServer } from 'node:http'
110
+ import { Client } from 'undici'
111
+ import { once } from 'node:events'
112
+
113
+ const server = createServer((request, response) => {
114
+ throw new Error('should never get here')
115
+ }).listen()
116
+
117
+ server.on('connect', (req, socket, head) => {
118
+ socket.write('HTTP/1.1 200 Connection established\r\n\r\n')
119
+
120
+ let data = head.toString()
121
+ socket.on('data', (buf) => {
122
+ data += buf.toString()
123
+ })
124
+
125
+ socket.on('end', () => {
126
+ socket.end(data)
127
+ })
128
+ })
129
+
130
+ await once(server, 'listening')
131
+
132
+ const client = new Client(`http://localhost:${server.address().port}`)
133
+
134
+ try {
135
+ const { socket } = await client.connect({ path: '/' })
136
+ const wanted = 'Body'
137
+ let data = ''
138
+ socket.on('data', d => { data += d })
139
+ socket.on('end', () => {
140
+ console.log(`Data received: ${data.toString()} | Data wanted: ${wanted}`)
141
+ client.close()
142
+ server.close()
143
+ })
144
+ socket.write(wanted)
145
+ socket.end()
146
+ } catch (error) {}
147
+ ```
148
+
149
+ ### `dispatcher.destroy([error[, callback]])`
150
+
151
+ <!-- YAML
152
+ added: v4.0.0
153
+ -->
154
+
155
+ * `error` {Error|null} (optional) The error with which pending requests are
156
+ rejected. **Default:** `null`.
157
+ * `callback` {Function} (optional) Invoked once the socket is closed.
158
+ * Returns: {Promise} A `Promise` is returned only when `callback` is omitted. It
159
+ resolves with `void` once the dispatcher is destroyed.
160
+
161
+ Destroys the dispatcher abruptly with the given `error`. All pending and running
162
+ requests are asynchronously aborted and rejected. Because the operation is
163
+ dispatched asynchronously, dispatched requests may still make some progress
164
+ before being aborted.
165
+
166
+ Both arguments are optional, so the method can be called in four ways:
167
+
168
+ ```mjs
169
+ dispatcher.destroy() // -> Promise
170
+ dispatcher.destroy(new Error()) // -> Promise
171
+ dispatcher.destroy(() => {}) // -> void
172
+ dispatcher.destroy(new Error(), () => {}) // -> void
173
+ ```
174
+
175
+ ```mjs
176
+ import { createServer } from 'node:http'
177
+ import { Client } from 'undici'
178
+ import { once } from 'node:events'
179
+
180
+ const server = createServer((request, response) => {
181
+ response.end()
182
+ }).listen()
183
+
184
+ await once(server, 'listening')
185
+
186
+ const client = new Client(`http://localhost:${server.address().port}`)
187
+
188
+ try {
189
+ const request = client.request({ path: '/', method: 'GET' })
190
+ client.destroy()
191
+ .then(() => {
192
+ console.log('Client destroyed')
193
+ server.close()
194
+ })
195
+ await request
196
+ } catch (error) {
197
+ console.error(error)
198
+ }
199
+ ```
200
+
201
+ ### `dispatcher.dispatch(options, handler)`
202
+
203
+ <!-- YAML
204
+ added: v4.0.0
205
+ -->
206
+
207
+ * `options` {Object}
208
+ * `origin` {string|URL} The origin to dispatch the request to. Optional for a
209
+ dispatcher that is already bound to a single origin, such as `Client` or
210
+ `Pool`, which then use their own origin. Required on `Agent`, which is not
211
+ bound to one origin and throws an `InvalidArgumentError` when it is missing.
212
+ * `path` {string} The request path.
213
+ * `method` {string} The HTTP method, e.g. `'GET'` or `'POST'`.
214
+ * `body` {string|Buffer|Uint8Array|Readable|FormData|null} The request body.
215
+ Undici's network clients require a `FormData` body created by the same
216
+ undici package instance. A body from another source, including Node.js's
217
+ built-in `FormData`, is rejected with an `InvalidArgumentError`.
218
+ **Default:** `null`.
219
+ * `headers` {UndiciHeaders} Request headers. **Default:** `null`.
220
+ * `query` {Object} Query string parameters embedded into the request URL. Both
221
+ keys and values are encoded with `encodeURIComponent`. **Default:** `null`.
222
+ * `idempotent` {boolean} Whether the request can be safely retried. If `false`,
223
+ the request is not sent until all preceding requests in the pipeline have
224
+ completed. **Default:** `true` when `method` is `'HEAD'` or `'GET'`.
225
+ * `blocking` {boolean} Whether the response is expected to block the pipeline.
226
+ When `true`, further pipelining on the same connection is avoided until
227
+ headers have been received. **Default:** `method !== 'HEAD'`.
228
+ * `typeOfService` {number|null} The IP Type of Service (ToS) value for the
229
+ request socket. Must be an integer between `0` and `255`. **Default:** `0`.
230
+ * `upgrade` {boolean|string|null} Upgrades the request, e.g. to `'Websocket'`.
231
+ **Default:** `null`, or the request method when it is `'CONNECT'`.
232
+ * `headersTimeout` {number|null} The time, in milliseconds, the parser waits to
233
+ receive the complete HTTP headers. Defaults to 300 seconds.
234
+ * `bodyTimeout` {number|null} The time, in milliseconds, after which the request
235
+ times out while receiving body data. Monitors the time between body chunks.
236
+ Use `0` to disable it entirely. Defaults to 300 seconds.
237
+ HTTP/1.1 headers/body parser timeouts are not guaranteed to fire with exact
238
+ millisecond precision: delays up to 1000ms use native timers, while larger
239
+ delays use undici's lower-overhead fast timers with a target resolution
240
+ around 500ms.
241
+ * `reset` {boolean} Whether the request should establish a keep-alive
242
+ connection. **Default:** `false`.
243
+ * `expectContinue` {boolean} For HTTP/2, appends the `expect: 100-continue`
244
+ header and halts the request body until a `100 Continue` is received from the
245
+ remote server. **Default:** `false`.
246
+ * `handler` {Object} A set of callbacks invoked over the request lifecycle.
247
+ * `onRequestStart` {Function} Invoked before the request is dispatched on the
248
+ socket. May be invoked multiple times when the request is retried.
249
+ * `controller` {DispatchController}
250
+ * `context` {any}
251
+ * `onRequestUpgrade` {Function} (optional) Invoked when the request is upgraded.
252
+ Required when `options.upgrade` is set or `options.method` is `'CONNECT'`.
253
+ * `controller` {DispatchController}
254
+ * `statusCode` {number}
255
+ * `headers` {Object}
256
+ * `socket` {Duplex}
257
+ * `onResponseStart` {Function} (optional) Invoked when the status code and
258
+ headers have been received. May be invoked multiple times for 1xx
259
+ informational responses. Not used for `upgrade` requests.
260
+ * `controller` {DispatchController}
261
+ * `statusCode` {number}
262
+ * `headers` {Object}
263
+ * `statusMessage` {string} (optional)
264
+ * `onResponseData` {Function} (optional) Invoked when response payload data is
265
+ received. Not used for `upgrade` requests.
266
+ * `controller` {DispatchController}
267
+ * `chunk` {Buffer}
268
+ * `onResponseEnd` {Function} (optional) Invoked when the response payload and
269
+ trailers have been received and the request has completed. Not used for
270
+ `upgrade` requests.
271
+ * `controller` {DispatchController}
272
+ * `trailers` {Object}
273
+ * `onResponseError` {Function} (optional) Invoked when an error occurs. Must not
274
+ throw.
275
+ * `controller` {DispatchController}
276
+ * `error` {Error}
277
+ * `onResponseStarted` {Function} (optional) Invoked when the response is
278
+ received, before headers have been read.
279
+ * `onBodySent` {Function} (optional) Invoked when a chunk of the request body is
280
+ sent. May be invoked multiple times for chunked requests.
281
+ * `chunk` {Buffer}
282
+ * `onRequestSent` {Function} (optional) Invoked after the request body is fully
283
+ sent.
284
+ * Returns: {boolean} `false` when the dispatcher is busy and further `dispatch()`
285
+ calls will make no progress until the [`'drain'`][] event is emitted.
286
+
287
+ This is the low-level API on which all the higher-level methods are built. This
288
+ API is expected to evolve through semver-major versions and is less stable than
289
+ the higher-level methods. It is primarily intended for library developers who
290
+ implement higher-level APIs on top of it.
291
+
292
+ The `controller` passed to each handler is a `DispatchController` with the
293
+ following shape:
294
+
295
+ * `aborted` {boolean} Whether the request has been aborted.
296
+ * `paused` {boolean} Whether the request is paused.
297
+ * `reason` {Error|null} The reason the request was aborted, if any.
298
+ * `rawHeaders` {Buffer[]|string[]|Object|null} The raw response headers,
299
+ preserving duplicates and casing.
300
+ * `rawTrailers` {Buffer[]|string[]|Object|null} The raw response trailers.
301
+ * `abort(reason)` Aborts the request with the given `reason`.
302
+ * `pause()` Pauses the response stream.
303
+ * `resume()` Resumes the response stream.
304
+
305
+ Call `controller.pause()` and `controller.resume()` to apply backpressure rather
306
+ than returning `false` from a handler.
307
+
308
+ ```mjs
309
+ import { createServer } from 'node:http'
310
+ import { Client } from 'undici'
311
+ import { once } from 'node:events'
312
+
313
+ const server = createServer((request, response) => {
314
+ response.end('Hello, World!')
315
+ }).listen()
316
+
317
+ await once(server, 'listening')
318
+
319
+ const client = new Client(`http://localhost:${server.address().port}`)
320
+
321
+ const data = []
322
+
323
+ client.dispatch({
324
+ path: '/',
325
+ method: 'GET',
326
+ headers: { 'x-foo': 'bar' }
327
+ }, {
328
+ onRequestStart: () => {
329
+ console.log('Connected!')
330
+ },
331
+ onResponseError: (_controller, error) => {
332
+ console.error(error)
333
+ },
334
+ onResponseStart: (_controller, statusCode, headers) => {
335
+ console.log(`statusCode: ${statusCode} | headers: ${JSON.stringify(headers)}`)
336
+ },
337
+ onResponseData: (_controller, chunk) => {
338
+ data.push(chunk)
339
+ },
340
+ onResponseEnd: (_controller, trailers) => {
341
+ console.log(`trailers: ${JSON.stringify(trailers)}`)
342
+ console.log(`Data: ${Buffer.concat(data).toString('utf8')}`)
343
+ client.close()
344
+ server.close()
345
+ }
346
+ })
347
+ ```
348
+
349
+ ### `dispatcher.pipeline(options, handler)`
350
+
351
+ <!-- YAML
352
+ added: v4.0.0
353
+ -->
354
+
355
+ * `options` {Object} Accepts every field of [`dispatcher.request()`][]'s
356
+ `options`, plus:
357
+ * `objectMode` {boolean} Set to `true` when `handler` returns an object stream.
358
+ **Default:** `false`.
359
+ * `handler` {Function} Returns a `Readable` from which the result is read.
360
+ * `data` {Object}
361
+ * `statusCode` {number}
362
+ * `headers` {Object} The response headers.
363
+ * `opaque` {any} The `opaque` value passed in `options`.
364
+ * `body` {Readable} The response body.
365
+ * `context` {Object}
366
+ * Returns: {Readable}
367
+ * Returns: {Duplex} A duplex stream that writes to the request and reads from the
368
+ response.
369
+
370
+ For easy use with [`stream.pipeline()`][]. The `handler` should return a
371
+ `Readable` from which the result is read. Usually it returns the `body` directly,
372
+ unless a transformation is needed based on, for example, `headers` or
373
+ `statusCode`. The `handler` should validate the response and save any required
374
+ state; if there is an error, it should be thrown.
375
+
376
+ ```mjs
377
+ import { Readable, Writable, PassThrough, pipeline } from 'node:stream'
378
+ import { createServer } from 'node:http'
379
+ import { Client } from 'undici'
380
+ import { once } from 'node:events'
381
+
382
+ const server = createServer((request, response) => {
383
+ request.pipe(response)
384
+ }).listen()
385
+
386
+ await once(server, 'listening')
387
+
388
+ const client = new Client(`http://localhost:${server.address().port}`)
389
+
390
+ let res = ''
391
+
392
+ pipeline(
393
+ new Readable({
394
+ read () {
395
+ this.push(Buffer.from('undici'))
396
+ this.push(null)
397
+ }
398
+ }),
399
+ client.pipeline({ path: '/', method: 'GET' }, ({ statusCode, headers, body }) => {
400
+ console.log(`response received ${statusCode}`)
401
+ console.log('headers', headers)
402
+ return pipeline(body, new PassThrough(), () => {})
403
+ }),
404
+ new Writable({
405
+ write (chunk, _, callback) {
406
+ res += chunk.toString()
407
+ callback()
408
+ },
409
+ final (callback) {
410
+ console.log(`Response pipelined to writable: ${res}`)
411
+ callback()
412
+ }
413
+ }),
414
+ error => {
415
+ if (error) {
416
+ console.error(error)
417
+ }
418
+ client.close()
419
+ server.close()
420
+ }
421
+ )
422
+ ```
423
+
424
+ ### `dispatcher.request(options[, callback])`
425
+
426
+ <!-- YAML
427
+ added: v4.0.0
428
+ -->
429
+
430
+ * `options` {Object} Accepts every field of [`dispatcher.dispatch()`][]'s
431
+ `options`, plus:
432
+ * `opaque` {any} A value passed through to the returned response data.
433
+ **Default:** `null`.
434
+ * `signal` {AbortSignal|EventEmitter|null} A signal used to abort the request.
435
+ **Default:** `null`.
436
+ * `onInfo` {Function|null} Invoked for each informational (1xx) response
437
+ received. **Default:** `null`.
438
+ * `info` {Object}
439
+ * `statusCode` {number}
440
+ * `headers` {Object}
441
+ * `responseHeaders` {string|null} Set to `'raw'` to return the response headers
442
+ as a raw array. **Default:** `null`.
443
+ * `highWaterMark` {number} The high water mark of the response body stream.
444
+ **Default:** `65536` (64 KiB).
445
+ * `callback` {Function} (optional) Invoked when the response is received.
446
+ * `error` {Error|null}
447
+ * `data` {Object}
448
+ * `statusCode` {number}
449
+ * `statusText` {string} The status message, e.g. `'OK'` or `'Not Found'`.
450
+ * `headers` {Object} The response headers. All keys are lower-cased.
451
+ * `body` {Readable} The response body, which also implements the
452
+ [body mixin][] from the Fetch Standard.
453
+ * `trailers` {Object} Starts out empty and is mutated to contain the trailers
454
+ after `body` emits `'end'`.
455
+ * `opaque` {any} The `opaque` value passed in `options`.
456
+ * `context` {Object}
457
+ * Returns: {Promise} A `Promise` is returned only when `callback` is omitted. It
458
+ resolves with the `data` object described above.
459
+
460
+ Performs an HTTP request. `options.method` must not be `'CONNECT'`.
461
+
462
+ Non-idempotent requests are not pipelined, to avoid indirect failures. Idempotent
463
+ requests are automatically retried if they fail due to an indirect failure from
464
+ the request at the head of the pipeline; this does not apply to idempotent
465
+ requests with a stream request body. All response bodies must always be fully
466
+ consumed or destroyed.
467
+
468
+ The `body` exposes the following [body mixin][] methods and properties:
469
+ [`.arrayBuffer()`][], [`.blob()`][], [`.bytes()`][], [`.json()`][],
470
+ [`.text()`][], `body`, and `bodyUsed`. A body cannot be consumed twice; for
471
+ example, calling `text()` after `json()` throws a `TypeError`. The body also
472
+ provides `dump({ limit })`, which discards up to `limit` bytes (default
473
+ `131072`) without destroying the socket.
474
+
475
+ > [!WARNING]
476
+ > The `arrayBuffer()`, `blob()`, `bytes()`, `json()`, and `text()` methods buffer
477
+ > the entire body in memory before returning. Where applicable, they also decode
478
+ > or parse the payload and retain that representation in memory. Calling these
479
+ > methods therefore means trusting that the body is small enough to fit in the
480
+ > available memory. Do not use them for bodies received from untrusted or
481
+ > user-controlled sources. Instead, process `body` as a `Readable` stream and
482
+ > enforce an application-specific size limit.
483
+
484
+ The body is always a `Readable`, even when empty. Deserializing an empty body
485
+ with `json()` throws. To guard against this, verify the status code is not `204`
486
+ and the `content-type` header starts with `application/json` before calling
487
+ `json()`.
488
+
489
+ ```mjs
490
+ import { createServer } from 'node:http'
491
+ import { Client } from 'undici'
492
+ import { once } from 'node:events'
493
+
494
+ const server = createServer((request, response) => {
495
+ response.end('Hello, World!')
496
+ }).listen()
497
+
498
+ await once(server, 'listening')
499
+
500
+ const client = new Client(`http://localhost:${server.address().port}`)
501
+
502
+ try {
503
+ const { body, headers, statusCode, statusText, trailers } = await client.request({
504
+ path: '/',
505
+ method: 'GET'
506
+ })
507
+ console.log(`response received ${statusCode}`)
508
+ console.log('headers', headers)
509
+ body.setEncoding('utf8')
510
+ body.on('data', console.log)
511
+ body.on('error', console.error)
512
+ body.on('end', () => {
513
+ console.log('trailers', trailers)
514
+ })
515
+
516
+ client.close()
517
+ server.close()
518
+ } catch (error) {
519
+ console.error(error)
520
+ }
521
+ ```
522
+
523
+ A request can be aborted with an `AbortSignal`, with any `EventEmitter` that
524
+ emits an `'abort'` event, or by destroying the response body:
525
+
526
+ ```mjs
527
+ import { Client } from 'undici'
528
+
529
+ const client = new Client('http://localhost:3000')
530
+ const abortController = new AbortController()
531
+
532
+ try {
533
+ client.request({ path: '/', method: 'GET', signal: abortController.signal })
534
+ } catch (error) {
535
+ console.error(error) // RequestAbortedError
536
+ }
537
+
538
+ abortController.abort()
539
+ ```
540
+
541
+ When the response body is conditionally read, always fully consume it otherwise:
542
+
543
+ ```mjs
544
+ const { body, statusCode } = await client.request({ path: '/', method: 'GET' })
545
+
546
+ if (statusCode === 200) {
547
+ return await body.arrayBuffer()
548
+ }
549
+
550
+ await body.dump()
551
+
552
+ return null
553
+ ```
554
+
555
+ ### `dispatcher.stream(options, factory[, callback])`
556
+
557
+ <!-- YAML
558
+ added: v4.0.0
559
+ -->
560
+
561
+ * `options` {Object} Accepts the same fields as [`dispatcher.request()`][]'s
562
+ `options`.
563
+ * `factory` {Function} Returns the `Writable` to which the response is written.
564
+ * `data` {Object}
565
+ * `statusCode` {number}
566
+ * `headers` {Object} The response headers.
567
+ * `opaque` {any} The `opaque` value passed in `options`.
568
+ * `context` {Object}
569
+ * Returns: {Writable}
570
+ * `callback` {Function} (optional) Invoked when the request has completed.
571
+ * `error` {Error|null}
572
+ * `data` {Object}
573
+ * `opaque` {any} The `opaque` value passed in `options`.
574
+ * `trailers` {Object}
575
+ * Returns: {Promise} A `Promise` is returned only when `callback` is omitted. It
576
+ resolves with the `data` object described above.
577
+
578
+ A faster version of [`dispatcher.request()`][]. The `factory` returns a
579
+ [`Writable`][] to which the response is written, which avoids creating an
580
+ intermediate [`Readable`][] when the caller intends to pipe the response body
581
+ directly to a `Writable`.
582
+
583
+ Use `options.opaque` to avoid creating a closure for the `factory` method. This
584
+ pattern works well with Node.js web frameworks such as [Fastify][].
585
+
586
+ ```mjs
587
+ import { createServer } from 'node:http'
588
+ import { Client } from 'undici'
589
+ import { once } from 'node:events'
590
+ import { Writable } from 'node:stream'
591
+
592
+ const server = createServer((request, response) => {
593
+ response.end('Hello, World!')
594
+ }).listen()
595
+
596
+ await once(server, 'listening')
597
+
598
+ const client = new Client(`http://localhost:${server.address().port}`)
599
+
600
+ const bufs = []
601
+
602
+ try {
603
+ await client.stream({
604
+ path: '/',
605
+ method: 'GET',
606
+ opaque: { bufs }
607
+ }, ({ statusCode, headers, opaque: { bufs } }) => {
608
+ console.log(`response received ${statusCode}`)
609
+ console.log('headers', headers)
610
+ return new Writable({
611
+ write (chunk, encoding, callback) {
612
+ bufs.push(chunk)
613
+ callback()
614
+ }
615
+ })
616
+ })
617
+
618
+ console.log(Buffer.concat(bufs).toString('utf-8'))
619
+
620
+ client.close()
621
+ server.close()
622
+ } catch (error) {
623
+ console.error(error)
624
+ }
625
+ ```
626
+
627
+ ### `dispatcher.upgrade(options[, callback])`
628
+
629
+ <!-- YAML
630
+ added: v4.0.0
631
+ -->
632
+
633
+ * `options` {Object}
634
+ * `path` {string} The request path.
635
+ * `method` {string} The HTTP method. **Default:** `'GET'`.
636
+ * `headers` {UndiciHeaders} Request headers. **Default:** `null`.
637
+ * `protocol` {string} A comma-separated list of protocols, in descending
638
+ preference order. **Default:** `'Websocket'`.
639
+ * `signal` {AbortSignal|EventEmitter|null} A signal used to abort the request.
640
+ **Default:** `null`.
641
+ * `responseHeaders` {string|null} Set to `'raw'` to return the response headers
642
+ as a raw array. **Default:** `null`.
643
+ * `callback` {Function} (optional) Invoked when the upgrade completes.
644
+ * `error` {Error|null}
645
+ * `data` {Object}
646
+ * `headers` {Object} The response headers.
647
+ * `socket` {Duplex} The upgraded socket.
648
+ * `opaque` {any}
649
+ * Returns: {Promise} A `Promise` is returned only when `callback` is omitted. It
650
+ resolves with the `data` object described above.
651
+
652
+ Upgrades to a different protocol. See
653
+ [MDN: Protocol upgrade mechanism][] for more details.
654
+
655
+ ```mjs
656
+ import { createServer } from 'node:http'
657
+ import { Client } from 'undici'
658
+ import { once } from 'node:events'
659
+
660
+ const server = createServer((request, response) => {
661
+ response.statusCode = 101
662
+ response.setHeader('connection', 'upgrade')
663
+ response.setHeader('upgrade', request.headers.upgrade)
664
+ response.end()
665
+ }).listen()
666
+
667
+ await once(server, 'listening')
668
+
669
+ const client = new Client(`http://localhost:${server.address().port}`)
670
+
671
+ try {
672
+ const { headers, socket } = await client.upgrade({ path: '/' })
673
+ socket.on('end', () => {
674
+ console.log(`upgrade: ${headers.upgrade}`) // upgrade: Websocket
675
+ client.close()
676
+ server.close()
677
+ })
678
+ socket.end()
679
+ } catch (error) {
680
+ console.error(error)
681
+ client.close()
682
+ server.close()
683
+ }
684
+ ```
685
+
686
+ ### `dispatcher.compose(interceptors[, interceptor])`
687
+
688
+ <!-- YAML
689
+ added: v6.9.0
690
+ -->
691
+
692
+ * `interceptors` {Array|Function} An array of interceptor functions, or the first
693
+ of several interceptors passed as separate arguments.
694
+ * `...interceptor` {Function} Additional interceptors when passed as separate
695
+ arguments.
696
+ * Returns: {Dispatcher} A new dispatcher that applies the interceptors over the
697
+ current dispatcher's [`dispatch()`][] method.
698
+
699
+ Composes a new dispatcher from the current dispatcher and the given
700
+ interceptors. Each interceptor is a function that takes a `dispatch` method and
701
+ returns a `dispatch`-like function with the same signature
702
+ (`(options, handler)`).
703
+
704
+ The order of the interceptors matters: the last interceptor in the chain is the
705
+ first to be called. Forking the chain of interceptors can lead to unexpected
706
+ results.
707
+
708
+ ```text
709
+ compose([interceptor1, interceptor2, interceptor3])
710
+
711
+ Request flow:
712
+ Request -> interceptor3 -> interceptor2 -> interceptor1 -> dispatcher.dispatch
713
+ (called first) (called second) (called last)
714
+ ```
715
+
716
+ ```mjs
717
+ import { Client, RedirectHandler } from 'undici'
718
+
719
+ const redirectInterceptor = dispatch => {
720
+ return (opts, handler) => {
721
+ const { maxRedirections } = opts
722
+
723
+ if (!maxRedirections) {
724
+ return dispatch(opts, handler)
725
+ }
726
+
727
+ const redirectHandler = new RedirectHandler(dispatch, maxRedirections, opts, handler)
728
+ opts = { ...opts, maxRedirections: 0 } // Stop the sub-dispatcher from also redirecting.
729
+ return dispatch(opts, redirectHandler)
730
+ }
731
+ }
732
+
733
+ const client = new Client('http://localhost:3000').compose(redirectInterceptor)
734
+
735
+ await client.request({ path: '/', method: 'GET' })
736
+ ```
737
+
738
+ Interceptors can be chained by calling `compose()` repeatedly:
739
+
740
+ ```mjs
741
+ import { Client } from 'undici'
742
+
743
+ const client = new Client('http://localhost:3000')
744
+ .compose(redirectInterceptor)
745
+ .compose(retryInterceptor)
746
+
747
+ await client.request({ path: '/', method: 'GET' })
748
+ ```
749
+
750
+ For the full list of built-in interceptors provided by undici, see [Interceptors](Interceptors.md).
751
+ For an example of a custom interceptor that wraps handler callbacks, see
752
+ [Custom interceptors](Interceptors.md#custom-interceptors).
753
+
754
+ ### Event: `'connect'`
755
+
756
+ <!-- YAML
757
+ added: v4.0.0
758
+ -->
759
+
760
+ * `origin` {URL}
761
+ * `targets` {Array<Dispatcher>}
762
+
763
+ Emitted when the dispatcher has connected to the origin.
764
+
765
+ ### Event: `'disconnect'`
766
+
767
+ <!-- YAML
768
+ added: v4.0.0
769
+ -->
770
+
771
+ * `origin` {URL}
772
+ * `targets` {Array<Dispatcher>}
773
+ * `error` {Error}
774
+
775
+ Emitted when the dispatcher has been disconnected from the origin.
776
+
777
+ For HTTP/2, this event is also emitted when the dispatcher receives a
778
+ [GOAWAY frame][], with an error whose message is `HTTP/2: "GOAWAY" frame received`
779
+ and whose code is `UND_ERR_INFO`. Because of the binary-framing nature of the
780
+ protocol, a request may hang if a frame is received between the `HEADER` and
781
+ `DATA` frames. It is recommended to handle this event and close the dispatcher to
782
+ create a new HTTP/2 session.
783
+
784
+ ### Event: `'connectionError'`
785
+
786
+ <!-- YAML
787
+ added: v4.0.0
788
+ -->
789
+
790
+ * `origin` {URL}
791
+ * `targets` {Array<Dispatcher>}
792
+ * `error` {Error}
793
+
794
+ Emitted when the dispatcher fails to connect to the origin.
795
+
796
+ ### Event: `'drain'`
797
+
798
+ <!-- YAML
799
+ added: v4.0.0
800
+ -->
801
+
802
+ * `origin` {URL}
803
+
804
+ Emitted when the dispatcher is no longer busy and further [`dispatch()`][] calls
805
+ can make progress.
806
+
807
+ ## Pre-built interceptors
808
+
809
+ For the full reference of built-in interceptors (`dump`, `retry`, `redirect`,
810
+ `decompress`, `responseError`, `dns`, `cache`, `deduplicate`) and their options,
811
+ see [Interceptors](Interceptors.md).
812
+
813
+ [Fastify]: https://fastify.dev
814
+ [GOAWAY frame]: https://webconcepts.info/concepts/http2-frame-type/0x7
815
+ [HTTP `CONNECT`]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/CONNECT
816
+ [MDN: Protocol upgrade mechanism]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Protocol_upgrade_mechanism
817
+ [`.arrayBuffer()`]: https://fetch.spec.whatwg.org/#dom-body-arraybuffer
818
+ [`.blob()`]: https://fetch.spec.whatwg.org/#dom-body-blob
819
+ [`.bytes()`]: https://fetch.spec.whatwg.org/#dom-body-bytes
820
+ [`.json()`]: https://fetch.spec.whatwg.org/#dom-body-json
821
+ [`.text()`]: https://fetch.spec.whatwg.org/#dom-body-text
822
+ [`'drain'`]: #event-drain
823
+ [`Agent`]: Agent.md#class-agent
824
+ [`BalancedPool`]: BalancedPool.md#class-balancedpool
825
+ [`Client`]: Client.md#class-client
826
+ [`EventEmitter`]: https://nodejs.org/api/events.html#class-eventemitter
827
+ [`Pool`]: Pool.md#class-pool
828
+ [`Readable`]: https://nodejs.org/api/stream.html#class-streamreadable
829
+ [`Writable`]: https://nodejs.org/api/stream.html#class-streamwritable
830
+ [`close()`]: #dispatcherclosecallback
831
+ [`connect()`]: #dispatcherconnectoptions-callback
832
+ [`destroy()`]: #dispatcherdestroyerror-callback
833
+ [`dispatch()`]: #dispatcherdispatchoptions-handler
834
+ [`dispatcher.compose()`]: #dispatchercomposeinterceptors-interceptor
835
+ [`dispatcher.dispatch()`]: #dispatcherdispatchoptions-handler
836
+ [`dispatcher.request()`]: #dispatcherrequestoptions-callback
837
+ [`pipeline()`]: #dispatcherpipelineoptions-handler
838
+ [`request()`]: #dispatcherrequestoptions-callback
839
+ [`stream()`]: #dispatcherstreamoptions-factory-callback
840
+ [`stream.pipeline()`]: https://nodejs.org/api/stream.html#streampipelinesource-transforms-destination-options
841
+ [`upgrade()`]: #dispatcherupgradeoptions-callback
842
+ [body mixin]: https://fetch.spec.whatwg.org/#body-mixin