effect 4.0.0-beta.31 → 4.0.0-beta.33

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 (481) hide show
  1. package/dist/Array.d.ts +87 -86
  2. package/dist/Array.d.ts.map +1 -1
  3. package/dist/Array.js +47 -40
  4. package/dist/Array.js.map +1 -1
  5. package/dist/BigDecimal.d.ts +46 -45
  6. package/dist/BigDecimal.d.ts.map +1 -1
  7. package/dist/BigDecimal.js +35 -38
  8. package/dist/BigDecimal.js.map +1 -1
  9. package/dist/BigInt.d.ts +39 -32
  10. package/dist/BigInt.d.ts.map +1 -1
  11. package/dist/BigInt.js +32 -29
  12. package/dist/BigInt.js.map +1 -1
  13. package/dist/Chunk.d.ts +58 -57
  14. package/dist/Chunk.d.ts.map +1 -1
  15. package/dist/Chunk.js +20 -21
  16. package/dist/Chunk.js.map +1 -1
  17. package/dist/Config.d.ts.map +1 -1
  18. package/dist/Config.js +4 -1
  19. package/dist/Config.js.map +1 -1
  20. package/dist/Cron.d.ts +3 -6
  21. package/dist/Cron.d.ts.map +1 -1
  22. package/dist/Cron.js +8 -15
  23. package/dist/Cron.js.map +1 -1
  24. package/dist/DateTime.d.ts +16 -15
  25. package/dist/DateTime.d.ts.map +1 -1
  26. package/dist/DateTime.js +8 -8
  27. package/dist/DateTime.js.map +1 -1
  28. package/dist/Deferred.d.ts +7 -5
  29. package/dist/Deferred.d.ts.map +1 -1
  30. package/dist/Deferred.js +7 -5
  31. package/dist/Deferred.js.map +1 -1
  32. package/dist/Duration.d.ts +26 -24
  33. package/dist/Duration.d.ts.map +1 -1
  34. package/dist/Duration.js +23 -22
  35. package/dist/Duration.js.map +1 -1
  36. package/dist/Effect.d.ts +7 -3
  37. package/dist/Effect.d.ts.map +1 -1
  38. package/dist/Effect.js +3 -4
  39. package/dist/Effect.js.map +1 -1
  40. package/dist/Fiber.d.ts +2 -1
  41. package/dist/Fiber.d.ts.map +1 -1
  42. package/dist/Fiber.js.map +1 -1
  43. package/dist/FiberHandle.d.ts +9 -8
  44. package/dist/FiberHandle.d.ts.map +1 -1
  45. package/dist/FiberHandle.js +8 -7
  46. package/dist/FiberHandle.js.map +1 -1
  47. package/dist/FiberMap.d.ts +20 -19
  48. package/dist/FiberMap.d.ts.map +1 -1
  49. package/dist/FiberMap.js +6 -6
  50. package/dist/FiberMap.js.map +1 -1
  51. package/dist/FileSystem.d.ts +17 -16
  52. package/dist/FileSystem.d.ts.map +1 -1
  53. package/dist/FileSystem.js +10 -7
  54. package/dist/FileSystem.js.map +1 -1
  55. package/dist/Graph.d.ts +64 -64
  56. package/dist/Graph.d.ts.map +1 -1
  57. package/dist/Graph.js +53 -53
  58. package/dist/Graph.js.map +1 -1
  59. package/dist/HashMap.d.ts +11 -5
  60. package/dist/HashMap.d.ts.map +1 -1
  61. package/dist/HashMap.js +3 -1
  62. package/dist/HashMap.js.map +1 -1
  63. package/dist/Iterable.d.ts +11 -11
  64. package/dist/Iterable.d.ts.map +1 -1
  65. package/dist/Iterable.js +12 -12
  66. package/dist/Iterable.js.map +1 -1
  67. package/dist/Latch.d.ts +69 -3
  68. package/dist/Latch.d.ts.map +1 -1
  69. package/dist/Latch.js +58 -0
  70. package/dist/Latch.js.map +1 -1
  71. package/dist/Layer.d.ts +84 -0
  72. package/dist/Layer.d.ts.map +1 -1
  73. package/dist/Layer.js +27 -0
  74. package/dist/Layer.js.map +1 -1
  75. package/dist/Number.d.ts +74 -18
  76. package/dist/Number.d.ts.map +1 -1
  77. package/dist/Number.js +34 -15
  78. package/dist/Number.js.map +1 -1
  79. package/dist/Option.d.ts +2 -0
  80. package/dist/Option.d.ts.map +1 -1
  81. package/dist/Option.js.map +1 -1
  82. package/dist/PartitionedSemaphore.d.ts +183 -0
  83. package/dist/PartitionedSemaphore.d.ts.map +1 -0
  84. package/dist/PartitionedSemaphore.js +231 -0
  85. package/dist/PartitionedSemaphore.js.map +1 -0
  86. package/dist/PubSub.d.ts +5 -4
  87. package/dist/PubSub.d.ts.map +1 -1
  88. package/dist/PubSub.js +6 -5
  89. package/dist/PubSub.js.map +1 -1
  90. package/dist/Queue.d.ts +4 -4
  91. package/dist/Queue.d.ts.map +1 -1
  92. package/dist/Queue.js +2 -2
  93. package/dist/Queue.js.map +1 -1
  94. package/dist/Record.d.ts +40 -40
  95. package/dist/Record.d.ts.map +1 -1
  96. package/dist/Record.js +16 -15
  97. package/dist/Record.js.map +1 -1
  98. package/dist/Scheduler.d.ts +25 -123
  99. package/dist/Scheduler.d.ts.map +1 -1
  100. package/dist/Scheduler.js +20 -123
  101. package/dist/Scheduler.js.map +1 -1
  102. package/dist/Schema.d.ts +30 -0
  103. package/dist/Schema.d.ts.map +1 -1
  104. package/dist/Schema.js +28 -1
  105. package/dist/Schema.js.map +1 -1
  106. package/dist/SchemaGetter.js +6 -4
  107. package/dist/SchemaGetter.js.map +1 -1
  108. package/dist/SchemaTransformation.d.ts.map +1 -1
  109. package/dist/SchemaTransformation.js +32 -27
  110. package/dist/SchemaTransformation.js.map +1 -1
  111. package/dist/Semaphore.d.ts +149 -53
  112. package/dist/Semaphore.d.ts.map +1 -1
  113. package/dist/Semaphore.js +137 -117
  114. package/dist/Semaphore.js.map +1 -1
  115. package/dist/ServiceMap.d.ts +26 -0
  116. package/dist/ServiceMap.d.ts.map +1 -1
  117. package/dist/ServiceMap.js +36 -21
  118. package/dist/ServiceMap.js.map +1 -1
  119. package/dist/Stream.js +1 -1
  120. package/dist/Stream.js.map +1 -1
  121. package/dist/String.d.ts +114 -47
  122. package/dist/String.d.ts.map +1 -1
  123. package/dist/String.js +29 -47
  124. package/dist/String.js.map +1 -1
  125. package/dist/SubscriptionRef.d.ts +1 -2
  126. package/dist/SubscriptionRef.d.ts.map +1 -1
  127. package/dist/SubscriptionRef.js +81 -115
  128. package/dist/SubscriptionRef.js.map +1 -1
  129. package/dist/Terminal.d.ts +2 -1
  130. package/dist/Terminal.d.ts.map +1 -1
  131. package/dist/Terminal.js.map +1 -1
  132. package/dist/Tracer.d.ts +5 -4
  133. package/dist/Tracer.d.ts.map +1 -1
  134. package/dist/Tracer.js +2 -1
  135. package/dist/Tracer.js.map +1 -1
  136. package/dist/Trie.d.ts +26 -14
  137. package/dist/Trie.d.ts.map +1 -1
  138. package/dist/Trie.js +8 -4
  139. package/dist/Trie.js.map +1 -1
  140. package/dist/TxHashMap.d.ts +77 -59
  141. package/dist/TxHashMap.d.ts.map +1 -1
  142. package/dist/TxHashMap.js +25 -19
  143. package/dist/TxHashMap.js.map +1 -1
  144. package/dist/TxSemaphore.d.ts +162 -2
  145. package/dist/TxSemaphore.d.ts.map +1 -1
  146. package/dist/TxSemaphore.js +16 -2
  147. package/dist/TxSemaphore.js.map +1 -1
  148. package/dist/index.d.ts +88 -32
  149. package/dist/index.d.ts.map +1 -1
  150. package/dist/index.js +88 -32
  151. package/dist/index.js.map +1 -1
  152. package/dist/internal/dateTime.js +9 -9
  153. package/dist/internal/dateTime.js.map +1 -1
  154. package/dist/internal/effect.js +20 -89
  155. package/dist/internal/effect.js.map +1 -1
  156. package/dist/internal/hashMap.js +2 -1
  157. package/dist/internal/hashMap.js.map +1 -1
  158. package/dist/internal/option.js +6 -0
  159. package/dist/internal/option.js.map +1 -1
  160. package/dist/internal/trie.js +3 -3
  161. package/dist/internal/trie.js.map +1 -1
  162. package/dist/unstable/ai/AiError.js +1 -1
  163. package/dist/unstable/ai/AiError.js.map +1 -1
  164. package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
  165. package/dist/unstable/ai/AnthropicStructuredOutput.js +4 -0
  166. package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
  167. package/dist/unstable/ai/Chat.d.ts.map +1 -1
  168. package/dist/unstable/ai/Chat.js +2 -2
  169. package/dist/unstable/ai/Chat.js.map +1 -1
  170. package/dist/unstable/ai/LanguageModel.d.ts +8 -0
  171. package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
  172. package/dist/unstable/ai/LanguageModel.js +112 -11
  173. package/dist/unstable/ai/LanguageModel.js.map +1 -1
  174. package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
  175. package/dist/unstable/ai/OpenAiStructuredOutput.js +4 -0
  176. package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
  177. package/dist/unstable/ai/ResponseIdTracker.d.ts +38 -0
  178. package/dist/unstable/ai/ResponseIdTracker.d.ts.map +1 -0
  179. package/dist/unstable/ai/ResponseIdTracker.js +68 -0
  180. package/dist/unstable/ai/ResponseIdTracker.js.map +1 -0
  181. package/dist/unstable/ai/Tool.d.ts +14 -0
  182. package/dist/unstable/ai/Tool.d.ts.map +1 -1
  183. package/dist/unstable/ai/Tool.js +13 -0
  184. package/dist/unstable/ai/Tool.js.map +1 -1
  185. package/dist/unstable/ai/index.d.ts +4 -0
  186. package/dist/unstable/ai/index.d.ts.map +1 -1
  187. package/dist/unstable/ai/index.js +4 -0
  188. package/dist/unstable/ai/index.js.map +1 -1
  189. package/dist/unstable/cli/Argument.d.ts +2 -4
  190. package/dist/unstable/cli/Argument.d.ts.map +1 -1
  191. package/dist/unstable/cli/Argument.js +1 -3
  192. package/dist/unstable/cli/Argument.js.map +1 -1
  193. package/dist/unstable/cli/CliOutput.d.ts +3 -2
  194. package/dist/unstable/cli/CliOutput.d.ts.map +1 -1
  195. package/dist/unstable/cli/CliOutput.js +4 -3
  196. package/dist/unstable/cli/CliOutput.js.map +1 -1
  197. package/dist/unstable/cli/Command.d.ts +3 -2
  198. package/dist/unstable/cli/Command.d.ts.map +1 -1
  199. package/dist/unstable/cli/Command.js +3 -3
  200. package/dist/unstable/cli/Command.js.map +1 -1
  201. package/dist/unstable/cli/Flag.d.ts +2 -2
  202. package/dist/unstable/cli/Flag.d.ts.map +1 -1
  203. package/dist/unstable/cli/Flag.js +1 -1
  204. package/dist/unstable/cli/Flag.js.map +1 -1
  205. package/dist/unstable/cli/HelpDoc.d.ts +14 -12
  206. package/dist/unstable/cli/HelpDoc.d.ts.map +1 -1
  207. package/dist/unstable/cli/Param.d.ts +4 -4
  208. package/dist/unstable/cli/Param.d.ts.map +1 -1
  209. package/dist/unstable/cli/Param.js +7 -7
  210. package/dist/unstable/cli/Param.js.map +1 -1
  211. package/dist/unstable/cli/Primitive.d.ts +1 -1
  212. package/dist/unstable/cli/Primitive.d.ts.map +1 -1
  213. package/dist/unstable/cli/Primitive.js.map +1 -1
  214. package/dist/unstable/cli/Prompt.js +71 -67
  215. package/dist/unstable/cli/Prompt.js.map +1 -1
  216. package/dist/unstable/cli/internal/completions/CommandDescriptor.js +9 -2
  217. package/dist/unstable/cli/internal/completions/CommandDescriptor.js.map +1 -1
  218. package/dist/unstable/cli/internal/parser.js +8 -3
  219. package/dist/unstable/cli/internal/parser.js.map +1 -1
  220. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts +3 -2
  221. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
  222. package/dist/unstable/cluster/ClusterWorkflowEngine.js +25 -23
  223. package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
  224. package/dist/unstable/cluster/Entity.d.ts +3 -2
  225. package/dist/unstable/cluster/Entity.d.ts.map +1 -1
  226. package/dist/unstable/cluster/Entity.js +7 -7
  227. package/dist/unstable/cluster/Entity.js.map +1 -1
  228. package/dist/unstable/cluster/Message.d.ts +4 -3
  229. package/dist/unstable/cluster/Message.d.ts.map +1 -1
  230. package/dist/unstable/cluster/Message.js +3 -2
  231. package/dist/unstable/cluster/Message.js.map +1 -1
  232. package/dist/unstable/cluster/MessageStorage.d.ts +10 -10
  233. package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
  234. package/dist/unstable/cluster/MessageStorage.js +12 -12
  235. package/dist/unstable/cluster/MessageStorage.js.map +1 -1
  236. package/dist/unstable/cluster/Reply.d.ts +2 -1
  237. package/dist/unstable/cluster/Reply.d.ts.map +1 -1
  238. package/dist/unstable/cluster/Reply.js +4 -3
  239. package/dist/unstable/cluster/Reply.js.map +1 -1
  240. package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
  241. package/dist/unstable/cluster/RunnerServer.js +9 -8
  242. package/dist/unstable/cluster/RunnerServer.js.map +1 -1
  243. package/dist/unstable/cluster/Runners.d.ts +2 -1
  244. package/dist/unstable/cluster/Runners.d.ts.map +1 -1
  245. package/dist/unstable/cluster/Runners.js +7 -6
  246. package/dist/unstable/cluster/Runners.js.map +1 -1
  247. package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
  248. package/dist/unstable/cluster/Sharding.js +19 -13
  249. package/dist/unstable/cluster/Sharding.js.map +1 -1
  250. package/dist/unstable/cluster/ShardingConfig.d.ts +5 -4
  251. package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
  252. package/dist/unstable/cluster/ShardingConfig.js +4 -4
  253. package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
  254. package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
  255. package/dist/unstable/cluster/SqlMessageStorage.js +19 -18
  256. package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
  257. package/dist/unstable/cluster/internal/entityManager.js +9 -10
  258. package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
  259. package/dist/unstable/devtools/DevToolsSchema.d.ts +2 -1
  260. package/dist/unstable/devtools/DevToolsSchema.d.ts.map +1 -1
  261. package/dist/unstable/devtools/DevToolsSchema.js +1 -4
  262. package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
  263. package/dist/unstable/http/Cookies.d.ts +5 -4
  264. package/dist/unstable/http/Cookies.d.ts.map +1 -1
  265. package/dist/unstable/http/Cookies.js +3 -4
  266. package/dist/unstable/http/Cookies.js.map +1 -1
  267. package/dist/unstable/http/Etag.d.ts.map +1 -1
  268. package/dist/unstable/http/Etag.js +5 -1
  269. package/dist/unstable/http/Etag.js.map +1 -1
  270. package/dist/unstable/http/Headers.d.ts +3 -2
  271. package/dist/unstable/http/Headers.d.ts.map +1 -1
  272. package/dist/unstable/http/Headers.js +2 -1
  273. package/dist/unstable/http/Headers.js.map +1 -1
  274. package/dist/unstable/http/HttpClient.d.ts.map +1 -1
  275. package/dist/unstable/http/HttpClient.js +2 -1
  276. package/dist/unstable/http/HttpClient.js.map +1 -1
  277. package/dist/unstable/http/HttpClientRequest.d.ts +4 -3
  278. package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
  279. package/dist/unstable/http/HttpClientRequest.js +8 -6
  280. package/dist/unstable/http/HttpClientRequest.js.map +1 -1
  281. package/dist/unstable/http/HttpClientResponse.d.ts.map +1 -1
  282. package/dist/unstable/http/HttpClientResponse.js +2 -1
  283. package/dist/unstable/http/HttpClientResponse.js.map +1 -1
  284. package/dist/unstable/http/HttpIncomingMessage.d.ts +2 -1
  285. package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
  286. package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
  287. package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
  288. package/dist/unstable/http/HttpMiddleware.js +16 -15
  289. package/dist/unstable/http/HttpMiddleware.js.map +1 -1
  290. package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
  291. package/dist/unstable/http/HttpPlatform.js +3 -2
  292. package/dist/unstable/http/HttpPlatform.js.map +1 -1
  293. package/dist/unstable/http/HttpRouter.d.ts +2 -1
  294. package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
  295. package/dist/unstable/http/HttpRouter.js +7 -7
  296. package/dist/unstable/http/HttpRouter.js.map +1 -1
  297. package/dist/unstable/http/HttpServer.d.ts.map +1 -1
  298. package/dist/unstable/http/HttpServer.js +2 -2
  299. package/dist/unstable/http/HttpServer.js.map +1 -1
  300. package/dist/unstable/http/HttpServerError.d.ts +2 -1
  301. package/dist/unstable/http/HttpServerError.d.ts.map +1 -1
  302. package/dist/unstable/http/HttpServerError.js +2 -1
  303. package/dist/unstable/http/HttpServerError.js.map +1 -1
  304. package/dist/unstable/http/HttpServerRequest.d.ts +3 -2
  305. package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
  306. package/dist/unstable/http/HttpServerRequest.js +14 -10
  307. package/dist/unstable/http/HttpServerRequest.js.map +1 -1
  308. package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
  309. package/dist/unstable/http/HttpServerResponse.js +4 -3
  310. package/dist/unstable/http/HttpServerResponse.js.map +1 -1
  311. package/dist/unstable/http/HttpTraceContext.d.ts +3 -2
  312. package/dist/unstable/http/HttpTraceContext.d.ts.map +1 -1
  313. package/dist/unstable/http/HttpTraceContext.js +27 -15
  314. package/dist/unstable/http/HttpTraceContext.js.map +1 -1
  315. package/dist/unstable/http/UrlParams.d.ts +5 -4
  316. package/dist/unstable/http/UrlParams.d.ts.map +1 -1
  317. package/dist/unstable/http/UrlParams.js +5 -6
  318. package/dist/unstable/http/UrlParams.js.map +1 -1
  319. package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
  320. package/dist/unstable/httpapi/HttpApiBuilder.js +4 -2
  321. package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
  322. package/dist/unstable/httpapi/HttpApiError.d.ts +15 -0
  323. package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
  324. package/dist/unstable/httpapi/HttpApiError.js +81 -3
  325. package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
  326. package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
  327. package/dist/unstable/observability/OtlpExporter.js +2 -2
  328. package/dist/unstable/observability/OtlpExporter.js.map +1 -1
  329. package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
  330. package/dist/unstable/observability/OtlpTracer.js +7 -3
  331. package/dist/unstable/observability/OtlpTracer.js.map +1 -1
  332. package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
  333. package/dist/unstable/reactivity/Atom.js +1 -5
  334. package/dist/unstable/reactivity/Atom.js.map +1 -1
  335. package/dist/unstable/reactivity/AtomRegistry.d.ts.map +1 -1
  336. package/dist/unstable/reactivity/AtomRegistry.js +4 -2
  337. package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
  338. package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
  339. package/dist/unstable/rpc/Rpc.js +4 -3
  340. package/dist/unstable/rpc/Rpc.js.map +1 -1
  341. package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
  342. package/dist/unstable/rpc/RpcClient.js +4 -4
  343. package/dist/unstable/rpc/RpcClient.js.map +1 -1
  344. package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
  345. package/dist/unstable/rpc/RpcSchema.js +3 -2
  346. package/dist/unstable/rpc/RpcSchema.js.map +1 -1
  347. package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
  348. package/dist/unstable/rpc/RpcSerialization.js +4 -1
  349. package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
  350. package/dist/unstable/rpc/RpcServer.d.ts +1 -1
  351. package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
  352. package/dist/unstable/rpc/RpcServer.js +3 -2
  353. package/dist/unstable/rpc/RpcServer.js.map +1 -1
  354. package/dist/unstable/socket/Socket.d.ts +2 -1
  355. package/dist/unstable/socket/Socket.d.ts.map +1 -1
  356. package/dist/unstable/socket/Socket.js +5 -3
  357. package/dist/unstable/socket/Socket.js.map +1 -1
  358. package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
  359. package/dist/unstable/sql/SqlClient.js +1 -1
  360. package/dist/unstable/sql/SqlClient.js.map +1 -1
  361. package/dist/unstable/workflow/DurableDeferred.js +6 -6
  362. package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
  363. package/dist/unstable/workflow/Workflow.d.ts +2 -1
  364. package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
  365. package/dist/unstable/workflow/WorkflowEngine.d.ts +5 -4
  366. package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
  367. package/dist/unstable/workflow/WorkflowEngine.js +19 -14
  368. package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
  369. package/package.json +1 -1
  370. package/src/Array.ts +112 -105
  371. package/src/BigDecimal.ts +63 -66
  372. package/src/BigInt.ts +49 -41
  373. package/src/Chunk.ts +68 -63
  374. package/src/Config.ts +4 -1
  375. package/src/Cron.ts +10 -15
  376. package/src/DateTime.ts +16 -15
  377. package/src/Deferred.ts +8 -6
  378. package/src/Duration.ts +34 -33
  379. package/src/Effect.ts +12 -23
  380. package/src/Fiber.ts +2 -1
  381. package/src/FiberHandle.ts +10 -9
  382. package/src/FiberMap.ts +22 -22
  383. package/src/FileSystem.ts +25 -22
  384. package/src/Graph.ts +105 -105
  385. package/src/HashMap.ts +11 -5
  386. package/src/Iterable.ts +13 -13
  387. package/src/Latch.ts +85 -3
  388. package/src/Layer.ts +121 -0
  389. package/src/Number.ts +85 -26
  390. package/src/Option.ts +2 -0
  391. package/src/PartitionedSemaphore.ts +414 -0
  392. package/src/PubSub.ts +7 -6
  393. package/src/Queue.ts +6 -6
  394. package/src/Record.ts +52 -47
  395. package/src/Scheduler.ts +37 -126
  396. package/src/Schema.ts +49 -1
  397. package/src/SchemaGetter.ts +4 -4
  398. package/src/SchemaTransformation.ts +27 -27
  399. package/src/Semaphore.ts +271 -183
  400. package/src/ServiceMap.ts +83 -31
  401. package/src/Stream.ts +1 -1
  402. package/src/String.ts +122 -69
  403. package/src/SubscriptionRef.ts +96 -117
  404. package/src/Terminal.ts +2 -1
  405. package/src/Tracer.ts +6 -5
  406. package/src/Trie.ts +26 -14
  407. package/src/TxHashMap.ts +78 -60
  408. package/src/TxSemaphore.ts +186 -11
  409. package/src/index.ts +89 -33
  410. package/src/internal/dateTime.ts +14 -14
  411. package/src/internal/effect.ts +29 -121
  412. package/src/internal/hashMap.ts +4 -3
  413. package/src/internal/option.ts +7 -0
  414. package/src/internal/trie.ts +6 -6
  415. package/src/unstable/ai/AiError.ts +1 -1
  416. package/src/unstable/ai/AnthropicStructuredOutput.ts +4 -0
  417. package/src/unstable/ai/Chat.ts +6 -2
  418. package/src/unstable/ai/LanguageModel.ts +192 -65
  419. package/src/unstable/ai/OpenAiStructuredOutput.ts +4 -0
  420. package/src/unstable/ai/ResponseIdTracker.ts +97 -0
  421. package/src/unstable/ai/Tool.ts +20 -0
  422. package/src/unstable/ai/index.ts +5 -0
  423. package/src/unstable/cli/Argument.ts +2 -4
  424. package/src/unstable/cli/CliOutput.ts +7 -5
  425. package/src/unstable/cli/Command.ts +5 -5
  426. package/src/unstable/cli/Flag.ts +2 -2
  427. package/src/unstable/cli/HelpDoc.ts +14 -12
  428. package/src/unstable/cli/Param.ts +15 -11
  429. package/src/unstable/cli/Primitive.ts +1 -1
  430. package/src/unstable/cli/Prompt.ts +81 -83
  431. package/src/unstable/cli/internal/completions/CommandDescriptor.ts +3 -2
  432. package/src/unstable/cli/internal/parser.ts +7 -4
  433. package/src/unstable/cluster/ClusterWorkflowEngine.ts +35 -30
  434. package/src/unstable/cluster/Entity.ts +13 -12
  435. package/src/unstable/cluster/Message.ts +6 -5
  436. package/src/unstable/cluster/MessageStorage.ts +26 -25
  437. package/src/unstable/cluster/Reply.ts +7 -4
  438. package/src/unstable/cluster/RunnerServer.ts +10 -13
  439. package/src/unstable/cluster/Runners.ts +8 -7
  440. package/src/unstable/cluster/Sharding.ts +24 -17
  441. package/src/unstable/cluster/ShardingConfig.ts +6 -6
  442. package/src/unstable/cluster/SqlMessageStorage.ts +21 -18
  443. package/src/unstable/cluster/internal/entityManager.ts +27 -21
  444. package/src/unstable/devtools/DevToolsSchema.ts +3 -2
  445. package/src/unstable/http/Cookies.ts +7 -8
  446. package/src/unstable/http/Etag.ts +5 -3
  447. package/src/unstable/http/Headers.ts +6 -5
  448. package/src/unstable/http/HttpClient.ts +2 -1
  449. package/src/unstable/http/HttpClientRequest.ts +11 -9
  450. package/src/unstable/http/HttpClientResponse.ts +3 -2
  451. package/src/unstable/http/HttpIncomingMessage.ts +2 -1
  452. package/src/unstable/http/HttpMiddleware.ts +16 -15
  453. package/src/unstable/http/HttpPlatform.ts +3 -2
  454. package/src/unstable/http/HttpRouter.ts +9 -9
  455. package/src/unstable/http/HttpServer.ts +3 -9
  456. package/src/unstable/http/HttpServerError.ts +3 -2
  457. package/src/unstable/http/HttpServerRequest.ts +25 -21
  458. package/src/unstable/http/HttpServerResponse.ts +5 -4
  459. package/src/unstable/http/HttpTraceContext.ts +31 -17
  460. package/src/unstable/http/UrlParams.ts +11 -14
  461. package/src/unstable/httpapi/HttpApiBuilder.ts +9 -3
  462. package/src/unstable/httpapi/HttpApiError.ts +67 -12
  463. package/src/unstable/observability/OtlpExporter.ts +5 -2
  464. package/src/unstable/observability/OtlpTracer.ts +8 -4
  465. package/src/unstable/reactivity/Atom.ts +1 -4
  466. package/src/unstable/reactivity/AtomRegistry.ts +5 -3
  467. package/src/unstable/rpc/Rpc.ts +4 -3
  468. package/src/unstable/rpc/RpcClient.ts +10 -9
  469. package/src/unstable/rpc/RpcSchema.ts +6 -5
  470. package/src/unstable/rpc/RpcSerialization.ts +4 -1
  471. package/src/unstable/rpc/RpcServer.ts +3 -3
  472. package/src/unstable/socket/Socket.ts +14 -9
  473. package/src/unstable/sql/SqlClient.ts +5 -3
  474. package/src/unstable/workflow/DurableDeferred.ts +6 -6
  475. package/src/unstable/workflow/Workflow.ts +1 -1
  476. package/src/unstable/workflow/WorkflowEngine.ts +29 -20
  477. package/dist/NullOr.d.ts +0 -149
  478. package/dist/NullOr.d.ts.map +0 -1
  479. package/dist/NullOr.js +0 -152
  480. package/dist/NullOr.js.map +0 -1
  481. package/src/NullOr.ts +0 -204
