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/Terminal.ts CHANGED
@@ -121,7 +121,7 @@ const QuitErrorTypeId = "effect/platform/Terminal/QuitError"
121
121
  * @category errors
122
122
  * @since 4.0.0
123
123
  */
124
- export class QuitError extends Schema.ErrorClass<QuitError>("QuitError")({
124
+ export class QuitError extends Schema.Error<QuitError>("QuitError")({
125
125
  _tag: Schema.tag("QuitError")
126
126
  }) {
127
127
  /**
package/src/Tuple.ts CHANGED
@@ -43,7 +43,8 @@ import type { Apply, Lambda } from "./Struct.ts"
43
43
  * @category constructors
44
44
  * @since 2.0.0
45
45
  */
46
- export const make = <Elements extends ReadonlyArray<unknown>>(...elements: Elements): Elements => elements
46
+ export const make = <const Elements extends ReadonlyArray<unknown>>(...elements: [...Elements]): [...Elements] =>
47
+ elements
47
48
 
48
49
  type Indices<T extends ReadonlyArray<unknown>> = Exclude<Partial<T>["length"], T["length"]>
49
50
 
@@ -138,7 +139,9 @@ type _BuildTuple<
138
139
  [...I, unknown]
139
140
  >
140
141
 
141
- type PickTuple<T extends ReadonlyArray<unknown>, K> = _BuildTuple<T, K>
142
+ type PickTuple<T extends ReadonlyArray<unknown>, I extends ReadonlyArray<Indices<T>>> = {
143
+ -readonly [K in keyof I]: T[I[K] & keyof T]
144
+ }
142
145
 
143
146
  /**
144
147
  * Creates a new tuple containing only the elements at the specified indices.
@@ -189,7 +192,7 @@ export const pick: {
189
192
  * @category filtering
190
193
  * @since 4.0.0
191
194
  */
192
- <const T extends ReadonlyArray<unknown>, const I extends ReadonlyArray<Indices<T>>>(indices: I): (self: T) => PickTuple<T, I[number]>
195
+ <const T extends ReadonlyArray<unknown>, const I extends ReadonlyArray<Indices<T>>>(indices: I): (self: T) => PickTuple<T, I>
193
196
  /**
194
197
  * Creates a new tuple containing only the elements at the specified indices.
195
198
  *
@@ -214,7 +217,7 @@ export const pick: {
214
217
  * @category filtering
215
218
  * @since 4.0.0
216
219
  */
217
- <const T extends ReadonlyArray<unknown>, const I extends ReadonlyArray<Indices<T>>>(self: T, indices: I): PickTuple<T, I[number]>
220
+ <const T extends ReadonlyArray<unknown>, const I extends ReadonlyArray<Indices<T>>>(self: T, indices: I): PickTuple<T, I>
218
221
  } = dual(
219
222
  2,
220
223
  <const T extends ReadonlyArray<unknown>>(
@@ -266,24 +266,24 @@ export const acquireWrite = (self: TxReentrantLock): Effect.Effect<number> =>
266
266
  * @category mutations
267
267
  * @since 2.0.0
268
268
  */
269
- export const releaseRead = (self: TxReentrantLock): Effect.Effect<number> =>
270
- Effect.withFiber((fiber) =>
271
- Effect.gen(function*() {
272
- const state = yield* TxRef.get(self.stateRef)
273
- const fiberId = fiber.id
274
- const currentCount = Option.getOrElse(HashMap.get(state.readers, fiberId), () => 0)
269
+ const releaseReadFor = (self: TxReentrantLock, fiberId: number): Effect.Effect<number> =>
270
+ Effect.gen(function*() {
271
+ const state = yield* TxRef.get(self.stateRef)
272
+ const currentCount = Option.getOrElse(HashMap.get(state.readers, fiberId), () => 0)
275
273
 
276
- if (currentCount <= 0) return 0
274
+ if (currentCount <= 0) return 0
277
275
 
278
- const newCount = currentCount - 1
279
- const newReaders = newCount === 0
280
- ? HashMap.remove(state.readers, fiberId)
281
- : HashMap.set(state.readers, fiberId, newCount)
276
+ const newCount = currentCount - 1
277
+ const newReaders = newCount === 0
278
+ ? HashMap.remove(state.readers, fiberId)
279
+ : HashMap.set(state.readers, fiberId, newCount)
282
280
 
283
- yield* TxRef.set(self.stateRef, { ...state, readers: newReaders })
284
- return newCount
285
- }).pipe(Effect.tx)
286
- )
281
+ yield* TxRef.set(self.stateRef, { ...state, readers: newReaders })
282
+ return newCount
283
+ }).pipe(Effect.tx)
284
+
285
+ export const releaseRead = (self: TxReentrantLock): Effect.Effect<number> =>
286
+ Effect.withFiber((fiber) => releaseReadFor(self, fiber.id))
287
287
 
288
288
  /**
289
289
  * Releases one write lock held by the current fiber.
@@ -313,23 +313,23 @@ export const releaseRead = (self: TxReentrantLock): Effect.Effect<number> =>
313
313
  * @category mutations
314
314
  * @since 2.0.0
315
315
  */
316
- export const releaseWrite = (self: TxReentrantLock): Effect.Effect<number> =>
317
- Effect.withFiber((fiber) =>
318
- Effect.gen(function*() {
319
- const state = yield* TxRef.get(self.stateRef)
320
- const fiberId = fiber.id
316
+ const releaseWriteFor = (self: TxReentrantLock, fiberId: number): Effect.Effect<number> =>
317
+ Effect.gen(function*() {
318
+ const state = yield* TxRef.get(self.stateRef)
321
319
 
322
- if (Option.isNone(state.writer) || state.writer.value[0] !== fiberId) return 0
320
+ if (Option.isNone(state.writer) || state.writer.value[0] !== fiberId) return 0
323
321
 
324
- const newCount = state.writer.value[1] - 1
325
- const newWriter = newCount <= 0
326
- ? Option.none<readonly [number, number]>()
327
- : Option.some([fiberId, newCount] as const)
322
+ const newCount = state.writer.value[1] - 1
323
+ const newWriter = newCount <= 0
324
+ ? Option.none<readonly [number, number]>()
325
+ : Option.some([fiberId, newCount] as const)
328
326
 
329
- yield* TxRef.set(self.stateRef, { ...state, writer: newWriter })
330
- return newCount
331
- }).pipe(Effect.tx)
332
- )
327
+ yield* TxRef.set(self.stateRef, { ...state, writer: newWriter })
328
+ return newCount
329
+ }).pipe(Effect.tx)
330
+
331
+ export const releaseWrite = (self: TxReentrantLock): Effect.Effect<number> =>
332
+ Effect.withFiber((fiber) => releaseWriteFor(self, fiber.id))
333
333
 
334
334
  /**
335
335
  * Acquires a read lock for the duration of the scope.
@@ -361,9 +361,11 @@ export const releaseWrite = (self: TxReentrantLock): Effect.Effect<number> =>
361
361
  * @since 2.0.0
362
362
  */
363
363
  export const readLock = (self: TxReentrantLock): Effect.Effect<number, never, Scope.Scope> =>
364
- Effect.acquireRelease(
365
- acquireRead(self),
366
- () => releaseRead(self)
364
+ Effect.withFiber((fiber) =>
365
+ Effect.acquireRelease(
366
+ acquireRead(self),
367
+ () => releaseReadFor(self, fiber.id)
368
+ )
367
369
  )
368
370
 
369
371
  /**
@@ -396,9 +398,11 @@ export const readLock = (self: TxReentrantLock): Effect.Effect<number, never, Sc
396
398
  * @since 2.0.0
397
399
  */
398
400
  export const writeLock = (self: TxReentrantLock): Effect.Effect<number, never, Scope.Scope> =>
399
- Effect.acquireRelease(
400
- acquireWrite(self),
401
- () => releaseWrite(self)
401
+ Effect.withFiber((fiber) =>
402
+ Effect.acquireRelease(
403
+ acquireWrite(self),
404
+ () => releaseWriteFor(self, fiber.id)
405
+ )
402
406
  )
403
407
 
404
408
  /**
@@ -221,7 +221,7 @@ export const makeUnsafe = <A extends DateTime.DateTime.Input>(input: A): DateTim
221
221
  return fromDateUnsafe(input) as DateTime.DateTime.PreserveZone<A>
222
222
  } else if (typeof input === "object") {
223
223
  if ("epochMilliseconds" in input) {
224
- return makeUtc(input.epochMilliseconds) as DateTime.DateTime.PreserveZone<A>
224
+ return fromDateUnsafe(new Date(input.epochMilliseconds)) as DateTime.DateTime.PreserveZone<A>
225
225
  }
226
226
  const date = new Date(0)
227
227
  setPartsDate(date, input)
@@ -1,47 +1,131 @@
1
+ import * as Duration from "../Duration.ts"
1
2
  import type { Effect } from "../Effect.ts"
2
3
  import * as Api from "../ExecutionPlan.ts"
3
- import { dual } from "../Function.ts"
4
+ import type * as Exit from "../Exit.ts"
5
+ import { dual, identity } from "../Function.ts"
4
6
  import * as Result from "../Result.ts"
5
7
  import * as Schedule from "../Schedule.ts"
8
+ import { isEffect } from "./core.ts"
6
9
  import * as effect from "./effect.ts"
7
10
  import * as internalLayer from "./layer.ts"
8
11
  import * as internalSchedule from "./schedule.ts"
9
12
 
13
+ /** @internal */
14
+ export interface AttemptState {
15
+ readonly attempt: number
16
+ readonly stepAttempt: number
17
+ readonly stepIndex: number
18
+ readonly startNanos: bigint
19
+ }
20
+
21
+ /** @internal */
22
+ export interface EventEmitter {
23
+ readonly begin: Effect<AttemptState, never, any>
24
+ readonly end: (state: AttemptState, exit: Exit.Exit<any, any>) => Effect<void, never, any>
25
+ }
26
+
27
+ /** @internal */
28
+ export const makeEventEmitter = (
29
+ onEvent: (event: Api.Event<any>) => Effect<void, never, any>,
30
+ currentMetadata: () => Api.Metadata
31
+ ): EventEmitter => {
32
+ let lastStepIndex = -1
33
+ let stepAttempt = 0
34
+ return {
35
+ begin: effect.clockWith((clock) =>
36
+ effect.suspend(() => {
37
+ const meta = currentMetadata()
38
+ if (meta.stepIndex !== lastStepIndex) {
39
+ lastStepIndex = meta.stepIndex
40
+ stepAttempt = 0
41
+ }
42
+ stepAttempt++
43
+ const state: AttemptState = {
44
+ attempt: meta.attempt,
45
+ stepAttempt,
46
+ stepIndex: meta.stepIndex,
47
+ startNanos: clock.monotonicTimeNanosUnsafe()
48
+ }
49
+ return effect.as(
50
+ onEvent({
51
+ _tag: "AttemptStart",
52
+ attempt: state.attempt,
53
+ stepAttempt: state.stepAttempt,
54
+ stepIndex: state.stepIndex
55
+ }),
56
+ state
57
+ )
58
+ })
59
+ ),
60
+ end: (state, exit) =>
61
+ effect.clockWith((clock) => {
62
+ const duration = Duration.nanos(clock.monotonicTimeNanosUnsafe() - state.startNanos)
63
+ return onEvent(
64
+ exit._tag === "Success"
65
+ ? {
66
+ _tag: "AttemptSuccess",
67
+ attempt: state.attempt,
68
+ stepAttempt: state.stepAttempt,
69
+ stepIndex: state.stepIndex,
70
+ duration
71
+ }
72
+ : {
73
+ _tag: "AttemptFailure",
74
+ attempt: state.attempt,
75
+ stepAttempt: state.stepAttempt,
76
+ stepIndex: state.stepIndex,
77
+ duration,
78
+ cause: exit.cause
79
+ }
80
+ )
81
+ })
82
+ }
83
+ }
84
+
10
85
  /** @internal */
11
86
  export const withExecutionPlan: {
12
- <Input, Provides, PlanE, PlanR>(
87
+ <Input, Provides, PlanE, PlanR, RX = never>(
13
88
  plan: Api.ExecutionPlan<{
14
89
  provides: Provides
15
90
  input: Input
16
91
  error: PlanE
17
92
  requirements: PlanR
18
- }>
93
+ }>,
94
+ options?: {
95
+ readonly onEvent?: ((event: Api.Event<Input | PlanE>) => Effect<void, never, RX>) | undefined
96
+ }
19
97
  ): <A, E extends Input, R>(effect: Effect<A, E, R>) => Effect<
20
98
  A,
21
99
  E | PlanE,
22
- Exclude<R, Provides> | PlanR
100
+ Exclude<R, Provides> | PlanR | RX
23
101
  >
24
- <A, E extends Input, R, Provides, Input, PlanE, PlanR>(
102
+ <A, E extends Input, R, Provides, Input, PlanE, PlanR, RX = never>(
25
103
  effect: Effect<A, E, R>,
26
104
  plan: Api.ExecutionPlan<{
27
105
  provides: Provides
28
106
  input: Input
29
107
  error: PlanE
30
108
  requirements: PlanR
31
- }>
109
+ }>,
110
+ options?: {
111
+ readonly onEvent?: ((event: Api.Event<E | PlanE>) => Effect<void, never, RX>) | undefined
112
+ }
32
113
  ): Effect<
33
114
  A,
34
115
  E | PlanE,
35
- Exclude<R, Provides> | PlanR
116
+ Exclude<R, Provides> | PlanR | RX
36
117
  >
37
- } = dual(2, <A, E extends Input, R, Provides, Input, PlanE, PlanR>(
118
+ } = dual((args) => isEffect(args[0]), <A, E extends Input, R, Provides, Input, PlanE, PlanR, RX>(
38
119
  self: Effect<A, E, R>,
39
120
  plan: Api.ExecutionPlan<{
40
121
  provides: Provides
41
122
  input: Input
42
123
  error: PlanE
43
124
  requirements: PlanR
44
- }>
125
+ }>,
126
+ options?: {
127
+ readonly onEvent?: ((event: Api.Event<E | PlanE>) => Effect<void, never, RX>) | undefined
128
+ }
45
129
  ) =>
46
130
  effect.suspend(() => {
47
131
  let i = 0
@@ -59,13 +143,24 @@ export const withExecutionPlan: {
59
143
  return meta
60
144
  })
61
145
  )
146
+ const emitter = options?.onEvent === undefined
147
+ ? undefined
148
+ : makeEventEmitter(options.onEvent, () => meta)
149
+ const instrument: (attempt: Effect<A, any, any>) => Effect<A, any, any> = emitter === undefined
150
+ ? identity
151
+ : (attempt) =>
152
+ effect.uninterruptibleMask((restore) =>
153
+ effect.flatMap(emitter.begin, (state) => effect.onExit(restore(attempt), (exit) => emitter.end(state, exit)))
154
+ )
62
155
  let result: Result.Result<A, any> | undefined
63
156
  return effect.flatMap(
64
157
  effect.whileLoop({
65
158
  while: () => i < plan.steps.length && (result === undefined || Result.isFailure(result)),
66
159
  body() {
67
160
  const step = plan.steps[i]
68
- let nextEffect: Effect<A, any, any> = provideMeta(internalLayer.provide(self, step.provide as any))
161
+ let nextEffect: Effect<A, any, any> = provideMeta(
162
+ instrument(internalLayer.provide(self, step.provide as any))
163
+ )
69
164
  if (result) {
70
165
  let attempted = false
71
166
  const wrapped = nextEffect
@@ -977,13 +977,8 @@ export const hasBy = dual<
977
977
  return false
978
978
  })
979
979
 
980
- /** @internal */
981
- export const set = dual<
982
- <K, V>(key: K, value: V) => (self: HashMap<K, V>) => HashMap<K, V>,
983
- <K, V>(self: HashMap<K, V>, key: K, value: V) => HashMap<K, V>
984
- >(3, <K, V>(self: HashMap<K, V>, key: K, value: V): HashMap<K, V> => {
980
+ const setHash = <K, V>(self: HashMap<K, V>, key: K, hash: number, value: V): HashMap<K, V> => {
985
981
  const impl = self as HashMapImpl<K, V>
986
- const hash = Hash.hash(key)
987
982
  const added = { value: false }
988
983
 
989
984
  // Pass edit context: use current edit if editable, otherwise NaN (never matches any edit)
@@ -1005,6 +1000,14 @@ export const set = dual<
1005
1000
  }
1006
1001
 
1007
1002
  return new HashMapImpl(false, impl._edit, newRoot, impl._size + (added.value ? 1 : 0))
1003
+ }
1004
+
1005
+ /** @internal */
1006
+ export const set = dual<
1007
+ <K, V>(key: K, value: V) => (self: HashMap<K, V>) => HashMap<K, V>,
1008
+ <K, V>(self: HashMap<K, V>, key: K, value: V) => HashMap<K, V>
1009
+ >(3, <K, V>(self: HashMap<K, V>, key: K, value: V): HashMap<K, V> => {
1010
+ return setHash(self, key, Hash.hash(key), value)
1008
1011
  })
1009
1012
 
1010
1013
  /** @internal */
@@ -1104,10 +1107,10 @@ export const modifyHash = dual<
1104
1107
  const updated = f(current)
1105
1108
 
1106
1109
  if (Option.isNone(updated)) {
1107
- return hasHash(self, key, hash) ? remove(self, key) : self
1110
+ return hasHash(self, key, hash) ? removeHash(self, key, hash) : self
1108
1111
  }
1109
1112
 
1110
- return set(self, key, updated.value)
1113
+ return setHash(self, key, hash, updated.value)
1111
1114
  })
1112
1115
 
1113
1116
  /** @internal */
@@ -1130,13 +1133,8 @@ export const union = dual<
1130
1133
  return result
1131
1134
  })
1132
1135
 
1133
- /** @internal */
1134
- export const remove = dual<
1135
- <K>(key: K) => <V>(self: HashMap<K, V>) => HashMap<K, V>,
1136
- <K, V>(self: HashMap<K, V>, key: K) => HashMap<K, V>
1137
- >(2, <K, V>(self: HashMap<K, V>, key: K): HashMap<K, V> => {
1136
+ const removeHash = <K, V>(self: HashMap<K, V>, key: K, hash: number): HashMap<K, V> => {
1138
1137
  const impl = self as HashMapImpl<K, V>
1139
- const hash = Hash.hash(key)
1140
1138
  const removed = { value: false }
1141
1139
 
1142
1140
  const edit = impl._editable ? impl._edit : NaN
@@ -1157,6 +1155,14 @@ export const remove = dual<
1157
1155
  }
1158
1156
 
1159
1157
  return new HashMapImpl(false, impl._edit, newRoot, impl._size - 1)
1158
+ }
1159
+
1160
+ /** @internal */
1161
+ export const remove = dual<
1162
+ <K>(key: K) => <V>(self: HashMap<K, V>) => HashMap<K, V>,
1163
+ <K, V>(self: HashMap<K, V>, key: K) => HashMap<K, V>
1164
+ >(2, <K, V>(self: HashMap<K, V>, key: K): HashMap<K, V> => {
1165
+ return removeHash(self, key, Hash.hash(key))
1160
1166
  })
1161
1167
 
1162
1168
  /** @internal */
@@ -124,8 +124,8 @@ const makePredicate = (pattern: unknown): Predicate.Predicate<unknown> => {
124
124
  return true
125
125
  }
126
126
  } else if (pattern !== null && typeof pattern === "object") {
127
- const keysAndPredicates = Object.entries(pattern).map(
128
- ([k, p]) => [k, makePredicate(p)] as const
127
+ const keysAndPredicates = Reflect.ownKeys(pattern).map(
128
+ (key) => [key, makePredicate((pattern as any)[key])] as const
129
129
  )
130
130
  const len = keysAndPredicates.length
131
131
 
@@ -184,17 +184,17 @@ export const scheduleFrom = dual<
184
184
  schedule: Schedule.Schedule<Output, Input, Error, Env>
185
185
  ) => <E, R>(
186
186
  self: Effect<Input, E, R>
187
- ) => Effect<Output, E, R | Env>,
187
+ ) => Effect<Output, E | Error, R | Env>,
188
188
  <Input, E, R, Output, Error, Env>(
189
189
  self: Effect<Input, E, R>,
190
190
  initial: Input,
191
191
  schedule: Schedule.Schedule<Output, Input, Error, Env>
192
- ) => Effect<Output, E, R | Env>
192
+ ) => Effect<Output, E | Error, R | Env>
193
193
  >(3, <Input, E, R, Output, Error, Env>(
194
194
  self: Effect<Input, E, R>,
195
195
  initial: Input,
196
196
  schedule: Schedule.Schedule<Output, Input, Error, Env>
197
- ): Effect<Output, E, R | Env> =>
197
+ ): Effect<Output, E | Error, R | Env> =>
198
198
  effect.flatMap(Schedule.toStepWithMetadata(schedule), (step) => {
199
199
  let meta = Schedule.CurrentMetadata.defaultValue()
200
200
  const selfWithMeta = effect.suspend(() => effect.provideService(self, Schedule.CurrentMetadata, meta))
@@ -213,7 +213,7 @@ export const scheduleFrom = dual<
213
213
  }) as Effect<never, E, R | Env>
214
214
  }
215
215
  ),
216
- (error) => core.isDone(error) ? effect.succeed(error.value as Output) : effect.fail(error as E)
216
+ (error) => core.isDone(error) ? effect.succeed(error.value as Output) : effect.fail(error as E | Error)
217
217
  )
218
218
  }))
