effect 4.0.0-beta.5 → 4.0.0-beta.50

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 (1504) 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 +82 -45
  6. package/dist/BigDecimal.d.ts.map +1 -1
  7. package/dist/BigDecimal.js +87 -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 +14 -45
  18. package/dist/Cache.d.ts.map +1 -1
  19. package/dist/Cache.js +21 -47
  20. package/dist/Cache.js.map +1 -1
  21. package/dist/Cause.d.ts +54 -23
  22. package/dist/Cause.d.ts.map +1 -1
  23. package/dist/Cause.js +108 -10
  24. package/dist/Cause.js.map +1 -1
  25. package/dist/Channel.d.ts +166 -48
  26. package/dist/Channel.d.ts.map +1 -1
  27. package/dist/Channel.js +182 -91
  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/Clock.d.ts +2 -2
  34. package/dist/Clock.d.ts.map +1 -1
  35. package/dist/Clock.js.map +1 -1
  36. package/dist/Combiner.d.ts +280 -13
  37. package/dist/Combiner.d.ts.map +1 -1
  38. package/dist/Combiner.js +198 -7
  39. package/dist/Combiner.js.map +1 -1
  40. package/dist/Config.d.ts +171 -11
  41. package/dist/Config.d.ts.map +1 -1
  42. package/dist/Config.js +69 -11
  43. package/dist/Config.js.map +1 -1
  44. package/dist/ConfigProvider.d.ts +6 -6
  45. package/dist/ConfigProvider.d.ts.map +1 -1
  46. package/dist/ConfigProvider.js +5 -5
  47. package/dist/ConfigProvider.js.map +1 -1
  48. package/dist/Console.d.ts +2 -2
  49. package/dist/Console.d.ts.map +1 -1
  50. package/dist/Console.js.map +1 -1
  51. package/dist/Context.d.ts +1150 -0
  52. package/dist/Context.d.ts.map +1 -0
  53. package/dist/{ServiceMap.js → Context.js} +181 -165
  54. package/dist/Context.js.map +1 -0
  55. package/dist/Cron.d.ts +11 -7
  56. package/dist/Cron.d.ts.map +1 -1
  57. package/dist/Cron.js +120 -63
  58. package/dist/Cron.js.map +1 -1
  59. package/dist/Data.d.ts +535 -366
  60. package/dist/Data.d.ts.map +1 -1
  61. package/dist/Data.js +132 -79
  62. package/dist/Data.js.map +1 -1
  63. package/dist/DateTime.d.ts +74 -255
  64. package/dist/DateTime.d.ts.map +1 -1
  65. package/dist/DateTime.js +17 -62
  66. package/dist/DateTime.js.map +1 -1
  67. package/dist/Deferred.d.ts +12 -5
  68. package/dist/Deferred.d.ts.map +1 -1
  69. package/dist/Deferred.js +13 -5
  70. package/dist/Deferred.js.map +1 -1
  71. package/dist/Duration.d.ts +62 -32
  72. package/dist/Duration.d.ts.map +1 -1
  73. package/dist/Duration.js +108 -78
  74. package/dist/Duration.js.map +1 -1
  75. package/dist/Effect.d.ts +1377 -1147
  76. package/dist/Effect.d.ts.map +1 -1
  77. package/dist/Effect.js +465 -446
  78. package/dist/Effect.js.map +1 -1
  79. package/dist/Encoding.d.ts +194 -0
  80. package/dist/Encoding.d.ts.map +1 -0
  81. package/dist/Encoding.js +352 -0
  82. package/dist/Encoding.js.map +1 -0
  83. package/dist/Equal.d.ts +276 -109
  84. package/dist/Equal.d.ts.map +1 -1
  85. package/dist/Equal.js +140 -48
  86. package/dist/Equal.js.map +1 -1
  87. package/dist/Equivalence.d.ts +60 -3
  88. package/dist/Equivalence.d.ts.map +1 -1
  89. package/dist/Equivalence.js +70 -13
  90. package/dist/Equivalence.js.map +1 -1
  91. package/dist/ErrorReporter.d.ts +374 -0
  92. package/dist/ErrorReporter.d.ts.map +1 -0
  93. package/dist/ErrorReporter.js +245 -0
  94. package/dist/ErrorReporter.js.map +1 -0
  95. package/dist/ExecutionPlan.d.ts +6 -6
  96. package/dist/ExecutionPlan.d.ts.map +1 -1
  97. package/dist/ExecutionPlan.js +4 -4
  98. package/dist/ExecutionPlan.js.map +1 -1
  99. package/dist/Exit.d.ts +24 -12
  100. package/dist/Exit.d.ts.map +1 -1
  101. package/dist/Exit.js +8 -4
  102. package/dist/Exit.js.map +1 -1
  103. package/dist/Fiber.d.ts +10 -8
  104. package/dist/Fiber.d.ts.map +1 -1
  105. package/dist/Fiber.js.map +1 -1
  106. package/dist/FiberHandle.d.ts +11 -10
  107. package/dist/FiberHandle.d.ts.map +1 -1
  108. package/dist/FiberHandle.js +12 -11
  109. package/dist/FiberHandle.js.map +1 -1
  110. package/dist/FiberMap.d.ts +22 -21
  111. package/dist/FiberMap.d.ts.map +1 -1
  112. package/dist/FiberMap.js +10 -10
  113. package/dist/FiberMap.js.map +1 -1
  114. package/dist/FiberSet.d.ts +2 -2
  115. package/dist/FiberSet.d.ts.map +1 -1
  116. package/dist/FiberSet.js +4 -4
  117. package/dist/FiberSet.js.map +1 -1
  118. package/dist/FileSystem.d.ts +20 -19
  119. package/dist/FileSystem.d.ts.map +1 -1
  120. package/dist/FileSystem.js +17 -13
  121. package/dist/FileSystem.js.map +1 -1
  122. package/dist/Filter.d.ts +4 -37
  123. package/dist/Filter.d.ts.map +1 -1
  124. package/dist/Filter.js +0 -13
  125. package/dist/Filter.js.map +1 -1
  126. package/dist/Formatter.d.ts +131 -47
  127. package/dist/Formatter.d.ts.map +1 -1
  128. package/dist/Formatter.js +229 -51
  129. package/dist/Formatter.js.map +1 -1
  130. package/dist/Function.d.ts +1 -9
  131. package/dist/Function.d.ts.map +1 -1
  132. package/dist/Function.js +2 -10
  133. package/dist/Function.js.map +1 -1
  134. package/dist/Graph.d.ts +65 -65
  135. package/dist/Graph.d.ts.map +1 -1
  136. package/dist/Graph.js +60 -62
  137. package/dist/Graph.js.map +1 -1
  138. package/dist/Hash.js +1 -1
  139. package/dist/Hash.js.map +1 -1
  140. package/dist/HashMap.d.ts +26 -19
  141. package/dist/HashMap.d.ts.map +1 -1
  142. package/dist/HashMap.js +7 -5
  143. package/dist/HashMap.js.map +1 -1
  144. package/dist/Iterable.d.ts +50 -50
  145. package/dist/Iterable.d.ts.map +1 -1
  146. package/dist/Iterable.js +106 -34
  147. package/dist/Iterable.js.map +1 -1
  148. package/dist/JsonSchema.d.ts +299 -10
  149. package/dist/JsonSchema.d.ts.map +1 -1
  150. package/dist/JsonSchema.js +323 -4
  151. package/dist/JsonSchema.js.map +1 -1
  152. package/dist/Latch.d.ts +175 -0
  153. package/dist/Latch.d.ts.map +1 -0
  154. package/dist/Latch.js +130 -0
  155. package/dist/Latch.js.map +1 -0
  156. package/dist/Layer.d.ts +599 -379
  157. package/dist/Layer.d.ts.map +1 -1
  158. package/dist/Layer.js +249 -180
  159. package/dist/Layer.js.map +1 -1
  160. package/dist/LayerMap.d.ts +27 -26
  161. package/dist/LayerMap.d.ts.map +1 -1
  162. package/dist/LayerMap.js +21 -18
  163. package/dist/LayerMap.js.map +1 -1
  164. package/dist/LogLevel.d.ts +32 -0
  165. package/dist/LogLevel.d.ts.map +1 -1
  166. package/dist/LogLevel.js +28 -100
  167. package/dist/LogLevel.js.map +1 -1
  168. package/dist/Logger.d.ts +31 -97
  169. package/dist/Logger.d.ts.map +1 -1
  170. package/dist/Logger.js +2 -3
  171. package/dist/Logger.js.map +1 -1
  172. package/dist/ManagedRuntime.d.ts +8 -8
  173. package/dist/ManagedRuntime.d.ts.map +1 -1
  174. package/dist/ManagedRuntime.js +34 -25
  175. package/dist/ManagedRuntime.js.map +1 -1
  176. package/dist/Metric.d.ts +23 -25
  177. package/dist/Metric.d.ts.map +1 -1
  178. package/dist/Metric.js +24 -26
  179. package/dist/Metric.js.map +1 -1
  180. package/dist/MutableHashMap.d.ts +7 -0
  181. package/dist/MutableHashMap.d.ts.map +1 -1
  182. package/dist/MutableHashMap.js +8 -0
  183. package/dist/MutableHashMap.js.map +1 -1
  184. package/dist/MutableHashSet.d.ts +7 -0
  185. package/dist/MutableHashSet.d.ts.map +1 -1
  186. package/dist/MutableHashSet.js +8 -0
  187. package/dist/MutableHashSet.js.map +1 -1
  188. package/dist/MutableList.d.ts.map +1 -1
  189. package/dist/MutableList.js +3 -0
  190. package/dist/MutableList.js.map +1 -1
  191. package/dist/Newtype.d.ts +291 -0
  192. package/dist/Newtype.d.ts.map +1 -0
  193. package/dist/Newtype.js +161 -0
  194. package/dist/Newtype.js.map +1 -0
  195. package/dist/Number.d.ts +74 -18
  196. package/dist/Number.d.ts.map +1 -1
  197. package/dist/Number.js +46 -18
  198. package/dist/Number.js.map +1 -1
  199. package/dist/Optic.d.ts +947 -18
  200. package/dist/Optic.d.ts.map +1 -1
  201. package/dist/Optic.js +454 -5
  202. package/dist/Optic.js.map +1 -1
  203. package/dist/Option.d.ts +25 -16
  204. package/dist/Option.d.ts.map +1 -1
  205. package/dist/Option.js +15 -9
  206. package/dist/Option.js.map +1 -1
  207. package/dist/Order.d.ts +6 -1
  208. package/dist/Order.d.ts.map +1 -1
  209. package/dist/Order.js +19 -14
  210. package/dist/Order.js.map +1 -1
  211. package/dist/PartitionedSemaphore.d.ts +146 -15
  212. package/dist/PartitionedSemaphore.d.ts.map +1 -1
  213. package/dist/PartitionedSemaphore.js +174 -61
  214. package/dist/PartitionedSemaphore.js.map +1 -1
  215. package/dist/Path.d.ts +2 -2
  216. package/dist/Path.d.ts.map +1 -1
  217. package/dist/Path.js +2 -2
  218. package/dist/Path.js.map +1 -1
  219. package/dist/Pipeable.d.ts +17 -0
  220. package/dist/Pipeable.d.ts.map +1 -1
  221. package/dist/Pipeable.js +19 -1
  222. package/dist/Pipeable.js.map +1 -1
  223. package/dist/PlatformError.d.ts +2 -2
  224. package/dist/Pool.d.ts +6 -4
  225. package/dist/Pool.d.ts.map +1 -1
  226. package/dist/Pool.js +11 -9
  227. package/dist/Pool.js.map +1 -1
  228. package/dist/PubSub.d.ts +8 -6
  229. package/dist/PubSub.d.ts.map +1 -1
  230. package/dist/PubSub.js +18 -10
  231. package/dist/PubSub.js.map +1 -1
  232. package/dist/Pull.d.ts.map +1 -1
  233. package/dist/Pull.js +1 -1
  234. package/dist/Pull.js.map +1 -1
  235. package/dist/Queue.d.ts +9 -6
  236. package/dist/Queue.d.ts.map +1 -1
  237. package/dist/Queue.js +7 -5
  238. package/dist/Queue.js.map +1 -1
  239. package/dist/Random.d.ts +36 -2
  240. package/dist/Random.d.ts.map +1 -1
  241. package/dist/Random.js +46 -35
  242. package/dist/Random.js.map +1 -1
  243. package/dist/RcMap.d.ts +4 -4
  244. package/dist/RcMap.d.ts.map +1 -1
  245. package/dist/RcMap.js +13 -13
  246. package/dist/RcMap.js.map +1 -1
  247. package/dist/RcRef.d.ts +1 -1
  248. package/dist/RcRef.d.ts.map +1 -1
  249. package/dist/Record.d.ts +63 -160
  250. package/dist/Record.d.ts.map +1 -1
  251. package/dist/Record.js +37 -56
  252. package/dist/Record.js.map +1 -1
  253. package/dist/Redactable.d.ts +139 -62
  254. package/dist/Redactable.d.ts.map +1 -1
  255. package/dist/Redactable.js +59 -55
  256. package/dist/Redactable.js.map +1 -1
  257. package/dist/Reducer.d.ts +166 -7
  258. package/dist/Reducer.d.ts.map +1 -1
  259. package/dist/Reducer.js +135 -1
  260. package/dist/Reducer.js.map +1 -1
  261. package/dist/References.d.ts +257 -229
  262. package/dist/References.d.ts.map +1 -1
  263. package/dist/References.js +240 -259
  264. package/dist/References.js.map +1 -1
  265. package/dist/Request.d.ts +6 -6
  266. package/dist/Request.d.ts.map +1 -1
  267. package/dist/Request.js +2 -1
  268. package/dist/Request.js.map +1 -1
  269. package/dist/RequestResolver.d.ts +25 -45
  270. package/dist/RequestResolver.d.ts.map +1 -1
  271. package/dist/RequestResolver.js +15 -36
  272. package/dist/RequestResolver.js.map +1 -1
  273. package/dist/Resource.d.ts +0 -3
  274. package/dist/Resource.d.ts.map +1 -1
  275. package/dist/Resource.js +5 -4
  276. package/dist/Resource.js.map +1 -1
  277. package/dist/Result.d.ts +1 -1
  278. package/dist/Result.d.ts.map +1 -1
  279. package/dist/Result.js +1 -2
  280. package/dist/Result.js.map +1 -1
  281. package/dist/Runtime.d.ts +66 -0
  282. package/dist/Runtime.d.ts.map +1 -1
  283. package/dist/Runtime.js +79 -6
  284. package/dist/Runtime.js.map +1 -1
  285. package/dist/Schedule.d.ts +176 -293
  286. package/dist/Schedule.d.ts.map +1 -1
  287. package/dist/Schedule.js +162 -136
  288. package/dist/Schedule.js.map +1 -1
  289. package/dist/Scheduler.d.ts +36 -125
  290. package/dist/Scheduler.d.ts.map +1 -1
  291. package/dist/Scheduler.js +37 -126
  292. package/dist/Scheduler.js.map +1 -1
  293. package/dist/Schema.d.ts +3269 -394
  294. package/dist/Schema.d.ts.map +1 -1
  295. package/dist/Schema.js +2284 -282
  296. package/dist/Schema.js.map +1 -1
  297. package/dist/SchemaAST.d.ts +7 -2
  298. package/dist/SchemaAST.d.ts.map +1 -1
  299. package/dist/SchemaAST.js +136 -40
  300. package/dist/SchemaAST.js.map +1 -1
  301. package/dist/SchemaGetter.d.ts +54 -10
  302. package/dist/SchemaGetter.d.ts.map +1 -1
  303. package/dist/SchemaGetter.js +82 -23
  304. package/dist/SchemaGetter.js.map +1 -1
  305. package/dist/SchemaParser.d.ts +44 -54
  306. package/dist/SchemaParser.d.ts.map +1 -1
  307. package/dist/SchemaParser.js +55 -2
  308. package/dist/SchemaParser.js.map +1 -1
  309. package/dist/SchemaRepresentation.d.ts +46 -45
  310. package/dist/SchemaRepresentation.d.ts.map +1 -1
  311. package/dist/SchemaRepresentation.js +65 -38
  312. package/dist/SchemaRepresentation.js.map +1 -1
  313. package/dist/SchemaTransformation.d.ts +252 -3
  314. package/dist/SchemaTransformation.d.ts.map +1 -1
  315. package/dist/SchemaTransformation.js +319 -13
  316. package/dist/SchemaTransformation.js.map +1 -1
  317. package/dist/Scope.d.ts +2 -2
  318. package/dist/Scope.d.ts.map +1 -1
  319. package/dist/Scope.js.map +1 -1
  320. package/dist/ScopedCache.d.ts +2 -2
  321. package/dist/ScopedCache.d.ts.map +1 -1
  322. package/dist/ScopedCache.js +5 -5
  323. package/dist/ScopedCache.js.map +1 -1
  324. package/dist/Semaphore.d.ts +307 -0
  325. package/dist/Semaphore.d.ts.map +1 -0
  326. package/dist/Semaphore.js +220 -0
  327. package/dist/Semaphore.js.map +1 -0
  328. package/dist/Sink.d.ts +22 -19
  329. package/dist/Sink.d.ts.map +1 -1
  330. package/dist/Sink.js +54 -7
  331. package/dist/Sink.js.map +1 -1
  332. package/dist/Stdio.d.ts +18 -6
  333. package/dist/Stdio.d.ts.map +1 -1
  334. package/dist/Stdio.js +20 -2
  335. package/dist/Stdio.js.map +1 -1
  336. package/dist/Stream.d.ts +465 -542
  337. package/dist/Stream.d.ts.map +1 -1
  338. package/dist/Stream.js +321 -144
  339. package/dist/Stream.js.map +1 -1
  340. package/dist/String.d.ts +114 -47
  341. package/dist/String.d.ts.map +1 -1
  342. package/dist/String.js +29 -47
  343. package/dist/String.js.map +1 -1
  344. package/dist/Struct.d.ts +23 -7
  345. package/dist/Struct.d.ts.map +1 -1
  346. package/dist/Struct.js +22 -0
  347. package/dist/Struct.js.map +1 -1
  348. package/dist/SubscriptionRef.d.ts +3 -3
  349. package/dist/SubscriptionRef.d.ts.map +1 -1
  350. package/dist/SubscriptionRef.js +85 -117
  351. package/dist/SubscriptionRef.js.map +1 -1
  352. package/dist/SynchronizedRef.d.ts +2 -1
  353. package/dist/SynchronizedRef.d.ts.map +1 -1
  354. package/dist/SynchronizedRef.js +2 -1
  355. package/dist/SynchronizedRef.js.map +1 -1
  356. package/dist/Terminal.d.ts +5 -4
  357. package/dist/Terminal.d.ts.map +1 -1
  358. package/dist/Terminal.js +2 -2
  359. package/dist/Terminal.js.map +1 -1
  360. package/dist/Tracer.d.ts +21 -20
  361. package/dist/Tracer.d.ts.map +1 -1
  362. package/dist/Tracer.js +13 -9
  363. package/dist/Tracer.js.map +1 -1
  364. package/dist/Trie.d.ts +44 -31
  365. package/dist/Trie.d.ts.map +1 -1
  366. package/dist/Trie.js +13 -9
  367. package/dist/Trie.js.map +1 -1
  368. package/dist/TxChunk.d.ts +4 -4
  369. package/dist/TxChunk.d.ts.map +1 -1
  370. package/dist/TxChunk.js +4 -4
  371. package/dist/TxChunk.js.map +1 -1
  372. package/dist/TxDeferred.d.ts +328 -0
  373. package/dist/TxDeferred.d.ts.map +1 -0
  374. package/dist/TxDeferred.js +197 -0
  375. package/dist/TxDeferred.js.map +1 -0
  376. package/dist/TxHashMap.d.ts +105 -86
  377. package/dist/TxHashMap.d.ts.map +1 -1
  378. package/dist/TxHashMap.js +51 -44
  379. package/dist/TxHashMap.js.map +1 -1
  380. package/dist/TxHashSet.d.ts +2 -2
  381. package/dist/TxHashSet.d.ts.map +1 -1
  382. package/dist/TxHashSet.js +16 -15
  383. package/dist/TxHashSet.js.map +1 -1
  384. package/dist/TxPriorityQueue.d.ts +609 -0
  385. package/dist/TxPriorityQueue.d.ts.map +1 -0
  386. package/dist/TxPriorityQueue.js +416 -0
  387. package/dist/TxPriorityQueue.js.map +1 -0
  388. package/dist/TxPubSub.d.ts +585 -0
  389. package/dist/TxPubSub.d.ts.map +1 -0
  390. package/dist/TxPubSub.js +521 -0
  391. package/dist/TxPubSub.js.map +1 -0
  392. package/dist/TxQueue.d.ts +1 -1
  393. package/dist/TxQueue.d.ts.map +1 -1
  394. package/dist/TxQueue.js +42 -57
  395. package/dist/TxQueue.js.map +1 -1
  396. package/dist/TxReentrantLock.d.ts +500 -0
  397. package/dist/TxReentrantLock.d.ts.map +1 -0
  398. package/dist/TxReentrantLock.js +481 -0
  399. package/dist/TxReentrantLock.js.map +1 -0
  400. package/dist/TxRef.d.ts +14 -20
  401. package/dist/TxRef.d.ts.map +1 -1
  402. package/dist/TxRef.js +8 -10
  403. package/dist/TxRef.js.map +1 -1
  404. package/dist/TxSemaphore.d.ts +162 -2
  405. package/dist/TxSemaphore.d.ts.map +1 -1
  406. package/dist/TxSemaphore.js +25 -10
  407. package/dist/TxSemaphore.js.map +1 -1
  408. package/dist/TxSubscriptionRef.d.ts +508 -0
  409. package/dist/TxSubscriptionRef.d.ts.map +1 -0
  410. package/dist/TxSubscriptionRef.js +293 -0
  411. package/dist/TxSubscriptionRef.js.map +1 -0
  412. package/dist/Types.d.ts +83 -17
  413. package/dist/Types.d.ts.map +1 -1
  414. package/dist/Unify.d.ts +8 -2
  415. package/dist/Unify.d.ts.map +1 -1
  416. package/dist/Unify.js.map +1 -1
  417. package/dist/Utils.d.ts +137 -65
  418. package/dist/Utils.d.ts.map +1 -1
  419. package/dist/Utils.js +38 -66
  420. package/dist/Utils.js.map +1 -1
  421. package/dist/index.d.ts +888 -71
  422. package/dist/index.d.ts.map +1 -1
  423. package/dist/index.js +888 -71
  424. package/dist/index.js.map +1 -1
  425. package/dist/internal/core.js +11 -3
  426. package/dist/internal/core.js.map +1 -1
  427. package/dist/internal/dateTime.js +77 -71
  428. package/dist/internal/dateTime.js.map +1 -1
  429. package/dist/internal/effect.js +343 -260
  430. package/dist/internal/effect.js.map +1 -1
  431. package/dist/internal/hashMap.js +7 -5
  432. package/dist/internal/hashMap.js.map +1 -1
  433. package/dist/internal/layer.js +3 -3
  434. package/dist/internal/layer.js.map +1 -1
  435. package/dist/internal/option.js +6 -0
  436. package/dist/internal/option.js.map +1 -1
  437. package/dist/internal/random.d.ts +2 -0
  438. package/dist/internal/random.d.ts.map +1 -0
  439. package/dist/internal/random.js +13 -0
  440. package/dist/internal/random.js.map +1 -0
  441. package/dist/internal/rcRef.js +11 -10
  442. package/dist/internal/rcRef.js.map +1 -1
  443. package/dist/internal/references.d.ts +2 -0
  444. package/dist/internal/references.d.ts.map +1 -0
  445. package/dist/internal/references.js +51 -0
  446. package/dist/internal/references.js.map +1 -0
  447. package/dist/internal/request.js +6 -6
  448. package/dist/internal/request.js.map +1 -1
  449. package/dist/internal/schedule.js +1 -1
  450. package/dist/internal/schedule.js.map +1 -1
  451. package/dist/internal/schema/annotations.js +2 -0
  452. package/dist/internal/schema/annotations.js.map +1 -1
  453. package/dist/internal/schema/representation.js +86 -107
  454. package/dist/internal/schema/representation.js.map +1 -1
  455. package/dist/internal/schema/schema.d.ts +10 -1
  456. package/dist/internal/schema/schema.d.ts.map +1 -1
  457. package/dist/internal/schema/schema.js +22 -1
  458. package/dist/internal/schema/schema.js.map +1 -1
  459. package/dist/internal/schema/to-codec.js +7 -10
  460. package/dist/internal/schema/to-codec.js.map +1 -1
  461. package/dist/internal/trie.js +8 -7
  462. package/dist/internal/trie.js.map +1 -1
  463. package/dist/testing/TestClock.d.ts +8 -7
  464. package/dist/testing/TestClock.d.ts.map +1 -1
  465. package/dist/testing/TestClock.js +6 -4
  466. package/dist/testing/TestClock.js.map +1 -1
  467. package/dist/testing/TestSchema.d.ts +267 -33
  468. package/dist/testing/TestSchema.d.ts.map +1 -1
  469. package/dist/testing/TestSchema.js +296 -23
  470. package/dist/testing/TestSchema.js.map +1 -1
  471. package/dist/testing/index.d.ts +64 -1
  472. package/dist/testing/index.d.ts.map +1 -1
  473. package/dist/testing/index.js +64 -1
  474. package/dist/testing/index.js.map +1 -1
  475. package/dist/unstable/ai/AiError.d.ts +155 -73
  476. package/dist/unstable/ai/AiError.d.ts.map +1 -1
  477. package/dist/unstable/ai/AiError.js +29 -23
  478. package/dist/unstable/ai/AiError.js.map +1 -1
  479. package/dist/unstable/ai/AnthropicStructuredOutput.d.ts +1 -1
  480. package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
  481. package/dist/unstable/ai/AnthropicStructuredOutput.js +9 -2
  482. package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
  483. package/dist/unstable/ai/Chat.d.ts +39 -11
  484. package/dist/unstable/ai/Chat.d.ts.map +1 -1
  485. package/dist/unstable/ai/Chat.js +41 -47
  486. package/dist/unstable/ai/Chat.js.map +1 -1
  487. package/dist/unstable/ai/EmbeddingModel.d.ts +130 -0
  488. package/dist/unstable/ai/EmbeddingModel.d.ts.map +1 -0
  489. package/dist/unstable/ai/EmbeddingModel.js +127 -0
  490. package/dist/unstable/ai/EmbeddingModel.js.map +1 -0
  491. package/dist/unstable/ai/IdGenerator.d.ts +2 -2
  492. package/dist/unstable/ai/IdGenerator.d.ts.map +1 -1
  493. package/dist/unstable/ai/IdGenerator.js +2 -2
  494. package/dist/unstable/ai/IdGenerator.js.map +1 -1
  495. package/dist/unstable/ai/LanguageModel.d.ts +119 -49
  496. package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
  497. package/dist/unstable/ai/LanguageModel.js +260 -61
  498. package/dist/unstable/ai/LanguageModel.js.map +1 -1
  499. package/dist/unstable/ai/McpSchema.d.ts +236 -141
  500. package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
  501. package/dist/unstable/ai/McpSchema.js +71 -19
  502. package/dist/unstable/ai/McpSchema.js.map +1 -1
  503. package/dist/unstable/ai/McpServer.d.ts +68 -15
  504. package/dist/unstable/ai/McpServer.d.ts.map +1 -1
  505. package/dist/unstable/ai/McpServer.js +218 -73
  506. package/dist/unstable/ai/McpServer.js.map +1 -1
  507. package/dist/unstable/ai/Model.d.ts +27 -9
  508. package/dist/unstable/ai/Model.d.ts.map +1 -1
  509. package/dist/unstable/ai/Model.js +25 -9
  510. package/dist/unstable/ai/Model.js.map +1 -1
  511. package/dist/unstable/ai/OpenAiStructuredOutput.d.ts +1 -1
  512. package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
  513. package/dist/unstable/ai/OpenAiStructuredOutput.js +9 -1
  514. package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
  515. package/dist/unstable/ai/Prompt.d.ts +20 -20
  516. package/dist/unstable/ai/Prompt.d.ts.map +1 -1
  517. package/dist/unstable/ai/Prompt.js +6 -9
  518. package/dist/unstable/ai/Prompt.js.map +1 -1
  519. package/dist/unstable/ai/Response.d.ts +27 -27
  520. package/dist/unstable/ai/Response.d.ts.map +1 -1
  521. package/dist/unstable/ai/Response.js +7 -8
  522. package/dist/unstable/ai/Response.js.map +1 -1
  523. package/dist/unstable/ai/ResponseIdTracker.d.ts +38 -0
  524. package/dist/unstable/ai/ResponseIdTracker.d.ts.map +1 -0
  525. package/dist/unstable/ai/ResponseIdTracker.js +68 -0
  526. package/dist/unstable/ai/ResponseIdTracker.js.map +1 -0
  527. package/dist/unstable/ai/Telemetry.d.ts +35 -2
  528. package/dist/unstable/ai/Telemetry.d.ts.map +1 -1
  529. package/dist/unstable/ai/Telemetry.js +2 -2
  530. package/dist/unstable/ai/Telemetry.js.map +1 -1
  531. package/dist/unstable/ai/Tokenizer.d.ts +2 -2
  532. package/dist/unstable/ai/Tokenizer.d.ts.map +1 -1
  533. package/dist/unstable/ai/Tokenizer.js +2 -2
  534. package/dist/unstable/ai/Tokenizer.js.map +1 -1
  535. package/dist/unstable/ai/Tool.d.ts +46 -16
  536. package/dist/unstable/ai/Tool.d.ts.map +1 -1
  537. package/dist/unstable/ai/Tool.js +68 -22
  538. package/dist/unstable/ai/Tool.js.map +1 -1
  539. package/dist/unstable/ai/Toolkit.d.ts +4 -4
  540. package/dist/unstable/ai/Toolkit.d.ts.map +1 -1
  541. package/dist/unstable/ai/Toolkit.js +14 -21
  542. package/dist/unstable/ai/Toolkit.js.map +1 -1
  543. package/dist/unstable/ai/index.d.ts +22 -1
  544. package/dist/unstable/ai/index.d.ts.map +1 -1
  545. package/dist/unstable/ai/index.js +22 -1
  546. package/dist/unstable/ai/index.js.map +1 -1
  547. package/dist/unstable/ai/internal/codec-transformer.js +5 -7
  548. package/dist/unstable/ai/internal/codec-transformer.js.map +1 -1
  549. package/dist/unstable/cli/Argument.d.ts +4 -7
  550. package/dist/unstable/cli/Argument.d.ts.map +1 -1
  551. package/dist/unstable/cli/Argument.js +1 -3
  552. package/dist/unstable/cli/Argument.js.map +1 -1
  553. package/dist/unstable/cli/CliError.d.ts +55 -67
  554. package/dist/unstable/cli/CliError.d.ts.map +1 -1
  555. package/dist/unstable/cli/CliError.js +32 -57
  556. package/dist/unstable/cli/CliError.js.map +1 -1
  557. package/dist/unstable/cli/CliOutput.d.ts +5 -4
  558. package/dist/unstable/cli/CliOutput.d.ts.map +1 -1
  559. package/dist/unstable/cli/CliOutput.js +67 -12
  560. package/dist/unstable/cli/CliOutput.js.map +1 -1
  561. package/dist/unstable/cli/Command.d.ts +372 -59
  562. package/dist/unstable/cli/Command.d.ts.map +1 -1
  563. package/dist/unstable/cli/Command.js +328 -66
  564. package/dist/unstable/cli/Command.js.map +1 -1
  565. package/dist/unstable/cli/Completions.d.ts +97 -0
  566. package/dist/unstable/cli/Completions.d.ts.map +1 -0
  567. package/dist/unstable/cli/Completions.js +25 -0
  568. package/dist/unstable/cli/Completions.js.map +1 -0
  569. package/dist/unstable/cli/Flag.d.ts +4 -5
  570. package/dist/unstable/cli/Flag.d.ts.map +1 -1
  571. package/dist/unstable/cli/Flag.js +1 -1
  572. package/dist/unstable/cli/Flag.js.map +1 -1
  573. package/dist/unstable/cli/GlobalFlag.d.ts +125 -0
  574. package/dist/unstable/cli/GlobalFlag.d.ts.map +1 -0
  575. package/dist/unstable/cli/GlobalFlag.js +118 -0
  576. package/dist/unstable/cli/GlobalFlag.js.map +1 -0
  577. package/dist/unstable/cli/HelpDoc.d.ts +81 -11
  578. package/dist/unstable/cli/HelpDoc.d.ts.map +1 -1
  579. package/dist/unstable/cli/Param.d.ts +34 -6
  580. package/dist/unstable/cli/Param.d.ts.map +1 -1
  581. package/dist/unstable/cli/Param.js +24 -14
  582. package/dist/unstable/cli/Param.js.map +1 -1
  583. package/dist/unstable/cli/Primitive.d.ts +2 -2
  584. package/dist/unstable/cli/Primitive.d.ts.map +1 -1
  585. package/dist/unstable/cli/Primitive.js +1 -1
  586. package/dist/unstable/cli/Primitive.js.map +1 -1
  587. package/dist/unstable/cli/Prompt.js +266 -86
  588. package/dist/unstable/cli/Prompt.js.map +1 -1
  589. package/dist/unstable/cli/index.d.ts +8 -0
  590. package/dist/unstable/cli/index.d.ts.map +1 -1
  591. package/dist/unstable/cli/index.js +8 -0
  592. package/dist/unstable/cli/index.js.map +1 -1
  593. package/dist/unstable/cli/internal/command.d.ts +41 -15
  594. package/dist/unstable/cli/internal/command.d.ts.map +1 -1
  595. package/dist/unstable/cli/internal/command.js +84 -47
  596. package/dist/unstable/cli/internal/command.js.map +1 -1
  597. package/dist/unstable/cli/internal/completions/bash.js.map +1 -1
  598. package/dist/unstable/cli/internal/completions/descriptor.d.ts +2 -0
  599. package/dist/unstable/cli/internal/completions/descriptor.d.ts.map +1 -0
  600. package/dist/unstable/cli/internal/completions/{CommandDescriptor.js → descriptor.js} +17 -5
  601. package/dist/unstable/cli/internal/completions/descriptor.js.map +1 -0
  602. package/dist/unstable/cli/internal/completions/fish.js.map +1 -1
  603. package/dist/unstable/cli/internal/completions/zsh.js.map +1 -1
  604. package/dist/unstable/cli/internal/config.js +42 -0
  605. package/dist/unstable/cli/internal/config.js.map +1 -1
  606. package/dist/unstable/cli/internal/help.d.ts +33 -0
  607. package/dist/unstable/cli/internal/help.d.ts.map +1 -0
  608. package/dist/unstable/cli/internal/help.js +125 -0
  609. package/dist/unstable/cli/internal/help.js.map +1 -0
  610. package/dist/unstable/cli/internal/parser.js +155 -58
  611. package/dist/unstable/cli/internal/parser.js.map +1 -1
  612. package/dist/unstable/cluster/ClusterCron.d.ts +1 -1
  613. package/dist/unstable/cluster/ClusterCron.d.ts.map +1 -1
  614. package/dist/unstable/cluster/ClusterCron.js +1 -1
  615. package/dist/unstable/cluster/ClusterCron.js.map +1 -1
  616. package/dist/unstable/cluster/ClusterError.d.ts +7 -7
  617. package/dist/unstable/cluster/ClusterSchema.d.ts +28 -7
  618. package/dist/unstable/cluster/ClusterSchema.d.ts.map +1 -1
  619. package/dist/unstable/cluster/ClusterSchema.js +28 -8
  620. package/dist/unstable/cluster/ClusterSchema.js.map +1 -1
  621. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts +4 -2
  622. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
  623. package/dist/unstable/cluster/ClusterWorkflowEngine.js +97 -63
  624. package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
  625. package/dist/unstable/cluster/DeliverAt.js +1 -1
  626. package/dist/unstable/cluster/DeliverAt.js.map +1 -1
  627. package/dist/unstable/cluster/Entity.d.ts +18 -16
  628. package/dist/unstable/cluster/Entity.d.ts.map +1 -1
  629. package/dist/unstable/cluster/Entity.js +31 -25
  630. package/dist/unstable/cluster/Entity.js.map +1 -1
  631. package/dist/unstable/cluster/EntityAddress.d.ts +2 -2
  632. package/dist/unstable/cluster/EntityAddress.d.ts.map +1 -1
  633. package/dist/unstable/cluster/EntityAddress.js +1 -1
  634. package/dist/unstable/cluster/EntityAddress.js.map +1 -1
  635. package/dist/unstable/cluster/EntityProxy.js +3 -3
  636. package/dist/unstable/cluster/EntityProxy.js.map +1 -1
  637. package/dist/unstable/cluster/EntityProxyServer.d.ts.map +1 -1
  638. package/dist/unstable/cluster/EntityProxyServer.js +4 -4
  639. package/dist/unstable/cluster/EntityProxyServer.js.map +1 -1
  640. package/dist/unstable/cluster/EntityResource.d.ts +4 -4
  641. package/dist/unstable/cluster/EntityResource.d.ts.map +1 -1
  642. package/dist/unstable/cluster/EntityResource.js +2 -2
  643. package/dist/unstable/cluster/EntityResource.js.map +1 -1
  644. package/dist/unstable/cluster/Envelope.d.ts +4 -4
  645. package/dist/unstable/cluster/HttpRunner.js +2 -2
  646. package/dist/unstable/cluster/HttpRunner.js.map +1 -1
  647. package/dist/unstable/cluster/K8sHttpClient.d.ts +5 -5
  648. package/dist/unstable/cluster/K8sHttpClient.d.ts.map +1 -1
  649. package/dist/unstable/cluster/K8sHttpClient.js +6 -6
  650. package/dist/unstable/cluster/K8sHttpClient.js.map +1 -1
  651. package/dist/unstable/cluster/Message.d.ts +21 -15
  652. package/dist/unstable/cluster/Message.d.ts.map +1 -1
  653. package/dist/unstable/cluster/Message.js +16 -8
  654. package/dist/unstable/cluster/Message.js.map +1 -1
  655. package/dist/unstable/cluster/MessageStorage.d.ts +46 -23
  656. package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
  657. package/dist/unstable/cluster/MessageStorage.js +42 -26
  658. package/dist/unstable/cluster/MessageStorage.js.map +1 -1
  659. package/dist/unstable/cluster/Reply.d.ts +10 -9
  660. package/dist/unstable/cluster/Reply.d.ts.map +1 -1
  661. package/dist/unstable/cluster/Reply.js +8 -7
  662. package/dist/unstable/cluster/Reply.js.map +1 -1
  663. package/dist/unstable/cluster/Runner.d.ts +2 -2
  664. package/dist/unstable/cluster/Runner.d.ts.map +1 -1
  665. package/dist/unstable/cluster/Runner.js +1 -1
  666. package/dist/unstable/cluster/Runner.js.map +1 -1
  667. package/dist/unstable/cluster/RunnerAddress.d.ts +1 -1
  668. package/dist/unstable/cluster/RunnerAddress.d.ts.map +1 -1
  669. package/dist/unstable/cluster/RunnerAddress.js +1 -1
  670. package/dist/unstable/cluster/RunnerAddress.js.map +1 -1
  671. package/dist/unstable/cluster/RunnerHealth.d.ts +2 -2
  672. package/dist/unstable/cluster/RunnerHealth.d.ts.map +1 -1
  673. package/dist/unstable/cluster/RunnerHealth.js +2 -2
  674. package/dist/unstable/cluster/RunnerHealth.js.map +1 -1
  675. package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
  676. package/dist/unstable/cluster/RunnerServer.js +10 -9
  677. package/dist/unstable/cluster/RunnerServer.js.map +1 -1
  678. package/dist/unstable/cluster/RunnerStorage.d.ts +12 -12
  679. package/dist/unstable/cluster/RunnerStorage.d.ts.map +1 -1
  680. package/dist/unstable/cluster/RunnerStorage.js +3 -3
  681. package/dist/unstable/cluster/RunnerStorage.js.map +1 -1
  682. package/dist/unstable/cluster/Runners.d.ts +5 -4
  683. package/dist/unstable/cluster/Runners.d.ts.map +1 -1
  684. package/dist/unstable/cluster/Runners.js +18 -16
  685. package/dist/unstable/cluster/Runners.js.map +1 -1
  686. package/dist/unstable/cluster/ShardId.d.ts +35 -49
  687. package/dist/unstable/cluster/ShardId.d.ts.map +1 -1
  688. package/dist/unstable/cluster/ShardId.js +65 -67
  689. package/dist/unstable/cluster/ShardId.js.map +1 -1
  690. package/dist/unstable/cluster/Sharding.d.ts +4 -4
  691. package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
  692. package/dist/unstable/cluster/Sharding.js +66 -54
  693. package/dist/unstable/cluster/Sharding.js.map +1 -1
  694. package/dist/unstable/cluster/ShardingConfig.d.ts +28 -27
  695. package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
  696. package/dist/unstable/cluster/ShardingConfig.js +27 -27
  697. package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
  698. package/dist/unstable/cluster/SingletonAddress.d.ts +2 -2
  699. package/dist/unstable/cluster/Snowflake.d.ts +2 -2
  700. package/dist/unstable/cluster/Snowflake.d.ts.map +1 -1
  701. package/dist/unstable/cluster/Snowflake.js +2 -2
  702. package/dist/unstable/cluster/Snowflake.js.map +1 -1
  703. package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
  704. package/dist/unstable/cluster/SqlMessageStorage.js +23 -20
  705. package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
  706. package/dist/unstable/cluster/SqlRunnerStorage.js +1 -1
  707. package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
  708. package/dist/unstable/cluster/internal/entityManager.js +34 -27
  709. package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
  710. package/dist/unstable/cluster/internal/entityReaper.js +4 -3
  711. package/dist/unstable/cluster/internal/entityReaper.js.map +1 -1
  712. package/dist/unstable/cluster/internal/resourceMap.js +3 -3
  713. package/dist/unstable/cluster/internal/resourceMap.js.map +1 -1
  714. package/dist/unstable/cluster/internal/resourceRef.js +2 -1
  715. package/dist/unstable/cluster/internal/resourceRef.js.map +1 -1
  716. package/dist/unstable/devtools/DevToolsClient.d.ts +2 -2
  717. package/dist/unstable/devtools/DevToolsClient.d.ts.map +1 -1
  718. package/dist/unstable/devtools/DevToolsClient.js +9 -8
  719. package/dist/unstable/devtools/DevToolsClient.js.map +1 -1
  720. package/dist/unstable/devtools/DevToolsSchema.d.ts +40 -40
  721. package/dist/unstable/devtools/DevToolsSchema.d.ts.map +1 -1
  722. package/dist/unstable/devtools/DevToolsSchema.js +9 -2
  723. package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
  724. package/dist/unstable/encoding/Msgpack.d.ts +1 -1
  725. package/dist/unstable/encoding/Ndjson.d.ts +9 -9
  726. package/dist/unstable/encoding/Ndjson.d.ts.map +1 -1
  727. package/dist/unstable/encoding/Ndjson.js.map +1 -1
  728. package/dist/unstable/encoding/Sse.d.ts +4 -4
  729. package/dist/unstable/encoding/Sse.d.ts.map +1 -1
  730. package/dist/unstable/encoding/Sse.js +1 -1
  731. package/dist/unstable/encoding/Sse.js.map +1 -1
  732. package/dist/unstable/eventlog/Event.d.ts +0 -6
  733. package/dist/unstable/eventlog/Event.d.ts.map +1 -1
  734. package/dist/unstable/eventlog/Event.js +0 -5
  735. package/dist/unstable/eventlog/Event.js.map +1 -1
  736. package/dist/unstable/eventlog/EventGroup.d.ts +0 -2
  737. package/dist/unstable/eventlog/EventGroup.d.ts.map +1 -1
  738. package/dist/unstable/eventlog/EventGroup.js +0 -2
  739. package/dist/unstable/eventlog/EventGroup.js.map +1 -1
  740. package/dist/unstable/eventlog/EventJournal.d.ts +28 -11
  741. package/dist/unstable/eventlog/EventJournal.d.ts.map +1 -1
  742. package/dist/unstable/eventlog/EventJournal.js +130 -71
  743. package/dist/unstable/eventlog/EventJournal.js.map +1 -1
  744. package/dist/unstable/eventlog/EventLog.d.ts +94 -37
  745. package/dist/unstable/eventlog/EventLog.d.ts.map +1 -1
  746. package/dist/unstable/eventlog/EventLog.js +225 -150
  747. package/dist/unstable/eventlog/EventLog.js.map +1 -1
  748. package/dist/unstable/eventlog/EventLogEncryption.d.ts +11 -9
  749. package/dist/unstable/eventlog/EventLogEncryption.d.ts.map +1 -1
  750. package/dist/unstable/eventlog/EventLogEncryption.js +15 -17
  751. package/dist/unstable/eventlog/EventLogEncryption.js.map +1 -1
  752. package/dist/unstable/eventlog/EventLogMessage.d.ts +228 -0
  753. package/dist/unstable/eventlog/EventLogMessage.d.ts.map +1 -0
  754. package/dist/unstable/eventlog/EventLogMessage.js +214 -0
  755. package/dist/unstable/eventlog/EventLogMessage.js.map +1 -0
  756. package/dist/unstable/eventlog/EventLogRemote.d.ts +112 -194
  757. package/dist/unstable/eventlog/EventLogRemote.d.ts.map +1 -1
  758. package/dist/unstable/eventlog/EventLogRemote.js +168 -322
  759. package/dist/unstable/eventlog/EventLogRemote.js.map +1 -1
  760. package/dist/unstable/eventlog/EventLogServer.d.ts +26 -48
  761. package/dist/unstable/eventlog/EventLogServer.d.ts.map +1 -1
  762. package/dist/unstable/eventlog/EventLogServer.js +128 -199
  763. package/dist/unstable/eventlog/EventLogServer.js.map +1 -1
  764. package/dist/unstable/eventlog/EventLogServerEncrypted.d.ts +60 -0
  765. package/dist/unstable/eventlog/EventLogServerEncrypted.d.ts.map +1 -0
  766. package/dist/unstable/eventlog/EventLogServerEncrypted.js +166 -0
  767. package/dist/unstable/eventlog/EventLogServerEncrypted.js.map +1 -0
  768. package/dist/unstable/eventlog/EventLogServerUnencrypted.d.ts +183 -0
  769. package/dist/unstable/eventlog/EventLogServerUnencrypted.d.ts.map +1 -0
  770. package/dist/unstable/eventlog/EventLogServerUnencrypted.js +461 -0
  771. package/dist/unstable/eventlog/EventLogServerUnencrypted.js.map +1 -0
  772. package/dist/unstable/eventlog/EventLogSessionAuth.d.ts +117 -0
  773. package/dist/unstable/eventlog/EventLogSessionAuth.d.ts.map +1 -0
  774. package/dist/unstable/eventlog/EventLogSessionAuth.js +284 -0
  775. package/dist/unstable/eventlog/EventLogSessionAuth.js.map +1 -0
  776. package/dist/unstable/eventlog/{SqlEventLogJournal.d.ts → SqlEventJournal.d.ts} +2 -2
  777. package/dist/unstable/eventlog/SqlEventJournal.d.ts.map +1 -0
  778. package/dist/unstable/eventlog/{SqlEventLogJournal.js → SqlEventJournal.js} +22 -16
  779. package/dist/unstable/eventlog/SqlEventJournal.js.map +1 -0
  780. package/dist/unstable/eventlog/{SqlEventLogServer.d.ts → SqlEventLogServerEncrypted.d.ts} +5 -5
  781. package/dist/unstable/eventlog/SqlEventLogServerEncrypted.d.ts.map +1 -0
  782. package/dist/unstable/eventlog/{SqlEventLogServer.js → SqlEventLogServerEncrypted.js} +65 -24
  783. package/dist/unstable/eventlog/SqlEventLogServerEncrypted.js.map +1 -0
  784. package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.d.ts +25 -0
  785. package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.d.ts.map +1 -0
  786. package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js +354 -0
  787. package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js.map +1 -0
  788. package/dist/unstable/eventlog/index.d.ts +22 -2
  789. package/dist/unstable/eventlog/index.d.ts.map +1 -1
  790. package/dist/unstable/eventlog/index.js +22 -2
  791. package/dist/unstable/eventlog/index.js.map +1 -1
  792. package/dist/unstable/eventlog/internal/identityRootSecretDerivation.d.ts +2 -0
  793. package/dist/unstable/eventlog/internal/identityRootSecretDerivation.d.ts.map +1 -0
  794. package/dist/unstable/eventlog/internal/identityRootSecretDerivation.js +89 -0
  795. package/dist/unstable/eventlog/internal/identityRootSecretDerivation.js.map +1 -0
  796. package/dist/unstable/http/Cookies.d.ts +52 -7
  797. package/dist/unstable/http/Cookies.d.ts.map +1 -1
  798. package/dist/unstable/http/Cookies.js +27 -6
  799. package/dist/unstable/http/Cookies.js.map +1 -1
  800. package/dist/unstable/http/Etag.d.ts +2 -2
  801. package/dist/unstable/http/Etag.d.ts.map +1 -1
  802. package/dist/unstable/http/Etag.js +7 -3
  803. package/dist/unstable/http/Etag.js.map +1 -1
  804. package/dist/unstable/http/FetchHttpClient.d.ts +6 -3
  805. package/dist/unstable/http/FetchHttpClient.d.ts.map +1 -1
  806. package/dist/unstable/http/FetchHttpClient.js +5 -5
  807. package/dist/unstable/http/FetchHttpClient.js.map +1 -1
  808. package/dist/unstable/http/Headers.d.ts +24 -4
  809. package/dist/unstable/http/Headers.d.ts.map +1 -1
  810. package/dist/unstable/http/Headers.js +42 -13
  811. package/dist/unstable/http/Headers.js.map +1 -1
  812. package/dist/unstable/http/HttpBody.d.ts +1 -1
  813. package/dist/unstable/http/HttpClient.d.ts +125 -21
  814. package/dist/unstable/http/HttpClient.d.ts.map +1 -1
  815. package/dist/unstable/http/HttpClient.js +197 -19
  816. package/dist/unstable/http/HttpClient.js.map +1 -1
  817. package/dist/unstable/http/HttpClientError.d.ts +8 -8
  818. package/dist/unstable/http/HttpClientRequest.d.ts +43 -15
  819. package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
  820. package/dist/unstable/http/HttpClientRequest.js +131 -21
  821. package/dist/unstable/http/HttpClientRequest.js.map +1 -1
  822. package/dist/unstable/http/HttpClientResponse.d.ts +2 -1
  823. package/dist/unstable/http/HttpClientResponse.d.ts.map +1 -1
  824. package/dist/unstable/http/HttpClientResponse.js +6 -1
  825. package/dist/unstable/http/HttpClientResponse.js.map +1 -1
  826. package/dist/unstable/http/HttpEffect.d.ts +13 -11
  827. package/dist/unstable/http/HttpEffect.d.ts.map +1 -1
  828. package/dist/unstable/http/HttpEffect.js +67 -75
  829. package/dist/unstable/http/HttpEffect.js.map +1 -1
  830. package/dist/unstable/http/HttpIncomingMessage.d.ts +5 -4
  831. package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
  832. package/dist/unstable/http/HttpIncomingMessage.js +2 -2
  833. package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
  834. package/dist/unstable/http/HttpMethod.d.ts +4 -4
  835. package/dist/unstable/http/HttpMethod.d.ts.map +1 -1
  836. package/dist/unstable/http/HttpMethod.js +3 -3
  837. package/dist/unstable/http/HttpMethod.js.map +1 -1
  838. package/dist/unstable/http/HttpMiddleware.d.ts +4 -9
  839. package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
  840. package/dist/unstable/http/HttpMiddleware.js +47 -43
  841. package/dist/unstable/http/HttpMiddleware.js.map +1 -1
  842. package/dist/unstable/http/HttpPlatform.d.ts +2 -2
  843. package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
  844. package/dist/unstable/http/HttpPlatform.js +5 -4
  845. package/dist/unstable/http/HttpPlatform.js.map +1 -1
  846. package/dist/unstable/http/HttpRouter.d.ts +9 -8
  847. package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
  848. package/dist/unstable/http/HttpRouter.js +36 -36
  849. package/dist/unstable/http/HttpRouter.js.map +1 -1
  850. package/dist/unstable/http/HttpServer.d.ts +2 -2
  851. package/dist/unstable/http/HttpServer.d.ts.map +1 -1
  852. package/dist/unstable/http/HttpServer.js +4 -4
  853. package/dist/unstable/http/HttpServer.js.map +1 -1
  854. package/dist/unstable/http/HttpServerError.d.ts +22 -34
  855. package/dist/unstable/http/HttpServerError.d.ts.map +1 -1
  856. package/dist/unstable/http/HttpServerError.js +39 -45
  857. package/dist/unstable/http/HttpServerError.js.map +1 -1
  858. package/dist/unstable/http/HttpServerRequest.d.ts +19 -7
  859. package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
  860. package/dist/unstable/http/HttpServerRequest.js +307 -13
  861. package/dist/unstable/http/HttpServerRequest.js.map +1 -1
  862. package/dist/unstable/http/HttpServerRespondable.d.ts +2 -2
  863. package/dist/unstable/http/HttpServerRespondable.d.ts.map +1 -1
  864. package/dist/unstable/http/HttpServerRespondable.js +5 -5
  865. package/dist/unstable/http/HttpServerRespondable.js.map +1 -1
  866. package/dist/unstable/http/HttpServerResponse.d.ts +52 -5
  867. package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
  868. package/dist/unstable/http/HttpServerResponse.js +240 -5
  869. package/dist/unstable/http/HttpServerResponse.js.map +1 -1
  870. package/dist/unstable/http/HttpStaticServer.d.ts +69 -0
  871. package/dist/unstable/http/HttpStaticServer.d.ts.map +1 -0
  872. package/dist/unstable/http/HttpStaticServer.js +353 -0
  873. package/dist/unstable/http/HttpStaticServer.js.map +1 -0
  874. package/dist/unstable/http/HttpTraceContext.d.ts +3 -2
  875. package/dist/unstable/http/HttpTraceContext.d.ts.map +1 -1
  876. package/dist/unstable/http/HttpTraceContext.js +27 -15
  877. package/dist/unstable/http/HttpTraceContext.js.map +1 -1
  878. package/dist/unstable/http/Multipart.d.ts +9 -9
  879. package/dist/unstable/http/Multipart.d.ts.map +1 -1
  880. package/dist/unstable/http/Multipart.js +7 -7
  881. package/dist/unstable/http/Multipart.js.map +1 -1
  882. package/dist/unstable/http/Url.d.ts +604 -0
  883. package/dist/unstable/http/Url.d.ts.map +1 -0
  884. package/dist/unstable/http/Url.js +256 -0
  885. package/dist/unstable/http/Url.js.map +1 -0
  886. package/dist/unstable/http/UrlParams.d.ts +19 -10
  887. package/dist/unstable/http/UrlParams.d.ts.map +1 -1
  888. package/dist/unstable/http/UrlParams.js +6 -7
  889. package/dist/unstable/http/UrlParams.js.map +1 -1
  890. package/dist/unstable/http/index.d.ts +8 -0
  891. package/dist/unstable/http/index.d.ts.map +1 -1
  892. package/dist/unstable/http/index.js +8 -0
  893. package/dist/unstable/http/index.js.map +1 -1
  894. package/dist/unstable/http/internal/preResponseHandler.d.ts +2 -0
  895. package/dist/unstable/http/internal/preResponseHandler.d.ts.map +1 -0
  896. package/dist/unstable/http/internal/preResponseHandler.js +10 -0
  897. package/dist/unstable/http/internal/preResponseHandler.js.map +1 -0
  898. package/dist/unstable/httpapi/HttpApi.d.ts +11 -11
  899. package/dist/unstable/httpapi/HttpApi.d.ts.map +1 -1
  900. package/dist/unstable/httpapi/HttpApi.js +8 -8
  901. package/dist/unstable/httpapi/HttpApi.js.map +1 -1
  902. package/dist/unstable/httpapi/HttpApiBuilder.d.ts +12 -9
  903. package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
  904. package/dist/unstable/httpapi/HttpApiBuilder.js +53 -39
  905. package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
  906. package/dist/unstable/httpapi/HttpApiClient.d.ts +83 -7
  907. package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
  908. package/dist/unstable/httpapi/HttpApiClient.js +79 -11
  909. package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
  910. package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +211 -105
  911. package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
  912. package/dist/unstable/httpapi/HttpApiEndpoint.js +53 -47
  913. package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
  914. package/dist/unstable/httpapi/HttpApiError.d.ts +43 -26
  915. package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
  916. package/dist/unstable/httpapi/HttpApiError.js +125 -32
  917. package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
  918. package/dist/unstable/httpapi/HttpApiGroup.d.ts +9 -8
  919. package/dist/unstable/httpapi/HttpApiGroup.d.ts.map +1 -1
  920. package/dist/unstable/httpapi/HttpApiGroup.js +4 -4
  921. package/dist/unstable/httpapi/HttpApiGroup.js.map +1 -1
  922. package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +49 -18
  923. package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
  924. package/dist/unstable/httpapi/HttpApiMiddleware.js +38 -8
  925. package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
  926. package/dist/unstable/httpapi/HttpApiScalar.d.ts +6 -0
  927. package/dist/unstable/httpapi/HttpApiScalar.d.ts.map +1 -1
  928. package/dist/unstable/httpapi/HttpApiScalar.js.map +1 -1
  929. package/dist/unstable/httpapi/HttpApiSchema.d.ts +88 -9
  930. package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
  931. package/dist/unstable/httpapi/HttpApiSchema.js +86 -11
  932. package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
  933. package/dist/unstable/httpapi/HttpApiSecurity.d.ts +9 -6
  934. package/dist/unstable/httpapi/HttpApiSecurity.d.ts.map +1 -1
  935. package/dist/unstable/httpapi/HttpApiSecurity.js +6 -6
  936. package/dist/unstable/httpapi/HttpApiSecurity.js.map +1 -1
  937. package/dist/unstable/httpapi/OpenApi.d.ts +16 -15
  938. package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
  939. package/dist/unstable/httpapi/OpenApi.js +57 -49
  940. package/dist/unstable/httpapi/OpenApi.js.map +1 -1
  941. package/dist/unstable/observability/Otlp.d.ts +12 -12
  942. package/dist/unstable/observability/Otlp.d.ts.map +1 -1
  943. package/dist/unstable/observability/OtlpExporter.d.ts +2 -2
  944. package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
  945. package/dist/unstable/observability/OtlpExporter.js +8 -8
  946. package/dist/unstable/observability/OtlpExporter.js.map +1 -1
  947. package/dist/unstable/observability/OtlpLogger.d.ts +4 -4
  948. package/dist/unstable/observability/OtlpLogger.d.ts.map +1 -1
  949. package/dist/unstable/observability/OtlpLogger.js +7 -4
  950. package/dist/unstable/observability/OtlpLogger.js.map +1 -1
  951. package/dist/unstable/observability/OtlpMetrics.d.ts +4 -4
  952. package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
  953. package/dist/unstable/observability/OtlpMetrics.js +1 -1
  954. package/dist/unstable/observability/OtlpMetrics.js.map +1 -1
  955. package/dist/unstable/observability/OtlpSerialization.d.ts +2 -2
  956. package/dist/unstable/observability/OtlpSerialization.d.ts.map +1 -1
  957. package/dist/unstable/observability/OtlpSerialization.js +2 -2
  958. package/dist/unstable/observability/OtlpSerialization.js.map +1 -1
  959. package/dist/unstable/observability/OtlpTracer.d.ts +4 -4
  960. package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
  961. package/dist/unstable/observability/OtlpTracer.js +7 -3
  962. package/dist/unstable/observability/OtlpTracer.js.map +1 -1
  963. package/dist/unstable/observability/PrometheusMetrics.d.ts +3 -3
  964. package/dist/unstable/observability/PrometheusMetrics.d.ts.map +1 -1
  965. package/dist/unstable/observability/PrometheusMetrics.js +4 -33
  966. package/dist/unstable/observability/PrometheusMetrics.js.map +1 -1
  967. package/dist/unstable/persistence/KeyValueStore.d.ts +24 -3
  968. package/dist/unstable/persistence/KeyValueStore.d.ts.map +1 -1
  969. package/dist/unstable/persistence/KeyValueStore.js +148 -6
  970. package/dist/unstable/persistence/KeyValueStore.js.map +1 -1
  971. package/dist/unstable/persistence/Persistable.d.ts +2 -2
  972. package/dist/unstable/persistence/Persistable.d.ts.map +1 -1
  973. package/dist/unstable/persistence/Persistable.js +1 -1
  974. package/dist/unstable/persistence/Persistable.js.map +1 -1
  975. package/dist/unstable/persistence/PersistedCache.d.ts +6 -6
  976. package/dist/unstable/persistence/PersistedCache.d.ts.map +1 -1
  977. package/dist/unstable/persistence/PersistedCache.js +12 -12
  978. package/dist/unstable/persistence/PersistedCache.js.map +1 -1
  979. package/dist/unstable/persistence/PersistedQueue.d.ts +16 -16
  980. package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
  981. package/dist/unstable/persistence/PersistedQueue.js +15 -14
  982. package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
  983. package/dist/unstable/persistence/Persistence.d.ts +5 -5
  984. package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
  985. package/dist/unstable/persistence/Persistence.js +5 -5
  986. package/dist/unstable/persistence/Persistence.js.map +1 -1
  987. package/dist/unstable/persistence/RateLimiter.d.ts +9 -9
  988. package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
  989. package/dist/unstable/persistence/RateLimiter.js +4 -4
  990. package/dist/unstable/persistence/RateLimiter.js.map +1 -1
  991. package/dist/unstable/persistence/Redis.d.ts +3 -3
  992. package/dist/unstable/persistence/Redis.d.ts.map +1 -1
  993. package/dist/unstable/persistence/Redis.js +2 -2
  994. package/dist/unstable/persistence/Redis.js.map +1 -1
  995. package/dist/unstable/process/ChildProcess.d.ts +5 -128
  996. package/dist/unstable/process/ChildProcess.d.ts.map +1 -1
  997. package/dist/unstable/process/ChildProcess.js +1 -65
  998. package/dist/unstable/process/ChildProcess.js.map +1 -1
  999. package/dist/unstable/process/ChildProcessSpawner.d.ts +89 -8
  1000. package/dist/unstable/process/ChildProcessSpawner.d.ts.map +1 -1
  1001. package/dist/unstable/process/ChildProcessSpawner.js +22 -2
  1002. package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
  1003. package/dist/unstable/reactivity/Atom.d.ts +108 -47
  1004. package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
  1005. package/dist/unstable/reactivity/Atom.js +105 -25
  1006. package/dist/unstable/reactivity/Atom.js.map +1 -1
  1007. package/dist/unstable/reactivity/AtomHttpApi.d.ts +22 -20
  1008. package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
  1009. package/dist/unstable/reactivity/AtomHttpApi.js +58 -26
  1010. package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
  1011. package/dist/unstable/reactivity/AtomRegistry.d.ts +8 -2
  1012. package/dist/unstable/reactivity/AtomRegistry.d.ts.map +1 -1
  1013. package/dist/unstable/reactivity/AtomRegistry.js +57 -14
  1014. package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
  1015. package/dist/unstable/reactivity/AtomRpc.d.ts +12 -12
  1016. package/dist/unstable/reactivity/AtomRpc.d.ts.map +1 -1
  1017. package/dist/unstable/reactivity/AtomRpc.js +59 -31
  1018. package/dist/unstable/reactivity/AtomRpc.js.map +1 -1
  1019. package/dist/unstable/reactivity/Reactivity.d.ts +2 -2
  1020. package/dist/unstable/reactivity/Reactivity.d.ts.map +1 -1
  1021. package/dist/unstable/reactivity/Reactivity.js +6 -6
  1022. package/dist/unstable/reactivity/Reactivity.js.map +1 -1
  1023. package/dist/unstable/reactivity/index.d.ts +2 -2
  1024. package/dist/unstable/reactivity/index.d.ts.map +1 -1
  1025. package/dist/unstable/reactivity/index.js +2 -2
  1026. package/dist/unstable/reactivity/index.js.map +1 -1
  1027. package/dist/unstable/rpc/Rpc.d.ts +47 -19
  1028. package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
  1029. package/dist/unstable/rpc/Rpc.js +39 -7
  1030. package/dist/unstable/rpc/Rpc.js.map +1 -1
  1031. package/dist/unstable/rpc/RpcClient.d.ts +26 -47
  1032. package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
  1033. package/dist/unstable/rpc/RpcClient.js +120 -77
  1034. package/dist/unstable/rpc/RpcClient.js.map +1 -1
  1035. package/dist/unstable/rpc/RpcClientError.d.ts +2 -2
  1036. package/dist/unstable/rpc/RpcGroup.d.ts +15 -11
  1037. package/dist/unstable/rpc/RpcGroup.d.ts.map +1 -1
  1038. package/dist/unstable/rpc/RpcGroup.js +30 -20
  1039. package/dist/unstable/rpc/RpcGroup.js.map +1 -1
  1040. package/dist/unstable/rpc/RpcMiddleware.d.ts +12 -12
  1041. package/dist/unstable/rpc/RpcMiddleware.d.ts.map +1 -1
  1042. package/dist/unstable/rpc/RpcMiddleware.js +5 -5
  1043. package/dist/unstable/rpc/RpcMiddleware.js.map +1 -1
  1044. package/dist/unstable/rpc/RpcSchema.d.ts +14 -1
  1045. package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
  1046. package/dist/unstable/rpc/RpcSchema.js +17 -2
  1047. package/dist/unstable/rpc/RpcSchema.js.map +1 -1
  1048. package/dist/unstable/rpc/RpcSerialization.d.ts +2 -2
  1049. package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
  1050. package/dist/unstable/rpc/RpcSerialization.js +46 -18
  1051. package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
  1052. package/dist/unstable/rpc/RpcServer.d.ts +8 -12
  1053. package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
  1054. package/dist/unstable/rpc/RpcServer.js +78 -46
  1055. package/dist/unstable/rpc/RpcServer.js.map +1 -1
  1056. package/dist/unstable/rpc/RpcWorker.d.ts +2 -2
  1057. package/dist/unstable/rpc/RpcWorker.d.ts.map +1 -1
  1058. package/dist/unstable/rpc/RpcWorker.js +4 -4
  1059. package/dist/unstable/rpc/RpcWorker.js.map +1 -1
  1060. package/dist/unstable/rpc/Utils.d.ts +6 -3
  1061. package/dist/unstable/rpc/Utils.d.ts.map +1 -1
  1062. package/dist/unstable/rpc/Utils.js +48 -6
  1063. package/dist/unstable/rpc/Utils.js.map +1 -1
  1064. package/dist/unstable/schema/Model.d.ts +24 -3
  1065. package/dist/unstable/schema/Model.d.ts.map +1 -1
  1066. package/dist/unstable/schema/Model.js +17 -4
  1067. package/dist/unstable/schema/Model.js.map +1 -1
  1068. package/dist/unstable/schema/VariantSchema.d.ts +7 -7
  1069. package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
  1070. package/dist/unstable/schema/VariantSchema.js +7 -18
  1071. package/dist/unstable/schema/VariantSchema.js.map +1 -1
  1072. package/dist/unstable/socket/Socket.d.ts +16 -15
  1073. package/dist/unstable/socket/Socket.d.ts.map +1 -1
  1074. package/dist/unstable/socket/Socket.js +22 -19
  1075. package/dist/unstable/socket/Socket.js.map +1 -1
  1076. package/dist/unstable/socket/SocketServer.d.ts +8 -5
  1077. package/dist/unstable/socket/SocketServer.d.ts.map +1 -1
  1078. package/dist/unstable/socket/SocketServer.js +2 -2
  1079. package/dist/unstable/socket/SocketServer.js.map +1 -1
  1080. package/dist/unstable/sql/Migrator.d.ts +1 -1
  1081. package/dist/unstable/sql/Migrator.d.ts.map +1 -1
  1082. package/dist/unstable/sql/Migrator.js +2 -2
  1083. package/dist/unstable/sql/Migrator.js.map +1 -1
  1084. package/dist/unstable/sql/SqlClient.d.ts +5 -5
  1085. package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
  1086. package/dist/unstable/sql/SqlClient.js +7 -7
  1087. package/dist/unstable/sql/SqlClient.js.map +1 -1
  1088. package/dist/unstable/sql/SqlConnection.d.ts +2 -2
  1089. package/dist/unstable/sql/SqlConnection.d.ts.map +1 -1
  1090. package/dist/unstable/sql/SqlConnection.js +5 -2
  1091. package/dist/unstable/sql/SqlConnection.js.map +1 -1
  1092. package/dist/unstable/sql/SqlError.d.ts +237 -17
  1093. package/dist/unstable/sql/SqlError.d.ts.map +1 -1
  1094. package/dist/unstable/sql/SqlError.js +260 -4
  1095. package/dist/unstable/sql/SqlError.js.map +1 -1
  1096. package/dist/unstable/sql/SqlModel.d.ts +8 -9
  1097. package/dist/unstable/sql/SqlModel.d.ts.map +1 -1
  1098. package/dist/unstable/sql/SqlModel.js +12 -38
  1099. package/dist/unstable/sql/SqlModel.js.map +1 -1
  1100. package/dist/unstable/sql/SqlResolver.d.ts.map +1 -1
  1101. package/dist/unstable/sql/SqlResolver.js +26 -17
  1102. package/dist/unstable/sql/SqlResolver.js.map +1 -1
  1103. package/dist/unstable/sql/SqlSchema.d.ts +17 -6
  1104. package/dist/unstable/sql/SqlSchema.d.ts.map +1 -1
  1105. package/dist/unstable/sql/SqlSchema.js +17 -7
  1106. package/dist/unstable/sql/SqlSchema.js.map +1 -1
  1107. package/dist/unstable/sql/Statement.d.ts +2 -2
  1108. package/dist/unstable/sql/Statement.d.ts.map +1 -1
  1109. package/dist/unstable/sql/Statement.js +2 -3
  1110. package/dist/unstable/sql/Statement.js.map +1 -1
  1111. package/dist/unstable/workers/Transferable.d.ts +4 -4
  1112. package/dist/unstable/workers/Transferable.d.ts.map +1 -1
  1113. package/dist/unstable/workers/Transferable.js +7 -7
  1114. package/dist/unstable/workers/Transferable.js.map +1 -1
  1115. package/dist/unstable/workers/Worker.d.ts +3 -3
  1116. package/dist/unstable/workers/Worker.d.ts.map +1 -1
  1117. package/dist/unstable/workers/Worker.js +8 -4
  1118. package/dist/unstable/workers/Worker.js.map +1 -1
  1119. package/dist/unstable/workers/WorkerError.d.ts +5 -5
  1120. package/dist/unstable/workers/WorkerRunner.d.ts +2 -2
  1121. package/dist/unstable/workers/WorkerRunner.d.ts.map +1 -1
  1122. package/dist/unstable/workers/WorkerRunner.js +5 -2
  1123. package/dist/unstable/workers/WorkerRunner.js.map +1 -1
  1124. package/dist/unstable/workflow/Activity.d.ts +7 -2
  1125. package/dist/unstable/workflow/Activity.d.ts.map +1 -1
  1126. package/dist/unstable/workflow/Activity.js +17 -4
  1127. package/dist/unstable/workflow/Activity.js.map +1 -1
  1128. package/dist/unstable/workflow/DurableClock.d.ts +3 -6
  1129. package/dist/unstable/workflow/DurableClock.d.ts.map +1 -1
  1130. package/dist/unstable/workflow/DurableClock.js +6 -6
  1131. package/dist/unstable/workflow/DurableClock.js.map +1 -1
  1132. package/dist/unstable/workflow/DurableDeferred.d.ts +1 -1
  1133. package/dist/unstable/workflow/DurableDeferred.d.ts.map +1 -1
  1134. package/dist/unstable/workflow/DurableDeferred.js +15 -15
  1135. package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
  1136. package/dist/unstable/workflow/Workflow.d.ts +13 -12
  1137. package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
  1138. package/dist/unstable/workflow/Workflow.js +18 -18
  1139. package/dist/unstable/workflow/Workflow.js.map +1 -1
  1140. package/dist/unstable/workflow/WorkflowEngine.d.ts +26 -8
  1141. package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
  1142. package/dist/unstable/workflow/WorkflowEngine.js +167 -17
  1143. package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
  1144. package/dist/unstable/workflow/WorkflowProxyServer.d.ts.map +1 -1
  1145. package/dist/unstable/workflow/WorkflowProxyServer.js +4 -4
  1146. package/dist/unstable/workflow/WorkflowProxyServer.js.map +1 -1
  1147. package/package.json +11 -11
  1148. package/src/Array.ts +304 -447
  1149. package/src/BigDecimal.ts +117 -66
  1150. package/src/BigInt.ts +49 -41
  1151. package/src/Brand.ts +1 -1
  1152. package/src/Cache.ts +27 -54
  1153. package/src/Cause.ts +58 -23
  1154. package/src/Channel.ts +693 -224
  1155. package/src/Chunk.ts +149 -331
  1156. package/src/Clock.ts +2 -2
  1157. package/src/Combiner.ts +280 -13
  1158. package/src/Config.ts +197 -27
  1159. package/src/ConfigProvider.ts +5 -5
  1160. package/src/Console.ts +2 -2
  1161. package/src/Context.ts +1454 -0
  1162. package/src/Cron.ts +155 -63
  1163. package/src/Data.ts +539 -376
  1164. package/src/DateTime.ts +77 -258
  1165. package/src/Deferred.ts +15 -6
  1166. package/src/Duration.ts +122 -66
  1167. package/src/Effect.ts +1629 -1355
  1168. package/src/Encoding.ts +879 -0
  1169. package/src/Equal.ts +295 -111
  1170. package/src/Equivalence.ts +114 -52
  1171. package/src/ErrorReporter.ts +458 -0
  1172. package/src/ExecutionPlan.ts +8 -9
  1173. package/src/Exit.ts +24 -12
  1174. package/src/Fiber.ts +17 -8
  1175. package/src/FiberHandle.ts +15 -14
  1176. package/src/FiberMap.ts +27 -27
  1177. package/src/FiberSet.ts +5 -5
  1178. package/src/FileSystem.ts +34 -30
  1179. package/src/Filter.ts +4 -62
  1180. package/src/Formatter.ts +253 -51
  1181. package/src/Function.ts +2 -10
  1182. package/src/Graph.ts +131 -117
  1183. package/src/Hash.ts +2 -2
  1184. package/src/HashMap.ts +26 -19
  1185. package/src/Iterable.ts +117 -63
  1186. package/src/JsonSchema.ts +383 -10
  1187. package/src/Latch.ts +194 -0
  1188. package/src/Layer.ts +728 -441
  1189. package/src/LayerMap.ts +38 -35
  1190. package/src/LogLevel.ts +37 -0
  1191. package/src/Logger.ts +35 -102
  1192. package/src/ManagedRuntime.ts +61 -48
  1193. package/src/Metric.ts +64 -66
  1194. package/src/MutableHashMap.ts +9 -0
  1195. package/src/MutableHashSet.ts +9 -0
  1196. package/src/MutableList.ts +3 -0
  1197. package/src/Newtype.ts +308 -0
  1198. package/src/Number.ts +98 -29
  1199. package/src/Optic.ts +948 -19
  1200. package/src/Option.ts +34 -24
  1201. package/src/Order.ts +39 -32
  1202. package/src/PartitionedSemaphore.ts +288 -56
  1203. package/src/Path.ts +2 -2
  1204. package/src/Pipeable.ts +32 -1
  1205. package/src/Pool.ts +18 -16
  1206. package/src/PubSub.ts +30 -20
  1207. package/src/Pull.ts +1 -1
  1208. package/src/Queue.ts +11 -9
  1209. package/src/Random.ts +51 -14
  1210. package/src/RcMap.ts +19 -19
  1211. package/src/RcRef.ts +1 -1
  1212. package/src/Record.ts +94 -199
  1213. package/src/Redactable.ts +146 -72
  1214. package/src/Reducer.ts +166 -7
  1215. package/src/References.ts +283 -287
  1216. package/src/Request.ts +8 -7
  1217. package/src/RequestResolver.ts +34 -55
  1218. package/src/Resource.ts +6 -5
  1219. package/src/Result.ts +2 -4
  1220. package/src/Runtime.ts +102 -6
  1221. package/src/Schedule.ts +460 -451
  1222. package/src/Scheduler.ts +52 -129
  1223. package/src/Schema.ts +4102 -663
  1224. package/src/SchemaAST.ts +177 -47
  1225. package/src/SchemaGetter.ts +88 -32
  1226. package/src/SchemaParser.ts +92 -27
  1227. package/src/SchemaRepresentation.ts +59 -32
  1228. package/src/SchemaTransformation.ts +364 -13
  1229. package/src/Scope.ts +2 -2
  1230. package/src/ScopedCache.ts +8 -8
  1231. package/src/Semaphore.ts +442 -0
  1232. package/src/Sink.ts +89 -34
  1233. package/src/Stdio.ts +29 -6
  1234. package/src/Stream.ts +898 -752
  1235. package/src/String.ts +122 -69
  1236. package/src/Struct.ts +33 -7
  1237. package/src/SubscriptionRef.ts +101 -120
  1238. package/src/SynchronizedRef.ts +3 -2
  1239. package/src/Terminal.ts +5 -4
  1240. package/src/Tracer.ts +23 -22
  1241. package/src/Trie.ts +44 -31
  1242. package/src/TxChunk.ts +26 -16
  1243. package/src/TxDeferred.ts +391 -0
  1244. package/src/TxHashMap.ts +347 -291
  1245. package/src/TxHashSet.ts +54 -61
  1246. package/src/TxPriorityQueue.ts +762 -0
  1247. package/src/TxPubSub.ts +787 -0
  1248. package/src/TxQueue.ts +221 -245
  1249. package/src/TxReentrantLock.ts +729 -0
  1250. package/src/TxRef.ts +31 -31
  1251. package/src/TxSemaphore.ts +203 -31
  1252. package/src/TxSubscriptionRef.ts +637 -0
  1253. package/src/Types.ts +78 -17
  1254. package/src/Unify.ts +26 -2
  1255. package/src/Utils.ts +137 -111
  1256. package/src/index.ts +898 -72
  1257. package/src/internal/core.ts +19 -12
  1258. package/src/internal/dateTime.ts +91 -96
  1259. package/src/internal/effect.ts +918 -506
  1260. package/src/internal/hashMap.ts +12 -10
  1261. package/src/internal/layer.ts +7 -7
  1262. package/src/internal/option.ts +7 -0
  1263. package/src/internal/random.ts +20 -0
  1264. package/src/internal/rcRef.ts +14 -13
  1265. package/src/internal/references.ts +72 -0
  1266. package/src/internal/request.ts +8 -8
  1267. package/src/internal/schedule.ts +3 -1
  1268. package/src/internal/schema/annotations.ts +2 -0
  1269. package/src/internal/schema/representation.ts +81 -95
  1270. package/src/internal/schema/schema.ts +25 -1
  1271. package/src/internal/schema/to-codec.ts +7 -17
  1272. package/src/internal/trie.ts +21 -15
  1273. package/src/testing/TestClock.ts +13 -11
  1274. package/src/testing/TestSchema.ts +333 -36
  1275. package/src/testing/index.ts +64 -1
  1276. package/src/unstable/ai/AiError.ts +112 -54
  1277. package/src/unstable/ai/AnthropicStructuredOutput.ts +7 -3
  1278. package/src/unstable/ai/Chat.ts +137 -88
  1279. package/src/unstable/ai/EmbeddingModel.ts +209 -0
  1280. package/src/unstable/ai/IdGenerator.ts +2 -2
  1281. package/src/unstable/ai/LanguageModel.ts +685 -255
  1282. package/src/unstable/ai/McpSchema.ts +84 -22
  1283. package/src/unstable/ai/McpServer.ts +299 -87
  1284. package/src/unstable/ai/Model.ts +44 -13
  1285. package/src/unstable/ai/OpenAiStructuredOutput.ts +9 -2
  1286. package/src/unstable/ai/Prompt.ts +43 -49
  1287. package/src/unstable/ai/Response.ts +31 -33
  1288. package/src/unstable/ai/ResponseIdTracker.ts +95 -0
  1289. package/src/unstable/ai/Telemetry.ts +2 -2
  1290. package/src/unstable/ai/Tokenizer.ts +2 -2
  1291. package/src/unstable/ai/Tool.ts +62 -36
  1292. package/src/unstable/ai/Toolkit.ts +17 -26
  1293. package/src/unstable/ai/index.ts +24 -1
  1294. package/src/unstable/ai/internal/codec-transformer.ts +3 -9
  1295. package/src/unstable/cli/Argument.ts +5 -8
  1296. package/src/unstable/cli/CliError.ts +67 -66
  1297. package/src/unstable/cli/CliOutput.ts +87 -15
  1298. package/src/unstable/cli/Command.ts +808 -193
  1299. package/src/unstable/cli/Completions.ts +107 -0
  1300. package/src/unstable/cli/Flag.ts +5 -6
  1301. package/src/unstable/cli/GlobalFlag.ts +242 -0
  1302. package/src/unstable/cli/HelpDoc.ts +91 -11
  1303. package/src/unstable/cli/Param.ts +54 -27
  1304. package/src/unstable/cli/Primitive.ts +2 -2
  1305. package/src/unstable/cli/Prompt.ts +275 -104
  1306. package/src/unstable/cli/index.ts +10 -0
  1307. package/src/unstable/cli/internal/command.ts +125 -64
  1308. package/src/unstable/cli/internal/completions/bash.ts +7 -7
  1309. package/src/unstable/cli/internal/completions/{CommandDescriptor.ts → descriptor.ts} +16 -58
  1310. package/src/unstable/cli/internal/completions/fish.ts +7 -7
  1311. package/src/unstable/cli/internal/completions/zsh.ts +8 -14
  1312. package/src/unstable/cli/internal/config.ts +49 -0
  1313. package/src/unstable/cli/internal/help.ts +171 -0
  1314. package/src/unstable/cli/internal/parser.ts +201 -84
  1315. package/src/unstable/cluster/ClusterCron.ts +2 -2
  1316. package/src/unstable/cluster/ClusterSchema.ts +38 -10
  1317. package/src/unstable/cluster/ClusterWorkflowEngine.ts +144 -81
  1318. package/src/unstable/cluster/DeliverAt.ts +1 -1
  1319. package/src/unstable/cluster/Entity.ts +59 -45
  1320. package/src/unstable/cluster/EntityAddress.ts +1 -1
  1321. package/src/unstable/cluster/EntityProxy.ts +3 -3
  1322. package/src/unstable/cluster/EntityProxyServer.ts +4 -4
  1323. package/src/unstable/cluster/EntityResource.ts +6 -6
  1324. package/src/unstable/cluster/Envelope.ts +1 -1
  1325. package/src/unstable/cluster/HttpRunner.ts +2 -2
  1326. package/src/unstable/cluster/K8sHttpClient.ts +7 -7
  1327. package/src/unstable/cluster/Message.ts +30 -17
  1328. package/src/unstable/cluster/MessageStorage.ts +76 -46
  1329. package/src/unstable/cluster/Reply.ts +13 -10
  1330. package/src/unstable/cluster/Runner.ts +1 -1
  1331. package/src/unstable/cluster/RunnerAddress.ts +1 -1
  1332. package/src/unstable/cluster/RunnerHealth.ts +2 -2
  1333. package/src/unstable/cluster/RunnerServer.ts +11 -14
  1334. package/src/unstable/cluster/RunnerStorage.ts +9 -9
  1335. package/src/unstable/cluster/Runners.ts +21 -19
  1336. package/src/unstable/cluster/ShardId.ts +84 -74
  1337. package/src/unstable/cluster/Sharding.ts +83 -66
  1338. package/src/unstable/cluster/ShardingConfig.ts +39 -40
  1339. package/src/unstable/cluster/Snowflake.ts +2 -2
  1340. package/src/unstable/cluster/SqlMessageStorage.ts +28 -20
  1341. package/src/unstable/cluster/SqlRunnerStorage.ts +1 -1
  1342. package/src/unstable/cluster/internal/entityManager.ts +66 -46
  1343. package/src/unstable/cluster/internal/entityReaper.ts +4 -3
  1344. package/src/unstable/cluster/internal/resourceMap.ts +3 -3
  1345. package/src/unstable/cluster/internal/resourceRef.ts +2 -1
  1346. package/src/unstable/devtools/DevToolsClient.ts +26 -21
  1347. package/src/unstable/devtools/DevToolsSchema.ts +16 -3
  1348. package/src/unstable/encoding/Ndjson.ts +17 -17
  1349. package/src/unstable/encoding/Sse.ts +3 -5
  1350. package/src/unstable/eventlog/Event.ts +0 -8
  1351. package/src/unstable/eventlog/EventGroup.ts +0 -4
  1352. package/src/unstable/eventlog/EventJournal.ts +148 -80
  1353. package/src/unstable/eventlog/EventLog.ts +360 -233
  1354. package/src/unstable/eventlog/EventLogEncryption.ts +18 -32
  1355. package/src/unstable/eventlog/EventLogMessage.ts +277 -0
  1356. package/src/unstable/eventlog/EventLogRemote.ts +264 -410
  1357. package/src/unstable/eventlog/EventLogServer.ts +183 -275
  1358. package/src/unstable/eventlog/EventLogServerEncrypted.ts +206 -0
  1359. package/src/unstable/eventlog/EventLogServerUnencrypted.ts +749 -0
  1360. package/src/unstable/eventlog/EventLogSessionAuth.ts +437 -0
  1361. package/src/unstable/eventlog/{SqlEventLogJournal.ts → SqlEventJournal.ts} +28 -20
  1362. package/src/unstable/eventlog/{SqlEventLogServer.ts → SqlEventLogServerEncrypted.ts} +102 -40
  1363. package/src/unstable/eventlog/SqlEventLogServerUnencrypted.ts +500 -0
  1364. package/src/unstable/eventlog/index.ts +27 -2
  1365. package/src/unstable/eventlog/internal/identityRootSecretDerivation.ts +153 -0
  1366. package/src/unstable/http/Cookies.ts +94 -11
  1367. package/src/unstable/http/Etag.ts +7 -5
  1368. package/src/unstable/http/FetchHttpClient.ts +5 -5
  1369. package/src/unstable/http/Headers.ts +70 -20
  1370. package/src/unstable/http/HttpClient.ts +385 -42
  1371. package/src/unstable/http/HttpClientRequest.ts +151 -39
  1372. package/src/unstable/http/HttpClientResponse.ts +12 -6
  1373. package/src/unstable/http/HttpEffect.ts +86 -100
  1374. package/src/unstable/http/HttpIncomingMessage.ts +5 -4
  1375. package/src/unstable/http/HttpMethod.ts +16 -4
  1376. package/src/unstable/http/HttpMiddleware.ts +50 -50
  1377. package/src/unstable/http/HttpPlatform.ts +5 -4
  1378. package/src/unstable/http/HttpRouter.ts +46 -46
  1379. package/src/unstable/http/HttpServer.ts +5 -11
  1380. package/src/unstable/http/HttpServerError.ts +45 -47
  1381. package/src/unstable/http/HttpServerRequest.ts +414 -23
  1382. package/src/unstable/http/HttpServerRespondable.ts +6 -6
  1383. package/src/unstable/http/HttpServerResponse.ts +351 -13
  1384. package/src/unstable/http/HttpStaticServer.ts +456 -0
  1385. package/src/unstable/http/HttpTraceContext.ts +31 -17
  1386. package/src/unstable/http/Multipart.ts +10 -10
  1387. package/src/unstable/http/Url.ts +650 -0
  1388. package/src/unstable/http/UrlParams.ts +31 -19
  1389. package/src/unstable/http/index.ts +10 -0
  1390. package/src/unstable/http/internal/preResponseHandler.ts +15 -0
  1391. package/src/unstable/httpapi/HttpApi.ts +21 -21
  1392. package/src/unstable/httpapi/HttpApiBuilder.ts +128 -55
  1393. package/src/unstable/httpapi/HttpApiClient.ts +186 -34
  1394. package/src/unstable/httpapi/HttpApiEndpoint.ts +225 -113
  1395. package/src/unstable/httpapi/HttpApiError.ts +108 -30
  1396. package/src/unstable/httpapi/HttpApiGroup.ts +18 -17
  1397. package/src/unstable/httpapi/HttpApiMiddleware.ts +95 -33
  1398. package/src/unstable/httpapi/HttpApiScalar.ts +6 -0
  1399. package/src/unstable/httpapi/HttpApiSchema.ts +106 -11
  1400. package/src/unstable/httpapi/HttpApiSecurity.ts +13 -13
  1401. package/src/unstable/httpapi/OpenApi.ts +71 -58
  1402. package/src/unstable/observability/Otlp.ts +12 -12
  1403. package/src/unstable/observability/OtlpExporter.ts +14 -10
  1404. package/src/unstable/observability/OtlpLogger.ts +13 -9
  1405. package/src/unstable/observability/OtlpMetrics.ts +5 -5
  1406. package/src/unstable/observability/OtlpSerialization.ts +2 -2
  1407. package/src/unstable/observability/OtlpTracer.ts +14 -10
  1408. package/src/unstable/observability/PrometheusMetrics.ts +5 -5
  1409. package/src/unstable/persistence/KeyValueStore.ts +230 -7
  1410. package/src/unstable/persistence/Persistable.ts +3 -3
  1411. package/src/unstable/persistence/PersistedCache.ts +35 -21
  1412. package/src/unstable/persistence/PersistedQueue.ts +28 -27
  1413. package/src/unstable/persistence/Persistence.ts +7 -7
  1414. package/src/unstable/persistence/RateLimiter.ts +7 -7
  1415. package/src/unstable/persistence/Redis.ts +2 -2
  1416. package/src/unstable/process/ChildProcess.ts +6 -208
  1417. package/src/unstable/process/ChildProcessSpawner.ts +120 -15
  1418. package/src/unstable/reactivity/Atom.ts +280 -124
  1419. package/src/unstable/reactivity/AtomHttpApi.ts +115 -59
  1420. package/src/unstable/reactivity/AtomRegistry.ts +70 -16
  1421. package/src/unstable/reactivity/AtomRpc.ts +82 -37
  1422. package/src/unstable/reactivity/Reactivity.ts +6 -6
  1423. package/src/unstable/reactivity/index.ts +2 -2
  1424. package/src/unstable/rpc/Rpc.ts +77 -32
  1425. package/src/unstable/rpc/RpcClient.ts +165 -145
  1426. package/src/unstable/rpc/RpcGroup.ts +51 -34
  1427. package/src/unstable/rpc/RpcMiddleware.ts +28 -22
  1428. package/src/unstable/rpc/RpcSchema.ts +24 -6
  1429. package/src/unstable/rpc/RpcSerialization.ts +56 -18
  1430. package/src/unstable/rpc/RpcServer.ts +97 -69
  1431. package/src/unstable/rpc/RpcWorker.ts +5 -5
  1432. package/src/unstable/rpc/Utils.ts +65 -5
  1433. package/src/unstable/schema/Model.ts +35 -6
  1434. package/src/unstable/schema/VariantSchema.ts +14 -27
  1435. package/src/unstable/socket/Socket.ts +42 -38
  1436. package/src/unstable/socket/SocketServer.ts +2 -2
  1437. package/src/unstable/sql/Migrator.ts +7 -5
  1438. package/src/unstable/sql/SqlClient.ts +13 -11
  1439. package/src/unstable/sql/SqlConnection.ts +2 -2
  1440. package/src/unstable/sql/SqlError.ts +365 -11
  1441. package/src/unstable/sql/SqlModel.ts +57 -85
  1442. package/src/unstable/sql/SqlResolver.ts +26 -16
  1443. package/src/unstable/sql/SqlSchema.ts +42 -26
  1444. package/src/unstable/sql/Statement.ts +2 -3
  1445. package/src/unstable/workers/Transferable.ts +17 -19
  1446. package/src/unstable/workers/Worker.ts +6 -5
  1447. package/src/unstable/workers/WorkerRunner.ts +2 -2
  1448. package/src/unstable/workflow/Activity.ts +27 -4
  1449. package/src/unstable/workflow/DurableClock.ts +11 -11
  1450. package/src/unstable/workflow/DurableDeferred.ts +16 -16
  1451. package/src/unstable/workflow/Workflow.ts +32 -25
  1452. package/src/unstable/workflow/WorkflowEngine.ts +239 -25
  1453. package/src/unstable/workflow/WorkflowProxyServer.ts +4 -4
  1454. package/dist/NullOr.d.ts +0 -149
  1455. package/dist/NullOr.d.ts.map +0 -1
  1456. package/dist/NullOr.js +0 -152
  1457. package/dist/NullOr.js.map +0 -1
  1458. package/dist/ServiceMap.d.ts +0 -1126
  1459. package/dist/ServiceMap.d.ts.map +0 -1
  1460. package/dist/ServiceMap.js.map +0 -1
  1461. package/dist/encoding/Base64.d.ts +0 -67
  1462. package/dist/encoding/Base64.d.ts.map +0 -1
  1463. package/dist/encoding/Base64.js +0 -146
  1464. package/dist/encoding/Base64.js.map +0 -1
  1465. package/dist/encoding/Base64Url.d.ts +0 -60
  1466. package/dist/encoding/Base64Url.d.ts.map +0 -1
  1467. package/dist/encoding/Base64Url.js +0 -89
  1468. package/dist/encoding/Base64Url.js.map +0 -1
  1469. package/dist/encoding/EncodingError.d.ts +0 -31
  1470. package/dist/encoding/EncodingError.d.ts.map +0 -1
  1471. package/dist/encoding/EncodingError.js +0 -22
  1472. package/dist/encoding/EncodingError.js.map +0 -1
  1473. package/dist/encoding/Hex.d.ts +0 -61
  1474. package/dist/encoding/Hex.d.ts.map +0 -1
  1475. package/dist/encoding/Hex.js +0 -115
  1476. package/dist/encoding/Hex.js.map +0 -1
  1477. package/dist/encoding/index.d.ts +0 -26
  1478. package/dist/encoding/index.d.ts.map +0 -1
  1479. package/dist/encoding/index.js +0 -27
  1480. package/dist/encoding/index.js.map +0 -1
  1481. package/dist/unstable/cli/internal/builtInFlags.d.ts +0 -7
  1482. package/dist/unstable/cli/internal/builtInFlags.d.ts.map +0 -1
  1483. package/dist/unstable/cli/internal/builtInFlags.js +0 -44
  1484. package/dist/unstable/cli/internal/builtInFlags.js.map +0 -1
  1485. package/dist/unstable/cli/internal/completions/CommandDescriptor.d.ts +0 -2
  1486. package/dist/unstable/cli/internal/completions/CommandDescriptor.d.ts.map +0 -1
  1487. package/dist/unstable/cli/internal/completions/CommandDescriptor.js.map +0 -1
  1488. package/dist/unstable/cli/internal/completions/Completions.d.ts +0 -2
  1489. package/dist/unstable/cli/internal/completions/Completions.d.ts.map +0 -1
  1490. package/dist/unstable/cli/internal/completions/Completions.js +0 -23
  1491. package/dist/unstable/cli/internal/completions/Completions.js.map +0 -1
  1492. package/dist/unstable/eventlog/SqlEventLogJournal.d.ts.map +0 -1
  1493. package/dist/unstable/eventlog/SqlEventLogJournal.js.map +0 -1
  1494. package/dist/unstable/eventlog/SqlEventLogServer.d.ts.map +0 -1
  1495. package/dist/unstable/eventlog/SqlEventLogServer.js.map +0 -1
  1496. package/src/NullOr.ts +0 -204
  1497. package/src/ServiceMap.ts +0 -1410
  1498. package/src/encoding/Base64.ts +0 -366
  1499. package/src/encoding/Base64Url.ts +0 -104
  1500. package/src/encoding/EncodingError.ts +0 -35
  1501. package/src/encoding/Hex.ts +0 -390
  1502. package/src/encoding/index.ts +0 -31
  1503. package/src/unstable/cli/internal/builtInFlags.ts +0 -78
  1504. package/src/unstable/cli/internal/completions/Completions.ts +0 -31
