effect 4.0.0-beta.103 → 4.0.0-beta.104

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 (523) hide show
  1. package/dist/Cache.js +1 -1
  2. package/dist/Cache.js.map +1 -1
  3. package/dist/Channel.d.ts +1 -1
  4. package/dist/Channel.d.ts.map +1 -1
  5. package/dist/Channel.js.map +1 -1
  6. package/dist/Config.d.ts.map +1 -1
  7. package/dist/Config.js +28 -7
  8. package/dist/Config.js.map +1 -1
  9. package/dist/ConfigProvider.d.ts.map +1 -1
  10. package/dist/ConfigProvider.js +2 -1
  11. package/dist/ConfigProvider.js.map +1 -1
  12. package/dist/Context.d.ts +2 -2
  13. package/dist/Context.d.ts.map +1 -1
  14. package/dist/Context.js.map +1 -1
  15. package/dist/Crypto.d.ts.map +1 -1
  16. package/dist/Crypto.js +13 -5
  17. package/dist/Crypto.js.map +1 -1
  18. package/dist/Duration.d.ts.map +1 -1
  19. package/dist/Duration.js +12 -1
  20. package/dist/Duration.js.map +1 -1
  21. package/dist/Effect.d.ts +132 -14
  22. package/dist/Effect.d.ts.map +1 -1
  23. package/dist/Effect.js +38 -0
  24. package/dist/Effect.js.map +1 -1
  25. package/dist/Equal.d.ts.map +1 -1
  26. package/dist/Equal.js +10 -2
  27. package/dist/Equal.js.map +1 -1
  28. package/dist/ExecutionPlan.d.ts +73 -0
  29. package/dist/ExecutionPlan.d.ts.map +1 -1
  30. package/dist/ExecutionPlan.js +1 -1
  31. package/dist/ExecutionPlan.js.map +1 -1
  32. package/dist/FiberSet.js +1 -1
  33. package/dist/FileSystem.d.ts +2 -2
  34. package/dist/Function.d.ts +4 -3
  35. package/dist/Function.d.ts.map +1 -1
  36. package/dist/Function.js +5 -5
  37. package/dist/Function.js.map +1 -1
  38. package/dist/Iterable.d.ts.map +1 -1
  39. package/dist/Iterable.js +11 -10
  40. package/dist/Iterable.js.map +1 -1
  41. package/dist/Layer.d.ts.map +1 -1
  42. package/dist/Layer.js +7 -5
  43. package/dist/Layer.js.map +1 -1
  44. package/dist/Schedule.d.ts +8 -8
  45. package/dist/Schedule.d.ts.map +1 -1
  46. package/dist/Schedule.js +4 -4
  47. package/dist/Schedule.js.map +1 -1
  48. package/dist/Schema.d.ts +32 -32
  49. package/dist/Schema.d.ts.map +1 -1
  50. package/dist/Schema.js +23 -18
  51. package/dist/Schema.js.map +1 -1
  52. package/dist/SchemaAST.d.ts +3 -3
  53. package/dist/SchemaAST.d.ts.map +1 -1
  54. package/dist/SchemaAST.js +47 -31
  55. package/dist/SchemaAST.js.map +1 -1
  56. package/dist/SchemaParser.d.ts.map +1 -1
  57. package/dist/SchemaParser.js +35 -53
  58. package/dist/SchemaParser.js.map +1 -1
  59. package/dist/ScopedCache.js +1 -1
  60. package/dist/ScopedCache.js.map +1 -1
  61. package/dist/Sink.d.ts +1 -1
  62. package/dist/Sink.d.ts.map +1 -1
  63. package/dist/Stream.d.ts +27 -4
  64. package/dist/Stream.d.ts.map +1 -1
  65. package/dist/Stream.js +27 -2
  66. package/dist/Stream.js.map +1 -1
  67. package/dist/SynchronizedRef.js +1 -1
  68. package/dist/SynchronizedRef.js.map +1 -1
  69. package/dist/Terminal.js +1 -1
  70. package/dist/Terminal.js.map +1 -1
  71. package/dist/Tuple.d.ts +6 -4
  72. package/dist/Tuple.d.ts.map +1 -1
  73. package/dist/Tuple.js.map +1 -1
  74. package/dist/TxReentrantLock.d.ts +0 -56
  75. package/dist/TxReentrantLock.d.ts.map +1 -1
  76. package/dist/TxReentrantLock.js +8 -8
  77. package/dist/TxReentrantLock.js.map +1 -1
  78. package/dist/internal/dateTime.js +1 -1
  79. package/dist/internal/dateTime.js.map +1 -1
  80. package/dist/internal/executionPlan.js +51 -3
  81. package/dist/internal/executionPlan.js.map +1 -1
  82. package/dist/internal/hashMap.js +12 -8
  83. package/dist/internal/hashMap.js.map +1 -1
  84. package/dist/internal/matcher.js +1 -1
  85. package/dist/internal/matcher.js.map +1 -1
  86. package/dist/internal/schedule.js.map +1 -1
  87. package/dist/internal/schema/annotations.js +2 -0
  88. package/dist/internal/schema/annotations.js.map +1 -1
  89. package/dist/internal/schema/toArbitrary.js +1 -1
  90. package/dist/internal/schema/toArbitrary.js.map +1 -1
  91. package/dist/internal/trie.js +13 -3
  92. package/dist/internal/trie.js.map +1 -1
  93. package/dist/testing/TestClock.d.ts.map +1 -1
  94. package/dist/testing/TestClock.js +11 -1
  95. package/dist/testing/TestClock.js.map +1 -1
  96. package/dist/testing/TestSchema.d.ts +1 -1
  97. package/dist/testing/TestSchema.d.ts.map +1 -1
  98. package/dist/unstable/ai/AiError.js +19 -19
  99. package/dist/unstable/ai/AiError.js.map +1 -1
  100. package/dist/unstable/ai/Chat.js +1 -1
  101. package/dist/unstable/ai/Chat.js.map +1 -1
  102. package/dist/unstable/ai/LanguageModel.js +4 -2
  103. package/dist/unstable/ai/LanguageModel.js.map +1 -1
  104. package/dist/unstable/ai/McpSchema.d.ts +132 -132
  105. package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
  106. package/dist/unstable/ai/McpSchema.js +8 -8
  107. package/dist/unstable/ai/McpSchema.js.map +1 -1
  108. package/dist/unstable/ai/McpServer.js +1 -1
  109. package/dist/unstable/ai/McpServer.js.map +1 -1
  110. package/dist/unstable/ai/Prompt.d.ts +15 -3
  111. package/dist/unstable/ai/Prompt.d.ts.map +1 -1
  112. package/dist/unstable/ai/Prompt.js +6 -3
  113. package/dist/unstable/ai/Prompt.js.map +1 -1
  114. package/dist/unstable/cli/CliError.d.ts +3 -3
  115. package/dist/unstable/cli/CliError.js +11 -11
  116. package/dist/unstable/cli/CliError.js.map +1 -1
  117. package/dist/unstable/cli/Command.d.ts +9 -9
  118. package/dist/unstable/cli/Command.d.ts.map +1 -1
  119. package/dist/unstable/cli/Command.js +8 -6
  120. package/dist/unstable/cli/Command.js.map +1 -1
  121. package/dist/unstable/cli/Param.d.ts +7 -5
  122. package/dist/unstable/cli/Param.d.ts.map +1 -1
  123. package/dist/unstable/cli/Param.js +15 -11
  124. package/dist/unstable/cli/Param.js.map +1 -1
  125. package/dist/unstable/cli/Primitive.d.ts.map +1 -1
  126. package/dist/unstable/cli/Primitive.js +31 -24
  127. package/dist/unstable/cli/Primitive.js.map +1 -1
  128. package/dist/unstable/cli/Prompt.d.ts.map +1 -1
  129. package/dist/unstable/cli/Prompt.js +31 -17
  130. package/dist/unstable/cli/Prompt.js.map +1 -1
  131. package/dist/unstable/cli/internal/ansi.js +2 -2
  132. package/dist/unstable/cli/internal/ansi.js.map +1 -1
  133. package/dist/unstable/cli/internal/command.d.ts +2 -2
  134. package/dist/unstable/cli/internal/command.d.ts.map +1 -1
  135. package/dist/unstable/cli/internal/command.js +10 -9
  136. package/dist/unstable/cli/internal/command.js.map +1 -1
  137. package/dist/unstable/cli/internal/completions/bash.js +69 -9
  138. package/dist/unstable/cli/internal/completions/bash.js.map +1 -1
  139. package/dist/unstable/cli/internal/completions/descriptor.js +24 -18
  140. package/dist/unstable/cli/internal/completions/descriptor.js.map +1 -1
  141. package/dist/unstable/cli/internal/completions/fish.js +5 -5
  142. package/dist/unstable/cli/internal/completions/fish.js.map +1 -1
  143. package/dist/unstable/cli/internal/help.d.ts.map +1 -1
  144. package/dist/unstable/cli/internal/help.js +4 -2
  145. package/dist/unstable/cli/internal/help.js.map +1 -1
  146. package/dist/unstable/cli/internal/parser.js +3 -3
  147. package/dist/unstable/cli/internal/parser.js.map +1 -1
  148. package/dist/unstable/cli/internal/wizard.js +2 -2
  149. package/dist/unstable/cli/internal/wizard.js.map +1 -1
  150. package/dist/unstable/cluster/ClusterError.js +7 -7
  151. package/dist/unstable/cluster/ClusterError.js.map +1 -1
  152. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
  153. package/dist/unstable/cluster/ClusterWorkflowEngine.js +1 -1
  154. package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
  155. package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
  156. package/dist/unstable/cluster/MessageStorage.js +8 -1
  157. package/dist/unstable/cluster/MessageStorage.js.map +1 -1
  158. package/dist/unstable/cluster/Reply.d.ts +8 -0
  159. package/dist/unstable/cluster/Reply.d.ts.map +1 -1
  160. package/dist/unstable/cluster/Reply.js +12 -0
  161. package/dist/unstable/cluster/Reply.js.map +1 -1
  162. package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
  163. package/dist/unstable/cluster/RunnerServer.js +4 -2
  164. package/dist/unstable/cluster/RunnerServer.js.map +1 -1
  165. package/dist/unstable/cluster/RunnerStorage.d.ts +1 -2
  166. package/dist/unstable/cluster/RunnerStorage.d.ts.map +1 -1
  167. package/dist/unstable/cluster/RunnerStorage.js +7 -6
  168. package/dist/unstable/cluster/RunnerStorage.js.map +1 -1
  169. package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
  170. package/dist/unstable/cluster/Sharding.js +22 -4
  171. package/dist/unstable/cluster/Sharding.js.map +1 -1
  172. package/dist/unstable/cluster/internal/entityManager.js +1 -1
  173. package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
  174. package/dist/unstable/cluster/internal/resourceMap.js +2 -2
  175. package/dist/unstable/cluster/internal/resourceMap.js.map +1 -1
  176. package/dist/unstable/cluster/internal/resourceRef.js +17 -0
  177. package/dist/unstable/cluster/internal/resourceRef.js.map +1 -1
  178. package/dist/unstable/devtools/DevToolsClient.d.ts.map +1 -1
  179. package/dist/unstable/devtools/DevToolsClient.js +7 -2
  180. package/dist/unstable/devtools/DevToolsClient.js.map +1 -1
  181. package/dist/unstable/encoding/Ini.d.ts +20 -0
  182. package/dist/unstable/encoding/Ini.d.ts.map +1 -0
  183. package/dist/unstable/encoding/Ini.js +153 -0
  184. package/dist/unstable/encoding/Ini.js.map +1 -0
  185. package/dist/unstable/encoding/Msgpack.d.ts +2 -1
  186. package/dist/unstable/encoding/Msgpack.d.ts.map +1 -1
  187. package/dist/unstable/encoding/Msgpack.js +21 -7
  188. package/dist/unstable/encoding/Msgpack.js.map +1 -1
  189. package/dist/unstable/encoding/Ndjson.d.ts.map +1 -1
  190. package/dist/unstable/encoding/Ndjson.js +7 -1
  191. package/dist/unstable/encoding/Ndjson.js.map +1 -1
  192. package/dist/unstable/encoding/Sse.d.ts.map +1 -1
  193. package/dist/unstable/encoding/Sse.js +14 -23
  194. package/dist/unstable/encoding/Sse.js.map +1 -1
  195. package/dist/unstable/encoding/Toml.d.ts +19 -0
  196. package/dist/unstable/encoding/Toml.d.ts.map +1 -0
  197. package/dist/unstable/encoding/Toml.js +434 -0
  198. package/dist/unstable/encoding/Toml.js.map +1 -0
  199. package/dist/unstable/encoding/Yaml.d.ts +19 -0
  200. package/dist/unstable/encoding/Yaml.d.ts.map +1 -0
  201. package/dist/unstable/encoding/Yaml.js +461 -0
  202. package/dist/unstable/encoding/Yaml.js.map +1 -0
  203. package/dist/unstable/encoding/index.d.ts +12 -0
  204. package/dist/unstable/encoding/index.d.ts.map +1 -1
  205. package/dist/unstable/encoding/index.js +12 -0
  206. package/dist/unstable/encoding/index.js.map +1 -1
  207. package/dist/unstable/eventlog/EventJournal.d.ts +1 -1
  208. package/dist/unstable/eventlog/EventJournal.d.ts.map +1 -1
  209. package/dist/unstable/eventlog/EventJournal.js +13 -5
  210. package/dist/unstable/eventlog/EventJournal.js.map +1 -1
  211. package/dist/unstable/eventlog/EventLogMessage.js +1 -1
  212. package/dist/unstable/eventlog/EventLogMessage.js.map +1 -1
  213. package/dist/unstable/eventlog/EventLogServerUnencrypted.js +1 -1
  214. package/dist/unstable/eventlog/EventLogServerUnencrypted.js.map +1 -1
  215. package/dist/unstable/eventlog/SqlEventJournal.d.ts.map +1 -1
  216. package/dist/unstable/eventlog/SqlEventJournal.js +1 -4
  217. package/dist/unstable/eventlog/SqlEventJournal.js.map +1 -1
  218. package/dist/unstable/http/FindMyWay/internal/queryString.d.ts +11 -0
  219. package/dist/unstable/http/FindMyWay/internal/queryString.d.ts.map +1 -0
  220. package/dist/unstable/http/FindMyWay/internal/queryString.js +259 -0
  221. package/dist/unstable/http/FindMyWay/internal/queryString.js.map +1 -0
  222. package/dist/unstable/http/FindMyWay/internal/router.d.ts +2 -0
  223. package/dist/unstable/http/FindMyWay/internal/router.d.ts.map +1 -0
  224. package/dist/unstable/http/FindMyWay/internal/router.js +665 -0
  225. package/dist/unstable/http/FindMyWay/internal/router.js.map +1 -0
  226. package/dist/unstable/http/FindMyWay.d.ts +33 -8
  227. package/dist/unstable/http/FindMyWay.d.ts.map +1 -1
  228. package/dist/unstable/http/FindMyWay.js +4 -7
  229. package/dist/unstable/http/FindMyWay.js.map +1 -1
  230. package/dist/unstable/http/HttpClientError.js +1 -1
  231. package/dist/unstable/http/HttpClientError.js.map +1 -1
  232. package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
  233. package/dist/unstable/http/HttpClientRequest.js +2 -14
  234. package/dist/unstable/http/HttpClientRequest.js.map +1 -1
  235. package/dist/unstable/http/HttpClientResponse.js +1 -16
  236. package/dist/unstable/http/HttpClientResponse.js.map +1 -1
  237. package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
  238. package/dist/unstable/http/HttpPlatform.js +21 -3
  239. package/dist/unstable/http/HttpPlatform.js.map +1 -1
  240. package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
  241. package/dist/unstable/http/HttpServerRequest.js +7 -6
  242. package/dist/unstable/http/HttpServerRequest.js.map +1 -1
  243. package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
  244. package/dist/unstable/http/HttpServerResponse.js +8 -6
  245. package/dist/unstable/http/HttpServerResponse.js.map +1 -1
  246. package/dist/unstable/http/Multipart.d.ts +1 -1
  247. package/dist/unstable/http/Multipart.d.ts.map +1 -1
  248. package/dist/unstable/http/Multipart.js +9 -2
  249. package/dist/unstable/http/Multipart.js.map +1 -1
  250. package/dist/unstable/http/MultipartParser/HeadersParser.d.ts +53 -0
  251. package/dist/unstable/http/MultipartParser/HeadersParser.d.ts.map +1 -0
  252. package/dist/unstable/http/MultipartParser/HeadersParser.js +14 -0
  253. package/dist/unstable/http/MultipartParser/HeadersParser.js.map +1 -0
  254. package/dist/unstable/http/MultipartParser/Search.d.ts +11 -0
  255. package/dist/unstable/http/MultipartParser/Search.d.ts.map +1 -0
  256. package/dist/unstable/http/MultipartParser/Search.js +14 -0
  257. package/dist/unstable/http/MultipartParser/Search.js.map +1 -0
  258. package/dist/unstable/http/MultipartParser/internal/contentType.d.ts +5 -0
  259. package/dist/unstable/http/MultipartParser/internal/contentType.d.ts.map +1 -0
  260. package/dist/unstable/http/MultipartParser/internal/contentType.js +82 -0
  261. package/dist/unstable/http/MultipartParser/internal/contentType.js.map +1 -0
  262. package/dist/unstable/http/MultipartParser/internal/headers.d.ts +3 -0
  263. package/dist/unstable/http/MultipartParser/internal/headers.d.ts.map +1 -0
  264. package/dist/unstable/http/MultipartParser/internal/headers.js +194 -0
  265. package/dist/unstable/http/MultipartParser/internal/headers.js.map +1 -0
  266. package/dist/unstable/http/MultipartParser/internal/multipart.d.ts +8 -0
  267. package/dist/unstable/http/MultipartParser/internal/multipart.d.ts.map +1 -0
  268. package/dist/unstable/http/MultipartParser/internal/multipart.js +226 -0
  269. package/dist/unstable/http/MultipartParser/internal/multipart.js.map +1 -0
  270. package/dist/unstable/http/MultipartParser/internal/search.d.ts +5 -0
  271. package/dist/unstable/http/MultipartParser/internal/search.d.ts.map +1 -0
  272. package/dist/unstable/http/MultipartParser/internal/search.js +120 -0
  273. package/dist/unstable/http/MultipartParser/internal/search.js.map +1 -0
  274. package/dist/unstable/http/MultipartParser.d.ts +98 -0
  275. package/dist/unstable/http/MultipartParser.d.ts.map +1 -0
  276. package/dist/unstable/http/MultipartParser.js +23 -0
  277. package/dist/unstable/http/MultipartParser.js.map +1 -0
  278. package/dist/unstable/http/Template.d.ts.map +1 -1
  279. package/dist/unstable/http/Template.js +2 -2
  280. package/dist/unstable/http/Template.js.map +1 -1
  281. package/dist/unstable/http/index.d.ts +1 -1
  282. package/dist/unstable/http/index.d.ts.map +1 -1
  283. package/dist/unstable/http/index.js +1 -1
  284. package/dist/unstable/http/index.js.map +1 -1
  285. package/dist/unstable/http/internal/httpBody.d.ts +2 -0
  286. package/dist/unstable/http/internal/httpBody.d.ts.map +1 -0
  287. package/dist/unstable/http/internal/httpBody.js +10 -0
  288. package/dist/unstable/http/internal/httpBody.js.map +1 -0
  289. package/dist/unstable/httpapi/HttpApi.d.ts.map +1 -1
  290. package/dist/unstable/httpapi/HttpApi.js +5 -5
  291. package/dist/unstable/httpapi/HttpApi.js.map +1 -1
  292. package/dist/unstable/httpapi/HttpApiBuilder.js +68 -15
  293. package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
  294. package/dist/unstable/httpapi/HttpApiClient.d.ts +1 -1
  295. package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
  296. package/dist/unstable/httpapi/HttpApiClient.js +65 -25
  297. package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
  298. package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +6 -4
  299. package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
  300. package/dist/unstable/httpapi/HttpApiEndpoint.js +73 -16
  301. package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
  302. package/dist/unstable/httpapi/HttpApiError.d.ts +5 -5
  303. package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
  304. package/dist/unstable/httpapi/HttpApiError.js +17 -17
  305. package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
  306. package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +1 -1
  307. package/dist/unstable/httpapi/HttpApiMiddleware.js +1 -1
  308. package/dist/unstable/httpapi/HttpApiSchema.d.ts +219 -0
  309. package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
  310. package/dist/unstable/httpapi/HttpApiSchema.js +170 -0
  311. package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
  312. package/dist/unstable/httpapi/OpenApi.d.ts +8 -0
  313. package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
  314. package/dist/unstable/httpapi/OpenApi.js +45 -18
  315. package/dist/unstable/httpapi/OpenApi.js.map +1 -1
  316. package/dist/unstable/observability/OtlpExporter.d.ts +1 -1
  317. package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
  318. package/dist/unstable/observability/OtlpExporter.js +2 -1
  319. package/dist/unstable/observability/OtlpExporter.js.map +1 -1
  320. package/dist/unstable/observability/OtlpLogger.d.ts.map +1 -1
  321. package/dist/unstable/observability/OtlpLogger.js +2 -2
  322. package/dist/unstable/observability/OtlpLogger.js.map +1 -1
  323. package/dist/unstable/observability/OtlpMetrics.d.ts +2 -2
  324. package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
  325. package/dist/unstable/observability/OtlpMetrics.js +28 -15
  326. package/dist/unstable/observability/OtlpMetrics.js.map +1 -1
  327. package/dist/unstable/observability/OtlpTracer.js +1 -1
  328. package/dist/unstable/observability/OtlpTracer.js.map +1 -1
  329. package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
  330. package/dist/unstable/persistence/PersistedQueue.js +9 -9
  331. package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
  332. package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
  333. package/dist/unstable/persistence/Persistence.js +17 -7
  334. package/dist/unstable/persistence/Persistence.js.map +1 -1
  335. package/dist/unstable/persistence/RateLimiter.d.ts +22 -12
  336. package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
  337. package/dist/unstable/persistence/RateLimiter.js +15 -42
  338. package/dist/unstable/persistence/RateLimiter.js.map +1 -1
  339. package/dist/unstable/persistence/Redis.js +1 -1
  340. package/dist/unstable/persistence/Redis.js.map +1 -1
  341. package/dist/unstable/rpc/RpcClient.d.ts +14 -0
  342. package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
  343. package/dist/unstable/rpc/RpcClient.js +18 -9
  344. package/dist/unstable/rpc/RpcClient.js.map +1 -1
  345. package/dist/unstable/rpc/RpcClientError.js +2 -2
  346. package/dist/unstable/rpc/RpcClientError.js.map +1 -1
  347. package/dist/unstable/rpc/RpcSerialization.js +3 -1
  348. package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
  349. package/dist/unstable/schema/Model.d.ts +1 -1
  350. package/dist/unstable/schema/Model.d.ts.map +1 -1
  351. package/dist/unstable/schema/VariantSchema.d.ts +5 -5
  352. package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
  353. package/dist/unstable/schema/VariantSchema.js +17 -9
  354. package/dist/unstable/schema/VariantSchema.js.map +1 -1
  355. package/dist/unstable/socket/Socket.d.ts.map +1 -1
  356. package/dist/unstable/socket/Socket.js +28 -12
  357. package/dist/unstable/socket/Socket.js.map +1 -1
  358. package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
  359. package/dist/unstable/sql/SqlClient.js +7 -3
  360. package/dist/unstable/sql/SqlClient.js.map +1 -1
  361. package/dist/unstable/sql/SqlError.js +13 -13
  362. package/dist/unstable/sql/SqlError.js.map +1 -1
  363. package/dist/unstable/sql/SqlResolver.js +8 -6
  364. package/dist/unstable/sql/SqlResolver.js.map +1 -1
  365. package/dist/unstable/sql/Statement.d.ts.map +1 -1
  366. package/dist/unstable/sql/Statement.js +8 -6
  367. package/dist/unstable/sql/Statement.js.map +1 -1
  368. package/dist/unstable/workers/WorkerError.js +5 -5
  369. package/dist/unstable/workers/WorkerError.js.map +1 -1
  370. package/dist/unstable/workflow/WorkflowEngine.d.ts +1 -1
  371. package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
  372. package/dist/unstable/workflow/WorkflowEngine.js +3 -3
  373. package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
  374. package/package.json +2 -8
  375. package/src/Cache.ts +1 -1
  376. package/src/Channel.ts +1 -1
  377. package/src/Config.ts +28 -7
  378. package/src/ConfigProvider.ts +4 -1
  379. package/src/Context.ts +5 -5
  380. package/src/Crypto.ts +17 -8
  381. package/src/Duration.ts +16 -2
  382. package/src/Effect.ts +141 -17
  383. package/src/Equal.ts +10 -2
  384. package/src/ExecutionPlan.ts +78 -1
  385. package/src/FiberSet.ts +1 -1
  386. package/src/FileSystem.ts +2 -2
  387. package/src/Function.ts +6 -6
  388. package/src/Iterable.ts +11 -10
  389. package/src/Layer.ts +7 -5
  390. package/src/Schedule.ts +13 -13
  391. package/src/Schema.ts +50 -41
  392. package/src/SchemaAST.ts +69 -37
  393. package/src/SchemaParser.ts +75 -69
  394. package/src/ScopedCache.ts +1 -1
  395. package/src/Sink.ts +1 -1
  396. package/src/Stream.ts +77 -10
  397. package/src/SynchronizedRef.ts +1 -1
  398. package/src/Terminal.ts +1 -1
  399. package/src/Tuple.ts +7 -4
  400. package/src/TxReentrantLock.ts +39 -35
  401. package/src/internal/dateTime.ts +1 -1
  402. package/src/internal/executionPlan.ts +105 -10
  403. package/src/internal/hashMap.ts +20 -14
  404. package/src/internal/matcher.ts +2 -2
  405. package/src/internal/schedule.ts +4 -4
  406. package/src/internal/schema/annotations.ts +3 -0
  407. package/src/internal/schema/toArbitrary.ts +3 -1
  408. package/src/internal/trie.ts +12 -2
  409. package/src/testing/TestClock.ts +13 -1
  410. package/src/testing/TestSchema.ts +1 -1
  411. package/src/unstable/ai/AiError.ts +19 -19
  412. package/src/unstable/ai/Chat.ts +1 -1
  413. package/src/unstable/ai/LanguageModel.ts +4 -2
  414. package/src/unstable/ai/McpSchema.ts +17 -16
  415. package/src/unstable/ai/McpServer.ts +1 -1
  416. package/src/unstable/ai/Prompt.ts +21 -6
  417. package/src/unstable/cli/CliError.ts +12 -12
  418. package/src/unstable/cli/Command.ts +12 -10
  419. package/src/unstable/cli/Param.ts +41 -19
  420. package/src/unstable/cli/Primitive.ts +11 -5
  421. package/src/unstable/cli/Prompt.ts +36 -20
  422. package/src/unstable/cli/internal/ansi.ts +2 -2
  423. package/src/unstable/cli/internal/command.ts +15 -10
  424. package/src/unstable/cli/internal/completions/bash.ts +59 -9
  425. package/src/unstable/cli/internal/completions/descriptor.ts +14 -20
  426. package/src/unstable/cli/internal/completions/fish.ts +5 -7
  427. package/src/unstable/cli/internal/help.ts +4 -2
  428. package/src/unstable/cli/internal/parser.ts +3 -3
  429. package/src/unstable/cli/internal/wizard.ts +2 -2
  430. package/src/unstable/cluster/ClusterError.ts +7 -7
  431. package/src/unstable/cluster/ClusterWorkflowEngine.ts +4 -1
  432. package/src/unstable/cluster/MessageStorage.ts +9 -5
  433. package/src/unstable/cluster/Reply.ts +21 -0
  434. package/src/unstable/cluster/RunnerServer.ts +4 -10
  435. package/src/unstable/cluster/RunnerStorage.ts +9 -7
  436. package/src/unstable/cluster/Sharding.ts +35 -7
  437. package/src/unstable/cluster/internal/entityManager.ts +1 -1
  438. package/src/unstable/cluster/internal/resourceMap.ts +5 -2
  439. package/src/unstable/cluster/internal/resourceRef.ts +27 -5
  440. package/src/unstable/devtools/DevToolsClient.ts +3 -2
  441. package/src/unstable/encoding/Ini.ts +174 -0
  442. package/src/unstable/encoding/Msgpack.ts +47 -28
  443. package/src/unstable/encoding/Ndjson.ts +9 -1
  444. package/src/unstable/encoding/Sse.ts +11 -21
  445. package/src/unstable/encoding/Toml.ts +504 -0
  446. package/src/unstable/encoding/Yaml.ts +541 -0
  447. package/src/unstable/encoding/index.ts +15 -0
  448. package/src/unstable/eventlog/EventJournal.ts +14 -6
  449. package/src/unstable/eventlog/EventLogMessage.ts +1 -1
  450. package/src/unstable/eventlog/EventLogServerUnencrypted.ts +1 -1
  451. package/src/unstable/eventlog/SqlEventJournal.ts +6 -4
  452. package/src/unstable/http/FindMyWay/internal/queryString.ts +420 -0
  453. package/src/unstable/http/FindMyWay/internal/router.ts +950 -0
  454. package/src/unstable/http/FindMyWay.ts +65 -6
  455. package/src/unstable/http/HttpClientError.ts +1 -1
  456. package/src/unstable/http/HttpClientRequest.ts +2 -14
  457. package/src/unstable/http/HttpClientResponse.ts +1 -17
  458. package/src/unstable/http/HttpPlatform.ts +34 -6
  459. package/src/unstable/http/HttpServerRequest.ts +14 -6
  460. package/src/unstable/http/HttpServerResponse.ts +9 -7
  461. package/src/unstable/http/Multipart.ts +9 -2
  462. package/src/unstable/http/MultipartParser/HeadersParser.ts +68 -0
  463. package/src/unstable/http/MultipartParser/Search.ts +17 -0
  464. package/src/unstable/http/MultipartParser/internal/contentType.ts +103 -0
  465. package/src/unstable/http/MultipartParser/internal/headers.ts +615 -0
  466. package/src/unstable/http/MultipartParser/internal/multipart.ts +262 -0
  467. package/src/unstable/http/MultipartParser/internal/search.ts +167 -0
  468. package/src/unstable/http/MultipartParser.ts +115 -0
  469. package/src/unstable/http/Template.ts +6 -5
  470. package/src/unstable/http/index.ts +1 -1
  471. package/src/unstable/http/internal/httpBody.ts +15 -0
  472. package/src/unstable/httpapi/HttpApi.ts +6 -7
  473. package/src/unstable/httpapi/HttpApiBuilder.ts +119 -21
  474. package/src/unstable/httpapi/HttpApiClient.ts +104 -41
  475. package/src/unstable/httpapi/HttpApiEndpoint.ts +117 -29
  476. package/src/unstable/httpapi/HttpApiError.ts +33 -39
  477. package/src/unstable/httpapi/HttpApiMiddleware.ts +1 -1
  478. package/src/unstable/httpapi/HttpApiSchema.ts +353 -0
  479. package/src/unstable/httpapi/OpenApi.ts +70 -20
  480. package/src/unstable/observability/OtlpExporter.ts +4 -2
  481. package/src/unstable/observability/OtlpLogger.ts +3 -1
  482. package/src/unstable/observability/OtlpMetrics.ts +32 -18
  483. package/src/unstable/observability/OtlpTracer.ts +1 -1
  484. package/src/unstable/persistence/PersistedQueue.ts +12 -9
  485. package/src/unstable/persistence/Persistence.ts +27 -7
  486. package/src/unstable/persistence/RateLimiter.ts +54 -31
  487. package/src/unstable/persistence/Redis.ts +1 -1
  488. package/src/unstable/rpc/RpcClient.ts +38 -12
  489. package/src/unstable/rpc/RpcClientError.ts +2 -2
  490. package/src/unstable/rpc/RpcSerialization.ts +1 -1
  491. package/src/unstable/schema/VariantSchema.ts +36 -18
  492. package/src/unstable/socket/Socket.ts +24 -14
  493. package/src/unstable/sql/SqlClient.ts +65 -56
  494. package/src/unstable/sql/SqlError.ts +13 -13
  495. package/src/unstable/sql/SqlResolver.ts +8 -6
  496. package/src/unstable/sql/Statement.ts +13 -8
  497. package/src/unstable/workers/WorkerError.ts +5 -5
  498. package/src/unstable/workflow/WorkflowEngine.ts +8 -3
  499. package/dist/unstable/http/Multipasta/HeadersParser.d.ts +0 -14
  500. package/dist/unstable/http/Multipasta/HeadersParser.d.ts.map +0 -1
  501. package/dist/unstable/http/Multipasta/HeadersParser.js +0 -14
  502. package/dist/unstable/http/Multipasta/HeadersParser.js.map +0 -1
  503. package/dist/unstable/http/Multipasta/Node.d.ts +0 -14
  504. package/dist/unstable/http/Multipasta/Node.d.ts.map +0 -1
  505. package/dist/unstable/http/Multipasta/Node.js +0 -14
  506. package/dist/unstable/http/Multipasta/Node.js.map +0 -1
  507. package/dist/unstable/http/Multipasta/Search.d.ts +0 -14
  508. package/dist/unstable/http/Multipasta/Search.d.ts.map +0 -1
  509. package/dist/unstable/http/Multipasta/Search.js +0 -14
  510. package/dist/unstable/http/Multipasta/Search.js.map +0 -1
  511. package/dist/unstable/http/Multipasta/Web.d.ts +0 -14
  512. package/dist/unstable/http/Multipasta/Web.d.ts.map +0 -1
  513. package/dist/unstable/http/Multipasta/Web.js +0 -14
  514. package/dist/unstable/http/Multipasta/Web.js.map +0 -1
  515. package/dist/unstable/http/Multipasta.d.ts +0 -15
  516. package/dist/unstable/http/Multipasta.d.ts.map +0 -1
  517. package/dist/unstable/http/Multipasta.js +0 -15
  518. package/dist/unstable/http/Multipasta.js.map +0 -1
  519. package/src/unstable/http/Multipasta/HeadersParser.ts +0 -14
  520. package/src/unstable/http/Multipasta/Node.ts +0 -14
  521. package/src/unstable/http/Multipasta/Search.ts +0 -14
  522. package/src/unstable/http/Multipasta/Web.ts +0 -14
  523. package/src/unstable/http/Multipasta.ts +0 -15
