effect 4.0.0-beta.5 → 4.0.0-beta.51

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 (1512) 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 +105 -52
  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 +36 -33
  12. package/dist/BigInt.js.map +1 -1
  13. package/dist/Brand.d.ts +3 -5
  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 +109 -79
  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 +3326 -383
  294. package/dist/Schema.d.ts.map +1 -1
  295. package/dist/Schema.js +2315 -283
  296. package/dist/Schema.js.map +1 -1
  297. package/dist/SchemaAST.d.ts +13 -2
  298. package/dist/SchemaAST.d.ts.map +1 -1
  299. package/dist/SchemaAST.js +340 -257
  300. package/dist/SchemaAST.js.map +1 -1
  301. package/dist/SchemaGetter.d.ts +57 -15
  302. package/dist/SchemaGetter.d.ts.map +1 -1
  303. package/dist/SchemaGetter.js +85 -25
  304. package/dist/SchemaGetter.js.map +1 -1
  305. package/dist/SchemaIssue.d.ts.map +1 -1
  306. package/dist/SchemaIssue.js +29 -11
  307. package/dist/SchemaIssue.js.map +1 -1
  308. package/dist/SchemaParser.d.ts +44 -54
  309. package/dist/SchemaParser.d.ts.map +1 -1
  310. package/dist/SchemaParser.js +69 -4
  311. package/dist/SchemaParser.js.map +1 -1
  312. package/dist/SchemaRepresentation.d.ts +46 -45
  313. package/dist/SchemaRepresentation.d.ts.map +1 -1
  314. package/dist/SchemaRepresentation.js +65 -38
  315. package/dist/SchemaRepresentation.js.map +1 -1
  316. package/dist/SchemaTransformation.d.ts +252 -3
  317. package/dist/SchemaTransformation.d.ts.map +1 -1
  318. package/dist/SchemaTransformation.js +319 -13
  319. package/dist/SchemaTransformation.js.map +1 -1
  320. package/dist/Scope.d.ts +2 -2
  321. package/dist/Scope.d.ts.map +1 -1
  322. package/dist/Scope.js.map +1 -1
  323. package/dist/ScopedCache.d.ts +2 -2
  324. package/dist/ScopedCache.d.ts.map +1 -1
  325. package/dist/ScopedCache.js +5 -5
  326. package/dist/ScopedCache.js.map +1 -1
  327. package/dist/Semaphore.d.ts +307 -0
  328. package/dist/Semaphore.d.ts.map +1 -0
  329. package/dist/Semaphore.js +220 -0
  330. package/dist/Semaphore.js.map +1 -0
  331. package/dist/Sink.d.ts +22 -19
  332. package/dist/Sink.d.ts.map +1 -1
  333. package/dist/Sink.js +54 -7
  334. package/dist/Sink.js.map +1 -1
  335. package/dist/Stdio.d.ts +18 -6
  336. package/dist/Stdio.d.ts.map +1 -1
  337. package/dist/Stdio.js +20 -2
  338. package/dist/Stdio.js.map +1 -1
  339. package/dist/Stream.d.ts +465 -542
  340. package/dist/Stream.d.ts.map +1 -1
  341. package/dist/Stream.js +321 -144
  342. package/dist/Stream.js.map +1 -1
  343. package/dist/String.d.ts +114 -47
  344. package/dist/String.d.ts.map +1 -1
  345. package/dist/String.js +29 -47
  346. package/dist/String.js.map +1 -1
  347. package/dist/Struct.d.ts +23 -7
  348. package/dist/Struct.d.ts.map +1 -1
  349. package/dist/Struct.js +22 -0
  350. package/dist/Struct.js.map +1 -1
  351. package/dist/SubscriptionRef.d.ts +3 -3
  352. package/dist/SubscriptionRef.d.ts.map +1 -1
  353. package/dist/SubscriptionRef.js +85 -117
  354. package/dist/SubscriptionRef.js.map +1 -1
  355. package/dist/SynchronizedRef.d.ts +2 -1
  356. package/dist/SynchronizedRef.d.ts.map +1 -1
  357. package/dist/SynchronizedRef.js +2 -1
  358. package/dist/SynchronizedRef.js.map +1 -1
  359. package/dist/Terminal.d.ts +5 -4
  360. package/dist/Terminal.d.ts.map +1 -1
  361. package/dist/Terminal.js +2 -2
  362. package/dist/Terminal.js.map +1 -1
  363. package/dist/Tracer.d.ts +21 -20
  364. package/dist/Tracer.d.ts.map +1 -1
  365. package/dist/Tracer.js +13 -9
  366. package/dist/Tracer.js.map +1 -1
  367. package/dist/Trie.d.ts +44 -31
  368. package/dist/Trie.d.ts.map +1 -1
  369. package/dist/Trie.js +13 -9
  370. package/dist/Trie.js.map +1 -1
  371. package/dist/TxChunk.d.ts +4 -4
  372. package/dist/TxChunk.d.ts.map +1 -1
  373. package/dist/TxChunk.js +4 -4
  374. package/dist/TxChunk.js.map +1 -1
  375. package/dist/TxDeferred.d.ts +328 -0
  376. package/dist/TxDeferred.d.ts.map +1 -0
  377. package/dist/TxDeferred.js +197 -0
  378. package/dist/TxDeferred.js.map +1 -0
  379. package/dist/TxHashMap.d.ts +105 -86
  380. package/dist/TxHashMap.d.ts.map +1 -1
  381. package/dist/TxHashMap.js +51 -44
  382. package/dist/TxHashMap.js.map +1 -1
  383. package/dist/TxHashSet.d.ts +2 -2
  384. package/dist/TxHashSet.d.ts.map +1 -1
  385. package/dist/TxHashSet.js +16 -15
  386. package/dist/TxHashSet.js.map +1 -1
  387. package/dist/TxPriorityQueue.d.ts +609 -0
  388. package/dist/TxPriorityQueue.d.ts.map +1 -0
  389. package/dist/TxPriorityQueue.js +416 -0
  390. package/dist/TxPriorityQueue.js.map +1 -0
  391. package/dist/TxPubSub.d.ts +585 -0
  392. package/dist/TxPubSub.d.ts.map +1 -0
  393. package/dist/TxPubSub.js +521 -0
  394. package/dist/TxPubSub.js.map +1 -0
  395. package/dist/TxQueue.d.ts +1 -1
  396. package/dist/TxQueue.d.ts.map +1 -1
  397. package/dist/TxQueue.js +42 -57
  398. package/dist/TxQueue.js.map +1 -1
  399. package/dist/TxReentrantLock.d.ts +500 -0
  400. package/dist/TxReentrantLock.d.ts.map +1 -0
  401. package/dist/TxReentrantLock.js +481 -0
  402. package/dist/TxReentrantLock.js.map +1 -0
  403. package/dist/TxRef.d.ts +14 -20
  404. package/dist/TxRef.d.ts.map +1 -1
  405. package/dist/TxRef.js +8 -10
  406. package/dist/TxRef.js.map +1 -1
  407. package/dist/TxSemaphore.d.ts +162 -2
  408. package/dist/TxSemaphore.d.ts.map +1 -1
  409. package/dist/TxSemaphore.js +25 -10
  410. package/dist/TxSemaphore.js.map +1 -1
  411. package/dist/TxSubscriptionRef.d.ts +508 -0
  412. package/dist/TxSubscriptionRef.d.ts.map +1 -0
  413. package/dist/TxSubscriptionRef.js +293 -0
  414. package/dist/TxSubscriptionRef.js.map +1 -0
  415. package/dist/Types.d.ts +83 -17
  416. package/dist/Types.d.ts.map +1 -1
  417. package/dist/Unify.d.ts +8 -2
  418. package/dist/Unify.d.ts.map +1 -1
  419. package/dist/Unify.js.map +1 -1
  420. package/dist/Utils.d.ts +137 -65
  421. package/dist/Utils.d.ts.map +1 -1
  422. package/dist/Utils.js +38 -66
  423. package/dist/Utils.js.map +1 -1
  424. package/dist/index.d.ts +888 -71
  425. package/dist/index.d.ts.map +1 -1
  426. package/dist/index.js +888 -71
  427. package/dist/index.js.map +1 -1
  428. package/dist/internal/core.js +11 -3
  429. package/dist/internal/core.js.map +1 -1
  430. package/dist/internal/dateTime.js +77 -71
  431. package/dist/internal/dateTime.js.map +1 -1
  432. package/dist/internal/effect.js +485 -325
  433. package/dist/internal/effect.js.map +1 -1
  434. package/dist/internal/hashMap.js +7 -5
  435. package/dist/internal/hashMap.js.map +1 -1
  436. package/dist/internal/layer.js +3 -3
  437. package/dist/internal/layer.js.map +1 -1
  438. package/dist/internal/option.js +6 -0
  439. package/dist/internal/option.js.map +1 -1
  440. package/dist/internal/random.d.ts +2 -0
  441. package/dist/internal/random.d.ts.map +1 -0
  442. package/dist/internal/random.js +13 -0
  443. package/dist/internal/random.js.map +1 -0
  444. package/dist/internal/rcRef.js +11 -10
  445. package/dist/internal/rcRef.js.map +1 -1
  446. package/dist/internal/references.d.ts +2 -0
  447. package/dist/internal/references.d.ts.map +1 -0
  448. package/dist/internal/references.js +51 -0
  449. package/dist/internal/references.js.map +1 -0
  450. package/dist/internal/request.js +6 -6
  451. package/dist/internal/request.js.map +1 -1
  452. package/dist/internal/schedule.js +1 -1
  453. package/dist/internal/schedule.js.map +1 -1
  454. package/dist/internal/schema/annotations.js +2 -0
  455. package/dist/internal/schema/annotations.js.map +1 -1
  456. package/dist/internal/schema/representation.js +86 -107
  457. package/dist/internal/schema/representation.js.map +1 -1
  458. package/dist/internal/schema/schema.d.ts +10 -1
  459. package/dist/internal/schema/schema.d.ts.map +1 -1
  460. package/dist/internal/schema/schema.js +22 -1
  461. package/dist/internal/schema/schema.js.map +1 -1
  462. package/dist/internal/schema/to-codec.js +7 -10
  463. package/dist/internal/schema/to-codec.js.map +1 -1
  464. package/dist/internal/trie.js +8 -7
  465. package/dist/internal/trie.js.map +1 -1
  466. package/dist/testing/TestClock.d.ts +8 -7
  467. package/dist/testing/TestClock.d.ts.map +1 -1
  468. package/dist/testing/TestClock.js +6 -4
  469. package/dist/testing/TestClock.js.map +1 -1
  470. package/dist/testing/TestSchema.d.ts +267 -33
  471. package/dist/testing/TestSchema.d.ts.map +1 -1
  472. package/dist/testing/TestSchema.js +296 -23
  473. package/dist/testing/TestSchema.js.map +1 -1
  474. package/dist/testing/index.d.ts +64 -1
  475. package/dist/testing/index.d.ts.map +1 -1
  476. package/dist/testing/index.js +64 -1
  477. package/dist/testing/index.js.map +1 -1
  478. package/dist/unstable/ai/AiError.d.ts +155 -73
  479. package/dist/unstable/ai/AiError.d.ts.map +1 -1
  480. package/dist/unstable/ai/AiError.js +29 -23
  481. package/dist/unstable/ai/AiError.js.map +1 -1
  482. package/dist/unstable/ai/AnthropicStructuredOutput.d.ts +1 -1
  483. package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
  484. package/dist/unstable/ai/AnthropicStructuredOutput.js +9 -2
  485. package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
  486. package/dist/unstable/ai/Chat.d.ts +39 -11
  487. package/dist/unstable/ai/Chat.d.ts.map +1 -1
  488. package/dist/unstable/ai/Chat.js +41 -47
  489. package/dist/unstable/ai/Chat.js.map +1 -1
  490. package/dist/unstable/ai/EmbeddingModel.d.ts +130 -0
  491. package/dist/unstable/ai/EmbeddingModel.d.ts.map +1 -0
  492. package/dist/unstable/ai/EmbeddingModel.js +127 -0
  493. package/dist/unstable/ai/EmbeddingModel.js.map +1 -0
  494. package/dist/unstable/ai/IdGenerator.d.ts +2 -2
  495. package/dist/unstable/ai/IdGenerator.d.ts.map +1 -1
  496. package/dist/unstable/ai/IdGenerator.js +2 -2
  497. package/dist/unstable/ai/IdGenerator.js.map +1 -1
  498. package/dist/unstable/ai/LanguageModel.d.ts +119 -49
  499. package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
  500. package/dist/unstable/ai/LanguageModel.js +260 -61
  501. package/dist/unstable/ai/LanguageModel.js.map +1 -1
  502. package/dist/unstable/ai/McpSchema.d.ts +236 -141
  503. package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
  504. package/dist/unstable/ai/McpSchema.js +71 -19
  505. package/dist/unstable/ai/McpSchema.js.map +1 -1
  506. package/dist/unstable/ai/McpServer.d.ts +68 -15
  507. package/dist/unstable/ai/McpServer.d.ts.map +1 -1
  508. package/dist/unstable/ai/McpServer.js +218 -73
  509. package/dist/unstable/ai/McpServer.js.map +1 -1
  510. package/dist/unstable/ai/Model.d.ts +27 -9
  511. package/dist/unstable/ai/Model.d.ts.map +1 -1
  512. package/dist/unstable/ai/Model.js +25 -9
  513. package/dist/unstable/ai/Model.js.map +1 -1
  514. package/dist/unstable/ai/OpenAiStructuredOutput.d.ts +1 -1
  515. package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
  516. package/dist/unstable/ai/OpenAiStructuredOutput.js +9 -1
  517. package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
  518. package/dist/unstable/ai/Prompt.d.ts +20 -20
  519. package/dist/unstable/ai/Prompt.d.ts.map +1 -1
  520. package/dist/unstable/ai/Prompt.js +6 -9
  521. package/dist/unstable/ai/Prompt.js.map +1 -1
  522. package/dist/unstable/ai/Response.d.ts +27 -27
  523. package/dist/unstable/ai/Response.d.ts.map +1 -1
  524. package/dist/unstable/ai/Response.js +7 -8
  525. package/dist/unstable/ai/Response.js.map +1 -1
  526. package/dist/unstable/ai/ResponseIdTracker.d.ts +38 -0
  527. package/dist/unstable/ai/ResponseIdTracker.d.ts.map +1 -0
  528. package/dist/unstable/ai/ResponseIdTracker.js +68 -0
  529. package/dist/unstable/ai/ResponseIdTracker.js.map +1 -0
  530. package/dist/unstable/ai/Telemetry.d.ts +35 -2
  531. package/dist/unstable/ai/Telemetry.d.ts.map +1 -1
  532. package/dist/unstable/ai/Telemetry.js +2 -2
  533. package/dist/unstable/ai/Telemetry.js.map +1 -1
  534. package/dist/unstable/ai/Tokenizer.d.ts +2 -2
  535. package/dist/unstable/ai/Tokenizer.d.ts.map +1 -1
  536. package/dist/unstable/ai/Tokenizer.js +2 -2
  537. package/dist/unstable/ai/Tokenizer.js.map +1 -1
  538. package/dist/unstable/ai/Tool.d.ts +46 -16
  539. package/dist/unstable/ai/Tool.d.ts.map +1 -1
  540. package/dist/unstable/ai/Tool.js +68 -22
  541. package/dist/unstable/ai/Tool.js.map +1 -1
  542. package/dist/unstable/ai/Toolkit.d.ts +4 -4
  543. package/dist/unstable/ai/Toolkit.d.ts.map +1 -1
  544. package/dist/unstable/ai/Toolkit.js +14 -21
  545. package/dist/unstable/ai/Toolkit.js.map +1 -1
  546. package/dist/unstable/ai/index.d.ts +22 -1
  547. package/dist/unstable/ai/index.d.ts.map +1 -1
  548. package/dist/unstable/ai/index.js +22 -1
  549. package/dist/unstable/ai/index.js.map +1 -1
  550. package/dist/unstable/ai/internal/codec-transformer.js +5 -7
  551. package/dist/unstable/ai/internal/codec-transformer.js.map +1 -1
  552. package/dist/unstable/cli/Argument.d.ts +4 -7
  553. package/dist/unstable/cli/Argument.d.ts.map +1 -1
  554. package/dist/unstable/cli/Argument.js +1 -3
  555. package/dist/unstable/cli/Argument.js.map +1 -1
  556. package/dist/unstable/cli/CliError.d.ts +55 -67
  557. package/dist/unstable/cli/CliError.d.ts.map +1 -1
  558. package/dist/unstable/cli/CliError.js +32 -57
  559. package/dist/unstable/cli/CliError.js.map +1 -1
  560. package/dist/unstable/cli/CliOutput.d.ts +5 -4
  561. package/dist/unstable/cli/CliOutput.d.ts.map +1 -1
  562. package/dist/unstable/cli/CliOutput.js +67 -12
  563. package/dist/unstable/cli/CliOutput.js.map +1 -1
  564. package/dist/unstable/cli/Command.d.ts +372 -59
  565. package/dist/unstable/cli/Command.d.ts.map +1 -1
  566. package/dist/unstable/cli/Command.js +328 -66
  567. package/dist/unstable/cli/Command.js.map +1 -1
  568. package/dist/unstable/cli/Completions.d.ts +97 -0
  569. package/dist/unstable/cli/Completions.d.ts.map +1 -0
  570. package/dist/unstable/cli/Completions.js +25 -0
  571. package/dist/unstable/cli/Completions.js.map +1 -0
  572. package/dist/unstable/cli/Flag.d.ts +4 -5
  573. package/dist/unstable/cli/Flag.d.ts.map +1 -1
  574. package/dist/unstable/cli/Flag.js +1 -1
  575. package/dist/unstable/cli/Flag.js.map +1 -1
  576. package/dist/unstable/cli/GlobalFlag.d.ts +125 -0
  577. package/dist/unstable/cli/GlobalFlag.d.ts.map +1 -0
  578. package/dist/unstable/cli/GlobalFlag.js +118 -0
  579. package/dist/unstable/cli/GlobalFlag.js.map +1 -0
  580. package/dist/unstable/cli/HelpDoc.d.ts +81 -11
  581. package/dist/unstable/cli/HelpDoc.d.ts.map +1 -1
  582. package/dist/unstable/cli/Param.d.ts +34 -6
  583. package/dist/unstable/cli/Param.d.ts.map +1 -1
  584. package/dist/unstable/cli/Param.js +24 -14
  585. package/dist/unstable/cli/Param.js.map +1 -1
  586. package/dist/unstable/cli/Primitive.d.ts +2 -2
  587. package/dist/unstable/cli/Primitive.d.ts.map +1 -1
  588. package/dist/unstable/cli/Primitive.js +1 -1
  589. package/dist/unstable/cli/Primitive.js.map +1 -1
  590. package/dist/unstable/cli/Prompt.js +266 -86
  591. package/dist/unstable/cli/Prompt.js.map +1 -1
  592. package/dist/unstable/cli/index.d.ts +8 -0
  593. package/dist/unstable/cli/index.d.ts.map +1 -1
  594. package/dist/unstable/cli/index.js +8 -0
  595. package/dist/unstable/cli/index.js.map +1 -1
  596. package/dist/unstable/cli/internal/command.d.ts +41 -15
  597. package/dist/unstable/cli/internal/command.d.ts.map +1 -1
  598. package/dist/unstable/cli/internal/command.js +84 -47
  599. package/dist/unstable/cli/internal/command.js.map +1 -1
  600. package/dist/unstable/cli/internal/completions/bash.js.map +1 -1
  601. package/dist/unstable/cli/internal/completions/descriptor.d.ts +2 -0
  602. package/dist/unstable/cli/internal/completions/descriptor.d.ts.map +1 -0
  603. package/dist/unstable/cli/internal/completions/{CommandDescriptor.js → descriptor.js} +17 -5
  604. package/dist/unstable/cli/internal/completions/descriptor.js.map +1 -0
  605. package/dist/unstable/cli/internal/completions/fish.js.map +1 -1
  606. package/dist/unstable/cli/internal/completions/zsh.js.map +1 -1
  607. package/dist/unstable/cli/internal/config.js +42 -0
  608. package/dist/unstable/cli/internal/config.js.map +1 -1
  609. package/dist/unstable/cli/internal/help.d.ts +33 -0
  610. package/dist/unstable/cli/internal/help.d.ts.map +1 -0
  611. package/dist/unstable/cli/internal/help.js +125 -0
  612. package/dist/unstable/cli/internal/help.js.map +1 -0
  613. package/dist/unstable/cli/internal/parser.js +155 -58
  614. package/dist/unstable/cli/internal/parser.js.map +1 -1
  615. package/dist/unstable/cluster/ClusterCron.d.ts +1 -1
  616. package/dist/unstable/cluster/ClusterCron.d.ts.map +1 -1
  617. package/dist/unstable/cluster/ClusterCron.js +1 -1
  618. package/dist/unstable/cluster/ClusterCron.js.map +1 -1
  619. package/dist/unstable/cluster/ClusterError.d.ts +7 -7
  620. package/dist/unstable/cluster/ClusterSchema.d.ts +28 -7
  621. package/dist/unstable/cluster/ClusterSchema.d.ts.map +1 -1
  622. package/dist/unstable/cluster/ClusterSchema.js +28 -8
  623. package/dist/unstable/cluster/ClusterSchema.js.map +1 -1
  624. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts +4 -2
  625. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
  626. package/dist/unstable/cluster/ClusterWorkflowEngine.js +97 -63
  627. package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
  628. package/dist/unstable/cluster/DeliverAt.js +1 -1
  629. package/dist/unstable/cluster/DeliverAt.js.map +1 -1
  630. package/dist/unstable/cluster/Entity.d.ts +18 -16
  631. package/dist/unstable/cluster/Entity.d.ts.map +1 -1
  632. package/dist/unstable/cluster/Entity.js +31 -25
  633. package/dist/unstable/cluster/Entity.js.map +1 -1
  634. package/dist/unstable/cluster/EntityAddress.d.ts +2 -2
  635. package/dist/unstable/cluster/EntityAddress.d.ts.map +1 -1
  636. package/dist/unstable/cluster/EntityAddress.js +1 -1
  637. package/dist/unstable/cluster/EntityAddress.js.map +1 -1
  638. package/dist/unstable/cluster/EntityProxy.js +3 -3
  639. package/dist/unstable/cluster/EntityProxy.js.map +1 -1
  640. package/dist/unstable/cluster/EntityProxyServer.d.ts.map +1 -1
  641. package/dist/unstable/cluster/EntityProxyServer.js +4 -4
  642. package/dist/unstable/cluster/EntityProxyServer.js.map +1 -1
  643. package/dist/unstable/cluster/EntityResource.d.ts +4 -4
  644. package/dist/unstable/cluster/EntityResource.d.ts.map +1 -1
  645. package/dist/unstable/cluster/EntityResource.js +2 -2
  646. package/dist/unstable/cluster/EntityResource.js.map +1 -1
  647. package/dist/unstable/cluster/Envelope.d.ts +4 -4
  648. package/dist/unstable/cluster/HttpRunner.js +2 -2
  649. package/dist/unstable/cluster/HttpRunner.js.map +1 -1
  650. package/dist/unstable/cluster/K8sHttpClient.d.ts +5 -5
  651. package/dist/unstable/cluster/K8sHttpClient.d.ts.map +1 -1
  652. package/dist/unstable/cluster/K8sHttpClient.js +6 -6
  653. package/dist/unstable/cluster/K8sHttpClient.js.map +1 -1
  654. package/dist/unstable/cluster/Message.d.ts +21 -15
  655. package/dist/unstable/cluster/Message.d.ts.map +1 -1
  656. package/dist/unstable/cluster/Message.js +16 -8
  657. package/dist/unstable/cluster/Message.js.map +1 -1
  658. package/dist/unstable/cluster/MessageStorage.d.ts +46 -23
  659. package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
  660. package/dist/unstable/cluster/MessageStorage.js +42 -26
  661. package/dist/unstable/cluster/MessageStorage.js.map +1 -1
  662. package/dist/unstable/cluster/Reply.d.ts +10 -9
  663. package/dist/unstable/cluster/Reply.d.ts.map +1 -1
  664. package/dist/unstable/cluster/Reply.js +8 -7
  665. package/dist/unstable/cluster/Reply.js.map +1 -1
  666. package/dist/unstable/cluster/Runner.d.ts +2 -2
  667. package/dist/unstable/cluster/Runner.d.ts.map +1 -1
  668. package/dist/unstable/cluster/Runner.js +1 -1
  669. package/dist/unstable/cluster/Runner.js.map +1 -1
  670. package/dist/unstable/cluster/RunnerAddress.d.ts +1 -1
  671. package/dist/unstable/cluster/RunnerAddress.d.ts.map +1 -1
  672. package/dist/unstable/cluster/RunnerAddress.js +1 -1
  673. package/dist/unstable/cluster/RunnerAddress.js.map +1 -1
  674. package/dist/unstable/cluster/RunnerHealth.d.ts +2 -2
  675. package/dist/unstable/cluster/RunnerHealth.d.ts.map +1 -1
  676. package/dist/unstable/cluster/RunnerHealth.js +2 -2
  677. package/dist/unstable/cluster/RunnerHealth.js.map +1 -1
  678. package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
  679. package/dist/unstable/cluster/RunnerServer.js +10 -9
  680. package/dist/unstable/cluster/RunnerServer.js.map +1 -1
  681. package/dist/unstable/cluster/RunnerStorage.d.ts +12 -12
  682. package/dist/unstable/cluster/RunnerStorage.d.ts.map +1 -1
  683. package/dist/unstable/cluster/RunnerStorage.js +3 -3
  684. package/dist/unstable/cluster/RunnerStorage.js.map +1 -1
  685. package/dist/unstable/cluster/Runners.d.ts +5 -4
  686. package/dist/unstable/cluster/Runners.d.ts.map +1 -1
  687. package/dist/unstable/cluster/Runners.js +20 -17
  688. package/dist/unstable/cluster/Runners.js.map +1 -1
  689. package/dist/unstable/cluster/ShardId.d.ts +35 -49
  690. package/dist/unstable/cluster/ShardId.d.ts.map +1 -1
  691. package/dist/unstable/cluster/ShardId.js +65 -67
  692. package/dist/unstable/cluster/ShardId.js.map +1 -1
  693. package/dist/unstable/cluster/Sharding.d.ts +4 -4
  694. package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
  695. package/dist/unstable/cluster/Sharding.js +66 -54
  696. package/dist/unstable/cluster/Sharding.js.map +1 -1
  697. package/dist/unstable/cluster/ShardingConfig.d.ts +28 -27
  698. package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
  699. package/dist/unstable/cluster/ShardingConfig.js +27 -27
  700. package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
  701. package/dist/unstable/cluster/SingletonAddress.d.ts +2 -2
  702. package/dist/unstable/cluster/Snowflake.d.ts +2 -2
  703. package/dist/unstable/cluster/Snowflake.d.ts.map +1 -1
  704. package/dist/unstable/cluster/Snowflake.js +2 -2
  705. package/dist/unstable/cluster/Snowflake.js.map +1 -1
  706. package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
  707. package/dist/unstable/cluster/SqlMessageStorage.js +24 -20
  708. package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
  709. package/dist/unstable/cluster/SqlRunnerStorage.d.ts.map +1 -1
  710. package/dist/unstable/cluster/SqlRunnerStorage.js +7 -7
  711. package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
  712. package/dist/unstable/cluster/internal/entityManager.js +34 -27
  713. package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
  714. package/dist/unstable/cluster/internal/entityReaper.js +4 -3
  715. package/dist/unstable/cluster/internal/entityReaper.js.map +1 -1
  716. package/dist/unstable/cluster/internal/resourceMap.js +3 -3
  717. package/dist/unstable/cluster/internal/resourceMap.js.map +1 -1
  718. package/dist/unstable/cluster/internal/resourceRef.js +2 -1
  719. package/dist/unstable/cluster/internal/resourceRef.js.map +1 -1
  720. package/dist/unstable/devtools/DevToolsClient.d.ts +2 -2
  721. package/dist/unstable/devtools/DevToolsClient.d.ts.map +1 -1
  722. package/dist/unstable/devtools/DevToolsClient.js +9 -8
  723. package/dist/unstable/devtools/DevToolsClient.js.map +1 -1
  724. package/dist/unstable/devtools/DevToolsSchema.d.ts +40 -40
  725. package/dist/unstable/devtools/DevToolsSchema.d.ts.map +1 -1
  726. package/dist/unstable/devtools/DevToolsSchema.js +9 -2
  727. package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
  728. package/dist/unstable/encoding/Msgpack.d.ts +1 -1
  729. package/dist/unstable/encoding/Ndjson.d.ts +9 -9
  730. package/dist/unstable/encoding/Ndjson.d.ts.map +1 -1
  731. package/dist/unstable/encoding/Ndjson.js.map +1 -1
  732. package/dist/unstable/encoding/Sse.d.ts +4 -4
  733. package/dist/unstable/encoding/Sse.d.ts.map +1 -1
  734. package/dist/unstable/encoding/Sse.js +1 -1
  735. package/dist/unstable/encoding/Sse.js.map +1 -1
  736. package/dist/unstable/eventlog/Event.d.ts +0 -6
  737. package/dist/unstable/eventlog/Event.d.ts.map +1 -1
  738. package/dist/unstable/eventlog/Event.js +0 -5
  739. package/dist/unstable/eventlog/Event.js.map +1 -1
  740. package/dist/unstable/eventlog/EventGroup.d.ts +0 -2
  741. package/dist/unstable/eventlog/EventGroup.d.ts.map +1 -1
  742. package/dist/unstable/eventlog/EventGroup.js +0 -2
  743. package/dist/unstable/eventlog/EventGroup.js.map +1 -1
  744. package/dist/unstable/eventlog/EventJournal.d.ts +28 -11
  745. package/dist/unstable/eventlog/EventJournal.d.ts.map +1 -1
  746. package/dist/unstable/eventlog/EventJournal.js +130 -71
  747. package/dist/unstable/eventlog/EventJournal.js.map +1 -1
  748. package/dist/unstable/eventlog/EventLog.d.ts +94 -37
  749. package/dist/unstable/eventlog/EventLog.d.ts.map +1 -1
  750. package/dist/unstable/eventlog/EventLog.js +225 -150
  751. package/dist/unstable/eventlog/EventLog.js.map +1 -1
  752. package/dist/unstable/eventlog/EventLogEncryption.d.ts +11 -9
  753. package/dist/unstable/eventlog/EventLogEncryption.d.ts.map +1 -1
  754. package/dist/unstable/eventlog/EventLogEncryption.js +15 -17
  755. package/dist/unstable/eventlog/EventLogEncryption.js.map +1 -1
  756. package/dist/unstable/eventlog/EventLogMessage.d.ts +228 -0
  757. package/dist/unstable/eventlog/EventLogMessage.d.ts.map +1 -0
  758. package/dist/unstable/eventlog/EventLogMessage.js +214 -0
  759. package/dist/unstable/eventlog/EventLogMessage.js.map +1 -0
  760. package/dist/unstable/eventlog/EventLogRemote.d.ts +112 -194
  761. package/dist/unstable/eventlog/EventLogRemote.d.ts.map +1 -1
  762. package/dist/unstable/eventlog/EventLogRemote.js +168 -322
  763. package/dist/unstable/eventlog/EventLogRemote.js.map +1 -1
  764. package/dist/unstable/eventlog/EventLogServer.d.ts +26 -48
  765. package/dist/unstable/eventlog/EventLogServer.d.ts.map +1 -1
  766. package/dist/unstable/eventlog/EventLogServer.js +128 -199
  767. package/dist/unstable/eventlog/EventLogServer.js.map +1 -1
  768. package/dist/unstable/eventlog/EventLogServerEncrypted.d.ts +60 -0
  769. package/dist/unstable/eventlog/EventLogServerEncrypted.d.ts.map +1 -0
  770. package/dist/unstable/eventlog/EventLogServerEncrypted.js +166 -0
  771. package/dist/unstable/eventlog/EventLogServerEncrypted.js.map +1 -0
  772. package/dist/unstable/eventlog/EventLogServerUnencrypted.d.ts +183 -0
  773. package/dist/unstable/eventlog/EventLogServerUnencrypted.d.ts.map +1 -0
  774. package/dist/unstable/eventlog/EventLogServerUnencrypted.js +461 -0
  775. package/dist/unstable/eventlog/EventLogServerUnencrypted.js.map +1 -0
  776. package/dist/unstable/eventlog/EventLogSessionAuth.d.ts +117 -0
  777. package/dist/unstable/eventlog/EventLogSessionAuth.d.ts.map +1 -0
  778. package/dist/unstable/eventlog/EventLogSessionAuth.js +284 -0
  779. package/dist/unstable/eventlog/EventLogSessionAuth.js.map +1 -0
  780. package/dist/unstable/eventlog/{SqlEventLogJournal.d.ts → SqlEventJournal.d.ts} +2 -2
  781. package/dist/unstable/eventlog/SqlEventJournal.d.ts.map +1 -0
  782. package/dist/unstable/eventlog/{SqlEventLogJournal.js → SqlEventJournal.js} +28 -21
  783. package/dist/unstable/eventlog/SqlEventJournal.js.map +1 -0
  784. package/dist/unstable/eventlog/{SqlEventLogServer.d.ts → SqlEventLogServerEncrypted.d.ts} +5 -5
  785. package/dist/unstable/eventlog/SqlEventLogServerEncrypted.d.ts.map +1 -0
  786. package/dist/unstable/eventlog/{SqlEventLogServer.js → SqlEventLogServerEncrypted.js} +69 -27
  787. package/dist/unstable/eventlog/SqlEventLogServerEncrypted.js.map +1 -0
  788. package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.d.ts +25 -0
  789. package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.d.ts.map +1 -0
  790. package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js +355 -0
  791. package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js.map +1 -0
  792. package/dist/unstable/eventlog/index.d.ts +22 -2
  793. package/dist/unstable/eventlog/index.d.ts.map +1 -1
  794. package/dist/unstable/eventlog/index.js +22 -2
  795. package/dist/unstable/eventlog/index.js.map +1 -1
  796. package/dist/unstable/eventlog/internal/identityRootSecretDerivation.d.ts +2 -0
  797. package/dist/unstable/eventlog/internal/identityRootSecretDerivation.d.ts.map +1 -0
  798. package/dist/unstable/eventlog/internal/identityRootSecretDerivation.js +89 -0
  799. package/dist/unstable/eventlog/internal/identityRootSecretDerivation.js.map +1 -0
  800. package/dist/unstable/http/Cookies.d.ts +52 -7
  801. package/dist/unstable/http/Cookies.d.ts.map +1 -1
  802. package/dist/unstable/http/Cookies.js +27 -6
  803. package/dist/unstable/http/Cookies.js.map +1 -1
  804. package/dist/unstable/http/Etag.d.ts +2 -2
  805. package/dist/unstable/http/Etag.d.ts.map +1 -1
  806. package/dist/unstable/http/Etag.js +7 -3
  807. package/dist/unstable/http/Etag.js.map +1 -1
  808. package/dist/unstable/http/FetchHttpClient.d.ts +6 -3
  809. package/dist/unstable/http/FetchHttpClient.d.ts.map +1 -1
  810. package/dist/unstable/http/FetchHttpClient.js +5 -5
  811. package/dist/unstable/http/FetchHttpClient.js.map +1 -1
  812. package/dist/unstable/http/Headers.d.ts +24 -4
  813. package/dist/unstable/http/Headers.d.ts.map +1 -1
  814. package/dist/unstable/http/Headers.js +42 -13
  815. package/dist/unstable/http/Headers.js.map +1 -1
  816. package/dist/unstable/http/HttpBody.d.ts +1 -1
  817. package/dist/unstable/http/HttpClient.d.ts +125 -21
  818. package/dist/unstable/http/HttpClient.d.ts.map +1 -1
  819. package/dist/unstable/http/HttpClient.js +197 -19
  820. package/dist/unstable/http/HttpClient.js.map +1 -1
  821. package/dist/unstable/http/HttpClientError.d.ts +8 -8
  822. package/dist/unstable/http/HttpClientRequest.d.ts +43 -15
  823. package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
  824. package/dist/unstable/http/HttpClientRequest.js +131 -21
  825. package/dist/unstable/http/HttpClientRequest.js.map +1 -1
  826. package/dist/unstable/http/HttpClientResponse.d.ts +2 -1
  827. package/dist/unstable/http/HttpClientResponse.d.ts.map +1 -1
  828. package/dist/unstable/http/HttpClientResponse.js +6 -1
  829. package/dist/unstable/http/HttpClientResponse.js.map +1 -1
  830. package/dist/unstable/http/HttpEffect.d.ts +13 -11
  831. package/dist/unstable/http/HttpEffect.d.ts.map +1 -1
  832. package/dist/unstable/http/HttpEffect.js +67 -75
  833. package/dist/unstable/http/HttpEffect.js.map +1 -1
  834. package/dist/unstable/http/HttpIncomingMessage.d.ts +5 -4
  835. package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
  836. package/dist/unstable/http/HttpIncomingMessage.js +2 -2
  837. package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
  838. package/dist/unstable/http/HttpMethod.d.ts +4 -4
  839. package/dist/unstable/http/HttpMethod.d.ts.map +1 -1
  840. package/dist/unstable/http/HttpMethod.js +3 -3
  841. package/dist/unstable/http/HttpMethod.js.map +1 -1
  842. package/dist/unstable/http/HttpMiddleware.d.ts +4 -9
  843. package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
  844. package/dist/unstable/http/HttpMiddleware.js +47 -43
  845. package/dist/unstable/http/HttpMiddleware.js.map +1 -1
  846. package/dist/unstable/http/HttpPlatform.d.ts +2 -2
  847. package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
  848. package/dist/unstable/http/HttpPlatform.js +5 -4
  849. package/dist/unstable/http/HttpPlatform.js.map +1 -1
  850. package/dist/unstable/http/HttpRouter.d.ts +9 -8
  851. package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
  852. package/dist/unstable/http/HttpRouter.js +36 -36
  853. package/dist/unstable/http/HttpRouter.js.map +1 -1
  854. package/dist/unstable/http/HttpServer.d.ts +2 -2
  855. package/dist/unstable/http/HttpServer.d.ts.map +1 -1
  856. package/dist/unstable/http/HttpServer.js +4 -4
  857. package/dist/unstable/http/HttpServer.js.map +1 -1
  858. package/dist/unstable/http/HttpServerError.d.ts +22 -34
  859. package/dist/unstable/http/HttpServerError.d.ts.map +1 -1
  860. package/dist/unstable/http/HttpServerError.js +39 -45
  861. package/dist/unstable/http/HttpServerError.js.map +1 -1
  862. package/dist/unstable/http/HttpServerRequest.d.ts +19 -7
  863. package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
  864. package/dist/unstable/http/HttpServerRequest.js +307 -13
  865. package/dist/unstable/http/HttpServerRequest.js.map +1 -1
  866. package/dist/unstable/http/HttpServerRespondable.d.ts +2 -2
  867. package/dist/unstable/http/HttpServerRespondable.d.ts.map +1 -1
  868. package/dist/unstable/http/HttpServerRespondable.js +5 -5
  869. package/dist/unstable/http/HttpServerRespondable.js.map +1 -1
  870. package/dist/unstable/http/HttpServerResponse.d.ts +52 -5
  871. package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
  872. package/dist/unstable/http/HttpServerResponse.js +240 -5
  873. package/dist/unstable/http/HttpServerResponse.js.map +1 -1
  874. package/dist/unstable/http/HttpStaticServer.d.ts +69 -0
  875. package/dist/unstable/http/HttpStaticServer.d.ts.map +1 -0
  876. package/dist/unstable/http/HttpStaticServer.js +353 -0
  877. package/dist/unstable/http/HttpStaticServer.js.map +1 -0
  878. package/dist/unstable/http/HttpTraceContext.d.ts +3 -2
  879. package/dist/unstable/http/HttpTraceContext.d.ts.map +1 -1
  880. package/dist/unstable/http/HttpTraceContext.js +27 -15
  881. package/dist/unstable/http/HttpTraceContext.js.map +1 -1
  882. package/dist/unstable/http/Multipart.d.ts +9 -9
  883. package/dist/unstable/http/Multipart.d.ts.map +1 -1
  884. package/dist/unstable/http/Multipart.js +7 -7
  885. package/dist/unstable/http/Multipart.js.map +1 -1
  886. package/dist/unstable/http/Url.d.ts +604 -0
  887. package/dist/unstable/http/Url.d.ts.map +1 -0
  888. package/dist/unstable/http/Url.js +256 -0
  889. package/dist/unstable/http/Url.js.map +1 -0
  890. package/dist/unstable/http/UrlParams.d.ts +19 -10
  891. package/dist/unstable/http/UrlParams.d.ts.map +1 -1
  892. package/dist/unstable/http/UrlParams.js +6 -7
  893. package/dist/unstable/http/UrlParams.js.map +1 -1
  894. package/dist/unstable/http/index.d.ts +8 -0
  895. package/dist/unstable/http/index.d.ts.map +1 -1
  896. package/dist/unstable/http/index.js +8 -0
  897. package/dist/unstable/http/index.js.map +1 -1
  898. package/dist/unstable/http/internal/preResponseHandler.d.ts +2 -0
  899. package/dist/unstable/http/internal/preResponseHandler.d.ts.map +1 -0
  900. package/dist/unstable/http/internal/preResponseHandler.js +10 -0
  901. package/dist/unstable/http/internal/preResponseHandler.js.map +1 -0
  902. package/dist/unstable/httpapi/HttpApi.d.ts +11 -11
  903. package/dist/unstable/httpapi/HttpApi.d.ts.map +1 -1
  904. package/dist/unstable/httpapi/HttpApi.js +8 -8
  905. package/dist/unstable/httpapi/HttpApi.js.map +1 -1
  906. package/dist/unstable/httpapi/HttpApiBuilder.d.ts +12 -9
  907. package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
  908. package/dist/unstable/httpapi/HttpApiBuilder.js +53 -39
  909. package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
  910. package/dist/unstable/httpapi/HttpApiClient.d.ts +83 -7
  911. package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
  912. package/dist/unstable/httpapi/HttpApiClient.js +79 -11
  913. package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
  914. package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +211 -105
  915. package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
  916. package/dist/unstable/httpapi/HttpApiEndpoint.js +53 -47
  917. package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
  918. package/dist/unstable/httpapi/HttpApiError.d.ts +43 -26
  919. package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
  920. package/dist/unstable/httpapi/HttpApiError.js +125 -32
  921. package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
  922. package/dist/unstable/httpapi/HttpApiGroup.d.ts +9 -8
  923. package/dist/unstable/httpapi/HttpApiGroup.d.ts.map +1 -1
  924. package/dist/unstable/httpapi/HttpApiGroup.js +4 -4
  925. package/dist/unstable/httpapi/HttpApiGroup.js.map +1 -1
  926. package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +49 -18
  927. package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
  928. package/dist/unstable/httpapi/HttpApiMiddleware.js +38 -8
  929. package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
  930. package/dist/unstable/httpapi/HttpApiScalar.d.ts +6 -0
  931. package/dist/unstable/httpapi/HttpApiScalar.d.ts.map +1 -1
  932. package/dist/unstable/httpapi/HttpApiScalar.js.map +1 -1
  933. package/dist/unstable/httpapi/HttpApiSchema.d.ts +88 -9
  934. package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
  935. package/dist/unstable/httpapi/HttpApiSchema.js +86 -11
  936. package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
  937. package/dist/unstable/httpapi/HttpApiSecurity.d.ts +9 -6
  938. package/dist/unstable/httpapi/HttpApiSecurity.d.ts.map +1 -1
  939. package/dist/unstable/httpapi/HttpApiSecurity.js +6 -6
  940. package/dist/unstable/httpapi/HttpApiSecurity.js.map +1 -1
  941. package/dist/unstable/httpapi/OpenApi.d.ts +17 -25
  942. package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
  943. package/dist/unstable/httpapi/OpenApi.js +59 -60
  944. package/dist/unstable/httpapi/OpenApi.js.map +1 -1
  945. package/dist/unstable/observability/Otlp.d.ts +12 -12
  946. package/dist/unstable/observability/Otlp.d.ts.map +1 -1
  947. package/dist/unstable/observability/OtlpExporter.d.ts +2 -2
  948. package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
  949. package/dist/unstable/observability/OtlpExporter.js +8 -8
  950. package/dist/unstable/observability/OtlpExporter.js.map +1 -1
  951. package/dist/unstable/observability/OtlpLogger.d.ts +4 -4
  952. package/dist/unstable/observability/OtlpLogger.d.ts.map +1 -1
  953. package/dist/unstable/observability/OtlpLogger.js +7 -4
  954. package/dist/unstable/observability/OtlpLogger.js.map +1 -1
  955. package/dist/unstable/observability/OtlpMetrics.d.ts +4 -4
  956. package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
  957. package/dist/unstable/observability/OtlpMetrics.js +2 -2
  958. package/dist/unstable/observability/OtlpMetrics.js.map +1 -1
  959. package/dist/unstable/observability/OtlpSerialization.d.ts +2 -2
  960. package/dist/unstable/observability/OtlpSerialization.d.ts.map +1 -1
  961. package/dist/unstable/observability/OtlpSerialization.js +2 -2
  962. package/dist/unstable/observability/OtlpSerialization.js.map +1 -1
  963. package/dist/unstable/observability/OtlpTracer.d.ts +4 -4
  964. package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
  965. package/dist/unstable/observability/OtlpTracer.js +7 -3
  966. package/dist/unstable/observability/OtlpTracer.js.map +1 -1
  967. package/dist/unstable/observability/PrometheusMetrics.d.ts +3 -3
  968. package/dist/unstable/observability/PrometheusMetrics.d.ts.map +1 -1
  969. package/dist/unstable/observability/PrometheusMetrics.js +4 -33
  970. package/dist/unstable/observability/PrometheusMetrics.js.map +1 -1
  971. package/dist/unstable/observability/internal/protobuf.js +4 -4
  972. package/dist/unstable/observability/internal/protobuf.js.map +1 -1
  973. package/dist/unstable/persistence/KeyValueStore.d.ts +24 -3
  974. package/dist/unstable/persistence/KeyValueStore.d.ts.map +1 -1
  975. package/dist/unstable/persistence/KeyValueStore.js +148 -6
  976. package/dist/unstable/persistence/KeyValueStore.js.map +1 -1
  977. package/dist/unstable/persistence/Persistable.d.ts +2 -2
  978. package/dist/unstable/persistence/Persistable.d.ts.map +1 -1
  979. package/dist/unstable/persistence/Persistable.js +1 -1
  980. package/dist/unstable/persistence/Persistable.js.map +1 -1
  981. package/dist/unstable/persistence/PersistedCache.d.ts +6 -6
  982. package/dist/unstable/persistence/PersistedCache.d.ts.map +1 -1
  983. package/dist/unstable/persistence/PersistedCache.js +12 -12
  984. package/dist/unstable/persistence/PersistedCache.js.map +1 -1
  985. package/dist/unstable/persistence/PersistedQueue.d.ts +16 -16
  986. package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
  987. package/dist/unstable/persistence/PersistedQueue.js +15 -14
  988. package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
  989. package/dist/unstable/persistence/Persistence.d.ts +5 -5
  990. package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
  991. package/dist/unstable/persistence/Persistence.js +5 -5
  992. package/dist/unstable/persistence/Persistence.js.map +1 -1
  993. package/dist/unstable/persistence/RateLimiter.d.ts +9 -9
  994. package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
  995. package/dist/unstable/persistence/RateLimiter.js +4 -4
  996. package/dist/unstable/persistence/RateLimiter.js.map +1 -1
  997. package/dist/unstable/persistence/Redis.d.ts +3 -3
  998. package/dist/unstable/persistence/Redis.d.ts.map +1 -1
  999. package/dist/unstable/persistence/Redis.js +2 -2
  1000. package/dist/unstable/persistence/Redis.js.map +1 -1
  1001. package/dist/unstable/process/ChildProcess.d.ts +5 -128
  1002. package/dist/unstable/process/ChildProcess.d.ts.map +1 -1
  1003. package/dist/unstable/process/ChildProcess.js +1 -65
  1004. package/dist/unstable/process/ChildProcess.js.map +1 -1
  1005. package/dist/unstable/process/ChildProcessSpawner.d.ts +89 -8
  1006. package/dist/unstable/process/ChildProcessSpawner.d.ts.map +1 -1
  1007. package/dist/unstable/process/ChildProcessSpawner.js +22 -2
  1008. package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
  1009. package/dist/unstable/reactivity/Atom.d.ts +108 -47
  1010. package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
  1011. package/dist/unstable/reactivity/Atom.js +105 -25
  1012. package/dist/unstable/reactivity/Atom.js.map +1 -1
  1013. package/dist/unstable/reactivity/AtomHttpApi.d.ts +22 -20
  1014. package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
  1015. package/dist/unstable/reactivity/AtomHttpApi.js +58 -26
  1016. package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
  1017. package/dist/unstable/reactivity/AtomRegistry.d.ts +8 -2
  1018. package/dist/unstable/reactivity/AtomRegistry.d.ts.map +1 -1
  1019. package/dist/unstable/reactivity/AtomRegistry.js +57 -14
  1020. package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
  1021. package/dist/unstable/reactivity/AtomRpc.d.ts +12 -12
  1022. package/dist/unstable/reactivity/AtomRpc.d.ts.map +1 -1
  1023. package/dist/unstable/reactivity/AtomRpc.js +59 -31
  1024. package/dist/unstable/reactivity/AtomRpc.js.map +1 -1
  1025. package/dist/unstable/reactivity/Reactivity.d.ts +2 -2
  1026. package/dist/unstable/reactivity/Reactivity.d.ts.map +1 -1
  1027. package/dist/unstable/reactivity/Reactivity.js +6 -6
  1028. package/dist/unstable/reactivity/Reactivity.js.map +1 -1
  1029. package/dist/unstable/reactivity/index.d.ts +2 -2
  1030. package/dist/unstable/reactivity/index.d.ts.map +1 -1
  1031. package/dist/unstable/reactivity/index.js +2 -2
  1032. package/dist/unstable/reactivity/index.js.map +1 -1
  1033. package/dist/unstable/rpc/Rpc.d.ts +47 -19
  1034. package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
  1035. package/dist/unstable/rpc/Rpc.js +39 -7
  1036. package/dist/unstable/rpc/Rpc.js.map +1 -1
  1037. package/dist/unstable/rpc/RpcClient.d.ts +26 -47
  1038. package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
  1039. package/dist/unstable/rpc/RpcClient.js +120 -77
  1040. package/dist/unstable/rpc/RpcClient.js.map +1 -1
  1041. package/dist/unstable/rpc/RpcClientError.d.ts +2 -2
  1042. package/dist/unstable/rpc/RpcGroup.d.ts +15 -11
  1043. package/dist/unstable/rpc/RpcGroup.d.ts.map +1 -1
  1044. package/dist/unstable/rpc/RpcGroup.js +30 -20
  1045. package/dist/unstable/rpc/RpcGroup.js.map +1 -1
  1046. package/dist/unstable/rpc/RpcMiddleware.d.ts +12 -12
  1047. package/dist/unstable/rpc/RpcMiddleware.d.ts.map +1 -1
  1048. package/dist/unstable/rpc/RpcMiddleware.js +5 -5
  1049. package/dist/unstable/rpc/RpcMiddleware.js.map +1 -1
  1050. package/dist/unstable/rpc/RpcSchema.d.ts +14 -1
  1051. package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
  1052. package/dist/unstable/rpc/RpcSchema.js +17 -2
  1053. package/dist/unstable/rpc/RpcSchema.js.map +1 -1
  1054. package/dist/unstable/rpc/RpcSerialization.d.ts +13 -2
  1055. package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
  1056. package/dist/unstable/rpc/RpcSerialization.js +60 -27
  1057. package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
  1058. package/dist/unstable/rpc/RpcServer.d.ts +8 -12
  1059. package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
  1060. package/dist/unstable/rpc/RpcServer.js +78 -46
  1061. package/dist/unstable/rpc/RpcServer.js.map +1 -1
  1062. package/dist/unstable/rpc/RpcWorker.d.ts +2 -2
  1063. package/dist/unstable/rpc/RpcWorker.d.ts.map +1 -1
  1064. package/dist/unstable/rpc/RpcWorker.js +4 -4
  1065. package/dist/unstable/rpc/RpcWorker.js.map +1 -1
  1066. package/dist/unstable/rpc/Utils.d.ts +6 -3
  1067. package/dist/unstable/rpc/Utils.d.ts.map +1 -1
  1068. package/dist/unstable/rpc/Utils.js +48 -6
  1069. package/dist/unstable/rpc/Utils.js.map +1 -1
  1070. package/dist/unstable/schema/Model.d.ts +24 -3
  1071. package/dist/unstable/schema/Model.d.ts.map +1 -1
  1072. package/dist/unstable/schema/Model.js +17 -4
  1073. package/dist/unstable/schema/Model.js.map +1 -1
  1074. package/dist/unstable/schema/VariantSchema.d.ts +7 -7
  1075. package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
  1076. package/dist/unstable/schema/VariantSchema.js +7 -18
  1077. package/dist/unstable/schema/VariantSchema.js.map +1 -1
  1078. package/dist/unstable/socket/Socket.d.ts +16 -15
  1079. package/dist/unstable/socket/Socket.d.ts.map +1 -1
  1080. package/dist/unstable/socket/Socket.js +22 -19
  1081. package/dist/unstable/socket/Socket.js.map +1 -1
  1082. package/dist/unstable/socket/SocketServer.d.ts +8 -5
  1083. package/dist/unstable/socket/SocketServer.d.ts.map +1 -1
  1084. package/dist/unstable/socket/SocketServer.js +2 -2
  1085. package/dist/unstable/socket/SocketServer.js.map +1 -1
  1086. package/dist/unstable/sql/Migrator.d.ts +1 -1
  1087. package/dist/unstable/sql/Migrator.d.ts.map +1 -1
  1088. package/dist/unstable/sql/Migrator.js +2 -2
  1089. package/dist/unstable/sql/Migrator.js.map +1 -1
  1090. package/dist/unstable/sql/SqlClient.d.ts +5 -5
  1091. package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
  1092. package/dist/unstable/sql/SqlClient.js +7 -7
  1093. package/dist/unstable/sql/SqlClient.js.map +1 -1
  1094. package/dist/unstable/sql/SqlConnection.d.ts +2 -2
  1095. package/dist/unstable/sql/SqlConnection.d.ts.map +1 -1
  1096. package/dist/unstable/sql/SqlConnection.js +5 -2
  1097. package/dist/unstable/sql/SqlConnection.js.map +1 -1
  1098. package/dist/unstable/sql/SqlError.d.ts +237 -17
  1099. package/dist/unstable/sql/SqlError.d.ts.map +1 -1
  1100. package/dist/unstable/sql/SqlError.js +260 -4
  1101. package/dist/unstable/sql/SqlError.js.map +1 -1
  1102. package/dist/unstable/sql/SqlModel.d.ts +8 -9
  1103. package/dist/unstable/sql/SqlModel.d.ts.map +1 -1
  1104. package/dist/unstable/sql/SqlModel.js +12 -38
  1105. package/dist/unstable/sql/SqlModel.js.map +1 -1
  1106. package/dist/unstable/sql/SqlResolver.d.ts.map +1 -1
  1107. package/dist/unstable/sql/SqlResolver.js +26 -17
  1108. package/dist/unstable/sql/SqlResolver.js.map +1 -1
  1109. package/dist/unstable/sql/SqlSchema.d.ts +17 -6
  1110. package/dist/unstable/sql/SqlSchema.d.ts.map +1 -1
  1111. package/dist/unstable/sql/SqlSchema.js +17 -7
  1112. package/dist/unstable/sql/SqlSchema.js.map +1 -1
  1113. package/dist/unstable/sql/Statement.d.ts +2 -2
  1114. package/dist/unstable/sql/Statement.d.ts.map +1 -1
  1115. package/dist/unstable/sql/Statement.js +2 -3
  1116. package/dist/unstable/sql/Statement.js.map +1 -1
  1117. package/dist/unstable/workers/Transferable.d.ts +4 -4
  1118. package/dist/unstable/workers/Transferable.d.ts.map +1 -1
  1119. package/dist/unstable/workers/Transferable.js +7 -7
  1120. package/dist/unstable/workers/Transferable.js.map +1 -1
  1121. package/dist/unstable/workers/Worker.d.ts +3 -3
  1122. package/dist/unstable/workers/Worker.d.ts.map +1 -1
  1123. package/dist/unstable/workers/Worker.js +8 -4
  1124. package/dist/unstable/workers/Worker.js.map +1 -1
  1125. package/dist/unstable/workers/WorkerError.d.ts +5 -5
  1126. package/dist/unstable/workers/WorkerRunner.d.ts +2 -2
  1127. package/dist/unstable/workers/WorkerRunner.d.ts.map +1 -1
  1128. package/dist/unstable/workers/WorkerRunner.js +5 -2
  1129. package/dist/unstable/workers/WorkerRunner.js.map +1 -1
  1130. package/dist/unstable/workflow/Activity.d.ts +7 -2
  1131. package/dist/unstable/workflow/Activity.d.ts.map +1 -1
  1132. package/dist/unstable/workflow/Activity.js +17 -4
  1133. package/dist/unstable/workflow/Activity.js.map +1 -1
  1134. package/dist/unstable/workflow/DurableClock.d.ts +3 -6
  1135. package/dist/unstable/workflow/DurableClock.d.ts.map +1 -1
  1136. package/dist/unstable/workflow/DurableClock.js +6 -6
  1137. package/dist/unstable/workflow/DurableClock.js.map +1 -1
  1138. package/dist/unstable/workflow/DurableDeferred.d.ts +1 -1
  1139. package/dist/unstable/workflow/DurableDeferred.d.ts.map +1 -1
  1140. package/dist/unstable/workflow/DurableDeferred.js +15 -15
  1141. package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
  1142. package/dist/unstable/workflow/Workflow.d.ts +13 -12
  1143. package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
  1144. package/dist/unstable/workflow/Workflow.js +18 -18
  1145. package/dist/unstable/workflow/Workflow.js.map +1 -1
  1146. package/dist/unstable/workflow/WorkflowEngine.d.ts +26 -8
  1147. package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
  1148. package/dist/unstable/workflow/WorkflowEngine.js +167 -17
  1149. package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
  1150. package/dist/unstable/workflow/WorkflowProxyServer.d.ts.map +1 -1
  1151. package/dist/unstable/workflow/WorkflowProxyServer.js +4 -4
  1152. package/dist/unstable/workflow/WorkflowProxyServer.js.map +1 -1
  1153. package/package.json +11 -11
  1154. package/src/Array.ts +304 -447
  1155. package/src/BigDecimal.ts +137 -82
  1156. package/src/BigInt.ts +53 -45
  1157. package/src/Brand.ts +3 -5
  1158. package/src/Cache.ts +27 -54
  1159. package/src/Cause.ts +58 -23
  1160. package/src/Channel.ts +693 -224
  1161. package/src/Chunk.ts +149 -331
  1162. package/src/Clock.ts +2 -2
  1163. package/src/Combiner.ts +280 -13
  1164. package/src/Config.ts +197 -27
  1165. package/src/ConfigProvider.ts +5 -5
  1166. package/src/Console.ts +2 -2
  1167. package/src/Context.ts +1454 -0
  1168. package/src/Cron.ts +155 -63
  1169. package/src/Data.ts +539 -376
  1170. package/src/DateTime.ts +77 -258
  1171. package/src/Deferred.ts +15 -6
  1172. package/src/Duration.ts +123 -67
  1173. package/src/Effect.ts +1629 -1355
  1174. package/src/Encoding.ts +879 -0
  1175. package/src/Equal.ts +295 -111
  1176. package/src/Equivalence.ts +114 -52
  1177. package/src/ErrorReporter.ts +458 -0
  1178. package/src/ExecutionPlan.ts +8 -9
  1179. package/src/Exit.ts +24 -12
  1180. package/src/Fiber.ts +17 -8
  1181. package/src/FiberHandle.ts +15 -14
  1182. package/src/FiberMap.ts +27 -27
  1183. package/src/FiberSet.ts +5 -5
  1184. package/src/FileSystem.ts +34 -30
  1185. package/src/Filter.ts +4 -62
  1186. package/src/Formatter.ts +253 -51
  1187. package/src/Function.ts +2 -10
  1188. package/src/Graph.ts +131 -117
  1189. package/src/Hash.ts +2 -2
  1190. package/src/HashMap.ts +26 -19
  1191. package/src/Iterable.ts +117 -63
  1192. package/src/JsonSchema.ts +383 -10
  1193. package/src/Latch.ts +194 -0
  1194. package/src/Layer.ts +728 -441
  1195. package/src/LayerMap.ts +38 -35
  1196. package/src/LogLevel.ts +37 -0
  1197. package/src/Logger.ts +35 -102
  1198. package/src/ManagedRuntime.ts +61 -48
  1199. package/src/Metric.ts +64 -66
  1200. package/src/MutableHashMap.ts +9 -0
  1201. package/src/MutableHashSet.ts +9 -0
  1202. package/src/MutableList.ts +3 -0
  1203. package/src/Newtype.ts +308 -0
  1204. package/src/Number.ts +98 -29
  1205. package/src/Optic.ts +948 -19
  1206. package/src/Option.ts +34 -24
  1207. package/src/Order.ts +39 -32
  1208. package/src/PartitionedSemaphore.ts +288 -56
  1209. package/src/Path.ts +2 -2
  1210. package/src/Pipeable.ts +32 -1
  1211. package/src/Pool.ts +18 -16
  1212. package/src/PubSub.ts +30 -20
  1213. package/src/Pull.ts +1 -1
  1214. package/src/Queue.ts +11 -9
  1215. package/src/Random.ts +51 -14
  1216. package/src/RcMap.ts +19 -19
  1217. package/src/RcRef.ts +1 -1
  1218. package/src/Record.ts +94 -199
  1219. package/src/Redactable.ts +146 -72
  1220. package/src/Reducer.ts +166 -7
  1221. package/src/References.ts +283 -287
  1222. package/src/Request.ts +8 -7
  1223. package/src/RequestResolver.ts +34 -55
  1224. package/src/Resource.ts +6 -5
  1225. package/src/Result.ts +2 -4
  1226. package/src/Runtime.ts +102 -6
  1227. package/src/Schedule.ts +460 -451
  1228. package/src/Scheduler.ts +52 -129
  1229. package/src/Schema.ts +4267 -752
  1230. package/src/SchemaAST.ts +480 -302
  1231. package/src/SchemaGetter.ts +92 -38
  1232. package/src/SchemaIssue.ts +28 -15
  1233. package/src/SchemaParser.ts +100 -29
  1234. package/src/SchemaRepresentation.ts +59 -32
  1235. package/src/SchemaTransformation.ts +364 -13
  1236. package/src/Scope.ts +2 -2
  1237. package/src/ScopedCache.ts +8 -8
  1238. package/src/Semaphore.ts +442 -0
  1239. package/src/Sink.ts +89 -34
  1240. package/src/Stdio.ts +29 -6
  1241. package/src/Stream.ts +898 -752
  1242. package/src/String.ts +122 -69
  1243. package/src/Struct.ts +33 -7
  1244. package/src/SubscriptionRef.ts +101 -120
  1245. package/src/SynchronizedRef.ts +3 -2
  1246. package/src/Terminal.ts +5 -4
  1247. package/src/Tracer.ts +23 -22
  1248. package/src/Trie.ts +44 -31
  1249. package/src/TxChunk.ts +26 -16
  1250. package/src/TxDeferred.ts +391 -0
  1251. package/src/TxHashMap.ts +347 -291
  1252. package/src/TxHashSet.ts +54 -61
  1253. package/src/TxPriorityQueue.ts +762 -0
  1254. package/src/TxPubSub.ts +787 -0
  1255. package/src/TxQueue.ts +221 -245
  1256. package/src/TxReentrantLock.ts +729 -0
  1257. package/src/TxRef.ts +31 -31
  1258. package/src/TxSemaphore.ts +203 -31
  1259. package/src/TxSubscriptionRef.ts +637 -0
  1260. package/src/Types.ts +78 -17
  1261. package/src/Unify.ts +26 -2
  1262. package/src/Utils.ts +137 -111
  1263. package/src/index.ts +898 -72
  1264. package/src/internal/core.ts +19 -12
  1265. package/src/internal/dateTime.ts +91 -96
  1266. package/src/internal/effect.ts +1150 -611
  1267. package/src/internal/hashMap.ts +12 -10
  1268. package/src/internal/layer.ts +7 -7
  1269. package/src/internal/option.ts +7 -0
  1270. package/src/internal/random.ts +20 -0
  1271. package/src/internal/rcRef.ts +14 -13
  1272. package/src/internal/references.ts +72 -0
  1273. package/src/internal/request.ts +8 -8
  1274. package/src/internal/schedule.ts +3 -1
  1275. package/src/internal/schema/annotations.ts +2 -0
  1276. package/src/internal/schema/representation.ts +81 -95
  1277. package/src/internal/schema/schema.ts +25 -1
  1278. package/src/internal/schema/to-codec.ts +7 -17
  1279. package/src/internal/trie.ts +21 -15
  1280. package/src/testing/TestClock.ts +13 -11
  1281. package/src/testing/TestSchema.ts +333 -36
  1282. package/src/testing/index.ts +64 -1
  1283. package/src/unstable/ai/AiError.ts +112 -54
  1284. package/src/unstable/ai/AnthropicStructuredOutput.ts +7 -3
  1285. package/src/unstable/ai/Chat.ts +137 -88
  1286. package/src/unstable/ai/EmbeddingModel.ts +209 -0
  1287. package/src/unstable/ai/IdGenerator.ts +2 -2
  1288. package/src/unstable/ai/LanguageModel.ts +685 -255
  1289. package/src/unstable/ai/McpSchema.ts +84 -22
  1290. package/src/unstable/ai/McpServer.ts +299 -87
  1291. package/src/unstable/ai/Model.ts +44 -13
  1292. package/src/unstable/ai/OpenAiStructuredOutput.ts +9 -2
  1293. package/src/unstable/ai/Prompt.ts +43 -49
  1294. package/src/unstable/ai/Response.ts +31 -33
  1295. package/src/unstable/ai/ResponseIdTracker.ts +95 -0
  1296. package/src/unstable/ai/Telemetry.ts +2 -2
  1297. package/src/unstable/ai/Tokenizer.ts +2 -2
  1298. package/src/unstable/ai/Tool.ts +62 -36
  1299. package/src/unstable/ai/Toolkit.ts +17 -26
  1300. package/src/unstable/ai/index.ts +24 -1
  1301. package/src/unstable/ai/internal/codec-transformer.ts +3 -9
  1302. package/src/unstable/cli/Argument.ts +5 -8
  1303. package/src/unstable/cli/CliError.ts +67 -66
  1304. package/src/unstable/cli/CliOutput.ts +87 -15
  1305. package/src/unstable/cli/Command.ts +808 -193
  1306. package/src/unstable/cli/Completions.ts +107 -0
  1307. package/src/unstable/cli/Flag.ts +5 -6
  1308. package/src/unstable/cli/GlobalFlag.ts +242 -0
  1309. package/src/unstable/cli/HelpDoc.ts +91 -11
  1310. package/src/unstable/cli/Param.ts +54 -27
  1311. package/src/unstable/cli/Primitive.ts +2 -2
  1312. package/src/unstable/cli/Prompt.ts +275 -104
  1313. package/src/unstable/cli/index.ts +10 -0
  1314. package/src/unstable/cli/internal/command.ts +125 -64
  1315. package/src/unstable/cli/internal/completions/bash.ts +7 -7
  1316. package/src/unstable/cli/internal/completions/{CommandDescriptor.ts → descriptor.ts} +16 -58
  1317. package/src/unstable/cli/internal/completions/fish.ts +7 -7
  1318. package/src/unstable/cli/internal/completions/zsh.ts +8 -14
  1319. package/src/unstable/cli/internal/config.ts +49 -0
  1320. package/src/unstable/cli/internal/help.ts +171 -0
  1321. package/src/unstable/cli/internal/parser.ts +201 -84
  1322. package/src/unstable/cluster/ClusterCron.ts +2 -2
  1323. package/src/unstable/cluster/ClusterSchema.ts +38 -10
  1324. package/src/unstable/cluster/ClusterWorkflowEngine.ts +144 -81
  1325. package/src/unstable/cluster/DeliverAt.ts +1 -1
  1326. package/src/unstable/cluster/Entity.ts +59 -45
  1327. package/src/unstable/cluster/EntityAddress.ts +1 -1
  1328. package/src/unstable/cluster/EntityProxy.ts +3 -3
  1329. package/src/unstable/cluster/EntityProxyServer.ts +4 -4
  1330. package/src/unstable/cluster/EntityResource.ts +6 -6
  1331. package/src/unstable/cluster/Envelope.ts +1 -1
  1332. package/src/unstable/cluster/HttpRunner.ts +2 -2
  1333. package/src/unstable/cluster/K8sHttpClient.ts +7 -7
  1334. package/src/unstable/cluster/Message.ts +30 -17
  1335. package/src/unstable/cluster/MessageStorage.ts +76 -46
  1336. package/src/unstable/cluster/Reply.ts +13 -10
  1337. package/src/unstable/cluster/Runner.ts +1 -1
  1338. package/src/unstable/cluster/RunnerAddress.ts +1 -1
  1339. package/src/unstable/cluster/RunnerHealth.ts +2 -2
  1340. package/src/unstable/cluster/RunnerServer.ts +11 -14
  1341. package/src/unstable/cluster/RunnerStorage.ts +9 -9
  1342. package/src/unstable/cluster/Runners.ts +28 -23
  1343. package/src/unstable/cluster/ShardId.ts +84 -74
  1344. package/src/unstable/cluster/Sharding.ts +83 -66
  1345. package/src/unstable/cluster/ShardingConfig.ts +39 -40
  1346. package/src/unstable/cluster/Snowflake.ts +2 -2
  1347. package/src/unstable/cluster/SqlMessageStorage.ts +29 -20
  1348. package/src/unstable/cluster/SqlRunnerStorage.ts +13 -7
  1349. package/src/unstable/cluster/internal/entityManager.ts +66 -46
  1350. package/src/unstable/cluster/internal/entityReaper.ts +4 -3
  1351. package/src/unstable/cluster/internal/resourceMap.ts +3 -3
  1352. package/src/unstable/cluster/internal/resourceRef.ts +2 -1
  1353. package/src/unstable/devtools/DevToolsClient.ts +26 -21
  1354. package/src/unstable/devtools/DevToolsSchema.ts +16 -3
  1355. package/src/unstable/encoding/Ndjson.ts +17 -17
  1356. package/src/unstable/encoding/Sse.ts +3 -5
  1357. package/src/unstable/eventlog/Event.ts +0 -8
  1358. package/src/unstable/eventlog/EventGroup.ts +0 -4
  1359. package/src/unstable/eventlog/EventJournal.ts +148 -80
  1360. package/src/unstable/eventlog/EventLog.ts +360 -233
  1361. package/src/unstable/eventlog/EventLogEncryption.ts +18 -32
  1362. package/src/unstable/eventlog/EventLogMessage.ts +277 -0
  1363. package/src/unstable/eventlog/EventLogRemote.ts +264 -410
  1364. package/src/unstable/eventlog/EventLogServer.ts +183 -275
  1365. package/src/unstable/eventlog/EventLogServerEncrypted.ts +206 -0
  1366. package/src/unstable/eventlog/EventLogServerUnencrypted.ts +749 -0
  1367. package/src/unstable/eventlog/EventLogSessionAuth.ts +437 -0
  1368. package/src/unstable/eventlog/{SqlEventLogJournal.ts → SqlEventJournal.ts} +38 -22
  1369. package/src/unstable/eventlog/{SqlEventLogServer.ts → SqlEventLogServerEncrypted.ts} +110 -43
  1370. package/src/unstable/eventlog/SqlEventLogServerUnencrypted.ts +506 -0
  1371. package/src/unstable/eventlog/index.ts +27 -2
  1372. package/src/unstable/eventlog/internal/identityRootSecretDerivation.ts +153 -0
  1373. package/src/unstable/http/Cookies.ts +94 -11
  1374. package/src/unstable/http/Etag.ts +7 -5
  1375. package/src/unstable/http/FetchHttpClient.ts +5 -5
  1376. package/src/unstable/http/Headers.ts +70 -20
  1377. package/src/unstable/http/HttpClient.ts +385 -42
  1378. package/src/unstable/http/HttpClientRequest.ts +151 -39
  1379. package/src/unstable/http/HttpClientResponse.ts +12 -6
  1380. package/src/unstable/http/HttpEffect.ts +86 -100
  1381. package/src/unstable/http/HttpIncomingMessage.ts +5 -4
  1382. package/src/unstable/http/HttpMethod.ts +16 -4
  1383. package/src/unstable/http/HttpMiddleware.ts +50 -50
  1384. package/src/unstable/http/HttpPlatform.ts +5 -4
  1385. package/src/unstable/http/HttpRouter.ts +46 -46
  1386. package/src/unstable/http/HttpServer.ts +5 -11
  1387. package/src/unstable/http/HttpServerError.ts +45 -47
  1388. package/src/unstable/http/HttpServerRequest.ts +414 -23
  1389. package/src/unstable/http/HttpServerRespondable.ts +6 -6
  1390. package/src/unstable/http/HttpServerResponse.ts +351 -13
  1391. package/src/unstable/http/HttpStaticServer.ts +456 -0
  1392. package/src/unstable/http/HttpTraceContext.ts +31 -17
  1393. package/src/unstable/http/Multipart.ts +10 -10
  1394. package/src/unstable/http/Url.ts +650 -0
  1395. package/src/unstable/http/UrlParams.ts +31 -19
  1396. package/src/unstable/http/index.ts +10 -0
  1397. package/src/unstable/http/internal/preResponseHandler.ts +15 -0
  1398. package/src/unstable/httpapi/HttpApi.ts +21 -21
  1399. package/src/unstable/httpapi/HttpApiBuilder.ts +128 -55
  1400. package/src/unstable/httpapi/HttpApiClient.ts +186 -34
  1401. package/src/unstable/httpapi/HttpApiEndpoint.ts +225 -113
  1402. package/src/unstable/httpapi/HttpApiError.ts +108 -30
  1403. package/src/unstable/httpapi/HttpApiGroup.ts +18 -17
  1404. package/src/unstable/httpapi/HttpApiMiddleware.ts +95 -33
  1405. package/src/unstable/httpapi/HttpApiScalar.ts +6 -0
  1406. package/src/unstable/httpapi/HttpApiSchema.ts +106 -11
  1407. package/src/unstable/httpapi/HttpApiSecurity.ts +13 -13
  1408. package/src/unstable/httpapi/OpenApi.ts +73 -72
  1409. package/src/unstable/observability/Otlp.ts +12 -12
  1410. package/src/unstable/observability/OtlpExporter.ts +14 -10
  1411. package/src/unstable/observability/OtlpLogger.ts +13 -9
  1412. package/src/unstable/observability/OtlpMetrics.ts +6 -6
  1413. package/src/unstable/observability/OtlpSerialization.ts +2 -2
  1414. package/src/unstable/observability/OtlpTracer.ts +14 -10
  1415. package/src/unstable/observability/PrometheusMetrics.ts +5 -5
  1416. package/src/unstable/observability/internal/protobuf.ts +4 -4
  1417. package/src/unstable/persistence/KeyValueStore.ts +230 -7
  1418. package/src/unstable/persistence/Persistable.ts +3 -3
  1419. package/src/unstable/persistence/PersistedCache.ts +35 -21
  1420. package/src/unstable/persistence/PersistedQueue.ts +28 -27
  1421. package/src/unstable/persistence/Persistence.ts +7 -7
  1422. package/src/unstable/persistence/RateLimiter.ts +7 -7
  1423. package/src/unstable/persistence/Redis.ts +2 -2
  1424. package/src/unstable/process/ChildProcess.ts +6 -208
  1425. package/src/unstable/process/ChildProcessSpawner.ts +120 -15
  1426. package/src/unstable/reactivity/Atom.ts +280 -124
  1427. package/src/unstable/reactivity/AtomHttpApi.ts +115 -59
  1428. package/src/unstable/reactivity/AtomRegistry.ts +70 -16
  1429. package/src/unstable/reactivity/AtomRpc.ts +82 -37
  1430. package/src/unstable/reactivity/Reactivity.ts +6 -6
  1431. package/src/unstable/reactivity/index.ts +2 -2
  1432. package/src/unstable/rpc/Rpc.ts +77 -32
  1433. package/src/unstable/rpc/RpcClient.ts +165 -145
  1434. package/src/unstable/rpc/RpcGroup.ts +51 -34
  1435. package/src/unstable/rpc/RpcMiddleware.ts +28 -22
  1436. package/src/unstable/rpc/RpcSchema.ts +24 -6
  1437. package/src/unstable/rpc/RpcSerialization.ts +97 -54
  1438. package/src/unstable/rpc/RpcServer.ts +97 -69
  1439. package/src/unstable/rpc/RpcWorker.ts +5 -5
  1440. package/src/unstable/rpc/Utils.ts +65 -5
  1441. package/src/unstable/schema/Model.ts +35 -6
  1442. package/src/unstable/schema/VariantSchema.ts +14 -27
  1443. package/src/unstable/socket/Socket.ts +42 -38
  1444. package/src/unstable/socket/SocketServer.ts +2 -2
  1445. package/src/unstable/sql/Migrator.ts +7 -5
  1446. package/src/unstable/sql/SqlClient.ts +13 -11
  1447. package/src/unstable/sql/SqlConnection.ts +2 -2
  1448. package/src/unstable/sql/SqlError.ts +365 -11
  1449. package/src/unstable/sql/SqlModel.ts +57 -85
  1450. package/src/unstable/sql/SqlResolver.ts +26 -16
  1451. package/src/unstable/sql/SqlSchema.ts +42 -26
  1452. package/src/unstable/sql/Statement.ts +2 -3
  1453. package/src/unstable/workers/Transferable.ts +17 -19
  1454. package/src/unstable/workers/Worker.ts +6 -5
  1455. package/src/unstable/workers/WorkerRunner.ts +2 -2
  1456. package/src/unstable/workflow/Activity.ts +27 -4
  1457. package/src/unstable/workflow/DurableClock.ts +11 -11
  1458. package/src/unstable/workflow/DurableDeferred.ts +16 -16
  1459. package/src/unstable/workflow/Workflow.ts +32 -25
  1460. package/src/unstable/workflow/WorkflowEngine.ts +239 -25
  1461. package/src/unstable/workflow/WorkflowProxyServer.ts +4 -4
  1462. package/dist/NullOr.d.ts +0 -149
  1463. package/dist/NullOr.d.ts.map +0 -1
  1464. package/dist/NullOr.js +0 -152
  1465. package/dist/NullOr.js.map +0 -1
  1466. package/dist/ServiceMap.d.ts +0 -1126
  1467. package/dist/ServiceMap.d.ts.map +0 -1
  1468. package/dist/ServiceMap.js.map +0 -1
  1469. package/dist/encoding/Base64.d.ts +0 -67
  1470. package/dist/encoding/Base64.d.ts.map +0 -1
  1471. package/dist/encoding/Base64.js +0 -146
  1472. package/dist/encoding/Base64.js.map +0 -1
  1473. package/dist/encoding/Base64Url.d.ts +0 -60
  1474. package/dist/encoding/Base64Url.d.ts.map +0 -1
  1475. package/dist/encoding/Base64Url.js +0 -89
  1476. package/dist/encoding/Base64Url.js.map +0 -1
  1477. package/dist/encoding/EncodingError.d.ts +0 -31
  1478. package/dist/encoding/EncodingError.d.ts.map +0 -1
  1479. package/dist/encoding/EncodingError.js +0 -22
  1480. package/dist/encoding/EncodingError.js.map +0 -1
  1481. package/dist/encoding/Hex.d.ts +0 -61
  1482. package/dist/encoding/Hex.d.ts.map +0 -1
  1483. package/dist/encoding/Hex.js +0 -115
  1484. package/dist/encoding/Hex.js.map +0 -1
  1485. package/dist/encoding/index.d.ts +0 -26
  1486. package/dist/encoding/index.d.ts.map +0 -1
  1487. package/dist/encoding/index.js +0 -27
  1488. package/dist/encoding/index.js.map +0 -1
  1489. package/dist/unstable/cli/internal/builtInFlags.d.ts +0 -7
  1490. package/dist/unstable/cli/internal/builtInFlags.d.ts.map +0 -1
  1491. package/dist/unstable/cli/internal/builtInFlags.js +0 -44
  1492. package/dist/unstable/cli/internal/builtInFlags.js.map +0 -1
  1493. package/dist/unstable/cli/internal/completions/CommandDescriptor.d.ts +0 -2
  1494. package/dist/unstable/cli/internal/completions/CommandDescriptor.d.ts.map +0 -1
  1495. package/dist/unstable/cli/internal/completions/CommandDescriptor.js.map +0 -1
  1496. package/dist/unstable/cli/internal/completions/Completions.d.ts +0 -2
  1497. package/dist/unstable/cli/internal/completions/Completions.d.ts.map +0 -1
  1498. package/dist/unstable/cli/internal/completions/Completions.js +0 -23
  1499. package/dist/unstable/cli/internal/completions/Completions.js.map +0 -1
  1500. package/dist/unstable/eventlog/SqlEventLogJournal.d.ts.map +0 -1
  1501. package/dist/unstable/eventlog/SqlEventLogJournal.js.map +0 -1
  1502. package/dist/unstable/eventlog/SqlEventLogServer.d.ts.map +0 -1
  1503. package/dist/unstable/eventlog/SqlEventLogServer.js.map +0 -1
  1504. package/src/NullOr.ts +0 -204
  1505. package/src/ServiceMap.ts +0 -1410
  1506. package/src/encoding/Base64.ts +0 -366
  1507. package/src/encoding/Base64Url.ts +0 -104
  1508. package/src/encoding/EncodingError.ts +0 -35
  1509. package/src/encoding/Hex.ts +0 -390
  1510. package/src/encoding/index.ts +0 -31
  1511. package/src/unstable/cli/internal/builtInFlags.ts +0 -78
  1512. 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