@@ -1,12 +1,28 @@
1
1
  /**
2
2
  * @since 4.0.0
3
3
  */
4
+ import * as Effect from "../../Effect.ts"
4
5
  import * as ErrorReporter from "../../ErrorReporter.ts"
5
6
  import { identity } from "../../Function.ts"
6
7
  import * as Schema from "../../Schema.ts"
7
8
  import * as Transformation from "../../SchemaTransformation.ts"
9
+ import * as HttpServerRespondable from "../http/HttpServerRespondable.ts"
10
+ import * as HttpServerResponse from "../http/HttpServerResponse.ts"
8
11
  import * as HttpApiSchema from "./HttpApiSchema.ts"
9
12
 
13
+ const badRequestResponse = HttpServerResponse.empty({ status: 400 })
14
+ const unauthorizedResponse = HttpServerResponse.empty({ status: 401 })
15
+ const forbiddenResponse = HttpServerResponse.empty({ status: 403 })
16
+ const notFoundResponse = HttpServerResponse.empty({ status: 404 })
17
+ const methodNotAllowedResponse = HttpServerResponse.empty({ status: 405 })
18
+ const notAcceptableResponse = HttpServerResponse.empty({ status: 406 })
19
+ const requestTimeoutResponse = HttpServerResponse.empty({ status: 408 })
20
+ const conflictResponse = HttpServerResponse.empty({ status: 409 })
21
+ const goneResponse = HttpServerResponse.empty({ status: 410 })
22
+ const internalServerErrorResponse = HttpServerResponse.empty({ status: 500 })
23
+ const notImplementedResponse = HttpServerResponse.empty({ status: 501 })
24
+ const serviceUnavailableResponse = HttpServerResponse.empty({ status: 503 })
25
+
10
26
  /**
11
27
  * @category Built-in errors
12
28
  * @since 4.0.0
@@ -17,7 +33,10 @@ export class BadRequest extends Schema.ErrorClass<BadRequest>("effect/HttpApiErr
17
33
  description: "BadRequest",
18
34
  httpApiStatus: 400
19
35
  }) {
20
- override readonly [ErrorReporter.ignore] = true
36
+ override readonly [ErrorReporter.ignore] = true;
37
+ [HttpServerRespondable.symbol]() {
38
+ return Effect.succeed(badRequestResponse)
39
+ }
21
40
  static readonly singleton = new BadRequest()
22
41
  }
23
42
 
@@ -59,7 +78,10 @@ export class Unauthorized extends Schema.ErrorClass<Unauthorized>("effect/HttpAp
59
78
  description: "Unauthorized",
60
79
  httpApiStatus: 401
61
80
  }) {
62
- override readonly [ErrorReporter.ignore] = true
81
+ override readonly [ErrorReporter.ignore] = true;
82
+ [HttpServerRespondable.symbol]() {
83
+ return Effect.succeed(unauthorizedResponse)
84
+ }
63
85
  }
64
86
 
65
87
  /**
@@ -80,7 +102,10 @@ export class Forbidden extends Schema.ErrorClass<Forbidden>("effect/HttpApiError
80
102
  description: "Forbidden",
81
103
  httpApiStatus: 403
82
104
  }) {
83
- override readonly [ErrorReporter.ignore] = true
105
+ override readonly [ErrorReporter.ignore] = true;
106
+ [HttpServerRespondable.symbol]() {
107
+ return Effect.succeed(forbiddenResponse)
108
+ }
84
109
  }
85
110
 
86
111
  /**
@@ -101,7 +126,10 @@ export class NotFound extends Schema.ErrorClass<NotFound>("effect/HttpApiError/N
101
126
  description: "NotFound",
102
127
  httpApiStatus: 404
103
128
  }) {
104
- override readonly [ErrorReporter.ignore] = true
129
+ override readonly [ErrorReporter.ignore] = true;
130
+ [HttpServerRespondable.symbol]() {
131
+ return Effect.succeed(notFoundResponse)
132
+ }
105
133
  }
106
134
 
107
135
  /**
@@ -122,7 +150,10 @@ export class MethodNotAllowed extends Schema.ErrorClass<MethodNotAllowed>("effec
122
150
  description: "MethodNotAllowed",
123
151
  httpApiStatus: 405
124
152
  }) {
125
- override readonly [ErrorReporter.ignore] = true
153
+ override readonly [ErrorReporter.ignore] = true;
154
+ [HttpServerRespondable.symbol]() {
155
+ return Effect.succeed(methodNotAllowedResponse)
156
+ }
126
157
  }
127
158
 
128
159
  /**
@@ -143,7 +174,10 @@ export class NotAcceptable extends Schema.ErrorClass<NotAcceptable>("effect/Http
143
174
  description: "NotAcceptable",
144
175
  httpApiStatus: 406
145
176
  }) {
146
- override readonly [ErrorReporter.ignore] = true
177
+ override readonly [ErrorReporter.ignore] = true;
178
+ [HttpServerRespondable.symbol]() {
179
+ return Effect.succeed(notAcceptableResponse)
180
+ }
147
181
  }
148
182
 
149
183
  /**
@@ -164,7 +198,10 @@ export class RequestTimeout extends Schema.ErrorClass<RequestTimeout>("effect/Ht
164
198
  description: "RequestTimeout",
165
199
  httpApiStatus: 408
166
200
  }) {
167
- override readonly [ErrorReporter.ignore] = true
201
+ override readonly [ErrorReporter.ignore] = true;
202
+ [HttpServerRespondable.symbol]() {
203
+ return Effect.succeed(requestTimeoutResponse)
204
+ }
168
205
  }
169
206
 
170
207
  /**
@@ -185,7 +222,10 @@ export class Conflict extends Schema.ErrorClass<Conflict>("effect/HttpApiError/C
185
222
  description: "Conflict",
186
223
  httpApiStatus: 409
187
224
  }) {
188
- override readonly [ErrorReporter.ignore] = true
225
+ override readonly [ErrorReporter.ignore] = true;
226
+ [HttpServerRespondable.symbol]() {
227
+ return Effect.succeed(conflictResponse)
228
+ }
189
229
  }
190
230
 
191
231
  /**
@@ -206,7 +246,10 @@ export class Gone extends Schema.ErrorClass<Gone>("effect/HttpApiError/Gone")({
206
246
  description: "Gone",
207
247
  httpApiStatus: 410
208
248
  }) {
209
- override readonly [ErrorReporter.ignore] = true
249
+ override readonly [ErrorReporter.ignore] = true;
250
+ [HttpServerRespondable.symbol]() {
251
+ return Effect.succeed(goneResponse)
252
+ }
210
253
  }
211
254
 
212
255
  /**
@@ -228,7 +271,11 @@ export class InternalServerError
228
271
  description: "InternalServerError",
229
272
  httpApiStatus: 500
230
273
  })
231
- {}
274
+ {
275
+ [HttpServerRespondable.symbol]() {
276
+ return Effect.succeed(internalServerErrorResponse)
277
+ }
278
+ }
232
279
 
233
280
  /**
234
281
  * @category NoContent errors
@@ -247,7 +294,11 @@ export class NotImplemented extends Schema.ErrorClass<NotImplemented>("effect/Ht
247
294
  }, {
248
295
  description: "NotImplemented",
249
296
  httpApiStatus: 501
250
- }) {}
297
+ }) {
298
+ [HttpServerRespondable.symbol]() {
299
+ return Effect.succeed(notImplementedResponse)
300
+ }
301
+ }
251
302
 
252
303
  /**
253
304
  * @category NoContent errors
@@ -268,7 +319,11 @@ export class ServiceUnavailable
268
319
  description: "ServiceUnavailable",
269
320
  httpApiStatus: 503
270
321
  })
271
- {}
322
+ {
323
+ [HttpServerRespondable.symbol]() {
324
+ return Effect.succeed(serviceUnavailableResponse)
325
+ }
326
+ }
272
327
 
273
328
  /**
274
329
  * @category NoContent errors
@@ -6,10 +6,10 @@ import * as Duration from "../../Duration.ts"
6
6
  import * as Effect from "../../Effect.ts"
7
7
  import * as Fiber from "../../Fiber.ts"
8
8
  import * as Num from "../../Number.ts"
9
+ import * as Option from "../../Option.ts"
9
10
  import * as Schedule from "../../Schedule.ts"
10
11
  import * as Scope from "../../Scope.ts"
11
12
  import * as ServiceMap from "../../ServiceMap.ts"
12
- import * as UndefinedOr from "../../UndefinedOr.ts"
13
13
  import * as Headers from "../../unstable/http/Headers.ts"
14
14
  import * as HttpClient from "../../unstable/http/HttpClient.ts"
15
15
  import * as HttpClientError from "../../unstable/http/HttpClientError.ts"
@@ -24,7 +24,10 @@ const policy = Schedule.forever.pipe(
24
24
  && error.reason._tag === "StatusCodeError"
25
25
  && error.reason.response.status === 429
26
26
  ) {
27
- const retryAfter = UndefinedOr.map(error.reason.response.headers["retry-after"], Num.parse) ?? 5
27
+ const retryAfter = Option.fromUndefinedOr(error.reason.response.headers["retry-after"]).pipe(
28
+ Option.flatMap(Num.parse),
29
+ Option.getOrElse(() => 5)
30
+ )
28
31
  return Effect.succeed(Duration.seconds(retryAfter))
29
32
  }
30
33
  return Effect.succeed(Duration.seconds(1))
@@ -7,6 +7,7 @@ import * as Effect from "../../Effect.ts"
7
7
  import type * as Exit from "../../Exit.ts"
8
8
  import { flow } from "../../Function.ts"
9
9
  import * as Layer from "../../Layer.ts"
10
+ import * as Option from "../../Option.ts"
10
11
  import type * as Scope from "../../Scope.ts"
11
12
  import type * as ServiceMap from "../../ServiceMap.ts"
12
13
  import * as Tracer from "../../Tracer.ts"
@@ -150,7 +151,7 @@ type RemainingSpanImpl = Omit<Tracer.Span, (keyof typeof SpanProto) | "traceId"
150
151
 
151
152
  const makeSpan = (options: {
152
153
  readonly name: string
153
- readonly parent: Tracer.AnySpan | undefined
154
+ readonly parent: Option.Option<Tracer.AnySpan>
154
155
  readonly annotations: ServiceMap.ServiceMap<never>
155
156
  readonly status: Tracer.SpanStatus
156
157
  readonly attributes: ReadonlyMap<string, unknown>
@@ -163,8 +164,8 @@ const makeSpan = (options: {
163
164
  Object.create(SpanProto),
164
165
  options satisfies RemainingSpanImpl
165
166
  )
166
- if (self.parent) {
167
- self.traceId = self.parent.traceId
167
+ if (Option.isSome(self.parent)) {
168
+ self.traceId = self.parent.value.traceId
168
169
  } else {
169
170
  self.traceId = generateId(32)
170
171
  }
@@ -249,7 +250,10 @@ const makeOtlpSpan = (self: SpanImpl): OtlpSpan => {
249
250
  return {
250
251
  traceId: self.traceId,
251
252
  spanId: self.spanId,
252
- parentSpanId: self.parent ? self.parent.spanId : undefined,
253
+ parentSpanId: Option.match(self.parent, {
254
+ onNone: () => undefined,
255
+ onSome: (parent) => parent.spanId
256
+ }),
253
257
  name: self.name,
254
258
  kind: SpanKind[self.kind],
255
259
  startTimeUnixNano: String(status.startTime),
@@ -607,11 +607,8 @@ function runCallbackSync<R, A, E, ER = never>(
607
607
  return undefined
608
608
  }
609
609
  const runFork = Effect.runForkWith(services)
610
- const scheduler = ServiceMap.get(services, Scheduler.Scheduler)
611
610
  const fiber = runFork(effect)
612
- if ("flush" in scheduler) {
613
- ;(scheduler as Scheduler.MixedScheduler).flush()
614
- }
611
+ fiber.currentDispatcher?.flush()
615
612
  const result = fiber.pollUnsafe()
616
613
  if (result) {
617
614
  onExit(result)
@@ -9,7 +9,7 @@ import * as Layer from "../../Layer.ts"
9
9
  import * as Option from "../../Option.ts"
10
10
  import { hasProperty } from "../../Predicate.ts"
11
11
  import * as Queue from "../../Queue.ts"
12
- import type { Scheduler } from "../../Scheduler.ts"
12
+ import type { Scheduler, SchedulerDispatcher } from "../../Scheduler.ts"
13
13
  import { MixedScheduler } from "../../Scheduler.ts"
14
14
  import * as Scope from "../../Scope.ts"
15
15
  import * as ServiceMap from "../../ServiceMap.ts"
@@ -296,6 +296,7 @@ class RegistryImpl implements AtomRegistry {
296
296
  readonly defaultIdleTTL: number | undefined
297
297
  readonly scheduler: Scheduler
298
298
  readonly schedulerAsync: Scheduler
299
+ readonly dispatcher: SchedulerDispatcher
299
300
  onNodeAdded?: ((node: Node<any>) => void) | undefined
300
301
  onNodeRemoved?: ((node: Node<any>) => void) | undefined
301
302
 
@@ -308,6 +309,7 @@ class RegistryImpl implements AtomRegistry {
308
309
  this[TypeId] = TypeId
309
310
  this.scheduler = new MixedScheduler("sync", scheduleTask)
310
311
  this.schedulerAsync = new MixedScheduler("async", scheduleTask)
312
+ this.dispatcher = this.schedulerAsync.makeDispatcher()
311
313
  this.defaultIdleTTL = defaultIdleTTL
312
314
 
313
315
  if (timeoutResolution === undefined && defaultIdleTTL !== undefined) {
@@ -427,7 +429,7 @@ class RegistryImpl implements AtomRegistry {
427
429
  }
428
430
 
429
431
  scheduleAtomRemoval(atom: Atom.Atom<any>): void {
430
- this.schedulerAsync.scheduleTask(() => {
432
+ this.dispatcher.scheduleTask(() => {
431
433
  const node = this.nodes.get(atomKey(atom))
432
434
  if (node !== undefined && node.canBeRemoved) {
433
435
  this.removeNode(node)
@@ -436,7 +438,7 @@ class RegistryImpl implements AtomRegistry {
436
438
  }
437
439
 
438
440
  scheduleNodeRemoval(node: NodeImpl<any>): void {
439
- this.schedulerAsync.scheduleTask(() => {
441
+ this.dispatcher.scheduleTask(() => {
440
442
  if (node.canBeRemoved) {
441
443
  this.removeNode(node)
442
444
  }
@@ -4,6 +4,7 @@
4
4
  import type * as Cause from "../../Cause.ts"
5
5
  import type { Effect } from "../../Effect.ts"
6
6
  import type { Exit as Exit_ } from "../../Exit.ts"
7
+ import * as Option from "../../Option.ts"
7
8
  import { type Pipeable, pipeArguments } from "../../Pipeable.ts"
8
9
  import * as Predicate from "../../Predicate.ts"
9
10
  import * as PrimaryKey from "../../PrimaryKey.ts"
@@ -780,14 +781,14 @@ export const exitSchema = <R extends Any>(
780
781
  const rpc = self as any as AnyWithProps
781
782
  const failures = new Set<Schema.Top>([rpc.errorSchema])
782
783
  const streamSchemas = RpcSchema.getStreamSchemas(rpc.successSchema)
783
- if (streamSchemas) {
784
- failures.add(streamSchemas.error)
784
+ if (Option.isSome(streamSchemas)) {
785
+ failures.add(streamSchemas.value.error)
785
786
  }
786
787
  for (const middleware of rpc.middlewares) {
787
788
  failures.add(middleware.error)
788
789
  }
789
790
  const schema = Schema.Exit(
790
- streamSchemas ? Schema.Void : rpc.successSchema,
791
+ Option.isSome(streamSchemas) ? Schema.Void : rpc.successSchema,
791
792
  Schema.Union([...failures]),
792
793
  rpc.defectSchema
793
794
  )
@@ -366,7 +366,7 @@ export const makeNoSerialization: <Rpcs extends Rpc.Any, E, const Flatten extend
366
366
  resume(exit) {
367
367
  resume(exit)
368
368
  if (fiber && !fiber.pollUnsafe()) {
369
- parentFiber.currentScheduler.scheduleTask(() => {
369
+ parentFiber.currentDispatcher.scheduleTask(() => {
370
370
  fiber.interruptUnsafe(parentFiber.id)
371
371
  }, 0)
372
372
  }
@@ -683,8 +683,8 @@ export const make: <Rpcs extends Rpc.Any, const Flatten extends boolean = false>
683
683
  case "Chunk": {
684
684
  const requestId = RequestId(message.requestId)
685
685
  const entry = entries.get(requestId)
686
- if (!entry || !entry.schemas.decodeChunk) return Effect.void
687
- return entry.schemas.decodeChunk(message.values).pipe(
686
+ if (!entry || Option.isNone(entry.schemas.decodeChunk)) return Effect.void
687
+ return entry.schemas.decodeChunk.value(message.values).pipe(
688
688
  Effect.provideServices(entry.context),
689
689
  Effect.orDie,
690
690
  Effect.flatMap((chunk) =>
@@ -738,9 +738,9 @@ export const make: <Rpcs extends Rpc.Any, const Flatten extends boolean = false>
738
738
  })
739
739
 
740
740
  interface RpcSchemas {
741
- readonly decodeChunk:
742
- | ((chunk: ReadonlyArray<unknown>) => Effect.Effect<NonEmptyReadonlyArray<any>, Schema.SchemaError, unknown>)
743
- | undefined
741
+ readonly decodeChunk: Option.Option<
742
+ (chunk: ReadonlyArray<unknown>) => Effect.Effect<NonEmptyReadonlyArray<any>, Schema.SchemaError, unknown>
743
+ >
744
744
  readonly encodePayload: (payload: any) => Effect.Effect<any, Schema.SchemaError, unknown>
745
745
  readonly decodeExit: (encoded: unknown) => Effect.Effect<Exit.Exit<any, any>, Schema.SchemaError, unknown>
746
746
  }
@@ -752,9 +752,10 @@ const rpcSchemas = (rpc: Rpc.AnyWithProps) => {
752
752
  }
753
753
  const streamSchemas = RpcSchema.getStreamSchemas(rpc.successSchema)
754
754
  entry = {
755
- decodeChunk: streamSchemas ?
756
- Schema.decodeUnknownEffect(Schema.toCodecJson(Schema.NonEmptyArray(streamSchemas.success))) :
757
- undefined,
755
+ decodeChunk: Option.map(
756
+ streamSchemas,
757
+ (streamSchemas) => Schema.decodeUnknownEffect(Schema.toCodecJson(Schema.NonEmptyArray(streamSchemas.success)))
758
+ ),
758
759
  encodePayload: Schema.encodeEffect(Schema.toCodecJson(rpc.payloadSchema)),
759
760
  decodeExit: Schema.decodeUnknownEffect(Schema.toCodecJson(Rpc.exitSchema(rpc as any)))
760
761
  }
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import * as Cause from "../../Cause.ts"
5
5
  import { constUndefined } from "../../Function.ts"
6
+ import * as Option from "../../Option.ts"
6
7
  import * as Predicate from "../../Predicate.ts"
7
8
  import * as Schema from "../../Schema.ts"
8
9
  import type * as AST from "../../SchemaAST.ts"
@@ -20,16 +21,16 @@ export function isStreamSchema(schema: Schema.Top): schema is Stream<Schema.Top,
20
21
  }
21
22
 
22
23
  /** @internal */
