@effect/platform-node 4.0.0-beta.67 → 4.0.0-beta.68

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 (51) hide show
  1. package/dist/NodeClusterHttp.d.ts +3 -3
  2. package/dist/NodeClusterHttp.js +3 -3
  3. package/dist/NodeClusterSocket.d.ts +5 -5
  4. package/dist/NodeClusterSocket.js +5 -5
  5. package/dist/NodeCrypto.d.ts +10 -0
  6. package/dist/NodeCrypto.d.ts.map +1 -0
  7. package/dist/NodeCrypto.js +14 -0
  8. package/dist/NodeCrypto.js.map +1 -0
  9. package/dist/NodeFileSystem.d.ts +1 -1
  10. package/dist/NodeFileSystem.js +1 -1
  11. package/dist/NodeHttpIncomingMessage.d.ts +1 -1
  12. package/dist/NodeHttpIncomingMessage.js +1 -1
  13. package/dist/NodeHttpPlatform.d.ts +2 -2
  14. package/dist/NodeHttpPlatform.js +2 -2
  15. package/dist/NodeHttpServer.d.ts +4 -4
  16. package/dist/NodeHttpServer.js +4 -4
  17. package/dist/NodeMultipart.d.ts +1 -0
  18. package/dist/NodeMultipart.d.ts.map +1 -1
  19. package/dist/NodeMultipart.js +1 -0
  20. package/dist/NodeMultipart.js.map +1 -1
  21. package/dist/NodePath.d.ts +3 -3
  22. package/dist/NodePath.js +3 -3
  23. package/dist/NodeRedis.d.ts +3 -3
  24. package/dist/NodeRedis.js +3 -3
  25. package/dist/NodeRuntime.d.ts +3 -3
  26. package/dist/NodeRuntime.js +1 -1
  27. package/dist/NodeServices.d.ts +3 -2
  28. package/dist/NodeServices.d.ts.map +1 -1
  29. package/dist/NodeServices.js +3 -2
  30. package/dist/NodeServices.js.map +1 -1
  31. package/dist/NodeStdio.d.ts +1 -1
  32. package/dist/NodeStdio.js +1 -1
  33. package/dist/index.d.ts +352 -0
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +352 -0
  36. package/dist/index.js.map +1 -1
  37. package/package.json +4 -4
  38. package/src/NodeClusterHttp.ts +3 -3
  39. package/src/NodeClusterSocket.ts +5 -5
  40. package/src/NodeCrypto.ts +16 -0
  41. package/src/NodeFileSystem.ts +1 -1
  42. package/src/NodeHttpIncomingMessage.ts +1 -1
  43. package/src/NodeHttpPlatform.ts +2 -2
  44. package/src/NodeHttpServer.ts +4 -4
  45. package/src/NodeMultipart.ts +1 -0
  46. package/src/NodePath.ts +3 -3
  47. package/src/NodeRedis.ts +3 -3
  48. package/src/NodeRuntime.ts +3 -3
  49. package/src/NodeServices.ts +5 -2
  50. package/src/NodeStdio.ts +1 -1
  51. package/src/index.ts +353 -0
package/dist/index.js CHANGED
@@ -13,54 +13,327 @@ export * as Mime from "./Mime.js";
13
13
  */
14
14
  export * as NodeChildProcessSpawner from "./NodeChildProcessSpawner.js";
15
15
  /**
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
+ *
16
49
  * @since 4.0.0
17
50
  */
18
51
  export * as NodeClusterHttp from "./NodeClusterHttp.js";
19
52
  /**
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
+ *
20
82
  * @since 4.0.0
21
83
  */
22
84
  export * as NodeClusterSocket from "./NodeClusterSocket.js";
23
85
  /**
86
+ * Node.js platform Crypto service layer.
87
+ *
88
+ * @since 1.0.0
89
+ */
90
+ export * as NodeCrypto from "./NodeCrypto.js";
91
+ /**
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
+ *
24
109
  * @since 4.0.0
25
110
  */
26
111
  export * as NodeFileSystem from "./NodeFileSystem.js";
