@effect/platform-bun 4.0.0-rc.117 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/AGENTS.md +4 -4
  2. package/CLAUDE.md +4 -4
  3. package/README.md +15 -4
  4. package/ai-docs/package.json +1 -1
  5. package/ai-docs/src/01_effect/03_services/20_layer-composition.ts +1 -1
  6. package/ai-docs/src/01_effect/06_running/20_layer-launch.ts +1 -1
  7. package/ai-docs/src/03_stream/30_encoding.ts +1 -1
  8. package/ai-docs/src/08_observability/20_otlp-tracing.ts +2 -2
  9. package/ai-docs/src/08_observability/index.md +1 -1
  10. package/ai-docs/src/40_sql/10_basics.ts +2 -2
  11. package/ai-docs/src/40_sql/index.md +1 -1
  12. package/ai-docs/src/50_http-client/10_basics.ts +1 -1
  13. package/ai-docs/src/51_http-server/10_basics.ts +2 -2
  14. package/ai-docs/src/51_http-server/20_testing.ts +2 -2
  15. package/ai-docs/src/51_http-server/fixtures/api/Api.ts +1 -1
  16. package/ai-docs/src/51_http-server/fixtures/api/Authorization.ts +1 -1
  17. package/ai-docs/src/51_http-server/fixtures/api/System.ts +1 -1
  18. package/ai-docs/src/51_http-server/fixtures/api/Users.ts +1 -1
  19. package/ai-docs/src/51_http-server/fixtures/domain/User.ts +1 -1
  20. package/ai-docs/src/51_http-server/fixtures/server/Users/http.ts +1 -1
  21. package/ai-docs/src/51_http-server/fixtures/server/Users.ts +1 -1
  22. package/ai-docs/src/60_child-process/10_working-with-child-processes.ts +1 -1
  23. package/ai-docs/src/60_child-process/index.md +1 -1
  24. package/ai-docs/src/70_cli/10_basics.ts +1 -1
  25. package/ai-docs/src/70_cli/index.md +1 -1
  26. package/ai-docs/src/71_ai/10_language-model.ts +2 -2
  27. package/ai-docs/src/71_ai/20_tools.ts +2 -2
  28. package/ai-docs/src/71_ai/30_chat.ts +2 -2
  29. package/ai-docs/src/80_cluster/10_entities.ts +3 -3
  30. package/dist/BunClusterHttp.d.ts +10 -20
  31. package/dist/BunClusterHttp.d.ts.map +1 -1
  32. package/dist/BunClusterHttp.js +20 -10
  33. package/dist/BunClusterHttp.js.map +1 -1
  34. package/dist/BunClusterSocket.d.ts +8 -8
  35. package/dist/BunClusterSocket.d.ts.map +1 -1
  36. package/dist/BunClusterSocket.js +11 -11
  37. package/dist/BunClusterSocket.js.map +1 -1
  38. package/dist/BunHttpClient.d.ts +1 -1
  39. package/dist/BunHttpClient.d.ts.map +1 -1
  40. package/dist/BunHttpClient.js +1 -1
  41. package/dist/BunHttpClient.js.map +1 -1
  42. package/dist/BunHttpPlatform.d.ts +1 -1
  43. package/dist/BunHttpPlatform.d.ts.map +1 -1
  44. package/dist/BunHttpPlatform.js +3 -3
  45. package/dist/BunHttpPlatform.js.map +1 -1
  46. package/dist/BunHttpServer.d.ts +10 -10
  47. package/dist/BunHttpServer.d.ts.map +1 -1
  48. package/dist/BunHttpServer.js +17 -15
  49. package/dist/BunHttpServer.js.map +1 -1
  50. package/dist/BunHttpServerRequest.d.ts +1 -1
  51. package/dist/BunHttpServerRequest.d.ts.map +1 -1
  52. package/dist/BunMultipart.d.ts +1 -1
  53. package/dist/BunMultipart.d.ts.map +1 -1
  54. package/dist/BunMultipart.js +1 -1
  55. package/dist/BunMultipart.js.map +1 -1
  56. package/dist/BunRedis.d.ts +5 -1
  57. package/dist/BunRedis.d.ts.map +1 -1
  58. package/dist/BunRedis.js +4 -1
  59. package/dist/BunRedis.js.map +1 -1
  60. package/dist/BunServices.d.ts +1 -1
  61. package/dist/BunServices.d.ts.map +1 -1
  62. package/dist/BunSocket.d.ts +1 -1
  63. package/dist/BunSocket.d.ts.map +1 -1
  64. package/dist/BunSocket.js +1 -1
  65. package/dist/BunSocket.js.map +1 -1
  66. package/dist/BunWorker.d.ts +1 -1
  67. package/dist/BunWorker.d.ts.map +1 -1
  68. package/dist/BunWorker.js +2 -2
  69. package/dist/BunWorker.js.map +1 -1
  70. package/dist/BunWorkerRunner.d.ts +1 -1
  71. package/dist/BunWorkerRunner.d.ts.map +1 -1
  72. package/dist/BunWorkerRunner.js +2 -2
  73. package/dist/BunWorkerRunner.js.map +1 -1
  74. package/dist/index.d.ts +1 -0
  75. package/dist/index.d.ts.map +1 -1
  76. package/dist/index.js +1 -0
  77. package/dist/index.js.map +1 -1
  78. package/package.json +4 -4
  79. package/src/BunClusterHttp.ts +16 -16
  80. package/src/BunClusterSocket.ts +14 -14
  81. package/src/BunHttpClient.ts +1 -1
  82. package/src/BunHttpPlatform.ts +3 -3
  83. package/src/BunHttpServer.ts +35 -30
  84. package/src/BunHttpServerRequest.ts +1 -1
  85. package/src/BunMultipart.ts +1 -1
  86. package/src/BunRedis.ts +5 -1
  87. package/src/BunServices.ts +1 -1
  88. package/src/BunSocket.ts +1 -1
  89. package/src/BunWorker.ts +2 -2
  90. package/src/BunWorkerRunner.ts +2 -2
  91. package/src/index.ts +1 -0