package/dist/Schema.js CHANGED
@@ -1,24 +1,111 @@
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
- import { format, formatDate, formatPropertyKey } from "./Formatter.js";
98
+ import { format, 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";
19
105
  import * as InternalEquivalence from "./internal/schema/equivalence.js";
20
106
  import * as InternalStandard from "./internal/schema/representation.js";
21
107
  import * as InternalSchema from "./internal/schema/schema.js";
108
+ import { SchemaError } from "./internal/schema/schema.js";
22
109
  import * as InternalToCodec from "./internal/schema/to-codec.js";
23
110
  import * as JsonPatch from "./JsonPatch.js";
24
111
  import * as JsonSchema from "./JsonSchema.js";
@@ -41,9 +128,51 @@ import * as Struct_ from "./Struct.js";
41
128
  import * as FastCheck from "./testing/FastCheck.js";
42
129
  const TypeId = InternalSchema.TypeId;
43
130
  /**
44
- * An API for creating schemas for parametric types.
131
+ * Creates a schema for a **parametric** type (a generic container such as
132
+ * `Array<A>`, `Option<A>`, etc.) by accepting a list of type-parameter schemas
133
+ * and a decoder factory.
134
+ *
135
+ * The outer call `declareConstructor<T, E, Iso>()` fixes the decoded type `T`,
136
+ * the encoded type `E`, and the optional iso type. The inner call receives:
137
+ * - `typeParameters` — the concrete schemas for each type variable
138
+ * - `run` — a factory that, given resolved codecs for each type parameter,
139
+ * returns a parsing function `(u, ast, options) => Effect<T, Issue>`
140
+ * - `annotations` — optional metadata
141
+ *
142
+ * @see {@link declare} for creating schemas for non-parametric types.
143
+ *
144
+ * **Example** (Schema for a parametric `Box<A>` type)
145
+ *
146
+ * ```ts
147
+ * import { Effect, Schema } from "effect"
148
+ * import * as SchemaParser from "effect/SchemaParser"
149
+ * import * as Issue from "effect/SchemaIssue"
150
+ * import * as Option from "effect/Option"
151
+ *
152
+ * interface Box<A> {
153
+ * readonly value: A
154
+ * }
155
+ *
156
+ * const isBox = (u: unknown): u is Box<unknown> =>
157
+ * typeof u === "object" && u !== null && "value" in u
158
+ *
159
+ * const Box = <A extends Schema.Top>(item: A) =>
160
+ * Schema.declareConstructor<Box<A["Type"]>, Box<A["Encoded"]>>()(
161
+ * [item],
162
+ * ([itemCodec]) =>
163
+ * (u, ast, options) => {
164
+ * if (!isBox(u)) {
165
+ * return Effect.fail(new Issue.InvalidType(ast, Option.some(u)))
166
+ * }
167
+ * return Effect.map(
168
+ * SchemaParser.decodeUnknownEffect(itemCodec)(u.value, options),
169
+ * (value) => ({ value })
170
+ * )
171
+ * }
172
+ * )
45
173
  *
46
- * @see {@link declare} for creating schemas for non parametric types.
174
+ * const schema = Box(Schema.Number)
175
+ * ```
47
176
  *
48
177
  * @category Constructors
49
178
  * @since 4.0.0
@@ -54,18 +183,60 @@ export function declareConstructor() {
54
183
  };
55
184
  }
56
185
  /**
57
- * An API for creating schemas for non parametric types.
186
+ * Creates a schema for a **non-parametric** opaque type using a type-guard
187
+ * function. The schema accepts any unknown value and succeeds when `is` returns
188
+ * `true`, failing with an `InvalidType` issue otherwise.
189
+ *
190
+ * Use this when the type has no type parameters. For parametric types such as
191
+ * `Option<A>` or `Array<A>`, use {@link declareConstructor} instead.
192
+ *
193
+ * **Example** (Schema for a custom `UserId` branded type)
194
+ *
195
+ * ```ts
196
+ * import { Schema } from "effect"
197
+ *
198
+ * type UserId = string & { readonly _tag: "UserId" }
199
+ *
200
+ * const isUserId = (u: unknown): u is UserId =>
201
+ * typeof u === "string" && u.startsWith("user_")
202
+ *
203
+ * const UserId = Schema.declare<UserId>(isUserId, {
204
+ * title: "UserId",
205
+ * description: "A user identifier starting with 'user_'"
206
+ * })
207
+ * ```
58
208
  *
59
209
  * @see {@link declareConstructor} for creating schemas for parametric types.
60
210
  *
211
+ * @category Constructors
61
212
  * @since 4.0.0
62
213
  */
63
214
  export function declare(is, annotations) {
64
215
  return declareConstructor()([], () => (input, ast) => is(input) ? Effect.succeed(input) : Effect.fail(new Issue.InvalidType(ast, Option_.some(input))), annotations);
65
216
  }
66
217
  /**
67
- * Reveals the complete Bottom interface type of a schema, exposing all 14 type
68
- * parameters.
218
+ * Widens a schema's type to the fully-parameterized {@link Bottom} interface,
219
+ * making all 14 type parameters visible to TypeScript.
220
+ *
221
+ * Normally, concrete schema interfaces (e.g. `Schema<string>`) hide most type
222
+ * parameters. `revealBottom` is useful when writing generic utilities that need
223
+ * to inspect or propagate the complete set of type parameters.
224
+ *
225
+ * **Example** (Inspecting all type parameters of a schema)
226
+ *
227
+ * ```ts
228
+ * import { Schema } from "effect"
229
+ *
230
+ * const schema = Schema.String
231
+ *
232
+ * // Widen to Bottom to access all 14 type parameters
233
+ * const bottom = Schema.revealBottom(schema)
234
+ *
235
+ * // `bottom` now exposes Type, Encoded, DecodingServices, EncodingServices,
236
+ * // ast, Rebuild, ~type.make.in, Iso, ~type.parameters, etc.
237
+ * type T = typeof bottom["Type"] // string
238
+ * type E = typeof bottom["Encoded"] // string
239
+ * ```
69
240
  *
70
241
  * @since 4.0.0
71
242
  */
@@ -74,21 +245,88 @@ export function revealBottom(bottom) {
74
245
  }
75
246
  /**
76
247
  * 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.
248
+ * This is the pipeable (curried) counterpart of the `.annotate` method.
249
+ *
250
+ * Annotations provide extra context used by documentation generators, JSON
251
+ * Schema converters, error formatters, and other tooling. Common keys include
252
+ * `title`, `description`, `examples`, `message`, and `identifier`.
253
+ *
254
+ * **Example** (Adding a title and description)
255
+ *
256
+ * ```ts
257
+ * import { Schema } from "effect"
258
+ *
259
+ * const Age = Schema.Number.pipe(
260
+ * Schema.annotate({
261
+ * title: "Age",
262
+ * description: "A non-negative integer representing age in years"
263
+ * })
264
+ * )
265
+ * ```
266
+ *
267
+ * @see {@link annotateEncoded} to annotate the encoded side instead.
79
268
  *
80
269
  * @category Annotations
81
270
  * @since 4.0.0
82
271
  */
83
272
  export function annotate(annotations) {
84
- return self => {
85
- return self.annotate(annotations);
86
- };
273
+ return self => self.annotate(annotations);
87
274
  }
88
275
  /**
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.
276
+ * Adds metadata annotations to the **encoded** side of a schema without
277
+ * changing its runtime behavior. This is the encoded-side counterpart of
278
+ * `annotate`, which targets the decoded (Type) side.
279
+ *
280
+ * Internally the schema is flipped so that `Encoded` becomes `Type`,
281
+ * annotated, and then flipped back.
282
+ *
283
+ * **Example** (Adding a title to the encoded representation)
284
+ *
285
+ * ```ts
286
+ * import { Schema } from "effect"
287
+ *
288
+ * const schema = Schema.NumberFromString.pipe(
289
+ * Schema.annotateEncoded({
290
+ * title: "my title"
291
+ * })
292
+ * )
293
+ *
294
+ * console.log(Schema.toEncoded(schema).ast.annotations?.title)
295
+ * // "my title"
296
+ * ```
297
+ *
298
+ * @see {@link annotate} to annotate the type side instead.
299
+ *
300
+ * @category Annotations
301
+ * @since 4.0.0
302
+ */
303
+ export function annotateEncoded(annotations) {
304
+ return self => flip(flip(self).annotate(annotations));
305
+ }
306
+ /**
307
+ * Adds key-level annotations to a schema field. This is the pipeable
308
+ * (curried) counterpart of the `.annotateKey` method.
309
+ *
310
+ * Key annotations apply to a field's position inside a `Struct` or `Tuple`
311
+ * rather than to the field's value type. They can carry a
312
+ * `messageMissingKey` to customise the error shown when the field is absent,
313
+ * as well as standard documentation fields such as `title`, `description`,
314
+ * and `examples`.
315
+ *
316
+ * **Example** (Custom missing-key message for a required field)
317
+ *
318
+ * ```ts
319
+ * import { Schema } from "effect"
320
+ *
321
+ * const schema = Schema.Struct({
322
+ * username: Schema.String.pipe(
323
+ * Schema.annotateKey({
324
+ * description: "The username used to log in",
325
+ * messageMissingKey: "Username is required"
326
+ * })
327
+ * )
328
+ * })
329
+ * ```
92
330
  *
93
331
  * @category Annotations
94
332
  * @since 4.0.0
@@ -99,42 +337,81 @@ export function annotateKey(annotations) {
99
337
  };
100
338
  }
101
339
  /**
340
+ * Identity function that widens a value to the full {@link Codec} interface,
341
+ * prompting TypeScript to infer all four type parameters (`T`, `E`, `RD`, `RE`).
342
+ *
343
+ * When a schema is stored in a variable typed as `Schema<T>` or `Top`, the
344
+ * encoded type and service requirements are erased. Passing the value through
345
+ * `revealCodec` recovers those parameters without any runtime cost.
346
+ *
347
+ * **Example** (Recovering encoded type from a schema variable)
348
+ *
349
+ * ```ts
350
+ * import { Schema } from "effect"
351
+ *
352
+ * const schema: Schema.Schema<number> = Schema.NumberFromString
353
+ *
354
+ * // Without revealCodec, Encoded is unknown
355
+ * const codec = Schema.revealCodec(schema)
356
+ * type Enc = typeof codec["Encoded"] // string
357
+ * ```
358
+ *
102
359
  * @since 4.0.0
103
360
  */
104
361
  export function revealCodec(codec) {
105
362
  return codec;
106
363
  }
107
- const SchemaErrorTypeId = "~effect/Schema/SchemaError";
364
+ export {
108
365
  /**
109
- * A `SchemaError` is returned when schema decoding or encoding fails.
366
+ * Error thrown (or returned as the error channel value) when schema decoding
367
+ * or encoding fails.
368
+ *
369
+ * The `issue` field contains a structured {@link Issue.Issue} tree describing
370
+ * every validation failure, including the path to the problematic value,
371
+ * expected types, and actual values received. `message` renders the issue tree
372
+ * as a human-readable string.
373
+ *
374
+ * Use {@link isSchemaError} to narrow an unknown value to `SchemaError`.
110
375
  *
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.
376
+ * **Example** (Catching a SchemaError)
377
+ *
378
+ * ```ts
379
+ * import { Schema } from "effect"
380
+ *
381
+ * try {
382
+ * Schema.decodeUnknownSync(Schema.Number)("not a number")
383
+ * } catch (err) {
384
+ * if (Schema.isSchemaError(err)) {
385
+ * console.log(err.message)
386
+ * // Expected number, actual "not a number"
387
+ * }
388
+ * }
389
+ * ```
115
390
  *
116
391
  * @since 4.0.0
117
392
  */
118
- export class SchemaError {
119
- [SchemaErrorTypeId] = SchemaErrorTypeId;
120
- _tag = "SchemaError";
121
- name = "SchemaError";
122
- issue;
123
- constructor(issue) {
124
- this.issue = issue;
125
- }
126
- get message() {
127
- return this.issue.toString();
128
- }
129
- toString() {
130
- return `SchemaError(${this.message})`;
131
- }
132
- }
393
+ SchemaError };
133
394
  /**
395
+ * Returns `true` if `u` is a {@link SchemaError}.
396
+ *
397
+ * **Example** (Type guard in a catch block)
398
+ *
399
+ * ```ts
400
+ * import { Schema } from "effect"
401
+ *
402
+ * try {
403
+ * Schema.decodeUnknownSync(Schema.Number)("oops")
404
+ * } catch (err) {
405
+ * if (Schema.isSchemaError(err)) {
406
+ * console.log(err._tag) // "SchemaError"
407
+ * }
408
+ * }
409
+ * ```
410
+ *
134
411
  * @since 4.0.0
135
412
  */
136
413
  export function isSchemaError(u) {
137
- return Predicate.hasProperty(u, SchemaErrorTypeId);
414
+ return Predicate.hasProperty(u, InternalSchema.SchemaErrorTypeId);
138
415
  }
139
416
  function makeStandardResult(exit) {
140
417
  return Exit_.isSuccess(exit) ? exit.value : {
@@ -221,7 +498,7 @@ export function toStandardSchemaV1(self, options) {
221
498
  }), {
222
499
  scheduler
223
500
  });
224
- scheduler.flush();
501
+ fiber.currentDispatcher?.flush();
225
502
  const exit = fiber.pollUnsafe();
226
503
  if (exit) {
227
504
  return makeStandardResult(exit);
@@ -370,6 +647,11 @@ export const is = Parser.is;
370
647
  */
371
648
  export const asserts = Parser.asserts;
372
649
  /**
650
+ * Decodes an `unknown` input against a schema, returning an `Effect` that
651
+ * succeeds with the decoded value or fails with a {@link SchemaError}. Use this
652
+ * when the input type is not statically known. Prefer {@link decodeEffect} when
653
+ * the input is already typed as the schema's `Encoded` type.
654
+ *
373
655
  * @category Decoding
374
656
  * @since 4.0.0
375
657
  */
@@ -380,11 +662,22 @@ export function decodeUnknownEffect(schema) {
380
662
  };
381
663
  }
382
664
  /**
665
+ * Decodes a typed input (the schema's `Encoded` type) against a schema,
666
+ * returning an `Effect` that succeeds with the decoded value or fails with a
667
+ * {@link SchemaError}. Use this when the input is already typed; for `unknown`
668
+ * input use {@link decodeUnknownEffect}.
669
+ *
383
670
  * @category Decoding
384
671
  * @since 4.0.0
385
672
  */
386
673
  export const decodeEffect = decodeUnknownEffect;
387
674
  /**
675
+ * Decodes an `unknown` input against a schema synchronously, returning an
676
+ * `Exit` that is either a `Success` with the decoded value or a `Failure` with
677
+ * a {@link SchemaError}. Only usable with schemas that have no
678
+ * `DecodingServices` requirement. Prefer {@link decodeExit} when the input is
679
+ * already typed as the schema's `Encoded` type.
680
+ *
388
681
  * @category Decoding
389
682
  * @since 4.0.0
390
683
  */
@@ -395,41 +688,120 @@ export function decodeUnknownExit(schema) {
395
688
  };
396
689
  }
