effect 4.1.3 → 4.1.5
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/THIRD_PARTY_NOTICES.md +88 -0
- package/ai-docs/package.json +2 -2
- package/dist/Arbitrary.d.ts +44 -2
- package/dist/Arbitrary.d.ts.map +1 -1
- package/dist/Arbitrary.js +9 -1
- package/dist/Arbitrary.js.map +1 -1
- package/dist/BigInt.d.ts +200 -1
- package/dist/BigInt.d.ts.map +1 -1
- package/dist/BigInt.js +105 -9
- package/dist/BigInt.js.map +1 -1
- package/dist/Cache.d.ts.map +1 -1
- package/dist/Cache.js +4 -2
- package/dist/Cache.js.map +1 -1
- package/dist/Cause.d.ts +3 -3
- package/dist/Cause.js +1 -1
- package/dist/Chunk.d.ts +5 -0
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Chunk.js +7 -2
- package/dist/Chunk.js.map +1 -1
- package/dist/Clock.d.ts +5 -2
- package/dist/Clock.d.ts.map +1 -1
- package/dist/Clock.js +2 -1
- package/dist/Clock.js.map +1 -1
- package/dist/Codegen.d.ts +295 -0
- package/dist/Codegen.d.ts.map +1 -0
- package/dist/Codegen.js +521 -0
- package/dist/Codegen.js.map +1 -0
- package/dist/Config.d.ts +31 -2
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +12 -1
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.d.ts +11 -1
- package/dist/ConfigProvider.d.ts.map +1 -1
- package/dist/ConfigProvider.js +17 -6
- package/dist/ConfigProvider.js.map +1 -1
- package/dist/Effect.d.ts +869 -109
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +400 -47
- package/dist/Effect.js.map +1 -1
- package/dist/Equivalence.d.ts +11 -9
- package/dist/Equivalence.d.ts.map +1 -1
- package/dist/Equivalence.js +15 -12
- package/dist/Equivalence.js.map +1 -1
- package/dist/Fiber.d.ts +58 -8
- package/dist/Fiber.d.ts.map +1 -1
- package/dist/Fiber.js +28 -4
- package/dist/Fiber.js.map +1 -1
- package/dist/FiberHandle.d.ts +81 -10
- package/dist/FiberHandle.d.ts.map +1 -1
- package/dist/FiberHandle.js +40 -8
- package/dist/FiberHandle.js.map +1 -1
- package/dist/FiberMap.d.ts +80 -10
- package/dist/FiberMap.d.ts.map +1 -1
- package/dist/FiberMap.js +37 -6
- package/dist/FiberMap.js.map +1 -1
- package/dist/FiberSet.d.ts +93 -8
- package/dist/FiberSet.d.ts.map +1 -1
- package/dist/FiberSet.js +46 -4
- package/dist/FiberSet.js.map +1 -1
- package/dist/Formatter.d.ts +2 -0
- package/dist/Formatter.d.ts.map +1 -1
- package/dist/Formatter.js +2 -0
- package/dist/Formatter.js.map +1 -1
- package/dist/LayerMap.d.ts +12 -3
- package/dist/LayerMap.d.ts.map +1 -1
- package/dist/LayerMap.js +12 -2
- package/dist/LayerMap.js.map +1 -1
- package/dist/LayerRef.d.ts +2 -2
- package/dist/Match.d.ts +12 -0
- package/dist/Match.d.ts.map +1 -1
- package/dist/Match.js +16 -0
- package/dist/Match.js.map +1 -1
- package/dist/Metric.js +1 -1
- package/dist/Metric.js.map +1 -1
- package/dist/Option.d.ts +4 -1
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js +6 -2
- package/dist/Option.js.map +1 -1
- package/dist/Order.d.ts +7 -5
- package/dist/Order.d.ts.map +1 -1
- package/dist/Order.js +7 -2
- package/dist/Order.js.map +1 -1
- package/dist/Pool.d.ts +4 -3
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +21 -18
- package/dist/Pool.js.map +1 -1
- package/dist/Predicate.d.ts +4 -1
- package/dist/Predicate.d.ts.map +1 -1
- package/dist/Predicate.js +5 -1
- package/dist/Predicate.js.map +1 -1
- package/dist/Queue.d.ts +69 -22
- package/dist/Queue.d.ts.map +1 -1
- package/dist/Queue.js +40 -18
- package/dist/Queue.js.map +1 -1
- package/dist/Rational.d.ts +179 -0
- package/dist/Rational.d.ts.map +1 -1
- package/dist/Rational.js +63 -0
- package/dist/Rational.js.map +1 -1
- package/dist/Request.d.ts +20 -0
- package/dist/Request.d.ts.map +1 -1
- package/dist/Request.js +20 -0
- package/dist/Request.js.map +1 -1
- package/dist/Result.d.ts +3 -1
- package/dist/Result.d.ts.map +1 -1
- package/dist/Result.js +5 -2
- package/dist/Result.js.map +1 -1
- package/dist/Schema.d.ts +49 -19
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +44 -27
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +11 -4
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaGetter.d.ts +5 -6
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +14 -10
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +36 -67
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +5 -30
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +11 -10
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +12 -11
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/Scope.d.ts +12 -6
- package/dist/Scope.d.ts.map +1 -1
- package/dist/Scope.js +12 -6
- package/dist/Scope.js.map +1 -1
- package/dist/ScopedCache.d.ts.map +1 -1
- package/dist/ScopedCache.js +2 -1
- package/dist/ScopedCache.js.map +1 -1
- package/dist/Semaphore.d.ts.map +1 -1
- package/dist/Semaphore.js +18 -4
- package/dist/Semaphore.js.map +1 -1
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +55 -14
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +57 -3
- package/dist/String.d.ts.map +1 -1
- package/dist/String.js +62 -4
- package/dist/String.js.map +1 -1
- package/dist/Struct.d.ts +135 -1
- package/dist/Struct.d.ts.map +1 -1
- package/dist/Struct.js +64 -5
- package/dist/Struct.js.map +1 -1
- package/dist/TextDiff.d.ts +105 -0
- package/dist/TextDiff.d.ts.map +1 -1
- package/dist/TextDiff.js +137 -24
- package/dist/TextDiff.js.map +1 -1
- package/dist/TxPriorityQueue.js +2 -2
- package/dist/TxPriorityQueue.js.map +1 -1
- package/dist/ai/Chat.d.ts +1 -1
- package/dist/ai/Chat.d.ts.map +1 -1
- package/dist/ai/Chat.js.map +1 -1
- package/dist/ai/LanguageModel.d.ts +23 -4
- package/dist/ai/LanguageModel.d.ts.map +1 -1
- package/dist/ai/LanguageModel.js +9 -5
- package/dist/ai/LanguageModel.js.map +1 -1
- package/dist/ai/McpClient.d.ts +0 -5
- package/dist/ai/McpClient.d.ts.map +1 -1
- package/dist/ai/McpClient.js +1 -11
- package/dist/ai/McpClient.js.map +1 -1
- package/dist/ai/McpSchema.d.ts +128 -128
- package/dist/ai/McpSchema.d.ts.map +1 -1
- package/dist/ai/McpServer.d.ts +48 -5
- package/dist/ai/McpServer.d.ts.map +1 -1
- package/dist/ai/McpServer.js +136 -19
- package/dist/ai/McpServer.js.map +1 -1
- package/dist/ai/Tool.d.ts +3 -2
- package/dist/ai/Tool.d.ts.map +1 -1
- package/dist/ai/Tool.js +3 -2
- package/dist/ai/Tool.js.map +1 -1
- package/dist/ai/Toolkit.d.ts.map +1 -1
- package/dist/ai/Toolkit.js +5 -1
- package/dist/ai/Toolkit.js.map +1 -1
- package/dist/ai/WorkloadIdentity.d.ts +111 -0
- package/dist/ai/WorkloadIdentity.d.ts.map +1 -0
- package/dist/ai/WorkloadIdentity.js +227 -0
- package/dist/ai/WorkloadIdentity.js.map +1 -0
- 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/mcpProtocol/v2024_11_05.js +3 -1
- package/dist/ai/internal/mcpProtocol/v2024_11_05.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_03_26.js +3 -1
- package/dist/ai/internal/mcpProtocol/v2025_03_26.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_06_18.js +3 -1
- package/dist/ai/internal/mcpProtocol/v2025_06_18.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_11_25.js +3 -1
- package/dist/ai/internal/mcpProtocol/v2025_11_25.js.map +1 -1
- package/dist/ai/internal/mcpRuntime.js +2 -4
- package/dist/ai/internal/mcpRuntime.js.map +1 -1
- package/dist/ai/internal/mcpSkills.js +80 -2
- package/dist/ai/internal/mcpSkills.js.map +1 -1
- package/dist/ai/internal/structured-output.js +5 -1
- package/dist/ai/internal/structured-output.js.map +1 -1
- package/dist/chat/Chat.d.ts +90 -0
- package/dist/chat/Chat.d.ts.map +1 -0
- package/dist/chat/Chat.js +127 -0
- package/dist/chat/Chat.js.map +1 -0
- package/dist/chat/ChatAdapter.d.ts +386 -0
- package/dist/chat/ChatAdapter.d.ts.map +1 -0
- package/dist/chat/ChatAdapter.js +110 -0
- package/dist/chat/ChatAdapter.js.map +1 -0
- package/dist/chat/ChatError.d.ts +500 -0
- package/dist/chat/ChatError.d.ts.map +1 -0
- package/dist/chat/ChatError.js +521 -0
- package/dist/chat/ChatError.js.map +1 -0
- package/dist/chat/ChatEvent.d.ts +321 -0
- package/dist/chat/ChatEvent.d.ts.map +1 -0
- package/dist/chat/ChatEvent.js +163 -0
- package/dist/chat/ChatEvent.js.map +1 -0
- package/dist/chat/ChatHandler.d.ts +81 -0
- package/dist/chat/ChatHandler.d.ts.map +1 -0
- package/dist/chat/ChatHandler.js +85 -0
- package/dist/chat/ChatHandler.js.map +1 -0
- package/dist/chat/ChatInteraction.d.ts +1519 -0
- package/dist/chat/ChatInteraction.d.ts.map +1 -0
- package/dist/chat/ChatInteraction.js +1052 -0
- package/dist/chat/ChatInteraction.js.map +1 -0
- package/dist/chat/ChatMarkdown.d.ts +280 -0
- package/dist/chat/ChatMarkdown.d.ts.map +1 -0
- package/dist/chat/ChatMarkdown.js +1172 -0
- package/dist/chat/ChatMarkdown.js.map +1 -0
- package/dist/chat/ChatMessage.d.ts +224 -0
- package/dist/chat/ChatMessage.d.ts.map +1 -0
- package/dist/chat/ChatMessage.js +172 -0
- package/dist/chat/ChatMessage.js.map +1 -0
- package/dist/chat/ChatTest.d.ts +407 -0
- package/dist/chat/ChatTest.d.ts.map +1 -0
- package/dist/chat/ChatTest.js +2145 -0
- package/dist/chat/ChatTest.js.map +1 -0
- package/dist/chat/ChatThread.d.ts +92 -0
- package/dist/chat/ChatThread.d.ts.map +1 -0
- package/dist/chat/ChatThread.js +116 -0
- package/dist/chat/ChatThread.js.map +1 -0
- package/dist/chat/ChatUi.d.ts +362 -0
- package/dist/chat/ChatUi.d.ts.map +1 -0
- package/dist/chat/ChatUi.js +209 -0
- package/dist/chat/ChatUi.js.map +1 -0
- package/dist/chat/index.d.ts +60 -0
- package/dist/chat/index.d.ts.map +1 -0
- package/dist/chat/index.js +61 -0
- package/dist/chat/index.js.map +1 -0
- package/dist/chat/internal/retries.d.ts +2 -0
- package/dist/chat/internal/retries.d.ts.map +1 -0
- package/dist/chat/internal/retries.js +7 -0
- package/dist/chat/internal/retries.js.map +1 -0
- package/dist/cli/CliOutput.d.ts.map +1 -1
- package/dist/cli/CliOutput.js +6 -7
- package/dist/cli/CliOutput.js.map +1 -1
- package/dist/cli/Command.d.ts +20 -2
- package/dist/cli/Command.d.ts.map +1 -1
- package/dist/cli/Command.js +7 -1
- package/dist/cli/Command.js.map +1 -1
- package/dist/cli/Prompt.d.ts +5 -6
- package/dist/cli/Prompt.d.ts.map +1 -1
- package/dist/cli/Prompt.js +9 -4
- package/dist/cli/Prompt.js.map +1 -1
- package/dist/cli/internal/command.d.ts +1 -1
- package/dist/cli/internal/command.d.ts.map +1 -1
- package/dist/cli/internal/config.d.ts +1 -1
- package/dist/cli/internal/config.d.ts.map +1 -1
- package/dist/cli/internal/config.js +3 -3
- package/dist/cli/internal/config.js.map +1 -1
- package/dist/cli/internal/lexer.js +13 -0
- package/dist/cli/internal/lexer.js.map +1 -1
- package/dist/cli/internal/parser.js +23 -16
- package/dist/cli/internal/parser.js.map +1 -1
- package/dist/cli/internal/wizard.d.ts.map +1 -1
- package/dist/cli/internal/wizard.js +4 -0
- package/dist/cli/internal/wizard.js.map +1 -1
- package/dist/cluster/ClusterCron.d.ts +21 -1
- package/dist/cluster/ClusterCron.d.ts.map +1 -1
- package/dist/cluster/ClusterCron.js +24 -6
- package/dist/cluster/ClusterCron.js.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.js +30 -22
- package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/cluster/Sharding.d.ts.map +1 -1
- package/dist/cluster/Sharding.js +15 -3
- package/dist/cluster/Sharding.js.map +1 -1
- package/dist/cluster/ShardingConfig.d.ts +6 -0
- package/dist/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/cluster/ShardingConfig.js.map +1 -1
- package/dist/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/cluster/SqlMessageStorage.js +13 -15
- package/dist/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/cluster/SqlRunnerStorage.d.ts.map +1 -1
- package/dist/cluster/SqlRunnerStorage.js +18 -8
- package/dist/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/cluster/internal/entityManager.js +12 -8
- package/dist/cluster/internal/entityManager.js.map +1 -1
- package/dist/cluster/internal/entityReaper.js +1 -1
- package/dist/cluster/internal/entityReaper.js.map +1 -1
- package/dist/crypto/Kdf.d.ts +2 -1
- package/dist/crypto/Kdf.d.ts.map +1 -1
- package/dist/crypto/Kdf.js +2 -1
- package/dist/crypto/Kdf.js.map +1 -1
- package/dist/crypto/Password.d.ts +162 -0
- package/dist/crypto/Password.d.ts.map +1 -0
- package/dist/crypto/Password.js +217 -0
- package/dist/crypto/Password.js.map +1 -0
- package/dist/crypto/index.d.ts +5 -0
- package/dist/crypto/index.d.ts.map +1 -1
- package/dist/crypto/index.js +5 -0
- package/dist/crypto/index.js.map +1 -1
- package/dist/encoding/Base64.d.ts +63 -0
- package/dist/encoding/Base64.d.ts.map +1 -1
- package/dist/encoding/Base64.js +77 -0
- package/dist/encoding/Base64.js.map +1 -1
- package/dist/encoding/Base64Url.d.ts +1 -0
- package/dist/encoding/Base64Url.d.ts.map +1 -1
- package/dist/encoding/Base64Url.js +1 -0
- package/dist/encoding/Base64Url.js.map +1 -1
- package/dist/encoding/Csv.d.ts.map +1 -1
- package/dist/encoding/Csv.js +44 -16
- package/dist/encoding/Csv.js.map +1 -1
- package/dist/encoding/Hex.d.ts +5 -0
- package/dist/encoding/Hex.d.ts.map +1 -1
- package/dist/encoding/Hex.js +5 -0
- package/dist/encoding/Hex.js.map +1 -1
- package/dist/encoding/SchemaBinary.d.ts.map +1 -1
- package/dist/encoding/SchemaBinary.js +13 -124
- package/dist/encoding/SchemaBinary.js.map +1 -1
- package/dist/encoding/Sse.d.ts +1 -0
- package/dist/encoding/Sse.d.ts.map +1 -1
- package/dist/encoding/Sse.js +7 -5
- package/dist/encoding/Sse.js.map +1 -1
- package/dist/encoding/Xml.d.ts +117 -11
- package/dist/encoding/Xml.d.ts.map +1 -1
- package/dist/encoding/Xml.js +332 -42
- package/dist/encoding/Xml.js.map +1 -1
- package/dist/eventlog/EventJournal.d.ts.map +1 -1
- package/dist/eventlog/EventJournal.js +3 -8
- package/dist/eventlog/EventJournal.js.map +1 -1
- package/dist/eventlog/SqlEventLogServerEncrypted.js +6 -8
- package/dist/eventlog/SqlEventLogServerEncrypted.js.map +1 -1
- package/dist/http/FindMyWay/internal/router.js +163 -116
- package/dist/http/FindMyWay/internal/router.js.map +1 -1
- package/dist/http/FindMyWay.d.ts +99 -0
- package/dist/http/FindMyWay.d.ts.map +1 -1
- package/dist/http/FindMyWay.js +39 -0
- package/dist/http/FindMyWay.js.map +1 -1
- package/dist/http/HttpClient.d.ts.map +1 -1
- package/dist/http/HttpClient.js +1 -1
- package/dist/http/HttpClient.js.map +1 -1
- package/dist/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/http/HttpMiddleware.js +18 -9
- package/dist/http/HttpMiddleware.js.map +1 -1
- package/dist/http/HttpRouter.d.ts +49 -1
- package/dist/http/HttpRouter.d.ts.map +1 -1
- package/dist/http/HttpRouter.js +70 -20
- package/dist/http/HttpRouter.js.map +1 -1
- package/dist/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/http/HttpServerResponse.js +24 -58
- package/dist/http/HttpServerResponse.js.map +1 -1
- package/dist/http/Mime.d.ts.map +1 -1
- package/dist/http/Mime.js +3 -2
- package/dist/http/Mime.js.map +1 -1
- package/dist/http/internal/compression.d.ts.map +1 -1
- package/dist/http/internal/compression.js +2 -2
- package/dist/http/internal/compression.js.map +1 -1
- package/dist/http/internal/mediaType.d.ts.map +1 -0
- package/dist/{http-api → http}/internal/mediaType.js +4 -0
- package/dist/{http-api → http}/internal/mediaType.js.map +1 -1
- package/dist/http/internal/redactedPath.d.ts +2 -0
- package/dist/http/internal/redactedPath.d.ts.map +1 -0
- package/dist/http/internal/redactedPath.js +138 -0
- package/dist/http/internal/redactedPath.js.map +1 -0
- package/dist/http/internal/requestState.js +16 -0
- package/dist/http/internal/requestState.js.map +1 -1
- package/dist/http-api/HttpApi.d.ts +58 -0
- package/dist/http-api/HttpApi.d.ts.map +1 -1
- package/dist/http-api/HttpApi.js +80 -0
- 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 +12 -3
- package/dist/http-api/HttpApiBuilder.js.map +1 -1
- package/dist/http-api/HttpApiClient.d.ts +1 -1
- package/dist/http-api/HttpApiClient.d.ts.map +1 -1
- package/dist/http-api/HttpApiClient.js +11 -7
- 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 +1 -1
- package/dist/http-api/HttpApiEndpoint.js.map +1 -1
- package/dist/http-api/HttpApiScalar.d.ts +4 -0
- package/dist/http-api/HttpApiScalar.d.ts.map +1 -1
- package/dist/http-api/HttpApiScalar.js +10 -1
- package/dist/http-api/HttpApiScalar.js.map +1 -1
- package/dist/http-api/HttpApiSchema.d.ts +66 -0
- package/dist/http-api/HttpApiSchema.d.ts.map +1 -1
- package/dist/http-api/HttpApiSchema.js +67 -2
- package/dist/http-api/HttpApiSchema.js.map +1 -1
- package/dist/http-api/OpenApi.d.ts +2 -0
- package/dist/http-api/OpenApi.d.ts.map +1 -1
- package/dist/http-api/internal/httpApiScalar.js +5 -2
- package/dist/http-api/internal/httpApiScalar.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/arbitrary/model.js +0 -5
- package/dist/internal/arbitrary/model.js.map +1 -1
- package/dist/internal/arbitrary/regexp.js +2 -1
- package/dist/internal/arbitrary/regexp.js.map +1 -1
- package/dist/internal/arbitrary/runner.d.ts.map +1 -1
- package/dist/internal/arbitrary/runner.js +21 -16
- package/dist/internal/arbitrary/runner.js.map +1 -1
- package/dist/internal/arbitrary/schema.js +140 -23
- package/dist/internal/arbitrary/schema.js.map +1 -1
- package/dist/internal/codegen.d.ts +2 -0
- package/dist/internal/codegen.d.ts.map +1 -0
- package/dist/internal/codegen.js +59 -0
- package/dist/internal/codegen.js.map +1 -0
- package/dist/internal/core.js +3 -3
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/dateTime.js +26 -12
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +21 -7
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/hashMap.js +7 -7
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/matcher.js +2 -1
- package/dist/internal/matcher.js.map +1 -1
- package/dist/internal/record.js +18 -4
- package/dist/internal/record.js.map +1 -1
- package/dist/internal/result.js +1 -1
- package/dist/internal/result.js.map +1 -1
- package/dist/internal/schema/codeExpression.d.ts +4 -0
- package/dist/internal/schema/codeExpression.d.ts.map +1 -0
- package/dist/internal/schema/codeExpression.js +179 -0
- package/dist/internal/schema/codeExpression.js.map +1 -0
- package/dist/internal/schema/codeImports.d.ts +8 -0
- package/dist/internal/schema/codeImports.d.ts.map +1 -0
- package/dist/internal/schema/codeImports.js +135 -0
- package/dist/internal/schema/codeImports.js.map +1 -0
- package/dist/internal/schema/codeTokens.d.ts +8 -0
- package/dist/internal/schema/codeTokens.d.ts.map +1 -0
- package/dist/internal/schema/codeTokens.js +17 -0
- package/dist/internal/schema/codeTokens.js.map +1 -0
- package/dist/internal/schema/fromJsonSchemaDocument.js +141 -35
- package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -1
- package/dist/internal/schema/passthrough.d.ts +2 -0
- package/dist/internal/schema/passthrough.d.ts.map +1 -0
- package/dist/internal/schema/passthrough.js +8 -0
- package/dist/internal/schema/passthrough.js.map +1 -0
- package/dist/internal/schema/schemaCodegen.d.ts +2 -0
- package/dist/internal/schema/schemaCodegen.d.ts.map +1 -0
- package/dist/internal/schema/schemaCodegen.js +377 -0
- package/dist/internal/schema/schemaCodegen.js.map +1 -0
- package/dist/internal/schema/toJsonSchemaDocument.js +11 -4
- package/dist/internal/schema/toJsonSchemaDocument.js.map +1 -1
- package/dist/internal/trie.js +51 -64
- package/dist/internal/trie.js.map +1 -1
- package/dist/internal/utf8.d.ts +2 -0
- package/dist/internal/utf8.d.ts.map +1 -0
- package/dist/internal/utf8.js +151 -0
- package/dist/internal/utf8.js.map +1 -0
- package/dist/internal/version.js +1 -1
- package/dist/jose/Jwks.d.ts +13 -0
- package/dist/jose/Jwks.d.ts.map +1 -1
- package/dist/jose/Jwks.js +10 -2
- package/dist/jose/Jwks.js.map +1 -1
- package/dist/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/observability/OtlpExporter.js +12 -10
- package/dist/observability/OtlpExporter.js.map +1 -1
- package/dist/observability/OtlpLogger.d.ts.map +1 -1
- package/dist/observability/OtlpLogger.js +5 -3
- package/dist/observability/OtlpLogger.js.map +1 -1
- package/dist/observability/internal/otlpProtobuf.d.ts +4 -2
- package/dist/observability/internal/otlpProtobuf.d.ts.map +1 -1
- package/dist/observability/internal/otlpProtobuf.js +238 -156
- package/dist/observability/internal/otlpProtobuf.js.map +1 -1
- package/dist/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/persistence/PersistedQueue.js +20 -3
- package/dist/persistence/PersistedQueue.js.map +1 -1
- package/dist/protobuf/ProtobufDescriptor.d.ts +377 -0
- package/dist/protobuf/ProtobufDescriptor.d.ts.map +1 -0
- package/dist/protobuf/ProtobufDescriptor.js +135 -0
- package/dist/protobuf/ProtobufDescriptor.js.map +1 -0
- package/dist/protobuf/ProtobufDescriptorProto.d.ts +2083 -0
- package/dist/protobuf/ProtobufDescriptorProto.d.ts.map +1 -0
- package/dist/protobuf/ProtobufDescriptorProto.js +2674 -0
- package/dist/protobuf/ProtobufDescriptorProto.js.map +1 -0
- package/dist/protobuf/ProtobufMessage.d.ts +183 -0
- package/dist/protobuf/ProtobufMessage.d.ts.map +1 -0
- package/dist/protobuf/ProtobufMessage.js +232 -0
- package/dist/protobuf/ProtobufMessage.js.map +1 -0
- package/dist/protobuf/ProtobufReader.d.ts +350 -0
- package/dist/protobuf/ProtobufReader.d.ts.map +1 -0
- package/dist/protobuf/ProtobufReader.js +698 -0
- package/dist/protobuf/ProtobufReader.js.map +1 -0
- package/dist/protobuf/ProtobufWriter.d.ts +224 -0
- package/dist/protobuf/ProtobufWriter.d.ts.map +1 -0
- package/dist/protobuf/ProtobufWriter.js +483 -0
- package/dist/protobuf/ProtobufWriter.js.map +1 -0
- package/dist/protobuf/index.d.ts +30 -0
- package/dist/protobuf/index.d.ts.map +1 -0
- package/dist/protobuf/index.js +31 -0
- package/dist/protobuf/index.js.map +1 -0
- package/dist/protobuf/internal/binary.d.ts +2 -0
- package/dist/protobuf/internal/binary.d.ts.map +1 -0
- package/dist/protobuf/internal/binary.js +966 -0
- package/dist/protobuf/internal/binary.js.map +1 -0
- package/dist/protobuf/internal/resolve.d.ts +2 -0
- package/dist/protobuf/internal/resolve.d.ts.map +1 -0
- package/dist/protobuf/internal/resolve.js +463 -0
- package/dist/protobuf/internal/resolve.js.map +1 -0
- package/dist/protobuf/internal/wireType.d.ts +2 -0
- package/dist/protobuf/internal/wireType.d.ts.map +1 -0
- package/dist/protobuf/internal/wireType.js +10 -0
- package/dist/protobuf/internal/wireType.js.map +1 -0
- package/dist/reactivity/AsyncResult.d.ts +3 -0
- package/dist/reactivity/AsyncResult.d.ts.map +1 -1
- package/dist/reactivity/AsyncResult.js +4 -1
- package/dist/reactivity/AsyncResult.js.map +1 -1
- package/dist/reactivity/Atom.d.ts +10 -4
- package/dist/reactivity/Atom.d.ts.map +1 -1
- package/dist/reactivity/Atom.js +38 -13
- package/dist/reactivity/Atom.js.map +1 -1
- package/dist/reactivity/AtomHttpApi.d.ts +5 -0
- package/dist/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/reactivity/AtomHttpApi.js +5 -1
- package/dist/reactivity/AtomHttpApi.js.map +1 -1
- package/dist/reactivity/AtomRegistry.js +13 -0
- package/dist/reactivity/AtomRegistry.js.map +1 -1
- package/dist/reactivity/AtomRpc.d.ts +5 -0
- package/dist/reactivity/AtomRpc.d.ts.map +1 -1
- package/dist/reactivity/AtomRpc.js +6 -1
- package/dist/reactivity/AtomRpc.js.map +1 -1
- package/dist/rpc/Rpc.d.ts +25 -0
- package/dist/rpc/Rpc.d.ts.map +1 -1
- package/dist/rpc/Rpc.js +18 -0
- package/dist/rpc/Rpc.js.map +1 -1
- package/dist/rpc/RpcClient.d.ts.map +1 -1
- package/dist/rpc/RpcClient.js +38 -21
- package/dist/rpc/RpcClient.js.map +1 -1
- package/dist/rpc/RpcGroup.d.ts +5 -0
- package/dist/rpc/RpcGroup.d.ts.map +1 -1
- package/dist/rpc/RpcGroup.js.map +1 -1
- package/dist/rpc/RpcMiddleware.d.ts +9 -0
- package/dist/rpc/RpcMiddleware.d.ts.map +1 -1
- package/dist/rpc/RpcMiddleware.js.map +1 -1
- package/dist/rpc/RpcSerialization.d.ts +7 -1
- package/dist/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/rpc/RpcSerialization.js +22 -5
- package/dist/rpc/RpcSerialization.js.map +1 -1
- package/dist/rpc/RpcServer.d.ts.map +1 -1
- package/dist/rpc/RpcServer.js +33 -18
- package/dist/rpc/RpcServer.js.map +1 -1
- package/dist/schema/SchemaCompiler/runtime.js +2 -1
- package/dist/schema/SchemaCompiler/runtime.js.map +1 -1
- package/dist/schema/VariantSchema.d.ts +10 -2
- package/dist/schema/VariantSchema.d.ts.map +1 -1
- package/dist/schema/VariantSchema.js +7 -1
- package/dist/schema/VariantSchema.js.map +1 -1
- package/dist/socket/Socket.d.ts +24 -10
- package/dist/socket/Socket.d.ts.map +1 -1
- package/dist/socket/Socket.js +52 -17
- package/dist/socket/Socket.js.map +1 -1
- package/dist/sql/Migrator.d.ts +3 -0
- package/dist/sql/Migrator.d.ts.map +1 -1
- package/dist/sql/Migrator.js +10 -1
- package/dist/sql/Migrator.js.map +1 -1
- package/dist/sql/SqlModel.d.ts.map +1 -1
- package/dist/sql/SqlModel.js +1 -0
- package/dist/sql/SqlModel.js.map +1 -1
- package/dist/testing/TestClock.js +3 -1
- package/dist/testing/TestClock.js.map +1 -1
- package/dist/testing/TestConsole.d.ts +96 -0
- package/dist/testing/TestConsole.d.ts.map +1 -1
- package/dist/testing/TestConsole.js +78 -6
- package/dist/testing/TestConsole.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +5 -1
- package/dist/testing/TestSchema.d.ts.map +1 -1
- package/dist/testing/TestSchema.js +7 -2
- package/dist/testing/TestSchema.js.map +1 -1
- package/dist/workers/SharedMemory.d.ts +115 -0
- package/dist/workers/SharedMemory.d.ts.map +1 -0
- package/dist/workers/SharedMemory.js +149 -0
- package/dist/workers/SharedMemory.js.map +1 -0
- package/dist/workers/Transferable.d.ts.map +1 -1
- package/dist/workers/Transferable.js +1 -4
- package/dist/workers/Transferable.js.map +1 -1
- package/dist/workers/index.d.ts +5 -0
- package/dist/workers/index.d.ts.map +1 -1
- package/dist/workers/index.js +5 -0
- package/dist/workers/index.js.map +1 -1
- package/dist/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/workflow/WorkflowEngine.js +3 -1
- package/dist/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +7 -4
- package/src/Arbitrary.ts +60 -3
- package/src/BigInt.ts +247 -9
- package/src/Cache.ts +4 -2
- package/src/Cause.ts +3 -3
- package/src/Chunk.ts +7 -3
- package/src/Clock.ts +5 -2
- package/src/Codegen.ts +741 -0
- package/src/Config.ts +35 -4
- package/src/ConfigProvider.ts +24 -7
- package/src/Effect.ts +871 -109
- package/src/Equivalence.ts +16 -13
- package/src/Fiber.ts +58 -8
- package/src/FiberHandle.ts +86 -12
- package/src/FiberMap.ts +83 -10
- package/src/FiberSet.ts +96 -8
- package/src/Formatter.ts +2 -0
- package/src/LayerMap.ts +14 -4
- package/src/LayerRef.ts +2 -2
- package/src/Match.ts +16 -0
- package/src/Metric.ts +1 -1
- package/src/Option.ts +9 -5
- package/src/Order.ts +9 -4
- package/src/Pool.ts +22 -17
- package/src/Predicate.ts +7 -3
- package/src/Queue.ts +84 -31
- package/src/Rational.ts +198 -0
- package/src/Request.ts +20 -0
- package/src/Result.ts +9 -6
- package/src/Schema.ts +69 -32
- package/src/SchemaAST.ts +15 -4
- package/src/SchemaGetter.ts +17 -10
- package/src/SchemaRepresentation.ts +37 -77
- package/src/SchemaTransformation.ts +12 -11
- package/src/Scope.ts +12 -6
- package/src/ScopedCache.ts +2 -1
- package/src/Semaphore.ts +18 -4
- package/src/Stream.ts +66 -20
- package/src/String.ts +83 -6
- package/src/Struct.ts +138 -5
- package/src/TextDiff.ts +186 -30
- package/src/TxPriorityQueue.ts +2 -2
- package/src/ai/Chat.ts +9 -3
- package/src/ai/LanguageModel.ts +72 -15
- package/src/ai/McpClient.ts +1 -11
- package/src/ai/McpServer.ts +146 -25
- package/src/ai/Tool.ts +3 -2
- package/src/ai/Toolkit.ts +3 -1
- package/src/ai/WorkloadIdentity.ts +318 -0
- package/src/ai/index.ts +6 -0
- package/src/ai/internal/mcpProtocol/v2024_11_05.ts +3 -1
- package/src/ai/internal/mcpProtocol/v2025_03_26.ts +3 -1
- package/src/ai/internal/mcpProtocol/v2025_06_18.ts +3 -1
- package/src/ai/internal/mcpProtocol/v2025_11_25.ts +3 -1
- package/src/ai/internal/mcpRuntime.ts +2 -6
- package/src/ai/internal/mcpSkills.ts +70 -2
- package/src/ai/internal/structured-output.ts +6 -1
- package/src/chat/Chat.ts +164 -0
- package/src/chat/ChatAdapter.ts +444 -0
- package/src/chat/ChatError.ts +684 -0
- package/src/chat/ChatEvent.ts +221 -0
- package/src/chat/ChatHandler.ts +102 -0
- package/src/chat/ChatInteraction.ts +1979 -0
- package/src/chat/ChatMarkdown.ts +1406 -0
- package/src/chat/ChatMessage.ts +213 -0
- package/src/chat/ChatTest.ts +2606 -0
- package/src/chat/ChatThread.ts +132 -0
- package/src/chat/ChatUi.ts +320 -0
- package/src/chat/index.ts +72 -0
- package/src/chat/internal/retries.ts +7 -0
- package/src/cli/CliOutput.ts +4 -5
- package/src/cli/Command.ts +25 -3
- package/src/cli/Prompt.ts +15 -9
- package/src/cli/internal/config.ts +8 -8
- package/src/cli/internal/lexer.ts +14 -0
- package/src/cli/internal/parser.ts +28 -20
- package/src/cli/internal/wizard.ts +4 -0
- package/src/cluster/ClusterCron.ts +33 -10
- package/src/cluster/ClusterWorkflowEngine.ts +42 -23
- package/src/cluster/Sharding.ts +17 -3
- package/src/cluster/ShardingConfig.ts +3 -0
- package/src/cluster/SqlMessageStorage.ts +16 -20
- package/src/cluster/SqlRunnerStorage.ts +21 -8
- package/src/cluster/internal/entityManager.ts +19 -10
- package/src/cluster/internal/entityReaper.ts +1 -1
- package/src/crypto/Kdf.ts +2 -1
- package/src/crypto/Password.ts +258 -0
- package/src/crypto/index.ts +6 -0
- package/src/encoding/Base64.ts +79 -0
- package/src/encoding/Base64Url.ts +1 -0
- package/src/encoding/Csv.ts +47 -20
- package/src/encoding/Hex.ts +5 -0
- package/src/encoding/SchemaBinary.ts +13 -79
- package/src/encoding/Sse.ts +7 -5
- package/src/encoding/Xml.ts +394 -47
- package/src/eventlog/EventJournal.ts +3 -8
- package/src/eventlog/SqlEventLogServerEncrypted.ts +9 -9
- package/src/http/FindMyWay/internal/router.ts +181 -129
- package/src/http/FindMyWay.ts +106 -0
- package/src/http/HttpClient.ts +2 -1
- package/src/http/HttpMiddleware.ts +34 -10
- package/src/http/HttpRouter.ts +84 -20
- package/src/http/HttpServerResponse.ts +33 -61
- package/src/http/Mime.ts +3 -2
- package/src/http/internal/compression.ts +2 -2
- package/src/{http-api → http}/internal/mediaType.ts +4 -0
- package/src/http/internal/redactedPath.ts +144 -0
- package/src/http/internal/requestState.ts +22 -0
- package/src/http-api/HttpApi.ts +103 -0
- package/src/http-api/HttpApiBuilder.ts +14 -3
- package/src/http-api/HttpApiClient.ts +23 -8
- package/src/http-api/HttpApiEndpoint.ts +1 -1
- package/src/http-api/HttpApiScalar.ts +9 -1
- package/src/http-api/HttpApiSchema.ts +69 -3
- package/src/http-api/OpenApi.ts +2 -0
- package/src/http-api/internal/httpApiScalar.ts +5 -1
- package/src/index.ts +6 -0
- package/src/internal/arbitrary/model.ts +3 -9
- package/src/internal/arbitrary/regexp.ts +3 -1
- package/src/internal/arbitrary/runner.ts +28 -14
- package/src/internal/arbitrary/schema.ts +140 -35
- package/src/internal/codegen.ts +53 -0
- package/src/internal/core.ts +3 -3
- package/src/internal/dateTime.ts +30 -13
- package/src/internal/effect.ts +25 -9
- package/src/internal/hashMap.ts +8 -7
- package/src/internal/matcher.ts +2 -1
- package/src/internal/record.ts +19 -4
- package/src/internal/result.ts +1 -1
- package/src/internal/schema/codeExpression.ts +179 -0
- package/src/internal/schema/codeImports.ts +142 -0
- package/src/internal/schema/codeTokens.ts +39 -0
- package/src/internal/schema/fromJsonSchemaDocument.ts +154 -34
- package/src/internal/schema/passthrough.ts +8 -0
- package/src/internal/schema/schemaCodegen.ts +543 -0
- package/src/internal/schema/toJsonSchemaDocument.ts +13 -4
- package/src/internal/trie.ts +46 -60
- package/src/internal/utf8.ts +106 -0
- package/src/internal/version.ts +1 -1
- package/src/jose/Jwks.ts +23 -4
- package/src/observability/OtlpExporter.ts +12 -10
- package/src/observability/OtlpLogger.ts +5 -3
- package/src/observability/internal/otlpProtobuf.ts +386 -457
- package/src/persistence/PersistedQueue.ts +21 -4
- package/src/protobuf/ProtobufDescriptor.ts +503 -0
- package/src/protobuf/ProtobufDescriptorProto.ts +3611 -0
- package/src/protobuf/ProtobufMessage.ts +277 -0
- package/src/protobuf/ProtobufReader.ts +756 -0
- package/src/protobuf/ProtobufWriter.ts +530 -0
- package/src/protobuf/index.ts +36 -0
- package/src/protobuf/internal/binary.ts +1215 -0
- package/src/protobuf/internal/resolve.ts +533 -0
- package/src/protobuf/internal/wireType.ts +9 -0
- package/src/reactivity/AsyncResult.ts +6 -1
- package/src/reactivity/Atom.ts +55 -16
- package/src/reactivity/AtomHttpApi.ts +10 -1
- package/src/reactivity/AtomRegistry.ts +16 -0
- package/src/reactivity/AtomRpc.ts +11 -1
- package/src/rpc/Rpc.ts +31 -0
- package/src/rpc/RpcClient.ts +30 -21
- package/src/rpc/RpcGroup.ts +5 -0
- package/src/rpc/RpcMiddleware.ts +9 -0
- package/src/rpc/RpcSerialization.ts +26 -6
- package/src/rpc/RpcServer.ts +33 -20
- package/src/schema/SchemaCompiler/runtime.ts +2 -3
- package/src/schema/VariantSchema.ts +12 -4
- package/src/socket/Socket.ts +67 -20
- package/src/sql/Migrator.ts +8 -1
- package/src/sql/SqlModel.ts +4 -0
- package/src/testing/TestClock.ts +1 -1
- package/src/testing/TestConsole.ts +119 -9
- package/src/testing/TestSchema.ts +8 -3
- package/src/workers/SharedMemory.ts +227 -0
- package/src/workers/Transferable.ts +1 -5
- package/src/workers/index.ts +6 -0
- package/src/workflow/WorkflowEngine.ts +3 -1
- package/dist/http-api/internal/mediaType.d.ts.map +0 -1
- package/dist/internal/schema/toCodeDocument.d.ts +0 -2
- package/dist/internal/schema/toCodeDocument.d.ts.map +0 -1
- package/dist/internal/schema/toCodeDocument.js +0 -444
- package/dist/internal/schema/toCodeDocument.js.map +0 -1
- package/dist/observability/internal/protobuf.d.ts +0 -2
- package/dist/observability/internal/protobuf.d.ts.map +0 -1
- package/dist/observability/internal/protobuf.js +0 -169
- package/dist/observability/internal/protobuf.js.map +0 -1
- package/src/internal/schema/toCodeDocument.ts +0 -570
- package/src/observability/internal/protobuf.ts +0 -225
- /package/dist/{http-api → http}/internal/mediaType.d.ts +0 -0
package/src/reactivity/Atom.ts
CHANGED
|
@@ -282,6 +282,9 @@ const RuntimeProto = {
|
|
|
282
282
|
return readable((get) => {
|
|
283
283
|
const previous = get.self<AsyncResult.AsyncResult<any, any>>()
|
|
284
284
|
const runtimeResult = get(this)
|
|
285
|
+
if (runtimeResult._tag === "Initial" && runtimeResult.waiting) {
|
|
286
|
+
return AsyncResult.waitingFrom(previous)
|
|
287
|
+
}
|
|
285
288
|
if (runtimeResult._tag !== "Success") {
|
|
286
289
|
return AsyncResult.replacePrevious(runtimeResult, previous)
|
|
287
290
|
}
|
|
@@ -1990,7 +1993,7 @@ function makeLabel(name: string, error: Error | undefined): readonly [name: stri
|
|
|
1990
1993
|
* refreshed or one of its dependencies changes. The factory and any wrappers
|
|
1991
1994
|
* still build, so `get(...)` calls in the factory and `withReactivity` keys are
|
|
1992
1995
|
* tracked; only the first effect or stream run is skipped. Dependencies read
|
|
1993
|
-
* inside the effect are tracked from its first real run. An `Initial` seed
|
|
1996
|
+
* inside the effect are tracked from its first real run. An `Initial` or waiting seed
|
|
1994
1997
|
* never skips the effect.
|
|
1995
1998
|
*
|
|
1996
1999
|
* @stability unstable
|
|
@@ -2150,6 +2153,8 @@ export const transform: {
|
|
|
2150
2153
|
readonly initialValueTarget?: Atom<B> | undefined
|
|
2151
2154
|
}
|
|
2152
2155
|
): Atom<B> => {
|
|
2156
|
+
// Forward through the registry so a serializable source resolves to its shared node.
|
|
2157
|
+
const refresh = (refresh: (atom: Atom<any>) => void) => refresh(self)
|
|
2153
2158
|
const atom = removeTtl(
|
|
2154
2159
|
isWritable(self)
|
|
2155
2160
|
? writable(
|
|
@@ -2157,15 +2162,11 @@ export const transform: {
|
|
|
2157
2162
|
function(ctx, value) {
|
|
2158
2163
|
ctx.set(self, value)
|
|
2159
2164
|
},
|
|
2160
|
-
|
|
2161
|
-
refresh(self)
|
|
2162
|
-
}
|
|
2165
|
+
refresh
|
|
2163
2166
|
)
|
|
2164
2167
|
: readable(
|
|
2165
2168
|
(get) => f(get, self),
|
|
2166
|
-
|
|
2167
|
-
refresh(self)
|
|
2168
|
-
}
|
|
2169
|
+
refresh
|
|
2169
2170
|
)
|
|
2170
2171
|
)
|
|
2171
2172
|
if (options?.initialValueTarget) {
|
|
@@ -2405,7 +2406,9 @@ export const withRefresh: {
|
|
|
2405
2406
|
* Skips revalidation if the source becomes fresh or the atom is disposed.
|
|
2406
2407
|
* Manual refreshes still forward to the source. `revalidateOnMount` controls
|
|
2407
2408
|
* initial stale refreshes; `revalidateOnFocus` controls focus refreshes
|
|
2408
|
-
* (`true` respects `staleTime`, `"always"` forces refresh).
|
|
2409
|
+
* (`true` respects `staleTime`, `"always"` forces refresh). Apply `swr` after
|
|
2410
|
+
* serialization and idle TTL so the source is retained and dehydrated, and
|
|
2411
|
+
* the wrapper checks freshness when mounted again.
|
|
2409
2412
|
*
|
|
2410
2413
|
* @stability unstable
|
|
2411
2414
|
* @category combinators
|
|
@@ -2421,7 +2424,9 @@ export const swr: {
|
|
|
2421
2424
|
* Skips revalidation if the source becomes fresh or the atom is disposed.
|
|
2422
2425
|
* Manual refreshes still forward to the source. `revalidateOnMount` controls
|
|
2423
2426
|
* initial stale refreshes; `revalidateOnFocus` controls focus refreshes
|
|
2424
|
-
* (`true` respects `staleTime`, `"always"` forces refresh).
|
|
2427
|
+
* (`true` respects `staleTime`, `"always"` forces refresh). Apply `swr` after
|
|
2428
|
+
* serialization and idle TTL so the source is retained and dehydrated, and
|
|
2429
|
+
* the wrapper checks freshness when mounted again.
|
|
2425
2430
|
*
|
|
2426
2431
|
* @stability unstable
|
|
2427
2432
|
* @category combinators
|
|
@@ -2444,7 +2449,9 @@ export const swr: {
|
|
|
2444
2449
|
* Skips revalidation if the source becomes fresh or the atom is disposed.
|
|
2445
2450
|
* Manual refreshes still forward to the source. `revalidateOnMount` controls
|
|
2446
2451
|
* initial stale refreshes; `revalidateOnFocus` controls focus refreshes
|
|
2447
|
-
* (`true` respects `staleTime`, `"always"` forces refresh).
|
|
2452
|
+
* (`true` respects `staleTime`, `"always"` forces refresh). Apply `swr` after
|
|
2453
|
+
* serialization and idle TTL so the source is retained and dehydrated, and
|
|
2454
|
+
* the wrapper checks freshness when mounted again.
|
|
2448
2455
|
*
|
|
2449
2456
|
* @stability unstable
|
|
2450
2457
|
* @category combinators
|
|
@@ -2842,18 +2849,26 @@ export const kvs = <S extends Schema.ConstraintCodec<any, any>, const Mode exten
|
|
|
2842
2849
|
readonly mode?: Mode | undefined
|
|
2843
2850
|
}): Writable<"async" extends Mode ? AsyncResult.AsyncResult<S["Type"]> : S["Type"], S["Type"]> => {
|
|
2844
2851
|
const setAtom = options.runtime.fn(
|
|
2845
|
-
(value: S["Type"]) =>
|
|
2852
|
+
(value: S["Type"], get) =>
|
|
2846
2853
|
KeyValueStore.KeyValueStore.use((store) =>
|
|
2847
|
-
|
|
2854
|
+
Effect.map(
|
|
2855
|
+
KeyValueStore.toSchemaStore(store, options.schema).set(options.key, value),
|
|
2856
|
+
() => get.set(persistedAtom, value)
|
|
2857
|
+
)
|
|
2848
2858
|
)
|
|
2849
2859
|
)
|
|
2850
2860
|
const resultAtom = options.runtime.atom(
|
|
2851
2861
|
KeyValueStore.KeyValueStore.use((store) => KeyValueStore.toSchemaStore(store, options.schema).get(options.key))
|
|
2852
2862
|
)
|
|
2863
|
+
const persistedAtom = writable(
|
|
2864
|
+
(get) => get(resultAtom),
|
|
2865
|
+
(ctx, value: S["Type"]) => ctx.setSelf(AsyncResult.success(Option.some(value)))
|
|
2866
|
+
)
|
|
2853
2867
|
return writable(
|
|
2854
2868
|
options.mode === "async" ?
|
|
2855
2869
|
(get) => {
|
|
2856
2870
|
get.mount(setAtom)
|
|
2871
|
+
get.mount(persistedAtom)
|
|
2857
2872
|
const mapper = AsyncResult.map<Option.Option<S["Type"]>, S["Type"]>(
|
|
2858
2873
|
Option.getOrElse(() => {
|
|
2859
2874
|
const value = options.defaultValue()
|
|
@@ -2862,11 +2877,12 @@ export const kvs = <S extends Schema.ConstraintCodec<any, any>, const Mode exten
|
|
|
2862
2877
|
})
|
|
2863
2878
|
)
|
|
2864
2879
|
get.subscribe(resultAtom, (result) => get.setSelf(mapper(result)))
|
|
2865
|
-
return mapper(get.once(
|
|
2880
|
+
return mapper(get.once(persistedAtom))
|
|
2866
2881
|
} :
|
|
2867
2882
|
(get) => {
|
|
2868
2883
|
get.mount(setAtom)
|
|
2869
|
-
get.
|
|
2884
|
+
get.mount(persistedAtom)
|
|
2885
|
+
const update = (result: AsyncResult.AsyncResult<Option.Option<S["Type"]>, unknown>) => {
|
|
2870
2886
|
if (!AsyncResult.isSuccess(result)) return
|
|
2871
2887
|
if (Option.isSome(result.value)) {
|
|
2872
2888
|
get.setSelf(result.value.value)
|
|
@@ -2875,7 +2891,9 @@ export const kvs = <S extends Schema.ConstraintCodec<any, any>, const Mode exten
|
|
|
2875
2891
|
get.setSelf(value)
|
|
2876
2892
|
get.set(setAtom, value)
|
|
2877
2893
|
}
|
|
2878
|
-
}
|
|
2894
|
+
}
|
|
2895
|
+
get.subscribe(resultAtom, update)
|
|
2896
|
+
update(get.once(persistedAtom))
|
|
2879
2897
|
return Option.getOrElse(get.self<S["Type"]>(), options.defaultValue)
|
|
2880
2898
|
},
|
|
2881
2899
|
(ctx, value: S["Type"]) => {
|
|
@@ -2923,11 +2941,16 @@ export const searchParam = <S extends Schema.ConstraintCodec<any, string> = neve
|
|
|
2923
2941
|
get.setSelf(newValue)
|
|
2924
2942
|
}
|
|
2925
2943
|
}
|
|
2944
|
+
searchParamState.readers++
|
|
2945
|
+
// Registered ahead of every reader, so stale writes are discarded before observers run.
|
|
2946
|
+
window.addEventListener("popstate", cancelSearchParamUpdates)
|
|
2926
2947
|
window.addEventListener("popstate", handleUpdate)
|
|
2927
2948
|
window.addEventListener("pushstate", handleUpdate)
|
|
2928
2949
|
get.addFinalizer(() => {
|
|
2929
2950
|
window.removeEventListener("popstate", handleUpdate)
|
|
2930
2951
|
window.removeEventListener("pushstate", handleUpdate)
|
|
2952
|
+
searchParamState.readers--
|
|
2953
|
+
releaseSearchParamCancel()
|
|
2931
2954
|
})
|
|
2932
2955
|
const value = new URLSearchParams(window.location.search).get(name) || ""
|
|
2933
2956
|
return decode ? Exit.getSuccess(decode(value)) : value as any
|
|
@@ -2945,11 +2968,12 @@ export const searchParam = <S extends Schema.ConstraintCodec<any, string> = neve
|
|
|
2945
2968
|
} else {
|
|
2946
2969
|
searchParamState.updates.set(name, value)
|
|
2947
2970
|
}
|
|
2948
|
-
|
|
2971
|
+
window.addEventListener("popstate", cancelSearchParamUpdates)
|
|
2949
2972
|
if (searchParamState.timeout) {
|
|
2950
2973
|
clearTimeout(searchParamState.timeout)
|
|
2951
2974
|
}
|
|
2952
2975
|
searchParamState.timeout = setTimeout(updateSearchParams, 500) as any
|
|
2976
|
+
ctx.setSelf(value)
|
|
2953
2977
|
}
|
|
2954
2978
|
)
|
|
2955
2979
|
}
|
|
@@ -2957,11 +2981,26 @@ export const searchParam = <S extends Schema.ConstraintCodec<any, string> = neve
|
|
|
2957
2981
|
const searchParamState = {
|
|
2958
2982
|
timeout: undefined as number | undefined,
|
|
2959
2983
|
updates: new Map<string, string>(),
|
|
2984
|
+
readers: 0,
|
|
2960
2985
|
updating: false
|
|
2961
2986
|
}
|
|
2962
2987
|
|
|
2988
|
+
function cancelSearchParamUpdates() {
|
|
2989
|
+
clearTimeout(searchParamState.timeout)
|
|
2990
|
+
searchParamState.timeout = undefined
|
|
2991
|
+
searchParamState.updates.clear()
|
|
2992
|
+
releaseSearchParamCancel()
|
|
2993
|
+
}
|
|
2994
|
+
|
|
2995
|
+
function releaseSearchParamCancel() {
|
|
2996
|
+
if (searchParamState.readers === 0 && searchParamState.timeout === undefined) {
|
|
2997
|
+
window.removeEventListener("popstate", cancelSearchParamUpdates)
|
|
2998
|
+
}
|
|
2999
|
+
}
|
|
3000
|
+
|
|
2963
3001
|
function updateSearchParams() {
|
|
2964
3002
|
searchParamState.timeout = undefined
|
|
3003
|
+
releaseSearchParamCancel()
|
|
2965
3004
|
searchParamState.updating = true
|
|
2966
3005
|
const searchParams = new URLSearchParams(window.location.search)
|
|
2967
3006
|
for (const [key, value] of searchParamState.updates.entries()) {
|
|
@@ -88,6 +88,10 @@ export interface AtomHttpApiClient<Self, Id extends string, Groups extends HttpA
|
|
|
88
88
|
>
|
|
89
89
|
: never
|
|
90
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Queries an HTTP endpoint. When set, `staleTime` reuses fresh results on mount
|
|
93
|
+
* and revalidates stale results in the background. Use `timeToLive` to retain results across mounts.
|
|
94
|
+
*/
|
|
91
95
|
readonly query: <
|
|
92
96
|
GroupIdentifier extends HttpApiGroup.Identifier<Groups>,
|
|
93
97
|
EndpointIdentifier extends HttpApiEndpoint.Identifier<HttpApiGroup.Endpoints<Group>>,
|
|
@@ -116,6 +120,7 @@ export interface AtomHttpApiClient<Self, Id extends string, Groups extends HttpA
|
|
|
116
120
|
>
|
|
117
121
|
] ? HttpApiEndpoint.ClientRequest<_Params, _Query, _Payload, _Headers, ResponseMode> & {
|
|
118
122
|
readonly reactivityKeys?: Reactivity.KeysInput | undefined
|
|
123
|
+
readonly staleTime?: Duration.Input | undefined
|
|
119
124
|
readonly timeToLive?: Duration.Input | undefined
|
|
120
125
|
readonly serializationKey?: string | undefined
|
|
121
126
|
}
|
|
@@ -272,6 +277,7 @@ export const Service =
|
|
|
272
277
|
if (opts.responseMode === "decoded-only" && opts.serializationKey) {
|
|
273
278
|
const endpoint = groups[opts.group].endpoints[opts.endpoint]
|
|
274
279
|
atom = Atom.serializable(atom, {
|
|
280
|
+
skipInitialRun: opts.staleTime !== undefined,
|
|
275
281
|
key: `AtomHttpApi:${opts.group}:${opts.endpoint}:${opts.serializationKey}`,
|
|
276
282
|
schema: AsyncResult.Schema({
|
|
277
283
|
success: Schema.Union(HttpApiEndpoint.getSuccessSchemas(endpoint)),
|
|
@@ -284,7 +290,7 @@ export const Service =
|
|
|
284
290
|
? Atom.setIdleTTL(atom, opts.timeToLive)
|
|
285
291
|
: Atom.keepAlive(atom)
|
|
286
292
|
}
|
|
287
|
-
return atom
|
|
293
|
+
return opts.staleTime !== undefined ? Atom.swr(atom, { staleTime: opts.staleTime }) : atom
|
|
288
294
|
})
|
|
289
295
|
|
|
290
296
|
self.query = ((
|
|
@@ -298,6 +304,7 @@ export const Service =
|
|
|
298
304
|
readonly responseMode?: HttpApiEndpoint.ClientResponseMode
|
|
299
305
|
readonly sseOptions?: Sse.DecodeOptions | undefined
|
|
300
306
|
readonly reactivityKeys?: Reactivity.KeysInput | undefined
|
|
307
|
+
readonly staleTime?: Duration.Input | undefined
|
|
301
308
|
readonly timeToLive?: Duration.Input | undefined
|
|
302
309
|
readonly serializationKey?: string | undefined
|
|
303
310
|
}
|
|
@@ -312,6 +319,7 @@ export const Service =
|
|
|
312
319
|
responseMode: request.responseMode ?? "decoded-only",
|
|
313
320
|
sseOptions: request.sseOptions,
|
|
314
321
|
reactivityKeys: request.reactivityKeys,
|
|
322
|
+
staleTime: request.staleTime !== undefined ? Duration.fromInputUnsafe(request.staleTime) : undefined,
|
|
315
323
|
timeToLive: request.timeToLive !== undefined
|
|
316
324
|
? Duration.fromInputUnsafe(request.timeToLive)
|
|
317
325
|
: undefined,
|
|
@@ -339,6 +347,7 @@ interface QueryKey {
|
|
|
339
347
|
responseMode: HttpApiEndpoint.ClientResponseMode
|
|
340
348
|
reactivityKeys: Reactivity.KeysInput | undefined
|
|
341
349
|
sseOptions: Sse.DecodeOptions | undefined
|
|
350
|
+
staleTime: Duration.Duration | undefined
|
|
342
351
|
timeToLive: Duration.Duration | undefined
|
|
343
352
|
serializationKey: string | undefined
|
|
344
353
|
}
|
|
@@ -542,6 +542,8 @@ class RegistryImpl implements AtomRegistry {
|
|
|
542
542
|
}
|
|
543
543
|
|
|
544
544
|
refresh = <A>(atom: Atom.Atom<A>): void => {
|
|
545
|
+
// Readers of a serialization key share the first node, including its refresh target.
|
|
546
|
+
if (SerializableTypeId in atom) atom = this.ensureNode(atom).atom
|
|
545
547
|
if (atom.refresh !== undefined) {
|
|
546
548
|
atom.refresh(this.refresh)
|
|
547
549
|
} else {
|
|
@@ -628,6 +630,7 @@ class RegistryImpl implements AtomRegistry {
|
|
|
628
630
|
|
|
629
631
|
invalidateAtom = <A>(atom: Atom.Atom<A>): void => {
|
|
630
632
|
const node = this.ensureNode(atom)
|
|
633
|
+
if (node.skipInitialRun) node.preserveInitialValueOnBuild = false
|
|
631
634
|
node.skipInitialRun = false
|
|
632
635
|
node.invalidate()
|
|
633
636
|
}
|
|
@@ -872,6 +875,14 @@ class NodeImpl<A> {
|
|
|
872
875
|
}
|
|
873
876
|
}
|
|
874
877
|
if (this.lifetime === lifetime && (this.state & NodeFlags.waitingForValue) !== 0) {
|
|
878
|
+
if (
|
|
879
|
+
this.skipInitialRun && Result.isAsyncResult(this._value) && this._value.waiting &&
|
|
880
|
+
Result.isAsyncResult(value) && Result.isFailure(value)
|
|
881
|
+
) {
|
|
882
|
+
// Runtime acquisition can fail before the effect consumes its seed.
|
|
883
|
+
this.preserveInitialValueOnBuild = false
|
|
884
|
+
this.skipInitialRun = false
|
|
885
|
+
}
|
|
875
886
|
if (this.preserveInitialValueOnBuild) {
|
|
876
887
|
this.preserveInitialValueOnBuild = false
|
|
877
888
|
if (this.skipInitialRun) {
|
|
@@ -1127,6 +1138,11 @@ export const consumeSkipInitialRun = (ctx: Atom.AtomContext): boolean => {
|
|
|
1127
1138
|
const keptParents = node.keptParents
|
|
1128
1139
|
node.skipInitialRun = false
|
|
1129
1140
|
node.keptParents = undefined
|
|
1141
|
+
if (node._value.waiting) {
|
|
1142
|
+
// No local request owns the seed; commit the replacement even if it completes synchronously.
|
|
1143
|
+
node.preserveInitialValueOnBuild = false
|
|
1144
|
+
return false
|
|
1145
|
+
}
|
|
1130
1146
|
return !lifetime.isFn && !Result.isInitial(node._value) &&
|
|
1131
1147
|
(keptParents === undefined || keptParents.every(([parent, lifetime]) => parent.lifetime === lifetime))
|
|
1132
1148
|
}
|
|
@@ -56,12 +56,17 @@ export interface AtomRpcClient<Self, Id extends string, Rpcs extends Rpc.Any> ex
|
|
|
56
56
|
|
|
57
57
|
readonly mutation: <Tag extends Rpc.Tag<Rpcs>>(arg: Tag) => Mutation<Rpc.ExtractTag<Rpcs, Tag>>
|
|
58
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Queries an RPC. For non-stream RPCs, `staleTime` reuses fresh results on mount
|
|
61
|
+
* and revalidates stale results in the background. Use `timeToLive` to retain results across mounts.
|
|
62
|
+
*/
|
|
59
63
|
readonly query: <Tag extends Rpc.Tag<Rpcs>>(
|
|
60
64
|
tag: Tag,
|
|
61
65
|
payload: Rpc.PayloadConstructor<Rpc.ExtractTag<Rpcs, Tag>>,
|
|
62
66
|
options?: {
|
|
63
67
|
readonly headers?: Headers.Input | undefined
|
|
64
68
|
readonly reactivityKeys?: Reactivity.KeysInput | undefined
|
|
69
|
+
readonly staleTime?: Duration.Input | undefined
|
|
65
70
|
readonly timeToLive?: Duration.Input | undefined
|
|
66
71
|
readonly serializationKey?: string | undefined
|
|
67
72
|
}
|
|
@@ -244,11 +249,13 @@ export const Service = <Self>() =>
|
|
|
244
249
|
: self.runtime.atom(
|
|
245
250
|
self.use((client) => client(tag, payload, { headers } as any)) as any
|
|
246
251
|
)
|
|
252
|
+
const staleTime = isStream ? undefined : key.staleTime
|
|
247
253
|
if (reactivityKeys) {
|
|
248
254
|
atom = self.runtime.factory.withReactivity(reactivityKeys)(atom)
|
|
249
255
|
}
|
|
250
256
|
if (!isStream && key.serializationKey) {
|
|
251
257
|
atom = Atom.serializable(atom, {
|
|
258
|
+
skipInitialRun: staleTime !== undefined,
|
|
252
259
|
key: `AtomRpc:${key.tag}:${key.serializationKey}`,
|
|
253
260
|
schema: AsyncResult.Schema({
|
|
254
261
|
success: rpc.successSchema,
|
|
@@ -261,7 +268,7 @@ export const Service = <Self>() =>
|
|
|
261
268
|
? Atom.setIdleTTL(atom, timeToLive)
|
|
262
269
|
: Atom.keepAlive(atom)
|
|
263
270
|
}
|
|
264
|
-
return atom
|
|
271
|
+
return staleTime !== undefined ? Atom.swr(atom, { staleTime }) : atom
|
|
265
272
|
}
|
|
266
273
|
)
|
|
267
274
|
|
|
@@ -271,6 +278,7 @@ export const Service = <Self>() =>
|
|
|
271
278
|
options?: {
|
|
272
279
|
readonly headers?: Headers.Input | undefined
|
|
273
280
|
readonly reactivityKeys?: Reactivity.KeysInput | undefined
|
|
281
|
+
readonly staleTime?: Duration.Input | undefined
|
|
274
282
|
readonly timeToLive?: Duration.Input | undefined
|
|
275
283
|
readonly serializationKey?: string | undefined
|
|
276
284
|
}
|
|
@@ -282,6 +290,7 @@ export const Service = <Self>() =>
|
|
|
282
290
|
? Headers.fromInput(options.headers)
|
|
283
291
|
: undefined,
|
|
284
292
|
reactivityKeys: options?.reactivityKeys,
|
|
293
|
+
staleTime: options?.staleTime !== undefined ? Duration.fromInputUnsafe(options.staleTime) : undefined,
|
|
285
294
|
timeToLive: options?.timeToLive !== undefined
|
|
286
295
|
? Duration.fromInputUnsafe(options.timeToLive)
|
|
287
296
|
: undefined,
|
|
@@ -298,6 +307,7 @@ interface QueryKey {
|
|
|
298
307
|
payload: any
|
|
299
308
|
headers: Headers.Headers | undefined
|
|
300
309
|
reactivityKeys: Reactivity.KeysInput | undefined
|
|
310
|
+
staleTime: Duration.Duration | undefined
|
|
301
311
|
timeToLive: Duration.Duration | undefined
|
|
302
312
|
serializationKey: string | undefined
|
|
303
313
|
}
|
package/src/rpc/Rpc.ts
CHANGED
|
@@ -26,6 +26,7 @@ import * as Schema from "../Schema.ts"
|
|
|
26
26
|
import * as SchemaAST from "../SchemaAST.ts"
|
|
27
27
|
import type { Stream } from "../Stream.ts"
|
|
28
28
|
import type * as Struct from "../Struct.ts"
|
|
29
|
+
import type * as Tracer from "../Tracer.ts"
|
|
29
30
|
import type { NoInfer } from "../Types.ts"
|
|
30
31
|
import type { RequestId } from "./RpcMessage.ts"
|
|
31
32
|
import type * as RpcMiddleware from "./RpcMiddleware.ts"
|
|
@@ -224,6 +225,10 @@ export interface Handler<Tag extends string> {
|
|
|
224
225
|
readonly handler: (request: any, options: {
|
|
225
226
|
readonly client: ServerClient
|
|
226
227
|
readonly requestId: RequestId
|
|
228
|
+
/**
|
|
229
|
+
* The span sent by the client, or `undefined` when no span was propagated.
|
|
230
|
+
*/
|
|
231
|
+
readonly remoteParentSpan: Tracer.ExternalSpan | undefined
|
|
227
232
|
readonly headers: Headers
|
|
228
233
|
readonly rpc: Any
|
|
229
234
|
}) => Effect<{} | Deferred<any, any>, any> | Stream<any, any>
|
|
@@ -666,6 +671,10 @@ export type ToHandlerFn<Current extends Any, R = any> = (
|
|
|
666
671
|
options: {
|
|
667
672
|
readonly client: ServerClient
|
|
668
673
|
readonly requestId: RequestId
|
|
674
|
+
/**
|
|
675
|
+
* The span sent by the client, or `undefined` when no span was propagated.
|
|
676
|
+
*/
|
|
677
|
+
readonly remoteParentSpan: Tracer.ExternalSpan | undefined
|
|
669
678
|
readonly headers: Headers
|
|
670
679
|
readonly rpc: Current
|
|
671
680
|
}
|
|
@@ -1249,6 +1258,28 @@ export const ParseOptions = Context.Reference<SchemaAST.ParseOptions>("effect/rp
|
|
|
1249
1258
|
defaultValue: () => SchemaAST.defaultParseOptions
|
|
1250
1259
|
})
|
|
1251
1260
|
|
|
1261
|
+
/**
|
|
1262
|
+
* Annotation that selects which sides create automatic spans for an RPC:
|
|
1263
|
+
* `"client"`, `"server"`, `"both"` (the default), or `"none"`.
|
|
1264
|
+
*
|
|
1265
|
+
* **Details**
|
|
1266
|
+
*
|
|
1267
|
+
* When the annotation disables the client span, the client can still propagate
|
|
1268
|
+
* its caller's span. A client's or server's `disableTracing: true` option
|
|
1269
|
+
* overrides this annotation on that side; a globally disabled client does not
|
|
1270
|
+
* propagate a span.
|
|
1271
|
+
*
|
|
1272
|
+
* @stability unstable
|
|
1273
|
+
* @category annotations
|
|
1274
|
+
* @since 4.1.5
|
|
1275
|
+
*/
|
|
1276
|
+
export const TracingEnabled = Context.Reference<"client" | "server" | "both" | "none">(
|
|
1277
|
+
"effect/rpc/Rpc/TracingEnabled",
|
|
1278
|
+
{
|
|
1279
|
+
defaultValue: () => "both"
|
|
1280
|
+
}
|
|
1281
|
+
)
|
|
1282
|
+
|
|
1252
1283
|
const WrapperTypeId = "~effect/rpc/Rpc/Wrapper"
|
|
1253
1284
|
|
|
1254
1285
|
/**
|
package/src/rpc/RpcClient.ts
CHANGED
|
@@ -40,7 +40,7 @@ import * as Scope from "../Scope.ts"
|
|
|
40
40
|
import * as Socket from "../socket/Socket.ts"
|
|
41
41
|
import * as Stream from "../Stream.ts"
|
|
42
42
|
import type * as Struct from "../Struct.ts"
|
|
43
|
-
import
|
|
43
|
+
import * as Tracer from "../Tracer.ts"
|
|
44
44
|
import * as Transferable from "../workers/Transferable.ts"
|
|
45
45
|
import * as Worker from "../workers/Worker.ts"
|
|
46
46
|
import type { WorkerError } from "../workers/WorkerError.ts"
|
|
@@ -303,9 +303,18 @@ export const makeNoSerialization: <Rpcs extends Rpc.Any, E, const Flatten extend
|
|
|
303
303
|
}
|
|
304
304
|
}, Effect.uninterruptible)
|
|
305
305
|
|
|
306
|
+
const traceFields = (fiber: Fiber.Fiber<unknown, unknown>, clientSpan: Tracer.Span | undefined) => {
|
|
307
|
+
if (disableTracing || !fiber.cache.tracerEnabled || fiber.getRef(Tracer.DisablePropagation)) return undefined
|
|
308
|
+
const span = clientSpan ?? fiber.cache.span
|
|
309
|
+
if (!span || Context.get(span.annotations, Tracer.DisablePropagation)) return undefined
|
|
310
|
+
return { traceId: span.traceId, spanId: span.spanId, sampled: span.sampled }
|
|
311
|
+
}
|
|
312
|
+
|
|
306
313
|
const onRequest = (rpc: Rpc.AnyWithProps) => {
|
|
307
314
|
const isStream = RpcSchema.isStreamSchema(rpc.successSchema)
|
|
308
315
|
const middleware = getRpcClientMiddleware(rpc)
|
|
316
|
+
const tracing = Context.get(rpc.annotations, Rpc.TracingEnabled)
|
|
317
|
+
const createSpan = !disableTracing && (tracing === "both" || tracing === "client")
|
|
309
318
|
return (payload: any, opts?: {
|
|
310
319
|
readonly asQueue?: boolean | undefined
|
|
311
320
|
readonly streamBufferSize?: number | undefined
|
|
@@ -316,7 +325,7 @@ export const makeNoSerialization: <Rpcs extends Rpc.Any, E, const Flatten extend
|
|
|
316
325
|
const headers = opts?.headers ? Headers.fromInput(opts.headers) : Headers.empty
|
|
317
326
|
const context = opts?.context ?? Context.empty()
|
|
318
327
|
if (!isStream) {
|
|
319
|
-
const onRequest = (span: Span | undefined) =>
|
|
328
|
+
const onRequest = (span: Tracer.Span | undefined) =>
|
|
320
329
|
onEffectRequest(
|
|
321
330
|
rpc,
|
|
322
331
|
middleware,
|
|
@@ -326,7 +335,8 @@ export const makeNoSerialization: <Rpcs extends Rpc.Any, E, const Flatten extend
|
|
|
326
335
|
context,
|
|
327
336
|
opts?.discard ?? false
|
|
328
337
|
)
|
|
329
|
-
|
|
338
|
+
if (!createSpan) return onRequest(undefined)
|
|
339
|
+
return Effect.useSpan(
|
|
330
340
|
RpcTracing.spanName(spanPrefix, rpc._tag),
|
|
331
341
|
{ kind: "client", attributes: RpcTracing.spanAttributes(rpc._tag, options.spanAttributes) },
|
|
332
342
|
onRequest
|
|
@@ -334,6 +344,7 @@ export const makeNoSerialization: <Rpcs extends Rpc.Any, E, const Flatten extend
|
|
|
334
344
|
}
|
|
335
345
|
const queue = onStreamRequest(
|
|
336
346
|
rpc,
|
|
347
|
+
createSpan,
|
|
337
348
|
middleware,
|
|
338
349
|
rpc.payloadSchema.make(payload),
|
|
339
350
|
headers,
|
|
@@ -351,7 +362,7 @@ export const makeNoSerialization: <Rpcs extends Rpc.Any, E, const Flatten extend
|
|
|
351
362
|
send: (request: Request<Rpcs>) => Effect.Effect<any, E>,
|
|
352
363
|
request: Request<Rpcs>
|
|
353
364
|
) => Effect.Effect<any, E>,
|
|
354
|
-
span: Span | undefined,
|
|
365
|
+
span: Tracer.Span | undefined,
|
|
355
366
|
payload: any,
|
|
356
367
|
headers: Headers.Headers,
|
|
357
368
|
context: Context.Context<never>,
|
|
@@ -369,13 +380,7 @@ export const makeNoSerialization: <Rpcs extends Rpc.Any, E, const Flatten extend
|
|
|
369
380
|
id,
|
|
370
381
|
tag: rpc._tag as Rpc.Tag<Rpcs>,
|
|
371
382
|
payload,
|
|
372
|
-
...(span
|
|
373
|
-
{
|
|
374
|
-
traceId: span.traceId,
|
|
375
|
-
spanId: span.spanId,
|
|
376
|
-
sampled: span.sampled
|
|
377
|
-
} :
|
|
378
|
-
{}),
|
|
383
|
+
...traceFields(parentFiber, span),
|
|
379
384
|
headers: Headers.merge(parentFiber.getRef(CurrentHeaders), headers),
|
|
380
385
|
...(discard ? { discard: true as const } : {})
|
|
381
386
|
}
|
|
@@ -431,6 +436,7 @@ export const makeNoSerialization: <Rpcs extends Rpc.Any, E, const Flatten extend
|
|
|
431
436
|
|
|
432
437
|
const onStreamRequest = Effect.fnUntraced(function*(
|
|
433
438
|
rpc: Rpc.AnyWithProps,
|
|
439
|
+
createSpan: boolean,
|
|
434
440
|
middleware: (
|
|
435
441
|
send: (request: Request<Rpcs>) => Effect.Effect<any, E>,
|
|
436
442
|
request: Request<Rpcs>
|
|
@@ -444,7 +450,7 @@ export const makeNoSerialization: <Rpcs extends Rpc.Any, E, const Flatten extend
|
|
|
444
450
|
return yield* Effect.interrupt
|
|
445
451
|
}
|
|
446
452
|
|
|
447
|
-
const span =
|
|
453
|
+
const span = !createSpan ? undefined : yield* Effect.makeSpanScoped(
|
|
448
454
|
RpcTracing.spanName(spanPrefix, rpc._tag),
|
|
449
455
|
{ kind: "client", attributes: RpcTracing.spanAttributes(rpc._tag, options.spanAttributes) }
|
|
450
456
|
)
|
|
@@ -484,13 +490,7 @@ export const makeNoSerialization: <Rpcs extends Rpc.Any, E, const Flatten extend
|
|
|
484
490
|
id,
|
|
485
491
|
tag: rpc._tag as Rpc.Tag<Rpcs>,
|
|
486
492
|
payload,
|
|
487
|
-
...(span
|
|
488
|
-
{
|
|
489
|
-
traceId: span.traceId,
|
|
490
|
-
spanId: span.spanId,
|
|
491
|
-
sampled: span.sampled
|
|
492
|
-
} :
|
|
493
|
-
{}),
|
|
493
|
+
...traceFields(fiber, span),
|
|
494
494
|
headers: Headers.merge(fiber.getRef(CurrentHeaders), headers)
|
|
495
495
|
}
|
|
496
496
|
).pipe(
|
|
@@ -656,6 +656,7 @@ export const make: <Rpcs extends Rpc.Any, const Flatten extends boolean = false>
|
|
|
656
656
|
readonly flatten?: Flatten | undefined
|
|
657
657
|
} | undefined
|
|
658
658
|
) {
|
|
659
|
+
const scope = yield* Effect.scope
|
|
659
660
|
const clientId = clientIdCounter++
|
|
660
661
|
const { codecFor, run, send, supportsAck, supportsTransferables } = yield* Protocol
|
|
661
662
|
const rpcSchemas = makeRpcSchemas(codecFor)
|
|
@@ -750,7 +751,13 @@ export const make: <Rpcs extends Rpc.Any, const Flatten extends boolean = false>
|
|
|
750
751
|
decodeChunk(message.values).pipe(
|
|
751
752
|
Effect.provideContext(entry.context),
|
|
752
753
|
Effect.orDie,
|
|
753
|
-
Effect.flatMap((chunk) =>
|
|
754
|
+
Effect.flatMap((chunk) => {
|
|
755
|
+
const deliver = write({ _tag: "Chunk", clientId: 0, requestId, values: chunk })
|
|
756
|
+
// The server waits for each chunk's Ack, so a chunk waiting for
|
|
757
|
+
// buffer space must not block other responses on this
|
|
758
|
+
// connection. Starting immediately keeps it ahead of the Exit.
|
|
759
|
+
return supportsAck ? Effect.forkIn(deliver, scope, { startImmediately: true }) : deliver
|
|
760
|
+
})
|
|
754
761
|
)
|
|
755
762
|
).pipe(
|
|
756
763
|
Effect.onError((cause) =>
|
|
@@ -1403,7 +1410,9 @@ export const makeProtocolSocket = (options?: {
|
|
|
1403
1410
|
const write = (request: FromClientEncoded) =>
|
|
1404
1411
|
Effect.suspend(() => {
|
|
1405
1412
|
const encoded = parser.encode(request)
|
|
1406
|
-
return encoded === undefined
|
|
1413
|
+
return encoded === undefined
|
|
1414
|
+
? Effect.void
|
|
1415
|
+
: Effect.mapError(writer.write(encoded), (error) => new RpcClientError({ reason: error.reason }))
|
|
1407
1416
|
})
|
|
1408
1417
|
|
|
1409
1418
|
return {
|
package/src/rpc/RpcGroup.ts
CHANGED
|
@@ -20,6 +20,7 @@ import type * as Queue from "../Queue.ts"
|
|
|
20
20
|
import type * as Record from "../Record.ts"
|
|
21
21
|
import type { Scope } from "../Scope.ts"
|
|
22
22
|
import * as Stream from "../Stream.ts"
|
|
23
|
+
import type * as Tracer from "../Tracer.ts"
|
|
23
24
|
import * as Rpc from "./Rpc.ts"
|
|
24
25
|
import type { RequestId } from "./RpcMessage.ts"
|
|
25
26
|
import type * as RpcMiddleware from "./RpcMiddleware.ts"
|
|
@@ -140,6 +141,10 @@ export interface RpcGroup<in out R extends Rpc.Any> extends Pipeable {
|
|
|
140
141
|
options: {
|
|
141
142
|
readonly client: Rpc.ServerClient
|
|
142
143
|
readonly requestId: RequestId
|
|
144
|
+
/**
|
|
145
|
+
* The span sent by the client, or `undefined` when no span was propagated.
|
|
146
|
+
*/
|
|
147
|
+
readonly remoteParentSpan: Tracer.ExternalSpan | undefined
|
|
143
148
|
readonly headers: Headers
|
|
144
149
|
}
|
|
145
150
|
) => Rpc.ResultFrom<Extract<R, { readonly _tag: Tag }>, never>,
|
package/src/rpc/RpcMiddleware.ts
CHANGED
|
@@ -17,6 +17,7 @@ import { getStackTraceLimit, setStackTraceLimit } from "../internal/stackTraceLi
|
|
|
17
17
|
import * as Layer from "../Layer.ts"
|
|
18
18
|
import * as Schema from "../Schema.ts"
|
|
19
19
|
import { Scope } from "../Scope.ts"
|
|
20
|
+
import type * as Tracer from "../Tracer.ts"
|
|
20
21
|
import type { Mutable, unhandled } from "../Types.ts"
|
|
21
22
|
import type * as Rpc from "./Rpc.ts"
|
|
22
23
|
import type { Request, RequestId } from "./RpcMessage.ts"
|
|
@@ -54,6 +55,10 @@ export interface RpcMiddleware<Provides, E, Requires> {
|
|
|
54
55
|
options: {
|
|
55
56
|
readonly client: Rpc.ServerClient
|
|
56
57
|
readonly requestId: RequestId
|
|
58
|
+
/**
|
|
59
|
+
* The span sent by the client, or `undefined` when no span was propagated.
|
|
60
|
+
*/
|
|
61
|
+
readonly remoteParentSpan: Tracer.ExternalSpan | undefined
|
|
57
62
|
readonly rpc: Rpc.AnyWithProps
|
|
58
63
|
readonly payload: unknown
|
|
59
64
|
readonly headers: Headers
|
|
@@ -116,6 +121,10 @@ export interface Any {
|
|
|
116
121
|
options: {
|
|
117
122
|
readonly client: Rpc.ServerClient
|
|
118
123
|
readonly requestId: RequestId
|
|
124
|
+
/**
|
|
125
|
+
* The span sent by the client, or `undefined` when no span was propagated.
|
|
126
|
+
*/
|
|
127
|
+
readonly remoteParentSpan: Tracer.ExternalSpan | undefined
|
|
119
128
|
readonly rpc: Rpc.AnyWithProps
|
|
120
129
|
readonly payload: unknown
|
|
121
130
|
readonly headers: Headers
|
|
@@ -60,7 +60,13 @@ const decodeText = (bytes: Uint8Array): string => (sharedTextDecoder ??= new Tex
|
|
|
60
60
|
* @since 4.0.0
|
|
61
61
|
*/
|
|
62
62
|
export class RpcSerialization extends Context.Service<RpcSerialization, {
|
|
63
|
-
makeUnsafe(
|
|
63
|
+
makeUnsafe(options?: {
|
|
64
|
+
/**
|
|
65
|
+
* Receives each malformed NDJSON frame instead of `decode` throwing, so the
|
|
66
|
+
* frames around it still decode. Other decoding failures still throw.
|
|
67
|
+
*/
|
|
68
|
+
readonly onDecodeError?: ((error: unknown) => void) | undefined
|
|
69
|
+
}): Parser
|
|
64
70
|
readonly contentType: string
|
|
65
71
|
readonly includesFraming: boolean
|
|
66
72
|
readonly codecFor: CodecFor
|
|
@@ -165,12 +171,14 @@ export const makeNdjson = (options?: StreamOptions): RpcSerialization["Service"]
|
|
|
165
171
|
contentType: "application/x-ndjson",
|
|
166
172
|
includesFraming: true,
|
|
167
173
|
codecFor: codecForJson,
|
|
168
|
-
makeUnsafe: () => {
|
|
174
|
+
makeUnsafe: (options) => {
|
|
175
|
+
const onDecodeError = options?.onDecodeError
|
|
169
176
|
// lazily created: string transports never need byte decoding
|
|
170
177
|
let decoder: TextDecoder | undefined
|
|
171
178
|
let buffer = ""
|
|
172
179
|
const failMaxBufferSize = (maxBufferSize: number): never => {
|
|
173
180
|
buffer = ""
|
|
181
|
+
decoder = undefined
|
|
174
182
|
throw new MaxBufferSizeExceeded({ maxBufferSize })
|
|
175
183
|
}
|
|
176
184
|
return ({
|
|
@@ -189,8 +197,13 @@ export const makeNdjson = (options?: StreamOptions): RpcSerialization["Service"]
|
|
|
189
197
|
try {
|
|
190
198
|
items.push(JSON.parse(line))
|
|
191
199
|
} catch (cause) {
|
|
192
|
-
|
|
193
|
-
|
|
200
|
+
const error = new NdjsonDecodeError({ cause })
|
|
201
|
+
if (onDecodeError === undefined) {
|
|
202
|
+
buffer = ""
|
|
203
|
+
decoder = undefined
|
|
204
|
+
throw error
|
|
205
|
+
}
|
|
206
|
+
onDecodeError(error)
|
|
194
207
|
}
|
|
195
208
|
}
|
|
196
209
|
nlIndex = buffer.indexOf("\n", position)
|
|
@@ -290,8 +303,8 @@ export const ndJsonRpc = (options?: {
|
|
|
290
303
|
contentType: options?.contentType ?? "application/json-rpc",
|
|
291
304
|
includesFraming: true,
|
|
292
305
|
codecFor: codecForJson,
|
|
293
|
-
makeUnsafe: () => {
|
|
294
|
-
const parser = makeNdjson({ maxBufferSize: options?.maxBufferSize }).makeUnsafe()
|
|
306
|
+
makeUnsafe: (parserOptions) => {
|
|
307
|
+
const parser = makeNdjson({ maxBufferSize: options?.maxBufferSize }).makeUnsafe(parserOptions)
|
|
295
308
|
const controlMessages = options?.controlMessages ?? true
|
|
296
309
|
const batches = new Map<string, {
|
|
297
310
|
readonly size: number
|
|
@@ -539,6 +552,13 @@ function encodeJsonRpcMessage(response: RpcMessage.FromServerEncoded | RpcMessag
|
|
|
539
552
|
} as any
|
|
540
553
|
}
|
|
541
554
|
case "Defect":
|
|
555
|
+
if (hasProperty(response.defect, "name") && response.defect.name === "NdjsonDecodeError") {
|
|
556
|
+
return {
|
|
557
|
+
jsonrpc: "2.0",
|
|
558
|
+
id: null,
|
|
559
|
+
error: { code: -32700, message: "Parse error" }
|
|
560
|
+
}
|
|
561
|
+
}
|
|
542
562
|
return {
|
|
543
563
|
jsonrpc: "2.0",
|
|
544
564
|
id: jsonRpcInternalError,
|