effect 4.0.7 → 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/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 +9 -3
- 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/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 +164 -7
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +11 -1
- package/dist/Effect.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/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/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/Pool.d.ts +51 -0
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +59 -9
- package/dist/Pool.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/Schedule.d.ts +18 -1
- package/dist/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js +7 -2
- package/dist/Schedule.js.map +1 -1
- package/dist/Schema.d.ts +666 -41
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +650 -0
- package/dist/Schema.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/SchemaRepresentation.d.ts +14 -0
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +16 -0
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +8 -3
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +6 -3
- 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 +40 -0
- package/dist/Semaphore.js.map +1 -1
- package/dist/Stream.d.ts +13 -4
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +9 -0
- package/dist/Stream.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/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/McpServer.d.ts +630 -29
- package/dist/ai/McpServer.d.ts.map +1 -1
- package/dist/ai/McpServer.js +562 -116
- 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/Response.d.ts +1 -25
- package/dist/ai/Response.d.ts.map +1 -1
- package/dist/ai/Response.js +1 -10
- package/dist/ai/Response.js.map +1 -1
- package/dist/ai/Tool.d.ts +19 -1
- package/dist/ai/Tool.d.ts.map +1 -1
- package/dist/ai/Tool.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 +6 -0
- package/dist/cli/Argument.d.ts.map +1 -1
- package/dist/cli/Argument.js +2 -0
- package/dist/cli/Argument.js.map +1 -1
- package/dist/cli/CliOutput.d.ts +65 -1
- package/dist/cli/CliOutput.d.ts.map +1 -1
- package/dist/cli/CliOutput.js +94 -37
- package/dist/cli/CliOutput.js.map +1 -1
- package/dist/cli/Command.d.ts +23 -0
- package/dist/cli/Command.d.ts.map +1 -1
- package/dist/cli/Command.js +8 -0
- package/dist/cli/Command.js.map +1 -1
- package/dist/cli/Flag.d.ts +107 -0
- package/dist/cli/Flag.d.ts.map +1 -1
- package/dist/cli/Flag.js +37 -0
- package/dist/cli/Flag.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 +6 -0
- package/dist/cli/Param.d.ts.map +1 -1
- package/dist/cli/Param.js +2 -0
- 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/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/Sharding.d.ts.map +1 -1
- package/dist/cluster/Sharding.js +90 -28
- package/dist/cluster/Sharding.js.map +1 -1
- package/dist/cluster/ShardingConfig.d.ts +72 -6
- 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/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 +23 -8
- package/dist/cluster/SqlRunnerStorage.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/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/Toml.d.ts +17 -3
- package/dist/encoding/Toml.d.ts.map +1 -1
- package/dist/encoding/Toml.js +104 -16
- 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.js +2 -2
- 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/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 +143 -1
- 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 +79 -8
- package/dist/http/HttpClient.d.ts.map +1 -1
- package/dist/http/HttpClient.js +65 -5
- package/dist/http/HttpClient.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 +2 -3
- 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/HttpServerRequest.d.ts +5 -2
- package/dist/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/http/HttpServerRequest.js +6 -17
- 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/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/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/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/decompression.js +3 -2
- package/dist/http/internal/decompression.js.map +1 -1
- package/dist/http/internal/urlParams.js +8 -0
- package/dist/http/internal/urlParams.js.map +1 -1
- package/dist/http-api/HttpApiBuilder.js +19 -5
- package/dist/http-api/HttpApiBuilder.js.map +1 -1
- package/dist/http-api/HttpApiClient.d.ts +63 -0
- package/dist/http-api/HttpApiClient.d.ts.map +1 -1
- package/dist/http-api/HttpApiClient.js +51 -0
- package/dist/http-api/HttpApiClient.js.map +1 -1
- package/dist/http-api/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/http-api/HttpApiEndpoint.js +14 -5
- 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 +76 -14
- package/dist/http-api/HttpApiSchema.d.ts.map +1 -1
- package/dist/http-api/HttpApiSchema.js +53 -0
- package/dist/http-api/HttpApiSchema.js.map +1 -1
- 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/effect.js +25 -14
- package/dist/internal/effect.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/matcher.js +10 -0
- 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/toCodeDocument.js +6 -3
- package/dist/internal/schema/toCodeDocument.js.map +1 -1
- 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/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/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/process/ChildProcess.d.ts +207 -67
- 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 +5 -0
- package/dist/process/ChildProcessSpawner.d.ts.map +1 -1
- 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/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 +50 -16
- 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.map +1 -1
- package/dist/rpc/RpcSerialization.js +6 -0
- 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 -66
- package/dist/rpc/RpcServer.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 +0 -19
- package/dist/sql/Migrator.d.ts.map +1 -1
- package/dist/sql/Migrator.js +3 -48
- 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.map +1 -1
- package/dist/sql/SqlClient.js +5 -9
- package/dist/sql/SqlClient.js.map +1 -1
- package/dist/sql/Statement.d.ts +20 -6
- package/dist/sql/Statement.d.ts.map +1 -1
- package/dist/sql/Statement.js +0 -13
- 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/internal/crypto.js +9 -8
- package/dist/workflow/internal/crypto.js.map +1 -1
- package/package.json +3 -1
- package/src/BigDecimal.ts +3 -0
- package/src/Channel.ts +17 -11
- package/src/Config.ts +7 -1
- package/src/Context.ts +34 -10
- package/src/Cron.ts +178 -29
- package/src/Duration.ts +140 -0
- package/src/Effect.ts +914 -85
- package/src/FileSystem.ts +65 -4
- package/src/Glob.ts +205 -0
- package/src/Match.ts +127 -0
- package/src/Pool.ts +73 -15
- package/src/Random.ts +3 -3
- package/src/RcMap.ts +5 -1
- package/src/Schedule.ts +26 -3
- package/src/Schema.ts +1189 -62
- package/src/SchemaGetter.ts +27 -11
- package/src/SchemaRepresentation.ts +19 -0
- package/src/SchemaTransformation.ts +8 -3
- package/src/ScopedCache.ts +5 -9
- package/src/Semaphore.ts +141 -0
- package/src/Stream.ts +15 -6
- package/src/Terminal.ts +19 -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/McpServer.ts +1269 -286
- package/src/ai/McpTest.ts +380 -0
- package/src/ai/Response.ts +2 -22
- package/src/ai/Tool.ts +27 -8
- 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 +6 -0
- package/src/cli/CliOutput.ts +117 -49
- package/src/cli/Command.ts +23 -0
- package/src/cli/Flag.ts +107 -0
- package/src/cli/HelpDoc.ts +18 -1
- package/src/cli/Param.ts +6 -0
- package/src/cli/Primitive.ts +16 -1
- package/src/cli/Prompt.ts +1 -0
- package/src/cli/internal/help.ts +21 -9
- package/src/cluster/Sharding.ts +93 -26
- package/src/cluster/ShardingConfig.ts +41 -3
- package/src/cluster/SingleRunner.ts +3 -3
- package/src/cluster/SqlMessageStorage.ts +49 -17
- package/src/cluster/SqlRunnerStorage.ts +37 -27
- 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/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/Toml.ts +85 -20
- 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 +2 -2
- 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/identityRootSecretDerivation.ts +93 -123
- package/src/eventlog/internal/remoteCompaction.ts +92 -0
- package/src/http/Cookies.ts +281 -1
- package/src/http/FetchHttpClient.ts +88 -16
- package/src/http/HttpClient.ts +89 -22
- package/src/http/HttpClientRequest.ts +12 -9
- package/src/http/HttpClientResponse.ts +3 -2
- package/src/http/HttpMethod.ts +10 -2
- package/src/http/HttpServerRequest.ts +15 -30
- package/src/http/HttpServerResponse.ts +3 -2
- package/src/http/HttpTraceContext.ts +7 -4
- package/src/http/ProblemDetails.ts +149 -0
- package/src/http/index.ts +6 -0
- package/src/http/internal/decompression.ts +4 -4
- package/src/http/internal/urlParams.ts +8 -0
- package/src/http-api/HttpApiBuilder.ts +24 -12
- package/src/http-api/HttpApiClient.ts +67 -1
- package/src/http-api/HttpApiEndpoint.ts +14 -5
- package/src/http-api/HttpApiError.ts +250 -0
- package/src/http-api/HttpApiMiddleware.ts +95 -1
- package/src/http-api/HttpApiSchema.ts +105 -14
- package/src/index.ts +6 -6
- package/src/internal/effect.ts +34 -18
- package/src/internal/glob.ts +736 -0
- package/src/internal/matcher.ts +17 -0
- package/src/internal/persistence.ts +11 -0
- package/src/internal/rcRef.ts +4 -1
- package/src/internal/schema/toCodeDocument.ts +7 -3
- 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/OtlpResource.ts +9 -1
- package/src/persistence/KeyValueStore.ts +219 -22
- package/src/persistence/PersistedQueue.ts +128 -59
- package/src/persistence/Persistence.ts +20 -13
- package/src/process/ChildProcess.ts +255 -260
- package/src/process/ChildProcessSpawner.ts +5 -0
- package/src/process/CommandLine.ts +630 -0
- package/src/process/index.ts +6 -0
- package/src/reactivity/Atom.ts +5 -5
- package/src/reactivity/AtomRegistry.ts +1 -1
- package/src/rpc/RpcClient.ts +62 -26
- package/src/rpc/RpcMessage.ts +10 -1
- package/src/rpc/RpcSerialization.ts +3 -0
- package/src/rpc/RpcServer.ts +176 -78
- package/src/schema/Model.ts +26 -3
- package/src/sql/Migrator.ts +4 -63
- package/src/sql/MigratorFileSystem.ts +71 -0
- package/src/sql/SqlClient.ts +2 -16
- package/src/sql/Statement.ts +8 -7
- package/src/sql/index.ts +1 -1
- package/src/testing/index.ts +0 -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
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
import * as Cause from "../Cause.ts"
|
|
18
18
|
import * as Clock from "../Clock.ts"
|
|
19
19
|
import * as Context from "../Context.ts"
|
|
20
|
+
import * as SecureRandom from "../crypto/SecureRandom.ts"
|
|
20
21
|
import * as Duration from "../Duration.ts"
|
|
21
22
|
import * as Effect from "../Effect.ts"
|
|
22
23
|
import { flow } from "../Function.ts"
|
|
@@ -250,7 +251,7 @@ export const makeFactory = Effect.gen(function*() {
|
|
|
250
251
|
[TypeId]: TypeId,
|
|
251
252
|
offer: (value, opts) =>
|
|
252
253
|
Effect.suspend(() => {
|
|
253
|
-
const id = opts?.id ??
|
|
254
|
+
const id = opts?.id ?? SecureRandom.uuidV4Unsafe()
|
|
254
255
|
const delay = positiveDelay(opts?.delay)
|
|
255
256
|
if (delay !== undefined && !Duration.isFinite(delay)) {
|
|
256
257
|
return Effect.succeed(id)
|
|
@@ -695,6 +696,15 @@ export const layerStoreMemory: Layer.Layer<
|
|
|
695
696
|
* queue. Delayed offers share the retry sorted set: they are scored with the
|
|
696
697
|
* offering process's clock and released by the polling worker's clock, so
|
|
697
698
|
* clock skew between hosts shifts their delivery.
|
|
699
|
+
* A handler whose lock lapsed can still settle or renew its claim until a
|
|
700
|
+
* reset recovers the element.
|
|
701
|
+
*
|
|
702
|
+
* **Gotchas**
|
|
703
|
+
*
|
|
704
|
+
* The lock format is incompatible with older workers on the same prefix: their
|
|
705
|
+
* settlements are not fenced and can corrupt newer claims. Stop every old
|
|
706
|
+
* worker and let its locks expire before starting upgraded workers. Keep the
|
|
707
|
+
* existing Redis data rather than flushing it.
|
|
698
708
|
*
|
|
699
709
|
* @stability unstable
|
|
700
710
|
* @category constructors
|
|
@@ -728,17 +738,15 @@ export const makeStoreRedis = Effect.fnUntraced(function*(
|
|
|
728
738
|
1
|
|
729
739
|
)
|
|
730
740
|
const prefix = options?.prefix ?? "effectq:"
|
|
731
|
-
const keyLock = (id: string) => `${prefix}${id}:lock`
|
|
732
741
|
const keysFor = (name: string) => ({
|
|
733
742
|
queue: `${prefix}${name}`,
|
|
734
743
|
pending: `${prefix}${name}:pending`,
|
|
735
744
|
failed: `${prefix}${name}:failed`,
|
|
736
745
|
delayed: `${prefix}${name}:delayed`,
|
|
737
746
|
attempts: `${prefix}${name}:attempts`,
|
|
738
|
-
ids: `${prefix}${name}:ids
|
|
747
|
+
ids: `${prefix}${name}:ids`,
|
|
748
|
+
owners: `${prefix}${name}:owners`
|
|
739
749
|
})
|
|
740
|
-
const workerId = crypto.randomUUID()
|
|
741
|
-
|
|
742
750
|
const ackRetrySchedule = makeAckRetrySchedule(lockExpirationMillis)
|
|
743
751
|
|
|
744
752
|
type Element = {
|
|
@@ -747,6 +755,8 @@ export const makeStoreRedis = Effect.fnUntraced(function*(
|
|
|
747
755
|
readonly attempts: number
|
|
748
756
|
// the raw wire payload, so requeue and retry do not re-stringify it
|
|
749
757
|
readonly payload: string
|
|
758
|
+
// unique per acquisition, and recorded in the owners hash as the claim token
|
|
759
|
+
readonly lock: string
|
|
750
760
|
}
|
|
751
761
|
|
|
752
762
|
const requeue = redis.eval(requeueRedis)
|
|
@@ -780,8 +790,9 @@ export const makeStoreRedis = Effect.fnUntraced(function*(
|
|
|
780
790
|
requeue(
|
|
781
791
|
keys.queue,
|
|
782
792
|
keys.pending,
|
|
783
|
-
|
|
793
|
+
element.lock,
|
|
784
794
|
keys.attempts,
|
|
795
|
+
keys.owners,
|
|
785
796
|
element.id,
|
|
786
797
|
element.payload
|
|
787
798
|
), { concurrency: "unbounded", discard: true })
|
|
@@ -796,7 +807,7 @@ export const makeStoreRedis = Effect.fnUntraced(function*(
|
|
|
796
807
|
keys.attempts,
|
|
797
808
|
keys.failed,
|
|
798
809
|
keys.ids,
|
|
799
|
-
|
|
810
|
+
keys.owners,
|
|
800
811
|
state.maxAttempts,
|
|
801
812
|
clock.currentTimeMillisUnsafe()
|
|
802
813
|
)
|
|
@@ -813,8 +824,8 @@ export const makeStoreRedis = Effect.fnUntraced(function*(
|
|
|
813
824
|
keys.pending,
|
|
814
825
|
keys.delayed,
|
|
815
826
|
keys.attempts,
|
|
816
|
-
|
|
817
|
-
|
|
827
|
+
keys.owners,
|
|
828
|
+
`${prefix}lock:${SecureRandom.uuidV4Unsafe()}:`,
|
|
818
829
|
size,
|
|
819
830
|
lockExpirationMillis,
|
|
820
831
|
clock.currentTimeMillisUnsafe()
|
|
@@ -833,14 +844,15 @@ export const makeStoreRedis = Effect.fnUntraced(function*(
|
|
|
833
844
|
}
|
|
834
845
|
takenLatch.closeUnsafe()
|
|
835
846
|
const elements: Array<Element> = []
|
|
836
|
-
for (let i = 0; i < results.length; i +=
|
|
847
|
+
for (let i = 0; i < results.length; i += 3) {
|
|
837
848
|
const payload = results[i] as string
|
|
838
849
|
const parsed = JSON.parse(payload)
|
|
839
850
|
elements.push({
|
|
840
851
|
id: parsed.id,
|
|
841
852
|
element: parsed.element,
|
|
842
853
|
attempts: Number(results[i + 1]),
|
|
843
|
-
payload
|
|
854
|
+
payload,
|
|
855
|
+
lock: results[i + 2] as string
|
|
844
856
|
})
|
|
845
857
|
}
|
|
846
858
|
yield* Queue.offerAll(queue, elements)
|
|
@@ -860,12 +872,12 @@ export const makeStoreRedis = Effect.fnUntraced(function*(
|
|
|
860
872
|
idleTimeToLive: Duration.seconds(30)
|
|
861
873
|
})
|
|
862
874
|
|
|
863
|
-
const
|
|
875
|
+
const activeLocks = new Map<string, { readonly owners: string; readonly id: string }>()
|
|
864
876
|
|
|
865
877
|
yield* Effect.gen(function*() {
|
|
866
878
|
while (true) {
|
|
867
879
|
yield* Effect.sleep(lockRefreshMillis)
|
|
868
|
-
yield* Effect.ignore(expireAll(
|
|
880
|
+
yield* Effect.ignore(expireAll(activeLocks, lockExpirationMillis))
|
|
869
881
|
}
|
|
870
882
|
}).pipe(
|
|
871
883
|
Effect.forkScoped,
|
|
@@ -952,19 +964,19 @@ export const makeStoreRedis = Effect.fnUntraced(function*(
|
|
|
952
964
|
Effect.scoped,
|
|
953
965
|
Effect.tap((element) => {
|
|
954
966
|
const keys = keysFor(options.name)
|
|
955
|
-
const lock =
|
|
956
|
-
|
|
967
|
+
const lock = element.lock
|
|
968
|
+
activeLocks.set(lock, { owners: keys.owners, id: element.id })
|
|
957
969
|
const ack = (effect: Effect.Effect<unknown, Redis.RedisError>) =>
|
|
958
970
|
effect.pipe(
|
|
959
971
|
Effect.retry(ackRetrySchedule),
|
|
960
972
|
Effect.orDie,
|
|
961
|
-
Effect.ensuring(Effect.sync(() =>
|
|
973
|
+
Effect.ensuring(Effect.sync(() => activeLocks.delete(lock)))
|
|
962
974
|
)
|
|
963
975
|
return Effect.addFinalizer((exit) =>
|
|
964
976
|
Effect.suspend(() => {
|
|
965
977
|
const now = clock.currentTimeMillisUnsafe()
|
|
966
978
|
if (exit._tag === "Success") {
|
|
967
|
-
return ack(complete(keys.pending, lock, keys.attempts, keys.ids, element.id, now))
|
|
979
|
+
return ack(complete(keys.pending, lock, keys.attempts, keys.ids, keys.owners, element.id, now))
|
|
968
980
|
}
|
|
969
981
|
const dead = deadLetterFromCause(exit.cause)
|
|
970
982
|
const failElement = (cause: Cause.Cause<unknown>) =>
|
|
@@ -974,6 +986,7 @@ export const makeStoreRedis = Effect.fnUntraced(function*(
|
|
|
974
986
|
keys.failed,
|
|
975
987
|
keys.attempts,
|
|
976
988
|
keys.ids,
|
|
989
|
+
keys.owners,
|
|
977
990
|
element.id,
|
|
978
991
|
JSON.stringify({
|
|
979
992
|
id: element.id,
|
|
@@ -987,7 +1000,9 @@ export const makeStoreRedis = Effect.fnUntraced(function*(
|
|
|
987
1000
|
return failElement(dead.cause)
|
|
988
1001
|
}
|
|
989
1002
|
if (Cause.hasInterruptsOnly(exit.cause)) {
|
|
990
|
-
return ack(
|
|
1003
|
+
return ack(
|
|
1004
|
+
requeue(keys.queue, keys.pending, lock, keys.attempts, keys.owners, element.id, element.payload)
|
|
1005
|
+
)
|
|
991
1006
|
}
|
|
992
1007
|
if (element.attempts >= options.maxAttempts) {
|
|
993
1008
|
return failElement(exit.cause)
|
|
@@ -997,6 +1012,7 @@ export const makeStoreRedis = Effect.fnUntraced(function*(
|
|
|
997
1012
|
keys.pending,
|
|
998
1013
|
lock,
|
|
999
1014
|
keys.delayed,
|
|
1015
|
+
keys.owners,
|
|
1000
1016
|
element.id,
|
|
1001
1017
|
element.payload,
|
|
1002
1018
|
now + Duration.toMillis(delay)
|
|
@@ -1087,7 +1103,7 @@ const resetQueueRedis = Redis.script(
|
|
|
1087
1103
|
keyAttempts: string,
|
|
1088
1104
|
keyFailed: string,
|
|
1089
1105
|
keyIds: string,
|
|
1090
|
-
|
|
1106
|
+
keyOwners: string,
|
|
1091
1107
|
maxAttempts: number,
|
|
1092
1108
|
now: number
|
|
1093
1109
|
]
|
|
@@ -1099,17 +1115,17 @@ local key_pending = KEYS[2]
|
|
|
1099
1115
|
local key_attempts = KEYS[3]
|
|
1100
1116
|
local key_failed = KEYS[4]
|
|
1101
1117
|
local key_ids = KEYS[5]
|
|
1102
|
-
local
|
|
1103
|
-
local max_attempts = tonumber(ARGV[
|
|
1104
|
-
local now = ARGV[
|
|
1118
|
+
local key_owners = KEYS[6]
|
|
1119
|
+
local max_attempts = tonumber(ARGV[1])
|
|
1120
|
+
local now = ARGV[2]
|
|
1105
1121
|
|
|
1106
1122
|
local entries = redis.call("HGETALL", key_pending)
|
|
1123
|
+
-- recovery revokes ownership, so late settlements from the old claim are no-ops
|
|
1107
1124
|
for i = 1, #entries, 2 do
|
|
1108
1125
|
local id = entries[i]
|
|
1109
1126
|
local payload = entries[i + 1]
|
|
1110
|
-
local
|
|
1111
|
-
|
|
1112
|
-
if exists == 0 then
|
|
1127
|
+
local key_lock = redis.call("HGET", key_owners, id)
|
|
1128
|
+
if not key_lock or redis.call("EXISTS", key_lock) == 0 then
|
|
1113
1129
|
local attempts = tonumber(redis.call("HGET", key_attempts, id) or "0")
|
|
1114
1130
|
if attempts >= max_attempts then
|
|
1115
1131
|
-- compose the failed record by hand so the element payload does not go
|
|
@@ -1124,17 +1140,37 @@ for i = 1, #entries, 2 do
|
|
|
1124
1140
|
else
|
|
1125
1141
|
redis.call("RPUSH", key_queue, payload)
|
|
1126
1142
|
end
|
|
1143
|
+
redis.call("HDEL", key_owners, id)
|
|
1127
1144
|
redis.call("HDEL", key_pending, id)
|
|
1128
1145
|
end
|
|
1129
1146
|
end
|
|
1130
1147
|
`,
|
|
1131
|
-
numberOfKeys:
|
|
1148
|
+
numberOfKeys: 6
|
|
1132
1149
|
}
|
|
1133
1150
|
)
|
|
1134
1151
|
|
|
1152
|
+
// Settlements are fenced on the acquisition's lock key, so a handler whose claim
|
|
1153
|
+
// was recovered cannot release a newer claim on the same id.
|
|
1154
|
+
const releaseClaimLua = `if redis.call("HGET", key_owners, id) ~= key_lock then
|
|
1155
|
+
return 0
|
|
1156
|
+
end
|
|
1157
|
+
|
|
1158
|
+
redis.call("HDEL", key_owners, id)
|
|
1159
|
+
redis.call("DEL", key_lock)
|
|
1160
|
+
redis.call("HDEL", key_pending, id)
|
|
1161
|
+
`
|
|
1162
|
+
|
|
1135
1163
|
const requeueRedis = Redis.script(
|
|
1136
1164
|
(
|
|
1137
|
-
...args: [
|
|
1165
|
+
...args: [
|
|
1166
|
+
keyQueue: string,
|
|
1167
|
+
keyPending: string,
|
|
1168
|
+
keyLock: string,
|
|
1169
|
+
keyAttempts: string,
|
|
1170
|
+
keyOwners: string,
|
|
1171
|
+
id: string,
|
|
1172
|
+
payload: string
|
|
1173
|
+
]
|
|
1138
1174
|
) => args,
|
|
1139
1175
|
{
|
|
1140
1176
|
lua: `
|
|
@@ -1142,60 +1178,77 @@ local key_queue = KEYS[1]
|
|
|
1142
1178
|
local key_pending = KEYS[2]
|
|
1143
1179
|
local key_lock = KEYS[3]
|
|
1144
1180
|
local key_attempts = KEYS[4]
|
|
1181
|
+
local key_owners = KEYS[5]
|
|
1145
1182
|
local id = ARGV[1]
|
|
1146
1183
|
local payload = ARGV[2]
|
|
1147
1184
|
|
|
1148
|
-
|
|
1149
|
-
redis.call("HDEL", key_pending, id)
|
|
1185
|
+
${releaseClaimLua}
|
|
1150
1186
|
local attempts = redis.call("HINCRBY", key_attempts, id, -1)
|
|
1151
1187
|
if attempts <= 0 then
|
|
1152
1188
|
redis.call("HDEL", key_attempts, id)
|
|
1153
1189
|
end
|
|
1154
1190
|
redis.call("RPUSH", key_queue, payload)
|
|
1155
1191
|
`,
|
|
1156
|
-
numberOfKeys:
|
|
1192
|
+
numberOfKeys: 5
|
|
1157
1193
|
}
|
|
1158
1194
|
)
|
|
1159
1195
|
|
|
1160
1196
|
const completeRedis = Redis.script(
|
|
1161
|
-
(
|
|
1162
|
-
args
|
|
1197
|
+
(
|
|
1198
|
+
...args: [
|
|
1199
|
+
keyPending: string,
|
|
1200
|
+
keyLock: string,
|
|
1201
|
+
keyAttempts: string,
|
|
1202
|
+
keyIds: string,
|
|
1203
|
+
keyOwners: string,
|
|
1204
|
+
id: string,
|
|
1205
|
+
now: number
|
|
1206
|
+
]
|
|
1207
|
+
) => args,
|
|
1163
1208
|
{
|
|
1164
1209
|
lua: `
|
|
1165
1210
|
local key_pending = KEYS[1]
|
|
1166
1211
|
local key_lock = KEYS[2]
|
|
1167
1212
|
local key_attempts = KEYS[3]
|
|
1168
1213
|
local key_ids = KEYS[4]
|
|
1214
|
+
local key_owners = KEYS[5]
|
|
1169
1215
|
local id = ARGV[1]
|
|
1170
1216
|
local now = ARGV[2]
|
|
1171
1217
|
|
|
1172
|
-
|
|
1173
|
-
redis.call("HDEL", key_pending, id)
|
|
1218
|
+
${releaseClaimLua}
|
|
1174
1219
|
redis.call("HDEL", key_attempts, id)
|
|
1175
1220
|
redis.call("ZADD", key_ids, "XX", now, id)
|
|
1176
1221
|
`,
|
|
1177
|
-
numberOfKeys:
|
|
1222
|
+
numberOfKeys: 5
|
|
1178
1223
|
}
|
|
1179
1224
|
)
|
|
1180
1225
|
|
|
1181
1226
|
const retryRedis = Redis.script(
|
|
1182
1227
|
(
|
|
1183
|
-
...args: [
|
|
1228
|
+
...args: [
|
|
1229
|
+
keyPending: string,
|
|
1230
|
+
keyLock: string,
|
|
1231
|
+
keyDelayed: string,
|
|
1232
|
+
keyOwners: string,
|
|
1233
|
+
id: string,
|
|
1234
|
+
payload: string,
|
|
1235
|
+
visibleAt: number
|
|
1236
|
+
]
|
|
1184
1237
|
) => args,
|
|
1185
1238
|
{
|
|
1186
1239
|
lua: `
|
|
1187
1240
|
local key_pending = KEYS[1]
|
|
1188
1241
|
local key_lock = KEYS[2]
|
|
1189
1242
|
local key_delayed = KEYS[3]
|
|
1243
|
+
local key_owners = KEYS[4]
|
|
1190
1244
|
local id = ARGV[1]
|
|
1191
1245
|
local payload = ARGV[2]
|
|
1192
1246
|
local visible_at = ARGV[3]
|
|
1193
1247
|
|
|
1194
|
-
|
|
1195
|
-
redis.call("HDEL", key_pending, id)
|
|
1248
|
+
${releaseClaimLua}
|
|
1196
1249
|
redis.call("ZADD", key_delayed, visible_at, payload)
|
|
1197
1250
|
`,
|
|
1198
|
-
numberOfKeys:
|
|
1251
|
+
numberOfKeys: 4
|
|
1199
1252
|
}
|
|
1200
1253
|
)
|
|
1201
1254
|
|
|
@@ -1207,6 +1260,7 @@ const failedRedis = Redis.script(
|
|
|
1207
1260
|
keyFailed: string,
|
|
1208
1261
|
keyAttempts: string,
|
|
1209
1262
|
keyIds: string,
|
|
1263
|
+
keyOwners: string,
|
|
1210
1264
|
id: string,
|
|
1211
1265
|
payload: string
|
|
1212
1266
|
]
|
|
@@ -1218,18 +1272,18 @@ local key_lock = KEYS[2]
|
|
|
1218
1272
|
local key_failed = KEYS[3]
|
|
1219
1273
|
local key_attempts = KEYS[4]
|
|
1220
1274
|
local key_ids = KEYS[5]
|
|
1275
|
+
local key_owners = KEYS[6]
|
|
1221
1276
|
local id = ARGV[1]
|
|
1222
1277
|
local payload = ARGV[2]
|
|
1223
1278
|
|
|
1224
|
-
|
|
1225
|
-
redis.call("HDEL", key_pending, id)
|
|
1279
|
+
${releaseClaimLua}
|
|
1226
1280
|
redis.call("HDEL", key_attempts, id)
|
|
1227
1281
|
redis.call("RPUSH", key_failed, payload)
|
|
1228
1282
|
-- failed ids keep their dedupe entry until failedTimeToLive removes the
|
|
1229
1283
|
-- dead-letter record, so park them outside the timeToLive trim range
|
|
1230
1284
|
redis.call("ZADD", key_ids, "XX", "+inf", id)
|
|
1231
1285
|
`,
|
|
1232
|
-
numberOfKeys:
|
|
1286
|
+
numberOfKeys: 6
|
|
1233
1287
|
}
|
|
1234
1288
|
)
|
|
1235
1289
|
|
|
@@ -1261,8 +1315,8 @@ const takeRedis = Redis.script(
|
|
|
1261
1315
|
keyPending: string,
|
|
1262
1316
|
keyDelayed: string,
|
|
1263
1317
|
keyAttempts: string,
|
|
1264
|
-
|
|
1265
|
-
|
|
1318
|
+
keyOwners: string,
|
|
1319
|
+
lockPrefix: string,
|
|
1266
1320
|
batchSize: number,
|
|
1267
1321
|
pttl: number,
|
|
1268
1322
|
now: number
|
|
@@ -1274,11 +1328,11 @@ local key_queue = KEYS[1]
|
|
|
1274
1328
|
local key_pending = KEYS[2]
|
|
1275
1329
|
local key_delayed = KEYS[3]
|
|
1276
1330
|
local key_attempts = KEYS[4]
|
|
1277
|
-
local
|
|
1278
|
-
local
|
|
1279
|
-
local batch_size = tonumber(ARGV[
|
|
1280
|
-
local pttl = ARGV[
|
|
1281
|
-
local now = ARGV[
|
|
1331
|
+
local key_owners = KEYS[5]
|
|
1332
|
+
local lock_prefix = ARGV[1]
|
|
1333
|
+
local batch_size = tonumber(ARGV[2])
|
|
1334
|
+
local pttl = ARGV[3]
|
|
1335
|
+
local now = ARGV[4]
|
|
1282
1336
|
|
|
1283
1337
|
${queueRecordIdRedis}
|
|
1284
1338
|
|
|
@@ -1305,28 +1359,43 @@ redis.call("LTRIM", key_queue, #payloads, -1)
|
|
|
1305
1359
|
local result = {}
|
|
1306
1360
|
for i, id in ipairs(ids) do
|
|
1307
1361
|
local payload = payloads[i]
|
|
1308
|
-
|
|
1309
|
-
|
|
1362
|
+
-- the lock key is unique per acquisition and doubles as the ownership token
|
|
1363
|
+
local key_lock = lock_prefix .. i
|
|
1364
|
+
redis.call("SET", key_lock, 1, "PX", pttl)
|
|
1365
|
+
redis.call("HSET", key_owners, id, key_lock)
|
|
1310
1366
|
redis.call("HSET", key_pending, id, payload)
|
|
1311
1367
|
local attempts = redis.call("HINCRBY", key_attempts, id, 1)
|
|
1312
|
-
result[i *
|
|
1313
|
-
result[i *
|
|
1368
|
+
result[i * 3 - 2] = payload
|
|
1369
|
+
result[i * 3 - 1] = attempts
|
|
1370
|
+
result[i * 3] = key_lock
|
|
1314
1371
|
end
|
|
1315
1372
|
|
|
1316
1373
|
return result
|
|
1317
1374
|
`,
|
|
1318
|
-
numberOfKeys:
|
|
1375
|
+
numberOfKeys: 5
|
|
1319
1376
|
}
|
|
1320
1377
|
).withReturnType<ReadonlyArray<string | number> | null>()
|
|
1321
1378
|
|
|
1322
1379
|
const expireAllRedis = Redis.script(
|
|
1323
|
-
(
|
|
1380
|
+
(claims: ReadonlyMap<string, { readonly owners: string; readonly id: string }>, ttl: number) => {
|
|
1381
|
+
const keys: Array<string> = []
|
|
1382
|
+
const ids: Array<string> = []
|
|
1383
|
+
for (const [lock, { id, owners }] of claims) {
|
|
1384
|
+
keys.push(lock, owners)
|
|
1385
|
+
ids.push(id)
|
|
1386
|
+
}
|
|
1387
|
+
return [...keys, ttl, ...ids]
|
|
1388
|
+
},
|
|
1324
1389
|
{
|
|
1325
|
-
numberOfKeys: (
|
|
1390
|
+
numberOfKeys: (claims) => claims.size * 2,
|
|
1326
1391
|
lua: `
|
|
1327
1392
|
local ttl = ARGV[1]
|
|
1328
|
-
|
|
1329
|
-
|
|
1393
|
+
-- a lapsed lock can be recreated only while the claim has not been recovered
|
|
1394
|
+
for i = 2, #ARGV do
|
|
1395
|
+
local key_lock = KEYS[i * 2 - 3]
|
|
1396
|
+
if redis.call("HGET", KEYS[i * 2 - 2], ARGV[i]) == key_lock then
|
|
1397
|
+
redis.call("SET", key_lock, 1, "PX", ttl)
|
|
1398
|
+
end
|
|
1330
1399
|
end
|
|
1331
1400
|
`
|
|
1332
1401
|
}
|
|
@@ -1767,7 +1836,7 @@ export const makeStoreSql: (
|
|
|
1767
1836
|
yield* pollLatch.await
|
|
1768
1837
|
yield* Effect.yieldNow
|
|
1769
1838
|
nudge.closeUnsafe()
|
|
1770
|
-
const lock =
|
|
1839
|
+
const lock = SecureRandom.uuidV4Unsafe()
|
|
1771
1840
|
const results = takers.current === 0 ? [] : yield* poll(takers.current, stringLiteral(lock))
|
|
1772
1841
|
if (results.length === 0) {
|
|
1773
1842
|
yield* Effect.race(Effect.sleep(pollInterval), nudge.await)
|
|
@@ -16,7 +16,7 @@ import * as Duration from "../Duration.ts"
|
|
|
16
16
|
import * as Effect from "../Effect.ts"
|
|
17
17
|
import * as Exit from "../Exit.ts"
|
|
18
18
|
import { identity } from "../Function.ts"
|
|
19
|
-
import { sqlCleanupBatchSize } from "../internal/persistence.ts"
|
|
19
|
+
import { escapeRedisGlob, sqlCleanupBatchSize, storeNamespace } from "../internal/persistence.ts"
|
|
20
20
|
import * as Layer from "../Layer.ts"
|
|
21
21
|
import * as PrimaryKey from "../PrimaryKey.ts"
|
|
22
22
|
import * as Schedule from "../Schedule.ts"
|
|
@@ -377,7 +377,7 @@ export const layerBackingSqlMultiTable: Layer.Layer<
|
|
|
377
377
|
)
|
|
378
378
|
|
|
379
379
|
type UpsertFn = (
|
|
380
|
-
entries:
|
|
380
|
+
entries: Arr.NonEmptyReadonlyArray<{ id: string; value: string; expires: number | null }>
|
|
381
381
|
) => Effect.Effect<unknown, SqlError>
|
|
382
382
|
|
|
383
383
|
const upsert = sql.onDialectOrElse({
|
|
@@ -492,7 +492,7 @@ export const layerBackingSqlMultiTable: Layer.Layer<
|
|
|
492
492
|
setMany: (entries) =>
|
|
493
493
|
Effect.suspend(() => {
|
|
494
494
|
try {
|
|
495
|
-
const encoded =
|
|
495
|
+
const encoded = Arr.map(entries, ([key, value, ttl]) => ({
|
|
496
496
|
id: key,
|
|
497
497
|
value: JSON.stringify(value),
|
|
498
498
|
expires: unsafeTtlToExpires(clock, ttl)
|
|
@@ -716,7 +716,7 @@ export const layerBackingSql: Layer.Layer<
|
|
|
716
716
|
)
|
|
717
717
|
|
|
718
718
|
type UpsertFn = (
|
|
719
|
-
entries:
|
|
719
|
+
entries: Arr.NonEmptyReadonlyArray<{ store_id: string; id: string; value: string; expires: number | null }>
|
|
720
720
|
) => Effect.Effect<unknown, SqlError>
|
|
721
721
|
|
|
722
722
|
const upsert = sql.onDialectOrElse({
|
|
@@ -841,7 +841,7 @@ export const layerBackingSql: Layer.Layer<
|
|
|
841
841
|
setMany: (entries) =>
|
|
842
842
|
Effect.suspend(() => {
|
|
843
843
|
try {
|
|
844
|
-
const encoded =
|
|
844
|
+
const encoded = Arr.map(entries, ([key, value, ttl]) => ({
|
|
845
845
|
store_id: storeId,
|
|
846
846
|
id: key,
|
|
847
847
|
value: JSON.stringify(value),
|
|
@@ -894,8 +894,10 @@ export const layerBackingSql: Layer.Layer<
|
|
|
894
894
|
*
|
|
895
895
|
* **Details**
|
|
896
896
|
*
|
|
897
|
-
*
|
|
898
|
-
*
|
|
897
|
+
* Entries are stored under `<storeId>:<key>`, with `%` and `:` in the store id
|
|
898
|
+
* percent-encoded so store namespaces cannot overlap. Values are JSON-encoded,
|
|
899
|
+
* finite TTLs are stored with Redis expiration, and `clear` only removes keys
|
|
900
|
+
* in the store's namespace.
|
|
899
901
|
*
|
|
900
902
|
* @stability unstable
|
|
901
903
|
* @category layers
|
|
@@ -910,9 +912,10 @@ export const layerBackingRedis: Layer.Layer<
|
|
|
910
912
|
const setMany = redis.eval(setManyRedis)
|
|
911
913
|
|
|
912
914
|
return BackingPersistence.of({
|
|
913
|
-
make: (
|
|
915
|
+
make: (storeId) =>
|
|
914
916
|
Effect.sync(() => {
|
|
915
|
-
const
|
|
917
|
+
const namespace = storeNamespace(storeId)
|
|
918
|
+
const prefixed = (key: string) => `${namespace}${key}`
|
|
916
919
|
const parse = (str: string | null) => {
|
|
917
920
|
if (str === null) {
|
|
918
921
|
return Effect.undefined
|
|
@@ -1007,7 +1010,7 @@ export const layerBackingRedis: Layer.Layer<
|
|
|
1007
1010
|
redis.send("DEL", prefixed(key)),
|
|
1008
1011
|
({ cause }) => new PersistenceError({ message: `Failed to remove key ${key} from Redis`, cause })
|
|
1009
1012
|
),
|
|
1010
|
-
clear: redis.send<Array<string>>("KEYS", `${
|
|
1013
|
+
clear: redis.send<Array<string>>("KEYS", `${escapeRedisGlob(namespace)}*`).pipe(
|
|
1011
1014
|
Effect.flatMap((keys) => keys.length === 0 ? Effect.void : redis.send("DEL", ...keys)),
|
|
1012
1015
|
Effect.mapError(({ cause }) =>
|
|
1013
1016
|
new PersistenceError({
|
|
@@ -1062,8 +1065,12 @@ end
|
|
|
1062
1065
|
*
|
|
1063
1066
|
* **Details**
|
|
1064
1067
|
*
|
|
1065
|
-
*
|
|
1066
|
-
*
|
|
1068
|
+
* Entries are stored under `<storeId>:<key>`, with `%` and `:` in the store id
|
|
1069
|
+
* percent-encoded so store namespaces cannot overlap. Values are stored as JSON
|
|
1070
|
+
* with optional expiration timestamps.
|
|
1071
|
+
*
|
|
1072
|
+
* `clear` uses `KeyValueStore.clearPrefix` to remove only the store's entries,
|
|
1073
|
+
* so the backing store must support it.
|
|
1067
1074
|
*
|
|
1068
1075
|
* @stability unstable
|
|
1069
1076
|
* @category layers
|
|
@@ -1079,7 +1086,7 @@ export const layerBackingKvs: Layer.Layer<
|
|
|
1079
1086
|
return BackingPersistence.of({
|
|
1080
1087
|
make: (storeId) =>
|
|
1081
1088
|
Effect.sync(() => {
|
|
1082
|
-
const store = KeyValueStore.prefix(backing, storeId)
|
|
1089
|
+
const store = KeyValueStore.prefix(backing, storeNamespace(storeId))
|
|
1083
1090
|
const get = (key: string) =>
|
|
1084
1091
|
Effect.flatMap(
|
|
1085
1092
|
Effect.mapError(
|