effect 4.0.0-beta.100 → 4.0.0-beta.102

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 (502) hide show
  1. package/dist/Array.d.ts.map +1 -1
  2. package/dist/Array.js +81 -5
  3. package/dist/Array.js.map +1 -1
  4. package/dist/Channel.d.ts.map +1 -1
  5. package/dist/Channel.js +27 -9
  6. package/dist/Channel.js.map +1 -1
  7. package/dist/Config.d.ts +1 -1
  8. package/dist/Config.d.ts.map +1 -1
  9. package/dist/Config.js +6 -5
  10. package/dist/Config.js.map +1 -1
  11. package/dist/ConfigProvider.js +7 -7
  12. package/dist/ConfigProvider.js.map +1 -1
  13. package/dist/Data.d.ts.map +1 -1
  14. package/dist/Data.js +2 -1
  15. package/dist/Data.js.map +1 -1
  16. package/dist/Effect.d.ts +61 -100
  17. package/dist/Effect.d.ts.map +1 -1
  18. package/dist/Effect.js +66 -39
  19. package/dist/Effect.js.map +1 -1
  20. package/dist/FiberHandle.d.ts.map +1 -1
  21. package/dist/FiberHandle.js +3 -2
  22. package/dist/FiberHandle.js.map +1 -1
  23. package/dist/Iterable.d.ts.map +1 -1
  24. package/dist/Iterable.js +2 -1
  25. package/dist/Iterable.js.map +1 -1
  26. package/dist/JsonPatch.d.ts.map +1 -1
  27. package/dist/JsonPatch.js +4 -3
  28. package/dist/JsonPatch.js.map +1 -1
  29. package/dist/JsonSchema.d.ts.map +1 -1
  30. package/dist/JsonSchema.js +9 -11
  31. package/dist/JsonSchema.js.map +1 -1
  32. package/dist/Logger.d.ts.map +1 -1
  33. package/dist/Logger.js +3 -2
  34. package/dist/Logger.js.map +1 -1
  35. package/dist/ManagedRuntime.d.ts +9 -0
  36. package/dist/ManagedRuntime.d.ts.map +1 -1
  37. package/dist/ManagedRuntime.js +3 -0
  38. package/dist/ManagedRuntime.js.map +1 -1
  39. package/dist/Metric.d.ts.map +1 -1
  40. package/dist/Metric.js +4 -3
  41. package/dist/Metric.js.map +1 -1
  42. package/dist/MutableList.d.ts.map +1 -1
  43. package/dist/MutableList.js +4 -0
  44. package/dist/MutableList.js.map +1 -1
  45. package/dist/Optic.d.ts.map +1 -1
  46. package/dist/Optic.js +5 -4
  47. package/dist/Optic.js.map +1 -1
  48. package/dist/Option.d.ts.map +1 -1
  49. package/dist/Option.js +2 -1
  50. package/dist/Option.js.map +1 -1
  51. package/dist/PartitionedSemaphore.d.ts.map +1 -1
  52. package/dist/PartitionedSemaphore.js +1 -4
  53. package/dist/PartitionedSemaphore.js.map +1 -1
  54. package/dist/Record.d.ts +93 -1
  55. package/dist/Record.d.ts.map +1 -1
  56. package/dist/Record.js +57 -19
  57. package/dist/Record.js.map +1 -1
  58. package/dist/References.d.ts +0 -45
  59. package/dist/References.d.ts.map +1 -1
  60. package/dist/References.js +0 -45
  61. package/dist/References.js.map +1 -1
  62. package/dist/Request.d.ts.map +1 -1
  63. package/dist/Request.js +9 -6
  64. package/dist/Request.js.map +1 -1
  65. package/dist/Result.d.ts.map +1 -1
  66. package/dist/Result.js +2 -1
  67. package/dist/Result.js.map +1 -1
  68. package/dist/Schema.d.ts +1269 -496
  69. package/dist/Schema.d.ts.map +1 -1
  70. package/dist/Schema.js +2308 -614
  71. package/dist/Schema.js.map +1 -1
  72. package/dist/SchemaAST.d.ts +2 -2
  73. package/dist/SchemaAST.d.ts.map +1 -1
  74. package/dist/SchemaAST.js +189 -130
  75. package/dist/SchemaAST.js.map +1 -1
  76. package/dist/SchemaError.js +1 -1
  77. package/dist/SchemaError.js.map +1 -1
  78. package/dist/SchemaGetter.d.ts +13 -11
  79. package/dist/SchemaGetter.d.ts.map +1 -1
  80. package/dist/SchemaGetter.js +34 -24
  81. package/dist/SchemaGetter.js.map +1 -1
  82. package/dist/SchemaIssue.js +1 -1
  83. package/dist/SchemaIssue.js.map +1 -1
  84. package/dist/SchemaParser.d.ts.map +1 -1
  85. package/dist/SchemaParser.js +1 -12
  86. package/dist/SchemaParser.js.map +1 -1
  87. package/dist/SchemaRepresentation.d.ts +403 -1504
  88. package/dist/SchemaRepresentation.d.ts.map +1 -1
  89. package/dist/SchemaRepresentation.js +294 -2852
  90. package/dist/SchemaRepresentation.js.map +1 -1
  91. package/dist/SchemaTransformation.d.ts +2 -2
  92. package/dist/SchemaTransformation.js +3 -3
  93. package/dist/SchemaTransformation.js.map +1 -1
  94. package/dist/Semaphore.d.ts +5 -3
  95. package/dist/Semaphore.d.ts.map +1 -1
  96. package/dist/Semaphore.js.map +1 -1
  97. package/dist/Stream.d.ts +15 -9
  98. package/dist/Stream.d.ts.map +1 -1
  99. package/dist/Stream.js +46 -16
  100. package/dist/Stream.js.map +1 -1
  101. package/dist/Struct.d.ts.map +1 -1
  102. package/dist/Struct.js +5 -4
  103. package/dist/Struct.js.map +1 -1
  104. package/dist/Types.d.ts +1 -3
  105. package/dist/Types.d.ts.map +1 -1
  106. package/dist/index.d.ts +0 -4
  107. package/dist/index.d.ts.map +1 -1
  108. package/dist/index.js +0 -4
  109. package/dist/index.js.map +1 -1
  110. package/dist/internal/core.js +3 -2
  111. package/dist/internal/core.js.map +1 -1
  112. package/dist/internal/effect.js +119 -53
  113. package/dist/internal/effect.js.map +1 -1
  114. package/dist/internal/matcher.js +1 -1
  115. package/dist/internal/matcher.js.map +1 -1
  116. package/dist/internal/record.d.ts +0 -3
  117. package/dist/internal/record.d.ts.map +1 -1
  118. package/dist/internal/record.js +10 -5
  119. package/dist/internal/record.js.map +1 -1
  120. package/dist/internal/references.js +0 -4
  121. package/dist/internal/references.js.map +1 -1
  122. package/dist/internal/schema/annotations.js +12 -0
  123. package/dist/internal/schema/annotations.js.map +1 -1
  124. package/dist/internal/schema/fromJsonSchemaDocument.d.ts +2 -0
  125. package/dist/internal/schema/fromJsonSchemaDocument.d.ts.map +1 -0
  126. package/dist/internal/schema/fromJsonSchemaDocument.js +743 -0
  127. package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -0
  128. package/dist/internal/schema/fromRepresentation.d.ts +2 -0
  129. package/dist/internal/schema/fromRepresentation.d.ts.map +1 -0
  130. package/dist/internal/schema/fromRepresentation.js +252 -0
  131. package/dist/internal/schema/fromRepresentation.js.map +1 -0
  132. package/dist/internal/schema/schema.js +28 -40
  133. package/dist/internal/schema/schema.js.map +1 -1
  134. package/dist/internal/schema/{arbitrary.d.ts → toArbitrary.d.ts} +1 -1
  135. package/dist/internal/schema/toArbitrary.d.ts.map +1 -0
  136. package/dist/internal/schema/{arbitrary.js → toArbitrary.js} +8 -9
  137. package/dist/internal/schema/toArbitrary.js.map +1 -0
  138. package/dist/internal/schema/toCodeDocument.d.ts +2 -0
  139. package/dist/internal/schema/toCodeDocument.d.ts.map +1 -0
  140. package/dist/internal/schema/toCodeDocument.js +438 -0
  141. package/dist/internal/schema/toCodeDocument.js.map +1 -0
  142. package/dist/internal/schema/toEquivalence.d.ts +2 -0
  143. package/dist/internal/schema/toEquivalence.d.ts.map +1 -0
  144. package/dist/internal/schema/{equivalence.js → toEquivalence.js} +15 -13
  145. package/dist/internal/schema/toEquivalence.js.map +1 -0
  146. package/dist/internal/schema/toJsonSchemaDocument.d.ts +2 -0
  147. package/dist/internal/schema/toJsonSchemaDocument.d.ts.map +1 -0
  148. package/dist/internal/schema/toJsonSchemaDocument.js +466 -0
  149. package/dist/internal/schema/toJsonSchemaDocument.js.map +1 -0
  150. package/dist/internal/schema/toRepresentation.d.ts +2 -0
  151. package/dist/internal/schema/toRepresentation.d.ts.map +1 -0
  152. package/dist/internal/schema/toRepresentation.js +369 -0
  153. package/dist/internal/schema/toRepresentation.js.map +1 -0
  154. package/dist/internal/stackTraceLimit.js +3 -6
  155. package/dist/internal/stackTraceLimit.js.map +1 -1
  156. package/dist/testing/TestClock.js +4 -1
  157. package/dist/testing/TestClock.js.map +1 -1
  158. package/dist/unstable/ai/AiError.d.ts +26 -26
  159. package/dist/unstable/ai/AiError.d.ts.map +1 -1
  160. package/dist/unstable/ai/AiError.js +5 -4
  161. package/dist/unstable/ai/AiError.js.map +1 -1
  162. package/dist/unstable/ai/AnthropicStructuredOutput.d.ts +21 -6
  163. package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
  164. package/dist/unstable/ai/AnthropicStructuredOutput.js +86 -316
  165. package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
  166. package/dist/unstable/ai/EmbeddingModel.d.ts +1 -1
  167. package/dist/unstable/ai/EmbeddingModel.js +1 -1
  168. package/dist/unstable/ai/EmbeddingModel.js.map +1 -1
  169. package/dist/unstable/ai/LanguageModel.d.ts +4 -1
  170. package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
  171. package/dist/unstable/ai/LanguageModel.js +19 -17
  172. package/dist/unstable/ai/LanguageModel.js.map +1 -1
  173. package/dist/unstable/ai/McpSchema.d.ts +197 -197
  174. package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
  175. package/dist/unstable/ai/McpSchema.js +13 -13
  176. package/dist/unstable/ai/McpSchema.js.map +1 -1
  177. package/dist/unstable/ai/McpServer.d.ts +4 -4
  178. package/dist/unstable/ai/McpServer.d.ts.map +1 -1
  179. package/dist/unstable/ai/McpServer.js +116 -49
  180. package/dist/unstable/ai/McpServer.js.map +1 -1
  181. package/dist/unstable/ai/OpenAiStructuredOutput.d.ts +32 -10
  182. package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
  183. package/dist/unstable/ai/OpenAiStructuredOutput.js +193 -377
  184. package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
  185. package/dist/unstable/ai/Response.d.ts +19 -19
  186. package/dist/unstable/ai/Response.d.ts.map +1 -1
  187. package/dist/unstable/ai/Response.js +14 -14
  188. package/dist/unstable/ai/Response.js.map +1 -1
  189. package/dist/unstable/ai/Tool.d.ts +4 -0
  190. package/dist/unstable/ai/Tool.d.ts.map +1 -1
  191. package/dist/unstable/ai/Tool.js +11 -3
  192. package/dist/unstable/ai/Tool.js.map +1 -1
  193. package/dist/unstable/ai/Toolkit.d.ts +9 -1
  194. package/dist/unstable/ai/Toolkit.d.ts.map +1 -1
  195. package/dist/unstable/ai/Toolkit.js +14 -10
  196. package/dist/unstable/ai/Toolkit.js.map +1 -1
  197. package/dist/unstable/ai/internal/codec-transformer.js +15 -12
  198. package/dist/unstable/ai/internal/codec-transformer.js.map +1 -1
  199. package/dist/unstable/ai/internal/structured-output.d.ts +2 -0
  200. package/dist/unstable/ai/internal/structured-output.d.ts.map +1 -0
  201. package/dist/unstable/ai/internal/structured-output.js +316 -0
  202. package/dist/unstable/ai/internal/structured-output.js.map +1 -0
  203. package/dist/unstable/cli/CliError.d.ts +40 -2
  204. package/dist/unstable/cli/CliError.d.ts.map +1 -1
  205. package/dist/unstable/cli/CliError.js +45 -6
  206. package/dist/unstable/cli/CliError.js.map +1 -1
  207. package/dist/unstable/cli/Command.js +14 -5
  208. package/dist/unstable/cli/Command.js.map +1 -1
  209. package/dist/unstable/cli/Param.js +3 -3
  210. package/dist/unstable/cli/Param.js.map +1 -1
  211. package/dist/unstable/cli/Primitive.js +1 -1
  212. package/dist/unstable/cli/Primitive.js.map +1 -1
  213. package/dist/unstable/cli/internal/command.d.ts +3 -1
  214. package/dist/unstable/cli/internal/command.d.ts.map +1 -1
  215. package/dist/unstable/cli/internal/command.js +11 -4
  216. package/dist/unstable/cli/internal/command.js.map +1 -1
  217. package/dist/unstable/cli/internal/config.d.ts +0 -48
  218. package/dist/unstable/cli/internal/config.d.ts.map +1 -1
  219. package/dist/unstable/cli/internal/config.js +8 -10
  220. package/dist/unstable/cli/internal/config.js.map +1 -1
  221. package/dist/unstable/cluster/ClusterWorkflowEngine.js +1 -1
  222. package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
  223. package/dist/unstable/cluster/Entity.js +1 -1
  224. package/dist/unstable/cluster/Entity.js.map +1 -1
  225. package/dist/unstable/cluster/Envelope.d.ts.map +1 -1
  226. package/dist/unstable/cluster/Envelope.js +2 -1
  227. package/dist/unstable/cluster/Envelope.js.map +1 -1
  228. package/dist/unstable/cluster/Reply.js +1 -1
  229. package/dist/unstable/cluster/Reply.js.map +1 -1
  230. package/dist/unstable/cluster/Runner.d.ts +1 -1
  231. package/dist/unstable/cluster/Runner.js +1 -1
  232. package/dist/unstable/cluster/Runner.js.map +1 -1
  233. package/dist/unstable/cluster/RunnerAddress.d.ts +1 -1
  234. package/dist/unstable/cluster/RunnerAddress.js +1 -1
  235. package/dist/unstable/cluster/RunnerAddress.js.map +1 -1
  236. package/dist/unstable/cluster/ShardId.js +1 -1
  237. package/dist/unstable/cluster/ShardId.js.map +1 -1
  238. package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
  239. package/dist/unstable/cluster/Sharding.js +125 -24
  240. package/dist/unstable/cluster/Sharding.js.map +1 -1
  241. package/dist/unstable/cluster/ShardingConfig.d.ts +10 -2
  242. package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
  243. package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
  244. package/dist/unstable/cluster/SingleRunner.d.ts +4 -2
  245. package/dist/unstable/cluster/SingleRunner.d.ts.map +1 -1
  246. package/dist/unstable/cluster/SingleRunner.js +2 -1
  247. package/dist/unstable/cluster/SingleRunner.js.map +1 -1
  248. package/dist/unstable/cluster/SqlMessageStorage.d.ts +7 -4
  249. package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
  250. package/dist/unstable/cluster/SqlMessageStorage.js +55 -24
  251. package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
  252. package/dist/unstable/cluster/SqlRunnerStorage.d.ts.map +1 -1
  253. package/dist/unstable/cluster/SqlRunnerStorage.js +109 -62
  254. package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
  255. package/dist/unstable/cluster/internal/entityManager.js +19 -7
  256. package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
  257. package/dist/unstable/cluster/internal/shardLock.d.ts +2 -0
  258. package/dist/unstable/cluster/internal/shardLock.d.ts.map +1 -0
  259. package/dist/unstable/cluster/internal/shardLock.js +4 -0
  260. package/dist/unstable/cluster/internal/shardLock.js.map +1 -0
  261. package/dist/unstable/devtools/DevToolsSchema.d.ts +20 -20
  262. package/dist/unstable/devtools/DevToolsSchema.d.ts.map +1 -1
  263. package/dist/unstable/devtools/DevToolsSchema.js +8 -5
  264. package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
  265. package/dist/unstable/eventlog/EventJournal.d.ts +1 -1
  266. package/dist/unstable/eventlog/EventJournal.js +1 -1
  267. package/dist/unstable/eventlog/EventJournal.js.map +1 -1
  268. package/dist/unstable/eventlog/EventLog.d.ts.map +1 -1
  269. package/dist/unstable/eventlog/EventLog.js +15 -11
  270. package/dist/unstable/eventlog/EventLog.js.map +1 -1
  271. package/dist/unstable/eventlog/EventLogEncryption.d.ts +1 -1
  272. package/dist/unstable/eventlog/EventLogEncryption.js +1 -1
  273. package/dist/unstable/eventlog/EventLogEncryption.js.map +1 -1
  274. package/dist/unstable/eventlog/EventLogMessage.d.ts +26 -26
  275. package/dist/unstable/eventlog/EventLogMessage.d.ts.map +1 -1
  276. package/dist/unstable/eventlog/EventLogMessage.js +8 -3
  277. package/dist/unstable/eventlog/EventLogMessage.js.map +1 -1
  278. package/dist/unstable/eventlog/EventLogRemote.d.ts +1 -1
  279. package/dist/unstable/eventlog/SqlEventJournal.js +2 -2
  280. package/dist/unstable/eventlog/SqlEventJournal.js.map +1 -1
  281. package/dist/unstable/eventlog/SqlEventLogServerEncrypted.js +1 -1
  282. package/dist/unstable/eventlog/SqlEventLogServerEncrypted.js.map +1 -1
  283. package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js +3 -3
  284. package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js.map +1 -1
  285. package/dist/unstable/http/Cookies.d.ts.map +1 -1
  286. package/dist/unstable/http/Cookies.js +24 -22
  287. package/dist/unstable/http/Cookies.js.map +1 -1
  288. package/dist/unstable/http/Headers.js +8 -8
  289. package/dist/unstable/http/Headers.js.map +1 -1
  290. package/dist/unstable/http/HttpClientRequest.d.ts +44 -0
  291. package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
  292. package/dist/unstable/http/HttpClientRequest.js +14 -0
  293. package/dist/unstable/http/HttpClientRequest.js.map +1 -1
  294. package/dist/unstable/http/HttpRouter.d.ts +2 -2
  295. package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
  296. package/dist/unstable/http/HttpRouter.js.map +1 -1
  297. package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
  298. package/dist/unstable/http/HttpServerRequest.js +5 -4
  299. package/dist/unstable/http/HttpServerRequest.js.map +1 -1
  300. package/dist/unstable/http/Multipart.d.ts.map +1 -1
  301. package/dist/unstable/http/Multipart.js +17 -15
  302. package/dist/unstable/http/Multipart.js.map +1 -1
  303. package/dist/unstable/http/Template.js +1 -1
  304. package/dist/unstable/http/Template.js.map +1 -1
  305. package/dist/unstable/http/UrlParams.d.ts.map +1 -1
  306. package/dist/unstable/http/UrlParams.js +17 -14
  307. package/dist/unstable/http/UrlParams.js.map +1 -1
  308. package/dist/unstable/httpapi/HttpApi.js +3 -3
  309. package/dist/unstable/httpapi/HttpApi.js.map +1 -1
  310. package/dist/unstable/httpapi/HttpApiClient.js +5 -5
  311. package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
  312. package/dist/unstable/httpapi/HttpApiGroup.js +1 -1
  313. package/dist/unstable/httpapi/HttpApiGroup.js.map +1 -1
  314. package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
  315. package/dist/unstable/httpapi/OpenApi.js +37 -24
  316. package/dist/unstable/httpapi/OpenApi.js.map +1 -1
  317. package/dist/unstable/observability/OtlpExporter.d.ts +72 -1
  318. package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
  319. package/dist/unstable/observability/OtlpExporter.js +69 -4
  320. package/dist/unstable/observability/OtlpExporter.js.map +1 -1
  321. package/dist/unstable/observability/OtlpLogger.d.ts +4 -3
  322. package/dist/unstable/observability/OtlpLogger.d.ts.map +1 -1
  323. package/dist/unstable/observability/OtlpLogger.js +2 -2
  324. package/dist/unstable/observability/OtlpLogger.js.map +1 -1
  325. package/dist/unstable/observability/OtlpMetrics.d.ts +7 -3
  326. package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
  327. package/dist/unstable/observability/OtlpMetrics.js +5 -2
  328. package/dist/unstable/observability/OtlpMetrics.js.map +1 -1
  329. package/dist/unstable/observability/OtlpTracer.d.ts +4 -3
  330. package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
  331. package/dist/unstable/observability/OtlpTracer.js +2 -2
  332. package/dist/unstable/observability/OtlpTracer.js.map +1 -1
  333. package/dist/unstable/persistence/Persistable.d.ts.map +1 -1
  334. package/dist/unstable/persistence/Persistable.js +2 -1
  335. package/dist/unstable/persistence/Persistable.js.map +1 -1
  336. package/dist/unstable/persistence/RateLimiter.d.ts +2 -2
  337. package/dist/unstable/persistence/RateLimiter.js +2 -2
  338. package/dist/unstable/persistence/RateLimiter.js.map +1 -1
  339. package/dist/unstable/persistence/Redis.d.ts.map +1 -1
  340. package/dist/unstable/persistence/Redis.js +2 -2
  341. package/dist/unstable/persistence/Redis.js.map +1 -1
  342. package/dist/unstable/process/ChildProcessSpawner.js +3 -1
  343. package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
  344. package/dist/unstable/reactivity/AsyncResult.d.ts.map +1 -1
  345. package/dist/unstable/reactivity/AsyncResult.js +4 -3
  346. package/dist/unstable/reactivity/AsyncResult.js.map +1 -1
  347. package/dist/unstable/reactivity/Atom.d.ts +83 -0
  348. package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
  349. package/dist/unstable/reactivity/Atom.js +31 -0
  350. package/dist/unstable/reactivity/Atom.js.map +1 -1
  351. package/dist/unstable/reactivity/AtomRegistry.js +1 -1
  352. package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
  353. package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
  354. package/dist/unstable/rpc/RpcClient.js +2 -1
  355. package/dist/unstable/rpc/RpcClient.js.map +1 -1
  356. package/dist/unstable/schema/VariantSchema.d.ts +1 -2
  357. package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
  358. package/dist/unstable/schema/VariantSchema.js +13 -10
  359. package/dist/unstable/schema/VariantSchema.js.map +1 -1
  360. package/dist/unstable/socket/Socket.d.ts +1 -1
  361. package/dist/unstable/socket/Socket.js +1 -1
  362. package/dist/unstable/socket/Socket.js.map +1 -1
  363. package/dist/unstable/sql/SqlError.d.ts +2 -2
  364. package/dist/unstable/sql/SqlError.js +2 -2
  365. package/dist/unstable/sql/SqlError.js.map +1 -1
  366. package/dist/unstable/sql/Statement.d.ts.map +1 -1
  367. package/dist/unstable/sql/Statement.js +7 -6
  368. package/dist/unstable/sql/Statement.js.map +1 -1
  369. package/package.json +1 -1
  370. package/src/Array.ts +86 -25
  371. package/src/Channel.ts +32 -14
  372. package/src/Config.ts +6 -5
  373. package/src/ConfigProvider.ts +7 -7
  374. package/src/Data.ts +3 -2
  375. package/src/Effect.ts +70 -116
  376. package/src/FiberHandle.ts +3 -2
  377. package/src/Iterable.ts +2 -1
  378. package/src/JsonPatch.ts +4 -3
  379. package/src/JsonSchema.ts +9 -11
  380. package/src/Logger.ts +3 -2
  381. package/src/ManagedRuntime.ts +13 -0
  382. package/src/Metric.ts +4 -3
  383. package/src/MutableList.ts +4 -0
  384. package/src/Optic.ts +5 -4
  385. package/src/Option.ts +2 -1
  386. package/src/PartitionedSemaphore.ts +1 -4
  387. package/src/Record.ts +119 -22
  388. package/src/References.ts +0 -46
  389. package/src/Request.ts +5 -7
  390. package/src/Result.ts +2 -1
  391. package/src/Schema.ts +2538 -987
  392. package/src/SchemaAST.ts +228 -149
  393. package/src/SchemaError.ts +1 -1
  394. package/src/SchemaGetter.ts +36 -29
  395. package/src/SchemaIssue.ts +1 -1
  396. package/src/SchemaParser.ts +1 -25
  397. package/src/SchemaRepresentation.ts +697 -3398
  398. package/src/SchemaTransformation.ts +3 -3
  399. package/src/Semaphore.ts +5 -3
  400. package/src/Stream.ts +63 -19
  401. package/src/Struct.ts +5 -4
  402. package/src/Types.ts +1 -3
  403. package/src/index.ts +0 -5
  404. package/src/internal/core.ts +4 -3
  405. package/src/internal/effect.ts +132 -70
  406. package/src/internal/matcher.ts +1 -1
  407. package/src/internal/record.ts +11 -7
  408. package/src/internal/references.ts +0 -5
  409. package/src/internal/schema/annotations.ts +44 -0
  410. package/src/internal/schema/fromJsonSchemaDocument.ts +957 -0
  411. package/src/internal/schema/fromRepresentation.ts +345 -0
  412. package/src/internal/schema/schema.ts +45 -46
  413. package/src/internal/schema/{arbitrary.ts → toArbitrary.ts} +8 -10
  414. package/src/internal/schema/toCodeDocument.ts +572 -0
  415. package/src/internal/schema/{equivalence.ts → toEquivalence.ts} +12 -7
  416. package/src/internal/schema/toJsonSchemaDocument.ts +475 -0
  417. package/src/internal/schema/toRepresentation.ts +401 -0
  418. package/src/internal/stackTraceLimit.ts +3 -7
  419. package/src/testing/TestClock.ts +1 -1
  420. package/src/unstable/ai/AiError.ts +5 -4
  421. package/src/unstable/ai/AnthropicStructuredOutput.ts +102 -333
  422. package/src/unstable/ai/EmbeddingModel.ts +1 -1
  423. package/src/unstable/ai/LanguageModel.ts +30 -28
  424. package/src/unstable/ai/McpSchema.ts +15 -15
  425. package/src/unstable/ai/McpServer.ts +172 -56
  426. package/src/unstable/ai/OpenAiStructuredOutput.ts +230 -395
  427. package/src/unstable/ai/Response.ts +24 -24
  428. package/src/unstable/ai/Tool.ts +22 -4
  429. package/src/unstable/ai/Toolkit.ts +19 -7
  430. package/src/unstable/ai/internal/codec-transformer.ts +13 -7
  431. package/src/unstable/ai/internal/structured-output.ts +458 -0
  432. package/src/unstable/cli/CliError.ts +51 -5
  433. package/src/unstable/cli/Command.ts +4 -4
  434. package/src/unstable/cli/Param.ts +3 -3
  435. package/src/unstable/cli/Primitive.ts +1 -1
  436. package/src/unstable/cli/internal/command.ts +13 -5
  437. package/src/unstable/cli/internal/config.ts +8 -10
  438. package/src/unstable/cluster/ClusterWorkflowEngine.ts +3 -3
  439. package/src/unstable/cluster/Entity.ts +1 -1
  440. package/src/unstable/cluster/Envelope.ts +2 -1
  441. package/src/unstable/cluster/Reply.ts +1 -1
  442. package/src/unstable/cluster/Runner.ts +1 -1
  443. package/src/unstable/cluster/RunnerAddress.ts +1 -1
  444. package/src/unstable/cluster/ShardId.ts +1 -1
  445. package/src/unstable/cluster/Sharding.ts +161 -34
  446. package/src/unstable/cluster/ShardingConfig.ts +5 -1
  447. package/src/unstable/cluster/SingleRunner.ts +4 -2
  448. package/src/unstable/cluster/SqlMessageStorage.ts +83 -35
  449. package/src/unstable/cluster/SqlRunnerStorage.ts +186 -116
  450. package/src/unstable/cluster/internal/entityManager.ts +31 -10
  451. package/src/unstable/cluster/internal/shardLock.ts +9 -0
  452. package/src/unstable/devtools/DevToolsSchema.ts +10 -5
  453. package/src/unstable/eventlog/EventJournal.ts +1 -1
  454. package/src/unstable/eventlog/EventLog.ts +21 -11
  455. package/src/unstable/eventlog/EventLogEncryption.ts +1 -1
  456. package/src/unstable/eventlog/EventLogMessage.ts +10 -3
  457. package/src/unstable/eventlog/SqlEventJournal.ts +2 -2
  458. package/src/unstable/eventlog/SqlEventLogServerEncrypted.ts +1 -1
  459. package/src/unstable/eventlog/SqlEventLogServerUnencrypted.ts +6 -3
  460. package/src/unstable/http/Cookies.ts +29 -24
  461. package/src/unstable/http/Headers.ts +8 -8
  462. package/src/unstable/http/HttpClientRequest.ts +57 -0
  463. package/src/unstable/http/HttpRouter.ts +6 -3
  464. package/src/unstable/http/HttpServerRequest.ts +5 -4
  465. package/src/unstable/http/Multipart.ts +16 -13
  466. package/src/unstable/http/Template.ts +1 -1
  467. package/src/unstable/http/UrlParams.ts +17 -14
  468. package/src/unstable/httpapi/HttpApi.ts +3 -3
  469. package/src/unstable/httpapi/HttpApiClient.ts +5 -5
  470. package/src/unstable/httpapi/HttpApiGroup.ts +1 -1
  471. package/src/unstable/httpapi/OpenApi.ts +52 -28
  472. package/src/unstable/observability/OtlpExporter.ts +109 -5
  473. package/src/unstable/observability/OtlpLogger.ts +5 -5
  474. package/src/unstable/observability/OtlpMetrics.ts +8 -4
  475. package/src/unstable/observability/OtlpTracer.ts +8 -4
  476. package/src/unstable/persistence/Persistable.ts +3 -2
  477. package/src/unstable/persistence/RateLimiter.ts +2 -2
  478. package/src/unstable/persistence/Redis.ts +2 -2
  479. package/src/unstable/process/ChildProcessSpawner.ts +1 -1
  480. package/src/unstable/reactivity/AsyncResult.ts +4 -3
  481. package/src/unstable/reactivity/Atom.ts +92 -0
  482. package/src/unstable/reactivity/AtomRegistry.ts +1 -1
  483. package/src/unstable/rpc/RpcClient.ts +2 -1
  484. package/src/unstable/schema/VariantSchema.ts +14 -24
  485. package/src/unstable/socket/Socket.ts +1 -1
  486. package/src/unstable/sql/SqlError.ts +2 -2
  487. package/src/unstable/sql/Statement.ts +7 -6
  488. package/dist/SchemaUtils.d.ts +0 -28
  489. package/dist/SchemaUtils.d.ts.map +0 -1
  490. package/dist/SchemaUtils.js +0 -45
  491. package/dist/SchemaUtils.js.map +0 -1
  492. package/dist/internal/schema/arbitrary.d.ts.map +0 -1
  493. package/dist/internal/schema/arbitrary.js.map +0 -1
  494. package/dist/internal/schema/equivalence.d.ts +0 -2
  495. package/dist/internal/schema/equivalence.d.ts.map +0 -1
  496. package/dist/internal/schema/equivalence.js.map +0 -1
  497. package/dist/internal/schema/representation.d.ts +0 -2
  498. package/dist/internal/schema/representation.d.ts.map +0 -1
  499. package/dist/internal/schema/representation.js +0 -865
  500. package/dist/internal/schema/representation.js.map +0 -1
  501. package/src/SchemaUtils.ts +0 -51
  502. package/src/internal/schema/representation.ts +0 -795