23
- export function getStreamSchemas(schema: Schema.Top): {
24
+ export function getStreamSchemas(schema: Schema.Top): Option.Option<{
24
25
  readonly success: Schema.Top
25
26
  readonly error: Schema.Top
26
- } | undefined {
27
+ }> {
27
28
  return isStreamSchema(schema) ?
28
- {
29
+ Option.some({
29
30
  success: schema.success,
30
31
  error: schema.error
31
- } :
32
- undefined
32
+ }) :
33
+ Option.none()
33
34
  }
34
35
 
35
36
  /**
@@ -37,7 +37,10 @@ export const json: RpcSerialization["Service"] = RpcSerialization.of({
37
37
  makeUnsafe: () => {
38
38
  const decoder = new TextDecoder()
39
39
  return {
40
- decode: (bytes) => [JSON.parse(typeof bytes === "string" ? bytes : decoder.decode(bytes))],
40
+ decode: (bytes) => {
41
+ const decoded = JSON.parse(typeof bytes === "string" ? bytes : decoder.decode(bytes))
42
+ return Array.isArray(decoded) ? decoded : [decoded]
43
+ },
41
44
  encode: (response) => JSON.stringify(response)
42
45
  }
43
46
  }
@@ -11,7 +11,7 @@ import { constant, constTrue, constVoid, identity } from "../../Function.ts"
11
11
  import { reportCauseUnsafe } from "../../internal/effect.ts"
12
12
  import * as Latch from "../../Latch.ts"
13
13
  import * as Layer from "../../Layer.ts"
14
- import type * as Option from "../../Option.ts"
14
+ import * as Option from "../../Option.ts"
15
15
  import * as Predicate from "../../Predicate.ts"
16
16
  import * as Pull from "../../Pull.ts"
17
17
  import * as Queue from "../../Queue.ts"
@@ -547,7 +547,7 @@ export const make: <Rpcs extends Rpc.Any>(
547
547
  decode: Schema.decodeUnknownEffect(Schema.toCodecJson(rpc.payloadSchema)) as any,
548
548
  encodeChunk: Schema.encodeUnknownEffect(
549
549
  Schema.toCodecJson(
550
- Schema.Array(streamSchemas ? streamSchemas.success : Schema.Any)
550
+ Schema.Array(Option.isSome(streamSchemas) ? streamSchemas.value.success : Schema.Any)
551
551
  )
552
552
  ) as any,
553
553
  encodeExit: Schema.encodeUnknownEffect(Schema.toCodecJson(Rpc.exitSchema(rpc as any))) as any,
@@ -1245,7 +1245,7 @@ export const makeProtocolWorkerRunner: Effect.Effect<
1245
1245
  Effect.tapCause(Effect.logError),
1246
1246
  Effect.onExit(() =>
1247
1247
  Effect.sync(() => {
1248
- fiber.currentScheduler.scheduleTask(() => fiber.interruptUnsafe(fiber.id), 0)
1248
+ fiber.currentDispatcher.scheduleTask(() => fiber.interruptUnsafe(fiber.id), 0)
1249
1249
  })
1250
1250
  ),
1251
1251
  Effect.forkScoped
@@ -214,7 +214,7 @@ export type SocketErrorReason =
214
214
  * @since 4.0.0
215
215
  * @category errors
216
216
  */
217
- export class SocketError extends Schema.ErrorClass<SocketError>(SocketErrorTypeId)({
217
+ export class SocketError extends Schema.TaggedErrorClass<SocketError>(SocketErrorTypeId)("SocketError", {
218
218
  _tag: Schema.tag("SocketError"),
219
219
  reason: SocketErrorReason
220
220
  }) {
@@ -243,6 +243,8 @@ export class SocketError extends Schema.ErrorClass<SocketError>(SocketErrorTypeI
243
243
  static is(u: unknown): u is SocketError {
244
244
  return isSocketError(u)
245
245
  }
246
+
247
+ override readonly message = this.reason.message
246
248
  }
247
249
 
248
250
  /**
@@ -426,14 +428,16 @@ export const makeWebSocket = (url: string | Effect.Effect<string>, options?: {
426
428
  readonly openTimeout?: Duration.Input | undefined
427
429
  readonly protocols?: string | Array<string> | undefined
428
430
  }): Effect.Effect<Socket, never, WebSocketConstructor> =>
429
- fromWebSocket(
430
- Effect.acquireRelease(
431
- (typeof url === "string" ? Effect.succeed(url) : url).pipe(
432
- Effect.flatMap((url) => Effect.map(WebSocketConstructor.asEffect(), (f) => f(url, options?.protocols)))
431
+ WebSocketConstructor.use((makeWs) =>
432
+ fromWebSocket(
433
+ Effect.acquireRelease(
434
+ (typeof url === "string" ? Effect.succeed(url) : url).pipe(
435
+ Effect.map((url) => makeWs(url, options?.protocols))
436
+ ),
437
+ (ws) => Effect.sync(() => ws.close(1000))
433
438
  ),
434
- (ws) => Effect.sync(() => ws.close(1000))
435
- ),
436
- options
439
+ options
440
+ )
437
441
  )
438
442
 
439
443
  /**
@@ -500,6 +504,7 @@ export const fromWebSocket = <RO>(
500
504
  )
501
505
  }
502
506
  function onClose(event: globalThis.CloseEvent) {
507
+ const code = typeof event.code === "number" ? event.code : 1001
503
508
  ws.removeEventListener("message", onMessage)
504
509
  ws.removeEventListener("error", onError)
505
510
  Deferred.doneUnsafe(
@@ -507,7 +512,7 @@ export const fromWebSocket = <RO>(
507
512
  Effect.fail(
508
513
  new SocketError({
509
514
  reason: new SocketCloseError({
510
- code: event.code,
515
+ code,
511
516
  closeReason: event.reason
512
517
  })
513
518
  })
@@ -215,9 +215,11 @@ export const makeWithTransaction = <I, S>(options: {
215
215
  Effect.flatMap(() =>
216
216
  Effect.provideServices(
217
217
  restore(effect),
218
- ServiceMap.add(services, options.transactionService, [conn, id]).pipe(
219
- ServiceMap.add(Tracer.ParentSpan, span)
220
- )
218
+ ServiceMap.mutate(services, (services) =>
219
+ services.pipe(
220
+ ServiceMap.add(options.transactionService, [conn, id]),
221
+ ServiceMap.add(Tracer.ParentSpan, span)
222
+ ))
221
223
  )
222
224
  ),
223
225
  Effect.exit,
@@ -8,7 +8,7 @@ import * as Effect from "../../Effect.ts"
8
8
  import * as Encoding from "../../Encoding.ts"
9
9
  import * as Exit from "../../Exit.ts"
10
10
  import { dual } from "../../Function.ts"
11
- import * as Predicate from "../../Predicate.ts"
11
+ import * as Option from "../../Option.ts"
12
12
  import * as Schema from "../../Schema.ts"
13
13
  import * as Getter from "../../SchemaGetter.ts"
14
14
  import * as ServiceMap from "../../ServiceMap.ts"
@@ -124,12 +124,12 @@ const await_: <Success extends Schema.Top, Error extends Schema.Top>(
124
124
  const instance = yield* InstanceTag
125
125
  const exit = yield* Workflow.wrapActivityResult(
126
126
  engine.deferredResult(self),
127
- Predicate.isUndefined
127
+ Option.isNone
128
128
  )
129
- if (exit === undefined) {
129
+ if (Option.isNone(exit)) {
130
130
  return yield* Workflow.suspend(instance)
131
131
  }
132
- return yield* exit as Exit.Exit<any, any>
132
+ return yield* exit.value as Exit.Exit<any, any>
133
133
  })
134
134
 
135
135
  export {
@@ -241,8 +241,8 @@ export const raceAll = <
241
241
  return Effect.gen(function*() {
242
242
  const engine = yield* EngineTag
243
243
  const exit = yield* engine.deferredResult(deferred)
244
- if (exit !== undefined) {
245
- return yield* Effect.flatten(exit) as Effect.Effect<any, any, any>
244
+ if (Option.isSome(exit)) {
245
+ return yield* Effect.flatten(exit.value) as Effect.Effect<any, any, any>
246
246
  }
247
247
  return yield* into(Effect.raceAll(options.effects), deferred)
248
248
  })
@@ -78,7 +78,7 @@ export interface Workflow<
78
78
  readonly poll: (
79
79
  executionId: string
80
80
  ) => Effect.Effect<
81
- Result<Success["Type"], Error["Type"]> | undefined,
81
+ Option.Option<Result<Success["Type"], Error["Type"]>>,
82
82
  never,
83
83
  WorkflowEngine | Success["DecodingServices"] | Error["DecodingServices"]
84
84
  >