@@ -8,26 +8,26 @@
8
8
  *
9
9
  * @since 4.0.0
10
10
  */
11
+ import * as HttpRunner from "effect/cluster/HttpRunner"
12
+ import * as MessageStorage from "effect/cluster/MessageStorage"
13
+ import * as RunnerHealth from "effect/cluster/RunnerHealth"
14
+ import * as Runners from "effect/cluster/Runners"
15
+ import * as RunnerStorage from "effect/cluster/RunnerStorage"
16
+ import type { Sharding } from "effect/cluster/Sharding"
17
+ import * as ShardingConfig from "effect/cluster/ShardingConfig"
18
+ import * as SqlMessageStorage from "effect/cluster/SqlMessageStorage"
19
+ import * as SqlRunnerStorage from "effect/cluster/SqlRunnerStorage"
11
20
  import type * as Config from "effect/Config"
12
21
  import * as Effect from "effect/Effect"
22
+ import type * as Etag from "effect/http/Etag"
23
+ import * as FetchHttpClient from "effect/http/FetchHttpClient"
24
+ import type { HttpPlatform } from "effect/http/HttpPlatform"
25
+ import type { HttpServer } from "effect/http/HttpServer"
26
+ import type { ServeError } from "effect/http/HttpServerError"
13
27
  import * as Layer from "effect/Layer"
14
28
  import * as Option from "effect/Option"