package/src/SchemaAST.ts CHANGED
@@ -532,7 +532,7 @@ export const defaultParseOptions: ParseOptions = {}
532
532
  *
533
533
  * - `isOptional` — the property key may be absent from the input.
534
534
  * - `isMutable` — the property is `readonly` when `false`.
535
- * - `defaultValue` — an {@link Encoding} applied during construction to
535
+ * - `constructorDefault` — a {@link Link} applied during construction to
536
536
  * supply missing values.
537
537
  * - `annotations` — key-level annotations (e.g. description of the key
538
538
  * itself).
@@ -546,19 +546,19 @@ export class Context {
546
546
  readonly isOptional: boolean
547
547
  readonly isMutable: boolean
548
548
  /** Used for constructor default values (e.g. `withConstructorDefault` API) */
549
- readonly defaultValue: Encoding | undefined
549
+ readonly constructorDefault: Link | undefined
550
550
  readonly annotations: Schema.Annotations.Key<unknown> | undefined
551
551
 
552
552
  constructor(
553
553
  isOptional: boolean,
554
554
  isMutable: boolean,
555
555
  /** Used for constructor default values (e.g. `withConstructorDefault` API) */
556
- defaultValue: Encoding | undefined = undefined,
556
+ constructorDefault: Link | undefined = undefined,
557
557
  annotations: Schema.Annotations.Key<unknown> | undefined = undefined
558
558
  ) {
559
559
  this.isOptional = isOptional
560
560
  this.isMutable = isMutable
561
- this.defaultValue = defaultValue
561
+ this.constructorDefault = constructorDefault
562
562
  this.annotations = annotations
563
563
  }
564
564
  }
