@effect/platform-node 4.0.0-beta.66 → 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 (119) hide show
  1. package/dist/Mime.d.ts +3 -3
  2. package/dist/Mime.js +3 -3
  3. package/dist/NodeChildProcessSpawner.d.ts +1 -1
  4. package/dist/NodeChildProcessSpawner.js +1 -1
  5. package/dist/NodeClusterHttp.d.ts +47 -7
  6. package/dist/NodeClusterHttp.d.ts.map +1 -1
  7. package/dist/NodeClusterHttp.js +13 -6
  8. package/dist/NodeClusterHttp.js.map +1 -1
  9. package/dist/NodeClusterSocket.d.ts +51 -11
  10. package/dist/NodeClusterSocket.d.ts.map +1 -1
  11. package/dist/NodeClusterSocket.js +51 -11
  12. package/dist/NodeClusterSocket.js.map +1 -1
  13. package/dist/NodeCrypto.d.ts +10 -0
  14. package/dist/NodeCrypto.d.ts.map +1 -0
  15. package/dist/NodeCrypto.js +14 -0
  16. package/dist/NodeCrypto.js.map +1 -0
  17. package/dist/NodeFileSystem.d.ts +4 -2
  18. package/dist/NodeFileSystem.d.ts.map +1 -1
  19. package/dist/NodeFileSystem.js +22 -3
  20. package/dist/NodeFileSystem.js.map +1 -1
  21. package/dist/NodeHttpClient.d.ts +91 -19
  22. package/dist/NodeHttpClient.d.ts.map +1 -1
  23. package/dist/NodeHttpClient.js +91 -19
  24. package/dist/NodeHttpClient.js.map +1 -1
  25. package/dist/NodeHttpIncomingMessage.d.ts +22 -4
  26. package/dist/NodeHttpIncomingMessage.d.ts.map +1 -1
  27. package/dist/NodeHttpIncomingMessage.js +22 -4
  28. package/dist/NodeHttpIncomingMessage.js.map +1 -1
  29. package/dist/NodeHttpPlatform.d.ts +10 -4
  30. package/dist/NodeHttpPlatform.d.ts.map +1 -1
  31. package/dist/NodeHttpPlatform.js +32 -5
  32. package/dist/NodeHttpPlatform.js.map +1 -1
  33. package/dist/NodeHttpServer.d.ts +39 -12
  34. package/dist/NodeHttpServer.d.ts.map +1 -1
  35. package/dist/NodeHttpServer.js +69 -13
  36. package/dist/NodeHttpServer.js.map +1 -1
  37. package/dist/NodeHttpServerRequest.d.ts +29 -3
  38. package/dist/NodeHttpServerRequest.d.ts.map +1 -1
  39. package/dist/NodeHttpServerRequest.js +9 -2
  40. package/dist/NodeHttpServerRequest.js.map +1 -1
  41. package/dist/NodeMultipart.d.ts +32 -4
  42. package/dist/NodeMultipart.d.ts.map +1 -1
  43. package/dist/NodeMultipart.js +32 -4
  44. package/dist/NodeMultipart.js.map +1 -1
  45. package/dist/NodePath.d.ts +15 -6
  46. package/dist/NodePath.d.ts.map +1 -1
  47. package/dist/NodePath.js +30 -7
  48. package/dist/NodePath.js.map +1 -1
  49. package/dist/NodeRedis.d.ts +36 -7
  50. package/dist/NodeRedis.d.ts.map +1 -1
  51. package/dist/NodeRedis.js +36 -7
  52. package/dist/NodeRedis.js.map +1 -1
  53. package/dist/NodeRuntime.d.ts +6 -6
  54. package/dist/NodeRuntime.d.ts.map +1 -1
  55. package/dist/NodeRuntime.js +17 -3
  56. package/dist/NodeRuntime.js.map +1 -1
  57. package/dist/NodeServices.d.ts +29 -5
  58. package/dist/NodeServices.d.ts.map +1 -1
  59. package/dist/NodeServices.js +7 -3
  60. package/dist/NodeServices.js.map +1 -1
  61. package/dist/NodeSink.d.ts +2 -2
  62. package/dist/NodeSink.js +2 -2
  63. package/dist/NodeSocket.d.ts +14 -4
  64. package/dist/NodeSocket.d.ts.map +1 -1
  65. package/dist/NodeSocket.js +32 -5
  66. package/dist/NodeSocket.js.map +1 -1
  67. package/dist/NodeSocketServer.d.ts +2 -2
  68. package/dist/NodeSocketServer.js +2 -2
  69. package/dist/NodeStdio.d.ts +5 -2
  70. package/dist/NodeStdio.d.ts.map +1 -1
  71. package/dist/NodeStdio.js +22 -3
  72. package/dist/NodeStdio.js.map +1 -1
  73. package/dist/NodeStream.d.ts +2 -2
  74. package/dist/NodeStream.js +2 -2
  75. package/dist/NodeTerminal.d.ts +8 -2
  76. package/dist/NodeTerminal.d.ts.map +1 -1
  77. package/dist/NodeTerminal.js +19 -3
  78. package/dist/NodeTerminal.js.map +1 -1
  79. package/dist/NodeWorker.d.ts +9 -2
  80. package/dist/NodeWorker.d.ts.map +1 -1
  81. package/dist/NodeWorker.js +28 -3
  82. package/dist/NodeWorker.js.map +1 -1
  83. package/dist/NodeWorkerRunner.d.ts +5 -1
  84. package/dist/NodeWorkerRunner.d.ts.map +1 -1
  85. package/dist/NodeWorkerRunner.js +24 -2
  86. package/dist/NodeWorkerRunner.js.map +1 -1
  87. package/dist/Undici.d.ts +3 -3
  88. package/dist/Undici.js +3 -3
  89. package/dist/index.d.ts +376 -24
  90. package/dist/index.d.ts.map +1 -1
  91. package/dist/index.js +376 -24
  92. package/dist/index.js.map +1 -1
  93. package/package.json +6 -6
  94. package/src/Mime.ts +3 -3
  95. package/src/NodeChildProcessSpawner.ts +1 -1
  96. package/src/NodeClusterHttp.ts +47 -7
  97. package/src/NodeClusterSocket.ts +51 -11
  98. package/src/NodeCrypto.ts +16 -0
  99. package/src/NodeFileSystem.ts +22 -3
  100. package/src/NodeHttpClient.ts +91 -19
  101. package/src/NodeHttpIncomingMessage.ts +22 -4
  102. package/src/NodeHttpPlatform.ts +32 -5
  103. package/src/NodeHttpServer.ts +69 -13
  104. package/src/NodeHttpServerRequest.ts +29 -3
  105. package/src/NodeMultipart.ts +32 -4
  106. package/src/NodePath.ts +30 -7
  107. package/src/NodeRedis.ts +36 -7
  108. package/src/NodeRuntime.ts +21 -7
  109. package/src/NodeServices.ts +31 -5
  110. package/src/NodeSink.ts +2 -2
  111. package/src/NodeSocket.ts +32 -5
  112. package/src/NodeSocketServer.ts +2 -2
  113. package/src/NodeStdio.ts +22 -3
  114. package/src/NodeStream.ts +2 -2
  115. package/src/NodeTerminal.ts +19 -3
  116. package/src/NodeWorker.ts +28 -3
  117. package/src/NodeWorkerRunner.ts +24 -2
  118. package/src/Undici.ts +3 -3
  119. package/src/index.ts +377 -24
