effect 4.0.0-beta.4 → 4.0.0-beta.40

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 (1222) hide show
  1. package/dist/Array.d.ts +213 -385
  2. package/dist/Array.d.ts.map +1 -1
  3. package/dist/Array.js +149 -102
  4. package/dist/Array.js.map +1 -1
  5. package/dist/BigDecimal.d.ts +46 -45
  6. package/dist/BigDecimal.d.ts.map +1 -1
  7. package/dist/BigDecimal.js +35 -38
  8. package/dist/BigDecimal.js.map +1 -1
  9. package/dist/BigInt.d.ts +39 -32
  10. package/dist/BigInt.d.ts.map +1 -1
  11. package/dist/BigInt.js +32 -29
  12. package/dist/BigInt.js.map +1 -1
  13. package/dist/Brand.d.ts +1 -1
  14. package/dist/Brand.d.ts.map +1 -1
  15. package/dist/Brand.js +1 -1
  16. package/dist/Brand.js.map +1 -1
  17. package/dist/Cache.d.ts +2 -2
  18. package/dist/Cache.d.ts.map +1 -1
  19. package/dist/Cache.js +6 -5
  20. package/dist/Cache.js.map +1 -1
  21. package/dist/Cause.d.ts +33 -2
  22. package/dist/Cause.d.ts.map +1 -1
  23. package/dist/Cause.js +19 -0
  24. package/dist/Cause.js.map +1 -1
  25. package/dist/Channel.d.ts +130 -35
  26. package/dist/Channel.d.ts.map +1 -1
  27. package/dist/Channel.js +96 -45
  28. package/dist/Channel.js.map +1 -1
  29. package/dist/Chunk.d.ts +112 -304
  30. package/dist/Chunk.d.ts.map +1 -1
  31. package/dist/Chunk.js +56 -88
  32. package/dist/Chunk.js.map +1 -1
  33. package/dist/Combiner.d.ts +280 -13
  34. package/dist/Combiner.d.ts.map +1 -1
  35. package/dist/Combiner.js +198 -7
  36. package/dist/Combiner.js.map +1 -1
  37. package/dist/Config.d.ts +169 -9
  38. package/dist/Config.d.ts.map +1 -1
  39. package/dist/Config.js +69 -11
  40. package/dist/Config.js.map +1 -1
  41. package/dist/ConfigProvider.d.ts +1 -1
  42. package/dist/Cron.d.ts +11 -7
  43. package/dist/Cron.d.ts.map +1 -1
  44. package/dist/Cron.js +120 -63
  45. package/dist/Cron.js.map +1 -1
  46. package/dist/Data.d.ts +535 -366
  47. package/dist/Data.d.ts.map +1 -1
  48. package/dist/Data.js +132 -79
  49. package/dist/Data.js.map +1 -1
  50. package/dist/DateTime.d.ts +72 -253
  51. package/dist/DateTime.d.ts.map +1 -1
  52. package/dist/DateTime.js +15 -60
  53. package/dist/DateTime.js.map +1 -1
  54. package/dist/Deferred.d.ts +7 -5
  55. package/dist/Deferred.d.ts.map +1 -1
  56. package/dist/Deferred.js +7 -5
  57. package/dist/Deferred.js.map +1 -1
  58. package/dist/Duration.d.ts +62 -32
  59. package/dist/Duration.d.ts.map +1 -1
  60. package/dist/Duration.js +108 -78
  61. package/dist/Duration.js.map +1 -1
  62. package/dist/Effect.d.ts +1224 -951
  63. package/dist/Effect.d.ts.map +1 -1
  64. package/dist/Effect.js +398 -338
  65. package/dist/Effect.js.map +1 -1
  66. package/dist/Encoding.d.ts +194 -0
  67. package/dist/Encoding.d.ts.map +1 -0
  68. package/dist/Encoding.js +352 -0
  69. package/dist/Encoding.js.map +1 -0
  70. package/dist/Equal.d.ts +276 -109
  71. package/dist/Equal.d.ts.map +1 -1
  72. package/dist/Equal.js +124 -48
  73. package/dist/Equal.js.map +1 -1
  74. package/dist/Equivalence.d.ts +60 -3
  75. package/dist/Equivalence.d.ts.map +1 -1
  76. package/dist/Equivalence.js +70 -13
  77. package/dist/Equivalence.js.map +1 -1
  78. package/dist/ErrorReporter.d.ts +374 -0
  79. package/dist/ErrorReporter.d.ts.map +1 -0
  80. package/dist/ErrorReporter.js +245 -0
  81. package/dist/ErrorReporter.js.map +1 -0
  82. package/dist/Exit.d.ts +24 -12
  83. package/dist/Exit.d.ts.map +1 -1
  84. package/dist/Exit.js +8 -4
  85. package/dist/Exit.js.map +1 -1
  86. package/dist/Fiber.d.ts +5 -3
  87. package/dist/Fiber.d.ts.map +1 -1
  88. package/dist/Fiber.js.map +1 -1
  89. package/dist/FiberHandle.d.ts +9 -8
  90. package/dist/FiberHandle.d.ts.map +1 -1
  91. package/dist/FiberHandle.js +8 -7
  92. package/dist/FiberHandle.js.map +1 -1
  93. package/dist/FiberMap.d.ts +20 -19
  94. package/dist/FiberMap.d.ts.map +1 -1
  95. package/dist/FiberMap.js +6 -6
  96. package/dist/FiberMap.js.map +1 -1
  97. package/dist/FileSystem.d.ts +18 -17
  98. package/dist/FileSystem.d.ts.map +1 -1
  99. package/dist/FileSystem.js +17 -13
  100. package/dist/FileSystem.js.map +1 -1
  101. package/dist/Filter.d.ts +34 -38
  102. package/dist/Filter.d.ts.map +1 -1
  103. package/dist/Filter.js +15 -13
  104. package/dist/Filter.js.map +1 -1
  105. package/dist/Formatter.d.ts +131 -47
  106. package/dist/Formatter.d.ts.map +1 -1
  107. package/dist/Formatter.js +229 -51
  108. package/dist/Formatter.js.map +1 -1
  109. package/dist/Function.d.ts +1 -9
  110. package/dist/Function.d.ts.map +1 -1
  111. package/dist/Function.js +2 -10
  112. package/dist/Function.js.map +1 -1
  113. package/dist/Graph.d.ts +65 -65
  114. package/dist/Graph.d.ts.map +1 -1
  115. package/dist/Graph.js +60 -62
  116. package/dist/Graph.js.map +1 -1
  117. package/dist/HashMap.d.ts +26 -19
  118. package/dist/HashMap.d.ts.map +1 -1
  119. package/dist/HashMap.js +7 -5
  120. package/dist/HashMap.js.map +1 -1
  121. package/dist/Iterable.d.ts +50 -50
  122. package/dist/Iterable.d.ts.map +1 -1
  123. package/dist/Iterable.js +106 -34
  124. package/dist/Iterable.js.map +1 -1
  125. package/dist/JsonSchema.d.ts +299 -10
  126. package/dist/JsonSchema.d.ts.map +1 -1
  127. package/dist/JsonSchema.js +323 -4
  128. package/dist/JsonSchema.js.map +1 -1
  129. package/dist/Latch.d.ts +175 -0
  130. package/dist/Latch.d.ts.map +1 -0
  131. package/dist/Latch.js +130 -0
  132. package/dist/Latch.js.map +1 -0
  133. package/dist/Layer.d.ts +306 -129
  134. package/dist/Layer.d.ts.map +1 -1
  135. package/dist/Layer.js +92 -47
  136. package/dist/Layer.js.map +1 -1
  137. package/dist/LayerMap.d.ts +9 -8
  138. package/dist/LayerMap.d.ts.map +1 -1
  139. package/dist/LayerMap.js +3 -3
  140. package/dist/LayerMap.js.map +1 -1
  141. package/dist/LogLevel.d.ts +32 -0
  142. package/dist/LogLevel.d.ts.map +1 -1
  143. package/dist/LogLevel.js +28 -100
  144. package/dist/LogLevel.js.map +1 -1
  145. package/dist/Logger.d.ts +29 -95
  146. package/dist/Logger.d.ts.map +1 -1
  147. package/dist/Logger.js +2 -3
  148. package/dist/Logger.js.map +1 -1
  149. package/dist/ManagedRuntime.d.ts +2 -2
  150. package/dist/ManagedRuntime.js +2 -2
  151. package/dist/Metric.d.ts +4 -6
  152. package/dist/Metric.d.ts.map +1 -1
  153. package/dist/Metric.js +3 -5
  154. package/dist/Metric.js.map +1 -1
  155. package/dist/MutableHashMap.d.ts +7 -0
  156. package/dist/MutableHashMap.d.ts.map +1 -1
  157. package/dist/MutableHashMap.js +8 -0
  158. package/dist/MutableHashMap.js.map +1 -1
  159. package/dist/MutableHashSet.d.ts +7 -0
  160. package/dist/MutableHashSet.d.ts.map +1 -1
  161. package/dist/MutableHashSet.js +8 -0
  162. package/dist/MutableHashSet.js.map +1 -1
  163. package/dist/Newtype.d.ts +291 -0
  164. package/dist/Newtype.d.ts.map +1 -0
  165. package/dist/Newtype.js +161 -0
  166. package/dist/Newtype.js.map +1 -0
  167. package/dist/Number.d.ts +74 -18
  168. package/dist/Number.d.ts.map +1 -1
  169. package/dist/Number.js +34 -15
  170. package/dist/Number.js.map +1 -1
  171. package/dist/Optic.d.ts +947 -18
  172. package/dist/Optic.d.ts.map +1 -1
  173. package/dist/Optic.js +454 -5
  174. package/dist/Optic.js.map +1 -1
  175. package/dist/Option.d.ts +25 -16
  176. package/dist/Option.d.ts.map +1 -1
  177. package/dist/Option.js +15 -9
  178. package/dist/Option.js.map +1 -1
  179. package/dist/Order.d.ts +6 -1
  180. package/dist/Order.d.ts.map +1 -1
  181. package/dist/Order.js +19 -14
  182. package/dist/Order.js.map +1 -1
  183. package/dist/PartitionedSemaphore.d.ts +146 -15
  184. package/dist/PartitionedSemaphore.d.ts.map +1 -1
  185. package/dist/PartitionedSemaphore.js +174 -61
  186. package/dist/PartitionedSemaphore.js.map +1 -1
  187. package/dist/Pipeable.d.ts +17 -0
  188. package/dist/Pipeable.d.ts.map +1 -1
  189. package/dist/Pipeable.js +19 -1
  190. package/dist/Pipeable.js.map +1 -1
  191. package/dist/PlatformError.d.ts +10 -9
  192. package/dist/PlatformError.d.ts.map +1 -1
  193. package/dist/PlatformError.js +2 -2
  194. package/dist/PlatformError.js.map +1 -1
  195. package/dist/Pool.d.ts +6 -4
  196. package/dist/Pool.d.ts.map +1 -1
  197. package/dist/Pool.js +7 -5
  198. package/dist/Pool.js.map +1 -1
  199. package/dist/PubSub.d.ts +8 -6
  200. package/dist/PubSub.d.ts.map +1 -1
  201. package/dist/PubSub.js +18 -10
  202. package/dist/PubSub.js.map +1 -1
  203. package/dist/Pull.d.ts.map +1 -1
  204. package/dist/Pull.js +1 -1
  205. package/dist/Pull.js.map +1 -1
  206. package/dist/Queue.d.ts +9 -6
  207. package/dist/Queue.d.ts.map +1 -1
  208. package/dist/Queue.js +7 -5
  209. package/dist/Queue.js.map +1 -1
  210. package/dist/Random.d.ts +35 -1
  211. package/dist/Random.d.ts.map +1 -1
  212. package/dist/Random.js +46 -12
  213. package/dist/Random.js.map +1 -1
  214. package/dist/RcMap.d.ts +2 -2
  215. package/dist/RcMap.d.ts.map +1 -1
  216. package/dist/RcMap.js +1 -1
  217. package/dist/RcMap.js.map +1 -1
  218. package/dist/RcRef.d.ts +1 -1
  219. package/dist/RcRef.d.ts.map +1 -1
  220. package/dist/Record.d.ts +63 -160
  221. package/dist/Record.d.ts.map +1 -1
  222. package/dist/Record.js +37 -56
  223. package/dist/Record.js.map +1 -1
  224. package/dist/Reducer.d.ts +166 -7
  225. package/dist/Reducer.d.ts.map +1 -1
  226. package/dist/Reducer.js +135 -1
  227. package/dist/Reducer.js.map +1 -1
  228. package/dist/References.d.ts +242 -226
  229. package/dist/References.d.ts.map +1 -1
  230. package/dist/References.js +240 -247
  231. package/dist/References.js.map +1 -1
  232. package/dist/Request.d.ts +1 -1
  233. package/dist/Request.d.ts.map +1 -1
  234. package/dist/Request.js +2 -1
  235. package/dist/Request.js.map +1 -1
  236. package/dist/RequestResolver.d.ts +25 -45
  237. package/dist/RequestResolver.d.ts.map +1 -1
  238. package/dist/RequestResolver.js +10 -30
  239. package/dist/RequestResolver.js.map +1 -1
  240. package/dist/Resource.d.ts.map +1 -1
  241. package/dist/Resource.js +2 -1
  242. package/dist/Resource.js.map +1 -1
  243. package/dist/Result.d.ts +1 -1
  244. package/dist/Result.d.ts.map +1 -1
  245. package/dist/Result.js +1 -2
  246. package/dist/Result.js.map +1 -1
  247. package/dist/Runtime.d.ts +66 -0
  248. package/dist/Runtime.d.ts.map +1 -1
  249. package/dist/Runtime.js +79 -6
  250. package/dist/Runtime.js.map +1 -1
  251. package/dist/Schedule.d.ts +174 -291
  252. package/dist/Schedule.d.ts.map +1 -1
  253. package/dist/Schedule.js +160 -134
  254. package/dist/Schedule.js.map +1 -1
  255. package/dist/Scheduler.d.ts +34 -123
  256. package/dist/Scheduler.d.ts.map +1 -1
  257. package/dist/Scheduler.js +31 -123
  258. package/dist/Scheduler.js.map +1 -1
  259. package/dist/Schema.d.ts +2722 -247
  260. package/dist/Schema.d.ts.map +1 -1
  261. package/dist/Schema.js +1947 -224
  262. package/dist/Schema.js.map +1 -1
  263. package/dist/SchemaAST.d.ts +7 -2
  264. package/dist/SchemaAST.d.ts.map +1 -1
  265. package/dist/SchemaAST.js +131 -25
  266. package/dist/SchemaAST.js.map +1 -1
  267. package/dist/SchemaGetter.d.ts +5 -5
  268. package/dist/SchemaGetter.d.ts.map +1 -1
  269. package/dist/SchemaGetter.js +18 -18
  270. package/dist/SchemaGetter.js.map +1 -1
  271. package/dist/SchemaParser.d.ts +44 -54
  272. package/dist/SchemaParser.d.ts.map +1 -1
  273. package/dist/SchemaParser.js +55 -2
  274. package/dist/SchemaParser.js.map +1 -1
  275. package/dist/SchemaRepresentation.d.ts +46 -45
  276. package/dist/SchemaRepresentation.d.ts.map +1 -1
  277. package/dist/SchemaRepresentation.js +49 -24
  278. package/dist/SchemaRepresentation.js.map +1 -1
  279. package/dist/SchemaTransformation.d.ts +107 -3
  280. package/dist/SchemaTransformation.d.ts.map +1 -1
  281. package/dist/SchemaTransformation.js +173 -13
  282. package/dist/SchemaTransformation.js.map +1 -1
  283. package/dist/ScopedCache.d.ts +2 -2
  284. package/dist/ScopedCache.d.ts.map +1 -1
  285. package/dist/ScopedCache.js +1 -1
  286. package/dist/ScopedCache.js.map +1 -1
  287. package/dist/Semaphore.d.ts +307 -0
  288. package/dist/Semaphore.d.ts.map +1 -0
  289. package/dist/Semaphore.js +222 -0
  290. package/dist/Semaphore.js.map +1 -0
  291. package/dist/ServiceMap.d.ts +67 -31
  292. package/dist/ServiceMap.d.ts.map +1 -1
  293. package/dist/ServiceMap.js +39 -24
  294. package/dist/ServiceMap.js.map +1 -1
  295. package/dist/Sink.d.ts +18 -15
  296. package/dist/Sink.d.ts.map +1 -1
  297. package/dist/Sink.js +53 -6
  298. package/dist/Sink.js.map +1 -1
  299. package/dist/Stdio.d.ts +16 -4
  300. package/dist/Stdio.d.ts.map +1 -1
  301. package/dist/Stdio.js +18 -0
  302. package/dist/Stdio.js.map +1 -1
  303. package/dist/Stream.d.ts +284 -431
  304. package/dist/Stream.d.ts.map +1 -1
  305. package/dist/Stream.js +189 -88
  306. package/dist/Stream.js.map +1 -1
  307. package/dist/String.d.ts +114 -47
  308. package/dist/String.d.ts.map +1 -1
  309. package/dist/String.js +29 -47
  310. package/dist/String.js.map +1 -1
  311. package/dist/Struct.d.ts +23 -7
  312. package/dist/Struct.d.ts.map +1 -1
  313. package/dist/Struct.js +22 -0
  314. package/dist/Struct.js.map +1 -1
  315. package/dist/SubscriptionRef.d.ts +3 -3
  316. package/dist/SubscriptionRef.d.ts.map +1 -1
  317. package/dist/SubscriptionRef.js +85 -117
  318. package/dist/SubscriptionRef.js.map +1 -1
  319. package/dist/SynchronizedRef.d.ts +2 -1
  320. package/dist/SynchronizedRef.d.ts.map +1 -1
  321. package/dist/SynchronizedRef.js +2 -1
  322. package/dist/SynchronizedRef.js.map +1 -1
  323. package/dist/Terminal.d.ts +2 -1
  324. package/dist/Terminal.d.ts.map +1 -1
  325. package/dist/Terminal.js.map +1 -1
  326. package/dist/Tracer.d.ts +5 -4
  327. package/dist/Tracer.d.ts.map +1 -1
  328. package/dist/Tracer.js +2 -1
  329. package/dist/Tracer.js.map +1 -1
  330. package/dist/Trie.d.ts +44 -31
  331. package/dist/Trie.d.ts.map +1 -1
  332. package/dist/Trie.js +13 -9
  333. package/dist/Trie.js.map +1 -1
  334. package/dist/TxChunk.d.ts +37 -37
  335. package/dist/TxChunk.d.ts.map +1 -1
  336. package/dist/TxChunk.js +3 -3
  337. package/dist/TxChunk.js.map +1 -1
  338. package/dist/TxDeferred.d.ts +328 -0
  339. package/dist/TxDeferred.d.ts.map +1 -0
  340. package/dist/TxDeferred.js +197 -0
  341. package/dist/TxDeferred.js.map +1 -0
  342. package/dist/TxHashMap.d.ts +159 -140
  343. package/dist/TxHashMap.d.ts.map +1 -1
  344. package/dist/TxHashMap.js +51 -44
  345. package/dist/TxHashMap.js.map +1 -1
  346. package/dist/TxHashSet.d.ts +36 -36
  347. package/dist/TxHashSet.d.ts.map +1 -1
  348. package/dist/TxHashSet.js +16 -15
  349. package/dist/TxHashSet.js.map +1 -1
  350. package/dist/TxPriorityQueue.d.ts +609 -0
  351. package/dist/TxPriorityQueue.d.ts.map +1 -0
  352. package/dist/TxPriorityQueue.js +416 -0
  353. package/dist/TxPriorityQueue.js.map +1 -0
  354. package/dist/TxPubSub.d.ts +585 -0
  355. package/dist/TxPubSub.d.ts.map +1 -0
  356. package/dist/TxPubSub.js +521 -0
  357. package/dist/TxPubSub.js.map +1 -0
  358. package/dist/TxQueue.d.ts +32 -32
  359. package/dist/TxQueue.d.ts.map +1 -1
  360. package/dist/TxQueue.js +26 -26
  361. package/dist/TxQueue.js.map +1 -1
  362. package/dist/TxReentrantLock.d.ts +523 -0
  363. package/dist/TxReentrantLock.d.ts.map +1 -0
  364. package/dist/TxReentrantLock.js +504 -0
  365. package/dist/TxReentrantLock.js.map +1 -0
  366. package/dist/TxRef.d.ts +34 -34
  367. package/dist/TxRef.d.ts.map +1 -1
  368. package/dist/TxRef.js +21 -14
  369. package/dist/TxRef.js.map +1 -1
  370. package/dist/TxSemaphore.d.ts +170 -10
  371. package/dist/TxSemaphore.d.ts.map +1 -1
  372. package/dist/TxSemaphore.js +23 -8
  373. package/dist/TxSemaphore.js.map +1 -1
  374. package/dist/TxSubscriptionRef.d.ts +508 -0
  375. package/dist/TxSubscriptionRef.d.ts.map +1 -0
  376. package/dist/TxSubscriptionRef.js +293 -0
  377. package/dist/TxSubscriptionRef.js.map +1 -0
  378. package/dist/Types.d.ts +80 -23
  379. package/dist/Types.d.ts.map +1 -1
  380. package/dist/Utils.d.ts +137 -65
  381. package/dist/Utils.d.ts.map +1 -1
  382. package/dist/Utils.js +38 -66
  383. package/dist/Utils.js.map +1 -1
  384. package/dist/index.d.ts +804 -53
  385. package/dist/index.d.ts.map +1 -1
  386. package/dist/index.js +804 -53
  387. package/dist/index.js.map +1 -1
  388. package/dist/internal/core.js +11 -3
  389. package/dist/internal/core.js.map +1 -1
  390. package/dist/internal/dateTime.js +77 -71
  391. package/dist/internal/dateTime.js.map +1 -1
  392. package/dist/internal/effect.js +281 -201
  393. package/dist/internal/effect.js.map +1 -1
  394. package/dist/internal/hashMap.js +7 -5
  395. package/dist/internal/hashMap.js.map +1 -1
  396. package/dist/internal/option.js +6 -0
  397. package/dist/internal/option.js.map +1 -1
  398. package/dist/internal/random.d.ts +2 -0
  399. package/dist/internal/random.d.ts.map +1 -0
  400. package/dist/internal/random.js +13 -0
  401. package/dist/internal/random.js.map +1 -0
  402. package/dist/internal/rcRef.js +3 -2
  403. package/dist/internal/rcRef.js.map +1 -1
  404. package/dist/internal/references.d.ts +2 -0
  405. package/dist/internal/references.d.ts.map +1 -0
  406. package/dist/internal/references.js +51 -0
  407. package/dist/internal/references.js.map +1 -0
  408. package/dist/internal/request.js +2 -2
  409. package/dist/internal/request.js.map +1 -1
  410. package/dist/internal/schema/annotations.js +2 -0
  411. package/dist/internal/schema/annotations.js.map +1 -1
  412. package/dist/internal/schema/representation.js +47 -106
  413. package/dist/internal/schema/representation.js.map +1 -1
  414. package/dist/internal/schema/schema.js +1 -0
  415. package/dist/internal/schema/schema.js.map +1 -1
  416. package/dist/internal/schema/to-codec.js +7 -10
  417. package/dist/internal/schema/to-codec.js.map +1 -1
  418. package/dist/internal/trie.js +8 -7
  419. package/dist/internal/trie.js.map +1 -1
  420. package/dist/testing/TestClock.d.ts +8 -7
  421. package/dist/testing/TestClock.d.ts.map +1 -1
  422. package/dist/testing/TestClock.js +6 -4
  423. package/dist/testing/TestClock.js.map +1 -1
  424. package/dist/testing/TestSchema.d.ts +266 -32
  425. package/dist/testing/TestSchema.d.ts.map +1 -1
  426. package/dist/testing/TestSchema.js +296 -23
  427. package/dist/testing/TestSchema.js.map +1 -1
  428. package/dist/testing/index.d.ts +64 -1
  429. package/dist/testing/index.d.ts.map +1 -1
  430. package/dist/testing/index.js +64 -1
  431. package/dist/testing/index.js.map +1 -1
  432. package/dist/unstable/ai/AiError.d.ts +136 -54
  433. package/dist/unstable/ai/AiError.d.ts.map +1 -1
  434. package/dist/unstable/ai/AiError.js +28 -23
  435. package/dist/unstable/ai/AiError.js.map +1 -1
  436. package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
  437. package/dist/unstable/ai/AnthropicStructuredOutput.js +4 -0
  438. package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
  439. package/dist/unstable/ai/Chat.d.ts +7 -8
  440. package/dist/unstable/ai/Chat.d.ts.map +1 -1
  441. package/dist/unstable/ai/Chat.js +38 -44
  442. package/dist/unstable/ai/Chat.js.map +1 -1
  443. package/dist/unstable/ai/EmbeddingModel.d.ts +130 -0
  444. package/dist/unstable/ai/EmbeddingModel.d.ts.map +1 -0
  445. package/dist/unstable/ai/EmbeddingModel.js +127 -0
  446. package/dist/unstable/ai/EmbeddingModel.js.map +1 -0
  447. package/dist/unstable/ai/LanguageModel.d.ts +53 -45
  448. package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
  449. package/dist/unstable/ai/LanguageModel.js +265 -143
  450. package/dist/unstable/ai/LanguageModel.js.map +1 -1
  451. package/dist/unstable/ai/McpSchema.d.ts +183 -88
  452. package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
  453. package/dist/unstable/ai/McpSchema.js +57 -12
  454. package/dist/unstable/ai/McpSchema.js.map +1 -1
  455. package/dist/unstable/ai/McpServer.d.ts +66 -13
  456. package/dist/unstable/ai/McpServer.d.ts.map +1 -1
  457. package/dist/unstable/ai/McpServer.js +193 -51
  458. package/dist/unstable/ai/McpServer.js.map +1 -1
  459. package/dist/unstable/ai/Model.d.ts +25 -7
  460. package/dist/unstable/ai/Model.d.ts.map +1 -1
  461. package/dist/unstable/ai/Model.js +22 -6
  462. package/dist/unstable/ai/Model.js.map +1 -1
  463. package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
  464. package/dist/unstable/ai/OpenAiStructuredOutput.js +4 -0
  465. package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
  466. package/dist/unstable/ai/Prompt.d.ts +20 -20
  467. package/dist/unstable/ai/Prompt.d.ts.map +1 -1
  468. package/dist/unstable/ai/Response.d.ts +26 -26
  469. package/dist/unstable/ai/Response.d.ts.map +1 -1
  470. package/dist/unstable/ai/Response.js +1 -1
  471. package/dist/unstable/ai/Response.js.map +1 -1
  472. package/dist/unstable/ai/ResponseIdTracker.d.ts +38 -0
  473. package/dist/unstable/ai/ResponseIdTracker.d.ts.map +1 -0
  474. package/dist/unstable/ai/ResponseIdTracker.js +68 -0
  475. package/dist/unstable/ai/ResponseIdTracker.js.map +1 -0
  476. package/dist/unstable/ai/Tool.d.ts +34 -4
  477. package/dist/unstable/ai/Tool.d.ts.map +1 -1
  478. package/dist/unstable/ai/Tool.js +28 -10
  479. package/dist/unstable/ai/Tool.js.map +1 -1
  480. package/dist/unstable/ai/Toolkit.d.ts +1 -1
  481. package/dist/unstable/ai/Toolkit.d.ts.map +1 -1
  482. package/dist/unstable/ai/Toolkit.js +4 -11
  483. package/dist/unstable/ai/Toolkit.js.map +1 -1
  484. package/dist/unstable/ai/index.d.ts +22 -1
  485. package/dist/unstable/ai/index.d.ts.map +1 -1
  486. package/dist/unstable/ai/index.js +22 -1
  487. package/dist/unstable/ai/index.js.map +1 -1
  488. package/dist/unstable/ai/internal/codec-transformer.js +0 -5
  489. package/dist/unstable/ai/internal/codec-transformer.js.map +1 -1
  490. package/dist/unstable/cli/Argument.d.ts +2 -4
  491. package/dist/unstable/cli/Argument.d.ts.map +1 -1
  492. package/dist/unstable/cli/Argument.js +1 -3
  493. package/dist/unstable/cli/Argument.js.map +1 -1
  494. package/dist/unstable/cli/CliError.d.ts +27 -60
  495. package/dist/unstable/cli/CliError.d.ts.map +1 -1
  496. package/dist/unstable/cli/CliError.js +25 -57
  497. package/dist/unstable/cli/CliError.js.map +1 -1
  498. package/dist/unstable/cli/CliOutput.d.ts +3 -2
  499. package/dist/unstable/cli/CliOutput.d.ts.map +1 -1
  500. package/dist/unstable/cli/CliOutput.js +65 -10
  501. package/dist/unstable/cli/CliOutput.js.map +1 -1
  502. package/dist/unstable/cli/Command.d.ts +371 -58
  503. package/dist/unstable/cli/Command.d.ts.map +1 -1
  504. package/dist/unstable/cli/Command.js +328 -67
  505. package/dist/unstable/cli/Command.js.map +1 -1
  506. package/dist/unstable/cli/Completions.d.ts +16 -0
  507. package/dist/unstable/cli/Completions.d.ts.map +1 -0
  508. package/dist/unstable/cli/Completions.js +23 -0
  509. package/dist/unstable/cli/Completions.js.map +1 -0
  510. package/dist/unstable/cli/Flag.d.ts +2 -2
  511. package/dist/unstable/cli/Flag.d.ts.map +1 -1
  512. package/dist/unstable/cli/Flag.js +1 -1
  513. package/dist/unstable/cli/Flag.js.map +1 -1
  514. package/dist/unstable/cli/GlobalFlag.d.ts +125 -0
  515. package/dist/unstable/cli/GlobalFlag.d.ts.map +1 -0
  516. package/dist/unstable/cli/GlobalFlag.js +118 -0
  517. package/dist/unstable/cli/GlobalFlag.js.map +1 -0
  518. package/dist/unstable/cli/HelpDoc.d.ts +81 -11
  519. package/dist/unstable/cli/HelpDoc.d.ts.map +1 -1
  520. package/dist/unstable/cli/Param.d.ts +4 -4
  521. package/dist/unstable/cli/Param.d.ts.map +1 -1
  522. package/dist/unstable/cli/Param.js +7 -7
  523. package/dist/unstable/cli/Param.js.map +1 -1
  524. package/dist/unstable/cli/Primitive.d.ts +2 -2
  525. package/dist/unstable/cli/Primitive.d.ts.map +1 -1
  526. package/dist/unstable/cli/Primitive.js +1 -1
  527. package/dist/unstable/cli/Primitive.js.map +1 -1
  528. package/dist/unstable/cli/Prompt.js +258 -84
  529. package/dist/unstable/cli/Prompt.js.map +1 -1
  530. package/dist/unstable/cli/index.d.ts +8 -0
  531. package/dist/unstable/cli/index.d.ts.map +1 -1
  532. package/dist/unstable/cli/index.js +8 -0
  533. package/dist/unstable/cli/index.js.map +1 -1
  534. package/dist/unstable/cli/internal/command.d.ts +40 -14
  535. package/dist/unstable/cli/internal/command.d.ts.map +1 -1
  536. package/dist/unstable/cli/internal/command.js +72 -46
  537. package/dist/unstable/cli/internal/command.js.map +1 -1
  538. package/dist/unstable/cli/internal/completions/CommandDescriptor.js +16 -4
  539. package/dist/unstable/cli/internal/completions/CommandDescriptor.js.map +1 -1
  540. package/dist/unstable/cli/internal/config.js +42 -0
  541. package/dist/unstable/cli/internal/config.js.map +1 -1
  542. package/dist/unstable/cli/internal/help.d.ts +33 -0
  543. package/dist/unstable/cli/internal/help.d.ts.map +1 -0
  544. package/dist/unstable/cli/internal/help.js +125 -0
  545. package/dist/unstable/cli/internal/help.js.map +1 -0
  546. package/dist/unstable/cli/internal/parser.js +61 -43
  547. package/dist/unstable/cli/internal/parser.js.map +1 -1
  548. package/dist/unstable/cluster/ClusterCron.d.ts +1 -1
  549. package/dist/unstable/cluster/ClusterCron.d.ts.map +1 -1
  550. package/dist/unstable/cluster/ClusterCron.js +1 -1
  551. package/dist/unstable/cluster/ClusterCron.js.map +1 -1
  552. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts +3 -2
  553. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
  554. package/dist/unstable/cluster/ClusterWorkflowEngine.js +29 -26
  555. package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
  556. package/dist/unstable/cluster/DeliverAt.js +1 -1
  557. package/dist/unstable/cluster/DeliverAt.js.map +1 -1
  558. package/dist/unstable/cluster/Entity.d.ts +10 -8
  559. package/dist/unstable/cluster/Entity.d.ts.map +1 -1
  560. package/dist/unstable/cluster/Entity.js +7 -7
  561. package/dist/unstable/cluster/Entity.js.map +1 -1
  562. package/dist/unstable/cluster/EntityAddress.d.ts.map +1 -1
  563. package/dist/unstable/cluster/EntityAddress.js +1 -1
  564. package/dist/unstable/cluster/EntityAddress.js.map +1 -1
  565. package/dist/unstable/cluster/EntityResource.d.ts +2 -2
  566. package/dist/unstable/cluster/EntityResource.d.ts.map +1 -1
  567. package/dist/unstable/cluster/Envelope.d.ts +1 -1
  568. package/dist/unstable/cluster/K8sHttpClient.d.ts +1 -1
  569. package/dist/unstable/cluster/K8sHttpClient.js +4 -4
  570. package/dist/unstable/cluster/K8sHttpClient.js.map +1 -1
  571. package/dist/unstable/cluster/Message.d.ts +14 -13
  572. package/dist/unstable/cluster/Message.d.ts.map +1 -1
  573. package/dist/unstable/cluster/Message.js +3 -2
  574. package/dist/unstable/cluster/Message.js.map +1 -1
  575. package/dist/unstable/cluster/MessageStorage.d.ts +10 -10
  576. package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
  577. package/dist/unstable/cluster/MessageStorage.js +14 -13
  578. package/dist/unstable/cluster/MessageStorage.js.map +1 -1
  579. package/dist/unstable/cluster/Reply.d.ts +8 -7
  580. package/dist/unstable/cluster/Reply.d.ts.map +1 -1
  581. package/dist/unstable/cluster/Reply.js +4 -3
  582. package/dist/unstable/cluster/Reply.js.map +1 -1
  583. package/dist/unstable/cluster/Runner.d.ts +1 -1
  584. package/dist/unstable/cluster/Runner.d.ts.map +1 -1
  585. package/dist/unstable/cluster/Runner.js +1 -1
  586. package/dist/unstable/cluster/Runner.js.map +1 -1
  587. package/dist/unstable/cluster/RunnerAddress.d.ts.map +1 -1
  588. package/dist/unstable/cluster/RunnerAddress.js +1 -1
  589. package/dist/unstable/cluster/RunnerAddress.js.map +1 -1
  590. package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
  591. package/dist/unstable/cluster/RunnerServer.js +9 -8
  592. package/dist/unstable/cluster/RunnerServer.js.map +1 -1
  593. package/dist/unstable/cluster/Runners.d.ts +2 -1
  594. package/dist/unstable/cluster/Runners.d.ts.map +1 -1
  595. package/dist/unstable/cluster/Runners.js +11 -9
  596. package/dist/unstable/cluster/Runners.js.map +1 -1
  597. package/dist/unstable/cluster/ShardId.js +3 -3
  598. package/dist/unstable/cluster/ShardId.js.map +1 -1
  599. package/dist/unstable/cluster/Sharding.d.ts +2 -2
  600. package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
  601. package/dist/unstable/cluster/Sharding.js +28 -20
  602. package/dist/unstable/cluster/Sharding.js.map +1 -1
  603. package/dist/unstable/cluster/ShardingConfig.d.ts +26 -25
  604. package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
  605. package/dist/unstable/cluster/ShardingConfig.js +24 -24
  606. package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
  607. package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
  608. package/dist/unstable/cluster/SqlMessageStorage.js +19 -18
  609. package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
  610. package/dist/unstable/cluster/SqlRunnerStorage.js +1 -1
  611. package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
  612. package/dist/unstable/cluster/internal/entityManager.js +14 -14
  613. package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
  614. package/dist/unstable/cluster/internal/entityReaper.js +2 -1
  615. package/dist/unstable/cluster/internal/entityReaper.js.map +1 -1
  616. package/dist/unstable/cluster/internal/resourceRef.js +2 -1
  617. package/dist/unstable/cluster/internal/resourceRef.js.map +1 -1
  618. package/dist/unstable/devtools/DevToolsClient.d.ts.map +1 -1
  619. package/dist/unstable/devtools/DevToolsClient.js +4 -3
  620. package/dist/unstable/devtools/DevToolsClient.js.map +1 -1
  621. package/dist/unstable/devtools/DevToolsSchema.d.ts +40 -40
  622. package/dist/unstable/devtools/DevToolsSchema.d.ts.map +1 -1
  623. package/dist/unstable/devtools/DevToolsSchema.js +9 -2
  624. package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
  625. package/dist/unstable/encoding/Msgpack.d.ts +1 -1
  626. package/dist/unstable/encoding/Ndjson.d.ts +9 -9
  627. package/dist/unstable/encoding/Ndjson.d.ts.map +1 -1
  628. package/dist/unstable/encoding/Ndjson.js.map +1 -1
  629. package/dist/unstable/encoding/Sse.d.ts +4 -4
  630. package/dist/unstable/encoding/Sse.d.ts.map +1 -1
  631. package/dist/unstable/encoding/Sse.js +1 -1
  632. package/dist/unstable/encoding/Sse.js.map +1 -1
  633. package/dist/unstable/eventlog/EventJournal.d.ts +2 -2
  634. package/dist/unstable/eventlog/EventJournal.js +2 -2
  635. package/dist/unstable/eventlog/EventJournal.js.map +1 -1
  636. package/dist/unstable/eventlog/EventLog.d.ts.map +1 -1
  637. package/dist/unstable/eventlog/EventLog.js +3 -2
  638. package/dist/unstable/eventlog/EventLog.js.map +1 -1
  639. package/dist/unstable/eventlog/EventLogRemote.d.ts +6 -6
  640. package/dist/unstable/eventlog/SqlEventLogJournal.js +2 -2
  641. package/dist/unstable/eventlog/SqlEventLogJournal.js.map +1 -1
  642. package/dist/unstable/http/Cookies.d.ts +52 -7
  643. package/dist/unstable/http/Cookies.d.ts.map +1 -1
  644. package/dist/unstable/http/Cookies.js +27 -6
  645. package/dist/unstable/http/Cookies.js.map +1 -1
  646. package/dist/unstable/http/Etag.d.ts.map +1 -1
  647. package/dist/unstable/http/Etag.js +5 -1
  648. package/dist/unstable/http/Etag.js.map +1 -1
  649. package/dist/unstable/http/Headers.d.ts +19 -2
  650. package/dist/unstable/http/Headers.d.ts.map +1 -1
  651. package/dist/unstable/http/Headers.js +40 -11
  652. package/dist/unstable/http/Headers.js.map +1 -1
  653. package/dist/unstable/http/HttpBody.d.ts +1 -1
  654. package/dist/unstable/http/HttpClient.d.ts +117 -15
  655. package/dist/unstable/http/HttpClient.d.ts.map +1 -1
  656. package/dist/unstable/http/HttpClient.js +191 -13
  657. package/dist/unstable/http/HttpClient.js.map +1 -1
  658. package/dist/unstable/http/HttpClientError.d.ts +7 -7
  659. package/dist/unstable/http/HttpClientRequest.d.ts +43 -15
  660. package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
  661. package/dist/unstable/http/HttpClientRequest.js +131 -21
  662. package/dist/unstable/http/HttpClientRequest.js.map +1 -1
  663. package/dist/unstable/http/HttpClientResponse.d.ts +2 -1
  664. package/dist/unstable/http/HttpClientResponse.d.ts.map +1 -1
  665. package/dist/unstable/http/HttpClientResponse.js +6 -1
  666. package/dist/unstable/http/HttpClientResponse.js.map +1 -1
  667. package/dist/unstable/http/HttpEffect.d.ts +7 -5
  668. package/dist/unstable/http/HttpEffect.d.ts.map +1 -1
  669. package/dist/unstable/http/HttpEffect.js +46 -54
  670. package/dist/unstable/http/HttpEffect.js.map +1 -1
  671. package/dist/unstable/http/HttpIncomingMessage.d.ts +3 -2
  672. package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
  673. package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
  674. package/dist/unstable/http/HttpMethod.d.ts +4 -4
  675. package/dist/unstable/http/HttpMethod.d.ts.map +1 -1
  676. package/dist/unstable/http/HttpMethod.js +3 -3
  677. package/dist/unstable/http/HttpMethod.js.map +1 -1
  678. package/dist/unstable/http/HttpMiddleware.d.ts +1 -6
  679. package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
  680. package/dist/unstable/http/HttpMiddleware.js +24 -32
  681. package/dist/unstable/http/HttpMiddleware.js.map +1 -1
  682. package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
  683. package/dist/unstable/http/HttpPlatform.js +3 -2
  684. package/dist/unstable/http/HttpPlatform.js.map +1 -1
  685. package/dist/unstable/http/HttpRouter.d.ts +2 -1
  686. package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
  687. package/dist/unstable/http/HttpRouter.js +7 -7
  688. package/dist/unstable/http/HttpRouter.js.map +1 -1
  689. package/dist/unstable/http/HttpServer.d.ts.map +1 -1
  690. package/dist/unstable/http/HttpServer.js +2 -2
  691. package/dist/unstable/http/HttpServer.js.map +1 -1
  692. package/dist/unstable/http/HttpServerError.d.ts +22 -34
  693. package/dist/unstable/http/HttpServerError.d.ts.map +1 -1
  694. package/dist/unstable/http/HttpServerError.js +39 -45
  695. package/dist/unstable/http/HttpServerError.js.map +1 -1
  696. package/dist/unstable/http/HttpServerRequest.d.ts +15 -3
  697. package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
  698. package/dist/unstable/http/HttpServerRequest.js +301 -7
  699. package/dist/unstable/http/HttpServerRequest.js.map +1 -1
  700. package/dist/unstable/http/HttpServerRespondable.d.ts +2 -2
  701. package/dist/unstable/http/HttpServerRespondable.d.ts.map +1 -1
  702. package/dist/unstable/http/HttpServerRespondable.js +5 -5
  703. package/dist/unstable/http/HttpServerRespondable.js.map +1 -1
  704. package/dist/unstable/http/HttpServerResponse.d.ts +50 -3
  705. package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
  706. package/dist/unstable/http/HttpServerResponse.js +236 -1
  707. package/dist/unstable/http/HttpServerResponse.js.map +1 -1
  708. package/dist/unstable/http/HttpStaticServer.d.ts +69 -0
  709. package/dist/unstable/http/HttpStaticServer.d.ts.map +1 -0
  710. package/dist/unstable/http/HttpStaticServer.js +353 -0
  711. package/dist/unstable/http/HttpStaticServer.js.map +1 -0
  712. package/dist/unstable/http/HttpTraceContext.d.ts +3 -2
  713. package/dist/unstable/http/HttpTraceContext.d.ts.map +1 -1
  714. package/dist/unstable/http/HttpTraceContext.js +27 -15
  715. package/dist/unstable/http/HttpTraceContext.js.map +1 -1
  716. package/dist/unstable/http/Multipart.d.ts +3 -3
  717. package/dist/unstable/http/Url.d.ts +604 -0
  718. package/dist/unstable/http/Url.d.ts.map +1 -0
  719. package/dist/unstable/http/Url.js +256 -0
  720. package/dist/unstable/http/Url.js.map +1 -0
  721. package/dist/unstable/http/UrlParams.d.ts +19 -10
  722. package/dist/unstable/http/UrlParams.d.ts.map +1 -1
  723. package/dist/unstable/http/UrlParams.js +6 -7
  724. package/dist/unstable/http/UrlParams.js.map +1 -1
  725. package/dist/unstable/http/index.d.ts +8 -0
  726. package/dist/unstable/http/index.d.ts.map +1 -1
  727. package/dist/unstable/http/index.js +8 -0
  728. package/dist/unstable/http/index.js.map +1 -1
  729. package/dist/unstable/http/internal/preResponseHandler.d.ts +2 -0
  730. package/dist/unstable/http/internal/preResponseHandler.d.ts.map +1 -0
  731. package/dist/unstable/http/internal/preResponseHandler.js +10 -0
  732. package/dist/unstable/http/internal/preResponseHandler.js.map +1 -0
  733. package/dist/unstable/httpapi/HttpApi.d.ts +4 -4
  734. package/dist/unstable/httpapi/HttpApi.d.ts.map +1 -1
  735. package/dist/unstable/httpapi/HttpApi.js.map +1 -1
  736. package/dist/unstable/httpapi/HttpApiBuilder.d.ts +11 -5
  737. package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
  738. package/dist/unstable/httpapi/HttpApiBuilder.js +40 -27
  739. package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
  740. package/dist/unstable/httpapi/HttpApiClient.d.ts +83 -7
  741. package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
  742. package/dist/unstable/httpapi/HttpApiClient.js +78 -10
  743. package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
  744. package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +207 -101
  745. package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
  746. package/dist/unstable/httpapi/HttpApiEndpoint.js +49 -43
  747. package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
  748. package/dist/unstable/httpapi/HttpApiError.d.ts +31 -14
  749. package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
  750. package/dist/unstable/httpapi/HttpApiError.js +125 -32
  751. package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
  752. package/dist/unstable/httpapi/HttpApiGroup.d.ts +4 -3
  753. package/dist/unstable/httpapi/HttpApiGroup.d.ts.map +1 -1
  754. package/dist/unstable/httpapi/HttpApiGroup.js.map +1 -1
  755. package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +46 -15
  756. package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
  757. package/dist/unstable/httpapi/HttpApiMiddleware.js +32 -3
  758. package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
  759. package/dist/unstable/httpapi/HttpApiScalar.d.ts +6 -0
  760. package/dist/unstable/httpapi/HttpApiScalar.d.ts.map +1 -1
  761. package/dist/unstable/httpapi/HttpApiScalar.js.map +1 -1
  762. package/dist/unstable/httpapi/HttpApiSchema.d.ts +5 -0
  763. package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
  764. package/dist/unstable/httpapi/HttpApiSchema.js +20 -2
  765. package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
  766. package/dist/unstable/httpapi/HttpApiSecurity.d.ts +2 -2
  767. package/dist/unstable/httpapi/HttpApiSecurity.d.ts.map +1 -1
  768. package/dist/unstable/httpapi/HttpApiSecurity.js.map +1 -1
  769. package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
  770. package/dist/unstable/httpapi/OpenApi.js +34 -26
  771. package/dist/unstable/httpapi/OpenApi.js.map +1 -1
  772. package/dist/unstable/observability/Otlp.d.ts +12 -12
  773. package/dist/unstable/observability/Otlp.d.ts.map +1 -1
  774. package/dist/unstable/observability/OtlpExporter.d.ts +2 -2
  775. package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
  776. package/dist/unstable/observability/OtlpExporter.js +3 -3
  777. package/dist/unstable/observability/OtlpExporter.js.map +1 -1
  778. package/dist/unstable/observability/OtlpLogger.d.ts +4 -4
  779. package/dist/unstable/observability/OtlpLogger.d.ts.map +1 -1
  780. package/dist/unstable/observability/OtlpLogger.js +7 -4
  781. package/dist/unstable/observability/OtlpLogger.js.map +1 -1
  782. package/dist/unstable/observability/OtlpMetrics.d.ts +4 -4
  783. package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
  784. package/dist/unstable/observability/OtlpTracer.d.ts +4 -4
  785. package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
  786. package/dist/unstable/observability/OtlpTracer.js +7 -3
  787. package/dist/unstable/observability/OtlpTracer.js.map +1 -1
  788. package/dist/unstable/persistence/KeyValueStore.d.ts +1 -1
  789. package/dist/unstable/persistence/KeyValueStore.js +6 -6
  790. package/dist/unstable/persistence/KeyValueStore.js.map +1 -1
  791. package/dist/unstable/persistence/Persistable.d.ts +2 -2
  792. package/dist/unstable/persistence/Persistable.d.ts.map +1 -1
  793. package/dist/unstable/persistence/Persistable.js +1 -1
  794. package/dist/unstable/persistence/Persistable.js.map +1 -1
  795. package/dist/unstable/persistence/PersistedCache.d.ts +6 -5
  796. package/dist/unstable/persistence/PersistedCache.d.ts.map +1 -1
  797. package/dist/unstable/persistence/PersistedCache.js +2 -1
  798. package/dist/unstable/persistence/PersistedCache.js.map +1 -1
  799. package/dist/unstable/persistence/PersistedQueue.d.ts +12 -12
  800. package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
  801. package/dist/unstable/persistence/PersistedQueue.js +12 -11
  802. package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
  803. package/dist/unstable/persistence/Persistence.d.ts +1 -1
  804. package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
  805. package/dist/unstable/persistence/Persistence.js +2 -2
  806. package/dist/unstable/persistence/Persistence.js.map +1 -1
  807. package/dist/unstable/persistence/RateLimiter.d.ts +3 -3
  808. package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
  809. package/dist/unstable/persistence/RateLimiter.js +1 -1
  810. package/dist/unstable/persistence/RateLimiter.js.map +1 -1
  811. package/dist/unstable/process/ChildProcess.d.ts +5 -128
  812. package/dist/unstable/process/ChildProcess.d.ts.map +1 -1
  813. package/dist/unstable/process/ChildProcess.js +1 -65
  814. package/dist/unstable/process/ChildProcess.js.map +1 -1
  815. package/dist/unstable/process/ChildProcessSpawner.d.ts +45 -7
  816. package/dist/unstable/process/ChildProcessSpawner.d.ts.map +1 -1
  817. package/dist/unstable/process/ChildProcessSpawner.js +21 -1
  818. package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
  819. package/dist/unstable/reactivity/Atom.d.ts +73 -12
  820. package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
  821. package/dist/unstable/reactivity/Atom.js +108 -25
  822. package/dist/unstable/reactivity/Atom.js.map +1 -1
  823. package/dist/unstable/reactivity/AtomHttpApi.d.ts +17 -15
  824. package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
  825. package/dist/unstable/reactivity/AtomHttpApi.js +45 -15
  826. package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
  827. package/dist/unstable/reactivity/AtomRegistry.d.ts +6 -0
  828. package/dist/unstable/reactivity/AtomRegistry.d.ts.map +1 -1
  829. package/dist/unstable/reactivity/AtomRegistry.js +54 -11
  830. package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
  831. package/dist/unstable/reactivity/AtomRpc.d.ts +9 -9
  832. package/dist/unstable/reactivity/AtomRpc.d.ts.map +1 -1
  833. package/dist/unstable/reactivity/AtomRpc.js +47 -21
  834. package/dist/unstable/reactivity/AtomRpc.js.map +1 -1
  835. package/dist/unstable/reactivity/Hydration.d.ts +39 -0
  836. package/dist/unstable/reactivity/Hydration.d.ts.map +1 -0
  837. package/dist/unstable/reactivity/Hydration.js +76 -0
  838. package/dist/unstable/reactivity/Hydration.js.map +1 -0
  839. package/dist/unstable/reactivity/index.d.ts +4 -0
  840. package/dist/unstable/reactivity/index.d.ts.map +1 -1
  841. package/dist/unstable/reactivity/index.js +4 -0
  842. package/dist/unstable/reactivity/index.js.map +1 -1
  843. package/dist/unstable/rpc/Rpc.d.ts +5 -5
  844. package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
  845. package/dist/unstable/rpc/Rpc.js +4 -3
  846. package/dist/unstable/rpc/Rpc.js.map +1 -1
  847. package/dist/unstable/rpc/RpcClient.d.ts +5 -26
  848. package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
  849. package/dist/unstable/rpc/RpcClient.js +10 -17
  850. package/dist/unstable/rpc/RpcClient.js.map +1 -1
  851. package/dist/unstable/rpc/RpcGroup.d.ts +3 -5
  852. package/dist/unstable/rpc/RpcGroup.d.ts.map +1 -1
  853. package/dist/unstable/rpc/RpcGroup.js.map +1 -1
  854. package/dist/unstable/rpc/RpcMiddleware.d.ts +8 -8
  855. package/dist/unstable/rpc/RpcMiddleware.d.ts.map +1 -1
  856. package/dist/unstable/rpc/RpcMiddleware.js.map +1 -1
  857. package/dist/unstable/rpc/RpcSchema.d.ts +13 -0
  858. package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
  859. package/dist/unstable/rpc/RpcSchema.js +17 -2
  860. package/dist/unstable/rpc/RpcSchema.js.map +1 -1
  861. package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
  862. package/dist/unstable/rpc/RpcSerialization.js +39 -11
  863. package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
  864. package/dist/unstable/rpc/RpcServer.d.ts +6 -10
  865. package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
  866. package/dist/unstable/rpc/RpcServer.js +20 -19
  867. package/dist/unstable/rpc/RpcServer.js.map +1 -1
  868. package/dist/unstable/rpc/Utils.d.ts.map +1 -1
  869. package/dist/unstable/rpc/Utils.js +3 -2
  870. package/dist/unstable/rpc/Utils.js.map +1 -1
  871. package/dist/unstable/schema/Model.d.ts +22 -1
  872. package/dist/unstable/schema/Model.d.ts.map +1 -1
  873. package/dist/unstable/schema/Model.js +15 -0
  874. package/dist/unstable/schema/Model.js.map +1 -1
  875. package/dist/unstable/schema/VariantSchema.d.ts +6 -6
  876. package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
  877. package/dist/unstable/schema/VariantSchema.js +6 -6
  878. package/dist/unstable/schema/VariantSchema.js.map +1 -1
  879. package/dist/unstable/socket/Socket.d.ts +6 -5
  880. package/dist/unstable/socket/Socket.d.ts.map +1 -1
  881. package/dist/unstable/socket/Socket.js +12 -9
  882. package/dist/unstable/socket/Socket.js.map +1 -1
  883. package/dist/unstable/socket/SocketServer.d.ts +3 -3
  884. package/dist/unstable/sql/Migrator.d.ts +1 -1
  885. package/dist/unstable/sql/Migrator.d.ts.map +1 -1
  886. package/dist/unstable/sql/Migrator.js +2 -2
  887. package/dist/unstable/sql/Migrator.js.map +1 -1
  888. package/dist/unstable/sql/SqlClient.d.ts +1 -1
  889. package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
  890. package/dist/unstable/sql/SqlClient.js +1 -1
  891. package/dist/unstable/sql/SqlClient.js.map +1 -1
  892. package/dist/unstable/sql/SqlError.d.ts +237 -17
  893. package/dist/unstable/sql/SqlError.d.ts.map +1 -1
  894. package/dist/unstable/sql/SqlError.js +260 -4
  895. package/dist/unstable/sql/SqlError.js.map +1 -1
  896. package/dist/unstable/sql/SqlModel.d.ts +2 -2
  897. package/dist/unstable/sql/SqlModel.d.ts.map +1 -1
  898. package/dist/unstable/sql/SqlModel.js +3 -3
  899. package/dist/unstable/sql/SqlModel.js.map +1 -1
  900. package/dist/unstable/sql/SqlResolver.d.ts.map +1 -1
  901. package/dist/unstable/sql/SqlResolver.js +17 -8
  902. package/dist/unstable/sql/SqlResolver.js.map +1 -1
  903. package/dist/unstable/sql/SqlSchema.d.ts +17 -6
  904. package/dist/unstable/sql/SqlSchema.d.ts.map +1 -1
  905. package/dist/unstable/sql/SqlSchema.js +17 -7
  906. package/dist/unstable/sql/SqlSchema.js.map +1 -1
  907. package/dist/unstable/sql/Statement.js +0 -1
  908. package/dist/unstable/sql/Statement.js.map +1 -1
  909. package/dist/unstable/workers/Worker.d.ts.map +1 -1
  910. package/dist/unstable/workers/Worker.js +2 -1
  911. package/dist/unstable/workers/Worker.js.map +1 -1
  912. package/dist/unstable/workflow/DurableClock.d.ts +3 -3
  913. package/dist/unstable/workflow/DurableClock.d.ts.map +1 -1
  914. package/dist/unstable/workflow/DurableClock.js +3 -3
  915. package/dist/unstable/workflow/DurableClock.js.map +1 -1
  916. package/dist/unstable/workflow/DurableDeferred.js +8 -8
  917. package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
  918. package/dist/unstable/workflow/Workflow.d.ts +5 -4
  919. package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
  920. package/dist/unstable/workflow/Workflow.js +1 -1
  921. package/dist/unstable/workflow/Workflow.js.map +1 -1
  922. package/dist/unstable/workflow/WorkflowEngine.d.ts +17 -5
  923. package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
  924. package/dist/unstable/workflow/WorkflowEngine.js +153 -12
  925. package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
  926. package/package.json +2 -2
  927. package/src/Array.ts +304 -447
  928. package/src/BigDecimal.ts +63 -66
  929. package/src/BigInt.ts +49 -41
  930. package/src/Brand.ts +1 -1
  931. package/src/Cache.ts +9 -8
  932. package/src/Cause.ts +37 -2
  933. package/src/Channel.ts +582 -154
  934. package/src/Chunk.ts +149 -331
  935. package/src/Combiner.ts +280 -13
  936. package/src/Config.ts +195 -25
  937. package/src/Cron.ts +155 -63
  938. package/src/Data.ts +539 -376
  939. package/src/DateTime.ts +75 -256
  940. package/src/Deferred.ts +8 -6
  941. package/src/Duration.ts +122 -66
  942. package/src/Effect.ts +1483 -1157
  943. package/src/Encoding.ts +879 -0
  944. package/src/Equal.ts +278 -111
  945. package/src/Equivalence.ts +114 -52
  946. package/src/ErrorReporter.ts +458 -0
  947. package/src/Exit.ts +24 -12
  948. package/src/Fiber.ts +12 -3
  949. package/src/FiberHandle.ts +10 -9
  950. package/src/FiberMap.ts +22 -22
  951. package/src/FileSystem.ts +34 -31
  952. package/src/Filter.ts +52 -63
  953. package/src/Formatter.ts +253 -51
  954. package/src/Function.ts +2 -10
  955. package/src/Graph.ts +131 -117
  956. package/src/HashMap.ts +26 -19
  957. package/src/Iterable.ts +117 -63
  958. package/src/JsonSchema.ts +383 -10
  959. package/src/Latch.ts +194 -0
  960. package/src/Layer.ts +393 -159
  961. package/src/LayerMap.ts +11 -9
  962. package/src/LogLevel.ts +37 -0
  963. package/src/Logger.ts +33 -100
  964. package/src/ManagedRuntime.ts +2 -2
  965. package/src/Metric.ts +6 -8
  966. package/src/MutableHashMap.ts +9 -0
  967. package/src/MutableHashSet.ts +9 -0
  968. package/src/Newtype.ts +308 -0
  969. package/src/Number.ts +85 -26
  970. package/src/Optic.ts +948 -19
  971. package/src/Option.ts +34 -24
  972. package/src/Order.ts +39 -32
  973. package/src/PartitionedSemaphore.ts +288 -56
  974. package/src/Pipeable.ts +32 -1
  975. package/src/PlatformError.ts +5 -5
  976. package/src/Pool.ts +13 -11
  977. package/src/PubSub.ts +30 -20
  978. package/src/Pull.ts +1 -1
  979. package/src/Queue.ts +11 -9
  980. package/src/Random.ts +51 -14
  981. package/src/RcMap.ts +5 -5
  982. package/src/RcRef.ts +1 -1
  983. package/src/Record.ts +94 -199
  984. package/src/Reducer.ts +166 -7
  985. package/src/References.ts +283 -287
  986. package/src/Request.ts +3 -2
  987. package/src/RequestResolver.ts +29 -49
  988. package/src/Resource.ts +2 -1
  989. package/src/Result.ts +2 -4
  990. package/src/Runtime.ts +102 -6
  991. package/src/Schedule.ts +458 -449
  992. package/src/Scheduler.ts +49 -126
  993. package/src/Schema.ts +3298 -392
  994. package/src/SchemaAST.ts +172 -33
  995. package/src/SchemaGetter.ts +19 -21
  996. package/src/SchemaParser.ts +92 -27
  997. package/src/SchemaRepresentation.ts +51 -26
  998. package/src/SchemaTransformation.ts +198 -13
  999. package/src/ScopedCache.ts +3 -3
  1000. package/src/Semaphore.ts +444 -0
  1001. package/src/ServiceMap.ts +133 -71
  1002. package/src/Sink.ts +83 -28
  1003. package/src/Stdio.ts +27 -4
  1004. package/src/Stream.ts +687 -617
  1005. package/src/String.ts +122 -69
  1006. package/src/Struct.ts +33 -7
  1007. package/src/SubscriptionRef.ts +101 -120
  1008. package/src/SynchronizedRef.ts +3 -2
  1009. package/src/Terminal.ts +2 -1
  1010. package/src/Tracer.ts +6 -5
  1011. package/src/Trie.ts +44 -31
  1012. package/src/TxChunk.ts +72 -53
  1013. package/src/TxDeferred.ts +394 -0
  1014. package/src/TxHashMap.ts +409 -343
  1015. package/src/TxHashSet.ts +113 -118
  1016. package/src/TxPriorityQueue.ts +766 -0
  1017. package/src/TxPubSub.ts +789 -0
  1018. package/src/TxQueue.ts +241 -251
  1019. package/src/TxReentrantLock.ts +753 -0
  1020. package/src/TxRef.ts +50 -38
  1021. package/src/TxSemaphore.ts +217 -44
  1022. package/src/TxSubscriptionRef.ts +639 -0
  1023. package/src/Types.ts +73 -19
  1024. package/src/Utils.ts +137 -111
  1025. package/src/index.ts +814 -54
  1026. package/src/internal/core.ts +12 -5
  1027. package/src/internal/dateTime.ts +91 -96
  1028. package/src/internal/effect.ts +841 -432
  1029. package/src/internal/hashMap.ts +12 -10
  1030. package/src/internal/option.ts +7 -0
  1031. package/src/internal/random.ts +20 -0
  1032. package/src/internal/rcRef.ts +4 -3
  1033. package/src/internal/references.ts +72 -0
  1034. package/src/internal/request.ts +2 -2
  1035. package/src/internal/schema/annotations.ts +2 -0
  1036. package/src/internal/schema/representation.ts +45 -94
  1037. package/src/internal/schema/schema.ts +1 -0
  1038. package/src/internal/schema/to-codec.ts +7 -17
  1039. package/src/internal/trie.ts +21 -15
  1040. package/src/testing/TestClock.ts +13 -11
  1041. package/src/testing/TestSchema.ts +332 -35
  1042. package/src/testing/index.ts +64 -1
  1043. package/src/unstable/ai/AiError.ts +111 -54
  1044. package/src/unstable/ai/AnthropicStructuredOutput.ts +4 -0
  1045. package/src/unstable/ai/Chat.ts +62 -74
  1046. package/src/unstable/ai/EmbeddingModel.ts +209 -0
  1047. package/src/unstable/ai/LanguageModel.ts +544 -230
  1048. package/src/unstable/ai/McpSchema.ts +73 -13
  1049. package/src/unstable/ai/McpServer.ts +271 -61
  1050. package/src/unstable/ai/Model.ts +40 -9
  1051. package/src/unstable/ai/OpenAiStructuredOutput.ts +4 -0
  1052. package/src/unstable/ai/Prompt.ts +37 -37
  1053. package/src/unstable/ai/Response.ts +25 -25
  1054. package/src/unstable/ai/ResponseIdTracker.ts +97 -0
  1055. package/src/unstable/ai/Tool.ts +42 -16
  1056. package/src/unstable/ai/Toolkit.ts +5 -14
  1057. package/src/unstable/ai/index.ts +24 -1
  1058. package/src/unstable/ai/internal/codec-transformer.ts +0 -7
  1059. package/src/unstable/cli/Argument.ts +2 -4
  1060. package/src/unstable/cli/CliError.ts +47 -59
  1061. package/src/unstable/cli/CliOutput.ts +85 -13
  1062. package/src/unstable/cli/Command.ts +801 -192
  1063. package/src/unstable/cli/Completions.ts +36 -0
  1064. package/src/unstable/cli/Flag.ts +2 -2
  1065. package/src/unstable/cli/GlobalFlag.ts +242 -0
  1066. package/src/unstable/cli/HelpDoc.ts +91 -11
  1067. package/src/unstable/cli/Param.ts +15 -11
  1068. package/src/unstable/cli/Primitive.ts +2 -2
  1069. package/src/unstable/cli/Prompt.ts +262 -100
  1070. package/src/unstable/cli/index.ts +10 -0
  1071. package/src/unstable/cli/internal/command.ts +109 -63
  1072. package/src/unstable/cli/internal/completions/CommandDescriptor.ts +10 -4
  1073. package/src/unstable/cli/internal/config.ts +49 -0
  1074. package/src/unstable/cli/internal/help.ts +171 -0
  1075. package/src/unstable/cli/internal/parser.ts +71 -63
  1076. package/src/unstable/cluster/ClusterCron.ts +2 -2
  1077. package/src/unstable/cluster/ClusterWorkflowEngine.ts +40 -34
  1078. package/src/unstable/cluster/DeliverAt.ts +1 -1
  1079. package/src/unstable/cluster/Entity.ts +24 -22
  1080. package/src/unstable/cluster/EntityAddress.ts +1 -1
  1081. package/src/unstable/cluster/EntityResource.ts +4 -4
  1082. package/src/unstable/cluster/Envelope.ts +1 -1
  1083. package/src/unstable/cluster/K8sHttpClient.ts +5 -5
  1084. package/src/unstable/cluster/Message.ts +6 -5
  1085. package/src/unstable/cluster/MessageStorage.ts +29 -30
  1086. package/src/unstable/cluster/Reply.ts +7 -4
  1087. package/src/unstable/cluster/Runner.ts +1 -1
  1088. package/src/unstable/cluster/RunnerAddress.ts +1 -1
  1089. package/src/unstable/cluster/RunnerServer.ts +10 -13
  1090. package/src/unstable/cluster/Runners.ts +14 -12
  1091. package/src/unstable/cluster/ShardId.ts +2 -2
  1092. package/src/unstable/cluster/Sharding.ts +36 -27
  1093. package/src/unstable/cluster/ShardingConfig.ts +36 -37
  1094. package/src/unstable/cluster/SqlMessageStorage.ts +21 -18
  1095. package/src/unstable/cluster/SqlRunnerStorage.ts +1 -1
  1096. package/src/unstable/cluster/internal/entityManager.ts +36 -29
  1097. package/src/unstable/cluster/internal/entityReaper.ts +2 -1
  1098. package/src/unstable/cluster/internal/resourceRef.ts +2 -1
  1099. package/src/unstable/devtools/DevToolsClient.ts +23 -18
  1100. package/src/unstable/devtools/DevToolsSchema.ts +16 -3
  1101. package/src/unstable/encoding/Ndjson.ts +17 -17
  1102. package/src/unstable/encoding/Sse.ts +3 -5
  1103. package/src/unstable/eventlog/EventJournal.ts +2 -2
  1104. package/src/unstable/eventlog/EventLog.ts +3 -2
  1105. package/src/unstable/eventlog/SqlEventLogJournal.ts +2 -2
  1106. package/src/unstable/http/Cookies.ts +94 -11
  1107. package/src/unstable/http/Etag.ts +5 -3
  1108. package/src/unstable/http/Headers.ts +68 -18
  1109. package/src/unstable/http/HttpClient.ts +376 -34
  1110. package/src/unstable/http/HttpClientRequest.ts +151 -39
  1111. package/src/unstable/http/HttpClientResponse.ts +12 -6
  1112. package/src/unstable/http/HttpEffect.ts +54 -68
  1113. package/src/unstable/http/HttpIncomingMessage.ts +3 -2
  1114. package/src/unstable/http/HttpMethod.ts +16 -4
  1115. package/src/unstable/http/HttpMiddleware.ts +25 -39
  1116. package/src/unstable/http/HttpPlatform.ts +3 -2
  1117. package/src/unstable/http/HttpRouter.ts +9 -9
  1118. package/src/unstable/http/HttpServer.ts +3 -9
  1119. package/src/unstable/http/HttpServerError.ts +45 -47
  1120. package/src/unstable/http/HttpServerRequest.ts +407 -16
  1121. package/src/unstable/http/HttpServerRespondable.ts +6 -6
  1122. package/src/unstable/http/HttpServerResponse.ts +345 -7
  1123. package/src/unstable/http/HttpStaticServer.ts +456 -0
  1124. package/src/unstable/http/HttpTraceContext.ts +31 -17
  1125. package/src/unstable/http/Multipart.ts +2 -2
  1126. package/src/unstable/http/Url.ts +650 -0
  1127. package/src/unstable/http/UrlParams.ts +31 -19
  1128. package/src/unstable/http/index.ts +10 -0
  1129. package/src/unstable/http/internal/preResponseHandler.ts +15 -0
  1130. package/src/unstable/httpapi/HttpApi.ts +6 -6
  1131. package/src/unstable/httpapi/HttpApiBuilder.ts +106 -41
  1132. package/src/unstable/httpapi/HttpApiClient.ts +180 -28
  1133. package/src/unstable/httpapi/HttpApiEndpoint.ts +216 -104
  1134. package/src/unstable/httpapi/HttpApiError.ts +108 -30
  1135. package/src/unstable/httpapi/HttpApiGroup.ts +7 -6
  1136. package/src/unstable/httpapi/HttpApiMiddleware.ts +83 -22
  1137. package/src/unstable/httpapi/HttpApiScalar.ts +6 -0
  1138. package/src/unstable/httpapi/HttpApiSchema.ts +20 -2
  1139. package/src/unstable/httpapi/HttpApiSecurity.ts +3 -3
  1140. package/src/unstable/httpapi/OpenApi.ts +43 -29
  1141. package/src/unstable/observability/Otlp.ts +12 -12
  1142. package/src/unstable/observability/OtlpExporter.ts +8 -5
  1143. package/src/unstable/observability/OtlpLogger.ts +13 -9
  1144. package/src/unstable/observability/OtlpMetrics.ts +4 -4
  1145. package/src/unstable/observability/OtlpTracer.ts +12 -8
  1146. package/src/unstable/persistence/KeyValueStore.ts +6 -6
  1147. package/src/unstable/persistence/Persistable.ts +3 -3
  1148. package/src/unstable/persistence/PersistedCache.ts +20 -9
  1149. package/src/unstable/persistence/PersistedQueue.ts +25 -24
  1150. package/src/unstable/persistence/Persistence.ts +3 -3
  1151. package/src/unstable/persistence/RateLimiter.ts +4 -4
  1152. package/src/unstable/process/ChildProcess.ts +6 -208
  1153. package/src/unstable/process/ChildProcessSpawner.ts +75 -14
  1154. package/src/unstable/reactivity/Atom.ts +212 -54
  1155. package/src/unstable/reactivity/AtomHttpApi.ts +81 -41
  1156. package/src/unstable/reactivity/AtomRegistry.ts +66 -12
  1157. package/src/unstable/reactivity/AtomRpc.ts +51 -20
  1158. package/src/unstable/reactivity/Hydration.ts +112 -0
  1159. package/src/unstable/reactivity/index.ts +5 -0
  1160. package/src/unstable/rpc/Rpc.ts +11 -12
  1161. package/src/unstable/rpc/RpcClient.ts +22 -63
  1162. package/src/unstable/rpc/RpcGroup.ts +7 -7
  1163. package/src/unstable/rpc/RpcMiddleware.ts +15 -9
  1164. package/src/unstable/rpc/RpcSchema.ts +23 -5
  1165. package/src/unstable/rpc/RpcSerialization.ts +49 -11
  1166. package/src/unstable/rpc/RpcServer.ts +31 -35
  1167. package/src/unstable/rpc/Utils.ts +3 -2
  1168. package/src/unstable/schema/Model.ts +31 -0
  1169. package/src/unstable/schema/VariantSchema.ts +10 -10
  1170. package/src/unstable/socket/Socket.ts +31 -27
  1171. package/src/unstable/sql/Migrator.ts +7 -5
  1172. package/src/unstable/sql/SqlClient.ts +6 -4
  1173. package/src/unstable/sql/SqlError.ts +365 -11
  1174. package/src/unstable/sql/SqlModel.ts +5 -5
  1175. package/src/unstable/sql/SqlResolver.ts +17 -7
  1176. package/src/unstable/sql/SqlSchema.ts +42 -26
  1177. package/src/unstable/sql/Statement.ts +0 -1
  1178. package/src/unstable/workers/Worker.ts +2 -1
  1179. package/src/unstable/workflow/DurableClock.ts +8 -8
  1180. package/src/unstable/workflow/DurableDeferred.ts +8 -8
  1181. package/src/unstable/workflow/Workflow.ts +7 -3
  1182. package/src/unstable/workflow/WorkflowEngine.ts +211 -19
  1183. package/dist/NullOr.d.ts +0 -149
  1184. package/dist/NullOr.d.ts.map +0 -1
  1185. package/dist/NullOr.js +0 -152
  1186. package/dist/NullOr.js.map +0 -1
  1187. package/dist/encoding/Base64.d.ts +0 -67
  1188. package/dist/encoding/Base64.d.ts.map +0 -1
  1189. package/dist/encoding/Base64.js +0 -146
  1190. package/dist/encoding/Base64.js.map +0 -1
  1191. package/dist/encoding/Base64Url.d.ts +0 -60
  1192. package/dist/encoding/Base64Url.d.ts.map +0 -1
  1193. package/dist/encoding/Base64Url.js +0 -89
  1194. package/dist/encoding/Base64Url.js.map +0 -1
  1195. package/dist/encoding/EncodingError.d.ts +0 -31
  1196. package/dist/encoding/EncodingError.d.ts.map +0 -1
  1197. package/dist/encoding/EncodingError.js +0 -22
  1198. package/dist/encoding/EncodingError.js.map +0 -1
  1199. package/dist/encoding/Hex.d.ts +0 -61
  1200. package/dist/encoding/Hex.d.ts.map +0 -1
  1201. package/dist/encoding/Hex.js +0 -115
  1202. package/dist/encoding/Hex.js.map +0 -1
  1203. package/dist/encoding/index.d.ts +0 -26
  1204. package/dist/encoding/index.d.ts.map +0 -1
  1205. package/dist/encoding/index.js +0 -27
  1206. package/dist/encoding/index.js.map +0 -1
  1207. package/dist/unstable/cli/internal/builtInFlags.d.ts +0 -7
  1208. package/dist/unstable/cli/internal/builtInFlags.d.ts.map +0 -1
  1209. package/dist/unstable/cli/internal/builtInFlags.js +0 -44
  1210. package/dist/unstable/cli/internal/builtInFlags.js.map +0 -1
  1211. package/dist/unstable/cli/internal/completions/Completions.d.ts +0 -2
  1212. package/dist/unstable/cli/internal/completions/Completions.d.ts.map +0 -1
  1213. package/dist/unstable/cli/internal/completions/Completions.js +0 -23
  1214. package/dist/unstable/cli/internal/completions/Completions.js.map +0 -1
  1215. package/src/NullOr.ts +0 -204
  1216. package/src/encoding/Base64.ts +0 -366
  1217. package/src/encoding/Base64Url.ts +0 -104
  1218. package/src/encoding/EncodingError.ts +0 -35
  1219. package/src/encoding/Hex.ts +0 -390
  1220. package/src/encoding/index.ts +0 -31
  1221. package/src/unstable/cli/internal/builtInFlags.ts +0 -78
  1222. package/src/unstable/cli/internal/completions/Completions.ts +0 -31
