effect 4.1.5 → 4.1.7

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 (441) hide show
  1. package/ai-docs/package.json +2 -2
  2. package/dist/Channel.d.ts +104 -7
  3. package/dist/Channel.d.ts.map +1 -1
  4. package/dist/Channel.js +73 -4
  5. package/dist/Channel.js.map +1 -1
  6. package/dist/Codegen.d.ts +7 -2
  7. package/dist/Codegen.d.ts.map +1 -1
  8. package/dist/Codegen.js +7 -2
  9. package/dist/Codegen.js.map +1 -1
  10. package/dist/Config.d.ts +1 -1
  11. package/dist/Config.d.ts.map +1 -1
  12. package/dist/Config.js +5 -3
  13. package/dist/Config.js.map +1 -1
  14. package/dist/Context.d.ts.map +1 -1
  15. package/dist/Context.js +79 -31
  16. package/dist/Context.js.map +1 -1
  17. package/dist/Cron.d.ts.map +1 -1
  18. package/dist/Cron.js +10 -9
  19. package/dist/Cron.js.map +1 -1
  20. package/dist/Effect.d.ts +139 -18
  21. package/dist/Effect.d.ts.map +1 -1
  22. package/dist/Effect.js +10 -2
  23. package/dist/Effect.js.map +1 -1
  24. package/dist/Equal.d.ts +4 -4
  25. package/dist/Equal.d.ts.map +1 -1
  26. package/dist/Equal.js +78 -66
  27. package/dist/Equal.js.map +1 -1
  28. package/dist/Formatter.js +4 -4
  29. package/dist/Formatter.js.map +1 -1
  30. package/dist/Hash.d.ts.map +1 -1
  31. package/dist/Hash.js +34 -41
  32. package/dist/Hash.js.map +1 -1
  33. package/dist/LayerRef.d.ts +1 -1
  34. package/dist/LayerRef.d.ts.map +1 -1
  35. package/dist/LayerRef.js +3 -3
  36. package/dist/LayerRef.js.map +1 -1
  37. package/dist/Logger.d.ts +37 -13
  38. package/dist/Logger.d.ts.map +1 -1
  39. package/dist/Logger.js +39 -10
  40. package/dist/Logger.js.map +1 -1
  41. package/dist/Match.d.ts +23 -23
  42. package/dist/Match.d.ts.map +1 -1
  43. package/dist/Match.js.map +1 -1
  44. package/dist/Metric.d.ts.map +1 -1
  45. package/dist/Metric.js +3 -4
  46. package/dist/Metric.js.map +1 -1
  47. package/dist/Order.js +1 -1
  48. package/dist/Order.js.map +1 -1
  49. package/dist/Pool.d.ts.map +1 -1
  50. package/dist/Pool.js +49 -21
  51. package/dist/Pool.js.map +1 -1
  52. package/dist/Predicate.d.ts.map +1 -1
  53. package/dist/Predicate.js +2 -1
  54. package/dist/Predicate.js.map +1 -1
  55. package/dist/Scheduler.d.ts.map +1 -1
  56. package/dist/Scheduler.js +15 -9
  57. package/dist/Scheduler.js.map +1 -1
  58. package/dist/Schema.d.ts +41 -0
  59. package/dist/Schema.d.ts.map +1 -1
  60. package/dist/Schema.js +51 -390
  61. package/dist/Schema.js.map +1 -1
  62. package/dist/SchemaAST.d.ts +2 -2
  63. package/dist/SchemaAST.d.ts.map +1 -1
  64. package/dist/SchemaAST.js +199 -98
  65. package/dist/SchemaAST.js.map +1 -1
  66. package/dist/SchemaParser.d.ts.map +1 -1
  67. package/dist/SchemaParser.js +29 -50
  68. package/dist/SchemaParser.js.map +1 -1
  69. package/dist/ScopedCache.d.ts.map +1 -1
  70. package/dist/ScopedCache.js +6 -4
  71. package/dist/ScopedCache.js.map +1 -1
  72. package/dist/Stream.d.ts +128 -5
  73. package/dist/Stream.d.ts.map +1 -1
  74. package/dist/Stream.js +124 -29
  75. package/dist/Stream.js.map +1 -1
  76. package/dist/String.js +1 -1
  77. package/dist/String.js.map +1 -1
  78. package/dist/Tracer.d.ts +10 -0
  79. package/dist/Tracer.d.ts.map +1 -1
  80. package/dist/Tracer.js +3 -4
  81. package/dist/Tracer.js.map +1 -1
  82. package/dist/ai/McpClient.d.ts +68 -4
  83. package/dist/ai/McpClient.d.ts.map +1 -1
  84. package/dist/ai/McpClient.js +100 -17
  85. package/dist/ai/McpClient.js.map +1 -1
  86. package/dist/ai/McpClientError.d.ts +46 -4
  87. package/dist/ai/McpClientError.d.ts.map +1 -1
  88. package/dist/ai/McpClientError.js +38 -3
  89. package/dist/ai/McpClientError.js.map +1 -1
  90. package/dist/ai/McpServer.d.ts +158 -7
  91. package/dist/ai/McpServer.d.ts.map +1 -1
  92. package/dist/ai/McpServer.js +103 -49
  93. package/dist/ai/McpServer.js.map +1 -1
  94. package/dist/ai/Prompt.d.ts +3 -1
  95. package/dist/ai/Prompt.d.ts.map +1 -1
  96. package/dist/ai/Prompt.js +17 -3
  97. package/dist/ai/Prompt.js.map +1 -1
  98. package/dist/ai/Skill.d.ts +172 -0
  99. package/dist/ai/Skill.d.ts.map +1 -0
  100. package/dist/ai/Skill.js +209 -0
  101. package/dist/ai/Skill.js.map +1 -0
  102. package/dist/ai/index.d.ts +5 -0
  103. package/dist/ai/index.d.ts.map +1 -1
  104. package/dist/ai/index.js +5 -0
  105. package/dist/ai/index.js.map +1 -1
  106. package/dist/ai/internal/mcpProtocol/v2024_11_05.js +9 -7
  107. package/dist/ai/internal/mcpProtocol/v2024_11_05.js.map +1 -1
  108. package/dist/ai/internal/mcpProtocol/v2025_03_26.js +12 -11
  109. package/dist/ai/internal/mcpProtocol/v2025_03_26.js.map +1 -1
  110. package/dist/ai/internal/mcpProtocol/v2025_06_18.js +18 -17
  111. package/dist/ai/internal/mcpProtocol/v2025_06_18.js.map +1 -1
  112. package/dist/ai/internal/mcpProtocol/v2025_11_25.js +19 -18
  113. package/dist/ai/internal/mcpProtocol/v2025_11_25.js.map +1 -1
  114. package/dist/ai/internal/mcpProtocol/v2026_07_28.js +1 -1
  115. package/dist/ai/internal/mcpProtocol/v2026_07_28.js.map +1 -1
  116. package/dist/ai/internal/mcpProtocol.js +11 -0
  117. package/dist/ai/internal/mcpProtocol.js.map +1 -1
  118. package/dist/ai/internal/mcpRuntime.js +29 -17
  119. package/dist/ai/internal/mcpRuntime.js.map +1 -1
  120. package/dist/ai/internal/mcpSchema/v2024_11_05.js +2 -1
  121. package/dist/ai/internal/mcpSchema/v2024_11_05.js.map +1 -1
  122. package/dist/ai/internal/mcpSchema/v2025_03_26.js +1 -8
  123. package/dist/ai/internal/mcpSchema/v2025_03_26.js.map +1 -1
  124. package/dist/ai/internal/mcpSchema/v2025_06_18.js +5 -9
  125. package/dist/ai/internal/mcpSchema/v2025_06_18.js.map +1 -1
  126. package/dist/ai/internal/mcpSchema/v2025_11_25.js +1 -8
  127. package/dist/ai/internal/mcpSchema/v2025_11_25.js.map +1 -1
  128. package/dist/ai/internal/mcpSchema/v2026_07_28.js +4 -3
  129. package/dist/ai/internal/mcpSchema/v2026_07_28.js.map +1 -1
  130. package/dist/cluster/ClusterCron.d.ts +5 -20
  131. package/dist/cluster/ClusterCron.d.ts.map +1 -1
  132. package/dist/cluster/ClusterCron.js +16 -4
  133. package/dist/cluster/ClusterCron.js.map +1 -1
  134. package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
  135. package/dist/cluster/ClusterWorkflowEngine.js +155 -83
  136. package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
  137. package/dist/cluster/MessageStorage.d.ts +56 -0
  138. package/dist/cluster/MessageStorage.d.ts.map +1 -1
  139. package/dist/cluster/MessageStorage.js +18 -2
  140. package/dist/cluster/MessageStorage.js.map +1 -1
  141. package/dist/cluster/SqlMessageStorage.d.ts.map +1 -1
  142. package/dist/cluster/SqlMessageStorage.js +48 -23
  143. package/dist/cluster/SqlMessageStorage.js.map +1 -1
  144. package/dist/cluster/internal/entityActivation.js +2 -0
  145. package/dist/cluster/internal/entityActivation.js.map +1 -1
  146. package/dist/cluster/internal/entityManager.js +8 -5
  147. package/dist/cluster/internal/entityManager.js.map +1 -1
  148. package/dist/encoding/Base64.js +5 -1
  149. package/dist/encoding/Base64.js.map +1 -1
  150. package/dist/encoding/Base64Url.d.ts.map +1 -1
  151. package/dist/encoding/Base64Url.js +6 -1
  152. package/dist/encoding/Base64Url.js.map +1 -1
  153. package/dist/encoding/Hex.js +7 -5
  154. package/dist/encoding/Hex.js.map +1 -1
  155. package/dist/encoding/Xml.d.ts +38 -9
  156. package/dist/encoding/Xml.d.ts.map +1 -1
  157. package/dist/encoding/Xml.js +63 -31
  158. package/dist/encoding/Xml.js.map +1 -1
  159. package/dist/http/FetchHttpClient.d.ts +2 -1
  160. package/dist/http/FetchHttpClient.d.ts.map +1 -1
  161. package/dist/http/FetchHttpClient.js +14 -10
  162. package/dist/http/FetchHttpClient.js.map +1 -1
  163. package/dist/http/Headers.d.ts +201 -3
  164. package/dist/http/Headers.d.ts.map +1 -1
  165. package/dist/http/Headers.js +205 -3
  166. package/dist/http/Headers.js.map +1 -1
  167. package/dist/http/HttpClient.d.ts.map +1 -1
  168. package/dist/http/HttpClient.js +11 -7
  169. package/dist/http/HttpClient.js.map +1 -1
  170. package/dist/http/HttpClientError.d.ts +1 -0
  171. package/dist/http/HttpClientError.d.ts.map +1 -1
  172. package/dist/http/HttpClientError.js +32 -9
  173. package/dist/http/HttpClientError.js.map +1 -1
  174. package/dist/http/HttpClientRequest.d.ts +46 -0
  175. package/dist/http/HttpClientRequest.d.ts.map +1 -1
  176. package/dist/http/HttpClientRequest.js +15 -0
  177. package/dist/http/HttpClientRequest.js.map +1 -1
  178. package/dist/http/HttpClientResponse.d.ts +132 -0
  179. package/dist/http/HttpClientResponse.d.ts.map +1 -1
  180. package/dist/http/HttpClientResponse.js +83 -0
  181. package/dist/http/HttpClientResponse.js.map +1 -1
  182. package/dist/http/HttpEffect.d.ts.map +1 -1
  183. package/dist/http/HttpEffect.js +31 -2
  184. package/dist/http/HttpEffect.js.map +1 -1
  185. package/dist/http/HttpMiddleware.js +1 -1
  186. package/dist/http/HttpMiddleware.js.map +1 -1
  187. package/dist/http/HttpServerError.d.ts +1 -1
  188. package/dist/http/HttpServerError.js +1 -1
  189. package/dist/http/HttpServerResponse.d.ts +118 -0
  190. package/dist/http/HttpServerResponse.d.ts.map +1 -1
  191. package/dist/http/HttpServerResponse.js +43 -0
  192. package/dist/http/HttpServerResponse.js.map +1 -1
  193. package/dist/http/Multipart.d.ts.map +1 -1
  194. package/dist/http/Multipart.js +0 -5
  195. package/dist/http/Multipart.js.map +1 -1
  196. package/dist/http/MultipartParser/internal/contentType.d.ts +6 -0
  197. package/dist/http/MultipartParser/internal/contentType.d.ts.map +1 -1
  198. package/dist/http/MultipartParser/internal/contentType.js +1 -1
  199. package/dist/http/MultipartParser/internal/contentType.js.map +1 -1
  200. package/dist/http/internal/clientPath.d.ts +2 -0
  201. package/dist/http/internal/clientPath.d.ts.map +1 -0
  202. package/dist/http/internal/clientPath.js +24 -0
  203. package/dist/http/internal/clientPath.js.map +1 -0
  204. package/dist/http/internal/redactedPath.js +2 -0
  205. package/dist/http/internal/redactedPath.js.map +1 -1
  206. package/dist/http/internal/tracing.js +5 -3
  207. package/dist/http/internal/tracing.js.map +1 -1
  208. package/dist/http-api/HttpApi.d.ts +2 -2
  209. package/dist/http-api/HttpApi.d.ts.map +1 -1
  210. package/dist/http-api/HttpApi.js +30 -7
  211. package/dist/http-api/HttpApi.js.map +1 -1
  212. package/dist/http-api/HttpApiBuilder.d.ts.map +1 -1
  213. package/dist/http-api/HttpApiBuilder.js +5 -2
  214. package/dist/http-api/HttpApiBuilder.js.map +1 -1
  215. package/dist/http-api/HttpApiClient.d.ts.map +1 -1
  216. package/dist/http-api/HttpApiClient.js +23 -6
  217. package/dist/http-api/HttpApiClient.js.map +1 -1
  218. package/dist/http-api/internal/redactedKeys.d.ts +2 -0
  219. package/dist/http-api/internal/redactedKeys.d.ts.map +1 -0
  220. package/dist/http-api/internal/redactedKeys.js +37 -0
  221. package/dist/http-api/internal/redactedKeys.js.map +1 -0
  222. package/dist/internal/base64.js +34 -2
  223. package/dist/internal/base64.js.map +1 -1
  224. package/dist/internal/core.js +60 -43
  225. package/dist/internal/core.js.map +1 -1
  226. package/dist/internal/dateTime.js +35 -17
  227. package/dist/internal/dateTime.js.map +1 -1
  228. package/dist/internal/effect.js +60 -52
  229. package/dist/internal/effect.js.map +1 -1
  230. package/dist/internal/equal.js +44 -13
  231. package/dist/internal/equal.js.map +1 -1
  232. package/dist/internal/fiberCachedKeys.d.ts +2 -0
  233. package/dist/internal/fiberCachedKeys.d.ts.map +1 -0
  234. package/dist/internal/fiberCachedKeys.js +48 -0
  235. package/dist/internal/fiberCachedKeys.js.map +1 -0
  236. package/dist/internal/hashMap.js +1 -1
  237. package/dist/internal/hashMap.js.map +1 -1
  238. package/dist/internal/matcher.js +17 -17
  239. package/dist/internal/matcher.js.map +1 -1
  240. package/dist/internal/predicate.d.ts +2 -0
  241. package/dist/internal/predicate.d.ts.map +1 -0
  242. package/dist/internal/predicate.js +10 -0
  243. package/dist/internal/predicate.js.map +1 -0
  244. package/dist/internal/references.js +8 -11
  245. package/dist/internal/references.js.map +1 -1
  246. package/dist/internal/schema/schemaCodegen.js +3 -2
  247. package/dist/internal/schema/schemaCodegen.js.map +1 -1
  248. package/dist/internal/schema/schemaCodegenBuiltIns.d.ts +2 -0
  249. package/dist/internal/schema/schemaCodegenBuiltIns.d.ts.map +1 -0
  250. package/dist/internal/schema/schemaCodegenBuiltIns.js +425 -0
  251. package/dist/internal/schema/schemaCodegenBuiltIns.js.map +1 -0
  252. package/dist/internal/schema/toEquivalence.js +3 -4
  253. package/dist/internal/schema/toEquivalence.js.map +1 -1
  254. package/dist/internal/version.js +1 -1
  255. package/dist/jose/JoseError.d.ts +51 -1
  256. package/dist/jose/JoseError.d.ts.map +1 -1
  257. package/dist/jose/JoseError.js +25 -18
  258. package/dist/jose/JoseError.js.map +1 -1
  259. package/dist/jose/internal/compact.js +10 -5
  260. package/dist/jose/internal/compact.js.map +1 -1
  261. package/dist/observability/Otlp.d.ts +19 -0
  262. package/dist/observability/Otlp.d.ts.map +1 -1
  263. package/dist/observability/Otlp.js +10 -0
  264. package/dist/observability/Otlp.js.map +1 -1
  265. package/dist/observability/OtlpExporter.d.ts +49 -13
  266. package/dist/observability/OtlpExporter.d.ts.map +1 -1
  267. package/dist/observability/OtlpExporter.js +135 -54
  268. package/dist/observability/OtlpExporter.js.map +1 -1
  269. package/dist/observability/OtlpLogger.d.ts +14 -0
  270. package/dist/observability/OtlpLogger.d.ts.map +1 -1
  271. package/dist/observability/OtlpLogger.js +10 -2
  272. package/dist/observability/OtlpLogger.js.map +1 -1
  273. package/dist/observability/OtlpMetrics.d.ts.map +1 -1
  274. package/dist/observability/OtlpMetrics.js +2 -0
  275. package/dist/observability/OtlpMetrics.js.map +1 -1
  276. package/dist/observability/OtlpTracer.d.ts +14 -0
  277. package/dist/observability/OtlpTracer.d.ts.map +1 -1
  278. package/dist/observability/OtlpTracer.js +10 -2
  279. package/dist/observability/OtlpTracer.js.map +1 -1
  280. package/dist/persistence/KeyValueStore.d.ts.map +1 -1
  281. package/dist/persistence/KeyValueStore.js +6 -4
  282. package/dist/persistence/KeyValueStore.js.map +1 -1
  283. package/dist/reactivity/Atom.d.ts.map +1 -1
  284. package/dist/reactivity/Atom.js +10 -9
  285. package/dist/reactivity/Atom.js.map +1 -1
  286. package/dist/rpc/RpcClient.d.ts.map +1 -1
  287. package/dist/rpc/RpcClient.js +32 -1
  288. package/dist/rpc/RpcClient.js.map +1 -1
  289. package/dist/rpc/RpcGroup.d.ts +1 -1
  290. package/dist/rpc/RpcGroup.d.ts.map +1 -1
  291. package/dist/rpc/RpcGroup.js +4 -0
  292. package/dist/rpc/RpcGroup.js.map +1 -1
  293. package/dist/sql/Migrator.d.ts.map +1 -1
  294. package/dist/sql/Migrator.js +2 -5
  295. package/dist/sql/Migrator.js.map +1 -1
  296. package/dist/sql/SqlClient.d.ts.map +1 -1
  297. package/dist/sql/SqlClient.js +5 -1
  298. package/dist/sql/SqlClient.js.map +1 -1
  299. package/dist/sql/Statement.d.ts +23 -0
  300. package/dist/sql/Statement.d.ts.map +1 -1
  301. package/dist/sql/Statement.js +30 -5
  302. package/dist/sql/Statement.js.map +1 -1
  303. package/dist/workers/Worker.d.ts +21 -0
  304. package/dist/workers/Worker.d.ts.map +1 -1
  305. package/dist/workers/Worker.js +23 -0
  306. package/dist/workers/Worker.js.map +1 -1
  307. package/dist/workflow/Activity.d.ts +18 -0
  308. package/dist/workflow/Activity.d.ts.map +1 -1
  309. package/dist/workflow/Activity.js +13 -4
  310. package/dist/workflow/Activity.js.map +1 -1
  311. package/dist/workflow/Workflow.d.ts +10 -9
  312. package/dist/workflow/Workflow.d.ts.map +1 -1
  313. package/dist/workflow/Workflow.js +33 -22
  314. package/dist/workflow/Workflow.js.map +1 -1
  315. package/dist/workflow/WorkflowEngine.d.ts.map +1 -1
  316. package/dist/workflow/WorkflowEngine.js +26 -12
  317. package/dist/workflow/WorkflowEngine.js.map +1 -1
  318. package/dist/workflow/internal/retry.d.ts +2 -0
  319. package/dist/workflow/internal/retry.d.ts.map +1 -0
  320. package/dist/workflow/internal/retry.js +11 -0
  321. package/dist/workflow/internal/retry.js.map +1 -0
  322. package/dist/workflow/internal/scope.d.ts +2 -0
  323. package/dist/workflow/internal/scope.d.ts.map +1 -0
  324. package/dist/workflow/internal/scope.js +26 -0
  325. package/dist/workflow/internal/scope.js.map +1 -0
  326. package/package.json +3 -3
  327. package/src/Channel.ts +105 -8
  328. package/src/Codegen.ts +7 -2
  329. package/src/Config.ts +6 -3
  330. package/src/Context.ts +108 -50
  331. package/src/Cron.ts +11 -10
  332. package/src/Effect.ts +224 -48
  333. package/src/Equal.ts +93 -80
  334. package/src/Formatter.ts +4 -4
  335. package/src/Hash.ts +49 -48
  336. package/src/LayerRef.ts +6 -4
  337. package/src/Logger.ts +68 -25
  338. package/src/Match.ts +78 -50
  339. package/src/Metric.ts +4 -4
  340. package/src/Order.ts +1 -1
  341. package/src/Pool.ts +62 -33
  342. package/src/Predicate.ts +2 -5
  343. package/src/Scheduler.ts +27 -10
  344. package/src/Schema.ts +79 -296
  345. package/src/SchemaAST.ts +231 -157
  346. package/src/SchemaParser.ts +40 -57
  347. package/src/ScopedCache.ts +6 -4
  348. package/src/Stream.ts +167 -33
  349. package/src/String.ts +1 -1
  350. package/src/Tracer.ts +11 -2
  351. package/src/ai/McpClient.ts +157 -15
  352. package/src/ai/McpClientError.ts +55 -4
  353. package/src/ai/McpServer.ts +318 -91
  354. package/src/ai/Prompt.ts +20 -3
  355. package/src/ai/Skill.ts +236 -0
  356. package/src/ai/index.ts +6 -0
  357. package/src/ai/internal/mcpProtocol/v2024_11_05.ts +8 -13
  358. package/src/ai/internal/mcpProtocol/v2025_03_26.ts +13 -15
  359. package/src/ai/internal/mcpProtocol/v2025_06_18.ts +21 -23
  360. package/src/ai/internal/mcpProtocol/v2025_11_25.ts +22 -24
  361. package/src/ai/internal/mcpProtocol/v2026_07_28.ts +1 -1
  362. package/src/ai/internal/mcpProtocol.ts +15 -0
  363. package/src/ai/internal/mcpRuntime.ts +36 -13
  364. package/src/ai/internal/mcpSchema/v2024_11_05.ts +2 -1
  365. package/src/ai/internal/mcpSchema/v2025_03_26.ts +1 -9
  366. package/src/ai/internal/mcpSchema/v2025_06_18.ts +3 -10
  367. package/src/ai/internal/mcpSchema/v2025_11_25.ts +1 -9
  368. package/src/ai/internal/mcpSchema/v2026_07_28.ts +6 -8
  369. package/src/cluster/ClusterCron.ts +31 -20
  370. package/src/cluster/ClusterWorkflowEngine.ts +172 -96
  371. package/src/cluster/MessageStorage.ts +51 -2
  372. package/src/cluster/SqlMessageStorage.ts +88 -36
  373. package/src/cluster/internal/entityActivation.ts +6 -0
  374. package/src/cluster/internal/entityManager.ts +8 -4
  375. package/src/encoding/Base64.ts +5 -1
  376. package/src/encoding/Base64Url.ts +6 -1
  377. package/src/encoding/Hex.ts +5 -5
  378. package/src/encoding/Xml.ts +96 -26
  379. package/src/http/FetchHttpClient.ts +8 -5
  380. package/src/http/Headers.ts +309 -3
  381. package/src/http/HttpClient.ts +19 -7
  382. package/src/http/HttpClientError.ts +42 -9
  383. package/src/http/HttpClientRequest.ts +51 -0
  384. package/src/http/HttpClientResponse.ts +156 -0
  385. package/src/http/HttpEffect.ts +23 -3
  386. package/src/http/HttpMiddleware.ts +1 -1
  387. package/src/http/HttpServerError.ts +1 -1
  388. package/src/http/HttpServerResponse.ts +126 -0
  389. package/src/http/Multipart.ts +0 -5
  390. package/src/http/MultipartParser/internal/contentType.ts +1 -1
  391. package/src/http/internal/clientPath.ts +39 -0
  392. package/src/http/internal/redactedPath.ts +4 -0
  393. package/src/http/internal/tracing.ts +6 -3
  394. package/src/http-api/HttpApi.ts +29 -8
  395. package/src/http-api/HttpApiBuilder.ts +7 -2
  396. package/src/http-api/HttpApiClient.ts +30 -7
  397. package/src/http-api/internal/redactedKeys.ts +40 -0
  398. package/src/internal/base64.ts +57 -2
  399. package/src/internal/core.ts +80 -44
  400. package/src/internal/dateTime.ts +43 -24
  401. package/src/internal/effect.ts +115 -157
  402. package/src/internal/equal.ts +73 -17
  403. package/src/internal/fiberCachedKeys.ts +81 -0
  404. package/src/internal/hashMap.ts +1 -1
  405. package/src/internal/matcher.ts +34 -113
  406. package/src/internal/predicate.ts +10 -0
  407. package/src/internal/references.ts +21 -14
  408. package/src/internal/schema/schemaCodegen.ts +5 -4
  409. package/src/internal/schema/schemaCodegenBuiltIns.ts +343 -0
  410. package/src/internal/schema/toEquivalence.ts +3 -5
  411. package/src/internal/version.ts +1 -1
  412. package/src/jose/JoseError.ts +34 -0
  413. package/src/jose/internal/compact.ts +14 -5
  414. package/src/observability/Otlp.ts +29 -0
  415. package/src/observability/OtlpExporter.ts +206 -75
  416. package/src/observability/OtlpLogger.ts +24 -2
  417. package/src/observability/OtlpMetrics.ts +2 -0
  418. package/src/observability/OtlpTracer.ts +24 -3
  419. package/src/persistence/KeyValueStore.ts +17 -14
  420. package/src/reactivity/Atom.ts +12 -18
  421. package/src/rpc/RpcClient.ts +26 -1
  422. package/src/rpc/RpcGroup.ts +4 -1
  423. package/src/sql/Migrator.ts +2 -11
  424. package/src/sql/SqlClient.ts +14 -8
  425. package/src/sql/Statement.ts +48 -12
  426. package/src/workers/Worker.ts +25 -0
  427. package/src/workflow/Activity.ts +28 -4
  428. package/src/workflow/Workflow.ts +68 -44
  429. package/src/workflow/WorkflowEngine.ts +38 -15
  430. package/src/workflow/internal/retry.ts +12 -0
  431. package/src/workflow/internal/scope.ts +36 -0
  432. package/dist/internal/hash.d.ts +0 -2
  433. package/dist/internal/hash.d.ts.map +0 -1
  434. package/dist/internal/hash.js +0 -11
  435. package/dist/internal/hash.js.map +0 -1
  436. package/dist/internal/metric.d.ts +0 -2
  437. package/dist/internal/metric.d.ts.map +0 -1
  438. package/dist/internal/metric.js +0 -3
  439. package/dist/internal/metric.js.map +0 -1
  440. package/src/internal/hash.ts +0 -11
  441. package/src/internal/metric.ts +0 -2