15
- import * as HttpRunner from "effect/unstable/cluster/HttpRunner"
16
- import * as MessageStorage from "effect/unstable/cluster/MessageStorage"
17
- import * as RunnerHealth from "effect/unstable/cluster/RunnerHealth"
18
- import * as Runners from "effect/unstable/cluster/Runners"
19
- import * as RunnerStorage from "effect/unstable/cluster/RunnerStorage"
20
- import type { Sharding } from "effect/unstable/cluster/Sharding"
21
- import * as ShardingConfig from "effect/unstable/cluster/ShardingConfig"
22
- import * as SqlMessageStorage from "effect/unstable/cluster/SqlMessageStorage"
23
- import * as SqlRunnerStorage from "effect/unstable/cluster/SqlRunnerStorage"
24
- import type * as Etag from "effect/unstable/http/Etag"
25
- import * as FetchHttpClient from "effect/unstable/http/FetchHttpClient"
26
- import type { HttpPlatform } from "effect/unstable/http/HttpPlatform"
27
- import type { HttpServer } from "effect/unstable/http/HttpServer"
28
- import type { ServeError } from "effect/unstable/http/HttpServerError"
29
- import * as RpcSerialization from "effect/unstable/rpc/RpcSerialization"
30
- import type { SqlClient } from "effect/unstable/sql/SqlClient"
29
+ import * as RpcSerialization from "effect/rpc/RpcSerialization"
30
+ import type { SqlClient } from "effect/sql/SqlClient"
31
31
  import { layerK8sHttpClient } from "./BunClusterSocket.ts"
32
32
  import * as BunCrypto from "./BunCrypto.ts"
33
33
  import * as BunFileSystem from "./BunFileSystem.ts"
@@ -10,24 +10,24 @@
10
10
  * @since 4.0.0
11
11
  */
12
12
  import { layerClientProtocol, layerSocketServer } from "@effect/platform-node-shared/NodeClusterSocket"
13
+ import * as K8sHttpClient from "effect/cluster/K8sHttpClient"
14
+ import * as MessageStorage from "effect/cluster/MessageStorage"
15
+ import * as RunnerHealth from "effect/cluster/RunnerHealth"
16
+ import * as Runners from "effect/cluster/Runners"
17
+ import * as RunnerStorage from "effect/cluster/RunnerStorage"
18
+ import type { Sharding } from "effect/cluster/Sharding"
19
+ import * as ShardingConfig from "effect/cluster/ShardingConfig"
20
+ import * as SocketRunner from "effect/cluster/SocketRunner"
21
+ import * as SqlMessageStorage from "effect/cluster/SqlMessageStorage"
22
+ import * as SqlRunnerStorage from "effect/cluster/SqlRunnerStorage"
13
23
  import type * as Config from "effect/Config"
14
24
  import * as Effect from "effect/Effect"
15
25
  import * as FileSystem from "effect/FileSystem"
26
+ import * as FetchHttpClient from "effect/http/FetchHttpClient"
16
27
  import * as Layer from "effect/Layer"
17
- import * as K8sHttpClient from "effect/unstable/cluster/K8sHttpClient"
18
- import * as MessageStorage from "effect/unstable/cluster/MessageStorage"
19
- import * as RunnerHealth from "effect/unstable/cluster/RunnerHealth"
20
- import * as Runners from "effect/unstable/cluster/Runners"
21
- import * as RunnerStorage from "effect/unstable/cluster/RunnerStorage"
22
- import type { Sharding } from "effect/unstable/cluster/Sharding"
23
- import * as ShardingConfig from "effect/unstable/cluster/ShardingConfig"
24
- import * as SocketRunner from "effect/unstable/cluster/SocketRunner"
25
- import * as SqlMessageStorage from "effect/unstable/cluster/SqlMessageStorage"
26
- import * as SqlRunnerStorage from "effect/unstable/cluster/SqlRunnerStorage"
27
- import * as FetchHttpClient from "effect/unstable/http/FetchHttpClient"
28
- import * as RpcSerialization from "effect/unstable/rpc/RpcSerialization"
29
- import type * as SocketServer from "effect/unstable/socket/SocketServer"
30
- import type { SqlClient } from "effect/unstable/sql/SqlClient"
28
+ import * as RpcSerialization from "effect/rpc/RpcSerialization"
29
+ import type * as SocketServer from "effect/socket/SocketServer"
30
+ import type { SqlClient } from "effect/sql/SqlClient"
31
31
  import * as BunCrypto from "./BunCrypto.ts"
32
32
  import * as BunFileSystem from "./BunFileSystem.ts"
33
33
 
@@ -6,4 +6,4 @@
6
6
  * @category re-exports
7
7
  * @since 4.0.0
8
8
  */
9
- export * from "effect/unstable/http/FetchHttpClient"
9
+ export * from "effect/http/FetchHttpClient"
@@ -12,10 +12,10 @@
12
12
  import * as NodeHttpCompression from "@effect/platform-node-shared/NodeHttpCompression"
