effect 4.0.0-beta.103 → 4.0.0-beta.105

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 (667) hide show
  1. package/AGENTS.md +381 -0
  2. package/CLAUDE.md +381 -0
  3. package/ai-docs/README.md +44 -0
  4. package/ai-docs/package.json +36 -0
  5. package/ai-docs/src/01_effect/01_basics/01_effect-gen.ts +30 -0
  6. package/ai-docs/src/01_effect/01_basics/02_effect-fn.ts +39 -0
  7. package/ai-docs/src/01_effect/01_basics/10_creating-effects.ts +74 -0
  8. package/ai-docs/src/01_effect/01_basics/index.md +5 -0
  9. package/ai-docs/src/01_effect/02_schema/10_schema-basics.ts +43 -0
  10. package/ai-docs/src/01_effect/02_schema/index.md +7 -0
  11. package/ai-docs/src/01_effect/03_services/01_service.ts +45 -0
  12. package/ai-docs/src/01_effect/03_services/10_reference.ts +10 -0
  13. package/ai-docs/src/01_effect/03_services/20_layer-composition.ts +70 -0
  14. package/ai-docs/src/01_effect/03_services/20_layer-unwrap.ts +66 -0
  15. package/ai-docs/src/01_effect/03_services/index.md +5 -0
  16. package/ai-docs/src/01_effect/04_errors/01_error-handling.ts +30 -0
  17. package/ai-docs/src/01_effect/04_errors/10_catch-tags.ts +24 -0
  18. package/ai-docs/src/01_effect/04_errors/20_reason-errors.ts +64 -0
  19. package/ai-docs/src/01_effect/04_errors/index.md +1 -0
  20. package/ai-docs/src/01_effect/05_resources/10_acquire-release.ts +105 -0
  21. package/ai-docs/src/01_effect/05_resources/20_layer-side-effects.ts +31 -0
  22. package/ai-docs/src/01_effect/05_resources/30_layer-map.ts +86 -0
  23. package/ai-docs/src/01_effect/05_resources/index.md +3 -0
  24. package/ai-docs/src/01_effect/06_running/10_run-main.ts +30 -0
  25. package/ai-docs/src/01_effect/06_running/20_layer-launch.ts +27 -0
  26. package/ai-docs/src/01_effect/06_running/index.md +1 -0
  27. package/ai-docs/src/01_effect/07_pubsub/10_pubsub.ts +56 -0
  28. package/ai-docs/src/01_effect/07_pubsub/index.md +3 -0
  29. package/ai-docs/src/03_stream/10_creating-streams.ts +103 -0
  30. package/ai-docs/src/03_stream/20_consuming-streams.ts +137 -0
  31. package/ai-docs/src/03_stream/30_encoding.ts +165 -0
  32. package/ai-docs/src/03_stream/index.md +4 -0
  33. package/ai-docs/src/04_integration/10_managed-runtime.ts +129 -0
  34. package/ai-docs/src/04_integration/index.md +5 -0
  35. package/ai-docs/src/05_batching/10_request-resolver.ts +89 -0
  36. package/ai-docs/src/05_batching/index.md +3 -0
  37. package/ai-docs/src/06_schedule/10_schedules.ts +110 -0
  38. package/ai-docs/src/06_schedule/index.md +3 -0
  39. package/ai-docs/src/07_datetime/10_creating-and-formatting.ts +30 -0
  40. package/ai-docs/src/07_datetime/20_time-zones.ts +44 -0
  41. package/ai-docs/src/07_datetime/index.md +5 -0
  42. package/ai-docs/src/08_observability/10_logging.ts +66 -0
  43. package/ai-docs/src/08_observability/20_otlp-tracing.ts +95 -0
  44. package/ai-docs/src/08_observability/index.md +7 -0
  45. package/ai-docs/src/09_testing/10_effect-tests.ts +55 -0
  46. package/ai-docs/src/09_testing/20_layer-tests.ts +138 -0
  47. package/ai-docs/src/09_testing/index.md +1 -0
  48. package/ai-docs/src/10_predicate/01_basics.ts +14 -0
  49. package/ai-docs/src/10_predicate/index.md +9 -0
  50. package/ai-docs/src/50_http-client/10_basics.ts +102 -0
  51. package/ai-docs/src/50_http-client/index.md +3 -0
  52. package/ai-docs/src/51_http-server/10_basics.ts +116 -0
  53. package/ai-docs/src/51_http-server/fixtures/api/Api.ts +14 -0
  54. package/ai-docs/src/51_http-server/fixtures/api/Authorization.ts +36 -0
  55. package/ai-docs/src/51_http-server/fixtures/api/System.ts +10 -0
  56. package/ai-docs/src/51_http-server/fixtures/api/Users.ts +91 -0
  57. package/ai-docs/src/51_http-server/fixtures/domain/User.ts +12 -0
  58. package/ai-docs/src/51_http-server/fixtures/domain/UserErrors.ts +22 -0
  59. package/ai-docs/src/51_http-server/fixtures/server/Authorization.ts +36 -0
  60. package/ai-docs/src/51_http-server/fixtures/server/Users/http.ts +71 -0
  61. package/ai-docs/src/51_http-server/fixtures/server/Users.ts +62 -0
  62. package/ai-docs/src/51_http-server/index.md +3 -0
  63. package/ai-docs/src/60_child-process/10_working-with-child-processes.ts +117 -0
  64. package/ai-docs/src/60_child-process/index.md +3 -0
  65. package/ai-docs/src/70_cli/10_basics.ts +136 -0
  66. package/ai-docs/src/70_cli/index.md +5 -0
  67. package/ai-docs/src/71_ai/10_language-model.ts +156 -0
  68. package/ai-docs/src/71_ai/20_tools.ts +226 -0
  69. package/ai-docs/src/71_ai/30_chat.ts +158 -0
  70. package/ai-docs/src/71_ai/fixtures/domain/LaunchPlan.ts +9 -0
  71. package/ai-docs/src/71_ai/index.md +5 -0
  72. package/ai-docs/src/80_cluster/10_entities.ts +97 -0
  73. package/ai-docs/src/80_cluster/index.md +4 -0
  74. package/ai-docs/src/index.md +10 -0
  75. package/ai-docs/tsconfig.json +24 -0
  76. package/dist/Brand.d.ts +3 -3
  77. package/dist/Brand.d.ts.map +1 -1
  78. package/dist/Brand.js +4 -3
  79. package/dist/Brand.js.map +1 -1
  80. package/dist/Cache.js +1 -1
  81. package/dist/Cache.js.map +1 -1
  82. package/dist/Channel.d.ts +1 -1
  83. package/dist/Channel.d.ts.map +1 -1
  84. package/dist/Channel.js.map +1 -1
  85. package/dist/Config.d.ts.map +1 -1
  86. package/dist/Config.js +30 -8
  87. package/dist/Config.js.map +1 -1
  88. package/dist/ConfigProvider.d.ts.map +1 -1
  89. package/dist/ConfigProvider.js +2 -1
  90. package/dist/ConfigProvider.js.map +1 -1
  91. package/dist/Context.d.ts +2 -3
  92. package/dist/Context.d.ts.map +1 -1
  93. package/dist/Context.js +1 -22
  94. package/dist/Context.js.map +1 -1
  95. package/dist/Cron.d.ts +31 -0
  96. package/dist/Cron.d.ts.map +1 -1
  97. package/dist/Cron.js +58 -2
  98. package/dist/Cron.js.map +1 -1
  99. package/dist/Crypto.d.ts.map +1 -1
  100. package/dist/Crypto.js +13 -5
  101. package/dist/Crypto.js.map +1 -1
  102. package/dist/Duration.d.ts.map +1 -1
  103. package/dist/Duration.js +12 -1
  104. package/dist/Duration.js.map +1 -1
  105. package/dist/Effect.d.ts +132 -14
  106. package/dist/Effect.d.ts.map +1 -1
  107. package/dist/Effect.js +38 -0
  108. package/dist/Effect.js.map +1 -1
  109. package/dist/Equal.d.ts.map +1 -1
  110. package/dist/Equal.js +10 -2
  111. package/dist/Equal.js.map +1 -1
  112. package/dist/ExecutionPlan.d.ts +73 -0
  113. package/dist/ExecutionPlan.d.ts.map +1 -1
  114. package/dist/ExecutionPlan.js +1 -1
  115. package/dist/ExecutionPlan.js.map +1 -1
  116. package/dist/FiberSet.js +1 -1
  117. package/dist/FileSystem.d.ts +2 -2
  118. package/dist/Function.d.ts +4 -3
  119. package/dist/Function.d.ts.map +1 -1
  120. package/dist/Function.js +5 -5
  121. package/dist/Function.js.map +1 -1
  122. package/dist/Iterable.d.ts.map +1 -1
  123. package/dist/Iterable.js +11 -10
  124. package/dist/Iterable.js.map +1 -1
  125. package/dist/Layer.d.ts.map +1 -1
  126. package/dist/Layer.js +7 -5
  127. package/dist/Layer.js.map +1 -1
  128. package/dist/Optic.d.ts +35 -21
  129. package/dist/Optic.d.ts.map +1 -1
  130. package/dist/Optic.js +33 -34
  131. package/dist/Optic.js.map +1 -1
  132. package/dist/Schedule.d.ts +8 -8
  133. package/dist/Schedule.d.ts.map +1 -1
  134. package/dist/Schedule.js +4 -4
  135. package/dist/Schedule.js.map +1 -1
  136. package/dist/Schema.d.ts +105 -57
  137. package/dist/Schema.d.ts.map +1 -1
  138. package/dist/Schema.js +105 -67
  139. package/dist/Schema.js.map +1 -1
  140. package/dist/SchemaAST.d.ts +33 -3
  141. package/dist/SchemaAST.d.ts.map +1 -1
  142. package/dist/SchemaAST.js +87 -63
  143. package/dist/SchemaAST.js.map +1 -1
  144. package/dist/SchemaError.d.ts +8 -8
  145. package/dist/SchemaError.d.ts.map +1 -1
  146. package/dist/SchemaError.js +7 -6
  147. package/dist/SchemaError.js.map +1 -1
  148. package/dist/SchemaGetter.d.ts +8 -5
  149. package/dist/SchemaGetter.d.ts.map +1 -1
  150. package/dist/SchemaGetter.js +41 -37
  151. package/dist/SchemaGetter.js.map +1 -1
  152. package/dist/SchemaIssue.d.ts +195 -38
  153. package/dist/SchemaIssue.d.ts.map +1 -1
  154. package/dist/SchemaIssue.js +243 -68
  155. package/dist/SchemaIssue.js.map +1 -1
  156. package/dist/SchemaParser.d.ts +30 -0
  157. package/dist/SchemaParser.d.ts.map +1 -1
  158. package/dist/SchemaParser.js +74 -62
  159. package/dist/SchemaParser.js.map +1 -1
  160. package/dist/SchemaTransformation.d.ts +2 -2
  161. package/dist/SchemaTransformation.d.ts.map +1 -1
  162. package/dist/SchemaTransformation.js +26 -26
  163. package/dist/SchemaTransformation.js.map +1 -1
  164. package/dist/ScopedCache.js +1 -1
  165. package/dist/ScopedCache.js.map +1 -1
  166. package/dist/Sink.d.ts +1 -1
  167. package/dist/Sink.d.ts.map +1 -1
  168. package/dist/Stdio.d.ts +17 -4
  169. package/dist/Stdio.d.ts.map +1 -1
  170. package/dist/Stdio.js +6 -3
  171. package/dist/Stdio.js.map +1 -1
  172. package/dist/Stream.d.ts +27 -4
  173. package/dist/Stream.d.ts.map +1 -1
  174. package/dist/Stream.js +27 -2
  175. package/dist/Stream.js.map +1 -1
  176. package/dist/SynchronizedRef.js +1 -1
  177. package/dist/SynchronizedRef.js.map +1 -1
  178. package/dist/Terminal.js +1 -1
  179. package/dist/Terminal.js.map +1 -1
  180. package/dist/Tuple.d.ts +6 -4
  181. package/dist/Tuple.d.ts.map +1 -1
  182. package/dist/Tuple.js.map +1 -1
  183. package/dist/TxReentrantLock.d.ts +0 -56
  184. package/dist/TxReentrantLock.d.ts.map +1 -1
  185. package/dist/TxReentrantLock.js +8 -8
  186. package/dist/TxReentrantLock.js.map +1 -1
  187. package/dist/internal/dateTime.js +1 -1
  188. package/dist/internal/dateTime.js.map +1 -1
  189. package/dist/internal/executionPlan.js +51 -3
  190. package/dist/internal/executionPlan.js.map +1 -1
  191. package/dist/internal/hashMap.js +12 -8
  192. package/dist/internal/hashMap.js.map +1 -1
  193. package/dist/internal/matcher.js +1 -1
  194. package/dist/internal/matcher.js.map +1 -1
  195. package/dist/internal/schedule.js.map +1 -1
  196. package/dist/internal/schema/annotations.js +2 -0
  197. package/dist/internal/schema/annotations.js.map +1 -1
  198. package/dist/internal/schema/schema.js +1 -9
  199. package/dist/internal/schema/schema.js.map +1 -1
  200. package/dist/internal/schema/toArbitrary.js +1 -1
  201. package/dist/internal/schema/toArbitrary.js.map +1 -1
  202. package/dist/internal/trie.js +13 -3
  203. package/dist/internal/trie.js.map +1 -1
  204. package/dist/testing/TestClock.d.ts.map +1 -1
  205. package/dist/testing/TestClock.js +11 -1
  206. package/dist/testing/TestClock.js.map +1 -1
  207. package/dist/testing/TestSchema.d.ts +2 -2
  208. package/dist/testing/TestSchema.d.ts.map +1 -1
  209. package/dist/testing/TestSchema.js +8 -7
  210. package/dist/testing/TestSchema.js.map +1 -1
  211. package/dist/unstable/ai/AiError.js +19 -19
  212. package/dist/unstable/ai/AiError.js.map +1 -1
  213. package/dist/unstable/ai/Chat.js +1 -1
  214. package/dist/unstable/ai/Chat.js.map +1 -1
  215. package/dist/unstable/ai/LanguageModel.js +4 -2
  216. package/dist/unstable/ai/LanguageModel.js.map +1 -1
  217. package/dist/unstable/ai/McpSchema.d.ts +132 -132
  218. package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
  219. package/dist/unstable/ai/McpSchema.js +8 -8
  220. package/dist/unstable/ai/McpSchema.js.map +1 -1
  221. package/dist/unstable/ai/McpServer.js +1 -1
  222. package/dist/unstable/ai/McpServer.js.map +1 -1
  223. package/dist/unstable/ai/Prompt.d.ts +15 -3
  224. package/dist/unstable/ai/Prompt.d.ts.map +1 -1
  225. package/dist/unstable/ai/Prompt.js +10 -7
  226. package/dist/unstable/ai/Prompt.js.map +1 -1
  227. package/dist/unstable/cli/CliError.d.ts +3 -3
  228. package/dist/unstable/cli/CliError.js +11 -11
  229. package/dist/unstable/cli/CliError.js.map +1 -1
  230. package/dist/unstable/cli/Command.d.ts +9 -9
  231. package/dist/unstable/cli/Command.d.ts.map +1 -1
  232. package/dist/unstable/cli/Command.js +8 -6
  233. package/dist/unstable/cli/Command.js.map +1 -1
  234. package/dist/unstable/cli/Param.d.ts +7 -5
  235. package/dist/unstable/cli/Param.d.ts.map +1 -1
  236. package/dist/unstable/cli/Param.js +15 -11
  237. package/dist/unstable/cli/Param.js.map +1 -1
  238. package/dist/unstable/cli/Primitive.d.ts.map +1 -1
  239. package/dist/unstable/cli/Primitive.js +31 -24
  240. package/dist/unstable/cli/Primitive.js.map +1 -1
  241. package/dist/unstable/cli/Prompt.d.ts.map +1 -1
  242. package/dist/unstable/cli/Prompt.js +31 -17
  243. package/dist/unstable/cli/Prompt.js.map +1 -1
  244. package/dist/unstable/cli/internal/ansi.js +2 -2
  245. package/dist/unstable/cli/internal/ansi.js.map +1 -1
  246. package/dist/unstable/cli/internal/command.d.ts +2 -2
  247. package/dist/unstable/cli/internal/command.d.ts.map +1 -1
  248. package/dist/unstable/cli/internal/command.js +10 -9
  249. package/dist/unstable/cli/internal/command.js.map +1 -1
  250. package/dist/unstable/cli/internal/completions/bash.js +69 -9
  251. package/dist/unstable/cli/internal/completions/bash.js.map +1 -1
  252. package/dist/unstable/cli/internal/completions/descriptor.js +24 -18
  253. package/dist/unstable/cli/internal/completions/descriptor.js.map +1 -1
  254. package/dist/unstable/cli/internal/completions/fish.js +5 -5
  255. package/dist/unstable/cli/internal/completions/fish.js.map +1 -1
  256. package/dist/unstable/cli/internal/help.d.ts.map +1 -1
  257. package/dist/unstable/cli/internal/help.js +4 -2
  258. package/dist/unstable/cli/internal/help.js.map +1 -1
  259. package/dist/unstable/cli/internal/parser.js +3 -3
  260. package/dist/unstable/cli/internal/parser.js.map +1 -1
  261. package/dist/unstable/cli/internal/wizard.js +2 -2
  262. package/dist/unstable/cli/internal/wizard.js.map +1 -1
  263. package/dist/unstable/cluster/ClusterError.js +7 -7
  264. package/dist/unstable/cluster/ClusterError.js.map +1 -1
  265. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
  266. package/dist/unstable/cluster/ClusterWorkflowEngine.js +1 -1
  267. package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
  268. package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
  269. package/dist/unstable/cluster/MessageStorage.js +8 -1
  270. package/dist/unstable/cluster/MessageStorage.js.map +1 -1
  271. package/dist/unstable/cluster/Reply.d.ts +8 -0
  272. package/dist/unstable/cluster/Reply.d.ts.map +1 -1
  273. package/dist/unstable/cluster/Reply.js +16 -4
  274. package/dist/unstable/cluster/Reply.js.map +1 -1
  275. package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
  276. package/dist/unstable/cluster/RunnerServer.js +4 -2
  277. package/dist/unstable/cluster/RunnerServer.js.map +1 -1
  278. package/dist/unstable/cluster/RunnerStorage.d.ts +1 -2
  279. package/dist/unstable/cluster/RunnerStorage.d.ts.map +1 -1
  280. package/dist/unstable/cluster/RunnerStorage.js +7 -6
  281. package/dist/unstable/cluster/RunnerStorage.js.map +1 -1
  282. package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
  283. package/dist/unstable/cluster/Sharding.js +22 -4
  284. package/dist/unstable/cluster/Sharding.js.map +1 -1
  285. package/dist/unstable/cluster/internal/entityManager.js +1 -1
  286. package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
  287. package/dist/unstable/cluster/internal/resourceMap.js +2 -2
  288. package/dist/unstable/cluster/internal/resourceMap.js.map +1 -1
  289. package/dist/unstable/cluster/internal/resourceRef.js +17 -0
  290. package/dist/unstable/cluster/internal/resourceRef.js.map +1 -1
  291. package/dist/unstable/devtools/DevToolsClient.d.ts.map +1 -1
  292. package/dist/unstable/devtools/DevToolsClient.js +7 -2
  293. package/dist/unstable/devtools/DevToolsClient.js.map +1 -1
  294. package/dist/unstable/encoding/Ini.d.ts +20 -0
  295. package/dist/unstable/encoding/Ini.d.ts.map +1 -0
  296. package/dist/unstable/encoding/Ini.js +153 -0
  297. package/dist/unstable/encoding/Ini.js.map +1 -0
  298. package/dist/unstable/encoding/Msgpack.d.ts +2 -1
  299. package/dist/unstable/encoding/Msgpack.d.ts.map +1 -1
  300. package/dist/unstable/encoding/Msgpack.js +27 -13
  301. package/dist/unstable/encoding/Msgpack.js.map +1 -1
  302. package/dist/unstable/encoding/Ndjson.d.ts.map +1 -1
  303. package/dist/unstable/encoding/Ndjson.js +7 -1
  304. package/dist/unstable/encoding/Ndjson.js.map +1 -1
  305. package/dist/unstable/encoding/Sse.d.ts.map +1 -1
  306. package/dist/unstable/encoding/Sse.js +14 -23
  307. package/dist/unstable/encoding/Sse.js.map +1 -1
  308. package/dist/unstable/encoding/Toml.d.ts +19 -0
  309. package/dist/unstable/encoding/Toml.d.ts.map +1 -0
  310. package/dist/unstable/encoding/Toml.js +434 -0
  311. package/dist/unstable/encoding/Toml.js.map +1 -0
  312. package/dist/unstable/encoding/Yaml.d.ts +19 -0
  313. package/dist/unstable/encoding/Yaml.d.ts.map +1 -0
  314. package/dist/unstable/encoding/Yaml.js +461 -0
  315. package/dist/unstable/encoding/Yaml.js.map +1 -0
  316. package/dist/unstable/encoding/index.d.ts +12 -0
  317. package/dist/unstable/encoding/index.d.ts.map +1 -1
  318. package/dist/unstable/encoding/index.js +12 -0
  319. package/dist/unstable/encoding/index.js.map +1 -1
  320. package/dist/unstable/eventlog/EventJournal.d.ts +1 -1
  321. package/dist/unstable/eventlog/EventJournal.d.ts.map +1 -1
  322. package/dist/unstable/eventlog/EventJournal.js +13 -5
  323. package/dist/unstable/eventlog/EventJournal.js.map +1 -1
  324. package/dist/unstable/eventlog/EventLogMessage.js +1 -1
  325. package/dist/unstable/eventlog/EventLogMessage.js.map +1 -1
  326. package/dist/unstable/eventlog/EventLogServerUnencrypted.js +1 -1
  327. package/dist/unstable/eventlog/EventLogServerUnencrypted.js.map +1 -1
  328. package/dist/unstable/eventlog/SqlEventJournal.d.ts.map +1 -1
  329. package/dist/unstable/eventlog/SqlEventJournal.js +1 -4
  330. package/dist/unstable/eventlog/SqlEventJournal.js.map +1 -1
  331. package/dist/unstable/http/FindMyWay/internal/queryString.d.ts +11 -0
  332. package/dist/unstable/http/FindMyWay/internal/queryString.d.ts.map +1 -0
  333. package/dist/unstable/http/FindMyWay/internal/queryString.js +259 -0
  334. package/dist/unstable/http/FindMyWay/internal/queryString.js.map +1 -0
  335. package/dist/unstable/http/FindMyWay/internal/router.d.ts +2 -0
  336. package/dist/unstable/http/FindMyWay/internal/router.d.ts.map +1 -0
  337. package/dist/unstable/http/FindMyWay/internal/router.js +665 -0
  338. package/dist/unstable/http/FindMyWay/internal/router.js.map +1 -0
  339. package/dist/unstable/http/FindMyWay.d.ts +33 -8
  340. package/dist/unstable/http/FindMyWay.d.ts.map +1 -1
  341. package/dist/unstable/http/FindMyWay.js +4 -7
  342. package/dist/unstable/http/FindMyWay.js.map +1 -1
  343. package/dist/unstable/http/HttpClient.d.ts +59 -3
  344. package/dist/unstable/http/HttpClient.d.ts.map +1 -1
  345. package/dist/unstable/http/HttpClient.js +33 -19
  346. package/dist/unstable/http/HttpClient.js.map +1 -1
  347. package/dist/unstable/http/HttpClientError.js +1 -1
  348. package/dist/unstable/http/HttpClientError.js.map +1 -1
  349. package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
  350. package/dist/unstable/http/HttpClientRequest.js +2 -14
  351. package/dist/unstable/http/HttpClientRequest.js.map +1 -1
  352. package/dist/unstable/http/HttpClientResponse.js +1 -16
  353. package/dist/unstable/http/HttpClientResponse.js.map +1 -1
  354. package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
  355. package/dist/unstable/http/HttpPlatform.js +21 -3
  356. package/dist/unstable/http/HttpPlatform.js.map +1 -1
  357. package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
  358. package/dist/unstable/http/HttpServerRequest.js +7 -6
  359. package/dist/unstable/http/HttpServerRequest.js.map +1 -1
  360. package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
  361. package/dist/unstable/http/HttpServerResponse.js +8 -6
  362. package/dist/unstable/http/HttpServerResponse.js.map +1 -1
  363. package/dist/unstable/http/Multipart.d.ts +1 -1
  364. package/dist/unstable/http/Multipart.d.ts.map +1 -1
  365. package/dist/unstable/http/Multipart.js +9 -2
  366. package/dist/unstable/http/Multipart.js.map +1 -1
  367. package/dist/unstable/http/MultipartParser/HeadersParser.d.ts +53 -0
  368. package/dist/unstable/http/MultipartParser/HeadersParser.d.ts.map +1 -0
  369. package/dist/unstable/http/MultipartParser/HeadersParser.js +14 -0
  370. package/dist/unstable/http/MultipartParser/HeadersParser.js.map +1 -0
  371. package/dist/unstable/http/MultipartParser/Search.d.ts +11 -0
  372. package/dist/unstable/http/MultipartParser/Search.d.ts.map +1 -0
  373. package/dist/unstable/http/MultipartParser/Search.js +14 -0
  374. package/dist/unstable/http/MultipartParser/Search.js.map +1 -0
  375. package/dist/unstable/http/MultipartParser/internal/contentType.d.ts +5 -0
  376. package/dist/unstable/http/MultipartParser/internal/contentType.d.ts.map +1 -0
  377. package/dist/unstable/http/MultipartParser/internal/contentType.js +82 -0
  378. package/dist/unstable/http/MultipartParser/internal/contentType.js.map +1 -0
  379. package/dist/unstable/http/MultipartParser/internal/headers.d.ts +3 -0
  380. package/dist/unstable/http/MultipartParser/internal/headers.d.ts.map +1 -0
  381. package/dist/unstable/http/MultipartParser/internal/headers.js +194 -0
  382. package/dist/unstable/http/MultipartParser/internal/headers.js.map +1 -0
  383. package/dist/unstable/http/MultipartParser/internal/multipart.d.ts +8 -0
  384. package/dist/unstable/http/MultipartParser/internal/multipart.d.ts.map +1 -0
  385. package/dist/unstable/http/MultipartParser/internal/multipart.js +226 -0
  386. package/dist/unstable/http/MultipartParser/internal/multipart.js.map +1 -0
  387. package/dist/unstable/http/MultipartParser/internal/search.d.ts +5 -0
  388. package/dist/unstable/http/MultipartParser/internal/search.d.ts.map +1 -0
  389. package/dist/unstable/http/MultipartParser/internal/search.js +120 -0
  390. package/dist/unstable/http/MultipartParser/internal/search.js.map +1 -0
  391. package/dist/unstable/http/MultipartParser.d.ts +98 -0
  392. package/dist/unstable/http/MultipartParser.d.ts.map +1 -0
  393. package/dist/unstable/http/MultipartParser.js +23 -0
  394. package/dist/unstable/http/MultipartParser.js.map +1 -0
  395. package/dist/unstable/http/Template.d.ts.map +1 -1
  396. package/dist/unstable/http/Template.js +2 -2
  397. package/dist/unstable/http/Template.js.map +1 -1
  398. package/dist/unstable/http/index.d.ts +1 -1
  399. package/dist/unstable/http/index.d.ts.map +1 -1
  400. package/dist/unstable/http/index.js +1 -1
  401. package/dist/unstable/http/index.js.map +1 -1
  402. package/dist/unstable/http/internal/httpBody.d.ts +2 -0
  403. package/dist/unstable/http/internal/httpBody.d.ts.map +1 -0
  404. package/dist/unstable/http/internal/httpBody.js +10 -0
  405. package/dist/unstable/http/internal/httpBody.js.map +1 -0
  406. package/dist/unstable/httpapi/HttpApi.d.ts.map +1 -1
  407. package/dist/unstable/httpapi/HttpApi.js +5 -5
  408. package/dist/unstable/httpapi/HttpApi.js.map +1 -1
  409. package/dist/unstable/httpapi/HttpApiBuilder.js +73 -20
  410. package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
  411. package/dist/unstable/httpapi/HttpApiClient.d.ts +1 -1
  412. package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
  413. package/dist/unstable/httpapi/HttpApiClient.js +74 -34
  414. package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
  415. package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +6 -4
  416. package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
  417. package/dist/unstable/httpapi/HttpApiEndpoint.js +73 -16
  418. package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
  419. package/dist/unstable/httpapi/HttpApiError.d.ts +5 -5
  420. package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
  421. package/dist/unstable/httpapi/HttpApiError.js +17 -17
  422. package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
  423. package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +1 -1
  424. package/dist/unstable/httpapi/HttpApiMiddleware.js +1 -1
  425. package/dist/unstable/httpapi/HttpApiSchema.d.ts +219 -0
  426. package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
  427. package/dist/unstable/httpapi/HttpApiSchema.js +170 -0
  428. package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
  429. package/dist/unstable/httpapi/OpenApi.d.ts +8 -0
  430. package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
  431. package/dist/unstable/httpapi/OpenApi.js +45 -18
  432. package/dist/unstable/httpapi/OpenApi.js.map +1 -1
  433. package/dist/unstable/observability/OtlpExporter.d.ts +1 -1
  434. package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
  435. package/dist/unstable/observability/OtlpExporter.js +2 -1
  436. package/dist/unstable/observability/OtlpExporter.js.map +1 -1
  437. package/dist/unstable/observability/OtlpLogger.d.ts.map +1 -1
  438. package/dist/unstable/observability/OtlpLogger.js +2 -2
  439. package/dist/unstable/observability/OtlpLogger.js.map +1 -1
  440. package/dist/unstable/observability/OtlpMetrics.d.ts +2 -2
  441. package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
  442. package/dist/unstable/observability/OtlpMetrics.js +28 -15
  443. package/dist/unstable/observability/OtlpMetrics.js.map +1 -1
  444. package/dist/unstable/observability/OtlpTracer.js +1 -1
  445. package/dist/unstable/observability/OtlpTracer.js.map +1 -1
  446. package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
  447. package/dist/unstable/persistence/PersistedQueue.js +9 -9
  448. package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
  449. package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
  450. package/dist/unstable/persistence/Persistence.js +17 -7
  451. package/dist/unstable/persistence/Persistence.js.map +1 -1
  452. package/dist/unstable/persistence/RateLimiter.d.ts +22 -12
  453. package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
  454. package/dist/unstable/persistence/RateLimiter.js +15 -42
  455. package/dist/unstable/persistence/RateLimiter.js.map +1 -1
  456. package/dist/unstable/persistence/Redis.js +1 -1
  457. package/dist/unstable/persistence/Redis.js.map +1 -1
  458. package/dist/unstable/reactivity/AsyncResult.d.ts.map +1 -1
  459. package/dist/unstable/reactivity/AsyncResult.js +4 -4
  460. package/dist/unstable/reactivity/AsyncResult.js.map +1 -1
  461. package/dist/unstable/reactivity/Atom.d.ts +26 -11
  462. package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
  463. package/dist/unstable/reactivity/Atom.js +9 -22
  464. package/dist/unstable/reactivity/Atom.js.map +1 -1
  465. package/dist/unstable/rpc/RpcClient.d.ts +14 -0
  466. package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
  467. package/dist/unstable/rpc/RpcClient.js +21 -10
  468. package/dist/unstable/rpc/RpcClient.js.map +1 -1
  469. package/dist/unstable/rpc/RpcClientError.js +2 -2
  470. package/dist/unstable/rpc/RpcClientError.js.map +1 -1
  471. package/dist/unstable/rpc/RpcSerialization.js +3 -1
  472. package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
  473. package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
  474. package/dist/unstable/rpc/RpcServer.js +3 -2
  475. package/dist/unstable/rpc/RpcServer.js.map +1 -1
  476. package/dist/unstable/schema/Model.d.ts +1 -1
  477. package/dist/unstable/schema/Model.d.ts.map +1 -1
  478. package/dist/unstable/schema/VariantSchema.d.ts +5 -5
  479. package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
  480. package/dist/unstable/schema/VariantSchema.js +17 -9
  481. package/dist/unstable/schema/VariantSchema.js.map +1 -1
  482. package/dist/unstable/socket/Socket.d.ts.map +1 -1
  483. package/dist/unstable/socket/Socket.js +28 -12
  484. package/dist/unstable/socket/Socket.js.map +1 -1
  485. package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
  486. package/dist/unstable/sql/SqlClient.js +7 -3
  487. package/dist/unstable/sql/SqlClient.js.map +1 -1
  488. package/dist/unstable/sql/SqlError.js +13 -13
  489. package/dist/unstable/sql/SqlError.js.map +1 -1
  490. package/dist/unstable/sql/SqlResolver.js +8 -6
  491. package/dist/unstable/sql/SqlResolver.js.map +1 -1
  492. package/dist/unstable/sql/Statement.d.ts.map +1 -1
  493. package/dist/unstable/sql/Statement.js +8 -6
  494. package/dist/unstable/sql/Statement.js.map +1 -1
  495. package/dist/unstable/workers/WorkerError.js +5 -5
  496. package/dist/unstable/workers/WorkerError.js.map +1 -1
  497. package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
  498. package/dist/unstable/workflow/Workflow.js +2 -2
  499. package/dist/unstable/workflow/Workflow.js.map +1 -1
  500. package/dist/unstable/workflow/WorkflowEngine.d.ts +1 -1
  501. package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
  502. package/dist/unstable/workflow/WorkflowEngine.js +3 -3
  503. package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
  504. package/package.json +6 -9
  505. package/src/Brand.ts +4 -4
  506. package/src/Cache.ts +1 -1
  507. package/src/Channel.ts +1 -1
  508. package/src/Config.ts +31 -8
  509. package/src/ConfigProvider.ts +4 -1
  510. package/src/Context.ts +6 -28
  511. package/src/Cron.ts +65 -2
  512. package/src/Crypto.ts +17 -8
  513. package/src/Duration.ts +16 -2
  514. package/src/Effect.ts +141 -17
  515. package/src/Equal.ts +10 -2
  516. package/src/ExecutionPlan.ts +78 -1
  517. package/src/FiberSet.ts +1 -1
  518. package/src/FileSystem.ts +2 -2
  519. package/src/Function.ts +6 -6
  520. package/src/Iterable.ts +11 -10
  521. package/src/Layer.ts +7 -5
  522. package/src/Optic.ts +59 -58
  523. package/src/Schedule.ts +13 -13
  524. package/src/Schema.ts +195 -112
  525. package/src/SchemaAST.ts +154 -85
  526. package/src/SchemaError.ts +9 -9
  527. package/src/SchemaGetter.ts +89 -30
  528. package/src/SchemaIssue.ts +285 -80
  529. package/src/SchemaParser.ts +126 -86
  530. package/src/SchemaTransformation.ts +66 -18
  531. package/src/ScopedCache.ts +1 -1
  532. package/src/Sink.ts +1 -1
  533. package/src/Stdio.ts +23 -4
  534. package/src/Stream.ts +77 -10
  535. package/src/SynchronizedRef.ts +1 -1
  536. package/src/Terminal.ts +1 -1
  537. package/src/Tuple.ts +7 -4
  538. package/src/TxReentrantLock.ts +39 -35
  539. package/src/internal/dateTime.ts +1 -1
  540. package/src/internal/executionPlan.ts +105 -10
  541. package/src/internal/hashMap.ts +20 -14
  542. package/src/internal/matcher.ts +2 -2
  543. package/src/internal/schedule.ts +4 -4
  544. package/src/internal/schema/annotations.ts +3 -0
  545. package/src/internal/schema/schema.ts +1 -17
  546. package/src/internal/schema/toArbitrary.ts +3 -1
  547. package/src/internal/trie.ts +12 -2
  548. package/src/testing/TestClock.ts +13 -1
  549. package/src/testing/TestSchema.ts +9 -9
  550. package/src/unstable/ai/AiError.ts +19 -19
  551. package/src/unstable/ai/Chat.ts +1 -1
  552. package/src/unstable/ai/LanguageModel.ts +4 -2
  553. package/src/unstable/ai/McpSchema.ts +17 -16
  554. package/src/unstable/ai/McpServer.ts +1 -1
  555. package/src/unstable/ai/Prompt.ts +35 -10
  556. package/src/unstable/cli/CliError.ts +12 -12
  557. package/src/unstable/cli/Command.ts +12 -10
  558. package/src/unstable/cli/Param.ts +41 -19
  559. package/src/unstable/cli/Primitive.ts +11 -5
  560. package/src/unstable/cli/Prompt.ts +36 -20
  561. package/src/unstable/cli/internal/ansi.ts +2 -2
  562. package/src/unstable/cli/internal/command.ts +15 -10
  563. package/src/unstable/cli/internal/completions/bash.ts +59 -9
  564. package/src/unstable/cli/internal/completions/descriptor.ts +14 -20
  565. package/src/unstable/cli/internal/completions/fish.ts +5 -7
  566. package/src/unstable/cli/internal/help.ts +4 -2
  567. package/src/unstable/cli/internal/parser.ts +3 -3
  568. package/src/unstable/cli/internal/wizard.ts +2 -2
  569. package/src/unstable/cluster/ClusterError.ts +7 -7
  570. package/src/unstable/cluster/ClusterWorkflowEngine.ts +4 -1
  571. package/src/unstable/cluster/MessageStorage.ts +9 -5
  572. package/src/unstable/cluster/Reply.ts +25 -4
  573. package/src/unstable/cluster/RunnerServer.ts +4 -10
  574. package/src/unstable/cluster/RunnerStorage.ts +9 -7
  575. package/src/unstable/cluster/Sharding.ts +35 -7
  576. package/src/unstable/cluster/internal/entityManager.ts +1 -1
  577. package/src/unstable/cluster/internal/resourceMap.ts +5 -2
  578. package/src/unstable/cluster/internal/resourceRef.ts +27 -5
  579. package/src/unstable/devtools/DevToolsClient.ts +3 -2
  580. package/src/unstable/encoding/Ini.ts +174 -0
  581. package/src/unstable/encoding/Msgpack.ts +59 -36
  582. package/src/unstable/encoding/Ndjson.ts +9 -1
  583. package/src/unstable/encoding/Sse.ts +11 -21
  584. package/src/unstable/encoding/Toml.ts +504 -0
  585. package/src/unstable/encoding/Yaml.ts +541 -0
  586. package/src/unstable/encoding/index.ts +15 -0
  587. package/src/unstable/eventlog/EventJournal.ts +14 -6
  588. package/src/unstable/eventlog/EventLogMessage.ts +1 -1
  589. package/src/unstable/eventlog/EventLogServerUnencrypted.ts +1 -1
  590. package/src/unstable/eventlog/SqlEventJournal.ts +6 -4
  591. package/src/unstable/http/FindMyWay/internal/queryString.ts +420 -0
  592. package/src/unstable/http/FindMyWay/internal/router.ts +950 -0
  593. package/src/unstable/http/FindMyWay.ts +65 -6
  594. package/src/unstable/http/HttpClient.ts +132 -23
  595. package/src/unstable/http/HttpClientError.ts +1 -1
  596. package/src/unstable/http/HttpClientRequest.ts +2 -14
  597. package/src/unstable/http/HttpClientResponse.ts +1 -17
  598. package/src/unstable/http/HttpPlatform.ts +34 -6
  599. package/src/unstable/http/HttpServerRequest.ts +14 -6
  600. package/src/unstable/http/HttpServerResponse.ts +9 -7
  601. package/src/unstable/http/Multipart.ts +9 -2
  602. package/src/unstable/http/MultipartParser/HeadersParser.ts +68 -0
  603. package/src/unstable/http/MultipartParser/Search.ts +17 -0
  604. package/src/unstable/http/MultipartParser/internal/contentType.ts +103 -0
  605. package/src/unstable/http/MultipartParser/internal/headers.ts +615 -0
  606. package/src/unstable/http/MultipartParser/internal/multipart.ts +262 -0
  607. package/src/unstable/http/MultipartParser/internal/search.ts +167 -0
  608. package/src/unstable/http/MultipartParser.ts +115 -0
  609. package/src/unstable/http/Template.ts +6 -5
  610. package/src/unstable/http/index.ts +1 -1
  611. package/src/unstable/http/internal/httpBody.ts +15 -0
  612. package/src/unstable/httpapi/HttpApi.ts +6 -7
  613. package/src/unstable/httpapi/HttpApiBuilder.ts +142 -25
  614. package/src/unstable/httpapi/HttpApiClient.ts +130 -49
  615. package/src/unstable/httpapi/HttpApiEndpoint.ts +117 -29
  616. package/src/unstable/httpapi/HttpApiError.ts +33 -39
  617. package/src/unstable/httpapi/HttpApiMiddleware.ts +1 -1
  618. package/src/unstable/httpapi/HttpApiSchema.ts +353 -0
  619. package/src/unstable/httpapi/OpenApi.ts +70 -20
  620. package/src/unstable/observability/OtlpExporter.ts +4 -2
  621. package/src/unstable/observability/OtlpLogger.ts +3 -1
  622. package/src/unstable/observability/OtlpMetrics.ts +32 -18
  623. package/src/unstable/observability/OtlpTracer.ts +1 -1
  624. package/src/unstable/persistence/PersistedQueue.ts +12 -9
  625. package/src/unstable/persistence/Persistence.ts +27 -7
  626. package/src/unstable/persistence/RateLimiter.ts +54 -31
  627. package/src/unstable/persistence/Redis.ts +1 -1
  628. package/src/unstable/reactivity/AsyncResult.ts +11 -6
  629. package/src/unstable/reactivity/Atom.ts +44 -25
  630. package/src/unstable/rpc/RpcClient.ts +42 -13
  631. package/src/unstable/rpc/RpcClientError.ts +2 -2
  632. package/src/unstable/rpc/RpcSerialization.ts +1 -1
  633. package/src/unstable/rpc/RpcServer.ts +4 -2
  634. package/src/unstable/schema/VariantSchema.ts +36 -18
  635. package/src/unstable/socket/Socket.ts +24 -14
  636. package/src/unstable/sql/SqlClient.ts +65 -56
  637. package/src/unstable/sql/SqlError.ts +13 -13
  638. package/src/unstable/sql/SqlResolver.ts +8 -6
  639. package/src/unstable/sql/Statement.ts +13 -8
  640. package/src/unstable/workers/WorkerError.ts +5 -5
  641. package/src/unstable/workflow/Workflow.ts +2 -5
  642. package/src/unstable/workflow/WorkflowEngine.ts +8 -3
  643. package/dist/unstable/http/Multipasta/HeadersParser.d.ts +0 -14
  644. package/dist/unstable/http/Multipasta/HeadersParser.d.ts.map +0 -1
  645. package/dist/unstable/http/Multipasta/HeadersParser.js +0 -14
  646. package/dist/unstable/http/Multipasta/HeadersParser.js.map +0 -1
  647. package/dist/unstable/http/Multipasta/Node.d.ts +0 -14
  648. package/dist/unstable/http/Multipasta/Node.d.ts.map +0 -1
  649. package/dist/unstable/http/Multipasta/Node.js +0 -14
  650. package/dist/unstable/http/Multipasta/Node.js.map +0 -1
  651. package/dist/unstable/http/Multipasta/Search.d.ts +0 -14
  652. package/dist/unstable/http/Multipasta/Search.d.ts.map +0 -1
  653. package/dist/unstable/http/Multipasta/Search.js +0 -14
  654. package/dist/unstable/http/Multipasta/Search.js.map +0 -1
  655. package/dist/unstable/http/Multipasta/Web.d.ts +0 -14
  656. package/dist/unstable/http/Multipasta/Web.d.ts.map +0 -1
  657. package/dist/unstable/http/Multipasta/Web.js +0 -14
  658. package/dist/unstable/http/Multipasta/Web.js.map +0 -1
  659. package/dist/unstable/http/Multipasta.d.ts +0 -15
  660. package/dist/unstable/http/Multipasta.d.ts.map +0 -1
  661. package/dist/unstable/http/Multipasta.js +0 -15
  662. package/dist/unstable/http/Multipasta.js.map +0 -1
  663. package/src/unstable/http/Multipasta/HeadersParser.ts +0 -14
  664. package/src/unstable/http/Multipasta/Node.ts +0 -14
  665. package/src/unstable/http/Multipasta/Search.ts +0 -14
  666. package/src/unstable/http/Multipasta/Web.ts +0 -14
  667. package/src/unstable/http/Multipasta.ts +0 -15