package/dist/Schema.js CHANGED
@@ -1,18 +1,104 @@
1
1
  /**
2
+ * Define data shapes, validate unknown input, and transform values between formats.
3
+ *
4
+ * ## Mental model
5
+ *
6
+ * - **Schema** — a description of a data shape. Every schema carries a decoded
7
+ * *Type* (the value you work with) and an *Encoded* representation (the
8
+ * serialized form, e.g. JSON).
9
+ * - **Decoding** — turning unknown external data (API responses, form
10
+ * submissions, config files) into typed, validated values.
11
+ * - **Encoding** — turning typed values back into a serializable format.
12
+ * - **Codec** — a schema that tracks both Type and Encoded, so it can decode
13
+ * *and* encode. Most concrete schemas are Codecs.
14
+ * - **Check / Filter** — a constraint attached to a schema (e.g. `isMinLength`,
15
+ * `isGreaterThan`). Attach them with `.check(...)`.
16
+ * - **Transformation** — a pair of functions (decode + encode) that convert
17
+ * values between two schemas. Created with {@link decodeTo} / {@link encodeTo}.
18
+ * - **Annotation** — metadata attached to a schema (title, description, custom
19
+ * keys). Attach with `.annotate(...)`.
20
+ *
21
+ * ## Common tasks
22
+ *
23
+ * - Define a struct: {@link Struct}
24
+ * - Define a union: {@link Union}, {@link TaggedUnion}, {@link Literals}
25
+ * - Define an array: {@link ArraySchema}, {@link NonEmptyArray}
26
+ * - Define a record: {@link Record}
27
+ * - Define a tuple: {@link Tuple}, {@link TupleWithRest}
28
+ * - Validate unknown data synchronously: {@link decodeUnknownSync}
29
+ * - Validate unknown data (Effect): {@link decodeUnknownEffect}
30
+ * - Encode a value: {@link encodeUnknownSync}, {@link encodeUnknownEffect}
31
+ * - Type guard: {@link is}
32
+ * - Assertion: {@link asserts}
33
+ * - Add constraints: `.check(...)` with filters like {@link isMinLength},
34
+ * {@link isGreaterThan}, {@link isPattern}, {@link isUUID}
35
+ * - Transform between schemas: {@link decodeTo}, {@link encodeTo}
36
+ * - Add a default for missing keys: {@link withDecodingDefault}, {@link withDecodingDefaultKey}
37
+ * - Create branded types: {@link brand}
38
+ * - Define classes with validation: {@link Class}, {@link TaggedClass}
39
+ * - Define error classes: {@link ErrorClass}, {@link TaggedErrorClass}
40
+ * - Generate JSON Schema: {@link toJsonSchemaDocument}
41
+ * - Generate test data: {@link toArbitrary}
42
+ * - Derive equivalence: {@link toEquivalence}
43
+ *
44
+ * ## Gotchas
45
+ *
46
+ * - `Schema.optional` creates `T | undefined` (key can be missing *or*
47
+ * `undefined`). Use `Schema.optionalKey` for exact optional properties.
48
+ * - `decodeTo` is curried: use `from.pipe(Schema.decodeTo(to, ...))`.
49
+ * - `decodeUnknownSync` throws on failure. Use `decodeUnknownExit` or
50
+ * `decodeUnknownOption` for non-throwing alternatives.
51
+ * - Filters do not change the TypeScript type. Use {@link refine} or
52
+ * {@link brand} to narrow the type.
53
+ * - Recursive schemas require {@link suspend} to avoid infinite loops.
54
+ *
55
+ * ## Quickstart
56
+ *
57
+ * **Example** (Validate a user object)
58
+ *
59
+ * ```ts
60
+ * import { Schema } from "effect"
61
+ *
62
+ * const User = Schema.Struct({
63
+ * name: Schema.String.check(Schema.isMinLength(1)),
64
+ * age: Schema.Number.check(Schema.isGreaterThanOrEqualTo(0)),
65
+ * email: Schema.optionalKey(Schema.String)
66
+ * })
67
+ *
68
+ * // Decode unknown input — throws on failure
69
+ * const user = Schema.decodeUnknownSync(User)({
70
+ * name: "Alice",
71
+ * age: 30
72
+ * })
73
+ *
74
+ * console.log(user)
75
+ * // { name: "Alice", age: 30 }
76
+ * ```
77
+ *
78
+ * @see {@link Schema} — type-level view tracking only the decoded Type
79
+ * @see {@link Codec} — type-level view tracking both Type and Encoded
80
+ * @see {@link Struct} — define object shapes
81
+ * @see {@link decodeUnknownSync} — synchronous validation
82
+ * @see {@link decodeTo} — schema transformations
83
+ *
2
84
  * @since 4.0.0
3
85
  */
