effect 4.0.5 → 4.0.7

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 (1177) hide show
  1. package/ai-docs/package.json +1 -1
  2. package/ai-docs/src/06_schedule/10_schedules.ts +5 -4
  3. package/ai-docs/tsconfig.json +3 -1
  4. package/dist/Arbitrary.d.ts +10 -2
  5. package/dist/Arbitrary.d.ts.map +1 -1
  6. package/dist/Arbitrary.js +2 -1
  7. package/dist/Arbitrary.js.map +1 -1
  8. package/dist/Array.d.ts +117 -52
  9. package/dist/Array.d.ts.map +1 -1
  10. package/dist/Array.js +41 -20
  11. package/dist/Array.js.map +1 -1
  12. package/dist/Bytes.d.ts +79 -0
  13. package/dist/Bytes.d.ts.map +1 -0
  14. package/dist/Bytes.js +109 -0
  15. package/dist/Bytes.js.map +1 -0
  16. package/dist/Channel.d.ts +181 -13
  17. package/dist/Channel.d.ts.map +1 -1
  18. package/dist/Channel.js +144 -34
  19. package/dist/Channel.js.map +1 -1
  20. package/dist/ChannelSchema.d.ts.map +1 -1
  21. package/dist/ChannelSchema.js.map +1 -1
  22. package/dist/Chunk.d.ts +39 -21
  23. package/dist/Chunk.d.ts.map +1 -1
  24. package/dist/Chunk.js +26 -17
  25. package/dist/Chunk.js.map +1 -1
  26. package/dist/Config.d.ts.map +1 -1
  27. package/dist/Config.js +8 -3
  28. package/dist/Config.js.map +1 -1
  29. package/dist/ConfigProvider.d.ts.map +1 -1
  30. package/dist/ConfigProvider.js +2 -1
  31. package/dist/ConfigProvider.js.map +1 -1
  32. package/dist/Cron.d.ts +2 -2
  33. package/dist/Cron.d.ts.map +1 -1
  34. package/dist/Cron.js +6 -3
  35. package/dist/Cron.js.map +1 -1
  36. package/dist/Data.d.ts +54 -235
  37. package/dist/Data.d.ts.map +1 -1
  38. package/dist/Data.js.map +1 -1
  39. package/dist/Duration.d.ts.map +1 -1
  40. package/dist/Duration.js +56 -16
  41. package/dist/Duration.js.map +1 -1
  42. package/dist/Effect.d.ts +488 -164
  43. package/dist/Effect.d.ts.map +1 -1
  44. package/dist/Effect.js +204 -38
  45. package/dist/Effect.js.map +1 -1
  46. package/dist/Equal.d.ts.map +1 -1
  47. package/dist/Equal.js +8 -1
  48. package/dist/Equal.js.map +1 -1
  49. package/dist/Equivalence.d.ts +2 -1
  50. package/dist/Equivalence.d.ts.map +1 -1
  51. package/dist/Equivalence.js +12 -8
  52. package/dist/Equivalence.js.map +1 -1
  53. package/dist/Exit.d.ts +27 -12
  54. package/dist/Exit.d.ts.map +1 -1
  55. package/dist/Exit.js +8 -3
  56. package/dist/Exit.js.map +1 -1
  57. package/dist/FiberHandle.d.ts +2 -0
  58. package/dist/FiberHandle.d.ts.map +1 -1
  59. package/dist/FiberHandle.js +9 -4
  60. package/dist/FiberHandle.js.map +1 -1
  61. package/dist/FiberMap.d.ts +2 -0
  62. package/dist/FiberMap.d.ts.map +1 -1
  63. package/dist/FiberMap.js +5 -2
  64. package/dist/FiberMap.js.map +1 -1
  65. package/dist/FileSystem.d.ts +5 -0
  66. package/dist/FileSystem.d.ts.map +1 -1
  67. package/dist/FileSystem.js +3 -0
  68. package/dist/FileSystem.js.map +1 -1
  69. package/dist/Formatter.d.ts.map +1 -1
  70. package/dist/Formatter.js +27 -13
  71. package/dist/Formatter.js.map +1 -1
  72. package/dist/Graph.d.ts.map +1 -1
  73. package/dist/Graph.js.map +1 -1
  74. package/dist/Hash.d.ts.map +1 -1
  75. package/dist/Hash.js +4 -1
  76. package/dist/Hash.js.map +1 -1
  77. package/dist/HashSet.d.ts.map +1 -1
  78. package/dist/HashSet.js.map +1 -1
  79. package/dist/Iterable.d.ts.map +1 -1
  80. package/dist/Iterable.js +18 -17
  81. package/dist/Iterable.js.map +1 -1
  82. package/dist/JsonPatch.js +4 -0
  83. package/dist/JsonPatch.js.map +1 -1
  84. package/dist/JsonSchema.d.ts +9 -3
  85. package/dist/JsonSchema.d.ts.map +1 -1
  86. package/dist/JsonSchema.js +32 -43
  87. package/dist/JsonSchema.js.map +1 -1
  88. package/dist/Layer.d.ts.map +1 -1
  89. package/dist/Layer.js +2 -2
  90. package/dist/Layer.js.map +1 -1
  91. package/dist/ManagedRuntime.d.ts +19 -1
  92. package/dist/ManagedRuntime.d.ts.map +1 -1
  93. package/dist/ManagedRuntime.js +62 -6
  94. package/dist/ManagedRuntime.js.map +1 -1
  95. package/dist/Metric.d.ts +135 -3
  96. package/dist/Metric.d.ts.map +1 -1
  97. package/dist/Metric.js +197 -25
  98. package/dist/Metric.js.map +1 -1
  99. package/dist/MutableHashMap.d.ts.map +1 -1
  100. package/dist/MutableHashMap.js.map +1 -1
  101. package/dist/MutableList.d.ts +5 -2
  102. package/dist/MutableList.d.ts.map +1 -1
  103. package/dist/MutableList.js +7 -5
  104. package/dist/MutableList.js.map +1 -1
  105. package/dist/MutableRef.d.ts.map +1 -1
  106. package/dist/MutableRef.js +7 -0
  107. package/dist/MutableRef.js.map +1 -1
  108. package/dist/Number.js +2 -2
  109. package/dist/Number.js.map +1 -1
  110. package/dist/Optic.d.ts.map +1 -1
  111. package/dist/Optic.js.map +1 -1
  112. package/dist/PartitionedSemaphore.d.ts +2 -1
  113. package/dist/PartitionedSemaphore.d.ts.map +1 -1
  114. package/dist/PartitionedSemaphore.js +22 -12
  115. package/dist/PartitionedSemaphore.js.map +1 -1
  116. package/dist/Path.d.ts.map +1 -1
  117. package/dist/Path.js +8 -1
  118. package/dist/Path.js.map +1 -1
  119. package/dist/Pool.d.ts.map +1 -1
  120. package/dist/Pool.js +77 -27
  121. package/dist/Pool.js.map +1 -1
  122. package/dist/PubSub.d.ts.map +1 -1
  123. package/dist/PubSub.js +17 -13
  124. package/dist/PubSub.js.map +1 -1
  125. package/dist/Queue.d.ts +4 -1
  126. package/dist/Queue.d.ts.map +1 -1
  127. package/dist/Queue.js +4 -1
  128. package/dist/Queue.js.map +1 -1
  129. package/dist/Random.d.ts.map +1 -1
  130. package/dist/Random.js +1 -1
  131. package/dist/Random.js.map +1 -1
  132. package/dist/RcMap.d.ts +12 -7
  133. package/dist/RcMap.d.ts.map +1 -1
  134. package/dist/RcMap.js +9 -6
  135. package/dist/RcMap.js.map +1 -1
  136. package/dist/Record.d.ts +51 -0
  137. package/dist/Record.d.ts.map +1 -1
  138. package/dist/Record.js +17 -0
  139. package/dist/Record.js.map +1 -1
  140. package/dist/Ref.d.ts.map +1 -1
  141. package/dist/Ref.js +8 -0
  142. package/dist/Ref.js.map +1 -1
  143. package/dist/References.d.ts +5 -4
  144. package/dist/References.d.ts.map +1 -1
  145. package/dist/References.js +5 -4
  146. package/dist/References.js.map +1 -1
  147. package/dist/RequestResolver.d.ts +31 -1
  148. package/dist/RequestResolver.d.ts.map +1 -1
  149. package/dist/RequestResolver.js +39 -4
  150. package/dist/RequestResolver.js.map +1 -1
  151. package/dist/Resource.js +1 -1
  152. package/dist/Resource.js.map +1 -1
  153. package/dist/Runtime.d.ts +3 -3
  154. package/dist/Runtime.d.ts.map +1 -1
  155. package/dist/Runtime.js +18 -15
  156. package/dist/Runtime.js.map +1 -1
  157. package/dist/Schedule.d.ts.map +1 -1
  158. package/dist/Schedule.js +1 -1
  159. package/dist/Schedule.js.map +1 -1
  160. package/dist/Schema.d.ts +408 -340
  161. package/dist/Schema.d.ts.map +1 -1
  162. package/dist/Schema.js +370 -47
  163. package/dist/Schema.js.map +1 -1
  164. package/dist/SchemaAST.d.ts +9 -7
  165. package/dist/SchemaAST.d.ts.map +1 -1
  166. package/dist/SchemaAST.js +38 -25
  167. package/dist/SchemaAST.js.map +1 -1
  168. package/dist/SchemaGetter.d.ts +8 -3
  169. package/dist/SchemaGetter.d.ts.map +1 -1
  170. package/dist/SchemaGetter.js +15 -5
  171. package/dist/SchemaGetter.js.map +1 -1
  172. package/dist/SchemaIssue.d.ts +4 -4
  173. package/dist/SchemaIssue.d.ts.map +1 -1
  174. package/dist/SchemaIssue.js +29 -51
  175. package/dist/SchemaIssue.js.map +1 -1
  176. package/dist/SchemaParser.d.ts.map +1 -1
  177. package/dist/SchemaParser.js +48 -22
  178. package/dist/SchemaParser.js.map +1 -1
  179. package/dist/SchemaRepresentation.d.ts +75 -11
  180. package/dist/SchemaRepresentation.d.ts.map +1 -1
  181. package/dist/SchemaRepresentation.js +41 -13
  182. package/dist/SchemaRepresentation.js.map +1 -1
  183. package/dist/SchemaTransformation.d.ts +5 -2
  184. package/dist/SchemaTransformation.d.ts.map +1 -1
  185. package/dist/SchemaTransformation.js +10 -3
  186. package/dist/SchemaTransformation.js.map +1 -1
  187. package/dist/Scope.d.ts +12 -2
  188. package/dist/Scope.d.ts.map +1 -1
  189. package/dist/Scope.js +5 -0
  190. package/dist/Scope.js.map +1 -1
  191. package/dist/ScopedCache.d.ts +10 -7
  192. package/dist/ScopedCache.d.ts.map +1 -1
  193. package/dist/ScopedCache.js +9 -5
  194. package/dist/ScopedCache.js.map +1 -1
  195. package/dist/SemVer.d.ts +1196 -0
  196. package/dist/SemVer.d.ts.map +1 -0
  197. package/dist/SemVer.js +756 -0
  198. package/dist/SemVer.js.map +1 -0
  199. package/dist/SemVerRange.d.ts +559 -0
  200. package/dist/SemVerRange.d.ts.map +1 -0
  201. package/dist/SemVerRange.js +551 -0
  202. package/dist/SemVerRange.js.map +1 -0
  203. package/dist/Semaphore.d.ts.map +1 -1
  204. package/dist/Semaphore.js +54 -35
  205. package/dist/Semaphore.js.map +1 -1
  206. package/dist/Sink.d.ts.map +1 -1
  207. package/dist/Sink.js +13 -4
  208. package/dist/Sink.js.map +1 -1
  209. package/dist/Stream.d.ts +235 -8
  210. package/dist/Stream.d.ts.map +1 -1
  211. package/dist/Stream.js +167 -70
  212. package/dist/Stream.js.map +1 -1
  213. package/dist/String.d.ts +7 -2
  214. package/dist/String.d.ts.map +1 -1
  215. package/dist/String.js +11 -6
  216. package/dist/String.js.map +1 -1
  217. package/dist/TextDiff.d.ts +399 -0
  218. package/dist/TextDiff.d.ts.map +1 -0
  219. package/dist/TextDiff.js +634 -0
  220. package/dist/TextDiff.js.map +1 -0
  221. package/dist/Tracer.d.ts +11 -1
  222. package/dist/Tracer.d.ts.map +1 -1
  223. package/dist/Tracer.js +6 -1
  224. package/dist/Tracer.js.map +1 -1
  225. package/dist/TxHashMap.d.ts.map +1 -1
  226. package/dist/TxHashMap.js.map +1 -1
  227. package/dist/TxHashSet.d.ts.map +1 -1
  228. package/dist/TxHashSet.js.map +1 -1
  229. package/dist/ai/AiError.d.ts +68 -4
  230. package/dist/ai/AiError.d.ts.map +1 -1
  231. package/dist/ai/AiError.js +50 -2
  232. package/dist/ai/AiError.js.map +1 -1
  233. package/dist/ai/Chat.d.ts +1 -2
  234. package/dist/ai/Chat.d.ts.map +1 -1
  235. package/dist/ai/Chat.js +6 -3
  236. package/dist/ai/Chat.js.map +1 -1
  237. package/dist/ai/Decision.d.ts +46 -1
  238. package/dist/ai/Decision.d.ts.map +1 -1
  239. package/dist/ai/Decision.js.map +1 -1
  240. package/dist/ai/DecisionModel.d.ts +129 -11
  241. package/dist/ai/DecisionModel.d.ts.map +1 -1
  242. package/dist/ai/DecisionModel.js +182 -94
  243. package/dist/ai/DecisionModel.js.map +1 -1
  244. package/dist/ai/EmbeddingModel.d.ts +10 -0
  245. package/dist/ai/EmbeddingModel.d.ts.map +1 -1
  246. package/dist/ai/EmbeddingModel.js +21 -7
  247. package/dist/ai/EmbeddingModel.js.map +1 -1
  248. package/dist/ai/LanguageModel.d.ts.map +1 -1
  249. package/dist/ai/LanguageModel.js +9 -0
  250. package/dist/ai/LanguageModel.js.map +1 -1
  251. package/dist/ai/McpClient.d.ts +289 -0
  252. package/dist/ai/McpClient.d.ts.map +1 -0
  253. package/dist/ai/McpClient.js +819 -0
  254. package/dist/ai/McpClient.js.map +1 -0
  255. package/dist/ai/McpClientError.d.ts +254 -0
  256. package/dist/ai/McpClientError.d.ts.map +1 -0
  257. package/dist/ai/McpClientError.js +260 -0
  258. package/dist/ai/McpClientError.js.map +1 -0
  259. package/dist/ai/McpProtocol.d.ts +2 -2
  260. package/dist/ai/McpProtocol.d.ts.map +1 -1
  261. package/dist/ai/McpSchema.d.ts +258 -125
  262. package/dist/ai/McpSchema.d.ts.map +1 -1
  263. package/dist/ai/McpSchema.js +94 -24
  264. package/dist/ai/McpSchema.js.map +1 -1
  265. package/dist/ai/McpServer.d.ts.map +1 -1
  266. package/dist/ai/McpServer.js +46 -37
  267. package/dist/ai/McpServer.js.map +1 -1
  268. package/dist/ai/Prompt.d.ts +74 -20
  269. package/dist/ai/Prompt.d.ts.map +1 -1
  270. package/dist/ai/Prompt.js +61 -1
  271. package/dist/ai/Prompt.js.map +1 -1
  272. package/dist/ai/Response.d.ts +160 -3
  273. package/dist/ai/Response.d.ts.map +1 -1
  274. package/dist/ai/Response.js +39 -37
  275. package/dist/ai/Response.js.map +1 -1
  276. package/dist/ai/Tool.d.ts +36 -4
  277. package/dist/ai/Tool.d.ts.map +1 -1
  278. package/dist/ai/Tool.js +5 -2
  279. package/dist/ai/Tool.js.map +1 -1
  280. package/dist/ai/Toolkit.d.ts +48 -1
  281. package/dist/ai/Toolkit.d.ts.map +1 -1
  282. package/dist/ai/Toolkit.js +73 -13
  283. package/dist/ai/Toolkit.js.map +1 -1
  284. package/dist/ai/index.d.ts +10 -0
  285. package/dist/ai/index.d.ts.map +1 -1
  286. package/dist/ai/index.js +10 -0
  287. package/dist/ai/index.js.map +1 -1
  288. package/dist/ai/internal/mcpCore.js.map +1 -1
  289. package/dist/ai/internal/mcpProtocol/v2024_11_05.js +1 -1
  290. package/dist/ai/internal/mcpProtocol/v2024_11_05.js.map +1 -1
  291. package/dist/ai/internal/mcpProtocol/v2025_03_26.js +1 -1
  292. package/dist/ai/internal/mcpProtocol/v2025_03_26.js.map +1 -1
  293. package/dist/ai/internal/mcpProtocol/v2025_06_18.js +2 -2
  294. package/dist/ai/internal/mcpProtocol/v2025_06_18.js.map +1 -1
  295. package/dist/ai/internal/mcpProtocol/v2025_11_25.js +2 -2
  296. package/dist/ai/internal/mcpProtocol/v2025_11_25.js.map +1 -1
  297. package/dist/ai/internal/mcpProtocol/v2026_07_28.js +4 -7
  298. package/dist/ai/internal/mcpProtocol/v2026_07_28.js.map +1 -1
  299. package/dist/ai/internal/mcpProtocol.js +16 -2
  300. package/dist/ai/internal/mcpProtocol.js.map +1 -1
  301. package/dist/ai/internal/mcpRuntime.js +3 -4
  302. package/dist/ai/internal/mcpRuntime.js.map +1 -1
  303. package/dist/ai/internal/mcpSchema/v2024_11_05.js +19 -13
  304. package/dist/ai/internal/mcpSchema/v2024_11_05.js.map +1 -1
  305. package/dist/ai/internal/mcpSchema/v2025_03_26.js +3 -2
  306. package/dist/ai/internal/mcpSchema/v2025_03_26.js.map +1 -1
  307. package/dist/ai/internal/mcpSchema/v2025_06_18.js +7 -7
  308. package/dist/ai/internal/mcpSchema/v2025_06_18.js.map +1 -1
  309. package/dist/ai/internal/mcpSchema/v2025_11_25.js +8 -8
  310. package/dist/ai/internal/mcpSchema/v2025_11_25.js.map +1 -1
  311. package/dist/ai/internal/mcpSchema/v2026_07_28.js +43 -42
  312. package/dist/ai/internal/mcpSchema/v2026_07_28.js.map +1 -1
  313. package/dist/cli/Argument.d.ts +15 -0
  314. package/dist/cli/Argument.d.ts.map +1 -1
  315. package/dist/cli/Argument.js +5 -0
  316. package/dist/cli/Argument.js.map +1 -1
  317. package/dist/cli/CliError.d.ts +120 -2
  318. package/dist/cli/CliError.d.ts.map +1 -1
  319. package/dist/cli/CliError.js +106 -5
  320. package/dist/cli/CliError.js.map +1 -1
  321. package/dist/cli/CliOutput.d.ts +155 -6
  322. package/dist/cli/CliOutput.d.ts.map +1 -1
  323. package/dist/cli/CliOutput.js +62 -6
  324. package/dist/cli/CliOutput.js.map +1 -1
  325. package/dist/cli/Command.d.ts +310 -18
  326. package/dist/cli/Command.d.ts.map +1 -1
  327. package/dist/cli/Command.js +164 -33
  328. package/dist/cli/Command.js.map +1 -1
  329. package/dist/cli/Completions.d.ts +63 -0
  330. package/dist/cli/Completions.d.ts.map +1 -1
  331. package/dist/cli/Completions.js +49 -9
  332. package/dist/cli/Completions.js.map +1 -1
  333. package/dist/cli/Flag.d.ts +130 -0
  334. package/dist/cli/Flag.d.ts.map +1 -1
  335. package/dist/cli/Flag.js +61 -0
  336. package/dist/cli/Flag.js.map +1 -1
  337. package/dist/cli/GlobalFlag.d.ts.map +1 -1
  338. package/dist/cli/GlobalFlag.js +14 -6
  339. package/dist/cli/GlobalFlag.js.map +1 -1
  340. package/dist/cli/Param.d.ts +116 -0
  341. package/dist/cli/Param.d.ts.map +1 -1
  342. package/dist/cli/Param.js +77 -2
  343. package/dist/cli/Param.js.map +1 -1
  344. package/dist/cli/TerminalCapabilities.d.ts +85 -0
  345. package/dist/cli/TerminalCapabilities.d.ts.map +1 -0
  346. package/dist/cli/TerminalCapabilities.js +124 -0
  347. package/dist/cli/TerminalCapabilities.js.map +1 -0
  348. package/dist/cli/index.d.ts +5 -0
  349. package/dist/cli/index.d.ts.map +1 -1
  350. package/dist/cli/index.js +5 -0
  351. package/dist/cli/index.js.map +1 -1
  352. package/dist/cli/internal/command.d.ts +2 -1
  353. package/dist/cli/internal/command.d.ts.map +1 -1
  354. package/dist/cli/internal/command.js +5 -2
  355. package/dist/cli/internal/command.js.map +1 -1
  356. package/dist/cli/internal/completions/bash.js +77 -30
  357. package/dist/cli/internal/completions/bash.js.map +1 -1
  358. package/dist/cli/internal/completions/descriptor.js +9 -1
  359. package/dist/cli/internal/completions/descriptor.js.map +1 -1
  360. package/dist/cli/internal/completions/fish.js +10 -8
  361. package/dist/cli/internal/completions/fish.js.map +1 -1
  362. package/dist/cli/internal/completions/powershell.js +18 -9
  363. package/dist/cli/internal/completions/powershell.js.map +1 -1
  364. package/dist/cli/internal/completions/zsh.js +8 -5
  365. package/dist/cli/internal/completions/zsh.js.map +1 -1
  366. package/dist/cli/internal/formatter.d.ts +2 -0
  367. package/dist/cli/internal/formatter.d.ts.map +1 -0
  368. package/dist/cli/internal/formatter.js +15 -0
  369. package/dist/cli/internal/formatter.js.map +1 -0
  370. package/dist/cli/internal/lexer.js +24 -10
  371. package/dist/cli/internal/lexer.js.map +1 -1
  372. package/dist/cli/internal/parser.js +24 -12
  373. package/dist/cli/internal/parser.js.map +1 -1
  374. package/dist/cluster/ClusterCron.d.ts +29 -1
  375. package/dist/cluster/ClusterCron.d.ts.map +1 -1
  376. package/dist/cluster/ClusterCron.js +64 -32
  377. package/dist/cluster/ClusterCron.js.map +1 -1
  378. package/dist/cluster/ClusterMetrics.d.ts +143 -7
  379. package/dist/cluster/ClusterMetrics.d.ts.map +1 -1
  380. package/dist/cluster/ClusterMetrics.js +151 -7
  381. package/dist/cluster/ClusterMetrics.js.map +1 -1
  382. package/dist/cluster/ClusterWorkflowEngine.d.ts +1 -1
  383. package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
  384. package/dist/cluster/ClusterWorkflowEngine.js +82 -21
  385. package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
  386. package/dist/cluster/Entity.d.ts +2 -0
  387. package/dist/cluster/Entity.d.ts.map +1 -1
  388. package/dist/cluster/Entity.js.map +1 -1
  389. package/dist/cluster/MessageStorage.d.ts +44 -45
  390. package/dist/cluster/MessageStorage.d.ts.map +1 -1
  391. package/dist/cluster/MessageStorage.js +6 -7
  392. package/dist/cluster/MessageStorage.js.map +1 -1
  393. package/dist/cluster/Runners.d.ts.map +1 -1
  394. package/dist/cluster/Runners.js +54 -15
  395. package/dist/cluster/Runners.js.map +1 -1
  396. package/dist/cluster/Sharding.d.ts +1 -0
  397. package/dist/cluster/Sharding.d.ts.map +1 -1
  398. package/dist/cluster/Sharding.js +155 -52
  399. package/dist/cluster/Sharding.js.map +1 -1
  400. package/dist/cluster/ShardingConfig.d.ts +30 -0
  401. package/dist/cluster/ShardingConfig.d.ts.map +1 -1
  402. package/dist/cluster/ShardingConfig.js +4 -0
  403. package/dist/cluster/ShardingConfig.js.map +1 -1
  404. package/dist/cluster/Snowflake.d.ts.map +1 -1
  405. package/dist/cluster/Snowflake.js +3 -7
  406. package/dist/cluster/Snowflake.js.map +1 -1
  407. package/dist/cluster/SqlMessageStorage.d.ts.map +1 -1
  408. package/dist/cluster/SqlMessageStorage.js +40 -50
  409. package/dist/cluster/SqlMessageStorage.js.map +1 -1
  410. package/dist/cluster/SqlRunnerStorage.d.ts +2 -2
  411. package/dist/cluster/SqlRunnerStorage.d.ts.map +1 -1
  412. package/dist/cluster/SqlRunnerStorage.js +97 -43
  413. package/dist/cluster/SqlRunnerStorage.js.map +1 -1
  414. package/dist/cluster/internal/entityManager.js +119 -28
  415. package/dist/cluster/internal/entityManager.js.map +1 -1
  416. package/dist/devtools/DevTools.d.ts +3 -2
  417. package/dist/devtools/DevTools.d.ts.map +1 -1
  418. package/dist/devtools/DevTools.js +3 -2
  419. package/dist/devtools/DevTools.js.map +1 -1
  420. package/dist/devtools/DevToolsClient.d.ts +11 -0
  421. package/dist/devtools/DevToolsClient.d.ts.map +1 -1
  422. package/dist/devtools/DevToolsClient.js +33 -4
  423. package/dist/devtools/DevToolsClient.js.map +1 -1
  424. package/dist/encoding/Base64.js +36 -0
  425. package/dist/encoding/Base64.js.map +1 -1
  426. package/dist/encoding/Base64Url.d.ts +29 -0
  427. package/dist/encoding/Base64Url.d.ts.map +1 -1
  428. package/dist/encoding/Base64Url.js +29 -0
  429. package/dist/encoding/Base64Url.js.map +1 -1
  430. package/dist/encoding/Ini.d.ts.map +1 -1
  431. package/dist/encoding/Ini.js +3 -0
  432. package/dist/encoding/Ini.js.map +1 -1
  433. package/dist/encoding/JsonArray.d.ts +270 -0
  434. package/dist/encoding/JsonArray.d.ts.map +1 -0
  435. package/dist/encoding/JsonArray.js +691 -0
  436. package/dist/encoding/JsonArray.js.map +1 -0
  437. package/dist/encoding/Ndjson.d.ts +43 -4
  438. package/dist/encoding/Ndjson.d.ts.map +1 -1
  439. package/dist/encoding/Ndjson.js +169 -18
  440. package/dist/encoding/Ndjson.js.map +1 -1
  441. package/dist/encoding/SchemaBinary.d.ts +9 -1
  442. package/dist/encoding/SchemaBinary.d.ts.map +1 -1
  443. package/dist/encoding/SchemaBinary.js +12 -19
  444. package/dist/encoding/SchemaBinary.js.map +1 -1
  445. package/dist/encoding/Sse.d.ts.map +1 -1
  446. package/dist/encoding/Sse.js +3 -3
  447. package/dist/encoding/Sse.js.map +1 -1
  448. package/dist/encoding/Tar.d.ts +309 -0
  449. package/dist/encoding/Tar.d.ts.map +1 -0
  450. package/dist/encoding/Tar.js +1182 -0
  451. package/dist/encoding/Tar.js.map +1 -0
  452. package/dist/encoding/Toml.d.ts.map +1 -1
  453. package/dist/encoding/Toml.js +24 -19
  454. package/dist/encoding/Toml.js.map +1 -1
  455. package/dist/encoding/Xml.d.ts +464 -0
  456. package/dist/encoding/Xml.d.ts.map +1 -0
  457. package/dist/encoding/Xml.js +1619 -0
  458. package/dist/encoding/Xml.js.map +1 -0
  459. package/dist/encoding/Yaml.d.ts +6 -2
  460. package/dist/encoding/Yaml.d.ts.map +1 -1
  461. package/dist/encoding/Yaml.js +97 -34
  462. package/dist/encoding/Yaml.js.map +1 -1
  463. package/dist/encoding/Zip.d.ts +413 -0
  464. package/dist/encoding/Zip.d.ts.map +1 -0
  465. package/dist/encoding/Zip.js +1255 -0
  466. package/dist/encoding/Zip.js.map +1 -0
  467. package/dist/encoding/index.d.ts +20 -0
  468. package/dist/encoding/index.d.ts.map +1 -1
  469. package/dist/encoding/index.js +20 -0
  470. package/dist/encoding/index.js.map +1 -1
  471. package/dist/eventlog/EventJournal.d.ts +90 -5
  472. package/dist/eventlog/EventJournal.d.ts.map +1 -1
  473. package/dist/eventlog/EventJournal.js +488 -228
  474. package/dist/eventlog/EventJournal.js.map +1 -1
  475. package/dist/eventlog/EventLog.d.ts +180 -12
  476. package/dist/eventlog/EventLog.d.ts.map +1 -1
  477. package/dist/eventlog/EventLog.js +394 -146
  478. package/dist/eventlog/EventLog.js.map +1 -1
  479. package/dist/eventlog/EventLogEncryption.d.ts +36 -30
  480. package/dist/eventlog/EventLogEncryption.d.ts.map +1 -1
  481. package/dist/eventlog/EventLogEncryption.js +97 -38
  482. package/dist/eventlog/EventLogEncryption.js.map +1 -1
  483. package/dist/eventlog/EventLogMessage.d.ts +74 -34
  484. package/dist/eventlog/EventLogMessage.d.ts.map +1 -1
  485. package/dist/eventlog/EventLogMessage.js +45 -11
  486. package/dist/eventlog/EventLogMessage.js.map +1 -1
  487. package/dist/eventlog/EventLogRemote.d.ts +45 -8
  488. package/dist/eventlog/EventLogRemote.d.ts.map +1 -1
  489. package/dist/eventlog/EventLogRemote.js +51 -14
  490. package/dist/eventlog/EventLogRemote.js.map +1 -1
  491. package/dist/eventlog/EventLogServer.d.ts +46 -3
  492. package/dist/eventlog/EventLogServer.d.ts.map +1 -1
  493. package/dist/eventlog/EventLogServer.js +119 -19
  494. package/dist/eventlog/EventLogServer.js.map +1 -1
  495. package/dist/eventlog/EventLogServerEncrypted.d.ts +23 -33
  496. package/dist/eventlog/EventLogServerEncrypted.d.ts.map +1 -1
  497. package/dist/eventlog/EventLogServerEncrypted.js +97 -70
  498. package/dist/eventlog/EventLogServerEncrypted.js.map +1 -1
  499. package/dist/eventlog/EventLogServerUnencrypted.d.ts +39 -5
  500. package/dist/eventlog/EventLogServerUnencrypted.d.ts.map +1 -1
  501. package/dist/eventlog/EventLogServerUnencrypted.js +151 -69
  502. package/dist/eventlog/EventLogServerUnencrypted.js.map +1 -1
  503. package/dist/eventlog/EventRow.d.ts +288 -0
  504. package/dist/eventlog/EventRow.d.ts.map +1 -0
  505. package/dist/eventlog/EventRow.js +435 -0
  506. package/dist/eventlog/EventRow.js.map +1 -0
  507. package/dist/eventlog/SqlEventJournal.d.ts +18 -18
  508. package/dist/eventlog/SqlEventJournal.d.ts.map +1 -1
  509. package/dist/eventlog/SqlEventJournal.js +417 -169
  510. package/dist/eventlog/SqlEventJournal.js.map +1 -1
  511. package/dist/eventlog/SqlEventLogServerEncrypted.d.ts +10 -18
  512. package/dist/eventlog/SqlEventLogServerEncrypted.d.ts.map +1 -1
  513. package/dist/eventlog/SqlEventLogServerEncrypted.js +179 -69
  514. package/dist/eventlog/SqlEventLogServerEncrypted.js.map +1 -1
  515. package/dist/eventlog/SqlEventLogServerUnencrypted.d.ts +23 -3
  516. package/dist/eventlog/SqlEventLogServerUnencrypted.d.ts.map +1 -1
  517. package/dist/eventlog/SqlEventLogServerUnencrypted.js +102 -51
  518. package/dist/eventlog/SqlEventLogServerUnencrypted.js.map +1 -1
  519. package/dist/eventlog/index.d.ts +5 -0
  520. package/dist/eventlog/index.d.ts.map +1 -1
  521. package/dist/eventlog/index.js +5 -0
  522. package/dist/eventlog/index.js.map +1 -1
  523. package/dist/eventlog/internal/conflicts.d.ts +46 -0
  524. package/dist/eventlog/internal/conflicts.d.ts.map +1 -0
  525. package/dist/eventlog/internal/conflicts.js +89 -0
  526. package/dist/eventlog/internal/conflicts.js.map +1 -0
  527. package/dist/graphql/GraphQLClientError.d.ts +2 -2
  528. package/dist/graphql/GraphQLClientError.d.ts.map +1 -1
  529. package/dist/graphql/GraphQLClientError.js +4 -18
  530. package/dist/graphql/GraphQLClientError.js.map +1 -1
  531. package/dist/graphql/GraphQLProtocol.d.ts +12 -9
  532. package/dist/graphql/GraphQLProtocol.d.ts.map +1 -1
  533. package/dist/graphql/GraphQLProtocol.js +4 -3
  534. package/dist/graphql/GraphQLProtocol.js.map +1 -1
  535. package/dist/graphql/GraphQLResolver.d.ts +2 -0
  536. package/dist/graphql/GraphQLResolver.d.ts.map +1 -1
  537. package/dist/graphql/GraphQLResolver.js +74 -32
  538. package/dist/graphql/GraphQLResolver.js.map +1 -1
  539. package/dist/http/Cookies.d.ts.map +1 -1
  540. package/dist/http/Cookies.js +10 -9
  541. package/dist/http/Cookies.js.map +1 -1
  542. package/dist/http/FetchHttpClient.d.ts +8 -1
  543. package/dist/http/FetchHttpClient.d.ts.map +1 -1
  544. package/dist/http/FetchHttpClient.js +51 -4
  545. package/dist/http/FetchHttpClient.js.map +1 -1
  546. package/dist/http/FindMyWay/internal/router.js +10 -0
  547. package/dist/http/FindMyWay/internal/router.js.map +1 -1
  548. package/dist/http/Headers.d.ts +227 -0
  549. package/dist/http/Headers.d.ts.map +1 -1
  550. package/dist/http/Headers.js +261 -0
  551. package/dist/http/Headers.js.map +1 -1
  552. package/dist/http/HttpClient.d.ts +516 -0
  553. package/dist/http/HttpClient.d.ts.map +1 -1
  554. package/dist/http/HttpClient.js +286 -23
  555. package/dist/http/HttpClient.js.map +1 -1
  556. package/dist/http/HttpClientError.d.ts +8 -1
  557. package/dist/http/HttpClientError.d.ts.map +1 -1
  558. package/dist/http/HttpClientError.js +37 -1
  559. package/dist/http/HttpClientError.js.map +1 -1
  560. package/dist/http/HttpClientRequest.d.ts +127 -3
  561. package/dist/http/HttpClientRequest.d.ts.map +1 -1
  562. package/dist/http/HttpClientRequest.js +45 -3
  563. package/dist/http/HttpClientRequest.js.map +1 -1
  564. package/dist/http/HttpClientResponse.d.ts +53 -0
  565. package/dist/http/HttpClientResponse.d.ts.map +1 -1
  566. package/dist/http/HttpClientResponse.js +47 -0
  567. package/dist/http/HttpClientResponse.js.map +1 -1
  568. package/dist/http/HttpEffect.d.ts +6 -2
  569. package/dist/http/HttpEffect.d.ts.map +1 -1
  570. package/dist/http/HttpEffect.js +21 -17
  571. package/dist/http/HttpEffect.js.map +1 -1
  572. package/dist/http/HttpIncomingMessage.d.ts +2 -1
  573. package/dist/http/HttpIncomingMessage.d.ts.map +1 -1
  574. package/dist/http/HttpIncomingMessage.js +3 -23
  575. package/dist/http/HttpIncomingMessage.js.map +1 -1
  576. package/dist/http/HttpMiddleware.d.ts +119 -2
  577. package/dist/http/HttpMiddleware.d.ts.map +1 -1
  578. package/dist/http/HttpMiddleware.js +173 -29
  579. package/dist/http/HttpMiddleware.js.map +1 -1
  580. package/dist/http/HttpRouter.d.ts.map +1 -1
  581. package/dist/http/HttpRouter.js +9 -3
  582. package/dist/http/HttpRouter.js.map +1 -1
  583. package/dist/http/HttpServerError.d.ts +5 -2
  584. package/dist/http/HttpServerError.d.ts.map +1 -1
  585. package/dist/http/HttpServerError.js +7 -5
  586. package/dist/http/HttpServerError.js.map +1 -1
  587. package/dist/http/HttpServerRequest.d.ts +30 -5
  588. package/dist/http/HttpServerRequest.d.ts.map +1 -1
  589. package/dist/http/HttpServerRequest.js +109 -20
  590. package/dist/http/HttpServerRequest.js.map +1 -1
  591. package/dist/http/HttpServerResponse.d.ts +17 -8
  592. package/dist/http/HttpServerResponse.d.ts.map +1 -1
  593. package/dist/http/HttpServerResponse.js +37 -21
  594. package/dist/http/HttpServerResponse.js.map +1 -1
  595. package/dist/http/HttpStaticServer.d.ts +0 -12
  596. package/dist/http/HttpStaticServer.d.ts.map +1 -1
  597. package/dist/http/HttpStaticServer.js +65 -24
  598. package/dist/http/HttpStaticServer.js.map +1 -1
  599. package/dist/http/MultipartParser/internal/contentType.d.ts +15 -1
  600. package/dist/http/MultipartParser/internal/contentType.d.ts.map +1 -1
  601. package/dist/http/MultipartParser/internal/contentType.js +89 -7
  602. package/dist/http/MultipartParser/internal/contentType.js.map +1 -1
  603. package/dist/http/MultipartParser/internal/headers.d.ts.map +1 -1
  604. package/dist/http/MultipartParser/internal/headers.js +4 -12
  605. package/dist/http/MultipartParser/internal/headers.js.map +1 -1
  606. package/dist/http/MultipartParser/internal/multipart.d.ts.map +1 -1
  607. package/dist/http/MultipartParser/internal/multipart.js +6 -27
  608. package/dist/http/MultipartParser/internal/multipart.js.map +1 -1
  609. package/dist/http/Url.d.ts.map +1 -1
  610. package/dist/http/Url.js +6 -1
  611. package/dist/http/Url.js.map +1 -1
  612. package/dist/http/UrlParams.d.ts +3 -1
  613. package/dist/http/UrlParams.d.ts.map +1 -1
  614. package/dist/http/UrlParams.js +4 -2
  615. package/dist/http/UrlParams.js.map +1 -1
  616. package/dist/http/internal/compression.js +4 -5
  617. package/dist/http/internal/compression.js.map +1 -1
  618. package/dist/http/internal/decompression.js +20 -11
  619. package/dist/http/internal/decompression.js.map +1 -1
  620. package/dist/http/internal/httpBody.js +8 -1
  621. package/dist/http/internal/httpBody.js.map +1 -1
  622. package/dist/http/internal/lazyStream.d.ts +2 -0
  623. package/dist/http/internal/lazyStream.d.ts.map +1 -0
  624. package/dist/http/internal/lazyStream.js +18 -0
  625. package/dist/http/internal/lazyStream.js.map +1 -0
  626. package/dist/http/internal/requestState.d.ts +2 -0
  627. package/dist/http/internal/requestState.d.ts.map +1 -0
  628. package/dist/http/internal/requestState.js +28 -0
  629. package/dist/http/internal/requestState.js.map +1 -0
  630. package/dist/http/internal/urlParams.js +25 -0
  631. package/dist/http/internal/urlParams.js.map +1 -1
  632. package/dist/http/internal/webResponse.d.ts +2 -0
  633. package/dist/http/internal/webResponse.d.ts.map +1 -0
  634. package/dist/http/internal/webResponse.js +12 -0
  635. package/dist/http/internal/webResponse.js.map +1 -0
  636. package/dist/http-api/HttpApi.d.ts +3 -6
  637. package/dist/http-api/HttpApi.d.ts.map +1 -1
  638. package/dist/http-api/HttpApi.js +4 -7
  639. package/dist/http-api/HttpApi.js.map +1 -1
  640. package/dist/http-api/HttpApiBuilder.d.ts.map +1 -1
  641. package/dist/http-api/HttpApiBuilder.js +142 -23
  642. package/dist/http-api/HttpApiBuilder.js.map +1 -1
  643. package/dist/http-api/HttpApiClient.d.ts +99 -4
  644. package/dist/http-api/HttpApiClient.d.ts.map +1 -1
  645. package/dist/http-api/HttpApiClient.js +218 -60
  646. package/dist/http-api/HttpApiClient.js.map +1 -1
  647. package/dist/http-api/HttpApiEndpoint.d.ts +72 -29
  648. package/dist/http-api/HttpApiEndpoint.d.ts.map +1 -1
  649. package/dist/http-api/HttpApiEndpoint.js +140 -14
  650. package/dist/http-api/HttpApiEndpoint.js.map +1 -1
  651. package/dist/http-api/HttpApiError.d.ts +58 -0
  652. package/dist/http-api/HttpApiError.d.ts.map +1 -1
  653. package/dist/http-api/HttpApiError.js +38 -12
  654. package/dist/http-api/HttpApiError.js.map +1 -1
  655. package/dist/http-api/HttpApiScalar.d.ts +2 -1
  656. package/dist/http-api/HttpApiScalar.d.ts.map +1 -1
  657. package/dist/http-api/HttpApiScalar.js +6 -3
  658. package/dist/http-api/HttpApiScalar.js.map +1 -1
  659. package/dist/http-api/HttpApiSchema.d.ts +242 -13
  660. package/dist/http-api/HttpApiSchema.d.ts.map +1 -1
  661. package/dist/http-api/HttpApiSchema.js +149 -5
  662. package/dist/http-api/HttpApiSchema.js.map +1 -1
  663. package/dist/http-api/HttpApiSwagger.d.ts +5 -0
  664. package/dist/http-api/HttpApiSwagger.d.ts.map +1 -1
  665. package/dist/http-api/HttpApiSwagger.js +14 -4
  666. package/dist/http-api/HttpApiSwagger.js.map +1 -1
  667. package/dist/http-api/HttpApiTest.d.ts +13 -2
  668. package/dist/http-api/HttpApiTest.d.ts.map +1 -1
  669. package/dist/http-api/HttpApiTest.js +33 -11
  670. package/dist/http-api/HttpApiTest.js.map +1 -1
  671. package/dist/http-api/OpenApi.d.ts +17 -3
  672. package/dist/http-api/OpenApi.d.ts.map +1 -1
  673. package/dist/http-api/OpenApi.js +81 -47
  674. package/dist/http-api/OpenApi.js.map +1 -1
  675. package/dist/http-api/internal/path.js +35 -10
  676. package/dist/http-api/internal/path.js.map +1 -1
  677. package/dist/http-api/internal/toCodecHttpProperties.d.ts +2 -0
  678. package/dist/http-api/internal/toCodecHttpProperties.d.ts.map +1 -0
  679. package/dist/http-api/internal/toCodecHttpProperties.js +38 -0
  680. package/dist/http-api/internal/toCodecHttpProperties.js.map +1 -0
  681. package/dist/index.d.ts +20 -0
  682. package/dist/index.d.ts.map +1 -1
  683. package/dist/index.js +20 -0
  684. package/dist/index.js.map +1 -1
  685. package/dist/internal/arbitrary/runner.d.ts.map +1 -1
  686. package/dist/internal/arbitrary/runner.js +120 -44
  687. package/dist/internal/arbitrary/runner.js.map +1 -1
  688. package/dist/internal/core.js +3 -1
  689. package/dist/internal/core.js.map +1 -1
  690. package/dist/internal/dateTime.js +19 -7
  691. package/dist/internal/dateTime.js.map +1 -1
  692. package/dist/internal/effect.js +106 -87
  693. package/dist/internal/effect.js.map +1 -1
  694. package/dist/internal/equal.js +14 -0
  695. package/dist/internal/equal.js.map +1 -1
  696. package/dist/internal/hashMap.js +2 -2
  697. package/dist/internal/hashMap.js.map +1 -1
  698. package/dist/internal/hydration.d.ts +2 -0
  699. package/dist/internal/hydration.d.ts.map +1 -0
  700. package/dist/internal/hydration.js +15 -0
  701. package/dist/internal/hydration.js.map +1 -0
  702. package/dist/internal/inflate.d.ts +2 -0
  703. package/dist/internal/inflate.d.ts.map +1 -0
  704. package/dist/internal/inflate.js +680 -0
  705. package/dist/internal/inflate.js.map +1 -0
  706. package/dist/internal/jsonSchema.d.ts +2 -0
  707. package/dist/internal/jsonSchema.d.ts.map +1 -0
  708. package/dist/internal/jsonSchema.js +28 -0
  709. package/dist/internal/jsonSchema.js.map +1 -0
  710. package/dist/internal/matcher.js +1 -1
  711. package/dist/internal/matcher.js.map +1 -1
  712. package/dist/internal/record.js +6 -0
  713. package/dist/internal/record.js.map +1 -1
  714. package/dist/internal/request.js +20 -7
  715. package/dist/internal/request.js.map +1 -1
  716. package/dist/internal/schedule.js +17 -22
  717. package/dist/internal/schedule.js.map +1 -1
  718. package/dist/internal/schema/compilerRegistry.js +4 -1
  719. package/dist/internal/schema/compilerRegistry.js.map +1 -1
  720. package/dist/internal/schema/content.d.ts +2 -0
  721. package/dist/internal/schema/content.d.ts.map +1 -0
  722. package/dist/internal/schema/content.js +13 -0
  723. package/dist/internal/schema/content.js.map +1 -0
  724. package/dist/internal/schema/fromJsonSchemaDocument.js +253 -255
  725. package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -1
  726. package/dist/internal/schema/fromRepresentation.js +2 -1
  727. package/dist/internal/schema/fromRepresentation.js.map +1 -1
  728. package/dist/internal/schema/interpreter.js +51 -36
  729. package/dist/internal/schema/interpreter.js.map +1 -1
  730. package/dist/internal/schema/standardSchema.js +42 -35
  731. package/dist/internal/schema/standardSchema.js.map +1 -1
  732. package/dist/internal/schema/toCodeDocument.js +10 -5
  733. package/dist/internal/schema/toCodeDocument.js.map +1 -1
  734. package/dist/internal/schema/toCodec.js +99 -17
  735. package/dist/internal/schema/toCodec.js.map +1 -1
  736. package/dist/internal/schema/toFormatter.js +5 -5
  737. package/dist/internal/schema/toFormatter.js.map +1 -1
  738. package/dist/internal/schema/toJsonSchemaDocument.js +257 -170
  739. package/dist/internal/schema/toJsonSchemaDocument.js.map +1 -1
  740. package/dist/internal/schema/toRepresentation.js +107 -129
  741. package/dist/internal/schema/toRepresentation.js.map +1 -1
  742. package/dist/internal/sql.d.ts +2 -0
  743. package/dist/internal/sql.d.ts.map +1 -0
  744. package/dist/internal/sql.js +13 -0
  745. package/dist/internal/sql.js.map +1 -0
  746. package/dist/internal/trie.js +1 -3
  747. package/dist/internal/trie.js.map +1 -1
  748. package/dist/internal/uuid.js +7 -3
  749. package/dist/internal/uuid.js.map +1 -1
  750. package/dist/internal/version.js +1 -1
  751. package/dist/net/NetAddress.d.ts.map +1 -1
  752. package/dist/net/NetAddress.js +2 -8
  753. package/dist/net/NetAddress.js.map +1 -1
  754. package/dist/observability/OtlpExporter.d.ts.map +1 -1
  755. package/dist/observability/OtlpExporter.js +5 -12
  756. package/dist/observability/OtlpExporter.js.map +1 -1
  757. package/dist/observability/OtlpMetrics.d.ts.map +1 -1
  758. package/dist/observability/OtlpMetrics.js +5 -3
  759. package/dist/observability/OtlpMetrics.js.map +1 -1
  760. package/dist/observability/OtlpProxy.d.ts +154 -0
  761. package/dist/observability/OtlpProxy.d.ts.map +1 -0
  762. package/dist/observability/OtlpProxy.js +235 -0
  763. package/dist/observability/OtlpProxy.js.map +1 -0
  764. package/dist/observability/OtlpResource.d.ts +3 -1
  765. package/dist/observability/OtlpResource.d.ts.map +1 -1
  766. package/dist/observability/OtlpResource.js +11 -4
  767. package/dist/observability/OtlpResource.js.map +1 -1
  768. package/dist/observability/OtlpSerialization.d.ts +5 -0
  769. package/dist/observability/OtlpSerialization.d.ts.map +1 -1
  770. package/dist/observability/OtlpSerialization.js +14 -3
  771. package/dist/observability/OtlpSerialization.js.map +1 -1
  772. package/dist/observability/OtlpTracer.d.ts.map +1 -1
  773. package/dist/observability/OtlpTracer.js +4 -0
  774. package/dist/observability/OtlpTracer.js.map +1 -1
  775. package/dist/observability/index.d.ts +5 -0
  776. package/dist/observability/index.d.ts.map +1 -1
  777. package/dist/observability/index.js +5 -0
  778. package/dist/observability/index.js.map +1 -1
  779. package/dist/observability/internal/protobuf.d.ts +0 -9
  780. package/dist/observability/internal/protobuf.d.ts.map +1 -1
  781. package/dist/observability/internal/protobuf.js +2 -10
  782. package/dist/observability/internal/protobuf.js.map +1 -1
  783. package/dist/persistence/CircuitBreaker.d.ts +897 -0
  784. package/dist/persistence/CircuitBreaker.d.ts.map +1 -0
  785. package/dist/persistence/CircuitBreaker.js +1165 -0
  786. package/dist/persistence/CircuitBreaker.js.map +1 -0
  787. package/dist/persistence/PersistedCache.d.ts.map +1 -1
  788. package/dist/persistence/PersistedCache.js +1 -1
  789. package/dist/persistence/PersistedCache.js.map +1 -1
  790. package/dist/persistence/PersistedQueue.d.ts +6 -2
  791. package/dist/persistence/PersistedQueue.d.ts.map +1 -1
  792. package/dist/persistence/PersistedQueue.js +162 -84
  793. package/dist/persistence/PersistedQueue.js.map +1 -1
  794. package/dist/persistence/Persistence.d.ts +28 -0
  795. package/dist/persistence/Persistence.d.ts.map +1 -1
  796. package/dist/persistence/Persistence.js +36 -8
  797. package/dist/persistence/Persistence.js.map +1 -1
  798. package/dist/persistence/RateLimiter.d.ts.map +1 -1
  799. package/dist/persistence/RateLimiter.js +8 -12
  800. package/dist/persistence/RateLimiter.js.map +1 -1
  801. package/dist/persistence/Redis.d.ts +78 -2
  802. package/dist/persistence/Redis.d.ts.map +1 -1
  803. package/dist/persistence/Redis.js +62 -7
  804. package/dist/persistence/Redis.js.map +1 -1
  805. package/dist/persistence/UserDirectories.d.ts +129 -0
  806. package/dist/persistence/UserDirectories.d.ts.map +1 -0
  807. package/dist/persistence/UserDirectories.js +178 -0
  808. package/dist/persistence/UserDirectories.js.map +1 -0
  809. package/dist/persistence/index.d.ts +10 -0
  810. package/dist/persistence/index.d.ts.map +1 -1
  811. package/dist/persistence/index.js +10 -0
  812. package/dist/persistence/index.js.map +1 -1
  813. package/dist/process/ChildProcess.d.ts +32 -5
  814. package/dist/process/ChildProcess.d.ts.map +1 -1
  815. package/dist/process/ChildProcess.js.map +1 -1
  816. package/dist/process/ChildProcessSpawner.d.ts +30 -0
  817. package/dist/process/ChildProcessSpawner.d.ts.map +1 -1
  818. package/dist/process/ChildProcessSpawner.js +5 -2
  819. package/dist/process/ChildProcessSpawner.js.map +1 -1
  820. package/dist/reactivity/AsyncResult.d.ts +1 -1
  821. package/dist/reactivity/AsyncResult.d.ts.map +1 -1
  822. package/dist/reactivity/AsyncResult.js +1 -1
  823. package/dist/reactivity/AsyncResult.js.map +1 -1
  824. package/dist/reactivity/Atom.d.ts +69 -30
  825. package/dist/reactivity/Atom.d.ts.map +1 -1
  826. package/dist/reactivity/Atom.js +40 -15
  827. package/dist/reactivity/Atom.js.map +1 -1
  828. package/dist/reactivity/AtomHttpApi.d.ts +5 -5
  829. package/dist/reactivity/AtomHttpApi.d.ts.map +1 -1
  830. package/dist/reactivity/AtomHttpApi.js +1 -1
  831. package/dist/reactivity/AtomHttpApi.js.map +1 -1
  832. package/dist/reactivity/AtomRegistry.d.ts +2 -2
  833. package/dist/reactivity/AtomRegistry.d.ts.map +1 -1
  834. package/dist/reactivity/AtomRegistry.js +44 -9
  835. package/dist/reactivity/AtomRegistry.js.map +1 -1
  836. package/dist/reactivity/AtomRpc.d.ts +3 -3
  837. package/dist/reactivity/AtomRpc.d.ts.map +1 -1
  838. package/dist/reactivity/AtomRpc.js +1 -1
  839. package/dist/reactivity/AtomRpc.js.map +1 -1
  840. package/dist/reactivity/Hydration.d.ts.map +1 -1
  841. package/dist/reactivity/Hydration.js +46 -12
  842. package/dist/reactivity/Hydration.js.map +1 -1
  843. package/dist/reactivity/Reactivity.d.ts +71 -7
  844. package/dist/reactivity/Reactivity.d.ts.map +1 -1
  845. package/dist/reactivity/Reactivity.js +21 -12
  846. package/dist/reactivity/Reactivity.js.map +1 -1
  847. package/dist/rpc/Rpc.d.ts +18 -0
  848. package/dist/rpc/Rpc.d.ts.map +1 -1
  849. package/dist/rpc/Rpc.js +20 -0
  850. package/dist/rpc/Rpc.js.map +1 -1
  851. package/dist/rpc/RpcClient.d.ts +26 -2
  852. package/dist/rpc/RpcClient.d.ts.map +1 -1
  853. package/dist/rpc/RpcClient.js +198 -61
  854. package/dist/rpc/RpcClient.js.map +1 -1
  855. package/dist/rpc/RpcSerialization.d.ts +29 -0
  856. package/dist/rpc/RpcSerialization.d.ts.map +1 -1
  857. package/dist/rpc/RpcSerialization.js +41 -13
  858. package/dist/rpc/RpcSerialization.js.map +1 -1
  859. package/dist/rpc/RpcServer.d.ts.map +1 -1
  860. package/dist/rpc/RpcServer.js +20 -19
  861. package/dist/rpc/RpcServer.js.map +1 -1
  862. package/dist/rpc/RpcTest.d.ts +1 -0
  863. package/dist/rpc/RpcTest.d.ts.map +1 -1
  864. package/dist/rpc/RpcTest.js +1 -0
  865. package/dist/rpc/RpcTest.js.map +1 -1
  866. package/dist/schema/Model.d.ts +1 -1
  867. package/dist/schema/VariantSchema.d.ts +22 -3
  868. package/dist/schema/VariantSchema.d.ts.map +1 -1
  869. package/dist/schema/VariantSchema.js +32 -18
  870. package/dist/schema/VariantSchema.js.map +1 -1
  871. package/dist/socket/Socket.d.ts +23 -1
  872. package/dist/socket/Socket.d.ts.map +1 -1
  873. package/dist/socket/Socket.js +36 -3
  874. package/dist/socket/Socket.js.map +1 -1
  875. package/dist/sql/Migrator.d.ts +2 -1
  876. package/dist/sql/Migrator.d.ts.map +1 -1
  877. package/dist/sql/Migrator.js +21 -6
  878. package/dist/sql/Migrator.js.map +1 -1
  879. package/dist/sql/SqlClient.d.ts +148 -5
  880. package/dist/sql/SqlClient.d.ts.map +1 -1
  881. package/dist/sql/SqlClient.js +155 -27
  882. package/dist/sql/SqlClient.js.map +1 -1
  883. package/dist/sql/SqlResolver.d.ts +13 -0
  884. package/dist/sql/SqlResolver.d.ts.map +1 -1
  885. package/dist/sql/SqlResolver.js +27 -4
  886. package/dist/sql/SqlResolver.js.map +1 -1
  887. package/dist/sql/Statement.d.ts +10 -1
  888. package/dist/sql/Statement.d.ts.map +1 -1
  889. package/dist/sql/Statement.js +45 -7
  890. package/dist/sql/Statement.js.map +1 -1
  891. package/dist/testing/TestClock.d.ts.map +1 -1
  892. package/dist/testing/TestClock.js +4 -2
  893. package/dist/testing/TestClock.js.map +1 -1
  894. package/dist/testing/TestSchema.d.ts +7 -1
  895. package/dist/testing/TestSchema.d.ts.map +1 -1
  896. package/dist/testing/TestSchema.js +9 -3
  897. package/dist/testing/TestSchema.js.map +1 -1
  898. package/dist/workflow/DurableDeferred.d.ts.map +1 -1
  899. package/dist/workflow/DurableDeferred.js +21 -2
  900. package/dist/workflow/DurableDeferred.js.map +1 -1
  901. package/dist/workflow/WorkflowEngine.d.ts.map +1 -1
  902. package/dist/workflow/WorkflowEngine.js +18 -4
  903. package/dist/workflow/WorkflowEngine.js.map +1 -1
  904. package/package.json +13 -3
  905. package/src/Arbitrary.ts +10 -2
  906. package/src/Array.ts +128 -55
  907. package/src/Bytes.ts +111 -0
  908. package/src/Channel.ts +308 -452
  909. package/src/ChannelSchema.ts +1 -49
  910. package/src/Chunk.ts +55 -61
  911. package/src/Config.ts +12 -86
  912. package/src/ConfigProvider.ts +2 -1
  913. package/src/Cron.ts +6 -3
  914. package/src/Data.ts +60 -265
  915. package/src/Duration.ts +66 -16
  916. package/src/Effect.ts +503 -168
  917. package/src/Equal.ts +8 -1
  918. package/src/Equivalence.ts +7 -4
  919. package/src/Exit.ts +27 -12
  920. package/src/FiberHandle.ts +10 -9
  921. package/src/FiberMap.ts +13 -66
  922. package/src/FileSystem.ts +10 -0
  923. package/src/Formatter.ts +28 -13
  924. package/src/Graph.ts +171 -1263
  925. package/src/Hash.ts +4 -1
  926. package/src/HashSet.ts +0 -60
  927. package/src/Iterable.ts +15 -14
  928. package/src/JsonPatch.ts +4 -0
  929. package/src/JsonSchema.ts +40 -43
  930. package/src/Layer.ts +2 -2
  931. package/src/ManagedRuntime.ts +72 -6
  932. package/src/Metric.ts +252 -510
  933. package/src/MutableHashMap.ts +4 -473
  934. package/src/MutableList.ts +7 -5
  935. package/src/MutableRef.ts +8 -1
  936. package/src/Number.ts +2 -2
  937. package/src/Optic.ts +17 -332
  938. package/src/PartitionedSemaphore.ts +24 -13
  939. package/src/Path.ts +9 -1
  940. package/src/Pool.ts +109 -37
  941. package/src/PubSub.ts +17 -13
  942. package/src/Queue.ts +5 -37
  943. package/src/Random.ts +1 -1
  944. package/src/RcMap.ts +14 -8
  945. package/src/Record.ts +51 -0
  946. package/src/Ref.ts +15 -104
  947. package/src/References.ts +5 -4
  948. package/src/RequestResolver.ts +46 -87
  949. package/src/Resource.ts +1 -1
  950. package/src/Runtime.ts +19 -18
  951. package/src/Schedule.ts +3 -95
  952. package/src/Schema.ts +639 -381
  953. package/src/SchemaAST.ts +40 -29
  954. package/src/SchemaGetter.ts +22 -5
  955. package/src/SchemaIssue.ts +44 -53
  956. package/src/SchemaParser.ts +51 -18
  957. package/src/SchemaRepresentation.ts +95 -35
  958. package/src/SchemaTransformation.ts +10 -3
  959. package/src/Scope.ts +12 -2
  960. package/src/ScopedCache.ts +17 -142
  961. package/src/SemVer.ts +1528 -0
  962. package/src/SemVerRange.ts +883 -0
  963. package/src/Semaphore.ts +67 -40
  964. package/src/Sink.ts +21 -4
  965. package/src/Stream.ts +367 -1027
  966. package/src/String.ts +11 -8
  967. package/src/TextDiff.ts +766 -0
  968. package/src/Tracer.ts +15 -1
  969. package/src/TxHashMap.ts +1 -103
  970. package/src/TxHashSet.ts +48 -753
  971. package/src/ai/AiError.ts +66 -4
  972. package/src/ai/Chat.ts +10 -5
  973. package/src/ai/Decision.ts +49 -1
  974. package/src/ai/DecisionModel.ts +264 -108
  975. package/src/ai/EmbeddingModel.ts +25 -13
  976. package/src/ai/LanguageModel.ts +9 -0
  977. package/src/ai/McpClient.ts +1211 -0
  978. package/src/ai/McpClientError.ts +329 -0
  979. package/src/ai/McpProtocol.ts +2 -2
  980. package/src/ai/McpSchema.ts +153 -35
  981. package/src/ai/McpServer.ts +231 -233
  982. package/src/ai/Prompt.ts +114 -35
  983. package/src/ai/Response.ts +220 -65
  984. package/src/ai/Tool.ts +50 -6
  985. package/src/ai/Toolkit.ts +82 -11
  986. package/src/ai/index.ts +12 -0
  987. package/src/ai/internal/mcpCore.ts +13 -14
  988. package/src/ai/internal/mcpProtocol/v2024_11_05.ts +1 -1
  989. package/src/ai/internal/mcpProtocol/v2025_03_26.ts +1 -1
  990. package/src/ai/internal/mcpProtocol/v2025_06_18.ts +3 -3
  991. package/src/ai/internal/mcpProtocol/v2025_11_25.ts +3 -3
  992. package/src/ai/internal/mcpProtocol/v2026_07_28.ts +12 -14
  993. package/src/ai/internal/mcpProtocol.ts +22 -2
  994. package/src/ai/internal/mcpRuntime.ts +3 -4
  995. package/src/ai/internal/mcpSchema/v2024_11_05.ts +20 -13
  996. package/src/ai/internal/mcpSchema/v2025_03_26.ts +4 -2
  997. package/src/ai/internal/mcpSchema/v2025_06_18.ts +7 -7
  998. package/src/ai/internal/mcpSchema/v2025_11_25.ts +8 -8
  999. package/src/ai/internal/mcpSchema/v2026_07_28.ts +44 -42
  1000. package/src/cli/Argument.ts +15 -0
  1001. package/src/cli/CliError.ts +136 -4
  1002. package/src/cli/CliOutput.ts +183 -6
  1003. package/src/cli/Command.ts +367 -48
  1004. package/src/cli/Completions.ts +56 -0
  1005. package/src/cli/Flag.ts +132 -0
  1006. package/src/cli/GlobalFlag.ts +5 -6
  1007. package/src/cli/Param.ts +151 -6
  1008. package/src/cli/TerminalCapabilities.ts +159 -0
  1009. package/src/cli/index.ts +6 -0
  1010. package/src/cli/internal/command.ts +8 -3
  1011. package/src/cli/internal/completions/bash.ts +83 -32
  1012. package/src/cli/internal/completions/descriptor.ts +11 -1
  1013. package/src/cli/internal/completions/fish.ts +10 -8
  1014. package/src/cli/internal/completions/powershell.ts +23 -14
  1015. package/src/cli/internal/completions/zsh.ts +8 -5
  1016. package/src/cli/internal/formatter.ts +18 -0
  1017. package/src/cli/internal/lexer.ts +12 -5
  1018. package/src/cli/internal/parser.ts +31 -11
  1019. package/src/cluster/ClusterCron.ts +94 -35
  1020. package/src/cluster/ClusterMetrics.ts +149 -7
  1021. package/src/cluster/ClusterWorkflowEngine.ts +130 -57
  1022. package/src/cluster/Entity.ts +4 -0
  1023. package/src/cluster/MessageStorage.ts +26 -14
  1024. package/src/cluster/Runners.ts +76 -25
  1025. package/src/cluster/Sharding.ts +200 -58
  1026. package/src/cluster/ShardingConfig.ts +20 -0
  1027. package/src/cluster/Snowflake.ts +3 -7
  1028. package/src/cluster/SqlMessageStorage.ts +58 -55
  1029. package/src/cluster/SqlRunnerStorage.ts +120 -51
  1030. package/src/cluster/internal/entityManager.ts +155 -32
  1031. package/src/devtools/DevTools.ts +3 -2
  1032. package/src/devtools/DevToolsClient.ts +29 -10
  1033. package/src/encoding/Base64.ts +38 -0
  1034. package/src/encoding/Base64Url.ts +31 -0
  1035. package/src/encoding/Ini.ts +3 -0
  1036. package/src/encoding/JsonArray.ts +849 -0
  1037. package/src/encoding/Ndjson.ts +211 -20
  1038. package/src/encoding/SchemaBinary.ts +14 -48
  1039. package/src/encoding/Sse.ts +4 -3
  1040. package/src/encoding/Tar.ts +1417 -0
  1041. package/src/encoding/Toml.ts +36 -19
  1042. package/src/encoding/Xml.ts +2037 -0
  1043. package/src/encoding/Yaml.ts +108 -36
  1044. package/src/encoding/Zip.ts +1558 -0
  1045. package/src/encoding/index.ts +24 -0
  1046. package/src/eventlog/EventJournal.ts +611 -227
  1047. package/src/eventlog/EventLog.ts +496 -196
  1048. package/src/eventlog/EventLogEncryption.ts +128 -43
  1049. package/src/eventlog/EventLogMessage.ts +62 -11
  1050. package/src/eventlog/EventLogRemote.ts +77 -21
  1051. package/src/eventlog/EventLogServer.ts +162 -20
  1052. package/src/eventlog/EventLogServerEncrypted.ts +121 -80
  1053. package/src/eventlog/EventLogServerUnencrypted.ts +180 -77
  1054. package/src/eventlog/EventRow.ts +706 -0
  1055. package/src/eventlog/SqlEventJournal.ts +496 -193
  1056. package/src/eventlog/SqlEventLogServerEncrypted.ts +212 -83
  1057. package/src/eventlog/SqlEventLogServerUnencrypted.ts +141 -62
  1058. package/src/eventlog/index.ts +6 -0
  1059. package/src/eventlog/internal/conflicts.ts +119 -0
  1060. package/src/graphql/GraphQLClientError.ts +5 -12
  1061. package/src/graphql/GraphQLProtocol.ts +12 -9
  1062. package/src/graphql/GraphQLResolver.ts +90 -239
  1063. package/src/http/Cookies.ts +10 -11
  1064. package/src/http/FetchHttpClient.ts +56 -6
  1065. package/src/http/FindMyWay/internal/router.ts +11 -0
  1066. package/src/http/Headers.ts +337 -154
  1067. package/src/http/HttpClient.ts +673 -142
  1068. package/src/http/HttpClientError.ts +35 -1
  1069. package/src/http/HttpClientRequest.ts +151 -5
  1070. package/src/http/HttpClientResponse.ts +71 -0
  1071. package/src/http/HttpEffect.ts +25 -33
  1072. package/src/http/HttpIncomingMessage.ts +3 -23
  1073. package/src/http/HttpMiddleware.ts +194 -40
  1074. package/src/http/HttpRouter.ts +10 -3
  1075. package/src/http/HttpServerError.ts +8 -5
  1076. package/src/http/HttpServerRequest.ts +172 -27
  1077. package/src/http/HttpServerResponse.ts +49 -23
  1078. package/src/http/HttpStaticServer.ts +71 -26
  1079. package/src/http/MultipartParser/internal/contentType.ts +109 -8
  1080. package/src/http/MultipartParser/internal/headers.ts +4 -16
  1081. package/src/http/MultipartParser/internal/multipart.ts +10 -32
  1082. package/src/http/Url.ts +6 -1
  1083. package/src/http/UrlParams.ts +6 -1
  1084. package/src/http/internal/compression.ts +4 -5
  1085. package/src/http/internal/decompression.ts +32 -17
  1086. package/src/http/internal/httpBody.ts +10 -2
  1087. package/src/http/internal/lazyStream.ts +25 -0
  1088. package/src/http/internal/requestState.ts +33 -0
  1089. package/src/http/internal/urlParams.ts +29 -0
  1090. package/src/http/internal/webResponse.ts +20 -0
  1091. package/src/http-api/HttpApi.ts +4 -7
  1092. package/src/http-api/HttpApiBuilder.ts +190 -32
  1093. package/src/http-api/HttpApiClient.ts +364 -90
  1094. package/src/http-api/HttpApiEndpoint.ts +248 -46
  1095. package/src/http-api/HttpApiError.ts +55 -0
  1096. package/src/http-api/HttpApiScalar.ts +4 -3
  1097. package/src/http-api/HttpApiSchema.ts +373 -18
  1098. package/src/http-api/HttpApiSwagger.ts +11 -4
  1099. package/src/http-api/HttpApiTest.ts +36 -11
  1100. package/src/http-api/OpenApi.ts +103 -58
  1101. package/src/http-api/internal/path.ts +40 -12
  1102. package/src/http-api/internal/toCodecHttpProperties.ts +56 -0
  1103. package/src/index.ts +24 -0
  1104. package/src/internal/arbitrary/runner.ts +133 -36
  1105. package/src/internal/core.ts +3 -1
  1106. package/src/internal/dateTime.ts +20 -7
  1107. package/src/internal/effect.ts +144 -100
  1108. package/src/internal/equal.ts +17 -0
  1109. package/src/internal/hashMap.ts +2 -2
  1110. package/src/internal/hydration.ts +15 -0
  1111. package/src/internal/inflate.ts +710 -0
  1112. package/src/internal/jsonSchema.ts +27 -0
  1113. package/src/internal/matcher.ts +1 -1
  1114. package/src/internal/record.ts +6 -0
  1115. package/src/internal/request.ts +21 -6
  1116. package/src/internal/schedule.ts +20 -39
  1117. package/src/internal/schema/compilerRegistry.ts +6 -1
  1118. package/src/internal/schema/content.ts +18 -0
  1119. package/src/internal/schema/fromJsonSchemaDocument.ts +458 -351
  1120. package/src/internal/schema/fromRepresentation.ts +2 -1
  1121. package/src/internal/schema/interpreter.ts +58 -45
  1122. package/src/internal/schema/standardSchema.ts +34 -32
  1123. package/src/internal/schema/toCodeDocument.ts +12 -7
  1124. package/src/internal/schema/toCodec.ts +134 -15
  1125. package/src/internal/schema/toFormatter.ts +6 -6
  1126. package/src/internal/schema/toJsonSchemaDocument.ts +246 -194
  1127. package/src/internal/schema/toRepresentation.ts +122 -140
  1128. package/src/internal/sql.ts +14 -0
  1129. package/src/internal/trie.ts +1 -3
  1130. package/src/internal/uuid.ts +15 -10
  1131. package/src/internal/version.ts +1 -1
  1132. package/src/net/NetAddress.ts +2 -9
  1133. package/src/observability/OtlpExporter.ts +5 -12
  1134. package/src/observability/OtlpMetrics.ts +5 -3
  1135. package/src/observability/OtlpProxy.ts +314 -0
  1136. package/src/observability/OtlpResource.ts +16 -6
  1137. package/src/observability/OtlpSerialization.ts +17 -3
  1138. package/src/observability/OtlpTracer.ts +4 -0
  1139. package/src/observability/index.ts +6 -0
  1140. package/src/observability/internal/protobuf.ts +2 -10
  1141. package/src/persistence/CircuitBreaker.ts +1678 -0
  1142. package/src/persistence/PersistedCache.ts +3 -1
  1143. package/src/persistence/PersistedQueue.ts +223 -153
  1144. package/src/persistence/Persistence.ts +64 -30
  1145. package/src/persistence/RateLimiter.ts +18 -21
  1146. package/src/persistence/Redis.ts +129 -8
  1147. package/src/persistence/UserDirectories.ts +273 -0
  1148. package/src/persistence/index.ts +12 -0
  1149. package/src/process/ChildProcess.ts +32 -5
  1150. package/src/process/ChildProcessSpawner.ts +41 -2
  1151. package/src/reactivity/AsyncResult.ts +5 -39
  1152. package/src/reactivity/Atom.ts +134 -166
  1153. package/src/reactivity/AtomHttpApi.ts +10 -16
  1154. package/src/reactivity/AtomRegistry.ts +50 -29
  1155. package/src/reactivity/AtomRpc.ts +6 -22
  1156. package/src/reactivity/Hydration.ts +53 -12
  1157. package/src/reactivity/Reactivity.ts +97 -39
  1158. package/src/rpc/Rpc.ts +21 -0
  1159. package/src/rpc/RpcClient.ts +283 -104
  1160. package/src/rpc/RpcSerialization.ts +53 -14
  1161. package/src/rpc/RpcServer.ts +27 -21
  1162. package/src/rpc/RpcTest.ts +3 -0
  1163. package/src/schema/VariantSchema.ts +86 -22
  1164. package/src/socket/Socket.ts +45 -20
  1165. package/src/sql/Migrator.ts +26 -11
  1166. package/src/sql/SqlClient.ts +273 -29
  1167. package/src/sql/SqlResolver.ts +32 -9
  1168. package/src/sql/Statement.ts +65 -10
  1169. package/src/testing/TestClock.ts +4 -1
  1170. package/src/testing/TestSchema.ts +9 -3
  1171. package/src/workflow/DurableDeferred.ts +23 -6
  1172. package/src/workflow/WorkflowEngine.ts +34 -10
  1173. package/dist/http/internal/preResponseHandler.d.ts +0 -2
  1174. package/dist/http/internal/preResponseHandler.d.ts.map +0 -1
  1175. package/dist/http/internal/preResponseHandler.js +0 -14
  1176. package/dist/http/internal/preResponseHandler.js.map +0 -1
  1177. package/src/http/internal/preResponseHandler.ts +0 -19