package/src/Schema.ts CHANGED
@@ -203,7 +203,9 @@ export interface BottomWithoutNew<
203
203
  * **Gotchas**
204
204
  *
205
205
  * Throws an `Error` with the schema issue in its `cause` when validation
206
- * fails.
206
+ * fails. Schema validation failures use the generic message
207
+ * `"Schema validation failed"`; format the `cause` explicitly with
208
+ * `SchemaIssue.makeFormatterDefault()` when human-readable details are needed.
207
209
  * Causes that contain defects, interruptions, or other non-schema reasons
208
210
  * throw with the underlying `Cause` attached instead.
209
211
  *
@@ -244,10 +246,15 @@ export interface BottomWithoutNew<
244
246
  * Use when constructor input may fail validation and you want to
245
247
  * compose that failure with other `Effect` operations instead of throwing.
246
248
  *
249
+ * **Details**
250
+ *
251
+ * Validation failures are returned directly as `SchemaIssue.Issue` values
252
+ * and are not wrapped in `SchemaError`.
253
+ *
247
254
  * @see {@link BottomWithoutNew.make} — construct synchronously when validation failure should throw
248
255
  * @see {@link BottomWithoutNew.makeOption} — construct synchronously and discard validation details
249
256
  */
250
- makeEffect(input: this["~type.make.in"], options?: MakeOptions): Effect.Effect<this["Type"], SchemaError>
257
+ makeEffect(input: this["~type.make.in"], options?: MakeOptions): Effect.Effect<this["Type"], SchemaIssue.Issue>
251
258
  }
