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
@@ -0,0 +1,343 @@
1
+ import { format } from "../../Formatter.ts"
2
+ import { isObject } from "../../Predicate.ts"
3
+ import type { Json } from "../../Schema.ts"
4
+ import type * as Representation from "../../SchemaRepresentation.ts"
5
+ import { literal } from "../codegen.ts"
6
+ import { errorWithPath } from "../errors.ts"
7
+
8
+ type Path = ReadonlyArray<string | number>
9
+ type PrintArgument = (value: unknown) => string | undefined
10
+
11
+ const noArguments: PrintArgument = (payload) => payload === null ? "" : undefined
12
+ const string: PrintArgument = (value) => typeof value === "string" ? literal(value) : undefined
13
+ const number: PrintArgument = (value) =>
14
+ typeof value === "number" && Number.isFinite(value) ? literal(value) : undefined
15
+ const natural: PrintArgument = (value) =>
16
+ typeof value === "number" && Number.isInteger(value) && value >= 0 ? literal(value) : undefined
17
+ const bigint: PrintArgument = (value) =>
18
+ typeof value === "string" && /^-?(?:0|[1-9][0-9]*)$/.test(value) ? literal(BigInt(value)) : undefined
19
+ const date: PrintArgument = (value) => {
20
+ if (typeof value !== "string") return undefined
21
+ const ms = Date.parse(value)
22
+ return Number.isFinite(ms) && new Date(ms).toISOString() === value ? `new globalThis.Date(${ms})` : undefined
23
+ }
24
+
25
+ function fields(render: PrintArgument, ...keys: ReadonlyArray<string>): PrintArgument {
26
+ return (payload) => {
27
+ if (!isObject(payload)) return undefined
28
+ const args: Array<string> = []
29
+ for (const key of keys) {
30
+ const arg = render(payload[key])
31
+ if (arg === undefined) return undefined
32
+ args.push(arg)
33
+ }
34
+ return args.join(", ")
35
+ }
36
+ }
37
+
38
+ function between(render: PrintArgument): PrintArgument {
39
+ return (payload) => {
40
+ if (!isObject(payload)) return undefined
41
+ const minimum = render(payload.minimum)
42
+ const maximum = render(payload.maximum)
43
+ const { exclusiveMaximum, exclusiveMinimum } = payload
44
+ if (
45
+ minimum === undefined || maximum === undefined ||
46
+ exclusiveMinimum !== undefined && exclusiveMinimum !== true ||
47
+ exclusiveMaximum !== undefined && exclusiveMaximum !== true
48
+ ) return undefined
49
+ return `{ minimum: ${minimum}, maximum: ${maximum}, exclusiveMinimum: ${exclusiveMinimum}, exclusiveMaximum: ${exclusiveMaximum} }`
50
+ }
51
+ }
52
+
53
+ const checkArguments: Record<string, PrintArgument> = {
54
+ isTrimmed: noArguments,
55
+ isPattern: (payload) => {
56
+ if (!isObject(payload) || typeof payload.source !== "string" || typeof payload.flags !== "string") return undefined
57
+ const { source, flags } = payload
58
+ try {
59
+ const pattern = new RegExp(source, flags)
60
+ if (pattern.source !== source || pattern.flags !== flags) return undefined
61
+ } catch {
62
+ return undefined
63
+ }
64
+ return `new globalThis.RegExp(${literal(source)}${flags === "" ? "" : ", " + literal(flags)})`
65
+ },
66
+ isStringFinite: noArguments,
67
+ isStringBigInt: noArguments,
68
+ isStringSymbol: noArguments,
69
+ isUUID: (payload) => {
70
+ if (!isObject(payload)) return undefined
71
+ const { version } = payload
72
+ if (version === null) return ""
73
+ return typeof version === "number" && Number.isInteger(version) && version >= 1 && version <= 8
74
+ ? literal(version)
75
+ : undefined
76
+ },
77
+ isGUID: noArguments,
78
+ isULID: noArguments,
79
+ isAscii: noArguments,
80
+ isBase64: noArguments,
81
+ isBase64Url: noArguments,
82
+ isStartingWith: fields(string, "startsWith"),
83
+ isEndingWith: fields(string, "endsWith"),
84
+ isIncluding: fields(string, "includes"),
85
+ isUppercased: noArguments,
86
+ isLowercased: noArguments,
87
+ isCapitalized: noArguments,
88
+ isUncapitalized: noArguments,
89
+ isFinite: noArguments,
90
+ isInt: noArguments,
91
+ isGreaterThan: fields(number, "exclusiveMinimum"),
92
+ isGreaterThanOrEqualTo: fields(number, "minimum"),
93
+ isLessThan: fields(number, "exclusiveMaximum"),
94
+ isLessThanOrEqualTo: fields(number, "maximum"),
95
+ isBetween: between(number),
96
+ isMultipleOf: fields((value) => typeof value === "number" && value > 0 ? number(value) : undefined, "divisor"),
97
+ isGreaterThanDate: fields(date, "exclusiveMinimum"),
98
+ isGreaterThanOrEqualToDate: fields(date, "minimum"),
99
+ isLessThanDate: fields(date, "exclusiveMaximum"),
100
+ isLessThanOrEqualToDate: fields(date, "maximum"),
101
+ isBetweenDate: between(date),
102
+ isGreaterThanBigInt: fields(bigint, "exclusiveMinimum"),
103
+ isGreaterThanOrEqualToBigInt: fields(bigint, "minimum"),
104
+ isLessThanBigInt: fields(bigint, "exclusiveMaximum"),
105
+ isLessThanOrEqualToBigInt: fields(bigint, "maximum"),
106
+ isBetweenBigInt: between(bigint),
107
+ isMinLength: fields(natural, "minLength"),
108
+ isMaxLength: fields(natural, "maxLength"),
109
+ isBetweenLength: fields(natural, "minimum", "maximum"),
110
+ isMinCodePoints: fields(natural, "minCodePoints"),
111
+ isMaxCodePoints: fields(natural, "maxCodePoints"),
112
+ isBetweenCodePoints: fields(natural, "minimum", "maximum"),
113
+ isMinSize: fields(natural, "minSize"),
114
+ isMaxSize: fields(natural, "maxSize"),
115
+ isBetweenSize: fields(natural, "minimum", "maximum"),
116
+ isMinProperties: fields(natural, "minProperties"),
117
+ isMaxProperties: fields(natural, "maxProperties"),
118
+ isBetweenProperties: fields(natural, "minimum", "maximum"),
119
+ isPropertyNames: noArguments,
120
+ isUnique: noArguments,
121
+ isUniqueKey: noArguments
122
+ }
123
+
124
+ function invalidPayload(id: string, path: Path): never {
125
+ throw errorWithPath(`Invalid representation payload for ${id}`, [...path, "representation", "payload"])
126
+ }
127
+
128
+ function checkArity(id: string, actual: number, expected: number, path: Path): void {
129
+ if (actual !== expected) {
130
+ throw errorWithPath(`Invalid number of schema arguments for ${id}: expected ${expected}, got ${actual}`, path)
131
+ }
132
+ }
133
+
134
+ /** @internal */
135
+ export function resolveCheck(check: Representation.Check, path: Path): Representation.Generation.Check | undefined {
136
+ const { annotations, representation: repr } = check
137
+ if (annotations && "toCode" in annotations) return annotations.toCode as Representation.Generation.Check | undefined
138
+ if (check._tag !== "Filter" || !repr?.id.startsWith("effect/schema/")) return undefined
139
+ const name = repr.id.slice("effect/schema/".length)
140
+ if (!Object.hasOwn(checkArguments, name)) return undefined
141
+ const args = checkArguments[name](repr.payload) ?? invalidPayload(repr.id, path)
142
+ checkArity(repr.id, repr.schemas?.length ?? 0, name === "isPropertyNames" ? 1 : 0, [
143
+ ...path,
144
+ "representation",
145
+ "schemas"
146
+ ])
147
+ return ({ schemas }) => ({ runtime: `Schema.${name}(${schemas[0]?.runtime ?? args})` })
148
+ }
149
+
150
+ interface DeclarationRule {
151
+ readonly type: string
152
+ // An explicit zero distinguishes a call like ErrorInstance() from a constant like Date.
153
+ readonly arity?: number
154
+ readonly typeArity?: number
155
+ readonly module?: string
156
+ readonly runtime?: string
157
+ readonly argument?: PrintArgument
158
+ readonly crypto?: KeyAlgorithms
159
+ }
160
+
161
+ function options(accepts: (key: string, value: unknown) => boolean): PrintArgument {
162
+ return (payload) => {
163
+ if (payload === null) return ""
164
+ if (!isObject(payload)) return undefined
165
+ const entries = Object.entries(payload)
166
+ return entries.length > 0 && entries.every(([key, value]) => accepts(key, value)) ? format(payload) : undefined
167
+ }
168
+ }
169
+
170
+ interface KeyAlgorithms {
171
+ readonly withoutHash?: ReadonlyArray<string>
172
+ readonly withHash?: ReadonlyArray<string>
173
+ readonly rsa?: string
174
+ readonly rsaWithSalt?: string
175
+ }
176
+
177
+ const signature: KeyAlgorithms = {
178
+ withoutHash: ["ed25519"],
179
+ withHash: ["ecdsaP256", "ecdsaP384", "ecdsaP521"],
180
+ rsa: "rsaPkcs1v15",
181
+ rsaWithSalt: "rsaPss"
182
+ }
183
+ const keyAgreement: KeyAlgorithms = { withoutHash: ["x25519", "ecdhP256", "ecdhP384", "ecdhP521"] }
184
+
185
+ const declarations: Record<string, DeclarationRule> = {
186
+ "effect/schema/Json": { type: "Schema.Json" },
187
+ "effect/schema/MutableJson": { type: "Schema.MutableJson" },
188
+ "effect/schema/Error": {
189
+ type: "globalThis.Error",
190
+ runtime: "Schema.ErrorInstance",
191
+ arity: 0,
192
+ argument: options((key, value) => (key === "includeStack" || key === "excludeCause") && value === true)
193
+ },
194
+ "effect/schema/RegExp": { type: "globalThis.RegExp" },
195
+ "effect/schema/URL": { type: "globalThis.URL" },
196
+ "effect/schema/Date": { type: "globalThis.Date" },
197
+ "effect/schema/File": { type: "globalThis.File" },
198
+ "effect/schema/FormData": { type: "globalThis.FormData" },
199
+ "effect/schema/URLSearchParams": { type: "globalThis.URLSearchParams" },
200
+ "effect/schema/Uint8Array": { type: "globalThis.Uint8Array" },
201
+ "effect/schema/ReadonlyMap": { type: "globalThis.ReadonlyMap", arity: 2 },
202
+ "effect/schema/ReadonlySet": { type: "globalThis.ReadonlySet", arity: 1 },
203
+ "effect/schema/BigDecimal": { type: "BigDecimal.BigDecimal" },
204
+ "effect/schema/Rational": { type: "Rational.Rational" },
205
+ "effect/schema/ByteSize": { type: "ByteSize.ByteSize" },
206
+ "effect/schema/CauseReason": { type: "Cause.Reason", arity: 2, typeArity: 1 },
207
+ "effect/schema/Cause": { type: "Cause.Cause", arity: 2, typeArity: 1 },
208
+ "effect/schema/Chunk": { type: "Chunk.Chunk", arity: 1 },
209
+ "effect/schema/DateTimeUtc": { type: "DateTime.Utc" },
210
+ "effect/schema/TimeZoneOffset": { type: "DateTime.TimeZone.Offset" },
211
+ "effect/schema/TimeZoneNamed": { type: "DateTime.TimeZone.Named" },
212
+ "effect/schema/TimeZone": { type: "DateTime.TimeZone" },
213
+ "effect/schema/DateTimeZoned": { type: "DateTime.Zoned" },
214
+ "effect/schema/Duration": { type: "Duration.Duration" },
215
+ "effect/schema/Exit": { type: "Exit.Exit", arity: 3, typeArity: 2 },
216
+ "effect/schema/Graph": {
217
+ type: "Graph.Graph",
218
+ arity: 2,
219
+ argument: (kind) => kind === "directed" || kind === "undirected" ? literal(kind) : undefined
220
+ },
221
+ "effect/schema/HashMap": { type: "HashMap.HashMap", arity: 2 },
222
+ "effect/schema/HashSet": { type: "HashSet.HashSet", arity: 1 },
223
+ "effect/schema/Option": { type: "Option.Option", arity: 1 },
224
+ "effect/schema/Redacted": {
225
+ type: "Redacted.Redacted",
226
+ arity: 1,
227
+ argument: options((key, value) =>
228
+ key === "label" ? typeof value === "string" : key === "disallowJsonEncode" && value === true
229
+ )
230
+ },
231
+ "effect/schema/Result": { type: "Result.Result", arity: 2 },
232
+ "effect/schema/SemVer": { type: "SemVer.SemVer" },
233
+ "effect/schema/SemVerRange": { type: "SemVerRange.SemVerRange" },
234
+ "effect/http/Cookie": { type: "Cookies.Cookie", module: "effect/http/Cookies" },
235
+ "effect/http/Cookies": { type: "Cookies.Cookies", module: "effect/http/Cookies" },
236
+ "effect/http/Headers": { type: "Headers.Headers", module: "effect/http/Headers" },
237
+ "effect/http/UrlParams": { type: "UrlParams.UrlParams", module: "effect/http/UrlParams" },
238
+ "effect/http/PersistedFile": {
239
+ type: "Multipart.PersistedFile",
240
+ module: "effect/http/Multipart",
241
+ runtime: "Multipart.PersistedFileSchema"
242
+ },
243
+ "effect/crypto/MacKey": {
244
+ type: "Mac.Key",
245
+ crypto: { withHash: ["hmacSha1", "hmacSha256", "hmacSha384", "hmacSha512"] }
246
+ },
247
+ "effect/crypto/AeadKey": {
248
+ type: "Aead.Key",
249
+ crypto: { withoutHash: ["aes128Gcm", "aes256Gcm", "chacha20Poly1305", "xchacha20Poly1305"] }
250
+ },
251
+ "effect/crypto/CipherKey": {
252
+ type: "Cipher.Key",
253
+ crypto: { withoutHash: ["aes128Ctr", "aes256Ctr", "aes128Cbc", "aes256Cbc"] }
254
+ },
255
+ "effect/crypto/SignaturePublicKey": { type: "Signature.PublicKey", crypto: signature },
256
+ "effect/crypto/SignaturePrivateKey": { type: "Signature.PrivateKey", crypto: signature },
257
+ "effect/crypto/KeyAgreementPublicKey": { type: "KeyAgreement.PublicKey", crypto: keyAgreement },
258
+ "effect/crypto/KeyAgreementPrivateKey": { type: "KeyAgreement.PrivateKey", crypto: keyAgreement },
259
+ "effect/crypto/KeyWrapKey": { type: "KeyWrap.Key", crypto: { withoutHash: ["aes128Kw", "aes256Kw"] } },
260
+ "effect/crypto/KeyWrapPublicKey": { type: "KeyWrap.PublicKey", crypto: { rsa: "rsaOaep" } },
261
+ "effect/crypto/KeyWrapPrivateKey": { type: "KeyWrap.PrivateKey", crypto: { rsa: "rsaOaep" } }
262
+ }
263
+
264
+ const digestSuffixes = new Map([
265
+ ["MD5", "Md5"],
266
+ ["SHA-1", "Sha1"],
267
+ ["SHA-256", "Sha256"],
268
+ ["SHA-384", "Sha384"],
269
+ ["SHA-512", "Sha512"]
270
+ ])
271
+
272
+ function cryptoKey(
273
+ name: string,
274
+ type: string,
275
+ algorithms: KeyAlgorithms,
276
+ payload: Json
277
+ ): Representation.Generation.DeclarationOutput | undefined {
278
+ if (!isObject(payload) || typeof payload.name !== "string") return undefined
279
+ const { hash, modulusLength, saltLength } = payload
280
+ const suffix = typeof hash === "string" ? digestSuffixes.get(hash) : undefined
281
+ if (hash !== undefined && suffix === undefined) return undefined
282
+ const digest = suffix === undefined ? undefined : `Digest.${suffix.toLowerCase()}`
283
+ const family = type.split(".")[0]
284
+ const imports = [`import * as ${family} from "effect/crypto/${family}"`]
285
+ if (digest !== undefined) imports.push("import * as Digest from \"effect/crypto/Digest\"")
286
+ let algorithm: string
287
+ if (modulusLength === undefined) {
288
+ const names = digest === undefined ? algorithms.withoutHash : algorithms.withHash
289
+ if (!names?.includes(payload.name) || saltLength !== undefined) return undefined
290
+ algorithm = `${family}.${payload.name}`
291
+ if (digest !== undefined) algorithm = `{ ...${algorithm}, hash: ${digest} }`
292
+ } else {
293
+ const factory = saltLength === undefined ? algorithms.rsa : algorithms.rsaWithSalt
294
+ if (
295
+ factory === undefined || digest === undefined || !Number.isFinite(modulusLength) ||
296
+ saltLength !== undefined && !Number.isFinite(saltLength)
297
+ ) return undefined
298
+ const salt = saltLength === undefined ? "" : `, saltLength: ${saltLength}`
299
+ algorithm = `${family}.${factory}({ hash: ${digest}, modulusLength: ${modulusLength}${salt} })`
300
+ if (payload.name !== factory + suffix) algorithm = `{ ...${algorithm}, name: ${literal(payload.name)} }`
301
+ }
302
+ return { runtime: `Schema.${name}(${algorithm})`, Type: type, importDeclarations: imports }
303
+ }
304
+
305
+ /** @internal */
306
+ export function resolveDeclaration(
307
+ node: Representation.Declaration,
308
+ path: Path
309
+ ): Representation.Generation.Declaration | undefined {
310
+ const { annotations, representation: repr } = node
311
+ if (annotations && "toCode" in annotations) {
312
+ return annotations.toCode as Representation.Generation.Declaration | undefined
313
+ }
314
+ if (!repr || !Object.hasOwn(declarations, repr.id)) return undefined
315
+ const { id, payload } = repr
316
+ const name = id.slice(id.lastIndexOf("/") + 1)
317
+ const rule = declarations[id]
318
+ checkArity(id, node.typeParameters.length, rule.arity ?? 0, [...path, "typeParameters"])
319
+ if (rule.crypto) {
320
+ const output = cryptoKey(name, rule.type, rule.crypto, payload) ?? invalidPayload(id, path)
321
+ return () => output
322
+ }
323
+ return ({ typeParameters }) => {
324
+ const args = typeParameters.map((p) => p.runtime)
325
+ const types = typeParameters.slice(0, rule.typeArity).map((p) => p.Type)
326
+ const argument = (rule.argument ?? noArguments)(payload) ?? invalidPayload(id, path)
327
+ if (id === "effect/schema/Graph") {
328
+ args.unshift(argument)
329
+ types.push(argument)
330
+ } else if (argument !== "") {
331
+ args.push(argument)
332
+ }
333
+ const runtime = rule.runtime ?? `Schema.${name}`
334
+ const namespace = rule.type.split(".")[0]
335
+ return {
336
+ runtime: rule.arity === undefined ? runtime : `${runtime}(${args.join(", ")})`,
337
+ Type: types.length > 0 ? `${rule.type}<${types.join(", ")}>` : rule.type,
338
+ importDeclarations: namespace === "globalThis" || namespace === "Schema" ? [] : [
339
+ `import * as ${namespace} from "${rule.module ?? "effect/" + namespace}"`
340
+ ]
341
+ }
342
+ }
343
+ }
@@ -8,14 +8,12 @@ import * as SchemaAST from "../../SchemaAST.ts"
8
8
  import * as SchemaParser from "../../SchemaParser.ts"