4
86
  import * as Arr from "./Array.js";
87
+ import * as BigDecimal_ from "./BigDecimal.js";
5
88
  import * as Cause_ from "./Cause.js";
89
+ import * as Chunk_ from "./Chunk.js";
6
90
  import * as Data from "./Data.js";
7
91
  import * as DateTime from "./DateTime.js";
8
92
  import * as Duration_ from "./Duration.js";
9
93
  import * as Effect from "./Effect.js";
10
- import * as Base64 from "./encoding/Base64.js";
94
+ import * as Encoding from "./Encoding.js";
11
95
  import * as Equal from "./Equal.js";
12
96
  import * as Equivalence from "./Equivalence.js";
13
97
  import * as Exit_ from "./Exit.js";
14
98
  import { format, formatDate, formatPropertyKey } from "./Formatter.js";
15
99
  import { identity } from "./Function.js";
100
+ import * as HashMap_ from "./HashMap.js";
101
+ import * as HashSet_ from "./HashSet.js";
16
102
  import * as core from "./internal/core.js";
17
103
  import * as InternalAnnotations from "./internal/schema/annotations.js";
18
104
  import * as InternalArbitrary from "./internal/schema/arbitrary.js";
@@ -41,9 +127,51 @@ import * as Struct_ from "./Struct.js";
41
127
  import * as FastCheck from "./testing/FastCheck.js";
42
128
  const TypeId = InternalSchema.TypeId;
43
129
  /**
44
- * An API for creating schemas for parametric types.
130
+ * Creates a schema for a **parametric** type (a generic container such as
131
+ * `Array<A>`, `Option<A>`, etc.) by accepting a list of type-parameter schemas
132
+ * and a decoder factory.
133
+ *
134
+ * The outer call `declareConstructor<T, E, Iso>()` fixes the decoded type `T`,
135
+ * the encoded type `E`, and the optional iso type. The inner call receives:
136
+ * - `typeParameters` — the concrete schemas for each type variable
137
+ * - `run` — a factory that, given resolved codecs for each type parameter,
138
+ * returns a parsing function `(u, ast, options) => Effect<T, Issue>`
139
+ * - `annotations` — optional metadata
45
140
  *
46
- * @see {@link declare} for creating schemas for non parametric types.
141
+ * @see {@link declare} for creating schemas for non-parametric types.
142
+ *
143
+ * **Example** (Schema for a parametric `Box<A>` type)
144
+ *
145
+ * ```ts
146
+ * import { Effect, Schema } from "effect"
147
+ * import * as SchemaParser from "effect/SchemaParser"
148
+ * import * as Issue from "effect/SchemaIssue"
149
+ * import * as Option from "effect/Option"
150
+ *
151
+ * interface Box<A> {
152
+ * readonly value: A
153
+ * }
154
+ *
155
+ * const isBox = (u: unknown): u is Box<unknown> =>
156
+ * typeof u === "object" && u !== null && "value" in u
157
+ *
158
+ * const Box = <A extends Schema.Top>(item: A) =>
159
+ * Schema.declareConstructor<Box<A["Type"]>, Box<A["Encoded"]>>()(
160
+ * [item],
161
+ * ([itemCodec]) =>
162
+ * (u, ast, options) => {
163
+ * if (!isBox(u)) {
164
+ * return Effect.fail(new Issue.InvalidType(ast, Option.some(u)))
165
+ * }
166
+ * return Effect.map(
167
+ * SchemaParser.decodeUnknownEffect(itemCodec)(u.value, options),
168
+ * (value) => ({ value })
169
+ * )
170
+ * }
171
+ * )
172
+ *
173
+ * const schema = Box(Schema.Number)
174
+ * ```
47
175
  *
48
176
  * @category Constructors
49
177
  * @since 4.0.0
@@ -54,18 +182,60 @@ export function declareConstructor() {
54
182
  };
55
183
  }
56
184
  /**
57
- * An API for creating schemas for non parametric types.
185
+ * Creates a schema for a **non-parametric** opaque type using a type-guard
186
+ * function. The schema accepts any unknown value and succeeds when `is` returns
187
+ * `true`, failing with an `InvalidType` issue otherwise.
188
+ *
189
+ * Use this when the type has no type parameters. For parametric types such as
190
+ * `Option<A>` or `Array<A>`, use {@link declareConstructor} instead.
191
+ *
192
+ * **Example** (Schema for a custom `UserId` branded type)
193
+ *
194
+ * ```ts
195
+ * import { Schema } from "effect"
196
+ *
197
+ * type UserId = string & { readonly _tag: "UserId" }
198
+ *
199
+ * const isUserId = (u: unknown): u is UserId =>
200
+ * typeof u === "string" && u.startsWith("user_")
201
+ *
202
+ * const UserId = Schema.declare<UserId>(isUserId, {
203
+ * title: "UserId",
204
+ * description: "A user identifier starting with 'user_'"
205
+ * })
206
+ * ```
58
207
  *
59
208
  * @see {@link declareConstructor} for creating schemas for parametric types.
60
209
  *
210
+ * @category Constructors
61
211
  * @since 4.0.0
62
212
  */
63
213
  export function declare(is, annotations) {
64
214
  return declareConstructor()([], () => (input, ast) => is(input) ? Effect.succeed(input) : Effect.fail(new Issue.InvalidType(ast, Option_.some(input))), annotations);
65
215
  }
66
216
  /**
67
- * Reveals the complete Bottom interface type of a schema, exposing all 14 type
68
- * parameters.
217
+ * Widens a schema's type to the fully-parameterized {@link Bottom} interface,
218
+ * making all 14 type parameters visible to TypeScript.
219
+ *
220
+ * Normally, concrete schema interfaces (e.g. `Schema<string>`) hide most type
221
+ * parameters. `revealBottom` is useful when writing generic utilities that need
222
+ * to inspect or propagate the complete set of type parameters.
223
+ *
224
+ * **Example** (Inspecting all type parameters of a schema)
225
+ *
226
+ * ```ts
227
+ * import { Schema } from "effect"
228
+ *
229
+ * const schema = Schema.String
230
+ *
231
+ * // Widen to Bottom to access all 14 type parameters
232
+ * const bottom = Schema.revealBottom(schema)
233
+ *
234
+ * // `bottom` now exposes Type, Encoded, DecodingServices, EncodingServices,
235
+ * // ast, ~rebuild.out, ~type.make.in, Iso, ~type.parameters, etc.
236
+ * type T = typeof bottom["Type"] // string
237
+ * type E = typeof bottom["Encoded"] // string
238
+ * ```
69
239
  *
70
240
  * @since 4.0.0
71
241
  */