252
259
 
253
260
  /**
@@ -449,7 +456,7 @@ export interface declareConstructor<T, E, TypeParameters extends ReadonlyArray<C
449
456
  * **Example** (Schema for a parametric `Box<A>` type)
450
457
  *
451
458
  * ```ts import.meta.vitest
452
- * import { Effect, Schema, SchemaIssue as Issue, SchemaParser } from "effect"
459
+ * import { Effect, Schema, SchemaIssue, SchemaParser } from "effect"
453
460
  *
454
461
  * interface Box<A> {
455
462
  * readonly value: A
@@ -464,7 +471,7 @@ export interface declareConstructor<T, E, TypeParameters extends ReadonlyArray<C
464
471
  * ([itemCodec]) =>
465
472
  * (u, ast, options) => {
466
473
  * if (!isBox(u)) {
467
- * return Effect.fail(new SchemaIssue.InvalidType(ast))
474
+ * return Effect.fail(new SchemaIssue.InvalidType(ast, u, options))
468
475
  * }
469
476
  * return Effect.map(
470
477
  * SchemaParser.decodeUnknownEffect(itemCodec)(u.value, options),
@@ -552,10 +559,10 @@ export function declare<T, Iso = T>(
552
559
  ): declare<T, Iso> {
553
560
  return declareConstructor<T, T, Iso>()(
554
561
  [],
555
- () => (input, ast) =>
562
+ () => (input, ast, options) =>
556
563
  is(input) ?
557
564
  Effect.succeed(input) :
558
- Effect.fail(new SchemaIssue.InvalidType(ast)),
565
+ Effect.fail(new SchemaIssue.InvalidType(ast, input, options)),
559
566
  annotations
560
567
  )
561
568
  }
@@ -1161,10 +1168,12 @@ export {
1161
1168
  *
1162
1169
  * The `issue` field contains a structured {@link SchemaIssue.Issue} tree describing
1163
1170
  * every validation failure, including the path to the problematic value and
1164
- * the expected type or constraint. Built-in issues have no `actual` field,
1165
- * and built-in messages do not include the rejected value. Other Issue fields
1166
- * and custom annotations or messages are not sanitized. `message` renders the
1167
- * issue tree as a human-readable string.
1171
+ * the expected type or constraint. Parsing with `reportInput: true` adds an
1172
+ * enumerable `input` field to value-bearing issues created by the parser.
1173
+ * Built-in messages may include reported input. Other issue fields and
1174
+ * custom annotations or messages are not sanitized.
1175
+ * `message` renders the issue tree as a human-readable string and can disclose
1176
+ * retained input.
1168
1177
  *
1169
1178
  * Use {@link isSchemaError} to narrow an unknown value to `SchemaError`.
1170
1179
  *
@@ -1416,6 +1425,9 @@ export const is = SchemaParser.is
1416
1425
  *
1417
1426
  * The input is narrowed if the assertion succeeds. If schema validation fails,
1418
1427
  * the assertion throws an `Error` whose cause is `SchemaIssue.Issue`.
1428
+ * Schema validation failures use the generic message `"Schema validation failed"`.
1429
+ * Format the `cause` explicitly with `SchemaIssue.makeFormatterDefault()` when
1430
+ * human-readable details are needed.
1419
1431
  *
1420
1432
  * **Gotchas**
1421
1433
  *
@@ -1478,10 +1490,19 @@ export function decodeUnknownEffect<S extends Constraint>(schema: S, options?: S
1478
1490
  input: unknown,
1479
1491
  options?: SchemaAST.ParseOptions
1480
1492
  ): Effect.Effect<S["Type"], SchemaError, S["DecodingServices"]> => {
1481
- return InternalSchema.fromIssueEffect(parser(input, options))
1493
+ return fromIssueEffect(parser(input, options))
1482
1494
  }
1483
1495
  }
1484
1496
 
1497
+ function fromIssueEffect<A, R>(
1498
+ self: Effect.Effect<A, SchemaIssue.Issue, R>
1499
+ ): Effect.Effect<A, SchemaError, R> {
1500
+ return Effect.catchCause(
1501
+ self,
1502
+ (cause) => Effect.failCauseSync(() => Cause_.map(cause, (issue) => new SchemaError(issue)))
1503
+ )
1504
+ }
1505
+
1485
1506
  /**
1486
1507
  * Decodes a typed input (the schema's `Encoded` type) against a schema,
1487
1508
  * returning an `Effect` that succeeds with the decoded value or fails with a
@@ -1939,7 +1960,7 @@ export function encodeUnknownEffect<S extends Constraint>(schema: S, options?: S
1939
1960
  input: unknown,
1940
1961
  options?: SchemaAST.ParseOptions
1941
1962
  ): Effect.Effect<S["Encoded"], SchemaError, S["EncodingServices"]> => {
1942
- return InternalSchema.fromIssueEffect(parser(input, options))
1963
+ return fromIssueEffect(parser(input, options))
1943
1964
  }
1944
1965
  }
1945
1966
 
@@ -5744,7 +5765,7 @@ export interface withConstructorDefault<S extends Constraint & WithoutConstructo
5744
5765
  * **Details**
5745
5766
  *
5746
5767
  * Constructor defaults are applied only during `make*`, not during decoding or
5747
- * encoding.
5768
+ * encoding. Failures are represented directly as `SchemaIssue.Issue` values.
5748
5769
  *
5749
5770
  * **Example** (Defining an optional field with a static default)
5750
5771
  *
@@ -5767,10 +5788,10 @@ export interface withConstructorDefault<S extends Constraint & WithoutConstructo
5767
5788
  export function withConstructorDefault<S extends Constraint & WithoutConstructorDefault>(
5768
5789
  // `S["~type.make.in"]` instead of `S["Type"]` is intentional here because
5769
5790
  // it makes easier to define the default value if there are nested defaults
5770
- defaultValue: Effect.Effect<S["~type.make.in"], SchemaError>
5791
+ defaultValue: Effect.Effect<S["~type.make.in"], SchemaIssue.Issue>
5771
5792
  ) {
5772
5793
  return (schema: S): withConstructorDefault<S> =>
5773
- make(SchemaAST.withConstructorDefault(schema.ast, toIssueEffect(defaultValue)), { schema })
5794
+ make(SchemaAST.withConstructorDefault(schema.ast, defaultValue), { schema })
5774
5795
  }
5775
5796
 
5776
5797
  function toIssueEffect<A, R>(
@@ -6552,12 +6573,13 @@ export const makeFilter: <T>(
6552
6573
  *
6553
6574
  * - `string`: failure with that string as the message. Produces an
6554
6575
  * {@link SchemaIssue.InvalidValue} with the string used as the issue's
6555
- * `message` annotation.
6556
- * - {@link SchemaIssue.Issue}: a fully-formed issue, returned as-is.
6576
+ * `message` annotation and honors `reportInput`.
6577
+ * - {@link SchemaIssue.Issue}: a fully-formed issue, returned as-is. It is not
6578
+ * enriched when `reportInput` is enabled.
6557
6579
  * - `{ path, issue }`: failure attached to a nested path. `issue` is either
6558
- * a `string` (wrapped in an {@link SchemaIssue.InvalidValue}) or a full
6559
- * {@link SchemaIssue.Issue}; the result is wrapped in an {@link SchemaIssue.Pointer}
6560
- * at the given `path`.
6580
+ * a `string` (wrapped in an {@link SchemaIssue.InvalidValue} that honors
6581
+ * `reportInput`) or a full {@link SchemaIssue.Issue} (returned unchanged);
6582
+ * the result is wrapped in an {@link SchemaIssue.Pointer} at the given `path`.
6561
6583
  *
6562
6584
  * @category models
6563
6585
  * @since 3.10.0
@@ -6579,7 +6601,7 @@ export type FilterIssue = string | SchemaIssue.Issue | {
6579
6601
  * - `true`: success. Equivalent to `undefined`, useful when the predicate is
6580
6602
  * a plain boolean expression.
6581
6603
  * - `false`: generic failure. Produces an {@link SchemaIssue.InvalidValue}
6582
- * with no custom message.
6604
+ * with no custom message and honors `reportInput`.
6583
6605
  * - {@link FilterIssue}: a single failure. See {@link FilterIssue} for the
6584
6606
  * shapes (`string`, {@link SchemaIssue.Issue}, or `{ path, issue }`).
6585
6607
  * - `ReadonlyArray<FilterIssue>`: several failures reported together. An
@@ -9379,7 +9401,7 @@ export function isPropertyNames(keySchema: Constraint, annotations?: Annotations
9379
9401
  }
9380
9402
  }
9381
9403
  if (Arr.isArrayNonEmpty(issues)) {
9382
- return new SchemaIssue.Composite(ast, issues)
9404
+ return new SchemaIssue.Composite(ast, issues, input, options)
9383
9405
  }
9384
9406
  return true
9385
9407
  },
@@ -9580,11 +9602,11 @@ export function Option<A extends Constraint>(value: A): Option<A> {
9580
9602
  SchemaParser.decodeUnknownEffect(value)(input.value, options),
9581
9603
  {
9582
9604
  onSuccess: Option_.some,
9583
- onFailure: (issue) => new SchemaIssue.Composite(ast, [new SchemaIssue.Pointer(["value"], issue)])
9605
+ onFailure: (issue) => SchemaIssue.makeCompositeAtKey(ast, "value", issue, input, options)
9584
9606
  }
9585
9607
  )
9586
9608
  }
9587
- return Effect.fail(new SchemaIssue.InvalidType(ast))
9609
+ return Effect.fail(new SchemaIssue.InvalidType(ast, input, options))
9588
9610
  },
9589
9611
  {
9590
9612
  representation: {
@@ -9897,18 +9919,18 @@ export function Result<A extends Constraint, E extends Constraint>(
9897
9919
  [success, failure],
9898
9920
  ([success, failure]) => (input, ast, options) => {
9899
9921
  if (!Result_.isResult(input)) {
9900
- return Effect.fail(new SchemaIssue.InvalidType(ast))
9922
+ return Effect.fail(new SchemaIssue.InvalidType(ast, input, options))
9901
9923
  }
9902
9924
  switch (input._tag) {
9903
9925
  case "Success":
9904
9926
  return Effect.mapBothEager(SchemaParser.decodeEffect(success)(input.success, options), {
9905
9927
  onSuccess: Result_.succeed,
9906
- onFailure: (issue) => new SchemaIssue.Composite(ast, [new SchemaIssue.Pointer(["success"], issue)])
9928
+ onFailure: (issue) => SchemaIssue.makeCompositeAtKey(ast, "success", issue, input, options)
9907
9929
  })
9908
9930
  case "Failure":
9909
9931
  return Effect.mapBothEager(SchemaParser.decodeEffect(failure)(input.failure, options), {
9910
9932
  onSuccess: Result_.fail,
9911
- onFailure: (issue) => new SchemaIssue.Composite(ast, [new SchemaIssue.Pointer(["failure"], issue)])
9933
+ onFailure: (issue) => SchemaIssue.makeCompositeAtKey(ast, "failure", issue, input, options)
9912
9934
  })
9913
9935
  }
9914
9936
  },
@@ -10080,15 +10102,23 @@ export function Redacted<S extends Constraint>(value: S, options?: {
10080
10102
  {
10081
10103
  onSuccess: () => input,
10082
10104
  onFailure: (/** ignore the issue because of security reasons */) => {
10083
- return new SchemaIssue.Composite(ast, [
10084
- new SchemaIssue.Pointer(["value"], new SchemaIssue.InvalidValue())
10085
- ])
10105
+ return new SchemaIssue.Composite(
10106
+ ast,
10107
+ [
10108
+ new SchemaIssue.Pointer(
10109
+ ["value"],
10110
+ new SchemaIssue.InvalidValue(undefined, input, poptions)
10111
+ )
10112
+ ],
10113
+ input,
10114
+ poptions
10115
+ )
10086
10116
  }
