effect 4.1.0 → 4.1.2

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 (445) hide show
  1. package/README.md +30 -0
  2. package/THIRD_PARTY_NOTICES.md +62 -0
  3. package/ai-docs/package.json +2 -2
  4. package/dist/BigDecimal.d.ts +139 -7
  5. package/dist/BigDecimal.d.ts.map +1 -1
  6. package/dist/BigDecimal.js +83 -14
  7. package/dist/BigDecimal.js.map +1 -1
  8. package/dist/ByteSize.d.ts.map +1 -1
  9. package/dist/ByteSize.js +27 -14
  10. package/dist/ByteSize.js.map +1 -1
  11. package/dist/Equal.d.ts +2 -2
  12. package/dist/Equal.d.ts.map +1 -1
  13. package/dist/Equal.js +3 -3
  14. package/dist/Equal.js.map +1 -1
  15. package/dist/Hash.d.ts +3 -2
  16. package/dist/Hash.d.ts.map +1 -1
  17. package/dist/Hash.js +5 -4
  18. package/dist/Hash.js.map +1 -1
  19. package/dist/Iterable.d.ts.map +1 -1
  20. package/dist/Iterable.js +38 -32
  21. package/dist/Iterable.js.map +1 -1
  22. package/dist/JsonSchema.d.ts.map +1 -1
  23. package/dist/JsonSchema.js +27 -6
  24. package/dist/JsonSchema.js.map +1 -1
  25. package/dist/MutableRef.d.ts.map +1 -1
  26. package/dist/MutableRef.js +0 -7
  27. package/dist/MutableRef.js.map +1 -1
  28. package/dist/Path.d.ts.map +1 -1
  29. package/dist/Path.js +5 -1
  30. package/dist/Path.js.map +1 -1
  31. package/dist/Pool.d.ts.map +1 -1
  32. package/dist/Pool.js +2 -1
  33. package/dist/Pool.js.map +1 -1
  34. package/dist/Ref.d.ts.map +1 -1
  35. package/dist/Ref.js +0 -8
  36. package/dist/Ref.js.map +1 -1
  37. package/dist/Schedule.d.ts.map +1 -1
  38. package/dist/Schedule.js +8 -3
  39. package/dist/Schedule.js.map +1 -1
  40. package/dist/Schema.d.ts +2 -1
  41. package/dist/Schema.d.ts.map +1 -1
  42. package/dist/Schema.js +2 -1
  43. package/dist/Schema.js.map +1 -1
  44. package/dist/SchemaRepresentation.d.ts +4 -2
  45. package/dist/SchemaRepresentation.d.ts.map +1 -1
  46. package/dist/SchemaRepresentation.js +4 -2
  47. package/dist/SchemaRepresentation.js.map +1 -1
  48. package/dist/SchemaTransformation.d.ts +2 -2
  49. package/dist/SchemaTransformation.js +2 -2
  50. package/dist/Stream.d.ts.map +1 -1
  51. package/dist/Stream.js +6 -5
  52. package/dist/Stream.js.map +1 -1
  53. package/dist/ai/McpClient.d.ts +171 -19
  54. package/dist/ai/McpClient.d.ts.map +1 -1
  55. package/dist/ai/McpClient.js +277 -66
  56. package/dist/ai/McpClient.js.map +1 -1
  57. package/dist/ai/McpSchema.d.ts +108 -0
  58. package/dist/ai/McpSchema.d.ts.map +1 -1
  59. package/dist/ai/McpSchema.js +99 -0
  60. package/dist/ai/McpSchema.js.map +1 -1
  61. package/dist/ai/McpServer.d.ts +120 -6
  62. package/dist/ai/McpServer.d.ts.map +1 -1
  63. package/dist/ai/McpServer.js +258 -49
  64. package/dist/ai/McpServer.js.map +1 -1
  65. package/dist/ai/Prompt.d.ts.map +1 -1
  66. package/dist/ai/Prompt.js +20 -11
  67. package/dist/ai/Prompt.js.map +1 -1
  68. package/dist/ai/Tool.d.ts.map +1 -1
  69. package/dist/ai/Tool.js +5 -7
  70. package/dist/ai/Tool.js.map +1 -1
  71. package/dist/ai/internal/mcpCore.js +72 -3
  72. package/dist/ai/internal/mcpCore.js.map +1 -1
  73. package/dist/ai/internal/mcpProtocol/v2024_11_05.js +3 -1
  74. package/dist/ai/internal/mcpProtocol/v2024_11_05.js.map +1 -1
  75. package/dist/ai/internal/mcpProtocol/v2025_03_26.js +3 -1
  76. package/dist/ai/internal/mcpProtocol/v2025_03_26.js.map +1 -1
  77. package/dist/ai/internal/mcpProtocol/v2025_06_18.js +3 -1
  78. package/dist/ai/internal/mcpProtocol/v2025_06_18.js.map +1 -1
  79. package/dist/ai/internal/mcpProtocol/v2025_11_25.js +3 -1
  80. package/dist/ai/internal/mcpProtocol/v2025_11_25.js.map +1 -1
  81. package/dist/ai/internal/mcpProtocol/v2026_07_28.js +44 -8
  82. package/dist/ai/internal/mcpProtocol/v2026_07_28.js.map +1 -1
  83. package/dist/ai/internal/mcpProtocol.js +12 -0
  84. package/dist/ai/internal/mcpProtocol.js.map +1 -1
  85. package/dist/ai/internal/mcpRuntime.js +3 -3
  86. package/dist/ai/internal/mcpRuntime.js.map +1 -1
  87. package/dist/ai/internal/mcpSkills.d.ts +2 -0
  88. package/dist/ai/internal/mcpSkills.d.ts.map +1 -0
  89. package/dist/ai/internal/mcpSkills.js +428 -0
  90. package/dist/ai/internal/mcpSkills.js.map +1 -0
  91. package/dist/ai/internal/structured-output.js +11 -2
  92. package/dist/ai/internal/structured-output.js.map +1 -1
  93. package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
  94. package/dist/cluster/ClusterWorkflowEngine.js +30 -11
  95. package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
  96. package/dist/cluster/Entity.d.ts +26 -0
  97. package/dist/cluster/Entity.d.ts.map +1 -1
  98. package/dist/cluster/Entity.js.map +1 -1
  99. package/dist/cluster/MessageStorage.d.ts +6 -6
  100. package/dist/cluster/MessageStorage.d.ts.map +1 -1
  101. package/dist/cluster/MessageStorage.js +1 -3
  102. package/dist/cluster/MessageStorage.js.map +1 -1
  103. package/dist/cluster/Reply.d.ts +1 -1
  104. package/dist/cluster/Reply.d.ts.map +1 -1
  105. package/dist/cluster/Reply.js.map +1 -1
  106. package/dist/cluster/Runners.d.ts.map +1 -1
  107. package/dist/cluster/Runners.js +13 -2
  108. package/dist/cluster/Runners.js.map +1 -1
  109. package/dist/cluster/Sharding.d.ts +13 -0
  110. package/dist/cluster/Sharding.d.ts.map +1 -1
  111. package/dist/cluster/Sharding.js +4 -1
  112. package/dist/cluster/Sharding.js.map +1 -1
  113. package/dist/cluster/internal/clusterAbandon.d.ts.map +1 -1
  114. package/dist/cluster/internal/clusterAbandon.js +6 -4
  115. package/dist/cluster/internal/clusterAbandon.js.map +1 -1
  116. package/dist/cluster/internal/entityManager.js +63 -11
  117. package/dist/cluster/internal/entityManager.js.map +1 -1
  118. package/dist/cluster/internal/transactionNotifications.d.ts +5 -0
  119. package/dist/cluster/internal/transactionNotifications.d.ts.map +1 -0
  120. package/dist/cluster/internal/transactionNotifications.js +5 -0
  121. package/dist/cluster/internal/transactionNotifications.js.map +1 -0
  122. package/dist/crypto/Aead.d.ts +2 -1
  123. package/dist/crypto/Aead.d.ts.map +1 -1
  124. package/dist/crypto/Aead.js +2 -2
  125. package/dist/crypto/Aead.js.map +1 -1
  126. package/dist/crypto/Cipher.d.ts +2 -1
  127. package/dist/crypto/Cipher.d.ts.map +1 -1
  128. package/dist/crypto/Cipher.js +2 -2
  129. package/dist/crypto/Cipher.js.map +1 -1
  130. package/dist/crypto/KeyAgreement.d.ts +3 -2
  131. package/dist/crypto/KeyAgreement.d.ts.map +1 -1
  132. package/dist/crypto/KeyAgreement.js +2 -2
  133. package/dist/crypto/KeyAgreement.js.map +1 -1
  134. package/dist/crypto/KeyFormat.d.ts +33 -1
  135. package/dist/crypto/KeyFormat.d.ts.map +1 -1
  136. package/dist/crypto/KeyFormat.js.map +1 -1
  137. package/dist/crypto/KeyWrap.d.ts +4 -3
  138. package/dist/crypto/KeyWrap.d.ts.map +1 -1
  139. package/dist/crypto/KeyWrap.js +2 -2
  140. package/dist/crypto/KeyWrap.js.map +1 -1
  141. package/dist/crypto/Mac.d.ts +2 -1
  142. package/dist/crypto/Mac.d.ts.map +1 -1
  143. package/dist/crypto/Mac.js +2 -2
  144. package/dist/crypto/Mac.js.map +1 -1
  145. package/dist/crypto/Signature.d.ts +3 -2
  146. package/dist/crypto/Signature.d.ts.map +1 -1
  147. package/dist/crypto/Signature.js +2 -2
  148. package/dist/crypto/Signature.js.map +1 -1
  149. package/dist/crypto/WebCrypto.d.ts +19 -0
  150. package/dist/crypto/WebCrypto.d.ts.map +1 -1
  151. package/dist/crypto/WebCrypto.js.map +1 -1
  152. package/dist/crypto/internal/asymmetric.js.map +1 -1
  153. package/dist/crypto/internal/key.js +3 -2
  154. package/dist/crypto/internal/key.js.map +1 -1
  155. package/dist/encoding/Base64Url.d.ts.map +1 -1
  156. package/dist/encoding/Base64Url.js +26 -3
  157. package/dist/encoding/Base64Url.js.map +1 -1
  158. package/dist/encoding/Json5.d.ts +44 -0
  159. package/dist/encoding/Json5.d.ts.map +1 -0
  160. package/dist/encoding/Json5.js +56 -0
  161. package/dist/encoding/Json5.js.map +1 -0
  162. package/dist/encoding/Jsonc.d.ts +47 -0
  163. package/dist/encoding/Jsonc.d.ts.map +1 -0
  164. package/dist/encoding/Jsonc.js +120 -0
  165. package/dist/encoding/Jsonc.js.map +1 -0
  166. package/dist/encoding/Ndjson.d.ts +5 -4
  167. package/dist/encoding/Ndjson.d.ts.map +1 -1
  168. package/dist/encoding/Ndjson.js +6 -5
  169. package/dist/encoding/Ndjson.js.map +1 -1
  170. package/dist/encoding/SchemaBinary.d.ts +94 -0
  171. package/dist/encoding/SchemaBinary.d.ts.map +1 -1
  172. package/dist/encoding/SchemaBinary.js +219 -6
  173. package/dist/encoding/SchemaBinary.js.map +1 -1
  174. package/dist/encoding/Sse.d.ts +3 -1
  175. package/dist/encoding/Sse.d.ts.map +1 -1
  176. package/dist/encoding/Sse.js +5 -3
  177. package/dist/encoding/Sse.js.map +1 -1
  178. package/dist/encoding/index.d.ts +10 -0
  179. package/dist/encoding/index.d.ts.map +1 -1
  180. package/dist/encoding/index.js +10 -0
  181. package/dist/encoding/index.js.map +1 -1
  182. package/dist/eventlog/EventLog.d.ts +7 -0
  183. package/dist/eventlog/EventLog.d.ts.map +1 -1
  184. package/dist/eventlog/EventLog.js +7 -0
  185. package/dist/eventlog/EventLog.js.map +1 -1
  186. package/dist/eventlog/EventLogServer.d.ts +7 -1
  187. package/dist/eventlog/EventLogServer.d.ts.map +1 -1
  188. package/dist/eventlog/EventLogServer.js +55 -24
  189. package/dist/eventlog/EventLogServer.js.map +1 -1
  190. package/dist/eventlog/EventLogServerEncrypted.d.ts +10 -0
  191. package/dist/eventlog/EventLogServerEncrypted.d.ts.map +1 -1
  192. package/dist/eventlog/EventLogServerEncrypted.js.map +1 -1
  193. package/dist/eventlog/EventLogServerUnencrypted.d.ts +17 -0
  194. package/dist/eventlog/EventLogServerUnencrypted.d.ts.map +1 -1
  195. package/dist/eventlog/EventLogServerUnencrypted.js +14 -2
  196. package/dist/eventlog/EventLogServerUnencrypted.js.map +1 -1
  197. package/dist/eventlog/EventLogSessionAuth.d.ts +21 -0
  198. package/dist/eventlog/EventLogSessionAuth.d.ts.map +1 -1
  199. package/dist/eventlog/EventLogSessionAuth.js +22 -0
  200. package/dist/eventlog/EventLogSessionAuth.js.map +1 -1
  201. package/dist/graphql/GraphQLClient.d.ts +3 -1
  202. package/dist/graphql/GraphQLClient.d.ts.map +1 -1
  203. package/dist/graphql/GraphQLClient.js.map +1 -1
  204. package/dist/graphql/GraphQLClientError.d.ts +14 -9
  205. package/dist/graphql/GraphQLClientError.d.ts.map +1 -1
  206. package/dist/graphql/GraphQLClientError.js +14 -21
  207. package/dist/graphql/GraphQLClientError.js.map +1 -1
  208. package/dist/graphql/GraphQLProtocol.d.ts +12 -3
  209. package/dist/graphql/GraphQLProtocol.d.ts.map +1 -1
  210. package/dist/graphql/GraphQLProtocol.js +4 -1
  211. package/dist/graphql/GraphQLProtocol.js.map +1 -1
  212. package/dist/http/HttpClient.d.ts +204 -16
  213. package/dist/http/HttpClient.d.ts.map +1 -1
  214. package/dist/http/HttpClient.js +93 -13
  215. package/dist/http/HttpClient.js.map +1 -1
  216. package/dist/http/HttpServerRequest.d.ts.map +1 -1
  217. package/dist/http/HttpServerRequest.js +38 -22
  218. package/dist/http/HttpServerRequest.js.map +1 -1
  219. package/dist/http/internal/mimeTypes.d.ts +4 -1
  220. package/dist/http/internal/mimeTypes.d.ts.map +1 -1
  221. package/dist/http/internal/mimeTypes.js +4 -1
  222. package/dist/http/internal/mimeTypes.js.map +1 -1
  223. package/dist/http-api/HttpApiSchema.js +1 -1
  224. package/dist/http-api/HttpApiSchema.js.map +1 -1
  225. package/dist/internal/dateTime.js +66 -27
  226. package/dist/internal/dateTime.js.map +1 -1
  227. package/dist/internal/effect.js +10 -0
  228. package/dist/internal/effect.js.map +1 -1
  229. package/dist/internal/glob.js +234 -56
  230. package/dist/internal/glob.js.map +1 -1
  231. package/dist/internal/graphql.js +21 -7
  232. package/dist/internal/graphql.js.map +1 -1
  233. package/dist/internal/graphqlHeaders.d.ts +7 -0
  234. package/dist/internal/graphqlHeaders.d.ts.map +1 -1
  235. package/dist/internal/graphqlHeaders.js +11 -0
  236. package/dist/internal/graphqlHeaders.js.map +1 -1
  237. package/dist/internal/jsonParser.d.ts +5 -0
  238. package/dist/internal/jsonParser.d.ts.map +1 -0
  239. package/dist/internal/jsonParser.js +280 -0
  240. package/dist/internal/jsonParser.js.map +1 -0
  241. package/dist/internal/persistence.js +8 -1
  242. package/dist/internal/persistence.js.map +1 -1
  243. package/dist/internal/request.js +29 -42
  244. package/dist/internal/request.js.map +1 -1
  245. package/dist/internal/schema/fromJsonSchemaDocument.js +7 -8
  246. package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -1
  247. package/dist/internal/sql.js +16 -0
  248. package/dist/internal/sql.js.map +1 -1
  249. package/dist/internal/version.js +1 -1
  250. package/dist/jose/JoseError.d.ts +285 -0
  251. package/dist/jose/JoseError.d.ts.map +1 -0
  252. package/dist/jose/JoseError.js +269 -0
  253. package/dist/jose/JoseError.js.map +1 -0
  254. package/dist/jose/Jwe.d.ts +128 -0
  255. package/dist/jose/Jwe.d.ts.map +1 -0
  256. package/dist/jose/Jwe.js +134 -0
  257. package/dist/jose/Jwe.js.map +1 -0
  258. package/dist/jose/Jwk.d.ts +597 -0
  259. package/dist/jose/Jwk.d.ts.map +1 -0
  260. package/dist/jose/Jwk.js +503 -0
  261. package/dist/jose/Jwk.js.map +1 -0
  262. package/dist/jose/Jwks.d.ts +236 -0
  263. package/dist/jose/Jwks.d.ts.map +1 -0
  264. package/dist/jose/Jwks.js +306 -0
  265. package/dist/jose/Jwks.js.map +1 -0
  266. package/dist/jose/Jws.d.ts +177 -0
  267. package/dist/jose/Jws.d.ts.map +1 -0
  268. package/dist/jose/Jws.js +183 -0
  269. package/dist/jose/Jws.js.map +1 -0
  270. package/dist/jose/Jwt.d.ts +270 -0
  271. package/dist/jose/Jwt.d.ts.map +1 -0
  272. package/dist/jose/Jwt.js +293 -0
  273. package/dist/jose/Jwt.js.map +1 -0
  274. package/dist/jose/index.d.ts +51 -0
  275. package/dist/jose/index.d.ts.map +1 -0
  276. package/dist/jose/index.js +52 -0
  277. package/dist/jose/index.js.map +1 -0
  278. package/dist/jose/internal/compact.d.ts +2 -0
  279. package/dist/jose/internal/compact.d.ts.map +1 -0
  280. package/dist/jose/internal/compact.js +179 -0
  281. package/dist/jose/internal/compact.js.map +1 -0
  282. package/dist/net/Host.d.ts.map +1 -1
  283. package/dist/net/Host.js +5 -10
  284. package/dist/net/Host.js.map +1 -1
  285. package/dist/observability/OtlpExporter.d.ts +4 -0
  286. package/dist/observability/OtlpExporter.d.ts.map +1 -1
  287. package/dist/observability/OtlpExporter.js +40 -12
  288. package/dist/observability/OtlpExporter.js.map +1 -1
  289. package/dist/observability/OtlpSerialization.d.ts +1 -1
  290. package/dist/observability/OtlpSerialization.d.ts.map +1 -1
  291. package/dist/observability/OtlpSerialization.js +10 -4
  292. package/dist/observability/OtlpSerialization.js.map +1 -1
  293. package/dist/observability/internal/otlpProtobuf.js +3 -3
  294. package/dist/observability/internal/otlpProtobuf.js.map +1 -1
  295. package/dist/observability/internal/protobuf.js +6 -0
  296. package/dist/observability/internal/protobuf.js.map +1 -1
  297. package/dist/persistence/CircuitBreaker.d.ts +98 -38
  298. package/dist/persistence/CircuitBreaker.d.ts.map +1 -1
  299. package/dist/persistence/CircuitBreaker.js +67 -29
  300. package/dist/persistence/CircuitBreaker.js.map +1 -1
  301. package/dist/persistence/RateLimiter.d.ts +15 -0
  302. package/dist/persistence/RateLimiter.d.ts.map +1 -1
  303. package/dist/persistence/RateLimiter.js +76 -16
  304. package/dist/persistence/RateLimiter.js.map +1 -1
  305. package/dist/persistence/index.d.ts +1 -1
  306. package/dist/persistence/index.js +1 -1
  307. package/dist/reactivity/AtomRegistry.js +17 -7
  308. package/dist/reactivity/AtomRegistry.js.map +1 -1
  309. package/dist/rpc/Rpc.d.ts +1 -1
  310. package/dist/rpc/Rpc.d.ts.map +1 -1
  311. package/dist/rpc/Rpc.js.map +1 -1
  312. package/dist/rpc/RpcClient.d.ts +14 -2
  313. package/dist/rpc/RpcClient.d.ts.map +1 -1
  314. package/dist/rpc/RpcClient.js +38 -21
  315. package/dist/rpc/RpcClient.js.map +1 -1
  316. package/dist/rpc/RpcMessage.d.ts +3 -2
  317. package/dist/rpc/RpcMessage.d.ts.map +1 -1
  318. package/dist/rpc/RpcMessage.js.map +1 -1
  319. package/dist/rpc/RpcServer.d.ts.map +1 -1
  320. package/dist/rpc/RpcServer.js +10 -1
  321. package/dist/rpc/RpcServer.js.map +1 -1
  322. package/dist/sql/Migrator.d.ts +9 -1
  323. package/dist/sql/Migrator.d.ts.map +1 -1
  324. package/dist/sql/Migrator.js +18 -6
  325. package/dist/sql/Migrator.js.map +1 -1
  326. package/dist/sql/SqlClient.d.ts +46 -3
  327. package/dist/sql/SqlClient.d.ts.map +1 -1
  328. package/dist/sql/SqlClient.js +40 -15
  329. package/dist/sql/SqlClient.js.map +1 -1
  330. package/dist/sql/Statement.d.ts +46 -3
  331. package/dist/sql/Statement.d.ts.map +1 -1
  332. package/dist/sql/Statement.js +32 -26
  333. package/dist/sql/Statement.js.map +1 -1
  334. package/dist/workflow/Workflow.d.ts +4 -0
  335. package/dist/workflow/Workflow.d.ts.map +1 -1
  336. package/dist/workflow/Workflow.js.map +1 -1
  337. package/dist/workflow/WorkflowEngine.d.ts.map +1 -1
  338. package/dist/workflow/WorkflowEngine.js +5 -0
  339. package/dist/workflow/WorkflowEngine.js.map +1 -1
  340. package/package.json +7 -3
  341. package/src/BigDecimal.ts +170 -16
  342. package/src/ByteSize.ts +29 -14
  343. package/src/Equal.ts +3 -3
  344. package/src/Hash.ts +5 -4
  345. package/src/Iterable.ts +28 -19
  346. package/src/JsonSchema.ts +45 -7
  347. package/src/MutableRef.ts +1 -8
  348. package/src/Path.ts +6 -1
  349. package/src/Pool.ts +2 -1
  350. package/src/Ref.ts +0 -8
  351. package/src/Schedule.ts +8 -6
  352. package/src/Schema.ts +3 -2
  353. package/src/SchemaRepresentation.ts +4 -2
  354. package/src/SchemaTransformation.ts +2 -2
  355. package/src/Stream.ts +6 -5
  356. package/src/ai/McpClient.ts +488 -91
  357. package/src/ai/McpSchema.ts +119 -0
  358. package/src/ai/McpServer.ts +302 -56
  359. package/src/ai/Prompt.ts +16 -11
  360. package/src/ai/Tool.ts +5 -10
  361. package/src/ai/internal/mcpCore.ts +165 -12
  362. package/src/ai/internal/mcpProtocol/v2024_11_05.ts +3 -1
  363. package/src/ai/internal/mcpProtocol/v2025_03_26.ts +3 -1
  364. package/src/ai/internal/mcpProtocol/v2025_06_18.ts +3 -1
  365. package/src/ai/internal/mcpProtocol/v2025_11_25.ts +3 -1
  366. package/src/ai/internal/mcpProtocol/v2026_07_28.ts +42 -9
  367. package/src/ai/internal/mcpProtocol.ts +15 -0
  368. package/src/ai/internal/mcpRuntime.ts +6 -3
  369. package/src/ai/internal/mcpSkills.ts +480 -0
  370. package/src/ai/internal/structured-output.ts +10 -4
  371. package/src/cluster/ClusterWorkflowEngine.ts +48 -33
  372. package/src/cluster/Entity.ts +52 -0
  373. package/src/cluster/MessageStorage.ts +3 -6
  374. package/src/cluster/Reply.ts +1 -1
  375. package/src/cluster/Runners.ts +16 -2
  376. package/src/cluster/Sharding.ts +17 -1
  377. package/src/cluster/internal/clusterAbandon.ts +7 -7
  378. package/src/cluster/internal/entityManager.ts +89 -15
  379. package/src/cluster/internal/transactionNotifications.ts +7 -0
  380. package/src/crypto/Aead.ts +3 -3
  381. package/src/crypto/Cipher.ts +3 -3
  382. package/src/crypto/KeyAgreement.ts +4 -4
  383. package/src/crypto/KeyFormat.ts +30 -1
  384. package/src/crypto/KeyWrap.ts +6 -6
  385. package/src/crypto/Mac.ts +3 -3
  386. package/src/crypto/Signature.ts +4 -4
  387. package/src/crypto/WebCrypto.ts +20 -0
  388. package/src/crypto/internal/asymmetric.ts +2 -1
  389. package/src/crypto/internal/key.ts +12 -5
  390. package/src/encoding/Base64Url.ts +27 -3
  391. package/src/encoding/Json5.ts +59 -0
  392. package/src/encoding/Jsonc.ts +126 -0
  393. package/src/encoding/Ndjson.ts +6 -5
  394. package/src/encoding/SchemaBinary.ts +228 -7
  395. package/src/encoding/Sse.ts +5 -3
  396. package/src/encoding/index.ts +12 -0
  397. package/src/eventlog/EventLog.ts +7 -0
  398. package/src/eventlog/EventLogServer.ts +67 -24
  399. package/src/eventlog/EventLogServerEncrypted.ts +5 -0
  400. package/src/eventlog/EventLogServerUnencrypted.ts +19 -2
  401. package/src/eventlog/EventLogSessionAuth.ts +26 -0
  402. package/src/graphql/GraphQLClient.ts +3 -1
  403. package/src/graphql/GraphQLClientError.ts +15 -22
  404. package/src/graphql/GraphQLProtocol.ts +12 -3
  405. package/src/http/HttpClient.ts +244 -33
  406. package/src/http/HttpServerRequest.ts +61 -23
  407. package/src/http/internal/mimeTypes.ts +4 -1
  408. package/src/http-api/HttpApiSchema.ts +1 -1
  409. package/src/internal/dateTime.ts +80 -27
  410. package/src/internal/effect.ts +6 -0
  411. package/src/internal/glob.ts +279 -63
  412. package/src/internal/graphql.ts +27 -9
  413. package/src/internal/graphqlHeaders.ts +13 -0
  414. package/src/internal/jsonParser.ts +307 -0
  415. package/src/internal/persistence.ts +9 -1
  416. package/src/internal/request.ts +51 -58
  417. package/src/internal/schema/fromJsonSchemaDocument.ts +11 -10
  418. package/src/internal/sql.ts +25 -0
  419. package/src/internal/version.ts +1 -1
  420. package/src/jose/JoseError.ts +329 -0
  421. package/src/jose/Jwe.ts +196 -0
  422. package/src/jose/Jwk.ts +777 -0
  423. package/src/jose/Jwks.ts +418 -0
  424. package/src/jose/Jws.ts +312 -0
  425. package/src/jose/Jwt.ts +493 -0
  426. package/src/jose/index.ts +58 -0
  427. package/src/jose/internal/compact.ts +195 -0
  428. package/src/net/Host.ts +5 -10
  429. package/src/observability/OtlpExporter.ts +42 -18
  430. package/src/observability/OtlpSerialization.ts +13 -5
  431. package/src/observability/internal/otlpProtobuf.ts +6 -6
  432. package/src/observability/internal/protobuf.ts +10 -0
  433. package/src/persistence/CircuitBreaker.ts +113 -48
  434. package/src/persistence/RateLimiter.ts +97 -19
  435. package/src/persistence/index.ts +1 -1
  436. package/src/reactivity/AtomRegistry.ts +19 -8
  437. package/src/rpc/Rpc.ts +3 -1
  438. package/src/rpc/RpcClient.ts +44 -24
  439. package/src/rpc/RpcMessage.ts +3 -2
  440. package/src/rpc/RpcServer.ts +12 -1
  441. package/src/sql/Migrator.ts +35 -18
  442. package/src/sql/SqlClient.ts +91 -22
  443. package/src/sql/Statement.ts +60 -35
  444. package/src/workflow/Workflow.ts +4 -0
  445. package/src/workflow/WorkflowEngine.ts +5 -0
