effect 4.0.0-beta.2 → 4.0.0-beta.21
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 +127 -299
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +102 -62
- package/dist/Array.js.map +1 -1
- package/dist/Cache.d.ts +2 -2
- package/dist/Cache.d.ts.map +1 -1
- package/dist/Cache.js +6 -5
- package/dist/Cache.js.map +1 -1
- package/dist/Cause.d.ts +1 -1
- package/dist/Cause.d.ts.map +1 -1
- package/dist/Channel.d.ts +116 -30
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +82 -37
- package/dist/Channel.js.map +1 -1
- package/dist/Chunk.d.ts +54 -247
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Chunk.js +36 -67
- package/dist/Chunk.js.map +1 -1
- package/dist/Combiner.d.ts +280 -13
- package/dist/Combiner.d.ts.map +1 -1
- package/dist/Combiner.js +198 -7
- package/dist/Combiner.js.map +1 -1
- package/dist/Config.d.ts +165 -9
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +62 -7
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.d.ts +1 -1
- package/dist/Cron.d.ts +1 -1
- package/dist/Data.d.ts +534 -365
- package/dist/Data.d.ts.map +1 -1
- package/dist/Data.js +132 -79
- package/dist/Data.js.map +1 -1
- package/dist/DateTime.d.ts +23 -161
- package/dist/DateTime.d.ts.map +1 -1
- package/dist/DateTime.js +6 -51
- package/dist/DateTime.js.map +1 -1
- package/dist/Duration.d.ts +12 -12
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +12 -12
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts +829 -692
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +263 -251
- package/dist/Effect.js.map +1 -1
- package/dist/Encoding.d.ts +194 -0
- package/dist/Encoding.d.ts.map +1 -0
- package/dist/Encoding.js +352 -0
- package/dist/Encoding.js.map +1 -0
- package/dist/Equal.d.ts +276 -109
- package/dist/Equal.d.ts.map +1 -1
- package/dist/Equal.js +124 -48
- package/dist/Equal.js.map +1 -1
- package/dist/ErrorReporter.d.ts +376 -0
- package/dist/ErrorReporter.d.ts.map +1 -0
- package/dist/ErrorReporter.js +246 -0
- package/dist/ErrorReporter.js.map +1 -0
- package/dist/Fiber.d.ts +2 -2
- package/dist/Fiber.d.ts.map +1 -1
- package/dist/Fiber.js.map +1 -1
- package/dist/FileSystem.d.ts +1 -1
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js +5 -5
- package/dist/FileSystem.js.map +1 -1
- package/dist/Filter.d.ts +30 -34
- package/dist/Filter.d.ts.map +1 -1
- package/dist/Filter.js +15 -13
- package/dist/Filter.js.map +1 -1
- package/dist/Formatter.d.ts +131 -47
- package/dist/Formatter.d.ts.map +1 -1
- package/dist/Formatter.js +229 -51
- package/dist/Formatter.js.map +1 -1
- package/dist/Graph.d.ts +1 -1
- package/dist/Graph.d.ts.map +1 -1
- package/dist/Graph.js +5 -8
- package/dist/Graph.js.map +1 -1
- package/dist/HashMap.d.ts +15 -14
- package/dist/HashMap.d.ts.map +1 -1
- package/dist/HashMap.js +4 -4
- package/dist/HashMap.js.map +1 -1
- package/dist/Iterable.d.ts +40 -39
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +94 -22
- package/dist/Iterable.js.map +1 -1
- package/dist/JsonSchema.d.ts +299 -10
- package/dist/JsonSchema.d.ts.map +1 -1
- package/dist/JsonSchema.js +323 -4
- package/dist/JsonSchema.js.map +1 -1
- package/dist/Latch.d.ts +109 -0
- package/dist/Latch.d.ts.map +1 -0
- package/dist/Latch.js +72 -0
- package/dist/Latch.js.map +1 -0
- package/dist/Layer.d.ts +9 -9
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js.map +1 -1
- package/dist/LayerMap.d.ts +4 -4
- package/dist/LayerMap.d.ts.map +1 -1
- package/dist/LogLevel.d.ts +32 -0
- package/dist/LogLevel.d.ts.map +1 -1
- package/dist/LogLevel.js +28 -100
- package/dist/LogLevel.js.map +1 -1
- package/dist/Logger.d.ts +29 -95
- package/dist/Logger.d.ts.map +1 -1
- package/dist/Logger.js +2 -3
- package/dist/Logger.js.map +1 -1
- package/dist/ManagedRuntime.d.ts +1 -1
- package/dist/ManagedRuntime.js +1 -1
- package/dist/Metric.d.ts +2 -2
- package/dist/Metric.d.ts.map +1 -1
- package/dist/Metric.js +1 -1
- package/dist/Metric.js.map +1 -1
- package/dist/Optic.d.ts +947 -18
- package/dist/Optic.d.ts.map +1 -1
- package/dist/Optic.js +454 -5
- package/dist/Optic.js.map +1 -1
- package/dist/Option.d.ts +22 -15
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js +14 -7
- package/dist/Option.js.map +1 -1
- package/dist/Pipeable.d.ts +17 -0
- package/dist/Pipeable.d.ts.map +1 -1
- package/dist/Pipeable.js +19 -1
- package/dist/Pipeable.js.map +1 -1
- package/dist/PlatformError.d.ts +10 -9
- package/dist/PlatformError.d.ts.map +1 -1
- package/dist/PlatformError.js +2 -2
- package/dist/PlatformError.js.map +1 -1
- package/dist/Pool.d.ts +6 -4
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +7 -5
- package/dist/Pool.js.map +1 -1
- package/dist/PubSub.d.ts +3 -2
- package/dist/PubSub.d.ts.map +1 -1
- package/dist/PubSub.js +3 -2
- package/dist/PubSub.js.map +1 -1
- package/dist/Pull.d.ts.map +1 -1
- package/dist/Pull.js +1 -1
- package/dist/Pull.js.map +1 -1
- package/dist/Queue.d.ts.map +1 -1
- package/dist/Queue.js +0 -1
- package/dist/Queue.js.map +1 -1
- package/dist/Random.d.ts +35 -1
- package/dist/Random.d.ts.map +1 -1
- package/dist/Random.js +46 -12
- package/dist/Random.js.map +1 -1
- package/dist/RcMap.d.ts +2 -2
- package/dist/RcMap.d.ts.map +1 -1
- package/dist/RcMap.js +1 -1
- package/dist/RcMap.js.map +1 -1
- package/dist/RcRef.d.ts +1 -1
- package/dist/RcRef.d.ts.map +1 -1
- package/dist/Record.d.ts +24 -120
- package/dist/Record.d.ts.map +1 -1
- package/dist/Record.js +21 -41
- package/dist/Record.js.map +1 -1
- package/dist/Reducer.d.ts +166 -7
- package/dist/Reducer.d.ts.map +1 -1
- package/dist/Reducer.js +135 -1
- package/dist/Reducer.js.map +1 -1
- package/dist/References.d.ts +3 -3
- package/dist/References.d.ts.map +1 -1
- package/dist/Request.d.ts +1 -1
- package/dist/Request.d.ts.map +1 -1
- package/dist/Request.js +2 -1
- package/dist/Request.js.map +1 -1
- package/dist/RequestResolver.d.ts +6 -26
- package/dist/RequestResolver.d.ts.map +1 -1
- package/dist/RequestResolver.js +0 -20
- package/dist/RequestResolver.js.map +1 -1
- package/dist/Result.d.ts +12 -0
- package/dist/Result.d.ts.map +1 -1
- package/dist/Result.js +12 -0
- package/dist/Result.js.map +1 -1
- package/dist/Schedule.d.ts +47 -20
- package/dist/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js +94 -34
- package/dist/Schedule.js.map +1 -1
- package/dist/Schema.d.ts +266 -50
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +426 -74
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +7 -6
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaGetter.d.ts +2 -2
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +12 -14
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaParser.d.ts +5 -0
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +10 -0
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +44 -43
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +43 -24
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +107 -3
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +159 -4
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/ScopedCache.d.ts +2 -2
- package/dist/ScopedCache.d.ts.map +1 -1
- package/dist/ScopedCache.js +1 -1
- package/dist/ScopedCache.js.map +1 -1
- package/dist/Semaphore.d.ts +211 -0
- package/dist/Semaphore.d.ts.map +1 -0
- package/dist/{PartitionedSemaphore.js → Semaphore.js} +97 -13
- package/dist/Semaphore.js.map +1 -0
- package/dist/ServiceMap.d.ts +39 -30
- package/dist/ServiceMap.d.ts.map +1 -1
- package/dist/ServiceMap.js +3 -3
- package/dist/ServiceMap.js.map +1 -1
- package/dist/Sink.d.ts +13 -13
- package/dist/Sink.d.ts.map +1 -1
- package/dist/Sink.js +53 -6
- package/dist/Sink.js.map +1 -1
- package/dist/Stream.d.ts +235 -423
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +124 -77
- package/dist/Stream.js.map +1 -1
- package/dist/Struct.d.ts +16 -0
- package/dist/Struct.d.ts.map +1 -1
- package/dist/Struct.js +22 -0
- package/dist/Struct.js.map +1 -1
- package/dist/SubscriptionRef.d.ts +2 -1
- package/dist/SubscriptionRef.d.ts.map +1 -1
- package/dist/SubscriptionRef.js +2 -1
- package/dist/SubscriptionRef.js.map +1 -1
- package/dist/SynchronizedRef.d.ts +2 -1
- package/dist/SynchronizedRef.d.ts.map +1 -1
- package/dist/SynchronizedRef.js +2 -1
- package/dist/SynchronizedRef.js.map +1 -1
- package/dist/Trie.d.ts +18 -17
- package/dist/Trie.d.ts.map +1 -1
- package/dist/Trie.js +5 -5
- package/dist/Trie.js.map +1 -1
- package/dist/TxChunk.d.ts +37 -37
- package/dist/TxChunk.d.ts.map +1 -1
- package/dist/TxChunk.js +3 -3
- package/dist/TxChunk.js.map +1 -1
- package/dist/TxDeferred.d.ts +328 -0
- package/dist/TxDeferred.d.ts.map +1 -0
- package/dist/TxDeferred.js +196 -0
- package/dist/TxDeferred.js.map +1 -0
- package/dist/TxHashMap.d.ts +84 -83
- package/dist/TxHashMap.d.ts.map +1 -1
- package/dist/TxHashMap.js +24 -24
- package/dist/TxHashMap.js.map +1 -1
- package/dist/TxHashSet.d.ts +35 -35
- package/dist/TxHashSet.d.ts.map +1 -1
- package/dist/TxHashSet.js +14 -14
- package/dist/TxHashSet.js.map +1 -1
- package/dist/TxPriorityQueue.d.ts +609 -0
- package/dist/TxPriorityQueue.d.ts.map +1 -0
- package/dist/TxPriorityQueue.js +415 -0
- package/dist/TxPriorityQueue.js.map +1 -0
- package/dist/TxPubSub.d.ts +585 -0
- package/dist/TxPubSub.d.ts.map +1 -0
- package/dist/TxPubSub.js +521 -0
- package/dist/TxPubSub.js.map +1 -0
- package/dist/TxQueue.d.ts +32 -32
- package/dist/TxQueue.d.ts.map +1 -1
- package/dist/TxQueue.js +26 -26
- package/dist/TxQueue.js.map +1 -1
- package/dist/TxReentrantLock.d.ts +523 -0
- package/dist/TxReentrantLock.d.ts.map +1 -0
- package/dist/TxReentrantLock.js +504 -0
- package/dist/TxReentrantLock.js.map +1 -0
- package/dist/TxRef.d.ts +34 -34
- package/dist/TxRef.d.ts.map +1 -1
- package/dist/TxRef.js +21 -14
- package/dist/TxRef.js.map +1 -1
- package/dist/TxSemaphore.d.ts +8 -8
- package/dist/TxSemaphore.d.ts.map +1 -1
- package/dist/TxSemaphore.js +7 -7
- package/dist/TxSemaphore.js.map +1 -1
- package/dist/TxSubscriptionRef.d.ts +508 -0
- package/dist/TxSubscriptionRef.d.ts.map +1 -0
- package/dist/TxSubscriptionRef.js +293 -0
- package/dist/TxSubscriptionRef.js.map +1 -0
- package/dist/Types.d.ts +84 -6
- package/dist/Types.d.ts.map +1 -1
- package/dist/index.d.ts +591 -20
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +591 -20
- package/dist/index.js.map +1 -1
- package/dist/internal/core.js +11 -3
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/dateTime.js +3 -11
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +263 -99
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/hashMap.js +5 -4
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/random.d.ts +2 -0
- package/dist/internal/random.d.ts.map +1 -0
- package/dist/internal/random.js +13 -0
- package/dist/internal/random.js.map +1 -0
- package/dist/internal/rcRef.js +3 -2
- package/dist/internal/rcRef.js.map +1 -1
- package/dist/internal/request.js +2 -2
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/schema/annotations.js +2 -0
- package/dist/internal/schema/annotations.js.map +1 -1
- package/dist/internal/schema/schema.js +1 -0
- package/dist/internal/schema/schema.js.map +1 -1
- package/dist/internal/trie.js +5 -4
- package/dist/internal/trie.js.map +1 -1
- package/dist/testing/TestClock.d.ts +7 -6
- package/dist/testing/TestClock.d.ts.map +1 -1
- package/dist/testing/TestClock.js +6 -4
- package/dist/testing/TestClock.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +8 -8
- package/dist/testing/TestSchema.d.ts.map +1 -1
- package/dist/testing/TestSchema.js.map +1 -1
- package/dist/unstable/ai/AiError.d.ts +128 -48
- package/dist/unstable/ai/AiError.d.ts.map +1 -1
- package/dist/unstable/ai/AiError.js +11 -12
- package/dist/unstable/ai/AiError.js.map +1 -1
- package/dist/unstable/ai/Chat.d.ts +3 -3
- package/dist/unstable/ai/Chat.d.ts.map +1 -1
- package/dist/unstable/ai/Chat.js +4 -3
- package/dist/unstable/ai/Chat.js.map +1 -1
- package/dist/unstable/ai/LanguageModel.d.ts +4 -2
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +86 -14
- package/dist/unstable/ai/LanguageModel.js.map +1 -1
- package/dist/unstable/ai/McpSchema.d.ts +163 -87
- package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
- package/dist/unstable/ai/McpSchema.js +49 -12
- package/dist/unstable/ai/McpSchema.js.map +1 -1
- package/dist/unstable/ai/McpServer.d.ts +1 -1
- package/dist/unstable/ai/McpServer.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.js +35 -7
- package/dist/unstable/ai/McpServer.js.map +1 -1
- package/dist/unstable/ai/Model.d.ts +25 -7
- package/dist/unstable/ai/Model.d.ts.map +1 -1
- package/dist/unstable/ai/Model.js +22 -6
- package/dist/unstable/ai/Model.js.map +1 -1
- package/dist/unstable/ai/Prompt.d.ts +20 -20
- package/dist/unstable/ai/Prompt.d.ts.map +1 -1
- package/dist/unstable/ai/Response.d.ts +26 -26
- package/dist/unstable/ai/Response.d.ts.map +1 -1
- package/dist/unstable/ai/Response.js +1 -1
- package/dist/unstable/ai/Response.js.map +1 -1
- package/dist/unstable/ai/Tool.d.ts +19 -3
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +14 -9
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/ai/index.d.ts +1 -1
- package/dist/unstable/ai/index.js +1 -1
- package/dist/unstable/cli/CliError.d.ts +5 -5
- package/dist/unstable/cli/CliOutput.js +59 -6
- package/dist/unstable/cli/CliOutput.js.map +1 -1
- package/dist/unstable/cli/Command.d.ts +276 -19
- package/dist/unstable/cli/Command.d.ts.map +1 -1
- package/dist/unstable/cli/Command.js +234 -36
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cli/GlobalFlag.d.ts +125 -0
- package/dist/unstable/cli/GlobalFlag.d.ts.map +1 -0
- package/dist/unstable/cli/GlobalFlag.js +118 -0
- package/dist/unstable/cli/GlobalFlag.js.map +1 -0
- package/dist/unstable/cli/HelpDoc.d.ts +70 -2
- package/dist/unstable/cli/HelpDoc.d.ts.map +1 -1
- package/dist/unstable/cli/index.d.ts +4 -0
- package/dist/unstable/cli/index.d.ts.map +1 -1
- package/dist/unstable/cli/index.js +4 -0
- package/dist/unstable/cli/index.js.map +1 -1
- package/dist/unstable/cli/internal/command.d.ts +17 -8
- package/dist/unstable/cli/internal/command.d.ts.map +1 -1
- package/dist/unstable/cli/internal/command.js +32 -23
- package/dist/unstable/cli/internal/command.js.map +1 -1
- package/dist/unstable/cli/internal/completions/CommandDescriptor.js +7 -2
- package/dist/unstable/cli/internal/completions/CommandDescriptor.js.map +1 -1
- package/dist/unstable/cli/internal/help.d.ts +33 -0
- package/dist/unstable/cli/internal/help.d.ts.map +1 -0
- package/dist/unstable/cli/internal/help.js +107 -0
- package/dist/unstable/cli/internal/help.js.map +1 -0
- package/dist/unstable/cli/internal/parser.js +29 -36
- package/dist/unstable/cli/internal/parser.js.map +1 -1
- package/dist/unstable/cluster/ClusterCron.d.ts +1 -1
- package/dist/unstable/cluster/ClusterCron.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterCron.js +1 -1
- package/dist/unstable/cluster/ClusterCron.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +4 -3
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/cluster/Entity.d.ts +7 -6
- package/dist/unstable/cluster/Entity.d.ts.map +1 -1
- package/dist/unstable/cluster/Entity.js.map +1 -1
- package/dist/unstable/cluster/EntityResource.d.ts +2 -2
- package/dist/unstable/cluster/EntityResource.d.ts.map +1 -1
- package/dist/unstable/cluster/Envelope.d.ts +1 -1
- package/dist/unstable/cluster/K8sHttpClient.d.ts +1 -1
- package/dist/unstable/cluster/K8sHttpClient.js +4 -4
- package/dist/unstable/cluster/K8sHttpClient.js.map +1 -1
- package/dist/unstable/cluster/Message.d.ts +10 -10
- package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/MessageStorage.js +2 -1
- package/dist/unstable/cluster/MessageStorage.js.map +1 -1
- package/dist/unstable/cluster/Reply.d.ts +6 -6
- package/dist/unstable/cluster/Runner.d.ts +1 -1
- package/dist/unstable/cluster/Runners.d.ts.map +1 -1
- package/dist/unstable/cluster/Runners.js +4 -3
- package/dist/unstable/cluster/Runners.js.map +1 -1
- package/dist/unstable/cluster/Sharding.d.ts +2 -2
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +9 -7
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.d.ts +21 -21
- package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.js +20 -20
- package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.js +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/unstable/cluster/internal/entityManager.js +5 -4
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/cluster/internal/entityReaper.js +2 -1
- package/dist/unstable/cluster/internal/entityReaper.js.map +1 -1
- package/dist/unstable/cluster/internal/resourceRef.js +2 -1
- package/dist/unstable/cluster/internal/resourceRef.js.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.d.ts +36 -36
- package/dist/unstable/encoding/Msgpack.d.ts +1 -1
- package/dist/unstable/encoding/Ndjson.d.ts +1 -1
- package/dist/unstable/encoding/Sse.d.ts +4 -4
- package/dist/unstable/encoding/Sse.d.ts.map +1 -1
- package/dist/unstable/encoding/Sse.js +1 -1
- package/dist/unstable/encoding/Sse.js.map +1 -1
- package/dist/unstable/eventlog/EventJournal.d.ts +2 -2
- package/dist/unstable/eventlog/EventLog.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLog.js +2 -1
- package/dist/unstable/eventlog/EventLog.js.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.d.ts +6 -6
- package/dist/unstable/http/Cookies.d.ts +3 -3
- package/dist/unstable/http/Cookies.d.ts.map +1 -1
- package/dist/unstable/http/Cookies.js +2 -2
- package/dist/unstable/http/Cookies.js.map +1 -1
- package/dist/unstable/http/Headers.d.ts.map +1 -1
- package/dist/unstable/http/Headers.js +27 -10
- package/dist/unstable/http/Headers.js.map +1 -1
- package/dist/unstable/http/HttpBody.d.ts +17 -2
- package/dist/unstable/http/HttpBody.d.ts.map +1 -1
- package/dist/unstable/http/HttpBody.js +28 -1
- package/dist/unstable/http/HttpBody.js.map +1 -1
- package/dist/unstable/http/HttpClient.d.ts +37 -13
- package/dist/unstable/http/HttpClient.d.ts.map +1 -1
- package/dist/unstable/http/HttpClient.js +4 -4
- package/dist/unstable/http/HttpClient.js.map +1 -1
- package/dist/unstable/http/HttpClientError.d.ts +7 -7
- package/dist/unstable/http/HttpClientRequest.d.ts +27 -11
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.js +15 -3
- package/dist/unstable/http/HttpClientRequest.js.map +1 -1
- package/dist/unstable/http/HttpEffect.d.ts +3 -8
- package/dist/unstable/http/HttpEffect.d.ts.map +1 -1
- package/dist/unstable/http/HttpEffect.js +42 -56
- package/dist/unstable/http/HttpEffect.js.map +1 -1
- package/dist/unstable/http/HttpMethod.d.ts +4 -4
- package/dist/unstable/http/HttpMethod.d.ts.map +1 -1
- package/dist/unstable/http/HttpMethod.js +3 -3
- package/dist/unstable/http/HttpMethod.js.map +1 -1
- package/dist/unstable/http/HttpMiddleware.d.ts +1 -6
- package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/unstable/http/HttpMiddleware.js +8 -17
- package/dist/unstable/http/HttpMiddleware.js.map +1 -1
- package/dist/unstable/http/HttpServerError.d.ts +20 -33
- package/dist/unstable/http/HttpServerError.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerError.js +37 -44
- package/dist/unstable/http/HttpServerError.js.map +1 -1
- package/dist/unstable/http/HttpServerRequest.d.ts +1 -1
- package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRespondable.d.ts +2 -2
- package/dist/unstable/http/HttpServerRespondable.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRespondable.js +5 -5
- package/dist/unstable/http/HttpServerRespondable.js.map +1 -1
- package/dist/unstable/http/HttpServerResponse.d.ts +2 -1
- package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerResponse.js +3 -1
- package/dist/unstable/http/HttpServerResponse.js.map +1 -1
- package/dist/unstable/http/Multipart.d.ts +3 -3
- package/dist/unstable/http/UrlParams.d.ts +14 -6
- package/dist/unstable/http/UrlParams.d.ts.map +1 -1
- package/dist/unstable/http/UrlParams.js +1 -1
- package/dist/unstable/http/UrlParams.js.map +1 -1
- package/dist/unstable/http/internal/preResponseHandler.d.ts +2 -0
- package/dist/unstable/http/internal/preResponseHandler.d.ts.map +1 -0
- package/dist/unstable/http/internal/preResponseHandler.js +10 -0
- package/dist/unstable/http/internal/preResponseHandler.js.map +1 -0
- package/dist/unstable/httpapi/HttpApi.d.ts +3 -3
- package/dist/unstable/httpapi/HttpApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApi.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts +11 -5
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +23 -12
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.d.ts +7 -2
- package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.js +3 -3
- package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +31 -44
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.js +15 -24
- package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.d.ts +11 -0
- package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.js +29 -9
- package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.d.ts +3 -3
- package/dist/unstable/httpapi/HttpApiGroup.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +4 -4
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.d.ts +6 -0
- package/dist/unstable/httpapi/HttpApiScalar.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSecurity.d.ts +2 -2
- package/dist/unstable/httpapi/HttpApiSecurity.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSecurity.js.map +1 -1
- package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/OpenApi.js +32 -21
- package/dist/unstable/httpapi/OpenApi.js.map +1 -1
- package/dist/unstable/observability/Otlp.d.ts +12 -12
- package/dist/unstable/observability/Otlp.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.d.ts +2 -2
- package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.js +1 -1
- package/dist/unstable/observability/OtlpExporter.js.map +1 -1
- package/dist/unstable/observability/OtlpLogger.d.ts +4 -4
- package/dist/unstable/observability/OtlpLogger.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpLogger.js +7 -4
- package/dist/unstable/observability/OtlpLogger.js.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.d.ts +4 -4
- package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpTracer.d.ts +4 -4
- package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/unstable/persistence/KeyValueStore.d.ts +1 -1
- package/dist/unstable/persistence/KeyValueStore.js +6 -6
- package/dist/unstable/persistence/KeyValueStore.js.map +1 -1
- package/dist/unstable/persistence/Persistable.d.ts +2 -2
- package/dist/unstable/persistence/Persistable.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedCache.d.ts +6 -5
- package/dist/unstable/persistence/PersistedCache.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedCache.js +2 -1
- package/dist/unstable/persistence/PersistedCache.js.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.d.ts +12 -12
- package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.js +12 -11
- package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
- package/dist/unstable/persistence/Persistence.d.ts +1 -1
- package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
- package/dist/unstable/persistence/Persistence.js +2 -2
- package/dist/unstable/persistence/Persistence.js.map +1 -1
- package/dist/unstable/persistence/RateLimiter.d.ts +3 -3
- package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
- package/dist/unstable/persistence/RateLimiter.js +1 -1
- package/dist/unstable/persistence/RateLimiter.js.map +1 -1
- package/dist/unstable/process/ChildProcess.d.ts +5 -128
- package/dist/unstable/process/ChildProcess.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcess.js +1 -65
- package/dist/unstable/process/ChildProcess.js.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.d.ts +45 -7
- package/dist/unstable/process/ChildProcessSpawner.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.js +21 -1
- package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts +10 -10
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +16 -13
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts +8 -8
- package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.js +3 -3
- package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.d.ts +6 -0
- package/dist/unstable/reactivity/AtomRegistry.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.js +24 -7
- package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.d.ts +1 -1
- package/dist/unstable/reactivity/AtomRpc.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.js +1 -1
- package/dist/unstable/reactivity/AtomRpc.js.map +1 -1
- package/dist/unstable/reactivity/Hydration.d.ts +39 -0
- package/dist/unstable/reactivity/Hydration.d.ts.map +1 -0
- package/dist/unstable/reactivity/Hydration.js +76 -0
- package/dist/unstable/reactivity/Hydration.js.map +1 -0
- package/dist/unstable/reactivity/index.d.ts +4 -0
- package/dist/unstable/reactivity/index.d.ts.map +1 -1
- package/dist/unstable/reactivity/index.js +4 -0
- package/dist/unstable/reactivity/index.js.map +1 -1
- package/dist/unstable/rpc/Rpc.d.ts +4 -4
- package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
- package/dist/unstable/rpc/Rpc.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts +5 -26
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +6 -13
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/rpc/RpcGroup.d.ts +2 -2
- package/dist/unstable/rpc/RpcGroup.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcGroup.js.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.d.ts +3 -3
- package/dist/unstable/rpc/RpcMiddleware.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.js.map +1 -1
- package/dist/unstable/rpc/RpcSchema.d.ts +13 -0
- package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSchema.js +14 -0
- 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 +34 -9
- package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts +0 -7
- package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +15 -15
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/rpc/Utils.d.ts.map +1 -1
- package/dist/unstable/rpc/Utils.js +2 -1
- package/dist/unstable/rpc/Utils.js.map +1 -1
- package/dist/unstable/schema/Model.d.ts +1 -1
- package/dist/unstable/schema/Model.d.ts.map +1 -1
- package/dist/unstable/schema/VariantSchema.d.ts +3 -3
- package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
- package/dist/unstable/schema/VariantSchema.js +3 -3
- package/dist/unstable/schema/VariantSchema.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts +4 -4
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +6 -5
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/dist/unstable/socket/SocketServer.d.ts +3 -3
- package/dist/unstable/sql/Migrator.d.ts +1 -1
- package/dist/unstable/sql/SqlClient.d.ts +1 -1
- package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
- package/dist/unstable/sql/SqlError.d.ts +14 -14
- package/dist/unstable/sql/SqlError.d.ts.map +1 -1
- package/dist/unstable/sql/SqlError.js +9 -3
- package/dist/unstable/sql/SqlError.js.map +1 -1
- package/dist/unstable/sql/SqlModel.d.ts +2 -2
- package/dist/unstable/sql/SqlModel.d.ts.map +1 -1
- package/dist/unstable/sql/SqlModel.js +3 -3
- package/dist/unstable/sql/SqlModel.js.map +1 -1
- package/dist/unstable/sql/SqlSchema.d.ts +16 -5
- package/dist/unstable/sql/SqlSchema.d.ts.map +1 -1
- package/dist/unstable/sql/SqlSchema.js +17 -7
- package/dist/unstable/sql/SqlSchema.js.map +1 -1
- package/dist/unstable/sql/Statement.js +0 -1
- package/dist/unstable/sql/Statement.js.map +1 -1
- package/dist/unstable/workers/Worker.d.ts.map +1 -1
- package/dist/unstable/workers/Worker.js +2 -1
- package/dist/unstable/workers/Worker.js.map +1 -1
- package/dist/unstable/workflow/DurableClock.d.ts +3 -3
- package/dist/unstable/workflow/DurableClock.d.ts.map +1 -1
- package/dist/unstable/workflow/DurableClock.js +3 -3
- package/dist/unstable/workflow/DurableClock.js.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.js +2 -2
- package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts +3 -3
- package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
- package/dist/unstable/workflow/Workflow.js +1 -1
- package/dist/unstable/workflow/Workflow.js.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts +12 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js +137 -1
- package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +2 -2
- package/src/Array.ts +190 -342
- package/src/Cache.ts +9 -8
- package/src/Cause.ts +1 -1
- package/src/Channel.ts +554 -138
- package/src/Chunk.ts +81 -268
- package/src/Combiner.ts +280 -13
- package/src/Config.ts +183 -21
- package/src/Data.ts +538 -374
- package/src/DateTime.ts +24 -164
- package/src/Duration.ts +15 -15
- package/src/Effect.ts +991 -800
- package/src/Encoding.ts +879 -0
- package/src/Equal.ts +278 -111
- package/src/ErrorReporter.ts +459 -0
- package/src/Fiber.ts +9 -2
- package/src/FileSystem.ts +7 -8
- package/src/Filter.ts +48 -58
- package/src/Formatter.ts +253 -51
- package/src/Graph.ts +24 -11
- package/src/HashMap.ts +15 -14
- package/src/Iterable.ts +105 -50
- package/src/JsonSchema.ts +383 -10
- package/src/Latch.ts +112 -0
- package/src/Layer.ts +11 -15
- package/src/LayerMap.ts +5 -5
- package/src/LogLevel.ts +37 -0
- package/src/Logger.ts +33 -100
- package/src/ManagedRuntime.ts +1 -1
- package/src/Metric.ts +4 -4
- package/src/Optic.ts +948 -19
- package/src/Option.ts +30 -20
- package/src/Pipeable.ts +32 -1
- package/src/PlatformError.ts +5 -5
- package/src/Pool.ts +13 -11
- package/src/PubSub.ts +10 -9
- package/src/Pull.ts +1 -1
- package/src/Queue.ts +0 -1
- package/src/Random.ts +51 -14
- package/src/RcMap.ts +5 -5
- package/src/RcRef.ts +1 -1
- package/src/Record.ts +43 -152
- package/src/Reducer.ts +166 -7
- package/src/References.ts +4 -4
- package/src/Request.ts +3 -2
- package/src/RequestResolver.ts +9 -29
- package/src/Result.ts +13 -0
- package/src/Schedule.ts +318 -160
- package/src/Schema.ts +661 -116
- package/src/SchemaAST.ts +7 -6
- package/src/SchemaGetter.ts +12 -14
- package/src/SchemaParser.ts +11 -0
- package/src/SchemaRepresentation.ts +43 -24
- package/src/SchemaTransformation.ts +189 -4
- package/src/ScopedCache.ts +3 -3
- package/src/Semaphore.ts +356 -0
- package/src/ServiceMap.ts +47 -38
- package/src/Sink.ts +78 -26
- package/src/Stream.ts +566 -601
- package/src/Struct.ts +26 -0
- package/src/SubscriptionRef.ts +3 -2
- package/src/SynchronizedRef.ts +3 -2
- package/src/Trie.ts +18 -17
- package/src/TxChunk.ts +72 -53
- package/src/TxDeferred.ts +394 -0
- package/src/TxHashMap.ts +332 -285
- package/src/TxHashSet.ts +111 -116
- package/src/TxPriorityQueue.ts +767 -0
- package/src/TxPubSub.ts +789 -0
- package/src/TxQueue.ts +241 -251
- package/src/TxReentrantLock.ts +753 -0
- package/src/TxRef.ts +50 -38
- package/src/TxSemaphore.ts +29 -32
- package/src/TxSubscriptionRef.ts +639 -0
- package/src/Types.ts +78 -2
- package/src/index.ts +600 -21
- package/src/internal/core.ts +12 -5
- package/src/internal/dateTime.ts +9 -30
- package/src/internal/effect.ts +744 -265
- package/src/internal/hashMap.ts +9 -7
- package/src/internal/random.ts +20 -0
- package/src/internal/rcRef.ts +4 -3
- package/src/internal/request.ts +2 -2
- package/src/internal/schema/annotations.ts +2 -0
- package/src/internal/schema/schema.ts +1 -0
- package/src/internal/trie.ts +16 -9
- package/src/testing/TestClock.ts +13 -11
- package/src/testing/TestSchema.ts +10 -10
- package/src/unstable/ai/AiError.ts +97 -44
- package/src/unstable/ai/Chat.ts +12 -11
- package/src/unstable/ai/LanguageModel.ts +129 -25
- package/src/unstable/ai/McpSchema.ts +59 -13
- package/src/unstable/ai/McpServer.ts +48 -9
- package/src/unstable/ai/Model.ts +40 -9
- package/src/unstable/ai/Prompt.ts +37 -37
- package/src/unstable/ai/Response.ts +25 -25
- package/src/unstable/ai/Tool.ts +19 -13
- package/src/unstable/ai/index.ts +1 -1
- package/src/unstable/cli/CliOutput.ts +75 -6
- package/src/unstable/cli/Command.ts +501 -60
- package/src/unstable/cli/GlobalFlag.ts +243 -0
- package/src/unstable/cli/HelpDoc.ts +80 -2
- package/src/unstable/cli/index.ts +5 -0
- package/src/unstable/cli/internal/command.ts +50 -34
- package/src/unstable/cli/internal/completions/CommandDescriptor.ts +7 -2
- package/src/unstable/cli/internal/help.ts +146 -0
- package/src/unstable/cli/internal/parser.ts +33 -54
- package/src/unstable/cluster/ClusterCron.ts +2 -2
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +5 -4
- package/src/unstable/cluster/Entity.ts +11 -10
- package/src/unstable/cluster/EntityResource.ts +4 -4
- package/src/unstable/cluster/Envelope.ts +1 -1
- package/src/unstable/cluster/K8sHttpClient.ts +5 -5
- package/src/unstable/cluster/MessageStorage.ts +3 -5
- package/src/unstable/cluster/Runners.ts +6 -5
- package/src/unstable/cluster/Sharding.ts +12 -10
- package/src/unstable/cluster/ShardingConfig.ts +30 -31
- package/src/unstable/cluster/SqlRunnerStorage.ts +1 -1
- package/src/unstable/cluster/internal/entityManager.ts +9 -8
- package/src/unstable/cluster/internal/entityReaper.ts +2 -1
- package/src/unstable/cluster/internal/resourceRef.ts +2 -1
- package/src/unstable/encoding/Sse.ts +3 -5
- package/src/unstable/eventlog/EventLog.ts +2 -1
- package/src/unstable/http/Cookies.ts +3 -3
- package/src/unstable/http/Headers.ts +28 -13
- package/src/unstable/http/HttpBody.ts +42 -1
- package/src/unstable/http/HttpClient.ts +58 -23
- package/src/unstable/http/HttpClientRequest.ts +38 -13
- package/src/unstable/http/HttpEffect.ts +46 -68
- package/src/unstable/http/HttpMethod.ts +16 -4
- package/src/unstable/http/HttpMiddleware.ts +9 -24
- package/src/unstable/http/HttpServerError.ts +42 -45
- package/src/unstable/http/HttpServerRequest.ts +1 -1
- package/src/unstable/http/HttpServerRespondable.ts +6 -6
- package/src/unstable/http/HttpServerResponse.ts +4 -2
- package/src/unstable/http/Multipart.ts +2 -2
- package/src/unstable/http/UrlParams.ts +20 -5
- package/src/unstable/http/internal/preResponseHandler.ts +15 -0
- package/src/unstable/httpapi/HttpApi.ts +5 -5
- package/src/unstable/httpapi/HttpApiBuilder.ts +77 -21
- package/src/unstable/httpapi/HttpApiClient.ts +14 -6
- package/src/unstable/httpapi/HttpApiEndpoint.ts +67 -83
- package/src/unstable/httpapi/HttpApiError.ts +30 -9
- package/src/unstable/httpapi/HttpApiGroup.ts +6 -6
- package/src/unstable/httpapi/HttpApiMiddleware.ts +4 -4
- package/src/unstable/httpapi/HttpApiScalar.ts +6 -0
- package/src/unstable/httpapi/HttpApiSecurity.ts +3 -3
- package/src/unstable/httpapi/OpenApi.ts +41 -23
- package/src/unstable/observability/Otlp.ts +12 -12
- package/src/unstable/observability/OtlpExporter.ts +3 -3
- package/src/unstable/observability/OtlpLogger.ts +13 -9
- package/src/unstable/observability/OtlpMetrics.ts +4 -4
- package/src/unstable/observability/OtlpTracer.ts +4 -4
- package/src/unstable/persistence/KeyValueStore.ts +6 -6
- package/src/unstable/persistence/Persistable.ts +2 -2
- package/src/unstable/persistence/PersistedCache.ts +20 -9
- package/src/unstable/persistence/PersistedQueue.ts +25 -24
- package/src/unstable/persistence/Persistence.ts +3 -3
- package/src/unstable/persistence/RateLimiter.ts +4 -4
- package/src/unstable/process/ChildProcess.ts +6 -208
- package/src/unstable/process/ChildProcessSpawner.ts +75 -14
- package/src/unstable/reactivity/Atom.ts +27 -25
- package/src/unstable/reactivity/AtomHttpApi.ts +21 -20
- package/src/unstable/reactivity/AtomRegistry.ts +31 -7
- package/src/unstable/reactivity/AtomRpc.ts +3 -3
- package/src/unstable/reactivity/Hydration.ts +112 -0
- package/src/unstable/reactivity/index.ts +5 -0
- package/src/unstable/rpc/Rpc.ts +6 -6
- package/src/unstable/rpc/RpcClient.ts +12 -54
- package/src/unstable/rpc/RpcGroup.ts +4 -4
- package/src/unstable/rpc/RpcMiddleware.ts +3 -3
- package/src/unstable/rpc/RpcSchema.ts +17 -0
- package/src/unstable/rpc/RpcSerialization.ts +44 -9
- package/src/unstable/rpc/RpcServer.ts +21 -30
- package/src/unstable/rpc/Utils.ts +2 -1
- package/src/unstable/schema/VariantSchema.ts +6 -6
- package/src/unstable/socket/Socket.ts +16 -17
- package/src/unstable/sql/SqlClient.ts +1 -1
- package/src/unstable/sql/SqlError.ts +11 -9
- package/src/unstable/sql/SqlModel.ts +5 -5
- package/src/unstable/sql/SqlSchema.ts +41 -25
- package/src/unstable/sql/Statement.ts +0 -1
- package/src/unstable/workers/Worker.ts +2 -1
- package/src/unstable/workflow/DurableClock.ts +8 -8
- package/src/unstable/workflow/DurableDeferred.ts +2 -2
- package/src/unstable/workflow/Workflow.ts +6 -2
- package/src/unstable/workflow/WorkflowEngine.ts +185 -2
- package/dist/PartitionedSemaphore.d.ts +0 -52
- package/dist/PartitionedSemaphore.d.ts.map +0 -1
- package/dist/PartitionedSemaphore.js.map +0 -1
- package/dist/encoding/Base64.d.ts +0 -67
- package/dist/encoding/Base64.d.ts.map +0 -1
- package/dist/encoding/Base64.js +0 -146
- package/dist/encoding/Base64.js.map +0 -1
- package/dist/encoding/Base64Url.d.ts +0 -60
- package/dist/encoding/Base64Url.d.ts.map +0 -1
- package/dist/encoding/Base64Url.js +0 -89
- package/dist/encoding/Base64Url.js.map +0 -1
- package/dist/encoding/EncodingError.d.ts +0 -31
- package/dist/encoding/EncodingError.d.ts.map +0 -1
- package/dist/encoding/EncodingError.js +0 -22
- package/dist/encoding/EncodingError.js.map +0 -1
- package/dist/encoding/Hex.d.ts +0 -61
- package/dist/encoding/Hex.d.ts.map +0 -1
- package/dist/encoding/Hex.js +0 -115
- package/dist/encoding/Hex.js.map +0 -1
- package/dist/encoding/index.d.ts +0 -26
- package/dist/encoding/index.d.ts.map +0 -1
- package/dist/encoding/index.js +0 -27
- package/dist/encoding/index.js.map +0 -1
- package/dist/unstable/cli/internal/builtInFlags.d.ts +0 -7
- package/dist/unstable/cli/internal/builtInFlags.d.ts.map +0 -1
- package/dist/unstable/cli/internal/builtInFlags.js +0 -44
- package/dist/unstable/cli/internal/builtInFlags.js.map +0 -1
- package/src/PartitionedSemaphore.ts +0 -182
- package/src/encoding/Base64.ts +0 -366
- package/src/encoding/Base64Url.ts +0 -104
- package/src/encoding/EncodingError.ts +0 -35
- package/src/encoding/Hex.ts +0 -390
- package/src/encoding/index.ts +0 -31
- package/src/unstable/cli/internal/builtInFlags.ts +0 -78
package/src/Effect.ts
CHANGED
|
@@ -84,7 +84,7 @@ import * as internalRequest from "./internal/request.ts"
|
|
|
84
84
|
import * as internalSchedule from "./internal/schedule.ts"
|
|
85
85
|
import type * as Layer from "./Layer.ts"
|
|
86
86
|
import type { Logger } from "./Logger.ts"
|
|
87
|
-
import type {
|
|
87
|
+
import type { Severity } from "./LogLevel.ts"
|
|
88
88
|
import * as Metric from "./Metric.ts"
|
|
89
89
|
import type { Option } from "./Option.ts"
|
|
90
90
|
import type { Pipeable } from "./Pipeable.ts"
|
|
@@ -116,9 +116,12 @@ import type {
|
|
|
116
116
|
ExcludeTag,
|
|
117
117
|
ExtractReason,
|
|
118
118
|
ExtractTag,
|
|
119
|
+
NarrowReason,
|
|
119
120
|
NoInfer,
|
|
121
|
+
OmitReason,
|
|
120
122
|
ReasonOf,
|
|
121
123
|
ReasonTags,
|
|
124
|
+
Simplify,
|
|
122
125
|
Tags,
|
|
123
126
|
unassigned
|
|
124
127
|
} from "./Types.ts"
|
|
@@ -740,7 +743,6 @@ export declare namespace All {
|
|
|
740
743
|
* ```
|
|
741
744
|
*
|
|
742
745
|
* @see {@link forEach} for iterating over elements and applying an effect.
|
|
743
|
-
* @see {@link allWith} for a data-last version of this function.
|
|
744
746
|
*
|
|
745
747
|
* @since 2.0.0
|
|
746
748
|
* @category Collecting
|
|
@@ -852,6 +854,314 @@ export const partition: {
|
|
|
852
854
|
): Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>
|
|
853
855
|
} = internal.partition
|
|
854
856
|
|
|
857
|
+
/**
|
|
858
|
+
* Applies an effectful function to each element and accumulates all failures.
|
|
859
|
+
*
|
|
860
|
+
* This function always evaluates every element. If at least one effect fails,
|
|
861
|
+
* all failures are returned as a non-empty array and successes are discarded.
|
|
862
|
+
* If all effects succeed, it returns all collected successes.
|
|
863
|
+
*
|
|
864
|
+
* Use `discard: true` to ignore successful values while still validating all
|
|
865
|
+
* elements.
|
|
866
|
+
*
|
|
867
|
+
* @example
|
|
868
|
+
* ```ts
|
|
869
|
+
* import { Effect } from "effect"
|
|
870
|
+
*
|
|
871
|
+
* const program = Effect.validate([0, 1, 2, 3], (n) =>
|
|
872
|
+
* n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
|
|
873
|
+
* )
|
|
874
|
+
*
|
|
875
|
+
* Effect.runPromiseExit(program).then(console.log)
|
|
876
|
+
* // {
|
|
877
|
+
* // _id: 'Exit',
|
|
878
|
+
* // _tag: 'Failure',
|
|
879
|
+
* // cause: {
|
|
880
|
+
* // _id: 'Cause',
|
|
881
|
+
* // reasons: [
|
|
882
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '0 is even' },
|
|
883
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '2 is even' }
|
|
884
|
+
* // ]
|
|
885
|
+
* // }
|
|
886
|
+
* // }
|
|
887
|
+
* ```
|
|
888
|
+
*
|
|
889
|
+
* @since 4.0.0
|
|
890
|
+
* @category Error Accumulation
|
|
891
|
+
*/
|
|
892
|
+
export const validate: {
|
|
893
|
+
/**
|
|
894
|
+
* Applies an effectful function to each element and accumulates all failures.
|
|
895
|
+
*
|
|
896
|
+
* This function always evaluates every element. If at least one effect fails,
|
|
897
|
+
* all failures are returned as a non-empty array and successes are discarded.
|
|
898
|
+
* If all effects succeed, it returns all collected successes.
|
|
899
|
+
*
|
|
900
|
+
* Use `discard: true` to ignore successful values while still validating all
|
|
901
|
+
* elements.
|
|
902
|
+
*
|
|
903
|
+
* @example
|
|
904
|
+
* ```ts
|
|
905
|
+
* import { Effect } from "effect"
|
|
906
|
+
*
|
|
907
|
+
* const program = Effect.validate([0, 1, 2, 3], (n) =>
|
|
908
|
+
* n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
|
|
909
|
+
* )
|
|
910
|
+
*
|
|
911
|
+
* Effect.runPromiseExit(program).then(console.log)
|
|
912
|
+
* // {
|
|
913
|
+
* // _id: 'Exit',
|
|
914
|
+
* // _tag: 'Failure',
|
|
915
|
+
* // cause: {
|
|
916
|
+
* // _id: 'Cause',
|
|
917
|
+
* // reasons: [
|
|
918
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '0 is even' },
|
|
919
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '2 is even' }
|
|
920
|
+
* // ]
|
|
921
|
+
* // }
|
|
922
|
+
* // }
|
|
923
|
+
* ```
|
|
924
|
+
*
|
|
925
|
+
* @since 4.0.0
|
|
926
|
+
* @category Error Accumulation
|
|
927
|
+
*/
|
|
928
|
+
<A, B, E, R>(
|
|
929
|
+
f: (a: A, i: number) => Effect<B, E, R>,
|
|
930
|
+
options?: {
|
|
931
|
+
readonly concurrency?: Concurrency | undefined
|
|
932
|
+
readonly discard?: false | undefined
|
|
933
|
+
} | undefined
|
|
934
|
+
): (elements: Iterable<A>) => Effect<Array<B>, Arr.NonEmptyArray<E>, R>
|
|
935
|
+
/**
|
|
936
|
+
* Applies an effectful function to each element and accumulates all failures.
|
|
937
|
+
*
|
|
938
|
+
* This function always evaluates every element. If at least one effect fails,
|
|
939
|
+
* all failures are returned as a non-empty array and successes are discarded.
|
|
940
|
+
* If all effects succeed, it returns all collected successes.
|
|
941
|
+
*
|
|
942
|
+
* Use `discard: true` to ignore successful values while still validating all
|
|
943
|
+
* elements.
|
|
944
|
+
*
|
|
945
|
+
* @example
|
|
946
|
+
* ```ts
|
|
947
|
+
* import { Effect } from "effect"
|
|
948
|
+
*
|
|
949
|
+
* const program = Effect.validate([0, 1, 2, 3], (n) =>
|
|
950
|
+
* n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
|
|
951
|
+
* )
|
|
952
|
+
*
|
|
953
|
+
* Effect.runPromiseExit(program).then(console.log)
|
|
954
|
+
* // {
|
|
955
|
+
* // _id: 'Exit',
|
|
956
|
+
* // _tag: 'Failure',
|
|
957
|
+
* // cause: {
|
|
958
|
+
* // _id: 'Cause',
|
|
959
|
+
* // reasons: [
|
|
960
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '0 is even' },
|
|
961
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '2 is even' }
|
|
962
|
+
* // ]
|
|
963
|
+
* // }
|
|
964
|
+
* // }
|
|
965
|
+
* ```
|
|
966
|
+
*
|
|
967
|
+
* @since 4.0.0
|
|
968
|
+
* @category Error Accumulation
|
|
969
|
+
*/
|
|
970
|
+
<A, B, E, R>(
|
|
971
|
+
f: (a: A, i: number) => Effect<B, E, R>,
|
|
972
|
+
options: {
|
|
973
|
+
readonly concurrency?: Concurrency | undefined
|
|
974
|
+
readonly discard: true
|
|
975
|
+
}
|
|
976
|
+
): (elements: Iterable<A>) => Effect<void, Arr.NonEmptyArray<E>, R>
|
|
977
|
+
/**
|
|
978
|
+
* Applies an effectful function to each element and accumulates all failures.
|
|
979
|
+
*
|
|
980
|
+
* This function always evaluates every element. If at least one effect fails,
|
|
981
|
+
* all failures are returned as a non-empty array and successes are discarded.
|
|
982
|
+
* If all effects succeed, it returns all collected successes.
|
|
983
|
+
*
|
|
984
|
+
* Use `discard: true` to ignore successful values while still validating all
|
|
985
|
+
* elements.
|
|
986
|
+
*
|
|
987
|
+
* @example
|
|
988
|
+
* ```ts
|
|
989
|
+
* import { Effect } from "effect"
|
|
990
|
+
*
|
|
991
|
+
* const program = Effect.validate([0, 1, 2, 3], (n) =>
|
|
992
|
+
* n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
|
|
993
|
+
* )
|
|
994
|
+
*
|
|
995
|
+
* Effect.runPromiseExit(program).then(console.log)
|
|
996
|
+
* // {
|
|
997
|
+
* // _id: 'Exit',
|
|
998
|
+
* // _tag: 'Failure',
|
|
999
|
+
* // cause: {
|
|
1000
|
+
* // _id: 'Cause',
|
|
1001
|
+
* // reasons: [
|
|
1002
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '0 is even' },
|
|
1003
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '2 is even' }
|
|
1004
|
+
* // ]
|
|
1005
|
+
* // }
|
|
1006
|
+
* // }
|
|
1007
|
+
* ```
|
|
1008
|
+
*
|
|
1009
|
+
* @since 4.0.0
|
|
1010
|
+
* @category Error Accumulation
|
|
1011
|
+
*/
|
|
1012
|
+
<A, B, E, R>(
|
|
1013
|
+
elements: Iterable<A>,
|
|
1014
|
+
f: (a: A, i: number) => Effect<B, E, R>,
|
|
1015
|
+
options?: {
|
|
1016
|
+
readonly concurrency?: Concurrency | undefined
|
|
1017
|
+
readonly discard?: false | undefined
|
|
1018
|
+
} | undefined
|
|
1019
|
+
): Effect<Array<B>, Arr.NonEmptyArray<E>, R>
|
|
1020
|
+
/**
|
|
1021
|
+
* Applies an effectful function to each element and accumulates all failures.
|
|
1022
|
+
*
|
|
1023
|
+
* This function always evaluates every element. If at least one effect fails,
|
|
1024
|
+
* all failures are returned as a non-empty array and successes are discarded.
|
|
1025
|
+
* If all effects succeed, it returns all collected successes.
|
|
1026
|
+
*
|
|
1027
|
+
* Use `discard: true` to ignore successful values while still validating all
|
|
1028
|
+
* elements.
|
|
1029
|
+
*
|
|
1030
|
+
* @example
|
|
1031
|
+
* ```ts
|
|
1032
|
+
* import { Effect } from "effect"
|
|
1033
|
+
*
|
|
1034
|
+
* const program = Effect.validate([0, 1, 2, 3], (n) =>
|
|
1035
|
+
* n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
|
|
1036
|
+
* )
|
|
1037
|
+
*
|
|
1038
|
+
* Effect.runPromiseExit(program).then(console.log)
|
|
1039
|
+
* // {
|
|
1040
|
+
* // _id: 'Exit',
|
|
1041
|
+
* // _tag: 'Failure',
|
|
1042
|
+
* // cause: {
|
|
1043
|
+
* // _id: 'Cause',
|
|
1044
|
+
* // reasons: [
|
|
1045
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '0 is even' },
|
|
1046
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '2 is even' }
|
|
1047
|
+
* // ]
|
|
1048
|
+
* // }
|
|
1049
|
+
* // }
|
|
1050
|
+
* ```
|
|
1051
|
+
*
|
|
1052
|
+
* @since 4.0.0
|
|
1053
|
+
* @category Error Accumulation
|
|
1054
|
+
*/
|
|
1055
|
+
<A, B, E, R>(
|
|
1056
|
+
elements: Iterable<A>,
|
|
1057
|
+
f: (a: A, i: number) => Effect<B, E, R>,
|
|
1058
|
+
options: {
|
|
1059
|
+
readonly concurrency?: Concurrency | undefined
|
|
1060
|
+
readonly discard: true
|
|
1061
|
+
}
|
|
1062
|
+
): Effect<void, Arr.NonEmptyArray<E>, R>
|
|
1063
|
+
} = internal.validate
|
|
1064
|
+
|
|
1065
|
+
/**
|
|
1066
|
+
* Returns the first element that satisfies an effectful predicate.
|
|
1067
|
+
*
|
|
1068
|
+
* The predicate receives the element and its index. Evaluation short-circuits
|
|
1069
|
+
* as soon as an element matches.
|
|
1070
|
+
*
|
|
1071
|
+
* @example
|
|
1072
|
+
* ```ts
|
|
1073
|
+
* import { Effect } from "effect"
|
|
1074
|
+
*
|
|
1075
|
+
* const program = Effect.findFirst([1, 2, 3, 4], (n) => Effect.succeed(n > 2))
|
|
1076
|
+
*
|
|
1077
|
+
* Effect.runPromise(program).then(console.log)
|
|
1078
|
+
* // { _id: 'Option', _tag: 'Some', value: 3 }
|
|
1079
|
+
* ```
|
|
1080
|
+
*
|
|
1081
|
+
* @since 2.0.0
|
|
1082
|
+
* @category Collecting
|
|
1083
|
+
*/
|
|
1084
|
+
export const findFirst: {
|
|
1085
|
+
/**
|
|
1086
|
+
* Returns the first element that satisfies an effectful predicate.
|
|
1087
|
+
*
|
|
1088
|
+
* The predicate receives the element and its index. Evaluation short-circuits
|
|
1089
|
+
* as soon as an element matches.
|
|
1090
|
+
*
|
|
1091
|
+
* @example
|
|
1092
|
+
* ```ts
|
|
1093
|
+
* import { Effect } from "effect"
|
|
1094
|
+
*
|
|
1095
|
+
* const program = Effect.findFirst([1, 2, 3, 4], (n) => Effect.succeed(n > 2))
|
|
1096
|
+
*
|
|
1097
|
+
* Effect.runPromise(program).then(console.log)
|
|
1098
|
+
* // { _id: 'Option', _tag: 'Some', value: 3 }
|
|
1099
|
+
* ```
|
|
1100
|
+
*
|
|
1101
|
+
* @since 2.0.0
|
|
1102
|
+
* @category Collecting
|
|
1103
|
+
*/
|
|
1104
|
+
<A, E, R>(predicate: (a: NoInfer<A>, i: number) => Effect<boolean, E, R>): (elements: Iterable<A>) => Effect<Option<A>, E, R>
|
|
1105
|
+
/**
|
|
1106
|
+
* Returns the first element that satisfies an effectful predicate.
|
|
1107
|
+
*
|
|
1108
|
+
* The predicate receives the element and its index. Evaluation short-circuits
|
|
1109
|
+
* as soon as an element matches.
|
|
1110
|
+
*
|
|
1111
|
+
* @example
|
|
1112
|
+
* ```ts
|
|
1113
|
+
* import { Effect } from "effect"
|
|
1114
|
+
*
|
|
1115
|
+
* const program = Effect.findFirst([1, 2, 3, 4], (n) => Effect.succeed(n > 2))
|
|
1116
|
+
*
|
|
1117
|
+
* Effect.runPromise(program).then(console.log)
|
|
1118
|
+
* // { _id: 'Option', _tag: 'Some', value: 3 }
|
|
1119
|
+
* ```
|
|
1120
|
+
*
|
|
1121
|
+
* @since 2.0.0
|
|
1122
|
+
* @category Collecting
|
|
1123
|
+
*/
|
|
1124
|
+
<A, E, R>(
|
|
1125
|
+
elements: Iterable<A>,
|
|
1126
|
+
predicate: (a: NoInfer<A>, i: number) => Effect<boolean, E, R>
|
|
1127
|
+
): Effect<Option<A>, E, R>
|
|
1128
|
+
} = internal.findFirst
|
|
1129
|
+
|
|
1130
|
+
/**
|
|
1131
|
+
* Returns the first value that passes an effectful `FilterEffect`.
|
|
1132
|
+
*
|
|
1133
|
+
* The filter receives the element and index. Evaluation short-circuits on the
|
|
1134
|
+
* first `Result.succeed` and returns the transformed value in `Option.some`.
|
|
1135
|
+
*
|
|
1136
|
+
* @since 4.0.0
|
|
1137
|
+
* @category Collecting
|
|
1138
|
+
*/
|
|
1139
|
+
export const findFirstFilter: {
|
|
1140
|
+
/**
|
|
1141
|
+
* Returns the first value that passes an effectful `FilterEffect`.
|
|
1142
|
+
*
|
|
1143
|
+
* The filter receives the element and index. Evaluation short-circuits on the
|
|
1144
|
+
* first `Result.succeed` and returns the transformed value in `Option.some`.
|
|
1145
|
+
*
|
|
1146
|
+
* @since 4.0.0
|
|
1147
|
+
* @category Collecting
|
|
1148
|
+
*/
|
|
1149
|
+
<A, B, X, E, R>(filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R, [i: number]>): (elements: Iterable<A>) => Effect<Option<B>, E, R>
|
|
1150
|
+
/**
|
|
1151
|
+
* Returns the first value that passes an effectful `FilterEffect`.
|
|
1152
|
+
*
|
|
1153
|
+
* The filter receives the element and index. Evaluation short-circuits on the
|
|
1154
|
+
* first `Result.succeed` and returns the transformed value in `Option.some`.
|
|
1155
|
+
*
|
|
1156
|
+
* @since 4.0.0
|
|
1157
|
+
* @category Collecting
|
|
1158
|
+
*/
|
|
1159
|
+
<A, B, X, E, R>(
|
|
1160
|
+
elements: Iterable<A>,
|
|
1161
|
+
filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R, [i: number]>
|
|
1162
|
+
): Effect<Option<B>, E, R>
|
|
1163
|
+
} = internal.findFirstFilter
|
|
1164
|
+
|
|
855
1165
|
/**
|
|
856
1166
|
* Executes an effectful operation for each element in an `Iterable`.
|
|
857
1167
|
*
|
|
@@ -1511,6 +1821,103 @@ export const callback: <A, E = never, R = never>(
|
|
|
1511
1821
|
*/
|
|
1512
1822
|
export const never: Effect<never> = internal.never
|
|
1513
1823
|
|
|
1824
|
+
/**
|
|
1825
|
+
* An `Effect` containing an empty record `{}`, used as the starting point for
|
|
1826
|
+
* do notation chains.
|
|
1827
|
+
*
|
|
1828
|
+
* @example
|
|
1829
|
+
* ```ts
|
|
1830
|
+
* import { Effect } from "effect"
|
|
1831
|
+
* import { pipe } from "effect/Function"
|
|
1832
|
+
*
|
|
1833
|
+
* const program = pipe(
|
|
1834
|
+
* Effect.Do,
|
|
1835
|
+
* Effect.bind("x", () => Effect.succeed(2)),
|
|
1836
|
+
* Effect.bind("y", ({ x }) => Effect.succeed(x + 1)),
|
|
1837
|
+
* Effect.let("sum", ({ x, y }) => x + y)
|
|
1838
|
+
* )
|
|
1839
|
+
* ```
|
|
1840
|
+
*
|
|
1841
|
+
* @since 4.0.0
|
|
1842
|
+
* @category Do notation
|
|
1843
|
+
*/
|
|
1844
|
+
export const Do: Effect<{}> = internal.Do
|
|
1845
|
+
|
|
1846
|
+
/**
|
|
1847
|
+
* Gives a name to the success value of an `Effect`, creating a single-key
|
|
1848
|
+
* record used in do notation pipelines.
|
|
1849
|
+
*
|
|
1850
|
+
* @since 4.0.0
|
|
1851
|
+
* @category Do notation
|
|
1852
|
+
*/
|
|
1853
|
+
export const bindTo: {
|
|
1854
|
+
/**
|
|
1855
|
+
* Gives a name to the success value of an `Effect`, creating a single-key
|
|
1856
|
+
* record used in do notation pipelines.
|
|
1857
|
+
*
|
|
1858
|
+
* @since 4.0.0
|
|
1859
|
+
* @category Do notation
|
|
1860
|
+
*/
|
|
1861
|
+
<N extends string>(name: N): <A, E, R>(self: Effect<A, E, R>) => Effect<{ [K in N]: A }, E, R>
|
|
1862
|
+
/**
|
|
1863
|
+
* Gives a name to the success value of an `Effect`, creating a single-key
|
|
1864
|
+
* record used in do notation pipelines.
|
|
1865
|
+
*
|
|
1866
|
+
* @since 4.0.0
|
|
1867
|
+
* @category Do notation
|
|
1868
|
+
*/
|
|
1869
|
+
<A, E, R, N extends string>(self: Effect<A, E, R>, name: N): Effect<{ [K in N]: A }, E, R>
|
|
1870
|
+
} = internal.bindTo
|
|
1871
|
+
|
|
1872
|
+
const let_: {
|
|
1873
|
+
<N extends string, A extends Record<string, any>, B>(
|
|
1874
|
+
name: N,
|
|
1875
|
+
f: (a: NoInfer<A>) => B
|
|
1876
|
+
): <E, R>(
|
|
1877
|
+
self: Effect<A, E, R>
|
|
1878
|
+
) => Effect<Simplify<Omit<A, N> & Record<N, B>>, E, R>
|
|
1879
|
+
<A extends Record<string, any>, E, R, B, N extends string>(
|
|
1880
|
+
self: Effect<A, E, R>,
|
|
1881
|
+
name: N,
|
|
1882
|
+
f: (a: NoInfer<A>) => B
|
|
1883
|
+
): Effect<Simplify<Omit<A, N> & Record<N, B>>, E, R>
|
|
1884
|
+
} = internal.let
|
|
1885
|
+
|
|
1886
|
+
export {
|
|
1887
|
+
/**
|
|
1888
|
+
* Adds a computed plain value to the do notation record.
|
|
1889
|
+
*
|
|
1890
|
+
* @since 4.0.0
|
|
1891
|
+
* @category Do notation
|
|
1892
|
+
*/
|
|
1893
|
+
let_ as let
|
|
1894
|
+
}
|
|
1895
|
+
|
|
1896
|
+
/**
|
|
1897
|
+
* Adds an `Effect` value to the do notation record under a given name.
|
|
1898
|
+
*
|
|
1899
|
+
* @since 4.0.0
|
|
1900
|
+
* @category Do notation
|
|
1901
|
+
*/
|
|
1902
|
+
export const bind: {
|
|
1903
|
+
/**
|
|
1904
|
+
* Adds an `Effect` value to the do notation record under a given name.
|
|
1905
|
+
*
|
|
1906
|
+
* @since 4.0.0
|
|
1907
|
+
* @category Do notation
|
|
1908
|
+
*/
|
|
1909
|
+
<N extends string, A extends Record<string, any>, B, E2, R2>(name: N, f: (a: NoInfer<A>) => Effect<B, E2, R2>): <E, R>(
|
|
1910
|
+
self: Effect<A, E, R>
|
|
1911
|
+
) => Effect<Simplify<Omit<A, N> & Record<N, B>>, E | E2, R | R2>
|
|
1912
|
+
/**
|
|
1913
|
+
* Adds an `Effect` value to the do notation record under a given name.
|
|
1914
|
+
*
|
|
1915
|
+
* @since 4.0.0
|
|
1916
|
+
* @category Do notation
|
|
1917
|
+
*/
|
|
1918
|
+
<A extends Record<string, any>, E, R, B, E2, R2, N extends string>(self: Effect<A, E, R>, name: N, f: (a: NoInfer<A>) => Effect<B, E2, R2>): Effect<Simplify<Omit<A, N> & Record<N, B>>, E | E2, R | R2>
|
|
1919
|
+
} = internal.bind
|
|
1920
|
+
|
|
1514
1921
|
/**
|
|
1515
1922
|
* Provides a way to write effectful code using generator functions, simplifying
|
|
1516
1923
|
* control flow and error handling.
|
|
@@ -4228,8 +4635,16 @@ export const catchReason: {
|
|
|
4228
4635
|
>(
|
|
4229
4636
|
errorTag: K,
|
|
4230
4637
|
reasonTag: RK,
|
|
4231
|
-
f: (
|
|
4232
|
-
|
|
4638
|
+
f: (
|
|
4639
|
+
reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK>,
|
|
4640
|
+
error: NarrowReason<ExtractTag<NoInfer<E>, K>, RK>
|
|
4641
|
+
) => Effect<A2, E2, R2>,
|
|
4642
|
+
orElse?:
|
|
4643
|
+
| ((
|
|
4644
|
+
reasons: ExcludeReason<ExtractTag<NoInfer<E>, K>, RK>,
|
|
4645
|
+
error: OmitReason<ExtractTag<NoInfer<E>, K>, RK>
|
|
4646
|
+
) => Effect<A3, E3, R3>)
|
|
4647
|
+
| undefined
|
|
4233
4648
|
): <A, R>(
|
|
4234
4649
|
self: Effect<A, E, R>
|
|
4235
4650
|
) => Effect<A | A2 | Exclude<A3, unassigned>, (A3 extends unassigned ? E : ExcludeTag<E, K>) | E2 | E3, R | R2 | R3>
|
|
@@ -4284,8 +4699,10 @@ export const catchReason: {
|
|
|
4284
4699
|
self: Effect<A, E, R>,
|
|
4285
4700
|
errorTag: K,
|
|
4286
4701
|
reasonTag: RK,
|
|
4287
|
-
f: (reason: ExtractReason<ExtractTag<E, K>, RK>) => Effect<A2, E2, R2>,
|
|
4288
|
-
orElse?:
|
|
4702
|
+
f: (reason: ExtractReason<ExtractTag<E, K>, RK>, error: NarrowReason<ExtractTag<E, K>, RK>) => Effect<A2, E2, R2>,
|
|
4703
|
+
orElse?:
|
|
4704
|
+
| ((reasons: ExcludeReason<ExtractTag<E, K>, RK>, error: OmitReason<ExtractTag<E, K>, RK>) => Effect<A3, E3, R3>)
|
|
4705
|
+
| undefined
|
|
4289
4706
|
): Effect<A | A2 | Exclude<A3, unassigned>, (A3 extends unassigned ? E : ExcludeTag<E, K>) | E2 | E3, R | R2 | R3>
|
|
4290
4707
|
} = internal.catchReason
|
|
4291
4708
|
|
|
@@ -4363,7 +4780,8 @@ export const catchReasons: {
|
|
|
4363
4780
|
E,
|
|
4364
4781
|
Cases extends {
|
|
4365
4782
|
[RK in ReasonTags<ExtractTag<NoInfer<E>, K>>]+?: (
|
|
4366
|
-
reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK
|
|
4783
|
+
reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK>,
|
|
4784
|
+
error: NarrowReason<ExtractTag<NoInfer<E>, K>, RK>
|
|
4367
4785
|
) => Effect<any, any, any>
|
|
4368
4786
|
},
|
|
4369
4787
|
A2 = unassigned,
|
|
@@ -4373,7 +4791,10 @@ export const catchReasons: {
|
|
|
4373
4791
|
errorTag: K,
|
|
4374
4792
|
cases: Cases,
|
|
4375
4793
|
orElse?:
|
|
4376
|
-
| ((
|
|
4794
|
+
| ((
|
|
4795
|
+
reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>,
|
|
4796
|
+
error: OmitReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>
|
|
4797
|
+
) => Effect<A2, E2, R2>)
|
|
4377
4798
|
| undefined
|
|
4378
4799
|
): <A, R>(
|
|
4379
4800
|
self: Effect<A, E, R>
|
|
@@ -4434,7 +4855,10 @@ export const catchReasons: {
|
|
|
4434
4855
|
R,
|
|
4435
4856
|
K extends Tags<E>,
|
|
4436
4857
|
Cases extends {
|
|
4437
|
-
[RK in ReasonTags<ExtractTag<E, K>>]+?: (
|
|
4858
|
+
[RK in ReasonTags<ExtractTag<E, K>>]+?: (
|
|
4859
|
+
reason: ExtractReason<ExtractTag<E, K>, RK>,
|
|
4860
|
+
error: NarrowReason<ExtractTag<E, K>, RK>
|
|
4861
|
+
) => Effect<any, any, any>
|
|
4438
4862
|
},
|
|
4439
4863
|
A2 = unassigned,
|
|
4440
4864
|
E2 = never,
|
|
@@ -4444,7 +4868,10 @@ export const catchReasons: {
|
|
|
4444
4868
|
errorTag: K,
|
|
4445
4869
|
cases: Cases,
|
|
4446
4870
|
orElse?:
|
|
4447
|
-
| ((
|
|
4871
|
+
| ((
|
|
4872
|
+
reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>,
|
|
4873
|
+
error: OmitReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>
|
|
4874
|
+
) => Effect<A2, E2, R2>)
|
|
4448
4875
|
| undefined
|
|
4449
4876
|
): Effect<
|
|
4450
4877
|
| A
|
|
@@ -4870,15 +5297,14 @@ export const catchDefect: {
|
|
|
4870
5297
|
} = internal.catchDefect
|
|
4871
5298
|
|
|
4872
5299
|
/**
|
|
4873
|
-
* Recovers from specific errors using a `
|
|
4874
|
-
* `Refinement`.
|
|
5300
|
+
* Recovers from specific errors using a `Predicate` or `Refinement`.
|
|
4875
5301
|
*
|
|
4876
5302
|
* **When to Use**
|
|
4877
5303
|
*
|
|
4878
|
-
* `catchIf` lets you recover from errors that match a condition.
|
|
4879
|
-
* `
|
|
4880
|
-
*
|
|
4881
|
-
*
|
|
5304
|
+
* `catchIf` lets you recover from errors that match a condition. Use a
|
|
5305
|
+
* `Refinement` for type narrowing or a `Predicate` for simple boolean
|
|
5306
|
+
* matching. Non-matching errors re-fail with the original cause. Defects and
|
|
5307
|
+
* interrupts are not caught.
|
|
4882
5308
|
*
|
|
4883
5309
|
* **Previously Known As**
|
|
4884
5310
|
*
|
|
@@ -4905,7 +5331,7 @@ export const catchDefect: {
|
|
|
4905
5331
|
*
|
|
4906
5332
|
* // With a Filter
|
|
4907
5333
|
* const recovered2 = program.pipe(
|
|
4908
|
-
* Effect.
|
|
5334
|
+
* Effect.catchFilter(
|
|
4909
5335
|
* Filter.tagged("NotFound"),
|
|
4910
5336
|
* (error) => Effect.succeed(`missing:${error.id}`)
|
|
4911
5337
|
* )
|
|
@@ -4917,15 +5343,14 @@ export const catchDefect: {
|
|
|
4917
5343
|
*/
|
|
4918
5344
|
export const catchIf: {
|
|
4919
5345
|
/**
|
|
4920
|
-
* Recovers from specific errors using a `
|
|
4921
|
-
* `Refinement`.
|
|
5346
|
+
* Recovers from specific errors using a `Predicate` or `Refinement`.
|
|
4922
5347
|
*
|
|
4923
5348
|
* **When to Use**
|
|
4924
5349
|
*
|
|
4925
|
-
* `catchIf` lets you recover from errors that match a condition.
|
|
4926
|
-
* `
|
|
4927
|
-
*
|
|
4928
|
-
*
|
|
5350
|
+
* `catchIf` lets you recover from errors that match a condition. Use a
|
|
5351
|
+
* `Refinement` for type narrowing or a `Predicate` for simple boolean
|
|
5352
|
+
* matching. Non-matching errors re-fail with the original cause. Defects and
|
|
5353
|
+
* interrupts are not caught.
|
|
4929
5354
|
*
|
|
4930
5355
|
* **Previously Known As**
|
|
4931
5356
|
*
|
|
@@ -4952,7 +5377,7 @@ export const catchIf: {
|
|
|
4952
5377
|
*
|
|
4953
5378
|
* // With a Filter
|
|
4954
5379
|
* const recovered2 = program.pipe(
|
|
4955
|
-
* Effect.
|
|
5380
|
+
* Effect.catchFilter(
|
|
4956
5381
|
* Filter.tagged("NotFound"),
|
|
4957
5382
|
* (error) => Effect.succeed(`missing:${error.id}`)
|
|
4958
5383
|
* )
|
|
@@ -4968,15 +5393,14 @@ export const catchIf: {
|
|
|
4968
5393
|
orElse?: ((e: Exclude<E, EB>) => Effect<A3, E3, R3>) | undefined
|
|
4969
5394
|
): <A, R>(self: Effect<A, E, R>) => Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
4970
5395
|
/**
|
|
4971
|
-
* Recovers from specific errors using a `
|
|
4972
|
-
* `Refinement`.
|
|
5396
|
+
* Recovers from specific errors using a `Predicate` or `Refinement`.
|
|
4973
5397
|
*
|
|
4974
5398
|
* **When to Use**
|
|
4975
5399
|
*
|
|
4976
|
-
* `catchIf` lets you recover from errors that match a condition.
|
|
4977
|
-
* `
|
|
4978
|
-
*
|
|
4979
|
-
*
|
|
5400
|
+
* `catchIf` lets you recover from errors that match a condition. Use a
|
|
5401
|
+
* `Refinement` for type narrowing or a `Predicate` for simple boolean
|
|
5402
|
+
* matching. Non-matching errors re-fail with the original cause. Defects and
|
|
5403
|
+
* interrupts are not caught.
|
|
4980
5404
|
*
|
|
4981
5405
|
* **Previously Known As**
|
|
4982
5406
|
*
|
|
@@ -5003,7 +5427,7 @@ export const catchIf: {
|
|
|
5003
5427
|
*
|
|
5004
5428
|
* // With a Filter
|
|
5005
5429
|
* const recovered2 = program.pipe(
|
|
5006
|
-
* Effect.
|
|
5430
|
+
* Effect.catchFilter(
|
|
5007
5431
|
* Filter.tagged("NotFound"),
|
|
5008
5432
|
* (error) => Effect.succeed(`missing:${error.id}`)
|
|
5009
5433
|
* )
|
|
@@ -5013,21 +5437,20 @@ export const catchIf: {
|
|
|
5013
5437
|
* @since 2.0.0
|
|
5014
5438
|
* @category Error Handling
|
|
5015
5439
|
*/
|
|
5016
|
-
<E,
|
|
5017
|
-
|
|
5018
|
-
f: (e:
|
|
5019
|
-
orElse?: ((e:
|
|
5440
|
+
<E, A2, E2, R2, A3 = never, E3 = E, R3 = never>(
|
|
5441
|
+
predicate: Predicate.Predicate<NoInfer<E>>,
|
|
5442
|
+
f: (e: NoInfer<E>) => Effect<A2, E2, R2>,
|
|
5443
|
+
orElse?: ((e: NoInfer<E>) => Effect<A3, E3, R3>) | undefined
|
|
5020
5444
|
): <A, R>(self: Effect<A, E, R>) => Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
5021
5445
|
/**
|
|
5022
|
-
* Recovers from specific errors using a `
|
|
5023
|
-
* `Refinement`.
|
|
5446
|
+
* Recovers from specific errors using a `Predicate` or `Refinement`.
|
|
5024
5447
|
*
|
|
5025
5448
|
* **When to Use**
|
|
5026
5449
|
*
|
|
5027
|
-
* `catchIf` lets you recover from errors that match a condition.
|
|
5028
|
-
* `
|
|
5029
|
-
*
|
|
5030
|
-
*
|
|
5450
|
+
* `catchIf` lets you recover from errors that match a condition. Use a
|
|
5451
|
+
* `Refinement` for type narrowing or a `Predicate` for simple boolean
|
|
5452
|
+
* matching. Non-matching errors re-fail with the original cause. Defects and
|
|
5453
|
+
* interrupts are not caught.
|
|
5031
5454
|
*
|
|
5032
5455
|
* **Previously Known As**
|
|
5033
5456
|
*
|
|
@@ -5054,7 +5477,7 @@ export const catchIf: {
|
|
|
5054
5477
|
*
|
|
5055
5478
|
* // With a Filter
|
|
5056
5479
|
* const recovered2 = program.pipe(
|
|
5057
|
-
* Effect.
|
|
5480
|
+
* Effect.catchFilter(
|
|
5058
5481
|
* Filter.tagged("NotFound"),
|
|
5059
5482
|
* (error) => Effect.succeed(`missing:${error.id}`)
|
|
5060
5483
|
* )
|
|
@@ -5071,15 +5494,14 @@ export const catchIf: {
|
|
|
5071
5494
|
orElse?: ((e: Exclude<E, EB>) => Effect<A3, E3, R3>) | undefined
|
|
5072
5495
|
): Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
5073
5496
|
/**
|
|
5074
|
-
* Recovers from specific errors using a `
|
|
5075
|
-
* `Refinement`.
|
|
5497
|
+
* Recovers from specific errors using a `Predicate` or `Refinement`.
|
|
5076
5498
|
*
|
|
5077
5499
|
* **When to Use**
|
|
5078
5500
|
*
|
|
5079
|
-
* `catchIf` lets you recover from errors that match a condition.
|
|
5080
|
-
* `
|
|
5081
|
-
*
|
|
5082
|
-
*
|
|
5501
|
+
* `catchIf` lets you recover from errors that match a condition. Use a
|
|
5502
|
+
* `Refinement` for type narrowing or a `Predicate` for simple boolean
|
|
5503
|
+
* matching. Non-matching errors re-fail with the original cause. Defects and
|
|
5504
|
+
* interrupts are not caught.
|
|
5083
5505
|
*
|
|
5084
5506
|
* **Previously Known As**
|
|
5085
5507
|
*
|
|
@@ -5106,7 +5528,7 @@ export const catchIf: {
|
|
|
5106
5528
|
*
|
|
5107
5529
|
* // With a Filter
|
|
5108
5530
|
* const recovered2 = program.pipe(
|
|
5109
|
-
* Effect.
|
|
5531
|
+
* Effect.catchFilter(
|
|
5110
5532
|
* Filter.tagged("NotFound"),
|
|
5111
5533
|
* (error) => Effect.succeed(`missing:${error.id}`)
|
|
5112
5534
|
* )
|
|
@@ -5116,14 +5538,46 @@ export const catchIf: {
|
|
|
5116
5538
|
* @since 2.0.0
|
|
5117
5539
|
* @category Error Handling
|
|
5118
5540
|
*/
|
|
5119
|
-
<A, E, R,
|
|
5541
|
+
<A, E, R, A2, E2, R2, A3 = never, E3 = E, R3 = never>(
|
|
5120
5542
|
self: Effect<A, E, R>,
|
|
5121
|
-
|
|
5122
|
-
f: (e:
|
|
5123
|
-
orElse?: ((e:
|
|
5543
|
+
predicate: Predicate.Predicate<E>,
|
|
5544
|
+
f: (e: E) => Effect<A2, E2, R2>,
|
|
5545
|
+
orElse?: ((e: E) => Effect<A3, E3, R3>) | undefined
|
|
5124
5546
|
): Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
5125
5547
|
} = internal.catchIf
|
|
5126
5548
|
|
|
5549
|
+
/**
|
|
5550
|
+
* Recovers from specific errors using a `Filter`.
|
|
5551
|
+
*
|
|
5552
|
+
* @since 4.0.0
|
|
5553
|
+
* @category Error Handling
|
|
5554
|
+
*/
|
|
5555
|
+
export const catchFilter: {
|
|
5556
|
+
/**
|
|
5557
|
+
* Recovers from specific errors using a `Filter`.
|
|
5558
|
+
*
|
|
5559
|
+
* @since 4.0.0
|
|
5560
|
+
* @category Error Handling
|
|
5561
|
+
*/
|
|
5562
|
+
<E, EB, A2, E2, R2, X, A3 = never, E3 = X, R3 = never>(
|
|
5563
|
+
filter: Filter.Filter<NoInfer<E>, EB, X>,
|
|
5564
|
+
f: (e: EB) => Effect<A2, E2, R2>,
|
|
5565
|
+
orElse?: ((e: X) => Effect<A3, E3, R3>) | undefined
|
|
5566
|
+
): <A, R>(self: Effect<A, E, R>) => Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
5567
|
+
/**
|
|
5568
|
+
* Recovers from specific errors using a `Filter`.
|
|
5569
|
+
*
|
|
5570
|
+
* @since 4.0.0
|
|
5571
|
+
* @category Error Handling
|
|
5572
|
+
*/
|
|
5573
|
+
<A, E, R, EB, A2, E2, R2, X, A3 = never, E3 = X, R3 = never>(
|
|
5574
|
+
self: Effect<A, E, R>,
|
|
5575
|
+
filter: Filter.Filter<NoInfer<E>, EB, X>,
|
|
5576
|
+
f: (e: EB) => Effect<A2, E2, R2>,
|
|
5577
|
+
orElse?: ((e: X) => Effect<A3, E3, R3>) | undefined
|
|
5578
|
+
): Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
5579
|
+
} = internal.catchFilter
|
|
5580
|
+
|
|
5127
5581
|
/**
|
|
5128
5582
|
* Catches `NoSuchElementError` failures and converts them to `Option.none`.
|
|
5129
5583
|
*
|
|
@@ -5231,10 +5685,10 @@ export const catchCauseIf: {
|
|
|
5231
5685
|
* @since 4.0.0
|
|
5232
5686
|
* @category Error Handling
|
|
5233
5687
|
*/
|
|
5234
|
-
<E,
|
|
5235
|
-
|
|
5236
|
-
f: (
|
|
5237
|
-
): <A, R>(self: Effect<A, E, R>) => Effect<A | B,
|
|
5688
|
+
<E, B, E2, R2>(
|
|
5689
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
5690
|
+
f: (cause: Cause.Cause<E>) => Effect<B, E2, R2>
|
|
5691
|
+
): <A, R>(self: Effect<A, E, R>) => Effect<A | B, E | E2, R | R2>
|
|
5238
5692
|
/**
|
|
5239
5693
|
* Recovers from specific failures based on a predicate.
|
|
5240
5694
|
*
|
|
@@ -5273,13 +5727,43 @@ export const catchCauseIf: {
|
|
|
5273
5727
|
* @since 4.0.0
|
|
5274
5728
|
* @category Error Handling
|
|
5275
5729
|
*/
|
|
5276
|
-
<A, E, R, B, E2, R2
|
|
5730
|
+
<A, E, R, B, E2, R2>(
|
|
5277
5731
|
self: Effect<A, E, R>,
|
|
5278
|
-
|
|
5279
|
-
f: (
|
|
5280
|
-
): Effect<A | B,
|
|
5732
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
5733
|
+
f: (cause: Cause.Cause<E>) => Effect<B, E2, R2>
|
|
5734
|
+
): Effect<A | B, E | E2, R | R2>
|
|
5281
5735
|
} = internal.catchCauseIf
|
|
5282
5736
|
|
|
5737
|
+
/**
|
|
5738
|
+
* Recovers from specific failures based on a `Filter`.
|
|
5739
|
+
*
|
|
5740
|
+
* @since 4.0.0
|
|
5741
|
+
* @category Error Handling
|
|
5742
|
+
*/
|
|
5743
|
+
export const catchCauseFilter: {
|
|
5744
|
+
/**
|
|
5745
|
+
* Recovers from specific failures based on a `Filter`.
|
|
5746
|
+
*
|
|
5747
|
+
* @since 4.0.0
|
|
5748
|
+
* @category Error Handling
|
|
5749
|
+
*/
|
|
5750
|
+
<E, B, E2, R2, EB, X extends Cause.Cause<any>>(
|
|
5751
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
5752
|
+
f: (failure: EB, cause: Cause.Cause<E>) => Effect<B, E2, R2>
|
|
5753
|
+
): <A, R>(self: Effect<A, E, R>) => Effect<A | B, Cause.Cause.Error<X> | E2, R | R2>
|
|
5754
|
+
/**
|
|
5755
|
+
* Recovers from specific failures based on a `Filter`.
|
|
5756
|
+
*
|
|
5757
|
+
* @since 4.0.0
|
|
5758
|
+
* @category Error Handling
|
|
5759
|
+
*/
|
|
5760
|
+
<A, E, R, B, E2, R2, EB, X extends Cause.Cause<any>>(
|
|
5761
|
+
self: Effect<A, E, R>,
|
|
5762
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
5763
|
+
f: (failure: EB, cause: Cause.Cause<E>) => Effect<B, E2, R2>
|
|
5764
|
+
): Effect<A | B, Cause.Cause.Error<X> | E2, R | R2>
|
|
5765
|
+
} = internal.catchCauseFilter
|
|
5766
|
+
|
|
5283
5767
|
/**
|
|
5284
5768
|
* The `mapError` function is used to transform or modify the error
|
|
5285
5769
|
* produced by an effect, without affecting its success value.
|
|
@@ -5905,9 +6389,9 @@ export const tapCauseIf: {
|
|
|
5905
6389
|
* @since 4.0.0
|
|
5906
6390
|
* @category Sequencing
|
|
5907
6391
|
*/
|
|
5908
|
-
<E,
|
|
5909
|
-
|
|
5910
|
-
f: (
|
|
6392
|
+
<E, B, E2, R2>(
|
|
6393
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
6394
|
+
f: (cause: Cause.Cause<E>) => Effect<B, E2, R2>
|
|
5911
6395
|
): <A, R>(self: Effect<A, E, R>) => Effect<A, E | E2, R | R2>
|
|
5912
6396
|
/**
|
|
5913
6397
|
* Conditionally executes a side effect based on the cause of a failed effect.
|
|
@@ -5937,13 +6421,43 @@ export const tapCauseIf: {
|
|
|
5937
6421
|
* @since 4.0.0
|
|
5938
6422
|
* @category Sequencing
|
|
5939
6423
|
*/
|
|
5940
|
-
<A, E, R,
|
|
6424
|
+
<A, E, R, B, E2, R2>(
|
|
5941
6425
|
self: Effect<A, E, R>,
|
|
5942
|
-
|
|
5943
|
-
f: (
|
|
6426
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
6427
|
+
f: (cause: Cause.Cause<E>) => Effect<B, E2, R2>
|
|
5944
6428
|
): Effect<A, E | E2, R | R2>
|
|
5945
6429
|
} = internal.tapCauseIf
|
|
5946
6430
|
|
|
6431
|
+
/**
|
|
6432
|
+
* Conditionally executes a side effect based on the cause of a failed effect.
|
|
6433
|
+
*
|
|
6434
|
+
* @since 4.0.0
|
|
6435
|
+
* @category Sequencing
|
|
6436
|
+
*/
|
|
6437
|
+
export const tapCauseFilter: {
|
|
6438
|
+
/**
|
|
6439
|
+
* Conditionally executes a side effect based on the cause of a failed effect.
|
|
6440
|
+
*
|
|
6441
|
+
* @since 4.0.0
|
|
6442
|
+
* @category Sequencing
|
|
6443
|
+
*/
|
|
6444
|
+
<E, B, E2, R2, EB, X extends Cause.Cause<any>>(
|
|
6445
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
6446
|
+
f: (a: EB, cause: Cause.Cause<E>) => Effect<B, E2, R2>
|
|
6447
|
+
): <A, R>(self: Effect<A, E, R>) => Effect<A, E | E2, R | R2>
|
|
6448
|
+
/**
|
|
6449
|
+
* Conditionally executes a side effect based on the cause of a failed effect.
|
|
6450
|
+
*
|
|
6451
|
+
* @since 4.0.0
|
|
6452
|
+
* @category Sequencing
|
|
6453
|
+
*/
|
|
6454
|
+
<A, E, R, B, E2, R2, EB, X extends Cause.Cause<any>>(
|
|
6455
|
+
self: Effect<A, E, R>,
|
|
6456
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
6457
|
+
f: (a: EB, cause: Cause.Cause<E>) => Effect<B, E2, R2>
|
|
6458
|
+
): Effect<A, E | E2, R | R2>
|
|
6459
|
+
} = internal.tapCauseFilter
|
|
6460
|
+
|
|
5947
6461
|
/**
|
|
5948
6462
|
* Inspect severe errors or defects (non-recoverable failures) in an effect.
|
|
5949
6463
|
*
|
|
@@ -6837,14 +7351,14 @@ export const sandbox: <A, E, R>(
|
|
|
6837
7351
|
*/
|
|
6838
7352
|
export const ignore: <
|
|
6839
7353
|
Arg extends Effect<any, any, any> | {
|
|
6840
|
-
readonly log?: boolean |
|
|
7354
|
+
readonly log?: boolean | Severity | undefined
|
|
6841
7355
|
} | undefined = {
|
|
6842
|
-
readonly log?: boolean |
|
|
7356
|
+
readonly log?: boolean | Severity | undefined
|
|
6843
7357
|
}
|
|
6844
7358
|
>(
|
|
6845
7359
|
effectOrOptions?: Arg,
|
|
6846
7360
|
options?: {
|
|
6847
|
-
readonly log?: boolean |
|
|
7361
|
+
readonly log?: boolean | Severity | undefined
|
|
6848
7362
|
} | undefined
|
|
6849
7363
|
) => [Arg] extends [Effect<infer _A, infer _E, infer _R>] ? Effect<void, never, _R>
|
|
6850
7364
|
: <A, E, R>(self: Effect<A, E, R>) => Effect<void, never, R> = internal.ignore
|
|
@@ -6869,14 +7383,14 @@ export const ignore: <
|
|
|
6869
7383
|
*/
|
|
6870
7384
|
export const ignoreCause: <
|
|
6871
7385
|
Arg extends Effect<any, any, any> | {
|
|
6872
|
-
readonly log?: boolean |
|
|
7386
|
+
readonly log?: boolean | Severity | undefined
|
|
6873
7387
|
} | undefined = {
|
|
6874
|
-
readonly log?: boolean |
|
|
7388
|
+
readonly log?: boolean | Severity | undefined
|
|
6875
7389
|
}
|
|
6876
7390
|
>(
|
|
6877
7391
|
effectOrOptions?: Arg,
|
|
6878
7392
|
options?: {
|
|
6879
|
-
readonly log?: boolean |
|
|
7393
|
+
readonly log?: boolean | Severity | undefined
|
|
6880
7394
|
} | undefined
|
|
6881
7395
|
) => [Arg] extends [Effect<infer _A, infer _E, infer _R>] ? Effect<void, never, _R>
|
|
6882
7396
|
: <A, E, R>(self: Effect<A, E, R>) => Effect<void, never, R> = internal.ignoreCause
|
|
@@ -6983,6 +7497,25 @@ export const withExecutionPlan: {
|
|
|
6983
7497
|
): Effect<A, E | PlanE, Exclude<R, Provides> | PlanR>
|
|
6984
7498
|
} = internalExecutionPlan.withExecutionPlan
|
|
6985
7499
|
|
|
7500
|
+
/**
|
|
7501
|
+
* Runs an effect and reports any errors to the configured `ErrorReporter`s.
|
|
7502
|
+
*
|
|
7503
|
+
* If the `defectsOnly` option is set to `true`, only defects (unrecoverable
|
|
7504
|
+
* errors) will be reported, while regular failures will be ignored.
|
|
7505
|
+
*
|
|
7506
|
+
* @since 4.0.0
|
|
7507
|
+
* @category Error Handling
|
|
7508
|
+
*/
|
|
7509
|
+
export const withErrorReporting: <
|
|
7510
|
+
Arg extends Effect<any, any, any> | { readonly defectsOnly?: boolean | undefined } | undefined = {
|
|
7511
|
+
readonly defectsOnly?: boolean | undefined
|
|
7512
|
+
}
|
|
7513
|
+
>(
|
|
7514
|
+
effectOrOptions: Arg,
|
|
7515
|
+
options?: { readonly defectsOnly?: boolean | undefined } | undefined
|
|
7516
|
+
) => [Arg] extends [Effect<infer _A, infer _E, infer _R>] ? Arg : <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, R> =
|
|
7517
|
+
internal.withErrorReporting
|
|
7518
|
+
|
|
6986
7519
|
// -----------------------------------------------------------------------------
|
|
6987
7520
|
// Fallback
|
|
6988
7521
|
// -----------------------------------------------------------------------------
|
|
@@ -7224,7 +7757,7 @@ export const timeout: {
|
|
|
7224
7757
|
* @since 2.0.0
|
|
7225
7758
|
* @category Delays & Timeouts
|
|
7226
7759
|
*/
|
|
7227
|
-
(duration: Duration.
|
|
7760
|
+
(duration: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E | Cause.TimeoutError, R>
|
|
7228
7761
|
// -----------------------------------------------------------------------------
|
|
7229
7762
|
// Delays & timeouts
|
|
7230
7763
|
// -----------------------------------------------------------------------------
|
|
@@ -7275,7 +7808,7 @@ export const timeout: {
|
|
|
7275
7808
|
* @since 2.0.0
|
|
7276
7809
|
* @category Delays & Timeouts
|
|
7277
7810
|
*/
|
|
7278
|
-
<A, E, R>(self: Effect<A, E, R>, duration: Duration.
|
|
7811
|
+
<A, E, R>(self: Effect<A, E, R>, duration: Duration.Input): Effect<A, E | Cause.TimeoutError, R>
|
|
7279
7812
|
} = internal.timeout
|
|
7280
7813
|
|
|
7281
7814
|
/**
|
|
@@ -7377,7 +7910,7 @@ export const timeoutOption: {
|
|
|
7377
7910
|
* @since 3.1.0
|
|
7378
7911
|
* @category Delays & Timeouts
|
|
7379
7912
|
*/
|
|
7380
|
-
(duration: Duration.
|
|
7913
|
+
(duration: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<Option<A>, E, R>
|
|
7381
7914
|
/**
|
|
7382
7915
|
* Handles timeouts by returning an `Option` that represents either the result
|
|
7383
7916
|
* or a timeout.
|
|
@@ -7427,7 +7960,7 @@ export const timeoutOption: {
|
|
|
7427
7960
|
* @since 3.1.0
|
|
7428
7961
|
* @category Delays & Timeouts
|
|
7429
7962
|
*/
|
|
7430
|
-
<A, E, R>(self: Effect<A, E, R>, duration: Duration.
|
|
7963
|
+
<A, E, R>(self: Effect<A, E, R>, duration: Duration.Input): Effect<Option<A>, E, R>
|
|
7431
7964
|
} = internal.timeoutOption
|
|
7432
7965
|
|
|
7433
7966
|
/**
|
|
@@ -7505,7 +8038,7 @@ export const timeoutOrElse: {
|
|
|
7505
8038
|
*/
|
|
7506
8039
|
<A2, E2, R2>(
|
|
7507
8040
|
options: {
|
|
7508
|
-
readonly duration: Duration.
|
|
8041
|
+
readonly duration: Duration.Input
|
|
7509
8042
|
readonly onTimeout: LazyArg<Effect<A2, E2, R2>>
|
|
7510
8043
|
}
|
|
7511
8044
|
): <A, E, R>(self: Effect<A, E, R>) => Effect<A | A2, E | E2, R | R2>
|
|
@@ -7548,7 +8081,7 @@ export const timeoutOrElse: {
|
|
|
7548
8081
|
<A, E, R, A2, E2, R2>(
|
|
7549
8082
|
self: Effect<A, E, R>,
|
|
7550
8083
|
options: {
|
|
7551
|
-
readonly duration: Duration.
|
|
8084
|
+
readonly duration: Duration.Input
|
|
7552
8085
|
readonly onTimeout: LazyArg<Effect<A2, E2, R2>>
|
|
7553
8086
|
}
|
|
7554
8087
|
): Effect<A | A2, E | E2, R | R2>
|
|
@@ -7595,7 +8128,7 @@ export const delay: {
|
|
|
7595
8128
|
* @since 2.0.0
|
|
7596
8129
|
* @category Delays & Timeouts
|
|
7597
8130
|
*/
|
|
7598
|
-
(duration: Duration.
|
|
8131
|
+
(duration: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, R>
|
|
7599
8132
|
/**
|
|
7600
8133
|
* Returns an effect that is delayed from this effect by the specified
|
|
7601
8134
|
* `Duration`.
|
|
@@ -7616,7 +8149,7 @@ export const delay: {
|
|
|
7616
8149
|
* @since 2.0.0
|
|
7617
8150
|
* @category Delays & Timeouts
|
|
7618
8151
|
*/
|
|
7619
|
-
<A, E, R>(self: Effect<A, E, R>, duration: Duration.
|
|
8152
|
+
<A, E, R>(self: Effect<A, E, R>, duration: Duration.Input): Effect<A, E, R>
|
|
7620
8153
|
} = internal.delay
|
|
7621
8154
|
|
|
7622
8155
|
/**
|
|
@@ -7641,7 +8174,7 @@ export const delay: {
|
|
|
7641
8174
|
* @since 2.0.0
|
|
7642
8175
|
* @category Delays & Timeouts
|
|
7643
8176
|
*/
|
|
7644
|
-
export const sleep: (duration: Duration.
|
|
8177
|
+
export const sleep: (duration: Duration.Input) => Effect<void> = internal.sleep
|
|
7645
8178
|
|
|
7646
8179
|
/**
|
|
7647
8180
|
* Measures the runtime of an effect and returns the duration with its result.
|
|
@@ -7961,12 +8494,12 @@ export const raceFirst: {
|
|
|
7961
8494
|
// -----------------------------------------------------------------------------
|
|
7962
8495
|
|
|
7963
8496
|
/**
|
|
7964
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7965
|
-
* predicate
|
|
8497
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8498
|
+
* predicate.
|
|
7966
8499
|
*
|
|
7967
8500
|
* @example
|
|
7968
8501
|
* ```ts
|
|
7969
|
-
* import { Effect
|
|
8502
|
+
* import { Effect } from "effect"
|
|
7970
8503
|
*
|
|
7971
8504
|
* // Sync predicate
|
|
7972
8505
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -7974,10 +8507,7 @@ export const raceFirst: {
|
|
|
7974
8507
|
* // Effectful predicate
|
|
7975
8508
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7976
8509
|
*
|
|
7977
|
-
* //
|
|
7978
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
7979
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
7980
|
-
* )
|
|
8510
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
7981
8511
|
* ```
|
|
7982
8512
|
*
|
|
7983
8513
|
* @since 2.0.0
|
|
@@ -7989,12 +8519,12 @@ export const filter: {
|
|
|
7989
8519
|
// -----------------------------------------------------------------------------
|
|
7990
8520
|
|
|
7991
8521
|
/**
|
|
7992
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7993
|
-
* predicate
|
|
8522
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8523
|
+
* predicate.
|
|
7994
8524
|
*
|
|
7995
8525
|
* @example
|
|
7996
8526
|
* ```ts
|
|
7997
|
-
* import { Effect
|
|
8527
|
+
* import { Effect } from "effect"
|
|
7998
8528
|
*
|
|
7999
8529
|
* // Sync predicate
|
|
8000
8530
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -8002,10 +8532,7 @@ export const filter: {
|
|
|
8002
8532
|
* // Effectful predicate
|
|
8003
8533
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
8004
8534
|
*
|
|
8005
|
-
* //
|
|
8006
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
8007
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
8008
|
-
* )
|
|
8535
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
8009
8536
|
* ```
|
|
8010
8537
|
*
|
|
8011
8538
|
* @since 2.0.0
|
|
@@ -8017,12 +8544,12 @@ export const filter: {
|
|
|
8017
8544
|
// -----------------------------------------------------------------------------
|
|
8018
8545
|
|
|
8019
8546
|
/**
|
|
8020
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
8021
|
-
* predicate
|
|
8547
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8548
|
+
* predicate.
|
|
8022
8549
|
*
|
|
8023
8550
|
* @example
|
|
8024
8551
|
* ```ts
|
|
8025
|
-
* import { Effect
|
|
8552
|
+
* import { Effect } from "effect"
|
|
8026
8553
|
*
|
|
8027
8554
|
* // Sync predicate
|
|
8028
8555
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -8030,10 +8557,7 @@ export const filter: {
|
|
|
8030
8557
|
* // Effectful predicate
|
|
8031
8558
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
8032
8559
|
*
|
|
8033
|
-
* //
|
|
8034
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
8035
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
8036
|
-
* )
|
|
8560
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
8037
8561
|
* ```
|
|
8038
8562
|
*
|
|
8039
8563
|
* @since 2.0.0
|
|
@@ -8045,12 +8569,12 @@ export const filter: {
|
|
|
8045
8569
|
// -----------------------------------------------------------------------------
|
|
8046
8570
|
|
|
8047
8571
|
/**
|
|
8048
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
8049
|
-
* predicate
|
|
8572
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8573
|
+
* predicate.
|
|
8050
8574
|
*
|
|
8051
8575
|
* @example
|
|
8052
8576
|
* ```ts
|
|
8053
|
-
* import { Effect
|
|
8577
|
+
* import { Effect } from "effect"
|
|
8054
8578
|
*
|
|
8055
8579
|
* // Sync predicate
|
|
8056
8580
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -8058,30 +8582,27 @@ export const filter: {
|
|
|
8058
8582
|
* // Effectful predicate
|
|
8059
8583
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
8060
8584
|
*
|
|
8061
|
-
* //
|
|
8062
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
8063
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
8064
|
-
* )
|
|
8585
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
8065
8586
|
* ```
|
|
8066
8587
|
*
|
|
8067
8588
|
* @since 2.0.0
|
|
8068
8589
|
* @category Filtering
|
|
8069
8590
|
*/
|
|
8070
|
-
<A,
|
|
8071
|
-
|
|
8591
|
+
<A, E, R>(
|
|
8592
|
+
predicate: (a: NoInfer<A>, i: number) => Effect<boolean, E, R>,
|
|
8072
8593
|
options?: { readonly concurrency?: Concurrency | undefined }
|
|
8073
|
-
): (
|
|
8594
|
+
): (iterable: Iterable<A>) => Effect<Array<A>, E, R>
|
|
8074
8595
|
// -----------------------------------------------------------------------------
|
|
8075
8596
|
// Filtering
|
|
8076
8597
|
// -----------------------------------------------------------------------------
|
|
8077
8598
|
|
|
8078
8599
|
/**
|
|
8079
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
8080
|
-
* predicate
|
|
8600
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8601
|
+
* predicate.
|
|
8081
8602
|
*
|
|
8082
8603
|
* @example
|
|
8083
8604
|
* ```ts
|
|
8084
|
-
* import { Effect
|
|
8605
|
+
* import { Effect } from "effect"
|
|
8085
8606
|
*
|
|
8086
8607
|
* // Sync predicate
|
|
8087
8608
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -8089,30 +8610,24 @@ export const filter: {
|
|
|
8089
8610
|
* // Effectful predicate
|
|
8090
8611
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
8091
8612
|
*
|
|
8092
|
-
* //
|
|
8093
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
8094
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
8095
|
-
* )
|
|
8613
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
8096
8614
|
* ```
|
|
8097
8615
|
*
|
|
8098
8616
|
* @since 2.0.0
|
|
8099
8617
|
* @category Filtering
|
|
8100
8618
|
*/
|
|
8101
|
-
<A, B
|
|
8102
|
-
filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R>,
|
|
8103
|
-
options?: { readonly concurrency?: Concurrency | undefined }
|
|
8104
|
-
): (elements: Iterable<A>) => Effect<Array<B>, E, R>
|
|
8619
|
+
<A, B extends A>(elements: Iterable<A>, refinement: Predicate.Refinement<A, B>): Effect<Array<B>>
|
|
8105
8620
|
// -----------------------------------------------------------------------------
|
|
8106
8621
|
// Filtering
|
|
8107
8622
|
// -----------------------------------------------------------------------------
|
|
8108
8623
|
|
|
8109
8624
|
/**
|
|
8110
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
8111
|
-
* predicate
|
|
8625
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8626
|
+
* predicate.
|
|
8112
8627
|
*
|
|
8113
8628
|
* @example
|
|
8114
8629
|
* ```ts
|
|
8115
|
-
* import { Effect
|
|
8630
|
+
* import { Effect } from "effect"
|
|
8116
8631
|
*
|
|
8117
8632
|
* // Sync predicate
|
|
8118
8633
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -8120,30 +8635,24 @@ export const filter: {
|
|
|
8120
8635
|
* // Effectful predicate
|
|
8121
8636
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
8122
8637
|
*
|
|
8123
|
-
* //
|
|
8124
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
8125
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
8126
|
-
* )
|
|
8638
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
8127
8639
|
* ```
|
|
8128
8640
|
*
|
|
8129
8641
|
* @since 2.0.0
|
|
8130
8642
|
* @category Filtering
|
|
8131
8643
|
*/
|
|
8132
|
-
<A
|
|
8133
|
-
predicate: (a: NoInfer<A>, i: number) => Effect<boolean, E, R>,
|
|
8134
|
-
options?: { readonly concurrency?: Concurrency | undefined }
|
|
8135
|
-
): (iterable: Iterable<A>) => Effect<Array<A>, E, R>
|
|
8644
|
+
<A>(elements: Iterable<A>, predicate: Predicate.Predicate<A>): Effect<Array<A>>
|
|
8136
8645
|
// -----------------------------------------------------------------------------
|
|
8137
8646
|
// Filtering
|
|
8138
8647
|
// -----------------------------------------------------------------------------
|
|
8139
8648
|
|
|
8140
8649
|
/**
|
|
8141
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
8142
|
-
* predicate
|
|
8650
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8651
|
+
* predicate.
|
|
8143
8652
|
*
|
|
8144
8653
|
* @example
|
|
8145
8654
|
* ```ts
|
|
8146
|
-
* import { Effect
|
|
8655
|
+
* import { Effect } from "effect"
|
|
8147
8656
|
*
|
|
8148
8657
|
* // Sync predicate
|
|
8149
8658
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -8151,137 +8660,71 @@ export const filter: {
|
|
|
8151
8660
|
* // Effectful predicate
|
|
8152
8661
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
8153
8662
|
*
|
|
8154
|
-
* //
|
|
8155
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
8156
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
8157
|
-
* )
|
|
8663
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
8158
8664
|
* ```
|
|
8159
8665
|
*
|
|
8160
8666
|
* @since 2.0.0
|
|
8161
8667
|
* @category Filtering
|
|
8162
8668
|
*/
|
|
8163
|
-
<A,
|
|
8164
|
-
|
|
8165
|
-
|
|
8166
|
-
|
|
8669
|
+
<A, E, R>(
|
|
8670
|
+
iterable: Iterable<A>,
|
|
8671
|
+
predicate: (a: NoInfer<A>, i: number) => Effect<boolean, E, R>,
|
|
8672
|
+
options?: { readonly concurrency?: Concurrency | undefined }
|
|
8673
|
+
): Effect<Array<A>, E, R>
|
|
8674
|
+
} = internal.filter
|
|
8167
8675
|
|
|
8676
|
+
/**
|
|
8677
|
+
* Filters and maps elements of an iterable with a `Filter`.
|
|
8678
|
+
*
|
|
8679
|
+
* @since 4.0.0
|
|
8680
|
+
* @category Filtering
|
|
8681
|
+
*/
|
|
8682
|
+
export const filterMap: {
|
|
8168
8683
|
/**
|
|
8169
|
-
* Filters elements of an iterable
|
|
8170
|
-
* predicate, or `Filter.FilterEffect`.
|
|
8171
|
-
*
|
|
8172
|
-
* @example
|
|
8173
|
-
* ```ts
|
|
8174
|
-
* import { Effect, Filter, Result } from "effect"
|
|
8684
|
+
* Filters and maps elements of an iterable with a `Filter`.
|
|
8175
8685
|
*
|
|
8176
|
-
*
|
|
8177
|
-
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
8178
|
-
*
|
|
8179
|
-
* // Effectful predicate
|
|
8180
|
-
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
8181
|
-
*
|
|
8182
|
-
* // FilterEffect
|
|
8183
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
8184
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
8185
|
-
* )
|
|
8186
|
-
* ```
|
|
8187
|
-
*
|
|
8188
|
-
* @since 2.0.0
|
|
8686
|
+
* @since 4.0.0
|
|
8189
8687
|
* @category Filtering
|
|
8190
8688
|
*/
|
|
8191
|
-
<A>(
|
|
8192
|
-
// -----------------------------------------------------------------------------
|
|
8193
|
-
// Filtering
|
|
8194
|
-
// -----------------------------------------------------------------------------
|
|
8195
|
-
|
|
8689
|
+
<A, B, X>(filter: Filter.Filter<NoInfer<A>, B, X>): (elements: Iterable<A>) => Effect<Array<B>>
|
|
8196
8690
|
/**
|
|
8197
|
-
* Filters elements of an iterable
|
|
8198
|
-
* predicate, or `Filter.FilterEffect`.
|
|
8199
|
-
*
|
|
8200
|
-
* @example
|
|
8201
|
-
* ```ts
|
|
8202
|
-
* import { Effect, Filter, Result } from "effect"
|
|
8691
|
+
* Filters and maps elements of an iterable with a `Filter`.
|
|
8203
8692
|
*
|
|
8204
|
-
*
|
|
8205
|
-
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
8206
|
-
*
|
|
8207
|
-
* // Effectful predicate
|
|
8208
|
-
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
8209
|
-
*
|
|
8210
|
-
* // FilterEffect
|
|
8211
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
8212
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
8213
|
-
* )
|
|
8214
|
-
* ```
|
|
8215
|
-
*
|
|
8216
|
-
* @since 2.0.0
|
|
8693
|
+
* @since 4.0.0
|
|
8217
8694
|
* @category Filtering
|
|
8218
8695
|
*/
|
|
8219
8696
|
<A, B, X>(elements: Iterable<A>, filter: Filter.Filter<NoInfer<A>, B, X>): Effect<Array<B>>
|
|
8220
|
-
|
|
8221
|
-
// Filtering
|
|
8222
|
-
// -----------------------------------------------------------------------------
|
|
8697
|
+
} = internal.filterMap
|
|
8223
8698
|
|
|
8224
|
-
|
|
8225
|
-
|
|
8226
|
-
|
|
8227
|
-
|
|
8228
|
-
|
|
8229
|
-
|
|
8230
|
-
|
|
8231
|
-
|
|
8232
|
-
*
|
|
8233
|
-
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
8234
|
-
*
|
|
8235
|
-
* // Effectful predicate
|
|
8236
|
-
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
8237
|
-
*
|
|
8238
|
-
* // FilterEffect
|
|
8239
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
8240
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
8241
|
-
* )
|
|
8242
|
-
* ```
|
|
8699
|
+
/**
|
|
8700
|
+
* Effectfully filters and maps elements of an iterable with a `FilterEffect`.
|
|
8701
|
+
*
|
|
8702
|
+
* @since 4.0.0
|
|
8703
|
+
* @category Filtering
|
|
8704
|
+
*/
|
|
8705
|
+
export const filterMapEffect: {
|
|
8706
|
+
/**
|
|
8707
|
+
* Effectfully filters and maps elements of an iterable with a `FilterEffect`.
|
|
8243
8708
|
*
|
|
8244
|
-
* @since
|
|
8709
|
+
* @since 4.0.0
|
|
8245
8710
|
* @category Filtering
|
|
8246
8711
|
*/
|
|
8247
8712
|
<A, B, X, E, R>(
|
|
8248
|
-
elements: Iterable<A>,
|
|
8249
8713
|
filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R>,
|
|
8250
8714
|
options?: { readonly concurrency?: Concurrency | undefined }
|
|
8251
|
-
): Effect<Array<B>, E, R>
|
|
8252
|
-
// -----------------------------------------------------------------------------
|
|
8253
|
-
// Filtering
|
|
8254
|
-
// -----------------------------------------------------------------------------
|
|
8255
|
-
|
|
8715
|
+
): (elements: Iterable<A>) => Effect<Array<B>, E, R>
|
|
8256
8716
|
/**
|
|
8257
|
-
*
|
|
8258
|
-
* predicate, or `Filter.FilterEffect`.
|
|
8259
|
-
*
|
|
8260
|
-
* @example
|
|
8261
|
-
* ```ts
|
|
8262
|
-
* import { Effect, Filter, Result } from "effect"
|
|
8263
|
-
*
|
|
8264
|
-
* // Sync predicate
|
|
8265
|
-
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
8266
|
-
*
|
|
8267
|
-
* // Effectful predicate
|
|
8268
|
-
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
8717
|
+
* Effectfully filters and maps elements of an iterable with a `FilterEffect`.
|
|
8269
8718
|
*
|
|
8270
|
-
*
|
|
8271
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
8272
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
8273
|
-
* )
|
|
8274
|
-
* ```
|
|
8275
|
-
*
|
|
8276
|
-
* @since 2.0.0
|
|
8719
|
+
* @since 4.0.0
|
|
8277
8720
|
* @category Filtering
|
|
8278
8721
|
*/
|
|
8279
|
-
<A, E, R>(
|
|
8280
|
-
|
|
8281
|
-
|
|
8722
|
+
<A, B, X, E, R>(
|
|
8723
|
+
elements: Iterable<A>,
|
|
8724
|
+
filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R>,
|
|
8282
8725
|
options?: { readonly concurrency?: Concurrency | undefined }
|
|
8283
|
-
): Effect<Array<
|
|
8284
|
-
} = internal.
|
|
8726
|
+
): Effect<Array<B>, E, R>
|
|
8727
|
+
} = internal.filterMapEffect
|
|
8285
8728
|
|
|
8286
8729
|
/**
|
|
8287
8730
|
* Filters an effect, providing an alternative effect if the predicate fails.
|
|
@@ -8378,10 +8821,10 @@ export const filterOrElse: {
|
|
|
8378
8821
|
* @since 2.0.0
|
|
8379
8822
|
* @category Filtering
|
|
8380
8823
|
*/
|
|
8381
|
-
<A,
|
|
8382
|
-
|
|
8383
|
-
orElse: (a:
|
|
8384
|
-
): <E, R>(self: Effect<A, E, R>) => Effect<
|
|
8824
|
+
<A, C, E2, R2>(
|
|
8825
|
+
predicate: Predicate.Predicate<NoInfer<A>>,
|
|
8826
|
+
orElse: (a: NoInfer<A>) => Effect<C, E2, R2>
|
|
8827
|
+
): <E, R>(self: Effect<A, E, R>) => Effect<A | C, E2 | E, R2 | R>
|
|
8385
8828
|
/**
|
|
8386
8829
|
* Filters an effect, providing an alternative effect if the predicate fails.
|
|
8387
8830
|
*
|
|
@@ -8447,13 +8890,43 @@ export const filterOrElse: {
|
|
|
8447
8890
|
* @since 2.0.0
|
|
8448
8891
|
* @category Filtering
|
|
8449
8892
|
*/
|
|
8450
|
-
<A, E, R,
|
|
8893
|
+
<A, E, R, C, E2, R2>(
|
|
8451
8894
|
self: Effect<A, E, R>,
|
|
8452
|
-
|
|
8453
|
-
orElse: (a:
|
|
8454
|
-
): Effect<
|
|
8895
|
+
predicate: Predicate.Predicate<NoInfer<A>>,
|
|
8896
|
+
orElse: (a: NoInfer<A>) => Effect<C, E2, R2>
|
|
8897
|
+
): Effect<A | C, E | E2, R | R2>
|
|
8455
8898
|
} = internal.filterOrElse
|
|
8456
8899
|
|
|
8900
|
+
/**
|
|
8901
|
+
* Filters an effect with a `Filter`, providing an alternative effect on failure.
|
|
8902
|
+
*
|
|
8903
|
+
* @since 4.0.0
|
|
8904
|
+
* @category Filtering
|
|
8905
|
+
*/
|
|
8906
|
+
export const filterMapOrElse: {
|
|
8907
|
+
/**
|
|
8908
|
+
* Filters an effect with a `Filter`, providing an alternative effect on failure.
|
|
8909
|
+
*
|
|
8910
|
+
* @since 4.0.0
|
|
8911
|
+
* @category Filtering
|
|
8912
|
+
*/
|
|
8913
|
+
<A, B, X, C, E2, R2>(
|
|
8914
|
+
filter: Filter.Filter<NoInfer<A>, B, X>,
|
|
8915
|
+
orElse: (x: X) => Effect<C, E2, R2>
|
|
8916
|
+
): <E, R>(self: Effect<A, E, R>) => Effect<B | C, E2 | E, R2 | R>
|
|
8917
|
+
/**
|
|
8918
|
+
* Filters an effect with a `Filter`, providing an alternative effect on failure.
|
|
8919
|
+
*
|
|
8920
|
+
* @since 4.0.0
|
|
8921
|
+
* @category Filtering
|
|
8922
|
+
*/
|
|
8923
|
+
<A, E, R, B, X, C, E2, R2>(
|
|
8924
|
+
self: Effect<A, E, R>,
|
|
8925
|
+
filter: Filter.Filter<NoInfer<A>, B, X>,
|
|
8926
|
+
orElse: (x: X) => Effect<C, E2, R2>
|
|
8927
|
+
): Effect<B | C, E | E2, R | R2>
|
|
8928
|
+
} = internal.filterMapOrElse
|
|
8929
|
+
|
|
8457
8930
|
/**
|
|
8458
8931
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8459
8932
|
*
|
|
@@ -8550,36 +9023,6 @@ export const filterOrFail: {
|
|
|
8550
9023
|
predicate: Predicate.Predicate<NoInfer<A>>,
|
|
8551
9024
|
orFailWith: (a: NoInfer<A>) => E2
|
|
8552
9025
|
): <E, R>(self: Effect<A, E, R>) => Effect<A, E2 | E, R>
|
|
8553
|
-
/**
|
|
8554
|
-
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8555
|
-
*
|
|
8556
|
-
* **Details**
|
|
8557
|
-
*
|
|
8558
|
-
* This function applies a predicate to the result of an effect. If the
|
|
8559
|
-
* predicate evaluates to `false`, the effect fails with either a custom
|
|
8560
|
-
* error (if `orFailWith` is provided) or a `NoSuchElementError`.
|
|
8561
|
-
*
|
|
8562
|
-
* @example
|
|
8563
|
-
* ```ts
|
|
8564
|
-
* import { Effect } from "effect"
|
|
8565
|
-
*
|
|
8566
|
-
* // An effect that produces a number
|
|
8567
|
-
* const program = Effect.succeed(5)
|
|
8568
|
-
*
|
|
8569
|
-
* // Filter for even numbers, fail for odd numbers
|
|
8570
|
-
* const filtered = Effect.filterOrFail(
|
|
8571
|
-
* program,
|
|
8572
|
-
* (n) => n % 2 === 0,
|
|
8573
|
-
* (n) => `Expected even number, got ${n}`
|
|
8574
|
-
* )
|
|
8575
|
-
*
|
|
8576
|
-
* // Result: Effect.fail("Expected even number, got 5")
|
|
8577
|
-
* ```
|
|
8578
|
-
*
|
|
8579
|
-
* @since 2.0.0
|
|
8580
|
-
* @category Filtering
|
|
8581
|
-
*/
|
|
8582
|
-
<A, B, X, E2>(filter: Filter.Filter<NoInfer<A>, B, X>, orFailWith: (x: X) => E2): <E, R>(self: Effect<A, E, R>) => Effect<B, E2 | E, R>
|
|
8583
9026
|
/**
|
|
8584
9027
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8585
9028
|
*
|
|
@@ -8640,36 +9083,6 @@ export const filterOrFail: {
|
|
|
8640
9083
|
* @category Filtering
|
|
8641
9084
|
*/
|
|
8642
9085
|
<A>(predicate: Predicate.Predicate<NoInfer<A>>): <E, R>(self: Effect<A, E, R>) => Effect<A, Cause.NoSuchElementError | E, R>
|
|
8643
|
-
/**
|
|
8644
|
-
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8645
|
-
*
|
|
8646
|
-
* **Details**
|
|
8647
|
-
*
|
|
8648
|
-
* This function applies a predicate to the result of an effect. If the
|
|
8649
|
-
* predicate evaluates to `false`, the effect fails with either a custom
|
|
8650
|
-
* error (if `orFailWith` is provided) or a `NoSuchElementError`.
|
|
8651
|
-
*
|
|
8652
|
-
* @example
|
|
8653
|
-
* ```ts
|
|
8654
|
-
* import { Effect } from "effect"
|
|
8655
|
-
*
|
|
8656
|
-
* // An effect that produces a number
|
|
8657
|
-
* const program = Effect.succeed(5)
|
|
8658
|
-
*
|
|
8659
|
-
* // Filter for even numbers, fail for odd numbers
|
|
8660
|
-
* const filtered = Effect.filterOrFail(
|
|
8661
|
-
* program,
|
|
8662
|
-
* (n) => n % 2 === 0,
|
|
8663
|
-
* (n) => `Expected even number, got ${n}`
|
|
8664
|
-
* )
|
|
8665
|
-
*
|
|
8666
|
-
* // Result: Effect.fail("Expected even number, got 5")
|
|
8667
|
-
* ```
|
|
8668
|
-
*
|
|
8669
|
-
* @since 2.0.0
|
|
8670
|
-
* @category Filtering
|
|
8671
|
-
*/
|
|
8672
|
-
<A, B, X>(filter: Filter.Filter<NoInfer<A>, B, X>): <E, R>(self: Effect<A, E, R>) => Effect<B, Cause.NoSuchElementError | E, R>
|
|
8673
9086
|
/**
|
|
8674
9087
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8675
9088
|
*
|
|
@@ -8767,11 +9180,7 @@ export const filterOrFail: {
|
|
|
8767
9180
|
* @since 2.0.0
|
|
8768
9181
|
* @category Filtering
|
|
8769
9182
|
*/
|
|
8770
|
-
<A, E, R, B,
|
|
8771
|
-
self: Effect<A, E, R>,
|
|
8772
|
-
filter: Filter.Filter<A, B, X>,
|
|
8773
|
-
orFailWith: (x: X) => E2
|
|
8774
|
-
): Effect<B, E2 | E, R>
|
|
9183
|
+
<A, E, R, B extends A>(self: Effect<A, E, R>, refinement: Predicate.Refinement<NoInfer<A>, B>): Effect<B, E | Cause.NoSuchElementError, R>
|
|
8775
9184
|
/**
|
|
8776
9185
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8777
9186
|
*
|
|
@@ -8801,68 +9210,49 @@ export const filterOrFail: {
|
|
|
8801
9210
|
* @since 2.0.0
|
|
8802
9211
|
* @category Filtering
|
|
8803
9212
|
*/
|
|
8804
|
-
<A, E, R
|
|
9213
|
+
<A, E, R>(self: Effect<A, E, R>, predicate: Predicate.Predicate<NoInfer<A>>): Effect<A, E | Cause.NoSuchElementError, R>
|
|
9214
|
+
} = internal.filterOrFail
|
|
9215
|
+
|
|
9216
|
+
/**
|
|
9217
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
9218
|
+
*
|
|
9219
|
+
* @since 4.0.0
|
|
9220
|
+
* @category Filtering
|
|
9221
|
+
*/
|
|
9222
|
+
export const filterMapOrFail: {
|
|
8805
9223
|
/**
|
|
8806
|
-
* Filters an effect
|
|
8807
|
-
*
|
|
8808
|
-
* **Details**
|
|
8809
|
-
*
|
|
8810
|
-
* This function applies a predicate to the result of an effect. If the
|
|
8811
|
-
* predicate evaluates to `false`, the effect fails with either a custom
|
|
8812
|
-
* error (if `orFailWith` is provided) or a `NoSuchElementError`.
|
|
8813
|
-
*
|
|
8814
|
-
* @example
|
|
8815
|
-
* ```ts
|
|
8816
|
-
* import { Effect } from "effect"
|
|
8817
|
-
*
|
|
8818
|
-
* // An effect that produces a number
|
|
8819
|
-
* const program = Effect.succeed(5)
|
|
8820
|
-
*
|
|
8821
|
-
* // Filter for even numbers, fail for odd numbers
|
|
8822
|
-
* const filtered = Effect.filterOrFail(
|
|
8823
|
-
* program,
|
|
8824
|
-
* (n) => n % 2 === 0,
|
|
8825
|
-
* (n) => `Expected even number, got ${n}`
|
|
8826
|
-
* )
|
|
8827
|
-
*
|
|
8828
|
-
* // Result: Effect.fail("Expected even number, got 5")
|
|
8829
|
-
* ```
|
|
9224
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
8830
9225
|
*
|
|
8831
|
-
* @since
|
|
9226
|
+
* @since 4.0.0
|
|
8832
9227
|
* @category Filtering
|
|
8833
9228
|
*/
|
|
8834
|
-
<A,
|
|
9229
|
+
<A, B, X, E2>(filter: Filter.Filter<NoInfer<A>, B, X>, orFailWith: (x: X) => E2): <E, R>(self: Effect<A, E, R>) => Effect<B, E2 | E, R>
|
|
8835
9230
|
/**
|
|
8836
|
-
* Filters an effect
|
|
8837
|
-
*
|
|
8838
|
-
* **Details**
|
|
8839
|
-
*
|
|
8840
|
-
* This function applies a predicate to the result of an effect. If the
|
|
8841
|
-
* predicate evaluates to `false`, the effect fails with either a custom
|
|
8842
|
-
* error (if `orFailWith` is provided) or a `NoSuchElementError`.
|
|
8843
|
-
*
|
|
8844
|
-
* @example
|
|
8845
|
-
* ```ts
|
|
8846
|
-
* import { Effect } from "effect"
|
|
8847
|
-
*
|
|
8848
|
-
* // An effect that produces a number
|
|
8849
|
-
* const program = Effect.succeed(5)
|
|
9231
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
8850
9232
|
*
|
|
8851
|
-
*
|
|
8852
|
-
*
|
|
8853
|
-
|
|
8854
|
-
|
|
8855
|
-
|
|
8856
|
-
*
|
|
9233
|
+
* @since 4.0.0
|
|
9234
|
+
* @category Filtering
|
|
9235
|
+
*/
|
|
9236
|
+
<A, B, X>(filter: Filter.Filter<NoInfer<A>, B, X>): <E, R>(self: Effect<A, E, R>) => Effect<B, Cause.NoSuchElementError | E, R>
|
|
9237
|
+
/**
|
|
9238
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
8857
9239
|
*
|
|
8858
|
-
*
|
|
8859
|
-
*
|
|
9240
|
+
* @since 4.0.0
|
|
9241
|
+
* @category Filtering
|
|
9242
|
+
*/
|
|
9243
|
+
<A, E, R, B, X, E2>(
|
|
9244
|
+
self: Effect<A, E, R>,
|
|
9245
|
+
filter: Filter.Filter<A, B, X>,
|
|
9246
|
+
orFailWith: (x: X) => E2
|
|
9247
|
+
): Effect<B, E2 | E, R>
|
|
9248
|
+
/**
|
|
9249
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
8860
9250
|
*
|
|
8861
|
-
* @since
|
|
9251
|
+
* @since 4.0.0
|
|
8862
9252
|
* @category Filtering
|
|
8863
9253
|
*/
|
|
8864
|
-
<A, E, R, B, X>(self: Effect<A, E, R>, filter: Filter.Filter<A, B, X>): Effect<B,
|
|
8865
|
-
} = internal.
|
|
9254
|
+
<A, E, R, B, X>(self: Effect<A, E, R>, filter: Filter.Filter<A, B, X>): Effect<B, Cause.NoSuchElementError | E, R>
|
|
9255
|
+
} = internal.filterMapOrFail
|
|
8866
9256
|
|
|
8867
9257
|
// -----------------------------------------------------------------------------
|
|
8868
9258
|
// Conditional Operators
|
|
@@ -10496,7 +10886,7 @@ export const provideServices: {
|
|
|
10496
10886
|
* @since 4.0.0
|
|
10497
10887
|
* @category ServiceMap
|
|
10498
10888
|
*/
|
|
10499
|
-
export const service: <I, S>(service: ServiceMap.
|
|
10889
|
+
export const service: <I, S>(service: ServiceMap.Key<I, S>) => Effect<S, never, I> = internal.service
|
|
10500
10890
|
|
|
10501
10891
|
/**
|
|
10502
10892
|
* Optionally accesses a service from the environment.
|
|
@@ -10532,7 +10922,7 @@ export const service: <I, S>(service: ServiceMap.Service<I, S>) => Effect<S, nev
|
|
|
10532
10922
|
* @since 2.0.0
|
|
10533
10923
|
* @category ServiceMap
|
|
10534
10924
|
*/
|
|
10535
|
-
export const serviceOption: <I, S>(key: ServiceMap.
|
|
10925
|
+
export const serviceOption: <I, S>(key: ServiceMap.Key<I, S>) => Effect<Option<S>> = internal.serviceOption
|
|
10536
10926
|
|
|
10537
10927
|
/**
|
|
10538
10928
|
* Provides part of the required context while leaving the rest unchanged.
|
|
@@ -10721,7 +11111,7 @@ export const updateService: {
|
|
|
10721
11111
|
* @since 2.0.0
|
|
10722
11112
|
* @category ServiceMap
|
|
10723
11113
|
*/
|
|
10724
|
-
<I, A>(service: ServiceMap.
|
|
11114
|
+
<I, A>(service: ServiceMap.Key<I, A>, f: (value: A) => A): <XA, E, R>(self: Effect<XA, E, R>) => Effect<XA, E, R | I>
|
|
10725
11115
|
/**
|
|
10726
11116
|
* Updates the service with the required service entry.
|
|
10727
11117
|
*
|
|
@@ -10750,11 +11140,7 @@ export const updateService: {
|
|
|
10750
11140
|
* @since 2.0.0
|
|
10751
11141
|
* @category ServiceMap
|
|
10752
11142
|
*/
|
|
10753
|
-
<XA, E, R, I, A>(
|
|
10754
|
-
self: Effect<XA, E, R>,
|
|
10755
|
-
service: ServiceMap.Service<I, A>,
|
|
10756
|
-
f: (value: A) => A
|
|
10757
|
-
): Effect<XA, E, R | I>
|
|
11143
|
+
<XA, E, R, I, A>(self: Effect<XA, E, R>, service: ServiceMap.Key<I, A>, f: (value: A) => A): Effect<XA, E, R | I>
|
|
10758
11144
|
} = internal.updateService
|
|
10759
11145
|
|
|
10760
11146
|
/**
|
|
@@ -10848,7 +11234,7 @@ export const provideService: {
|
|
|
10848
11234
|
* @since 2.0.0
|
|
10849
11235
|
* @category ServiceMap
|
|
10850
11236
|
*/
|
|
10851
|
-
<I, S>(service: ServiceMap.
|
|
11237
|
+
<I, S>(service: ServiceMap.Key<I, S>): {
|
|
10852
11238
|
/**
|
|
10853
11239
|
* The `provideService` function is used to provide an actual
|
|
10854
11240
|
* implementation for a service in the context of an effect.
|
|
@@ -10987,7 +11373,7 @@ export const provideService: {
|
|
|
10987
11373
|
* @since 2.0.0
|
|
10988
11374
|
* @category ServiceMap
|
|
10989
11375
|
*/
|
|
10990
|
-
<I, S>(service: ServiceMap.
|
|
11376
|
+
<I, S>(service: ServiceMap.Key<I, S>, implementation: S): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, Exclude<R, I>>
|
|
10991
11377
|
/**
|
|
10992
11378
|
* The `provideService` function is used to provide an actual
|
|
10993
11379
|
* implementation for a service in the context of an effect.
|
|
@@ -11033,11 +11419,7 @@ export const provideService: {
|
|
|
11033
11419
|
* @since 2.0.0
|
|
11034
11420
|
* @category ServiceMap
|
|
11035
11421
|
*/
|
|
11036
|
-
<A, E, R, I, S>(
|
|
11037
|
-
self: Effect<A, E, R>,
|
|
11038
|
-
service: ServiceMap.Service<I, S>,
|
|
11039
|
-
implementation: S
|
|
11040
|
-
): Effect<A, E, Exclude<R, I>>
|
|
11422
|
+
<A, E, R, I, S>(self: Effect<A, E, R>, service: ServiceMap.Key<I, S>, implementation: S): Effect<A, E, Exclude<R, I>>
|
|
11041
11423
|
} = internal.provideService
|
|
11042
11424
|
|
|
11043
11425
|
/**
|
|
@@ -11145,7 +11527,7 @@ export const provideServiceEffect: {
|
|
|
11145
11527
|
* @since 2.0.0
|
|
11146
11528
|
* @category ServiceMap
|
|
11147
11529
|
*/
|
|
11148
|
-
<I, S, E2, R2>(service: ServiceMap.
|
|
11530
|
+
<I, S, E2, R2>(service: ServiceMap.Key<I, S>, acquire: Effect<S, E2, R2>): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E | E2, Exclude<R, I> | R2>
|
|
11149
11531
|
/**
|
|
11150
11532
|
* Provides the effect with the single service it requires. If the effect
|
|
11151
11533
|
* requires more than one service use `provide` instead.
|
|
@@ -11200,7 +11582,7 @@ export const provideServiceEffect: {
|
|
|
11200
11582
|
*/
|
|
11201
11583
|
<A, E, R, I, S, E2, R2>(
|
|
11202
11584
|
self: Effect<A, E, R>,
|
|
11203
|
-
service: ServiceMap.
|
|
11585
|
+
service: ServiceMap.Key<I, S>,
|
|
11204
11586
|
acquire: Effect<S, E2, R2>
|
|
11205
11587
|
): Effect<A, E | E2, Exclude<R, I> | R2>
|
|
11206
11588
|
} = internal.provideServiceEffect
|
|
@@ -11813,7 +12195,7 @@ export const onError: {
|
|
|
11813
12195
|
|
|
11814
12196
|
/**
|
|
11815
12197
|
* Runs the finalizer only when this effect fails and the `Cause` matches the
|
|
11816
|
-
*
|
|
12198
|
+
* provided predicate.
|
|
11817
12199
|
*
|
|
11818
12200
|
* @example
|
|
11819
12201
|
* ```ts
|
|
@@ -11837,7 +12219,7 @@ export const onError: {
|
|
|
11837
12219
|
export const onErrorIf: {
|
|
11838
12220
|
/**
|
|
11839
12221
|
* Runs the finalizer only when this effect fails and the `Cause` matches the
|
|
11840
|
-
*
|
|
12222
|
+
* provided predicate.
|
|
11841
12223
|
*
|
|
11842
12224
|
* @example
|
|
11843
12225
|
* ```ts
|
|
@@ -11858,13 +12240,13 @@ export const onErrorIf: {
|
|
|
11858
12240
|
* @since 4.0.0
|
|
11859
12241
|
* @category Resource Management & Finalization
|
|
11860
12242
|
*/
|
|
11861
|
-
<E,
|
|
11862
|
-
|
|
11863
|
-
f: (
|
|
12243
|
+
<E, XE, XR>(
|
|
12244
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
12245
|
+
f: (cause: Cause.Cause<E>) => Effect<void, XE, XR>
|
|
11864
12246
|
): <A, R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>
|
|
11865
12247
|
/**
|
|
11866
12248
|
* Runs the finalizer only when this effect fails and the `Cause` matches the
|
|
11867
|
-
*
|
|
12249
|
+
* provided predicate.
|
|
11868
12250
|
*
|
|
11869
12251
|
* @example
|
|
11870
12252
|
* ```ts
|
|
@@ -11885,13 +12267,43 @@ export const onErrorIf: {
|
|
|
11885
12267
|
* @since 4.0.0
|
|
11886
12268
|
* @category Resource Management & Finalization
|
|
11887
12269
|
*/
|
|
11888
|
-
<A, E, R, XE, XR
|
|
12270
|
+
<A, E, R, XE, XR>(
|
|
11889
12271
|
self: Effect<A, E, R>,
|
|
11890
|
-
|
|
11891
|
-
f: (
|
|
12272
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
12273
|
+
f: (cause: Cause.Cause<E>) => Effect<void, XE, XR>
|
|
11892
12274
|
): Effect<A, E | XE, R | XR>
|
|
11893
12275
|
} = internal.onErrorIf
|
|
11894
12276
|
|
|
12277
|
+
/**
|
|
12278
|
+
* Runs the finalizer only when this effect fails and the cause matches the provided `Filter`.
|
|
12279
|
+
*
|
|
12280
|
+
* @since 4.0.0
|
|
12281
|
+
* @category Resource Management & Finalization
|
|
12282
|
+
*/
|
|
12283
|
+
export const onErrorFilter: {
|
|
12284
|
+
/**
|
|
12285
|
+
* Runs the finalizer only when this effect fails and the cause matches the provided `Filter`.
|
|
12286
|
+
*
|
|
12287
|
+
* @since 4.0.0
|
|
12288
|
+
* @category Resource Management & Finalization
|
|
12289
|
+
*/
|
|
12290
|
+
<A, E, EB, X, XE, XR>(
|
|
12291
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
12292
|
+
f: (failure: EB, cause: Cause.Cause<E>) => Effect<void, XE, XR>
|
|
12293
|
+
): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>
|
|
12294
|
+
/**
|
|
12295
|
+
* Runs the finalizer only when this effect fails and the cause matches the provided `Filter`.
|
|
12296
|
+
*
|
|
12297
|
+
* @since 4.0.0
|
|
12298
|
+
* @category Resource Management & Finalization
|
|
12299
|
+
*/
|
|
12300
|
+
<A, E, R, EB, X, XE, XR>(
|
|
12301
|
+
self: Effect<A, E, R>,
|
|
12302
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
12303
|
+
f: (failure: EB, cause: Cause.Cause<E>) => Effect<void, XE, XR>
|
|
12304
|
+
): Effect<A, E | XE, R | XR>
|
|
12305
|
+
} = internal.onErrorFilter
|
|
12306
|
+
|
|
11895
12307
|
/**
|
|
11896
12308
|
* The low level primitive that powers `onExit`.
|
|
11897
12309
|
* function is used to run a finalizer when the effect exits, regardless of the
|
|
@@ -11990,20 +12402,20 @@ export const onExit: {
|
|
|
11990
12402
|
} = internal.onExit
|
|
11991
12403
|
|
|
11992
12404
|
/**
|
|
11993
|
-
* Runs the cleanup effect only when the `Exit`
|
|
11994
|
-
*
|
|
11995
|
-
* The cleanup is skipped when the filter returns `Filter.fail`.
|
|
12405
|
+
* Runs the cleanup effect only when the `Exit` satisfies the provided
|
|
12406
|
+
* predicate.
|
|
11996
12407
|
*
|
|
11997
12408
|
* @example
|
|
11998
12409
|
* ```ts
|
|
11999
|
-
* import { Console, Effect, Exit
|
|
12000
|
-
*
|
|
12001
|
-
* const exitFilter = Filter.fromPredicate(Exit.isSuccess<number, never>)
|
|
12410
|
+
* import { Console, Effect, Exit } from "effect"
|
|
12002
12411
|
*
|
|
12003
12412
|
* const program = Effect.onExitIf(
|
|
12004
12413
|
* Effect.succeed(42),
|
|
12005
|
-
*
|
|
12006
|
-
* (
|
|
12414
|
+
* Exit.isSuccess,
|
|
12415
|
+
* (exit) =>
|
|
12416
|
+
* Exit.isSuccess(exit)
|
|
12417
|
+
* ? Console.log(`Succeeded with: ${exit.value}`)
|
|
12418
|
+
* : Effect.void
|
|
12007
12419
|
* )
|
|
12008
12420
|
* ```
|
|
12009
12421
|
*
|
|
@@ -12012,63 +12424,87 @@ export const onExit: {
|
|
|
12012
12424
|
*/
|
|
12013
12425
|
export const onExitIf: {
|
|
12014
12426
|
/**
|
|
12015
|
-
* Runs the cleanup effect only when the `Exit`
|
|
12016
|
-
*
|
|
12017
|
-
* The cleanup is skipped when the filter returns `Filter.fail`.
|
|
12427
|
+
* Runs the cleanup effect only when the `Exit` satisfies the provided
|
|
12428
|
+
* predicate.
|
|
12018
12429
|
*
|
|
12019
12430
|
* @example
|
|
12020
12431
|
* ```ts
|
|
12021
|
-
* import { Console, Effect, Exit
|
|
12022
|
-
*
|
|
12023
|
-
* const exitFilter = Filter.fromPredicate(Exit.isSuccess<number, never>)
|
|
12432
|
+
* import { Console, Effect, Exit } from "effect"
|
|
12024
12433
|
*
|
|
12025
12434
|
* const program = Effect.onExitIf(
|
|
12026
12435
|
* Effect.succeed(42),
|
|
12027
|
-
*
|
|
12028
|
-
* (
|
|
12436
|
+
* Exit.isSuccess,
|
|
12437
|
+
* (exit) =>
|
|
12438
|
+
* Exit.isSuccess(exit)
|
|
12439
|
+
* ? Console.log(`Succeeded with: ${exit.value}`)
|
|
12440
|
+
* : Effect.void
|
|
12029
12441
|
* )
|
|
12030
12442
|
* ```
|
|
12031
12443
|
*
|
|
12032
12444
|
* @since 4.0.0
|
|
12033
12445
|
* @category Resource Management & Finalization
|
|
12034
12446
|
*/
|
|
12035
|
-
<A, E, XE, XR
|
|
12036
|
-
|
|
12037
|
-
f: (
|
|
12038
|
-
pass: Filter.Pass<Exit.Exit<NoInfer<A>, NoInfer<E>>, Result>,
|
|
12039
|
-
exit: Exit.Exit<NoInfer<A>, NoInfer<E>>
|
|
12040
|
-
) => Effect<void, XE, XR>
|
|
12447
|
+
<A, E, XE, XR>(
|
|
12448
|
+
predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>,
|
|
12449
|
+
f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>
|
|
12041
12450
|
): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>
|
|
12042
12451
|
/**
|
|
12043
|
-
* Runs the cleanup effect only when the `Exit`
|
|
12044
|
-
*
|
|
12045
|
-
* The cleanup is skipped when the filter returns `Filter.fail`.
|
|
12452
|
+
* Runs the cleanup effect only when the `Exit` satisfies the provided
|
|
12453
|
+
* predicate.
|
|
12046
12454
|
*
|
|
12047
12455
|
* @example
|
|
12048
12456
|
* ```ts
|
|
12049
|
-
* import { Console, Effect, Exit
|
|
12050
|
-
*
|
|
12051
|
-
* const exitFilter = Filter.fromPredicate(Exit.isSuccess<number, never>)
|
|
12457
|
+
* import { Console, Effect, Exit } from "effect"
|
|
12052
12458
|
*
|
|
12053
12459
|
* const program = Effect.onExitIf(
|
|
12054
12460
|
* Effect.succeed(42),
|
|
12055
|
-
*
|
|
12056
|
-
* (
|
|
12461
|
+
* Exit.isSuccess,
|
|
12462
|
+
* (exit) =>
|
|
12463
|
+
* Exit.isSuccess(exit)
|
|
12464
|
+
* ? Console.log(`Succeeded with: ${exit.value}`)
|
|
12465
|
+
* : Effect.void
|
|
12057
12466
|
* )
|
|
12058
12467
|
* ```
|
|
12059
12468
|
*
|
|
12060
12469
|
* @since 4.0.0
|
|
12061
12470
|
* @category Resource Management & Finalization
|
|
12062
12471
|
*/
|
|
12063
|
-
<A, E, R, XE, XR
|
|
12472
|
+
<A, E, R, XE, XR>(
|
|
12473
|
+
self: Effect<A, E, R>,
|
|
12474
|
+
predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>,
|
|
12475
|
+
f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>
|
|
12476
|
+
): Effect<A, E | XE, R | XR>
|
|
12477
|
+
} = internal.onExitIf
|
|
12478
|
+
|
|
12479
|
+
/**
|
|
12480
|
+
* Runs the cleanup effect only when the `Exit` matches the provided `Filter`.
|
|
12481
|
+
*
|
|
12482
|
+
* @since 4.0.0
|
|
12483
|
+
* @category Resource Management & Finalization
|
|
12484
|
+
*/
|
|
12485
|
+
export const onExitFilter: {
|
|
12486
|
+
/**
|
|
12487
|
+
* Runs the cleanup effect only when the `Exit` matches the provided `Filter`.
|
|
12488
|
+
*
|
|
12489
|
+
* @since 4.0.0
|
|
12490
|
+
* @category Resource Management & Finalization
|
|
12491
|
+
*/
|
|
12492
|
+
<A, E, XE, XR, B, X>(
|
|
12493
|
+
filter: Filter.Filter<Exit.Exit<NoInfer<A>, NoInfer<E>>, B, X>,
|
|
12494
|
+
f: (b: B, exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>
|
|
12495
|
+
): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>
|
|
12496
|
+
/**
|
|
12497
|
+
* Runs the cleanup effect only when the `Exit` matches the provided `Filter`.
|
|
12498
|
+
*
|
|
12499
|
+
* @since 4.0.0
|
|
12500
|
+
* @category Resource Management & Finalization
|
|
12501
|
+
*/
|
|
12502
|
+
<A, E, R, XE, XR, B, X>(
|
|
12064
12503
|
self: Effect<A, E, R>,
|
|
12065
|
-
filter: Filter.
|
|
12066
|
-
f: (
|
|
12067
|
-
pass: Filter.Pass<Exit.Exit<NoInfer<A>, NoInfer<E>>, Result>,
|
|
12068
|
-
exit: Exit.Exit<NoInfer<A>, NoInfer<E>>
|
|
12069
|
-
) => Effect<void, XE, XR>
|
|
12504
|
+
filter: Filter.Filter<Exit.Exit<NoInfer<A>, NoInfer<E>>, B, X>,
|
|
12505
|
+
f: (b: B, exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>
|
|
12070
12506
|
): Effect<A, E | XE, R | XR>
|
|
12071
|
-
} = internal.
|
|
12507
|
+
} = internal.onExitFilter
|
|
12072
12508
|
|
|
12073
12509
|
// -----------------------------------------------------------------------------
|
|
12074
12510
|
// Caching
|
|
@@ -12272,7 +12708,7 @@ export const cachedWithTTL: {
|
|
|
12272
12708
|
* @since 2.0.0
|
|
12273
12709
|
* @category Caching
|
|
12274
12710
|
*/
|
|
12275
|
-
(timeToLive: Duration.
|
|
12711
|
+
(timeToLive: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<Effect<A, E, R>>
|
|
12276
12712
|
/**
|
|
12277
12713
|
* Returns an effect that caches its result for a specified `Duration`,
|
|
12278
12714
|
* known as "timeToLive" (TTL).
|
|
@@ -12339,7 +12775,7 @@ export const cachedWithTTL: {
|
|
|
12339
12775
|
* @since 2.0.0
|
|
12340
12776
|
* @category Caching
|
|
12341
12777
|
*/
|
|
12342
|
-
<A, E, R>(self: Effect<A, E, R>, timeToLive: Duration.
|
|
12778
|
+
<A, E, R>(self: Effect<A, E, R>, timeToLive: Duration.Input): Effect<Effect<A, E, R>>
|
|
12343
12779
|
} = internal.cachedWithTTL
|
|
12344
12780
|
|
|
12345
12781
|
/**
|
|
@@ -12481,7 +12917,7 @@ export const cachedInvalidateWithTTL: {
|
|
|
12481
12917
|
* @since 2.0.0
|
|
12482
12918
|
* @category Caching
|
|
12483
12919
|
*/
|
|
12484
|
-
(timeToLive: Duration.
|
|
12920
|
+
(timeToLive: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<[Effect<A, E, R>, Effect<void>]>
|
|
12485
12921
|
/**
|
|
12486
12922
|
* Caches an effect's result for a specified duration and allows manual
|
|
12487
12923
|
* invalidation before expiration.
|
|
@@ -12551,7 +12987,7 @@ export const cachedInvalidateWithTTL: {
|
|
|
12551
12987
|
* @since 2.0.0
|
|
12552
12988
|
* @category Caching
|
|
12553
12989
|
*/
|
|
12554
|
-
<A, E, R>(self: Effect<A, E, R>, timeToLive: Duration.
|
|
12990
|
+
<A, E, R>(self: Effect<A, E, R>, timeToLive: Duration.Input): Effect<[Effect<A, E, R>, Effect<void>]>
|
|
12555
12991
|
} = internal.cachedInvalidateWithTTL
|
|
12556
12992
|
|
|
12557
12993
|
// -----------------------------------------------------------------------------
|
|
@@ -12777,252 +13213,6 @@ export const interruptibleMask: <A, E, R>(
|
|
|
12777
13213
|
) => Effect<A, E, R>
|
|
12778
13214
|
) => Effect<A, E, R> = internal.interruptibleMask
|
|
12779
13215
|
|
|
12780
|
-
// -----------------------------------------------------------------------------
|
|
12781
|
-
// Semaphore
|
|
12782
|
-
// -----------------------------------------------------------------------------
|
|
12783
|
-
|
|
12784
|
-
/**
|
|
12785
|
-
* @category Semaphore
|
|
12786
|
-
* @since 2.0.0
|
|
12787
|
-
* @example
|
|
12788
|
-
* ```ts
|
|
12789
|
-
* import { Effect } from "effect"
|
|
12790
|
-
*
|
|
12791
|
-
* // Create and use a semaphore for controlling concurrent access
|
|
12792
|
-
* const program = Effect.gen(function*() {
|
|
12793
|
-
* const semaphore = yield* Effect.makeSemaphore(2)
|
|
12794
|
-
*
|
|
12795
|
-
* return yield* semaphore.withPermits(1)(
|
|
12796
|
-
* Effect.succeed("Resource accessed")
|
|
12797
|
-
* )
|
|
12798
|
-
* })
|
|
12799
|
-
* ```
|
|
12800
|
-
*/
|
|
12801
|
-
export interface Semaphore {
|
|
12802
|
-
/**
|
|
12803
|
-
* Adjusts the number of permits available in the semaphore.
|
|
12804
|
-
*/
|
|
12805
|
-
resize(permits: number): Effect<void>
|
|
12806
|
-
|
|
12807
|
-
/**
|
|
12808
|
-
* Runs an effect with the given number of permits and releases the permits
|
|
12809
|
-
* when the effect completes.
|
|
12810
|
-
*
|
|
12811
|
-
* **Details**
|
|
12812
|
-
*
|
|
12813
|
-
* This function acquires the specified number of permits before executing
|
|
12814
|
-
* the provided effect. Once the effect finishes, the permits are released.
|
|
12815
|
-
* If insufficient permits are available, the function will wait until they
|
|
12816
|
-
* are released by other tasks.
|
|
12817
|
-
*/
|
|
12818
|
-
withPermits(permits: number): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, R>
|
|
12819
|
-
|
|
12820
|
-
/**
|
|
12821
|
-
* Runs an effect with the given number of permits and releases the permits
|
|
12822
|
-
* when the effect completes.
|
|
12823
|
-
*
|
|
12824
|
-
* **Details**
|
|
12825
|
-
*
|
|
12826
|
-
* This function acquires the specified number of permits before executing
|
|
12827
|
-
* the provided effect. Once the effect finishes, the permits are released.
|
|
12828
|
-
* If insufficient permits are available, the function will wait until they
|
|
12829
|
-
* are released by other tasks.
|
|
12830
|
-
*/
|
|
12831
|
-
withPermit<A, E, R>(self: Effect<A, E, R>): Effect<A, E, R>
|
|
12832
|
-
|
|
12833
|
-
/**
|
|
12834
|
-
* Runs an effect only if the specified number of permits are immediately
|
|
12835
|
-
* available.
|
|
12836
|
-
*
|
|
12837
|
-
* **Details**
|
|
12838
|
-
*
|
|
12839
|
-
* This function attempts to acquire the specified number of permits. If they
|
|
12840
|
-
* are available, it runs the effect and releases the permits after the effect
|
|
12841
|
-
* completes. If permits are not available, the effect does not execute, and
|
|
12842
|
-
* the result is `Option.none`.
|
|
12843
|
-
*/
|
|
12844
|
-
withPermitsIfAvailable(permits: number): <A, E, R>(self: Effect<A, E, R>) => Effect<Option<A>, E, R>
|
|
12845
|
-
|
|
12846
|
-
/**
|
|
12847
|
-
* Acquires the specified number of permits and returns the resulting
|
|
12848
|
-
* available permits, suspending the task if they are not yet available.
|
|
12849
|
-
* Concurrent pending `take` calls are processed in a first-in, first-out manner.
|
|
12850
|
-
*/
|
|
12851
|
-
take(permits: number): Effect<number>
|
|
12852
|
-
|
|
12853
|
-
/**
|
|
12854
|
-
* Releases the specified number of permits and returns the resulting
|
|
12855
|
-
* available permits.
|
|
12856
|
-
*/
|
|
12857
|
-
release(permits: number): Effect<number>
|
|
12858
|
-
|
|
12859
|
-
/**
|
|
12860
|
-
* Releases all permits held by this semaphore and returns the resulting available permits.
|
|
12861
|
-
*/
|
|
12862
|
-
releaseAll: Effect<number>
|
|
12863
|
-
}
|
|
12864
|
-
|
|
12865
|
-
/**
|
|
12866
|
-
* Unsafely creates a new Semaphore.
|
|
12867
|
-
*
|
|
12868
|
-
* @example
|
|
12869
|
-
* ```ts
|
|
12870
|
-
* import { Effect } from "effect"
|
|
12871
|
-
*
|
|
12872
|
-
* const semaphore = Effect.makeSemaphoreUnsafe(3)
|
|
12873
|
-
*
|
|
12874
|
-
* const task = (id: number) =>
|
|
12875
|
-
* semaphore.withPermits(1)(
|
|
12876
|
-
* Effect.gen(function*() {
|
|
12877
|
-
* yield* Effect.log(`Task ${id} started`)
|
|
12878
|
-
* yield* Effect.sleep("1 second")
|
|
12879
|
-
* yield* Effect.log(`Task ${id} completed`)
|
|
12880
|
-
* })
|
|
12881
|
-
* )
|
|
12882
|
-
*
|
|
12883
|
-
* // Only 3 tasks can run concurrently
|
|
12884
|
-
* const program = Effect.all([
|
|
12885
|
-
* task(1),
|
|
12886
|
-
* task(2),
|
|
12887
|
-
* task(3),
|
|
12888
|
-
* task(4),
|
|
12889
|
-
* task(5)
|
|
12890
|
-
* ], { concurrency: "unbounded" })
|
|
12891
|
-
* ```
|
|
12892
|
-
*
|
|
12893
|
-
* @since 2.0.0
|
|
12894
|
-
* @category Semaphore
|
|
12895
|
-
*/
|
|
12896
|
-
export const makeSemaphoreUnsafe: (permits: number) => Semaphore = internal.makeSemaphoreUnsafe
|
|
12897
|
-
|
|
12898
|
-
/**
|
|
12899
|
-
* Creates a new Semaphore.
|
|
12900
|
-
*
|
|
12901
|
-
* @example
|
|
12902
|
-
* ```ts
|
|
12903
|
-
* import { Effect } from "effect"
|
|
12904
|
-
*
|
|
12905
|
-
* const program = Effect.gen(function*() {
|
|
12906
|
-
* const semaphore = yield* Effect.makeSemaphore(2)
|
|
12907
|
-
*
|
|
12908
|
-
* const task = (id: number) =>
|
|
12909
|
-
* semaphore.withPermits(1)(
|
|
12910
|
-
* Effect.gen(function*() {
|
|
12911
|
-
* yield* Effect.log(`Task ${id} acquired permit`)
|
|
12912
|
-
* yield* Effect.sleep("1 second")
|
|
12913
|
-
* yield* Effect.log(`Task ${id} releasing permit`)
|
|
12914
|
-
* })
|
|
12915
|
-
* )
|
|
12916
|
-
*
|
|
12917
|
-
* // Run 4 tasks, but only 2 can run concurrently
|
|
12918
|
-
* yield* Effect.all([task(1), task(2), task(3), task(4)])
|
|
12919
|
-
* })
|
|
12920
|
-
* ```
|
|
12921
|
-
*
|
|
12922
|
-
* @since 2.0.0
|
|
12923
|
-
* @category Semaphore
|
|
12924
|
-
*/
|
|
12925
|
-
export const makeSemaphore: (permits: number) => Effect<Semaphore> = internal.makeSemaphore
|
|
12926
|
-
|
|
12927
|
-
// -----------------------------------------------------------------------------
|
|
12928
|
-
// Latch
|
|
12929
|
-
// -----------------------------------------------------------------------------
|
|
12930
|
-
|
|
12931
|
-
/**
|
|
12932
|
-
* @category Latch
|
|
12933
|
-
* @since 3.8.0
|
|
12934
|
-
* @example
|
|
12935
|
-
* ```ts
|
|
12936
|
-
* import { Effect } from "effect"
|
|
12937
|
-
*
|
|
12938
|
-
* // Create and use a latch for coordination between fibers
|
|
12939
|
-
* const program = Effect.gen(function*() {
|
|
12940
|
-
* const latch = yield* Effect.makeLatch()
|
|
12941
|
-
*
|
|
12942
|
-
* // Wait for the latch to be opened
|
|
12943
|
-
* yield* latch.await
|
|
12944
|
-
*
|
|
12945
|
-
* return "Latch was opened!"
|
|
12946
|
-
* })
|
|
12947
|
-
* ```
|
|
12948
|
-
*/
|
|
12949
|
-
export interface Latch {
|
|
12950
|
-
/** open the latch, releasing all fibers waiting on it */
|
|
12951
|
-
readonly open: Effect<boolean>
|
|
12952
|
-
/** open the latch, releasing all fibers waiting on it */
|
|
12953
|
-
readonly openUnsafe: () => boolean
|
|
12954
|
-
/** release all fibers waiting on the latch, without opening it */
|
|
12955
|
-
readonly release: Effect<boolean>
|
|
12956
|
-
/** wait for the latch to be opened */
|
|
12957
|
-
readonly await: Effect<void>
|
|
12958
|
-
/** close the latch */
|
|
12959
|
-
readonly close: Effect<boolean>
|
|
12960
|
-
/** close the latch */
|
|
12961
|
-
readonly closeUnsafe: () => boolean
|
|
12962
|
-
/** only run the given effect when the latch is open */
|
|
12963
|
-
readonly whenOpen: <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, R>
|
|
12964
|
-
}
|
|
12965
|
-
|
|
12966
|
-
/**
|
|
12967
|
-
* Creates a new Latch.
|
|
12968
|
-
*
|
|
12969
|
-
* @example
|
|
12970
|
-
* ```ts
|
|
12971
|
-
* import { Effect } from "effect"
|
|
12972
|
-
*
|
|
12973
|
-
* const latch = Effect.makeLatchUnsafe(false)
|
|
12974
|
-
*
|
|
12975
|
-
* const waiter = Effect.gen(function*() {
|
|
12976
|
-
* yield* Effect.log("Waiting for latch to open...")
|
|
12977
|
-
* yield* latch.await
|
|
12978
|
-
* yield* Effect.log("Latch opened! Continuing...")
|
|
12979
|
-
* })
|
|
12980
|
-
*
|
|
12981
|
-
* const opener = Effect.gen(function*() {
|
|
12982
|
-
* yield* Effect.sleep("2 seconds")
|
|
12983
|
-
* yield* Effect.log("Opening latch...")
|
|
12984
|
-
* yield* latch.open
|
|
12985
|
-
* })
|
|
12986
|
-
*
|
|
12987
|
-
* const program = Effect.all([waiter, opener])
|
|
12988
|
-
* ```
|
|
12989
|
-
*
|
|
12990
|
-
* @category Latch
|
|
12991
|
-
* @since 3.8.0
|
|
12992
|
-
*/
|
|
12993
|
-
export const makeLatchUnsafe: (open?: boolean | undefined) => Latch = internal.makeLatchUnsafe
|
|
12994
|
-
|
|
12995
|
-
/**
|
|
12996
|
-
* Creates a new Latch.
|
|
12997
|
-
*
|
|
12998
|
-
* @example
|
|
12999
|
-
* ```ts
|
|
13000
|
-
* import { Effect } from "effect"
|
|
13001
|
-
*
|
|
13002
|
-
* const program = Effect.gen(function*() {
|
|
13003
|
-
* const latch = yield* Effect.makeLatch(false)
|
|
13004
|
-
*
|
|
13005
|
-
* const waiter = Effect.gen(function*() {
|
|
13006
|
-
* yield* Effect.log("Waiting for latch to open...")
|
|
13007
|
-
* yield* latch.await
|
|
13008
|
-
* yield* Effect.log("Latch opened! Continuing...")
|
|
13009
|
-
* })
|
|
13010
|
-
*
|
|
13011
|
-
* const opener = Effect.gen(function*() {
|
|
13012
|
-
* yield* Effect.sleep("2 seconds")
|
|
13013
|
-
* yield* Effect.log("Opening latch...")
|
|
13014
|
-
* yield* latch.open
|
|
13015
|
-
* })
|
|
13016
|
-
*
|
|
13017
|
-
* yield* Effect.all([waiter, opener])
|
|
13018
|
-
* })
|
|
13019
|
-
* ```
|
|
13020
|
-
*
|
|
13021
|
-
* @category Latch
|
|
13022
|
-
* @since 3.8.0
|
|
13023
|
-
*/
|
|
13024
|
-
export const makeLatch: (open?: boolean | undefined) => Effect<Latch> = internal.makeLatch
|
|
13025
|
-
|
|
13026
13216
|
// -----------------------------------------------------------------------------
|
|
13027
13217
|
// Repetition & Recursion
|
|
13028
13218
|
// -----------------------------------------------------------------------------
|
|
@@ -20339,7 +20529,7 @@ export const clockWith: <A, E, R>(
|
|
|
20339
20529
|
* @since 2.0.0
|
|
20340
20530
|
* @category Logging
|
|
20341
20531
|
*/
|
|
20342
|
-
export const logWithLevel: (level?:
|
|
20532
|
+
export const logWithLevel: (level?: Severity) => (...message: ReadonlyArray<any>) => Effect<void> =
|
|
20343
20533
|
internal.logWithLevel
|
|
20344
20534
|
|
|
20345
20535
|
/**
|
|
@@ -20767,6 +20957,86 @@ export const annotateLogs = dual<
|
|
|
20767
20957
|
})
|
|
20768
20958
|
)
|
|
20769
20959
|
|
|
20960
|
+
/**
|
|
20961
|
+
* Adds log annotations to the current scope.
|
|
20962
|
+
*
|
|
20963
|
+
* This differs from `annotateLogs`, which only annotates a specific effect.
|
|
20964
|
+
* `annotateLogsScoped` updates annotations for the entire current `Scope` and
|
|
20965
|
+
* restores the previous annotations when the scope closes.
|
|
20966
|
+
*
|
|
20967
|
+
* @example
|
|
20968
|
+
* ```ts
|
|
20969
|
+
* import { Effect } from "effect"
|
|
20970
|
+
*
|
|
20971
|
+
* const program = Effect.scoped(
|
|
20972
|
+
* Effect.gen(function*() {
|
|
20973
|
+
* yield* Effect.log("before")
|
|
20974
|
+
* yield* Effect.annotateLogsScoped({ requestId: "req-123" })
|
|
20975
|
+
* yield* Effect.log("inside scope")
|
|
20976
|
+
* })
|
|
20977
|
+
* )
|
|
20978
|
+
*
|
|
20979
|
+
* Effect.runPromise(program)
|
|
20980
|
+
* ```
|
|
20981
|
+
*
|
|
20982
|
+
* @since 4.0.0
|
|
20983
|
+
* @category Logging
|
|
20984
|
+
*/
|
|
20985
|
+
export const annotateLogsScoped: {
|
|
20986
|
+
/**
|
|
20987
|
+
* Adds log annotations to the current scope.
|
|
20988
|
+
*
|
|
20989
|
+
* This differs from `annotateLogs`, which only annotates a specific effect.
|
|
20990
|
+
* `annotateLogsScoped` updates annotations for the entire current `Scope` and
|
|
20991
|
+
* restores the previous annotations when the scope closes.
|
|
20992
|
+
*
|
|
20993
|
+
* @example
|
|
20994
|
+
* ```ts
|
|
20995
|
+
* import { Effect } from "effect"
|
|
20996
|
+
*
|
|
20997
|
+
* const program = Effect.scoped(
|
|
20998
|
+
* Effect.gen(function*() {
|
|
20999
|
+
* yield* Effect.log("before")
|
|
21000
|
+
* yield* Effect.annotateLogsScoped({ requestId: "req-123" })
|
|
21001
|
+
* yield* Effect.log("inside scope")
|
|
21002
|
+
* })
|
|
21003
|
+
* )
|
|
21004
|
+
*
|
|
21005
|
+
* Effect.runPromise(program)
|
|
21006
|
+
* ```
|
|
21007
|
+
*
|
|
21008
|
+
* @since 4.0.0
|
|
21009
|
+
* @category Logging
|
|
21010
|
+
*/
|
|
21011
|
+
(key: string, value: unknown): Effect<void, never, Scope>
|
|
21012
|
+
/**
|
|
21013
|
+
* Adds log annotations to the current scope.
|
|
21014
|
+
*
|
|
21015
|
+
* This differs from `annotateLogs`, which only annotates a specific effect.
|
|
21016
|
+
* `annotateLogsScoped` updates annotations for the entire current `Scope` and
|
|
21017
|
+
* restores the previous annotations when the scope closes.
|
|
21018
|
+
*
|
|
21019
|
+
* @example
|
|
21020
|
+
* ```ts
|
|
21021
|
+
* import { Effect } from "effect"
|
|
21022
|
+
*
|
|
21023
|
+
* const program = Effect.scoped(
|
|
21024
|
+
* Effect.gen(function*() {
|
|
21025
|
+
* yield* Effect.log("before")
|
|
21026
|
+
* yield* Effect.annotateLogsScoped({ requestId: "req-123" })
|
|
21027
|
+
* yield* Effect.log("inside scope")
|
|
21028
|
+
* })
|
|
21029
|
+
* )
|
|
21030
|
+
*
|
|
21031
|
+
* Effect.runPromise(program)
|
|
21032
|
+
* ```
|
|
21033
|
+
*
|
|
21034
|
+
* @since 4.0.0
|
|
21035
|
+
* @category Logging
|
|
21036
|
+
*/
|
|
21037
|
+
(values: Record<string, unknown>): Effect<void, never, Scope>
|
|
21038
|
+
} = internal.annotateLogsScoped
|
|
21039
|
+
|
|
20770
21040
|
/**
|
|
20771
21041
|
* Adds a span to each log line in this effect.
|
|
20772
21042
|
*
|
|
@@ -22151,8 +22421,8 @@ export const trackDuration: {
|
|
|
22151
22421
|
return onExit(self, () => {
|
|
22152
22422
|
const endTime = clock.currentTimeNanosUnsafe()
|
|
22153
22423
|
const duration = Duration.subtract(
|
|
22154
|
-
Duration.
|
|
22155
|
-
Duration.
|
|
22424
|
+
Duration.fromInputUnsafe(endTime),
|
|
22425
|
+
Duration.fromInputUnsafe(startTime)
|
|
22156
22426
|
)
|
|
22157
22427
|
const input = f === undefined ? duration : internalCall(() => f(duration))
|
|
22158
22428
|
return Metric.update(metric, input as any)
|
|
@@ -22200,136 +22470,70 @@ export class Transaction extends ServiceMap.Service<
|
|
|
22200
22470
|
>()("effect/Effect/Transaction") {}
|
|
22201
22471
|
|
|
22202
22472
|
/**
|
|
22203
|
-
*
|
|
22204
|
-
* transactional values (i.e. TxRef) that occur within the transaction body.
|
|
22205
|
-
*
|
|
22206
|
-
* In Effect transactions are optimistic with retry, that means transactions are retried when:
|
|
22207
|
-
*
|
|
22208
|
-
* - the body of the transaction explicitely calls to `Effect.retryTransaction` and any of the
|
|
22209
|
-
* accessed transactional values changes.
|
|
22210
|
-
*
|
|
22211
|
-
* - any of the accessed transactional values change during the execution of the transaction
|
|
22212
|
-
* due to a different transaction committing before the current.
|
|
22473
|
+
* Accesses the current transaction state within an active transaction.
|
|
22213
22474
|
*
|
|
22214
|
-
*
|
|
22215
|
-
*
|
|
22475
|
+
* This function requires `Transaction` in the context and does NOT create or strip
|
|
22476
|
+
* transaction boundaries. Use it to interact with the transaction journal (e.g. in
|
|
22477
|
+
* `TxRef` internals). To define a transaction boundary, use {@link transaction}.
|
|
22216
22478
|
*
|
|
22217
22479
|
* @example
|
|
22218
22480
|
* ```ts
|
|
22219
22481
|
* import { Effect, TxRef } from "effect"
|
|
22220
22482
|
*
|
|
22221
22483
|
* const program = Effect.gen(function*() {
|
|
22222
|
-
* const
|
|
22223
|
-
* const ref2 = yield* TxRef.make(0)
|
|
22224
|
-
*
|
|
22225
|
-
* // All operations within atomic block succeed or fail together
|
|
22226
|
-
* yield* Effect.atomic(Effect.gen(function*() {
|
|
22227
|
-
* yield* TxRef.set(ref1, 10)
|
|
22228
|
-
* yield* TxRef.set(ref2, 20)
|
|
22229
|
-
* const sum = (yield* TxRef.get(ref1)) + (yield* TxRef.get(ref2))
|
|
22230
|
-
* console.log(`Transaction sum: ${sum}`)
|
|
22231
|
-
* }))
|
|
22232
|
-
*
|
|
22233
|
-
* console.log(`Final ref1: ${yield* TxRef.get(ref1)}`) // 10
|
|
22234
|
-
* console.log(`Final ref2: ${yield* TxRef.get(ref2)}`) // 20
|
|
22235
|
-
* })
|
|
22236
|
-
* ```
|
|
22237
|
-
*
|
|
22238
|
-
* @since 4.0.0
|
|
22239
|
-
* @category Transactions
|
|
22240
|
-
*/
|
|
22241
|
-
export const atomic = <A, E, R>(
|
|
22242
|
-
effect: Effect<A, E, R>
|
|
22243
|
-
): Effect<A, E, Exclude<R, Transaction>> => atomicWith(() => effect)
|
|
22244
|
-
|
|
22245
|
-
/**
|
|
22246
|
-
* Executes a function within a transaction context, providing access to the transaction state.
|
|
22247
|
-
*
|
|
22248
|
-
* @example
|
|
22249
|
-
* ```ts
|
|
22250
|
-
* import { Effect, TxRef } from "effect"
|
|
22251
|
-
*
|
|
22252
|
-
* const program = Effect.atomicWith((txState) =>
|
|
22253
|
-
* Effect.gen(function*() {
|
|
22254
|
-
* const ref = yield* TxRef.make(0)
|
|
22255
|
-
*
|
|
22256
|
-
* // Access transaction state for debugging
|
|
22257
|
-
* console.log(`Journal size: ${txState.journal.size}`)
|
|
22258
|
-
* console.log(`Retry flag: ${txState.retry}`)
|
|
22484
|
+
* const ref = yield* Effect.transaction(TxRef.make(0))
|
|
22259
22485
|
*
|
|
22486
|
+
* yield* Effect.transaction(Effect.gen(function*() {
|
|
22260
22487
|
* yield* TxRef.set(ref, 42)
|
|
22261
22488
|
* return yield* TxRef.get(ref)
|
|
22262
|
-
* })
|
|
22263
|
-
* )
|
|
22264
|
-
*
|
|
22265
|
-
* Effect.runPromise(program).then(console.log) // 42
|
|
22489
|
+
* }))
|
|
22490
|
+
* })
|
|
22266
22491
|
* ```
|
|
22267
22492
|
*
|
|
22268
22493
|
* @since 4.0.0
|
|
22269
22494
|
* @category Transactions
|
|
22270
22495
|
*/
|
|
22271
|
-
export const
|
|
22496
|
+
export const withTxState = <A, E, R>(
|
|
22272
22497
|
f: (state: Transaction["Service"]) => Effect<A, E, R>
|
|
22273
|
-
): Effect<A, E,
|
|
22274
|
-
|
|
22275
|
-
|
|
22276
|
-
|
|
22277
|
-
|
|
22278
|
-
A,
|
|
22279
|
-
E,
|
|
22280
|
-
Exclude<R, Transaction>
|
|
22281
|
-
>
|
|
22282
|
-
}
|
|
22283
|
-
// No existing transaction, create isolated one using transactionWith
|
|
22284
|
-
return transactionWith(f)
|
|
22285
|
-
})
|
|
22498
|
+
): Effect<A, E, R | Transaction> =>
|
|
22499
|
+
flatMap(
|
|
22500
|
+
Transaction.asEffect(),
|
|
22501
|
+
(state) => internalCall(() => f(state))
|
|
22502
|
+
)
|
|
22286
22503
|
|
|
22287
22504
|
/**
|
|
22288
|
-
*
|
|
22505
|
+
* Defines a transaction boundary. Transactions are "all or nothing" with respect to changes
|
|
22506
|
+
* made to transactional values (i.e. TxRef) that occur within the transaction body.
|
|
22289
22507
|
*
|
|
22290
|
-
*
|
|
22508
|
+
* In Effect transactions are optimistic with retry, that means transactions are retried when:
|
|
22291
22509
|
*
|
|
22292
|
-
*
|
|
22293
|
-
*
|
|
22294
|
-
* This ensures complete isolation between different transaction scopes.
|
|
22510
|
+
* - the body of the transaction explicitely calls to `Effect.retryTransaction` and any of the
|
|
22511
|
+
* accessed transactional values changes.
|
|
22295
22512
|
*
|
|
22296
|
-
*
|
|
22297
|
-
*
|
|
22298
|
-
* - Parent transaction failures don't affect isolated transactions
|
|
22299
|
-
* - Isolated transaction failures don't affect parent transactions
|
|
22300
|
-
* - Each transaction has its own journal and retry logic
|
|
22513
|
+
* - any of the accessed transactional values change during the execution of the transaction
|
|
22514
|
+
* due to a different transaction committing before the current.
|
|
22301
22515
|
*
|
|
22302
|
-
*
|
|
22303
|
-
*
|
|
22304
|
-
* - For implementing independent operations that shouldn't be affected by outer transactions
|
|
22305
|
-
* - When building transaction-based systems where isolation is critical
|
|
22516
|
+
* Each call to `transaction` always creates a new isolated transaction boundary with its own
|
|
22517
|
+
* journal and retry logic.
|
|
22306
22518
|
*
|
|
22307
22519
|
* @example
|
|
22308
22520
|
* ```ts
|
|
22309
22521
|
* import { Effect, TxRef } from "effect"
|
|
22310
22522
|
*
|
|
22311
22523
|
* const program = Effect.gen(function*() {
|
|
22312
|
-
* const ref1 = yield* TxRef.make(0)
|
|
22313
|
-
* const ref2 = yield* TxRef.make(
|
|
22314
|
-
*
|
|
22315
|
-
* // Nested atomic transaction - ref1 will be part of outer transaction
|
|
22316
|
-
* yield* Effect.atomic(Effect.gen(function*() {
|
|
22317
|
-
* yield* TxRef.set(ref1, 10)
|
|
22318
|
-
*
|
|
22319
|
-
* // This atomic operation composes with the parent
|
|
22320
|
-
* yield* Effect.atomic(Effect.gen(function*() {
|
|
22321
|
-
* yield* TxRef.set(ref1, 20) // Part of same transaction
|
|
22322
|
-
* }))
|
|
22323
|
-
* }))
|
|
22524
|
+
* const ref1 = yield* Effect.transaction(TxRef.make(0))
|
|
22525
|
+
* const ref2 = yield* Effect.transaction(TxRef.make(0))
|
|
22324
22526
|
*
|
|
22325
|
-
* //
|
|
22527
|
+
* // All operations within transaction block succeed or fail together
|
|
22326
22528
|
* yield* Effect.transaction(Effect.gen(function*() {
|
|
22327
|
-
* yield* TxRef.set(
|
|
22529
|
+
* yield* TxRef.set(ref1, 10)
|
|
22530
|
+
* yield* TxRef.set(ref2, 20)
|
|
22531
|
+
* const sum = (yield* TxRef.get(ref1)) + (yield* TxRef.get(ref2))
|
|
22532
|
+
* console.log(`Transaction sum: ${sum}`)
|
|
22328
22533
|
* }))
|
|
22329
22534
|
*
|
|
22330
|
-
*
|
|
22331
|
-
*
|
|
22332
|
-
* return { ref1: val1, ref2: val2 }
|
|
22535
|
+
* console.log(`Final ref1: ${yield* Effect.transaction(TxRef.get(ref1))}`) // 10
|
|
22536
|
+
* console.log(`Final ref2: ${yield* Effect.transaction(TxRef.get(ref2))}`) // 20
|
|
22333
22537
|
* })
|
|
22334
22538
|
* ```
|
|
22335
22539
|
*
|
|
@@ -22341,34 +22545,21 @@ export const transaction = <A, E, R>(
|
|
|
22341
22545
|
): Effect<A, E, Exclude<R, Transaction>> => transactionWith(() => effect)
|
|
22342
22546
|
|
|
22343
22547
|
/**
|
|
22344
|
-
*
|
|
22548
|
+
* Like {@link transaction} but provides access to the transaction state.
|
|
22345
22549
|
*
|
|
22346
|
-
*
|
|
22347
|
-
* within another transaction. This ensures complete isolation between transaction scopes.
|
|
22550
|
+
* Always creates a new isolated transaction boundary with its own journal and retry logic.
|
|
22348
22551
|
*
|
|
22349
22552
|
* @example
|
|
22350
22553
|
* ```ts
|
|
22351
22554
|
* import { Effect, TxRef } from "effect"
|
|
22352
22555
|
*
|
|
22353
|
-
* const program = Effect.transactionWith((
|
|
22556
|
+
* const program = Effect.transactionWith((_txState) =>
|
|
22354
22557
|
* Effect.gen(function*() {
|
|
22355
22558
|
* const ref = yield* TxRef.make(0)
|
|
22356
|
-
*
|
|
22357
|
-
* // This transaction is isolated - it has its own journal
|
|
22358
|
-
* // txState.journal is independent of any parent transaction
|
|
22359
|
-
*
|
|
22360
22559
|
* yield* TxRef.set(ref, 42)
|
|
22361
22560
|
* return yield* TxRef.get(ref)
|
|
22362
22561
|
* })
|
|
22363
22562
|
* )
|
|
22364
|
-
*
|
|
22365
|
-
* // Even when nested in another atomic block, this transaction is isolated
|
|
22366
|
-
* const nestedProgram = Effect.atomic(
|
|
22367
|
-
* Effect.gen(function*() {
|
|
22368
|
-
* const result = yield* program // Runs in its own isolated transaction
|
|
22369
|
-
* return result
|
|
22370
|
-
* })
|
|
22371
|
-
* )
|
|
22372
22563
|
* ```
|
|
22373
22564
|
*
|
|
22374
22565
|
* @since 4.0.0
|
|
@@ -22476,16 +22667,16 @@ function clearTransaction(state: Transaction["Service"]) {
|
|
|
22476
22667
|
*
|
|
22477
22668
|
* const program = Effect.gen(function*() {
|
|
22478
22669
|
* // create a transactional reference
|
|
22479
|
-
* const ref = yield* TxRef.make(0)
|
|
22670
|
+
* const ref = yield* Effect.transaction(TxRef.make(0))
|
|
22480
22671
|
*
|
|
22481
22672
|
* // forks a fiber that increases the value of `ref` every 100 millis
|
|
22482
22673
|
* yield* Effect.forkChild(Effect.forever(
|
|
22483
22674
|
* // update to transactional value
|
|
22484
|
-
* TxRef.update(ref, (n) => n + 1).pipe(Effect.delay("100 millis"))
|
|
22675
|
+
* Effect.transaction(TxRef.update(ref, (n) => n + 1)).pipe(Effect.delay("100 millis"))
|
|
22485
22676
|
* ))
|
|
22486
22677
|
*
|
|
22487
22678
|
* // the following will retry 10 times until the `ref` value is 10
|
|
22488
|
-
* yield* Effect.
|
|
22679
|
+
* yield* Effect.transaction(Effect.gen(function*() {
|
|
22489
22680
|
* const value = yield* TxRef.get(ref)
|
|
22490
22681
|
* if (value < 10) {
|
|
22491
22682
|
* yield* Effect.log(`retry due to value: ${value}`)
|