10087
10117
  }
10088
10118
  )
10089
10119
  )
10090
10120
  }
10091
- return Effect.fail(new SchemaIssue.InvalidType(ast))
10121
+ return Effect.fail(new SchemaIssue.InvalidType(ast, input, poptions))
10092
10122
  },
10093
10123
  {
10094
10124
  representation: {
@@ -10254,7 +10284,7 @@ export function CauseReason<E extends Constraint, D extends Constraint>(error: E
10254
10284
  [error, defect],
10255
10285
  ([error, defect]) => (input, ast, options) => {
10256
10286
  if (!Cause_.isReason(input)) {
10257
- return Effect.fail(new SchemaIssue.InvalidType(ast))
10287
+ return Effect.fail(new SchemaIssue.InvalidType(ast, input, options))
10258
10288
  }
10259
10289
  switch (input._tag) {
10260
10290
  case "Fail":
@@ -10262,7 +10292,7 @@ export function CauseReason<E extends Constraint, D extends Constraint>(error: E
10262
10292
  SchemaParser.decodeUnknownEffect(error)(input.error, options),
10263
10293
  {
10264
10294
  onSuccess: Cause_.makeFailReason,
10265
- onFailure: (issue) => new SchemaIssue.Composite(ast, [new SchemaIssue.Pointer(["error"], issue)])
10295
+ onFailure: (issue) => SchemaIssue.makeCompositeAtKey(ast, "error", issue, input, options)
10266
10296
  }
10267
10297
  )
10268
10298
  case "Die":
@@ -10270,7 +10300,7 @@ export function CauseReason<E extends Constraint, D extends Constraint>(error: E
10270
10300
  SchemaParser.decodeUnknownEffect(defect)(input.defect, options),
10271
10301
  {
10272
10302
  onSuccess: Cause_.makeDieReason,
10273
- onFailure: (issue) => new SchemaIssue.Composite(ast, [new SchemaIssue.Pointer(["defect"], issue)])
10303
+ onFailure: (issue) => SchemaIssue.makeCompositeAtKey(ast, "defect", issue, input, options)
10274
10304
  }
10275
10305
  )
10276
10306
  case "Interrupt":
@@ -10445,11 +10475,11 @@ export function Cause<E extends Constraint, D extends Constraint>(error: E, defe
10445
10475
  const failures = ArraySchema(CauseReason(error, defect))
10446
10476
  return (input, ast, options) => {
10447
10477
  if (!Cause_.isCause(input)) {
10448
- return Effect.fail(new SchemaIssue.InvalidType(ast))
10478
+ return Effect.fail(new SchemaIssue.InvalidType(ast, input, options))
10449
10479
  }
10450
10480
  return Effect.mapBothEager(SchemaParser.decodeUnknownEffect(failures)(input.reasons, options), {
10451
10481
  onSuccess: Cause_.fromReasons,
10452
- onFailure: (issue) => new SchemaIssue.Composite(ast, [new SchemaIssue.Pointer(["failures"], issue)])
10482
+ onFailure: (issue) => SchemaIssue.makeCompositeAtKey(ast, "failures", issue, input, options)
10453
10483
  })
10454
10484
  }
10455
10485
  },
@@ -10524,17 +10554,17 @@ function causeToFormatter<E>(error: Formatter<E>, defect: Formatter<unknown>) {
10524
10554
  }
10525
10555
 
10526
10556
  /**
10527
- * Type-level representation of {@link Error}.
10557
+ * Type-level representation of {@link ErrorInstance}.
10528
10558
  *
10529
10559
  * @category models
10530
10560
  * @since 4.0.0
10531
10561
  */
10532
- export interface Error extends instanceOf<globalThis.Error> {
10533
- readonly "Rebuild": Error
10562
+ export interface ErrorInstance extends instanceOf<globalThis.Error> {
10563
+ readonly "Rebuild": ErrorInstance
10534
10564
  }
10535
10565
 
10536
10566
  /**
10537
- * Options for {@link Error} and {@link Defect}.
10567
+ * Options for {@link ErrorInstance} and {@link Defect}.
10538
10568
  *
10539
10569
  * @category options
10540
10570
  * @since 4.0.0
@@ -10597,7 +10627,7 @@ const getErrorOptions = (key: ErrorOptionsKey): NormalizedErrorOptions | undefin
10597
10627
  }
10598
10628
  }
10599
10629
 
10600
- const errorSchemaCache: Array<Error | undefined> = []
10630
+ const errorSchemaCache: Array<ErrorInstance | undefined> = []
10601
10631
 
10602
10632
  /**
10603
10633
  * Schema for JavaScript `Error` objects.
@@ -10614,7 +10644,7 @@ const errorSchemaCache: Array<Error | undefined> = []
10614
10644
  * @category schemas
10615
10645
  * @since 4.0.0
10616
10646
  */
10617
- export function Error(options?: ErrorOptions): Error {
10647
+ export function ErrorInstance(options?: ErrorOptions): ErrorInstance {
10618
10648
  const key = getErrorOptionsKey(options)
10619
10649
  const cached = errorSchemaCache[key]
10620
10650
  if (cached !== undefined) {
@@ -10627,7 +10657,9 @@ export function Error(options?: ErrorOptions): Error {
10627
10657
  payload: normalizedOptions ?? null
10628
10658
  },
10629
10659
  toCode: () => ({
10630
- runtime: normalizedOptions !== undefined ? `Schema.Error(${format(normalizedOptions)})` : `Schema.Error()`,
10660
+ runtime: normalizedOptions !== undefined
10661
+ ? `Schema.ErrorInstance(${format(normalizedOptions)})`
10662
+ : `Schema.ErrorInstance()`,
10631
10663
  Type: `globalThis.Error`
10632
10664
  }),
10633
10665
  expected: "Error",
@@ -10639,22 +10671,22 @@ export function Error(options?: ErrorOptions): Error {
10639
10671
  }
10640
10672
 
10641
10673
  /**
10642
- * Reviver for persisted {@link Error} declarations.
10674
+ * Reviver for persisted {@link ErrorInstance} declarations.
10643
10675
  *
10644
10676
  * **When to use**
10645
10677
  *
10646
- * Use when reconstructing documents that may contain schemas created by {@link Error}.
10678
+ * Use when reconstructing documents that may contain schemas created by {@link ErrorInstance}.
10647
10679
  *
10648
- * @see {@link Error} for creating the corresponding schema
10680
+ * @see {@link ErrorInstance} for creating the corresponding schema
10649
10681
  *
10650
10682
  * @category schemas
10651
10683
  * @since 4.0.0
10652
10684
  */
10653
- export const ErrorReviver = InternalSchema.makeDeclarationReviver(
10685
+ export const ErrorInstanceReviver = InternalSchema.makeDeclarationReviver(
10654
10686
  "effect/schema/Error",
10655
10687
  ErrorRepresentationPayload,
10656
10688
  ({ annotations, payload }) => {
10657
- const schema = Error(payload ?? undefined)
10689
+ const schema = ErrorInstance(payload ?? undefined)
10658
10690
  return annotations === undefined ? schema : schema.annotate(annotations)
10659
10691
  }
10660
10692
  )
@@ -10708,7 +10740,7 @@ const defectSchemaCache: Array<Defect | undefined> = []
10708
10740
  * - Values that cannot be represented as JSON fall back to Effect's formatted
10709
10741
  * string representation.
10710
10742
  *
10711
- * @see {@link Error} for a schema that only accepts JavaScript `Error` values.
10743
+ * @see {@link ErrorInstance} for a schema that only accepts JavaScript `Error` values.
10712
10744
  * @category schemas
10713
10745
  * @since 4.0.0
10714
10746
  */
@@ -10789,7 +10821,7 @@ export function Exit<A extends Constraint, E extends Constraint, D extends Const
10789
10821
  const cause = Cause(error, defect)
10790
10822
  return (input, ast, options) => {
10791
10823
  if (!Exit_.isExit(input)) {
10792
- return Effect.fail(new SchemaIssue.InvalidType(ast))
10824
+ return Effect.fail(new SchemaIssue.InvalidType(ast, input, options))
10793
10825
  }
10794
10826
  switch (input._tag) {
10795
10827
  case "Success":
@@ -10797,7 +10829,7 @@ export function Exit<A extends Constraint, E extends Constraint, D extends Const
10797
10829
  SchemaParser.decodeUnknownEffect(value)(input.value, options),
10798
10830
  {
10799
10831
  onSuccess: Exit_.succeed,
10800
- onFailure: (issue) => new SchemaIssue.Composite(ast, [new SchemaIssue.Pointer(["value"], issue)])
10832
+ onFailure: (issue) => SchemaIssue.makeCompositeAtKey(ast, "value", issue, input, options)
10801
10833
  }
10802
10834
  )
10803
10835
  case "Failure":
@@ -10805,7 +10837,7 @@ export function Exit<A extends Constraint, E extends Constraint, D extends Const
10805
10837
  SchemaParser.decodeUnknownEffect(cause)(input.cause, options),
10806
10838
  {
10807
10839
  onSuccess: Exit_.failCause,
10808
- onFailure: (issue) => new SchemaIssue.Composite(ast, [new SchemaIssue.Pointer(["cause"], issue)])
10840
+ onFailure: (issue) => SchemaIssue.makeCompositeAtKey(ast, "cause", issue, input, options)
10809
10841
  }
10810
10842
  )
10811
10843
  }
@@ -11046,11 +11078,11 @@ export function ReadonlyMap<Key extends Constraint, Value extends Constraint>(
11046
11078
  SchemaParser.decodeUnknownEffect(array)([...input], options),
11047
11079
  {
11048
11080
  onSuccess: (array: ReadonlyArray<readonly [Key["Type"], Value["Type"]]>) => new globalThis.Map(array),
11049
- onFailure: (issue) => new SchemaIssue.Composite(ast, [new SchemaIssue.Pointer(["entries"], issue)])
11081
+ onFailure: (issue) => SchemaIssue.makeCompositeAtKey(ast, "entries", issue, input, options)
11050
11082
  }
11051
11083
  )
11052
11084
  }
11053
- return Effect.fail(new SchemaIssue.InvalidType(ast))
11085
+ return Effect.fail(new SchemaIssue.InvalidType(ast, input, options))
11054
11086
  }
11055
11087
  },
11056
11088
  {
@@ -11158,11 +11190,11 @@ export function HashMap<Key extends Constraint, Value extends Constraint>(key: K
11158
11190
  SchemaParser.decodeUnknownEffect(entries)(HashMap_.toEntries(input), options),
11159
11191
  {
11160
11192
  onSuccess: HashMap_.fromIterable,
11161
- onFailure: (issue) => new SchemaIssue.Composite(ast, [new SchemaIssue.Pointer(["entries"], issue)])
11193
+ onFailure: (issue) => SchemaIssue.makeCompositeAtKey(ast, "entries", issue, input, options)
11162
11194
  }
11163
11195
  )
11164
11196
  }
11165
- return Effect.fail(new SchemaIssue.InvalidType(ast))
11197
+ return Effect.fail(new SchemaIssue.InvalidType(ast, input, options))
11166
11198
  }
11167
11199
  },
11168
11200
  {
@@ -11268,11 +11300,11 @@ export function ReadonlySet<Value extends Constraint>(value: Value): $ReadonlySe
11268
11300
  SchemaParser.decodeUnknownEffect(array)([...input], options),
11269
11301
  {
11270
11302
  onSuccess: (array: ReadonlyArray<Value["Type"]>) => new globalThis.Set(array),
11271
- onFailure: (issue) => new SchemaIssue.Composite(ast, [new SchemaIssue.Pointer(["values"], issue)])
11303
+ onFailure: (issue) => SchemaIssue.makeCompositeAtKey(ast, "values", issue, input, options)
11272
11304
  }
11273
11305
  )
11274
11306
  }
11275
- return Effect.fail(new SchemaIssue.InvalidType(ast))
11307
+ return Effect.fail(new SchemaIssue.InvalidType(ast, input, options))
11276
11308
  }
11277
11309
  },
11278
11310
  {
@@ -11378,11 +11410,11 @@ export function HashSet<Value extends Constraint>(value: Value): HashSet<Value>
11378
11410
  SchemaParser.decodeUnknownEffect(values)(Arr.fromIterable(input), options),
11379
11411
  {
11380
11412
  onSuccess: HashSet_.fromIterable,
11381
- onFailure: (issue) => new SchemaIssue.Composite(ast, [new SchemaIssue.Pointer(["values"], issue)])
11413
+ onFailure: (issue) => SchemaIssue.makeCompositeAtKey(ast, "values", issue, input, options)
11382
11414
  }
11383
11415
  )
11384
11416
  }