27
112
  /**
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
+ *
28
139
  * @since 4.0.0
29
140
  */
30
141
  export * as NodeHttpClient from "./NodeHttpClient.js";
31
142
  /**
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
+ *
32
155
  * @since 4.0.0
33
156
  */
34
157
  export * as NodeHttpIncomingMessage from "./NodeHttpIncomingMessage.js";
35
158
  /**
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
+ *
36
180
  * @since 4.0.0
37
181
  */
38
182
  export * as NodeHttpPlatform from "./NodeHttpPlatform.js";
39
183
  /**
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
+ *
40
213
  * @since 4.0.0
41
214
  */
42
215
  export * as NodeHttpServer from "./NodeHttpServer.js";
43
216
  /**
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
+ *
44
236
  * @since 4.0.0
45
237
  */
46
238
  export * as NodeHttpServerRequest from "./NodeHttpServerRequest.js";
47
239
  /**
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
+ *
48
257
  * @since 4.0.0
49
258
  */
50
259
  export * as NodeMultipart from "./NodeMultipart.js";
51
260
  /**
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
+ *
52
275
  * @since 4.0.0
53
276
  */
54
277
  export * as NodePath from "./NodePath.js";
55
278
  /**
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
+ *
56
298
  * @since 4.0.0
57
299
  */
58
300
  export * as NodeRedis from "./NodeRedis.js";
59
301
  /**
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
+ *
60
316
  * @since 4.0.0
61
317
  */
62
318
  export * as NodeRuntime from "./NodeRuntime.js";
63
319
  /**
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
+ *
64
337
  * @since 4.0.0
65
338
  */
66
339
  export * as NodeServices from "./NodeServices.js";
@@ -69,6 +342,23 @@ export * as NodeServices from "./NodeServices.js";
69
342
  */
70
343
  export * as NodeSink from "./NodeSink.js";
71
344
  /**
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
+ *
72
362
  * @since 4.0.0
73
363
  */
74
364
  export * as NodeSocket from "./NodeSocket.js";
@@ -77,6 +367,22 @@ export * as NodeSocket from "./NodeSocket.js";
77
367
  */
78
368
  export * as NodeSocketServer from "./NodeSocketServer.js";
79
369
  /**
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
+ *
80
386
  * @since 4.0.0
81
387
  */
82
388
  export * as NodeStdio from "./NodeStdio.js";
@@ -85,14 +391,60 @@ export * as NodeStdio from "./NodeStdio.js";
85
391
  */
86
392
  export * as NodeStream from "./NodeStream.js";
87
393
  /**
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
+ *
88
404
  * @since 4.0.0
89
405
  */
90
406
  export * as NodeTerminal from "./NodeTerminal.js";
91
407
  /**
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
+ *
92
426
  * @since 4.0.0
93
427
  */
94
428
  export * as NodeWorker from "./NodeWorker.js";
95
429
  /**
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
+ *
96
448
  * @since 4.0.0
97
449
  */
98
450
  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","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;;;AAGA,OAAO,KAAKC,eAAe,MAAM,sBAAsB;AAEvD;;;AAGA,OAAO,KAAKC,iBAAiB,MAAM,wBAAwB;AAE3D;;;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":[]}
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":[]}
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.67",
4
+ "version": "4.0.0-beta.68",
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.67"
53
+ "@effect/platform-node-shared": "^4.0.0-beta.68"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "ioredis": "^5.7.0",
57
- "effect": "^4.0.0-beta.67"
57
+ "effect": "^4.0.0-beta.68"
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.67"
64
+ "effect": "^4.0.0-beta.68"
65
65
  },