@@ -1,5 +1,22 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Node-specific helpers for parsing HTTP `multipart/form-data` request bodies.
3
+ *
4
+ * This module adapts a Node `Readable` request body plus its incoming headers
5
+ * into the shared `Multipart` model. Use `stream` when an HTTP server route
6
+ * wants to handle form fields and uploaded files incrementally, for example API
7
+ * endpoints that validate text fields while piping file parts to storage. Use
8
+ * `persisted` when the whole form should be collected into a record and uploaded
9
+ * files should be written into scoped temporary files through the current
10
+ * `FileSystem` and `Path` services.
11
+ *
12
+ * Node request bodies are one-shot streams, so consume either `stream` or
13
+ * `persisted`, and make sure file parts are drained, piped, or otherwise
14
+ * deliberately handled. `contentEffect` loads a file into memory and should be
15
+ * reserved for small uploads. Persisted paths live only for the surrounding
16
+ * `Scope`, and filenames supplied by clients should be treated as metadata, not
17
+ * trusted filesystem paths.
18
+ *
19
+ * @since 4.0.0
3
20
  */
4
21
  import * as Effect from "effect/Effect"
5
22
  import type * as FileSystem from "effect/FileSystem"
@@ -16,8 +33,12 @@ import * as NodeStreamP from "node:stream/promises"
16
33
  import * as NodeStream from "./NodeStream.ts"