@@ -0,0 +1,743 @@
1
+ import { unescapeToken } from "../../JsonPointer.js";
2
+ import { remainder } from "../../Number.js";
3
+ import * as Schema from "../../Schema.js";
4
+ import * as SchemaAST from "../../SchemaAST.js";
5
+ import { errorWithPath } from "../errors.js";
6
+ import * as InternalRecord from "../record.js";
7
+ import * as InternalAnnotations from "./annotations.js";
8
+ import { fromRepresentation, fromRepresentations } from "./fromRepresentation.js";
9
+ const never = {
10
+ _tag: "Never",
11
+ checks: []
12
+ };
13
+ const unknown = {
14
+ _tag: "Unknown",
15
+ checks: []
16
+ };
17
+ const string = {
18
+ _tag: "String",
19
+ checks: []
20
+ };
21
+ function makeLiteral(literal) {
22
+ return {
23
+ _tag: "Literal",
24
+ literal,
25
+ checks: []
26
+ };
27
+ }
28
+ function annotate(representation, annotations) {
29
+ if (annotations === undefined) return representation;
30
+ if (representation._tag === "Reference") {
31
+ return {
32
+ _tag: "Suspend",
33
+ annotations,
34
+ checks: [],
35
+ thunk: representation
36
+ };
37
+ }
38
+ return {
39
+ ...representation,
40
+ annotations: {
41
+ ...representation.annotations,
42
+ ...annotations
43
+ }
44
+ };
45
+ }
46
+ const jsonSchemaTypes = /*#__PURE__*/new Set(["null", "string", "number", "integer", "boolean", "object", "array"]);
47
+ const jsonSchemaStringKeys = ["minLength", "maxLength", "pattern", "format", "contentMediaType", "contentSchema"];
48
+ const jsonSchemaNumberKeys = ["minimum", "maximum", "exclusiveMinimum", "exclusiveMaximum", "multipleOf"];
49
+ const jsonSchemaObjectKeys = ["properties", "required", "additionalProperties", "patternProperties", "propertyNames", "minProperties", "maxProperties"];
50
+ const jsonSchemaArrayKeys = ["items", "prefixItems", "additionalItems", "minItems", "maxItems", "uniqueItems"];
51
+ function isImportedJsonSchemaType(input) {
52
+ return typeof input === "string" && jsonSchemaTypes.has(input);
53
+ }
54
+ function inferJsonSchemaType(schema) {
55
+ if (jsonSchemaStringKeys.some(key => schema[key] !== undefined)) return "string";
56
+ if (jsonSchemaNumberKeys.some(key => schema[key] !== undefined)) return "number";
57
+ if (jsonSchemaObjectKeys.some(key => schema[key] !== undefined)) return "object";
58
+ if (jsonSchemaArrayKeys.some(key => schema[key] !== undefined)) return "array";
59
+ }
60
+ function jsonSchemaReferenceKey($ref) {
61
+ const token = $ref.slice($ref.lastIndexOf("/") + 1);
62
+ return token.length === 0 ? undefined : unescapeToken(token);
63
+ }
64
+ function jsonSchemaFilter(id, payload, schemas) {
65
+ return {
66
+ _tag: "Filter",
67
+ aborted: false,
68
+ representation: {
69
+ id,
70
+ payload,
71
+ ...(schemas === undefined ? undefined : {
72
+ schemas
73
+ })
74
+ }
75
+ };
76
+ }
77
+ function addNumberCheck(checks, value, id, key) {
78
+ if (typeof value === "number") {
79
+ checks.push(jsonSchemaFilter(id, {
80
+ [key]: value
81
+ }));
82
+ }
83
+ }
84
+ function jsonSchemaAnnotations(schema) {
85
+ const annotations = {};
86
+ if (typeof schema.title === "string") annotations.title = schema.title;
87
+ if (typeof schema.description === "string") annotations.description = schema.description;
88
+ if (Object.hasOwn(schema, "default")) annotations.default = schema.default;
89
+ if (Array.isArray(schema.examples)) annotations.examples = schema.examples;
90
+ if (typeof schema.readOnly === "boolean") annotations.readOnly = schema.readOnly;
91
+ if (typeof schema.writeOnly === "boolean") annotations.writeOnly = schema.writeOnly;
92
+ if (typeof schema.format === "string") annotations.format = schema.format;
93
+ if (typeof schema.contentEncoding === "string") annotations.contentEncoding = schema.contentEncoding;
94
+ if (typeof schema.contentMediaType === "string") annotations.contentMediaType = schema.contentMediaType;
95
+ if (SchemaAST.isJson(schema.contentSchema)) annotations.contentSchema = schema.contentSchema;
96
+ return Object.keys(annotations).length === 0 ? undefined : annotations;
97
+ }
98
+ function jsonDeclaration(annotations) {
99
+ return {
100
+ _tag: "Declaration",
101
+ representation: {
102
+ id: "effect/schema/Json",
103
+ payload: null
104
+ },
105
+ annotations: {
106
+ ...annotations,
107
+ expected: "JSON value"
108
+ },
109
+ checks: [],
110
+ typeParameters: []
111
+ };
112
+ }
113
+ function unknownJsonSchemas(representation) {
114
+ switch (representation._tag) {
115
+ case "Unknown":
116
+ return jsonDeclaration(representation.annotations);
117
+ case "Suspend":
118
+ return {
119
+ ...representation,
120
+ thunk: unknownJsonSchemas(representation.thunk)
121
+ };
122
+ case "Arrays":
123
+ return {
124
+ ...representation,
125
+ elements: representation.elements.map(element => ({
126
+ ...element,
127
+ type: unknownJsonSchemas(element.type)
128
+ })),
129
+ rest: representation.rest.map(unknownJsonSchemas)
130
+ };
131
+ case "Objects":
132
+ return {
133
+ ...representation,
134
+ propertySignatures: representation.propertySignatures.map(property => ({
135
+ ...property,
136
+ type: unknownJsonSchemas(property.type)
137
+ })),
138
+ indexSignatures: representation.indexSignatures.map(indexSignature => ({
139
+ parameter: unknownJsonSchemas(indexSignature.parameter),
140
+ type: unknownJsonSchemas(indexSignature.type)
141
+ })),
142
+ checks: representation.checks.map(unknownJsonSchemaCheck)
143
+ };
144
+ case "Union":
145
+ return {
146
+ ...representation,
147
+ types: representation.types.map(unknownJsonSchemas)
148
+ };
149
+ default:
150
+ return representation;
151
+ }
152
+ }
153
+ function unknownJsonSchemaCheck(check) {
154
+ const representation = check.representation;
155
+ const schemas = representation?.schemas;
156
+ if (representation === undefined || schemas === undefined) {
157
+ return check;
158
+ }
159
+ return {
160
+ ...check,
161
+ representation: {
162
+ ...representation,
163
+ schemas: schemas.map(unknownJsonSchemas)
164
+ }
165
+ };
166
+ }
167
+ function translateJsonSchemaMultiDocument(document, options, singleRoot = false) {
168
+ const definitionCache = new Map();
169
+ const definitionsInProgress = new Set();
170
+ const annotatedReferences = [];
171
+ function translateDefinition(key, path, recursiveReferenceError) {
172
+ const cached = definitionCache.get(key);
173
+ if (cached !== undefined) return cached;
174
+ if (!Object.hasOwn(document.definitions, key)) {
175
+ throw errorWithPath(`Invalid reference ${key}`, [...path, "$ref"]);
176
+ }
177
+ if (definitionsInProgress.has(key)) {
178
+ throw errorWithPath(recursiveReferenceError ?? `Invalid reference ${key}`, [...path, "$ref"]);
179
+ }
180
+ definitionsInProgress.add(key);
181
+ const representation = recur(document.definitions[key], ["definitions", key]);
182
+ definitionsInProgress.delete(key);
183
+ definitionCache.set(key, representation);
184
+ return representation;
185
+ }
186
+ function resolveReference(reference, path, options, seen = new Set()) {
187
+ if (seen.has(reference.$ref)) {
188
+ throw errorWithPath(`Invalid reference ${reference.$ref}`, [...path, "$ref"]);
189
+ }
190
+ const nextSeen = new Set(seen).add(reference.$ref);
191
+ const representation = translateDefinition(reference.$ref, path, options?.recursiveReferenceError);
192
+ if (representation._tag === "Reference") {
193
+ return resolveReference(representation, path, options, nextSeen);
194
+ }
195
+ if (representation._tag === "Suspend" && representation.thunk._tag === "Reference") {
196
+ return annotate(resolveReference(representation.thunk, path, options, nextSeen), representation.annotations);
197
+ }
198
+ return representation;
199
+ }
200
+ function annotationsOf(representation) {
201
+ return representation._tag === "Reference" ? undefined : representation.annotations;
202
+ }
203
+ function mergeAnnotations(left, right) {
204
+ if (left === undefined) return right;
205
+ if (right === undefined) return left;
206
+ return {
207
+ ...left,
208
+ ...right
209
+ };
210
+ }
211
+ function combinedAnnotations(representation, left, right) {
212
+ return annotate(representation, mergeAnnotations(annotationsOf(left), annotationsOf(right)));
213
+ }
214
+ function asChecks(checks, annotations) {
215
+ if (checks.length === 0) return undefined;
216
+ if (annotations === undefined) return checks;
217
+ if (checks.length === 1 && checks[0].annotations === undefined) {
218
+ return [{
219
+ ...checks[0],
220
+ annotations
221
+ }];
222
+ }
223
+ return [{
224
+ _tag: "FilterGroup",
225
+ checks: checks,
226
+ annotations
227
+ }];
228
+ }
229
+ function combineChecks(left, right, annotations, deduplicate = []) {
230
+ for (const id of deduplicate) {
231
+ if (left.some(check => checkId(check) === id)) {
232
+ right = right.filter(check => checkId(check) !== id);
233
+ }
234
+ }
235
+ const checks = asChecks(right, annotations);
236
+ return checks === undefined ? undefined : [...left, ...checks];
237
+ }
238
+ function checkId(check) {
239
+ return check._tag === "Filter" ? check.representation?.id : undefined;
240
+ }
241
+ function satisfiesPrimitiveCheck(check, value) {
242
+ if (check._tag === "FilterGroup") {
243
+ return check.checks.every(check => satisfiesPrimitiveCheck(check, value));
244
+ }
245
+ const representation = check.representation;
246
+ const payload = representation.payload;
247
+ switch (representation.id) {
248
+ case "effect/schema/isMinLength":
249
+ return value.length >= payload.minLength;
250
+ case "effect/schema/isMaxLength":
251
+ return value.length <= payload.maxLength;
252
+ case "effect/schema/isPattern":
253
+ return new RegExp(payload.source, payload.flags).test(value);
254
+ case "effect/schema/isFinite":
255
+ return globalThis.Number.isFinite(value);
256
+ case "effect/schema/isInt":
257
+ return globalThis.Number.isSafeInteger(value);
258
+ case "effect/schema/isMultipleOf":
259
+ return remainder(value, payload.divisor) === 0;
260
+ case "effect/schema/isGreaterThan":
261
+ return value > payload.exclusiveMinimum;
262
+ case "effect/schema/isGreaterThanOrEqualTo":
263
+ return value >= payload.minimum;
264
+ case "effect/schema/isLessThan":
265
+ return value < payload.exclusiveMaximum;
266
+ case "effect/schema/isLessThanOrEqualTo":
267
+ return value <= payload.maximum;
268
+ }
269
+ }
270
+ function satisfiesLiteral(representation, literal) {
271
+ const value = literal.literal;
272
+ if (representation._tag === "String" ? typeof value !== "string" : typeof value !== "number") {
273
+ return false;
274
+ }
275
+ return representation.checks.every(check => satisfiesPrimitiveCheck(check, value));
276
+ }
277
+ function combinePrimitiveWithLiteral(primitive, literal) {
278
+ const satisfies = primitive._tag === "Boolean" ? typeof literal.literal === "boolean" : satisfiesLiteral(primitive, literal);
279
+ return satisfies ? combinedAnnotations(literal, primitive, literal) : never;
280
+ }
281
+ function combineArrays(left, right, path) {
282
+ const elements = [];
283
+ const length = Math.max(left.elements.length, right.elements.length);
284
+ for (let index = 0; index < length; index++) {
285
+ const leftElement = left.elements[index];
286
+ const rightElement = right.elements[index];
287
+ const isOptional = leftElement?.isOptional !== false && rightElement?.isOptional !== false;
288
+ const leftType = leftElement?.type ?? left.rest[0];
289
+ const rightType = rightElement?.type ?? right.rest[0];
290
+ if (leftType === undefined || rightType === undefined) {
291
+ return isOptional ? {
292
+ elements,
293
+ rest: []
294
+ } : undefined;
295
+ }
296
+ const type = combine(leftType, rightType, [...path, "elements", index, "type"]);
297
+ if (type._tag === "Never") {
298
+ return isOptional ? {
299
+ elements,
300
+ rest: []
301
+ } : undefined;
302
+ }
303
+ elements.push({
304
+ isOptional,
305
+ type
306
+ });
307
+ }
308
+ const leftRest = left.rest[0];
309
+ const rightRest = right.rest[0];
310
+ if (leftRest === undefined || rightRest === undefined) {
311
+ return {
312
+ elements,
313
+ rest: []
314
+ };
315
+ }
316
+ const rest = combine(leftRest, rightRest, [...path, "rest", 0]);
317
+ return {
318
+ elements,
319
+ rest: rest._tag === "Never" ? [] : [rest]
320
+ };
321
+ }
322
+ function combineProperties(left, right, path) {
323
+ const rightByName = new Map(right.map(property => [property.name, property]));
324
+ const names = new Set();
325
+ const properties = left.map(property => {
326
+ const name = property.name;
327
+ names.add(name);
328
+ const other = rightByName.get(name);
329
+ if (other === undefined) return property;
330
+ return {
331
+ name: property.name,
332
+ type: combine(property.type, other.type, [...path, "properties", globalThis.String(name)]),
333
+ isOptional: property.isOptional && other.isOptional,
334
+ isMutable: false
335
+ };
336
+ });
337
+ for (const property of right) {
338
+ if (!names.has(property.name)) properties.push(property);
339
+ }
340
+ return properties;
341
+ }
342
+ function isUnconstrainedString(representation) {
343
+ return representation._tag === "String" && representation.checks.length === 0 && representation.annotations === undefined;
344
+ }
345
+ function combineIndexSignatures(left, right, path) {
346
+ if (left.length === 0 || right.length === 0) return [];
347
+ const signatures = [...left];
348
+ for (const signature of right) {
349
+ if (isUnconstrainedString(signature.parameter)) {
350
+ const index = signatures.findIndex(candidate => isUnconstrainedString(candidate.parameter));
351
+ if (index !== -1) {
352
+ signatures[index] = {
353
+ parameter: signatures[index].parameter,
354
+ type: combine(signatures[index].type, signature.type, [...path, "indexSignatures", index, "type"])
355
+ };
356
+ } else {
357
+ signatures.push(signature);
358
+ }
359
+ } else {
360
+ signatures.push(signature);
361
+ }
362
+ }
363
+ return signatures;
364
+ }
365
+ function combine(left, right, path) {
366
+ if (left._tag === "Never") return left;
367
+ if (right._tag === "Never") return right;
368
+ if (left._tag === "Unknown") return combinedAnnotations(right, left, right);
369
+ if (right._tag === "Unknown") return combinedAnnotations(left, left, right);
370
+ if (left._tag === "Reference") return combine(resolveReference(left, path), right, path);
371
+ if (right._tag === "Reference") return combine(left, resolveReference(right, path), path);
372
+ if (left._tag === "Suspend") {
373
+ return annotate(combine(left.thunk, right, path), left.annotations);
374
+ }
375
+ if (right._tag === "Suspend") {
376
+ return annotate(combine(left, right.thunk, path), right.annotations);
377
+ }
378
+ if (left._tag === "Union") {
379
+ const types = left.types.map((type, index) => combine(type, right, [...path, "types", index])).filter(type => type._tag !== "Never");
380
+ if (types.length === 0) return never;
381
+ return annotate({
382
+ _tag: "Union",
383
+ types,
384
+ mode: left.mode,
385
+ checks: left.checks
386
+ }, left.annotations);
387
+ }
388
+ if (right._tag === "Union") return combine(right, left, path);
389
+ switch (left._tag) {
390
+ case "Null":
391
+ return right._tag === "Null" ? combinedAnnotations({
392
+ _tag: "Null",
393
+ checks: [...left.checks, ...right.checks]
394
+ }, left, right) : never;
395
+ case "String":
396
+ if (right._tag === "Literal") {
397
+ return combinePrimitiveWithLiteral(left, right);
398
+ }
399
+ if (right._tag !== "String") return never;
400
+ const stringChecks = combineChecks(left.checks, right.checks, right.annotations);
401
+ return annotate({
402
+ _tag: "String",
403
+ checks: stringChecks ?? left.checks
404
+ }, mergeAnnotations(left.annotations, stringChecks === undefined ? right.annotations : undefined));
405
+ case "Number":
406
+ if (right._tag === "Literal") {
407
+ return combinePrimitiveWithLiteral(left, right);
408
+ }
409
+ if (right._tag !== "Number") return never;
410
+ const numberChecks = combineChecks(left.checks, right.checks, right.annotations, ["effect/schema/isFinite", "effect/schema/isInt"]);
411
+ return annotate({
412
+ _tag: "Number",
413
+ checks: numberChecks ?? left.checks
414
+ }, mergeAnnotations(left.annotations, numberChecks === undefined ? right.annotations : undefined));
415
+ case "Boolean":
416
+ if (right._tag === "Literal") {
417
+ return combinePrimitiveWithLiteral(left, right);
418
+ }
419
+ return right._tag === "Boolean" ? combinedAnnotations({
420
+ _tag: "Boolean",
421
+ checks: [...left.checks, ...right.checks]
422
+ }, left, right) : never;
423
+ case "Literal":
424
+ if (right._tag === "Literal") {
425
+ return left.literal === right.literal ? combinedAnnotations({
426
+ ...left,
427
+ checks: [...left.checks, ...right.checks]
428
+ }, left, right) : never;
429
+ }
430
+ if ((right._tag === "String" || right._tag === "Number") && satisfiesLiteral(right, left) || right._tag === "Boolean" && typeof left.literal === "boolean") {
431
+ return combinedAnnotations(left, left, right);
432
+ }
433
+ return never;
434
+ case "Arrays":
435
+ {
436
+ if (right._tag !== "Arrays") return never;
437
+ const arrays = combineArrays(left, right, path);
438
+ if (arrays === undefined) return never;
439
+ const arrayChecks = combineChecks(left.checks, right.checks, right.annotations, ["effect/schema/isUnique"]);
440
+ return annotate({
441
+ _tag: "Arrays",
442
+ elements: arrays.elements,
443
+ rest: arrays.rest,
444
+ checks: arrayChecks ?? left.checks
445
+ }, mergeAnnotations(left.annotations, arrayChecks === undefined ? right.annotations : undefined));
446
+ }
447
+ case "Objects":
448
+ {
449
+ if (right._tag !== "Objects") return never;
450
+ const objectChecks = combineChecks(left.checks, right.checks, right.annotations);
451
+ return annotate({
452
+ _tag: "Objects",
453
+ propertySignatures: combineProperties(left.propertySignatures, right.propertySignatures, path),
454
+ indexSignatures: combineIndexSignatures(left.indexSignatures, right.indexSignatures, path),
455
+ checks: objectChecks ?? left.checks
456
+ }, mergeAnnotations(left.annotations, objectChecks === undefined ? right.annotations : undefined));
457
+ }
458
+ }
459
+ }
460
+ function enter(input) {
461
+ if (typeof input !== "object" || input === null || Array.isArray(input)) {
462
+ return undefined;
463
+ }
464
+ const schema = input;
465
+ return options?.onEnter === undefined ? schema : options.onEnter(schema);
466
+ }
467
+ function recur(input, path) {
468
+ if (input === false) {
469
+ return never;
470
+ }
471
+ const schema = enter(input);
472
+ if (schema === undefined) {
473
+ return unknown;
474
+ }
475
+ let representation = on(schema, path);
476
+ if (representation._tag === "Reference") {
477
+ const siblingSchema = {
478
+ ...schema,
479
+ $ref: undefined
480
+ };
481
+ for (const key of InternalAnnotations.jsonSchemaAnnotationKeys) {
482
+ delete siblingSchema[key];
483
+ }
484
+ const sibling = on(siblingSchema, path);
485
+ if (sibling._tag !== "Unknown") {
486
+ const reference = representation;
487
+ representation = combine(resolveReference(reference, path, {
488
+ recursiveReferenceError: `Unsupported assertion siblings on recursive reference ${reference.$ref}`
489
+ }), sibling, path);
490
+ }
491
+ }
492
+ const annotations = jsonSchemaAnnotations(schema);
493
+ if (annotations !== undefined && representation._tag === "Reference") {
494
+ annotatedReferences.push({
495
+ reference: representation,
496
+ path
497
+ });
498
+ }
499
+ representation = annotate(representation, annotations);
500
+ if (Array.isArray(schema.allOf)) {
501
+ for (let index = 0; index < schema.allOf.length; index++) {
502
+ representation = combine(representation, recur(schema.allOf[index], [...path, "allOf", index]), [...path, "allOf", index]);
503
+ }
504
+ }
505
+ for (const mode of ["anyOf", "oneOf"]) {
506
+ const members = schema[mode];
507
+ if (Array.isArray(members)) {
508
+ const union = {
509
+ _tag: "Union",
510
+ types: members.map((member, index) => recur(member, [...path, mode, index])),
511
+ mode,
512
+ checks: []
513
+ };
514
+ representation = combine(union, representation, [...path, mode]);
515
+ }
516
+ }
517
+ return representation;
518
+ }
519
+ function on(schema, path) {
520
+ if (typeof schema.$ref === "string") {
521
+ const $ref = jsonSchemaReferenceKey(schema.$ref);
522
+ if ($ref !== undefined) {
523
+ return {
524
+ _tag: "Reference",
525
+ $ref
526
+ };
527
+ }
528
+ }
529
+ if (Object.hasOwn(schema, "const")) {
530
+ if (schema.const === null) {
531
+ return {
532
+ _tag: "Null",
533
+ checks: []
534
+ };
535
+ }
536
+ if (typeof schema.const === "string" || typeof schema.const === "number" || typeof schema.const === "boolean") {
537
+ return makeLiteral(schema.const);
538
+ }
539
+ }
540
+ if (Array.isArray(schema.enum)) {
541
+ const types = [];
542
+ for (let index = 0; index < schema.enum.length; index++) {
543
+ const value = schema.enum[index];
544
+ if (value === null) {
545
+ types.push({
546
+ _tag: "Null",
547
+ checks: []
548
+ });
549
+ } else if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
550
+ types.push(makeLiteral(value));
551
+ } else {
552
+ types.push(recur(value, [...path, "enum", index]));
553
+ }
554
+ }
555
+ if (types.length === 1) {
556
+ return types[0];
557
+ }
558
+ return {
559
+ _tag: "Union",
560
+ types,
561
+ mode: "anyOf",
562
+ checks: []
563
+ };
564
+ }
565
+ if (Array.isArray(schema.type) && schema.type.every(isImportedJsonSchemaType)) {
566
+ return {
567
+ _tag: "Union",
568
+ types: schema.type.map(type => on({
569
+ ...schema,
570
+ type
571
+ }, path)),
572
+ mode: "anyOf",
573
+ checks: []
574
+ };
575
+ }
576
+ const type = isImportedJsonSchemaType(schema.type) ? schema.type : inferJsonSchemaType(schema);
577
+ switch (type) {
578
+ case "null":
579
+ return {
580
+ _tag: "Null",
581
+ checks: []
582
+ };
583
+ case "string":
584
+ return {
585
+ _tag: "String",
586
+ checks: collectStringChecks(schema)
587
+ };
588
+ case "number":
589
+ case "integer":
590
+ return {
591
+ _tag: "Number",
592
+ checks: [jsonSchemaFilter(type === "number" ? "effect/schema/isFinite" : "effect/schema/isInt", null), ...collectNumberChecks(schema)]
593
+ };
594
+ case "boolean":
595
+ return {
596
+ _tag: "Boolean",
597
+ checks: []
598
+ };
599
+ case "array":
600
+ {
601
+ const minItems = typeof schema.minItems === "number" ? schema.minItems : 0;
602
+ const elements = Array.isArray(schema.prefixItems) ? schema.prefixItems.map((element, index) => ({
603
+ isOptional: index + 1 > minItems,
604
+ type: recur(element, [...path, "prefixItems", index])
605
+ })) : [];
606
+ const rest = schema.items !== undefined ? [recur(schema.items, [...path, "items"])] : schema.prefixItems !== undefined && typeof schema.maxItems === "number" ? [] : [unknown];
607
+ return {
608
+ _tag: "Arrays",
609
+ elements,
610
+ rest,
611
+ checks: collectArrayChecks(schema)
612
+ };
613
+ }
614
+ case "object":
615
+ return {
616
+ _tag: "Objects",
617
+ propertySignatures: collectProperties(schema, path),
618
+ indexSignatures: collectIndexSignatures(schema, path),
619
+ checks: collectObjectChecks(schema, path)
620
+ };
621
+ default:
622
+ return unknown;
623
+ }
624
+ }
625
+ function collectStringChecks(schema) {
626
+ const checks = [];
627
+ addNumberCheck(checks, schema.minLength, "effect/schema/isMinLength", "minLength");
628
+ addNumberCheck(checks, schema.maxLength, "effect/schema/isMaxLength", "maxLength");
629
+ if (typeof schema.pattern === "string") {
630
+ checks.push(jsonSchemaFilter("effect/schema/isPattern", {
631
+ source: schema.pattern,
632
+ flags: ""
633
+ }));
634
+ }
635
+ return checks;
636
+ }
637
+ function collectNumberChecks(schema) {
638
+ const checks = [];
639
+ addNumberCheck(checks, schema.minimum, "effect/schema/isGreaterThanOrEqualTo", "minimum");
640
+ addNumberCheck(checks, schema.maximum, "effect/schema/isLessThanOrEqualTo", "maximum");
641
+ addNumberCheck(checks, schema.exclusiveMinimum, "effect/schema/isGreaterThan", "exclusiveMinimum");
642
+ addNumberCheck(checks, schema.exclusiveMaximum, "effect/schema/isLessThan", "exclusiveMaximum");
643
+ addNumberCheck(checks, schema.multipleOf, "effect/schema/isMultipleOf", "divisor");
644
+ return checks;
645
+ }
646
+ function collectArrayChecks(schema) {
647
+ const checks = [];
648
+ if (schema.prefixItems === undefined) {
649
+ addNumberCheck(checks, schema.minItems, "effect/schema/isMinLength", "minLength");
650
+ addNumberCheck(checks, schema.maxItems, "effect/schema/isMaxLength", "maxLength");
651
+ }
652
+ if (typeof schema.uniqueItems === "boolean") {
653
+ checks.push(jsonSchemaFilter("effect/schema/isUnique", null));
654
+ }
655
+ return checks;
656
+ }
657
+ function collectProperties(schema, path) {
658
+ const properties = typeof schema.properties === "object" && schema.properties !== null && !Array.isArray(schema.properties) ? schema.properties : {};
659
+ const required = Array.isArray(schema.required) ? schema.required.filter(key => typeof key === "string") : [];
660
+ const keys = new Set([...Object.keys(properties), ...required]);
661
+ return Array.from(keys, name => ({
662
+ name,
663
+ type: recur(properties[name], [...path, "properties", name]),
664
+ isOptional: !required.includes(name),
665
+ isMutable: false
666
+ }));
667
+ }
668
+ function collectIndexSignatures(schema, path) {
669
+ const signatures = [];
670
+ if (typeof schema.patternProperties === "object" && schema.patternProperties !== null && !Array.isArray(schema.patternProperties)) {
671
+ for (const [pattern, value] of Object.entries(schema.patternProperties)) {
672
+ signatures.push({
673
+ parameter: {
674
+ _tag: "String",
675
+ checks: [jsonSchemaFilter("effect/schema/isPattern", {
676
+ source: pattern,
677
+ flags: ""
678
+ })]
679
+ },
680
+ type: recur(value, [...path, "patternProperties", pattern])
681
+ });
682
+ }
683
+ }
684
+ if (schema.additionalProperties === undefined || schema.additionalProperties === true) {
685
+ signatures.push({
686
+ parameter: string,
687
+ type: unknown
688
+ });
689
+ } else if (typeof schema.additionalProperties === "object" && schema.additionalProperties !== null) {
690
+ signatures.push({
691
+ parameter: string,
692
+ type: recur(schema.additionalProperties, [...path, "additionalProperties"])
693
+ });
694
+ }
695
+ return signatures;
696
+ }
697
+ function collectObjectChecks(schema, path) {
698
+ const checks = [];
699
+ addNumberCheck(checks, schema.minProperties, "effect/schema/isMinProperties", "minProperties");
700
+ addNumberCheck(checks, schema.maxProperties, "effect/schema/isMaxProperties", "maxProperties");
701
+ if (schema.propertyNames !== undefined) {
702
+ checks.push(jsonSchemaFilter("effect/schema/isPropertyNames", null, [recur(schema.propertyNames, [...path, "propertyNames"])]));
703
+ }
704
+ return checks;
705
+ }
706
+ const references = {};
707
+ for (const key of Object.keys(document.definitions)) {
708
+ InternalRecord.assignProperty(references, key, unknownJsonSchemas(translateDefinition(key, ["definitions", key])));
709
+ }
710
+ const representations = document.schemas.map((schema, index) => unknownJsonSchemas(recur(schema, singleRoot ? ["schema"] : ["schemas", index])));
711
+ for (const {
712
+ reference,
713
+ path
714
+ } of annotatedReferences) {
715
+ resolveReference(reference, path);
716
+ }
717
+ return {
718
+ representations,
719
+ references
720
+ };
721
+ }
722
+ /** @internal */
723
+ function toRepresentation(document, options) {
724
+ const translated = translateJsonSchemaMultiDocument({
725
+ dialect: document.dialect,
726
+ schemas: [document.schema],
727
+ definitions: document.definitions
728
+ }, options, true);
729
+ return {
730
+ representation: translated.representations[0],
731
+ references: translated.references
732
+ };
733
+ }
734
+ const jsonSchemaRevivers = [Schema.JsonReviver, Schema.isPatternReviver, Schema.isFiniteReviver, Schema.isGreaterThanReviver, Schema.isGreaterThanOrEqualToReviver, Schema.isLessThanReviver, Schema.isLessThanOrEqualToReviver, Schema.isMultipleOfReviver, Schema.isIntReviver, Schema.isMinLengthReviver, Schema.isMaxLengthReviver, Schema.isMinPropertiesReviver, Schema.isMaxPropertiesReviver, Schema.isPropertyNamesReviver, Schema.isUniqueReviver];
735
+ /** @internal */
736
+ export function fromJsonSchemaDocument(document, options) {
737
+ return fromRepresentation(toRepresentation(document, options), jsonSchemaRevivers);
738
+ }
739
+ /** @internal */
740
+ export function fromJsonSchemaMultiDocument(document, options) {
741
+ return fromRepresentations(translateJsonSchemaMultiDocument(document, options), jsonSchemaRevivers);
742
+ }
743
+ //# sourceMappingURL=fromJsonSchemaDocument.js.map