13
13
  import type * as Effect from "effect/Effect"
14
14
  import type { FileSystem } from "effect/FileSystem"
15
+ import * as Etag from "effect/http/Etag"
16
+ import * as Platform from "effect/http/HttpPlatform"
17
+ import * as Response from "effect/http/HttpServerResponse"
15
18
  import * as Layer from "effect/Layer"
16
- import * as Etag from "effect/unstable/http/Etag"
17
- import * as Platform from "effect/unstable/http/HttpPlatform"
18
- import * as Response from "effect/unstable/http/HttpServerResponse"
19
19
  import * as BunFileSystem from "./BunFileSystem.ts"
20
20
 
21
21
  // Bun's CompressionStream supports an extended format set covering brotli and
@@ -13,6 +13,7 @@
13
13
  */
14
14
  import type { Server as BunServer, ServerWebSocket } from "bun"
15
15
  import type * as Arr from "effect/Array"
16
+ import * as Cause from "effect/Cause"
16
17
  import * as Config from "effect/Config"
17
18
  import type { ConfigError } from "effect/Config"
18
19
  import * as Context from "effect/Context"
@@ -23,8 +24,24 @@ import * as Exit from "effect/Exit"
23
24
  import * as Fiber from "effect/Fiber"
24
25
  import type * as FileSystem from "effect/FileSystem"
25
26
  import { constVoid, flow } from "effect/Function"
27
+ import * as Cookies from "effect/http/Cookies"
28
+ import * as Etag from "effect/http/Etag"
29
+ import * as FetchHttpClient from "effect/http/FetchHttpClient"
30
+ import * as Headers from "effect/http/Headers"
31
+ import type { HttpClient } from "effect/http/HttpClient"
32
+ import * as HttpEffect from "effect/http/HttpEffect"
33
+ import * as IncomingMessage from "effect/http/HttpIncomingMessage"
34
+ import type { HttpMethod } from "effect/http/HttpMethod"
35
+ import type { HttpPlatform } from "effect/http/HttpPlatform"
36
+ import * as Server from "effect/http/HttpServer"
37
+ import * as Error from "effect/http/HttpServerError"
38
+ import * as ServerRequest from "effect/http/HttpServerRequest"
39
+ import * as ServerResponse from "effect/http/HttpServerResponse"
40
+ import type * as Multipart from "effect/http/Multipart"
41
+ import * as UrlParams from "effect/http/UrlParams"
26
42
  import * as Inspectable from "effect/Inspectable"
27
43
  import * as Layer from "effect/Layer"
44
+ import * as NetAddress from "effect/net/NetAddress"
28
45
  import * as Option from "effect/Option"
29
46
  import type * as Path from "effect/Path"
30
47
  import type * as Record from "effect/Record"
@@ -33,24 +50,8 @@ import * as Scheduler from "effect/Scheduler"
33
50
  import type * as Schema from "effect/Schema"
34
51
  import * as Scope from "effect/Scope"
35
52
  import * as Semaphore from "effect/Semaphore"
53
+ import * as Socket from "effect/socket/Socket"
36
54
  import * as Stream from "effect/Stream"
37
- import * as Cookies from "effect/unstable/http/Cookies"
38
- import * as Etag from "effect/unstable/http/Etag"
39
- import * as FetchHttpClient from "effect/unstable/http/FetchHttpClient"
40
- import * as Headers from "effect/unstable/http/Headers"
41
- import type { HttpClient } from "effect/unstable/http/HttpClient"
42
- import * as HttpEffect from "effect/unstable/http/HttpEffect"
43
- import * as IncomingMessage from "effect/unstable/http/HttpIncomingMessage"
44
- import type { HttpMethod } from "effect/unstable/http/HttpMethod"
45
- import type { HttpPlatform } from "effect/unstable/http/HttpPlatform"
46
- import * as Server from "effect/unstable/http/HttpServer"
47
- import * as Error from "effect/unstable/http/HttpServerError"
48
- import * as ServerRequest from "effect/unstable/http/HttpServerRequest"
49
- import * as ServerResponse from "effect/unstable/http/HttpServerResponse"
50
- import type * as Multipart from "effect/unstable/http/Multipart"
51
- import * as UrlParams from "effect/unstable/http/UrlParams"
52
- import * as NetAddress from "effect/unstable/net/NetAddress"
53
- import * as Socket from "effect/unstable/socket/Socket"
54
55
  import * as Platform from "./BunHttpPlatform.ts"
