effect 4.0.3 → 4.0.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/AGENTS.md +24 -0
- package/CLAUDE.md +24 -0
- package/ai-docs/package.json +2 -2
- package/ai-docs/src/52_graphql/10_basics.ts +117 -0
- package/ai-docs/src/52_graphql/20_testing.ts +45 -0
- package/ai-docs/src/52_graphql/30_batching.ts +118 -0
- package/ai-docs/src/52_graphql/40_aliased-batching.ts +124 -0
- package/ai-docs/src/52_graphql/50_errors-and-retries.ts +74 -0
- package/ai-docs/src/52_graphql/index.md +6 -0
- package/dist/Array.d.ts +90 -6
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +4 -2
- package/dist/Array.js.map +1 -1
- package/dist/Channel.d.ts +6 -1
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +17 -3
- package/dist/Channel.js.map +1 -1
- package/dist/ConfigProvider.d.ts.map +1 -1
- package/dist/ConfigProvider.js +33 -32
- package/dist/ConfigProvider.js.map +1 -1
- package/dist/Context.d.ts.map +1 -1
- package/dist/Context.js +9 -0
- package/dist/Context.js.map +1 -1
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +2 -5
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts +61 -19
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +58 -39
- package/dist/Effect.js.map +1 -1
- package/dist/FileSystem.d.ts +23 -9
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js.map +1 -1
- package/dist/Match.d.ts +20 -6
- package/dist/Match.d.ts.map +1 -1
- package/dist/Match.js +2 -2
- package/dist/Match.js.map +1 -1
- package/dist/Path.d.ts +37 -5
- package/dist/Path.d.ts.map +1 -1
- package/dist/Path.js +36 -5
- package/dist/Path.js.map +1 -1
- package/dist/RequestResolver.d.ts.map +1 -1
- package/dist/RequestResolver.js +4 -10
- package/dist/RequestResolver.js.map +1 -1
- package/dist/Scheduler.d.ts +9 -0
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/Scheduler.js +9 -0
- package/dist/Scheduler.js.map +1 -1
- package/dist/Schema.d.ts +15 -2
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +16 -2
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaGetter.d.ts +4 -0
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +52 -33
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/Sink.d.ts.map +1 -1
- package/dist/Sink.js +38 -17
- package/dist/Sink.js.map +1 -1
- package/dist/Stream.d.ts +11 -0
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +16 -1
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +12 -0
- package/dist/String.d.ts.map +1 -1
- package/dist/String.js +17 -4
- package/dist/String.js.map +1 -1
- package/dist/TxRef.d.ts.map +1 -1
- package/dist/TxRef.js +3 -2
- package/dist/TxRef.js.map +1 -1
- package/dist/Utils.js +8 -3
- package/dist/Utils.js.map +1 -1
- package/dist/ai/AiError.d.ts +10 -10
- package/dist/ai/AiError.d.ts.map +1 -1
- package/dist/ai/AiError.js +1 -1
- package/dist/ai/AiError.js.map +1 -1
- package/dist/ai/AnthropicStructuredOutput.js +0 -2
- package/dist/ai/AnthropicStructuredOutput.js.map +1 -1
- package/dist/ai/Chat.d.ts +2 -2
- package/dist/ai/Chat.d.ts.map +1 -1
- package/dist/ai/Decision.d.ts +70 -19
- package/dist/ai/Decision.d.ts.map +1 -1
- package/dist/ai/Decision.js +37 -3
- package/dist/ai/Decision.js.map +1 -1
- package/dist/ai/DecisionModel.js +1 -1
- package/dist/ai/DecisionModel.js.map +1 -1
- package/dist/ai/LanguageModel.d.ts +38 -7
- package/dist/ai/LanguageModel.d.ts.map +1 -1
- package/dist/ai/LanguageModel.js +70 -40
- package/dist/ai/LanguageModel.js.map +1 -1
- package/dist/ai/McpServer.d.ts +61 -52
- package/dist/ai/McpServer.d.ts.map +1 -1
- package/dist/ai/McpServer.js +134 -50
- package/dist/ai/McpServer.js.map +1 -1
- package/dist/ai/Prompt.d.ts.map +1 -1
- package/dist/ai/Prompt.js +28 -5
- package/dist/ai/Prompt.js.map +1 -1
- package/dist/ai/Response.d.ts +5 -4
- package/dist/ai/Response.d.ts.map +1 -1
- package/dist/ai/Response.js.map +1 -1
- package/dist/cli/Completions.d.ts +5 -0
- package/dist/cli/Completions.d.ts.map +1 -1
- package/dist/cli/Completions.js.map +1 -1
- package/dist/cli/Flag.d.ts +100 -0
- package/dist/cli/Flag.d.ts.map +1 -1
- package/dist/cli/Flag.js +33 -0
- package/dist/cli/Flag.js.map +1 -1
- package/dist/cli/Param.d.ts +87 -0
- package/dist/cli/Param.d.ts.map +1 -1
- package/dist/cli/Param.js +30 -0
- package/dist/cli/Param.js.map +1 -1
- package/dist/cli/internal/command.d.ts.map +1 -1
- package/dist/cli/internal/command.js +2 -1
- package/dist/cli/internal/command.js.map +1 -1
- package/dist/cli/internal/completions/bash.js +4 -3
- package/dist/cli/internal/completions/bash.js.map +1 -1
- package/dist/cli/internal/completions/descriptor.js +8 -1
- package/dist/cli/internal/completions/descriptor.js.map +1 -1
- package/dist/cli/internal/completions/fish.js +4 -4
- package/dist/cli/internal/completions/fish.js.map +1 -1
- package/dist/cli/internal/completions/powershell.js +3 -2
- package/dist/cli/internal/completions/powershell.js.map +1 -1
- package/dist/cli/internal/completions/zsh.js +7 -3
- package/dist/cli/internal/completions/zsh.js.map +1 -1
- package/dist/cli/internal/parser.js +11 -3
- 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 +2 -1
- package/dist/cli/internal/wizard.js.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.d.ts +1 -0
- package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.js +113 -21
- package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/cluster/MessageStorage.js +20 -12
- package/dist/cluster/MessageStorage.js.map +1 -1
- package/dist/cluster/Runners.d.ts.map +1 -1
- package/dist/cluster/Runners.js +54 -34
- package/dist/cluster/Runners.js.map +1 -1
- package/dist/cluster/Sharding.d.ts.map +1 -1
- package/dist/cluster/Sharding.js +6 -4
- package/dist/cluster/Sharding.js.map +1 -1
- package/dist/cluster/internal/entityManager.js +1 -1
- package/dist/cluster/internal/entityManager.js.map +1 -1
- package/dist/encoding/Sse.d.ts +6 -0
- package/dist/encoding/Sse.d.ts.map +1 -1
- package/dist/encoding/Sse.js +63 -71
- package/dist/encoding/Sse.js.map +1 -1
- package/dist/graphql/GraphQL.d.ts +349 -0
- package/dist/graphql/GraphQL.d.ts.map +1 -0
- package/dist/graphql/GraphQL.js +207 -0
- package/dist/graphql/GraphQL.js.map +1 -0
- package/dist/graphql/GraphQLClient.d.ts +562 -0
- package/dist/graphql/GraphQLClient.d.ts.map +1 -0
- package/dist/graphql/GraphQLClient.js +505 -0
- package/dist/graphql/GraphQLClient.js.map +1 -0
- package/dist/graphql/GraphQLClientError.d.ts +445 -0
- package/dist/graphql/GraphQLClientError.d.ts.map +1 -0
- package/dist/graphql/GraphQLClientError.js +479 -0
- package/dist/graphql/GraphQLClientError.js.map +1 -0
- package/dist/graphql/GraphQLGroup.d.ts +118 -0
- package/dist/graphql/GraphQLGroup.d.ts.map +1 -0
- package/dist/graphql/GraphQLGroup.js +109 -0
- package/dist/graphql/GraphQLGroup.js.map +1 -0
- package/dist/graphql/GraphQLMiddleware.d.ts +249 -0
- package/dist/graphql/GraphQLMiddleware.d.ts.map +1 -0
- package/dist/graphql/GraphQLMiddleware.js +130 -0
- package/dist/graphql/GraphQLMiddleware.js.map +1 -0
- package/dist/graphql/GraphQLProtocol.d.ts +969 -0
- package/dist/graphql/GraphQLProtocol.d.ts.map +1 -0
- package/dist/graphql/GraphQLProtocol.js +809 -0
- package/dist/graphql/GraphQLProtocol.js.map +1 -0
- package/dist/graphql/GraphQLResolver.d.ts +453 -0
- package/dist/graphql/GraphQLResolver.d.ts.map +1 -0
- package/dist/graphql/GraphQLResolver.js +582 -0
- package/dist/graphql/GraphQLResolver.js.map +1 -0
- package/dist/graphql/index.d.ts +40 -0
- package/dist/graphql/index.d.ts.map +1 -0
- package/dist/graphql/index.js +41 -0
- package/dist/graphql/index.js.map +1 -0
- package/dist/http/FetchHttpClient.d.ts +6 -3
- package/dist/http/FetchHttpClient.d.ts.map +1 -1
- package/dist/http/FetchHttpClient.js +6 -3
- package/dist/http/FetchHttpClient.js.map +1 -1
- package/dist/http/FindMyWay/internal/router.js +2 -1
- package/dist/http/FindMyWay/internal/router.js.map +1 -1
- package/dist/http/Headers.d.ts +3 -3
- package/dist/http/Headers.d.ts.map +1 -1
- package/dist/http/Headers.js +6 -5
- package/dist/http/Headers.js.map +1 -1
- package/dist/http/HttpClient.d.ts +27 -0
- package/dist/http/HttpClient.d.ts.map +1 -1
- package/dist/http/HttpClient.js +38 -11
- package/dist/http/HttpClient.js.map +1 -1
- package/dist/http/HttpClientError.d.ts.map +1 -1
- package/dist/http/HttpClientError.js +8 -6
- package/dist/http/HttpClientError.js.map +1 -1
- package/dist/http/HttpClientRequest.d.ts +147 -4
- package/dist/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/http/HttpClientRequest.js +47 -1
- package/dist/http/HttpClientRequest.js.map +1 -1
- package/dist/http/HttpEffect.d.ts.map +1 -1
- package/dist/http/HttpEffect.js +14 -7
- package/dist/http/HttpEffect.js.map +1 -1
- package/dist/http/HttpMiddleware.d.ts +60 -0
- package/dist/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/http/HttpMiddleware.js +93 -32
- package/dist/http/HttpMiddleware.js.map +1 -1
- package/dist/http/HttpRouter.d.ts +35 -0
- package/dist/http/HttpRouter.d.ts.map +1 -1
- package/dist/http/HttpRouter.js +87 -13
- package/dist/http/HttpRouter.js.map +1 -1
- package/dist/http/HttpServerError.d.ts.map +1 -1
- package/dist/http/HttpServerError.js +6 -4
- package/dist/http/HttpServerError.js.map +1 -1
- package/dist/http/HttpServerRequest.js +2 -2
- package/dist/http/HttpServerRequest.js.map +1 -1
- package/dist/http/HttpServerResponse.d.ts +8 -6
- package/dist/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/http/HttpServerResponse.js +27 -16
- package/dist/http/HttpServerResponse.js.map +1 -1
- package/dist/http/HttpStaticServer.d.ts.map +1 -1
- package/dist/http/HttpStaticServer.js +4 -10
- package/dist/http/HttpStaticServer.js.map +1 -1
- package/dist/http/HttpTraceContext.js +1 -1
- package/dist/http/HttpTraceContext.js.map +1 -1
- package/dist/http/Multipart.d.ts.map +1 -1
- package/dist/http/Multipart.js +15 -1
- package/dist/http/Multipart.js.map +1 -1
- package/dist/http/Url.d.ts.map +1 -1
- package/dist/http/Url.js +2 -1
- package/dist/http/Url.js.map +1 -1
- package/dist/http/UrlParams.d.ts +112 -8
- package/dist/http/UrlParams.d.ts.map +1 -1
- package/dist/http/UrlParams.js +141 -14
- package/dist/http/UrlParams.js.map +1 -1
- package/dist/http/internal/compression.d.ts +1 -1
- package/dist/http/internal/compression.d.ts.map +1 -1
- package/dist/http/internal/compression.js +2 -10
- package/dist/http/internal/compression.js.map +1 -1
- package/dist/http/internal/compressionBody.d.ts +2 -0
- package/dist/http/internal/compressionBody.d.ts.map +1 -0
- package/dist/http/internal/compressionBody.js +36 -0
- package/dist/http/internal/compressionBody.js.map +1 -0
- package/dist/http/internal/decompression.d.ts +2 -0
- package/dist/http/internal/decompression.d.ts.map +1 -0
- package/dist/http/internal/decompression.js +162 -0
- package/dist/http/internal/decompression.js.map +1 -0
- package/dist/http/internal/tracing.js +14 -4
- package/dist/http/internal/tracing.js.map +1 -1
- package/dist/http/internal/urlParams.d.ts +2 -0
- package/dist/http/internal/urlParams.d.ts.map +1 -0
- package/dist/http/internal/urlParams.js +4 -0
- package/dist/http/internal/urlParams.js.map +1 -0
- package/dist/http-api/HttpApiClient.d.ts.map +1 -1
- package/dist/http-api/HttpApiClient.js +2 -1
- package/dist/http-api/HttpApiClient.js.map +1 -1
- package/dist/http-api/HttpApiScalar.d.ts +5 -0
- package/dist/http-api/HttpApiScalar.d.ts.map +1 -1
- package/dist/http-api/HttpApiScalar.js.map +1 -1
- package/dist/internal/core.js +17 -1
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/dateTime.js +40 -35
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +13 -6
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/graphql.d.ts +2 -0
- package/dist/internal/graphql.d.ts.map +1 -0
- package/dist/internal/graphql.js +205 -0
- package/dist/internal/graphql.js.map +1 -0
- package/dist/internal/graphqlHeaders.d.ts +4 -0
- package/dist/internal/graphqlHeaders.d.ts.map +1 -0
- package/dist/internal/graphqlHeaders.js +11 -0
- package/dist/internal/graphqlHeaders.js.map +1 -0
- package/dist/internal/request.js +20 -1
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/schema/toCodeDocument.js +4 -1
- package/dist/internal/schema/toCodeDocument.js.map +1 -1
- package/dist/internal/schema/toJsonSchemaDocument.js +29 -5
- package/dist/internal/schema/toJsonSchemaDocument.js.map +1 -1
- package/dist/internal/version.js +1 -1
- package/dist/net/Host.d.ts +49 -0
- package/dist/net/Host.d.ts.map +1 -1
- package/dist/net/Host.js +55 -0
- package/dist/net/Host.js.map +1 -1
- package/dist/net/NetAddress.d.ts +8 -0
- package/dist/net/NetAddress.d.ts.map +1 -1
- package/dist/net/NetAddress.js +8 -0
- package/dist/net/NetAddress.js.map +1 -1
- package/dist/observability/Otlp.d.ts +15 -0
- package/dist/observability/Otlp.d.ts.map +1 -1
- package/dist/observability/Otlp.js +3 -0
- package/dist/observability/Otlp.js.map +1 -1
- package/dist/observability/OtlpExporter.d.ts +8 -0
- package/dist/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/observability/OtlpExporter.js +10 -1
- package/dist/observability/OtlpExporter.js.map +1 -1
- package/dist/observability/OtlpLogger.d.ts +17 -0
- package/dist/observability/OtlpLogger.d.ts.map +1 -1
- package/dist/observability/OtlpLogger.js +14 -1
- package/dist/observability/OtlpLogger.js.map +1 -1
- package/dist/observability/OtlpMetrics.d.ts +17 -0
- package/dist/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/observability/OtlpMetrics.js +13 -0
- package/dist/observability/OtlpMetrics.js.map +1 -1
- package/dist/observability/OtlpTracer.d.ts +17 -0
- package/dist/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/observability/OtlpTracer.js +15 -2
- package/dist/observability/OtlpTracer.js.map +1 -1
- package/dist/reactivity/AsyncResult.d.ts +6 -0
- package/dist/reactivity/AsyncResult.d.ts.map +1 -1
- package/dist/reactivity/AsyncResult.js +27 -0
- package/dist/reactivity/AsyncResult.js.map +1 -1
- package/dist/reactivity/AtomRegistry.js +3 -1
- package/dist/reactivity/AtomRegistry.js.map +1 -1
- package/dist/rpc/RpcClient.d.ts.map +1 -1
- package/dist/rpc/RpcClient.js +6 -1
- package/dist/rpc/RpcClient.js.map +1 -1
- package/dist/rpc/RpcServer.d.ts.map +1 -1
- package/dist/rpc/RpcServer.js +36 -9
- package/dist/rpc/RpcServer.js.map +1 -1
- package/dist/socket/Socket.d.ts +6 -0
- package/dist/socket/Socket.d.ts.map +1 -1
- package/dist/socket/Socket.js.map +1 -1
- package/dist/sql/SqlClient.d.ts +8 -7
- package/dist/sql/SqlClient.d.ts.map +1 -1
- package/dist/sql/SqlClient.js +8 -7
- package/dist/sql/SqlClient.js.map +1 -1
- package/dist/testing/TestClock.d.ts +16 -3
- package/dist/testing/TestClock.d.ts.map +1 -1
- package/dist/testing/TestClock.js +112 -22
- package/dist/testing/TestClock.js.map +1 -1
- package/dist/workflow/Activity.js +1 -0
- package/dist/workflow/Activity.js.map +1 -1
- package/dist/workflow/DurableDeferred.d.ts.map +1 -1
- package/dist/workflow/DurableDeferred.js +32 -3
- package/dist/workflow/DurableDeferred.js.map +1 -1
- package/dist/workflow/Workflow.d.ts +22 -0
- package/dist/workflow/Workflow.d.ts.map +1 -1
- package/dist/workflow/Workflow.js +15 -3
- package/dist/workflow/Workflow.js.map +1 -1
- package/dist/workflow/WorkflowEngine.d.ts +44 -3
- package/dist/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/workflow/WorkflowEngine.js +45 -22
- package/dist/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +6 -3
- package/src/Array.ts +95 -6
- package/src/Channel.ts +24 -3
- package/src/ConfigProvider.ts +40 -44
- package/src/Context.ts +9 -0
- package/src/Duration.ts +4 -5
- package/src/Effect.ts +140 -53
- package/src/FileSystem.ts +23 -9
- package/src/Match.ts +65 -12
- package/src/Path.ts +52 -7
- package/src/RequestResolver.ts +4 -10
- package/src/Scheduler.ts +9 -0
- package/src/Schema.ts +25 -4
- package/src/SchemaGetter.ts +47 -35
- package/src/Sink.ts +45 -18
- package/src/Stream.ts +33 -4
- package/src/String.ts +17 -4
- package/src/TxRef.ts +4 -2
- package/src/Utils.ts +8 -5
- package/src/ai/AiError.ts +3 -1
- package/src/ai/AnthropicStructuredOutput.ts +2 -2
- package/src/ai/Chat.ts +2 -2
- package/src/ai/Decision.ts +70 -21
- package/src/ai/DecisionModel.ts +1 -1
- package/src/ai/LanguageModel.ts +141 -63
- package/src/ai/McpServer.ts +259 -145
- package/src/ai/Prompt.ts +24 -10
- package/src/ai/Response.ts +6 -3
- package/src/cli/Completions.ts +5 -0
- package/src/cli/Flag.ts +101 -0
- package/src/cli/Param.ts +96 -0
- package/src/cli/internal/command.ts +2 -1
- package/src/cli/internal/completions/bash.ts +4 -3
- package/src/cli/internal/completions/descriptor.ts +10 -1
- package/src/cli/internal/completions/fish.ts +4 -4
- package/src/cli/internal/completions/powershell.ts +5 -2
- package/src/cli/internal/completions/zsh.ts +7 -3
- package/src/cli/internal/parser.ts +12 -3
- package/src/cli/internal/wizard.ts +2 -1
- package/src/cluster/ClusterWorkflowEngine.ts +143 -36
- package/src/cluster/MessageStorage.ts +14 -3
- package/src/cluster/Runners.ts +88 -66
- package/src/cluster/Sharding.ts +12 -9
- package/src/cluster/internal/entityManager.ts +1 -1
- package/src/encoding/Sse.ts +70 -80
- package/src/graphql/GraphQL.ts +494 -0
- package/src/graphql/GraphQLClient.ts +924 -0
- package/src/graphql/GraphQLClientError.ts +542 -0
- package/src/graphql/GraphQLGroup.ts +167 -0
- package/src/graphql/GraphQLMiddleware.ts +253 -0
- package/src/graphql/GraphQLProtocol.ts +1540 -0
- package/src/graphql/GraphQLResolver.ts +1038 -0
- package/src/graphql/index.ts +48 -0
- package/src/http/FetchHttpClient.ts +6 -3
- package/src/http/FindMyWay/internal/router.ts +2 -1
- package/src/http/Headers.ts +6 -9
- package/src/http/HttpClient.ts +72 -11
- package/src/http/HttpClientError.ts +10 -6
- package/src/http/HttpClientRequest.ts +173 -7
- package/src/http/HttpEffect.ts +11 -5
- package/src/http/HttpMiddleware.ts +113 -34
- package/src/http/HttpRouter.ts +95 -13
- package/src/http/HttpServerError.ts +8 -4
- package/src/http/HttpServerRequest.ts +2 -2
- package/src/http/HttpServerResponse.ts +28 -16
- package/src/http/HttpStaticServer.ts +4 -10
- package/src/http/HttpTraceContext.ts +1 -1
- package/src/http/Multipart.ts +17 -1
- package/src/http/Url.ts +2 -1
- package/src/http/UrlParams.ts +225 -26
- package/src/http/internal/compression.ts +3 -17
- package/src/http/internal/compressionBody.ts +56 -0
- package/src/http/internal/decompression.ts +226 -0
- package/src/http/internal/tracing.ts +21 -4
- package/src/http/internal/urlParams.ts +5 -0
- package/src/http-api/HttpApiClient.ts +2 -1
- package/src/http-api/HttpApiScalar.ts +5 -0
- package/src/internal/core.ts +21 -1
- package/src/internal/dateTime.ts +13 -10
- package/src/internal/effect.ts +13 -7
- package/src/internal/graphql.ts +286 -0
- package/src/internal/graphqlHeaders.ts +11 -0
- package/src/internal/request.ts +31 -3
- package/src/internal/schema/toCodeDocument.ts +7 -1
- package/src/internal/schema/toJsonSchemaDocument.ts +34 -2
- package/src/internal/version.ts +1 -1
- package/src/net/Host.ts +72 -0
- package/src/net/NetAddress.ts +9 -0
- package/src/observability/Otlp.ts +18 -0
- package/src/observability/OtlpExporter.ts +14 -3
- package/src/observability/OtlpLogger.ts +31 -2
- package/src/observability/OtlpMetrics.ts +30 -1
- package/src/observability/OtlpTracer.ts +32 -3
- package/src/reactivity/AsyncResult.ts +31 -0
- package/src/reactivity/AtomRegistry.ts +3 -1
- package/src/rpc/RpcClient.ts +6 -1
- package/src/rpc/RpcServer.ts +55 -15
- package/src/socket/Socket.ts +6 -0
- package/src/sql/SqlClient.ts +9 -7
- package/src/testing/TestClock.ts +144 -29
- package/src/workflow/Activity.ts +1 -0
- package/src/workflow/DurableDeferred.ts +43 -5
- package/src/workflow/Workflow.ts +31 -5
- package/src/workflow/WorkflowEngine.ts +107 -25
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import * as Cause from "../Cause.ts"
|
|
14
14
|
import * as Context from "../Context.ts"
|
|
15
|
+
import * as Deferred from "../Deferred.ts"
|
|
15
16
|
import * as Effect from "../Effect.ts"
|
|
16
17
|
import * as Exit from "../Exit.ts"
|
|
17
18
|
import * as Fiber from "../Fiber.ts"
|
|
@@ -75,6 +76,17 @@ export class WorkflowEngine extends Context.Service<
|
|
|
75
76
|
|
|
76
77
|
/**
|
|
77
78
|
* Execute a registered workflow.
|
|
79
|
+
*
|
|
80
|
+
* **Details**
|
|
81
|
+
*
|
|
82
|
+
* Unless `discard` is set, a caller outside any workflow waits for the
|
|
83
|
+
* result. While the execution is suspended, the caller retries on
|
|
84
|
+
* `suspendedRetrySchedule`; engines that observe the final result wake it
|
|
85
|
+
* sooner. `ClusterWorkflowEngine` does so only for callers on the runner
|
|
86
|
+
* that owns the execution.
|
|
87
|
+
*
|
|
88
|
+
* `detached: true` requires `discard: true` and skips parent completion
|
|
89
|
+
* wakes and interruption linkage. Otherwise, it is a defect.
|
|
78
90
|
*/
|
|
79
91
|
readonly execute: <
|
|
80
92
|
Name extends string,
|
|
@@ -88,6 +100,7 @@ export class WorkflowEngine extends Context.Service<
|
|
|
88
100
|
readonly executionId: string
|
|
89
101
|
readonly payload: Payload["Type"]
|
|
90
102
|
readonly discard?: Discard | undefined
|
|
103
|
+
readonly detached?: boolean | undefined
|
|
91
104
|
readonly suspendedRetrySchedule?:
|
|
92
105
|
| Schedule.Schedule<any, unknown>
|
|
93
106
|
| undefined
|
|
@@ -271,8 +284,17 @@ export class WorkflowInstance extends Context.Service<
|
|
|
271
284
|
*/
|
|
272
285
|
cause: Cause.Cause<never> | undefined
|
|
273
286
|
|
|
274
|
-
/**
|
|
275
|
-
|
|
287
|
+
/**
|
|
288
|
+
* Whether this workflow or an activity hit `SuspendOnFailure`, excluding
|
|
289
|
+
* inherited child failures.
|
|
290
|
+
*/
|
|
291
|
+
failed: boolean
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Deferred names this run waits on, counted per live wait; their
|
|
295
|
+
* completions preempt the run.
|
|
296
|
+
*/
|
|
297
|
+
readonly awaitedDeferreds: Map<string, number>
|
|
276
298
|
|
|
277
299
|
/** Deferred names this run completed itself; their completions need not wake it. */
|
|
278
300
|
readonly completedDeferreds: Set<string>
|
|
@@ -286,17 +308,26 @@ export class WorkflowInstance extends Context.Service<
|
|
|
286
308
|
static initial(
|
|
287
309
|
workflow: Workflow.Any,
|
|
288
310
|
executionId: string,
|
|
289
|
-
|
|
311
|
+
options?: {
|
|
312
|
+
readonly scope?: Scope.Closeable | undefined
|
|
313
|
+
/**
|
|
314
|
+
* Awaited deferred names shared with the run this instance belongs to.
|
|
315
|
+
* An activity instance registers its durable waits there so the run
|
|
316
|
+
* can be woken once it suspends, without those waits preempting it.
|
|
317
|
+
*/
|
|
318
|
+
readonly awaitedDeferreds?: Map<string, number> | undefined
|
|
319
|
+
}
|
|
290
320
|
): WorkflowInstance["Service"] {
|
|
291
321
|
return WorkflowInstance.of({
|
|
292
322
|
executionId,
|
|
293
323
|
workflow,
|
|
294
|
-
scope,
|
|
324
|
+
scope: options?.scope ?? Scope.makeUnsafe(),
|
|
295
325
|
suspended: false,
|
|
296
326
|
interrupted: false,
|
|
297
327
|
abandoned: false,
|
|
298
328
|
cause: undefined,
|
|
299
|
-
|
|
329
|
+
failed: false,
|
|
330
|
+
awaitedDeferreds: options?.awaitedDeferreds ?? new Map(),
|
|
300
331
|
completedDeferreds: new Set(),
|
|
301
332
|
activityState: {
|
|
302
333
|
count: 0,
|
|
@@ -394,6 +425,8 @@ export interface Encoded {
|
|
|
394
425
|
readonly payload: object
|
|
395
426
|
readonly discard: Discard
|
|
396
427
|
readonly parent?: WorkflowInstance["Service"] | undefined
|
|
428
|
+
/** Skip parent completion wakes and interruption linkage. */
|
|
429
|
+
readonly detached?: boolean | undefined
|
|
397
430
|
}
|
|
398
431
|
) => Effect.Effect<
|
|
399
432
|
Discard extends true ? void : Workflow.Result<unknown, unknown>
|
|
@@ -414,6 +447,22 @@ export interface Encoded {
|
|
|
414
447
|
workflow: Workflow.Any,
|
|
415
448
|
executionId: string
|
|
416
449
|
) => Effect.Effect<void>
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Waits until a suspended execution has a result other than `Suspended`.
|
|
453
|
+
*
|
|
454
|
+
* **Gotchas**
|
|
455
|
+
*
|
|
456
|
+
* External callers race this with their `suspendedRetrySchedule`, so it may
|
|
457
|
+
* never complete when the engine cannot observe the result. Completing while
|
|
458
|
+
* the execution is still suspended skips the sleep and spends a step of that
|
|
459
|
+
* schedule. A hook that keeps completing early makes the caller spin.
|
|
460
|
+
*/
|
|
461
|
+
readonly awaitComplete?: (
|
|
462
|
+
workflow: Workflow.Any,
|
|
463
|
+
executionId: string
|
|
464
|
+
) => Effect.Effect<void>
|
|
465
|
+
|
|
417
466
|
readonly activityExecute: (
|
|
418
467
|
activity: Activity.Any,
|
|
419
468
|
attempt: number
|
|
@@ -486,11 +535,15 @@ export const makeUnsafe = (options: Encoded): WorkflowEngine["Service"] =>
|
|
|
486
535
|
readonly executionId: string
|
|
487
536
|
readonly payload: Payload["Type"]
|
|
488
537
|
readonly discard?: Discard | undefined
|
|
538
|
+
readonly detached?: boolean | undefined
|
|
489
539
|
readonly suspendedRetrySchedule?:
|
|
490
540
|
| Schedule.Schedule<any, unknown>
|
|
491
541
|
| undefined
|
|
492
542
|
}
|
|
493
543
|
) {
|
|
544
|
+
if (opts.detached && !opts.discard) {
|
|
545
|
+
return yield* Effect.die(`${self._tag}.execute: detached requires discard`)
|
|
546
|
+
}
|
|
494
547
|
const payload = opts.payload
|
|
495
548
|
const executionId = opts.executionId
|
|
496
549
|
const suspendedRetrySchedule = opts.suspendedRetrySchedule ?? defaultRetrySchedule
|
|
@@ -499,7 +552,7 @@ export const makeUnsafe = (options: Encoded): WorkflowEngine["Service"] =>
|
|
|
499
552
|
|
|
500
553
|
// link interruption with parent workflow
|
|
501
554
|
const parentInstance = yield* Effect.serviceOption(WorkflowInstance)
|
|
502
|
-
if (Option.isSome(parentInstance)) {
|
|
555
|
+
if (Option.isSome(parentInstance) && !opts.detached) {
|
|
503
556
|
const instance = parentInstance.value
|
|
504
557
|
yield* Effect.addFinalizer(() => {
|
|
505
558
|
if (!instance.interrupted || (Option.isSome(result) && result.value._tag === "Complete")) {
|
|
@@ -512,7 +565,8 @@ export const makeUnsafe = (options: Encoded): WorkflowEngine["Service"] =>
|
|
|
512
565
|
executionId,
|
|
513
566
|
payload: payload as object,
|
|
514
567
|
discard: opts.discard ?? false,
|
|
515
|
-
parent: Option.getOrUndefined(parentInstance)
|
|
568
|
+
parent: Option.getOrUndefined(parentInstance),
|
|
569
|
+
detached: opts.detached
|
|
516
570
|
}) as Effect.Effect<Workflow.Result<Success["Type"], Error["Type"]>>
|
|
517
571
|
|
|
518
572
|
if (opts.discard) {
|
|
@@ -548,7 +602,10 @@ export const makeUnsafe = (options: Encoded): WorkflowEngine["Service"] =>
|
|
|
548
602
|
)
|
|
549
603
|
)
|
|
550
604
|
)
|
|
551
|
-
|
|
605
|
+
// Completion wakes the caller early; the schedule is the fallback.
|
|
606
|
+
yield* options.awaitComplete
|
|
607
|
+
? Effect.raceFirst(sleep, options.awaitComplete(self, executionId))
|
|
608
|
+
: sleep
|
|
552
609
|
}
|
|
553
610
|
}),
|
|
554
611
|
poll: options.poll,
|
|
@@ -644,6 +701,11 @@ const defaultRetrySchedule = Schedule.min([
|
|
|
644
701
|
Schedule.spaced(30000)
|
|
645
702
|
])
|
|
646
703
|
|
|
704
|
+
type WakeMode = "explicit" | "automatic"
|
|
705
|
+
|
|
706
|
+
const isUnwakeable = (result: Workflow.Result<unknown, unknown>, mode: WakeMode) =>
|
|
707
|
+
result._tag === "Complete" || (mode === "automatic" && result.failed === true)
|
|
708
|
+
|
|
647
709
|
/**
|
|
648
710
|
* Layer that provides an in-memory `WorkflowEngine`.
|
|
649
711
|
*
|
|
@@ -683,8 +745,11 @@ export const layerMemory: Layer.Layer<WorkflowEngine> = Layer.effect(WorkflowEng
|
|
|
683
745
|
readonly parent: string | undefined
|
|
684
746
|
instance: WorkflowInstance["Service"]
|
|
685
747
|
interrupted: boolean
|
|
686
|
-
|
|
748
|
+
// The strongest wake requested while a run was still finishing.
|
|
749
|
+
resumeRequested: WakeMode | undefined
|
|
687
750
|
fiber: Fiber.Fiber<Workflow.Result<unknown, unknown>> | undefined
|
|
751
|
+
// Completed once a run succeeds with `Complete`, after which it cannot resume.
|
|
752
|
+
readonly done: Deferred.Deferred<void>
|
|
688
753
|
}
|
|
689
754
|
const executions = new Map<string, ExecutionState>()
|
|
690
755
|
|
|
@@ -695,21 +760,22 @@ export const layerMemory: Layer.Layer<WorkflowEngine> = Layer.effect(WorkflowEng
|
|
|
695
760
|
|
|
696
761
|
const deferredState = makeDeferredState()
|
|
697
762
|
|
|
698
|
-
const resume = Effect.fnUntraced(function*(executionId: string): Effect.fn.Return<void> {
|
|
763
|
+
const resume = Effect.fnUntraced(function*(executionId: string, mode: WakeMode): Effect.fn.Return<void> {
|
|
699
764
|
const state = executions.get(executionId)
|
|
700
765
|
if (!state) return
|
|
701
766
|
const exit = state.fiber?.pollUnsafe()
|
|
702
|
-
if (exit && exit._tag === "Success" && exit.value
|
|
767
|
+
if (exit && exit._tag === "Success" && isUnwakeable(exit.value, mode)) {
|
|
703
768
|
return
|
|
704
769
|
} else if (state.fiber && !exit) {
|
|
705
|
-
//
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
770
|
+
// Queue wakes until the run finishes cleanup; explicit wakes take priority.
|
|
771
|
+
const requested = state.resumeRequested
|
|
772
|
+
state.resumeRequested = mode === "explicit" ? mode : requested ?? mode
|
|
773
|
+
if (requested === undefined) {
|
|
709
774
|
yield* Fiber.await(state.fiber).pipe(
|
|
710
775
|
Effect.flatMap(() => {
|
|
711
|
-
state.resumeRequested
|
|
712
|
-
|
|
776
|
+
const mode = state.resumeRequested!
|
|
777
|
+
state.resumeRequested = undefined
|
|
778
|
+
return resume(executionId, mode)
|
|
713
779
|
}),
|
|
714
780
|
Effect.forkIn(scope)
|
|
715
781
|
)
|
|
@@ -721,7 +787,7 @@ export const layerMemory: Layer.Layer<WorkflowEngine> = Layer.effect(WorkflowEng
|
|
|
721
787
|
const instance = WorkflowInstance.initial(
|
|
722
788
|
state.instance.workflow,
|
|
723
789
|
state.instance.executionId,
|
|
724
|
-
state.instance.scope
|
|
790
|
+
{ scope: state.instance.scope }
|
|
725
791
|
)
|
|
726
792
|
state.instance = instance
|
|
727
793
|
state.fiber = yield* state.execute(state.payload, state.instance.executionId).pipe(
|
|
@@ -740,7 +806,12 @@ export const layerMemory: Layer.Layer<WorkflowEngine> = Layer.effect(WorkflowEng
|
|
|
740
806
|
if (!state.parent || result._tag !== "Complete") {
|
|
741
807
|
return Effect.void
|
|
742
808
|
}
|
|
743
|
-
return Effect.forkIn(resume(state.parent), scope)
|
|
809
|
+
return Effect.forkIn(resume(state.parent, "automatic"), scope)
|
|
810
|
+
}),
|
|
811
|
+
Effect.onExit((exit) => {
|
|
812
|
+
return Exit.isSuccess(exit) && exit.value._tag === "Complete"
|
|
813
|
+
? Deferred.succeed(state.done, void 0)
|
|
814
|
+
: Effect.void
|
|
744
815
|
}),
|
|
745
816
|
Effect.forkIn(entry.scope)
|
|
746
817
|
)
|
|
@@ -771,12 +842,13 @@ export const layerMemory: Layer.Layer<WorkflowEngine> = Layer.effect(WorkflowEng
|
|
|
771
842
|
execute: entry.execute,
|
|
772
843
|
instance: WorkflowInstance.initial(workflow, options.executionId),
|
|
773
844
|
interrupted: false,
|
|
774
|
-
resumeRequested:
|
|
845
|
+
resumeRequested: undefined,
|
|
775
846
|
fiber: undefined,
|
|
776
|
-
|
|
847
|
+
done: Deferred.makeUnsafe(),
|
|
848
|
+
parent: options.detached ? undefined : options.parent?.executionId
|
|
777
849
|
}
|
|
778
850
|
executions.set(options.executionId, state)
|
|
779
|
-
yield* resume(options.executionId)
|
|
851
|
+
yield* resume(options.executionId, "explicit")
|
|
780
852
|
}
|
|
781
853
|
if (options.discard) return
|
|
782
854
|
// Capture together so a wake that swaps in a replay cannot desync them.
|
|
@@ -788,11 +860,16 @@ export const layerMemory: Layer.Layer<WorkflowEngine> = Layer.effect(WorkflowEng
|
|
|
788
860
|
}
|
|
789
861
|
return (yield* exit) as any
|
|
790
862
|
}),
|
|
863
|
+
awaitComplete: (_workflow, executionId) =>
|
|
864
|
+
Effect.suspend(() => {
|
|
865
|
+
const state = executions.get(executionId)
|
|
866
|
+
return state ? Deferred.await(state.done) : Effect.never
|
|
867
|
+
}),
|
|
791
868
|
interrupt: Effect.fnUntraced(function*(_workflow, executionId) {
|
|
792
869
|
const state = executions.get(executionId)
|
|
793
870
|
if (!state) return
|
|
794
871
|
state.interrupted = true
|
|
795
|
-
yield* resume(executionId)
|
|
872
|
+
yield* resume(executionId, "explicit")
|
|
796
873
|
}),
|
|
797
874
|
interruptUnsafe: Effect.fnUntraced(function*(_workflow, executionId) {
|
|
798
875
|
const state = executions.get(executionId)
|
|
@@ -803,7 +880,7 @@ export const layerMemory: Layer.Layer<WorkflowEngine> = Layer.effect(WorkflowEng
|
|
|
803
880
|
}
|
|
804
881
|
}),
|
|
805
882
|
resume(_workflow, executionId) {
|
|
806
|
-
return resume(executionId)
|
|
883
|
+
return resume(executionId, "explicit")
|
|
807
884
|
},
|
|
808
885
|
activityExecute: Effect.fnUntraced(function*(activity, attempt) {
|
|
809
886
|
const instance = yield* WorkflowInstance
|
|
@@ -820,6 +897,11 @@ export const layerMemory: Layer.Layer<WorkflowEngine> = Layer.effect(WorkflowEng
|
|
|
820
897
|
state = { exit: undefined }
|
|
821
898
|
activities.set(activityId, state)
|
|
822
899
|
}
|
|
900
|
+
// A pending interrupt replays only to rebuild compensations, so it must
|
|
901
|
+
// not run new activities. Finalizers run once `interrupted` is set.
|
|
902
|
+
if (executions.get(instance.executionId)?.interrupted && !instance.interrupted) {
|
|
903
|
+
return new Workflow.Suspended({})
|
|
904
|
+
}
|
|
823
905
|
const activityInstance = WorkflowInstance.initial(instance.workflow, instance.executionId)
|
|
824
906
|
activityInstance.interrupted = instance.interrupted
|
|
825
907
|
return yield* activity.executeEncoded.pipe(
|
|
@@ -858,7 +940,7 @@ export const layerMemory: Layer.Layer<WorkflowEngine> = Layer.effect(WorkflowEng
|
|
|
858
940
|
deferredResults.set(id, options.exit)
|
|
859
941
|
const wake = Effect.andThen(
|
|
860
942
|
deferredState.deferredDone(options.executionId, options.deferredName),
|
|
861
|
-
resume(options.executionId)
|
|
943
|
+
resume(options.executionId, "automatic")
|
|
862
944
|
)
|
|
863
945
|
return Effect.flatMap(Effect.serviceOption(WorkflowInstance), (instance) =>
|
|
864
946
|
// A workflow finalizer cannot wait for its own run's cleanup.
|