66
66
  "scripts": {
67
67
  "codegen": "effect-utils codegen",
@@ -62,7 +62,7 @@ import * as NodeSocket from "./NodeSocket.ts"
62
62
 
63
63
  export {
64
64
  /**
65
- * @category Re-exports
65
+ * @category re-exports
66
66
  * @since 4.0.0
67
67
  */
68
68
  layerK8sHttpClient
@@ -73,7 +73,7 @@ export {
73
73
  * transport, RPC serialization, message storage, runner health checks, and
74
74
  * optional client-only mode.
75
75
  *
76
- * @category Layers
76
+ * @category layers
77
77
  * @since 4.0.0
78
78
  */
79
79
  export const layer = <
@@ -157,7 +157,7 @@ export const layer = <
157
157
  * Provides the HTTP server and Node HTTP services used by cluster runners,
158
158
  * listening on `ShardingConfig.runnerListenAddress` or `runnerAddress`.
159
159
  *
160
- * @category Layers
160
+ * @category layers
161
161
  * @since 4.0.0
162
162
  */
163
163
  export const layerHttpServer: Layer.Layer<
@@ -54,12 +54,12 @@ import * as Undici from "./Undici.ts"
54
54
 
55
55
  export {
56
56
  /**
57
- * @category Re-exports
57
+ * @category re-exports
58
58
  * @since 4.0.0
59
59
  */
60
60
  layerClientProtocol,
61
61
  /**
62
- * @category Re-exports
62
+ * @category re-exports
63
63
  * @since 4.0.0
64
64
  */
65
65
  layerSocketServer
@@ -70,7 +70,7 @@ export {
70
70
  * serialization, message storage, runner health checks, and optional
71
71
  * client-only mode.
72
72
  *
73
- * @category Layers
73
+ * @category layers
74
74
  * @since 4.0.0
75
75
  */
76
76
  export const layer = <
@@ -148,7 +148,7 @@ export const layer = <
148
148
  * account CA certificate when it is available and falling back to the default
149
149
  * dispatcher otherwise.
150
150
  *
151
- * @category Layers
151
+ * @category layers
152
152
  * @since 4.0.0
153
153
  */
154
154
  export const layerDispatcherK8s: Layer.Layer<NodeHttpClient.Dispatcher> = Layer.effect(NodeHttpClient.Dispatcher)(
@@ -180,7 +180,7 @@ export const layerDispatcherK8s: Layer.Layer<NodeHttpClient.Dispatcher> = Layer.
180
180
  * Provides a `K8sHttpClient` backed by the Undici HTTP client and the
181
181
  * Kubernetes-aware dispatcher.
182
182
  *
183
- * @category Layers
183
+ * @category layers
184
184
  * @since 4.0.0
185
185
  */
186
186
  export const layerK8sHttpClient: Layer.Layer<K8sHttpClient.K8sHttpClient> = K8sHttpClient.layer.pipe(
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Node.js platform Crypto service layer.
3
+ *
4
+ * @since 1.0.0
5
+ */
6
+ import * as NodeCrypto from "@effect/platform-node-shared/NodeCrypto"
7
+ import type * as Crypto from "effect/Crypto"
8
+ import type * as Layer from "effect/Layer"
9
+
10
+ /**
11
+ * A layer that provides the Node.js Crypto service implementation.
12
+ *
13
+ * @category layers
14
+ * @since 1.0.0
15
+ */
16
+ export const layer: Layer.Layer<Crypto.Crypto> = NodeCrypto.layer
@@ -25,7 +25,7 @@ import type * as Layer from "effect/Layer"
25
25
  /**
26
26
  * Provides the `FileSystem` service backed by Node filesystem APIs.
27
27
  *
28
- * @category layer
28
+ * @category layers
29
29
  * @since 4.0.0
30
30
  */
31
31
  export const layer: Layer.Layer<FileSystem> = NodeFileSystem.layer
@@ -29,7 +29,7 @@ import * as NodeStream from "./NodeStream.ts"
29
29
  * exposing headers, remote address, stream access, and cached text, JSON, URL
30
30
  * parameter, and array-buffer body decoders with caller-provided error mapping.
31
31
  *
32
- * @category Constructors
32
+ * @category constructors
33
33
  * @since 4.0.0
34
34
  */
35
35
  export abstract class NodeHttpIncomingMessage<E> extends Inspectable.Class
@@ -37,7 +37,7 @@ import * as NodeFileSystem from "./NodeFileSystem.ts"
37
37
  * Creates the Node `HttpPlatform`, serving file responses from Node readable
38
38
  * streams and adding MIME type and content-length headers when needed.
39
39
  *
40
- * @category Constructors
40
+ * @category constructors
41
41
  * @since 4.0.0
42
42
  */
43
43
  export const make = Platform.make({
@@ -74,7 +74,7 @@ export const make = Platform.make({
74
74
  * Provides the Node `HttpPlatform` together with the filesystem and ETag
75
75
  * services it needs for file responses.
76
76
  *
77
- * @category Layers
77
+ * @category layers
78
78
  * @since 4.0.0
79
79
  */
80
80
  export const layer: Layer.Layer<Platform.HttpPlatform> = pipe(
@@ -410,7 +410,7 @@ class ServerRequestImpl extends NodeHttpIncomingMessage<HttpServerError> impleme
410
410
  * Provides an `HttpServer` by creating and managing a scoped Node
411
411
  * `http.Server` with the supplied listen and shutdown options.
412
412
  *
413
- * @category Layers
413
+ * @category layers
414
414
  * @since 4.0.0
415
415
  */
416
416
  export const layerServer: (
@@ -425,7 +425,7 @@ export const layerServer: (
425
425
  * Provides the Node HTTP support services used by `NodeHttpServer`, including
426
426
  * the HTTP platform, ETag generator, and core Node platform services.
427
427
  *
428
- * @category Layers
428
+ * @category layers
429
429
  * @since 4.0.0
430
430
  */
431
431
  export const layerHttpServices: Layer.Layer<
@@ -440,7 +440,7 @@ export const layerHttpServices: Layer.Layer<
440
440
  * Provides a Node `HttpServer` together with the Node HTTP platform, ETag, and
441
441
  * core platform services required to serve requests.
442
442
  *
443
- * @category Layers
443
+ * @category layers
444
444
  * @since 4.0.0
445
445
  */
446
446
  export const layer = (
@@ -462,7 +462,7 @@ export const layer = (
462
462
  * Provides a Node `HttpServer` and HTTP support services, reading the listen
463
463
  * and shutdown options from a `Config` value.
464
464
  *
465
- * @category Layers
465
+ * @category layers
466
466
  * @since 4.0.0
467
467
  */
468
468
  export const layerConfig = (
@@ -84,6 +84,7 @@ export const persisted = (
84
84
  * Returns the underlying Node readable stream for a multipart file produced by
85
85
  * the Node multipart parser.
86
86
  *
87
+ * @category converting
87
88
  * @since 4.0.0
88
89
  */
89
90
  export const fileToReadable = (file: Multipart.File): Readable => (file as FileImpl).file
package/src/NodePath.ts CHANGED
@@ -23,7 +23,7 @@ import type { Path } from "effect/Path"
23
23
  * Provides the default Node `Path` service using the platform's `node:path`
24
24
  * implementation.
25
25
  *
26
- * @category layer
26
+ * @category layers
27
27
  * @since 4.0.0
28
28
  */
29
29
  export const layer: Layer.Layer<Path> = NodePath.layer
@@ -32,7 +32,7 @@ export const layer: Layer.Layer<Path> = NodePath.layer
32
32
  * Provides the `Path` service using Node's POSIX path implementation,
33
33
  * regardless of the host platform.
34
34
  *
35
- * @category layer
35
+ * @category layers
36
36
  * @since 4.0.0
37
37
  */
38
38
  export const layerPosix: Layer.Layer<Path> = NodePath.layerPosix
@@ -41,7 +41,7 @@ export const layerPosix: Layer.Layer<Path> = NodePath.layerPosix
41
41
  * Provides the `Path` service using Node's Windows path implementation,
42
42
  * regardless of the host platform.
43
43
  *
44
- * @category layer
44
+ * @category layers
45
45
  * @since 4.0.0
46
46
  */
47
47
  export const layerWin32: Layer.Layer<Path> = NodePath.layerWin32