effect 4.1.5 → 4.1.7
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/ai-docs/package.json +2 -2
- package/dist/Channel.d.ts +104 -7
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +73 -4
- package/dist/Channel.js.map +1 -1
- package/dist/Codegen.d.ts +7 -2
- package/dist/Codegen.d.ts.map +1 -1
- package/dist/Codegen.js +7 -2
- package/dist/Codegen.js.map +1 -1
- package/dist/Config.d.ts +1 -1
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +5 -3
- package/dist/Config.js.map +1 -1
- package/dist/Context.d.ts.map +1 -1
- package/dist/Context.js +79 -31
- package/dist/Context.js.map +1 -1
- package/dist/Cron.d.ts.map +1 -1
- package/dist/Cron.js +10 -9
- package/dist/Cron.js.map +1 -1
- package/dist/Effect.d.ts +139 -18
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +10 -2
- package/dist/Effect.js.map +1 -1
- package/dist/Equal.d.ts +4 -4
- package/dist/Equal.d.ts.map +1 -1
- package/dist/Equal.js +78 -66
- package/dist/Equal.js.map +1 -1
- package/dist/Formatter.js +4 -4
- package/dist/Formatter.js.map +1 -1
- package/dist/Hash.d.ts.map +1 -1
- package/dist/Hash.js +34 -41
- package/dist/Hash.js.map +1 -1
- package/dist/LayerRef.d.ts +1 -1
- package/dist/LayerRef.d.ts.map +1 -1
- package/dist/LayerRef.js +3 -3
- package/dist/LayerRef.js.map +1 -1
- package/dist/Logger.d.ts +37 -13
- package/dist/Logger.d.ts.map +1 -1
- package/dist/Logger.js +39 -10
- package/dist/Logger.js.map +1 -1
- package/dist/Match.d.ts +23 -23
- package/dist/Match.d.ts.map +1 -1
- package/dist/Match.js.map +1 -1
- package/dist/Metric.d.ts.map +1 -1
- package/dist/Metric.js +3 -4
- package/dist/Metric.js.map +1 -1
- package/dist/Order.js +1 -1
- package/dist/Order.js.map +1 -1
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +49 -21
- package/dist/Pool.js.map +1 -1
- package/dist/Predicate.d.ts.map +1 -1
- package/dist/Predicate.js +2 -1
- package/dist/Predicate.js.map +1 -1
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/Scheduler.js +15 -9
- package/dist/Scheduler.js.map +1 -1
- package/dist/Schema.d.ts +41 -0
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +51 -390
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +2 -2
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +199 -98
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +29 -50
- package/dist/SchemaParser.js.map +1 -1
- package/dist/ScopedCache.d.ts.map +1 -1
- package/dist/ScopedCache.js +6 -4
- package/dist/ScopedCache.js.map +1 -1
- package/dist/Stream.d.ts +128 -5
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +124 -29
- package/dist/Stream.js.map +1 -1
- package/dist/String.js +1 -1
- package/dist/String.js.map +1 -1
- package/dist/Tracer.d.ts +10 -0
- package/dist/Tracer.d.ts.map +1 -1
- package/dist/Tracer.js +3 -4
- package/dist/Tracer.js.map +1 -1
- package/dist/ai/McpClient.d.ts +68 -4
- package/dist/ai/McpClient.d.ts.map +1 -1
- package/dist/ai/McpClient.js +100 -17
- package/dist/ai/McpClient.js.map +1 -1
- package/dist/ai/McpClientError.d.ts +46 -4
- package/dist/ai/McpClientError.d.ts.map +1 -1
- package/dist/ai/McpClientError.js +38 -3
- package/dist/ai/McpClientError.js.map +1 -1
- package/dist/ai/McpServer.d.ts +158 -7
- package/dist/ai/McpServer.d.ts.map +1 -1
- package/dist/ai/McpServer.js +103 -49
- package/dist/ai/McpServer.js.map +1 -1
- package/dist/ai/Prompt.d.ts +3 -1
- package/dist/ai/Prompt.d.ts.map +1 -1
- package/dist/ai/Prompt.js +17 -3
- package/dist/ai/Prompt.js.map +1 -1
- package/dist/ai/Skill.d.ts +172 -0
- package/dist/ai/Skill.d.ts.map +1 -0
- package/dist/ai/Skill.js +209 -0
- package/dist/ai/Skill.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 +9 -7
- package/dist/ai/internal/mcpProtocol/v2024_11_05.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_03_26.js +12 -11
- package/dist/ai/internal/mcpProtocol/v2025_03_26.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_06_18.js +18 -17
- package/dist/ai/internal/mcpProtocol/v2025_06_18.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_11_25.js +19 -18
- package/dist/ai/internal/mcpProtocol/v2025_11_25.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2026_07_28.js +1 -1
- package/dist/ai/internal/mcpProtocol/v2026_07_28.js.map +1 -1
- package/dist/ai/internal/mcpProtocol.js +11 -0
- package/dist/ai/internal/mcpProtocol.js.map +1 -1
- package/dist/ai/internal/mcpRuntime.js +29 -17
- package/dist/ai/internal/mcpRuntime.js.map +1 -1
- package/dist/ai/internal/mcpSchema/v2024_11_05.js +2 -1
- package/dist/ai/internal/mcpSchema/v2024_11_05.js.map +1 -1
- package/dist/ai/internal/mcpSchema/v2025_03_26.js +1 -8
- package/dist/ai/internal/mcpSchema/v2025_03_26.js.map +1 -1
- package/dist/ai/internal/mcpSchema/v2025_06_18.js +5 -9
- package/dist/ai/internal/mcpSchema/v2025_06_18.js.map +1 -1
- package/dist/ai/internal/mcpSchema/v2025_11_25.js +1 -8
- package/dist/ai/internal/mcpSchema/v2025_11_25.js.map +1 -1
- package/dist/ai/internal/mcpSchema/v2026_07_28.js +4 -3
- package/dist/ai/internal/mcpSchema/v2026_07_28.js.map +1 -1
- package/dist/cluster/ClusterCron.d.ts +5 -20
- package/dist/cluster/ClusterCron.d.ts.map +1 -1
- package/dist/cluster/ClusterCron.js +16 -4
- package/dist/cluster/ClusterCron.js.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.js +155 -83
- package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/cluster/MessageStorage.d.ts +56 -0
- package/dist/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/cluster/MessageStorage.js +18 -2
- package/dist/cluster/MessageStorage.js.map +1 -1
- package/dist/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/cluster/SqlMessageStorage.js +48 -23
- package/dist/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/cluster/internal/entityActivation.js +2 -0
- package/dist/cluster/internal/entityActivation.js.map +1 -1
- package/dist/cluster/internal/entityManager.js +8 -5
- package/dist/cluster/internal/entityManager.js.map +1 -1
- package/dist/encoding/Base64.js +5 -1
- package/dist/encoding/Base64.js.map +1 -1
- package/dist/encoding/Base64Url.d.ts.map +1 -1
- package/dist/encoding/Base64Url.js +6 -1
- package/dist/encoding/Base64Url.js.map +1 -1
- package/dist/encoding/Hex.js +7 -5
- package/dist/encoding/Hex.js.map +1 -1
- package/dist/encoding/Xml.d.ts +38 -9
- package/dist/encoding/Xml.d.ts.map +1 -1
- package/dist/encoding/Xml.js +63 -31
- package/dist/encoding/Xml.js.map +1 -1
- package/dist/http/FetchHttpClient.d.ts +2 -1
- package/dist/http/FetchHttpClient.d.ts.map +1 -1
- package/dist/http/FetchHttpClient.js +14 -10
- package/dist/http/FetchHttpClient.js.map +1 -1
- package/dist/http/Headers.d.ts +201 -3
- package/dist/http/Headers.d.ts.map +1 -1
- package/dist/http/Headers.js +205 -3
- package/dist/http/Headers.js.map +1 -1
- package/dist/http/HttpClient.d.ts.map +1 -1
- package/dist/http/HttpClient.js +11 -7
- package/dist/http/HttpClient.js.map +1 -1
- package/dist/http/HttpClientError.d.ts +1 -0
- package/dist/http/HttpClientError.d.ts.map +1 -1
- package/dist/http/HttpClientError.js +32 -9
- package/dist/http/HttpClientError.js.map +1 -1
- package/dist/http/HttpClientRequest.d.ts +46 -0
- package/dist/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/http/HttpClientRequest.js +15 -0
- package/dist/http/HttpClientRequest.js.map +1 -1
- package/dist/http/HttpClientResponse.d.ts +132 -0
- package/dist/http/HttpClientResponse.d.ts.map +1 -1
- package/dist/http/HttpClientResponse.js +83 -0
- package/dist/http/HttpClientResponse.js.map +1 -1
- package/dist/http/HttpEffect.d.ts.map +1 -1
- package/dist/http/HttpEffect.js +31 -2
- package/dist/http/HttpEffect.js.map +1 -1
- package/dist/http/HttpMiddleware.js +1 -1
- package/dist/http/HttpMiddleware.js.map +1 -1
- package/dist/http/HttpServerError.d.ts +1 -1
- package/dist/http/HttpServerError.js +1 -1
- package/dist/http/HttpServerResponse.d.ts +118 -0
- package/dist/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/http/HttpServerResponse.js +43 -0
- package/dist/http/HttpServerResponse.js.map +1 -1
- package/dist/http/Multipart.d.ts.map +1 -1
- package/dist/http/Multipart.js +0 -5
- package/dist/http/Multipart.js.map +1 -1
- package/dist/http/MultipartParser/internal/contentType.d.ts +6 -0
- package/dist/http/MultipartParser/internal/contentType.d.ts.map +1 -1
- package/dist/http/MultipartParser/internal/contentType.js +1 -1
- package/dist/http/MultipartParser/internal/contentType.js.map +1 -1
- package/dist/http/internal/clientPath.d.ts +2 -0
- package/dist/http/internal/clientPath.d.ts.map +1 -0
- package/dist/http/internal/clientPath.js +24 -0
- package/dist/http/internal/clientPath.js.map +1 -0
- package/dist/http/internal/redactedPath.js +2 -0
- package/dist/http/internal/redactedPath.js.map +1 -1
- package/dist/http/internal/tracing.js +5 -3
- package/dist/http/internal/tracing.js.map +1 -1
- package/dist/http-api/HttpApi.d.ts +2 -2
- package/dist/http-api/HttpApi.d.ts.map +1 -1
- package/dist/http-api/HttpApi.js +30 -7
- 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 +5 -2
- package/dist/http-api/HttpApiBuilder.js.map +1 -1
- package/dist/http-api/HttpApiClient.d.ts.map +1 -1
- package/dist/http-api/HttpApiClient.js +23 -6
- package/dist/http-api/HttpApiClient.js.map +1 -1
- package/dist/http-api/internal/redactedKeys.d.ts +2 -0
- package/dist/http-api/internal/redactedKeys.d.ts.map +1 -0
- package/dist/http-api/internal/redactedKeys.js +37 -0
- package/dist/http-api/internal/redactedKeys.js.map +1 -0
- package/dist/internal/base64.js +34 -2
- package/dist/internal/base64.js.map +1 -1
- package/dist/internal/core.js +60 -43
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/dateTime.js +35 -17
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +60 -52
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/equal.js +44 -13
- package/dist/internal/equal.js.map +1 -1
- package/dist/internal/fiberCachedKeys.d.ts +2 -0
- package/dist/internal/fiberCachedKeys.d.ts.map +1 -0
- package/dist/internal/fiberCachedKeys.js +48 -0
- package/dist/internal/fiberCachedKeys.js.map +1 -0
- package/dist/internal/hashMap.js +1 -1
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/matcher.js +17 -17
- package/dist/internal/matcher.js.map +1 -1
- package/dist/internal/predicate.d.ts +2 -0
- package/dist/internal/predicate.d.ts.map +1 -0
- package/dist/internal/predicate.js +10 -0
- package/dist/internal/predicate.js.map +1 -0
- package/dist/internal/references.js +8 -11
- package/dist/internal/references.js.map +1 -1
- package/dist/internal/schema/schemaCodegen.js +3 -2
- package/dist/internal/schema/schemaCodegen.js.map +1 -1
- package/dist/internal/schema/schemaCodegenBuiltIns.d.ts +2 -0
- package/dist/internal/schema/schemaCodegenBuiltIns.d.ts.map +1 -0
- package/dist/internal/schema/schemaCodegenBuiltIns.js +425 -0
- package/dist/internal/schema/schemaCodegenBuiltIns.js.map +1 -0
- package/dist/internal/schema/toEquivalence.js +3 -4
- package/dist/internal/schema/toEquivalence.js.map +1 -1
- package/dist/internal/version.js +1 -1
- package/dist/jose/JoseError.d.ts +51 -1
- package/dist/jose/JoseError.d.ts.map +1 -1
- package/dist/jose/JoseError.js +25 -18
- package/dist/jose/JoseError.js.map +1 -1
- package/dist/jose/internal/compact.js +10 -5
- package/dist/jose/internal/compact.js.map +1 -1
- package/dist/observability/Otlp.d.ts +19 -0
- package/dist/observability/Otlp.d.ts.map +1 -1
- package/dist/observability/Otlp.js +10 -0
- package/dist/observability/Otlp.js.map +1 -1
- package/dist/observability/OtlpExporter.d.ts +49 -13
- package/dist/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/observability/OtlpExporter.js +135 -54
- package/dist/observability/OtlpExporter.js.map +1 -1
- package/dist/observability/OtlpLogger.d.ts +14 -0
- package/dist/observability/OtlpLogger.d.ts.map +1 -1
- package/dist/observability/OtlpLogger.js +10 -2
- package/dist/observability/OtlpLogger.js.map +1 -1
- package/dist/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/observability/OtlpMetrics.js +2 -0
- package/dist/observability/OtlpMetrics.js.map +1 -1
- package/dist/observability/OtlpTracer.d.ts +14 -0
- package/dist/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/observability/OtlpTracer.js +10 -2
- package/dist/observability/OtlpTracer.js.map +1 -1
- package/dist/persistence/KeyValueStore.d.ts.map +1 -1
- package/dist/persistence/KeyValueStore.js +6 -4
- package/dist/persistence/KeyValueStore.js.map +1 -1
- package/dist/reactivity/Atom.d.ts.map +1 -1
- package/dist/reactivity/Atom.js +10 -9
- package/dist/reactivity/Atom.js.map +1 -1
- package/dist/rpc/RpcClient.d.ts.map +1 -1
- package/dist/rpc/RpcClient.js +32 -1
- package/dist/rpc/RpcClient.js.map +1 -1
- package/dist/rpc/RpcGroup.d.ts +1 -1
- package/dist/rpc/RpcGroup.d.ts.map +1 -1
- package/dist/rpc/RpcGroup.js +4 -0
- package/dist/rpc/RpcGroup.js.map +1 -1
- package/dist/sql/Migrator.d.ts.map +1 -1
- package/dist/sql/Migrator.js +2 -5
- package/dist/sql/Migrator.js.map +1 -1
- package/dist/sql/SqlClient.d.ts.map +1 -1
- package/dist/sql/SqlClient.js +5 -1
- package/dist/sql/SqlClient.js.map +1 -1
- package/dist/sql/Statement.d.ts +23 -0
- package/dist/sql/Statement.d.ts.map +1 -1
- package/dist/sql/Statement.js +30 -5
- package/dist/sql/Statement.js.map +1 -1
- package/dist/workers/Worker.d.ts +21 -0
- package/dist/workers/Worker.d.ts.map +1 -1
- package/dist/workers/Worker.js +23 -0
- package/dist/workers/Worker.js.map +1 -1
- package/dist/workflow/Activity.d.ts +18 -0
- package/dist/workflow/Activity.d.ts.map +1 -1
- package/dist/workflow/Activity.js +13 -4
- package/dist/workflow/Activity.js.map +1 -1
- package/dist/workflow/Workflow.d.ts +10 -9
- package/dist/workflow/Workflow.d.ts.map +1 -1
- package/dist/workflow/Workflow.js +33 -22
- package/dist/workflow/Workflow.js.map +1 -1
- package/dist/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/workflow/WorkflowEngine.js +26 -12
- package/dist/workflow/WorkflowEngine.js.map +1 -1
- package/dist/workflow/internal/retry.d.ts +2 -0
- package/dist/workflow/internal/retry.d.ts.map +1 -0
- package/dist/workflow/internal/retry.js +11 -0
- package/dist/workflow/internal/retry.js.map +1 -0
- package/dist/workflow/internal/scope.d.ts +2 -0
- package/dist/workflow/internal/scope.d.ts.map +1 -0
- package/dist/workflow/internal/scope.js +26 -0
- package/dist/workflow/internal/scope.js.map +1 -0
- package/package.json +3 -3
- package/src/Channel.ts +105 -8
- package/src/Codegen.ts +7 -2
- package/src/Config.ts +6 -3
- package/src/Context.ts +108 -50
- package/src/Cron.ts +11 -10
- package/src/Effect.ts +224 -48
- package/src/Equal.ts +93 -80
- package/src/Formatter.ts +4 -4
- package/src/Hash.ts +49 -48
- package/src/LayerRef.ts +6 -4
- package/src/Logger.ts +68 -25
- package/src/Match.ts +78 -50
- package/src/Metric.ts +4 -4
- package/src/Order.ts +1 -1
- package/src/Pool.ts +62 -33
- package/src/Predicate.ts +2 -5
- package/src/Scheduler.ts +27 -10
- package/src/Schema.ts +79 -296
- package/src/SchemaAST.ts +231 -157
- package/src/SchemaParser.ts +40 -57
- package/src/ScopedCache.ts +6 -4
- package/src/Stream.ts +167 -33
- package/src/String.ts +1 -1
- package/src/Tracer.ts +11 -2
- package/src/ai/McpClient.ts +157 -15
- package/src/ai/McpClientError.ts +55 -4
- package/src/ai/McpServer.ts +318 -91
- package/src/ai/Prompt.ts +20 -3
- package/src/ai/Skill.ts +236 -0
- package/src/ai/index.ts +6 -0
- package/src/ai/internal/mcpProtocol/v2024_11_05.ts +8 -13
- package/src/ai/internal/mcpProtocol/v2025_03_26.ts +13 -15
- package/src/ai/internal/mcpProtocol/v2025_06_18.ts +21 -23
- package/src/ai/internal/mcpProtocol/v2025_11_25.ts +22 -24
- package/src/ai/internal/mcpProtocol/v2026_07_28.ts +1 -1
- package/src/ai/internal/mcpProtocol.ts +15 -0
- package/src/ai/internal/mcpRuntime.ts +36 -13
- package/src/ai/internal/mcpSchema/v2024_11_05.ts +2 -1
- package/src/ai/internal/mcpSchema/v2025_03_26.ts +1 -9
- package/src/ai/internal/mcpSchema/v2025_06_18.ts +3 -10
- package/src/ai/internal/mcpSchema/v2025_11_25.ts +1 -9
- package/src/ai/internal/mcpSchema/v2026_07_28.ts +6 -8
- package/src/cluster/ClusterCron.ts +31 -20
- package/src/cluster/ClusterWorkflowEngine.ts +172 -96
- package/src/cluster/MessageStorage.ts +51 -2
- package/src/cluster/SqlMessageStorage.ts +88 -36
- package/src/cluster/internal/entityActivation.ts +6 -0
- package/src/cluster/internal/entityManager.ts +8 -4
- package/src/encoding/Base64.ts +5 -1
- package/src/encoding/Base64Url.ts +6 -1
- package/src/encoding/Hex.ts +5 -5
- package/src/encoding/Xml.ts +96 -26
- package/src/http/FetchHttpClient.ts +8 -5
- package/src/http/Headers.ts +309 -3
- package/src/http/HttpClient.ts +19 -7
- package/src/http/HttpClientError.ts +42 -9
- package/src/http/HttpClientRequest.ts +51 -0
- package/src/http/HttpClientResponse.ts +156 -0
- package/src/http/HttpEffect.ts +23 -3
- package/src/http/HttpMiddleware.ts +1 -1
- package/src/http/HttpServerError.ts +1 -1
- package/src/http/HttpServerResponse.ts +126 -0
- package/src/http/Multipart.ts +0 -5
- package/src/http/MultipartParser/internal/contentType.ts +1 -1
- package/src/http/internal/clientPath.ts +39 -0
- package/src/http/internal/redactedPath.ts +4 -0
- package/src/http/internal/tracing.ts +6 -3
- package/src/http-api/HttpApi.ts +29 -8
- package/src/http-api/HttpApiBuilder.ts +7 -2
- package/src/http-api/HttpApiClient.ts +30 -7
- package/src/http-api/internal/redactedKeys.ts +40 -0
- package/src/internal/base64.ts +57 -2
- package/src/internal/core.ts +80 -44
- package/src/internal/dateTime.ts +43 -24
- package/src/internal/effect.ts +115 -157
- package/src/internal/equal.ts +73 -17
- package/src/internal/fiberCachedKeys.ts +81 -0
- package/src/internal/hashMap.ts +1 -1
- package/src/internal/matcher.ts +34 -113
- package/src/internal/predicate.ts +10 -0
- package/src/internal/references.ts +21 -14
- package/src/internal/schema/schemaCodegen.ts +5 -4
- package/src/internal/schema/schemaCodegenBuiltIns.ts +343 -0
- package/src/internal/schema/toEquivalence.ts +3 -5
- package/src/internal/version.ts +1 -1
- package/src/jose/JoseError.ts +34 -0
- package/src/jose/internal/compact.ts +14 -5
- package/src/observability/Otlp.ts +29 -0
- package/src/observability/OtlpExporter.ts +206 -75
- package/src/observability/OtlpLogger.ts +24 -2
- package/src/observability/OtlpMetrics.ts +2 -0
- package/src/observability/OtlpTracer.ts +24 -3
- package/src/persistence/KeyValueStore.ts +17 -14
- package/src/reactivity/Atom.ts +12 -18
- package/src/rpc/RpcClient.ts +26 -1
- package/src/rpc/RpcGroup.ts +4 -1
- package/src/sql/Migrator.ts +2 -11
- package/src/sql/SqlClient.ts +14 -8
- package/src/sql/Statement.ts +48 -12
- package/src/workers/Worker.ts +25 -0
- package/src/workflow/Activity.ts +28 -4
- package/src/workflow/Workflow.ts +68 -44
- package/src/workflow/WorkflowEngine.ts +38 -15
- package/src/workflow/internal/retry.ts +12 -0
- package/src/workflow/internal/scope.ts +36 -0
- package/dist/internal/hash.d.ts +0 -2
- package/dist/internal/hash.d.ts.map +0 -1
- package/dist/internal/hash.js +0 -11
- package/dist/internal/hash.js.map +0 -1
- package/dist/internal/metric.d.ts +0 -2
- package/dist/internal/metric.d.ts.map +0 -1
- package/dist/internal/metric.js +0 -3
- package/dist/internal/metric.js.map +0 -1
- package/src/internal/hash.ts +0 -11
- package/src/internal/metric.ts +0 -2
package/src/SchemaParser.ts
CHANGED
|
@@ -44,15 +44,13 @@ import * as SchemaIssue from "./SchemaIssue.ts"
|
|
|
44
44
|
*/
|
|
45
45
|
export function makeEffect<S extends Schema.Constraint>(schema: S) {
|
|
46
46
|
const ast = schema.ast
|
|
47
|
-
let
|
|
48
|
-
return (input: S["~type.make.in"], options?: Schema.MakeOptions): Effect.Effect<S["Type"], SchemaIssue.Issue> =>
|
|
49
|
-
|
|
47
|
+
let entry: CompilerRegistry.Entry | undefined
|
|
48
|
+
return (input: S["~type.make.in"], options?: Schema.MakeOptions): Effect.Effect<S["Type"], SchemaIssue.Issue> =>
|
|
49
|
+
constructEffect<S["Type"]>(
|
|
50
|
+
entry ??= CompilerRegistry.resolve(SchemaAST.toType(ast)),
|
|
50
51
|
input,
|
|
51
|
-
options
|
|
52
|
-
? options?.parseOptions ? { ...options.parseOptions, disableChecks: true } : { disableChecks: true }
|
|
53
|
-
: options?.parseOptions
|
|
52
|
+
constructorParseOptions(options)
|
|
54
53
|
)
|
|
55
|
-
}
|
|
56
54
|
}
|
|
57
55
|
|
|
58
56
|
/**
|
|
@@ -76,14 +74,8 @@ export function makeEffect<S extends Schema.Constraint>(schema: S) {
|
|
|
76
74
|
*/
|
|
77
75
|
export function makeOption<S extends Schema.Constraint>(schema: S) {
|
|
78
76
|
const parser = makeEffect(schema)
|
|
79
|
-
return (input: S["~type.make.in"], options?: Schema.MakeOptions): Option.Option<S["Type"]> =>
|
|
80
|
-
|
|
81
|
-
if (Exit.isSuccess(exit)) {
|
|
82
|
-
return Option.some(exit.value)
|
|
83
|
-
}
|
|
84
|
-
InternalSchemaCause.getSchemaIssueOrThrow(exit.cause, "Option adapter can only return none for schema issues")
|
|
85
|
-
return Option.none()
|
|
86
|
-
}
|
|
77
|
+
return (input: S["~type.make.in"], options?: Schema.MakeOptions): Option.Option<S["Type"]> =>
|
|
78
|
+
exitToOption(Effect.runSyncExit(parser(input, options)))
|
|
87
79
|
}
|
|
88
80
|
|
|
89
81
|
/**
|
|
@@ -275,9 +267,7 @@ export function decodeUnknownEffect<S extends Schema.Constraint>(
|
|
|
275
267
|
options?: SchemaAST.ParseOptions
|
|
276
268
|
) => Effect.Effect<S["Type"], SchemaIssue.Issue, S["DecodingServices"]> {
|
|
277
269
|
const parser = run<S["Type"], S["DecodingServices"]>(schema.ast)
|
|
278
|
-
return options
|
|
279
|
-
? parser
|
|
280
|
-
: (input, overrideOptions) => parser(input, mergeParseOptions(options, overrideOptions))
|
|
270
|
+
return withParseOptions(parser, options)
|
|
281
271
|
}
|
|
282
272
|
|
|
283
273
|
/**
|
|
@@ -638,9 +628,7 @@ export function encodeUnknownEffect<S extends Schema.Constraint>(
|
|
|
638
628
|
options?: SchemaAST.ParseOptions
|
|
639
629
|
) => Effect.Effect<S["Encoded"], SchemaIssue.Issue, S["EncodingServices"]> {
|
|
640
630
|
const parser = run<S["Encoded"], S["EncodingServices"]>(SchemaAST.flip(schema.ast))
|
|
641
|
-
return options
|
|
642
|
-
? parser
|
|
643
|
-
: (input, overrideOptions) => parser(input, mergeParseOptions(options, overrideOptions))
|
|
631
|
+
return withParseOptions(parser, options)
|
|
644
632
|
}
|
|
645
633
|
|
|
646
634
|
/**
|
|
@@ -965,10 +953,15 @@ export const encodeSync: <S extends Schema.ConstraintEncoder<unknown>>(
|
|
|
965
953
|
options?: SchemaAST.ParseOptions
|
|
966
954
|
) => (input: S["Type"], options?: SchemaAST.ParseOptions) => S["Encoded"] = encodeUnknownSync
|
|
967
955
|
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
)
|
|
956
|
+
function withParseOptions<T>(
|
|
957
|
+
parse: (input: unknown, options?: SchemaAST.ParseOptions) => T,
|
|
958
|
+
options?: SchemaAST.ParseOptions
|
|
959
|
+
) {
|
|
960
|
+
return options === undefined ?
|
|
961
|
+
parse :
|
|
962
|
+
(input: unknown, overrides?: SchemaAST.ParseOptions) =>
|
|
963
|
+
parse(input, overrides ? { ...options, ...overrides } : options)
|
|
964
|
+
}
|
|
972
965
|
|
|
973
966
|
const getValue = (value: unknown): Effect.Effect<any, SchemaIssue.Issue> => {
|
|
974
967
|
if (value === InternalParser.missing) {
|
|
@@ -1001,20 +994,7 @@ function parserResult<T, R>(
|
|
|
1001
994
|
function runWithCompiler<T, R>(compiler: Compiler, ast: SchemaAST.AST) {
|
|
1002
995
|
let parser: Parser
|
|
1003
996
|
return (input: unknown, options?: SchemaAST.ParseOptions): Effect.Effect<T, SchemaIssue.Issue, R> => {
|
|
1004
|
-
|
|
1005
|
-
input,
|
|
1006
|
-
options ?? SchemaAST.defaultParseOptions
|
|
1007
|
-
)
|
|
1008
|
-
if (InternalParser.isSameExit(result)) {
|
|
1009
|
-
return Effect.succeed(input) as Effect.Effect<T, SchemaIssue.Issue, R>
|
|
1010
|
-
}
|
|
1011
|
-
if (!effectIsExit(result)) {
|
|
1012
|
-
return Effect.flatMapEager(result, getValue)
|
|
1013
|
-
}
|
|
1014
|
-
return (result as InternalParser.Success<unknown, SchemaIssue.Issue>)[InternalParser.args] ===
|
|
1015
|
-
InternalParser.missing
|
|
1016
|
-
? getValue(InternalParser.missing)
|
|
1017
|
-
: result as Effect.Effect<T, SchemaIssue.Issue, R>
|
|
997
|
+
return parserResult<T, R>((parser ??= compiler(ast))(input, options ?? SchemaAST.defaultParseOptions), input)
|
|
1018
998
|
}
|
|
1019
999
|
}
|
|
1020
1000
|
|
|
@@ -1055,6 +1035,12 @@ export function asOption<T, E, R>(
|
|
|
1055
1035
|
}
|
|
1056
1036
|
}
|
|
1057
1037
|
|
|
1038
|
+
function exitToOption<T>(exit: Exit.Exit<T, SchemaIssue.Issue>): Option.Option<T> {
|
|
1039
|
+
if (Exit.isSuccess(exit)) return Option.some(exit.value)
|
|
1040
|
+
InternalSchemaCause.getSchemaIssueOrThrow(exit.cause, "Option adapter can only return none for schema issues")
|
|
1041
|
+
return Option.none()
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1058
1044
|
function asResult<T, E, R>(
|
|
1059
1045
|
parser: (input: E, options?: SchemaAST.ParseOptions) => Effect.Effect<T, SchemaIssue.Issue, R>
|
|
1060
1046
|
): (input: E, options?: SchemaAST.ParseOptions) => Result.Result<T, SchemaIssue.Issue> {
|
|
@@ -1102,9 +1088,7 @@ function makeSyncEntry<T>(
|
|
|
1102
1088
|
if (output !== CompilerRegistry.invalid) return output as T
|
|
1103
1089
|
return (detailed ??= makeDetailedSync<T>(entry))(input, parseOptions)
|
|
1104
1090
|
}
|
|
1105
|
-
return options
|
|
1106
|
-
? run
|
|
1107
|
-
: (input, overrideOptions) => run(input, mergeParseOptions(options, overrideOptions))
|
|
1091
|
+
return withParseOptions(run, options)
|
|
1108
1092
|
}
|
|
1109
1093
|
|
|
1110
1094
|
function makeDetailedSync<T>(
|
|
@@ -1116,15 +1100,7 @@ function makeDetailedSync<T>(
|
|
|
1116
1100
|
function asSync<T, E>(
|
|
1117
1101
|
parser: (input: E, options?: SchemaAST.ParseOptions) => Effect.Effect<T, SchemaIssue.Issue>
|
|
1118
1102
|
): (input: E, options?: SchemaAST.ParseOptions) => T {
|
|
1119
|
-
|
|
1120
|
-
return (input: E, options?: SchemaAST.ParseOptions) => {
|
|
1121
|
-
const exit = parserExit(input, options)
|
|
1122
|
-
if (Exit.isSuccess(exit)) {
|
|
1123
|
-
return exit.value
|
|
1124
|
-
}
|
|
1125
|
-
const issue = InternalSchemaCause.getSchemaIssueOrThrow(exit.cause, "Sync adapter can only throw schema issues")
|
|
1126
|
-
throw new Error("Schema validation failed", { cause: issue })
|
|
1127
|
-
}
|
|
1103
|
+
return (input, options) => runSync(parser(input, options), "Sync adapter can only throw schema issues")
|
|
1128
1104
|
}
|
|
1129
1105
|
|
|
1130
1106
|
function runSync<T>(effect: Effect.Effect<T, SchemaIssue.Issue>, message: string): T {
|
|
@@ -1149,11 +1125,19 @@ function makeConstructorSync<T, E>(
|
|
|
1149
1125
|
return (input, options) => constructSync(entry ??= CompilerRegistry.resolve(ast), input, options)
|
|
1150
1126
|
}
|
|
1151
1127
|
|
|
1152
|
-
function
|
|
1153
|
-
|
|
1154
|
-
?
|
|
1128
|
+
function constructorParseOptions(options: Schema.MakeOptions | undefined): SchemaAST.ParseOptions {
|
|
1129
|
+
return options?.disableChecks
|
|
1130
|
+
? { ...options.parseOptions, disableChecks: true }
|
|
1155
1131
|
: options?.parseOptions ?? SchemaAST.defaultParseOptions
|
|
1156
|
-
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
function constructEffect<T>(entry: CompilerRegistry.Entry, input: unknown, options: SchemaAST.ParseOptions) {
|
|
1135
|
+
return parserResult<T, never>(entry.makeEffect(input, options), input)
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
function constructSync<T>(entry: CompilerRegistry.Entry, input: unknown, options: Schema.MakeOptions | undefined): T {
|
|
1139
|
+
const parseOptions = constructorParseOptions(options)
|
|
1140
|
+
const make = CompilerRegistry.compilerAdaptersEnabled ? entry.make : undefined
|
|
1157
1141
|
if (make !== undefined && input !== InternalParser.missing) {
|
|
1158
1142
|
let output: unknown
|
|
1159
1143
|
try {
|
|
@@ -1163,7 +1147,7 @@ function constructSync<T>(entry: CompilerRegistry.Entry, input: unknown, options
|
|
|
1163
1147
|
}
|
|
1164
1148
|
if (output !== CompilerRegistry.invalid && output !== InternalParser.missing) return output as T
|
|
1165
1149
|
}
|
|
1166
|
-
return runSync(
|
|
1150
|
+
return runSync(constructEffect<T>(entry, input, parseOptions), constructorDefectMessage)
|
|
1167
1151
|
}
|
|
1168
1152
|
|
|
1169
1153
|
/**
|
|
@@ -1209,4 +1193,3 @@ export interface Compiler {
|
|
|
1209
1193
|
}
|
|
1210
1194
|
|
|
1211
1195
|
const normalCompiler: Compiler = (ast) => CompilerRegistry.resolve(ast).parser
|
|
1212
|
-
const constructorCompiler: Compiler = (ast) => CompilerRegistry.resolve(ast).makeEffect
|
package/src/ScopedCache.ts
CHANGED
|
@@ -339,11 +339,13 @@ export const get: {
|
|
|
339
339
|
return effect.interrupt
|
|
340
340
|
}
|
|
341
341
|
const oentry = MutableHashMap.get(state.map, key)
|
|
342
|
-
if (Option.isSome(oentry)
|
|
343
|
-
// Move the entry to the end of the map to keep it fresh
|
|
342
|
+
if (Option.isSome(oentry)) {
|
|
344
343
|
MutableHashMap.remove(state.map, key)
|
|
345
|
-
|
|
346
|
-
|
|
344
|
+
if (!hasExpired(oentry.value, fiber)) {
|
|
345
|
+
// Move the entry to the end of the map to keep it fresh
|
|
346
|
+
MutableHashMap.set(state.map, key, oentry.value)
|
|
347
|
+
return awaitEntry(self, key, oentry.value, restore)
|
|
348
|
+
}
|
|
347
349
|
}
|
|
348
350
|
const clock = fiber.getRef(effect.ClockRef)
|
|
349
351
|
const scope = Scope.makeUnsafe()
|
package/src/Stream.ts
CHANGED
|
@@ -8,6 +8,26 @@
|
|
|
8
8
|
* stream lifecycle: create a stream, transform or combine it, control buffering
|
|
9
9
|
* and timing, handle failures, and finally consume it.
|
|
10
10
|
*
|
|
11
|
+
* Every stream runs in a scope supplied by its consumer, called the stream's
|
|
12
|
+
* scope. The run functions create that scope and close it before they return,
|
|
13
|
+
* however the stream ends: completion, failure, defect, an early stop by a
|
|
14
|
+
* downstream operator such as `take`, or interruption. `toPull` uses the scope
|
|
15
|
+
* it is given and leaves closing it to its owner. Operators that run inner
|
|
16
|
+
* streams, such as `flatMap` and `concat`, may give each inner stream a child
|
|
17
|
+
* scope that closes sooner.
|
|
18
|
+
*
|
|
19
|
+
* `ensuring`, `onExit`, and `scoped` finalize when their stream ends on its own
|
|
20
|
+
* (completion, failure, or defect), before downstream observes that end.
|
|
21
|
+
* `callback` and `unwrap` register finalizers in the stream's scope, so they
|
|
22
|
+
* run when that scope closes. A stream that is abandoned because a downstream
|
|
23
|
+
* operator such as `take` stopped pulling from it is finalized no later than
|
|
24
|
+
* when its scope closes. Under `toPull`, that can be after the pull has
|
|
25
|
+
* returned its final result, so close the scope to release what the stream
|
|
26
|
+
* still holds. `toQueue` and `toPubSub` use the given scope for the queue or
|
|
27
|
+
* pubsub and for the fiber that feeds it. That fiber runs the stream like a run
|
|
28
|
+
* function, so the stream's resources are released when it ends, without
|
|
29
|
+
* waiting for the scope to close.
|
|
30
|
+
*
|
|
11
31
|
* @stability stable
|
|
12
32
|
* @since 2.0.0
|
|
13
33
|
*/
|
|
@@ -695,9 +715,15 @@ export const toChannel = <A, E, R>(
|
|
|
695
715
|
* Use when you need callback-based code to emit stream values by offering to a
|
|
696
716
|
* `Queue`, or signal stream completion through the `Queue` module APIs.
|
|
697
717
|
*
|
|
698
|
-
*
|
|
699
|
-
*
|
|
700
|
-
*
|
|
718
|
+
* **Details**
|
|
719
|
+
*
|
|
720
|
+
* The callback effect runs in the stream's scope. Finalizers it registers, for
|
|
721
|
+
* example with `Effect.acquireRelease`, run when that scope closes, not when
|
|
722
|
+
* the queue ends.
|
|
723
|
+
*
|
|
724
|
+
* By default it uses an "unbounded" buffer size. You can customize the buffer
|
|
725
|
+
* size and strategy by passing an object as the second argument with the
|
|
726
|
+
* `bufferSize` and `strategy` fields.
|
|
701
727
|
*
|
|
702
728
|
* **Example** (Creating a stream from a callback that can emit values into a queue)
|
|
703
729
|
*
|
|
@@ -718,6 +744,29 @@ export const toChannel = <A, E, R>(
|
|
|
718
744
|
* await Effect.runPromise(Stream.runCollect(stream)) // => [1, 2, 3]
|
|
719
745
|
* ```
|
|
720
746
|
*
|
|
747
|
+
* **Example** (Unregistering a listener when the stream scope closes)
|
|
748
|
+
*
|
|
749
|
+
* ```ts import.meta.vitest
|
|
750
|
+
* import { Effect, Queue, Stream } from "effect"
|
|
751
|
+
*
|
|
752
|
+
* const listeners = new Set<(value: number) => void>()
|
|
753
|
+
*
|
|
754
|
+
* const stream = Stream.callback<number>(Effect.fnUntraced(function*(queue) {
|
|
755
|
+
* const listener = (value: number) => {
|
|
756
|
+
* Queue.offerUnsafe(queue, value)
|
|
757
|
+
* }
|
|
758
|
+
* yield* Effect.acquireRelease(
|
|
759
|
+
* Effect.sync(() => listeners.add(listener)),
|
|
760
|
+
* () => Effect.sync(() => listeners.delete(listener))
|
|
761
|
+
* )
|
|
762
|
+
* listeners.forEach((notify) => notify(1))
|
|
763
|
+
* }))
|
|
764
|
+
*
|
|
765
|
+
* const values = await Effect.runPromise(Stream.runCollect(stream.pipe(Stream.take(1))))
|
|
766
|
+
* values // => [1]
|
|
767
|
+
* listeners.size // => 0
|
|
768
|
+
* ```
|
|
769
|
+
*
|
|
721
770
|
* @stability stable
|
|
722
771
|
* @category constructors
|
|
723
772
|
* @since 4.0.0
|
|
@@ -1692,6 +1741,11 @@ export const never: Stream<never> = fromChannel(Channel.never)
|
|
|
1692
1741
|
/**
|
|
1693
1742
|
* Creates a stream produced from an `Effect`.
|
|
1694
1743
|
*
|
|
1744
|
+
* **Details**
|
|
1745
|
+
*
|
|
1746
|
+
* The effect runs in the stream's scope, so finalizers it registers run when
|
|
1747
|
+
* that scope closes.
|
|
1748
|
+
*
|
|
1695
1749
|
* **Example** (Unwrapping a stream effect)
|
|
1696
1750
|
*
|
|
1697
1751
|
* ```ts import.meta.vitest
|
|
@@ -1720,6 +1774,14 @@ export const unwrap = <A, E2, R2, E, R>(
|
|
|
1720
1774
|
* Runs a stream that requires `Scope` in a managed scope, ensuring its
|
|
1721
1775
|
* finalizers are run when the stream completes.
|
|
1722
1776
|
*
|
|
1777
|
+
* **Details**
|
|
1778
|
+
*
|
|
1779
|
+
* The provided scope closes when the stream ends on its own (completion,
|
|
1780
|
+
* failure, or defect), before downstream observes that end. If a downstream
|
|
1781
|
+
* operator stops pulling first, it closes no later than when the stream's scope
|
|
1782
|
+
* closes. It satisfies the `Scope` service requirement only; constructors that
|
|
1783
|
+
* register finalizers in the stream's scope, such as `callback`, keep using it.
|
|
1784
|
+
*
|
|
1723
1785
|
* **Example** (Scoping a stream)
|
|
1724
1786
|
*
|
|
1725
1787
|
* ```ts import.meta.vitest
|
|
@@ -17677,6 +17739,12 @@ export const haltWhen: {
|
|
|
17677
17739
|
/**
|
|
17678
17740
|
* Runs the provided finalizer when the stream exits, passing the exit value.
|
|
17679
17741
|
*
|
|
17742
|
+
* **Details**
|
|
17743
|
+
*
|
|
17744
|
+
* The finalizer runs when the stream ends on its own (completion, failure, or
|
|
17745
|
+
* defect), before downstream observes that end. If a downstream operator stops
|
|
17746
|
+
* pulling first, it runs no later than when the stream's scope closes.
|
|
17747
|
+
*
|
|
17680
17748
|
* **Example** (Running a finalizer on exit)
|
|
17681
17749
|
*
|
|
17682
17750
|
* ```ts import.meta.vitest
|
|
@@ -17705,6 +17773,12 @@ export const onExit: {
|
|
|
17705
17773
|
/**
|
|
17706
17774
|
* Runs the provided finalizer when the stream exits, passing the exit value.
|
|
17707
17775
|
*
|
|
17776
|
+
* **Details**
|
|
17777
|
+
*
|
|
17778
|
+
* The finalizer runs when the stream ends on its own (completion, failure, or
|
|
17779
|
+
* defect), before downstream observes that end. If a downstream operator stops
|
|
17780
|
+
* pulling first, it runs no later than when the stream's scope closes.
|
|
17781
|
+
*
|
|
17708
17782
|
* **Example** (Running a finalizer on exit)
|
|
17709
17783
|
*
|
|
17710
17784
|
* ```ts import.meta.vitest
|
|
@@ -17735,6 +17809,12 @@ export const onExit: {
|
|
|
17735
17809
|
/**
|
|
17736
17810
|
* Runs the provided finalizer when the stream exits, passing the exit value.
|
|
17737
17811
|
*
|
|
17812
|
+
* **Details**
|
|
17813
|
+
*
|
|
17814
|
+
* The finalizer runs when the stream ends on its own (completion, failure, or
|
|
17815
|
+
* defect), before downstream observes that end. If a downstream operator stops
|
|
17816
|
+
* pulling first, it runs no later than when the stream's scope closes.
|
|
17817
|
+
*
|
|
17738
17818
|
* **Example** (Running a finalizer on exit)
|
|
17739
17819
|
*
|
|
17740
17820
|
* ```ts import.meta.vitest
|
|
@@ -18121,6 +18201,12 @@ export const onEnd: {
|
|
|
18121
18201
|
/**
|
|
18122
18202
|
* Executes the provided finalizer after this stream's finalizers run.
|
|
18123
18203
|
*
|
|
18204
|
+
* **Details**
|
|
18205
|
+
*
|
|
18206
|
+
* The finalizer runs when the stream ends on its own (completion, failure, or
|
|
18207
|
+
* defect), before downstream observes that end. If a downstream operator stops
|
|
18208
|
+
* pulling first, it runs no later than when the stream's scope closes.
|
|
18209
|
+
*
|
|
18124
18210
|
* **Example** (Ensuring finalization)
|
|
18125
18211
|
*
|
|
18126
18212
|
* ```ts import.meta.vitest
|
|
@@ -18148,6 +18234,12 @@ export const ensuring: {
|
|
|
18148
18234
|
/**
|
|
18149
18235
|
* Executes the provided finalizer after this stream's finalizers run.
|
|
18150
18236
|
*
|
|
18237
|
+
* **Details**
|
|
18238
|
+
*
|
|
18239
|
+
* The finalizer runs when the stream ends on its own (completion, failure, or
|
|
18240
|
+
* defect), before downstream observes that end. If a downstream operator stops
|
|
18241
|
+
* pulling first, it runs no later than when the stream's scope closes.
|
|
18242
|
+
*
|
|
18151
18243
|
* **Example** (Ensuring finalization)
|
|
18152
18244
|
*
|
|
18153
18245
|
* ```ts import.meta.vitest
|
|
@@ -18175,6 +18267,12 @@ export const ensuring: {
|
|
|
18175
18267
|
/**
|
|
18176
18268
|
* Executes the provided finalizer after this stream's finalizers run.
|
|
18177
18269
|
*
|
|
18270
|
+
* **Details**
|
|
18271
|
+
*
|
|
18272
|
+
* The finalizer runs when the stream ends on its own (completion, failure, or
|
|
18273
|
+
* defect), before downstream observes that end. If a downstream operator stops
|
|
18274
|
+
* pulling first, it runs no later than when the stream's scope closes.
|
|
18275
|
+
*
|
|
18178
18276
|
* **Example** (Ensuring finalization)
|
|
18179
18277
|
*
|
|
18180
18278
|
* ```ts import.meta.vitest
|
|
@@ -20062,8 +20160,9 @@ export const runDrain = <A, E, R>(self: Stream<A, E, R>): Effect.Effect<void, E,
|
|
|
20062
20160
|
*
|
|
20063
20161
|
* **Details**
|
|
20064
20162
|
*
|
|
20065
|
-
* The
|
|
20066
|
-
*
|
|
20163
|
+
* The stream runs in the provided scope, which the pull leaves open; close it
|
|
20164
|
+
* to release any resources the stream still holds. The pull fails with
|
|
20165
|
+
* `Cause.Done` when the stream ends and with the stream error on failure.
|
|
20067
20166
|
*
|
|
20068
20167
|
* **Example** (Creating a scoped pull)
|
|
20069
20168
|
*
|
|
@@ -20621,11 +20720,13 @@ export const toAsyncIterableWith: {
|
|
|
20621
20720
|
): AsyncIterable<A> => ({
|
|
20622
20721
|
[Symbol.asyncIterator]() {
|
|
20623
20722
|
const runPromise = Effect.runPromiseWith(context)
|
|
20624
|
-
const
|
|
20723
|
+
const runPromiseExit = Effect.runPromiseExitWith(context)
|
|
20625
20724
|
const scope = Scope.makeUnsafe()
|
|
20626
20725
|
let pull: Pull.Pull<Arr.NonEmptyReadonlyArray<A>, E, void, R> | undefined
|
|
20627
20726
|
let currentIter: Iterator<A> | undefined
|
|
20628
|
-
let currentFiber: Fiber.Fiber<
|
|
20727
|
+
let currentFiber: Fiber.Fiber<unknown, unknown> | undefined
|
|
20728
|
+
let reading = false
|
|
20729
|
+
const queuedReads: Array<() => void> = []
|
|
20629
20730
|
let closePromise: Promise<IteratorResult<A>> | undefined
|
|
20630
20731
|
const close = (exit: Exit.Exit<unknown, unknown>): Promise<IteratorResult<A>> => {
|
|
20631
20732
|
if (closePromise) return closePromise
|
|
@@ -20646,37 +20747,46 @@ export const toAsyncIterableWith: {
|
|
|
20646
20747
|
await runPromise(Effect.logError("Suppressed error while closing Stream async iterator", error))
|
|
20647
20748
|
}
|
|
20648
20749
|
}
|
|
20750
|
+
// Register the fiber before pulling so a reentrant close can interrupt it.
|
|
20751
|
+
const pullChunk = Effect.withFiber((fiber) => {
|
|
20752
|
+
currentFiber = fiber
|
|
20753
|
+
return pull ??
|
|
20754
|
+
Effect.flatMap(Channel.toPullScoped(self.channel, scope), (nextPull) => {
|
|
20755
|
+
pull = nextPull
|
|
20756
|
+
return nextPull
|
|
20757
|
+
})
|
|
20758
|
+
})
|
|
20649
20759
|
return {
|
|
20650
20760
|
async next(): Promise<IteratorResult<A>> {
|
|
20651
|
-
if (
|
|
20652
|
-
|
|
20653
|
-
const next = currentIter.next()
|
|
20654
|
-
if (!next.done) return next
|
|
20655
|
-
currentIter = undefined
|
|
20761
|
+
if (reading) {
|
|
20762
|
+
await new Promise<void>((resolve) => queuedReads.push(resolve))
|
|
20656
20763
|
}
|
|
20657
|
-
|
|
20658
|
-
|
|
20659
|
-
|
|
20660
|
-
|
|
20661
|
-
|
|
20662
|
-
|
|
20663
|
-
|
|
20664
|
-
|
|
20665
|
-
|
|
20666
|
-
if (currentFiber === fiber) {
|
|
20764
|
+
reading = true
|
|
20765
|
+
try {
|
|
20766
|
+
if (closePromise) return closePromise
|
|
20767
|
+
if (currentIter) {
|
|
20768
|
+
const next = currentIter.next()
|
|
20769
|
+
if (!next.done) return next
|
|
20770
|
+
currentIter = undefined
|
|
20771
|
+
}
|
|
20772
|
+
const exit = await runPromiseExit(pullChunk)
|
|
20667
20773
|
currentFiber = undefined
|
|
20774
|
+
if (Exit.isSuccess(exit)) {
|
|
20775
|
+
currentIter = exit.value[Symbol.iterator]()
|
|
20776
|
+
return currentIter.next()
|
|
20777
|
+
} else if (Pull.isDoneCause(exit.cause)) {
|
|
20778
|
+
return close(Exit.void)
|
|
20779
|
+
}
|
|
20780
|
+
if (closePromise && Cause.hasInterruptsOnly(exit.cause)) {
|
|
20781
|
+
return closePromise
|
|
20782
|
+
}
|
|
20783
|
+
await closeAndReportError(exit)
|
|
20784
|
+
throw Cause.squash(exit.cause)
|
|
20785
|
+
} finally {
|
|
20786
|
+
const resume = queuedReads.shift()
|
|
20787
|
+
if (resume) resume()
|
|
20788
|
+
else reading = false
|
|
20668
20789
|
}
|
|
20669
|
-
if (Exit.isSuccess(exit)) {
|
|
20670
|
-
currentIter = exit.value[Symbol.iterator]()
|
|
20671
|
-
return currentIter.next()
|
|
20672
|
-
} else if (Pull.isDoneCause(exit.cause)) {
|
|
20673
|
-
return close(Exit.void)
|
|
20674
|
-
}
|
|
20675
|
-
if (closePromise && Cause.hasInterruptsOnly(exit.cause)) {
|
|
20676
|
-
return closePromise
|
|
20677
|
-
}
|
|
20678
|
-
await closeAndReportError(exit)
|
|
20679
|
-
throw Cause.squash(exit.cause)
|
|
20680
20790
|
},
|
|
20681
20791
|
return() {
|
|
20682
20792
|
return close(Exit.void)
|
|
@@ -20869,6 +20979,10 @@ export const runIntoPubSub: {
|
|
|
20869
20979
|
*
|
|
20870
20980
|
* **Details**
|
|
20871
20981
|
*
|
|
20982
|
+
* The surrounding scope owns the PubSub and the fiber that feeds it. The stream
|
|
20983
|
+
* runs like a run function inside that fiber, so its finalizers run when it
|
|
20984
|
+
* ends, or when the fiber is interrupted by the scope closing.
|
|
20985
|
+
*
|
|
20872
20986
|
* `shutdownOnEnd` indicates whether the PubSub should be shut down when the
|
|
20873
20987
|
* stream ends. By default this is `true`.
|
|
20874
20988
|
*
|
|
@@ -20899,6 +21013,10 @@ export const toPubSub: {
|
|
|
20899
21013
|
*
|
|
20900
21014
|
* **Details**
|
|
20901
21015
|
*
|
|
21016
|
+
* The surrounding scope owns the PubSub and the fiber that feeds it. The stream
|
|
21017
|
+
* runs like a run function inside that fiber, so its finalizers run when it
|
|
21018
|
+
* ends, or when the fiber is interrupted by the scope closing.
|
|
21019
|
+
*
|
|
20902
21020
|
* `shutdownOnEnd` indicates whether the PubSub should be shut down when the
|
|
20903
21021
|
* stream ends. By default this is `true`.
|
|
20904
21022
|
*
|
|
@@ -20940,6 +21058,10 @@ export const toPubSub: {
|
|
|
20940
21058
|
*
|
|
20941
21059
|
* **Details**
|
|
20942
21060
|
*
|
|
21061
|
+
* The surrounding scope owns the PubSub and the fiber that feeds it. The stream
|
|
21062
|
+
* runs like a run function inside that fiber, so its finalizers run when it
|
|
21063
|
+
* ends, or when the fiber is interrupted by the scope closing.
|
|
21064
|
+
*
|
|
20943
21065
|
* `shutdownOnEnd` indicates whether the PubSub should be shut down when the
|
|
20944
21066
|
* stream ends. By default this is `true`.
|
|
20945
21067
|
*
|
|
@@ -21134,6 +21256,10 @@ export const toPubSubTake: {
|
|
|
21134
21256
|
*
|
|
21135
21257
|
* **Details**
|
|
21136
21258
|
*
|
|
21259
|
+
* The surrounding scope owns the queue and the fiber that feeds it. The stream
|
|
21260
|
+
* runs like a run function inside that fiber, so its finalizers run when it
|
|
21261
|
+
* ends, or when the fiber is interrupted by the scope closing.
|
|
21262
|
+
*
|
|
21137
21263
|
* Elements are offered to the queue as the stream runs. Stream completion is
|
|
21138
21264
|
* signaled with `Cause.Done`, stream failures fail the queue, and the queue is
|
|
21139
21265
|
* shut down when the surrounding scope closes.
|
|
@@ -21162,6 +21288,10 @@ export const toQueue: {
|
|
|
21162
21288
|
*
|
|
21163
21289
|
* **Details**
|
|
21164
21290
|
*
|
|
21291
|
+
* The surrounding scope owns the queue and the fiber that feeds it. The stream
|
|
21292
|
+
* runs like a run function inside that fiber, so its finalizers run when it
|
|
21293
|
+
* ends, or when the fiber is interrupted by the scope closing.
|
|
21294
|
+
*
|
|
21165
21295
|
* Elements are offered to the queue as the stream runs. Stream completion is
|
|
21166
21296
|
* signaled with `Cause.Done`, stream failures fail the queue, and the queue is
|
|
21167
21297
|
* shut down when the surrounding scope closes.
|
|
@@ -21197,6 +21327,10 @@ export const toQueue: {
|
|
|
21197
21327
|
*
|
|
21198
21328
|
* **Details**
|
|
21199
21329
|
*
|
|
21330
|
+
* The surrounding scope owns the queue and the fiber that feeds it. The stream
|
|
21331
|
+
* runs like a run function inside that fiber, so its finalizers run when it
|
|
21332
|
+
* ends, or when the fiber is interrupted by the scope closing.
|
|
21333
|
+
*
|
|
21200
21334
|
* Elements are offered to the queue as the stream runs. Stream completion is
|
|
21201
21335
|
* signaled with `Cause.Done`, stream failures fail the queue, and the queue is
|
|
21202
21336
|
* shut down when the surrounding scope closes.
|
package/src/String.ts
CHANGED
package/src/Tracer.ts
CHANGED
|
@@ -175,13 +175,21 @@ export const ParentSpanKey = "effect/Tracer/ParentSpan"
|
|
|
175
175
|
* @category services
|
|
176
176
|
* @since 2.0.0
|
|
177
177
|
*/
|
|
178
|
-
export class ParentSpan extends Context.Service<ParentSpan, AnySpan>()(ParentSpanKey
|
|
178
|
+
export class ParentSpan extends Context.Service<ParentSpan, AnySpan>()(ParentSpanKey) {}
|
|
179
179
|
|
|
180
180
|
/**
|
|
181
181
|
* Represents a span created outside Effect's tracer, carrying trace and span
|
|
182
182
|
* identifiers, sampling state, and annotations so it can be used as a parent or
|
|
183
183
|
* link in Effect tracing.
|
|
184
184
|
*
|
|
185
|
+
* **Details**
|
|
186
|
+
*
|
|
187
|
+
* An external span identifies a parent or link only. Effect never records on
|
|
188
|
+
* it: it has no attributes, events, or end. While the nearest parent span is
|
|
189
|
+
* external, `Effect.currentSpan` fails, `Effect.annotateCurrentSpan` does
|
|
190
|
+
* nothing, and `Logger.tracerLogger` records nothing. Open a span with
|
|
191
|
+
* `Effect.withSpan` to get one that records.
|
|
192
|
+
*
|
|
185
193
|
* **Example** (Creating an external span value)
|
|
186
194
|
*
|
|
187
195
|
* ```ts import.meta.vitest
|
|
@@ -514,6 +522,8 @@ export const make = (options: Tracer): Tracer => options
|
|
|
514
522
|
* spans.map((span) => Option.getOrUndefined(span.parent)?.spanId) // => ["span-abc-123"]
|
|
515
523
|
* ```
|
|
516
524
|
*
|
|
525
|
+
* @see {@link ExternalSpan}
|
|
526
|
+
*
|
|
517
527
|
* @stability stable
|
|
518
528
|
* @category constructors
|
|
519
529
|
* @since 2.0.0
|
|
@@ -660,7 +670,6 @@ export const TracerKey = "effect/Tracer"
|
|
|
660
670
|
* @since 2.0.0
|
|
661
671
|
*/
|
|
662
672
|
export const Tracer: Context.Reference<Tracer> = Context.Reference<Tracer>(TracerKey, {
|
|
663
|
-
fiberCached: true,
|
|
664
673
|
defaultValue: () => nativeTracer
|
|
665
674
|
})
|
|
666
675
|
|