effect 4.0.0-beta.30 → 4.0.0-beta.32

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 (514) 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/Channel.d.ts +2 -2
  14. package/dist/Channel.d.ts.map +1 -1
  15. package/dist/Channel.js.map +1 -1
  16. package/dist/Chunk.d.ts +58 -57
  17. package/dist/Chunk.d.ts.map +1 -1
  18. package/dist/Chunk.js +20 -21
  19. package/dist/Chunk.js.map +1 -1
  20. package/dist/Config.d.ts.map +1 -1
  21. package/dist/Config.js +4 -1
  22. package/dist/Config.js.map +1 -1
  23. package/dist/Cron.d.ts +3 -6
  24. package/dist/Cron.d.ts.map +1 -1
  25. package/dist/Cron.js +11 -18
  26. package/dist/Cron.js.map +1 -1
  27. package/dist/DateTime.d.ts +49 -92
  28. package/dist/DateTime.d.ts.map +1 -1
  29. package/dist/DateTime.js +9 -9
  30. package/dist/DateTime.js.map +1 -1
  31. package/dist/Deferred.d.ts +7 -5
  32. package/dist/Deferred.d.ts.map +1 -1
  33. package/dist/Deferred.js +7 -5
  34. package/dist/Deferred.js.map +1 -1
  35. package/dist/Duration.d.ts +55 -25
  36. package/dist/Duration.d.ts.map +1 -1
  37. package/dist/Duration.js +100 -70
  38. package/dist/Duration.js.map +1 -1
  39. package/dist/Effect.d.ts.map +1 -1
  40. package/dist/Effect.js +3 -4
  41. package/dist/Effect.js.map +1 -1
  42. package/dist/Fiber.d.ts +2 -1
  43. package/dist/Fiber.d.ts.map +1 -1
  44. package/dist/Fiber.js.map +1 -1
  45. package/dist/FiberHandle.d.ts +9 -8
  46. package/dist/FiberHandle.d.ts.map +1 -1
  47. package/dist/FiberHandle.js +8 -7
  48. package/dist/FiberHandle.js.map +1 -1
  49. package/dist/FiberMap.d.ts +20 -19
  50. package/dist/FiberMap.d.ts.map +1 -1
  51. package/dist/FiberMap.js +6 -6
  52. package/dist/FiberMap.js.map +1 -1
  53. package/dist/FileSystem.d.ts +17 -16
  54. package/dist/FileSystem.d.ts.map +1 -1
  55. package/dist/FileSystem.js +10 -7
  56. package/dist/FileSystem.js.map +1 -1
  57. package/dist/Graph.d.ts +64 -64
  58. package/dist/Graph.d.ts.map +1 -1
  59. package/dist/Graph.js +53 -53
  60. package/dist/Graph.js.map +1 -1
  61. package/dist/HashMap.d.ts +11 -5
  62. package/dist/HashMap.d.ts.map +1 -1
  63. package/dist/HashMap.js +3 -1
  64. package/dist/HashMap.js.map +1 -1
  65. package/dist/Iterable.d.ts +11 -11
  66. package/dist/Iterable.d.ts.map +1 -1
  67. package/dist/Iterable.js +12 -12
  68. package/dist/Iterable.js.map +1 -1
  69. package/dist/Latch.d.ts +69 -3
  70. package/dist/Latch.d.ts.map +1 -1
  71. package/dist/Latch.js +58 -0
  72. package/dist/Latch.js.map +1 -1
  73. package/dist/Layer.d.ts +181 -2
  74. package/dist/Layer.d.ts.map +1 -1
  75. package/dist/Layer.js +35 -2
  76. package/dist/Layer.js.map +1 -1
  77. package/dist/Number.d.ts +74 -18
  78. package/dist/Number.d.ts.map +1 -1
  79. package/dist/Number.js +34 -15
  80. package/dist/Number.js.map +1 -1
  81. package/dist/Option.d.ts +2 -0
  82. package/dist/Option.d.ts.map +1 -1
  83. package/dist/Option.js.map +1 -1
  84. package/dist/PartitionedSemaphore.d.ts +183 -0
  85. package/dist/PartitionedSemaphore.d.ts.map +1 -0
  86. package/dist/PartitionedSemaphore.js +231 -0
  87. package/dist/PartitionedSemaphore.js.map +1 -0
  88. package/dist/PubSub.d.ts +5 -4
  89. package/dist/PubSub.d.ts.map +1 -1
  90. package/dist/PubSub.js +6 -5
  91. package/dist/PubSub.js.map +1 -1
  92. package/dist/Queue.d.ts +3 -3
  93. package/dist/Queue.d.ts.map +1 -1
  94. package/dist/Queue.js +2 -2
  95. package/dist/Queue.js.map +1 -1
  96. package/dist/Record.d.ts +40 -40
  97. package/dist/Record.d.ts.map +1 -1
  98. package/dist/Record.js +16 -15
  99. package/dist/Record.js.map +1 -1
  100. package/dist/Scheduler.d.ts +25 -123
  101. package/dist/Scheduler.d.ts.map +1 -1
  102. package/dist/Scheduler.js +20 -123
  103. package/dist/Scheduler.js.map +1 -1
  104. package/dist/Schema.d.ts +2346 -114
  105. package/dist/Schema.d.ts.map +1 -1
  106. package/dist/Schema.js +1359 -68
  107. package/dist/Schema.js.map +1 -1
  108. package/dist/SchemaAST.d.ts +2 -2
  109. package/dist/SchemaAST.js +2 -2
  110. package/dist/SchemaGetter.js +6 -4
  111. package/dist/SchemaGetter.js.map +1 -1
  112. package/dist/SchemaRepresentation.d.ts +2 -2
  113. package/dist/SchemaRepresentation.d.ts.map +1 -1
  114. package/dist/SchemaRepresentation.js.map +1 -1
  115. package/dist/SchemaTransformation.d.ts.map +1 -1
  116. package/dist/SchemaTransformation.js +32 -27
  117. package/dist/SchemaTransformation.js.map +1 -1
  118. package/dist/Semaphore.d.ts +149 -53
  119. package/dist/Semaphore.d.ts.map +1 -1
  120. package/dist/Semaphore.js +137 -117
  121. package/dist/Semaphore.js.map +1 -1
  122. package/dist/ServiceMap.d.ts +26 -0
  123. package/dist/ServiceMap.d.ts.map +1 -1
  124. package/dist/ServiceMap.js +36 -21
  125. package/dist/ServiceMap.js.map +1 -1
  126. package/dist/Stream.js +1 -1
  127. package/dist/Stream.js.map +1 -1
  128. package/dist/String.d.ts +114 -47
  129. package/dist/String.d.ts.map +1 -1
  130. package/dist/String.js +29 -47
  131. package/dist/String.js.map +1 -1
  132. package/dist/SubscriptionRef.d.ts +1 -2
  133. package/dist/SubscriptionRef.d.ts.map +1 -1
  134. package/dist/SubscriptionRef.js +81 -115
  135. package/dist/SubscriptionRef.js.map +1 -1
  136. package/dist/Terminal.d.ts +2 -1
  137. package/dist/Terminal.d.ts.map +1 -1
  138. package/dist/Terminal.js.map +1 -1
  139. package/dist/Tracer.d.ts +5 -4
  140. package/dist/Tracer.d.ts.map +1 -1
  141. package/dist/Tracer.js +2 -1
  142. package/dist/Tracer.js.map +1 -1
  143. package/dist/Trie.d.ts +26 -14
  144. package/dist/Trie.d.ts.map +1 -1
  145. package/dist/Trie.js +8 -4
  146. package/dist/Trie.js.map +1 -1
  147. package/dist/TxHashMap.d.ts +77 -59
  148. package/dist/TxHashMap.d.ts.map +1 -1
  149. package/dist/TxHashMap.js +25 -19
  150. package/dist/TxHashMap.js.map +1 -1
  151. package/dist/TxSemaphore.d.ts +162 -2
  152. package/dist/TxSemaphore.d.ts.map +1 -1
  153. package/dist/TxSemaphore.js +16 -2
  154. package/dist/TxSemaphore.js.map +1 -1
  155. package/dist/index.d.ts +88 -32
  156. package/dist/index.d.ts.map +1 -1
  157. package/dist/index.js +88 -32
  158. package/dist/index.js.map +1 -1
  159. package/dist/internal/dateTime.js +66 -59
  160. package/dist/internal/dateTime.js.map +1 -1
  161. package/dist/internal/effect.js +21 -90
  162. package/dist/internal/effect.js.map +1 -1
  163. package/dist/internal/hashMap.js +2 -1
  164. package/dist/internal/hashMap.js.map +1 -1
  165. package/dist/internal/option.js +6 -0
  166. package/dist/internal/option.js.map +1 -1
  167. package/dist/internal/trie.js +3 -3
  168. package/dist/internal/trie.js.map +1 -1
  169. package/dist/unstable/ai/AiError.js +1 -1
  170. package/dist/unstable/ai/AiError.js.map +1 -1
  171. package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
  172. package/dist/unstable/ai/AnthropicStructuredOutput.js +4 -0
  173. package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
  174. package/dist/unstable/ai/Chat.d.ts +3 -4
  175. package/dist/unstable/ai/Chat.d.ts.map +1 -1
  176. package/dist/unstable/ai/Chat.js +2 -2
  177. package/dist/unstable/ai/Chat.js.map +1 -1
  178. package/dist/unstable/ai/LanguageModel.d.ts +30 -16
  179. package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
  180. package/dist/unstable/ai/LanguageModel.js +10 -87
  181. package/dist/unstable/ai/LanguageModel.js.map +1 -1
  182. package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
  183. package/dist/unstable/ai/OpenAiStructuredOutput.js +4 -0
  184. package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
  185. package/dist/unstable/ai/Tool.d.ts +14 -0
  186. package/dist/unstable/ai/Tool.d.ts.map +1 -1
  187. package/dist/unstable/ai/Tool.js +13 -0
  188. package/dist/unstable/ai/Tool.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/Completions.d.ts +16 -0
  202. package/dist/unstable/cli/Completions.d.ts.map +1 -0
  203. package/dist/unstable/cli/Completions.js +23 -0
  204. package/dist/unstable/cli/Completions.js.map +1 -0
  205. package/dist/unstable/cli/Flag.d.ts +2 -2
  206. package/dist/unstable/cli/Flag.d.ts.map +1 -1
  207. package/dist/unstable/cli/Flag.js +1 -1
  208. package/dist/unstable/cli/Flag.js.map +1 -1
  209. package/dist/unstable/cli/GlobalFlag.d.ts.map +1 -1
  210. package/dist/unstable/cli/GlobalFlag.js +4 -4
  211. package/dist/unstable/cli/GlobalFlag.js.map +1 -1
  212. package/dist/unstable/cli/HelpDoc.d.ts +14 -12
  213. package/dist/unstable/cli/HelpDoc.d.ts.map +1 -1
  214. package/dist/unstable/cli/Param.d.ts +4 -4
  215. package/dist/unstable/cli/Param.d.ts.map +1 -1
  216. package/dist/unstable/cli/Param.js +7 -7
  217. package/dist/unstable/cli/Param.js.map +1 -1
  218. package/dist/unstable/cli/Primitive.d.ts +1 -1
  219. package/dist/unstable/cli/Primitive.d.ts.map +1 -1
  220. package/dist/unstable/cli/Primitive.js.map +1 -1
  221. package/dist/unstable/cli/Prompt.js +71 -67
  222. package/dist/unstable/cli/Prompt.js.map +1 -1
  223. package/dist/unstable/cli/index.d.ts +4 -0
  224. package/dist/unstable/cli/index.d.ts.map +1 -1
  225. package/dist/unstable/cli/index.js +4 -0
  226. package/dist/unstable/cli/index.js.map +1 -1
  227. package/dist/unstable/cli/internal/completions/CommandDescriptor.js +9 -2
  228. package/dist/unstable/cli/internal/completions/CommandDescriptor.js.map +1 -1
  229. package/dist/unstable/cli/internal/parser.js +8 -3
  230. package/dist/unstable/cli/internal/parser.js.map +1 -1
  231. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts +3 -2
  232. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
  233. package/dist/unstable/cluster/ClusterWorkflowEngine.js +25 -23
  234. package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
  235. package/dist/unstable/cluster/DeliverAt.js +1 -1
  236. package/dist/unstable/cluster/DeliverAt.js.map +1 -1
  237. package/dist/unstable/cluster/Entity.d.ts +3 -2
  238. package/dist/unstable/cluster/Entity.d.ts.map +1 -1
  239. package/dist/unstable/cluster/Entity.js +7 -7
  240. package/dist/unstable/cluster/Entity.js.map +1 -1
  241. package/dist/unstable/cluster/Message.d.ts +4 -3
  242. package/dist/unstable/cluster/Message.d.ts.map +1 -1
  243. package/dist/unstable/cluster/Message.js +3 -2
  244. package/dist/unstable/cluster/Message.js.map +1 -1
  245. package/dist/unstable/cluster/MessageStorage.d.ts +10 -10
  246. package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
  247. package/dist/unstable/cluster/MessageStorage.js +12 -12
  248. package/dist/unstable/cluster/MessageStorage.js.map +1 -1
  249. package/dist/unstable/cluster/Reply.d.ts +2 -1
  250. package/dist/unstable/cluster/Reply.d.ts.map +1 -1
  251. package/dist/unstable/cluster/Reply.js +4 -3
  252. package/dist/unstable/cluster/Reply.js.map +1 -1
  253. package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
  254. package/dist/unstable/cluster/RunnerServer.js +9 -8
  255. package/dist/unstable/cluster/RunnerServer.js.map +1 -1
  256. package/dist/unstable/cluster/Runners.d.ts +2 -1
  257. package/dist/unstable/cluster/Runners.d.ts.map +1 -1
  258. package/dist/unstable/cluster/Runners.js +7 -6
  259. package/dist/unstable/cluster/Runners.js.map +1 -1
  260. package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
  261. package/dist/unstable/cluster/Sharding.js +19 -13
  262. package/dist/unstable/cluster/Sharding.js.map +1 -1
  263. package/dist/unstable/cluster/ShardingConfig.d.ts +5 -4
  264. package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
  265. package/dist/unstable/cluster/ShardingConfig.js +4 -4
  266. package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
  267. package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
  268. package/dist/unstable/cluster/SqlMessageStorage.js +19 -18
  269. package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
  270. package/dist/unstable/cluster/internal/entityManager.js +9 -10
  271. package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
  272. package/dist/unstable/devtools/DevToolsSchema.d.ts +2 -1
  273. package/dist/unstable/devtools/DevToolsSchema.d.ts.map +1 -1
  274. package/dist/unstable/devtools/DevToolsSchema.js +1 -4
  275. package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
  276. package/dist/unstable/encoding/Ndjson.d.ts +8 -8
  277. package/dist/unstable/encoding/Ndjson.d.ts.map +1 -1
  278. package/dist/unstable/encoding/Ndjson.js.map +1 -1
  279. package/dist/unstable/http/Cookies.d.ts +5 -4
  280. package/dist/unstable/http/Cookies.d.ts.map +1 -1
  281. package/dist/unstable/http/Cookies.js +3 -4
  282. package/dist/unstable/http/Cookies.js.map +1 -1
  283. package/dist/unstable/http/Etag.d.ts.map +1 -1
  284. package/dist/unstable/http/Etag.js +5 -1
  285. package/dist/unstable/http/Etag.js.map +1 -1
  286. package/dist/unstable/http/Headers.d.ts +3 -2
  287. package/dist/unstable/http/Headers.d.ts.map +1 -1
  288. package/dist/unstable/http/Headers.js +2 -1
  289. package/dist/unstable/http/Headers.js.map +1 -1
  290. package/dist/unstable/http/HttpClient.d.ts.map +1 -1
  291. package/dist/unstable/http/HttpClient.js +2 -1
  292. package/dist/unstable/http/HttpClient.js.map +1 -1
  293. package/dist/unstable/http/HttpClientRequest.d.ts +4 -3
  294. package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
  295. package/dist/unstable/http/HttpClientRequest.js +8 -6
  296. package/dist/unstable/http/HttpClientRequest.js.map +1 -1
  297. package/dist/unstable/http/HttpClientResponse.d.ts.map +1 -1
  298. package/dist/unstable/http/HttpClientResponse.js +2 -1
  299. package/dist/unstable/http/HttpClientResponse.js.map +1 -1
  300. package/dist/unstable/http/HttpIncomingMessage.d.ts +3 -2
  301. package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
  302. package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
  303. package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
  304. package/dist/unstable/http/HttpMiddleware.js +16 -15
  305. package/dist/unstable/http/HttpMiddleware.js.map +1 -1
  306. package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
  307. package/dist/unstable/http/HttpPlatform.js +3 -2
  308. package/dist/unstable/http/HttpPlatform.js.map +1 -1
  309. package/dist/unstable/http/HttpRouter.d.ts +2 -1
  310. package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
  311. package/dist/unstable/http/HttpRouter.js +7 -7
  312. package/dist/unstable/http/HttpRouter.js.map +1 -1
  313. package/dist/unstable/http/HttpServer.d.ts.map +1 -1
  314. package/dist/unstable/http/HttpServer.js +2 -2
  315. package/dist/unstable/http/HttpServer.js.map +1 -1
  316. package/dist/unstable/http/HttpServerError.d.ts +2 -1
  317. package/dist/unstable/http/HttpServerError.d.ts.map +1 -1
  318. package/dist/unstable/http/HttpServerError.js +2 -1
  319. package/dist/unstable/http/HttpServerError.js.map +1 -1
  320. package/dist/unstable/http/HttpServerRequest.d.ts +3 -2
  321. package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
  322. package/dist/unstable/http/HttpServerRequest.js +14 -10
  323. package/dist/unstable/http/HttpServerRequest.js.map +1 -1
  324. package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
  325. package/dist/unstable/http/HttpServerResponse.js +4 -3
  326. package/dist/unstable/http/HttpServerResponse.js.map +1 -1
  327. package/dist/unstable/http/HttpTraceContext.d.ts +3 -2
  328. package/dist/unstable/http/HttpTraceContext.d.ts.map +1 -1
  329. package/dist/unstable/http/HttpTraceContext.js +27 -15
  330. package/dist/unstable/http/HttpTraceContext.js.map +1 -1
  331. package/dist/unstable/http/UrlParams.d.ts +5 -4
  332. package/dist/unstable/http/UrlParams.d.ts.map +1 -1
  333. package/dist/unstable/http/UrlParams.js +5 -6
  334. package/dist/unstable/http/UrlParams.js.map +1 -1
  335. package/dist/unstable/httpapi/HttpApiBuilder.d.ts +2 -2
  336. package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
  337. package/dist/unstable/httpapi/HttpApiBuilder.js +4 -2
  338. package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
  339. package/dist/unstable/httpapi/HttpApiError.d.ts +15 -0
  340. package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
  341. package/dist/unstable/httpapi/HttpApiError.js +81 -3
  342. package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
  343. package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
  344. package/dist/unstable/observability/OtlpExporter.js +2 -2
  345. package/dist/unstable/observability/OtlpExporter.js.map +1 -1
  346. package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
  347. package/dist/unstable/observability/OtlpTracer.js +7 -3
  348. package/dist/unstable/observability/OtlpTracer.js.map +1 -1
  349. package/dist/unstable/persistence/Persistable.js +1 -1
  350. package/dist/unstable/persistence/Persistable.js.map +1 -1
  351. package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
  352. package/dist/unstable/reactivity/Atom.js +1 -5
  353. package/dist/unstable/reactivity/Atom.js.map +1 -1
  354. package/dist/unstable/reactivity/AtomRegistry.d.ts.map +1 -1
  355. package/dist/unstable/reactivity/AtomRegistry.js +4 -2
  356. package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
  357. package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
  358. package/dist/unstable/rpc/Rpc.js +4 -3
  359. package/dist/unstable/rpc/Rpc.js.map +1 -1
  360. package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
  361. package/dist/unstable/rpc/RpcClient.js +4 -4
  362. package/dist/unstable/rpc/RpcClient.js.map +1 -1
  363. package/dist/unstable/rpc/RpcGroup.d.ts +1 -3
  364. package/dist/unstable/rpc/RpcGroup.d.ts.map +1 -1
  365. package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
  366. package/dist/unstable/rpc/RpcSchema.js +3 -2
  367. package/dist/unstable/rpc/RpcSchema.js.map +1 -1
  368. package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
  369. package/dist/unstable/rpc/RpcSerialization.js +4 -1
  370. package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
  371. package/dist/unstable/rpc/RpcServer.d.ts +1 -1
  372. package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
  373. package/dist/unstable/rpc/RpcServer.js +3 -2
  374. package/dist/unstable/rpc/RpcServer.js.map +1 -1
  375. package/dist/unstable/socket/Socket.d.ts.map +1 -1
  376. package/dist/unstable/socket/Socket.js +2 -1
  377. package/dist/unstable/socket/Socket.js.map +1 -1
  378. package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
  379. package/dist/unstable/sql/SqlClient.js +1 -1
  380. package/dist/unstable/sql/SqlClient.js.map +1 -1
  381. package/dist/unstable/workflow/DurableDeferred.js +6 -6
  382. package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
  383. package/dist/unstable/workflow/Workflow.d.ts +2 -1
  384. package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
  385. package/dist/unstable/workflow/WorkflowEngine.d.ts +5 -4
  386. package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
  387. package/dist/unstable/workflow/WorkflowEngine.js +19 -14
  388. package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
  389. package/package.json +1 -1
  390. package/src/Array.ts +112 -105
  391. package/src/BigDecimal.ts +63 -66
  392. package/src/BigInt.ts +49 -41
  393. package/src/Channel.ts +3 -3
  394. package/src/Chunk.ts +68 -63
  395. package/src/Config.ts +4 -1
  396. package/src/Cron.ts +13 -18
  397. package/src/DateTime.ts +51 -92
  398. package/src/Deferred.ts +8 -6
  399. package/src/Duration.ts +112 -56
  400. package/src/Effect.ts +3 -4
  401. package/src/Fiber.ts +2 -1
  402. package/src/FiberHandle.ts +10 -9
  403. package/src/FiberMap.ts +22 -22
  404. package/src/FileSystem.ts +25 -22
  405. package/src/Graph.ts +105 -105
  406. package/src/HashMap.ts +11 -5
  407. package/src/Iterable.ts +13 -13
  408. package/src/Latch.ts +85 -3
  409. package/src/Layer.ts +244 -19
  410. package/src/Number.ts +85 -26
  411. package/src/Option.ts +2 -0
  412. package/src/PartitionedSemaphore.ts +414 -0
  413. package/src/PubSub.ts +7 -6
  414. package/src/Queue.ts +5 -5
  415. package/src/Record.ts +52 -47
  416. package/src/Scheduler.ts +37 -126
  417. package/src/Schema.ts +2366 -116
  418. package/src/SchemaAST.ts +2 -2
  419. package/src/SchemaGetter.ts +4 -4
  420. package/src/SchemaRepresentation.ts +2 -2
  421. package/src/SchemaTransformation.ts +27 -27
  422. package/src/Semaphore.ts +271 -183
  423. package/src/ServiceMap.ts +83 -31
  424. package/src/Stream.ts +1 -1
  425. package/src/String.ts +122 -69
  426. package/src/SubscriptionRef.ts +96 -117
  427. package/src/Terminal.ts +2 -1
  428. package/src/Tracer.ts +6 -5
  429. package/src/Trie.ts +26 -14
  430. package/src/TxHashMap.ts +78 -60
  431. package/src/TxSemaphore.ts +186 -11
  432. package/src/index.ts +89 -33
  433. package/src/internal/dateTime.ts +74 -65
  434. package/src/internal/effect.ts +30 -122
  435. package/src/internal/hashMap.ts +4 -3
  436. package/src/internal/option.ts +7 -0
  437. package/src/internal/trie.ts +6 -6
  438. package/src/unstable/ai/AiError.ts +1 -1
  439. package/src/unstable/ai/AnthropicStructuredOutput.ts +4 -0
  440. package/src/unstable/ai/Chat.ts +17 -15
  441. package/src/unstable/ai/LanguageModel.ts +148 -97
  442. package/src/unstable/ai/OpenAiStructuredOutput.ts +4 -0
  443. package/src/unstable/ai/Tool.ts +20 -0
  444. package/src/unstable/cli/Argument.ts +2 -4
  445. package/src/unstable/cli/CliOutput.ts +7 -5
  446. package/src/unstable/cli/Command.ts +5 -5
  447. package/src/unstable/cli/Completions.ts +36 -0
  448. package/src/unstable/cli/Flag.ts +2 -2
  449. package/src/unstable/cli/GlobalFlag.ts +4 -5
  450. package/src/unstable/cli/HelpDoc.ts +14 -12
  451. package/src/unstable/cli/Param.ts +15 -11
  452. package/src/unstable/cli/Primitive.ts +1 -1
  453. package/src/unstable/cli/Prompt.ts +81 -83
  454. package/src/unstable/cli/index.ts +5 -0
  455. package/src/unstable/cli/internal/completions/CommandDescriptor.ts +3 -2
  456. package/src/unstable/cli/internal/parser.ts +7 -4
  457. package/src/unstable/cluster/ClusterWorkflowEngine.ts +35 -30
  458. package/src/unstable/cluster/DeliverAt.ts +1 -1
  459. package/src/unstable/cluster/Entity.ts +13 -12
  460. package/src/unstable/cluster/Message.ts +6 -5
  461. package/src/unstable/cluster/MessageStorage.ts +26 -25
  462. package/src/unstable/cluster/Reply.ts +7 -4
  463. package/src/unstable/cluster/RunnerServer.ts +10 -13
  464. package/src/unstable/cluster/Runners.ts +8 -7
  465. package/src/unstable/cluster/Sharding.ts +24 -17
  466. package/src/unstable/cluster/ShardingConfig.ts +6 -6
  467. package/src/unstable/cluster/SqlMessageStorage.ts +21 -18
  468. package/src/unstable/cluster/internal/entityManager.ts +27 -21
  469. package/src/unstable/devtools/DevToolsSchema.ts +3 -2
  470. package/src/unstable/encoding/Ndjson.ts +17 -17
  471. package/src/unstable/http/Cookies.ts +7 -8
  472. package/src/unstable/http/Etag.ts +5 -3
  473. package/src/unstable/http/Headers.ts +6 -5
  474. package/src/unstable/http/HttpClient.ts +2 -1
  475. package/src/unstable/http/HttpClientRequest.ts +11 -9
  476. package/src/unstable/http/HttpClientResponse.ts +5 -4
  477. package/src/unstable/http/HttpIncomingMessage.ts +3 -2
  478. package/src/unstable/http/HttpMiddleware.ts +16 -15
  479. package/src/unstable/http/HttpPlatform.ts +3 -2
  480. package/src/unstable/http/HttpRouter.ts +9 -9
  481. package/src/unstable/http/HttpServer.ts +3 -9
  482. package/src/unstable/http/HttpServerError.ts +3 -2
  483. package/src/unstable/http/HttpServerRequest.ts +29 -25
  484. package/src/unstable/http/HttpServerResponse.ts +7 -6
  485. package/src/unstable/http/HttpTraceContext.ts +31 -17
  486. package/src/unstable/http/UrlParams.ts +11 -14
  487. package/src/unstable/httpapi/HttpApiBuilder.ts +13 -7
  488. package/src/unstable/httpapi/HttpApiError.ts +67 -12
  489. package/src/unstable/observability/OtlpExporter.ts +5 -2
  490. package/src/unstable/observability/OtlpTracer.ts +8 -4
  491. package/src/unstable/persistence/Persistable.ts +1 -1
  492. package/src/unstable/reactivity/Atom.ts +1 -4
  493. package/src/unstable/reactivity/AtomRegistry.ts +5 -3
  494. package/src/unstable/rpc/Rpc.ts +4 -3
  495. package/src/unstable/rpc/RpcClient.ts +10 -9
  496. package/src/unstable/rpc/RpcGroup.ts +3 -3
  497. package/src/unstable/rpc/RpcSchema.ts +6 -5
  498. package/src/unstable/rpc/RpcSerialization.ts +4 -1
  499. package/src/unstable/rpc/RpcServer.ts +3 -3
  500. package/src/unstable/socket/Socket.ts +2 -1
  501. package/src/unstable/sql/SqlClient.ts +5 -3
  502. package/src/unstable/workflow/DurableDeferred.ts +6 -6
  503. package/src/unstable/workflow/Workflow.ts +1 -1
  504. package/src/unstable/workflow/WorkflowEngine.ts +29 -20
  505. package/dist/NullOr.d.ts +0 -149
  506. package/dist/NullOr.d.ts.map +0 -1
  507. package/dist/NullOr.js +0 -152
  508. package/dist/NullOr.js.map +0 -1
  509. package/dist/unstable/cli/internal/completions/Completions.d.ts +0 -2
  510. package/dist/unstable/cli/internal/completions/Completions.d.ts.map +0 -1
  511. package/dist/unstable/cli/internal/completions/Completions.js +0 -23
  512. package/dist/unstable/cli/internal/completions/Completions.js.map +0 -1
  513. package/src/NullOr.ts +0 -204
  514. package/src/unstable/cli/internal/completions/Completions.ts +0 -31
