effect 4.0.6 → 4.0.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/dist/Arbitrary.d.ts +10 -2
- package/dist/Arbitrary.d.ts.map +1 -1
- package/dist/Arbitrary.js +2 -1
- package/dist/Arbitrary.js.map +1 -1
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +21 -6
- package/dist/Channel.js.map +1 -1
- package/dist/Data.d.ts +54 -235
- package/dist/Data.d.ts.map +1 -1
- package/dist/Data.js.map +1 -1
- package/dist/Effect.d.ts +1 -1
- package/dist/Effect.js +1 -1
- package/dist/Equal.d.ts.map +1 -1
- package/dist/Equal.js +8 -1
- package/dist/Equal.js.map +1 -1
- package/dist/Exit.d.ts +3 -3
- package/dist/Exit.d.ts.map +1 -1
- package/dist/Exit.js.map +1 -1
- package/dist/Formatter.d.ts.map +1 -1
- package/dist/Formatter.js +27 -13
- package/dist/Formatter.js.map +1 -1
- package/dist/Hash.d.ts.map +1 -1
- package/dist/Hash.js +4 -1
- package/dist/Hash.js.map +1 -1
- package/dist/JsonPatch.js +4 -0
- package/dist/JsonPatch.js.map +1 -1
- package/dist/JsonSchema.d.ts.map +1 -1
- package/dist/JsonSchema.js +13 -40
- package/dist/JsonSchema.js.map +1 -1
- package/dist/Metric.d.ts +3 -3
- package/dist/MutableList.d.ts +5 -2
- package/dist/MutableList.d.ts.map +1 -1
- package/dist/MutableList.js +7 -5
- package/dist/MutableList.js.map +1 -1
- package/dist/MutableRef.d.ts.map +1 -1
- package/dist/MutableRef.js +7 -0
- package/dist/MutableRef.js.map +1 -1
- package/dist/PartitionedSemaphore.d.ts +2 -1
- package/dist/PartitionedSemaphore.d.ts.map +1 -1
- package/dist/PartitionedSemaphore.js +22 -12
- package/dist/PartitionedSemaphore.js.map +1 -1
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +77 -27
- package/dist/Pool.js.map +1 -1
- package/dist/PubSub.d.ts.map +1 -1
- package/dist/PubSub.js +5 -6
- package/dist/PubSub.js.map +1 -1
- package/dist/Ref.d.ts.map +1 -1
- package/dist/Ref.js +8 -0
- package/dist/Ref.js.map +1 -1
- package/dist/Schedule.js +1 -1
- package/dist/Schedule.js.map +1 -1
- package/dist/Schema.d.ts +24 -8
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +37 -28
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +4 -2
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +14 -17
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +48 -22
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +19 -10
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +23 -13
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +4 -1
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +9 -2
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/Semaphore.d.ts.map +1 -1
- package/dist/Semaphore.js +54 -35
- package/dist/Semaphore.js.map +1 -1
- package/dist/Sink.d.ts.map +1 -1
- package/dist/Sink.js +7 -2
- package/dist/Sink.js.map +1 -1
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +22 -10
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +3 -0
- package/dist/String.d.ts.map +1 -1
- package/dist/String.js +3 -0
- package/dist/String.js.map +1 -1
- package/dist/Tracer.d.ts +11 -1
- package/dist/Tracer.d.ts.map +1 -1
- package/dist/Tracer.js +6 -1
- package/dist/Tracer.js.map +1 -1
- package/dist/ai/LanguageModel.d.ts.map +1 -1
- package/dist/ai/LanguageModel.js +9 -0
- package/dist/ai/LanguageModel.js.map +1 -1
- package/dist/ai/McpSchema.d.ts +110 -110
- package/dist/ai/McpSchema.d.ts.map +1 -1
- package/dist/ai/McpServer.d.ts.map +1 -1
- package/dist/ai/McpServer.js +21 -15
- package/dist/ai/McpServer.js.map +1 -1
- package/dist/ai/Prompt.d.ts +52 -0
- package/dist/ai/Prompt.d.ts.map +1 -1
- package/dist/ai/Prompt.js +38 -0
- package/dist/ai/Prompt.js.map +1 -1
- package/dist/ai/Response.d.ts +16 -3
- package/dist/ai/Response.d.ts.map +1 -1
- package/dist/ai/Response.js +4 -0
- package/dist/ai/Response.js.map +1 -1
- package/dist/ai/Tool.d.ts +24 -0
- package/dist/ai/Tool.d.ts.map +1 -1
- package/dist/ai/Tool.js +5 -2
- package/dist/ai/Tool.js.map +1 -1
- package/dist/ai/Toolkit.d.ts.map +1 -1
- package/dist/ai/Toolkit.js +8 -1
- package/dist/ai/Toolkit.js.map +1 -1
- package/dist/cli/Argument.d.ts +15 -0
- package/dist/cli/Argument.d.ts.map +1 -1
- package/dist/cli/Argument.js +5 -0
- package/dist/cli/Argument.js.map +1 -1
- package/dist/cli/CliError.d.ts +78 -0
- package/dist/cli/CliError.d.ts.map +1 -1
- package/dist/cli/CliError.js +65 -3
- package/dist/cli/CliError.js.map +1 -1
- package/dist/cli/CliOutput.d.ts +155 -6
- package/dist/cli/CliOutput.d.ts.map +1 -1
- package/dist/cli/CliOutput.js +62 -6
- package/dist/cli/CliOutput.js.map +1 -1
- package/dist/cli/Command.d.ts +24 -16
- package/dist/cli/Command.d.ts.map +1 -1
- package/dist/cli/Command.js +59 -29
- package/dist/cli/Command.js.map +1 -1
- package/dist/cli/Completions.d.ts +58 -0
- package/dist/cli/Completions.d.ts.map +1 -1
- package/dist/cli/Completions.js +49 -9
- package/dist/cli/Completions.js.map +1 -1
- package/dist/cli/Flag.d.ts +15 -0
- package/dist/cli/Flag.d.ts.map +1 -1
- package/dist/cli/Flag.js +5 -0
- package/dist/cli/Flag.js.map +1 -1
- package/dist/cli/GlobalFlag.d.ts.map +1 -1
- package/dist/cli/GlobalFlag.js +15 -7
- package/dist/cli/GlobalFlag.js.map +1 -1
- package/dist/cli/Param.d.ts +9 -0
- package/dist/cli/Param.d.ts.map +1 -1
- package/dist/cli/Param.js +21 -2
- package/dist/cli/Param.js.map +1 -1
- package/dist/cli/TerminalCapabilities.d.ts +3 -2
- package/dist/cli/TerminalCapabilities.d.ts.map +1 -1
- package/dist/cli/TerminalCapabilities.js +3 -1
- package/dist/cli/TerminalCapabilities.js.map +1 -1
- package/dist/cli/internal/completions/bash.js +73 -27
- package/dist/cli/internal/completions/bash.js.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.js +45 -10
- package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/cluster/MessageStorage.d.ts +23 -45
- package/dist/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/cluster/MessageStorage.js +6 -7
- package/dist/cluster/MessageStorage.js.map +1 -1
- package/dist/cluster/Sharding.d.ts.map +1 -1
- package/dist/cluster/Sharding.js +61 -21
- package/dist/cluster/Sharding.js.map +1 -1
- package/dist/cluster/ShardingConfig.d.ts +10 -0
- package/dist/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/cluster/ShardingConfig.js.map +1 -1
- package/dist/cluster/Snowflake.d.ts.map +1 -1
- package/dist/cluster/Snowflake.js +3 -7
- package/dist/cluster/Snowflake.js.map +1 -1
- package/dist/cluster/SqlRunnerStorage.d.ts.map +1 -1
- package/dist/cluster/SqlRunnerStorage.js +87 -39
- package/dist/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/cluster/internal/entityManager.js +54 -20
- package/dist/cluster/internal/entityManager.js.map +1 -1
- package/dist/devtools/DevToolsClient.d.ts.map +1 -1
- package/dist/devtools/DevToolsClient.js +2 -0
- package/dist/devtools/DevToolsClient.js.map +1 -1
- package/dist/encoding/Base64.js +36 -0
- package/dist/encoding/Base64.js.map +1 -1
- package/dist/encoding/Sse.d.ts.map +1 -1
- package/dist/encoding/Sse.js +3 -3
- package/dist/encoding/Sse.js.map +1 -1
- package/dist/encoding/Toml.d.ts.map +1 -1
- package/dist/encoding/Toml.js +21 -16
- package/dist/encoding/Toml.js.map +1 -1
- package/dist/eventlog/SqlEventJournal.d.ts.map +1 -1
- package/dist/eventlog/SqlEventJournal.js +47 -27
- package/dist/eventlog/SqlEventJournal.js.map +1 -1
- package/dist/eventlog/internal/conflicts.d.ts +0 -1
- package/dist/eventlog/internal/conflicts.d.ts.map +1 -1
- package/dist/eventlog/internal/conflicts.js +0 -3
- package/dist/eventlog/internal/conflicts.js.map +1 -1
- package/dist/http/Cookies.d.ts.map +1 -1
- package/dist/http/Cookies.js +10 -9
- package/dist/http/Cookies.js.map +1 -1
- package/dist/http/HttpClient.d.ts +423 -0
- package/dist/http/HttpClient.d.ts.map +1 -1
- package/dist/http/HttpClient.js +231 -7
- package/dist/http/HttpClient.js.map +1 -1
- package/dist/http/HttpClientError.d.ts +8 -1
- package/dist/http/HttpClientError.d.ts.map +1 -1
- package/dist/http/HttpClientError.js +37 -1
- package/dist/http/HttpClientError.js.map +1 -1
- package/dist/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/http/HttpClientRequest.js +1 -1
- package/dist/http/HttpClientRequest.js.map +1 -1
- package/dist/http/HttpMiddleware.d.ts +1 -1
- package/dist/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/http/HttpMiddleware.js +14 -16
- package/dist/http/HttpMiddleware.js.map +1 -1
- package/dist/http/HttpRouter.d.ts.map +1 -1
- package/dist/http/HttpRouter.js +2 -1
- package/dist/http/HttpRouter.js.map +1 -1
- package/dist/http/HttpServerError.js +2 -2
- package/dist/http/HttpServerError.js.map +1 -1
- package/dist/http/HttpServerRequest.d.ts +6 -1
- package/dist/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/http/HttpServerRequest.js +73 -10
- package/dist/http/HttpServerRequest.js.map +1 -1
- package/dist/http/HttpStaticServer.d.ts.map +1 -1
- package/dist/http/HttpStaticServer.js +48 -21
- package/dist/http/HttpStaticServer.js.map +1 -1
- package/dist/http/MultipartParser/internal/contentType.js +3 -3
- package/dist/http/UrlParams.d.ts +3 -1
- package/dist/http/UrlParams.d.ts.map +1 -1
- package/dist/http/UrlParams.js +4 -2
- package/dist/http/UrlParams.js.map +1 -1
- package/dist/http/internal/compression.js +4 -5
- package/dist/http/internal/compression.js.map +1 -1
- package/dist/http/internal/decompression.js +3 -0
- package/dist/http/internal/decompression.js.map +1 -1
- package/dist/http/internal/httpBody.js +8 -1
- package/dist/http/internal/httpBody.js.map +1 -1
- package/dist/http/internal/urlParams.js +25 -0
- package/dist/http/internal/urlParams.js.map +1 -1
- package/dist/http-api/HttpApi.d.ts +3 -6
- package/dist/http-api/HttpApi.d.ts.map +1 -1
- package/dist/http-api/HttpApi.js +3 -6
- 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 +27 -11
- package/dist/http-api/HttpApiBuilder.js.map +1 -1
- package/dist/http-api/HttpApiClient.d.ts +77 -7
- package/dist/http-api/HttpApiClient.d.ts.map +1 -1
- package/dist/http-api/HttpApiClient.js +142 -44
- package/dist/http-api/HttpApiClient.js.map +1 -1
- package/dist/http-api/HttpApiEndpoint.d.ts +24 -7
- package/dist/http-api/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/http-api/HttpApiEndpoint.js +109 -27
- package/dist/http-api/HttpApiEndpoint.js.map +1 -1
- package/dist/http-api/HttpApiSchema.d.ts +76 -29
- package/dist/http-api/HttpApiSchema.d.ts.map +1 -1
- package/dist/http-api/HttpApiSchema.js +70 -59
- package/dist/http-api/HttpApiSchema.js.map +1 -1
- package/dist/http-api/HttpApiTest.d.ts.map +1 -1
- package/dist/http-api/HttpApiTest.js +3 -2
- package/dist/http-api/HttpApiTest.js.map +1 -1
- package/dist/http-api/OpenApi.d.ts.map +1 -1
- package/dist/http-api/OpenApi.js +25 -16
- package/dist/http-api/OpenApi.js.map +1 -1
- package/dist/http-api/internal/toCodecHttpProperties.d.ts +2 -0
- package/dist/http-api/internal/toCodecHttpProperties.d.ts.map +1 -0
- package/dist/http-api/internal/toCodecHttpProperties.js +38 -0
- package/dist/http-api/internal/toCodecHttpProperties.js.map +1 -0
- package/dist/internal/arbitrary/runner.d.ts.map +1 -1
- package/dist/internal/arbitrary/runner.js +120 -44
- package/dist/internal/arbitrary/runner.js.map +1 -1
- package/dist/internal/core.js +2 -0
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/effect.js +21 -13
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/equal.js +14 -0
- package/dist/internal/equal.js.map +1 -1
- package/dist/internal/jsonSchema.d.ts +2 -0
- package/dist/internal/jsonSchema.d.ts.map +1 -0
- package/dist/internal/jsonSchema.js +28 -0
- package/dist/internal/jsonSchema.js.map +1 -0
- package/dist/internal/matcher.js +1 -1
- package/dist/internal/matcher.js.map +1 -1
- package/dist/internal/schema/compilerRegistry.js +4 -1
- package/dist/internal/schema/compilerRegistry.js.map +1 -1
- package/dist/internal/schema/content.d.ts +2 -0
- package/dist/internal/schema/content.d.ts.map +1 -0
- package/dist/internal/schema/content.js +13 -0
- package/dist/internal/schema/content.js.map +1 -0
- package/dist/internal/schema/fromJsonSchemaDocument.js +173 -185
- package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -1
- package/dist/internal/schema/fromRepresentation.js +2 -1
- package/dist/internal/schema/fromRepresentation.js.map +1 -1
- package/dist/internal/schema/standardSchema.js +8 -2
- package/dist/internal/schema/standardSchema.js.map +1 -1
- package/dist/internal/schema/toCodeDocument.js +3 -3
- package/dist/internal/schema/toCodeDocument.js.map +1 -1
- package/dist/internal/schema/toCodec.js +21 -24
- package/dist/internal/schema/toCodec.js.map +1 -1
- package/dist/internal/schema/toJsonSchemaDocument.js +205 -140
- package/dist/internal/schema/toJsonSchemaDocument.js.map +1 -1
- package/dist/internal/schema/toRepresentation.js +107 -129
- package/dist/internal/schema/toRepresentation.js.map +1 -1
- package/dist/internal/sql.d.ts +2 -0
- package/dist/internal/sql.d.ts.map +1 -0
- package/dist/internal/sql.js +13 -0
- package/dist/internal/sql.js.map +1 -0
- package/dist/internal/version.js +1 -1
- package/dist/observability/OtlpProxy.d.ts +154 -0
- package/dist/observability/OtlpProxy.d.ts.map +1 -0
- package/dist/observability/OtlpProxy.js +235 -0
- package/dist/observability/OtlpProxy.js.map +1 -0
- package/dist/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/observability/OtlpTracer.js +4 -0
- package/dist/observability/OtlpTracer.js.map +1 -1
- package/dist/observability/index.d.ts +5 -0
- package/dist/observability/index.d.ts.map +1 -1
- package/dist/observability/index.js +5 -0
- package/dist/observability/index.js.map +1 -1
- package/dist/persistence/CircuitBreaker.d.ts +897 -0
- package/dist/persistence/CircuitBreaker.d.ts.map +1 -0
- package/dist/persistence/CircuitBreaker.js +1165 -0
- package/dist/persistence/CircuitBreaker.js.map +1 -0
- package/dist/persistence/Redis.d.ts +78 -2
- package/dist/persistence/Redis.d.ts.map +1 -1
- package/dist/persistence/Redis.js +62 -7
- package/dist/persistence/Redis.js.map +1 -1
- package/dist/persistence/index.d.ts +5 -0
- package/dist/persistence/index.d.ts.map +1 -1
- package/dist/persistence/index.js +5 -0
- package/dist/persistence/index.js.map +1 -1
- package/dist/process/ChildProcess.d.ts +30 -4
- package/dist/process/ChildProcess.d.ts.map +1 -1
- package/dist/process/ChildProcess.js.map +1 -1
- package/dist/process/ChildProcessSpawner.d.ts +30 -0
- package/dist/process/ChildProcessSpawner.d.ts.map +1 -1
- package/dist/process/ChildProcessSpawner.js +5 -2
- package/dist/process/ChildProcessSpawner.js.map +1 -1
- package/dist/reactivity/AsyncResult.d.ts +1 -1
- package/dist/reactivity/AsyncResult.d.ts.map +1 -1
- package/dist/rpc/RpcClient.d.ts.map +1 -1
- package/dist/rpc/RpcClient.js +9 -8
- package/dist/rpc/RpcClient.js.map +1 -1
- package/dist/rpc/RpcSerialization.d.ts +14 -0
- package/dist/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/rpc/RpcSerialization.js +20 -8
- package/dist/rpc/RpcSerialization.js.map +1 -1
- package/dist/rpc/RpcServer.d.ts.map +1 -1
- package/dist/rpc/RpcServer.js +11 -1
- package/dist/rpc/RpcServer.js.map +1 -1
- package/dist/rpc/RpcTest.d.ts +1 -0
- package/dist/rpc/RpcTest.d.ts.map +1 -1
- package/dist/rpc/RpcTest.js +1 -0
- package/dist/rpc/RpcTest.js.map +1 -1
- package/dist/sql/Migrator.d.ts +2 -1
- package/dist/sql/Migrator.d.ts.map +1 -1
- package/dist/sql/Migrator.js +11 -8
- package/dist/sql/Migrator.js.map +1 -1
- package/dist/sql/SqlClient.d.ts +9 -4
- package/dist/sql/SqlClient.d.ts.map +1 -1
- package/dist/sql/SqlClient.js +8 -1
- package/dist/sql/SqlClient.js.map +1 -1
- package/dist/sql/SqlResolver.d.ts +4 -0
- package/dist/sql/SqlResolver.d.ts.map +1 -1
- package/dist/sql/SqlResolver.js +18 -4
- package/dist/sql/SqlResolver.js.map +1 -1
- package/dist/sql/Statement.d.ts +7 -0
- package/dist/sql/Statement.d.ts.map +1 -1
- package/dist/sql/Statement.js +21 -2
- package/dist/sql/Statement.js.map +1 -1
- package/dist/workflow/DurableDeferred.d.ts.map +1 -1
- package/dist/workflow/DurableDeferred.js +21 -2
- package/dist/workflow/DurableDeferred.js.map +1 -1
- package/package.json +1 -1
- package/src/Arbitrary.ts +10 -2
- package/src/Channel.ts +47 -18
- package/src/Data.ts +60 -265
- package/src/Effect.ts +1 -1
- package/src/Equal.ts +8 -1
- package/src/Exit.ts +3 -3
- package/src/Formatter.ts +28 -13
- package/src/Hash.ts +4 -1
- package/src/JsonPatch.ts +4 -0
- package/src/JsonSchema.ts +12 -40
- package/src/Metric.ts +3 -3
- package/src/MutableList.ts +7 -5
- package/src/MutableRef.ts +8 -1
- package/src/PartitionedSemaphore.ts +24 -13
- package/src/Pool.ts +109 -37
- package/src/PubSub.ts +5 -6
- package/src/Ref.ts +8 -0
- package/src/Schedule.ts +1 -1
- package/src/Schema.ts +48 -25
- package/src/SchemaAST.ts +20 -20
- package/src/SchemaParser.ts +51 -18
- package/src/SchemaRepresentation.ts +31 -34
- package/src/SchemaTransformation.ts +9 -2
- package/src/Semaphore.ts +67 -40
- package/src/Sink.ts +15 -2
- package/src/Stream.ts +33 -16
- package/src/String.ts +3 -0
- package/src/Tracer.ts +15 -1
- package/src/ai/LanguageModel.ts +9 -0
- package/src/ai/McpServer.ts +14 -13
- package/src/ai/Prompt.ts +65 -0
- package/src/ai/Response.ts +34 -9
- package/src/ai/Tool.ts +38 -2
- package/src/ai/Toolkit.ts +4 -1
- package/src/cli/Argument.ts +15 -0
- package/src/cli/CliError.ts +90 -3
- package/src/cli/CliOutput.ts +183 -6
- package/src/cli/Command.ts +53 -41
- package/src/cli/Completions.ts +51 -0
- package/src/cli/Flag.ts +15 -0
- package/src/cli/GlobalFlag.ts +6 -7
- package/src/cli/Param.ts +29 -6
- package/src/cli/TerminalCapabilities.ts +6 -3
- package/src/cli/internal/completions/bash.ts +79 -29
- package/src/cluster/ClusterWorkflowEngine.ts +46 -16
- package/src/cluster/MessageStorage.ts +19 -14
- package/src/cluster/Sharding.ts +83 -21
- package/src/cluster/ShardingConfig.ts +5 -0
- package/src/cluster/Snowflake.ts +3 -7
- package/src/cluster/SqlRunnerStorage.ts +110 -47
- package/src/cluster/internal/entityManager.ts +75 -22
- package/src/devtools/DevToolsClient.ts +2 -0
- package/src/encoding/Base64.ts +38 -0
- package/src/encoding/Sse.ts +4 -3
- package/src/encoding/Toml.ts +33 -16
- package/src/eventlog/SqlEventJournal.ts +68 -45
- package/src/eventlog/internal/conflicts.ts +0 -4
- package/src/http/Cookies.ts +10 -11
- package/src/http/HttpClient.ts +547 -7
- package/src/http/HttpClientError.ts +35 -1
- package/src/http/HttpClientRequest.ts +9 -1
- package/src/http/HttpMiddleware.ts +15 -18
- package/src/http/HttpRouter.ts +2 -1
- package/src/http/HttpServerError.ts +2 -2
- package/src/http/HttpServerRequest.ts +102 -16
- package/src/http/HttpStaticServer.ts +51 -22
- package/src/http/MultipartParser/internal/contentType.ts +3 -3
- package/src/http/UrlParams.ts +6 -1
- package/src/http/internal/compression.ts +4 -5
- package/src/http/internal/decompression.ts +6 -0
- package/src/http/internal/httpBody.ts +10 -2
- package/src/http/internal/urlParams.ts +29 -0
- package/src/http-api/HttpApi.ts +3 -6
- package/src/http-api/HttpApiBuilder.ts +45 -15
- package/src/http-api/HttpApiClient.ts +218 -72
- package/src/http-api/HttpApiEndpoint.ts +121 -30
- package/src/http-api/HttpApiSchema.ts +141 -48
- package/src/http-api/HttpApiTest.ts +3 -2
- package/src/http-api/OpenApi.ts +20 -17
- package/src/http-api/internal/toCodecHttpProperties.ts +56 -0
- package/src/internal/arbitrary/runner.ts +133 -36
- package/src/internal/core.ts +2 -0
- package/src/internal/effect.ts +24 -16
- package/src/internal/equal.ts +17 -0
- package/src/internal/jsonSchema.ts +27 -0
- package/src/internal/matcher.ts +1 -1
- package/src/internal/schema/compilerRegistry.ts +6 -1
- package/src/internal/schema/content.ts +18 -0
- package/src/internal/schema/fromJsonSchemaDocument.ts +228 -190
- package/src/internal/schema/fromRepresentation.ts +2 -1
- package/src/internal/schema/standardSchema.ts +2 -2
- package/src/internal/schema/toCodeDocument.ts +4 -4
- package/src/internal/schema/toCodec.ts +26 -22
- package/src/internal/schema/toJsonSchemaDocument.ts +189 -167
- package/src/internal/schema/toRepresentation.ts +122 -140
- package/src/internal/sql.ts +14 -0
- package/src/internal/version.ts +1 -1
- package/src/observability/OtlpProxy.ts +314 -0
- package/src/observability/OtlpTracer.ts +4 -0
- package/src/observability/index.ts +6 -0
- package/src/persistence/CircuitBreaker.ts +1678 -0
- package/src/persistence/Redis.ts +129 -8
- package/src/persistence/index.ts +6 -0
- package/src/process/ChildProcess.ts +30 -4
- package/src/process/ChildProcessSpawner.ts +41 -2
- package/src/reactivity/AsyncResult.ts +1 -1
- package/src/rpc/RpcClient.ts +13 -10
- package/src/rpc/RpcSerialization.ts +32 -9
- package/src/rpc/RpcServer.ts +16 -1
- package/src/rpc/RpcTest.ts +3 -0
- package/src/sql/Migrator.ts +12 -7
- package/src/sql/SqlClient.ts +11 -4
- package/src/sql/SqlResolver.ts +23 -9
- package/src/sql/Statement.ts +30 -2
- package/src/workflow/DurableDeferred.ts +23 -6
package/src/SchemaParser.ts
CHANGED
|
@@ -1136,29 +1136,62 @@ function runSync<T>(effect: Effect.Effect<T, SchemaIssue.Issue>, message: string
|
|
|
1136
1136
|
throw new Error("Schema validation failed", { cause: issue })
|
|
1137
1137
|
}
|
|
1138
1138
|
|
|
1139
|
+
const constructorDefectMessage = "Constructor adapter can only throw schema issues"
|
|
1140
|
+
|
|
1141
|
+
function throwConstructorDefect(error: unknown): never {
|
|
1142
|
+
throw new Error(constructorDefectMessage, { cause: Cause.die(error) })
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1139
1145
|
function makeConstructorSync<T, E>(
|
|
1140
1146
|
ast: SchemaAST.AST
|
|
1141
1147
|
): (input: E, options?: Schema.MakeOptions) => T {
|
|
1142
1148
|
let entry: CompilerRegistry.Entry | undefined
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
}
|
|
1158
|
-
if (output !== CompilerRegistry.invalid && output !== InternalParser.missing) return output as T
|
|
1149
|
+
return (input, options) => constructSync(entry ??= CompilerRegistry.resolve(ast), input, options)
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
function constructSync<T>(entry: CompilerRegistry.Entry, input: unknown, options: Schema.MakeOptions | undefined): T {
|
|
1153
|
+
const parseOptions = options?.disableChecks
|
|
1154
|
+
? options.parseOptions ? { ...options.parseOptions, disableChecks: true } : { disableChecks: true }
|
|
1155
|
+
: options?.parseOptions ?? SchemaAST.defaultParseOptions
|
|
1156
|
+
const make = entry.make
|
|
1157
|
+
if (make !== undefined && input !== InternalParser.missing) {
|
|
1158
|
+
let output: unknown
|
|
1159
|
+
try {
|
|
1160
|
+
output = make(input, parseOptions)
|
|
1161
|
+
} catch (error) {
|
|
1162
|
+
throwConstructorDefect(error)
|
|
1159
1163
|
}
|
|
1160
|
-
|
|
1161
|
-
|
|
1164
|
+
if (output !== CompilerRegistry.invalid && output !== InternalParser.missing) return output as T
|
|
1165
|
+
}
|
|
1166
|
+
return runSync(parserResult<T, never>(entry.makeEffect(input, parseOptions), input), constructorDefectMessage)
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
/**
|
|
1170
|
+
* Constructs a class instance from its type-side declaration.
|
|
1171
|
+
*
|
|
1172
|
+
* When the declaration has no compiled constructor, the fields are validated first
|
|
1173
|
+
* and the instance is built outside the parser, so stacks captured by the
|
|
1174
|
+
* class constructor keep the caller's frames.
|
|
1175
|
+
*
|
|
1176
|
+
* @internal
|
|
1177
|
+
*/
|
|
1178
|
+
export function makeClassSync<T>(
|
|
1179
|
+
ast: SchemaAST.AST,
|
|
1180
|
+
input: unknown,
|
|
1181
|
+
options: Schema.MakeOptions | undefined,
|
|
1182
|
+
construct: (fields: object) => T
|
|
1183
|
+
): T {
|
|
1184
|
+
const entry = CompilerRegistry.resolve(ast)
|
|
1185
|
+
const descriptor = SchemaAST.getConstructorDescriptor(ast)
|
|
1186
|
+
if (descriptor === undefined || entry.make !== undefined || entry.compiledMakeEffect !== undefined) {
|
|
1187
|
+
return constructSync(entry, input, options)
|
|
1188
|
+
}
|
|
1189
|
+
if (descriptor.isConstructed(input)) return input as T
|
|
1190
|
+
const fields = constructSync<object>((entry.resolve ?? CompilerRegistry.resolve)(descriptor.link.to), input, options)
|
|
1191
|
+
try {
|
|
1192
|
+
return construct(fields)
|
|
1193
|
+
} catch (error) {
|
|
1194
|
+
throwConstructorDefect(error)
|
|
1162
1195
|
}
|
|
1163
1196
|
}
|
|
1164
1197
|
|
|
@@ -288,13 +288,19 @@ export interface Unknown extends Keyword<"Unknown"> {}
|
|
|
288
288
|
export interface Any extends Keyword<"Any"> {}
|
|
289
289
|
|
|
290
290
|
/**
|
|
291
|
-
* A string representation
|
|
291
|
+
* A string representation, optionally describing its content through a media
|
|
292
|
+
* type and a schema for the value encoded in the string.
|
|
292
293
|
*
|
|
293
294
|
* @stability stable
|
|
294
295
|
* @category models
|
|
295
296
|
* @since 4.0.0
|
|
296
297
|
*/
|
|
297
|
-
export interface String extends Keyword<"String"> {
|
|
298
|
+
export interface String extends Keyword<"String"> {
|
|
299
|
+
readonly content?: {
|
|
300
|
+
readonly mediaType: string
|
|
301
|
+
readonly schema?: Representation | undefined
|
|
302
|
+
} | undefined
|
|
303
|
+
}
|
|
298
304
|
|
|
299
305
|
/**
|
|
300
306
|
* A number representation.
|
|
@@ -2388,26 +2394,6 @@ export const MutableJsonReviver: DeclarationReviver<null> = makeFixedDeclaration
|
|
|
2388
2394
|
Schema.MutableJson
|
|
2389
2395
|
)
|
|
2390
2396
|
|
|
2391
|
-
const jsonSchemaRevivers: ReadonlyArray<AnyReviver> = [
|
|
2392
|
-
JsonReviver,
|
|
2393
|
-
isPatternReviver,
|
|
2394
|
-
isFiniteReviver,
|
|
2395
|
-
isGreaterThanReviver,
|
|
2396
|
-
isGreaterThanOrEqualToReviver,
|
|
2397
|
-
isLessThanReviver,
|
|
2398
|
-
isLessThanOrEqualToReviver,
|
|
2399
|
-
isMultipleOfReviver,
|
|
2400
|
-
isIntReviver,
|
|
2401
|
-
isMinLengthReviver,
|
|
2402
|
-
isMaxLengthReviver,
|
|
2403
|
-
isMinCodePointsReviver,
|
|
2404
|
-
isMaxCodePointsReviver,
|
|
2405
|
-
isMinPropertiesReviver,
|
|
2406
|
-
isMaxPropertiesReviver,
|
|
2407
|
-
isPropertyNamesReviver,
|
|
2408
|
-
isUniqueReviver
|
|
2409
|
-
]
|
|
2410
|
-
|
|
2411
2397
|
/**
|
|
2412
2398
|
* Options for importing JSON Schema Draft 2020-12 documents.
|
|
2413
2399
|
*
|
|
@@ -2965,7 +2951,14 @@ const RepresentationUnion = Schema.Union([
|
|
|
2965
2951
|
makeKeywordSchema("Never"),
|
|
2966
2952
|
makeKeywordSchema("Unknown"),
|
|
2967
2953
|
makeKeywordSchema("Any"),
|
|
2968
|
-
|
|
2954
|
+
Schema.Struct({
|
|
2955
|
+
_tag: Schema.tag("String"),
|
|
2956
|
+
...KeywordFields,
|
|
2957
|
+
content: Schema.optional(Schema.Struct({
|
|
2958
|
+
mediaType: Schema.String,
|
|
2959
|
+
schema: Schema.optional(RepresentationSchema)
|
|
2960
|
+
}))
|
|
2961
|
+
}),
|
|
2969
2962
|
makeKeywordSchema("Number"),
|
|
2970
2963
|
makeKeywordSchema("Boolean"),
|
|
2971
2964
|
makeKeywordSchema("BigInt"),
|
|
@@ -3192,11 +3185,13 @@ export function fromRepresentations(
|
|
|
3192
3185
|
* - Intersections of overlapping unions are limited to disjoint root-type partitions and finite primitive `anyOf`
|
|
3193
3186
|
* literal sets. Other union intersections, including cases that would duplicate a nested choice, are rejected.
|
|
3194
3187
|
* - Unknown extension keywords are ignored and their semantics are not enforced.
|
|
3195
|
-
* - Only
|
|
3196
|
-
*
|
|
3197
|
-
*
|
|
3198
|
-
*
|
|
3199
|
-
*
|
|
3188
|
+
* - Only local references to top-level definitions in the form `#/$defs/<escaped-token>` are supported, optionally
|
|
3189
|
+
* followed by a pointer below the definition. A pointer target becomes a definition keyed by its escaped tokens, such
|
|
3190
|
+
* as `Name/properties/field`, and is rejected if a top-level definition already uses that key. Root references and
|
|
3191
|
+
* external references are rejected with the supported reference format. Missing definitions are reported by name.
|
|
3192
|
+
* References reached inside nested schema resources introduced by `$id` are rejected instead of resolved against the
|
|
3193
|
+
* top-level definitions.
|
|
3194
|
+
* - Imported constraints use built-in schemas and checks.
|
|
3200
3195
|
* - Pattern constraints reached during translation cause an error by default. Use `patterns: "apply"` only for trusted
|
|
3201
3196
|
* documents, or `patterns: "ignore"` to skip them. Ignoring patterns can both admit invalid values and reject valid
|
|
3202
3197
|
* values when `oneOf` branches start overlapping.
|
|
@@ -3214,7 +3209,7 @@ export function fromJsonSchemaDocument(
|
|
|
3214
3209
|
document: JsonSchema.Document<"draft-2020-12">,
|
|
3215
3210
|
options?: FromJsonSchemaOptions
|
|
3216
3211
|
): Schema.Top {
|
|
3217
|
-
return InternalFromJsonSchemaDocument.fromJsonSchemaDocument(document, options
|
|
3212
|
+
return InternalFromJsonSchemaDocument.fromJsonSchemaDocument(document, options)
|
|
3218
3213
|
}
|
|
3219
3214
|
|
|
3220
3215
|
/**
|
|
@@ -3238,10 +3233,12 @@ export function fromJsonSchemaDocument(
|
|
|
3238
3233
|
* are supported.
|
|
3239
3234
|
* - Intersections of overlapping unions are limited to disjoint root-type partitions and finite primitive `anyOf`
|
|
3240
3235
|
* literal sets. Other union intersections, including cases that would duplicate a nested choice, are rejected.
|
|
3241
|
-
* - Only
|
|
3242
|
-
*
|
|
3243
|
-
*
|
|
3244
|
-
*
|
|
3236
|
+
* - Only local references to top-level definitions in the form `#/$defs/<escaped-token>` are supported, optionally
|
|
3237
|
+
* followed by a pointer below the definition. A pointer target becomes a definition keyed by its escaped tokens, such
|
|
3238
|
+
* as `Name/properties/field`, and is rejected if a top-level definition already uses that key. Root references and
|
|
3239
|
+
* external references are rejected with the supported reference format. Missing definitions are reported by name.
|
|
3240
|
+
* References reached inside nested schema resources introduced by `$id` are rejected instead of resolved against the
|
|
3241
|
+
* top-level definitions.
|
|
3245
3242
|
* - Pattern constraints reached during translation cause an error by default. Use `patterns: "apply"` only for trusted
|
|
3246
3243
|
* documents, or `patterns: "ignore"` to skip them. Ignoring patterns can both admit invalid values and reject valid
|
|
3247
3244
|
* values when `oneOf` branches start overlapping.
|
|
@@ -3258,5 +3255,5 @@ export function fromJsonSchemaMultiDocument(
|
|
|
3258
3255
|
document: JsonSchema.MultiDocument<"draft-2020-12">,
|
|
3259
3256
|
options?: FromJsonSchemaOptions
|
|
3260
3257
|
): readonly [Schema.Top, ...Array<Schema.Top>] {
|
|
3261
|
-
return InternalFromJsonSchemaDocument.fromJsonSchemaMultiDocument(document, options
|
|
3258
|
+
return InternalFromJsonSchemaDocument.fromJsonSchemaMultiDocument(document, options)
|
|
3262
3259
|
}
|
|
@@ -20,6 +20,7 @@ import * as Duration from "./Duration.ts"
|
|
|
20
20
|
import * as Effect from "./Effect.ts"
|
|
21
21
|
import { format, formatDate, formatJson } from "./Formatter.ts"
|
|
22
22
|
import { dual } from "./Function.ts"
|
|
23
|
+
import * as InternalContent from "./internal/schema/content.ts"
|
|
23
24
|
import * as Option from "./Option.ts"
|
|
24
25
|
import * as Pipeable from "./Pipeable.ts"
|
|
25
26
|
import * as Predicate from "./Predicate.ts"
|
|
@@ -613,7 +614,10 @@ export function trim(): Transformation<string, string> {
|
|
|
613
614
|
*
|
|
614
615
|
* Decoding converts values such as `"my_field_name"` to `"myFieldName"`.
|
|
615
616
|
* Encoding converts values such as `"myFieldName"` back to `"my_field_name"`.
|
|
616
|
-
*
|
|
617
|
+
* Lowercase snake_case values round-trip when single underscores separate the
|
|
618
|
+
* segments and every segment after the first starts with a letter. A segment
|
|
619
|
+
* that starts with a digit does not: `"foo_2_bar"` decodes to `"foo2Bar"`,
|
|
620
|
+
* which encodes to `"foo2_bar"`.
|
|
617
621
|
*
|
|
618
622
|
* **Example** (Converting snake case to camel case)
|
|
619
623
|
*
|
|
@@ -1950,7 +1954,10 @@ export function fromJsonString(options?: {
|
|
|
1950
1954
|
}): Transformation<unknown, string> {
|
|
1951
1955
|
return new Transformation(
|
|
1952
1956
|
SchemaGetter.parseJson(options ?? {}),
|
|
1953
|
-
SchemaGetter.stringifyJson(options)
|
|
1957
|
+
InternalContent.setContent(SchemaGetter.stringifyJson(options), {
|
|
1958
|
+
mediaType: "application/json",
|
|
1959
|
+
preserveSchema: options?.reviver === undefined && options?.replacer === undefined
|
|
1960
|
+
})
|
|
1954
1961
|
)
|
|
1955
1962
|
}
|
|
1956
1963
|
|
package/src/Semaphore.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import type * as Effect from "./Effect.ts"
|
|
15
15
|
import type { Fiber } from "./Fiber.ts"
|
|
16
|
-
import { dual } from "./Function.ts"
|
|
16
|
+
import { dual, identity } from "./Function.ts"
|
|
17
17
|
import * as core from "./internal/core.ts"
|
|
18
18
|
import * as internal from "./internal/effect.ts"
|
|
19
19
|
import type * as Option from "./Option.ts"
|
|
@@ -214,26 +214,58 @@ export interface Semaphore {
|
|
|
214
214
|
*/
|
|
215
215
|
export const makeUnsafe = (permits: number): Semaphore => new SemaphoreImpl(permits)
|
|
216
216
|
|
|
217
|
-
|
|
217
|
+
interface Waiter {
|
|
218
|
+
readonly permits: number
|
|
219
|
+
resume: ((effect: Effect.Effect<void>) => void) | undefined
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// The first queued request that fits in the free permits. Larger requests
|
|
223
|
+
// ahead of it keep their place but are overtaken, as documented on `take`.
|
|
224
|
+
const firstAvailableWaiter = (self: SemaphoreImpl): Waiter | undefined => {
|
|
225
|
+
for (const waiter of self.waiters) {
|
|
226
|
+
if (waiter.permits <= self.free) return waiter
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const takePermits = <A, E, R>(
|
|
218
231
|
self: SemaphoreImpl,
|
|
219
232
|
n: number,
|
|
220
|
-
|
|
233
|
+
onAcquire: () => Effect.Effect<A, E, R>,
|
|
234
|
+
restore: <AX, EX, RX>(effect: Effect.Effect<AX, EX, RX>) => Effect.Effect<AX, EX, RX> = identity
|
|
221
235
|
): Effect.Effect<A, E, R> =>
|
|
222
|
-
|
|
223
|
-
if (self.free >= n
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
236
|
+
core.withFiber((fiber) => {
|
|
237
|
+
if (self.free >= n && firstAvailableWaiter(self) === undefined) {
|
|
238
|
+
self.taken += n
|
|
239
|
+
return onAcquire()
|
|
240
|
+
}
|
|
241
|
+
// A wake does not reserve permits: the waiter keeps its queue entry until
|
|
242
|
+
// it acquires or is interrupted, and re-checks eligibility when it runs.
|
|
243
|
+
const waiter: Waiter = { permits: n, resume: undefined }
|
|
244
|
+
const remove = () => {
|
|
245
|
+
if (self.waiters.delete(waiter)) self.releaseUnsafe(fiber, 0)
|
|
246
|
+
return undefined
|
|
228
247
|
}
|
|
229
|
-
self.waiters.add(
|
|
230
|
-
|
|
231
|
-
|
|
248
|
+
self.waiters.add(waiter)
|
|
249
|
+
internal.onExitUnsafe(fiber, remove)
|
|
250
|
+
const wait = restore(internal.callback<void>((resume) => {
|
|
251
|
+
// The fiber may have yielded since the last check, missing a wake.
|
|
252
|
+
if (firstAvailableWaiter(self) === waiter) {
|
|
253
|
+
resume(internal.void)
|
|
254
|
+
} else {
|
|
255
|
+
waiter.resume = resume
|
|
256
|
+
}
|
|
257
|
+
}))
|
|
258
|
+
const loop: Effect.Effect<A, E, R> = internal.flatMap(wait, () => {
|
|
259
|
+
if (firstAvailableWaiter(self) !== waiter) return loop
|
|
260
|
+
self.taken += n
|
|
261
|
+
remove()
|
|
262
|
+
return onAcquire()
|
|
232
263
|
})
|
|
264
|
+
return loop
|
|
233
265
|
})
|
|
234
266
|
|
|
235
267
|
class SemaphoreImpl implements Semaphore {
|
|
236
|
-
public waiters = new Set<
|
|
268
|
+
public waiters = new Set<Waiter>()
|
|
237
269
|
public taken = 0
|
|
238
270
|
public permits: number
|
|
239
271
|
|
|
@@ -246,14 +278,7 @@ class SemaphoreImpl implements Semaphore {
|
|
|
246
278
|
}
|
|
247
279
|
|
|
248
280
|
take(n: number): Effect.Effect<number> {
|
|
249
|
-
|
|
250
|
-
if (this.free < n) {
|
|
251
|
-
return waitForPermits(this, n, take)
|
|
252
|
-
}
|
|
253
|
-
this.taken += n
|
|
254
|
-
return internal.succeed(n)
|
|
255
|
-
})
|
|
256
|
-
return take
|
|
281
|
+
return takePermits(this, n, () => internal.succeed(n))
|
|
257
282
|
}
|
|
258
283
|
|
|
259
284
|
takeIfAvailable(n: number): Effect.Effect<boolean> {
|
|
@@ -268,9 +293,17 @@ class SemaphoreImpl implements Semaphore {
|
|
|
268
293
|
this.taken -= n
|
|
269
294
|
if (this.waiters.size > 0) {
|
|
270
295
|
fiber.currentDispatcher.scheduleTask(() => {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
296
|
+
// Wake every queued request that fits in the free permits. Waiters
|
|
297
|
+
// that were already woken still count against the budget, since they
|
|
298
|
+
// keep their place until they acquire. Resumed fibers run inline and
|
|
299
|
+
// can add or remove waiters, so iterate over a snapshot.
|
|
300
|
+
let remaining = this.free
|
|
301
|
+
for (const waiter of Array.from(this.waiters)) {
|
|
302
|
+
if (!this.waiters.has(waiter) || waiter.permits > remaining) continue
|
|
303
|
+
remaining -= waiter.permits
|
|
304
|
+
const resume = waiter.resume
|
|
305
|
+
waiter.resume = undefined
|
|
306
|
+
resume?.(internal.void)
|
|
274
307
|
}
|
|
275
308
|
}, 0)
|
|
276
309
|
}
|
|
@@ -296,24 +329,18 @@ class SemaphoreImpl implements Semaphore {
|
|
|
296
329
|
|
|
297
330
|
withPermits(n: number) {
|
|
298
331
|
return <A, E, R>(self: Effect.Effect<A, E, R>) =>
|
|
299
|
-
internal.uninterruptibleMask((restore) =>
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
this.taken += n
|
|
306
|
-
return internal.onExitPrimitive(
|
|
307
|
-
restore(self),
|
|
308
|
-
() => {
|
|
332
|
+
internal.uninterruptibleMask((restore) =>
|
|
333
|
+
takePermits(
|
|
334
|
+
this,
|
|
335
|
+
n,
|
|
336
|
+
() =>
|
|
337
|
+
internal.onExitPrimitive(restore(self), () => {
|
|
309
338
|
this.releaseUnsafe(internal.getCurrentFiber()!, n)
|
|
310
339
|
return undefined
|
|
311
|
-
},
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
return acquire
|
|
316
|
-
})
|
|
340
|
+
}, true),
|
|
341
|
+
restore
|
|
342
|
+
)
|
|
343
|
+
)
|
|
317
344
|
}
|
|
318
345
|
|
|
319
346
|
readonly withPermit = this.withPermits(1)
|
package/src/Sink.ts
CHANGED
|
@@ -2687,7 +2687,12 @@ export const catchCause: {
|
|
|
2687
2687
|
): Sink<A | A2, In, L, E2, R | R2> =>
|
|
2688
2688
|
transformEffect(
|
|
2689
2689
|
self,
|
|
2690
|
-
Effect.catchCause((cause) =>
|
|
2690
|
+
Effect.catchCause((cause) =>
|
|
2691
|
+
// Upstream failures are not sink errors, so they bypass the handler.
|
|
2692
|
+
Channel.hasUpstreamFailure(cause)
|
|
2693
|
+
? Effect.failCause(cause as Cause.Cause<never>)
|
|
2694
|
+
: Effect.map(f(cause), (a2) => [a2 as A | A2] as const)
|
|
2695
|
+
)
|
|
2691
2696
|
))
|
|
2692
2697
|
|
|
2693
2698
|
const catch_: {
|
|
@@ -2774,7 +2779,15 @@ export const onExit: {
|
|
|
2774
2779
|
): Sink<A, In, L, E | E2, R | R2> =>
|
|
2775
2780
|
transformEffect(
|
|
2776
2781
|
self,
|
|
2777
|
-
Effect.onExit((exit) =>
|
|
2782
|
+
Effect.onExit((exit) =>
|
|
2783
|
+
// Upstream failures stop the sink like an interruption; they are not
|
|
2784
|
+
// sink errors.
|
|
2785
|
+
f(
|
|
2786
|
+
Exit.isFailure(exit) && Channel.hasUpstreamFailure(exit.cause)
|
|
2787
|
+
? Exit.interrupt()
|
|
2788
|
+
: Exit.map(exit, ([a]) => a)
|
|
2789
|
+
)
|
|
2790
|
+
)
|
|
2778
2791
|
))
|
|
2779
2792
|
|
|
2780
2793
|
/**
|
package/src/Stream.ts
CHANGED
|
@@ -7295,17 +7295,12 @@ export const peel: {
|
|
|
7295
7295
|
): Effect.fn.Return<[A2, Stream<A, E, never>], E | E2, Scope.Scope | R | R2> {
|
|
7296
7296
|
let cause: Cause.Cause<E | Cause.Done<void>> | undefined = undefined
|
|
7297
7297
|
const originalPull = yield* Channel.toPull(self.channel)
|
|
7298
|
-
const pull
|
|
7299
|
-
Arr.NonEmptyReadonlyArray<A>,
|
|
7300
|
-
E
|
|
7301
|
-
> = Effect.catchCause(originalPull, (cause_) => {
|
|
7298
|
+
const pull = Effect.catchCause(originalPull, (cause_) => {
|
|
7302
7299
|
cause = cause_
|
|
7303
7300
|
return Effect.failCause(cause_)
|
|
7304
7301
|
})
|
|
7305
7302
|
|
|
7306
|
-
const [result, leftover] = yield* Effect.scopedWith((scope) =>
|
|
7307
|
-
sink.transform(pull as Pull.Pull<Arr.NonEmptyReadonlyArray<A>>, scope)
|
|
7308
|
-
)
|
|
7303
|
+
const [result, leftover] = yield* Effect.scopedWith((scope) => runSink(sink, pull, scope))
|
|
7309
7304
|
let stream: Stream<A, E> = cause ? empty : fromPull(Effect.succeed(originalPull))
|
|
7310
7305
|
if (leftover) {
|
|
7311
7306
|
stream = concat(fromArray(leftover), stream)
|
|
@@ -11098,7 +11093,7 @@ export const takeRight: {
|
|
|
11098
11093
|
const count = Count.normalize(n)
|
|
11099
11094
|
if (count === 0) return empty
|
|
11100
11095
|
return mapAccumArray(self, MutableList.make<A>, (list, arr) => {
|
|
11101
|
-
MutableList.
|
|
11096
|
+
MutableList.appendAllUnsafe(list, arr)
|
|
11102
11097
|
if (list.length > count) {
|
|
11103
11098
|
MutableList.takeNVoid(list, list.length - count)
|
|
11104
11099
|
}
|
|
@@ -12528,10 +12523,10 @@ export const rechunk: {
|
|
|
12528
12523
|
let chunk = Arr.empty<A>() as Arr.NonEmptyArray<A>
|
|
12529
12524
|
let index = 0
|
|
12530
12525
|
let current: Arr.NonEmptyReadonlyArray<A> | undefined
|
|
12531
|
-
let
|
|
12526
|
+
let cause: Cause.Cause<E | Cause.Done> | undefined
|
|
12532
12527
|
|
|
12533
12528
|
return Effect.suspend(function loop(): Pull.Pull<Arr.NonEmptyReadonlyArray<A>, E, void, R> {
|
|
12534
|
-
if (
|
|
12529
|
+
if (cause) return Effect.failCause(cause)
|
|
12535
12530
|
else if (current === undefined) {
|
|
12536
12531
|
return Effect.flatMap(pull, (arr) => {
|
|
12537
12532
|
if (chunk.length === 0 && arr.length === target) {
|
|
@@ -12558,10 +12553,10 @@ export const rechunk: {
|
|
|
12558
12553
|
current = undefined
|
|
12559
12554
|
return loop()
|
|
12560
12555
|
}).pipe(
|
|
12561
|
-
|
|
12562
|
-
if (chunk.length === 0) return
|
|
12556
|
+
Effect.catchCause((cause_) => {
|
|
12557
|
+
if (chunk.length === 0) return Effect.failCause(cause_)
|
|
12563
12558
|
const result = chunk
|
|
12564
|
-
|
|
12559
|
+
cause = cause_
|
|
12565
12560
|
chunk = [] as any
|
|
12566
12561
|
return Effect.succeed(result)
|
|
12567
12562
|
})
|
|
@@ -15122,7 +15117,12 @@ const groupByImpl = <A, E, R, K, V, E2, R2>(
|
|
|
15122
15117
|
body: constant(Effect.flatMap(pull, (arr) => f(arr, queues, queueMap))),
|
|
15123
15118
|
step: constVoid
|
|
15124
15119
|
}).pipe(
|
|
15125
|
-
Effect.catchCause((cause) =>
|
|
15120
|
+
Effect.catchCause((cause) => {
|
|
15121
|
+
for (const [, queue] of queueMap) {
|
|
15122
|
+
Queue.endUnsafe(queue)
|
|
15123
|
+
}
|
|
15124
|
+
return Queue.failCause(out, cause)
|
|
15125
|
+
}),
|
|
15126
15126
|
Effect.forkIn(scope)
|
|
15127
15127
|
)
|
|
15128
15128
|
|
|
@@ -15659,7 +15659,7 @@ export const aggregateWithin: {
|
|
|
15659
15659
|
return buffer.state.exit as Exit.Exit<never, Cause.Done<void> | E>
|
|
15660
15660
|
}
|
|
15661
15661
|
hasInput.closeUnsafe()
|
|
15662
|
-
const pull = emit(Effect.suspend(() => sink
|
|
15662
|
+
const pull = emit(Effect.suspend(() => runSink(sink, sinkUpstream, scope)))
|
|
15663
15663
|
return buffer.state._tag === "Open" ? Effect.raceFirst(pull, stepToBuffer) : pull
|
|
15664
15664
|
})
|
|
15665
15665
|
}))))
|
|
@@ -19327,11 +19327,28 @@ export const run: {
|
|
|
19327
19327
|
): Effect.Effect<A2, E | E2, R | R2> =>
|
|
19328
19328
|
Effect.scopedWith((scope) =>
|
|
19329
19329
|
Channel.toPullScoped(self.channel, scope).pipe(
|
|
19330
|
-
Effect.flatMap((upstream) => sink
|
|
19330
|
+
Effect.flatMap((upstream) => runSink(sink, upstream, scope)),
|
|
19331
19331
|
Effect.map(([a]) => a)
|
|
19332
19332
|
)
|
|
19333
19333
|
))
|
|
19334
19334
|
|
|
19335
|
+
/**
|
|
19336
|
+
* Runs `sink` against `upstream`. Upstream failures bypass the sink's error
|
|
19337
|
+
* handlers and are restored once the sink has exited.
|
|
19338
|
+
*/
|
|
19339
|
+
const runSink = <A, E, R, A2, L, E2, R2>(
|
|
19340
|
+
sink: Sink.Sink<A2, A, L, E2, R2>,
|
|
19341
|
+
upstream: Pull.Pull<Arr.NonEmptyReadonlyArray<A>, E, void, R>,
|
|
19342
|
+
scope: Scope.Scope
|
|
19343
|
+
): Effect.Effect<Sink.End<A2, L>, E | E2, R | R2> =>
|
|
19344
|
+
Channel.restoreUpstreamFailure<Sink.End<A2, L>, E | E2, R2>(
|
|
19345
|
+
// The upstream pull runs in this fiber, which already provides `R`.
|
|
19346
|
+
sink.transform(
|
|
19347
|
+
Channel.upstreamFailureToDefect(upstream) as Pull.Pull<Arr.NonEmptyReadonlyArray<A>, never, void>,
|
|
19348
|
+
scope
|
|
19349
|
+
)
|
|
19350
|
+
)
|
|
19351
|
+
|
|
19335
19352
|
/**
|
|
19336
19353
|
* Runs the stream and collects all elements into an array.
|
|
19337
19354
|
*
|
package/src/String.ts
CHANGED
|
@@ -1860,6 +1860,9 @@ export const constantCase: (self: string) => string = noCase({
|
|
|
1860
1860
|
* Unlike {@link constantCase}, digit-letter boundaries are not split. For
|
|
1861
1861
|
* example, `"api-v2 xml"` becomes `"API_V2_XML"`.
|
|
1862
1862
|
*
|
|
1863
|
+
* `configCase` is not idempotent: `"field2value"` becomes `"FIELD2VALUE"`, and
|
|
1864
|
+
* applying it again gives `"FIELD2_VALUE"`.
|
|
1865
|
+
*
|
|
1863
1866
|
* @see {@link constantCase} for standard uppercase underscore-separated output
|
|
1864
1867
|
* @stability stable
|
|
1865
1868
|
* @category transforming
|
package/src/Tracer.ts
CHANGED
|
@@ -326,6 +326,15 @@ export type SpanKind = "internal" | "server" | "client" | "producer" | "consumer
|
|
|
326
326
|
* annotations, attributes, links, sampling and kind information, lifecycle
|
|
327
327
|
* status, and methods to end the span or add attributes, events, and links.
|
|
328
328
|
*
|
|
329
|
+
* **Details**
|
|
330
|
+
*
|
|
331
|
+
* Once a span has `Ended` status, implementations should ignore further calls
|
|
332
|
+
* to `end`, `attribute`, `event`, and `addLinks`, following the OpenTelemetry
|
|
333
|
+
* tracing specification. An ended span can still be read and used as a parent.
|
|
334
|
+
* The built-in span implementations follow this rule, and Effect does not
|
|
335
|
+
* record logs or `annotateCurrentSpan` attributes on an ended span, such as
|
|
336
|
+
* when a fiber outlives the span it was forked in.
|
|
337
|
+
*
|
|
329
338
|
* **Example** (Working with spans)
|
|
330
339
|
*
|
|
331
340
|
* ```ts import.meta.vitest
|
|
@@ -684,7 +693,8 @@ export const nativeTracer: Tracer = make({
|
|
|
684
693
|
* identifiers, the attribute map, and the event list are created lazily on
|
|
685
694
|
* first access, so spans that are never inspected allocate as little as
|
|
686
695
|
* possible. Attributes, events, links, and status are mutated through `Span`
|
|
687
|
-
* methods.
|
|
696
|
+
* methods. Once the span has ended, those methods do nothing, so a second `end`
|
|
697
|
+
* keeps the original end time and exit.
|
|
688
698
|
*
|
|
689
699
|
* @see {@link Span} for the interface implemented by native spans
|
|
690
700
|
*
|
|
@@ -748,6 +758,7 @@ export class NativeSpan implements Span {
|
|
|
748
758
|
}
|
|
749
759
|
|
|
750
760
|
end(endTime: bigint, exit: Exit.Exit<unknown, unknown>): void {
|
|
761
|
+
if (this.status._tag === "Ended") return
|
|
751
762
|
this.status = {
|
|
752
763
|
_tag: "Ended",
|
|
753
764
|
endTime,
|
|
@@ -757,14 +768,17 @@ export class NativeSpan implements Span {
|
|
|
757
768
|
}
|
|
758
769
|
|
|
759
770
|
attribute(key: string, value: unknown): void {
|
|
771
|
+
if (this.status._tag === "Ended") return
|
|
760
772
|
this.attributes.set(key, value)
|
|
761
773
|
}
|
|
762
774
|
|
|
763
775
|
event(name: string, startTime: bigint, attributes?: Record<string, unknown>): void {
|
|
776
|
+
if (this.status._tag === "Ended") return
|
|
764
777
|
this.events.push([name, startTime, attributes ?? {}])
|
|
765
778
|
}
|
|
766
779
|
|
|
767
780
|
addLinks(links: ReadonlyArray<SpanLink>): void {
|
|
781
|
+
if (this.status._tag === "Ended") return
|
|
768
782
|
// oxlint-disable-next-line no-restricted-syntax
|
|
769
783
|
this.links.push(...links)
|
|
770
784
|
}
|
package/src/ai/LanguageModel.ts
CHANGED
|
@@ -1553,6 +1553,7 @@ export const make: (params: {
|
|
|
1553
1553
|
preliminary: false,
|
|
1554
1554
|
result: r.encodedResult,
|
|
1555
1555
|
encodedResult: r.encodedResult,
|
|
1556
|
+
...modelOutputField(r.modelOutput),
|
|
1556
1557
|
isFailure: r.isFailure
|
|
1557
1558
|
}) as Response.StreamPart<Tools>
|
|
1558
1559
|
)
|
|
@@ -1680,6 +1681,7 @@ export const make: (params: {
|
|
|
1680
1681
|
providerExecuted: false,
|
|
1681
1682
|
result: result.result,
|
|
1682
1683
|
encodedResult: result.encodedResult,
|
|
1684
|
+
...modelOutputField(result.modelOutput),
|
|
1683
1685
|
isFailure: result.isFailure,
|
|
1684
1686
|
preliminary: result.preliminary
|
|
1685
1687
|
}) as Response.StreamPart<Tools>
|
|
@@ -2268,6 +2270,7 @@ const executeApprovedToolCalls = <Tools extends Record<string, Tool.Any>>(
|
|
|
2268
2270
|
name: toolCall.name,
|
|
2269
2271
|
result: terminalResult.result,
|
|
2270
2272
|
encodedResult: terminalResult.encodedResult,
|
|
2273
|
+
...modelOutputField(terminalResult.modelOutput),
|
|
2271
2274
|
isFailure: terminalResult.isFailure,
|
|
2272
2275
|
preliminary: terminalResult.preliminary,
|
|
2273
2276
|
providerExecuted: false
|
|
@@ -2347,6 +2350,10 @@ const makeInterruptedToolResult = (
|
|
|
2347
2350
|
})
|
|
2348
2351
|
}
|
|
2349
2352
|
|
|
2353
|
+
// Omits the key entirely so unmapped tool result parts keep their shape.
|
|
2354
|
+
const modelOutputField = (modelOutput: ReadonlyArray<Prompt.ToolModelOutputPart> | undefined) =>
|
|
2355
|
+
modelOutput === undefined ? undefined : { modelOutput }
|
|
2356
|
+
|
|
2350
2357
|
type ToolResolutionResult<Tools extends Record<string, Tool.Any>> =
|
|
2351
2358
|
| Response.ToolResultPart<
|
|
2352
2359
|
Tool.Name<Tools[keyof Tools]>,
|
|
@@ -2417,6 +2424,7 @@ const resolveToolCalls = <Tools extends Record<string, Tool.Any>>(
|
|
|
2417
2424
|
providerExecuted: false,
|
|
2418
2425
|
result: result.result,
|
|
2419
2426
|
encodedResult: result.encodedResult,
|
|
2427
|
+
...modelOutputField(result.modelOutput),
|
|
2420
2428
|
isFailure: result.isFailure,
|
|
2421
2429
|
preliminary: result.preliminary
|
|
2422
2430
|
}) as ToolResolutionResult<Tools>
|
|
@@ -2446,6 +2454,7 @@ const resolveToolCalls = <Tools extends Record<string, Tool.Any>>(
|
|
|
2446
2454
|
providerExecuted: false,
|
|
2447
2455
|
result: result.result,
|
|
2448
2456
|
encodedResult: result.encodedResult,
|
|
2457
|
+
...modelOutputField(result.modelOutput),
|
|
2449
2458
|
isFailure: result.isFailure,
|
|
2450
2459
|
preliminary: result.preliminary
|
|
2451
2460
|
}) as ToolResolutionResult<Tools>
|