@noodleseed/one 0.22.0 → 0.23.0

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 (197) hide show
  1. package/dist/commands/author-loop.d.ts.map +1 -1
  2. package/dist/commands/author-loop.js +2 -2
  3. package/dist/commands/author-loop.js.map +1 -1
  4. package/dist/commands/catalog-dispatch.d.ts.map +1 -1
  5. package/dist/commands/catalog-dispatch.js +21 -2
  6. package/dist/commands/catalog-dispatch.js.map +1 -1
  7. package/dist/commands/deploy-ops.d.ts.map +1 -1
  8. package/dist/commands/deploy-ops.js +28 -11
  9. package/dist/commands/deploy-ops.js.map +1 -1
  10. package/dist/first-run.d.ts +11 -0
  11. package/dist/first-run.d.ts.map +1 -1
  12. package/dist/first-run.js +19 -4
  13. package/dist/first-run.js.map +1 -1
  14. package/dist/project-scaffold-templates.d.ts +11 -0
  15. package/dist/project-scaffold-templates.d.ts.map +1 -0
  16. package/dist/project-scaffold-templates.js +359 -0
  17. package/dist/project-scaffold-templates.js.map +1 -0
  18. package/dist/project.d.ts.map +1 -1
  19. package/dist/project.js +1 -323
  20. package/dist/project.js.map +1 -1
  21. package/dist/react.d.ts +2 -2
  22. package/dist/react.d.ts.map +1 -1
  23. package/dist/react.js +1 -1
  24. package/dist/react.js.map +1 -1
  25. package/dist/validate.d.ts +12 -0
  26. package/dist/validate.d.ts.map +1 -1
  27. package/dist/validate.js +11 -0
  28. package/dist/validate.js.map +1 -1
  29. package/node_modules/@noodle-borg/agent-kit/dist/skill-content.d.ts.map +1 -1
  30. package/node_modules/@noodle-borg/agent-kit/dist/skill-content.js +6 -9
  31. package/node_modules/@noodle-borg/agent-kit/dist/skill-content.js.map +1 -1
  32. package/node_modules/@noodle-borg/agent-kit/package.json +1 -1
  33. package/node_modules/@noodle-borg/authoring/dist/index.d.ts +3 -3
  34. package/node_modules/@noodle-borg/authoring/dist/index.d.ts.map +1 -1
  35. package/node_modules/@noodle-borg/authoring/dist/index.js +1 -1
  36. package/node_modules/@noodle-borg/authoring/dist/index.js.map +1 -1
  37. package/node_modules/@noodle-borg/authoring/dist/react/components.d.ts +302 -7
  38. package/node_modules/@noodle-borg/authoring/dist/react/components.d.ts.map +1 -1
  39. package/node_modules/@noodle-borg/authoring/dist/react/components.js +39 -7
  40. package/node_modules/@noodle-borg/authoring/dist/react/components.js.map +1 -1
  41. package/node_modules/@noodle-borg/authoring/dist/react/index.d.ts +4 -2
  42. package/node_modules/@noodle-borg/authoring/dist/react/index.d.ts.map +1 -1
  43. package/node_modules/@noodle-borg/authoring/dist/react/index.js +2 -1
  44. package/node_modules/@noodle-borg/authoring/dist/react/index.js.map +1 -1
  45. package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.d.ts +2618 -0
  46. package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.d.ts.map +1 -0
  47. package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.js +110 -0
  48. package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.js.map +1 -0
  49. package/node_modules/@noodle-borg/authoring/dist/react.d.ts +2 -2
  50. package/node_modules/@noodle-borg/authoring/dist/react.d.ts.map +1 -1
  51. package/node_modules/@noodle-borg/authoring/dist/react.js +1 -1
  52. package/node_modules/@noodle-borg/authoring/dist/react.js.map +1 -1
  53. package/node_modules/@noodle-borg/authoring/dist/recording.d.ts +1 -1
  54. package/node_modules/@noodle-borg/authoring/dist/recording.d.ts.map +1 -1
  55. package/node_modules/@noodle-borg/authoring/dist/recording.js +14 -1
  56. package/node_modules/@noodle-borg/authoring/dist/recording.js.map +1 -1
  57. package/node_modules/@noodle-borg/authoring/dist/server.d.ts +25 -2
  58. package/node_modules/@noodle-borg/authoring/dist/server.d.ts.map +1 -1
  59. package/node_modules/@noodle-borg/authoring/dist/server.js +7 -3
  60. package/node_modules/@noodle-borg/authoring/dist/server.js.map +1 -1
  61. package/node_modules/@noodle-borg/compiler/dist/compile.d.ts.map +1 -1
  62. package/node_modules/@noodle-borg/compiler/dist/compile.js +20 -8
  63. package/node_modules/@noodle-borg/compiler/dist/compile.js.map +1 -1
  64. package/node_modules/@noodle-borg/compiler/dist/manifest/schema.d.ts +2 -0
  65. package/node_modules/@noodle-borg/compiler/dist/manifest/schema.d.ts.map +1 -1
  66. package/node_modules/@noodle-borg/compiler/dist/manifest/schema.js +6 -0
  67. package/node_modules/@noodle-borg/compiler/dist/manifest/schema.js.map +1 -1
  68. package/node_modules/@noodle-borg/connector-http/package.json +1 -1
  69. package/node_modules/@noodle-borg/protocol/dist/mapping.d.ts.map +1 -1
  70. package/node_modules/@noodle-borg/protocol/dist/mapping.js +8 -0
  71. package/node_modules/@noodle-borg/protocol/dist/mapping.js.map +1 -1
  72. package/node_modules/hono/dist/adapter/aws-lambda/handler.js +15 -21
  73. package/node_modules/hono/dist/adapter/bun/websocket.js +3 -1
  74. package/node_modules/hono/dist/adapter/lambda-edge/handler.js +8 -2
  75. package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +15 -21
  76. package/node_modules/hono/dist/cjs/adapter/bun/websocket.js +3 -1
  77. package/node_modules/hono/dist/cjs/adapter/lambda-edge/handler.js +8 -2
  78. package/node_modules/hono/dist/cjs/helper/css/common.js +3 -1
  79. package/node_modules/hono/dist/cjs/helper/css/index.js +9 -1
  80. package/node_modules/hono/dist/cjs/jsx/base.js +8 -14
  81. package/node_modules/hono/dist/cjs/jsx/components.js +41 -21
  82. package/node_modules/hono/dist/cjs/jsx/context.js +131 -5
  83. package/node_modules/hono/dist/cjs/jsx/streaming.js +9 -7
  84. package/node_modules/hono/dist/cjs/middleware/cors/index.js +2 -5
  85. package/node_modules/hono/dist/cjs/middleware/serve-static/index.js +2 -2
  86. package/node_modules/hono/dist/cjs/utils/body.js +12 -4
  87. package/node_modules/hono/dist/cjs/utils/buffer.js +2 -1
  88. package/node_modules/hono/dist/cjs/validator/validator.js +3 -3
  89. package/node_modules/hono/dist/helper/css/common.js +3 -1
  90. package/node_modules/hono/dist/helper/css/index.js +9 -1
  91. package/node_modules/hono/dist/jsx/base.js +15 -15
  92. package/node_modules/hono/dist/jsx/components.js +42 -22
  93. package/node_modules/hono/dist/jsx/context.js +129 -5
  94. package/node_modules/hono/dist/jsx/streaming.js +10 -8
  95. package/node_modules/hono/dist/middleware/cors/index.js +2 -5
  96. package/node_modules/hono/dist/middleware/serve-static/index.js +2 -2
  97. package/node_modules/hono/dist/types/adapter/aws-lambda/handler.d.ts +1 -1
  98. package/node_modules/hono/dist/types/jsx/base.d.ts +1 -3
  99. package/node_modules/hono/dist/types/jsx/context.d.ts +39 -0
  100. package/node_modules/hono/dist/types/middleware/context-storage/index.d.ts +2 -2
  101. package/node_modules/hono/dist/types/utils/body.d.ts +1 -1
  102. package/node_modules/hono/dist/utils/body.js +12 -4
  103. package/node_modules/hono/dist/utils/buffer.js +2 -1
  104. package/node_modules/hono/dist/validator/validator.js +3 -3
  105. package/node_modules/hono/package.json +9 -10
  106. package/node_modules/tailwindcss/dist/chunk-HMCCH6MG.mjs +1 -0
  107. package/node_modules/tailwindcss/dist/default-theme.mjs +1 -1
  108. package/node_modules/tailwindcss/dist/lib.js +13 -13
  109. package/node_modules/tailwindcss/dist/lib.mjs +18 -18
  110. package/node_modules/tailwindcss/package.json +2 -2
  111. package/node_modules/undici/README.md +3 -2
  112. package/node_modules/undici/docs/docs/api/Agent.md +248 -44
  113. package/node_modules/undici/docs/docs/api/BalancedPool.md +246 -48
  114. package/node_modules/undici/docs/docs/api/CacheStorage.md +171 -13
  115. package/node_modules/undici/docs/docs/api/CacheStore.md +294 -98
  116. package/node_modules/undici/docs/docs/api/Client.md +365 -178
  117. package/node_modules/undici/docs/docs/api/ClientStats.md +80 -14
  118. package/node_modules/undici/docs/docs/api/Connector.md +118 -36
  119. package/node_modules/undici/docs/docs/api/ContentType.md +65 -25
  120. package/node_modules/undici/docs/docs/api/Cookies.md +125 -47
  121. package/node_modules/undici/docs/docs/api/Debug.md +34 -18
  122. package/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +364 -164
  123. package/node_modules/undici/docs/docs/api/Dispatcher.md +479 -1093
  124. package/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +101 -87
  125. package/node_modules/undici/docs/docs/api/Errors.md +503 -40
  126. package/node_modules/undici/docs/docs/api/EventSource.md +294 -32
  127. package/node_modules/undici/docs/docs/api/Fetch.md +680 -31
  128. package/node_modules/undici/docs/docs/api/GlobalInstallation.md +78 -98
  129. package/node_modules/undici/docs/docs/api/H2CClient.md +298 -176
  130. package/node_modules/undici/docs/docs/api/Interceptors.md +355 -0
  131. package/node_modules/undici/docs/docs/api/MockAgent.md +314 -322
  132. package/node_modules/undici/docs/docs/api/MockCallHistory.md +272 -98
  133. package/node_modules/undici/docs/docs/api/MockCallHistoryLog.md +189 -26
  134. package/node_modules/undici/docs/docs/api/MockClient.md +151 -33
  135. package/node_modules/undici/docs/docs/api/MockErrors.md +56 -5
  136. package/node_modules/undici/docs/docs/api/MockPool.md +299 -263
  137. package/node_modules/undici/docs/docs/api/Pool.md +235 -43
  138. package/node_modules/undici/docs/docs/api/PoolStats.md +119 -13
  139. package/node_modules/undici/docs/docs/api/ProxyAgent.md +179 -160
  140. package/node_modules/undici/docs/docs/api/RedirectHandler.md +238 -63
  141. package/node_modules/undici/docs/docs/api/RetryAgent.md +113 -26
  142. package/node_modules/undici/docs/docs/api/RetryHandler.md +161 -77
  143. package/node_modules/undici/docs/docs/api/RoundRobinPool.md +166 -72
  144. package/node_modules/undici/docs/docs/api/SnapshotAgent.md +264 -542
  145. package/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +162 -186
  146. package/node_modules/undici/docs/docs/api/Util.md +68 -11
  147. package/node_modules/undici/docs/docs/api/WebSocket.md +475 -80
  148. package/node_modules/undici/docs/docs/api/api-lifecycle.md +100 -32
  149. package/node_modules/undici/docs/docs/best-practices/client-certificate.md +2 -0
  150. package/node_modules/undici/docs/docs/best-practices/crawling.md +3 -1
  151. package/node_modules/undici/docs/docs/best-practices/migrating-from-v7-to-v8.md +6 -4
  152. package/node_modules/undici/docs/docs/best-practices/mocking-request.md +9 -7
  153. package/node_modules/undici/docs/docs/best-practices/proxy.md +3 -1
  154. package/node_modules/undici/docs/docs/best-practices/undici-vs-builtin-fetch.md +10 -8
  155. package/node_modules/undici/docs/docs/best-practices/writing-tests.md +2 -0
  156. package/node_modules/undici/docs/docs/{GettingStarted.md → getting-started.md} +22 -19
  157. package/node_modules/undici/docs/docs/index.md +779 -0
  158. package/node_modules/undici/docs/docs/site.json +125 -0
  159. package/node_modules/undici/docs/docs/type-map.json +79 -0
  160. package/node_modules/undici/lib/api/api-request.js +7 -1
  161. package/node_modules/undici/lib/api/readable.js +47 -2
  162. package/node_modules/undici/lib/core/errors.js +20 -0
  163. package/node_modules/undici/lib/core/request.js +1 -1
  164. package/node_modules/undici/lib/core/util.js +24 -1
  165. package/node_modules/undici/lib/dispatcher/client-h1.js +92 -1
  166. package/node_modules/undici/lib/dispatcher/client-h2.js +322 -118
  167. package/node_modules/undici/lib/dispatcher/client.js +6 -2
  168. package/node_modules/undici/lib/dispatcher/dispatcher-base.js +1 -0
  169. package/node_modules/undici/lib/dispatcher/proxy-agent.js +42 -7
  170. package/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +4 -2
  171. package/node_modules/undici/lib/handler/redirect-handler.js +1 -0
  172. package/node_modules/undici/lib/handler/retry-handler.js +57 -19
  173. package/node_modules/undici/lib/util/cache.js +8 -2
  174. package/node_modules/undici/lib/web/cookies/parse.js +20 -27
  175. package/node_modules/undici/lib/web/cookies/util.js +1 -1
  176. package/node_modules/undici/lib/web/eventsource/eventsource.js +7 -18
  177. package/node_modules/undici/lib/web/eventsource/util.js +32 -1
  178. package/node_modules/undici/lib/web/fetch/body.js +43 -0
  179. package/node_modules/undici/lib/web/fetch/constants.js +1 -1
  180. package/node_modules/undici/lib/web/fetch/index.js +11 -2
  181. package/node_modules/undici/lib/web/fetch/request.js +1 -0
  182. package/node_modules/undici/lib/web/fetch/util.js +4 -1
  183. package/node_modules/undici/lib/web/websocket/receiver.js +20 -3
  184. package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +8 -1
  185. package/node_modules/undici/lib/web/websocket/websocket.js +3 -1
  186. package/node_modules/undici/package.json +1 -1
  187. package/node_modules/undici/types/client.d.ts +6 -1
  188. package/node_modules/undici/types/cookies.d.ts +1 -1
  189. package/node_modules/undici/types/errors.d.ts +10 -0
  190. package/node_modules/undici/types/fetch.d.ts +1 -0
  191. package/node_modules/undici/types/handlers.d.ts +2 -0
  192. package/node_modules/undici/types/proxy-agent.d.ts +7 -0
  193. package/package.json +4 -4
  194. package/react/styles.css +510 -5
  195. package/react/styles.source.css +850 -0
  196. package/node_modules/hono/dist/tsconfig.build.tsbuildinfo +0 -1
  197. package/node_modules/tailwindcss/dist/chunk-XVOTX5KS.mjs +0 -1