397
690
  /**
691
+ * Decodes a typed input (the schema's `Encoded` type) against a schema
692
+ * synchronously, returning an `Exit` that is either a `Success` with the
693
+ * decoded value or a `Failure` with a {@link SchemaError}. Only usable with
694
+ * schemas that have no `DecodingServices` requirement. For `unknown` input use
695
+ * {@link decodeUnknownExit}.
696
+ *
398
697
  * @category Decoding
399
698
  * @since 4.0.0
400
699
  */
401
700
  export const decodeExit = decodeUnknownExit;
402
701
  /**
702
+ * Decodes an `unknown` input against a schema, returning an `Option` that is
703
+ * `Some` with the decoded value on success or `None` on failure. Prefer this
704
+ * over {@link decodeUnknownExit} or {@link decodeUnknownEffect} when you only
705
+ * need to know whether decoding succeeded and don't need error details. For
706
+ * typed input use {@link decodeOption}.
707
+ *
403
708
  * @category Decoding
404
709
  * @since 4.0.0
405
710
  */
406
711
  export const decodeUnknownOption = Parser.decodeUnknownOption;
407
712
  /**
713
+ * Decodes a typed input (the schema's `Encoded` type) against a schema,
714
+ * returning an `Option` that is `Some` with the decoded value on success or
715
+ * `None` on failure. For `unknown` input use {@link decodeUnknownOption}.
716
+ *
408
717
  * @category Decoding
409
718
  * @since 4.0.0
410
719
  */