9
9
  import * as InternalAnnotations from "./annotations.ts"
10
10
 
11
- const recurMemo = memoize(recur)
12
-
13
11
  /** @internal */
14
12
  export const toEquivalence = (ast: SchemaAST.AST): Equivalence.Equivalence<any> => {
15
- return recurMemo(SchemaAST.toType(ast))
13
+ return recur(SchemaAST.toType(ast))
16
14
  }
17
15
 
18
- function recur(ast: SchemaAST.AST): Equivalence.Equivalence<any> {
16
+ const recur = memoize((ast: SchemaAST.AST): Equivalence.Equivalence<any> => {
19
17
  // ---------------------------------------------
20
18
  // handle annotations
21
19
  // ---------------------------------------------
@@ -156,7 +154,7 @@ function recur(ast: SchemaAST.AST): Equivalence.Equivalence<any> {
156
154
  return Equivalence.make((a, b) => (equivalence ??= toEquivalence(ast.thunk()))(a, b))
157
155
  }
158
156
  }
159
- }
157
+ })
160
158
 
161
159
  function declarationEquivalence(ast: SchemaAST.Declaration): Equivalence.Equivalence<any> {
162
160
  const representation = (ast.annotations as Schema.Annotations.Declaration<any> | undefined)?.representation
@@ -1,2 +1,2 @@
1
1
  /** @internal */
2
- export const version = "4.1.5"
2
+ export const version = "4.1.7"
@@ -16,6 +16,7 @@
16
16
  * @stability unstable
17
17
  * @since 4.1.1
18
18
  */
19
+ import type * as CryptoError from "../crypto/CryptoError.ts"
19
20
  import * as Data from "../Data.ts"
20
21
  import * as Predicate from "../Predicate.ts"
21
22
 
@@ -69,6 +70,38 @@ export class InvalidKey extends Data.TaggedError("InvalidKey")<{
69
70
  }
70
71
  }