219
219
 
@@ -21,6 +21,9 @@ export const IDENTIFIER_FALLBACK_KEY = "~identifier"
21
21
  /** @internal */
22
22
  export const SENTINELS_ANNOTATION_KEY = "~sentinels"
23
23
 
24
+ /** @internal */
25
+ export const CONSTRUCTOR_ANNOTATION_KEY = "~constructor"
26
+
24
27
  /** @internal */
25
28
  export const jsonSchemaAnnotationKeys = [
26
29
  "title",
@@ -717,7 +717,9 @@ function base(ast: SchemaAST.AST, path: ReadonlyArray<PropertyKey>): LazyArbitra
717
717
  : out.map(Option.some)
718
718
  }
719
719
  )
720
- let out = fc.tuple(...elementArbitraries).map(Array.getSomes)
720
+ let out = fc.tuple(...elementArbitraries).map((elements) =>
721
+ Array.getSomes(Array.takeWhile(elements, Option.isSome))
722
+ )
721
723
  // ---------------------------------------------
722
724
  // handle rest element
723
725
  // ---------------------------------------------
@@ -172,7 +172,7 @@ export const insert = dual<
172
172
  key: key[0],
173
173
  count: 0
174
174
  }
175
- const count = n.count + 1
175
+ let count = n.count + 1
176
176
  let cIndex = 0
