@effect/platform-node 4.0.0-beta.70 → 4.0.0-beta.71
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/Mime.d.ts +6 -0
- package/dist/Mime.d.ts.map +1 -1
- package/dist/Mime.js +6 -0
- package/dist/Mime.js.map +1 -1
- package/dist/NodeCrypto.d.ts.map +1 -1
- package/dist/NodeCrypto.js +9 -1
- package/dist/NodeCrypto.js.map +1 -1
- package/dist/NodeFileSystem.d.ts.map +1 -1
- package/dist/NodeFileSystem.js +22 -14
- package/dist/NodeFileSystem.js.map +1 -1
- package/dist/NodeHttpClient.d.ts +31 -22
- package/dist/NodeHttpClient.d.ts.map +1 -1
- package/dist/NodeHttpClient.js +29 -20
- package/dist/NodeHttpClient.js.map +1 -1
- package/dist/NodeHttpIncomingMessage.d.ts +23 -10
- package/dist/NodeHttpIncomingMessage.d.ts.map +1 -1
- package/dist/NodeHttpIncomingMessage.js +23 -10
- package/dist/NodeHttpIncomingMessage.js.map +1 -1
- package/dist/NodeMultipart.d.ts +31 -16
- package/dist/NodeMultipart.d.ts.map +1 -1
- package/dist/NodeMultipart.js +29 -14
- package/dist/NodeMultipart.js.map +1 -1
- package/dist/NodePath.d.ts.map +1 -1
- package/dist/NodePath.js +24 -11
- package/dist/NodePath.js.map +1 -1
- package/dist/NodeRedis.d.ts +34 -16
- package/dist/NodeRedis.d.ts.map +1 -1
- package/dist/NodeRedis.js +33 -15
- package/dist/NodeRedis.js.map +1 -1
- package/dist/NodeRuntime.d.ts +3 -3
- package/dist/NodeRuntime.d.ts.map +1 -1
- package/dist/NodeRuntime.js +26 -12
- package/dist/NodeRuntime.js.map +1 -1
- package/dist/NodeServices.d.ts +31 -16
- package/dist/NodeServices.d.ts.map +1 -1
- package/dist/NodeServices.js.map +1 -1
- package/dist/NodeSocket.d.ts.map +1 -1
- package/dist/NodeSocket.js +31 -16
- package/dist/NodeSocket.js.map +1 -1
- package/dist/NodeStdio.d.ts.map +1 -1
- package/dist/NodeStdio.js +21 -13
- package/dist/NodeStdio.js.map +1 -1
- package/dist/NodeTerminal.d.ts.map +1 -1
- package/dist/NodeTerminal.js +18 -8
- package/dist/NodeTerminal.js.map +1 -1
- package/dist/NodeWorker.d.ts.map +1 -1
- package/dist/NodeWorker.js +28 -14
- package/dist/NodeWorker.js.map +1 -1
- package/dist/NodeWorkerRunner.d.ts.map +1 -1
- package/dist/NodeWorkerRunner.js +35 -15
- package/dist/NodeWorkerRunner.js.map +1 -1
- package/dist/Undici.d.ts +13 -0
- package/dist/Undici.d.ts.map +1 -1
- package/dist/Undici.js +13 -0
- package/dist/Undici.js.map +1 -1
- package/dist/index.d.ts +0 -350
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -350
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/Mime.ts +7 -0
- package/src/NodeCrypto.ts +9 -1
- package/src/NodeFileSystem.ts +22 -14
- package/src/NodeHttpClient.ts +29 -20
- package/src/NodeHttpIncomingMessage.ts +23 -10
- package/src/NodeMultipart.ts +29 -14
- package/src/NodePath.ts +24 -11
- package/src/NodeRedis.ts +33 -15
- package/src/NodeRuntime.ts +28 -14
- package/src/NodeServices.ts +31 -16
- package/src/NodeSocket.ts +29 -14
- package/src/NodeStdio.ts +21 -13
- package/src/NodeTerminal.ts +18 -8
- package/src/NodeWorker.ts +28 -14
- package/src/NodeWorkerRunner.ts +35 -15
- package/src/Undici.ts +13 -0
- package/src/index.ts +0 -350
package/dist/index.js
CHANGED
|
@@ -7,333 +7,62 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export * as Mime from "./Mime.js";
|
|
9
9
|
/**
|
|
10
|
-
* Node.js implementation of `ChildProcessSpawner`.
|
|
11
|
-
*
|
|
12
10
|
* @since 4.0.0
|
|
13
11
|
*/
|
|
14
12
|
export * as NodeChildProcessSpawner from "./NodeChildProcessSpawner.js";
|
|
15
13
|
/**
|
|
16
|
-
* The `NodeClusterHttp` module provides the Node.js HTTP and WebSocket
|
|
17
|
-
* transports for Effect Cluster runners. It wires `HttpRunner` to the Node HTTP
|
|
18
|
-
* server, supplies Undici and WebSocket client protocols, and builds a complete
|
|
19
|
-
* sharding layer with serialization, runner health, runner storage, and message
|
|
20
|
-
* storage.
|
|
21
|
-
*
|
|
22
|
-
* **Common tasks**
|
|
23
|
-
*
|
|
24
|
-
* - Run a Node process as a cluster runner over HTTP or WebSocket with
|
|
25
|
-
* {@link layer}
|
|
26
|
-
* - Connect a client-only process to an existing HTTP cluster without starting
|
|
27
|
-
* a runner server
|
|
28
|
-
* - Use SQL-backed storage for durable multi-process clusters, `local` storage
|
|
29
|
-
* for short-lived development, or `byo` storage when the deployment owns the
|
|
30
|
-
* persistence boundary
|
|
31
|
-
* - Check runner health with protocol pings or Kubernetes pod readiness through
|
|
32
|
-
* {@link layerK8sHttpClient}
|
|
33
|
-
*
|
|
34
|
-
* **Gotchas**
|
|
35
|
-
*
|
|
36
|
-
* - `runnerAddress` is the host and port advertised to other runners; set
|
|
37
|
-
* `runnerListenAddress` when the local bind address differs from the
|
|
38
|
-
* externally reachable address
|
|
39
|
-
* - The HTTP and WebSocket transports serve runner RPCs at the default
|
|
40
|
-
* `HttpRunner` route, so proxies and load balancers must preserve the path
|
|
41
|
-
* and allow WebSocket upgrades when `transport` is `"websocket"`
|
|
42
|
-
* - `clientOnly` does not start an HTTP server or receive shard assignments
|
|
43
|
-
* - SQL storage is the default; `local` storage is in-memory/noop and `byo`
|
|
44
|
-
* requires the surrounding application to provide both runner and message
|
|
45
|
-
* storage services
|
|
46
|
-
* - Ping health checks use the selected transport and serialization, so route,
|
|
47
|
-
* port, proxy, or codec mismatches can make a runner appear unhealthy
|
|
48
|
-
*
|
|
49
14
|
* @since 4.0.0
|
|
50
15
|
*/
|
|
51
16
|
export * as NodeClusterHttp from "./NodeClusterHttp.js";
|
|
52
17
|
/**
|
|
53
|
-
* The `NodeClusterSocket` module provides the Node.js socket transport for
|
|
54
|
-
* Effect Cluster runners. It wires `SocketRunner` to Node TCP sockets, supplies
|
|
55
|
-
* RPC client and server protocol layers, and builds a complete sharding layer
|
|
56
|
-
* with serialization, runner health, runner storage, and message storage.
|
|
57
|
-
*
|
|
58
|
-
* **Common tasks**
|
|
59
|
-
*
|
|
60
|
-
* - Run a Node process as a cluster runner over raw TCP sockets with
|
|
61
|
-
* {@link layer}
|
|
62
|
-
* - Connect a client-only process to an existing socket cluster without
|
|
63
|
-
* starting a runner server
|
|
64
|
-
* - Use SQL-backed storage for durable multi-process clusters, `local` storage
|
|
65
|
-
* for short-lived development, or `byo` storage when the deployment owns the
|
|
66
|
-
* persistence boundary
|
|
67
|
-
* - Check runner health with socket pings or Kubernetes pod readiness through
|
|
68
|
-
* {@link layerK8sHttpClient}
|
|
69
|
-
*
|
|
70
|
-
* **Gotchas**
|
|
71
|
-
*
|
|
72
|
-
* - `runnerAddress` is the host and port advertised to other runners; set
|
|
73
|
-
* `runnerListenAddress` when the local bind address differs from the
|
|
74
|
-
* externally reachable address
|
|
75
|
-
* - The socket transport is point-to-point RPC, not cluster gossip: runner
|
|
76
|
-
* membership, shard ownership, and persisted delivery are coordinated through
|
|
77
|
-
* `RunnerStorage`, `MessageStorage`, and `RunnerHealth`
|
|
78
|
-
* - `clientOnly` does not start a socket server or receive shard assignments
|
|
79
|
-
* - Ping health checks use the same socket protocol, so unreachable ports,
|
|
80
|
-
* firewalls, or serialization mismatches can make a runner appear unhealthy
|
|
81
|
-
*
|
|
82
18
|
* @since 4.0.0
|
|
83
19
|
*/
|
|
84
20
|
export * as NodeClusterSocket from "./NodeClusterSocket.js";
|
|
85
21
|
/**
|
|
86
|
-
* Node.js platform Crypto service layer.
|
|
87
|
-
*
|
|
88
22
|
* @since 1.0.0
|
|
89
23
|
*/
|
|
90
24
|
export * as NodeCrypto from "./NodeCrypto.js";
|
|
91
25
|
/**
|
|
92
|
-
* Provides the Node.js `FileSystem` layer for Effect programs.
|
|
93
|
-
*
|
|
94
|
-
* Use this module when a Node application, CLI, script, or test needs to
|
|
95
|
-
* satisfy the `FileSystem` service with real filesystem access for reading and
|
|
96
|
-
* writing files, creating directories and temporary files, inspecting metadata,
|
|
97
|
-
* managing links, or watching paths for changes.
|
|
98
|
-
*
|
|
99
|
-
* This module only exposes the Node-backed layer; filesystem operations are
|
|
100
|
-
* accessed through the `FileSystem` service from `effect/FileSystem`. Provide
|
|
101
|
-
* `NodeFileSystem.layer` at the edge of the program, or use
|
|
102
|
-
* `NodeServices.layer` when you also want the standard Node path, stdio,
|
|
103
|
-
* terminal, and child process services. The implementation is shared with
|
|
104
|
-
* other Node-compatible platform packages, so optional services such as
|
|
105
|
-
* `FileSystem.WatchBackend` are honored when present; otherwise file watching
|
|
106
|
-
* follows Node's `node:fs.watch` behavior. Paths are interpreted by Node, so
|
|
107
|
-
* relative paths use the current working directory and platform path rules.
|
|
108
|
-
*
|
|
109
26
|
* @since 4.0.0
|
|
110
27
|
*/
|
|
111
28
|
export * as NodeFileSystem from "./NodeFileSystem.js";
|
|
112
29
|
/**
|
|
113
|
-
* Node.js implementations of the Effect `HttpClient`.
|
|
114
|
-
*
|
|
115
|
-
* This module provides the Node-specific layers and constructors for sending
|
|
116
|
-
* Effect HTTP client requests. It re-exports the fetch-based client for
|
|
117
|
-
* programs that want to use `globalThis.fetch`, provides an Undici-backed
|
|
118
|
-
* client for applications that need Undici dispatcher control, and provides a
|
|
119
|
-
* lower-level `node:http` / `node:https` client for integrations that need
|
|
120
|
-
* native Node agent configuration.
|
|
121
|
-
*
|
|
122
|
-
* Use these clients in server-side applications, CLIs, tests, and integrations
|
|
123
|
-
* where requests should participate in Effect resource management, interruption,
|
|
124
|
-
* streaming, and typed transport / decode errors. The Undici path sends each
|
|
125
|
-
* request through the current `Dispatcher`; `layerUndici` owns a scoped
|
|
126
|
-
* `Agent`, while `dispatcherLayerGlobal` uses Undici's process-global dispatcher
|
|
127
|
-
* without destroying it. The `node:http` path uses separate scoped HTTP and
|
|
128
|
-
* HTTPS agents, making it the right choice when native agent options such as
|
|
129
|
-
* TLS, proxy, keep-alive, or socket behavior need to be configured directly.
|
|
130
|
-
*
|
|
131
|
-
* The backends are not completely interchangeable. Fetch, Undici, and
|
|
132
|
-
* `node:http` expose different agent and dispatcher hooks, body implementations,
|
|
133
|
-
* abort behavior, upgrade support, and response body readers. This module
|
|
134
|
-
* converts Effect request bodies to the selected runtime representation:
|
|
135
|
-
* streams remain streaming, `FormData` may contribute generated content headers,
|
|
136
|
-
* and body read failures are reported as `HttpClientError` decode or transport
|
|
137
|
-
* errors.
|
|
138
|
-
*
|
|
139
30
|
* @since 4.0.0
|
|
140
31
|
*/
|
|
141
32
|
export * as NodeHttpClient from "./NodeHttpClient.js";
|
|
142
33
|
/**
|
|
143
|
-
* Utilities for adapting Node `http.IncomingMessage` values to the Effect HTTP
|
|
144
|
-
* incoming message interface used by the platform Node server and client
|
|
145
|
-
* implementations.
|
|
146
|
-
*
|
|
147
|
-
* This module is useful when code needs to keep access to Node's request or
|
|
148
|
-
* response object while also exposing Effect's typed headers, remote address,
|
|
149
|
-
* body decoders, and stream interface. The body helpers consume Node's readable
|
|
150
|
-
* stream, cache decoded text and array-buffer results, and honor the
|
|
151
|
-
* `HttpIncomingMessage.MaxBodySize` fiber ref. Prefer a single body access
|
|
152
|
-
* strategy per message: raw `stream` access is not cached, and Node request
|
|
153
|
-
* bodies cannot be replayed once the underlying stream has been consumed.
|
|
154
|
-
*
|
|
155
34
|
* @since 4.0.0
|
|
156
35
|
*/
|
|
157
36
|
export * as NodeHttpIncomingMessage from "./NodeHttpIncomingMessage.js";
|
|
158
37
|
/**
|
|
159
|
-
* Node.js implementation of the Effect HTTP platform service.
|
|
160
|
-
*
|
|
161
|
-
* This module connects the portable `HttpPlatform` file response helpers to
|
|
162
|
-
* Node runtime primitives. It is used by Node HTTP servers and static file
|
|
163
|
-
* handlers when returning local files, public assets, downloads, byte ranges,
|
|
164
|
-
* or Web `File` values as `HttpServerResponse` bodies.
|
|
165
|
-
*
|
|
166
|
-
* Path-based responses are served with `node:fs.createReadStream`; Web `File`
|
|
167
|
-
* responses are bridged with `Readable.fromWeb`. The implementation fills in
|
|
168
|
-
* `content-type` from `Mime`, falls back to `application/octet-stream`, and
|
|
169
|
-
* writes the `content-length` for the selected range or whole file. Node's
|
|
170
|
-
* stream `end` option is inclusive, so the platform converts Effect's half-open
|
|
171
|
-
* range before reading. Empty bodies use an empty readable stream.
|
|
172
|
-
*
|
|
173
|
-
* Provide `layer` at the Node runtime edge when file responses, static serving,
|
|
174
|
-
* or response bodies created from files need real filesystem and ETag support.
|
|
175
|
-
* These responses are raw Node streams, so they are intended for the Node HTTP
|
|
176
|
-
* server adapter; keep files available until the response body has been
|
|
177
|
-
* consumed and prefer the portable `HttpServerResponse` constructors when a
|
|
178
|
-
* response does not depend on Node file or stream behavior.
|
|
179
|
-
*
|
|
180
38
|
* @since 4.0.0
|
|
181
39
|
*/
|
|
182
40
|
export * as NodeHttpPlatform from "./NodeHttpPlatform.js";
|
|
183
41
|
/**
|
|
184
|
-
* Node.js implementation of the Effect `HttpServer`.
|
|
185
|
-
*
|
|
186
|
-
* This module adapts a supplied Node `http.Server` into Effect's
|
|
187
|
-
* platform-independent HTTP server service. It starts the server with Node
|
|
188
|
-
* `listen` options, converts `request` events into `HttpServerRequest` values,
|
|
189
|
-
* writes `HttpServerResponse` bodies through Node's `ServerResponse`, and
|
|
190
|
-
* handles `upgrade` events by exposing the upgraded socket through
|
|
191
|
-
* `HttpServerRequest.upgrade`.
|
|
192
|
-
*
|
|
193
|
-
* Common use cases include serving an Effect HTTP application with {@link layer}
|
|
194
|
-
* or {@link layerConfig}, embedding request or upgrade handlers into an
|
|
195
|
-
* existing Node server with {@link makeHandler} and {@link makeUpgradeHandler},
|
|
196
|
-
* and using {@link layerTest} for integration tests that need an ephemeral
|
|
197
|
-
* listening port and a client pointed at it.
|
|
198
|
-
*
|
|
199
|
-
* Listen options are passed directly to Node, so host, port, backlog, and Unix
|
|
200
|
-
* socket path behavior follow `node:http`. The server begins listening when the
|
|
201
|
-
* `HttpServer` is acquired, and handlers are installed when `serve` is run.
|
|
202
|
-
* Request fibers are interrupted with `ClientAbort` when the client disconnects
|
|
203
|
-
* before a response finishes. WebSocket support only applies to Node `upgrade`
|
|
204
|
-
* requests, and ordinary HTTP requests fail if their application attempts to use
|
|
205
|
-
* `HttpServerRequest.upgrade`.
|
|
206
|
-
*
|
|
207
|
-
* Scope ownership is important: the server is closed when the acquiring scope
|
|
208
|
-
* finalizes, while each `serve` call installs its own request and upgrade
|
|
209
|
-
* listeners and removes them on finalization. Unless preemptive shutdown is
|
|
210
|
-
* disabled, finalizing a serve scope also starts a graceful server close, using
|
|
211
|
-
* the configured timeout or the default timeout.
|
|
212
|
-
*
|
|
213
42
|
* @since 4.0.0
|
|
214
43
|
*/
|
|
215
44
|
export * as NodeHttpServer from "./NodeHttpServer.js";
|
|
216
45
|
/**
|
|
217
|
-
* Accessors for the Node.js objects backing a platform Node
|
|
218
|
-
* `HttpServerRequest`.
|
|
219
|
-
*
|
|
220
|
-
* Use this module at interop boundaries when an Effect HTTP handler needs the
|
|
221
|
-
* original `http.IncomingMessage` or `http.ServerResponse` for APIs that are
|
|
222
|
-
* specific to Node, such as existing middleware, socket inspection, raw stream
|
|
223
|
-
* piping, or response customization that cannot be expressed with the portable
|
|
224
|
-
* `HttpServerRequest` and `HttpServerResponse` interfaces.
|
|
225
|
-
*
|
|
226
|
-
* The returned request is the original Node request supplied to the server. It
|
|
227
|
-
* does not reflect Effect request overrides made by middleware, such as a
|
|
228
|
-
* rewritten URL, adjusted headers, or a substituted remote address. Its body is
|
|
229
|
-
* also Node's one-shot readable stream, so avoid mixing raw stream consumption
|
|
230
|
-
* with Effect body, multipart, or stream helpers unless ownership of the body
|
|
231
|
-
* is clear. The returned response is the Node response owned by the platform
|
|
232
|
-
* server; writing to it directly bypasses the usual Effect response writer and
|
|
233
|
-
* must be coordinated carefully to avoid duplicate writes. Upgrade requests may
|
|
234
|
-
* create that response lazily when it is first requested.
|
|
235
|
-
*
|
|
236
46
|
* @since 4.0.0
|
|
237
47
|
*/
|
|
238
48
|
export * as NodeHttpServerRequest from "./NodeHttpServerRequest.js";
|
|
239
49
|
/**
|
|
240
|
-
* Node-specific helpers for parsing HTTP `multipart/form-data` request bodies.
|
|
241
|
-
*
|
|
242
|
-
* This module adapts a Node `Readable` request body plus its incoming headers
|
|
243
|
-
* into the shared `Multipart` model. Use `stream` when an HTTP server route
|
|
244
|
-
* wants to handle form fields and uploaded files incrementally, for example API
|
|
245
|
-
* endpoints that validate text fields while piping file parts to storage. Use
|
|
246
|
-
* `persisted` when the whole form should be collected into a record and uploaded
|
|
247
|
-
* files should be written into scoped temporary files through the current
|
|
248
|
-
* `FileSystem` and `Path` services.
|
|
249
|
-
*
|
|
250
|
-
* Node request bodies are one-shot streams, so consume either `stream` or
|
|
251
|
-
* `persisted`, and make sure file parts are drained, piped, or otherwise
|
|
252
|
-
* deliberately handled. `contentEffect` loads a file into memory and should be
|
|
253
|
-
* reserved for small uploads. Persisted paths live only for the surrounding
|
|
254
|
-
* `Scope`, and filenames supplied by clients should be treated as metadata, not
|
|
255
|
-
* trusted filesystem paths.
|
|
256
|
-
*
|
|
257
50
|
* @since 4.0.0
|
|
258
51
|
*/
|
|
259
52
|
export * as NodeMultipart from "./NodeMultipart.js";
|
|
260
53
|
/**
|
|
261
|
-
* Node.js layers for Effect's `Path` service.
|
|
262
|
-
*
|
|
263
|
-
* Use this module when an Effect program running on Node needs path operations
|
|
264
|
-
* from the `Path` service, such as joining and normalizing filesystem
|
|
265
|
-
* locations, resolving configuration or static asset paths, working with CLI
|
|
266
|
-
* path arguments, or converting between file paths and `file:` URLs.
|
|
267
|
-
*
|
|
268
|
-
* `layer` follows the host platform's `node:path` semantics. Use `layerPosix`
|
|
269
|
-
* or `layerWin32` when code needs stable POSIX or Windows behavior regardless
|
|
270
|
-
* of the operating system. These layers provide only path manipulation; they do
|
|
271
|
-
* not read the filesystem or validate that paths exist. `NodeServices.layer`
|
|
272
|
-
* already includes the default Node path layer, so provide this module directly
|
|
273
|
-
* when you want the narrower service or one of the platform-specific variants.
|
|
274
|
-
*
|
|
275
54
|
* @since 4.0.0
|
|
276
55
|
*/
|
|
277
56
|
export * as NodePath from "./NodePath.js";
|
|
278
57
|
/**
|
|
279
|
-
* Node.js Redis integration backed by `ioredis`.
|
|
280
|
-
*
|
|
281
|
-
* This module provides scoped layers that create an `ioredis` client and expose
|
|
282
|
-
* both the low-level `Redis` service used by Effect persistence modules and the
|
|
283
|
-
* `NodeRedis` service for direct access to the underlying client. It is useful
|
|
284
|
-
* for Node applications that want Redis-backed persistence, persisted queues,
|
|
285
|
-
* distributed rate limiting, or custom Redis commands alongside the Effect
|
|
286
|
-
* services that build on Redis.
|
|
287
|
-
*
|
|
288
|
-
* The client is acquired when the layer is built and closed with `quit` when
|
|
289
|
-
* the layer scope ends, so install the layer at the lifetime you want for the
|
|
290
|
-
* connection and pass `ioredis` options, or `layerConfig`, for connection,
|
|
291
|
-
* TLS, database, retry, and reconnect settings. Persistence and rate limiter
|
|
292
|
-
* stores build their own keys and Lua scripts on top of this service; choose
|
|
293
|
-
* stable prefixes and store ids to avoid collisions, account for persisted
|
|
294
|
-
* values that may fail to decode after schema changes, and avoid unbounded
|
|
295
|
-
* high-cardinality rate-limit keys unless you have a cleanup or bounding
|
|
296
|
-
* strategy.
|
|
297
|
-
*
|
|
298
58
|
* @since 4.0.0
|
|
299
59
|
*/
|
|
300
60
|
export * as NodeRedis from "./NodeRedis.js";
|
|
301
61
|
/**
|
|
302
|
-
* Node.js entry-point helpers for running Effect programs.
|
|
303
|
-
*
|
|
304
|
-
* This module exposes `runMain`, the Node runtime launcher used at the edge of
|
|
305
|
-
* CLI tools, scripts, servers, and worker processes. It runs an already
|
|
306
|
-
* self-contained Effect as the process main program, with built-in error
|
|
307
|
-
* reporting and Node signal handling.
|
|
308
|
-
*
|
|
309
|
-
* `NodeRuntime` does not provide application services by itself. Provide any
|
|
310
|
-
* required layers, such as `NodeServices.layer` or narrower service-specific
|
|
311
|
-
* layers, before passing the effect to `runMain`. On `SIGINT` or `SIGTERM`,
|
|
312
|
-
* the main fiber is interrupted so scoped resources and finalizers can shut
|
|
313
|
-
* down; keep long-running work attached to that scope and avoid finalizers that
|
|
314
|
-
* never complete, otherwise process shutdown can be delayed.
|
|
315
|
-
*
|
|
316
62
|
* @since 4.0.0
|
|
317
63
|
*/
|
|
318
64
|
export * as NodeRuntime from "./NodeRuntime.js";
|
|
319
65
|
/**
|
|
320
|
-
* Provides the aggregate Node platform services layer for applications that run
|
|
321
|
-
* on the Node.js runtime.
|
|
322
|
-
*
|
|
323
|
-
* This module is useful when an application needs the standard Node-backed
|
|
324
|
-
* implementations of filesystem access, path operations, stdio, terminal
|
|
325
|
-
* interaction, and child process spawning from a single layer. Provide
|
|
326
|
-
* `NodeServices.layer` near the edge of a program to satisfy effects that read
|
|
327
|
-
* or write files, resolve paths, interact with stdin/stdout/stderr or a
|
|
328
|
-
* terminal, or launch subprocesses.
|
|
329
|
-
*
|
|
330
|
-
* The layer only supplies the runtime services listed by `NodeServices`; it does
|
|
331
|
-
* not provide unrelated platform services such as HTTP clients or servers.
|
|
332
|
-
* Libraries should continue to depend on the individual service tags they use,
|
|
333
|
-
* while applications, CLIs, and tests can choose this layer or narrower
|
|
334
|
-
* service-specific layers depending on how much of the Node runtime they want to
|
|
335
|
-
* expose.
|
|
336
|
-
*
|
|
337
66
|
* @since 4.0.0
|
|
338
67
|
*/
|
|
339
68
|
export * as NodeServices from "./NodeServices.js";
|
|
@@ -342,23 +71,6 @@ export * as NodeServices from "./NodeServices.js";
|
|
|
342
71
|
*/
|
|
343
72
|
export * as NodeSink from "./NodeSink.js";
|
|
344
73
|
/**
|
|
345
|
-
* Node platform socket entry point for Effect sockets backed by Node streams
|
|
346
|
-
* and WebSocket implementations.
|
|
347
|
-
*
|
|
348
|
-
* This module re-exports the shared Node socket constructors for TCP clients,
|
|
349
|
-
* Unix domain socket clients, and adapters from existing Node `Duplex` streams,
|
|
350
|
-
* then adds Node-specific WebSocket constructor layers. Use it when connecting
|
|
351
|
-
* to raw socket protocols, wiring RPC transports over TCP or Unix sockets, or
|
|
352
|
-
* opening WebSocket clients in Node.
|
|
353
|
-
*
|
|
354
|
-
* TCP and Unix socket behavior comes from the shared Node layer: Unix sockets
|
|
355
|
-
* are selected with `NetConnectOpts.path`, scoped sockets close or destroy the
|
|
356
|
-
* underlying stream on finalization, and Node open, read, write, and close
|
|
357
|
-
* events are translated into `SocketError` values. For WebSockets,
|
|
358
|
-
* `layerWebSocketConstructor` prefers `globalThis.WebSocket` when available
|
|
359
|
-
* and falls back to `ws`; use `layerWebSocketConstructorWS` when you need the
|
|
360
|
-
* `ws` implementation consistently across Node versions.
|
|
361
|
-
*
|
|
362
74
|
* @since 4.0.0
|
|
363
75
|
*/
|
|
364
76
|
export * as NodeSocket from "./NodeSocket.js";
|
|
@@ -367,22 +79,6 @@ export * as NodeSocket from "./NodeSocket.js";
|
|
|
367
79
|
*/
|
|
368
80
|
export * as NodeSocketServer from "./NodeSocketServer.js";
|
|
369
81
|
/**
|
|
370
|
-
* Node.js implementation of the Effect `Stdio` service.
|
|
371
|
-
*
|
|
372
|
-
* This module exposes a layer that connects `Stdio` to the current process:
|
|
373
|
-
* command-line arguments come from `process.argv`, input is read from
|
|
374
|
-
* `process.stdin`, and output and error output write to `process.stdout` and
|
|
375
|
-
* `process.stderr`. It is intended for CLIs, scripts, command runners, and
|
|
376
|
-
* other process-oriented programs that need standard input and output through
|
|
377
|
-
* Effect services.
|
|
378
|
-
*
|
|
379
|
-
* The underlying streams are owned by the Node process. The layer keeps stdin
|
|
380
|
-
* open and does not end stdout or stderr when a stream finishes, which avoids
|
|
381
|
-
* closing global process handles that other code may still use. Be mindful that
|
|
382
|
-
* stdio may be a pipe, file, or TTY, so terminal-specific behavior such as raw
|
|
383
|
-
* mode, echo, colors, and cursor control should be handled with the terminal
|
|
384
|
-
* APIs instead of assuming an interactive console.
|
|
385
|
-
*
|
|
386
82
|
* @since 4.0.0
|
|
387
83
|
*/
|
|
388
84
|
export * as NodeStdio from "./NodeStdio.js";
|
|
@@ -391,60 +87,14 @@ export * as NodeStdio from "./NodeStdio.js";
|
|
|
391
87
|
*/
|
|
392
88
|
export * as NodeStream from "./NodeStream.js";
|
|
393
89
|
/**
|
|
394
|
-
* Provides the Node.js `Terminal` service for interactive command-line
|
|
395
|
-
* programs, prompts, and tools that need to read lines, react to key presses,
|
|
396
|
-
* write to stdout, or inspect terminal dimensions.
|
|
397
|
-
*
|
|
398
|
-
* The implementation is backed by the current process' stdin and stdout. When
|
|
399
|
-
* stdin is a TTY, key input temporarily enables raw mode for the scope of the
|
|
400
|
-
* service, so callers should acquire it with a scope or use the provided layer
|
|
401
|
-
* to ensure terminal state is restored. In non-TTY environments, terminal
|
|
402
|
-
* dimensions may be reported as zero and raw-mode key handling is unavailable.
|
|
403
|
-
*
|
|
404
90
|
* @since 4.0.0
|
|
405
91
|
*/
|
|
406
92
|
export * as NodeTerminal from "./NodeTerminal.js";
|
|
407
93
|
/**
|
|
408
|
-
* Parent-side Node.js support for Effect workers.
|
|
409
|
-
*
|
|
410
|
-
* This module provides the `WorkerPlatform` used by Node programs that spawn
|
|
411
|
-
* and communicate with `node:worker_threads` workers or IPC-enabled child
|
|
412
|
-
* processes through Effect's worker protocol. Pair it with `NodeWorkerRunner`
|
|
413
|
-
* in the worker entrypoint when building worker-backed RPC clients, offloading
|
|
414
|
-
* CPU-bound work, isolating Node resources, or hosting services that should
|
|
415
|
-
* exchange typed messages with the parent process.
|
|
416
|
-
*
|
|
417
|
-
* Worker-thread spawners can use `postMessage` transfer lists for values such
|
|
418
|
-
* as `ArrayBuffer` and `MessagePort`, but transferring moves ownership and
|
|
419
|
-
* invalid transfer lists surface as worker send or receive failures.
|
|
420
|
-
* Child-process spawners must provide an IPC channel, for example via
|
|
421
|
-
* `child_process.fork` or `stdio: "ipc"`; their messages use Node IPC
|
|
422
|
-
* serialization and this module does not forward transfer lists to
|
|
423
|
-
* `ChildProcess.send`. Scope finalization sends the worker close signal and
|
|
424
|
-
* waits for exit before falling back to `terminate()` or `SIGKILL`.
|
|
425
|
-
*
|
|
426
94
|
* @since 4.0.0
|
|
427
95
|
*/
|
|
428
96
|
export * as NodeWorker from "./NodeWorker.js";
|
|
429
97
|
/**
|
|
430
|
-
* Runtime support for Effect workers that are executed by Node.js.
|
|
431
|
-
*
|
|
432
|
-
* This module is intended to be installed in the program running inside a
|
|
433
|
-
* `node:worker_threads` worker or an IPC-enabled child process. It provides the
|
|
434
|
-
* `WorkerRunnerPlatform` used by `WorkerRunner` to receive request messages
|
|
435
|
-
* from the parent, run the registered Effect handler, and send responses back
|
|
436
|
-
* over the parent channel.
|
|
437
|
-
*
|
|
438
|
-
* Use it when the parent side is created with `NodeWorker` and the worker code
|
|
439
|
-
* needs to perform CPU-bound work, isolate Node resources, or host services that
|
|
440
|
-
* should communicate through the Effect worker protocol. The runner must be
|
|
441
|
-
* started from an actual worker context: `parentPort` is required for worker
|
|
442
|
-
* threads, while child processes must be spawned with an IPC channel so
|
|
443
|
-
* `process.send` is available. Transfer lists only apply to worker-thread
|
|
444
|
-
* `postMessage`; child-process messages go through Node IPC serialization.
|
|
445
|
-
* Shutdown is coordinated by the parent message protocol, so long-running
|
|
446
|
-
* handlers should remain interruptible and keep resource cleanup in scopes.
|
|
447
|
-
*
|
|
448
98
|
* @since 4.0.0
|
|
449
99
|
*/
|
|
450
100
|
export * as NodeWorkerRunner from "./NodeWorkerRunner.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Mime","NodeChildProcessSpawner","NodeClusterHttp","NodeClusterSocket","NodeCrypto","NodeFileSystem","NodeHttpClient","NodeHttpIncomingMessage","NodeHttpPlatform","NodeHttpServer","NodeHttpServerRequest","NodeMultipart","NodePath","NodeRedis","NodeRuntime","NodeServices","NodeSink","NodeSocket","NodeSocketServer","NodeStdio","NodeStream","NodeTerminal","NodeWorker","NodeWorkerRunner","Undici"],"sources":["../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAIA;AAEA;;;AAGA,OAAO,KAAKA,IAAI,MAAM,WAAW;AAEjC
|
|
1
|
+
{"version":3,"file":"index.js","names":["Mime","NodeChildProcessSpawner","NodeClusterHttp","NodeClusterSocket","NodeCrypto","NodeFileSystem","NodeHttpClient","NodeHttpIncomingMessage","NodeHttpPlatform","NodeHttpServer","NodeHttpServerRequest","NodeMultipart","NodePath","NodeRedis","NodeRuntime","NodeServices","NodeSink","NodeSocket","NodeSocketServer","NodeStdio","NodeStream","NodeTerminal","NodeWorker","NodeWorkerRunner","Undici"],"sources":["../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAIA;AAEA;;;AAGA,OAAO,KAAKA,IAAI,MAAM,WAAW;AAEjC;;;AAGA,OAAO,KAAKC,uBAAuB,MAAM,8BAA8B;AAEvE;;;AAGA,OAAO,KAAKC,eAAe,MAAM,sBAAsB;AAEvD;;;AAGA,OAAO,KAAKC,iBAAiB,MAAM,wBAAwB;AAE3D;;;AAGA,OAAO,KAAKC,UAAU,MAAM,iBAAiB;AAE7C;;;AAGA,OAAO,KAAKC,cAAc,MAAM,qBAAqB;AAErD;;;AAGA,OAAO,KAAKC,cAAc,MAAM,qBAAqB;AAErD;;;AAGA,OAAO,KAAKC,uBAAuB,MAAM,8BAA8B;AAEvE;;;AAGA,OAAO,KAAKC,gBAAgB,MAAM,uBAAuB;AAEzD;;;AAGA,OAAO,KAAKC,cAAc,MAAM,qBAAqB;AAErD;;;AAGA,OAAO,KAAKC,qBAAqB,MAAM,4BAA4B;AAEnE;;;AAGA,OAAO,KAAKC,aAAa,MAAM,oBAAoB;AAEnD;;;AAGA,OAAO,KAAKC,QAAQ,MAAM,eAAe;AAEzC;;;AAGA,OAAO,KAAKC,SAAS,MAAM,gBAAgB;AAE3C;;;AAGA,OAAO,KAAKC,WAAW,MAAM,kBAAkB;AAE/C;;;AAGA,OAAO,KAAKC,YAAY,MAAM,mBAAmB;AAEjD;;;AAGA,OAAO,KAAKC,QAAQ,MAAM,eAAe;AAEzC;;;AAGA,OAAO,KAAKC,UAAU,MAAM,iBAAiB;AAE7C;;;AAGA,OAAO,KAAKC,gBAAgB,MAAM,uBAAuB;AAEzD;;;AAGA,OAAO,KAAKC,SAAS,MAAM,gBAAgB;AAE3C;;;AAGA,OAAO,KAAKC,UAAU,MAAM,iBAAiB;AAE7C;;;AAGA,OAAO,KAAKC,YAAY,MAAM,mBAAmB;AAEjD;;;AAGA,OAAO,KAAKC,UAAU,MAAM,iBAAiB;AAE7C;;;AAGA,OAAO,KAAKC,gBAAgB,MAAM,uBAAuB;AAEzD;;;AAGA,OAAO,KAAKC,MAAM,MAAM,aAAa","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect/platform-node",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.0-beta.
|
|
4
|
+
"version": "4.0.0-beta.71",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Platform specific implementations for the Node.js runtime",
|
|
7
7
|
"homepage": "https://effect.website",
|
|
@@ -50,18 +50,18 @@
|
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"mime": "^4.1.0",
|
|
52
52
|
"undici": "^8.2.0",
|
|
53
|
-
"@effect/platform-node-shared": "^4.0.0-beta.
|
|
53
|
+
"@effect/platform-node-shared": "^4.0.0-beta.71"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"ioredis": "^5.7.0",
|
|
57
|
-
"effect": "^4.0.0-beta.
|
|
57
|
+
"effect": "^4.0.0-beta.71"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@testcontainers/mysql": "^11.14.0",
|
|
61
61
|
"@testcontainers/postgresql": "^11.14.0",
|
|
62
62
|
"@testcontainers/redis": "^11.14.0",
|
|
63
63
|
"@types/node": "^25.7.0",
|
|
64
|
-
"effect": "^4.0.0-beta.
|
|
64
|
+
"effect": "^4.0.0-beta.71"
|
|
65
65
|
},
|
|
66
66
|
"scripts": {
|
|
67
67
|
"codegen": "effect-utils codegen",
|
package/src/Mime.ts
CHANGED
package/src/NodeCrypto.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Node.js
|
|
2
|
+
* The `NodeCrypto` module provides the Node.js `Crypto` service layer for
|
|
3
|
+
* Effect programs. Provide {@link layer} at the edge of a Node application,
|
|
4
|
+
* CLI, script, or test to satisfy `effect/Crypto` with Node's `node:crypto`
|
|
5
|
+
* implementation for secure random bytes, UUID generation, random values, and
|
|
6
|
+
* SHA digest operations.
|
|
7
|
+
*
|
|
8
|
+
* This module is the public Node adapter around the shared Node-compatible
|
|
9
|
+
* implementation. Digest failures are reported as platform errors, and SHA-1
|
|
10
|
+
* remains available only for interoperability with existing protocols.
|
|
3
11
|
*
|
|
4
12
|
* @since 1.0.0
|
|
5
13
|
*/
|
package/src/NodeFileSystem.ts
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Node.js `FileSystem` layer for programs that perform real filesystem I/O.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* The exported layer satisfies the platform-independent `FileSystem` service
|
|
5
|
+
* with Node-backed operations for files, directories, metadata, permissions,
|
|
6
|
+
* links, temporary paths, and path watching. Effects still call the service from
|
|
7
|
+
* `effect/FileSystem`; this module only chooses the Node implementation.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* `NodeFileSystem.layer` at the
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* `FileSystem
|
|
16
|
-
*
|
|
17
|
-
*
|
|
9
|
+
* **Mental model**
|
|
10
|
+
*
|
|
11
|
+
* Provide `NodeFileSystem.layer` at the process boundary when filesystem
|
|
12
|
+
* effects should touch the host filesystem. Use `NodeServices.layer` instead
|
|
13
|
+
* when the same program also needs the standard Node path, stdio, terminal,
|
|
14
|
+
* crypto, and child process services. Tests that need isolation can provide a
|
|
15
|
+
* different `FileSystem` layer without changing the code that performs the
|
|
16
|
+
* reads and writes.
|
|
17
|
+
*
|
|
18
|
+
* **Gotchas**
|
|
19
|
+
*
|
|
20
|
+
* Paths are interpreted by Node, so relative paths resolve against the current
|
|
21
|
+
* working directory and platform-specific path rules apply. Filesystem failures
|
|
22
|
+
* are reported through Effect platform errors rather than thrown exceptions.
|
|
23
|
+
* File watching uses `FileSystem.WatchBackend` when one is available; otherwise
|
|
24
|
+
* it follows `node:fs.watch`, whose recursive support, event batching, and
|
|
25
|
+
* reported path names vary across operating systems.
|
|
18
26
|
*
|
|
19
27
|
* @since 4.0.0
|
|
20
28
|
*/
|
package/src/NodeHttpClient.ts
CHANGED
|
@@ -1,28 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Node.js implementations of the Effect `HttpClient`.
|
|
3
3
|
*
|
|
4
|
-
* This module
|
|
5
|
-
* Effect HTTP client
|
|
6
|
-
*
|
|
7
|
-
* client for
|
|
8
|
-
* lower-level `node:http` / `node:https` client for integrations that need
|
|
9
|
-
* native Node agent configuration.
|
|
4
|
+
* This module supplies Node runtime backends for the platform-independent
|
|
5
|
+
* Effect HTTP client API. It re-exports the fetch-based client, defines an
|
|
6
|
+
* Undici-backed client, and defines a lower-level `node:http` / `node:https`
|
|
7
|
+
* client for integrations that need native agent configuration.
|
|
10
8
|
*
|
|
11
|
-
*
|
|
12
|
-
* where requests should participate in Effect resource management, interruption,
|
|
13
|
-
* streaming, and typed transport / decode errors. The Undici path sends each
|
|
14
|
-
* request through the current `Dispatcher`; `layerUndici` owns a scoped
|
|
15
|
-
* `Agent`, while `dispatcherLayerGlobal` uses Undici's process-global dispatcher
|
|
16
|
-
* without destroying it. The `node:http` path uses separate scoped HTTP and
|
|
17
|
-
* HTTPS agents, making it the right choice when native agent options such as
|
|
18
|
-
* TLS, proxy, keep-alive, or socket behavior need to be configured directly.
|
|
9
|
+
* **Mental model**
|
|
19
10
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
11
|
+
* All backends provide the same `HttpClient` service, so application code can
|
|
12
|
+
* depend on the Effect HTTP client interface while the layer chooses the Node
|
|
13
|
+
* implementation. The difference is where request execution and connection
|
|
14
|
+
* ownership live: fetch uses `globalThis.fetch`, Undici sends through a
|
|
15
|
+
* `Dispatcher`, and the `node:http` backend sends through scoped HTTP and HTTPS
|
|
16
|
+
* agents.
|
|
17
|
+
*
|
|
18
|
+
* **Common tasks**
|
|
19
|
+
*
|
|
20
|
+
* Use `layerFetch` when the built-in fetch implementation is enough. Use
|
|
21
|
+
* `layerUndici` for a scoped Undici `Agent`, or `layerUndiciNoDispatcher` when
|
|
22
|
+
* the caller provides the `Dispatcher` service, including the process-global
|
|
23
|
+
* dispatcher from `dispatcherLayerGlobal`. Use `layerNodeHttp` or
|
|
24
|
+
* `layerAgentOptions` when TLS, proxy, keep-alive, socket, or other native
|
|
25
|
+
* Node agent options must be configured directly.
|
|
26
|
+
*
|
|
27
|
+
* **Gotchas**
|
|
28
|
+
*
|
|
29
|
+
* Fetch, Undici, and `node:http` are not exact substitutes. They differ in
|
|
30
|
+
* dispatcher and agent hooks, request body support, abort behavior, upgrade
|
|
31
|
+
* support, and response body readers. Scoped layers destroy the agents or
|
|
32
|
+
* dispatchers they create when the layer scope ends; `dispatcherLayerGlobal`
|
|
33
|
+
* intentionally does not own or destroy Undici's process-global dispatcher.
|
|
34
|
+
* Body read failures are reported as `HttpClientError` decode or transport
|
|
26
35
|
* errors.
|
|
27
36
|
*
|
|
28
37
|
* @since 4.0.0
|
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* incoming
|
|
4
|
-
* implementations.
|
|
2
|
+
* Adapter base for exposing Node `http.IncomingMessage` values as Effect HTTP
|
|
3
|
+
* incoming messages.
|
|
5
4
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
5
|
+
* Server requests and Node client responses both arrive as Node readable
|
|
6
|
+
* streams with raw header objects, socket metadata, and one-shot body
|
|
7
|
+
* consumption. This module's `NodeHttpIncomingMessage` class keeps the original
|
|
8
|
+
* Node message available while presenting Effect's `HttpIncomingMessage` shape:
|
|
9
|
+
* typed headers, remote address lookup, stream access, and text, JSON,
|
|
10
|
+
* URL-encoded, and array-buffer body readers.
|
|
11
|
+
*
|
|
12
|
+
* **Mental model**
|
|
13
|
+
*
|
|
14
|
+
* The Node message remains the source of truth. The adapter translates headers
|
|
15
|
+
* and remote address on demand, delegates raw streaming to `NodeStream`, and
|
|
16
|
+
* lets subclasses choose how unknown Node errors are mapped into their HTTP
|
|
17
|
+
* error type.
|
|
18
|
+
*
|
|
19
|
+
* **Gotchas**
|
|
20
|
+
*
|
|
21
|
+
* Node request and response bodies are one-shot streams. The `text` and
|
|
22
|
+
* `arrayBuffer` readers are cached and share decoded values with each other,
|
|
23
|
+
* but direct `stream` access is not cached and can consume the underlying Node
|
|
24
|
+
* stream before a decoder reads it. Body readers honor
|
|
25
|
+
* `HttpIncomingMessage.MaxBodySize`.
|
|
13
26
|
*
|
|
14
27
|
* @since 4.0.0
|
|
15
28
|
*/
|