effect 4.0.2 → 4.0.4

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 (389) hide show
  1. package/AGENTS.md +24 -0
  2. package/CLAUDE.md +24 -0
  3. package/ai-docs/package.json +2 -2
  4. package/ai-docs/src/52_graphql/10_basics.ts +111 -0
  5. package/ai-docs/src/52_graphql/20_testing.ts +45 -0
  6. package/ai-docs/src/52_graphql/30_batching.ts +116 -0
  7. package/ai-docs/src/52_graphql/40_aliased-batching.ts +122 -0
  8. package/ai-docs/src/52_graphql/50_errors-and-retries.ts +74 -0
  9. package/ai-docs/src/52_graphql/index.md +6 -0
  10. package/dist/Context.d.ts.map +1 -1
  11. package/dist/Context.js +12 -3
  12. package/dist/Context.js.map +1 -1
  13. package/dist/Crypto.d.ts +33 -5
  14. package/dist/Crypto.d.ts.map +1 -1
  15. package/dist/Crypto.js +8 -2
  16. package/dist/Crypto.js.map +1 -1
  17. package/dist/DateTime.d.ts +9 -6
  18. package/dist/DateTime.d.ts.map +1 -1
  19. package/dist/DateTime.js +9 -6
  20. package/dist/DateTime.js.map +1 -1
  21. package/dist/Duration.d.ts +6 -6
  22. package/dist/Duration.d.ts.map +1 -1
  23. package/dist/Duration.js +27 -8
  24. package/dist/Duration.js.map +1 -1
  25. package/dist/FileSystem.d.ts +44 -2
  26. package/dist/FileSystem.d.ts.map +1 -1
  27. package/dist/FileSystem.js.map +1 -1
  28. package/dist/RequestResolver.d.ts.map +1 -1
  29. package/dist/RequestResolver.js +4 -10
  30. package/dist/RequestResolver.js.map +1 -1
  31. package/dist/Scheduler.d.ts +9 -0
  32. package/dist/Scheduler.d.ts.map +1 -1
  33. package/dist/Scheduler.js +9 -0
  34. package/dist/Scheduler.js.map +1 -1
  35. package/dist/Schema.d.ts +481 -1
  36. package/dist/Schema.d.ts.map +1 -1
  37. package/dist/Schema.js +362 -4
  38. package/dist/Schema.js.map +1 -1
  39. package/dist/SchemaGetter.d.ts +4 -0
  40. package/dist/SchemaGetter.d.ts.map +1 -1
  41. package/dist/SchemaGetter.js +52 -33
  42. package/dist/SchemaGetter.js.map +1 -1
  43. package/dist/Sink.d.ts.map +1 -1
  44. package/dist/Sink.js +38 -17
  45. package/dist/Sink.js.map +1 -1
  46. package/dist/Stdio.d.ts +7 -1
  47. package/dist/Stdio.d.ts.map +1 -1
  48. package/dist/Stdio.js +1 -0
  49. package/dist/Stdio.js.map +1 -1
  50. package/dist/Stream.d.ts +22 -11
  51. package/dist/Stream.d.ts.map +1 -1
  52. package/dist/Stream.js +21 -6
  53. package/dist/Stream.js.map +1 -1
  54. package/dist/Utils.js +8 -3
  55. package/dist/Utils.js.map +1 -1
  56. package/dist/ai/AnthropicStructuredOutput.js +0 -2
  57. package/dist/ai/AnthropicStructuredOutput.js.map +1 -1
  58. package/dist/ai/Chat.d.ts +2 -2
  59. package/dist/ai/Chat.d.ts.map +1 -1
  60. package/dist/ai/LanguageModel.d.ts +38 -7
  61. package/dist/ai/LanguageModel.d.ts.map +1 -1
  62. package/dist/ai/LanguageModel.js +25 -7
  63. package/dist/ai/LanguageModel.js.map +1 -1
  64. package/dist/ai/McpServer.d.ts +61 -0
  65. package/dist/ai/McpServer.d.ts.map +1 -1
  66. package/dist/ai/McpServer.js +196 -44
  67. package/dist/ai/McpServer.js.map +1 -1
  68. package/dist/ai/Prompt.d.ts.map +1 -1
  69. package/dist/ai/Prompt.js +28 -5
  70. package/dist/ai/Prompt.js.map +1 -1
  71. package/dist/ai/Response.d.ts +4 -3
  72. package/dist/ai/Response.d.ts.map +1 -1
  73. package/dist/ai/Response.js.map +1 -1
  74. package/dist/ai/internal/mcpProtocol/v2026_07_28.js +5 -0
  75. package/dist/ai/internal/mcpProtocol/v2026_07_28.js.map +1 -1
  76. package/dist/ai/internal/mcpProtocol.js.map +1 -1
  77. package/dist/ai/internal/mcpRuntime.js +1 -0
  78. package/dist/ai/internal/mcpRuntime.js.map +1 -1
  79. package/dist/cli/CliOutput.d.ts +27 -0
  80. package/dist/cli/CliOutput.d.ts.map +1 -1
  81. package/dist/cli/CliOutput.js +33 -10
  82. package/dist/cli/CliOutput.js.map +1 -1
  83. package/dist/cli/Command.d.ts.map +1 -1
  84. package/dist/cli/Command.js +6 -3
  85. package/dist/cli/Command.js.map +1 -1
  86. package/dist/cli/Completions.d.ts +3 -3
  87. package/dist/cli/Completions.d.ts.map +1 -1
  88. package/dist/cli/Completions.js +8 -5
  89. package/dist/cli/Completions.js.map +1 -1
  90. package/dist/cli/GlobalFlag.d.ts +5 -4
  91. package/dist/cli/GlobalFlag.d.ts.map +1 -1
  92. package/dist/cli/GlobalFlag.js +3 -3
  93. package/dist/cli/GlobalFlag.js.map +1 -1
  94. package/dist/cli/Prompt.d.ts +17 -1
  95. package/dist/cli/Prompt.d.ts.map +1 -1
  96. package/dist/cli/Prompt.js +119 -114
  97. package/dist/cli/Prompt.js.map +1 -1
  98. package/dist/cli/internal/ansi.d.ts +0 -1
  99. package/dist/cli/internal/ansi.d.ts.map +1 -1
  100. package/dist/cli/internal/ansi.js +20 -3
  101. package/dist/cli/internal/ansi.js.map +1 -1
  102. package/dist/cli/internal/completions/powershell.d.ts +2 -0
  103. package/dist/cli/internal/completions/powershell.d.ts.map +1 -0
  104. package/dist/cli/internal/completions/powershell.js +273 -0
  105. package/dist/cli/internal/completions/powershell.js.map +1 -0
  106. package/dist/cli/internal/completions/zsh.js +3 -2
  107. package/dist/cli/internal/completions/zsh.js.map +1 -1
  108. package/dist/cli/internal/wizard.d.ts +3 -3
  109. package/dist/cli/internal/wizard.d.ts.map +1 -1
  110. package/dist/cli/internal/wizard.js +21 -18
  111. package/dist/cli/internal/wizard.js.map +1 -1
  112. package/dist/cluster/ClusterSchema.d.ts +28 -0
  113. package/dist/cluster/ClusterSchema.d.ts.map +1 -1
  114. package/dist/cluster/ClusterSchema.js +30 -0
  115. package/dist/cluster/ClusterSchema.js.map +1 -1
  116. package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
  117. package/dist/cluster/ClusterWorkflowEngine.js +56 -26
  118. package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
  119. package/dist/cluster/MessageStorage.d.ts +18 -3
  120. package/dist/cluster/MessageStorage.d.ts.map +1 -1
  121. package/dist/cluster/MessageStorage.js +31 -11
  122. package/dist/cluster/MessageStorage.js.map +1 -1
  123. package/dist/cluster/Runners.d.ts.map +1 -1
  124. package/dist/cluster/Runners.js +8 -2
  125. package/dist/cluster/Runners.js.map +1 -1
  126. package/dist/cluster/Sharding.d.ts.map +1 -1
  127. package/dist/cluster/Sharding.js +187 -66
  128. package/dist/cluster/Sharding.js.map +1 -1
  129. package/dist/cluster/SqlMessageStorage.d.ts +59 -19
  130. package/dist/cluster/SqlMessageStorage.d.ts.map +1 -1
  131. package/dist/cluster/SqlMessageStorage.js +84 -55
  132. package/dist/cluster/SqlMessageStorage.js.map +1 -1
  133. package/dist/cluster/SqlRunnerStorage.d.ts +68 -19
  134. package/dist/cluster/SqlRunnerStorage.d.ts.map +1 -1
  135. package/dist/cluster/SqlRunnerStorage.js +191 -113
  136. package/dist/cluster/SqlRunnerStorage.js.map +1 -1
  137. package/dist/cluster/internal/entityManager.js +104 -37
  138. package/dist/cluster/internal/entityManager.js.map +1 -1
  139. package/dist/encoding/Sse.d.ts +6 -0
  140. package/dist/encoding/Sse.d.ts.map +1 -1
  141. package/dist/encoding/Sse.js +62 -70
  142. package/dist/encoding/Sse.js.map +1 -1
  143. package/dist/graphql/GraphQL.d.ts +349 -0
  144. package/dist/graphql/GraphQL.d.ts.map +1 -0
  145. package/dist/graphql/GraphQL.js +207 -0
  146. package/dist/graphql/GraphQL.js.map +1 -0
  147. package/dist/graphql/GraphQLClient.d.ts +562 -0
  148. package/dist/graphql/GraphQLClient.d.ts.map +1 -0
  149. package/dist/graphql/GraphQLClient.js +498 -0
  150. package/dist/graphql/GraphQLClient.js.map +1 -0
  151. package/dist/graphql/GraphQLClientError.d.ts +445 -0
  152. package/dist/graphql/GraphQLClientError.d.ts.map +1 -0
  153. package/dist/graphql/GraphQLClientError.js +479 -0
  154. package/dist/graphql/GraphQLClientError.js.map +1 -0
  155. package/dist/graphql/GraphQLGroup.d.ts +118 -0
  156. package/dist/graphql/GraphQLGroup.d.ts.map +1 -0
  157. package/dist/graphql/GraphQLGroup.js +109 -0
  158. package/dist/graphql/GraphQLGroup.js.map +1 -0
  159. package/dist/graphql/GraphQLMiddleware.d.ts +249 -0
  160. package/dist/graphql/GraphQLMiddleware.d.ts.map +1 -0
  161. package/dist/graphql/GraphQLMiddleware.js +130 -0
  162. package/dist/graphql/GraphQLMiddleware.js.map +1 -0
  163. package/dist/graphql/GraphQLProtocol.d.ts +731 -0
  164. package/dist/graphql/GraphQLProtocol.d.ts.map +1 -0
  165. package/dist/graphql/GraphQLProtocol.js +719 -0
  166. package/dist/graphql/GraphQLProtocol.js.map +1 -0
  167. package/dist/graphql/GraphQLResolver.d.ts +453 -0
  168. package/dist/graphql/GraphQLResolver.d.ts.map +1 -0
  169. package/dist/graphql/GraphQLResolver.js +552 -0
  170. package/dist/graphql/GraphQLResolver.js.map +1 -0
  171. package/dist/graphql/index.d.ts +40 -0
  172. package/dist/graphql/index.d.ts.map +1 -0
  173. package/dist/graphql/index.js +41 -0
  174. package/dist/graphql/index.js.map +1 -0
  175. package/dist/http/FindMyWay/internal/router.js +3 -6
  176. package/dist/http/FindMyWay/internal/router.js.map +1 -1
  177. package/dist/http/HttpClient.d.ts +21 -0
  178. package/dist/http/HttpClient.d.ts.map +1 -1
  179. package/dist/http/HttpClient.js +63 -12
  180. package/dist/http/HttpClient.js.map +1 -1
  181. package/dist/http/HttpEffect.d.ts.map +1 -1
  182. package/dist/http/HttpEffect.js +14 -7
  183. package/dist/http/HttpEffect.js.map +1 -1
  184. package/dist/http/HttpMiddleware.d.ts.map +1 -1
  185. package/dist/http/HttpMiddleware.js +31 -32
  186. package/dist/http/HttpMiddleware.js.map +1 -1
  187. package/dist/http/HttpRouter.d.ts +35 -0
  188. package/dist/http/HttpRouter.d.ts.map +1 -1
  189. package/dist/http/HttpRouter.js +35 -0
  190. package/dist/http/HttpRouter.js.map +1 -1
  191. package/dist/http/HttpServerResponse.d.ts +8 -6
  192. package/dist/http/HttpServerResponse.d.ts.map +1 -1
  193. package/dist/http/HttpServerResponse.js +27 -16
  194. package/dist/http/HttpServerResponse.js.map +1 -1
  195. package/dist/http/HttpTraceContext.d.ts.map +1 -1
  196. package/dist/http/HttpTraceContext.js +4 -2
  197. package/dist/http/HttpTraceContext.js.map +1 -1
  198. package/dist/http/Multipart.d.ts.map +1 -1
  199. package/dist/http/Multipart.js +15 -1
  200. package/dist/http/Multipart.js.map +1 -1
  201. package/dist/http-api/HttpApiScalar.d.ts +5 -0
  202. package/dist/http-api/HttpApiScalar.d.ts.map +1 -1
  203. package/dist/http-api/HttpApiScalar.js.map +1 -1
  204. package/dist/internal/dateTime.js +40 -35
  205. package/dist/internal/dateTime.js.map +1 -1
  206. package/dist/internal/effect.js +19 -9
  207. package/dist/internal/effect.js.map +1 -1
  208. package/dist/internal/graphql.d.ts +2 -0
  209. package/dist/internal/graphql.d.ts.map +1 -0
  210. package/dist/internal/graphql.js +195 -0
  211. package/dist/internal/graphql.js.map +1 -0
  212. package/dist/internal/graphqlHeaders.d.ts +4 -0
  213. package/dist/internal/graphqlHeaders.d.ts.map +1 -0
  214. package/dist/internal/graphqlHeaders.js +11 -0
  215. package/dist/internal/graphqlHeaders.js.map +1 -0
  216. package/dist/internal/request.js +20 -1
  217. package/dist/internal/request.js.map +1 -1
  218. package/dist/internal/schema/toCodeDocument.js +4 -1
  219. package/dist/internal/schema/toCodeDocument.js.map +1 -1
  220. package/dist/internal/schema/toJsonSchemaDocument.js +29 -5
  221. package/dist/internal/schema/toJsonSchemaDocument.js.map +1 -1
  222. package/dist/internal/version.js +1 -1
  223. package/dist/net/AddressResolver.d.ts +145 -0
  224. package/dist/net/AddressResolver.d.ts.map +1 -0
  225. package/dist/net/AddressResolver.js +114 -0
  226. package/dist/net/AddressResolver.js.map +1 -0
  227. package/dist/net/Dns.d.ts +596 -0
  228. package/dist/net/Dns.d.ts.map +1 -0
  229. package/dist/net/Dns.js +549 -0
  230. package/dist/net/Dns.js.map +1 -0
  231. package/dist/net/Host.d.ts +369 -0
  232. package/dist/net/Host.d.ts.map +1 -0
  233. package/dist/net/Host.js +397 -0
  234. package/dist/net/Host.js.map +1 -0
  235. package/dist/net/IpInterface.d.ts +76 -3
  236. package/dist/net/IpInterface.d.ts.map +1 -1
  237. package/dist/net/IpInterface.js +53 -4
  238. package/dist/net/IpInterface.js.map +1 -1
  239. package/dist/net/IpNetwork.d.ts +82 -8
  240. package/dist/net/IpNetwork.d.ts.map +1 -1
  241. package/dist/net/IpNetwork.js +60 -4
  242. package/dist/net/IpNetwork.js.map +1 -1
  243. package/dist/net/NetAddress.d.ts +396 -35
  244. package/dist/net/NetAddress.d.ts.map +1 -1
  245. package/dist/net/NetAddress.js +358 -34
  246. package/dist/net/NetAddress.js.map +1 -1
  247. package/dist/net/index.d.ts +15 -0
  248. package/dist/net/index.d.ts.map +1 -1
  249. package/dist/net/index.js +15 -0
  250. package/dist/net/index.js.map +1 -1
  251. package/dist/observability/OtlpMetrics.d.ts.map +1 -1
  252. package/dist/observability/OtlpMetrics.js +15 -21
  253. package/dist/observability/OtlpMetrics.js.map +1 -1
  254. package/dist/observability/PrometheusMetrics.js +1 -0
  255. package/dist/observability/PrometheusMetrics.js.map +1 -1
  256. package/dist/persistence/PersistedQueue.d.ts +32 -3
  257. package/dist/persistence/PersistedQueue.d.ts.map +1 -1
  258. package/dist/persistence/PersistedQueue.js +75 -16
  259. package/dist/persistence/PersistedQueue.js.map +1 -1
  260. package/dist/rpc/RpcClient.d.ts +22 -6
  261. package/dist/rpc/RpcClient.d.ts.map +1 -1
  262. package/dist/rpc/RpcClient.js +12 -5
  263. package/dist/rpc/RpcClient.js.map +1 -1
  264. package/dist/rpc/RpcServer.d.ts +6 -0
  265. package/dist/rpc/RpcServer.d.ts.map +1 -1
  266. package/dist/rpc/RpcServer.js +78 -29
  267. package/dist/rpc/RpcServer.js.map +1 -1
  268. package/dist/socket/DatagramSocket.d.ts +456 -0
  269. package/dist/socket/DatagramSocket.d.ts.map +1 -0
  270. package/dist/socket/DatagramSocket.js +535 -0
  271. package/dist/socket/DatagramSocket.js.map +1 -0
  272. package/dist/socket/Socket.d.ts +20 -1
  273. package/dist/socket/Socket.d.ts.map +1 -1
  274. package/dist/socket/Socket.js +9 -1
  275. package/dist/socket/Socket.js.map +1 -1
  276. package/dist/socket/index.d.ts +5 -0
  277. package/dist/socket/index.d.ts.map +1 -1
  278. package/dist/socket/index.js +5 -0
  279. package/dist/socket/index.js.map +1 -1
  280. package/dist/sql/Migrator.d.ts.map +1 -1
  281. package/dist/sql/Migrator.js +7 -2
  282. package/dist/sql/Migrator.js.map +1 -1
  283. package/dist/sql/SqlClient.d.ts +7 -1
  284. package/dist/sql/SqlClient.d.ts.map +1 -1
  285. package/dist/sql/SqlClient.js +31 -6
  286. package/dist/sql/SqlClient.js.map +1 -1
  287. package/dist/testing/TestCrypto.d.ts +73 -0
  288. package/dist/testing/TestCrypto.d.ts.map +1 -0
  289. package/dist/testing/TestCrypto.js +87 -0
  290. package/dist/testing/TestCrypto.js.map +1 -0
  291. package/dist/testing/index.d.ts +5 -0
  292. package/dist/testing/index.d.ts.map +1 -1
  293. package/dist/testing/index.js +5 -0
  294. package/dist/testing/index.js.map +1 -1
  295. package/dist/workflow/DurableDeferred.d.ts +54 -0
  296. package/dist/workflow/DurableDeferred.d.ts.map +1 -1
  297. package/dist/workflow/DurableDeferred.js +108 -50
  298. package/dist/workflow/DurableDeferred.js.map +1 -1
  299. package/dist/workflow/WorkflowEngine.d.ts +24 -2
  300. package/dist/workflow/WorkflowEngine.d.ts.map +1 -1
  301. package/dist/workflow/WorkflowEngine.js +13 -3
  302. package/dist/workflow/WorkflowEngine.js.map +1 -1
  303. package/package.json +6 -3
  304. package/src/Context.ts +12 -3
  305. package/src/Crypto.ts +43 -9
  306. package/src/DateTime.ts +9 -6
  307. package/src/Duration.ts +36 -16
  308. package/src/FileSystem.ts +48 -2
  309. package/src/RequestResolver.ts +4 -10
  310. package/src/Scheduler.ts +9 -0
  311. package/src/Schema.ts +677 -5
  312. package/src/SchemaGetter.ts +47 -35
  313. package/src/Sink.ts +45 -18
  314. package/src/Stdio.ts +9 -2
  315. package/src/Stream.ts +44 -15
  316. package/src/Utils.ts +8 -5
  317. package/src/ai/AnthropicStructuredOutput.ts +2 -2
  318. package/src/ai/Chat.ts +2 -2
  319. package/src/ai/LanguageModel.ts +96 -24
  320. package/src/ai/McpServer.ts +288 -94
  321. package/src/ai/Prompt.ts +24 -10
  322. package/src/ai/Response.ts +6 -3
  323. package/src/ai/internal/mcpProtocol/v2026_07_28.ts +5 -0
  324. package/src/ai/internal/mcpProtocol.ts +3 -0
  325. package/src/ai/internal/mcpRuntime.ts +2 -0
  326. package/src/cli/CliOutput.ts +33 -16
  327. package/src/cli/Command.ts +4 -3
  328. package/src/cli/Completions.ts +9 -6
  329. package/src/cli/GlobalFlag.ts +19 -11
  330. package/src/cli/Prompt.ts +159 -149
  331. package/src/cli/internal/ansi.ts +26 -3
  332. package/src/cli/internal/completions/powershell.ts +322 -0
  333. package/src/cli/internal/completions/zsh.ts +4 -2
  334. package/src/cli/internal/wizard.ts +34 -26
  335. package/src/cluster/ClusterSchema.ts +32 -0
  336. package/src/cluster/ClusterWorkflowEngine.ts +64 -36
  337. package/src/cluster/MessageStorage.ts +45 -14
  338. package/src/cluster/Runners.ts +8 -2
  339. package/src/cluster/Sharding.ts +219 -58
  340. package/src/cluster/SqlMessageStorage.ts +118 -84
  341. package/src/cluster/SqlRunnerStorage.ts +224 -128
  342. package/src/cluster/internal/entityManager.ts +151 -55
  343. package/src/encoding/Sse.ts +69 -79
  344. package/src/graphql/GraphQL.ts +494 -0
  345. package/src/graphql/GraphQLClient.ts +912 -0
  346. package/src/graphql/GraphQLClientError.ts +542 -0
  347. package/src/graphql/GraphQLGroup.ts +167 -0
  348. package/src/graphql/GraphQLMiddleware.ts +253 -0
  349. package/src/graphql/GraphQLProtocol.ts +1286 -0
  350. package/src/graphql/GraphQLResolver.ts +1010 -0
  351. package/src/graphql/index.ts +48 -0
  352. package/src/http/FindMyWay/internal/router.ts +4 -7
  353. package/src/http/HttpClient.ts +110 -12
  354. package/src/http/HttpEffect.ts +11 -5
  355. package/src/http/HttpMiddleware.ts +33 -34
  356. package/src/http/HttpRouter.ts +35 -0
  357. package/src/http/HttpServerResponse.ts +28 -16
  358. package/src/http/HttpTraceContext.ts +8 -2
  359. package/src/http/Multipart.ts +17 -1
  360. package/src/http-api/HttpApiScalar.ts +5 -0
  361. package/src/internal/dateTime.ts +13 -10
  362. package/src/internal/effect.ts +22 -15
  363. package/src/internal/graphql.ts +263 -0
  364. package/src/internal/graphqlHeaders.ts +11 -0
  365. package/src/internal/request.ts +31 -3
  366. package/src/internal/schema/toCodeDocument.ts +7 -1
  367. package/src/internal/schema/toJsonSchemaDocument.ts +34 -2
  368. package/src/internal/version.ts +1 -1
  369. package/src/net/AddressResolver.ts +222 -0
  370. package/src/net/Dns.ts +1035 -0
  371. package/src/net/Host.ts +544 -0
  372. package/src/net/IpInterface.ts +117 -7
  373. package/src/net/IpNetwork.ts +116 -17
  374. package/src/net/NetAddress.ts +620 -76
  375. package/src/net/index.ts +18 -0
  376. package/src/observability/OtlpMetrics.ts +12 -23
  377. package/src/observability/PrometheusMetrics.ts +1 -0
  378. package/src/persistence/PersistedQueue.ts +146 -53
  379. package/src/rpc/RpcClient.ts +41 -19
  380. package/src/rpc/RpcServer.ts +115 -40
  381. package/src/socket/DatagramSocket.ts +919 -0
  382. package/src/socket/Socket.ts +28 -2
  383. package/src/socket/index.ts +6 -0
  384. package/src/sql/Migrator.ts +21 -5
  385. package/src/sql/SqlClient.ts +39 -15
  386. package/src/testing/TestCrypto.ts +94 -0
  387. package/src/testing/index.ts +6 -0
  388. package/src/workflow/DurableDeferred.ts +160 -47
  389. package/src/workflow/WorkflowEngine.ts +50 -5