package/src/Stream.ts CHANGED
@@ -823,8 +823,13 @@ export const sync = <A>(evaluate: LazyArg<A>): Stream<A> => fromChannel(Channel.
823
823
  * @category constructors
824
824
  * @since 2.0.0
825
825
  */
826
- export const suspend = <A, E, R>(stream: LazyArg<Stream<A, E, R>>): Stream<A, E, R> =>
827
- fromChannel(Channel.suspend(() => stream().channel))
826
+ export const suspend = <A, E, R>(stream: LazyArg<Stream<A, E, R>>): Stream<A, E, R> => {
827
+ const suspended = fromChannel(Channel.suspend(() => stream().channel))
828
+ suspendedStreams.set(suspended, stream)
829
+ return suspended
830
+ }
831
+
832
+ const suspendedStreams = new WeakMap<Stream<any, any, any>, LazyArg<Stream<any, any, any>>>()
828
833
 
829
834
  /**
830
835
  * Terminates with the specified error.
@@ -1259,9 +1264,10 @@ export const fromPubSubTake = <A, E>(pubsub: PubSub.PubSub<Take.Take<A, E>>): St
1259
1264
  *
1260
1265
  * **Details**
1261
1266
  *
1262
- * The stream reads from a `ReadableStreamDefaultReader`, maps read failures
1263
- * with `onError`, and closes the reader when the stream finalizes. By default
1264
- * the reader is canceled; set `releaseLockOnEnd` to release the lock instead.
1267
+ * The stream reads from a `ReadableStreamDefaultReader` and maps read failures
1268
+ * with `onError`. Finalization cancels the reader and releases its lock, or
1269
+ * only releases the lock when `releaseLockOnEnd` is set. A rejected cancel
1270
+ * hook becomes a defect.
1265
1271
  *
1266
1272
  * **Example** (Creating a stream from a ReadableStream)
1267
1273
  *
@@ -1433,6 +1439,11 @@ export interface EventListener<A = unknown> {
1433
1439
  /**
1434
1440
  * Creates a stream from an event listener.
1435
1441
  *
1442
+ * **Gotchas**
1443
+ *
1444
+ * Event listeners cannot backpressure the source. When a bounded `bufferSize`
1445
+ * is full, additional events are dropped rather than suspending the listener.
1446
+ *
1436
1447
  * **Example** (Creating a stream from an event listener)
1437
1448
  *
1438
1449
  * ```ts import.meta.vitest
@@ -1882,6 +1893,11 @@ export const as: {
1882
1893
  /**
1883
1894
  * Maps both the failure and success channels of a stream.
1884
1895
  *
1896
+ * **Details**
1897
+ *
1898
+ * Maps every typed error in the cause, preserving defects, interrupts and
1899
+ * reason order. Unlike typed recovery, mapping does not convert errors to defects.
1900
+ *
1885
1901
  * **Example** (Mapping both the failure and success channels of a stream)
1886
1902
  *
1887
1903
  * ```ts import.meta.vitest
@@ -1918,6 +1934,11 @@ export const mapBoth: {
1918
1934
  /**
1919
1935
  * Maps both the failure and success channels of a stream.
1920
1936
  *
1937
+ * **Details**
1938
+ *
1939
+ * Maps every typed error in the cause, preserving defects, interrupts and
1940
+ * reason order. Unlike typed recovery, mapping does not convert errors to defects.
1941
+ *
1921
1942
  * **Example** (Mapping both the failure and success channels of a stream)
1922
1943
  *
1923
1944
  * ```ts import.meta.vitest
@@ -1956,6 +1977,11 @@ export const mapBoth: {
1956
1977
  /**
1957
1978
  * Maps both the failure and success channels of a stream.
1958
1979
  *
1980
+ * **Details**
1981
+ *
1982
+ * Maps every typed error in the cause, preserving defects, interrupts and
1983
+ * reason order. Unlike typed recovery, mapping does not convert errors to defects.
1984
+ *
1959
1985
  * **Example** (Mapping both the failure and success channels of a stream)
1960
1986
  *
1961
1987
  * ```ts import.meta.vitest
@@ -3924,70 +3950,7 @@ export const concat: {
3924
3950
  2,
3925
3951
  <A, E, R, A2, E2, R2>(self: Stream<A, E, R>, that: Stream<A2, E2, R2>): Stream<A | A2, E | E2, R | R2> => {
3926
3952
  const stream = fromChannel(
3927
- Channel.flatten(Channel.fromIterator(() => concatChannels</**
3928
- * Concatenates two streams, emitting all elements from the first stream
3929
- * followed by all elements from the second stream.
3930
- *
3931
- * **Example** (Concatenating streams)
3932
- *
3933
- * ```ts import.meta.vitest
3934
- * import { Effect, Stream } from "effect"
3935
- *
3936
- * const stream = Stream.concat(Stream.make(1, 2, 3), Stream.make(4, 5, 6))
3937
- *
3938
- * await Effect.runPromise(Effect.gen(function*() {
3939
- * const values = yield* Stream.runCollect(stream)
3940
- * values // => [ 1, 2, 3, 4, 5, 6 ]
3941
- * }))
3942
- * ```
3943
- *
3944
- * @stability stable
3945
- * @category sequencing
3946
- * @since 2.0.0
3947
- */
3948
- A | A2, /**
3949
- * Concatenates two streams, emitting all elements from the first stream
3950
- * followed by all elements from the second stream.
3951
- *
3952
- * **Example** (Concatenating streams)
3953
- *
3954
- * ```ts import.meta.vitest
3955
- * import { Effect, Stream } from "effect"
3956
- *
3957
- * const stream = Stream.concat(Stream.make(1, 2, 3), Stream.make(4, 5, 6))
3958
- *
3959
- * await Effect.runPromise(Effect.gen(function*() {
3960
- * const values = yield* Stream.runCollect(stream)
3961
- * values // => [ 1, 2, 3, 4, 5, 6 ]
3962
- * }))
3963
- * ```
3964
- *
3965
- * @stability stable
3966
- * @category sequencing
3967
- * @since 2.0.0
3968
- */
3969
- E | E2, /**
3970
- * Concatenates two streams, emitting all elements from the first stream
3971
- * followed by all elements from the second stream.
3972
- *
3973
- * **Example** (Concatenating streams)
3974
- *
3975
- * ```ts import.meta.vitest
3976
- * import { Effect, Stream } from "effect"
3977
- *
3978
- * const stream = Stream.concat(Stream.make(1, 2, 3), Stream.make(4, 5, 6))
3979
- *
3980
- * await Effect.runPromise(Effect.gen(function*() {
3981
- * const values = yield* Stream.runCollect(stream)
3982
- * values // => [ 1, 2, 3, 4, 5, 6 ]
3983
- * }))
3984
- * ```
3985
- *
3986
- * @stability stable
3987
- * @category sequencing
3988
- * @since 2.0.0
3989
- */
3990
- R | R2>(self, that)))
3953
+ Channel.flatten(Channel.fromIterator(() => concatChannels<A | A2, E | E2, R | R2>(self, that)))
3991
3954
  )
