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
package/src/Iterable.ts CHANGED
@@ -12,7 +12,7 @@
12
12
  *
13
13
  * @example
14
14
  * ```ts
15
- * import { Iterable } from "effect"
15
+ * import { Iterable, Option } from "effect"
16
16
  *
17
17
  * // Create iterables
18
18
  * const numbers = Iterable.range(1, 5)
@@ -22,7 +22,7 @@
22
22
  * console.log(Array.from(filtered)) // [6, 8, 10]
23
23
  *
24
24
  * // Infinite iterables
25
- * const fibonacci = Iterable.unfold([0, 1], ([a, b]) => [a, [b, a + b]])
25
+ * const fibonacci = Iterable.unfold([0, 1], ([a, b]) => Option.some([a, [b, a + b]]))
26
26
  * const first10 = Iterable.take(fibonacci, 10)
27
27
  * console.log(Array.from(first10)) // [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
28
28
  * ```
@@ -4054,31 +4054,31 @@ export const some: {
4054
4054
  * next element and state.
4055
4055
  *
4056
4056
  * This is useful for creating iterables from a generating function that
4057
- * maintains state. The function should return `[value, nextState]` to continue
4058
- * or `undefined` to stop.
4057
+ * maintains state. The function should return `Option.some([value, nextState])`
4058
+ * to continue or `Option.none()` to stop.
4059
4059
  *
4060
4060
  * @example
4061
4061
  * ```ts
4062
- * import { Iterable } from "effect"
4062
+ * import { Iterable, Option } from "effect"
4063
4063
  *
4064
4064
  * // Generate Fibonacci sequence
4065
- * const fibonacci = Iterable.unfold([0, 1], ([a, b]) => [a, [b, a + b]])
4065
+ * const fibonacci = Iterable.unfold([0, 1], ([a, b]) => Option.some([a, [b, a + b]]))
4066
4066
  * const first10Fib = Iterable.take(fibonacci, 10)
4067
4067
  * console.log(Array.from(first10Fib)) // [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
4068
4068
  *
4069
4069
  * // Generate powers of 2 up to a limit
4070
- * const powersOf2 = Iterable.unfold(1, (n) => n <= 1000 ? [n, n * 2] : undefined)
4070
+ * const powersOf2 = Iterable.unfold(1, (n) => n <= 1000 ? Option.some([n, n * 2]) : Option.none())
4071
4071
  * console.log(Array.from(powersOf2)) // [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]
4072
4072
  *
4073
4073
  * // Generate countdown
4074
- * const countdown = Iterable.unfold(5, (n) => n > 0 ? [n, n - 1] : undefined)
4074
+ * const countdown = Iterable.unfold(5, (n) => n > 0 ? Option.some([n, n - 1]) : Option.none())
4075
4075
  * console.log(Array.from(countdown)) // [5, 4, 3, 2, 1]
4076
4076
  *
4077
4077
  * // Generate collatz sequence
4078
4078
  * const collatz = Iterable.unfold(7, (n) => {
4079
- * if (n === 1) return undefined
4079
+ * if (n === 1) return Option.none()
4080
4080
  * const next = n % 2 === 0 ? n / 2 : n * 3 + 1
4081
- * return [n, next]
4081
+ * return Option.some([n, next])
4082
4082
  * })
4083
4083
  * console.log(Array.from(collatz)) // [7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2]
4084
4084
  * ```
@@ -4086,16 +4086,16 @@ export const some: {
4086
4086
  * @category constructors
4087
4087
  * @since 2.0.0
4088
4088
  */
4089
- export const unfold = <B, A>(b: B, f: (b: B) => readonly [A, B] | undefined): Iterable<A> => ({
4089
+ export const unfold = <B, A>(b: B, f: (b: B) => Option<readonly [A, B]>): Iterable<A> => ({
4090
4090
  [Symbol.iterator]() {
4091
4091
  let next = b
4092
4092
  return {
4093
4093
  next() {
4094
4094
  const ab = f(next)
4095
- if (ab === undefined) {
4095
+ if (O.isNone(ab)) {
4096
4096
  return { done: true, value: undefined }
4097
4097
  }
4098
- const [a, b] = ab
4098
+ const [a, b] = ab.value
4099
4099
  next = b
4100
4100
  return { done: false, value: a }
4101
4101
  }
package/src/Latch.ts CHANGED
@@ -26,7 +26,7 @@ export interface Latch {
26
26
  /** open the latch, releasing all fibers waiting on it */
27
27
  readonly open: Effect.Effect<boolean>
28
28
  /** open the latch, releasing all fibers waiting on it */
29
- readonly openUnsafe: () => boolean
29
+ openUnsafe(this: Latch): boolean
30
30
  /** release all fibers waiting on the latch, without opening it */
31
31
  readonly release: Effect.Effect<boolean>
32
32
  /** wait for the latch to be opened */
@@ -34,9 +34,9 @@ export interface Latch {
34
34
  /** close the latch */
35
35
  readonly close: Effect.Effect<boolean>
36
36
  /** close the latch */
37
- readonly closeUnsafe: () => boolean
37
+ closeUnsafe(this: Latch): boolean
38
38
  /** only run the given effect when the latch is open */
39
- readonly whenOpen: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
39
+ whenOpen<A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>
40
40
  }
41
41
 
42
42
  /**
@@ -110,3 +110,85 @@ export const makeUnsafe: (open?: boolean | undefined) => Latch = internal.makeLa
110
110
  * @since 3.8.0
111
111
  */
112
112
  export const make: (open?: boolean | undefined) => Effect.Effect<Latch> = internal.makeLatch
113
+
114
+ /**
115
+ * Opens the latch, releasing all fibers waiting on it.
116
+ *
117
+ * @category combinators
118
+ * @since 4.0.0
119
+ */
120
+ export const open = (self: Latch): Effect.Effect<boolean> => self.open
121
+
122
+ /**
123
+ * Opens the latch, releasing all fibers waiting on it.
124
+ *
125
+ * @category unsafe
126
+ * @since 4.0.0
127
+ */
128
+ export const openUnsafe = (self: Latch): boolean => self.openUnsafe()
129
+
130
+ /**
131
+ * Releases all fibers waiting on the latch, without opening it.
132
+ *
133
+ * @category combinators
134
+ * @since 4.0.0
135
+ */
136
+ export const release = (self: Latch): Effect.Effect<boolean> => self.release
137
+
138
+ const _await = (self: Latch): Effect.Effect<void> => self.await
139
+
140
+ export {
141
+ /**
142
+ * Waits for the latch to be opened.
143
+ *
144
+ * @category getters
145
+ * @since 4.0.0
146
+ */
147
+ _await as await
148
+ }
149
+
150
+ /**
151
+ * Closes the latch.
152
+ *
153
+ * @category combinators
154
+ * @since 4.0.0
155
+ */
156
+ export const close = (self: Latch): Effect.Effect<boolean> => self.close
157
+
158
+ /**
159
+ * Closes the latch.
160
+ *
161
+ * @category unsafe
162
+ * @since 4.0.0
163
+ */
164
+ export const closeUnsafe = (self: Latch): boolean => self.closeUnsafe()
165
+
166
+ /**
167
+ * Runs the given effect only when the latch is open.
168
+ *
169
+ * @category combinators
170
+ * @since 4.0.0
171
+ */
172
+ export const whenOpen: {
173
+ /**
174
+ * Runs the given effect only when the latch is open.
175
+ *
176
+ * @category combinators
177
+ * @since 4.0.0
178
+ */
179
+ (self: Latch): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
180
+ /**
181
+ * Runs the given effect only when the latch is open.
182
+ *
183
+ * @category combinators
184
+ * @since 4.0.0
185
+ */
186
+ <A, E, R>(self: Latch, effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>
187
+ } = ((...args: Array<any>) => {
188
+ if (args.length === 1) {
189
+ const [self] = args
190
+ return (effect: Effect.Effect<any, any, any>) => self.whenOpen(effect)
191
+ }
192
+ const [self, effect] = args
193
+ return self.whenOpen(effect)
194
+ }) as any
package/src/Layer.ts CHANGED
@@ -2447,6 +2447,127 @@ export const flatMap: {
2447
2447
  )
2448
2448
  ))
2449
2449
 
2450
+ /**
2451
+ * Performs the specified effect if this layer succeeds.
2452
+ *
2453
+ * @since 4.0.0
2454
+ * @category sequencing
2455
+ */
2456
+ export const tap: {
2457
+ /**
2458
+ * Performs the specified effect if this layer succeeds.
2459
+ *
2460
+ * @since 4.0.0
2461
+ * @category sequencing
2462
+ */
2463
+ <ROut, XR extends ROut, RIn2, E2, X>(f: (context: ServiceMap.ServiceMap<XR>) => Effect<X, E2, RIn2>): <RIn, E>(self: Layer<ROut, E, RIn>) => Layer<ROut, E | E2, RIn | Exclude<RIn2, Scope.Scope>>
2464
+ /**
2465
+ * Performs the specified effect if this layer succeeds.
2466
+ *
2467
+ * @since 4.0.0
2468
+ * @category sequencing
2469
+ */
2470
+ <RIn, E, ROut, XR extends ROut, RIn2, E2, X>(
2471
+ self: Layer<ROut, E, RIn>,
2472
+ f: (context: ServiceMap.ServiceMap<XR>) => Effect<X, E2, RIn2>
2473
+ ): Layer<ROut, E | E2, RIn | Exclude<RIn2, Scope.Scope>>
2474
+ } = dual(2, <RIn, E, ROut, XR extends ROut, RIn2, E2, X>(
2475
+ self: Layer<ROut, E, RIn>,
2476
+ f: (context: ServiceMap.ServiceMap<XR>) => Effect<X, E2, RIn2>
2477
+ ): Layer<ROut, E | E2, RIn | Exclude<RIn2, Scope.Scope>> =>
2478
+ fromBuild((memoMap, scope) =>
2479
+ internalEffect.flatMap(
2480
+ self.build(memoMap, scope),
2481
+ (context) => Scope.provide(internalEffect.as(f(context as ServiceMap.ServiceMap<XR>), context), scope)
2482
+ )
2483
+ ))
2484
+
2485
+ /**
2486
+ * Performs the specified effect if this layer fails.
2487
+ *
2488
+ * @since 4.0.0
2489
+ * @category sequencing
2490
+ */
2491
+ export const tapError: {
2492
+ /**
2493
+ * Performs the specified effect if this layer fails.
2494
+ *
2495
+ * @since 4.0.0
2496
+ * @category sequencing
2497
+ */
2498
+ <E, XE extends E, RIn2, E2, X>(f: (e: XE) => Effect<X, E2, RIn2>): <RIn, ROut>(self: Layer<ROut, E, RIn>) => Layer<ROut, E | E2, RIn | Exclude<RIn2, Scope.Scope>>
2499
+ /**
2500
+ * Performs the specified effect if this layer fails.
2501
+ *
2502
+ * @since 4.0.0
2503
+ * @category sequencing
2504
+ */
2505
+ <RIn, E, XE extends E, ROut, RIn2, E2, X>(self: Layer<ROut, E, RIn>, f: (e: XE) => Effect<X, E2, RIn2>): Layer<ROut, E | E2, RIn | Exclude<RIn2, Scope.Scope>>
2506
+ } = dual(2, <RIn, E, XE extends E, ROut, RIn2, E2, X>(
2507
+ self: Layer<ROut, E, RIn>,
2508
+ f: (e: XE) => Effect<X, E2, RIn2>
2509
+ ): Layer<ROut, E | E2, RIn | Exclude<RIn2, Scope.Scope>> =>
2510
+ fromBuild((memoMap, scope) =>
2511
+ internalEffect.catch_(
2512
+ self.build(memoMap, scope),
2513
+ (error) => Scope.provide(internalEffect.andThen(f(error as XE), internalEffect.fail(error)), scope)
2514
+ )
2515
+ ))
2516
+
2517
+ /**
2518
+ * Performs the specified effect if this layer fails.
2519
+ *
2520
+ * **Previously Known As**
2521
+ *
2522
+ * This API replaces the following from Effect 3.x:
2523
+ *
2524
+ * - `Layer.tapErrorCause`
2525
+ *
2526
+ * @since 4.0.0
2527
+ * @category sequencing
2528
+ */
2529
+ export const tapCause: {
2530
+ /**
2531
+ * Performs the specified effect if this layer fails.
2532
+ *
2533
+ * **Previously Known As**
2534
+ *
2535
+ * This API replaces the following from Effect 3.x:
2536
+ *
2537
+ * - `Layer.tapErrorCause`
2538
+ *
2539
+ * @since 4.0.0
2540
+ * @category sequencing
2541
+ */
2542
+ <E, XE extends E, RIn2, E2, X>(f: (cause: Cause.Cause<XE>) => Effect<X, E2, RIn2>): <RIn, ROut>(self: Layer<ROut, E, RIn>) => Layer<ROut, E | E2, RIn | Exclude<RIn2, Scope.Scope>>
2543
+ /**
2544
+ * Performs the specified effect if this layer fails.
2545
+ *
2546
+ * **Previously Known As**
2547
+ *
2548
+ * This API replaces the following from Effect 3.x:
2549
+ *
2550
+ * - `Layer.tapErrorCause`
2551
+ *
2552
+ * @since 4.0.0
2553
+ * @category sequencing
2554
+ */
2555
+ <RIn, E, XE extends E, ROut, RIn2, E2, X>(
2556
+ self: Layer<ROut, E, RIn>,
2557
+ f: (cause: Cause.Cause<XE>) => Effect<X, E2, RIn2>
2558
+ ): Layer<ROut, E | E2, RIn | Exclude<RIn2, Scope.Scope>>
2559
+ } = dual(2, <RIn, E, XE extends E, ROut, RIn2, E2, X>(
2560
+ self: Layer<ROut, E, RIn>,
2561
+ f: (cause: Cause.Cause<XE>) => Effect<X, E2, RIn2>
2562
+ ): Layer<ROut, E | E2, RIn | Exclude<RIn2, Scope.Scope>> =>
2563
+ fromBuild((memoMap, scope) =>
2564
+ internalEffect.catchCause(
2565
+ self.build(memoMap, scope),
2566
+ (cause) =>
2567
+ Scope.provide(internalEffect.andThen(f(cause as Cause.Cause<XE>), internalEffect.failCause(cause)), scope)
2568
+ )
2569
+ ))
2570
+
2450
2571
  /**
2451
2572
  * Translates effect failure into death of the fiber, making all failures
2452
2573
  * unchecked and not a part of the type of the layer.
@@ -3062,7 +3183,7 @@ export type PartialEffectful<A extends object> = Types.Simplify<
3062
3183
  * }>()("UserService") {}
3063
3184
  *
3064
3185
  * // Create a partial mock - only implement what you need for testing
3065
- * const testUserLayer = Layer.mock(UserService)({
3186
+ * const testUserLayer = Layer.mock(UserService, {
3066
3187
  * config: { apiUrl: "https://test-api.com" }, // Required - non-Effect property
3067
3188
  * getUser: (id: string) => Effect.succeed({ id, name: "Test User" }) // Mock implementation
3068
3189
  * // deleteUser and updateUser are omitted - will throw UnimplementedError if called
@@ -3086,24 +3207,128 @@ export type PartialEffectful<A extends object> = Types.Simplify<
3086
3207
  * @since 4.0.0
3087
3208
  * @category Testing
3088
3209
  */
3089
- export const mock =
3090
- <I, S extends object>(service: ServiceMap.Key<I, S>) => (implementation: PartialEffectful<S>): Layer<I> =>
3091
- succeed(service)(
3092
- new Proxy({ ...implementation as object } as S, {
3093
- get(target, prop, _receiver) {
3094
- if (prop in target) {
3095
- return target[prop as keyof S]
3096
- }
3097
- const prevLimit = (Error as ErrorWithStackTraceLimit).stackTraceLimit
3098
- ;(Error as ErrorWithStackTraceLimit).stackTraceLimit = 2
3099
- const error = new Error(`${service.key}: Unimplemented method "${prop.toString()}"`)
3100
- ;(Error as ErrorWithStackTraceLimit).stackTraceLimit = prevLimit
3101
- error.name = "UnimplementedError"
3102
- return makeUnimplemented(error)
3103
- },
3104
- has: constTrue
3105
- })
3106
- )
3210
+ export const mock: {
3211
+ /**
3212
+ * Creates a mock layer for testing purposes. You can provide a partial
3213
+ * implementation of the service, and any methods not provided will
3214
+ * throw an unimplemented defect when called.
3215
+ *
3216
+ * @example
3217
+ * ```ts
3218
+ * import { Effect, Layer, ServiceMap } from "effect"
3219
+ *
3220
+ * class UserService extends ServiceMap.Service<UserService, {
3221
+ * readonly config: { apiUrl: string }
3222
+ * readonly getUser: (
3223
+ * id: string
3224
+ * ) => Effect.Effect<{ id: string; name: string }, Error>
3225
+ * readonly deleteUser: (id: string) => Effect.Effect<void, Error>
3226
+ * readonly updateUser: (
3227
+ * id: string,
3228
+ * data: object
3229
+ * ) => Effect.Effect<{ id: string; name: string }, Error>
3230
+ * }>()("UserService") {}
3231
+ *
3232
+ * // Create a partial mock - only implement what you need for testing
3233
+ * const testUserLayer = Layer.mock(UserService, {
3234
+ * config: { apiUrl: "https://test-api.com" }, // Required - non-Effect property
3235
+ * getUser: (id: string) => Effect.succeed({ id, name: "Test User" }) // Mock implementation
3236
+ * // deleteUser and updateUser are omitted - will throw UnimplementedError if called
3237
+ * })
3238
+ *
3239
+ * // Use in tests
3240
+ * const testProgram = Effect.gen(function*() {
3241
+ * const userService = yield* UserService
3242
+ *
3243
+ * // This works - we provided an implementation
3244
+ * const user = yield* userService.getUser("123")
3245
+ * console.log(user.name) // "Test User"
3246
+ *
3247
+ * // This would throw - we didn't implement deleteUser
3248
+ * // yield* userService.deleteUser("123") // UnimplementedError
3249
+ * }).pipe(
3250
+ * Effect.provide(testUserLayer)
3251
+ * )
3252
+ * ```
3253
+ *
3254
+ * @since 4.0.0
3255
+ * @category Testing
3256
+ */
3257
+ <I, S extends object>(service: ServiceMap.Key<I, S>): (implementation: PartialEffectful<S>) => Layer<I>
3258
+ /**
3259
+ * Creates a mock layer for testing purposes. You can provide a partial
3260
+ * implementation of the service, and any methods not provided will
3261
+ * throw an unimplemented defect when called.
3262
+ *
3263
+ * @example
3264
+ * ```ts
3265
+ * import { Effect, Layer, ServiceMap } from "effect"
3266
+ *
3267
+ * class UserService extends ServiceMap.Service<UserService, {
3268
+ * readonly config: { apiUrl: string }
3269
+ * readonly getUser: (
3270
+ * id: string
3271
+ * ) => Effect.Effect<{ id: string; name: string }, Error>
3272
+ * readonly deleteUser: (id: string) => Effect.Effect<void, Error>
3273
+ * readonly updateUser: (
3274
+ * id: string,
3275
+ * data: object
3276
+ * ) => Effect.Effect<{ id: string; name: string }, Error>
3277
+ * }>()("UserService") {}
3278
+ *
3279
+ * // Create a partial mock - only implement what you need for testing
3280
+ * const testUserLayer = Layer.mock(UserService, {
3281
+ * config: { apiUrl: "https://test-api.com" }, // Required - non-Effect property
3282
+ * getUser: (id: string) => Effect.succeed({ id, name: "Test User" }) // Mock implementation
3283
+ * // deleteUser and updateUser are omitted - will throw UnimplementedError if called
3284
+ * })
3285
+ *
3286
+ * // Use in tests
3287
+ * const testProgram = Effect.gen(function*() {
3288
+ * const userService = yield* UserService
3289
+ *
3290
+ * // This works - we provided an implementation
3291
+ * const user = yield* userService.getUser("123")
3292
+ * console.log(user.name) // "Test User"
3293
+ *
3294
+ * // This would throw - we didn't implement deleteUser
3295
+ * // yield* userService.deleteUser("123") // UnimplementedError
3296
+ * }).pipe(
3297
+ * Effect.provide(testUserLayer)
3298
+ * )
3299
+ * ```
3300
+ *
3301
+ * @since 4.0.0
3302
+ * @category Testing
3303
+ */
3304
+ <I, S extends object>(
3305
+ service: ServiceMap.Key<I, S>,
3306
+ implementation: Types.NoInfer<PartialEffectful<S>>
3307
+ ): Layer<I>
3308
+ } = function() {
3309
+ if (arguments.length === 1) {
3310
+ return (implementation: any) => mockImpl(arguments[0], implementation)
3311
+ }
3312
+ return mockImpl(arguments[0], arguments[1])
3313
+ } as any
3314
+
3315
+ const mockImpl = <I, S extends object>(service: ServiceMap.Key<I, S>, implementation: PartialEffectful<S>): Layer<I> =>
3316
+ succeed(service)(
3317
+ new Proxy({ ...implementation as object } as S, {
3318
+ get(target, prop, _receiver) {
3319
+ if (prop in target) {
3320
+ return target[prop as keyof S]
3321
+ }
3322
+ const prevLimit = (Error as ErrorWithStackTraceLimit).stackTraceLimit
3323
+ ;(Error as ErrorWithStackTraceLimit).stackTraceLimit = 2
3324
+ const error = new Error(`${service.key}: Unimplemented method "${prop.toString()}"`)
3325
+ ;(Error as ErrorWithStackTraceLimit).stackTraceLimit = prevLimit
3326
+ error.name = "UnimplementedError"
3327
+ return makeUnimplemented(error)
3328
+ },
3329
+ has: constTrue
3330
+ })
3331
+ )
3107
3332
 
3108
3333
  const makeUnimplemented = (error: globalThis.Error) => {
3109
3334
  const dead = internalEffect.die(error)
package/src/Number.ts CHANGED
@@ -6,6 +6,7 @@
6
6
  */
7
7
  import * as Equ from "./Equivalence.ts"
8
8
  import { dual } from "./Function.ts"
9
+ import * as Option from "./Option.ts"
9
10
  import * as order from "./Order.ts"
10
11
  import type { Ordering } from "./Ordering.ts"
11
12
  import * as predicate from "./Predicate.ts"
@@ -191,15 +192,15 @@ export const subtract: {
191
192
  /**
192
193
  * Provides a division operation on `number`s.
193
194
  *
194
- * Returns `undefined` if the divisor is `0`.
195
+ * Returns `Option.none()` if the divisor is `0`.
195
196
  *
196
197
  * **Example**
197
198
  *
198
199
  * ```ts
199
200
  * import { Number } from "effect"
200
201
  *
201
- * Number.divide(6, 3) // 2
202
- * Number.divide(6, 0) // undefined
202
+ * Number.divide(6, 3) // Option.some(2)
203
+ * Number.divide(6, 0) // Option.none()
203
204
  * ```
204
205
  *
205
206
  * @category math
@@ -209,42 +210,102 @@ export const divide: {
209
210
  /**
210
211
  * Provides a division operation on `number`s.
211
212
  *
212
- * Returns `undefined` if the divisor is `0`.
213
+ * Returns `Option.none()` if the divisor is `0`.
213
214
  *
214
215
  * **Example**
215
216
  *
216
217
  * ```ts
217
218
  * import { Number } from "effect"
218
219
  *
219
- * Number.divide(6, 3) // 2
220
- * Number.divide(6, 0) // undefined
220
+ * Number.divide(6, 3) // Option.some(2)
221
+ * Number.divide(6, 0) // Option.none()
221
222
  * ```
222
223
  *
223
224
  * @category math
224
225
  * @since 2.0.0
225
226
  */
226
- (that: number): (self: number) => number | undefined
227
+ (that: number): (self: number) => Option.Option<number>
227
228
  /**
228
229
  * Provides a division operation on `number`s.
229
230
  *
230
- * Returns `undefined` if the divisor is `0`.
231
+ * Returns `Option.none()` if the divisor is `0`.
231
232
  *
232
233
  * **Example**
233
234
  *
234
235
  * ```ts
235
236
  * import { Number } from "effect"
236
237
  *
237
- * Number.divide(6, 3) // 2
238
- * Number.divide(6, 0) // undefined
238
+ * Number.divide(6, 3) // Option.some(2)
239
+ * Number.divide(6, 0) // Option.none()
239
240
  * ```
240
241
  *
241
242
  * @category math
242
243
  * @since 2.0.0
243
244
  */
244
- (self: number, that: number): number | undefined
245
+ (self: number, that: number): Option.Option<number>
245
246
  } = dual(
246
247
  2,
247
- (self: number, that: number): number | undefined => that === 0 ? undefined : self / that
248
+ (self: number, that: number): Option.Option<number> => that === 0 ? Option.none() : Option.some(self / that)
249
+ )
250
+
251
+ /**
252
+ * Provides an unsafe division operation on `number`s.
253
+ *
254
+ * Throws a `RangeError` if the divisor is `0`.
255
+ *
256
+ * **Example**
257
+ *
258
+ * ```ts
259
+ * import { Number } from "effect"
260
+ *
261
+ * Number.divideUnsafe(6, 3) // 2
262
+ * Number.divideUnsafe(6, 0) // throws RangeError("Division by zero")
263
+ * ```
264
+ *
265
+ * @category math
266
+ * @since 2.0.0
267
+ */
268
+ export const divideUnsafe: {
269
+ /**
270
+ * Provides an unsafe division operation on `number`s.
271
+ *
272
+ * Throws a `RangeError` if the divisor is `0`.
273
+ *
274
+ * **Example**
275
+ *
276
+ * ```ts
277
+ * import { Number } from "effect"
278
+ *
279
+ * Number.divideUnsafe(6, 3) // 2
280
+ * Number.divideUnsafe(6, 0) // throws RangeError("Division by zero")
281
+ * ```
282
+ *
283
+ * @category math
284
+ * @since 2.0.0
285
+ */
286
+ (that: number): (self: number) => number
287
+ /**
288
+ * Provides an unsafe division operation on `number`s.
289
+ *
290
+ * Throws a `RangeError` if the divisor is `0`.
291
+ *
292
+ * **Example**
293
+ *
294
+ * ```ts
295
+ * import { Number } from "effect"
296
+ *
297
+ * Number.divideUnsafe(6, 3) // 2
298
+ * Number.divideUnsafe(6, 0) // throws RangeError("Division by zero")
299
+ * ```
300
+ *
301
+ * @category math
302
+ * @since 2.0.0
303
+ */
304
+ (self: number, that: number): number
305
+ } = dual(
306
+ 2,
307
+ (self: number, that: number): number =>
308
+ Option.getOrThrowWith(divide(self, that), () => new RangeError("Division by zero"))
248
309
  )
249
310
 
250
311
  /**
@@ -934,34 +995,32 @@ export const nextPow2 = (n: number): number => {
934
995
  * ```ts
935
996
  * import { Number } from "effect"
936
997
  *
937
- * Number.parse("42") // 42
938
- * Number.parse("3.14") // 3.14
939
- * Number.parse("NaN") // NaN
940
- * Number.parse("Infinity") // Infinity
941
- * Number.parse("-Infinity") // -Infinity
942
- * Number.parse("not a number") // undefined
998
+ * Number.parse("42") // Option.some(42)
999
+ * Number.parse("3.14") // Option.some(3.14)
1000
+ * Number.parse("NaN") // Option.some(NaN)
1001
+ * Number.parse("Infinity") // Option.some(Infinity)
1002
+ * Number.parse("-Infinity") // Option.some(-Infinity)
1003
+ * Number.parse("not a number") // Option.none()
943
1004
  * ```
944
1005
  *
945
1006
  * @category constructors
946
1007
  * @since 2.0.0
947
1008
  */
948
- export const parse = (s: string): number | undefined => {
1009
+ export const parse = (s: string): Option.Option<number> => {
949
1010
  if (s === "NaN") {
950
- return NaN
1011
+ return Option.some(NaN)
951
1012
  }
952
1013
  if (s === "Infinity") {
953
- return Infinity
1014
+ return Option.some(Infinity)
954
1015
  }
955
1016
  if (s === "-Infinity") {
956
- return -Infinity
1017
+ return Option.some(-Infinity)
957
1018
  }
958
1019
  if (s.trim() === "") {
959
- return undefined
1020
+ return Option.none()
960
1021
  }
961
1022
  const n = Number(s)
962
- return Number.isNaN(n) ?
963
- undefined
964
- : n
1023
+ return Number.isNaN(n) ? Option.none() : Option.some(n)
965
1024
  }
966
1025
 
967
1026
  /**
package/src/Option.ts CHANGED
@@ -156,6 +156,7 @@ export type Option<A> = None<A> | Some<A>
156
156
  export interface None<out A> extends Pipeable, Inspectable, Yieldable<Option<A>, A, NoSuchElementError> {
157
157
  readonly _tag: "None"
158
158
  readonly _op: "None"
159
+ readonly valueOrUndefined: undefined
159
160
  readonly [TypeId]: {
160
161
  readonly _A: Covariant<A>
161
162
  }
@@ -189,6 +190,7 @@ export interface Some<out A> extends Pipeable, Inspectable, Yieldable<Option<A>,
189
190
  readonly _tag: "Some"
190
191
  readonly _op: "Some"
191
192
  readonly value: A
193
+ readonly valueOrUndefined: A
192
194
  readonly [TypeId]: {
193
195
  readonly _A: Covariant<A>
194
196
  }