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
|
@@ -346,6 +346,162 @@ export const filterStatusOk = (self: HttpClientResponse): Effect.Effect<HttpClie
|
|
|
346
346
|
})
|
|
347
347
|
)
|
|
348
348
|
|
|
349
|
+
/**
|
|
350
|
+
* Returns the links of the response's `Link` header with absolute targets.
|
|
351
|
+
*
|
|
352
|
+
* **Details**
|
|
353
|
+
*
|
|
354
|
+
* Each target is resolved against the response URL, which is the final URL
|
|
355
|
+
* after redirects, so `target` holds an absolute href. Links whose target does
|
|
356
|
+
* not resolve are dropped. A response without a `Link` header gives `[]`.
|
|
357
|
+
*
|
|
358
|
+
* **Gotchas**
|
|
359
|
+
*
|
|
360
|
+
* Links with an `anchor` parameter are dropped, because they describe a
|
|
361
|
+
* resource other than this response (RFC 8288 section 3.2). Parse the raw header
|
|
362
|
+
* with `Headers.parseLink` to read them.
|
|
363
|
+
*
|
|
364
|
+
* @see {@link link} to look up a single link by relation type
|
|
365
|
+
*
|
|
366
|
+
* @stability unstable
|
|
367
|
+
* @category accessors
|
|
368
|
+
* @since 4.1.6
|
|
369
|
+
*/
|
|
370
|
+
export const links = (self: HttpClientResponse): Array<Headers.Link> => {
|
|
371
|
+
const header = self.headers.link
|
|
372
|
+
if (header === undefined) return []
|
|
373
|
+
const base = self.url || undefined
|
|
374
|
+
const out: Array<Headers.Link> = []
|
|
375
|
+
for (const link of Headers.parseLink(header)) {
|
|
376
|
+
if (Object.hasOwn(link.params, "anchor")) continue
|
|
377
|
+
const url = resolveUrl(link.target, base)
|
|
378
|
+
if (url !== undefined) out.push({ ...link, target: url.href })
|
|
379
|
+
}
|
|
380
|
+
return out
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
const resolveUrl = (target: string, base: string | undefined): URL | undefined => {
|
|
384
|
+
try {
|
|
385
|
+
return new URL(target, base)
|
|
386
|
+
} catch {
|
|
387
|
+
return undefined
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Returns the URL of the first link in the response's `Link` header with the
|
|
393
|
+
* given relation type.
|
|
394
|
+
*
|
|
395
|
+
* **When to use**
|
|
396
|
+
*
|
|
397
|
+
* Use to follow pagination links such as `next` with `Stream.paginate`.
|
|
398
|
+
*
|
|
399
|
+
* **Details**
|
|
400
|
+
*
|
|
401
|
+
* The relation type is compared case-insensitively, and the URL is resolved
|
|
402
|
+
* against the response URL. Returns `Option.none()` when no link matches.
|
|
403
|
+
* Links are read as by {@link links}, so links with an `anchor` parameter
|
|
404
|
+
* never match.
|
|
405
|
+
*
|
|
406
|
+
* **Example** (Reading the next page link)
|
|
407
|
+
*
|
|
408
|
+
* ```ts import.meta.vitest
|
|
409
|
+
* import { Option } from "effect"
|
|
410
|
+
* import { HttpClientRequest, HttpClientResponse } from "effect/http"
|
|
411
|
+
*
|
|
412
|
+
* const response = HttpClientResponse.fromWeb(
|
|
413
|
+
* HttpClientRequest.get("https://example.com/items"),
|
|
414
|
+
* new Response(null, { headers: { link: '</items?page=2>; rel="next"' } })
|
|
415
|
+
* )
|
|
416
|
+
*
|
|
417
|
+
* Option.map(HttpClientResponse.link(response, "next"), (url) => url.href) // => Option.some("https://example.com/items?page=2")
|
|
418
|
+
* ```
|
|
419
|
+
*
|
|
420
|
+
* @see {@link links} to read every link
|
|
421
|
+
*
|
|
422
|
+
* @stability unstable
|
|
423
|
+
* @category accessors
|
|
424
|
+
* @since 4.1.6
|
|
425
|
+
*/
|
|
426
|
+
export const link: {
|
|
427
|
+
/**
|
|
428
|
+
* Returns the URL of the first link in the response's `Link` header with the
|
|
429
|
+
* given relation type.
|
|
430
|
+
*
|
|
431
|
+
* **When to use**
|
|
432
|
+
*
|
|
433
|
+
* Use to follow pagination links such as `next` with `Stream.paginate`.
|
|
434
|
+
*
|
|
435
|
+
* **Details**
|
|
436
|
+
*
|
|
437
|
+
* The relation type is compared case-insensitively, and the URL is resolved
|
|
438
|
+
* against the response URL. Returns `Option.none()` when no link matches.
|
|
439
|
+
* Links are read as by {@link links}, so links with an `anchor` parameter
|
|
440
|
+
* never match.
|
|
441
|
+
*
|
|
442
|
+
* **Example** (Reading the next page link)
|
|
443
|
+
*
|
|
444
|
+
* ```ts import.meta.vitest
|
|
445
|
+
* import { Option } from "effect"
|
|
446
|
+
* import { HttpClientRequest, HttpClientResponse } from "effect/http"
|
|
447
|
+
*
|
|
448
|
+
* const response = HttpClientResponse.fromWeb(
|
|
449
|
+
* HttpClientRequest.get("https://example.com/items"),
|
|
450
|
+
* new Response(null, { headers: { link: '</items?page=2>; rel="next"' } })
|
|
451
|
+
* )
|
|
452
|
+
*
|
|
453
|
+
* Option.map(HttpClientResponse.link(response, "next"), (url) => url.href) // => Option.some("https://example.com/items?page=2")
|
|
454
|
+
* ```
|
|
455
|
+
*
|
|
456
|
+
* @see {@link links} to read every link
|
|
457
|
+
*
|
|
458
|
+
* @stability unstable
|
|
459
|
+
* @category accessors
|
|
460
|
+
* @since 4.1.6
|
|
461
|
+
*/
|
|
462
|
+
(rel: string): (self: HttpClientResponse) => Option.Option<URL>
|
|
463
|
+
/**
|
|
464
|
+
* Returns the URL of the first link in the response's `Link` header with the
|
|
465
|
+
* given relation type.
|
|
466
|
+
*
|
|
467
|
+
* **When to use**
|
|
468
|
+
*
|
|
469
|
+
* Use to follow pagination links such as `next` with `Stream.paginate`.
|
|
470
|
+
*
|
|
471
|
+
* **Details**
|
|
472
|
+
*
|
|
473
|
+
* The relation type is compared case-insensitively, and the URL is resolved
|
|
474
|
+
* against the response URL. Returns `Option.none()` when no link matches.
|
|
475
|
+
* Links are read as by {@link links}, so links with an `anchor` parameter
|
|
476
|
+
* never match.
|
|
477
|
+
*
|
|
478
|
+
* **Example** (Reading the next page link)
|
|
479
|
+
*
|
|
480
|
+
* ```ts import.meta.vitest
|
|
481
|
+
* import { Option } from "effect"
|
|
482
|
+
* import { HttpClientRequest, HttpClientResponse } from "effect/http"
|
|
483
|
+
*
|
|
484
|
+
* const response = HttpClientResponse.fromWeb(
|
|
485
|
+
* HttpClientRequest.get("https://example.com/items"),
|
|
486
|
+
* new Response(null, { headers: { link: '</items?page=2>; rel="next"' } })
|
|
487
|
+
* )
|
|
488
|
+
*
|
|
489
|
+
* Option.map(HttpClientResponse.link(response, "next"), (url) => url.href) // => Option.some("https://example.com/items?page=2")
|
|
490
|
+
* ```
|
|
491
|
+
*
|
|
492
|
+
* @see {@link links} to read every link
|
|
493
|
+
*
|
|
494
|
+
* @stability unstable
|
|
495
|
+
* @category accessors
|
|
496
|
+
* @since 4.1.6
|
|
497
|
+
*/
|
|
498
|
+
(self: HttpClientResponse, rel: string): Option.Option<URL>
|
|
499
|
+
} = dual(2, (self: HttpClientResponse, rel: string): Option.Option<URL> => {
|
|
500
|
+
const type = rel.toLowerCase()
|
|
501
|
+
const found = links(self).find((link) => link.rel.includes(type))
|
|
502
|
+
return found === undefined ? Option.none() : Option.some(new URL(found.target))
|
|
503
|
+
})
|
|
504
|
+
|
|
349
505
|
// -----------------------------------------------------------------------------
|
|
350
506
|
// internal
|
|
351
507
|
// -----------------------------------------------------------------------------
|
package/src/http/HttpEffect.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @stability unstable
|
|
10
10
|
* @since 4.0.0
|
|
11
11
|
*/
|
|
12
|
-
import
|
|
12
|
+
import * as Cause from "../Cause.ts"
|
|
13
13
|
import * as Context from "../Context.ts"
|
|
14
14
|
import * as Effect from "../Effect.ts"
|
|
15
15
|
import * as Exit from "../Exit.ts"
|
|
@@ -17,6 +17,7 @@ import * as Fiber from "../Fiber.ts"
|
|
|
17
17
|
import { constVoid, dual } from "../Function.ts"
|
|
18
18
|
import { contA, contE } from "../internal/core.ts"
|
|
19
19
|
import { effectIsExit, fiberEnterUninterruptibleUnsafe, reportCauseUnsafe } from "../internal/effect.ts"
|
|
20
|
+
import { isSchemaError } from "../internal/schemaError.ts"
|
|
20
21
|
import * as Layer from "../Layer.ts"
|
|
21
22
|
import * as Scope from "../Scope.ts"
|
|
22
23
|
import * as Stream from "../Stream.ts"
|
|
@@ -26,6 +27,7 @@ import { type HttpMiddleware, isTracerDisabledUnsafe, tracer } from "./HttpMiddl
|
|
|
26
27
|
import { causeResponse, ClientAbort, HttpServerError, InternalError } from "./HttpServerError.ts"
|
|
27
28
|
import { HttpServerRequest } from "./HttpServerRequest.ts"
|
|
28
29
|
import * as Request from "./HttpServerRequest.ts"
|
|
30
|
+
import { isRespondable } from "./HttpServerRespondable.ts"
|
|
29
31
|
import type { HttpServerResponse } from "./HttpServerResponse.ts"
|
|
30
32
|
import * as Response from "./HttpServerResponse.ts"
|
|
31
33
|
import * as requestState from "./internal/requestState.ts"
|
|
@@ -63,7 +65,7 @@ export const toHandled = <E, R, EH, RH>(
|
|
|
63
65
|
const request = frame.request
|
|
64
66
|
return Effect.flatMapEager(causeResponse(cause), ([response, cause]) => {
|
|
65
67
|
const fiber = Fiber.getCurrent()!
|
|
66
|
-
|
|
68
|
+
reportServerCauseUnsafe(fiber, cause)
|
|
67
69
|
const handler = frame.preResponseHandler
|
|
68
70
|
const cont = cause.reasons.length === 0 ? Effect.succeed(response) : Effect.failCause(cause)
|
|
69
71
|
if (handler === undefined) {
|
|
@@ -122,7 +124,7 @@ export const toHandled = <E, R, EH, RH>(
|
|
|
122
124
|
responded :
|
|
123
125
|
Effect.matchCauseEffect(tracer(middleware(responded)), {
|
|
124
126
|
onFailure(cause): Effect.Effect<void, EH, RH> {
|
|
125
|
-
|
|
127
|
+
reportServerCauseUnsafe(Fiber.getCurrent()!, cause)
|
|
126
128
|
if (handledSymbol in request) return Effect.void
|
|
127
129
|
return Effect.matchCauseEffectEager(causeResponse(cause), {
|
|
128
130
|
onFailure(_) {
|
|
@@ -227,6 +229,24 @@ export const toHandled = <E, R, EH, RH>(
|
|
|
227
229
|
|
|
228
230
|
const handledSymbol = Symbol.for("effect/http/HttpEffect/handled")
|
|
229
231
|
|
|
232
|
+
// Client errors that `HttpServerRespondable.toResponseOrElse` answers with 400
|
|
233
|
+
// or 404. They are not reported.
|
|
234
|
+
const isClientError = (u: unknown) => !isRespondable(u) && (isSchemaError(u) || Cause.isNoSuchElementError(u))
|
|
235
|
+
|
|
236
|
+
// Both reporting paths can see the same cause. Reusing its filtered cause lets
|
|
237
|
+
// reporters skip the second report.
|
|
238
|
+
const reportableCauses = new WeakMap<Cause.Cause<unknown>, Cause.Cause<unknown>>()
|
|
239
|
+
|
|
240
|
+
const reportServerCauseUnsafe = (fiber: Fiber.Fiber<unknown, unknown>, cause: Cause.Cause<unknown>) => {
|
|
241
|
+
let reportable = reportableCauses.get(cause)
|
|
242
|
+
if (reportable === undefined) {
|
|
243
|
+
const reasons = cause.reasons.filter((reason) => reason._tag !== "Fail" || !isClientError(reason.error))
|
|
244
|
+
reportable = reasons.length === cause.reasons.length ? cause : Cause.fromReasons(reasons)
|
|
245
|
+
reportableCauses.set(cause, reportable)
|
|
246
|
+
}
|
|
247
|
+
reportCauseUnsafe(fiber, reportable)
|
|
248
|
+
}
|
|
249
|
+
|
|
230
250
|
/**
|
|
231
251
|
* Disables automatic closing for an HTTP request scope.
|
|
232
252
|
*
|
|
@@ -608,7 +608,7 @@ export const cors = (options?: {
|
|
|
608
608
|
? { "access-control-expose-headers": opts.exposedHeaders.join(",") }
|
|
609
609
|
: undefined
|
|
610
610
|
|
|
611
|
-
const maxAge = opts.maxAge
|
|
611
|
+
const maxAge = opts.maxAge === 0 || opts.maxAge
|
|
612
612
|
? { "access-control-max-age": opts.maxAge.toString() }
|
|
613
613
|
: undefined
|
|
614
614
|
|
|
@@ -289,7 +289,7 @@ const formatRequestMessage = (reason: string, description: string | undefined, i
|
|
|
289
289
|
|
|
290
290
|
/**
|
|
291
291
|
* Converts a failed handler cause into the HTTP response that should be sent and
|
|
292
|
-
* the cause
|
|
292
|
+
* the cause to propagate.
|
|
293
293
|
*
|
|
294
294
|
* **Details**
|
|
295
295
|
*
|
|
@@ -597,6 +597,132 @@ export const setHeader: {
|
|
|
597
597
|
makeResponse(self, Headers.set(self.headers, key, value))
|
|
598
598
|
)
|
|
599
599
|
|
|
600
|
+
/**
|
|
601
|
+
* Returns a response with the value added to the specified header, keeping any
|
|
602
|
+
* existing value.
|
|
603
|
+
*
|
|
604
|
+
* **When to use**
|
|
605
|
+
*
|
|
606
|
+
* Use when several parts of an application each add to a list-valued header,
|
|
607
|
+
* such as `Link` or `Vary`.
|
|
608
|
+
*
|
|
609
|
+
* **Details**
|
|
610
|
+
*
|
|
611
|
+
* An existing value is joined with the new one by `", "`, and an empty value
|
|
612
|
+
* leaves the response unchanged, so formatting an empty list of links is safe.
|
|
613
|
+
*
|
|
614
|
+
* **Gotchas**
|
|
615
|
+
*
|
|
616
|
+
* Do not append `Set-Cookie` this way; use the cookie APIs instead.
|
|
617
|
+
*
|
|
618
|
+
* **Example** (Adding canonical and alternate links)
|
|
619
|
+
*
|
|
620
|
+
* ```ts
|
|
621
|
+
* import { Headers, HttpServerResponse } from "effect/http"
|
|
622
|
+
*
|
|
623
|
+
* const withLinks = HttpServerResponse.appendHeader(
|
|
624
|
+
* "Link",
|
|
625
|
+
* Headers.formatLink([
|
|
626
|
+
* { target: "https://example.com/en", rel: ["canonical"] },
|
|
627
|
+
* { target: "https://example.com/de", rel: ["alternate"], params: { hreflang: "de" } }
|
|
628
|
+
* ])
|
|
629
|
+
* )
|
|
630
|
+
* ```
|
|
631
|
+
*
|
|
632
|
+
* @see {@link setHeader} to replace a header value
|
|
633
|
+
*
|
|
634
|
+
* @stability unstable
|
|
635
|
+
* @category combinators
|
|
636
|
+
* @since 4.1.6
|
|
637
|
+
*/
|
|
638
|
+
export const appendHeader: {
|
|
639
|
+
/**
|
|
640
|
+
* Returns a response with the value added to the specified header, keeping any
|
|
641
|
+
* existing value.
|
|
642
|
+
*
|
|
643
|
+
* **When to use**
|
|
644
|
+
*
|
|
645
|
+
* Use when several parts of an application each add to a list-valued header,
|
|
646
|
+
* such as `Link` or `Vary`.
|
|
647
|
+
*
|
|
648
|
+
* **Details**
|
|
649
|
+
*
|
|
650
|
+
* An existing value is joined with the new one by `", "`, and an empty value
|
|
651
|
+
* leaves the response unchanged, so formatting an empty list of links is safe.
|
|
652
|
+
*
|
|
653
|
+
* **Gotchas**
|
|
654
|
+
*
|
|
655
|
+
* Do not append `Set-Cookie` this way; use the cookie APIs instead.
|
|
656
|
+
*
|
|
657
|
+
* **Example** (Adding canonical and alternate links)
|
|
658
|
+
*
|
|
659
|
+
* ```ts
|
|
660
|
+
* import { Headers, HttpServerResponse } from "effect/http"
|
|
661
|
+
*
|
|
662
|
+
* const withLinks = HttpServerResponse.appendHeader(
|
|
663
|
+
* "Link",
|
|
664
|
+
* Headers.formatLink([
|
|
665
|
+
* { target: "https://example.com/en", rel: ["canonical"] },
|
|
666
|
+
* { target: "https://example.com/de", rel: ["alternate"], params: { hreflang: "de" } }
|
|
667
|
+
* ])
|
|
668
|
+
* )
|
|
669
|
+
* ```
|
|
670
|
+
*
|
|
671
|
+
* @see {@link setHeader} to replace a header value
|
|
672
|
+
*
|
|
673
|
+
* @stability unstable
|
|
674
|
+
* @category combinators
|
|
675
|
+
* @since 4.1.6
|
|
676
|
+
*/
|
|
677
|
+
(key: string, value: string): (self: HttpServerResponse) => HttpServerResponse
|
|
678
|
+
/**
|
|
679
|
+
* Returns a response with the value added to the specified header, keeping any
|
|
680
|
+
* existing value.
|
|
681
|
+
*
|
|
682
|
+
* **When to use**
|
|
683
|
+
*
|
|
684
|
+
* Use when several parts of an application each add to a list-valued header,
|
|
685
|
+
* such as `Link` or `Vary`.
|
|
686
|
+
*
|
|
687
|
+
* **Details**
|
|
688
|
+
*
|
|
689
|
+
* An existing value is joined with the new one by `", "`, and an empty value
|
|
690
|
+
* leaves the response unchanged, so formatting an empty list of links is safe.
|
|
691
|
+
*
|
|
692
|
+
* **Gotchas**
|
|
693
|
+
*
|
|
694
|
+
* Do not append `Set-Cookie` this way; use the cookie APIs instead.
|
|
695
|
+
*
|
|
696
|
+
* **Example** (Adding canonical and alternate links)
|
|
697
|
+
*
|
|
698
|
+
* ```ts
|
|
699
|
+
* import { Headers, HttpServerResponse } from "effect/http"
|
|
700
|
+
*
|
|
701
|
+
* const withLinks = HttpServerResponse.appendHeader(
|
|
702
|
+
* "Link",
|
|
703
|
+
* Headers.formatLink([
|
|
704
|
+
* { target: "https://example.com/en", rel: ["canonical"] },
|
|
705
|
+
* { target: "https://example.com/de", rel: ["alternate"], params: { hreflang: "de" } }
|
|
706
|
+
* ])
|
|
707
|
+
* )
|
|
708
|
+
* ```
|
|
709
|
+
*
|
|
710
|
+
* @see {@link setHeader} to replace a header value
|
|
711
|
+
*
|
|
712
|
+
* @stability unstable
|
|
713
|
+
* @category combinators
|
|
714
|
+
* @since 4.1.6
|
|
715
|
+
*/
|
|
716
|
+
(self: HttpServerResponse, key: string, value: string): HttpServerResponse
|
|
717
|
+
} = dual(
|
|
718
|
+
3,
|
|
719
|
+
(self: HttpServerResponse, key: string, value: string): HttpServerResponse => {
|
|
720
|
+
const headers = Headers.append(self.headers, key, value)
|
|
721
|
+
// makeResponse mutates the headers map in place, so never pass self.headers
|
|
722
|
+
return headers === self.headers ? self : makeResponse(self, headers)
|
|
723
|
+
}
|
|
724
|
+
)
|
|
725
|
+
|
|
600
726
|
/**
|
|
601
727
|
* Returns a response with the specified header removed.
|
|
602
728
|
*
|
package/src/http/Multipart.ts
CHANGED
|
@@ -350,11 +350,6 @@ export const PersistedFileSchema: PersistedFileSchema = Schema.declare(
|
|
|
350
350
|
id: "effect/http/PersistedFile",
|
|
351
351
|
payload: null
|
|
352
352
|
},
|
|
353
|
-
toCode: () => ({
|
|
354
|
-
runtime: "Multipart.PersistedFileSchema",
|
|
355
|
-
Type: "Multipart.PersistedFile",
|
|
356
|
-
importDeclarations: [`import * as Multipart from "effect/http/Multipart"`]
|
|
357
|
-
}),
|
|
358
353
|
expected: "PersistedFile",
|
|
359
354
|
toCodecJson: () =>
|
|
360
355
|
Schema.link<PersistedFile>()(
|
|
@@ -116,7 +116,7 @@ const pctEncodedRE = /%([0-9a-f]{2})/gi
|
|
|
116
116
|
* ISO-8859-1 is decoded byte by byte because `TextDecoder` treats it as
|
|
117
117
|
* windows-1252.
|
|
118
118
|
*/
|
|
119
|
-
function decodeExtValue(value: string): string | undefined {
|
|
119
|
+
export function decodeExtValue(value: string): string | undefined {
|
|
120
120
|
const match = extValueRE.exec(value)
|
|
121
121
|
if (match === null) {
|
|
122
122
|
return undefined
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as Context from "../../Context.ts"
|
|
2
|
+
import * as Redactable from "../../Redactable.ts"
|
|
3
|
+
import { stripSearchAndHash } from "./urlParams.ts"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The path of the request a client executes, as sent and as recorded in spans
|
|
7
|
+
* and errors.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export interface ClientPath {
|
|
12
|
+
readonly sent: string
|
|
13
|
+
readonly redacted: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** @internal */
|
|
17
|
+
export const CurrentClientPath = Context.Reference<ClientPath | undefined>(
|
|
18
|
+
"effect/http/internal/clientPath/CurrentClientPath",
|
|
19
|
+
{ defaultValue: () => undefined }
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
/** @internal */
|
|
23
|
+
export const currentClientPath = (): ClientPath | undefined =>
|
|
24
|
+
Context.get((globalThis as any)[Redactable.currentFiberTypeId]?.context ?? Context.empty(), CurrentClientPath)
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Replaces the path of a URL with its redacted form. A pathname that does not
|
|
28
|
+
* match the expected sent pathname is replaced by `/REDACTED`.
|
|
29
|
+
*
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
export const redactClientPath = (url: string, path: ClientPath): string => {
|
|
33
|
+
const head = stripSearchAndHash(url)
|
|
34
|
+
const origin = /^[a-z][a-z\d+.-]*:\/\/[^/]*/i.exec(head)?.[0] ?? ""
|
|
35
|
+
const pathname = head.slice(origin.length)
|
|
36
|
+
if (pathname === path.redacted) return url
|
|
37
|
+
const tail = url.slice(head.length)
|
|
38
|
+
return origin + (pathname === path.sent ? path.redacted : "/REDACTED") + tail
|
|
39
|
+
}
|
|
@@ -60,6 +60,10 @@ export const compile = (path: string, redactedParams: ReadonlyArray<string>): Te
|
|
|
60
60
|
return ambiguous ? parts.map((part) => typeof part === "string" ? part : { name: part.name, redacted: true }) : parts
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
/** @internal */
|
|
64
|
+
export const allParamNames = (path: string): ReadonlyArray<string> =>
|
|
65
|
+
compile(path, []).flatMap((part) => typeof part === "string" ? [] : [part.name])
|
|
66
|
+
|
|
63
67
|
const countCaptures = (regex: string): number => {
|
|
64
68
|
try {
|
|
65
69
|
return new RegExp(regex + "|").exec("")!.length - 1
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type * as Tracer from "../../Tracer.ts"
|
|
2
2
|
import * as Headers from "../Headers.ts"
|
|
3
3
|
import * as UrlParams from "../UrlParams.ts"
|
|
4
|
+
import { type ClientPath, redactClientPath } from "./clientPath.ts"
|
|
4
5
|
|
|
5
6
|
const defaultPorts: Record<string, number> = {
|
|
6
7
|
"http:": 80,
|
|
@@ -17,11 +18,13 @@ const defaultPorts: Record<string, number> = {
|
|
|
17
18
|
export const addUrlAttributes = (
|
|
18
19
|
span: Tracer.Span,
|
|
19
20
|
url: URL,
|
|
20
|
-
redactedNames: ReadonlyArray<string | RegExp
|
|
21
|
+
redactedNames: ReadonlyArray<string | RegExp>,
|
|
22
|
+
path?: ClientPath | undefined
|
|
21
23
|
): void => {
|
|
24
|
+
const redactPath = (url: string) => path === undefined ? url : redactClientPath(url, path)
|
|
22
25
|
const query = UrlParams.redactUrl(url.search, redactedNames).slice(1)
|
|
23
|
-
span.attribute("url.full", UrlParams.redactUrl(url.href, redactedNames))
|
|
24
|
-
span.attribute("url.path", url.pathname)
|
|
26
|
+
span.attribute("url.full", redactPath(UrlParams.redactUrl(url.href, redactedNames)))
|
|
27
|
+
span.attribute("url.path", redactPath(url.pathname))
|
|
25
28
|
if (query !== "") {
|
|
26
29
|
span.attribute("url.query", query)
|
|
27
30
|
}
|
package/src/http-api/HttpApi.ts
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import type { NonEmptyReadonlyArray } from "../Array.ts"
|
|
13
13
|
import * as Context from "../Context.ts"
|
|
14
|
+
import * as HttpMethod from "../http/HttpMethod.ts"
|
|
14
15
|
import type { PathInput } from "../http/HttpRouter.ts"
|
|
15
16
|
import * as InternalRecord from "../internal/record.ts"
|
|
16
17
|
import { type Pipeable, pipeArguments } from "../Pipeable.ts"
|
|
@@ -23,6 +24,7 @@ import * as HttpApiEndpoint from "./HttpApiEndpoint.ts"
|
|
|
23
24
|
import type * as HttpApiGroup from "./HttpApiGroup.ts"
|
|
24
25
|
import type * as HttpApiMiddleware from "./HttpApiMiddleware.ts"
|
|
25
26
|
import * as HttpApiSchema from "./HttpApiSchema.ts"
|
|
27
|
+
import { getRedactedKeys } from "./internal/redactedKeys.ts"
|
|
26
28
|
|
|
27
29
|
const TypeId = "~effect/http-api/HttpApi"
|
|
28
30
|
|
|
@@ -512,8 +514,8 @@ export class ErrorParseOptions extends Context.Service<
|
|
|
512
514
|
* the names on the group to keep both.
|
|
513
515
|
* - Only URL and header attributes use these names. `user_agent.original` and
|
|
514
516
|
* the messages of span errors are recorded as is.
|
|
515
|
-
* - `params` apply to
|
|
516
|
-
*
|
|
517
|
+
* - `params` apply to client spans and error messages as well as server spans
|
|
518
|
+
* and `HttpMiddleware.logger` entries.
|
|
517
519
|
* - `HttpApiBuilder.endpoint` returns a handler without a route, so set
|
|
518
520
|
* `redactedParams` on the route it is mounted with.
|
|
519
521
|
*
|
|
@@ -590,26 +592,45 @@ export const getEndpointRedactedNames = (
|
|
|
590
592
|
): EndpointRedactedNames | undefined => {
|
|
591
593
|
const query: Array<string | RegExp> = []
|
|
592
594
|
const headers: Array<string | RegExp> = []
|
|
595
|
+
const addQuery = (name: string | RegExp) => {
|
|
596
|
+
query.push(name)
|
|
597
|
+
if (typeof name === "string") query.push(new RegExp(`^${RegExp_.escape(name)}\\[`, "i"))
|
|
598
|
+
}
|
|
593
599
|
for (const annotations of [api.annotations, group.annotations, endpoint.annotations]) {
|
|
594
600
|
const options = Context.getOrUndefined(annotations, RedactedNames)
|
|
595
601
|
if (options === undefined) continue
|
|
596
|
-
|
|
597
|
-
query.push(name)
|
|
598
|
-
if (typeof name === "string") query.push(new RegExp(`^${RegExp_.escape(name)}\\[`, "i"))
|
|
599
|
-
}
|
|
602
|
+
options.query?.forEach(addQuery)
|
|
600
603
|
if (options.headers !== undefined) headers.push(...options.headers)
|
|
601
604
|
}
|
|
605
|
+
// Fields whose schema holds a `Redacted` are redacted without being listed.
|
|
606
|
+
// Payloads of methods without a body are sent as query parameters.
|
|
607
|
+
const querySchemas = HttpMethod.hasBody(endpoint.method)
|
|
608
|
+
? [endpoint.query]
|
|
609
|
+
: [endpoint.query, ...HttpApiEndpoint.getPayloadSchemas(endpoint)]
|
|
610
|
+
for (const schema of querySchemas) (getRedactedKeys(schema) ?? redactAll).forEach(addQuery)
|
|
611
|
+
headers.push(...(getRedactedKeys(endpoint.headers) ?? redactAll))
|
|
602
612
|
return query.length === 0 && headers.length === 0 ? undefined : { query, headers }
|
|
603
613
|
}
|
|
604
614
|
|
|
605
615
|
/**
|
|
616
|
+
* Returns the path param names to redact and whether to redact every param in
|
|
617
|
+
* the endpoint path (when the schema holds a `Redacted` under unknown wire names).
|
|
618
|
+
*
|
|
606
619
|
* @internal
|
|
607
620
|
*/
|
|
608
621
|
export const getEndpointRedactedParams = (
|
|
609
622
|
api: Pick<Top, "annotations">,
|
|
610
623
|
group: HttpApiGroup.Top,
|
|
611
624
|
endpoint: HttpApiEndpoint.Top
|
|
612
|
-
): ReadonlyArray<string
|
|
613
|
-
[api.annotations, group.annotations, endpoint.annotations].flatMap((annotations) =>
|
|
625
|
+
): { readonly names: ReadonlyArray<string>; readonly all: boolean } => {
|
|
626
|
+
const explicit = [api.annotations, group.annotations, endpoint.annotations].flatMap((annotations) =>
|
|
614
627
|
Context.getOrUndefined(annotations, RedactedNames)?.params ?? []
|
|
615
628
|
)
|
|
629
|
+
const keys = getRedactedKeys(endpoint.params)
|
|
630
|
+
return keys === undefined
|
|
631
|
+
? { names: explicit, all: true }
|
|
632
|
+
: { names: [...explicit, ...keys], all: false }
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
// Matches every name, for a schema whose wire names are unknown.
|
|
636
|
+
const redactAll: ReadonlyArray<RegExp> = [/^/]
|
|
@@ -32,6 +32,7 @@ import * as Respondable from "../http/HttpServerRespondable.ts"
|
|
|
32
32
|
import * as Response from "../http/HttpServerResponse.ts"
|
|
33
33
|
import type { HttpServerResponse } from "../http/HttpServerResponse.ts"
|
|
34
34
|
import * as MediaType from "../http/internal/mediaType.ts"
|
|
35
|
+
import * as RedactedPath from "../http/internal/redactedPath.ts"
|
|
35
36
|
import { addRedactedNamesUnsafe } from "../http/internal/requestState.ts"
|
|
36
37
|
import * as Multipart from "../http/Multipart.ts"
|
|
37
38
|
import * as UrlParams from "../http/UrlParams.ts"
|
|
@@ -1077,13 +1078,17 @@ export function handlerToRoute(
|
|
|
1077
1078
|
context: Context.Context<any>
|
|
1078
1079
|
): HttpRouter.Route<any, any> {
|
|
1079
1080
|
const endpoint = handler.endpoint
|
|
1081
|
+
const path = HttpApiPath.toRouterPath(endpoint.path, endpoint.params)
|
|
1082
|
+
const redactedParams = HttpApi.getEndpointRedactedParams(api, group, endpoint)
|
|
1080
1083
|
return HttpRouter.route(
|
|
1081
1084
|
endpoint.method,
|
|
1082
|
-
|
|
1085
|
+
path as HttpRouter.PathInput,
|
|
1083
1086
|
handlerToHttpEffect(api, group, endpoint, context, handler.handler, handler.isRaw),
|
|
1084
1087
|
{
|
|
1085
1088
|
uninterruptible: handler.uninterruptible,
|
|
1086
|
-
redactedParams:
|
|
1089
|
+
redactedParams: redactedParams.all
|
|
1090
|
+
? [...redactedParams.names, ...RedactedPath.allParamNames(path)]
|
|
1091
|
+
: redactedParams.names
|
|
1087
1092
|
}
|
|
1088
1093
|
)
|
|
1089
1094
|
}
|