@effect/platform-node 4.0.0-beta.70 → 4.0.0-beta.72

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 (81) hide show
  1. package/dist/Mime.d.ts +6 -0
  2. package/dist/Mime.d.ts.map +1 -1
  3. package/dist/Mime.js +6 -0
  4. package/dist/Mime.js.map +1 -1
  5. package/dist/NodeCrypto.d.ts +1 -1
  6. package/dist/NodeCrypto.d.ts.map +1 -1
  7. package/dist/NodeCrypto.js +10 -2
  8. package/dist/NodeCrypto.js.map +1 -1
  9. package/dist/NodeFileSystem.d.ts.map +1 -1
  10. package/dist/NodeFileSystem.js +22 -14
  11. package/dist/NodeFileSystem.js.map +1 -1
  12. package/dist/NodeHttpClient.d.ts +44 -26
  13. package/dist/NodeHttpClient.d.ts.map +1 -1
  14. package/dist/NodeHttpClient.js +42 -24
  15. package/dist/NodeHttpClient.js.map +1 -1
  16. package/dist/NodeHttpIncomingMessage.d.ts +35 -14
  17. package/dist/NodeHttpIncomingMessage.d.ts.map +1 -1
  18. package/dist/NodeHttpIncomingMessage.js +34 -13
  19. package/dist/NodeHttpIncomingMessage.js.map +1 -1
  20. package/dist/NodeHttpServerRequest.d.ts +2 -2
  21. package/dist/NodeHttpServerRequest.js +2 -2
  22. package/dist/NodeMultipart.d.ts +31 -16
  23. package/dist/NodeMultipart.d.ts.map +1 -1
  24. package/dist/NodeMultipart.js +29 -14
  25. package/dist/NodeMultipart.js.map +1 -1
  26. package/dist/NodePath.d.ts.map +1 -1
  27. package/dist/NodePath.js +24 -11
  28. package/dist/NodePath.js.map +1 -1
  29. package/dist/NodeRedis.d.ts +34 -16
  30. package/dist/NodeRedis.d.ts.map +1 -1
  31. package/dist/NodeRedis.js +33 -15
  32. package/dist/NodeRedis.js.map +1 -1
  33. package/dist/NodeRuntime.d.ts +3 -3
  34. package/dist/NodeRuntime.d.ts.map +1 -1
  35. package/dist/NodeRuntime.js +26 -12
  36. package/dist/NodeRuntime.js.map +1 -1
  37. package/dist/NodeServices.d.ts +31 -16
  38. package/dist/NodeServices.d.ts.map +1 -1
  39. package/dist/NodeServices.js.map +1 -1
  40. package/dist/NodeSocket.d.ts.map +1 -1
  41. package/dist/NodeSocket.js +31 -16
  42. package/dist/NodeSocket.js.map +1 -1
  43. package/dist/NodeStdio.d.ts.map +1 -1
  44. package/dist/NodeStdio.js +21 -13
  45. package/dist/NodeStdio.js.map +1 -1
  46. package/dist/NodeTerminal.d.ts.map +1 -1
  47. package/dist/NodeTerminal.js +18 -8
  48. package/dist/NodeTerminal.js.map +1 -1
  49. package/dist/NodeWorker.d.ts.map +1 -1
  50. package/dist/NodeWorker.js +28 -14
  51. package/dist/NodeWorker.js.map +1 -1
  52. package/dist/NodeWorkerRunner.d.ts.map +1 -1
  53. package/dist/NodeWorkerRunner.js +35 -15
  54. package/dist/NodeWorkerRunner.js.map +1 -1
  55. package/dist/Undici.d.ts +13 -0
  56. package/dist/Undici.d.ts.map +1 -1
  57. package/dist/Undici.js +13 -0
  58. package/dist/Undici.js.map +1 -1
  59. package/dist/index.d.ts +0 -350
  60. package/dist/index.d.ts.map +1 -1
  61. package/dist/index.js +0 -350
  62. package/dist/index.js.map +1 -1
  63. package/package.json +4 -4
  64. package/src/Mime.ts +7 -0
  65. package/src/NodeCrypto.ts +10 -2
  66. package/src/NodeFileSystem.ts +22 -14
  67. package/src/NodeHttpClient.ts +42 -24
  68. package/src/NodeHttpIncomingMessage.ts +34 -13
  69. package/src/NodeHttpServerRequest.ts +2 -2
  70. package/src/NodeMultipart.ts +29 -14
  71. package/src/NodePath.ts +24 -11
  72. package/src/NodeRedis.ts +33 -15
  73. package/src/NodeRuntime.ts +28 -14
  74. package/src/NodeServices.ts +31 -16
  75. package/src/NodeSocket.ts +29 -14
  76. package/src/NodeStdio.ts +21 -13
  77. package/src/NodeTerminal.ts +18 -8
  78. package/src/NodeWorker.ts +28 -14
  79. package/src/NodeWorkerRunner.ts +35 -15
  80. package/src/Undici.ts +13 -0
  81. 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;;;;;AAKA,OAAO,KAAKC,uBAAuB,MAAM,8BAA8B;AAEvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,OAAO,KAAKC,eAAe,MAAM,sBAAsB;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,OAAO,KAAKC,iBAAiB,MAAM,wBAAwB;AAE3D;;;;;AAKA,OAAO,KAAKC,UAAU,MAAM,iBAAiB;AAE7C;;;;;;;;;;;;;;;;;;;;AAoBA,OAAO,KAAKC,cAAc,MAAM,qBAAqB;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,OAAO,KAAKC,cAAc,MAAM,qBAAqB;AAErD;;;;;;;;;;;;;;;AAeA,OAAO,KAAKC,uBAAuB,MAAM,8BAA8B;AAEvE;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,OAAO,KAAKC,gBAAgB,MAAM,uBAAuB;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,OAAO,KAAKC,cAAc,MAAM,qBAAqB;AAErD;;;;;;;;;;;;;;;;;;;;;;AAsBA,OAAO,KAAKC,qBAAqB,MAAM,4BAA4B;AAEnE;;;;;;;;;;;;;;;;;;;;AAoBA,OAAO,KAAKC,aAAa,MAAM,oBAAoB;AAEnD;;;;;;;;;;;;;;;;;AAiBA,OAAO,KAAKC,QAAQ,MAAM,eAAe;AAEzC;;;;;;;;;;;;;;;;;;;;;;AAsBA,OAAO,KAAKC,SAAS,MAAM,gBAAgB;AAE3C;;;;;;;;;;;;;;;;;AAiBA,OAAO,KAAKC,WAAW,MAAM,kBAAkB;AAE/C;;;;;;;;;;;;;;;;;;;;AAoBA,OAAO,KAAKC,YAAY,MAAM,mBAAmB;AAEjD;;;AAGA,OAAO,KAAKC,QAAQ,MAAM,eAAe;AAEzC;;;;;;;;;;;;;;;;;;;;AAoBA,OAAO,KAAKC,UAAU,MAAM,iBAAiB;AAE7C;;;AAGA,OAAO,KAAKC,gBAAgB,MAAM,uBAAuB;AAEzD;;;;;;;;;;;;;;;;;;;AAmBA,OAAO,KAAKC,SAAS,MAAM,gBAAgB;AAE3C;;;AAGA,OAAO,KAAKC,UAAU,MAAM,iBAAiB;AAE7C;;;;;;;;;;;;;AAaA,OAAO,KAAKC,YAAY,MAAM,mBAAmB;AAEjD;;;;;;;;;;;;;;;;;;;;;AAqBA,OAAO,KAAKC,UAAU,MAAM,iBAAiB;AAE7C;;;;;;;;;;;;;;;;;;;;;AAqBA,OAAO,KAAKC,gBAAgB,MAAM,uBAAuB;AAEzD;;;AAGA,OAAO,KAAKC,MAAM,MAAM,aAAa","ignoreList":[]}
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.70",
4
+ "version": "4.0.0-beta.72",
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.70"
53
+ "@effect/platform-node-shared": "^4.0.0-beta.72"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "ioredis": "^5.7.0",
57
- "effect": "^4.0.0-beta.70"
57
+ "effect": "^4.0.0-beta.72"
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.70"
64
+ "effect": "^4.0.0-beta.72"
65
65
  },
