@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.
- package/dist/commands/author-loop.d.ts.map +1 -1
- package/dist/commands/author-loop.js +2 -2
- package/dist/commands/author-loop.js.map +1 -1
- package/dist/commands/catalog-dispatch.d.ts.map +1 -1
- package/dist/commands/catalog-dispatch.js +21 -2
- package/dist/commands/catalog-dispatch.js.map +1 -1
- package/dist/commands/deploy-ops.d.ts.map +1 -1
- package/dist/commands/deploy-ops.js +28 -11
- package/dist/commands/deploy-ops.js.map +1 -1
- package/dist/first-run.d.ts +11 -0
- package/dist/first-run.d.ts.map +1 -1
- package/dist/first-run.js +19 -4
- package/dist/first-run.js.map +1 -1
- package/dist/project-scaffold-templates.d.ts +11 -0
- package/dist/project-scaffold-templates.d.ts.map +1 -0
- package/dist/project-scaffold-templates.js +359 -0
- package/dist/project-scaffold-templates.js.map +1 -0
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +1 -323
- package/dist/project.js.map +1 -1
- package/dist/react.d.ts +2 -2
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +1 -1
- package/dist/react.js.map +1 -1
- package/dist/validate.d.ts +12 -0
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +11 -0
- package/dist/validate.js.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/dist/skill-content.d.ts.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/dist/skill-content.js +6 -9
- package/node_modules/@noodle-borg/agent-kit/dist/skill-content.js.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/package.json +1 -1
- package/node_modules/@noodle-borg/authoring/dist/index.d.ts +3 -3
- package/node_modules/@noodle-borg/authoring/dist/index.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/index.js +1 -1
- package/node_modules/@noodle-borg/authoring/dist/index.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/components.d.ts +302 -7
- package/node_modules/@noodle-borg/authoring/dist/react/components.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/components.js +39 -7
- package/node_modules/@noodle-borg/authoring/dist/react/components.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/index.d.ts +4 -2
- package/node_modules/@noodle-borg/authoring/dist/react/index.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/index.js +2 -1
- package/node_modules/@noodle-borg/authoring/dist/react/index.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.d.ts +2618 -0
- package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.d.ts.map +1 -0
- package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.js +110 -0
- package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.js.map +1 -0
- package/node_modules/@noodle-borg/authoring/dist/react.d.ts +2 -2
- package/node_modules/@noodle-borg/authoring/dist/react.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react.js +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/recording.d.ts +1 -1
- package/node_modules/@noodle-borg/authoring/dist/recording.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/recording.js +14 -1
- package/node_modules/@noodle-borg/authoring/dist/recording.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/server.d.ts +25 -2
- package/node_modules/@noodle-borg/authoring/dist/server.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/server.js +7 -3
- package/node_modules/@noodle-borg/authoring/dist/server.js.map +1 -1
- package/node_modules/@noodle-borg/compiler/dist/compile.d.ts.map +1 -1
- package/node_modules/@noodle-borg/compiler/dist/compile.js +20 -8
- package/node_modules/@noodle-borg/compiler/dist/compile.js.map +1 -1
- package/node_modules/@noodle-borg/compiler/dist/manifest/schema.d.ts +2 -0
- package/node_modules/@noodle-borg/compiler/dist/manifest/schema.d.ts.map +1 -1
- package/node_modules/@noodle-borg/compiler/dist/manifest/schema.js +6 -0
- package/node_modules/@noodle-borg/compiler/dist/manifest/schema.js.map +1 -1
- package/node_modules/@noodle-borg/connector-http/package.json +1 -1
- package/node_modules/@noodle-borg/protocol/dist/mapping.d.ts.map +1 -1
- package/node_modules/@noodle-borg/protocol/dist/mapping.js +8 -0
- package/node_modules/@noodle-borg/protocol/dist/mapping.js.map +1 -1
- package/node_modules/hono/dist/adapter/aws-lambda/handler.js +15 -21
- package/node_modules/hono/dist/adapter/bun/websocket.js +3 -1
- package/node_modules/hono/dist/adapter/lambda-edge/handler.js +8 -2
- package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +15 -21
- package/node_modules/hono/dist/cjs/adapter/bun/websocket.js +3 -1
- package/node_modules/hono/dist/cjs/adapter/lambda-edge/handler.js +8 -2
- package/node_modules/hono/dist/cjs/helper/css/common.js +3 -1
- package/node_modules/hono/dist/cjs/helper/css/index.js +9 -1
- package/node_modules/hono/dist/cjs/jsx/base.js +8 -14
- package/node_modules/hono/dist/cjs/jsx/components.js +41 -21
- package/node_modules/hono/dist/cjs/jsx/context.js +131 -5
- package/node_modules/hono/dist/cjs/jsx/streaming.js +9 -7
- package/node_modules/hono/dist/cjs/middleware/cors/index.js +2 -5
- package/node_modules/hono/dist/cjs/middleware/serve-static/index.js +2 -2
- package/node_modules/hono/dist/cjs/utils/body.js +12 -4
- package/node_modules/hono/dist/cjs/utils/buffer.js +2 -1
- package/node_modules/hono/dist/cjs/validator/validator.js +3 -3
- package/node_modules/hono/dist/helper/css/common.js +3 -1
- package/node_modules/hono/dist/helper/css/index.js +9 -1
- package/node_modules/hono/dist/jsx/base.js +15 -15
- package/node_modules/hono/dist/jsx/components.js +42 -22
- package/node_modules/hono/dist/jsx/context.js +129 -5
- package/node_modules/hono/dist/jsx/streaming.js +10 -8
- package/node_modules/hono/dist/middleware/cors/index.js +2 -5
- package/node_modules/hono/dist/middleware/serve-static/index.js +2 -2
- package/node_modules/hono/dist/types/adapter/aws-lambda/handler.d.ts +1 -1
- package/node_modules/hono/dist/types/jsx/base.d.ts +1 -3
- package/node_modules/hono/dist/types/jsx/context.d.ts +39 -0
- package/node_modules/hono/dist/types/middleware/context-storage/index.d.ts +2 -2
- package/node_modules/hono/dist/types/utils/body.d.ts +1 -1
- package/node_modules/hono/dist/utils/body.js +12 -4
- package/node_modules/hono/dist/utils/buffer.js +2 -1
- package/node_modules/hono/dist/validator/validator.js +3 -3
- package/node_modules/hono/package.json +9 -10
- package/node_modules/tailwindcss/dist/chunk-HMCCH6MG.mjs +1 -0
- package/node_modules/tailwindcss/dist/default-theme.mjs +1 -1
- package/node_modules/tailwindcss/dist/lib.js +13 -13
- package/node_modules/tailwindcss/dist/lib.mjs +18 -18
- package/node_modules/tailwindcss/package.json +2 -2
- package/node_modules/undici/README.md +3 -2
- package/node_modules/undici/docs/docs/api/Agent.md +248 -44
- package/node_modules/undici/docs/docs/api/BalancedPool.md +246 -48
- package/node_modules/undici/docs/docs/api/CacheStorage.md +171 -13
- package/node_modules/undici/docs/docs/api/CacheStore.md +294 -98
- package/node_modules/undici/docs/docs/api/Client.md +365 -178
- package/node_modules/undici/docs/docs/api/ClientStats.md +80 -14
- package/node_modules/undici/docs/docs/api/Connector.md +118 -36
- package/node_modules/undici/docs/docs/api/ContentType.md +65 -25
- package/node_modules/undici/docs/docs/api/Cookies.md +125 -47
- package/node_modules/undici/docs/docs/api/Debug.md +34 -18
- package/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +364 -164
- package/node_modules/undici/docs/docs/api/Dispatcher.md +479 -1093
- package/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +101 -87
- package/node_modules/undici/docs/docs/api/Errors.md +503 -40
- package/node_modules/undici/docs/docs/api/EventSource.md +294 -32
- package/node_modules/undici/docs/docs/api/Fetch.md +680 -31
- package/node_modules/undici/docs/docs/api/GlobalInstallation.md +78 -98
- package/node_modules/undici/docs/docs/api/H2CClient.md +298 -176
- package/node_modules/undici/docs/docs/api/Interceptors.md +355 -0
- package/node_modules/undici/docs/docs/api/MockAgent.md +314 -322
- package/node_modules/undici/docs/docs/api/MockCallHistory.md +272 -98
- package/node_modules/undici/docs/docs/api/MockCallHistoryLog.md +189 -26
- package/node_modules/undici/docs/docs/api/MockClient.md +151 -33
- package/node_modules/undici/docs/docs/api/MockErrors.md +56 -5
- package/node_modules/undici/docs/docs/api/MockPool.md +299 -263
- package/node_modules/undici/docs/docs/api/Pool.md +235 -43
- package/node_modules/undici/docs/docs/api/PoolStats.md +119 -13
- package/node_modules/undici/docs/docs/api/ProxyAgent.md +179 -160
- package/node_modules/undici/docs/docs/api/RedirectHandler.md +238 -63
- package/node_modules/undici/docs/docs/api/RetryAgent.md +113 -26
- package/node_modules/undici/docs/docs/api/RetryHandler.md +161 -77
- package/node_modules/undici/docs/docs/api/RoundRobinPool.md +166 -72
- package/node_modules/undici/docs/docs/api/SnapshotAgent.md +264 -542
- package/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +162 -186
- package/node_modules/undici/docs/docs/api/Util.md +68 -11
- package/node_modules/undici/docs/docs/api/WebSocket.md +475 -80
- package/node_modules/undici/docs/docs/api/api-lifecycle.md +100 -32
- package/node_modules/undici/docs/docs/best-practices/client-certificate.md +2 -0
- package/node_modules/undici/docs/docs/best-practices/crawling.md +3 -1
- package/node_modules/undici/docs/docs/best-practices/migrating-from-v7-to-v8.md +6 -4
- package/node_modules/undici/docs/docs/best-practices/mocking-request.md +9 -7
- package/node_modules/undici/docs/docs/best-practices/proxy.md +3 -1
- package/node_modules/undici/docs/docs/best-practices/undici-vs-builtin-fetch.md +10 -8
- package/node_modules/undici/docs/docs/best-practices/writing-tests.md +2 -0
- package/node_modules/undici/docs/docs/{GettingStarted.md → getting-started.md} +22 -19
- package/node_modules/undici/docs/docs/index.md +779 -0
- package/node_modules/undici/docs/docs/site.json +125 -0
- package/node_modules/undici/docs/docs/type-map.json +79 -0
- package/node_modules/undici/lib/api/api-request.js +7 -1
- package/node_modules/undici/lib/api/readable.js +47 -2
- package/node_modules/undici/lib/core/errors.js +20 -0
- package/node_modules/undici/lib/core/request.js +1 -1
- package/node_modules/undici/lib/core/util.js +24 -1
- package/node_modules/undici/lib/dispatcher/client-h1.js +92 -1
- package/node_modules/undici/lib/dispatcher/client-h2.js +322 -118
- package/node_modules/undici/lib/dispatcher/client.js +6 -2
- package/node_modules/undici/lib/dispatcher/dispatcher-base.js +1 -0
- package/node_modules/undici/lib/dispatcher/proxy-agent.js +42 -7
- package/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +4 -2
- package/node_modules/undici/lib/handler/redirect-handler.js +1 -0
- package/node_modules/undici/lib/handler/retry-handler.js +57 -19
- package/node_modules/undici/lib/util/cache.js +8 -2
- package/node_modules/undici/lib/web/cookies/parse.js +20 -27
- package/node_modules/undici/lib/web/cookies/util.js +1 -1
- package/node_modules/undici/lib/web/eventsource/eventsource.js +7 -18
- package/node_modules/undici/lib/web/eventsource/util.js +32 -1
- package/node_modules/undici/lib/web/fetch/body.js +43 -0
- package/node_modules/undici/lib/web/fetch/constants.js +1 -1
- package/node_modules/undici/lib/web/fetch/index.js +11 -2
- package/node_modules/undici/lib/web/fetch/request.js +1 -0
- package/node_modules/undici/lib/web/fetch/util.js +4 -1
- package/node_modules/undici/lib/web/websocket/receiver.js +20 -3
- package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +8 -1
- package/node_modules/undici/lib/web/websocket/websocket.js +3 -1
- package/node_modules/undici/package.json +1 -1
- package/node_modules/undici/types/client.d.ts +6 -1
- package/node_modules/undici/types/cookies.d.ts +1 -1
- package/node_modules/undici/types/errors.d.ts +10 -0
- package/node_modules/undici/types/fetch.d.ts +1 -0
- package/node_modules/undici/types/handlers.d.ts +2 -0
- package/node_modules/undici/types/proxy-agent.d.ts +7 -0
- package/package.json +4 -4
- package/react/styles.css +510 -5
- package/react/styles.source.css +850 -0
- package/node_modules/hono/dist/tsconfig.build.tsbuildinfo +0 -1
- package/node_modules/tailwindcss/dist/chunk-XVOTX5KS.mjs +0 -1
|
@@ -1,27 +1,49 @@
|
|
|
1
1
|
# Client Lifecycle
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
*
|
|
20
|
-
|
|
21
|
-
*
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
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 [`
|
|
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
|
-
|
|
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 [`
|
|
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 [`
|
|
106
|
+
Calling [`client.destroy()`][] moves the {Client} directly to **destroyed**,
|
|
107
|
+
regardless of any queued requests.
|
|
72
108
|
|
|
73
109
|
### processing
|
|
74
110
|
|
|
75
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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](
|
|
229
|
-
- [Client](
|
|
230
|
-
- [Global Installation](
|
|
231
|
-
- [Undici Module vs. Node.js Built-in Fetch](
|
|
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
|
-
|
|
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](
|
|
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](
|
|
128
|
+
Explore other MockAgent functionality [here](../api/MockAgent.md)
|
|
127
129
|
|
|
128
|
-
Explore other MockCallHistory functionality [here](
|
|
130
|
+
Explore other MockCallHistory functionality [here](../api/MockCallHistory.md)
|
|
129
131
|
|
|
130
|
-
Explore other MockCallHistoryLog functionality [here](
|
|
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
|
|
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()`](
|
|
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()`](
|
|
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](
|
|
220
|
-
- [API Reference: Client](
|
|
221
|
-
- [API Reference: Pool](
|
|
222
|
-
- [API Reference: ProxyAgent](
|
|
223
|
-
- [API Reference: MockAgent](
|
|
224
|
-
- [API Reference: Global Installation](
|
|
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
|
# 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
|
-
```
|
|
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
|
-
```
|
|
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
|
-
```
|
|
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](
|
|
58
|
+
> [Specification Compliance - Garbage Collection](/#garbage-collection)
|
|
57
59
|
> for details.
|
|
58
60
|
|
|
59
|
-
For more on `fetch`, see [API Reference: Fetch](
|
|
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](
|
|
131
|
-
- [API Reference: Pool](
|
|
132
|
-
- [API Reference: Client](
|
|
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](
|
|
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](
|
|
221
|
-
[API Reference: ProxyAgent](
|
|
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](
|
|
239
|
-
and [API Reference: MockAgent](
|
|
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](
|
|
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](
|
|
274
|
+
See [API Reference: Global Installation](api/GlobalInstallation.md).
|
|
272
275
|
|
|
273
276
|
## Further reading
|
|
274
277
|
|
|
275
|
-
- [Undici vs. Built-in Fetch](
|
|
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](
|
|
278
|
-
- [Examples](/
|
|
280
|
+
- [API Reference](api/Dispatcher.md) — full dispatcher API documentation
|
|
281
|
+
- [Examples](/examples/) — runnable code examples
|