45
141
  *
46
- * @see {@link declare} for creating schemas for non parametric types.
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
+ * )
173
+ *
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`.
375
+ *
376
+ * **Example** (Catching a SchemaError)
377
+ *
378
+ * ```ts
379
+ * import { Schema } from "effect"
110
380
  *
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.
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.
929
1681
  *
930
- * Optionally, you can specify the `mode` to be `"anyOf"` or `"oneOf"`.
1682
+ * **Example** (String or number union)
931
1683
  *
932
- * - `"anyOf"` - The union matches if any member matches.
933
- * - `"oneOf"` - The union matches if exactly one member matches.
1684
+ * ```ts
1685
+ * import { Schema } from "effect"
1686
+ *
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)
2184
+ *
2185
+ * ```ts
2186
+ * import { Schema } from "effect"
1177
2187
  *
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.
2188
+ * const A = Schema.Struct({ _tag: Schema.tag("A"), value: Schema.Number })
1182
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
+ * ```
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
+ * })
1191
2216
  *
2217
+ * // Encode strips the _tag field
2218
+ * const encoded = Schema.encodeUnknownSync(A)({ _tag: "A", value: 1 })
2219
+ * // encoded: { value: 1 }
2220
+ * ```
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,59 @@ 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
+ * a value of type {@link FilterOutput}.
2458
+ *
2459
+ * **Example** (Failure at a nested path)
2460
+ *
2461
+ * ```ts
2462
+ * import { Schema } from "effect"
2463
+ *
2464
+ * const schema = Schema.Struct({ password: Schema.String, confirmPassword: Schema.String }).check(
2465
+ * Schema.makeFilter((o) =>
2466
+ * o.password === o.confirmPassword
2467
+ * ? undefined
2468
+ * : { path: ["password"], issue: "password and confirmPassword must match" }
2469
+ * )
2470
+ * )
2471
+ *
2472
+ * console.log(String(Schema.decodeUnknownExit(schema)({ password: "123456", confirmPassword: "1234567" })))
2473
+ * // Failure(Cause([Fail(SchemaError: password and confirmPassword must match
2474
+ * // at ["password"])]))
2475
+ * ```
2476
+ *
2477
+ * **Example** (Reporting multiple failures at once)
2478
+ *
2479
+ * ```ts
2480
+ * import { Schema } from "effect"
2481
+ *
2482
+ * const schema = Schema.Struct({ a: Schema.Finite, b: Schema.Finite, c: Schema.Finite }).check(
2483
+ * Schema.makeFilter((o) => {
2484
+ * const issues: Array<Schema.FilterIssue> = []
2485
+ * if (o.a > 0) {
2486
+ * if (o.b <= 0) issues.push({ path: ["b"], issue: "b must be greater than 0" })
2487
+ * if (o.c <= 0) issues.push({ path: ["c"], issue: "c must be greater than 0" })
2488
+ * }
2489
+ * return issues
2490
+ * })
2491
+ * )
2492
+ *
2493
+ * console.log(String(Schema.decodeUnknownExit(schema)({ a: 1, b: 0, c: 0 })))
2494
+ * // Failure(Cause([Fail(SchemaError: b must be greater than 0
2495
+ * // at ["b"]
2496
+ * // c must be greater than 0
2497
+ * // at ["c"])]))
2498
+ * ```
2499
+ *
1358
2500
  * @category Checks Constructors
