effect 4.0.0-rc.111 → 4.0.0-rc.113

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 (1293) hide show
  1. package/AGENTS.md +24 -9
  2. package/CLAUDE.md +24 -9
  3. package/ai-docs/package.json +2 -2
  4. package/ai-docs/src/01_effect/01_basics/02_effect-fn.ts +18 -5
  5. package/ai-docs/src/01_effect/01_basics/index.md +5 -3
  6. package/ai-docs/src/01_effect/03_services/20_layer-composition.ts +1 -1
  7. package/ai-docs/src/01_effect/03_services/20_layer-unwrap.ts +2 -2
  8. package/ai-docs/src/01_effect/05_resources/10_acquire-release.ts +2 -2
  9. package/ai-docs/src/03_stream/30_encoding.ts +5 -7
  10. package/ai-docs/src/08_observability/10_logging.ts +1 -1
  11. package/ai-docs/src/70_cli/10_basics.ts +7 -7
  12. package/ai-docs/src/71_ai/10_language-model.ts +2 -2
  13. package/ai-docs/src/71_ai/20_tools.ts +1 -1
  14. package/ai-docs/src/71_ai/30_chat.ts +1 -1
  15. package/dist/Array.d.ts +109 -52
  16. package/dist/Array.d.ts.map +1 -1
  17. package/dist/Array.js +65 -32
  18. package/dist/Array.js.map +1 -1
  19. package/dist/BigDecimal.d.ts +5 -1
  20. package/dist/BigDecimal.d.ts.map +1 -1
  21. package/dist/BigDecimal.js +40 -23
  22. package/dist/BigDecimal.js.map +1 -1
  23. package/dist/ByteSize.d.ts +633 -0
  24. package/dist/ByteSize.d.ts.map +1 -0
  25. package/dist/ByteSize.js +524 -0
  26. package/dist/ByteSize.js.map +1 -0
  27. package/dist/Cache.d.ts.map +1 -1
  28. package/dist/Cache.js +17 -3
  29. package/dist/Cache.js.map +1 -1
  30. package/dist/Cause.d.ts +1 -1
  31. package/dist/Cause.d.ts.map +1 -1
  32. package/dist/Channel.d.ts +97 -24
  33. package/dist/Channel.d.ts.map +1 -1
  34. package/dist/Channel.js +68 -41
  35. package/dist/Channel.js.map +1 -1
  36. package/dist/Chunk.d.ts +49 -28
  37. package/dist/Chunk.d.ts.map +1 -1
  38. package/dist/Chunk.js +27 -18
  39. package/dist/Chunk.js.map +1 -1
  40. package/dist/Config.d.ts +162 -201
  41. package/dist/Config.d.ts.map +1 -1
  42. package/dist/Config.js +103 -212
  43. package/dist/Config.js.map +1 -1
  44. package/dist/ConfigProvider.d.ts +4 -4
  45. package/dist/ConfigProvider.d.ts.map +1 -1
  46. package/dist/ConfigProvider.js +7 -7
  47. package/dist/ConfigProvider.js.map +1 -1
  48. package/dist/Context.d.ts +31 -0
  49. package/dist/Context.d.ts.map +1 -1
  50. package/dist/Context.js.map +1 -1
  51. package/dist/Cron.d.ts +2 -2
  52. package/dist/Cron.d.ts.map +1 -1
  53. package/dist/Cron.js +2 -2
  54. package/dist/Cron.js.map +1 -1
  55. package/dist/Crypto.d.ts +1 -1
  56. package/dist/Crypto.d.ts.map +1 -1
  57. package/dist/Crypto.js +3 -2
  58. package/dist/Crypto.js.map +1 -1
  59. package/dist/DateTime.d.ts +2 -2
  60. package/dist/DateTime.d.ts.map +1 -1
  61. package/dist/Deferred.d.ts.map +1 -1
  62. package/dist/Deferred.js +6 -6
  63. package/dist/Deferred.js.map +1 -1
  64. package/dist/Duration.d.ts +1 -1
  65. package/dist/Duration.d.ts.map +1 -1
  66. package/dist/Duration.js +1 -1
  67. package/dist/Duration.js.map +1 -1
  68. package/dist/Effect.d.ts +220 -113
  69. package/dist/Effect.d.ts.map +1 -1
  70. package/dist/Effect.js +27 -26
  71. package/dist/Effect.js.map +1 -1
  72. package/dist/Effectable.d.ts +58 -2
  73. package/dist/Effectable.d.ts.map +1 -1
  74. package/dist/Effectable.js +58 -6
  75. package/dist/Effectable.js.map +1 -1
  76. package/dist/Encoding.d.ts +3 -1
  77. package/dist/Encoding.d.ts.map +1 -1
  78. package/dist/Encoding.js +40 -10
  79. package/dist/Encoding.js.map +1 -1
  80. package/dist/Equal.d.ts +1 -1
  81. package/dist/Equal.d.ts.map +1 -1
  82. package/dist/Equal.js +1 -1
  83. package/dist/Equal.js.map +1 -1
  84. package/dist/ExecutionPlan.d.ts.map +1 -1
  85. package/dist/ExecutionPlan.js +1 -0
  86. package/dist/ExecutionPlan.js.map +1 -1
  87. package/dist/Fiber.d.ts +32 -8
  88. package/dist/Fiber.d.ts.map +1 -1
  89. package/dist/Fiber.js.map +1 -1
  90. package/dist/FiberHandle.js +3 -3
  91. package/dist/FiberHandle.js.map +1 -1
  92. package/dist/FiberMap.d.ts +12 -6
  93. package/dist/FiberMap.d.ts.map +1 -1
  94. package/dist/FiberMap.js +11 -6
  95. package/dist/FiberMap.js.map +1 -1
  96. package/dist/FileSystem.d.ts +42 -210
  97. package/dist/FileSystem.d.ts.map +1 -1
  98. package/dist/FileSystem.js +16 -148
  99. package/dist/FileSystem.js.map +1 -1
  100. package/dist/Formatter.d.ts +1 -0
  101. package/dist/Formatter.d.ts.map +1 -1
  102. package/dist/Formatter.js +19 -3
  103. package/dist/Formatter.js.map +1 -1
  104. package/dist/Graph.d.ts +48 -20
  105. package/dist/Graph.d.ts.map +1 -1
  106. package/dist/Graph.js +20 -5
  107. package/dist/Graph.js.map +1 -1
  108. package/dist/Hash.d.ts +1 -1
  109. package/dist/Hash.d.ts.map +1 -1
  110. package/dist/Hash.js +5 -14
  111. package/dist/Hash.js.map +1 -1
  112. package/dist/HashMap.d.ts +1 -1
  113. package/dist/HashMap.d.ts.map +1 -1
  114. package/dist/HashRing.d.ts +6 -1
  115. package/dist/HashRing.d.ts.map +1 -1
  116. package/dist/HashRing.js +9 -2
  117. package/dist/HashRing.js.map +1 -1
  118. package/dist/HashSet.d.ts +1 -1
  119. package/dist/HashSet.d.ts.map +1 -1
  120. package/dist/HashSet.js.map +1 -1
  121. package/dist/Iterable.d.ts +56 -17
  122. package/dist/Iterable.d.ts.map +1 -1
  123. package/dist/Iterable.js +65 -45
  124. package/dist/Iterable.js.map +1 -1
  125. package/dist/JsonPatch.js +4 -4
  126. package/dist/JsonPatch.js.map +1 -1
  127. package/dist/JsonPointer.d.ts +68 -4
  128. package/dist/JsonPointer.d.ts.map +1 -1
  129. package/dist/JsonPointer.js +90 -4
  130. package/dist/JsonPointer.js.map +1 -1
  131. package/dist/JsonSchema.d.ts +67 -94
  132. package/dist/JsonSchema.d.ts.map +1 -1
  133. package/dist/JsonSchema.js +752 -397
  134. package/dist/JsonSchema.js.map +1 -1
  135. package/dist/Layer.d.ts +47 -4
  136. package/dist/Layer.d.ts.map +1 -1
  137. package/dist/Layer.js +4 -6
  138. package/dist/Layer.js.map +1 -1
  139. package/dist/LayerMap.d.ts +24 -3
  140. package/dist/LayerMap.d.ts.map +1 -1
  141. package/dist/LayerMap.js +9 -5
  142. package/dist/LayerMap.js.map +1 -1
  143. package/dist/LayerRef.d.ts.map +1 -1
  144. package/dist/LayerRef.js +7 -5
  145. package/dist/LayerRef.js.map +1 -1
  146. package/dist/Logger.d.ts +114 -9
  147. package/dist/Logger.d.ts.map +1 -1
  148. package/dist/Logger.js +109 -9
  149. package/dist/Logger.js.map +1 -1
  150. package/dist/ManagedRuntime.js +1 -1
  151. package/dist/ManagedRuntime.js.map +1 -1
  152. package/dist/Match.d.ts +43 -31
  153. package/dist/Match.d.ts.map +1 -1
  154. package/dist/Match.js +5 -2
  155. package/dist/Match.js.map +1 -1
  156. package/dist/Metric.d.ts +11 -4
  157. package/dist/Metric.d.ts.map +1 -1
  158. package/dist/Metric.js +14 -18
  159. package/dist/Metric.js.map +1 -1
  160. package/dist/MutableHashMap.d.ts +1 -1
  161. package/dist/MutableHashMap.d.ts.map +1 -1
  162. package/dist/MutableHashMap.js +1 -1
  163. package/dist/MutableHashMap.js.map +1 -1
  164. package/dist/MutableHashSet.d.ts +1 -1
  165. package/dist/MutableHashSet.d.ts.map +1 -1
  166. package/dist/MutableHashSet.js +1 -1
  167. package/dist/MutableHashSet.js.map +1 -1
  168. package/dist/MutableList.d.ts +13 -2
  169. package/dist/MutableList.d.ts.map +1 -1
  170. package/dist/MutableList.js +18 -2
  171. package/dist/MutableList.js.map +1 -1
  172. package/dist/Number.d.ts +6 -0
  173. package/dist/Number.d.ts.map +1 -1
  174. package/dist/Number.js +3 -1
  175. package/dist/Number.js.map +1 -1
  176. package/dist/Optic.d.ts.map +1 -1
  177. package/dist/Optic.js +5 -4
  178. package/dist/Optic.js.map +1 -1
  179. package/dist/Option.d.ts +1 -1
  180. package/dist/Option.d.ts.map +1 -1
  181. package/dist/Option.js +1 -1
  182. package/dist/Option.js.map +1 -1
  183. package/dist/Order.d.ts +1 -0
  184. package/dist/Order.d.ts.map +1 -1
  185. package/dist/Order.js +3 -1
  186. package/dist/Order.js.map +1 -1
  187. package/dist/PartitionedSemaphore.d.ts.map +1 -1
  188. package/dist/PartitionedSemaphore.js +1 -2
  189. package/dist/PartitionedSemaphore.js.map +1 -1
  190. package/dist/Path.d.ts +1 -1
  191. package/dist/Path.d.ts.map +1 -1
  192. package/dist/Path.js +1 -1
  193. package/dist/Path.js.map +1 -1
  194. package/dist/PlatformError.d.ts +1 -1
  195. package/dist/PlatformError.d.ts.map +1 -1
  196. package/dist/PlatformError.js +1 -1
  197. package/dist/PlatformError.js.map +1 -1
  198. package/dist/Pool.d.ts +137 -10
  199. package/dist/Pool.d.ts.map +1 -1
  200. package/dist/Pool.js +332 -75
  201. package/dist/Pool.js.map +1 -1
  202. package/dist/PrimaryKey.d.ts +1 -1
  203. package/dist/PrimaryKey.d.ts.map +1 -1
  204. package/dist/PrimaryKey.js +1 -1
  205. package/dist/PrimaryKey.js.map +1 -1
  206. package/dist/PubSub.d.ts +21 -9
  207. package/dist/PubSub.d.ts.map +1 -1
  208. package/dist/PubSub.js +18 -14
  209. package/dist/PubSub.js.map +1 -1
  210. package/dist/Queue.d.ts +82 -6
  211. package/dist/Queue.d.ts.map +1 -1
  212. package/dist/Queue.js +116 -27
  213. package/dist/Queue.js.map +1 -1
  214. package/dist/Random.d.ts +17 -4
  215. package/dist/Random.d.ts.map +1 -1
  216. package/dist/Random.js +1 -1
  217. package/dist/Random.js.map +1 -1
  218. package/dist/RcMap.d.ts +137 -0
  219. package/dist/RcMap.d.ts.map +1 -1
  220. package/dist/RcMap.js +72 -9
  221. package/dist/RcMap.js.map +1 -1
  222. package/dist/Record.d.ts +13 -0
  223. package/dist/Record.d.ts.map +1 -1
  224. package/dist/Record.js.map +1 -1
  225. package/dist/Redacted.d.ts +1 -1
  226. package/dist/Redacted.d.ts.map +1 -1
  227. package/dist/Redacted.js +1 -1
  228. package/dist/Redacted.js.map +1 -1
  229. package/dist/RequestResolver.d.ts +15 -9
  230. package/dist/RequestResolver.d.ts.map +1 -1
  231. package/dist/RequestResolver.js +33 -15
  232. package/dist/RequestResolver.js.map +1 -1
  233. package/dist/Result.d.ts +1 -1
  234. package/dist/Result.d.ts.map +1 -1
  235. package/dist/Result.js +1 -1
  236. package/dist/Result.js.map +1 -1
  237. package/dist/Scheduler.d.ts.map +1 -1
  238. package/dist/Scheduler.js +19 -10
  239. package/dist/Scheduler.js.map +1 -1
  240. package/dist/Schema.d.ts +2200 -2433
  241. package/dist/Schema.d.ts.map +1 -1
  242. package/dist/Schema.js +2797 -4184
  243. package/dist/Schema.js.map +1 -1
  244. package/dist/SchemaAST.d.ts +359 -176
  245. package/dist/SchemaAST.d.ts.map +1 -1
  246. package/dist/SchemaAST.js +373 -630
  247. package/dist/SchemaAST.js.map +1 -1
  248. package/dist/SchemaGetter.d.ts +46 -22
  249. package/dist/SchemaGetter.d.ts.map +1 -1
  250. package/dist/SchemaGetter.js +56 -53
  251. package/dist/SchemaGetter.js.map +1 -1
  252. package/dist/SchemaIssue.d.ts +123 -200
  253. package/dist/SchemaIssue.d.ts.map +1 -1
  254. package/dist/SchemaIssue.js +59 -263
  255. package/dist/SchemaIssue.js.map +1 -1
  256. package/dist/SchemaParser.js +2 -9
  257. package/dist/SchemaParser.js.map +1 -1
  258. package/dist/SchemaRepresentation.d.ts +1276 -172
  259. package/dist/SchemaRepresentation.d.ts.map +1 -1
  260. package/dist/SchemaRepresentation.js +1371 -29
  261. package/dist/SchemaRepresentation.js.map +1 -1
  262. package/dist/SchemaTransformation.d.ts +49 -16
  263. package/dist/SchemaTransformation.d.ts.map +1 -1
  264. package/dist/SchemaTransformation.js +75 -98
  265. package/dist/SchemaTransformation.js.map +1 -1
  266. package/dist/Scope.d.ts +9 -2
  267. package/dist/Scope.d.ts.map +1 -1
  268. package/dist/Scope.js.map +1 -1
  269. package/dist/ScopedCache.d.ts.map +1 -1
  270. package/dist/ScopedCache.js +10 -3
  271. package/dist/ScopedCache.js.map +1 -1
  272. package/dist/Sink.d.ts +9 -4
  273. package/dist/Sink.d.ts.map +1 -1
  274. package/dist/Sink.js +49 -31
  275. package/dist/Sink.js.map +1 -1
  276. package/dist/StandardSchema.d.ts +125 -0
  277. package/dist/StandardSchema.d.ts.map +1 -0
  278. package/dist/StandardSchema.js +9 -0
  279. package/dist/StandardSchema.js.map +1 -0
  280. package/dist/Stream.d.ts +221 -35
  281. package/dist/Stream.d.ts.map +1 -1
  282. package/dist/Stream.js +168 -84
  283. package/dist/Stream.js.map +1 -1
  284. package/dist/String.d.ts +16 -6
  285. package/dist/String.d.ts.map +1 -1
  286. package/dist/String.js +12 -5
  287. package/dist/String.js.map +1 -1
  288. package/dist/Struct.d.ts.map +1 -1
  289. package/dist/Struct.js +7 -4
  290. package/dist/Struct.js.map +1 -1
  291. package/dist/SynchronizedRef.d.ts +3 -2
  292. package/dist/SynchronizedRef.d.ts.map +1 -1
  293. package/dist/SynchronizedRef.js.map +1 -1
  294. package/dist/Terminal.d.ts +3 -3
  295. package/dist/Terminal.d.ts.map +1 -1
  296. package/dist/Terminal.js +3 -3
  297. package/dist/Terminal.js.map +1 -1
  298. package/dist/Tracer.d.ts +27 -7
  299. package/dist/Tracer.d.ts.map +1 -1
  300. package/dist/Tracer.js +38 -13
  301. package/dist/Tracer.js.map +1 -1
  302. package/dist/Trie.d.ts +1 -1
  303. package/dist/Trie.d.ts.map +1 -1
  304. package/dist/Tuple.d.ts +2 -1
  305. package/dist/Tuple.d.ts.map +1 -1
  306. package/dist/Tuple.js.map +1 -1
  307. package/dist/TxChunk.d.ts +1 -1
  308. package/dist/TxChunk.d.ts.map +1 -1
  309. package/dist/TxChunk.js +1 -1
  310. package/dist/TxChunk.js.map +1 -1
  311. package/dist/TxDeferred.d.ts +1 -1
  312. package/dist/TxDeferred.d.ts.map +1 -1
  313. package/dist/TxDeferred.js +1 -1
  314. package/dist/TxDeferred.js.map +1 -1
  315. package/dist/TxHashMap.d.ts +1 -1
  316. package/dist/TxHashMap.d.ts.map +1 -1
  317. package/dist/TxHashMap.js +1 -1
  318. package/dist/TxHashMap.js.map +1 -1
  319. package/dist/TxHashSet.d.ts +1 -1
  320. package/dist/TxHashSet.d.ts.map +1 -1
  321. package/dist/TxHashSet.js +1 -1
  322. package/dist/TxHashSet.js.map +1 -1
  323. package/dist/TxPriorityQueue.d.ts +1 -1
  324. package/dist/TxPriorityQueue.d.ts.map +1 -1
  325. package/dist/TxPriorityQueue.js +1 -1
  326. package/dist/TxPriorityQueue.js.map +1 -1
  327. package/dist/TxPubSub.d.ts +1 -1
  328. package/dist/TxPubSub.d.ts.map +1 -1
  329. package/dist/TxPubSub.js +1 -1
  330. package/dist/TxPubSub.js.map +1 -1
  331. package/dist/TxQueue.d.ts +9 -9
  332. package/dist/TxQueue.d.ts.map +1 -1
  333. package/dist/TxQueue.js +93 -86
  334. package/dist/TxQueue.js.map +1 -1
  335. package/dist/TxReentrantLock.d.ts +29 -1
  336. package/dist/TxReentrantLock.d.ts.map +1 -1
  337. package/dist/TxReentrantLock.js +29 -1
  338. package/dist/TxReentrantLock.js.map +1 -1
  339. package/dist/TxRef.d.ts +1 -1
  340. package/dist/TxRef.d.ts.map +1 -1
  341. package/dist/TxRef.js +1 -1
  342. package/dist/TxRef.js.map +1 -1
  343. package/dist/TxSemaphore.d.ts +1 -1
  344. package/dist/TxSemaphore.d.ts.map +1 -1
  345. package/dist/TxSemaphore.js +1 -1
  346. package/dist/TxSemaphore.js.map +1 -1
  347. package/dist/TxSubscriptionRef.d.ts +1 -1
  348. package/dist/TxSubscriptionRef.d.ts.map +1 -1
  349. package/dist/TxSubscriptionRef.js +1 -1
  350. package/dist/TxSubscriptionRef.js.map +1 -1
  351. package/dist/Types.d.ts +33 -19
  352. package/dist/Types.d.ts.map +1 -1
  353. package/dist/Utils.d.ts.map +1 -1
  354. package/dist/Utils.js +2 -1
  355. package/dist/Utils.js.map +1 -1
  356. package/dist/index.d.ts +8 -0
  357. package/dist/index.d.ts.map +1 -1
  358. package/dist/index.js +8 -0
  359. package/dist/index.js.map +1 -1
  360. package/dist/internal/arbitrary/model.d.ts +2 -0
  361. package/dist/internal/arbitrary/model.d.ts.map +1 -0
  362. package/dist/internal/arbitrary/model.js +495 -0
  363. package/dist/internal/arbitrary/model.js.map +1 -0
  364. package/dist/internal/arbitrary/regexp.d.ts +2 -0
  365. package/dist/internal/arbitrary/regexp.d.ts.map +1 -0
  366. package/dist/internal/arbitrary/regexp.js +789 -0
  367. package/dist/internal/arbitrary/regexp.js.map +1 -0
  368. package/dist/internal/arbitrary/runner.d.ts +2 -0
  369. package/dist/internal/arbitrary/runner.d.ts.map +1 -0
  370. package/dist/internal/arbitrary/runner.js +496 -0
  371. package/dist/internal/arbitrary/runner.js.map +1 -0
  372. package/dist/internal/arbitrary/schema.d.ts.map +1 -0
  373. package/dist/internal/arbitrary/schema.js +1340 -0
  374. package/dist/internal/arbitrary/schema.js.map +1 -0
  375. package/dist/internal/core.js +27 -13
  376. package/dist/internal/core.js.map +1 -1
  377. package/dist/internal/count.d.ts +2 -0
  378. package/dist/internal/count.d.ts.map +1 -0
  379. package/dist/internal/count.js +14 -0
  380. package/dist/internal/count.js.map +1 -0
  381. package/dist/internal/dateTime.js +4 -10
  382. package/dist/internal/dateTime.js.map +1 -1
  383. package/dist/internal/effect.js +416 -258
  384. package/dist/internal/effect.js.map +1 -1
  385. package/dist/internal/graph.js +3 -1
  386. package/dist/internal/graph.js.map +1 -1
  387. package/dist/internal/hashMap.js +5 -3
  388. package/dist/internal/hashMap.js.map +1 -1
  389. package/dist/internal/hashSet.js +1 -1
  390. package/dist/internal/hashSet.js.map +1 -1
  391. package/dist/internal/matcher.js +1 -1
  392. package/dist/internal/matcher.js.map +1 -1
  393. package/dist/internal/metric.js +1 -1
  394. package/dist/internal/metric.js.map +1 -1
  395. package/dist/internal/option.js +6 -5
  396. package/dist/internal/option.js.map +1 -1
  397. package/dist/internal/random.js +17 -0
  398. package/dist/internal/random.js.map +1 -1
  399. package/dist/internal/rcRef.js +10 -7
  400. package/dist/internal/rcRef.js.map +1 -1
  401. package/dist/internal/references.js +1 -0
  402. package/dist/internal/references.js.map +1 -1
  403. package/dist/internal/request.js +13 -6
  404. package/dist/internal/request.js.map +1 -1
  405. package/dist/internal/result.js +11 -9
  406. package/dist/internal/result.js.map +1 -1
  407. package/dist/internal/schema/annotations.js +1 -1
  408. package/dist/internal/schema/annotations.js.map +1 -1
  409. package/dist/internal/schema/fromJsonSchemaDocument.js +238 -132
  410. package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -1
  411. package/dist/internal/schema/fromRepresentation.js +5 -5
  412. package/dist/internal/schema/fromRepresentation.js.map +1 -1
  413. package/dist/internal/schema/make.d.ts +2 -0
  414. package/dist/internal/schema/make.d.ts.map +1 -0
  415. package/dist/internal/schema/{schema.js → make.js} +1 -25
  416. package/dist/internal/schema/make.js.map +1 -0
  417. package/dist/internal/schema/parser.d.ts +0 -12
  418. package/dist/internal/schema/parser.d.ts.map +1 -1
  419. package/dist/internal/schema/parser.js +7 -0
  420. package/dist/internal/schema/parser.js.map +1 -1
  421. package/dist/internal/schema/standardSchema.d.ts +2 -0
  422. package/dist/internal/schema/standardSchema.d.ts.map +1 -0
  423. package/dist/internal/schema/standardSchema.js +112 -0
  424. package/dist/internal/schema/standardSchema.js.map +1 -0
  425. package/dist/internal/schema/toCodeDocument.js +34 -22
  426. package/dist/internal/schema/toCodeDocument.js.map +1 -1
  427. package/dist/internal/schema/toCodec.d.ts +2 -0
  428. package/dist/internal/schema/toCodec.d.ts.map +1 -0
  429. package/dist/internal/schema/toCodec.js +242 -0
  430. package/dist/internal/schema/toCodec.js.map +1 -0
  431. package/dist/internal/schema/toDifferJsonPatch.d.ts +2 -0
  432. package/dist/internal/schema/toDifferJsonPatch.d.ts.map +1 -0
  433. package/dist/internal/schema/toDifferJsonPatch.js +20 -0
  434. package/dist/internal/schema/toDifferJsonPatch.js.map +1 -0
  435. package/dist/internal/schema/toEncoderXml.d.ts +2 -0
  436. package/dist/internal/schema/toEncoderXml.d.ts.map +1 -0
  437. package/dist/internal/schema/toEncoderXml.js +104 -0
  438. package/dist/internal/schema/toEncoderXml.js.map +1 -0
  439. package/dist/internal/schema/toEquivalence.js +66 -0
  440. package/dist/internal/schema/toEquivalence.js.map +1 -1
  441. package/dist/internal/schema/toFormatter.d.ts +2 -0
  442. package/dist/internal/schema/toFormatter.d.ts.map +1 -0
  443. package/dist/internal/schema/toFormatter.js +227 -0
  444. package/dist/internal/schema/toFormatter.js.map +1 -0
  445. package/dist/internal/schema/toIso.d.ts +2 -0
  446. package/dist/internal/schema/toIso.d.ts.map +1 -0
  447. package/dist/internal/schema/toIso.js +17 -0
  448. package/dist/internal/schema/toIso.js.map +1 -0
  449. package/dist/internal/schema/toJsonSchemaDocument.js +122 -71
  450. package/dist/internal/schema/toJsonSchemaDocument.js.map +1 -1
  451. package/dist/internal/schema/toRepresentation.js +3 -1
  452. package/dist/internal/schema/toRepresentation.js.map +1 -1
  453. package/dist/internal/schemaError.d.ts +4 -0
  454. package/dist/internal/schemaError.d.ts.map +1 -0
  455. package/dist/internal/schemaError.js +6 -0
  456. package/dist/internal/schemaError.js.map +1 -0
  457. package/dist/internal/stream.js +5 -6
  458. package/dist/internal/stream.js.map +1 -1
  459. package/dist/internal/tracer.d.ts +1 -3
  460. package/dist/internal/tracer.d.ts.map +1 -1
  461. package/dist/internal/tracer.js +6 -0
  462. package/dist/internal/tracer.js.map +1 -1
  463. package/dist/internal/trie.js +2 -2
  464. package/dist/internal/trie.js.map +1 -1
  465. package/dist/internal/uuid.d.ts +1 -2
  466. package/dist/internal/uuid.d.ts.map +1 -1
  467. package/dist/internal/uuid.js +2 -0
  468. package/dist/internal/uuid.js.map +1 -1
  469. package/dist/testing/TestSchema.d.ts +9 -11
  470. package/dist/testing/TestSchema.d.ts.map +1 -1
  471. package/dist/testing/TestSchema.js +20 -18
  472. package/dist/testing/TestSchema.js.map +1 -1
  473. package/dist/testing/index.d.ts +0 -4
  474. package/dist/testing/index.d.ts.map +1 -1
  475. package/dist/testing/index.js +0 -4
  476. package/dist/testing/index.js.map +1 -1
  477. package/dist/unstable/ai/AiError.d.ts +98 -23
  478. package/dist/unstable/ai/AiError.d.ts.map +1 -1
  479. package/dist/unstable/ai/AiError.js +98 -6
  480. package/dist/unstable/ai/AiError.js.map +1 -1
  481. package/dist/unstable/ai/AnthropicStructuredOutput.d.ts +1 -1
  482. package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
  483. package/dist/unstable/ai/AnthropicStructuredOutput.js +5 -16
  484. package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
  485. package/dist/unstable/ai/Chat.d.ts +27 -32
  486. package/dist/unstable/ai/Chat.d.ts.map +1 -1
  487. package/dist/unstable/ai/Chat.js +10 -13
  488. package/dist/unstable/ai/Chat.js.map +1 -1
  489. package/dist/unstable/ai/EmbeddingModel.d.ts +23 -16
  490. package/dist/unstable/ai/EmbeddingModel.d.ts.map +1 -1
  491. package/dist/unstable/ai/EmbeddingModel.js +13 -11
  492. package/dist/unstable/ai/EmbeddingModel.js.map +1 -1
  493. package/dist/unstable/ai/LanguageModel.d.ts +48 -37
  494. package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
  495. package/dist/unstable/ai/LanguageModel.js +150 -47
  496. package/dist/unstable/ai/LanguageModel.js.map +1 -1
  497. package/dist/unstable/ai/McpServer.d.ts +2 -2
  498. package/dist/unstable/ai/McpServer.d.ts.map +1 -1
  499. package/dist/unstable/ai/McpServer.js +87 -78
  500. package/dist/unstable/ai/McpServer.js.map +1 -1
  501. package/dist/unstable/ai/OpenAiStructuredOutput.d.ts +1 -1
  502. package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
  503. package/dist/unstable/ai/OpenAiStructuredOutput.js +3 -14
  504. package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
  505. package/dist/unstable/ai/Prompt.d.ts +2 -2
  506. package/dist/unstable/ai/Prompt.d.ts.map +1 -1
  507. package/dist/unstable/ai/Prompt.js +15 -4
  508. package/dist/unstable/ai/Prompt.js.map +1 -1
  509. package/dist/unstable/ai/Response.d.ts +37 -94
  510. package/dist/unstable/ai/Response.d.ts.map +1 -1
  511. package/dist/unstable/ai/Response.js +46 -96
  512. package/dist/unstable/ai/Response.js.map +1 -1
  513. package/dist/unstable/ai/Tokenizer.js +4 -5
  514. package/dist/unstable/ai/Tokenizer.js.map +1 -1
  515. package/dist/unstable/ai/Tool.d.ts +38 -20
  516. package/dist/unstable/ai/Tool.d.ts.map +1 -1
  517. package/dist/unstable/ai/Tool.js +27 -1
  518. package/dist/unstable/ai/Tool.js.map +1 -1
  519. package/dist/unstable/ai/Toolkit.d.ts +1 -1
  520. package/dist/unstable/ai/Toolkit.d.ts.map +1 -1
  521. package/dist/unstable/ai/Toolkit.js +30 -18
  522. package/dist/unstable/ai/Toolkit.js.map +1 -1
  523. package/dist/unstable/ai/internal/codec-transformer.js +2 -2
  524. package/dist/unstable/ai/internal/codec-transformer.js.map +1 -1
  525. package/dist/unstable/ai/internal/structured-output.js +28 -5
  526. package/dist/unstable/ai/internal/structured-output.js.map +1 -1
  527. package/dist/unstable/arbitrary/Arbitrary.d.ts +626 -0
  528. package/dist/unstable/arbitrary/Arbitrary.d.ts.map +1 -0
  529. package/dist/unstable/arbitrary/Arbitrary.js +238 -0
  530. package/dist/unstable/arbitrary/Arbitrary.js.map +1 -0
  531. package/dist/unstable/arbitrary/index.d.ts +8 -0
  532. package/dist/unstable/arbitrary/index.d.ts.map +1 -0
  533. package/dist/unstable/arbitrary/index.js +9 -0
  534. package/dist/unstable/arbitrary/index.js.map +1 -0
  535. package/dist/unstable/cli/Argument.d.ts +104 -108
  536. package/dist/unstable/cli/Argument.d.ts.map +1 -1
  537. package/dist/unstable/cli/Argument.js +56 -57
  538. package/dist/unstable/cli/Argument.js.map +1 -1
  539. package/dist/unstable/cli/CliError.d.ts +2 -0
  540. package/dist/unstable/cli/CliError.d.ts.map +1 -1
  541. package/dist/unstable/cli/CliError.js +2 -0
  542. package/dist/unstable/cli/CliError.js.map +1 -1
  543. package/dist/unstable/cli/CliOutput.js +27 -4
  544. package/dist/unstable/cli/CliOutput.js.map +1 -1
  545. package/dist/unstable/cli/Command.d.ts +73 -73
  546. package/dist/unstable/cli/Command.d.ts.map +1 -1
  547. package/dist/unstable/cli/Command.js +22 -22
  548. package/dist/unstable/cli/Command.js.map +1 -1
  549. package/dist/unstable/cli/Completions.d.ts +4 -4
  550. package/dist/unstable/cli/Completions.d.ts.map +1 -1
  551. package/dist/unstable/cli/Flag.d.ts +150 -161
  552. package/dist/unstable/cli/Flag.d.ts.map +1 -1
  553. package/dist/unstable/cli/Flag.js +79 -90
  554. package/dist/unstable/cli/Flag.js.map +1 -1
  555. package/dist/unstable/cli/GlobalFlag.d.ts +3 -3
  556. package/dist/unstable/cli/GlobalFlag.js +13 -13
  557. package/dist/unstable/cli/GlobalFlag.js.map +1 -1
  558. package/dist/unstable/cli/Param.d.ts +118 -126
  559. package/dist/unstable/cli/Param.d.ts.map +1 -1
  560. package/dist/unstable/cli/Param.js +104 -113
  561. package/dist/unstable/cli/Param.js.map +1 -1
  562. package/dist/unstable/cli/Primitive.d.ts +69 -58
  563. package/dist/unstable/cli/Primitive.d.ts.map +1 -1
  564. package/dist/unstable/cli/Primitive.js +65 -66
  565. package/dist/unstable/cli/Primitive.js.map +1 -1
  566. package/dist/unstable/cli/Prompt.d.ts +113 -59
  567. package/dist/unstable/cli/Prompt.d.ts.map +1 -1
  568. package/dist/unstable/cli/Prompt.js +391 -327
  569. package/dist/unstable/cli/Prompt.js.map +1 -1
  570. package/dist/unstable/cli/internal/completions/bash.js +109 -38
  571. package/dist/unstable/cli/internal/completions/bash.js.map +1 -1
  572. package/dist/unstable/cli/internal/completions/descriptor.js +23 -11
  573. package/dist/unstable/cli/internal/completions/descriptor.js.map +1 -1
  574. package/dist/unstable/cli/internal/completions/fish.js +15 -7
  575. package/dist/unstable/cli/internal/completions/fish.js.map +1 -1
  576. package/dist/unstable/cli/internal/completions/zsh.js +6 -4
  577. package/dist/unstable/cli/internal/completions/zsh.js.map +1 -1
  578. package/dist/unstable/cli/internal/config.js +4 -4
  579. package/dist/unstable/cli/internal/parser.js +1 -1
  580. package/dist/unstable/cli/internal/parser.js.map +1 -1
  581. package/dist/unstable/cli/internal/wizard.d.ts +5 -1
  582. package/dist/unstable/cli/internal/wizard.d.ts.map +1 -1
  583. package/dist/unstable/cli/internal/wizard.js +34 -26
  584. package/dist/unstable/cli/internal/wizard.js.map +1 -1
  585. package/dist/unstable/cluster/ClusterSchema.d.ts +13 -0
  586. package/dist/unstable/cluster/ClusterSchema.d.ts.map +1 -1
  587. package/dist/unstable/cluster/ClusterSchema.js +16 -1
  588. package/dist/unstable/cluster/ClusterSchema.js.map +1 -1
  589. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
  590. package/dist/unstable/cluster/ClusterWorkflowEngine.js +57 -14
  591. package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
  592. package/dist/unstable/cluster/Entity.d.ts.map +1 -1
  593. package/dist/unstable/cluster/Entity.js +2 -0
  594. package/dist/unstable/cluster/Entity.js.map +1 -1
  595. package/dist/unstable/cluster/EntityProxyServer.d.ts +2 -2
  596. package/dist/unstable/cluster/EntityProxyServer.d.ts.map +1 -1
  597. package/dist/unstable/cluster/EntityProxyServer.js.map +1 -1
  598. package/dist/unstable/cluster/Envelope.d.ts +22 -5
  599. package/dist/unstable/cluster/Envelope.d.ts.map +1 -1
  600. package/dist/unstable/cluster/Envelope.js +23 -3
  601. package/dist/unstable/cluster/Envelope.js.map +1 -1
  602. package/dist/unstable/cluster/HttpRunner.d.ts.map +1 -1
  603. package/dist/unstable/cluster/HttpRunner.js +32 -13
  604. package/dist/unstable/cluster/HttpRunner.js.map +1 -1
  605. package/dist/unstable/cluster/Message.d.ts +17 -5
  606. package/dist/unstable/cluster/Message.d.ts.map +1 -1
  607. package/dist/unstable/cluster/Message.js +21 -8
  608. package/dist/unstable/cluster/Message.js.map +1 -1
  609. package/dist/unstable/cluster/MessageStorage.d.ts +34 -4
  610. package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
  611. package/dist/unstable/cluster/MessageStorage.js +33 -12
  612. package/dist/unstable/cluster/MessageStorage.js.map +1 -1
  613. package/dist/unstable/cluster/Reply.d.ts +5 -4
  614. package/dist/unstable/cluster/Reply.d.ts.map +1 -1
  615. package/dist/unstable/cluster/Reply.js +21 -12
  616. package/dist/unstable/cluster/Reply.js.map +1 -1
  617. package/dist/unstable/cluster/RunnerServer.d.ts +1 -1
  618. package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
  619. package/dist/unstable/cluster/RunnerServer.js +12 -6
  620. package/dist/unstable/cluster/RunnerServer.js.map +1 -1
  621. package/dist/unstable/cluster/Runners.d.ts +11 -5
  622. package/dist/unstable/cluster/Runners.d.ts.map +1 -1
  623. package/dist/unstable/cluster/Runners.js +56 -35
  624. package/dist/unstable/cluster/Runners.js.map +1 -1
  625. package/dist/unstable/cluster/Sharding.d.ts +1 -1
  626. package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
  627. package/dist/unstable/cluster/Sharding.js +32 -17
  628. package/dist/unstable/cluster/Sharding.js.map +1 -1
  629. package/dist/unstable/cluster/ShardingConfig.js +23 -23
  630. package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
  631. package/dist/unstable/cluster/SocketRunner.d.ts +2 -2
  632. package/dist/unstable/cluster/SocketRunner.d.ts.map +1 -1
  633. package/dist/unstable/cluster/SocketRunner.js +4 -3
  634. package/dist/unstable/cluster/SocketRunner.js.map +1 -1
  635. package/dist/unstable/cluster/SqlMessageStorage.js +11 -8
  636. package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
  637. package/dist/unstable/cluster/SqlRunnerStorage.d.ts.map +1 -1
  638. package/dist/unstable/cluster/SqlRunnerStorage.js +11 -4
  639. package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
  640. package/dist/unstable/cluster/internal/clusterAbandon.d.ts +5 -0
  641. package/dist/unstable/cluster/internal/clusterAbandon.d.ts.map +1 -0
  642. package/dist/unstable/cluster/internal/clusterAbandon.js +9 -0
  643. package/dist/unstable/cluster/internal/clusterAbandon.js.map +1 -0
  644. package/dist/unstable/cluster/internal/entityManager.js +10 -6
  645. package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
  646. package/dist/unstable/cluster/internal/interruptors.js +30 -1
  647. package/dist/unstable/cluster/internal/interruptors.js.map +1 -1
  648. package/dist/unstable/cluster/internal/resourceRef.js +12 -7
  649. package/dist/unstable/cluster/internal/resourceRef.js.map +1 -1
  650. package/dist/unstable/devtools/DevToolsClient.d.ts.map +1 -1
  651. package/dist/unstable/devtools/DevToolsClient.js +12 -7
  652. package/dist/unstable/devtools/DevToolsClient.js.map +1 -1
  653. package/dist/unstable/encoding/Ini.d.ts +2 -0
  654. package/dist/unstable/encoding/Ini.d.ts.map +1 -1
  655. package/dist/unstable/encoding/Ini.js +2 -0
  656. package/dist/unstable/encoding/Ini.js.map +1 -1
  657. package/dist/unstable/encoding/SchemaBinary.d.ts +273 -0
  658. package/dist/unstable/encoding/SchemaBinary.d.ts.map +1 -0
  659. package/dist/unstable/encoding/SchemaBinary.js +4573 -0
  660. package/dist/unstable/encoding/SchemaBinary.js.map +1 -0
  661. package/dist/unstable/encoding/Sse.js +1 -1
  662. package/dist/unstable/encoding/Sse.js.map +1 -1
  663. package/dist/unstable/encoding/Toml.d.ts +2 -0
  664. package/dist/unstable/encoding/Toml.d.ts.map +1 -1
  665. package/dist/unstable/encoding/Toml.js +6 -4
  666. package/dist/unstable/encoding/Toml.js.map +1 -1
  667. package/dist/unstable/encoding/Yaml.d.ts +2 -0
  668. package/dist/unstable/encoding/Yaml.d.ts.map +1 -1
  669. package/dist/unstable/encoding/Yaml.js +16 -5
  670. package/dist/unstable/encoding/Yaml.js.map +1 -1
  671. package/dist/unstable/encoding/index.d.ts +2 -2
  672. package/dist/unstable/encoding/index.d.ts.map +1 -1
  673. package/dist/unstable/encoding/index.js +2 -2
  674. package/dist/unstable/encoding/index.js.map +1 -1
  675. package/dist/unstable/eventlog/Event.d.ts +5 -5
  676. package/dist/unstable/eventlog/Event.d.ts.map +1 -1
  677. package/dist/unstable/eventlog/Event.js +3 -3
  678. package/dist/unstable/eventlog/Event.js.map +1 -1
  679. package/dist/unstable/eventlog/EventJournal.d.ts +15 -9
  680. package/dist/unstable/eventlog/EventJournal.d.ts.map +1 -1
  681. package/dist/unstable/eventlog/EventJournal.js +26 -12
  682. package/dist/unstable/eventlog/EventJournal.js.map +1 -1
  683. package/dist/unstable/eventlog/EventLog.d.ts +1 -1
  684. package/dist/unstable/eventlog/EventLog.d.ts.map +1 -1
  685. package/dist/unstable/eventlog/EventLog.js +13 -9
  686. package/dist/unstable/eventlog/EventLog.js.map +1 -1
  687. package/dist/unstable/eventlog/EventLogMessage.d.ts +11 -5
  688. package/dist/unstable/eventlog/EventLogMessage.d.ts.map +1 -1
  689. package/dist/unstable/eventlog/EventLogMessage.js +25 -15
  690. package/dist/unstable/eventlog/EventLogMessage.js.map +1 -1
  691. package/dist/unstable/eventlog/EventLogRemote.d.ts +7 -1
  692. package/dist/unstable/eventlog/EventLogRemote.d.ts.map +1 -1
  693. package/dist/unstable/eventlog/EventLogRemote.js +13 -3
  694. package/dist/unstable/eventlog/EventLogRemote.js.map +1 -1
  695. package/dist/unstable/eventlog/EventLogServerUnencrypted.js +2 -2
  696. package/dist/unstable/eventlog/EventLogServerUnencrypted.js.map +1 -1
  697. package/dist/unstable/eventlog/SqlEventJournal.d.ts +0 -10
  698. package/dist/unstable/eventlog/SqlEventJournal.d.ts.map +1 -1
  699. package/dist/unstable/eventlog/SqlEventJournal.js +29 -14
  700. package/dist/unstable/eventlog/SqlEventJournal.js.map +1 -1
  701. package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.d.ts.map +1 -1
  702. package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js +5 -1
  703. package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js.map +1 -1
  704. package/dist/unstable/http/Cookies.d.ts +1 -45
  705. package/dist/unstable/http/Cookies.d.ts.map +1 -1
  706. package/dist/unstable/http/Cookies.js +2 -64
  707. package/dist/unstable/http/Cookies.js.map +1 -1
  708. package/dist/unstable/http/FetchHttpClient.js +1 -1
  709. package/dist/unstable/http/FetchHttpClient.js.map +1 -1
  710. package/dist/unstable/http/FindMyWay/internal/router.js +124 -33
  711. package/dist/unstable/http/FindMyWay/internal/router.js.map +1 -1
  712. package/dist/unstable/http/FindMyWay.d.ts +15 -5
  713. package/dist/unstable/http/FindMyWay.d.ts.map +1 -1
  714. package/dist/unstable/http/FindMyWay.js +3 -1
  715. package/dist/unstable/http/FindMyWay.js.map +1 -1
  716. package/dist/unstable/http/Headers.d.ts +0 -22
  717. package/dist/unstable/http/Headers.d.ts.map +1 -1
  718. package/dist/unstable/http/Headers.js +3 -34
  719. package/dist/unstable/http/Headers.js.map +1 -1
  720. package/dist/unstable/http/HttpBody.d.ts +41 -10
  721. package/dist/unstable/http/HttpBody.d.ts.map +1 -1
  722. package/dist/unstable/http/HttpBody.js +64 -10
  723. package/dist/unstable/http/HttpBody.js.map +1 -1
  724. package/dist/unstable/http/HttpClient.d.ts +1 -1
  725. package/dist/unstable/http/HttpClient.d.ts.map +1 -1
  726. package/dist/unstable/http/HttpClient.js +28 -18
  727. package/dist/unstable/http/HttpClient.js.map +1 -1
  728. package/dist/unstable/http/HttpClientRequest.d.ts +28 -6
  729. package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
  730. package/dist/unstable/http/HttpClientRequest.js +8 -19
  731. package/dist/unstable/http/HttpClientRequest.js.map +1 -1
  732. package/dist/unstable/http/HttpClientResponse.d.ts +6 -1
  733. package/dist/unstable/http/HttpClientResponse.d.ts.map +1 -1
  734. package/dist/unstable/http/HttpClientResponse.js +10 -6
  735. package/dist/unstable/http/HttpClientResponse.js.map +1 -1
  736. package/dist/unstable/http/HttpEffect.d.ts +16 -0
  737. package/dist/unstable/http/HttpEffect.d.ts.map +1 -1
  738. package/dist/unstable/http/HttpEffect.js +121 -65
  739. package/dist/unstable/http/HttpEffect.js.map +1 -1
  740. package/dist/unstable/http/HttpIncomingMessage.d.ts +3 -3
  741. package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
  742. package/dist/unstable/http/HttpIncomingMessage.js +1 -13
  743. package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
  744. package/dist/unstable/http/HttpMiddleware.d.ts +1 -1
  745. package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
  746. package/dist/unstable/http/HttpMiddleware.js +29 -21
  747. package/dist/unstable/http/HttpMiddleware.js.map +1 -1
  748. package/dist/unstable/http/HttpPlatform.d.ts +12 -11
  749. package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
  750. package/dist/unstable/http/HttpPlatform.js +36 -10
  751. package/dist/unstable/http/HttpPlatform.js.map +1 -1
  752. package/dist/unstable/http/HttpRouter.d.ts +5 -1
  753. package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
  754. package/dist/unstable/http/HttpRouter.js +22 -8
  755. package/dist/unstable/http/HttpRouter.js.map +1 -1
  756. package/dist/unstable/http/HttpServer.d.ts +11 -42
  757. package/dist/unstable/http/HttpServer.d.ts.map +1 -1
  758. package/dist/unstable/http/HttpServer.js +16 -20
  759. package/dist/unstable/http/HttpServer.js.map +1 -1
  760. package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
  761. package/dist/unstable/http/HttpServerRequest.js +11 -11
  762. package/dist/unstable/http/HttpServerRequest.js.map +1 -1
  763. package/dist/unstable/http/HttpServerRespondable.js +1 -1
  764. package/dist/unstable/http/HttpServerRespondable.js.map +1 -1
  765. package/dist/unstable/http/HttpServerResponse.d.ts +9 -13
  766. package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
  767. package/dist/unstable/http/HttpServerResponse.js +34 -44
  768. package/dist/unstable/http/HttpServerResponse.js.map +1 -1
  769. package/dist/unstable/http/HttpStaticServer.d.ts +2 -2
  770. package/dist/unstable/http/HttpStaticServer.d.ts.map +1 -1
  771. package/dist/unstable/http/HttpStaticServer.js +19 -19
  772. package/dist/unstable/http/HttpStaticServer.js.map +1 -1
  773. package/dist/unstable/http/Mime.d.ts +28 -0
  774. package/dist/unstable/http/Mime.d.ts.map +1 -0
  775. package/dist/unstable/http/Mime.js +72 -0
  776. package/dist/unstable/http/Mime.js.map +1 -0
  777. package/dist/unstable/http/Multipart.d.ts +22 -9
  778. package/dist/unstable/http/Multipart.d.ts.map +1 -1
  779. package/dist/unstable/http/Multipart.js +26 -10
  780. package/dist/unstable/http/Multipart.js.map +1 -1
  781. package/dist/unstable/http/MultipartParser/internal/multipart.d.ts +1 -1
  782. package/dist/unstable/http/MultipartParser/internal/multipart.d.ts.map +1 -1
  783. package/dist/unstable/http/MultipartParser/internal/multipart.js +8 -3
  784. package/dist/unstable/http/MultipartParser/internal/multipart.js.map +1 -1
  785. package/dist/unstable/http/MultipartParser.d.ts +4 -3
  786. package/dist/unstable/http/MultipartParser.d.ts.map +1 -1
  787. package/dist/unstable/http/MultipartParser.js.map +1 -1
  788. package/dist/unstable/http/UrlParams.d.ts +0 -97
  789. package/dist/unstable/http/UrlParams.d.ts.map +1 -1
  790. package/dist/unstable/http/UrlParams.js +3 -104
  791. package/dist/unstable/http/UrlParams.js.map +1 -1
  792. package/dist/unstable/http/index.d.ts +4 -0
  793. package/dist/unstable/http/index.d.ts.map +1 -1
  794. package/dist/unstable/http/index.js +4 -0
  795. package/dist/unstable/http/index.js.map +1 -1
  796. package/dist/unstable/http/internal/compression.js +8 -11
  797. package/dist/unstable/http/internal/compression.js.map +1 -1
  798. package/dist/unstable/http/internal/headers.d.ts +2 -0
  799. package/dist/unstable/http/internal/headers.d.ts.map +1 -0
  800. package/dist/unstable/http/internal/headers.js +5 -0
  801. package/dist/unstable/http/internal/headers.js.map +1 -0
  802. package/dist/unstable/http/internal/httpBody.js +8 -0
  803. package/dist/unstable/http/internal/httpBody.js.map +1 -1
  804. package/dist/unstable/http/internal/mimeTypes.d.ts +361 -0
  805. package/dist/unstable/http/internal/mimeTypes.d.ts.map +1 -0
  806. package/dist/unstable/http/internal/mimeTypes.js +363 -0
  807. package/dist/unstable/http/internal/mimeTypes.js.map +1 -0
  808. package/dist/unstable/httpapi/HttpApiBuilder.d.ts +13 -0
  809. package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
  810. package/dist/unstable/httpapi/HttpApiBuilder.js +28 -11
  811. package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
  812. package/dist/unstable/httpapi/HttpApiClient.d.ts +4 -3
  813. package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
  814. package/dist/unstable/httpapi/HttpApiClient.js +25 -13
  815. package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
  816. package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +8 -3
  817. package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
  818. package/dist/unstable/httpapi/HttpApiEndpoint.js +9 -6
  819. package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
  820. package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
  821. package/dist/unstable/httpapi/HttpApiError.js +3 -1
  822. package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
  823. package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
  824. package/dist/unstable/httpapi/HttpApiMiddleware.js +7 -5
  825. package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
  826. package/dist/unstable/httpapi/HttpApiScalar.d.ts.map +1 -1
  827. package/dist/unstable/httpapi/HttpApiScalar.js +15 -12
  828. package/dist/unstable/httpapi/HttpApiScalar.js.map +1 -1
  829. package/dist/unstable/httpapi/HttpApiSchema.d.ts +12 -0
  830. package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
  831. package/dist/unstable/httpapi/HttpApiSchema.js +8 -10
  832. package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
  833. package/dist/unstable/httpapi/HttpApiSwagger.d.ts.map +1 -1
  834. package/dist/unstable/httpapi/HttpApiSwagger.js +6 -3
  835. package/dist/unstable/httpapi/HttpApiSwagger.js.map +1 -1
  836. package/dist/unstable/httpapi/HttpApiTest.d.ts.map +1 -1
  837. package/dist/unstable/httpapi/HttpApiTest.js +8 -2
  838. package/dist/unstable/httpapi/HttpApiTest.js.map +1 -1
  839. package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
  840. package/dist/unstable/httpapi/OpenApi.js +31 -20
  841. package/dist/unstable/httpapi/OpenApi.js.map +1 -1
  842. package/dist/unstable/net/IpInterface.d.ts +140 -0
  843. package/dist/unstable/net/IpInterface.d.ts.map +1 -0
  844. package/dist/unstable/net/IpInterface.js +149 -0
  845. package/dist/unstable/net/IpInterface.js.map +1 -0
  846. package/dist/unstable/net/IpNetwork.d.ts +227 -0
  847. package/dist/unstable/net/IpNetwork.d.ts.map +1 -0
  848. package/dist/unstable/net/IpNetwork.js +239 -0
  849. package/dist/unstable/net/IpNetwork.js.map +1 -0
  850. package/dist/unstable/net/NetAddress.d.ts +705 -0
  851. package/dist/unstable/net/NetAddress.d.ts.map +1 -0
  852. package/dist/unstable/net/NetAddress.js +956 -0
  853. package/dist/unstable/net/NetAddress.js.map +1 -0
  854. package/dist/unstable/net/index.d.ts +16 -0
  855. package/dist/unstable/net/index.d.ts.map +1 -0
  856. package/dist/unstable/net/index.js +17 -0
  857. package/dist/unstable/net/index.js.map +1 -0
  858. package/dist/unstable/observability/OtlpExporter.d.ts +1 -0
  859. package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
  860. package/dist/unstable/observability/OtlpExporter.js +4 -6
  861. package/dist/unstable/observability/OtlpExporter.js.map +1 -1
  862. package/dist/unstable/observability/OtlpLogger.js +9 -9
  863. package/dist/unstable/observability/OtlpLogger.js.map +1 -1
  864. package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
  865. package/dist/unstable/observability/OtlpMetrics.js +9 -8
  866. package/dist/unstable/observability/OtlpMetrics.js.map +1 -1
  867. package/dist/unstable/observability/OtlpResource.d.ts.map +1 -1
  868. package/dist/unstable/observability/OtlpResource.js +2 -2
  869. package/dist/unstable/observability/OtlpResource.js.map +1 -1
  870. package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
  871. package/dist/unstable/observability/OtlpTracer.js +82 -55
  872. package/dist/unstable/observability/OtlpTracer.js.map +1 -1
  873. package/dist/unstable/observability/internal/otlpEnv.d.ts +1 -1
  874. package/dist/unstable/observability/internal/otlpEnv.d.ts.map +1 -1
  875. package/dist/unstable/observability/internal/otlpEnv.js +5 -9
  876. package/dist/unstable/observability/internal/otlpEnv.js.map +1 -1
  877. package/dist/unstable/persistence/PersistedCache.js +1 -1
  878. package/dist/unstable/persistence/PersistedCache.js.map +1 -1
  879. package/dist/unstable/persistence/PersistedQueue.d.ts +114 -14
  880. package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
  881. package/dist/unstable/persistence/PersistedQueue.js +799 -234
  882. package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
  883. package/dist/unstable/persistence/RateLimiter.d.ts +28 -15
  884. package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
  885. package/dist/unstable/persistence/RateLimiter.js +33 -41
  886. package/dist/unstable/persistence/RateLimiter.js.map +1 -1
  887. package/dist/unstable/process/ChildProcess.d.ts +8 -2
  888. package/dist/unstable/process/ChildProcess.d.ts.map +1 -1
  889. package/dist/unstable/process/ChildProcess.js +7 -2
  890. package/dist/unstable/process/ChildProcess.js.map +1 -1
  891. package/dist/unstable/process/ChildProcessSpawner.d.ts +1 -1
  892. package/dist/unstable/process/ChildProcessSpawner.d.ts.map +1 -1
  893. package/dist/unstable/process/ChildProcessSpawner.js +1 -1
  894. package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
  895. package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
  896. package/dist/unstable/reactivity/Atom.js +6 -3
  897. package/dist/unstable/reactivity/Atom.js.map +1 -1
  898. package/dist/unstable/reactivity/AtomHttpApi.d.ts +3 -6
  899. package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
  900. package/dist/unstable/reactivity/AtomHttpApi.js +6 -3
  901. package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
  902. package/dist/unstable/reactivity/AtomRegistry.js +2 -3
  903. package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
  904. package/dist/unstable/reactivity/AtomRpc.d.ts +2 -2
  905. package/dist/unstable/reactivity/AtomRpc.d.ts.map +1 -1
  906. package/dist/unstable/reactivity/AtomRpc.js +1 -1
  907. package/dist/unstable/reactivity/AtomRpc.js.map +1 -1
  908. package/dist/unstable/reactivity/Hydration.d.ts +6 -4
  909. package/dist/unstable/reactivity/Hydration.d.ts.map +1 -1
  910. package/dist/unstable/reactivity/Hydration.js +20 -6
  911. package/dist/unstable/reactivity/Hydration.js.map +1 -1
  912. package/dist/unstable/reactivity/Reactivity.d.ts +26 -26
  913. package/dist/unstable/reactivity/Reactivity.d.ts.map +1 -1
  914. package/dist/unstable/reactivity/Reactivity.js +10 -12
  915. package/dist/unstable/reactivity/Reactivity.js.map +1 -1
  916. package/dist/unstable/rpc/RpcClient.d.ts +5 -0
  917. package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
  918. package/dist/unstable/rpc/RpcClient.js +94 -81
  919. package/dist/unstable/rpc/RpcClient.js.map +1 -1
  920. package/dist/unstable/rpc/RpcClientError.d.ts +1 -1
  921. package/dist/unstable/rpc/RpcMessage.d.ts +66 -7
  922. package/dist/unstable/rpc/RpcMessage.d.ts.map +1 -1
  923. package/dist/unstable/rpc/RpcMessage.js +68 -9
  924. package/dist/unstable/rpc/RpcMessage.js.map +1 -1
  925. package/dist/unstable/rpc/RpcMiddleware.d.ts.map +1 -1
  926. package/dist/unstable/rpc/RpcMiddleware.js +7 -5
  927. package/dist/unstable/rpc/RpcMiddleware.js.map +1 -1
  928. package/dist/unstable/rpc/RpcSerialization.d.ts +28 -33
  929. package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
  930. package/dist/unstable/rpc/RpcSerialization.js +56 -92
  931. package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
  932. package/dist/unstable/rpc/RpcServer.d.ts +25 -0
  933. package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
  934. package/dist/unstable/rpc/RpcServer.js +125 -68
  935. package/dist/unstable/rpc/RpcServer.js.map +1 -1
  936. package/dist/unstable/schema/Model.d.ts.map +1 -1
  937. package/dist/unstable/schema/Model.js +7 -6
  938. package/dist/unstable/schema/Model.js.map +1 -1
  939. package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
  940. package/dist/unstable/schema/VariantSchema.js +3 -0
  941. package/dist/unstable/schema/VariantSchema.js.map +1 -1
  942. package/dist/unstable/socket/Socket.d.ts +287 -102
  943. package/dist/unstable/socket/Socket.d.ts.map +1 -1
  944. package/dist/unstable/socket/Socket.js +408 -215
  945. package/dist/unstable/socket/Socket.js.map +1 -1
  946. package/dist/unstable/socket/SocketServer.d.ts +5 -32
  947. package/dist/unstable/socket/SocketServer.d.ts.map +1 -1
  948. package/dist/unstable/socket/SocketServer.js +3 -3
  949. package/dist/unstable/socket/SocketServer.js.map +1 -1
  950. package/dist/unstable/sql/SqlClient.d.ts +20 -0
  951. package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
  952. package/dist/unstable/sql/SqlClient.js +14 -7
  953. package/dist/unstable/sql/SqlClient.js.map +1 -1
  954. package/dist/unstable/sql/SqlConnection.d.ts +15 -0
  955. package/dist/unstable/sql/SqlConnection.d.ts.map +1 -1
  956. package/dist/unstable/sql/SqlConnection.js.map +1 -1
  957. package/dist/unstable/sql/SqlModel.d.ts +1 -1
  958. package/dist/unstable/sql/SqlModel.d.ts.map +1 -1
  959. package/dist/unstable/sql/Statement.d.ts +13 -5
  960. package/dist/unstable/sql/Statement.d.ts.map +1 -1
  961. package/dist/unstable/sql/Statement.js +29 -15
  962. package/dist/unstable/sql/Statement.js.map +1 -1
  963. package/dist/unstable/workers/Transferable.js +1 -1
  964. package/dist/unstable/workers/Worker.d.ts.map +1 -1
  965. package/dist/unstable/workers/Worker.js +3 -1
  966. package/dist/unstable/workers/Worker.js.map +1 -1
  967. package/dist/unstable/workflow/Activity.d.ts +7 -0
  968. package/dist/unstable/workflow/Activity.d.ts.map +1 -1
  969. package/dist/unstable/workflow/Activity.js +14 -4
  970. package/dist/unstable/workflow/Activity.js.map +1 -1
  971. package/dist/unstable/workflow/DurableClock.js +1 -1
  972. package/dist/unstable/workflow/DurableClock.js.map +1 -1
  973. package/dist/unstable/workflow/DurableDeferred.d.ts +2 -2
  974. package/dist/unstable/workflow/DurableDeferred.d.ts.map +1 -1
  975. package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
  976. package/dist/unstable/workflow/DurableQueue.d.ts +8 -0
  977. package/dist/unstable/workflow/DurableQueue.d.ts.map +1 -1
  978. package/dist/unstable/workflow/DurableQueue.js +8 -0
  979. package/dist/unstable/workflow/DurableQueue.js.map +1 -1
  980. package/dist/unstable/workflow/Workflow.d.ts +5 -0
  981. package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
  982. package/dist/unstable/workflow/Workflow.js +70 -12
  983. package/dist/unstable/workflow/Workflow.js.map +1 -1
  984. package/dist/unstable/workflow/WorkflowEngine.d.ts +6 -0
  985. package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
  986. package/dist/unstable/workflow/WorkflowEngine.js +11 -0
  987. package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
  988. package/dist/unstable/workflow/WorkflowProxy.d.ts +2 -2
  989. package/dist/unstable/workflow/WorkflowProxy.d.ts.map +1 -1
  990. package/dist/unstable/workflow/WorkflowProxy.js +4 -2
  991. package/dist/unstable/workflow/WorkflowProxy.js.map +1 -1
  992. package/package.json +8 -10
  993. package/src/Array.ts +142 -70
  994. package/src/BigDecimal.ts +50 -28
  995. package/src/ByteSize.ts +838 -0
  996. package/src/Cache.ts +17 -3
  997. package/src/Cause.ts +1 -1
  998. package/src/Channel.ts +185 -50
  999. package/src/Chunk.ts +65 -36
  1000. package/src/Config.ts +237 -248
  1001. package/src/ConfigProvider.ts +7 -8
  1002. package/src/Context.ts +31 -0
  1003. package/src/Cron.ts +2 -2
  1004. package/src/Crypto.ts +3 -2
  1005. package/src/Deferred.ts +7 -6
  1006. package/src/Duration.ts +1 -1
  1007. package/src/Effect.ts +226 -122
  1008. package/src/Effectable.ts +78 -9
  1009. package/src/Encoding.ts +101 -11
  1010. package/src/Equal.ts +1 -1
  1011. package/src/ExecutionPlan.ts +3 -0
  1012. package/src/Fiber.ts +33 -8
  1013. package/src/FiberHandle.ts +3 -3
  1014. package/src/FiberMap.ts +19 -10
  1015. package/src/FileSystem.ts +55 -230
  1016. package/src/Formatter.ts +21 -3
  1017. package/src/Graph.ts +55 -25
  1018. package/src/Hash.ts +5 -16
  1019. package/src/HashRing.ts +9 -2
  1020. package/src/HashSet.ts +56 -0
  1021. package/src/Iterable.ts +90 -44
  1022. package/src/JsonPatch.ts +4 -4
  1023. package/src/JsonPointer.ts +97 -4
  1024. package/src/JsonSchema.ts +998 -476
  1025. package/src/Layer.ts +59 -18
  1026. package/src/LayerMap.ts +38 -6
  1027. package/src/LayerRef.ts +7 -5
  1028. package/src/Logger.ts +125 -18
  1029. package/src/ManagedRuntime.ts +1 -1
  1030. package/src/Match.ts +33 -14
  1031. package/src/Metric.ts +24 -21
  1032. package/src/MutableHashMap.ts +1 -1
  1033. package/src/MutableHashSet.ts +1 -1
  1034. package/src/MutableList.ts +18 -2
  1035. package/src/Number.ts +7 -1
  1036. package/src/Optic.ts +8 -4
  1037. package/src/Option.ts +1 -1
  1038. package/src/Order.ts +3 -1
  1039. package/src/PartitionedSemaphore.ts +1 -2
  1040. package/src/Path.ts +1 -1
  1041. package/src/PlatformError.ts +1 -1
  1042. package/src/Pool.ts +535 -134
  1043. package/src/PrimaryKey.ts +1 -1
  1044. package/src/PubSub.ts +32 -20
  1045. package/src/Queue.ts +119 -28
  1046. package/src/Random.ts +20 -6
  1047. package/src/RcMap.ts +176 -13
  1048. package/src/Record.ts +15 -0
  1049. package/src/Redacted.ts +1 -1
  1050. package/src/RequestResolver.ts +49 -26
  1051. package/src/Result.ts +1 -1
  1052. package/src/Scheduler.ts +21 -11
  1053. package/src/Schema.ts +5032 -6518
  1054. package/src/SchemaAST.ts +1156 -316
  1055. package/src/SchemaGetter.ts +75 -21
  1056. package/src/SchemaIssue.ts +260 -16
  1057. package/src/SchemaParser.ts +2 -12
  1058. package/src/SchemaRepresentation.ts +1774 -189
  1059. package/src/SchemaTransformation.ts +145 -22
  1060. package/src/Scope.ts +9 -2
  1061. package/src/ScopedCache.ts +10 -3
  1062. package/src/Sink.ts +31 -15
  1063. package/src/StandardSchema.ts +207 -0
  1064. package/src/Stream.ts +294 -76
  1065. package/src/String.ts +20 -9
  1066. package/src/Struct.ts +8 -4
  1067. package/src/SynchronizedRef.ts +3 -5
  1068. package/src/Terminal.ts +3 -3
  1069. package/src/Tracer.ts +43 -14
  1070. package/src/Tuple.ts +3 -1
  1071. package/src/TxChunk.ts +1 -1
  1072. package/src/TxDeferred.ts +1 -1
  1073. package/src/TxHashMap.ts +1 -1
  1074. package/src/TxHashSet.ts +92 -11
  1075. package/src/TxPriorityQueue.ts +1 -1
  1076. package/src/TxPubSub.ts +1 -1
  1077. package/src/TxQueue.ts +22 -17
  1078. package/src/TxReentrantLock.ts +29 -1
  1079. package/src/TxRef.ts +1 -1
  1080. package/src/TxSemaphore.ts +1 -1
  1081. package/src/TxSubscriptionRef.ts +1 -1
  1082. package/src/Types.ts +40 -17
  1083. package/src/Utils.ts +3 -1
  1084. package/src/index.ts +10 -0
  1085. package/src/internal/arbitrary/model.ts +701 -0
  1086. package/src/internal/arbitrary/regexp.ts +855 -0
  1087. package/src/internal/arbitrary/runner.ts +608 -0
  1088. package/src/internal/arbitrary/schema.ts +1800 -0
  1089. package/src/internal/core.ts +48 -22
  1090. package/src/internal/count.ts +14 -0
  1091. package/src/internal/dateTime.ts +8 -10
  1092. package/src/internal/effect.ts +510 -301
  1093. package/src/internal/graph.ts +6 -1
  1094. package/src/internal/hashMap.ts +5 -3
  1095. package/src/internal/hashSet.ts +1 -1
  1096. package/src/internal/matcher.ts +34 -19
  1097. package/src/internal/metric.ts +1 -1
  1098. package/src/internal/option.ts +8 -6
  1099. package/src/internal/random.ts +20 -7
  1100. package/src/internal/rcRef.ts +10 -7
  1101. package/src/internal/references.ts +1 -0
  1102. package/src/internal/request.ts +12 -7
  1103. package/src/internal/result.ts +15 -11
  1104. package/src/internal/schema/annotations.ts +3 -3
  1105. package/src/internal/schema/fromJsonSchemaDocument.ts +326 -160
  1106. package/src/internal/schema/fromRepresentation.ts +5 -3
  1107. package/src/internal/schema/{schema.ts → make.ts} +0 -40
  1108. package/src/internal/schema/parser.ts +8 -0
  1109. package/src/internal/schema/standardSchema.ts +125 -0
  1110. package/src/internal/schema/toCodeDocument.ts +58 -44
  1111. package/src/internal/schema/toCodec.ts +312 -0
  1112. package/src/internal/schema/toDifferJsonPatch.ts +24 -0
  1113. package/src/internal/schema/toEncoderXml.ts +110 -0
  1114. package/src/internal/schema/toEquivalence.ts +76 -0
  1115. package/src/internal/schema/toFormatter.ts +230 -0
  1116. package/src/internal/schema/toIso.ts +20 -0
  1117. package/src/internal/schema/toJsonSchemaDocument.ts +125 -67
  1118. package/src/internal/schema/toRepresentation.ts +1 -1
  1119. package/src/internal/schemaError.ts +8 -0
  1120. package/src/internal/stream.ts +14 -6
  1121. package/src/internal/tracer.ts +4 -0
  1122. package/src/internal/trie.ts +5 -2
  1123. package/src/internal/uuid.ts +4 -0
  1124. package/src/testing/TestSchema.ts +36 -30
  1125. package/src/testing/index.ts +0 -5
  1126. package/src/unstable/ai/AiError.ts +126 -6
  1127. package/src/unstable/ai/AnthropicStructuredOutput.ts +8 -5
  1128. package/src/unstable/ai/Chat.ts +35 -36
  1129. package/src/unstable/ai/EmbeddingModel.ts +27 -15
  1130. package/src/unstable/ai/LanguageModel.ts +283 -100
  1131. package/src/unstable/ai/McpServer.ts +105 -92
  1132. package/src/unstable/ai/OpenAiStructuredOutput.ts +6 -3
  1133. package/src/unstable/ai/Prompt.ts +20 -5
  1134. package/src/unstable/ai/Response.ts +107 -189
  1135. package/src/unstable/ai/Tokenizer.ts +4 -5
  1136. package/src/unstable/ai/Tool.ts +58 -35
  1137. package/src/unstable/ai/Toolkit.ts +43 -37
  1138. package/src/unstable/ai/internal/codec-transformer.ts +3 -2
  1139. package/src/unstable/ai/internal/structured-output.ts +29 -6
  1140. package/src/unstable/arbitrary/Arbitrary.ts +715 -0
  1141. package/src/unstable/arbitrary/index.ts +10 -0
  1142. package/src/unstable/cli/Argument.ts +111 -115
  1143. package/src/unstable/cli/CliError.ts +2 -0
  1144. package/src/unstable/cli/CliOutput.ts +41 -4
  1145. package/src/unstable/cli/Command.ts +79 -78
  1146. package/src/unstable/cli/Completions.ts +4 -4
  1147. package/src/unstable/cli/Flag.ts +158 -169
  1148. package/src/unstable/cli/GlobalFlag.ts +13 -13
  1149. package/src/unstable/cli/Param.ts +150 -159
  1150. package/src/unstable/cli/Primitive.ts +75 -76
  1151. package/src/unstable/cli/Prompt.ts +543 -408
  1152. package/src/unstable/cli/internal/completions/bash.ts +113 -38
  1153. package/src/unstable/cli/internal/completions/descriptor.ts +23 -11
  1154. package/src/unstable/cli/internal/completions/fish.ts +17 -9
  1155. package/src/unstable/cli/internal/completions/zsh.ts +7 -4
  1156. package/src/unstable/cli/internal/config.ts +4 -4
  1157. package/src/unstable/cli/internal/parser.ts +1 -1
  1158. package/src/unstable/cli/internal/wizard.ts +60 -32
  1159. package/src/unstable/cluster/ClusterSchema.ts +19 -1
  1160. package/src/unstable/cluster/ClusterWorkflowEngine.ts +66 -16
  1161. package/src/unstable/cluster/Entity.ts +3 -0
  1162. package/src/unstable/cluster/EntityProxyServer.ts +6 -2
  1163. package/src/unstable/cluster/Envelope.ts +32 -3
  1164. package/src/unstable/cluster/HttpRunner.ts +52 -25
  1165. package/src/unstable/cluster/Message.ts +35 -13
  1166. package/src/unstable/cluster/MessageStorage.ts +69 -24
  1167. package/src/unstable/cluster/Reply.ts +36 -19
  1168. package/src/unstable/cluster/RunnerServer.ts +21 -11
  1169. package/src/unstable/cluster/Runners.ts +93 -80
  1170. package/src/unstable/cluster/Sharding.ts +44 -19
  1171. package/src/unstable/cluster/ShardingConfig.ts +23 -23
  1172. package/src/unstable/cluster/SocketRunner.ts +5 -4
  1173. package/src/unstable/cluster/SqlMessageStorage.ts +12 -8
  1174. package/src/unstable/cluster/SqlRunnerStorage.ts +18 -10
  1175. package/src/unstable/cluster/internal/clusterAbandon.ts +14 -0
  1176. package/src/unstable/cluster/internal/entityManager.ts +15 -6
  1177. package/src/unstable/cluster/internal/interruptors.ts +58 -1
  1178. package/src/unstable/cluster/internal/resourceRef.ts +15 -7
  1179. package/src/unstable/devtools/DevToolsClient.ts +13 -3
  1180. package/src/unstable/encoding/Ini.ts +2 -0
  1181. package/src/unstable/encoding/SchemaBinary.ts +5308 -0
  1182. package/src/unstable/encoding/Sse.ts +1 -1
  1183. package/src/unstable/encoding/Toml.ts +7 -5
  1184. package/src/unstable/encoding/Yaml.ts +18 -5
  1185. package/src/unstable/encoding/index.ts +2 -2
  1186. package/src/unstable/eventlog/Event.ts +7 -7
  1187. package/src/unstable/eventlog/EventJournal.ts +22 -15
  1188. package/src/unstable/eventlog/EventLog.ts +24 -14
  1189. package/src/unstable/eventlog/EventLogMessage.ts +25 -15
  1190. package/src/unstable/eventlog/EventLogRemote.ts +15 -4
  1191. package/src/unstable/eventlog/EventLogServerUnencrypted.ts +2 -2
  1192. package/src/unstable/eventlog/SqlEventJournal.ts +35 -10
  1193. package/src/unstable/eventlog/SqlEventLogServerUnencrypted.ts +11 -1
  1194. package/src/unstable/http/Cookies.ts +2 -102
  1195. package/src/unstable/http/FetchHttpClient.ts +1 -1
  1196. package/src/unstable/http/FindMyWay/internal/router.ts +139 -33
  1197. package/src/unstable/http/FindMyWay.ts +15 -5
  1198. package/src/unstable/http/Headers.ts +3 -48
  1199. package/src/unstable/http/HttpBody.ts +107 -36
  1200. package/src/unstable/http/HttpClient.ts +41 -30
  1201. package/src/unstable/http/HttpClientRequest.ts +32 -18
  1202. package/src/unstable/http/HttpClientResponse.ts +16 -3
  1203. package/src/unstable/http/HttpEffect.ts +145 -73
  1204. package/src/unstable/http/HttpIncomingMessage.ts +4 -4
  1205. package/src/unstable/http/HttpMiddleware.ts +43 -24
  1206. package/src/unstable/http/HttpPlatform.ts +62 -20
  1207. package/src/unstable/http/HttpRouter.ts +27 -16
  1208. package/src/unstable/http/HttpServer.ts +18 -57
  1209. package/src/unstable/http/HttpServerRequest.ts +17 -15
  1210. package/src/unstable/http/HttpServerRespondable.ts +1 -1
  1211. package/src/unstable/http/HttpServerResponse.ts +49 -40
  1212. package/src/unstable/http/HttpStaticServer.ts +30 -28
  1213. package/src/unstable/http/Mime.ts +76 -0
  1214. package/src/unstable/http/Multipart.ts +35 -18
  1215. package/src/unstable/http/MultipartParser/internal/multipart.ts +10 -3
  1216. package/src/unstable/http/MultipartParser.ts +4 -3
  1217. package/src/unstable/http/UrlParams.ts +3 -161
  1218. package/src/unstable/http/index.ts +5 -0
  1219. package/src/unstable/http/internal/compression.ts +11 -12
  1220. package/src/unstable/http/internal/headers.ts +7 -0
  1221. package/src/unstable/http/internal/httpBody.ts +9 -0
  1222. package/src/unstable/http/internal/mimeTypes.ts +395 -0
  1223. package/src/unstable/httpapi/HttpApiBuilder.ts +63 -11
  1224. package/src/unstable/httpapi/HttpApiClient.ts +44 -24
  1225. package/src/unstable/httpapi/HttpApiEndpoint.ts +24 -11
  1226. package/src/unstable/httpapi/HttpApiError.ts +3 -1
  1227. package/src/unstable/httpapi/HttpApiMiddleware.ts +7 -5
  1228. package/src/unstable/httpapi/HttpApiScalar.ts +30 -27
  1229. package/src/unstable/httpapi/HttpApiSchema.ts +14 -7
  1230. package/src/unstable/httpapi/HttpApiSwagger.ts +6 -3
  1231. package/src/unstable/httpapi/HttpApiTest.ts +6 -1
  1232. package/src/unstable/httpapi/OpenApi.ts +32 -22
  1233. package/src/unstable/net/IpInterface.ts +242 -0
  1234. package/src/unstable/net/IpNetwork.ts +357 -0
  1235. package/src/unstable/net/NetAddress.ts +1271 -0
  1236. package/src/unstable/net/index.ts +20 -0
  1237. package/src/unstable/observability/OtlpExporter.ts +5 -6
  1238. package/src/unstable/observability/OtlpLogger.ts +9 -9
  1239. package/src/unstable/observability/OtlpMetrics.ts +9 -8
  1240. package/src/unstable/observability/OtlpResource.ts +5 -4
  1241. package/src/unstable/observability/OtlpTracer.ts +103 -81
  1242. package/src/unstable/observability/internal/otlpEnv.ts +10 -13
  1243. package/src/unstable/persistence/PersistedCache.ts +1 -1
  1244. package/src/unstable/persistence/PersistedQueue.ts +1100 -291
  1245. package/src/unstable/persistence/RateLimiter.ts +64 -58
  1246. package/src/unstable/process/ChildProcess.ts +15 -4
  1247. package/src/unstable/process/ChildProcessSpawner.ts +1 -1
  1248. package/src/unstable/reactivity/Atom.ts +6 -3
  1249. package/src/unstable/reactivity/AtomHttpApi.ts +21 -10
  1250. package/src/unstable/reactivity/AtomRegistry.ts +2 -4
  1251. package/src/unstable/reactivity/AtomRpc.ts +6 -5
  1252. package/src/unstable/reactivity/Hydration.ts +26 -7
  1253. package/src/unstable/reactivity/Reactivity.ts +49 -36
  1254. package/src/unstable/rpc/RpcClient.ts +100 -82
  1255. package/src/unstable/rpc/RpcMessage.ts +78 -11
  1256. package/src/unstable/rpc/RpcMiddleware.ts +7 -5
  1257. package/src/unstable/rpc/RpcSerialization.ts +82 -92
  1258. package/src/unstable/rpc/RpcServer.ts +171 -93
  1259. package/src/unstable/schema/Model.ts +8 -7
  1260. package/src/unstable/schema/VariantSchema.ts +3 -0
  1261. package/src/unstable/socket/Socket.ts +714 -383
  1262. package/src/unstable/socket/SocketServer.ts +5 -35
  1263. package/src/unstable/sql/SqlClient.ts +42 -7
  1264. package/src/unstable/sql/SqlConnection.ts +18 -0
  1265. package/src/unstable/sql/SqlModel.ts +1 -1
  1266. package/src/unstable/sql/Statement.ts +46 -20
  1267. package/src/unstable/workers/Transferable.ts +1 -1
  1268. package/src/unstable/workers/Worker.ts +3 -1
  1269. package/src/unstable/workflow/Activity.ts +20 -9
  1270. package/src/unstable/workflow/DurableClock.ts +1 -1
  1271. package/src/unstable/workflow/DurableDeferred.ts +6 -0
  1272. package/src/unstable/workflow/DurableQueue.ts +8 -0
  1273. package/src/unstable/workflow/Workflow.ts +105 -28
  1274. package/src/unstable/workflow/WorkflowEngine.ts +22 -0
  1275. package/src/unstable/workflow/WorkflowProxy.ts +8 -4
  1276. package/dist/internal/schema/schema.d.ts.map +0 -1
  1277. package/dist/internal/schema/schema.js.map +0 -1
  1278. package/dist/internal/schema/toArbitrary.d.ts +0 -2
  1279. package/dist/internal/schema/toArbitrary.d.ts.map +0 -1
  1280. package/dist/internal/schema/toArbitrary.js +0 -705
  1281. package/dist/internal/schema/toArbitrary.js.map +0 -1
  1282. package/dist/testing/FastCheck.d.ts +0 -90
  1283. package/dist/testing/FastCheck.d.ts.map +0 -1
  1284. package/dist/testing/FastCheck.js +0 -90
  1285. package/dist/testing/FastCheck.js.map +0 -1
  1286. package/dist/unstable/encoding/Msgpack.d.ts +0 -185
  1287. package/dist/unstable/encoding/Msgpack.d.ts.map +0 -1
  1288. package/dist/unstable/encoding/Msgpack.js +0 -227
  1289. package/dist/unstable/encoding/Msgpack.js.map +0 -1
  1290. package/src/internal/schema/toArbitrary.ts +0 -843
  1291. package/src/testing/FastCheck.ts +0 -90
  1292. package/src/unstable/encoding/Msgpack.ts +0 -432
  1293. /package/dist/internal/{schema → arbitrary}/schema.d.ts +0 -0