3992
3955
  concatParts.set(stream, [self, that])
3993
3956
  return stream
@@ -3998,14 +3961,30 @@ export const concat: {
3998
3961
  // a single layer instead of one layer per call
3999
3962
  const concatParts = new WeakMap<Stream<any, any, any>, readonly [Stream<any, any, any>, Stream<any, any, any>]>()
4000
3963
 
4001
- // Yields the channel of each non-`concat` stream in a chain, in order
3964
+ // Yields the channel of each non-`concat` stream in a chain, in order. A
3965
+ // `suspend` part is evaluated when it is reached and its result joins the chain
4002
3966
  function* concatChannels<A, E, R>(self: Stream<A, E, R>, that: Stream<A, E, R>) {
4003
3967
  const stack = [that, self]
4004
3968
  while (stack.length > 0) {
4005
3969
  const stream = stack.pop()!
4006
3970
  const parts = concatParts.get(stream)
4007
- if (parts === undefined) yield stream.channel
4008
- else stack.push(parts[1], parts[0])
3971
+ if (parts !== undefined) {
3972
+ stack.push(parts[1], parts[0])
3973
+ continue
3974
+ }
3975
+ const evaluate = suspendedStreams.get(stream)
3976
+ if (evaluate === undefined) {
3977
+ yield stream.channel
3978
+ continue
3979
+ }
3980
+ // Evaluated here rather than in an effect, so retrying an interrupted pull
3981
+ // cannot evaluate it twice. `Channel.empty` keeps a yield point
3982
+ try {
3983
+ stack.push(evaluate())
3984
+ } catch (defect) {
3985
+ stack.push(die(defect))
3986
+ }
3987
+ yield Channel.empty
4009
3988
  }
4010
3989
  }
4011
3990
 
@@ -5104,24 +5083,23 @@ export const zipWith: {
5104
5083
  left: Stream<AL, EL, RL>,
5105
5084
  right: Stream<AR, ER, RR>,
5106
5085
  f: (left: AL, right: AR) => A
5107
- ): Stream<A, EL | ER, RL | RR> => zipWithArray(left, right, zipArrays(f)))
5108
-
5109
- const zipArrays = <AL, AR, A>(
5110
- f: (left: AL, right: AR) => A
5111
- ) =>
5112
- (
5113
- leftArr: Arr.NonEmptyReadonlyArray<AL>,
5114
- rightArr: Arr.NonEmptyReadonlyArray<AR>
5115
- ) => {
5116
- const minLength = Math.min(leftArr.length, rightArr.length)
5117
- const result: Arr.NonEmptyArray<A> = [] as any
5118
-
5119
- for (let i = 0; i < minLength; i++) {
5120
- result.push(f(leftArr[i], rightArr[i]))
5121
- }
5122
-
5123
- return [result, leftArr.slice(minLength), rightArr.slice(minLength)] as const
5124
- }
5086
+ ): Stream<A, EL | ER, RL | RR> =>
5087
+ suspend(() => {
5088
+ // Track consumed elements with cursors instead of slicing leftovers
5089
+ let leftIndex = 0
5090
+ let rightIndex = 0
5091
+ return zipWithArray(left, right, (leftArr, rightArr) => {
5092
+ const length = Math.min(leftArr.length - leftIndex, rightArr.length - rightIndex)
5093
+ const output = Arr.makeBy(length, (i) => f(leftArr[leftIndex + i], rightArr[rightIndex + i]))
5094
+ leftIndex += length
5095
+ rightIndex += length
5096
+ const leftDone = leftIndex === leftArr.length
5097
+ const rightDone = rightIndex === rightArr.length
5098
+ if (leftDone) leftIndex = 0
5099
+ if (rightDone) rightIndex = 0
5100
+ return [output, leftDone ? [] : leftArr, rightDone ? [] : rightArr]
5101
+ })
5102
+ }))
5125
5103
 
