effect 4.0.6 → 4.1.0
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.
- package/README.md +1 -1
- package/dist/Arbitrary.d.ts +10 -2
- package/dist/Arbitrary.d.ts.map +1 -1
- package/dist/Arbitrary.js +2 -1
- package/dist/Arbitrary.js.map +1 -1
- package/dist/BigDecimal.d.ts.map +1 -1
- package/dist/BigDecimal.js +3 -0
- package/dist/BigDecimal.js.map +1 -1
- package/dist/Channel.d.ts +12 -6
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +30 -9
- package/dist/Channel.js.map +1 -1
- package/dist/Config.d.ts +7 -1
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js.map +1 -1
- package/dist/Context.d.ts +18 -1
- package/dist/Context.d.ts.map +1 -1
- package/dist/Context.js +27 -8
- package/dist/Context.js.map +1 -1
- package/dist/Cron.d.ts +81 -11
- package/dist/Cron.d.ts.map +1 -1
- package/dist/Cron.js +101 -26
- package/dist/Cron.js.map +1 -1
- package/dist/Data.d.ts +54 -235
- package/dist/Data.d.ts.map +1 -1
- package/dist/Data.js.map +1 -1
- package/dist/Duration.d.ts +78 -0
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +123 -0
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts +165 -8
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +12 -2
- package/dist/Effect.js.map +1 -1
- package/dist/Equal.d.ts.map +1 -1
- package/dist/Equal.js +8 -1
- package/dist/Equal.js.map +1 -1
- package/dist/Exit.d.ts +3 -3
- package/dist/Exit.d.ts.map +1 -1
- package/dist/Exit.js.map +1 -1
- package/dist/FileSystem.d.ts +59 -4
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js +9 -2
- package/dist/FileSystem.js.map +1 -1
- package/dist/Formatter.d.ts.map +1 -1
- package/dist/Formatter.js +27 -13
- package/dist/Formatter.js.map +1 -1
- package/dist/Glob.d.ts +165 -0
- package/dist/Glob.d.ts.map +1 -0
- package/dist/Glob.js +127 -0
- package/dist/Glob.js.map +1 -0
- package/dist/Hash.d.ts.map +1 -1
- package/dist/Hash.js +4 -1
- package/dist/Hash.js.map +1 -1
- package/dist/JsonPatch.js +4 -0
- package/dist/JsonPatch.js.map +1 -1
- package/dist/JsonSchema.d.ts.map +1 -1
- package/dist/JsonSchema.js +13 -40
- package/dist/JsonSchema.js.map +1 -1
- package/dist/Match.d.ts +86 -0
- package/dist/Match.d.ts.map +1 -1
- package/dist/Match.js +72 -0
- package/dist/Match.js.map +1 -1
- package/dist/Metric.d.ts +3 -3
- package/dist/MutableList.d.ts +5 -2
- package/dist/MutableList.d.ts.map +1 -1
- package/dist/MutableList.js +7 -5
- package/dist/MutableList.js.map +1 -1
- package/dist/MutableRef.d.ts.map +1 -1
- package/dist/MutableRef.js +7 -0
- package/dist/MutableRef.js.map +1 -1
- package/dist/PartitionedSemaphore.d.ts +2 -1
- package/dist/PartitionedSemaphore.d.ts.map +1 -1
- package/dist/PartitionedSemaphore.js +22 -12
- package/dist/PartitionedSemaphore.js.map +1 -1
- package/dist/Pool.d.ts +51 -0
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +136 -36
- package/dist/Pool.js.map +1 -1
- package/dist/PubSub.d.ts.map +1 -1
- package/dist/PubSub.js +5 -6
- package/dist/PubSub.js.map +1 -1
- package/dist/Random.d.ts.map +1 -1
- package/dist/Random.js +3 -3
- package/dist/Random.js.map +1 -1
- package/dist/RcMap.d.ts.map +1 -1
- package/dist/RcMap.js +8 -2
- package/dist/RcMap.js.map +1 -1
- package/dist/Ref.d.ts.map +1 -1
- package/dist/Ref.js +8 -0
- package/dist/Ref.js.map +1 -1
- package/dist/Schedule.d.ts +18 -1
- package/dist/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js +8 -3
- package/dist/Schedule.js.map +1 -1
- package/dist/Schema.d.ts +690 -49
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +687 -28
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +4 -2
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +14 -17
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaGetter.d.ts +6 -1
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +22 -11
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +48 -22
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +33 -10
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +39 -13
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +12 -4
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +15 -5
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/ScopedCache.d.ts.map +1 -1
- package/dist/ScopedCache.js +5 -7
- package/dist/ScopedCache.js.map +1 -1
- package/dist/Semaphore.d.ts +130 -0
- package/dist/Semaphore.d.ts.map +1 -1
- package/dist/Semaphore.js +94 -35
- package/dist/Semaphore.js.map +1 -1
- package/dist/Sink.d.ts.map +1 -1
- package/dist/Sink.js +7 -2
- package/dist/Sink.js.map +1 -1
- package/dist/Stream.d.ts +13 -4
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +31 -10
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +3 -0
- package/dist/String.d.ts.map +1 -1
- package/dist/String.js +3 -0
- package/dist/String.js.map +1 -1
- package/dist/Terminal.d.ts +18 -1
- package/dist/Terminal.d.ts.map +1 -1
- package/dist/Terminal.js +1 -1
- package/dist/Terminal.js.map +1 -1
- package/dist/Tracer.d.ts +11 -1
- package/dist/Tracer.d.ts.map +1 -1
- package/dist/Tracer.js +6 -1
- package/dist/Tracer.js.map +1 -1
- package/dist/ai/AiError.d.ts +43 -116
- package/dist/ai/AiError.d.ts.map +1 -1
- package/dist/ai/AiError.js +53 -72
- package/dist/ai/AiError.js.map +1 -1
- package/dist/ai/Decision.d.ts +196 -15
- package/dist/ai/Decision.d.ts.map +1 -1
- package/dist/ai/Decision.js +130 -0
- package/dist/ai/Decision.js.map +1 -1
- package/dist/ai/DecisionModel.d.ts +54 -13
- package/dist/ai/DecisionModel.d.ts.map +1 -1
- package/dist/ai/DecisionModel.js +123 -12
- package/dist/ai/DecisionModel.js.map +1 -1
- package/dist/ai/LanguageModel.d.ts.map +1 -1
- package/dist/ai/LanguageModel.js +9 -0
- package/dist/ai/LanguageModel.js.map +1 -1
- package/dist/ai/McpSchema.d.ts +110 -110
- package/dist/ai/McpSchema.d.ts.map +1 -1
- package/dist/ai/McpServer.d.ts +630 -29
- package/dist/ai/McpServer.d.ts.map +1 -1
- package/dist/ai/McpServer.js +583 -131
- package/dist/ai/McpServer.js.map +1 -1
- package/dist/ai/McpTest.d.ts +130 -0
- package/dist/ai/McpTest.d.ts.map +1 -0
- package/dist/ai/McpTest.js +237 -0
- package/dist/ai/McpTest.js.map +1 -0
- package/dist/ai/Prompt.d.ts +52 -0
- package/dist/ai/Prompt.d.ts.map +1 -1
- package/dist/ai/Prompt.js +38 -0
- package/dist/ai/Prompt.js.map +1 -1
- package/dist/ai/Response.d.ts +17 -28
- package/dist/ai/Response.d.ts.map +1 -1
- package/dist/ai/Response.js +5 -10
- package/dist/ai/Response.js.map +1 -1
- package/dist/ai/Tool.d.ts +43 -1
- package/dist/ai/Tool.d.ts.map +1 -1
- package/dist/ai/Tool.js +5 -2
- package/dist/ai/Tool.js.map +1 -1
- package/dist/ai/Toolkit.d.ts.map +1 -1
- package/dist/ai/Toolkit.js +8 -1
- package/dist/ai/Toolkit.js.map +1 -1
- package/dist/ai/index.d.ts +5 -0
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js +5 -0
- package/dist/ai/index.js.map +1 -1
- package/dist/ai/internal/mcpCore.js +17 -12
- package/dist/ai/internal/mcpCore.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2024_11_05.js +4 -5
- package/dist/ai/internal/mcpProtocol/v2024_11_05.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_03_26.js +4 -5
- package/dist/ai/internal/mcpProtocol/v2025_03_26.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_06_18.js +4 -5
- package/dist/ai/internal/mcpProtocol/v2025_06_18.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_11_25.js +4 -5
- package/dist/ai/internal/mcpProtocol/v2025_11_25.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2026_07_28.js +18 -10
- package/dist/ai/internal/mcpProtocol/v2026_07_28.js.map +1 -1
- package/dist/ai/internal/mcpProtocol.js +13 -0
- package/dist/ai/internal/mcpProtocol.js.map +1 -1
- package/dist/ai/internal/mcpRuntime.js +5 -3
- package/dist/ai/internal/mcpRuntime.js.map +1 -1
- package/dist/ai/internal/mcpStatefulRuntime.js +6 -1
- package/dist/ai/internal/mcpStatefulRuntime.js.map +1 -1
- package/dist/cli/Argument.d.ts +21 -0
- package/dist/cli/Argument.d.ts.map +1 -1
- package/dist/cli/Argument.js +7 -0
- package/dist/cli/Argument.js.map +1 -1
- package/dist/cli/CliError.d.ts +78 -0
- package/dist/cli/CliError.d.ts.map +1 -1
- package/dist/cli/CliError.js +65 -3
- package/dist/cli/CliError.js.map +1 -1
- package/dist/cli/CliOutput.d.ts +220 -7
- package/dist/cli/CliOutput.d.ts.map +1 -1
- package/dist/cli/CliOutput.js +156 -43
- package/dist/cli/CliOutput.js.map +1 -1
- package/dist/cli/Command.d.ts +47 -16
- package/dist/cli/Command.d.ts.map +1 -1
- package/dist/cli/Command.js +67 -29
- package/dist/cli/Command.js.map +1 -1
- package/dist/cli/Completions.d.ts +58 -0
- package/dist/cli/Completions.d.ts.map +1 -1
- package/dist/cli/Completions.js +49 -9
- package/dist/cli/Completions.js.map +1 -1
- package/dist/cli/Flag.d.ts +122 -0
- package/dist/cli/Flag.d.ts.map +1 -1
- package/dist/cli/Flag.js +42 -0
- package/dist/cli/Flag.js.map +1 -1
- package/dist/cli/GlobalFlag.d.ts.map +1 -1
- package/dist/cli/GlobalFlag.js +15 -7
- package/dist/cli/GlobalFlag.js.map +1 -1
- package/dist/cli/HelpDoc.d.ts +15 -1
- package/dist/cli/HelpDoc.d.ts.map +1 -1
- package/dist/cli/Param.d.ts +15 -0
- package/dist/cli/Param.d.ts.map +1 -1
- package/dist/cli/Param.js +23 -2
- package/dist/cli/Param.js.map +1 -1
- package/dist/cli/Primitive.d.ts +14 -0
- package/dist/cli/Primitive.d.ts.map +1 -1
- package/dist/cli/Primitive.js +15 -1
- package/dist/cli/Primitive.js.map +1 -1
- package/dist/cli/Prompt.d.ts +1 -0
- package/dist/cli/Prompt.d.ts.map +1 -1
- package/dist/cli/Prompt.js +1 -0
- package/dist/cli/Prompt.js.map +1 -1
- package/dist/cli/TerminalCapabilities.d.ts +3 -2
- package/dist/cli/TerminalCapabilities.d.ts.map +1 -1
- package/dist/cli/TerminalCapabilities.js +3 -1
- package/dist/cli/TerminalCapabilities.js.map +1 -1
- package/dist/cli/internal/completions/bash.js +73 -27
- package/dist/cli/internal/completions/bash.js.map +1 -1
- package/dist/cli/internal/help.d.ts.map +1 -1
- package/dist/cli/internal/help.js +17 -10
- package/dist/cli/internal/help.js.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.js +45 -10
- package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/cluster/MessageStorage.d.ts +23 -45
- package/dist/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/cluster/MessageStorage.js +6 -7
- package/dist/cluster/MessageStorage.js.map +1 -1
- package/dist/cluster/Sharding.d.ts.map +1 -1
- package/dist/cluster/Sharding.js +151 -49
- package/dist/cluster/Sharding.js.map +1 -1
- package/dist/cluster/ShardingConfig.d.ts +76 -0
- package/dist/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/cluster/ShardingConfig.js +4 -0
- package/dist/cluster/ShardingConfig.js.map +1 -1
- package/dist/cluster/SingleRunner.d.ts +3 -3
- package/dist/cluster/SingleRunner.d.ts.map +1 -1
- package/dist/cluster/SingleRunner.js +1 -1
- package/dist/cluster/Snowflake.d.ts.map +1 -1
- package/dist/cluster/Snowflake.js +3 -7
- package/dist/cluster/Snowflake.js.map +1 -1
- package/dist/cluster/SqlMessageStorage.d.ts +37 -6
- package/dist/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/cluster/SqlMessageStorage.js +34 -7
- package/dist/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/cluster/SqlRunnerStorage.d.ts.map +1 -1
- package/dist/cluster/SqlRunnerStorage.js +109 -46
- package/dist/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/cluster/internal/entityManager.js +54 -20
- package/dist/cluster/internal/entityManager.js.map +1 -1
- package/dist/crypto/Aead.d.ts +322 -0
- package/dist/crypto/Aead.d.ts.map +1 -0
- package/dist/crypto/Aead.js +331 -0
- package/dist/crypto/Aead.js.map +1 -0
- package/dist/crypto/Cipher.d.ts +235 -0
- package/dist/crypto/Cipher.d.ts.map +1 -0
- package/dist/crypto/Cipher.js +233 -0
- package/dist/crypto/Cipher.js.map +1 -0
- package/dist/crypto/CryptoError.d.ts +212 -0
- package/dist/crypto/CryptoError.d.ts.map +1 -0
- package/dist/crypto/CryptoError.js +202 -0
- package/dist/crypto/CryptoError.js.map +1 -0
- package/dist/crypto/Digest.d.ts +143 -0
- package/dist/crypto/Digest.d.ts.map +1 -0
- package/dist/crypto/Digest.js +146 -0
- package/dist/crypto/Digest.js.map +1 -0
- package/dist/crypto/Kdf.d.ts +220 -0
- package/dist/crypto/Kdf.d.ts.map +1 -0
- package/dist/crypto/Kdf.js +212 -0
- package/dist/crypto/Kdf.js.map +1 -0
- package/dist/crypto/KeyAgreement.d.ts +323 -0
- package/dist/crypto/KeyAgreement.d.ts.map +1 -0
- package/dist/crypto/KeyAgreement.js +303 -0
- package/dist/crypto/KeyAgreement.js.map +1 -0
- package/dist/crypto/KeyFormat.d.ts +309 -0
- package/dist/crypto/KeyFormat.d.ts.map +1 -0
- package/dist/crypto/KeyFormat.js +556 -0
- package/dist/crypto/KeyFormat.js.map +1 -0
- package/dist/crypto/KeyWrap.d.ts +389 -0
- package/dist/crypto/KeyWrap.d.ts.map +1 -0
- package/dist/crypto/KeyWrap.js +381 -0
- package/dist/crypto/KeyWrap.js.map +1 -0
- package/dist/crypto/Mac.d.ts +277 -0
- package/dist/crypto/Mac.d.ts.map +1 -0
- package/dist/crypto/Mac.js +288 -0
- package/dist/crypto/Mac.js.map +1 -0
- package/dist/crypto/SecureRandom.d.ts +340 -0
- package/dist/crypto/SecureRandom.d.ts.map +1 -0
- package/dist/crypto/SecureRandom.js +257 -0
- package/dist/crypto/SecureRandom.js.map +1 -0
- package/dist/crypto/Signature.d.ts +448 -0
- package/dist/crypto/Signature.d.ts.map +1 -0
- package/dist/crypto/Signature.js +484 -0
- package/dist/crypto/Signature.js.map +1 -0
- package/dist/crypto/WebCrypto.d.ts +61 -0
- package/dist/crypto/WebCrypto.d.ts.map +1 -0
- package/dist/crypto/WebCrypto.js +63 -0
- package/dist/crypto/WebCrypto.js.map +1 -0
- package/dist/crypto/index.d.ts +65 -0
- package/dist/crypto/index.d.ts.map +1 -0
- package/dist/crypto/index.js +66 -0
- package/dist/crypto/index.js.map +1 -0
- package/dist/crypto/internal/asymmetric.d.ts +2 -0
- package/dist/crypto/internal/asymmetric.d.ts.map +1 -0
- package/dist/crypto/internal/asymmetric.js +210 -0
- package/dist/crypto/internal/asymmetric.js.map +1 -0
- package/dist/crypto/internal/chacha.d.ts +46 -0
- package/dist/crypto/internal/chacha.d.ts.map +1 -0
- package/dist/crypto/internal/chacha.js +885 -0
- package/dist/crypto/internal/chacha.js.map +1 -0
- package/dist/crypto/internal/der.d.ts +6 -0
- package/dist/crypto/internal/der.d.ts.map +1 -0
- package/dist/crypto/internal/der.js +86 -0
- package/dist/crypto/internal/der.js.map +1 -0
- package/dist/crypto/internal/digest.d.ts +2 -0
- package/dist/crypto/internal/digest.d.ts.map +1 -0
- package/dist/crypto/internal/digest.js +15 -0
- package/dist/crypto/internal/digest.js.map +1 -0
- package/dist/crypto/internal/key.d.ts +2 -0
- package/dist/crypto/internal/key.d.ts.map +1 -0
- package/dist/crypto/internal/key.js +170 -0
- package/dist/crypto/internal/key.js.map +1 -0
- package/dist/crypto/internal/md5.d.ts +39 -0
- package/dist/crypto/internal/md5.d.ts.map +1 -0
- package/dist/crypto/internal/md5.js +179 -0
- package/dist/crypto/internal/md5.js.map +1 -0
- package/dist/crypto/internal/webCrypto.d.ts +2 -0
- package/dist/crypto/internal/webCrypto.d.ts.map +1 -0
- package/dist/crypto/internal/webCrypto.js +111 -0
- package/dist/crypto/internal/webCrypto.js.map +1 -0
- package/dist/devtools/DevToolsClient.d.ts.map +1 -1
- package/dist/devtools/DevToolsClient.js +2 -0
- package/dist/devtools/DevToolsClient.js.map +1 -1
- package/dist/encoding/Base64.js +36 -0
- package/dist/encoding/Base64.js.map +1 -1
- package/dist/encoding/Base64Url.d.ts.map +1 -1
- package/dist/encoding/Base64Url.js +3 -2
- package/dist/encoding/Base64Url.js.map +1 -1
- package/dist/encoding/Csv.d.ts +608 -0
- package/dist/encoding/Csv.d.ts.map +1 -0
- package/dist/encoding/Csv.js +718 -0
- package/dist/encoding/Csv.js.map +1 -0
- package/dist/encoding/Hex.d.ts +3 -2
- package/dist/encoding/Hex.d.ts.map +1 -1
- package/dist/encoding/Hex.js +3 -2
- package/dist/encoding/Hex.js.map +1 -1
- package/dist/encoding/SchemaBinary.d.ts.map +1 -1
- package/dist/encoding/SchemaBinary.js +42 -4
- package/dist/encoding/SchemaBinary.js.map +1 -1
- package/dist/encoding/Sse.d.ts.map +1 -1
- package/dist/encoding/Sse.js +3 -3
- package/dist/encoding/Sse.js.map +1 -1
- package/dist/encoding/Toml.d.ts +17 -3
- package/dist/encoding/Toml.d.ts.map +1 -1
- package/dist/encoding/Toml.js +124 -31
- package/dist/encoding/Toml.js.map +1 -1
- package/dist/encoding/Yaml.d.ts +8 -1
- package/dist/encoding/Yaml.d.ts.map +1 -1
- package/dist/encoding/Yaml.js +54 -18
- package/dist/encoding/Yaml.js.map +1 -1
- package/dist/encoding/index.d.ts +5 -0
- package/dist/encoding/index.d.ts.map +1 -1
- package/dist/encoding/index.js +5 -0
- package/dist/encoding/index.js.map +1 -1
- package/dist/eventlog/EventJournal.d.ts.map +1 -1
- package/dist/eventlog/EventJournal.js +6 -3
- package/dist/eventlog/EventJournal.js.map +1 -1
- package/dist/eventlog/EventLog.d.ts +119 -4
- package/dist/eventlog/EventLog.d.ts.map +1 -1
- package/dist/eventlog/EventLog.js +200 -12
- package/dist/eventlog/EventLog.js.map +1 -1
- package/dist/eventlog/EventLogEncryption.d.ts +41 -4
- package/dist/eventlog/EventLogEncryption.d.ts.map +1 -1
- package/dist/eventlog/EventLogEncryption.js +83 -64
- package/dist/eventlog/EventLogEncryption.js.map +1 -1
- package/dist/eventlog/EventLogMessage.d.ts +279 -0
- package/dist/eventlog/EventLogMessage.d.ts.map +1 -1
- package/dist/eventlog/EventLogMessage.js +217 -1
- package/dist/eventlog/EventLogMessage.js.map +1 -1
- package/dist/eventlog/EventLogRemote.d.ts +200 -28
- package/dist/eventlog/EventLogRemote.d.ts.map +1 -1
- package/dist/eventlog/EventLogRemote.js +186 -16
- package/dist/eventlog/EventLogRemote.js.map +1 -1
- package/dist/eventlog/EventLogServer.d.ts +3 -0
- package/dist/eventlog/EventLogServer.d.ts.map +1 -1
- package/dist/eventlog/EventLogServer.js +18 -10
- package/dist/eventlog/EventLogServer.js.map +1 -1
- package/dist/eventlog/EventLogServerEncrypted.d.ts +326 -5
- package/dist/eventlog/EventLogServerEncrypted.d.ts.map +1 -1
- package/dist/eventlog/EventLogServerEncrypted.js +769 -14
- package/dist/eventlog/EventLogServerEncrypted.js.map +1 -1
- package/dist/eventlog/EventLogSessionAuth.d.ts +5 -3
- package/dist/eventlog/EventLogSessionAuth.d.ts.map +1 -1
- package/dist/eventlog/EventLogSessionAuth.js +41 -64
- package/dist/eventlog/EventLogSessionAuth.js.map +1 -1
- package/dist/eventlog/EventRow.d.ts +4 -0
- package/dist/eventlog/EventRow.d.ts.map +1 -1
- package/dist/eventlog/EventRow.js +12 -2
- package/dist/eventlog/EventRow.js.map +1 -1
- package/dist/eventlog/SqlEventJournal.d.ts.map +1 -1
- package/dist/eventlog/SqlEventJournal.js +47 -27
- package/dist/eventlog/SqlEventJournal.js.map +1 -1
- package/dist/eventlog/SqlEventLogServerEncrypted.d.ts +21 -5
- package/dist/eventlog/SqlEventLogServerEncrypted.d.ts.map +1 -1
- package/dist/eventlog/SqlEventLogServerEncrypted.js +1048 -113
- package/dist/eventlog/SqlEventLogServerEncrypted.js.map +1 -1
- package/dist/eventlog/SqlEventLogServerUnencrypted.js +2 -2
- package/dist/eventlog/SqlEventLogServerUnencrypted.js.map +1 -1
- package/dist/eventlog/internal/batches.d.ts +12 -0
- package/dist/eventlog/internal/batches.d.ts.map +1 -0
- package/dist/eventlog/internal/batches.js +26 -0
- package/dist/eventlog/internal/batches.js.map +1 -0
- package/dist/eventlog/internal/compaction.d.ts +38 -0
- package/dist/eventlog/internal/compaction.d.ts.map +1 -0
- package/dist/eventlog/internal/compaction.js +33 -0
- package/dist/eventlog/internal/compaction.js.map +1 -0
- package/dist/eventlog/internal/conflicts.d.ts +0 -1
- package/dist/eventlog/internal/conflicts.d.ts.map +1 -1
- package/dist/eventlog/internal/conflicts.js +0 -3
- package/dist/eventlog/internal/conflicts.js.map +1 -1
- package/dist/eventlog/internal/identityRootSecretDerivation.js +66 -67
- package/dist/eventlog/internal/identityRootSecretDerivation.js.map +1 -1
- package/dist/eventlog/internal/remoteCompaction.d.ts +31 -0
- package/dist/eventlog/internal/remoteCompaction.d.ts.map +1 -0
- package/dist/eventlog/internal/remoteCompaction.js +76 -0
- package/dist/eventlog/internal/remoteCompaction.js.map +1 -0
- package/dist/http/Cookies.d.ts +172 -0
- package/dist/http/Cookies.d.ts.map +1 -1
- package/dist/http/Cookies.js +153 -10
- package/dist/http/Cookies.js.map +1 -1
- package/dist/http/FetchHttpClient.d.ts +26 -2
- package/dist/http/FetchHttpClient.d.ts.map +1 -1
- package/dist/http/FetchHttpClient.js +78 -15
- package/dist/http/FetchHttpClient.js.map +1 -1
- package/dist/http/HttpClient.d.ts +502 -8
- package/dist/http/HttpClient.d.ts.map +1 -1
- package/dist/http/HttpClient.js +296 -12
- package/dist/http/HttpClient.js.map +1 -1
- package/dist/http/HttpClientError.d.ts +8 -1
- package/dist/http/HttpClientError.d.ts.map +1 -1
- package/dist/http/HttpClientError.js +37 -1
- package/dist/http/HttpClientError.js.map +1 -1
- package/dist/http/HttpClientRequest.d.ts +9 -5
- package/dist/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/http/HttpClientRequest.js +3 -4
- package/dist/http/HttpClientRequest.js.map +1 -1
- package/dist/http/HttpClientResponse.d.ts.map +1 -1
- package/dist/http/HttpClientResponse.js +3 -2
- package/dist/http/HttpClientResponse.js.map +1 -1
- package/dist/http/HttpMethod.d.ts +7 -1
- package/dist/http/HttpMethod.d.ts.map +1 -1
- package/dist/http/HttpMethod.js +3 -8
- package/dist/http/HttpMethod.js.map +1 -1
- package/dist/http/HttpMiddleware.d.ts +1 -1
- package/dist/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/http/HttpMiddleware.js +14 -16
- package/dist/http/HttpMiddleware.js.map +1 -1
- package/dist/http/HttpRouter.d.ts.map +1 -1
- package/dist/http/HttpRouter.js +2 -1
- package/dist/http/HttpRouter.js.map +1 -1
- package/dist/http/HttpServerError.js +2 -2
- package/dist/http/HttpServerError.js.map +1 -1
- package/dist/http/HttpServerRequest.d.ts +11 -3
- package/dist/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/http/HttpServerRequest.js +77 -25
- package/dist/http/HttpServerRequest.js.map +1 -1
- package/dist/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/http/HttpServerResponse.js +3 -2
- package/dist/http/HttpServerResponse.js.map +1 -1
- package/dist/http/HttpStaticServer.d.ts.map +1 -1
- package/dist/http/HttpStaticServer.js +48 -21
- package/dist/http/HttpStaticServer.js.map +1 -1
- package/dist/http/HttpTraceContext.d.ts +2 -1
- package/dist/http/HttpTraceContext.d.ts.map +1 -1
- package/dist/http/HttpTraceContext.js +7 -5
- package/dist/http/HttpTraceContext.js.map +1 -1
- package/dist/http/MultipartParser/internal/contentType.js +3 -3
- package/dist/http/ProblemDetails.d.ts +96 -0
- package/dist/http/ProblemDetails.d.ts.map +1 -0
- package/dist/http/ProblemDetails.js +98 -0
- package/dist/http/ProblemDetails.js.map +1 -0
- package/dist/http/UrlParams.d.ts +3 -1
- package/dist/http/UrlParams.d.ts.map +1 -1
- package/dist/http/UrlParams.js +4 -2
- package/dist/http/UrlParams.js.map +1 -1
- package/dist/http/index.d.ts +5 -0
- package/dist/http/index.d.ts.map +1 -1
- package/dist/http/index.js +5 -0
- package/dist/http/index.js.map +1 -1
- package/dist/http/internal/compression.js +4 -5
- package/dist/http/internal/compression.js.map +1 -1
- package/dist/http/internal/decompression.js +6 -2
- package/dist/http/internal/decompression.js.map +1 -1
- package/dist/http/internal/httpBody.js +8 -1
- package/dist/http/internal/httpBody.js.map +1 -1
- package/dist/http/internal/urlParams.js +33 -0
- package/dist/http/internal/urlParams.js.map +1 -1
- package/dist/http-api/HttpApi.d.ts +3 -6
- package/dist/http-api/HttpApi.d.ts.map +1 -1
- package/dist/http-api/HttpApi.js +3 -6
- package/dist/http-api/HttpApi.js.map +1 -1
- package/dist/http-api/HttpApiBuilder.d.ts.map +1 -1
- package/dist/http-api/HttpApiBuilder.js +43 -13
- package/dist/http-api/HttpApiBuilder.js.map +1 -1
- package/dist/http-api/HttpApiClient.d.ts +140 -7
- package/dist/http-api/HttpApiClient.d.ts.map +1 -1
- package/dist/http-api/HttpApiClient.js +193 -44
- package/dist/http-api/HttpApiClient.js.map +1 -1
- package/dist/http-api/HttpApiEndpoint.d.ts +24 -7
- package/dist/http-api/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/http-api/HttpApiEndpoint.js +123 -32
- package/dist/http-api/HttpApiEndpoint.js.map +1 -1
- package/dist/http-api/HttpApiError.d.ts +185 -13
- package/dist/http-api/HttpApiError.d.ts.map +1 -1
- package/dist/http-api/HttpApiError.js +128 -0
- package/dist/http-api/HttpApiError.js.map +1 -1
- package/dist/http-api/HttpApiMiddleware.d.ts +64 -17
- package/dist/http-api/HttpApiMiddleware.d.ts.map +1 -1
- package/dist/http-api/HttpApiMiddleware.js +85 -1
- package/dist/http-api/HttpApiMiddleware.js.map +1 -1
- package/dist/http-api/HttpApiSchema.d.ts +142 -33
- package/dist/http-api/HttpApiSchema.d.ts.map +1 -1
- package/dist/http-api/HttpApiSchema.js +123 -59
- package/dist/http-api/HttpApiSchema.js.map +1 -1
- package/dist/http-api/HttpApiTest.d.ts.map +1 -1
- package/dist/http-api/HttpApiTest.js +3 -2
- package/dist/http-api/HttpApiTest.js.map +1 -1
- package/dist/http-api/OpenApi.d.ts.map +1 -1
- package/dist/http-api/OpenApi.js +25 -16
- package/dist/http-api/OpenApi.js.map +1 -1
- package/dist/http-api/internal/toCodecHttpProperties.d.ts +2 -0
- package/dist/http-api/internal/toCodecHttpProperties.d.ts.map +1 -0
- package/dist/http-api/internal/toCodecHttpProperties.js +38 -0
- package/dist/http-api/internal/toCodecHttpProperties.js.map +1 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/internal/arbitrary/runner.d.ts.map +1 -1
- package/dist/internal/arbitrary/runner.js +120 -44
- package/dist/internal/arbitrary/runner.js.map +1 -1
- package/dist/internal/core.js +2 -0
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/effect.js +46 -27
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/equal.js +14 -0
- package/dist/internal/equal.js.map +1 -1
- package/dist/internal/glob.d.ts +2 -0
- package/dist/internal/glob.d.ts.map +1 -0
- package/dist/internal/glob.js +630 -0
- package/dist/internal/glob.js.map +1 -0
- package/dist/internal/jsonSchema.d.ts +2 -0
- package/dist/internal/jsonSchema.d.ts.map +1 -0
- package/dist/internal/jsonSchema.js +28 -0
- package/dist/internal/jsonSchema.js.map +1 -0
- package/dist/internal/matcher.js +11 -1
- package/dist/internal/matcher.js.map +1 -1
- package/dist/internal/persistence.js +9 -0
- package/dist/internal/persistence.js.map +1 -1
- package/dist/internal/rcRef.js +4 -1
- package/dist/internal/rcRef.js.map +1 -1
- package/dist/internal/schema/compilerRegistry.js +4 -1
- package/dist/internal/schema/compilerRegistry.js.map +1 -1
- package/dist/internal/schema/content.d.ts +2 -0
- package/dist/internal/schema/content.d.ts.map +1 -0
- package/dist/internal/schema/content.js +13 -0
- package/dist/internal/schema/content.js.map +1 -0
- package/dist/internal/schema/fromJsonSchemaDocument.js +173 -185
- package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -1
- package/dist/internal/schema/fromRepresentation.js +2 -1
- package/dist/internal/schema/fromRepresentation.js.map +1 -1
- package/dist/internal/schema/standardSchema.js +8 -2
- package/dist/internal/schema/standardSchema.js.map +1 -1
- package/dist/internal/schema/toCodeDocument.js +9 -6
- package/dist/internal/schema/toCodeDocument.js.map +1 -1
- package/dist/internal/schema/toCodec.js +21 -24
- package/dist/internal/schema/toCodec.js.map +1 -1
- package/dist/internal/schema/toJsonSchemaDocument.js +205 -140
- package/dist/internal/schema/toJsonSchemaDocument.js.map +1 -1
- package/dist/internal/schema/toRepresentation.js +107 -129
- package/dist/internal/schema/toRepresentation.js.map +1 -1
- package/dist/internal/sql.d.ts +2 -0
- package/dist/internal/sql.d.ts.map +1 -0
- package/dist/internal/sql.js +13 -0
- package/dist/internal/sql.js.map +1 -0
- package/dist/internal/trie.js +42 -13
- package/dist/internal/trie.js.map +1 -1
- package/dist/internal/ulid.js +41 -0
- package/dist/internal/ulid.js.map +1 -1
- package/dist/internal/uuid.js +52 -8
- package/dist/internal/uuid.js.map +1 -1
- package/dist/internal/version.js +1 -1
- package/dist/observability/Otlp.d.ts +15 -4
- package/dist/observability/Otlp.d.ts.map +1 -1
- package/dist/observability/Otlp.js +10 -0
- package/dist/observability/Otlp.js.map +1 -1
- package/dist/observability/OtlpProxy.d.ts +154 -0
- package/dist/observability/OtlpProxy.d.ts.map +1 -0
- package/dist/observability/OtlpProxy.js +235 -0
- package/dist/observability/OtlpProxy.js.map +1 -0
- package/dist/observability/OtlpResource.d.ts +7 -0
- package/dist/observability/OtlpResource.d.ts.map +1 -1
- package/dist/observability/OtlpResource.js +11 -1
- package/dist/observability/OtlpResource.js.map +1 -1
- package/dist/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/observability/OtlpTracer.js +4 -0
- package/dist/observability/OtlpTracer.js.map +1 -1
- package/dist/observability/index.d.ts +5 -0
- package/dist/observability/index.d.ts.map +1 -1
- package/dist/observability/index.js +5 -0
- package/dist/observability/index.js.map +1 -1
- package/dist/persistence/CircuitBreaker.d.ts +897 -0
- package/dist/persistence/CircuitBreaker.d.ts.map +1 -0
- package/dist/persistence/CircuitBreaker.js +1165 -0
- package/dist/persistence/CircuitBreaker.js.map +1 -0
- package/dist/persistence/KeyValueStore.d.ts +47 -2
- package/dist/persistence/KeyValueStore.d.ts.map +1 -1
- package/dist/persistence/KeyValueStore.js +129 -18
- package/dist/persistence/KeyValueStore.js.map +1 -1
- package/dist/persistence/PersistedQueue.d.ts +9 -0
- package/dist/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/persistence/PersistedQueue.js +94 -52
- package/dist/persistence/PersistedQueue.js.map +1 -1
- package/dist/persistence/Persistence.d.ts +10 -4
- package/dist/persistence/Persistence.d.ts.map +1 -1
- package/dist/persistence/Persistence.js +18 -11
- package/dist/persistence/Persistence.js.map +1 -1
- package/dist/persistence/Redis.d.ts +78 -2
- package/dist/persistence/Redis.d.ts.map +1 -1
- package/dist/persistence/Redis.js +62 -7
- package/dist/persistence/Redis.js.map +1 -1
- package/dist/persistence/index.d.ts +5 -0
- package/dist/persistence/index.d.ts.map +1 -1
- package/dist/persistence/index.js +5 -0
- package/dist/persistence/index.js.map +1 -1
- package/dist/process/ChildProcess.d.ts +237 -71
- package/dist/process/ChildProcess.d.ts.map +1 -1
- package/dist/process/ChildProcess.js +56 -158
- package/dist/process/ChildProcess.js.map +1 -1
- package/dist/process/ChildProcessSpawner.d.ts +35 -0
- package/dist/process/ChildProcessSpawner.d.ts.map +1 -1
- package/dist/process/ChildProcessSpawner.js +5 -2
- package/dist/process/ChildProcessSpawner.js.map +1 -1
- package/dist/process/CommandLine.d.ts +294 -0
- package/dist/process/CommandLine.d.ts.map +1 -0
- package/dist/process/CommandLine.js +481 -0
- package/dist/process/CommandLine.js.map +1 -0
- package/dist/process/index.d.ts +5 -0
- package/dist/process/index.d.ts.map +1 -1
- package/dist/process/index.js +5 -0
- package/dist/process/index.js.map +1 -1
- package/dist/reactivity/AsyncResult.d.ts +1 -1
- package/dist/reactivity/AsyncResult.d.ts.map +1 -1
- package/dist/reactivity/Atom.d.ts +2 -1
- package/dist/reactivity/Atom.d.ts.map +1 -1
- package/dist/reactivity/Atom.js +3 -4
- package/dist/reactivity/Atom.js.map +1 -1
- package/dist/reactivity/AtomRegistry.js.map +1 -1
- package/dist/rpc/RpcClient.d.ts +16 -1
- package/dist/rpc/RpcClient.d.ts.map +1 -1
- package/dist/rpc/RpcClient.js +59 -24
- package/dist/rpc/RpcClient.js.map +1 -1
- package/dist/rpc/RpcMessage.d.ts +10 -1
- package/dist/rpc/RpcMessage.d.ts.map +1 -1
- package/dist/rpc/RpcMessage.js +1 -0
- package/dist/rpc/RpcMessage.js.map +1 -1
- package/dist/rpc/RpcSerialization.d.ts +14 -0
- package/dist/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/rpc/RpcSerialization.js +26 -8
- package/dist/rpc/RpcSerialization.js.map +1 -1
- package/dist/rpc/RpcServer.d.ts +31 -0
- package/dist/rpc/RpcServer.d.ts.map +1 -1
- package/dist/rpc/RpcServer.js +139 -56
- package/dist/rpc/RpcServer.js.map +1 -1
- package/dist/rpc/RpcTest.d.ts +1 -0
- package/dist/rpc/RpcTest.d.ts.map +1 -1
- package/dist/rpc/RpcTest.js +1 -0
- package/dist/rpc/RpcTest.js.map +1 -1
- package/dist/schema/Model.d.ts +14 -0
- package/dist/schema/Model.d.ts.map +1 -1
- package/dist/schema/Model.js +18 -3
- package/dist/schema/Model.js.map +1 -1
- package/dist/sql/Migrator.d.ts +2 -20
- package/dist/sql/Migrator.d.ts.map +1 -1
- package/dist/sql/Migrator.js +13 -55
- package/dist/sql/Migrator.js.map +1 -1
- package/dist/sql/MigratorFileSystem.d.ts +21 -0
- package/dist/sql/MigratorFileSystem.d.ts.map +1 -0
- package/dist/sql/MigratorFileSystem.js +57 -0
- package/dist/sql/MigratorFileSystem.js.map +1 -0
- package/dist/sql/SqlClient.d.ts +9 -4
- package/dist/sql/SqlClient.d.ts.map +1 -1
- package/dist/sql/SqlClient.js +13 -10
- package/dist/sql/SqlClient.js.map +1 -1
- package/dist/sql/SqlResolver.d.ts +4 -0
- package/dist/sql/SqlResolver.d.ts.map +1 -1
- package/dist/sql/SqlResolver.js +18 -4
- package/dist/sql/SqlResolver.js.map +1 -1
- package/dist/sql/Statement.d.ts +27 -6
- package/dist/sql/Statement.d.ts.map +1 -1
- package/dist/sql/Statement.js +21 -15
- package/dist/sql/Statement.js.map +1 -1
- package/dist/sql/index.js +1 -1
- package/dist/testing/index.d.ts +0 -5
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +0 -5
- package/dist/testing/index.js.map +1 -1
- package/dist/workflow/DurableDeferred.d.ts.map +1 -1
- package/dist/workflow/DurableDeferred.js +21 -2
- package/dist/workflow/DurableDeferred.js.map +1 -1
- package/dist/workflow/internal/crypto.js +9 -8
- package/dist/workflow/internal/crypto.js.map +1 -1
- package/package.json +3 -1
- package/src/Arbitrary.ts +10 -2
- package/src/BigDecimal.ts +3 -0
- package/src/Channel.ts +64 -29
- package/src/Config.ts +7 -1
- package/src/Context.ts +34 -10
- package/src/Cron.ts +178 -29
- package/src/Data.ts +60 -265
- package/src/Duration.ts +140 -0
- package/src/Effect.ts +915 -86
- package/src/Equal.ts +8 -1
- package/src/Exit.ts +3 -3
- package/src/FileSystem.ts +65 -4
- package/src/Formatter.ts +28 -13
- package/src/Glob.ts +205 -0
- package/src/Hash.ts +4 -1
- package/src/JsonPatch.ts +4 -0
- package/src/JsonSchema.ts +12 -40
- package/src/Match.ts +127 -0
- package/src/Metric.ts +3 -3
- package/src/MutableList.ts +7 -5
- package/src/MutableRef.ts +8 -1
- package/src/PartitionedSemaphore.ts +24 -13
- package/src/Pool.ts +182 -52
- package/src/PubSub.ts +5 -6
- package/src/Random.ts +3 -3
- package/src/RcMap.ts +5 -1
- package/src/Ref.ts +8 -0
- package/src/Schedule.ts +27 -4
- package/src/Schema.ts +1237 -87
- package/src/SchemaAST.ts +20 -20
- package/src/SchemaGetter.ts +27 -11
- package/src/SchemaParser.ts +51 -18
- package/src/SchemaRepresentation.ts +50 -34
- package/src/SchemaTransformation.ts +17 -5
- package/src/ScopedCache.ts +5 -9
- package/src/Semaphore.ts +208 -40
- package/src/Sink.ts +15 -2
- package/src/Stream.ts +48 -22
- package/src/String.ts +3 -0
- package/src/Terminal.ts +19 -1
- package/src/Tracer.ts +15 -1
- package/src/ai/AiError.ts +56 -80
- package/src/ai/Decision.ts +257 -6
- package/src/ai/DecisionModel.ts +171 -28
- package/src/ai/LanguageModel.ts +9 -0
- package/src/ai/McpServer.ts +1283 -299
- package/src/ai/McpTest.ts +380 -0
- package/src/ai/Prompt.ts +65 -0
- package/src/ai/Response.ts +36 -31
- package/src/ai/Tool.ts +65 -10
- package/src/ai/Toolkit.ts +4 -1
- package/src/ai/index.ts +6 -0
- package/src/ai/internal/mcpCore.ts +78 -44
- package/src/ai/internal/mcpProtocol/v2024_11_05.ts +4 -7
- package/src/ai/internal/mcpProtocol/v2025_03_26.ts +4 -7
- package/src/ai/internal/mcpProtocol/v2025_06_18.ts +4 -7
- package/src/ai/internal/mcpProtocol/v2025_11_25.ts +4 -7
- package/src/ai/internal/mcpProtocol/v2026_07_28.ts +15 -10
- package/src/ai/internal/mcpProtocol.ts +29 -0
- package/src/ai/internal/mcpRuntime.ts +9 -5
- package/src/ai/internal/mcpStatefulRuntime.ts +14 -2
- package/src/cli/Argument.ts +21 -0
- package/src/cli/CliError.ts +90 -3
- package/src/cli/CliOutput.ts +300 -55
- package/src/cli/Command.ts +76 -41
- package/src/cli/Completions.ts +51 -0
- package/src/cli/Flag.ts +122 -0
- package/src/cli/GlobalFlag.ts +6 -7
- package/src/cli/HelpDoc.ts +18 -1
- package/src/cli/Param.ts +35 -6
- package/src/cli/Primitive.ts +16 -1
- package/src/cli/Prompt.ts +1 -0
- package/src/cli/TerminalCapabilities.ts +6 -3
- package/src/cli/internal/completions/bash.ts +79 -29
- package/src/cli/internal/help.ts +21 -9
- package/src/cluster/ClusterWorkflowEngine.ts +46 -16
- package/src/cluster/MessageStorage.ts +19 -14
- package/src/cluster/Sharding.ts +176 -47
- package/src/cluster/ShardingConfig.ts +43 -0
- package/src/cluster/SingleRunner.ts +3 -3
- package/src/cluster/Snowflake.ts +3 -7
- package/src/cluster/SqlMessageStorage.ts +49 -17
- package/src/cluster/SqlRunnerStorage.ts +143 -70
- package/src/cluster/internal/entityManager.ts +75 -22
- package/src/crypto/Aead.ts +517 -0
- package/src/crypto/Cipher.ts +326 -0
- package/src/crypto/CryptoError.ts +242 -0
- package/src/crypto/Digest.ts +167 -0
- package/src/crypto/Kdf.ts +315 -0
- package/src/crypto/KeyAgreement.ts +489 -0
- package/src/crypto/KeyFormat.ts +712 -0
- package/src/crypto/KeyWrap.ts +639 -0
- package/src/crypto/Mac.ts +386 -0
- package/src/crypto/SecureRandom.ts +459 -0
- package/src/crypto/Signature.ts +673 -0
- package/src/crypto/WebCrypto.ts +64 -0
- package/src/crypto/index.ts +78 -0
- package/src/crypto/internal/asymmetric.ts +329 -0
- package/src/crypto/internal/chacha.ts +1088 -0
- package/src/crypto/internal/der.ts +110 -0
- package/src/crypto/internal/digest.ts +16 -0
- package/src/crypto/internal/key.ts +235 -0
- package/src/crypto/internal/md5.ts +170 -0
- package/src/crypto/internal/webCrypto.ts +150 -0
- package/src/devtools/DevToolsClient.ts +2 -0
- package/src/encoding/Base64.ts +38 -0
- package/src/encoding/Base64Url.ts +5 -2
- package/src/encoding/Csv.ts +1298 -0
- package/src/encoding/Hex.ts +3 -2
- package/src/encoding/SchemaBinary.ts +40 -4
- package/src/encoding/Sse.ts +4 -3
- package/src/encoding/Toml.ts +117 -35
- package/src/encoding/Yaml.ts +61 -18
- package/src/encoding/index.ts +6 -0
- package/src/eventlog/EventJournal.ts +4 -3
- package/src/eventlog/EventLog.ts +340 -15
- package/src/eventlog/EventLogEncryption.ts +118 -110
- package/src/eventlog/EventLogMessage.ts +273 -1
- package/src/eventlog/EventLogRemote.ts +367 -23
- package/src/eventlog/EventLogServer.ts +23 -8
- package/src/eventlog/EventLogServerEncrypted.ts +1130 -67
- package/src/eventlog/EventLogSessionAuth.ts +56 -70
- package/src/eventlog/EventRow.ts +12 -3
- package/src/eventlog/SqlEventJournal.ts +68 -45
- package/src/eventlog/SqlEventLogServerEncrypted.ts +1244 -136
- package/src/eventlog/SqlEventLogServerUnencrypted.ts +2 -2
- package/src/eventlog/internal/batches.ts +30 -0
- package/src/eventlog/internal/compaction.ts +64 -0
- package/src/eventlog/internal/conflicts.ts +0 -4
- package/src/eventlog/internal/identityRootSecretDerivation.ts +93 -123
- package/src/eventlog/internal/remoteCompaction.ts +92 -0
- package/src/http/Cookies.ts +291 -12
- package/src/http/FetchHttpClient.ts +88 -16
- package/src/http/HttpClient.ts +636 -29
- package/src/http/HttpClientError.ts +35 -1
- package/src/http/HttpClientRequest.ts +21 -10
- package/src/http/HttpClientResponse.ts +3 -2
- package/src/http/HttpMethod.ts +10 -2
- package/src/http/HttpMiddleware.ts +15 -18
- package/src/http/HttpRouter.ts +2 -1
- package/src/http/HttpServerError.ts +2 -2
- package/src/http/HttpServerRequest.ts +101 -30
- package/src/http/HttpServerResponse.ts +3 -2
- package/src/http/HttpStaticServer.ts +51 -22
- package/src/http/HttpTraceContext.ts +7 -4
- package/src/http/MultipartParser/internal/contentType.ts +3 -3
- package/src/http/ProblemDetails.ts +149 -0
- package/src/http/UrlParams.ts +6 -1
- package/src/http/index.ts +6 -0
- package/src/http/internal/compression.ts +4 -5
- package/src/http/internal/decompression.ts +10 -4
- package/src/http/internal/httpBody.ts +10 -2
- package/src/http/internal/urlParams.ts +37 -0
- package/src/http-api/HttpApi.ts +3 -6
- package/src/http-api/HttpApiBuilder.ts +61 -19
- package/src/http-api/HttpApiClient.ts +284 -72
- package/src/http-api/HttpApiEndpoint.ts +135 -35
- package/src/http-api/HttpApiError.ts +250 -0
- package/src/http-api/HttpApiMiddleware.ts +95 -1
- package/src/http-api/HttpApiSchema.ts +236 -52
- package/src/http-api/HttpApiTest.ts +3 -2
- package/src/http-api/OpenApi.ts +20 -17
- package/src/http-api/internal/toCodecHttpProperties.ts +56 -0
- package/src/index.ts +6 -6
- package/src/internal/arbitrary/runner.ts +133 -36
- package/src/internal/core.ts +2 -0
- package/src/internal/effect.ts +58 -34
- package/src/internal/equal.ts +17 -0
- package/src/internal/glob.ts +736 -0
- package/src/internal/jsonSchema.ts +27 -0
- package/src/internal/matcher.ts +18 -1
- package/src/internal/persistence.ts +11 -0
- package/src/internal/rcRef.ts +4 -1
- package/src/internal/schema/compilerRegistry.ts +6 -1
- package/src/internal/schema/content.ts +18 -0
- package/src/internal/schema/fromJsonSchemaDocument.ts +228 -190
- package/src/internal/schema/fromRepresentation.ts +2 -1
- package/src/internal/schema/standardSchema.ts +2 -2
- package/src/internal/schema/toCodeDocument.ts +11 -7
- package/src/internal/schema/toCodec.ts +26 -22
- package/src/internal/schema/toJsonSchemaDocument.ts +189 -167
- package/src/internal/schema/toRepresentation.ts +122 -140
- package/src/internal/sql.ts +14 -0
- package/src/internal/trie.ts +43 -14
- package/src/internal/ulid.ts +44 -0
- package/src/internal/uuid.ts +57 -16
- package/src/internal/version.ts +1 -1
- package/src/observability/Otlp.ts +21 -4
- package/src/observability/OtlpProxy.ts +314 -0
- package/src/observability/OtlpResource.ts +9 -1
- package/src/observability/OtlpTracer.ts +4 -0
- package/src/observability/index.ts +6 -0
- package/src/persistence/CircuitBreaker.ts +1678 -0
- package/src/persistence/KeyValueStore.ts +219 -22
- package/src/persistence/PersistedQueue.ts +128 -59
- package/src/persistence/Persistence.ts +20 -13
- package/src/persistence/Redis.ts +129 -8
- package/src/persistence/index.ts +6 -0
- package/src/process/ChildProcess.ts +285 -264
- package/src/process/ChildProcessSpawner.ts +46 -2
- package/src/process/CommandLine.ts +630 -0
- package/src/process/index.ts +6 -0
- package/src/reactivity/AsyncResult.ts +1 -1
- package/src/reactivity/Atom.ts +5 -5
- package/src/reactivity/AtomRegistry.ts +1 -1
- package/src/rpc/RpcClient.ts +75 -36
- package/src/rpc/RpcMessage.ts +10 -1
- package/src/rpc/RpcSerialization.ts +35 -9
- package/src/rpc/RpcServer.ts +176 -63
- package/src/rpc/RpcTest.ts +3 -0
- package/src/schema/Model.ts +26 -3
- package/src/sql/Migrator.ts +15 -69
- package/src/sql/MigratorFileSystem.ts +71 -0
- package/src/sql/SqlClient.ts +13 -20
- package/src/sql/SqlResolver.ts +23 -9
- package/src/sql/Statement.ts +38 -9
- package/src/sql/index.ts +1 -1
- package/src/testing/index.ts +0 -6
- package/src/workflow/DurableDeferred.ts +23 -6
- package/src/workflow/internal/crypto.ts +15 -11
- package/dist/Crypto.d.ts +0 -244
- package/dist/Crypto.d.ts.map +0 -1
- package/dist/Crypto.js +0 -139
- package/dist/Crypto.js.map +0 -1
- package/dist/testing/TestCrypto.d.ts +0 -73
- package/dist/testing/TestCrypto.d.ts.map +0 -1
- package/dist/testing/TestCrypto.js +0 -87
- package/dist/testing/TestCrypto.js.map +0 -1
- package/src/Crypto.ts +0 -347
- package/src/testing/TestCrypto.ts +0 -94
package/src/http/HttpClient.ts
CHANGED
|
@@ -25,6 +25,7 @@ import * as Inspectable from "../Inspectable.ts"
|
|
|
25
25
|
import { getStackTraceLimit, setStackTraceLimit } from "../internal/stackTraceLimit.ts"
|
|
26
26
|
import * as Layer from "../Layer.ts"
|
|
27
27
|
import * as Option from "../Option.ts"
|
|
28
|
+
import type * as CircuitBreaker from "../persistence/CircuitBreaker.ts"
|
|
28
29
|
import type * as RateLimiter from "../persistence/RateLimiter.ts"
|
|
29
30
|
import { type Pipeable, pipeArguments } from "../Pipeable.ts"
|
|
30
31
|
import * as Predicate from "../Predicate.ts"
|
|
@@ -836,12 +837,11 @@ export const make = (
|
|
|
836
837
|
fiber.getRef(TracerDisabledWhen)(request)
|
|
837
838
|
if (tracerDisabled) {
|
|
838
839
|
const effect = f(request, url, controller.signal, fiber as any)
|
|
839
|
-
if (scopedController) return effect
|
|
840
|
+
if (scopedController) return Effect.map(effect, (response) => trackResponse(response, controller, true))
|
|
840
841
|
return Effect.uninterruptibleMask((restore) =>
|
|
841
842
|
Effect.matchCauseEffect(restore(effect), {
|
|
842
843
|
onSuccess(response) {
|
|
843
|
-
|
|
844
|
-
return Effect.succeed(new InterruptibleResponse(response, controller))
|
|
844
|
+
return Effect.succeed(trackResponse(response, controller, false))
|
|
845
845
|
},
|
|
846
846
|
onFailure(cause) {
|
|
847
847
|
if (Cause.hasInterrupts(cause)) {
|
|
@@ -882,9 +882,7 @@ export const make = (
|
|
|
882
882
|
endSpanWithStatusError(fiber, span, request, response)
|
|
883
883
|
}
|
|
884
884
|
|
|
885
|
-
|
|
886
|
-
responseRegistry.register(response, controller)
|
|
887
|
-
return Effect.succeed(new InterruptibleResponse(response, controller))
|
|
885
|
+
return Effect.succeed(trackResponse(response, controller, scopedController !== undefined))
|
|
888
886
|
},
|
|
889
887
|
onFailure(cause) {
|
|
890
888
|
if (!scopedController && Cause.hasInterrupts(cause)) {
|
|
@@ -1678,6 +1676,515 @@ export const withRateLimiter: {
|
|
|
1678
1676
|
})
|
|
1679
1677
|
})
|
|
1680
1678
|
|
|
1679
|
+
/**
|
|
1680
|
+
* Namespace containing configuration types for `withCircuitBreaker`.
|
|
1681
|
+
*
|
|
1682
|
+
* @stability experimental
|
|
1683
|
+
* @since 4.0.6
|
|
1684
|
+
*/
|
|
1685
|
+
export declare namespace WithCircuitBreaker {
|
|
1686
|
+
/**
|
|
1687
|
+
* Options used to configure `withCircuitBreaker`.
|
|
1688
|
+
*
|
|
1689
|
+
* @stability experimental
|
|
1690
|
+
* @category circuit breaking
|
|
1691
|
+
* @since 4.0.6
|
|
1692
|
+
*/
|
|
1693
|
+
export interface Options<E, R2 = never> {
|
|
1694
|
+
/**
|
|
1695
|
+
* The `CircuitBreaker` service that guards each request.
|
|
1696
|
+
*/
|
|
1697
|
+
readonly breaker: CircuitBreaker.CircuitBreaker
|
|
1698
|
+
/**
|
|
1699
|
+
* The circuit key for a request. Requests with the same key share one
|
|
1700
|
+
* circuit. Defaults to the request origin, falling back to the raw request
|
|
1701
|
+
* URL when it cannot be parsed.
|
|
1702
|
+
*/
|
|
1703
|
+
readonly key?: string | ((request: HttpClientRequest.HttpClientRequest) => string) | undefined
|
|
1704
|
+
/**
|
|
1705
|
+
* Classifies the `Exit` of each request that the breaker admitted.
|
|
1706
|
+
* Defaults to `circuitBreakerClassifier`.
|
|
1707
|
+
*/
|
|
1708
|
+
readonly classify?:
|
|
1709
|
+
| ((
|
|
1710
|
+
exit: Exit.Exit<HttpClientResponse.HttpClientResponse, E>
|
|
1711
|
+
) => CircuitBreaker.Outcome | Effect.Effect<CircuitBreaker.Outcome, never, R2>)
|
|
1712
|
+
| undefined
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1716
|
+
/**
|
|
1717
|
+
* Guards requests with a `CircuitBreaker`.
|
|
1718
|
+
*
|
|
1719
|
+
* **Details**
|
|
1720
|
+
*
|
|
1721
|
+
* Requests are keyed by origin unless `key` is set, and classified with
|
|
1722
|
+
* `circuitBreakerClassifier` unless `classify` is set. A rejected request
|
|
1723
|
+
* fails with `CircuitBreakerError` without reaching the wrapped client.
|
|
1724
|
+
*
|
|
1725
|
+
* Apply it after `withRateLimiter` and `retryTransient`, so the breaker sees
|
|
1726
|
+
* one outcome per call and an open circuit skips the retry loop.
|
|
1727
|
+
* `retryTransient` never retries a `CircuitBreakerError`. A custom `classify`
|
|
1728
|
+
* can delegate the cases it doesn't handle to `circuitBreakerClassifier`.
|
|
1729
|
+
*
|
|
1730
|
+
* **Gotchas**
|
|
1731
|
+
*
|
|
1732
|
+
* - The breaker only sees the response headers. To count an error in the
|
|
1733
|
+
* body, lift it into the error channel below the breaker with
|
|
1734
|
+
* `transformResponse` and count it in `classify`.
|
|
1735
|
+
* - `withRateLimiter` retries `429` without limit by default, which can hold
|
|
1736
|
+
* the probe slot for minutes. Set its `times`.
|
|
1737
|
+
* - A rejected request has no client span. The rejection fails the caller's
|
|
1738
|
+
* span instead.
|
|
1739
|
+
*
|
|
1740
|
+
* **Example** (Guarding an API in the recommended order)
|
|
1741
|
+
*
|
|
1742
|
+
* ```ts import.meta.vitest
|
|
1743
|
+
* import { Effect, Layer, Ref, Schedule } from "effect"
|
|
1744
|
+
* import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http"
|
|
1745
|
+
* import { CircuitBreaker, RateLimiter } from "effect/persistence"
|
|
1746
|
+
*
|
|
1747
|
+
* const program = Effect.gen(function*() {
|
|
1748
|
+
* const requests = yield* Ref.make(0)
|
|
1749
|
+
* // A dependency that always answers 503.
|
|
1750
|
+
* const unavailable = HttpClient.make((request) =>
|
|
1751
|
+
* Effect.as(Ref.update(requests, (n) => n + 1), HttpClientResponse.fromWeb(request, new Response(null, { status: 503 })))
|
|
1752
|
+
* )
|
|
1753
|
+
*
|
|
1754
|
+
* const breaker = yield* CircuitBreaker.make({
|
|
1755
|
+
* tripPolicy: CircuitBreaker.consecutive(1),
|
|
1756
|
+
* openDuration: "30 seconds"
|
|
1757
|
+
* })
|
|
1758
|
+
* const client = unavailable.pipe(
|
|
1759
|
+
* HttpClient.withRateLimiter({
|
|
1760
|
+
* limiter: yield* RateLimiter.RateLimiter,
|
|
1761
|
+
* key: "inventory",
|
|
1762
|
+
* limit: 100,
|
|
1763
|
+
* window: "1 second",
|
|
1764
|
+
* times: 3
|
|
1765
|
+
* }),
|
|
1766
|
+
* HttpClient.retryTransient({ times: 2, schedule: Schedule.exponential("1 millis") }),
|
|
1767
|
+
* HttpClient.withCircuitBreaker({ breaker })
|
|
1768
|
+
* )
|
|
1769
|
+
*
|
|
1770
|
+
* // Three attempts, then the breaker records one failure and opens.
|
|
1771
|
+
* yield* client.execute(HttpClientRequest.get("http://inventory.test/items"))
|
|
1772
|
+
* // Rejected before the retry loop starts, so no further request is sent.
|
|
1773
|
+
* const rejected = yield* Effect.flip(client.execute(HttpClientRequest.get("http://inventory.test/items")))
|
|
1774
|
+
*
|
|
1775
|
+
* return [yield* Ref.get(requests), rejected._tag]
|
|
1776
|
+
* }).pipe(
|
|
1777
|
+
* Effect.scoped,
|
|
1778
|
+
* Effect.provide(Layer.merge(
|
|
1779
|
+
* CircuitBreaker.layerStoreMemory(),
|
|
1780
|
+
* RateLimiter.layer.pipe(Layer.provide(RateLimiter.layerStoreMemory))
|
|
1781
|
+
* ))
|
|
1782
|
+
* )
|
|
1783
|
+
*
|
|
1784
|
+
* await Effect.runPromise(program) // => [3, "CircuitBreakerError"]
|
|
1785
|
+
* ```
|
|
1786
|
+
*
|
|
1787
|
+
* **Example** (Counting an error in the body as a failure)
|
|
1788
|
+
*
|
|
1789
|
+
* This API answers `200` with `{ "status": "degraded" }` when it is failing.
|
|
1790
|
+
*
|
|
1791
|
+
* ```ts import.meta.vitest
|
|
1792
|
+
* import { Data, Effect, Exit, Option } from "effect"
|
|
1793
|
+
* import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http"
|
|
1794
|
+
* import { CircuitBreaker } from "effect/persistence"
|
|
1795
|
+
*
|
|
1796
|
+
* class Degraded extends Data.TaggedError("Degraded") {}
|
|
1797
|
+
*
|
|
1798
|
+
* const degraded = HttpClient.make((request) =>
|
|
1799
|
+
* Effect.succeed(HttpClientResponse.fromWeb(request, Response.json({ status: "degraded" })))
|
|
1800
|
+
* )
|
|
1801
|
+
*
|
|
1802
|
+
* const program = Effect.gen(function*() {
|
|
1803
|
+
* const breaker = yield* CircuitBreaker.make({
|
|
1804
|
+
* tripPolicy: CircuitBreaker.consecutive(1),
|
|
1805
|
+
* openDuration: "30 seconds"
|
|
1806
|
+
* })
|
|
1807
|
+
* const client = degraded.pipe(
|
|
1808
|
+
* HttpClient.transformResponse(Effect.flatMap((response) =>
|
|
1809
|
+
* Effect.flatMap(response.json, (body) =>
|
|
1810
|
+
* typeof body === "object" && body !== null && "status" in body && body.status === "degraded"
|
|
1811
|
+
* ? Effect.fail(new Degraded())
|
|
1812
|
+
* : Effect.succeed(response))
|
|
1813
|
+
* )),
|
|
1814
|
+
* HttpClient.withCircuitBreaker({
|
|
1815
|
+
* breaker,
|
|
1816
|
+
* classify: (exit) =>
|
|
1817
|
+
* Option.exists(Exit.findErrorOption(exit), (error) => error._tag === "Degraded")
|
|
1818
|
+
* ? CircuitBreaker.failure()
|
|
1819
|
+
* : HttpClient.circuitBreakerClassifier(exit)
|
|
1820
|
+
* })
|
|
1821
|
+
* )
|
|
1822
|
+
*
|
|
1823
|
+
* yield* Effect.flip(client.get("http://status.test/"))
|
|
1824
|
+
* const state = yield* breaker.state("http://status.test")
|
|
1825
|
+
* return state._tag
|
|
1826
|
+
* }).pipe(Effect.scoped, Effect.provide(CircuitBreaker.layerStoreMemory()))
|
|
1827
|
+
*
|
|
1828
|
+
* await Effect.runPromise(program) // => "Open"
|
|
1829
|
+
* ```
|
|
1830
|
+
*
|
|
1831
|
+
* @stability experimental
|
|
1832
|
+
* @category circuit breaking
|
|
1833
|
+
* @since 4.0.6
|
|
1834
|
+
*/
|
|
1835
|
+
export const withCircuitBreaker: {
|
|
1836
|
+
/**
|
|
1837
|
+
* Guards requests with a `CircuitBreaker`.
|
|
1838
|
+
*
|
|
1839
|
+
* **Details**
|
|
1840
|
+
*
|
|
1841
|
+
* Requests are keyed by origin unless `key` is set, and classified with
|
|
1842
|
+
* `circuitBreakerClassifier` unless `classify` is set. A rejected request
|
|
1843
|
+
* fails with `CircuitBreakerError` without reaching the wrapped client.
|
|
1844
|
+
*
|
|
1845
|
+
* Apply it after `withRateLimiter` and `retryTransient`, so the breaker sees
|
|
1846
|
+
* one outcome per call and an open circuit skips the retry loop.
|
|
1847
|
+
* `retryTransient` never retries a `CircuitBreakerError`. A custom `classify`
|
|
1848
|
+
* can delegate the cases it doesn't handle to `circuitBreakerClassifier`.
|
|
1849
|
+
*
|
|
1850
|
+
* **Gotchas**
|
|
1851
|
+
*
|
|
1852
|
+
* - The breaker only sees the response headers. To count an error in the
|
|
1853
|
+
* body, lift it into the error channel below the breaker with
|
|
1854
|
+
* `transformResponse` and count it in `classify`.
|
|
1855
|
+
* - `withRateLimiter` retries `429` without limit by default, which can hold
|
|
1856
|
+
* the probe slot for minutes. Set its `times`.
|
|
1857
|
+
* - A rejected request has no client span. The rejection fails the caller's
|
|
1858
|
+
* span instead.
|
|
1859
|
+
*
|
|
1860
|
+
* **Example** (Guarding an API in the recommended order)
|
|
1861
|
+
*
|
|
1862
|
+
* ```ts import.meta.vitest
|
|
1863
|
+
* import { Effect, Layer, Ref, Schedule } from "effect"
|
|
1864
|
+
* import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http"
|
|
1865
|
+
* import { CircuitBreaker, RateLimiter } from "effect/persistence"
|
|
1866
|
+
*
|
|
1867
|
+
* const program = Effect.gen(function*() {
|
|
1868
|
+
* const requests = yield* Ref.make(0)
|
|
1869
|
+
* // A dependency that always answers 503.
|
|
1870
|
+
* const unavailable = HttpClient.make((request) =>
|
|
1871
|
+
* Effect.as(Ref.update(requests, (n) => n + 1), HttpClientResponse.fromWeb(request, new Response(null, { status: 503 })))
|
|
1872
|
+
* )
|
|
1873
|
+
*
|
|
1874
|
+
* const breaker = yield* CircuitBreaker.make({
|
|
1875
|
+
* tripPolicy: CircuitBreaker.consecutive(1),
|
|
1876
|
+
* openDuration: "30 seconds"
|
|
1877
|
+
* })
|
|
1878
|
+
* const client = unavailable.pipe(
|
|
1879
|
+
* HttpClient.withRateLimiter({
|
|
1880
|
+
* limiter: yield* RateLimiter.RateLimiter,
|
|
1881
|
+
* key: "inventory",
|
|
1882
|
+
* limit: 100,
|
|
1883
|
+
* window: "1 second",
|
|
1884
|
+
* times: 3
|
|
1885
|
+
* }),
|
|
1886
|
+
* HttpClient.retryTransient({ times: 2, schedule: Schedule.exponential("1 millis") }),
|
|
1887
|
+
* HttpClient.withCircuitBreaker({ breaker })
|
|
1888
|
+
* )
|
|
1889
|
+
*
|
|
1890
|
+
* // Three attempts, then the breaker records one failure and opens.
|
|
1891
|
+
* yield* client.execute(HttpClientRequest.get("http://inventory.test/items"))
|
|
1892
|
+
* // Rejected before the retry loop starts, so no further request is sent.
|
|
1893
|
+
* const rejected = yield* Effect.flip(client.execute(HttpClientRequest.get("http://inventory.test/items")))
|
|
1894
|
+
*
|
|
1895
|
+
* return [yield* Ref.get(requests), rejected._tag]
|
|
1896
|
+
* }).pipe(
|
|
1897
|
+
* Effect.scoped,
|
|
1898
|
+
* Effect.provide(Layer.merge(
|
|
1899
|
+
* CircuitBreaker.layerStoreMemory(),
|
|
1900
|
+
* RateLimiter.layer.pipe(Layer.provide(RateLimiter.layerStoreMemory))
|
|
1901
|
+
* ))
|
|
1902
|
+
* )
|
|
1903
|
+
*
|
|
1904
|
+
* await Effect.runPromise(program) // => [3, "CircuitBreakerError"]
|
|
1905
|
+
* ```
|
|
1906
|
+
*
|
|
1907
|
+
* **Example** (Counting an error in the body as a failure)
|
|
1908
|
+
*
|
|
1909
|
+
* This API answers `200` with `{ "status": "degraded" }` when it is failing.
|
|
1910
|
+
*
|
|
1911
|
+
* ```ts import.meta.vitest
|
|
1912
|
+
* import { Data, Effect, Exit, Option } from "effect"
|
|
1913
|
+
* import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http"
|
|
1914
|
+
* import { CircuitBreaker } from "effect/persistence"
|
|
1915
|
+
*
|
|
1916
|
+
* class Degraded extends Data.TaggedError("Degraded") {}
|
|
1917
|
+
*
|
|
1918
|
+
* const degraded = HttpClient.make((request) =>
|
|
1919
|
+
* Effect.succeed(HttpClientResponse.fromWeb(request, Response.json({ status: "degraded" })))
|
|
1920
|
+
* )
|
|
1921
|
+
*
|
|
1922
|
+
* const program = Effect.gen(function*() {
|
|
1923
|
+
* const breaker = yield* CircuitBreaker.make({
|
|
1924
|
+
* tripPolicy: CircuitBreaker.consecutive(1),
|
|
1925
|
+
* openDuration: "30 seconds"
|
|
1926
|
+
* })
|
|
1927
|
+
* const client = degraded.pipe(
|
|
1928
|
+
* HttpClient.transformResponse(Effect.flatMap((response) =>
|
|
1929
|
+
* Effect.flatMap(response.json, (body) =>
|
|
1930
|
+
* typeof body === "object" && body !== null && "status" in body && body.status === "degraded"
|
|
1931
|
+
* ? Effect.fail(new Degraded())
|
|
1932
|
+
* : Effect.succeed(response))
|
|
1933
|
+
* )),
|
|
1934
|
+
* HttpClient.withCircuitBreaker({
|
|
1935
|
+
* breaker,
|
|
1936
|
+
* classify: (exit) =>
|
|
1937
|
+
* Option.exists(Exit.findErrorOption(exit), (error) => error._tag === "Degraded")
|
|
1938
|
+
* ? CircuitBreaker.failure()
|
|
1939
|
+
* : HttpClient.circuitBreakerClassifier(exit)
|
|
1940
|
+
* })
|
|
1941
|
+
* )
|
|
1942
|
+
*
|
|
1943
|
+
* yield* Effect.flip(client.get("http://status.test/"))
|
|
1944
|
+
* const state = yield* breaker.state("http://status.test")
|
|
1945
|
+
* return state._tag
|
|
1946
|
+
* }).pipe(Effect.scoped, Effect.provide(CircuitBreaker.layerStoreMemory()))
|
|
1947
|
+
*
|
|
1948
|
+
* await Effect.runPromise(program) // => "Open"
|
|
1949
|
+
* ```
|
|
1950
|
+
*
|
|
1951
|
+
* @stability experimental
|
|
1952
|
+
* @category circuit breaking
|
|
1953
|
+
* @since 4.0.6
|
|
1954
|
+
*/
|
|
1955
|
+
<E, R2 = never>(options: WithCircuitBreaker.Options<E, R2>): <R>(
|
|
1956
|
+
self: HttpClient.With<E, R>
|
|
1957
|
+
) => HttpClient.With<E | CircuitBreaker.CircuitBreakerError, R | R2>
|
|
1958
|
+
/**
|
|
1959
|
+
* Guards requests with a `CircuitBreaker`.
|
|
1960
|
+
*
|
|
1961
|
+
* **Details**
|
|
1962
|
+
*
|
|
1963
|
+
* Requests are keyed by origin unless `key` is set, and classified with
|
|
1964
|
+
* `circuitBreakerClassifier` unless `classify` is set. A rejected request
|
|
1965
|
+
* fails with `CircuitBreakerError` without reaching the wrapped client.
|
|
1966
|
+
*
|
|
1967
|
+
* Apply it after `withRateLimiter` and `retryTransient`, so the breaker sees
|
|
1968
|
+
* one outcome per call and an open circuit skips the retry loop.
|
|
1969
|
+
* `retryTransient` never retries a `CircuitBreakerError`. A custom `classify`
|
|
1970
|
+
* can delegate the cases it doesn't handle to `circuitBreakerClassifier`.
|
|
1971
|
+
*
|
|
1972
|
+
* **Gotchas**
|
|
1973
|
+
*
|
|
1974
|
+
* - The breaker only sees the response headers. To count an error in the
|
|
1975
|
+
* body, lift it into the error channel below the breaker with
|
|
1976
|
+
* `transformResponse` and count it in `classify`.
|
|
1977
|
+
* - `withRateLimiter` retries `429` without limit by default, which can hold
|
|
1978
|
+
* the probe slot for minutes. Set its `times`.
|
|
1979
|
+
* - A rejected request has no client span. The rejection fails the caller's
|
|
1980
|
+
* span instead.
|
|
1981
|
+
*
|
|
1982
|
+
* **Example** (Guarding an API in the recommended order)
|
|
1983
|
+
*
|
|
1984
|
+
* ```ts import.meta.vitest
|
|
1985
|
+
* import { Effect, Layer, Ref, Schedule } from "effect"
|
|
1986
|
+
* import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http"
|
|
1987
|
+
* import { CircuitBreaker, RateLimiter } from "effect/persistence"
|
|
1988
|
+
*
|
|
1989
|
+
* const program = Effect.gen(function*() {
|
|
1990
|
+
* const requests = yield* Ref.make(0)
|
|
1991
|
+
* // A dependency that always answers 503.
|
|
1992
|
+
* const unavailable = HttpClient.make((request) =>
|
|
1993
|
+
* Effect.as(Ref.update(requests, (n) => n + 1), HttpClientResponse.fromWeb(request, new Response(null, { status: 503 })))
|
|
1994
|
+
* )
|
|
1995
|
+
*
|
|
1996
|
+
* const breaker = yield* CircuitBreaker.make({
|
|
1997
|
+
* tripPolicy: CircuitBreaker.consecutive(1),
|
|
1998
|
+
* openDuration: "30 seconds"
|
|
1999
|
+
* })
|
|
2000
|
+
* const client = unavailable.pipe(
|
|
2001
|
+
* HttpClient.withRateLimiter({
|
|
2002
|
+
* limiter: yield* RateLimiter.RateLimiter,
|
|
2003
|
+
* key: "inventory",
|
|
2004
|
+
* limit: 100,
|
|
2005
|
+
* window: "1 second",
|
|
2006
|
+
* times: 3
|
|
2007
|
+
* }),
|
|
2008
|
+
* HttpClient.retryTransient({ times: 2, schedule: Schedule.exponential("1 millis") }),
|
|
2009
|
+
* HttpClient.withCircuitBreaker({ breaker })
|
|
2010
|
+
* )
|
|
2011
|
+
*
|
|
2012
|
+
* // Three attempts, then the breaker records one failure and opens.
|
|
2013
|
+
* yield* client.execute(HttpClientRequest.get("http://inventory.test/items"))
|
|
2014
|
+
* // Rejected before the retry loop starts, so no further request is sent.
|
|
2015
|
+
* const rejected = yield* Effect.flip(client.execute(HttpClientRequest.get("http://inventory.test/items")))
|
|
2016
|
+
*
|
|
2017
|
+
* return [yield* Ref.get(requests), rejected._tag]
|
|
2018
|
+
* }).pipe(
|
|
2019
|
+
* Effect.scoped,
|
|
2020
|
+
* Effect.provide(Layer.merge(
|
|
2021
|
+
* CircuitBreaker.layerStoreMemory(),
|
|
2022
|
+
* RateLimiter.layer.pipe(Layer.provide(RateLimiter.layerStoreMemory))
|
|
2023
|
+
* ))
|
|
2024
|
+
* )
|
|
2025
|
+
*
|
|
2026
|
+
* await Effect.runPromise(program) // => [3, "CircuitBreakerError"]
|
|
2027
|
+
* ```
|
|
2028
|
+
*
|
|
2029
|
+
* **Example** (Counting an error in the body as a failure)
|
|
2030
|
+
*
|
|
2031
|
+
* This API answers `200` with `{ "status": "degraded" }` when it is failing.
|
|
2032
|
+
*
|
|
2033
|
+
* ```ts import.meta.vitest
|
|
2034
|
+
* import { Data, Effect, Exit, Option } from "effect"
|
|
2035
|
+
* import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http"
|
|
2036
|
+
* import { CircuitBreaker } from "effect/persistence"
|
|
2037
|
+
*
|
|
2038
|
+
* class Degraded extends Data.TaggedError("Degraded") {}
|
|
2039
|
+
*
|
|
2040
|
+
* const degraded = HttpClient.make((request) =>
|
|
2041
|
+
* Effect.succeed(HttpClientResponse.fromWeb(request, Response.json({ status: "degraded" })))
|
|
2042
|
+
* )
|
|
2043
|
+
*
|
|
2044
|
+
* const program = Effect.gen(function*() {
|
|
2045
|
+
* const breaker = yield* CircuitBreaker.make({
|
|
2046
|
+
* tripPolicy: CircuitBreaker.consecutive(1),
|
|
2047
|
+
* openDuration: "30 seconds"
|
|
2048
|
+
* })
|
|
2049
|
+
* const client = degraded.pipe(
|
|
2050
|
+
* HttpClient.transformResponse(Effect.flatMap((response) =>
|
|
2051
|
+
* Effect.flatMap(response.json, (body) =>
|
|
2052
|
+
* typeof body === "object" && body !== null && "status" in body && body.status === "degraded"
|
|
2053
|
+
* ? Effect.fail(new Degraded())
|
|
2054
|
+
* : Effect.succeed(response))
|
|
2055
|
+
* )),
|
|
2056
|
+
* HttpClient.withCircuitBreaker({
|
|
2057
|
+
* breaker,
|
|
2058
|
+
* classify: (exit) =>
|
|
2059
|
+
* Option.exists(Exit.findErrorOption(exit), (error) => error._tag === "Degraded")
|
|
2060
|
+
* ? CircuitBreaker.failure()
|
|
2061
|
+
* : HttpClient.circuitBreakerClassifier(exit)
|
|
2062
|
+
* })
|
|
2063
|
+
* )
|
|
2064
|
+
*
|
|
2065
|
+
* yield* Effect.flip(client.get("http://status.test/"))
|
|
2066
|
+
* const state = yield* breaker.state("http://status.test")
|
|
2067
|
+
* return state._tag
|
|
2068
|
+
* }).pipe(Effect.scoped, Effect.provide(CircuitBreaker.layerStoreMemory()))
|
|
2069
|
+
*
|
|
2070
|
+
* await Effect.runPromise(program) // => "Open"
|
|
2071
|
+
* ```
|
|
2072
|
+
*
|
|
2073
|
+
* @stability experimental
|
|
2074
|
+
* @category circuit breaking
|
|
2075
|
+
* @since 4.0.6
|
|
2076
|
+
*/
|
|
2077
|
+
<E, R, R2 = never>(self: HttpClient.With<E, R>, options: WithCircuitBreaker.Options<E, R2>): HttpClient.With<E | CircuitBreaker.CircuitBreakerError, R | R2>
|
|
2078
|
+
} = dual(2, <E, R, R2>(
|
|
2079
|
+
self: HttpClient.With<E, R>,
|
|
2080
|
+
options: WithCircuitBreaker.Options<E, R2>
|
|
2081
|
+
): HttpClient.With<E | CircuitBreaker.CircuitBreakerError, R | R2> => {
|
|
2082
|
+
const keyOption = options.key
|
|
2083
|
+
const resolveKey: (request: HttpClientRequest.HttpClientRequest) => string = typeof keyOption === "function"
|
|
2084
|
+
? keyOption
|
|
2085
|
+
: keyOption === undefined
|
|
2086
|
+
? requestOrigin
|
|
2087
|
+
: constant(keyOption)
|
|
2088
|
+
const classify = options.classify ?? circuitBreakerClassifier
|
|
2089
|
+
return transform(self, (effect, request) => options.breaker.execute(effect, { key: resolveKey(request), classify }))
|
|
2090
|
+
})
|
|
2091
|
+
|
|
2092
|
+
const requestOrigin = (request: HttpClientRequest.HttpClientRequest): string =>
|
|
2093
|
+
Option.match(HttpClientRequest.toUrl(request), {
|
|
2094
|
+
onNone: () => request.url,
|
|
2095
|
+
onSome: (url) => url.origin
|
|
2096
|
+
})
|
|
2097
|
+
|
|
2098
|
+
/**
|
|
2099
|
+
* The default `withCircuitBreaker` classifier.
|
|
2100
|
+
*
|
|
2101
|
+
* **Details**
|
|
2102
|
+
*
|
|
2103
|
+
* - Failure: status 408, 500, 502, 503 or 504, returned or wrapped in a
|
|
2104
|
+
* `StatusCodeError`, and any `TransportError` or `Cause.TimeoutError`.
|
|
2105
|
+
* - Success: any other response, including other 4xx, since the dependency
|
|
2106
|
+
* answered.
|
|
2107
|
+
* - Ignored: status 429 (left to `withRateLimiter`), `EncodeError`,
|
|
2108
|
+
* `InvalidUrlError`, `DecodeError`, `EmptyBodyError`, unknown typed errors
|
|
2109
|
+
* and defects. HttpClient errors are typed, so a defect here is a bug in
|
|
2110
|
+
* the caller.
|
|
2111
|
+
*
|
|
2112
|
+
* When a cause holds several errors, a failure beats a success and a success
|
|
2113
|
+
* beats an ignored outcome. A failure carries the longest `Retry-After` it
|
|
2114
|
+
* saw. The result is an `Effect` only because parsing an HTTP-date
|
|
2115
|
+
* `Retry-After` reads `Clock`.
|
|
2116
|
+
*
|
|
2117
|
+
* **Gotchas**
|
|
2118
|
+
*
|
|
2119
|
+
* `TransportError` also covers client-side refusals, which count as failures.
|
|
2120
|
+
*
|
|
2121
|
+
* @stability experimental
|
|
2122
|
+
* @category circuit breaking
|
|
2123
|
+
* @since 4.0.6
|
|
2124
|
+
*/
|
|
2125
|
+
export const circuitBreakerClassifier = <E>(
|
|
2126
|
+
exit: Exit.Exit<HttpClientResponse.HttpClientResponse, E>
|
|
2127
|
+
): Effect.Effect<CircuitBreaker.Outcome> =>
|
|
2128
|
+
Effect.clockWith((clock) => Effect.succeed(classifyCircuitBreakerExit(exit, clock.currentTimeMillisUnsafe())))
|
|
2129
|
+
|
|
2130
|
+
const classifyCircuitBreakerExit = <E>(
|
|
2131
|
+
exit: Exit.Exit<HttpClientResponse.HttpClientResponse, E>,
|
|
2132
|
+
nowMillis: number
|
|
2133
|
+
): CircuitBreaker.Outcome => {
|
|
2134
|
+
if (Exit.isSuccess(exit)) {
|
|
2135
|
+
const outcome = circuitBreakerStatusOutcome(exit.value.status)
|
|
2136
|
+
return outcome === "Failure" ? circuitBreakerFailure(retryAfterOf(exit.value, nowMillis)) : { _tag: outcome }
|
|
2137
|
+
}
|
|
2138
|
+
let failed = false
|
|
2139
|
+
let succeeded = false
|
|
2140
|
+
let retryAfter: Duration.Duration | undefined
|
|
2141
|
+
for (const reason of exit.cause.reasons) {
|
|
2142
|
+
if (!Cause.isFailReason(reason)) {
|
|
2143
|
+
continue
|
|
2144
|
+
}
|
|
2145
|
+
const outcome = circuitBreakerErrorOutcome(reason.error)
|
|
2146
|
+
if (outcome === "Failure") {
|
|
2147
|
+
failed = true
|
|
2148
|
+
const hint = retryAfterOf(reason.error, nowMillis)
|
|
2149
|
+
if (hint !== undefined) {
|
|
2150
|
+
retryAfter = retryAfter === undefined ? hint : Duration.max(retryAfter, hint)
|
|
2151
|
+
}
|
|
2152
|
+
} else if (outcome === "Success") {
|
|
2153
|
+
succeeded = true
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
return failed ? circuitBreakerFailure(retryAfter) : { _tag: succeeded ? "Success" : "Ignored" }
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2159
|
+
const circuitBreakerFailure = (retryAfter: Duration.Duration | undefined): CircuitBreaker.Outcome => ({
|
|
2160
|
+
_tag: "Failure",
|
|
2161
|
+
retryAfter
|
|
2162
|
+
})
|
|
2163
|
+
|
|
2164
|
+
const circuitBreakerErrorOutcome = (error: unknown): CircuitBreaker.Outcome["_tag"] => {
|
|
2165
|
+
if (Cause.isTimeoutError(error)) {
|
|
2166
|
+
return "Failure"
|
|
2167
|
+
}
|
|
2168
|
+
if (!Error.isHttpClientError(error)) {
|
|
2169
|
+
return "Ignored"
|
|
2170
|
+
}
|
|
2171
|
+
switch (error.reason._tag) {
|
|
2172
|
+
case "TransportError":
|
|
2173
|
+
return "Failure"
|
|
2174
|
+
case "StatusCodeError":
|
|
2175
|
+
return circuitBreakerStatusOutcome(error.reason.response.status)
|
|
2176
|
+
default:
|
|
2177
|
+
return "Ignored"
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2180
|
+
|
|
2181
|
+
const circuitBreakerStatusOutcome = (status: number): CircuitBreaker.Outcome["_tag"] =>
|
|
2182
|
+
status === 429
|
|
2183
|
+
? "Ignored"
|
|
2184
|
+
: status === 408 || status === 500 || status === 502 || status === 503 || status === 504
|
|
2185
|
+
? "Failure"
|
|
2186
|
+
: "Success"
|
|
2187
|
+
|
|
1681
2188
|
interface RateLimiterHeaderNames {
|
|
1682
2189
|
readonly limit: ReadonlyArray<string>
|
|
1683
2190
|
readonly remaining: ReadonlyArray<string>
|
|
@@ -1949,12 +2456,20 @@ export const tapRequest: {
|
|
|
1949
2456
|
)
|
|
1950
2457
|
|
|
1951
2458
|
/**
|
|
1952
|
-
* Adds a `Ref` of cookies to the client for handling cookies across
|
|
2459
|
+
* Adds a `Ref` of stored cookies to the client for handling cookies across
|
|
2460
|
+
* requests.
|
|
1953
2461
|
*
|
|
1954
2462
|
* **When to use**
|
|
1955
2463
|
*
|
|
1956
2464
|
* Use to add shared cookie storage to a client so response cookies are retained
|
|
1957
|
-
* and sent by later requests.
|
|
2465
|
+
* and sent by later requests to a matching host, path, and scheme.
|
|
2466
|
+
*
|
|
2467
|
+
* **Details**
|
|
2468
|
+
*
|
|
2469
|
+
* Response cookies are merged into the ref with `Cookies.mergeIntoArray` for
|
|
2470
|
+
* the response URL. Before each request, `Cookies.toRequestCookieHeader` selects
|
|
2471
|
+
* the cookies for the request URL and sets them as the `cookie` header. Expiry
|
|
2472
|
+
* uses the current `Clock`.
|
|
1958
2473
|
*
|
|
1959
2474
|
* @stability unstable
|
|
1960
2475
|
* @category cookies
|
|
@@ -1962,52 +2477,66 @@ export const tapRequest: {
|
|
|
1962
2477
|
*/
|
|
1963
2478
|
export const withCookiesRef: {
|
|
1964
2479
|
/**
|
|
1965
|
-
* Adds a `Ref` of cookies to the client for handling cookies across
|
|
2480
|
+
* Adds a `Ref` of stored cookies to the client for handling cookies across
|
|
2481
|
+
* requests.
|
|
1966
2482
|
*
|
|
1967
2483
|
* **When to use**
|
|
1968
2484
|
*
|
|
1969
2485
|
* Use to add shared cookie storage to a client so response cookies are retained
|
|
1970
|
-
* and sent by later requests.
|
|
2486
|
+
* and sent by later requests to a matching host, path, and scheme.
|
|
2487
|
+
*
|
|
2488
|
+
* **Details**
|
|
2489
|
+
*
|
|
2490
|
+
* Response cookies are merged into the ref with `Cookies.mergeIntoArray` for
|
|
2491
|
+
* the response URL. Before each request, `Cookies.toRequestCookieHeader` selects
|
|
2492
|
+
* the cookies for the request URL and sets them as the `cookie` header. Expiry
|
|
2493
|
+
* uses the current `Clock`.
|
|
1971
2494
|
*
|
|
1972
2495
|
* @stability unstable
|
|
1973
2496
|
* @category cookies
|
|
1974
2497
|
* @since 4.0.0
|
|
1975
2498
|
*/
|
|
1976
|
-
(ref: Ref.Ref<Cookies.
|
|
2499
|
+
(ref: Ref.Ref<ReadonlyArray<Cookies.Cookie>>): <E, R>(self: HttpClient.With<E, R>) => HttpClient.With<E, R>
|
|
1977
2500
|
/**
|
|
1978
|
-
* Adds a `Ref` of cookies to the client for handling cookies across
|
|
2501
|
+
* Adds a `Ref` of stored cookies to the client for handling cookies across
|
|
2502
|
+
* requests.
|
|
1979
2503
|
*
|
|
1980
2504
|
* **When to use**
|
|
1981
2505
|
*
|
|
1982
2506
|
* Use to add shared cookie storage to a client so response cookies are retained
|
|
1983
|
-
* and sent by later requests.
|
|
2507
|
+
* and sent by later requests to a matching host, path, and scheme.
|
|
2508
|
+
*
|
|
2509
|
+
* **Details**
|
|
2510
|
+
*
|
|
2511
|
+
* Response cookies are merged into the ref with `Cookies.mergeIntoArray` for
|
|
2512
|
+
* the response URL. Before each request, `Cookies.toRequestCookieHeader` selects
|
|
2513
|
+
* the cookies for the request URL and sets them as the `cookie` header. Expiry
|
|
2514
|
+
* uses the current `Clock`.
|
|
1984
2515
|
*
|
|
1985
2516
|
* @stability unstable
|
|
1986
2517
|
* @category cookies
|
|
1987
2518
|
* @since 4.0.0
|
|
1988
2519
|
*/
|
|
1989
|
-
<E, R>(self: HttpClient.With<E, R>, ref: Ref.Ref<Cookies.
|
|
2520
|
+
<E, R>(self: HttpClient.With<E, R>, ref: Ref.Ref<ReadonlyArray<Cookies.Cookie>>): HttpClient.With<E, R>
|
|
1990
2521
|
} = dual(
|
|
1991
2522
|
2,
|
|
1992
2523
|
<E, R>(
|
|
1993
2524
|
self: HttpClient.With<E, R>,
|
|
1994
|
-
ref: Ref.Ref<Cookies.
|
|
2525
|
+
ref: Ref.Ref<ReadonlyArray<Cookies.Cookie>>
|
|
1995
2526
|
): HttpClient.With<E, R> =>
|
|
1996
2527
|
makeWith(
|
|
1997
2528
|
(request: Effect.Effect<HttpClientRequest.HttpClientRequest, E, R>) =>
|
|
1998
|
-
Effect.tap(
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
),
|
|
2529
|
+
Effect.tap(self.postprocess(request), (response) => {
|
|
2530
|
+
const now = Fiber.getCurrent()!.getRef(Clock).currentTimeMillisUnsafe()
|
|
2531
|
+
return Ref.update(ref, Cookies.mergeIntoArray(response.url, response.cookies, now))
|
|
2532
|
+
}),
|
|
2002
2533
|
(request) =>
|
|
2003
2534
|
Effect.flatMap(self.preprocess(request), (request) =>
|
|
2004
|
-
Effect.map(
|
|
2005
|
-
|
|
2006
|
-
(cookies)
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
: HttpClientRequest.setHeader(request, "cookie", Cookies.toCookieHeader(cookies))
|
|
2010
|
-
))
|
|
2535
|
+
Effect.map(Ref.get(ref), (cookies) => {
|
|
2536
|
+
const now = Fiber.getCurrent()!.getRef(Clock).currentTimeMillisUnsafe()
|
|
2537
|
+
const header = Cookies.toRequestCookieHeader(cookies, request.url, now)
|
|
2538
|
+
return header === undefined ? request : HttpClientRequest.setHeader(request, "cookie", header)
|
|
2539
|
+
}))
|
|
2011
2540
|
)
|
|
2012
2541
|
)
|
|
2013
2542
|
|
|
@@ -2187,13 +2716,31 @@ export const followRedirects: {
|
|
|
2187
2716
|
) {
|
|
2188
2717
|
nextRequest = HttpClientRequest.setMethod(nextRequest, "GET")
|
|
2189
2718
|
nextRequest = HttpClientRequest.setBody(nextRequest, HttpBody.empty)
|
|
2719
|
+
nextRequest = HttpClientRequest.removeHeader(nextRequest, "content-encoding")
|
|
2720
|
+
nextRequest = HttpClientRequest.removeHeader(nextRequest, "content-language")
|
|
2721
|
+
nextRequest = HttpClientRequest.removeHeader(nextRequest, "content-location")
|
|
2190
2722
|
}
|
|
2191
2723
|
if (url.origin !== new URL(response.request.url).origin) {
|
|
2192
2724
|
nextRequest = HttpClientRequest.removeHeader(nextRequest, "authorization")
|
|
2193
2725
|
nextRequest = HttpClientRequest.removeHeader(nextRequest, "proxy-authorization")
|
|
2194
2726
|
nextRequest = HttpClientRequest.removeHeader(nextRequest, "cookie")
|
|
2195
2727
|
}
|
|
2196
|
-
|
|
2728
|
+
// Request the Location as sent: setUrl with a URL object would re-encode its query
|
|
2729
|
+
const hash = url.hash === "" ? Option.none() : Option.some(url.hash.slice(1))
|
|
2730
|
+
url.hash = ""
|
|
2731
|
+
nextRequest = HttpClientRequest.makeWith(
|
|
2732
|
+
nextRequest.method,
|
|
2733
|
+
url.href,
|
|
2734
|
+
UrlParams.empty,
|
|
2735
|
+
hash,
|
|
2736
|
+
nextRequest.headers,
|
|
2737
|
+
nextRequest.body
|
|
2738
|
+
)
|
|
2739
|
+
// Abort the discarded response to release its connection without reading the body
|
|
2740
|
+
return Effect.andThen(
|
|
2741
|
+
Effect.sync(() => responseControllers.get(response)?.abort()),
|
|
2742
|
+
loop(Effect.succeed(nextRequest), redirects + 1)
|
|
2743
|
+
)
|
|
2197
2744
|
}
|
|
2198
2745
|
)
|
|
2199
2746
|
})
|
|
@@ -2332,6 +2879,21 @@ const responseRegistry = (() => {
|
|
|
2332
2879
|
|
|
2333
2880
|
const scopedRequests = new WeakMap<HttpClientRequest.HttpClientRequest, AbortController>()
|
|
2334
2881
|
|
|
2882
|
+
const responseControllers = new WeakMap<HttpClientResponse.HttpClientResponse, AbortController>()
|
|
2883
|
+
|
|
2884
|
+
const trackResponse = (
|
|
2885
|
+
response: HttpClientResponse.HttpClientResponse,
|
|
2886
|
+
controller: AbortController,
|
|
2887
|
+
scoped: boolean
|
|
2888
|
+
): HttpClientResponse.HttpClientResponse => {
|
|
2889
|
+
if (!scoped) {
|
|
2890
|
+
responseRegistry.register(response, controller)
|
|
2891
|
+
response = new InterruptibleResponse(response, controller)
|
|
2892
|
+
}
|
|
2893
|
+
responseControllers.set(response, controller)
|
|
2894
|
+
return response
|
|
2895
|
+
}
|
|
2896
|
+
|
|
2335
2897
|
class InterruptibleResponse implements HttpClientResponse.HttpClientResponse, Pipeable {
|
|
2336
2898
|
readonly original: HttpClientResponse.HttpClientResponse
|
|
2337
2899
|
readonly controller: AbortController
|
|
@@ -2440,7 +3002,38 @@ class InterruptibleResponse implements HttpClientResponse.HttpClientResponse, Pi
|
|
|
2440
3002
|
}
|
|
2441
3003
|
}
|
|
2442
3004
|
|
|
2443
|
-
|
|
3005
|
+
/**
|
|
3006
|
+
* Returns `true` for an error that `retryTransient` retries by default: a
|
|
3007
|
+
* timeout, a transport error, or a status code error with a transient response.
|
|
3008
|
+
*
|
|
3009
|
+
* **When to use**
|
|
3010
|
+
*
|
|
3011
|
+
* Use to classify failures the same way `retryTransient` does, for example in a
|
|
3012
|
+
* custom retry policy or a circuit breaker.
|
|
3013
|
+
*
|
|
3014
|
+
* **Example** (Classifying client errors)
|
|
3015
|
+
*
|
|
3016
|
+
* ```ts import.meta.vitest
|
|
3017
|
+
* import { Cause } from "effect"
|
|
3018
|
+
* import { HttpClient, HttpClientError, HttpClientRequest } from "effect/http"
|
|
3019
|
+
*
|
|
3020
|
+
* const request = HttpClientRequest.get("https://example.com")
|
|
3021
|
+
* const transportError = new HttpClientError.HttpClientError({
|
|
3022
|
+
* reason: new HttpClientError.TransportError({ request })
|
|
3023
|
+
* })
|
|
3024
|
+
*
|
|
3025
|
+
* HttpClient.isTransientError(transportError) // => true
|
|
3026
|
+
* HttpClient.isTransientError(new Cause.TimeoutError()) // => true
|
|
3027
|
+
* HttpClient.isTransientError(new Error("boom")) // => false
|
|
3028
|
+
* ```
|
|
3029
|
+
*
|
|
3030
|
+
* @see {@link isTransientResponse} for the response statuses it accepts
|
|
3031
|
+
* @see {@link retryTransient} for the retry policy that uses it
|
|
3032
|
+
* @stability unstable
|
|
3033
|
+
* @category predicates
|
|
3034
|
+
* @since 4.1.0
|
|
3035
|
+
*/
|
|
3036
|
+
export const isTransientError = (error: unknown): boolean => Cause.isTimeoutError(error) || isTransientHttpError(error)
|
|
2444
3037
|
|
|
2445
3038
|
const isTransientHttpError = (error: unknown) =>
|
|
2446
3039
|
Error.isHttpClientError(error) &&
|
|
@@ -2474,7 +3067,21 @@ const isTooManyRequestsHttpClientError = (
|
|
|
2474
3067
|
): error is Error.HttpClientError & { readonly reason: Error.StatusCodeError } =>
|
|
2475
3068
|
Error.isHttpClientError(error) && error.reason._tag === "StatusCodeError" && error.reason.response.status === 429
|
|
2476
3069
|
|
|
2477
|
-
|
|
3070
|
+
/**
|
|
3071
|
+
* Returns `true` for a response whose status `retryTransient` retries by
|
|
3072
|
+
* default: 408, 429, 500, 502, 503 or 504.
|
|
3073
|
+
*
|
|
3074
|
+
* **When to use**
|
|
3075
|
+
*
|
|
3076
|
+
* Use to retry the same responses as `retryTransient` in a custom retry policy.
|
|
3077
|
+
*
|
|
3078
|
+
* @see {@link isTransientError} for the matching error predicate
|
|
3079
|
+
* @see {@link retryTransient} for the retry policy that uses it
|
|
3080
|
+
* @stability unstable
|
|
3081
|
+
* @category predicates
|
|
3082
|
+
* @since 4.1.0
|
|
3083
|
+
*/
|
|
3084
|
+
export const isTransientResponse = (response: HttpClientResponse.HttpClientResponse): boolean =>
|
|
2478
3085
|
response.status === 408 ||
|
|
2479
3086
|
response.status === 429 ||
|
|
2480
3087
|
response.status === 500 ||
|