1359
2501
  * @since 4.0.0
1360
2502
  */
1361
2503
  export const makeFilter = AST.makeFilter;
1362
2504
  /**
2505
+ * Groups multiple checks into a single {@link AST.FilterGroup}, applying
2506
+ * optional shared annotations to the group as a whole.
2507
+ *
1363
2508
  * @category Checks Constructors
1364
2509
  * @since 4.0.0
1365
2510
  */
@@ -1847,6 +2992,9 @@ export function isFinite(annotations) {
1847
2992
  });
1848
2993
  }
1849
2994
  /**
2995
+ * Generic factory for creating a "greater than" (`>`) check for any ordered
2996
+ * type by supplying an {@link Order.Order} instance.
2997
+ *
1850
2998
  * @category Order checks
1851
2999
  * @since 4.0.0
1852
3000
  */
@@ -1862,6 +3010,9 @@ export function makeIsGreaterThan(options) {
1862
3010
  };
1863
3011
  }
1864
3012
  /**
3013
+ * Generic factory for creating a ">=" check for any ordered type by supplying
3014
+ * an {@link Order.Order} instance.
3015
+ *
1865
3016
  * @category Order checks
1866
3017
  * @since 4.0.0
1867
3018
  */
@@ -1877,6 +3028,9 @@ export function makeIsGreaterThanOrEqualTo(options) {
1877
3028
  };