411
720
  export const decodeOption = Parser.decodeOption;
721
+ /**
722
+ * Decodes an `unknown` input against a schema, returning a `Promise` that
723
+ * resolves with the decoded value or rejects with a {@link SchemaError}. Useful
724
+ * for integrating with Promise-based APIs. For typed input use
725
+ * {@link decodePromise}.
726
+ *
727
+ * @category Decoding
728
+ * @since 4.0.0
729
+ */
730
+ export const decodeUnknownResult = Parser.decodeUnknownResult;
731
+ /**
732
+ * @category Decoding
733
+ * @since 4.0.0
734
+ */
735
+ export const decodeResult = Parser.decodeResult;
412
736
  /**
413
737
  * @category Decoding
414
738
  * @since 4.0.0
415
739
  */
416
740
  export const decodeUnknownPromise = Parser.decodeUnknownPromise;
417
741
  /**
742
+ * Decodes a typed input (the schema's `Encoded` type) against a schema,
743
+ * returning a `Promise` that resolves with the decoded value or rejects with a
744
+ * {@link SchemaError}. For `unknown` input use {@link decodeUnknownPromise}.
745
+ *
418
746
  * @category Decoding
419
747
  * @since 4.0.0
420
748
  */
421
749
  export const decodePromise = Parser.decodePromise;
422
750
  /**
751
+ * Decodes an `unknown` input against a schema synchronously, throwing a
752
+ * {@link SchemaError} on failure. Use this when you want to validate data at a
753
+ * boundary and treat a schema mismatch as an unrecoverable error. For
754
+ * non-throwing alternatives see {@link decodeUnknownOption},
755
+ * {@link decodeUnknownExit}, or {@link decodeUnknownEffect}. For typed input
756
+ * use {@link decodeSync}.
757
+ *
758
+ * **Example** (Decoding with a transformation schema)
759
+ *
760
+ * ```ts
761
+ * import { Schema } from "effect"
762
+ *
763
+ * const NumberFromString = Schema.NumberFromString
764
+ *
765
+ * console.log(Schema.decodeUnknownSync(NumberFromString)("42"))
766
+ * // Output: 42
767
+ *
768
+ * Schema.decodeUnknownSync(NumberFromString)("not a number")
769
+ * // throws SchemaError: NumberFromString
770
+ * // └─ Encoded side transformation failure
771
+ * // └─ NumberFromString
772
+ * // └─ Expected a numeric string, actual "not a number"
773
+ * ```
774
+ *
423
775
  * @category Decoding
424
776
  * @since 4.0.0
425
777
  */
426
778
  export const decodeUnknownSync = Parser.decodeUnknownSync;
427
779
  /**
780
+ * Decodes a typed input (the schema's `Encoded` type) against a schema
781
+ * synchronously, throwing a {@link SchemaError} on failure. For `unknown` input
782
+ * use {@link decodeUnknownSync}.
783
+ *
428
784
  * @category Decoding
429
785
  * @since 4.0.0
430
786
  */
431
787
  export const decodeSync = Parser.decodeSync;
432
788
  /**
789
+ * Encodes an `unknown` input against a schema, returning an `Effect` that
790
+ * succeeds with the encoded value or fails with a {@link SchemaError}. Use this
791
+ * when the input type is not statically known. Prefer {@link encodeEffect} when
792
+ * the input is already typed as the schema's `Type`.
793
+ *
794
+ * **Example** (Encoding a value to a string)
795
+ *
796
+ * ```ts
797
+ * import { Effect, Schema } from "effect"
798
+ *
799
+ * const NumberFromString = Schema.NumberFromString
800
+ *
801
+ * Effect.runPromise(Schema.encodeUnknownEffect(NumberFromString)(42)).then(console.log)
802
+ * // Output: "42"
803
+ * ```
804
+ *
433
805
  * @category Encoding
434
806
  * @since 4.0.0
435
807
  */
@@ -440,11 +812,22 @@ export function encodeUnknownEffect(schema) {
440
812
  };
441
813
  }
442
814
  /**
815
+ * Encodes a typed input (the schema's `Type`) against a schema, returning an
816
+ * `Effect` that succeeds with the encoded value or fails with a
817
+ * {@link SchemaError}. Use this when the input is already typed; for `unknown`
818
+ * input use {@link encodeUnknownEffect}.
819
+ *
443
820
  * @category Encoding
444
821
  * @since 4.0.0
445
822
  */
446
823
  export const encodeEffect = encodeUnknownEffect;
447
824
  /**
825
+ * Encodes an `unknown` input against a schema synchronously, returning an
826
+ * `Exit` that is either a `Success` with the encoded value or a `Failure` with
827
+ * a {@link SchemaError}. Only usable with schemas that have no
828
+ * `EncodingServices` requirement. Prefer {@link encodeExit} when the input is
829
+ * already typed as the schema's `Type`.
830
+ *
448
831
  * @category Encoding
449
832
  * @since 4.0.0
450
833
  */
@@ -455,36 +838,82 @@ export function encodeUnknownExit(schema) {
455
838
  };
456
839
  }
457
840
  /**
841
+ * Encodes a typed input (the schema's `Type`) against a schema synchronously,
842
+ * returning an `Exit` that is either a `Success` with the encoded value or a
843
+ * `Failure` with a {@link SchemaError}. Only usable with schemas that have no
844
+ * `EncodingServices` requirement. For `unknown` input use
845
+ * {@link encodeUnknownExit}.
846
+ *
458
847
  * @category Encoding
459
848
  * @since 4.0.0
460
849
  */
461
850
  export const encodeExit = encodeUnknownExit;
462
851
  /**
852
+ * Encodes an `unknown` input against a schema, returning an `Option` that is
853
+ * `Some` with the encoded value on success or `None` on failure. Prefer this
854
+ * over {@link encodeUnknownExit} or {@link encodeUnknownEffect} when you only
855
+ * need to know whether encoding succeeded and don't need error details. For
856
+ * typed input use {@link encodeOption}.
857
+ *
463
858
  * @category Encoding
464
859
  * @since 4.0.0
465
860
  */
466
861
  export const encodeUnknownOption = Parser.encodeUnknownOption;
467
862
  /**
863
+ * Encodes a typed input (the schema's `Type`) against a schema, returning an
864
+ * `Option` that is `Some` with the encoded value on success or `None` on
865
+ * failure. For `unknown` input use {@link encodeUnknownOption}.
866
+ *
468
867
  * @category Encoding
469
868
  * @since 4.0.0
470
869
  */
471
870
  export const encodeOption = Parser.encodeOption;
871
+ /**
872
+ * Encodes an `unknown` input against a schema, returning a `Promise` that
873
+ * resolves with the encoded value or rejects with a {@link SchemaError}. Useful
874
+ * for integrating with Promise-based APIs. For typed input use
875
+ * {@link encodePromise}.
876
+ *
877
+ * @category Encoding
878
+ * @since 4.0.0
879
+ */
880
+ export const encodeUnknownResult = Parser.encodeUnknownResult;
881
+ /**
882
+ * @category Encoding
883
+ * @since 4.0.0
884
+ */
885
+ export const encodeResult = Parser.encodeResult;
472
886
  /**
473
887
  * @category Encoding
474
888
  * @since 4.0.0
475
889
  */
476
890
  export const encodeUnknownPromise = Parser.encodeUnknownPromise;
477
891
  /**
892
+ * Encodes a typed input (the schema's `Type`) against a schema, returning a
893
+ * `Promise` that resolves with the encoded value or rejects with a
894
+ * {@link SchemaError}. For `unknown` input use {@link encodeUnknownPromise}.
895
+ *
478
896
  * @category Encoding
479
897
  * @since 4.0.0
480
898
  */
481
899
  export const encodePromise = Parser.encodePromise;
482
900
  /**
901
+ * Encodes an `unknown` input against a schema synchronously, throwing a
902
+ * {@link SchemaError} on failure. Use this when you want to serialize data at a
903
+ * boundary and treat a schema mismatch as an unrecoverable error. For
904
+ * non-throwing alternatives see {@link encodeUnknownOption},
905
+ * {@link encodeUnknownExit}, or {@link encodeUnknownEffect}. For typed input
906
+ * use {@link encodeSync}.
907
+ *
483
908
  * @category Encoding
484
909
  * @since 4.0.0
485
910
  */
486
911
  export const encodeUnknownSync = Parser.encodeUnknownSync;
487
912
  /**
913
+ * Encodes a typed input (the schema's `Type`) against a schema synchronously,
914
+ * throwing a {@link SchemaError} on failure. For `unknown` input use
915
+ * {@link encodeUnknownSync}.
916
+ *
488
917
  * @category Encoding
489
918
  * @since 4.0.0
490
919
  */
@@ -505,6 +934,31 @@ export const encodeSync = Parser.encodeSync;
505
934
  * @since 4.0.0
506
935
  */
507
936
  export const make = InternalSchema.make;
937
+ /**
938
+ * Transforms a schema into a class that can be extended with `extends`. The
939
+ * resulting class inherits the full schema API (e.g. `annotate`) and can define
940
+ * static methods that reference `this`.
941
+ *
942
+ * **Example** (Wrapping a primitive schema)
943
+ *
944
+ * ```ts
945
+ * import { Schema } from "effect"
946
+ *
947
+ * class MyString extends Schema.asClass(Schema.String) {
948
+ * static readonly decodeUnknownSync = Schema.decodeUnknownSync(this)
949
+ * }
950
+ *
951
+ * console.log(MyString.decodeUnknownSync("a"))
952
+ * // "a"
953
+ * ```
954
+ *
955
+ * @since 4.0.0
956
+ */
957
+ export function asClass(schema) {
958
+ // oxlint-disable-next-line @typescript-eslint/no-extraneous-class
959
+ class Class {}
960
+ return Object.setPrototypeOf(Class, schema);
961
+ }
508
962
  /**
509
963
  * Tests if a value is a `Schema`.
510
964
  *
@@ -539,57 +993,74 @@ export const optionalKey = /*#__PURE__*/Struct_.lambda(schema => make(AST.option
539
993
  schema
540
994
  }));
541
995
  /**
996
+ * Reverses {@link optionalKey}, returning the inner required schema. Only
997
+ * applicable to schemas already wrapped with `optionalKey`.
998
+ *
542
999
  * @since 4.0.0
543
1000
  */
544
1001
  export const requiredKey = /*#__PURE__*/Struct_.lambda(self => self.schema);
545
1002
  /**
546
- * Creates an optional schema field that allows both the specified type and
1003
+ * Marks a struct field as optional, allowing the key to be absent or
547
1004
  * `undefined`.
548
1005
  *
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
1006
+ * explicitly set to `undefined`. Equivalent to `optionalKey(UndefinedOr(S))`.
554
1007
  *
555
- * **Example** (Creating a struct with optional)
1008
+ * Use {@link optionalKey} instead if you want exact optional semantics (absent
1009
+ * only, not `undefined`).
1010
+ *
1011
+ * **Example** (Optional field accepting undefined)
556
1012
  *
557
1013
  * ```ts
558
1014
  * import { Schema } from "effect"
559
1015
  *
560
1016
  * const schema = Schema.Struct({
561
1017
  * name: Schema.String,
562
- * age: Schema.optionalKey(Schema.Number)
1018
+ * age: Schema.optional(Schema.Number)
563
1019
  * })
564
1020
  *
565
- * // Type: { readonly name: string; readonly age?: number | undefined }
566
- * type Person = typeof schema["Type"]
1021
+ * // { readonly name: string; readonly age?: number | undefined }
1022
+ * type Person = typeof schema.Type
567
1023
  * ```
568
1024
  *
569
1025
  * @since 4.0.0
570
1026
  */
571
1027
  export const optional = /*#__PURE__*/Struct_.lambda(self => optionalKey(UndefinedOr(self)));
572
1028
  /**
1029
+ * Reverses {@link optional}, returning the inner schema (unwrapping `UndefinedOr`).
1030
+ * Only applicable to schemas already wrapped with `optional`.
1031
+ *
573
1032
  * @since 4.0.0
574
1033
  */
575
1034
  export const required = /*#__PURE__*/Struct_.lambda(self => self.schema.members[0]);
576
1035
  /**
1036
+ * Makes a struct field mutable (removes the `readonly` modifier on the property).
1037
+ * Use {@link readonlyKey} to reverse.
1038
+ *
577
1039
  * @since 4.0.0
578
1040
  */
579
1041
  export const mutableKey = /*#__PURE__*/Struct_.lambda(schema => make(AST.mutableKey(schema.ast), {
580
1042
  schema
581
1043
  }));
582
1044
  /**
1045
+ * Reverses {@link mutableKey}, returning the inner schema as readonly again.
1046
+ * Only applicable to schemas already wrapped with `mutableKey`.
1047
+ *
583
1048
  * @since 4.0.0
584
1049
  */
585
1050
  export const readonlyKey = /*#__PURE__*/Struct_.lambda(self => self.schema);
586
1051
  /**
1052
+ * Extracts the type-side schema: sets `Encoded` to equal the decoded `Type`,
1053
+ * discarding the encoding transformation path.
1054
+ *
587
1055
  * @since 4.0.0
588
1056
  */
589
1057
  export const toType = /*#__PURE__*/Struct_.lambda(schema => make(AST.toType(schema.ast), {
590
1058
  schema
591
1059
  }));
592
1060
  /**
1061
+ * Extracts the encoded-side schema: sets `Type` to equal the `Encoded`,
1062
+ * discarding the decoding transformation path.
1063
+ *
593
1064
  * @since 4.0.0
594
1065
  */
595
1066
  export const toEncoded = /*#__PURE__*/Struct_.lambda(schema => make(AST.toEncoded(schema.ast), {
@@ -609,6 +1080,16 @@ export function flip(schema) {
609
1080
  });
610
1081
  }
611
1082
  /**
1083
+ * Creates a schema for a single literal value (string, number, bigint, boolean, or null).
1084
+ *
1085
+ * **Example** (String literal)
1086
+ * ```ts
1087
+ * import { Schema } from "effect"
1088
+ *
1089
+ * const schema = Schema.Literal("hello")
1090
+ * // Type: Schema.Literal<"hello">
1091
+ * ```
1092
+ *
612
1093
  * @see {@link Literals} for a schema that represents a union of literals.
613
1094
  * @see {@link tag} for a schema that represents a literal value that can be
614
1095
  * used as a discriminator field in tagged unions and has a constructor default.
@@ -630,6 +1111,18 @@ function templateLiteralFromParts(parts) {
630
1111
  return new AST.TemplateLiteral(parts.map(part => isSchema(part) ? part.ast : new AST.Literal(part)));
631
1112
  }
632
1113
  /**
1114
+ * Creates a schema that validates strings matching a template literal pattern. Each part can be
1115
+ * a literal string/number/bigint or a schema whose encoded type is a string, number, or bigint.
1116
+ *
1117
+ * **Example** (URL path pattern)
1118
+ * ```ts
1119
+ * import { Schema } from "effect"
1120
+ *
1121
+ * const schema = Schema.TemplateLiteral(["/user/", Schema.Number])
1122
+ * // matches strings like "/user/123", "/user/42", etc.
1123
+ * ```
1124
+ *
1125
+ * @see {@link TemplateLiteralParser} for a schema that also parses matched parts into a tuple.
633
1126
  * @since 4.0.0
634
1127
  */
635
1128
  export function TemplateLiteral(parts) {
@@ -638,6 +1131,18 @@ export function TemplateLiteral(parts) {
638
1131
  });
639
1132
  }
640
1133
  /**
1134
+ * Like {@link TemplateLiteral} but decodes the matched string into a readonly tuple of typed values,
1135
+ * one element per schema part.
1136
+ *
1137
+ * **Example** (Parse path parameters)
1138
+ * ```ts
1139
+ * import { Schema } from "effect"
1140
+ *
1141
+ * const schema = Schema.TemplateLiteralParser(["/user/", Schema.NumberFromString])
1142
+ * // decodes "/user/42" => readonly ["/user/", 42]
1143
+ * ```
1144
+ *
1145
+ * @see {@link TemplateLiteral} for a validation-only version that keeps the string encoded.
641
1146
  * @since 4.0.0
642
1147
  */
643
1148
  export function TemplateLiteralParser(parts) {
@@ -646,6 +1151,21 @@ export function TemplateLiteralParser(parts) {
646
1151
  });
647
1152
  }
648
1153
  /**
1154
+ * Creates a schema from a TypeScript enum object. Validates that the input is one of the enum's values.
1155
+ *
1156
+ * **Example** (Direction enum)
1157
+ * ```ts
1158
+ * import { Schema } from "effect"
1159
+ *
1160
+ * enum Direction {
1161
+ * Up = "Up",
1162
+ * Down = "Down"
1163
+ * }
1164
+ *
1165
+ * const schema = Schema.Enum(Direction)
1166
+ * // accepts "Up" or "Down"
1167
+ * ```
1168
+ *
649
1169
  * @since 4.0.0
650
1170
  */
651
1171
  export function Enum(enums) {
@@ -654,84 +1174,102 @@ export function Enum(enums) {
654
1174
  });
655
1175
  }
656
1176
  /**
1177
+ * Schema for the `never` type. Always fails validation — no value satisfies it.
1178
+ *
657
1179
  * @since 4.0.0
658
1180
  */
659
1181
  export const Never = /*#__PURE__*/make(AST.never);
660
1182
  /**
1183
+ * Schema for the `any` type. Accepts any value without validation.
1184
+ *
1185
+ * @see {@link Unknown} for a safer alternative that uses `unknown`.
661
1186
  * @since 4.0.0
662
1187
  */
663
1188
  export const Any = /*#__PURE__*/make(AST.any);
664
1189
  /**
1190
+ * Schema for the `unknown` type. Accepts any value without validation.
1191
+ *
1192
+ * @see {@link Any} for the `any` variant.
665
1193
  * @since 4.0.0
666
1194
  */
667
1195
  export const Unknown = /*#__PURE__*/make(AST.unknown);
668
1196
  /**
1197
+ * Schema for the `null` literal. Validates that the input is strictly `null`.
1198
+ *
1199
+ * @see {@link NullOr} for a union with another schema.
669
1200
  * @since 4.0.0
670
1201
  */
671
1202
  export const Null = /*#__PURE__*/make(AST.null);
672
1203
  /**
1204
+ * Schema for the `undefined` literal. Validates that the input is strictly `undefined`.
1205
+ *
1206
+ * @see {@link UndefinedOr} for a union with another schema.
673
1207
  * @since 4.0.0
674
1208
  */
675
1209
  export const Undefined = /*#__PURE__*/make(AST.undefined);
676
1210
  /**
677
- * A schema for all strings.
1211
+ * Schema for `string` values. Validates that the input is `typeof` `"string"`.
678
1212
  *
679
1213
  * @since 4.0.0
680
1214
  */
681
1215
  export const String = /*#__PURE__*/make(AST.string);
682
1216
  /**
683
- * A schema for all numbers, including `NaN`, `Infinity`, and `-Infinity`.
1217
+ * Schema for `number` values, including `NaN`, `Infinity`, and `-Infinity`.
684
1218
  *
685
1219
  * **Default Json Serializer**
686
1220
  *
687
- * - If the number is finite, it is serialized as a number.
688
- * - Otherwise, it is serialized as a string ("NaN", "Infinity", or "-Infinity").
1221
+ * - Finite numbers are serialized as numbers.
1222
+ * - Non-finite values are serialized as strings (`"NaN"`, `"Infinity"`, `"-Infinity"`).
689
1223
  *
1224
+ * @see {@link Finite} for a schema that excludes non-finite values.
690
1225
  * @since 4.0.0
691
1226
  */
