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
@@ -710,7 +710,7 @@ export const date = (options: DateOptions): Prompt<Date> => {
710
710
  typed: "",
711
711
  cursor: initialCursorPosition,
712
712
  value: opts.initial,
713
- error: undefined
713
+ error: Option.none()
714
714
  }
715
715
  return custom(initialState, {
716
716
  render: handleDateRender(opts),
@@ -727,7 +727,7 @@ export const file = (options: FileOptions = {}): Prompt<string> => {
727
727
  const opts: FileOptionsReq = {
728
728
  type: options.type ?? "file",
729
729
  message: options.message ?? `Choose a file`,
730
- startingPath: options.startingPath,
730
+ startingPath: Option.fromUndefinedOr(options.startingPath),
731
731
  maxPerPage: options.maxPerPage ?? 10,
732
732
  filter: options.filter ?? (() => Effect.succeed(true))
733
733
  }
@@ -736,10 +736,10 @@ export const file = (options: FileOptions = {}): Prompt<string> => {
736
736
  never,
737
737
  Environment
738
738
  > = Effect.gen(function*() {
739
- const currentPath = yield* resolveCurrentPath(undefined, opts)
739
+ const currentPath = yield* resolveCurrentPath(Option.none(), opts)
740
740
  const files = yield* getFileList(currentPath, opts)
741
741
  const confirm = Confirm.Hide()
742
- return { cursor: 0, files, path: undefined, confirm }
742
+ return { cursor: 0, files, path: Option.none(), confirm }
743
743
  })
744
744
  return custom(initialState, {
745
745
  render: handleFileRender(opts),
@@ -799,7 +799,7 @@ export const float = (options: FloatOptions): Prompt<number> => {
799
799
  const initialState: NumberState = {
800
800
  cursor: 0,
801
801
  value: "",
802
- error: undefined
802
+ error: Option.none()
803
803
  }
804
804
  return custom(initialState, {
805
805
  render: handleRenderFloat(opts),
@@ -839,7 +839,7 @@ export const integer = (options: IntegerOptions): Prompt<number> => {
839
839
  const initialState: NumberState = {
840
840
  cursor: 0,
841
841
  value: "",
842
- error: undefined
842
+ error: Option.none()
843
843
  }
844
844
  return custom(initialState, {
845
845
  render: handleRenderInteger(opts),
@@ -1009,7 +1009,7 @@ export const multiSelect = <const A>(
1009
1009
  initialSelected.add(i)
1010
1010
  }
1011
1011
  }
1012
- const initialState: MultiSelectState = { index: 0, selectedIndices: initialSelected, error: undefined }
1012
+ const initialState: MultiSelectState = { index: 0, selectedIndices: initialSelected, error: Option.none() }
1013
1013
  return custom(initialState, {
1014
1014
  render: handleMultiSelectRender(opts),
1015
1015
  process: handleMultiSelectProcess(opts),
@@ -1289,7 +1289,7 @@ const TRUE_VALUE_REGEXP = /^y|t$/
1289
1289
  const FALSE_VALUE_REGEXP = /^n|f$/
1290
1290
 
1291
1291
  const handleConfirmProcess = (input: Terminal.UserInput, defaultValue: boolean) => {
1292
- const value = input.input ?? ""
1292
+ const value = Option.getOrElse(input.input, () => "")
1293
1293
  if (input.key.name === "enter" || input.key.name === "return") {
1294
1294
  return Effect.succeed(Action.Submit({ value: defaultValue }))
1295
1295
  }
@@ -1309,7 +1309,7 @@ interface DateState {
1309
1309
  readonly cursor: number
1310
1310
  readonly value: globalThis.Date
1311
1311
  readonly dateParts: ReadonlyArray<DatePart>
1312
- readonly error: string | undefined
1312
+ readonly error: Option.Option<string>
1313
1313
  }
1314
1314
 
1315
1315
  const handleDateClear = (options: DateOptionsReq) => {
@@ -1320,8 +1320,8 @@ const handleDateClear = (options: DateOptionsReq) => {
1320
1320
  const resetCurrentLine = Ansi.eraseLine + Ansi.cursorLeft
1321
1321
  const parts = Arr.reduce(state.dateParts, "", (doc, part) => doc + part.toString())
1322
1322
  const promptText = renderDateOutput("?", figures.pointerSmall, parts, options, { plain: true })
1323
- const errorText = state.error !== undefined
1324
- ? Arr.match(state.error.split(NEWLINE_REGEXP), {
1323
+ const errorText = Option.isSome(state.error)
1324
+ ? Arr.match(state.error.value.split(NEWLINE_REGEXP), {
1325
1325
  onEmpty: () => "",
1326
1326
  onNonEmpty: (errorLines) => `${figures.pointerSmall} ${errorLines.join("\n")}`
1327
1327
  })
@@ -1332,8 +1332,8 @@ const handleDateClear = (options: DateOptionsReq) => {
1332
1332
  }
1333
1333
 
1334
1334
  const renderDateError = (state: DateState, pointer: string): string => {
1335
- if (state.error !== undefined) {
1336
- const errorLines = state.error.split(NEWLINE_REGEXP)
1335
+ if (Option.isSome(state.error)) {
1336
+ const errorLines = state.error.value.split(NEWLINE_REGEXP)
1337
1337
  if (Arr.isReadonlyArrayNonEmpty(errorLines)) {
1338
1338
  const prefix = Ansi.annotate(pointer, Ansi.red) + " "
1339
1339
  const lines = Arr.map(errorLines, (str) => annotateErrorLine(str))
@@ -1401,12 +1401,12 @@ const processDown = (state: DateState) => {
1401
1401
 
1402
1402
  const processDateCursorLeft = (state: DateState) => {
1403
1403
  const previous = state.dateParts[state.cursor].previousPart()
1404
- if (previous !== undefined) {
1404
+ if (Option.isSome(previous)) {
1405
1405
  return Action.NextFrame({
1406
1406
  state: {
1407
1407
  ...state,
1408
1408
  typed: "",
1409
- cursor: state.dateParts.indexOf(previous)
1409
+ cursor: state.dateParts.indexOf(previous.value)
1410
1410
  }
1411
1411
  })
1412
1412
  }
@@ -1415,12 +1415,12 @@ const processDateCursorLeft = (state: DateState) => {
1415
1415
 
1416
1416
  const processDateCursorRight = (state: DateState) => {
1417
1417
  const next = state.dateParts[state.cursor].nextPart()
1418
- if (next !== undefined) {
1418
+ if (Option.isSome(next)) {
1419
1419
  return Action.NextFrame({
1420
1420
  state: {
1421
1421
  ...state,
1422
1422
  typed: "",
1423
- cursor: state.dateParts.indexOf(next)
1423
+ cursor: state.dateParts.indexOf(next.value)
1424
1424
  }
1425
1425
  })
1426
1426
  }
@@ -1429,9 +1429,10 @@ const processDateCursorRight = (state: DateState) => {
1429
1429
 
1430
1430
  const processDateNext = (state: DateState) => {
1431
1431
  const next = state.dateParts[state.cursor].nextPart()
1432
- const cursor = next !== undefined
1433
- ? state.dateParts.indexOf(next)
1434
- : state.dateParts.findIndex((part) => !part.isToken())
1432
+ const cursor = Option.match(next, {
1433
+ onNone: () => state.dateParts.findIndex((part) => !part.isToken()),
1434
+ onSome: (next) => state.dateParts.indexOf(next)
1435
+ })
1435
1436
  return Action.NextFrame({
1436
1437
  state: { ...state, cursor }
1437
1438
  })
@@ -1505,14 +1506,14 @@ const handleDateProcess = (options: DateOptionsReq) => {
1505
1506
  Action.NextFrame({
1506
1507
  state: {
1507
1508
  ...state,
1508
- error
1509
+ error: Option.some(error)
1509
1510
  }
1510
1511
  }),
1511
1512
  onSuccess: (value) => Action.Submit({ value })
1512
1513
  })
1513
1514
  }
1514
1515
  default: {
1515
- return Effect.succeed(defaultDateProcessor(input.input ?? "", state))
1516
+ return Effect.succeed(defaultDateProcessor(Option.getOrElse(input.input, () => ""), state))
1516
1517
  }
1517
1518
  }
1518
1519
  }
@@ -1609,23 +1610,20 @@ abstract class DatePart {
1609
1610
  /**
1610
1611
  * Retrieves the next date part in the list of parts.
1611
1612
  */
1612
- nextPart(): DatePart | undefined {
1613
- const currentPartIndex = Arr.findFirstIndex(this.parts, (part) => part === this) ?? 0
1614
- return Option.getOrUndefined(
1615
- Arr.findFirst(this.parts.slice(currentPartIndex + 1), (part) => !part.isToken())
1616
- )
1613
+ nextPart(): Option.Option<DatePart> {
1614
+ const currentPartIndex = Option.getOrElse(Arr.findFirstIndex(this.parts, (part) => part === this), () => 0)
1615
+ return Arr.findFirst(this.parts.slice(currentPartIndex + 1), (part) => !part.isToken())
1617
1616
  }
1618
1617
 
1619
1618
  /**
1620
1619
  * Retrieves the previous date part in the list of parts.
1621
1620
  */
1622
- previousPart(): DatePart | undefined {
1621
+ previousPart(): Option.Option<DatePart> {
1623
1622
  const currentPartIndex = Arr.findFirstIndex(this.parts, (part) => part === this)
1624
- if (currentPartIndex !== undefined) {
1625
- return Option.getOrUndefined(
1626
- Arr.findLast(this.parts.slice(0, currentPartIndex), (part) => !part.isToken())
1627
- )
1623
+ if (Option.isSome(currentPartIndex)) {
1624
+ return Arr.findLast(this.parts.slice(0, currentPartIndex.value), (part) => !part.isToken())
1628
1625
  }
1626
+ return Option.none()
1629
1627
  }
1630
1628
 
1631
1629
  toString() {
@@ -1851,13 +1849,13 @@ class Meridiem extends DatePart {
1851
1849
  }
1852
1850
 
1853
1851
  interface FileOptionsReq extends Required<Omit<FileOptions, "startingPath">> {
1854
- readonly startingPath: string | undefined
1852
+ readonly startingPath: Option.Option<string>
1855
1853
  }
1856
1854
 
1857
1855
  interface FileState {
1858
1856
  readonly cursor: number
1859
1857
  readonly files: ReadonlyArray<string>
1860
- readonly path: string | undefined
1858
+ readonly path: Option.Option<string>
1861
1859
  readonly confirm: Confirm
1862
1860
  }
1863
1861
 
@@ -1871,14 +1869,14 @@ const Confirm = Data.taggedEnum<Confirm>()
1871
1869
  const showConfirmation = Confirm.$is("Show")
1872
1870
 
1873
1871
  const resolveCurrentPath = (
1874
- path: string | undefined,
1872
+ path: Option.Option<string>,
1875
1873
  options: FileOptionsReq
1876
1874
  ): Effect.Effect<string, never, FileSystem.FileSystem> => {
1877
- if (path !== undefined) {
1878
- return Effect.succeed(path)
1875
+ if (Option.isSome(path)) {
1876
+ return Effect.succeed(path.value)
1879
1877
  }
1880
- const startingPath = options.startingPath
1881
- if (startingPath !== undefined) {
1878
+ if (Option.isSome(options.startingPath)) {
1879
+ const startingPath = options.startingPath.value
1882
1880
  return Effect.flatMap(FileSystem.FileSystem.asEffect(), (fs) =>
1883
1881
  // Ensure the user provided starting path exists
1884
1882
  Effect.orDie(fs.exists(startingPath)).pipe(
@@ -2099,7 +2097,7 @@ const processSelection = Effect.fnUntraced(function*(state: FileState, options:
2099
2097
  state: {
2100
2098
  cursor: 0,
2101
2099
  files,
2102
- path: resolvedPath,
2100
+ path: Option.some(resolvedPath),
2103
2101
  confirm: Confirm.Hide()
2104
2102
  }
2105
2103
  })
@@ -2135,7 +2133,7 @@ const handleFileProcess = (options: FileOptionsReq) => {
2135
2133
  state: {
2136
2134
  cursor: 0,
2137
2135
  files,
2138
- path: resolvedPath,
2136
+ path: Option.some(resolvedPath),
2139
2137
  confirm: Confirm.Hide()
2140
2138
  }
2141
2139
  })
@@ -2166,7 +2164,7 @@ interface MultiSelectOptionsReq extends MultiSelectOptions {}
2166
2164
  type MultiSelectState = {
2167
2165
  index: number
2168
2166
  selectedIndices: Set<number>
2169
- error: string | undefined
2167
+ error: Option.Option<string>
2170
2168
  }
2171
2169
 
2172
2170
  const renderMultiSelectError = (
@@ -2174,8 +2172,8 @@ const renderMultiSelectError = (
2174
2172
  pointer: string,
2175
2173
  renderOptions?: RenderOptions | undefined
2176
2174
  ): string => {
2177
- if (state.error !== undefined) {
2178
- return Arr.match(state.error.split(NEWLINE_REGEXP), {
2175
+ if (Option.isSome(state.error)) {
2176
+ return Arr.match(state.error.value.split(NEWLINE_REGEXP), {
2179
2177
  onEmpty: () => "",
2180
2178
  onNonEmpty: (errorLines) => {
2181
2179
  if (renderOptions?.plain === true) {
@@ -2347,12 +2345,12 @@ const handleMultiSelectProcess = <A>(options: SelectOptionsReq<A> & MultiSelectO
2347
2345
  switch (input.key.name) {
2348
2346
  case "k":
2349
2347
  case "up": {
2350
- return processMultiSelectCursorUp({ ...state, error: undefined }, totalChoices)
2348
+ return processMultiSelectCursorUp({ ...state, error: Option.none() }, totalChoices)
2351
2349
  }
2352
2350
  case "j":
2353
2351
  case "down":
2354
2352
  case "tab": {
2355
- return processMultiSelectCursorDown({ ...state, error: undefined }, totalChoices)
2353
+ return processMultiSelectCursorDown({ ...state, error: Option.none() }, totalChoices)
2356
2354
  }
2357
2355
  case "space": {
2358
2356
  return processSpace(state, options)
@@ -2362,12 +2360,12 @@ const handleMultiSelectProcess = <A>(options: SelectOptionsReq<A> & MultiSelectO
2362
2360
  const selectedCount = state.selectedIndices.size
2363
2361
  if (options.min !== undefined && selectedCount < options.min) {
2364
2362
  return Effect.succeed(
2365
- Action.NextFrame({ state: { ...state, error: `At least ${options.min} are required` } })
2363
+ Action.NextFrame({ state: { ...state, error: Option.some(`At least ${options.min} are required`) } })
2366
2364
  )
2367
2365
  }
2368
2366
  if (options.max !== undefined && selectedCount > options.max) {
2369
2367
  return Effect.succeed(
2370
- Action.NextFrame({ state: { ...state, error: `At most ${options.max} choices are allowed` } })
2368
+ Action.NextFrame({ state: { ...state, error: Option.some(`At most ${options.max} choices are allowed`) } })
2371
2369
  )
2372
2370
  }
2373
2371
  const selectedValues = Array.from(state.selectedIndices).sort(EffectNumber.Order).map((index) =>
@@ -2398,7 +2396,7 @@ interface FloatOptionsReq extends Required<FloatOptions> {}
2398
2396
  interface NumberState {
2399
2397
  readonly cursor: number
2400
2398
  readonly value: string
2401
- readonly error: string | undefined
2399
+ readonly error: Option.Option<string>
2402
2400
  }
2403
2401
 
2404
2402
  const handleNumberClear = (options: IntegerOptionsReq) => {
@@ -2423,7 +2421,7 @@ const renderNumberInput = (
2423
2421
  if (submitted || renderOptions?.plain === true) {
2424
2422
  return value
2425
2423
  }
2426
- const annotation = state.error !== undefined ?
2424
+ const annotation = Option.isSome(state.error) ?
2427
2425
  Ansi.red :
2428
2426
  Ansi.combine(Ansi.underlined, Ansi.cyanBright)
2429
2427
  return Ansi.annotate(value, annotation)
@@ -2434,8 +2432,8 @@ const renderNumberError = (
2434
2432
  pointer: string,
2435
2433
  renderOptions?: RenderOptions | undefined
2436
2434
  ) => {
2437
- if (state.error !== undefined) {
2438
- return Arr.match(state.error.split(NEWLINE_REGEXP), {
2435
+ if (Option.isSome(state.error)) {
2436
+ return Arr.match(state.error.value.split(NEWLINE_REGEXP), {
2439
2437
  onEmpty: () => "",
2440
2438
  onNonEmpty: (errorLines) => {
2441
2439
  if (renderOptions?.plain === true) {
@@ -2485,19 +2483,19 @@ const processNumberBackspace = (state: NumberState) => {
2485
2483
  }
2486
2484
  const value = state.value.slice(0, state.value.length - 1)
2487
2485
  return Effect.succeed(Action.NextFrame({
2488
- state: { ...state, value, error: undefined }
2486
+ state: { ...state, value, error: Option.none() }
2489
2487
  }))
2490
2488
  }
2491
2489
 
2492
2490
  const processNumberClear = (state: NumberState) =>
2493
2491
  Effect.succeed(Action.NextFrame({
2494
- state: { ...state, cursor: 0, value: "", error: undefined }
2492
+ state: { ...state, cursor: 0, value: "", error: Option.none() }
2495
2493
  }))
2496
2494
 
2497
2495
  const defaultIntProcessor = (input: string, state: NumberState) => {
2498
2496
  if (state.value.length === 0 && input === "-") {
2499
2497
  return Effect.succeed(Action.NextFrame({
2500
- state: { ...state, value: "-", error: undefined }
2498
+ state: { ...state, value: "-", error: Option.none() }
2501
2499
  }))
2502
2500
  }
2503
2501
 
@@ -2506,7 +2504,7 @@ const defaultIntProcessor = (input: string, state: NumberState) => {
2506
2504
  return Effect.succeed(Action.Beep())
2507
2505
  } else {
2508
2506
  return Effect.succeed(Action.NextFrame({
2509
- state: { ...state, value: `${parsed}`, error: undefined }
2507
+ state: { ...state, value: `${parsed}`, error: Option.none() }
2510
2508
  }))
2511
2509
  }
2512
2510
  }
@@ -2517,7 +2515,7 @@ const defaultFloatProcessor = (input: string, state: NumberState) => {
2517
2515
  }
2518
2516
  if (state.value.length === 0 && input === "-") {
2519
2517
  return Effect.succeed(Action.NextFrame({
2520
- state: { ...state, value: "-", error: undefined }
2518
+ state: { ...state, value: "-", error: Option.none() }
2521
2519
  }))
2522
2520
  }
2523
2521
 
@@ -2529,7 +2527,7 @@ const defaultFloatProcessor = (input: string, state: NumberState) => {
2529
2527
  state: {
2530
2528
  ...state,
2531
2529
  value: input === "." ? `${parsed}.` : `${parsed}`,
2532
- error: undefined
2530
+ error: Option.none()
2533
2531
  }
2534
2532
  }))
2535
2533
  }
@@ -2562,7 +2560,7 @@ const handleProcessInteger = (options: IntegerOptionsReq) => {
2562
2560
  value: state.value === "" || state.value === "-"
2563
2561
  ? `${options.incrementBy}`
2564
2562
  : `${Number.parseInt(state.value) + options.incrementBy}`,
2565
- error: undefined
2563
+ error: Option.none()
2566
2564
  }
2567
2565
  }))
2568
2566
  }
@@ -2574,7 +2572,7 @@ const handleProcessInteger = (options: IntegerOptionsReq) => {
2574
2572
  value: state.value === "" || state.value === "-"
2575
2573
  ? `-${options.decrementBy}`
2576
2574
  : `${Number.parseInt(state.value) - options.decrementBy}`,
2577
- error: undefined
2575
+ error: Option.none()
2578
2576
  }
2579
2577
  }))
2580
2578
  }
@@ -2585,7 +2583,7 @@ const handleProcessInteger = (options: IntegerOptionsReq) => {
2585
2583
  return Effect.succeed(Action.NextFrame({
2586
2584
  state: {
2587
2585
  ...state,
2588
- error: "Must provide an integer value"
2586
+ error: Option.some("Must provide an integer value")
2589
2587
  }
2590
2588
  }))
2591
2589
  } else {
@@ -2594,7 +2592,7 @@ const handleProcessInteger = (options: IntegerOptionsReq) => {
2594
2592
  Action.NextFrame({
2595
2593
  state: {
2596
2594
  ...state,
2597
- error
2595
+ error: Option.some(error)
2598
2596
  }
2599
2597
  }),
2600
2598
  onSuccess: (value) => Action.Submit({ value })
@@ -2602,7 +2600,7 @@ const handleProcessInteger = (options: IntegerOptionsReq) => {
2602
2600
  }
2603
2601
  }
2604
2602
  default: {
2605
- return defaultIntProcessor(input.input ?? "", state)
2603
+ return defaultIntProcessor(Option.getOrElse(input.input, () => ""), state)
2606
2604
  }
2607
2605
  }
2608
2606
  }
@@ -2635,7 +2633,7 @@ const handleProcessFloat = (options: FloatOptionsReq) => {
2635
2633
  value: state.value === "" || state.value === "-"
2636
2634
  ? `${options.incrementBy}`
2637
2635
  : `${Number.parseFloat(state.value) + options.incrementBy}`,
2638
- error: undefined
2636
+ error: Option.none()
2639
2637
  }
2640
2638
  }))
2641
2639
  }
@@ -2647,7 +2645,7 @@ const handleProcessFloat = (options: FloatOptionsReq) => {
2647
2645
  value: state.value === "" || state.value === "-"
2648
2646
  ? `-${options.decrementBy}`
2649
2647
  : `${Number.parseFloat(state.value) - options.decrementBy}`,
2650
- error: undefined
2648
+ error: Option.none()
2651
2649
  }
2652
2650
  }))
2653
2651
  }
@@ -2658,7 +2656,7 @@ const handleProcessFloat = (options: FloatOptionsReq) => {
2658
2656
  return Effect.succeed(Action.NextFrame({
2659
2657
  state: {
2660
2658
  ...state,
2661
- error: "Must provide a floating point value"
2659
+ error: Option.some("Must provide a floating point value")
2662
2660
  }
2663
2661
  }))
2664
2662
  } else {
@@ -2670,7 +2668,7 @@ const handleProcessFloat = (options: FloatOptionsReq) => {
2670
2668
  Action.NextFrame({
2671
2669
  state: {
2672
2670
  ...state,
2673
- error
2671
+ error: Option.some(error)
2674
2672
  }
2675
2673
  }),
2676
2674
  onSuccess: (value) => Action.Submit({ value })
@@ -2679,7 +2677,7 @@ const handleProcessFloat = (options: FloatOptionsReq) => {
2679
2677
  }
2680
2678
  }
2681
2679
  default: {
2682
- return defaultFloatProcessor(input.input ?? "", state)
2680
+ return defaultFloatProcessor(Option.getOrElse(input.input, () => ""), state)
2683
2681
  }
2684
2682
  }
2685
2683
  }
@@ -2723,7 +2721,7 @@ const updateAutoCompleteState = <A>(
2723
2721
  }
2724
2722
 
2725
2723
  const autoCompleteCursor = (state: AutoCompleteState) =>
2726
- Arr.findFirstIndex(state.filtered, (index) => index === state.index) ?? 0
2724
+ Option.getOrElse(Arr.findFirstIndex(state.filtered, (index) => index === state.index), () => 0)
2727
2725
 
2728
2726
  const renderSelectOutput = <A>(
2729
2727
  leadingSymbol: string,
@@ -3089,7 +3087,7 @@ const handleAutoCompleteProcess = <A>(options: AutoCompleteOptionsReq<A>) => {
3089
3087
  return Effect.succeed(Action.Submit({ value: selected.value }))
3090
3088
  }
3091
3089
  default: {
3092
- return processAutoCompleteInput(input.input ?? "", state, options)
3090
+ return processAutoCompleteInput(Option.getOrElse(input.input, () => ""), state, options)
3093
3091
  }
3094
3092
  }
3095
3093
  }
@@ -3105,7 +3103,7 @@ interface TextOptionsReq extends Required<TextOptions> {
3105
3103
  interface TextState {
3106
3104
  readonly cursor: number
3107
3105
  readonly value: string
3108
- readonly error: string | undefined
3106
+ readonly error: Option.Option<string>
3109
3107
  }
3110
3108
 
3111
3109
  const renderClearScreen = Effect.fnUntraced(function*(state: TextState, options: TextOptionsReq) {
@@ -3143,7 +3141,7 @@ const renderTextInput = (
3143
3141
  }
3144
3142
  }
3145
3143
 
3146
- const annotation = nextState.error !== undefined ?
3144
+ const annotation = Option.isSome(nextState.error) ?
3147
3145
  Ansi.red
3148
3146
  : submitted ?
3149
3147
  Ansi.white
@@ -3169,8 +3167,8 @@ const renderTextError = (
3169
3167
  pointer: string,
3170
3168
  renderOptions?: RenderOptions | undefined
3171
3169
  ): string => {
3172
- if (nextState.error !== undefined) {
3173
- return Arr.match(nextState.error.split(NEWLINE_REGEXP), {
3170
+ if (Option.isSome(nextState.error)) {
3171
+ return Arr.match(nextState.error.value.split(NEWLINE_REGEXP), {
3174
3172
  onEmpty: () => "",
3175
3173
  onNonEmpty: (errorLines) => {
3176
3174
  if (renderOptions?.plain === true) {
@@ -3225,7 +3223,7 @@ const processTextBackspace = (state: TextState) => {
3225
3223
  const value = `${beforeCursor}${afterCursor}`
3226
3224
  return Effect.succeed(
3227
3225
  Action.NextFrame({
3228
- state: { ...state, cursor, value, error: undefined }
3226
+ state: { ...state, cursor, value, error: Option.none() }
3229
3227
  })
3230
3228
  )
3231
3229
  }
@@ -3233,7 +3231,7 @@ const processTextBackspace = (state: TextState) => {
3233
3231
  const processTextClear = (state: TextState) =>
3234
3232
  Effect.succeed(
3235
3233
  Action.NextFrame({
3236
- state: { ...state, cursor: 0, value: "", error: undefined }
3234
+ state: { ...state, cursor: 0, value: "", error: Option.none() }
3237
3235
  })
3238
3236
  )
3239
3237
 
@@ -3244,7 +3242,7 @@ const processTextCursorLeft = (state: TextState) => {
3244
3242
  const cursor = state.cursor - 1
3245
3243
  return Effect.succeed(
3246
3244
  Action.NextFrame({
3247
- state: { ...state, cursor, error: undefined }
3245
+ state: { ...state, cursor, error: Option.none() }
3248
3246
  })
3249
3247
  )
3250
3248
  }
@@ -3256,7 +3254,7 @@ const processTextCursorRight = (state: TextState) => {
3256
3254
  const cursor = Math.min(state.cursor + 1, state.value.length)
3257
3255
  return Effect.succeed(
3258
3256
  Action.NextFrame({
3259
- state: { ...state, cursor, error: undefined }
3257
+ state: { ...state, cursor, error: Option.none() }
3260
3258
  })
3261
3259
  )
3262
3260
  }
@@ -3268,7 +3266,7 @@ const processTab = (state: TextState, options: TextOptionsReq) => {
3268
3266
  const value = state.value.length === 0 ? options.default : state.value
3269
3267
  return Effect.succeed(
3270
3268
  Action.NextFrame({
3271
- state: { ...state, value, cursor: value.length, error: undefined }
3269
+ state: { ...state, value, cursor: value.length, error: Option.none() }
3272
3270
  })
3273
3271
  )
3274
3272
  }
@@ -3280,7 +3278,7 @@ const defaultTextProcessor = (input: string, state: TextState) => {
3280
3278
  const cursor = state.cursor + input.length
3281
3279
  return Effect.succeed(
3282
3280
  Action.NextFrame({
3283
- state: { ...state, cursor, value, error: undefined }
3281
+ state: { ...state, cursor, value, error: Option.none() }
3284
3282
  })
3285
3283
  )
3286
3284
  }
@@ -3316,7 +3314,7 @@ const handleTextProcess = (options: TextOptionsReq) => {
3316
3314
  return Effect.match(options.validate(value), {
3317
3315
  onFailure: (error) =>
3318
3316
  Action.NextFrame({
3319
- state: { ...state, value, error }
3317
+ state: { ...state, value, error: Option.some(error) }
3320
3318
  }),
3321
3319
  onSuccess: (value) => Action.Submit({ value })
3322
3320
  })
@@ -3325,7 +3323,7 @@ const handleTextProcess = (options: TextOptionsReq) => {
3325
3323
  return processTab(state, options)
3326
3324
  }
3327
3325
  default: {
3328
- return defaultTextProcessor(input.input ?? "", state)
3326
+ return defaultTextProcessor(Option.getOrElse(input.input, () => ""), state)
3329
3327
  }
3330
3328
  }
3331
3329
  }
@@ -3351,7 +3349,7 @@ const basePrompt = (
3351
3349
  const initialState: TextState = {
3352
3350
  cursor: opts.default.length,
3353
3351
  value: opts.default,
3354
- error: undefined
3352
+ error: Option.none()
3355
3353
  }
3356
3354
  return custom(initialState, {
3357
3355
  render: handleTextRender(opts),
@@ -24,6 +24,11 @@ export * as CliOutput from "./CliOutput.ts"
24
24
  */
25
25
  export * as Command from "./Command.ts"
26
26
 
27
+ /**
28
+ * @since 4.0.0
29
+ */
30
+ export * as Completions from "./Completions.ts"
31
+
27
32
  /**
28
33
  * @since 4.0.0
29
34
  */
@@ -4,6 +4,7 @@
4
4
  *
5
5
  * @internal
6
6
  */
7
+ import * as Option from "../../../../Option.ts"
7
8
  import type { Command } from "../../Command.ts"
8
9
  import * as Param from "../../Param.ts"
9
10
  import * as Primitive from "../../Primitive.ts"
@@ -135,7 +136,7 @@ export const fromCommand = (cmd: Command.Any): CommandDescriptor => {
135
136
  flags.push({
136
137
  name: single.name,
137
138
  aliases: single.aliases,
138
- description: single.description,
139
+ description: Option.getOrUndefined(single.description),
139
140
  type: toFlagType(single as Param.Single<"flag", unknown>)
140
141
  })
141
142
  }
@@ -149,7 +150,7 @@ export const fromCommand = (cmd: Command.Any): CommandDescriptor => {
149
150
  if (single.kind !== "argument") continue
150
151
  args.push({
151
152
  name: single.name,
152
- description: single.description,
153
+ description: Option.getOrUndefined(single.description),
153
154
  required: !metadata.isOptional,
154
155
  variadic: metadata.isVariadic,
155
156
  type: toArgumentType(single as Param.Single<"argument", unknown>)
@@ -25,6 +25,7 @@
25
25
  * - Errors accumulate rather than throwing exceptions
26
26
  */
27
27
  import * as Effect from "../../../Effect.ts"
28
+ import * as Option from "../../../Option.ts"
28
29
  import * as CliError from "../CliError.ts"
29
30
  import type { Command, ParsedTokens } from "../Command.ts"
30
31
  import * as Param from "../Param.ts"
@@ -39,9 +40,10 @@ import type { LexResult, Token } from "./lexer.ts"
39
40
 
40
41
  /** @internal */
41
42
  export const getCommandPath = (parsedInput: ParsedTokens): ReadonlyArray<string> =>
42
- parsedInput.subcommand
43
- ? [parsedInput.subcommand.name, ...getCommandPath(parsedInput.subcommand.parsedInput)]
44
- : []
43
+ Option.match(parsedInput.subcommand, {
44
+ onNone: () => [],
45
+ onSome: (subcommand) => [subcommand.name, ...getCommandPath(subcommand.parsedInput)]
46
+ })
45
47
 
46
48
  /** @internal */
47
49
  export const parseArgs = (
@@ -77,6 +79,7 @@ export const parseArgs = (
77
79
  return {
78
80
  flags: result.flags,
79
81
  arguments: [...result.arguments, ...afterEndOfOptions],
82
+ subcommand: Option.none(),
80
83
  ...(result.errors.length > 0 && { errors: result.errors })
81
84
  }
82
85
  }
@@ -92,7 +95,7 @@ export const parseArgs = (
92
95
  return {
93
96
  flags: result.flags,
94
97
  arguments: afterEndOfOptions,
95
- subcommand: { name: result.sub.name, parsedInput: subParsed },
98
+ subcommand: Option.some({ name: result.sub.name, parsedInput: subParsed }),
96
99
  ...(allErrors.length > 0 && { errors: allErrors })
97
100
  }
98
101
  })