71
72
 
73
+ /**
74
+ * Reason for a crypto backend failure other than a rejected key, such as an
75
+ * algorithm the provider does not support.
76
+ *
77
+ * **Details**
78
+ *
79
+ * `module`, `method`, and `reason` identify the failed backend operation and
80
+ * reason tag. The backend description and cause are omitted because they may
81
+ * contain secret material.
82
+ *
83
+ * @stability unstable
84
+ * @category errors
85
+ * @since 4.1.6
86
+ */
87
+ export class CryptoFailed extends Data.TaggedError("CryptoFailed")<{
88
+ readonly description: string
89
+ readonly module: string
90
+ readonly method: string
91
+ readonly reason: CryptoError.CryptoErrorReason["_tag"]
92
+ }> {
93
+ /**
94
+ * Marks this value as a `JoseError` reason for runtime guards.
95
+ *
96
+ * @since 4.1.6
97
+ */
98
+ readonly [ReasonTypeId] = ReasonTypeId
99
+
100
+ override get message(): string {
101
+ return `${this.description} (${this.module}.${this.method}: ${this.reason})`
102
+ }
103
+ }
104
+
72
105
  /**
73
106
  * Reason for an option or configuration value that the operation rejects
74
107
  * before doing any work, such as a non-HTTPS key-set URL.
@@ -253,6 +286,7 @@ export class ClaimValidationFailed extends Data.TaggedError("ClaimValidationFail
253
286
  export type JoseErrorReason =
254
287
  | InvalidToken
255
288
  | InvalidKey
289
+ | CryptoFailed
256
290
  | InvalidArgument
257
291
  | AlgorithmNotAllowed
258
292
  | SignatureVerificationFailed
@@ -24,14 +24,23 @@ export const invalidArgument = (description: string, cause?: unknown) =>
24
24
  fail(new JoseError.InvalidArgument({ description, cause }))
25
25
 
26
26
  /**
27
- * Maps a failure of an operation on secret material, such as signing or
28
- * private-key import, to a fixed description. Backend messages and causes may
29
- * describe the secret, so they are dropped.
27
+ * Maps a backend failure without exposing its message or cause, which may
28
+ * describe secret material. `InvalidKey` stays `InvalidKey`; other reasons
29
+ * become `CryptoFailed`.
30
30
  *
31
31
  * @internal
32
32
  */
