effect 4.0.0-beta.101 → 4.0.0-beta.102

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 (494) hide show
  1. package/dist/Array.d.ts.map +1 -1
  2. package/dist/Array.js +81 -5
  3. package/dist/Array.js.map +1 -1
  4. package/dist/Channel.d.ts.map +1 -1
  5. package/dist/Channel.js +27 -9
  6. package/dist/Channel.js.map +1 -1
  7. package/dist/Config.d.ts +1 -1
  8. package/dist/Config.d.ts.map +1 -1
  9. package/dist/Config.js +6 -5
  10. package/dist/Config.js.map +1 -1
  11. package/dist/ConfigProvider.js +7 -7
  12. package/dist/ConfigProvider.js.map +1 -1
  13. package/dist/Data.d.ts.map +1 -1
  14. package/dist/Data.js +2 -1
  15. package/dist/Data.js.map +1 -1
  16. package/dist/Effect.d.ts +61 -100
  17. package/dist/Effect.d.ts.map +1 -1
  18. package/dist/Effect.js +66 -39
  19. package/dist/Effect.js.map +1 -1
  20. package/dist/FiberHandle.d.ts.map +1 -1
  21. package/dist/FiberHandle.js +3 -2
  22. package/dist/FiberHandle.js.map +1 -1
  23. package/dist/Iterable.d.ts.map +1 -1
  24. package/dist/Iterable.js +2 -1
  25. package/dist/Iterable.js.map +1 -1
  26. package/dist/JsonPatch.d.ts.map +1 -1
  27. package/dist/JsonPatch.js +4 -3
  28. package/dist/JsonPatch.js.map +1 -1
  29. package/dist/JsonSchema.d.ts.map +1 -1
  30. package/dist/JsonSchema.js +9 -11
  31. package/dist/JsonSchema.js.map +1 -1
  32. package/dist/Logger.d.ts.map +1 -1
  33. package/dist/Logger.js +3 -2
  34. package/dist/Logger.js.map +1 -1
  35. package/dist/ManagedRuntime.d.ts +9 -0
  36. package/dist/ManagedRuntime.d.ts.map +1 -1
  37. package/dist/ManagedRuntime.js +3 -0
  38. package/dist/ManagedRuntime.js.map +1 -1
  39. package/dist/Metric.d.ts.map +1 -1
  40. package/dist/Metric.js +4 -3
  41. package/dist/Metric.js.map +1 -1
  42. package/dist/Optic.d.ts.map +1 -1
  43. package/dist/Optic.js +5 -4
  44. package/dist/Optic.js.map +1 -1
  45. package/dist/Option.d.ts.map +1 -1
  46. package/dist/Option.js +2 -1
  47. package/dist/Option.js.map +1 -1
  48. package/dist/PartitionedSemaphore.d.ts.map +1 -1
  49. package/dist/PartitionedSemaphore.js +1 -4
  50. package/dist/PartitionedSemaphore.js.map +1 -1
  51. package/dist/Record.d.ts +93 -1
  52. package/dist/Record.d.ts.map +1 -1
  53. package/dist/Record.js +57 -19
  54. package/dist/Record.js.map +1 -1
  55. package/dist/References.d.ts +0 -45
  56. package/dist/References.d.ts.map +1 -1
  57. package/dist/References.js +0 -45
  58. package/dist/References.js.map +1 -1
  59. package/dist/Request.d.ts.map +1 -1
  60. package/dist/Request.js +9 -6
  61. package/dist/Request.js.map +1 -1
  62. package/dist/Result.d.ts.map +1 -1
  63. package/dist/Result.js +2 -1
  64. package/dist/Result.js.map +1 -1
  65. package/dist/Schema.d.ts +1268 -495
  66. package/dist/Schema.d.ts.map +1 -1
  67. package/dist/Schema.js +2308 -614
  68. package/dist/Schema.js.map +1 -1
  69. package/dist/SchemaAST.d.ts +2 -2
  70. package/dist/SchemaAST.d.ts.map +1 -1
  71. package/dist/SchemaAST.js +189 -130
  72. package/dist/SchemaAST.js.map +1 -1
  73. package/dist/SchemaError.js +1 -1
  74. package/dist/SchemaError.js.map +1 -1
  75. package/dist/SchemaGetter.d.ts +13 -11
  76. package/dist/SchemaGetter.d.ts.map +1 -1
  77. package/dist/SchemaGetter.js +34 -24
  78. package/dist/SchemaGetter.js.map +1 -1
  79. package/dist/SchemaIssue.js +1 -1
  80. package/dist/SchemaIssue.js.map +1 -1
  81. package/dist/SchemaParser.d.ts.map +1 -1
  82. package/dist/SchemaParser.js +1 -12
  83. package/dist/SchemaParser.js.map +1 -1
  84. package/dist/SchemaRepresentation.d.ts +403 -1504
  85. package/dist/SchemaRepresentation.d.ts.map +1 -1
  86. package/dist/SchemaRepresentation.js +294 -2852
  87. package/dist/SchemaRepresentation.js.map +1 -1
  88. package/dist/SchemaTransformation.d.ts +2 -2
  89. package/dist/SchemaTransformation.js +3 -3
  90. package/dist/SchemaTransformation.js.map +1 -1
  91. package/dist/Semaphore.d.ts +5 -3
  92. package/dist/Semaphore.d.ts.map +1 -1
  93. package/dist/Semaphore.js.map +1 -1
  94. package/dist/Stream.d.ts +15 -9
  95. package/dist/Stream.d.ts.map +1 -1
  96. package/dist/Stream.js +46 -16
  97. package/dist/Stream.js.map +1 -1
  98. package/dist/Struct.d.ts.map +1 -1
  99. package/dist/Struct.js +5 -4
  100. package/dist/Struct.js.map +1 -1
  101. package/dist/Types.d.ts +1 -3
  102. package/dist/Types.d.ts.map +1 -1
  103. package/dist/index.d.ts +0 -4
  104. package/dist/index.d.ts.map +1 -1
  105. package/dist/index.js +0 -4
  106. package/dist/index.js.map +1 -1
  107. package/dist/internal/core.js +2 -1
  108. package/dist/internal/core.js.map +1 -1
  109. package/dist/internal/effect.js +64 -21
  110. package/dist/internal/effect.js.map +1 -1
  111. package/dist/internal/matcher.js +1 -1
  112. package/dist/internal/matcher.js.map +1 -1
  113. package/dist/internal/record.d.ts +0 -3
  114. package/dist/internal/record.d.ts.map +1 -1
  115. package/dist/internal/record.js +10 -5
  116. package/dist/internal/record.js.map +1 -1
  117. package/dist/internal/references.js +0 -4
  118. package/dist/internal/references.js.map +1 -1
  119. package/dist/internal/schema/annotations.js +12 -0
  120. package/dist/internal/schema/annotations.js.map +1 -1
  121. package/dist/internal/schema/fromJsonSchemaDocument.d.ts +2 -0
  122. package/dist/internal/schema/fromJsonSchemaDocument.d.ts.map +1 -0
  123. package/dist/internal/schema/fromJsonSchemaDocument.js +743 -0
  124. package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -0
  125. package/dist/internal/schema/fromRepresentation.d.ts +2 -0
  126. package/dist/internal/schema/fromRepresentation.d.ts.map +1 -0
  127. package/dist/internal/schema/fromRepresentation.js +252 -0
  128. package/dist/internal/schema/fromRepresentation.js.map +1 -0
  129. package/dist/internal/schema/schema.js +28 -40
  130. package/dist/internal/schema/schema.js.map +1 -1
  131. package/dist/internal/schema/{arbitrary.d.ts → toArbitrary.d.ts} +1 -1
  132. package/dist/internal/schema/toArbitrary.d.ts.map +1 -0
  133. package/dist/internal/schema/{arbitrary.js → toArbitrary.js} +8 -9
  134. package/dist/internal/schema/toArbitrary.js.map +1 -0
  135. package/dist/internal/schema/toCodeDocument.d.ts +2 -0
  136. package/dist/internal/schema/toCodeDocument.d.ts.map +1 -0
  137. package/dist/internal/schema/toCodeDocument.js +438 -0
  138. package/dist/internal/schema/toCodeDocument.js.map +1 -0
  139. package/dist/internal/schema/toEquivalence.d.ts +2 -0
  140. package/dist/internal/schema/toEquivalence.d.ts.map +1 -0
  141. package/dist/internal/schema/{equivalence.js → toEquivalence.js} +15 -13
  142. package/dist/internal/schema/toEquivalence.js.map +1 -0
  143. package/dist/internal/schema/toJsonSchemaDocument.d.ts +2 -0
  144. package/dist/internal/schema/toJsonSchemaDocument.d.ts.map +1 -0
  145. package/dist/internal/schema/toJsonSchemaDocument.js +466 -0
  146. package/dist/internal/schema/toJsonSchemaDocument.js.map +1 -0
  147. package/dist/internal/schema/toRepresentation.d.ts +2 -0
  148. package/dist/internal/schema/toRepresentation.d.ts.map +1 -0
  149. package/dist/internal/schema/toRepresentation.js +369 -0
  150. package/dist/internal/schema/toRepresentation.js.map +1 -0
  151. package/dist/internal/stackTraceLimit.js +3 -6
  152. package/dist/internal/stackTraceLimit.js.map +1 -1
  153. package/dist/testing/TestClock.js +4 -1
  154. package/dist/testing/TestClock.js.map +1 -1
  155. package/dist/unstable/ai/AiError.d.ts +26 -26
  156. package/dist/unstable/ai/AiError.d.ts.map +1 -1
  157. package/dist/unstable/ai/AiError.js +5 -4
  158. package/dist/unstable/ai/AiError.js.map +1 -1
  159. package/dist/unstable/ai/AnthropicStructuredOutput.d.ts +21 -6
  160. package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
  161. package/dist/unstable/ai/AnthropicStructuredOutput.js +86 -316
  162. package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
  163. package/dist/unstable/ai/EmbeddingModel.d.ts +1 -1
  164. package/dist/unstable/ai/EmbeddingModel.js +1 -1
  165. package/dist/unstable/ai/EmbeddingModel.js.map +1 -1
  166. package/dist/unstable/ai/LanguageModel.d.ts +4 -1
  167. package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
  168. package/dist/unstable/ai/LanguageModel.js +19 -17
  169. package/dist/unstable/ai/LanguageModel.js.map +1 -1
  170. package/dist/unstable/ai/McpSchema.d.ts +197 -197
  171. package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
  172. package/dist/unstable/ai/McpSchema.js +13 -13
  173. package/dist/unstable/ai/McpSchema.js.map +1 -1
  174. package/dist/unstable/ai/McpServer.d.ts +4 -4
  175. package/dist/unstable/ai/McpServer.d.ts.map +1 -1
  176. package/dist/unstable/ai/McpServer.js +116 -49
  177. package/dist/unstable/ai/McpServer.js.map +1 -1
  178. package/dist/unstable/ai/OpenAiStructuredOutput.d.ts +32 -10
  179. package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
  180. package/dist/unstable/ai/OpenAiStructuredOutput.js +193 -377
  181. package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
  182. package/dist/unstable/ai/Response.d.ts +19 -19
  183. package/dist/unstable/ai/Response.d.ts.map +1 -1
  184. package/dist/unstable/ai/Response.js +14 -14
  185. package/dist/unstable/ai/Response.js.map +1 -1
  186. package/dist/unstable/ai/Tool.d.ts +4 -0
  187. package/dist/unstable/ai/Tool.d.ts.map +1 -1
  188. package/dist/unstable/ai/Tool.js +11 -3
  189. package/dist/unstable/ai/Tool.js.map +1 -1
  190. package/dist/unstable/ai/Toolkit.d.ts +9 -1
  191. package/dist/unstable/ai/Toolkit.d.ts.map +1 -1
  192. package/dist/unstable/ai/Toolkit.js +14 -10
  193. package/dist/unstable/ai/Toolkit.js.map +1 -1
  194. package/dist/unstable/ai/internal/codec-transformer.js +15 -12
  195. package/dist/unstable/ai/internal/codec-transformer.js.map +1 -1
  196. package/dist/unstable/ai/internal/structured-output.d.ts +2 -0
  197. package/dist/unstable/ai/internal/structured-output.d.ts.map +1 -0
  198. package/dist/unstable/ai/internal/structured-output.js +316 -0
  199. package/dist/unstable/ai/internal/structured-output.js.map +1 -0
  200. package/dist/unstable/cli/CliError.d.ts +40 -2
  201. package/dist/unstable/cli/CliError.d.ts.map +1 -1
  202. package/dist/unstable/cli/CliError.js +45 -6
  203. package/dist/unstable/cli/CliError.js.map +1 -1
  204. package/dist/unstable/cli/Command.js +14 -5
  205. package/dist/unstable/cli/Command.js.map +1 -1
  206. package/dist/unstable/cli/Param.js +3 -3
  207. package/dist/unstable/cli/Param.js.map +1 -1
  208. package/dist/unstable/cli/Primitive.js +1 -1
  209. package/dist/unstable/cli/Primitive.js.map +1 -1
  210. package/dist/unstable/cli/internal/command.d.ts +3 -1
  211. package/dist/unstable/cli/internal/command.d.ts.map +1 -1
  212. package/dist/unstable/cli/internal/command.js +11 -4
  213. package/dist/unstable/cli/internal/command.js.map +1 -1
  214. package/dist/unstable/cli/internal/config.d.ts +0 -48
  215. package/dist/unstable/cli/internal/config.d.ts.map +1 -1
  216. package/dist/unstable/cli/internal/config.js +8 -10
  217. package/dist/unstable/cli/internal/config.js.map +1 -1
  218. package/dist/unstable/cluster/ClusterWorkflowEngine.js +1 -1
  219. package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
  220. package/dist/unstable/cluster/Entity.js +1 -1
  221. package/dist/unstable/cluster/Entity.js.map +1 -1
  222. package/dist/unstable/cluster/Envelope.d.ts.map +1 -1
  223. package/dist/unstable/cluster/Envelope.js +2 -1
  224. package/dist/unstable/cluster/Envelope.js.map +1 -1
  225. package/dist/unstable/cluster/Reply.js +1 -1
  226. package/dist/unstable/cluster/Reply.js.map +1 -1
  227. package/dist/unstable/cluster/Runner.d.ts +1 -1
  228. package/dist/unstable/cluster/Runner.js +1 -1
  229. package/dist/unstable/cluster/Runner.js.map +1 -1
  230. package/dist/unstable/cluster/RunnerAddress.d.ts +1 -1
  231. package/dist/unstable/cluster/RunnerAddress.js +1 -1
  232. package/dist/unstable/cluster/RunnerAddress.js.map +1 -1
  233. package/dist/unstable/cluster/ShardId.js +1 -1
  234. package/dist/unstable/cluster/ShardId.js.map +1 -1
  235. package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
  236. package/dist/unstable/cluster/Sharding.js +125 -24
  237. package/dist/unstable/cluster/Sharding.js.map +1 -1
  238. package/dist/unstable/cluster/ShardingConfig.d.ts +10 -2
  239. package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
  240. package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
  241. package/dist/unstable/cluster/SingleRunner.d.ts +4 -2
  242. package/dist/unstable/cluster/SingleRunner.d.ts.map +1 -1
  243. package/dist/unstable/cluster/SingleRunner.js +2 -1
  244. package/dist/unstable/cluster/SingleRunner.js.map +1 -1
  245. package/dist/unstable/cluster/SqlMessageStorage.d.ts +7 -4
  246. package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
  247. package/dist/unstable/cluster/SqlMessageStorage.js +55 -24
  248. package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
  249. package/dist/unstable/cluster/SqlRunnerStorage.d.ts.map +1 -1
  250. package/dist/unstable/cluster/SqlRunnerStorage.js +109 -62
  251. package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
  252. package/dist/unstable/cluster/internal/entityManager.js +19 -7
  253. package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
  254. package/dist/unstable/cluster/internal/shardLock.d.ts +2 -0
  255. package/dist/unstable/cluster/internal/shardLock.d.ts.map +1 -0
  256. package/dist/unstable/cluster/internal/shardLock.js +4 -0
  257. package/dist/unstable/cluster/internal/shardLock.js.map +1 -0
  258. package/dist/unstable/devtools/DevToolsSchema.d.ts +20 -20
  259. package/dist/unstable/devtools/DevToolsSchema.d.ts.map +1 -1
  260. package/dist/unstable/devtools/DevToolsSchema.js +8 -5
  261. package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
  262. package/dist/unstable/eventlog/EventJournal.d.ts +1 -1
  263. package/dist/unstable/eventlog/EventJournal.js +1 -1
  264. package/dist/unstable/eventlog/EventJournal.js.map +1 -1
  265. package/dist/unstable/eventlog/EventLog.d.ts.map +1 -1
  266. package/dist/unstable/eventlog/EventLog.js +15 -11
  267. package/dist/unstable/eventlog/EventLog.js.map +1 -1
  268. package/dist/unstable/eventlog/EventLogEncryption.d.ts +1 -1
  269. package/dist/unstable/eventlog/EventLogEncryption.js +1 -1
  270. package/dist/unstable/eventlog/EventLogEncryption.js.map +1 -1
  271. package/dist/unstable/eventlog/EventLogMessage.d.ts +4 -4
  272. package/dist/unstable/eventlog/EventLogMessage.d.ts.map +1 -1
  273. package/dist/unstable/eventlog/EventLogMessage.js +8 -3
  274. package/dist/unstable/eventlog/EventLogMessage.js.map +1 -1
  275. package/dist/unstable/eventlog/EventLogRemote.d.ts +1 -1
  276. package/dist/unstable/eventlog/SqlEventJournal.js +2 -2
  277. package/dist/unstable/eventlog/SqlEventJournal.js.map +1 -1
  278. package/dist/unstable/eventlog/SqlEventLogServerEncrypted.js +1 -1
  279. package/dist/unstable/eventlog/SqlEventLogServerEncrypted.js.map +1 -1
  280. package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js +3 -3
  281. package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js.map +1 -1
  282. package/dist/unstable/http/Cookies.d.ts.map +1 -1
  283. package/dist/unstable/http/Cookies.js +24 -22
  284. package/dist/unstable/http/Cookies.js.map +1 -1
  285. package/dist/unstable/http/Headers.js +8 -8
  286. package/dist/unstable/http/Headers.js.map +1 -1
  287. package/dist/unstable/http/HttpClientRequest.d.ts +44 -0
  288. package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
  289. package/dist/unstable/http/HttpClientRequest.js +14 -0
  290. package/dist/unstable/http/HttpClientRequest.js.map +1 -1
  291. package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
  292. package/dist/unstable/http/HttpServerRequest.js +5 -4
  293. package/dist/unstable/http/HttpServerRequest.js.map +1 -1
  294. package/dist/unstable/http/Multipart.d.ts.map +1 -1
  295. package/dist/unstable/http/Multipart.js +17 -15
  296. package/dist/unstable/http/Multipart.js.map +1 -1
  297. package/dist/unstable/http/Template.js +1 -1
  298. package/dist/unstable/http/Template.js.map +1 -1
  299. package/dist/unstable/http/UrlParams.d.ts.map +1 -1
  300. package/dist/unstable/http/UrlParams.js +17 -14
  301. package/dist/unstable/http/UrlParams.js.map +1 -1
  302. package/dist/unstable/httpapi/HttpApi.js +3 -3
  303. package/dist/unstable/httpapi/HttpApi.js.map +1 -1
  304. package/dist/unstable/httpapi/HttpApiClient.js +5 -5
  305. package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
  306. package/dist/unstable/httpapi/HttpApiGroup.js +1 -1
  307. package/dist/unstable/httpapi/HttpApiGroup.js.map +1 -1
  308. package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
  309. package/dist/unstable/httpapi/OpenApi.js +37 -24
  310. package/dist/unstable/httpapi/OpenApi.js.map +1 -1
  311. package/dist/unstable/observability/OtlpExporter.d.ts +72 -1
  312. package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
  313. package/dist/unstable/observability/OtlpExporter.js +69 -4
  314. package/dist/unstable/observability/OtlpExporter.js.map +1 -1
  315. package/dist/unstable/observability/OtlpLogger.d.ts +4 -3
  316. package/dist/unstable/observability/OtlpLogger.d.ts.map +1 -1
  317. package/dist/unstable/observability/OtlpLogger.js +2 -2
  318. package/dist/unstable/observability/OtlpLogger.js.map +1 -1
  319. package/dist/unstable/observability/OtlpMetrics.d.ts +7 -3
  320. package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
  321. package/dist/unstable/observability/OtlpMetrics.js +5 -2
  322. package/dist/unstable/observability/OtlpMetrics.js.map +1 -1
  323. package/dist/unstable/observability/OtlpTracer.d.ts +4 -3
  324. package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
  325. package/dist/unstable/observability/OtlpTracer.js +2 -2
  326. package/dist/unstable/observability/OtlpTracer.js.map +1 -1
  327. package/dist/unstable/persistence/Persistable.d.ts.map +1 -1
  328. package/dist/unstable/persistence/Persistable.js +2 -1
  329. package/dist/unstable/persistence/Persistable.js.map +1 -1
  330. package/dist/unstable/persistence/RateLimiter.d.ts +2 -2
  331. package/dist/unstable/persistence/RateLimiter.js +2 -2
  332. package/dist/unstable/persistence/RateLimiter.js.map +1 -1
  333. package/dist/unstable/persistence/Redis.d.ts.map +1 -1
  334. package/dist/unstable/persistence/Redis.js +2 -2
  335. package/dist/unstable/persistence/Redis.js.map +1 -1
  336. package/dist/unstable/process/ChildProcessSpawner.js +3 -1
  337. package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
  338. package/dist/unstable/reactivity/AsyncResult.d.ts.map +1 -1
  339. package/dist/unstable/reactivity/AsyncResult.js +4 -3
  340. package/dist/unstable/reactivity/AsyncResult.js.map +1 -1
  341. package/dist/unstable/reactivity/Atom.d.ts +83 -0
  342. package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
  343. package/dist/unstable/reactivity/Atom.js +31 -0
  344. package/dist/unstable/reactivity/Atom.js.map +1 -1
  345. package/dist/unstable/reactivity/AtomRegistry.js +1 -1
  346. package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
  347. package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
  348. package/dist/unstable/rpc/RpcClient.js +2 -1
  349. package/dist/unstable/rpc/RpcClient.js.map +1 -1
  350. package/dist/unstable/schema/VariantSchema.d.ts +1 -2
  351. package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
  352. package/dist/unstable/schema/VariantSchema.js +13 -10
  353. package/dist/unstable/schema/VariantSchema.js.map +1 -1
  354. package/dist/unstable/socket/Socket.d.ts +1 -1
  355. package/dist/unstable/socket/Socket.js +1 -1
  356. package/dist/unstable/socket/Socket.js.map +1 -1
  357. package/dist/unstable/sql/SqlError.d.ts +2 -2
  358. package/dist/unstable/sql/SqlError.js +2 -2
  359. package/dist/unstable/sql/SqlError.js.map +1 -1
  360. package/dist/unstable/sql/Statement.d.ts.map +1 -1
  361. package/dist/unstable/sql/Statement.js +7 -6
  362. package/dist/unstable/sql/Statement.js.map +1 -1
  363. package/package.json +1 -1
  364. package/src/Array.ts +86 -25
  365. package/src/Channel.ts +32 -14
  366. package/src/Config.ts +6 -5
  367. package/src/ConfigProvider.ts +7 -7
  368. package/src/Data.ts +3 -2
  369. package/src/Effect.ts +70 -116
  370. package/src/FiberHandle.ts +3 -2
  371. package/src/Iterable.ts +2 -1
  372. package/src/JsonPatch.ts +4 -3
  373. package/src/JsonSchema.ts +9 -11
  374. package/src/Logger.ts +3 -2
  375. package/src/ManagedRuntime.ts +13 -0
  376. package/src/Metric.ts +4 -3
  377. package/src/Optic.ts +5 -4
  378. package/src/Option.ts +2 -1
  379. package/src/PartitionedSemaphore.ts +1 -4
  380. package/src/Record.ts +119 -22
  381. package/src/References.ts +0 -46
  382. package/src/Request.ts +5 -7
  383. package/src/Result.ts +2 -1
  384. package/src/Schema.ts +2537 -986
  385. package/src/SchemaAST.ts +228 -149
  386. package/src/SchemaError.ts +1 -1
  387. package/src/SchemaGetter.ts +36 -29
  388. package/src/SchemaIssue.ts +1 -1
  389. package/src/SchemaParser.ts +1 -25
  390. package/src/SchemaRepresentation.ts +697 -3398
  391. package/src/SchemaTransformation.ts +3 -3
  392. package/src/Semaphore.ts +5 -3
  393. package/src/Stream.ts +63 -19
  394. package/src/Struct.ts +5 -4
  395. package/src/Types.ts +1 -3
  396. package/src/index.ts +0 -5
  397. package/src/internal/core.ts +3 -2
  398. package/src/internal/effect.ts +67 -31
  399. package/src/internal/matcher.ts +1 -1
  400. package/src/internal/record.ts +11 -7
  401. package/src/internal/references.ts +0 -5
  402. package/src/internal/schema/annotations.ts +44 -0
  403. package/src/internal/schema/fromJsonSchemaDocument.ts +957 -0
  404. package/src/internal/schema/fromRepresentation.ts +345 -0
  405. package/src/internal/schema/schema.ts +45 -46
  406. package/src/internal/schema/{arbitrary.ts → toArbitrary.ts} +8 -10
  407. package/src/internal/schema/toCodeDocument.ts +572 -0
  408. package/src/internal/schema/{equivalence.ts → toEquivalence.ts} +12 -7
  409. package/src/internal/schema/toJsonSchemaDocument.ts +475 -0
  410. package/src/internal/schema/toRepresentation.ts +401 -0
  411. package/src/internal/stackTraceLimit.ts +3 -7
  412. package/src/testing/TestClock.ts +1 -1
  413. package/src/unstable/ai/AiError.ts +5 -4
  414. package/src/unstable/ai/AnthropicStructuredOutput.ts +102 -333
  415. package/src/unstable/ai/EmbeddingModel.ts +1 -1
  416. package/src/unstable/ai/LanguageModel.ts +30 -28
  417. package/src/unstable/ai/McpSchema.ts +15 -15
  418. package/src/unstable/ai/McpServer.ts +172 -56
  419. package/src/unstable/ai/OpenAiStructuredOutput.ts +230 -395
  420. package/src/unstable/ai/Response.ts +24 -24
  421. package/src/unstable/ai/Tool.ts +22 -4
  422. package/src/unstable/ai/Toolkit.ts +19 -7
  423. package/src/unstable/ai/internal/codec-transformer.ts +13 -7
  424. package/src/unstable/ai/internal/structured-output.ts +458 -0
  425. package/src/unstable/cli/CliError.ts +51 -5
  426. package/src/unstable/cli/Command.ts +4 -4
  427. package/src/unstable/cli/Param.ts +3 -3
  428. package/src/unstable/cli/Primitive.ts +1 -1
  429. package/src/unstable/cli/internal/command.ts +13 -5
  430. package/src/unstable/cli/internal/config.ts +8 -10
  431. package/src/unstable/cluster/ClusterWorkflowEngine.ts +3 -3
  432. package/src/unstable/cluster/Entity.ts +1 -1
  433. package/src/unstable/cluster/Envelope.ts +2 -1
  434. package/src/unstable/cluster/Reply.ts +1 -1
  435. package/src/unstable/cluster/Runner.ts +1 -1
  436. package/src/unstable/cluster/RunnerAddress.ts +1 -1
  437. package/src/unstable/cluster/ShardId.ts +1 -1
  438. package/src/unstable/cluster/Sharding.ts +161 -34
  439. package/src/unstable/cluster/ShardingConfig.ts +5 -1
  440. package/src/unstable/cluster/SingleRunner.ts +4 -2
  441. package/src/unstable/cluster/SqlMessageStorage.ts +83 -35
  442. package/src/unstable/cluster/SqlRunnerStorage.ts +186 -116
  443. package/src/unstable/cluster/internal/entityManager.ts +31 -10
  444. package/src/unstable/cluster/internal/shardLock.ts +9 -0
  445. package/src/unstable/devtools/DevToolsSchema.ts +10 -5
  446. package/src/unstable/eventlog/EventJournal.ts +1 -1
  447. package/src/unstable/eventlog/EventLog.ts +21 -11
  448. package/src/unstable/eventlog/EventLogEncryption.ts +1 -1
  449. package/src/unstable/eventlog/EventLogMessage.ts +10 -3
  450. package/src/unstable/eventlog/SqlEventJournal.ts +2 -2
  451. package/src/unstable/eventlog/SqlEventLogServerEncrypted.ts +1 -1
  452. package/src/unstable/eventlog/SqlEventLogServerUnencrypted.ts +6 -3
  453. package/src/unstable/http/Cookies.ts +29 -24
  454. package/src/unstable/http/Headers.ts +8 -8
  455. package/src/unstable/http/HttpClientRequest.ts +57 -0
  456. package/src/unstable/http/HttpServerRequest.ts +5 -4
  457. package/src/unstable/http/Multipart.ts +16 -13
  458. package/src/unstable/http/Template.ts +1 -1
  459. package/src/unstable/http/UrlParams.ts +17 -14
  460. package/src/unstable/httpapi/HttpApi.ts +3 -3
  461. package/src/unstable/httpapi/HttpApiClient.ts +5 -5
  462. package/src/unstable/httpapi/HttpApiGroup.ts +1 -1
  463. package/src/unstable/httpapi/OpenApi.ts +52 -28
  464. package/src/unstable/observability/OtlpExporter.ts +109 -5
  465. package/src/unstable/observability/OtlpLogger.ts +5 -5
  466. package/src/unstable/observability/OtlpMetrics.ts +8 -4
  467. package/src/unstable/observability/OtlpTracer.ts +8 -4
  468. package/src/unstable/persistence/Persistable.ts +3 -2
  469. package/src/unstable/persistence/RateLimiter.ts +2 -2
  470. package/src/unstable/persistence/Redis.ts +2 -2
  471. package/src/unstable/process/ChildProcessSpawner.ts +1 -1
  472. package/src/unstable/reactivity/AsyncResult.ts +4 -3
  473. package/src/unstable/reactivity/Atom.ts +92 -0
  474. package/src/unstable/reactivity/AtomRegistry.ts +1 -1
  475. package/src/unstable/rpc/RpcClient.ts +2 -1
  476. package/src/unstable/schema/VariantSchema.ts +14 -24
  477. package/src/unstable/socket/Socket.ts +1 -1
  478. package/src/unstable/sql/SqlError.ts +2 -2
  479. package/src/unstable/sql/Statement.ts +7 -6
  480. package/dist/SchemaUtils.d.ts +0 -28
  481. package/dist/SchemaUtils.d.ts.map +0 -1
  482. package/dist/SchemaUtils.js +0 -45
  483. package/dist/SchemaUtils.js.map +0 -1
  484. package/dist/internal/schema/arbitrary.d.ts.map +0 -1
  485. package/dist/internal/schema/arbitrary.js.map +0 -1
  486. package/dist/internal/schema/equivalence.d.ts +0 -2
  487. package/dist/internal/schema/equivalence.d.ts.map +0 -1
  488. package/dist/internal/schema/equivalence.js.map +0 -1
  489. package/dist/internal/schema/representation.d.ts +0 -2
  490. package/dist/internal/schema/representation.d.ts.map +0 -1
  491. package/dist/internal/schema/representation.js +0 -865
  492. package/dist/internal/schema/representation.js.map +0 -1
  493. package/src/SchemaUtils.ts +0 -51
  494. package/src/internal/schema/representation.ts +0 -795