@@ -6,6 +6,7 @@ import type * as FileSystem from "../../FileSystem.ts"
6
6
  import { dual } from "../../Function.ts"
7
7
  import * as Inspectable from "../../Inspectable.ts"
8
8
  import { stringOrRedacted } from "../../internal/redacted.ts"
9
+ import * as Option from "../../Option.ts"
9
10
  import { type Pipeable, pipeArguments } from "../../Pipeable.ts"
10
11
  import type * as PlatformError from "../../PlatformError.ts"
11
12
  import { hasProperty } from "../../Predicate.ts"
@@ -37,7 +38,7 @@ export interface HttpClientRequest extends Inspectable.Inspectable, Pipeable {
37
38
  readonly method: HttpMethod
38
39
  readonly url: string
39
40
  readonly urlParams: UrlParams.UrlParams
40
- readonly hash: string | undefined
41
+ readonly hash: Option.Option<string>
41
42
  readonly headers: Headers.Headers
42
43
  readonly body: HttpBody.HttpBody
43
44
  }
@@ -95,7 +96,7 @@ export function makeWith(
95
96
  method: HttpMethod,
96
97
  url: string,
97
98
  urlParams: UrlParams.UrlParams,
98
- hash: string | undefined,
99
+ hash: Option.Option<string>,
99
100
  headers: Headers.Headers,
100
101
  body: HttpBody.HttpBody
101
102
  ): HttpClientRequest {
@@ -117,7 +118,7 @@ export const empty: HttpClientRequest = makeWith(
117
118
  "GET",
118
119
  "",
119
120
  UrlParams.empty,
120
- undefined,
121
+ Option.none(),
121
122
  Headers.empty,
122
123
  HttpBody.empty
123
124
  )
@@ -409,7 +410,7 @@ export const setUrl: {
409
410
  }
410
411
  const clone = new URL(url.toString())
411
412
  const urlParams = UrlParams.fromInput(clone.searchParams)
412
- const hash = clone.hash ? clone.hash.slice(1) : undefined
413
+ const hash = Option.fromNullishOr(clone.hash === "" ? undefined : clone.hash.slice(1))
413
414
  clone.search = ""
414
415
  clone.hash = ""
415
416
  return makeWith(
@@ -633,7 +634,7 @@ export const setHash: {
633
634
  self.method,
634
635
  self.url,
635
636
  self.urlParams,
636
- hash,
637
+ Option.some(hash),
637
638
  self.headers,
638
639
  self.body
639
640
  ))
@@ -647,7 +648,7 @@ export const removeHash = (self: HttpClientRequest): HttpClientRequest =>
647
648
  self.method,
648
649
  self.url,
649
650
  self.urlParams,
650
- undefined,
651
+ Option.none(),
651
652
  self.headers,
652
653
  self.body
653
654
  )