5126
5104
  /**
5127
5105
  * Zips two streams by applying a function to non-empty arrays of elements.
@@ -5273,31 +5251,23 @@ export const zipWithArray: {
5273
5251
  ]
5274
5252
  })
5275
5253
 
5276
- type State =
5277
- | { _tag: "PullBoth" }
5278
- | { _tag: "PullLeft"; rightArray: Arr.NonEmptyReadonlyArray<AR> }
5279
- | { _tag: "PullRight"; leftArray: Arr.NonEmptyReadonlyArray<AL> }
5280
- let state: State = { _tag: "PullBoth" }
5254
+ let leftArray: Arr.NonEmptyReadonlyArray<AL> | undefined
5255
+ let rightArray: Arr.NonEmptyReadonlyArray<AR> | undefined
5281
5256
 
5282
5257
  const pull: Effect.Effect<
5283
5258
  Arr.NonEmptyReadonlyArray<A>,
5284
5259
  EL | ER | Cause.Done,
5285
5260
  RL | RR
5286
5261
  > = Effect.gen(function*() {
5287
- const [left, right] = state._tag === "PullBoth"
5288
- ? yield* pullBoth
5289
- : state._tag === "PullLeft"
5290
- ? [yield* pullLeft, state.rightArray]
5291
- : [state.leftArray, yield* pullRight]
5292
- const result = f(left, right)
5293
- if (Arr.isReadonlyArrayNonEmpty(result[1])) {
5294
- state = { _tag: "PullRight", leftArray: result[1] }
5295
- } else if (Arr.isReadonlyArrayNonEmpty(result[2])) {
5296
- state = { _tag: "PullLeft", rightArray: result[2] }
5297
- } else {
5298
- state = { _tag: "PullBoth" }
5299
- }
5300
- return result[0]
5262
+ const [left, right] = leftArray
5263
+ ? [leftArray, rightArray ?? (yield* pullRight)]
5264
+ : rightArray
5265
+ ? [yield* pullLeft, rightArray]
5266
+ : yield* pullBoth
5267
+ const [output, leftoverLeft, leftoverRight] = f(left, right)
5268
+ leftArray = Arr.isReadonlyArrayNonEmpty(leftoverLeft) ? leftoverLeft : undefined
5269
+ rightArray = Arr.isReadonlyArrayNonEmpty(leftoverRight) ? leftoverRight : undefined
5270
+ return output
5301
5271
  })
5302
5272
 
5303
5273
  return pull
@@ -5484,15 +5454,7 @@ export const zipLeft: {
5484
5454
  <AL, EL, RL, AR, ER, RR>(
5485
5455
  left: Stream<AL, EL, RL>,
5486
5456
  right: Stream<AR, ER, RR>
5487
- ): Stream<AL, EL | ER, RL | RR> =>
5488
- zipWithArray(left, right, (leftArr, rightArr) => {
5489
- const minLength = Math.min(leftArr.length, rightArr.length)
5490
- const output = leftArr.slice(0, minLength) as Arr.NonEmptyArray<AL>
5491
- const leftoverLeft = leftArr.slice(minLength)
5492
- const leftoverRight = rightArr.slice(minLength)
5493
-
5494
- return [output, leftoverLeft, leftoverRight] as const
5495
- })
5457
+ ): Stream<AL, EL | ER, RL | RR> => zipWith(left, right, (a) => a)
5496
5458
  )
5497
5459
 
5498
5460
  /**
@@ -5572,15 +5534,7 @@ export const zipRight: {
5572
5534
  <AL, EL, RL, AR, ER, RR>(
5573
5535
  left: Stream<AL, EL, RL>,
5574
5536
  right: Stream<AR, ER, RR>
5575
- ): Stream<AR, EL | ER, RL | RR> =>
5576
- zipWithArray(left, right, (leftArr, rightArr) => {
5577
- const minLength = Math.min(leftArr.length, rightArr.length)
5578
- const output = rightArr.slice(0, minLength) as Arr.NonEmptyArray<AR>
5579
- const leftoverLeft = leftArr.slice(minLength)
5580
- const leftoverRight = rightArr.slice(minLength)
5581
-
5582
- return [output, leftoverLeft, leftoverRight] as const
5583
- })
5537
+ ): Stream<AR, EL | ER, RL | RR> => zipWith(left, right, (_, a) => a)
5584
5538
  )
5585
5539
 
5586
5540
  /**
@@ -6832,144 +6786,8 @@ export const partitionQueue: {
6832
6786
  const scope = yield* Effect.scope
6833
6787
  const pull = yield* Channel.toPullScoped(self.channel, scope)
6834
6788
  const capacity = options?.capacity === "unbounded" ? undefined : options?.capacity ?? DefaultChunkSize
6835
- const passes = yield* Queue.make</**
6836
- * Partitions a stream using a `Filter` and exposes passing and failing values
6837
- * as scoped queues.
6838
- *
6839
- * **Details**
6840
- *
6841
- * The queues are backed by a fiber in the current scope and should be consumed
6842
- * while that scope remains open. Each queue fails with the stream error or
6843
- * `Cause.Done` when the source ends.
6844
- *
6845
- * **Example** (Partitioning a stream into queues)
6846
- *
6847
- * ```ts import.meta.vitest
6848
- * import { Effect, Result, Stream } from "effect"
6849
- *
6850
- * const program = Effect.gen(function*() {
6851
- * const [passes, fails] = yield* Stream.make(1, 2, 3, 4).pipe(
6852
- * Stream.partitionQueue((n) => n % 2 === 0 ? Result.succeed(n) : Result.fail(n))
6853
- * )
6854
- *
6855
- * const passValues = yield* Stream.fromQueue(passes).pipe(Stream.runCollect)
6856
- * const failValues = yield* Stream.fromQueue(fails).pipe(Stream.runCollect)
6857
- *
6858
- * passValues // => [ 2, 4 ]
6859
- * failValues // => [ 1, 3 ]
6860
- * })
6861
- *
6862
- * await Effect.runPromise(Effect.scoped(program))
6863
- * ```
6864
- *
6865
- * @stability stable
6866
- * @category filtering
6867
- * @since 4.0.0
6868
- */
6869
- Pass, /**
6870
- * Partitions a stream using a `Filter` and exposes passing and failing values
6871
- * as scoped queues.
6872
- *
6873
- * **Details**
6874
- *
6875
- * The queues are backed by a fiber in the current scope and should be consumed
6876
- * while that scope remains open. Each queue fails with the stream error or
6877
- * `Cause.Done` when the source ends.
6878
- *
6879
- * **Example** (Partitioning a stream into queues)
6880
- *
6881
- * ```ts import.meta.vitest
6882
- * import { Effect, Result, Stream } from "effect"
6883
- *
6884
- * const program = Effect.gen(function*() {
6885
- * const [passes, fails] = yield* Stream.make(1, 2, 3, 4).pipe(
6886
- * Stream.partitionQueue((n) => n % 2 === 0 ? Result.succeed(n) : Result.fail(n))
6887
- * )
6888
- *
6889
- * const passValues = yield* Stream.fromQueue(passes).pipe(Stream.runCollect)
6890
- * const failValues = yield* Stream.fromQueue(fails).pipe(Stream.runCollect)
6891
- *
6892
- * passValues // => [ 2, 4 ]
6893
- * failValues // => [ 1, 3 ]
6894
- * })
6895
- *
6896
- * await Effect.runPromise(Effect.scoped(program))
6897
- * ```
6898
- *
6899
- * @stability stable
6900
- * @category filtering
6901
- * @since 4.0.0
6902
- */
6903
- E | Cause.Done>({ capacity })
6904
- const fails = yield* Queue.make</**
6905
- * Partitions a stream using a `Filter` and exposes passing and failing values
6906
- * as scoped queues.
6907
- *
6908
- * **Details**
6909
- *
6910
- * The queues are backed by a fiber in the current scope and should be consumed
6911
- * while that scope remains open. Each queue fails with the stream error or
6912
- * `Cause.Done` when the source ends.
6913
- *
6914
- * **Example** (Partitioning a stream into queues)
6915
- *
6916
- * ```ts import.meta.vitest
6917
- * import { Effect, Result, Stream } from "effect"
6918
- *
6919
- * const program = Effect.gen(function*() {
6920
- * const [passes, fails] = yield* Stream.make(1, 2, 3, 4).pipe(
6921
- * Stream.partitionQueue((n) => n % 2 === 0 ? Result.succeed(n) : Result.fail(n))
6922
- * )
6923
- *
6924
- * const passValues = yield* Stream.fromQueue(passes).pipe(Stream.runCollect)
6925
- * const failValues = yield* Stream.fromQueue(fails).pipe(Stream.runCollect)
6926
- *
6927
- * passValues // => [ 2, 4 ]
6928
- * failValues // => [ 1, 3 ]
6929
- * })
6930
- *
6931
- * await Effect.runPromise(Effect.scoped(program))
6932
- * ```
6933
- *
6934
- * @stability stable
6935
- * @category filtering
6936
- * @since 4.0.0
6937
- */
6938
- Fail, /**
6939
- * Partitions a stream using a `Filter` and exposes passing and failing values
6940
- * as scoped queues.
6941
- *
6942
- * **Details**
6943
- *
6944
- * The queues are backed by a fiber in the current scope and should be consumed
6945
- * while that scope remains open. Each queue fails with the stream error or
6946
- * `Cause.Done` when the source ends.
6947
- *
6948
- * **Example** (Partitioning a stream into queues)
6949
- *
6950
- * ```ts import.meta.vitest
6951
- * import { Effect, Result, Stream } from "effect"
6952
- *
6953
- * const program = Effect.gen(function*() {
6954
- * const [passes, fails] = yield* Stream.make(1, 2, 3, 4).pipe(
6955
- * Stream.partitionQueue((n) => n % 2 === 0 ? Result.succeed(n) : Result.fail(n))
6956
- * )
6957
- *
6958
- * const passValues = yield* Stream.fromQueue(passes).pipe(Stream.runCollect)
6959
- * const failValues = yield* Stream.fromQueue(fails).pipe(Stream.runCollect)
6960
- *
6961
- * passValues // => [ 2, 4 ]
6962
- * failValues // => [ 1, 3 ]
6963
- * })
6964
- *
6965
- * await Effect.runPromise(Effect.scoped(program))
6966
- * ```
6967
- *
6968
- * @stability stable
6969
- * @category filtering
6970
- * @since 4.0.0
6971
- */
6972
- E | Cause.Done>({ capacity })
6789
+ const passes = yield* Queue.make<Pass, E | Cause.Done>({ capacity })
6790
+ const fails = yield* Queue.make<Fail, E | Cause.Done>({ capacity })
6973
6791
 