@@ -1141,8 +1141,8 @@ export class TemplateLiteral extends Base {
1141
1141
  this.suffixLengths = suffixLengths
1142
1142
  }
1143
1143
  /** @internal */
1144
- getParser(recur: (ast: AST) => SchemaParser.Parser): SchemaParser.Parser {
1145
- const parser = recur(this.asTemplateLiteralParser())
1144
+ getParser(compile: SchemaParser.Compiler): SchemaParser.Parser {
1145
+ const parser = compile(this.asTemplateLiteralParser())
1146
1146
  return (input, options) => {
1147
1147
  if (input === InternalParser.missing) return InternalParser.missingExit
1148
1148
  const result = parser(input, options)
@@ -1684,7 +1684,10 @@ export class Arrays extends Base {
1684
1684
  }
1685
1685
  }
1686
1686
  /** @internal */
1687
- getParser(recur: (ast: AST) => SchemaParser.Parser): SchemaParser.Parser {
1687
+ getParser(
1688
+ compile: SchemaParser.Compiler,
1689
+ compileConstructorDefault: SchemaParser.Compiler = compile
1690
+ ): SchemaParser.Parser {
1688
1691
  // oxlint-disable-next-line @typescript-eslint/no-this-alias
1689
1692
  const ast = this
1690
1693
  type ElementParser = { readonly ast: AST; readonly parser: SchemaParser.Parser }
@@ -1715,8 +1718,8 @@ export class Arrays extends Base {
1715
1718
  return yield* Effect.fail(new SchemaIssue.InvalidType(ast))
1716
1719
  }
1717
1720
  if (!elements) {
1718
- elements = ast.elements.map((ast) => ({ ast, parser: recur(ast) }))
1719
- rest = ast.rest.map((ast) => ({ ast, parser: recur(ast) }))
1721
+ elements = ast.elements.map((ast) => ({ ast, parser: compileConstructorDefault(ast) }))
1722
+ rest = ast.rest.map((ast) => ({ ast, parser: compileConstructorDefault(ast) }))
1720
1723
  }
1721
1724
 
1722
1725
  const len = input.length
@@ -2076,7 +2079,10 @@ export class Objects extends Base {
2076
2079
  }
2077
2080
  }
2078
2081
  /** @internal */
2079
- getParser(recur: (ast: AST) => SchemaParser.Parser): SchemaParser.Parser {
2082
+ getParser(
2083
+ compile: SchemaParser.Compiler,
2084
+ compileConstructorDefault: SchemaParser.Compiler = compile
2085
+ ): SchemaParser.Parser {
2080
2086
  // oxlint-disable-next-line @typescript-eslint/no-this-alias
2081
2087
  const ast = this
2082
2088
  const expectedKeys: Array<PropertyKey> = []
@@ -2175,15 +2181,15 @@ export class Objects extends Base {
2175
2181
  }
2176
2182
  if (!properties) {
2177
2183
  properties = ast.propertySignatures.map((ps) => ({
2178
- parser: recur(ps.type),
2184
+ parser: compileConstructorDefault(ps.type),
2179
2185
  name: ps.name,
2180
2186
  type: ps.type
2181
2187
  }))
2182
2188
  indexes = indexCount
2183
2189
  ? ast.indexSignatures.map((is) => ({
2184
2190
  is,
2185
- parserKey: recur(parameterFromPropertyKey(is.parameter)),
2186
- parserValue: recur(is.type)
2191
+ parserKey: compile(parameterFromPropertyKey(is.parameter)),
2192
+ parserValue: compileConstructorDefault(is.type)
2187
2193
  }))
2188
2194
  : undefined
2189
2195
  }
@@ -2577,7 +2583,7 @@ export function collectSentinels(ast: AST): Array<Sentinel> {
2577
2583
  }
2578
2584
 
2579
2585
  type CandidateIndex =
2580
- | ((input: any) => ReadonlyArray<AST>)
2586
+ | ((input: any, isConstructor: boolean) => ReadonlyArray<AST>)
2581
2587
  | {
2582
2588
  bySentinel?: Map<PropertyKey, Map<LiteralValue | symbol, Array<number>>>
2583
2589
  otherwise?: { [K in Type]?: Array<number> }
@@ -2636,10 +2642,14 @@ function getIndex(types: ReadonlyArray<AST>): CandidateIndex {
2636
2642
  for (const [literal, indexes] of byValue) {
2637
2643
  candidates.set(literal, Object.freeze(indexes.map((index) => types[index])))
2638
2644
  }
2639
- idx = (input) =>
2640
- Predicate.isObjectKeyword(input) && Object.hasOwn(input, key)
2641
- ? candidates.get((input as any)[key]) ?? emptyCandidates
2642
- : emptyCandidates
2645
+ idx = (input, isConstructor) => {
2646
+ if (Predicate.isObjectKeyword(input)) {
2647
+ const value = Object.hasOwn(input, key) ? (input as any)[key] : undefined
2648
+ if (value !== undefined) return candidates.get(value) ?? emptyCandidates
2649
+ if (isConstructor) return types
2650
+ }
2651
+ return emptyCandidates
2652
+ }
2643
2653
  }
2644
2654
  }
2645
2655
 
@@ -2664,9 +2674,13 @@ function filterLiterals(input: any) {
2664
2674
  *
2665
2675
  * @internal
2666
2676
  */
2667
- export function getCandidates(input: any, types: ReadonlyArray<AST>): ReadonlyArray<AST> {
2677
+ export function getCandidates(
2678
+ input: any,
2679
+ types: ReadonlyArray<AST>,
2680
+ isConstructor = false
2681
+ ): ReadonlyArray<AST> {
2668
2682
  const idx = getIndex(types)
2669
- if (typeof idx === "function") return idx(input)
2683
+ if (typeof idx === "function") return idx(input, isConstructor)
2670
2684
 
2671
2685
  const runtimeType: Type = input === null ? "null" : Array.isArray(input) ? "array" : typeof input
2672
2686
 
@@ -2676,11 +2690,16 @@ export function getCandidates(input: any, types: ReadonlyArray<AST>): ReadonlyAr
2676
2690
  if (Predicate.isObjectKeyword(input)) {
2677
2691
  const selected = new Set(base)
2678
2692
  for (const [k, m] of idx.bySentinel) {
2679
- if (Object.hasOwn(input, k)) {
2680
- const match = m.get((input as any)[k])
2693
+ const value = Object.hasOwn(input, k) ? (input as any)[k] : undefined
2694
+ if (value !== undefined) {
2695
+ const match = m.get(value)
2681
2696
  if (match) {
2682
2697
  for (const candidate of match) selected.add(candidate)
2683
2698
  }
2699
+ } else if (isConstructor) {
2700
+ for (const indexes of m.values()) {
2701
+ for (const candidate of indexes) selected.add(candidate)
2702
+ }
2684
2703
  }
2685
2704
  }
2686
2705
  return Array.from(selected).sort((a, b) => a - b).map((i) => types[i])
@@ -2743,7 +2762,10 @@ export class Union<A extends AST = AST> extends Base {
2743
2762
  this.encodingChecks = encodingChecks
2744
2763
  }
2745
2764
  /** @internal */
2746
- getParser(recur: (ast: AST) => SchemaParser.Parser): SchemaParser.Parser {
2765
+ getParser(
2766
+ compile: SchemaParser.Compiler,
2767
+ compileConstructorDefault?: SchemaParser.Compiler
2768
+ ): SchemaParser.Parser {
2747
2769
  // oxlint-disable-next-line @typescript-eslint/no-this-alias
2748
2770
  const ast = this
2749
2771
 
@@ -2751,10 +2773,10 @@ export class Union<A extends AST = AST> extends Base {
2751
2773
  if (input === InternalParser.missing) {
2752
2774
  return InternalParser.missingExit
2753
2775
  }
2754
- const candidates = getCandidates(input, ast.types)
2776
+ const candidates = getCandidates(input, ast.types, compileConstructorDefault !== undefined)
2755
2777
 
2756
2778
  if (candidates.length === 1) {
2757
- const result = recur(candidates[0])(input, options)
2779
+ const result = compile(candidates[0])(input, options)
2758
2780
  if ((result as Exit.Exit<unknown, SchemaIssue.Issue>)._tag === "Success") return result
2759
2781
  return effectIsExit(result)
2760
2782
  ? failSingleUnionCandidate(ast, (result as Exit.Failure<unknown, SchemaIssue.Issue>).cause)
@@ -2763,7 +2785,7 @@ export class Union<A extends AST = AST> extends Base {
2763
2785
 
2764
2786
  const state = {
2765
2787
  ast,
2766
- recur,
2788
+ compile,
2767
2789
  input,
2768
2790
  out: undefined,
2769
2791
  successes: ast.mode === "oneOf" ? [] : undefined,
@@ -2854,7 +2876,7 @@ function failSingleUnionCandidate(
2854
2876
  }
2855
2877
 
2856
2878
  const parseUnion = iterateEager<{
2857
- readonly recur: (ast: AST) => SchemaParser.Parser
2879
+ readonly compile: (ast: AST) => SchemaParser.Parser
2858
2880
  readonly ast: Union
2859
2881
  readonly input: unknown
2860
2882
  readonly options: ParseOptions
@@ -2863,7 +2885,7 @@ const parseUnion = iterateEager<{
2863
2885
  issues: Array<SchemaIssue.Issue> | undefined
2864
2886
  }, AST>()({
2865
2887
  onItem(s, ast) {
2866
- const parser = s.recur(ast)
2888
+ const parser = s.compile(ast)
2867
2889
  return parser(s.input, s.options)
2868
2890
  },
2869
2891
  step(s, candidate, exit) {
@@ -2966,9 +2988,9 @@ export class Suspend extends Base {
2966
2988
  this.thunk = memoizeThunk(thunk)
2967
2989
  }
2968
2990
  /** @internal */
2969
- getParser(recur: (ast: AST) => SchemaParser.Parser): SchemaParser.Parser {
2991
+ getParser(compile: SchemaParser.Compiler): SchemaParser.Parser {
2970
2992
  let parser: SchemaParser.Parser
2971
- return (input, options) => (parser ??= recur(this.thunk()))(input, options)
2993
+ return (input, options) => (parser ??= compile(this.thunk()))(input, options)
2972
2994
  }
2973
2995
  /** @internal */
2974
2996
  recur(recur: (ast: AST) => AST) {
@@ -3364,7 +3386,7 @@ export function annotateKey<A extends AST>(ast: A, annotations: Schema.Annotatio
3364
3386
  new Context(
3365
3387
  ast.context.isOptional,
3366
3388
  ast.context.isMutable,
3367
- ast.context.defaultValue,
3389
+ ast.context.constructorDefault,
3368
3390
  { ...ast.context.annotations, ...annotations }
3369
3391
  ) :
3370
3392
  new Context(false, false, undefined, annotations)
@@ -3390,7 +3412,7 @@ const optionalKeyLastLink = applyToLastLink(optionalKey)
3390
3412
  export function optionalKey<A extends AST>(ast: A): A {
3391
3413
  const context = ast.context ?
3392
3414
  ast.context.isOptional === false ?
3393
- new Context(true, ast.context.isMutable, ast.context.defaultValue, ast.context.annotations) :
3415
+ new Context(true, ast.context.isMutable, ast.context.constructorDefault, ast.context.annotations) :
3394
3416
  ast.context :
3395
3417
  new Context(true, false)
3396
3418
  return optionalKeyLastLink(replaceContext(ast, context))
@@ -3402,7 +3424,7 @@ const mutableKeyLastLink = applyToLastLink(mutableKey)
3402
3424
  export function mutableKey<A extends AST>(ast: A): A {
3403
3425
  const context = ast.context ?
3404
3426
  ast.context.isMutable === false ?
3405
- new Context(ast.context.isOptional, true, ast.context.defaultValue, ast.context.annotations) :
3427
+ new Context(ast.context.isOptional, true, ast.context.constructorDefault, ast.context.annotations) :
3406
3428
  ast.context :
3407
3429
  new Context(false, true)
3408
3430
  return mutableKeyLastLink(replaceContext(ast, context))
@@ -3417,10 +3439,10 @@ export function withConstructorDefault<A extends AST>(
3417
3439
  SchemaGetter.withDefault(defaultValue),
3418
3440
  SchemaGetter.passthrough()
3419
3441
  )
3420
- const encoding: Encoding = [new Link(unknown, transformation)]
3442
+ const constructorDefault = new Link(unknown, transformation)
3421
3443
  const context = ast.context ?
3422
- new Context(ast.context.isOptional, ast.context.isMutable, encoding, ast.context.annotations) :
3423
- new Context(false, false, encoding)
3444
+ new Context(ast.context.isOptional, ast.context.isMutable, constructorDefault, ast.context.annotations) :
3445
+ new Context(false, false, constructorDefault)
3424
3446
  return replaceContext(ast, context)
3425
3447
  }
3426
3448
 
@@ -3949,7 +3971,17 @@ export function runChecks<T>(
3949
3971
  }
3950
3972
 
3951
3973
  /** @internal */
3952
- export const ClassTypeId = "~effect/Schema/Class"
3974
+ export interface ConstructorDescriptor {
3975
+ readonly isConstructed: Predicate.Predicate<unknown>
3976
+ readonly link: Link
3977
+ }
3978
+
3979
+ /** @internal */
3980
+ export function getConstructorDescriptor(ast: AST): ConstructorDescriptor | undefined {
3981
+ if (!isDeclaration(ast)) return undefined
3982
+ const getDescriptor = ast.annotations?.[InternalAnnotations.CONSTRUCTOR_ANNOTATION_KEY]
3983
+ return Predicate.isFunction(getDescriptor) ? getDescriptor(ast.typeParameters) : undefined
3984
+ }
3953
3985
 
3954
3986
  /**
3955
3987
  * Returns all annotations from the AST node.
@@ -18,41 +18,11 @@ import { effectIsExit } from "./internal/effect.ts"
18
18
  import * as InternalSchemaCause from "./internal/schema/cause.ts"
19
19
  import * as InternalParser from "./internal/schema/parser.ts"
20
20
  import * as Option from "./Option.ts"
21
- import * as Predicate from "./Predicate.ts"
22
21
  import * as Result from "./Result.ts"
23
22
  import type * as Schema from "./Schema.ts"
24
23
  import * as SchemaAST from "./SchemaAST.ts"
25
24
  import * as SchemaIssue from "./SchemaIssue.ts"
26
25
 
27
- // Converts a type-side AST into its constructor form by recursively restoring
28
- // constructor encodings for nested classes and fields with constructor defaults.
29
- const toConstructorAST = memoize((ast: SchemaAST.AST): SchemaAST.AST => {
30
- switch (ast._tag) {
31
- case "Declaration": {
32
- const getLink = ast.annotations?.[SchemaAST.ClassTypeId]
33
- if (Predicate.isFunction(getLink)) {
34
- const link = getLink(ast.typeParameters)
35
- return SchemaAST.replaceEncoding(ast, [SchemaAST.mapLink(link, toConstructorAST)])
36
- }
37
- return ast
38
- }
39
- case "Objects":
40
- case "Arrays":
41
- return ast.recur((ast) => {
42
- const defaultValue = ast.context?.defaultValue
43
- if (defaultValue) {
44
- const out = toConstructorAST(ast)
45
- return SchemaAST.replaceEncoding(out, out.encoding ? [...out.encoding, ...defaultValue] : defaultValue)
46
- }
47
- return toConstructorAST(ast)
48
- })
49
- case "Suspend":
50
- return ast.recur(toConstructorAST)
51
- default:
52
- return ast
53
- }
54
- })
55
-
56
26
  /**
57
27
  * Creates an effectful maker for the schema's decoded type side.
58
28
  *
@@ -71,8 +41,7 @@ const toConstructorAST = memoize((ast: SchemaAST.AST): SchemaAST.AST => {
71
41
  * @since 4.0.0
72
42
  */
73
43
  export function makeEffect<S extends Schema.Constraint>(schema: S) {
74
- const ast = toConstructorAST(SchemaAST.toType(schema.ast))
75
- const parser = run<S["Type"], never>(ast)
44
+ const parser = runWithCompiler<S["Type"], never>(constructorCompiler, SchemaAST.toType(schema.ast))
76
45
  return (input: S["~type.make.in"], options?: Schema.MakeOptions): Effect.Effect<S["Type"], SchemaIssue.Issue> => {
77
46
  return parser(
78
47
  input,
@@ -923,9 +892,13 @@ const getValue = (value: unknown): Effect.Effect<any, SchemaIssue.Issue> => {
923
892
 
924
893
  /** @internal */
925
894
  export function run<T, R>(ast: SchemaAST.AST) {
895
+ return runWithCompiler<T, R>(normalCompiler, ast)
896
+ }
897
+
898
+ function runWithCompiler<T, R>(compiler: Compiler, ast: SchemaAST.AST) {
926
899
  let parser: Parser
927
900
  return (input: unknown, options?: SchemaAST.ParseOptions): Effect.Effect<T, SchemaIssue.Issue, R> => {
928
- const result = (parser ??= compile(ast))(
901
+ const result = (parser ??= compiler(ast))(
929
902
  input,
930
903
  options ?? SchemaAST.defaultParseOptions
931
904
  )
@@ -1016,20 +989,79 @@ export interface Parser {
1016
989
  ): Effect.Effect<unknown, SchemaIssue.Issue, any>
1017
990
  }
1018
991
 
1019
- const parserCache = new WeakMap<SchemaAST.AST, Parser>()
992
+ /** @internal */
993
+ export interface Compiler {
994
+ (ast: SchemaAST.AST): Parser
995
+ }
996
+
997
+ const normalCompiler: Compiler = memoize((ast) => makeParser(ast, normalCompiler))
998
+ const constructorCompiler: Compiler = memoize((ast) => makeParser(ast, constructorCompiler, compileConstructorDefault))
999
+ const compileDefaulted = memoize((ast: SchemaAST.AST) =>
1000
+ makeParser(ast, constructorCompiler, compileConstructorDefault, ast.context?.constructorDefault)
1001
+ )
1002
+
1003
+ function compileConstructorDefault(ast: SchemaAST.AST): Parser {
1004
+ return ast.context?.constructorDefault ? compileDefaulted(ast) : constructorCompiler(ast)
1005
+ }
1020
1006
 
1021
- function compile(ast: SchemaAST.AST): Parser {
1022
- let parser = parserCache.get(ast)
1023
- if (!parser) {
1024
- parserCache.set(ast, parser = makeParser(ast))
1007
+ function applyTransformation(
1008
+ result: Effect.Effect<unknown, SchemaIssue.Issue, unknown>,
1009
+ current: unknown,
1010
+ transformation: SchemaAST.Link["transformation"],
1011
+ options: SchemaAST.ParseOptions
1012
+ ): Effect.Effect<unknown, SchemaIssue.Issue, unknown> {
1013
+ let transformed: Effect.Effect<Option.Option<unknown>, SchemaIssue.Issue, unknown>
1014
+ if (effectIsExit(result) && result._tag === "Success") {
1015
+ const optional = InternalParser.toOption(
1016
+ result === InternalParser.sameExit
1017
+ ? current
1018
+ : (result as InternalParser.Success<unknown, SchemaIssue.Issue>)[InternalParser.args]
1019
+ )
1020
+ transformed = transformation._tag === "Transformation"
1021
+ ? transformation.decode.run(optional, options)
1022
+ : transformation.decode(InternalParser.succeed(optional), options)
1023
+ } else if (transformation._tag === "Transformation") {
1024
+ transformed = Effect.flatMapEager(
1025
+ result,
1026
+ (value) => transformation.decode.run(InternalParser.toOption(value), options)
1027
+ )
1028
+ } else {
1029
+ transformed = transformation.decode(
1030
+ Effect.mapEager(result, InternalParser.toOption),
1031
+ options
1032
+ )
1025
1033
  }
1026
- return parser
1034
+ return effectIsExit(transformed) && transformed._tag === "Success"
1035
+ ? InternalParser.fromOptionExit(
1036
+ (transformed as InternalParser.Success<Option.Option<unknown>, SchemaIssue.Issue>)[InternalParser.args]
1037
+ )
1038
+ : Effect.flatMapEager(transformed, InternalParser.fromOptionExit)
1027
1039
  }
1028
1040
 
1029
- function makeParser(ast: SchemaAST.AST): Parser {
1030
- const parser = ast.getParser(compile)
1041
+ function makeConstructorParser(descriptor: SchemaAST.ConstructorDescriptor, compile: Compiler): Parser {
1042
+ let sourceParser: Parser
1043
+ return (input, options) => {
1044
+ if (input === InternalParser.missing) return InternalParser.missingExit
1045
+ if (descriptor.isConstructed(input)) return InternalParser.sameExit
1046
+ const result = (sourceParser ??= compile(descriptor.link.to))(input, options)
1047
+ return applyTransformation(result, input, descriptor.link.transformation, options)
1048
+ }
1049
+ }
1050
+
1051
+ function makeParser(
1052
+ ast: SchemaAST.AST,
1053
+ compile: Compiler,
1054
+ compileConstructorDefault?: Compiler,
1055
+ constructorDefault?: SchemaAST.Link
1056
+ ): Parser {
1057
+ const descriptor = compileConstructorDefault ? SchemaAST.getConstructorDescriptor(ast) : undefined
1058
+ const parser = descriptor
1059
+ ? makeConstructorParser(descriptor, compile)
1060
+ : ast.getParser(compile, compileConstructorDefault)
1031
1061
  const checks = ast.checks
1032
- const links = ast.encoding
1062
+ const links = constructorDefault
1063
+ ? ast.encoding ? [...ast.encoding, constructorDefault] : [constructorDefault]
1064
+ : ast.encoding
1033
1065
  const encodingChecks = (ast as any).encodingChecks
1034
1066
  const astOptions = (checks ? checks[checks.length - 1].annotations : ast.annotations)
1035
1067
  ?.["parseOptions"]
@@ -1122,33 +1154,7 @@ function makeParser(ast: SchemaAST.AST): Parser {
1122
1154
  let current = input
1123
1155
  let result = parsers[parsers.length - 1](input, options)
1124
1156
  for (let i = links.length - 1; i >= 0; i--) {
1125
- const transformation = links[i].transformation
1126
- let transformed: Effect.Effect<Option.Option<unknown>, SchemaIssue.Issue, unknown>
1127
- if (effectIsExit(result) && result._tag === "Success") {
1128
- const optional = InternalParser.toOption(
1129
- result === InternalParser.sameExit
1130
- ? current
1131
- : (result as InternalParser.Success<unknown, SchemaIssue.Issue>)[InternalParser.args]
1132
- )
1133
- transformed = transformation._tag === "Transformation"
1134
- ? transformation.decode.run(optional, options)
1135
- : transformation.decode(InternalParser.succeed(optional), options)
1136
- } else if (transformation._tag === "Transformation") {
1137
- transformed = Effect.flatMapEager(
1138
- result,
1139
- (value) => transformation.decode.run(InternalParser.toOption(value), options)
1140
- )
1141
- } else {
1142
- transformed = transformation.decode(
1143
- Effect.mapEager(result, InternalParser.toOption),
1144
- options
1145
- )
1146
- }
1147
- result = effectIsExit(transformed) && transformed._tag === "Success"
1148
- ? InternalParser.fromOptionExit(
1149
- (transformed as InternalParser.Success<Option.Option<unknown>, SchemaIssue.Issue>)[InternalParser.args]
1150
- )
1151
- : Effect.flatMapEager(transformed, InternalParser.fromOptionExit)
1157
+ result = applyTransformation(result, current, links[i].transformation, options)
1152
1158
  if (i !== 0) {
1153
1159
  const next = parsers[i - 1]
1154
1160
  if ((result as Exit.Exit<unknown, unknown>)._tag === "Success") {
@@ -211,7 +211,7 @@ export const make = <
211
211
  > =>
212
212
  makeWith<Key, A, E, R, ServiceMode>({
213
213
  ...options,
214
- timeToLive: options.timeToLive ? () => options.timeToLive! : defaultTimeToLive
214
+ timeToLive: options.timeToLive !== undefined ? () => options.timeToLive! : defaultTimeToLive
215
215
  })
216
216
 
217
217
  const Proto = {
package/src/Sink.ts CHANGED
@@ -2529,7 +2529,7 @@ export const catchCause: {
2529
2529
  const catch_: {
2530
2530
  <E, A2, E2, R2>(
2531
2531
  f: (error: Types.NoInfer<E>) => Effect.Effect<A2, E2, R2>
2532
- ): <A, In, L, R>(self: Sink<A, In, L, E, R>) => Sink<A2 | A, In, L, E, R2 | R>
2532
+ ): <A, In, L, R>(self: Sink<A, In, L, E, R>) => Sink<A2 | A, In, L, E2, R2 | R>
2533
2533
  <A, In, L, E, R, A2, E2, R2>(
2534
2534
  self: Sink<A, In, L, E, R>,
2535
2535
  f: (error: E) => Effect.Effect<A2, E2, R2>
package/src/Stream.ts CHANGED
@@ -9657,6 +9657,13 @@ const retryWithoutReset = <A, E, R, X, E2, R2>(
9657
9657
  * `preventFallbackOnPartialStream` to fail instead of mixing partial output with
9658
9658
  * a later fallback.
9659
9659
  *
9660
+ * Attempts can be observed from outside the stream by passing
9661
+ * `options.onEvent`, which receives an `ExecutionPlan.Event` before each
9662
+ * attempt and after it settles; see `Effect.withExecutionPlan` for the handler
9663
+ * semantics. When a downstream consumer stops pulling early (for example
9664
+ * `Stream.take` outside the plan), the truncated attempt reports
9665
+ * `AttemptSuccess`: the consumer stopped, not the source.
9666
+ *
9660
9667
  * **Example** (Applying an execution plan)
9661
9668
  *
9662
9669
  * ```ts import.meta.vitest
@@ -9700,6 +9707,13 @@ export const withExecutionPlan: {
9700
9707
  * `preventFallbackOnPartialStream` to fail instead of mixing partial output with
9701
9708
  * a later fallback.
9702
9709
  *
9710
+ * Attempts can be observed from outside the stream by passing
9711
+ * `options.onEvent`, which receives an `ExecutionPlan.Event` before each
9712
+ * attempt and after it settles; see `Effect.withExecutionPlan` for the handler
9713
+ * semantics. When a downstream consumer stops pulling early (for example
9714
+ * `Stream.take` outside the plan), the truncated attempt reports
9715
+ * `AttemptSuccess`: the consumer stopped, not the source.
9716
+ *
9703
9717
  * **Example** (Applying an execution plan)
9704
9718
  *
9705
9719
  * ```ts import.meta.vitest
@@ -9732,10 +9746,13 @@ export const withExecutionPlan: {
9732
9746
  * @category error handling
9733
9747
  * @since 3.16.0
9734
9748
  */
9735
- <Input, R2, Provides, PolicyE>(
9749
+ <Input, R2, Provides, PolicyE, RX = never>(
9736
9750
  policy: ExecutionPlan.ExecutionPlan<{ provides: Provides; input: Input; error: PolicyE; requirements: R2 }>,
9737
- options?: { readonly preventFallbackOnPartialStream?: boolean | undefined }
9738
- ): <A, E extends Input, R>(self: Stream<A, E, R>) => Stream<A, E | PolicyE, R2 | Exclude<R, Provides>>
9751
+ options?: {
9752
+ readonly preventFallbackOnPartialStream?: boolean | undefined
9753
+ readonly onEvent?: ((event: ExecutionPlan.Event<Input | PolicyE>) => Effect.Effect<void, never, RX>) | undefined
9754
+ }
9755
+ ): <A, E extends Input, R>(self: Stream<A, E, R>) => Stream<A, E | PolicyE, R2 | Exclude<R, Provides> | RX>
9739
9756
  /**
9740
9757
  * Applies an `ExecutionPlan` to a stream, retrying with step-provided resources
9741
9758
  * until it succeeds or the plan is exhausted.
@@ -9746,6 +9763,13 @@ export const withExecutionPlan: {
9746
9763
  * `preventFallbackOnPartialStream` to fail instead of mixing partial output with
9747
9764
  * a later fallback.
9748
9765
  *
9766
+ * Attempts can be observed from outside the stream by passing
9767
+ * `options.onEvent`, which receives an `ExecutionPlan.Event` before each
9768
+ * attempt and after it settles; see `Effect.withExecutionPlan` for the handler
9769
+ * semantics. When a downstream consumer stops pulling early (for example
9770
+ * `Stream.take` outside the plan), the truncated attempt reports
9771
+ * `AttemptSuccess`: the consumer stopped, not the source.
9772
+ *
9749
9773
  * **Example** (Applying an execution plan)
9750
9774
  *
9751
9775
  * ```ts import.meta.vitest
@@ -9778,12 +9802,15 @@ export const withExecutionPlan: {
9778
9802
  * @category error handling
9779
9803
  * @since 3.16.0
9780
9804
  */
9781
- <A, E extends Input, R, R2, Input, Provides, PolicyE>(
9805
+ <A, E extends Input, R, R2, Input, Provides, PolicyE, RX = never>(
9782
9806
  self: Stream<A, E, R>,
9783
9807
  policy: ExecutionPlan.ExecutionPlan<{ provides: Provides; input: Input; error: PolicyE; requirements: R2 }>,
9784
- options?: { readonly preventFallbackOnPartialStream?: boolean | undefined }
9785
- ): Stream<A, E | PolicyE, R2 | Exclude<R, Provides>>
9786
- } = dual((args) => isStream(args[0]), <A, E extends Input, R, R2, Input, Provides, PolicyE>(
9808
+ options?: {
9809
+ readonly preventFallbackOnPartialStream?: boolean | undefined
9810
+ readonly onEvent?: ((event: ExecutionPlan.Event<E | PolicyE>) => Effect.Effect<void, never, RX>) | undefined
9811
+ }
9812
+ ): Stream<A, E | PolicyE, R2 | Exclude<R, Provides> | RX>
9813
+ } = dual((args) => isStream(args[0]), <A, E extends Input, R, R2, Input, Provides, PolicyE, RX>(
9787
9814
  self: Stream<A, E, R>,
9788
9815
  policy: ExecutionPlan.ExecutionPlan<{
9789
9816
  provides: Provides
@@ -9793,8 +9820,9 @@ export const withExecutionPlan: {
9793
9820
  }>,
9794
9821
  options?: {
9795
9822
  readonly preventFallbackOnPartialStream?: boolean | undefined
9823
+ readonly onEvent?: ((event: ExecutionPlan.Event<E | PolicyE>) => Effect.Effect<void, never, RX>) | undefined
9796
9824
  }
9797
- ): Stream<A, E | PolicyE, R2 | Exclude<R, Provides>> =>
9825
+ ): Stream<A, E | PolicyE, R2 | Exclude<R, Provides> | RX> =>
9798
9826
  suspend(() => {
9799
9827
  const preventFallbackOnPartialStream = options?.preventFallbackOnPartialStream ?? false
9800
9828
  let i = 0
@@ -9812,6 +9840,28 @@ export const withExecutionPlan: {
9812
9840
  return meta
9813
9841
  })
9814
9842
  )
9843
+ const emitter = options?.onEvent === undefined
9844
+ ? undefined
9845
+ : internalExecutionPlan.makeEventEmitter(options.onEvent, () => meta)
9846
+ let attemptState: internalExecutionPlan.AttemptState | undefined
9847
+ const instrument: (attempt: Stream<A, E | PolicyE, any>) => Stream<A, E | PolicyE, any> = emitter === undefined
9848
+ ? identity
9849
+ : (attempt) =>
9850
+ onExit(
9851
+ onStart(
9852
+ attempt,
9853
+ Effect.map(emitter.begin, (state) => {
9854
+ attemptState = state
9855
+ })
9856
+ ),
9857
+ (exit) =>
9858
+ Effect.suspend(() => {
9859
+ if (attemptState === undefined) return Effect.void
9860
+ const state = attemptState
9861
+ attemptState = undefined
9862
+ return emitter.end(state, exit)
9863
+ })
9864
+ )
9815
9865
  let lastError = Option.none</**
9816
9866
  * Applies an `ExecutionPlan` to a stream, retrying with step-provided resources
9817
9867
  * until it succeeds or the plan is exhausted.
@@ -9822,6 +9872,13 @@ export const withExecutionPlan: {
9822
9872
  * `preventFallbackOnPartialStream` to fail instead of mixing partial output with
9823
9873
  * a later fallback.
9824
9874
  *
9875
+ * Attempts can be observed from outside the stream by passing
9876
+ * `options.onEvent`, which receives an `ExecutionPlan.Event` before each
9877
+ * attempt and after it settles; see `Effect.withExecutionPlan` for the handler
9878
+ * semantics. When a downstream consumer stops pulling early (for example
9879
+ * `Stream.take` outside the plan), the truncated attempt reports
9880
+ * `AttemptSuccess`: the consumer stopped, not the source.
9881
+ *
9825
9882
  * **Example** (Applying an execution plan)
9826
9883
  *
9827
9884
  * ```ts import.meta.vitest
@@ -9865,7 +9922,9 @@ export const withExecutionPlan: {
9865
9922
  return fail(Option.getOrThrow(lastError))
9866
9923
  }
9867
9924
 
9868
- let nextStream: Stream<A, E | PolicyE, R2 | Exclude<R, Provides>> = provideMeta(provide(self, step.provide))
9925
+ let nextStream: Stream<A, E | PolicyE, R2 | Exclude<R, Provides>> = provideMeta(
9926
+ instrument(provide(self, step.provide))
9927
+ )
9869
9928
  let receivedElements = false
9870
9929
 
9871
9930
  if (Option.isSome(lastError)) {
@@ -11776,12 +11835,18 @@ export const slidingSize: {
11776
11835
  */
11777
11836
  A>()
11778
11837
  let emitted = false
11838
+ let skip = 0
11779
11839
  const pull: Pull.Pull<
11780
11840
  Arr.NonEmptyReadonlyArray<Arr.NonEmptyReadonlyArray<A>>,
11781
11841
  E | Cause.Done
11782
11842
  > = Effect.matchCauseEffect(upstream, {
11783
11843
  onSuccess(arr) {
11784
11844
  MutableList.appendAllUnsafe(list, arr)
11845
+ if (skip > 0) {
11846
+ const length = list.length
11847
+ MutableList.takeNVoid(list, skip)
11848
+ skip = Math.max(0, skip - length)
11849
+ }
11785
11850
  if (list.length < chunkSize) return pull
11786
11851
  emitted = true
11787
11852
  const chunks = [] as any as Arr.NonEmptyArray<Arr.NonEmptyReadonlyArray<A>>
@@ -11790,10 +11855,12 @@ export const slidingSize: {
11790
11855
  chunks.push(MutableList.takeN(list, chunkSize) as any)
11791
11856
  } else {
11792
11857
  chunks.push(MutableList.toArrayN(list, chunkSize) as any)
11793
- if (chunkSize === 1) {
11858
+ if (chunkSize === 1 && stepSize <= 0) {
11794
11859
  MutableList.take(list)
11795
11860
  } else {
11861
+ const length = list.length
11796
11862
  MutableList.takeNVoid(list, stepSize)
11863
+ skip = Math.max(0, stepSize - length)
11797
11864
  }
11798
11865
  }
11799
11866
  }
@@ -358,7 +358,7 @@ export const getAndUpdateSome: {
358
358
  } = dual(
359
359
  2,
360
360
  <A>(self: SynchronizedRef<A>, pf: (a: A) => Option.Option<A>): Effect.Effect<A> =>
361
- self.semaphore.withPermit(Ref.getAndUpdateSome(self, pf))
361
+ self.semaphore.withPermit(Ref.getAndUpdateSome(self.backing, pf))
362
362
  )
363
363
 
364
364
  /**