effect 4.0.0-beta.2 → 4.0.0-beta.20
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 +733 -687
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +233 -250
- 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 +91 -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 +3 -2
- 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 +123 -76
- 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 +225 -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 +33 -6
- 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/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/WorkflowEngine.d.ts +8 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js +133 -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 +909 -817
- 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 +315 -160
- package/src/Schema.ts +661 -116
- package/src/SchemaAST.ts +3 -2
- 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 +565 -600
- 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 +660 -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 +46 -8
- 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/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 +1 -1
- package/src/unstable/workflow/WorkflowEngine.ts +181 -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"
|
|
@@ -852,6 +855,214 @@ export const partition: {
|
|
|
852
855
|
): Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>
|
|
853
856
|
} = internal.partition
|
|
854
857
|
|
|
858
|
+
/**
|
|
859
|
+
* Applies an effectful function to each element and accumulates all failures.
|
|
860
|
+
*
|
|
861
|
+
* This function always evaluates every element. If at least one effect fails,
|
|
862
|
+
* all failures are returned as a non-empty array and successes are discarded.
|
|
863
|
+
* If all effects succeed, it returns all collected successes.
|
|
864
|
+
*
|
|
865
|
+
* Use `discard: true` to ignore successful values while still validating all
|
|
866
|
+
* elements.
|
|
867
|
+
*
|
|
868
|
+
* @example
|
|
869
|
+
* ```ts
|
|
870
|
+
* import { Effect } from "effect"
|
|
871
|
+
*
|
|
872
|
+
* const program = Effect.validate([0, 1, 2, 3], (n) =>
|
|
873
|
+
* n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
|
|
874
|
+
* )
|
|
875
|
+
*
|
|
876
|
+
* Effect.runPromiseExit(program).then(console.log)
|
|
877
|
+
* // {
|
|
878
|
+
* // _id: 'Exit',
|
|
879
|
+
* // _tag: 'Failure',
|
|
880
|
+
* // cause: {
|
|
881
|
+
* // _id: 'Cause',
|
|
882
|
+
* // reasons: [
|
|
883
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '0 is even' },
|
|
884
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '2 is even' }
|
|
885
|
+
* // ]
|
|
886
|
+
* // }
|
|
887
|
+
* // }
|
|
888
|
+
* ```
|
|
889
|
+
*
|
|
890
|
+
* @since 4.0.0
|
|
891
|
+
* @category Error Accumulation
|
|
892
|
+
*/
|
|
893
|
+
export const validate: {
|
|
894
|
+
/**
|
|
895
|
+
* Applies an effectful function to each element and accumulates all failures.
|
|
896
|
+
*
|
|
897
|
+
* This function always evaluates every element. If at least one effect fails,
|
|
898
|
+
* all failures are returned as a non-empty array and successes are discarded.
|
|
899
|
+
* If all effects succeed, it returns all collected successes.
|
|
900
|
+
*
|
|
901
|
+
* Use `discard: true` to ignore successful values while still validating all
|
|
902
|
+
* elements.
|
|
903
|
+
*
|
|
904
|
+
* @example
|
|
905
|
+
* ```ts
|
|
906
|
+
* import { Effect } from "effect"
|
|
907
|
+
*
|
|
908
|
+
* const program = Effect.validate([0, 1, 2, 3], (n) =>
|
|
909
|
+
* n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
|
|
910
|
+
* )
|
|
911
|
+
*
|
|
912
|
+
* Effect.runPromiseExit(program).then(console.log)
|
|
913
|
+
* // {
|
|
914
|
+
* // _id: 'Exit',
|
|
915
|
+
* // _tag: 'Failure',
|
|
916
|
+
* // cause: {
|
|
917
|
+
* // _id: 'Cause',
|
|
918
|
+
* // reasons: [
|
|
919
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '0 is even' },
|
|
920
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '2 is even' }
|
|
921
|
+
* // ]
|
|
922
|
+
* // }
|
|
923
|
+
* // }
|
|
924
|
+
* ```
|
|
925
|
+
*
|
|
926
|
+
* @since 4.0.0
|
|
927
|
+
* @category Error Accumulation
|
|
928
|
+
*/
|
|
929
|
+
<A, B, E, R>(
|
|
930
|
+
f: (a: A, i: number) => Effect<B, E, R>,
|
|
931
|
+
options?: {
|
|
932
|
+
readonly concurrency?: Concurrency | undefined
|
|
933
|
+
readonly discard?: false | undefined
|
|
934
|
+
} | undefined
|
|
935
|
+
): (elements: Iterable<A>) => Effect<Array<B>, Arr.NonEmptyArray<E>, R>
|
|
936
|
+
/**
|
|
937
|
+
* Applies an effectful function to each element and accumulates all failures.
|
|
938
|
+
*
|
|
939
|
+
* This function always evaluates every element. If at least one effect fails,
|
|
940
|
+
* all failures are returned as a non-empty array and successes are discarded.
|
|
941
|
+
* If all effects succeed, it returns all collected successes.
|
|
942
|
+
*
|
|
943
|
+
* Use `discard: true` to ignore successful values while still validating all
|
|
944
|
+
* elements.
|
|
945
|
+
*
|
|
946
|
+
* @example
|
|
947
|
+
* ```ts
|
|
948
|
+
* import { Effect } from "effect"
|
|
949
|
+
*
|
|
950
|
+
* const program = Effect.validate([0, 1, 2, 3], (n) =>
|
|
951
|
+
* n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
|
|
952
|
+
* )
|
|
953
|
+
*
|
|
954
|
+
* Effect.runPromiseExit(program).then(console.log)
|
|
955
|
+
* // {
|
|
956
|
+
* // _id: 'Exit',
|
|
957
|
+
* // _tag: 'Failure',
|
|
958
|
+
* // cause: {
|
|
959
|
+
* // _id: 'Cause',
|
|
960
|
+
* // reasons: [
|
|
961
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '0 is even' },
|
|
962
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '2 is even' }
|
|
963
|
+
* // ]
|
|
964
|
+
* // }
|
|
965
|
+
* // }
|
|
966
|
+
* ```
|
|
967
|
+
*
|
|
968
|
+
* @since 4.0.0
|
|
969
|
+
* @category Error Accumulation
|
|
970
|
+
*/
|
|
971
|
+
<A, B, E, R>(
|
|
972
|
+
f: (a: A, i: number) => Effect<B, E, R>,
|
|
973
|
+
options: {
|
|
974
|
+
readonly concurrency?: Concurrency | undefined
|
|
975
|
+
readonly discard: true
|
|
976
|
+
}
|
|
977
|
+
): (elements: Iterable<A>) => Effect<void, Arr.NonEmptyArray<E>, R>
|
|
978
|
+
/**
|
|
979
|
+
* Applies an effectful function to each element and accumulates all failures.
|
|
980
|
+
*
|
|
981
|
+
* This function always evaluates every element. If at least one effect fails,
|
|
982
|
+
* all failures are returned as a non-empty array and successes are discarded.
|
|
983
|
+
* If all effects succeed, it returns all collected successes.
|
|
984
|
+
*
|
|
985
|
+
* Use `discard: true` to ignore successful values while still validating all
|
|
986
|
+
* elements.
|
|
987
|
+
*
|
|
988
|
+
* @example
|
|
989
|
+
* ```ts
|
|
990
|
+
* import { Effect } from "effect"
|
|
991
|
+
*
|
|
992
|
+
* const program = Effect.validate([0, 1, 2, 3], (n) =>
|
|
993
|
+
* n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
|
|
994
|
+
* )
|
|
995
|
+
*
|
|
996
|
+
* Effect.runPromiseExit(program).then(console.log)
|
|
997
|
+
* // {
|
|
998
|
+
* // _id: 'Exit',
|
|
999
|
+
* // _tag: 'Failure',
|
|
1000
|
+
* // cause: {
|
|
1001
|
+
* // _id: 'Cause',
|
|
1002
|
+
* // reasons: [
|
|
1003
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '0 is even' },
|
|
1004
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '2 is even' }
|
|
1005
|
+
* // ]
|
|
1006
|
+
* // }
|
|
1007
|
+
* // }
|
|
1008
|
+
* ```
|
|
1009
|
+
*
|
|
1010
|
+
* @since 4.0.0
|
|
1011
|
+
* @category Error Accumulation
|
|
1012
|
+
*/
|
|
1013
|
+
<A, B, E, R>(
|
|
1014
|
+
elements: Iterable<A>,
|
|
1015
|
+
f: (a: A, i: number) => Effect<B, E, R>,
|
|
1016
|
+
options?: {
|
|
1017
|
+
readonly concurrency?: Concurrency | undefined
|
|
1018
|
+
readonly discard?: false | undefined
|
|
1019
|
+
} | undefined
|
|
1020
|
+
): Effect<Array<B>, Arr.NonEmptyArray<E>, R>
|
|
1021
|
+
/**
|
|
1022
|
+
* Applies an effectful function to each element and accumulates all failures.
|
|
1023
|
+
*
|
|
1024
|
+
* This function always evaluates every element. If at least one effect fails,
|
|
1025
|
+
* all failures are returned as a non-empty array and successes are discarded.
|
|
1026
|
+
* If all effects succeed, it returns all collected successes.
|
|
1027
|
+
*
|
|
1028
|
+
* Use `discard: true` to ignore successful values while still validating all
|
|
1029
|
+
* elements.
|
|
1030
|
+
*
|
|
1031
|
+
* @example
|
|
1032
|
+
* ```ts
|
|
1033
|
+
* import { Effect } from "effect"
|
|
1034
|
+
*
|
|
1035
|
+
* const program = Effect.validate([0, 1, 2, 3], (n) =>
|
|
1036
|
+
* n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
|
|
1037
|
+
* )
|
|
1038
|
+
*
|
|
1039
|
+
* Effect.runPromiseExit(program).then(console.log)
|
|
1040
|
+
* // {
|
|
1041
|
+
* // _id: 'Exit',
|
|
1042
|
+
* // _tag: 'Failure',
|
|
1043
|
+
* // cause: {
|
|
1044
|
+
* // _id: 'Cause',
|
|
1045
|
+
* // reasons: [
|
|
1046
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '0 is even' },
|
|
1047
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '2 is even' }
|
|
1048
|
+
* // ]
|
|
1049
|
+
* // }
|
|
1050
|
+
* // }
|
|
1051
|
+
* ```
|
|
1052
|
+
*
|
|
1053
|
+
* @since 4.0.0
|
|
1054
|
+
* @category Error Accumulation
|
|
1055
|
+
*/
|
|
1056
|
+
<A, B, E, R>(
|
|
1057
|
+
elements: Iterable<A>,
|
|
1058
|
+
f: (a: A, i: number) => Effect<B, E, R>,
|
|
1059
|
+
options: {
|
|
1060
|
+
readonly concurrency?: Concurrency | undefined
|
|
1061
|
+
readonly discard: true
|
|
1062
|
+
}
|
|
1063
|
+
): Effect<void, Arr.NonEmptyArray<E>, R>
|
|
1064
|
+
} = internal.validate
|
|
1065
|
+
|
|
855
1066
|
/**
|
|
856
1067
|
* Executes an effectful operation for each element in an `Iterable`.
|
|
857
1068
|
*
|
|
@@ -1511,6 +1722,103 @@ export const callback: <A, E = never, R = never>(
|
|
|
1511
1722
|
*/
|
|
1512
1723
|
export const never: Effect<never> = internal.never
|
|
1513
1724
|
|
|
1725
|
+
/**
|
|
1726
|
+
* An `Effect` containing an empty record `{}`, used as the starting point for
|
|
1727
|
+
* do notation chains.
|
|
1728
|
+
*
|
|
1729
|
+
* @example
|
|
1730
|
+
* ```ts
|
|
1731
|
+
* import { Effect } from "effect"
|
|
1732
|
+
* import { pipe } from "effect/Function"
|
|
1733
|
+
*
|
|
1734
|
+
* const program = pipe(
|
|
1735
|
+
* Effect.Do,
|
|
1736
|
+
* Effect.bind("x", () => Effect.succeed(2)),
|
|
1737
|
+
* Effect.bind("y", ({ x }) => Effect.succeed(x + 1)),
|
|
1738
|
+
* Effect.let("sum", ({ x, y }) => x + y)
|
|
1739
|
+
* )
|
|
1740
|
+
* ```
|
|
1741
|
+
*
|
|
1742
|
+
* @since 4.0.0
|
|
1743
|
+
* @category Do notation
|
|
1744
|
+
*/
|
|
1745
|
+
export const Do: Effect<{}> = internal.Do
|
|
1746
|
+
|
|
1747
|
+
/**
|
|
1748
|
+
* Gives a name to the success value of an `Effect`, creating a single-key
|
|
1749
|
+
* record used in do notation pipelines.
|
|
1750
|
+
*
|
|
1751
|
+
* @since 4.0.0
|
|
1752
|
+
* @category Do notation
|
|
1753
|
+
*/
|
|
1754
|
+
export const bindTo: {
|
|
1755
|
+
/**
|
|
1756
|
+
* Gives a name to the success value of an `Effect`, creating a single-key
|
|
1757
|
+
* record used in do notation pipelines.
|
|
1758
|
+
*
|
|
1759
|
+
* @since 4.0.0
|
|
1760
|
+
* @category Do notation
|
|
1761
|
+
*/
|
|
1762
|
+
<N extends string>(name: N): <A, E, R>(self: Effect<A, E, R>) => Effect<{ [K in N]: A }, E, R>
|
|
1763
|
+
/**
|
|
1764
|
+
* Gives a name to the success value of an `Effect`, creating a single-key
|
|
1765
|
+
* record used in do notation pipelines.
|
|
1766
|
+
*
|
|
1767
|
+
* @since 4.0.0
|
|
1768
|
+
* @category Do notation
|
|
1769
|
+
*/
|
|
1770
|
+
<A, E, R, N extends string>(self: Effect<A, E, R>, name: N): Effect<{ [K in N]: A }, E, R>
|
|
1771
|
+
} = internal.bindTo
|
|
1772
|
+
|
|
1773
|
+
const let_: {
|
|
1774
|
+
<N extends string, A extends Record<string, any>, B>(
|
|
1775
|
+
name: N,
|
|
1776
|
+
f: (a: NoInfer<A>) => B
|
|
1777
|
+
): <E, R>(
|
|
1778
|
+
self: Effect<A, E, R>
|
|
1779
|
+
) => Effect<Simplify<Omit<A, N> & Record<N, B>>, E, R>
|
|
1780
|
+
<A extends Record<string, any>, E, R, B, N extends string>(
|
|
1781
|
+
self: Effect<A, E, R>,
|
|
1782
|
+
name: N,
|
|
1783
|
+
f: (a: NoInfer<A>) => B
|
|
1784
|
+
): Effect<Simplify<Omit<A, N> & Record<N, B>>, E, R>
|
|
1785
|
+
} = internal.let
|
|
1786
|
+
|
|
1787
|
+
export {
|
|
1788
|
+
/**
|
|
1789
|
+
* Adds a computed plain value to the do notation record.
|
|
1790
|
+
*
|
|
1791
|
+
* @since 4.0.0
|
|
1792
|
+
* @category Do notation
|
|
1793
|
+
*/
|
|
1794
|
+
let_ as let
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1797
|
+
/**
|
|
1798
|
+
* Adds an `Effect` value to the do notation record under a given name.
|
|
1799
|
+
*
|
|
1800
|
+
* @since 4.0.0
|
|
1801
|
+
* @category Do notation
|
|
1802
|
+
*/
|
|
1803
|
+
export const bind: {
|
|
1804
|
+
/**
|
|
1805
|
+
* Adds an `Effect` value to the do notation record under a given name.
|
|
1806
|
+
*
|
|
1807
|
+
* @since 4.0.0
|
|
1808
|
+
* @category Do notation
|
|
1809
|
+
*/
|
|
1810
|
+
<N extends string, A extends Record<string, any>, B, E2, R2>(name: N, f: (a: NoInfer<A>) => Effect<B, E2, R2>): <E, R>(
|
|
1811
|
+
self: Effect<A, E, R>
|
|
1812
|
+
) => Effect<Simplify<Omit<A, N> & Record<N, B>>, E | E2, R | R2>
|
|
1813
|
+
/**
|
|
1814
|
+
* Adds an `Effect` value to the do notation record under a given name.
|
|
1815
|
+
*
|
|
1816
|
+
* @since 4.0.0
|
|
1817
|
+
* @category Do notation
|
|
1818
|
+
*/
|
|
1819
|
+
<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>
|
|
1820
|
+
} = internal.bind
|
|
1821
|
+
|
|
1514
1822
|
/**
|
|
1515
1823
|
* Provides a way to write effectful code using generator functions, simplifying
|
|
1516
1824
|
* control flow and error handling.
|
|
@@ -4228,8 +4536,16 @@ export const catchReason: {
|
|
|
4228
4536
|
>(
|
|
4229
4537
|
errorTag: K,
|
|
4230
4538
|
reasonTag: RK,
|
|
4231
|
-
f: (
|
|
4232
|
-
|
|
4539
|
+
f: (
|
|
4540
|
+
reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK>,
|
|
4541
|
+
error: NarrowReason<ExtractTag<NoInfer<E>, K>, RK>
|
|
4542
|
+
) => Effect<A2, E2, R2>,
|
|
4543
|
+
orElse?:
|
|
4544
|
+
| ((
|
|
4545
|
+
reasons: ExcludeReason<ExtractTag<NoInfer<E>, K>, RK>,
|
|
4546
|
+
error: OmitReason<ExtractTag<NoInfer<E>, K>, RK>
|
|
4547
|
+
) => Effect<A3, E3, R3>)
|
|
4548
|
+
| undefined
|
|
4233
4549
|
): <A, R>(
|
|
4234
4550
|
self: Effect<A, E, R>
|
|
4235
4551
|
) => Effect<A | A2 | Exclude<A3, unassigned>, (A3 extends unassigned ? E : ExcludeTag<E, K>) | E2 | E3, R | R2 | R3>
|
|
@@ -4284,8 +4600,10 @@ export const catchReason: {
|
|
|
4284
4600
|
self: Effect<A, E, R>,
|
|
4285
4601
|
errorTag: K,
|
|
4286
4602
|
reasonTag: RK,
|
|
4287
|
-
f: (reason: ExtractReason<ExtractTag<E, K>, RK>) => Effect<A2, E2, R2>,
|
|
4288
|
-
orElse?:
|
|
4603
|
+
f: (reason: ExtractReason<ExtractTag<E, K>, RK>, error: NarrowReason<ExtractTag<E, K>, RK>) => Effect<A2, E2, R2>,
|
|
4604
|
+
orElse?:
|
|
4605
|
+
| ((reasons: ExcludeReason<ExtractTag<E, K>, RK>, error: OmitReason<ExtractTag<E, K>, RK>) => Effect<A3, E3, R3>)
|
|
4606
|
+
| undefined
|
|
4289
4607
|
): Effect<A | A2 | Exclude<A3, unassigned>, (A3 extends unassigned ? E : ExcludeTag<E, K>) | E2 | E3, R | R2 | R3>
|
|
4290
4608
|
} = internal.catchReason
|
|
4291
4609
|
|
|
@@ -4363,7 +4681,8 @@ export const catchReasons: {
|
|
|
4363
4681
|
E,
|
|
4364
4682
|
Cases extends {
|
|
4365
4683
|
[RK in ReasonTags<ExtractTag<NoInfer<E>, K>>]+?: (
|
|
4366
|
-
reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK
|
|
4684
|
+
reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK>,
|
|
4685
|
+
error: NarrowReason<ExtractTag<NoInfer<E>, K>, RK>
|
|
4367
4686
|
) => Effect<any, any, any>
|
|
4368
4687
|
},
|
|
4369
4688
|
A2 = unassigned,
|
|
@@ -4373,7 +4692,10 @@ export const catchReasons: {
|
|
|
4373
4692
|
errorTag: K,
|
|
4374
4693
|
cases: Cases,
|
|
4375
4694
|
orElse?:
|
|
4376
|
-
| ((
|
|
4695
|
+
| ((
|
|
4696
|
+
reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>,
|
|
4697
|
+
error: OmitReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>
|
|
4698
|
+
) => Effect<A2, E2, R2>)
|
|
4377
4699
|
| undefined
|
|
4378
4700
|
): <A, R>(
|
|
4379
4701
|
self: Effect<A, E, R>
|
|
@@ -4434,7 +4756,10 @@ export const catchReasons: {
|
|
|
4434
4756
|
R,
|
|
4435
4757
|
K extends Tags<E>,
|
|
4436
4758
|
Cases extends {
|
|
4437
|
-
[RK in ReasonTags<ExtractTag<E, K>>]+?: (
|
|
4759
|
+
[RK in ReasonTags<ExtractTag<E, K>>]+?: (
|
|
4760
|
+
reason: ExtractReason<ExtractTag<E, K>, RK>,
|
|
4761
|
+
error: NarrowReason<ExtractTag<E, K>, RK>
|
|
4762
|
+
) => Effect<any, any, any>
|
|
4438
4763
|
},
|
|
4439
4764
|
A2 = unassigned,
|
|
4440
4765
|
E2 = never,
|
|
@@ -4444,7 +4769,10 @@ export const catchReasons: {
|
|
|
4444
4769
|
errorTag: K,
|
|
4445
4770
|
cases: Cases,
|
|
4446
4771
|
orElse?:
|
|
4447
|
-
| ((
|
|
4772
|
+
| ((
|
|
4773
|
+
reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>,
|
|
4774
|
+
error: OmitReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>
|
|
4775
|
+
) => Effect<A2, E2, R2>)
|
|
4448
4776
|
| undefined
|
|
4449
4777
|
): Effect<
|
|
4450
4778
|
| A
|
|
@@ -4870,15 +5198,14 @@ export const catchDefect: {
|
|
|
4870
5198
|
} = internal.catchDefect
|
|
4871
5199
|
|
|
4872
5200
|
/**
|
|
4873
|
-
* Recovers from specific errors using a `
|
|
4874
|
-
* `Refinement`.
|
|
5201
|
+
* Recovers from specific errors using a `Predicate` or `Refinement`.
|
|
4875
5202
|
*
|
|
4876
5203
|
* **When to Use**
|
|
4877
5204
|
*
|
|
4878
|
-
* `catchIf` lets you recover from errors that match a condition.
|
|
4879
|
-
* `
|
|
4880
|
-
*
|
|
4881
|
-
*
|
|
5205
|
+
* `catchIf` lets you recover from errors that match a condition. Use a
|
|
5206
|
+
* `Refinement` for type narrowing or a `Predicate` for simple boolean
|
|
5207
|
+
* matching. Non-matching errors re-fail with the original cause. Defects and
|
|
5208
|
+
* interrupts are not caught.
|
|
4882
5209
|
*
|
|
4883
5210
|
* **Previously Known As**
|
|
4884
5211
|
*
|
|
@@ -4905,7 +5232,7 @@ export const catchDefect: {
|
|
|
4905
5232
|
*
|
|
4906
5233
|
* // With a Filter
|
|
4907
5234
|
* const recovered2 = program.pipe(
|
|
4908
|
-
* Effect.
|
|
5235
|
+
* Effect.catchFilter(
|
|
4909
5236
|
* Filter.tagged("NotFound"),
|
|
4910
5237
|
* (error) => Effect.succeed(`missing:${error.id}`)
|
|
4911
5238
|
* )
|
|
@@ -4917,15 +5244,14 @@ export const catchDefect: {
|
|
|
4917
5244
|
*/
|
|
4918
5245
|
export const catchIf: {
|
|
4919
5246
|
/**
|
|
4920
|
-
* Recovers from specific errors using a `
|
|
4921
|
-
* `Refinement`.
|
|
5247
|
+
* Recovers from specific errors using a `Predicate` or `Refinement`.
|
|
4922
5248
|
*
|
|
4923
5249
|
* **When to Use**
|
|
4924
5250
|
*
|
|
4925
|
-
* `catchIf` lets you recover from errors that match a condition.
|
|
4926
|
-
* `
|
|
4927
|
-
*
|
|
4928
|
-
*
|
|
5251
|
+
* `catchIf` lets you recover from errors that match a condition. Use a
|
|
5252
|
+
* `Refinement` for type narrowing or a `Predicate` for simple boolean
|
|
5253
|
+
* matching. Non-matching errors re-fail with the original cause. Defects and
|
|
5254
|
+
* interrupts are not caught.
|
|
4929
5255
|
*
|
|
4930
5256
|
* **Previously Known As**
|
|
4931
5257
|
*
|
|
@@ -4952,7 +5278,7 @@ export const catchIf: {
|
|
|
4952
5278
|
*
|
|
4953
5279
|
* // With a Filter
|
|
4954
5280
|
* const recovered2 = program.pipe(
|
|
4955
|
-
* Effect.
|
|
5281
|
+
* Effect.catchFilter(
|
|
4956
5282
|
* Filter.tagged("NotFound"),
|
|
4957
5283
|
* (error) => Effect.succeed(`missing:${error.id}`)
|
|
4958
5284
|
* )
|
|
@@ -4968,15 +5294,14 @@ export const catchIf: {
|
|
|
4968
5294
|
orElse?: ((e: Exclude<E, EB>) => Effect<A3, E3, R3>) | undefined
|
|
4969
5295
|
): <A, R>(self: Effect<A, E, R>) => Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
4970
5296
|
/**
|
|
4971
|
-
* Recovers from specific errors using a `
|
|
4972
|
-
* `Refinement`.
|
|
5297
|
+
* Recovers from specific errors using a `Predicate` or `Refinement`.
|
|
4973
5298
|
*
|
|
4974
5299
|
* **When to Use**
|
|
4975
5300
|
*
|
|
4976
|
-
* `catchIf` lets you recover from errors that match a condition.
|
|
4977
|
-
* `
|
|
4978
|
-
*
|
|
4979
|
-
*
|
|
5301
|
+
* `catchIf` lets you recover from errors that match a condition. Use a
|
|
5302
|
+
* `Refinement` for type narrowing or a `Predicate` for simple boolean
|
|
5303
|
+
* matching. Non-matching errors re-fail with the original cause. Defects and
|
|
5304
|
+
* interrupts are not caught.
|
|
4980
5305
|
*
|
|
4981
5306
|
* **Previously Known As**
|
|
4982
5307
|
*
|
|
@@ -5003,7 +5328,7 @@ export const catchIf: {
|
|
|
5003
5328
|
*
|
|
5004
5329
|
* // With a Filter
|
|
5005
5330
|
* const recovered2 = program.pipe(
|
|
5006
|
-
* Effect.
|
|
5331
|
+
* Effect.catchFilter(
|
|
5007
5332
|
* Filter.tagged("NotFound"),
|
|
5008
5333
|
* (error) => Effect.succeed(`missing:${error.id}`)
|
|
5009
5334
|
* )
|
|
@@ -5013,21 +5338,20 @@ export const catchIf: {
|
|
|
5013
5338
|
* @since 2.0.0
|
|
5014
5339
|
* @category Error Handling
|
|
5015
5340
|
*/
|
|
5016
|
-
<E,
|
|
5017
|
-
|
|
5018
|
-
f: (e:
|
|
5019
|
-
orElse?: ((e:
|
|
5341
|
+
<E, A2, E2, R2, A3 = never, E3 = E, R3 = never>(
|
|
5342
|
+
predicate: Predicate.Predicate<NoInfer<E>>,
|
|
5343
|
+
f: (e: NoInfer<E>) => Effect<A2, E2, R2>,
|
|
5344
|
+
orElse?: ((e: NoInfer<E>) => Effect<A3, E3, R3>) | undefined
|
|
5020
5345
|
): <A, R>(self: Effect<A, E, R>) => Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
5021
5346
|
/**
|
|
5022
|
-
* Recovers from specific errors using a `
|
|
5023
|
-
* `Refinement`.
|
|
5347
|
+
* Recovers from specific errors using a `Predicate` or `Refinement`.
|
|
5024
5348
|
*
|
|
5025
5349
|
* **When to Use**
|
|
5026
5350
|
*
|
|
5027
|
-
* `catchIf` lets you recover from errors that match a condition.
|
|
5028
|
-
* `
|
|
5029
|
-
*
|
|
5030
|
-
*
|
|
5351
|
+
* `catchIf` lets you recover from errors that match a condition. Use a
|
|
5352
|
+
* `Refinement` for type narrowing or a `Predicate` for simple boolean
|
|
5353
|
+
* matching. Non-matching errors re-fail with the original cause. Defects and
|
|
5354
|
+
* interrupts are not caught.
|
|
5031
5355
|
*
|
|
5032
5356
|
* **Previously Known As**
|
|
5033
5357
|
*
|
|
@@ -5054,7 +5378,7 @@ export const catchIf: {
|
|
|
5054
5378
|
*
|
|
5055
5379
|
* // With a Filter
|
|
5056
5380
|
* const recovered2 = program.pipe(
|
|
5057
|
-
* Effect.
|
|
5381
|
+
* Effect.catchFilter(
|
|
5058
5382
|
* Filter.tagged("NotFound"),
|
|
5059
5383
|
* (error) => Effect.succeed(`missing:${error.id}`)
|
|
5060
5384
|
* )
|
|
@@ -5071,15 +5395,14 @@ export const catchIf: {
|
|
|
5071
5395
|
orElse?: ((e: Exclude<E, EB>) => Effect<A3, E3, R3>) | undefined
|
|
5072
5396
|
): Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
5073
5397
|
/**
|
|
5074
|
-
* Recovers from specific errors using a `
|
|
5075
|
-
* `Refinement`.
|
|
5398
|
+
* Recovers from specific errors using a `Predicate` or `Refinement`.
|
|
5076
5399
|
*
|
|
5077
5400
|
* **When to Use**
|
|
5078
5401
|
*
|
|
5079
|
-
* `catchIf` lets you recover from errors that match a condition.
|
|
5080
|
-
* `
|
|
5081
|
-
*
|
|
5082
|
-
*
|
|
5402
|
+
* `catchIf` lets you recover from errors that match a condition. Use a
|
|
5403
|
+
* `Refinement` for type narrowing or a `Predicate` for simple boolean
|
|
5404
|
+
* matching. Non-matching errors re-fail with the original cause. Defects and
|
|
5405
|
+
* interrupts are not caught.
|
|
5083
5406
|
*
|
|
5084
5407
|
* **Previously Known As**
|
|
5085
5408
|
*
|
|
@@ -5106,7 +5429,7 @@ export const catchIf: {
|
|
|
5106
5429
|
*
|
|
5107
5430
|
* // With a Filter
|
|
5108
5431
|
* const recovered2 = program.pipe(
|
|
5109
|
-
* Effect.
|
|
5432
|
+
* Effect.catchFilter(
|
|
5110
5433
|
* Filter.tagged("NotFound"),
|
|
5111
5434
|
* (error) => Effect.succeed(`missing:${error.id}`)
|
|
5112
5435
|
* )
|
|
@@ -5116,14 +5439,46 @@ export const catchIf: {
|
|
|
5116
5439
|
* @since 2.0.0
|
|
5117
5440
|
* @category Error Handling
|
|
5118
5441
|
*/
|
|
5119
|
-
<A, E, R,
|
|
5442
|
+
<A, E, R, A2, E2, R2, A3 = never, E3 = E, R3 = never>(
|
|
5120
5443
|
self: Effect<A, E, R>,
|
|
5121
|
-
|
|
5122
|
-
f: (e:
|
|
5123
|
-
orElse?: ((e:
|
|
5444
|
+
predicate: Predicate.Predicate<E>,
|
|
5445
|
+
f: (e: E) => Effect<A2, E2, R2>,
|
|
5446
|
+
orElse?: ((e: E) => Effect<A3, E3, R3>) | undefined
|
|
5124
5447
|
): Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
5125
5448
|
} = internal.catchIf
|
|
5126
5449
|
|
|
5450
|
+
/**
|
|
5451
|
+
* Recovers from specific errors using a `Filter`.
|
|
5452
|
+
*
|
|
5453
|
+
* @since 4.0.0
|
|
5454
|
+
* @category Error Handling
|
|
5455
|
+
*/
|
|
5456
|
+
export const catchFilter: {
|
|
5457
|
+
/**
|
|
5458
|
+
* Recovers from specific errors using a `Filter`.
|
|
5459
|
+
*
|
|
5460
|
+
* @since 4.0.0
|
|
5461
|
+
* @category Error Handling
|
|
5462
|
+
*/
|
|
5463
|
+
<E, EB, A2, E2, R2, X, A3 = never, E3 = X, R3 = never>(
|
|
5464
|
+
filter: Filter.Filter<NoInfer<E>, EB, X>,
|
|
5465
|
+
f: (e: EB) => Effect<A2, E2, R2>,
|
|
5466
|
+
orElse?: ((e: X) => Effect<A3, E3, R3>) | undefined
|
|
5467
|
+
): <A, R>(self: Effect<A, E, R>) => Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
5468
|
+
/**
|
|
5469
|
+
* Recovers from specific errors using a `Filter`.
|
|
5470
|
+
*
|
|
5471
|
+
* @since 4.0.0
|
|
5472
|
+
* @category Error Handling
|
|
5473
|
+
*/
|
|
5474
|
+
<A, E, R, EB, A2, E2, R2, X, A3 = never, E3 = X, R3 = never>(
|
|
5475
|
+
self: Effect<A, E, R>,
|
|
5476
|
+
filter: Filter.Filter<NoInfer<E>, EB, X>,
|
|
5477
|
+
f: (e: EB) => Effect<A2, E2, R2>,
|
|
5478
|
+
orElse?: ((e: X) => Effect<A3, E3, R3>) | undefined
|
|
5479
|
+
): Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
5480
|
+
} = internal.catchFilter
|
|
5481
|
+
|
|
5127
5482
|
/**
|
|
5128
5483
|
* Catches `NoSuchElementError` failures and converts them to `Option.none`.
|
|
5129
5484
|
*
|
|
@@ -5231,10 +5586,10 @@ export const catchCauseIf: {
|
|
|
5231
5586
|
* @since 4.0.0
|
|
5232
5587
|
* @category Error Handling
|
|
5233
5588
|
*/
|
|
5234
|
-
<E,
|
|
5235
|
-
|
|
5236
|
-
f: (
|
|
5237
|
-
): <A, R>(self: Effect<A, E, R>) => Effect<A | B,
|
|
5589
|
+
<E, B, E2, R2>(
|
|
5590
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
5591
|
+
f: (cause: Cause.Cause<E>) => Effect<B, E2, R2>
|
|
5592
|
+
): <A, R>(self: Effect<A, E, R>) => Effect<A | B, E | E2, R | R2>
|
|
5238
5593
|
/**
|
|
5239
5594
|
* Recovers from specific failures based on a predicate.
|
|
5240
5595
|
*
|
|
@@ -5273,13 +5628,43 @@ export const catchCauseIf: {
|
|
|
5273
5628
|
* @since 4.0.0
|
|
5274
5629
|
* @category Error Handling
|
|
5275
5630
|
*/
|
|
5276
|
-
<A, E, R, B, E2, R2
|
|
5631
|
+
<A, E, R, B, E2, R2>(
|
|
5277
5632
|
self: Effect<A, E, R>,
|
|
5278
|
-
|
|
5279
|
-
f: (
|
|
5280
|
-
): Effect<A | B,
|
|
5633
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
5634
|
+
f: (cause: Cause.Cause<E>) => Effect<B, E2, R2>
|
|
5635
|
+
): Effect<A | B, E | E2, R | R2>
|
|
5281
5636
|
} = internal.catchCauseIf
|
|
5282
5637
|
|
|
5638
|
+
/**
|
|
5639
|
+
* Recovers from specific failures based on a `Filter`.
|
|
5640
|
+
*
|
|
5641
|
+
* @since 4.0.0
|
|
5642
|
+
* @category Error Handling
|
|
5643
|
+
*/
|
|
5644
|
+
export const catchCauseFilter: {
|
|
5645
|
+
/**
|
|
5646
|
+
* Recovers from specific failures based on a `Filter`.
|
|
5647
|
+
*
|
|
5648
|
+
* @since 4.0.0
|
|
5649
|
+
* @category Error Handling
|
|
5650
|
+
*/
|
|
5651
|
+
<E, B, E2, R2, EB, X extends Cause.Cause<any>>(
|
|
5652
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
5653
|
+
f: (failure: EB, cause: Cause.Cause<E>) => Effect<B, E2, R2>
|
|
5654
|
+
): <A, R>(self: Effect<A, E, R>) => Effect<A | B, Cause.Cause.Error<X> | E2, R | R2>
|
|
5655
|
+
/**
|
|
5656
|
+
* Recovers from specific failures based on a `Filter`.
|
|
5657
|
+
*
|
|
5658
|
+
* @since 4.0.0
|
|
5659
|
+
* @category Error Handling
|
|
5660
|
+
*/
|
|
5661
|
+
<A, E, R, B, E2, R2, EB, X extends Cause.Cause<any>>(
|
|
5662
|
+
self: Effect<A, E, R>,
|
|
5663
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
5664
|
+
f: (failure: EB, cause: Cause.Cause<E>) => Effect<B, E2, R2>
|
|
5665
|
+
): Effect<A | B, Cause.Cause.Error<X> | E2, R | R2>
|
|
5666
|
+
} = internal.catchCauseFilter
|
|
5667
|
+
|
|
5283
5668
|
/**
|
|
5284
5669
|
* The `mapError` function is used to transform or modify the error
|
|
5285
5670
|
* produced by an effect, without affecting its success value.
|
|
@@ -5905,9 +6290,9 @@ export const tapCauseIf: {
|
|
|
5905
6290
|
* @since 4.0.0
|
|
5906
6291
|
* @category Sequencing
|
|
5907
6292
|
*/
|
|
5908
|
-
<E,
|
|
5909
|
-
|
|
5910
|
-
f: (
|
|
6293
|
+
<E, B, E2, R2>(
|
|
6294
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
6295
|
+
f: (cause: Cause.Cause<E>) => Effect<B, E2, R2>
|
|
5911
6296
|
): <A, R>(self: Effect<A, E, R>) => Effect<A, E | E2, R | R2>
|
|
5912
6297
|
/**
|
|
5913
6298
|
* Conditionally executes a side effect based on the cause of a failed effect.
|
|
@@ -5937,34 +6322,64 @@ export const tapCauseIf: {
|
|
|
5937
6322
|
* @since 4.0.0
|
|
5938
6323
|
* @category Sequencing
|
|
5939
6324
|
*/
|
|
5940
|
-
<A, E, R,
|
|
6325
|
+
<A, E, R, B, E2, R2>(
|
|
5941
6326
|
self: Effect<A, E, R>,
|
|
5942
|
-
|
|
5943
|
-
f: (
|
|
6327
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
6328
|
+
f: (cause: Cause.Cause<E>) => Effect<B, E2, R2>
|
|
5944
6329
|
): Effect<A, E | E2, R | R2>
|
|
5945
6330
|
} = internal.tapCauseIf
|
|
5946
6331
|
|
|
5947
6332
|
/**
|
|
5948
|
-
*
|
|
5949
|
-
*
|
|
5950
|
-
* **Details**
|
|
5951
|
-
*
|
|
5952
|
-
* This function is specifically designed to handle and inspect defects, which
|
|
5953
|
-
* are critical failures in your program, such as unexpected runtime exceptions
|
|
5954
|
-
* or system-level errors. Unlike normal recoverable errors, defects typically
|
|
5955
|
-
* indicate serious issues that cannot be addressed through standard error
|
|
5956
|
-
* handling.
|
|
5957
|
-
*
|
|
5958
|
-
* When a defect occurs in an effect, the function you provide to this function
|
|
5959
|
-
* will be executed, allowing you to log, monitor, or handle the defect in some
|
|
5960
|
-
* way. Importantly, this does not alter the main result of the effect. If no
|
|
5961
|
-
* defect occurs, the effect behaves as if this function was not used.
|
|
5962
|
-
*
|
|
5963
|
-
* @example
|
|
5964
|
-
* ```ts
|
|
5965
|
-
* import { Console, Effect } from "effect"
|
|
6333
|
+
* Conditionally executes a side effect based on the cause of a failed effect.
|
|
5966
6334
|
*
|
|
5967
|
-
*
|
|
6335
|
+
* @since 4.0.0
|
|
6336
|
+
* @category Sequencing
|
|
6337
|
+
*/
|
|
6338
|
+
export const tapCauseFilter: {
|
|
6339
|
+
/**
|
|
6340
|
+
* Conditionally executes a side effect based on the cause of a failed effect.
|
|
6341
|
+
*
|
|
6342
|
+
* @since 4.0.0
|
|
6343
|
+
* @category Sequencing
|
|
6344
|
+
*/
|
|
6345
|
+
<E, B, E2, R2, EB, X extends Cause.Cause<any>>(
|
|
6346
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
6347
|
+
f: (a: EB, cause: Cause.Cause<E>) => Effect<B, E2, R2>
|
|
6348
|
+
): <A, R>(self: Effect<A, E, R>) => Effect<A, E | E2, R | R2>
|
|
6349
|
+
/**
|
|
6350
|
+
* Conditionally executes a side effect based on the cause of a failed effect.
|
|
6351
|
+
*
|
|
6352
|
+
* @since 4.0.0
|
|
6353
|
+
* @category Sequencing
|
|
6354
|
+
*/
|
|
6355
|
+
<A, E, R, B, E2, R2, EB, X extends Cause.Cause<any>>(
|
|
6356
|
+
self: Effect<A, E, R>,
|
|
6357
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
6358
|
+
f: (a: EB, cause: Cause.Cause<E>) => Effect<B, E2, R2>
|
|
6359
|
+
): Effect<A, E | E2, R | R2>
|
|
6360
|
+
} = internal.tapCauseFilter
|
|
6361
|
+
|
|
6362
|
+
/**
|
|
6363
|
+
* Inspect severe errors or defects (non-recoverable failures) in an effect.
|
|
6364
|
+
*
|
|
6365
|
+
* **Details**
|
|
6366
|
+
*
|
|
6367
|
+
* This function is specifically designed to handle and inspect defects, which
|
|
6368
|
+
* are critical failures in your program, such as unexpected runtime exceptions
|
|
6369
|
+
* or system-level errors. Unlike normal recoverable errors, defects typically
|
|
6370
|
+
* indicate serious issues that cannot be addressed through standard error
|
|
6371
|
+
* handling.
|
|
6372
|
+
*
|
|
6373
|
+
* When a defect occurs in an effect, the function you provide to this function
|
|
6374
|
+
* will be executed, allowing you to log, monitor, or handle the defect in some
|
|
6375
|
+
* way. Importantly, this does not alter the main result of the effect. If no
|
|
6376
|
+
* defect occurs, the effect behaves as if this function was not used.
|
|
6377
|
+
*
|
|
6378
|
+
* @example
|
|
6379
|
+
* ```ts
|
|
6380
|
+
* import { Console, Effect } from "effect"
|
|
6381
|
+
*
|
|
6382
|
+
* // Simulate a task that fails with a recoverable error
|
|
5968
6383
|
* const task1: Effect.Effect<number, string> = Effect.fail("NetworkError")
|
|
5969
6384
|
*
|
|
5970
6385
|
* // tapDefect won't log anything because NetworkError is not a defect
|
|
@@ -6837,14 +7252,14 @@ export const sandbox: <A, E, R>(
|
|
|
6837
7252
|
*/
|
|
6838
7253
|
export const ignore: <
|
|
6839
7254
|
Arg extends Effect<any, any, any> | {
|
|
6840
|
-
readonly log?: boolean |
|
|
7255
|
+
readonly log?: boolean | Severity | undefined
|
|
6841
7256
|
} | undefined = {
|
|
6842
|
-
readonly log?: boolean |
|
|
7257
|
+
readonly log?: boolean | Severity | undefined
|
|
6843
7258
|
}
|
|
6844
7259
|
>(
|
|
6845
7260
|
effectOrOptions?: Arg,
|
|
6846
7261
|
options?: {
|
|
6847
|
-
readonly log?: boolean |
|
|
7262
|
+
readonly log?: boolean | Severity | undefined
|
|
6848
7263
|
} | undefined
|
|
6849
7264
|
) => [Arg] extends [Effect<infer _A, infer _E, infer _R>] ? Effect<void, never, _R>
|
|
6850
7265
|
: <A, E, R>(self: Effect<A, E, R>) => Effect<void, never, R> = internal.ignore
|
|
@@ -6869,14 +7284,14 @@ export const ignore: <
|
|
|
6869
7284
|
*/
|
|
6870
7285
|
export const ignoreCause: <
|
|
6871
7286
|
Arg extends Effect<any, any, any> | {
|
|
6872
|
-
readonly log?: boolean |
|
|
7287
|
+
readonly log?: boolean | Severity | undefined
|
|
6873
7288
|
} | undefined = {
|
|
6874
|
-
readonly log?: boolean |
|
|
7289
|
+
readonly log?: boolean | Severity | undefined
|
|
6875
7290
|
}
|
|
6876
7291
|
>(
|
|
6877
7292
|
effectOrOptions?: Arg,
|
|
6878
7293
|
options?: {
|
|
6879
|
-
readonly log?: boolean |
|
|
7294
|
+
readonly log?: boolean | Severity | undefined
|
|
6880
7295
|
} | undefined
|
|
6881
7296
|
) => [Arg] extends [Effect<infer _A, infer _E, infer _R>] ? Effect<void, never, _R>
|
|
6882
7297
|
: <A, E, R>(self: Effect<A, E, R>) => Effect<void, never, R> = internal.ignoreCause
|
|
@@ -6983,6 +7398,25 @@ export const withExecutionPlan: {
|
|
|
6983
7398
|
): Effect<A, E | PlanE, Exclude<R, Provides> | PlanR>
|
|
6984
7399
|
} = internalExecutionPlan.withExecutionPlan
|
|
6985
7400
|
|
|
7401
|
+
/**
|
|
7402
|
+
* Runs an effect and reports any errors to the configured `ErrorReporter`s.
|
|
7403
|
+
*
|
|
7404
|
+
* If the `defectsOnly` option is set to `true`, only defects (unrecoverable
|
|
7405
|
+
* errors) will be reported, while regular failures will be ignored.
|
|
7406
|
+
*
|
|
7407
|
+
* @since 4.0.0
|
|
7408
|
+
* @category Error Handling
|
|
7409
|
+
*/
|
|
7410
|
+
export const withErrorReporting: <
|
|
7411
|
+
Arg extends Effect<any, any, any> | { readonly defectsOnly?: boolean | undefined } | undefined = {
|
|
7412
|
+
readonly defectsOnly?: boolean | undefined
|
|
7413
|
+
}
|
|
7414
|
+
>(
|
|
7415
|
+
effectOrOptions: Arg,
|
|
7416
|
+
options?: { readonly defectsOnly?: boolean | undefined } | undefined
|
|
7417
|
+
) => [Arg] extends [Effect<infer _A, infer _E, infer _R>] ? Arg : <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, R> =
|
|
7418
|
+
internal.withErrorReporting
|
|
7419
|
+
|
|
6986
7420
|
// -----------------------------------------------------------------------------
|
|
6987
7421
|
// Fallback
|
|
6988
7422
|
// -----------------------------------------------------------------------------
|
|
@@ -7224,7 +7658,7 @@ export const timeout: {
|
|
|
7224
7658
|
* @since 2.0.0
|
|
7225
7659
|
* @category Delays & Timeouts
|
|
7226
7660
|
*/
|
|
7227
|
-
(duration: Duration.
|
|
7661
|
+
(duration: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E | Cause.TimeoutError, R>
|
|
7228
7662
|
// -----------------------------------------------------------------------------
|
|
7229
7663
|
// Delays & timeouts
|
|
7230
7664
|
// -----------------------------------------------------------------------------
|
|
@@ -7275,7 +7709,7 @@ export const timeout: {
|
|
|
7275
7709
|
* @since 2.0.0
|
|
7276
7710
|
* @category Delays & Timeouts
|
|
7277
7711
|
*/
|
|
7278
|
-
<A, E, R>(self: Effect<A, E, R>, duration: Duration.
|
|
7712
|
+
<A, E, R>(self: Effect<A, E, R>, duration: Duration.Input): Effect<A, E | Cause.TimeoutError, R>
|
|
7279
7713
|
} = internal.timeout
|
|
7280
7714
|
|
|
7281
7715
|
/**
|
|
@@ -7377,7 +7811,7 @@ export const timeoutOption: {
|
|
|
7377
7811
|
* @since 3.1.0
|
|
7378
7812
|
* @category Delays & Timeouts
|
|
7379
7813
|
*/
|
|
7380
|
-
(duration: Duration.
|
|
7814
|
+
(duration: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<Option<A>, E, R>
|
|
7381
7815
|
/**
|
|
7382
7816
|
* Handles timeouts by returning an `Option` that represents either the result
|
|
7383
7817
|
* or a timeout.
|
|
@@ -7427,7 +7861,7 @@ export const timeoutOption: {
|
|
|
7427
7861
|
* @since 3.1.0
|
|
7428
7862
|
* @category Delays & Timeouts
|
|
7429
7863
|
*/
|
|
7430
|
-
<A, E, R>(self: Effect<A, E, R>, duration: Duration.
|
|
7864
|
+
<A, E, R>(self: Effect<A, E, R>, duration: Duration.Input): Effect<Option<A>, E, R>
|
|
7431
7865
|
} = internal.timeoutOption
|
|
7432
7866
|
|
|
7433
7867
|
/**
|
|
@@ -7505,7 +7939,7 @@ export const timeoutOrElse: {
|
|
|
7505
7939
|
*/
|
|
7506
7940
|
<A2, E2, R2>(
|
|
7507
7941
|
options: {
|
|
7508
|
-
readonly duration: Duration.
|
|
7942
|
+
readonly duration: Duration.Input
|
|
7509
7943
|
readonly onTimeout: LazyArg<Effect<A2, E2, R2>>
|
|
7510
7944
|
}
|
|
7511
7945
|
): <A, E, R>(self: Effect<A, E, R>) => Effect<A | A2, E | E2, R | R2>
|
|
@@ -7548,7 +7982,7 @@ export const timeoutOrElse: {
|
|
|
7548
7982
|
<A, E, R, A2, E2, R2>(
|
|
7549
7983
|
self: Effect<A, E, R>,
|
|
7550
7984
|
options: {
|
|
7551
|
-
readonly duration: Duration.
|
|
7985
|
+
readonly duration: Duration.Input
|
|
7552
7986
|
readonly onTimeout: LazyArg<Effect<A2, E2, R2>>
|
|
7553
7987
|
}
|
|
7554
7988
|
): Effect<A | A2, E | E2, R | R2>
|
|
@@ -7595,7 +8029,7 @@ export const delay: {
|
|
|
7595
8029
|
* @since 2.0.0
|
|
7596
8030
|
* @category Delays & Timeouts
|
|
7597
8031
|
*/
|
|
7598
|
-
(duration: Duration.
|
|
8032
|
+
(duration: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, R>
|
|
7599
8033
|
/**
|
|
7600
8034
|
* Returns an effect that is delayed from this effect by the specified
|
|
7601
8035
|
* `Duration`.
|
|
@@ -7616,7 +8050,7 @@ export const delay: {
|
|
|
7616
8050
|
* @since 2.0.0
|
|
7617
8051
|
* @category Delays & Timeouts
|
|
7618
8052
|
*/
|
|
7619
|
-
<A, E, R>(self: Effect<A, E, R>, duration: Duration.
|
|
8053
|
+
<A, E, R>(self: Effect<A, E, R>, duration: Duration.Input): Effect<A, E, R>
|
|
7620
8054
|
} = internal.delay
|
|
7621
8055
|
|
|
7622
8056
|
/**
|
|
@@ -7641,7 +8075,7 @@ export const delay: {
|
|
|
7641
8075
|
* @since 2.0.0
|
|
7642
8076
|
* @category Delays & Timeouts
|
|
7643
8077
|
*/
|
|
7644
|
-
export const sleep: (duration: Duration.
|
|
8078
|
+
export const sleep: (duration: Duration.Input) => Effect<void> = internal.sleep
|
|
7645
8079
|
|
|
7646
8080
|
/**
|
|
7647
8081
|
* Measures the runtime of an effect and returns the duration with its result.
|
|
@@ -7961,12 +8395,12 @@ export const raceFirst: {
|
|
|
7961
8395
|
// -----------------------------------------------------------------------------
|
|
7962
8396
|
|
|
7963
8397
|
/**
|
|
7964
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7965
|
-
* predicate
|
|
8398
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8399
|
+
* predicate.
|
|
7966
8400
|
*
|
|
7967
8401
|
* @example
|
|
7968
8402
|
* ```ts
|
|
7969
|
-
* import { Effect
|
|
8403
|
+
* import { Effect } from "effect"
|
|
7970
8404
|
*
|
|
7971
8405
|
* // Sync predicate
|
|
7972
8406
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -7974,10 +8408,7 @@ export const raceFirst: {
|
|
|
7974
8408
|
* // Effectful predicate
|
|
7975
8409
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7976
8410
|
*
|
|
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
|
-
* )
|
|
8411
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
7981
8412
|
* ```
|
|
7982
8413
|
*
|
|
7983
8414
|
* @since 2.0.0
|
|
@@ -7989,12 +8420,12 @@ export const filter: {
|
|
|
7989
8420
|
// -----------------------------------------------------------------------------
|
|
7990
8421
|
|
|
7991
8422
|
/**
|
|
7992
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7993
|
-
* predicate
|
|
8423
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8424
|
+
* predicate.
|
|
7994
8425
|
*
|
|
7995
8426
|
* @example
|
|
7996
8427
|
* ```ts
|
|
7997
|
-
* import { Effect
|
|
8428
|
+
* import { Effect } from "effect"
|
|
7998
8429
|
*
|
|
7999
8430
|
* // Sync predicate
|
|
8000
8431
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -8002,10 +8433,7 @@ export const filter: {
|
|
|
8002
8433
|
* // Effectful predicate
|
|
8003
8434
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
8004
8435
|
*
|
|
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
|
-
* )
|
|
8436
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
8009
8437
|
* ```
|
|
8010
8438
|
*
|
|
8011
8439
|
* @since 2.0.0
|
|
@@ -8017,12 +8445,12 @@ export const filter: {
|
|
|
8017
8445
|
// -----------------------------------------------------------------------------
|
|
8018
8446
|
|
|
8019
8447
|
/**
|
|
8020
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
8021
|
-
* predicate
|
|
8448
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8449
|
+
* predicate.
|
|
8022
8450
|
*
|
|
8023
8451
|
* @example
|
|
8024
8452
|
* ```ts
|
|
8025
|
-
* import { Effect
|
|
8453
|
+
* import { Effect } from "effect"
|
|
8026
8454
|
*
|
|
8027
8455
|
* // Sync predicate
|
|
8028
8456
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -8030,10 +8458,7 @@ export const filter: {
|
|
|
8030
8458
|
* // Effectful predicate
|
|
8031
8459
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
8032
8460
|
*
|
|
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
|
-
* )
|
|
8461
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
8037
8462
|
* ```
|
|
8038
8463
|
*
|
|
8039
8464
|
* @since 2.0.0
|
|
@@ -8045,12 +8470,12 @@ export const filter: {
|
|
|
8045
8470
|
// -----------------------------------------------------------------------------
|
|
8046
8471
|
|
|
8047
8472
|
/**
|
|
8048
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
8049
|
-
* predicate
|
|
8473
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8474
|
+
* predicate.
|
|
8050
8475
|
*
|
|
8051
8476
|
* @example
|
|
8052
8477
|
* ```ts
|
|
8053
|
-
* import { Effect
|
|
8478
|
+
* import { Effect } from "effect"
|
|
8054
8479
|
*
|
|
8055
8480
|
* // Sync predicate
|
|
8056
8481
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -8058,30 +8483,27 @@ export const filter: {
|
|
|
8058
8483
|
* // Effectful predicate
|
|
8059
8484
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
8060
8485
|
*
|
|
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
|
-
* )
|
|
8486
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
8065
8487
|
* ```
|
|
8066
8488
|
*
|
|
8067
8489
|
* @since 2.0.0
|
|
8068
8490
|
* @category Filtering
|
|
8069
8491
|
*/
|
|
8070
|
-
<A,
|
|
8071
|
-
|
|
8492
|
+
<A, E, R>(
|
|
8493
|
+
predicate: (a: NoInfer<A>, i: number) => Effect<boolean, E, R>,
|
|
8072
8494
|
options?: { readonly concurrency?: Concurrency | undefined }
|
|
8073
|
-
): (
|
|
8495
|
+
): (iterable: Iterable<A>) => Effect<Array<A>, E, R>
|
|
8074
8496
|
// -----------------------------------------------------------------------------
|
|
8075
8497
|
// Filtering
|
|
8076
8498
|
// -----------------------------------------------------------------------------
|
|
8077
8499
|
|
|
8078
8500
|
/**
|
|
8079
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
8080
|
-
* predicate
|
|
8501
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8502
|
+
* predicate.
|
|
8081
8503
|
*
|
|
8082
8504
|
* @example
|
|
8083
8505
|
* ```ts
|
|
8084
|
-
* import { Effect
|
|
8506
|
+
* import { Effect } from "effect"
|
|
8085
8507
|
*
|
|
8086
8508
|
* // Sync predicate
|
|
8087
8509
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -8089,30 +8511,24 @@ export const filter: {
|
|
|
8089
8511
|
* // Effectful predicate
|
|
8090
8512
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
8091
8513
|
*
|
|
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
|
-
* )
|
|
8514
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
8096
8515
|
* ```
|
|
8097
8516
|
*
|
|
8098
8517
|
* @since 2.0.0
|
|
8099
8518
|
* @category Filtering
|
|
8100
8519
|
*/
|
|
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>
|
|
8520
|
+
<A, B extends A>(elements: Iterable<A>, refinement: Predicate.Refinement<A, B>): Effect<Array<B>>
|
|
8105
8521
|
// -----------------------------------------------------------------------------
|
|
8106
8522
|
// Filtering
|
|
8107
8523
|
// -----------------------------------------------------------------------------
|
|
8108
8524
|
|
|
8109
8525
|
/**
|
|
8110
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
8111
|
-
* predicate
|
|
8526
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8527
|
+
* predicate.
|
|
8112
8528
|
*
|
|
8113
8529
|
* @example
|
|
8114
8530
|
* ```ts
|
|
8115
|
-
* import { Effect
|
|
8531
|
+
* import { Effect } from "effect"
|
|
8116
8532
|
*
|
|
8117
8533
|
* // Sync predicate
|
|
8118
8534
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -8120,30 +8536,24 @@ export const filter: {
|
|
|
8120
8536
|
* // Effectful predicate
|
|
8121
8537
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
8122
8538
|
*
|
|
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
|
-
* )
|
|
8539
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
8127
8540
|
* ```
|
|
8128
8541
|
*
|
|
8129
8542
|
* @since 2.0.0
|
|
8130
8543
|
* @category Filtering
|
|
8131
8544
|
*/
|
|
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>
|
|
8545
|
+
<A>(elements: Iterable<A>, predicate: Predicate.Predicate<A>): Effect<Array<A>>
|
|
8136
8546
|
// -----------------------------------------------------------------------------
|
|
8137
8547
|
// Filtering
|
|
8138
8548
|
// -----------------------------------------------------------------------------
|
|
8139
8549
|
|
|
8140
8550
|
/**
|
|
8141
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
8142
|
-
* predicate
|
|
8551
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8552
|
+
* predicate.
|
|
8143
8553
|
*
|
|
8144
8554
|
* @example
|
|
8145
8555
|
* ```ts
|
|
8146
|
-
* import { Effect
|
|
8556
|
+
* import { Effect } from "effect"
|
|
8147
8557
|
*
|
|
8148
8558
|
* // Sync predicate
|
|
8149
8559
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -8151,137 +8561,71 @@ export const filter: {
|
|
|
8151
8561
|
* // Effectful predicate
|
|
8152
8562
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
8153
8563
|
*
|
|
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
|
-
* )
|
|
8564
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
8158
8565
|
* ```
|
|
8159
8566
|
*
|
|
8160
8567
|
* @since 2.0.0
|
|
8161
8568
|
* @category Filtering
|
|
8162
8569
|
*/
|
|
8163
|
-
<A,
|
|
8164
|
-
|
|
8165
|
-
|
|
8166
|
-
|
|
8570
|
+
<A, E, R>(
|
|
8571
|
+
iterable: Iterable<A>,
|
|
8572
|
+
predicate: (a: NoInfer<A>, i: number) => Effect<boolean, E, R>,
|
|
8573
|
+
options?: { readonly concurrency?: Concurrency | undefined }
|
|
8574
|
+
): Effect<Array<A>, E, R>
|
|
8575
|
+
} = internal.filter
|
|
8167
8576
|
|
|
8577
|
+
/**
|
|
8578
|
+
* Filters and maps elements of an iterable with a `Filter`.
|
|
8579
|
+
*
|
|
8580
|
+
* @since 4.0.0
|
|
8581
|
+
* @category Filtering
|
|
8582
|
+
*/
|
|
8583
|
+
export const filterMap: {
|
|
8168
8584
|
/**
|
|
8169
|
-
* Filters elements of an iterable
|
|
8170
|
-
* predicate, or `Filter.FilterEffect`.
|
|
8171
|
-
*
|
|
8172
|
-
* @example
|
|
8173
|
-
* ```ts
|
|
8174
|
-
* import { Effect, Filter, Result } from "effect"
|
|
8175
|
-
*
|
|
8176
|
-
* // Sync predicate
|
|
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))
|
|
8585
|
+
* Filters and maps elements of an iterable with a `Filter`.
|
|
8181
8586
|
*
|
|
8182
|
-
*
|
|
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
|
|
8587
|
+
* @since 4.0.0
|
|
8189
8588
|
* @category Filtering
|
|
8190
8589
|
*/
|
|
8191
|
-
<A>(
|
|
8192
|
-
// -----------------------------------------------------------------------------
|
|
8193
|
-
// Filtering
|
|
8194
|
-
// -----------------------------------------------------------------------------
|
|
8195
|
-
|
|
8590
|
+
<A, B, X>(filter: Filter.Filter<NoInfer<A>, B, X>): (elements: Iterable<A>) => Effect<Array<B>>
|
|
8196
8591
|
/**
|
|
8197
|
-
* Filters elements of an iterable
|
|
8198
|
-
* predicate, or `Filter.FilterEffect`.
|
|
8592
|
+
* Filters and maps elements of an iterable with a `Filter`.
|
|
8199
8593
|
*
|
|
8200
|
-
* @
|
|
8201
|
-
* ```ts
|
|
8202
|
-
* import { Effect, Filter, Result } from "effect"
|
|
8203
|
-
*
|
|
8204
|
-
* // Sync predicate
|
|
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
|
|
8594
|
+
* @since 4.0.0
|
|
8217
8595
|
* @category Filtering
|
|
8218
8596
|
*/
|
|
8219
8597
|
<A, B, X>(elements: Iterable<A>, filter: Filter.Filter<NoInfer<A>, B, X>): Effect<Array<B>>
|
|
8220
|
-
|
|
8221
|
-
// Filtering
|
|
8222
|
-
// -----------------------------------------------------------------------------
|
|
8598
|
+
} = internal.filterMap
|
|
8223
8599
|
|
|
8600
|
+
/**
|
|
8601
|
+
* Effectfully filters and maps elements of an iterable with a `FilterEffect`.
|
|
8602
|
+
*
|
|
8603
|
+
* @since 4.0.0
|
|
8604
|
+
* @category Filtering
|
|
8605
|
+
*/
|
|
8606
|
+
export const filterMapEffect: {
|
|
8224
8607
|
/**
|
|
8225
|
-
*
|
|
8226
|
-
* predicate, or `Filter.FilterEffect`.
|
|
8227
|
-
*
|
|
8228
|
-
* @example
|
|
8229
|
-
* ```ts
|
|
8230
|
-
* import { Effect, Filter, Result } from "effect"
|
|
8608
|
+
* Effectfully filters and maps elements of an iterable with a `FilterEffect`.
|
|
8231
8609
|
*
|
|
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
|
-
* ```
|
|
8243
|
-
*
|
|
8244
|
-
* @since 2.0.0
|
|
8610
|
+
* @since 4.0.0
|
|
8245
8611
|
* @category Filtering
|
|
8246
8612
|
*/
|
|
8247
8613
|
<A, B, X, E, R>(
|
|
8248
|
-
elements: Iterable<A>,
|
|
8249
8614
|
filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R>,
|
|
8250
8615
|
options?: { readonly concurrency?: Concurrency | undefined }
|
|
8251
|
-
): Effect<Array<B>, E, R>
|
|
8252
|
-
// -----------------------------------------------------------------------------
|
|
8253
|
-
// Filtering
|
|
8254
|
-
// -----------------------------------------------------------------------------
|
|
8255
|
-
|
|
8616
|
+
): (elements: Iterable<A>) => Effect<Array<B>, E, R>
|
|
8256
8617
|
/**
|
|
8257
|
-
*
|
|
8258
|
-
* predicate, or `Filter.FilterEffect`.
|
|
8618
|
+
* Effectfully filters and maps elements of an iterable with a `FilterEffect`.
|
|
8259
8619
|
*
|
|
8260
|
-
* @
|
|
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))
|
|
8269
|
-
*
|
|
8270
|
-
* // FilterEffect
|
|
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
|
|
8620
|
+
* @since 4.0.0
|
|
8277
8621
|
* @category Filtering
|
|
8278
8622
|
*/
|
|
8279
|
-
<A, E, R>(
|
|
8280
|
-
|
|
8281
|
-
|
|
8623
|
+
<A, B, X, E, R>(
|
|
8624
|
+
elements: Iterable<A>,
|
|
8625
|
+
filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R>,
|
|
8282
8626
|
options?: { readonly concurrency?: Concurrency | undefined }
|
|
8283
|
-
): Effect<Array<
|
|
8284
|
-
} = internal.
|
|
8627
|
+
): Effect<Array<B>, E, R>
|
|
8628
|
+
} = internal.filterMapEffect
|
|
8285
8629
|
|
|
8286
8630
|
/**
|
|
8287
8631
|
* Filters an effect, providing an alternative effect if the predicate fails.
|
|
@@ -8378,10 +8722,10 @@ export const filterOrElse: {
|
|
|
8378
8722
|
* @since 2.0.0
|
|
8379
8723
|
* @category Filtering
|
|
8380
8724
|
*/
|
|
8381
|
-
<A,
|
|
8382
|
-
|
|
8383
|
-
orElse: (a:
|
|
8384
|
-
): <E, R>(self: Effect<A, E, R>) => Effect<
|
|
8725
|
+
<A, C, E2, R2>(
|
|
8726
|
+
predicate: Predicate.Predicate<NoInfer<A>>,
|
|
8727
|
+
orElse: (a: NoInfer<A>) => Effect<C, E2, R2>
|
|
8728
|
+
): <E, R>(self: Effect<A, E, R>) => Effect<A | C, E2 | E, R2 | R>
|
|
8385
8729
|
/**
|
|
8386
8730
|
* Filters an effect, providing an alternative effect if the predicate fails.
|
|
8387
8731
|
*
|
|
@@ -8447,13 +8791,43 @@ export const filterOrElse: {
|
|
|
8447
8791
|
* @since 2.0.0
|
|
8448
8792
|
* @category Filtering
|
|
8449
8793
|
*/
|
|
8450
|
-
<A, E, R,
|
|
8794
|
+
<A, E, R, C, E2, R2>(
|
|
8451
8795
|
self: Effect<A, E, R>,
|
|
8452
|
-
|
|
8453
|
-
orElse: (a:
|
|
8454
|
-
): Effect<
|
|
8796
|
+
predicate: Predicate.Predicate<NoInfer<A>>,
|
|
8797
|
+
orElse: (a: NoInfer<A>) => Effect<C, E2, R2>
|
|
8798
|
+
): Effect<A | C, E | E2, R | R2>
|
|
8455
8799
|
} = internal.filterOrElse
|
|
8456
8800
|
|
|
8801
|
+
/**
|
|
8802
|
+
* Filters an effect with a `Filter`, providing an alternative effect on failure.
|
|
8803
|
+
*
|
|
8804
|
+
* @since 4.0.0
|
|
8805
|
+
* @category Filtering
|
|
8806
|
+
*/
|
|
8807
|
+
export const filterMapOrElse: {
|
|
8808
|
+
/**
|
|
8809
|
+
* Filters an effect with a `Filter`, providing an alternative effect on failure.
|
|
8810
|
+
*
|
|
8811
|
+
* @since 4.0.0
|
|
8812
|
+
* @category Filtering
|
|
8813
|
+
*/
|
|
8814
|
+
<A, B, X, C, E2, R2>(
|
|
8815
|
+
filter: Filter.Filter<NoInfer<A>, B, X>,
|
|
8816
|
+
orElse: (x: X) => Effect<C, E2, R2>
|
|
8817
|
+
): <E, R>(self: Effect<A, E, R>) => Effect<B | C, E2 | E, R2 | R>
|
|
8818
|
+
/**
|
|
8819
|
+
* Filters an effect with a `Filter`, providing an alternative effect on failure.
|
|
8820
|
+
*
|
|
8821
|
+
* @since 4.0.0
|
|
8822
|
+
* @category Filtering
|
|
8823
|
+
*/
|
|
8824
|
+
<A, E, R, B, X, C, E2, R2>(
|
|
8825
|
+
self: Effect<A, E, R>,
|
|
8826
|
+
filter: Filter.Filter<NoInfer<A>, B, X>,
|
|
8827
|
+
orElse: (x: X) => Effect<C, E2, R2>
|
|
8828
|
+
): Effect<B | C, E | E2, R | R2>
|
|
8829
|
+
} = internal.filterMapOrElse
|
|
8830
|
+
|
|
8457
8831
|
/**
|
|
8458
8832
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8459
8833
|
*
|
|
@@ -8550,36 +8924,6 @@ export const filterOrFail: {
|
|
|
8550
8924
|
predicate: Predicate.Predicate<NoInfer<A>>,
|
|
8551
8925
|
orFailWith: (a: NoInfer<A>) => E2
|
|
8552
8926
|
): <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
8927
|
/**
|
|
8584
8928
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8585
8929
|
*
|
|
@@ -8640,36 +8984,6 @@ export const filterOrFail: {
|
|
|
8640
8984
|
* @category Filtering
|
|
8641
8985
|
*/
|
|
8642
8986
|
<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
8987
|
/**
|
|
8674
8988
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8675
8989
|
*
|
|
@@ -8767,11 +9081,7 @@ export const filterOrFail: {
|
|
|
8767
9081
|
* @since 2.0.0
|
|
8768
9082
|
* @category Filtering
|
|
8769
9083
|
*/
|
|
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>
|
|
9084
|
+
<A, E, R, B extends A>(self: Effect<A, E, R>, refinement: Predicate.Refinement<NoInfer<A>, B>): Effect<B, E | Cause.NoSuchElementError, R>
|
|
8775
9085
|
/**
|
|
8776
9086
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8777
9087
|
*
|
|
@@ -8801,68 +9111,49 @@ export const filterOrFail: {
|
|
|
8801
9111
|
* @since 2.0.0
|
|
8802
9112
|
* @category Filtering
|
|
8803
9113
|
*/
|
|
8804
|
-
<A, E, R
|
|
9114
|
+
<A, E, R>(self: Effect<A, E, R>, predicate: Predicate.Predicate<NoInfer<A>>): Effect<A, E | Cause.NoSuchElementError, R>
|
|
9115
|
+
} = internal.filterOrFail
|
|
9116
|
+
|
|
9117
|
+
/**
|
|
9118
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
9119
|
+
*
|
|
9120
|
+
* @since 4.0.0
|
|
9121
|
+
* @category Filtering
|
|
9122
|
+
*/
|
|
9123
|
+
export const filterMapOrFail: {
|
|
8805
9124
|
/**
|
|
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
|
-
* )
|
|
9125
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
8827
9126
|
*
|
|
8828
|
-
*
|
|
8829
|
-
* ```
|
|
8830
|
-
*
|
|
8831
|
-
* @since 2.0.0
|
|
9127
|
+
* @since 4.0.0
|
|
8832
9128
|
* @category Filtering
|
|
8833
9129
|
*/
|
|
8834
|
-
<A,
|
|
9130
|
+
<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
9131
|
/**
|
|
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`.
|
|
9132
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
8843
9133
|
*
|
|
8844
|
-
* @
|
|
8845
|
-
*
|
|
8846
|
-
|
|
8847
|
-
|
|
8848
|
-
|
|
8849
|
-
*
|
|
8850
|
-
*
|
|
8851
|
-
* // Filter for even numbers, fail for odd numbers
|
|
8852
|
-
* const filtered = Effect.filterOrFail(
|
|
8853
|
-
* program,
|
|
8854
|
-
* (n) => n % 2 === 0,
|
|
8855
|
-
* (n) => `Expected even number, got ${n}`
|
|
8856
|
-
* )
|
|
9134
|
+
* @since 4.0.0
|
|
9135
|
+
* @category Filtering
|
|
9136
|
+
*/
|
|
9137
|
+
<A, B, X>(filter: Filter.Filter<NoInfer<A>, B, X>): <E, R>(self: Effect<A, E, R>) => Effect<B, Cause.NoSuchElementError | E, R>
|
|
9138
|
+
/**
|
|
9139
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
8857
9140
|
*
|
|
8858
|
-
*
|
|
8859
|
-
*
|
|
9141
|
+
* @since 4.0.0
|
|
9142
|
+
* @category Filtering
|
|
9143
|
+
*/
|
|
9144
|
+
<A, E, R, B, X, E2>(
|
|
9145
|
+
self: Effect<A, E, R>,
|
|
9146
|
+
filter: Filter.Filter<A, B, X>,
|
|
9147
|
+
orFailWith: (x: X) => E2
|
|
9148
|
+
): Effect<B, E2 | E, R>
|
|
9149
|
+
/**
|
|
9150
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
8860
9151
|
*
|
|
8861
|
-
* @since
|
|
9152
|
+
* @since 4.0.0
|
|
8862
9153
|
* @category Filtering
|
|
8863
9154
|
*/
|
|
8864
|
-
<A, E, R, B, X>(self: Effect<A, E, R>, filter: Filter.Filter<A, B, X>): Effect<B,
|
|
8865
|
-
} = internal.
|
|
9155
|
+
<A, E, R, B, X>(self: Effect<A, E, R>, filter: Filter.Filter<A, B, X>): Effect<B, Cause.NoSuchElementError | E, R>
|
|
9156
|
+
} = internal.filterMapOrFail
|
|
8866
9157
|
|
|
8867
9158
|
// -----------------------------------------------------------------------------
|
|
8868
9159
|
// Conditional Operators
|
|
@@ -10496,7 +10787,7 @@ export const provideServices: {
|
|
|
10496
10787
|
* @since 4.0.0
|
|
10497
10788
|
* @category ServiceMap
|
|
10498
10789
|
*/
|
|
10499
|
-
export const service: <I, S>(service: ServiceMap.
|
|
10790
|
+
export const service: <I, S>(service: ServiceMap.Key<I, S>) => Effect<S, never, I> = internal.service
|
|
10500
10791
|
|
|
10501
10792
|
/**
|
|
10502
10793
|
* Optionally accesses a service from the environment.
|
|
@@ -10532,7 +10823,7 @@ export const service: <I, S>(service: ServiceMap.Service<I, S>) => Effect<S, nev
|
|
|
10532
10823
|
* @since 2.0.0
|
|
10533
10824
|
* @category ServiceMap
|
|
10534
10825
|
*/
|
|
10535
|
-
export const serviceOption: <I, S>(key: ServiceMap.
|
|
10826
|
+
export const serviceOption: <I, S>(key: ServiceMap.Key<I, S>) => Effect<Option<S>> = internal.serviceOption
|
|
10536
10827
|
|
|
10537
10828
|
/**
|
|
10538
10829
|
* Provides part of the required context while leaving the rest unchanged.
|
|
@@ -10721,7 +11012,7 @@ export const updateService: {
|
|
|
10721
11012
|
* @since 2.0.0
|
|
10722
11013
|
* @category ServiceMap
|
|
10723
11014
|
*/
|
|
10724
|
-
<I, A>(service: ServiceMap.
|
|
11015
|
+
<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
11016
|
/**
|
|
10726
11017
|
* Updates the service with the required service entry.
|
|
10727
11018
|
*
|
|
@@ -10750,11 +11041,7 @@ export const updateService: {
|
|
|
10750
11041
|
* @since 2.0.0
|
|
10751
11042
|
* @category ServiceMap
|
|
10752
11043
|
*/
|
|
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>
|
|
11044
|
+
<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
11045
|
} = internal.updateService
|
|
10759
11046
|
|
|
10760
11047
|
/**
|
|
@@ -10848,7 +11135,7 @@ export const provideService: {
|
|
|
10848
11135
|
* @since 2.0.0
|
|
10849
11136
|
* @category ServiceMap
|
|
10850
11137
|
*/
|
|
10851
|
-
<I, S>(service: ServiceMap.
|
|
11138
|
+
<I, S>(service: ServiceMap.Key<I, S>): {
|
|
10852
11139
|
/**
|
|
10853
11140
|
* The `provideService` function is used to provide an actual
|
|
10854
11141
|
* implementation for a service in the context of an effect.
|
|
@@ -10987,7 +11274,7 @@ export const provideService: {
|
|
|
10987
11274
|
* @since 2.0.0
|
|
10988
11275
|
* @category ServiceMap
|
|
10989
11276
|
*/
|
|
10990
|
-
<I, S>(service: ServiceMap.
|
|
11277
|
+
<I, S>(service: ServiceMap.Key<I, S>, implementation: S): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, Exclude<R, I>>
|
|
10991
11278
|
/**
|
|
10992
11279
|
* The `provideService` function is used to provide an actual
|
|
10993
11280
|
* implementation for a service in the context of an effect.
|
|
@@ -11033,11 +11320,7 @@ export const provideService: {
|
|
|
11033
11320
|
* @since 2.0.0
|
|
11034
11321
|
* @category ServiceMap
|
|
11035
11322
|
*/
|
|
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>>
|
|
11323
|
+
<A, E, R, I, S>(self: Effect<A, E, R>, service: ServiceMap.Key<I, S>, implementation: S): Effect<A, E, Exclude<R, I>>
|
|
11041
11324
|
} = internal.provideService
|
|
11042
11325
|
|
|
11043
11326
|
/**
|
|
@@ -11145,7 +11428,7 @@ export const provideServiceEffect: {
|
|
|
11145
11428
|
* @since 2.0.0
|
|
11146
11429
|
* @category ServiceMap
|
|
11147
11430
|
*/
|
|
11148
|
-
<I, S, E2, R2>(service: ServiceMap.
|
|
11431
|
+
<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
11432
|
/**
|
|
11150
11433
|
* Provides the effect with the single service it requires. If the effect
|
|
11151
11434
|
* requires more than one service use `provide` instead.
|
|
@@ -11200,7 +11483,7 @@ export const provideServiceEffect: {
|
|
|
11200
11483
|
*/
|
|
11201
11484
|
<A, E, R, I, S, E2, R2>(
|
|
11202
11485
|
self: Effect<A, E, R>,
|
|
11203
|
-
service: ServiceMap.
|
|
11486
|
+
service: ServiceMap.Key<I, S>,
|
|
11204
11487
|
acquire: Effect<S, E2, R2>
|
|
11205
11488
|
): Effect<A, E | E2, Exclude<R, I> | R2>
|
|
11206
11489
|
} = internal.provideServiceEffect
|
|
@@ -11813,7 +12096,7 @@ export const onError: {
|
|
|
11813
12096
|
|
|
11814
12097
|
/**
|
|
11815
12098
|
* Runs the finalizer only when this effect fails and the `Cause` matches the
|
|
11816
|
-
*
|
|
12099
|
+
* provided predicate.
|
|
11817
12100
|
*
|
|
11818
12101
|
* @example
|
|
11819
12102
|
* ```ts
|
|
@@ -11837,7 +12120,7 @@ export const onError: {
|
|
|
11837
12120
|
export const onErrorIf: {
|
|
11838
12121
|
/**
|
|
11839
12122
|
* Runs the finalizer only when this effect fails and the `Cause` matches the
|
|
11840
|
-
*
|
|
12123
|
+
* provided predicate.
|
|
11841
12124
|
*
|
|
11842
12125
|
* @example
|
|
11843
12126
|
* ```ts
|
|
@@ -11858,13 +12141,13 @@ export const onErrorIf: {
|
|
|
11858
12141
|
* @since 4.0.0
|
|
11859
12142
|
* @category Resource Management & Finalization
|
|
11860
12143
|
*/
|
|
11861
|
-
<E,
|
|
11862
|
-
|
|
11863
|
-
f: (
|
|
12144
|
+
<E, XE, XR>(
|
|
12145
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
12146
|
+
f: (cause: Cause.Cause<E>) => Effect<void, XE, XR>
|
|
11864
12147
|
): <A, R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>
|
|
11865
12148
|
/**
|
|
11866
12149
|
* Runs the finalizer only when this effect fails and the `Cause` matches the
|
|
11867
|
-
*
|
|
12150
|
+
* provided predicate.
|
|
11868
12151
|
*
|
|
11869
12152
|
* @example
|
|
11870
12153
|
* ```ts
|
|
@@ -11885,13 +12168,43 @@ export const onErrorIf: {
|
|
|
11885
12168
|
* @since 4.0.0
|
|
11886
12169
|
* @category Resource Management & Finalization
|
|
11887
12170
|
*/
|
|
11888
|
-
<A, E, R, XE, XR
|
|
12171
|
+
<A, E, R, XE, XR>(
|
|
11889
12172
|
self: Effect<A, E, R>,
|
|
11890
|
-
|
|
11891
|
-
f: (
|
|
12173
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
12174
|
+
f: (cause: Cause.Cause<E>) => Effect<void, XE, XR>
|
|
11892
12175
|
): Effect<A, E | XE, R | XR>
|
|
11893
12176
|
} = internal.onErrorIf
|
|
11894
12177
|
|
|
12178
|
+
/**
|
|
12179
|
+
* Runs the finalizer only when this effect fails and the cause matches the provided `Filter`.
|
|
12180
|
+
*
|
|
12181
|
+
* @since 4.0.0
|
|
12182
|
+
* @category Resource Management & Finalization
|
|
12183
|
+
*/
|
|
12184
|
+
export const onErrorFilter: {
|
|
12185
|
+
/**
|
|
12186
|
+
* Runs the finalizer only when this effect fails and the cause matches the provided `Filter`.
|
|
12187
|
+
*
|
|
12188
|
+
* @since 4.0.0
|
|
12189
|
+
* @category Resource Management & Finalization
|
|
12190
|
+
*/
|
|
12191
|
+
<A, E, EB, X, XE, XR>(
|
|
12192
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
12193
|
+
f: (failure: EB, cause: Cause.Cause<E>) => Effect<void, XE, XR>
|
|
12194
|
+
): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>
|
|
12195
|
+
/**
|
|
12196
|
+
* Runs the finalizer only when this effect fails and the cause matches the provided `Filter`.
|
|
12197
|
+
*
|
|
12198
|
+
* @since 4.0.0
|
|
12199
|
+
* @category Resource Management & Finalization
|
|
12200
|
+
*/
|
|
12201
|
+
<A, E, R, EB, X, XE, XR>(
|
|
12202
|
+
self: Effect<A, E, R>,
|
|
12203
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
12204
|
+
f: (failure: EB, cause: Cause.Cause<E>) => Effect<void, XE, XR>
|
|
12205
|
+
): Effect<A, E | XE, R | XR>
|
|
12206
|
+
} = internal.onErrorFilter
|
|
12207
|
+
|
|
11895
12208
|
/**
|
|
11896
12209
|
* The low level primitive that powers `onExit`.
|
|
11897
12210
|
* function is used to run a finalizer when the effect exits, regardless of the
|
|
@@ -11990,20 +12303,20 @@ export const onExit: {
|
|
|
11990
12303
|
} = internal.onExit
|
|
11991
12304
|
|
|
11992
12305
|
/**
|
|
11993
|
-
* Runs the cleanup effect only when the `Exit`
|
|
11994
|
-
*
|
|
11995
|
-
* The cleanup is skipped when the filter returns `Filter.fail`.
|
|
12306
|
+
* Runs the cleanup effect only when the `Exit` satisfies the provided
|
|
12307
|
+
* predicate.
|
|
11996
12308
|
*
|
|
11997
12309
|
* @example
|
|
11998
12310
|
* ```ts
|
|
11999
|
-
* import { Console, Effect, Exit
|
|
12000
|
-
*
|
|
12001
|
-
* const exitFilter = Filter.fromPredicate(Exit.isSuccess<number, never>)
|
|
12311
|
+
* import { Console, Effect, Exit } from "effect"
|
|
12002
12312
|
*
|
|
12003
12313
|
* const program = Effect.onExitIf(
|
|
12004
12314
|
* Effect.succeed(42),
|
|
12005
|
-
*
|
|
12006
|
-
* (
|
|
12315
|
+
* Exit.isSuccess,
|
|
12316
|
+
* (exit) =>
|
|
12317
|
+
* Exit.isSuccess(exit)
|
|
12318
|
+
* ? Console.log(`Succeeded with: ${exit.value}`)
|
|
12319
|
+
* : Effect.void
|
|
12007
12320
|
* )
|
|
12008
12321
|
* ```
|
|
12009
12322
|
*
|
|
@@ -12012,63 +12325,87 @@ export const onExit: {
|
|
|
12012
12325
|
*/
|
|
12013
12326
|
export const onExitIf: {
|
|
12014
12327
|
/**
|
|
12015
|
-
* Runs the cleanup effect only when the `Exit`
|
|
12016
|
-
*
|
|
12017
|
-
* The cleanup is skipped when the filter returns `Filter.fail`.
|
|
12328
|
+
* Runs the cleanup effect only when the `Exit` satisfies the provided
|
|
12329
|
+
* predicate.
|
|
12018
12330
|
*
|
|
12019
12331
|
* @example
|
|
12020
12332
|
* ```ts
|
|
12021
|
-
* import { Console, Effect, Exit
|
|
12022
|
-
*
|
|
12023
|
-
* const exitFilter = Filter.fromPredicate(Exit.isSuccess<number, never>)
|
|
12333
|
+
* import { Console, Effect, Exit } from "effect"
|
|
12024
12334
|
*
|
|
12025
12335
|
* const program = Effect.onExitIf(
|
|
12026
12336
|
* Effect.succeed(42),
|
|
12027
|
-
*
|
|
12028
|
-
* (
|
|
12337
|
+
* Exit.isSuccess,
|
|
12338
|
+
* (exit) =>
|
|
12339
|
+
* Exit.isSuccess(exit)
|
|
12340
|
+
* ? Console.log(`Succeeded with: ${exit.value}`)
|
|
12341
|
+
* : Effect.void
|
|
12029
12342
|
* )
|
|
12030
12343
|
* ```
|
|
12031
12344
|
*
|
|
12032
12345
|
* @since 4.0.0
|
|
12033
12346
|
* @category Resource Management & Finalization
|
|
12034
12347
|
*/
|
|
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>
|
|
12348
|
+
<A, E, XE, XR>(
|
|
12349
|
+
predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>,
|
|
12350
|
+
f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>
|
|
12041
12351
|
): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>
|
|
12042
12352
|
/**
|
|
12043
|
-
* Runs the cleanup effect only when the `Exit`
|
|
12044
|
-
*
|
|
12045
|
-
* The cleanup is skipped when the filter returns `Filter.fail`.
|
|
12353
|
+
* Runs the cleanup effect only when the `Exit` satisfies the provided
|
|
12354
|
+
* predicate.
|
|
12046
12355
|
*
|
|
12047
12356
|
* @example
|
|
12048
12357
|
* ```ts
|
|
12049
|
-
* import { Console, Effect, Exit
|
|
12050
|
-
*
|
|
12051
|
-
* const exitFilter = Filter.fromPredicate(Exit.isSuccess<number, never>)
|
|
12358
|
+
* import { Console, Effect, Exit } from "effect"
|
|
12052
12359
|
*
|
|
12053
12360
|
* const program = Effect.onExitIf(
|
|
12054
12361
|
* Effect.succeed(42),
|
|
12055
|
-
*
|
|
12056
|
-
* (
|
|
12362
|
+
* Exit.isSuccess,
|
|
12363
|
+
* (exit) =>
|
|
12364
|
+
* Exit.isSuccess(exit)
|
|
12365
|
+
* ? Console.log(`Succeeded with: ${exit.value}`)
|
|
12366
|
+
* : Effect.void
|
|
12057
12367
|
* )
|
|
12058
12368
|
* ```
|
|
12059
12369
|
*
|
|
12060
12370
|
* @since 4.0.0
|
|
12061
12371
|
* @category Resource Management & Finalization
|
|
12062
12372
|
*/
|
|
12063
|
-
<A, E, R, XE, XR
|
|
12373
|
+
<A, E, R, XE, XR>(
|
|
12374
|
+
self: Effect<A, E, R>,
|
|
12375
|
+
predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>,
|
|
12376
|
+
f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>
|
|
12377
|
+
): Effect<A, E | XE, R | XR>
|
|
12378
|
+
} = internal.onExitIf
|
|
12379
|
+
|
|
12380
|
+
/**
|
|
12381
|
+
* Runs the cleanup effect only when the `Exit` matches the provided `Filter`.
|
|
12382
|
+
*
|
|
12383
|
+
* @since 4.0.0
|
|
12384
|
+
* @category Resource Management & Finalization
|
|
12385
|
+
*/
|
|
12386
|
+
export const onExitFilter: {
|
|
12387
|
+
/**
|
|
12388
|
+
* Runs the cleanup effect only when the `Exit` matches the provided `Filter`.
|
|
12389
|
+
*
|
|
12390
|
+
* @since 4.0.0
|
|
12391
|
+
* @category Resource Management & Finalization
|
|
12392
|
+
*/
|
|
12393
|
+
<A, E, XE, XR, B, X>(
|
|
12394
|
+
filter: Filter.Filter<Exit.Exit<NoInfer<A>, NoInfer<E>>, B, X>,
|
|
12395
|
+
f: (b: B, exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>
|
|
12396
|
+
): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>
|
|
12397
|
+
/**
|
|
12398
|
+
* Runs the cleanup effect only when the `Exit` matches the provided `Filter`.
|
|
12399
|
+
*
|
|
12400
|
+
* @since 4.0.0
|
|
12401
|
+
* @category Resource Management & Finalization
|
|
12402
|
+
*/
|
|
12403
|
+
<A, E, R, XE, XR, B, X>(
|
|
12064
12404
|
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>
|
|
12405
|
+
filter: Filter.Filter<Exit.Exit<NoInfer<A>, NoInfer<E>>, B, X>,
|
|
12406
|
+
f: (b: B, exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>
|
|
12070
12407
|
): Effect<A, E | XE, R | XR>
|
|
12071
|
-
} = internal.
|
|
12408
|
+
} = internal.onExitFilter
|
|
12072
12409
|
|
|
12073
12410
|
// -----------------------------------------------------------------------------
|
|
12074
12411
|
// Caching
|
|
@@ -12272,7 +12609,7 @@ export const cachedWithTTL: {
|
|
|
12272
12609
|
* @since 2.0.0
|
|
12273
12610
|
* @category Caching
|
|
12274
12611
|
*/
|
|
12275
|
-
(timeToLive: Duration.
|
|
12612
|
+
(timeToLive: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<Effect<A, E, R>>
|
|
12276
12613
|
/**
|
|
12277
12614
|
* Returns an effect that caches its result for a specified `Duration`,
|
|
12278
12615
|
* known as "timeToLive" (TTL).
|
|
@@ -12339,7 +12676,7 @@ export const cachedWithTTL: {
|
|
|
12339
12676
|
* @since 2.0.0
|
|
12340
12677
|
* @category Caching
|
|
12341
12678
|
*/
|
|
12342
|
-
<A, E, R>(self: Effect<A, E, R>, timeToLive: Duration.
|
|
12679
|
+
<A, E, R>(self: Effect<A, E, R>, timeToLive: Duration.Input): Effect<Effect<A, E, R>>
|
|
12343
12680
|
} = internal.cachedWithTTL
|
|
12344
12681
|
|
|
12345
12682
|
/**
|
|
@@ -12481,7 +12818,7 @@ export const cachedInvalidateWithTTL: {
|
|
|
12481
12818
|
* @since 2.0.0
|
|
12482
12819
|
* @category Caching
|
|
12483
12820
|
*/
|
|
12484
|
-
(timeToLive: Duration.
|
|
12821
|
+
(timeToLive: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<[Effect<A, E, R>, Effect<void>]>
|
|
12485
12822
|
/**
|
|
12486
12823
|
* Caches an effect's result for a specified duration and allows manual
|
|
12487
12824
|
* invalidation before expiration.
|
|
@@ -12551,7 +12888,7 @@ export const cachedInvalidateWithTTL: {
|
|
|
12551
12888
|
* @since 2.0.0
|
|
12552
12889
|
* @category Caching
|
|
12553
12890
|
*/
|
|
12554
|
-
<A, E, R>(self: Effect<A, E, R>, timeToLive: Duration.
|
|
12891
|
+
<A, E, R>(self: Effect<A, E, R>, timeToLive: Duration.Input): Effect<[Effect<A, E, R>, Effect<void>]>
|
|
12555
12892
|
} = internal.cachedInvalidateWithTTL
|
|
12556
12893
|
|
|
12557
12894
|
// -----------------------------------------------------------------------------
|
|
@@ -12777,252 +13114,6 @@ export const interruptibleMask: <A, E, R>(
|
|
|
12777
13114
|
) => Effect<A, E, R>
|
|
12778
13115
|
) => Effect<A, E, R> = internal.interruptibleMask
|
|
12779
13116
|
|
|
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
13117
|
// -----------------------------------------------------------------------------
|
|
13027
13118
|
// Repetition & Recursion
|
|
13028
13119
|
// -----------------------------------------------------------------------------
|
|
@@ -20339,7 +20430,7 @@ export const clockWith: <A, E, R>(
|
|
|
20339
20430
|
* @since 2.0.0
|
|
20340
20431
|
* @category Logging
|
|
20341
20432
|
*/
|
|
20342
|
-
export const logWithLevel: (level?:
|
|
20433
|
+
export const logWithLevel: (level?: Severity) => (...message: ReadonlyArray<any>) => Effect<void> =
|
|
20343
20434
|
internal.logWithLevel
|
|
20344
20435
|
|
|
20345
20436
|
/**
|
|
@@ -20767,6 +20858,86 @@ export const annotateLogs = dual<
|
|
|
20767
20858
|
})
|
|
20768
20859
|
)
|
|
20769
20860
|
|
|
20861
|
+
/**
|
|
20862
|
+
* Adds log annotations to the current scope.
|
|
20863
|
+
*
|
|
20864
|
+
* This differs from `annotateLogs`, which only annotates a specific effect.
|
|
20865
|
+
* `annotateLogsScoped` updates annotations for the entire current `Scope` and
|
|
20866
|
+
* restores the previous annotations when the scope closes.
|
|
20867
|
+
*
|
|
20868
|
+
* @example
|
|
20869
|
+
* ```ts
|
|
20870
|
+
* import { Effect } from "effect"
|
|
20871
|
+
*
|
|
20872
|
+
* const program = Effect.scoped(
|
|
20873
|
+
* Effect.gen(function*() {
|
|
20874
|
+
* yield* Effect.log("before")
|
|
20875
|
+
* yield* Effect.annotateLogsScoped({ requestId: "req-123" })
|
|
20876
|
+
* yield* Effect.log("inside scope")
|
|
20877
|
+
* })
|
|
20878
|
+
* )
|
|
20879
|
+
*
|
|
20880
|
+
* Effect.runPromise(program)
|
|
20881
|
+
* ```
|
|
20882
|
+
*
|
|
20883
|
+
* @since 4.0.0
|
|
20884
|
+
* @category Logging
|
|
20885
|
+
*/
|
|
20886
|
+
export const annotateLogsScoped: {
|
|
20887
|
+
/**
|
|
20888
|
+
* Adds log annotations to the current scope.
|
|
20889
|
+
*
|
|
20890
|
+
* This differs from `annotateLogs`, which only annotates a specific effect.
|
|
20891
|
+
* `annotateLogsScoped` updates annotations for the entire current `Scope` and
|
|
20892
|
+
* restores the previous annotations when the scope closes.
|
|
20893
|
+
*
|
|
20894
|
+
* @example
|
|
20895
|
+
* ```ts
|
|
20896
|
+
* import { Effect } from "effect"
|
|
20897
|
+
*
|
|
20898
|
+
* const program = Effect.scoped(
|
|
20899
|
+
* Effect.gen(function*() {
|
|
20900
|
+
* yield* Effect.log("before")
|
|
20901
|
+
* yield* Effect.annotateLogsScoped({ requestId: "req-123" })
|
|
20902
|
+
* yield* Effect.log("inside scope")
|
|
20903
|
+
* })
|
|
20904
|
+
* )
|
|
20905
|
+
*
|
|
20906
|
+
* Effect.runPromise(program)
|
|
20907
|
+
* ```
|
|
20908
|
+
*
|
|
20909
|
+
* @since 4.0.0
|
|
20910
|
+
* @category Logging
|
|
20911
|
+
*/
|
|
20912
|
+
(key: string, value: unknown): Effect<void, never, Scope>
|
|
20913
|
+
/**
|
|
20914
|
+
* Adds log annotations to the current scope.
|
|
20915
|
+
*
|
|
20916
|
+
* This differs from `annotateLogs`, which only annotates a specific effect.
|
|
20917
|
+
* `annotateLogsScoped` updates annotations for the entire current `Scope` and
|
|
20918
|
+
* restores the previous annotations when the scope closes.
|
|
20919
|
+
*
|
|
20920
|
+
* @example
|
|
20921
|
+
* ```ts
|
|
20922
|
+
* import { Effect } from "effect"
|
|
20923
|
+
*
|
|
20924
|
+
* const program = Effect.scoped(
|
|
20925
|
+
* Effect.gen(function*() {
|
|
20926
|
+
* yield* Effect.log("before")
|
|
20927
|
+
* yield* Effect.annotateLogsScoped({ requestId: "req-123" })
|
|
20928
|
+
* yield* Effect.log("inside scope")
|
|
20929
|
+
* })
|
|
20930
|
+
* )
|
|
20931
|
+
*
|
|
20932
|
+
* Effect.runPromise(program)
|
|
20933
|
+
* ```
|
|
20934
|
+
*
|
|
20935
|
+
* @since 4.0.0
|
|
20936
|
+
* @category Logging
|
|
20937
|
+
*/
|
|
20938
|
+
(values: Record<string, unknown>): Effect<void, never, Scope>
|
|
20939
|
+
} = internal.annotateLogsScoped
|
|
20940
|
+
|
|
20770
20941
|
/**
|
|
20771
20942
|
* Adds a span to each log line in this effect.
|
|
20772
20943
|
*
|
|
@@ -22151,8 +22322,8 @@ export const trackDuration: {
|
|
|
22151
22322
|
return onExit(self, () => {
|
|
22152
22323
|
const endTime = clock.currentTimeNanosUnsafe()
|
|
22153
22324
|
const duration = Duration.subtract(
|
|
22154
|
-
Duration.
|
|
22155
|
-
Duration.
|
|
22325
|
+
Duration.fromInputUnsafe(endTime),
|
|
22326
|
+
Duration.fromInputUnsafe(startTime)
|
|
22156
22327
|
)
|
|
22157
22328
|
const input = f === undefined ? duration : internalCall(() => f(duration))
|
|
22158
22329
|
return Metric.update(metric, input as any)
|
|
@@ -22200,136 +22371,70 @@ export class Transaction extends ServiceMap.Service<
|
|
|
22200
22371
|
>()("effect/Effect/Transaction") {}
|
|
22201
22372
|
|
|
22202
22373
|
/**
|
|
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.
|
|
22374
|
+
* Accesses the current transaction state within an active transaction.
|
|
22213
22375
|
*
|
|
22214
|
-
*
|
|
22215
|
-
*
|
|
22376
|
+
* This function requires `Transaction` in the context and does NOT create or strip
|
|
22377
|
+
* transaction boundaries. Use it to interact with the transaction journal (e.g. in
|
|
22378
|
+
* `TxRef` internals). To define a transaction boundary, use {@link transaction}.
|
|
22216
22379
|
*
|
|
22217
22380
|
* @example
|
|
22218
22381
|
* ```ts
|
|
22219
22382
|
* import { Effect, TxRef } from "effect"
|
|
22220
22383
|
*
|
|
22221
22384
|
* 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}`)
|
|
22385
|
+
* const ref = yield* Effect.transaction(TxRef.make(0))
|
|
22259
22386
|
*
|
|
22387
|
+
* yield* Effect.transaction(Effect.gen(function*() {
|
|
22260
22388
|
* yield* TxRef.set(ref, 42)
|
|
22261
22389
|
* return yield* TxRef.get(ref)
|
|
22262
|
-
* })
|
|
22263
|
-
* )
|
|
22264
|
-
*
|
|
22265
|
-
* Effect.runPromise(program).then(console.log) // 42
|
|
22390
|
+
* }))
|
|
22391
|
+
* })
|
|
22266
22392
|
* ```
|
|
22267
22393
|
*
|
|
22268
22394
|
* @since 4.0.0
|
|
22269
22395
|
* @category Transactions
|
|
22270
22396
|
*/
|
|
22271
|
-
export const
|
|
22397
|
+
export const withTxState = <A, E, R>(
|
|
22272
22398
|
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
|
-
})
|
|
22399
|
+
): Effect<A, E, R | Transaction> =>
|
|
22400
|
+
flatMap(
|
|
22401
|
+
Transaction.asEffect(),
|
|
22402
|
+
(state) => internalCall(() => f(state))
|
|
22403
|
+
)
|
|
22286
22404
|
|
|
22287
22405
|
/**
|
|
22288
|
-
*
|
|
22406
|
+
* Defines a transaction boundary. Transactions are "all or nothing" with respect to changes
|
|
22407
|
+
* made to transactional values (i.e. TxRef) that occur within the transaction body.
|
|
22289
22408
|
*
|
|
22290
|
-
*
|
|
22409
|
+
* In Effect transactions are optimistic with retry, that means transactions are retried when:
|
|
22291
22410
|
*
|
|
22292
|
-
*
|
|
22293
|
-
*
|
|
22294
|
-
* This ensures complete isolation between different transaction scopes.
|
|
22411
|
+
* - the body of the transaction explicitely calls to `Effect.retryTransaction` and any of the
|
|
22412
|
+
* accessed transactional values changes.
|
|
22295
22413
|
*
|
|
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
|
|
22414
|
+
* - any of the accessed transactional values change during the execution of the transaction
|
|
22415
|
+
* due to a different transaction committing before the current.
|
|
22301
22416
|
*
|
|
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
|
|
22417
|
+
* Each call to `transaction` always creates a new isolated transaction boundary with its own
|
|
22418
|
+
* journal and retry logic.
|
|
22306
22419
|
*
|
|
22307
22420
|
* @example
|
|
22308
22421
|
* ```ts
|
|
22309
22422
|
* import { Effect, TxRef } from "effect"
|
|
22310
22423
|
*
|
|
22311
22424
|
* 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
|
-
* }))
|
|
22425
|
+
* const ref1 = yield* Effect.transaction(TxRef.make(0))
|
|
22426
|
+
* const ref2 = yield* Effect.transaction(TxRef.make(0))
|
|
22324
22427
|
*
|
|
22325
|
-
* //
|
|
22428
|
+
* // All operations within transaction block succeed or fail together
|
|
22326
22429
|
* yield* Effect.transaction(Effect.gen(function*() {
|
|
22327
|
-
* yield* TxRef.set(
|
|
22430
|
+
* yield* TxRef.set(ref1, 10)
|
|
22431
|
+
* yield* TxRef.set(ref2, 20)
|
|
22432
|
+
* const sum = (yield* TxRef.get(ref1)) + (yield* TxRef.get(ref2))
|
|
22433
|
+
* console.log(`Transaction sum: ${sum}`)
|
|
22328
22434
|
* }))
|
|
22329
22435
|
*
|
|
22330
|
-
*
|
|
22331
|
-
*
|
|
22332
|
-
* return { ref1: val1, ref2: val2 }
|
|
22436
|
+
* console.log(`Final ref1: ${yield* Effect.transaction(TxRef.get(ref1))}`) // 10
|
|
22437
|
+
* console.log(`Final ref2: ${yield* Effect.transaction(TxRef.get(ref2))}`) // 20
|
|
22333
22438
|
* })
|
|
22334
22439
|
* ```
|
|
22335
22440
|
*
|
|
@@ -22341,34 +22446,21 @@ export const transaction = <A, E, R>(
|
|
|
22341
22446
|
): Effect<A, E, Exclude<R, Transaction>> => transactionWith(() => effect)
|
|
22342
22447
|
|
|
22343
22448
|
/**
|
|
22344
|
-
*
|
|
22449
|
+
* Like {@link transaction} but provides access to the transaction state.
|
|
22345
22450
|
*
|
|
22346
|
-
*
|
|
22347
|
-
* within another transaction. This ensures complete isolation between transaction scopes.
|
|
22451
|
+
* Always creates a new isolated transaction boundary with its own journal and retry logic.
|
|
22348
22452
|
*
|
|
22349
22453
|
* @example
|
|
22350
22454
|
* ```ts
|
|
22351
22455
|
* import { Effect, TxRef } from "effect"
|
|
22352
22456
|
*
|
|
22353
|
-
* const program = Effect.transactionWith((
|
|
22457
|
+
* const program = Effect.transactionWith((_txState) =>
|
|
22354
22458
|
* Effect.gen(function*() {
|
|
22355
22459
|
* 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
22460
|
* yield* TxRef.set(ref, 42)
|
|
22361
22461
|
* return yield* TxRef.get(ref)
|
|
22362
22462
|
* })
|
|
22363
22463
|
* )
|
|
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
22464
|
* ```
|
|
22373
22465
|
*
|
|
22374
22466
|
* @since 4.0.0
|
|
@@ -22476,16 +22568,16 @@ function clearTransaction(state: Transaction["Service"]) {
|
|
|
22476
22568
|
*
|
|
22477
22569
|
* const program = Effect.gen(function*() {
|
|
22478
22570
|
* // create a transactional reference
|
|
22479
|
-
* const ref = yield* TxRef.make(0)
|
|
22571
|
+
* const ref = yield* Effect.transaction(TxRef.make(0))
|
|
22480
22572
|
*
|
|
22481
22573
|
* // forks a fiber that increases the value of `ref` every 100 millis
|
|
22482
22574
|
* yield* Effect.forkChild(Effect.forever(
|
|
22483
22575
|
* // update to transactional value
|
|
22484
|
-
* TxRef.update(ref, (n) => n + 1).pipe(Effect.delay("100 millis"))
|
|
22576
|
+
* Effect.transaction(TxRef.update(ref, (n) => n + 1)).pipe(Effect.delay("100 millis"))
|
|
22485
22577
|
* ))
|
|
22486
22578
|
*
|
|
22487
22579
|
* // the following will retry 10 times until the `ref` value is 10
|
|
22488
|
-
* yield* Effect.
|
|
22580
|
+
* yield* Effect.transaction(Effect.gen(function*() {
|
|
22489
22581
|
* const value = yield* TxRef.get(ref)
|
|
22490
22582
|
* if (value < 10) {
|
|
22491
22583
|
* yield* Effect.log(`retry due to value: ${value}`)
|