package/src/SchemaAST.ts CHANGED
@@ -17,7 +17,7 @@ import * as Effect from "./Effect.ts"
17
17
  import * as Exit from "./Exit.ts"
18
18
  import { format, formatPropertyKey } from "./Formatter.ts"
19
19
  import { identity, memoize, memoizeIdempotent } from "./Function.ts"
20
- import { effectIsExit, iterateEager } from "./internal/effect.ts"
20
+ import { effectIsExit, iterateConcurrent, iterateEager, resolveConcurrency } from "./internal/effect.ts"
21
21
  import * as InternalRecord from "./internal/record.ts"
22
22
  import * as InternalAnnotations from "./internal/schema/annotations.ts"
23
23
  import * as InternalSchemaCause from "./internal/schema/cause.ts"
@@ -30,7 +30,7 @@ import * as SchemaGetter from "./SchemaGetter.ts"
30
30
  import * as SchemaIssue from "./SchemaIssue.ts"
31
31
  import type * as SchemaParser from "./SchemaParser.ts"
32
32
  import * as SchemaTransformation from "./SchemaTransformation.ts"
33
- import type * as FastCheck from "./testing/FastCheck.ts"
33
+ import type * as Types from "./Types.ts"
34
34
 
35
35
  /**
36
36
  * Discriminated union of all AST node types.
@@ -41,14 +41,13 @@ import type * as FastCheck from "./testing/FastCheck.ts"
41
41
  * ({@link isString}, {@link isObjects}, etc.) to narrow to a specific variant,
42
42
  * then access variant-specific fields.
43
43
  *
44
- * - All variants share the {@link Base} fields: `annotations`, `checks`,
45
- * `encoding`, `context`.
44
+ * - All variants share the `annotations`, `checks`, `encoding`, and `context`
45
+ * fields.
46
46
  * - Discriminate on the `_tag` field (e.g. `"String"`, `"Objects"`, `"Union"`).
47
47
  *
48
- * @see {@link Base}
49
48
  * @see {@link isAST}
50
49
  * @category models
51
- * @since 3.10.0
50
+ * @since 4.0.0
52
51
  */