17
34
 
18
35
  /**
19
- * @since 1.0.0
36
+ * Parses multipart data from a Node readable request body and headers into a
37
+ * stream of `Multipart.Part` values, converting parser failures to
38
+ * `MultipartError`.
39
+ *
20
40
  * @category constructors
41
+ * @since 4.0.0
21
42
  */
22
43
  export const stream = (
23
44
  source: Readable,
@@ -39,8 +60,11 @@ export const stream = (
39
60
  )
40
61
 
41
62
  /**
42
- * @since 1.0.0
63
+ * Parses multipart data from a Node readable request body and persists file
64
+ * parts using the current `FileSystem`, `Path`, and `Scope` services.
65
+ *
43
66
  * @category constructors
67
+ * @since 4.0.0
44
68
  */
45
69
  export const persisted = (
46
70
  source: Readable,
@@ -57,7 +81,11 @@ export const persisted = (
57
81
  }))
58
82
 
59
83
  /**
60
- * @since 1.0.0
84
+ * Returns the underlying Node readable stream for a multipart file produced by
85
+ * the Node multipart parser.
86
+ *
87
+ * @category converting
88
+ * @since 4.0.0
61
89
  */
62
90
  export const fileToReadable = (file: Multipart.File): Readable => (file as FileImpl).file
63
91
 
package/src/NodePath.ts CHANGED
@@ -1,24 +1,47 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Node.js layers for Effect's `Path` service.
3
+ *
4
+ * Use this module when an Effect program running on Node needs path operations
5
+ * from the `Path` service, such as joining and normalizing filesystem
6
+ * locations, resolving configuration or static asset paths, working with CLI
7
+ * path arguments, or converting between file paths and `file:` URLs.
8
+ *
9
+ * `layer` follows the host platform's `node:path` semantics. Use `layerPosix`
10
+ * or `layerWin32` when code needs stable POSIX or Windows behavior regardless
11
+ * of the operating system. These layers provide only path manipulation; they do
12
+ * not read the filesystem or validate that paths exist. `NodeServices.layer`
13
+ * already includes the default Node path layer, so provide this module directly
14
+ * when you want the narrower service or one of the platform-specific variants.
15
+ *
16
+ * @since 4.0.0
3
17
  */
4
18
  import * as NodePath from "@effect/platform-node-shared/NodePath"
5
19
  import type * as Layer from "effect/Layer"
6
20
  import type { Path } from "effect/Path"
7
21
 
8
22
  /**
9
- * @since 1.0.0
10
- * @category layer
23
+ * Provides the default Node `Path` service using the platform's `node:path`
24
+ * implementation.
25
+ *
26
+ * @category layers
27
+ * @since 4.0.0
11
28
  */
12
29
  export const layer: Layer.Layer<Path> = NodePath.layer
13
30
 
14
31
  /**
15
- * @since 1.0.0
16
- * @category layer
32
+ * Provides the `Path` service using Node's POSIX path implementation,
33
+ * regardless of the host platform.
34
+ *
35
+ * @category layers
36
+ * @since 4.0.0
17
37
  */
18
38
  export const layerPosix: Layer.Layer<Path> = NodePath.layerPosix
19
39
 
20
40
  /**
21
- * @since 1.0.0
22
- * @category layer
41
+ * Provides the `Path` service using Node's Windows path implementation,
42
+ * regardless of the host platform.
43
+ *
44
+ * @category layers
45
+ * @since 4.0.0
23
46
  */
24
47
  export const layerWin32: Layer.Layer<Path> = NodePath.layerWin32