66
66
  "scripts": {
67
67
  "codegen": "effect-utils codegen",
package/src/Mime.ts CHANGED
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Re-exports the `mime` package through the `@effect/platform-node/Mime`
3
+ * module and the `Mime` namespace in the package barrel.
4
+ *
5
+ * @since 4.0.0
6
+ */
7
+
1
8
  /* oxlint-disable no-named-as-default */
2
9
 
3
10
  /**
package/src/NodeCrypto.ts CHANGED
@@ -1,5 +1,13 @@
1
1
  /**
2
- * Node.js platform Crypto service layer.
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
  */
@@ -8,7 +16,7 @@ import type * as Crypto from "effect/Crypto"
8
16
  import type * as Layer from "effect/Layer"
9
17
 
10
18
  /**
11
- * A layer that provides the Node.js Crypto service implementation.
19
+ * Layer that provides the Node.js Crypto service implementation.
12
20
  *
13
21
  * @category layers
14
22
  * @since 1.0.0
@@ -1,20 +1,28 @@
1
1
  /**
2
- * Provides the Node.js `FileSystem` layer for Effect programs.
2
+ * Node.js `FileSystem` layer for programs that perform real filesystem I/O.
3
3
  *
4
- * Use this module when a Node application, CLI, script, or test needs to
5
- * satisfy the `FileSystem` service with real filesystem access for reading and
6
- * writing files, creating directories and temporary files, inspecting metadata,
7
- * managing links, or watching paths for changes.
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
- * This module only exposes the Node-backed layer; filesystem operations are
10
- * accessed through the `FileSystem` service from `effect/FileSystem`. Provide
11
- * `NodeFileSystem.layer` at the edge of the program, or use
12
- * `NodeServices.layer` when you also want the standard Node path, stdio,
13
- * terminal, and child process services. The implementation is shared with
14
- * other Node-compatible platform packages, so optional services such as
15
- * `FileSystem.WatchBackend` are honored when present; otherwise file watching
16
- * follows Node's `node:fs.watch` behavior. Paths are interpreted by Node, so
17
- * relative paths use the current working directory and platform path rules.
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
  */
@@ -1,28 +1,37 @@
1
1
  /**
2
2
  * Node.js implementations of the Effect `HttpClient`.
3
3
  *
4
- * This module provides the Node-specific layers and constructors for sending
5
- * Effect HTTP client requests. It re-exports the fetch-based client for
6
- * programs that want to use `globalThis.fetch`, provides an Undici-backed
7
- * client for applications that need Undici dispatcher control, and provides a
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
- * Use these clients in server-side applications, CLIs, tests, and integrations
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
- * The backends are not completely interchangeable. Fetch, Undici, and
21
- * `node:http` expose different agent and dispatcher hooks, body implementations,
22
- * abort behavior, upgrade support, and response body readers. This module
23
- * converts Effect request bodies to the selected runtime representation:
24
- * streams remain streaming, `FormData` may contribute generated content headers,
25
- * and body read failures are reported as `HttpClientError` decode or transport
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
@@ -62,9 +71,14 @@ import * as Undici from "./Undici.ts"
62
71
 
63
72
  export {
64
73
  /**
65
- * Fetch-based HTTP client implementation for Node.js.
74
+ * Provides a fetch-based HTTP client implementation for Node.js.
66
75
  *
67
- * @category Fetch
76
+ * **When to use**
77
+ *
78
+ * Use to access or override the fetch implementation used by the Node
79
+ * fetch-based HTTP client.
80
+ *
81
+ * @category fetch
68
82
  * @since 4.0.0
69
83
  */
70
84
  Fetch,
@@ -76,9 +90,13 @@ export {
76
90
  */
77
91
  layer as layerFetch,
78
92
  /**
79
- * Request initialization options accepted by the fetch-based HTTP client.
93
+ * Provides request initialization options accepted by the fetch-based HTTP client.
80
94
  *
81
- * @category Fetch
95
+ * **When to use**
96
+ *
97
+ * Use to provide default fetch request options for Node HTTP requests.
98
+ *
99
+ * @category fetch
82
100
  * @since 4.0.0
83
101
  */
84
102
  RequestInit