1878
3029
  }
1879
3030
  /**
3031
+ * Generic factory for creating a "<" check for any ordered type by supplying
3032
+ * an {@link Order.Order} instance.
3033
+ *
1880
3034
  * @category Order checks
1881
3035
  * @since 4.0.0
1882
3036
  */
@@ -1892,6 +3046,9 @@ export function makeIsLessThan(options) {
1892
3046
  };
1893
3047
  }
1894
3048
  /**
3049
+ * Generic factory for creating a "<=" check for any ordered type by supplying
3050
+ * an {@link Order.Order} instance.
3051
+ *
1895
3052
  * @category Order checks
1896
3053
  * @since 4.0.0
1897
3054
  */
@@ -1907,6 +3064,9 @@ export function makeIsLessThanOrEqualTo(options) {
1907
3064
  };
1908
3065
  }
1909
3066
  /**
3067
+ * Generic factory for creating an inclusive/exclusive range check for any
3068
+ * ordered type by supplying an {@link Order.Order} instance.
3069
+ *
1910
3070
  * @category Order checks
1911
3071
  * @since 4.0.0
1912
3072
  */
@@ -1927,6 +3087,9 @@ export function makeIsBetween(deriveOptions) {
1927
3087
  };
1928
3088
  }
1929
3089
  /**
3090
+ * Generic factory for creating a divisibility check for any numeric type by
3091
+ * supplying a remainder function and a zero value.
3092
+ *
1930
3093
  * @category Numeric checks
1931
3094
  * @since 4.0.0
1932
3095
  */