33
- export const cryptoFailure = (description: string) => (_: CryptoError.CryptoError): JoseError.JoseError =>
34
- new JoseError.JoseError({ reason: new JoseError.InvalidKey({ description }) })
33
+ export const cryptoFailure = (description: string) => (error: CryptoError.CryptoError): JoseError.JoseError =>
34
+ new JoseError.JoseError({
35
+ reason: error.reason._tag === "InvalidKey"
36
+ ? new JoseError.InvalidKey({ description })
37
+ : new JoseError.CryptoFailed({
38
+ description,
39
+ module: error.module,
40
+ method: error.method,
41
+ reason: error.reason._tag
42
+ })
43
+ })
35
44
 
36
45
  /**
37
46
  * Maps a public-key import failure, keeping the backend diagnostic.
@@ -16,6 +16,7 @@ import type * as HttpClient from "../http/HttpClient.ts"
16
16
  import * as HttpClientRequest from "../http/HttpClientRequest.ts"
17
17
  import * as Layer from "../Layer.ts"
18
18
  import type * as Tracer from "../Tracer.ts"
19
+ import type { Concurrency } from "../Types.ts"
19
20
  import type * as OtlpExporter from "./OtlpExporter.ts"
20
21
  import * as OtlpLogger from "./OtlpLogger.ts"
21
22
  import type { AggregationTemporality } from "./OtlpMetrics.ts"
@@ -53,6 +54,11 @@ export const layer = (options: {
53
54
  */