692
1227
  export const Number = /*#__PURE__*/make(AST.number);
693
1228
  /**
694
- * A schema for all booleans.
1229
+ * Schema for `boolean` values. Validates that the input is `typeof` `"boolean"`.
695
1230
  *
696
1231
  * @category Boolean
697
1232
  * @since 4.0.0
698
1233
  */
699
1234
  export const Boolean = /*#__PURE__*/make(AST.boolean);
700
1235
  /**
701
- * A schema for all symbols.
1236
+ * Schema for `symbol` values. Validates that the input is `typeof` `"symbol"`.
702
1237
  *
1238
+ * @see {@link UniqueSymbol} for a schema that matches a specific symbol.
703
1239
  * @since 4.0.0
704
1240
  */
705
1241
  export const Symbol = /*#__PURE__*/make(AST.symbol);
706
1242
  /**
707
- * A schema for all bigints.
1243
+ * Schema for `bigint` values. Validates that the input is `typeof` `"bigint"`.
708
1244
  *
709
1245
  * @since 4.0.0
710
1246
  */
711
1247
  export const BigInt = /*#__PURE__*/make(AST.bigInt);
712
1248
  /**
713
- * A schema for the `void` type.
1249
+ * Schema for the `void` type. Accepts `undefined` as the encoded value.
714
1250
  *
715
1251
  * @since 4.0.0
716
1252
  */
717
1253
  export const Void = /*#__PURE__*/make(AST.void);
718
1254
  /**
719
- * A schema for the `object` type.
1255
+ * Schema for the `object` type. Validates that the input is a non-null object or function
1256
+ * (i.e. `typeof value === "object" && value !== null || typeof value === "function"`).
720
1257
  *
721
1258
  * @since 4.0.0
722
1259
  */
723
1260
  export const ObjectKeyword = /*#__PURE__*/make(AST.objectKeyword);
724
1261
  /**
725
- * A schema for unique symbols.
726
- *
727
- * **Example**
1262
+ * Creates a schema for a specific symbol. Only that exact symbol satisfies the schema.
728
1263
  *
1264
+ * **Example** (Specific symbol)
729
1265
  * ```ts
730
1266
  * import { Schema } from "effect"
731
1267
  *
732
- * const a = Symbol.for("a")
733
- * const schema = Schema.UniqueSymbol(a)
1268
+ * const mySymbol = Symbol.for("mySymbol")
1269
+ * const schema = Schema.UniqueSymbol(mySymbol)
734
1270
  * ```
1271
+ *
1272
+ * @see {@link Symbol} for a schema that accepts any symbol.
735
1273
  * @since 4.0.0
736
1274
  */
737
1275
  export function UniqueSymbol(symbol) {
@@ -747,6 +1285,34 @@ function makeStruct(ast, fields) {
747
1285
  });
748
1286
  }
749
1287
  /**
1288
+ * Defines a struct schema from a map of field schemas.
1289
+ *
1290
+ * Each field value is a schema. Use {@link optionalKey} or {@link optional} to
1291
+ * mark fields as optional, and {@link mutableKey} to mark them as mutable.
1292
+ *
1293
+ * The resulting schema's `Type` is a readonly object type with the fields'
1294
+ * decoded types. The `Encoded` form mirrors the field schemas' encoded types.
1295
+ *
1296
+ * **Example** (Basic struct)
1297
+ *
1298
+ * ```ts
1299
+ * import { Schema } from "effect"
1300
+ *
1301
+ * const Person = Schema.Struct({
1302
+ * name: Schema.String,
1303
+ * age: Schema.Number,
1304
+ * email: Schema.optionalKey(Schema.String)
1305
+ * })
1306
+ *
1307
+ * // { readonly name: string; readonly age: number; readonly email?: string }
1308
+ * type Person = typeof Person.Type
1309
+ *
1310
+ * const alice = Schema.decodeUnknownSync(Person)({ name: "Alice", age: 30 })
1311
+ * console.log(alice)
1312
+ * // { name: 'Alice', age: 30 }
1313
+ * ```
1314
+ *
1315
+ * @category Constructors
750
1316
  * @since 4.0.0
751
1317
  */
752
1318
  export function Struct(fields) {
@@ -774,6 +1340,26 @@ export function fieldsAssign(fields) {
774
1340
  return Struct_.lambda(struct => struct.mapFields(Struct_.assign(fields)));
775
1341
  }
776
1342
  /**
1343
+ * Renames struct keys in the encoded form without changing the decoded type.
1344
+ *
1345
+ * Takes a partial mapping `{ decodedKey: encodedKey }` and produces a
1346
+ * transformation schema that decodes from the renamed keys and encodes back to
1347
+ * the renamed keys. Keys not present in the mapping are left unchanged.
1348
+ *
1349
+ * **Example** (Rename `name` to `full_name` in the encoded form)
1350
+ *
1351
+ * ```ts
1352
+ * import { Schema } from "effect"
1353
+ *
1354
+ * const Person = Schema.Struct({ name: Schema.String, age: Schema.Number })
1355
+ * const Encoded = Person.pipe(Schema.encodeKeys({ name: "full_name" }))
1356
+ *
1357
+ * // Decodes { full_name: "Alice", age: 30 } → { name: "Alice", age: 30 }
1358
+ * const alice = Schema.decodeUnknownSync(Encoded)({ full_name: "Alice", age: 30 })
1359
+ * console.log(alice)
1360
+ * // { name: 'Alice', age: 30 }
1361
+ * ```
1362
+ *
777
1363
  * @category Struct transformations
778
1364
  * @since 4.0.0
779
1365
  */
@@ -782,11 +1368,12 @@ export function encodeKeys(mapping) {
782
1368
  const fields = {};
783
1369
  const reverseMapping = {};
784
1370
  for (const k in self.fields) {
1371
+ const encoded = toEncoded(self.fields[k]);
785
1372
  if (Object.hasOwn(mapping, k)) {
786
- fields[mapping[k]] = toEncoded(self.fields[k]);
1373
+ fields[mapping[k]] = encoded;
787
1374
  reverseMapping[mapping[k]] = k;
788
1375
  } else {
789
- fields[k] = self.fields[k];
1376
+ fields[k] = encoded;
790
1377
  }
791
1378
  }
792
1379
  return Struct(fields).pipe(decodeTo(self, Transformation.transform({
@@ -796,6 +1383,31 @@ export function encodeKeys(mapping) {
796
1383
  };
797
1384
  }
798
1385
  /**
1386
+ * Adds derived fields to a struct schema during decoding.
1387
+ *
1388
+ * Each new field is derived from the decoded struct value via a function that
1389
+ * returns `Option`. On encoding the derived fields are stripped. This allows
1390
+ * computed or enriched fields to live in the decoded type without appearing in
1391
+ * the encoded form.
1392
+ *
1393
+ * **Example** (Add a computed `fullName` field)
1394
+ *
1395
+ * ```ts
1396
+ * import { Option, Schema } from "effect"
1397
+ *
1398
+ * const Person = Schema.Struct({ first: Schema.String, last: Schema.String })
1399
+ * const Extended = Person.pipe(
1400
+ * Schema.extendTo(
1401
+ * { fullName: Schema.String },
1402
+ * { fullName: (p) => Option.some(`${p.first} ${p.last}`) }
1403
+ * )
1404
+ * )
1405
+ *
1406
+ * const alice = Schema.decodeUnknownSync(Extended)({ first: "Alice", last: "Smith" })
1407
+ * console.log(alice.fullName)
1408
+ * // Alice Smith
1409
+ * ```
1410
+ *
799
1411
  * @since 4.0.0
800
1412
  * @experimental
801
1413
  */
@@ -835,6 +1447,24 @@ derive) {
835
1447
  };
836
1448
  }
837
1449
  /**
1450
+ * Defines a record (dictionary) schema with typed keys and values.
1451
+ *
1452
+ * **Example** (String-keyed record of numbers)
1453
+ *
1454
+ * ```ts
1455
+ * import { Schema } from "effect"
1456
+ *
1457
+ * const schema = Schema.Record(Schema.String, Schema.Number)
1458
+ *
1459
+ * // { readonly [x: string]: number }
1460
+ * type R = typeof schema.Type
1461
+ *
1462
+ * const result = Schema.decodeUnknownSync(schema)({ a: 1, b: 2 })
1463
+ * console.log(result)
1464
+ * // { a: 1, b: 2 }
1465
+ * ```
1466
+ *
1467
+ * @category Constructors
838
1468
  * @since 4.0.0
839
1469
  */
840
1470
  export function Record(key, value, options) {
@@ -845,6 +1475,24 @@ export function Record(key, value, options) {
845
1475
  });
846
1476
  }
847
1477
  /**
1478
+ * Extends a struct schema with one or more record (index-signature) schemas,
1479
+ * producing a schema whose decoded type intersects the struct and all records.
1480
+ *
1481
+ * **Example** (Struct with string-indexed extra keys)
1482
+ *
1483
+ * ```ts
1484
+ * import { Schema } from "effect"
1485
+ *
1486
+ * const schema = Schema.StructWithRest(
1487
+ * Schema.Struct({ id: Schema.Number }),
1488
+ * [Schema.Record(Schema.String, Schema.String)]
1489
+ * )
1490
+ *
1491
+ * // { readonly id: number } & { readonly [x: string]: string }
1492
+ * type T = typeof schema.Type
1493
+ * ```
1494
+ *
1495
+ * @category Constructors
848
1496
  * @since 4.0.0
849
1497
  */
850
1498
  export function StructWithRest(schema, records) {
@@ -863,6 +1511,20 @@ function makeTuple(ast, elements) {
863
1511
  });
864
1512
  }
865
1513
  /**
1514
+ * Defines a fixed-length tuple schema from an array of element schemas.
1515
+ *
1516
+ * **Example** (Pair of string and number)
1517
+ *
1518
+ * ```ts
1519
+ * import { Schema } from "effect"
1520
+ *
1521
+ * const schema = Schema.Tuple([Schema.String, Schema.Number])
1522
+ *
1523
+ * const pair = Schema.decodeUnknownSync(schema)(["hello", 42])
1524
+ * console.log(pair)
1525
+ * // [ 'hello', 42 ]
1526
+ * ```
1527
+ *
866
1528
  * @category Constructors
867
1529
  * @since 4.0.0
868
1530
  */
@@ -870,6 +1532,26 @@ export function Tuple(elements) {
870
1532
  return makeTuple(AST.tuple(elements), elements);
871
1533
  }
872
1534
  /**
1535
+ * Extends a fixed-length tuple schema with rest elements, creating a variadic
1536
+ * tuple that starts with the fixed elements and ends with zero or more rest
1537
+ * elements.
1538
+ *
1539
+ * **Example** (Tuple with rest)
1540
+ *
1541
+ * ```ts
1542
+ * import { Schema } from "effect"
1543
+ *
1544
+ * // [string, number, ...boolean[]]
1545
+ * const schema = Schema.TupleWithRest(
1546
+ * Schema.Tuple([Schema.String, Schema.Number]),
1547
+ * [Schema.Boolean]
1548
+ * )
1549
+ *
1550
+ * const result = Schema.decodeUnknownSync(schema)(["hello", 1, true, false])
1551
+ * console.log(result)
1552
+ * // [ 'hello', 1, true, false ]
1553
+ * ```
1554
+ *
873
1555
  * @category Constructors
874
1556
  * @since 4.0.0
875
1557
  */
@@ -883,16 +1565,70 @@ export function TupleWithRest(schema, rest) {
883
1565
  * @category Constructors
884
1566
  * @since 4.0.0
885
1567
  */
886
- export const Array = /*#__PURE__*/Struct_.lambda(schema => make(new AST.Arrays(false, [], [schema.ast]), {
1568
+ const ArraySchema = /*#__PURE__*/Struct_.lambda(schema => make(new AST.Arrays(false, [], [schema.ast]), {
887
1569
  schema
888
1570
  }));
1571
+ export {
889
1572
  /**
1573
+ * Defines a `ReadonlyArray` schema for a given element schema.
1574
+ *
1575
+ * **Example** (Array of strings)
1576
+ *
1577
+ * ```ts
1578
+ * import { Schema } from "effect"
1579
+ *
1580
+ * const schema = Schema.Array(Schema.String)
1581
+ *
1582
+ * const result = Schema.decodeUnknownSync(schema)(["a", "b", "c"])
1583
+ * console.log(result)
1584
+ * // [ 'a', 'b', 'c' ]
1585
+ * ```
1586
+ *
1587
+ * @category Constructors
1588
+ * @since 4.0.0
1589
+ */
1590
+ ArraySchema as Array };
1591
+ /**
1592
+ * Defines a non-empty `ReadonlyArray` schema — at least one element required.
1593
+ * Type is `readonly [T, ...T[]]`.
1594
+ *
1595
+ * **Example** (Non-empty array of numbers)
1596
+ *
1597
+ * ```ts
1598
+ * import { Schema } from "effect"
1599
+ *
1600
+ * const schema = Schema.NonEmptyArray(Schema.Number)
1601
+ *
1602
+ * Schema.decodeUnknownSync(schema)([1, 2, 3]) // ok
1603
+ * Schema.decodeUnknownSync(schema)([]) // throws
1604
+ * ```
1605
+ *
890
1606
  * @category Constructors
891
1607
  * @since 4.0.0
892
1608
  */
893
1609
  export const NonEmptyArray = /*#__PURE__*/Struct_.lambda(schema => make(new AST.Arrays(false, [schema.ast], [schema.ast]), {
894
1610
  schema
895
1611
  }));
1612
+ /**
1613
+ * Decodes a single value or an array of values into an array.
1614
+ *
1615
+ * Decoding:
1616
+ * - a single value is decoded as a one-element array
1617
+ * - an array is decoded as-is
1618
+ *
1619
+ * Encoding:
1620
+ * - a one-element array is encoded as a single value
1621
+ * - arrays with more than one element are encoded as arrays
1622
+ *
1623
+ * @category Arrays
1624
+ * @since 4.0.0
1625
+ */
1626
+ export function ArrayEnsure(schema) {
1627
+ return Union([schema, ArraySchema(schema)]).pipe(decodeTo(ArraySchema(toType(schema)), Transformation.transform({
1628
+ decode: Arr.ensure,
1629
+ encode: array => array.length === 1 ? array[0] : array
1630
+ })));
1631
+ }
896
1632
  /**
897
1633
  * Returns a new array schema that ensures all elements are unique.
898
1634
  *
@@ -903,10 +1639,21 @@ export const NonEmptyArray = /*#__PURE__*/Struct_.lambda(schema => make(new AST.
903
1639
  * @since 4.0.0
904
1640
  */
905
1641
  export function UniqueArray(item) {
906
- return Array(item).check(isUnique());
1642
+ return ArraySchema(item).check(isUnique());
907
1643
  }
908
1644
  /**
909
- * Makes arrays or tuples mutable.
1645
+ * Makes an array or tuple schema mutable, removing the `readonly` modifier.
1646
+ *
1647
+ * **Example** (Mutable array)
1648
+ *
1649
+ * ```ts
1650
+ * import { Schema } from "effect"
1651
+ *
1652
+ * const schema = Schema.mutable(Schema.Array(Schema.Number))
1653
+ *
1654
+ * // number[] (mutable)
1655
+ * type T = typeof schema.Type
1656
+ * ```
910
1657
  *
911
1658
  * @since 4.0.0
912
1659
  */
@@ -925,12 +1672,23 @@ function makeUnion(ast, members) {
925
1672
  });
926
1673
  }
927
1674
  /**
928
- * Creates a schema that represents a union of multiple schemas. Members are checked in order, and the first match is returned.
1675
+ * Creates a union schema from an array of member schemas. Members are tested in
1676
+ * order; the first match is returned.
1677
+ *
1678
+ * Optionally, specify `mode`:
1679
+ * - `"anyOf"` (default) — matches if any member matches.
1680
+ * - `"oneOf"` — matches if exactly one member matches.
1681
+ *
1682
+ * **Example** (String or number union)
929
1683
  *
930
- * Optionally, you can specify the `mode` to be `"anyOf"` or `"oneOf"`.
1684
+ * ```ts
1685
+ * import { Schema } from "effect"
931
1686
  *
932
- * - `"anyOf"` - The union matches if any member matches.
933
- * - `"oneOf"` - The union matches if exactly one member matches.
1687
+ * const schema = Schema.Union([Schema.String, Schema.Number])
1688
+ *
1689
+ * Schema.decodeUnknownSync(schema)("hello") // "hello"
1690
+ * Schema.decodeUnknownSync(schema)(42) // 42
1691
+ * ```
934
1692
  *
935
1693
  * @category Constructors
936
1694
  * @since 4.0.0
@@ -939,6 +1697,16 @@ export function Union(members, options) {
939
1697
  return makeUnion(AST.union(members, options?.mode ?? "anyOf", undefined), members);
940
1698
  }
941
1699
  /**
1700
+ * Creates a union schema from an array of literal values.
1701
+ *
1702
+ * **Example** (Status codes)
1703
+ * ```ts
1704
+ * import { Schema } from "effect"
1705
+ *
1706
+ * const schema = Schema.Literals(["active", "inactive", "pending"])
1707
+ * // accepts "active", "inactive", or "pending"
1708
+ * ```
1709
+ *
942
1710
  * @see {@link Literal} for a schema that represents a single literal.
943
1711
  * @category Constructors
944
1712
  * @since 4.0.0
@@ -960,16 +1728,21 @@ export function Literals(literals) {
960
1728
  });
961
1729
  }
962
1730
  /**
1731
+ * Creates a union schema of `S | null`.
1732
+ *
963
1733
  * @category Constructors
964
1734
  * @since 4.0.0
965
1735
  */
966
1736
  export const NullOr = /*#__PURE__*/Struct_.lambda(self => Union([self, Null]));
967
1737
  /**
1738
+ * Creates a union schema of `S | undefined`.
1739
+ *
968
1740
  * @category Constructors
969
1741
  * @since 4.0.0
970
1742
  */
971
1743
  export const UndefinedOr = /*#__PURE__*/Struct_.lambda(self => Union([self, Undefined]));
972
1744
  /**
1745
+ * Creates a union schema of `S | null | undefined`.
973
1746
  * @category Constructors
974
1747
  * @since 4.0.0
975
1748
  */
@@ -979,6 +1752,21 @@ export const NullishOr = /*#__PURE__*/Struct_.lambda(self => Union([self, Null,
979
1752
  * essential for creating recursive schemas where a schema references itself,
980
1753
  * preventing infinite recursion during schema definition.
981
1754
  *
1755
+ * **Example** (Recursive tree schema)
1756
+ * ```ts
1757
+ * import { Schema } from "effect"
1758
+ *
1759
+ * interface Tree {
1760
+ * readonly value: number
1761
+ * readonly children: ReadonlyArray<Tree>
1762
+ * }
1763
+ *
1764
+ * const Tree = Schema.Struct({
1765
+ * value: Schema.Number,
1766
+ * children: Schema.Array(Schema.suspend((): Schema.Codec<Tree> => Tree))
1767
+ * })
1768
+ * ```
1769
+ *
982
1770
  * @category Constructors
983
1771
  * @since 4.0.0
984
1772
  */
@@ -986,6 +1774,18 @@ export function suspend(f) {
986
1774
  return make(new AST.Suspend(() => f().ast));
987
1775
  }
988
1776
  /**
1777
+ * Pipeable function that attaches one or more filter checks to a schema without
1778
+ * changing the TypeScript type.
1779
+ *
1780
+ * **Example** (Adding checks to a schema)
1781
+ * ```ts
1782
+ * import { Schema } from "effect"
1783
+ *
1784
+ * const AgeSchema = Schema.Number.pipe(
1785
+ * Schema.check(Schema.isGreaterThanOrEqualTo(0), Schema.isLessThanOrEqualTo(120))
1786
+ * )
1787
+ * ```
1788
+ *
989
1789
  * @category Filtering
990
1790
  * @since 4.0.0
991
1791
  */
@@ -993,6 +1793,9 @@ export function check(...checks) {
993
1793
  return self => self.check(...checks);
994
1794
  }
995
1795
  /**
1796
+ * Narrows the TypeScript type of a schema's output via a type guard predicate,
1797
+ * attaching the guard as a runtime filter check.
1798
+ *
996
1799
  * @category Filtering
997
1800
  * @since 4.0.0
998
1801
  */
@@ -1002,7 +1805,8 @@ export function refine(refinement, annotations) {
1002
1805
  });
1003
1806
  }
1004
1807
  /**
1005
- * Adds a brand to a schema.
1808
+ * Adds a nominal brand to a schema, intersecting the output type with
1809
+ * `Brand.Brand<B>` to prevent accidental mixing of structurally identical types.
1006
1810
  *
1007
1811
  * @category Branding
1008
1812
  * @since 4.0.0
@@ -1014,7 +1818,10 @@ export function brand(identifier) {
1014
1818
  });
1015
1819
  }
1016
1820
  /**
1017
- * @category Constructors
1821
+ * Creates a branded schema from a {@link Brand.Constructor}, applying the
1822
+ * constructor's checks and brand tag to the underlying schema.
1823
+ *
1824
+ * @category Branding
1018
1825
  * @since 4.0.0
1019
1826
  */
1020
1827
  export function fromBrand(identifier, ctor) {
@@ -1023,6 +1830,25 @@ export function fromBrand(identifier, ctor) {
1023
1830
  };
1024
1831
  }
1025
1832
  /**
1833
+ * Intercepts the decoding pipeline of a schema.
1834
+ *
1835
+ * The provided function receives the current decoding `Effect` and `ParseOptions`,
1836
+ * and returns a new `Effect` — potentially adding service requirements (`RD`),
1837
+ * recovering from errors, or augmenting the result.
1838
+ *
1839
+ * **Example** (Logging decode failures)
1840
+ *
1841
+ * ```ts
1842
+ * import { Effect, Schema } from "effect"
1843
+ *
1844
+ * const Logged = Schema.String.pipe(
1845
+ * Schema.middlewareDecoding((effect) =>
1846
+ * Effect.tapError(effect, (issue) => Effect.log("decode failed", issue))
1847
+ * )
1848
+ * )
1849
+ * ```
1850
+ *
1851
+ * @see {@link catchDecoding} for a simpler error-recovery variant
1026
1852
  * @since 4.0.0
1027
1853
  */
1028
1854
  export function middlewareDecoding(decode) {
@@ -1031,6 +1857,25 @@ export function middlewareDecoding(decode) {
1031
1857
  });
1032
1858
  }
1033
1859
  /**
1860
+ * Intercepts the encoding pipeline of a schema.
1861
+ *
1862
+ * The provided function receives the current encoding `Effect` and `ParseOptions`,
1863
+ * and returns a new `Effect` — potentially adding service requirements (`RE`),
1864
+ * recovering from errors, or augmenting the result.
1865
+ *
1866
+ * **Example** (Logging encode failures)
1867
+ *
1868
+ * ```ts
1869
+ * import { Effect, Schema } from "effect"
1870
+ *
1871
+ * const Logged = Schema.String.pipe(
1872
+ * Schema.middlewareEncoding((effect) =>
1873
+ * Effect.tapError(effect, (issue) => Effect.log("encode failed", issue))
1874
+ * )
1875
+ * )
1876
+ * ```
1877
+ *
1878
+ * @see {@link catchEncoding} for a simpler error-recovery variant
1034
1879
  * @since 4.0.0
1035
1880
  */
1036
1881
  export function middlewareEncoding(encode) {
@@ -1039,24 +1884,50 @@ export function middlewareEncoding(encode) {
1039
1884
  });
1040
1885
  }
1041
1886
  /**
1887
+ * Recovers from a decoding error by providing a fallback value.
1888
+ *
1889
+ * The handler receives the `Issue` and returns an `Effect` that either
1890
+ * succeeds with a fallback value or re-fails with a (possibly different) issue.
1891
+ *
1892
+ * **Example** (Returning a default on decode failure)
1893
+ *
1894
+ * ```ts
1895
+ * import { Effect, Option, Schema } from "effect"
1896
+ *
1897
+ * const schema = Schema.Number.pipe(
1898
+ * Schema.catchDecoding((_issue) => Effect.succeed(Option.some(0)))
1899
+ * )
1900
+ * ```
1901
+ *
1902
+ * @see {@link catchDecodingWithContext} to add service requirements to the handler
1042
1903
  * @since 4.0.0
1043
1904
  */
1044
1905
  export function catchDecoding(f) {
1045
1906
  return catchDecodingWithContext(f);
1046
1907
  }
1047
1908
  /**
1909
+ * Like {@link catchDecoding}, but the handler may require Effect services (`R`).
1910
+ *
1048
1911
  * @since 4.0.0
1049
1912
  */
1050
1913
  export function catchDecodingWithContext(f) {
1051
1914
  return self => self.pipe(middlewareDecoding(Effect.catchEager(f)));
1052
1915
  }
1053
1916
  /**
1917
+ * Recovers from an encoding error by providing a fallback value.
1918
+ *
1919
+ * The handler receives the `Issue` and returns an `Effect` that either
1920
+ * succeeds with a fallback value or re-fails with a (possibly different) issue.
1921
+ *
1922
+ * @see {@link catchEncodingWithContext} to add service requirements to the handler
1054
1923
  * @since 4.0.0
1055
1924
  */
1056
1925
  export function catchEncoding(f) {
1057
1926
  return catchEncodingWithContext(f);
1058
1927
  }
1059
1928
  /**
1929
+ * Like {@link catchEncoding}, but the handler may require Effect services (`R`).
1930
+ *
1060
1931
  * @since 4.0.0
1061
1932
  */
1062
1933
  export function catchEncodingWithContext(f) {
@@ -1118,6 +1989,25 @@ export function encodeTo(to, transformation) {
1118
1989
  };
1119
1990
  }
1120
1991
  /**
1992
+ * Applies a transformation to a schema's encoded type, creating a new schema where encoding/decoding
1993
+ * operate on `S["Encoded"]` rather than `S["Type"]`.
1994
+ *
1995
+ * The `decode` getter maps `S["Encoded"]` → `S["Encoded"]` (applied during decoding),
1996
+ * and the `encode` getter maps `S["Encoded"]` → `S["Encoded"]` (applied during encoding).
1997
+ *
1998
+ * **Example** (Upper-casing encoded strings)
1999
+ *
2000
+ * ```ts
2001
+ * import { Schema, SchemaGetter } from "effect"
2002
+ *
2003
+ * const UpperFromLower = Schema.String.pipe(
2004
+ * Schema.encode({
2005
+ * decode: SchemaGetter.transform((s: string) => s.toLowerCase()),
2006
+ * encode: SchemaGetter.transform((s: string) => s.toUpperCase())
2007
+ * })
2008
+ * )
2009
+ * ```
2010
+ *
1121
2011
  * @since 4.0.0
1122
2012
  */
1123
2013
  export function encode(transformation) {
@@ -1126,22 +2016,66 @@ export function encode(transformation) {
1126
2016
  };
1127
2017
  }
1128
2018
  /**
2019
+ * Attaches a constructor default value to a schema field.
2020
+ *
2021
+ * Constructor defaults are applied only during `make*`, not during decoding or
2022
+ * encoding.
2023
+ *
2024
+ * **Example** (Optional field with a static default)
2025
+ *
2026
+ * ```ts
2027
+ * import { Effect, Schema } from "effect"
2028
+ *
2029
+ * const MySchema = Schema.Struct({
2030
+ * name: Schema.String.pipe(
2031
+ * Schema.optionalKey,
2032
+ * Schema.withConstructorDefault(Effect.succeed("anonymous"))
2033
+ * )
2034
+ * })
2035
+ *
2036
+ * const value = MySchema.make({})
2037
+ * // value: { name: "anonymous" }
2038
+ * ```
2039
+ *
1129
2040
  * @since 4.0.0
1130
2041
  */
1131
- export function withConstructorDefault(defaultValue) {
1132
- return schema => {
1133
- return make(AST.withConstructorDefault(schema.ast, defaultValue), {
1134
- schema
1135
- });
1136
- };
2042
+ export function withConstructorDefault(
2043
+ // `S["~type.make.in"]` instead of `S["Type"]` is intentional here because
2044
+ // it makes easier to define the default value if there are nested defaults
2045
+ defaultValue) {
2046
+ return schema => make(AST.withConstructorDefault(schema.ast, defaultValue), {
2047
+ schema
2048
+ });
1137
2049
  }
1138
2050
  /**
2051
+ * Makes a struct key optional on the `Encoded` side and provides a default
2052
+ * `Encoded` value when the key is missing during decoding.
2053
+ *
2054
+ * The key uses `optionalKey` on the encoded side, so it may be absent from the
2055
+ * input object but **not** `undefined`. The default value is specified in terms
2056
+ * of the `Encoded` type (before any decoding transformations).
2057
+ *
1139
2058
  * **Options**
1140
2059
  *
1141
- * - `encodingStrategy`: The strategy to use when encoding.
1142
- * - `passthrough`: (default) Pass the default value through to the output.
1143
- * - `omit`: Omit the value from the output.
2060
+ * - `encodingStrategy`:
2061
+ * - `"passthrough"` (default): include the value in the encoded output.
2062
+ * - `"omit"`: omit the key from the encoded output.
2063
+ *
2064
+ * **Example** (Default for a missing struct key)
2065
+ *
2066
+ * ```ts
2067
+ * import { Effect, Schema } from "effect"
2068
+ *
2069
+ * const MySchema = Schema.Struct({
2070
+ * name: Schema.String.pipe(Schema.withDecodingDefaultKey(Effect.succeed("anonymous")))
2071
+ * })
2072
+ *
2073
+ * const result = Schema.decodeUnknownSync(MySchema)({})
2074
+ * // result: { name: "anonymous" }
2075
+ * ```
1144
2076
  *
2077
+ * @see {@link withDecodingDefault} for the value-level variant (key absent **or** `undefined`)
2078
+ * @see {@link withDecodingDefaultTypeKey} for the variant where the default is a `Type` value
1145
2079
  * @since 4.0.0
1146
2080
  */
1147
2081
  export function withDecodingDefaultKey(defaultValue, options) {
@@ -1154,12 +2088,58 @@ export function withDecodingDefaultKey(defaultValue, options) {
1154
2088
  };
1155
2089
  }
1156
2090
  /**
2091
+ * Makes a struct key optional on the `Encoded` side (`optionalKey`, so the
2092
+ * key may be absent but **not** `undefined`) and provides a default `Type`
2093
+ * value when the key is missing during decoding.
2094
+ *
2095
+ * Unlike {@link withDecodingDefaultKey}, the default value is specified in
2096
+ * terms of the `Type` (decoded) representation, so it does not need to go
2097
+ * through the decoding transformation.
2098
+ *
2099
+ * **Options**
2100
+ *
2101
+ * - `encodingStrategy`:
2102
+ * - `"passthrough"` (default): include the value in the encoded output.
2103
+ * - `"omit"`: omit the key from the encoded output.
2104
+ *
2105
+ * @see {@link withDecodingDefaultKey} for the variant where the default is an `Encoded` value
2106
+ * @see {@link withDecodingDefaultType} for the value-level variant
2107
+ * @since 4.0.0
2108
+ */
2109
+ export function withDecodingDefaultTypeKey(defaultValue, options) {
2110
+ return self => {
2111
+ return toType(self).pipe(withDecodingDefaultKey(defaultValue, options), encodeTo(optionalKey(self)));
2112
+ };
2113
+ }
2114
+ /**
2115
+ * Wraps the `Encoded` side with `optional` (key absent **or** `undefined`)
2116
+ * and provides a default `Encoded` value when the field is missing or
2117
+ * `undefined` during decoding.
2118
+ *
2119
+ * The default value is specified in terms of the `Encoded` type (before any
2120
+ * decoding transformations).
2121
+ *
1157
2122
  * **Options**
1158
2123
  *
1159
- * - `encodingStrategy`: The strategy to use when encoding.
1160
- * - `passthrough`: (default) Pass the default value through to the output.
1161
- * - `omit`: Omit the value from the output.
2124
+ * - `encodingStrategy`:
2125
+ * - `"passthrough"` (default): include the value in the encoded output.
2126
+ * - `"omit"`: omit the key from the encoded output.
2127
+ *
2128
+ * **Example** (Default for an optional field value)
2129
+ *
2130
+ * ```ts
2131
+ * import { Effect, Schema } from "effect"
2132
+ *
2133
+ * const MySchema = Schema.Struct({
2134
+ * name: Schema.String.pipe(Schema.optional, Schema.withDecodingDefault(Effect.succeed("anonymous")))
2135
+ * })
2136
+ *
2137
+ * const result = Schema.decodeUnknownSync(MySchema)({ name: undefined })
2138
+ * // result: { name: "anonymous" }
2139
+ * ```
1162
2140
  *
2141
+ * @see {@link withDecodingDefaultKey} for the key-level variant (key absent only, not `undefined`)
2142
+ * @see {@link withDecodingDefaultType} for the variant where the default is a `Type` value
1163
2143
  * @since 4.0.0
1164
2144
  */
1165
2145
  export function withDecodingDefault(defaultValue, options) {
@@ -1172,27 +2152,78 @@ export function withDecodingDefault(defaultValue, options) {
1172
2152
  };
1173
2153
  }
1174
2154
  /**
1175
- * Creates a schema for a literal value and automatically provides itself as a
1176
- * default.
2155
+ * Wraps the `Encoded` side with `optional` (key absent **or** `undefined`)
2156
+ * and provides a default `Type` value when the field is missing or
2157
+ * `undefined` during decoding.
2158
+ *
2159
+ * Unlike {@link withDecodingDefault}, the default value is specified in terms
2160
+ * of the `Type` (decoded) representation, so it does not need to go through
2161
+ * the decoding transformation.
2162
+ *
2163
+ * **Options**
2164
+ *
2165
+ * - `encodingStrategy`:
2166
+ * - `"passthrough"` (default): include the value in the encoded output.
2167
+ * - `"omit"`: omit the key from the encoded output.
2168
+ *
2169
+ * @see {@link withDecodingDefault} for the variant where the default is an `Encoded` value
2170
+ * @see {@link withDecodingDefaultTypeKey} for the key-level variant
2171
+ * @since 4.0.0
2172
+ */
2173
+ export function withDecodingDefaultType(defaultValue, options) {
2174
+ return self => {
2175
+ return toType(self).pipe(withDecodingDefault(defaultValue, options), encodeTo(optional(self)));
2176
+ };
2177
+ }
2178
+ /**
2179
+ * Combines a {@link Literal} schema with {@link withConstructorDefault}, making it ideal
2180
+ * for discriminator fields in tagged unions. When constructing via `make`, the
2181
+ * `_tag` field can be omitted and will be filled automatically.
2182
+ *
2183
+ * **Example** (Discriminated union tag)
1177
2184
  *
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.
2185
+ * ```ts
2186
+ * import { Schema } from "effect"
2187
+ *
2188
+ * const A = Schema.Struct({ _tag: Schema.tag("A"), value: Schema.Number })
2189
+ *
2190
+ * // _tag is optional in make, auto-filled to "A"
2191
+ * const a = A.make({ value: 42 })
2192
+ * // a: { _tag: "A", value: 42 }
2193
+ * ```
1182
2194
  *
2195
+ * @see {@link tagDefaultOmit} to also omit the tag during encoding
2196
+ * @see {@link TaggedStruct} for a shorthand that adds `_tag` automatically
1183
2197
  * @since 4.0.0
1184
2198
  */
1185
2199
  export function tag(literal) {
1186
- return Literal(literal).pipe(withConstructorDefault(() => Option_.some(literal)));
2200
+ return Literal(literal).pipe(withConstructorDefault(Effect.succeed(literal)));
1187
2201
  }
1188
2202
  /**
1189
- * Similar to `tag`, but provides itself as a default when decoding and omits
1190
- * the value from the output when encoding.
2203
+ * Like {@link tag}, but additionally omits the tag field from the encoded output.
2204
+ * Useful when the encoded form (e.g. JSON) does not include the discriminator key,
2205
+ * but the decoded type and constructor still need it.
2206
+ *
2207
+ * **Example** (Tag omitted during encoding)
2208
+ *
2209
+ * ```ts
2210
+ * import { Schema } from "effect"
2211
+ *
2212
+ * const A = Schema.Struct({
2213
+ * _tag: Schema.tagDefaultOmit("A"),
2214
+ * value: Schema.Number
2215
+ * })
2216
+ *
2217
+ * // Encode strips the _tag field
2218
+ * const encoded = Schema.encodeUnknownSync(A)({ _tag: "A", value: 1 })
2219
+ * // encoded: { value: 1 }
2220
+ * ```
1191
2221
  *
2222
+ * @see {@link tag} for the variant that keeps the tag during encoding
1192
2223
  * @since 4.0.0
1193
2224
  */
1194
2225
  export function tagDefaultOmit(literal) {
1195
- return tag(literal).pipe(withDecodingDefaultKey(() => literal, {
2226
+ return tag(literal).pipe(withDecodingDefaultKey(Effect.succeed(literal), {
1196
2227
  encodingStrategy: "omit"
1197
2228
  }));
1198
2229
  }
@@ -1201,7 +2232,7 @@ export function tagDefaultOmit(literal) {
1201
2232
  * to identify the specific variant of the object, which is especially useful
1202
2233
  * when working with union types.
1203
2234
  *
1204
- * When using the `makeUnsafe` method, the `_tag` field is optional and will be
2235
+ * When using the `make` method, the `_tag` field is optional and will be
1205
2236
  * added automatically. However, when decoding or encoding, the `_tag` field
1206
2237
  * must be present in the input.
1207
2238
  *
@@ -1244,18 +2275,27 @@ export function TaggedStruct(value, fields) {
1244
2275
  ...fields
1245
2276
  });
1246
2277
  }
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
2278
  /**
2279
+ * Augments an existing {@link Union} of tagged structs with utility methods keyed by the discriminant field.
2280
+ *
2281
+ * **Example** (Adding tagged-union utilities to an existing union)
2282
+ *
2283
+ * ```ts
2284
+ * import { Schema } from "effect"
2285
+ *
2286
+ * const A = Schema.TaggedStruct("A", { value: Schema.Number })
2287
+ * const B = Schema.TaggedStruct("B", { name: Schema.String })
2288
+ *
2289
+ * const MyUnion = Schema.Union([A, B]).pipe(Schema.toTaggedUnion("_tag"))
2290
+ *
2291
+ * // Pattern-match on the union
2292
+ * const result = MyUnion.match({ _tag: "A", value: 1 }, {
2293
+ * A: (a) => `number: ${a.value}`,
2294
+ * B: (b) => `name: ${b.name}`
2295
+ * })
2296
+ * ```
2297
+ *
2298
+ * @see {@link TaggedUnion} for a shorthand that builds the union from scratch
1259
2299
  * @since 4.0.0
1260
2300
  * @experimental
1261
2301
  */
@@ -1276,15 +2316,16 @@ export function toTaggedUnion(tag) {
1276
2316
  if (AST.isUnion(ast) && "members" in schema && globalThis.Array.isArray(schema.members) && schema.members.every(isSchema)) {
1277
2317
  return schema.members.forEach(walk);
1278
2318
  }
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));
2319
+ const sentinels = AST.collectSentinels(ast);
2320
+ if (sentinels.length > 0) {
2321
+ const literal = sentinels.find(s => s.key === tag)?.literal;
2322
+ if (Predicate.isPropertyKey(literal)) {
2323
+ cases[literal] = schema;
2324
+ guards[literal] = is(toType(schema));
1284
2325
  return;
1285
2326
  }
1286
2327
  }
1287
- throw new globalThis.Error("No literal found");
2328
+ throw new globalThis.Error("No literal or unique symbol found");
1288
2329
  }
1289
2330
  function match() {
1290
2331
  if (arguments.length === 1) {
@@ -1300,6 +2341,28 @@ export function toTaggedUnion(tag) {
1300
2341
  };
1301
2342
  }
1302
2343
  /**
2344
+ * Builds a discriminated union from a record of field sets, one per variant.
2345
+ * Each key becomes the `_tag` literal and the value is passed to {@link TaggedStruct}.
2346
+ * The result includes `cases`, `guards`, `isAnyOf`, and `match` utilities.
2347
+ *
2348
+ * **Example** (Discriminated union with pattern matching)
2349
+ *
2350
+ * ```ts
2351
+ * import { Schema } from "effect"
2352
+ *
2353
+ * const Shape = Schema.TaggedUnion({
2354
+ * Circle: { radius: Schema.Number },
2355
+ * Rectangle: { width: Schema.Number, height: Schema.Number }
2356
+ * })
2357
+ *
2358
+ * // Pattern-match on a decoded value
2359
+ * const area = Shape.match({ _tag: "Circle", radius: 5 }, {
2360
+ * Circle: (c) => Math.PI * c.radius ** 2,
2361
+ * Rectangle: (r) => r.width * r.height
2362
+ * })
2363
+ * ```
2364
+ *
2365
+ * @see {@link toTaggedUnion} to augment an existing union instead
1303
2366
  * @category Constructors
1304
2367
  * @since 4.0.0
1305
2368
  */
@@ -1323,18 +2386,49 @@ export function TaggedUnion(casesByTag) {
1323
2386
  });
1324
2387
  }
1325
2388
  /**
2389
+ * Wraps a struct schema so that its decoded `Type` becomes a nominally distinct type `Self`.
2390
+ * Useful for creating opaque types that are structurally identical to a base struct
2391
+ * but type-incompatible with it.
2392
+ *
2393
+ * **Example** (Opaque struct)
2394
+ *
2395
+ * ```ts
2396
+ * import { Schema } from "effect"
2397
+ *
2398
+ * class Person extends Schema.Opaque<Person>()(
2399
+ * Schema.Struct({
2400
+ * name: Schema.String
2401
+ * })
2402
+ * ) {}
2403
+ *
2404
+ * // Decoded value is Person, not { name: string }
2405
+ * const person = Schema.decodeUnknownSync(Person)({ name: "Alice" })
2406
+ * // person: Person
2407
+ * ```
2408
+ *
1326
2409
  * @since 4.0.0
1327
2410
  */
1328
2411
  export function Opaque() {
1329
2412
  return schema => {
1330
2413
  // oxlint-disable-next-line @typescript-eslint/no-extraneous-class
1331
2414
  class Opaque {}
1332
- Object.setPrototypeOf(Opaque, schema);
1333
- return Opaque;
2415
+ return Object.setPrototypeOf(Opaque, schema);
1334
2416
  };
1335
2417
  }
1336
2418
  /**
1337
- * Creates a schema that validates an instance of a specific class constructor.
2419
+ * Creates a schema that validates values using `instanceof`.
2420
+ * Decoding and encoding pass the value through unchanged.
2421
+ *
2422
+ * **Example** (Schema for a built-in class)
2423
+ *
2424
+ * ```ts
2425
+ * import { Schema } from "effect"
2426
+ *
2427
+ * const DateSchema = Schema.instanceOf(Date)
2428
+ *
2429
+ * const decoded = Schema.decodeUnknownSync(DateSchema)(new Date("2024-01-01"))
2430
+ * // decoded: Date
2431
+ * ```
1338
2432
  *
1339
2433
  * @category Constructors
1340
2434
  * @since 4.0.0
@@ -1343,6 +2437,9 @@ export function instanceOf(constructor, annotations) {
1343
2437
  return declare(u => u instanceof constructor, annotations);
1344
2438
  }
1345
2439
  /**
2440
+ * Constructs an `AST.Link` that describes how a value of type `T` encodes to and decodes from a `To` schema.
2441
+ * Used when building low-level AST transformations that bridge two schema types.
2442
+ *
1346
2443
  * @since 4.0.0
1347
2444
  * @experimental
1348
2445
  */
@@ -1355,11 +2452,30 @@ export function link() {
1355
2452
  // Checks
1356
2453
  // -----------------------------------------------------------------------------
1357
2454
  /**
2455
+ * Creates a custom filter check from a predicate function. The predicate
2456
+ * receives the input value, the schema's AST, and parse options, and returns
2457
+ * `true`/`undefined` on success or a failure description on error.
2458
+ *
2459
+ * **Example** (Custom filter check)
2460
+ * ```ts
2461
+ * import { Schema } from "effect"
2462
+ *
2463
+ * // Check that a number is even
2464
+ * const isEven = Schema.makeFilter(
2465
+ * (n: number) => n % 2 === 0 || "expected an even number"
2466
+ * )
2467
+ *
2468
+ * const EvenNumber = Schema.Number.check(isEven)
2469
+ * ```
2470
+ *
1358
2471
  * @category Checks Constructors
1359
2472
  * @since 4.0.0
1360
2473
  */
1361
2474
  export const makeFilter = AST.makeFilter;
1362
2475
  /**
2476
+ * Groups multiple checks into a single {@link AST.FilterGroup}, applying
2477
+ * optional shared annotations to the group as a whole.
2478
+ *
1363
2479
  * @category Checks Constructors
1364
2480
  * @since 4.0.0
1365
2481
  */
@@ -1847,6 +2963,9 @@ export function isFinite(annotations) {
1847
2963
  });
1848
2964
  }
1849
2965
  /**
2966
+ * Generic factory for creating a "greater than" (`>`) check for any ordered
2967
+ * type by supplying an {@link Order.Order} instance.
2968
+ *
1850
2969
  * @category Order checks
1851
2970
  * @since 4.0.0
1852
2971
  */
@@ -1862,6 +2981,9 @@ export function makeIsGreaterThan(options) {
1862
2981
  };
1863
2982
  }
1864
2983
  /**
2984
+ * Generic factory for creating a ">=" check for any ordered type by supplying
2985
+ * an {@link Order.Order} instance.
2986
+ *
1865
2987
  * @category Order checks
1866
2988
  * @since 4.0.0
1867
2989
  */
@@ -1877,6 +2999,9 @@ export function makeIsGreaterThanOrEqualTo(options) {
1877
2999
  };
1878
3000
  }
1879
3001
  /**
3002
+ * Generic factory for creating a "<" check for any ordered type by supplying
3003
+ * an {@link Order.Order} instance.
3004
+ *
1880
3005
  * @category Order checks
1881
3006
  * @since 4.0.0
1882
3007
  */
@@ -1892,6 +3017,9 @@ export function makeIsLessThan(options) {
1892
3017
  };
1893
3018
  }