@@ -346,6 +346,162 @@ export const filterStatusOk = (self: HttpClientResponse): Effect.Effect<HttpClie
346
346
  })
347
347
  )
348
348
 
349
+ /**
350
+ * Returns the links of the response's `Link` header with absolute targets.
351
+ *
352
+ * **Details**
353
+ *
354
+ * Each target is resolved against the response URL, which is the final URL
355
+ * after redirects, so `target` holds an absolute href. Links whose target does
356
+ * not resolve are dropped. A response without a `Link` header gives `[]`.
357
+ *
358
+ * **Gotchas**
359
+ *
360
+ * Links with an `anchor` parameter are dropped, because they describe a
361
+ * resource other than this response (RFC 8288 section 3.2). Parse the raw header
362
+ * with `Headers.parseLink` to read them.
363
+ *
364
+ * @see {@link link} to look up a single link by relation type
365
+ *
366
+ * @stability unstable
367
+ * @category accessors
368
+ * @since 4.1.6
369
+ */
370
+ export const links = (self: HttpClientResponse): Array<Headers.Link> => {
371
+ const header = self.headers.link
372
+ if (header === undefined) return []
373
+ const base = self.url || undefined
374
+ const out: Array<Headers.Link> = []
375
+ for (const link of Headers.parseLink(header)) {
376
+ if (Object.hasOwn(link.params, "anchor")) continue
377
+ const url = resolveUrl(link.target, base)
378
+ if (url !== undefined) out.push({ ...link, target: url.href })
379
+ }
380
+ return out
381
+ }
382
+
383
+ const resolveUrl = (target: string, base: string | undefined): URL | undefined => {
384
+ try {
385
+ return new URL(target, base)
386
+ } catch {
387
+ return undefined
388
+ }
389
+ }
390
+
391
+ /**
392
+ * Returns the URL of the first link in the response's `Link` header with the
393
+ * given relation type.
394
+ *
395
+ * **When to use**
396
+ *
397
+ * Use to follow pagination links such as `next` with `Stream.paginate`.
398
+ *
399
+ * **Details**
400
+ *
401
+ * The relation type is compared case-insensitively, and the URL is resolved
402
+ * against the response URL. Returns `Option.none()` when no link matches.
403
+ * Links are read as by {@link links}, so links with an `anchor` parameter
404
+ * never match.
405
+ *
406
+ * **Example** (Reading the next page link)
407
+ *
408
+ * ```ts import.meta.vitest
409
+ * import { Option } from "effect"
410
+ * import { HttpClientRequest, HttpClientResponse } from "effect/http"
411
+ *
412
+ * const response = HttpClientResponse.fromWeb(
413
+ * HttpClientRequest.get("https://example.com/items"),
414
+ * new Response(null, { headers: { link: '</items?page=2>; rel="next"' } })
415
+ * )
416
+ *
417
+ * Option.map(HttpClientResponse.link(response, "next"), (url) => url.href) // => Option.some("https://example.com/items?page=2")
418
+ * ```
419
+ *
420
+ * @see {@link links} to read every link
421
+ *
422
+ * @stability unstable
423
+ * @category accessors
424
+ * @since 4.1.6
425
+ */
426
+ export const link: {
427
+ /**
428
+ * Returns the URL of the first link in the response's `Link` header with the
429
+ * given relation type.
430
+ *
431
+ * **When to use**
432
+ *
433
+ * Use to follow pagination links such as `next` with `Stream.paginate`.
434
+ *
435
+ * **Details**
436
+ *
437
+ * The relation type is compared case-insensitively, and the URL is resolved
438
+ * against the response URL. Returns `Option.none()` when no link matches.
439
+ * Links are read as by {@link links}, so links with an `anchor` parameter
440
+ * never match.
441
+ *
442
+ * **Example** (Reading the next page link)
443
+ *
444
+ * ```ts import.meta.vitest
445
+ * import { Option } from "effect"
446
+ * import { HttpClientRequest, HttpClientResponse } from "effect/http"
447
+ *
448
+ * const response = HttpClientResponse.fromWeb(
449
+ * HttpClientRequest.get("https://example.com/items"),
450
+ * new Response(null, { headers: { link: '</items?page=2>; rel="next"' } })
451
+ * )
452
+ *
453
+ * Option.map(HttpClientResponse.link(response, "next"), (url) => url.href) // => Option.some("https://example.com/items?page=2")
454
+ * ```
455
+ *
456
+ * @see {@link links} to read every link
457
+ *
458
+ * @stability unstable
459
+ * @category accessors
460
+ * @since 4.1.6
461
+ */
462
+ (rel: string): (self: HttpClientResponse) => Option.Option<URL>
463
+ /**
464
+ * Returns the URL of the first link in the response's `Link` header with the
465
+ * given relation type.
466
+ *
467
+ * **When to use**
468
+ *
469
+ * Use to follow pagination links such as `next` with `Stream.paginate`.
470
+ *
471
+ * **Details**
472
+ *
473
+ * The relation type is compared case-insensitively, and the URL is resolved
474
+ * against the response URL. Returns `Option.none()` when no link matches.
475
+ * Links are read as by {@link links}, so links with an `anchor` parameter
476
+ * never match.
477
+ *
478
+ * **Example** (Reading the next page link)
479
+ *
480
+ * ```ts import.meta.vitest
481
+ * import { Option } from "effect"
482
+ * import { HttpClientRequest, HttpClientResponse } from "effect/http"
483
+ *
484
+ * const response = HttpClientResponse.fromWeb(
485
+ * HttpClientRequest.get("https://example.com/items"),
486
+ * new Response(null, { headers: { link: '</items?page=2>; rel="next"' } })
487
+ * )
488
+ *
489
+ * Option.map(HttpClientResponse.link(response, "next"), (url) => url.href) // => Option.some("https://example.com/items?page=2")
490
+ * ```
491
+ *
492
+ * @see {@link links} to read every link
493
+ *
494
+ * @stability unstable
495
+ * @category accessors
496
+ * @since 4.1.6
497
+ */
498
+ (self: HttpClientResponse, rel: string): Option.Option<URL>
499
+ } = dual(2, (self: HttpClientResponse, rel: string): Option.Option<URL> => {
500
+ const type = rel.toLowerCase()
501
+ const found = links(self).find((link) => link.rel.includes(type))
502
+ return found === undefined ? Option.none() : Option.some(new URL(found.target))
503
+ })
504
+
349
505
  // -----------------------------------------------------------------------------