@@ -74,8 +244,24 @@ export function revealBottom(bottom) {
74
244
  }
75
245
  /**
76
246
  * Adds metadata annotations to a schema without changing its runtime behavior.
77
- * Annotations are used to provide additional context for documentation,
78
- * JSON schema generation, error formatting, and other tooling.
247
+ * This is the pipeable (curried) counterpart of the `.annotate` method.
248
+ *
249
+ * Annotations provide extra context used by documentation generators, JSON
250
+ * Schema converters, error formatters, and other tooling. Common keys include
251
+ * `title`, `description`, `examples`, `message`, and `identifier`.
252
+ *
253
+ * **Example** (Adding a title and description)
254
+ *
255
+ * ```ts
256
+ * import { Schema } from "effect"
257
+ *
258
+ * const Age = Schema.Number.pipe(
259
+ * Schema.annotate({
260
+ * title: "Age",
261
+ * description: "A non-negative integer representing age in years"
262
+ * })
263
+ * )
264
+ * ```
79
265
  *
80
266
  * @category Annotations
81
267
  * @since 4.0.0
@@ -86,9 +272,29 @@ export function annotate(annotations) {
86
272
  };
87
273
  }
88
274
  /**
89
- * Adds key-specific annotations to a schema field. This is useful for providing
90
- * custom error messages and documentation for individual fields within
91
- * structures.
275
+ * Adds key-level annotations to a schema field. This is the pipeable
276
+ * (curried) counterpart of the `.annotateKey` method.
277
+ *
278
+ * Key annotations apply to a field's position inside a `Struct` or `Tuple`
279
+ * rather than to the field's value type. They can carry a
280
+ * `messageMissingKey` to customise the error shown when the field is absent,
281
+ * as well as standard documentation fields such as `title`, `description`,
282
+ * and `examples`.
283
+ *
284
+ * **Example** (Custom missing-key message for a required field)
285
+ *
286
+ * ```ts
287
+ * import { Schema } from "effect"
288
+ *
289
+ * const schema = Schema.Struct({
290
+ * username: Schema.String.pipe(
291
+ * Schema.annotateKey({
292
+ * description: "The username used to log in",
293
+ * messageMissingKey: "Username is required"
294
+ * })
295
+ * )
296
+ * })
297
+ * ```
92
298
  *
93
299
  * @category Annotations
94
300
  * @since 4.0.0
@@ -99,6 +305,25 @@ export function annotateKey(annotations) {
99
305
  };
100
306
  }
101
307
  /**
308
+ * Identity function that widens a value to the full {@link Codec} interface,
309
+ * prompting TypeScript to infer all four type parameters (`T`, `E`, `RD`, `RE`).
310
+ *
311
+ * When a schema is stored in a variable typed as `Schema<T>` or `Top`, the
312
+ * encoded type and service requirements are erased. Passing the value through
313
+ * `revealCodec` recovers those parameters without any runtime cost.
314
+ *
315
+ * **Example** (Recovering encoded type from a schema variable)
316
+ *
317
+ * ```ts
318
+ * import { Schema } from "effect"
319
+ *
320
+ * const schema: Schema.Schema<number> = Schema.NumberFromString
321
+ *
322
+ * // Without revealCodec, Encoded is unknown
323
+ * const codec = Schema.revealCodec(schema)
324
+ * type Enc = typeof codec["Encoded"] // string
325
+ * ```
326
+ *
102
327
  * @since 4.0.0
103
328
  */
104
329
  export function revealCodec(codec) {
@@ -106,12 +331,30 @@ export function revealCodec(codec) {
106
331
  }
107
332
  const SchemaErrorTypeId = "~effect/Schema/SchemaError";
108
333
  /**
109
- * A `SchemaError` is returned when schema decoding or encoding fails.
334
+ * Error thrown (or returned as the error channel value) when schema decoding
335
+ * or encoding fails.
336
+ *
337
+ * The `issue` field contains a structured {@link Issue.Issue} tree describing
338
+ * every validation failure, including the path to the problematic value,
339
+ * expected types, and actual values received. `message` renders the issue tree
340
+ * as a human-readable string.
110
341
  *
111
- * This error extends `Data.TaggedError` and contains detailed information about
112
- * what went wrong during schema processing. The error includes an `issue` field
113
- * that provides comprehensive details about the validation failure, including
114
- * the path to the problematic data, expected types, and actual values.
342
+ * Use {@link isSchemaError} to narrow an unknown value to `SchemaError`.
343
+ *
344
+ * **Example** (Catching a SchemaError)
345
+ *
346
+ * ```ts
347
+ * import { Schema } from "effect"
348
+ *
349
+ * try {
350
+ * Schema.decodeUnknownSync(Schema.Number)("not a number")
351
+ * } catch (err) {
352
+ * if (Schema.isSchemaError(err)) {
353
+ * console.log(err.message)
354
+ * // Expected number, actual "not a number"
355
+ * }
356
+ * }
357
+ * ```
115
358
  *
116
359
  * @since 4.0.0
117
360
  */
@@ -131,6 +374,22 @@ export class SchemaError {
131
374
  }
132
375
  }
133
376
  /**
377
+ * Returns `true` if `u` is a {@link SchemaError}.
378
+ *
379
+ * **Example** (Type guard in a catch block)
380
+ *
381
+ * ```ts
382
+ * import { Schema } from "effect"
383
+ *
384
+ * try {
385
+ * Schema.decodeUnknownSync(Schema.Number)("oops")
386
+ * } catch (err) {
387
+ * if (Schema.isSchemaError(err)) {
388
+ * console.log(err._tag) // "SchemaError"
389
+ * }
390
+ * }
391
+ * ```
392
+ *
134
393
  * @since 4.0.0
135
394
  */
136
395
  export function isSchemaError(u) {
@@ -221,7 +480,7 @@ export function toStandardSchemaV1(self, options) {
221
480
  }), {
222
481
  scheduler
223
482
  });
224
- scheduler.flush();
483
+ fiber.currentDispatcher?.flush();
225
484
  const exit = fiber.pollUnsafe();
226
485
  if (exit) {
227
486
  return makeStandardResult(exit);
@@ -370,6 +629,11 @@ export const is = Parser.is;
370
629
  */
371
630
  export const asserts = Parser.asserts;
372
631
  /**
632
+ * Decodes an `unknown` input against a schema, returning an `Effect` that
633
+ * succeeds with the decoded value or fails with a {@link SchemaError}. Use this
634
+ * when the input type is not statically known. Prefer {@link decodeEffect} when
635
+ * the input is already typed as the schema's `Encoded` type.
636
+ *
373
637
  * @category Decoding
374
638
  * @since 4.0.0
375
639
  */
@@ -380,11 +644,22 @@ export function decodeUnknownEffect(schema) {
380
644
  };
381
645
  }
382
646
  /**
647
+ * Decodes a typed input (the schema's `Encoded` type) against a schema,
648
+ * returning an `Effect` that succeeds with the decoded value or fails with a
649
+ * {@link SchemaError}. Use this when the input is already typed; for `unknown`
650
+ * input use {@link decodeUnknownEffect}.
651
+ *
383
652
  * @category Decoding
384
653
  * @since 4.0.0
385
654
  */
386
655
  export const decodeEffect = decodeUnknownEffect;
387
656
  /**
657
+ * Decodes an `unknown` input against a schema synchronously, returning an
658
+ * `Exit` that is either a `Success` with the decoded value or a `Failure` with
659
+ * a {@link SchemaError}. Only usable with schemas that have no
660
+ * `DecodingServices` requirement. Prefer {@link decodeExit} when the input is
661
+ * already typed as the schema's `Encoded` type.
662
+ *
388
663
  * @category Decoding
389
664
  * @since 4.0.0
390
665
  */
@@ -395,41 +670,120 @@ export function decodeUnknownExit(schema) {
395
670
  };
396
671
  }
397
672
  /**
673
+ * Decodes a typed input (the schema's `Encoded` type) against a schema
674
+ * synchronously, returning an `Exit` that is either a `Success` with the
675
+ * decoded value or a `Failure` with a {@link SchemaError}. Only usable with
676
+ * schemas that have no `DecodingServices` requirement. For `unknown` input use
677
+ * {@link decodeUnknownExit}.
678
+ *
398
679
  * @category Decoding
399
680
  * @since 4.0.0
400
681
  */
401
682
  export const decodeExit = decodeUnknownExit;
402
683
  /**
684
+ * Decodes an `unknown` input against a schema, returning an `Option` that is
685
+ * `Some` with the decoded value on success or `None` on failure. Prefer this
686
+ * over {@link decodeUnknownExit} or {@link decodeUnknownEffect} when you only
687
+ * need to know whether decoding succeeded and don't need error details. For
688
+ * typed input use {@link decodeOption}.
689
+ *
403
690
  * @category Decoding
404
691
  * @since 4.0.0
405
692
  */
406
693
  export const decodeUnknownOption = Parser.decodeUnknownOption;
407
694
  /**
695
+ * Decodes a typed input (the schema's `Encoded` type) against a schema,
696
+ * returning an `Option` that is `Some` with the decoded value on success or
697
+ * `None` on failure. For `unknown` input use {@link decodeUnknownOption}.
698
+ *
408
699
  * @category Decoding
409
700
  * @since 4.0.0
410
701
  */
411
702
  export const decodeOption = Parser.decodeOption;
703
+ /**
704
+ * Decodes an `unknown` input against a schema, returning a `Promise` that
705
+ * resolves with the decoded value or rejects with a {@link SchemaError}. Useful
706
+ * for integrating with Promise-based APIs. For typed input use
707
+ * {@link decodePromise}.
708
+ *
709
+ * @category Decoding
710
+ * @since 4.0.0
711
+ */
712
+ export const decodeUnknownResult = Parser.decodeUnknownResult;
713
+ /**
714
+ * @category Decoding
715
+ * @since 4.0.0
716
+ */
717
+ export const decodeResult = Parser.decodeResult;
412
718
  /**
413
719
  * @category Decoding
414
720
  * @since 4.0.0
415
721
  */
416
722
  export const decodeUnknownPromise = Parser.decodeUnknownPromise;
417
723
  /**
724
+ * Decodes a typed input (the schema's `Encoded` type) against a schema,
725
+ * returning a `Promise` that resolves with the decoded value or rejects with a
726
+ * {@link SchemaError}. For `unknown` input use {@link decodeUnknownPromise}.
727
+ *
418
728
  * @category Decoding
419
729
  * @since 4.0.0
420
730
  */
421
731
  export const decodePromise = Parser.decodePromise;
422
732
  /**
733
+ * Decodes an `unknown` input against a schema synchronously, throwing a
734
+ * {@link SchemaError} on failure. Use this when you want to validate data at a
735
+ * boundary and treat a schema mismatch as an unrecoverable error. For
736
+ * non-throwing alternatives see {@link decodeUnknownOption},
737
+ * {@link decodeUnknownExit}, or {@link decodeUnknownEffect}. For typed input
738
+ * use {@link decodeSync}.
739
+ *
740
+ * **Example** (Decoding with a transformation schema)
741
+ *
742
+ * ```ts
743
+ * import { Schema } from "effect"
744
+ *
745
+ * const NumberFromString = Schema.NumberFromString
746
+ *
747
+ * console.log(Schema.decodeUnknownSync(NumberFromString)("42"))
748
+ * // Output: 42
749
+ *
750
+ * Schema.decodeUnknownSync(NumberFromString)("not a number")
751
+ * // throws SchemaError: NumberFromString
752
+ * // └─ Encoded side transformation failure
753
+ * // └─ NumberFromString
754
+ * // └─ Expected a numeric string, actual "not a number"
755
+ * ```
756
+ *
423
757
  * @category Decoding
424
758
  * @since 4.0.0
425
759
  */
426
760
  export const decodeUnknownSync = Parser.decodeUnknownSync;
427
761
  /**
762
+ * Decodes a typed input (the schema's `Encoded` type) against a schema
763
+ * synchronously, throwing a {@link SchemaError} on failure. For `unknown` input
764
+ * use {@link decodeUnknownSync}.
765
+ *
428
766
  * @category Decoding
429
767
  * @since 4.0.0
430
768
  */
431
769
  export const decodeSync = Parser.decodeSync;
432
770
  /**
771
+ * Encodes an `unknown` input against a schema, returning an `Effect` that
772
+ * succeeds with the encoded value or fails with a {@link SchemaError}. Use this
773
+ * when the input type is not statically known. Prefer {@link encodeEffect} when
774
+ * the input is already typed as the schema's `Type`.
775
+ *
776
+ * **Example** (Encoding a value to a string)
777
+ *
778
+ * ```ts
779
+ * import { Effect, Schema } from "effect"
780
+ *
781
+ * const NumberFromString = Schema.NumberFromString
782
+ *
783
+ * Effect.runPromise(Schema.encodeUnknownEffect(NumberFromString)(42)).then(console.log)
784
+ * // Output: "42"
785
+ * ```
786
+ *
433
787
  * @category Encoding
434
788
  * @since 4.0.0
435
789
  */
@@ -440,11 +794,22 @@ export function encodeUnknownEffect(schema) {
440
794
  };
441
795
  }
442
796
  /**
797
+ * Encodes a typed input (the schema's `Type`) against a schema, returning an
798
+ * `Effect` that succeeds with the encoded value or fails with a
799
+ * {@link SchemaError}. Use this when the input is already typed; for `unknown`
800
+ * input use {@link encodeUnknownEffect}.
801
+ *
443
802
  * @category Encoding
444
803
  * @since 4.0.0
445
804
  */
446
805
  export const encodeEffect = encodeUnknownEffect;
447
806
  /**
807
+ * Encodes an `unknown` input against a schema synchronously, returning an
808
+ * `Exit` that is either a `Success` with the encoded value or a `Failure` with
809
+ * a {@link SchemaError}. Only usable with schemas that have no
810
+ * `EncodingServices` requirement. Prefer {@link encodeExit} when the input is
811
+ * already typed as the schema's `Type`.
812
+ *
448
813
  * @category Encoding
449
814
  * @since 4.0.0
450
815
  */
@@ -455,36 +820,82 @@ export function encodeUnknownExit(schema) {
455
820
  };
456
821
  }
457
822
  /**
823
+ * Encodes a typed input (the schema's `Type`) against a schema synchronously,
824
+ * returning an `Exit` that is either a `Success` with the encoded value or a
825
+ * `Failure` with a {@link SchemaError}. Only usable with schemas that have no
826
+ * `EncodingServices` requirement. For `unknown` input use
827
+ * {@link encodeUnknownExit}.
828
+ *
458
829
  * @category Encoding
459
830
  * @since 4.0.0
460
831
  */
461
832
  export const encodeExit = encodeUnknownExit;
462
833
  /**
834
+ * Encodes an `unknown` input against a schema, returning an `Option` that is
835
+ * `Some` with the encoded value on success or `None` on failure. Prefer this
836
+ * over {@link encodeUnknownExit} or {@link encodeUnknownEffect} when you only
837
+ * need to know whether encoding succeeded and don't need error details. For
838
+ * typed input use {@link encodeOption}.
839
+ *
463
840
  * @category Encoding
464
841
  * @since 4.0.0
465
842
  */
466
843
  export const encodeUnknownOption = Parser.encodeUnknownOption;
467
844
  /**
845
+ * Encodes a typed input (the schema's `Type`) against a schema, returning an
846
+ * `Option` that is `Some` with the encoded value on success or `None` on
847
+ * failure. For `unknown` input use {@link encodeUnknownOption}.
848
+ *
468
849
  * @category Encoding
469
850
  * @since 4.0.0
470
851
  */
471
852
  export const encodeOption = Parser.encodeOption;
853
+ /**
854
+ * Encodes an `unknown` input against a schema, returning a `Promise` that
855
+ * resolves with the encoded value or rejects with a {@link SchemaError}. Useful
856
+ * for integrating with Promise-based APIs. For typed input use
857
+ * {@link encodePromise}.
858
+ *
859
+ * @category Encoding
860
+ * @since 4.0.0
861
+ */
862
+ export const encodeUnknownResult = Parser.encodeUnknownResult;
863
+ /**
864
+ * @category Encoding
865
+ * @since 4.0.0
866
+ */
867
+ export const encodeResult = Parser.encodeResult;
472
868
  /**
473
869
  * @category Encoding
474
870
  * @since 4.0.0
475
871
  */
476
872
  export const encodeUnknownPromise = Parser.encodeUnknownPromise;
477
873
  /**
874
+ * Encodes a typed input (the schema's `Type`) against a schema, returning a
875
+ * `Promise` that resolves with the encoded value or rejects with a
876
+ * {@link SchemaError}. For `unknown` input use {@link encodeUnknownPromise}.
877
+ *
478
878
  * @category Encoding
479
879
  * @since 4.0.0
480
880
  */
481
881
  export const encodePromise = Parser.encodePromise;
482
882
  /**
883
+ * Encodes an `unknown` input against a schema synchronously, throwing a
884
+ * {@link SchemaError} on failure. Use this when you want to serialize data at a
885
+ * boundary and treat a schema mismatch as an unrecoverable error. For
886
+ * non-throwing alternatives see {@link encodeUnknownOption},
887
+ * {@link encodeUnknownExit}, or {@link encodeUnknownEffect}. For typed input
888
+ * use {@link encodeSync}.
889
+ *
483
890
  * @category Encoding
484
891
  * @since 4.0.0
485
892
  */
486
893
  export const encodeUnknownSync = Parser.encodeUnknownSync;
487
894
  /**
895
+ * Encodes a typed input (the schema's `Type`) against a schema synchronously,
896
+ * throwing a {@link SchemaError} on failure. For `unknown` input use
897
+ * {@link encodeUnknownSync}.
898
+ *
488
899
  * @category Encoding
489
900
  * @since 4.0.0
490
901
  */
@@ -539,57 +950,74 @@ export const optionalKey = /*#__PURE__*/Struct_.lambda(schema => make(AST.option
539
950
  schema
540
951
  }));
541
952
  /**
953
+ * Reverses {@link optionalKey}, returning the inner required schema. Only
954
+ * applicable to schemas already wrapped with `optionalKey`.
955
+ *
542
956
  * @since 4.0.0
543
957
  */
544
958
  export const requiredKey = /*#__PURE__*/Struct_.lambda(self => self.schema);
545
959
  /**
546
- * Creates an optional schema field that allows both the specified type and
960
+ * Marks a struct field as optional, allowing the key to be absent or
547
961
  * `undefined`.
548
962
  *
549
- * This is equivalent to `optionalKey(UndefinedOr(schema))`, creating a field
550
- * that:
551
- * - Can be omitted from the object entirely
552
- * - Can be explicitly set to `undefined`
553
- * - Can contain the specified schema type
963
+ * explicitly set to `undefined`. Equivalent to `optionalKey(UndefinedOr(S))`.
964
+ *
965
+ * Use {@link optionalKey} instead if you want exact optional semantics (absent
966
+ * only, not `undefined`).
554
967
  *
555
- * **Example** (Creating a struct with optional)
968
+ * **Example** (Optional field accepting undefined)
556
969
  *
557
970
  * ```ts
558
971
  * import { Schema } from "effect"
559
972
  *
560
973
  * const schema = Schema.Struct({
561
974
  * name: Schema.String,
562
- * age: Schema.optionalKey(Schema.Number)
975
+ * age: Schema.optional(Schema.Number)
563
976
  * })
564
977
  *
565
- * // Type: { readonly name: string; readonly age?: number | undefined }
566
- * type Person = typeof schema["Type"]
978
+ * // { readonly name: string; readonly age?: number | undefined }
979
+ * type Person = typeof schema.Type
567
980
  * ```
568
981
  *
569
982
  * @since 4.0.0
570
983
  */
571
984
  export const optional = /*#__PURE__*/Struct_.lambda(self => optionalKey(UndefinedOr(self)));
572
985
  /**
986
+ * Reverses {@link optional}, returning the inner schema (unwrapping `UndefinedOr`).
987
+ * Only applicable to schemas already wrapped with `optional`.
988
+ *
573
989
  * @since 4.0.0
574
990
  */
575
991
  export const required = /*#__PURE__*/Struct_.lambda(self => self.schema.members[0]);
576
992
  /**
993
+ * Makes a struct field mutable (removes the `readonly` modifier on the property).
994
+ * Use {@link readonlyKey} to reverse.
995
+ *
577
996
  * @since 4.0.0
578
997
  */
579
998
  export const mutableKey = /*#__PURE__*/Struct_.lambda(schema => make(AST.mutableKey(schema.ast), {
580
999
  schema
581
1000
  }));
582
1001
  /**
1002
+ * Reverses {@link mutableKey}, returning the inner schema as readonly again.
1003
+ * Only applicable to schemas already wrapped with `mutableKey`.
1004
+ *
583
1005
  * @since 4.0.0
584
1006
  */
585
1007
  export const readonlyKey = /*#__PURE__*/Struct_.lambda(self => self.schema);
586
1008
  /**
1009
+ * Extracts the type-side schema: sets `Encoded` to equal the decoded `Type`,
1010
+ * discarding the encoding transformation path.
1011
+ *
587
1012
  * @since 4.0.0
588
1013
  */
589
1014
  export const toType = /*#__PURE__*/Struct_.lambda(schema => make(AST.toType(schema.ast), {
590
1015
  schema
591
1016
  }));
592
1017
  /**
1018
+ * Extracts the encoded-side schema: sets `Type` to equal the `Encoded`,
1019
+ * discarding the decoding transformation path.
1020
+ *
593
1021
  * @since 4.0.0
594
1022
  */
595
1023
  export const toEncoded = /*#__PURE__*/Struct_.lambda(schema => make(AST.toEncoded(schema.ast), {
@@ -609,6 +1037,16 @@ export function flip(schema) {
609
1037
  });
610
1038
  }
611
1039
  /**
1040
+ * Creates a schema for a single literal value (string, number, bigint, boolean, or null).
1041
+ *
1042
+ * **Example** (String literal)
1043
+ * ```ts
1044
+ * import { Schema } from "effect"
1045
+ *
1046
+ * const schema = Schema.Literal("hello")
1047
+ * // Type: Schema.Literal<"hello">
1048
+ * ```
1049
+ *
612
1050
  * @see {@link Literals} for a schema that represents a union of literals.
613
1051
  * @see {@link tag} for a schema that represents a literal value that can be
614
1052
  * used as a discriminator field in tagged unions and has a constructor default.
@@ -630,6 +1068,18 @@ function templateLiteralFromParts(parts) {
630
1068
  return new AST.TemplateLiteral(parts.map(part => isSchema(part) ? part.ast : new AST.Literal(part)));
631
1069
  }
632
1070
  /**
1071
+ * Creates a schema that validates strings matching a template literal pattern. Each part can be
1072
+ * a literal string/number/bigint or a schema whose encoded type is a string, number, or bigint.
1073
+ *
1074
+ * **Example** (URL path pattern)
1075
+ * ```ts
1076
+ * import { Schema } from "effect"
1077
+ *
1078
+ * const schema = Schema.TemplateLiteral(["/user/", Schema.Number])
1079
+ * // matches strings like "/user/123", "/user/42", etc.
1080
+ * ```
1081
+ *
1082
+ * @see {@link TemplateLiteralParser} for a schema that also parses matched parts into a tuple.
633
1083
  * @since 4.0.0
634
1084
  */
635
1085
  export function TemplateLiteral(parts) {
@@ -638,6 +1088,18 @@ export function TemplateLiteral(parts) {
638
1088
  });
639
1089
  }
640
1090
  /**
1091
+ * Like {@link TemplateLiteral} but decodes the matched string into a readonly tuple of typed values,
1092
+ * one element per schema part.
1093
+ *
1094
+ * **Example** (Parse path parameters)
1095
+ * ```ts
1096
+ * import { Schema } from "effect"
1097
+ *
1098
+ * const schema = Schema.TemplateLiteralParser(["/user/", Schema.NumberFromString])
1099
+ * // decodes "/user/42" => readonly ["/user/", 42]
1100
+ * ```
1101
+ *
1102
+ * @see {@link TemplateLiteral} for a validation-only version that keeps the string encoded.
641
1103
  * @since 4.0.0
642
1104
  */
643
1105
  export function TemplateLiteralParser(parts) {
@@ -646,6 +1108,21 @@ export function TemplateLiteralParser(parts) {
646
1108
  });
647
1109
  }
648
1110
  /**
1111
+ * Creates a schema from a TypeScript enum object. Validates that the input is one of the enum's values.
1112
+ *
1113
+ * **Example** (Direction enum)
1114
+ * ```ts
1115
+ * import { Schema } from "effect"
1116
+ *
1117
+ * enum Direction {
1118
+ * Up = "Up",
1119
+ * Down = "Down"
1120
+ * }
1121
+ *
1122
+ * const schema = Schema.Enum(Direction)
1123
+ * // accepts "Up" or "Down"
1124
+ * ```
1125
+ *
649
1126
  * @since 4.0.0
650
1127
  */
651
1128
  export function Enum(enums) {
@@ -654,84 +1131,102 @@ export function Enum(enums) {
654
1131
  });
655
1132
  }
656
1133
  /**
1134
+ * Schema for the `never` type. Always fails validation — no value satisfies it.
1135
+ *
657
1136
  * @since 4.0.0
658
1137
  */
659
1138
  export const Never = /*#__PURE__*/make(AST.never);
660
1139
  /**
1140
+ * Schema for the `any` type. Accepts any value without validation.
1141
+ *
1142
+ * @see {@link Unknown} for a safer alternative that uses `unknown`.
661
1143
  * @since 4.0.0
662
1144
  */
663
1145
  export const Any = /*#__PURE__*/make(AST.any);
664
1146
  /**
1147
+ * Schema for the `unknown` type. Accepts any value without validation.
1148
+ *
1149
+ * @see {@link Any} for the `any` variant.
665
1150
  * @since 4.0.0
666
1151
  */
667
1152
  export const Unknown = /*#__PURE__*/make(AST.unknown);
668
1153
  /**
1154
+ * Schema for the `null` literal. Validates that the input is strictly `null`.
1155
+ *
1156
+ * @see {@link NullOr} for a union with another schema.
669
1157
  * @since 4.0.0
670
1158
  */
671
1159
  export const Null = /*#__PURE__*/make(AST.null);
672
1160
  /**
1161
+ * Schema for the `undefined` literal. Validates that the input is strictly `undefined`.
1162
+ *
1163
+ * @see {@link UndefinedOr} for a union with another schema.
673
1164
  * @since 4.0.0
674
1165
  */
675
1166
  export const Undefined = /*#__PURE__*/make(AST.undefined);
676
1167
  /**
677
- * A schema for all strings.
1168
+ * Schema for `string` values. Validates that the input is `typeof` `"string"`.
678
1169
  *
679
1170
  * @since 4.0.0
680
1171
  */
681
1172
  export const String = /*#__PURE__*/make(AST.string);
682
1173
  /**
683
- * A schema for all numbers, including `NaN`, `Infinity`, and `-Infinity`.
1174
+ * Schema for `number` values, including `NaN`, `Infinity`, and `-Infinity`.
684
1175
  *
685
1176
  * **Default Json Serializer**
686
1177
  *
687
- * - If the number is finite, it is serialized as a number.
688
- * - Otherwise, it is serialized as a string ("NaN", "Infinity", or "-Infinity").
1178
+ * - Finite numbers are serialized as numbers.
1179
+ * - Non-finite values are serialized as strings (`"NaN"`, `"Infinity"`, `"-Infinity"`).
689
1180
  *
1181
+ * @see {@link Finite} for a schema that excludes non-finite values.
690
1182
  * @since 4.0.0
691
1183
  */
692
1184
  export const Number = /*#__PURE__*/make(AST.number);
693
1185
  /**
694
- * A schema for all booleans.
1186
+ * Schema for `boolean` values. Validates that the input is `typeof` `"boolean"`.
695
1187
  *
696
1188
  * @category Boolean
697
1189
  * @since 4.0.0
698
1190
  */
699
1191
  export const Boolean = /*#__PURE__*/make(AST.boolean);
700
1192
  /**
701
- * A schema for all symbols.
1193
+ * Schema for `symbol` values. Validates that the input is `typeof` `"symbol"`.
702
1194
  *
1195
+ * @see {@link UniqueSymbol} for a schema that matches a specific symbol.
703
1196
  * @since 4.0.0
704
1197
  */
705
1198
  export const Symbol = /*#__PURE__*/make(AST.symbol);
706
1199
  /**
707
- * A schema for all bigints.
1200
+ * Schema for `bigint` values. Validates that the input is `typeof` `"bigint"`.
708
1201
  *
709
1202
  * @since 4.0.0
710
1203
  */