177
177
 
178
178
  while (cIndex < key.length) {
@@ -194,7 +194,17 @@ export const insert = dual<
194
194
  }
195
195
  } else {
196
196
  if (cIndex === key.length - 1) {
197
- n.value = { value }
197
+ if (n.value !== undefined) {
198
+ count -= 1
199
+ }
200
+ nStack[nStack.length - 1] = {
201
+ key: n.key,
202
+ count,
203
+ value: { value },
204
+ left: n.left,
205
+ mid: n.mid,
206
+ right: n.right
207
+ }
198
208
  } else if (n.mid === undefined) {
199
209
  dStack.push(0)
200
210
  n = { key: key[cIndex + 1], count }
@@ -203,6 +203,14 @@ const SleepOrder = Order.flip(Order.Struct({
203
203
  sequence: Order.Number
204
204
  }))
205
205
 
206
+ const nanosPerMilli = BigInt(1_000_000)
207
+
208
+ const millisToNanos = (millis: number): bigint => {
209
+ const wholeMillis = Math.floor(millis)
210
+ const fractionalNanos = Math.floor((millis - wholeMillis) * 1_000_000)
211
+ return BigInt(wholeMillis) * nanosPerMilli + BigInt(fractionalNanos)
212
+ }
213
+
206
214
  /**
207
215
  * Creates a `TestClock` with optional configuration.
208
216
  *
@@ -247,6 +255,7 @@ export const make = Effect.fnUntraced(function*(
247
255
  const warningSemaphore = yield* Semaphore.make(1)
248
256
 
249
257
  let currentTimestamp: number = new Date(0).getTime()
258
+ let currentWallNanos = BigInt(0)
250
259
  let currentMonotonicNanos = BigInt(0)
251
260
  let warningState: WarningState = WarningState.Start()
252
261
 
@@ -255,7 +264,7 @@ export const make = Effect.fnUntraced(function*(
255
264
  }
256
265
 
257
266
  function currentTimeNanosUnsafe(): bigint {
258
- return BigInt(Math.floor(currentTimestamp * 1000000))
267
+ return currentWallNanos
259
268
  }
260
269
 
261
270
  function monotonicTimeNanosUnsafe(): bigint {
@@ -339,6 +348,9 @@ export const make = Effect.fnUntraced(function*(
339
348
  if (deltaMillis > 0 && Number.isFinite(deltaMillis)) {
340
349
  currentMonotonicNanos += BigInt(Math.round(deltaMillis * 1_000_000))
341
350
  }
351
+ if (Number.isFinite(timestamp)) {
352
+ currentWallNanos = millisToNanos(timestamp)
353
+ }
342
354
  currentTimestamp = timestamp
343
355
  }
344
356
  while (Arr.isArrayNonEmpty(sleeps)) {
@@ -459,7 +459,7 @@ export class Encoding<S extends Schema.Constraint> {
459
459
  readonly encodeUnknownEffect: (
460
460
  input: unknown,
461
461
  options?: SchemaAST.ParseOptions
462
- ) => Effect.Effect<S["Type"], SchemaIssue.Issue, S["EncodingServices"]>
462
+ ) => Effect.Effect<S["Encoded"], SchemaIssue.Issue, S["EncodingServices"]>
463
463
  readonly options?: {
464
464
  readonly parseOptions?: SchemaAST.ParseOptions | undefined
465
465
  } | undefined