@@ -2528,6 +3691,58 @@ export const isBetweenBigInt = /*#__PURE__*/makeIsBetween({
2528
3691
  }
2529
3692
  })
2530
3693
  });
3694
+ /**
3695
+ * Validates that a BigDecimal is greater than the specified value (exclusive).
3696
+ *
3697
+ * @category BigDecimal checks
3698
+ * @since 4.0.0
3699
+ */
3700
+ export const isGreaterThanBigDecimal = /*#__PURE__*/makeIsGreaterThan({
3701
+ order: BigDecimal_.Order,
3702
+ formatter: bd => BigDecimal_.format(bd)
3703
+ });
3704
+ /**
3705
+ * Validates that a BigDecimal is greater than or equal to the specified value
3706
+ * (inclusive).
3707
+ *
3708
+ * @category BigDecimal checks
3709
+ * @since 4.0.0
3710
+ */
3711
+ export const isGreaterThanOrEqualToBigDecimal = /*#__PURE__*/makeIsGreaterThanOrEqualTo({
3712
+ order: BigDecimal_.Order,
3713
+ formatter: bd => BigDecimal_.format(bd)
3714
+ });
3715
+ /**
3716
+ * Validates that a BigDecimal is less than the specified value (exclusive).
3717
+ *
3718
+ * @category BigDecimal checks
3719
+ * @since 4.0.0
3720
+ */
3721
+ export const isLessThanBigDecimal = /*#__PURE__*/makeIsLessThan({
3722
+ order: BigDecimal_.Order,
3723
+ formatter: bd => BigDecimal_.format(bd)
3724
+ });
3725
+ /**
3726
+ * Validates that a BigDecimal is less than or equal to the specified value
3727
+ * (inclusive).
3728
+ *
3729
+ * @category BigDecimal checks
3730
+ * @since 4.0.0
3731
+ */
3732
+ export const isLessThanOrEqualToBigDecimal = /*#__PURE__*/makeIsLessThanOrEqualTo({
3733
+ order: BigDecimal_.Order,
3734
+ formatter: bd => BigDecimal_.format(bd)
3735
+ });
3736
+ /**
3737
+ * Validates that a BigDecimal is within a specified range.
3738
+ *
3739
+ * @category BigDecimal checks
3740
+ * @since 4.0.0
3741
+ */
3742
+ export const isBetweenBigDecimal = /*#__PURE__*/makeIsBetween({
3743
+ order: BigDecimal_.Order,
3744
+ formatter: bd => BigDecimal_.format(bd)
3745
+ });
2531
3746
  /**
2532
3747
  * Validates that a value has at least the specified length. Works with strings
2533
3748
  * and arrays.
@@ -2543,6 +3758,14 @@ export const isBetweenBigInt = /*#__PURE__*/makeIsBetween({
2543
3758
  * constraint to ensure generated strings or arrays have at least the required
2544
3759
  * length.
2545
3760
  *
3761
+ * **Example** (Minimum length check)
3762
+ * ```ts
3763
+ * import { Schema } from "effect"
3764
+ *
3765
+ * const NonEmptyStringSchema = Schema.String.check(Schema.isMinLength(1))
3766
+ * const NonEmptyArraySchema = Schema.Array(Schema.Number).check(Schema.isMinLength(1))
3767
+ * ```
3768
+ *
2546
3769
  * @category Length checks
2547
3770
  * @since 4.0.0
2548
3771
  */
@@ -2935,6 +4158,7 @@ export function isPropertyNames(keySchema, annotations) {
2935
4158
  * constraint using the provided equivalence function to ensure generated arrays
2936
4159
  * contain only unique items.
2937
4160
  *
4161
+ * @category Array checks
2938
4162
  * @since 4.0.0
2939
4163
  */
2940
4164
  export function isUnique(annotations) {
@@ -2952,23 +4176,24 @@ export function isUnique(annotations) {
2952
4176
  ...annotations
2953
4177
  });
2954
4178
  }
2955
- // -----------------------------------------------------------------------------
2956
- // Built-in Schemas
2957
- // -----------------------------------------------------------------------------
2958
4179
  /**
2959
4180
  * A schema for non-empty strings. Validates that a string has at least one
2960
4181
  * character.
2961
4182
  *
4183
+ * @category String
2962
4184
  * @since 4.0.0
2963
4185
  */
2964
4186
  export const NonEmptyString = /*#__PURE__*/String.check(/*#__PURE__*/isNonEmpty());
2965
4187
  /**
2966
4188
  * A schema representing a single character.
2967
4189
  *
4190
+ * @category String
2968
4191
  * @since 4.0.0
2969
4192
  */
2970
4193
  export const Char = /*#__PURE__*/String.check(/*#__PURE__*/isLengthBetween(1, 1));
2971
4194
  /**
4195
+ * Creates a schema for `Option<A>`. See {@link Option} for details.
4196
+ *
2972
4197
  * @category Option
2973
4198
  * @since 4.0.0
2974
4199
  */
@@ -3041,6 +4266,40 @@ export function Option(value) {
3041
4266
  export function OptionFromNullOr(schema) {
3042
4267
  return NullOr(schema).pipe(decodeTo(Option(toType(schema)), Transformation.optionFromNullOr()));
3043
4268
  }
4269
+ /**
4270
+ * Decodes an undefined-or value `T` to a required `Option<T>` value.
4271
+ *
4272
+ * Decoding:
4273
+ * - `undefined` is decoded as `None`
4274
+ * - other values are decoded as `Some`
4275
+ *
4276
+ * Encoding:
4277
+ * - `None` is encoded as `undefined`
4278
+ * - `Some` is encoded as the value
4279
+ *
4280
+ * @category Option
4281
+ * @since 4.0.0
4282
+ */
4283
+ export function OptionFromUndefinedOr(schema) {
4284
+ return UndefinedOr(schema).pipe(decodeTo(Option(toType(schema)), Transformation.optionFromUndefinedOr()));
4285
+ }
4286
+ /**
4287
+ * Decodes a nullish value `T` to a required `Option<T>` value.
4288
+ *
4289
+ * Decoding:
4290
+ * - `null` and `undefined` are decoded as `None`
4291
+ * - other values are decoded as `Some`
4292
+ *
4293
+ * Encoding:
4294
+ * - `None` is encoded as `null` or `undefined` depending on the provided `options.onNoneEncoding` (defaults to `undefined`)
4295
+ * - `Some` is encoded as the value
4296
+ *
4297
+ * @category Option
4298
+ * @since 4.0.0
4299
+ */
4300
+ export function OptionFromNullishOr(schema, options) {
4301
+ return NullishOr(schema).pipe(decodeTo(Option(toType(schema)), Transformation.optionFromNullishOr(options)));
4302
+ }
3044
4303
  /**
3045
4304
  * Decodes an optional value `A` to a required `Option<A>` value.
3046
4305
  *
@@ -3078,6 +4337,35 @@ export function OptionFromOptional(schema) {
3078
4337
  return optional(schema).pipe(decodeTo(Option(toType(schema)), Transformation.optionFromOptional()));
3079
4338
  }
3080
4339
  /**
4340
+ * Decodes an optional or `null` or `undefined` value `A` to a required `Option<A>`
4341
+ * value.
4342
+ *
4343
+ * Decoding:
4344
+ * - a missing key is decoded as `None`
4345
+ * - a present key with an `undefined` value is decoded as `None`
4346
+ * - a present key with a `null` value is decoded as `None`
4347
+ * - all other values are decoded as `Some`
4348
+ *
4349
+ * Encoding (controlled by `options.onNoneEncoding`):
4350
+ * - `"omit"` (default): `None` is encoded as a missing key
4351
+ * - `null`: `None` is encoded as `null`
4352
+ * - `undefined`: `None` is encoded as `undefined`
4353
+ * - `Some` is always encoded as the value
4354
+ *
4355
+ * @category Option
4356
+ * @since 4.0.0
4357
+ */
4358
+ export function OptionFromOptionalNullOr(schema, options) {
4359
+ const onNoneEncoding = options === undefined ? "omit" : options.onNoneEncoding;
4360
+ const noneValue = onNoneEncoding === null ? null : undefined;
4361
+ return optional(NullOr(schema)).pipe(decodeTo(Option(toType(schema)), Transformation.transformOptional({
4362
+ decode: oe => oe.pipe(Option_.filter(Predicate.isNotNullish), Option_.some),
4363
+ encode: onNoneEncoding === "omit" ? Option_.flatten : ot => Option_.some(Option_.getOrElse(Option_.flatten(ot), () => noneValue))
4364
+ })));
4365
+ }
4366
+ /**
4367
+ * Creates a schema for `Result<A, E>`. See {@link Result} for details.
4368
+ *
3081
4369
  * @category Result
3082
4370
  * @since 4.0.0
3083
4371
  */
@@ -3206,6 +4494,9 @@ export function Redacted(value, options) {
3206
4494
  });
3207
4495
  }
3208
4496
  /**
4497
+ * Middleware that wraps decoded errors in `Redacted`, preventing sensitive
4498
+ * schema details from leaking in error messages.
4499
+ *
3209
4500
  * @category Redacted
3210
4501
  * @since 4.0.0
3211
4502
  */
@@ -3213,6 +4504,10 @@ export function redact(schema) {
3213
4504
  return schema.pipe(middlewareDecoding(Effect.mapErrorEager(Issue.redact)));
3214
4505
  }
3215
4506
  /**
4507
+ * Decodes a value and wraps it in `Redacted<A>`. Unlike {@link Redacted} which
4508
+ * expects the input to already be a `Redacted` instance, this schema decodes
4509
+ * the raw value and wraps it.
4510
+ *
3216
4511
  * @category Redacted
3217
4512
  * @since 4.0.0
3218
4513
  */
@@ -3225,10 +4520,12 @@ export function RedactedFromValue(value, options) {
3225
4520
  }));
3226
4521
  }
3227
4522
  /**
3228
- * @category CauseFailure
4523
+ * Creates a schema for `Cause.Reason<E>`. See {@link CauseReason} for details.
4524
+ *
4525
+ * @category CauseReason
3229
4526
  * @since 4.0.0
3230
4527
  */
3231
- export function CauseFailure(error, defect) {
4528
+ export function CauseReason(error, defect) {
3232
4529
  const schema = declareConstructor()([error, defect], ([error, defect]) => (input, ast, options) => {
3233
4530
  if (!Cause_.isReason(input)) {
3234
4531
  return Effect.fail(new Issue.InvalidType(ast, Option_.some(input)));
@@ -3252,7 +4549,7 @@ export function CauseFailure(error, defect) {
3252
4549
  _tag: "effect/Cause/Failure"
3253
4550
  },
3254
4551
  generation: {
3255
- runtime: `Schema.CauseFailure(?, ?)`,
4552
+ runtime: `Schema.CauseReason(?, ?)`,
3256
4553
  Type: `Cause.Failure<?, ?>`,
3257
4554
  importDeclaration: `import * as Cause from "effect/Cause"`
3258
4555
  },
@@ -3279,16 +4576,16 @@ export function CauseFailure(error, defect) {
3279
4576
  },
3280
4577
  encode: identity
3281
4578
  })),
3282
- toArbitrary: ([error, defect]) => causeFailureToArbitrary(error, defect),
3283
- toEquivalence: ([error, defect]) => causeFailureToEquivalence(error, defect),
3284
- toFormatter: ([error, defect]) => causeFailureToFormatter(error, defect)
4579
+ toArbitrary: ([error, defect]) => causeReasonToArbitrary(error, defect),
4580
+ toEquivalence: ([error, defect]) => causeReasonToEquivalence(error, defect),
4581
+ toFormatter: ([error, defect]) => causeReasonToFormatter(error, defect)
3285
4582
  });
3286
4583
  return make(schema.ast, {
3287
4584
  error,
3288
4585
  defect
3289
4586
  });
3290
4587
  }