53
52
  export type AST =
54
53
  | Declaration
@@ -398,7 +397,25 @@ export const isSuspend = makeGuard("Suspend")
398
397
  * @category models
399
398
  * @since 4.0.0
400
399
  */
401
- export class Link {
400
+ export interface Link {
401
+ readonly to: AST
402
+ readonly transformation:
403
+ | SchemaTransformation.Transformation<any, any, any, any>
404
+ | SchemaTransformation.Middleware<any, any, any, any, any, any>
405
+ }
406
+
407
+ /**
408
+ * Constructs a {@link Link}.
409
+ *
410
+ * @category constructors
411
+ * @since 4.0.0
412
+ */
413
+ export const Link: new(
414
+ to: AST,
415
+ transformation:
416
+ | SchemaTransformation.Transformation<any, any, any, any>
417
+ | SchemaTransformation.Middleware<any, any, any, any, any, any>
418
+ ) => Link = class {
402
419
  readonly to: AST
403
420
  readonly transformation:
404
421
  | SchemaTransformation.Transformation<any, any, any, any>
@@ -421,7 +438,7 @@ export class Link {
421
438
  *
422
439
  * **Details**
423
440
  *
424
- * Stored on {@link Base.encoding}. When `undefined`, the node has no
441
+ * Stored on an AST node's `encoding` field. When `undefined`, the node has no
425
442
  * encoding transformation (type and encoded forms are identical).
426
443
  *
427
444
  * @see {@link Link}
@@ -437,22 +454,25 @@ export type Encoding = readonly [Link, ...Array<Link>]
437
454
  * **Details**
438
455
  *
439
456
  * Pass to `Schema.decodeUnknown`, `Schema.encode`, and related APIs to customize
440
- * error reporting, excess property handling, output key ordering, check
441
- * execution, and asynchronous parser concurrency.
457
+ * error reporting, excess property handling, check execution, and product
458
+ * concurrency. Options apply throughout the parse; schema annotations do not
459
+ * override them.
442
460
  *
443
461
  * - `errors` — `"first"` (default) stops at the first error; `"all"` collects
444
462
  * every error.
445
463
  * - `onExcessProperty` — `"ignore"` (default) strips unknown object keys;
446
- * `"error"` fails; `"preserve"` keeps them.
447
- * - `propertyOrder` — `"none"` (default) lets the system choose key order;
448
- * `"original"` preserves input key order.
464
+ * `"error"` fails.
449
465
  * - `disableChecks` — skips validation checks while still applying defaults and
450
466
  * transformations.
451
- * - `concurrency` — maximum number of async parse effects to run concurrently;
452
- * defaults to `1`, or use `"unbounded"`.
467
+ * - `concurrency` — controls concurrent parsing of tuple elements, array
468
+ * elements, struct fields, and record entries using the same semantics as
469
+ * `Effect.forEach`; the default is sequential.
453
470
  * - `reportInput` — includes rejected input values in value-bearing schema
454
471
  * issues.
455
472
  *
473
+ * Object property order is unspecified, including in values passed to checks.
474
+ * Decoding and encoding do not guarantee preservation of input key order.
475
+ *
456
476
  * @category options
457
477
  * @since 3.10.0
458
478
  */
@@ -476,48 +496,45 @@ export interface ParseOptions {
476
496
  * **Details**
477
497
  *
478
498
  * The default, `"ignore"`, strips unspecified properties from the output. Use
479
- * `"error"` to fail when an excess property is present, or `"preserve"` to
480
- * keep excess properties in the output.
499
+ * `"error"` to fail when an excess property is present. A key is covered by a
500
+ * declared property or any index signature selecting that key. This applies
501
+ * to structs, records, and structs with rest. Values must satisfy every
502
+ * applicable index signature. Empty structs keep their non-nullish behavior.
481
503
  *
482
504
  * @default "ignore"
483
505
  */
484
- readonly onExcessProperty?: "ignore" | "error" | "preserve" | undefined
506
+ readonly onExcessProperty?: "ignore" | "error" | undefined
485
507
 
486
508
  /**
487
- * The `propertyOrder` option provides control over the order of object fields
488
- * in the output. This feature is useful when the sequence of keys is
489
- * important for the consuming processes or when maintaining the input order
490
- * enhances readability and usability.
509
+ * Whether to disable checks while still applying defaults and
510
+ * transformations.
511
+ */
512
+ readonly disableChecks?: boolean | undefined
513
+
514
+ /**
515
+ * Controls how many children of a product schema may parse concurrently.
491
516
  *
492
517
  * **Details**
493
518
  *
494
- * By default, the `propertyOrder` option is set to `"none"`. This means that
495
- * the internal system decides the order of keys to optimize parsing speed.
519
+ * This option has the same concurrency semantics as {@link Effect.forEach}.
520
+ * It applies to tuples, arrays, structs, records, and structs with rest. Each
521
+ * nested product applies the limit independently. Union members remain
522
+ * sequential, though products inside the current union member still receive
523
+ * the option.
496
524
  *
497
- * Setting `propertyOrder` to `"original"` ensures that the keys are ordered
498
- * as they appear in the input during the decoding/encoding process.
525
+ * Array and tuple outputs retain their element order. Other observable work,
526
+ * including issue accumulation and colliding transformed record keys, follows
527
+ * effect completion order when concurrency is greater than `1`.
499
528
  *
500
529
  * **Gotchas**
501
530
  *
502
- * The key order for `"none"` should not be considered stable and may change
503
- * in future updates without notice.
504
- *
505
- * @default "none"
506
- */
507
- readonly propertyOrder?: "none" | "original" | undefined
508
-
509
- /**
510
- * Whether to disable checks while still applying defaults and
511
- * transformations.
512
- */
513
- readonly disableChecks?: boolean | undefined
514
-
515
- /**
516
- * The maximum number of async effects to run concurrently.
531
+ * With `errors: "first"`, the first observed child failure interrupts the
532
+ * remaining children and may not belong to the earliest product position.
533
+ * Concurrent children may perform effects before another child fails.
517
534
  *
518
- * @default 1
535
+ * @default undefined
519
536
  */
520
- readonly concurrency?: number | "unbounded" | undefined
537
+ readonly concurrency?: Types.Concurrency | undefined
521
538
 
522
539
  /**
523
540
  * Whether schema issues should retain and report rejected input values.
@@ -533,13 +550,12 @@ export interface ParseOptions {
533
550
  * Enabling this option can retain or disclose secrets, personally
534
551
  * identifiable information, and large object graphs. The `input` field is
535
552
  * enumerable and may be included by object enumeration, spread, or
536
- * serialization. Disabling it on a nested schema does not redact that value
537
- * from an ancestor issue whose input reporting remains enabled. Issues
538
- * returned directly by user-defined declarations, checks, transformations,
539
- * and middleware are not modified; their authors decide whether to retain an
540
- * input. To respect this option, pass the callback's input and parse options
541
- * directly to a value-bearing issue constructor. Custom messages and
542
- * annotations remain the caller's responsibility regardless of this option.
553
+ * serialization. Issues returned directly by user-defined declarations,
554
+ * checks, transformations, and middleware are not modified; their authors
555
+ * decide whether to retain an input. To respect this option, pass the
556
+ * callback's input and parse options directly to a value-bearing issue
557
+ * constructor. Custom messages and annotations remain the caller's
558
+ * responsibility regardless of this option.
543
559
  * Formatting an issue with `SchemaIssue.makeFormatterDefault()`, reading
544
560
  * `SchemaError.message`, or formatting a Standard Schema failure can disclose
545
561
  * retained input.
@@ -553,7 +569,7 @@ export interface ParseOptions {
553
569
  export const defaultParseOptions: ParseOptions = {}
554
570
 
555
571
  /**
556
- * Represents per-property metadata attached to AST nodes via {@link Base.context}.
572
+ * Represents per-property metadata attached to an AST node's `context` field.
557
573
  *
558
574
  * **Details**
559
575
  *
@@ -568,12 +584,31 @@ export const defaultParseOptions: ParseOptions = {}
568
584
  * - `annotations` — key-level annotations (e.g. description of the key
569
585
  * itself).
570
586
  *
571
- * @see {@link optionalKey}
587
+ * @see `Schema.optionalKey`
572
588
  * @see {@link isOptional}
573
589
  * @category models
574
590
  * @since 4.0.0
575
591
  */
576
- export class Context {
592
+ export interface Context {
593
+ readonly isOptional: boolean
594
+ readonly isMutable: boolean
595
+ /** Used for constructor default values (e.g. `withConstructorDefault` API) */
596
+ readonly constructorDefault: Link | undefined
597
+ readonly annotations: Schema.Annotations.Key<unknown> | undefined
598
+ }
599
+
600
+ /**
601
+ * Constructs a {@link Context}.
602
+ *
603
+ * @category constructors
604
+ * @since 4.0.0
605
+ */
606
+ export const Context: new(
607
+ isOptional: boolean,
608
+ isMutable: boolean, /** Used for constructor default values (e.g. `withConstructorDefault` API) */
609
+ constructorDefault?: Link | undefined,
610
+ annotations?: Schema.Annotations.Key<unknown> | undefined
611
+ ) => Context = class {
577
612
  readonly isOptional: boolean
578
613
  readonly isMutable: boolean
579
614
  /** Used for constructor default values (e.g. `withConstructorDefault` API) */
@@ -595,8 +630,8 @@ export class Context {
595
630
  }
596
631
 
597
632
  /**
598
- * Non-empty array of validation {@link Check} values attached to an AST node
599
- * via {@link Base.checks}.
633
+ * Non-empty array of validation {@link Check} values attached to an AST node's
634
+ * `checks` field.
600
635
  *
601
636
  * **Details**
602
637
  *
@@ -612,28 +647,17 @@ export class Context {
612
647
  export type Checks = readonly [Check<any>, ...Array<Check<any>>]
613
648
 
614
649
  const TypeId = "~effect/Schema"
650
+ interface ASTNode {
651
+ readonly [TypeId]: typeof TypeId
652
+ readonly _tag: string
653
+ readonly annotations: Schema.Annotations.Annotations | undefined
654
+ readonly checks: Checks | undefined
655
+ readonly encoding: Encoding | undefined
656
+ readonly context: Context | undefined
657
+ toString(): string
658
+ }
615
659
 
616
- /**
617
- * Represents the abstract base class for all {@link AST} node variants.
618
- *
619
- * **Details**
620
- *
621
- * Every AST node extends `Base` and inherits these fields:
622
- *
623
- * - `annotations` — user-supplied metadata (identifier, title, description,
624
- * arbitrary keys).
625
- * - `checks` — optional {@link Checks} for post-type-match validation.
626
- * - `encoding` — optional {@link Encoding} chain for type ↔ wire
627
- * transformations.
628
- * - `context` — optional {@link Context} for per-property metadata.
629
- *
630
- * Subclasses add a `_tag` discriminant and variant-specific data.
631
- *
632
- * @see {@link AST}
633
- * @category models
634
- * @since 4.0.0
635
- */
636
- export abstract class Base {
660
+ abstract class ASTNodeImpl implements ASTNode {
637
661
  readonly [TypeId] = TypeId
638
662
  abstract readonly _tag: string
639
663
  readonly annotations: Schema.Annotations.Annotations | undefined
@@ -657,6 +681,10 @@ export abstract class Base {
657
681
  }
658
682
  }
659
683
 
684
+ type DeclarationRun = (
685
+ typeParameters: ReadonlyArray<AST>
686
+ ) => (input: unknown, self: Declaration, options: ParseOptions) => Effect.Effect<any, SchemaIssue.Issue>
687
+
660
688
  /**
661
689
  * AST node for user-defined opaque types with custom parsing logic.
662
690
  *
@@ -670,35 +698,78 @@ export abstract class Base {
670
698
  * - `typeParameters` — inner schemas this declaration is parameterized over
671
699
  * (e.g. the element type for a custom collection).
672
700
  * - `run` — factory that receives `typeParameters` and returns a parser that
673
- * validates or transforms raw input.
701
+ * validates or transforms raw input. The `Effect` returned by the parser must
702
+ * complete synchronously.
674
703
  *
675
704
  * @see {@link isDeclaration}
676
705
  * @category models
677
- * @since 3.10.0
706
+ * @since 4.0.0
678
707
  */
679
- export class Declaration extends Base {
708
+ export interface Declaration extends ASTNode {
709
+ readonly _tag: "Declaration"
710
+ readonly typeParameters: ReadonlyArray<AST>
711
+ readonly run: DeclarationRun
712
+ readonly encodingChecks: Checks | undefined
713
+ /**
714
+ * Parser factory {@link flip} swaps in, so a declaration can behave
715
+ * differently when encoding. `undefined` reuses `run`.
716
+ */
717
+ readonly encodingRun: DeclarationRun | undefined
718
+ /** @internal */
719
+
720
+ getParser(): SchemaParser.Parser
721
+ /** @internal */
722
+
723
+ recur(recur: (ast: AST) => AST): Declaration
724
+ /** @internal */
725
+
726
+ flip(recur: (ast: AST) => AST): Declaration
727
+ /** @internal */
728
+
729
+ getExpected(): string
730
+ }
731
+
732
+ /**
733
+ * Constructs a {@link Declaration}.
734
+ *
735
+ * @category constructors
736
+ * @since 4.0.0
737
+ */
738
+ export const Declaration: new(
739
+ typeParameters: ReadonlyArray<AST>,
740
+ run: DeclarationRun,
741
+ annotations?: Schema.Annotations.Annotations,
742
+ checks?: Checks,
743
+ encoding?: Encoding,
744
+ context?: Context,
745
+ encodingChecks?: Checks,
746
+ encodingRun?: DeclarationRun
747
+ ) => Declaration = class extends ASTNodeImpl {
680
748
  readonly _tag = "Declaration"
681
749
  readonly typeParameters: ReadonlyArray<AST>
682
- readonly run: (
683
- typeParameters: ReadonlyArray<AST>
684
- ) => (input: unknown, self: Declaration, options: ParseOptions) => Effect.Effect<any, SchemaIssue.Issue, any>
750
+ readonly run: DeclarationRun
685
751
  readonly encodingChecks: Checks | undefined
752
+ /**
753
+ * Parser factory {@link flip} swaps in, so a declaration can behave
754
+ * differently when encoding. `undefined` reuses `run`.
755
+ */
756
+ readonly encodingRun: DeclarationRun | undefined
686
757
 
687
758
  constructor(
688
759
  typeParameters: ReadonlyArray<AST>,
689
- run: (
690
- typeParameters: ReadonlyArray<AST>
691
- ) => (input: unknown, self: Declaration, options: ParseOptions) => Effect.Effect<any, SchemaIssue.Issue, any>,
760
+ run: DeclarationRun,
692
761
  annotations?: Schema.Annotations.Annotations,
693
762
  checks?: Checks,
694
763
  encoding?: Encoding,
695
764
  context?: Context,
696
- encodingChecks?: Checks
765
+ encodingChecks?: Checks,
766
+ encodingRun?: DeclarationRun
697
767
  ) {
698
768
  super(annotations, checks, encoding, context)
699
769
  this.typeParameters = typeParameters
700
770
  this.run = run
701
771
  this.encodingChecks = encodingChecks
772
+ this.encodingRun = encodingRun
702
773
  }
703
774
  /** @internal */
704
775
  getParser(): SchemaParser.Parser {
@@ -708,19 +779,26 @@ export class Declaration extends Base {
708
779
  return (run ??= this.run(this.typeParameters))(input, this, options)
709
780
  }
710
781
  }
711
- private _rebuild(recur: (ast: AST) => AST, checks: Checks | undefined, encodingChecks: Checks | undefined) {
782
+ private _rebuild(
783
+ recur: (ast: AST) => AST,
784
+ checks: Checks | undefined,
785
+ encodingChecks: Checks | undefined,
786
+ run: DeclarationRun,
787
+ encodingRun: DeclarationRun | undefined
788
+ ) {
712
789
  const tps = mapOrSame(this.typeParameters, recur)
713
- return tps === this.typeParameters && checks === this.checks && encodingChecks === this.encodingChecks ?
790
+ return tps === this.typeParameters && checks === this.checks && encodingChecks === this.encodingChecks &&
791
+ run === this.run && encodingRun === this.encodingRun ?
714
792
  this :
715
- new Declaration(tps, this.run, this.annotations, checks, undefined, this.context, encodingChecks)
793
+ new Declaration(tps, run, this.annotations, checks, undefined, this.context, encodingChecks, encodingRun)
716
794
  }
717
795
  /** @internal */
718
796
  recur(recur: (ast: AST) => AST) {
719
- return this._rebuild(recur, this.checks, this.encodingChecks)
797
+ return this._rebuild(recur, this.checks, this.encodingChecks, this.run, this.encodingRun)
720
798
  }
721
799
  /** @internal */
722
800
  flip(recur: (ast: AST) => AST) {
723
- return this._rebuild(recur, this.encodingChecks, this.checks)
801
+ return this._rebuild(recur, this.encodingChecks, this.checks, this.encodingRun ?? this.run, this.run)
724
802
  }
725
803
  /** @internal */
726
804
  getExpected(): string {
@@ -742,7 +820,28 @@ export class Declaration extends Base {
742
820
  * @category models
743
821
  * @since 4.0.0
744
822
  */
745
- export class Null extends Base {
823
+ export interface Null extends ASTNode {
824
+ readonly _tag: "Null"
825
+ /** @internal */
826
+
827
+ getParser(): SchemaParser.Parser
828
+ /** @internal */
829
+
830
+ getExpected(): string
831
+ }
832
+
833
+ /**
834
+ * Constructs a {@link Null}.
835
+ *
836
+ * @category constructors
837
+ * @since 4.0.0
838
+ */
839
+ export const Null: new(
840
+ annotations?: Schema.Annotations.Annotations | undefined,
841
+ checks?: Checks | undefined,
842
+ encoding?: Encoding | undefined,
843
+ context?: Context | undefined
844
+ ) => Null = class extends ASTNodeImpl {
746
845
  readonly _tag = "Null"
747
846
  /** @internal */
748
847
  getParser() {
@@ -782,7 +881,31 @@ export {
782
881
  * @category models
783
882
  * @since 4.0.0
784
883
  */
785
- export class Undefined extends Base {
884
+ export interface Undefined extends ASTNode {
885
+ readonly _tag: "Undefined"
886
+ /** @internal */
887
+
888
+ getParser(): SchemaParser.Parser
889
+ /** @internal */
890
+
891
+ toCodecJson(): AST
892
+ /** @internal */
893
+
894
+ getExpected(): string
895
+ }
896
+
897
+ /**
898
+ * Constructs a {@link Undefined}.
899
+ *
900
+ * @category constructors
901
+ * @since 4.0.0
902
+ */
903
+ export const Undefined: new(
904
+ annotations?: Schema.Annotations.Annotations | undefined,
905
+ checks?: Checks | undefined,
906
+ encoding?: Encoding | undefined,
907
+ context?: Context | undefined
908
+ ) => Undefined = class extends ASTNodeImpl {
786
909
  readonly _tag = "Undefined"
787
910
  /** @internal */
788
911
  getParser() {
@@ -842,7 +965,33 @@ export {
842
965
  * @category models
843
966
  * @since 4.0.0
844
967
  */
845
- export class Void extends Base {
968
+ export interface Void extends ASTNode {
969
+ readonly _tag: "Void"
970
+ /** @internal */
971
+
972
+ getParser(): (
973
+ input: unknown
974
+ ) => InternalParser.Success<undefined, never> | InternalParser.Success<typeof InternalParser.missing, never>
975
+ /** @internal */
976
+
977
+ toCodecJson(): AST
978
+ /** @internal */
979
+
980
+ getExpected(): string
981
+ }
982
+
983
+ /**
984
+ * Constructs a {@link Void}.
985
+ *
986
+ * @category constructors
987
+ * @since 4.0.0
988
+ */
989
+ export const Void: new(
990
+ annotations?: Schema.Annotations.Annotations | undefined,
991
+ checks?: Checks | undefined,
992
+ encoding?: Encoding | undefined,
993
+ context?: Context | undefined
994
+ ) => Void = class extends ASTNodeImpl {
846
995
  readonly _tag = "Void"
847
996
  /** @internal */
848
997
  getParser() {
@@ -897,7 +1046,28 @@ export {
897
1046
  * @category models
898
1047
  * @since 4.0.0
899
1048
  */
900
- export class Never extends Base {
1049
+ export interface Never extends ASTNode {
1050
+ readonly _tag: "Never"
1051
+ /** @internal */
1052
+
1053
+ getParser(): SchemaParser.Parser
1054
+ /** @internal */
1055
+
1056
+ getExpected(): string
1057
+ }
1058
+
1059
+ /**
1060
+ * Constructs a {@link Never}.
1061
+ *
1062
+ * @category constructors
1063
+ * @since 4.0.0
1064
+ */
1065
+ export const Never: new(
1066
+ annotations?: Schema.Annotations.Annotations | undefined,
1067
+ checks?: Checks | undefined,
1068
+ encoding?: Encoding | undefined,
1069
+ context?: Context | undefined
1070
+ ) => Never = class extends ASTNodeImpl {
901
1071
  readonly _tag = "Never"
902
1072
  /** @internal */
903
1073
  getParser() {
@@ -934,7 +1104,28 @@ export const never = new Never()
934
1104
  * @category models
935
1105
  * @since 4.0.0
936
1106
  */
937
- export class Any extends Base {
1107
+ export interface Any extends ASTNode {
1108
+ readonly _tag: "Any"
1109
+ /** @internal */
1110
+
1111
+ getParser(): SchemaParser.Parser
1112
+ /** @internal */
1113
+
1114
+ getExpected(): string
1115
+ }
1116
+
1117
+ /**
1118
+ * Constructs a {@link Any}.
1119
+ *
1120
+ * @category constructors
1121
+ * @since 4.0.0
1122
+ */
1123
+ export const Any: new(
1124
+ annotations?: Schema.Annotations.Annotations | undefined,
1125
+ checks?: Checks | undefined,
1126
+ encoding?: Encoding | undefined,
1127
+ context?: Context | undefined
1128
+ ) => Any = class extends ASTNodeImpl {
938
1129
  readonly _tag = "Any"
939
1130
  /** @internal */
940
1131
  getParser() {
@@ -974,7 +1165,28 @@ export const any = new Any()
974
1165
  * @category models
975
1166
  * @since 4.0.0
976
1167
  */
977
- export class Unknown extends Base {
1168
+ export interface Unknown extends ASTNode {
1169
+ readonly _tag: "Unknown"
1170
+ /** @internal */
1171
+
1172
+ getParser(): SchemaParser.Parser
1173
+ /** @internal */
1174
+
1175
+ getExpected(): string
1176
+ }
1177
+
1178
+ /**
1179
+ * Constructs a {@link Unknown}.
1180
+ *
1181
+ * @category constructors
1182
+ * @since 4.0.0
1183
+ */
1184
+ export const Unknown: new(
1185
+ annotations?: Schema.Annotations.Annotations | undefined,
1186
+ checks?: Checks | undefined,
1187
+ encoding?: Encoding | undefined,
1188
+ context?: Context | undefined
1189
+ ) => Unknown = class extends ASTNodeImpl {
978
1190
  readonly _tag = "Unknown"
979
1191
  /** @internal */
980
1192
  getParser() {
@@ -1009,9 +1221,30 @@ export const unknown = new Unknown()
1009
1221
  * @see {@link isObjectKeyword}
1010
1222
  *
1011
1223
  * @category models
1012
- * @since 3.10.0
1224
+ * @since 4.0.0
1013
1225
  */
1014
- export class ObjectKeyword extends Base {
1226
+ export interface ObjectKeyword extends ASTNode {
1227
+ readonly _tag: "ObjectKeyword"
1228
+ /** @internal */
1229
+
1230
+ getParser(): SchemaParser.Parser
1231
+ /** @internal */
1232
+
1233
+ getExpected(): string
1234
+ }
1235
+
1236
+ /**
1237
+ * Constructs a {@link ObjectKeyword}.
1238
+ *
1239
+ * @category constructors
1240
+ * @since 4.0.0
1241
+ */
1242
+ export const ObjectKeyword: new(
1243
+ annotations?: Schema.Annotations.Annotations | undefined,
1244
+ checks?: Checks | undefined,
1245
+ encoding?: Encoding | undefined,
1246
+ context?: Context | undefined
1247
+ ) => ObjectKeyword = class extends ASTNodeImpl {
1015
1248
  readonly _tag = "ObjectKeyword"
1016
1249
  /** @internal */
1017
1250
  getParser() {
@@ -1051,7 +1284,43 @@ export const objectKeyword = new ObjectKeyword()
1051
1284
  * @category models
1052
1285
  * @since 4.0.0
1053
1286
  */
1054
- export class Enum extends Base {
1287
+ export interface Enum extends ASTNode {
1288
+ readonly _tag: "Enum"
1289
+ readonly enums: ReadonlyArray<
1290
+ readonly [
1291
+ string,
1292
+ string | number
1293
+ ]
1294
+ >
1295
+ /** @internal */
1296
+
1297
+ getParser(): SchemaParser.Parser
1298
+ /** @internal */
1299
+
1300
+ toCodecStringTree(): AST
1301
+ /** @internal */
1302
+
1303
+ getExpected(): string
1304
+ }
1305
+
1306
+ /**
1307
+ * Constructs a {@link Enum}. Numeric values must be finite.
1308
+ *
1309
+ * @category constructors
1310
+ * @since 4.0.0
1311
+ */
1312
+ export const Enum: new(
1313
+ enums: ReadonlyArray<
1314
+ readonly [
1315
+ string,
1316
+ string | number
1317
+ ]
1318
+ >,
1319
+ annotations?: Schema.Annotations.Annotations,
1320
+ checks?: Checks,
1321
+ encoding?: Encoding,
1322
+ context?: Context
1323
+ ) => Enum = class extends ASTNodeImpl {
1055
1324
  readonly _tag = "Enum"
1056
1325
  readonly enums: ReadonlyArray<readonly [string, string | number]>
1057
1326
 
@@ -1063,6 +1332,11 @@ export class Enum extends Base {
1063
1332
  context?: Context
1064
1333
  ) {
1065
1334
  super(annotations, checks, encoding, context)
1335
+ for (const [, value] of enums) {
1336
+ if (typeof value === "number" && !globalThis.Number.isFinite(value)) {
1337
+ throw new Error(`A numeric enum value must be finite, got ${format(value)}`)
1338
+ }
1339
+ }
1066
1340
  this.enums = enums
1067
1341
  }
1068
1342
  /** @internal */
@@ -1079,7 +1353,7 @@ export class Enum extends Base {
1079
1353
  const coercions = Object.fromEntries(this.enums.map(([_, v]) => [globalThis.String(v), v]))
1080
1354
  return replaceEncoding(this, [
1081
1355
  new Link(
1082
- new Union(Object.keys(coercions).map((k) => new Literal(k)), "anyOf"),
1356
+ new Union(Object.keys(coercions).map((k) => new Literal(k))),
1083
1357
  new SchemaTransformation.Transformation(
1084
1358
  SchemaGetter.transform((s) => coercions[s]),
1085
1359
  SchemaGetter.String()
@@ -1103,20 +1377,34 @@ type TemplateLiteralPart =
1103
1377
  | TemplateLiteral
1104
1378
  | Union<TemplateLiteralPart>
1105
1379
 
1106
- function isTemplateLiteralPart(ast: AST): ast is TemplateLiteralPart {
1380
+ function isTemplateLiteralPart(ast: AST, path: string, validated: WeakSet<AST>): ast is TemplateLiteralPart {
1381
+ if (validated.has(ast)) return true
1382
+ if (ast.encoding) {
1383
+ throw new Error(`TemplateLiteral parts cannot have an encoding at ${path}`)
1384
+ }
1385
+ let valid: boolean
1107
1386
  switch (ast._tag) {
1108
1387
  case "String":
1109
1388
  case "Number":
1110
1389
  case "BigInt":
1111
- return true
1390
+ valid = true
1391
+ break
1112
1392
  case "Literal":
1393
+ valid = !ast.checks
1394
+ break
1113
1395
  case "TemplateLiteral":
1114
- return !ast.checks
1396
+ valid = !ast.checks &&
1397
+ ast.parts.every((part, index) => isTemplateLiteralPart(part, `${path}.parts[${index}]`, validated))
1398
+ break
1115
1399
  case "Union":
1116
- return !ast.checks && ast.types.every(isTemplateLiteralPart)
1400
+ valid = !ast.checks &&
1401
+ ast.types.every((part, index) => isTemplateLiteralPart(part, `${path}.types[${index}]`, validated))
1402
+ break
1117
1403
  default:
1118
1404
  return false
1119
1405
  }
1406
+ if (valid) validated.add(ast)
1407
+ return valid
1120
1408
  }
1121
1409
 
1122
1410
  /**
@@ -1130,9 +1418,46 @@ function isTemplateLiteralPart(ast: AST): ast is TemplateLiteralPart {
1130
1418
  *
1131
1419
  * @see {@link isTemplateLiteral}
1132
1420
  * @category models
1133
- * @since 3.10.0
1421
+ * @since 4.0.0
1422
+ */
1423
+ export interface TemplateLiteral extends ASTNode {
1424
+ readonly _tag: "TemplateLiteral"
1425
+ readonly parts: ReadonlyArray<AST>
1426
+ /** @internal */
1427
+ readonly encodedParts: ReadonlyArray<TemplateLiteralPart>
1428
+ /** @internal */
1429
+ readonly literals: ReadonlyArray<string | undefined>
1430
+ /** @internal */
1431
+ readonly suffixLengths: ReadonlyArray<number>
1432
+ /** @internal */
1433
+
1434
+ getParser(compile: SchemaParser.Compiler): SchemaParser.Parser
1435
+ /** @internal */
1436
+
1437
+ getExpected(): string
1438
+ /** @internal */
1439
+
1440
+ matchPart(s: string, options: ParseOptions): string | undefined
1441
+ }
1442
+
1443
+ /**
1444
+ * Constructs a {@link TemplateLiteral}.
1445
+ *
1446
+ * **Gotchas**
1447
+ *
1448
+ * Throws if a part contains an encoding, including inside unions or nested
1449
+ * template literals. Parts must describe their values without transformations.
1450
+ *
1451
+ * @category constructors
1452
+ * @since 4.0.0
1134
1453
  */
1135
- export class TemplateLiteral extends Base {
1454
+ export const TemplateLiteral: new(
1455
+ parts: ReadonlyArray<AST>,
1456
+ annotations?: Schema.Annotations.Annotations,
1457
+ checks?: Checks,
1458
+ encoding?: Encoding,
1459
+ context?: Context
1460
+ ) => TemplateLiteral = class extends ASTNodeImpl {
1136
1461
  readonly _tag = "TemplateLiteral"
1137
1462
  readonly parts: ReadonlyArray<AST>
1138
1463
  /** @internal */
@@ -1152,14 +1477,14 @@ export class TemplateLiteral extends Base {
1152
1477
  super(annotations, checks, encoding, context)
1153
1478
  const encodedParts: Array<TemplateLiteralPart> = []
1154
1479
  const literals: Array<string | undefined> = []
1155
- for (const part of parts) {
1156
- const encoded = toEncoded(part)
1157
- if (isTemplateLiteralPart(encoded)) {
1158
- encodedParts.push(encoded)
1159
- literals.push(encoded._tag === "Literal" ? globalThis.String(encoded.literal) : undefined)
1160
- } else {
1161
- throw new Error(`Invalid TemplateLiteral part ${encoded._tag}`)
1480
+ const validated = new WeakSet<AST>()
1481
+ for (let index = 0; index < parts.length; index++) {
1482
+ const part = parts[index]
1483
+ if (!isTemplateLiteralPart(part, `parts[${index}]`, validated)) {
1484
+ throw new Error(`Invalid TemplateLiteral part ${part._tag}`)
1162
1485
  }
1486
+ encodedParts.push(part)
1487
+ literals.push(part._tag === "Literal" ? globalThis.String(part.literal) : undefined)
1163
1488
  }
1164
1489
  const suffixLengths = new Array<number>(encodedParts.length + 1)
1165
1490
  suffixLengths[encodedParts.length] = 0
@@ -1173,7 +1498,8 @@ export class TemplateLiteral extends Base {
1173
1498
  }
1174
1499
  /** @internal */
1175
1500
  getParser(compile: SchemaParser.Compiler): SchemaParser.Parser {
1176
- const parser = compile(this.asTemplateLiteralParser())
1501
+ const tuple = new Arrays(false, this.parts.map(partFromString), [])
1502
+ const parser = compile(decodeTo(string, tuple, templateLiteralTransformation(this)))
1177
1503
  return (input, options) => {
1178
1504
  if (input === InternalParser.missing) return InternalParser.missingExit
1179
1505
  const result = parser(input, options)
@@ -1194,28 +1520,46 @@ export class TemplateLiteral extends Base {
1194
1520
  matchPart(s: string, options: ParseOptions): string | undefined {
1195
1521
  return segmentTemplateLiteralParts(this, s, options) === undefined ? undefined : s
1196
1522
  }
1197
- /** @internal */
1198
- asTemplateLiteralParser(): Arrays {
1199
- const tuple = new Arrays(false, this.parts.map(partFromString), [])
1200
- return decodeTo(
1201
- string,
1202
- tuple,
1203
- new SchemaTransformation.Transformation(
1204
- SchemaGetter.transformOrFail((s: string, options) => {
1205
- const segments = segmentTemplateLiteralParts(this, s, options)
1206
- if (segments) return Effect.succeed(segments)
1207
- return Effect.fail(
1208
- new SchemaIssue.InvalidValue(
1209
- { expected: "a string matching template literal parts" },
1210
- s,
1211
- options
1212
- )
1213
- )
1214
- }),
1215
- SchemaGetter.transform((parts) => parts.join(""))
1523
+ }
1524
+
1525
+ /** @internal */
1526
+ export function templateLiteralParser(parts: ReadonlyArray<AST>): Arrays {
1527
+ // Encoded members can overlap even when decoding selects exactly one member.
1528
+ // Match their spellings here; the original tuple enforces the union's mode.
1529
+ const normalize = memoize((encoded: AST): AST => {
1530
+ if (encoded._tag !== "Union") return encoded
1531
+ const types = mapOrSame(encoded.types, normalize)
1532
+ return (encoded.options?.mode ?? "anyOf") === "anyOf" && types === encoded.types
1533
+ ? encoded
1534
+ : new Union(
1535
+ types,
1536
+ encoded.options === undefined ? undefined : { ...encoded.options, mode: "anyOf" },
1537
+ encoded.annotations,
1538
+ encoded.checks,
1539
+ undefined,
1540
+ encoded.context
1216
1541
  )
1217
- )
1218
- }
1542
+ })
1543
+ const template = new TemplateLiteral(parts.map((part) => normalize(toEncoded(part))))
1544
+ const tuple = new Arrays(false, parts.map(partFromString), [])
1545
+ return decodeTo(template, tuple, templateLiteralTransformation(template))
1546
+ }
1547
+
1548
+ function templateLiteralTransformation(template: TemplateLiteral) {
1549
+ return new SchemaTransformation.Transformation(
1550
+ SchemaGetter.transformEffect((s: string, options) => {
1551
+ const segments = segmentTemplateLiteralParts(template, s, options)
1552
+ if (segments) return Effect.succeed(segments)
1553
+ return Effect.fail(
1554
+ new SchemaIssue.InvalidValue(
1555
+ { expected: "a string matching template literal parts" },
1556
+ s,
1557
+ options
1558
+ )
1559
+ )
1560
+ }),
1561
+ SchemaGetter.transform((parts: ReadonlyArray<string>) => parts.join(""))
1562
+ )
1219
1563
  }
1220
1564
 
1221
1565
  /**
@@ -1228,9 +1572,35 @@ export class TemplateLiteral extends Base {
1228
1572
  *
1229
1573
  * @see {@link isUniqueSymbol}
1230
1574
  * @category models
1231
- * @since 3.10.0
1575
+ * @since 4.0.0
1576
+ */
1577
+ export interface UniqueSymbol extends ASTNode {
1578
+ readonly _tag: "UniqueSymbol"
1579
+ readonly symbol: symbol
1580
+ /** @internal */
1581
+
1582
+ getParser(): SchemaParser.Parser
1583
+ /** @internal */
1584
+
1585
+ toCodecStringTree(): AST
1586
+ /** @internal */
1587
+
1588
+ getExpected(): string
1589
+ }
1590
+
1591
+ /**
1592
+ * Constructs a {@link UniqueSymbol}.
1593
+ *
1594
+ * @category constructors
1595
+ * @since 4.0.0
1232
1596
  */
1233
- export class UniqueSymbol extends Base {
1597
+ export const UniqueSymbol: new(
1598
+ symbol: symbol,
1599
+ annotations?: Schema.Annotations.Annotations,
1600
+ checks?: Checks,
1601
+ encoding?: Encoding,
1602
+ context?: Context
1603
+ ) => UniqueSymbol = class extends ASTNodeImpl {
1234
1604
  readonly _tag = "UniqueSymbol"
1235
1605
  readonly symbol: symbol
1236
1606
 
@@ -1250,7 +1620,13 @@ export class UniqueSymbol extends Base {
1250
1620
  }
1251
1621
  /** @internal */
1252
1622
  toCodecStringTree(): AST {
1253
- return replaceEncoding(this, [symbolToString])
1623
+ const key = globalThis.Symbol.keyFor(this.symbol)
1624
+ return replaceEncoding(this, [
1625
+ new Link(
1626
+ key === undefined ? never : new Literal(globalThis.String(this.symbol)),
1627
+ symbolToString.transformation
1628
+ )
1629
+ ])
1254
1630
  }
1255
1631
  /** @internal */
1256
1632
  getExpected(): string {
@@ -1275,8 +1651,10 @@ export type LiteralValue = string | number | boolean | bigint
1275
1651
  * **Details**
1276
1652
  *
1277
1653
  * Parsing succeeds only when the input is strictly equal (`===`) to the
1278
- * stored `literal`. Numeric literals must be finite — `Infinity`, `-Infinity`,
1279
- * and `NaN` are rejected at construction time.
1654
+ * stored `literal`, preserving the input value. Both `0` and `-0` are accepted
1655
+ * by either zero literal, and parsing preserves the input's sign. Numeric
1656
+ * literals must be finite. `Infinity`, `-Infinity`, and `NaN` are rejected at
1657
+ * construction time.
1280
1658
  *
1281
1659
  * **Example** (Creating a literal AST)
1282
1660
  *
@@ -1290,9 +1668,41 @@ export type LiteralValue = string | number | boolean | bigint
1290
1668
  * @see {@link LiteralValue}
1291
1669
  * @see {@link isLiteral}
1292
1670
  * @category models
1293
- * @since 3.10.0
1671
+ * @since 4.0.0
1672
+ */
1673
+ export interface Literal extends ASTNode {
1674
+ readonly _tag: "Literal"
1675
+ readonly literal: LiteralValue
1676
+ /** @internal */
1677
+
1678
+ getParser(): SchemaParser.Parser
1679
+ /** @internal */
1680
+
1681
+ matchPart(s: string, _options: ParseOptions): LiteralValue | undefined
1682
+ /** @internal */
1683
+
1684
+ toCodecJson(): AST
1685
+ /** @internal */
1686
+
1687
+ toCodecStringTree(): AST
1688
+ /** @internal */
1689
+
1690
+ getExpected(): string
1691
+ }
1692
+
1693
+ /**
1694
+ * Constructs a {@link Literal}.
1695
+ *
1696
+ * @category constructors
1697
+ * @since 4.0.0
1294
1698
  */
1295
- export class Literal extends Base {
1699
+ export const Literal: new(
1700
+ literal: LiteralValue,
1701
+ annotations?: Schema.Annotations.Annotations,
1702
+ checks?: Checks,
1703
+ encoding?: Encoding,
1704
+ context?: Context
1705
+ ) => Literal = class extends ASTNodeImpl {
1296
1706
  readonly _tag = "Literal"
1297
1707
  readonly literal: LiteralValue
1298
1708
 
@@ -1353,7 +1763,31 @@ function literalToString(ast: Literal): Literal {
1353
1763
  * @category models
1354
1764
  * @since 4.0.0
1355
1765
  */
1356
- export class String extends Base {
1766
+ export interface String extends ASTNode {
1767
+ readonly _tag: "String"
1768
+ /** @internal */
1769
+
1770
+ getParser(): SchemaParser.Parser
1771
+ /** @internal */
1772
+
1773
+ matchPart(s: string, options: ParseOptions): string | undefined
1774
+ /** @internal */
1775
+
1776
+ getExpected(): string
1777
+ }
1778
+
1779
+ /**
1780
+ * Constructs a {@link String}.
1781
+ *
1782
+ * @category constructors
1783
+ * @since 4.0.0
1784
+ */
1785
+ export const String: new(
1786
+ annotations?: Schema.Annotations.Annotations | undefined,
1787
+ checks?: Checks | undefined,
1788
+ encoding?: Encoding | undefined,
1789
+ context?: Context | undefined
1790
+ ) => String = class extends ASTNodeImpl {
1357
1791
  readonly _tag = "String"
1358
1792
  /** @internal */
1359
1793
  getParser() {
@@ -1404,7 +1838,40 @@ export const string = new String()
1404
1838
  * @category models
1405
1839
  * @since 4.0.0
1406
1840
  */
1407
- export class Number extends Base {
1841
+ export interface Number extends ASTNode {
1842
+ readonly _tag: "Number"
1843
+ /** @internal */
1844
+
1845
+ getParser(): SchemaParser.Parser
1846
+ /** @internal */
1847
+
1848
+ matchKey(s: string, options: ParseOptions): number | undefined
1849
+ /** @internal */
1850
+
1851
+ matchPart(s: string, options: ParseOptions): number | undefined
1852
+ /** @internal */
1853
+
1854
+ toCodecJson(): AST
1855
+ /** @internal */
1856
+
1857
+ toCodecStringTree(): AST
1858
+ /** @internal */
1859
+
1860
+ getExpected(): string
1861
+ }
1862
+
1863
+ /**
1864
+ * Constructs a {@link Number}.
1865
+ *
1866
+ * @category constructors
1867
+ * @since 4.0.0
1868
+ */
1869
+ export const Number: new(
1870
+ annotations?: Schema.Annotations.Annotations | undefined,
1871
+ checks?: Checks | undefined,
1872
+ encoding?: Encoding | undefined,
1873
+ context?: Context | undefined
1874
+ ) => Number = class extends ASTNodeImpl {
1408
1875
  readonly _tag = "Number"
1409
1876
  /** @internal */
1410
1877
  getParser() {
@@ -1479,7 +1946,28 @@ export const number = new Number()
1479
1946
  * @category models
1480
1947
  * @since 4.0.0
1481
1948
  */
1482
- export class Boolean extends Base {
1949
+ export interface Boolean extends ASTNode {
1950
+ readonly _tag: "Boolean"
1951
+ /** @internal */
1952
+
1953
+ getParser(): SchemaParser.Parser
1954
+ /** @internal */
1955
+
1956
+ getExpected(): string
1957
+ }
1958
+
1959
+ /**
1960
+ * Constructs a {@link Boolean}.
1961
+ *
1962
+ * @category constructors
1963
+ * @since 4.0.0
1964
+ */
1965
+ export const Boolean: new(
1966
+ annotations?: Schema.Annotations.Annotations | undefined,
1967
+ checks?: Checks | undefined,
1968
+ encoding?: Encoding | undefined,
1969
+ context?: Context | undefined
1970
+ ) => Boolean = class extends ASTNodeImpl {
1483
1971
  readonly _tag = "Boolean"
1484
1972
  /** @internal */
1485
1973
  getParser() {
@@ -1520,12 +2008,39 @@ export const boolean = new Boolean()
1520
2008
  * When serialized to a string-based codec, symbols are converted via
1521
2009
  * `Symbol.keyFor` and must be registered with `Symbol.for`.
1522
2010
  *
1523
- * @see {@link symbol}
1524
- * @see {@link isSymbol}
1525
- * @category models
2011
+ * @see {@link symbol}
2012
+ * @see {@link isSymbol}
2013
+ * @category models
2014
+ * @since 4.0.0
2015
+ */
2016
+ export interface Symbol extends ASTNode {
2017
+ readonly _tag: "Symbol"
2018
+ /** @internal */
2019
+
2020
+ getParser(): SchemaParser.Parser
2021
+ /** @internal */
2022
+
2023
+ matchKey(s: symbol, options: ParseOptions): symbol | undefined
2024
+ /** @internal */
2025
+
2026
+ toCodecStringTree(): AST
2027
+ /** @internal */
2028
+
2029
+ getExpected(): string
2030
+ }
2031
+
2032
+ /**
2033
+ * Constructs a {@link Symbol}.
2034
+ *
2035
+ * @category constructors
1526
2036
  * @since 4.0.0
1527
2037
  */
1528
- export class Symbol extends Base {
2038
+ export const Symbol: new(
2039
+ annotations?: Schema.Annotations.Annotations | undefined,
2040
+ checks?: Checks | undefined,
2041
+ encoding?: Encoding | undefined,
2042
+ context?: Context | undefined
2043
+ ) => Symbol = class extends ASTNodeImpl {
1529
2044
  readonly _tag = "Symbol"
1530
2045
  /** @internal */
1531
2046
  getParser() {
@@ -1579,7 +2094,34 @@ export const symbol = new Symbol()
1579
2094
  * @category models
1580
2095
  * @since 4.0.0
1581
2096
  */
1582
- export class BigInt extends Base {
2097
+ export interface BigInt extends ASTNode {
2098
+ readonly _tag: "BigInt"
2099
+ /** @internal */
2100
+
2101
+ getParser(): SchemaParser.Parser
2102
+ /** @internal */
2103
+
2104
+ matchPart(s: string, options: ParseOptions): bigint | undefined
2105
+ /** @internal */
2106
+
2107
+ toCodecStringTree(): AST
2108
+ /** @internal */
2109
+
2110
+ getExpected(): string
2111
+ }
2112
+
2113
+ /**
2114
+ * Constructs a {@link BigInt}.
2115
+ *
2116
+ * @category constructors
2117
+ * @since 4.0.0
2118
+ */
2119
+ export const BigInt: new(
2120
+ annotations?: Schema.Annotations.Annotations | undefined,
2121
+ checks?: Checks | undefined,
2122
+ encoding?: Encoding | undefined,
2123
+ context?: Context | undefined
2124
+ ) => BigInt = class extends ASTNodeImpl {
1583
2125
  readonly _tag = "BigInt"
1584
2126
  /** @internal */
1585
2127
  getParser() {
@@ -1629,7 +2171,7 @@ export const bigInt = new BigInt()
1629
2171
  * **Details**
1630
2172
  *
1631
2173
  * - `elements` — positional element types (tuple elements). An element is
1632
- * optional if its {@link Context.isOptional} is `true`.
2174
+ * optional if its context's `isOptional` field is `true`.
1633
2175
  * - `rest` — the rest/variadic element types. When non-empty, the first
1634
2176
  * entry is the "spread" type (e.g. `...Array<string>`), and subsequent
1635
2177
  * entries are trailing positional elements after the spread.
@@ -1660,7 +2202,42 @@ export const bigInt = new BigInt()
1660
2202
  * @category models
1661
2203
  * @since 4.0.0
1662
2204
  */
1663
- export class Arrays extends Base {
2205
+ export interface Arrays extends ASTNode {
2206
+ readonly _tag: "Arrays"
2207
+ readonly isMutable: boolean
2208
+ readonly elements: ReadonlyArray<AST>
2209
+ readonly rest: ReadonlyArray<AST>
2210
+ readonly encodingChecks: Checks | undefined
2211
+ /** @internal */
2212
+
2213
+ getParser(compile: SchemaParser.Compiler, compileConstructorDefault?: SchemaParser.Compiler): SchemaParser.Parser
2214
+ /** @internal */
2215
+
2216
+ recur(recur: (ast: AST) => AST): Arrays
2217
+ /** @internal */
2218
+
2219
+ flip(recur: (ast: AST) => AST): Arrays
2220
+ /** @internal */
2221
+
2222
+ getExpected(): string
2223
+ }
2224
+
2225
+ /**
2226
+ * Constructs a {@link Arrays}.
2227
+ *
2228
+ * @category constructors
2229
+ * @since 4.0.0
2230
+ */
2231
+ export const Arrays: new(
2232
+ isMutable: boolean,
2233
+ elements: ReadonlyArray<AST>,
2234
+ rest: ReadonlyArray<AST>,
2235
+ annotations?: Schema.Annotations.Annotations,
2236
+ checks?: Checks,
2237
+ encoding?: Encoding,
2238
+ context?: Context,
2239
+ encodingChecks?: Checks
2240
+ ) => Arrays = class extends ASTNodeImpl {
1664
2241
  readonly _tag = "Arrays"
1665
2242
  readonly isMutable: boolean
1666
2243
  readonly elements: ReadonlyArray<AST>
@@ -1752,11 +2329,11 @@ export class Arrays extends Base {
1752
2329
  issues: undefined as Arr.NonEmptyArray<SchemaIssue.Issue> | undefined,
1753
2330
  options
1754
2331
  }
1755
- const concurrency = resolveConcurrency(options?.concurrency)
1756
- const eff = parseArray(state, input, {
1757
- concurrency: concurrency?.concurrency,
1758
- end: ast.rest.length === 0 ? elementLen : Math.max(len, elementLen + tailLen)
1759
- })
2332
+ const end = ast.rest.length === 0 ? elementLen : Math.max(len, elementLen + tailLen)
2333
+ const concurrency = options.concurrency === undefined ? 1 : resolveConcurrency(options.concurrency)
2334
+ const eff = concurrency === 1
2335
+ ? parseArray(state, input, 0, end)
2336
+ : parseArrayConcurrent(state, input, { concurrency, end })
1760
2337
  if (eff) yield* eff
1761
2338
 
1762
2339
  // ---------------------------------------------
@@ -1814,7 +2391,7 @@ export class Arrays extends Base {
1814
2391
  return "array"
1815
2392
  }
1816
2393
  }
1817
- const parseArray = iterateEager<{
2394
+ type ArrayParserState = {
1818
2395
  readonly ast: AST
1819
2396
  readonly input: unknown
1820
2397
  readonly len: number
@@ -1826,12 +2403,14 @@ const parseArray = iterateEager<{
1826
2403
  readonly options: ParseOptions
1827
2404
  readonly output: Array<unknown>
1828
2405
  issues: Array<SchemaIssue.Issue> | undefined
1829
- }, unknown>()({
1830
- onItem(s, item, i) {
2406
+ }
2407
+
2408
+ const parseArrayOptions = {
2409
+ onItem(s: ArrayParserState, item: unknown, i: number) {
1831
2410
  const value = i < s.len ? item : InternalParser.missing
1832
2411
  return s.getParser(s.tailThreshold, i).parser(value, s.options)
1833
2412
  },
1834
- step(s, item, exit, i) {
2413
+ step(s: ArrayParserState, item: unknown, exit: Exit.Exit<unknown, SchemaIssue.Issue>, i: number) {
1835
2414
  if (exit._tag === "Failure") {
1836
2415
  return wrapPropertyKeyIssue(s, s.ast, i, exit)
1837
2416
  }
@@ -1854,13 +2433,11 @@ const parseArray = iterateEager<{
1854
2433
  }
1855
2434
  }
1856
2435
  }
1857
- })
1858
-
1859
- const resolveConcurrency = (value: number | "unbounded" | undefined) => {
1860
- value = value === "unbounded" ? Infinity : value ?? 1
1861
- return value > 1 ? { concurrency: value } : undefined
1862
2436
  }
1863
2437
 
2438
+ const parseArray = iterateEager<ArrayParserState, unknown>()(parseArrayOptions)
2439
+ const parseArrayConcurrent = iterateConcurrent<ArrayParserState, unknown>()(parseArrayOptions)
2440
+
1864
2441
  const wrapPropertyKeyIssue = (
1865
2442
  s: {
1866
2443
  readonly input: unknown
@@ -1949,9 +2526,20 @@ export function getIndexSignatureKeys(
1949
2526
  *
1950
2527
  * @see {@link Objects}
1951
2528
  * @category models
1952
- * @since 3.10.0
2529
+ * @since 4.0.0
2530
+ */
2531
+ export interface PropertySignature {
2532
+ readonly name: PropertyKey
2533
+ readonly type: AST
2534
+ }
2535
+
2536
+ /**
2537
+ * Constructs a {@link PropertySignature}.
2538
+ *
2539
+ * @category constructors
2540
+ * @since 4.0.0
1953
2541
  */
1954
- export class PropertySignature {
2542
+ export const PropertySignature: new(name: PropertyKey, type: AST) => PropertySignature = class {
1955
2543
  readonly name: PropertyKey
1956
2544
  readonly type: AST
1957
2545
 
@@ -2011,9 +2599,20 @@ function isIndexSignatureParameter(ast: AST): ast is IndexSignatureParameter {
2011
2599
  * @see {@link Objects}
2012
2600
  * @see {@link PropertySignature}
2013
2601
  * @category models
2014
- * @since 3.10.0
2602
+ * @since 4.0.0
2015
2603
  */
2016
- export class IndexSignature {
2604
+ export interface IndexSignature {
2605
+ readonly parameter: IndexSignatureParameter
2606
+ readonly type: AST
2607
+ }
2608
+
2609
+ /**
2610
+ * Constructs a {@link IndexSignature}.
2611
+ *
2612
+ * @category constructors
2613
+ * @since 4.0.0
2614
+ */
2615
+ export const IndexSignature: new(parameter: AST, type: AST) => IndexSignature = class {
2017
2616
  readonly parameter: IndexSignatureParameter
2018
2617
  readonly type: AST
2019
2618
 
@@ -2074,7 +2673,40 @@ export class IndexSignature {
2074
2673
  * @category models
2075
2674
  * @since 4.0.0
2076
2675
  */
2077
- export class Objects extends Base {
2676
+ export interface Objects extends ASTNode {
2677
+ readonly _tag: "Objects"
2678
+ readonly propertySignatures: ReadonlyArray<PropertySignature>
2679
+ readonly indexSignatures: ReadonlyArray<IndexSignature>
2680
+ readonly encodingChecks: Checks | undefined
2681
+ /** @internal */
2682
+
2683
+ getParser(compile: SchemaParser.Compiler, compileConstructorDefault?: SchemaParser.Compiler): SchemaParser.Parser
2684
+ /** @internal */
2685
+
2686
+ flip(recur: (ast: AST) => AST): AST
2687
+ /** @internal */
2688
+
2689
+ recur(recur: (ast: AST) => AST, recurParameter?: (ast: AST) => AST): AST
2690
+ /** @internal */
2691
+
2692
+ getExpected(): string
2693
+ }
2694
+
2695
+ /**
2696
+ * Constructs a {@link Objects}.
2697
+ *
2698
+ * @category constructors
2699
+ * @since 4.0.0
2700
+ */
2701
+ export const Objects: new(
2702
+ propertySignatures: ReadonlyArray<PropertySignature>,
2703
+ indexSignatures: ReadonlyArray<IndexSignature>,
2704
+ annotations?: Schema.Annotations.Annotations,
2705
+ checks?: Checks,
2706
+ encoding?: Encoding,
2707
+ context?: Context,
2708
+ encodingChecks?: Checks
2709
+ ) => Objects = class extends ASTNodeImpl {
2078
2710
  readonly _tag = "Objects"
2079
2711
  readonly propertySignatures: ReadonlyArray<PropertySignature>
2080
2712
  readonly indexSignatures: ReadonlyArray<IndexSignature>
@@ -2109,7 +2741,7 @@ export class Objects extends Base {
2109
2741
  const ast = this
2110
2742
  const expectedKeys: Array<PropertyKey> = []
2111
2743
  for (const ps of ast.propertySignatures) {
2112
- expectedKeys.push(ps.name)
2744
+ expectedKeys.push(typeof ps.name === "number" ? globalThis.String(ps.name) : ps.name)
2113
2745
  }
2114
2746
  const hasProperties = expectedKeys.length
2115
2747
  const indexCount = ast.indexSignatures.length
@@ -2144,7 +2776,10 @@ export class Objects extends Base {
2144
2776
  ? inputValue
2145
2777
  : (exitValue as InternalParser.Success<unknown, SchemaIssue.Issue>)[InternalParser.args]
2146
2778
  if (k2 !== InternalParser.missing && value !== InternalParser.missing) {
2147
- if (hasProperties && (expectedKeysSet!.has(key) || expectedKeysSet!.has(k2))) return Exit.void
2779
+ if (
2780
+ hasProperties &&
2781
+ (expectedKeysSet!.has(key) || expectedKeysSet!.has(typeof k2 === "number" ? globalThis.String(k2) : k2))
2782
+ ) return Exit.void
2148
2783
  InternalRecord.assignProperty(s.out, k2, value)
2149
2784
  }
2150
2785
  return Exit.void
@@ -2185,22 +2820,14 @@ export class Objects extends Base {
2185
2820
  ? finishIndex(s, key, key, inputValue, result)
2186
2821
  : Effect.flatMap(Effect.exit(result), (exit) => finishIndex(s, key, key, inputValue, exit))
2187
2822
  }
2188
- const parseIndexes = indexCount ?
2189
- iterateEager<ObjectParserState, [key: PropertyKey, index: Index]>()({
2190
- onItem: (s, [key, index]) => parseIndex(s, key, index),
2191
- step: (_s, _, exit: Exit.Exit<void, SchemaIssue.Issue>) => exit._tag === "Failure" ? exit : undefined
2192
- }) :
2193
- undefined
2194
-
2195
- return Effect.fnUntracedEager(function*(input, options) {
2196
- if (input === InternalParser.missing) {
2197
- return InternalParser.missing
2198
- }
2199
-
2200
- // If the input is not a record, return early with an error
2201
- if (!(typeof input === "object" && input !== null && !Array.isArray(input))) {
2202
- return yield* Effect.fail(new SchemaIssue.InvalidType(ast, input, options))
2203
- }
2823
+ const parseIndexes = indexCount
2824
+ ? iterateConcurrent<ObjectParserState, readonly [key: PropertyKey, index: Index]>()({
2825
+ onItem: (s, [key, index]) =>
2826
+ index.is.parameter === string ? parseStringIndex(s, key, index) : parseIndex(s, key, index),
2827
+ step: (_s, _item, exit) => exit._tag === "Failure" ? exit : undefined
2828
+ })
2829
+ : undefined
2830
+ const compileMembers = (): Array<ParsedProperty> => {
2204
2831
  if (!properties) {
2205
2832
  properties = ast.propertySignatures.map((ps) => ({
2206
2833
  parser: compileConstructorDefault(ps.type),
@@ -2215,6 +2842,19 @@ export class Objects extends Base {
2215
2842
  }))
2216
2843
  : undefined
2217
2844
  }
2845
+ return properties
2846
+ }
2847
+
2848
+ const fallback: SchemaParser.Parser = Effect.fnUntracedEager(function*(input, options) {
2849
+ if (input === InternalParser.missing) {
2850
+ return InternalParser.missing
2851
+ }
2852
+
2853
+ // If the input is not a record, return early with an error
2854
+ if (!(typeof input === "object" && input !== null && !Array.isArray(input))) {
2855
+ return yield* Effect.fail(new SchemaIssue.InvalidType(ast, input, options))
2856
+ }
2857
+ compileMembers()
2218
2858
 
2219
2859
  const record = input as Record<PropertyKey, unknown>
2220
2860
  const out: Record<PropertyKey, unknown> = {}
@@ -2227,62 +2867,65 @@ export class Objects extends Base {
2227
2867
  }
2228
2868
  const errorsAllOption = options.errors === "all"
2229
2869
  const onExcessPropertyError = options.onExcessProperty === "error"
2230
- const onExcessPropertyPreserve = options.onExcessProperty === "preserve"
2870
+ const concurrency = options.concurrency === undefined ? 1 : resolveConcurrency(options.concurrency)
2231
2871
 
2232
2872
  // ---------------------------------------------
2233
2873
  // handle excess properties
2234
2874
  // ---------------------------------------------
2235
- let inputKeys: Array<PropertyKey> | undefined
2236
- if (!indexCount && (onExcessPropertyError || onExcessPropertyPreserve)) {
2875
+ const indexKeys = indexCount && onExcessPropertyError
2876
+ ? ast.indexSignatures.map((index) => getIndexSignatureKeys(record, index.parameter, options))
2877
+ : undefined
2878
+ if (onExcessPropertyError) {
2237
2879
  expectedKeysSet ??= new Set(expectedKeys)
2238
- inputKeys = Reflect.ownKeys(record)
2880
+ const coveredKeys = indexKeys ? new Set(expectedKeysSet) : expectedKeysSet
2881
+ if (indexKeys) {
2882
+ for (const keys of indexKeys) {
2883
+ for (const key of keys) coveredKeys.add(key)
2884
+ }
2885
+ }
2886
+ const inputKeys = Reflect.ownKeys(record)
2239
2887
  for (let i = 0; i < inputKeys.length; i++) {
2240
2888
  const key = inputKeys[i]
2241
- if (!expectedKeysSet.has(key)) {
2889
+ if (!coveredKeys.has(key)) {
2242
2890
  // key is unexpected
2243
- if (onExcessPropertyError) {
2244
- const unexpected = new SchemaIssue.UnexpectedKey(ast, record[key], options)
2245
- const issue = new SchemaIssue.Pointer([key], unexpected)
2246
- if (errorsAllOption) {
2247
- if (state.issues) {
2248
- state.issues.push(issue)
2249
- } else {
2250
- state.issues = [issue]
2251
- }
2252
- continue
2891
+ const unexpected = new SchemaIssue.UnexpectedKey(ast, record[key], options)
2892
+ const issue = new SchemaIssue.Pointer([key], unexpected)
2893
+ if (errorsAllOption) {
2894
+ if (state.issues) {
2895
+ state.issues.push(issue)
2253
2896
  } else {
2254
- return yield* Effect.fail(
2255
- new SchemaIssue.Composite(ast, [issue], input, options)
2256
- )
2897
+ state.issues = [issue]
2257
2898
  }
2899
+ continue
2258
2900
  } else {
2259
- // preserve key
2260
- InternalRecord.assignProperty(out, key, record[key])
2901
+ return yield* Effect.fail(
2902
+ new SchemaIssue.Composite(ast, [issue], input, options)
2903
+ )
2261
2904
  }
2262
2905
  }
2263
2906
  }
2264
2907
  }
2265
2908
 
2266
- const concurrency = resolveConcurrency(options?.concurrency)
2267
-
2268
2909
  // ---------------------------------------------
2269
2910
  // handle property signatures
2270
2911
  // ---------------------------------------------
2271
2912
  if (hasProperties) {
2272
- const eff = parseProperties(state, properties!, concurrency)
2913
+ const eff = concurrency === 1
2914
+ ? parseProperties(state, properties!)
2915
+ : parsePropertiesConcurrent(state, properties!, { concurrency })
2273
2916
  if (eff) yield* eff
2274
2917
  }
2275
2918
 
2276
2919
  // ---------------------------------------------
2277
2920
  // handle index signatures
2278
2921
  // ---------------------------------------------
2279
- if (indexCount && !concurrency) {
2922
+ if (indexCount && concurrency === 1) {
2280
2923
  for (let i = 0; i < indexCount; i++) {
2281
2924
  const index = indexes![i]
2282
2925
  const parse = index.is.parameter === string ? parseStringIndex : parseIndex
2283
- const keys = index.is.parameter === string
2926
+ const keys = indexKeys?.[i] ?? (index.is.parameter === string
2284
2927
  ? Object.keys(record)
2285
- : getIndexSignatureKeys(record, index.is.parameter, options)
2928
+ : getIndexSignatureKeys(record, index.is.parameter, options))
2286
2929
  for (let j = 0; j < keys.length; j++) {
2287
2930
  const eff = parse(state, keys[j], index)
2288
2931
  if (!effectIsExit(eff)) yield* eff
@@ -2290,15 +2933,17 @@ export class Objects extends Base {
2290
2933
  }
2291
2934
  }
2292
2935
  } else if (parseIndexes) {
2293
- const keyPairs = Arr.empty<[PropertyKey, Index]>()
2936
+ const keyPairs = Arr.empty<readonly [PropertyKey, Index]>()
2294
2937
  for (let i = 0; i < indexCount; i++) {
2295
2938
  const index = indexes![i]
2296
- const keys = getIndexSignatureKeys(record, index.is.parameter, options)
2939
+ const keys = indexKeys?.[i] ?? (index.is.parameter === string
2940
+ ? Object.keys(record)
2941
+ : getIndexSignatureKeys(record, index.is.parameter, options))
2297
2942
  for (let j = 0; j < keys.length; j++) {
2298
2943
  keyPairs.push([keys[j], index])
2299
2944
  }
2300
2945
  }
2301
- const eff = parseIndexes(state, keyPairs, concurrency)
2946
+ const eff = parseIndexes(state, keyPairs, { concurrency })
2302
2947
  if (eff) yield* eff
2303
2948
  }
2304
2949
 
@@ -2307,19 +2952,69 @@ export class Objects extends Base {
2307
2952
  new SchemaIssue.Composite(ast, state.issues, input, options)
2308
2953
  )
2309
2954
  }
2310
- if (options.propertyOrder === "original") {
2311
- // preserve input keys order
2312
- const keys = (inputKeys ?? Reflect.ownKeys(record)).concat(expectedKeys)
2313
- const preserved: Record<PropertyKey, unknown> = {}
2314
- for (const key of keys) {
2315
- if (Object.hasOwn(out, key)) {
2316
- InternalRecord.assignProperty(preserved, key, out[key])
2955
+ return out
2956
+ })
2957
+
2958
+ if (indexCount) return fallback
2959
+
2960
+ // Resumes at the property whose parser suspended, without replaying the
2961
+ // properties already parsed.
2962
+ const resume = (
2963
+ state: ObjectParserState,
2964
+ index: number,
2965
+ pending: Effect.Effect<unknown, SchemaIssue.Issue, any>
2966
+ ): Effect.Effect<unknown, SchemaIssue.Issue, any> => {
2967
+ const property = properties![index]
2968
+ return Effect.flatMap(Effect.exit(pending), (exit) => {
2969
+ const terminal = stepProperty(state, property, exit)
2970
+ if (terminal) return terminal
2971
+ const done = () => InternalParser.succeed(state.out)
2972
+ const eff = parseProperties(state, properties!.slice(index + 1))
2973
+ return eff ? Effect.flatMapEager(eff, done) : done()
2974
+ })
2975
+ }
2976
+
2977
+ // Fast path: a struct without index signatures, under the default parse
2978
+ // options, needs none of the generator the fallback runs per value.
2979
+ return (input, options) => {
2980
+ if (input === InternalParser.missing) return InternalParser.missingExit
2981
+ if (
2982
+ options.errors === "all" ||
2983
+ options.onExcessProperty !== undefined ||
2984
+ (options.concurrency !== undefined && resolveConcurrency(options.concurrency) !== 1)
2985
+ ) {
2986
+ return fallback(input, options)
2987
+ }
2988
+ if (!(typeof input === "object" && input !== null && !Array.isArray(input))) {
2989
+ return Effect.fail(new SchemaIssue.InvalidType(ast, input, options))
2990
+ }
2991
+ const props = compileMembers()
2992
+ const record = input as Record<PropertyKey, unknown>
2993
+ const out: Record<PropertyKey, unknown> = {}
2994
+ const state: ObjectParserState = { ast, input: record, out, issues: undefined, options }
2995
+ try {
2996
+ for (let index = 0; index < props.length; index++) {
2997
+ const property = props[index]
2998
+ const name = property.name
2999
+ const hasKey = hasPropertySignature(record, name)
3000
+ const value = hasKey ? record[name] : InternalParser.missing
3001
+ const exit = property.parser(value, options)
3002
+ if (!effectIsExit(exit)) {
3003
+ return resume(state, index, exit)
2317
3004
  }
3005
+ if (exit === InternalParser.sameExit) {
3006
+ if (hasKey) InternalRecord.assignProperty(out, name, value)
3007
+ continue
3008
+ }
3009
+ const terminal = stepProperty(state, property, exit)
3010
+ if (terminal) return terminal
2318
3011
  }
2319
- return preserved
3012
+ } catch (error) {
3013
+ // `Effect.fnUntracedEager` turns a synchronous throw into a defect
3014
+ return Effect.die(error)
2320
3015
  }
2321
- return out
2322
- })
3016
+ return InternalParser.succeed(out)
3017
+ }
2323
3018
  }
2324
3019
  private _rebuild(
2325
3020
  recur: (ast: AST) => AST,
@@ -2382,40 +3077,49 @@ type ParsedProperty = {
2382
3077
  readonly type: AST
2383
3078
  }
2384
3079
 
2385
- const parseProperties = iterateEager<ObjectParserState, ParsedProperty>()({
2386
- onItem(s, p) {
2387
- if (!Object.hasOwn(s.input, p.name)) {
3080
+ function stepProperty(
3081
+ s: ObjectParserState,
3082
+ p: ParsedProperty,
3083
+ exit: Exit.Exit<unknown, SchemaIssue.Issue>
3084
+ ): Exit.Exit<void, SchemaIssue.Issue> | void {
3085
+ if (exit._tag === "Failure") {
3086
+ return wrapPropertyKeyIssue(s, s.ast, p.name, exit)
3087
+ }
3088
+ if (exit === InternalParser.sameExit) return
3089
+ const value = (exit as InternalParser.Success<unknown, SchemaIssue.Issue>)[InternalParser.args]
3090
+ if (value !== InternalParser.missing) {
3091
+ InternalRecord.assignProperty(s.out, p.name, value)
3092
+ return
3093
+ }
3094
+ delete s.out[p.name]
3095
+ if (!isOptional(p.type)) {
3096
+ const issue = new SchemaIssue.Pointer([p.name], new SchemaIssue.MissingKey(p.type.context?.annotations))
3097
+ if (s.options.errors === "all") {
3098
+ if (s.issues) s.issues.push(issue)
3099
+ else s.issues = [issue]
3100
+ return
3101
+ } else {
3102
+ return Exit.fail(
3103
+ new SchemaIssue.Composite(s.ast, [issue], s.input, s.options)
3104
+ )
3105
+ }
3106
+ }
3107
+ }
3108
+
3109
+ const parsePropertiesOptions = {
3110
+ onItem(s: ObjectParserState, p: ParsedProperty) {
3111
+ if (!hasPropertySignature(s.input, p.name)) {
2388
3112
  return p.parser(InternalParser.missing, s.options)
2389
3113
  }
2390
3114
  const value = s.input[p.name]
2391
3115
  InternalRecord.assignProperty(s.out, p.name, value)
2392
3116
  return p.parser(value, s.options)
2393
3117
  },
2394
- step(s, p, exit) {
2395
- if (exit._tag === "Failure") {
2396
- return wrapPropertyKeyIssue(s, s.ast, p.name, exit)
2397
- }
2398
- if (exit === InternalParser.sameExit) return
2399
- const value = (exit as InternalParser.Success<unknown, SchemaIssue.Issue>)[InternalParser.args]
2400
- if (value !== InternalParser.missing) {
2401
- InternalRecord.assignProperty(s.out, p.name, value)
2402
- return
2403
- }
2404
- delete s.out[p.name]
2405
- if (!isOptional(p.type)) {
2406
- const issue = new SchemaIssue.Pointer([p.name], new SchemaIssue.MissingKey(p.type.context?.annotations))
2407
- if (s.options.errors === "all") {
2408
- if (s.issues) s.issues.push(issue)
2409
- else s.issues = [issue]
2410
- return
2411
- } else {
2412
- return Exit.fail(
2413
- new SchemaIssue.Composite(s.ast, [issue], s.input, s.options)
2414
- )
2415
- }
2416
- }
2417
- }
2418
- })
3118
+ step: stepProperty
3119
+ }
3120
+
3121
+ const parseProperties = iterateEager<ObjectParserState, ParsedProperty>()(parsePropertiesOptions)
3122
+ const parsePropertiesConcurrent = iterateConcurrent<ObjectParserState, ParsedProperty>()(parsePropertiesOptions)
2419
3123
 
2420
3124
  function combineChecks(a: Checks | undefined, b: Checks | undefined): Checks | undefined {
2421
3125
  if (!a) return b
@@ -2455,10 +3159,10 @@ export function tuple<Elements extends Schema.Tuple.Elements>(
2455
3159
  /** @internal */
2456
3160
  export function union<Members extends ReadonlyArray<{ readonly ast: AST }>>(
2457
3161
  members: Members,
2458
- mode: "anyOf" | "oneOf",
3162
+ options: UnionOptions | undefined,
2459
3163
  checks: Checks | undefined
2460
3164
  ): Union<Members[number]["ast"]> {
2461
- return new Union(members.map(getAST), mode, undefined, checks)
3165
+ return new Union(members.map(getAST), options, undefined, checks)
2462
3166
  }
2463
3167
 
2464
3168
  /** @internal */
@@ -2485,6 +3189,23 @@ export function tupleWithRest(ast: Arrays, rest: ReadonlyArray<AST>): Arrays {
2485
3189
  return new Arrays(ast.isMutable, ast.elements, rest, undefined, ast.checks)
2486
3190
  }
2487
3191
 
3192
+ /** @internal */
3193
+ export function mutable(ast: Arrays): Arrays {
3194
+ if (ast.encoding) {
3195
+ throw new Error("mutable does not support encodings")
3196
+ }
3197
+ return new Arrays(
3198
+ true,
3199
+ ast.elements,
3200
+ ast.rest,
3201
+ ast.annotations,
3202
+ ast.checks,
3203
+ undefined,
3204
+ ast.context,
3205
+ ast.encodingChecks
3206
+ )
3207
+ }
3208
+
2488
3209
  type Type =
2489
3210
  | "null"
2490
3211
  | "array"
@@ -2622,6 +3343,9 @@ type SentinelIndex = Map<PropertyKey, SentinelEntry>
2622
3343
  const candidateIndexCache = new WeakMap<ReadonlyArray<AST>, CandidateIndex>()
2623
3344
  const emptyCandidates: ReadonlyArray<never> = Object.freeze([])
2624
3345
 
3346
+ const hasPropertySignature = (input: object, key: PropertyKey): boolean =>
3347
+ key === "__proto__" ? Object.hasOwn(input, key) : key in input
3348
+
2625
3349
  function getIndex(types: ReadonlyArray<AST>): CandidateIndex {
2626
3350
  let index = candidateIndexCache.get(types)
2627
3351
  if (index) return index
@@ -2679,7 +3403,7 @@ function getIndex(types: ReadonlyArray<AST>): CandidateIndex {
2679
3403
  }
2680
3404
  index = (input, isConstructor) => {
2681
3405
  if (Predicate.isObjectKeyword(input)) {
2682
- const value = Object.hasOwn(input, key) ? (input as any)[key] : undefined
3406
+ const value = hasPropertySignature(input, key) ? (input as any)[key] : undefined
2683
3407
  if (value !== undefined) return candidates.get(value) ?? emptyCandidates
2684
3408
  if (isConstructor) return types
2685
3409
  }
@@ -2711,7 +3435,7 @@ function getIndex(types: ReadonlyArray<AST>): CandidateIndex {
2711
3435
  // discriminated candidate.
2712
3436
  if (commonSentinel) {
2713
3437
  const [key, [byValue]] = commonSentinel
2714
- const hasKey = Object.hasOwn(input, key)
3438
+ const hasKey = hasPropertySignature(input, key)
2715
3439
  const value = hasKey ? (input as any)[key] : undefined
2716
3440
  if (hasKey && (!isConstructor || value !== undefined)) {
2717
3441
  const match = byValue.get(value)
@@ -2725,7 +3449,7 @@ function getIndex(types: ReadonlyArray<AST>): CandidateIndex {
2725
3449
  // absent and undefined keys as unconstrained and therefore selects every candidate that owns the key.
2726
3450
  if (directKey === undefined) {
2727
3451
  for (const [key, [byValue, all]] of bySentinel) {
2728
- const hasKey = Object.hasOwn(input, key)
3452
+ const hasKey = hasPropertySignature(input, key)
2729
3453
  const value = hasKey ? (input as any)[key] : undefined
2730
3454
  if (hasKey && (!isConstructor || value !== undefined)) {
2731
3455
  const match = byValue.get(value)
@@ -2740,7 +3464,7 @@ function getIndex(types: ReadonlyArray<AST>): CandidateIndex {
2740
3464
  // Missing keys are neutral. An observed key rejects only selected candidates that own it and do not match.
2741
3465
  for (const [key, [byValue, all]] of bySentinel) {
2742
3466
  if (key === directKey) continue
2743
- const hasKey = Object.hasOwn(input, key)
3467
+ const hasKey = hasPropertySignature(input, key)
2744
3468
  const value = hasKey ? (input as any)[key] : undefined
2745
3469
  if (hasKey && (!isConstructor || value !== undefined)) {
2746
3470
  const match = byValue.get(value)
@@ -2793,7 +3517,7 @@ export function getCandidates(
2793
3517
  * **Details**
2794
3518
  *
2795
3519
  * - `types` — the member AST nodes.
2796
- * - `mode` — `"anyOf"` succeeds on the first match (like TypeScript unions);
3520
+ * - `options.mode` selects matching behavior. `"anyOf"` succeeds on the first match;
2797
3521
  * `"oneOf"` requires exactly one member to match (fails if multiple do).
2798
3522
  *
2799
3523
  * During parsing, members are tried in order. An internal candidate index
@@ -2809,23 +3533,70 @@ export function getCandidates(
2809
3533
  * const ast = schema.ast
2810
3534
  *
2811
3535
  * if (SchemaAST.isUnion(ast)) {
2812
- * [ast.types.length, ast.mode] // => [2, "anyOf"]
3536
+ * [ast.types.length, ast.options?.mode ?? "anyOf"] // => [2, "anyOf"]
2813
3537
  * }
2814
3538
  * ```
2815
3539
  *
2816
3540
  * @see {@link isUnion}
2817
3541
  * @category models
2818
- * @since 3.10.0
3542
+ * @since 4.0.0
3543
+ */
3544
+ export interface Union<A extends AST = AST> extends ASTNode {
3545
+ readonly _tag: "Union"
3546
+ readonly types: ReadonlyArray<A>
3547
+ readonly options: UnionOptions | undefined
3548
+ readonly encodingChecks: Checks | undefined
3549
+ /** @internal */
3550
+
3551
+ getParser(compile: SchemaParser.Compiler, compileConstructorDefault?: SchemaParser.Compiler): SchemaParser.Parser
3552
+ /** @internal */
3553
+
3554
+ recur(recur: (ast: AST) => AST): Union<AST>
3555
+ /** @internal */
3556
+
3557
+ flip(recur: (ast: AST) => AST): Union<AST>
3558
+ /** @internal */
3559
+
3560
+ matchPart(s: string, options: ParseOptions): LiteralValue | undefined
3561
+ /** @internal */
3562
+
3563
+ getExpected(getExpected: (ast: AST) => string): string
3564
+ }
3565
+
3566
+ /**
3567
+ * Local matching options stored on {@link Union} nodes.
3568
+ *
3569
+ * @category options
3570
+ * @since 4.0.0
3571
+ */
3572
+ export interface UnionOptions {
3573
+ /** Defaults to `"anyOf"`; `"oneOf"` requires exactly one matching member. */
3574
+ readonly mode?: "anyOf" | "oneOf" | undefined
3575
+ }
3576
+
3577
+ /**
3578
+ * Constructs a {@link Union}.
3579
+ *
3580
+ * @category constructors
3581
+ * @since 4.0.0
2819
3582
  */
2820
- export class Union<A extends AST = AST> extends Base {
3583
+ export const Union: new<A extends AST = AST>(
3584
+ types: ReadonlyArray<A>,
3585
+ options?: UnionOptions,
3586
+ annotations?: Schema.Annotations.Annotations,
3587
+ checks?: Checks,
3588
+ encoding?: Encoding,
3589
+ context?: Context,
3590
+ encodingChecks?: Checks
3591
+ ) => Union<A> = class<A extends AST = AST> extends ASTNodeImpl {
2821
3592
  readonly _tag = "Union"
2822
3593
  readonly types: ReadonlyArray<A>
2823
- readonly mode: "anyOf" | "oneOf"
3594
+ readonly options: UnionOptions | undefined
2824
3595
  readonly encodingChecks: Checks | undefined
2825
3596
 
2826
3597
  constructor(
2827
3598
  types: ReadonlyArray<A>,
2828
- mode: "anyOf" | "oneOf",
3599
+ options?: UnionOptions,
2829
3600
  annotations?: Schema.Annotations.Annotations,
2830
3601
  checks?: Checks,
2831
3602
  encoding?: Encoding,
@@ -2834,7 +3605,7 @@ export class Union<A extends AST = AST> extends Base {
2834
3605
  ) {
2835
3606
  super(annotations, checks, encoding, context)
2836
3607
  this.types = types
2837
- this.mode = mode
3608
+ this.options = options
2838
3609
  this.encodingChecks = encodingChecks
2839
3610
  }
2840
3611
  /** @internal */
@@ -2851,6 +3622,9 @@ export class Union<A extends AST = AST> extends Base {
2851
3622
  }
2852
3623
  const candidates = getCandidates(input, ast.types, compileConstructorDefault !== undefined)
2853
3624
 
3625
+ if (candidates.length === 0) {
3626
+ return Effect.fail(new SchemaIssue.AnyOf(ast, [], input, options))
3627
+ }
2854
3628
  if (candidates.length === 1) {
2855
3629
  const result = compile(candidates[0])(input, options)
2856
3630
  if ((result as Exit.Exit<unknown, SchemaIssue.Issue>)._tag === "Success") return result
@@ -2864,12 +3638,11 @@ export class Union<A extends AST = AST> extends Base {
2864
3638
  compile,
2865
3639
  input,
2866
3640
  out: undefined,
2867
- successes: ast.mode === "oneOf" ? [] : undefined,
3641
+ successes: ast.options?.mode === "oneOf" ? [] : undefined,
2868
3642
  issues: undefined as Arr.NonEmptyArray<SchemaIssue.Issue> | undefined,
2869
3643
  options
2870
3644
  }
2871
- const concurrency = resolveConcurrency(options?.concurrency)
2872
- const eff = parseUnion(state, candidates, concurrency ? { ...concurrency, orderedStep: true } : undefined)
3645
+ const eff = parseUnion(state, candidates)
2873
3646
  if (!eff) {
2874
3647
  if (state.out) return state.out
2875
3648
  return Effect.fail(new SchemaIssue.AnyOf(ast, state.issues ?? [], input, options))
@@ -2881,18 +3654,22 @@ export class Union<A extends AST = AST> extends Base {
2881
3654
  })
2882
3655
  }
2883
3656
  }
2884
- private _rebuild(recur: (ast: AST) => AST, checks: Checks | undefined, encodingChecks: Checks | undefined) {
3657
+ private _rebuild(
3658
+ recur: (ast: AST) => AST,
3659
+ checks: Checks | undefined,
3660
+ encodingChecks: Checks | undefined
3661
+ ): Union<AST> {
2885
3662
  const types = mapOrSame(this.types, recur)
2886
3663
  return types === this.types && checks === this.checks && encodingChecks === this.encodingChecks ?
2887
3664
  this :
2888
- new Union(types, this.mode, this.annotations, checks, undefined, this.context, encodingChecks)
3665
+ new Union(types, this.options, this.annotations, checks, undefined, this.context, encodingChecks)
2889
3666
  }
2890
3667
  /** @internal */
2891
- recur(recur: (ast: AST) => AST) {
3668
+ recur(recur: (ast: AST) => AST): Union<AST> {
2892
3669
  return this._rebuild(recur, this.checks, this.encodingChecks)
2893
3670
  }
2894
3671
  /** @internal */
2895
- flip(recur: (ast: AST) => AST) {
3672
+ flip(recur: (ast: AST) => AST): Union<AST> {
2896
3673
  return this._rebuild(recur, this.encodingChecks, this.checks)
2897
3674
  }
2898
3675
  /** @internal */
@@ -2993,7 +3770,7 @@ const nonFiniteLiterals = new Union([
2993
3770
  new Literal("Infinity"),
2994
3771
  new Literal("-Infinity"),
2995
3772
  new Literal("NaN")
2996
- ], "anyOf")
3773
+ ])
2997
3774
 
2998
3775
  function formatIsMutable(isMutable: boolean | undefined): string {
2999
3776
  return isMutable ? "" : "readonly "
@@ -3046,9 +3823,35 @@ export function memoizeThunk<A>(f: () => A): () => A {
3046
3823
  *
3047
3824
  * @see {@link isSuspend}
3048
3825
  * @category models
3049
- * @since 3.10.0
3826
+ * @since 4.0.0
3827
+ */
3828
+ export interface Suspend extends ASTNode {
3829
+ readonly _tag: "Suspend"
3830
+ readonly thunk: () => AST
3831
+ /** @internal */
3832
+
3833
+ getParser(compile: SchemaParser.Compiler): SchemaParser.Parser
3834
+ /** @internal */
3835
+
3836
+ recur(recur: (ast: AST) => AST): Suspend
3837
+ /** @internal */
3838
+
3839
+ getExpected(getExpected: (ast: AST) => string): string
3840
+ }
3841
+
3842
+ /**
3843
+ * Constructs a {@link Suspend}.
3844
+ *
3845
+ * @category constructors
3846
+ * @since 4.0.0
3050
3847
  */
3051
- export class Suspend extends Base {
3848
+ export const Suspend: new(
3849
+ thunk: () => AST,
3850
+ annotations?: Schema.Annotations.Annotations,
3851
+ checks?: Checks,
3852
+ encoding?: Encoding,
3853
+ context?: Context
3854
+ ) => Suspend = class extends ASTNodeImpl {
3052
3855
  readonly _tag = "Suspend"
3053
3856
  readonly thunk: () => AST
3054
3857
 
@@ -3111,7 +3914,32 @@ export class Suspend extends Base {
3111
3914
  * @category models
3112
3915
  * @since 4.0.0
3113
3916
  */
3114
- export class Filter<in E> extends Pipeable.Class {
3917
+ export interface Filter<in E> extends Pipeable.Pipeable {
3918
+ readonly _tag: "Filter"
3919
+ readonly run: (input: E, self: AST, options: ParseOptions) => SchemaIssue.Issue | undefined
3920
+ readonly annotations: Schema.Annotations.Filter | undefined
3921
+ /**
3922
+ * Whether the parsing process should be aborted after this check has failed.
3923
+ */
3924
+ readonly aborted: boolean
3925
+ annotate(annotations: Schema.Annotations.Filter): Filter<E>
3926
+ abort(): Filter<E>
3927
+ and(other: Check<E>, annotations?: Schema.Annotations.Filter): FilterGroup<E>
3928
+ }
3929
+
3930
+ /**
3931
+ * Constructs a {@link Filter}.
3932
+ *
3933
+ * @category constructors
3934
+ * @since 4.0.0
3935
+ */
3936
+ export const Filter: new<E>(
3937
+ run: (input: E, self: AST, options: ParseOptions) => SchemaIssue.Issue | undefined,
3938
+ annotations?: Schema.Annotations.Filter | undefined, /**
3939
+ * Whether the parsing process should be aborted after this check has failed.
3940
+ */
3941
+ aborted?: boolean
3942
+ ) => Filter<E> = class<in E> extends Pipeable.Class {
3115
3943
  readonly _tag = "Filter"
3116
3944
  readonly run: (input: E, self: AST, options: ParseOptions) => SchemaIssue.Issue | undefined
3117
3945
  readonly annotations: Schema.Annotations.Filter | undefined
@@ -3159,7 +3987,30 @@ export class Filter<in E> extends Pipeable.Class {
3159
3987
  * @category models
3160
3988
  * @since 4.0.0
3161
3989
  */
3162
- export class FilterGroup<in E> extends Pipeable.Class {
3990
+ export interface FilterGroup<in E> extends Pipeable.Pipeable {
3991
+ readonly _tag: "FilterGroup"
3992
+ readonly checks: readonly [
3993
+ Check<E>,
3994
+ ...Array<Check<E>>
3995
+ ]
3996
+ readonly annotations: Schema.Annotations.Filter | undefined
3997
+ annotate(annotations: Schema.Annotations.Filter): FilterGroup<E>
3998
+ and(other: Check<E>, annotations?: Schema.Annotations.Filter): FilterGroup<E>
3999
+ }
4000
+
4001
+ /**
4002
+ * Constructs a {@link FilterGroup}.
4003
+ *
4004
+ * @category constructors
4005
+ * @since 4.0.0
4006
+ */
4007
+ export const FilterGroup: new<E>(
4008
+ checks: readonly [
4009
+ Check<E>,
4010
+ ...Array<Check<E>>
4011
+ ],
4012
+ annotations?: Schema.Annotations.Filter | undefined
4013
+ ) => FilterGroup<E> = class<in E> extends Pipeable.Class {
3163
4014
  readonly _tag = "FilterGroup"
3164
4015
  readonly checks: readonly [Check<E>, ...Array<Check<E>>]
3165
4016
  readonly annotations: Schema.Annotations.Filter | undefined
@@ -3187,7 +4038,7 @@ export class FilterGroup<in E> extends Pipeable.Class {
3187
4038
  *
3188
4039
  * **Details**
3189
4040
  *
3190
- * Stored in the {@link Checks} array on {@link Base.checks}.
4041
+ * Stored in an AST node's {@link Checks} array.
3191
4042
  *
3192
4043
  * @see {@link Filter}
3193
4044
  * @see {@link FilterGroup}
@@ -3233,11 +4084,8 @@ export function isFinite(annotations?: Schema.Annotations.Filter) {
3233
4084
  },
3234
4085
  toJsonSchema: () => ({ type: "number" }),
3235
4086
  toCode: () => ({ runtime: "Schema.isFinite()" }),
3236
- arbitrary: {
3237
- constraint: {
3238
- noInfinity: true,
3239
- noNaN: true
3240
- }
4087
+ arbitraryConstraint: {
4088
+ number: "finite"
3241
4089
  },
3242
4090
  ...annotations
3243
4091
  }
@@ -3248,7 +4096,7 @@ export function isFinite(annotations?: Schema.Annotations.Filter) {
3248
4096
  export const finite = appendChecks(number, [isFinite()])
3249
4097
 
3250
4098
  const numberToJson = new Link(
3251
- new Union([finite, nonFiniteLiterals], "anyOf"),
4099
+ new Union([finite, nonFiniteLiterals]),
3252
4100
  new SchemaTransformation.Transformation(
3253
4101
  SchemaGetter.Number(),
3254
4102
  SchemaGetter.transform((n) => globalThis.Number.isFinite(n) ? n : globalThis.String(n))
@@ -3274,8 +4122,12 @@ const numberToJson = new Link(
3274
4122
  *
3275
4123
  * **Gotchas**
3276
4124
  *
3277
- * When deriving an arbitrary, only `regExp.source` is used. Regular expression
3278
- * flags are ignored because fast-check does not support them.
4125
+ * Arbitrary metadata preserves both `regExp.source` and `regExp.flags`.
4126
+ * Implementations that cannot consume all flags may still use the source as a
4127
+ * generation hint because the Schema filter validates every generated value.
4128
+ * JSON Schema has no way to carry JavaScript regular-expression flags. The
4129
+ * generated `pattern` contains the source only, so validation can differ when
4130
+ * the RegExp uses flags or relies on JavaScript's non-Unicode behavior.
3279
4131
  *
3280
4132
  * **Example** (Validating an email pattern)
3281
4133
  *
@@ -3306,10 +4158,8 @@ export function isPattern(regExp: globalThis.RegExp, annotations?: Schema.Annota
3306
4158
  payload: { source, flags: regExp.flags }
3307
4159
  },
3308
4160
  toJsonSchema: () => ({ pattern: source }),
3309
- arbitrary: {
3310
- constraint: {
3311
- patterns: [regExp.source]
3312
- }
4161
+ arbitraryConstraint: {
4162
+ patterns: [{ source: regExp.source, flags: regExp.flags }]
3313
4163
  },
3314
4164
  ...annotations
3315
4165
  }
@@ -3521,7 +4371,7 @@ const optionalKeyLastLink = applyToLastLink(optionalKey)
3521
4371
 
3522
4372
  /** @internal */
3523
4373
  export const optional = memoize(<A extends AST>(ast: A): Union<A | Undefined> =>
3524
- optionalKey(new Union([ast, undefined_], "anyOf"))
4374
+ optionalKey(new Union([ast, undefined_]))
3525
4375
  )
3526
4376
 
3527
4377
  /** @internal */
@@ -3558,9 +4408,8 @@ export function withConstructorDefault<A extends AST>(
3558
4408
  *
3559
4409
  * **Details**
3560
4410
  *
3561
- * This is the low-level primitive behind `Schema.transform` and
3562
- * `Schema.transformOrFail`. It appends a {@link Link} to the `to` node's
3563
- * encoding chain.
4411
+ * This is the low-level primitive behind `Schema.decodeTo`. It appends a
4412
+ * {@link Link} to the `to` node's encoding chain.
3564
4413
  *
3565
4414
  * - Returns a new AST with the same type as `to`.
3566
4415
  *
@@ -3630,7 +4479,7 @@ export function record(key: AST, value: AST): Objects {
3630
4479
  * Checks `ast.context?.isOptional`. Defaults to `false` when no
3631
4480
  * {@link Context} is set.
3632
4481
  *
3633
- * @see {@link optionalKey}
4482
+ * @see `Schema.optionalKey`
3634
4483
  * @see {@link Context}
3635
4484
  * @category predicates
3636
4485
  * @since 4.0.0
@@ -3793,7 +4642,7 @@ function fromConst<const T>(
3793
4642
  ast: AST,
3794
4643
  value: T
3795
4644
  ): SchemaParser.Parser {
3796
- const succeed = InternalParser.succeed(value)
4645
+ const succeed = value === 0 ? InternalParser.sameExit : InternalParser.succeed(value)
3797
4646
  return (input, options) => {
3798
4647
  if (input === InternalParser.missing) return InternalParser.missingExit
3799
4648
  if (input === value) return succeed
@@ -3866,14 +4715,6 @@ function segmentTemplateLiteralParts(
3866
4715
  return go(0, 0) ? out : undefined
3867
4716
  }
3868
4717
 
3869
- /** @internal */
3870
- export const enumsToLiterals = memoize((ast: Enum): Union<Literal> => {
3871
- return new Union(
3872
- ast.enums.map((e) => new Literal(e[1], { title: e[0] })),
3873
- "anyOf"
3874
- )
3875
- })
3876
-
3877
4718
  const parameterFromPropertyKey = applyToSelfOrLastLinkEncodingIdempotent((ast) => {
3878
4719
  switch (ast._tag) {
3879
4720
  default:
@@ -3945,7 +4786,7 @@ const finiteToString = new Link(
3945
4786
  )
3946
4787
 
3947
4788
  const numberToString = new Link(
3948
- new Union([finiteString, nonFiniteLiterals], "anyOf"),
4789
+ new Union([finiteString, nonFiniteLiterals]),
3949
4790
  SchemaTransformation.numberFromString
3950
4791
  )
3951
4792
 
@@ -3982,7 +4823,7 @@ const bigIntToString = new Link(
3982
4823
  SchemaTransformation.bigintFromString
3983
4824
  )
3984
4825
 
3985
- const REGEXP_PATTERN = "Symbol\\((.*)\\)"
4826
+ const REGEXP_PATTERN = "Symbol\\(([\\s\\S]*)\\)"
3986
4827
 
3987
4828
  const isStringSymbolRegExp = new globalThis.RegExp(`^${REGEXP_PATTERN}$`)
3988
4829
 
@@ -3996,7 +4837,7 @@ const symbolToString = new Link(
3996
4837
  symbolString,
3997
4838
  new SchemaTransformation.Transformation(
3998
4839
  SchemaGetter.transform((description) => globalThis.Symbol.for(isStringSymbolRegExp.exec(description)![1])),
3999
- SchemaGetter.transformOrFail((sym: symbol, options) => {
4840
+ SchemaGetter.transformEffect((sym: symbol, options) => {
4000
4841
  const key = globalThis.Symbol.keyFor(sym)
4001
4842
  if (key !== undefined) {
4002
4843
  return Effect.succeed(globalThis.String(sym))
@@ -4094,7 +4935,7 @@ export function getConstructorDescriptor(ast: AST): ConstructorDescriptor | unde
4094
4935
  *
4095
4936
  * If the node has {@link Checks}, returns annotations from the last check
4096
4937
  * (which is where user-supplied annotations end up after `.pipe(Schema.annotations(...))`).
4097
- * Otherwise returns `Base.annotations` directly.
4938
+ * Otherwise returns the node's `annotations` directly.
4098
4939
  *
4099
4940
  * **Example** (Reading annotations)
4100
4941
  *
@@ -4269,8 +5110,7 @@ export const Json = new Declaration(
4269
5110
  },
4270
5111
  expected: "JSON value",
4271
5112
  toCodecJson: () => undefined,
4272
- toCodecStringTree: () => unknownToStringTree,
4273
- toArbitrary: () => (fc: typeof FastCheck) => fc.jsonValue()
5113
+ toCodecStringTree: () => unknownToStringTree
4274
5114
  }
4275
5115
  )
4276
5116
 
@@ -4293,7 +5133,7 @@ export const objectKeywordToJson = new Link(
4293
5133
  new Union([
4294
5134
  new Arrays(false, [], [Json]),
4295
5135
  new Objects([], [new IndexSignature(string, Json)])
4296
- ], "anyOf"),
5136
+ ]),
4297
5137
  SchemaTransformation.passthrough()
4298
5138
  )
4299
5139