package/dist/Schema.js CHANGED
@@ -31,6 +31,7 @@ import * as HashSet_ from "./HashSet.js";
31
31
  import * as Cookies_ from "./http/Cookies.js";
32
32
  import * as Headers_ from "./http/Headers.js";
33
33
  import * as UrlParams_ from "./http/UrlParams.js";
34
+ import { NodeInspectSymbol } from "./Inspectable.js";
34
35
  import * as core from "./internal/core.js";
35
36
  import { effectIsExit } from "./internal/effect.js";
36
37
  import * as InternalGraph from "./internal/graph.js";
@@ -48,6 +49,8 @@ import * as InternalToJsonSchemaDocument from "./internal/schema/toJsonSchemaDoc
48
49
  import * as InternalToRepresentation from "./internal/schema/toRepresentation.js";
49
50
  import { isSchemaError as isSchemaErrorInternal, SchemaErrorTypeId } from "./internal/schemaError.js";
50
51
  import { getStackTraceLimit, setStackTraceLimit } from "./internal/stackTraceLimit.js";
52
+ import * as Dns_ from "./net/Dns.js";
53
+ import * as Host_ from "./net/Host.js";
51
54
  import * as IpInterface_ from "./net/IpInterface.js";
52
55
  import * as IpNetwork_ from "./net/IpNetwork.js";