@@ -48,7 +48,7 @@ import * as Asymmetric from "./internal/asymmetric.ts"
48
48
  import * as KeyModel from "./internal/key.ts"
49
49
  import * as internal from "./internal/webCrypto.ts"
50
50
  import * as SecureRandom from "./SecureRandom.ts"
51
- import { WebCrypto } from "./WebCrypto.ts"
51
+ import * as WebCrypto from "./WebCrypto.ts"
52
52
 
53
53
  const PrivateKeyTypeId = "~effect/crypto/Signature/PrivateKey" as const
54
54
  const PublicKeyTypeId = "~effect/crypto/Signature/PublicKey" as const
@@ -513,7 +513,7 @@ export const layerWebCrypto: Layer.Layer<Signature, never, SecureRandom.SecureRa
513
513
  Signature,
514
514
  Effect.gen(function*() {
515
515
  const random = yield* SecureRandom.SecureRandom
516
- const crypto = yield* WebCrypto
516
+ const crypto = yield* WebCrypto.WebCrypto
517
517
  const caches = Asymmetric.makeCaches(family)
518
518
  return Signature.of({
519
519
  generateKeyPair: <A extends Algorithm>(algorithm: A) =>
@@ -630,7 +630,7 @@ export const publicKey = <
630
630
  */
631
631
  export const privateKeyFromCryptoKey = <A extends Algorithm>(
632
632
  algorithm: A,
633
- cryptoKey: CryptoKey
633
+ cryptoKey: WebCrypto.CryptoKey
634
634
  ): Effect.Effect<PrivateKey<A>, CryptoError.CryptoError> =>
635
635
  Asymmetric.fromCryptoKey(family, "privateKeyFromCryptoKey", algorithm, "private", cryptoKey)
636
636
 
@@ -650,7 +650,7 @@ export const privateKeyFromCryptoKey = <A extends Algorithm>(
650
650
  */
651
651
  export const publicKeyFromCryptoKey = <A extends Algorithm>(
652
652
  algorithm: A,
653
- cryptoKey: CryptoKey
653
+ cryptoKey: WebCrypto.CryptoKey
654
654
  ): Effect.Effect<PublicKey<A>, CryptoError.CryptoError> =>
655
655
  Asymmetric.fromCryptoKey(family, "publicKeyFromCryptoKey", algorithm, "public", cryptoKey)
656
656
 
@@ -20,6 +20,10 @@
20
20
  import * as Context from "../Context.ts"
21
21
  import * as Layer from "../Layer.ts"
22
22
 
23
+ // The type of `globalThis.crypto`, which, unlike the global `Crypto` type,
24
+ // every `@types/node` version declares.
25
+ type Crypto = typeof globalThis.crypto
26
+
23
27
  /**
24
28
  * Reference to the WebCrypto `Crypto` object, defaulting to
25
29
  * `globalThis.crypto`.
@@ -62,3 +66,19 @@ export const WebCrypto: Context.Reference<Crypto> = Context.Reference<Crypto>("e
62
66
  * @since 4.0.0
63
67
  */
64
68
  export const layer = (crypto: Crypto): Layer.Layer<never> => Layer.succeed(WebCrypto, crypto)
69
+
70
+ /**
71
+ * A WebCrypto `CryptoKey`, declared structurally so the `effect` declarations
72
+ * type-check without the DOM library and with any `@types/node` version.
73
+ * Keys from `crypto.subtle` and Node's `webcrypto` are assignable to it.
74
+ *
75
+ * @stability unstable
76
+ * @category models
77
+ * @since 4.1.1
78
+ */
79
+ export interface CryptoKey {
80
+ readonly algorithm: { readonly name: string }
81
+ readonly extractable: boolean
82
+ readonly type: "private" | "public" | "secret"
83
+ readonly usages: ReadonlyArray<string>
84
+ }
@@ -2,6 +2,7 @@ import * as Effect from "../../Effect.ts"
2
2
  import * as Predicate from "../../Predicate.ts"
3
3
  import * as CryptoError from "../CryptoError.ts"
4
4
  import type * as SecureRandom from "../SecureRandom.ts"
5
+ import type * as WebCrypto from "../WebCrypto.ts"
5
6
  import * as KeyModel from "./key.ts"
6
7
  import * as internal from "./webCrypto.ts"
7
8
 
@@ -121,7 +122,7 @@ export const fromCryptoKey = <K>(
121
122
  method: string,
122
123
  algorithm: unknown,
123
124
  role: Role,
124
- cryptoKey: CryptoKey
125
+ cryptoKey: WebCrypto.CryptoKey
125
126
  ): Effect.Effect<K, CryptoError.CryptoError> => {
126
127
  const spec = family.specOf(algorithm)
127
128
  return KeyModel.fromCryptoKey(
@@ -4,6 +4,7 @@ import { format } from "../../Formatter.ts"
4
4
  import { NodeInspectSymbol } from "../../Inspectable.ts"
5
5
  import * as Predicate from "../../Predicate.ts"
6
6
  import type * as CryptoError from "../CryptoError.ts"
7
+ import type * as WebCrypto from "../WebCrypto.ts"
7
8
  import * as internal from "./webCrypto.ts"
8
9
 
9
10
  /**
@@ -131,7 +132,7 @@ export const checkAesLength = (name: string, keyLength: number) => (algorithm: K
131
132
  return length === keyLength * 8 ? undefined : `Expected a ${keyLength * 8}-bit ${name} key, not ${length} bits`
132
133
  }
133
134
 
134
- const checkCryptoKey = (cryptoKey: CryptoKey, expected: ExpectedCryptoKey): string | undefined => {
135
+ const checkCryptoKey = (cryptoKey: WebCrypto.CryptoKey, expected: ExpectedCryptoKey): string | undefined => {
135
136
  if (
136
137
  !Predicate.hasProperty(cryptoKey, "type") || !Predicate.hasProperty(cryptoKey, "algorithm") ||
137
138
  !Predicate.hasProperty(cryptoKey, "usages") || !Array.isArray(cryptoKey.usages)
@@ -162,7 +163,7 @@ const checkCryptoKey = (cryptoKey: CryptoKey, expected: ExpectedCryptoKey): stri
162
163
  *
163
164
  * @internal
164
165
  */
165
- export const importedAlgorithm = (algorithm: unknown, cryptoKey: CryptoKey): unknown => {
166
+ export const importedAlgorithm = (algorithm: unknown, cryptoKey: WebCrypto.CryptoKey): unknown => {
166
167
  const modulusLength = (cryptoKey.algorithm as Partial<RsaKeyAlgorithm>).modulusLength
167
168
  return Predicate.hasProperty(algorithm, "modulusLength") && modulusLength !== undefined &&
168
169
  algorithm.modulusLength !== modulusLength
@@ -171,7 +172,8 @@ export const importedAlgorithm = (algorithm: unknown, cryptoKey: CryptoKey): unk
171
172
  }
172
173
 
173
174
  /**
174
- * Synchronously validates and wraps a `CryptoKey`.
175
+ * Synchronously validates and wraps a `CryptoKey`. The structural key only
176
+ * becomes the native `CryptoKey` once it passes the check.
175
177
  *
176
178
  * @internal
177
179
  */
@@ -180,13 +182,18 @@ export const fromCryptoKey = <K>(
180
182
  method: string,
181
183
  proto: object,
182
184
  algorithm: unknown,
183
- cryptoKey: CryptoKey,
185
+ cryptoKey: WebCrypto.CryptoKey,
184
186
  expected: ExpectedCryptoKey
185
187
  ): Effect.Effect<K, CryptoError.CryptoError> =>
186
188
  Effect.suspend(() => {
187
189
  const problem = checkCryptoKey(cryptoKey, expected)
188
190
  return problem === undefined
189
- ? Effect.succeed(make<K>(proto, importedAlgorithm(algorithm, cryptoKey), { _tag: "CryptoKey", cryptoKey }))
191
+ ? Effect.succeed(
192
+ make<K>(proto, importedAlgorithm(algorithm, cryptoKey), {
193
+ _tag: "CryptoKey",
194
+ cryptoKey: cryptoKey as CryptoKey
195
+ })
196
+ )
190
197
  : internal.invalidKey(module, method, problem)
191
198
  })
192
199
 
@@ -115,6 +115,7 @@ export const decode = (str: string): Result.Result<Uint8Array, EncodingError> =>
115
115
  })
116
116
  )
117
117
  }
118
+ // Validating up front keeps failures as cheap as the scan, without allocating the output.
118
119
  if (!/^[-_A-Z0-9]*?={0,2}$/i.test(stripped)) {
119
120
  return Result.fail(
120
121
  new EncodingError({
@@ -125,11 +126,34 @@ export const decode = (str: string): Result.Result<Uint8Array, EncodingError> =>
125
126
  })
126
127
  )
127
128
  }
128
- let sanitized = length % 4 === 2 ? `${stripped}==` : length % 4 === 3 ? `${stripped}=` : stripped
129
- sanitized = sanitized.replace(/-/g, "+").replace(/_/g, "/")
130
- return Base64.decode(sanitized)
129
+ const end = !padded ? length : stripped.charCodeAt(length - 2) === 61 ? length - 2 : length - 1
130
+ const fullEnd = end & ~3
131
+ // Not `(end * 3) >> 2`: engines that allow strings over 2^31 / 3 characters would overflow int32.
132
+ const result = new Uint8Array(Math.floor(end * 3 / 4))
133
+ let j = 0
134
+ for (let i = 0; i < fullEnd; i += 4) {
135
+ const a = codes[stripped.charCodeAt(i)]
136
+ const b = codes[stripped.charCodeAt(i + 1)]
137
+ const c = codes[stripped.charCodeAt(i + 2)]
138
+ const d = codes[stripped.charCodeAt(i + 3)]
139
+ result[j++] = (a << 2) | (b >> 4)
140
+ result[j++] = (b << 4) | (c >> 2)
141
+ result[j++] = (c << 6) | d
142
+ }
143
+ // Non-zero trailing bits in the final character are ignored.
144
+ if (end > fullEnd) {
145
+ const a = codes[stripped.charCodeAt(fullEnd)]
146
+ const b = codes[stripped.charCodeAt(fullEnd + 1)]
147
+ result[j++] = (a << 2) | (b >> 4)
148
+ if (end - fullEnd === 3) result[j] = (b << 4) | (codes[stripped.charCodeAt(fullEnd + 2)] >> 2)
149
+ }
150
+ return Result.succeed(result)
131
151
  }
132
152
 
153
+ const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
154
+ const codes = new Uint8Array(128)
155
+ for (let i = 0; i < alphabet.length; i++) codes[alphabet.charCodeAt(i)] = i
156
+
133
157
  /**
134
158
  * Decodes a padded or unpadded URL-safe Base64 string into UTF-8 text safely.
135
159
  *
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Parses JSON5 configuration files without external dependencies.
3
+ *
4
+ * The compatibility target is [JSON5 1.0.0](https://spec.json5.org/) and the
5
+ * value-parsing behavior of `json5` 2.2.3, without its optional reviver.
6
+ * Identifier names use the runtime's Unicode property tables.
7
+ *
8
+ * @stability unstable
9
+ * @since 4.1.2
10
+ */
11
+
12
+ import * as internal from "../internal/jsonParser.ts"
13
+ import * as Result from "../Result.ts"
14
+ import { EncodingError } from "./EncodingError.ts"
15
+
16
+ /**
17
+ * Parses a JSON5 document into a JavaScript value.
18
+ *
19
+ * **Details**
20
+ *
21
+ * Returns `Result.succeed` with the parsed value, or `Result.fail` with an
22
+ * `EncodingError` when the input is not valid JSON5. Accepts comments,
23
+ * trailing commas, unquoted identifier keys, single-quoted strings,
24
+ * hexadecimal numbers, `Infinity`, and `NaN`. Duplicate keys use the last
25
+ * value; `__proto__` is preserved as an own data property.
26
+ *
27
+ * **Gotchas**
28
+ *
29
+ * Error messages give a line and column but do not include the input text.
30
+ * Unlike `JSON.parse`, this function has no reviver.
31
+ *
32
+ * **Example** (Parsing a JSON5 document)
33
+ *
34
+ * ```ts import.meta.vitest
35
+ * import { Result } from "effect"
36
+ * import { Json5 } from "effect/encoding"
37
+ *
38
+ * Json5.parse("{ port: 8080, }") // => Result.succeed({ port: 8080 })
39
+ * Result.isFailure(Json5.parse("{ port: }")) // => true
40
+ * ```
41
+ *
42
+ * @stability unstable
43
+ * @category decoding
44
+ * @since 4.1.2
45
+ */
46
+ export const parse = (input: string): Result.Result<unknown, EncodingError> => {
47
+ try {
48
+ return Result.succeed(internal.parse(input, "JSON5"))
49
+ } catch (e) {
50
+ return Result.fail(
51
+ new EncodingError({
52
+ module: "Json5",
53
+ kind: "Decode",
54
+ input,
55
+ message: e instanceof Error ? e.message : "Invalid input"
56
+ })
57
+ )
58
+ }
59
+ }
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Parses JSON with JavaScript-style comments without external dependencies.
3
+ *
4
+ * The syntax target is the [JSONC draft specification](https://jsonc.org/)
5
+ * with `jsonc-parser` 3.3.1's default profile: JSON plus line and block comments,
6
+ * with trailing commas disabled. One leading BOM is accepted, matching the
7
+ * TOML and YAML parsers. Decoded values follow `JSON.parse` semantics; invalid
8
+ * documents fail instead of returning a partial result.
9
+ *
10
+ * @stability unstable
11
+ * @since 4.1.2
12
+ */
13
+
14
+ import * as internal from "../internal/jsonParser.ts"
15
+ import * as Result from "../Result.ts"
16
+ import { EncodingError } from "./EncodingError.ts"
17
+
18
+ const fail = (input: string): never => {
19
+ // Native errors differ across engines and may quote the input, so the strict parser
20
+ // locates the error. It accepts exactly what JSON.parse accepts once comments are
21
+ // removed; the final throw only guards against an engine that disagrees.
22
+ internal.parse(input, "JSONC")
23
+ throw internal.syntaxError(input, input.length, "JSONC")
24
+ }
25
+
26
+ const lineEnd = /[\r\n]/g
27
+
28
+ const parseUnsafe = (input: string): unknown => {
29
+ // Ignore one leading BOM without shifting original-input error positions.
30
+ if (input.charCodeAt(0) === 0xfeff) input = " " + input.slice(1)
31
+ let slash = input.indexOf("/")
32
+ let json = input
33
+ if (slash !== -1) {
34
+ let stripped = ""
35
+ let start = 0
36
+ let quote = input.indexOf("\"")
37
+ while (slash !== -1) {
38
+ if (quote !== -1 && quote < slash) {
39
+ // Skip the string; a quote after an odd run of backslashes is escaped.
40
+ let end = quote
41
+ for (;;) {
42
+ end = input.indexOf("\"", end + 1)
43
+ if (end === -1) break
44
+ let backslash = end - 1
45
+ while (input.charCodeAt(backslash) === 92) backslash--
46
+ if ((end - backslash) % 2 === 1) break
47
+ }
48
+ if (end === -1) break
49
+ quote = input.indexOf("\"", end + 1)
50
+ if (slash < end) slash = input.indexOf("/", end + 1)
51
+ continue
52
+ }
53
+ const next = input.charCodeAt(slash + 1)
54
+ let index: number
55
+ if (next === 47) {
56
+ lineEnd.lastIndex = slash + 2
57
+ index = lineEnd.test(input) ? lineEnd.lastIndex - 1 : input.length
58
+ } else if (next === 42) {
59
+ const end = input.indexOf("*/", slash + 2)
60
+ if (end === -1) fail(input)
61
+ index = end + 2
62
+ } else {
63
+ // Not a comment; JSON.parse rejects it below.
64
+ slash = input.indexOf("/", slash + 1)
65
+ continue
66
+ }
67
+ // A space prevents comments inside invalid tokens from joining those tokens.
68
+ stripped += input.slice(start, slash) + " "
69
+ start = index
70
+ slash = input.indexOf("/", index)
71
+ if (quote !== -1 && quote < index) quote = input.indexOf("\"", index)
72
+ }
73
+ json = stripped + input.slice(start)
74
+ }
75
+ try {
76
+ return JSON.parse(json)
77
+ } catch {
78
+ return fail(input)
79
+ }
80
+ }
81
+
82
+ /**
83
+ * Parses a JSONC document into a JavaScript value.
84
+ *
85
+ * **Details**
86
+ *
87
+ * Returns `Result.succeed` with the parsed value, or `Result.fail` with an
88
+ * `EncodingError` when the input is not valid JSONC. Accepts one leading BOM
89
+ * and line and block comments wherever JSON permits whitespace. All other
90
+ * syntax follows `JSON.parse`, including duplicate keys and `__proto__`
91
+ * handling.
92
+ *
93
+ * **Gotchas**
94
+ *
95
+ * Error messages give a 1-based line and column, counted in UTF-16 code units,
96
+ * but do not include the input text. Trailing commas and JSON5 extensions are
97
+ * not accepted. Unlike `JSON.parse`, this function has no reviver.
98
+ *
99
+ * **Example** (Parsing a JSONC document)
100
+ *
101
+ * ```ts import.meta.vitest
102
+ * import { Result } from "effect"
103
+ * import { Jsonc } from "effect/encoding"
104
+ *
105
+ * Jsonc.parse("{ \"port\": 8080 } // comment") // => Result.succeed({ port: 8080 })
106
+ * Result.isFailure(Jsonc.parse("{ \"port\": 8080, }")) // => true
107
+ * ```
108
+ *
109
+ * @stability unstable
110
+ * @category decoding
111
+ * @since 4.1.2
112
+ */
113
+ export const parse = (input: string): Result.Result<unknown, EncodingError> => {
114
+ try {
115
+ return Result.succeed(parseUnsafe(input))
116
+ } catch (e) {
117
+ return Result.fail(
118
+ new EncodingError({
119
+ module: "Jsonc",
120
+ kind: "Decode",
121
+ input,
122
+ message: e instanceof Error ? e.message : "Invalid input"
123
+ })
124
+ )
125
+ }
126
+ }
@@ -236,7 +236,7 @@ const parseLine = (
236
236
  ignoreEmptyLines: boolean,
237
237
  unterminated: boolean
238
238
  ): NdjsonError | undefined => {
239
- if (ignoreEmptyLines && line.length === 0) return
239
+ if (ignoreEmptyLines && /^[ \t]*$/.test(line)) return
240
240
  try {
241
241
  out.push(JSON.parse(line))
242
242
  } catch (cause) {
@@ -262,8 +262,9 @@ const flushNothing = () => undefined
262
262
  *
263
263
  * **Gotchas**
264
264
  *
265
- * Set `ignoreEmptyLines` to skip blank lines before calling `JSON.parse`;
266
- * otherwise blank lines are parsed and fail as invalid JSON.
265
+ * Set `ignoreEmptyLines` to skip empty lines and lines containing only spaces
266
+ * or tabs before calling `JSON.parse`; otherwise these lines fail as invalid
267
+ * JSON.
267
268
  *
268
269
  * @stability unstable
269
270
  * @category constructors
@@ -314,8 +315,8 @@ const emptyBytes = new Uint8Array(0)
314
315
  * **Details**
315
316
  *
316
317
  * Lines may span input chunks. `\n`, `\r\n` and a bare `\r` end a line, and a
317
- * leading UTF-8 BOM is skipped. `ignoreEmptyLines` controls whether blank lines
318
- * are skipped before JSON parsing.
318
+ * leading UTF-8 BOM is skipped. `ignoreEmptyLines` skips empty lines and lines
319
+ * containing only spaces or tabs before JSON parsing.
319
320
  *
320
321
  * The first bad line fails the channel after the lines before it have been
321
322
  * emitted. A line that is not valid UTF-8 fails with `reason: "InvalidUtf8"`