package/src/NodeRedis.ts CHANGED
@@ -1,5 +1,24 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Node.js Redis integration backed by `ioredis`.
3
+ *
4
+ * This module provides scoped layers that create an `ioredis` client and expose
5
+ * both the low-level `Redis` service used by Effect persistence modules and the
6
+ * `NodeRedis` service for direct access to the underlying client. It is useful
7
+ * for Node applications that want Redis-backed persistence, persisted queues,
8
+ * distributed rate limiting, or custom Redis commands alongside the Effect
9
+ * services that build on Redis.
10
+ *
11
+ * The client is acquired when the layer is built and closed with `quit` when
12
+ * the layer scope ends, so install the layer at the lifetime you want for the
13
+ * connection and pass `ioredis` options, or `layerConfig`, for connection,
14
+ * TLS, database, retry, and reconnect settings. Persistence and rate limiter
15
+ * stores build their own keys and Lua scripts on top of this service; choose
16
+ * stable prefixes and store ids to avoid collisions, account for persisted
17
+ * values that may fail to decode after schema changes, and avoid unbounded
18
+ * high-cardinality rate-limit keys unless you have a cleanup or bounding
19
+ * strategy.
20
+ *
21
+ * @since 4.0.0
3
22
  */
4
23
  import * as Config from "effect/Config"
5
24
  import * as Context from "effect/Context"
@@ -11,8 +30,12 @@ import * as Redis from "effect/unstable/persistence/Redis"
11
30
  import * as IoRedis from "ioredis"
12
31
 
13
32
  /**
14
- * @since 1.0.0
15
- * @category Service
33
+ * Service tag for the Node Redis integration, exposing the underlying
34
+ * `ioredis` client and a `use` helper that maps client failures to
35
+ * `RedisError`.
36
+ *
37
+ * @category services
38
+ * @since 4.0.0
16
39
  */