350
506
  // internal
351
507
  // -----------------------------------------------------------------------------
@@ -9,7 +9,7 @@
9
9
  * @stability unstable
10
10
  * @since 4.0.0
11
11
  */
12
- import type * as Cause from "../Cause.ts"
12
+ import * as Cause from "../Cause.ts"
13
13
  import * as Context from "../Context.ts"
14
14
  import * as Effect from "../Effect.ts"
15
15
  import * as Exit from "../Exit.ts"
@@ -17,6 +17,7 @@ import * as Fiber from "../Fiber.ts"
17
17
  import { constVoid, dual } from "../Function.ts"
18
18
  import { contA, contE } from "../internal/core.ts"
19
19
  import { effectIsExit, fiberEnterUninterruptibleUnsafe, reportCauseUnsafe } from "../internal/effect.ts"
20
+ import { isSchemaError } from "../internal/schemaError.ts"
20
21
  import * as Layer from "../Layer.ts"
21
22
  import * as Scope from "../Scope.ts"
22
23
  import * as Stream from "../Stream.ts"
@@ -26,6 +27,7 @@ import { type HttpMiddleware, isTracerDisabledUnsafe, tracer } from "./HttpMiddl
26
27
  import { causeResponse, ClientAbort, HttpServerError, InternalError } from "./HttpServerError.ts"