11385
- return Effect.fail(new SchemaIssue.InvalidType(ast))
11417
+ return Effect.fail(new SchemaIssue.InvalidType(ast, input, options))
11386
11418
  }
11387
11419
  },
11388
11420
  {
@@ -11495,11 +11527,11 @@ export function Chunk<Value extends Constraint>(value: Value): Chunk<Value> {
11495
11527
  SchemaParser.decodeUnknownEffect(values)(Arr.fromIterable(input), options),
11496
11528
  {
11497
11529
  onSuccess: Chunk_.fromIterable,
11498
- onFailure: (issue) => new SchemaIssue.Composite(ast, [new SchemaIssue.Pointer(["values"], issue)])
11530
+ onFailure: (issue) => SchemaIssue.makeCompositeAtKey(ast, "values", issue, input, options)
11499
11531
  }
11500
11532
  )
11501
11533
  }
11502
- return Effect.fail(new SchemaIssue.InvalidType(ast))
11534
+ return Effect.fail(new SchemaIssue.InvalidType(ast, input, options))
11503
11535
  }
11504
11536
  },
11505
11537
  {
@@ -11596,10 +11628,15 @@ export const RegExp: RegExp = instanceOf(
11596
11628
  flags: String
11597
11629
  }),
11598
11630
  SchemaTransformation.transformOrFail({
11599
- decode: (e) =>
11631
+ decode: (e, options) =>
11600
11632
  Effect.try({
11601
11633
  try: () => new globalThis.RegExp(e.source, e.flags),
11602
- catch: () => new SchemaIssue.InvalidValue({ message: "Expected valid RegExp source and flags" })
11634
+ catch: () =>
11635
+ new SchemaIssue.InvalidValue(
11636
+ { expected: "valid RegExp source and flags" },
11637
+ e,
11638
+ options
11639
+ )
11603
11640
  }),
11604
11641
  encode: (regExp) =>
11605
11642
  Effect.succeed({
@@ -12428,13 +12465,15 @@ export const File: File = instanceOf(globalThis.File, {
12428
12465
  lastModified: Int
12429
12466
  }),
12430
12467
  SchemaTransformation.transformOrFail({
12431
- decode: (e) =>
12468
+ decode: (e, options) =>
12432
12469
  Result_.match(Encoding.decodeBase64(e.data), {
12433
12470
  onFailure: () =>
12434
12471
  Effect.fail(
12435
- new SchemaIssue.InvalidValue({
12436
- message: "Expected a valid Base64 string"
12437
- })
12472
+ new SchemaIssue.InvalidValue(
12473
+ { expected: "a valid Base64 string" },
12474
+ e.data,
12475
+ options
12476
+ )
12438
12477
  ),
12439
12478
  onSuccess: (bytes) => {
12440
12479
  const buffer = new globalThis.Uint8Array(bytes)
@@ -12443,7 +12482,7 @@ export const File: File = instanceOf(globalThis.File, {
12443
12482
  )
12444
12483
  }
12445
12484
  }),
12446
- encode: (file) =>
12485
+ encode: (file, options) =>
12447
12486
  Effect.tryPromise({
12448
12487
  try: async () => {
12449
12488
  const bytes = new globalThis.Uint8Array(await file.arrayBuffer())
@@ -12455,9 +12494,11 @@ export const File: File = instanceOf(globalThis.File, {
12455
12494
  }
12456
12495
  },
12457
12496
  catch: () =>
12458
- new SchemaIssue.InvalidValue({
12459
- message: "Expected File to be readable"
12460
- })
12497
+ new SchemaIssue.InvalidValue(
12498
+ { expected: "a readable File" },
12499
+ file,
12500
+ options
12501
+ )
12461
12502
  })
12462
12503
  })
12463
12504
  )
@@ -14051,7 +14092,7 @@ function makeClass<
14051
14092
  static makeOption(input: S["~type.make.in"], options?: MakeOptions): Option_.Option<Self> {
14052
14093
  return SchemaParser.makeOption(getClassSchema(this) as any)(input ?? {}, options) as any
14053
14094
  }
14054
- static makeEffect(input: S["~type.make.in"], options?: MakeOptions): Effect.Effect<Self, SchemaError> {
14095
+ static makeEffect(input: S["~type.make.in"], options?: MakeOptions): Effect.Effect<Self, SchemaIssue.Issue> {
14055
14096
  return (getClassSchema(this) as any).makeEffect(input ?? {}, options)
14056
14097
  }
14057
14098
  static annotate(annotations: Annotations.Declaration<Self, readonly [S]>) {
@@ -14129,19 +14170,26 @@ function getClassSchemaFactory<S extends Constraint>(
14129
14170
  if (memo !== undefined) {
14130
14171
  return memo
14131
14172
  }
14173
+ const ClassTypeId = getClassTypeId(identifier)
14174
+ const isClassValue: Predicate.Predicate<unknown> = (input) =>
14175
+ input instanceof self || Predicate.hasProperty(input, ClassTypeId)
14132
14176
  const transformation = getClassTransformation(self)
14133
14177
  const to = make<declareConstructor<Self, S["Encoded"], readonly [S]>>(
14134
14178
  new SchemaAST.Declaration(
14135
14179
  [from.ast],
14136
- () => (input, ast) => {
14137
- return input instanceof self ||
14138
- Predicate.hasProperty(input, getClassTypeId(identifier)) ?
14180
+ () => (input, ast, options) => {
14181
+ return isClassValue(input) ?
14139
14182
  Effect.succeed(input) :
14140
- Effect.fail(new SchemaIssue.InvalidType(ast))
14183
+ Effect.fail(new SchemaIssue.InvalidType(ast, input, options))
14141
14184
  },
14142
14185
  {
14143
14186
  identifier,
14144
- [SchemaAST.ClassTypeId]: ([from]: readonly [SchemaAST.AST]) => new SchemaAST.Link(from, transformation),
14187
+ [InternalAnnotations.CONSTRUCTOR_ANNOTATION_KEY]: (
14188
+ [from]: readonly [SchemaAST.AST]
14189
+ ): SchemaAST.ConstructorDescriptor => ({
14190
+ isConstructed: isClassValue,
14191
+ link: new SchemaAST.Link(from, transformation)
14192
+ }),
14145
14193
  toCodec: ([from]: readonly [ConstraintCodec<S["Encoded"], S["Encoded"]>]) =>
14146
14194
  new SchemaAST.Link(from.ast, transformation),
14147
14195
  toArbitrary: ([from]: readonly [Annotations.ToArbitrary.TypeParameter<S["Type"]>]) => () => ({
@@ -14167,8 +14215,8 @@ type MissingSelfGeneric<Usage extends string> =
14167
14215
 
14168
14216
  /**
14169
14217
  * Creates a schema-backed class whose constructor validates input against a
14170
- * {@link Struct} schema. Construction throws a {@link SchemaError} on invalid
14171
- * input.
14218
+ * {@link Struct} schema. Construction throws an `Error` with a
14219
+ * `SchemaIssue.Issue` in its `cause` on invalid input.
14172
14220
  *
14173
14221
  * **When to use**
14174
14222
  *
@@ -14228,8 +14276,8 @@ type MissingSelfGeneric<Usage extends string> =
14228
14276
  * ```
14229
14277
  *
14230
14278
  * @see {@link TaggedClass} for adding a `_tag` literal field to the class schema
14231
- * @see {@link ErrorClass} for defining schema-backed error classes
14232
- * @see {@link TaggedErrorClass} for defining tagged schema-backed error classes
14279
+ * @see {@link Error} for defining schema-backed error classes
14280
+ * @see {@link TaggedError} for defining tagged schema-backed error classes
14233
14281
  *
14234
14282
  * @category constructors
14235
14283
  * @since 3.10.0
@@ -14237,8 +14285,8 @@ type MissingSelfGeneric<Usage extends string> =
14237
14285
  export const Class: {
14238
14286
  /**
14239
14287
  * Creates a schema-backed class whose constructor validates input against a
14240
- * {@link Struct} schema. Construction throws a {@link SchemaError} on invalid
14241
- * input.
14288
+ * {@link Struct} schema. Construction throws an `Error` with a
14289
+ * `SchemaIssue.Issue` in its `cause` on invalid input.
14242
14290
  *
14243
14291
  * **When to use**
14244
14292
  *
@@ -14298,8 +14346,8 @@ export const Class: {
14298
14346
  * ```
14299
14347
  *
14300
14348
  * @see {@link TaggedClass} for adding a `_tag` literal field to the class schema
14301
- * @see {@link ErrorClass} for defining schema-backed error classes
14302
- * @see {@link TaggedErrorClass} for defining tagged schema-backed error classes
14349
+ * @see {@link Error} for defining schema-backed error classes
14350
+ * @see {@link TaggedError} for defining tagged schema-backed error classes
14303
14351
  *
14304
14352
  * @category constructors
14305
14353
  * @since 3.10.0
@@ -14307,8 +14355,8 @@ export const Class: {
14307
14355
  <Self = never, Brand = {}>(identifier: string): {
14308
14356
  /**
14309
14357
  * Creates a schema-backed class whose constructor validates input against a
14310
- * {@link Struct} schema. Construction throws a {@link SchemaError} on invalid
14311
- * input.
14358
+ * {@link Struct} schema. Construction throws an `Error` with a
14359
+ * `SchemaIssue.Issue` in its `cause` on invalid input.
14312
14360
  *
14313
14361
  * **When to use**
14314
14362
  *
@@ -14368,8 +14416,8 @@ export const Class: {
14368
14416
  * ```
14369
14417
  *
14370
14418
  * @see {@link TaggedClass} for adding a `_tag` literal field to the class schema
14371
- * @see {@link ErrorClass} for defining schema-backed error classes
14372
- * @see {@link TaggedErrorClass} for defining tagged schema-backed error classes
14419
+ * @see {@link Error} for defining schema-backed error classes
14420
+ * @see {@link TaggedError} for defining tagged schema-backed error classes
14373
14421
  *
14374
14422
  * @category constructors
14375
14423
  * @since 3.10.0
@@ -14380,8 +14428,8 @@ export const Class: {
14380
14428
  ): [Self] extends [never] ? MissingSelfGeneric<"Schema.Class"> : Class<Self, Struct<Fields>, Brand>
14381
14429
  /**
14382
14430
  * Creates a schema-backed class whose constructor validates input against a
14383
- * {@link Struct} schema. Construction throws a {@link SchemaError} on invalid
14384
- * input.
14431
+ * {@link Struct} schema. Construction throws an `Error` with a
14432
+ * `SchemaIssue.Issue` in its `cause` on invalid input.
14385
14433
  *
14386
14434
  * **When to use**
14387
14435
  *
@@ -14441,8 +14489,8 @@ export const Class: {
14441
14489
  * ```
14442
14490
  *
14443
14491
  * @see {@link TaggedClass} for adding a `_tag` literal field to the class schema
14444
- * @see {@link ErrorClass} for defining schema-backed error classes
14445
- * @see {@link TaggedErrorClass} for defining tagged schema-backed error classes
14492
+ * @see {@link Error} for defining schema-backed error classes
14493
+ * @see {@link TaggedError} for defining tagged schema-backed error classes
14446
14494
  *
14447
14495
  * @category constructors
14448
14496
  * @since 3.10.0
@@ -14634,7 +14682,7 @@ export const TaggedClass: {
14634
14682
  * ```ts import.meta.vitest
14635
14683
  * import { Effect, Schema } from "effect"
14636
14684
  *
14637
- * class NotFound extends Schema.ErrorClass<NotFound>("NotFound")({
14685
+ * class NotFound extends Schema.Error<NotFound>("NotFound")({
14638
14686
  * id: Schema.Number
14639
14687
  * }) {}
14640
14688
  *
@@ -14648,7 +14696,7 @@ export const TaggedClass: {
14648
14696
  * @category constructors
14649
14697
  * @since 4.0.0
14650
14698
  */
14651
- export const ErrorClass: {
14699
+ export const Error: {
14652
14700
  /**
14653
14701
  * Creates a schema-backed error class that can be used as a typed,
14654
14702
  * yieldable error in Effect programs. Combines {@link Class} validation with
@@ -14660,7 +14708,7 @@ export const ErrorClass: {
14660
14708
  * ```ts import.meta.vitest
14661
14709
  * import { Effect, Schema } from "effect"
14662
14710
  *
14663
- * class NotFound extends Schema.ErrorClass<NotFound>("NotFound")({
14711
+ * class NotFound extends Schema.Error<NotFound>("NotFound")({
14664
14712
  * id: Schema.Number
14665
14713
  * }) {}
14666
14714
  *
@@ -14686,7 +14734,7 @@ export const ErrorClass: {
14686
14734
  * ```ts import.meta.vitest
14687
14735
  * import { Effect, Schema } from "effect"
14688
14736
  *
14689
- * class NotFound extends Schema.ErrorClass<NotFound>("NotFound")({
14737
+ * class NotFound extends Schema.Error<NotFound>("NotFound")({
14690
14738
  * id: Schema.Number
14691
14739
  * }) {}
14692
14740
  *
@@ -14703,7 +14751,7 @@ export const ErrorClass: {
14703
14751
  <const Fields extends Struct.Fields>(
14704
14752
  fields: Fields,
14705
14753
  annotations?: Annotations.Declaration<Self, readonly [Struct<Fields>]>
14706
- ): [Self] extends [never] ? MissingSelfGeneric<"Schema.ErrorClass">
14754
+ ): [Self] extends [never] ? MissingSelfGeneric<"Schema.Error">
14707
14755
  : Class<Self, Struct<Fields>, Cause_.YieldableError & Brand>
14708
14756
  /**
14709
14757
  * Creates a schema-backed error class that can be used as a typed,
@@ -14716,7 +14764,7 @@ export const ErrorClass: {
14716
14764
  * ```ts import.meta.vitest
14717
14765
  * import { Effect, Schema } from "effect"
14718
14766
  *
14719
- * class NotFound extends Schema.ErrorClass<NotFound>("NotFound")({
14767
+ * class NotFound extends Schema.Error<NotFound>("NotFound")({
14720
14768
  * id: Schema.Number
14721
14769
  * }) {}
14722
14770
  *
@@ -14730,13 +14778,13 @@ export const ErrorClass: {
14730
14778
  * @category constructors
14731
14779
  * @since 4.0.0
14732
14780
  */
14733
- <S extends Struct<Struct.Fields>>(schema: S, annotations?: Annotations.Declaration<Self, readonly [S]>): [Self] extends [never] ? MissingSelfGeneric<"Schema.ErrorClass"> : Class<Self, S, Cause_.YieldableError & Brand>
14781
+ <S extends Struct<Struct.Fields>>(schema: S, annotations?: Annotations.Declaration<Self, readonly [S]>): [Self] extends [never] ? MissingSelfGeneric<"Schema.Error"> : Class<Self, S, Cause_.YieldableError & Brand>
14734
14782
  }
14735
14783
  } = <Self, Brand = {}>(identifier: string) =>
14736
14784
  (
14737
14785
  schema: Struct.Fields | Struct<Struct.Fields>,
14738
14786
  annotations?: Annotations.Declaration<Self, readonly [Struct<Struct.Fields>]>
14739
- ): [Self] extends [never] ? MissingSelfGeneric<"Schema.ErrorClass">
14787
+ ): [Self] extends [never] ? MissingSelfGeneric<"Schema.Error">
14740
14788
  : Class<Self, Struct<Struct.Fields>, Cause_.YieldableError & Brand> =>
14741
14789
  {
14742
14790
  const struct = isStruct(schema) ? schema : Struct(schema)
@@ -14766,7 +14814,7 @@ export const ErrorClass: {
14766
14814
  * ```ts import.meta.vitest
14767
14815
  * import { Effect, Schema } from "effect"
14768
14816
  *
14769
- * class NotFound extends Schema.TaggedErrorClass<NotFound>()("NotFound", {
14817
+ * class NotFound extends Schema.TaggedError<NotFound>()("NotFound", {
14770
14818
  * id: Schema.Number
14771
14819
  * }) {}
14772
14820
  *
@@ -14781,7 +14829,7 @@ export const ErrorClass: {
14781
14829
  * @category constructors
14782
14830
  * @since 3.10.0
14783
14831
  */
14784
- export const TaggedErrorClass: {
14832
+ export const TaggedError: {
14785
14833
  /**
14786
14834
  * Defines a schema-backed yieldable error class with an automatically populated
14787
14835
  * `_tag` field.
@@ -14796,7 +14844,7 @@ export const TaggedErrorClass: {
14796
14844
  * ```ts import.meta.vitest
14797
14845
  * import { Effect, Schema } from "effect"
14798
14846
  *
14799
- * class NotFound extends Schema.TaggedErrorClass<NotFound>()("NotFound", {
14847
+ * class NotFound extends Schema.TaggedError<NotFound>()("NotFound", {
14800
14848
  * id: Schema.Number
14801
14849
  * }) {}
14802
14850
  *
@@ -14826,7 +14874,7 @@ export const TaggedErrorClass: {
14826
14874
  * ```ts import.meta.vitest
14827
14875
  * import { Effect, Schema } from "effect"
14828
14876
  *
14829
- * class NotFound extends Schema.TaggedErrorClass<NotFound>()("NotFound", {
14877
+ * class NotFound extends Schema.TaggedError<NotFound>()("NotFound", {
14830
14878
  * id: Schema.Number
14831
14879
  * }) {}
14832
14880
  *
@@ -14845,7 +14893,7 @@ export const TaggedErrorClass: {
14845
14893
  tag: Tag,
14846
14894
  fields: Fields,
14847
14895
  annotations?: Annotations.Declaration<Self, readonly [TaggedStruct<Tag, Fields>]>
14848
- ): [Self] extends [never] ? MissingSelfGeneric<"Schema.TaggedErrorClass">
14896
+ ): [Self] extends [never] ? MissingSelfGeneric<"Schema.TaggedError">
14849
14897
  : Class<Self, TaggedStruct<Tag, Fields>, Cause_.YieldableError & Brand>
14850
14898
  /**
14851
14899
  * Defines a schema-backed yieldable error class with an automatically populated
@@ -14861,7 +14909,7 @@ export const TaggedErrorClass: {
14861
14909
  * ```ts import.meta.vitest
14862
14910
  * import { Effect, Schema } from "effect"
14863
14911
  *
14864
- * class NotFound extends Schema.TaggedErrorClass<NotFound>()("NotFound", {
14912
+ * class NotFound extends Schema.TaggedError<NotFound>()("NotFound", {
14865
14913
  * id: Schema.Number
14866
14914
  * }) {}
14867
14915
  *
@@ -14883,7 +14931,7 @@ export const TaggedErrorClass: {
14883
14931
  Self,
14884
14932
  readonly [Struct<Simplify<{ readonly _tag: tag<Tag> } & S["fields"]>>]
14885
14933
  >
14886
- ): [Self] extends [never] ? MissingSelfGeneric<"Schema.TaggedErrorClass">
14934
+ ): [Self] extends [never] ? MissingSelfGeneric<"Schema.TaggedError">
14887
14935
  : Class<Self, Struct<Simplify<{ readonly _tag: tag<Tag> } & S["fields"]>>, Cause_.YieldableError & Brand>
14888
14936
  }
14889
14937
  } = (identifier?: string) => {
@@ -14897,7 +14945,7 @@ export const TaggedErrorClass: {
14897
14945
  unsafePreserveChecks: true
14898
14946
  }) :
14899
14947
  TaggedStruct(tagValue, schema)
14900
- return ErrorClass<any, {}>(identifier ?? tagValue)(
14948
+ return Error<any, {}>(identifier ?? tagValue)(
14901
14949
  struct,
14902
14950
  annotations as Annotations.Declaration<any, readonly [typeof struct]>
14903
14951
  )
@@ -15385,7 +15433,7 @@ const toCodecJsonASTBase = SchemaAST.applyToSelfOrLastLinkEncoding((ast) => {
15385
15433
  export const toCodecJsonAST = memoize(toCodecJsonASTBase)
15386
15434
 
15387
15435
  function withoutConstructorDefault(context: SchemaAST.Context): SchemaAST.Context {
15388
- return context.defaultValue === undefined ?
15436
+ return context.constructorDefault === undefined ?
15389
15437
  context :
15390
15438
  new SchemaAST.Context(context.isOptional, context.isMutable, undefined, context.annotations)
15391
15439
  }
@@ -16122,6 +16170,18 @@ export const isBetweenBigIntReviver: SchemaRepresentation.FilterReviver<{
16122
16170
  * Derives an `Iso` optic from a schema that isomorphically converts between
16123
16171
  * the schema's `Type` and its `Iso` (intermediate / serialized form).
16124
16172
  *
16173
+ * **Details**
16174
+ *
16175
+ * Reading through the `Iso` encodes the schema value, while replacing through
16176
+ * it decodes the new focus.
16177
+ *
16178
+ * **Gotchas**
16179
+ *
16180
+ * Either direction can throw an `Error` with the generic message
16181
+ * `"Schema validation failed"` and a `SchemaIssue.Issue` in its `cause`. Format
16182
+ * the `cause` explicitly with `SchemaIssue.makeFormatterDefault()` when
16183
+ * human-readable details are needed.
16184
+ *
16125
16185
  * @category converting
16126
16186
  * @since 4.0.0
16127
16187
  */
@@ -16221,6 +16281,19 @@ export function overrideToCodecIso<S extends Constraint, Iso>(
16221
16281
  * {@link toCodecJson}), computes RFC 6902 JSON Patch operations between old
16222
16282
  * and new values, and can apply patches back to the typed value.
16223
16283
  *
16284
+ * **Details**
16285
+ *
16286
+ * `diff` encodes both values before computing the patch. `patch` encodes the old
16287
+ * value, applies the patch to its JSON representation, and decodes the result.
16288
+ *
16289
+ * **Gotchas**
16290
+ *
16291
+ * Schema encoding or decoding failures throw an `Error` with the generic message
16292
+ * `"Schema validation failed"` and a `SchemaIssue.Issue` in its `cause`. Format
16293
+ * the `cause` explicitly with `SchemaIssue.makeFormatterDefault()` when
16294
+ * human-readable details are needed. Errors produced by {@link JsonPatch.apply}
16295
+ * for invalid patch operations are separate from schema validation failures.
16296
+ *
16224
16297
  * @category converting
16225
16298
  * @since 4.0.0
16226
16299
  */
@@ -17057,12 +17130,22 @@ export declare namespace Annotations {
17057
17130
  *
17058
17131
  * **Details**
17059
17132
  *
17060
- * The optional `message` field overrides the default issue message.
17133
+ * For `InvalidValue` issues, `message` overrides the complete formatted
17134
+ * message. When `message` is absent, `expected` uses the default expected
17135
+ * value policy, including reported input when available. Other issue types
17136
+ * ignore `expected`.
17061
17137
  *
17062
17138
  * @category models
17063
17139
  * @since 4.0.0
17064
17140
  */
17065
17141
  export interface Issue extends Annotations {
17142
+ /**
17143
+ * The expected value description for an `InvalidValue` issue.
17144
+ */
17145
+ readonly expected?: string | undefined
17146
+ /**
17147
+ * The complete formatted message for the issue.
17148
+ */
17066
17149
  readonly message?: string | undefined
17067
17150
  }
17068
17151
  }