1894
3019
  /**
3020
+ * Generic factory for creating a "<=" check for any ordered type by supplying
3021
+ * an {@link Order.Order} instance.
3022
+ *
1895
3023
  * @category Order checks
1896
3024
  * @since 4.0.0
1897
3025
  */
@@ -1907,6 +3035,9 @@ export function makeIsLessThanOrEqualTo(options) {
1907
3035
  };
1908
3036
  }
1909
3037
  /**
3038
+ * Generic factory for creating an inclusive/exclusive range check for any
3039
+ * ordered type by supplying an {@link Order.Order} instance.
3040
+ *
1910
3041
  * @category Order checks
1911
3042
  * @since 4.0.0
1912
3043
  */
@@ -1927,6 +3058,9 @@ export function makeIsBetween(deriveOptions) {
1927
3058
  };
1928
3059
  }
1929
3060
  /**
3061
+ * Generic factory for creating a divisibility check for any numeric type by
3062
+ * supplying a remainder function and a zero value.
3063
+ *
1930
3064
  * @category Numeric checks
1931
3065
  * @since 4.0.0
1932
3066
  */
@@ -2528,6 +3662,58 @@ export const isBetweenBigInt = /*#__PURE__*/makeIsBetween({
2528
3662
  }
2529
3663
  })
2530
3664
  });
3665
+ /**
3666
+ * Validates that a BigDecimal is greater than the specified value (exclusive).
3667
+ *
3668
+ * @category BigDecimal checks
3669
+ * @since 4.0.0
3670
+ */
3671
+ export const isGreaterThanBigDecimal = /*#__PURE__*/makeIsGreaterThan({
3672
+ order: BigDecimal_.Order,
3673
+ formatter: bd => BigDecimal_.format(bd)
3674
+ });
3675
+ /**
3676
+ * Validates that a BigDecimal is greater than or equal to the specified value
3677
+ * (inclusive).
3678
+ *
3679
+ * @category BigDecimal checks
3680
+ * @since 4.0.0
3681
+ */
3682
+ export const isGreaterThanOrEqualToBigDecimal = /*#__PURE__*/makeIsGreaterThanOrEqualTo({
3683
+ order: BigDecimal_.Order,
3684
+ formatter: bd => BigDecimal_.format(bd)
3685
+ });
3686
+ /**
3687
+ * Validates that a BigDecimal is less than the specified value (exclusive).
3688
+ *
3689
+ * @category BigDecimal checks
3690
+ * @since 4.0.0
3691
+ */
3692
+ export const isLessThanBigDecimal = /*#__PURE__*/makeIsLessThan({
3693
+ order: BigDecimal_.Order,
3694
+ formatter: bd => BigDecimal_.format(bd)
3695
+ });
3696
+ /**
3697
+ * Validates that a BigDecimal is less than or equal to the specified value
3698
+ * (inclusive).
3699
+ *
3700
+ * @category BigDecimal checks
3701
+ * @since 4.0.0
3702
+ */
3703
+ export const isLessThanOrEqualToBigDecimal = /*#__PURE__*/makeIsLessThanOrEqualTo({
3704
+ order: BigDecimal_.Order,
3705
+ formatter: bd => BigDecimal_.format(bd)
3706
+ });
3707
+ /**
3708
+ * Validates that a BigDecimal is within a specified range.
3709
+ *
3710
+ * @category BigDecimal checks
3711
+ * @since 4.0.0
3712
+ */
3713
+ export const isBetweenBigDecimal = /*#__PURE__*/makeIsBetween({
3714
+ order: BigDecimal_.Order,
3715
+ formatter: bd => BigDecimal_.format(bd)
3716
+ });
2531
3717
  /**
2532
3718
  * Validates that a value has at least the specified length. Works with strings
2533
3719
  * and arrays.
@@ -2543,6 +3729,14 @@ export const isBetweenBigInt = /*#__PURE__*/makeIsBetween({
2543
3729
  * constraint to ensure generated strings or arrays have at least the required
2544
3730
  * length.
2545
3731
  *
3732
+ * **Example** (Minimum length check)
3733
+ * ```ts
3734
+ * import { Schema } from "effect"
3735
+ *
3736
+ * const NonEmptyStringSchema = Schema.String.check(Schema.isMinLength(1))
3737
+ * const NonEmptyArraySchema = Schema.Array(Schema.Number).check(Schema.isMinLength(1))
3738
+ * ```
3739
+ *
2546
3740
  * @category Length checks
2547
3741
  * @since 4.0.0
2548
3742
  */
@@ -2935,6 +4129,7 @@ export function isPropertyNames(keySchema, annotations) {
2935
4129
  * constraint using the provided equivalence function to ensure generated arrays
2936
4130
  * contain only unique items.
2937
4131
  *
4132
+ * @category Array checks
2938
4133
  * @since 4.0.0
2939
4134
  */
2940
4135
  export function isUnique(annotations) {
@@ -2952,23 +4147,24 @@ export function isUnique(annotations) {
2952
4147
  ...annotations
2953
4148
  });
2954
4149
  }
2955
- // -----------------------------------------------------------------------------
2956
- // Built-in Schemas
2957
- // -----------------------------------------------------------------------------
2958
4150
  /**
2959
4151
  * A schema for non-empty strings. Validates that a string has at least one
2960
4152
  * character.
2961
4153
  *
4154
+ * @category String
2962
4155
  * @since 4.0.0
2963
4156
  */
2964
4157
  export const NonEmptyString = /*#__PURE__*/String.check(/*#__PURE__*/isNonEmpty());
2965
4158
  /**
2966
4159
  * A schema representing a single character.
2967
4160
  *
4161
+ * @category String
2968
4162
  * @since 4.0.0
2969
4163
  */
2970
4164
  export const Char = /*#__PURE__*/String.check(/*#__PURE__*/isLengthBetween(1, 1));
2971
4165
  /**
4166
+ * Creates a schema for `Option<A>`. See {@link Option} for details.
4167
+ *
2972
4168
  * @category Option
2973
4169
  * @since 4.0.0
2974
4170
  */
@@ -3041,6 +4237,40 @@ export function Option(value) {
3041
4237
  export function OptionFromNullOr(schema) {
3042
4238
  return NullOr(schema).pipe(decodeTo(Option(toType(schema)), Transformation.optionFromNullOr()));
3043
4239
  }
4240
+ /**
4241
+ * Decodes an undefined-or value `T` to a required `Option<T>` value.
4242
+ *
4243
+ * Decoding:
4244
+ * - `undefined` is decoded as `None`
4245
+ * - other values are decoded as `Some`
4246
+ *
4247
+ * Encoding:
4248
+ * - `None` is encoded as `undefined`
4249
+ * - `Some` is encoded as the value
4250
+ *
4251
+ * @category Option
4252
+ * @since 4.0.0
4253
+ */
4254
+ export function OptionFromUndefinedOr(schema) {
4255
+ return UndefinedOr(schema).pipe(decodeTo(Option(toType(schema)), Transformation.optionFromUndefinedOr()));
4256
+ }
4257
+ /**
4258
+ * Decodes a nullish value `T` to a required `Option<T>` value.
4259
+ *
4260
+ * Decoding:
4261
+ * - `null` and `undefined` are decoded as `None`
4262
+ * - other values are decoded as `Some`
4263
+ *
4264
+ * Encoding:
4265
+ * - `None` is encoded as `null` or `undefined` depending on the provided `options.onNoneEncoding` (defaults to `undefined`)
4266
+ * - `Some` is encoded as the value
4267
+ *
4268
+ * @category Option
4269
+ * @since 4.0.0
4270
+ */
4271
+ export function OptionFromNullishOr(schema, options) {
4272
+ return NullishOr(schema).pipe(decodeTo(Option(toType(schema)), Transformation.optionFromNullishOr(options)));
4273
+ }
3044
4274
  /**
3045
4275
  * Decodes an optional value `A` to a required `Option<A>` value.
3046
4276
  *
@@ -3078,6 +4308,35 @@ export function OptionFromOptional(schema) {
3078
4308
  return optional(schema).pipe(decodeTo(Option(toType(schema)), Transformation.optionFromOptional()));
3079
4309
  }
3080
4310
  /**
4311
+ * Decodes an optional or `null` or `undefined` value `A` to a required `Option<A>`
4312
+ * value.
4313
+ *
4314
+ * Decoding:
4315
+ * - a missing key is decoded as `None`
4316
+ * - a present key with an `undefined` value is decoded as `None`
4317
+ * - a present key with a `null` value is decoded as `None`
4318
+ * - all other values are decoded as `Some`
4319
+ *
4320
+ * Encoding (controlled by `options.onNoneEncoding`):
4321
+ * - `"omit"` (default): `None` is encoded as a missing key
4322
+ * - `null`: `None` is encoded as `null`
4323
+ * - `undefined`: `None` is encoded as `undefined`
4324
+ * - `Some` is always encoded as the value
4325
+ *
4326
+ * @category Option
4327
+ * @since 4.0.0
4328
+ */
4329
+ export function OptionFromOptionalNullOr(schema, options) {
4330
+ const onNoneEncoding = options === undefined ? "omit" : options.onNoneEncoding;
4331
+ const noneValue = onNoneEncoding === null ? null : undefined;
4332
+ return optional(NullOr(schema)).pipe(decodeTo(Option(toType(schema)), Transformation.transformOptional({
4333
+ decode: oe => oe.pipe(Option_.filter(Predicate.isNotNullish), Option_.some),
4334
+ encode: onNoneEncoding === "omit" ? Option_.flatten : ot => Option_.some(Option_.getOrElse(Option_.flatten(ot), () => noneValue))
4335
+ })));
4336
+ }
4337
+ /**
4338
+ * Creates a schema for `Result<A, E>`. See {@link Result} for details.
4339
+ *
3081
4340
  * @category Result
3082
4341
  * @since 4.0.0
3083
4342
  */
@@ -3206,6 +4465,9 @@ export function Redacted(value, options) {
3206
4465
  });
3207
4466
  }
3208
4467
  /**
4468
+ * Middleware that wraps decoded errors in `Redacted`, preventing sensitive
4469
+ * schema details from leaking in error messages.
4470
+ *
3209
4471
  * @category Redacted
3210
4472
  * @since 4.0.0
3211
4473
  */
@@ -3213,6 +4475,10 @@ export function redact(schema) {
3213
4475
  return schema.pipe(middlewareDecoding(Effect.mapErrorEager(Issue.redact)));
3214
4476
  }
3215
4477
  /**
4478
+ * Decodes a value and wraps it in `Redacted<A>`. Unlike {@link Redacted} which
4479
+ * expects the input to already be a `Redacted` instance, this schema decodes
4480
+ * the raw value and wraps it.
4481
+ *
3216
4482
  * @category Redacted
3217
4483
  * @since 4.0.0
3218
4484
  */
@@ -3225,10 +4491,12 @@ export function RedactedFromValue(value, options) {
3225
4491
  }));
3226
4492
  }
3227
4493
  /**
3228
- * @category CauseFailure
4494
+ * Creates a schema for `Cause.Reason<E>`. See {@link CauseReason} for details.
4495
+ *
4496
+ * @category CauseReason
3229
4497
  * @since 4.0.0
3230
4498
  */
3231
- export function CauseFailure(error, defect) {
4499
+ export function CauseReason(error, defect) {
3232
4500
  const schema = declareConstructor()([error, defect], ([error, defect]) => (input, ast, options) => {
3233
4501
  if (!Cause_.isReason(input)) {
3234
4502
  return Effect.fail(new Issue.InvalidType(ast, Option_.some(input)));
@@ -3252,7 +4520,7 @@ export function CauseFailure(error, defect) {
3252
4520
  _tag: "effect/Cause/Failure"
3253
4521
  },
3254
4522
  generation: {
3255
- runtime: `Schema.CauseFailure(?, ?)`,
4523
+ runtime: `Schema.CauseReason(?, ?)`,
3256
4524
  Type: `Cause.Failure<?, ?>`,
3257
4525
  importDeclaration: `import * as Cause from "effect/Cause"`
3258
4526
  },
@@ -3279,16 +4547,16 @@ export function CauseFailure(error, defect) {
3279
4547
  },
3280
4548
  encode: identity
3281
4549
  })),
3282
- toArbitrary: ([error, defect]) => causeFailureToArbitrary(error, defect),
3283
- toEquivalence: ([error, defect]) => causeFailureToEquivalence(error, defect),
3284
- toFormatter: ([error, defect]) => causeFailureToFormatter(error, defect)
4550
+ toArbitrary: ([error, defect]) => causeReasonToArbitrary(error, defect),
4551
+ toEquivalence: ([error, defect]) => causeReasonToEquivalence(error, defect),
4552
+ toFormatter: ([error, defect]) => causeReasonToFormatter(error, defect)
3285
4553
  });
3286
4554
  return make(schema.ast, {
3287
4555
  error,
3288
4556
  defect
3289
4557
  });
3290
4558
  }
