effect 4.0.0-beta.31 → 4.0.0-beta.32
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/Array.d.ts +87 -86
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +47 -40
- package/dist/Array.js.map +1 -1
- package/dist/BigDecimal.d.ts +46 -45
- package/dist/BigDecimal.d.ts.map +1 -1
- package/dist/BigDecimal.js +35 -38
- package/dist/BigDecimal.js.map +1 -1
- package/dist/BigInt.d.ts +39 -32
- package/dist/BigInt.d.ts.map +1 -1
- package/dist/BigInt.js +32 -29
- package/dist/BigInt.js.map +1 -1
- package/dist/Chunk.d.ts +58 -57
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Chunk.js +20 -21
- package/dist/Chunk.js.map +1 -1
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +4 -1
- package/dist/Config.js.map +1 -1
- package/dist/Cron.d.ts +3 -6
- package/dist/Cron.d.ts.map +1 -1
- package/dist/Cron.js +8 -15
- package/dist/Cron.js.map +1 -1
- package/dist/DateTime.d.ts +16 -15
- package/dist/DateTime.d.ts.map +1 -1
- package/dist/DateTime.js +8 -8
- package/dist/DateTime.js.map +1 -1
- package/dist/Deferred.d.ts +7 -5
- package/dist/Deferred.d.ts.map +1 -1
- package/dist/Deferred.js +7 -5
- package/dist/Deferred.js.map +1 -1
- package/dist/Duration.d.ts +26 -24
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +23 -22
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +3 -4
- package/dist/Effect.js.map +1 -1
- package/dist/Fiber.d.ts +2 -1
- package/dist/Fiber.d.ts.map +1 -1
- package/dist/Fiber.js.map +1 -1
- package/dist/FiberHandle.d.ts +9 -8
- package/dist/FiberHandle.d.ts.map +1 -1
- package/dist/FiberHandle.js +8 -7
- package/dist/FiberHandle.js.map +1 -1
- package/dist/FiberMap.d.ts +20 -19
- package/dist/FiberMap.d.ts.map +1 -1
- package/dist/FiberMap.js +6 -6
- package/dist/FiberMap.js.map +1 -1
- package/dist/FileSystem.d.ts +17 -16
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js +10 -7
- package/dist/FileSystem.js.map +1 -1
- package/dist/Graph.d.ts +64 -64
- package/dist/Graph.d.ts.map +1 -1
- package/dist/Graph.js +53 -53
- package/dist/Graph.js.map +1 -1
- package/dist/HashMap.d.ts +11 -5
- package/dist/HashMap.d.ts.map +1 -1
- package/dist/HashMap.js +3 -1
- package/dist/HashMap.js.map +1 -1
- package/dist/Iterable.d.ts +11 -11
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +12 -12
- package/dist/Iterable.js.map +1 -1
- package/dist/Latch.d.ts +69 -3
- package/dist/Latch.d.ts.map +1 -1
- package/dist/Latch.js +58 -0
- package/dist/Latch.js.map +1 -1
- package/dist/Layer.d.ts +84 -0
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +27 -0
- package/dist/Layer.js.map +1 -1
- package/dist/Number.d.ts +74 -18
- package/dist/Number.d.ts.map +1 -1
- package/dist/Number.js +34 -15
- package/dist/Number.js.map +1 -1
- package/dist/Option.d.ts +2 -0
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js.map +1 -1
- package/dist/PartitionedSemaphore.d.ts +183 -0
- package/dist/PartitionedSemaphore.d.ts.map +1 -0
- package/dist/PartitionedSemaphore.js +231 -0
- package/dist/PartitionedSemaphore.js.map +1 -0
- package/dist/PubSub.d.ts +5 -4
- package/dist/PubSub.d.ts.map +1 -1
- package/dist/PubSub.js +6 -5
- package/dist/PubSub.js.map +1 -1
- package/dist/Queue.d.ts +3 -3
- package/dist/Queue.d.ts.map +1 -1
- package/dist/Queue.js +2 -2
- package/dist/Queue.js.map +1 -1
- package/dist/Record.d.ts +40 -40
- package/dist/Record.d.ts.map +1 -1
- package/dist/Record.js +16 -15
- package/dist/Record.js.map +1 -1
- package/dist/Scheduler.d.ts +25 -123
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/Scheduler.js +20 -123
- package/dist/Scheduler.js.map +1 -1
- package/dist/Schema.d.ts +30 -0
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +28 -1
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaGetter.js +6 -4
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +32 -27
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/Semaphore.d.ts +149 -53
- package/dist/Semaphore.d.ts.map +1 -1
- package/dist/Semaphore.js +137 -117
- package/dist/Semaphore.js.map +1 -1
- package/dist/ServiceMap.d.ts +26 -0
- package/dist/ServiceMap.d.ts.map +1 -1
- package/dist/ServiceMap.js +36 -21
- package/dist/ServiceMap.js.map +1 -1
- package/dist/Stream.js +1 -1
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +114 -47
- package/dist/String.d.ts.map +1 -1
- package/dist/String.js +29 -47
- package/dist/String.js.map +1 -1
- package/dist/SubscriptionRef.d.ts +1 -2
- package/dist/SubscriptionRef.d.ts.map +1 -1
- package/dist/SubscriptionRef.js +81 -115
- package/dist/SubscriptionRef.js.map +1 -1
- package/dist/Terminal.d.ts +2 -1
- package/dist/Terminal.d.ts.map +1 -1
- package/dist/Terminal.js.map +1 -1
- package/dist/Tracer.d.ts +5 -4
- package/dist/Tracer.d.ts.map +1 -1
- package/dist/Tracer.js +2 -1
- package/dist/Tracer.js.map +1 -1
- package/dist/Trie.d.ts +26 -14
- package/dist/Trie.d.ts.map +1 -1
- package/dist/Trie.js +8 -4
- package/dist/Trie.js.map +1 -1
- package/dist/TxHashMap.d.ts +77 -59
- package/dist/TxHashMap.d.ts.map +1 -1
- package/dist/TxHashMap.js +25 -19
- package/dist/TxHashMap.js.map +1 -1
- package/dist/TxSemaphore.d.ts +162 -2
- package/dist/TxSemaphore.d.ts.map +1 -1
- package/dist/TxSemaphore.js +16 -2
- package/dist/TxSemaphore.js.map +1 -1
- package/dist/index.d.ts +88 -32
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +88 -32
- package/dist/index.js.map +1 -1
- package/dist/internal/dateTime.js +9 -9
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +20 -89
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/hashMap.js +2 -1
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/option.js +6 -0
- package/dist/internal/option.js.map +1 -1
- package/dist/internal/trie.js +3 -3
- package/dist/internal/trie.js.map +1 -1
- package/dist/unstable/ai/AiError.js +1 -1
- package/dist/unstable/ai/AiError.js.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.js +4 -0
- package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Chat.d.ts.map +1 -1
- package/dist/unstable/ai/Chat.js +2 -2
- package/dist/unstable/ai/Chat.js.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js +4 -0
- package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Tool.d.ts +14 -0
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +13 -0
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/cli/Argument.d.ts +2 -4
- package/dist/unstable/cli/Argument.d.ts.map +1 -1
- package/dist/unstable/cli/Argument.js +1 -3
- package/dist/unstable/cli/Argument.js.map +1 -1
- package/dist/unstable/cli/CliOutput.d.ts +3 -2
- package/dist/unstable/cli/CliOutput.d.ts.map +1 -1
- package/dist/unstable/cli/CliOutput.js +4 -3
- package/dist/unstable/cli/CliOutput.js.map +1 -1
- package/dist/unstable/cli/Command.d.ts +3 -2
- package/dist/unstable/cli/Command.d.ts.map +1 -1
- package/dist/unstable/cli/Command.js +3 -3
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cli/Flag.d.ts +2 -2
- package/dist/unstable/cli/Flag.d.ts.map +1 -1
- package/dist/unstable/cli/Flag.js +1 -1
- package/dist/unstable/cli/Flag.js.map +1 -1
- package/dist/unstable/cli/HelpDoc.d.ts +14 -12
- package/dist/unstable/cli/HelpDoc.d.ts.map +1 -1
- package/dist/unstable/cli/Param.d.ts +4 -4
- package/dist/unstable/cli/Param.d.ts.map +1 -1
- package/dist/unstable/cli/Param.js +7 -7
- package/dist/unstable/cli/Param.js.map +1 -1
- package/dist/unstable/cli/Primitive.d.ts +1 -1
- package/dist/unstable/cli/Primitive.d.ts.map +1 -1
- package/dist/unstable/cli/Primitive.js.map +1 -1
- package/dist/unstable/cli/Prompt.js +71 -67
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/cli/internal/completions/CommandDescriptor.js +9 -2
- package/dist/unstable/cli/internal/completions/CommandDescriptor.js.map +1 -1
- package/dist/unstable/cli/internal/parser.js +8 -3
- package/dist/unstable/cli/internal/parser.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts +3 -2
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +25 -23
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/cluster/Entity.d.ts +3 -2
- package/dist/unstable/cluster/Entity.d.ts.map +1 -1
- package/dist/unstable/cluster/Entity.js +7 -7
- package/dist/unstable/cluster/Entity.js.map +1 -1
- package/dist/unstable/cluster/Message.d.ts +4 -3
- package/dist/unstable/cluster/Message.d.ts.map +1 -1
- package/dist/unstable/cluster/Message.js +3 -2
- package/dist/unstable/cluster/Message.js.map +1 -1
- package/dist/unstable/cluster/MessageStorage.d.ts +10 -10
- package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/MessageStorage.js +12 -12
- package/dist/unstable/cluster/MessageStorage.js.map +1 -1
- package/dist/unstable/cluster/Reply.d.ts +2 -1
- package/dist/unstable/cluster/Reply.d.ts.map +1 -1
- package/dist/unstable/cluster/Reply.js +4 -3
- package/dist/unstable/cluster/Reply.js.map +1 -1
- package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerServer.js +9 -8
- package/dist/unstable/cluster/RunnerServer.js.map +1 -1
- package/dist/unstable/cluster/Runners.d.ts +2 -1
- package/dist/unstable/cluster/Runners.d.ts.map +1 -1
- package/dist/unstable/cluster/Runners.js +7 -6
- package/dist/unstable/cluster/Runners.js.map +1 -1
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +19 -13
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.d.ts +5 -4
- package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.js +4 -4
- package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.js +19 -18
- package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/unstable/cluster/internal/entityManager.js +9 -10
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.d.ts +2 -1
- package/dist/unstable/devtools/DevToolsSchema.d.ts.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.js +1 -4
- package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
- package/dist/unstable/http/Cookies.d.ts +5 -4
- package/dist/unstable/http/Cookies.d.ts.map +1 -1
- package/dist/unstable/http/Cookies.js +3 -4
- package/dist/unstable/http/Cookies.js.map +1 -1
- package/dist/unstable/http/Etag.d.ts.map +1 -1
- package/dist/unstable/http/Etag.js +5 -1
- package/dist/unstable/http/Etag.js.map +1 -1
- package/dist/unstable/http/Headers.d.ts +3 -2
- package/dist/unstable/http/Headers.d.ts.map +1 -1
- package/dist/unstable/http/Headers.js +2 -1
- package/dist/unstable/http/Headers.js.map +1 -1
- package/dist/unstable/http/HttpClient.d.ts.map +1 -1
- package/dist/unstable/http/HttpClient.js +2 -1
- package/dist/unstable/http/HttpClient.js.map +1 -1
- package/dist/unstable/http/HttpClientRequest.d.ts +4 -3
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.js +8 -6
- package/dist/unstable/http/HttpClientRequest.js.map +1 -1
- package/dist/unstable/http/HttpClientResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientResponse.js +2 -1
- package/dist/unstable/http/HttpClientResponse.js.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.d.ts +2 -1
- package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
- package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/unstable/http/HttpMiddleware.js +16 -15
- package/dist/unstable/http/HttpMiddleware.js.map +1 -1
- package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
- package/dist/unstable/http/HttpPlatform.js +3 -2
- package/dist/unstable/http/HttpPlatform.js.map +1 -1
- package/dist/unstable/http/HttpRouter.d.ts +2 -1
- package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
- package/dist/unstable/http/HttpRouter.js +7 -7
- package/dist/unstable/http/HttpRouter.js.map +1 -1
- package/dist/unstable/http/HttpServer.d.ts.map +1 -1
- package/dist/unstable/http/HttpServer.js +2 -2
- package/dist/unstable/http/HttpServer.js.map +1 -1
- package/dist/unstable/http/HttpServerError.d.ts +2 -1
- package/dist/unstable/http/HttpServerError.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerError.js +2 -1
- package/dist/unstable/http/HttpServerError.js.map +1 -1
- package/dist/unstable/http/HttpServerRequest.d.ts +3 -2
- package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRequest.js +14 -10
- package/dist/unstable/http/HttpServerRequest.js.map +1 -1
- package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerResponse.js +4 -3
- package/dist/unstable/http/HttpServerResponse.js.map +1 -1
- package/dist/unstable/http/HttpTraceContext.d.ts +3 -2
- package/dist/unstable/http/HttpTraceContext.d.ts.map +1 -1
- package/dist/unstable/http/HttpTraceContext.js +27 -15
- package/dist/unstable/http/HttpTraceContext.js.map +1 -1
- package/dist/unstable/http/UrlParams.d.ts +5 -4
- package/dist/unstable/http/UrlParams.d.ts.map +1 -1
- package/dist/unstable/http/UrlParams.js +5 -6
- package/dist/unstable/http/UrlParams.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +4 -2
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.d.ts +15 -0
- package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.js +81 -3
- package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
- package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.js +2 -2
- package/dist/unstable/observability/OtlpExporter.js.map +1 -1
- package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpTracer.js +7 -3
- package/dist/unstable/observability/OtlpTracer.js.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +1 -5
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.js +4 -2
- package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
- package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
- package/dist/unstable/rpc/Rpc.js +4 -3
- package/dist/unstable/rpc/Rpc.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +4 -4
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSchema.js +3 -2
- package/dist/unstable/rpc/RpcSchema.js.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.js +4 -1
- package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +3 -2
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +2 -1
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
- package/dist/unstable/sql/SqlClient.js +1 -1
- package/dist/unstable/sql/SqlClient.js.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.js +6 -6
- package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts +2 -1
- package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts +5 -4
- package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js +19 -14
- package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +1 -1
- package/src/Array.ts +112 -105
- package/src/BigDecimal.ts +63 -66
- package/src/BigInt.ts +49 -41
- package/src/Chunk.ts +68 -63
- package/src/Config.ts +4 -1
- package/src/Cron.ts +10 -15
- package/src/DateTime.ts +16 -15
- package/src/Deferred.ts +8 -6
- package/src/Duration.ts +34 -33
- package/src/Effect.ts +3 -4
- package/src/Fiber.ts +2 -1
- package/src/FiberHandle.ts +10 -9
- package/src/FiberMap.ts +22 -22
- package/src/FileSystem.ts +25 -22
- package/src/Graph.ts +105 -105
- package/src/HashMap.ts +11 -5
- package/src/Iterable.ts +13 -13
- package/src/Latch.ts +85 -3
- package/src/Layer.ts +121 -0
- package/src/Number.ts +85 -26
- package/src/Option.ts +2 -0
- package/src/PartitionedSemaphore.ts +414 -0
- package/src/PubSub.ts +7 -6
- package/src/Queue.ts +5 -5
- package/src/Record.ts +52 -47
- package/src/Scheduler.ts +37 -126
- package/src/Schema.ts +49 -1
- package/src/SchemaGetter.ts +4 -4
- package/src/SchemaTransformation.ts +27 -27
- package/src/Semaphore.ts +271 -183
- package/src/ServiceMap.ts +83 -31
- package/src/Stream.ts +1 -1
- package/src/String.ts +122 -69
- package/src/SubscriptionRef.ts +96 -117
- package/src/Terminal.ts +2 -1
- package/src/Tracer.ts +6 -5
- package/src/Trie.ts +26 -14
- package/src/TxHashMap.ts +78 -60
- package/src/TxSemaphore.ts +186 -11
- package/src/index.ts +89 -33
- package/src/internal/dateTime.ts +14 -14
- package/src/internal/effect.ts +29 -121
- package/src/internal/hashMap.ts +4 -3
- package/src/internal/option.ts +7 -0
- package/src/internal/trie.ts +6 -6
- package/src/unstable/ai/AiError.ts +1 -1
- package/src/unstable/ai/AnthropicStructuredOutput.ts +4 -0
- package/src/unstable/ai/Chat.ts +6 -2
- package/src/unstable/ai/OpenAiStructuredOutput.ts +4 -0
- package/src/unstable/ai/Tool.ts +20 -0
- package/src/unstable/cli/Argument.ts +2 -4
- package/src/unstable/cli/CliOutput.ts +7 -5
- package/src/unstable/cli/Command.ts +5 -5
- package/src/unstable/cli/Flag.ts +2 -2
- package/src/unstable/cli/HelpDoc.ts +14 -12
- package/src/unstable/cli/Param.ts +15 -11
- package/src/unstable/cli/Primitive.ts +1 -1
- package/src/unstable/cli/Prompt.ts +81 -83
- package/src/unstable/cli/internal/completions/CommandDescriptor.ts +3 -2
- package/src/unstable/cli/internal/parser.ts +7 -4
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +35 -30
- package/src/unstable/cluster/Entity.ts +13 -12
- package/src/unstable/cluster/Message.ts +6 -5
- package/src/unstable/cluster/MessageStorage.ts +26 -25
- package/src/unstable/cluster/Reply.ts +7 -4
- package/src/unstable/cluster/RunnerServer.ts +10 -13
- package/src/unstable/cluster/Runners.ts +8 -7
- package/src/unstable/cluster/Sharding.ts +24 -17
- package/src/unstable/cluster/ShardingConfig.ts +6 -6
- package/src/unstable/cluster/SqlMessageStorage.ts +21 -18
- package/src/unstable/cluster/internal/entityManager.ts +27 -21
- package/src/unstable/devtools/DevToolsSchema.ts +3 -2
- package/src/unstable/http/Cookies.ts +7 -8
- package/src/unstable/http/Etag.ts +5 -3
- package/src/unstable/http/Headers.ts +6 -5
- package/src/unstable/http/HttpClient.ts +2 -1
- package/src/unstable/http/HttpClientRequest.ts +11 -9
- package/src/unstable/http/HttpClientResponse.ts +3 -2
- package/src/unstable/http/HttpIncomingMessage.ts +2 -1
- package/src/unstable/http/HttpMiddleware.ts +16 -15
- package/src/unstable/http/HttpPlatform.ts +3 -2
- package/src/unstable/http/HttpRouter.ts +9 -9
- package/src/unstable/http/HttpServer.ts +3 -9
- package/src/unstable/http/HttpServerError.ts +3 -2
- package/src/unstable/http/HttpServerRequest.ts +25 -21
- package/src/unstable/http/HttpServerResponse.ts +5 -4
- package/src/unstable/http/HttpTraceContext.ts +31 -17
- package/src/unstable/http/UrlParams.ts +11 -14
- package/src/unstable/httpapi/HttpApiBuilder.ts +9 -3
- package/src/unstable/httpapi/HttpApiError.ts +67 -12
- package/src/unstable/observability/OtlpExporter.ts +5 -2
- package/src/unstable/observability/OtlpTracer.ts +8 -4
- package/src/unstable/reactivity/Atom.ts +1 -4
- package/src/unstable/reactivity/AtomRegistry.ts +5 -3
- package/src/unstable/rpc/Rpc.ts +4 -3
- package/src/unstable/rpc/RpcClient.ts +10 -9
- package/src/unstable/rpc/RpcSchema.ts +6 -5
- package/src/unstable/rpc/RpcSerialization.ts +4 -1
- package/src/unstable/rpc/RpcServer.ts +3 -3
- package/src/unstable/socket/Socket.ts +2 -1
- package/src/unstable/sql/SqlClient.ts +5 -3
- package/src/unstable/workflow/DurableDeferred.ts +6 -6
- package/src/unstable/workflow/Workflow.ts +1 -1
- package/src/unstable/workflow/WorkflowEngine.ts +29 -20
- package/dist/NullOr.d.ts +0 -149
- package/dist/NullOr.d.ts.map +0 -1
- package/dist/NullOr.js +0 -152
- package/dist/NullOr.js.map +0 -1
- package/src/NullOr.ts +0 -204
package/src/TxHashMap.ts
CHANGED
|
@@ -42,7 +42,7 @@ const TxHashMapProto = {
|
|
|
42
42
|
*
|
|
43
43
|
* @example
|
|
44
44
|
* ```ts
|
|
45
|
-
* import { Effect,
|
|
45
|
+
* import { Effect, TxHashMap } from "effect"
|
|
46
46
|
*
|
|
47
47
|
* const program = Effect.gen(function*() {
|
|
48
48
|
* // Create a transactional hash map
|
|
@@ -57,7 +57,7 @@ const TxHashMapProto = {
|
|
|
57
57
|
* yield* Effect.transaction(
|
|
58
58
|
* Effect.gen(function*() {
|
|
59
59
|
* const currentUser = yield* TxHashMap.get(txMap, "user1")
|
|
60
|
-
* if (
|
|
60
|
+
* if (currentUser._tag === "Some") {
|
|
61
61
|
* yield* TxHashMap.set(txMap, "user1", currentUser.value + "_updated")
|
|
62
62
|
* yield* TxHashMap.remove(txMap, "user2")
|
|
63
63
|
* }
|
|
@@ -348,7 +348,7 @@ export const fromIterable = <K, V>(
|
|
|
348
348
|
*
|
|
349
349
|
* // Use with pipe syntax for type-safe access
|
|
350
350
|
* const bobRole = yield* TxHashMap.get(userMap, "bob")
|
|
351
|
-
* if (
|
|
351
|
+
* if (bobRole._tag === "Some") {
|
|
352
352
|
* console.log(bobRole.value.role) // "user"
|
|
353
353
|
* }
|
|
354
354
|
* })
|
|
@@ -380,7 +380,7 @@ export const get: {
|
|
|
380
380
|
*
|
|
381
381
|
* // Use with pipe syntax for type-safe access
|
|
382
382
|
* const bobRole = yield* TxHashMap.get(userMap, "bob")
|
|
383
|
-
* if (
|
|
383
|
+
* if (bobRole._tag === "Some") {
|
|
384
384
|
* console.log(bobRole.value.role) // "user"
|
|
385
385
|
* }
|
|
386
386
|
* })
|
|
@@ -412,7 +412,7 @@ export const get: {
|
|
|
412
412
|
*
|
|
413
413
|
* // Use with pipe syntax for type-safe access
|
|
414
414
|
* const bobRole = yield* TxHashMap.get(userMap, "bob")
|
|
415
|
-
* if (
|
|
415
|
+
* if (bobRole._tag === "Some") {
|
|
416
416
|
* console.log(bobRole.value.role) // "user"
|
|
417
417
|
* }
|
|
418
418
|
* })
|
|
@@ -1068,7 +1068,7 @@ export const modify: {
|
|
|
1068
1068
|
*
|
|
1069
1069
|
* @example
|
|
1070
1070
|
* ```ts
|
|
1071
|
-
* import { Effect,
|
|
1071
|
+
* import { Effect, TxHashMap } from "effect"
|
|
1072
1072
|
*
|
|
1073
1073
|
* const program = Effect.gen(function*() {
|
|
1074
1074
|
* const storage = yield* TxHashMap.make<string, string | number>([
|
|
@@ -1076,26 +1076,32 @@ export const modify: {
|
|
|
1076
1076
|
* "content1"
|
|
1077
1077
|
* ], ["access_count", 0])
|
|
1078
1078
|
*
|
|
1079
|
-
* // Increment counter or initialize to 1
|
|
1080
|
-
* const updateFn = (opt: Option.Option<string | number>) =>
|
|
1081
|
-
* Option.isSome(opt) && typeof opt.value === "number"
|
|
1082
|
-
* ? Option.some(opt.value + 1)
|
|
1083
|
-
* : Option.some(1)
|
|
1084
|
-
*
|
|
1085
1079
|
* // Increment existing counter
|
|
1086
|
-
* yield* TxHashMap.modifyAt(storage, "access_count",
|
|
1080
|
+
* yield* TxHashMap.modifyAt(storage, "access_count", (current) =>
|
|
1081
|
+
* current._tag === "Some" && typeof current.value === "number"
|
|
1082
|
+
* ? { ...current, value: current.value + 1 }
|
|
1083
|
+
* : current
|
|
1084
|
+
* )
|
|
1087
1085
|
* const count1 = yield* TxHashMap.get(storage, "access_count")
|
|
1088
1086
|
* console.log(count1) // Option.some(1)
|
|
1089
1087
|
*
|
|
1090
1088
|
* // Increment existing counter again
|
|
1091
|
-
* yield* TxHashMap.modifyAt(storage, "access_count",
|
|
1089
|
+
* yield* TxHashMap.modifyAt(storage, "access_count", (current) =>
|
|
1090
|
+
* current._tag === "Some" && typeof current.value === "number"
|
|
1091
|
+
* ? { ...current, value: current.value + 1 }
|
|
1092
|
+
* : current
|
|
1093
|
+
* )
|
|
1092
1094
|
* const count2 = yield* TxHashMap.get(storage, "access_count")
|
|
1093
1095
|
* console.log(count2) // Option.some(2)
|
|
1094
1096
|
*
|
|
1095
|
-
* //
|
|
1096
|
-
* yield* TxHashMap.modifyAt(storage, "file1.txt", () =>
|
|
1097
|
-
*
|
|
1098
|
-
*
|
|
1097
|
+
* // Update an existing string entry
|
|
1098
|
+
* yield* TxHashMap.modifyAt(storage, "file1.txt", (current) =>
|
|
1099
|
+
* current._tag === "Some" && typeof current.value === "string"
|
|
1100
|
+
* ? { ...current, value: `${current.value}.bak` }
|
|
1101
|
+
* : current
|
|
1102
|
+
* )
|
|
1103
|
+
* const backup = yield* TxHashMap.get(storage, "file1.txt")
|
|
1104
|
+
* console.log(backup) // Option.some("content1.bak")
|
|
1099
1105
|
* })
|
|
1100
1106
|
* ```
|
|
1101
1107
|
*
|
|
@@ -1112,7 +1118,7 @@ export const modifyAt: {
|
|
|
1112
1118
|
*
|
|
1113
1119
|
* @example
|
|
1114
1120
|
* ```ts
|
|
1115
|
-
* import { Effect,
|
|
1121
|
+
* import { Effect, TxHashMap } from "effect"
|
|
1116
1122
|
*
|
|
1117
1123
|
* const program = Effect.gen(function*() {
|
|
1118
1124
|
* const storage = yield* TxHashMap.make<string, string | number>([
|
|
@@ -1120,26 +1126,32 @@ export const modifyAt: {
|
|
|
1120
1126
|
* "content1"
|
|
1121
1127
|
* ], ["access_count", 0])
|
|
1122
1128
|
*
|
|
1123
|
-
* // Increment counter or initialize to 1
|
|
1124
|
-
* const updateFn = (opt: Option.Option<string | number>) =>
|
|
1125
|
-
* Option.isSome(opt) && typeof opt.value === "number"
|
|
1126
|
-
* ? Option.some(opt.value + 1)
|
|
1127
|
-
* : Option.some(1)
|
|
1128
|
-
*
|
|
1129
1129
|
* // Increment existing counter
|
|
1130
|
-
* yield* TxHashMap.modifyAt(storage, "access_count",
|
|
1130
|
+
* yield* TxHashMap.modifyAt(storage, "access_count", (current) =>
|
|
1131
|
+
* current._tag === "Some" && typeof current.value === "number"
|
|
1132
|
+
* ? { ...current, value: current.value + 1 }
|
|
1133
|
+
* : current
|
|
1134
|
+
* )
|
|
1131
1135
|
* const count1 = yield* TxHashMap.get(storage, "access_count")
|
|
1132
1136
|
* console.log(count1) // Option.some(1)
|
|
1133
1137
|
*
|
|
1134
1138
|
* // Increment existing counter again
|
|
1135
|
-
* yield* TxHashMap.modifyAt(storage, "access_count",
|
|
1139
|
+
* yield* TxHashMap.modifyAt(storage, "access_count", (current) =>
|
|
1140
|
+
* current._tag === "Some" && typeof current.value === "number"
|
|
1141
|
+
* ? { ...current, value: current.value + 1 }
|
|
1142
|
+
* : current
|
|
1143
|
+
* )
|
|
1136
1144
|
* const count2 = yield* TxHashMap.get(storage, "access_count")
|
|
1137
1145
|
* console.log(count2) // Option.some(2)
|
|
1138
1146
|
*
|
|
1139
|
-
* //
|
|
1140
|
-
* yield* TxHashMap.modifyAt(storage, "file1.txt", () =>
|
|
1141
|
-
*
|
|
1142
|
-
*
|
|
1147
|
+
* // Update an existing string entry
|
|
1148
|
+
* yield* TxHashMap.modifyAt(storage, "file1.txt", (current) =>
|
|
1149
|
+
* current._tag === "Some" && typeof current.value === "string"
|
|
1150
|
+
* ? { ...current, value: `${current.value}.bak` }
|
|
1151
|
+
* : current
|
|
1152
|
+
* )
|
|
1153
|
+
* const backup = yield* TxHashMap.get(storage, "file1.txt")
|
|
1154
|
+
* console.log(backup) // Option.some("content1.bak")
|
|
1143
1155
|
* })
|
|
1144
1156
|
* ```
|
|
1145
1157
|
*
|
|
@@ -1156,7 +1168,7 @@ export const modifyAt: {
|
|
|
1156
1168
|
*
|
|
1157
1169
|
* @example
|
|
1158
1170
|
* ```ts
|
|
1159
|
-
* import { Effect,
|
|
1171
|
+
* import { Effect, TxHashMap } from "effect"
|
|
1160
1172
|
*
|
|
1161
1173
|
* const program = Effect.gen(function*() {
|
|
1162
1174
|
* const storage = yield* TxHashMap.make<string, string | number>([
|
|
@@ -1164,26 +1176,32 @@ export const modifyAt: {
|
|
|
1164
1176
|
* "content1"
|
|
1165
1177
|
* ], ["access_count", 0])
|
|
1166
1178
|
*
|
|
1167
|
-
* // Increment counter or initialize to 1
|
|
1168
|
-
* const updateFn = (opt: Option.Option<string | number>) =>
|
|
1169
|
-
* Option.isSome(opt) && typeof opt.value === "number"
|
|
1170
|
-
* ? Option.some(opt.value + 1)
|
|
1171
|
-
* : Option.some(1)
|
|
1172
|
-
*
|
|
1173
1179
|
* // Increment existing counter
|
|
1174
|
-
* yield* TxHashMap.modifyAt(storage, "access_count",
|
|
1180
|
+
* yield* TxHashMap.modifyAt(storage, "access_count", (current) =>
|
|
1181
|
+
* current._tag === "Some" && typeof current.value === "number"
|
|
1182
|
+
* ? { ...current, value: current.value + 1 }
|
|
1183
|
+
* : current
|
|
1184
|
+
* )
|
|
1175
1185
|
* const count1 = yield* TxHashMap.get(storage, "access_count")
|
|
1176
1186
|
* console.log(count1) // Option.some(1)
|
|
1177
1187
|
*
|
|
1178
1188
|
* // Increment existing counter again
|
|
1179
|
-
* yield* TxHashMap.modifyAt(storage, "access_count",
|
|
1189
|
+
* yield* TxHashMap.modifyAt(storage, "access_count", (current) =>
|
|
1190
|
+
* current._tag === "Some" && typeof current.value === "number"
|
|
1191
|
+
* ? { ...current, value: current.value + 1 }
|
|
1192
|
+
* : current
|
|
1193
|
+
* )
|
|
1180
1194
|
* const count2 = yield* TxHashMap.get(storage, "access_count")
|
|
1181
1195
|
* console.log(count2) // Option.some(2)
|
|
1182
1196
|
*
|
|
1183
|
-
* //
|
|
1184
|
-
* yield* TxHashMap.modifyAt(storage, "file1.txt", () =>
|
|
1185
|
-
*
|
|
1186
|
-
*
|
|
1197
|
+
* // Update an existing string entry
|
|
1198
|
+
* yield* TxHashMap.modifyAt(storage, "file1.txt", (current) =>
|
|
1199
|
+
* current._tag === "Some" && typeof current.value === "string"
|
|
1200
|
+
* ? { ...current, value: `${current.value}.bak` }
|
|
1201
|
+
* : current
|
|
1202
|
+
* )
|
|
1203
|
+
* const backup = yield* TxHashMap.get(storage, "file1.txt")
|
|
1204
|
+
* console.log(backup) // Option.some("content1.bak")
|
|
1187
1205
|
* })
|
|
1188
1206
|
* ```
|
|
1189
1207
|
*
|
|
@@ -1235,7 +1253,7 @@ export const modifyAt: {
|
|
|
1235
1253
|
* // Useful for iteration
|
|
1236
1254
|
* for (const username of usernames) {
|
|
1237
1255
|
* const role = yield* TxHashMap.get(userRoles, username)
|
|
1238
|
-
* if (
|
|
1256
|
+
* if (role._tag === "Some") {
|
|
1239
1257
|
* console.log(`${username}: ${role.value}`)
|
|
1240
1258
|
* }
|
|
1241
1259
|
* }
|
|
@@ -3061,8 +3079,8 @@ export const hasBy: {
|
|
|
3061
3079
|
* (task) => task.priority >= 2 && !task.completed
|
|
3062
3080
|
* )
|
|
3063
3081
|
*
|
|
3064
|
-
* if (highPriorityTask) {
|
|
3065
|
-
* const [taskId, task] = highPriorityTask
|
|
3082
|
+
* if (highPriorityTask._tag === "Some") {
|
|
3083
|
+
* const [taskId, task] = highPriorityTask.value
|
|
3066
3084
|
* console.log(`Found task: ${taskId}, priority: ${task.priority}`)
|
|
3067
3085
|
* // "Found task: task3, priority: 2"
|
|
3068
3086
|
* }
|
|
@@ -3072,8 +3090,8 @@ export const hasBy: {
|
|
|
3072
3090
|
* TxHashMap.findFirst((task) => task.assignee === "alice")
|
|
3073
3091
|
* )
|
|
3074
3092
|
*
|
|
3075
|
-
* if (aliceTask) {
|
|
3076
|
-
* console.log(`Alice's task: ${aliceTask[0]}`)
|
|
3093
|
+
* if (aliceTask._tag === "Some") {
|
|
3094
|
+
* console.log(`Alice's task: ${aliceTask.value[0]}`)
|
|
3077
3095
|
* }
|
|
3078
3096
|
* })
|
|
3079
3097
|
* ```
|
|
@@ -3104,8 +3122,8 @@ export const findFirst: {
|
|
|
3104
3122
|
* (task) => task.priority >= 2 && !task.completed
|
|
3105
3123
|
* )
|
|
3106
3124
|
*
|
|
3107
|
-
* if (highPriorityTask) {
|
|
3108
|
-
* const [taskId, task] = highPriorityTask
|
|
3125
|
+
* if (highPriorityTask._tag === "Some") {
|
|
3126
|
+
* const [taskId, task] = highPriorityTask.value
|
|
3109
3127
|
* console.log(`Found task: ${taskId}, priority: ${task.priority}`)
|
|
3110
3128
|
* // "Found task: task3, priority: 2"
|
|
3111
3129
|
* }
|
|
@@ -3115,8 +3133,8 @@ export const findFirst: {
|
|
|
3115
3133
|
* TxHashMap.findFirst((task) => task.assignee === "alice")
|
|
3116
3134
|
* )
|
|
3117
3135
|
*
|
|
3118
|
-
* if (aliceTask) {
|
|
3119
|
-
* console.log(`Alice's task: ${aliceTask[0]}`)
|
|
3136
|
+
* if (aliceTask._tag === "Some") {
|
|
3137
|
+
* console.log(`Alice's task: ${aliceTask.value[0]}`)
|
|
3120
3138
|
* }
|
|
3121
3139
|
* })
|
|
3122
3140
|
* ```
|
|
@@ -3124,7 +3142,7 @@ export const findFirst: {
|
|
|
3124
3142
|
* @since 2.0.0
|
|
3125
3143
|
* @category combinators
|
|
3126
3144
|
*/
|
|
3127
|
-
<K, V>(predicate: (value: V, key: K) => boolean): (self: TxHashMap<K, V>) => Effect.Effect<[K, V]
|
|
3145
|
+
<K, V>(predicate: (value: V, key: K) => boolean): (self: TxHashMap<K, V>) => Effect.Effect<Option.Option<[K, V]>, never, Effect.Transaction>
|
|
3128
3146
|
/**
|
|
3129
3147
|
* Finds the first entry in the TxHashMap that matches the given predicate.
|
|
3130
3148
|
* Returns the key-value pair as a tuple wrapped in an Option.
|
|
@@ -3147,8 +3165,8 @@ export const findFirst: {
|
|
|
3147
3165
|
* (task) => task.priority >= 2 && !task.completed
|
|
3148
3166
|
* )
|
|
3149
3167
|
*
|
|
3150
|
-
* if (highPriorityTask) {
|
|
3151
|
-
* const [taskId, task] = highPriorityTask
|
|
3168
|
+
* if (highPriorityTask._tag === "Some") {
|
|
3169
|
+
* const [taskId, task] = highPriorityTask.value
|
|
3152
3170
|
* console.log(`Found task: ${taskId}, priority: ${task.priority}`)
|
|
3153
3171
|
* // "Found task: task3, priority: 2"
|
|
3154
3172
|
* }
|
|
@@ -3158,8 +3176,8 @@ export const findFirst: {
|
|
|
3158
3176
|
* TxHashMap.findFirst((task) => task.assignee === "alice")
|
|
3159
3177
|
* )
|
|
3160
3178
|
*
|
|
3161
|
-
* if (aliceTask) {
|
|
3162
|
-
* console.log(`Alice's task: ${aliceTask[0]}`)
|
|
3179
|
+
* if (aliceTask._tag === "Some") {
|
|
3180
|
+
* console.log(`Alice's task: ${aliceTask.value[0]}`)
|
|
3163
3181
|
* }
|
|
3164
3182
|
* })
|
|
3165
3183
|
* ```
|
|
@@ -3167,13 +3185,13 @@ export const findFirst: {
|
|
|
3167
3185
|
* @since 2.0.0
|
|
3168
3186
|
* @category combinators
|
|
3169
3187
|
*/
|
|
3170
|
-
<K, V>(self: TxHashMap<K, V>, predicate: (value: V, key: K) => boolean): Effect.Effect<[K, V]
|
|
3188
|
+
<K, V>(self: TxHashMap<K, V>, predicate: (value: V, key: K) => boolean): Effect.Effect<Option.Option<[K, V]>, never, Effect.Transaction>
|
|
3171
3189
|
} = dual(
|
|
3172
3190
|
2,
|
|
3173
3191
|
<K, V>(
|
|
3174
3192
|
self: TxHashMap<K, V>,
|
|
3175
3193
|
predicate: (value: V, key: K) => boolean
|
|
3176
|
-
): Effect.Effect<[K, V]
|
|
3194
|
+
): Effect.Effect<Option.Option<[K, V]>, never, Effect.Transaction> =>
|
|
3177
3195
|
TxRef.get(self.ref).pipe(Effect.map((map) => HashMap.findFirst(map, predicate)))
|
|
3178
3196
|
)
|
|
3179
3197
|
|
package/src/TxSemaphore.ts
CHANGED
|
@@ -433,15 +433,102 @@ export const releaseN = (self: TxSemaphore, n: number): Effect.Effect<void, neve
|
|
|
433
433
|
* @since 4.0.0
|
|
434
434
|
* @category combinators
|
|
435
435
|
*/
|
|
436
|
-
export const withPermit
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
436
|
+
export const withPermit: {
|
|
437
|
+
/**
|
|
438
|
+
* Executes an effect with a single permit from the semaphore. The permit is
|
|
439
|
+
* automatically acquired before execution and released afterwards, even if the
|
|
440
|
+
* effect fails or is interrupted.
|
|
441
|
+
*
|
|
442
|
+
* **Note**: The permit acquisition and release operations use atomic semantics
|
|
443
|
+
* to ensure proper resource management with Effect's scoped operations.
|
|
444
|
+
*
|
|
445
|
+
* @example
|
|
446
|
+
* ```ts
|
|
447
|
+
* import { Console, Effect, TxSemaphore } from "effect"
|
|
448
|
+
*
|
|
449
|
+
* const program = Effect.gen(function*() {
|
|
450
|
+
* const semaphore = yield* TxSemaphore.make(2)
|
|
451
|
+
*
|
|
452
|
+
* // Execute database operation with automatic permit management
|
|
453
|
+
* const result = yield* TxSemaphore.withPermit(
|
|
454
|
+
* semaphore,
|
|
455
|
+
* Effect.gen(function*() {
|
|
456
|
+
* yield* Console.log("Permit acquired, accessing database...")
|
|
457
|
+
* yield* Effect.sleep("100 millis") // Simulate database work
|
|
458
|
+
* yield* Console.log("Database operation complete")
|
|
459
|
+
* return "query result"
|
|
460
|
+
* })
|
|
461
|
+
* )
|
|
462
|
+
*
|
|
463
|
+
* yield* Console.log(`Result: ${result}`)
|
|
464
|
+
* // Permit is automatically released here
|
|
465
|
+
* })
|
|
466
|
+
* ```
|
|
467
|
+
*
|
|
468
|
+
* @param self - The TxSemaphore to acquire a permit from
|
|
469
|
+
* @param effect - The effect to execute with the permit
|
|
470
|
+
* @returns Effect that succeeds with the result of the provided effect
|
|
471
|
+
*
|
|
472
|
+
* @since 4.0.0
|
|
473
|
+
* @category combinators
|
|
474
|
+
*/
|
|
475
|
+
(self: TxSemaphore): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
|
|
476
|
+
/**
|
|
477
|
+
* Executes an effect with a single permit from the semaphore. The permit is
|
|
478
|
+
* automatically acquired before execution and released afterwards, even if the
|
|
479
|
+
* effect fails or is interrupted.
|
|
480
|
+
*
|
|
481
|
+
* **Note**: The permit acquisition and release operations use atomic semantics
|
|
482
|
+
* to ensure proper resource management with Effect's scoped operations.
|
|
483
|
+
*
|
|
484
|
+
* @example
|
|
485
|
+
* ```ts
|
|
486
|
+
* import { Console, Effect, TxSemaphore } from "effect"
|
|
487
|
+
*
|
|
488
|
+
* const program = Effect.gen(function*() {
|
|
489
|
+
* const semaphore = yield* TxSemaphore.make(2)
|
|
490
|
+
*
|
|
491
|
+
* // Execute database operation with automatic permit management
|
|
492
|
+
* const result = yield* TxSemaphore.withPermit(
|
|
493
|
+
* semaphore,
|
|
494
|
+
* Effect.gen(function*() {
|
|
495
|
+
* yield* Console.log("Permit acquired, accessing database...")
|
|
496
|
+
* yield* Effect.sleep("100 millis") // Simulate database work
|
|
497
|
+
* yield* Console.log("Database operation complete")
|
|
498
|
+
* return "query result"
|
|
499
|
+
* })
|
|
500
|
+
* )
|
|
501
|
+
*
|
|
502
|
+
* yield* Console.log(`Result: ${result}`)
|
|
503
|
+
* // Permit is automatically released here
|
|
504
|
+
* })
|
|
505
|
+
* ```
|
|
506
|
+
*
|
|
507
|
+
* @param self - The TxSemaphore to acquire a permit from
|
|
508
|
+
* @param effect - The effect to execute with the permit
|
|
509
|
+
* @returns Effect that succeeds with the result of the provided effect
|
|
510
|
+
*
|
|
511
|
+
* @since 4.0.0
|
|
512
|
+
* @category combinators
|
|
513
|
+
*/
|
|
514
|
+
<A, E, R>(self: TxSemaphore, effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>
|
|
515
|
+
} = ((...args: Array<any>) => {
|
|
516
|
+
if (args.length === 1) {
|
|
517
|
+
const [self] = args
|
|
518
|
+
return (effect: Effect.Effect<any, any, any>) =>
|
|
519
|
+
Effect.acquireUseRelease(
|
|
520
|
+
Effect.transaction(acquire(self)),
|
|
521
|
+
() => effect,
|
|
522
|
+
() => Effect.transaction(release(self))
|
|
523
|
+
)
|
|
524
|
+
}
|
|
525
|
+
const [self, effect] = args
|
|
526
|
+
return Effect.acquireUseRelease(
|
|
441
527
|
Effect.transaction(acquire(self)),
|
|
442
528
|
() => effect,
|
|
443
529
|
() => Effect.transaction(release(self))
|
|
444
530
|
)
|
|
531
|
+
}) as any
|
|
445
532
|
|
|
446
533
|
/**
|
|
447
534
|
* Executes an effect with the specified number of permits from the semaphore.
|
|
@@ -482,16 +569,104 @@ export const withPermit = <A, E, R>(
|
|
|
482
569
|
* @since 4.0.0
|
|
483
570
|
* @category combinators
|
|
484
571
|
*/
|
|
485
|
-
export const withPermits
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
572
|
+
export const withPermits: {
|
|
573
|
+
/**
|
|
574
|
+
* Executes an effect with the specified number of permits from the semaphore.
|
|
575
|
+
* The permits are automatically acquired before execution and released afterwards,
|
|
576
|
+
* even if the effect fails or is interrupted.
|
|
577
|
+
*
|
|
578
|
+
* **Note**: The permit acquisition and release operations use atomic semantics
|
|
579
|
+
* to ensure proper resource management with Effect's scoped operations.
|
|
580
|
+
*
|
|
581
|
+
* @example
|
|
582
|
+
* ```ts
|
|
583
|
+
* import { Console, Effect, TxSemaphore } from "effect"
|
|
584
|
+
*
|
|
585
|
+
* const program = Effect.gen(function*() {
|
|
586
|
+
* const semaphore = yield* TxSemaphore.make(5)
|
|
587
|
+
*
|
|
588
|
+
* // Execute batch operation with 3 permits
|
|
589
|
+
* const results = yield* TxSemaphore.withPermits(
|
|
590
|
+
* semaphore,
|
|
591
|
+
* 3,
|
|
592
|
+
* Effect.gen(function*() {
|
|
593
|
+
* yield* Console.log("3 permits acquired, processing batch...")
|
|
594
|
+
* yield* Effect.sleep("200 millis") // Simulate batch processing
|
|
595
|
+
* return ["result1", "result2", "result3"]
|
|
596
|
+
* })
|
|
597
|
+
* )
|
|
598
|
+
*
|
|
599
|
+
* yield* Console.log(`Batch results: ${results.join(", ")}`)
|
|
600
|
+
* // All 3 permits are automatically released here
|
|
601
|
+
* })
|
|
602
|
+
* ```
|
|
603
|
+
*
|
|
604
|
+
* @param self - The TxSemaphore to acquire permits from
|
|
605
|
+
* @param n - The number of permits to acquire (must be positive)
|
|
606
|
+
* @param effect - The effect to execute with the permits
|
|
607
|
+
* @returns Effect that succeeds with the result of the provided effect
|
|
608
|
+
*
|
|
609
|
+
* @since 4.0.0
|
|
610
|
+
* @category combinators
|
|
611
|
+
*/
|
|
612
|
+
(self: TxSemaphore, n: number): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
|
|
613
|
+
/**
|
|
614
|
+
* Executes an effect with the specified number of permits from the semaphore.
|
|
615
|
+
* The permits are automatically acquired before execution and released afterwards,
|
|
616
|
+
* even if the effect fails or is interrupted.
|
|
617
|
+
*
|
|
618
|
+
* **Note**: The permit acquisition and release operations use atomic semantics
|
|
619
|
+
* to ensure proper resource management with Effect's scoped operations.
|
|
620
|
+
*
|
|
621
|
+
* @example
|
|
622
|
+
* ```ts
|
|
623
|
+
* import { Console, Effect, TxSemaphore } from "effect"
|
|
624
|
+
*
|
|
625
|
+
* const program = Effect.gen(function*() {
|
|
626
|
+
* const semaphore = yield* TxSemaphore.make(5)
|
|
627
|
+
*
|
|
628
|
+
* // Execute batch operation with 3 permits
|
|
629
|
+
* const results = yield* TxSemaphore.withPermits(
|
|
630
|
+
* semaphore,
|
|
631
|
+
* 3,
|
|
632
|
+
* Effect.gen(function*() {
|
|
633
|
+
* yield* Console.log("3 permits acquired, processing batch...")
|
|
634
|
+
* yield* Effect.sleep("200 millis") // Simulate batch processing
|
|
635
|
+
* return ["result1", "result2", "result3"]
|
|
636
|
+
* })
|
|
637
|
+
* )
|
|
638
|
+
*
|
|
639
|
+
* yield* Console.log(`Batch results: ${results.join(", ")}`)
|
|
640
|
+
* // All 3 permits are automatically released here
|
|
641
|
+
* })
|
|
642
|
+
* ```
|
|
643
|
+
*
|
|
644
|
+
* @param self - The TxSemaphore to acquire permits from
|
|
645
|
+
* @param n - The number of permits to acquire (must be positive)
|
|
646
|
+
* @param effect - The effect to execute with the permits
|
|
647
|
+
* @returns Effect that succeeds with the result of the provided effect
|
|
648
|
+
*
|
|
649
|
+
* @since 4.0.0
|
|
650
|
+
* @category combinators
|
|
651
|
+
*/
|
|
652
|
+
<A, E, R>(self: TxSemaphore, n: number, effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>
|
|
653
|
+
} = ((...args: Array<any>) => {
|
|
654
|
+
if (args.length === 2) {
|
|
655
|
+
const [self, n] = args
|
|
656
|
+
return (effect: Effect.Effect<any, any, any>) =>
|
|
657
|
+
Effect.acquireUseRelease(
|
|
658
|
+
Effect.transaction(acquireN(self, n)),
|
|
659
|
+
() => effect,
|
|
660
|
+
() => Effect.transaction(releaseN(self, n))
|
|
661
|
+
)
|
|
662
|
+
}
|
|
663
|
+
const [self, n, effect] = args
|
|
664
|
+
return Effect.acquireUseRelease(
|
|
491
665
|
Effect.transaction(acquireN(self, n)),
|
|
492
666
|
() => effect,
|
|
493
667
|
() => Effect.transaction(releaseN(self, n))
|
|
494
668
|
)
|
|
669
|
+
}) as any
|
|
495
670
|
|
|
496
671
|
/**
|
|
497
672
|
* Acquires a single permit from the semaphore in a scoped manner. The permit
|
package/src/index.ts
CHANGED
|
@@ -1558,7 +1558,7 @@ export * as Inspectable from "./Inspectable.ts"
|
|
|
1558
1558
|
*
|
|
1559
1559
|
* @example
|
|
1560
1560
|
* ```ts
|
|
1561
|
-
* import { Iterable } from "effect"
|
|
1561
|
+
* import { Iterable, Option } from "effect"
|
|
1562
1562
|
*
|
|
1563
1563
|
* // Create iterables
|
|
1564
1564
|
* const numbers = Iterable.range(1, 5)
|
|
@@ -1568,7 +1568,7 @@ export * as Inspectable from "./Inspectable.ts"
|
|
|
1568
1568
|
* console.log(Array.from(filtered)) // [6, 8, 10]
|
|
1569
1569
|
*
|
|
1570
1570
|
* // Infinite iterables
|
|
1571
|
-
* const fibonacci = Iterable.unfold([0, 1], ([a, b]) => [a, [b, a + b]])
|
|
1571
|
+
* const fibonacci = Iterable.unfold([0, 1], ([a, b]) => Option.some([a, [b, a + b]]))
|
|
1572
1572
|
* const first10 = Iterable.take(fibonacci, 10)
|
|
1573
1573
|
* console.log(Array.from(first10)) // [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
|
|
1574
1574
|
* ```
|
|
@@ -2513,37 +2513,6 @@ export * as Newtype from "./Newtype.ts"
|
|
|
2513
2513
|
*/
|
|
2514
2514
|
export * as NonEmptyIterable from "./NonEmptyIterable.ts"
|
|
2515
2515
|
|
|
2516
|
-
/**
|
|
2517
|
-
* This module provides small, allocation-free utilities for working with values of type
|
|
2518
|
-
* `A | null`, where `null` means "no value".
|
|
2519
|
-
*
|
|
2520
|
-
* Why not `Option<A>`?
|
|
2521
|
-
* In TypeScript, `Option<A>` is often unnecessary. If `null` already models absence
|
|
2522
|
-
* in your domain, using `A | null` keeps types simple, avoids extra wrappers, and
|
|
2523
|
-
* reduces overhead. The key is that `A` itself must not include `null`; in this
|
|
2524
|
-
* module `null` is reserved to mean "no value".
|
|
2525
|
-
*
|
|
2526
|
-
* When to use `A | null`:
|
|
2527
|
-
* - Absence can be represented by `null` in your domain model.
|
|
2528
|
-
* - You do not need to distinguish between "no value" and "value is null".
|
|
2529
|
-
* - You want straightforward ergonomics and zero extra allocations.
|
|
2530
|
-
*
|
|
2531
|
-
* When to prefer `Option<A>`:
|
|
2532
|
-
* - You must distinguish `None` from `Some(null)` (that is, `null` is a valid
|
|
2533
|
-
* payload and carries meaning on its own).
|
|
2534
|
-
* - You need a tagged representation for serialization or pattern matching across
|
|
2535
|
-
* boundaries where `null` would be ambiguous.
|
|
2536
|
-
* - You want the richer `Option` API and are comfortable with the extra wrapper.
|
|
2537
|
-
*
|
|
2538
|
-
* Lawfulness note:
|
|
2539
|
-
* All helpers treat `null` as absence. Do not use these utilities with payloads
|
|
2540
|
-
* where `A` can itself be `null`, or you will lose information. If you need to
|
|
2541
|
-
* carry `null` as a valid payload, use `Option<A>` instead.
|
|
2542
|
-
*
|
|
2543
|
-
* @since 4.0.0
|
|
2544
|
-
*/
|
|
2545
|
-
export * as NullOr from "./NullOr.ts"
|
|
2546
|
-
|
|
2547
2516
|
/**
|
|
2548
2517
|
* This module provides utility functions and type class instances for working with the `number` type in TypeScript.
|
|
2549
2518
|
* It includes functions for basic arithmetic operations.
|
|
@@ -2808,6 +2777,11 @@ export * as Order from "./Order.ts"
|
|
|
2808
2777
|
*/
|
|
2809
2778
|
export * as Ordering from "./Ordering.ts"
|
|
2810
2779
|
|
|
2780
|
+
/**
|
|
2781
|
+
* @since 4.0.0
|
|
2782
|
+
*/
|
|
2783
|
+
export * as PartitionedSemaphore from "./PartitionedSemaphore.ts"
|
|
2784
|
+
|
|
2811
2785
|
/**
|
|
2812
2786
|
* @since 4.0.0
|
|
2813
2787
|
*/
|
|
@@ -3273,6 +3247,88 @@ export * as Schedule from "./Schedule.ts"
|
|
|
3273
3247
|
export * as Scheduler from "./Scheduler.ts"
|
|
3274
3248
|
|
|
3275
3249
|
/**
|
|
3250
|
+
* Define data shapes, validate unknown input, and transform values between formats.
|
|
3251
|
+
*
|
|
3252
|
+
* ## Mental model
|
|
3253
|
+
*
|
|
3254
|
+
* - **Schema** — a description of a data shape. Every schema carries a decoded
|
|
3255
|
+
* *Type* (the value you work with) and an *Encoded* representation (the
|
|
3256
|
+
* serialized form, e.g. JSON).
|
|
3257
|
+
* - **Decoding** — turning unknown external data (API responses, form
|
|
3258
|
+
* submissions, config files) into typed, validated values.
|
|
3259
|
+
* - **Encoding** — turning typed values back into a serializable format.
|
|
3260
|
+
* - **Codec** — a schema that tracks both Type and Encoded, so it can decode
|
|
3261
|
+
* *and* encode. Most concrete schemas are Codecs.
|
|
3262
|
+
* - **Check / Filter** — a constraint attached to a schema (e.g. `isMinLength`,
|
|
3263
|
+
* `isGreaterThan`). Attach them with `.check(...)`.
|
|
3264
|
+
* - **Transformation** — a pair of functions (decode + encode) that convert
|
|
3265
|
+
* values between two schemas. Created with {@link decodeTo} / {@link encodeTo}.
|
|
3266
|
+
* - **Annotation** — metadata attached to a schema (title, description, custom
|
|
3267
|
+
* keys). Attach with `.annotate(...)`.
|
|
3268
|
+
*
|
|
3269
|
+
* ## Common tasks
|
|
3270
|
+
*
|
|
3271
|
+
* - Define a struct: {@link Struct}
|
|
3272
|
+
* - Define a union: {@link Union}, {@link TaggedUnion}, {@link Literals}
|
|
3273
|
+
* - Define an array: {@link Array}, {@link NonEmptyArray}
|
|
3274
|
+
* - Define a record: {@link Record}
|
|
3275
|
+
* - Define a tuple: {@link Tuple}, {@link TupleWithRest}
|
|
3276
|
+
* - Validate unknown data synchronously: {@link decodeUnknownSync}
|
|
3277
|
+
* - Validate unknown data (Effect): {@link decodeUnknownEffect}
|
|
3278
|
+
* - Encode a value: {@link encodeUnknownSync}, {@link encodeUnknownEffect}
|
|
3279
|
+
* - Type guard: {@link is}
|
|
3280
|
+
* - Assertion: {@link asserts}
|
|
3281
|
+
* - Add constraints: `.check(...)` with filters like {@link isMinLength},
|
|
3282
|
+
* {@link isGreaterThan}, {@link isPattern}, {@link isUUID}
|
|
3283
|
+
* - Transform between schemas: {@link decodeTo}, {@link encodeTo}
|
|
3284
|
+
* - Add a default for missing keys: {@link withDecodingDefault}, {@link withDecodingDefaultKey}
|
|
3285
|
+
* - Create branded types: {@link brand}
|
|
3286
|
+
* - Define classes with validation: {@link Class}, {@link TaggedClass}
|
|
3287
|
+
* - Define error classes: {@link ErrorClass}, {@link TaggedErrorClass}
|
|
3288
|
+
* - Generate JSON Schema: {@link toJsonSchemaDocument}
|
|
3289
|
+
* - Generate test data: {@link toArbitrary}
|
|
3290
|
+
* - Derive equivalence: {@link toEquivalence}
|
|
3291
|
+
*
|
|
3292
|
+
* ## Gotchas
|
|
3293
|
+
*
|
|
3294
|
+
* - `Schema.optional` creates `T | undefined` (key can be missing *or*
|
|
3295
|
+
* `undefined`). Use `Schema.optionalKey` for exact optional properties.
|
|
3296
|
+
* - `decodeTo` is curried: use `from.pipe(Schema.decodeTo(to, ...))`.
|
|
3297
|
+
* - `decodeUnknownSync` throws on failure. Use `decodeUnknownExit` or
|
|
3298
|
+
* `decodeUnknownOption` for non-throwing alternatives.
|
|
3299
|
+
* - Filters do not change the TypeScript type. Use {@link refine} or
|
|
3300
|
+
* {@link brand} to narrow the type.
|
|
3301
|
+
* - Recursive schemas require {@link suspend} to avoid infinite loops.
|
|
3302
|
+
*
|
|
3303
|
+
* ## Quickstart
|
|
3304
|
+
*
|
|
3305
|
+
* **Example** (Validate a user object)
|
|
3306
|
+
*
|
|
3307
|
+
* ```ts
|
|
3308
|
+
* import { Schema } from "effect"
|
|
3309
|
+
*
|
|
3310
|
+
* const User = Schema.Struct({
|
|
3311
|
+
* name: Schema.String.check(Schema.isMinLength(1)),
|
|
3312
|
+
* age: Schema.Number.check(Schema.isGreaterThanOrEqualTo(0)),
|
|
3313
|
+
* email: Schema.optionalKey(Schema.String)
|
|
3314
|
+
* })
|
|
3315
|
+
*
|
|
3316
|
+
* // Decode unknown input — throws on failure
|
|
3317
|
+
* const user = Schema.decodeUnknownSync(User)({
|
|
3318
|
+
* name: "Alice",
|
|
3319
|
+
* age: 30
|
|
3320
|
+
* })
|
|
3321
|
+
*
|
|
3322
|
+
* console.log(user)
|
|
3323
|
+
* // { name: "Alice", age: 30 }
|
|
3324
|
+
* ```
|
|
3325
|
+
*
|
|
3326
|
+
* @see {@link Schema} — type-level view tracking only the decoded Type
|
|
3327
|
+
* @see {@link Codec} — type-level view tracking both Type and Encoded
|
|
3328
|
+
* @see {@link Struct} — define object shapes
|
|
3329
|
+
* @see {@link decodeUnknownSync} — synchronous validation
|
|
3330
|
+
* @see {@link decodeTo} — schema transformations
|
|
3331
|
+
*
|
|
3276
3332
|
* @since 4.0.0
|
|
3277
3333
|
*/
|
|
3278
3334
|
export * as Schema from "./Schema.ts"
|