@@ -946,9 +947,10 @@ export const bodyFile: {
946
947
  * @since 4.0.0
947
948
  * @category combinators
948
949
  */
949
- export function toUrl(self: HttpClientRequest): URL | undefined {
950
- const r = UrlParams.makeUrl(self.url, self.urlParams, self.hash)
950
+ export function toUrl(self: HttpClientRequest): Option.Option<URL> {
951
+ const r = UrlParams.makeUrl(self.url, self.urlParams, Option.getOrUndefined(self.hash))
951
952
  if (Result.isSuccess(r)) {
952
- return r.success
953
+ return Option.some(r.success)
953
954
  }
955
+ return Option.none()
954
956
  }
@@ -4,6 +4,7 @@
4
4
  import * as Effect from "../../Effect.ts"
5
5
  import { dual } from "../../Function.ts"
6
6
  import * as Inspectable from "../../Inspectable.ts"
7
+ import * as Option from "../../Option.ts"
7
8
  import { type Pipeable, pipeArguments } from "../../Pipeable.ts"
8
9
  import * as Schema from "../../Schema.ts"
9
10
  import type { ParseOptions } from "../../SchemaAST.ts"
@@ -270,8 +271,8 @@ class WebHttpClientResponse extends Inspectable.Class implements HttpClientRespo
270
271
  return this.cachedCookies = Cookies.fromSetCookie(this.source.headers.getSetCookie())
271
272
  }
272
273
 
273
- get remoteAddress(): string | undefined {
274
- return undefined
274
+ get remoteAddress(): Option.Option<string> {
275
+ return Option.none()
275
276
  }
276
277
 
277
278
  get stream(): Stream.Stream<Uint8Array, Error.HttpClientError> {
@@ -298,10 +299,10 @@ class WebHttpClientResponse extends Inspectable.Class implements HttpClientRespo
298
299
  )
299
300
  }
300
301
 
301
- get json(): Effect.Effect<unknown, Error.HttpClientError> {
302
+ get json(): Effect.Effect<Schema.Json, Error.HttpClientError> {
302
303
  return Effect.flatMap(this.text, (text) =>
303
304
  Effect.try({
304
- try: () => text === "" ? null : JSON.parse(text) as unknown,
305
+ try: () => text === "" ? null : JSON.parse(text),
305
306
  catch: (cause) =>
306
307
  new Error.HttpClientError({
307
308
  reason: new Error.DecodeError({
@@ -4,6 +4,7 @@
4
4
  import * as Effect from "../../Effect.ts"
5
5
  import type * as FileSystem from "../../FileSystem.ts"
6
6
  import type * as Inspectable from "../../Inspectable.ts"
7
+ import type * as Option from "../../Option.ts"
7
8
  import { hasProperty } from "../../Predicate.ts"
8
9
  import { redact } from "../../Redactable.ts"
9
10
  import * as Schema from "../../Schema.ts"
@@ -32,8 +33,8 @@ export const isHttpIncomingMessage = (u: unknown): u is HttpIncomingMessage => h
32
33
  export interface HttpIncomingMessage<E = unknown> extends Inspectable.Inspectable {
33
34
  readonly [TypeId]: typeof TypeId
34
35
  readonly headers: Headers.Headers
35
- readonly remoteAddress: string | undefined
36
- readonly json: Effect.Effect<unknown, E>
36
+ readonly remoteAddress: Option.Option<string>
37
+ readonly json: Effect.Effect<Schema.Json, E>
37
38
  readonly text: Effect.Effect<string, E>
38
39
  readonly urlParamsBody: Effect.Effect<UrlParams.UrlParams, E>
39
40
  readonly arrayBuffer: Effect.Effect<ArrayBuffer, E>
@@ -6,6 +6,7 @@ import * as Effect from "../../Effect.ts"
6
6
  import { constant, constFalse } from "../../Function.ts"
7
7
  import * as internalEffect from "../../internal/effect.ts"
8
8
  import * as Layer from "../../Layer.ts"
9
+ import * as Option from "../../Option.ts"
9
10
  import type { Predicate } from "../../Predicate.ts"
10
11
  import type { ReadonlyRecord } from "../../Record.ts"
11
12
  import { TracerEnabled } from "../../References.ts"
@@ -102,7 +103,7 @@ export const logger: <E, R>(
102
103
  } else if (exit._tag === "Failure") {
103
104
  const [response, cause] = causeResponseStripped(exit.cause)
104
105
  return Effect.andThen(
105
- Effect.annotateLogs(Effect.log(cause ?? "Sent HTTP Response"), {
106
+ Effect.annotateLogs(Effect.log(Option.getOrElse(cause, () => "Sent HTTP Response")), {
106
107
  "http.method": request.method,
107
108
  "http.url": request.url,
108
109
  "http.status": response.status
@@ -139,7 +140,7 @@ export const tracer: <E, R>(
139
140
  }
140
141
  const nameGenerator = fiber.getRef(SpanNameGenerator)
141
142
  const span = internalEffect.makeSpanUnsafe(fiber, nameGenerator(request), {
142
- parent: TraceContext.fromHeaders(request.headers),
143
+ parent: Option.getOrUndefined(TraceContext.fromHeaders(request.headers)),
143
144
  kind: "server"
144
145
  })
145
146
  const prevServices = fiber.services
@@ -147,23 +148,23 @@ export const tracer: <E, R>(
147
148
  return Effect.onExitPrimitive(httpApp, (exit) => {
148
149
  fiber.setServices(prevServices)
149
150
  const endTime = fiber.getRef(Clock).currentTimeNanosUnsafe()
150
- fiber.currentScheduler.scheduleTask(() => {
151
+ fiber.currentDispatcher.scheduleTask(() => {
151
152
  const url = Request.toURL(request)
152
- if (url !== undefined && (url.username !== "" || url.password !== "")) {
153
- url.username = "REDACTED"
154
- url.password = "REDACTED"
153
+ if (Option.isSome(url) && (url.value.username !== "" || url.value.password !== "")) {
154
+ url.value.username = "REDACTED"
155
+ url.value.password = "REDACTED"
155
156
  }
156
157
  const redactedHeaderNames = fiber.getRef(Headers.CurrentRedactedNames)
157
158
  const requestHeaders = Headers.redact(request.headers, redactedHeaderNames)
158
159
  span.attribute("http.request.method", request.method)
159
- if (url !== undefined) {
160
- span.attribute("url.full", url.toString())
161
- span.attribute("url.path", url.pathname)
162
- const query = url.search.slice(1)
160
+ if (Option.isSome(url)) {
161
+ span.attribute("url.full", url.value.toString())
162
+ span.attribute("url.path", url.value.pathname)
163
+ const query = url.value.search.slice(1)
163
164
  if (query !== "") {
164
- span.attribute("url.query", url.search.slice(1))
165
+ span.attribute("url.query", url.value.search.slice(1))
165
166
  }
166
- span.attribute("url.scheme", url.protocol.slice(0, -1))
167
+ span.attribute("url.scheme", url.value.protocol.slice(0, -1))
167
168
  }
168
169
  if (request.headers["user-agent"] !== undefined) {
169
170
  span.attribute("user_agent.original", request.headers["user-agent"])
@@ -171,8 +172,8 @@ export const tracer: <E, R>(
171
172
  for (const name in requestHeaders) {
172
173
  span.attribute(`http.request.header.${name}`, String(requestHeaders[name]))
173
174
  }
174
- if (request.remoteAddress !== undefined) {
175
- span.attribute("client.address", request.remoteAddress)
175
+ if (Option.isSome(request.remoteAddress)) {
176
+ span.attribute("client.address", request.remoteAddress.value)
176
177
  }
177
178
  const response = exitResponse(exit)
178
179
  span.attribute("http.response.status_code", response.status)
@@ -200,7 +201,7 @@ export const xForwardedHeaders = make((httpApp) =>
200
201
  "host",
201
202
  request.headers["x-forwarded-host"]
202
203
  ),
203
- remoteAddress: request.headers["x-forwarded-for"]?.split(",")[0].trim()
204
+ remoteAddress: Option.fromNullishOr(request.headers["x-forwarded-for"]?.split(",")[0].trim())
204
205
  })
205
206
  : request)
206
207
  )
@@ -5,6 +5,7 @@ import * as Effect from "../../Effect.ts"
5
5
  import * as FileSystem from "../../FileSystem.ts"
6
6
  import { identity } from "../../Function.ts"
7
7
  import * as Layer from "../../Layer.ts"
8
+ import * as Option from "../../Option.ts"
8
9
  import type { PlatformError } from "../../PlatformError.ts"
9
10
  import * as ServiceMap from "../../ServiceMap.ts"
10
11
  import * as Stream from "../../Stream.ts"
@@ -80,8 +81,8 @@ export const make: (impl: {
80
81
  "etag",
81
82
  Etag.toString(etag)
82
83
  )
83
- if (info.mtime) {
84
- ;(headers as any)["last-modified"] = info.mtime.toUTCString()
84
+ if (Option.isSome(info.mtime)) {
85
+ ;(headers as any)["last-modified"] = info.mtime.value.toUTCString()
85
86
  }
86
87
  const contentLength = end !== undefined ? end - start : Number(info.size) - start
87
88
  return impl.fileResponse(
@@ -5,6 +5,7 @@ import * as Arr from "../../Array.ts"
5
5
  import * as Effect from "../../Effect.ts"
6
6
  import { compose, dual, identity } from "../../Function.ts"
7
7
  import * as Layer from "../../Layer.ts"
8
+ import * as Option from "../../Option.ts"
8
9
  import type { ReadonlyRecord } from "../../Record.ts"
9
10
  import * as Schema from "../../Schema.ts"
10
11
  import type { ParseOptions } from "../../SchemaAST.ts"
@@ -12,7 +13,6 @@ import * as Scope from "../../Scope.ts"
12
13
  import * as ServiceMap from "../../ServiceMap.ts"
13
14
  import * as Tracer from "../../Tracer.ts"
14
15
  import type * as Types from "../../Types.ts"
15
- import * as UndefinedOr from "../../UndefinedOr.ts"
16
16
  import * as FindMyWay from "./FindMyWay.ts"
17
17
  import * as HttpEffect from "./HttpEffect.ts"
18
18
  import type * as HttpMethod from "./HttpMethod.ts"
@@ -177,8 +177,8 @@ export const make = Effect.gen(function*() {
177
177
  )
178
178
  }
179
179
  const route = result.handler
180
- if (route.prefix !== undefined) {
181
- contextMap.set(HttpServerRequest.HttpServerRequest.key, sliceRequestUrl(request, route.prefix))
180
+ if (Option.isSome(route.prefix)) {
181
+ contextMap.set(HttpServerRequest.HttpServerRequest.key, sliceRequestUrl(request, route.prefix.value))
182
182
  }
183
183
  contextMap.set(HttpServerRequest.ParsedSearchParams.key, result.searchParams)
184
184
  contextMap.set(RouteContext.key, {
@@ -501,7 +501,7 @@ export interface Route<E = never, R = never> {
501
501
  readonly path: PathInput
502
502
  readonly handler: Effect.Effect<HttpServerResponse.HttpServerResponse, E, R>
503
503
  readonly uninterruptible: boolean
504
- readonly prefix: string | undefined
504
+ readonly prefix: Option.Option<string>
505
505
  }
506
506
 
507
507
  /**
@@ -527,12 +527,12 @@ const makeRoute = <E, R>(options: {
527
527
  readonly path: PathInput
528
528
  readonly handler: Effect.Effect<HttpServerResponse.HttpServerResponse, E, R>
529
529
  readonly uninterruptible?: boolean | undefined
530
- readonly prefix?: string | undefined
530
+ readonly prefix?: Option.Option<string> | string | undefined
531
531
  }): Route<E, Exclude<R, Provided>> =>
532
532
  (({
533
533
  ...options,
534
534
  uninterruptible: options.uninterruptible ?? false,
535
- prefix: options.prefix,
535
+ prefix: typeof options.prefix === "string" ? Option.some(options.prefix) : options.prefix ?? Option.none(),
536
536
  [RouteTypeId]: RouteTypeId
537
537
  }) as Route<E, Exclude<R, Provided>>)
538
538
 
@@ -614,9 +614,9 @@ export const prefixRoute: {
614
614
  makeRoute({
615
615
  ...self,
616
616
  path: prefixPath(self.path, prefix) as PathInput,
617
- prefix: UndefinedOr.match(self.prefix, {
618
- onUndefined: () => prefix as string,
619
- onDefined: (existingPrefix) => prefixPath(existingPrefix, prefix) as string
617
+ prefix: Option.match(self.prefix, {
618
+ onNone: () => prefix as string,
619
+ onSome: (existingPrefix) => prefixPath(existingPrefix, prefix) as string
620
620
  })
621
621
  }))
622
622
 
@@ -36,6 +36,7 @@ export class HttpServer extends ServiceMap.Service<HttpServer, {
36
36
  Exclude<R, HttpServerRequest> | Scope.Scope
37
37
  >
38
38
  }
39
+
39
40
  readonly address: Address
40
41
  }>()("effect/http/HttpServer") {}
41
42
 
@@ -127,10 +128,7 @@ export const serve: {
127
128
  HttpServer | Exclude<Effect.Services<App>, HttpServerRequest | Scope.Scope>
128
129
  > =>
129
130
  Layer.effectDiscard(
130
- Effect.flatMap(
131
- HttpServer.asEffect(),
132
- (server) => server.serve(effect, middleware!)
133
- )
131
+ HttpServer.use((server) => server.serve(effect, middleware!))
134
132
  ) as any)
135
133
 
136
134
  /**
@@ -180,11 +178,7 @@ export const serveEffect: {
180
178
  void,
181
179
  never,
182
180
  Scope.Scope | HttpServer | Exclude<Effect.Services<App>, HttpServerRequest>
183
- > =>
184
- Effect.flatMap(
185
- HttpServer.asEffect(),
186
- (server) => server.serve(effect, middleware!)
187
- ) as any)
181
+ > => HttpServer.use((server) => server.serve(effect, middleware!)) as any)
188
182
 
189
183
  /**
190
184
  * @since 4.0.0
@@ -7,6 +7,7 @@ import * as Effect from "../../Effect.ts"
7
7
  import * as ErrorReporter from "../../ErrorReporter.ts"
8
8
  import type * as Exit from "../../Exit.ts"
9
9
  import { constUndefined } from "../../Function.ts"
10
+ import * as Option from "../../Option.ts"
10
11
  import { hasProperty } from "../../Predicate.ts"
11
12
  import * as ServiceMap from "../../ServiceMap.ts"
12
13
  import type * as Request from "./HttpServerRequest.ts"
@@ -256,7 +257,7 @@ export const causeResponse = <E>(
256
257
  */
257
258
  export const causeResponseStripped = <E>(
258
259
  cause: Cause.Cause<E>
259
- ): readonly [response: Response.HttpServerResponse, cause: Cause.Cause<E> | undefined] => {
260
+ ): readonly [response: Response.HttpServerResponse, cause: Option.Option<Cause.Cause<E>>] => {
260
261
  let response: Response.HttpServerResponse | undefined
261
262
  const failures = cause.reasons.filter((f) => {
262
263
  if (f._tag === "Die" && Response.isHttpServerResponse(f.defect)) {
@@ -267,7 +268,7 @@ export const causeResponseStripped = <E>(
267
268
  })
268
269
  return [
269
270
  response ?? internalServerError,
270
- failures.length > 0 ? Cause.fromReasons(failures) : undefined
271
+ failures.length > 0 ? Option.some(Cause.fromReasons(failures)) : Option.none()
271
272
  ]
272
273
  }
273
274
 
@@ -6,6 +6,7 @@ import * as Channel from "../../Channel.ts"
6
6
  import * as Effect from "../../Effect.ts"
7
7
  import type * as FileSystem from "../../FileSystem.ts"
8
8
  import * as Inspectable from "../../Inspectable.ts"
9
+ import * as Option from "../../Option.ts"
9
10
  import type * as Path from "../../Path.ts"
10
11
  import type { ReadonlyRecord } from "../../Record.ts"
11
12
  import * as Result from "../../Result.ts"
@@ -64,7 +65,7 @@ export interface HttpServerRequest extends HttpIncomingMessage.HttpIncomingMessa
64
65
  options: {
65
66
  readonly url?: string
66
67
  readonly headers?: Headers.Headers
67
- readonly remoteAddress?: string
68
+ readonly remoteAddress?: Option.Option<string>
68
69
  }
69
70
  ) => HttpServerRequest
70
71
  }
@@ -284,7 +285,10 @@ export const schemaBodyFormJson = <A, I, RD, RE>(
284
285
  * @category conversions
285
286
  */
286
287
  export const fromClientRequest = (request: HttpClientRequest.HttpClientRequest): HttpServerRequest => {
287
- const url = HttpClientRequest.toUrl(request)?.toString() ?? request.url
288
+ const url = Option.match(HttpClientRequest.toUrl(request), {
289
+ onNone: () => request.url,
290
+ onSome: (url) => url.toString()
291
+ })
288
292
  return new ClientRequestImpl(request, url)
289
293
  }
290
294
 
@@ -305,11 +309,11 @@ export const toClientRequest = (request: HttpServerRequest): HttpClientRequest.H
305
309
  request.method,
306
310
  "",
307
311
  UrlParams.empty,
308
- undefined,
312
+ Option.none(),
309
313
  request.headers,
310
314
  toClientBody(request)
311
315
  ),
312
- toURL(request) ?? request.url
316
+ Option.getOrElse(toURL(request), () => request.url)
313
317
  )
314
318
 
315
319
  const toClientBody = (request: HttpServerRequest): HttpBody.HttpBody =>
@@ -343,13 +347,13 @@ class ServerRequestImpl extends Inspectable.Class implements HttpServerRequest {
343
347
  readonly source: Request
344
348
  readonly url: string
345
349
  public headersOverride?: Headers.Headers | undefined
346
- private remoteAddressOverride?: string | undefined
350
+ private remoteAddressOverride?: Option.Option<string> | undefined
347
351
 
348
352
  constructor(
349
353
  source: Request,
350
354
  url: string,
351
355
  headersOverride?: Headers.Headers,
352
- remoteAddressOverride?: string
356
+ remoteAddressOverride?: Option.Option<string>
353
357
  ) {
354
358
  super()
355
359
  this[TypeId] = TypeId
@@ -370,14 +374,14 @@ class ServerRequestImpl extends Inspectable.Class implements HttpServerRequest {
370
374
  options: {
371
375
  readonly url?: string | undefined
372
376
  readonly headers?: Headers.Headers | undefined
373
- readonly remoteAddress?: string | undefined
377
+ readonly remoteAddress?: Option.Option<string> | undefined
374
378
  }
375
379
  ) {
376
380
  return new ServerRequestImpl(
377
381
  this.source,
378
382
  options.url ?? this.url,
379
383
  options.headers ?? this.headersOverride,
380
- options.remoteAddress ?? this.remoteAddressOverride
384
+ "remoteAddress" in options ? options.remoteAddress : this.remoteAddressOverride
381
385
  )
382
386
  }
383
387
  get method(): HttpMethod {
@@ -386,8 +390,8 @@ class ServerRequestImpl extends Inspectable.Class implements HttpServerRequest {
386
390
  get originalUrl() {
387
391
  return this.source.url
388
392
  }
389
- get remoteAddress(): string | undefined {
390
- return this.remoteAddressOverride ? this.remoteAddressOverride : undefined
393
+ get remoteAddress(): Option.Option<string> {
394
+ return this.remoteAddressOverride ?? Option.none()
391
395
  }
392
396
  get headers(): Headers.Headers {
393
397
  this.headersOverride ??= Headers.fromInput(this.source.headers as any)
@@ -444,10 +448,10 @@ class ServerRequestImpl extends Inspectable.Class implements HttpServerRequest {
444
448
  return this.textEffect
445
449
  }
446
450
 
447
- get json(): Effect.Effect<unknown, HttpServerError> {
451
+ get json(): Effect.Effect<Schema.Json, HttpServerError> {
448
452
  return Effect.flatMap(this.text, (text) =>
449
453
  Effect.try({
450
- try: () => JSON.parse(text) as unknown,
454
+ try: () => JSON.parse(text) as Schema.Json,
451
455
  catch: (cause) =>
452
456
  new HttpServerError({
453
457
  reason: new RequestParseError({
@@ -538,7 +542,7 @@ class ClientRequestImpl extends Inspectable.Class implements HttpServerRequest {
538
542
  readonly source: HttpClientRequest.HttpClientRequest
539
543
  public originalUrl: string
540
544
  public headersOverride?: Headers.Headers | undefined
541
- private remoteAddressOverride?: string | undefined
545
+ private remoteAddressOverride?: Option.Option<string> | undefined
542
546
  private urlOverride?: string | undefined
543
547
 
544
548
  constructor(
@@ -546,7 +550,7 @@ class ClientRequestImpl extends Inspectable.Class implements HttpServerRequest {
546
550
  originalUrl: string,
547
551
  urlOverride?: string,
548
552
  headersOverride?: Headers.Headers,
549
- remoteAddressOverride?: string
553
+ remoteAddressOverride?: Option.Option<string>
550
554
  ) {
551
555
  super()
552
556
  this[TypeId] = TypeId
@@ -570,7 +574,7 @@ class ClientRequestImpl extends Inspectable.Class implements HttpServerRequest {
570
574
  options: {
571
575
  readonly url?: string | undefined
572
576
  readonly headers?: Headers.Headers | undefined
573
- readonly remoteAddress?: string | undefined
577
+ readonly remoteAddress?: Option.Option<string> | undefined
574
578
  }
575
579
  ) {
576
580
  return new ClientRequestImpl(
@@ -578,7 +582,7 @@ class ClientRequestImpl extends Inspectable.Class implements HttpServerRequest {
578
582
  this.originalUrl,
579
583
  options.url ?? this.url,
580
584
  options.headers ?? this.headersOverride,
581
- options.remoteAddress ?? this.remoteAddressOverride
585
+ "remoteAddress" in options ? options.remoteAddress : this.remoteAddressOverride
582
586
  )
583
587
  }
584
588
 
@@ -590,8 +594,8 @@ class ClientRequestImpl extends Inspectable.Class implements HttpServerRequest {
590
594
  return this.urlOverride ?? removeHost(this.originalUrl)
591
595
  }
592
596
 
593
- get remoteAddress(): string | undefined {
594
- return this.remoteAddressOverride ? this.remoteAddressOverride : undefined
597
+ get remoteAddress(): Option.Option<string> {
598
+ return this.remoteAddressOverride ?? Option.none()
595
599
  }
596
600
 
597
601
  get headers(): Headers.Headers {
@@ -664,10 +668,10 @@ class ClientRequestImpl extends Inspectable.Class implements HttpServerRequest {
664
668
  return Effect.map(this.bytes, (bytes) => textDecoder.decode(bytes))
665
669
  }
666
670
 
667
- get json(): Effect.Effect<unknown, HttpServerError> {
671
+ get json(): Effect.Effect<Schema.Json, HttpServerError> {
668
672
  return Effect.flatMap(this.text, (text) =>
669
673
  Effect.try({
670
- try: () => text === "" ? null : JSON.parse(text) as unknown,
674
+ try: () => text === "" ? null : JSON.parse(text),
671
675
  catch: (cause) => requestParseError(this, undefined, cause)
672
676
  }))
673
677
  }
@@ -877,13 +881,13 @@ const textDecoder = new TextDecoder()
877
881
  * @since 4.0.0
878
882
  * @category conversions
879
883
  */
880
- export const toURL = (self: HttpServerRequest): URL | undefined => {
884
+ export const toURL = (self: HttpServerRequest): Option.Option<URL> => {
881
885
  const host = self.headers.host ?? "localhost"
882
886
  const protocol = self.headers["x-forwarded-proto"] === "https" ? "https" : "http"
883
887
  try {
884
- return new URL(self.url, `${protocol}://${host}`)
888
+ return Option.some(new URL(self.url, `${protocol}://${host}`))
885
889
  } catch {
886
- return undefined
890
+ return Option.none()
887
891
  }
888
892
  }
889
893
 
@@ -899,7 +903,7 @@ export const toWebResult = (self: HttpServerRequest, options?: {
899
903
  return Result.succeed(self.source)
900
904
  }
901
905
  const url = toURL(self)
902
- if (url === undefined) {
906
+ if (Option.isNone(url)) {
903
907
  return Result.fail(
904
908
  new RequestParseError({
905
909
  request: self,
@@ -918,7 +922,7 @@ export const toWebResult = (self: HttpServerRequest, options?: {
918
922
  requestInit.body = Stream.toReadableStreamWith(self.stream, options?.services ?? ServiceMap.empty())
919
923
  ;(requestInit as any).duplex = "half"
920
924
  }
921
- return Result.succeed(new Request(url, requestInit))
925
+ return Result.succeed(new Request(url.value, requestInit))
922
926
  }
923
927
 
924
928
  /**
@@ -7,6 +7,7 @@ import type * as FileSystem from "../../FileSystem.ts"
7
7
  import { dual } from "../../Function.ts"
8
8
  import * as Inspectable from "../../Inspectable.ts"
9
9
  import { PipeInspectableProto } from "../../internal/core.ts"
10
+ import * as Option from "../../Option.ts"
10
11
  import { type Pipeable, pipeArguments } from "../../Pipeable.ts"
11
12
  import type { PlatformError } from "../../PlatformError.ts"
12
13
  import { hasProperty } from "../../Predicate.ts"
@@ -965,8 +966,8 @@ class ServerHttpClientResponse extends Inspectable.Class implements HttpClientRe
965
966
  return this.response.cookies
966
967
  }
967
968
 
968
- get remoteAddress(): string | undefined {
969
- return undefined
969
+ get remoteAddress(): Option.Option<string> {
970
+ return Option.none()
970
971
  }
971
972
 
972
973
  get stream(): Stream.Stream<Uint8Array, HttpClientError.HttpClientError> {
@@ -1015,10 +1016,10 @@ class ServerHttpClientResponse extends Inspectable.Class implements HttpClientRe
1015
1016
  }
1016
1017
  }
1017
1018
 
1018
- get json(): Effect.Effect<unknown, HttpClientError.HttpClientError> {
1019
+ get json(): Effect.Effect<Schema.Json, HttpClientError.HttpClientError> {
1019
1020
  return Effect.flatMap(this.text, (text) =>
1020
1021
  Effect.try({
1021
- try: () => text === "" ? null : JSON.parse(text) as unknown,
1022
+ try: () => text === "" ? null : JSON.parse(text),
1022
1023
  catch: (cause) =>
1023
1024
  new HttpClientError.HttpClientError({
1024
1025
  reason: new HttpClientError.DecodeError({
@@ -1137,7 +1138,7 @@ export const fromClientResponse = (
1137
1138
  cookies: response.cookies,
1138
1139
  body: Body.stream(
1139
1140
  Stream.catchIf(response.stream, isEmptyBodyError, () => Stream.empty),
1140
- Headers.get(headers, "content-type"),
1141
+ Option.getOrUndefined(Headers.get(headers, "content-type")),
1141
1142
  getContentLength(headers)
1142
1143
  )
1143
1144
  })
@@ -1152,7 +1153,7 @@ const isEmptyBodyError = (
1152
1153
  HttpClientError.isHttpClientError(error) && error.reason._tag === "EmptyBodyError"
1153
1154
 
1154
1155
  const getContentLength = (headers: Headers.Headers): number | undefined => {
1155
- const contentLength = Headers.get(headers, "content-length")
1156
+ const contentLength = Option.getOrUndefined(Headers.get(headers, "content-length"))
1156
1157
  if (contentLength === undefined) {
1157
1158
  return undefined
1158
1159
  }