@@ -195,7 +195,7 @@ export class Transformation<in out T, in out E, RD = never, RE = never> {
195
195
  * @since 4.0.0
196
196
  */
197
197
  export function isTransformation(u: unknown): u is Transformation<any, any, unknown, unknown> {
198
- return Predicate.hasProperty(u, TypeId)
198
+ return Predicate.hasProperty(u, TypeId) && u[TypeId] === TypeId
199
199
  }
200
200
 
201
201
  /**
@@ -852,8 +852,8 @@ export const bigintFromString = new Transformation(
852
852
  *
853
853
  * **When to use**
854
854
  *
855
- * Use when you need a schema transformation to parse ISO 8601 date strings from
856
- * APIs or user input.
855
+ * Use when you need a schema transformation to parse date strings from APIs or
856
+ * user input.
857
857
  *
858
858
  * **Details**
859
859
  *
package/src/Semaphore.ts CHANGED
@@ -118,9 +118,11 @@ export interface Semaphore {
118
118
  ): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<Option.Option<A>, E, R>
119
119
 
120
120
  /**
121
- * Acquires the specified number of permits and returns the resulting
122
- * available permits, suspending the task if they are not yet available.
123
- * Concurrent pending `take` calls are processed in a first-in, first-out manner.
121
+ * Acquires the specified number of permits and returns the acquired permit
122
+ * count, suspending the task if they are not yet available. Pending `take`
123
+ * calls are scanned in registration order, but a request is served only when
124
+ * enough permits are available, so a smaller later request may overtake a
125
+ * larger earlier request.
124
126
  *
125
127
  * **When to use**
126
128
  *
package/src/Stream.ts CHANGED
@@ -9311,7 +9311,8 @@ export const catchReasons: {
9311
9311
  }[keyof Cases]
9312
9312
  >
9313
9313
  } = dual((args) => isStream(args[0]), (self, errorTag, cases, orElse) => {
9314
- const handlers: Record<string, (reason: any, error: any) => Channel.Channel<any, any, any, any, any, any, any>> = {}
9314
+ const handlers: Record<string, (reason: any, error: any) => Channel.Channel<any, any, any, any, any, any, any>> =
9315
+ Object.create(null)
9315
9316
  for (const key of Object.keys(cases)) {
9316
9317
  const handler = (cases as any)[key]
9317
9318
  handlers[key] = (reason, error) => handler(reason, error).channel
@@ -17133,7 +17134,7 @@ export const interruptWhen: {
17133
17134
  )
17134
17135
 
17135
17136
  /**
17136
- * Stops a stream after the current element when an effect completes.
17137
+ * Stops a stream after the current pull when an effect completes.
17137
17138
  *
17138
17139
  * **When to use**
17139
17140
  *
@@ -17146,8 +17147,10 @@ export const interruptWhen: {
17146
17147
  *
17147
17148
  * **Gotchas**
17148
17149
  *
17149
- * This does not interrupt an in-progress pull. Use {@link interruptWhen} when
17150
- * the stream should be interrupted immediately.
17150
+ * This does not interrupt or truncate an in-progress pull. A pull may emit
17151
+ * multiple elements in a single chunk, in which case the entire chunk is
17152
+ * emitted. Use {@link interruptWhen} when the stream should be interrupted
17153
+ * immediately.
17151
17154
  *
17152
17155
  * **Example** (Halting a stream after an effect completes)
17153
17156
  *
@@ -17174,7 +17177,7 @@ export const interruptWhen: {
17174
17177
  */
17175
17178
  export const haltWhen: {
17176
17179
  /**
17177
- * Stops a stream after the current element when an effect completes.
17180
+ * Stops a stream after the current pull when an effect completes.
17178
17181
  *
17179
17182
  * **When to use**
17180
17183
  *
@@ -17187,8 +17190,10 @@ export const haltWhen: {
17187
17190
  *
17188
17191
  * **Gotchas**
17189
17192
  *
17190
- * This does not interrupt an in-progress pull. Use {@link interruptWhen} when
17191
- * the stream should be interrupted immediately.
17193
+ * This does not interrupt or truncate an in-progress pull. A pull may emit
17194
+ * multiple elements in a single chunk, in which case the entire chunk is
17195
+ * emitted. Use {@link interruptWhen} when the stream should be interrupted
17196
+ * immediately.
17192
17197
  *
17193
17198
  * **Example** (Halting a stream after an effect completes)
17194
17199
  *
@@ -17215,7 +17220,7 @@ export const haltWhen: {
17215
17220
  */
17216
17221
  <X, E2, R2>(effect: Effect.Effect<X, E2, R2>): <A, E, R>(self: Stream<A, E, R>) => Stream<A, E2 | E, R2 | R>
17217
17222
  /**
17218
- * Stops a stream after the current element when an effect completes.
17223
+ * Stops a stream after the current pull when an effect completes.
17219
17224
  *
17220
17225
  * **When to use**
17221
17226
  *
@@ -17228,8 +17233,10 @@ export const haltWhen: {
17228
17233
  *
17229
17234
  * **Gotchas**
17230
17235
  *
17231
- * This does not interrupt an in-progress pull. Use {@link interruptWhen} when
17232
- * the stream should be interrupted immediately.
17236
+ * This does not interrupt or truncate an in-progress pull. A pull may emit
17237
+ * multiple elements in a single chunk, in which case the entire chunk is
17238
+ * emitted. Use {@link interruptWhen} when the stream should be interrupted
17239
+ * immediately.
17233
17240
  *
17234
17241
  * **Example** (Halting a stream after an effect completes)
17235
17242
  *
@@ -20193,32 +20200,69 @@ export const toAsyncIterableWith: {
20193
20200
  ): AsyncIterable<A> => ({
20194
20201
  [Symbol.asyncIterator]() {
20195
20202
  const runPromise = Effect.runPromiseWith(context)
20196
- const runPromiseExit = Effect.runPromiseExitWith(context)
20203
+ const runFork = Effect.runForkWith(context)
20197
20204
  const scope = Scope.makeUnsafe()
20198
20205
  let pull: Pull.Pull<Arr.NonEmptyReadonlyArray<A>, E, void, R> | undefined
20199
20206
  let currentIter: Iterator<A> | undefined
20207
+ let currentFiber: Fiber.Fiber<Arr.NonEmptyReadonlyArray<A>, E | Cause.Done<void>> | undefined
20208
+ let closePromise: Promise<IteratorResult<A>> | undefined
20209
+ const close = (exit: Exit.Exit<unknown, unknown>): Promise<IteratorResult<A>> => {
20210
+ if (closePromise) return closePromise
20211
+ const fiber = currentFiber
20212
+ closePromise = runPromise(Effect.as(
20213
+ Effect.andThen(
20214
+ fiber ? Fiber.interrupt(fiber) : Effect.void,
20215
+ Scope.close(scope, exit)
20216
+ ),
20217
+ { done: true, value: undefined }
20218
+ ))
20219
+ return closePromise
20220
+ }
20221
+ const closeAndReportError = async (exit: Exit.Exit<unknown, unknown>): Promise<void> => {
20222
+ try {
20223
+ await close(exit)
20224
+ } catch (error) {
20225
+ await runPromise(Effect.logError("Suppressed error while closing Stream async iterator", error))
20226
+ }
20227
+ }
20200
20228
  return {
20201
20229
  async next(): Promise<IteratorResult<A>> {
20230
+ if (closePromise) return closePromise
20202
20231
  if (currentIter) {
20203
20232
  const next = currentIter.next()
20204
20233
  if (!next.done) return next
20205
20234
  currentIter = undefined
20206
20235
  }
20207
- pull ??= await runPromise(Channel.toPullScoped(self.channel, scope))
20208
- const exit = await runPromiseExit(pull)
20236
+ const fiber = runFork(
20237
+ pull ??
20238
+ Effect.flatMap(Channel.toPullScoped(self.channel, scope), (nextPull) => {
20239
+ pull = nextPull
20240
+ return nextPull
20241
+ })
20242
+ )
20243
+ currentFiber = fiber
20244
+ const exit = await runPromise(Fiber.await(fiber))
20245
+ if (currentFiber === fiber) {
20246
+ currentFiber = undefined
20247
+ }
20209
20248
  if (Exit.isSuccess(exit)) {
20210
20249
  currentIter = exit.value[Symbol.iterator]()
20211
20250
  return currentIter.next()
20212
20251
  } else if (Pull.isDoneCause(exit.cause)) {
20213
- return { done: true, value: undefined }
20252
+ return close(Exit.void)
20214
20253
  }
20254
+ if (closePromise && Cause.hasInterruptsOnly(exit.cause)) {
20255
+ return closePromise
20256
+ }
20257
+ await closeAndReportError(exit)
20215
20258
  throw Cause.squash(exit.cause)
20216
20259
  },
20217
- return(_) {
20218
- return runPromise(Effect.as(
20219
- Scope.close(scope, Exit.void),
20220
- { done: true, value: undefined }
20221
- ))
20260
+ return() {
20261
+ return close(Exit.void)
20262
+ },
20263
+ async throw(error) {
20264
+ await closeAndReportError(Exit.die(error))
20265
+ throw error
20222
20266
  }
20223
20267
  }
20224
20268
  }
package/src/Struct.ts CHANGED
@@ -14,6 +14,7 @@
14
14
  import * as Combiner from "./Combiner.ts"
15
15
  import * as Equivalence from "./Equivalence.ts"
16
16
  import { dual } from "./Function.ts"
17
+ import * as InternalRecord from "./internal/record.ts"
17
18
  import * as order from "./Order.ts"
18
19
  import * as Reducer from "./Reducer.ts"
19
20
 
@@ -1464,7 +1465,7 @@ function buildStruct<
1464
1465
  const res = f(k, source[k])
1465
1466
  if (res) {
1466
1467
  const [nk, nv] = res
1467
- out[nk] = nv
1468
+ InternalRecord.assignProperty(out, nk, nv)
1468
1469
  }
1469
1470
  }
1470
1471
  return out
@@ -1516,7 +1517,7 @@ export function makeCombiner<A>(
1516
1517
  for (const key of keys) {
1517
1518
  const merge = combiners[key].combine(self[key], that[key])
1518
1519
  if (omitKeyWhen(merge)) continue
1519
- out[key] = merge
1520
+ InternalRecord.assignProperty(out as object, key, merge)
1520
1521
  }
1521
1522
  return out
1522
1523
  })
@@ -1571,7 +1572,7 @@ export function makeReducer<A>(
1571
1572
  for (const key of Reflect.ownKeys(reducers) as Array<keyof A>) {
1572
1573
  const iv = reducers[key].initialValue
1573
1574
  if (options?.omitKeyWhen?.(iv)) continue
1574
- initialValue[key] = iv
1575
+ InternalRecord.assignProperty(initialValue as object, key, iv)
1575
1576
  }
1576
1577
  return Reducer.make(combine, initialValue)
1577
1578
  }
@@ -1601,7 +1602,7 @@ export function Record<const Keys extends ReadonlyArray<string | symbol>, Value>
1601
1602
  ): Record<Keys[number], Value> {
1602
1603
  const out: any = {}
1603
1604
  for (const key of keys) {
1604
- out[key] = value
1605
+ InternalRecord.assignProperty(out, key, value)
1605
1606
  }
1606
1607
  return out
1607
1608
  }
package/src/Types.ts CHANGED
@@ -421,7 +421,6 @@ export type MergeRight<Target, Source> = Simplify<
421
421
  *
422
422
  * - `number` — run at most N effects concurrently.
423
423
  * - `"unbounded"` — run all effects concurrently with no limit.
424
- * - `"inherit"` — inherit the concurrency from the surrounding context.
425
424
  *
426
425
  * **Example** (Setting concurrency values)
427
426
  *
@@ -431,13 +430,12 @@ export type MergeRight<Target, Source> = Simplify<
431
430
  * const sequential: Types.Concurrency = 1
432
431
  * const limited: Types.Concurrency = 5
433
432
  * const unbounded: Types.Concurrency = "unbounded"
434
- * const inherit: Types.Concurrency = "inherit"
435
433
  * ```
436
434
  *
437
435
  * @category models
438
436
  * @since 2.0.0
439
437
  */
440
- export type Concurrency = number | "unbounded" | "inherit"
438
+ export type Concurrency = number | "unbounded"
441
439
 
442
440
  /**
443
441
  * Removes `readonly` from all properties of `T`. Supports arrays, tuples,
package/src/index.ts CHANGED
@@ -556,11 +556,6 @@ export * as SchemaRepresentation from "./SchemaRepresentation.ts"
556
556
  */
557
557
  export * as SchemaTransformation from "./SchemaTransformation.ts"
558
558
 
559
- /**
560
- * @since 4.0.0
561
- */
562
- export * as SchemaUtils from "./SchemaUtils.ts"
563
-
564
559
  /**
565
560
  * @since 2.0.0
566
561
  */
@@ -13,6 +13,7 @@ import type { StackFrame } from "../References.ts"
13
13
  import type * as Types from "../Types.ts"
14
14
  import { SingleShotGen } from "../Utils.ts"
15
15
  import type { FiberImpl } from "./effect.ts"
16
+ import * as InternalRecord from "./record.ts"
16
17
 
17
18
  /** @internal */
18
19
  export const EffectTypeId = `~effect/Effect` as const
@@ -587,10 +588,10 @@ export const Error: new<A extends Record<string, any> = {}>(
587
588
  ) => Cause.YieldableError & Readonly<A> = (function() {
588
589
  const plainArgsSymbol = Symbol.for("effect/Data/Error/plainArgs")
589
590
  return class Base extends YieldableError {
590
- constructor(args: any) {
591
+ constructor(args: Record<string, any> | undefined) {
591
592
  super(args?.message, args?.cause ? { cause: args.cause } : undefined)
592
593
  if (args) {
593
- Object.assign(this, args)
594
+ InternalRecord.assignProperties(this, args)
594
595
  // @effect-diagnostics-next-line floatingEffect:off
595
596
  Object.defineProperty(this, plainArgsSymbol, {
596
597
  value: args,
@@ -83,8 +83,8 @@ import {
83
83
  } from "./core.ts"
84
84
  import * as doNotation from "./doNotation.ts"
85
85
  import * as InternalMetric from "./metric.ts"
86
+ import * as InternalRecord from "./record.ts"
86
87
  import {
87
- CurrentConcurrency,
88
88
  CurrentErrorReporters,
89
89
  CurrentLogAnnotations,
90
90
  CurrentLogLevel,
@@ -2111,6 +2111,32 @@ export const updateService: {
2111
2111
  })
2112
2112
  )
2113
2113
 
2114
+ /** @internal */
2115
+ export const updateServiceScoped = <I, A>(
2116
+ service: Context.Key<I, A>,
2117
+ update: (value: A) => A,
2118
+ options?: {
2119
+ readonly reset?: ((original: A, updated: A, current: A) => A) | undefined
2120
+ } | undefined
2121
+ ): Effect.Effect<void, never, I | Scope.Scope> =>
2122
+ uninterruptible(withFiber((fiber) => {
2123
+ const original = Context.getUnsafe(fiber.context, service)
2124
+ const updated = update(original)
2125
+ fiber.setContext(Context.add(fiber.context, service, updated))
2126
+ return scopeAddFinalizerExit(Context.getUnsafe(fiber.context, scopeTag), (_) => {
2127
+ const current = Context.getUnsafe(fiber.context, service)
2128
+ let next: A
2129
+ if (options?.reset === undefined) {
2130
+ if (current !== updated) return void_
2131
+ next = original
2132
+ } else {
2133
+ next = options.reset(original, updated, current)
2134
+ }
2135
+ fiber.setContext(Context.add(fiber.context, service, next))
2136
+ return void_
2137
+ })
2138
+ }))
2139
+
2114
2140
  /** @internal */
2115
2141
  export const context = <R = never>(): Effect.Effect<Context.Context<R>> => getContext as any
2116
2142
  const getContext = withFiber((fiber) => succeed(fiber.context))
@@ -2222,17 +2248,6 @@ export const provideServiceEffect: {
2222
2248
  flatMap(acquire, (implementation) => provideService(self, service, implementation))
2223
2249
  )
2224
2250
 
2225
- /** @internal */
2226
- export const withConcurrency: {
2227
- (
2228
- concurrency: "unbounded" | number
2229
- ): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
2230
- <A, E, R>(
2231
- self: Effect.Effect<A, E, R>,
2232
- concurrency: "unbounded" | number
2233
- ): Effect.Effect<A, E, R>
2234
- } = provideService(CurrentConcurrency)
2235
-
2236
2251
  // ----------------------------------------------------------------------------
2237
2252
  // zipping
2238
2253
  // ----------------------------------------------------------------------------
@@ -4353,7 +4368,7 @@ export const all = <
4353
4368
  Object.entries(arg),
4354
4369
  ([key, effect]) =>
4355
4370
  map(options?.mode === "result" ? result(effect) : effect, (value) => {
4356
- out[key] = value
4371
+ InternalRecord.assignProperty(out, key, value)
4357
4372
  }),
4358
4373
  {
4359
4374
  discard: true,
@@ -4615,10 +4630,8 @@ export const forEach: {
4615
4630
  readonly discard?: boolean | undefined
4616
4631
  }
4617
4632
  ): Effect.Effect<any, E, R> =>
4618
- withFiber((parent) => {
4619
- const concurrencyOption = options?.concurrency === "inherit"
4620
- ? parent.getRef(CurrentConcurrency)
4621
- : (options?.concurrency ?? 1)
4633
+ suspend(() => {
4634
+ const concurrencyOption = options?.concurrency ?? 1
4622
4635
  const concurrency = concurrencyOption === "unbounded"
4623
4636
  ? Number.POSITIVE_INFINITY
4624
4637
  : Math.max(1, concurrencyOption)
@@ -5489,7 +5502,7 @@ const succeedFalse = succeed(false)
5489
5502
 
5490
5503
  class Latch implements _Latch.Latch {
5491
5504
  waiters: Array<(_: Effect.Effect<void>) => void> = []
5492
- scheduled = false
5505
+ scheduled: Array<(_: Effect.Effect<void>) => void> | undefined = undefined
5493
5506
  private _isOpen: boolean
5494
5507
 
5495
5508
  constructor(isOpen: boolean) {
@@ -5497,17 +5510,35 @@ class Latch implements _Latch.Latch {
5497
5510
  }
5498
5511
 
5499
5512
  private scheduleUnsafe(fiber: Fiber.Fiber<unknown, unknown>) {
5500
- if (this.scheduled || this.waiters.length === 0) {
5513
+ if (this.waiters.length === 0) {
5501
5514
  return succeedTrue
5502
5515
  }
5503
- this.scheduled = true
5504
- fiber.currentDispatcher.scheduleTask(this.flushWaiters, 0)
5516
+ if (this.scheduled === undefined) {
5517
+ this.scheduled = this.waiters
5518
+ fiber.currentDispatcher.scheduleTask(this.flushScheduled, 0)
5519
+ } else {
5520
+ for (let i = 0; i < this.waiters.length; i++) {
5521
+ this.scheduled.push(this.waiters[i])
5522
+ }
5523
+ }
5524
+ this.waiters = []
5505
5525
  return succeedTrue
5506
5526
  }
5507
- private flushWaiters = () => {
5508
- this.scheduled = false
5527
+ private flushScheduled = () => {
5528
+ if (this.scheduled === undefined) return
5529
+ const waiters = this.scheduled
5530
+ this.scheduled = undefined
5531
+ for (let i = 0; i < waiters.length; i++) {
5532
+ waiters[i](exitVoid)
5533
+ }
5534
+ }
5535
+ private flushWaiters() {
5536
+ // swap both arrays out before any resume runs: a resumed waiter can
5537
+ // reentrantly close the latch and register new waiters, which must not
5538
+ // be drained by this flush
5509
5539
  const waiters = this.waiters
5510
5540
  this.waiters = []
5541
+ this.flushScheduled()
5511
5542
  for (let i = 0; i < waiters.length; i++) {
5512
5543
  waiters[i](exitVoid)
5513
5544
  }
@@ -5531,9 +5562,14 @@ class Latch implements _Latch.Latch {
5531
5562
  }
5532
5563
  this.waiters.push(resume)
5533
5564
  return sync(() => {
5534
- const index = this.waiters.indexOf(resume)
5565
+ let index = this.waiters.indexOf(resume)
5535
5566
  if (index !== -1) {
5536
5567
  this.waiters.splice(index, 1)
5568
+ } else if (this.scheduled !== undefined) {
5569
+ index = this.scheduled.indexOf(resume)
5570
+ if (index !== -1) {
5571
+ this.scheduled.splice(index, 1)
5572
+ }
5537
5573
  }
5538
5574
  })
5539
5575
  })
@@ -5885,11 +5921,11 @@ export const annotateSpans: {
5885
5921
  ...args: [Record<string, unknown>] | [key: string, value: unknown]
5886
5922
  ): Effect.Effect<A, E, R> =>
5887
5923
  updateService(effect, TracerSpanAnnotations, (annotations) => {
5888
- const newAnnotations = { ...annotations }
5924
+ const newAnnotations = args.length === 1 ? { ...annotations, ...args[0] } : { ...annotations }
5889
5925
  if (args.length === 1) {
5890
- Object.assign(newAnnotations, args[0])
5926
+ return newAnnotations
5891
5927
  } else {
5892
- newAnnotations[args[0]] = args[1]
5928
+ InternalRecord.assignProperty(newAnnotations, args[0], args[1])
5893
5929
  }
5894
5930
  return newAnnotations
5895
5931
  })
@@ -6160,7 +6196,7 @@ export const annotateLogsScoped: {
6160
6196
  const next = { ...prev }
6161
6197
  for (let i = 0; i < entries.length; i++) {
6162
6198
  const [key, value] = entries[i]
6163
- next[key] = value
6199
+ InternalRecord.assignProperty(next, key, value)
6164
6200
  }
6165
6201
  fiber.setContext(Context.add(fiber.context, CurrentLogAnnotations, next))
6166
6202
  return scopeAddFinalizerExit(Context.getUnsafe(fiber.context, scopeTag), (_) => {
@@ -6169,8 +6205,8 @@ export const annotateLogsScoped: {
6169
6205
  for (let i = 0; i < entries.length; i++) {
6170
6206
  const [key, value] = entries[i]
6171
6207
  if (current[key] !== value) continue
6172
- if (key in prev) {
6173
- next[key] = prev[key]
6208
+ if (Object.hasOwn(prev, key)) {
6209
+ InternalRecord.assignProperty(next, key, prev[key])
6174
6210
  } else {
6175
6211
  delete next[key]
6176
6212
  }
@@ -6514,7 +6550,7 @@ export const tracerLogger = loggerMake<unknown, void>(({ cause, fiber, logLevel,
6514
6550
  if (span === undefined || span._tag === "ExternalSpan") return
6515
6551
  const attributes: Record<string, unknown> = {}
6516
6552
  for (const [key, value] of Object.entries(annotations)) {
6517
- attributes[key] = value
6553
+ InternalRecord.assignProperty(attributes, key, value)
6518
6554
  }
6519
6555
  attributes["effect.fiberId"] = fiber.id
6520
6556
  attributes["effect.logLevel"] = logLevel.toUpperCase()
@@ -396,7 +396,7 @@ export const discriminators = <D extends string>(field: D) =>
396
396
  fields: P
397
397
  ) => {
398
398
  const predicate = makeWhen(
399
- (arg: any) => arg != null && arg[field] in fields,
399
+ (arg: any) => arg != null && Object.hasOwn(fields, arg[field]),
400
400
  (data: any) => (fields as any)[data[field]](data)
401
401
  )
402
402
 
@@ -1,9 +1,5 @@
1
- /**
2
- * @since 4.0.0
3
- */
4
-
5
1
  /** @internal */
6
- export function set<K extends PropertyKey, A>(self: Record<K, A>, key: K, value: A): Record<K, A> {
2
+ export function assignProperty(self: object, key: PropertyKey, value: unknown): void {
7
3
  if (key === "__proto__") {
8
4
  Object.defineProperty(self, key, {
9
5
  value,
@@ -12,7 +8,15 @@ export function set<K extends PropertyKey, A>(self: Record<K, A>, key: K, value:
12
8
  configurable: true
13
9
  })
14
10
  } else {
15
- self[key] = value
11
+ ;(self as any)[key] = value
12
+ }
13
+ }
14
+
15
+ /** @internal */
16
+ export function assignProperties(self: object, source: object): void {
17
+ for (const key of Reflect.ownKeys(source)) {
18
+ if (Object.prototype.propertyIsEnumerable.call(source, key)) {
19
+ assignProperty(self, key, (source as any)[key])
20
+ }
16
21
  }
17
- return self
18
22
  }
@@ -6,11 +6,6 @@ import type { ReadonlyRecord } from "../Record.ts"
6
6
  import type { StackFrame } from "../References.ts"
7
7
  import type { SpanLink } from "../Tracer.ts"
8
8
 
9
- /** @internal */
10
- export const CurrentConcurrency = Context.Reference<"unbounded" | number>("effect/References/CurrentConcurrency", {
11
- defaultValue: () => "unbounded"
12
- })
13
-
14
9
  /** @internal */
15
10
  export const CurrentErrorReporters = Context.Reference<ReadonlySet<ErrorReporter>>(
16
11
  "effect/ErrorReporter/CurrentErrorReporters",
@@ -12,9 +12,35 @@ export function resolveAt<A>(key: string) {
12
12
  return (ast: SchemaAST.AST): A | undefined => resolve(ast)?.[key] as A | undefined
13
13
  }
14
14
 
15
+ /** @internal */
16
+ export const STRUCTURAL_ANNOTATION_KEY = "~structural"
17
+
18
+ /** @internal */
19
+ export const IDENTIFIER_FALLBACK_KEY = "~identifier"
20
+
21
+ /** @internal */
22
+ export const SENTINELS_ANNOTATION_KEY = "~sentinels"
23
+
24
+ /** @internal */
25
+ export const jsonSchemaAnnotationKeys = [
26
+ "title",
27
+ "description",
28
+ "default",
29
+ "examples",
30
+ "readOnly",
31
+ "writeOnly",
32
+ "format",
33
+ "contentEncoding",
34
+ "contentMediaType",
35
+ "contentSchema"
36
+ ] as const
37
+
15
38
  /** @internal */
16
39
  export const resolveIdentifier = resolveAt<string>("identifier")
17
40
 
41
+ /** @internal */
42
+ export const resolveIdentifierFallback = resolveAt<string>(IDENTIFIER_FALLBACK_KEY)
43
+
18
44
  /** @internal */
19
45
  export const resolveTitle = resolveAt<string>("title")
20
46
 
@@ -35,3 +61,21 @@ export const getExpected = memoize((ast: SchemaAST.AST): string => {
35
61
  export function collectBrands(annotations: Schema.Annotations.Annotations | undefined): ReadonlyArray<string> {
36
62
  return annotations !== undefined && Array.isArray(annotations.brands) ? annotations.brands : []
37
63
  }
64
+
65
+ /** @internal */
66
+ export const annotationExcludedKeys = new Set([
67
+ SENTINELS_ANNOTATION_KEY,
68
+ STRUCTURAL_ANNOTATION_KEY,
69
+ "representation",
70
+ "arbitrary",
71
+ "brands",
72
+ "toJsonSchema",
73
+ "toCode",
74
+ "toArbitrary",
75
+ "toEquivalence",
76
+ "toFormatter",
77
+ "toCodec",
78
+ "toCodecJson",
79
+ "toCodecStringTree",
80
+ "toCodecIso"
81
+ ])