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
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as Scope from "../../Scope.js";
|
|
2
|
+
const abandonedScopes = /*#__PURE__*/new WeakSet();
|
|
3
|
+
/**
|
|
4
|
+
* Marks `scope` and its direct children as abandoned, so engines need not
|
|
5
|
+
* retain the instances of the runs under it.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export const markScopeAbandoned = scope => {
|
|
10
|
+
abandonedScopes.add(scope);
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Reports whether `scope` or its parent scope was marked abandoned.
|
|
14
|
+
*
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export const isScopeAbandoned = scope => abandonedScopes.has(scope) || scope.parent !== undefined && abandonedScopes.has(scope.parent);
|
|
18
|
+
/**
|
|
19
|
+
* Reuses `prev` while it is still an empty child of `parent`, so replays that
|
|
20
|
+
* register nothing do not grow `parent`. Otherwise forks a fresh child, which
|
|
21
|
+
* keeps a superseded run's compensations apart from the next run's.
|
|
22
|
+
*
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
export const reuseOrForkScope = (prev, parent) => prev !== undefined && prev.parent === parent && prev.state._tag === "Empty" ? prev : Scope.forkUnsafe(parent);
|
|
26
|
+
//# sourceMappingURL=scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.js","names":[],"sources":["../../../src/workflow/internal/scope.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,gBAAgB;AAEvC,MAAM,eAAe,gBAAG,IAAI,OAAO,EAAe;AAElD;;;;;;AAMA,OAAO,MAAM,kBAAkB,GAAI,KAAkB,IAAU;EAC7D,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC;AAC5B,CAAC;AAED;;;;;AAKA,OAAO,MAAM,gBAAgB,GAAI,KAAkB,IACjD,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,IAAK,KAAK,CAAC,MAAM,KAAK,SAAS,IAAI,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAE;AAEjG;;;;;;;AAOA,OAAO,MAAM,gBAAgB,GAAG,CAC9B,IAAiC,EACjC,MAAmB,KAEnB,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,OAAO,GACvE,IAAI,GACJ,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "effect",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.1.
|
|
4
|
+
"version": "4.1.7",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "The missing standard library for TypeScript, for writing production-grade software.",
|
|
7
7
|
"homepage": "https://effect.website",
|
|
@@ -99,10 +99,10 @@
|
|
|
99
99
|
"esbuild": "^0.28.2",
|
|
100
100
|
"fake-indexeddb": "^6.2.8",
|
|
101
101
|
"immer": "^11.2.10",
|
|
102
|
-
"jose": "6.2.
|
|
102
|
+
"jose": "6.2.18",
|
|
103
103
|
"miniflare": "5.20260925.0-alpha",
|
|
104
104
|
"protobufjs": "^8.8.1",
|
|
105
|
-
"tinybench": "^6.2.
|
|
105
|
+
"tinybench": "^6.2.4",
|
|
106
106
|
"valibot": "^1.5.0"
|
|
107
107
|
},
|
|
108
108
|
"scripts": {
|
package/src/Channel.ts
CHANGED
|
@@ -7,6 +7,23 @@
|
|
|
7
7
|
* higher-level modules instead. This module is useful when implementing stream
|
|
8
8
|
* operators or specialized streaming workflows.
|
|
9
9
|
*
|
|
10
|
+
* Every channel runs in a scope supplied by its consumer, called the channel
|
|
11
|
+
* scope. The run functions create that scope and close it before they return,
|
|
12
|
+
* however the channel ends: completion, failure, defect, an early stop by a
|
|
13
|
+
* downstream operator, or interruption. `toPull` and `toPullScoped` use the
|
|
14
|
+
* scope they are given and leave closing it to its owner. Operators that run
|
|
15
|
+
* inner channels, such as `flatMap` and `concat`, may give each inner channel
|
|
16
|
+
* a child scope that closes sooner.
|
|
17
|
+
*
|
|
18
|
+
* `acquireUseRelease`, `ensuring`, `onExit`, and `scoped` finalize when their
|
|
19
|
+
* channel ends on its own (completion, failure, or defect), before downstream
|
|
20
|
+
* observes that end. `callback`, `callbackArray`, `unwrap`, and
|
|
21
|
+
* `acquireRelease` register finalizers in the channel scope, so they run when
|
|
22
|
+
* that scope closes. A channel that is abandoned because a downstream operator
|
|
23
|
+
* stopped pulling from it is finalized no later than when its channel scope
|
|
24
|
+
* closes. Under `toPull`, that can be after the pull has returned its final
|
|
25
|
+
* result, so close the scope to release what the channel still holds.
|
|
26
|
+
*
|
|
10
27
|
* @stability stable
|
|
11
28
|
* @since 2.0.0
|
|
12
29
|
*/
|
|
@@ -496,6 +513,12 @@ const asyncQueue = <A, E = never, R = never>(
|
|
|
496
513
|
/**
|
|
497
514
|
* Creates a `Channel` that interacts with a callback function using a queue.
|
|
498
515
|
*
|
|
516
|
+
* **Details**
|
|
517
|
+
*
|
|
518
|
+
* The callback effect runs in the channel scope. Finalizers it registers, for
|
|
519
|
+
* example with `Effect.acquireRelease`, run when that scope closes, not when
|
|
520
|
+
* the queue ends.
|
|
521
|
+
*
|
|
499
522
|
* **Example** (Creating channels from callbacks)
|
|
500
523
|
*
|
|
501
524
|
* ```ts import.meta.vitest
|
|
@@ -528,6 +551,12 @@ export const callback = <A, E = never, R = never>(
|
|
|
528
551
|
/**
|
|
529
552
|
* Creates a `Channel` that interacts with a callback function using a queue, emitting arrays.
|
|
530
553
|
*
|
|
554
|
+
* **Details**
|
|
555
|
+
*
|
|
556
|
+
* The callback effect runs in the channel scope. Finalizers it registers, for
|
|
557
|
+
* example with `Effect.acquireRelease`, run when that scope closes, not when
|
|
558
|
+
* the queue ends.
|
|
559
|
+
*
|
|
531
560
|
* **Example** (Creating array channels from callbacks)
|
|
532
561
|
*
|
|
533
562
|
* ```ts import.meta.vitest
|
|
@@ -585,6 +614,10 @@ export const suspend = <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>(
|
|
|
585
614
|
* Acquisition is uninterruptible. If acquisition fails, `use` is not run and
|
|
586
615
|
* `release` is not registered.
|
|
587
616
|
*
|
|
617
|
+
* The finalizer runs when the channel ends on its own (completion, failure, or
|
|
618
|
+
* defect), before downstream observes that end. If a downstream operator stops
|
|
619
|
+
* pulling first, it runs no later than when the channel scope closes.
|
|
620
|
+
*
|
|
588
621
|
* **Example** (Managing resources with acquire-use-release)
|
|
589
622
|
*
|
|
590
623
|
* ```ts import.meta.vitest
|
|
@@ -630,8 +663,9 @@ export const acquireUseRelease = <A, E, R, OutElem, OutErr, OutDone, InElem, InE
|
|
|
630
663
|
* **Details**
|
|
631
664
|
*
|
|
632
665
|
* The release action runs when the channel scope closes and receives the scope
|
|
633
|
-
* exit.
|
|
634
|
-
*
|
|
666
|
+
* exit. The channel scope is the scope supplied by whatever consumes this
|
|
667
|
+
* channel: a run function, `toPull`, or an enclosing operator. If acquisition
|
|
668
|
+
* fails, no element is emitted and `release` is not registered.
|
|
635
669
|
*
|
|
636
670
|
* **Example** (Managing resources with acquire-release)
|
|
637
671
|
*
|
|
@@ -646,6 +680,8 @@ export const acquireUseRelease = <A, E, R, OutElem, OutErr, OutDone, InElem, InE
|
|
|
646
680
|
* const observed = [await Effect.runPromise(Channel.runCollect(channel)), released] // => [["resource"], ["resource"]]
|
|
647
681
|
* ```
|
|
648
682
|
*
|
|
683
|
+
* @see {@link acquireUseRelease} for releasing when the channel itself ends
|
|
684
|
+
*
|
|
649
685
|
* @stability stable
|
|
650
686
|
* @category constructors
|
|
651
687
|
* @since 4.0.0
|
|
@@ -658,8 +694,9 @@ export const acquireRelease: {
|
|
|
658
694
|
* **Details**
|
|
659
695
|
*
|
|
660
696
|
* The release action runs when the channel scope closes and receives the scope
|
|
661
|
-
* exit.
|
|
662
|
-
*
|
|
697
|
+
* exit. The channel scope is the scope supplied by whatever consumes this
|
|
698
|
+
* channel: a run function, `toPull`, or an enclosing operator. If acquisition
|
|
699
|
+
* fails, no element is emitted and `release` is not registered.
|
|
663
700
|
*
|
|
664
701
|
* **Example** (Managing resources with acquire-release)
|
|
665
702
|
*
|
|
@@ -674,6 +711,8 @@ export const acquireRelease: {
|
|
|
674
711
|
* const observed = [await Effect.runPromise(Channel.runCollect(channel)), released] // => [["resource"], ["resource"]]
|
|
675
712
|
* ```
|
|
676
713
|
*
|
|
714
|
+
* @see {@link acquireUseRelease} for releasing when the channel itself ends
|
|
715
|
+
*
|
|
677
716
|
* @stability stable
|
|
678
717
|
* @category constructors
|
|
679
718
|
* @since 4.0.0
|
|
@@ -686,8 +725,9 @@ export const acquireRelease: {
|
|
|
686
725
|
* **Details**
|
|
687
726
|
*
|
|
688
727
|
* The release action runs when the channel scope closes and receives the scope
|
|
689
|
-
* exit.
|
|
690
|
-
*
|
|
728
|
+
* exit. The channel scope is the scope supplied by whatever consumes this
|
|
729
|
+
* channel: a run function, `toPull`, or an enclosing operator. If acquisition
|
|
730
|
+
* fails, no element is emitted and `release` is not registered.
|
|
691
731
|
*
|
|
692
732
|
* **Example** (Managing resources with acquire-release)
|
|
693
733
|
*
|
|
@@ -702,6 +742,8 @@ export const acquireRelease: {
|
|
|
702
742
|
* const observed = [await Effect.runPromise(Channel.runCollect(channel)), released] // => [["resource"], ["resource"]]
|
|
703
743
|
* ```
|
|
704
744
|
*
|
|
745
|
+
* @see {@link acquireUseRelease} for releasing when the channel itself ends
|
|
746
|
+
*
|
|
705
747
|
* @stability stable
|
|
706
748
|
* @category constructors
|
|
707
749
|
* @since 4.0.0
|
|
@@ -8992,7 +9034,7 @@ export const merge: {
|
|
|
8992
9034
|
})
|
|
8993
9035
|
)
|
|
8994
9036
|
),
|
|
8995
|
-
Effect.forkIn(forkedScope)
|
|
9037
|
+
Effect.forkIn(forkedScope, { startImmediately: true })
|
|
8996
9038
|
)
|
|
8997
9039
|
yield* runSide("left", left, Scope.forkUnsafe(forkedScope))
|
|
8998
9040
|
yield* runSide("right", right, Scope.forkUnsafe(forkedScope))
|
|
@@ -9523,6 +9565,11 @@ export const restoreUpstreamFailure = <A, E, R>(
|
|
|
9523
9565
|
* Constructs a `Channel` from a scoped effect that will result in a
|
|
9524
9566
|
* `Channel` if successful.
|
|
9525
9567
|
*
|
|
9568
|
+
* **Details**
|
|
9569
|
+
*
|
|
9570
|
+
* The effect runs in the channel scope, so finalizers it registers run when
|
|
9571
|
+
* that scope closes.
|
|
9572
|
+
*
|
|
9526
9573
|
* **Example** (Unwrapping channel effects)
|
|
9527
9574
|
*
|
|
9528
9575
|
* ```ts import.meta.vitest
|
|
@@ -9566,6 +9613,14 @@ export const unwrap = <OutElem, OutErr, OutDone, InElem, InErr, InDone, R2, E, R
|
|
|
9566
9613
|
* Runs a channel with a scope provided for the duration of the channel
|
|
9567
9614
|
* execution, removing the channel's `Scope` requirement.
|
|
9568
9615
|
*
|
|
9616
|
+
* **Details**
|
|
9617
|
+
*
|
|
9618
|
+
* The provided scope closes when the channel ends on its own (completion,
|
|
9619
|
+
* failure, or defect), before downstream observes that end. If a downstream
|
|
9620
|
+
* operator stops pulling first, it closes no later than when the channel scope
|
|
9621
|
+
* closes. It satisfies the `Scope` service requirement only; constructors that
|
|
9622
|
+
* register finalizers in the channel scope, such as `callback`, keep using it.
|
|
9623
|
+
*
|
|
9569
9624
|
* @stability stable
|
|
9570
9625
|
* @category resource management
|
|
9571
9626
|
* @since 2.0.0
|
|
@@ -10145,6 +10200,12 @@ export const onError: {
|
|
|
10145
10200
|
* Returns a channel with an exit-aware finalizer that is guaranteed to run once
|
|
10146
10201
|
* the channel begins execution, whether it succeeds or fails.
|
|
10147
10202
|
*
|
|
10203
|
+
* **Details**
|
|
10204
|
+
*
|
|
10205
|
+
* The finalizer runs when the channel ends on its own (completion, failure, or
|
|
10206
|
+
* defect), before downstream observes that end. If a downstream operator stops
|
|
10207
|
+
* pulling first, it runs no later than when the channel scope closes.
|
|
10208
|
+
*
|
|
10148
10209
|
* **Example** (Running exit finalizers)
|
|
10149
10210
|
*
|
|
10150
10211
|
* ```ts import.meta.vitest
|
|
@@ -10175,6 +10236,12 @@ export const onExit: {
|
|
|
10175
10236
|
* Returns a channel with an exit-aware finalizer that is guaranteed to run once
|
|
10176
10237
|
* the channel begins execution, whether it succeeds or fails.
|
|
10177
10238
|
*
|
|
10239
|
+
* **Details**
|
|
10240
|
+
*
|
|
10241
|
+
* The finalizer runs when the channel ends on its own (completion, failure, or
|
|
10242
|
+
* defect), before downstream observes that end. If a downstream operator stops
|
|
10243
|
+
* pulling first, it runs no later than when the channel scope closes.
|
|
10244
|
+
*
|
|
10178
10245
|
* **Example** (Running exit finalizers)
|
|
10179
10246
|
*
|
|
10180
10247
|
* ```ts import.meta.vitest
|
|
@@ -10209,6 +10276,12 @@ export const onExit: {
|
|
|
10209
10276
|
* Returns a channel with an exit-aware finalizer that is guaranteed to run once
|
|
10210
10277
|
* the channel begins execution, whether it succeeds or fails.
|
|
10211
10278
|
*
|
|
10279
|
+
* **Details**
|
|
10280
|
+
*
|
|
10281
|
+
* The finalizer runs when the channel ends on its own (completion, failure, or
|
|
10282
|
+
* defect), before downstream observes that end. If a downstream operator stops
|
|
10283
|
+
* pulling first, it runs no later than when the channel scope closes.
|
|
10284
|
+
*
|
|
10212
10285
|
* **Example** (Running exit finalizers)
|
|
10213
10286
|
*
|
|
10214
10287
|
* ```ts import.meta.vitest
|
|
@@ -10434,6 +10507,12 @@ export const onEnd: {
|
|
|
10434
10507
|
* Returns a channel with a finalizer effect that is guaranteed to run once the
|
|
10435
10508
|
* channel begins execution, whether it succeeds or fails.
|
|
10436
10509
|
*
|
|
10510
|
+
* **Details**
|
|
10511
|
+
*
|
|
10512
|
+
* The finalizer runs when the channel ends on its own (completion, failure, or
|
|
10513
|
+
* defect), before downstream observes that end. If a downstream operator stops
|
|
10514
|
+
* pulling first, it runs no later than when the channel scope closes.
|
|
10515
|
+
*
|
|
10437
10516
|
* **Example** (Ensuring cleanup runs)
|
|
10438
10517
|
*
|
|
10439
10518
|
* ```ts import.meta.vitest
|
|
@@ -10464,6 +10543,12 @@ export const ensuring: {
|
|
|
10464
10543
|
* Returns a channel with a finalizer effect that is guaranteed to run once the
|
|
10465
10544
|
* channel begins execution, whether it succeeds or fails.
|
|
10466
10545
|
*
|
|
10546
|
+
* **Details**
|
|
10547
|
+
*
|
|
10548
|
+
* The finalizer runs when the channel ends on its own (completion, failure, or
|
|
10549
|
+
* defect), before downstream observes that end. If a downstream operator stops
|
|
10550
|
+
* pulling first, it runs no later than when the channel scope closes.
|
|
10551
|
+
*
|
|
10467
10552
|
* **Example** (Ensuring cleanup runs)
|
|
10468
10553
|
*
|
|
10469
10554
|
* ```ts import.meta.vitest
|
|
@@ -10496,6 +10581,12 @@ export const ensuring: {
|
|
|
10496
10581
|
* Returns a channel with a finalizer effect that is guaranteed to run once the
|
|
10497
10582
|
* channel begins execution, whether it succeeds or fails.
|
|
10498
10583
|
*
|
|
10584
|
+
* **Details**
|
|
10585
|
+
*
|
|
10586
|
+
* The finalizer runs when the channel ends on its own (completion, failure, or
|
|
10587
|
+
* defect), before downstream observes that end. If a downstream operator stops
|
|
10588
|
+
* pulling first, it runs no later than when the channel scope closes.
|
|
10589
|
+
*
|
|
10499
10590
|
* **Example** (Ensuring cleanup runs)
|
|
10500
10591
|
*
|
|
10501
10592
|
* ```ts import.meta.vitest
|
|
@@ -11852,7 +11943,8 @@ export const runFoldEffect: {
|
|
|
11852
11943
|
*
|
|
11853
11944
|
* **Details**
|
|
11854
11945
|
*
|
|
11855
|
-
* The
|
|
11946
|
+
* The channel runs in the provided `Scope`, which the pull leaves open; close
|
|
11947
|
+
* it to release any resources the channel still holds. Consume the pull only
|
|
11856
11948
|
* while that scope remains open. Pulls are serialized so only one pull is
|
|
11857
11949
|
* evaluated at a time.
|
|
11858
11950
|
*
|
|
@@ -11905,6 +11997,11 @@ export const toPull: <OutElem, OutErr, OutDone, Env>(
|
|
|
11905
11997
|
/**
|
|
11906
11998
|
* Converts a channel to a Pull within an existing scope.
|
|
11907
11999
|
*
|
|
12000
|
+
* **Details**
|
|
12001
|
+
*
|
|
12002
|
+
* The channel runs in the provided scope, which the pull leaves open; close it
|
|
12003
|
+
* to release any resources the channel still holds.
|
|
12004
|
+
*
|
|
11908
12005
|
* **Example** (Converting channels to scoped pulls)
|
|
11909
12006
|
*
|
|
11910
12007
|
* ```ts import.meta.vitest
|
package/src/Codegen.ts
CHANGED
|
@@ -509,11 +509,16 @@ export class Module {
|
|
|
509
509
|
* Returned keys preserve the requested names even when declaration names must change to avoid collisions.
|
|
510
510
|
* A root that references a definition of the same name reuses that definition's binding.
|
|
511
511
|
* The module remains open for further declarations; imports and initialization order are resolved when printing.
|
|
512
|
+
* Built-in declarations and filters use their recorded representation ID and payload, including after a JSON
|
|
513
|
+
* round trip. A custom `toCode` annotation takes precedence. Replacing a built-in ID with a custom ID requires
|
|
514
|
+
* supplying a callback for that ID.
|
|
512
515
|
*
|
|
513
516
|
* **Gotchas**
|
|
514
517
|
*
|
|
515
|
-
* Recursive representations must contain explicit suspensions. Custom declarations and
|
|
516
|
-
* `toCode` callbacks. Each callback is called once and its exceptions pass through unchanged.
|
|
518
|
+
* Recursive representations must contain explicit suspensions. Custom declarations and individual filters require
|
|
519
|
+
* supported `toCode` callbacks. Each callback is called once and its exceptions pass through unchanged.
|
|
520
|
+
* An explicit `toCode: undefined` disables built-in lookup on a live declaration or filter.
|
|
521
|
+
* Mutable arguments such as date bounds are printed from the values recorded at schema creation.
|
|
517
522
|
* Callback output supports imports, qualified names, generic and structural types, API calls,
|
|
518
523
|
* literal/object/array arguments, and zero-argument arrows. Unsupported syntax throws with its document path.
|
|
519
524
|
* When another declaration eagerly uses a returned binding, include it in that declaration's dependencies.
|
package/src/Config.ts
CHANGED
|
@@ -77,11 +77,14 @@ export class ConfigError {
|
|
|
77
77
|
readonly _tag = "ConfigError"
|
|
78
78
|
readonly name: string = "ConfigError"
|
|
79
79
|
readonly cause: SourceError | Schema.SchemaError
|
|
80
|
+
declare readonly message: string
|
|
80
81
|
constructor(cause: SourceError | Schema.SchemaError) {
|
|
81
82
|
this.cause = cause
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
Object.defineProperty(this, "message", {
|
|
84
|
+
value: cause.toString(),
|
|
85
|
+
enumerable: false,
|
|
86
|
+
configurable: true
|
|
87
|
+
})
|
|
85
88
|
}
|
|
86
89
|
toString() {
|
|
87
90
|
return `ConfigError(${this.message})`
|
package/src/Context.ts
CHANGED
|
@@ -14,13 +14,14 @@
|
|
|
14
14
|
import type { Effect, EffectIterator } from "./Effect.ts"
|
|
15
15
|
import * as Effectable from "./Effectable.ts"
|
|
16
16
|
import * as Equal from "./Equal.ts"
|
|
17
|
-
import { dual, type LazyArg } from "./Function.ts"
|
|
17
|
+
import { dual, identity, type LazyArg } from "./Function.ts"
|
|
18
18
|
import * as Hash from "./Hash.ts"
|
|
19
19
|
import type { Inspectable } from "./Inspectable.ts"
|
|
20
|
-
import { exitSucceed, PipeInspectableProto, withFiber } from "./internal/core.ts"
|
|
20
|
+
import { contextMaker, exitSucceed, PipeInspectableProto, withFiber } from "./internal/core.ts"
|
|
21
|
+
import { fiberCachedKeys } from "./internal/fiberCachedKeys.ts"
|
|
22
|
+
import { hasProperty } from "./internal/predicate.ts"
|
|
21
23
|
import * as Option from "./Option.ts"
|
|
22
24
|
import type { Pipeable } from "./Pipeable.ts"
|
|
23
|
-
import { hasProperty } from "./Predicate.ts"
|
|
24
25
|
import type * as Types from "./Types.ts"
|
|
25
26
|
|
|
26
27
|
/**
|
|
@@ -420,45 +421,47 @@ export const Service: {
|
|
|
420
421
|
;(self as any).make = options.make
|
|
421
422
|
}
|
|
422
423
|
if (options?.fiberCached) {
|
|
423
|
-
|
|
424
|
+
fiberCachedKeys.add(key)
|
|
424
425
|
}
|
|
425
426
|
return self
|
|
426
427
|
}
|
|
427
428
|
return arguments.length > 0 ? init(arguments[0], arguments[1]) : init
|
|
428
429
|
} as any
|
|
429
430
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
431
|
+
// The build annotates `Object.assign` as pure, allowing bundles without service
|
|
432
|
+
// keys to drop `ServiceProto` and `Effectable.ts`.
|
|
433
|
+
const ServiceProto: any = Object.assign(
|
|
434
|
+
{ [ServiceTypeId]: ServiceTypeId },
|
|
435
|
+
Effectable.Prototype<Service<never, any>>({
|
|
433
436
|
label: "Service",
|
|
434
437
|
evaluate(fiber) {
|
|
435
438
|
return exitSucceed(get(fiber.context, this))
|
|
436
439
|
}
|
|
437
440
|
}),
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
441
|
+
{
|
|
442
|
+
toJSON<I, A>(this: Service<I, A>) {
|
|
443
|
+
return {
|
|
444
|
+
_id: "Service",
|
|
445
|
+
key: this.key
|
|
446
|
+
}
|
|
447
|
+
},
|
|
448
|
+
of<Service>(this: void, self: Service): Service {
|
|
449
|
+
return self
|
|
450
|
+
},
|
|
451
|
+
context<Identifier, Shape>(
|
|
452
|
+
this: Service<Identifier, Shape>,
|
|
453
|
+
self: Shape
|
|
454
|
+
): Context<Identifier> {
|
|
455
|
+
return make(this, self)
|
|
456
|
+
},
|
|
457
|
+
use<A, E, R>(this: Service<never, any>, f: (service: any) => Effect<A, E, R>): Effect<A, E, R> {
|
|
458
|
+
return withFiber((fiber) => f(get(fiber.context, this)))
|
|
459
|
+
},
|
|
460
|
+
useSync<A>(this: Service<never, any>, f: (service: any) => A): Effect<A, never, never> {
|
|
461
|
+
return withFiber((fiber) => exitSucceed(f(get(fiber.context, this))))
|
|
442
462
|
}
|
|
443
|
-
},
|
|
444
|
-
of<Service>(this: void, self: Service): Service {
|
|
445
|
-
return self
|
|
446
|
-
},
|
|
447
|
-
context<Identifier, Shape>(
|
|
448
|
-
this: Service<Identifier, Shape>,
|
|
449
|
-
self: Shape
|
|
450
|
-
): Context<Identifier> {
|
|
451
|
-
return make(this, self)
|
|
452
|
-
},
|
|
453
|
-
use<A, E, R>(this: Service<never, any>, f: (service: any) => Effect<A, E, R>): Effect<A, E, R> {
|
|
454
|
-
return withFiber((fiber) => f(get(fiber.context, this)))
|
|
455
|
-
},
|
|
456
|
-
useSync<A>(this: Service<never, any>, f: (service: any) => A): Effect<A, never, never> {
|
|
457
|
-
return withFiber((fiber) => exitSucceed(f(get(fiber.context, this))))
|
|
458
463
|
}
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
const cacheKeys = new Set<string>()
|
|
464
|
+
)
|
|
462
465
|
|
|
463
466
|
const ReferenceTypeId = "~effect/Context/Reference" as const
|
|
464
467
|
|
|
@@ -655,16 +658,29 @@ interface Overlay {
|
|
|
655
658
|
// enough fall-throughs to amortize the copy.
|
|
656
659
|
const FlattenAfterBaseHits = 8
|
|
657
660
|
|
|
658
|
-
const
|
|
661
|
+
const makeFlat = <Services>(
|
|
659
662
|
cacheRoot: ContextImpl<any> | undefined,
|
|
660
663
|
base: ReadonlyMap<string, any>,
|
|
661
|
-
overlay: Overlay | undefined,
|
|
662
|
-
depth: number,
|
|
663
664
|
maxDepth: number
|
|
664
665
|
): ContextImpl<Services> => {
|
|
665
666
|
const self: ContextImpl<Services> = Object.create(Proto)
|
|
666
667
|
self.cacheRoot = cacheRoot ?? self
|
|
667
668
|
self.base = base
|
|
669
|
+
self.depth = 0
|
|
670
|
+
self.maxDepth = maxDepth
|
|
671
|
+
return self
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
const makeOverlay = <Services>(
|
|
675
|
+
cacheRoot: ContextImpl<any> | undefined,
|
|
676
|
+
base: ReadonlyMap<string, any>,
|
|
677
|
+
overlay: Overlay,
|
|
678
|
+
depth: number,
|
|
679
|
+
maxDepth: number
|
|
680
|
+
): ContextImpl<Services> => {
|
|
681
|
+
const self: ContextImpl<Services> = Object.create(OverlayProto)
|
|
682
|
+
self.cacheRoot = cacheRoot ?? self
|
|
683
|
+
self.base = base
|
|
668
684
|
self.overlay = overlay
|
|
669
685
|
self.depth = depth
|
|
670
686
|
self._flat = undefined
|
|
@@ -690,26 +706,35 @@ const flatten = (self: ContextImpl<any>): ReadonlyMap<string, any> => {
|
|
|
690
706
|
const withFlat = <B>(self: Context<any>, f: (map: Map<string, any>) => void): Context<B> => {
|
|
691
707
|
const map = new Map(self.mapUnsafe)
|
|
692
708
|
f(map)
|
|
693
|
-
return
|
|
709
|
+
return makeFlat(undefined, map, (self as ContextImpl<any>).maxDepth)
|
|
694
710
|
}
|
|
695
711
|
|
|
696
712
|
// A private symbol so user code cannot forge a value that reads as absent
|
|
697
713
|
const notFound = Symbol()
|
|
698
714
|
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
715
|
+
// Read fields rather than dispatching through a method for contexts from other copies of effect.
|
|
716
|
+
const lookup = <Services>(self: Context<Services>, key: string): unknown => {
|
|
717
|
+
const impl = self as ContextImpl<Services>
|
|
718
|
+
if (impl.overlay !== undefined) return overlayLookup(impl, key)
|
|
719
|
+
const value = impl.base.get(key)
|
|
720
|
+
return value === undefined && !impl.base.has(key) ? notFound : value
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
const overlayLookup = (self: ContextImpl<any>, key: string): unknown => {
|
|
724
|
+
for (let overlay = self.overlay; overlay; overlay = overlay.parent) {
|
|
702
725
|
if (overlay.key === key) return overlay.value
|
|
703
726
|
}
|
|
704
|
-
const value =
|
|
727
|
+
const value = self.base.get(key)
|
|
705
728
|
// Misses must not advance the counter: reference-default lookups miss the
|
|
706
729
|
// base on every fiber cache refresh, which would flatten every short-lived
|
|
707
730
|
// request context and reintroduce the O(services) per-request cost
|
|
708
|
-
if (value === undefined && !
|
|
709
|
-
if (
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
731
|
+
if (value === undefined && !self.base.has(key)) return notFound
|
|
732
|
+
if (++self.baseHits >= self.base.size && self.baseHits >= FlattenAfterBaseHits) {
|
|
733
|
+
// Flatten through `OverlayProto.mapUnsafe` rather than calling `flatten`,
|
|
734
|
+
// so flat-only bundles never reach `flatten`
|
|
735
|
+
self.base = self.mapUnsafe
|
|
736
|
+
self.overlay = undefined
|
|
737
|
+
self.depth = 0
|
|
713
738
|
}
|
|
714
739
|
return value
|
|
715
740
|
}
|
|
@@ -767,24 +792,26 @@ export const makeUnsafe = <Services = never>(
|
|
|
767
792
|
): Context<Services> => {
|
|
768
793
|
const maxDepth = options?.maxDepth
|
|
769
794
|
// NaN or Infinity would never trigger a rebase, so fall back to the default
|
|
770
|
-
return
|
|
795
|
+
return makeFlat(undefined, mapUnsafe, Number.isInteger(maxDepth) && maxDepth! >= 0 ? maxDepth! : 8)
|
|
771
796
|
}
|
|
772
797
|
|
|
798
|
+
contextMaker.makeUnsafe = (mapUnsafe) => makeFlat(undefined, mapUnsafe, 8)
|
|
799
|
+
|
|
773
800
|
const Proto: Omit<
|
|
774
801
|
ContextImpl<never>,
|
|
775
802
|
"cacheRoot" | "base" | "overlay" | "depth" | "_flat" | "baseHits" | "maxDepth"
|
|
776
803
|
> = {
|
|
777
804
|
get mapUnsafe() {
|
|
778
|
-
return
|
|
805
|
+
return (this as any as ContextImpl<any>).base
|
|
779
806
|
},
|
|
780
807
|
...PipeInspectableProto,
|
|
781
808
|
[TypeId]: {
|
|
782
|
-
_Services:
|
|
809
|
+
_Services: identity
|
|
783
810
|
},
|
|
784
811
|
toJSON(this: Context<never>) {
|
|
785
812
|
return {
|
|
786
813
|
_id: "Context",
|
|
787
|
-
services: Array.from(this.mapUnsafe
|
|
814
|
+
services: Array.from(this.mapUnsafe, ([key, value]) => ({ key, value }))
|
|
788
815
|
}
|
|
789
816
|
},
|
|
790
817
|
[Equal.symbol]<A>(this: Context<A>, that: unknown): boolean {
|
|
@@ -802,6 +829,18 @@ const Proto: Omit<
|
|
|
802
829
|
}
|
|
803
830
|
}
|
|
804
831
|
|
|
832
|
+
// Separate prototype for contexts carrying an overlay chain (`Context.add`), so
|
|
833
|
+
// bundles that only build flat contexts drop `flatten` and `applyOverlays`.
|
|
834
|
+
const OverlayProto = Object.create(Proto, {
|
|
835
|
+
mapUnsafe: {
|
|
836
|
+
get(this: ContextImpl<any>) {
|
|
837
|
+
return flatten(this)
|
|
838
|
+
},
|
|
839
|
+
enumerable: true,
|
|
840
|
+
configurable: true
|
|
841
|
+
}
|
|
842
|
+
})
|
|
843
|
+
|
|
805
844
|
/** @internal */
|
|
806
845
|
export const hasSameCache = <Services, Services2>(
|
|
807
846
|
self: Context<Services>,
|
|
@@ -1054,16 +1093,16 @@ export const addUnsafe = <Services, I, S>(
|
|
|
1054
1093
|
service: Types.NoInfer<S>
|
|
1055
1094
|
): Context<Services | I> => {
|
|
1056
1095
|
const impl = self as ContextImpl<Services>
|
|
1057
|
-
const cacheRoot =
|
|
1096
|
+
const cacheRoot = fiberCachedKeys.has(key) ? undefined : impl.cacheRoot
|
|
1058
1097
|
if (impl.depth >= impl.maxDepth) {
|
|
1059
1098
|
// Avoid mapUnsafe: it would flatten the parent before copying.
|
|
1060
1099
|
const map = new Map(impl._flat ?? impl.base)
|
|
1061
1100
|
if (!impl._flat) applyOverlays(map, impl.overlay)
|
|
1062
1101
|
map.set(key, service)
|
|
1063
|
-
return
|
|
1102
|
+
return makeFlat(cacheRoot, map, impl.maxDepth)
|
|
1064
1103
|
}
|
|
1065
1104
|
|
|
1066
|
-
return
|
|
1105
|
+
return makeOverlay(
|
|
1067
1106
|
cacheRoot,
|
|
1068
1107
|
impl.base,
|
|
1069
1108
|
{ key, value: service, parent: impl.overlay },
|
|
@@ -1685,6 +1724,25 @@ const getDefaultValue = (ref: Reference<any>) => {
|
|
|
1685
1724
|
return (ref as any)[defaultValueCacheKey] = ref.defaultValue()
|
|
1686
1725
|
}
|
|
1687
1726
|
|
|
1727
|
+
/**
|
|
1728
|
+
* Shares the runtime default with reference lookups without changing
|
|
1729
|
+
* `ref.defaultValue()`.
|
|
1730
|
+
*
|
|
1731
|
+
* @internal
|
|
1732
|
+
*/
|
|
1733
|
+
export const shareDefaultValue = <Shape>(ref: Reference<Shape>, shared: () => Shape): Reference<Shape> =>
|
|
1734
|
+
Object.defineProperty(ref, defaultValueCacheKey, { get: shared })
|
|
1735
|
+
|
|
1736
|
+
/**
|
|
1737
|
+
* Reads a reference, falling back to its cached default.
|
|
1738
|
+
*
|
|
1739
|
+
* @internal
|
|
1740
|
+
*/
|
|
1741
|
+
export const getReferenceUnsafe = <Services, Shape>(self: Context<Services>, ref: Reference<Shape>): Shape => {
|
|
1742
|
+
const value = lookup(self, ref.key)
|
|
1743
|
+
return value === notFound ? getDefaultValue(ref) : value as Shape
|
|
1744
|
+
}
|
|
1745
|
+
|
|
1688
1746
|
const serviceNotFoundError = (service: Key<any, any>) => {
|
|
1689
1747
|
const error = new Error(
|
|
1690
1748
|
`Service not found${service.key ? `: ${String(service.key)}` : ""}`
|
|
@@ -2017,7 +2075,7 @@ export const pick = <S extends ReadonlyArray<Key<any, any>>>(
|
|
|
2017
2075
|
const value = lookup(self, key)
|
|
2018
2076
|
if (value !== notFound) map.set(key, value)
|
|
2019
2077
|
}
|
|
2020
|
-
return
|
|
2078
|
+
return makeFlat(undefined, map, (self as ContextImpl<any>).maxDepth)
|
|
2021
2079
|
}
|
|
2022
2080
|
const keep = new Set(services.map((key) => key.key))
|
|
2023
2081
|
return withFlat(self, (map) =>
|
package/src/Cron.ts
CHANGED
|
@@ -901,13 +901,19 @@ export const prev = (cron: Cron, now?: DateTime.DateTime.Input): Date => {
|
|
|
901
901
|
|
|
902
902
|
const stepCron = (cron: Cron, now: DateTime.DateTime.Input | undefined, direction: "next" | "prev"): Date => {
|
|
903
903
|
const start = now ?? new Date()
|
|
904
|
+
// Use the named host zone when unzoned so offsets update across DST transitions.
|
|
905
|
+
const useHostZone = Option.isNone(cron.tz) && !(dateTime.isDateTime(start) && dateTime.isZoned(start)) &&
|
|
906
|
+
!(typeof start === "object" && "timeZoneId" in start)
|
|
907
|
+
const zoned = dateTime.makeZonedUnsafe(start, {
|
|
908
|
+
timeZone: useHostZone ? dateTime.zoneMakeLocal() : Option.getOrUndefined(cron.tz)
|
|
909
|
+
})
|
|
904
910
|
if (cron.onDstOverlap !== "both") {
|
|
905
|
-
return searchCron(cron,
|
|
911
|
+
return searchCron(cron, zoned, direction, cron.onDstOverlap)
|
|
906
912
|
}
|
|
907
913
|
// Both occurrences are eligible, so the result is the nearest of the two
|
|
908
914
|
// single-occurrence searches in the search direction.
|
|
909
|
-
const earlier = searchCron(cron,
|
|
910
|
-
const later = searchCron(cron,
|
|
915
|
+
const earlier = searchCron(cron, zoned, direction, "earlier")
|
|
916
|
+
const later = searchCron(cron, zoned, direction, "later")
|
|
911
917
|
if (direction === "next") {
|
|
912
918
|
return earlier <= later ? earlier : later
|
|
913
919
|
}
|
|
@@ -916,15 +922,10 @@ const stepCron = (cron: Cron, now: DateTime.DateTime.Input | undefined, directio
|
|
|
916
922
|
|
|
917
923
|
const searchCron = (
|
|
918
924
|
cron: Cron,
|
|
919
|
-
|
|
925
|
+
zoned: DateTime.Zoned,
|
|
920
926
|
direction: "next" | "prev",
|
|
921
927
|
onDstOverlap: "earlier" | "later"
|
|
922
928
|
): Date => {
|
|
923
|
-
const tz = Option.getOrUndefined(cron.tz)
|
|
924
|
-
const zoned = dateTime.makeZonedUnsafe(now, {
|
|
925
|
-
timeZone: tz
|
|
926
|
-
})
|
|
927
|
-
|
|
928
929
|
const reverse = direction === "prev"
|
|
929
930
|
const tick = reverse ? -1 : 1
|
|
930
931
|
const table = cron[direction]
|
|
@@ -934,7 +935,7 @@ const searchCron = (
|
|
|
934
935
|
(next: number, current: number) => next < current :
|
|
935
936
|
(next: number, current: number) => next > current
|
|
936
937
|
|
|
937
|
-
const utc =
|
|
938
|
+
const utc = dateTime.isTimeZoneNamed(zoned.zone) && zoned.zone.id === "UTC"
|
|
938
939
|
// Going backward, a candidate inside a gap is left in place: it resolves to
|
|
939
940
|
// the instant after the gap, and the range check below rejects it when that
|
|
940
941
|
// instant is not before the input.
|