54
55
  readonly compression?: "gzip" | "none" | undefined
55
56
  readonly maxBatchSize?: number | undefined
57
+ /** Maximum pending queued spans/logs (does not include in-flight batches). */
58
+ readonly maxQueueSize?: number | undefined
59
+ /** Maximum concurrent export requests for spans/logs, or `"unbounded"`. Defaults to `4`. */
60
+ readonly concurrency?: Concurrency | undefined
61
+ readonly onDrop?: ((count: number) => void) | undefined
56
62
  readonly tracerContext?: (<X>(primitive: Tracer.EffectPrimitive<X>, span: Tracer.AnySpan) => X) | undefined
57
63
  readonly loggerExportInterval?: Duration.Input | undefined
58
64
  readonly loggerExcludeLogSpans?: boolean | undefined
@@ -72,6 +78,9 @@ export const layer = (options: {
72
78
  compression: options.compression,
73
79
  exportInterval: options.loggerExportInterval,
74
80
  maxBatchSize: options.maxBatchSize,
81
+ maxQueueSize: options.maxQueueSize,
82
+ concurrency: options.concurrency,
83
+ onDrop: options.onDrop,
75
84
  shutdownTimeout: options.shutdownTimeout,
76
85
  excludeLogSpans: options.loggerExcludeLogSpans,
77
86
  mergeWithExisting: options.loggerMergeWithExisting
@@ -92,6 +101,9 @@ export const layer = (options: {
92
101
  compression: options.compression,
93
102
  exportInterval: options.tracerExportInterval,
94
103
  maxBatchSize: options.maxBatchSize,
104
+ maxQueueSize: options.maxQueueSize,
105
+ concurrency: options.concurrency,
106
+ onDrop: options.onDrop,
95
107
  context: options.tracerContext,
96
108
  shutdownTimeout: options.shutdownTimeout
97
109
  })
@@ -119,6 +131,9 @@ export const layerFromConfig = (options?: {
119
131
  readonly attributes?: Record<string, unknown>
120
132
  } | undefined
121
133
  readonly headers?: Headers.Input | undefined
134
+ /** Maximum concurrent export requests for spans/logs, or `"unbounded"`. Defaults to `4`. */
135
+ readonly concurrency?: Concurrency | undefined
136
+ readonly onDrop?: ((count: number) => void) | undefined
122
137
  readonly tracerContext?: (<X>(primitive: Tracer.EffectPrimitive<X>, span: Tracer.AnySpan) => X) | undefined
123
138
  readonly loggerExcludeLogSpans?: boolean | undefined
124
139
  readonly loggerMergeWithExisting?: boolean | undefined
@@ -127,6 +142,8 @@ export const layerFromConfig = (options?: {
127
142
  OtlpLogger.layerFromConfig({
128
143
  resource: options?.resource,
129
144
  headers: options?.headers,
145
+ concurrency: options?.concurrency,
146
+ onDrop: options?.onDrop,
130
147
  excludeLogSpans: options?.loggerExcludeLogSpans,
131
148
  mergeWithExisting: options?.loggerMergeWithExisting
132
149
  }),
@@ -137,6 +154,8 @@ export const layerFromConfig = (options?: {
137
154
  OtlpTracer.layerFromConfig({
138
155
  resource: options?.resource,
139
156
  headers: options?.headers,
157
+ concurrency: options?.concurrency,
158
+ onDrop: options?.onDrop,
140
159
  context: options?.tracerContext
141
160
  })
142
161
  )
@@ -163,6 +182,11 @@ export const layerJson: (options: {
163
182
  */
164
183
  readonly compression?: "gzip" | "none" | undefined
165
184
  readonly maxBatchSize?: number | undefined
185
+ /** Maximum pending queued spans/logs (does not include in-flight batches). */
186
+ readonly maxQueueSize?: number | undefined
187
+ /** Maximum concurrent export requests for spans/logs, or `"unbounded"`. Defaults to `4`. */
188
+ readonly concurrency?: Concurrency | undefined
189
+ readonly onDrop?: ((count: number) => void) | undefined
166
190
  readonly tracerContext?: (<X>(primitive: Tracer.EffectPrimitive<X>, span: Tracer.AnySpan) => X) | undefined
167
191
  readonly loggerExportInterval?: Duration.Input | undefined
168
192
  readonly loggerExcludeLogSpans?: boolean | undefined
@@ -198,6 +222,11 @@ export const layerProtobuf: (options: {
198
222
  */
199
223
  readonly compression?: "gzip" | "none" | undefined
200
224
  readonly maxBatchSize?: number | undefined
225
+ /** Maximum pending queued spans/logs (does not include in-flight batches). */
226
+ readonly maxQueueSize?: number | undefined
227
+ /** Maximum concurrent export requests for spans/logs, or `"unbounded"`. Defaults to `4`. */
228
+ readonly concurrency?: Concurrency | undefined
229
+ readonly onDrop?: ((count: number) => void) | undefined
201
230
  readonly tracerContext?: (<X>(primitive: Tracer.EffectPrimitive<X>, span: Tracer.AnySpan) => X) | undefined
202
231
  readonly loggerExportInterval?: Duration.Input | undefined
203
232
  readonly loggerExcludeLogSpans?: boolean | undefined