55
56
  import * as BunMultipart from "./BunMultipart.ts"
56
57
  import * as BunServices from "./BunServices.ts"
@@ -689,20 +690,21 @@ class BunServerRequest extends Inspectable.Class implements ServerRequest.HttpSe
689
690
 
690
691
  ws.data.run = push
691
692
  ws.data.onClose = fail
692
- yield* Scope.addFinalizer(
693
+ yield* Scope.addFinalizerExit(
693
694
  scope,
694
- Effect.suspend(() => {
695
- // resume a pull blocked in another fiber before detaching
696
- fail(
697
- new Socket.SocketError({
698
- reason: new Socket.SocketCloseError({ code: 1006 })
699
- })
700
- )
701
- ws.data.run = wsDefaultRun
702
- ws.data.onClose = constVoid
703
- ws.close(1000)
704
- return Effect.void
705
- })
695
+ (exit) =>
696
+ Effect.suspend(() => {
697
+ // resume a pull blocked in another fiber before detaching
698
+ fail(
699
+ new Socket.SocketError({
700
+ reason: new Socket.SocketCloseError({ code: 1006 })
701
+ })
702
+ )
703
+ ws.data.run = wsDefaultRun
704
+ ws.data.onClose = constVoid
705
+ ws.close(closeCode(exit))
706
+ return Effect.void
707
+ })
706
708
  )
707
709
 
708
710
  return {
@@ -727,6 +729,9 @@ class BunServerRequest extends Inspectable.Class implements ServerRequest.HttpSe
727
729
  }
728
730
  }
729
731
 
