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
|
@@ -26,6 +26,7 @@ import * as HttpClientError from "../http/HttpClientError.ts"
|
|
|
26
26
|
import * as HttpClientRequest from "../http/HttpClientRequest.ts"
|
|
27
27
|
import type * as HttpClientResponse from "../http/HttpClientResponse.ts"
|
|
28
28
|
import * as HttpMethod from "../http/HttpMethod.ts"
|
|
29
|
+
import { type ClientPath, CurrentClientPath } from "../http/internal/clientPath.ts"
|
|
29
30
|
import * as MediaType from "../http/internal/mediaType.ts"
|
|
30
31
|
import * as internalUrlParams from "../http/internal/urlParams.ts"
|
|
31
32
|
import * as UrlParams from "../http/UrlParams.ts"
|
|
@@ -421,11 +422,16 @@ export const makeClient = <ApiId extends string, Groups extends HttpApiGroup.Con
|
|
|
421
422
|
Effect.gen(function*() {
|
|
422
423
|
const services = yield* Effect.context()
|
|
423
424
|
|
|
425
|
+
const baseUrl = options?.baseUrl?.toString()
|
|
426
|
+
const fullPath = (path: string) =>
|
|
427
|
+
baseUrl === undefined
|
|
428
|
+
? path
|
|
429
|
+
: internalUrlParams.toPath(HttpClientRequest.prependUrl(HttpClientRequest.get(path), baseUrl).url)
|
|
424
430
|
const httpClient = options.httpClient.pipe(
|
|
425
|
-
|
|
431
|
+
baseUrl === undefined
|
|
426
432
|
? identity
|
|
427
433
|
: HttpClient.mapRequest(
|
|
428
|
-
HttpClientRequest.prependUrl(
|
|
434
|
+
HttpClientRequest.prependUrl(baseUrl)
|
|
429
435
|
)
|
|
430
436
|
)
|
|
431
437
|
|
|
@@ -508,6 +514,10 @@ export const makeClient = <ApiId extends string, Groups extends HttpApiGroup.Con
|
|
|
508
514
|
|
|
509
515
|
const middlewareKeys = Array.from(onEndpointOptions.middleware, (tag) => `${tag.key}/Client`)
|
|
510
516
|
const redactedNames = HttpApi.getEndpointRedactedNames(api, group, endpoint)
|
|
517
|
+
const redactedParams = HttpApi.getEndpointRedactedParams(api, group, endpoint)
|
|
518
|
+
// Names declared on the API or group may belong to other endpoints.
|
|
519
|
+
const redactsPath = redactedParams.all ||
|
|
520
|
+
redactedParams.names.some((name) => endpoint.path.includes(`:${name}`))
|
|
511
521
|
|
|
512
522
|
const endpointFn = Effect.fnUntraced(function*(
|
|
513
523
|
request: {
|
|
@@ -520,12 +530,20 @@ export const makeClient = <ApiId extends string, Groups extends HttpApiGroup.Con
|
|
|
520
530
|
} | undefined
|
|
521
531
|
) {
|
|
522
532
|
let httpRequest = HttpClientRequest.make(endpoint.method)(endpoint.path)
|
|
533
|
+
let redactedPath: ClientPath | undefined
|
|
523
534
|
|
|
524
535
|
if (request !== undefined) {
|
|
525
536
|
// params
|
|
526
537
|
if (encodeParams !== undefined) {
|
|
527
538
|
const params = (yield* encodeParams(request.params)) as Record<string, string>
|
|
528
|
-
|
|
539
|
+
const sent = makeUrl(params)
|
|
540
|
+
httpRequest = HttpClientRequest.setUrl(httpRequest, sent)
|
|
541
|
+
if (redactsPath) {
|
|
542
|
+
redactedPath = {
|
|
543
|
+
sent: fullPath(sent),
|
|
544
|
+
redacted: fullPath(makeUrl(params, redactedParams.all ? "*" : redactedParams.names))
|
|
545
|
+
}
|
|
546
|
+
}
|
|
529
547
|
}
|
|
530
548
|
|
|
531
549
|
// payload
|
|
@@ -583,7 +601,10 @@ export const makeClient = <ApiId extends string, Groups extends HttpApiGroup.Con
|
|
|
583
601
|
middlewareKeys,
|
|
584
602
|
middlewareKeys.length - 1
|
|
585
603
|
)
|
|
586
|
-
const
|
|
604
|
+
const named = redactedNames === undefined ? execute : withRedactedNames(execute, redactedNames)
|
|
605
|
+
const response = yield* (redactedPath === undefined
|
|
606
|
+
? named
|
|
607
|
+
: Effect.provideService(named, CurrentClientPath, redactedPath))
|
|
587
608
|
|
|
588
609
|
if (request?.responseMode === "response-only") {
|
|
589
610
|
return response
|
|
@@ -972,17 +993,19 @@ export const urlBuilder = <Api extends HttpApi.Constraint>(api: Api, options?: {
|
|
|
972
993
|
|
|
973
994
|
const compilePath = (path: string, schema: Schema.Top | undefined) => {
|
|
974
995
|
if (schema === undefined || !path.includes(":")) {
|
|
975
|
-
return (_: any) => path
|
|
996
|
+
return (_: any, _redacted?: ReadonlyArray<string> | "*") => path
|
|
976
997
|
}
|
|
977
998
|
const paramNames = HttpApiPath.getParamNames(schema)
|
|
978
|
-
return (params: Record<string, string | undefined>) =>
|
|
999
|
+
return (params: Record<string, string | undefined>, redacted?: ReadonlyArray<string> | "*") =>
|
|
979
1000
|
HttpApiPath.replaceParams(path, paramNames, (key, optional) => {
|
|
980
1001
|
const value = params[key]
|
|
981
1002
|
if (value === "." || value === "..") {
|
|
982
1003
|
// dot segments survive encoding and would be resolved by URL normalization
|
|
983
1004
|
throw new Error(`Invalid path parameter: ${key}`)
|
|
984
1005
|
}
|
|
985
|
-
if (value !== undefined)
|
|
1006
|
+
if (value !== undefined) {
|
|
1007
|
+
return redacted === "*" || redacted?.includes(key) ? "REDACTED" : encodeURIComponent(value)
|
|
1008
|
+
}
|
|
986
1009
|
if (optional) return undefined
|
|
987
1010
|
throw new Error(`Missing path parameter: ${key}`)
|
|
988
1011
|
})
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type * as Schema from "../../Schema.ts"
|
|
2
|
+
import * as SchemaAST from "../../SchemaAST.ts"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Returns the wire keys of a params, query or headers schema whose values hold
|
|
6
|
+
* a `Redacted`, or `undefined` when a `Redacted` is present but the wire keys
|
|
7
|
+
* are unknown, so the caller redacts everything.
|
|
8
|
+
*
|
|
9
|
+
* Keys are only known for a struct whose keys are encoded as is.
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export const getRedactedKeys = (schema: Schema.Top | undefined): ReadonlyArray<string> | undefined => {
|
|
14
|
+
if (schema === undefined) return []
|
|
15
|
+
const ast = schema.ast
|
|
16
|
+
if (!SchemaAST.isObjects(ast) || ast.encoding !== undefined) return hasRedacted(ast, new Set()) ? undefined : []
|
|
17
|
+
if (ast.indexSignatures.some((is) => hasRedacted(is.type, new Set()))) return undefined
|
|
18
|
+
return ast.propertySignatures.filter((ps) => hasRedacted(ps.type, new Set())).map((ps) => String(ps.name))
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const hasRedacted = (ast: SchemaAST.AST, seen: Set<SchemaAST.AST>): boolean => {
|
|
22
|
+
const go = (ast: SchemaAST.AST) => hasRedacted(ast, seen)
|
|
23
|
+
switch (ast._tag) {
|
|
24
|
+
case "Declaration":
|
|
25
|
+
return (ast.annotations as Schema.Annotations.Declaration<unknown, readonly []> | undefined)?.representation
|
|
26
|
+
?.id === "effect/schema/Redacted" || ast.typeParameters.some(go)
|
|
27
|
+
case "Objects":
|
|
28
|
+
return ast.propertySignatures.some((ps) => go(ps.type)) || ast.indexSignatures.some((is) => go(is.type))
|
|
29
|
+
case "Union":
|
|
30
|
+
return ast.types.some(go)
|
|
31
|
+
case "Arrays":
|
|
32
|
+
return ast.elements.some(go) || ast.rest.some(go)
|
|
33
|
+
case "Suspend":
|
|
34
|
+
if (seen.has(ast)) return false
|
|
35
|
+
seen.add(ast)
|
|
36
|
+
return go(ast.thunk())
|
|
37
|
+
default:
|
|
38
|
+
return false
|
|
39
|
+
}
|
|
40
|
+
}
|
package/src/internal/base64.ts
CHANGED
|
@@ -4,7 +4,7 @@ export interface NativeDecodeOptions {
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Decodes `str` with native `Uint8Array.fromBase64`.
|
|
7
|
+
* Decodes `str` with native `Uint8Array.fromBase64`, falling back to `Buffer`.
|
|
8
8
|
*
|
|
9
9
|
* Returns `undefined` when native decoding is unavailable or skipped for a
|
|
10
10
|
* short input, and `null` when native decoding rejected the input. In both
|
|
@@ -28,7 +28,17 @@ export const decodeNative = (
|
|
|
28
28
|
const NativeUint8Array = Uint8Array as {
|
|
29
29
|
readonly fromBase64?: (string: string, options?: NativeDecodeOptions) => Uint8Array
|
|
30
30
|
}
|
|
31
|
-
if (typeof NativeUint8Array.fromBase64 !== "function")
|
|
31
|
+
if (typeof NativeUint8Array.fromBase64 !== "function") {
|
|
32
|
+
const Buffer = getBuffer()
|
|
33
|
+
if (Buffer === undefined) return undefined
|
|
34
|
+
const encoding = options?.alphabet ?? "base64"
|
|
35
|
+
const bytes = new Uint8Array(decodedLength)
|
|
36
|
+
const buffer = Buffer.from(bytes.buffer)
|
|
37
|
+
// `Buffer` is permissive (skips invalid chars, mixes alphabets, truncates
|
|
38
|
+
// code units), so accept only input that round-trips identically.
|
|
39
|
+
const canonical = options !== undefined && str.endsWith("=") ? str.slice(0, str.indexOf("=")) : str
|
|
40
|
+
return buffer.write(str, encoding) === decodedLength && buffer.toString(encoding) === canonical ? bytes : null
|
|
41
|
+
}
|
|
32
42
|
try {
|
|
33
43
|
const bytes = NativeUint8Array.fromBase64(str, options)
|
|
34
44
|
return bytes.length === decodedLength ? bytes : null
|
|
@@ -37,6 +47,51 @@ export const decodeNative = (
|
|
|
37
47
|
}
|
|
38
48
|
}
|
|
39
49
|
|
|
50
|
+
interface BufferLike {
|
|
51
|
+
write(string: string, encoding: string): number
|
|
52
|
+
toString(encoding: string): string
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
interface BufferConstructorLike {
|
|
56
|
+
from(buffer: ArrayBufferLike, byteOffset?: number, length?: number): BufferLike
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const typedArrayPrototype = Object.getPrototypeOf(Uint8Array.prototype)
|
|
60
|
+
const typedArrayBuffer = Object.getOwnPropertyDescriptor(typedArrayPrototype, "buffer")!.get as (
|
|
61
|
+
this: Uint8Array
|
|
62
|
+
) => ArrayBufferLike
|
|
63
|
+
const typedArrayByteOffset = Object.getOwnPropertyDescriptor(typedArrayPrototype, "byteOffset")!.get as (
|
|
64
|
+
this: Uint8Array
|
|
65
|
+
) => number
|
|
66
|
+
const typedArrayByteLength = Object.getOwnPropertyDescriptor(typedArrayPrototype, "byteLength")!.get as (
|
|
67
|
+
this: Uint8Array
|
|
68
|
+
) => number
|
|
69
|
+
|
|
70
|
+
// Gate on `process.versions.node` to avoid slow browser/RN `Buffer` polyfills;
|
|
71
|
+
// read at call time without importing `node:buffer`.
|
|
72
|
+
const getBuffer = (): BufferConstructorLike | undefined => {
|
|
73
|
+
const global = globalThis as {
|
|
74
|
+
readonly Buffer?: BufferConstructorLike
|
|
75
|
+
readonly process?: { readonly versions?: { readonly node?: unknown } }
|
|
76
|
+
}
|
|
77
|
+
return typeof global.process?.versions?.node === "string" && typeof global.Buffer === "function"
|
|
78
|
+
? global.Buffer
|
|
79
|
+
: undefined
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Encodes `bytes` with `Buffer` ("base64" padded, "base64url" unpadded), or returns `undefined` if unavailable.
|
|
84
|
+
*
|
|
85
|
+
* @internal
|
|
86
|
+
*/
|
|
87
|
+
export const encodeBuffer = (bytes: Uint8Array, encoding: "base64" | "base64url"): string | undefined => {
|
|
88
|
+
const Buffer = getBuffer()
|
|
89
|
+
if (Buffer === undefined) return undefined
|
|
90
|
+
const byteLength = typedArrayByteLength.call(bytes)
|
|
91
|
+
if (byteLength < 32) return undefined
|
|
92
|
+
return Buffer.from(typedArrayBuffer.call(bytes), typedArrayByteOffset.call(bytes), byteLength).toString(encoding)
|
|
93
|
+
}
|
|
94
|
+
|
|
40
95
|
/** @internal */
|
|
41
96
|
export const stripCrlf = (str: string): string =>
|
|
42
97
|
str.indexOf("\n") === -1 && str.indexOf("\r") === -1 ? str : str.replace(/[\n\r]/g, "")
|
package/src/internal/core.ts
CHANGED
|
@@ -8,11 +8,12 @@ import { dual, identity } from "../Function.ts"
|
|
|
8
8
|
import * as Hash from "../Hash.ts"
|
|
9
9
|
import { NodeInspectSymbol } from "../Inspectable.ts"
|
|
10
10
|
import { pipeArguments } from "../Pipeable.ts"
|
|
11
|
-
import { hasProperty } from "../Predicate.ts"
|
|
12
11
|
import type { StackFrame } from "../References.ts"
|
|
13
12
|
import type * as Types from "../Types.ts"
|
|
14
13
|
import { SingleShotGen } from "../Utils.ts"
|
|
15
14
|
import type { FiberImpl } from "./effect.ts"
|
|
15
|
+
import { combine as hashCombine } from "./equal.ts"
|
|
16
|
+
import { hasProperty } from "./predicate.ts"
|
|
16
17
|
import * as InternalRecord from "./record.ts"
|
|
17
18
|
|
|
18
19
|
/** @internal */
|
|
@@ -101,13 +102,6 @@ export const EffectProto = {
|
|
|
101
102
|
...PipeInspectableProto,
|
|
102
103
|
[Symbol.iterator]() {
|
|
103
104
|
return new SingleShotGen(this) as any
|
|
104
|
-
},
|
|
105
|
-
toJSON(this: Primitive) {
|
|
106
|
-
return {
|
|
107
|
-
_id: "Effect",
|
|
108
|
-
op: this[identifier],
|
|
109
|
-
...(args in this ? { args: this[args] } : undefined)
|
|
110
|
-
}
|
|
111
105
|
}
|
|
112
106
|
}
|
|
113
107
|
|
|
@@ -176,19 +170,37 @@ export class CauseImpl<E> implements Cause.Cause<E> {
|
|
|
176
170
|
|
|
177
171
|
const annotationsMap = new WeakMap<object, ReadonlyMap<string, unknown>>()
|
|
178
172
|
|
|
173
|
+
const annotateReasonMap = <T extends ReasonBase<any>>(
|
|
174
|
+
reason: T,
|
|
175
|
+
annotations: ReadonlyMap<string, unknown>,
|
|
176
|
+
options?: { readonly overwrite?: boolean | undefined }
|
|
177
|
+
): T => {
|
|
178
|
+
if (annotations.size === 0) return reason
|
|
179
|
+
const overwrite = options?.overwrite === true
|
|
180
|
+
const newAnnotations = new Map(reason.annotations)
|
|
181
|
+
for (const [key, value] of annotations) {
|
|
182
|
+
if (overwrite || !newAnnotations.has(key)) {
|
|
183
|
+
newAnnotations.set(key, value)
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
// Keep the reason when nothing was added, so interrupts still match by identity.
|
|
187
|
+
if (!overwrite && newAnnotations.size === reason.annotations.size) return reason
|
|
188
|
+
const self = Object.assign(Object.create(Object.getPrototypeOf(reason)), reason)
|
|
189
|
+
self.annotations = newAnnotations
|
|
190
|
+
return self
|
|
191
|
+
}
|
|
192
|
+
|
|
179
193
|
/** @internal */
|
|
180
194
|
export abstract class ReasonBase<Tag extends string> implements Cause.Cause.ReasonProto<Tag> {
|
|
181
|
-
readonly [CauseReasonTypeId]: typeof CauseReasonTypeId
|
|
182
|
-
readonly annotations: ReadonlyMap<string, unknown>
|
|
183
|
-
readonly _tag: Tag
|
|
195
|
+
declare readonly [CauseReasonTypeId]: typeof CauseReasonTypeId
|
|
196
|
+
declare readonly annotations: ReadonlyMap<string, unknown>
|
|
197
|
+
declare readonly _tag: Tag
|
|
184
198
|
|
|
185
199
|
constructor(
|
|
186
200
|
_tag: Tag,
|
|
187
201
|
annotations: ReadonlyMap<string, unknown>,
|
|
188
202
|
originalError: unknown
|
|
189
203
|
) {
|
|
190
|
-
this[CauseReasonTypeId] = CauseReasonTypeId
|
|
191
|
-
this._tag = _tag
|
|
192
204
|
if (
|
|
193
205
|
annotations !== constEmptyAnnotations && typeof originalError === "object" && originalError !== null &&
|
|
194
206
|
annotations.size > 0
|
|
@@ -202,24 +214,16 @@ export abstract class ReasonBase<Tag extends string> implements Cause.Cause.Reas
|
|
|
202
214
|
}
|
|
203
215
|
annotationsMap.set(originalError, annotations)
|
|
204
216
|
}
|
|
217
|
+
this[CauseReasonTypeId] = CauseReasonTypeId
|
|
205
218
|
this.annotations = annotations
|
|
219
|
+
this._tag = _tag
|
|
206
220
|
}
|
|
207
221
|
|
|
208
222
|
annotate(
|
|
209
223
|
annotations: Context.Context<never>,
|
|
210
224
|
options?: { readonly overwrite?: boolean | undefined }
|
|
211
225
|
): this {
|
|
212
|
-
|
|
213
|
-
const newAnnotations = new Map(this.annotations)
|
|
214
|
-
annotations.mapUnsafe.forEach((value, key) => {
|
|
215
|
-
if (options?.overwrite !== true && newAnnotations.has(key)) return
|
|
216
|
-
newAnnotations.set(key, value)
|
|
217
|
-
})
|
|
218
|
-
// Keep the reason when nothing was added, so interrupts still match by identity.
|
|
219
|
-
if (options?.overwrite !== true && newAnnotations.size === this.annotations.size) return this
|
|
220
|
-
const self = Object.assign(Object.create(Object.getPrototypeOf(this)), this)
|
|
221
|
-
self.annotations = newAnnotations
|
|
222
|
-
return self
|
|
226
|
+
return annotateReasonMap(this, annotations.mapUnsafe, options)
|
|
223
227
|
}
|
|
224
228
|
|
|
225
229
|
pipe() {
|
|
@@ -227,13 +231,10 @@ export abstract class ReasonBase<Tag extends string> implements Cause.Cause.Reas
|
|
|
227
231
|
}
|
|
228
232
|
|
|
229
233
|
abstract toJSON(): unknown
|
|
234
|
+
abstract toString(): string
|
|
230
235
|
abstract [Equal.symbol](that: any): boolean
|
|
231
236
|
abstract [Hash.symbol](): number
|
|
232
237
|
|
|
233
|
-
toString() {
|
|
234
|
-
return format(this)
|
|
235
|
-
}
|
|
236
|
-
|
|
237
238
|
[NodeInspectSymbol]() {
|
|
238
239
|
return this.toString()
|
|
239
240
|
}
|
|
@@ -269,9 +270,9 @@ export class Fail<E> extends ReasonBase<"Fail"> implements Cause.Fail<E> {
|
|
|
269
270
|
)
|
|
270
271
|
}
|
|
271
272
|
[Hash.symbol](): number {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
)
|
|
273
|
+
// The error is hashed before the annotations, as both can run user code
|
|
274
|
+
const error = Hash.hash(this.error)
|
|
275
|
+
return hashCombine(hashCombine(Hash.hash(this.annotations), error), Hash.string(this._tag))
|
|
275
276
|
}
|
|
276
277
|
}
|
|
277
278
|
|
|
@@ -375,15 +376,45 @@ export class Die extends ReasonBase<"Die"> implements Cause.Die {
|
|
|
375
376
|
)
|
|
376
377
|
}
|
|
377
378
|
[Hash.symbol](): number {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
)
|
|
379
|
+
// The defect is hashed before the annotations, as both can run user code
|
|
380
|
+
const defect = Hash.hash(this.defect)
|
|
381
|
+
return hashCombine(hashCombine(Hash.hash(this.annotations), defect), Hash.string(this._tag))
|
|
381
382
|
}
|
|
382
383
|
}
|
|
383
384
|
|
|
384
385
|
/** @internal */
|
|
385
386
|
export const causeDie = (defect: unknown): Cause.Cause<never> => new CauseImpl([new Die(defect)])
|
|
386
387
|
|
|
388
|
+
/**
|
|
389
|
+
* Context.ts imports this module, so it registers `makeUnsafe` here instead.
|
|
390
|
+
*
|
|
391
|
+
* @internal
|
|
392
|
+
*/
|
|
393
|
+
export const contextMaker: {
|
|
394
|
+
makeUnsafe?: (mapUnsafe: ReadonlyMap<string, unknown>) => Context.Context<never>
|
|
395
|
+
} = {}
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Data-first `causeAnnotate` taking a plain annotation map, so the fiber
|
|
399
|
+
* runtime does not pull in `Function.dual` or wrap maps in a `Context`.
|
|
400
|
+
* Only reasons with their own `annotate` method receive a `Context`.
|
|
401
|
+
*
|
|
402
|
+
* @internal
|
|
403
|
+
*/
|
|
404
|
+
export const causeAnnotateMap = <E>(
|
|
405
|
+
self: Cause.Cause<E>,
|
|
406
|
+
annotations: ReadonlyMap<string, unknown>,
|
|
407
|
+
options?: { readonly overwrite?: boolean | undefined },
|
|
408
|
+
context?: Context.Context<never>
|
|
409
|
+
): Cause.Cause<E> => {
|
|
410
|
+
if (annotations.size === 0) return self
|
|
411
|
+
return new CauseImpl(self.reasons.map((f) =>
|
|
412
|
+
f.annotate as unknown === ReasonBase.prototype.annotate
|
|
413
|
+
? annotateReasonMap(f as any, annotations, options)
|
|
414
|
+
: f.annotate(context ?? contextMaker.makeUnsafe!(annotations), options)
|
|
415
|
+
))
|
|
416
|
+
}
|
|
417
|
+
|
|
387
418
|
/** @internal */
|
|
388
419
|
export const causeAnnotate: {
|
|
389
420
|
(
|
|
@@ -407,10 +438,7 @@ export const causeAnnotate: {
|
|
|
407
438
|
options?: {
|
|
408
439
|
readonly overwrite?: boolean | undefined
|
|
409
440
|
}
|
|
410
|
-
): Cause.Cause<E> =>
|
|
411
|
-
if (annotations.mapUnsafe.size === 0) return self
|
|
412
|
-
return new CauseImpl(self.reasons.map((f) => f.annotate(annotations, options)))
|
|
413
|
-
}
|
|
441
|
+
): Cause.Cause<E> => causeAnnotateMap(self, annotations.mapUnsafe, options, annotations)
|
|
414
442
|
)
|
|
415
443
|
|
|
416
444
|
/** @internal */
|
|
@@ -477,6 +505,13 @@ export const makePrimitiveProto = <Op extends string>(options: {
|
|
|
477
505
|
}): Primitive =>
|
|
478
506
|
({
|
|
479
507
|
...EffectProto,
|
|
508
|
+
toJSON(this: Primitive) {
|
|
509
|
+
return {
|
|
510
|
+
_id: "Effect",
|
|
511
|
+
op: this[identifier],
|
|
512
|
+
...(args in this ? { args: this[args] } : undefined)
|
|
513
|
+
}
|
|
514
|
+
},
|
|
480
515
|
[identifier]: options.op,
|
|
481
516
|
[evaluate]: options[evaluate] ?? defaultEvaluate,
|
|
482
517
|
[contA]: options[contA],
|
|
@@ -540,13 +575,16 @@ export const makeExit = <
|
|
|
540
575
|
fiber: FiberImpl<unknown, unknown>
|
|
541
576
|
) => Primitive | Yield
|
|
542
577
|
}): Fn => {
|
|
578
|
+
const opHash = Hash.string(options.op)
|
|
543
579
|
const Proto = {
|
|
544
580
|
[ExitTypeId]: ExitTypeId,
|
|
545
581
|
_tag: options.op,
|
|
546
582
|
get [options.prop](): any {
|
|
547
583
|
return (this as any)[args]
|
|
548
584
|
},
|
|
549
|
-
...
|
|
585
|
+
...EffectProto,
|
|
586
|
+
[identifier]: options.op,
|
|
587
|
+
[evaluate]: options[evaluate],
|
|
550
588
|
toString(this: any) {
|
|
551
589
|
return `${options.op}(${format(this[args])})`
|
|
552
590
|
},
|
|
@@ -565,7 +603,7 @@ export const makeExit = <
|
|
|
565
603
|
)
|
|
566
604
|
},
|
|
567
605
|
[Hash.symbol](this: any): number {
|
|
568
|
-
return
|
|
606
|
+
return hashCombine(opHash, Hash.hash(this[args]))
|
|
569
607
|
}
|
|
570
608
|
}
|
|
571
609
|
const ExitPrimitive = function(this: any, value: unknown) {
|
|
@@ -588,9 +626,7 @@ export const exitSucceed: <A>(a: A) => Exit.Exit<A> = makeExit({
|
|
|
588
626
|
})
|
|
589
627
|
|
|
590
628
|
/** @internal */
|
|
591
|
-
export const StackTraceKey =
|
|
592
|
-
key: "effect/Cause/StackTrace" satisfies typeof Cause.StackTrace.key
|
|
593
|
-
} as Context.Service<Cause.StackTrace, StackFrame>
|
|
629
|
+
export const StackTraceKey = "effect/Cause/StackTrace" satisfies typeof Cause.StackTrace.key
|
|
594
630
|
|
|
595
631
|
/** @internal */
|
|
596
632
|
export const InterruptorStackTrace = {
|
|
@@ -605,7 +641,7 @@ export const exitFailCause: <E>(cause: Cause.Cause<E>) => Exit.Exit<never, E> =
|
|
|
605
641
|
let cause = this[args]
|
|
606
642
|
let annotated = false
|
|
607
643
|
if (fiber.cache.stackFrame) {
|
|
608
|
-
cause =
|
|
644
|
+
cause = causeAnnotateMap(cause, new Map([[StackTraceKey, fiber.cache.stackFrame]]))
|
|
609
645
|
annotated = true
|
|
610
646
|
}
|
|
611
647
|
let cont = fiber.getCont(contE)
|
package/src/internal/dateTime.ts
CHANGED
|
@@ -334,14 +334,22 @@ export const makeZonedUnsafe = (input: DateTime.DateTime.Input, options?: {
|
|
|
334
334
|
}
|
|
335
335
|
|
|
336
336
|
/** @internal */
|
|
337
|
-
export const makeZoned
|
|
337
|
+
export const makeZoned = (
|
|
338
338
|
input: DateTime.DateTime.Input,
|
|
339
339
|
options?: {
|
|
340
340
|
readonly timeZone?: number | string | DateTime.TimeZone | undefined
|
|
341
341
|
readonly adjustForTimeZone?: boolean | undefined
|
|
342
342
|
readonly disambiguation?: DateTime.Disambiguation | undefined
|
|
343
343
|
}
|
|
344
|
-
)
|
|
344
|
+
): Option.Option<DateTime.Zoned> => {
|
|
345
|
+
// Do not pass `makeZonedUnsafe` to a top-level call such as `Option.liftThrowable`,
|
|
346
|
+
// or AOT compilers that prune per function treat `Intl` as reachable whenever this module loads.
|
|
347
|
+
try {
|
|
348
|
+
return Option.some(makeZonedUnsafe(input, options))
|
|
349
|
+
} catch {
|
|
350
|
+
return Option.none()
|
|
351
|
+
}
|
|
352
|
+
}
|
|
345
353
|
|
|
346
354
|
/** @internal */
|
|
347
355
|
export const make: <A extends DateTime.DateTime.Input>(input: A) => Option.Option<DateTime.DateTime.PreserveZone<A>> =
|
|
@@ -475,9 +483,14 @@ export const zoneMakeOffset = (offset: number): DateTime.TimeZone.Offset => {
|
|
|
475
483
|
}
|
|
476
484
|
|
|
477
485
|
/** @internal */
|
|
478
|
-
export const zoneMakeNamed
|
|
479
|
-
|
|
480
|
-
|
|
486
|
+
export const zoneMakeNamed = (zoneId: string): Option.Option<DateTime.TimeZone.Named> => {
|
|
487
|
+
// Plain function for the same reason as `makeZoned`.
|
|
488
|
+
try {
|
|
489
|
+
return Option.some(zoneMakeNamedUnsafe(zoneId))
|
|
490
|
+
} catch {
|
|
491
|
+
return Option.none()
|
|
492
|
+
}
|
|
493
|
+
}
|
|
481
494
|
|
|
482
495
|
/** @internal */
|
|
483
496
|
export const zoneMakeNamedEffect = (zoneId: string): Effect.Effect<DateTime.TimeZone.Named, IllegalArgumentError> =>
|
|
@@ -778,7 +791,7 @@ export const setParts: {
|
|
|
778
791
|
} = dual(
|
|
779
792
|
2,
|
|
780
793
|
(self: DateTime.DateTime, parts: Partial<DateTime.DateTime.PartsWithWeekday>): DateTime.DateTime =>
|
|
781
|
-
|
|
794
|
+
mutateWithOffset(self, (date) => setPartsDate(date, parts))
|
|
782
795
|
)
|
|
783
796
|
|
|
784
797
|
/** @internal */
|
|
@@ -937,6 +950,25 @@ export const mutate: {
|
|
|
937
950
|
return makeZonedFromAdjusted(newAdjustedDate.getTime(), self.zone, options?.disambiguation ?? "compatible")
|
|
938
951
|
})
|
|
939
952
|
|
|
953
|
+
// Keep the input offset when valid for the updated wall-clock time so repeated hours stay in the same occurrence.
|
|
954
|
+
const mutateWithOffset = (
|
|
955
|
+
self: DateTime.DateTime,
|
|
956
|
+
f: (date: Date) => void,
|
|
957
|
+
disambiguation: DateTime.Disambiguation = "compatible"
|
|
958
|
+
): DateTime.DateTime => {
|
|
959
|
+
if (self._tag === "Utc" || self.zone._tag === "Offset") {
|
|
960
|
+
return mutate(self, f, { disambiguation })
|
|
961
|
+
}
|
|
962
|
+
const date = toDate(self)
|
|
963
|
+
const offset = date.getTime() - Math.trunc(self.epochMilliseconds)
|
|
964
|
+
f(date)
|
|
965
|
+
const adjustedMillis = date.getTime()
|
|
966
|
+
const result = makeZonedProto(adjustedMillis - offset, self.zone)
|
|
967
|
+
return zonedOffset(result) === offset
|
|
968
|
+
? result
|
|
969
|
+
: makeZonedFromAdjusted(adjustedMillis, self.zone, disambiguation)
|
|
970
|
+
}
|
|
971
|
+
|
|
940
972
|
/** @internal */
|
|
941
973
|
export const mutateUtc: {
|
|
942
974
|
(f: (date: Date) => void): <A extends DateTime.DateTime>(self: A) => A
|
|
@@ -1089,24 +1121,11 @@ const mutateRounding = (
|
|
|
1089
1121
|
self: DateTime.DateTime,
|
|
1090
1122
|
part: DateTime.DateTime.UnitSingular,
|
|
1091
1123
|
f: (date: Date) => void,
|
|
1092
|
-
disambiguation
|
|
1093
|
-
): DateTime.DateTime =>
|
|
1094
|
-
|
|
1095
|
-
self
|
|
1096
|
-
|
|
1097
|
-
) {
|
|
1098
|
-
return mutate(self, f, { disambiguation })
|
|
1099
|
-
}
|
|
1100
|
-
// keep the input's offset so rounding stays in the same occurrence of a repeated hour
|
|
1101
|
-
const date = toDate(self)
|
|
1102
|
-
const offset = date.getTime() - Math.trunc(self.epochMilliseconds)
|
|
1103
|
-
f(date)
|
|
1104
|
-
const adjustedMillis = date.getTime()
|
|
1105
|
-
const result = makeZonedProto(adjustedMillis - offset, self.zone)
|
|
1106
|
-
return zonedOffset(result) === offset
|
|
1107
|
-
? result
|
|
1108
|
-
: makeZonedFromAdjusted(adjustedMillis, self.zone, disambiguation)
|
|
1109
|
-
}
|
|
1124
|
+
disambiguation?: DateTime.Disambiguation
|
|
1125
|
+
): DateTime.DateTime =>
|
|
1126
|
+
part === "day" || part === "week" || part === "month" || part === "year"
|
|
1127
|
+
? mutate(self, f, { disambiguation })
|
|
1128
|
+
: mutateWithOffset(self, f, disambiguation)
|
|
1110
1129
|
|
|
1111
1130
|
const startOfDate = (date: Date, part: DateTime.DateTime.UnitSingular, options?: {
|
|
1112
1131
|
readonly weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | undefined
|