3291
- function causeFailureToArbitrary(error, defect) {
4559
+ function causeReasonToArbitrary(error, defect) {
3292
4560
  return (fc, ctx) => {
3293
4561
  return fc.oneof(ctx?.isSuspend ? {
3294
4562
  maxDepth: 2,
@@ -3298,7 +4566,7 @@ function causeFailureToArbitrary(error, defect) {
3298
4566
  }).map(Cause_.makeInterruptReason), error.map(e => Cause_.makeFailReason(e)), defect.map(d => Cause_.makeDieReason(d)));
3299
4567
  };
3300
4568
  }
3301
- function causeFailureToEquivalence(error, defect) {
4569
+ function causeReasonToEquivalence(error, defect) {
3302
4570
  return (a, b) => {
3303
4571
  if (a._tag !== b._tag) return false;
3304
4572
  switch (a._tag) {
@@ -3311,7 +4579,7 @@ function causeFailureToEquivalence(error, defect) {
3311
4579
  }
3312
4580
  };
3313
4581
  }
3314
- function causeFailureToFormatter(error, defect) {
4582
+ function causeReasonToFormatter(error, defect) {
3315
4583
  return t => {
3316
4584
  switch (t._tag) {
3317
4585
  case "Fail":
@@ -3324,19 +4592,23 @@ function causeFailureToFormatter(error, defect) {
3324
4592
  };
3325
4593
  }
3326
4594
  /**
4595
+ * Creates a schema for `Cause<E>`. See {@link Cause} for details.
4596
+ *
3327
4597
  * @category Cause
3328
4598
  * @since 4.0.0
3329
4599
  */
3330
4600
  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
- });
4601
+ const schema = declareConstructor()([error, defect], ([error, defect]) => {
4602
+ const failures = ArraySchema(CauseReason(error, defect));
4603
+ return (input, ast, options) => {
4604
+ if (!Cause_.isCause(input)) {
4605
+ return Effect.fail(new Issue.InvalidType(ast, Option_.some(input)));
4606
+ }
4607
+ return Effect.mapBothEager(Parser.decodeUnknownEffect(failures)(input.reasons, options), {
4608
+ onSuccess: Cause_.fromReasons,
4609
+ onFailure: issue => new Issue.Composite(ast, Option_.some(input), [new Issue.Pointer(["failures"], issue)])
4610
+ });
4611
+ };
3340
4612
  }, {
3341
4613
  typeConstructor: {
3342
4614
  _tag: "effect/Cause"
@@ -3347,7 +4619,7 @@ export function Cause(error, defect) {
3347
4619
  importDeclaration: `import * as Cause from "effect/Cause"`
3348
4620
  },
3349
4621
  expected: "Cause",
3350
- toCodec: ([error, defect]) => link()(Array(CauseFailure(error, defect)), Transformation.transform({
4622
+ toCodec: ([error, defect]) => link()(ArraySchema(CauseReason(error, defect)), Transformation.transform({
3351
4623
  decode: Cause_.fromReasons,
3352
4624
  encode: ({
3353
4625
  reasons: failures
@@ -3364,16 +4636,16 @@ export function Cause(error, defect) {
3364
4636
  }
3365
4637
  function causeToArbitrary(error, defect) {
3366
4638
  return (fc, ctx) => {
3367
- return fc.array(causeFailureToArbitrary(error, defect)(fc, ctx)).map(Cause_.fromReasons);
4639
+ return fc.array(causeReasonToArbitrary(error, defect)(fc, ctx)).map(Cause_.fromReasons);
3368
4640
  };
3369
4641
  }
3370
4642
  function causeToEquivalence(error, defect) {
3371
- const failures = Equivalence.Array(causeFailureToEquivalence(error, defect));
4643
+ const failures = Equivalence.Array(causeReasonToEquivalence(error, defect));
3372
4644
  return (a, b) => failures(a.reasons, b.reasons);
3373
4645
  }
3374
4646
  function causeToFormatter(error, defect) {
3375
- const causeFailure = causeFailureToFormatter(error, defect);
3376
- return t => `Cause([${t.reasons.map(causeFailure).join(", ")}])`;
4647
+ const causeReason = causeReasonToFormatter(error, defect);
4648
+ return t => `Cause([${t.reasons.map(causeReason).join(", ")}])`;
3377
4649
  }
3378
4650
  const ErrorJsonEncoded = /*#__PURE__*/Struct({
3379
4651
  message: String,
@@ -3445,7 +4717,7 @@ export const Defect = /*#__PURE__*/Union([/*#__PURE__*/ErrorJsonEncoded.pipe(/*#
3445
4717
  * A schema that represents defects, that also includes stack traces in the
3446
4718
  * encoded form.
3447
4719
  *
3448
- * @category Constructors
4720
+ * @category Defect
3449
4721
  * @since 4.0.0
3450
4722
  */
3451
4723
  export const DefectWithStack = /*#__PURE__*/Union([/*#__PURE__*/ErrorJsonEncoded.pipe(/*#__PURE__*/decodeTo(ErrorWithStack, /*#__PURE__*/Transformation.errorFromErrorJsonEncoded({
@@ -3455,27 +4727,31 @@ export const DefectWithStack = /*#__PURE__*/Union([/*#__PURE__*/ErrorJsonEncoded
3455
4727
  toArbitrary: () => fc => fc.json()
3456
4728
  }), defectTransformation))]);
3457
4729
  /**
4730
+ * Creates a schema for `Exit<A, E>`. See {@link Exit} for details.
4731
+ *
3458
4732
  * @category Exit
3459
4733
  * @since 4.0.0
3460
4734
  */
3461
4735
  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
- }
4736
+ const schema = declareConstructor()([value, error, defect], ([value, error, defect]) => {
3466
4737
  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
- }
4738
+ return (input, ast, options) => {
4739
+ if (!Exit_.isExit(input)) {
4740
+ return Effect.fail(new Issue.InvalidType(ast, Option_.some(input)));
4741
+ }
4742
+ switch (input._tag) {
4743
+ case "Success":
4744
+ return Effect.mapBothEager(Parser.decodeUnknownEffect(value)(input.value, options), {
4745
+ onSuccess: Exit_.succeed,
4746
+ onFailure: issue => new Issue.Composite(ast, Option_.some(input), [new Issue.Pointer(["value"], issue)])
4747
+ });
4748
+ case "Failure":
4749
+ return Effect.mapBothEager(Parser.decodeUnknownEffect(cause)(input.cause, options), {
4750
+ onSuccess: Exit_.failCause,
4751
+ onFailure: issue => new Issue.Composite(ast, Option_.some(input), [new Issue.Pointer(["cause"], issue)])
4752
+ });
4753
+ }
4754
+ };
3479
4755
  }, {
3480
4756
  typeConstructor: {
3481
4757
  _tag: "effect/Exit"
@@ -3544,15 +4820,17 @@ export function Exit(value, error, defect) {
3544
4820
  * @since 4.0.0
3545
4821
  */
3546
4822
  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
- });
3554
- }
3555
- return Effect.fail(new Issue.InvalidType(ast, Option_.some(input)));
4823
+ const schema = declareConstructor()([key, value], ([key, value]) => {
4824
+ const array = ArraySchema(Tuple([key, value]));
4825
+ return (input, ast, options) => {
4826
+ if (input instanceof globalThis.Map) {
4827
+ return Effect.mapBothEager(Parser.decodeUnknownEffect(array)([...input], options), {
4828
+ onSuccess: array => new globalThis.Map(array),
4829
+ onFailure: issue => new Issue.Composite(ast, Option_.some(input), [new Issue.Pointer(["entries"], issue)])
4830
+ });
4831
+ }
4832
+ return Effect.fail(new Issue.InvalidType(ast, Option_.some(input)));
4833
+ };
3556
4834
  }, {
3557
4835
  typeConstructor: {
3558
4836
  _tag: "ReadonlyMap"
@@ -3562,7 +4840,7 @@ export function ReadonlyMap(key, value) {
3562
4840
  Type: `globalThis.ReadonlyMap<?, ?>`
3563
4841
  },
3564
4842
  expected: "ReadonlyMap",
3565
- toCodec: ([key, value]) => link()(Array(Tuple([key, value])), Transformation.transform({
4843
+ toCodec: ([key, value]) => link()(ArraySchema(Tuple([key, value])), Transformation.transform({
3566
4844
  decode: e => new globalThis.Map(e),
3567
4845
  encode: map => [...map.entries()]
3568
4846
  })),
@@ -3587,20 +4865,76 @@ export function ReadonlyMap(key, value) {
3587
4865
  value
3588
4866
  });
3589
4867
  }
4868
+ /**
4869
+ * Creates a schema that validates a `HashMap` where keys and values must
4870
+ * conform to the provided schemas.
4871
+ *
4872
+ * @category HashMap
4873
+ * @since 4.0.0
4874
+ */
4875
+ export function HashMap(key, value) {
4876
+ const schema = declareConstructor()([key, value], ([key, value]) => {
4877
+ const entries = ArraySchema(Tuple([key, value]));
4878
+ return (input, ast, options) => {
4879
+ if (HashMap_.isHashMap(input)) {
4880
+ return Effect.mapBothEager(Parser.decodeUnknownEffect(entries)(HashMap_.toEntries(input), options), {
4881
+ onSuccess: HashMap_.fromIterable,
4882
+ onFailure: issue => new Issue.Composite(ast, Option_.some(input), [new Issue.Pointer(["entries"], issue)])
4883
+ });
4884
+ }
4885
+ return Effect.fail(new Issue.InvalidType(ast, Option_.some(input)));
4886
+ };
4887
+ }, {
4888
+ typeConstructor: {
4889
+ _tag: "effect/HashMap"
4890
+ },
4891
+ generation: {
4892
+ runtime: `Schema.HashMap(?, ?)`,
4893
+ Type: `HashMap.HashMap<?, ?>`,
4894
+ importDeclaration: `import * as HashMap from "effect/HashMap"`
4895
+ },
4896
+ expected: "HashMap",
4897
+ toCodec: ([key, value]) => link()(ArraySchema(Tuple([key, value])), Transformation.transform({
4898
+ decode: HashMap_.fromIterable,
4899
+ encode: HashMap_.toEntries
4900
+ })),
4901
+ toArbitrary: ([key, value]) => (fc, ctx) => {
4902
+ return fc.oneof(ctx?.isSuspend ? {
4903
+ maxDepth: 2,
4904
+ depthIdentifier: "HashMap"
4905
+ } : {}, fc.constant([]), fc.array(fc.tuple(key, value), ctx?.constraints?.array)).map(HashMap_.fromIterable);
4906
+ },
4907
+ toEquivalence: ([key, value]) => Equal.makeCompareMap(key, value),
4908
+ toFormatter: ([key, value]) => t => {
4909
+ const size = HashMap_.size(t);
4910
+ if (size === 0) {
4911
+ return "HashMap(0) {}";
4912
+ }
4913
+ const entries = HashMap_.toEntries(t).sort().map(([k, v]) => `${key(k)} => ${value(v)}`);
4914
+ return `HashMap(${size}) { ${entries.join(", ")} }`;
4915
+ }
4916
+ });
4917
+ return make(schema.ast, {
4918
+ key,
4919
+ value
4920
+ });
4921
+ }
3590
4922
  /**
3591
4923
  * @category ReadonlySet
3592
4924
  * @since 4.0.0
3593
4925
  */
3594
4926
  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)));
4927
+ const schema = declareConstructor()([value], ([value]) => {
4928
+ const array = ArraySchema(value);
4929
+ return (input, ast, options) => {
4930
+ if (input instanceof globalThis.Set) {
4931
+ return Effect.mapBothEager(Parser.decodeUnknownEffect(array)([...input], options), {
4932
+ onSuccess: array => new globalThis.Set(array),
4933
+ onFailure: issue => new Issue.Composite(ast, Option_.some(input), [new Issue.Pointer(["values"], issue)])
4934
+ });
4935
+ }
4936
+ return Effect.fail(new Issue.InvalidType(ast, Option_.some(input)));
4937
+ };
3604
4938
  }, {
3605
4939
  typeConstructor: {
3606
4940
  _tag: "ReadonlySet"
@@ -3610,7 +4944,7 @@ export function ReadonlySet(value) {
3610
4944
  Type: `globalThis.ReadonlySet<?>`
3611
4945
  },
3612
4946
  expected: "ReadonlySet",
3613
- toCodec: ([value]) => link()(Array(value), Transformation.transform({
4947
+ toCodec: ([value]) => link()(ArraySchema(value), Transformation.transform({
3614
4948
  decode: e => new globalThis.Set(e),
3615
4949
  encode: set => [...set.values()]
3616
4950
  })),
@@ -3635,6 +4969,115 @@ export function ReadonlySet(value) {
3635
4969
  });
3636
4970
  }
3637
4971
  /**
4972
+ * Creates a schema that validates a `HashSet` where values must conform to the
4973
+ * provided schema.
4974
+ *
4975
+ * @category HashSet
4976
+ * @since 4.0.0
4977
+ */
4978
+ export function HashSet(value) {
4979
+ const schema = declareConstructor()([value], ([value]) => {
4980
+ const values = ArraySchema(value);
4981
+ return (input, ast, options) => {
4982
+ if (HashSet_.isHashSet(input)) {
4983
+ return Effect.mapBothEager(Parser.decodeUnknownEffect(values)(Arr.fromIterable(input), options), {
4984
+ onSuccess: HashSet_.fromIterable,
4985
+ onFailure: issue => new Issue.Composite(ast, Option_.some(input), [new Issue.Pointer(["values"], issue)])
4986
+ });
4987
+ }
4988
+ return Effect.fail(new Issue.InvalidType(ast, Option_.some(input)));
4989
+ };
4990
+ }, {
4991
+ typeConstructor: {
4992
+ _tag: "effect/HashSet"
4993
+ },
4994
+ generation: {
4995
+ runtime: `Schema.HashSet(?)`,
4996
+ Type: `HashSet.HashSet<?>`
4997
+ },
4998
+ expected: "HashSet",
4999
+ toCodec: ([value]) => link()(ArraySchema(value), Transformation.transform({
5000
+ decode: HashSet_.fromIterable,
5001
+ encode: Arr.fromIterable
5002
+ })),
5003
+ toArbitrary: ([value]) => (fc, ctx) => {
5004
+ return fc.oneof(ctx?.isSuspend ? {
5005
+ maxDepth: 2,
5006
+ depthIdentifier: "HashSet"
5007
+ } : {}, fc.constant([]), fc.array(value, ctx?.constraints?.array)).map(HashSet_.fromIterable);
5008
+ },
5009
+ toEquivalence: ([value]) => Equal.makeCompareSet(value),
5010
+ toFormatter: ([value]) => t => {
5011
+ const size = HashSet_.size(t);
5012
+ if (size === 0) {
5013
+ return "HashSet(0) {}";
5014
+ }
5015
+ const values = globalThis.Array.from(t).sort().map(v => `${value(v)}`);
5016
+ return `HashSet(${size}) { ${values.join(", ")} }`;
5017
+ }
5018
+ });
5019
+ return make(schema.ast, {
5020
+ value
5021
+ });
5022
+ }
5023
+ /**
5024
+ * Creates a schema that validates a `Chunk` where values must conform to the
5025
+ * provided schema.
5026
+ *
5027
+ * @category Chunk
5028
+ * @since 4.0.0
5029
+ */
5030
+ export function Chunk(value) {
5031
+ const schema = declareConstructor()([value], ([value]) => {
5032
+ const values = ArraySchema(value);
5033
+ return (input, ast, options) => {
5034
+ if (Chunk_.isChunk(input)) {
5035
+ return Effect.mapBothEager(Parser.decodeUnknownEffect(values)(Arr.fromIterable(input), options), {
5036
+ onSuccess: Chunk_.fromIterable,
5037
+ onFailure: issue => new Issue.Composite(ast, Option_.some(input), [new Issue.Pointer(["values"], issue)])
5038
+ });
5039
+ }
5040
+ return Effect.fail(new Issue.InvalidType(ast, Option_.some(input)));
5041
+ };
5042
+ }, {
5043
+ typeConstructor: {
5044
+ _tag: "effect/Chunk"
5045
+ },
5046
+ generation: {
5047
+ runtime: `Schema.Chunk(?)`,
5048
+ Type: `Chunk.Chunk<?>`
5049
+ },
5050
+ expected: "Chunk",
5051
+ toCodec: ([value]) => link()(ArraySchema(value), Transformation.transform({
5052
+ decode: Chunk_.fromIterable,
5053
+ encode: Arr.fromIterable
5054
+ })),
5055
+ toArbitrary: ([value]) => (fc, ctx) => {
5056
+ return fc.oneof(ctx?.isSuspend ? {
5057
+ maxDepth: 2,
5058
+ depthIdentifier: "Chunk"
5059
+ } : {}, fc.constant([]), fc.array(value, ctx?.constraints?.array)).map(Chunk_.fromIterable);
5060
+ },
5061
+ toEquivalence: ([value]) => Chunk_.makeEquivalence(value),
5062
+ toFormatter: ([value]) => t => {
5063
+ const size = Chunk_.size(t);
5064
+ if (size === 0) {
5065
+ return "Chunk(0) {}";
5066
+ }
5067
+ const values = globalThis.Array.from(t).sort().map(v => `${value(v)}`);
5068
+ return `Chunk(${size}) { ${values.join(", ")} }`;
5069
+ }
5070
+ });
5071
+ return make(schema.ast, {
5072
+ value
5073
+ });
5074
+ }
5075
+ /**
5076
+ * Schema for JavaScript `RegExp` objects.
5077
+ *
5078
+ * The default JSON serializer encodes a `RegExp` as `{ source, flags }`.
5079
+ *
5080
+ * @category RegExp
3638
5081
  * @since 4.0.0
3639
5082
  */
3640
5083
  export const RegExp = /*#__PURE__*/instanceOf(globalThis.RegExp, {
@@ -3668,6 +5111,9 @@ export const RegExp = /*#__PURE__*/instanceOf(globalThis.RegExp, {
3668
5111
  }).map(flags => flags.join(""))).map(([source, flags]) => new globalThis.RegExp(source, flags)),
3669
5112
  toEquivalence: () => (a, b) => a.source === b.source && a.flags === b.flags
3670
5113
  });
5114
+ const URLString = /*#__PURE__*/String.annotate({
5115
+ expected: "a string that will be decoded as a URL"
5116
+ });
3671
5117
  /**
3672
5118
  * A schema for JavaScript `URL` objects.
3673
5119
  *
@@ -3687,9 +5133,7 @@ export const URL = /*#__PURE__*/instanceOf(globalThis.URL, {
3687
5133
  Type: `globalThis.URL`
3688
5134
  },
3689
5135
  expected: "URL",
3690
- toCodecJson: () => link()(String.annotate({
3691
- expected: "a string that will be decoded as a URL"
3692
- }), Transformation.urlFromString),
5136
+ toCodecJson: () => link()(URLString, Transformation.urlFromString),
3693
5137
  toArbitrary: () => fc => fc.webUrl().map(s => new globalThis.URL(s)),
3694
5138
  toEquivalence: () => (a, b) => a.toString() === b.toString()
3695
5139
  });
@@ -3705,15 +5149,27 @@ export const URL = /*#__PURE__*/instanceOf(globalThis.URL, {
3705
5149
  * @category URL
3706
5150
  * @since 4.0.0
3707
5151
  */
3708
- export const URLFromString = /*#__PURE__*/String.annotate({
3709
- expected: "a string that will be decoded as a URL"
3710
- }).pipe(/*#__PURE__*/decodeTo(URL, Transformation.urlFromString)); // TODO: remove duplication with URL schema
5152
+ export const URLFromString = /*#__PURE__*/URLString.pipe(/*#__PURE__*/decodeTo(URL, Transformation.urlFromString));
5153
+ const DateString = /*#__PURE__*/String.annotate({
5154
+ expected: "a string in ISO 8601 format that will be decoded as a Date"
5155
+ });
3711
5156
  /**
3712
5157
  * A schema for JavaScript `Date` objects.
3713
5158
  *
3714
5159
  * This schema accepts any `Date` instance, including invalid dates (e.g., `new
3715
- * Date("invalid")`). For validating only valid dates, use `ValidDate` instead.
5160
+ * Date("invalid")`). For validating only valid dates, use {@link DateValid}
5161
+ * instead. The default JSON serializer encodes `Date` as an ISO 8601 string.
5162
+ *
5163
+ * **Example** (Date schema)
5164
+ *
5165
+ * ```ts
5166
+ * import { Schema } from "effect"
3716
5167
  *
5168
+ * Schema.decodeUnknownSync(Schema.Date)(new Date("2024-01-01"))
5169
+ * // => Date { 2024-01-01T00:00:00.000Z }
5170
+ * ```
5171
+ *
5172
+ * @category Date
3717
5173
  * @since 4.0.0
3718
5174
  */
3719
5175
  export const Date = /*#__PURE__*/instanceOf(globalThis.Date, {
@@ -3725,29 +5181,49 @@ export const Date = /*#__PURE__*/instanceOf(globalThis.Date, {
3725
5181
  Type: `globalThis.Date`
3726
5182
  },
3727
5183
  expected: "Date",
3728
- toCodecJson: () => link()(String.annotate({
3729
- expected: "a string in ISO 8601 format that will be decoded as a Date"
3730
- }), Transformation.transform({
3731
- decode: s => new globalThis.Date(s),
3732
- encode: formatDate
3733
- })),
5184
+ toCodecJson: () => link()(DateString, Transformation.dateFromString),
3734
5185
  toArbitrary: () => (fc, ctx) => fc.date(ctx?.constraints?.date)
3735
5186
  });
5187
+ /**
5188
+ * A transformation schema that parses an ISO 8601 string into a `Date`.
5189
+ *
5190
+ * Decoding:
5191
+ * - A `string` is decoded as a `Date`.
5192
+ *
5193
+ * Encoding:
5194
+ * - A `Date` is encoded as a `string`.
5195
+ *
5196
+ * @category Date
5197
+ * @since 4.0.0
5198
+ */
5199
+ export const DateFromString = /*#__PURE__*/DateString.pipe(/*#__PURE__*/decodeTo(Date, Transformation.dateFromString));
3736
5200
  /**
3737
5201
  * A schema for **valid** JavaScript `Date` objects.
3738
5202
  *
3739
5203
  * This schema accepts `Date` instances but rejects invalid dates (such as `new
3740
5204
  * Date("invalid")`).
3741
5205
  *
5206
+ * @category Date
3742
5207
  * @since 4.0.0
3743
5208
  */
3744
5209
  export const DateValid = /*#__PURE__*/Date.check(/*#__PURE__*/isDateValid());
3745
5210
  /**
3746
5211
  * A schema for `Duration` values.
3747
5212
  *
3748
- * **Default JSON serializer**
5213
+ * The default JSON serializer encodes `Duration` as a tagged object with the
5214
+ * duration type and value.
5215
+ *
5216
+ * **Example** (Duration schema)
5217
+ *
5218
+ * ```ts
5219
+ * import { Schema } from "effect"
5220
+ * import { Duration } from "effect"
5221
+ *
5222
+ * Schema.decodeUnknownSync(Schema.Duration)(Duration.seconds(5))
5223
+ * // => Duration(5s)
5224
+ * ```
3749
5225
  *
3750
- * - encodes `Duration` as a `string`
5226
+ * @category Duration
3751
5227
  *
3752
5228
  * @since 4.0.0
3753
5229
  */
@@ -3842,6 +5318,50 @@ export const DurationFromNanos = /*#__PURE__*/BigInt.check(isGreaterThanOrEqualT
3842
5318
  * @since 4.0.0
3843
5319
  */
3844
5320
  export const DurationFromMillis = /*#__PURE__*/Number.check(isGreaterThanOrEqualTo(0)).pipe(/*#__PURE__*/decodeTo(Duration, Transformation.durationFromMillis));
5321
+ const BigDecimalString = /*#__PURE__*/String.annotate({
5322
+ expected: "a string that will be decoded as a BigDecimal"
5323
+ });
5324
+ /**
5325
+ * A schema for `BigDecimal` values.
5326
+ *
5327
+ * **Default JSON serializer**
5328
+ *
5329
+ * - encodes `BigDecimal` as a `string`
5330
+ *
5331
+ * @category BigDecimal
5332
+ * @since 4.0.0
5333
+ */
5334
+ export const BigDecimal = /*#__PURE__*/declare(BigDecimal_.isBigDecimal, {
5335
+ typeConstructor: {
5336
+ _tag: "effect/BigDecimal"
5337
+ },
5338
+ generation: {
5339
+ runtime: `Schema.BigDecimal`,
5340
+ Type: `BigDecimal.BigDecimal`,
5341
+ importDeclaration: `import * as BigDecimal from "effect/BigDecimal"`
5342
+ },
5343
+ expected: "BigDecimal",
5344
+ toCodecJson: () => link()(BigDecimalString, Transformation.bigDecimalFromString),
5345
+ toArbitrary: () => fc => fc.tuple(fc.bigInt(), fc.integer({
5346
+ min: 0,
5347
+ max: 20
5348
+ })).map(([value, scale]) => BigDecimal_.make(value, scale)),
5349
+ toFormatter: () => bd => BigDecimal_.format(bd),
5350
+ toEquivalence: () => BigDecimal_.Equivalence
5351
+ });
5352
+ /**
5353
+ * A transformation schema that parses a string into a `BigDecimal`.
5354
+ *
5355
+ * Decoding:
5356
+ * - A `string` is decoded as a `BigDecimal`.
5357
+ *
5358
+ * Encoding:
5359
+ * - A `BigDecimal` is encoded as a `string`.
5360
+ *
5361
+ * @category BigDecimal
5362
+ * @since 4.0.0
5363
+ */
5364
+ export const BigDecimalFromString = /*#__PURE__*/BigDecimalString.pipe(/*#__PURE__*/decodeTo(BigDecimal, Transformation.bigDecimalFromString));
3845
5365
  /**
3846
5366
  * A transformation schema that decodes a JSON-encoded string into an `unknown` value.
3847
5367
  *
@@ -3862,6 +5382,7 @@ export const DurationFromMillis = /*#__PURE__*/Number.check(isGreaterThanOrEqual
3862
5382
  * // => { a: 1, b: 2 }
3863
5383
  * ```
3864
5384
  *
5385
+ * @category JSON
3865
5386
  * @since 4.0.0
3866
5387
  */
3867
5388
  export const UnknownFromJsonString = /*#__PURE__*/fromJsonString(Unknown);
@@ -3926,6 +5447,7 @@ export const UnknownFromJsonString = /*#__PURE__*/fromJsonString(Unknown);
3926
5447
  * // }
3927
5448
  * ```
3928
5449
  *
5450
+ * @category JSON
3929
5451
  * @since 4.0.0
3930
5452
  */
3931
5453
  export function fromJsonString(schema) {
@@ -3936,6 +5458,12 @@ export function fromJsonString(schema) {
3936
5458
  }).pipe(decodeTo(schema, Transformation.fromJsonString));
3937
5459
  }
3938
5460
  /**
5461
+ * Schema for JavaScript `File` objects.
5462
+ *
5463
+ * The default JSON serializer encodes a `File` as `{ data, type, name, lastModified }`
5464
+ * where `data` is base64-encoded.
5465
+ *
5466
+ * @category File
3939
5467
  * @since 4.0.0
3940
5468
  */
3941
5469
  export const File = /*#__PURE__*/instanceOf(globalThis.File, {
@@ -3953,7 +5481,7 @@ export const File = /*#__PURE__*/instanceOf(globalThis.File, {
3953
5481
  name: String,
3954
5482
  lastModified: Number
3955
5483
  }), Transformation.transformOrFail({
3956
- decode: e => Result_.match(Base64.decode(e.data), {
5484
+ decode: e => Result_.match(Encoding.decodeBase64(e.data), {
3957
5485
  onFailure: error => Effect.fail(new Issue.InvalidValue(Option_.some(e.data), {
3958
5486
  message: error.message
3959
5487
  })),
@@ -3969,7 +5497,7 @@ export const File = /*#__PURE__*/instanceOf(globalThis.File, {
3969
5497
  try: async () => {
3970
5498
  const bytes = new globalThis.Uint8Array(await file.arrayBuffer());
3971
5499
  return {
3972
- data: Base64.encode(bytes),
5500
+ data: Encoding.encodeBase64(bytes),
3973
5501
  type: file.type,
3974
5502
  name: file.name,
3975
5503
  lastModified: file.lastModified
@@ -3982,6 +5510,12 @@ export const File = /*#__PURE__*/instanceOf(globalThis.File, {
3982
5510
  }))
3983
5511
  });
3984
5512
  /**
5513
+ * Schema for JavaScript `FormData` objects.
5514
+ *
5515
+ * The default JSON serializer encodes a `FormData` as an array of `[key, entry]`
5516
+ * pairs where each entry is tagged as `"String"` or `"File"`.
5517
+ *
5518
+ * @category FormData
3985
5519
  * @since 4.0.0
3986
5520
  */
3987
5521
  export const FormData = /*#__PURE__*/instanceOf(globalThis.FormData, {
@@ -3993,7 +5527,7 @@ export const FormData = /*#__PURE__*/instanceOf(globalThis.FormData, {
3993
5527
  Type: `globalThis.FormData`
3994
5528
  },
3995
5529
  expected: "FormData",
3996
- toCodecJson: () => link()(Array(Tuple([String, Union([Struct({
5530
+ toCodecJson: () => link()(ArraySchema(Tuple([String, Union([Struct({
3997
5531
  _tag: tag("String"),
3998
5532
  value: String
3999
5533
  }), Struct({
@@ -4111,6 +5645,11 @@ export function fromFormData(schema) {
4111
5645
  return FormData.pipe(decodeTo(schema, Transformation.fromFormData));
4112
5646
  }
4113
5647
  /**
5648
+ * Schema for JavaScript `URLSearchParams` objects.
5649
+ *
5650
+ * The default JSON serializer encodes a `URLSearchParams` as a query string.
5651
+ *
5652
+ * @category URLSearchParams
4114
5653
  * @since 4.0.0
4115
5654
  */
4116
5655
  export const URLSearchParams = /*#__PURE__*/instanceOf(globalThis.URLSearchParams, {
@@ -4209,75 +5748,177 @@ export function fromURLSearchParams(schema) {
4209
5748
  /**
4210
5749
  * A schema for finite numbers, rejecting `NaN`, `Infinity`, and `-Infinity`.
4211
5750
  *
5751
+ * @category Number
4212
5752
  * @since 4.0.0
4213
5753
  */
4214
5754
  export const Finite = /*#__PURE__*/Number.check(/*#__PURE__*/isFinite());
4215
5755
  /**
4216
5756
  * A schema for integers, rejecting `NaN`, `Infinity`, and `-Infinity`.
4217
5757
  *
5758
+ * @category Number
5759
+ * @since 4.0.0
5760
+ */
5761
+ export const Int = /*#__PURE__*/Number.check(/*#__PURE__*/isInt());
5762
+ /**
5763
+ * A transformation schema that parses a string into a number.
5764
+ *
5765
+ * Decoding:
5766
+ * - A `string` is decoded as a finite number.
5767
+ *
5768
+ * Encoding:
5769
+ * - A number is encoded as a `string`.
5770
+ *
5771
+ * @category Number
5772
+ * @since 4.0.0
5773
+ */
5774
+ export const NumberFromString = /*#__PURE__*/String.annotate({
5775
+ expected: "a string that will be decoded as a number"
5776
+ }).pipe(/*#__PURE__*/decodeTo(Number, Transformation.numberFromString));
5777
+ /**
5778
+ * A transformation schema that parses a string into a finite number.
5779
+ *
5780
+ * Decoding:
5781
+ * - A `string` is decoded as a finite number, rejecting `NaN`, `Infinity`, and
5782
+ * `-Infinity` values.
5783
+ *
5784
+ * Encoding:
5785
+ * - A finite number is encoded as a `string`.
5786
+ *
5787
+ * @category Number
5788
+ * @since 4.0.0
5789
+ */
5790
+ export const FiniteFromString = /*#__PURE__*/String.annotate({
5791
+ expected: "a string that will be decoded as a finite number"
5792
+ }).pipe(/*#__PURE__*/decodeTo(Finite, Transformation.numberFromString));
5793
+ /**
5794
+ * A transformation schema that parses a string into a `bigint`.
5795
+ *
5796
+ * Decoding:
5797
+ * - A `string` is decoded as a `bigint`.
5798
+ *
5799
+ * Encoding:
5800
+ * - A `bigint` is encoded as a `string`.
5801
+ *
5802
+ * @category BigInt
5803
+ * @since 4.0.0
5804
+ */
5805
+ export const BigIntFromString = /*#__PURE__*/make(AST.bigIntString).pipe(/*#__PURE__*/decodeTo(BigInt, Transformation.bigintFromString));
5806
+ /**
5807
+ * A schema for strings that contains no leading or trailing whitespaces.
5808
+ *
5809
+ * @category String
5810
+ * @since 4.0.0
5811
+ */
5812
+ export const Trimmed = /*#__PURE__*/String.check(/*#__PURE__*/isTrimmed());
5813
+ /**
5814
+ * A transformation schema that trims whitespace from a string.
5815
+ *
5816
+ * Decoding:
5817
+ * - A `string` is decoded as a string with no leading or trailing whitespaces.
5818
+ *
5819
+ * Encoding:
5820
+ * - The trimmed string is encoded as is.
5821
+ *
5822
+ * @category String
4218
5823
  * @since 4.0.0
4219
5824
  */
4220
- export const Int = /*#__PURE__*/Number.check(/*#__PURE__*/isInt());
5825
+ export const Trim = /*#__PURE__*/String.annotate({
5826
+ expected: "a string that will be decoded as a trimmed string"
5827
+ }).pipe(/*#__PURE__*/decodeTo(Trimmed, /*#__PURE__*/Transformation.trim()));
4221
5828
  /**
4222
- * A transformation schema that parses a string into a number.
5829
+ * Decodes a base64 (RFC4648) encoded string into a UTF-8 string.
4223
5830
  *
4224
5831
  * Decoding:
4225
- * - A `string` is decoded as a finite number.
5832
+ * - A **valid** base64 encoded string is decoded as a UTF-8 `string`.
4226
5833
  *
4227
5834
  * Encoding:
4228
- * - A number is encoded as a `string`.
5835
+ * - A `string` is encoded as a base64-encoded string.
4229
5836
  *
5837
+ * @category String
4230
5838
  * @since 4.0.0
4231
5839
  */
4232
- export const NumberFromString = /*#__PURE__*/String.annotate({
4233
- expected: "a string that will be decoded as a number"
4234
- }).pipe(/*#__PURE__*/decodeTo(Number, Transformation.numberFromString));
5840
+ export const StringFromBase64 = /*#__PURE__*/String.annotate({
5841
+ expected: "a base64 encoded string that will be decoded as a UTF-8 string"
5842
+ }).pipe(/*#__PURE__*/decodeTo(String, Transformation.stringFromBase64String));
4235
5843
  /**
4236
- * A transformation schema that parses a string into a finite number.
5844
+ * Decodes a base64 (URL) encoded string into a UTF-8 string.
4237
5845
  *
4238
5846
  * Decoding:
4239
- * - A `string` is decoded as a finite number, rejecting `NaN`, `Infinity`, and
4240
- * `-Infinity` values.
5847
+ * - A **valid** base64 (URL) encoded string is decoded as a UTF-8 `string`.
4241
5848
  *
4242
5849
  * Encoding:
4243
- * - A finite number is encoded as a `string`.
5850
+ * - A `string` is encoded as a base64 (URL) encoded string.
4244
5851
  *
5852
+ * @category String
4245
5853
  * @since 4.0.0
4246
5854
  */
4247
- export const FiniteFromString = /*#__PURE__*/String.annotate({
4248
- expected: "a string that will be decoded as a finite number"
4249
- }).pipe(/*#__PURE__*/decodeTo(Finite, Transformation.numberFromString));
5855
+ export const StringFromBase64Url = /*#__PURE__*/String.annotate({
5856
+ expected: "a base64 (URL) encoded string that will be decoded as a UTF-8 string"
5857
+ }).pipe(/*#__PURE__*/decodeTo(String, Transformation.stringFromBase64UrlString));
4250
5858
  /**
4251
- * A schema for strings that contains no leading or trailing whitespaces.
5859
+ * Decodes a hex encoded string into a UTF-8 string.
5860
+ *
5861
+ * Decoding:
5862
+ * - A **valid** hex encoded string is decoded as a UTF-8 `string`.
5863
+ *
5864
+ * Encoding:
5865
+ * - A `string` is encoded as a hex string.
4252
5866
  *
5867
+ * @category String
4253
5868
  * @since 4.0.0
4254
5869
  */
4255
- export const Trimmed = /*#__PURE__*/String.check(/*#__PURE__*/isTrimmed());
5870
+ export const StringFromHex = /*#__PURE__*/String.annotate({
5871
+ expected: "a hex encoded string that will be decoded as a UTF-8 string"
5872
+ }).pipe(/*#__PURE__*/decodeTo(String, Transformation.stringFromHexString));
4256
5873
  /**
4257
- * A transformation schema that trims whitespace from a string.
5874
+ * Decodes a URI component encoded string into a UTF-8 string.
5875
+ * Can be used to store data in a URL.
4258
5876
  *
4259
5877
  * Decoding:
4260
- * - A `string` is decoded as a string with no leading or trailing whitespaces.
5878
+ * - A **valid** URI component encoded string is decoded as a UTF-8 `string`.
4261
5879
  *
4262
5880
  * Encoding:
4263
- * - The trimmed string is encoded as is.
5881
+ * - A `string` is encoded as a URI component encoded string.
5882
+ *
5883
+ * **Example**
5884
+ *
5885
+ * ```ts
5886
+ * import { Schema } from "effect"
4264
5887
  *
5888
+ * const PaginationSchema = Schema.Struct({
5889
+ * maxItemPerPage: Schema.Number,
5890
+ * page: Schema.Number
5891
+ * })
5892
+ *
5893
+ * const UrlSchema = Schema.StringFromUriComponent.pipe(
5894
+ * Schema.decodeTo(Schema.fromJsonString(PaginationSchema))
5895
+ * )
5896
+ *
5897
+ * console.log(Schema.encodeSync(UrlSchema)({ maxItemPerPage: 10, page: 1 }))
5898
+ * // %7B%22maxItemPerPage%22%3A10%2C%22page%22%3A1%7D
5899
+ * ```
5900
+ *
5901
+ * @category String
4265
5902
  * @since 4.0.0
4266
5903
  */
4267
- export const Trim = /*#__PURE__*/String.annotate({
4268
- expected: "a string that will be decoded as a trimmed string"
4269
- }).pipe(/*#__PURE__*/decodeTo(Trimmed, /*#__PURE__*/Transformation.trim()));
5904
+ export const StringFromUriComponent = /*#__PURE__*/String.annotate({
5905
+ expected: "a URI component encoded string that will be decoded as a UTF-8 string"
5906
+ }).pipe(/*#__PURE__*/decodeTo(String, Transformation.stringFromUriComponent));
4270
5907
  /**
5908
+ * A union schema for JavaScript property keys: `number | symbol | string`.
5909
+ *
5910
+ * @category PropertyKey
4271
5911
  * @since 4.0.0
4272
5912
  */
4273
5913
  export const PropertyKey = /*#__PURE__*/Union([Finite, Symbol, String]);
4274
5914
  /**
5915
+ * @category StandardSchema
4275
5916
  * @since 4.0.0
4276
5917
  */
4277
5918
  export const StandardSchemaV1FailureResult = /*#__PURE__*/Struct({
4278
- issues: /*#__PURE__*/Array(/*#__PURE__*/Struct({
5919
+ issues: /*#__PURE__*/ArraySchema(/*#__PURE__*/Struct({
4279
5920
  message: String,
4280
- path: /*#__PURE__*/optional(/*#__PURE__*/Array(/*#__PURE__*/Union([PropertyKey, /*#__PURE__*/Struct({
5921
+ path: /*#__PURE__*/optional(/*#__PURE__*/ArraySchema(/*#__PURE__*/Union([PropertyKey, /*#__PURE__*/Struct({
4281
5922
  key: PropertyKey
4282
5923
  })])))
4283
5924
  }))
@@ -4383,7 +6024,7 @@ export const Uint8ArrayFromHex = /*#__PURE__*/String.annotate({
4383
6024
  */
4384
6025
  export const DateTimeUtc = /*#__PURE__*/declare(u => DateTime.isDateTime(u) && DateTime.isUtc(u), {
4385
6026
  typeConstructor: {
4386
- _tag: "DateTime.Utc"
6027
+ _tag: "effect/DateTime.Utc"
4387
6028
  },
4388
6029
  generation: {
4389
6030
  runtime: `Schema.DateTimeUtc`,
@@ -4391,10 +6032,7 @@ export const DateTimeUtc = /*#__PURE__*/declare(u => DateTime.isDateTime(u) && D
4391
6032
  importDeclaration: `import * as DateTime from "effect/DateTime"`
4392
6033
  },
4393
6034
  expected: "DateTime.Utc",
4394
- toCodecJson: () => link()(String, {
4395
- decode: Getter.dateTimeUtcFromInput(),
4396
- encode: Getter.transform(DateTime.formatIso)
4397
- }),
6035
+ toCodecJson: () => link()(String, Transformation.dateTimeUtcFromString),
4398
6036
  toArbitrary: () => (fc, ctx) => fc.date({
4399
6037
  noInvalidDate: true,
4400
6038
  ...ctx?.constraints?.date
@@ -4434,10 +6072,7 @@ export const DateTimeUtcFromDate = /*#__PURE__*/DateValid.pipe(/*#__PURE__*/deco
4434
6072
  */
4435
6073
  export const DateTimeUtcFromString = /*#__PURE__*/String.annotate({
4436
6074
  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
- })));
6075
+ }).pipe(/*#__PURE__*/decodeTo(DateTimeUtc, Transformation.dateTimeUtcFromString));
4441
6076
  /**
4442
6077
  * A transformation schema that decodes a number into a `DateTime.Utc`.
4443
6078
  *
@@ -4454,29 +6089,184 @@ export const DateTimeUtcFromMillis = /*#__PURE__*/Number.pipe(/*#__PURE__*/decod
4454
6089
  decode: /*#__PURE__*/Getter.dateTimeUtcFromInput(),
4455
6090
  encode: /*#__PURE__*/Getter.transform(DateTime.toEpochMillis)
4456
6091
  }));
6092
+ /**
6093
+ * A schema for `DateTime.TimeZone.Offset` values.
6094
+ *
6095
+ * **Default JSON serializer**
6096
+ *
6097
+ * - encodes `DateTime.TimeZone.Offset` as a number (offset in milliseconds)
6098
+ *
6099
+ * @category DateTime
6100
+ * @since 4.0.0
6101
+ */
6102
+ export const TimeZoneOffset = /*#__PURE__*/declare(DateTime.isTimeZoneOffset, {
6103
+ typeConstructor: {
6104
+ _tag: "effect/DateTime.TimeZone.Offset"
6105
+ },
6106
+ generation: {
6107
+ runtime: `Schema.TimeZoneOffset`,
6108
+ Type: `DateTime.TimeZone.Offset`,
6109
+ importDeclaration: `import * as DateTime from "effect/DateTime"`
6110
+ },
6111
+ expected: "DateTime.TimeZone.Offset",
6112
+ toCodecJson: () => link()(Number, Transformation.timeZoneOffsetFromNumber),
6113
+ toArbitrary: () => fc => fc.integer({
6114
+ min: -12 * 60 * 60 * 1000,
6115
+ max: 14 * 60 * 60 * 1000
6116
+ }).map(n => DateTime.zoneMakeOffset(n)),
6117
+ toFormatter: () => tz => DateTime.zoneToString(tz),
6118
+ toEquivalence: () => (a, b) => a.offset === b.offset
6119
+ });
6120
+ const TimeZoneNamedString = /*#__PURE__*/String.annotate({
6121
+ expected: "an IANA time zone identifier"
6122
+ });
6123
+ /**
6124
+ * A schema for `DateTime.TimeZone.Named` values.
6125
+ *
6126
+ * **Default JSON serializer**
6127
+ *
6128
+ * - encodes `DateTime.TimeZone.Named` as a string (IANA time zone identifier)
6129
+ *
6130
+ * @category DateTime
6131
+ * @since 4.0.0
6132
+ */
6133
+ export const TimeZoneNamed = /*#__PURE__*/declare(DateTime.isTimeZoneNamed, {
6134
+ typeConstructor: {
6135
+ _tag: "effect/DateTime.TimeZone.Named"
6136
+ },
6137
+ generation: {
6138
+ runtime: `Schema.TimeZoneNamed`,
6139
+ Type: `DateTime.TimeZone.Named`,
6140
+ importDeclaration: `import * as DateTime from "effect/DateTime"`
6141
+ },
6142
+ expected: "DateTime.TimeZone.Named",
6143
+ toCodecJson: () => link()(TimeZoneNamedString, Transformation.timeZoneNamedFromString),
6144
+ toArbitrary: () => fc => fc.constantFrom(...["UTC", "Europe/London", "America/New_York", "Asia/Tokyo", "Australia/Sydney"].map(DateTime.zoneMakeNamedUnsafe)),
6145
+ toFormatter: () => tz => DateTime.zoneToString(tz),
6146
+ toEquivalence: () => (a, b) => a.id === b.id
6147
+ });
6148
+ /**
6149
+ * A transformation schema that parses an IANA time zone identifier string into a `DateTime.TimeZone.Named`.
6150
+ *
6151
+ * Decoding:
6152
+ * - A `string` is decoded as a `DateTime.TimeZone.Named`.
6153
+ *
6154
+ * Encoding:
6155
+ * - A `DateTime.TimeZone.Named` is encoded as a `string`.
6156
+ *
6157
+ * @category DateTime
6158
+ * @since 4.0.0
6159
+ */
6160
+ export const TimeZoneNamedFromString = /*#__PURE__*/TimeZoneNamedString.pipe(/*#__PURE__*/decodeTo(TimeZoneNamed, Transformation.timeZoneNamedFromString));
6161
+ const TimeZoneString = /*#__PURE__*/String.annotate({
6162
+ expected: "a time zone string (IANA identifier or offset like +03:00)"
6163
+ });
6164
+ /**
6165
+ * A schema for `DateTime.TimeZone` values.
6166
+ *
6167
+ * **Default JSON serializer**
6168
+ *
6169
+ * - encodes `DateTime.TimeZone` as a string (IANA identifier or offset like
6170
+ * `+03:00`)
6171
+ *
6172
+ * @category DateTime
6173
+ * @since 4.0.0
6174
+ */
6175
+ export const TimeZone = /*#__PURE__*/declare(DateTime.isTimeZone, {
6176
+ typeConstructor: {
6177
+ _tag: "effect/DateTime.TimeZone"
6178
+ },
6179
+ generation: {
6180
+ runtime: `Schema.TimeZone`,
6181
+ Type: `DateTime.TimeZone`,
6182
+ importDeclaration: `import * as DateTime from "effect/DateTime"`
6183
+ },
6184
+ expected: "DateTime.TimeZone",
6185
+ toCodecJson: () => link()(TimeZoneString, Transformation.timeZoneFromString),
6186
+ toArbitrary: () => fc => fc.oneof(fc.integer({
6187
+ min: -12 * 60 * 60 * 1000,
6188
+ max: 14 * 60 * 60 * 1000
6189
+ }).map(n => DateTime.zoneMakeOffset(n)), fc.constantFrom(...["UTC", "Europe/London", "America/New_York", "Asia/Tokyo", "Australia/Sydney"].map(DateTime.zoneMakeNamedUnsafe))),
6190
+ toFormatter: () => tz => DateTime.zoneToString(tz),
6191
+ toEquivalence: () => (a, b) => DateTime.zoneToString(a) === DateTime.zoneToString(b)
6192
+ });
6193
+ /**
6194
+ * A transformation schema that parses a time zone string into a `DateTime.TimeZone`.
6195
+ *
6196
+ * Decoding:
6197
+ * - A `string` (IANA identifier or offset like `+03:00`) is decoded as a `DateTime.TimeZone`.
6198
+ *
6199
+ * Encoding:
6200
+ * - A `DateTime.TimeZone` is encoded as a `string`.
6201
+ *
6202
+ * @category DateTime
6203
+ * @since 4.0.0
6204
+ */
6205
+ export const TimeZoneFromString = /*#__PURE__*/TimeZoneString.pipe(/*#__PURE__*/decodeTo(TimeZone, Transformation.timeZoneFromString));
6206
+ const DateTimeZonedString = /*#__PURE__*/String.annotate({
6207
+ expected: "a zoned DateTime string (e.g. 2024-01-01T00:00:00.000+00:00[Europe/London])"
6208
+ });
6209
+ /**
6210
+ * A schema for `DateTime.Zoned` values.
6211
+ *
6212
+ * **Default JSON serializer**
6213
+ *
6214
+ * - encodes `DateTime.Zoned` as a string in the format
6215
+ * `YYYY-MM-DDTHH:mm:ss.sss+HH:MM[Time/Zone]`
6216
+ *
6217
+ * @category DateTime
6218
+ * @since 4.0.0
6219
+ */
6220
+ export const DateTimeZoned = /*#__PURE__*/declare(u => DateTime.isDateTime(u) && DateTime.isZoned(u), {
6221
+ typeConstructor: {
6222
+ _tag: "effect/DateTime.Zoned"
6223
+ },
6224
+ generation: {
6225
+ runtime: `Schema.DateTimeZoned`,
6226
+ Type: `DateTime.Zoned`,
6227
+ importDeclaration: `import * as DateTime from "effect/DateTime"`
6228
+ },
6229
+ expected: "DateTime.Zoned",
6230
+ toCodecJson: () => link()(DateTimeZonedString, Transformation.dateTimeZonedFromString),
6231
+ toArbitrary: () => (fc, ctx) => fc.tuple(fc.date({
6232
+ noInvalidDate: true,
6233
+ min: new globalThis.Date(-8640000000000000 + 14 * 60 * 60 * 1000),
6234
+ max: new globalThis.Date(8640000000000000 - 14 * 60 * 60 * 1000),
6235
+ ...ctx?.constraints?.date
6236
+ }), fc.constantFrom("UTC", "Europe/London", "America/New_York", "Asia/Tokyo", "Australia/Sydney")).map(([date, zone]) => DateTime.makeZonedUnsafe(date, {
6237
+ timeZone: zone
6238
+ })),
6239
+ toFormatter: () => zoned => DateTime.formatIsoZoned(zoned),
6240
+ toEquivalence: () => DateTime.Equivalence
6241
+ });
6242
+ /**
6243
+ * A transformation schema that parses a zoned DateTime string into a `DateTime.Zoned`.
6244
+ *
6245
+ * Decoding:
6246
+ * - A `string` (e.g. `2024-01-01T00:00:00.000+00:00[Europe/London]`) is decoded as a `DateTime.Zoned`.
6247
+ *
6248
+ * Encoding:
6249
+ * - A `DateTime.Zoned` is encoded as a `string`.
6250
+ *
6251
+ * @category DateTime
6252
+ * @since 4.0.0
6253
+ */
6254
+ export const DateTimeZonedFromString = /*#__PURE__*/DateTimeZonedString.pipe(/*#__PURE__*/decodeTo(DateTimeZoned, Transformation.dateTimeZonedFromString));
4457
6255
  const immerable = /*#__PURE__*/globalThis.Symbol.for("immer-draftable");
4458
- function makeClass(Inherited, identifier, struct, annotations) {
6256
+ function makeClass(Inherited, identifier, struct, annotations, proto) {
4459
6257
  const getClassSchema = getClassSchemaFactory(struct, identifier, annotations);
4460
6258
  const ClassTypeId = getClassTypeId(identifier); // HMR support
4461
- return class extends Inherited {
6259
+ const out = class extends Inherited {
4462
6260
  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
- }
4475
- }
4476
- toString() {
4477
- return `${identifier}(${format({
4478
- ...this
4479
- })})`;
6261
+ input = input ?? {};
6262
+ const validated = struct.make(input, options);
6263
+ super({
6264
+ ...input,
6265
+ ...validated
6266
+ }, {
6267
+ ...options,
6268
+ disableChecks: true
6269
+ });
4480
6270
  }
4481
6271
  static [TypeId] = TypeId;
4482
6272
  get [ClassTypeId]() {
@@ -4494,9 +6284,15 @@ function makeClass(Inherited, identifier, struct, annotations) {
4494
6284
  static rebuild(ast) {
4495
6285
  return getClassSchema(this).rebuild(ast);
4496
6286
  }
4497
- static makeUnsafe(input, options) {
6287
+ static make(input, options) {
4498
6288
  return new this(input, options);
4499
6289
  }
6290
+ static makeOption(input, options) {
6291
+ return Parser.makeOption(getClassSchema(this))(input ?? {}, options);
6292
+ }
6293
+ static makeEffect(input, options) {
6294
+ return Effect.mapErrorEager(Parser.makeEffect(getClassSchema(this))(input ?? {}, options), issue => new SchemaError(issue));
6295
+ }
4500
6296
  static annotate(annotations) {
4501
6297
  return this.rebuild(AST.annotate(this.ast, annotations));
4502
6298
  }
@@ -4514,13 +6310,17 @@ function makeClass(Inherited, identifier, struct, annotations) {
4514
6310
  };
4515
6311
  return makeClass(this, identifier, makeStruct(AST.struct(fields, struct.ast.checks, {
4516
6312
  identifier
4517
- }), fields), annotations);
6313
+ }), fields), annotations, proto);
4518
6314
  };
4519
6315
  }
4520
6316
  static mapFields(f, options) {
4521
6317
  return struct.mapFields(f, options);
4522
6318
  }
4523
6319
  };
6320
+ if (proto !== undefined) {
6321
+ Object.assign(out.prototype, proto(identifier));
6322
+ }
6323
+ return out;
4524
6324
  }
4525
6325
  function getClassTransformation(self) {
4526
6326
  return new Transformation.Transformation(Getter.transform(input => new self(input)), Getter.passthrough());
@@ -4541,6 +6341,7 @@ function getClassSchemaFactory(from, identifier, annotations) {
4541
6341
  toCodec: ([from]) => new AST.Link(from.ast, transformation),
4542
6342
  toArbitrary: ([from]) => () => from.map(args => new self(args)),
4543
6343
  toFormatter: ([from]) => t => `${self.identifier}(${from(t)})`,
6344
+ "~sentinels": AST.collectSentinels(from.ast),
4544
6345
  ...annotations
4545
6346
  }));
4546
6347
  memo = from.pipe(decodeTo(to, transformation));
@@ -4552,14 +6353,81 @@ function isStruct(schema) {
4552
6353
  return isSchema(schema);
4553
6354
  }
4554
6355
  /**
6356
+ * Creates a schema-backed class whose constructor validates input against a
6357
+ * {@link Struct} schema. Construction throws a {@link SchemaError} on invalid
6358
+ * input (unless `disableChecks` is set in the options).
6359
+ *
6360
+ * Pass the desired class type as the first type parameter. The second optional
6361
+ * type parameter can be used to add nominal brands.
6362
+ *
6363
+ * **Example** (Basic class)
6364
+ *
6365
+ * ```ts
6366
+ * import { Schema } from "effect"
6367
+ *
6368
+ * class Person extends Schema.Class<Person>("Person")({
6369
+ * name: Schema.String,
6370
+ * age: Schema.Number
6371
+ * }) {}
6372
+ *
6373
+ * const alice = new Person({ name: "Alice", age: 30 })
6374
+ * console.log(alice.name) // "Alice"
6375
+ * console.log(`${alice}`) // "Person({ name: Alice, age: 30 })"
6376
+ * ```
6377
+ *
6378
+ * **Example** (Extending a class)
6379
+ *
6380
+ * ```ts
6381
+ * import { Schema } from "effect"
6382
+ *
6383
+ * class Animal extends Schema.Class<Animal>("Animal")({
6384
+ * name: Schema.String
6385
+ * }) {}
6386
+ *
6387
+ * class Dog extends Animal.extend<Dog>("Dog")({
6388
+ * breed: Schema.String
6389
+ * }) {}
6390
+ *
6391
+ * const dog = new Dog({ name: "Rex", breed: "Labrador" })
6392
+ * console.log(dog.name) // "Rex"
6393
+ * console.log(dog.breed) // "Labrador"
6394
+ * ```
6395
+ *
4555
6396
  * @category Constructors
4556
6397
  * @since 4.0.0
4557
6398
  */
4558
6399
  export const Class = identifier => (schema, annotations) => {
4559
6400
  const struct = isStruct(schema) ? schema : Struct(schema);
4560
- return makeClass(Data.Class, identifier, struct, annotations);
6401
+ return makeClass(Data.Class, identifier, struct, annotations, identifier => ({
6402
+ toString() {
6403
+ return `${identifier}(${format({
6404
+ ...this
6405
+ })})`;
6406
+ }
6407
+ }));
4561
6408
  };
4562
6409
  /**
6410
+ * Like {@link Class} but automatically adds a `_tag` literal field set to the
6411
+ * given `tag` value. This makes instances compatible with tagged union
6412
+ * discrimination patterns.
6413
+ *
6414
+ * The optional `identifier` parameter overrides the schema identifier;
6415
+ * it defaults to the `tag` value.
6416
+ *
6417
+ * **Example** (Tagged class)
6418
+ *
6419
+ * ```ts
6420
+ * import { Schema } from "effect"
6421
+ *
6422
+ * class Circle extends Schema.TaggedClass<Circle>()("Circle", {
6423
+ * radius: Schema.Number
6424
+ * }) {}
6425
+ *
6426
+ * const c = new Circle({ radius: 5 })
6427
+ * console.log(c._tag) // "Circle"
6428
+ * console.log(c.radius) // 5
6429
+ * ```
6430
+ *
4563
6431
  * @category Constructors
4564
6432
  * @since 4.0.0
4565
6433
  */
@@ -4574,14 +6442,54 @@ export const TaggedClass = identifier => {
4574
6442
  };
4575
6443
  };
4576
6444
  /**
6445
+ * Creates a schema-backed error class that can be used as a typed,
6446
+ * yieldable error in Effect programs. Combines {@link Class} validation with
6447
+ * the `YieldableError` interface so instances can be yielded directly inside
6448
+ * `Effect.gen`.
6449
+ *
6450
+ * **Example** (Schema-backed error)
6451
+ *
6452
+ * ```ts
6453
+ * import { Effect, Schema } from "effect"
6454
+ *
6455
+ * class NotFound extends Schema.ErrorClass<NotFound>("NotFound")({
6456
+ * id: Schema.Number
6457
+ * }) {}
6458
+ *
6459
+ * const program = Effect.gen(function*() {
6460
+ * yield* new NotFound({ id: 1 })
6461
+ * })
6462
+ * ```
6463
+ *
4577
6464
  * @category Constructors
4578
6465
  * @since 4.0.0
4579
6466
  */
4580
6467
  export const ErrorClass = identifier => (schema, annotations) => {
4581
6468
  const struct = isStruct(schema) ? schema : Struct(schema);
4582
- return makeClass(core.Error, identifier, struct, annotations);
6469
+ const self = makeClass(core.Error, identifier, struct, annotations, identifier => ({
6470
+ name: identifier
6471
+ }));
6472
+ return self;
4583
6473
  };
4584
6474
  /**
6475
+ * Like {@link ErrorClass} but automatically adds a `_tag` literal field. The
6476
+ * resulting class is both a schema-validated, yieldable error and a tagged
6477
+ * union member.
6478
+ *
6479
+ * **Example** (Tagged error class)
6480
+ *
6481
+ * ```ts
6482
+ * import { Effect, Schema } from "effect"
6483
+ *
6484
+ * class NotFound extends Schema.TaggedErrorClass<NotFound>()("NotFound", {
6485
+ * id: Schema.Number
6486
+ * }) {}
6487
+ *
6488
+ * const program = Effect.gen(function*() {
6489
+ * yield* new NotFound({ id: 42 })
6490
+ * })
6491
+ * ```
6492
+ *
4585
6493
  * @category Constructors
4586
6494
  * @since 4.0.0
4587
6495
  */
@@ -4596,6 +6504,11 @@ export const TaggedErrorClass = identifier => {
4596
6504
  };
4597
6505
  };
4598
6506
  /**
6507
+ * Derives a {@link LazyArbitrary} from a schema. The result is memoized so
6508
+ * repeated calls with the same schema are cheap.
6509
+ *
6510
+ * Prefer {@link toArbitrary} when you just need the arbitrary directly.
6511
+ *
4599
6512
  * @category Arbitrary
4600
6513
  * @since 4.0.0
4601
6514
  */
@@ -4604,6 +6517,24 @@ export function toArbitraryLazy(schema) {
4604
6517
  return fc => lawc(fc, {});
4605
6518
  }
4606
6519
  /**
6520
+ * Derives a `fast-check` `Arbitrary` from a schema for property-based
6521
+ * testing. The derived arbitrary generates values that satisfy the schema.
6522
+ *
6523
+ * **Example** (Generating arbitrary values)
6524
+ *
6525
+ * ```ts
6526
+ * import { Schema } from "effect"
6527
+ * import * as FastCheck from "fast-check"
6528
+ *
6529
+ * const PersonArb = Schema.toArbitrary(
6530
+ * Schema.Struct({ name: Schema.String, age: Schema.Number })
6531
+ * )
6532
+ *
6533
+ * // Sample a random value
6534
+ * const sample = FastCheck.sample(PersonArb, 1)[0]
6535
+ * console.log(typeof sample.name) // "string"
6536
+ * ```
6537
+ *
4607
6538
  * @category Arbitrary
4608
6539
  * @since 4.0.0
4609
6540
  */
@@ -4630,6 +6561,13 @@ export function overrideToFormatter(toFormatter) {
4630
6561
  };
4631
6562
  }
4632
6563
  /**
6564
+ * Derives a string formatter function from a schema. The formatter converts
6565
+ * a value to its human-readable string representation, recursing into structs,
6566
+ * arrays, and unions.
6567
+ *
6568
+ * The optional `onBefore` hook lets you intercept specific AST nodes before
6569
+ * the default formatting logic runs.
6570
+ *
4633
6571
  * @category Formatter
4634
6572
  * @since 4.0.0
4635
6573
  */
@@ -4768,10 +6706,9 @@ export function toFormatter(schema, options) {
4768
6706
  // Equivalence
4769
6707
  // -----------------------------------------------------------------------------
4770
6708
  /**
4771
- * **Technical Note**
4772
- *
4773
- * This annotation cannot be added to `Annotations.Bottom` because it would make
4774
- * the schema invariant.
6709
+ * Overrides the equivalence derivation for a schema by supplying a custom
6710
+ * `Equivalence`. Use this when the default structural equivalence derived by
6711
+ * {@link toEquivalence} is not appropriate for a type.
4775
6712
  *
4776
6713
  * @category Equivalence
4777
6714
  * @since 4.0.0
@@ -4782,6 +6719,21 @@ export function overrideToEquivalence(toEquivalence) {
4782
6719
  });
4783
6720
  }
4784
6721
  /**
6722
+ * Derives an `Equivalence` from a schema. Two values are considered equal when
6723
+ * every field (and nested field) compares equal according to the schema
6724
+ * structure.
6725
+ *
6726
+ * **Example** (Struct equivalence)
6727
+ *
6728
+ * ```ts
6729
+ * import { Schema } from "effect"
6730
+ *
6731
+ * const eq = Schema.toEquivalence(Schema.Struct({ id: Schema.Number, name: Schema.String }))
6732
+ *
6733
+ * console.log(eq({ id: 1, name: "Alice" }, { id: 1, name: "Alice" })) // true
6734
+ * console.log(eq({ id: 1, name: "Alice" }, { id: 2, name: "Alice" })) // false
6735
+ * ```
6736
+ *
4785
6737
  * @category Equivalence
4786
6738
  * @since 4.0.0
4787
6739
  */
@@ -4792,6 +6744,10 @@ export function toEquivalence(schema) {
4792
6744
  // Representation
4793
6745
  // -----------------------------------------------------------------------------
4794
6746
  /**
6747
+ * Derives an intermediate `SchemaRepresentation.Document` from a schema. This
6748
+ * document is used internally by {@link toJsonSchemaDocument} and related
6749
+ * functions to produce JSON Schema output.
6750
+ *
4795
6751
  * @category Representation
4796
6752
  * @since 4.0.0
4797
6753
  */
@@ -4816,17 +6772,23 @@ export function toJsonSchemaDocument(schema, options) {
4816
6772
  };
4817
6773
  }
4818
6774
  // -----------------------------------------------------------------------------
4819
- // Serializer
6775
+ // Canonical Codecs
4820
6776
  // -----------------------------------------------------------------------------
4821
6777
  /**
4822
- * @category Serializer
6778
+ * Derives a canonical JSON codec from a schema. The encoded form is `unknown`
6779
+ * (any JSON-compatible value), decoded to the schema's `Type`.
6780
+ *
6781
+ * @category Canonical Codecs
4823
6782
  * @since 4.0.0
4824
6783
  */
4825
6784
  export function toCodecJson(schema) {
4826
6785
  return make(InternalToCodec.toCodecJson(schema.ast));
4827
6786
  }
4828
6787
  /**
4829
- * @category Serializer
6788
+ * Derives an isomorphism codec from a schema. The encoded form is the
6789
+ * schema's `Iso` type — the intermediate representation used for round-tripping.
6790
+ *
6791
+ * @category Canonical Codecs
4830
6792
  * @since 4.0.0
4831
6793
  */
4832
6794
  export function toCodecIso(schema) {
@@ -4840,7 +6802,11 @@ export function toCodecStringTree(schema, options) {
4840
6802
  }
4841
6803
  }
4842
6804
  /**
4843
- * @category Serializer
6805
+ * Derives an XML encoder from a codec. Encodes a value to an XML string by
6806
+ * first converting it through {@link toCodecStringTree}, then serializing the
6807
+ * resulting tree to XML.
6808
+ *
6809
+ * @category Canonical Codecs
4844
6810
  * @since 4.0.0
4845
6811
  */
4846
6812
  export function toEncoderXml(codec, options) {
@@ -4956,8 +6922,6 @@ function getStringTreePriority(ast) {
4956
6922
  const treeReorder = /*#__PURE__*/InternalToCodec.makeReorder(getStringTreePriority);
4957
6923
  function serializerTree(ast, recur, onMissingAnnotation) {
4958
6924
  switch (ast._tag) {
4959
- case "Unknown":
4960
- case "ObjectKeyword":
4961
6925
  case "Declaration":
4962
6926
  {
4963
6927
  const getLink = ast.annotations?.toCodecJson ?? ast.annotations?.toCodec;
@@ -4973,6 +6937,9 @@ function serializerTree(ast, recur, onMissingAnnotation) {
4973
6937
  return AST.replaceEncoding(ast, [nullToString]);
4974
6938
  case "Boolean":
4975
6939
  return AST.replaceEncoding(ast, [booleanToString]);
6940
+ case "Unknown":
6941
+ case "ObjectKeyword":
6942
+ return AST.replaceEncoding(ast, [AST.unknownToStringTree]);
4976
6943
  case "Enum":
4977
6944
  case "Number":
4978
6945
  case "Literal":
@@ -5051,6 +7018,9 @@ function onSerializerEnsureArray(ast) {
5051
7018
  // Optic APIs
5052
7019
  // -----------------------------------------------------------------------------
5053
7020
  /**
7021
+ * Derives an `Iso` optic from a schema that isomorphically converts between
7022
+ * the schema's `Type` and its `Iso` (intermediate / serialized form).
7023
+ *
5054
7024
  * @category Optic
5055
7025
  * @since 4.0.0
5056
7026
  */
@@ -5059,6 +7029,8 @@ export function toIso(schema) {
5059
7029
  return Optic_.makeIso(Parser.encodeSync(serializer), Parser.decodeSync(serializer));
5060
7030
  }
5061
7031
  /**
7032
+ * Returns an identity `Iso` over the schema's source (`Type`) side.
7033
+ *
5062
7034
  * @category Optic
5063
7035
  * @since 4.0.0
5064
7036
  */
@@ -5066,6 +7038,8 @@ export function toIsoSource(_) {
5066
7038
  return Optic_.id();
5067
7039
  }
5068
7040
  /**
7041
+ * Returns an identity `Iso` over the schema's focus (`Iso`) side.
7042
+ *
5069
7043
  * @category Optic
5070
7044
  * @since 4.0.0
5071
7045
  */
@@ -5073,10 +7047,11 @@ export function toIsoFocus(_) {
5073
7047
  return Optic_.id();
5074
7048
  }
5075
7049
  /**
5076
- * **Technical Note**
5077
- *
5078
- * This annotation cannot be added to `Annotations.Bottom` because it changes
5079
- * the schema type.
7050
+ * Overrides the ISO codec derivation for a schema by providing a target codec
7051
+ * and explicit `decode`/`encode` getters. The resulting schema carries a
7052
+ * custom `Iso` type, which changes the schema's type parameter — use
7053
+ * {@link overrideToCodecIso} when the default ISO transformation is not
7054
+ * appropriate.
5080
7055
  *
5081
7056
  * @category Optic
5082
7057
  * @since 4.0.0
@@ -5094,11 +7069,15 @@ export function overrideToCodecIso(to, transformation) {
5094
7069
  // Differ APIs
5095
7070
  // -----------------------------------------------------------------------------
5096
7071
  /**
7072
+ * Derives a JSON Patch differ from a codec. Serializes values to JSON (via
7073
+ * {@link toCodecJson}), computes RFC 6902 JSON Patch operations between old
7074
+ * and new values, and can apply patches back to the typed value.
7075
+ *
5097
7076
  * @category JsonPatch
5098
7077
  * @since 4.0.0
5099
7078
  */
5100
7079
  export function toDifferJsonPatch(schema) {
5101
- const serializer = toCodecJson(schema); // TODO: remove this cast
7080
+ const serializer = toCodecJson(schema);
5102
7081
  const get = Parser.encodeSync(serializer);
5103
7082
  const set = Parser.decodeSync(serializer);
5104
7083
  return {
@@ -5113,43 +7092,66 @@ export function toDifferJsonPatch(schema) {
5113
7092
  };
5114
7093
  }
5115
7094
  /**
7095
+ * Creates a recursive schema for a {@link Tree} of values described by `node`.
7096
+ * The resulting schema accepts a single node value, an array of trees, or an
7097
+ * object whose values are trees.
7098
+ *
5116
7099
  * @category Tree
5117
7100
  * @since 4.0.0
5118
7101
  */
5119
7102
  export function Tree(node) {
5120
7103
  const Tree$ref = suspend(() => Tree);
5121
- const Tree = Union([node, Array(Tree$ref), Record(String, Tree$ref)]);
7104
+ const Tree = Union([node, ArraySchema(Tree$ref), Record(String, Tree$ref)]);
5122
7105
  return Tree;
5123
7106
  }
5124
7107
  /**
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
- /**
7108
+ * Schema that accepts and validates any immutable JSON-compatible value.
7109
+ *
7110
+ * **Example** (Validating a JSON value)
7111
+ *
7112
+ * ```ts
7113
+ * import { Schema } from "effect"
7114
+ *
7115
+ * const result = Schema.decodeUnknownOption(Schema.Json)({ key: [1, true, null] })
7116
+ * console.log(result._tag) // "Some"
7117
+ * ```
7118
+ *
5134
7119
  * @category JSON
5135
7120
  * @since 4.0.0
5136
7121
  */
5137
- export const Json = /*#__PURE__*/Tree(/*#__PURE__*/Union([Null, Number, Boolean, String]));
7122
+ export const Json = /*#__PURE__*/make(AST.Json);
5138
7123
  /**
7124
+ * Schema that accepts any mutable JSON-compatible value. See {@link Json} for
7125
+ * the immutable variant.
7126
+ *
5139
7127
  * @category JSON
5140
7128
  * @since 4.0.0
5141
7129
  */
5142
- export const MutableJson = /*#__PURE__*/MutableTree(/*#__PURE__*/Union([Null, Number, Boolean, String]));
7130
+ export const MutableJson = /*#__PURE__*/make(AST.MutableJson);
5143
7131
  // -----------------------------------------------------------------------------
5144
7132
  // Annotations
5145
7133
  // -----------------------------------------------------------------------------
5146
7134
  /**
5147
- * Return all the typed annotations from the schema.
7135
+ * Resolves the typed annotations from a schema. The term "resolve" (rather
7136
+ * than "get") reflects the lookup strategy: if the schema has checks, the
7137
+ * annotations are taken from the last check; otherwise they are taken from
7138
+ * the base schema instance.
5148
7139
  *
5149
7140
  * @category Schema Resolvers
5150
7141
  * @since 4.0.0
5151
7142
  */
5152
- export function resolveInto(schema) {
7143
+ export function resolveAnnotations(schema) {
5153
7144
  return InternalAnnotations.resolve(schema.ast);
5154
7145
  }
7146
+ /**
7147
+ * Resolves the context (key-level) annotations from a schema. Context
7148
+ * annotations are those attached via `annotateKey` and live on the AST's
7149
+ * `context` rather than on the schema node itself.
7150
+ *
7151
+ * @category Schema Resolvers
7152
+ * @since 4.0.0
7153
+ */
7154
+ export function resolveAnnotationsKey(schema) {
7155
+ return schema.ast.context?.annotations;
7156
+ }
5155
7157
  //# sourceMappingURL=Schema.js.map