17
40
  export class NodeRedis extends Context.Service<NodeRedis, {
18
41
  readonly client: IoRedis.Redis
@@ -51,16 +74,22 @@ const make = Effect.fnUntraced(function*(
51
74
  })
52
75
 
53
76
  /**
54
- * @since 1.0.0
55
- * @category Layers
77
+ * Provides `Redis` and `NodeRedis` services backed by an `ioredis` client
78
+ * created with the supplied options and closed when the layer scope ends.
79
+ *
80
+ * @category layers
81
+ * @since 4.0.0
56
82
  */
57
83
  export const layer = (
58
84
  options?: IoRedis.RedisOptions | undefined
59
85
  ): Layer.Layer<Redis.Redis | NodeRedis> => Layer.effectContext(make(options))
60
86
 
61
87
  /**
62
- * @since 1.0.0
63
- * @category Layers
88
+ * Provides `Redis` and `NodeRedis` services from `Config`-backed ioredis
89
+ * options, closing the client when the layer scope ends.
90
+ *
91
+ * @category layers
92
+ * @since 4.0.0
64
93
  */
65
94
  export const layerConfig: (
66
95
  options: Config.Wrap<IoRedis.RedisOptions>
@@ -1,5 +1,19 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Node.js entry-point helpers for running Effect programs.
3
+ *
4
+ * This module exposes `runMain`, the Node runtime launcher used at the edge of
5
+ * CLI tools, scripts, servers, and worker processes. It runs an already
6
+ * self-contained Effect as the process main program, with built-in error
7
+ * reporting and Node signal handling.
8
+ *
9
+ * `NodeRuntime` does not provide application services by itself. Provide any
10
+ * required layers, such as `NodeServices.layer` or narrower service-specific
11
+ * layers, before passing the effect to `runMain`. On `SIGINT` or `SIGTERM`,
12
+ * the main fiber is interrupted so scoped resources and finalizers can shut
13
+ * down; keep long-running work attached to that scope and avoid finalizers that
14
+ * never complete, otherwise process shutdown can be delayed.
15
+ *
16
+ * @since 4.0.0
3
17
  */
4
18
  import * as NodeRuntime from "@effect/platform-node-shared/NodeRuntime"
5
19
  import type { Effect } from "effect/Effect"
@@ -28,8 +42,8 @@ import type * as Runtime from "effect/Runtime"
28
42
  * when you need structured error handling, log management, interrupt support,
29
43
  * or advanced teardown capabilities.
30
44
  *
31
- * @since 1.0.0
32
- * @category Run main
45
+ * @category running
46
+ * @since 4.0.0
33
47
  */
34
48
  export const runMain: {
35
49
  /**
@@ -55,8 +69,8 @@ export const runMain: {
55
69
  * when you need structured error handling, log management, interrupt support,
56
70
  * or advanced teardown capabilities.
57
71
  *
58
- * @since 1.0.0
59
- * @category Run main
72
+ * @category running
73
+ * @since 4.0.0
60
74
  */
61
75
  (
62
76
  options?: {
@@ -87,8 +101,8 @@ export const runMain: {
87
101
  * when you need structured error handling, log management, interrupt support,
88
102
  * or advanced teardown capabilities.
89
103
  *
90
- * @since 1.0.0
91
- * @category Run main
104
+ * @category running
105
+ * @since 4.0.0
92
106
  */
93
107
  <E, A>(
94
108
  effect: Effect<A, E>,
@@ -1,6 +1,24 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Provides the aggregate Node platform services layer for applications that run
3
+ * on the Node.js runtime.
4
+ *
5
+ * This module is useful when an application needs the standard Node-backed
6
+ * implementations of filesystem access, path operations, stdio, terminal
7
+ * interaction, and child process spawning from a single layer. Provide
8
+ * `NodeServices.layer` near the edge of a program to satisfy effects that read
9
+ * or write files, resolve paths, interact with stdin/stdout/stderr or a
10
+ * terminal, or launch subprocesses.
11
+ *
12
+ * The layer only supplies the runtime services listed by `NodeServices`; it does
13
+ * not provide unrelated platform services such as HTTP clients or servers.
14
+ * Libraries should continue to depend on the individual service tags they use,
15
+ * while applications, CLIs, and tests can choose this layer or narrower
16
+ * service-specific layers depending on how much of the Node runtime they want to
17
+ * expose.
18
+ *
19
+ * @since 4.0.0
3
20
  */
21
+ import type { Crypto } from "effect/Crypto"
4
22
  import type { FileSystem } from "effect/FileSystem"
5
23
  import * as Layer from "effect/Layer"
6
24
  import type { Path } from "effect/Path"
@@ -8,25 +26,33 @@ import type { Stdio } from "effect/Stdio"
8
26
  import type { Terminal } from "effect/Terminal"
9
27
  import type { ChildProcessSpawner } from "effect/unstable/process/ChildProcessSpawner"
10
28
  import * as NodeChildProcessSpawner from "./NodeChildProcessSpawner.ts"
29
+ import * as NodeCrypto from "./NodeCrypto.ts"
11
30
  import * as NodeFileSystem from "./NodeFileSystem.ts"
12
31
  import * as NodePath from "./NodePath.ts"
13
32
  import * as NodeStdio from "./NodeStdio.ts"
14
33
  import * as NodeTerminal from "./NodeTerminal.ts"
15
34
 
16
35
  /**
17
- * @since 1.0.0
36
+ * The union of core services provided by the Node platform layer, including
37
+ * child process spawning, filesystem, path, stdio, and terminal services.
38
+ *
18
39
  * @category models
40
+ * @since 4.0.0
19
41
  */
20
- export type NodeServices = ChildProcessSpawner | FileSystem | Path | Stdio | Terminal
42
+ export type NodeServices = ChildProcessSpawner | Crypto | FileSystem | Path | Stdio | Terminal
21
43
 
22
44
  /**
23
- * @since 1.0.0
24
- * @category layer
45
+ * Provides the default Node implementations for child process spawning,
46
+ * filesystem, path, stdio, and terminal services.
47
+ *
48
+ * @category layers
49
+ * @since 4.0.0
25
50
  */
26
51
  export const layer: Layer.Layer<NodeServices> = Layer.provideMerge(
27
52
  NodeChildProcessSpawner.layer,
28
53
  Layer.mergeAll(
29
54
  NodeFileSystem.layer,
55
+ NodeCrypto.layer,
30
56
  NodePath.layer,
31
57
  NodeStdio.layer,
32
58
  NodeTerminal.layer
package/src/NodeSink.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * @since 4.0.0
3
3
  */
4
4
 
5
5
  /**
6
- * @since 1.0.0
6
+ * @since 4.0.0
7
7
  */
8
8
  export * from "@effect/platform-node-shared/NodeSink"
package/src/NodeSocket.ts CHANGED
@@ -1,5 +1,22 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Node platform socket entry point for Effect sockets backed by Node streams
3
+ * and WebSocket implementations.
4
+ *
5
+ * This module re-exports the shared Node socket constructors for TCP clients,
6
+ * Unix domain socket clients, and adapters from existing Node `Duplex` streams,
7
+ * then adds Node-specific WebSocket constructor layers. Use it when connecting
8
+ * to raw socket protocols, wiring RPC transports over TCP or Unix sockets, or
9
+ * opening WebSocket clients in Node.
10
+ *
11
+ * TCP and Unix socket behavior comes from the shared Node layer: Unix sockets
12
+ * are selected with `NetConnectOpts.path`, scoped sockets close or destroy the
13
+ * underlying stream on finalization, and Node open, read, write, and close
14
+ * events are translated into `SocketError` values. For WebSockets,
15
+ * `layerWebSocketConstructor` prefers `globalThis.WebSocket` when available
16
+ * and falls back to `ws`; use `layerWebSocketConstructorWS` when you need the
17
+ * `ws` implementation consistently across Node versions.
18
+ *
19
+ * @since 4.0.0
3
20
  */
4
21
  import { NodeWS as WS } from "@effect/platform-node-shared/NodeSocket"
5
22
  import type * as Duration from "effect/Duration"
@@ -9,13 +26,16 @@ import * as Layer from "effect/Layer"
9
26
  import * as Socket from "effect/unstable/socket/Socket"
10
27
 
11
28
  /**
12
- * @since 1.0.0
29
+ * @since 4.0.0
13
30
  */
14
31
  export * from "@effect/platform-node-shared/NodeSocket"
15
32
 
16
33
  /**
17
- * @since 1.0.0
34
+ * Provides a `Socket.WebSocketConstructor`, using `globalThis.WebSocket` when
35
+ * available and falling back to the `ws` package otherwise.
36
+ *
18
37
  * @category layers
38
+ * @since 4.0.0
19
39
  */
20
40
  export const layerWebSocketConstructor: Layer.Layer<
21
41
  Socket.WebSocketConstructor
@@ -27,8 +47,11 @@ export const layerWebSocketConstructor: Layer.Layer<
27
47
  })
28
48
 
29
49
  /**
30
- * @since 1.0.0
50
+ * Provides a `Socket.WebSocketConstructor` backed explicitly by the `ws`
51
+ * package.
52
+ *
31
53
  * @category layers
54
+ * @since 4.0.0
32
55
  */
33
56
  export const layerWebSocketConstructorWS: Layer.Layer<
34
57
  Socket.WebSocketConstructor
@@ -37,8 +60,12 @@ export const layerWebSocketConstructorWS: Layer.Layer<
37
60
  )
38
61
 
39
62
  /**
40
- * @since 1.0.0
63
+ * Creates a `Socket.Socket` layer for a WebSocket URL using the Node WebSocket
64
+ * constructor layer, honoring protocol, open-timeout, and close-code error
65
+ * options.
66
+ *
41
67
  * @category layers
68
+ * @since 4.0.0
42
69
  */
43
70
  export const layerWebSocket: (
44
71
  url: string | Effect.Effect<string>,
@@ -1,8 +1,8 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * @since 4.0.0
3
3
  */
4
4
 
5
5
  /**
6
- * @since 1.0.0
6
+ * @since 4.0.0
7
7
  */
8
8
  export * from "@effect/platform-node-shared/NodeSocketServer"
package/src/NodeStdio.ts CHANGED
@@ -1,12 +1,31 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Node.js implementation of the Effect `Stdio` service.
3
+ *
4
+ * This module exposes a layer that connects `Stdio` to the current process:
5
+ * command-line arguments come from `process.argv`, input is read from
6
+ * `process.stdin`, and output and error output write to `process.stdout` and
7
+ * `process.stderr`. It is intended for CLIs, scripts, command runners, and
8
+ * other process-oriented programs that need standard input and output through
9
+ * Effect services.
10
+ *
11
+ * The underlying streams are owned by the Node process. The layer keeps stdin
12
+ * open and does not end stdout or stderr when a stream finishes, which avoids
13
+ * closing global process handles that other code may still use. Be mindful that
14
+ * stdio may be a pipe, file, or TTY, so terminal-specific behavior such as raw
15
+ * mode, echo, colors, and cursor control should be handled with the terminal
16
+ * APIs instead of assuming an interactive console.
17
+ *
18
+ * @since 4.0.0
3
19
  */
4
20
  import * as NodeStdio from "@effect/platform-node-shared/NodeStdio"
5
21
  import type * as Layer from "effect/Layer"
6
22
  import type { Stdio } from "effect/Stdio"
7
23
 
8
24
  /**
9
- * @since 1.0.0
10
- * @category layer
25
+ * Provides the `Stdio` service backed by the current process arguments,
26
+ * stdin, stdout, and stderr streams.
27
+ *
28
+ * @category layers
29
+ * @since 4.0.0
11
30
  */
12
31
  export const layer: Layer.Layer<Stdio> = NodeStdio.layer
package/src/NodeStream.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * @since 4.0.0
3
3
  */
4
4
 
5
5
  /**
6
- * @since 1.0.0
6
+ * @since 4.0.0
7
7
  */
8
8
  export * from "@effect/platform-node-shared/NodeStream"
@@ -1,5 +1,15 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Provides the Node.js `Terminal` service for interactive command-line
3
+ * programs, prompts, and tools that need to read lines, react to key presses,
4
+ * write to stdout, or inspect terminal dimensions.
5
+ *
6
+ * The implementation is backed by the current process' stdin and stdout. When
7
+ * stdin is a TTY, key input temporarily enables raw mode for the scope of the
8
+ * service, so callers should acquire it with a scope or use the provided layer
9
+ * to ensure terminal state is restored. In non-TTY environments, terminal
10
+ * dimensions may be reported as zero and raw-mode key handling is unavailable.
11
+ *
12
+ * @since 4.0.0
3
13
  */
4
14
  import * as NodeTerminal from "@effect/platform-node-shared/NodeTerminal"
5
15
  import type { Effect } from "effect/Effect"
@@ -8,13 +18,19 @@ import type { Scope } from "effect/Scope"
8
18
  import type { Terminal, UserInput } from "effect/Terminal"
9
19
 
10
20
  /**
11
- * @since 1.0.0
21
+ * Creates a scoped `Terminal` service backed by process stdin/stdout, using the
22
+ * optional predicate to decide when key input should end the input stream.
23
+ *
12
24
  * @category constructors
25
+ * @since 4.0.0
13
26
  */
14
27
  export const make: (shouldQuit?: (input: UserInput) => boolean) => Effect<Terminal, never, Scope> = NodeTerminal.make
15
28
 
16
29
  /**
17
- * @since 1.0.0
30
+ * Provides the default process-backed `Terminal` service, ending key input on
31
+ * the default quit keys.
32
+ *
18
33
  * @category layers
34
+ * @since 4.0.0
19
35
  */
20
36
  export const layer: Layer<Terminal> = NodeTerminal.layer
package/src/NodeWorker.ts CHANGED
@@ -1,5 +1,23 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Parent-side Node.js support for Effect workers.
3
+ *
4
+ * This module provides the `WorkerPlatform` used by Node programs that spawn
5
+ * and communicate with `node:worker_threads` workers or IPC-enabled child
6
+ * processes through Effect's worker protocol. Pair it with `NodeWorkerRunner`
7
+ * in the worker entrypoint when building worker-backed RPC clients, offloading
8
+ * CPU-bound work, isolating Node resources, or hosting services that should
9
+ * exchange typed messages with the parent process.
10
+ *
11
+ * Worker-thread spawners can use `postMessage` transfer lists for values such
12
+ * as `ArrayBuffer` and `MessagePort`, but transferring moves ownership and
13
+ * invalid transfer lists surface as worker send or receive failures.
14
+ * Child-process spawners must provide an IPC channel, for example via
15
+ * `child_process.fork` or `stdio: "ipc"`; their messages use Node IPC
16
+ * serialization and this module does not forward transfer lists to
17
+ * `ChildProcess.send`. Scope finalization sends the worker close signal and
18
+ * waits for exit before falling back to `terminate()` or `SIGKILL`.
19
+ *
20
+ * @since 4.0.0
3
21
  */
4
22
  import * as Deferred from "effect/Deferred"
5
23
  import * as Effect from "effect/Effect"
@@ -12,8 +30,12 @@ import type * as ChildProcess from "node:child_process"
12
30
  import type * as WorkerThreads from "node:worker_threads"
13
31
 
14
32
  /**
15
- * @since 1.0.0
33
+ * Provides the Node `WorkerPlatform` for `worker_threads` workers and child
34
+ * process workers, wiring messages, errors, and exits into Effect workers and
35
+ * terminating the worker if graceful shutdown times out.
36
+ *
16
37
  * @category layers
38
+ * @since 4.0.0
17
39
  */
18
40
  export const layerPlatform: Layer.Layer<Worker.WorkerPlatform> = Layer.succeed(Worker.WorkerPlatform)(
19
41
  Worker.makePlatform<WorkerThreads.Worker | ChildProcess.ChildProcess>()({
@@ -93,8 +115,11 @@ export const layerPlatform: Layer.Layer<Worker.WorkerPlatform> = Layer.succeed(W
93
115
  )
94
116
 
95
117
  /**
96
- * @since 1.0.0
118
+ * Provides the Node `WorkerPlatform` together with a `Worker.Spawner` created
119
+ * from the supplied worker or child-process spawning function.
120
+ *
97
121
  * @category layers
122
+ * @since 4.0.0
98
123
  */
99
124
  export const layer = (
100
125
  spawn: (id: number) => WorkerThreads.Worker | ChildProcess.ChildProcess
@@ -1,5 +1,23 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Runtime support for Effect workers that are executed by Node.js.
3
+ *
4
+ * This module is intended to be installed in the program running inside a
5
+ * `node:worker_threads` worker or an IPC-enabled child process. It provides the
6
+ * `WorkerRunnerPlatform` used by `WorkerRunner` to receive request messages
7
+ * from the parent, run the registered Effect handler, and send responses back
8
+ * over the parent channel.
9
+ *
10
+ * Use it when the parent side is created with `NodeWorker` and the worker code
11
+ * needs to perform CPU-bound work, isolate Node resources, or host services that
12
+ * should communicate through the Effect worker protocol. The runner must be
13
+ * started from an actual worker context: `parentPort` is required for worker
14
+ * threads, while child processes must be spawned with an IPC channel so
15
+ * `process.send` is available. Transfer lists only apply to worker-thread
16
+ * `postMessage`; child-process messages go through Node IPC serialization.
17
+ * Shutdown is coordinated by the parent message protocol, so long-running
18
+ * handlers should remain interruptible and keep resource cleanup in scopes.
19
+ *
20
+ * @since 4.0.0
3
21
  */
4
22
  import * as Cause from "effect/Cause"
5
23
  import * as Deferred from "effect/Deferred"
@@ -12,8 +30,12 @@ import * as WorkerRunner from "effect/unstable/workers/WorkerRunner"
12
30
  import * as WorkerThreads from "node:worker_threads"
13
31
 
14
32
  /**
15
- * @since 1.0.0
33
+ * Provides the `WorkerRunnerPlatform` for code running inside a Node worker
34
+ * thread or child process, routing parent messages to the registered handler
35
+ * and sending responses back through the parent channel.
36
+ *
16
37
  * @category layers
38
+ * @since 4.0.0
17
39
  */
18
40
  export const layer: Layer.Layer<WorkerRunner.WorkerRunnerPlatform> = Layer.succeed(WorkerRunner.WorkerRunnerPlatform)({
19
41
  start<O = unknown, I = unknown>() {
package/src/Undici.ts CHANGED
@@ -1,16 +1,16 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * @since 4.0.0
3
3
  */
4
4
  import Undici from "undici"
5
5
 
6
6
  /**
7
- * @since 1.0.0
8
7
  * @category undici
8
+ * @since 4.0.0
9
9
  */
10
10
  export * from "undici"
11
11
 
12
12
  /**
13
- * @since 1.0.0
14
13
  * @category undici
14
+ * @since 4.0.0
15
15
  */
16
16
  export default Undici