732
+ const closeCode = (exit: Exit.Exit<unknown, unknown>): number =>
733
+ Exit.isSuccess(exit) ? 1000 : Cause.hasInterruptsOnly(exit.cause) ? 1001 : 1011
734
+
730
735
  const emptyReadbleStream = new ReadableStream({
731
736
  start(controller) {
732
737
  controller.enqueue(new Uint8Array())
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * @since 4.0.0
9
9
  */
10
- import type { HttpServerRequest } from "effect/unstable/http/HttpServerRequest"
10
+ import type { HttpServerRequest } from "effect/http/HttpServerRequest"
11
11
 
12
12
  /**
13
13
  * Returns the underlying `Bun.BunRequest` from an Effect `HttpServerRequest`.
@@ -10,10 +10,10 @@
10
10
  */
11
11
  import type * as Effect from "effect/Effect"
12
12
  import type { FileSystem } from "effect/FileSystem"
13
+ import * as Multipart from "effect/http/Multipart"
13
14
  import type { Path } from "effect/Path"
14
15
  import type * as Scope from "effect/Scope"
15
16
  import * as Stream from "effect/Stream"
16
- import * as Multipart from "effect/unstable/http/Multipart"
17
17
  import * as BunStream from "./BunStream.ts"
18
18
 
19
19
  /**
package/src/BunRedis.ts CHANGED
@@ -7,6 +7,7 @@
7
7
  * directly, while `layerConfig` reads them from Effect config. Both close the
8
8
  * underlying client when the layer scope finalizes.
9
9
  *
10
+ * @stability unstable
10
11
  * @since 4.0.0
11
12
  */
12
13
  import type { RedisClient, RedisOptions } from "bun"
@@ -16,12 +17,13 @@ import * as Deferred from "effect/Deferred"
16
17
  import * as Effect from "effect/Effect"
17
18
  import * as Fn from "effect/Function"
18
19
  import * as Layer from "effect/Layer"
20
+ import * as Redis from "effect/persistence/Redis"
19
21
  import * as Scope from "effect/Scope"
20
- import * as Redis from "effect/unstable/persistence/Redis"
21
22
 
22
23
  /**
23
24
  * Service tag for Bun Redis integration, exposing the raw `RedisClient` and a `use` helper that maps client promise failures to `RedisError`.
24
25
  *
26
+ * @stability unstable
25
27
  * @category services
26
28
  * @since 4.0.0
27
29
  */
@@ -101,6 +103,7 @@ const make = Effect.fnUntraced(function*(
101
103
  /**
102
104
  * Creates scoped Bun Redis layers for `Redis.Redis` and `BunRedis`, closing the underlying client when the scope finalizes.
103
105
  *
106
+ * @stability unstable
104
107
  * @category layers
105
108
  * @since 4.0.0
106
109
  */
@@ -111,6 +114,7 @@ export const layer = (
111
114
  /**
112
115
  * Creates scoped Bun Redis layers from configurable Redis options, closing the underlying client when the scope finalizes.
113
116
  *
117
+ * @stability unstable
114
118
  * @category layers
115
119
  * @since 4.0.0
116
120
  */
@@ -12,9 +12,9 @@ import type { Crypto } from "effect/Crypto"
12
12
  import type { FileSystem } from "effect/FileSystem"
13
13
  import * as Layer from "effect/Layer"
14
14
  import type { Path } from "effect/Path"
15
+ import type { ChildProcessSpawner } from "effect/process/ChildProcessSpawner"
15
16
  import type { Stdio } from "effect/Stdio"
16
17
  import type { Terminal } from "effect/Terminal"
17
- import type { ChildProcessSpawner } from "effect/unstable/process/ChildProcessSpawner"
18
18
  import * as BunChildProcessSpawner from "./BunChildProcessSpawner.ts"
19
19
  import * as BunCrypto from "./BunCrypto.ts"
20
20
  import * as BunFileSystem from "./BunFileSystem.ts"
package/src/BunSocket.ts CHANGED
@@ -12,7 +12,7 @@ import type * as Duration from "effect/Duration"
12
12
  import type { Effect } from "effect/Effect"
13
13
  import { flow } from "effect/Function"
14
14
  import * as Layer from "effect/Layer"
15
- import * as Socket from "effect/unstable/socket/Socket"
15
+ import * as Socket from "effect/socket/Socket"
16
16
 
17
17
  /**
18
18
  * @since 4.0.0
package/src/BunWorker.ts CHANGED
@@ -15,8 +15,8 @@ import * as Effect from "effect/Effect"
15
15
  import * as Exit from "effect/Exit"
16
16
  import * as Layer from "effect/Layer"
17
17
  import * as Scope from "effect/Scope"
18
- import * as Worker from "effect/unstable/workers/Worker"
19
- import { WorkerError, WorkerUnknownError } from "effect/unstable/workers/WorkerError"
18
+ import * as Worker from "effect/workers/Worker"
19
+ import { WorkerError, WorkerUnknownError } from "effect/workers/WorkerError"
20
20
 
21
21
  /**
22
22
  * Provides the Bun `WorkerPlatform` together with a `Worker.Spawner` created
@@ -17,8 +17,8 @@ import * as Fiber from "effect/Fiber"
17
17
  import { identity } from "effect/Function"
18
18
  import * as Layer from "effect/Layer"
19
19
  import * as Scope from "effect/Scope"
20
- import { WorkerError, WorkerReceiveError, WorkerSpawnError } from "effect/unstable/workers/WorkerError"
21
- import * as WorkerRunner from "effect/unstable/workers/WorkerRunner"
20
+ import { WorkerError, WorkerReceiveError, WorkerSpawnError } from "effect/workers/WorkerError"
21
+ import * as WorkerRunner from "effect/workers/WorkerRunner"
22
22
 
23
23
  declare const self: MessagePort
24
24
 
package/src/index.ts CHANGED
@@ -60,6 +60,7 @@ export * as BunMultipart from "./BunMultipart.ts"
60
60
  export * as BunPath from "./BunPath.ts"
61
61
 
62
62
  /**
63
+ * @stability unstable
63
64
  * @since 4.0.0
64
65
  */
65
66
  export * as BunRedis from "./BunRedis.ts"