711
1204
  export const BigInt = /*#__PURE__*/make(AST.bigInt);
712
1205
  /**
713
- * A schema for the `void` type.
1206
+ * Schema for the `void` type. Accepts `undefined` as the encoded value.
714
1207
  *
715
1208
  * @since 4.0.0
716
1209
  */
717
1210
  export const Void = /*#__PURE__*/make(AST.void);
718
1211
  /**
719
- * A schema for the `object` type.
1212
+ * Schema for the `object` type. Validates that the input is a non-null object or function
1213
+ * (i.e. `typeof value === "object" && value !== null || typeof value === "function"`).
720
1214
  *
721
1215
  * @since 4.0.0
722
1216
  */
723
1217
  export const ObjectKeyword = /*#__PURE__*/make(AST.objectKeyword);
724
1218
  /**
725
- * A schema for unique symbols.
726
- *
727
- * **Example**
1219
+ * Creates a schema for a specific symbol. Only that exact symbol satisfies the schema.
728
1220
  *
1221
+ * **Example** (Specific symbol)
729
1222
  * ```ts
730
1223
  * import { Schema } from "effect"
731
1224
  *
732
- * const a = Symbol.for("a")
733
- * const schema = Schema.UniqueSymbol(a)
1225
+ * const mySymbol = Symbol.for("mySymbol")
1226
+ * const schema = Schema.UniqueSymbol(mySymbol)
734
1227
  * ```
1228
+ *
1229
+ * @see {@link Symbol} for a schema that accepts any symbol.
735
1230
  * @since 4.0.0
736
1231
  */
737
1232
  export function UniqueSymbol(symbol) {
@@ -747,6 +1242,34 @@ function makeStruct(ast, fields) {
747
1242
  });
748
1243
  }
749
1244
  /**
1245
+ * Defines a struct schema from a map of field schemas.
1246
+ *
1247
+ * Each field value is a schema. Use {@link optionalKey} or {@link optional} to
1248
+ * mark fields as optional, and {@link mutableKey} to mark them as mutable.
1249
+ *
1250
+ * The resulting schema's `Type` is a readonly object type with the fields'
1251
+ * decoded types. The `Encoded` form mirrors the field schemas' encoded types.
1252
+ *
1253
+ * **Example** (Basic struct)
1254
+ *
1255
+ * ```ts
1256
+ * import { Schema } from "effect"
1257
+ *
1258
+ * const Person = Schema.Struct({
1259
+ * name: Schema.String,
1260
+ * age: Schema.Number,
1261
+ * email: Schema.optionalKey(Schema.String)
1262
+ * })
1263
+ *
1264
+ * // { readonly name: string; readonly age: number; readonly email?: string }
1265
+ * type Person = typeof Person.Type
1266
+ *
1267
+ * const alice = Schema.decodeUnknownSync(Person)({ name: "Alice", age: 30 })
1268
+ * console.log(alice)
1269
+ * // { name: 'Alice', age: 30 }
1270
+ * ```
1271
+ *
1272
+ * @category Constructors
750
1273
  * @since 4.0.0
751
1274
  */
752
1275
  export function Struct(fields) {
@@ -774,6 +1297,26 @@ export function fieldsAssign(fields) {
774
1297
  return Struct_.lambda(struct => struct.mapFields(Struct_.assign(fields)));
775
1298
  }
776
1299
  /**
1300
+ * Renames struct keys in the encoded form without changing the decoded type.
1301
+ *
1302
+ * Takes a partial mapping `{ decodedKey: encodedKey }` and produces a
1303
+ * transformation schema that decodes from the renamed keys and encodes back to
1304
+ * the renamed keys. Keys not present in the mapping are left unchanged.
1305
+ *
1306
+ * **Example** (Rename `name` to `full_name` in the encoded form)
1307
+ *
1308
+ * ```ts
1309
+ * import { Schema } from "effect"
1310
+ *
1311
+ * const Person = Schema.Struct({ name: Schema.String, age: Schema.Number })
1312
+ * const Encoded = Person.pipe(Schema.encodeKeys({ name: "full_name" }))
1313
+ *
1314
+ * // Decodes { full_name: "Alice", age: 30 } → { name: "Alice", age: 30 }
1315
+ * const alice = Schema.decodeUnknownSync(Encoded)({ full_name: "Alice", age: 30 })
1316
+ * console.log(alice)
1317
+ * // { name: 'Alice', age: 30 }
1318
+ * ```
1319
+ *
777
1320
  * @category Struct transformations
778
1321
  * @since 4.0.0
779
1322
  */
@@ -782,11 +1325,12 @@ export function encodeKeys(mapping) {
782
1325
  const fields = {};
783
1326
  const reverseMapping = {};
784
1327
  for (const k in self.fields) {
1328
+ const encoded = toEncoded(self.fields[k]);
785
1329
  if (Object.hasOwn(mapping, k)) {
786
- fields[mapping[k]] = toEncoded(self.fields[k]);
1330
+ fields[mapping[k]] = encoded;
787
1331
  reverseMapping[mapping[k]] = k;
788
1332
  } else {
789
- fields[k] = self.fields[k];
1333
+ fields[k] = encoded;
790
1334
  }
791
1335
  }
792
1336
  return Struct(fields).pipe(decodeTo(self, Transformation.transform({
@@ -796,6 +1340,31 @@ export function encodeKeys(mapping) {
796
1340
  };
797
1341
  }
798
1342
  /**
1343
+ * Adds derived fields to a struct schema during decoding.
1344
+ *
1345
+ * Each new field is derived from the decoded struct value via a function that
1346
+ * returns `Option`. On encoding the derived fields are stripped. This allows
1347
+ * computed or enriched fields to live in the decoded type without appearing in
1348
+ * the encoded form.
1349
+ *
1350
+ * **Example** (Add a computed `fullName` field)
1351
+ *
1352
+ * ```ts
1353
+ * import { Option, Schema } from "effect"
1354
+ *
1355
+ * const Person = Schema.Struct({ first: Schema.String, last: Schema.String })
1356
+ * const Extended = Person.pipe(
1357
+ * Schema.extendTo(
1358
+ * { fullName: Schema.String },
1359
+ * { fullName: (p) => Option.some(`${p.first} ${p.last}`) }
1360
+ * )
1361
+ * )
1362
+ *
1363
+ * const alice = Schema.decodeUnknownSync(Extended)({ first: "Alice", last: "Smith" })
1364
+ * console.log(alice.fullName)
1365
+ * // Alice Smith
1366
+ * ```
1367
+ *
799
1368
  * @since 4.0.0
800
1369
  * @experimental
801
1370
  */
@@ -835,6 +1404,24 @@ derive) {
835
1404
  };
836
1405
  }
837
1406
  /**
1407
+ * Defines a record (dictionary) schema with typed keys and values.
1408
+ *
1409
+ * **Example** (String-keyed record of numbers)
1410
+ *
1411
+ * ```ts
1412
+ * import { Schema } from "effect"
1413
+ *
1414
+ * const schema = Schema.Record(Schema.String, Schema.Number)
1415
+ *
1416
+ * // { readonly [x: string]: number }
1417
+ * type R = typeof schema.Type
1418
+ *
1419
+ * const result = Schema.decodeUnknownSync(schema)({ a: 1, b: 2 })
1420
+ * console.log(result)
1421
+ * // { a: 1, b: 2 }
1422
+ * ```
1423
+ *
1424
+ * @category Constructors
838
1425
  * @since 4.0.0
839
1426
  */
840
1427
  export function Record(key, value, options) {
@@ -845,6 +1432,24 @@ export function Record(key, value, options) {
845
1432
  });
846
1433
  }
847
1434
  /**
1435
+ * Extends a struct schema with one or more record (index-signature) schemas,
1436
+ * producing a schema whose decoded type intersects the struct and all records.
1437
+ *
1438
+ * **Example** (Struct with string-indexed extra keys)
1439
+ *
1440
+ * ```ts
1441
+ * import { Schema } from "effect"
1442
+ *
1443
+ * const schema = Schema.StructWithRest(
1444
+ * Schema.Struct({ id: Schema.Number }),
1445
+ * [Schema.Record(Schema.String, Schema.String)]
1446
+ * )
1447
+ *
1448
+ * // { readonly id: number } & { readonly [x: string]: string }
1449
+ * type T = typeof schema.Type
1450
+ * ```
1451
+ *
1452
+ * @category Constructors
848
1453
  * @since 4.0.0
849
1454
  */
850
1455
  export function StructWithRest(schema, records) {
@@ -863,6 +1468,20 @@ function makeTuple(ast, elements) {
863
1468
  });
864
1469
  }
865
1470
  /**
1471
+ * Defines a fixed-length tuple schema from an array of element schemas.
1472
+ *
1473
+ * **Example** (Pair of string and number)
1474
+ *
1475
+ * ```ts
1476
+ * import { Schema } from "effect"
1477
+ *
1478
+ * const schema = Schema.Tuple([Schema.String, Schema.Number])
1479
+ *
1480
+ * const pair = Schema.decodeUnknownSync(schema)(["hello", 42])
1481
+ * console.log(pair)
1482
+ * // [ 'hello', 42 ]
1483
+ * ```
1484
+ *
866
1485
  * @category Constructors
867
1486
  * @since 4.0.0
868
1487
  */
@@ -870,6 +1489,26 @@ export function Tuple(elements) {
870
1489
  return makeTuple(AST.tuple(elements), elements);
871
1490
  }
872
1491
  /**
1492
+ * Extends a fixed-length tuple schema with rest elements, creating a variadic
1493
+ * tuple that starts with the fixed elements and ends with zero or more rest
1494
+ * elements.
1495
+ *
1496
+ * **Example** (Tuple with rest)
1497
+ *
1498
+ * ```ts
1499
+ * import { Schema } from "effect"
1500
+ *
1501
+ * // [string, number, ...boolean[]]
1502
+ * const schema = Schema.TupleWithRest(
1503
+ * Schema.Tuple([Schema.String, Schema.Number]),
1504
+ * [Schema.Boolean]
1505
+ * )
1506
+ *
1507
+ * const result = Schema.decodeUnknownSync(schema)(["hello", 1, true, false])
1508
+ * console.log(result)
1509
+ * // [ 'hello', 1, true, false ]
1510
+ * ```
1511
+ *
873
1512
  * @category Constructors
874
1513
  * @since 4.0.0
875
1514
  */
@@ -883,16 +1522,70 @@ export function TupleWithRest(schema, rest) {
883
1522
  * @category Constructors
884
1523
  * @since 4.0.0
885
1524
  */
886
- export const Array = /*#__PURE__*/Struct_.lambda(schema => make(new AST.Arrays(false, [], [schema.ast]), {
1525
+ const ArraySchema = /*#__PURE__*/Struct_.lambda(schema => make(new AST.Arrays(false, [], [schema.ast]), {
887
1526
  schema
888
1527
  }));
1528
+ export {
889
1529
  /**
1530
+ * Defines a `ReadonlyArray` schema for a given element schema.
1531
+ *
1532
+ * **Example** (Array of strings)
1533
+ *
1534
+ * ```ts
1535
+ * import { Schema } from "effect"
1536
+ *
1537
+ * const schema = Schema.Array(Schema.String)
1538
+ *
1539
+ * const result = Schema.decodeUnknownSync(schema)(["a", "b", "c"])
1540
+ * console.log(result)
1541
+ * // [ 'a', 'b', 'c' ]
1542
+ * ```
1543
+ *
1544
+ * @category Constructors
1545
+ * @since 4.0.0
1546
+ */
1547
+ ArraySchema as Array };
1548
+ /**
1549
+ * Defines a non-empty `ReadonlyArray` schema — at least one element required.
1550
+ * Type is `readonly [T, ...T[]]`.
1551
+ *
1552
+ * **Example** (Non-empty array of numbers)
1553
+ *
1554
+ * ```ts
1555
+ * import { Schema } from "effect"
1556
+ *
1557
+ * const schema = Schema.NonEmptyArray(Schema.Number)
1558
+ *
1559
+ * Schema.decodeUnknownSync(schema)([1, 2, 3]) // ok
1560
+ * Schema.decodeUnknownSync(schema)([]) // throws
1561
+ * ```
1562
+ *
890
1563
  * @category Constructors
891
1564
  * @since 4.0.0
892
1565
  */
893
1566
  export const NonEmptyArray = /*#__PURE__*/Struct_.lambda(schema => make(new AST.Arrays(false, [schema.ast], [schema.ast]), {
894
1567
  schema
895
1568
  }));
1569
+ /**
1570
+ * Decodes a single value or an array of values into an array.
1571
+ *
1572
+ * Decoding:
1573
+ * - a single value is decoded as a one-element array
1574
+ * - an array is decoded as-is
1575
+ *
1576
+ * Encoding:
1577
+ * - a one-element array is encoded as a single value
1578
+ * - arrays with more than one element are encoded as arrays
1579
+ *
1580
+ * @category Arrays
1581
+ * @since 4.0.0
1582
+ */
1583
+ export function ArrayEnsure(schema) {
1584
+ return Union([schema, ArraySchema(schema)]).pipe(decodeTo(ArraySchema(toType(schema)), Transformation.transform({
1585
+ decode: Arr.ensure,
1586
+ encode: array => array.length === 1 ? array[0] : array
1587
+ })));
1588
+ }
896
1589
  /**
897
1590
  * Returns a new array schema that ensures all elements are unique.
898
1591
  *
@@ -903,10 +1596,21 @@ export const NonEmptyArray = /*#__PURE__*/Struct_.lambda(schema => make(new AST.
903
1596
  * @since 4.0.0
904
1597
  */
905
1598
  export function UniqueArray(item) {
906
- return Array(item).check(isUnique());
1599
+ return ArraySchema(item).check(isUnique());
907
1600
  }
908
1601
  /**
909
- * Makes arrays or tuples mutable.
1602
+ * Makes an array or tuple schema mutable, removing the `readonly` modifier.
1603
+ *
1604
+ * **Example** (Mutable array)
1605
+ *
1606
+ * ```ts
1607
+ * import { Schema } from "effect"
1608
+ *
1609
+ * const schema = Schema.mutable(Schema.Array(Schema.Number))
1610
+ *
1611
+ * // number[] (mutable)
1612
+ * type T = typeof schema.Type
1613
+ * ```
910
1614
  *
911
1615
  * @since 4.0.0
912
1616
  */
@@ -925,12 +1629,23 @@ function makeUnion(ast, members) {
925
1629
  });
926
1630
  }
927
1631
  /**
928
- * Creates a schema that represents a union of multiple schemas. Members are checked in order, and the first match is returned.
1632
+ * Creates a union schema from an array of member schemas. Members are tested in
1633
+ * order; the first match is returned.
929
1634
  *
930
- * Optionally, you can specify the `mode` to be `"anyOf"` or `"oneOf"`.
1635
+ * Optionally, specify `mode`:
1636
+ * - `"anyOf"` (default) — matches if any member matches.
1637
+ * - `"oneOf"` — matches if exactly one member matches.
931
1638
  *
932
- * - `"anyOf"` - The union matches if any member matches.
933
- * - `"oneOf"` - The union matches if exactly one member matches.
1639
+ * **Example** (String or number union)
1640
+ *
1641
+ * ```ts
1642
+ * import { Schema } from "effect"
1643
+ *
1644
+ * const schema = Schema.Union([Schema.String, Schema.Number])
1645
+ *
1646
+ * Schema.decodeUnknownSync(schema)("hello") // "hello"
1647
+ * Schema.decodeUnknownSync(schema)(42) // 42
1648
+ * ```
934
1649
  *
935
1650
  * @category Constructors
936
1651
  * @since 4.0.0
@@ -939,6 +1654,16 @@ export function Union(members, options) {
939
1654
  return makeUnion(AST.union(members, options?.mode ?? "anyOf", undefined), members);
940
1655
  }
941
1656
  /**
1657
+ * Creates a union schema from an array of literal values.
1658
+ *
1659
+ * **Example** (Status codes)
1660
+ * ```ts
1661
+ * import { Schema } from "effect"
1662
+ *
1663
+ * const schema = Schema.Literals(["active", "inactive", "pending"])
1664
+ * // accepts "active", "inactive", or "pending"
1665
+ * ```
1666
+ *
942
1667
  * @see {@link Literal} for a schema that represents a single literal.
943
1668
  * @category Constructors
944
1669
  * @since 4.0.0
@@ -960,16 +1685,21 @@ export function Literals(literals) {
960
1685
  });
961
1686
  }
962
1687
  /**
1688
+ * Creates a union schema of `S | null`.
1689
+ *
963
1690
  * @category Constructors
964
1691
  * @since 4.0.0
965
1692
  */
966
1693
  export const NullOr = /*#__PURE__*/Struct_.lambda(self => Union([self, Null]));
967
1694
  /**
1695
+ * Creates a union schema of `S | undefined`.
1696
+ *
968
1697
  * @category Constructors
969
1698
  * @since 4.0.0
970
1699
  */
971
1700
  export const UndefinedOr = /*#__PURE__*/Struct_.lambda(self => Union([self, Undefined]));
972
1701
  /**
1702
+ * Creates a union schema of `S | null | undefined`.
973
1703
  * @category Constructors
974
1704
  * @since 4.0.0
975
1705
  */
@@ -979,6 +1709,21 @@ export const NullishOr = /*#__PURE__*/Struct_.lambda(self => Union([self, Null,
979
1709
  * essential for creating recursive schemas where a schema references itself,
980
1710
  * preventing infinite recursion during schema definition.
981
1711
  *
1712
+ * **Example** (Recursive tree schema)
1713
+ * ```ts
1714
+ * import { Schema } from "effect"
1715
+ *
1716
+ * interface Tree {
1717
+ * readonly value: number
1718
+ * readonly children: ReadonlyArray<Tree>
1719
+ * }
1720
+ *
1721
+ * const Tree = Schema.Struct({
1722
+ * value: Schema.Number,
1723
+ * children: Schema.Array(Schema.suspend((): Schema.Codec<Tree> => Tree))
1724
+ * })
1725
+ * ```
1726
+ *
982
1727
  * @category Constructors
983
1728
  * @since 4.0.0
984
1729
  */
@@ -986,6 +1731,18 @@ export function suspend(f) {
986
1731
  return make(new AST.Suspend(() => f().ast));
987
1732
  }
988
1733
  /**
1734
+ * Pipeable function that attaches one or more filter checks to a schema without
1735
+ * changing the TypeScript type.
1736
+ *
1737
+ * **Example** (Adding checks to a schema)
1738
+ * ```ts
1739
+ * import { Schema } from "effect"
1740
+ *
1741
+ * const AgeSchema = Schema.Number.pipe(
1742
+ * Schema.check(Schema.isGreaterThanOrEqualTo(0), Schema.isLessThanOrEqualTo(120))
1743
+ * )
1744
+ * ```
1745
+ *
989
1746
  * @category Filtering
990
1747
  * @since 4.0.0
991
1748
  */
@@ -993,6 +1750,9 @@ export function check(...checks) {
993
1750
  return self => self.check(...checks);
994
1751
  }
995
1752
  /**
1753
+ * Narrows the TypeScript type of a schema's output via a type guard predicate,
1754
+ * attaching the guard as a runtime filter check.
1755
+ *
996
1756
  * @category Filtering
997
1757
  * @since 4.0.0
998
1758
  */
@@ -1002,7 +1762,8 @@ export function refine(refinement, annotations) {
1002
1762
  });
1003
1763
  }
1004
1764
  /**
1005
- * Adds a brand to a schema.
1765
+ * Adds a nominal brand to a schema, intersecting the output type with
1766
+ * `Brand.Brand<B>` to prevent accidental mixing of structurally identical types.
1006
1767
  *
1007
1768
  * @category Branding
1008
1769
  * @since 4.0.0
@@ -1014,7 +1775,10 @@ export function brand(identifier) {
1014
1775
  });
1015
1776
  }
1016
1777
  /**
1017
- * @category Constructors
1778
+ * Creates a branded schema from a {@link Brand.Constructor}, applying the
1779
+ * constructor's checks and brand tag to the underlying schema.
1780
+ *
1781
+ * @category Branding
1018
1782
  * @since 4.0.0
1019
1783
  */
1020
1784
  export function fromBrand(identifier, ctor) {
@@ -1023,6 +1787,25 @@ export function fromBrand(identifier, ctor) {
1023
1787
  };
1024
1788
  }
1025
1789
  /**
1790
+ * Intercepts the decoding pipeline of a schema.
1791
+ *
1792
+ * The provided function receives the current decoding `Effect` and `ParseOptions`,
1793
+ * and returns a new `Effect` — potentially adding service requirements (`RD`),
1794
+ * recovering from errors, or augmenting the result.
1795
+ *
1796
+ * **Example** (Logging decode failures)
1797
+ *
1798
+ * ```ts
1799
+ * import { Effect, Schema } from "effect"
1800
+ *
1801
+ * const Logged = Schema.String.pipe(
1802
+ * Schema.middlewareDecoding((effect) =>
1803
+ * Effect.tapError(effect, (issue) => Effect.log("decode failed", issue))
1804
+ * )
1805
+ * )
1806
+ * ```
1807
+ *
1808
+ * @see {@link catchDecoding} for a simpler error-recovery variant
1026
1809
  * @since 4.0.0
1027
1810
  */
1028
1811
  export function middlewareDecoding(decode) {
@@ -1031,6 +1814,25 @@ export function middlewareDecoding(decode) {
1031
1814
  });
1032
1815
  }
1033
1816
  /**
1817
+ * Intercepts the encoding pipeline of a schema.
1818
+ *
1819
+ * The provided function receives the current encoding `Effect` and `ParseOptions`,
1820
+ * and returns a new `Effect` — potentially adding service requirements (`RE`),
1821
+ * recovering from errors, or augmenting the result.
1822
+ *
1823
+ * **Example** (Logging encode failures)
1824
+ *
1825
+ * ```ts
1826
+ * import { Effect, Schema } from "effect"
1827
+ *
1828
+ * const Logged = Schema.String.pipe(
1829
+ * Schema.middlewareEncoding((effect) =>
1830
+ * Effect.tapError(effect, (issue) => Effect.log("encode failed", issue))
1831
+ * )
1832
+ * )
1833
+ * ```
1834
+ *
1835
+ * @see {@link catchEncoding} for a simpler error-recovery variant
1034
1836
  * @since 4.0.0
1035
1837
  */
1036
1838
  export function middlewareEncoding(encode) {
@@ -1039,24 +1841,50 @@ export function middlewareEncoding(encode) {
1039
1841
  });
1040
1842
  }
1041
1843
  /**
1844
+ * Recovers from a decoding error by providing a fallback value.
1845
+ *
1846
+ * The handler receives the `Issue` and returns an `Effect` that either
1847
+ * succeeds with a fallback value or re-fails with a (possibly different) issue.
1848
+ *
1849
+ * **Example** (Returning a default on decode failure)
1850
+ *
1851
+ * ```ts
1852
+ * import { Effect, Option, Schema } from "effect"
1853
+ *
1854
+ * const schema = Schema.Number.pipe(
1855
+ * Schema.catchDecoding((_issue) => Effect.succeed(Option.some(0)))
1856
+ * )
1857
+ * ```
1858
+ *
1859
+ * @see {@link catchDecodingWithContext} to add service requirements to the handler
1042
1860
  * @since 4.0.0
1043
1861
  */
1044
1862
  export function catchDecoding(f) {
1045
1863
  return catchDecodingWithContext(f);
1046
1864
  }
1047
1865
  /**
1866
+ * Like {@link catchDecoding}, but the handler may require Effect services (`R`).
1867
+ *
1048
1868
  * @since 4.0.0
1049
1869
  */
1050
1870
  export function catchDecodingWithContext(f) {
1051
1871
  return self => self.pipe(middlewareDecoding(Effect.catchEager(f)));
1052
1872
  }
1053
1873
  /**
1874
+ * Recovers from an encoding error by providing a fallback value.
1875
+ *
1876
+ * The handler receives the `Issue` and returns an `Effect` that either
1877
+ * succeeds with a fallback value or re-fails with a (possibly different) issue.
1878
+ *
1879
+ * @see {@link catchEncodingWithContext} to add service requirements to the handler
1054
1880
  * @since 4.0.0
1055
1881
  */
1056
1882
  export function catchEncoding(f) {
1057
1883
  return catchEncodingWithContext(f);
1058
1884
  }
1059
1885
  /**
1886
+ * Like {@link catchEncoding}, but the handler may require Effect services (`R`).
1887
+ *
1060
1888
  * @since 4.0.0
1061
1889
  */
1062
1890
  export function catchEncodingWithContext(f) {
@@ -1118,6 +1946,25 @@ export function encodeTo(to, transformation) {
1118
1946
  };
1119
1947
  }
1120
1948
  /**
1949
+ * Applies a transformation to a schema's encoded type, creating a new schema where encoding/decoding
1950
+ * operate on `S["Encoded"]` rather than `S["Type"]`.
1951
+ *
1952
+ * The `decode` getter maps `S["Encoded"]` → `S["Encoded"]` (applied during decoding),
1953
+ * and the `encode` getter maps `S["Encoded"]` → `S["Encoded"]` (applied during encoding).
1954
+ *
1955
+ * **Example** (Upper-casing encoded strings)
1956
+ *
1957
+ * ```ts
1958
+ * import { Schema, SchemaGetter } from "effect"
1959
+ *
1960
+ * const UpperFromLower = Schema.String.pipe(
1961
+ * Schema.encode({
1962
+ * decode: SchemaGetter.transform((s: string) => s.toLowerCase()),
1963
+ * encode: SchemaGetter.transform((s: string) => s.toUpperCase())
1964
+ * })
1965
+ * )
1966
+ * ```
1967
+ *
1121
1968
  * @since 4.0.0
1122
1969
  */
1123
1970
  export function encode(transformation) {
@@ -1126,6 +1973,32 @@ export function encode(transformation) {
1126
1973
  };
1127
1974
  }
1128
1975
  /**
1976
+ * Attaches a constructor default value to a schema field.
1977
+ *
1978
+ * The `defaultValue` function receives `Option.some(undefined)` when the field is
1979
+ * explicitly set to `undefined`, or `Option.none()` when the field is absent.
1980
+ * Return `Option.some(value)` to supply a default, or `Option.none()` to leave the
1981
+ * field required. An `Effect` may be returned for async or service-dependent defaults.
1982
+ *
1983
+ * Constructor defaults are applied only during `makeUnsafe` / `make`, not during
1984
+ * decoding or encoding.
1985
+ *
1986
+ * **Example** (Optional field with a static default)
1987
+ *
1988
+ * ```ts
1989
+ * import { Option, Schema } from "effect"
1990
+ *
1991
+ * const MySchema = Schema.Struct({
1992
+ * name: Schema.String.pipe(
1993
+ * Schema.optionalKey,
1994
+ * Schema.withConstructorDefault(() => Option.some("anonymous"))
1995
+ * )
1996
+ * })
1997
+ *
1998
+ * const value = MySchema.makeUnsafe({})
1999
+ * // value: { name: "anonymous" }
2000
+ * ```
2001
+ *
1129
2002
  * @since 4.0.0
1130
2003
  */
1131
2004
  export function withConstructorDefault(defaultValue) {
@@ -1142,6 +2015,27 @@ export function withConstructorDefault(defaultValue) {
1142
2015
  * - `passthrough`: (default) Pass the default value through to the output.
1143
2016
  * - `omit`: Omit the value from the output.
1144
2017
  *
2018
+ * Provides a default value for a missing key during decoding.
2019
+ *
2020
+ * When the key is absent from the input, `defaultValue()` is called to supply a value.
2021
+ * During encoding, the behavior is controlled by `options.encodingStrategy`:
2022
+ * - `"passthrough"` (default): include the value in the output
2023
+ * - `"omit"`: omit the key from the output
2024
+ *
2025
+ * **Example** (Default for a missing struct key)
2026
+ *
2027
+ * ```ts
2028
+ * import { Schema } from "effect"
2029
+ *
2030
+ * const MySchema = Schema.Struct({
2031
+ * name: Schema.String.pipe(Schema.withDecodingDefaultKey(() => "anonymous"))
2032
+ * })
2033
+ *
2034
+ * const result = Schema.decodeUnknownSync(MySchema)({})
2035
+ * // result: { name: "anonymous" }
2036
+ * ```
2037
+ *
2038
+ * @see {@link withDecodingDefault} for the `optional` (value-level) variant
1145
2039
  * @since 4.0.0
1146
2040
  */
1147
2041
  export function withDecodingDefaultKey(defaultValue, options) {
@@ -1160,6 +2054,30 @@ export function withDecodingDefaultKey(defaultValue, options) {
1160
2054
  * - `passthrough`: (default) Pass the default value through to the output.
1161
2055
  * - `omit`: Omit the value from the output.
1162
2056
  *
2057
+ * Provides a default value for an `optional` field during decoding.
2058
+ *
2059
+ * Similar to {@link withDecodingDefaultKey} but works on `optional` (value-level optional)
2060
+ * rather than `optionalKey` (key-level optional).
2061
+ *
2062
+ * When the value is `undefined` or absent, `defaultValue()` is called to supply a value.
2063
+ * During encoding, the behavior is controlled by `options.encodingStrategy`:
2064
+ * - `"passthrough"` (default): include the value in the output
2065
+ * - `"omit"`: omit the value from the output
2066
+ *
2067
+ * **Example** (Default for an optional field value)
2068
+ *
2069
+ * ```ts
2070
+ * import { Schema } from "effect"
2071
+ *
2072
+ * const MySchema = Schema.Struct({
2073
+ * name: Schema.String.pipe(Schema.optional, Schema.withDecodingDefault(() => "anonymous"))
2074
+ * })
2075
+ *
2076
+ * const result = Schema.decodeUnknownSync(MySchema)({ name: undefined })
2077
+ * // result: { name: "anonymous" }
2078
+ * ```
2079
+ *
2080
+ * @see {@link withDecodingDefaultKey} for the key-level variant
1163
2081
  * @since 4.0.0
1164
2082
  */
1165
2083
  export function withDecodingDefault(defaultValue, options) {
@@ -1172,23 +2090,50 @@ export function withDecodingDefault(defaultValue, options) {
1172
2090
  };
1173
2091
  }
1174
2092
  /**
1175
- * Creates a schema for a literal value and automatically provides itself as a
1176
- * default.
2093
+ * Combines a {@link Literal} schema with {@link withConstructorDefault}, making it ideal
2094
+ * for discriminator fields in tagged unions. When constructing via `makeUnsafe`, the
2095
+ * `_tag` field can be omitted and will be filled automatically.
1177
2096
  *
1178
- * The `tag` function combines a literal schema with a constructor default,
1179
- * making it perfect for discriminated unions and tagged data structures. The
1180
- * tag value is automatically provided when the field is missing during
1181
- * construction.
2097
+ * **Example** (Discriminated union tag)
1182
2098
  *
2099
+ * ```ts
2100
+ * import { Schema } from "effect"
2101
+ *
2102
+ * const A = Schema.Struct({ _tag: Schema.tag("A"), value: Schema.Number })
2103
+ *
2104
+ * // _tag is optional in makeUnsafe, auto-filled to "A"
2105
+ * const a = A.makeUnsafe({ value: 42 })
2106
+ * // a: { _tag: "A", value: 42 }
2107
+ * ```
2108
+ *
2109
+ * @see {@link tagDefaultOmit} to also omit the tag during encoding
2110
+ * @see {@link TaggedStruct} for a shorthand that adds `_tag` automatically
1183
2111
  * @since 4.0.0
1184
2112
  */
1185
2113
  export function tag(literal) {
1186
2114
  return Literal(literal).pipe(withConstructorDefault(() => Option_.some(literal)));
1187
2115
  }
1188
2116
  /**
1189
- * Similar to `tag`, but provides itself as a default when decoding and omits
1190
- * the value from the output when encoding.
2117
+ * Like {@link tag}, but additionally omits the tag field from the encoded output.
2118
+ * Useful when the encoded form (e.g. JSON) does not include the discriminator key,
2119
+ * but the decoded type and constructor still need it.
2120
+ *
2121
+ * **Example** (Tag omitted during encoding)
2122
+ *
2123
+ * ```ts
2124
+ * import { Schema } from "effect"
2125
+ *
2126
+ * const A = Schema.Struct({
2127
+ * _tag: Schema.tagDefaultOmit("A"),
2128
+ * value: Schema.Number
2129
+ * })
1191
2130
  *
2131
+ * // Encode strips the _tag field
2132
+ * const encoded = Schema.encodeUnknownSync(A)({ _tag: "A", value: 1 })
2133
+ * // encoded: { value: 1 }
2134
+ * ```
2135
+ *
2136
+ * @see {@link tag} for the variant that keeps the tag during encoding
1192
2137
  * @since 4.0.0
1193
2138
  */
1194
2139
  export function tagDefaultOmit(literal) {
@@ -1244,18 +2189,27 @@ export function TaggedStruct(value, fields) {
1244
2189
  ...fields
1245
2190
  });
1246
2191
  }
1247
- /** @internal */
1248
- export function _getTagValueIfPropertyKey(tag, ast) {
1249
- const ps = ast.propertySignatures.find(p => p.name === tag);
1250
- if (ps) {
1251
- if (AST.isLiteral(ps.type) && Predicate.isPropertyKey(ps.type.literal)) {
1252
- return ps.type.literal;
1253
- } else if (AST.isUniqueSymbol(ps.type)) {
1254
- return ps.type.symbol;
1255
- }
1256
- }
1257
- }
1258
2192
  /**
2193
+ * Augments an existing {@link Union} of tagged structs with utility methods keyed by the discriminant field.
2194
+ *
2195
+ * **Example** (Adding tagged-union utilities to an existing union)
2196
+ *
2197
+ * ```ts
2198
+ * import { Schema } from "effect"
2199
+ *
2200
+ * const A = Schema.TaggedStruct("A", { value: Schema.Number })
2201
+ * const B = Schema.TaggedStruct("B", { name: Schema.String })
2202
+ *
2203
+ * const MyUnion = Schema.Union([A, B]).pipe(Schema.toTaggedUnion("_tag"))
2204
+ *
2205
+ * // Pattern-match on the union
2206
+ * const result = MyUnion.match({ _tag: "A", value: 1 }, {
2207
+ * A: (a) => `number: ${a.value}`,
2208
+ * B: (b) => `name: ${b.name}`
2209
+ * })
2210
+ * ```
2211
+ *
2212
+ * @see {@link TaggedUnion} for a shorthand that builds the union from scratch
1259
2213
  * @since 4.0.0
1260
2214
  * @experimental
1261
2215
  */
@@ -1276,15 +2230,16 @@ export function toTaggedUnion(tag) {
1276
2230
  if (AST.isUnion(ast) && "members" in schema && globalThis.Array.isArray(schema.members) && schema.members.every(isSchema)) {
1277
2231
  return schema.members.forEach(walk);
1278
2232
  }
1279
- if (AST.isObjects(ast)) {
1280
- const key = _getTagValueIfPropertyKey(tag, ast);
1281
- if (key !== undefined) {
1282
- cases[key] = schema;
1283
- guards[key] = is(toType(schema));
2233
+ const sentinels = AST.collectSentinels(ast);
2234
+ if (sentinels.length > 0) {
2235
+ const literal = sentinels.find(s => s.key === tag)?.literal;
2236
+ if (Predicate.isPropertyKey(literal)) {
2237
+ cases[literal] = schema;
2238
+ guards[literal] = is(toType(schema));
1284
2239
  return;
1285
2240
  }
1286
2241
  }
1287
- throw new globalThis.Error("No literal found");
2242
+ throw new globalThis.Error("No literal or unique symbol found");
1288
2243
  }
1289
2244
  function match() {
1290
2245
  if (arguments.length === 1) {
@@ -1300,6 +2255,28 @@ export function toTaggedUnion(tag) {
1300
2255
  };
1301
2256
  }
1302
2257
  /**
2258
+ * Builds a discriminated union from a record of field sets, one per variant.
2259
+ * Each key becomes the `_tag` literal and the value is passed to {@link TaggedStruct}.
2260
+ * The result includes `cases`, `guards`, `isAnyOf`, and `match` utilities.
2261
+ *
2262
+ * **Example** (Discriminated union with pattern matching)
2263
+ *
2264
+ * ```ts
2265
+ * import { Schema } from "effect"
2266
+ *
2267
+ * const Shape = Schema.TaggedUnion({
2268
+ * Circle: { radius: Schema.Number },
2269
+ * Rectangle: { width: Schema.Number, height: Schema.Number }
2270
+ * })
2271
+ *
2272
+ * // Pattern-match on a decoded value
2273
+ * const area = Shape.match({ _tag: "Circle", radius: 5 }, {
2274
+ * Circle: (c) => Math.PI * c.radius ** 2,
2275
+ * Rectangle: (r) => r.width * r.height
2276
+ * })
2277
+ * ```
2278
+ *
2279
+ * @see {@link toTaggedUnion} to augment an existing union instead
1303
2280
  * @category Constructors
1304
2281
  * @since 4.0.0
1305
2282
  */
@@ -1323,6 +2300,23 @@ export function TaggedUnion(casesByTag) {
1323
2300
  });
1324
2301
  }
1325
2302
  /**
2303
+ * Wraps a schema so that its decoded `Type` becomes a nominally distinct type `Self`.
2304
+ * Useful for creating opaque types that are structurally identical to a base schema
2305
+ * but type-incompatible with it.
2306
+ *
2307
+ * **Example** (Opaque user ID)
2308
+ *
2309
+ * ```ts
2310
+ * import { Schema } from "effect"
2311
+ *
2312
+ * type UserId = string & { readonly _tag: "UserId" }
2313
+ * const UserId = Schema.Opaque<UserId>()(Schema.String)
2314
+ *
2315
+ * // Decoded value is UserId, not plain string
2316
+ * const id = Schema.decodeUnknownSync(UserId)("abc")
2317
+ * // id: UserId
2318
+ * ```
2319
+ *
1326
2320
  * @since 4.0.0
1327
2321
  */
1328
2322
  export function Opaque() {
@@ -1334,7 +2328,19 @@ export function Opaque() {
1334
2328
  };
1335
2329
  }
1336
2330
  /**
1337
- * Creates a schema that validates an instance of a specific class constructor.
2331
+ * Creates a schema that validates values using `instanceof`.
2332
+ * Decoding and encoding pass the value through unchanged.
2333
+ *
2334
+ * **Example** (Schema for a built-in class)
2335
+ *
2336
+ * ```ts
2337
+ * import { Schema } from "effect"
2338
+ *
2339
+ * const DateSchema = Schema.instanceOf(Date)
2340
+ *
2341
+ * const decoded = Schema.decodeUnknownSync(DateSchema)(new Date("2024-01-01"))
2342
+ * // decoded: Date
2343
+ * ```
1338
2344
  *
1339
2345
  * @category Constructors
1340
2346
  * @since 4.0.0
@@ -1343,6 +2349,9 @@ export function instanceOf(constructor, annotations) {
1343
2349
  return declare(u => u instanceof constructor, annotations);
1344
2350
  }
1345
2351
  /**
2352
+ * Constructs an `AST.Link` that describes how a value of type `T` encodes to and decodes from a `To` schema.
2353
+ * Used when building low-level AST transformations that bridge two schema types.
2354
+ *
1346
2355
  * @since 4.0.0
1347
2356
  * @experimental
1348
2357
  */
@@ -1355,11 +2364,30 @@ export function link() {
1355
2364
  // Checks
1356
2365
  // -----------------------------------------------------------------------------
1357
2366
  /**
2367
+ * Creates a custom filter check from a predicate function. The predicate
2368
+ * receives the input value, the schema's AST, and parse options, and returns
2369
+ * `true`/`undefined` on success or a failure description on error.
2370
+ *
2371
+ * **Example** (Custom filter check)
2372
+ * ```ts
2373
+ * import { Schema } from "effect"
2374
+ *
2375
+ * // Check that a number is even
2376
+ * const isEven = Schema.makeFilter(
2377
+ * (n: number) => n % 2 === 0 || "expected an even number"
2378
+ * )
2379
+ *
2380
+ * const EvenNumber = Schema.Number.check(isEven)
2381
+ * ```
2382
+ *
1358
2383
  * @category Checks Constructors
1359
2384
  * @since 4.0.0
1360
2385
  */
1361
2386
  export const makeFilter = AST.makeFilter;
1362
2387
  /**
2388
+ * Groups multiple checks into a single {@link AST.FilterGroup}, applying
2389
+ * optional shared annotations to the group as a whole.
2390
+ *
1363
2391
  * @category Checks Constructors
1364
2392
  * @since 4.0.0
1365
2393
  */
@@ -1847,6 +2875,9 @@ export function isFinite(annotations) {
1847
2875
  });
1848
2876
  }
1849
2877
  /**
2878
+ * Generic factory for creating a "greater than" (`>`) check for any ordered
2879
+ * type by supplying an {@link Order.Order} instance.
2880
+ *
1850
2881
  * @category Order checks
1851
2882
  * @since 4.0.0
1852
2883
  */
@@ -1862,6 +2893,9 @@ export function makeIsGreaterThan(options) {
1862
2893
  };
1863
2894
  }
1864
2895
  /**
2896
+ * Generic factory for creating a ">=" check for any ordered type by supplying
2897
+ * an {@link Order.Order} instance.
2898
+ *
1865
2899
  * @category Order checks
1866
2900
  * @since 4.0.0
1867
2901
  */
@@ -1877,6 +2911,9 @@ export function makeIsGreaterThanOrEqualTo(options) {
1877
2911
  };
1878
2912
  }
1879
2913
  /**
2914
+ * Generic factory for creating a "<" check for any ordered type by supplying
2915
+ * an {@link Order.Order} instance.
2916
+ *
1880
2917
  * @category Order checks
1881
2918
  * @since 4.0.0
1882
2919
  */
@@ -1892,6 +2929,9 @@ export function makeIsLessThan(options) {
1892
2929
  };
1893
2930
  }
1894
2931
  /**
2932
+ * Generic factory for creating a "<=" check for any ordered type by supplying
2933
+ * an {@link Order.Order} instance.
2934
+ *
1895
2935
  * @category Order checks
1896
2936
  * @since 4.0.0
1897
2937
  */
@@ -1907,6 +2947,9 @@ export function makeIsLessThanOrEqualTo(options) {
1907
2947
  };
1908
2948
  }
1909
2949
  /**
2950
+ * Generic factory for creating an inclusive/exclusive range check for any
2951
+ * ordered type by supplying an {@link Order.Order} instance.
2952
+ *
1910
2953
  * @category Order checks
1911
2954
  * @since 4.0.0
1912
2955
  */
@@ -1927,6 +2970,9 @@ export function makeIsBetween(deriveOptions) {
1927
2970
  };
1928
2971
  }
1929
2972
  /**
2973
+ * Generic factory for creating a divisibility check for any numeric type by
2974
+ * supplying a remainder function and a zero value.
2975
+ *
1930
2976
  * @category Numeric checks
1931
2977
  * @since 4.0.0
1932
2978
  */
@@ -2528,6 +3574,58 @@ export const isBetweenBigInt = /*#__PURE__*/makeIsBetween({
2528
3574
  }
2529
3575
  })
2530
3576
  });
