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/MutableRef.ts
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import * as Equal from "./Equal.ts"
|
|
14
14
|
import * as Dual from "./Function.ts"
|
|
15
|
+
import * as Hash from "./Hash.ts"
|
|
15
16
|
import { type Inspectable, toJson } from "./Inspectable.ts"
|
|
16
17
|
import { PipeInspectableProto } from "./internal/core.ts"
|
|
17
18
|
import type { Pipeable } from "./Pipeable.ts"
|
|
@@ -74,9 +75,15 @@ export interface MutableRef<out T> extends Pipeable, Inspectable {
|
|
|
74
75
|
current: T
|
|
75
76
|
}
|
|
76
77
|
|
|
77
|
-
const MutableRefProto: Omit<MutableRef<unknown>, "current"> = {
|
|
78
|
+
const MutableRefProto: Omit<MutableRef<unknown>, "current"> & Equal.Equal = {
|
|
78
79
|
[TypeId]: TypeId,
|
|
79
80
|
...PipeInspectableProto,
|
|
81
|
+
[Equal.symbol](that: unknown): boolean {
|
|
82
|
+
return this === that
|
|
83
|
+
},
|
|
84
|
+
[Hash.symbol](): number {
|
|
85
|
+
return Hash.random(this)
|
|
86
|
+
},
|
|
80
87
|
toJSON<A>(this: MutableRef<A>) {
|
|
81
88
|
return {
|
|
82
89
|
_id: "MutableRef",
|
|
@@ -59,7 +59,8 @@ export type PartitionedTypeId = "~effect/PartitionedSemaphore"
|
|
|
59
59
|
*
|
|
60
60
|
* **Details**
|
|
61
61
|
*
|
|
62
|
-
*
|
|
62
|
+
* Waiters are served across partitions in round-robin order, completing each
|
|
63
|
+
* waiter's permit request before moving to the next partition.
|
|
63
64
|
*
|
|
64
65
|
* @stability unstable
|
|
65
66
|
* @category models
|
|
@@ -150,6 +151,7 @@ export const makeUnsafe = <K = unknown>(options: {
|
|
|
150
151
|
let iterator = partitions[Symbol.iterator]()
|
|
151
152
|
let releasing = false
|
|
152
153
|
let pendingPermits = 0
|
|
154
|
+
let partial: Waiter | undefined
|
|
153
155
|
|
|
154
156
|
const releaseUnsafe = (permits: number): number => {
|
|
155
157
|
if (permits > 0) {
|
|
@@ -162,26 +164,32 @@ export const makeUnsafe = <K = unknown>(options: {
|
|
|
162
164
|
releasing = true
|
|
163
165
|
try {
|
|
164
166
|
while (pendingPermits > 0 && waitingPermits > 0) {
|
|
165
|
-
let
|
|
166
|
-
if (
|
|
167
|
-
|
|
168
|
-
state = iterator.next()
|
|
167
|
+
let waiter = partial
|
|
168
|
+
if (waiter === undefined) {
|
|
169
|
+
let state = iterator.next()
|
|
169
170
|
if (state.done) {
|
|
170
|
-
|
|
171
|
+
iterator = partitions[Symbol.iterator]()
|
|
172
|
+
state = iterator.next()
|
|
173
|
+
if (state.done) {
|
|
174
|
+
break
|
|
175
|
+
}
|
|
171
176
|
}
|
|
172
|
-
}
|
|
173
177
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
178
|
+
waiter = state.value[1].values().next().value
|
|
179
|
+
if (waiter === undefined) {
|
|
180
|
+
continue
|
|
181
|
+
}
|
|
177
182
|
}
|
|
178
183
|
|
|
179
|
-
waiter.permits
|
|
180
|
-
|
|
181
|
-
|
|
184
|
+
const granted = Math.min(waiter.permits, pendingPermits)
|
|
185
|
+
waiter.permits -= granted
|
|
186
|
+
waitingPermits -= granted
|
|
187
|
+
pendingPermits -= granted
|
|
182
188
|
|
|
183
189
|
if (waiter.permits === 0) {
|
|
184
190
|
waiter.resume()
|
|
191
|
+
} else {
|
|
192
|
+
partial = waiter
|
|
185
193
|
}
|
|
186
194
|
}
|
|
187
195
|
} finally {
|
|
@@ -249,6 +257,9 @@ export const makeUnsafe = <K = unknown>(options: {
|
|
|
249
257
|
}
|
|
250
258
|
|
|
251
259
|
const cleanup = () => {
|
|
260
|
+
if (partial === entry) {
|
|
261
|
+
partial = undefined
|
|
262
|
+
}
|
|
252
263
|
if (waiters.delete(entry) && waiters.size === 0) {
|
|
253
264
|
MutableHashMap.remove(partitions, key)
|
|
254
265
|
}
|
package/src/Pool.ts
CHANGED
|
@@ -463,7 +463,7 @@ export const get = <A, E>(self: Pool<A, E>): Effect.Effect<A, E, Scope.Scope> =>
|
|
|
463
463
|
core.withFiber((fiber) => {
|
|
464
464
|
const state = self.state
|
|
465
465
|
if (state.isShuttingDown) return internal.interrupt
|
|
466
|
-
if (state.availableHead?.exit._tag === "Success") {
|
|
466
|
+
if (state.waiters.size === 0 && state.availableHead?.exit._tag === "Success") {
|
|
467
467
|
state.usage++
|
|
468
468
|
if (self.config.isFixed || targetSize(self) <= activeSize(self)) {
|
|
469
469
|
return leaseItem(self, state.availableHead, fiber)
|
|
@@ -570,7 +570,7 @@ export const use: {
|
|
|
570
570
|
core.withFiber((fiber) => {
|
|
571
571
|
const state = self.state
|
|
572
572
|
if (state.isShuttingDown) return internal.interrupt
|
|
573
|
-
if (state.availableHead?.exit._tag === "Success") {
|
|
573
|
+
if (state.waiters.size === 0 && state.availableHead?.exit._tag === "Success") {
|
|
574
574
|
state.usage++
|
|
575
575
|
if (self.config.isFixed || targetSize(self) <= activeSize(self)) {
|
|
576
576
|
return useItem(self, state.availableHead, f, fiber)
|
|
@@ -611,12 +611,18 @@ const getSlowWith = <A, E, X, R>(
|
|
|
611
611
|
internal.uninterruptibleMask((restore) => {
|
|
612
612
|
const state = self.state
|
|
613
613
|
state.usage++
|
|
614
|
+
const waiter = makeWaiter<A, E>()
|
|
614
615
|
const wait: Effect.Effect<X, any, R> = internal.flatMap(
|
|
615
616
|
internal.onError(
|
|
616
|
-
restore(waitForItem(self)),
|
|
617
|
+
restore(waitForItem(self, waiter)),
|
|
617
618
|
() =>
|
|
618
|
-
|
|
619
|
+
core.withFiber((fiber) => {
|
|
619
620
|
state.usage--
|
|
621
|
+
// Only a woken waiter is still registered here: one cancelled while
|
|
622
|
+
// asleep already left. It passes its wake on, so the capacity it was
|
|
623
|
+
// woken for is not stranded.
|
|
624
|
+
if (state.waiters.delete(waiter)) wakeWaiters(self, fiber, 1)
|
|
625
|
+
return internal.void
|
|
620
626
|
})
|
|
621
627
|
),
|
|
622
628
|
() => loop
|
|
@@ -626,6 +632,12 @@ const getSlowWith = <A, E, X, R>(
|
|
|
626
632
|
state.usage--
|
|
627
633
|
return internal.interrupt
|
|
628
634
|
}
|
|
635
|
+
// A borrower that has not waited yet queues behind the borrowers already
|
|
636
|
+
// waiting. Waiters keep their place until they take an item, so this
|
|
637
|
+
// also holds while a woken waiter has yet to run.
|
|
638
|
+
if (state.waiters.size > 0 && !state.waiters.has(waiter)) {
|
|
639
|
+
return wait
|
|
640
|
+
}
|
|
629
641
|
// Replace failed slots only when the pool cannot grow.
|
|
630
642
|
const item = firstHealthyAvailable(self) ??
|
|
631
643
|
(targetSize(self) <= activeSize(self) ? state.availableHead : undefined)
|
|
@@ -636,6 +648,7 @@ const getSlowWith = <A, E, X, R>(
|
|
|
636
648
|
removeFailedItem(self, item)
|
|
637
649
|
return loop
|
|
638
650
|
}
|
|
651
|
+
state.waiters.delete(waiter)
|
|
639
652
|
return lease(self, item, fiber, restore)
|
|
640
653
|
})
|
|
641
654
|
const loop: Effect.Effect<X, any, R> = internal.suspend(() => {
|
|
@@ -718,19 +731,49 @@ const firstHealthyAvailable = <A, E>(self: Pool<A, E>): PoolItem<A, E> | undefin
|
|
|
718
731
|
return item
|
|
719
732
|
}
|
|
720
733
|
|
|
721
|
-
|
|
734
|
+
/**
|
|
735
|
+
* A borrower's entry in `State.waiters`. It stays registered from the first
|
|
736
|
+
* wait until the borrower takes an item or leaves, so the borrower keeps its
|
|
737
|
+
* place in the queue across wakes.
|
|
738
|
+
*
|
|
739
|
+
* `resume` is set while the borrower is asleep. A registered waiter without
|
|
740
|
+
* one has been woken and has yet to take an item, wait again or leave.
|
|
741
|
+
*/
|
|
742
|
+
interface Waiter<A, E> {
|
|
743
|
+
(failure?: Exit.Failure<A, E>): void
|
|
744
|
+
resume: ((effect: Effect.Effect<void, E>) => void) | undefined
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
const makeWaiter = <A, E>(): Waiter<A, E> => {
|
|
748
|
+
const waiter = ((failure?: Exit.Failure<A, E>) => {
|
|
749
|
+
const resume = waiter.resume
|
|
750
|
+
if (resume === undefined) return
|
|
751
|
+
waiter.resume = undefined
|
|
752
|
+
resume(failure ?? internal.void)
|
|
753
|
+
}) as Waiter<A, E>
|
|
754
|
+
waiter.resume = undefined
|
|
755
|
+
return waiter
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
const waitForItem = <A, E>(self: Pool<A, E>, waiter: Waiter<A, E>): Effect.Effect<void, E> =>
|
|
722
759
|
internal.callback((resume) => {
|
|
723
760
|
const state = self.state
|
|
724
|
-
if (
|
|
761
|
+
if (
|
|
762
|
+
state.isShuttingDown ||
|
|
763
|
+
(state.waiters.size === 0 && firstHealthyAvailable(self) !== undefined)
|
|
764
|
+
) {
|
|
725
765
|
return resume(internal.void)
|
|
726
766
|
}
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
}
|
|
731
|
-
state.waiters.add(observer)
|
|
767
|
+
waiter.resume = resume
|
|
768
|
+
// Re-adding a registered waiter keeps its position.
|
|
769
|
+
state.waiters.add(waiter)
|
|
732
770
|
return internal.sync(() => {
|
|
733
|
-
|
|
771
|
+
// Cancelled while asleep: leave at once, so no wake or failure is spent
|
|
772
|
+
// on it. Cancelled after a wake: stay until the wake is passed on.
|
|
773
|
+
if (waiter.resume !== undefined) {
|
|
774
|
+
waiter.resume = undefined
|
|
775
|
+
state.waiters.delete(waiter)
|
|
776
|
+
}
|
|
734
777
|
})
|
|
735
778
|
})
|
|
736
779
|
|
|
@@ -738,23 +781,36 @@ const wakeWaiters = <A, E>(self: Pool<A, E>, fiber: Fiber.Fiber<unknown, unknown
|
|
|
738
781
|
const waiters = self.state.waiters
|
|
739
782
|
if (waiters.size === 0) return
|
|
740
783
|
fiber.currentDispatcher.scheduleTask(() => {
|
|
784
|
+
// Walk the live set, so a waiter that leaves during the walk does not use
|
|
785
|
+
// up a wake. Skip waiters already woken, and stop once nothing is left to
|
|
786
|
+
// take.
|
|
741
787
|
let remaining = count
|
|
742
|
-
const toWake: Array<(failure?: Exit.Failure<A, E>) => void> = []
|
|
743
788
|
for (const notify of waiters) {
|
|
744
|
-
if (remaining
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
toWake[i]()
|
|
789
|
+
if (remaining <= 0 || self.state.availableHead === undefined) break
|
|
790
|
+
if ((notify as Waiter<A, E>).resume === undefined) continue
|
|
791
|
+
remaining--
|
|
792
|
+
notify()
|
|
749
793
|
}
|
|
750
794
|
}, 0)
|
|
751
795
|
}
|
|
752
796
|
|
|
753
|
-
const
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
797
|
+
const firstSleepingWaiter = <A, E>(self: Pool<A, E>) => {
|
|
798
|
+
for (const notify of self.state.waiters) {
|
|
799
|
+
if ((notify as Waiter<A, E>).resume !== undefined) return notify
|
|
800
|
+
}
|
|
801
|
+
return undefined
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
// Wakes every waiter so it can retry after a failed acquisition. A waiter that
|
|
805
|
+
// could not start a resize while another was running depends on this. Waking
|
|
806
|
+
// a waiter that is already awake is a no-op.
|
|
807
|
+
const wakeAll = <A, E>(self: Pool<A, E>, fiber: Fiber.Fiber<unknown, unknown>) => {
|
|
808
|
+
const waiters = self.state.waiters
|
|
809
|
+
if (waiters.size === 0) return
|
|
810
|
+
fiber.currentDispatcher.scheduleTask(() => {
|
|
811
|
+
for (const notify of Array.from(waiters)) notify()
|
|
812
|
+
}, 0)
|
|
813
|
+
}
|
|
758
814
|
|
|
759
815
|
// Reservations prevent reuse without extending the lifetime of borrowed items.
|
|
760
816
|
const reservations = new WeakMap<PoolItem<unknown, unknown>, number>()
|
|
@@ -1005,22 +1061,38 @@ const resizeLoop = <A, E>(self: Pool<A, E>): Effect.Effect<void> =>
|
|
|
1005
1061
|
return Effect.void
|
|
1006
1062
|
}
|
|
1007
1063
|
const toAcquire = target - active
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1064
|
+
// Wake waiters as each item arrives. Waiting for the whole batch would
|
|
1065
|
+
// leave acquired items idle behind a slow acquisition, with every borrower
|
|
1066
|
+
// queued behind the waiters.
|
|
1067
|
+
const acquireOne = Effect.tap(
|
|
1068
|
+
self.config.strategy === strategyNoop
|
|
1069
|
+
? allocate(self)
|
|
1070
|
+
: Effect.flatMap(
|
|
1071
|
+
self.config.strategy.reclaim(self),
|
|
1072
|
+
(item) =>
|
|
1073
|
+
item
|
|
1074
|
+
? Effect.sync(() => {
|
|
1075
|
+
// A reclaimed item rejoins circulation like a released one.
|
|
1076
|
+
if (self.state.items.has(item) && !self.state.invalidated.has(item)) addAvailableFront(self, item)
|
|
1077
|
+
return item
|
|
1078
|
+
})
|
|
1079
|
+
: allocate(self)
|
|
1080
|
+
),
|
|
1081
|
+
(item) =>
|
|
1082
|
+
core.withFiber((fiber) => {
|
|
1083
|
+
// A failed acquisition wakes everyone so they can retry it. A new
|
|
1084
|
+
// item can only serve as many waiters as it has slots.
|
|
1085
|
+
if (item.exit._tag === "Failure") wakeAll(self, fiber)
|
|
1086
|
+
else wakeWaiters(self, fiber, self.config.concurrency)
|
|
1087
|
+
return internal.void
|
|
1088
|
+
})
|
|
1089
|
+
)
|
|
1014
1090
|
if (toAcquire === 1) {
|
|
1015
|
-
const acquired = Effect.tap(acquireOne, wakeAll(self))
|
|
1016
1091
|
return self.config.isFixed
|
|
1017
|
-
? Effect.asVoid(
|
|
1018
|
-
: Effect.flatMap(
|
|
1092
|
+
? Effect.asVoid(acquireOne)
|
|
1093
|
+
: Effect.flatMap(acquireOne, (item) => item.exit._tag === "Failure" ? Effect.void : resizeLoop(self))
|
|
1019
1094
|
}
|
|
1020
|
-
const acquired =
|
|
1021
|
-
Effect.replicateEffect(toAcquire, { concurrency: toAcquire }),
|
|
1022
|
-
Effect.tap(wakeAll(self))
|
|
1023
|
-
)
|
|
1095
|
+
const acquired = Effect.replicateEffect(acquireOne, toAcquire, { concurrency: toAcquire })
|
|
1024
1096
|
return self.config.isFixed
|
|
1025
1097
|
? Effect.asVoid(acquired)
|
|
1026
1098
|
: Effect.flatMap(
|
|
@@ -1059,7 +1131,7 @@ const allocate = <A, E>(self: Pool<A, E>): Effect.Effect<PoolItem<A, E>> =>
|
|
|
1059
1131
|
return self.config.strategy === strategyNoop ? Effect.succeed(item) : Effect.as(onAcquire, item)
|
|
1060
1132
|
}
|
|
1061
1133
|
// Deliver a waiting borrower its own failure; otherwise retain the slot.
|
|
1062
|
-
const waiter = firstHealthyAvailable(self) === undefined ? self
|
|
1134
|
+
const waiter = firstHealthyAvailable(self) === undefined ? firstSleepingWaiter(self) : undefined
|
|
1063
1135
|
if (waiter !== undefined) {
|
|
1064
1136
|
waiter(exit)
|
|
1065
1137
|
} else {
|
package/src/PubSub.ts
CHANGED
|
@@ -3129,14 +3129,13 @@ export class BackPressureStrategy<in out A> implements PubSub.Strategy<A> {
|
|
|
3129
3129
|
if (publisher === MutableList.Empty) {
|
|
3130
3130
|
keepPolling = false
|
|
3131
3131
|
} else {
|
|
3132
|
-
const [value, deferred] = publisher
|
|
3132
|
+
const [value, deferred, last] = publisher
|
|
3133
3133
|
const published = pubsub.publish(value)
|
|
3134
|
-
if (published
|
|
3135
|
-
Deferred.doneUnsafe(deferred, Exit.succeed(true))
|
|
3136
|
-
} else if (!published) {
|
|
3137
|
-
MutableList.prepend(this.publishers, publisher)
|
|
3138
|
-
}
|
|
3134
|
+
if (!published) MutableList.prepend(this.publishers, publisher)
|
|
3139
3135
|
this.completeSubscribersUnsafe(pubsub, subscribers)
|
|
3136
|
+
// Resuming the publisher can synchronously end the PubSub, so notify
|
|
3137
|
+
// waiting subscribers first.
|
|
3138
|
+
if (published && last) Deferred.doneUnsafe(deferred, Exit.succeed(true))
|
|
3140
3139
|
}
|
|
3141
3140
|
}
|
|
3142
3141
|
}
|
package/src/Ref.ts
CHANGED
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
* @since 2.0.0
|
|
13
13
|
*/
|
|
14
14
|
import * as Effect from "./Effect.ts"
|
|
15
|
+
import * as Equal from "./Equal.ts"
|
|
15
16
|
import { dual, identity } from "./Function.ts"
|
|
17
|
+
import * as Hash from "./Hash.ts"
|
|
16
18
|
import { PipeInspectableProto } from "./internal/core.ts"
|
|
17
19
|
import * as MutableRef from "./MutableRef.ts"
|
|
18
20
|
import type * as Option from "./Option.ts"
|
|
@@ -110,6 +112,12 @@ const RefProto = {
|
|
|
110
112
|
_A: identity
|
|
111
113
|
},
|
|
112
114
|
...PipeInspectableProto,
|
|
115
|
+
[Equal.symbol](that: unknown): boolean {
|
|
116
|
+
return this === that
|
|
117
|
+
},
|
|
118
|
+
[Hash.symbol](): number {
|
|
119
|
+
return Hash.random(this)
|
|
120
|
+
},
|
|
113
121
|
toJSON(this: Ref<any>) {
|
|
114
122
|
return {
|
|
115
123
|
_id: "Ref",
|
package/src/Schedule.ts
CHANGED
|
@@ -1071,10 +1071,10 @@ export const fibonacci = (one: Duration.Input): Schedule<Duration.Duration> => {
|
|
|
1071
1071
|
let a = 0
|
|
1072
1072
|
let b = oneMillis
|
|
1073
1073
|
return constant(effect.sync(() => {
|
|
1074
|
+
const duration = Duration.millis(b)
|
|
1074
1075
|
const next = a + b
|
|
1075
1076
|
a = b
|
|
1076
1077
|
b = next
|
|
1077
|
-
const duration = Duration.millis(next)
|
|
1078
1078
|
return [duration, duration]
|
|
1079
1079
|
}))
|
|
1080
1080
|
}))
|
package/src/Schema.ts
CHANGED
|
@@ -3983,11 +3983,18 @@ export interface $Record<Key extends Record.Key, Value extends Constraint> exten
|
|
|
3983
3983
|
*
|
|
3984
3984
|
* **Gotchas**
|
|
3985
3985
|
*
|
|
3986
|
+
* Dynamic records reject value schemas wrapped with {@link optionalKey} or
|
|
3987
|
+
* {@link optional}. Index signatures already allow keys to be absent; use
|
|
3988
|
+
* {@link UndefinedOr} when existing entries may contain `undefined`. Optional
|
|
3989
|
+
* value schemas remain valid for finite literal keys, which become declared
|
|
3990
|
+
* properties.
|
|
3991
|
+
*
|
|
3986
3992
|
* When decoded or encoded key transformations produce the same property key,
|
|
3987
3993
|
* sequential parsing applies selected own properties in selection order, so
|
|
3988
3994
|
* the later selected property overwrites the earlier value. Dynamic key
|
|
3989
|
-
* selection always examines own properties. Finite literal keys are
|
|
3990
|
-
* fields and may therefore be inherited. Output key order is not
|
|
3995
|
+
* selection always examines own properties. Finite literal and enum keys are
|
|
3996
|
+
* declared fields and may therefore be inherited. Output key order is not
|
|
3997
|
+
* guaranteed.
|
|
3991
3998
|
*
|
|
3992
3999
|
* **Example** (Defining a string-keyed record of numbers)
|
|
3993
4000
|
*
|
|
@@ -6737,9 +6744,8 @@ export function link<T>() {
|
|
|
6737
6744
|
* )
|
|
6738
6745
|
*
|
|
6739
6746
|
* const result = Schema.decodeUnknownResult(schema)({ password: "123456", confirmPassword: "1234567" })
|
|
6740
|
-
*
|
|
6741
|
-
*
|
|
6742
|
-
* }
|
|
6747
|
+
* const message = Result.isFailure(result) ? result.failure.message : ""
|
|
6748
|
+
* message // => "password and confirmPassword must match\n at [\"password\"]"
|
|
6743
6749
|
* ```
|
|
6744
6750
|
*
|
|
6745
6751
|
* **Example** (Reporting multiple failures at once)
|
|
@@ -6759,9 +6765,8 @@ export function link<T>() {
|
|
|
6759
6765
|
* )
|
|
6760
6766
|
*
|
|
6761
6767
|
* const result = Schema.decodeUnknownResult(schema)({ a: 1, b: 0, c: 0 })
|
|
6762
|
-
*
|
|
6763
|
-
*
|
|
6764
|
-
* }
|
|
6768
|
+
* const message = Result.isFailure(result) ? result.failure.message : ""
|
|
6769
|
+
* message // => "b must be greater than 0\n at [\"b\"]\nc must be greater than 0\n at [\"c\"]"
|
|
6765
6770
|
* ```
|
|
6766
6771
|
*
|
|
6767
6772
|
* @stability stable
|
|
@@ -6904,8 +6909,8 @@ export function isPattern(
|
|
|
6904
6909
|
const flags = regExp.flags
|
|
6905
6910
|
const canExport = /^[dg]*uy?$/.test(flags)
|
|
6906
6911
|
const runtimeRegExp = flags === ""
|
|
6907
|
-
? `new RegExp(${format(source)})`
|
|
6908
|
-
: `new RegExp(${format(source)}, ${format(flags)})`
|
|
6912
|
+
? `new globalThis.RegExp(${format(source)})`
|
|
6913
|
+
: `new globalThis.RegExp(${format(source)}, ${format(flags)})`
|
|
6909
6914
|
return SchemaAST.isPattern(regExp, {
|
|
6910
6915
|
toJsonSchema: () => canExport ? { pattern: flags.endsWith("y") ? `^(?:${source})` : source } : [{}, true],
|
|
6911
6916
|
toCode: () => ({ runtime: `Schema.isPattern(${runtimeRegExp})` }),
|
|
@@ -7037,7 +7042,7 @@ export function isUUID(version?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8, annotations?: An
|
|
|
7037
7042
|
)
|
|
7038
7043
|
}
|
|
7039
7044
|
|
|
7040
|
-
const GUID_REGEXP = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/
|
|
7045
|
+
const GUID_REGEXP = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/u
|
|
7041
7046
|
/**
|
|
7042
7047
|
* Validates that a string has the GUID / UUID textual shape.
|
|
7043
7048
|
*
|
|
@@ -7072,18 +7077,22 @@ export function isGUID(annotations?: Annotations.Filter) {
|
|
|
7072
7077
|
id: "effect/schema/isGUID",
|
|
7073
7078
|
payload: null
|
|
7074
7079
|
},
|
|
7075
|
-
toJsonSchema: () => ({ pattern: GUID_REGEXP.source }),
|
|
7076
7080
|
toCode: () => ({ runtime: "Schema.isGUID()" }),
|
|
7077
7081
|
...annotations
|
|
7078
7082
|
}
|
|
7079
7083
|
)
|
|
7080
7084
|
}
|
|
7085
|
+
|
|
7086
|
+
const ULID_REGEXP = /^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/u
|
|
7081
7087
|
/**
|
|
7082
7088
|
* Validates that a string is a valid ULID (Universally Unique Lexicographically
|
|
7083
7089
|
* Sortable Identifier).
|
|
7084
7090
|
*
|
|
7085
7091
|
* **Details**
|
|
7086
7092
|
*
|
|
7093
|
+
* Accepts uppercase and lowercase characters. The first character must be
|
|
7094
|
+
* between `0` and `7` so the value fits in 128 bits.
|
|
7095
|
+
*
|
|
7087
7096
|
* JSON Schema:
|
|
7088
7097
|
*
|
|
7089
7098
|
* This check corresponds to a `pattern` constraint in JSON Schema that matches
|
|
@@ -7099,15 +7108,13 @@ export function isGUID(annotations?: Annotations.Filter) {
|
|
|
7099
7108
|
* @since 4.0.0
|
|
7100
7109
|
*/
|
|
7101
7110
|
export function isULID(annotations?: Annotations.Filter) {
|
|
7102
|
-
const regExp = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/
|
|
7103
7111
|
return isPattern(
|
|
7104
|
-
|
|
7112
|
+
ULID_REGEXP,
|
|
7105
7113
|
{
|
|
7106
7114
|
representation: {
|
|
7107
7115
|
id: "effect/schema/isULID",
|
|
7108
7116
|
payload: null
|
|
7109
7117
|
},
|
|
7110
|
-
toJsonSchema: () => ({ pattern: regExp.source }),
|
|
7111
7118
|
toCode: () => ({ runtime: "Schema.isULID()" }),
|
|
7112
7119
|
...annotations
|
|
7113
7120
|
}
|
|
@@ -7392,16 +7399,18 @@ const CAPITALIZED_PATTERN = "^(?:[^a-z][\\s\\S]*)?$"
|
|
|
7392
7399
|
* @since 4.0.0
|
|
7393
7400
|
*/
|
|
7394
7401
|
export function isCapitalized(annotations?: Annotations.Filter) {
|
|
7395
|
-
const regExp = new globalThis.RegExp(CAPITALIZED_PATTERN)
|
|
7396
7402
|
return makeFilter(
|
|
7397
|
-
(s: string) =>
|
|
7403
|
+
(s: string) => {
|
|
7404
|
+
const [first = ""] = s
|
|
7405
|
+
return first.toUpperCase() === first
|
|
7406
|
+
},
|
|
7398
7407
|
{
|
|
7399
7408
|
expected: "a string with the first character in uppercase",
|
|
7400
7409
|
representation: {
|
|
7401
7410
|
id: "effect/schema/isCapitalized",
|
|
7402
7411
|
payload: null
|
|
7403
7412
|
},
|
|
7404
|
-
toJsonSchema: () => [{ pattern:
|
|
7413
|
+
toJsonSchema: () => [{ pattern: CAPITALIZED_PATTERN }, true],
|
|
7405
7414
|
toCode: () => ({ runtime: "Schema.isCapitalized()" }),
|
|
7406
7415
|
arbitraryConstraint: {
|
|
7407
7416
|
patterns: [{ source: CAPITALIZED_PATTERN, flags: "" }]
|
|
@@ -7426,16 +7435,18 @@ const UNCAPITALIZED_PATTERN = "^(?:[^A-Z][\\s\\S]*)?$"
|
|
|
7426
7435
|
* @since 4.0.0
|
|
7427
7436
|
*/
|
|
7428
7437
|
export function isUncapitalized(annotations?: Annotations.Filter) {
|
|
7429
|
-
const regExp = new globalThis.RegExp(UNCAPITALIZED_PATTERN)
|
|
7430
7438
|
return makeFilter(
|
|
7431
|
-
(s: string) =>
|
|
7439
|
+
(s: string) => {
|
|
7440
|
+
const [first = ""] = s
|
|
7441
|
+
return first.toLowerCase() === first
|
|
7442
|
+
},
|
|
7432
7443
|
{
|
|
7433
7444
|
expected: "a string with the first character in lowercase",
|
|
7434
7445
|
representation: {
|
|
7435
7446
|
id: "effect/schema/isUncapitalized",
|
|
7436
7447
|
payload: null
|
|
7437
7448
|
},
|
|
7438
|
-
toJsonSchema: () => [{ pattern:
|
|
7449
|
+
toJsonSchema: () => [{ pattern: UNCAPITALIZED_PATTERN }, true],
|
|
7439
7450
|
toCode: () => ({ runtime: "Schema.isUncapitalized()" }),
|
|
7440
7451
|
arbitraryConstraint: {
|
|
7441
7452
|
patterns: [{ source: UNCAPITALIZED_PATTERN, flags: "" }]
|
|
@@ -8064,7 +8075,7 @@ function encodeDatePayload(date: globalThis.Date): string {
|
|
|
8064
8075
|
}
|
|
8065
8076
|
|
|
8066
8077
|
function formatDateRuntime(date: globalThis.Date): string {
|
|
8067
|
-
return `new Date(${format(date.getTime())})`
|
|
8078
|
+
return `new globalThis.Date(${format(date.getTime())})`
|
|
8068
8079
|
}
|
|
8069
8080
|
/**
|
|
8070
8081
|
* Validates that a Date is greater than the specified value (exclusive).
|
|
@@ -9799,8 +9810,7 @@ export interface fromJsonString<S extends Constraint> extends decodeTo<S, String
|
|
|
9799
9810
|
}
|
|
9800
9811
|
|
|
9801
9812
|
const JsonString = String.annotate({
|
|
9802
|
-
expected: "a string that will be decoded as JSON"
|
|
9803
|
-
contentMediaType: "application/json"
|
|
9813
|
+
expected: "a string that will be decoded as JSON"
|
|
9804
9814
|
})
|
|
9805
9815
|
/**
|
|
9806
9816
|
* Returns a schema that decodes a JSON string and then decodes the parsed value
|
|
@@ -16268,7 +16278,12 @@ function makeClass<
|
|
|
16268
16278
|
return getClassSchema(this).rebuild(ast)
|
|
16269
16279
|
}
|
|
16270
16280
|
static make(input: S["~type.make.in"], options?: MakeOptions): Self {
|
|
16271
|
-
return SchemaParser.
|
|
16281
|
+
return SchemaParser.makeClassSync(
|
|
16282
|
+
SchemaAST.toType(getClassSchema(this).ast),
|
|
16283
|
+
input ?? {},
|
|
16284
|
+
options,
|
|
16285
|
+
(fields) => makeClassTrusted(this, fields)
|
|
16286
|
+
)
|
|
16272
16287
|
}
|
|
16273
16288
|
static makeOption(input: S["~type.make.in"], options?: MakeOptions): Option_.Option<Self> {
|
|
16274
16289
|
return SchemaParser.makeOption(getClassSchema(this) as any)(input ?? {}, options) as any
|
|
@@ -16417,6 +16432,10 @@ function isStruct(schema: Struct.Fields | Struct<Struct.Fields>): schema is Stru
|
|
|
16417
16432
|
*
|
|
16418
16433
|
* **Gotchas**
|
|
16419
16434
|
*
|
|
16435
|
+
* To subclass a `Schema.Class`, use `Base.extend<Self>(...)`, even when only
|
|
16436
|
+
* adding methods or getters. Pass `{}` for the fields when none are added.
|
|
16437
|
+
* Plain `class Child extends Base` is unsupported.
|
|
16438
|
+
*
|
|
16420
16439
|
* Passing `disableChecks: true` skips filters and checks, not parsing of types
|
|
16421
16440
|
* and structure. Wrong types and shapes are still rejected, and constructor
|
|
16422
16441
|
* defaults still apply.
|
|
@@ -16490,6 +16509,10 @@ export const Class: {
|
|
|
16490
16509
|
*
|
|
16491
16510
|
* **Gotchas**
|
|
16492
16511
|
*
|
|
16512
|
+
* To subclass a `Schema.Class`, use `Base.extend<Self>(...)`, even when only
|
|
16513
|
+
* adding methods or getters. Pass `{}` for the fields when none are added.
|
|
16514
|
+
* Plain `class Child extends Base` is unsupported.
|
|
16515
|
+
*
|
|
16493
16516
|
* Passing `disableChecks: true` skips filters and checks, not parsing of types
|
|
16494
16517
|
* and structure. Wrong types and shapes are still rejected, and constructor
|
|
16495
16518
|
* defaults still apply.
|
package/src/SchemaAST.ts
CHANGED
|
@@ -2739,8 +2739,10 @@ function isIndexSignatureParameter(ast: AST): ast is IndexSignatureParameter {
|
|
|
2739
2739
|
*
|
|
2740
2740
|
* **Gotchas**
|
|
2741
2741
|
*
|
|
2742
|
-
* Using `Schema.optionalKey` on the value type is not
|
|
2743
|
-
* signatures (throws at construction)
|
|
2742
|
+
* Using `Schema.optionalKey` or `Schema.optional` on the value type is not
|
|
2743
|
+
* allowed for index signatures (throws at construction). Index signatures
|
|
2744
|
+
* already allow keys to be absent; use `Schema.UndefinedOr` to allow
|
|
2745
|
+
* `undefined` values.
|
|
2744
2746
|
*
|
|
2745
2747
|
* @see {@link Objects}
|
|
2746
2748
|
* @see {@link PropertySignature}
|
|
@@ -2773,8 +2775,10 @@ export const IndexSignature: new(parameter: AST, type: AST) => IndexSignature =
|
|
|
2773
2775
|
}
|
|
2774
2776
|
this.parameter = parameter
|
|
2775
2777
|
this.type = type
|
|
2776
|
-
if (isOptional(type) &&
|
|
2777
|
-
throw new Error(
|
|
2778
|
+
if (isOptional(type) || (type.encoding !== undefined && isOptional(toEncoded(type)))) {
|
|
2779
|
+
throw new Error(
|
|
2780
|
+
"Cannot use `Schema.optionalKey` or `Schema.optional` with index signatures. Index signatures already allow keys to be absent; use `Schema.UndefinedOr` to allow `undefined` values."
|
|
2781
|
+
)
|
|
2778
2782
|
}
|
|
2779
2783
|
}
|
|
2780
2784
|
}
|
|
@@ -4598,16 +4602,24 @@ function parseParameter(ast: AST): {
|
|
|
4598
4602
|
} {
|
|
4599
4603
|
const literals: Array<PropertyKey> = []
|
|
4600
4604
|
const parameters: Array<AST> = []
|
|
4605
|
+
function addLiteral(literal: PropertyKey) {
|
|
4606
|
+
if (!literals.includes(literal)) {
|
|
4607
|
+
literals.push(literal)
|
|
4608
|
+
}
|
|
4609
|
+
}
|
|
4601
4610
|
function go(ast: AST) {
|
|
4602
4611
|
switch (ast._tag) {
|
|
4603
4612
|
case "Literal":
|
|
4604
|
-
if (Predicate.isPropertyKey(ast.literal)
|
|
4605
|
-
|
|
4613
|
+
if (Predicate.isPropertyKey(ast.literal)) {
|
|
4614
|
+
addLiteral(ast.literal)
|
|
4606
4615
|
}
|
|
4607
4616
|
return
|
|
4608
4617
|
case "UniqueSymbol":
|
|
4609
|
-
|
|
4610
|
-
|
|
4618
|
+
addLiteral(ast.symbol)
|
|
4619
|
+
return
|
|
4620
|
+
case "Enum":
|
|
4621
|
+
for (const [, value] of ast.enums) {
|
|
4622
|
+
addLiteral(value)
|
|
4611
4623
|
}
|
|
4612
4624
|
return
|
|
4613
4625
|
case "Never":
|
|
@@ -4812,18 +4824,6 @@ export const flip = memoize((ast: AST): AST => {
|
|
|
4812
4824
|
return "flip" in ast ? ast.flip(flip) : "recur" in ast ? ast.recur(flip) : ast
|
|
4813
4825
|
})
|
|
4814
4826
|
|
|
4815
|
-
/** @internal */
|
|
4816
|
-
export function containsUndefined(ast: AST): boolean {
|
|
4817
|
-
switch (ast._tag) {
|
|
4818
|
-
case "Undefined":
|
|
4819
|
-
return true
|
|
4820
|
-
case "Union":
|
|
4821
|
-
return ast.types.some(containsUndefined)
|
|
4822
|
-
default:
|
|
4823
|
-
return false
|
|
4824
|
-
}
|
|
4825
|
-
}
|
|
4826
|
-
|
|
4827
4827
|
function fromConst<const T>(
|
|
4828
4828
|
ast: AST,
|
|
4829
4829
|
value: T
|