3291
- function causeFailureToArbitrary(error, defect) {
4588
+ function causeReasonToArbitrary(error, defect) {
3292
4589
  return (fc, ctx) => {
3293
4590
  return fc.oneof(ctx?.isSuspend ? {
3294
4591
  maxDepth: 2,
@@ -3298,7 +4595,7 @@ function causeFailureToArbitrary(error, defect) {
3298
4595
  }).map(Cause_.makeInterruptReason), error.map(e => Cause_.makeFailReason(e)), defect.map(d => Cause_.makeDieReason(d)));
3299
4596
  };
3300
4597
  }
3301
- function causeFailureToEquivalence(error, defect) {
4598
+ function causeReasonToEquivalence(error, defect) {
3302
4599
  return (a, b) => {
3303
4600
  if (a._tag !== b._tag) return false;
3304
4601
  switch (a._tag) {
@@ -3311,7 +4608,7 @@ function causeFailureToEquivalence(error, defect) {
3311
4608
  }
3312
4609
  };
3313
4610
  }
3314
- function causeFailureToFormatter(error, defect) {
4611
+ function causeReasonToFormatter(error, defect) {
3315
4612
  return t => {
3316
4613
  switch (t._tag) {
3317
4614
  case "Fail":
@@ -3324,19 +4621,23 @@ function causeFailureToFormatter(error, defect) {
3324
4621
  };
3325
4622
  }
3326
4623
  /**
4624
+ * Creates a schema for `Cause<E>`. See {@link Cause} for details.
4625
+ *
3327
4626
  * @category Cause
3328
4627
  * @since 4.0.0
3329
4628
  */
3330
4629
  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
- });
4630
+ const schema = declareConstructor()([error, defect], ([error, defect]) => {
4631
+ const failures = ArraySchema(CauseReason(error, defect));
4632
+ return (input, ast, options) => {
4633
+ if (!Cause_.isCause(input)) {
4634
+ return Effect.fail(new Issue.InvalidType(ast, Option_.some(input)));
4635
+ }
4636
+ return Effect.mapBothEager(Parser.decodeUnknownEffect(failures)(input.reasons, options), {
4637
+ onSuccess: Cause_.fromReasons,
4638
+ onFailure: issue => new Issue.Composite(ast, Option_.some(input), [new Issue.Pointer(["failures"], issue)])
4639
+ });
4640
+ };
3340
4641
  }, {
3341
4642
  typeConstructor: {
3342
4643
  _tag: "effect/Cause"
@@ -3347,7 +4648,7 @@ export function Cause(error, defect) {
3347
4648
  importDeclaration: `import * as Cause from "effect/Cause"`
3348
4649
  },
3349
4650
  expected: "Cause",
3350
- toCodec: ([error, defect]) => link()(Array(CauseFailure(error, defect)), Transformation.transform({
4651
+ toCodec: ([error, defect]) => link()(ArraySchema(CauseReason(error, defect)), Transformation.transform({
3351
4652
  decode: Cause_.fromReasons,
3352
4653
  encode: ({
3353
4654
  reasons: failures
@@ -3364,16 +4665,16 @@ export function Cause(error, defect) {
3364
4665
  }
3365
4666
  function causeToArbitrary(error, defect) {
3366
4667
  return (fc, ctx) => {
3367
- return fc.array(causeFailureToArbitrary(error, defect)(fc, ctx)).map(Cause_.fromReasons);
4668
+ return fc.array(causeReasonToArbitrary(error, defect)(fc, ctx)).map(Cause_.fromReasons);
3368
4669
  };
3369
4670
  }
3370
4671
  function causeToEquivalence(error, defect) {
3371
- const failures = Equivalence.Array(causeFailureToEquivalence(error, defect));
4672
+ const failures = Equivalence.Array(causeReasonToEquivalence(error, defect));
3372
4673
  return (a, b) => failures(a.reasons, b.reasons);
3373
4674
  }
3374
4675
  function causeToFormatter(error, defect) {
3375
- const causeFailure = causeFailureToFormatter(error, defect);
3376
- return t => `Cause([${t.reasons.map(causeFailure).join(", ")}])`;
4676
+ const causeReason = causeReasonToFormatter(error, defect);
4677
+ return t => `Cause([${t.reasons.map(causeReason).join(", ")}])`;
3377
4678
  }
3378
4679
  const ErrorJsonEncoded = /*#__PURE__*/Struct({
3379
4680
  message: String,
@@ -3445,7 +4746,7 @@ export const Defect = /*#__PURE__*/Union([/*#__PURE__*/ErrorJsonEncoded.pipe(/*#
3445
4746
  * A schema that represents defects, that also includes stack traces in the
3446
4747
  * encoded form.
3447
4748
  *
3448
- * @category Constructors
4749
+ * @category Defect
3449
4750
  * @since 4.0.0
3450
4751
  */
3451
4752
  export const DefectWithStack = /*#__PURE__*/Union([/*#__PURE__*/ErrorJsonEncoded.pipe(/*#__PURE__*/decodeTo(ErrorWithStack, /*#__PURE__*/Transformation.errorFromErrorJsonEncoded({
@@ -3455,27 +4756,31 @@ export const DefectWithStack = /*#__PURE__*/Union([/*#__PURE__*/ErrorJsonEncoded
3455
4756
  toArbitrary: () => fc => fc.json()
3456
4757
  }), defectTransformation))]);
3457
4758
  /**
4759
+ * Creates a schema for `Exit<A, E>`. See {@link Exit} for details.
4760
+ *
3458
4761
  * @category Exit
3459
4762
  * @since 4.0.0
3460
4763
  */
3461
4764
  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
- }
4765
+ const schema = declareConstructor()([value, error, defect], ([value, error, defect]) => {
3466
4766
  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
- }
4767
+ return (input, ast, options) => {
4768
+ if (!Exit_.isExit(input)) {
4769
+ return Effect.fail(new Issue.InvalidType(ast, Option_.some(input)));
4770
+ }
4771
+ switch (input._tag) {
4772
+ case "Success":
4773
+ return Effect.mapBothEager(Parser.decodeUnknownEffect(value)(input.value, options), {
4774
+ onSuccess: Exit_.succeed,
4775
+ onFailure: issue => new Issue.Composite(ast, Option_.some(input), [new Issue.Pointer(["value"], issue)])
4776
+ });
4777
+ case "Failure":
4778
+ return Effect.mapBothEager(Parser.decodeUnknownEffect(cause)(input.cause, options), {
4779
+ onSuccess: Exit_.failCause,
4780
+ onFailure: issue => new Issue.Composite(ast, Option_.some(input), [new Issue.Pointer(["cause"], issue)])
4781
+ });
4782
+ }
4783
+ };
3479
4784
  }, {
3480
4785
  typeConstructor: {
3481
4786
  _tag: "effect/Exit"
@@ -3544,15 +4849,17 @@ export function Exit(value, error, defect) {
3544
4849
  * @since 4.0.0
3545
4850
  */
3546
4851
  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)));
4852
+ const schema = declareConstructor()([key, value], ([key, value]) => {
4853
+ const array = ArraySchema(Tuple([key, value]));
4854
+ return (input, ast, options) => {
4855
+ if (input instanceof globalThis.Map) {
4856
+ return Effect.mapBothEager(Parser.decodeUnknownEffect(array)([...input], options), {
4857
+ onSuccess: array => new globalThis.Map(array),
4858
+ onFailure: issue => new Issue.Composite(ast, Option_.some(input), [new Issue.Pointer(["entries"], issue)])
4859
+ });
4860
+ }
4861
+ return Effect.fail(new Issue.InvalidType(ast, Option_.some(input)));
4862
+ };
3556
4863
  }, {
3557
4864
  typeConstructor: {
3558
4865
  _tag: "ReadonlyMap"
@@ -3562,7 +4869,7 @@ export function ReadonlyMap(key, value) {
3562
4869
  Type: `globalThis.ReadonlyMap<?, ?>`
3563
4870
  },
3564
4871
  expected: "ReadonlyMap",
3565
- toCodec: ([key, value]) => link()(Array(Tuple([key, value])), Transformation.transform({
4872
+ toCodec: ([key, value]) => link()(ArraySchema(Tuple([key, value])), Transformation.transform({
3566
4873
  decode: e => new globalThis.Map(e),
3567
4874
  encode: map => [...map.entries()]
3568
4875
  })),
@@ -3587,20 +4894,76 @@ export function ReadonlyMap(key, value) {
3587
4894
  value
3588
4895
  });
3589
4896
  }
4897
+ /**
4898
+ * Creates a schema that validates a `HashMap` where keys and values must
4899
+ * conform to the provided schemas.
4900
+ *
4901
+ * @category HashMap
4902
+ * @since 4.0.0
4903
+ */
4904
+ export function HashMap(key, value) {
4905
+ const schema = declareConstructor()([key, value], ([key, value]) => {
4906
+ const entries = ArraySchema(Tuple([key, value]));
4907
+ return (input, ast, options) => {
4908
+ if (HashMap_.isHashMap(input)) {
4909
+ return Effect.mapBothEager(Parser.decodeUnknownEffect(entries)(HashMap_.toEntries(input), options), {
4910
+ onSuccess: HashMap_.fromIterable,
4911
+ onFailure: issue => new Issue.Composite(ast, Option_.some(input), [new Issue.Pointer(["entries"], issue)])
4912
+ });
4913
+ }
4914
+ return Effect.fail(new Issue.InvalidType(ast, Option_.some(input)));
4915
+ };
4916
+ }, {
4917
+ typeConstructor: {
4918
+ _tag: "effect/HashMap"
4919
+ },
4920
+ generation: {
4921
+ runtime: `Schema.HashMap(?, ?)`,
4922
+ Type: `HashMap.HashMap<?, ?>`,
4923
+ importDeclaration: `import * as HashMap from "effect/HashMap"`
4924
+ },
4925
+ expected: "HashMap",
4926
+ toCodec: ([key, value]) => link()(ArraySchema(Tuple([key, value])), Transformation.transform({
4927
+ decode: HashMap_.fromIterable,
4928
+ encode: HashMap_.toEntries
4929
+ })),
4930
+ toArbitrary: ([key, value]) => (fc, ctx) => {
4931
+ return fc.oneof(ctx?.isSuspend ? {
4932
+ maxDepth: 2,
4933
+ depthIdentifier: "HashMap"
4934
+ } : {}, fc.constant([]), fc.array(fc.tuple(key, value), ctx?.constraints?.array)).map(HashMap_.fromIterable);
4935
+ },
4936
+ toEquivalence: ([key, value]) => Equal.makeCompareMap(key, value),
4937
+ toFormatter: ([key, value]) => t => {
4938
+ const size = HashMap_.size(t);
4939
+ if (size === 0) {
4940
+ return "HashMap(0) {}";
4941
+ }
4942
+ const entries = HashMap_.toEntries(t).sort().map(([k, v]) => `${key(k)} => ${value(v)}`);
4943
+ return `HashMap(${size}) { ${entries.join(", ")} }`;
4944
+ }
4945
+ });
4946
+ return make(schema.ast, {
4947
+ key,
4948
+ value
4949
+ });
4950
+ }
3590
4951
  /**
3591
4952
  * @category ReadonlySet
3592
4953
  * @since 4.0.0
3593
4954
  */
3594
4955
  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)));
4956
+ const schema = declareConstructor()([value], ([value]) => {
4957
+ const array = ArraySchema(value);
4958
+ return (input, ast, options) => {
4959
+ if (input instanceof globalThis.Set) {
4960
+ return Effect.mapBothEager(Parser.decodeUnknownEffect(array)([...input], options), {
4961
+ onSuccess: array => new globalThis.Set(array),
4962
+ onFailure: issue => new Issue.Composite(ast, Option_.some(input), [new Issue.Pointer(["values"], issue)])
4963
+ });
4964
+ }
4965
+ return Effect.fail(new Issue.InvalidType(ast, Option_.some(input)));
4966
+ };
3604
4967
  }, {
3605
4968
  typeConstructor: {
3606
4969
  _tag: "ReadonlySet"
@@ -3610,7 +4973,7 @@ export function ReadonlySet(value) {
3610
4973
  Type: `globalThis.ReadonlySet<?>`
3611
4974
  },
3612
4975
  expected: "ReadonlySet",
3613
- toCodec: ([value]) => link()(Array(value), Transformation.transform({
4976
+ toCodec: ([value]) => link()(ArraySchema(value), Transformation.transform({
3614
4977
  decode: e => new globalThis.Set(e),
3615
4978
  encode: set => [...set.values()]
3616
4979
  })),
@@ -3635,6 +4998,115 @@ export function ReadonlySet(value) {
3635
4998
  });
3636
4999
  }
3637
5000
  /**
5001
+ * Creates a schema that validates a `HashSet` where values must conform to the
5002
+ * provided schema.
5003
+ *
5004
+ * @category HashSet
5005
+ * @since 4.0.0
5006
+ */
5007
+ export function HashSet(value) {
5008
+ const schema = declareConstructor()([value], ([value]) => {
5009
+ const values = ArraySchema(value);
5010
+ return (input, ast, options) => {
5011
+ if (HashSet_.isHashSet(input)) {
5012
+ return Effect.mapBothEager(Parser.decodeUnknownEffect(values)(Arr.fromIterable(input), options), {
5013
+ onSuccess: HashSet_.fromIterable,
5014
+ onFailure: issue => new Issue.Composite(ast, Option_.some(input), [new Issue.Pointer(["values"], issue)])
5015
+ });
5016
+ }
5017
+ return Effect.fail(new Issue.InvalidType(ast, Option_.some(input)));
5018
+ };
5019
+ }, {
5020
+ typeConstructor: {
5021
+ _tag: "effect/HashSet"
5022
+ },
5023
+ generation: {
5024
+ runtime: `Schema.HashSet(?)`,
5025
+ Type: `HashSet.HashSet<?>`
5026
+ },
5027
+ expected: "HashSet",
5028
+ toCodec: ([value]) => link()(ArraySchema(value), Transformation.transform({
5029
+ decode: HashSet_.fromIterable,
5030
+ encode: Arr.fromIterable
5031
+ })),
5032
+ toArbitrary: ([value]) => (fc, ctx) => {
5033
+ return fc.oneof(ctx?.isSuspend ? {
5034
+ maxDepth: 2,
5035
+ depthIdentifier: "HashSet"
5036
+ } : {}, fc.constant([]), fc.array(value, ctx?.constraints?.array)).map(HashSet_.fromIterable);
5037
+ },
5038
+ toEquivalence: ([value]) => Equal.makeCompareSet(value),
5039
+ toFormatter: ([value]) => t => {
5040
+ const size = HashSet_.size(t);
5041
+ if (size === 0) {
5042
+ return "HashSet(0) {}";
5043
+ }
5044
+ const values = globalThis.Array.from(t).sort().map(v => `${value(v)}`);
5045
+ return `HashSet(${size}) { ${values.join(", ")} }`;
5046
+ }
5047
+ });
5048
+ return make(schema.ast, {
5049
+ value
5050
+ });
5051
+ }
5052
+ /**
5053
+ * Creates a schema that validates a `Chunk` where values must conform to the
5054
+ * provided schema.
5055
+ *
5056
+ * @category Chunk
5057
+ * @since 4.0.0
5058
+ */
5059
+ export function Chunk(value) {
5060
+ const schema = declareConstructor()([value], ([value]) => {
5061
+ const values = ArraySchema(value);
5062
+ return (input, ast, options) => {
5063
+ if (Chunk_.isChunk(input)) {
5064
+ return Effect.mapBothEager(Parser.decodeUnknownEffect(values)(Arr.fromIterable(input), options), {
5065
+ onSuccess: Chunk_.fromIterable,
5066
+ onFailure: issue => new Issue.Composite(ast, Option_.some(input), [new Issue.Pointer(["values"], issue)])
5067
+ });
5068
+ }
5069
+ return Effect.fail(new Issue.InvalidType(ast, Option_.some(input)));
5070
+ };
5071
+ }, {
5072
+ typeConstructor: {
5073
+ _tag: "effect/Chunk"
5074
+ },
5075
+ generation: {
5076
+ runtime: `Schema.Chunk(?)`,
5077
+ Type: `Chunk.Chunk<?>`
5078
+ },
5079
+ expected: "Chunk",
5080
+ toCodec: ([value]) => link()(ArraySchema(value), Transformation.transform({
5081
+ decode: Chunk_.fromIterable,
5082
+ encode: Arr.fromIterable
5083
+ })),
5084
+ toArbitrary: ([value]) => (fc, ctx) => {
5085
+ return fc.oneof(ctx?.isSuspend ? {
5086
+ maxDepth: 2,
5087
+ depthIdentifier: "Chunk"
5088
+ } : {}, fc.constant([]), fc.array(value, ctx?.constraints?.array)).map(Chunk_.fromIterable);
5089
+ },
5090
+ toEquivalence: ([value]) => Chunk_.makeEquivalence(value),
5091
+ toFormatter: ([value]) => t => {
5092
+ const size = Chunk_.size(t);
5093
+ if (size === 0) {
5094
+ return "Chunk(0) {}";
5095
+ }
5096
+ const values = globalThis.Array.from(t).sort().map(v => `${value(v)}`);
5097
+ return `Chunk(${size}) { ${values.join(", ")} }`;
5098
+ }
5099
+ });
5100
+ return make(schema.ast, {
5101
+ value
5102
+ });
5103
+ }
5104
+ /**
5105
+ * Schema for JavaScript `RegExp` objects.
5106
+ *
5107
+ * The default JSON serializer encodes a `RegExp` as `{ source, flags }`.
5108
+ *
5109
+ * @category RegExp
3638
5110
  * @since 4.0.0
3639
5111
  */
3640
5112
  export const RegExp = /*#__PURE__*/instanceOf(globalThis.RegExp, {
@@ -3668,6 +5140,9 @@ export const RegExp = /*#__PURE__*/instanceOf(globalThis.RegExp, {
3668
5140
  }).map(flags => flags.join(""))).map(([source, flags]) => new globalThis.RegExp(source, flags)),
3669
5141
  toEquivalence: () => (a, b) => a.source === b.source && a.flags === b.flags
3670
5142
  });
5143
+ const URLString = /*#__PURE__*/String.annotate({
5144
+ expected: "a string that will be decoded as a URL"
5145
+ });
3671
5146
  /**
3672
5147
  * A schema for JavaScript `URL` objects.
3673
5148
  *
@@ -3687,9 +5162,7 @@ export const URL = /*#__PURE__*/instanceOf(globalThis.URL, {
3687
5162
  Type: `globalThis.URL`
3688
5163
  },
3689
5164
  expected: "URL",
3690
- toCodecJson: () => link()(String.annotate({
3691
- expected: "a string that will be decoded as a URL"
3692
- }), Transformation.urlFromString),
5165
+ toCodecJson: () => link()(URLString, Transformation.urlFromString),
3693
5166
  toArbitrary: () => fc => fc.webUrl().map(s => new globalThis.URL(s)),
3694
5167
  toEquivalence: () => (a, b) => a.toString() === b.toString()
3695
5168
  });
@@ -3705,15 +5178,27 @@ export const URL = /*#__PURE__*/instanceOf(globalThis.URL, {
3705
5178
  * @category URL
3706
5179
  * @since 4.0.0
3707
5180
  */
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
5181
+ export const URLFromString = /*#__PURE__*/URLString.pipe(/*#__PURE__*/decodeTo(URL, Transformation.urlFromString));
5182
+ const DateString = /*#__PURE__*/String.annotate({
5183
+ expected: "a string in ISO 8601 format that will be decoded as a Date"
5184
+ });
3711
5185
  /**
3712
5186
  * A schema for JavaScript `Date` objects.
3713
5187
  *
3714
5188
  * This schema accepts any `Date` instance, including invalid dates (e.g., `new
3715
- * Date("invalid")`). For validating only valid dates, use `ValidDate` instead.
5189
+ * Date("invalid")`). For validating only valid dates, use {@link DateValid}
5190
+ * instead. The default JSON serializer encodes `Date` as an ISO 8601 string.
5191
+ *
5192
+ * **Example** (Date schema)
5193
+ *
5194
+ * ```ts
5195
+ * import { Schema } from "effect"
3716
5196
  *
5197
+ * Schema.decodeUnknownSync(Schema.Date)(new Date("2024-01-01"))
5198
+ * // => Date { 2024-01-01T00:00:00.000Z }
5199
+ * ```
5200
+ *
5201
+ * @category Date
3717
5202
  * @since 4.0.0
3718
5203
  */
3719
5204
  export const Date = /*#__PURE__*/instanceOf(globalThis.Date, {
@@ -3725,29 +5210,49 @@ export const Date = /*#__PURE__*/instanceOf(globalThis.Date, {
3725
5210
  Type: `globalThis.Date`
3726
5211
  },
3727
5212
  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
- })),
5213
+ toCodecJson: () => link()(DateString, Transformation.dateFromString),
3734
5214
  toArbitrary: () => (fc, ctx) => fc.date(ctx?.constraints?.date)
3735
5215
  });
5216
+ /**
5217
+ * A transformation schema that parses an ISO 8601 string into a `Date`.
5218
+ *
5219
+ * Decoding:
5220
+ * - A `string` is decoded as a `Date`.
5221
+ *
5222
+ * Encoding:
5223
+ * - A `Date` is encoded as a `string`.
5224
+ *
5225
+ * @category Date
5226
+ * @since 4.0.0
5227
+ */
5228
+ export const DateFromString = /*#__PURE__*/DateString.pipe(/*#__PURE__*/decodeTo(Date, Transformation.dateFromString));
3736
5229
  /**
3737
5230
  * A schema for **valid** JavaScript `Date` objects.
3738
5231
  *
3739
5232
  * This schema accepts `Date` instances but rejects invalid dates (such as `new
3740
5233
  * Date("invalid")`).
3741
5234
  *
5235
+ * @category Date
3742
5236
  * @since 4.0.0
3743
5237
  */
3744
5238
  export const DateValid = /*#__PURE__*/Date.check(/*#__PURE__*/isDateValid());
3745
5239
  /**
3746
5240
  * A schema for `Duration` values.
3747
5241
  *
3748
- * **Default JSON serializer**
5242
+ * The default JSON serializer encodes `Duration` as a tagged object with the
5243
+ * duration type and value.
5244
+ *
5245
+ * **Example** (Duration schema)
5246
+ *
5247
+ * ```ts
5248
+ * import { Schema } from "effect"
5249
+ * import { Duration } from "effect"
5250
+ *
5251
+ * Schema.decodeUnknownSync(Schema.Duration)(Duration.seconds(5))
5252
+ * // => Duration(5s)
5253
+ * ```
3749
5254
  *
3750
- * - encodes `Duration` as a `string`
5255
+ * @category Duration
3751
5256
  *
3752
5257
  * @since 4.0.0
3753
5258
  */
@@ -3811,6 +5316,7 @@ export const Duration = /*#__PURE__*/declare(Duration_.isDuration, {
3811
5316
  toFormatter: () => globalThis.String,
3812
5317
  toEquivalence: () => Duration_.Equivalence
3813
5318
  });
5319
+ const bigint0 = /*#__PURE__*/globalThis.BigInt(0);
3814
5320
  /**
3815
5321
  * A transformation schema that decodes a non-negative `bigint` into a
3816
5322
  * `Duration`, treating the `bigint` value as the duration in nanoseconds.
@@ -3824,7 +5330,7 @@ export const Duration = /*#__PURE__*/declare(Duration_.isDuration, {
3824
5330
  * @category Duration
3825
5331
  * @since 4.0.0
3826
5332
  */
3827
- export const DurationFromNanos = /*#__PURE__*/BigInt.check(isGreaterThanOrEqualToBigInt(0n)).pipe(/*#__PURE__*/decodeTo(Duration, Transformation.durationFromNanos));
5333
+ export const DurationFromNanos = /*#__PURE__*/BigInt.check(isGreaterThanOrEqualToBigInt(bigint0)).pipe(/*#__PURE__*/decodeTo(Duration, Transformation.durationFromNanos));
3828
5334
  /**
3829
5335
  * A transformation schema that decodes a non-negative (possibly infinite)
3830
5336
  * integer into a `Duration`, treating the integer value as the duration in
@@ -3842,6 +5348,50 @@ export const DurationFromNanos = /*#__PURE__*/BigInt.check(isGreaterThanOrEqualT
3842
5348
  * @since 4.0.0
3843
5349
  */
3844
5350
  export const DurationFromMillis = /*#__PURE__*/Number.check(isGreaterThanOrEqualTo(0)).pipe(/*#__PURE__*/decodeTo(Duration, Transformation.durationFromMillis));
5351
+ const BigDecimalString = /*#__PURE__*/String.annotate({
5352
+ expected: "a string that will be decoded as a BigDecimal"
5353
+ });
5354
+ /**
5355
+ * A schema for `BigDecimal` values.
5356
+ *
5357
+ * **Default JSON serializer**
5358
+ *
5359
+ * - encodes `BigDecimal` as a `string`
5360
+ *
5361
+ * @category BigDecimal
5362
+ * @since 4.0.0
5363
+ */
5364
+ export const BigDecimal = /*#__PURE__*/declare(BigDecimal_.isBigDecimal, {
5365
+ typeConstructor: {
5366
+ _tag: "effect/BigDecimal"
5367
+ },
5368
+ generation: {
5369
+ runtime: `Schema.BigDecimal`,
5370
+ Type: `BigDecimal.BigDecimal`,
5371
+ importDeclaration: `import * as BigDecimal from "effect/BigDecimal"`
5372
+ },
5373
+ expected: "BigDecimal",
5374
+ toCodecJson: () => link()(BigDecimalString, Transformation.bigDecimalFromString),
5375
+ toArbitrary: () => fc => fc.tuple(fc.bigInt(), fc.integer({
5376
+ min: 0,
5377
+ max: 20
5378
+ })).map(([value, scale]) => BigDecimal_.make(value, scale)),
5379
+ toFormatter: () => bd => BigDecimal_.format(bd),
5380
+ toEquivalence: () => BigDecimal_.Equivalence
5381
+ });
5382
+ /**
5383
+ * A transformation schema that parses a string into a `BigDecimal`.
5384
+ *
5385
+ * Decoding:
5386
+ * - A `string` is decoded as a `BigDecimal`.
5387
+ *
5388
+ * Encoding:
5389
+ * - A `BigDecimal` is encoded as a `string`.
5390
+ *
5391
+ * @category BigDecimal
5392
+ * @since 4.0.0
5393
+ */
5394
+ export const BigDecimalFromString = /*#__PURE__*/BigDecimalString.pipe(/*#__PURE__*/decodeTo(BigDecimal, Transformation.bigDecimalFromString));
3845
5395
  /**
3846
5396
  * A transformation schema that decodes a JSON-encoded string into an `unknown` value.
3847
5397
  *
@@ -3862,6 +5412,7 @@ export const DurationFromMillis = /*#__PURE__*/Number.check(isGreaterThanOrEqual
3862
5412
  * // => { a: 1, b: 2 }
3863
5413
  * ```
3864
5414
  *
5415
+ * @category JSON
3865
5416
  * @since 4.0.0
3866
5417
  */
3867
5418
  export const UnknownFromJsonString = /*#__PURE__*/fromJsonString(Unknown);
@@ -3926,6 +5477,7 @@ export const UnknownFromJsonString = /*#__PURE__*/fromJsonString(Unknown);
3926
5477
  * // }
3927
5478
  * ```
3928
5479
  *
5480
+ * @category JSON
3929
5481
  * @since 4.0.0
3930
5482
  */
3931
5483
  export function fromJsonString(schema) {
@@ -3936,6 +5488,12 @@ export function fromJsonString(schema) {
3936
5488
  }).pipe(decodeTo(schema, Transformation.fromJsonString));
3937
5489
  }
3938
5490
  /**
5491
+ * Schema for JavaScript `File` objects.
5492
+ *
5493
+ * The default JSON serializer encodes a `File` as `{ data, type, name, lastModified }`
5494
+ * where `data` is base64-encoded.
5495
+ *
5496
+ * @category File
3939
5497
  * @since 4.0.0
3940
5498
  */
3941
5499
  export const File = /*#__PURE__*/instanceOf(globalThis.File, {
@@ -3953,7 +5511,7 @@ export const File = /*#__PURE__*/instanceOf(globalThis.File, {
3953
5511
  name: String,
3954
5512
  lastModified: Number
3955
5513
  }), Transformation.transformOrFail({
3956
- decode: e => Result_.match(Base64.decode(e.data), {
5514
+ decode: e => Result_.match(Encoding.decodeBase64(e.data), {
3957
5515
  onFailure: error => Effect.fail(new Issue.InvalidValue(Option_.some(e.data), {
3958
5516
  message: error.message
3959
5517
  })),
@@ -3969,7 +5527,7 @@ export const File = /*#__PURE__*/instanceOf(globalThis.File, {
3969
5527
  try: async () => {
3970
5528
  const bytes = new globalThis.Uint8Array(await file.arrayBuffer());
3971
5529
  return {
3972
- data: Base64.encode(bytes),
5530
+ data: Encoding.encodeBase64(bytes),
3973
5531
  type: file.type,
3974
5532
  name: file.name,
3975
5533
  lastModified: file.lastModified
@@ -3982,6 +5540,12 @@ export const File = /*#__PURE__*/instanceOf(globalThis.File, {
3982
5540
  }))
3983
5541
  });
3984
5542
  /**
5543
+ * Schema for JavaScript `FormData` objects.
5544
+ *
5545
+ * The default JSON serializer encodes a `FormData` as an array of `[key, entry]`
5546
+ * pairs where each entry is tagged as `"String"` or `"File"`.
5547
+ *
5548
+ * @category FormData
3985
5549
  * @since 4.0.0
3986
5550
  */
3987
5551
  export const FormData = /*#__PURE__*/instanceOf(globalThis.FormData, {
@@ -3993,7 +5557,7 @@ export const FormData = /*#__PURE__*/instanceOf(globalThis.FormData, {
3993
5557
  Type: `globalThis.FormData`
3994
5558
  },
3995
5559
  expected: "FormData",
3996
- toCodecJson: () => link()(Array(Tuple([String, Union([Struct({
5560
+ toCodecJson: () => link()(ArraySchema(Tuple([String, Union([Struct({
3997
5561
  _tag: tag("String"),
3998
5562
  value: String
3999
5563
  }), Struct({
@@ -4111,6 +5675,11 @@ export function fromFormData(schema) {
4111
5675
  return FormData.pipe(decodeTo(schema, Transformation.fromFormData));
4112
5676
  }
4113
5677
  /**
5678
+ * Schema for JavaScript `URLSearchParams` objects.
5679
+ *
5680
+ * The default JSON serializer encodes a `URLSearchParams` as a query string.
5681
+ *
5682
+ * @category URLSearchParams
4114
5683
  * @since 4.0.0
4115
5684
  */
4116
5685
  export const URLSearchParams = /*#__PURE__*/instanceOf(globalThis.URLSearchParams, {
@@ -4209,75 +5778,177 @@ export function fromURLSearchParams(schema) {
4209
5778
  /**
4210
5779
  * A schema for finite numbers, rejecting `NaN`, `Infinity`, and `-Infinity`.
4211
5780
  *
5781
+ * @category Number
4212
5782
  * @since 4.0.0
4213
5783
  */
4214
5784
  export const Finite = /*#__PURE__*/Number.check(/*#__PURE__*/isFinite());
4215
5785
  /**
4216
5786
  * A schema for integers, rejecting `NaN`, `Infinity`, and `-Infinity`.
4217
5787
  *
5788
+ * @category Number
5789
+ * @since 4.0.0
5790
+ */
5791
+ export const Int = /*#__PURE__*/Number.check(/*#__PURE__*/isInt());
5792
+ /**
5793
+ * A transformation schema that parses a string into a number.
5794
+ *
5795
+ * Decoding:
5796
+ * - A `string` is decoded as a finite number.
5797
+ *
5798
+ * Encoding:
5799
+ * - A number is encoded as a `string`.
5800
+ *
5801
+ * @category Number
5802
+ * @since 4.0.0
5803
+ */
5804
+ export const NumberFromString = /*#__PURE__*/String.annotate({
5805
+ expected: "a string that will be decoded as a number"
5806
+ }).pipe(/*#__PURE__*/decodeTo(Number, Transformation.numberFromString));
5807
+ /**
5808
+ * A transformation schema that parses a string into a finite number.
5809
+ *
5810
+ * Decoding:
5811
+ * - A `string` is decoded as a finite number, rejecting `NaN`, `Infinity`, and
5812
+ * `-Infinity` values.
5813
+ *
5814
+ * Encoding:
5815
+ * - A finite number is encoded as a `string`.
5816
+ *
5817
+ * @category Number
5818
+ * @since 4.0.0
5819
+ */
5820
+ export const FiniteFromString = /*#__PURE__*/String.annotate({
5821
+ expected: "a string that will be decoded as a finite number"
5822
+ }).pipe(/*#__PURE__*/decodeTo(Finite, Transformation.numberFromString));
5823
+ /**
5824
+ * A transformation schema that parses a string into a `bigint`.
5825
+ *
5826
+ * Decoding:
5827
+ * - A `string` is decoded as a `bigint`.
5828
+ *
5829
+ * Encoding:
5830
+ * - A `bigint` is encoded as a `string`.
5831
+ *
5832
+ * @category BigInt
5833
+ * @since 4.0.0
5834
+ */
5835
+ export const BigIntFromString = /*#__PURE__*/make(AST.bigIntString).pipe(/*#__PURE__*/decodeTo(BigInt, Transformation.bigintFromString));
5836
+ /**
5837
+ * A schema for strings that contains no leading or trailing whitespaces.
5838
+ *
5839
+ * @category String
5840
+ * @since 4.0.0
5841
+ */
5842
+ export const Trimmed = /*#__PURE__*/String.check(/*#__PURE__*/isTrimmed());
5843
+ /**
5844
+ * A transformation schema that trims whitespace from a string.
5845
+ *
5846
+ * Decoding:
5847
+ * - A `string` is decoded as a string with no leading or trailing whitespaces.
5848
+ *
5849
+ * Encoding:
5850
+ * - The trimmed string is encoded as is.
5851
+ *
5852
+ * @category String
4218
5853
  * @since 4.0.0
4219
5854
  */
4220
- export const Int = /*#__PURE__*/Number.check(/*#__PURE__*/isInt());
5855
+ export const Trim = /*#__PURE__*/String.annotate({
5856
+ expected: "a string that will be decoded as a trimmed string"
5857
+ }).pipe(/*#__PURE__*/decodeTo(Trimmed, /*#__PURE__*/Transformation.trim()));
4221
5858
  /**
4222
- * A transformation schema that parses a string into a number.
5859
+ * Decodes a base64 (RFC4648) encoded string into a UTF-8 string.
4223
5860
  *
4224
5861
  * Decoding:
4225
- * - A `string` is decoded as a finite number.
5862
+ * - A **valid** base64 encoded string is decoded as a UTF-8 `string`.
4226
5863
  *
4227
5864
  * Encoding:
4228
- * - A number is encoded as a `string`.
5865
+ * - A `string` is encoded as a base64-encoded string.
4229
5866
  *
5867
+ * @category String
4230
5868
  * @since 4.0.0
4231
5869
  */
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));
5870
+ export const StringFromBase64 = /*#__PURE__*/String.annotate({
5871
+ expected: "a base64 encoded string that will be decoded as a UTF-8 string"
5872
+ }).pipe(/*#__PURE__*/decodeTo(String, Transformation.stringFromBase64String));
4235
5873
  /**
4236
- * A transformation schema that parses a string into a finite number.
5874
+ * Decodes a base64 (URL) encoded string into a UTF-8 string.
4237
5875
  *
4238
5876
  * Decoding:
4239
- * - A `string` is decoded as a finite number, rejecting `NaN`, `Infinity`, and
4240
- * `-Infinity` values.
5877
+ * - A **valid** base64 (URL) encoded string is decoded as a UTF-8 `string`.
4241
5878
  *
4242
5879
  * Encoding:
4243
- * - A finite number is encoded as a `string`.
5880
+ * - A `string` is encoded as a base64 (URL) encoded string.
4244
5881
  *
5882
+ * @category String
4245
5883
  * @since 4.0.0
4246
5884
  */
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));
5885
+ export const StringFromBase64Url = /*#__PURE__*/String.annotate({
5886
+ expected: "a base64 (URL) encoded string that will be decoded as a UTF-8 string"
5887
+ }).pipe(/*#__PURE__*/decodeTo(String, Transformation.stringFromBase64UrlString));
4250
5888
  /**
4251
- * A schema for strings that contains no leading or trailing whitespaces.
5889
+ * Decodes a hex encoded string into a UTF-8 string.
5890
+ *
5891
+ * Decoding:
5892
+ * - A **valid** hex encoded string is decoded as a UTF-8 `string`.
5893
+ *
5894
+ * Encoding:
5895
+ * - A `string` is encoded as a hex string.
4252
5896
  *
5897
+ * @category String
4253
5898
  * @since 4.0.0
4254
5899
  */
4255
- export const Trimmed = /*#__PURE__*/String.check(/*#__PURE__*/isTrimmed());
5900
+ export const StringFromHex = /*#__PURE__*/String.annotate({
5901
+ expected: "a hex encoded string that will be decoded as a UTF-8 string"
5902
+ }).pipe(/*#__PURE__*/decodeTo(String, Transformation.stringFromHexString));
4256
5903
  /**
4257
- * A transformation schema that trims whitespace from a string.
5904
+ * Decodes a URI component encoded string into a UTF-8 string.
5905
+ * Can be used to store data in a URL.
4258
5906
  *
4259
5907
  * Decoding:
4260
- * - A `string` is decoded as a string with no leading or trailing whitespaces.
5908
+ * - A **valid** URI component encoded string is decoded as a UTF-8 `string`.
4261
5909
  *
4262
5910
  * Encoding:
4263
- * - The trimmed string is encoded as is.
5911
+ * - A `string` is encoded as a URI component encoded string.
5912
+ *
5913
+ * **Example**
5914
+ *
5915
+ * ```ts
5916
+ * import { Schema } from "effect"
4264
5917
  *
5918
+ * const PaginationSchema = Schema.Struct({
5919
+ * maxItemPerPage: Schema.Number,
5920
+ * page: Schema.Number
5921
+ * })
5922
+ *
5923
+ * const UrlSchema = Schema.StringFromUriComponent.pipe(
5924
+ * Schema.decodeTo(Schema.fromJsonString(PaginationSchema))
5925
+ * )
5926
+ *
5927
+ * console.log(Schema.encodeSync(UrlSchema)({ maxItemPerPage: 10, page: 1 }))
5928
+ * // %7B%22maxItemPerPage%22%3A10%2C%22page%22%3A1%7D
5929
+ * ```
5930
+ *
5931
+ * @category String
4265
5932
  * @since 4.0.0
4266
5933
  */
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()));
5934
+ export const StringFromUriComponent = /*#__PURE__*/String.annotate({
5935
+ expected: "a URI component encoded string that will be decoded as a UTF-8 string"
5936
+ }).pipe(/*#__PURE__*/decodeTo(String, Transformation.stringFromUriComponent));
4270
5937
  /**
5938
+ * A union schema for JavaScript property keys: `number | symbol | string`.
5939
+ *
5940
+ * @category PropertyKey
4271
5941
  * @since 4.0.0
4272
5942
  */
4273
5943
  export const PropertyKey = /*#__PURE__*/Union([Finite, Symbol, String]);
4274
5944
  /**
5945
+ * @category StandardSchema
4275
5946
  * @since 4.0.0
4276
5947
  */
4277
5948
  export const StandardSchemaV1FailureResult = /*#__PURE__*/Struct({
4278
- issues: /*#__PURE__*/Array(/*#__PURE__*/Struct({
5949
+ issues: /*#__PURE__*/ArraySchema(/*#__PURE__*/Struct({
4279
5950
  message: String,
4280
- path: /*#__PURE__*/optional(/*#__PURE__*/Array(/*#__PURE__*/Union([PropertyKey, /*#__PURE__*/Struct({
5951
+ path: /*#__PURE__*/optional(/*#__PURE__*/ArraySchema(/*#__PURE__*/Union([PropertyKey, /*#__PURE__*/Struct({
4281
5952
  key: PropertyKey
4282
5953
  })])))
4283
5954
  }))
@@ -4383,7 +6054,7 @@ export const Uint8ArrayFromHex = /*#__PURE__*/String.annotate({
4383
6054
  */
4384
6055
  export const DateTimeUtc = /*#__PURE__*/declare(u => DateTime.isDateTime(u) && DateTime.isUtc(u), {
4385
6056
  typeConstructor: {
4386
- _tag: "DateTime.Utc"
6057
+ _tag: "effect/DateTime.Utc"
4387
6058
  },
4388
6059
  generation: {
4389
6060
  runtime: `Schema.DateTimeUtc`,
@@ -4391,10 +6062,7 @@ export const DateTimeUtc = /*#__PURE__*/declare(u => DateTime.isDateTime(u) && D
4391
6062
  importDeclaration: `import * as DateTime from "effect/DateTime"`
4392
6063
  },
4393
6064
  expected: "DateTime.Utc",
4394
- toCodecJson: () => link()(String, {
4395
- decode: Getter.dateTimeUtcFromInput(),
4396
- encode: Getter.transform(DateTime.formatIso)
4397
- }),
6065
+ toCodecJson: () => link()(String, Transformation.dateTimeUtcFromString),
4398
6066
  toArbitrary: () => (fc, ctx) => fc.date({
4399
6067
  noInvalidDate: true,
4400
6068
  ...ctx?.constraints?.date
@@ -4434,10 +6102,7 @@ export const DateTimeUtcFromDate = /*#__PURE__*/DateValid.pipe(/*#__PURE__*/deco
4434
6102
  */
4435
6103
  export const DateTimeUtcFromString = /*#__PURE__*/String.annotate({
4436
6104
  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
- })));
6105
+ }).pipe(/*#__PURE__*/decodeTo(DateTimeUtc, Transformation.dateTimeUtcFromString));
4441
6106
  /**
4442
6107
  * A transformation schema that decodes a number into a `DateTime.Utc`.
4443
6108
  *
@@ -4454,29 +6119,184 @@ export const DateTimeUtcFromMillis = /*#__PURE__*/Number.pipe(/*#__PURE__*/decod
4454
6119
  decode: /*#__PURE__*/Getter.dateTimeUtcFromInput(),
4455
6120
  encode: /*#__PURE__*/Getter.transform(DateTime.toEpochMillis)
4456
6121
  }));
6122
+ /**
6123
+ * A schema for `DateTime.TimeZone.Offset` values.
6124
+ *
6125
+ * **Default JSON serializer**
6126
+ *
6127
+ * - encodes `DateTime.TimeZone.Offset` as a number (offset in milliseconds)
6128
+ *
6129
+ * @category DateTime
6130
+ * @since 4.0.0
6131
+ */
6132
+ export const TimeZoneOffset = /*#__PURE__*/declare(DateTime.isTimeZoneOffset, {
6133
+ typeConstructor: {
6134
+ _tag: "effect/DateTime.TimeZone.Offset"
6135
+ },
6136
+ generation: {
6137
+ runtime: `Schema.TimeZoneOffset`,
6138
+ Type: `DateTime.TimeZone.Offset`,
6139
+ importDeclaration: `import * as DateTime from "effect/DateTime"`
6140
+ },
6141
+ expected: "DateTime.TimeZone.Offset",
6142
+ toCodecJson: () => link()(Number, Transformation.timeZoneOffsetFromNumber),
6143
+ toArbitrary: () => fc => fc.integer({
6144
+ min: -12 * 60 * 60 * 1000,
6145
+ max: 14 * 60 * 60 * 1000
6146
+ }).map(n => DateTime.zoneMakeOffset(n)),
6147
+ toFormatter: () => tz => DateTime.zoneToString(tz),
6148
+ toEquivalence: () => (a, b) => a.offset === b.offset
6149
+ });
6150
+ const TimeZoneNamedString = /*#__PURE__*/String.annotate({
6151
+ expected: "an IANA time zone identifier"
6152
+ });
6153
+ /**
6154
+ * A schema for `DateTime.TimeZone.Named` values.
6155
+ *
6156
+ * **Default JSON serializer**
6157
+ *
6158
+ * - encodes `DateTime.TimeZone.Named` as a string (IANA time zone identifier)
6159
+ *
6160
+ * @category DateTime
6161
+ * @since 4.0.0
6162
+ */
6163
+ export const TimeZoneNamed = /*#__PURE__*/declare(DateTime.isTimeZoneNamed, {
6164
+ typeConstructor: {
6165
+ _tag: "effect/DateTime.TimeZone.Named"
6166
+ },
6167
+ generation: {
6168
+ runtime: `Schema.TimeZoneNamed`,
6169
+ Type: `DateTime.TimeZone.Named`,
6170
+ importDeclaration: `import * as DateTime from "effect/DateTime"`
6171
+ },
6172
+ expected: "DateTime.TimeZone.Named",
6173
+ toCodecJson: () => link()(TimeZoneNamedString, Transformation.timeZoneNamedFromString),
6174
+ toArbitrary: () => fc => fc.constantFrom(...["UTC", "Europe/London", "America/New_York", "Asia/Tokyo", "Australia/Sydney"].map(DateTime.zoneMakeNamedUnsafe)),
6175
+ toFormatter: () => tz => DateTime.zoneToString(tz),
6176
+ toEquivalence: () => (a, b) => a.id === b.id
6177
+ });
6178
+ /**
6179
+ * A transformation schema that parses an IANA time zone identifier string into a `DateTime.TimeZone.Named`.
6180
+ *
6181
+ * Decoding:
6182
+ * - A `string` is decoded as a `DateTime.TimeZone.Named`.
6183
+ *
6184
+ * Encoding:
6185
+ * - A `DateTime.TimeZone.Named` is encoded as a `string`.
6186
+ *
6187
+ * @category DateTime
6188
+ * @since 4.0.0
6189
+ */
6190
+ export const TimeZoneNamedFromString = /*#__PURE__*/TimeZoneNamedString.pipe(/*#__PURE__*/decodeTo(TimeZoneNamed, Transformation.timeZoneNamedFromString));
6191
+ const TimeZoneString = /*#__PURE__*/String.annotate({
6192
+ expected: "a time zone string (IANA identifier or offset like +03:00)"
6193
+ });
6194
+ /**
6195
+ * A schema for `DateTime.TimeZone` values.
6196
+ *
6197
+ * **Default JSON serializer**
6198
+ *
6199
+ * - encodes `DateTime.TimeZone` as a string (IANA identifier or offset like
6200
+ * `+03:00`)
6201
+ *
6202
+ * @category DateTime
6203
+ * @since 4.0.0
6204
+ */
6205
+ export const TimeZone = /*#__PURE__*/declare(DateTime.isTimeZone, {
6206
+ typeConstructor: {
6207
+ _tag: "effect/DateTime.TimeZone"
6208
+ },
6209
+ generation: {
6210
+ runtime: `Schema.TimeZone`,
6211
+ Type: `DateTime.TimeZone`,
6212
+ importDeclaration: `import * as DateTime from "effect/DateTime"`
6213
+ },
6214
+ expected: "DateTime.TimeZone",
6215
+ toCodecJson: () => link()(TimeZoneString, Transformation.timeZoneFromString),
6216
+ toArbitrary: () => fc => fc.oneof(fc.integer({
6217
+ min: -12 * 60 * 60 * 1000,
6218
+ max: 14 * 60 * 60 * 1000
6219
+ }).map(n => DateTime.zoneMakeOffset(n)), fc.constantFrom(...["UTC", "Europe/London", "America/New_York", "Asia/Tokyo", "Australia/Sydney"].map(DateTime.zoneMakeNamedUnsafe))),
6220
+ toFormatter: () => tz => DateTime.zoneToString(tz),
6221
+ toEquivalence: () => (a, b) => DateTime.zoneToString(a) === DateTime.zoneToString(b)
6222
+ });
6223
+ /**
6224
+ * A transformation schema that parses a time zone string into a `DateTime.TimeZone`.
6225
+ *
6226
+ * Decoding:
6227
+ * - A `string` (IANA identifier or offset like `+03:00`) is decoded as a `DateTime.TimeZone`.
6228
+ *
6229
+ * Encoding:
6230
+ * - A `DateTime.TimeZone` is encoded as a `string`.
6231
+ *
6232
+ * @category DateTime
6233
+ * @since 4.0.0
6234
+ */
6235
+ export const TimeZoneFromString = /*#__PURE__*/TimeZoneString.pipe(/*#__PURE__*/decodeTo(TimeZone, Transformation.timeZoneFromString));
6236
+ const DateTimeZonedString = /*#__PURE__*/String.annotate({
6237
+ expected: "a zoned DateTime string (e.g. 2024-01-01T00:00:00.000+00:00[Europe/London])"
6238
+ });
6239
+ /**
6240
+ * A schema for `DateTime.Zoned` values.
6241
+ *
6242
+ * **Default JSON serializer**
6243
+ *
6244
+ * - encodes `DateTime.Zoned` as a string in the format
6245
+ * `YYYY-MM-DDTHH:mm:ss.sss+HH:MM[Time/Zone]`
6246
+ *
6247
+ * @category DateTime
6248
+ * @since 4.0.0
6249
+ */
6250
+ export const DateTimeZoned = /*#__PURE__*/declare(u => DateTime.isDateTime(u) && DateTime.isZoned(u), {
6251
+ typeConstructor: {
6252
+ _tag: "effect/DateTime.Zoned"
6253
+ },
6254
+ generation: {
6255
+ runtime: `Schema.DateTimeZoned`,
6256
+ Type: `DateTime.Zoned`,
6257
+ importDeclaration: `import * as DateTime from "effect/DateTime"`
6258
+ },
6259
+ expected: "DateTime.Zoned",
6260
+ toCodecJson: () => link()(DateTimeZonedString, Transformation.dateTimeZonedFromString),
6261
+ toArbitrary: () => (fc, ctx) => fc.tuple(fc.date({
6262
+ noInvalidDate: true,
6263
+ min: new globalThis.Date(-8640000000000000 + 14 * 60 * 60 * 1000),
6264
+ max: new globalThis.Date(8640000000000000 - 14 * 60 * 60 * 1000),
6265
+ ...ctx?.constraints?.date
6266
+ }), fc.constantFrom("UTC", "Europe/London", "America/New_York", "Asia/Tokyo", "Australia/Sydney")).map(([date, zone]) => DateTime.makeZonedUnsafe(date, {
6267
+ timeZone: zone
6268
+ })),
6269
+ toFormatter: () => zoned => DateTime.formatIsoZoned(zoned),
6270
+ toEquivalence: () => DateTime.Equivalence
6271
+ });
6272
+ /**
6273
+ * A transformation schema that parses a zoned DateTime string into a `DateTime.Zoned`.
6274
+ *
6275
+ * Decoding:
6276
+ * - A `string` (e.g. `2024-01-01T00:00:00.000+00:00[Europe/London]`) is decoded as a `DateTime.Zoned`.
6277
+ *
6278
+ * Encoding:
6279
+ * - A `DateTime.Zoned` is encoded as a `string`.
6280
+ *
6281
+ * @category DateTime
6282
+ * @since 4.0.0
6283
+ */
6284
+ export const DateTimeZonedFromString = /*#__PURE__*/DateTimeZonedString.pipe(/*#__PURE__*/decodeTo(DateTimeZoned, Transformation.dateTimeZonedFromString));
4457
6285
  const immerable = /*#__PURE__*/globalThis.Symbol.for("immer-draftable");
4458
- function makeClass(Inherited, identifier, struct, annotations) {
6286
+ function makeClass(Inherited, identifier, struct, annotations, proto) {
4459
6287
  const getClassSchema = getClassSchemaFactory(struct, identifier, annotations);
4460
6288
  const ClassTypeId = getClassTypeId(identifier); // HMR support
4461
- return class extends Inherited {
6289
+ const out = class extends Inherited {
4462
6290
  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
- })})`;
6291
+ input = input ?? {};
6292
+ const validated = struct.make(input, options);
6293
+ super({
6294
+ ...input,
6295
+ ...validated
6296
+ }, {
6297
+ ...options,
6298
+ disableChecks: true
6299
+ });
4480
6300
  }
4481
6301
  static [TypeId] = TypeId;
4482
6302
  get [ClassTypeId]() {
@@ -4494,9 +6314,15 @@ function makeClass(Inherited, identifier, struct, annotations) {
4494
6314
  static rebuild(ast) {
4495
6315
  return getClassSchema(this).rebuild(ast);
4496
6316
  }
4497
- static makeUnsafe(input, options) {
6317
+ static make(input, options) {
4498
6318
  return new this(input, options);
4499
6319
  }
6320
+ static makeOption(input, options) {
6321
+ return Parser.makeOption(getClassSchema(this))(input ?? {}, options);
6322
+ }
6323
+ static makeEffect(input, options) {
6324
+ return Effect.mapErrorEager(Parser.makeEffect(getClassSchema(this))(input ?? {}, options), issue => new SchemaError(issue));
6325
+ }
4500
6326
  static annotate(annotations) {
4501
6327
  return this.rebuild(AST.annotate(this.ast, annotations));
4502
6328
  }
@@ -4514,13 +6340,17 @@ function makeClass(Inherited, identifier, struct, annotations) {
4514
6340
  };
4515
6341
  return makeClass(this, identifier, makeStruct(AST.struct(fields, struct.ast.checks, {
4516
6342
  identifier
4517
- }), fields), annotations);
6343
+ }), fields), annotations, proto);
4518
6344
  };
4519
6345
  }
4520
6346
  static mapFields(f, options) {
4521
6347
  return struct.mapFields(f, options);
4522
6348
  }
4523
6349
  };
6350
+ if (proto !== undefined) {
6351
+ Object.assign(out.prototype, proto(identifier));
6352
+ }
6353
+ return out;
4524
6354
  }
4525
6355
  function getClassTransformation(self) {
4526
6356
  return new Transformation.Transformation(Getter.transform(input => new self(input)), Getter.passthrough());
@@ -4541,6 +6371,7 @@ function getClassSchemaFactory(from, identifier, annotations) {
4541
6371
  toCodec: ([from]) => new AST.Link(from.ast, transformation),
4542
6372
  toArbitrary: ([from]) => () => from.map(args => new self(args)),
4543
6373
  toFormatter: ([from]) => t => `${self.identifier}(${from(t)})`,
6374
+ "~sentinels": AST.collectSentinels(from.ast),
4544
6375
  ...annotations
4545
6376
  }));
4546
6377
  memo = from.pipe(decodeTo(to, transformation));
@@ -4552,14 +6383,81 @@ function isStruct(schema) {
4552
6383
  return isSchema(schema);
4553
6384
  }
4554
6385
  /**
6386
+ * Creates a schema-backed class whose constructor validates input against a
6387
+ * {@link Struct} schema. Construction throws a {@link SchemaError} on invalid
6388
+ * input (unless `disableChecks` is set in the options).
6389
+ *
6390
+ * Pass the desired class type as the first type parameter. The second optional
6391
+ * type parameter can be used to add nominal brands.
6392
+ *
6393
+ * **Example** (Basic class)
6394
+ *
6395
+ * ```ts
6396
+ * import { Schema } from "effect"
6397
+ *
6398
+ * class Person extends Schema.Class<Person>("Person")({
6399
+ * name: Schema.String,
6400
+ * age: Schema.Number
6401
+ * }) {}
6402
+ *
6403
+ * const alice = new Person({ name: "Alice", age: 30 })
6404
+ * console.log(alice.name) // "Alice"
6405
+ * console.log(`${alice}`) // "Person({ name: Alice, age: 30 })"
6406
+ * ```
6407
+ *
6408
+ * **Example** (Extending a class)
6409
+ *
6410
+ * ```ts
6411
+ * import { Schema } from "effect"
6412
+ *
6413
+ * class Animal extends Schema.Class<Animal>("Animal")({
6414
+ * name: Schema.String
6415
+ * }) {}
6416
+ *
6417
+ * class Dog extends Animal.extend<Dog>("Dog")({
6418
+ * breed: Schema.String
6419
+ * }) {}
6420
+ *
6421
+ * const dog = new Dog({ name: "Rex", breed: "Labrador" })
6422
+ * console.log(dog.name) // "Rex"
6423
+ * console.log(dog.breed) // "Labrador"
6424
+ * ```
6425
+ *
4555
6426
  * @category Constructors
4556
6427
  * @since 4.0.0
4557
6428
  */
4558
6429
  export const Class = identifier => (schema, annotations) => {
4559
6430
  const struct = isStruct(schema) ? schema : Struct(schema);
4560
- return makeClass(Data.Class, identifier, struct, annotations);
6431
+ return makeClass(Data.Class, identifier, struct, annotations, identifier => ({
6432
+ toString() {
6433
+ return `${identifier}(${format({
6434
+ ...this
6435
+ })})`;
6436
+ }
6437
+ }));
4561
6438
  };
4562
6439
  /**
6440
+ * Like {@link Class} but automatically adds a `_tag` literal field set to the
6441
+ * given `tag` value. This makes instances compatible with tagged union
6442
+ * discrimination patterns.
6443
+ *
6444
+ * The optional `identifier` parameter overrides the schema identifier;
6445
+ * it defaults to the `tag` value.
6446
+ *
6447
+ * **Example** (Tagged class)
6448
+ *
6449
+ * ```ts
6450
+ * import { Schema } from "effect"
6451
+ *
6452
+ * class Circle extends Schema.TaggedClass<Circle>()("Circle", {
6453
+ * radius: Schema.Number
6454
+ * }) {}
6455
+ *
6456
+ * const c = new Circle({ radius: 5 })
6457
+ * console.log(c._tag) // "Circle"
6458
+ * console.log(c.radius) // 5
6459
+ * ```
6460
+ *
4563
6461
  * @category Constructors
4564
6462
  * @since 4.0.0
4565
6463
  */
@@ -4574,14 +6472,54 @@ export const TaggedClass = identifier => {
4574
6472
  };
4575
6473
  };
4576
6474
  /**
6475
+ * Creates a schema-backed error class that can be used as a typed,
6476
+ * yieldable error in Effect programs. Combines {@link Class} validation with
6477
+ * the `YieldableError` interface so instances can be yielded directly inside
6478
+ * `Effect.gen`.
6479
+ *
6480
+ * **Example** (Schema-backed error)
6481
+ *
6482
+ * ```ts
6483
+ * import { Effect, Schema } from "effect"
6484
+ *
6485
+ * class NotFound extends Schema.ErrorClass<NotFound>("NotFound")({
6486
+ * id: Schema.Number
6487
+ * }) {}
6488
+ *
6489
+ * const program = Effect.gen(function*() {
6490
+ * yield* new NotFound({ id: 1 })
6491
+ * })
6492
+ * ```
6493
+ *
4577
6494
  * @category Constructors
4578
6495
  * @since 4.0.0
4579
6496
  */
4580
6497
  export const ErrorClass = identifier => (schema, annotations) => {
4581
6498
  const struct = isStruct(schema) ? schema : Struct(schema);
4582
- return makeClass(core.Error, identifier, struct, annotations);
6499
+ const self = makeClass(core.Error, identifier, struct, annotations, identifier => ({
6500
+ name: identifier
6501
+ }));
6502
+ return self;
4583
6503
  };
4584
6504
  /**
6505
+ * Like {@link ErrorClass} but automatically adds a `_tag` literal field. The
6506
+ * resulting class is both a schema-validated, yieldable error and a tagged
6507
+ * union member.
6508
+ *
6509
+ * **Example** (Tagged error class)
6510
+ *
6511
+ * ```ts
6512
+ * import { Effect, Schema } from "effect"
6513
+ *
6514
+ * class NotFound extends Schema.TaggedErrorClass<NotFound>()("NotFound", {
6515
+ * id: Schema.Number
6516
+ * }) {}
6517
+ *
6518
+ * const program = Effect.gen(function*() {
6519
+ * yield* new NotFound({ id: 42 })
6520
+ * })
6521
+ * ```
6522
+ *
4585
6523
  * @category Constructors
4586
6524
  * @since 4.0.0
4587
6525
  */
@@ -4596,6 +6534,11 @@ export const TaggedErrorClass = identifier => {
4596
6534
  };
4597
6535
  };
4598
6536
  /**
6537
+ * Derives a {@link LazyArbitrary} from a schema. The result is memoized so
6538
+ * repeated calls with the same schema are cheap.
6539
+ *
6540
+ * Prefer {@link toArbitrary} when you just need the arbitrary directly.
6541
+ *
4599
6542
  * @category Arbitrary
4600
6543
  * @since 4.0.0
4601
6544
  */
@@ -4604,6 +6547,24 @@ export function toArbitraryLazy(schema) {
4604
6547
  return fc => lawc(fc, {});
4605
6548
  }
4606
6549
  /**
6550
+ * Derives a `fast-check` `Arbitrary` from a schema for property-based
6551
+ * testing. The derived arbitrary generates values that satisfy the schema.
6552
+ *
6553
+ * **Example** (Generating arbitrary values)
6554
+ *
6555
+ * ```ts
6556
+ * import { Schema } from "effect"
6557
+ * import * as FastCheck from "fast-check"
6558
+ *
6559
+ * const PersonArb = Schema.toArbitrary(
6560
+ * Schema.Struct({ name: Schema.String, age: Schema.Number })
6561
+ * )
6562
+ *
6563
+ * // Sample a random value
6564
+ * const sample = FastCheck.sample(PersonArb, 1)[0]
6565
+ * console.log(typeof sample.name) // "string"
6566
+ * ```
6567
+ *
4607
6568
  * @category Arbitrary
4608
6569
  * @since 4.0.0
4609
6570
  */
@@ -4630,6 +6591,13 @@ export function overrideToFormatter(toFormatter) {
4630
6591
  };
4631
6592
  }
4632
6593
  /**
6594
+ * Derives a string formatter function from a schema. The formatter converts
6595
+ * a value to its human-readable string representation, recursing into structs,
6596
+ * arrays, and unions.
6597
+ *
6598
+ * The optional `onBefore` hook lets you intercept specific AST nodes before
6599
+ * the default formatting logic runs.
6600
+ *
4633
6601
  * @category Formatter
4634
6602
  * @since 4.0.0
4635
6603
  */
@@ -4768,10 +6736,9 @@ export function toFormatter(schema, options) {
4768
6736
  // Equivalence
4769
6737
  // -----------------------------------------------------------------------------
4770
6738
  /**
4771
- * **Technical Note**
4772
- *
4773
- * This annotation cannot be added to `Annotations.Bottom` because it would make
4774
- * the schema invariant.
6739
+ * Overrides the equivalence derivation for a schema by supplying a custom
6740
+ * `Equivalence`. Use this when the default structural equivalence derived by
6741
+ * {@link toEquivalence} is not appropriate for a type.
4775
6742
  *
4776
6743
  * @category Equivalence
4777
6744
  * @since 4.0.0
@@ -4782,6 +6749,21 @@ export function overrideToEquivalence(toEquivalence) {
4782
6749
  });
4783
6750
  }
4784
6751
  /**
6752
+ * Derives an `Equivalence` from a schema. Two values are considered equal when
6753
+ * every field (and nested field) compares equal according to the schema
6754
+ * structure.
6755
+ *
6756
+ * **Example** (Struct equivalence)
6757
+ *
6758
+ * ```ts
6759
+ * import { Schema } from "effect"
6760
+ *
6761
+ * const eq = Schema.toEquivalence(Schema.Struct({ id: Schema.Number, name: Schema.String }))
6762
+ *
6763
+ * console.log(eq({ id: 1, name: "Alice" }, { id: 1, name: "Alice" })) // true
6764
+ * console.log(eq({ id: 1, name: "Alice" }, { id: 2, name: "Alice" })) // false
6765
+ * ```
6766
+ *
4785
6767
  * @category Equivalence
4786
6768
  * @since 4.0.0
4787
6769
  */
@@ -4792,6 +6774,10 @@ export function toEquivalence(schema) {
4792
6774
  // Representation
4793
6775
  // -----------------------------------------------------------------------------
4794
6776
  /**
6777
+ * Derives an intermediate `SchemaRepresentation.Document` from a schema. This
6778
+ * document is used internally by {@link toJsonSchemaDocument} and related
6779
+ * functions to produce JSON Schema output.
6780
+ *
4795
6781
  * @category Representation
4796
6782
  * @since 4.0.0
4797
6783
  */
@@ -4816,17 +6802,23 @@ export function toJsonSchemaDocument(schema, options) {
4816
6802
  };
4817
6803
  }
4818
6804
  // -----------------------------------------------------------------------------
4819
- // Serializer
6805
+ // Canonical Codecs
4820
6806
  // -----------------------------------------------------------------------------
4821
6807
  /**
4822
- * @category Serializer
6808
+ * Derives a canonical JSON codec from a schema. The encoded form is `unknown`
6809
+ * (any JSON-compatible value), decoded to the schema's `Type`.
6810
+ *
6811
+ * @category Canonical Codecs
4823
6812
  * @since 4.0.0
4824
6813
  */
4825
6814
  export function toCodecJson(schema) {
4826
6815
  return make(InternalToCodec.toCodecJson(schema.ast));
4827
6816
  }
4828
6817
  /**
4829
- * @category Serializer
6818
+ * Derives an isomorphism codec from a schema. The encoded form is the
6819
+ * schema's `Iso` type — the intermediate representation used for round-tripping.
6820
+ *
6821
+ * @category Canonical Codecs
4830
6822
  * @since 4.0.0
4831
6823
  */
4832
6824
  export function toCodecIso(schema) {
@@ -4840,7 +6832,11 @@ export function toCodecStringTree(schema, options) {
4840
6832
  }
4841
6833
  }
4842
6834
  /**
4843
- * @category Serializer
6835
+ * Derives an XML encoder from a codec. Encodes a value to an XML string by
6836
+ * first converting it through {@link toCodecStringTree}, then serializing the
6837
+ * resulting tree to XML.
6838
+ *
6839
+ * @category Canonical Codecs
4844
6840
  * @since 4.0.0
4845
6841
  */
4846
6842
  export function toEncoderXml(codec, options) {
@@ -4956,8 +6952,6 @@ function getStringTreePriority(ast) {
4956
6952
  const treeReorder = /*#__PURE__*/InternalToCodec.makeReorder(getStringTreePriority);
4957
6953
  function serializerTree(ast, recur, onMissingAnnotation) {
4958
6954
  switch (ast._tag) {
4959
- case "Unknown":
4960
- case "ObjectKeyword":
4961
6955
  case "Declaration":
4962
6956
  {
4963
6957
  const getLink = ast.annotations?.toCodecJson ?? ast.annotations?.toCodec;
@@ -4973,6 +6967,9 @@ function serializerTree(ast, recur, onMissingAnnotation) {
4973
6967
  return AST.replaceEncoding(ast, [nullToString]);
4974
6968
  case "Boolean":
4975
6969
  return AST.replaceEncoding(ast, [booleanToString]);
6970
+ case "Unknown":
6971
+ case "ObjectKeyword":
6972
+ return AST.replaceEncoding(ast, [AST.unknownToStringTree]);
4976
6973
  case "Enum":
4977
6974
  case "Number":
4978
6975
  case "Literal":
@@ -5051,6 +7048,9 @@ function onSerializerEnsureArray(ast) {
5051
7048
  // Optic APIs
5052
7049
  // -----------------------------------------------------------------------------
5053
7050
  /**
7051
+ * Derives an `Iso` optic from a schema that isomorphically converts between
7052
+ * the schema's `Type` and its `Iso` (intermediate / serialized form).
7053
+ *
5054
7054
  * @category Optic
5055
7055
  * @since 4.0.0
5056
7056
  */
@@ -5059,6 +7059,8 @@ export function toIso(schema) {
5059
7059
  return Optic_.makeIso(Parser.encodeSync(serializer), Parser.decodeSync(serializer));
5060
7060
  }
5061
7061
  /**
7062
+ * Returns an identity `Iso` over the schema's source (`Type`) side.
7063
+ *
5062
7064
  * @category Optic
5063
7065
  * @since 4.0.0
5064
7066
  */
@@ -5066,6 +7068,8 @@ export function toIsoSource(_) {
5066
7068
  return Optic_.id();
5067
7069
  }
5068
7070
  /**
7071
+ * Returns an identity `Iso` over the schema's focus (`Iso`) side.
7072
+ *
5069
7073
  * @category Optic
5070
7074
  * @since 4.0.0
5071
7075
  */
@@ -5073,10 +7077,11 @@ export function toIsoFocus(_) {
5073
7077
  return Optic_.id();
5074
7078
  }
5075
7079
  /**
5076
- * **Technical Note**
5077
- *
5078
- * This annotation cannot be added to `Annotations.Bottom` because it changes
5079
- * the schema type.
7080
+ * Overrides the ISO codec derivation for a schema by providing a target codec
7081
+ * and explicit `decode`/`encode` getters. The resulting schema carries a
7082
+ * custom `Iso` type, which changes the schema's type parameter — use
7083
+ * {@link overrideToCodecIso} when the default ISO transformation is not
7084
+ * appropriate.
5080
7085
  *
5081
7086
  * @category Optic
5082
7087
  * @since 4.0.0
@@ -5094,11 +7099,15 @@ export function overrideToCodecIso(to, transformation) {
5094
7099
  // Differ APIs
5095
7100
  // -----------------------------------------------------------------------------
5096
7101
  /**
7102
+ * Derives a JSON Patch differ from a codec. Serializes values to JSON (via
7103
+ * {@link toCodecJson}), computes RFC 6902 JSON Patch operations between old
7104
+ * and new values, and can apply patches back to the typed value.
7105
+ *
5097
7106
  * @category JsonPatch
5098
7107
  * @since 4.0.0
5099
7108
  */
5100
7109
  export function toDifferJsonPatch(schema) {
5101
- const serializer = toCodecJson(schema); // TODO: remove this cast
7110
+ const serializer = toCodecJson(schema);
5102
7111
  const get = Parser.encodeSync(serializer);
5103
7112
  const set = Parser.decodeSync(serializer);
5104
7113
  return {
@@ -5113,43 +7122,66 @@ export function toDifferJsonPatch(schema) {
5113
7122
  };
5114
7123
  }
5115
7124
  /**
7125
+ * Creates a recursive schema for a {@link Tree} of values described by `node`.
7126
+ * The resulting schema accepts a single node value, an array of trees, or an
7127
+ * object whose values are trees.
7128
+ *
5116
7129
  * @category Tree
5117
7130
  * @since 4.0.0
5118
7131
  */
5119
7132
  export function Tree(node) {
5120
7133
  const Tree$ref = suspend(() => Tree);
5121
- const Tree = Union([node, Array(Tree$ref), Record(String, Tree$ref)]);
7134
+ const Tree = Union([node, ArraySchema(Tree$ref), Record(String, Tree$ref)]);
5122
7135
  return Tree;
5123
7136
  }
5124
7137
  /**
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
- /**
7138
+ * Schema that accepts and validates any immutable JSON-compatible value.
7139
+ *
7140
+ * **Example** (Validating a JSON value)
7141
+ *
7142
+ * ```ts
7143
+ * import { Schema } from "effect"
7144
+ *
7145
+ * const result = Schema.decodeUnknownOption(Schema.Json)({ key: [1, true, null] })
7146
+ * console.log(result._tag) // "Some"
7147
+ * ```
7148
+ *
5134
7149
  * @category JSON
5135
7150
  * @since 4.0.0
5136
7151
  */
5137
- export const Json = /*#__PURE__*/Tree(/*#__PURE__*/Union([Null, Number, Boolean, String]));
7152
+ export const Json = /*#__PURE__*/make(AST.Json);
5138
7153
  /**
7154
+ * Schema that accepts any mutable JSON-compatible value. See {@link Json} for
7155
+ * the immutable variant.
7156
+ *
5139
7157
  * @category JSON
5140
7158
  * @since 4.0.0
5141
7159
  */
5142
- export const MutableJson = /*#__PURE__*/MutableTree(/*#__PURE__*/Union([Null, Number, Boolean, String]));
7160
+ export const MutableJson = /*#__PURE__*/make(AST.MutableJson);
5143
7161
  // -----------------------------------------------------------------------------
5144
7162
  // Annotations
5145
7163
  // -----------------------------------------------------------------------------
5146
7164
  /**
5147
- * Return all the typed annotations from the schema.
7165
+ * Resolves the typed annotations from a schema. The term "resolve" (rather
7166
+ * than "get") reflects the lookup strategy: if the schema has checks, the
7167
+ * annotations are taken from the last check; otherwise they are taken from
7168
+ * the base schema instance.
5148
7169
  *
5149
7170
  * @category Schema Resolvers
5150
7171
  * @since 4.0.0
5151
7172
  */
5152
- export function resolveInto(schema) {
7173
+ export function resolveAnnotations(schema) {
5153
7174
  return InternalAnnotations.resolve(schema.ast);
5154
7175
  }
7176
+ /**
7177
+ * Resolves the context (key-level) annotations from a schema. Context
7178
+ * annotations are those attached via `annotateKey` and live on the AST's
7179
+ * `context` rather than on the schema node itself.
7180
+ *
7181
+ * @category Schema Resolvers
7182
+ * @since 4.0.0
7183
+ */
7184
+ export function resolveAnnotationsKey(schema) {
7185
+ return schema.ast.context?.annotations;
7186
+ }
5155
7187
  //# sourceMappingURL=Schema.js.map