6974
6792
  yield* Effect.gen(function*() {
6975
6793
  while (true) {
@@ -7138,122 +6956,7 @@ export const partitionEffect: {
7138
6956
  R | RX | Scope.Scope
7139
6957
  > =>
7140
6958
  Effect.map(
7141
- partitionQueue</**
7142
- * Splits a stream with an effectful `Filter`, returning scoped streams for
7143
- * filter successes and failures.
7144
- *
7145
- * **When to use**
7146
- *
7147
- * Use when you need to classify each stream element with an effectful `Filter`
7148
- * and consume both passing and failing mapped values as streams.
7149
- *
7150
- * **Details**
7151
- *
7152
- * The returned streams are backed by queues in the current scope and should be
7153
- * consumed while that scope remains open. The first stream emits success values
7154
- * from the filter, and the second emits failure values.
7155
- *
7156
- * @see {@link partition} for the pure `Filter` variant
7157
- * @see {@link partitionQueue} for the lower-level queue result
7158
- * @see {@link filterMapEffect} for effectful filtering that discards failed filter results
7159
- *
7160
- * @stability stable
7161
- * @category filtering
7162
- * @since 4.0.0
7163
- */
7164
- Result.Result<Pass, Fail>, /**
7165
- * Splits a stream with an effectful `Filter`, returning scoped streams for
7166
- * filter successes and failures.
7167
- *
7168
- * **When to use**
7169
- *
7170
- * Use when you need to classify each stream element with an effectful `Filter`
7171
- * and consume both passing and failing mapped values as streams.
7172
- *
7173
- * **Details**
7174
- *
7175
- * The returned streams are backed by queues in the current scope and should be
7176
- * consumed while that scope remains open. The first stream emits success values
7177
- * from the filter, and the second emits failure values.
7178
- *
7179
- * @see {@link partition} for the pure `Filter` variant
7180
- * @see {@link partitionQueue} for the lower-level queue result
7181
- * @see {@link filterMapEffect} for effectful filtering that discards failed filter results
7182
- *
7183
- * @stability stable
7184
- * @category filtering
7185
- * @since 4.0.0
7186
- */
7187
- E | EX, /**
7188
- * Splits a stream with an effectful `Filter`, returning scoped streams for
7189
- * filter successes and failures.
7190
- *
7191
- * **When to use**
7192
- *
7193
- * Use when you need to classify each stream element with an effectful `Filter`
7194
- * and consume both passing and failing mapped values as streams.
7195
- *
7196
- * **Details**
7197
- *
7198
- * The returned streams are backed by queues in the current scope and should be
7199
- * consumed while that scope remains open. The first stream emits success values
7200
- * from the filter, and the second emits failure values.
7201
- *
7202
- * @see {@link partition} for the pure `Filter` variant
7203
- * @see {@link partitionQueue} for the lower-level queue result
7204
- * @see {@link filterMapEffect} for effectful filtering that discards failed filter results
7205
- *
7206
- * @stability stable
7207
- * @category filtering
7208
- * @since 4.0.0
7209
- */
7210
- R | RX, /**
7211
- * Splits a stream with an effectful `Filter`, returning scoped streams for
7212
- * filter successes and failures.
7213
- *
7214
- * **When to use**
7215
- *
7216
- * Use when you need to classify each stream element with an effectful `Filter`
7217
- * and consume both passing and failing mapped values as streams.
7218
- *
7219
- * **Details**
7220
- *
7221
- * The returned streams are backed by queues in the current scope and should be
7222
- * consumed while that scope remains open. The first stream emits success values
7223
- * from the filter, and the second emits failure values.
7224
- *
7225
- * @see {@link partition} for the pure `Filter` variant
7226
- * @see {@link partitionQueue} for the lower-level queue result
7227
- * @see {@link filterMapEffect} for effectful filtering that discards failed filter results
7228
- *
7229
- * @stability stable
7230
- * @category filtering
7231
- * @since 4.0.0
7232
- */
7233
- Pass, /**
7234
- * Splits a stream with an effectful `Filter`, returning scoped streams for
7235
- * filter successes and failures.
7236
- *
7237
- * **When to use**
7238
- *
7239
- * Use when you need to classify each stream element with an effectful `Filter`
7240
- * and consume both passing and failing mapped values as streams.
7241
- *
7242
- * **Details**
7243
- *
7244
- * The returned streams are backed by queues in the current scope and should be
7245
- * consumed while that scope remains open. The first stream emits success values
7246
- * from the filter, and the second emits failure values.
7247
- *
7248
- * @see {@link partition} for the pure `Filter` variant
7249
- * @see {@link partitionQueue} for the lower-level queue result
7250
- * @see {@link filterMapEffect} for effectful filtering that discards failed filter results
7251
- *
7252
- * @stability stable
7253
- * @category filtering
7254
- * @since 4.0.0
7255
- */
7256
- Fail>(
6959
+ partitionQueue<Result.Result<Pass, Fail>, E | EX, R | RX, Pass, Fail>(
7257
6960
  mapEffect(self, (a) => filter(a as NoInfer<A>), options),
7258
6961
  (result) => result,
7259
6962
  options
@@ -7592,17 +7295,12 @@ export const peel: {
7592
7295
  ): Effect.fn.Return<[A2, Stream<A, E, never>], E | E2, Scope.Scope | R | R2> {
7593
7296
  let cause: Cause.Cause<E | Cause.Done<void>> | undefined = undefined
7594
7297
  const originalPull = yield* Channel.toPull(self.channel)
7595
- const pull: Pull.Pull<
7596
- Arr.NonEmptyReadonlyArray<A>,
7597
- E
7598
- > = Effect.catchCause(originalPull, (cause_) => {
7298
+ const pull = Effect.catchCause(originalPull, (cause_) => {
7599
7299
  cause = cause_
7600
7300
  return Effect.failCause(cause_)
7601
7301
  })
7602
7302
 
7603
- const [result, leftover] = yield* Effect.scopedWith((scope) =>
7604
- sink.transform(pull as Pull.Pull<Arr.NonEmptyReadonlyArray<A>>, scope)
7605
- )
7303
+ const [result, leftover] = yield* Effect.scopedWith((scope) => runSink(sink, pull, scope))
7606
7304
  let stream: Stream<A, E> = cause ? empty : fromPull(Effect.succeed(originalPull))
7607
7305
  if (leftover) {
7608
7306
  stream = concat(fromArray(leftover), stream)
@@ -7953,6 +7651,12 @@ export const catchCause: {
7953
7651
  *
7954
7652
  * Typed failures and interruptions are not caught.
7955
7653
  *
7654
+ * **Gotchas**
7655
+ *
7656
+ * `catchDefect` recovers any cause that contains a defect, including causes
7657
+ * that also contain typed errors. Typed error handlers such as `catch` skip
7658
+ * those causes, so defects always take precedence.
7659
+ *
7956
7660
  * **Example** (Recovering from a defect)
7957
7661
  *
7958
7662
  * ```ts import.meta.vitest
@@ -7978,6 +7682,12 @@ export const catchDefect: {
7978
7682
  *
7979
7683
  * Typed failures and interruptions are not caught.
7980
7684
  *
7685
+ * **Gotchas**
7686
+ *
7687
+ * `catchDefect` recovers any cause that contains a defect, including causes
7688
+ * that also contain typed errors. Typed error handlers such as `catch` skip
7689
+ * those causes, so defects always take precedence.
7690
+ *
7981
7691
  * **Example** (Recovering from a defect)
7982
7692
  *
7983
7693
  * ```ts import.meta.vitest
@@ -8003,6 +7713,12 @@ export const catchDefect: {
8003
7713
  *
8004
7714
  * Typed failures and interruptions are not caught.
8005
7715
  *
7716
+ * **Gotchas**
7717
+ *
7718
+ * `catchDefect` recovers any cause that contains a defect, including causes
7719
+ * that also contain typed errors. Typed error handlers such as `catch` skip
7720
+ * those causes, so defects always take precedence.
7721
+ *
8006
7722
  * **Example** (Recovering from a defect)
8007
7723
  *
8008
7724
  * ```ts import.meta.vitest
@@ -8149,6 +7865,13 @@ export {
8149
7865
  /**
8150
7866
  * Switches over to the stream produced by the provided function if this one fails.
8151
7867
  *
7868
+ * **Gotchas**
7869
+ *
7870
+ * Defects take precedence over typed errors. If the cause also contains a
7871
+ * defect, the handler does not run and the failure is propagated with every
7872
+ * typed error converted to a defect. An interruption alongside a typed error
7873
+ * does not prevent recovery.
7874
+ *
8152
7875
  * **Example** (Catching stream failures)
8153
7876
  *
8154
7877
  * ```ts import.meta.vitest
@@ -8553,6 +8276,12 @@ export const tapDefect: {
8553
8276
  * stream. Non-matching failures propagate downstream, so the error type is
8554
8277
  * preserved unless the filter narrows it.
8555
8278
  *
8279
+ * **Gotchas**
8280
+ *
8281
+ * If the cause contains a defect, the handler is skipped and every typed error
8282
+ * is converted to a defect, preserving reason order and interrupts. An
8283
+ * interruption alongside a typed error does not prevent recovery.
8284
+ *
8556
8285
  * **Example** (Catching matching failures)
8557
8286
  *
8558
8287
  * ```ts import.meta.vitest
@@ -8588,6 +8317,12 @@ export const catchIf: {
8588
8317
  * stream. Non-matching failures propagate downstream, so the error type is
8589
8318
  * preserved unless the filter narrows it.
8590
8319
  *
8320
+ * **Gotchas**
8321
+ *
8322
+ * If the cause contains a defect, the handler is skipped and every typed error
8323
+ * is converted to a defect, preserving reason order and interrupts. An
8324
+ * interruption alongside a typed error does not prevent recovery.
8325
+ *
8591
8326
  * **Example** (Catching matching failures)
8592
8327
  *
8593
8328
  * ```ts import.meta.vitest
@@ -8629,6 +8364,12 @@ export const catchIf: {
8629
8364
  * stream. Non-matching failures propagate downstream, so the error type is
8630
8365
  * preserved unless the filter narrows it.
8631
8366
  *
8367
+ * **Gotchas**
8368
+ *
8369
+ * If the cause contains a defect, the handler is skipped and every typed error
8370
+ * is converted to a defect, preserving reason order and interrupts. An
8371
+ * interruption alongside a typed error does not prevent recovery.
8372
+ *
8632
8373
  * **Example** (Catching matching failures)
8633
8374
  *
8634
8375
  * ```ts import.meta.vitest
@@ -8670,6 +8411,12 @@ export const catchIf: {
8670
8411
  * stream. Non-matching failures propagate downstream, so the error type is
8671
8412
  * preserved unless the filter narrows it.
8672
8413
  *
8414
+ * **Gotchas**
8415
+ *
8416
+ * If the cause contains a defect, the handler is skipped and every typed error
8417
+ * is converted to a defect, preserving reason order and interrupts. An
8418
+ * interruption alongside a typed error does not prevent recovery.
8419
+ *
8673
8420
  * **Example** (Catching matching failures)
8674
8421
  *
8675
8422
  * ```ts import.meta.vitest
@@ -8697,7 +8444,7 @@ export const catchIf: {
8697
8444
  */
8698
8445
  <A, E, R, EB extends E, A2, E2, R2, A3 = unassigned, E3 = never, R3 = never>(
8699
8446
  self: Stream<A, E, R>,
8700
- refinement: Refinement<E, EB>,
8447
+ refinement: Refinement<NoInfer<E>, EB>,
8701
8448
  f: (e: EB) => Stream<A2, E2, R2>,
8702
8449
  orElse?: ((e: Exclude<E, EB>) => Stream<A3, E3, R3>) | undefined
8703
8450
  ): Stream<A | A2 | Exclude<A3, unassigned>, E2 | E3 | (A3 extends unassigned ? Exclude<E, EB> : never), R | R2 | R3>
@@ -8710,6 +8457,12 @@ export const catchIf: {
8710
8457
  * stream. Non-matching failures propagate downstream, so the error type is
8711
8458
  * preserved unless the filter narrows it.
8712
8459
  *
8460
+ * **Gotchas**
8461
+ *
8462
+ * If the cause contains a defect, the handler is skipped and every typed error
8463
+ * is converted to a defect, preserving reason order and interrupts. An
8464
+ * interruption alongside a typed error does not prevent recovery.
8465
+ *
8713
8466
  * **Example** (Catching matching failures)
8714
8467
  *
8715
8468
  * ```ts import.meta.vitest
@@ -8780,6 +8533,12 @@ export const catchIf: {
8780
8533
  * Successful filter results are passed to `f`. Failed filter results go to
8781
8534
  * `orElse` when provided; otherwise the filter failure is re-failed.
8782
8535
  *
8536
+ * **Gotchas**
8537
+ *
8538
+ * If the cause contains a defect, the handler is skipped and every typed error
8539
+ * is converted to a defect, preserving reason order and interrupts. An
8540
+ * interruption alongside a typed error does not prevent recovery.
8541
+ *
8783
8542
  * @see {@link catchIf} for predicate or refinement based recovery
8784
8543
  * @see {@link catchTag} for `_tag` based recovery from one tagged error
8785
8544
  * @see {@link catchTags} for `_tag` based recovery from multiple tagged errors
@@ -8804,6 +8563,12 @@ export const catchFilter: {
8804
8563
  * Successful filter results are passed to `f`. Failed filter results go to
8805
8564
  * `orElse` when provided; otherwise the filter failure is re-failed.
8806
8565
  *
8566
+ * **Gotchas**
8567
+ *
8568
+ * If the cause contains a defect, the handler is skipped and every typed error
8569
+ * is converted to a defect, preserving reason order and interrupts. An
8570
+ * interruption alongside a typed error does not prevent recovery.
8571
+ *
8807
8572
  * @see {@link catchIf} for predicate or refinement based recovery
8808
8573
  * @see {@link catchTag} for `_tag` based recovery from one tagged error
8809
8574
  * @see {@link catchTags} for `_tag` based recovery from multiple tagged errors
@@ -8834,6 +8599,12 @@ export const catchFilter: {
8834
8599
  * Successful filter results are passed to `f`. Failed filter results go to
8835
8600
  * `orElse` when provided; otherwise the filter failure is re-failed.
8836
8601
  *
8602
+ * **Gotchas**
8603
+ *
8604
+ * If the cause contains a defect, the handler is skipped and every typed error
8605
+ * is converted to a defect, preserving reason order and interrupts. An
8606
+ * interruption alongside a typed error does not prevent recovery.
8607
+ *
8837
8608
  * @see {@link catchIf} for predicate or refinement based recovery
8838
8609
  * @see {@link catchTag} for `_tag` based recovery from one tagged error
8839
8610
  * @see {@link catchTags} for `_tag` based recovery from multiple tagged errors
@@ -8885,6 +8656,12 @@ export const catchFilter: {
8885
8656
  * Use when you need to handle a specific error case from a stream whose error
8886
8657
  * type is a tagged union with a readonly `_tag` field.
8887
8658
  *
8659
+ * **Gotchas**
8660
+ *
8661
+ * If the cause contains a defect, the handler is skipped and every typed error
8662
+ * is converted to a defect, preserving reason order and interrupts. An
8663
+ * interruption alongside a typed error does not prevent recovery.
8664
+ *
8888
8665
  * **Example** (Catching tagged failures)
8889
8666
  *
8890
8667
  * ```ts import.meta.vitest
@@ -8920,6 +8697,12 @@ export const catchTag: {
8920
8697
  * Use when you need to handle a specific error case from a stream whose error
8921
8698
  * type is a tagged union with a readonly `_tag` field.
8922
8699
  *
8700
+ * **Gotchas**
8701
+ *
8702
+ * If the cause contains a defect, the handler is skipped and every typed error
8703
+ * is converted to a defect, preserving reason order and interrupts. An
8704
+ * interruption alongside a typed error does not prevent recovery.
8705
+ *
8923
8706
  * **Example** (Catching tagged failures)
8924
8707
  *
8925
8708
  * ```ts import.meta.vitest
@@ -8980,6 +8763,12 @@ export const catchTag: {
8980
8763
  * Use when you need to handle a specific error case from a stream whose error
8981
8764
  * type is a tagged union with a readonly `_tag` field.
8982
8765
  *
8766
+ * **Gotchas**
8767
+ *
8768
+ * If the cause contains a defect, the handler is skipped and every typed error
8769
+ * is converted to a defect, preserving reason order and interrupts. An
8770
+ * interruption alongside a typed error does not prevent recovery.
8771
+ *
8983
8772
  * **Example** (Catching tagged failures)
8984
8773
  *
8985
8774
  * ```ts import.meta.vitest
@@ -9061,6 +8850,12 @@ export const catchTag: {
9061
8850
  /**
9062
8851
  * Switches to a recovery stream based on matching `_tag` handlers.
9063
8852
  *
8853
+ * **Gotchas**
8854
+ *
8855
+ * If the cause contains a defect, the handler is skipped and every typed error
8856
+ * is converted to a defect, preserving reason order and interrupts. An
8857
+ * interruption alongside a typed error does not prevent recovery.
8858
+ *
9064
8859
  * **Example** (Catching tagged failures with handlers)
9065
8860
  *
9066
8861
  * ```ts import.meta.vitest
@@ -9100,6 +8895,12 @@ export const catchTags: {
9100
8895
  /**
9101
8896
  * Switches to a recovery stream based on matching `_tag` handlers.
9102
8897
  *
8898
+ * **Gotchas**
8899
+ *
8900
+ * If the cause contains a defect, the handler is skipped and every typed error
8901
+ * is converted to a defect, preserving reason order and interrupts. An
8902
+ * interruption alongside a typed error does not prevent recovery.
8903
+ *
9103
8904
  * **Example** (Catching tagged failures with handlers)
9104
8905
  *
9105
8906
  * ```ts import.meta.vitest
@@ -9166,6 +8967,12 @@ export const catchTags: {
9166
8967
  /**
9167
8968
  * Switches to a recovery stream based on matching `_tag` handlers.
9168
8969
  *
8970
+ * **Gotchas**
8971
+ *
8972
+ * If the cause contains a defect, the handler is skipped and every typed error
8973
+ * is converted to a defect, preserving reason order and interrupts. An
8974
+ * interruption alongside a typed error does not prevent recovery.
8975
+ *
9169
8976
  * **Example** (Catching tagged failures with handlers)
9170
8977
  *
9171
8978
  * ```ts import.meta.vitest
@@ -9259,6 +9066,12 @@ export const catchTags: {
9259
9066
  *
9260
9067
  * The handler receives the unwrapped reason.
9261
9068
  *
9069
+ * **Gotchas**
9070
+ *
9071
+ * If the cause contains a defect, the handler is skipped and every typed error
9072
+ * is converted to a defect, preserving reason order and interrupts. An
9073
+ * interruption alongside a typed error does not prevent recovery.
9074
+ *
9262
9075
  * **Example** (Catching a tagged error reason)
9263
9076
  *
9264
9077
  * ```ts import.meta.vitest
@@ -9310,6 +9123,12 @@ export const catchReason: {
9310
9123
  *
9311
9124
  * The handler receives the unwrapped reason.
9312
9125
  *
9126
+ * **Gotchas**
9127
+ *
9128
+ * If the cause contains a defect, the handler is skipped and every typed error
9129
+ * is converted to a defect, preserving reason order and interrupts. An
9130
+ * interruption alongside a typed error does not prevent recovery.
9131
+ *
9313
9132
  * **Example** (Catching a tagged error reason)
9314
9133
  *
9315
9134
  * ```ts import.meta.vitest
@@ -9390,6 +9209,12 @@ export const catchReason: {
9390
9209
  *
9391
9210
  * The handler receives the unwrapped reason.
9392
9211
  *
9212
+ * **Gotchas**
9213
+ *
9214
+ * If the cause contains a defect, the handler is skipped and every typed error
9215
+ * is converted to a defect, preserving reason order and interrupts. An
9216
+ * interruption alongside a typed error does not prevent recovery.
9217
+ *
9393
9218
  * **Example** (Catching a tagged error reason)
9394
9219
  *
9395
9220
  * ```ts import.meta.vitest
@@ -9494,6 +9319,12 @@ export const catchReason: {
9494
9319
  /**
9495
9320
  * Catches multiple reasons within a tagged error using an object of handlers.
9496
9321
  *
9322
+ * **Gotchas**
9323
+ *
9324
+ * If the cause contains a defect, the handler is skipped and every typed error
9325
+ * is converted to a defect, preserving reason order and interrupts. An
9326
+ * interruption alongside a typed error does not prevent recovery.
9327
+ *
9497
9328
  * **Example** (Catching tagged error reasons)
9498
9329
  *
9499
9330
  * ```ts import.meta.vitest
@@ -9537,6 +9368,12 @@ export const catchReasons: {
9537
9368
  /**
9538
9369
  * Catches multiple reasons within a tagged error using an object of handlers.
9539
9370
  *
9371
+ * **Gotchas**
9372
+ *
9373
+ * If the cause contains a defect, the handler is skipped and every typed error
9374
+ * is converted to a defect, preserving reason order and interrupts. An
9375
+ * interruption alongside a typed error does not prevent recovery.
9376
+ *
9540
9377
  * **Example** (Catching tagged error reasons)
9541
9378
  *
9542
9379
  * ```ts import.meta.vitest
@@ -9618,6 +9455,12 @@ export const catchReasons: {
9618
9455
  /**
9619
9456
  * Catches multiple reasons within a tagged error using an object of handlers.
9620
9457
  *
9458
+ * **Gotchas**
9459
+ *
9460
+ * If the cause contains a defect, the handler is skipped and every typed error
9461
+ * is converted to a defect, preserving reason order and interrupts. An
9462
+ * interruption alongside a typed error does not prevent recovery.
9463
+ *
9621
9464
  * **Example** (Catching tagged error reasons)
9622
9465
  *
9623
9466
  * ```ts import.meta.vitest
@@ -9889,6 +9732,11 @@ export const unwrapReason: {
9889
9732
  /**
9890
9733
  * Transforms the errors emitted by this stream using `f`.
9891
9734
  *
9735
+ * **Details**
9736
+ *
9737
+ * Maps every typed error in the cause, preserving defects, interrupts and
9738
+ * reason order. Unlike typed recovery, mapping does not convert errors to defects.
9739
+ *
9892
9740
  * **Example** (Mapping stream errors)
9893
9741
  *
9894
9742
  * ```ts import.meta.vitest
@@ -9914,6 +9762,11 @@ export const mapError: {
9914
9762
  /**
9915
9763
  * Transforms the errors emitted by this stream using `f`.
9916
9764
  *
9765
+ * **Details**
9766
+ *
9767
+ * Maps every typed error in the cause, preserving defects, interrupts and
9768
+ * reason order. Unlike typed recovery, mapping does not convert errors to defects.
9769
+ *
9917
9770
  * **Example** (Mapping stream errors)
9918
9771
  *
9919
9772
  * ```ts import.meta.vitest
@@ -9939,6 +9792,11 @@ export const mapError: {
9939
9792
  /**
9940
9793
  * Transforms the errors emitted by this stream using `f`.
9941
9794
  *
9795
+ * **Details**
9796
+ *
9797
+ * Maps every typed error in the cause, preserving defects, interrupts and
9798
+ * reason order. Unlike typed recovery, mapping does not convert errors to defects.
9799
+ *
9942
9800
  * **Example** (Mapping stream errors)
9943
9801
  *
9944
9802
  * ```ts import.meta.vitest
@@ -10256,6 +10114,12 @@ export const orElseIfEmpty: {
10256
10114
  /**
10257
10115
  * Returns a stream that emits a fallback value when this stream fails.
10258
10116
  *
10117
+ * **Gotchas**
10118
+ *
10119
+ * If the cause contains a defect, the handler is skipped and every typed error
10120
+ * is converted to a defect, preserving reason order and interrupts. An
10121
+ * interruption alongside a typed error does not prevent recovery.
10122
+ *
10259
10123
  * **Example** (Recovering with a fallback value)
10260
10124
  *
10261
10125
  * ```ts import.meta.vitest
@@ -10281,6 +10145,12 @@ export const orElseSucceed: {
10281
10145
  /**
10282
10146
  * Returns a stream that emits a fallback value when this stream fails.
10283
10147
  *
10148
+ * **Gotchas**
10149
+ *
10150
+ * If the cause contains a defect, the handler is skipped and every typed error
10151
+ * is converted to a defect, preserving reason order and interrupts. An
10152
+ * interruption alongside a typed error does not prevent recovery.
10153
+ *
10284
10154
  * **Example** (Recovering with a fallback value)
10285
10155
  *
10286
10156
  * ```ts import.meta.vitest
@@ -10306,6 +10176,12 @@ export const orElseSucceed: {
10306
10176
  /**
10307
10177
  * Returns a stream that emits a fallback value when this stream fails.
10308
10178
  *
10179
+ * **Gotchas**
10180
+ *
10181
+ * If the cause contains a defect, the handler is skipped and every typed error
10182
+ * is converted to a defect, preserving reason order and interrupts. An
10183
+ * interruption alongside a typed error does not prevent recovery.
10184
+ *
10309
10185
  * **Example** (Recovering with a fallback value)
10310
10186
  *
10311
10187
  * ```ts import.meta.vitest
@@ -10372,6 +10248,13 @@ export const orDie = <A, E, R>(self: Stream<A, E, R>): Stream<A, never, R> => fr
10372
10248
  * The `log` option controls whether the failure is logged before the stream
10373
10249
  * terminates.
10374
10250
  *
10251
+ * **Gotchas**
10252
+ *
10253
+ * Defects take precedence over typed errors. If the cause also contains a
10254
+ * defect, the failure is not ignored and is propagated with every typed error
10255
+ * converted to a defect. An interruption alongside a typed error does not
10256
+ * prevent the error from being ignored.
10257
+ *
10375
10258
  * **Example** (Ignoring stream failures)
10376
10259
  *
10377
10260
  * ```ts import.meta.vitest
@@ -10489,6 +10372,12 @@ export const ignoreCause: <
10489
10372
  * The schedule is reset as soon as the first element passes through the
10490
10373
  * stream again.
10491
10374
  *
10375
+ * **Gotchas**
10376
+ *
10377
+ * Defects take precedence over typed errors. A failure whose cause contains a
10378
+ * defect is not retried and is propagated with every typed error converted to a
10379
+ * defect. A typed error alongside an interruption is retried.
10380
+ *
10492
10381
  * **Example** (Retrying stream failures)
10493
10382
  *
10494
10383
  * ```ts import.meta.vitest
@@ -10524,6 +10413,12 @@ export const retry: {
10524
10413
  * The schedule is reset as soon as the first element passes through the
10525
10414
  * stream again.
10526
10415
  *
10416
+ * **Gotchas**
10417
+ *
10418
+ * Defects take precedence over typed errors. A failure whose cause contains a
10419
+ * defect is not retried and is propagated with every typed error converted to a
10420
+ * defect. A typed error alongside an interruption is retried.
10421
+ *
10527
10422
  * **Example** (Retrying stream failures)
10528
10423
  *
10529
10424
  * ```ts import.meta.vitest
@@ -10565,6 +10460,12 @@ export const retry: {
10565
10460
  * The schedule is reset as soon as the first element passes through the
10566
10461
  * stream again.
10567
10462
  *
10463
+ * **Gotchas**
10464
+ *
10465
+ * Defects take precedence over typed errors. A failure whose cause contains a
10466
+ * defect is not retried and is propagated with every typed error converted to a
10467
+ * defect. A typed error alongside an interruption is retried.
10468
+ *
10568
10469
  * **Example** (Retrying stream failures)
10569
10470
  *
10570
10471
  * ```ts import.meta.vitest
@@ -10847,57 +10748,7 @@ export const withExecutionPlan: {
10847
10748
  return emitter.end(state, exit)
10848
10749
  })
10849
10750
  )
10850
- let lastError = Option.none</**
10851
- * Applies an `ExecutionPlan` to a stream, retrying with step-provided resources
10852
- * until it succeeds or the plan is exhausted.
10853
- *
10854
- * **Details**
10855
- *
10856
- * By default, a failing step can fallback even after emitting elements; set
10857
- * `preventFallbackOnPartialStream` to fail instead of mixing partial output with
10858
- * a later fallback.
10859
- *
10860
- * Attempts can be observed from outside the stream by passing
10861
- * `options.onEvent`, which receives an `ExecutionPlan.Event` before each
10862
- * attempt and after it settles; see `Effect.withExecutionPlan` for the handler
10863
- * semantics. When a downstream consumer stops pulling early (for example
10864
- * `Stream.take` outside the plan), the truncated attempt reports
10865
- * `AttemptSuccess`: the consumer stopped, not the source.
10866
- *
10867
- * **Example** (Applying an execution plan)
10868
- *
10869
- * ```ts import.meta.vitest
10870
- * import { Context, Effect, ExecutionPlan, Layer, Stream } from "effect"
10871
- *
10872
- * class Service extends Context.Service<Service>()("Service", {
10873
- * make: Effect.succeed({
10874
- * stream: Stream.fail("A") as Stream.Stream<number, string>
10875
- * })
10876
- * }) {
10877
- * static Bad = Layer.succeed(Service, Service.of({ stream: Stream.fail("A") }))
10878
- * static Good = Layer.succeed(Service, Service.of({ stream: Stream.make(1, 2, 3) }))
10879
- * }
10880
- *
10881
- * const plan = ExecutionPlan.make(
10882
- * { provide: Service.Bad },
10883
- * { provide: Service.Good }
10884
- * )
10885
- *
10886
- * const stream = Stream.unwrap(Effect.map(Service, (_) => _.stream))
10887
- *
10888
- * const program = Effect.gen(function*() {
10889
- * const items = yield* stream.pipe(Stream.withExecutionPlan(plan), Stream.runCollect)
10890
- * items // => [ 1, 2, 3 ]
10891
- * })
10892
- *
10893
- * await Effect.runPromise(program)
10894
- * ```
10895
- *
10896
- * @stability unstable
10897
- * @category error handling
10898
- * @since 3.16.0
10899
- */
10900
- E | PolicyE>()
10751
+ let lastError = Option.none<E | PolicyE>()
10901
10752
  const loop: Stream<
10902
10753
  A,
10903
10754
  E | PolicyE,
@@ -11242,7 +11093,7 @@ export const takeRight: {
11242
11093
  const count = Count.normalize(n)
11243
11094
  if (count === 0) return empty
11244
11095
  return mapAccumArray(self, MutableList.make<A>, (list, arr) => {
11245
- MutableList.appendAll(list, arr)
11096
+ MutableList.appendAllUnsafe(list, arr)
11246
11097
  if (list.length > count) {
11247
11098
  MutableList.takeNVoid(list, list.length - count)
11248
11099
  }
@@ -12533,36 +12384,7 @@ export const dropRight: {
12533
12384
  if (count === 0) return self
12534
12385
  return transformPull(self, (pull, _scope) =>
12535
12386
  Effect.sync(() => {
12536
- const list = MutableList.make</**
12537
- * Drops the last specified number of elements from this stream.
12538
- *
12539
- * **Details**
12540
- *
12541
- * Keeps the last `n` elements in memory to drop them on completion. Finite
12542
- * fractional values of `n` are rounded down. `NaN` and non-positive values
12543
- * return the source stream unchanged.
12544
- *
12545
- * **Example** (Dropping values from the right)
12546
- *
12547
- * ```ts import.meta.vitest
12548
- * import { Effect, Stream } from "effect"
12549
- *
12550
- * const program = Effect.gen(function*() {
12551
- * const result = yield* Stream.make(1, 2, 3, 4, 5).pipe(
12552
- * Stream.dropRight(2),
12553
- * Stream.runCollect
12554
- * )
12555
- * result // => [ 1, 2, 3 ]
12556
- * })
12557
- *
12558
- * await Effect.runPromise(program)
12559
- * ```
12560
- *
12561
- * @stability stable
12562
- * @category filtering
12563
- * @since 2.0.0
12564
- */
12565
- A>()
12387
+ const list = MutableList.make<A>()
12566
12388
  const emit: Pull.Pull<Arr.NonEmptyReadonlyArray<A>, E> = Effect.flatMap(pull, (arr) => {
12567
12389
  MutableList.appendAllUnsafe(list, arr)
12568
12390
  const toTake = list.length - count
@@ -12570,7 +12392,7 @@ export const dropRight: {
12570
12392
  return Arr.isArrayNonEmpty(items) ? Effect.succeed(items) : emit
12571
12393
  })
12572
12394
  return emit
12573
- }));
12395
+ }))
12574
12396
  }
12575
12397
  )
12576
12398
 
@@ -12698,42 +12520,13 @@ export const rechunk: {
12698
12520
  target = Count.normalizeNonEmpty(target)
12699
12521
  return transformPull(self, (pull, _scope) =>
12700
12522
  Effect.sync(() => {
12701
- let chunk = Arr.empty</**
12702
- * Groups the stream into arrays of the specified size, preserving element order.
12703
- *
12704
- * **Details**
12705
- *
12706
- * Finite fractional sizes are rounded down. `NaN` and non-positive sizes are
12707
- * treated as `1`.
12708
- *
12709
- * **Example** (Rechunking stream elements)
12710
- *
12711
- * ```ts import.meta.vitest
12712
- * import { Effect, Stream } from "effect"
12713
- *
12714
- * const program = Effect.gen(function*() {
12715
- * const result = yield* Stream.make(1, 2, 3, 4, 5).pipe(
12716
- * Stream.rechunk(2),
12717
- * Stream.chunks,
12718
- * Stream.runCollect
12719
- * )
12720
- * result // => [ [ 1, 2 ], [ 3, 4 ], [ 5 ] ]
12721
- * })
12722
- *
12723
- * await Effect.runPromise(program)
12724
- * ```
12725
- *
12726
- * @stability stable
12727
- * @category grouping
12728
- * @since 2.0.0
12729
- */
12730
- A>() as Arr.NonEmptyArray<A>
12523
+ let chunk = Arr.empty<A>() as Arr.NonEmptyArray<A>
12731
12524
  let index = 0
12732
12525
  let current: Arr.NonEmptyReadonlyArray<A> | undefined
12733
- let done = false
12526
+ let cause: Cause.Cause<E | Cause.Done> | undefined
12734
12527
 
12735
12528
  return Effect.suspend(function loop(): Pull.Pull<Arr.NonEmptyReadonlyArray<A>, E, void, R> {
12736
- if (done) return Cause.done()
12529
+ if (cause) return Effect.failCause(cause)
12737
12530
  else if (current === undefined) {
12738
12531
  return Effect.flatMap(pull, (arr) => {
12739
12532
  if (chunk.length === 0 && arr.length === target) {
@@ -12760,15 +12553,15 @@ export const rechunk: {
12760
12553
  current = undefined
12761
12554
  return loop()
12762
12555
  }).pipe(
12763
- Pull.catchDone(() => {
12764
- if (chunk.length === 0) return Cause.done()
12556
+ Effect.catchCause((cause_) => {
12557
+ if (chunk.length === 0) return Effect.failCause(cause_)
12765
12558
  const result = chunk
12766
- done = true
12559
+ cause = cause_
12767
12560
  chunk = [] as any
12768
12561
  return Effect.succeed(result)
12769
12562
  })
12770
12563
  )
12771
- }));
12564
+ }))
12772
12565
  })
12773
12566
 
12774
12567
  /**
@@ -12956,35 +12749,7 @@ export const slidingSize: {
12956
12749
  return transformPull(self, (upstream, _scope) =>
12957
12750
  Effect.sync(() => {
12958
12751
  let cause: Cause.Cause<E | Cause.Done> | null = null
12959
- const list = MutableList.make</**
12960
- * Emits sliding windows of `chunkSize` elements, advancing by `stepSize`.
12961
- *
12962
- * **Details**
12963
- *
12964
- * Finite fractional window and step sizes are rounded down. `NaN` and
12965
- * non-positive sizes are treated as `1`.
12966
- *
12967
- * **Example** (Emitting sliding windows with a step size)
12968
- *
12969
- * ```ts import.meta.vitest
12970
- * import { Effect, Stream } from "effect"
12971
- *
12972
- * const program = Effect.gen(function*() {
12973
- * const chunks = yield* Stream.make(1, 2, 3, 4, 5).pipe(
12974
- * Stream.slidingSize(3, 2),
12975
- * Stream.runCollect
12976
- * )
12977
- * chunks // => [ [ 1, 2, 3 ], [ 3, 4, 5 ] ]
12978
- * })
12979
- *
12980
- * await Effect.runPromise(program)
12981
- * ```
12982
- *
12983
- * @stability stable
12984
- * @category grouping
12985
- * @since 2.0.0
12986
- */
12987
- A>()
12752
+ const list = MutableList.make<A>()
12988
12753
  let emitted = false
12989
12754
  let skip = 0
12990
12755
  const pull: Pull.Pull<
@@ -13022,7 +12787,7 @@ export const slidingSize: {
13022
12787
  })
13023
12788
 
13024
12789
  return Effect.suspend(() => cause ? Effect.failCause(cause) : pull)
13025
- }));
12790
+ }))
13026
12791
  }
13027
12792
  )
13028
12793
 
@@ -13171,34 +12936,7 @@ export const split: {
13171
12936
  predicate: Predicate<NoInfer<A>>
13172
12937
  ): Stream<Arr.NonEmptyReadonlyArray<A>, E, R> =>
13173
12938
  mapAccumArray(self, Arr.empty<A>, (acc, arr) => {
13174
- const out = Arr.empty</**
13175
- * Splits the stream into non-empty groups whenever the predicate matches.
13176
- *
13177
- * **Details**
13178
- *
13179
- * Matching elements act as delimiters and are not included in the output.
13180
- *
13181
- * **Example** (Splitting on matching values)
13182
- *
13183
- * ```ts import.meta.vitest
13184
- * import { Effect, Stream } from "effect"
13185
- *
13186
- * const program = Effect.gen(function*() {
13187
- * const result = yield* Stream.range(0, 9).pipe(
13188
- * Stream.split((n) => n % 4 === 0),
13189
- * Stream.runCollect
13190
- * )
13191
- * result // => [ [ 1, 2, 3 ], [ 5, 6, 7 ], [ 9 ] ]
13192
- * })
13193
- *
13194
- * await Effect.runPromise(program)
13195
- * ```
13196
- *
13197
- * @stability stable
13198
- * @category grouping
13199
- * @since 2.0.0
13200
- */
13201
- Arr.NonEmptyReadonlyArray<A>>()
12939
+ const out = Arr.empty<Arr.NonEmptyReadonlyArray<A>>()
13202
12940
  for (let i = 0; i < arr.length; i++) {
13203
12941
  if (predicate(arr[i])) {
13204
12942
  if (Arr.isArrayNonEmpty(acc)) {
@@ -13639,38 +13377,13 @@ export const mapAccum: {
13639
13377
  self.channel,
13640
13378
  initial,
13641
13379
  (state, arr) => {
13642
- const acc = Arr.empty</**
13643
- * Maps elements statefully, emitting zero or more outputs per input.
13644
- *
13645
- * **Example** (Statefully mapping stream values)
13646
- *
13647
- * ```ts import.meta.vitest
13648
- * import { Console, Effect, Stream } from "effect"
13649
- *
13650
- * const program = Effect.gen(function*() {
13651
- * const totals = yield* Stream.make(0, 1, 2, 3, 4, 5, 6).pipe(
13652
- * Stream.mapAccum(() => 0, (total, n) => {
13653
- * const next = total + n
13654
- * return [next, [next]] as const
13655
- * }),
13656
- * Stream.runCollect
13657
- * )
13658
- *
13659
- * totals // => [0, 1, 3, 6, 10, 15, 21]
13660
- * })
13661
- *
13662
- * await Effect.runPromise(program)
13663
- * ```
13664
- *
13665
- * @stability stable
13666
- * @category mapping
13667
- * @since 2.0.0
13668
- */
13669
- B>()
13380
+ const acc = Arr.empty<B>()
13670
13381
  for (let index = 0; index < arr.length; index++) {
13671
13382
  const [newState, values] = f(state, arr[index])
13672
13383
  state = newState
13673
- acc.push(...values)
13384
+ for (let i = 0; i < values.length; i++) {
13385
+ acc.push(values[i])
13386
+ }
13674
13387
  }
13675
13388
  return [state, Arr.isArrayNonEmpty(acc) ? Arr.of(acc) : emptyArr]
13676
13389
  },
@@ -13968,45 +13681,7 @@ export const mapAccumEffect: {
13968
13681
  f(state, a),
13969
13682
  ([state, values]) => [
13970
13683
  state,
13971
- Arr.isReadonlyArrayNonEmpty(values) ? Arr.of(values) : Arr.empty</**
13972
- * Maps each element statefully and effectfully, emitting zero or more output
13973
- * values per input.
13974
- *
13975
- * **When to use**
13976
- *
13977
- * Use when stateful element mapping needs Effects or can fail while emitting
13978
- * zero or more values per input element.
13979
- *
13980
- * **Details**
13981
- *
13982
- * The mapping effect receives the current state and element, then returns the
13983
- * next state plus the values to emit. The state is threaded through the
13984
- * stream.
13985
- *
13986
- * **Example** (Effectfully mapping stream values with state)
13987
- *
13988
- * ```ts import.meta.vitest
13989
- * import { Effect, Stream } from "effect"
13990
- *
13991
- * const program = Effect.gen(function*() {
13992
- * const result = yield* Stream.make(1, 1, 1).pipe(
13993
- * Stream.mapAccumEffect(() => 0, (total, n) =>
13994
- * Effect.succeed([total + n, [total + n]])
13995
- * ),
13996
- * Stream.runCollect
13997
- * )
13998
- *
13999
- * result // => [ 1, 2, 3 ]
14000
- * })
14001
- *
14002
- * await Effect.runPromise(program)
14003
- * ```
14004
- *
14005
- * @stability stable
14006
- * @category mapping
14007
- * @since 2.0.0
14008
- */
14009
- Arr.NonEmptyReadonlyArray<B>>()
13684
+ Arr.isReadonlyArrayNonEmpty(values) ? Arr.of(values) : Arr.empty<Arr.NonEmptyReadonlyArray<B>>()
14010
13685
  ]
14011
13686
  ),
14012
13687
  options?.onHalt ?
@@ -14270,37 +13945,14 @@ export const scan: {
14270
13945
  return concat(
14271
13946
  succeed(seed),
14272
13947
  fromChannel(Channel.mapAccum(self.channel, () => seed, (state, arr) => {
14273
- const states = Arr.empty</**
14274
- * Accumulates state across the stream, emitting the initial state and each updated state.
14275
- *
14276
- * **Example** (Scanning stream state)
14277
- *
14278
- * ```ts import.meta.vitest
14279
- * import { Effect, Stream } from "effect"
14280
- *
14281
- * const program = Effect.gen(function*() {
14282
- * const values = yield* Stream.make(1, 2, 3).pipe(
14283
- * Stream.scan(() => 0, (acc, n) => acc + n),
14284
- * Stream.runCollect
14285
- * )
14286
- * values // => [ 0, 1, 3, 6 ]
14287
- * })
14288
- *
14289
- * await Effect.runPromise(program)
14290
- * ```
14291
- *
14292
- * @stability stable
14293
- * @category accumulation
14294
- * @since 2.0.0
14295
- */
14296
- S>() as Arr.NonEmptyArray<S>
13948
+ const states = Arr.empty<S>() as Arr.NonEmptyArray<S>
14297
13949
  for (let index = 0; index < arr.length; index++) {
14298
13950
  state = f(state, arr[index])
14299
13951
  states.push(state)
14300
13952
  }
14301
13953
  return [state, Arr.of(states)]
14302
13954
  }))
14303
- );
13955
+ )
14304
13956
  }))
14305
13957
 
14306
13958
  /**
@@ -15397,67 +15049,7 @@ export const groupByKey: {
15397
15049
  }
15398
15050
  ): Stream<readonly [K, Stream<A>], E, R> =>
15399
15051
  suspend(() => {
15400
- const batch = MutableHashMap.empty</**
15401
- * Groups elements by a key and emits a stream per key.
15402
- *
15403
- * **Example** (Grouping elements by key)
15404
- *
15405
- * ```ts import.meta.vitest
15406
- * import { Effect, Stream } from "effect"
15407
- *
15408
- * const program = Effect.gen(function*() {
15409
- * const grouped = yield* Stream.make(1, 2, 3, 4, 5).pipe(
15410
- * Stream.groupByKey((n) => n % 2 === 0 ? "even" : "odd"),
15411
- * Stream.mapEffect(
15412
- * ([key, stream]) =>
15413
- * Stream.runCollect(stream).pipe(
15414
- * Effect.map((values) => [key, values] as const)
15415
- * ),
15416
- * { concurrency: "unbounded" }
15417
- * ),
15418
- * Stream.runCollect
15419
- * )
15420
- * grouped // => [ [ 'odd', [ 1, 3, 5 ] ], [ 'even', [ 2, 4 ] ] ]
15421
- * })
15422
- *
15423
- * await Effect.runPromise(program)
15424
- * ```
15425
- *
15426
- * @stability stable
15427
- * @category grouping
15428
- * @since 2.0.0
15429
- */
15430
- K, /**
15431
- * Groups elements by a key and emits a stream per key.
15432
- *
15433
- * **Example** (Grouping elements by key)
15434
- *
15435
- * ```ts import.meta.vitest
15436
- * import { Effect, Stream } from "effect"
15437
- *
15438
- * const program = Effect.gen(function*() {
15439
- * const grouped = yield* Stream.make(1, 2, 3, 4, 5).pipe(
15440
- * Stream.groupByKey((n) => n % 2 === 0 ? "even" : "odd"),
15441
- * Stream.mapEffect(
15442
- * ([key, stream]) =>
15443
- * Stream.runCollect(stream).pipe(
15444
- * Effect.map((values) => [key, values] as const)
15445
- * ),
15446
- * { concurrency: "unbounded" }
15447
- * ),
15448
- * Stream.runCollect
15449
- * )
15450
- * grouped // => [ [ 'odd', [ 1, 3, 5 ] ], [ 'even', [ 2, 4 ] ] ]
15451
- * })
15452
- *
15453
- * await Effect.runPromise(program)
15454
- * ```
15455
- *
15456
- * @stability stable
15457
- * @category grouping
15458
- * @since 2.0.0
15459
- */
15460
- Arr.NonEmptyArray<A>>()
15052
+ const batch = MutableHashMap.empty<K, Arr.NonEmptyArray<A>>()
15461
15053
  return groupByImpl(
15462
15054
  self,
15463
15055
  Effect.fnUntraced(function*(arr, queues, queueMap) {
@@ -15525,7 +15117,12 @@ const groupByImpl = <A, E, R, K, V, E2, R2>(
15525
15117
  body: constant(Effect.flatMap(pull, (arr) => f(arr, queues, queueMap))),
15526
15118
  step: constVoid
15527
15119
  }).pipe(
15528
- Effect.catchCause((cause) => Queue.failCause(out, cause)),
15120
+ Effect.catchCause((cause) => {
15121
+ for (const [, queue] of queueMap) {
15122
+ Queue.endUnsafe(queue)
15123
+ }
15124
+ return Queue.failCause(out, cause)
15125
+ }),
15529
15126
  Effect.forkIn(scope)
15530
15127
  )
15531
15128
 
@@ -15610,29 +15207,7 @@ export const groupAdjacentBy: {
15610
15207
  Effect.sync(() => {
15611
15208
  let currentKey: K = undefined as any
15612
15209
  let group: Arr.NonEmptyArray<A> | undefined
15613
- let toEmit = Arr.empty</**
15614
- * Groups consecutive elements that have equal keys into non-empty arrays.
15615
- *
15616
- * **When to use**
15617
- *
15618
- * Use when you already have a stream ordered by the grouping key and want to
15619
- * emit each consecutive run as a non-empty array while keeping later
15620
- * non-adjacent runs separate.
15621
- *
15622
- * **Details**
15623
- *
15624
- * The key is computed with `f`; adjacent elements whose keys are equal by
15625
- * `Equal.equals` are emitted as one `[key, group]`. Later non-adjacent runs
15626
- * with the same key are emitted separately.
15627
- *
15628
- * @see {@link groupByKey} for grouping all elements with the same key across the stream
15629
- * @see {@link groupBy} for custom grouped stream construction
15630
- *
15631
- * @stability stable
15632
- * @category grouping
15633
- * @since 2.0.0
15634
- */
15635
- readonly [K, Arr.NonEmptyArray<A>]>()
15210
+ let toEmit = Arr.empty<readonly [K, Arr.NonEmptyArray<A>]>()
15636
15211
  const loop: Pull.Pull<
15637
15212
  Arr.NonEmptyReadonlyArray<readonly [K, Arr.NonEmptyArray<A>]>,
15638
15213
  E
@@ -16019,89 +15594,7 @@ export const aggregateWithin: {
16019
15594
 
16020
15595
  const pullLatch = Latch.makeUnsafe(false)
16021
15596
  const scheduleStep = Symbol()
16022
- const buffer = yield* Queue.make</**
16023
- * Aggregates elements with a sink, emitting each result when the sink completes or the schedule triggers.
16024
- *
16025
- * **Details**
16026
- *
16027
- * The schedule can flush the current aggregation even if the sink has not finished.
16028
- * It is stepped at most once per aggregation, when the aggregation receives its
16029
- * first element, with the previous aggregation's output as input. An aggregation
16030
- * the sink completes immediately, such as one built from leftovers, may finish
16031
- * without stepping the schedule.
16032
- *
16033
- * Time between aggregations is hidden from the schedule, so an idle stream does
16034
- * not run it. Time-based schedules such as `Schedule.fixed` and
16035
- * `Schedule.upTo({ duration })` only count time spent aggregating; use
16036
- * `Schedule.spaced` for a flush timer.
16037
- *
16038
- * When the schedule ends, the stream emits the current aggregation and any sink
16039
- * leftovers, then ends without pulling more from upstream.
16040
- *
16041
- * **Example** (Aggregating with a sink and schedule)
16042
- *
16043
- * ```ts import.meta.vitest
16044
- * import { Effect, Schedule, Sink, Stream } from "effect"
16045
- *
16046
- * await Effect.runPromise(Effect.gen(function* () {
16047
- * const aggregated = yield* Stream.runCollect(
16048
- * Stream.make(1, 2, 3, 4, 5, 6).pipe(
16049
- * Stream.aggregateWithin(
16050
- * Sink.foldUntil(() => 0, 3, (sum, n) => Effect.succeed(sum + n)),
16051
- * Schedule.forever
16052
- * )
16053
- * )
16054
- * )
16055
- * aggregated // => [ 6, 15 ]
16056
- * }))
16057
- * ```
16058
- *
16059
- * @stability stable
16060
- * @category aggregation
16061
- * @since 2.0.0
16062
- */
16063
- Arr.NonEmptyReadonlyArray<A> | typeof scheduleStep, /**
16064
- * Aggregates elements with a sink, emitting each result when the sink completes or the schedule triggers.
16065
- *
16066
- * **Details**
16067
- *
16068
- * The schedule can flush the current aggregation even if the sink has not finished.
16069
- * It is stepped at most once per aggregation, when the aggregation receives its
16070
- * first element, with the previous aggregation's output as input. An aggregation
16071
- * the sink completes immediately, such as one built from leftovers, may finish
16072
- * without stepping the schedule.
16073
- *
16074
- * Time between aggregations is hidden from the schedule, so an idle stream does
16075
- * not run it. Time-based schedules such as `Schedule.fixed` and
16076
- * `Schedule.upTo({ duration })` only count time spent aggregating; use
16077
- * `Schedule.spaced` for a flush timer.
16078
- *
16079
- * When the schedule ends, the stream emits the current aggregation and any sink
16080
- * leftovers, then ends without pulling more from upstream.
16081
- *
16082
- * **Example** (Aggregating with a sink and schedule)
16083
- *
16084
- * ```ts import.meta.vitest
16085
- * import { Effect, Schedule, Sink, Stream } from "effect"
16086
- *
16087
- * await Effect.runPromise(Effect.gen(function* () {
16088
- * const aggregated = yield* Stream.runCollect(
16089
- * Stream.make(1, 2, 3, 4, 5, 6).pipe(
16090
- * Stream.aggregateWithin(
16091
- * Sink.foldUntil(() => 0, 3, (sum, n) => Effect.succeed(sum + n)),
16092
- * Schedule.forever
16093
- * )
16094
- * )
16095
- * )
16096
- * aggregated // => [ 6, 15 ]
16097
- * }))
16098
- * ```
16099
- *
16100
- * @stability stable
16101
- * @category aggregation
16102
- * @since 2.0.0
16103
- */
16104
- E | Cause.Done<void>>({
15597
+ const buffer = yield* Queue.make<Arr.NonEmptyReadonlyArray<A> | typeof scheduleStep, E | Cause.Done<void>>({
16105
15598
  capacity: 0
16106
15599
  })
16107
15600
 
@@ -16122,48 +15615,7 @@ export const aggregateWithin: {
16122
15615
  const hasInput = Latch.makeUnsafe(false)
16123
15616
  let scheduleTime = clock.currentTimeMillisUnsafe()
16124
15617
  let openedAt = 0
16125
- let lastOutput = Option.none</**
16126
- * Aggregates elements with a sink, emitting each result when the sink completes or the schedule triggers.
16127
- *
16128
- * **Details**
16129
- *
16130
- * The schedule can flush the current aggregation even if the sink has not finished.
16131
- * It is stepped at most once per aggregation, when the aggregation receives its
16132
- * first element, with the previous aggregation's output as input. An aggregation
16133
- * the sink completes immediately, such as one built from leftovers, may finish
16134
- * without stepping the schedule.
16135
- *
16136
- * Time between aggregations is hidden from the schedule, so an idle stream does
16137
- * not run it. Time-based schedules such as `Schedule.fixed` and
16138
- * `Schedule.upTo({ duration })` only count time spent aggregating; use
16139
- * `Schedule.spaced` for a flush timer.
16140
- *
16141
- * When the schedule ends, the stream emits the current aggregation and any sink
16142
- * leftovers, then ends without pulling more from upstream.
16143
- *
16144
- * **Example** (Aggregating with a sink and schedule)
16145
- *
16146
- * ```ts import.meta.vitest
16147
- * import { Effect, Schedule, Sink, Stream } from "effect"
16148
- *
16149
- * await Effect.runPromise(Effect.gen(function* () {
16150
- * const aggregated = yield* Stream.runCollect(
16151
- * Stream.make(1, 2, 3, 4, 5, 6).pipe(
16152
- * Stream.aggregateWithin(
16153
- * Sink.foldUntil(() => 0, 3, (sum, n) => Effect.succeed(sum + n)),
16154
- * Schedule.forever
16155
- * )
16156
- * )
16157
- * )
16158
- * aggregated // => [ 6, 15 ]
16159
- * }))
16160
- * ```
16161
- *
16162
- * @stability stable
16163
- * @category aggregation
16164
- * @since 2.0.0
16165
- */
16166
- B>()
15618
+ let lastOutput = Option.none<B>()
16167
15619
  let leftover: Arr.NonEmptyReadonlyArray<A2> | undefined
16168
15620
  const onInput = <X>(chunk: X): Effect.Effect<X> => {
16169
15621
  if (hasInput.openUnsafe()) {
@@ -16207,7 +15659,7 @@ export const aggregateWithin: {
16207
15659
  return buffer.state.exit as Exit.Exit<never, Cause.Done<void> | E>
16208
15660
  }
16209
15661
  hasInput.closeUnsafe()
16210
- const pull = emit(Effect.suspend(() => sink.transform(sinkUpstream as any, scope)))
15662
+ const pull = emit(Effect.suspend(() => runSink(sink, sinkUpstream, scope)))
16211
15663
  return buffer.state._tag === "Open" ? Effect.raceFirst(pull, stepToBuffer) : pull
16212
15664
  })
16213
15665
  }))))
@@ -16374,47 +15826,7 @@ export const broadcastN: {
16374
15826
  }
16375
15827
  ) {
16376
15828
  const n = Count.normalize(options.n)
16377
- const pubsub = yield* makePubSub</**
16378
- * Creates a fixed-size tuple of streams that each emit
16379
- * the same elements as the source stream.
16380
- *
16381
- * **Details**
16382
- *
16383
- * The source stream starts after all downstream streams have been subscribed.
16384
- * With the default suspend strategy, the source can only advance `capacity`
16385
- * chunks ahead of the slowest downstream stream. If a downstream stream is
16386
- * interrupted, it unsubscribes from the broadcast so it no longer contributes
16387
- * backpressure. Finite fractional values of `n` are rounded down. `NaN` and
16388
- * non-positive values create no downstream streams.
16389
- *
16390
- * **Example** (Broadcasting to two consumers)
16391
- *
16392
- * ```ts import.meta.vitest
16393
- * import { Effect, Stream } from "effect"
16394
- *
16395
- * const program = Effect.scoped(
16396
- * Effect.gen(function*() {
16397
- * const [left, right] = yield* Stream.make(1, 2, 3).pipe(
16398
- * Stream.broadcastN({ n: 2, capacity: 8 })
16399
- * )
16400
- *
16401
- * const values = yield* Effect.all([
16402
- * Stream.runCollect(left),
16403
- * Stream.runCollect(right)
16404
- * ], { concurrency: "unbounded" })
16405
- *
16406
- * values // => [ [ 1, 2, 3 ], [ 1, 2, 3 ] ]
16407
- * })
16408
- * )
16409
- *
16410
- * await Effect.runPromise(program)
16411
- * ```
16412
- *
16413
- * @stability stable
16414
- * @category broadcasting
16415
- * @since 4.0.0
16416
- */
16417
- Take.Take<A, E>>(options)
15829
+ const pubsub = yield* makePubSub<Take.Take<A, E>>(options)
16418
15830
  const streams = new Array(n)
16419
15831
  const parentScope = yield* Scope.Scope
16420
15832
  for (let i = 0; i < n; i++) {
@@ -17469,10 +16881,10 @@ export const decodeText: <
17469
16881
  <E, R>(self: Stream<Uint8Array, E, R>, options?: {
17470
16882
  readonly encoding?: string | undefined
17471
16883
  }): Stream<string, E, R> =>
17472
- suspend(() => {
17473
- const decoder = new TextDecoder(options?.encoding)
17474
- return map(self, (chunk) => decoder.decode(chunk, { stream: true }))
17475
- })
16884
+ self.channel.pipe(
16885
+ Channel.pipeTo(Channel.decodeText(options?.encoding)),
16886
+ fromChannel
16887
+ )
17476
16888
  )
17477
16889
 
17478
16890
  /**
@@ -17923,39 +17335,7 @@ export const interleaveWith: {
17923
17335
  )).pipe(
17924
17336
  Pull.catchDone(() => {
17925
17337
  leftDone = true
17926
- return Effect.succeed</**
17927
- * Interleaves two streams deterministically by following a boolean decider stream.
17928
- *
17929
- * **Details**
17930
- *
17931
- * The decider controls how many elements are pulled; if one side ends, pulls for
17932
- * that side are ignored.
17933
- *
17934
- * **Example** (Interleaving two streams deterministically by following a boolean decider stream)
17935
- *
17936
- * ```ts import.meta.vitest
17937
- * import { Effect, Stream } from "effect"
17938
- *
17939
- * const program = Effect.gen(function*() {
17940
- * const left = Stream.make(1, 3, 5)
17941
- * const right = Stream.make(2, 4, 6)
17942
- * const decider = Stream.make(true, false, false, true, true)
17943
- *
17944
- * const values = yield* Stream.runCollect(
17945
- * Stream.interleaveWith(left, right, decider)
17946
- * )
17947
- *
17948
- * values // => [ 1, 2, 4, 3, 5 ]
17949
- * })
17950
- *
17951
- * await Effect.runPromise(program)
17952
- * ```
17953
- *
17954
- * @stability stable
17955
- * @category merging
17956
- * @since 2.0.0
17957
- */
17958
- retry>(retry);
17338
+ return Effect.succeed<retry>(retry)
17959
17339
  })
17960
17340
  )
17961
17341
  const pullRight = (yield* Channel.toTransform(Channel.flattenArray(that.channel))(
@@ -17964,39 +17344,7 @@ export const interleaveWith: {
17964
17344
  )).pipe(
17965
17345
  Pull.catchDone(() => {
17966
17346
  rightDone = true
17967
- return Effect.succeed</**
17968
- * Interleaves two streams deterministically by following a boolean decider stream.
17969
- *
17970
- * **Details**
17971
- *
17972
- * The decider controls how many elements are pulled; if one side ends, pulls for
17973
- * that side are ignored.
17974
- *
17975
- * **Example** (Interleaving two streams deterministically by following a boolean decider stream)
17976
- *
17977
- * ```ts import.meta.vitest
17978
- * import { Effect, Stream } from "effect"
17979
- *
17980
- * const program = Effect.gen(function*() {
17981
- * const left = Stream.make(1, 3, 5)
17982
- * const right = Stream.make(2, 4, 6)
17983
- * const decider = Stream.make(true, false, false, true, true)
17984
- *
17985
- * const values = yield* Stream.runCollect(
17986
- * Stream.interleaveWith(left, right, decider)
17987
- * )
17988
- *
17989
- * values // => [ 1, 2, 4, 3, 5 ]
17990
- * })
17991
- *
17992
- * await Effect.runPromise(program)
17993
- * ```
17994
- *
17995
- * @stability stable
17996
- * @category merging
17997
- * @since 2.0.0
17998
- */
17999
- retry>(retry);
17347
+ return Effect.succeed<retry>(retry)
18000
17348
  })
18001
17349
  )
18002
17350
 
@@ -18804,7 +18152,8 @@ export const ensuring: {
18804
18152
  /**
18805
18153
  * Provides a layer or context to the stream, removing the corresponding
18806
18154
  * service requirements. Use `options.local` to build the layer every time; by
18807
- * default, layers are shared between provide calls.
18155
+ * default, a layer already built by an enclosing provide or runtime is reused;
18156
+ * sibling provide calls build their own copies.
18808
18157
  *
18809
18158
  * **Example** (Providing stream requirements)
18810
18159
  *
@@ -18835,7 +18184,8 @@ export const provide: {
18835
18184
  /**
18836
18185
  * Provides a layer or context to the stream, removing the corresponding
18837
18186
  * service requirements. Use `options.local` to build the layer every time; by
18838
- * default, layers are shared between provide calls.
18187
+ * default, a layer already built by an enclosing provide or runtime is reused;
18188
+ * sibling provide calls build their own copies.
18839
18189
  *
18840
18190
  * **Example** (Providing stream requirements)
18841
18191
  *
@@ -18873,7 +18223,8 @@ export const provide: {
18873
18223
  /**
18874
18224
  * Provides a layer or context to the stream, removing the corresponding
18875
18225
  * service requirements. Use `options.local` to build the layer every time; by
18876
- * default, layers are shared between provide calls.
18226
+ * default, a layer already built by an enclosing provide or runtime is reused;
18227
+ * sibling provide calls build their own copies.
18877
18228
  *
18878
18229
  * **Example** (Providing stream requirements)
18879
18230
  *
@@ -19976,11 +19327,28 @@ export const run: {
19976
19327
  ): Effect.Effect<A2, E | E2, R | R2> =>
19977
19328
  Effect.scopedWith((scope) =>
19978
19329
  Channel.toPullScoped(self.channel, scope).pipe(
19979
- Effect.flatMap((upstream) => sink.transform(upstream as any, scope)),
19330
+ Effect.flatMap((upstream) => runSink(sink, upstream, scope)),
19980
19331
  Effect.map(([a]) => a)
19981
19332
  )
19982
19333
  ))
19983
19334
 
19335
+ /**
19336
+ * Runs `sink` against `upstream`. Upstream failures bypass the sink's error
19337
+ * handlers and are restored once the sink has exited.
19338
+ */
19339
+ const runSink = <A, E, R, A2, L, E2, R2>(
19340
+ sink: Sink.Sink<A2, A, L, E2, R2>,
19341
+ upstream: Pull.Pull<Arr.NonEmptyReadonlyArray<A>, E, void, R>,
19342
+ scope: Scope.Scope
19343
+ ): Effect.Effect<Sink.End<A2, L>, E | E2, R | R2> =>
19344
+ Channel.restoreUpstreamFailure<Sink.End<A2, L>, E | E2, R2>(
19345
+ // The upstream pull runs in this fiber, which already provides `R`.
19346
+ sink.transform(
19347
+ Channel.upstreamFailureToDefect(upstream) as Pull.Pull<Arr.NonEmptyReadonlyArray<A>, never, void>,
19348
+ scope
19349
+ )
19350
+ )
19351
+
19984
19352
  /**
19985
19353
  * Runs the stream and collects all elements into an array.
19986
19354
  *
@@ -20752,7 +20120,7 @@ export const mkArrayBuffer = <E, R>(self: Stream<Uint8Array, E, R>): Effect.Effe
20752
20120
  * @category destructors
20753
20121
  * @since 4.0.0
20754
20122
  */
20755
- export const mkUint8Array = <E, R>(self: Stream<Uint8Array, E, R>): Effect.Effect<Uint8Array, E, R> =>
20123
+ export const mkUint8Array = <E, R>(self: Stream<Uint8Array, E, R>): Effect.Effect<Uint8Array<ArrayBuffer>, E, R> =>
20756
20124
  Channel.mkUint8Array(self.channel)
20757
20125
 
20758
20126
  /**
@@ -20882,15 +20250,18 @@ export const toReadableStreamWith: {
20882
20250
  return new ReadableStream<A>({
20883
20251
  start(controller) {
20884
20252
  fiber = Effect.runFork(Effect.provideContext(
20885
- runForEachArray(self, (chunk) =>
20886
- latch.whenOpen(Effect.sync(() => {
20887
- latch.closeUnsafe()
20888
- for (let i = 0; i < chunk.length; i++) {
20889
- controller.enqueue(chunk[i])
20890
- }
20891
- currentResolve!()
20892
- currentResolve = undefined
20893
- }))),
20253
+ Channel.runForEach(
20254
+ Channel.transformPull(self.channel, (pull) => Effect.succeed(latch.whenOpen(pull))),
20255
+ (chunk) =>
20256
+ Effect.sync(() => {
20257
+ latch.closeUnsafe()
20258
+ for (let i = 0; i < chunk.length; i++) {
20259
+ controller.enqueue(chunk[i])
20260
+ }
20261
+ currentResolve!()
20262
+ currentResolve = undefined
20263
+ })
20264
+ ),
20894
20265
  context
20895
20266
  ))
20896
20267
  fiber.addObserver((exit) => {
@@ -21109,38 +20480,7 @@ export const toReadableStreamEffect: {
21109
20480
  options?: { readonly strategy?: QueuingStrategy<A> | undefined }
21110
20481
  ): Effect.Effect<ReadableStream<A>, never, R> =>
21111
20482
  Effect.map(
21112
- Effect.context</**
21113
- * Creates an Effect that builds a ReadableStream from the stream.
21114
- *
21115
- * **When to use**
21116
- *
21117
- * Use when bridging to Web Streams from inside an `Effect` so the required
21118
- * services can be captured from the current context.
21119
- *
21120
- * **Details**
21121
- *
21122
- * See https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream.
21123
- *
21124
- * **Example** (Creating a ReadableStream effect)
21125
- *
21126
- * ```ts import.meta.vitest
21127
- * import { Effect, Stream } from "effect"
21128
- *
21129
- * const stream = Stream.make(1, 2, 3, 4, 5)
21130
- *
21131
- * const effect = Effect.gen(function*() {
21132
- * const readableStream = yield* Stream.toReadableStreamEffect(stream)
21133
- * readableStream instanceof ReadableStream // => true
21134
- * })
21135
- *
21136
- * await Effect.runPromise(effect)
21137
- * ```
21138
- *
21139
- * @stability stable
21140
- * @category destructors
21141
- * @since 2.0.0
21142
- */
21143
- R>(),
20483
+ Effect.context<R>(),
21144
20484
  (context) => toReadableStreamWith(self, context, options)
21145
20485
  )
21146
20486
  )