@@ -1,27 +1,49 @@
1
1
  # Client Lifecycle
2
2
 
3
- An Undici [Client](/docs/docs/api/Client.md) can be best described as a state machine. The following list is a summary of the various state transitions the `Client` will go through in its lifecycle. This document also contains detailed breakdowns of each state.
4
-
5
- > This diagram is not a perfect representation of the undici Client. Since the Client class is not actually implemented as a state-machine, actual execution may deviate slightly from what is described below. Consider this as a general resource for understanding the inner workings of the Undici client rather than some kind of formal specification.
6
-
7
- ## State Transition Overview
8
-
9
- * A `Client` begins in the **idle** state with no socket connection and no requests in queue.
10
- * The *connect* event transitions the `Client` to the **pending** state where requests can be queued prior to processing.
11
- * The *close* and *destroy* events transition the `Client` to the **destroyed** state. Since there are no requests in the queue, the *close* event immediately transitions to the **destroyed** state.
12
- * The **pending** state indicates the underlying socket connection has been successfully established and requests are queueing.
13
- * The *process* event transitions the `Client` to the **processing** state where requests are processed.
14
- * If requests are queued, the *close* event transitions to the **processing** state; otherwise, it transitions to the **destroyed** state.
15
- * The *destroy* event transitions to the **destroyed** state.
16
- * The **processing** state initializes to the **processing.running** state.
17
- * If the current request requires draining, the *needDrain* event transitions the `Client` into the **processing.busy** state which will return to the **processing.running** state with the *drainComplete* event.
18
- * After all queued requests are completed, the *keepalive* event transitions the `Client` back to the **pending** state. If no requests are queued during the timeout, the **close** event transitions the `Client` to the **destroyed** state.
19
- * If the *close* event is fired while the `Client` still has queued requests, the `Client` transitions to the **process.closing** state where it will complete all existing requests before firing the *done* event.
20
- * The *done* event gracefully transitions the `Client` to the **destroyed** state.
21
- * At any point in time, the *destroy* event will transition the `Client` from the **processing** state to the **destroyed** state, destroying any queued requests.
22
- * The **destroyed** state is a final state and the `Client` is no longer functional.
23
-
24
- A state diagram representing an Undici Client instance:
3
+ <!--type=misc-->
4
+
5
+ A {Client} can be understood as a state machine. As requests are dispatched,
6
+ processed, and drained, the client moves through a well-defined set of states
7
+ until it is eventually destroyed. This document describes those states and the
8
+ transitions between them.
9
+
10
+ The {Client} class is not literally implemented as a state machine, so the
11
+ actual execution may deviate slightly from what is described here. Treat this
12
+ guide as a conceptual model for reasoning about a client's behavior rather than
13
+ as a formal specification.
14
+
15
+ ## State transition overview
16
+
17
+ * A {Client} begins in the **idle** state with no socket connection and no
18
+ queued requests.
19
+ * The *connect* transition moves the {Client} to the **pending** state, where
20
+ requests can be queued before they are processed.
21
+ * Calling [`client.close()`][] or [`client.destroy()`][] moves the {Client}
22
+ to the **destroyed** state. Because there are no queued requests in this
23
+ state, *close* transitions straight to **destroyed**.
24
+ * The **pending** state indicates that the underlying socket connection has been
25
+ established and that requests are queueing.
26
+ * The *process* transition moves the {Client} to the **processing** state,
27
+ where requests are processed.
28
+ * If requests are queued, *close* transitions to **processing**; otherwise it
29
+ transitions to **destroyed**.
30
+ * The *destroy* transition moves the {Client} to **destroyed**.
31
+ * The **processing** state initializes to the **processing.running** sub-state.
32
+ * If the current request body requires draining, *needDrain* moves the
33
+ {Client} into the **processing.busy** sub-state, which returns to
34
+ **processing.running** once *drainComplete* fires.
35
+ * After all queued requests complete, *keepalive* moves the {Client} back to
36
+ the **pending** state. If no requests are queued before the socket times
37
+ out, the {Client} transitions to **idle**.
38
+ * If *close* is fired while the {Client} still has queued requests, the
39
+ {Client} transitions to **processing.closing**, where it completes all
40
+ outstanding requests before firing *done*.
41
+ * The *done* transition moves the {Client} gracefully to **destroyed**.
42
+ * At any time, *destroy* moves the {Client} from **processing** to
43
+ **destroyed**, aborting any queued requests.
44
+ * The **destroyed** state is final; the {Client} is no longer functional.
45
+
46
+ A state diagram representing a {Client} instance:
25
47
 