53
56
  import * as NetAddress_ from "./net/NetAddress.js";
@@ -376,6 +379,15 @@ export class SchemaError extends /*#__PURE__*/Data.TaggedError("SchemaError") {
376
379
  get message() {
377
380
  return SchemaIssue.defaultFormatter(this.issue);
378
381
  }
382
+ toJSON() {
383
+ return {
384
+ _tag: this._tag,
385
+ message: this.message
386
+ };
387
+ }
388
+ [NodeInspectSymbol]() {
389
+ return this.toJSON();
390
+ }
379
391
  toString() {
380
392
  return `SchemaError(${this.message})`;
381
393
  }
@@ -2147,6 +2159,13 @@ export function Record(key, value) {
2147
2159
  *
2148
2160
  * **Gotchas**
2149
2161
  *
2162
+ * The base schema must have an object-shaped encoded type. Whole-object
2163
+ * transformations are not supported, even with an empty rest array. Apply
2164
+ * transformations such as `Schema.fromJsonString` to the completed
2165
+ * `StructWithRest` schema instead. Object-shaped encoded types alone do not
2166
+ * guarantee compatibility: unsupported encodings are still rejected at runtime.
2167
+ * Transformations on individual fields remain supported.
2168
+ *
2150
2169
  * TypeScript index signatures also apply to fixed keys. `StructWithRest` does
2151
2170
  * not reject incompatible fixed fields at the call site; use
2152
2171
  * `StructWithRest.ValidateRecords` when you want an explicit type-level
@@ -4528,7 +4547,8 @@ export function isMultipleOf(divisor, annotations) {
4528
4547
  *
4529
4548
  * JSON Schema:
4530
4549
  *
4531
- * This check corresponds to the `type: "integer"` constraint in JSON Schema.
4550
+ * This check corresponds to `type: "integer"` with `minimum: Number.MIN_SAFE_INTEGER`
4551
+ * and `maximum: Number.MAX_SAFE_INTEGER` in JSON Schema.
4532
4552
  *
4533
4553
  * Arbitrary:
4534
4554
  *
@@ -4545,9 +4565,11 @@ export function isInt(annotations) {
4545
4565
  id: "effect/schema/isInt",
4546
4566
  payload: null
4547
4567
  },
4548
- toJsonSchema: () => [{
4549
- type: "integer"
4550
- }, true],
4568
+ toJsonSchema: () => ({
4569
+ type: "integer",
4570
+ minimum: globalThis.Number.MIN_SAFE_INTEGER,
4571
+ maximum: globalThis.Number.MAX_SAFE_INTEGER
4572
+ }),
4551
4573
  toCode: () => ({
4552
4574
  runtime: "Schema.isInt()"
4553
4575
  }),
@@ -8160,6 +8182,113 @@ export const UnixPathAddressFromString = /*#__PURE__*/String.pipe(decodeTo(UnixP
8160
8182
  export const SocketAddress = /*#__PURE__*/declare(NetAddress_.isSocketAddress, {
8161
8183
  identifier: "SocketAddress"
8162
8184
  });
8185
+ /**
8186
+ * Schema for normalized DNS domain names.
8187
+ *
8188
+ * **Details**
8189
+ *
8190
+ * Only names already in normalized form (lowercase ASCII, with
8191
+ * internationalized labels in `xn--` form) are accepted. Use
8192
+ * {@link DomainNameFromString} to normalize arbitrary input.
8193
+ *
8194
+ * @stability experimental
8195
+ * @category schemas
8196
+ * @since 4.0.0
8197
+ */
8198
+ export const DomainName = /*#__PURE__*/String.check(makeFilter(Host_.isDomainName, {
8199
+ expected: "a normalized domain name"
8200
+ })).pipe(brand("~effect/net/Host/DomainName")).annotate({
8201
+ identifier: "DomainName"
8202
+ });
8203
+ /**
8204
+ * Schema for DNS domain names decoded from strings, normalizing case and
8205
+ * converting internationalized names to their ASCII form.
8206
+ *
8207
+ * @stability experimental
8208
+ * @category schemas
8209
+ * @since 4.0.0
8210
+ */
8211
+ export const DomainNameFromString = /*#__PURE__*/netAddressFromString(DomainName, Host_.domainNameFromString, name => name, "DomainNameFromString");
8212
+ /**
8213
+ * Schema for canonical scoped IPv6 literals such as `fe80::1%eth0`.
8214
+ *
8215
+ * @stability experimental
8216
+ * @category schemas
8217
+ * @since 4.0.0
8218
+ */
8219
+ export const ScopedIpv6Literal = /*#__PURE__*/String.check(makeFilter(NetAddress_.isScopedIpv6Literal, {
8220
+ expected: "a canonical scoped IPv6 literal"
8221
+ })).pipe(brand("~effect/net/NetAddress/ScopedIpv6Literal")).annotate({
8222
+ identifier: "ScopedIpv6Literal"
8223
+ });
8224
+ /**
8225
+ * Schema for scoped IPv6 literals decoded from strings, normalizing the address
8226
+ * and numeric zones.
8227
+ *
8228
+ * @stability experimental
8229
+ * @category schemas
8230
+ * @since 4.0.0
8231
+ */
8232
+ export const ScopedIpv6LiteralFromString = /*#__PURE__*/netAddressFromString(ScopedIpv6Literal, NetAddress_.scopedIpv6LiteralFromString, literal => literal, "ScopedIpv6LiteralFromString");
8233
+ /**
8234
+ * Schema for hosts: numeric IP addresses, scoped IPv6 literals, or domain names.
8235
+ *
8236
+ * @stability experimental
8237
+ * @category schemas
8238
+ * @since 4.0.0
8239
+ */
8240
+ export const Host = /*#__PURE__*/Union([IpAddress, ScopedIpv6Literal, DomainName]).annotate({
8241
+ identifier: "Host"
8242
+ });
8243
+ /**
8244
+ * Schema for hosts decoded from strings. Numeric IP strings decode to IP
8245
+ * addresses; other strings decode to scoped IPv6 literals or domain names.
8246
+ *
8247
+ * @stability experimental
8248
+ * @category schemas
8249
+ * @since 4.0.0
8250
+ */
8251
+ export const HostFromString = /*#__PURE__*/Union([IpAddressFromString, ScopedIpv6LiteralFromString, DomainNameFromString]).annotate({
8252
+ identifier: "HostFromString"
8253
+ });
8254
+ /**
8255
+ * Schema for already-constructed unresolved host and port values.
8256
+ *
8257
+ * @stability experimental
8258
+ * @category schemas
8259
+ * @since 4.0.0
8260
+ */
8261
+ export const HostPort = /*#__PURE__*/declare(Host_.isHostPort, {
8262
+ identifier: "HostPort"
8263
+ });
8264
+ /**
8265
+ * Schema for unresolved endpoints encoded as `host:port` or `[IPv6]:port`
8266
+ * strings.
8267
+ *
8268
+ * @stability experimental
8269
+ * @category schemas
8270
+ * @since 4.0.0
8271
+ */
8272
+ export const HostPortFromString = /*#__PURE__*/netAddressFromString(HostPort, Host_.hostPortFromString, Host_.formatHostPort, "HostPortFromString");
8273
+ /**
8274
+ * Schema for TCP and UDP port numbers from 0 through 65535.
8275
+ *
8276
+ * **Details**
8277
+ *
8278
+ * Port 0 is accepted because it asks the operating system to choose a port
8279
+ * when binding, and it matches the port range of `InetAddress` and `HostPort`.
8280
+ * `Config.Port` accepts only 1 through 65535.
8281
+ *
8282
+ * @stability experimental
8283
+ * @category schemas
8284
+ * @since 4.0.0
8285
+ */
8286
+ export const Port = /*#__PURE__*/Int.check(/*#__PURE__*/isBetween({
8287
+ minimum: 0,
8288
+ maximum: 65535
8289
+ }, {
8290
+ expected: "a port number"
8291
+ }));
8163
8292
  // -----------------------------------------------------------------------------
8164
8293
  // Duration schemas
8165
8294
  // -----------------------------------------------------------------------------
@@ -8324,6 +8453,235 @@ export const DurationFromNanos = /*#__PURE__*/BigInt.pipe(/*#__PURE__*/decodeTo(
8324
8453
  * @since 3.10.0
8325
8454
  */
8326
8455
  export const DurationFromMillis = /*#__PURE__*/Number.pipe(/*#__PURE__*/decodeTo(Duration, durationFromMillis));
8456
+ /**
8457
+ * Schema for supported DNS record types such as `"A"` or `"SRV"`.
8458
+ *
8459
+ * @stability experimental
8460
+ * @category schemas
8461
+ * @since 4.0.0
8462
+ */
8463
+ export const DnsRecordType = /*#__PURE__*/Literals(Dns_.recordTypes);
8464
+ // Addresses in JSON records must already be canonical; normalizing input is
8465
+ // left to the `*FromString` schemas.
8466
+ const dnsCanonicalAddress = (schema, parse) => String.pipe(decodeTo(schema, SchemaTransformation.transformEffect({
8467
+ decode: (input, options) => {
8468
+ const result = parse(input);
8469
+ if (Result_.isFailure(result)) {
8470
+ return Effect.fail(new SchemaIssue.InvalidValue({
8471
+ message: result.failure.message
8472
+ }, input, options));
8473
+ }
8474
+ return NetAddress_.formatIp(result.success) === input ? Effect.succeed(result.success) : Effect.fail(new SchemaIssue.InvalidValue({
8475
+ message: "expected a canonical address"
8476
+ }, input, options));
8477
+ },
8478
+ encode: address => Effect.succeed(NetAddress_.formatIp(address))
8479
+ })));
8480
+ const dnsUint8 = /*#__PURE__*/Int.check(/*#__PURE__*/isBetween({
8481
+ minimum: 0,
8482
+ maximum: 0xff
8483
+ }));
8484
+ const dnsUint16 = /*#__PURE__*/Int.check(/*#__PURE__*/isBetween({
8485
+ minimum: 0,
8486
+ maximum: 0xffff
8487
+ }));
8488
+ const dnsUint32 = /*#__PURE__*/Int.check(/*#__PURE__*/isBetween({
8489
+ minimum: 0,
8490
+ maximum: 0xffffffff
8491
+ }));
8492
+ // SOA timers are written as whole seconds, as in zone files.
8493
+ const dnsSeconds = /*#__PURE__*/dnsUint32.pipe(/*#__PURE__*/decodeTo(Duration, /*#__PURE__*/SchemaTransformation.transform({
8494
+ decode: Duration_.seconds,
8495
+ encode: Duration_.toSeconds
8496
+ })));
8497
+ // Each record type is an opaque value whose JSON form is a plain object tagged
8498
+ // by record type, such as `{ "_tag": "MX", "exchange": "mail.example.com", "priority": 10 }`.
8499
+ const dnsRecordOfType = (type, fields) => declare(u => Dns_.isDnsRecord(u) && u._tag === type, {
8500
+ identifier: `Dns${type.charAt(0)}${type.slice(1).toLowerCase()}Record`,
8501
+ toCodecJson: () => {
8502
+ const json = TaggedStruct(type, fields);
8503
+ return link()(json, SchemaTransformation.transformEffect({
8504
+ decode: (input, options) => {
8505
+ const {
8506
+ _tag,
8507
+ ...rest
8508
+ } = input;
8509
+ const result = Dns_.makeRecord(type, rest);
8510
+ return Result_.isSuccess(result) ? Effect.succeed(result.success) : Effect.fail(new SchemaIssue.InvalidValue({
8511
+ message: result.failure.message
8512
+ }, input, options));
8513
+ },
8514
+ // Records hold only their tag and fields as own properties.
8515
+ encode: record => Effect.succeed({
8516
+ ...record
8517
+ })
8518
+ }));
8519
+ }
8520
+ });
8521
+ /**
8522
+ * Schema for already-constructed IPv4 address (`A`) DNS records.
8523
+ *
8524
+ * @stability experimental
8525
+ * @category schemas
8526
+ * @since 4.0.0
8527
+ */
8528
+ export const DnsARecord = /*#__PURE__*/dnsRecordOfType("A", {
8529
+ address: /*#__PURE__*/dnsCanonicalAddress(Ipv4Address, NetAddress_.ipv4FromString)
8530
+ });
8531
+ /**
8532
+ * Schema for already-constructed IPv6 address (`AAAA`) DNS records.
8533
+ *
8534
+ * @stability experimental
8535
+ * @category schemas
8536
+ * @since 4.0.0
8537
+ */
8538
+ export const DnsAaaaRecord = /*#__PURE__*/dnsRecordOfType("AAAA", {
8539
+ address: /*#__PURE__*/dnsCanonicalAddress(Ipv6Address, NetAddress_.ipv6FromString)
8540
+ });
8541
+ /**
8542
+ * Schema for already-constructed certification authority authorization (`CAA`) DNS records.
8543
+ *
8544
+ * @stability experimental
8545
+ * @category schemas
8546
+ * @since 4.0.0
8547
+ */
8548
+ export const DnsCaaRecord = /*#__PURE__*/dnsRecordOfType("CAA", {
8549
+ critical: Boolean,
8550
+ tag: /*#__PURE__*/String.check(/*#__PURE__*/isPattern(/^[a-z0-9]+$/i)),
8551
+ value: String
8552
+ });
8553
+ /**
8554
+ * Schema for already-constructed canonical name (`CNAME`) DNS records.
8555
+ *
8556
+ * @stability experimental
8557
+ * @category schemas
8558
+ * @since 4.0.0
8559
+ */
8560
+ export const DnsCnameRecord = /*#__PURE__*/dnsRecordOfType("CNAME", {
8561
+ target: DomainName
8562
+ });
8563
+ /**
8564
+ * Schema for already-constructed mail exchange (`MX`) DNS records.
8565
+ *
8566
+ * @stability experimental
8567
+ * @category schemas
8568
+ * @since 4.0.0
8569
+ */
8570
+ export const DnsMxRecord = /*#__PURE__*/dnsRecordOfType("MX", {
8571
+ exchange: DomainName,
8572
+ priority: dnsUint16
8573
+ });
8574
+ /**
8575
+ * Schema for already-constructed naming authority pointer (`NAPTR`) DNS records.
8576
+ *
8577
+ * @stability experimental
8578
+ * @category schemas
8579
+ * @since 4.0.0
8580
+ */
8581
+ export const DnsNaptrRecord = /*#__PURE__*/dnsRecordOfType("NAPTR", {
8582
+ order: dnsUint16,
8583
+ preference: dnsUint16,
8584
+ flags: String,
8585
+ service: String,
8586
+ regexp: String,
8587
+ replacement: DomainName
8588
+ });
8589
+ /**
8590
+ * Schema for already-constructed name server (`NS`) DNS records.
8591
+ *
8592
+ * @stability experimental
8593
+ * @category schemas
8594
+ * @since 4.0.0
8595
+ */
8596
+ export const DnsNsRecord = /*#__PURE__*/dnsRecordOfType("NS", {
8597
+ host: DomainName
8598
+ });
8599
+ /**
8600
+ * Schema for already-constructed pointer (`PTR`) DNS records.
8601
+ *
8602
+ * @stability experimental
8603
+ * @category schemas
8604
+ * @since 4.0.0
8605
+ */
8606
+ export const DnsPtrRecord = /*#__PURE__*/dnsRecordOfType("PTR", {
8607
+ host: NonEmptyString
8608
+ });
8609
+ /**
8610
+ * Schema for already-constructed start of authority (`SOA`) DNS records.
8611
+ *
8612
+ * @stability experimental
8613
+ * @category schemas
8614
+ * @since 4.0.0
8615
+ */
8616
+ export const DnsSoaRecord = /*#__PURE__*/dnsRecordOfType("SOA", {
8617
+ primary: DomainName,
8618
+ admin: NonEmptyString,
8619
+ serial: dnsUint32,
8620
+ refresh: dnsSeconds,
8621
+ retry: dnsSeconds,
8622
+ expire: dnsSeconds,
8623
+ minimum: dnsSeconds
8624
+ });
8625
+ /**
8626
+ * Schema for already-constructed service locator (`SRV`) DNS records.
8627
+ *
8628
+ * @stability experimental
8629
+ * @category schemas
8630
+ * @since 4.0.0
8631
+ */
8632
+ export const DnsSrvRecord = /*#__PURE__*/dnsRecordOfType("SRV", {
8633
+ target: DomainName,
8634
+ port: dnsUint16,
8635
+ priority: dnsUint16,
8636
+ weight: dnsUint16
8637
+ });
8638
+ /**
8639
+ * Schema for already-constructed TLS authentication (`TLSA`) DNS records.
8640
+ *
8641
+ * **Details**
8642
+ *
8643
+ * The default JSON serializer encodes the certificate association `data` as a
8644
+ * hex string.
8645
+ *
8646
+ * @stability experimental
8647
+ * @category schemas
8648
+ * @since 4.0.0
8649
+ */
8650
+ export const DnsTlsaRecord = /*#__PURE__*/dnsRecordOfType("TLSA", {
8651
+ certUsage: dnsUint8,
8652
+ selector: dnsUint8,
8653
+ matchingType: dnsUint8,
8654
+ data: Uint8ArrayFromHex
8655
+ });
8656
+ /**
8657
+ * Schema for already-constructed text (`TXT`) DNS records.
8658
+ *
8659
+ * @stability experimental
8660
+ * @category schemas
8661
+ * @since 4.0.0
8662
+ */
8663
+ export const DnsTxtRecord = /*#__PURE__*/dnsRecordOfType("TXT", {
8664
+ chunks: /*#__PURE__*/NonEmptyArray(String)
8665
+ });
8666
+ /**
8667
+ * Schema for already-constructed DNS records of any supported record type.
8668
+ *
8669
+ * **Details**
8670
+ *
8671
+ * The default JSON serializer encodes records as objects tagged by record type,
8672
+ * with addresses and names as canonical strings, SOA timers as whole seconds,
8673
+ * and TLSA data as hex, such as
8674
+ * `{ "_tag": "SRV", "target": "db.internal", "port": 5432, "priority": 10, "weight": 5 }`.
8675
+ * Decoding accepts only canonical addresses and normalized domain names, and
8676
+ * reports invalid fields with their path.
8677
+ *
8678
+ * @stability experimental
8679
+ * @category schemas
8680
+ * @since 4.0.0
8681
+ */
8682
+ export const DnsRecord = /*#__PURE__*/Union([DnsARecord, DnsAaaaRecord, DnsCaaRecord, DnsCnameRecord, DnsMxRecord, DnsNaptrRecord, DnsNsRecord, DnsPtrRecord, DnsSoaRecord, DnsSrvRecord, DnsTlsaRecord, DnsTxtRecord]).annotate({
8683
+ identifier: "DnsRecord"
8684
+ });
8327
8685
  /**
8328
8686
  * Creates a schema for `Exit` values using schemas for the success value, typed
8329
8687
  * failure, and unexpected defect channels.