27
28
  import { HttpServerRequest } from "./HttpServerRequest.ts"
28
29
  import * as Request from "./HttpServerRequest.ts"
30
+ import { isRespondable } from "./HttpServerRespondable.ts"
29
31
  import type { HttpServerResponse } from "./HttpServerResponse.ts"
30
32
  import * as Response from "./HttpServerResponse.ts"
31
33
  import * as requestState from "./internal/requestState.ts"
@@ -63,7 +65,7 @@ export const toHandled = <E, R, EH, RH>(
63
65
  const request = frame.request
64
66
  return Effect.flatMapEager(causeResponse(cause), ([response, cause]) => {
65
67
  const fiber = Fiber.getCurrent()!
66
- reportCauseUnsafe(fiber, cause)
68
+ reportServerCauseUnsafe(fiber, cause)
67
69
  const handler = frame.preResponseHandler
68
70
  const cont = cause.reasons.length === 0 ? Effect.succeed(response) : Effect.failCause(cause)
69
71
  if (handler === undefined) {
@@ -122,7 +124,7 @@ export const toHandled = <E, R, EH, RH>(
122
124
  responded :
123
125
  Effect.matchCauseEffect(tracer(middleware(responded)), {
124
126
  onFailure(cause): Effect.Effect<void, EH, RH> {
125
- reportCauseUnsafe(Fiber.getCurrent()!, cause)
127
+ reportServerCauseUnsafe(Fiber.getCurrent()!, cause)
126
128
  if (handledSymbol in request) return Effect.void
127
129
  return Effect.matchCauseEffectEager(causeResponse(cause), {
128
130
  onFailure(_) {
@@ -227,6 +229,24 @@ export const toHandled = <E, R, EH, RH>(
227
229
 
228
230
  const handledSymbol = Symbol.for("effect/http/HttpEffect/handled")
229
231
 
232
+ // Client errors that `HttpServerRespondable.toResponseOrElse` answers with 400
233
+ // or 404. They are not reported.
234
+ const isClientError = (u: unknown) => !isRespondable(u) && (isSchemaError(u) || Cause.isNoSuchElementError(u))
235
+
236
+ // Both reporting paths can see the same cause. Reusing its filtered cause lets
237
+ // reporters skip the second report.
238
+ const reportableCauses = new WeakMap<Cause.Cause<unknown>, Cause.Cause<unknown>>()
239
+
240
+ const reportServerCauseUnsafe = (fiber: Fiber.Fiber<unknown, unknown>, cause: Cause.Cause<unknown>) => {
241
+ let reportable = reportableCauses.get(cause)
242
+ if (reportable === undefined) {
243
+ const reasons = cause.reasons.filter((reason) => reason._tag !== "Fail" || !isClientError(reason.error))
244
+ reportable = reasons.length === cause.reasons.length ? cause : Cause.fromReasons(reasons)
245
+ reportableCauses.set(cause, reportable)
246
+ }
247
+ reportCauseUnsafe(fiber, reportable)
248
+ }
249
+
230
250
  /**
231
251
  * Disables automatic closing for an HTTP request scope.
232
252
  *
@@ -608,7 +608,7 @@ export const cors = (options?: {
608
608
  ? { "access-control-expose-headers": opts.exposedHeaders.join(",") }
609
609
  : undefined
610
610
 
611
- const maxAge = opts.maxAge
611
+ const maxAge = opts.maxAge === 0 || opts.maxAge
612
612
  ? { "access-control-max-age": opts.maxAge.toString() }
613
613
  : undefined
614
614
 
@@ -289,7 +289,7 @@ const formatRequestMessage = (reason: string, description: string | undefined, i
289
289
 
290
290
  /**
291
291
  * Converts a failed handler cause into the HTTP response that should be sent and
292
- * the cause that should be reported.
292
+ * the cause to propagate.
293
293
  *
294
294
  * **Details**
295
295
  *
@@ -597,6 +597,132 @@ export const setHeader: {
597
597
  makeResponse(self, Headers.set(self.headers, key, value))
598
598
  )
599
599
 
600
+ /**
601
+ * Returns a response with the value added to the specified header, keeping any
602
+ * existing value.
603
+ *
604
+ * **When to use**
605
+ *
606
+ * Use when several parts of an application each add to a list-valued header,
607
+ * such as `Link` or `Vary`.
608
+ *
609
+ * **Details**
610
+ *
611
+ * An existing value is joined with the new one by `", "`, and an empty value
612
+ * leaves the response unchanged, so formatting an empty list of links is safe.
613
+ *
614
+ * **Gotchas**
615
+ *
616
+ * Do not append `Set-Cookie` this way; use the cookie APIs instead.
617
+ *
618
+ * **Example** (Adding canonical and alternate links)
619
+ *
620
+ * ```ts
621
+ * import { Headers, HttpServerResponse } from "effect/http"
622
+ *
623
+ * const withLinks = HttpServerResponse.appendHeader(
624
+ * "Link",
625
+ * Headers.formatLink([
626
+ * { target: "https://example.com/en", rel: ["canonical"] },
627
+ * { target: "https://example.com/de", rel: ["alternate"], params: { hreflang: "de" } }
628
+ * ])
629
+ * )
630
+ * ```
631
+ *
632
+ * @see {@link setHeader} to replace a header value
633
+ *
634
+ * @stability unstable
635
+ * @category combinators
636
+ * @since 4.1.6
637
+ */
638
+ export const appendHeader: {
639
+ /**
640
+ * Returns a response with the value added to the specified header, keeping any
641
+ * existing value.
642
+ *
643
+ * **When to use**
644
+ *
645
+ * Use when several parts of an application each add to a list-valued header,
646
+ * such as `Link` or `Vary`.
647
+ *
648
+ * **Details**
649
+ *
650
+ * An existing value is joined with the new one by `", "`, and an empty value
651
+ * leaves the response unchanged, so formatting an empty list of links is safe.
652
+ *
653
+ * **Gotchas**
654
+ *
655
+ * Do not append `Set-Cookie` this way; use the cookie APIs instead.
656
+ *
657
+ * **Example** (Adding canonical and alternate links)
658
+ *
659
+ * ```ts
660
+ * import { Headers, HttpServerResponse } from "effect/http"
661
+ *
662
+ * const withLinks = HttpServerResponse.appendHeader(
663
+ * "Link",
664
+ * Headers.formatLink([
665
+ * { target: "https://example.com/en", rel: ["canonical"] },
666
+ * { target: "https://example.com/de", rel: ["alternate"], params: { hreflang: "de" } }
667
+ * ])
668
+ * )
669
+ * ```
670
+ *
671
+ * @see {@link setHeader} to replace a header value
672
+ *
673
+ * @stability unstable
674
+ * @category combinators
675
+ * @since 4.1.6
676
+ */
677
+ (key: string, value: string): (self: HttpServerResponse) => HttpServerResponse
678
+ /**
679
+ * Returns a response with the value added to the specified header, keeping any
680
+ * existing value.
681
+ *
682
+ * **When to use**
683
+ *
684
+ * Use when several parts of an application each add to a list-valued header,
685
+ * such as `Link` or `Vary`.
686
+ *
687
+ * **Details**
688
+ *
689
+ * An existing value is joined with the new one by `", "`, and an empty value
690
+ * leaves the response unchanged, so formatting an empty list of links is safe.
691
+ *
692
+ * **Gotchas**
693
+ *
694
+ * Do not append `Set-Cookie` this way; use the cookie APIs instead.
695
+ *
696
+ * **Example** (Adding canonical and alternate links)
697
+ *
698
+ * ```ts
699
+ * import { Headers, HttpServerResponse } from "effect/http"
700
+ *
701
+ * const withLinks = HttpServerResponse.appendHeader(
702
+ * "Link",
703
+ * Headers.formatLink([
704
+ * { target: "https://example.com/en", rel: ["canonical"] },
705
+ * { target: "https://example.com/de", rel: ["alternate"], params: { hreflang: "de" } }
706
+ * ])
707
+ * )
708
+ * ```
709
+ *
710
+ * @see {@link setHeader} to replace a header value
711
+ *
712
+ * @stability unstable
713
+ * @category combinators
714
+ * @since 4.1.6
715
+ */
716
+ (self: HttpServerResponse, key: string, value: string): HttpServerResponse
717
+ } = dual(
718
+ 3,
719
+ (self: HttpServerResponse, key: string, value: string): HttpServerResponse => {
720
+ const headers = Headers.append(self.headers, key, value)
721
+ // makeResponse mutates the headers map in place, so never pass self.headers
722
+ return headers === self.headers ? self : makeResponse(self, headers)
723
+ }
724
+ )
725
+
600
726
  /**
601
727
  * Returns a response with the specified header removed.
602
728
  *
@@ -350,11 +350,6 @@ export const PersistedFileSchema: PersistedFileSchema = Schema.declare(
350
350
  id: "effect/http/PersistedFile",
351
351
  payload: null
352
352
  },
353
- toCode: () => ({
354
- runtime: "Multipart.PersistedFileSchema",
355
- Type: "Multipart.PersistedFile",
356
- importDeclarations: [`import * as Multipart from "effect/http/Multipart"`]
357
- }),
358
353
  expected: "PersistedFile",
359
354
  toCodecJson: () =>
360
355
  Schema.link<PersistedFile>()(
@@ -116,7 +116,7 @@ const pctEncodedRE = /%([0-9a-f]{2})/gi
116
116
  * ISO-8859-1 is decoded byte by byte because `TextDecoder` treats it as
117
117
  * windows-1252.
118
118
  */
119
- function decodeExtValue(value: string): string | undefined {
119
+ export function decodeExtValue(value: string): string | undefined {
120
120
  const match = extValueRE.exec(value)
121
121
  if (match === null) {
122
122
  return undefined
@@ -0,0 +1,39 @@
1
+ import * as Context from "../../Context.ts"
2
+ import * as Redactable from "../../Redactable.ts"
3
+ import { stripSearchAndHash } from "./urlParams.ts"
4
+
5
+ /**
6
+ * The path of the request a client executes, as sent and as recorded in spans
7
+ * and errors.
8
+ *
9
+ * @internal
10
+ */
11
+ export interface ClientPath {
12
+ readonly sent: string
13
+ readonly redacted: string
14
+ }
15
+
16
+ /** @internal */
17
+ export const CurrentClientPath = Context.Reference<ClientPath | undefined>(
18
+ "effect/http/internal/clientPath/CurrentClientPath",
19
+ { defaultValue: () => undefined }
20
+ )
21
+
22
+ /** @internal */
23
+ export const currentClientPath = (): ClientPath | undefined =>
24
+ Context.get((globalThis as any)[Redactable.currentFiberTypeId]?.context ?? Context.empty(), CurrentClientPath)
25
+
26
+ /**
27
+ * Replaces the path of a URL with its redacted form. A pathname that does not
28
+ * match the expected sent pathname is replaced by `/REDACTED`.
29
+ *
30
+ * @internal
31
+ */
32
+ export const redactClientPath = (url: string, path: ClientPath): string => {
33
+ const head = stripSearchAndHash(url)
34
+ const origin = /^[a-z][a-z\d+.-]*:\/\/[^/]*/i.exec(head)?.[0] ?? ""
35
+ const pathname = head.slice(origin.length)
36
+ if (pathname === path.redacted) return url
37
+ const tail = url.slice(head.length)
38
+ return origin + (pathname === path.sent ? path.redacted : "/REDACTED") + tail
39
+ }
@@ -60,6 +60,10 @@ export const compile = (path: string, redactedParams: ReadonlyArray<string>): Te
60
60
  return ambiguous ? parts.map((part) => typeof part === "string" ? part : { name: part.name, redacted: true }) : parts
61
61
  }
62
62
 
63
+ /** @internal */
64
+ export const allParamNames = (path: string): ReadonlyArray<string> =>
65
+ compile(path, []).flatMap((part) => typeof part === "string" ? [] : [part.name])
66
+
63
67
  const countCaptures = (regex: string): number => {
64
68
  try {
65
69
  return new RegExp(regex + "|").exec("")!.length - 1
@@ -1,6 +1,7 @@
1
1
  import type * as Tracer from "../../Tracer.ts"
2
2
  import * as Headers from "../Headers.ts"
3
3
  import * as UrlParams from "../UrlParams.ts"
4
+ import { type ClientPath, redactClientPath } from "./clientPath.ts"
4
5
 
5
6
  const defaultPorts: Record<string, number> = {
6
7
  "http:": 80,
@@ -17,11 +18,13 @@ const defaultPorts: Record<string, number> = {
17
18
  export const addUrlAttributes = (
18
19
  span: Tracer.Span,
19
20
  url: URL,
20
- redactedNames: ReadonlyArray<string | RegExp>
21
+ redactedNames: ReadonlyArray<string | RegExp>,
22
+ path?: ClientPath | undefined
21
23
  ): void => {
24
+ const redactPath = (url: string) => path === undefined ? url : redactClientPath(url, path)
22
25
  const query = UrlParams.redactUrl(url.search, redactedNames).slice(1)
23
- span.attribute("url.full", UrlParams.redactUrl(url.href, redactedNames))
24
- span.attribute("url.path", url.pathname)
26
+ span.attribute("url.full", redactPath(UrlParams.redactUrl(url.href, redactedNames)))
27
+ span.attribute("url.path", redactPath(url.pathname))
25
28
  if (query !== "") {
26
29
  span.attribute("url.query", query)
27
30
  }
@@ -11,6 +11,7 @@
11
11
  */
12
12
  import type { NonEmptyReadonlyArray } from "../Array.ts"
13
13
  import * as Context from "../Context.ts"
14
+ import * as HttpMethod from "../http/HttpMethod.ts"
14
15
  import type { PathInput } from "../http/HttpRouter.ts"
15
16
  import * as InternalRecord from "../internal/record.ts"
16
17
  import { type Pipeable, pipeArguments } from "../Pipeable.ts"
@@ -23,6 +24,7 @@ import * as HttpApiEndpoint from "./HttpApiEndpoint.ts"
23
24
  import type * as HttpApiGroup from "./HttpApiGroup.ts"
24
25
  import type * as HttpApiMiddleware from "./HttpApiMiddleware.ts"
25
26
  import * as HttpApiSchema from "./HttpApiSchema.ts"
27
+ import { getRedactedKeys } from "./internal/redactedKeys.ts"
26
28
 
27
29
  const TypeId = "~effect/http-api/HttpApi"
28
30
 
@@ -512,8 +514,8 @@ export class ErrorParseOptions extends Context.Service<
512
514
  * the names on the group to keep both.
513
515
  * - Only URL and header attributes use these names. `user_agent.original` and
514
516
  * the messages of span errors are recorded as is.
515
- * - `params` apply to server spans and `HttpMiddleware.logger` entries.
516
- * Client spans record the path as sent.
517
+ * - `params` apply to client spans and error messages as well as server spans
518
+ * and `HttpMiddleware.logger` entries.
517
519
  * - `HttpApiBuilder.endpoint` returns a handler without a route, so set
518
520
  * `redactedParams` on the route it is mounted with.
519
521
  *
@@ -590,26 +592,45 @@ export const getEndpointRedactedNames = (
590
592
  ): EndpointRedactedNames | undefined => {
591
593
  const query: Array<string | RegExp> = []
592
594
  const headers: Array<string | RegExp> = []
595
+ const addQuery = (name: string | RegExp) => {
596
+ query.push(name)
597
+ if (typeof name === "string") query.push(new RegExp(`^${RegExp_.escape(name)}\\[`, "i"))
598
+ }
593
599
  for (const annotations of [api.annotations, group.annotations, endpoint.annotations]) {
594
600
  const options = Context.getOrUndefined(annotations, RedactedNames)
595
601
  if (options === undefined) continue
596
- for (const name of options.query ?? []) {
597
- query.push(name)
598
- if (typeof name === "string") query.push(new RegExp(`^${RegExp_.escape(name)}\\[`, "i"))
599
- }
602
+ options.query?.forEach(addQuery)
600
603
  if (options.headers !== undefined) headers.push(...options.headers)
601
604
  }
605
+ // Fields whose schema holds a `Redacted` are redacted without being listed.
606
+ // Payloads of methods without a body are sent as query parameters.
607
+ const querySchemas = HttpMethod.hasBody(endpoint.method)
608
+ ? [endpoint.query]
609
+ : [endpoint.query, ...HttpApiEndpoint.getPayloadSchemas(endpoint)]
610
+ for (const schema of querySchemas) (getRedactedKeys(schema) ?? redactAll).forEach(addQuery)
611
+ headers.push(...(getRedactedKeys(endpoint.headers) ?? redactAll))
602
612
  return query.length === 0 && headers.length === 0 ? undefined : { query, headers }
603
613
  }
604
614
 
605
615
  /**
616
+ * Returns the path param names to redact and whether to redact every param in
617
+ * the endpoint path (when the schema holds a `Redacted` under unknown wire names).
618
+ *
606
619
  * @internal
607
620
  */
608
621
  export const getEndpointRedactedParams = (
609
622
  api: Pick<Top, "annotations">,
610
623
  group: HttpApiGroup.Top,
611
624
  endpoint: HttpApiEndpoint.Top
612
- ): ReadonlyArray<string> =>
613
- [api.annotations, group.annotations, endpoint.annotations].flatMap((annotations) =>
625
+ ): { readonly names: ReadonlyArray<string>; readonly all: boolean } => {
626
+ const explicit = [api.annotations, group.annotations, endpoint.annotations].flatMap((annotations) =>
614
627
  Context.getOrUndefined(annotations, RedactedNames)?.params ?? []
615
628
  )
629
+ const keys = getRedactedKeys(endpoint.params)
630
+ return keys === undefined
631
+ ? { names: explicit, all: true }
632
+ : { names: [...explicit, ...keys], all: false }
633
+ }
634
+
635
+ // Matches every name, for a schema whose wire names are unknown.
636
+ const redactAll: ReadonlyArray<RegExp> = [/^/]
@@ -32,6 +32,7 @@ import * as Respondable from "../http/HttpServerRespondable.ts"
32
32
  import * as Response from "../http/HttpServerResponse.ts"
33
33
  import type { HttpServerResponse } from "../http/HttpServerResponse.ts"
34
34
  import * as MediaType from "../http/internal/mediaType.ts"
35
+ import * as RedactedPath from "../http/internal/redactedPath.ts"
35
36
  import { addRedactedNamesUnsafe } from "../http/internal/requestState.ts"
36
37
  import * as Multipart from "../http/Multipart.ts"
37
38
  import * as UrlParams from "../http/UrlParams.ts"
@@ -1077,13 +1078,17 @@ export function handlerToRoute(
1077
1078
  context: Context.Context<any>
1078
1079
  ): HttpRouter.Route<any, any> {
1079
1080
  const endpoint = handler.endpoint
1081
+ const path = HttpApiPath.toRouterPath(endpoint.path, endpoint.params)
1082
+ const redactedParams = HttpApi.getEndpointRedactedParams(api, group, endpoint)
1080
1083
  return HttpRouter.route(
1081
1084
  endpoint.method,
1082
- HttpApiPath.toRouterPath(endpoint.path, endpoint.params) as HttpRouter.PathInput,
1085
+ path as HttpRouter.PathInput,
1083
1086
  handlerToHttpEffect(api, group, endpoint, context, handler.handler, handler.isRaw),
1084
1087
  {
1085
1088
  uninterruptible: handler.uninterruptible,
1086
- redactedParams: HttpApi.getEndpointRedactedParams(api, group, endpoint)
1089
+ redactedParams: redactedParams.all
1090
+ ? [...redactedParams.names, ...RedactedPath.allParamNames(path)]
1091
+ : redactedParams.names
1087
1092
  }
1088
1093
  )
1089
1094
  }