26
48
  ```mermaid
27
49
  stateDiagram-v2
@@ -54,38 +76,84 @@ stateDiagram-v2
54
76
  closing --> [*] : done
55
77
  }
56
78
  ```
79
+
57
80
  ## State details
58
81
 
59
82
  ### idle
60
83
 
61
- The **idle** state is the initial state of a `Client` instance. While an `origin` is required for instantiating a `Client` instance, the underlying socket connection will not be established until a request is queued using [`Client.dispatch()`](/docs/docs/api/Client.md#clientdispatchoptions-handlers). By calling `Client.dispatch()` directly or using one of the multiple implementations ([`Client.connect()`](/docs/docs/api/Client.md#clientconnectoptions-callback), [`Client.pipeline()`](/docs/docs/api/Client.md#clientpipelineoptions-handler), [`Client.request()`](/docs/docs/api/Client.md#clientrequestoptions-callback), [`Client.stream()`](/docs/docs/api/Client.md#clientstreamoptions-factory-callback), and [`Client.upgrade()`](/docs/docs/api/Client.md#clientupgradeoptions-callback)), the `Client` instance will transition from **idle** to [**pending**](/docs/docs/api/Client.md#pending) and then most likely directly to [**processing**](/docs/docs/api/Client.md#processing).
84
+ **idle** is the initial state of a {Client} instance. Although an `origin` is
85
+ required to construct a {Client}, the underlying socket connection is not
86
+ established until a request is queued through [`client.dispatch()`][]. Calling
87
+ `client.dispatch()` directly, or through one of its higher-level wrappers
88
+ ([`client.connect()`][], [`client.pipeline()`][], [`client.request()`][],
89
+ [`client.stream()`][], or [`client.upgrade()`][]), moves the {Client} from
90
+ **idle** to **pending**, and then usually directly on to **processing**.
62
91
 
63
- Calling [`Client.close()`](/docs/docs/api/Client.md#clientclosecallback) or [`Client.destroy()`](/docs/docs/api/Client.md#clientdestroyerror-callback) transitions directly to the [**destroyed**](/docs/docs/api/Client.md#destroyed) state since the `Client` instance will have no queued requests in this state.
92
+ Calling [`client.close()`][] or [`client.destroy()`][] in this state moves the
93
+ {Client} straight to **destroyed**, since there are no queued requests.
64
94
 
65
95
  ### pending
66
96
 
67
- The **pending** state signifies a non-processing `Client`. Upon entering this state, the `Client` establishes a socket connection and emits the [`'connect'`](/docs/docs/api/Client.md#event-connect) event signalling a connection was successfully established with the `origin` provided during `Client` instantiation. The internal queue is initially empty, and requests can start queueing.
97
+ **pending** signifies a connected but non-processing {Client}. On entering this
98
+ state, the {Client} establishes a socket connection and emits the
99
+ [`'connect'`][] event, signalling that a connection to the `origin` supplied at
100
+ construction time has been established. The internal queue starts empty, and
101
+ requests can begin queueing.
68
102
 
69
- Calling [`Client.close()`](/docs/docs/api/Client.md#clientclosecallback) with queued requests, transitions the `Client` to the [**processing**](/docs/docs/api/Client.md#processing) state. Without queued requests, it transitions to the [**destroyed**](/docs/docs/api/Client.md#destroyed) state.
103
+ Calling [`client.close()`][] with queued requests moves the {Client} to the
104
+ **processing** state; without queued requests it moves to **destroyed**.
70
105
 
71
- Calling [`Client.destroy()`](/docs/docs/api/Client.md#clientdestroyerror-callback) transitions directly to the [**destroyed**](/docs/docs/api/Client.md#destroyed) state regardless of existing requests.
106
+ Calling [`client.destroy()`][] moves the {Client} directly to **destroyed**,
107
+ regardless of any queued requests.
72
108
 
73
109
  ### processing
74
110
 
75
- The **processing** state is a state machine within itself. It initializes to the [**processing.running**](/docs/docs/api/Client.md#running) state. The [`Client.dispatch()`](/docs/docs/api/Client.md#clientdispatchoptions-handlers), [`Client.close()`](/docs/docs/api/Client.md#clientclosecallback), and [`Client.destroy()`](/docs/docs/api/Client.md#clientdestroyerror-callback) can be called at any time while the `Client` is in this state. `Client.dispatch()` will add more requests to the queue while existing requests continue to be processed. `Client.close()` will transition to the [**processing.closing**](/docs/docs/api/Client.md#closing) state. And `Client.destroy()` will transition to [**destroyed**](/docs/docs/api/Client.md#destroyed).
111
+ **processing** is itself a sub-state machine that initializes to the
112
+ **processing.running** sub-state. [`client.dispatch()`][], [`client.close()`][],
113
+ and [`client.destroy()`][] can all be called while the {Client} is in this
114
+ state. `client.dispatch()` queues additional requests while existing ones
115
+ continue to be processed, `client.close()` moves the {Client} to the
116
+ **processing.closing** sub-state, and `client.destroy()` moves it to
117
+ **destroyed**.
76
118
 
77
119
  #### running
78
120
 
79
- In the **processing.running** sub-state, queued requests are being processed in a FIFO order. If a request body requires draining, the *needDrain* event transitions to the [**processing.busy**](/docs/docs/api/Client.md#busy) sub-state. The *close* event transitions the Client to the [**process.closing**](/docs/docs/api/Client.md#closing) sub-state. If all queued requests are processed and neither [`Client.close()`](/docs/docs/api/Client.md#clientclosecallback) nor [`Client.destroy()`](/docs/docs/api/Client.md#clientdestroyerror-callback) are called, then the [**processing**](/docs/docs/api/Client.md#processing) machine will trigger a *keepalive* event transitioning the `Client` back to the [**pending**](/docs/docs/api/Client.md#pending) state. During this time, the `Client` is waiting for the socket connection to timeout, and once it does, it triggers the *timeout* event and transitions to the [**idle**](/docs/docs/api/Client.md#idle) state.
121
+ In **processing.running**, queued requests are processed in FIFO order. If a
122
+ request body requires draining, *needDrain* moves the {Client} to the
123
+ **processing.busy** sub-state. The *close* transition moves the {Client} to the
124
+ **processing.closing** sub-state. When all queued requests have completed and
125
+ neither [`client.close()`][] nor [`client.destroy()`][] has been called, the
126
+ *keepalive* transition moves the {Client} back to the **pending** state. There
127
+ the {Client} waits for the socket connection to time out; once it does, the
128
+ {Client} returns to the **idle** state.
80
129
 
81
130
  #### busy
82
131
 
83
- This sub-state is only entered when a request body is an instance of [Stream](https://nodejs.org/api/stream.html) and requires draining. The `Client` cannot process additional requests while in this state and must wait until the currently processing request body is completely drained before transitioning back to [**processing.running**](/docs/docs/api/Client.md#running).
132
+ This sub-state is entered only when a request body is a {stream.Readable} that
133
+ requires draining. The {Client} cannot process additional requests while in
134
+ this state and waits until the current request body has been fully drained
135
+ before returning to **processing.running**.
84
136
 
85
137
  #### closing
86
138
 
87
- This sub-state is only entered when a `Client` instance has queued requests and the [`Client.close()`](/docs/docs/api/Client.md#clientclosecallback) method is called. In this state, the `Client` instance continues to process requests as usual, with the one exception that no additional requests can be queued. Once all of the queued requests are processed, the `Client` will trigger the *done* event gracefully entering the [**destroyed**](/docs/docs/api/Client.md#destroyed) state without an error.
139
+ This sub-state is entered only when a {Client} has queued requests and
140
+ [`client.close()`][] is called. The {Client} continues to process requests as
141
+ usual, except that no additional requests may be queued. Once all queued
142
+ requests have been processed, *done* fires and the {Client} moves gracefully to
143
+ **destroyed** without an error.
88
144
 
89
145
  ### destroyed
90
146
 
91
- The **destroyed** state is a final state for the `Client` instance. Once in this state, a `Client` is nonfunctional. Calling any other `Client` methods will result in an `ClientDestroyedError`.
147
+ **destroyed** is the final state of a {Client} instance. Once in this state, the
148
+ {Client} is no longer functional, and calling any further {Client} method
149
+ rejects or fails with a {ClientDestroyedError}.
150
+
151
+ [`'connect'`]: Client.md#event-connect
152
+ [`client.close()`]: Client.md#clientclosecallback
153
+ [`client.connect()`]: Client.md#clientconnectoptions-callback
154
+ [`client.destroy()`]: Client.md#clientdestroyerror-callback
155
+ [`client.dispatch()`]: Client.md#clientdispatchoptions-handlers
156
+ [`client.pipeline()`]: Client.md#clientpipelineoptions-handler
157
+ [`client.request()`]: Client.md#clientrequestoptions-callback
158
+ [`client.stream()`]: Client.md#clientstreamoptions-factory-callback
159
+ [`client.upgrade()`]: Client.md#clientupgradeoptions-callback
@@ -1,5 +1,7 @@
1
1
  # Client certificate
2
2
 
3
+ <!--type=misc-->
4
+
3
5
  Client certificate authentication can be configured with the `Client`, the required options are passed along through the `connect` option.
4
6
 
5
7
  The client certificates must be signed by a trusted CA. The Node.js default is to trust the well-known CAs curated by Mozilla.
@@ -1,5 +1,7 @@
1
1
  # Crawling
2
2
 
3
+ <!--type=misc-->
4
+
3
5
  [RFC 9309](https://datatracker.ietf.org/doc/html/rfc9309) defines crawlers as automated clients.
4
6
 
5
7
  Some web servers may reject requests that omit the `User-Agent` header or that use common defaults such as `'curl/7.79.1'`.
@@ -10,7 +12,7 @@ It is recommended to specify a **custom `User-Agent` header** when implementing
10
12
 
11
13
  A user agent string should include sufficient detail to identify the crawler and provide contact information. For example:
12
14
 
13
- ```
15
+ ```text
14
16
  AcmeCo Crawler - acme.co - contact@acme.co
15
17
  ```
16
18
 
@@ -1,5 +1,7 @@
1
1
  # Migrating from Undici 7 to 8
2
2
 
3
+ <!--type=misc-->
4
+
3
5
  This guide covers the changes you are most likely to hit when upgrading an
4
6
  application or library from Undici v7 to v8.
5
7
 
@@ -225,7 +227,7 @@ After moving to Undici v8, it is worth checking these paths in your test suite:
225
227
 
226
228
  ## Related documentation
227
229
 
228
- - [Dispatcher](/docs/api/Dispatcher.md)
229
- - [Client](/docs/api/Client.md)
230
- - [Global Installation](/docs/api/GlobalInstallation.md)
231
- - [Undici Module vs. Node.js Built-in Fetch](/docs/best-practices/undici-vs-builtin-fetch.md)
230
+ - [Dispatcher](../api/Dispatcher.md)
231
+ - [Client](../api/Client.md)
232
+ - [Global Installation](../api/GlobalInstallation.md)
233
+ - [Undici Module vs. Node.js Built-in Fetch](./undici-vs-builtin-fetch.md)
@@ -1,6 +1,8 @@
1
1
  # Mocking Request
2
2
 
3
- Undici has its own mocking [utility](/docs/docs/api/MockAgent.md). It allow us to intercept undici HTTP requests and return mocked values instead. It can be useful for testing purposes.
3
+ <!--type=misc-->
4
+
5
+ Undici has its own mocking [utility](../api/MockAgent.md). It allow us to intercept undici HTTP requests and return mocked values instead. It can be useful for testing purposes.
4
6
 
5
7
  Example:
6
8
 
@@ -73,7 +75,7 @@ const badRequest = await bankTransfer('1234567890', '100')
73
75
  assert.deepEqual(badRequest, { message: 'bank account not found' })
74
76
  ```
75
77
 
76
- Explore other MockAgent functionality [here](/docs/docs/api/MockAgent.md)
78
+ Explore other MockAgent functionality [here](../api/MockAgent.md)
77
79
 
78
80
  ## Access agent call history
79
81
 
@@ -100,7 +102,7 @@ setGlobalDispatcher(mockAgent)
100
102
  // this call is made (not intercepted)
101
103
  await fetch(`http://localhost:3000/endpoint?query='hello'`, {
102
104
  method: 'POST',
103
- headers: { 'content-type': 'application/json' }
105
+ headers: { 'content-type': 'application/json' },
104
106
  body: JSON.stringify({ data: '' })
105
107
  })
106
108
 
@@ -123,11 +125,11 @@ assert.ok(mockAgent.getCallHistory()?.calls().length === 0)
123
125
 
124
126
  Calling `mockAgent.close()` will automatically clear and delete every call history for you.
125
127
 
126
- Explore other MockAgent functionality [here](/docs/docs/api/MockAgent.md)
128
+ Explore other MockAgent functionality [here](../api/MockAgent.md)
127
129
 
128
- Explore other MockCallHistory functionality [here](/docs/docs/api/MockCallHistory.md)
130
+ Explore other MockCallHistory functionality [here](../api/MockCallHistory.md)
129
131
 
130
- Explore other MockCallHistoryLog functionality [here](/docs/docs/api/MockCallHistoryLog.md)
132
+ Explore other MockCallHistoryLog functionality [here](../api/MockCallHistoryLog.md)
131
133
 
132
134
  ## Debug Mock Value
133
135
 
@@ -179,7 +181,7 @@ mockPool.intercept({
179
181
 
180
182
  in this case opts will be
181
183
 
182
- ```
184
+ ```js
183
185
  {
184
186
  method: 'POST',
185
187
  headers: { 'X-TOKEN-SECRET': 'SuperSecretToken' },
@@ -1,8 +1,10 @@
1
1
  # Connecting through a proxy
2
2
 
3
+ <!--type=misc-->
4
+
3
5
  Connecting through a proxy is possible by:
4
6
 
5
- - Using [ProxyAgent](/docs/docs/api/ProxyAgent.md).
7
+ - Using {ProxyAgent}.
6
8
  - Configuring `Client` or `Pool` constructor.
7
9
 
8
10
  The proxy url should be passed to the `Client` or `Pool` constructor, while the upstream server url
@@ -1,5 +1,7 @@
1
1
  # Undici Module vs. Node.js Built-in Fetch
2
2
 
3
+ <!--type=misc-->
4
+
3
5
  Node.js has shipped a built-in `fetch()` implementation powered by undici since
4
6
  Node.js v18. This guide explains the relationship between the `undici` npm
5
7
  package and the built-in `fetch`, and when you should install one versus relying
@@ -57,7 +59,7 @@ await fetch('https://example.com', {
57
59
  ### `undici.install()` globals
58
60
 
59
61
  If you want the installed `undici` package to provide the globals, call
60
- [`install()`](/docs/api/GlobalInstallation.md):
62
+ [`install()`](../api/GlobalInstallation.md):
61
63
 
62
64
  ```js
63
65
  import { install } from 'undici'
@@ -207,7 +209,7 @@ You can always check the exact bundled version at runtime with
207
209
 
208
210
  Installing undici from npm does not replace the built-in globals. If you want
209
211
  your installed version to replace the global `fetch` and related classes, use
210
- [`install()`](/docs/api/GlobalInstallation.md). Otherwise, import `fetch`
212
+ [`install()`](../api/GlobalInstallation.md). Otherwise, import `fetch`
211
213
  directly from `'undici'`:
212
214
 
213
215
  ```js
@@ -216,9 +218,9 @@ import { fetch } from 'undici' // uses your installed version, not the built-in
216
218
 
217
219
  ## Further reading
218
220
 
219
- - [API Reference: Fetch](/docs/api/Fetch.md)
220
- - [API Reference: Client](/docs/api/Client.md)
221
- - [API Reference: Pool](/docs/api/Pool.md)
222
- - [API Reference: ProxyAgent](/docs/api/ProxyAgent.md)
223
- - [API Reference: MockAgent](/docs/api/MockAgent.md)
224
- - [API Reference: Global Installation](/docs/api/GlobalInstallation.md)
221
+ - [API Reference: Fetch](../api/Fetch.md)
222
+ - [API Reference: Client](../api/Client.md)
223
+ - [API Reference: Pool](../api/Pool.md)
224
+ - [API Reference: ProxyAgent](../api/ProxyAgent.md)
225
+ - [API Reference: MockAgent](../api/MockAgent.md)
226
+ - [API Reference: Global Installation](../api/GlobalInstallation.md)
@@ -1,5 +1,7 @@
1
1
  # Writing tests
2
2
 
3
+ <!--type=misc-->
4
+
3
5
  Undici is tuned for a production use case and its default will keep
4
6
  a socket open for a few seconds after an HTTP request is completed to
5
7
  remove the overhead of opening up a new socket. These settings that makes
@@ -1,5 +1,7 @@
1
1
  # Getting Started
2
2
 
3
+ <!--type=misc-->
4
+
3
5
  ## Installation
4
6
 
5
7
  ```bash
@@ -12,7 +14,7 @@ The quickest way to get started is with `fetch`, which follows the
12
14
  [Fetch Standard](https://fetch.spec.whatwg.org/) and works the same way as
13
15
  the browser API:
14
16
 
15
- ```js
17
+ ```mjs
16
18
  import { fetch } from 'undici'
17
19
 
18
20
  const res = await fetch('https://example.com')
@@ -24,7 +26,7 @@ console.log(data)
24
26
 
25
27
  undici also exports a `Request` class that follows the Fetch Standard:
26
28
 
27
- ```js
29
+ ```mjs
28
30
  import { fetch, Request } from 'undici'
29
31
 
30
32
  const req = new Request('https://example.com', {
@@ -41,7 +43,7 @@ console.log(res.status)
41
43
  `res.body` is a web `ReadableStream`. Use `pipeline` from
42
44
  `node:stream/promises` to stream it to a file:
43
45
 
44
- ```js
46
+ ```mjs
45
47
  import { fetch } from 'undici'
46
48
  import { pipeline } from 'node:stream/promises'
47
49
  import { createWriteStream } from 'node:fs'
@@ -53,10 +55,10 @@ await pipeline(res.body, createWriteStream('./file.zip'))
53
55
  > Always consume or cancel the response body. In Node.js, garbage collection
54
56
  > is not aggressive enough to release connections promptly, so leaving a body
55
57
  > unread can cause connection leaks and stalled requests. See
56
- > [Specification Compliance - Garbage Collection](/docs/#garbage-collection)
58
+ > [Specification Compliance - Garbage Collection](/#garbage-collection)
57
59
  > for details.
58
60
 
59
- For more on `fetch`, see [API Reference: Fetch](/docs/docs/api/Fetch.md).
61
+ For more on `fetch`, see [API Reference: Fetch](api/Fetch.md).
60
62
 
61
63
  ## Dispatchers: Connection reuse and pooling
62
64
 
@@ -111,7 +113,8 @@ pool.close()
111
113
  ### `Client` — for a single connection
112
114
 
113
115
  `Client` maps to a single TCP connection. It supports pipelining (sending
114
- multiple requests before responses arrive):
116
+ multiple requests before responses arrive), which should only be enabled for
117
+ trusted remote servers:
115
118
 
116
119
  ```js
117
120
  import { Client } from 'undici'
@@ -127,9 +130,9 @@ client.close()
127
130
  ```
128
131
 
129
132
  For more on dispatcher options and lifecycle, see:
130
- - [API Reference: Agent](/docs/docs/api/Agent.md)
131
- - [API Reference: Pool](/docs/docs/api/Pool.md)
132
- - [API Reference: Client](/docs/docs/api/Client.md)
133
+ - [API Reference: Agent](api/Agent.md)
134
+ - [API Reference: Pool](api/Pool.md)
135
+ - [API Reference: Client](api/Client.md)
133
136
 
134
137
  ## Timeouts
135
138
 
@@ -152,7 +155,7 @@ setGlobalDispatcher(agent)
152
155
  ```
153
156
 
154
157
  Timeout errors are thrown as `HeadersTimeoutError` and `BodyTimeoutError`.
155
- See [API Reference: Errors](/docs/docs/api/Errors.md) for the full list.
158
+ See [API Reference: Errors](api/Errors.md) for the full list.
156
159
 
157
160
  ## Error handling
158
161
 
@@ -217,8 +220,8 @@ const proxy = new ProxyAgent('http://proxy.internal:8080')
217
220
  setGlobalDispatcher(proxy)
218
221
  ```
219
222
 
220
- See [Best Practices: Proxy](/docs/docs/best-practices/proxy.md) and
221
- [API Reference: ProxyAgent](/docs/docs/api/ProxyAgent.md).
223
+ See [Best Practices: Proxy](best-practices/proxy.md) and
224
+ [API Reference: ProxyAgent](api/ProxyAgent.md).
222
225
 
223
226
  ### Mocking in tests
224
227
 
@@ -235,8 +238,8 @@ const { body } = await request('https://api.example.com/users')
235
238
  console.log(await body.json())
236
239
  ```
237
240
 
238
- See [Best Practices: Mocking Request](/docs/docs/best-practices/mocking-request.md)
239
- and [API Reference: MockAgent](/docs/docs/api/MockAgent.md).
241
+ See [Best Practices: Mocking Request](best-practices/mocking-request.md)
242
+ and [API Reference: MockAgent](api/MockAgent.md).
240
243
 
241
244
  ### Testing with undici
242
245
 
@@ -252,7 +255,7 @@ const agent = new Agent({
252
255
  setGlobalDispatcher(agent)
253
256
  ```
254
257
 
255
- See [Best Practices: Writing Tests](/docs/docs/best-practices/writing-tests.md).
258
+ See [Best Practices: Writing Tests](best-practices/writing-tests.md).
256
259
 
257
260
  ### Customizing the global fetch
258
261
 
@@ -268,11 +271,11 @@ install()
268
271
  const res = await fetch('https://example.com')
269
272
  ```
270
273
 
271
- See [API Reference: Global Installation](/docs/docs/api/GlobalInstallation.md).
274
+ See [API Reference: Global Installation](api/GlobalInstallation.md).
272
275
 
273
276
  ## Further reading
274
277
 
275
- - [Undici vs. Built-in Fetch](/docs/docs/best-practices/undici-vs-builtin-fetch.md) —
278
+ - [Undici vs. Built-in Fetch](best-practices/undici-vs-builtin-fetch.md) —
276
279
  when to install undici vs using Node.js built-in fetch
277
- - [API Reference](/docs/docs/api/Dispatcher.md) — full dispatcher API documentation
278
- - [Examples](/docs/examples/) — runnable code examples
280
+ - [API Reference](api/Dispatcher.md) — full dispatcher API documentation
281
+ - [Examples](/examples/) — runnable code examples