3577
+ /**
3578
+ * Validates that a BigDecimal is greater than the specified value (exclusive).
3579
+ *
3580
+ * @category BigDecimal checks
3581
+ * @since 4.0.0
3582
+ */
3583
+ export const isGreaterThanBigDecimal = /*#__PURE__*/makeIsGreaterThan({
3584
+ order: BigDecimal_.Order,
3585
+ formatter: bd => BigDecimal_.format(bd)
3586
+ });
3587
+ /**
3588
+ * Validates that a BigDecimal is greater than or equal to the specified value
3589
+ * (inclusive).
3590
+ *
3591
+ * @category BigDecimal checks
3592
+ * @since 4.0.0
3593
+ */
3594
+ export const isGreaterThanOrEqualToBigDecimal = /*#__PURE__*/makeIsGreaterThanOrEqualTo({
3595
+ order: BigDecimal_.Order,
3596
+ formatter: bd => BigDecimal_.format(bd)
3597
+ });
3598
+ /**
3599
+ * Validates that a BigDecimal is less than the specified value (exclusive).
3600
+ *
3601
+ * @category BigDecimal checks
3602
+ * @since 4.0.0
3603
+ */
3604
+ export const isLessThanBigDecimal = /*#__PURE__*/makeIsLessThan({
3605
+ order: BigDecimal_.Order,
3606
+ formatter: bd => BigDecimal_.format(bd)
3607
+ });
3608
+ /**
3609
+ * Validates that a BigDecimal is less than or equal to the specified value
3610
+ * (inclusive).
3611
+ *
3612
+ * @category BigDecimal checks
3613
+ * @since 4.0.0
3614
+ */
3615
+ export const isLessThanOrEqualToBigDecimal = /*#__PURE__*/makeIsLessThanOrEqualTo({
3616
+ order: BigDecimal_.Order,
3617
+ formatter: bd => BigDecimal_.format(bd)
3618
+ });
3619
+ /**
3620
+ * Validates that a BigDecimal is within a specified range.
3621
+ *
3622
+ * @category BigDecimal checks
3623
+ * @since 4.0.0
3624
+ */
3625
+ export const isBetweenBigDecimal = /*#__PURE__*/makeIsBetween({
3626
+ order: BigDecimal_.Order,
3627
+ formatter: bd => BigDecimal_.format(bd)
3628
+ });
2531
3629
  /**
2532
3630
  * Validates that a value has at least the specified length. Works with strings
2533
3631
  * and arrays.
@@ -2543,6 +3641,14 @@ export const isBetweenBigInt = /*#__PURE__*/makeIsBetween({
2543
3641
  * constraint to ensure generated strings or arrays have at least the required
2544
3642
  * length.
2545
3643
  *
3644
+ * **Example** (Minimum length check)
3645
+ * ```ts
3646
+ * import { Schema } from "effect"
3647
+ *
3648
+ * const NonEmptyStringSchema = Schema.String.check(Schema.isMinLength(1))
3649
+ * const NonEmptyArraySchema = Schema.Array(Schema.Number).check(Schema.isMinLength(1))
3650
+ * ```
3651
+ *
2546
3652
  * @category Length checks
2547
3653
  * @since 4.0.0
2548
3654
  */
@@ -2935,6 +4041,7 @@ export function isPropertyNames(keySchema, annotations) {
2935
4041
  * constraint using the provided equivalence function to ensure generated arrays
2936
4042
  * contain only unique items.
2937
4043
  *
4044
+ * @category Array checks
2938
4045
  * @since 4.0.0
2939
4046
  */
2940
4047
  export function isUnique(annotations) {
@@ -2969,6 +4076,8 @@ export const NonEmptyString = /*#__PURE__*/String.check(/*#__PURE__*/isNonEmpty(
2969
4076
  */
2970
4077
  export const Char = /*#__PURE__*/String.check(/*#__PURE__*/isLengthBetween(1, 1));
2971
4078
  /**
4079
+ * Creates a schema for `Option<A>`. See {@link Option} for details.
4080
+ *
2972
4081
  * @category Option
2973
4082
  * @since 4.0.0
2974
4083
  */
@@ -3041,6 +4150,40 @@ export function Option(value) {
3041
4150
  export function OptionFromNullOr(schema) {
3042
4151
  return NullOr(schema).pipe(decodeTo(Option(toType(schema)), Transformation.optionFromNullOr()));
3043
4152
  }
4153
+ /**
4154
+ * Decodes an undefined-or value `T` to a required `Option<T>` value.
4155
+ *
4156
+ * Decoding:
4157
+ * - `undefined` is decoded as `None`
4158
+ * - other values are decoded as `Some`
4159
+ *
4160
+ * Encoding:
4161
+ * - `None` is encoded as `undefined`
4162
+ * - `Some` is encoded as the value
4163
+ *
4164
+ * @category Option
4165
+ * @since 4.0.0
4166
+ */
4167
+ export function OptionFromUndefinedOr(schema) {
4168
+ return UndefinedOr(schema).pipe(decodeTo(Option(toType(schema)), Transformation.optionFromUndefinedOr()));
4169
+ }
4170
+ /**
4171
+ * Decodes a nullish value `T` to a required `Option<T>` value.
4172
+ *
4173
+ * Decoding:
4174
+ * - `null` and `undefined` are decoded as `None`
4175
+ * - other values are decoded as `Some`
4176
+ *
4177
+ * Encoding:
4178
+ * - `None` is encoded as `null` or `undefined` depending on the provided `options.onNoneEncoding` (defaults to `undefined`)
4179
+ * - `Some` is encoded as the value
4180
+ *
4181
+ * @category Option
4182
+ * @since 4.0.0
4183
+ */
4184
+ export function OptionFromNullishOr(schema, options) {
4185
+ return NullishOr(schema).pipe(decodeTo(Option(toType(schema)), Transformation.optionFromNullishOr(options)));
4186
+ }
3044
4187
  /**
3045
4188
  * Decodes an optional value `A` to a required `Option<A>` value.
3046
4189
  *
@@ -3078,6 +4221,35 @@ export function OptionFromOptional(schema) {
3078
4221
  return optional(schema).pipe(decodeTo(Option(toType(schema)), Transformation.optionFromOptional()));
3079
4222
  }
3080
4223
  /**
4224
+ * Decodes an optional or `null` or `undefined` value `A` to a required `Option<A>`
4225
+ * value.
4226
+ *
4227
+ * Decoding:
4228
+ * - a missing key is decoded as `None`
4229
+ * - a present key with an `undefined` value is decoded as `None`
4230
+ * - a present key with a `null` value is decoded as `None`
4231
+ * - all other values are decoded as `Some`
4232
+ *
4233
+ * Encoding (controlled by `options.onNoneEncoding`):
4234
+ * - `"omit"` (default): `None` is encoded as a missing key
4235
+ * - `null`: `None` is encoded as `null`
4236
+ * - `undefined`: `None` is encoded as `undefined`
4237
+ * - `Some` is always encoded as the value
4238
+ *
4239
+ * @category Option
4240
+ * @since 4.0.0
4241
+ */
4242
+ export function OptionFromOptionalNullOr(schema, options) {
4243
+ const onNoneEncoding = options === undefined ? "omit" : options.onNoneEncoding;
4244
+ const noneValue = onNoneEncoding === null ? null : undefined;
4245
+ return optional(NullOr(schema)).pipe(decodeTo(Option(toType(schema)), Transformation.transformOptional({
4246
+ decode: oe => oe.pipe(Option_.filter(Predicate.isNotNullish), Option_.some),
4247
+ encode: onNoneEncoding === "omit" ? Option_.flatten : ot => Option_.some(Option_.getOrElse(Option_.flatten(ot), () => noneValue))
4248
+ })));
4249
+ }
4250
+ /**
4251
+ * Creates a schema for `Result<A, E>`. See {@link Result} for details.
4252
+ *
3081
4253
  * @category Result
3082
4254
  * @since 4.0.0
3083
4255
  */
@@ -3206,6 +4378,9 @@ export function Redacted(value, options) {
3206
4378
  });
3207
4379
  }
3208
4380
  /**
4381
+ * Middleware that wraps decoded errors in `Redacted`, preventing sensitive
4382
+ * schema details from leaking in error messages.
4383
+ *
3209
4384
  * @category Redacted
3210
4385
  * @since 4.0.0
3211
4386
  */
@@ -3213,6 +4388,10 @@ export function redact(schema) {
3213
4388
  return schema.pipe(middlewareDecoding(Effect.mapErrorEager(Issue.redact)));
3214
4389
  }
3215
4390
  /**
4391
+ * Decodes a value and wraps it in `Redacted<A>`. Unlike {@link Redacted} which
4392
+ * expects the input to already be a `Redacted` instance, this schema decodes
4393
+ * the raw value and wraps it.
4394
+ *
3216
4395
  * @category Redacted
3217
4396
  * @since 4.0.0
3218
4397
  */
@@ -3225,10 +4404,12 @@ export function RedactedFromValue(value, options) {
3225
4404
  }));
3226
4405
  }
3227
4406
  /**
3228
- * @category CauseFailure
4407
+ * Creates a schema for `Cause.Reason<E>`. See {@link CauseReason} for details.
4408
+ *
4409
+ * @category CauseReason
3229
4410
  * @since 4.0.0
3230
4411
  */
3231
- export function CauseFailure(error, defect) {
4412
+ export function CauseReason(error, defect) {
3232
4413
  const schema = declareConstructor()([error, defect], ([error, defect]) => (input, ast, options) => {
3233
4414
  if (!Cause_.isReason(input)) {
3234
4415
  return Effect.fail(new Issue.InvalidType(ast, Option_.some(input)));
@@ -3252,7 +4433,7 @@ export function CauseFailure(error, defect) {
3252
4433
  _tag: "effect/Cause/Failure"
3253
4434
  },
3254
4435
  generation: {
3255
- runtime: `Schema.CauseFailure(?, ?)`,
4436
+ runtime: `Schema.CauseReason(?, ?)`,
3256
4437
  Type: `Cause.Failure<?, ?>`,
3257
4438
  importDeclaration: `import * as Cause from "effect/Cause"`
3258
4439
  },
@@ -3279,16 +4460,16 @@ export function CauseFailure(error, defect) {
3279
4460
  },
3280
4461
  encode: identity
3281
4462
  })),
3282
- toArbitrary: ([error, defect]) => causeFailureToArbitrary(error, defect),
3283
- toEquivalence: ([error, defect]) => causeFailureToEquivalence(error, defect),
3284
- toFormatter: ([error, defect]) => causeFailureToFormatter(error, defect)
4463
+ toArbitrary: ([error, defect]) => causeReasonToArbitrary(error, defect),
4464
+ toEquivalence: ([error, defect]) => causeReasonToEquivalence(error, defect),
4465
+ toFormatter: ([error, defect]) => causeReasonToFormatter(error, defect)
3285
4466
  });
3286
4467
  return make(schema.ast, {
3287
4468
  error,
3288
4469
  defect
3289
4470
  });
3290
4471
  }
3291
- function causeFailureToArbitrary(error, defect) {
4472
+ function causeReasonToArbitrary(error, defect) {
3292
4473
  return (fc, ctx) => {
3293
4474
  return fc.oneof(ctx?.isSuspend ? {
3294
4475
  maxDepth: 2,
@@ -3298,7 +4479,7 @@ function causeFailureToArbitrary(error, defect) {
3298
4479
  }).map(Cause_.makeInterruptReason), error.map(e => Cause_.makeFailReason(e)), defect.map(d => Cause_.makeDieReason(d)));
3299
4480
  };
3300
4481
  }
3301
- function causeFailureToEquivalence(error, defect) {
4482
+ function causeReasonToEquivalence(error, defect) {
3302
4483
  return (a, b) => {
3303
4484
  if (a._tag !== b._tag) return false;
3304
4485
  switch (a._tag) {
@@ -3311,7 +4492,7 @@ function causeFailureToEquivalence(error, defect) {
3311
4492
  }
3312
4493
  };
3313
4494
  }
3314
- function causeFailureToFormatter(error, defect) {
4495
+ function causeReasonToFormatter(error, defect) {
3315
4496
  return t => {
3316
4497
  switch (t._tag) {
3317
4498
  case "Fail":
@@ -3324,19 +4505,23 @@ function causeFailureToFormatter(error, defect) {
3324
4505
  };
3325
4506
  }
3326
4507
  /**
4508
+ * Creates a schema for `Cause<E>`. See {@link Cause} for details.
4509
+ *
3327
4510
  * @category Cause
3328
4511
  * @since 4.0.0
3329
4512
  */
3330
4513
  export function Cause(error, defect) {
3331
- const schema = declareConstructor()([error, defect], ([error, defect]) => (input, ast, options) => {
3332
- if (!Cause_.isCause(input)) {
3333
- return Effect.fail(new Issue.InvalidType(ast, Option_.some(input)));
3334
- }
3335
- const failures = Array(CauseFailure(error, defect));
3336
- return Effect.mapBothEager(Parser.decodeUnknownEffect(failures)(input.reasons, options), {
3337
- onSuccess: Cause_.fromReasons,
3338
- onFailure: issue => new Issue.Composite(ast, Option_.some(input), [new Issue.Pointer(["failures"], issue)])
3339
- });
4514
+ const schema = declareConstructor()([error, defect], ([error, defect]) => {
4515
+ const failures = ArraySchema(CauseReason(error, defect));
4516
+ return (input, ast, options) => {
4517
+ if (!Cause_.isCause(input)) {
4518
+ return Effect.fail(new Issue.InvalidType(ast, Option_.some(input)));
4519
+ }
4520
+ return Effect.mapBothEager(Parser.decodeUnknownEffect(failures)(input.reasons, options), {
4521
+ onSuccess: Cause_.fromReasons,
4522
+ onFailure: issue => new Issue.Composite(ast, Option_.some(input), [new Issue.Pointer(["failures"], issue)])
4523
+ });
4524
+ };
3340
4525
  }, {
3341
4526
  typeConstructor: {
3342
4527
  _tag: "effect/Cause"
@@ -3347,7 +4532,7 @@ export function Cause(error, defect) {
3347
4532
  importDeclaration: `import * as Cause from "effect/Cause"`
3348
4533
  },
3349
4534
  expected: "Cause",
3350
- toCodec: ([error, defect]) => link()(Array(CauseFailure(error, defect)), Transformation.transform({
4535
+ toCodec: ([error, defect]) => link()(ArraySchema(CauseReason(error, defect)), Transformation.transform({
3351
4536
  decode: Cause_.fromReasons,
3352
4537
  encode: ({
3353
4538
  reasons: failures
@@ -3364,16 +4549,16 @@ export function Cause(error, defect) {
3364
4549
  }
3365
4550
  function causeToArbitrary(error, defect) {
3366
4551
  return (fc, ctx) => {
3367
- return fc.array(causeFailureToArbitrary(error, defect)(fc, ctx)).map(Cause_.fromReasons);
4552
+ return fc.array(causeReasonToArbitrary(error, defect)(fc, ctx)).map(Cause_.fromReasons);
3368
4553
  };
3369
4554
  }
3370
4555
  function causeToEquivalence(error, defect) {
3371
- const failures = Equivalence.Array(causeFailureToEquivalence(error, defect));
4556
+ const failures = Equivalence.Array(causeReasonToEquivalence(error, defect));
3372
4557
  return (a, b) => failures(a.reasons, b.reasons);
3373
4558
  }
3374
4559
  function causeToFormatter(error, defect) {
3375
- const causeFailure = causeFailureToFormatter(error, defect);
3376
- return t => `Cause([${t.reasons.map(causeFailure).join(", ")}])`;
4560
+ const causeReason = causeReasonToFormatter(error, defect);
4561
+ return t => `Cause([${t.reasons.map(causeReason).join(", ")}])`;
3377
4562
  }
3378
4563
  const ErrorJsonEncoded = /*#__PURE__*/Struct({
3379
4564
  message: String,
@@ -3455,27 +4640,31 @@ export const DefectWithStack = /*#__PURE__*/Union([/*#__PURE__*/ErrorJsonEncoded
3455
4640
  toArbitrary: () => fc => fc.json()
3456
4641
  }), defectTransformation))]);
3457
4642
  /**
4643
+ * Creates a schema for `Exit<A, E>`. See {@link Exit} for details.
4644
+ *
3458
4645
  * @category Exit
3459
4646
  * @since 4.0.0
3460
4647
  */
3461
4648
  export function Exit(value, error, defect) {
3462
- const schema = declareConstructor()([value, error, defect], ([value, error, defect]) => (input, ast, options) => {
3463
- if (!Exit_.isExit(input)) {
3464
- return Effect.fail(new Issue.InvalidType(ast, Option_.some(input)));
3465
- }
4649
+ const schema = declareConstructor()([value, error, defect], ([value, error, defect]) => {
3466
4650
  const cause = Cause(error, defect);
3467
- switch (input._tag) {
3468
- case "Success":
3469
- return Effect.mapBothEager(Parser.decodeUnknownEffect(value)(input.value, options), {
3470
- onSuccess: Exit_.succeed,
3471
- onFailure: issue => new Issue.Composite(ast, Option_.some(input), [new Issue.Pointer(["value"], issue)])
3472
- });
3473
- case "Failure":
3474
- return Effect.mapBothEager(Parser.decodeUnknownEffect(cause)(input.cause, options), {
3475
- onSuccess: Exit_.failCause,
3476
- onFailure: issue => new Issue.Composite(ast, Option_.some(input), [new Issue.Pointer(["cause"], issue)])
3477
- });
3478
- }
4651
+ return (input, ast, options) => {
4652
+ if (!Exit_.isExit(input)) {
4653
+ return Effect.fail(new Issue.InvalidType(ast, Option_.some(input)));
4654
+ }
4655
+ switch (input._tag) {
4656
+ case "Success":
4657
+ return Effect.mapBothEager(Parser.decodeUnknownEffect(value)(input.value, options), {
4658
+ onSuccess: Exit_.succeed,
4659
+ onFailure: issue => new Issue.Composite(ast, Option_.some(input), [new Issue.Pointer(["value"], issue)])
4660
+ });
4661
+ case "Failure":
4662
+ return Effect.mapBothEager(Parser.decodeUnknownEffect(cause)(input.cause, options), {
4663
+ onSuccess: Exit_.failCause,
4664
+ onFailure: issue => new Issue.Composite(ast, Option_.some(input), [new Issue.Pointer(["cause"], issue)])
4665
+ });
4666
+ }
4667
+ };
3479
4668
  }, {
3480
4669
  typeConstructor: {
3481
4670
  _tag: "effect/Exit"
@@ -3544,90 +4733,252 @@ export function Exit(value, error, defect) {
3544
4733
  * @since 4.0.0
3545
4734
  */
3546
4735
  export function ReadonlyMap(key, value) {
3547
- const schema = declareConstructor()([key, value], ([key, value]) => (input, ast, options) => {
3548
- if (input instanceof globalThis.Map) {
3549
- const array = Array(Tuple([key, value]));
3550
- return Effect.mapBothEager(Parser.decodeUnknownEffect(array)([...input], options), {
3551
- onSuccess: array => new globalThis.Map(array),
3552
- onFailure: issue => new Issue.Composite(ast, Option_.some(input), [new Issue.Pointer(["entries"], issue)])
3553
- });
4736
+ const schema = declareConstructor()([key, value], ([key, value]) => {
4737
+ const array = ArraySchema(Tuple([key, value]));
4738
+ return (input, ast, options) => {
4739
+ if (input instanceof globalThis.Map) {
4740
+ return Effect.mapBothEager(Parser.decodeUnknownEffect(array)([...input], options), {
4741
+ onSuccess: array => new globalThis.Map(array),
4742
+ onFailure: issue => new Issue.Composite(ast, Option_.some(input), [new Issue.Pointer(["entries"], issue)])
4743
+ });
4744
+ }
4745
+ return Effect.fail(new Issue.InvalidType(ast, Option_.some(input)));
4746
+ };
4747
+ }, {
4748
+ typeConstructor: {
4749
+ _tag: "ReadonlyMap"
4750
+ },
4751
+ generation: {
4752
+ runtime: `Schema.ReadonlyMap(?, ?)`,
4753
+ Type: `globalThis.ReadonlyMap<?, ?>`
4754
+ },
4755
+ expected: "ReadonlyMap",
4756
+ toCodec: ([key, value]) => link()(ArraySchema(Tuple([key, value])), Transformation.transform({
4757
+ decode: e => new globalThis.Map(e),
4758
+ encode: map => [...map.entries()]
4759
+ })),
4760
+ toArbitrary: ([key, value]) => (fc, ctx) => {
4761
+ return fc.oneof(ctx?.isSuspend ? {
4762
+ maxDepth: 2,
4763
+ depthIdentifier: "ReadonlyMap"
4764
+ } : {}, fc.constant([]), fc.array(fc.tuple(key, value), ctx?.constraints?.array)).map(as => new globalThis.Map(as));
4765
+ },
4766
+ toEquivalence: ([key, value]) => Equal.makeCompareMap(key, value),
4767
+ toFormatter: ([key, value]) => t => {
4768
+ const size = t.size;
4769
+ if (size === 0) {
4770
+ return "ReadonlyMap(0) {}";
4771
+ }
4772
+ const entries = globalThis.Array.from(t.entries()).sort().map(([k, v]) => `${key(k)} => ${value(v)}`);
4773
+ return `ReadonlyMap(${size}) { ${entries.join(", ")} }`;
3554
4774
  }
3555
- return Effect.fail(new Issue.InvalidType(ast, Option_.some(input)));
4775
+ });
4776
+ return make(schema.ast, {
4777
+ key,
4778
+ value
4779
+ });
4780
+ }
4781
+ /**
4782
+ * Creates a schema that validates a `HashMap` where keys and values must
4783
+ * conform to the provided schemas.
4784
+ *
4785
+ * @category HashMap
4786
+ * @since 4.0.0
4787
+ */
4788
+ export function HashMap(key, value) {
4789
+ const schema = declareConstructor()([key, value], ([key, value]) => {
4790
+ const entries = ArraySchema(Tuple([key, value]));
4791
+ return (input, ast, options) => {
4792
+ if (HashMap_.isHashMap(input)) {
4793
+ return Effect.mapBothEager(Parser.decodeUnknownEffect(entries)(HashMap_.toEntries(input), options), {
4794
+ onSuccess: HashMap_.fromIterable,
4795
+ onFailure: issue => new Issue.Composite(ast, Option_.some(input), [new Issue.Pointer(["entries"], issue)])
4796
+ });
4797
+ }
4798
+ return Effect.fail(new Issue.InvalidType(ast, Option_.some(input)));
4799
+ };
4800
+ }, {
4801
+ typeConstructor: {
4802
+ _tag: "effect/HashMap"
4803
+ },
4804
+ generation: {
4805
+ runtime: `Schema.HashMap(?, ?)`,
4806
+ Type: `HashMap.HashMap<?, ?>`,
4807
+ importDeclaration: `import * as HashMap from "effect/HashMap"`
4808
+ },
4809
+ expected: "HashMap",
4810
+ toCodec: ([key, value]) => link()(ArraySchema(Tuple([key, value])), Transformation.transform({
4811
+ decode: HashMap_.fromIterable,
4812
+ encode: HashMap_.toEntries
4813
+ })),
4814
+ toArbitrary: ([key, value]) => (fc, ctx) => {
4815
+ return fc.oneof(ctx?.isSuspend ? {
4816
+ maxDepth: 2,
4817
+ depthIdentifier: "HashMap"
4818
+ } : {}, fc.constant([]), fc.array(fc.tuple(key, value), ctx?.constraints?.array)).map(HashMap_.fromIterable);
4819
+ },
4820
+ toEquivalence: ([key, value]) => Equal.makeCompareMap(key, value),
4821
+ toFormatter: ([key, value]) => t => {
4822
+ const size = HashMap_.size(t);
4823
+ if (size === 0) {
4824
+ return "HashMap(0) {}";
4825
+ }
4826
+ const entries = HashMap_.toEntries(t).sort().map(([k, v]) => `${key(k)} => ${value(v)}`);
4827
+ return `HashMap(${size}) { ${entries.join(", ")} }`;
4828
+ }
4829
+ });
4830
+ return make(schema.ast, {
4831
+ key,
4832
+ value
4833
+ });
4834
+ }
4835
+ /**
4836
+ * @category ReadonlySet
4837
+ * @since 4.0.0
4838
+ */
4839
+ export function ReadonlySet(value) {
4840
+ const schema = declareConstructor()([value], ([value]) => {
4841
+ const array = ArraySchema(value);
4842
+ return (input, ast, options) => {
4843
+ if (input instanceof globalThis.Set) {
4844
+ return Effect.mapBothEager(Parser.decodeUnknownEffect(array)([...input], options), {
4845
+ onSuccess: array => new globalThis.Set(array),
4846
+ onFailure: issue => new Issue.Composite(ast, Option_.some(input), [new Issue.Pointer(["values"], issue)])
4847
+ });
4848
+ }
4849
+ return Effect.fail(new Issue.InvalidType(ast, Option_.some(input)));
4850
+ };
4851
+ }, {
4852
+ typeConstructor: {
4853
+ _tag: "ReadonlySet"
4854
+ },
4855
+ generation: {
4856
+ runtime: `Schema.ReadonlySet(?)`,
4857
+ Type: `globalThis.ReadonlySet<?>`
4858
+ },
4859
+ expected: "ReadonlySet",
4860
+ toCodec: ([value]) => link()(ArraySchema(value), Transformation.transform({
4861
+ decode: e => new globalThis.Set(e),
4862
+ encode: set => [...set.values()]
4863
+ })),
4864
+ toArbitrary: ([value]) => (fc, ctx) => {
4865
+ return fc.oneof(ctx?.isSuspend ? {
4866
+ maxDepth: 2,
4867
+ depthIdentifier: "ReadonlySet"
4868
+ } : {}, fc.constant([]), fc.array(value, ctx?.constraints?.array)).map(as => new globalThis.Set(as));
4869
+ },
4870
+ toEquivalence: ([value]) => Equal.makeCompareSet(value),
4871
+ toFormatter: ([value]) => t => {
4872
+ const size = t.size;
4873
+ if (size === 0) {
4874
+ return "ReadonlySet(0) {}";
4875
+ }
4876
+ const values = globalThis.Array.from(t.values()).sort().map(v => `${value(v)}`);
4877
+ return `ReadonlySet(${size}) { ${values.join(", ")} }`;
4878
+ }
4879
+ });
4880
+ return make(schema.ast, {
4881
+ value
4882
+ });
4883
+ }
4884
+ /**
4885
+ * Creates a schema that validates a `HashSet` where values must conform to the
4886
+ * provided schema.
4887
+ *
4888
+ * @category HashSet
4889
+ * @since 4.0.0
4890
+ */
4891
+ export function HashSet(value) {
4892
+ const schema = declareConstructor()([value], ([value]) => {
4893
+ const values = ArraySchema(value);
4894
+ return (input, ast, options) => {
4895
+ if (HashSet_.isHashSet(input)) {
4896
+ return Effect.mapBothEager(Parser.decodeUnknownEffect(values)(Arr.fromIterable(input), options), {
4897
+ onSuccess: HashSet_.fromIterable,
4898
+ onFailure: issue => new Issue.Composite(ast, Option_.some(input), [new Issue.Pointer(["values"], issue)])
4899
+ });
4900
+ }
4901
+ return Effect.fail(new Issue.InvalidType(ast, Option_.some(input)));
4902
+ };
3556
4903
  }, {
3557
4904
  typeConstructor: {
3558
- _tag: "ReadonlyMap"
4905
+ _tag: "effect/HashSet"
3559
4906
  },
3560
4907
  generation: {
3561
- runtime: `Schema.ReadonlyMap(?, ?)`,
3562
- Type: `globalThis.ReadonlyMap<?, ?>`
4908
+ runtime: `Schema.HashSet(?)`,
4909
+ Type: `HashSet.HashSet<?>`
3563
4910
  },
3564
- expected: "ReadonlyMap",
3565
- toCodec: ([key, value]) => link()(Array(Tuple([key, value])), Transformation.transform({
3566
- decode: e => new globalThis.Map(e),
3567
- encode: map => [...map.entries()]
4911
+ expected: "HashSet",
4912
+ toCodec: ([value]) => link()(ArraySchema(value), Transformation.transform({
4913
+ decode: HashSet_.fromIterable,
4914
+ encode: Arr.fromIterable
3568
4915
  })),
3569
- toArbitrary: ([key, value]) => (fc, ctx) => {
4916
+ toArbitrary: ([value]) => (fc, ctx) => {
3570
4917
  return fc.oneof(ctx?.isSuspend ? {
3571
4918
  maxDepth: 2,
3572
- depthIdentifier: "ReadonlyMap"
3573
- } : {}, fc.constant([]), fc.array(fc.tuple(key, value), ctx?.constraints?.array)).map(as => new globalThis.Map(as));
4919
+ depthIdentifier: "HashSet"
4920
+ } : {}, fc.constant([]), fc.array(value, ctx?.constraints?.array)).map(HashSet_.fromIterable);
3574
4921
  },
3575
- toEquivalence: ([key, value]) => Equal.makeCompareMap(key, value),
3576
- toFormatter: ([key, value]) => t => {
3577
- const size = t.size;
4922
+ toEquivalence: ([value]) => Equal.makeCompareSet(value),
4923
+ toFormatter: ([value]) => t => {
4924
+ const size = HashSet_.size(t);
3578
4925
  if (size === 0) {
3579
- return "ReadonlyMap(0) {}";
4926
+ return "HashSet(0) {}";
3580
4927
  }
3581
- const entries = globalThis.Array.from(t.entries()).sort().map(([k, v]) => `${key(k)} => ${value(v)}`);
3582
- return `ReadonlyMap(${size}) { ${entries.join(", ")} }`;
4928
+ const values = globalThis.Array.from(t).sort().map(v => `${value(v)}`);
4929
+ return `HashSet(${size}) { ${values.join(", ")} }`;
3583
4930
  }
3584
4931
  });
3585
4932
  return make(schema.ast, {
3586
- key,
3587
4933
  value
3588
4934
  });
3589
4935
  }
3590
4936
  /**
3591
- * @category ReadonlySet
4937
+ * Creates a schema that validates a `Chunk` where values must conform to the
4938
+ * provided schema.
4939
+ *
4940
+ * @category Chunk
3592
4941
  * @since 4.0.0
3593
4942
  */
3594
- export function ReadonlySet(value) {
3595
- const schema = declareConstructor()([value], ([value]) => (input, ast, options) => {
3596
- if (input instanceof globalThis.Set) {
3597
- const array = Array(value);
3598
- return Effect.mapBothEager(Parser.decodeUnknownEffect(array)([...input], options), {
3599
- onSuccess: array => new globalThis.Set(array),
3600
- onFailure: issue => new Issue.Composite(ast, Option_.some(input), [new Issue.Pointer(["values"], issue)])
3601
- });
3602
- }
3603
- return Effect.fail(new Issue.InvalidType(ast, Option_.some(input)));
4943
+ export function Chunk(value) {
4944
+ const schema = declareConstructor()([value], ([value]) => {
4945
+ const values = ArraySchema(value);
4946
+ return (input, ast, options) => {
4947
+ if (Chunk_.isChunk(input)) {
4948
+ return Effect.mapBothEager(Parser.decodeUnknownEffect(values)(Arr.fromIterable(input), options), {
4949
+ onSuccess: Chunk_.fromIterable,
4950
+ onFailure: issue => new Issue.Composite(ast, Option_.some(input), [new Issue.Pointer(["values"], issue)])
4951
+ });
4952
+ }
4953
+ return Effect.fail(new Issue.InvalidType(ast, Option_.some(input)));
4954
+ };
3604
4955
  }, {
3605
4956
  typeConstructor: {
3606
- _tag: "ReadonlySet"
4957
+ _tag: "effect/Chunk"
3607
4958
  },
3608
4959
  generation: {
3609
- runtime: `Schema.ReadonlySet(?)`,
3610
- Type: `globalThis.ReadonlySet<?>`
4960
+ runtime: `Schema.Chunk(?)`,
4961
+ Type: `Chunk.Chunk<?>`
3611
4962
  },
3612
- expected: "ReadonlySet",
3613
- toCodec: ([value]) => link()(Array(value), Transformation.transform({
3614
- decode: e => new globalThis.Set(e),
3615
- encode: set => [...set.values()]
4963
+ expected: "Chunk",
4964
+ toCodec: ([value]) => link()(ArraySchema(value), Transformation.transform({
4965
+ decode: Chunk_.fromIterable,
4966
+ encode: Arr.fromIterable
3616
4967
  })),
3617
4968
  toArbitrary: ([value]) => (fc, ctx) => {
3618
4969
  return fc.oneof(ctx?.isSuspend ? {
3619
4970
  maxDepth: 2,
3620
- depthIdentifier: "ReadonlySet"
3621
- } : {}, fc.constant([]), fc.array(value, ctx?.constraints?.array)).map(as => new globalThis.Set(as));
4971
+ depthIdentifier: "Chunk"
4972
+ } : {}, fc.constant([]), fc.array(value, ctx?.constraints?.array)).map(Chunk_.fromIterable);
3622
4973
  },
3623
- toEquivalence: ([value]) => Equal.makeCompareSet(value),
4974
+ toEquivalence: ([value]) => Chunk_.makeEquivalence(value),
3624
4975
  toFormatter: ([value]) => t => {
3625
- const size = t.size;
4976
+ const size = Chunk_.size(t);
3626
4977
  if (size === 0) {
3627
- return "ReadonlySet(0) {}";
4978
+ return "Chunk(0) {}";
3628
4979
  }
3629
- const values = globalThis.Array.from(t.values()).sort().map(v => `${value(v)}`);
3630
- return `ReadonlySet(${size}) { ${values.join(", ")} }`;
4980
+ const values = globalThis.Array.from(t).sort().map(v => `${value(v)}`);
4981
+ return `Chunk(${size}) { ${values.join(", ")} }`;
3631
4982
  }
3632
4983
  });
3633
4984
  return make(schema.ast, {
@@ -3635,6 +4986,11 @@ export function ReadonlySet(value) {
3635
4986
  });
3636
4987
  }
3637
4988
  /**
4989
+ * Schema for JavaScript `RegExp` objects.
4990
+ *
4991
+ * The default JSON serializer encodes a `RegExp` as `{ source, flags }`.
4992
+ *
4993
+ * @category Schemas
3638
4994
  * @since 4.0.0
3639
4995
  */
3640
4996
  export const RegExp = /*#__PURE__*/instanceOf(globalThis.RegExp, {
@@ -3712,8 +5068,19 @@ export const URLFromString = /*#__PURE__*/String.annotate({
3712
5068
  * A schema for JavaScript `Date` objects.
3713
5069
  *
3714
5070
  * This schema accepts any `Date` instance, including invalid dates (e.g., `new
3715
- * Date("invalid")`). For validating only valid dates, use `ValidDate` instead.
5071
+ * Date("invalid")`). For validating only valid dates, use {@link DateValid}
5072
+ * instead. The default JSON serializer encodes `Date` as an ISO 8601 string.
5073
+ *
5074
+ * **Example** (Date schema)
5075
+ *
5076
+ * ```ts
5077
+ * import { Schema } from "effect"
5078
+ *
5079
+ * Schema.decodeUnknownSync(Schema.Date)(new Date("2024-01-01"))
5080
+ * // => Date { 2024-01-01T00:00:00.000Z }
5081
+ * ```
3716
5082
  *
5083
+ * @category Schemas
3717
5084
  * @since 4.0.0
3718
5085
  */
3719
5086
  export const Date = /*#__PURE__*/instanceOf(globalThis.Date, {
@@ -3745,9 +5112,20 @@ export const DateValid = /*#__PURE__*/Date.check(/*#__PURE__*/isDateValid());
3745
5112
  /**
3746
5113
  * A schema for `Duration` values.
3747
5114
  *
3748
- * **Default JSON serializer**
5115
+ * The default JSON serializer encodes `Duration` as a tagged object with the
5116
+ * duration type and value.
5117
+ *
5118
+ * **Example** (Duration schema)
5119
+ *
5120
+ * ```ts
5121
+ * import { Schema } from "effect"
5122
+ * import { Duration } from "effect"
5123
+ *
5124
+ * Schema.decodeUnknownSync(Schema.Duration)(Duration.seconds(5))
5125
+ * // => Duration(5s)
5126
+ * ```
3749
5127
  *
3750
- * - encodes `Duration` as a `string`
5128
+ * @category Duration
3751
5129
  *
3752
5130
  * @since 4.0.0
3753
5131
  */
@@ -3842,6 +5220,35 @@ export const DurationFromNanos = /*#__PURE__*/BigInt.check(isGreaterThanOrEqualT
3842
5220
  * @since 4.0.0
3843
5221
  */
3844
5222
  export const DurationFromMillis = /*#__PURE__*/Number.check(isGreaterThanOrEqualTo(0)).pipe(/*#__PURE__*/decodeTo(Duration, Transformation.durationFromMillis));
5223
+ /**
5224
+ * A schema for `BigDecimal` values.
5225
+ *
5226
+ * **Default JSON serializer**
5227
+ *
5228
+ * - encodes `BigDecimal` as a `string`
5229
+ *
5230
+ * @since 4.0.0
5231
+ */
5232
+ export const BigDecimal = /*#__PURE__*/declare(BigDecimal_.isBigDecimal, {
5233
+ typeConstructor: {
5234
+ _tag: "effect/BigDecimal"
5235
+ },
5236
+ generation: {
5237
+ runtime: `Schema.BigDecimal`,
5238
+ Type: `BigDecimal.BigDecimal`,
5239
+ importDeclaration: `import * as BigDecimal from "effect/BigDecimal"`
5240
+ },
5241
+ expected: "BigDecimal",
5242
+ toCodecJson: () => link()(String.annotate({
5243
+ expected: "a string that will be decoded as a BigDecimal"
5244
+ }), Transformation.bigDecimalFromString),
5245
+ toArbitrary: () => fc => fc.tuple(fc.bigInt(), fc.integer({
5246
+ min: 0,
5247
+ max: 20
5248
+ })).map(([value, scale]) => BigDecimal_.make(value, scale)),
5249
+ toFormatter: () => bd => BigDecimal_.format(bd),
5250
+ toEquivalence: () => BigDecimal_.Equivalence
5251
+ });
3845
5252
  /**
3846
5253
  * A transformation schema that decodes a JSON-encoded string into an `unknown` value.
3847
5254
  *
@@ -3936,6 +5343,12 @@ export function fromJsonString(schema) {
3936
5343
  }).pipe(decodeTo(schema, Transformation.fromJsonString));
3937
5344
  }
3938
5345
  /**
5346
+ * Schema for JavaScript `File` objects.
5347
+ *
5348
+ * The default JSON serializer encodes a `File` as `{ data, type, name, lastModified }`
5349
+ * where `data` is base64-encoded.
5350
+ *
5351
+ * @category Schemas
3939
5352
  * @since 4.0.0
3940
5353
  */
3941
5354
  export const File = /*#__PURE__*/instanceOf(globalThis.File, {
@@ -3953,7 +5366,7 @@ export const File = /*#__PURE__*/instanceOf(globalThis.File, {
3953
5366
  name: String,
3954
5367
  lastModified: Number
3955
5368
  }), Transformation.transformOrFail({
3956
- decode: e => Result_.match(Base64.decode(e.data), {
5369
+ decode: e => Result_.match(Encoding.decodeBase64(e.data), {
3957
5370
  onFailure: error => Effect.fail(new Issue.InvalidValue(Option_.some(e.data), {
3958
5371
  message: error.message
3959
5372
  })),
@@ -3969,7 +5382,7 @@ export const File = /*#__PURE__*/instanceOf(globalThis.File, {
3969
5382
  try: async () => {
3970
5383
  const bytes = new globalThis.Uint8Array(await file.arrayBuffer());
3971
5384
  return {
3972
- data: Base64.encode(bytes),
5385
+ data: Encoding.encodeBase64(bytes),
3973
5386
  type: file.type,
3974
5387
  name: file.name,
3975
5388
  lastModified: file.lastModified
@@ -3982,6 +5395,12 @@ export const File = /*#__PURE__*/instanceOf(globalThis.File, {
3982
5395
  }))
3983
5396
  });
3984
5397
  /**
5398
+ * Schema for JavaScript `FormData` objects.
5399
+ *
5400
+ * The default JSON serializer encodes a `FormData` as an array of `[key, entry]`
5401
+ * pairs where each entry is tagged as `"String"` or `"File"`.
5402
+ *
5403
+ * @category Schemas
3985
5404
  * @since 4.0.0
3986
5405
  */
3987
5406
  export const FormData = /*#__PURE__*/instanceOf(globalThis.FormData, {
@@ -3993,7 +5412,7 @@ export const FormData = /*#__PURE__*/instanceOf(globalThis.FormData, {
3993
5412
  Type: `globalThis.FormData`
3994
5413
  },
3995
5414
  expected: "FormData",
3996
- toCodecJson: () => link()(Array(Tuple([String, Union([Struct({
5415
+ toCodecJson: () => link()(ArraySchema(Tuple([String, Union([Struct({
3997
5416
  _tag: tag("String"),
3998
5417
  value: String
3999
5418
  }), Struct({
@@ -4111,6 +5530,11 @@ export function fromFormData(schema) {
4111
5530
  return FormData.pipe(decodeTo(schema, Transformation.fromFormData));
4112
5531
  }
4113
5532
  /**
5533
+ * Schema for JavaScript `URLSearchParams` objects.
5534
+ *
5535
+ * The default JSON serializer encodes a `URLSearchParams` as a query string.
5536
+ *
5537
+ * @category Schemas
4114
5538
  * @since 4.0.0
4115
5539
  */
4116
5540
  export const URLSearchParams = /*#__PURE__*/instanceOf(globalThis.URLSearchParams, {
@@ -4268,6 +5692,9 @@ export const Trim = /*#__PURE__*/String.annotate({
4268
5692
  expected: "a string that will be decoded as a trimmed string"
4269
5693
  }).pipe(/*#__PURE__*/decodeTo(Trimmed, /*#__PURE__*/Transformation.trim()));
4270
5694
  /**
5695
+ * A union schema for JavaScript property keys: `number | symbol | string`.
5696
+ *
5697
+ * @category Schemas
4271
5698
  * @since 4.0.0
4272
5699
  */
4273
5700
  export const PropertyKey = /*#__PURE__*/Union([Finite, Symbol, String]);
@@ -4275,9 +5702,9 @@ export const PropertyKey = /*#__PURE__*/Union([Finite, Symbol, String]);
4275
5702
  * @since 4.0.0
4276
5703
  */
4277
5704
  export const StandardSchemaV1FailureResult = /*#__PURE__*/Struct({
4278
- issues: /*#__PURE__*/Array(/*#__PURE__*/Struct({
5705
+ issues: /*#__PURE__*/ArraySchema(/*#__PURE__*/Struct({
4279
5706
  message: String,
4280
- path: /*#__PURE__*/optional(/*#__PURE__*/Array(/*#__PURE__*/Union([PropertyKey, /*#__PURE__*/Struct({
5707
+ path: /*#__PURE__*/optional(/*#__PURE__*/ArraySchema(/*#__PURE__*/Union([PropertyKey, /*#__PURE__*/Struct({
4281
5708
  key: PropertyKey
4282
5709
  })])))
4283
5710
  }))
@@ -4383,7 +5810,7 @@ export const Uint8ArrayFromHex = /*#__PURE__*/String.annotate({
4383
5810
  */
4384
5811
  export const DateTimeUtc = /*#__PURE__*/declare(u => DateTime.isDateTime(u) && DateTime.isUtc(u), {
4385
5812
  typeConstructor: {
4386
- _tag: "DateTime.Utc"
5813
+ _tag: "effect/DateTime.Utc"
4387
5814
  },
4388
5815
  generation: {
4389
5816
  runtime: `Schema.DateTimeUtc`,
@@ -4391,10 +5818,7 @@ export const DateTimeUtc = /*#__PURE__*/declare(u => DateTime.isDateTime(u) && D
4391
5818
  importDeclaration: `import * as DateTime from "effect/DateTime"`
4392
5819
  },
4393
5820
  expected: "DateTime.Utc",
4394
- toCodecJson: () => link()(String, {
4395
- decode: Getter.dateTimeUtcFromInput(),
4396
- encode: Getter.transform(DateTime.formatIso)
4397
- }),
5821
+ toCodecJson: () => link()(String, Transformation.dateTimeUtcFromString),
4398
5822
  toArbitrary: () => (fc, ctx) => fc.date({
4399
5823
  noInvalidDate: true,
4400
5824
  ...ctx?.constraints?.date
@@ -4434,10 +5858,7 @@ export const DateTimeUtcFromDate = /*#__PURE__*/DateValid.pipe(/*#__PURE__*/deco
4434
5858
  */
4435
5859
  export const DateTimeUtcFromString = /*#__PURE__*/String.annotate({
4436
5860
  expected: "a string that will be decoded as a DateTime.Utc"
4437
- }).pipe(/*#__PURE__*/decodeTo(DateTimeUtc, /*#__PURE__*/Transformation.transform({
4438
- decode: DateTime.makeUnsafe,
4439
- encode: DateTime.formatIso
4440
- })));
5861
+ }).pipe(/*#__PURE__*/decodeTo(DateTimeUtc, Transformation.dateTimeUtcFromString));
4441
5862
  /**
4442
5863
  * A transformation schema that decodes a number into a `DateTime.Utc`.
4443
5864
  *
@@ -4454,24 +5875,142 @@ export const DateTimeUtcFromMillis = /*#__PURE__*/Number.pipe(/*#__PURE__*/decod
4454
5875
  decode: /*#__PURE__*/Getter.dateTimeUtcFromInput(),
4455
5876
  encode: /*#__PURE__*/Getter.transform(DateTime.toEpochMillis)
4456
5877
  }));
5878
+ /**
5879
+ * A schema for `DateTime.TimeZone.Offset` values.
5880
+ *
5881
+ * **Default JSON serializer**
5882
+ *
5883
+ * - encodes `DateTime.TimeZone.Offset` as a number (offset in milliseconds)
5884
+ *
5885
+ * @category DateTime
5886
+ * @since 4.0.0
5887
+ */
5888
+ export const TimeZoneOffset = /*#__PURE__*/declare(DateTime.isTimeZoneOffset, {
5889
+ typeConstructor: {
5890
+ _tag: "effect/DateTime.TimeZone.Offset"
5891
+ },
5892
+ generation: {
5893
+ runtime: `Schema.TimeZoneOffset`,
5894
+ Type: `DateTime.TimeZone.Offset`,
5895
+ importDeclaration: `import * as DateTime from "effect/DateTime"`
5896
+ },
5897
+ expected: "DateTime.TimeZone.Offset",
5898
+ toCodecJson: () => link()(Number, Transformation.timeZoneOffsetFromNumber),
5899
+ toArbitrary: () => fc => fc.integer({
5900
+ min: -12 * 60 * 60 * 1000,
5901
+ max: 14 * 60 * 60 * 1000
5902
+ }).map(n => DateTime.zoneMakeOffset(n)),
5903
+ toFormatter: () => tz => DateTime.zoneToString(tz),
5904
+ toEquivalence: () => (a, b) => a.offset === b.offset
5905
+ });
5906
+ /**
5907
+ * A schema for `DateTime.TimeZone.Named` values.
5908
+ *
5909
+ * **Default JSON serializer**
5910
+ *
5911
+ * - encodes `DateTime.TimeZone.Named` as a string (IANA time zone identifier)
5912
+ *
5913
+ * @category DateTime
5914
+ * @since 4.0.0
5915
+ */
5916
+ export const TimeZoneNamed = /*#__PURE__*/declare(DateTime.isTimeZoneNamed, {
5917
+ typeConstructor: {
5918
+ _tag: "effect/DateTime.TimeZone.Named"
5919
+ },
5920
+ generation: {
5921
+ runtime: `Schema.TimeZoneNamed`,
5922
+ Type: `DateTime.TimeZone.Named`,
5923
+ importDeclaration: `import * as DateTime from "effect/DateTime"`
5924
+ },
5925
+ expected: "DateTime.TimeZone.Named",
5926
+ toCodecJson: () => link()(String.annotate({
5927
+ expected: "an IANA time zone identifier"
5928
+ }), Transformation.timeZoneNamedFromString),
5929
+ toArbitrary: () => fc => fc.constantFrom(...["UTC", "Europe/London", "America/New_York", "Asia/Tokyo", "Australia/Sydney"].map(DateTime.zoneMakeNamedUnsafe)),
5930
+ toFormatter: () => tz => DateTime.zoneToString(tz),
5931
+ toEquivalence: () => (a, b) => a.id === b.id
5932
+ });
5933
+ /**
5934
+ * A schema for `DateTime.TimeZone` values.
5935
+ *
5936
+ * **Default JSON serializer**
5937
+ *
5938
+ * - encodes `DateTime.TimeZone` as a string (IANA identifier or offset like
5939
+ * `+03:00`)
5940
+ *
5941
+ * @category DateTime
5942
+ * @since 4.0.0
5943
+ */
5944
+ export const TimeZone = /*#__PURE__*/declare(DateTime.isTimeZone, {
5945
+ typeConstructor: {
5946
+ _tag: "effect/DateTime.TimeZone"
5947
+ },
5948
+ generation: {
5949
+ runtime: `Schema.TimeZone`,
5950
+ Type: `DateTime.TimeZone`,
5951
+ importDeclaration: `import * as DateTime from "effect/DateTime"`
5952
+ },
5953
+ expected: "DateTime.TimeZone",
5954
+ toCodecJson: () => link()(String.annotate({
5955
+ expected: "a time zone string (IANA identifier or offset like +03:00)"
5956
+ }), Transformation.timeZoneFromString),
5957
+ toArbitrary: () => fc => fc.oneof(fc.integer({
5958
+ min: -12 * 60 * 60 * 1000,
5959
+ max: 14 * 60 * 60 * 1000
5960
+ }).map(n => DateTime.zoneMakeOffset(n)), fc.constantFrom(...["UTC", "Europe/London", "America/New_York", "Asia/Tokyo", "Australia/Sydney"].map(DateTime.zoneMakeNamedUnsafe))),
5961
+ toFormatter: () => tz => DateTime.zoneToString(tz),
5962
+ toEquivalence: () => (a, b) => DateTime.zoneToString(a) === DateTime.zoneToString(b)
5963
+ });
5964
+ /**
5965
+ * A schema for `DateTime.Zoned` values.
5966
+ *
5967
+ * **Default JSON serializer**
5968
+ *
5969
+ * - encodes `DateTime.Zoned` as a string in the format
5970
+ * `YYYY-MM-DDTHH:mm:ss.sss+HH:MM[Time/Zone]`
5971
+ *
5972
+ * @category DateTime
5973
+ * @since 4.0.0
5974
+ */
5975
+ export const DateTimeZoned = /*#__PURE__*/declare(u => DateTime.isDateTime(u) && DateTime.isZoned(u), {
5976
+ typeConstructor: {
5977
+ _tag: "effect/DateTime.Zoned"
5978
+ },
5979
+ generation: {
5980
+ runtime: `Schema.DateTimeZoned`,
5981
+ Type: `DateTime.Zoned`,
5982
+ importDeclaration: `import * as DateTime from "effect/DateTime"`
5983
+ },
5984
+ expected: "DateTime.Zoned",
5985
+ toCodecJson: () => link()(String.annotate({
5986
+ expected: "a zoned DateTime string (e.g. 2024-01-01T00:00:00.000+00:00[Europe/London])"
5987
+ }), Transformation.dateTimeZonedFromString),
5988
+ toArbitrary: () => (fc, ctx) => fc.tuple(fc.date({
5989
+ noInvalidDate: true,
5990
+ min: new globalThis.Date(-8640000000000000 + 14 * 60 * 60 * 1000),
5991
+ max: new globalThis.Date(8640000000000000 - 14 * 60 * 60 * 1000),
5992
+ ...ctx?.constraints?.date
5993
+ }), fc.constantFrom("UTC", "Europe/London", "America/New_York", "Asia/Tokyo", "Australia/Sydney")).map(([date, zone]) => DateTime.makeZonedUnsafe(date, {
5994
+ timeZone: zone
5995
+ })),
5996
+ toFormatter: () => zoned => DateTime.formatIsoZoned(zoned),
5997
+ toEquivalence: () => DateTime.Equivalence
5998
+ });
4457
5999
  const immerable = /*#__PURE__*/globalThis.Symbol.for("immer-draftable");
4458
6000
  function makeClass(Inherited, identifier, struct, annotations) {
4459
6001
  const getClassSchema = getClassSchemaFactory(struct, identifier, annotations);
4460
6002
  const ClassTypeId = getClassTypeId(identifier); // HMR support
4461
6003
  return class extends Inherited {
4462
6004
  constructor(...[input, options]) {
4463
- if (options?.disableValidation) {
4464
- super(input, options);
4465
- } else {
4466
- const validated = struct.makeUnsafe(input, options);
4467
- super({
4468
- ...input,
4469
- ...validated
4470
- }, {
4471
- ...options,
4472
- disableValidation: true
4473
- });
4474
- }
6005
+ const props = input ?? {};
6006
+ const validated = struct.makeUnsafe(props, options);
6007
+ super({
6008
+ ...props,
6009
+ ...validated
6010
+ }, {
6011
+ ...options,
6012
+ disableChecks: true
6013
+ });
4475
6014
  }
4476
6015
  toString() {
4477
6016
  return `${identifier}(${format({
@@ -4497,6 +6036,9 @@ function makeClass(Inherited, identifier, struct, annotations) {
4497
6036
  static makeUnsafe(input, options) {
4498
6037
  return new this(input, options);
4499
6038
  }
6039
+ static makeOption(input, options) {
6040
+ return Parser.makeOption(getClassSchema(this))(input, options);
6041
+ }
4500
6042
  static annotate(annotations) {
4501
6043
  return this.rebuild(AST.annotate(this.ast, annotations));
4502
6044
  }
@@ -4541,6 +6083,7 @@ function getClassSchemaFactory(from, identifier, annotations) {
4541
6083
  toCodec: ([from]) => new AST.Link(from.ast, transformation),
4542
6084
  toArbitrary: ([from]) => () => from.map(args => new self(args)),
4543
6085
  toFormatter: ([from]) => t => `${self.identifier}(${from(t)})`,
6086
+ "~sentinels": AST.collectSentinels(from.ast),
4544
6087
  ...annotations
4545
6088
  }));
4546
6089
  memo = from.pipe(decodeTo(to, transformation));
@@ -4552,6 +6095,46 @@ function isStruct(schema) {
4552
6095
  return isSchema(schema);
4553
6096
  }
4554
6097
  /**
6098
+ * Creates a schema-backed class whose constructor validates input against a
6099
+ * {@link Struct} schema. Construction throws a {@link SchemaError} on invalid
6100
+ * input (unless `disableChecks` is set in the options).
6101
+ *
6102
+ * Pass the desired class type as the first type parameter. The second optional
6103
+ * type parameter can be used to add nominal brands.
6104
+ *
6105
+ * **Example** (Basic class)
6106
+ *
6107
+ * ```ts
6108
+ * import { Schema } from "effect"
6109
+ *
6110
+ * class Person extends Schema.Class<Person>("Person")({
6111
+ * name: Schema.String,
6112
+ * age: Schema.Number
6113
+ * }) {}
6114
+ *
6115
+ * const alice = new Person({ name: "Alice", age: 30 })
6116
+ * console.log(alice.name) // "Alice"
6117
+ * console.log(`${alice}`) // "Person({ name: Alice, age: 30 })"
6118
+ * ```
6119
+ *
6120
+ * **Example** (Extending a class)
6121
+ *
6122
+ * ```ts
6123
+ * import { Schema } from "effect"
6124
+ *
6125
+ * class Animal extends Schema.Class<Animal>("Animal")({
6126
+ * name: Schema.String
6127
+ * }) {}
6128
+ *
6129
+ * class Dog extends Animal.extend<Dog>("Dog")({
6130
+ * breed: Schema.String
6131
+ * }) {}
6132
+ *
6133
+ * const dog = new Dog({ name: "Rex", breed: "Labrador" })
6134
+ * console.log(dog.name) // "Rex"
6135
+ * console.log(dog.breed) // "Labrador"
6136
+ * ```
6137
+ *
4555
6138
  * @category Constructors
4556
6139
  * @since 4.0.0
4557
6140
  */
@@ -4560,6 +6143,27 @@ export const Class = identifier => (schema, annotations) => {
4560
6143
  return makeClass(Data.Class, identifier, struct, annotations);
4561
6144
  };
4562
6145
  /**
6146
+ * Like {@link Class} but automatically adds a `_tag` literal field set to the
6147
+ * given `tag` value. This makes instances compatible with tagged union
6148
+ * discrimination patterns.
6149
+ *
6150
+ * The optional `identifier` parameter overrides the schema identifier;
6151
+ * it defaults to the `tag` value.
6152
+ *
6153
+ * **Example** (Tagged class)
6154
+ *
6155
+ * ```ts
6156
+ * import { Schema } from "effect"
6157
+ *
6158
+ * class Circle extends Schema.TaggedClass<Circle>()("Circle", {
6159
+ * radius: Schema.Number
6160
+ * }) {}
6161
+ *
6162
+ * const c = new Circle({ radius: 5 })
6163
+ * console.log(c._tag) // "Circle"
6164
+ * console.log(c.radius) // 5
6165
+ * ```
6166
+ *
4563
6167
  * @category Constructors
4564
6168
  * @since 4.0.0
4565
6169
  */
@@ -4574,14 +6178,53 @@ export const TaggedClass = identifier => {
4574
6178
  };
4575
6179
  };
4576
6180
  /**
6181
+ * Creates a schema-backed error class that can be used as a typed,
6182
+ * yieldable error in Effect programs. Combines {@link Class} validation with
6183
+ * the `YieldableError` interface so instances can be yielded directly inside
6184
+ * `Effect.gen`.
6185
+ *
6186
+ * **Example** (Schema-backed error)
6187
+ *
6188
+ * ```ts
6189
+ * import { Effect, Schema } from "effect"
6190
+ *
6191
+ * class NotFound extends Schema.ErrorClass<NotFound>("NotFound")({
6192
+ * id: Schema.Number
6193
+ * }) {}
6194
+ *
6195
+ * const program = Effect.gen(function*() {
6196
+ * yield* new NotFound({ id: 1 })
6197
+ * })
6198
+ * ```
6199
+ *
4577
6200
  * @category Constructors
4578
6201
  * @since 4.0.0
4579
6202
  */
4580
6203
  export const ErrorClass = identifier => (schema, annotations) => {
4581
6204
  const struct = isStruct(schema) ? schema : Struct(schema);
4582
- return makeClass(core.Error, identifier, struct, annotations);
6205
+ const self = makeClass(core.Error, identifier, struct, annotations);
6206
+ self.prototype.name = identifier;
6207
+ return self;
4583
6208
  };
4584
6209
  /**
6210
+ * Like {@link ErrorClass} but automatically adds a `_tag` literal field. The
6211
+ * resulting class is both a schema-validated, yieldable error and a tagged
6212
+ * union member.
6213
+ *
6214
+ * **Example** (Tagged error class)
6215
+ *
6216
+ * ```ts
6217
+ * import { Effect, Schema } from "effect"
6218
+ *
6219
+ * class NotFound extends Schema.TaggedErrorClass<NotFound>()("NotFound", {
6220
+ * id: Schema.Number
6221
+ * }) {}
6222
+ *
6223
+ * const program = Effect.gen(function*() {
6224
+ * yield* new NotFound({ id: 42 })
6225
+ * })
6226
+ * ```
6227
+ *
4585
6228
  * @category Constructors
4586
6229
  * @since 4.0.0
4587
6230
  */
@@ -4596,6 +6239,11 @@ export const TaggedErrorClass = identifier => {
4596
6239
  };
4597
6240
  };
4598
6241
  /**
6242
+ * Derives a {@link LazyArbitrary} from a schema. The result is memoized so
6243
+ * repeated calls with the same schema are cheap.
6244
+ *
6245
+ * Prefer {@link toArbitrary} when you just need the arbitrary directly.
6246
+ *
4599
6247
  * @category Arbitrary
4600
6248
  * @since 4.0.0
4601
6249
  */
@@ -4604,6 +6252,24 @@ export function toArbitraryLazy(schema) {
4604
6252
  return fc => lawc(fc, {});
4605
6253
  }
4606
6254
  /**
6255
+ * Derives a `fast-check` `Arbitrary` from a schema for property-based
6256
+ * testing. The derived arbitrary generates values that satisfy the schema.
6257
+ *
6258
+ * **Example** (Generating arbitrary values)
6259
+ *
6260
+ * ```ts
6261
+ * import { Schema } from "effect"
6262
+ * import * as FastCheck from "fast-check"
6263
+ *
6264
+ * const PersonArb = Schema.toArbitrary(
6265
+ * Schema.Struct({ name: Schema.String, age: Schema.Number })
6266
+ * )
6267
+ *
6268
+ * // Sample a random value
6269
+ * const sample = FastCheck.sample(PersonArb, 1)[0]
6270
+ * console.log(typeof sample.name) // "string"
6271
+ * ```
6272
+ *
4607
6273
  * @category Arbitrary
4608
6274
  * @since 4.0.0
4609
6275
  */
@@ -4630,6 +6296,13 @@ export function overrideToFormatter(toFormatter) {
4630
6296
  };
4631
6297
  }
4632
6298
  /**
6299
+ * Derives a string formatter function from a schema. The formatter converts
6300
+ * a value to its human-readable string representation, recursing into structs,
6301
+ * arrays, and unions.
6302
+ *
6303
+ * The optional `onBefore` hook lets you intercept specific AST nodes before
6304
+ * the default formatting logic runs.
6305
+ *
4633
6306
  * @category Formatter
4634
6307
  * @since 4.0.0
4635
6308
  */
@@ -4768,10 +6441,9 @@ export function toFormatter(schema, options) {
4768
6441
  // Equivalence
4769
6442
  // -----------------------------------------------------------------------------
4770
6443
  /**
4771
- * **Technical Note**
4772
- *
4773
- * This annotation cannot be added to `Annotations.Bottom` because it would make
4774
- * the schema invariant.
6444
+ * Overrides the equivalence derivation for a schema by supplying a custom
6445
+ * `Equivalence`. Use this when the default structural equivalence derived by
6446
+ * {@link toEquivalence} is not appropriate for a type.
4775
6447
  *
4776
6448
  * @category Equivalence
4777
6449
  * @since 4.0.0
@@ -4782,6 +6454,21 @@ export function overrideToEquivalence(toEquivalence) {
4782
6454
  });
4783
6455
  }
4784
6456
  /**
6457
+ * Derives an `Equivalence` from a schema. Two values are considered equal when
6458
+ * every field (and nested field) compares equal according to the schema
6459
+ * structure.
6460
+ *
6461
+ * **Example** (Struct equivalence)
6462
+ *
6463
+ * ```ts
6464
+ * import { Schema } from "effect"
6465
+ *
6466
+ * const eq = Schema.toEquivalence(Schema.Struct({ id: Schema.Number, name: Schema.String }))
6467
+ *
6468
+ * console.log(eq({ id: 1, name: "Alice" }, { id: 1, name: "Alice" })) // true
6469
+ * console.log(eq({ id: 1, name: "Alice" }, { id: 2, name: "Alice" })) // false
6470
+ * ```
6471
+ *
4785
6472
  * @category Equivalence
4786
6473
  * @since 4.0.0
4787
6474
  */
@@ -4792,6 +6479,10 @@ export function toEquivalence(schema) {
4792
6479
  // Representation
4793
6480
  // -----------------------------------------------------------------------------
4794
6481
  /**
6482
+ * Derives an intermediate `SchemaRepresentation.Document` from a schema. This
6483
+ * document is used internally by {@link toJsonSchemaDocument} and related
6484
+ * functions to produce JSON Schema output.
6485
+ *
4795
6486
  * @category Representation
4796
6487
  * @since 4.0.0
4797
6488
  */
@@ -4816,17 +6507,23 @@ export function toJsonSchemaDocument(schema, options) {
4816
6507
  };
4817
6508
  }
4818
6509
  // -----------------------------------------------------------------------------
4819
- // Serializer
6510
+ // Canonical Codecs
4820
6511
  // -----------------------------------------------------------------------------
4821
6512
  /**
4822
- * @category Serializer
6513
+ * Derives a canonical JSON codec from a schema. The encoded form is `unknown`
6514
+ * (any JSON-compatible value), decoded to the schema's `Type`.
6515
+ *
6516
+ * @category Canonical Codecs
4823
6517
  * @since 4.0.0
4824
6518
  */
4825
6519
  export function toCodecJson(schema) {
4826
6520
  return make(InternalToCodec.toCodecJson(schema.ast));
4827
6521
  }
4828
6522
  /**
4829
- * @category Serializer
6523
+ * Derives an isomorphism codec from a schema. The encoded form is the
6524
+ * schema's `Iso` type — the intermediate representation used for round-tripping.
6525
+ *
6526
+ * @category Canonical Codecs
4830
6527
  * @since 4.0.0
4831
6528
  */
4832
6529
  export function toCodecIso(schema) {
@@ -4840,7 +6537,11 @@ export function toCodecStringTree(schema, options) {
4840
6537
  }
4841
6538
  }
4842
6539
  /**
4843
- * @category Serializer
6540
+ * Derives an XML encoder from a codec. Encodes a value to an XML string by
6541
+ * first converting it through {@link toCodecStringTree}, then serializing the
6542
+ * resulting tree to XML.
6543
+ *
6544
+ * @category Canonical Codecs
4844
6545
  * @since 4.0.0
4845
6546
  */
4846
6547
  export function toEncoderXml(codec, options) {
@@ -4956,8 +6657,6 @@ function getStringTreePriority(ast) {
4956
6657
  const treeReorder = /*#__PURE__*/InternalToCodec.makeReorder(getStringTreePriority);
4957
6658
  function serializerTree(ast, recur, onMissingAnnotation) {
4958
6659
  switch (ast._tag) {
4959
- case "Unknown":
4960
- case "ObjectKeyword":
4961
6660
  case "Declaration":
4962
6661
  {
4963
6662
  const getLink = ast.annotations?.toCodecJson ?? ast.annotations?.toCodec;
@@ -4973,6 +6672,9 @@ function serializerTree(ast, recur, onMissingAnnotation) {
4973
6672
  return AST.replaceEncoding(ast, [nullToString]);
4974
6673
  case "Boolean":
4975
6674
  return AST.replaceEncoding(ast, [booleanToString]);
6675
+ case "Unknown":
6676
+ case "ObjectKeyword":
6677
+ return AST.replaceEncoding(ast, [AST.unknownToStringTree]);
4976
6678
  case "Enum":
4977
6679
  case "Number":
4978
6680
  case "Literal":
@@ -5051,6 +6753,9 @@ function onSerializerEnsureArray(ast) {
5051
6753
  // Optic APIs
5052
6754
  // -----------------------------------------------------------------------------
5053
6755
  /**
6756
+ * Derives an `Iso` optic from a schema that isomorphically converts between
6757
+ * the schema's `Type` and its `Iso` (intermediate / serialized form).
6758
+ *
5054
6759
  * @category Optic
5055
6760
  * @since 4.0.0
5056
6761
  */
@@ -5059,6 +6764,8 @@ export function toIso(schema) {
5059
6764
  return Optic_.makeIso(Parser.encodeSync(serializer), Parser.decodeSync(serializer));
5060
6765
  }
5061
6766
  /**
6767
+ * Returns an identity `Iso` over the schema's source (`Type`) side.
6768
+ *
5062
6769
  * @category Optic
5063
6770
  * @since 4.0.0
5064
6771
  */
@@ -5066,6 +6773,8 @@ export function toIsoSource(_) {
5066
6773
  return Optic_.id();
5067
6774
  }
5068
6775
  /**
6776
+ * Returns an identity `Iso` over the schema's focus (`Iso`) side.
6777
+ *
5069
6778
  * @category Optic
5070
6779
  * @since 4.0.0
5071
6780
  */
@@ -5073,10 +6782,11 @@ export function toIsoFocus(_) {
5073
6782
  return Optic_.id();
5074
6783
  }
5075
6784
  /**
5076
- * **Technical Note**
5077
- *
5078
- * This annotation cannot be added to `Annotations.Bottom` because it changes
5079
- * the schema type.
6785
+ * Overrides the ISO codec derivation for a schema by providing a target codec
6786
+ * and explicit `decode`/`encode` getters. The resulting schema carries a
6787
+ * custom `Iso` type, which changes the schema's type parameter — use
6788
+ * {@link overrideToCodecIso} when the default ISO transformation is not
6789
+ * appropriate.
5080
6790
  *
5081
6791
  * @category Optic
5082
6792
  * @since 4.0.0
@@ -5094,11 +6804,15 @@ export function overrideToCodecIso(to, transformation) {
5094
6804
  // Differ APIs
5095
6805
  // -----------------------------------------------------------------------------
5096
6806
  /**
6807
+ * Derives a JSON Patch differ from a codec. Serializes values to JSON (via
6808
+ * {@link toCodecJson}), computes RFC 6902 JSON Patch operations between old
6809
+ * and new values, and can apply patches back to the typed value.
6810
+ *
5097
6811
  * @category JsonPatch
5098
6812
  * @since 4.0.0
5099
6813
  */
5100
6814
  export function toDifferJsonPatch(schema) {
5101
- const serializer = toCodecJson(schema); // TODO: remove this cast
6815
+ const serializer = toCodecJson(schema);
5102
6816
  const get = Parser.encodeSync(serializer);
5103
6817
  const set = Parser.decodeSync(serializer);
5104
6818
  return {
@@ -5113,33 +6827,42 @@ export function toDifferJsonPatch(schema) {
5113
6827
  };
5114
6828
  }
5115
6829
  /**
6830
+ * Creates a recursive schema for a {@link Tree} of values described by `node`.
6831
+ * The resulting schema accepts a single node value, an array of trees, or an
6832
+ * object whose values are trees.
6833
+ *
5116
6834
  * @category Tree
5117
6835
  * @since 4.0.0
5118
6836
  */
5119
6837
  export function Tree(node) {
5120
6838
  const Tree$ref = suspend(() => Tree);
5121
- const Tree = Union([node, Array(Tree$ref), Record(String, Tree$ref)]);
6839
+ const Tree = Union([node, ArraySchema(Tree$ref), Record(String, Tree$ref)]);
5122
6840
  return Tree;
5123
6841
  }
5124
6842
  /**
5125
- * @category Tree
5126
- * @since 4.0.0
5127
- */
5128
- export function MutableTree(node) {
5129
- const MutableTree$ref = suspend(() => MutableTree);
5130
- const MutableTree = Union([node, mutable(Array(MutableTree$ref)), Record(String, mutableKey(MutableTree$ref))]);
5131
- return MutableTree;
5132
- }
5133
- /**
6843
+ * Schema that accepts and validates any immutable JSON-compatible value.
6844
+ *
6845
+ * **Example** (Validating a JSON value)
6846
+ *
6847
+ * ```ts
6848
+ * import { Schema } from "effect"
6849
+ *
6850
+ * const result = Schema.decodeUnknownOption(Schema.Json)({ key: [1, true, null] })
6851
+ * console.log(result._tag) // "Some"
6852
+ * ```
6853
+ *
5134
6854
  * @category JSON
5135
6855
  * @since 4.0.0
5136
6856
  */
5137
- export const Json = /*#__PURE__*/Tree(/*#__PURE__*/Union([Null, Number, Boolean, String]));
6857
+ export const Json = /*#__PURE__*/make(AST.Json);
5138
6858
  /**
6859
+ * Schema that accepts any mutable JSON-compatible value. See {@link Json} for
6860
+ * the immutable variant.
6861
+ *
5139
6862
  * @category JSON
5140
6863
  * @since 4.0.0
5141
6864
  */
5142
- export const MutableJson = /*#__PURE__*/MutableTree(/*#__PURE__*/Union([Null, Number, Boolean, String]));
6865
+ export const MutableJson = /*#__PURE__*/make(AST.MutableJson);
5143
6866
  // -----------------------------------------------------------------------------
5144
6867
  // Annotations
5145
6868
  // -----------------------------------------------------------------------------