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/cli/CliOutput.ts
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Formats CLI help and
|
|
2
|
+
* Formats and presents CLI help, errors, and version information.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* information into strings.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* support.
|
|
4
|
+
* The `Formatter` service turns help documents, errors, and version
|
|
5
|
+
* information into strings. The `Presenter` service decides where the built-in
|
|
6
|
+
* help, version, and invalid-invocation output of `Command.runWith` is written,
|
|
7
|
+
* and can be replaced to suppress or redirect it.
|
|
9
8
|
*
|
|
10
9
|
* @stability unstable
|
|
11
10
|
* @since 4.0.0
|
|
12
11
|
*/
|
|
13
12
|
|
|
13
|
+
import * as Console from "../Console.ts"
|
|
14
14
|
import * as Context from "../Context.ts"
|
|
15
|
+
import * as Effect from "../Effect.ts"
|
|
15
16
|
import * as Layer from "../Layer.ts"
|
|
16
17
|
import * as Option from "../Option.ts"
|
|
17
18
|
import type * as CliError from "./CliError.ts"
|
|
18
19
|
import type { HelpDoc } from "./HelpDoc.ts"
|
|
19
20
|
import * as Ansi from "./internal/ansi.ts"
|
|
21
|
+
import * as TerminalCapabilities from "./TerminalCapabilities.ts"
|
|
20
22
|
|
|
21
23
|
/**
|
|
22
24
|
* Defines the service interface for formatting CLI output including help, errors, and version info.
|
|
@@ -205,6 +207,124 @@ export interface Formatter {
|
|
|
205
207
|
readonly formatErrors: (errors: ReadonlyArray<CliError.CliError>) => string
|
|
206
208
|
}
|
|
207
209
|
|
|
210
|
+
/**
|
|
211
|
+
* Presents the built-in help, version, and invalid-invocation output of
|
|
212
|
+
* `Command.runWith`.
|
|
213
|
+
*
|
|
214
|
+
* **When to use**
|
|
215
|
+
*
|
|
216
|
+
* Use to suppress, redirect, or replace that output, for example to keep
|
|
217
|
+
* stdout clean for machine-readable results.
|
|
218
|
+
*
|
|
219
|
+
* **Details**
|
|
220
|
+
*
|
|
221
|
+
* Events carry the help document and errors rather than rendered text, so a
|
|
222
|
+
* presenter can still render them with the `Formatter` service. Presenting an
|
|
223
|
+
* event does not change the result of the run: implicit help and invalid
|
|
224
|
+
* invocations still fail with `CliError.ShowHelp`.
|
|
225
|
+
*
|
|
226
|
+
* **Gotchas**
|
|
227
|
+
*
|
|
228
|
+
* `--completions` scripts, wizard mode output, and handler failures rendered
|
|
229
|
+
* through `CliError.userMessage` do not go through the presenter.
|
|
230
|
+
*
|
|
231
|
+
* **Example** (Writing invalid-invocation output to stderr)
|
|
232
|
+
*
|
|
233
|
+
* ```ts import.meta.vitest
|
|
234
|
+
* import { Console, Effect } from "effect"
|
|
235
|
+
* import { CliOutput } from "effect/cli"
|
|
236
|
+
*
|
|
237
|
+
* const StderrPresenter = CliOutput.layerPresenter({
|
|
238
|
+
* present: (event) =>
|
|
239
|
+
* event._tag === "InvalidInvocation"
|
|
240
|
+
* ? Effect.gen(function*() {
|
|
241
|
+
* const formatter = yield* CliOutput.Formatter
|
|
242
|
+
* yield* Console.error(formatter.formatHelpDoc(event.helpDoc))
|
|
243
|
+
* yield* Console.error(formatter.formatErrors(event.errors))
|
|
244
|
+
* })
|
|
245
|
+
* : CliOutput.defaultPresenter.present(event)
|
|
246
|
+
* })
|
|
247
|
+
* ```
|
|
248
|
+
*
|
|
249
|
+
* @see {@link defaultPresenter} for the default console output
|
|
250
|
+
* @stability unstable
|
|
251
|
+
* @category models
|
|
252
|
+
* @since 4.0.0
|
|
253
|
+
*/
|
|
254
|
+
export interface Presenter {
|
|
255
|
+
/**
|
|
256
|
+
* Presents a CLI output event.
|
|
257
|
+
*
|
|
258
|
+
* @stability unstable
|
|
259
|
+
* @since 4.0.0
|
|
260
|
+
*/
|
|
261
|
+
readonly present: (event: Presenter.Event) => Effect.Effect<void>
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Types used by the `Presenter` service.
|
|
266
|
+
*
|
|
267
|
+
* @stability unstable
|
|
268
|
+
* @since 4.0.0
|
|
269
|
+
*/
|
|
270
|
+
export declare namespace Presenter {
|
|
271
|
+
/**
|
|
272
|
+
* Output events produced while running a CLI command.
|
|
273
|
+
*
|
|
274
|
+
* @stability unstable
|
|
275
|
+
* @category models
|
|
276
|
+
* @since 4.0.0
|
|
277
|
+
*/
|
|
278
|
+
export type Event = Help | InvalidInvocation | Version
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Help for a command path.
|
|
282
|
+
*
|
|
283
|
+
* **Details**
|
|
284
|
+
*
|
|
285
|
+
* `reason` is `"Requested"` for `--help`, and `"Implicit"` when the run
|
|
286
|
+
* fails with a `CliError.ShowHelp` that carries no errors, such as selecting
|
|
287
|
+
* a command that has no handler, or when `renderErrors` is `false`.
|
|
288
|
+
*
|
|
289
|
+
* @stability unstable
|
|
290
|
+
* @category models
|
|
291
|
+
* @since 4.0.0
|
|
292
|
+
*/
|
|
293
|
+
export interface Help {
|
|
294
|
+
readonly _tag: "Help"
|
|
295
|
+
readonly reason: "Requested" | "Implicit"
|
|
296
|
+
readonly commandPath: ReadonlyArray<string>
|
|
297
|
+
readonly helpDoc: HelpDoc
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Help and parse or validation errors for an invalid invocation.
|
|
302
|
+
*
|
|
303
|
+
* @stability unstable
|
|
304
|
+
* @category models
|
|
305
|
+
* @since 4.0.0
|
|
306
|
+
*/
|
|
307
|
+
export interface InvalidInvocation {
|
|
308
|
+
readonly _tag: "InvalidInvocation"
|
|
309
|
+
readonly commandPath: ReadonlyArray<string>
|
|
310
|
+
readonly helpDoc: HelpDoc
|
|
311
|
+
readonly errors: ReadonlyArray<CliError.NonShowHelpErrors>
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Version information requested with `--version`.
|
|
316
|
+
*
|
|
317
|
+
* @stability unstable
|
|
318
|
+
* @category models
|
|
319
|
+
* @since 4.0.0
|
|
320
|
+
*/
|
|
321
|
+
export interface Version {
|
|
322
|
+
readonly _tag: "Version"
|
|
323
|
+
readonly name: string
|
|
324
|
+
readonly version: string
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
208
328
|
/**
|
|
209
329
|
* Service reference for the CLI output formatter. Provides a default implementation
|
|
210
330
|
* that can be overridden for custom formatting or testing.
|
|
@@ -238,6 +358,53 @@ export const Formatter: Context.Reference<Formatter> = Context.Reference(
|
|
|
238
358
|
{ defaultValue: () => defaultFormatter() }
|
|
239
359
|
)
|
|
240
360
|
|
|
361
|
+
/**
|
|
362
|
+
* Default presenter that renders events with the current `Formatter` and
|
|
363
|
+
* writes them with `Console`.
|
|
364
|
+
*
|
|
365
|
+
* **Details**
|
|
366
|
+
*
|
|
367
|
+
* Help and version output goes to `Console.log`. Invalid invocations write
|
|
368
|
+
* help to `Console.log` and errors to `Console.error`. When no `Formatter` is
|
|
369
|
+
* installed, the default formatter colors output when `TerminalCapabilities`
|
|
370
|
+
* says it can.
|
|
371
|
+
*
|
|
372
|
+
* @see {@link Presenter} for replacing the default output
|
|
373
|
+
* @stability unstable
|
|
374
|
+
* @category defaults
|
|
375
|
+
* @since 4.0.0
|
|
376
|
+
*/
|
|
377
|
+
export const defaultPresenter: Presenter = {
|
|
378
|
+
present: Effect.fnUntraced(function*(event) {
|
|
379
|
+
const context = yield* Effect.context<never>()
|
|
380
|
+
const formatter = Context.getOrUndefined(context, Formatter) ??
|
|
381
|
+
defaultFormatter({ colors: Context.get(context, TerminalCapabilities.TerminalCapabilities).canColor })
|
|
382
|
+
switch (event._tag) {
|
|
383
|
+
case "Help":
|
|
384
|
+
return yield* Console.log(formatter.formatHelpDoc(event.helpDoc))
|
|
385
|
+
case "InvalidInvocation":
|
|
386
|
+
yield* Console.log(formatter.formatHelpDoc(event.helpDoc))
|
|
387
|
+
return yield* Console.error(formatter.formatErrors(event.errors))
|
|
388
|
+
case "Version":
|
|
389
|
+
return yield* Console.log(formatter.formatVersion(event.name, event.version))
|
|
390
|
+
}
|
|
391
|
+
})
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Service reference for the CLI output presenter. Defaults to
|
|
396
|
+
* `defaultPresenter`.
|
|
397
|
+
*
|
|
398
|
+
* @see {@link layerPresenter} for providing a custom presenter
|
|
399
|
+
* @stability unstable
|
|
400
|
+
* @category services
|
|
401
|
+
* @since 4.0.0
|
|
402
|
+
*/
|
|
403
|
+
export const Presenter: Context.Reference<Presenter> = Context.Reference(
|
|
404
|
+
"effect/cli/CliOutput/Presenter",
|
|
405
|
+
{ defaultValue: () => defaultPresenter }
|
|
406
|
+
)
|
|
407
|
+
|
|
241
408
|
/**
|
|
242
409
|
* Creates a Layer that provides a custom Formatter implementation.
|
|
243
410
|
*
|
|
@@ -268,6 +435,16 @@ export const Formatter: Context.Reference<Formatter> = Context.Reference(
|
|
|
268
435
|
*/
|
|
269
436
|
export const layer = (formatter: Formatter): Layer.Layer<never> => Layer.succeed(Formatter)(formatter)
|
|
270
437
|
|
|
438
|
+
/**
|
|
439
|
+
* Creates a Layer that provides a custom Presenter implementation.
|
|
440
|
+
*
|
|
441
|
+
* @see {@link Presenter} for the events a presenter receives
|
|
442
|
+
* @stability unstable
|
|
443
|
+
* @category layers
|
|
444
|
+
* @since 4.0.0
|
|
445
|
+
*/
|
|
446
|
+
export const layerPresenter = (presenter: Presenter): Layer.Layer<never> => Layer.succeed(Presenter)(presenter)
|
|
447
|
+
|
|
271
448
|
const escapeControlCharacters = (text: string): string =>
|
|
272
449
|
// oxlint-disable-next-line no-control-regex
|
|
273
450
|
text.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g, (character) =>
|
package/src/cli/Command.ts
CHANGED
|
@@ -30,6 +30,7 @@ import * as Terminal from "../Terminal.ts"
|
|
|
30
30
|
import type { Contravariant, Covariant, NoInfer, Simplify } from "../Types.ts"
|
|
31
31
|
import * as CliConfig from "./CliConfig.ts"
|
|
32
32
|
import * as CliError from "./CliError.ts"
|
|
33
|
+
import * as CliOutput from "./CliOutput.ts"
|
|
33
34
|
import * as GlobalFlag from "./GlobalFlag.ts"
|
|
34
35
|
import { checkForDuplicateFlags, makeCommand, makeParser, toImpl, TypeId } from "./internal/command.ts"
|
|
35
36
|
import { mergeConfig, parseConfig } from "./internal/config.ts"
|
|
@@ -3062,19 +3063,24 @@ const showHelp = <Name extends string, Input, E, R, ContextInput>(
|
|
|
3062
3063
|
): Effect.Effect<void, CliError.CliError, Environment> =>
|
|
3063
3064
|
Effect.gen(function*() {
|
|
3064
3065
|
const { builtIns } = yield* CliConfig.CliConfig
|
|
3065
|
-
const
|
|
3066
|
-
const
|
|
3067
|
-
yield*
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3066
|
+
const presenter = yield* CliOutput.Presenter
|
|
3067
|
+
const { commandPath, errors } = error
|
|
3068
|
+
const helpDoc = yield* getHelpForCommandPath(command, commandPath, builtIns)
|
|
3069
|
+
yield* presenter.present(
|
|
3070
|
+
renderErrors && errors.length > 0
|
|
3071
|
+
? { _tag: "InvalidInvocation", commandPath, helpDoc, errors }
|
|
3072
|
+
: { _tag: "Help", reason: "Implicit", commandPath, helpDoc }
|
|
3073
|
+
)
|
|
3071
3074
|
})
|
|
3072
3075
|
|
|
3073
|
-
const showUserError = (error:
|
|
3076
|
+
const showUserError = (error: object, userMessage: string): Effect.Effect<void> =>
|
|
3074
3077
|
Effect.gen(function*() {
|
|
3075
3078
|
const formatter = yield* resolveFormatter
|
|
3076
|
-
|
|
3077
|
-
|
|
3079
|
+
const rendered = error instanceof CliError.UserError
|
|
3080
|
+
? error
|
|
3081
|
+
: new CliError.UserError({ cause: error, userMessage })
|
|
3082
|
+
yield* Console.error(formatter.formatError(rendered))
|
|
3083
|
+
Object.assign(error, { [Runtime.errorReported]: false })
|
|
3078
3084
|
})
|
|
3079
3085
|
|
|
3080
3086
|
/**
|
|
@@ -3085,10 +3091,12 @@ const showUserError = (error: CliError.UserError): Effect.Effect<void> =>
|
|
|
3085
3091
|
* Use when command-line arguments should come from `Stdio` at the application
|
|
3086
3092
|
* entry point.
|
|
3087
3093
|
*
|
|
3088
|
-
* Help
|
|
3089
|
-
* `
|
|
3090
|
-
*
|
|
3091
|
-
* `
|
|
3094
|
+
* Help, version, and parse error output is written through
|
|
3095
|
+
* `CliOutput.Presenter`. Help documents are always presented. By default,
|
|
3096
|
+
* parse error details are also presented, and handler failures annotated with
|
|
3097
|
+
* `CliError.userMessage`, including `CliError.UserError`, are rendered with the
|
|
3098
|
+
* installed `CliOutput.Formatter` before the error is rethrown. Set
|
|
3099
|
+
* `renderErrors` to `false` when the host application owns error rendering.
|
|
3092
3100
|
*
|
|
3093
3101
|
* **Example** (Running commands with standard input)
|
|
3094
3102
|
*
|
|
@@ -3148,10 +3156,12 @@ export const run: {
|
|
|
3148
3156
|
* Use when command-line arguments should come from `Stdio` at the application
|
|
3149
3157
|
* entry point.
|
|
3150
3158
|
*
|
|
3151
|
-
* Help
|
|
3152
|
-
* `
|
|
3153
|
-
*
|
|
3154
|
-
* `
|
|
3159
|
+
* Help, version, and parse error output is written through
|
|
3160
|
+
* `CliOutput.Presenter`. Help documents are always presented. By default,
|
|
3161
|
+
* parse error details are also presented, and handler failures annotated with
|
|
3162
|
+
* `CliError.userMessage`, including `CliError.UserError`, are rendered with the
|
|
3163
|
+
* installed `CliOutput.Formatter` before the error is rethrown. Set
|
|
3164
|
+
* `renderErrors` to `false` when the host application owns error rendering.
|
|
3155
3165
|
*
|
|
3156
3166
|
* **Example** (Running commands with standard input)
|
|
3157
3167
|
*
|
|
@@ -3218,10 +3228,12 @@ export const run: {
|
|
|
3218
3228
|
* Use when command-line arguments should come from `Stdio` at the application
|
|
3219
3229
|
* entry point.
|
|
3220
3230
|
*
|
|
3221
|
-
* Help
|
|
3222
|
-
* `
|
|
3223
|
-
*
|
|
3224
|
-
* `
|
|
3231
|
+
* Help, version, and parse error output is written through
|
|
3232
|
+
* `CliOutput.Presenter`. Help documents are always presented. By default,
|
|
3233
|
+
* parse error details are also presented, and handler failures annotated with
|
|
3234
|
+
* `CliError.userMessage`, including `CliError.UserError`, are rendered with the
|
|
3235
|
+
* installed `CliOutput.Formatter` before the error is rethrown. Set
|
|
3236
|
+
* `renderErrors` to `false` when the host application owns error rendering.
|
|
3225
3237
|
*
|
|
3226
3238
|
* **Example** (Running commands with standard input)
|
|
3227
3239
|
*
|
|
@@ -3301,10 +3313,12 @@ export const run: {
|
|
|
3301
3313
|
* Use when you need to test CLI applications or programmatically execute
|
|
3302
3314
|
* commands with specific arguments.
|
|
3303
3315
|
*
|
|
3304
|
-
* Help
|
|
3305
|
-
* `
|
|
3306
|
-
*
|
|
3307
|
-
* `
|
|
3316
|
+
* Help, version, and parse error output is written through
|
|
3317
|
+
* `CliOutput.Presenter`. Help documents are always presented. By default,
|
|
3318
|
+
* parse error details are also presented, and handler failures annotated with
|
|
3319
|
+
* `CliError.userMessage`, including `CliError.UserError`, are rendered with the
|
|
3320
|
+
* installed `CliOutput.Formatter` before the error is rethrown. Set
|
|
3321
|
+
* `renderErrors` to `false` when the host application owns error rendering.
|
|
3308
3322
|
*
|
|
3309
3323
|
* **Example** (Running commands with explicit arguments)
|
|
3310
3324
|
*
|
|
@@ -3387,6 +3401,9 @@ export const runWith = <const Name extends string, Input, E, R, ContextInput>(
|
|
|
3387
3401
|
// 3. Parse command arguments from remaining tokens
|
|
3388
3402
|
const parsedArgs = yield* Parser.parseArgs({ tokens: remainder, trailingOperands }, command)
|
|
3389
3403
|
const commandPath = [command.name, ...Parser.getCommandPath(parsedArgs)] as const
|
|
3404
|
+
const toShowHelp = Effect.mapError((error: CliError.CliError) =>
|
|
3405
|
+
error._tag === "ShowHelp" ? error : new CliError.ShowHelp({ commandPath, errors: [error] })
|
|
3406
|
+
)
|
|
3390
3407
|
const handlerCtx: GlobalFlag.HandlerContext = { builtIns, command, commandPath, version: config.version }
|
|
3391
3408
|
const activeFlags = getGlobalFlagsForCommandPath(command, commandPath, builtIns)
|
|
3392
3409
|
|
|
@@ -3409,7 +3426,7 @@ export const runWith = <const Name extends string, Input, E, R, ContextInput>(
|
|
|
3409
3426
|
return entries !== undefined && entries.length > 0
|
|
3410
3427
|
})
|
|
3411
3428
|
if (!hasEntry) continue
|
|
3412
|
-
const [, value] = yield* flag.flag.parse(emptyArgs)
|
|
3429
|
+
const [, value] = yield* flag.flag.parse(emptyArgs).pipe(toShowHelp)
|
|
3413
3430
|
if (flag === GlobalFlag.Wizard) {
|
|
3414
3431
|
const { colors } = yield* Prompt.Theme
|
|
3415
3432
|
return yield* Effect.gen(function*() {
|
|
@@ -3442,23 +3459,17 @@ export const runWith = <const Name extends string, Input, E, R, ContextInput>(
|
|
|
3442
3459
|
if (parsedArgs.errors && parsedArgs.errors.length > 0) {
|
|
3443
3460
|
return yield* new CliError.ShowHelp({ commandPath, errors: parsedArgs.errors })
|
|
3444
3461
|
}
|
|
3445
|
-
const
|
|
3446
|
-
if (parseResult._tag === "Failure") {
|
|
3447
|
-
return yield* new CliError.ShowHelp({
|
|
3448
|
-
commandPath,
|
|
3449
|
-
errors: [parseResult.failure as CliError.NonShowHelpErrors]
|
|
3450
|
-
})
|
|
3451
|
-
}
|
|
3462
|
+
const input = yield* commandImpl.parse(parsedArgs).pipe(toShowHelp)
|
|
3452
3463
|
|
|
3453
3464
|
// 7. Provide setting values
|
|
3454
|
-
let program = commandImpl.handle(
|
|
3465
|
+
let program = commandImpl.handle(input, [command.name])
|
|
3455
3466
|
const logLevel = activeFlags.includes(GlobalFlag.LogLevel)
|
|
3456
|
-
? (yield* GlobalFlag.LogLevel.flag.parse(emptyArgs))[1]
|
|
3467
|
+
? (yield* GlobalFlag.LogLevel.flag.parse(emptyArgs).pipe(toShowHelp))[1]
|
|
3457
3468
|
: Option.none()
|
|
3458
3469
|
program = Effect.provideService(program, GlobalFlag.LogLevel, logLevel)
|
|
3459
3470
|
for (const flag of activeFlags) {
|
|
3460
3471
|
if (flag._tag !== "Setting" || flag === GlobalFlag.LogLevel) continue
|
|
3461
|
-
const [, value] = yield* flag.flag.parse(emptyArgs)
|
|
3472
|
+
const [, value] = yield* flag.flag.parse(emptyArgs).pipe(toShowHelp)
|
|
3462
3473
|
program = Effect.provideService(program, flag, value)
|
|
3463
3474
|
}
|
|
3464
3475
|
|
|
@@ -3479,11 +3490,12 @@ export const runWith = <const Name extends string, Input, E, R, ContextInput>(
|
|
|
3479
3490
|
(error) => Effect.andThen(showHelp(command, error, config.renderErrors !== false), Effect.fail(error))
|
|
3480
3491
|
),
|
|
3481
3492
|
Effect.catchFilter(
|
|
3482
|
-
(error) =>
|
|
3483
|
-
config.renderErrors
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3493
|
+
(error) => {
|
|
3494
|
+
if (config.renderErrors === false || !Predicate.isObjectKeyword(error)) return Result.fail(error)
|
|
3495
|
+
const userMessage = CliError.getUserMessage(error)
|
|
3496
|
+
return userMessage === undefined ? Result.fail(error) : Result.succeed({ error, userMessage })
|
|
3497
|
+
},
|
|
3498
|
+
({ error, userMessage }) => Effect.andThen(showUserError(error, userMessage), Effect.fail(error))
|
|
3487
3499
|
),
|
|
3488
3500
|
Effect.catchFilter(
|
|
3489
3501
|
(e) =>
|
package/src/cli/Completions.ts
CHANGED
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
* @stability unstable
|
|
8
8
|
* @since 4.0.0
|
|
9
9
|
*/
|
|
10
|
+
import type { Command } from "./Command.ts"
|
|
10
11
|
import * as Bash from "./internal/completions/bash.ts"
|
|
12
|
+
import * as Descriptor from "./internal/completions/descriptor.ts"
|
|
11
13
|
import * as Fish from "./internal/completions/fish.ts"
|
|
12
14
|
import * as PowerShell from "./internal/completions/powershell.ts"
|
|
13
15
|
import * as Zsh from "./internal/completions/zsh.ts"
|
|
@@ -106,6 +108,55 @@ export type ArgumentType =
|
|
|
106
108
|
| { readonly _tag: "Choice"; readonly values: ReadonlyArray<string> }
|
|
107
109
|
| { readonly _tag: "Path"; readonly pathType: "file" | "directory" | "either" }
|
|
108
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Converts a command tree into a `CommandDescriptor` for completion script
|
|
113
|
+
* generation.
|
|
114
|
+
*
|
|
115
|
+
* **When to use**
|
|
116
|
+
*
|
|
117
|
+
* Use when you need to generate a completion script from an existing
|
|
118
|
+
* `Command`, for example in a build step, without running the CLI or
|
|
119
|
+
* capturing the output of the built-in `--completions` flag.
|
|
120
|
+
*
|
|
121
|
+
* **Details**
|
|
122
|
+
*
|
|
123
|
+
* Reads the command's flags, arguments, and subcommands, including flags
|
|
124
|
+
* shared with subcommands and aliases. Hidden flags and unlisted subcommands
|
|
125
|
+
* are omitted, matching `--help`. Command handlers are never run.
|
|
126
|
+
*
|
|
127
|
+
* **Example** (Generating a Zsh completion script at build time)
|
|
128
|
+
*
|
|
129
|
+
* ```ts import.meta.vitest
|
|
130
|
+
* import { Effect } from "effect"
|
|
131
|
+
* import { Command, Completions, Flag } from "effect/cli"
|
|
132
|
+
*
|
|
133
|
+
* const start = Command.make(
|
|
134
|
+
* "start",
|
|
135
|
+
* { port: Flag.Int("port") },
|
|
136
|
+
* ({ port }) => Effect.log(`Listening on ${port}`)
|
|
137
|
+
* )
|
|
138
|
+
*
|
|
139
|
+
* const cli = Command.make("server").pipe(
|
|
140
|
+
* Command.withSubcommands([start])
|
|
141
|
+
* )
|
|
142
|
+
*
|
|
143
|
+
* const script = Completions.generate(
|
|
144
|
+
* "server",
|
|
145
|
+
* "zsh",
|
|
146
|
+
* Completions.fromCommand(cli)
|
|
147
|
+
* )
|
|
148
|
+
*
|
|
149
|
+
* script.startsWith("#compdef server") // => true
|
|
150
|
+
* ```
|
|
151
|
+
*
|
|
152
|
+
* @see {@link generate} for turning the descriptor into a shell script
|
|
153
|
+
*
|
|
154
|
+
* @stability unstable
|
|
155
|
+
* @category constructors
|
|
156
|
+
* @since 4.0.7
|
|
157
|
+
*/
|
|
158
|
+
export const fromCommand = (command: Command.Any): CommandDescriptor => Descriptor.fromCommand(command)
|
|
159
|
+
|
|
109
160
|
/**
|
|
110
161
|
* Generates a shell completion script for a command descriptor.
|
|
111
162
|
*
|
package/src/cli/Flag.ts
CHANGED
|
@@ -1155,6 +1155,11 @@ export const withFallbackConfig: {
|
|
|
1155
1155
|
/**
|
|
1156
1156
|
* Adds a fallback prompt that is shown when a required flag is missing.
|
|
1157
1157
|
*
|
|
1158
|
+
* **Gotchas**
|
|
1159
|
+
*
|
|
1160
|
+
* When `TerminalCapabilities.canPrompt` is `false`, the prompt is skipped and
|
|
1161
|
+
* the original `MissingOption` error is returned.
|
|
1162
|
+
*
|
|
1158
1163
|
* **Example** (Falling back to prompts)
|
|
1159
1164
|
*
|
|
1160
1165
|
* ```ts import.meta.vitest
|
|
@@ -1174,6 +1179,11 @@ export const withFallbackPrompt: {
|
|
|
1174
1179
|
/**
|
|
1175
1180
|
* Adds a fallback prompt that is shown when a required flag is missing.
|
|
1176
1181
|
*
|
|
1182
|
+
* **Gotchas**
|
|
1183
|
+
*
|
|
1184
|
+
* When `TerminalCapabilities.canPrompt` is `false`, the prompt is skipped and
|
|
1185
|
+
* the original `MissingOption` error is returned.
|
|
1186
|
+
*
|
|
1177
1187
|
* **Example** (Falling back to prompts)
|
|
1178
1188
|
*
|
|
1179
1189
|
* ```ts import.meta.vitest
|
|
@@ -1193,6 +1203,11 @@ export const withFallbackPrompt: {
|
|
|
1193
1203
|
/**
|
|
1194
1204
|
* Adds a fallback prompt that is shown when a required flag is missing.
|
|
1195
1205
|
*
|
|
1206
|
+
* **Gotchas**
|
|
1207
|
+
*
|
|
1208
|
+
* When `TerminalCapabilities.canPrompt` is `false`, the prompt is skipped and
|
|
1209
|
+
* the original `MissingOption` error is returned.
|
|
1210
|
+
*
|
|
1196
1211
|
* **Example** (Falling back to prompts)
|
|
1197
1212
|
*
|
|
1198
1213
|
* ```ts import.meta.vitest
|
package/src/cli/GlobalFlag.ts
CHANGED
|
@@ -17,11 +17,10 @@ import * as Context from "../Context.ts"
|
|
|
17
17
|
import * as Effect from "../Effect.ts"
|
|
18
18
|
import type { LogLevel as LogLevelType } from "../LogLevel.ts"
|
|
19
19
|
import * as Option from "../Option.ts"
|
|
20
|
+
import * as CliOutput from "./CliOutput.ts"
|
|
20
21
|
import type * as Command from "./Command.ts"
|
|
21
22
|
import * as Completions_ from "./Completions.ts"
|
|
22
23
|
import * as Flag from "./Flag.ts"
|
|
23
|
-
import * as CommandDescriptor from "./internal/completions/descriptor.ts"
|
|
24
|
-
import { resolveFormatter } from "./internal/formatter.ts"
|
|
25
24
|
import * as HelpInternal from "./internal/help.ts"
|
|
26
25
|
|
|
27
26
|
/* ========================================================================== */
|
|
@@ -169,9 +168,9 @@ export const Help: Action<boolean> = Action({
|
|
|
169
168
|
Flag.withDefault(false)
|
|
170
169
|
),
|
|
171
170
|
run: Effect.fnUntraced(function*(_, { builtIns, command, commandPath }) {
|
|
172
|
-
const
|
|
171
|
+
const presenter = yield* CliOutput.Presenter
|
|
173
172
|
const helpDoc = yield* HelpInternal.getHelpForCommandPath(command, commandPath, builtIns)
|
|
174
|
-
yield*
|
|
173
|
+
yield* presenter.present({ _tag: "Help", reason: "Requested", commandPath, helpDoc })
|
|
175
174
|
})
|
|
176
175
|
})
|
|
177
176
|
|
|
@@ -193,8 +192,8 @@ export const Version: Action<boolean> = Action({
|
|
|
193
192
|
Flag.withDefault(false)
|
|
194
193
|
),
|
|
195
194
|
run: Effect.fnUntraced(function*(_, { command, version }) {
|
|
196
|
-
const
|
|
197
|
-
yield*
|
|
195
|
+
const presenter = yield* CliOutput.Presenter
|
|
196
|
+
yield* presenter.present({ _tag: "Version", name: command.name, version })
|
|
198
197
|
})
|
|
199
198
|
})
|
|
200
199
|
|
|
@@ -249,7 +248,7 @@ export const Completions: Action<Option.Option<Completions_.Shell>> = Action({
|
|
|
249
248
|
),
|
|
250
249
|
run: Effect.fnUntraced(function*(shell, { command }) {
|
|
251
250
|
if (Option.isNone(shell)) return
|
|
252
|
-
const descriptor =
|
|
251
|
+
const descriptor = Completions_.fromCommand(command)
|
|
253
252
|
yield* Console.log(
|
|
254
253
|
Completions_.generate(command.name, shell.value, descriptor)
|
|
255
254
|
)
|
package/src/cli/Param.ts
CHANGED
|
@@ -25,6 +25,7 @@ import * as CliError from "./CliError.ts"
|
|
|
25
25
|
import type { Environment } from "./Command.ts"
|
|
26
26
|
import * as Primitive from "./Primitive.ts"
|
|
27
27
|
import * as Prompt from "./Prompt.ts"
|
|
28
|
+
import * as TerminalCapabilities from "./TerminalCapabilities.ts"
|
|
28
29
|
|
|
29
30
|
const TypeId = "~effect/cli/Param"
|
|
30
31
|
|
|
@@ -1931,6 +1932,9 @@ export const withFallbackConfig: {
|
|
|
1931
1932
|
*
|
|
1932
1933
|
* This only handles missing options and missing arguments. Invalid values do not
|
|
1933
1934
|
* prompt, and prompt cancellation re-fails with the original missing error.
|
|
1935
|
+
* When `TerminalCapabilities.canPrompt` is `false`, the fallback is skipped
|
|
1936
|
+
* entirely: no prompt is built or shown, and the original missing error is
|
|
1937
|
+
* returned.
|
|
1934
1938
|
*
|
|
1935
1939
|
* @see {@link FallbackPrompt} for accepted fallback prompt forms
|
|
1936
1940
|
* @see {@link withFallbackConfig} for loading a fallback from config
|
|
@@ -1958,6 +1962,9 @@ export const withFallbackPrompt: {
|
|
|
1958
1962
|
*
|
|
1959
1963
|
* This only handles missing options and missing arguments. Invalid values do not
|
|
1960
1964
|
* prompt, and prompt cancellation re-fails with the original missing error.
|
|
1965
|
+
* When `TerminalCapabilities.canPrompt` is `false`, the fallback is skipped
|
|
1966
|
+
* entirely: no prompt is built or shown, and the original missing error is
|
|
1967
|
+
* returned.
|
|
1961
1968
|
*
|
|
1962
1969
|
* @see {@link FallbackPrompt} for accepted fallback prompt forms
|
|
1963
1970
|
* @see {@link withFallbackConfig} for loading a fallback from config
|
|
@@ -1985,6 +1992,9 @@ export const withFallbackPrompt: {
|
|
|
1985
1992
|
*
|
|
1986
1993
|
* This only handles missing options and missing arguments. Invalid values do not
|
|
1987
1994
|
* prompt, and prompt cancellation re-fails with the original missing error.
|
|
1995
|
+
* When `TerminalCapabilities.canPrompt` is `false`, the fallback is skipped
|
|
1996
|
+
* entirely: no prompt is built or shown, and the original missing error is
|
|
1997
|
+
* returned.
|
|
1988
1998
|
*
|
|
1989
1999
|
* @see {@link FallbackPrompt} for accepted fallback prompt forms
|
|
1990
2000
|
* @see {@link withFallbackConfig} for loading a fallback from config
|
|
@@ -1999,11 +2009,16 @@ export const withFallbackPrompt: {
|
|
|
1999
2009
|
self: Param<Kind, A>,
|
|
2000
2010
|
prompt: FallbackPrompt<B>
|
|
2001
2011
|
): Param<Kind, A | B> => {
|
|
2002
|
-
const runPrompt = (
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2012
|
+
const runPrompt = Effect.fnUntraced(function*(
|
|
2013
|
+
error: CliError.MissingOption | CliError.MissingArgument,
|
|
2014
|
+
args: ParsedArgs
|
|
2015
|
+
) {
|
|
2016
|
+
const { canPrompt } = yield* TerminalCapabilities.TerminalCapabilities
|
|
2017
|
+
if (!canPrompt) return yield* Effect.fail(error)
|
|
2018
|
+
const built = Prompt.isPrompt(prompt) ? prompt : yield* prompt
|
|
2019
|
+
const value = yield* Effect.catchTag(Prompt.run(built), "QuitError", () => Effect.fail(error))
|
|
2020
|
+
return [args.arguments, value as A | B] as const
|
|
2021
|
+
})
|
|
2007
2022
|
return transform(
|
|
2008
2023
|
self,
|
|
2009
2024
|
(parse) => (args) =>
|
|
@@ -3191,7 +3206,15 @@ const parseFlag: <A>(
|
|
|
3191
3206
|
return yield* new CliError.MissingOption({ option: name })
|
|
3192
3207
|
}
|
|
3193
3208
|
|
|
3194
|
-
|
|
3209
|
+
if (providedValues.length > 1) {
|
|
3210
|
+
return yield* new CliError.InvalidValue({
|
|
3211
|
+
option: name,
|
|
3212
|
+
value: `${providedValues.length} occurrences`,
|
|
3213
|
+
expected: "at most 1 value",
|
|
3214
|
+
kind: "flag"
|
|
3215
|
+
})
|
|
3216
|
+
}
|
|
3217
|
+
|
|
3195
3218
|
const arg = providedValues[0]
|
|
3196
3219
|
const value = yield* Effect.mapError(
|
|
3197
3220
|
primitiveType.parse(arg),
|
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
* the current process. The layer reads the same variables through
|
|
6
6
|
* `ConfigProvider`, plus the TTY state of `Stdio`. Unless a
|
|
7
7
|
* `CliOutput.Formatter` is provided, the built-in help, version, and error
|
|
8
|
-
* output of `Command` follows `canColor`.
|
|
8
|
+
* output of `Command` follows `canColor`. Fallback prompts added with
|
|
9
|
+
* `Flag.withFallbackPrompt` or `Argument.withFallbackPrompt` only run when
|
|
10
|
+
* `canPrompt` is `true`.
|
|
9
11
|
*
|
|
10
12
|
* @stability unstable
|
|
11
13
|
* @since 4.0.0
|
|
@@ -25,8 +27,9 @@ import * as Stdio from "../Stdio.ts"
|
|
|
25
27
|
* `canColor` says whether styling will be rendered rather than stored as
|
|
26
28
|
* bytes. `canAnimate` says whether output is being watched, so pacing means
|
|
27
29
|
* something. `canPrompt` says whether a question can be asked and answered.
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
+
* The built-in `Command` output reads `canColor`, and fallback prompts for
|
|
31
|
+
* missing flags and arguments are skipped when `canPrompt` is `false`.
|
|
32
|
+
* `canAnimate` is for application code that renders its own output.
|
|
30
33
|
*
|
|
31
34
|
* @stability unstable
|
|
32
35
|
* @category models
|