effect 4.0.0-beta.6 → 4.0.0-beta.62
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 +213 -385
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +149 -102
- package/dist/Array.js.map +1 -1
- package/dist/BigDecimal.d.ts +82 -45
- package/dist/BigDecimal.d.ts.map +1 -1
- package/dist/BigDecimal.js +105 -52
- package/dist/BigDecimal.js.map +1 -1
- package/dist/BigInt.d.ts +39 -32
- package/dist/BigInt.d.ts.map +1 -1
- package/dist/BigInt.js +36 -33
- package/dist/BigInt.js.map +1 -1
- package/dist/Brand.d.ts +3 -5
- package/dist/Brand.d.ts.map +1 -1
- package/dist/Brand.js +1 -1
- package/dist/Brand.js.map +1 -1
- package/dist/Cache.d.ts +14 -45
- package/dist/Cache.d.ts.map +1 -1
- package/dist/Cache.js +21 -47
- package/dist/Cache.js.map +1 -1
- package/dist/Cause.d.ts +53 -22
- package/dist/Cause.d.ts.map +1 -1
- package/dist/Cause.js +108 -10
- package/dist/Cause.js.map +1 -1
- package/dist/Channel.d.ts +166 -48
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +176 -87
- package/dist/Channel.js.map +1 -1
- package/dist/Chunk.d.ts +112 -304
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Chunk.js +56 -88
- package/dist/Chunk.js.map +1 -1
- package/dist/Clock.d.ts +2 -2
- package/dist/Clock.d.ts.map +1 -1
- package/dist/Clock.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 +189 -29
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +85 -35
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.d.ts +6 -6
- package/dist/ConfigProvider.d.ts.map +1 -1
- package/dist/ConfigProvider.js +5 -5
- package/dist/ConfigProvider.js.map +1 -1
- package/dist/Console.d.ts +2 -2
- package/dist/Console.d.ts.map +1 -1
- package/dist/Console.js.map +1 -1
- package/dist/Context.d.ts +1150 -0
- package/dist/Context.d.ts.map +1 -0
- package/dist/{ServiceMap.js → Context.js} +181 -165
- package/dist/Context.js.map +1 -0
- package/dist/Cron.d.ts +11 -7
- package/dist/Cron.d.ts.map +1 -1
- package/dist/Cron.js +120 -63
- package/dist/Cron.js.map +1 -1
- package/dist/Data.d.ts +533 -365
- package/dist/Data.d.ts.map +1 -1
- package/dist/Data.js +125 -73
- package/dist/Data.js.map +1 -1
- package/dist/DateTime.d.ts +74 -255
- package/dist/DateTime.d.ts.map +1 -1
- package/dist/DateTime.js +17 -62
- package/dist/DateTime.js.map +1 -1
- package/dist/Deferred.d.ts +12 -5
- package/dist/Deferred.d.ts.map +1 -1
- package/dist/Deferred.js +13 -5
- package/dist/Deferred.js.map +1 -1
- package/dist/Duration.d.ts +74 -40
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +126 -87
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts +1435 -927
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +516 -328
- package/dist/Effect.js.map +1 -1
- package/dist/Effectable.d.ts +29 -0
- package/dist/Effectable.d.ts.map +1 -0
- package/dist/Effectable.js +31 -0
- package/dist/Effectable.js.map +1 -0
- package/dist/Encoding.d.ts +1 -1
- package/dist/Equal.d.ts +276 -109
- package/dist/Equal.d.ts.map +1 -1
- package/dist/Equal.js +140 -48
- package/dist/Equal.js.map +1 -1
- package/dist/Equivalence.d.ts +60 -3
- package/dist/Equivalence.d.ts.map +1 -1
- package/dist/Equivalence.js +70 -13
- package/dist/Equivalence.js.map +1 -1
- package/dist/ErrorReporter.d.ts +374 -0
- package/dist/ErrorReporter.d.ts.map +1 -0
- package/dist/ErrorReporter.js +245 -0
- package/dist/ErrorReporter.js.map +1 -0
- package/dist/ExecutionPlan.d.ts +6 -6
- package/dist/ExecutionPlan.d.ts.map +1 -1
- package/dist/ExecutionPlan.js +4 -4
- package/dist/ExecutionPlan.js.map +1 -1
- package/dist/Exit.d.ts +24 -12
- package/dist/Exit.d.ts.map +1 -1
- package/dist/Exit.js +8 -4
- package/dist/Exit.js.map +1 -1
- package/dist/Fiber.d.ts +10 -8
- package/dist/Fiber.d.ts.map +1 -1
- package/dist/Fiber.js.map +1 -1
- package/dist/FiberHandle.d.ts +11 -10
- package/dist/FiberHandle.d.ts.map +1 -1
- package/dist/FiberHandle.js +12 -11
- package/dist/FiberHandle.js.map +1 -1
- package/dist/FiberMap.d.ts +22 -21
- package/dist/FiberMap.d.ts.map +1 -1
- package/dist/FiberMap.js +10 -10
- package/dist/FiberMap.js.map +1 -1
- package/dist/FiberSet.d.ts +2 -2
- package/dist/FiberSet.d.ts.map +1 -1
- package/dist/FiberSet.js +4 -4
- package/dist/FiberSet.js.map +1 -1
- package/dist/FileSystem.d.ts +20 -19
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js +15 -11
- package/dist/FileSystem.js.map +1 -1
- package/dist/Filter.d.ts +4 -37
- package/dist/Filter.d.ts.map +1 -1
- package/dist/Filter.js +0 -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 +243 -55
- package/dist/Formatter.js.map +1 -1
- package/dist/Function.d.ts +1 -9
- package/dist/Function.d.ts.map +1 -1
- package/dist/Function.js +2 -10
- package/dist/Function.js.map +1 -1
- package/dist/Graph.d.ts +65 -65
- package/dist/Graph.d.ts.map +1 -1
- package/dist/Graph.js +58 -60
- package/dist/Graph.js.map +1 -1
- package/dist/Hash.js +1 -1
- package/dist/Hash.js.map +1 -1
- package/dist/HashMap.d.ts +26 -19
- package/dist/HashMap.d.ts.map +1 -1
- package/dist/HashMap.js +7 -5
- package/dist/HashMap.js.map +1 -1
- package/dist/Inspectable.d.ts +0 -4
- package/dist/Inspectable.d.ts.map +1 -1
- package/dist/Inspectable.js +4 -13
- package/dist/Inspectable.js.map +1 -1
- package/dist/Iterable.d.ts +50 -50
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +106 -34
- 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 +69 -3
- package/dist/Latch.d.ts.map +1 -1
- package/dist/Latch.js +58 -0
- package/dist/Latch.js.map +1 -1
- package/dist/Layer.d.ts +599 -379
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +249 -180
- package/dist/Layer.js.map +1 -1
- package/dist/LayerMap.d.ts +27 -26
- package/dist/LayerMap.d.ts.map +1 -1
- package/dist/LayerMap.js +21 -18
- package/dist/LayerMap.js.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 +31 -97
- 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 +8 -8
- package/dist/ManagedRuntime.d.ts.map +1 -1
- package/dist/ManagedRuntime.js +34 -25
- package/dist/ManagedRuntime.js.map +1 -1
- package/dist/Metric.d.ts +23 -25
- package/dist/Metric.d.ts.map +1 -1
- package/dist/Metric.js +24 -26
- package/dist/Metric.js.map +1 -1
- package/dist/MutableHashMap.d.ts +7 -0
- package/dist/MutableHashMap.d.ts.map +1 -1
- package/dist/MutableHashMap.js +8 -0
- package/dist/MutableHashMap.js.map +1 -1
- package/dist/MutableHashSet.d.ts +7 -0
- package/dist/MutableHashSet.d.ts.map +1 -1
- package/dist/MutableHashSet.js +8 -0
- package/dist/MutableHashSet.js.map +1 -1
- package/dist/MutableList.d.ts.map +1 -1
- package/dist/MutableList.js +3 -0
- package/dist/MutableList.js.map +1 -1
- package/dist/Newtype.d.ts +291 -0
- package/dist/Newtype.d.ts.map +1 -0
- package/dist/Newtype.js +161 -0
- package/dist/Newtype.js.map +1 -0
- package/dist/Number.d.ts +74 -18
- package/dist/Number.d.ts.map +1 -1
- package/dist/Number.js +46 -18
- package/dist/Number.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 +25 -16
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js +15 -9
- package/dist/Option.js.map +1 -1
- package/dist/Order.d.ts +6 -1
- package/dist/Order.d.ts.map +1 -1
- package/dist/Order.js +19 -14
- package/dist/Order.js.map +1 -1
- package/dist/PartitionedSemaphore.d.ts +183 -0
- package/dist/PartitionedSemaphore.d.ts.map +1 -0
- package/dist/PartitionedSemaphore.js +231 -0
- package/dist/PartitionedSemaphore.js.map +1 -0
- package/dist/Path.d.ts +2 -2
- package/dist/Path.d.ts.map +1 -1
- package/dist/Path.js +2 -2
- package/dist/Path.js.map +1 -1
- package/dist/PlatformError.d.ts +2 -2
- package/dist/Pool.d.ts +1 -1
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +5 -5
- package/dist/Pool.js.map +1 -1
- package/dist/Predicate.d.ts +1 -1
- package/dist/Predicate.d.ts.map +1 -1
- package/dist/PubSub.d.ts +5 -4
- package/dist/PubSub.d.ts.map +1 -1
- package/dist/PubSub.js +15 -8
- 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 +9 -6
- package/dist/Queue.d.ts.map +1 -1
- package/dist/Queue.js +7 -5
- package/dist/Queue.js.map +1 -1
- package/dist/Random.d.ts +36 -2
- package/dist/Random.d.ts.map +1 -1
- package/dist/Random.js +46 -35
- package/dist/Random.js.map +1 -1
- package/dist/RcMap.d.ts +4 -4
- package/dist/RcMap.d.ts.map +1 -1
- package/dist/RcMap.js +13 -13
- 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 +63 -160
- package/dist/Record.d.ts.map +1 -1
- package/dist/Record.js +37 -56
- package/dist/Record.js.map +1 -1
- package/dist/Redactable.d.ts +139 -62
- package/dist/Redactable.d.ts.map +1 -1
- package/dist/Redactable.js +59 -55
- package/dist/Redactable.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 +257 -229
- package/dist/References.d.ts.map +1 -1
- package/dist/References.js +240 -259
- package/dist/References.js.map +1 -1
- package/dist/Request.d.ts +5 -5
- package/dist/Request.d.ts.map +1 -1
- package/dist/Request.js.map +1 -1
- package/dist/RequestResolver.d.ts +25 -25
- package/dist/RequestResolver.d.ts.map +1 -1
- package/dist/RequestResolver.js +15 -16
- package/dist/RequestResolver.js.map +1 -1
- package/dist/Resource.d.ts +0 -3
- package/dist/Resource.d.ts.map +1 -1
- package/dist/Resource.js +5 -4
- package/dist/Resource.js.map +1 -1
- package/dist/Result.d.ts +1 -1
- package/dist/Result.d.ts.map +1 -1
- package/dist/Result.js +1 -2
- package/dist/Result.js.map +1 -1
- package/dist/Runtime.d.ts +66 -0
- package/dist/Runtime.d.ts.map +1 -1
- package/dist/Runtime.js +79 -6
- package/dist/Runtime.js.map +1 -1
- package/dist/Schedule.d.ts +174 -291
- package/dist/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js +132 -120
- package/dist/Schedule.js.map +1 -1
- package/dist/Scheduler.d.ts +36 -125
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/Scheduler.js +37 -126
- package/dist/Scheduler.js.map +1 -1
- package/dist/Schema.d.ts +3213 -392
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +2058 -252
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +13 -2
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +340 -257
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaGetter.d.ts +55 -13
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +73 -11
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaIssue.d.ts.map +1 -1
- package/dist/SchemaIssue.js +29 -11
- package/dist/SchemaIssue.js.map +1 -1
- package/dist/SchemaParser.d.ts +44 -54
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +69 -4
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +2 -2
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +63 -39
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +245 -3
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +297 -33
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/Scope.d.ts +2 -2
- package/dist/Scope.d.ts.map +1 -1
- package/dist/Scope.js.map +1 -1
- package/dist/ScopedCache.d.ts +2 -2
- package/dist/ScopedCache.d.ts.map +1 -1
- package/dist/ScopedCache.js +5 -5
- package/dist/ScopedCache.js.map +1 -1
- package/dist/Semaphore.d.ts +148 -52
- package/dist/Semaphore.d.ts.map +1 -1
- package/dist/Semaphore.js +135 -117
- package/dist/Semaphore.js.map +1 -1
- package/dist/Sink.d.ts +22 -19
- package/dist/Sink.d.ts.map +1 -1
- package/dist/Sink.js +54 -7
- package/dist/Sink.js.map +1 -1
- package/dist/Stdio.d.ts +18 -6
- package/dist/Stdio.d.ts.map +1 -1
- package/dist/Stdio.js +20 -2
- package/dist/Stdio.js.map +1 -1
- package/dist/Stream.d.ts +465 -542
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +329 -145
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +114 -47
- package/dist/String.d.ts.map +1 -1
- package/dist/String.js +29 -47
- package/dist/String.js.map +1 -1
- package/dist/Struct.d.ts +7 -7
- package/dist/Struct.d.ts.map +1 -1
- package/dist/SubscriptionRef.d.ts +1 -2
- package/dist/SubscriptionRef.d.ts.map +1 -1
- package/dist/SubscriptionRef.js +83 -116
- package/dist/SubscriptionRef.js.map +1 -1
- package/dist/Terminal.d.ts +5 -4
- package/dist/Terminal.d.ts.map +1 -1
- package/dist/Terminal.js +2 -2
- package/dist/Terminal.js.map +1 -1
- package/dist/Tracer.d.ts +21 -20
- package/dist/Tracer.d.ts.map +1 -1
- package/dist/Tracer.js +13 -9
- package/dist/Tracer.js.map +1 -1
- package/dist/Trie.d.ts +44 -31
- package/dist/Trie.d.ts.map +1 -1
- package/dist/Trie.js +13 -9
- package/dist/Trie.js.map +1 -1
- package/dist/TxChunk.d.ts +4 -4
- package/dist/TxChunk.d.ts.map +1 -1
- package/dist/TxChunk.js +4 -4
- 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 +197 -0
- package/dist/TxDeferred.js.map +1 -0
- package/dist/TxHashMap.d.ts +105 -86
- package/dist/TxHashMap.d.ts.map +1 -1
- package/dist/TxHashMap.js +51 -44
- package/dist/TxHashMap.js.map +1 -1
- package/dist/TxHashSet.d.ts +2 -2
- package/dist/TxHashSet.d.ts.map +1 -1
- package/dist/TxHashSet.js +16 -15
- 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 +416 -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 +1 -1
- package/dist/TxQueue.d.ts.map +1 -1
- package/dist/TxQueue.js +42 -57
- package/dist/TxQueue.js.map +1 -1
- package/dist/TxReentrantLock.d.ts +500 -0
- package/dist/TxReentrantLock.d.ts.map +1 -0
- package/dist/TxReentrantLock.js +481 -0
- package/dist/TxReentrantLock.js.map +1 -0
- package/dist/TxRef.d.ts +14 -20
- package/dist/TxRef.d.ts.map +1 -1
- package/dist/TxRef.js +8 -10
- package/dist/TxRef.js.map +1 -1
- package/dist/TxSemaphore.d.ts +162 -2
- package/dist/TxSemaphore.d.ts.map +1 -1
- package/dist/TxSemaphore.js +25 -10
- 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 +80 -22
- package/dist/Types.d.ts.map +1 -1
- package/dist/Unify.d.ts +8 -2
- package/dist/Unify.d.ts.map +1 -1
- package/dist/Unify.js.map +1 -1
- package/dist/Utils.d.ts +137 -65
- package/dist/Utils.d.ts.map +1 -1
- package/dist/Utils.js +38 -66
- package/dist/Utils.js.map +1 -1
- package/dist/index.d.ts +886 -71
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +886 -71
- package/dist/index.js.map +1 -1
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/dateTime.js +77 -71
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +502 -326
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/hashMap.js +7 -5
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/layer.js +3 -3
- package/dist/internal/layer.js.map +1 -1
- package/dist/internal/option.js +6 -0
- package/dist/internal/option.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 +9 -9
- package/dist/internal/rcRef.js.map +1 -1
- package/dist/internal/references.d.ts +2 -0
- package/dist/internal/references.d.ts.map +1 -0
- package/dist/internal/references.js +51 -0
- package/dist/internal/references.js.map +1 -0
- package/dist/internal/request.js +6 -6
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/schedule.js +1 -1
- package/dist/internal/schedule.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/representation.js +87 -109
- package/dist/internal/schema/representation.js.map +1 -1
- package/dist/internal/schema/schema.d.ts +10 -1
- package/dist/internal/schema/schema.d.ts.map +1 -1
- package/dist/internal/schema/schema.js +59 -1
- package/dist/internal/schema/schema.js.map +1 -1
- package/dist/internal/trie.js +8 -7
- package/dist/internal/trie.js.map +1 -1
- package/dist/testing/TestClock.d.ts +5 -5
- package/dist/testing/TestClock.d.ts.map +1 -1
- package/dist/testing/TestClock.js +2 -2
- package/dist/testing/TestClock.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +267 -33
- package/dist/testing/TestSchema.d.ts.map +1 -1
- package/dist/testing/TestSchema.js +296 -23
- package/dist/testing/TestSchema.js.map +1 -1
- package/dist/testing/index.d.ts +64 -1
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +64 -1
- package/dist/testing/index.js.map +1 -1
- package/dist/unstable/ai/AiError.d.ts +127 -45
- package/dist/unstable/ai/AiError.d.ts.map +1 -1
- package/dist/unstable/ai/AiError.js +29 -23
- package/dist/unstable/ai/AiError.js.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.js +9 -2
- package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Chat.d.ts +39 -11
- package/dist/unstable/ai/Chat.d.ts.map +1 -1
- package/dist/unstable/ai/Chat.js +40 -47
- package/dist/unstable/ai/Chat.js.map +1 -1
- package/dist/unstable/ai/EmbeddingModel.d.ts +130 -0
- package/dist/unstable/ai/EmbeddingModel.d.ts.map +1 -0
- package/dist/unstable/ai/EmbeddingModel.js +127 -0
- package/dist/unstable/ai/EmbeddingModel.js.map +1 -0
- package/dist/unstable/ai/IdGenerator.d.ts +2 -2
- package/dist/unstable/ai/IdGenerator.d.ts.map +1 -1
- package/dist/unstable/ai/IdGenerator.js +2 -2
- package/dist/unstable/ai/IdGenerator.js.map +1 -1
- package/dist/unstable/ai/LanguageModel.d.ts +119 -49
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +260 -61
- package/dist/unstable/ai/LanguageModel.js.map +1 -1
- package/dist/unstable/ai/McpSchema.d.ts +207 -112
- package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
- package/dist/unstable/ai/McpSchema.js +71 -19
- package/dist/unstable/ai/McpSchema.js.map +1 -1
- package/dist/unstable/ai/McpServer.d.ts +68 -15
- package/dist/unstable/ai/McpServer.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.js +225 -73
- package/dist/unstable/ai/McpServer.js.map +1 -1
- package/dist/unstable/ai/Model.d.ts +27 -9
- package/dist/unstable/ai/Model.d.ts.map +1 -1
- package/dist/unstable/ai/Model.js +25 -9
- package/dist/unstable/ai/Model.js.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js +9 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Prompt.d.ts +17 -17
- package/dist/unstable/ai/Prompt.d.ts.map +1 -1
- package/dist/unstable/ai/Prompt.js +6 -9
- package/dist/unstable/ai/Prompt.js.map +1 -1
- package/dist/unstable/ai/Response.d.ts +24 -24
- package/dist/unstable/ai/Response.d.ts.map +1 -1
- package/dist/unstable/ai/Response.js +7 -8
- package/dist/unstable/ai/Response.js.map +1 -1
- package/dist/unstable/ai/ResponseIdTracker.d.ts +38 -0
- package/dist/unstable/ai/ResponseIdTracker.d.ts.map +1 -0
- package/dist/unstable/ai/ResponseIdTracker.js +68 -0
- package/dist/unstable/ai/ResponseIdTracker.js.map +1 -0
- package/dist/unstable/ai/Telemetry.d.ts +35 -2
- package/dist/unstable/ai/Telemetry.d.ts.map +1 -1
- package/dist/unstable/ai/Telemetry.js +2 -2
- package/dist/unstable/ai/Telemetry.js.map +1 -1
- package/dist/unstable/ai/Tokenizer.d.ts +2 -2
- package/dist/unstable/ai/Tokenizer.d.ts.map +1 -1
- package/dist/unstable/ai/Tokenizer.js +2 -2
- package/dist/unstable/ai/Tokenizer.js.map +1 -1
- package/dist/unstable/ai/Tool.d.ts +46 -16
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +68 -22
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/ai/Toolkit.d.ts +4 -4
- package/dist/unstable/ai/Toolkit.d.ts.map +1 -1
- package/dist/unstable/ai/Toolkit.js +14 -21
- package/dist/unstable/ai/Toolkit.js.map +1 -1
- package/dist/unstable/ai/index.d.ts +22 -1
- package/dist/unstable/ai/index.d.ts.map +1 -1
- package/dist/unstable/ai/index.js +22 -1
- package/dist/unstable/ai/index.js.map +1 -1
- package/dist/unstable/ai/internal/codec-transformer.js +5 -7
- package/dist/unstable/ai/internal/codec-transformer.js.map +1 -1
- package/dist/unstable/cli/Argument.d.ts +4 -7
- package/dist/unstable/cli/Argument.d.ts.map +1 -1
- package/dist/unstable/cli/Argument.js +1 -3
- package/dist/unstable/cli/Argument.js.map +1 -1
- package/dist/unstable/cli/CliError.d.ts +51 -63
- package/dist/unstable/cli/CliError.d.ts.map +1 -1
- package/dist/unstable/cli/CliError.js +32 -57
- package/dist/unstable/cli/CliError.js.map +1 -1
- package/dist/unstable/cli/CliOutput.d.ts +5 -4
- package/dist/unstable/cli/CliOutput.d.ts.map +1 -1
- package/dist/unstable/cli/CliOutput.js +67 -12
- package/dist/unstable/cli/CliOutput.js.map +1 -1
- package/dist/unstable/cli/Command.d.ts +372 -59
- package/dist/unstable/cli/Command.d.ts.map +1 -1
- package/dist/unstable/cli/Command.js +328 -66
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cli/Completions.d.ts +97 -0
- package/dist/unstable/cli/Completions.d.ts.map +1 -0
- package/dist/unstable/cli/Completions.js +25 -0
- package/dist/unstable/cli/Completions.js.map +1 -0
- package/dist/unstable/cli/Flag.d.ts +4 -5
- package/dist/unstable/cli/Flag.d.ts.map +1 -1
- package/dist/unstable/cli/Flag.js +1 -1
- package/dist/unstable/cli/Flag.js.map +1 -1
- package/dist/unstable/cli/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 +81 -11
- package/dist/unstable/cli/HelpDoc.d.ts.map +1 -1
- package/dist/unstable/cli/Param.d.ts +34 -6
- package/dist/unstable/cli/Param.d.ts.map +1 -1
- package/dist/unstable/cli/Param.js +24 -14
- package/dist/unstable/cli/Param.js.map +1 -1
- package/dist/unstable/cli/Primitive.d.ts +2 -2
- package/dist/unstable/cli/Primitive.d.ts.map +1 -1
- package/dist/unstable/cli/Primitive.js +1 -1
- package/dist/unstable/cli/Primitive.js.map +1 -1
- package/dist/unstable/cli/Prompt.js +266 -86
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/cli/index.d.ts +10 -0
- package/dist/unstable/cli/index.d.ts.map +1 -1
- package/dist/unstable/cli/index.js +10 -0
- package/dist/unstable/cli/index.js.map +1 -1
- package/dist/unstable/cli/internal/command.d.ts +41 -15
- package/dist/unstable/cli/internal/command.d.ts.map +1 -1
- package/dist/unstable/cli/internal/command.js +84 -47
- package/dist/unstable/cli/internal/command.js.map +1 -1
- package/dist/unstable/cli/internal/completions/bash.js.map +1 -1
- package/dist/unstable/cli/internal/completions/descriptor.d.ts +2 -0
- package/dist/unstable/cli/internal/completions/descriptor.d.ts.map +1 -0
- package/dist/unstable/cli/internal/completions/{CommandDescriptor.js → descriptor.js} +17 -5
- package/dist/unstable/cli/internal/completions/descriptor.js.map +1 -0
- package/dist/unstable/cli/internal/completions/fish.js.map +1 -1
- package/dist/unstable/cli/internal/completions/zsh.js.map +1 -1
- package/dist/unstable/cli/internal/config.js +42 -0
- package/dist/unstable/cli/internal/config.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 +125 -0
- package/dist/unstable/cli/internal/help.js.map +1 -0
- package/dist/unstable/cli/internal/parser.js +155 -58
- 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/ClusterError.d.ts +7 -7
- package/dist/unstable/cluster/ClusterSchema.d.ts +28 -7
- package/dist/unstable/cluster/ClusterSchema.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterSchema.js +28 -8
- package/dist/unstable/cluster/ClusterSchema.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts +4 -2
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +96 -63
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/cluster/DeliverAt.js +1 -1
- package/dist/unstable/cluster/DeliverAt.js.map +1 -1
- package/dist/unstable/cluster/Entity.d.ts +17 -16
- package/dist/unstable/cluster/Entity.d.ts.map +1 -1
- package/dist/unstable/cluster/Entity.js +31 -25
- package/dist/unstable/cluster/Entity.js.map +1 -1
- package/dist/unstable/cluster/EntityAddress.d.ts +2 -2
- package/dist/unstable/cluster/EntityAddress.d.ts.map +1 -1
- package/dist/unstable/cluster/EntityAddress.js +1 -1
- package/dist/unstable/cluster/EntityAddress.js.map +1 -1
- package/dist/unstable/cluster/EntityProxy.js +3 -3
- package/dist/unstable/cluster/EntityProxy.js.map +1 -1
- package/dist/unstable/cluster/EntityProxyServer.d.ts.map +1 -1
- package/dist/unstable/cluster/EntityProxyServer.js +6 -6
- package/dist/unstable/cluster/EntityProxyServer.js.map +1 -1
- package/dist/unstable/cluster/EntityResource.d.ts +4 -4
- package/dist/unstable/cluster/EntityResource.d.ts.map +1 -1
- package/dist/unstable/cluster/EntityResource.js +2 -2
- package/dist/unstable/cluster/EntityResource.js.map +1 -1
- package/dist/unstable/cluster/Envelope.d.ts +3 -3
- package/dist/unstable/cluster/HttpRunner.js +2 -2
- package/dist/unstable/cluster/HttpRunner.js.map +1 -1
- package/dist/unstable/cluster/K8sHttpClient.d.ts +5 -5
- package/dist/unstable/cluster/K8sHttpClient.d.ts.map +1 -1
- package/dist/unstable/cluster/K8sHttpClient.js +7 -7
- package/dist/unstable/cluster/K8sHttpClient.js.map +1 -1
- package/dist/unstable/cluster/Message.d.ts +16 -10
- package/dist/unstable/cluster/Message.d.ts.map +1 -1
- package/dist/unstable/cluster/Message.js +16 -8
- package/dist/unstable/cluster/Message.js.map +1 -1
- package/dist/unstable/cluster/MessageStorage.d.ts +46 -23
- package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/MessageStorage.js +40 -25
- package/dist/unstable/cluster/MessageStorage.js.map +1 -1
- package/dist/unstable/cluster/Reply.d.ts +7 -6
- package/dist/unstable/cluster/Reply.d.ts.map +1 -1
- package/dist/unstable/cluster/Reply.js +8 -7
- package/dist/unstable/cluster/Reply.js.map +1 -1
- package/dist/unstable/cluster/Runner.d.ts +1 -1
- package/dist/unstable/cluster/Runner.d.ts.map +1 -1
- package/dist/unstable/cluster/Runner.js +1 -1
- package/dist/unstable/cluster/Runner.js.map +1 -1
- package/dist/unstable/cluster/RunnerAddress.d.ts +1 -1
- package/dist/unstable/cluster/RunnerAddress.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerAddress.js +1 -1
- package/dist/unstable/cluster/RunnerAddress.js.map +1 -1
- package/dist/unstable/cluster/RunnerHealth.d.ts +2 -2
- package/dist/unstable/cluster/RunnerHealth.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerHealth.js +2 -2
- package/dist/unstable/cluster/RunnerHealth.js.map +1 -1
- package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerServer.js +10 -9
- package/dist/unstable/cluster/RunnerServer.js.map +1 -1
- package/dist/unstable/cluster/RunnerStorage.d.ts +12 -12
- package/dist/unstable/cluster/RunnerStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerStorage.js +3 -3
- package/dist/unstable/cluster/RunnerStorage.js.map +1 -1
- package/dist/unstable/cluster/Runners.d.ts +5 -4
- package/dist/unstable/cluster/Runners.d.ts.map +1 -1
- package/dist/unstable/cluster/Runners.js +16 -14
- package/dist/unstable/cluster/Runners.js.map +1 -1
- package/dist/unstable/cluster/ShardId.d.ts +35 -49
- package/dist/unstable/cluster/ShardId.d.ts.map +1 -1
- package/dist/unstable/cluster/ShardId.js +65 -67
- package/dist/unstable/cluster/ShardId.js.map +1 -1
- package/dist/unstable/cluster/Sharding.d.ts +4 -4
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +59 -49
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.d.ts +28 -27
- package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.js +27 -27
- package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
- package/dist/unstable/cluster/SingletonAddress.d.ts +2 -2
- package/dist/unstable/cluster/Snowflake.d.ts +2 -2
- package/dist/unstable/cluster/Snowflake.d.ts.map +1 -1
- package/dist/unstable/cluster/Snowflake.js +2 -2
- package/dist/unstable/cluster/Snowflake.js.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.js +24 -20
- package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.js +7 -7
- package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/unstable/cluster/internal/entityManager.js +30 -24
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/cluster/internal/entityReaper.js +2 -2
- package/dist/unstable/cluster/internal/entityReaper.js.map +1 -1
- package/dist/unstable/cluster/internal/resourceMap.js +3 -3
- package/dist/unstable/cluster/internal/resourceMap.js.map +1 -1
- package/dist/unstable/devtools/DevToolsClient.d.ts +2 -2
- package/dist/unstable/devtools/DevToolsClient.d.ts.map +1 -1
- package/dist/unstable/devtools/DevToolsClient.js +9 -8
- package/dist/unstable/devtools/DevToolsClient.js.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.d.ts +4 -4
- package/dist/unstable/devtools/DevToolsSchema.d.ts.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.js +9 -2
- package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
- package/dist/unstable/encoding/Msgpack.d.ts +1 -1
- package/dist/unstable/encoding/Ndjson.d.ts +9 -9
- package/dist/unstable/encoding/Ndjson.d.ts.map +1 -1
- package/dist/unstable/encoding/Ndjson.js.map +1 -1
- package/dist/unstable/encoding/Sse.d.ts +3 -3
- 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/Event.d.ts +0 -6
- package/dist/unstable/eventlog/Event.d.ts.map +1 -1
- package/dist/unstable/eventlog/Event.js +0 -5
- package/dist/unstable/eventlog/Event.js.map +1 -1
- package/dist/unstable/eventlog/EventGroup.d.ts +0 -2
- package/dist/unstable/eventlog/EventGroup.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventGroup.js +0 -2
- package/dist/unstable/eventlog/EventGroup.js.map +1 -1
- package/dist/unstable/eventlog/EventJournal.d.ts +27 -10
- package/dist/unstable/eventlog/EventJournal.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventJournal.js +130 -71
- package/dist/unstable/eventlog/EventJournal.js.map +1 -1
- package/dist/unstable/eventlog/EventLog.d.ts +94 -37
- package/dist/unstable/eventlog/EventLog.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLog.js +225 -151
- package/dist/unstable/eventlog/EventLog.js.map +1 -1
- package/dist/unstable/eventlog/EventLogEncryption.d.ts +11 -9
- package/dist/unstable/eventlog/EventLogEncryption.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogEncryption.js +15 -17
- package/dist/unstable/eventlog/EventLogEncryption.js.map +1 -1
- package/dist/unstable/eventlog/EventLogMessage.d.ts +228 -0
- package/dist/unstable/eventlog/EventLogMessage.d.ts.map +1 -0
- package/dist/unstable/eventlog/EventLogMessage.js +214 -0
- package/dist/unstable/eventlog/EventLogMessage.js.map +1 -0
- package/dist/unstable/eventlog/EventLogRemote.d.ts +112 -194
- package/dist/unstable/eventlog/EventLogRemote.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.js +168 -322
- package/dist/unstable/eventlog/EventLogRemote.js.map +1 -1
- package/dist/unstable/eventlog/EventLogServer.d.ts +26 -48
- package/dist/unstable/eventlog/EventLogServer.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogServer.js +128 -199
- package/dist/unstable/eventlog/EventLogServer.js.map +1 -1
- package/dist/unstable/eventlog/EventLogServerEncrypted.d.ts +60 -0
- package/dist/unstable/eventlog/EventLogServerEncrypted.d.ts.map +1 -0
- package/dist/unstable/eventlog/EventLogServerEncrypted.js +166 -0
- package/dist/unstable/eventlog/EventLogServerEncrypted.js.map +1 -0
- package/dist/unstable/eventlog/EventLogServerUnencrypted.d.ts +183 -0
- package/dist/unstable/eventlog/EventLogServerUnencrypted.d.ts.map +1 -0
- package/dist/unstable/eventlog/EventLogServerUnencrypted.js +461 -0
- package/dist/unstable/eventlog/EventLogServerUnencrypted.js.map +1 -0
- package/dist/unstable/eventlog/EventLogSessionAuth.d.ts +117 -0
- package/dist/unstable/eventlog/EventLogSessionAuth.d.ts.map +1 -0
- package/dist/unstable/eventlog/EventLogSessionAuth.js +284 -0
- package/dist/unstable/eventlog/EventLogSessionAuth.js.map +1 -0
- package/dist/unstable/eventlog/{SqlEventLogJournal.d.ts → SqlEventJournal.d.ts} +2 -2
- package/dist/unstable/eventlog/SqlEventJournal.d.ts.map +1 -0
- package/dist/unstable/eventlog/{SqlEventLogJournal.js → SqlEventJournal.js} +28 -21
- package/dist/unstable/eventlog/SqlEventJournal.js.map +1 -0
- package/dist/unstable/eventlog/{SqlEventLogServer.d.ts → SqlEventLogServerEncrypted.d.ts} +5 -5
- package/dist/unstable/eventlog/SqlEventLogServerEncrypted.d.ts.map +1 -0
- package/dist/unstable/eventlog/{SqlEventLogServer.js → SqlEventLogServerEncrypted.js} +69 -27
- package/dist/unstable/eventlog/SqlEventLogServerEncrypted.js.map +1 -0
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.d.ts +25 -0
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.d.ts.map +1 -0
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js +355 -0
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js.map +1 -0
- package/dist/unstable/eventlog/index.d.ts +22 -2
- package/dist/unstable/eventlog/index.d.ts.map +1 -1
- package/dist/unstable/eventlog/index.js +22 -2
- package/dist/unstable/eventlog/index.js.map +1 -1
- package/dist/unstable/eventlog/internal/identityRootSecretDerivation.d.ts +2 -0
- package/dist/unstable/eventlog/internal/identityRootSecretDerivation.d.ts.map +1 -0
- package/dist/unstable/eventlog/internal/identityRootSecretDerivation.js +89 -0
- package/dist/unstable/eventlog/internal/identityRootSecretDerivation.js.map +1 -0
- package/dist/unstable/http/Cookies.d.ts +51 -6
- package/dist/unstable/http/Cookies.d.ts.map +1 -1
- package/dist/unstable/http/Cookies.js +27 -6
- package/dist/unstable/http/Cookies.js.map +1 -1
- package/dist/unstable/http/Etag.d.ts +2 -2
- package/dist/unstable/http/Etag.d.ts.map +1 -1
- package/dist/unstable/http/Etag.js +7 -3
- package/dist/unstable/http/Etag.js.map +1 -1
- package/dist/unstable/http/FetchHttpClient.d.ts +6 -3
- package/dist/unstable/http/FetchHttpClient.d.ts.map +1 -1
- package/dist/unstable/http/FetchHttpClient.js +5 -5
- package/dist/unstable/http/FetchHttpClient.js.map +1 -1
- package/dist/unstable/http/Headers.d.ts +24 -4
- package/dist/unstable/http/Headers.d.ts.map +1 -1
- package/dist/unstable/http/Headers.js +42 -13
- package/dist/unstable/http/Headers.js.map +1 -1
- package/dist/unstable/http/HttpBody.d.ts +1 -1
- package/dist/unstable/http/HttpClient.d.ts +125 -21
- package/dist/unstable/http/HttpClient.d.ts.map +1 -1
- package/dist/unstable/http/HttpClient.js +197 -19
- package/dist/unstable/http/HttpClient.js.map +1 -1
- package/dist/unstable/http/HttpClientError.d.ts +8 -8
- package/dist/unstable/http/HttpClientRequest.d.ts +43 -15
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.js +131 -21
- package/dist/unstable/http/HttpClientRequest.js.map +1 -1
- package/dist/unstable/http/HttpClientResponse.d.ts +2 -1
- package/dist/unstable/http/HttpClientResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientResponse.js +18 -3
- package/dist/unstable/http/HttpClientResponse.js.map +1 -1
- package/dist/unstable/http/HttpEffect.d.ts +13 -11
- package/dist/unstable/http/HttpEffect.d.ts.map +1 -1
- package/dist/unstable/http/HttpEffect.js +51 -51
- package/dist/unstable/http/HttpEffect.js.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.d.ts +5 -4
- package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.js +6 -10
- package/dist/unstable/http/HttpIncomingMessage.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 +4 -9
- package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/unstable/http/HttpMiddleware.js +47 -43
- package/dist/unstable/http/HttpMiddleware.js.map +1 -1
- package/dist/unstable/http/HttpPlatform.d.ts +2 -2
- package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
- package/dist/unstable/http/HttpPlatform.js +5 -4
- package/dist/unstable/http/HttpPlatform.js.map +1 -1
- package/dist/unstable/http/HttpRouter.d.ts +9 -8
- package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
- package/dist/unstable/http/HttpRouter.js +36 -36
- package/dist/unstable/http/HttpRouter.js.map +1 -1
- package/dist/unstable/http/HttpServer.d.ts +2 -2
- package/dist/unstable/http/HttpServer.d.ts.map +1 -1
- package/dist/unstable/http/HttpServer.js +4 -4
- package/dist/unstable/http/HttpServer.js.map +1 -1
- package/dist/unstable/http/HttpServerError.d.ts +22 -34
- package/dist/unstable/http/HttpServerError.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerError.js +39 -45
- package/dist/unstable/http/HttpServerError.js.map +1 -1
- package/dist/unstable/http/HttpServerRequest.d.ts +19 -7
- package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRequest.js +307 -13
- package/dist/unstable/http/HttpServerRequest.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 +52 -5
- package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerResponse.js +240 -5
- package/dist/unstable/http/HttpServerResponse.js.map +1 -1
- package/dist/unstable/http/HttpStaticServer.d.ts +69 -0
- package/dist/unstable/http/HttpStaticServer.d.ts.map +1 -0
- package/dist/unstable/http/HttpStaticServer.js +353 -0
- package/dist/unstable/http/HttpStaticServer.js.map +1 -0
- package/dist/unstable/http/HttpTraceContext.d.ts +3 -2
- package/dist/unstable/http/HttpTraceContext.d.ts.map +1 -1
- package/dist/unstable/http/HttpTraceContext.js +27 -15
- package/dist/unstable/http/HttpTraceContext.js.map +1 -1
- package/dist/unstable/http/Multipart.d.ts +7 -7
- package/dist/unstable/http/Multipart.d.ts.map +1 -1
- package/dist/unstable/http/Multipart.js +7 -7
- package/dist/unstable/http/Multipart.js.map +1 -1
- package/dist/unstable/http/Url.d.ts +604 -0
- package/dist/unstable/http/Url.d.ts.map +1 -0
- package/dist/unstable/http/Url.js +256 -0
- package/dist/unstable/http/Url.js.map +1 -0
- package/dist/unstable/http/UrlParams.d.ts +18 -9
- package/dist/unstable/http/UrlParams.d.ts.map +1 -1
- package/dist/unstable/http/UrlParams.js +6 -7
- package/dist/unstable/http/UrlParams.js.map +1 -1
- package/dist/unstable/http/index.d.ts +8 -0
- package/dist/unstable/http/index.d.ts.map +1 -1
- package/dist/unstable/http/index.js +8 -0
- package/dist/unstable/http/index.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 +11 -11
- package/dist/unstable/httpapi/HttpApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApi.js +8 -8
- package/dist/unstable/httpapi/HttpApi.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts +12 -9
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +73 -48
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.d.ts +82 -7
- package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.js +79 -11
- package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +210 -105
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.js +52 -47
- package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.d.ts +66 -29
- package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.js +138 -32
- package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.d.ts +9 -8
- package/dist/unstable/httpapi/HttpApiGroup.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.js +4 -4
- package/dist/unstable/httpapi/HttpApiGroup.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +49 -17
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.js +38 -8
- package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.d.ts +88 -9
- package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.js +86 -11
- package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSecurity.d.ts +9 -6
- package/dist/unstable/httpapi/HttpApiSecurity.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSecurity.js +6 -6
- package/dist/unstable/httpapi/HttpApiSecurity.js.map +1 -1
- package/dist/unstable/httpapi/OpenApi.d.ts +17 -25
- package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/OpenApi.js +59 -60
- 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 +8 -8
- 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/OtlpMetrics.js +2 -2
- package/dist/unstable/observability/OtlpMetrics.js.map +1 -1
- package/dist/unstable/observability/OtlpSerialization.d.ts +2 -2
- package/dist/unstable/observability/OtlpSerialization.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpSerialization.js +2 -2
- package/dist/unstable/observability/OtlpSerialization.js.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/observability/OtlpTracer.js +7 -3
- package/dist/unstable/observability/OtlpTracer.js.map +1 -1
- package/dist/unstable/observability/PrometheusMetrics.d.ts +3 -3
- package/dist/unstable/observability/PrometheusMetrics.d.ts.map +1 -1
- package/dist/unstable/observability/PrometheusMetrics.js +4 -33
- package/dist/unstable/observability/PrometheusMetrics.js.map +1 -1
- package/dist/unstable/observability/internal/protobuf.js +4 -4
- package/dist/unstable/observability/internal/protobuf.js.map +1 -1
- package/dist/unstable/persistence/KeyValueStore.d.ts +24 -3
- package/dist/unstable/persistence/KeyValueStore.d.ts.map +1 -1
- package/dist/unstable/persistence/KeyValueStore.js +144 -2
- 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/Persistable.js +1 -1
- package/dist/unstable/persistence/Persistable.js.map +1 -1
- package/dist/unstable/persistence/PersistedCache.d.ts +1 -2
- package/dist/unstable/persistence/PersistedCache.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedCache.js +10 -11
- package/dist/unstable/persistence/PersistedCache.js.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.d.ts +16 -16
- package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.js +9 -9
- package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
- package/dist/unstable/persistence/Persistence.d.ts +5 -5
- package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
- package/dist/unstable/persistence/Persistence.js +5 -5
- package/dist/unstable/persistence/Persistence.js.map +1 -1
- package/dist/unstable/persistence/RateLimiter.d.ts +9 -9
- package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
- package/dist/unstable/persistence/RateLimiter.js +4 -4
- package/dist/unstable/persistence/RateLimiter.js.map +1 -1
- package/dist/unstable/persistence/Redis.d.ts +3 -3
- package/dist/unstable/persistence/Redis.d.ts.map +1 -1
- package/dist/unstable/persistence/Redis.js +2 -2
- package/dist/unstable/persistence/Redis.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 +83 -8
- package/dist/unstable/process/ChildProcessSpawner.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.js +22 -2
- package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
- package/dist/unstable/reactivity/AsyncResult.d.ts +37 -17
- package/dist/unstable/reactivity/AsyncResult.d.ts.map +1 -1
- package/dist/unstable/reactivity/AsyncResult.js +9 -0
- package/dist/unstable/reactivity/AsyncResult.js.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts +108 -47
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +105 -25
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts +25 -20
- package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.js +58 -26
- package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.d.ts +8 -2
- package/dist/unstable/reactivity/AtomRegistry.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.js +57 -14
- package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.d.ts +12 -12
- package/dist/unstable/reactivity/AtomRpc.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.js +59 -31
- package/dist/unstable/reactivity/AtomRpc.js.map +1 -1
- package/dist/unstable/reactivity/Reactivity.d.ts +2 -2
- package/dist/unstable/reactivity/Reactivity.d.ts.map +1 -1
- package/dist/unstable/reactivity/Reactivity.js +6 -6
- package/dist/unstable/reactivity/Reactivity.js.map +1 -1
- package/dist/unstable/rpc/Rpc.d.ts +137 -19
- package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
- package/dist/unstable/rpc/Rpc.js +99 -7
- package/dist/unstable/rpc/Rpc.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts +26 -47
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +117 -75
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/rpc/RpcClientError.d.ts +2 -2
- package/dist/unstable/rpc/RpcGroup.d.ts +15 -11
- package/dist/unstable/rpc/RpcGroup.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcGroup.js +30 -20
- package/dist/unstable/rpc/RpcGroup.js.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.d.ts +12 -12
- package/dist/unstable/rpc/RpcMiddleware.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.js +5 -5
- package/dist/unstable/rpc/RpcMiddleware.js.map +1 -1
- package/dist/unstable/rpc/RpcSchema.d.ts +14 -1
- package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSchema.js +17 -2
- package/dist/unstable/rpc/RpcSchema.js.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.d.ts +13 -2
- package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.js +60 -27
- package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts +8 -12
- package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +73 -43
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/rpc/RpcWorker.d.ts +2 -2
- package/dist/unstable/rpc/RpcWorker.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcWorker.js +4 -4
- package/dist/unstable/rpc/RpcWorker.js.map +1 -1
- package/dist/unstable/rpc/Utils.d.ts +6 -3
- package/dist/unstable/rpc/Utils.d.ts.map +1 -1
- package/dist/unstable/rpc/Utils.js +46 -5
- package/dist/unstable/rpc/Utils.js.map +1 -1
- package/dist/unstable/schema/Model.d.ts +24 -3
- package/dist/unstable/schema/Model.d.ts.map +1 -1
- package/dist/unstable/schema/Model.js +17 -4
- package/dist/unstable/schema/Model.js.map +1 -1
- package/dist/unstable/schema/VariantSchema.d.ts +7 -7
- package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
- package/dist/unstable/schema/VariantSchema.js +7 -18
- package/dist/unstable/schema/VariantSchema.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts +35 -15
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +34 -27
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/dist/unstable/socket/SocketServer.d.ts +8 -5
- package/dist/unstable/socket/SocketServer.d.ts.map +1 -1
- package/dist/unstable/socket/SocketServer.js +2 -2
- package/dist/unstable/socket/SocketServer.js.map +1 -1
- package/dist/unstable/sql/Migrator.d.ts +1 -1
- package/dist/unstable/sql/Migrator.d.ts.map +1 -1
- package/dist/unstable/sql/Migrator.js +2 -2
- package/dist/unstable/sql/Migrator.js.map +1 -1
- package/dist/unstable/sql/SqlClient.d.ts +24 -6
- package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
- package/dist/unstable/sql/SqlClient.js +37 -32
- package/dist/unstable/sql/SqlClient.js.map +1 -1
- package/dist/unstable/sql/SqlConnection.d.ts +2 -2
- package/dist/unstable/sql/SqlConnection.d.ts.map +1 -1
- package/dist/unstable/sql/SqlConnection.js +5 -2
- package/dist/unstable/sql/SqlConnection.js.map +1 -1
- package/dist/unstable/sql/SqlError.d.ts +237 -17
- package/dist/unstable/sql/SqlError.d.ts.map +1 -1
- package/dist/unstable/sql/SqlError.js +260 -4
- package/dist/unstable/sql/SqlError.js.map +1 -1
- package/dist/unstable/sql/SqlModel.d.ts +8 -9
- package/dist/unstable/sql/SqlModel.d.ts.map +1 -1
- package/dist/unstable/sql/SqlModel.js +12 -38
- package/dist/unstable/sql/SqlModel.js.map +1 -1
- package/dist/unstable/sql/SqlResolver.js +24 -17
- package/dist/unstable/sql/SqlResolver.js.map +1 -1
- package/dist/unstable/sql/SqlSchema.d.ts +17 -6
- 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.d.ts +3 -5
- package/dist/unstable/sql/Statement.d.ts.map +1 -1
- package/dist/unstable/sql/Statement.js +14 -13
- package/dist/unstable/sql/Statement.js.map +1 -1
- package/dist/unstable/workers/Transferable.d.ts +4 -4
- package/dist/unstable/workers/Transferable.d.ts.map +1 -1
- package/dist/unstable/workers/Transferable.js +7 -7
- package/dist/unstable/workers/Transferable.js.map +1 -1
- package/dist/unstable/workers/Worker.d.ts +3 -3
- package/dist/unstable/workers/Worker.d.ts.map +1 -1
- package/dist/unstable/workers/Worker.js +6 -3
- package/dist/unstable/workers/Worker.js.map +1 -1
- package/dist/unstable/workers/WorkerError.d.ts +5 -5
- package/dist/unstable/workers/WorkerRunner.d.ts +2 -2
- package/dist/unstable/workers/WorkerRunner.d.ts.map +1 -1
- package/dist/unstable/workers/WorkerRunner.js +5 -2
- package/dist/unstable/workers/WorkerRunner.js.map +1 -1
- package/dist/unstable/workflow/Activity.d.ts +8 -3
- package/dist/unstable/workflow/Activity.d.ts.map +1 -1
- package/dist/unstable/workflow/Activity.js +25 -11
- package/dist/unstable/workflow/Activity.js.map +1 -1
- package/dist/unstable/workflow/DurableClock.d.ts +3 -6
- package/dist/unstable/workflow/DurableClock.d.ts.map +1 -1
- package/dist/unstable/workflow/DurableClock.js +6 -6
- package/dist/unstable/workflow/DurableClock.js.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.d.ts +2 -5
- package/dist/unstable/workflow/DurableDeferred.d.ts.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.js +33 -15
- package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts +12 -14
- package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
- package/dist/unstable/workflow/Workflow.js +30 -26
- package/dist/unstable/workflow/Workflow.js.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts +24 -7
- package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js +165 -16
- package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
- package/dist/unstable/workflow/WorkflowProxyServer.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowProxyServer.js +4 -4
- package/dist/unstable/workflow/WorkflowProxyServer.js.map +1 -1
- package/package.json +11 -10
- package/src/Array.ts +304 -447
- package/src/BigDecimal.ts +137 -82
- package/src/BigInt.ts +53 -45
- package/src/Brand.ts +3 -5
- package/src/Cache.ts +27 -54
- package/src/Cause.ts +57 -22
- package/src/Channel.ts +687 -220
- package/src/Chunk.ts +149 -331
- package/src/Clock.ts +2 -2
- package/src/Combiner.ts +280 -13
- package/src/Config.ts +214 -52
- package/src/ConfigProvider.ts +5 -5
- package/src/Console.ts +2 -2
- package/src/Context.ts +1454 -0
- package/src/Cron.ts +155 -63
- package/src/Data.ts +530 -368
- package/src/DateTime.ts +77 -258
- package/src/Deferred.ts +15 -6
- package/src/Duration.ts +151 -81
- package/src/Effect.ts +1633 -1055
- package/src/Effectable.ts +47 -0
- package/src/Equal.ts +293 -109
- package/src/Equivalence.ts +114 -52
- package/src/ErrorReporter.ts +458 -0
- package/src/ExecutionPlan.ts +8 -9
- package/src/Exit.ts +24 -12
- package/src/Fiber.ts +17 -8
- package/src/FiberHandle.ts +15 -14
- package/src/FiberMap.ts +27 -27
- package/src/FiberSet.ts +5 -5
- package/src/FileSystem.ts +30 -26
- package/src/Filter.ts +4 -62
- package/src/Formatter.ts +268 -60
- package/src/Function.ts +2 -10
- package/src/Graph.ts +123 -112
- package/src/Hash.ts +2 -2
- package/src/HashMap.ts +26 -19
- package/src/Inspectable.ts +2 -22
- package/src/Iterable.ts +117 -63
- package/src/JsonSchema.ts +383 -10
- package/src/Latch.ts +85 -3
- package/src/Layer.ts +728 -441
- package/src/LayerMap.ts +38 -35
- package/src/LogLevel.ts +37 -0
- package/src/Logger.ts +35 -102
- package/src/ManagedRuntime.ts +61 -48
- package/src/Metric.ts +64 -66
- package/src/MutableHashMap.ts +9 -0
- package/src/MutableHashSet.ts +9 -0
- package/src/MutableList.ts +3 -0
- package/src/Newtype.ts +308 -0
- package/src/Number.ts +98 -29
- package/src/Optic.ts +948 -19
- package/src/Option.ts +34 -24
- package/src/Order.ts +39 -32
- package/src/PartitionedSemaphore.ts +414 -0
- package/src/Path.ts +2 -2
- package/src/Pool.ts +9 -9
- package/src/Predicate.ts +1 -1
- package/src/PubSub.ts +20 -11
- package/src/Pull.ts +1 -1
- package/src/Queue.ts +11 -9
- package/src/Random.ts +51 -14
- package/src/RcMap.ts +19 -19
- package/src/RcRef.ts +1 -1
- package/src/Record.ts +94 -199
- package/src/Redactable.ts +146 -72
- package/src/Reducer.ts +166 -7
- package/src/References.ts +283 -287
- package/src/Request.ts +5 -5
- package/src/RequestResolver.ts +34 -35
- package/src/Resource.ts +6 -5
- package/src/Result.ts +2 -4
- package/src/Runtime.ts +102 -6
- package/src/Schedule.ts +243 -336
- package/src/Scheduler.ts +52 -129
- package/src/Schema.ts +3769 -597
- package/src/SchemaAST.ts +480 -302
- package/src/SchemaGetter.ts +80 -24
- package/src/SchemaIssue.ts +28 -15
- package/src/SchemaParser.ts +100 -29
- package/src/SchemaRepresentation.ts +57 -33
- package/src/SchemaTransformation.ts +321 -32
- package/src/Scope.ts +2 -2
- package/src/ScopedCache.ts +8 -8
- package/src/Semaphore.ts +268 -182
- package/src/Sink.ts +89 -34
- package/src/Stdio.ts +29 -6
- package/src/Stream.ts +908 -752
- package/src/String.ts +122 -69
- package/src/Struct.ts +7 -7
- package/src/SubscriptionRef.ts +98 -118
- package/src/Terminal.ts +5 -4
- package/src/Tracer.ts +23 -22
- package/src/Trie.ts +44 -31
- package/src/TxChunk.ts +26 -16
- package/src/TxDeferred.ts +391 -0
- package/src/TxHashMap.ts +347 -291
- package/src/TxHashSet.ts +54 -61
- package/src/TxPriorityQueue.ts +762 -0
- package/src/TxPubSub.ts +787 -0
- package/src/TxQueue.ts +221 -245
- package/src/TxReentrantLock.ts +729 -0
- package/src/TxRef.ts +31 -31
- package/src/TxSemaphore.ts +203 -31
- package/src/TxSubscriptionRef.ts +637 -0
- package/src/Types.ts +75 -23
- package/src/Unify.ts +26 -2
- package/src/Utils.ts +137 -111
- package/src/index.ts +896 -73
- package/src/internal/core.ts +9 -10
- package/src/internal/dateTime.ts +91 -96
- package/src/internal/effect.ts +1179 -614
- package/src/internal/hashMap.ts +12 -10
- package/src/internal/layer.ts +7 -7
- package/src/internal/option.ts +7 -0
- package/src/internal/random.ts +20 -0
- package/src/internal/rcRef.ts +12 -12
- package/src/internal/references.ts +72 -0
- package/src/internal/request.ts +8 -8
- package/src/internal/schedule.ts +3 -1
- package/src/internal/schema/annotations.ts +2 -0
- package/src/internal/schema/representation.ts +82 -97
- package/src/internal/schema/schema.ts +68 -1
- package/src/internal/trie.ts +21 -15
- package/src/testing/TestClock.ts +6 -6
- package/src/testing/TestSchema.ts +333 -36
- package/src/testing/index.ts +64 -1
- package/src/unstable/ai/AiError.ts +111 -53
- package/src/unstable/ai/AnthropicStructuredOutput.ts +7 -3
- package/src/unstable/ai/Chat.ts +136 -88
- package/src/unstable/ai/EmbeddingModel.ts +209 -0
- package/src/unstable/ai/IdGenerator.ts +2 -2
- package/src/unstable/ai/LanguageModel.ts +685 -255
- package/src/unstable/ai/McpSchema.ts +84 -22
- package/src/unstable/ai/McpServer.ts +307 -87
- package/src/unstable/ai/Model.ts +44 -13
- package/src/unstable/ai/OpenAiStructuredOutput.ts +9 -2
- package/src/unstable/ai/Prompt.ts +23 -29
- package/src/unstable/ai/Response.ts +29 -31
- package/src/unstable/ai/ResponseIdTracker.ts +95 -0
- package/src/unstable/ai/Telemetry.ts +2 -2
- package/src/unstable/ai/Tokenizer.ts +2 -2
- package/src/unstable/ai/Tool.ts +62 -36
- package/src/unstable/ai/Toolkit.ts +17 -26
- package/src/unstable/ai/index.ts +24 -1
- package/src/unstable/ai/internal/codec-transformer.ts +3 -9
- package/src/unstable/cli/Argument.ts +5 -8
- package/src/unstable/cli/CliError.ts +67 -66
- package/src/unstable/cli/CliOutput.ts +87 -15
- package/src/unstable/cli/Command.ts +808 -193
- package/src/unstable/cli/Completions.ts +107 -0
- package/src/unstable/cli/Flag.ts +5 -6
- package/src/unstable/cli/GlobalFlag.ts +242 -0
- package/src/unstable/cli/HelpDoc.ts +91 -11
- package/src/unstable/cli/Param.ts +54 -27
- package/src/unstable/cli/Primitive.ts +2 -2
- package/src/unstable/cli/Prompt.ts +275 -104
- package/src/unstable/cli/index.ts +12 -0
- package/src/unstable/cli/internal/command.ts +125 -64
- package/src/unstable/cli/internal/completions/bash.ts +7 -7
- package/src/unstable/cli/internal/completions/{CommandDescriptor.ts → descriptor.ts} +16 -58
- package/src/unstable/cli/internal/completions/fish.ts +7 -7
- package/src/unstable/cli/internal/completions/zsh.ts +8 -14
- package/src/unstable/cli/internal/config.ts +49 -0
- package/src/unstable/cli/internal/help.ts +171 -0
- package/src/unstable/cli/internal/parser.ts +201 -84
- package/src/unstable/cluster/ClusterCron.ts +2 -2
- package/src/unstable/cluster/ClusterSchema.ts +38 -10
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +142 -80
- package/src/unstable/cluster/DeliverAt.ts +1 -1
- package/src/unstable/cluster/Entity.ts +58 -45
- package/src/unstable/cluster/EntityAddress.ts +1 -1
- package/src/unstable/cluster/EntityProxy.ts +3 -3
- package/src/unstable/cluster/EntityProxyServer.ts +6 -6
- package/src/unstable/cluster/EntityResource.ts +6 -6
- package/src/unstable/cluster/HttpRunner.ts +2 -2
- package/src/unstable/cluster/K8sHttpClient.ts +10 -10
- package/src/unstable/cluster/Message.ts +30 -17
- package/src/unstable/cluster/MessageStorage.ts +74 -45
- package/src/unstable/cluster/Reply.ts +13 -10
- package/src/unstable/cluster/Runner.ts +1 -1
- package/src/unstable/cluster/RunnerAddress.ts +1 -1
- package/src/unstable/cluster/RunnerHealth.ts +2 -2
- package/src/unstable/cluster/RunnerServer.ts +11 -14
- package/src/unstable/cluster/RunnerStorage.ts +9 -9
- package/src/unstable/cluster/Runners.ts +22 -18
- package/src/unstable/cluster/ShardId.ts +84 -74
- package/src/unstable/cluster/Sharding.ts +75 -60
- package/src/unstable/cluster/ShardingConfig.ts +39 -40
- package/src/unstable/cluster/Snowflake.ts +2 -2
- package/src/unstable/cluster/SqlMessageStorage.ts +29 -20
- package/src/unstable/cluster/SqlRunnerStorage.ts +13 -7
- package/src/unstable/cluster/internal/entityManager.ts +60 -41
- package/src/unstable/cluster/internal/entityReaper.ts +2 -2
- package/src/unstable/cluster/internal/resourceMap.ts +3 -3
- package/src/unstable/devtools/DevToolsClient.ts +26 -21
- package/src/unstable/devtools/DevToolsSchema.ts +16 -3
- package/src/unstable/encoding/Ndjson.ts +17 -17
- package/src/unstable/encoding/Sse.ts +3 -5
- package/src/unstable/eventlog/Event.ts +0 -8
- package/src/unstable/eventlog/EventGroup.ts +0 -4
- package/src/unstable/eventlog/EventJournal.ts +148 -80
- package/src/unstable/eventlog/EventLog.ts +360 -234
- package/src/unstable/eventlog/EventLogEncryption.ts +18 -32
- package/src/unstable/eventlog/EventLogMessage.ts +277 -0
- package/src/unstable/eventlog/EventLogRemote.ts +264 -410
- package/src/unstable/eventlog/EventLogServer.ts +183 -275
- package/src/unstable/eventlog/EventLogServerEncrypted.ts +206 -0
- package/src/unstable/eventlog/EventLogServerUnencrypted.ts +749 -0
- package/src/unstable/eventlog/EventLogSessionAuth.ts +437 -0
- package/src/unstable/eventlog/{SqlEventLogJournal.ts → SqlEventJournal.ts} +38 -22
- package/src/unstable/eventlog/{SqlEventLogServer.ts → SqlEventLogServerEncrypted.ts} +110 -43
- package/src/unstable/eventlog/SqlEventLogServerUnencrypted.ts +506 -0
- package/src/unstable/eventlog/index.ts +27 -2
- package/src/unstable/eventlog/internal/identityRootSecretDerivation.ts +153 -0
- package/src/unstable/http/Cookies.ts +94 -11
- package/src/unstable/http/Etag.ts +7 -5
- package/src/unstable/http/FetchHttpClient.ts +5 -5
- package/src/unstable/http/Headers.ts +70 -20
- package/src/unstable/http/HttpClient.ts +385 -42
- package/src/unstable/http/HttpClientRequest.ts +151 -39
- package/src/unstable/http/HttpClientResponse.ts +24 -8
- package/src/unstable/http/HttpEffect.ts +71 -77
- package/src/unstable/http/HttpIncomingMessage.ts +9 -8
- package/src/unstable/http/HttpMethod.ts +16 -4
- package/src/unstable/http/HttpMiddleware.ts +50 -50
- package/src/unstable/http/HttpPlatform.ts +5 -4
- package/src/unstable/http/HttpRouter.ts +46 -46
- package/src/unstable/http/HttpServer.ts +5 -11
- package/src/unstable/http/HttpServerError.ts +45 -47
- package/src/unstable/http/HttpServerRequest.ts +414 -23
- package/src/unstable/http/HttpServerRespondable.ts +6 -6
- package/src/unstable/http/HttpServerResponse.ts +351 -13
- package/src/unstable/http/HttpStaticServer.ts +456 -0
- package/src/unstable/http/HttpTraceContext.ts +31 -17
- package/src/unstable/http/Multipart.ts +8 -8
- package/src/unstable/http/Url.ts +650 -0
- package/src/unstable/http/UrlParams.ts +30 -18
- package/src/unstable/http/index.ts +10 -0
- package/src/unstable/http/internal/preResponseHandler.ts +15 -0
- package/src/unstable/httpapi/HttpApi.ts +22 -22
- package/src/unstable/httpapi/HttpApiBuilder.ts +156 -66
- package/src/unstable/httpapi/HttpApiClient.ts +185 -34
- package/src/unstable/httpapi/HttpApiEndpoint.ts +225 -114
- package/src/unstable/httpapi/HttpApiError.ts +129 -30
- package/src/unstable/httpapi/HttpApiGroup.ts +18 -17
- package/src/unstable/httpapi/HttpApiMiddleware.ts +95 -32
- package/src/unstable/httpapi/HttpApiSchema.ts +106 -11
- package/src/unstable/httpapi/HttpApiSecurity.ts +13 -13
- package/src/unstable/httpapi/OpenApi.ts +74 -73
- package/src/unstable/observability/Otlp.ts +12 -12
- package/src/unstable/observability/OtlpExporter.ts +14 -10
- package/src/unstable/observability/OtlpLogger.ts +13 -9
- package/src/unstable/observability/OtlpMetrics.ts +6 -6
- package/src/unstable/observability/OtlpSerialization.ts +2 -2
- package/src/unstable/observability/OtlpTracer.ts +14 -10
- package/src/unstable/observability/PrometheusMetrics.ts +5 -5
- package/src/unstable/observability/internal/protobuf.ts +4 -4
- package/src/unstable/persistence/KeyValueStore.ts +226 -3
- package/src/unstable/persistence/Persistable.ts +3 -3
- package/src/unstable/persistence/PersistedCache.ts +20 -17
- package/src/unstable/persistence/PersistedQueue.ts +21 -21
- package/src/unstable/persistence/Persistence.ts +7 -7
- package/src/unstable/persistence/RateLimiter.ts +7 -7
- package/src/unstable/persistence/Redis.ts +2 -2
- package/src/unstable/process/ChildProcess.ts +6 -208
- package/src/unstable/process/ChildProcessSpawner.ts +114 -15
- package/src/unstable/reactivity/AsyncResult.ts +59 -17
- package/src/unstable/reactivity/Atom.ts +280 -124
- package/src/unstable/reactivity/AtomHttpApi.ts +127 -61
- package/src/unstable/reactivity/AtomRegistry.ts +70 -16
- package/src/unstable/reactivity/AtomRpc.ts +82 -37
- package/src/unstable/reactivity/Reactivity.ts +6 -6
- package/src/unstable/rpc/Rpc.ts +212 -32
- package/src/unstable/rpc/RpcClient.ts +161 -142
- package/src/unstable/rpc/RpcGroup.ts +51 -34
- package/src/unstable/rpc/RpcMiddleware.ts +28 -22
- package/src/unstable/rpc/RpcSchema.ts +24 -6
- package/src/unstable/rpc/RpcSerialization.ts +97 -54
- package/src/unstable/rpc/RpcServer.ts +91 -65
- package/src/unstable/rpc/RpcWorker.ts +5 -5
- package/src/unstable/rpc/Utils.ts +63 -4
- package/src/unstable/schema/Model.ts +35 -6
- package/src/unstable/schema/VariantSchema.ts +14 -27
- package/src/unstable/socket/Socket.ts +102 -62
- package/src/unstable/socket/SocketServer.ts +2 -2
- package/src/unstable/sql/Migrator.ts +7 -5
- package/src/unstable/sql/SqlClient.ts +48 -19
- package/src/unstable/sql/SqlConnection.ts +2 -2
- package/src/unstable/sql/SqlError.ts +365 -11
- package/src/unstable/sql/SqlModel.ts +57 -85
- package/src/unstable/sql/SqlResolver.ts +28 -20
- package/src/unstable/sql/SqlSchema.ts +42 -26
- package/src/unstable/sql/Statement.ts +21 -25
- package/src/unstable/workers/Transferable.ts +17 -19
- package/src/unstable/workers/Worker.ts +4 -4
- package/src/unstable/workers/WorkerRunner.ts +2 -2
- package/src/unstable/workflow/Activity.ts +36 -13
- package/src/unstable/workflow/DurableClock.ts +11 -11
- package/src/unstable/workflow/DurableDeferred.ts +36 -18
- package/src/unstable/workflow/Workflow.ts +46 -35
- package/src/unstable/workflow/WorkflowEngine.ts +236 -23
- package/src/unstable/workflow/WorkflowProxyServer.ts +4 -4
- package/dist/NullOr.d.ts +0 -149
- package/dist/NullOr.d.ts.map +0 -1
- package/dist/NullOr.js +0 -152
- package/dist/NullOr.js.map +0 -1
- package/dist/ServiceMap.d.ts +0 -1126
- package/dist/ServiceMap.d.ts.map +0 -1
- package/dist/ServiceMap.js.map +0 -1
- package/dist/internal/schema/to-codec.d.ts +0 -2
- package/dist/internal/schema/to-codec.d.ts.map +0 -1
- package/dist/internal/schema/to-codec.js +0 -129
- package/dist/internal/schema/to-codec.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/dist/unstable/cli/internal/completions/CommandDescriptor.d.ts +0 -2
- package/dist/unstable/cli/internal/completions/CommandDescriptor.d.ts.map +0 -1
- package/dist/unstable/cli/internal/completions/CommandDescriptor.js.map +0 -1
- package/dist/unstable/cli/internal/completions/Completions.d.ts +0 -2
- package/dist/unstable/cli/internal/completions/Completions.d.ts.map +0 -1
- package/dist/unstable/cli/internal/completions/Completions.js +0 -23
- package/dist/unstable/cli/internal/completions/Completions.js.map +0 -1
- package/dist/unstable/eventlog/SqlEventLogJournal.d.ts.map +0 -1
- package/dist/unstable/eventlog/SqlEventLogJournal.js.map +0 -1
- package/dist/unstable/eventlog/SqlEventLogServer.d.ts.map +0 -1
- package/dist/unstable/eventlog/SqlEventLogServer.js.map +0 -1
- package/src/NullOr.ts +0 -204
- package/src/ServiceMap.ts +0 -1410
- package/src/internal/schema/to-codec.ts +0 -148
- package/src/unstable/cli/internal/builtInFlags.ts +0 -78
- package/src/unstable/cli/internal/completions/Completions.ts +0 -31
package/dist/Effect.d.ts
CHANGED
|
@@ -40,12 +40,14 @@
|
|
|
40
40
|
*
|
|
41
41
|
* @example
|
|
42
42
|
* ```ts
|
|
43
|
-
* import { Effect } from "effect"
|
|
43
|
+
* import { Data, Effect } from "effect"
|
|
44
|
+
*
|
|
45
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
44
46
|
*
|
|
45
47
|
* // Effect that may fail
|
|
46
48
|
* const divide = (a: number, b: number) =>
|
|
47
49
|
* b === 0
|
|
48
|
-
* ? Effect.fail(new
|
|
50
|
+
* ? Effect.fail(new DiscountRateError())
|
|
49
51
|
* : Effect.succeed(a / b)
|
|
50
52
|
*
|
|
51
53
|
* // Error handling
|
|
@@ -69,6 +71,7 @@
|
|
|
69
71
|
import type * as Arr from "./Array.ts";
|
|
70
72
|
import type * as Cause from "./Cause.ts";
|
|
71
73
|
import type { Clock } from "./Clock.ts";
|
|
74
|
+
import * as Context from "./Context.ts";
|
|
72
75
|
import * as Duration from "./Duration.ts";
|
|
73
76
|
import type { ExecutionPlan } from "./ExecutionPlan.ts";
|
|
74
77
|
import * as Exit from "./Exit.ts";
|
|
@@ -76,9 +79,10 @@ import type { Fiber } from "./Fiber.ts";
|
|
|
76
79
|
import type * as Filter from "./Filter.ts";
|
|
77
80
|
import { type LazyArg } from "./Function.ts";
|
|
78
81
|
import type { TypeLambda } from "./HKT.ts";
|
|
82
|
+
import type { Inspectable } from "./Inspectable.ts";
|
|
79
83
|
import type * as Layer from "./Layer.ts";
|
|
80
84
|
import type { Logger } from "./Logger.ts";
|
|
81
|
-
import type {
|
|
85
|
+
import type { Severity } from "./LogLevel.ts";
|
|
82
86
|
import * as Metric from "./Metric.ts";
|
|
83
87
|
import type { Option } from "./Option.ts";
|
|
84
88
|
import type { Pipeable } from "./Pipeable.ts";
|
|
@@ -89,10 +93,9 @@ import type * as Result from "./Result.ts";
|
|
|
89
93
|
import type { Schedule } from "./Schedule.ts";
|
|
90
94
|
import type { Scheduler } from "./Scheduler.ts";
|
|
91
95
|
import type { Scope } from "./Scope.ts";
|
|
92
|
-
import * as ServiceMap from "./ServiceMap.ts";
|
|
93
96
|
import type { AnySpan, ParentSpan, Span, SpanLink, SpanOptions, SpanOptionsNoTrace, TraceOptions, Tracer } from "./Tracer.ts";
|
|
94
97
|
import type { TxRef } from "./TxRef.ts";
|
|
95
|
-
import type { Concurrency, Covariant, EqualsWith, ExcludeReason, ExcludeTag, ExtractReason, ExtractTag, NoInfer, ReasonOf, ReasonTags, Tags, unassigned } from "./Types.ts";
|
|
98
|
+
import type { Concurrency, Covariant, EqualsWith, ExcludeReason, ExcludeTag, ExtractReason, ExtractTag, NarrowReason, NoInfer, OmitReason, ReasonOf, ReasonTags, Simplify, Tags, unassigned } from "./Types.ts";
|
|
96
99
|
import type * as Unify from "./Unify.ts";
|
|
97
100
|
declare const TypeId: "~effect/Effect";
|
|
98
101
|
/**
|
|
@@ -111,13 +114,15 @@ declare const TypeId: "~effect/Effect";
|
|
|
111
114
|
*
|
|
112
115
|
* @example
|
|
113
116
|
* ```ts
|
|
114
|
-
* import { Effect } from "effect"
|
|
117
|
+
* import { Data, Effect } from "effect"
|
|
118
|
+
*
|
|
119
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
115
120
|
*
|
|
116
121
|
* // A simple effect that succeeds with a value
|
|
117
122
|
* const success = Effect.succeed(42)
|
|
118
123
|
*
|
|
119
|
-
* // An effect that
|
|
120
|
-
* const risky = Effect.fail(new
|
|
124
|
+
* // An effect that will always fail
|
|
125
|
+
* const risky = Effect.fail(new TaskError({ message: "Something went wrong" }))
|
|
121
126
|
*
|
|
122
127
|
* // Effects can be composed using generator functions
|
|
123
128
|
* const program = Effect.gen(function*() {
|
|
@@ -130,11 +135,11 @@ declare const TypeId: "~effect/Effect";
|
|
|
130
135
|
* @since 2.0.0
|
|
131
136
|
* @category Models
|
|
132
137
|
*/
|
|
133
|
-
export interface Effect<out A, out E = never, out R = never> extends Pipeable, Yieldable<Effect<A, E, R>, A, E, R> {
|
|
138
|
+
export interface Effect<out A, out E = never, out R = never> extends Pipeable, Inspectable, Yieldable<Effect<A, E, R>, A, E, R> {
|
|
134
139
|
readonly [TypeId]: Variance<A, E, R>;
|
|
135
140
|
[Unify.typeSymbol]?: unknown;
|
|
136
141
|
[Unify.unifySymbol]?: EffectUnify<this>;
|
|
137
|
-
[Unify.ignoreSymbol]?:
|
|
142
|
+
[Unify.ignoreSymbol]?: {};
|
|
138
143
|
}
|
|
139
144
|
/**
|
|
140
145
|
* A type that can be yielded in an Effect generator function.
|
|
@@ -191,21 +196,6 @@ export interface EffectUnify<A extends {
|
|
|
191
196
|
}> {
|
|
192
197
|
Effect?: () => A[Unify.typeSymbol] extends Effect<infer A0, infer E0, infer R0> | infer _ ? Effect<A0, E0, R0> : never;
|
|
193
198
|
}
|
|
194
|
-
/**
|
|
195
|
-
* @category Models
|
|
196
|
-
* @since 2.0.0
|
|
197
|
-
* @example
|
|
198
|
-
* ```ts
|
|
199
|
-
* import type { Effect } from "effect"
|
|
200
|
-
*
|
|
201
|
-
* // EffectUnifyIgnore is used internally to control type unification
|
|
202
|
-
* // It prevents certain types from being unified with Effect types
|
|
203
|
-
* declare const ignored: Effect.EffectUnifyIgnore
|
|
204
|
-
* ```
|
|
205
|
-
*/
|
|
206
|
-
export interface EffectUnifyIgnore {
|
|
207
|
-
Effect?: true;
|
|
208
|
-
}
|
|
209
199
|
/**
|
|
210
200
|
* @category Type Lambdas
|
|
211
201
|
* @since 2.0.0
|
|
@@ -367,13 +357,15 @@ export declare namespace All {
|
|
|
367
357
|
* @category Models
|
|
368
358
|
* @example
|
|
369
359
|
* ```ts
|
|
370
|
-
* import { Effect } from "effect"
|
|
360
|
+
* import { Data, Effect } from "effect"
|
|
361
|
+
*
|
|
362
|
+
* class OopsError extends Data.TaggedError("OopsError")<{}> {}
|
|
371
363
|
*
|
|
372
364
|
* // EffectAny represents an Effect with any type parameters
|
|
373
365
|
* const effects: Array<Effect.All.EffectAny> = [
|
|
374
366
|
* Effect.succeed(42),
|
|
375
367
|
* Effect.succeed("hello"),
|
|
376
|
-
* Effect.fail(new
|
|
368
|
+
* Effect.fail(new OopsError())
|
|
377
369
|
* ]
|
|
378
370
|
* ```
|
|
379
371
|
*/
|
|
@@ -625,7 +617,6 @@ export declare namespace All {
|
|
|
625
617
|
* ```
|
|
626
618
|
*
|
|
627
619
|
* @see {@link forEach} for iterating over elements and applying an effect.
|
|
628
|
-
* @see {@link allWith} for a data-last version of this function.
|
|
629
620
|
*
|
|
630
621
|
* @since 2.0.0
|
|
631
622
|
* @category Collecting
|
|
@@ -724,6 +715,291 @@ export declare const partition: {
|
|
|
724
715
|
readonly concurrency?: Concurrency | undefined;
|
|
725
716
|
}): Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>;
|
|
726
717
|
};
|
|
718
|
+
/**
|
|
719
|
+
* Applies an effectful function to each element and accumulates all failures.
|
|
720
|
+
*
|
|
721
|
+
* This function always evaluates every element. If at least one effect fails,
|
|
722
|
+
* all failures are returned as a non-empty array and successes are discarded.
|
|
723
|
+
* If all effects succeed, it returns all collected successes.
|
|
724
|
+
*
|
|
725
|
+
* Use `discard: true` to ignore successful values while still validating all
|
|
726
|
+
* elements.
|
|
727
|
+
*
|
|
728
|
+
* @example
|
|
729
|
+
* ```ts
|
|
730
|
+
* import { Effect } from "effect"
|
|
731
|
+
*
|
|
732
|
+
* const program = Effect.validate([0, 1, 2, 3], (n) =>
|
|
733
|
+
* n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
|
|
734
|
+
* )
|
|
735
|
+
*
|
|
736
|
+
* Effect.runPromiseExit(program).then(console.log)
|
|
737
|
+
* // {
|
|
738
|
+
* // _id: 'Exit',
|
|
739
|
+
* // _tag: 'Failure',
|
|
740
|
+
* // cause: {
|
|
741
|
+
* // _id: 'Cause',
|
|
742
|
+
* // reasons: [
|
|
743
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '0 is even' },
|
|
744
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '2 is even' }
|
|
745
|
+
* // ]
|
|
746
|
+
* // }
|
|
747
|
+
* // }
|
|
748
|
+
* ```
|
|
749
|
+
*
|
|
750
|
+
* @since 4.0.0
|
|
751
|
+
* @category Error Accumulation
|
|
752
|
+
*/
|
|
753
|
+
export declare const validate: {
|
|
754
|
+
/**
|
|
755
|
+
* Applies an effectful function to each element and accumulates all failures.
|
|
756
|
+
*
|
|
757
|
+
* This function always evaluates every element. If at least one effect fails,
|
|
758
|
+
* all failures are returned as a non-empty array and successes are discarded.
|
|
759
|
+
* If all effects succeed, it returns all collected successes.
|
|
760
|
+
*
|
|
761
|
+
* Use `discard: true` to ignore successful values while still validating all
|
|
762
|
+
* elements.
|
|
763
|
+
*
|
|
764
|
+
* @example
|
|
765
|
+
* ```ts
|
|
766
|
+
* import { Effect } from "effect"
|
|
767
|
+
*
|
|
768
|
+
* const program = Effect.validate([0, 1, 2, 3], (n) =>
|
|
769
|
+
* n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
|
|
770
|
+
* )
|
|
771
|
+
*
|
|
772
|
+
* Effect.runPromiseExit(program).then(console.log)
|
|
773
|
+
* // {
|
|
774
|
+
* // _id: 'Exit',
|
|
775
|
+
* // _tag: 'Failure',
|
|
776
|
+
* // cause: {
|
|
777
|
+
* // _id: 'Cause',
|
|
778
|
+
* // reasons: [
|
|
779
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '0 is even' },
|
|
780
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '2 is even' }
|
|
781
|
+
* // ]
|
|
782
|
+
* // }
|
|
783
|
+
* // }
|
|
784
|
+
* ```
|
|
785
|
+
*
|
|
786
|
+
* @since 4.0.0
|
|
787
|
+
* @category Error Accumulation
|
|
788
|
+
*/
|
|
789
|
+
<A, B, E, R>(f: (a: A, i: number) => Effect<B, E, R>, options?: {
|
|
790
|
+
readonly concurrency?: Concurrency | undefined;
|
|
791
|
+
readonly discard?: false | undefined;
|
|
792
|
+
} | undefined): (elements: Iterable<A>) => Effect<Array<B>, Arr.NonEmptyArray<E>, R>;
|
|
793
|
+
/**
|
|
794
|
+
* Applies an effectful function to each element and accumulates all failures.
|
|
795
|
+
*
|
|
796
|
+
* This function always evaluates every element. If at least one effect fails,
|
|
797
|
+
* all failures are returned as a non-empty array and successes are discarded.
|
|
798
|
+
* If all effects succeed, it returns all collected successes.
|
|
799
|
+
*
|
|
800
|
+
* Use `discard: true` to ignore successful values while still validating all
|
|
801
|
+
* elements.
|
|
802
|
+
*
|
|
803
|
+
* @example
|
|
804
|
+
* ```ts
|
|
805
|
+
* import { Effect } from "effect"
|
|
806
|
+
*
|
|
807
|
+
* const program = Effect.validate([0, 1, 2, 3], (n) =>
|
|
808
|
+
* n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
|
|
809
|
+
* )
|
|
810
|
+
*
|
|
811
|
+
* Effect.runPromiseExit(program).then(console.log)
|
|
812
|
+
* // {
|
|
813
|
+
* // _id: 'Exit',
|
|
814
|
+
* // _tag: 'Failure',
|
|
815
|
+
* // cause: {
|
|
816
|
+
* // _id: 'Cause',
|
|
817
|
+
* // reasons: [
|
|
818
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '0 is even' },
|
|
819
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '2 is even' }
|
|
820
|
+
* // ]
|
|
821
|
+
* // }
|
|
822
|
+
* // }
|
|
823
|
+
* ```
|
|
824
|
+
*
|
|
825
|
+
* @since 4.0.0
|
|
826
|
+
* @category Error Accumulation
|
|
827
|
+
*/
|
|
828
|
+
<A, B, E, R>(f: (a: A, i: number) => Effect<B, E, R>, options: {
|
|
829
|
+
readonly concurrency?: Concurrency | undefined;
|
|
830
|
+
readonly discard: true;
|
|
831
|
+
}): (elements: Iterable<A>) => Effect<void, Arr.NonEmptyArray<E>, R>;
|
|
832
|
+
/**
|
|
833
|
+
* Applies an effectful function to each element and accumulates all failures.
|
|
834
|
+
*
|
|
835
|
+
* This function always evaluates every element. If at least one effect fails,
|
|
836
|
+
* all failures are returned as a non-empty array and successes are discarded.
|
|
837
|
+
* If all effects succeed, it returns all collected successes.
|
|
838
|
+
*
|
|
839
|
+
* Use `discard: true` to ignore successful values while still validating all
|
|
840
|
+
* elements.
|
|
841
|
+
*
|
|
842
|
+
* @example
|
|
843
|
+
* ```ts
|
|
844
|
+
* import { Effect } from "effect"
|
|
845
|
+
*
|
|
846
|
+
* const program = Effect.validate([0, 1, 2, 3], (n) =>
|
|
847
|
+
* n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
|
|
848
|
+
* )
|
|
849
|
+
*
|
|
850
|
+
* Effect.runPromiseExit(program).then(console.log)
|
|
851
|
+
* // {
|
|
852
|
+
* // _id: 'Exit',
|
|
853
|
+
* // _tag: 'Failure',
|
|
854
|
+
* // cause: {
|
|
855
|
+
* // _id: 'Cause',
|
|
856
|
+
* // reasons: [
|
|
857
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '0 is even' },
|
|
858
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '2 is even' }
|
|
859
|
+
* // ]
|
|
860
|
+
* // }
|
|
861
|
+
* // }
|
|
862
|
+
* ```
|
|
863
|
+
*
|
|
864
|
+
* @since 4.0.0
|
|
865
|
+
* @category Error Accumulation
|
|
866
|
+
*/
|
|
867
|
+
<A, B, E, R>(elements: Iterable<A>, f: (a: A, i: number) => Effect<B, E, R>, options?: {
|
|
868
|
+
readonly concurrency?: Concurrency | undefined;
|
|
869
|
+
readonly discard?: false | undefined;
|
|
870
|
+
} | undefined): Effect<Array<B>, Arr.NonEmptyArray<E>, R>;
|
|
871
|
+
/**
|
|
872
|
+
* Applies an effectful function to each element and accumulates all failures.
|
|
873
|
+
*
|
|
874
|
+
* This function always evaluates every element. If at least one effect fails,
|
|
875
|
+
* all failures are returned as a non-empty array and successes are discarded.
|
|
876
|
+
* If all effects succeed, it returns all collected successes.
|
|
877
|
+
*
|
|
878
|
+
* Use `discard: true` to ignore successful values while still validating all
|
|
879
|
+
* elements.
|
|
880
|
+
*
|
|
881
|
+
* @example
|
|
882
|
+
* ```ts
|
|
883
|
+
* import { Effect } from "effect"
|
|
884
|
+
*
|
|
885
|
+
* const program = Effect.validate([0, 1, 2, 3], (n) =>
|
|
886
|
+
* n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
|
|
887
|
+
* )
|
|
888
|
+
*
|
|
889
|
+
* Effect.runPromiseExit(program).then(console.log)
|
|
890
|
+
* // {
|
|
891
|
+
* // _id: 'Exit',
|
|
892
|
+
* // _tag: 'Failure',
|
|
893
|
+
* // cause: {
|
|
894
|
+
* // _id: 'Cause',
|
|
895
|
+
* // reasons: [
|
|
896
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '0 is even' },
|
|
897
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '2 is even' }
|
|
898
|
+
* // ]
|
|
899
|
+
* // }
|
|
900
|
+
* // }
|
|
901
|
+
* ```
|
|
902
|
+
*
|
|
903
|
+
* @since 4.0.0
|
|
904
|
+
* @category Error Accumulation
|
|
905
|
+
*/
|
|
906
|
+
<A, B, E, R>(elements: Iterable<A>, f: (a: A, i: number) => Effect<B, E, R>, options: {
|
|
907
|
+
readonly concurrency?: Concurrency | undefined;
|
|
908
|
+
readonly discard: true;
|
|
909
|
+
}): Effect<void, Arr.NonEmptyArray<E>, R>;
|
|
910
|
+
};
|
|
911
|
+
/**
|
|
912
|
+
* Returns the first element that satisfies an effectful predicate.
|
|
913
|
+
*
|
|
914
|
+
* The predicate receives the element and its index. Evaluation short-circuits
|
|
915
|
+
* as soon as an element matches.
|
|
916
|
+
*
|
|
917
|
+
* @example
|
|
918
|
+
* ```ts
|
|
919
|
+
* import { Effect } from "effect"
|
|
920
|
+
*
|
|
921
|
+
* const program = Effect.findFirst([1, 2, 3, 4], (n) => Effect.succeed(n > 2))
|
|
922
|
+
*
|
|
923
|
+
* Effect.runPromise(program).then(console.log)
|
|
924
|
+
* // { _id: 'Option', _tag: 'Some', value: 3 }
|
|
925
|
+
* ```
|
|
926
|
+
*
|
|
927
|
+
* @since 2.0.0
|
|
928
|
+
* @category Collecting
|
|
929
|
+
*/
|
|
930
|
+
export declare const findFirst: {
|
|
931
|
+
/**
|
|
932
|
+
* Returns the first element that satisfies an effectful predicate.
|
|
933
|
+
*
|
|
934
|
+
* The predicate receives the element and its index. Evaluation short-circuits
|
|
935
|
+
* as soon as an element matches.
|
|
936
|
+
*
|
|
937
|
+
* @example
|
|
938
|
+
* ```ts
|
|
939
|
+
* import { Effect } from "effect"
|
|
940
|
+
*
|
|
941
|
+
* const program = Effect.findFirst([1, 2, 3, 4], (n) => Effect.succeed(n > 2))
|
|
942
|
+
*
|
|
943
|
+
* Effect.runPromise(program).then(console.log)
|
|
944
|
+
* // { _id: 'Option', _tag: 'Some', value: 3 }
|
|
945
|
+
* ```
|
|
946
|
+
*
|
|
947
|
+
* @since 2.0.0
|
|
948
|
+
* @category Collecting
|
|
949
|
+
*/
|
|
950
|
+
<A, E, R>(predicate: (a: NoInfer<A>, i: number) => Effect<boolean, E, R>): (elements: Iterable<A>) => Effect<Option<A>, E, R>;
|
|
951
|
+
/**
|
|
952
|
+
* Returns the first element that satisfies an effectful predicate.
|
|
953
|
+
*
|
|
954
|
+
* The predicate receives the element and its index. Evaluation short-circuits
|
|
955
|
+
* as soon as an element matches.
|
|
956
|
+
*
|
|
957
|
+
* @example
|
|
958
|
+
* ```ts
|
|
959
|
+
* import { Effect } from "effect"
|
|
960
|
+
*
|
|
961
|
+
* const program = Effect.findFirst([1, 2, 3, 4], (n) => Effect.succeed(n > 2))
|
|
962
|
+
*
|
|
963
|
+
* Effect.runPromise(program).then(console.log)
|
|
964
|
+
* // { _id: 'Option', _tag: 'Some', value: 3 }
|
|
965
|
+
* ```
|
|
966
|
+
*
|
|
967
|
+
* @since 2.0.0
|
|
968
|
+
* @category Collecting
|
|
969
|
+
*/
|
|
970
|
+
<A, E, R>(elements: Iterable<A>, predicate: (a: NoInfer<A>, i: number) => Effect<boolean, E, R>): Effect<Option<A>, E, R>;
|
|
971
|
+
};
|
|
972
|
+
/**
|
|
973
|
+
* Returns the first value that passes an effectful `FilterEffect`.
|
|
974
|
+
*
|
|
975
|
+
* The filter receives the element and index. Evaluation short-circuits on the
|
|
976
|
+
* first `Result.succeed` and returns the transformed value in `Option.some`.
|
|
977
|
+
*
|
|
978
|
+
* @since 4.0.0
|
|
979
|
+
* @category Collecting
|
|
980
|
+
*/
|
|
981
|
+
export declare const findFirstFilter: {
|
|
982
|
+
/**
|
|
983
|
+
* Returns the first value that passes an effectful `FilterEffect`.
|
|
984
|
+
*
|
|
985
|
+
* The filter receives the element and index. Evaluation short-circuits on the
|
|
986
|
+
* first `Result.succeed` and returns the transformed value in `Option.some`.
|
|
987
|
+
*
|
|
988
|
+
* @since 4.0.0
|
|
989
|
+
* @category Collecting
|
|
990
|
+
*/
|
|
991
|
+
<A, B, X, E, R>(filter: (input: NoInfer<A>, i: number) => Effect<Result.Result<B, X>, E, R>): (elements: Iterable<A>) => Effect<Option<B>, E, R>;
|
|
992
|
+
/**
|
|
993
|
+
* Returns the first value that passes an effectful `FilterEffect`.
|
|
994
|
+
*
|
|
995
|
+
* The filter receives the element and index. Evaluation short-circuits on the
|
|
996
|
+
* first `Result.succeed` and returns the transformed value in `Option.some`.
|
|
997
|
+
*
|
|
998
|
+
* @since 4.0.0
|
|
999
|
+
* @category Collecting
|
|
1000
|
+
*/
|
|
1001
|
+
<A, B, X, E, R>(elements: Iterable<A>, filter: (input: NoInfer<A>, i: number) => Effect<Result.Result<B, X>, E, R>): Effect<Option<B>, E, R>;
|
|
1002
|
+
};
|
|
727
1003
|
/**
|
|
728
1004
|
* Executes an effectful operation for each element in an `Iterable`.
|
|
729
1005
|
*
|
|
@@ -1068,16 +1344,18 @@ export declare const promise: <A>(evaluate: (signal: AbortSignal) => PromiseLike
|
|
|
1068
1344
|
*
|
|
1069
1345
|
* @example Custom Error Handling
|
|
1070
1346
|
* ```ts
|
|
1071
|
-
* import { Effect } from "effect"
|
|
1347
|
+
* import { Data, Effect } from "effect"
|
|
1348
|
+
*
|
|
1349
|
+
* class TodoFetchError extends Data.TaggedError("TodoFetchError")<{ readonly cause: unknown }> {}
|
|
1072
1350
|
*
|
|
1073
1351
|
* const getTodo = (id: number) =>
|
|
1074
1352
|
* Effect.tryPromise({
|
|
1075
1353
|
* try: () => fetch(`https://jsonplaceholder.typicode.com/todos/${id}`),
|
|
1076
1354
|
* // remap the error
|
|
1077
|
-
* catch: (
|
|
1355
|
+
* catch: (cause) => new TodoFetchError({ cause })
|
|
1078
1356
|
* })
|
|
1079
1357
|
*
|
|
1080
|
-
* // ┌─── Effect<Response,
|
|
1358
|
+
* // ┌─── Effect<Response, TodoFetchError, never>
|
|
1081
1359
|
* // ▼
|
|
1082
1360
|
* const program = getTodo(1)
|
|
1083
1361
|
* ```
|
|
@@ -1307,8 +1585,13 @@ undefined_ as undefined };
|
|
|
1307
1585
|
*
|
|
1308
1586
|
* **When to Use**
|
|
1309
1587
|
*
|
|
1310
|
-
* Use `Effect.
|
|
1588
|
+
* Use `Effect.callback` when dealing with APIs that use callback-style instead of
|
|
1311
1589
|
* `async/await` or `Promise`.
|
|
1590
|
+
* * **Previously Known As**
|
|
1591
|
+
*
|
|
1592
|
+
* This API replaces the following from Effect 3.x:
|
|
1593
|
+
*
|
|
1594
|
+
* - `Effect.async`
|
|
1312
1595
|
*
|
|
1313
1596
|
* @example
|
|
1314
1597
|
* ```ts
|
|
@@ -1352,6 +1635,90 @@ export declare const callback: <A, E = never, R = never>(register: (this: Schedu
|
|
|
1352
1635
|
* @category Creating Effects
|
|
1353
1636
|
*/
|
|
1354
1637
|
export declare const never: Effect<never>;
|
|
1638
|
+
/**
|
|
1639
|
+
* An `Effect` containing an empty record `{}`, used as the starting point for
|
|
1640
|
+
* do notation chains.
|
|
1641
|
+
*
|
|
1642
|
+
* @example
|
|
1643
|
+
* ```ts
|
|
1644
|
+
* import { Effect } from "effect"
|
|
1645
|
+
* import { pipe } from "effect/Function"
|
|
1646
|
+
*
|
|
1647
|
+
* const program = pipe(
|
|
1648
|
+
* Effect.Do,
|
|
1649
|
+
* Effect.bind("x", () => Effect.succeed(2)),
|
|
1650
|
+
* Effect.bind("y", ({ x }) => Effect.succeed(x + 1)),
|
|
1651
|
+
* Effect.let("sum", ({ x, y }) => x + y)
|
|
1652
|
+
* )
|
|
1653
|
+
* ```
|
|
1654
|
+
*
|
|
1655
|
+
* @since 4.0.0
|
|
1656
|
+
* @category Do notation
|
|
1657
|
+
*/
|
|
1658
|
+
export declare const Do: Effect<{}>;
|
|
1659
|
+
/**
|
|
1660
|
+
* Gives a name to the success value of an `Effect`, creating a single-key
|
|
1661
|
+
* record used in do notation pipelines.
|
|
1662
|
+
*
|
|
1663
|
+
* @since 4.0.0
|
|
1664
|
+
* @category Do notation
|
|
1665
|
+
*/
|
|
1666
|
+
export declare const bindTo: {
|
|
1667
|
+
/**
|
|
1668
|
+
* Gives a name to the success value of an `Effect`, creating a single-key
|
|
1669
|
+
* record used in do notation pipelines.
|
|
1670
|
+
*
|
|
1671
|
+
* @since 4.0.0
|
|
1672
|
+
* @category Do notation
|
|
1673
|
+
*/
|
|
1674
|
+
<N extends string>(name: N): <A, E, R>(self: Effect<A, E, R>) => Effect<{
|
|
1675
|
+
[K in N]: A;
|
|
1676
|
+
}, E, R>;
|
|
1677
|
+
/**
|
|
1678
|
+
* Gives a name to the success value of an `Effect`, creating a single-key
|
|
1679
|
+
* record used in do notation pipelines.
|
|
1680
|
+
*
|
|
1681
|
+
* @since 4.0.0
|
|
1682
|
+
* @category Do notation
|
|
1683
|
+
*/
|
|
1684
|
+
<A, E, R, N extends string>(self: Effect<A, E, R>, name: N): Effect<{
|
|
1685
|
+
[K in N]: A;
|
|
1686
|
+
}, E, R>;
|
|
1687
|
+
};
|
|
1688
|
+
declare const let_: {
|
|
1689
|
+
<N extends string, A extends Record<string, any>, B>(name: N, f: (a: NoInfer<A>) => B): <E, R>(self: Effect<A, E, R>) => Effect<Simplify<Omit<A, N> & Record<N, B>>, E, R>;
|
|
1690
|
+
<A extends Record<string, any>, E, R, B, N extends string>(self: Effect<A, E, R>, name: N, f: (a: NoInfer<A>) => B): Effect<Simplify<Omit<A, N> & Record<N, B>>, E, R>;
|
|
1691
|
+
};
|
|
1692
|
+
export {
|
|
1693
|
+
/**
|
|
1694
|
+
* Adds a computed plain value to the do notation record.
|
|
1695
|
+
*
|
|
1696
|
+
* @since 4.0.0
|
|
1697
|
+
* @category Do notation
|
|
1698
|
+
*/
|
|
1699
|
+
let_ as let };
|
|
1700
|
+
/**
|
|
1701
|
+
* Adds an `Effect` value to the do notation record under a given name.
|
|
1702
|
+
*
|
|
1703
|
+
* @since 4.0.0
|
|
1704
|
+
* @category Do notation
|
|
1705
|
+
*/
|
|
1706
|
+
export declare const bind: {
|
|
1707
|
+
/**
|
|
1708
|
+
* Adds an `Effect` value to the do notation record under a given name.
|
|
1709
|
+
*
|
|
1710
|
+
* @since 4.0.0
|
|
1711
|
+
* @category Do notation
|
|
1712
|
+
*/
|
|
1713
|
+
<N extends string, A extends Record<string, any>, B, E2, R2>(name: N, f: (a: NoInfer<A>) => Effect<B, E2, R2>): <E, R>(self: Effect<A, E, R>) => Effect<Simplify<Omit<A, N> & Record<N, B>>, E | E2, R | R2>;
|
|
1714
|
+
/**
|
|
1715
|
+
* Adds an `Effect` value to the do notation record under a given name.
|
|
1716
|
+
*
|
|
1717
|
+
* @since 4.0.0
|
|
1718
|
+
* @category Do notation
|
|
1719
|
+
*/
|
|
1720
|
+
<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>;
|
|
1721
|
+
};
|
|
1355
1722
|
/**
|
|
1356
1723
|
* Provides a way to write effectful code using generator functions, simplifying
|
|
1357
1724
|
* control flow and error handling.
|
|
@@ -1369,16 +1736,18 @@ export declare const never: Effect<never>;
|
|
|
1369
1736
|
*
|
|
1370
1737
|
* @example
|
|
1371
1738
|
* ```ts
|
|
1372
|
-
* import { Effect } from "effect"
|
|
1739
|
+
* import { Data, Effect } from "effect"
|
|
1740
|
+
*
|
|
1741
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
1373
1742
|
*
|
|
1374
1743
|
* const addServiceCharge = (amount: number) => amount + 1
|
|
1375
1744
|
*
|
|
1376
1745
|
* const applyDiscount = (
|
|
1377
1746
|
* total: number,
|
|
1378
1747
|
* discountRate: number
|
|
1379
|
-
* ): Effect.Effect<number,
|
|
1748
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
1380
1749
|
* discountRate === 0
|
|
1381
|
-
* ? Effect.fail(new
|
|
1750
|
+
* ? Effect.fail(new DiscountRateError())
|
|
1382
1751
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
1383
1752
|
*
|
|
1384
1753
|
* const fetchTransactionAmount = Effect.promise(() => Promise.resolve(100))
|
|
@@ -1418,16 +1787,18 @@ export declare const gen: {
|
|
|
1418
1787
|
*
|
|
1419
1788
|
* @example
|
|
1420
1789
|
* ```ts
|
|
1421
|
-
* import { Effect } from "effect"
|
|
1790
|
+
* import { Data, Effect } from "effect"
|
|
1791
|
+
*
|
|
1792
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
1422
1793
|
*
|
|
1423
1794
|
* const addServiceCharge = (amount: number) => amount + 1
|
|
1424
1795
|
*
|
|
1425
1796
|
* const applyDiscount = (
|
|
1426
1797
|
* total: number,
|
|
1427
1798
|
* discountRate: number
|
|
1428
|
-
* ): Effect.Effect<number,
|
|
1799
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
1429
1800
|
* discountRate === 0
|
|
1430
|
-
* ? Effect.fail(new
|
|
1801
|
+
* ? Effect.fail(new DiscountRateError())
|
|
1431
1802
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
1432
1803
|
*
|
|
1433
1804
|
* const fetchTransactionAmount = Effect.promise(() => Promise.resolve(100))
|
|
@@ -1471,16 +1842,18 @@ export declare const gen: {
|
|
|
1471
1842
|
*
|
|
1472
1843
|
* @example
|
|
1473
1844
|
* ```ts
|
|
1474
|
-
* import { Effect } from "effect"
|
|
1845
|
+
* import { Data, Effect } from "effect"
|
|
1846
|
+
*
|
|
1847
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
1475
1848
|
*
|
|
1476
1849
|
* const addServiceCharge = (amount: number) => amount + 1
|
|
1477
1850
|
*
|
|
1478
1851
|
* const applyDiscount = (
|
|
1479
1852
|
* total: number,
|
|
1480
1853
|
* discountRate: number
|
|
1481
|
-
* ): Effect.Effect<number,
|
|
1854
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
1482
1855
|
* discountRate === 0
|
|
1483
|
-
* ? Effect.fail(new
|
|
1856
|
+
* ? Effect.fail(new DiscountRateError())
|
|
1484
1857
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
1485
1858
|
*
|
|
1486
1859
|
* const fetchTransactionAmount = Effect.promise(() => Promise.resolve(100))
|
|
@@ -1535,12 +1908,14 @@ export declare namespace gen {
|
|
|
1535
1908
|
* @example
|
|
1536
1909
|
* ```ts
|
|
1537
1910
|
* // Title: Creating a Failed Effect
|
|
1538
|
-
* import { Effect } from "effect"
|
|
1911
|
+
* import { Data, Effect } from "effect"
|
|
1539
1912
|
*
|
|
1540
|
-
*
|
|
1913
|
+
* class OperationFailedError extends Data.TaggedError("OperationFailedError")<{}> {}
|
|
1914
|
+
*
|
|
1915
|
+
* // ┌─── Effect<never, OperationFailedError, never>
|
|
1541
1916
|
* // ▼
|
|
1542
1917
|
* const failure = Effect.fail(
|
|
1543
|
-
* new
|
|
1918
|
+
* new OperationFailedError()
|
|
1544
1919
|
* )
|
|
1545
1920
|
* ```
|
|
1546
1921
|
*
|
|
@@ -1556,9 +1931,11 @@ export declare const fail: <E>(error: E) => Effect<never, E>;
|
|
|
1556
1931
|
*
|
|
1557
1932
|
* @example
|
|
1558
1933
|
* ```ts
|
|
1559
|
-
* import { Effect } from "effect"
|
|
1934
|
+
* import { Data, Effect } from "effect"
|
|
1560
1935
|
*
|
|
1561
|
-
*
|
|
1936
|
+
* class ProgramError extends Data.TaggedError("ProgramError")<{ readonly failedAt: Date }> {}
|
|
1937
|
+
*
|
|
1938
|
+
* const program = Effect.failSync(() => new ProgramError({ failedAt: new Date() }))
|
|
1562
1939
|
*
|
|
1563
1940
|
* Effect.runPromiseExit(program).then(console.log)
|
|
1564
1941
|
* // Output: { _id: 'Exit', _tag: 'Failure', cause: ... }
|
|
@@ -1705,12 +2082,14 @@ export {
|
|
|
1705
2082
|
*
|
|
1706
2083
|
* @example Custom Error Handling
|
|
1707
2084
|
* ```ts
|
|
1708
|
-
* import { Effect } from "effect"
|
|
2085
|
+
* import { Data, Effect } from "effect"
|
|
2086
|
+
*
|
|
2087
|
+
* class JsonParsingError extends Data.TaggedError("JsonParsingError")<{ readonly cause: unknown }> {}
|
|
1709
2088
|
*
|
|
1710
2089
|
* const parseJSON = (input: string) =>
|
|
1711
2090
|
* Effect.try({
|
|
1712
2091
|
* try: () => JSON.parse(input),
|
|
1713
|
-
* catch: (
|
|
2092
|
+
* catch: (cause) => new JsonParsingError({ cause })
|
|
1714
2093
|
* })
|
|
1715
2094
|
*
|
|
1716
2095
|
* Effect.runPromiseExit(parseJSON("invalid json")).then(console.log)
|
|
@@ -1832,17 +2211,17 @@ export declare const fromOption: <A>(option: Option<A>) => Effect<A, Cause.NoSuc
|
|
|
1832
2211
|
* ```ts
|
|
1833
2212
|
* import { Console, Effect } from "effect"
|
|
1834
2213
|
*
|
|
1835
|
-
* const input: string | null
|
|
1836
|
-
*
|
|
1837
|
-
* const program = Effect.gen(function*() {
|
|
2214
|
+
* const program = Effect.fn(function*(input: string | null) {
|
|
1838
2215
|
* const value = yield* Effect.fromNullishOr(input)
|
|
1839
2216
|
* yield* Console.log(value)
|
|
1840
|
-
* }
|
|
2217
|
+
* },
|
|
1841
2218
|
* Effect.catch(() => Console.log("missing"))
|
|
1842
2219
|
* )
|
|
1843
2220
|
*
|
|
1844
|
-
* Effect.runPromise(program)
|
|
2221
|
+
* Effect.runPromise(program(null))
|
|
1845
2222
|
* // Output: missing
|
|
2223
|
+
* Effect.runPromise(program("hello"))
|
|
2224
|
+
* // Output: hello
|
|
1846
2225
|
* ```
|
|
1847
2226
|
*
|
|
1848
2227
|
* @since 4.0.0
|
|
@@ -1903,15 +2282,17 @@ export declare const fromYieldable: <Self extends Yieldable.Any, A, E, R>(yielda
|
|
|
1903
2282
|
*
|
|
1904
2283
|
* @example
|
|
1905
2284
|
* ```ts
|
|
1906
|
-
* import { Effect, pipe } from "effect"
|
|
2285
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2286
|
+
*
|
|
2287
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
1907
2288
|
*
|
|
1908
2289
|
* // Function to apply a discount safely to a transaction amount
|
|
1909
2290
|
* const applyDiscount = (
|
|
1910
2291
|
* total: number,
|
|
1911
2292
|
* discountRate: number
|
|
1912
|
-
* ): Effect.Effect<number,
|
|
2293
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
1913
2294
|
* discountRate === 0
|
|
1914
|
-
* ? Effect.fail(new
|
|
2295
|
+
* ? Effect.fail(new DiscountRateError())
|
|
1915
2296
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
1916
2297
|
*
|
|
1917
2298
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -1965,15 +2346,17 @@ export declare const flatMap: {
|
|
|
1965
2346
|
*
|
|
1966
2347
|
* @example
|
|
1967
2348
|
* ```ts
|
|
1968
|
-
* import { Effect, pipe } from "effect"
|
|
2349
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2350
|
+
*
|
|
2351
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
1969
2352
|
*
|
|
1970
2353
|
* // Function to apply a discount safely to a transaction amount
|
|
1971
2354
|
* const applyDiscount = (
|
|
1972
2355
|
* total: number,
|
|
1973
2356
|
* discountRate: number
|
|
1974
|
-
* ): Effect.Effect<number,
|
|
2357
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
1975
2358
|
* discountRate === 0
|
|
1976
|
-
* ? Effect.fail(new
|
|
2359
|
+
* ? Effect.fail(new DiscountRateError())
|
|
1977
2360
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
1978
2361
|
*
|
|
1979
2362
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2027,15 +2410,17 @@ export declare const flatMap: {
|
|
|
2027
2410
|
*
|
|
2028
2411
|
* @example
|
|
2029
2412
|
* ```ts
|
|
2030
|
-
* import { Effect, pipe } from "effect"
|
|
2413
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2414
|
+
*
|
|
2415
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
2031
2416
|
*
|
|
2032
2417
|
* // Function to apply a discount safely to a transaction amount
|
|
2033
2418
|
* const applyDiscount = (
|
|
2034
2419
|
* total: number,
|
|
2035
2420
|
* discountRate: number
|
|
2036
|
-
* ): Effect.Effect<number,
|
|
2421
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2037
2422
|
* discountRate === 0
|
|
2038
|
-
* ? Effect.fail(new
|
|
2423
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2039
2424
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2040
2425
|
*
|
|
2041
2426
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2120,15 +2505,17 @@ export declare const flatten: <A, E, R, E2, R2>(self: Effect<Effect<A, E, R>, E2
|
|
|
2120
2505
|
*
|
|
2121
2506
|
* @example Applying a Discount Based on Fetched Amount
|
|
2122
2507
|
* ```ts
|
|
2123
|
-
* import { Effect, pipe } from "effect"
|
|
2508
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2509
|
+
*
|
|
2510
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
2124
2511
|
*
|
|
2125
2512
|
* // Function to apply a discount safely to a transaction amount
|
|
2126
2513
|
* const applyDiscount = (
|
|
2127
2514
|
* total: number,
|
|
2128
2515
|
* discountRate: number
|
|
2129
|
-
* ): Effect.Effect<number,
|
|
2516
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2130
2517
|
* discountRate === 0
|
|
2131
|
-
* ? Effect.fail(new
|
|
2518
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2132
2519
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2133
2520
|
*
|
|
2134
2521
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2201,15 +2588,17 @@ export declare const andThen: {
|
|
|
2201
2588
|
*
|
|
2202
2589
|
* @example Applying a Discount Based on Fetched Amount
|
|
2203
2590
|
* ```ts
|
|
2204
|
-
* import { Effect, pipe } from "effect"
|
|
2591
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2592
|
+
*
|
|
2593
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
2205
2594
|
*
|
|
2206
2595
|
* // Function to apply a discount safely to a transaction amount
|
|
2207
2596
|
* const applyDiscount = (
|
|
2208
2597
|
* total: number,
|
|
2209
2598
|
* discountRate: number
|
|
2210
|
-
* ): Effect.Effect<number,
|
|
2599
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2211
2600
|
* discountRate === 0
|
|
2212
|
-
* ? Effect.fail(new
|
|
2601
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2213
2602
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2214
2603
|
*
|
|
2215
2604
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2282,15 +2671,17 @@ export declare const andThen: {
|
|
|
2282
2671
|
*
|
|
2283
2672
|
* @example Applying a Discount Based on Fetched Amount
|
|
2284
2673
|
* ```ts
|
|
2285
|
-
* import { Effect, pipe } from "effect"
|
|
2674
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2675
|
+
*
|
|
2676
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
2286
2677
|
*
|
|
2287
2678
|
* // Function to apply a discount safely to a transaction amount
|
|
2288
2679
|
* const applyDiscount = (
|
|
2289
2680
|
* total: number,
|
|
2290
2681
|
* discountRate: number
|
|
2291
|
-
* ): Effect.Effect<number,
|
|
2682
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2292
2683
|
* discountRate === 0
|
|
2293
|
-
* ? Effect.fail(new
|
|
2684
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2294
2685
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2295
2686
|
*
|
|
2296
2687
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2363,15 +2754,17 @@ export declare const andThen: {
|
|
|
2363
2754
|
*
|
|
2364
2755
|
* @example Applying a Discount Based on Fetched Amount
|
|
2365
2756
|
* ```ts
|
|
2366
|
-
* import { Effect, pipe } from "effect"
|
|
2757
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2758
|
+
*
|
|
2759
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
2367
2760
|
*
|
|
2368
2761
|
* // Function to apply a discount safely to a transaction amount
|
|
2369
2762
|
* const applyDiscount = (
|
|
2370
2763
|
* total: number,
|
|
2371
2764
|
* discountRate: number
|
|
2372
|
-
* ): Effect.Effect<number,
|
|
2765
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2373
2766
|
* discountRate === 0
|
|
2374
|
-
* ? Effect.fail(new
|
|
2767
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2375
2768
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2376
2769
|
*
|
|
2377
2770
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2444,15 +2837,17 @@ export declare const andThen: {
|
|
|
2444
2837
|
*
|
|
2445
2838
|
* @example Applying a Discount Based on Fetched Amount
|
|
2446
2839
|
* ```ts
|
|
2447
|
-
* import { Effect, pipe } from "effect"
|
|
2840
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2841
|
+
*
|
|
2842
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
2448
2843
|
*
|
|
2449
2844
|
* // Function to apply a discount safely to a transaction amount
|
|
2450
2845
|
* const applyDiscount = (
|
|
2451
2846
|
* total: number,
|
|
2452
2847
|
* discountRate: number
|
|
2453
|
-
* ): Effect.Effect<number,
|
|
2848
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2454
2849
|
* discountRate === 0
|
|
2455
|
-
* ? Effect.fail(new
|
|
2850
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2456
2851
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2457
2852
|
*
|
|
2458
2853
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2510,16 +2905,18 @@ export declare const andThen: {
|
|
|
2510
2905
|
* @example
|
|
2511
2906
|
* ```ts
|
|
2512
2907
|
* // Title: Logging a step in a pipeline
|
|
2513
|
-
* import { Effect, pipe } from "effect"
|
|
2908
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2514
2909
|
* import { Console } from "effect"
|
|
2515
2910
|
*
|
|
2911
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
2912
|
+
*
|
|
2516
2913
|
* // Function to apply a discount safely to a transaction amount
|
|
2517
2914
|
* const applyDiscount = (
|
|
2518
2915
|
* total: number,
|
|
2519
2916
|
* discountRate: number
|
|
2520
|
-
* ): Effect.Effect<number,
|
|
2917
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2521
2918
|
* discountRate === 0
|
|
2522
|
-
* ? Effect.fail(new
|
|
2919
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2523
2920
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2524
2921
|
*
|
|
2525
2922
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2569,16 +2966,18 @@ export declare const tap: {
|
|
|
2569
2966
|
* @example
|
|
2570
2967
|
* ```ts
|
|
2571
2968
|
* // Title: Logging a step in a pipeline
|
|
2572
|
-
* import { Effect, pipe } from "effect"
|
|
2969
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2573
2970
|
* import { Console } from "effect"
|
|
2574
2971
|
*
|
|
2972
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
2973
|
+
*
|
|
2575
2974
|
* // Function to apply a discount safely to a transaction amount
|
|
2576
2975
|
* const applyDiscount = (
|
|
2577
2976
|
* total: number,
|
|
2578
2977
|
* discountRate: number
|
|
2579
|
-
* ): Effect.Effect<number,
|
|
2978
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2580
2979
|
* discountRate === 0
|
|
2581
|
-
* ? Effect.fail(new
|
|
2980
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2582
2981
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2583
2982
|
*
|
|
2584
2983
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2628,16 +3027,18 @@ export declare const tap: {
|
|
|
2628
3027
|
* @example
|
|
2629
3028
|
* ```ts
|
|
2630
3029
|
* // Title: Logging a step in a pipeline
|
|
2631
|
-
* import { Effect, pipe } from "effect"
|
|
3030
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2632
3031
|
* import { Console } from "effect"
|
|
2633
3032
|
*
|
|
3033
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
3034
|
+
*
|
|
2634
3035
|
* // Function to apply a discount safely to a transaction amount
|
|
2635
3036
|
* const applyDiscount = (
|
|
2636
3037
|
* total: number,
|
|
2637
3038
|
* discountRate: number
|
|
2638
|
-
* ): Effect.Effect<number,
|
|
3039
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2639
3040
|
* discountRate === 0
|
|
2640
|
-
* ? Effect.fail(new
|
|
3041
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2641
3042
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2642
3043
|
*
|
|
2643
3044
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2687,16 +3088,18 @@ export declare const tap: {
|
|
|
2687
3088
|
* @example
|
|
2688
3089
|
* ```ts
|
|
2689
3090
|
* // Title: Logging a step in a pipeline
|
|
2690
|
-
* import { Effect, pipe } from "effect"
|
|
3091
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2691
3092
|
* import { Console } from "effect"
|
|
2692
3093
|
*
|
|
3094
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
3095
|
+
*
|
|
2693
3096
|
* // Function to apply a discount safely to a transaction amount
|
|
2694
3097
|
* const applyDiscount = (
|
|
2695
3098
|
* total: number,
|
|
2696
3099
|
* discountRate: number
|
|
2697
|
-
* ): Effect.Effect<number,
|
|
3100
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2698
3101
|
* discountRate === 0
|
|
2699
|
-
* ? Effect.fail(new
|
|
3102
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2700
3103
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2701
3104
|
*
|
|
2702
3105
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2746,16 +3149,18 @@ export declare const tap: {
|
|
|
2746
3149
|
* @example
|
|
2747
3150
|
* ```ts
|
|
2748
3151
|
* // Title: Logging a step in a pipeline
|
|
2749
|
-
* import { Effect, pipe } from "effect"
|
|
3152
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2750
3153
|
* import { Console } from "effect"
|
|
2751
3154
|
*
|
|
3155
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
3156
|
+
*
|
|
2752
3157
|
* // Function to apply a discount safely to a transaction amount
|
|
2753
3158
|
* const applyDiscount = (
|
|
2754
3159
|
* total: number,
|
|
2755
3160
|
* discountRate: number
|
|
2756
|
-
* ): Effect.Effect<number,
|
|
3161
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2757
3162
|
* discountRate === 0
|
|
2758
|
-
* ? Effect.fail(new
|
|
3163
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2759
3164
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2760
3165
|
*
|
|
2761
3166
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -3538,12 +3943,12 @@ export {
|
|
|
3538
3943
|
*
|
|
3539
3944
|
* **Details**
|
|
3540
3945
|
*
|
|
3541
|
-
* The `
|
|
3946
|
+
* The `catch` function catches any errors that may occur during the
|
|
3542
3947
|
* execution of an effect and allows you to handle them by specifying a fallback
|
|
3543
3948
|
* effect. This ensures that the program continues without failing by recovering
|
|
3544
3949
|
* from errors using the provided fallback logic.
|
|
3545
3950
|
*
|
|
3546
|
-
* **Note**: `
|
|
3951
|
+
* **Note**: `catch` only handles recoverable errors. It will not recover
|
|
3547
3952
|
* from unrecoverable defects.
|
|
3548
3953
|
*
|
|
3549
3954
|
* @see {@link catchCause} for a version that can recover from both recoverable and unrecoverable errors.
|
|
@@ -3691,7 +4096,8 @@ export declare const catchTag: {
|
|
|
3691
4096
|
* once. Instead of using {@link catchTag} multiple times, you can pass an
|
|
3692
4097
|
* object where each key is an error type's `_tag`, and the value is the handler
|
|
3693
4098
|
* for that specific error. This allows you to catch and recover from multiple
|
|
3694
|
-
* error types in a single call.
|
|
4099
|
+
* error types in a single call. You can also provide a fallback handler for
|
|
4100
|
+
* unhandled errors.
|
|
3695
4101
|
*
|
|
3696
4102
|
* The error type must have a readonly `_tag` field to use `catchTag`. This
|
|
3697
4103
|
* field is used to identify and match errors.
|
|
@@ -3733,7 +4139,8 @@ export declare const catchTags: {
|
|
|
3733
4139
|
* once. Instead of using {@link catchTag} multiple times, you can pass an
|
|
3734
4140
|
* object where each key is an error type's `_tag`, and the value is the handler
|
|
3735
4141
|
* for that specific error. This allows you to catch and recover from multiple
|
|
3736
|
-
* error types in a single call.
|
|
4142
|
+
* error types in a single call. You can also provide a fallback handler for
|
|
4143
|
+
* unhandled errors.
|
|
3737
4144
|
*
|
|
3738
4145
|
* The error type must have a readonly `_tag` field to use `catchTag`. This
|
|
3739
4146
|
* field is used to identify and match errors.
|
|
@@ -3775,13 +4182,15 @@ export declare const catchTags: {
|
|
|
3775
4182
|
[K in Exclude<keyof Cases, Extract<E, {
|
|
3776
4183
|
_tag: string;
|
|
3777
4184
|
}>["_tag"]>]: never;
|
|
3778
|
-
})
|
|
3779
|
-
|
|
3780
|
-
}
|
|
4185
|
+
}), A2 = never, E2 = Exclude<E, {
|
|
4186
|
+
_tag: keyof Cases;
|
|
4187
|
+
}>, R2 = never>(cases: Cases, orElse?: ((e: Exclude<E, {
|
|
3781
4188
|
_tag: keyof Cases;
|
|
3782
|
-
}> | {
|
|
4189
|
+
}>) => Effect<A2, E2, R2>) | undefined): <A, R>(self: Effect<A, E, R>) => Effect<A | A2 | {
|
|
4190
|
+
[K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect<infer A, any, any> ? A : never;
|
|
4191
|
+
}[keyof Cases], E2 | {
|
|
3783
4192
|
[K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect<any, infer E, any> ? E : never;
|
|
3784
|
-
}[keyof Cases], R | {
|
|
4193
|
+
}[keyof Cases], R | R2 | {
|
|
3785
4194
|
[K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect<any, any, infer R> ? R : never;
|
|
3786
4195
|
}[keyof Cases]>;
|
|
3787
4196
|
/**
|
|
@@ -3793,7 +4202,8 @@ export declare const catchTags: {
|
|
|
3793
4202
|
* once. Instead of using {@link catchTag} multiple times, you can pass an
|
|
3794
4203
|
* object where each key is an error type's `_tag`, and the value is the handler
|
|
3795
4204
|
* for that specific error. This allows you to catch and recover from multiple
|
|
3796
|
-
* error types in a single call.
|
|
4205
|
+
* error types in a single call. You can also provide a fallback handler for
|
|
4206
|
+
* unhandled errors.
|
|
3797
4207
|
*
|
|
3798
4208
|
* The error type must have a readonly `_tag` field to use `catchTag`. This
|
|
3799
4209
|
* field is used to identify and match errors.
|
|
@@ -3835,13 +4245,15 @@ export declare const catchTags: {
|
|
|
3835
4245
|
[K in Exclude<keyof Cases, Extract<E, {
|
|
3836
4246
|
_tag: string;
|
|
3837
4247
|
}>["_tag"]>]: never;
|
|
3838
|
-
})
|
|
3839
|
-
[K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect<infer A, any, any> ? A : never;
|
|
3840
|
-
}[keyof Cases], Exclude<E, {
|
|
4248
|
+
}), A2 = never, E2 = Exclude<E, {
|
|
3841
4249
|
_tag: keyof Cases;
|
|
3842
|
-
}>
|
|
4250
|
+
}>, R2 = never>(self: Effect<A, E, R>, cases: Cases, orElse?: ((e: Exclude<E, {
|
|
4251
|
+
_tag: keyof Cases;
|
|
4252
|
+
}>) => Effect<A2, E2, R2>) | undefined): Effect<A | A2 | {
|
|
4253
|
+
[K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect<infer A, any, any> ? A : never;
|
|
4254
|
+
}[keyof Cases], E2 | {
|
|
3843
4255
|
[K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect<any, infer E, any> ? E : never;
|
|
3844
|
-
}[keyof Cases], R | {
|
|
4256
|
+
}[keyof Cases], R | R2 | {
|
|
3845
4257
|
[K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect<any, any, infer R> ? R : never;
|
|
3846
4258
|
}[keyof Cases]>;
|
|
3847
4259
|
};
|
|
@@ -3916,7 +4328,7 @@ export declare const catchReason: {
|
|
|
3916
4328
|
* @since 4.0.0
|
|
3917
4329
|
* @category Error Handling
|
|
3918
4330
|
*/
|
|
3919
|
-
<K extends Tags<E>, E, RK extends ReasonTags<ExtractTag<NoInfer<E>, K>>, A2, E2, R2, A3 = unassigned, E3 = never, R3 = never>(errorTag: K, reasonTag: RK, f: (reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK>) => Effect<A2, E2, R2>, orElse?: ((reasons: ExcludeReason<ExtractTag<NoInfer<E>, K>, RK>) => Effect<A3, E3, R3>) | undefined): <A, R>(self: Effect<A, E, R>) => Effect<A | A2 | Exclude<A3, unassigned>, (A3 extends unassigned ? E : ExcludeTag<E, K>) | E2 | E3, R | R2 | R3>;
|
|
4331
|
+
<K extends Tags<E>, E, RK extends ReasonTags<ExtractTag<NoInfer<E>, K>>, A2, E2, R2, A3 = unassigned, E3 = never, R3 = never>(errorTag: K, reasonTag: RK, f: (reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK>, error: NarrowReason<ExtractTag<NoInfer<E>, K>, RK>) => Effect<A2, E2, R2>, orElse?: ((reasons: ExcludeReason<ExtractTag<NoInfer<E>, K>, RK>, error: OmitReason<ExtractTag<NoInfer<E>, K>, RK>) => Effect<A3, E3, R3>) | undefined): <A, R>(self: Effect<A, E, R>) => Effect<A | A2 | Exclude<A3, unassigned>, (A3 extends unassigned ? E : ExcludeTag<E, K>) | E2 | E3, R | R2 | R3>;
|
|
3920
4332
|
/**
|
|
3921
4333
|
* Catches a specific reason within a tagged error.
|
|
3922
4334
|
*
|
|
@@ -3952,7 +4364,7 @@ export declare const catchReason: {
|
|
|
3952
4364
|
* @since 4.0.0
|
|
3953
4365
|
* @category Error Handling
|
|
3954
4366
|
*/
|
|
3955
|
-
<A, E, R, K extends Tags<E>, RK extends ReasonTags<ExtractTag<E, K>>, A2, E2, R2, A3 = unassigned, E3 = never, R3 = never>(self: Effect<A, E, R>, errorTag: K, reasonTag: RK, f: (reason: ExtractReason<ExtractTag<E, K>, RK>) => Effect<A2, E2, R2>, orElse?: ((reasons: ExcludeReason<ExtractTag<E, K>, RK>) => Effect<A3, E3, R3>) | undefined): Effect<A | A2 | Exclude<A3, unassigned>, (A3 extends unassigned ? E : ExcludeTag<E, K>) | E2 | E3, R | R2 | R3>;
|
|
4367
|
+
<A, E, R, K extends Tags<E>, RK extends ReasonTags<ExtractTag<E, K>>, A2, E2, R2, A3 = unassigned, E3 = never, R3 = never>(self: Effect<A, E, R>, errorTag: K, reasonTag: RK, f: (reason: ExtractReason<ExtractTag<E, K>, RK>, error: NarrowReason<ExtractTag<E, K>, RK>) => Effect<A2, E2, R2>, orElse?: ((reasons: ExcludeReason<ExtractTag<E, K>, RK>, error: OmitReason<ExtractTag<E, K>, RK>) => Effect<A3, E3, R3>) | undefined): Effect<A | A2 | Exclude<A3, unassigned>, (A3 extends unassigned ? E : ExcludeTag<E, K>) | E2 | E3, R | R2 | R3>;
|
|
3956
4368
|
};
|
|
3957
4369
|
/**
|
|
3958
4370
|
* Catches multiple reasons within a tagged error using an object of handlers.
|
|
@@ -4024,8 +4436,8 @@ export declare const catchReasons: {
|
|
|
4024
4436
|
* @category Error Handling
|
|
4025
4437
|
*/
|
|
4026
4438
|
<K extends Tags<E>, E, Cases extends {
|
|
4027
|
-
[RK in ReasonTags<ExtractTag<NoInfer<E>, K>>]+?: (reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK>) => Effect<any, any, any>;
|
|
4028
|
-
}, A2 = unassigned, E2 = never, R2 = never>(errorTag: K, cases: Cases, orElse?: ((reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>) => Effect<A2, E2, R2>) | undefined): <A, R>(self: Effect<A, E, R>) => Effect<A | Exclude<A2, unassigned> | {
|
|
4439
|
+
[RK in ReasonTags<ExtractTag<NoInfer<E>, K>>]+?: (reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK>, error: NarrowReason<ExtractTag<NoInfer<E>, K>, RK>) => Effect<any, any, any>;
|
|
4440
|
+
}, A2 = unassigned, E2 = never, R2 = never>(errorTag: K, cases: Cases, orElse?: ((reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>, error: OmitReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>) => Effect<A2, E2, R2>) | undefined): <A, R>(self: Effect<A, E, R>) => Effect<A | Exclude<A2, unassigned> | {
|
|
4029
4441
|
[RK in keyof Cases]: Cases[RK] extends (...args: Array<any>) => Effect<infer A, any, any> ? A : never;
|
|
4030
4442
|
}[keyof Cases], (A2 extends unassigned ? E : ExcludeTag<E, K>) | E2 | {
|
|
4031
4443
|
[RK in keyof Cases]: Cases[RK] extends (...args: Array<any>) => Effect<any, infer E, any> ? E : never;
|
|
@@ -4067,8 +4479,8 @@ export declare const catchReasons: {
|
|
|
4067
4479
|
* @category Error Handling
|
|
4068
4480
|
*/
|
|
4069
4481
|
<A, E, R, K extends Tags<E>, Cases extends {
|
|
4070
|
-
[RK in ReasonTags<ExtractTag<E, K>>]+?: (reason: ExtractReason<ExtractTag<E, K>, RK>) => Effect<any, any, any>;
|
|
4071
|
-
}, A2 = unassigned, E2 = never, R2 = never>(self: Effect<A, E, R>, errorTag: K, cases: Cases, orElse?: ((reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>) => Effect<A2, E2, R2>) | undefined): Effect<A | Exclude<A2, unassigned> | {
|
|
4482
|
+
[RK in ReasonTags<ExtractTag<E, K>>]+?: (reason: ExtractReason<ExtractTag<E, K>, RK>, error: NarrowReason<ExtractTag<E, K>, RK>) => Effect<any, any, any>;
|
|
4483
|
+
}, A2 = unassigned, E2 = never, R2 = never>(self: Effect<A, E, R>, errorTag: K, cases: Cases, orElse?: ((reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>, error: OmitReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>) => Effect<A2, E2, R2>) | undefined): Effect<A | Exclude<A2, unassigned> | {
|
|
4072
4484
|
[RK in keyof Cases]: Cases[RK] extends (...args: Array<any>) => Effect<infer A, any, any> ? A : never;
|
|
4073
4485
|
}[keyof Cases], (A2 extends unassigned ? E : ExcludeTag<E, K>) | E2 | {
|
|
4074
4486
|
[RK in keyof Cases]: Cases[RK] extends (...args: Array<any>) => Effect<any, infer E, any> ? E : never;
|
|
@@ -4469,15 +4881,14 @@ export declare const catchDefect: {
|
|
|
4469
4881
|
<A, E, R, A2, E2, R2>(self: Effect<A, E, R>, f: (defect: unknown) => Effect<A2, E2, R2>): Effect<A | A2, E | E2, R | R2>;
|
|
4470
4882
|
};
|
|
4471
4883
|
/**
|
|
4472
|
-
* Recovers from specific errors using a `
|
|
4473
|
-
* `Refinement`.
|
|
4884
|
+
* Recovers from specific errors using a `Predicate` or `Refinement`.
|
|
4474
4885
|
*
|
|
4475
4886
|
* **When to Use**
|
|
4476
4887
|
*
|
|
4477
|
-
* `catchIf` lets you recover from errors that match a condition.
|
|
4478
|
-
* `
|
|
4479
|
-
*
|
|
4480
|
-
*
|
|
4888
|
+
* `catchIf` lets you recover from errors that match a condition. Use a
|
|
4889
|
+
* `Refinement` for type narrowing or a `Predicate` for simple boolean
|
|
4890
|
+
* matching. Non-matching errors re-fail with the original cause. Defects and
|
|
4891
|
+
* interrupts are not caught.
|
|
4481
4892
|
*
|
|
4482
4893
|
* **Previously Known As**
|
|
4483
4894
|
*
|
|
@@ -4504,7 +4915,7 @@ export declare const catchDefect: {
|
|
|
4504
4915
|
*
|
|
4505
4916
|
* // With a Filter
|
|
4506
4917
|
* const recovered2 = program.pipe(
|
|
4507
|
-
* Effect.
|
|
4918
|
+
* Effect.catchFilter(
|
|
4508
4919
|
* Filter.tagged("NotFound"),
|
|
4509
4920
|
* (error) => Effect.succeed(`missing:${error.id}`)
|
|
4510
4921
|
* )
|
|
@@ -4516,15 +4927,14 @@ export declare const catchDefect: {
|
|
|
4516
4927
|
*/
|
|
4517
4928
|
export declare const catchIf: {
|
|
4518
4929
|
/**
|
|
4519
|
-
* Recovers from specific errors using a `
|
|
4520
|
-
* `Refinement`.
|
|
4930
|
+
* Recovers from specific errors using a `Predicate` or `Refinement`.
|
|
4521
4931
|
*
|
|
4522
4932
|
* **When to Use**
|
|
4523
4933
|
*
|
|
4524
|
-
* `catchIf` lets you recover from errors that match a condition.
|
|
4525
|
-
* `
|
|
4526
|
-
*
|
|
4527
|
-
*
|
|
4934
|
+
* `catchIf` lets you recover from errors that match a condition. Use a
|
|
4935
|
+
* `Refinement` for type narrowing or a `Predicate` for simple boolean
|
|
4936
|
+
* matching. Non-matching errors re-fail with the original cause. Defects and
|
|
4937
|
+
* interrupts are not caught.
|
|
4528
4938
|
*
|
|
4529
4939
|
* **Previously Known As**
|
|
4530
4940
|
*
|
|
@@ -4551,7 +4961,7 @@ export declare const catchIf: {
|
|
|
4551
4961
|
*
|
|
4552
4962
|
* // With a Filter
|
|
4553
4963
|
* const recovered2 = program.pipe(
|
|
4554
|
-
* Effect.
|
|
4964
|
+
* Effect.catchFilter(
|
|
4555
4965
|
* Filter.tagged("NotFound"),
|
|
4556
4966
|
* (error) => Effect.succeed(`missing:${error.id}`)
|
|
4557
4967
|
* )
|
|
@@ -4563,15 +4973,14 @@ export declare const catchIf: {
|
|
|
4563
4973
|
*/
|
|
4564
4974
|
<E, EB extends E, A2, E2, R2, A3 = never, E3 = Exclude<E, EB>, R3 = never>(refinement: Predicate.Refinement<NoInfer<E>, EB>, f: (e: EB) => Effect<A2, E2, R2>, orElse?: ((e: Exclude<E, EB>) => Effect<A3, E3, R3>) | undefined): <A, R>(self: Effect<A, E, R>) => Effect<A | A2 | A3, E2 | E3, R | R2 | R3>;
|
|
4565
4975
|
/**
|
|
4566
|
-
* Recovers from specific errors using a `
|
|
4567
|
-
* `Refinement`.
|
|
4976
|
+
* Recovers from specific errors using a `Predicate` or `Refinement`.
|
|
4568
4977
|
*
|
|
4569
4978
|
* **When to Use**
|
|
4570
4979
|
*
|
|
4571
|
-
* `catchIf` lets you recover from errors that match a condition.
|
|
4572
|
-
* `
|
|
4573
|
-
*
|
|
4574
|
-
*
|
|
4980
|
+
* `catchIf` lets you recover from errors that match a condition. Use a
|
|
4981
|
+
* `Refinement` for type narrowing or a `Predicate` for simple boolean
|
|
4982
|
+
* matching. Non-matching errors re-fail with the original cause. Defects and
|
|
4983
|
+
* interrupts are not caught.
|
|
4575
4984
|
*
|
|
4576
4985
|
* **Previously Known As**
|
|
4577
4986
|
*
|
|
@@ -4598,7 +5007,7 @@ export declare const catchIf: {
|
|
|
4598
5007
|
*
|
|
4599
5008
|
* // With a Filter
|
|
4600
5009
|
* const recovered2 = program.pipe(
|
|
4601
|
-
* Effect.
|
|
5010
|
+
* Effect.catchFilter(
|
|
4602
5011
|
* Filter.tagged("NotFound"),
|
|
4603
5012
|
* (error) => Effect.succeed(`missing:${error.id}`)
|
|
4604
5013
|
* )
|
|
@@ -4608,17 +5017,16 @@ export declare const catchIf: {
|
|
|
4608
5017
|
* @since 2.0.0
|
|
4609
5018
|
* @category Error Handling
|
|
4610
5019
|
*/
|
|
4611
|
-
<E,
|
|
5020
|
+
<E, A2, E2, R2, A3 = never, E3 = E, R3 = never>(predicate: Predicate.Predicate<NoInfer<E>>, f: (e: NoInfer<E>) => Effect<A2, E2, R2>, orElse?: ((e: NoInfer<E>) => Effect<A3, E3, R3>) | undefined): <A, R>(self: Effect<A, E, R>) => Effect<A | A2 | A3, E2 | E3, R | R2 | R3>;
|
|
4612
5021
|
/**
|
|
4613
|
-
* Recovers from specific errors using a `
|
|
4614
|
-
* `Refinement`.
|
|
5022
|
+
* Recovers from specific errors using a `Predicate` or `Refinement`.
|
|
4615
5023
|
*
|
|
4616
5024
|
* **When to Use**
|
|
4617
5025
|
*
|
|
4618
|
-
* `catchIf` lets you recover from errors that match a condition.
|
|
4619
|
-
* `
|
|
4620
|
-
*
|
|
4621
|
-
*
|
|
5026
|
+
* `catchIf` lets you recover from errors that match a condition. Use a
|
|
5027
|
+
* `Refinement` for type narrowing or a `Predicate` for simple boolean
|
|
5028
|
+
* matching. Non-matching errors re-fail with the original cause. Defects and
|
|
5029
|
+
* interrupts are not caught.
|
|
4622
5030
|
*
|
|
4623
5031
|
* **Previously Known As**
|
|
4624
5032
|
*
|
|
@@ -4645,7 +5053,7 @@ export declare const catchIf: {
|
|
|
4645
5053
|
*
|
|
4646
5054
|
* // With a Filter
|
|
4647
5055
|
* const recovered2 = program.pipe(
|
|
4648
|
-
* Effect.
|
|
5056
|
+
* Effect.catchFilter(
|
|
4649
5057
|
* Filter.tagged("NotFound"),
|
|
4650
5058
|
* (error) => Effect.succeed(`missing:${error.id}`)
|
|
4651
5059
|
* )
|
|
@@ -4657,15 +5065,14 @@ export declare const catchIf: {
|
|
|
4657
5065
|
*/
|
|
4658
5066
|
<A, E, R, EB extends E, A2, E2, R2, A3 = never, E3 = Exclude<E, EB>, R3 = never>(self: Effect<A, E, R>, refinement: Predicate.Refinement<E, EB>, f: (e: EB) => Effect<A2, E2, R2>, orElse?: ((e: Exclude<E, EB>) => Effect<A3, E3, R3>) | undefined): Effect<A | A2 | A3, E2 | E3, R | R2 | R3>;
|
|
4659
5067
|
/**
|
|
4660
|
-
* Recovers from specific errors using a `
|
|
4661
|
-
* `Refinement`.
|
|
5068
|
+
* Recovers from specific errors using a `Predicate` or `Refinement`.
|
|
4662
5069
|
*
|
|
4663
5070
|
* **When to Use**
|
|
4664
5071
|
*
|
|
4665
|
-
* `catchIf` lets you recover from errors that match a condition.
|
|
4666
|
-
* `
|
|
4667
|
-
*
|
|
4668
|
-
*
|
|
5072
|
+
* `catchIf` lets you recover from errors that match a condition. Use a
|
|
5073
|
+
* `Refinement` for type narrowing or a `Predicate` for simple boolean
|
|
5074
|
+
* matching. Non-matching errors re-fail with the original cause. Defects and
|
|
5075
|
+
* interrupts are not caught.
|
|
4669
5076
|
*
|
|
4670
5077
|
* **Previously Known As**
|
|
4671
5078
|
*
|
|
@@ -4692,7 +5099,7 @@ export declare const catchIf: {
|
|
|
4692
5099
|
*
|
|
4693
5100
|
* // With a Filter
|
|
4694
5101
|
* const recovered2 = program.pipe(
|
|
4695
|
-
* Effect.
|
|
5102
|
+
* Effect.catchFilter(
|
|
4696
5103
|
* Filter.tagged("NotFound"),
|
|
4697
5104
|
* (error) => Effect.succeed(`missing:${error.id}`)
|
|
4698
5105
|
* )
|
|
@@ -4702,7 +5109,29 @@ export declare const catchIf: {
|
|
|
4702
5109
|
* @since 2.0.0
|
|
4703
5110
|
* @category Error Handling
|
|
4704
5111
|
*/
|
|
4705
|
-
<A, E, R,
|
|
5112
|
+
<A, E, R, A2, E2, R2, A3 = never, E3 = E, R3 = never>(self: Effect<A, E, R>, predicate: Predicate.Predicate<E>, f: (e: E) => Effect<A2, E2, R2>, orElse?: ((e: E) => Effect<A3, E3, R3>) | undefined): Effect<A | A2 | A3, E2 | E3, R | R2 | R3>;
|
|
5113
|
+
};
|
|
5114
|
+
/**
|
|
5115
|
+
* Recovers from specific errors using a `Filter`.
|
|
5116
|
+
*
|
|
5117
|
+
* @since 4.0.0
|
|
5118
|
+
* @category Error Handling
|
|
5119
|
+
*/
|
|
5120
|
+
export declare const catchFilter: {
|
|
5121
|
+
/**
|
|
5122
|
+
* Recovers from specific errors using a `Filter`.
|
|
5123
|
+
*
|
|
5124
|
+
* @since 4.0.0
|
|
5125
|
+
* @category Error Handling
|
|
5126
|
+
*/
|
|
5127
|
+
<E, EB, A2, E2, R2, X, A3 = never, E3 = X, R3 = never>(filter: Filter.Filter<NoInfer<E>, EB, X>, f: (e: EB) => Effect<A2, E2, R2>, orElse?: ((e: X) => Effect<A3, E3, R3>) | undefined): <A, R>(self: Effect<A, E, R>) => Effect<A | A2 | A3, E2 | E3, R | R2 | R3>;
|
|
5128
|
+
/**
|
|
5129
|
+
* Recovers from specific errors using a `Filter`.
|
|
5130
|
+
*
|
|
5131
|
+
* @since 4.0.0
|
|
5132
|
+
* @category Error Handling
|
|
5133
|
+
*/
|
|
5134
|
+
<A, E, R, EB, A2, E2, R2, X, A3 = never, E3 = X, R3 = never>(self: Effect<A, E, R>, filter: Filter.Filter<NoInfer<E>, EB, X>, f: (e: EB) => Effect<A2, E2, R2>, orElse?: ((e: X) => Effect<A3, E3, R3>) | undefined): Effect<A | A2 | A3, E2 | E3, R | R2 | R3>;
|
|
4706
5135
|
};
|
|
4707
5136
|
/**
|
|
4708
5137
|
* Catches `NoSuchElementError` failures and converts them to `Option.none`.
|
|
@@ -4808,7 +5237,7 @@ export declare const catchCauseIf: {
|
|
|
4808
5237
|
* @since 4.0.0
|
|
4809
5238
|
* @category Error Handling
|
|
4810
5239
|
*/
|
|
4811
|
-
<E,
|
|
5240
|
+
<E, B, E2, R2>(predicate: Predicate.Predicate<Cause.Cause<E>>, f: (cause: Cause.Cause<E>) => Effect<B, E2, R2>): <A, R>(self: Effect<A, E, R>) => Effect<A | B, E | E2, R | R2>;
|
|
4812
5241
|
/**
|
|
4813
5242
|
* Recovers from specific failures based on a predicate.
|
|
4814
5243
|
*
|
|
@@ -4847,7 +5276,29 @@ export declare const catchCauseIf: {
|
|
|
4847
5276
|
* @since 4.0.0
|
|
4848
5277
|
* @category Error Handling
|
|
4849
5278
|
*/
|
|
4850
|
-
<A, E, R, B, E2, R2
|
|
5279
|
+
<A, E, R, B, E2, R2>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Cause.Cause<E>>, f: (cause: Cause.Cause<E>) => Effect<B, E2, R2>): Effect<A | B, E | E2, R | R2>;
|
|
5280
|
+
};
|
|
5281
|
+
/**
|
|
5282
|
+
* Recovers from specific failures based on a `Filter`.
|
|
5283
|
+
*
|
|
5284
|
+
* @since 4.0.0
|
|
5285
|
+
* @category Error Handling
|
|
5286
|
+
*/
|
|
5287
|
+
export declare const catchCauseFilter: {
|
|
5288
|
+
/**
|
|
5289
|
+
* Recovers from specific failures based on a `Filter`.
|
|
5290
|
+
*
|
|
5291
|
+
* @since 4.0.0
|
|
5292
|
+
* @category Error Handling
|
|
5293
|
+
*/
|
|
5294
|
+
<E, B, E2, R2, EB, X extends Cause.Cause<any>>(filter: Filter.Filter<Cause.Cause<E>, EB, X>, f: (failure: EB, cause: Cause.Cause<E>) => Effect<B, E2, R2>): <A, R>(self: Effect<A, E, R>) => Effect<A | B, Cause.Cause.Error<X> | E2, R | R2>;
|
|
5295
|
+
/**
|
|
5296
|
+
* Recovers from specific failures based on a `Filter`.
|
|
5297
|
+
*
|
|
5298
|
+
* @since 4.0.0
|
|
5299
|
+
* @category Error Handling
|
|
5300
|
+
*/
|
|
5301
|
+
<A, E, R, B, E2, R2, EB, X extends Cause.Cause<any>>(self: Effect<A, E, R>, filter: Filter.Filter<Cause.Cause<E>, EB, X>, f: (failure: EB, cause: Cause.Cause<E>) => Effect<B, E2, R2>): Effect<A | B, Cause.Cause.Error<X> | E2, R | R2>;
|
|
4851
5302
|
};
|
|
4852
5303
|
/**
|
|
4853
5304
|
* The `mapError` function is used to transform or modify the error
|
|
@@ -4864,17 +5315,19 @@ export declare const catchCauseIf: {
|
|
|
4864
5315
|
*
|
|
4865
5316
|
* @example
|
|
4866
5317
|
* ```ts
|
|
4867
|
-
* import { Effect } from "effect"
|
|
5318
|
+
* import { Data, Effect } from "effect"
|
|
5319
|
+
*
|
|
5320
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
4868
5321
|
*
|
|
4869
5322
|
* // ┌─── Effect<number, string, never>
|
|
4870
5323
|
* // ▼
|
|
4871
5324
|
* const simulatedTask = Effect.fail("Oh no!").pipe(Effect.as(1))
|
|
4872
5325
|
*
|
|
4873
|
-
* // ┌─── Effect<number,
|
|
5326
|
+
* // ┌─── Effect<number, TaskError, never>
|
|
4874
5327
|
* // ▼
|
|
4875
5328
|
* const mapped = Effect.mapError(
|
|
4876
5329
|
* simulatedTask,
|
|
4877
|
-
* (message) => new
|
|
5330
|
+
* (message) => new TaskError({ message })
|
|
4878
5331
|
* )
|
|
4879
5332
|
* ```
|
|
4880
5333
|
*
|
|
@@ -4897,17 +5350,19 @@ export declare const mapError: {
|
|
|
4897
5350
|
*
|
|
4898
5351
|
* @example
|
|
4899
5352
|
* ```ts
|
|
4900
|
-
* import { Effect } from "effect"
|
|
5353
|
+
* import { Data, Effect } from "effect"
|
|
5354
|
+
*
|
|
5355
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
4901
5356
|
*
|
|
4902
5357
|
* // ┌─── Effect<number, string, never>
|
|
4903
5358
|
* // ▼
|
|
4904
5359
|
* const simulatedTask = Effect.fail("Oh no!").pipe(Effect.as(1))
|
|
4905
5360
|
*
|
|
4906
|
-
* // ┌─── Effect<number,
|
|
5361
|
+
* // ┌─── Effect<number, TaskError, never>
|
|
4907
5362
|
* // ▼
|
|
4908
5363
|
* const mapped = Effect.mapError(
|
|
4909
5364
|
* simulatedTask,
|
|
4910
|
-
* (message) => new
|
|
5365
|
+
* (message) => new TaskError({ message })
|
|
4911
5366
|
* )
|
|
4912
5367
|
* ```
|
|
4913
5368
|
*
|
|
@@ -4930,17 +5385,19 @@ export declare const mapError: {
|
|
|
4930
5385
|
*
|
|
4931
5386
|
* @example
|
|
4932
5387
|
* ```ts
|
|
4933
|
-
* import { Effect } from "effect"
|
|
5388
|
+
* import { Data, Effect } from "effect"
|
|
5389
|
+
*
|
|
5390
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
4934
5391
|
*
|
|
4935
5392
|
* // ┌─── Effect<number, string, never>
|
|
4936
5393
|
* // ▼
|
|
4937
5394
|
* const simulatedTask = Effect.fail("Oh no!").pipe(Effect.as(1))
|
|
4938
5395
|
*
|
|
4939
|
-
* // ┌─── Effect<number,
|
|
5396
|
+
* // ┌─── Effect<number, TaskError, never>
|
|
4940
5397
|
* // ▼
|
|
4941
5398
|
* const mapped = Effect.mapError(
|
|
4942
5399
|
* simulatedTask,
|
|
4943
|
-
* (message) => new
|
|
5400
|
+
* (message) => new TaskError({ message })
|
|
4944
5401
|
* )
|
|
4945
5402
|
* ```
|
|
4946
5403
|
*
|
|
@@ -4961,16 +5418,18 @@ export declare const mapError: {
|
|
|
4961
5418
|
*
|
|
4962
5419
|
* @example
|
|
4963
5420
|
* ```ts
|
|
4964
|
-
* import { Effect } from "effect"
|
|
5421
|
+
* import { Data, Effect } from "effect"
|
|
5422
|
+
*
|
|
5423
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
4965
5424
|
*
|
|
4966
5425
|
* // ┌─── Effect<number, string, never>
|
|
4967
5426
|
* // ▼
|
|
4968
5427
|
* const simulatedTask = Effect.fail("Oh no!").pipe(Effect.as(1))
|
|
4969
5428
|
*
|
|
4970
|
-
* // ┌─── Effect<boolean,
|
|
5429
|
+
* // ┌─── Effect<boolean, TaskError, never>
|
|
4971
5430
|
* // ▼
|
|
4972
5431
|
* const modified = Effect.mapBoth(simulatedTask, {
|
|
4973
|
-
* onFailure: (message) => new
|
|
5432
|
+
* onFailure: (message) => new TaskError({ message }),
|
|
4974
5433
|
* onSuccess: (n) => n > 0
|
|
4975
5434
|
* })
|
|
4976
5435
|
* ```
|
|
@@ -4994,16 +5453,18 @@ export declare const mapBoth: {
|
|
|
4994
5453
|
*
|
|
4995
5454
|
* @example
|
|
4996
5455
|
* ```ts
|
|
4997
|
-
* import { Effect } from "effect"
|
|
5456
|
+
* import { Data, Effect } from "effect"
|
|
5457
|
+
*
|
|
5458
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
4998
5459
|
*
|
|
4999
5460
|
* // ┌─── Effect<number, string, never>
|
|
5000
5461
|
* // ▼
|
|
5001
5462
|
* const simulatedTask = Effect.fail("Oh no!").pipe(Effect.as(1))
|
|
5002
5463
|
*
|
|
5003
|
-
* // ┌─── Effect<boolean,
|
|
5464
|
+
* // ┌─── Effect<boolean, TaskError, never>
|
|
5004
5465
|
* // ▼
|
|
5005
5466
|
* const modified = Effect.mapBoth(simulatedTask, {
|
|
5006
|
-
* onFailure: (message) => new
|
|
5467
|
+
* onFailure: (message) => new TaskError({ message }),
|
|
5007
5468
|
* onSuccess: (n) => n > 0
|
|
5008
5469
|
* })
|
|
5009
5470
|
* ```
|
|
@@ -5030,16 +5491,18 @@ export declare const mapBoth: {
|
|
|
5030
5491
|
*
|
|
5031
5492
|
* @example
|
|
5032
5493
|
* ```ts
|
|
5033
|
-
* import { Effect } from "effect"
|
|
5494
|
+
* import { Data, Effect } from "effect"
|
|
5495
|
+
*
|
|
5496
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
5034
5497
|
*
|
|
5035
5498
|
* // ┌─── Effect<number, string, never>
|
|
5036
5499
|
* // ▼
|
|
5037
5500
|
* const simulatedTask = Effect.fail("Oh no!").pipe(Effect.as(1))
|
|
5038
5501
|
*
|
|
5039
|
-
* // ┌─── Effect<boolean,
|
|
5502
|
+
* // ┌─── Effect<boolean, TaskError, never>
|
|
5040
5503
|
* // ▼
|
|
5041
5504
|
* const modified = Effect.mapBoth(simulatedTask, {
|
|
5042
|
-
* onFailure: (message) => new
|
|
5505
|
+
* onFailure: (message) => new TaskError({ message }),
|
|
5043
5506
|
* onSuccess: (n) => n > 0
|
|
5044
5507
|
* })
|
|
5045
5508
|
* ```
|
|
@@ -5073,11 +5536,13 @@ export declare const mapBoth: {
|
|
|
5073
5536
|
* @example
|
|
5074
5537
|
* ```ts
|
|
5075
5538
|
* // Title: Propagating an Error as a Defect
|
|
5076
|
-
* import { Effect } from "effect"
|
|
5539
|
+
* import { Data, Effect } from "effect"
|
|
5540
|
+
*
|
|
5541
|
+
* class DivideByZeroError extends Data.TaggedError("DivideByZeroError")<{}> {}
|
|
5077
5542
|
*
|
|
5078
5543
|
* const divide = (a: number, b: number) =>
|
|
5079
5544
|
* b === 0
|
|
5080
|
-
* ? Effect.fail(new
|
|
5545
|
+
* ? Effect.fail(new DivideByZeroError())
|
|
5081
5546
|
* : Effect.succeed(a / b)
|
|
5082
5547
|
*
|
|
5083
5548
|
* // ┌─── Effect<number, never, never>
|
|
@@ -5086,7 +5551,7 @@ export declare const mapBoth: {
|
|
|
5086
5551
|
*
|
|
5087
5552
|
* Effect.runPromise(program).catch(console.error)
|
|
5088
5553
|
* // Output:
|
|
5089
|
-
* // (FiberFailure)
|
|
5554
|
+
* // (FiberFailure) DivideByZeroError
|
|
5090
5555
|
* // ...stack trace...
|
|
5091
5556
|
* ```
|
|
5092
5557
|
*
|
|
@@ -5454,7 +5919,7 @@ export declare const tapCauseIf: {
|
|
|
5454
5919
|
* @since 4.0.0
|
|
5455
5920
|
* @category Sequencing
|
|
5456
5921
|
*/
|
|
5457
|
-
<E,
|
|
5922
|
+
<E, B, E2, R2>(predicate: Predicate.Predicate<Cause.Cause<E>>, f: (cause: Cause.Cause<E>) => Effect<B, E2, R2>): <A, R>(self: Effect<A, E, R>) => Effect<A, E | E2, R | R2>;
|
|
5458
5923
|
/**
|
|
5459
5924
|
* Conditionally executes a side effect based on the cause of a failed effect.
|
|
5460
5925
|
*
|
|
@@ -5483,7 +5948,29 @@ export declare const tapCauseIf: {
|
|
|
5483
5948
|
* @since 4.0.0
|
|
5484
5949
|
* @category Sequencing
|
|
5485
5950
|
*/
|
|
5486
|
-
<A, E, R,
|
|
5951
|
+
<A, E, R, B, E2, R2>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Cause.Cause<E>>, f: (cause: Cause.Cause<E>) => Effect<B, E2, R2>): Effect<A, E | E2, R | R2>;
|
|
5952
|
+
};
|
|
5953
|
+
/**
|
|
5954
|
+
* Conditionally executes a side effect based on the cause of a failed effect.
|
|
5955
|
+
*
|
|
5956
|
+
* @since 4.0.0
|
|
5957
|
+
* @category Sequencing
|
|
5958
|
+
*/
|
|
5959
|
+
export declare const tapCauseFilter: {
|
|
5960
|
+
/**
|
|
5961
|
+
* Conditionally executes a side effect based on the cause of a failed effect.
|
|
5962
|
+
*
|
|
5963
|
+
* @since 4.0.0
|
|
5964
|
+
* @category Sequencing
|
|
5965
|
+
*/
|
|
5966
|
+
<E, B, E2, R2, EB, X extends Cause.Cause<any>>(filter: Filter.Filter<Cause.Cause<E>, EB, X>, f: (a: EB, cause: Cause.Cause<E>) => Effect<B, E2, R2>): <A, R>(self: Effect<A, E, R>) => Effect<A, E | E2, R | R2>;
|
|
5967
|
+
/**
|
|
5968
|
+
* Conditionally executes a side effect based on the cause of a failed effect.
|
|
5969
|
+
*
|
|
5970
|
+
* @since 4.0.0
|
|
5971
|
+
* @category Sequencing
|
|
5972
|
+
*/
|
|
5973
|
+
<A, E, R, B, E2, R2, EB, X extends Cause.Cause<any>>(self: Effect<A, E, R>, filter: Filter.Filter<Cause.Cause<E>, EB, X>, f: (a: EB, cause: Cause.Cause<E>) => Effect<B, E2, R2>): Effect<A, E | E2, R | R2>;
|
|
5487
5974
|
};
|
|
5488
5975
|
/**
|
|
5489
5976
|
* Inspect severe errors or defects (non-recoverable failures) in an effect.
|
|
@@ -5660,7 +6147,7 @@ export declare const tapDefect: {
|
|
|
5660
6147
|
* attempts++
|
|
5661
6148
|
* yield* Console.log(`Attempt ${attempts}`)
|
|
5662
6149
|
* if (attempts < 3) {
|
|
5663
|
-
* yield* Effect.fail("Not ready")
|
|
6150
|
+
* return yield* Effect.fail("Not ready")
|
|
5664
6151
|
* }
|
|
5665
6152
|
* return "Ready"
|
|
5666
6153
|
* })
|
|
@@ -5708,9 +6195,13 @@ export declare namespace Retry {
|
|
|
5708
6195
|
*/
|
|
5709
6196
|
type Return<R, E, A, O extends Options<E>> = Effect<A, (O extends {
|
|
5710
6197
|
schedule: Schedule<infer _O, infer _I, infer _E1, infer _R>;
|
|
5711
|
-
} ? E
|
|
6198
|
+
} ? E : O extends {
|
|
6199
|
+
times: number;
|
|
6200
|
+
} ? E : O extends {
|
|
5712
6201
|
until: Predicate.Refinement<E, infer E2>;
|
|
5713
|
-
} ? E2 :
|
|
6202
|
+
} ? E2 : O extends {
|
|
6203
|
+
while: Predicate.Refinement<E, infer E2>;
|
|
6204
|
+
} ? Exclude<E, E2> : E) | (O extends {
|
|
5714
6205
|
schedule: Schedule<infer _O, infer _I, infer E, infer _R>;
|
|
5715
6206
|
} ? E : never) | (O extends {
|
|
5716
6207
|
while: (...args: Array<any>) => Effect<infer _A, infer E, infer _R>;
|
|
@@ -5769,13 +6260,15 @@ export declare namespace Retry {
|
|
|
5769
6260
|
*
|
|
5770
6261
|
* @example
|
|
5771
6262
|
* ```ts
|
|
5772
|
-
* import { Effect, Schedule } from "effect"
|
|
6263
|
+
* import { Data, Effect, Schedule } from "effect"
|
|
6264
|
+
*
|
|
6265
|
+
* class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
|
|
5773
6266
|
*
|
|
5774
6267
|
* let attempt = 0
|
|
5775
|
-
* const task = Effect.callback<string,
|
|
6268
|
+
* const task = Effect.callback<string, AttemptError>((resume) => {
|
|
5776
6269
|
* attempt++
|
|
5777
6270
|
* if (attempt <= 2) {
|
|
5778
|
-
* resume(Effect.fail(new
|
|
6271
|
+
* resume(Effect.fail(new AttemptError({ attempt })))
|
|
5779
6272
|
* } else {
|
|
5780
6273
|
* resume(Effect.succeed("Success!"))
|
|
5781
6274
|
* }
|
|
@@ -5818,13 +6311,15 @@ export declare const retry: {
|
|
|
5818
6311
|
*
|
|
5819
6312
|
* @example
|
|
5820
6313
|
* ```ts
|
|
5821
|
-
* import { Effect, Schedule } from "effect"
|
|
6314
|
+
* import { Data, Effect, Schedule } from "effect"
|
|
6315
|
+
*
|
|
6316
|
+
* class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
|
|
5822
6317
|
*
|
|
5823
6318
|
* let attempt = 0
|
|
5824
|
-
* const task = Effect.callback<string,
|
|
6319
|
+
* const task = Effect.callback<string, AttemptError>((resume) => {
|
|
5825
6320
|
* attempt++
|
|
5826
6321
|
* if (attempt <= 2) {
|
|
5827
|
-
* resume(Effect.fail(new
|
|
6322
|
+
* resume(Effect.fail(new AttemptError({ attempt })))
|
|
5828
6323
|
* } else {
|
|
5829
6324
|
* resume(Effect.succeed("Success!"))
|
|
5830
6325
|
* }
|
|
@@ -5867,13 +6362,15 @@ export declare const retry: {
|
|
|
5867
6362
|
*
|
|
5868
6363
|
* @example
|
|
5869
6364
|
* ```ts
|
|
5870
|
-
* import { Effect, Schedule } from "effect"
|
|
6365
|
+
* import { Data, Effect, Schedule } from "effect"
|
|
6366
|
+
*
|
|
6367
|
+
* class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
|
|
5871
6368
|
*
|
|
5872
6369
|
* let attempt = 0
|
|
5873
|
-
* const task = Effect.callback<string,
|
|
6370
|
+
* const task = Effect.callback<string, AttemptError>((resume) => {
|
|
5874
6371
|
* attempt++
|
|
5875
6372
|
* if (attempt <= 2) {
|
|
5876
|
-
* resume(Effect.fail(new
|
|
6373
|
+
* resume(Effect.fail(new AttemptError({ attempt })))
|
|
5877
6374
|
* } else {
|
|
5878
6375
|
* resume(Effect.succeed("Success!"))
|
|
5879
6376
|
* }
|
|
@@ -5916,13 +6413,15 @@ export declare const retry: {
|
|
|
5916
6413
|
*
|
|
5917
6414
|
* @example
|
|
5918
6415
|
* ```ts
|
|
5919
|
-
* import { Effect, Schedule } from "effect"
|
|
6416
|
+
* import { Data, Effect, Schedule } from "effect"
|
|
6417
|
+
*
|
|
6418
|
+
* class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
|
|
5920
6419
|
*
|
|
5921
6420
|
* let attempt = 0
|
|
5922
|
-
* const task = Effect.callback<string,
|
|
6421
|
+
* const task = Effect.callback<string, AttemptError>((resume) => {
|
|
5923
6422
|
* attempt++
|
|
5924
6423
|
* if (attempt <= 2) {
|
|
5925
|
-
* resume(Effect.fail(new
|
|
6424
|
+
* resume(Effect.fail(new AttemptError({ attempt })))
|
|
5926
6425
|
* } else {
|
|
5927
6426
|
* resume(Effect.succeed("Success!"))
|
|
5928
6427
|
* }
|
|
@@ -5965,13 +6464,15 @@ export declare const retry: {
|
|
|
5965
6464
|
*
|
|
5966
6465
|
* @example
|
|
5967
6466
|
* ```ts
|
|
5968
|
-
* import { Effect, Schedule } from "effect"
|
|
6467
|
+
* import { Data, Effect, Schedule } from "effect"
|
|
6468
|
+
*
|
|
6469
|
+
* class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
|
|
5969
6470
|
*
|
|
5970
6471
|
* let attempt = 0
|
|
5971
|
-
* const task = Effect.callback<string,
|
|
6472
|
+
* const task = Effect.callback<string, AttemptError>((resume) => {
|
|
5972
6473
|
* attempt++
|
|
5973
6474
|
* if (attempt <= 2) {
|
|
5974
|
-
* resume(Effect.fail(new
|
|
6475
|
+
* resume(Effect.fail(new AttemptError({ attempt })))
|
|
5975
6476
|
* } else {
|
|
5976
6477
|
* resume(Effect.succeed("Success!"))
|
|
5977
6478
|
* }
|
|
@@ -6014,13 +6515,15 @@ export declare const retry: {
|
|
|
6014
6515
|
*
|
|
6015
6516
|
* @example
|
|
6016
6517
|
* ```ts
|
|
6017
|
-
* import { Effect, Schedule } from "effect"
|
|
6518
|
+
* import { Data, Effect, Schedule } from "effect"
|
|
6519
|
+
*
|
|
6520
|
+
* class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
|
|
6018
6521
|
*
|
|
6019
6522
|
* let attempt = 0
|
|
6020
|
-
* const task = Effect.callback<string,
|
|
6523
|
+
* const task = Effect.callback<string, AttemptError>((resume) => {
|
|
6021
6524
|
* attempt++
|
|
6022
6525
|
* if (attempt <= 2) {
|
|
6023
|
-
* resume(Effect.fail(new
|
|
6526
|
+
* resume(Effect.fail(new AttemptError({ attempt })))
|
|
6024
6527
|
* } else {
|
|
6025
6528
|
* resume(Effect.succeed("Success!"))
|
|
6026
6529
|
* }
|
|
@@ -6063,13 +6566,15 @@ export declare const retry: {
|
|
|
6063
6566
|
*
|
|
6064
6567
|
* @example
|
|
6065
6568
|
* ```ts
|
|
6066
|
-
* import { Effect, Schedule } from "effect"
|
|
6569
|
+
* import { Data, Effect, Schedule } from "effect"
|
|
6570
|
+
*
|
|
6571
|
+
* class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
|
|
6067
6572
|
*
|
|
6068
6573
|
* let attempt = 0
|
|
6069
|
-
* const task = Effect.callback<string,
|
|
6574
|
+
* const task = Effect.callback<string, AttemptError>((resume) => {
|
|
6070
6575
|
* attempt++
|
|
6071
6576
|
* if (attempt <= 2) {
|
|
6072
|
-
* resume(Effect.fail(new
|
|
6577
|
+
* resume(Effect.fail(new AttemptError({ attempt })))
|
|
6073
6578
|
* } else {
|
|
6074
6579
|
* resume(Effect.succeed("Success!"))
|
|
6075
6580
|
* }
|
|
@@ -6110,14 +6615,16 @@ export declare const retry: {
|
|
|
6110
6615
|
*
|
|
6111
6616
|
* @example
|
|
6112
6617
|
* ```ts
|
|
6113
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
6618
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
6619
|
+
*
|
|
6620
|
+
* class NetworkTimeoutError extends Data.TaggedError("NetworkTimeoutError")<{}> {}
|
|
6114
6621
|
*
|
|
6115
6622
|
* let attempt = 0
|
|
6116
6623
|
* const networkRequest = Effect.gen(function*() {
|
|
6117
6624
|
* attempt++
|
|
6118
6625
|
* yield* Console.log(`Network attempt ${attempt}`)
|
|
6119
6626
|
* if (attempt < 3) {
|
|
6120
|
-
* return yield* Effect.fail(new
|
|
6627
|
+
* return yield* Effect.fail(new NetworkTimeoutError())
|
|
6121
6628
|
* }
|
|
6122
6629
|
* return "Network data"
|
|
6123
6630
|
* })
|
|
@@ -6165,14 +6672,16 @@ export declare const retryOrElse: {
|
|
|
6165
6672
|
*
|
|
6166
6673
|
* @example
|
|
6167
6674
|
* ```ts
|
|
6168
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
6675
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
6676
|
+
*
|
|
6677
|
+
* class NetworkTimeoutError extends Data.TaggedError("NetworkTimeoutError")<{}> {}
|
|
6169
6678
|
*
|
|
6170
6679
|
* let attempt = 0
|
|
6171
6680
|
* const networkRequest = Effect.gen(function*() {
|
|
6172
6681
|
* attempt++
|
|
6173
6682
|
* yield* Console.log(`Network attempt ${attempt}`)
|
|
6174
6683
|
* if (attempt < 3) {
|
|
6175
|
-
* return yield* Effect.fail(new
|
|
6684
|
+
* return yield* Effect.fail(new NetworkTimeoutError())
|
|
6176
6685
|
* }
|
|
6177
6686
|
* return "Network data"
|
|
6178
6687
|
* })
|
|
@@ -6220,14 +6729,16 @@ export declare const retryOrElse: {
|
|
|
6220
6729
|
*
|
|
6221
6730
|
* @example
|
|
6222
6731
|
* ```ts
|
|
6223
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
6732
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
6733
|
+
*
|
|
6734
|
+
* class NetworkTimeoutError extends Data.TaggedError("NetworkTimeoutError")<{}> {}
|
|
6224
6735
|
*
|
|
6225
6736
|
* let attempt = 0
|
|
6226
6737
|
* const networkRequest = Effect.gen(function*() {
|
|
6227
6738
|
* attempt++
|
|
6228
6739
|
* yield* Console.log(`Network attempt ${attempt}`)
|
|
6229
6740
|
* if (attempt < 3) {
|
|
6230
|
-
* return yield* Effect.fail(new
|
|
6741
|
+
* return yield* Effect.fail(new NetworkTimeoutError())
|
|
6231
6742
|
* }
|
|
6232
6743
|
* return "Network data"
|
|
6233
6744
|
* })
|
|
@@ -6300,7 +6811,8 @@ export declare const sandbox: <A, E, R>(self: Effect<A, E, R>) => Effect<A, Caus
|
|
|
6300
6811
|
* it succeeds or fails. This is useful when you only care about the side
|
|
6301
6812
|
* effects of the effect and do not need to handle or process its outcome.
|
|
6302
6813
|
*
|
|
6303
|
-
* Use the `log` option to emit the full {@link Cause} when the effect fails
|
|
6814
|
+
* Use the `log` option to emit the full {@link Cause} when the effect fails,
|
|
6815
|
+
* and `message` to prepend a custom log message.
|
|
6304
6816
|
*
|
|
6305
6817
|
* @example
|
|
6306
6818
|
* ```ts
|
|
@@ -6324,7 +6836,7 @@ export declare const sandbox: <A, E, R>(self: Effect<A, E, R>) => Effect<A, Caus
|
|
|
6324
6836
|
* const task = Effect.fail("Uh oh!")
|
|
6325
6837
|
*
|
|
6326
6838
|
* const program = task.pipe(Effect.ignore({ log: true }))
|
|
6327
|
-
* const programWarn = task.pipe(Effect.ignore({ log: "Warn" }))
|
|
6839
|
+
* const programWarn = task.pipe(Effect.ignore({ log: "Warn", message: "Ignoring task failure" }))
|
|
6328
6840
|
* ```
|
|
6329
6841
|
*
|
|
6330
6842
|
* **Previously Known As**
|
|
@@ -6337,16 +6849,20 @@ export declare const sandbox: <A, E, R>(self: Effect<A, E, R>) => Effect<A, Caus
|
|
|
6337
6849
|
* @category Error Handling
|
|
6338
6850
|
*/
|
|
6339
6851
|
export declare const ignore: <Arg extends Effect<any, any, any> | {
|
|
6340
|
-
readonly log?: boolean |
|
|
6852
|
+
readonly log?: boolean | Severity | undefined;
|
|
6853
|
+
readonly message?: string | undefined;
|
|
6341
6854
|
} | undefined = {
|
|
6342
|
-
readonly log?: boolean |
|
|
6855
|
+
readonly log?: boolean | Severity | undefined;
|
|
6856
|
+
readonly message?: string | undefined;
|
|
6343
6857
|
}>(effectOrOptions?: Arg, options?: {
|
|
6344
|
-
readonly log?: boolean |
|
|
6858
|
+
readonly log?: boolean | Severity | undefined;
|
|
6859
|
+
readonly message?: string | undefined;
|
|
6345
6860
|
} | undefined) => [Arg] extends [Effect<infer _A, infer _E, infer _R>] ? Effect<void, never, _R> : <A, E, R>(self: Effect<A, E, R>) => Effect<void, never, R>;
|
|
6346
6861
|
/**
|
|
6347
6862
|
* Ignores the effect's failure cause, including defects and interruptions.
|
|
6348
6863
|
*
|
|
6349
|
-
* Use the `log` option to emit the full {@link Cause} when the effect fails
|
|
6864
|
+
* Use the `log` option to emit the full {@link Cause} when the effect fails,
|
|
6865
|
+
* and `message` to prepend a custom log message.
|
|
6350
6866
|
*
|
|
6351
6867
|
* @example
|
|
6352
6868
|
* ```ts
|
|
@@ -6355,18 +6871,21 @@ export declare const ignore: <Arg extends Effect<any, any, any> | {
|
|
|
6355
6871
|
* const task = Effect.fail("boom")
|
|
6356
6872
|
*
|
|
6357
6873
|
* const program = task.pipe(Effect.ignoreCause)
|
|
6358
|
-
* const programLog = task.pipe(Effect.ignoreCause({ log: true }))
|
|
6874
|
+
* const programLog = task.pipe(Effect.ignoreCause({ log: true, message: "Ignoring failure cause" }))
|
|
6359
6875
|
* ```
|
|
6360
6876
|
*
|
|
6361
6877
|
* @since 4.0.0
|
|
6362
6878
|
* @category Error Handling
|
|
6363
6879
|
*/
|
|
6364
6880
|
export declare const ignoreCause: <Arg extends Effect<any, any, any> | {
|
|
6365
|
-
readonly log?: boolean |
|
|
6881
|
+
readonly log?: boolean | Severity | undefined;
|
|
6882
|
+
readonly message?: string | undefined;
|
|
6366
6883
|
} | undefined = {
|
|
6367
|
-
readonly log?: boolean |
|
|
6884
|
+
readonly log?: boolean | Severity | undefined;
|
|
6885
|
+
readonly message?: string | undefined;
|
|
6368
6886
|
}>(effectOrOptions?: Arg, options?: {
|
|
6369
|
-
readonly log?: boolean |
|
|
6887
|
+
readonly log?: boolean | Severity | undefined;
|
|
6888
|
+
readonly message?: string | undefined;
|
|
6370
6889
|
} | undefined) => [Arg] extends [Effect<infer _A, infer _E, infer _R>] ? Effect<void, never, _R> : <A, E, R>(self: Effect<A, E, R>) => Effect<void, never, R>;
|
|
6371
6890
|
/**
|
|
6372
6891
|
* Apply an `ExecutionPlan` to an effect, retrying with step-provided resources
|
|
@@ -6378,13 +6897,16 @@ export declare const ignoreCause: <Arg extends Effect<any, any, any> | {
|
|
|
6378
6897
|
*
|
|
6379
6898
|
* @example
|
|
6380
6899
|
* ```ts
|
|
6381
|
-
* import { Effect, ExecutionPlan, Layer,
|
|
6900
|
+
* import { Effect, ExecutionPlan, Layer, Context } from "effect"
|
|
6382
6901
|
*
|
|
6383
|
-
* const Endpoint =
|
|
6902
|
+
* const Endpoint = Context.Service<{ url: string }>("Endpoint")
|
|
6384
6903
|
*
|
|
6385
6904
|
* const fetchUrl = Effect.gen(function*() {
|
|
6386
6905
|
* const endpoint = yield* Effect.service(Endpoint)
|
|
6387
|
-
*
|
|
6906
|
+
* if (endpoint.url === "bad") {
|
|
6907
|
+
* return yield* Effect.fail("Unavailable")
|
|
6908
|
+
* }
|
|
6909
|
+
* return endpoint.url
|
|
6388
6910
|
* })
|
|
6389
6911
|
*
|
|
6390
6912
|
* const plan = ExecutionPlan.make(
|
|
@@ -6409,13 +6931,16 @@ export declare const withExecutionPlan: {
|
|
|
6409
6931
|
*
|
|
6410
6932
|
* @example
|
|
6411
6933
|
* ```ts
|
|
6412
|
-
* import { Effect, ExecutionPlan, Layer,
|
|
6934
|
+
* import { Effect, ExecutionPlan, Layer, Context } from "effect"
|
|
6413
6935
|
*
|
|
6414
|
-
* const Endpoint =
|
|
6936
|
+
* const Endpoint = Context.Service<{ url: string }>("Endpoint")
|
|
6415
6937
|
*
|
|
6416
6938
|
* const fetchUrl = Effect.gen(function*() {
|
|
6417
6939
|
* const endpoint = yield* Effect.service(Endpoint)
|
|
6418
|
-
*
|
|
6940
|
+
* if (endpoint.url === "bad") {
|
|
6941
|
+
* return yield* Effect.fail("Unavailable")
|
|
6942
|
+
* }
|
|
6943
|
+
* return endpoint.url
|
|
6419
6944
|
* })
|
|
6420
6945
|
*
|
|
6421
6946
|
* const plan = ExecutionPlan.make(
|
|
@@ -6445,13 +6970,16 @@ export declare const withExecutionPlan: {
|
|
|
6445
6970
|
*
|
|
6446
6971
|
* @example
|
|
6447
6972
|
* ```ts
|
|
6448
|
-
* import { Effect, ExecutionPlan, Layer,
|
|
6973
|
+
* import { Effect, ExecutionPlan, Layer, Context } from "effect"
|
|
6449
6974
|
*
|
|
6450
|
-
* const Endpoint =
|
|
6975
|
+
* const Endpoint = Context.Service<{ url: string }>("Endpoint")
|
|
6451
6976
|
*
|
|
6452
6977
|
* const fetchUrl = Effect.gen(function*() {
|
|
6453
6978
|
* const endpoint = yield* Effect.service(Endpoint)
|
|
6454
|
-
*
|
|
6979
|
+
* if (endpoint.url === "bad") {
|
|
6980
|
+
* return yield* Effect.fail("Unavailable")
|
|
6981
|
+
* }
|
|
6982
|
+
* return endpoint.url
|
|
6455
6983
|
* })
|
|
6456
6984
|
*
|
|
6457
6985
|
* const plan = ExecutionPlan.make(
|
|
@@ -6472,6 +7000,22 @@ export declare const withExecutionPlan: {
|
|
|
6472
7000
|
requirements: PlanR;
|
|
6473
7001
|
}>): Effect<A, E | PlanE, Exclude<R, Provides> | PlanR>;
|
|
6474
7002
|
};
|
|
7003
|
+
/**
|
|
7004
|
+
* Runs an effect and reports any errors to the configured `ErrorReporter`s.
|
|
7005
|
+
*
|
|
7006
|
+
* If the `defectsOnly` option is set to `true`, only defects (unrecoverable
|
|
7007
|
+
* errors) will be reported, while regular failures will be ignored.
|
|
7008
|
+
*
|
|
7009
|
+
* @since 4.0.0
|
|
7010
|
+
* @category Error Handling
|
|
7011
|
+
*/
|
|
7012
|
+
export declare const withErrorReporting: <Arg extends Effect<any, any, any> | {
|
|
7013
|
+
readonly defectsOnly?: boolean | undefined;
|
|
7014
|
+
} | undefined = {
|
|
7015
|
+
readonly defectsOnly?: boolean | undefined;
|
|
7016
|
+
}>(effectOrOptions: Arg, options?: {
|
|
7017
|
+
readonly defectsOnly?: boolean | undefined;
|
|
7018
|
+
} | undefined) => [Arg] extends [Effect<infer _A, infer _E, infer _R>] ? Arg : <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, R>;
|
|
6475
7019
|
/**
|
|
6476
7020
|
* Replaces the original failure with a success value, ensuring the effect
|
|
6477
7021
|
* cannot fail.
|
|
@@ -6599,6 +7143,50 @@ export declare const orElseSucceed: {
|
|
|
6599
7143
|
*/
|
|
6600
7144
|
<A, E, R, A2>(self: Effect<A, E, R>, evaluate: LazyArg<A2>): Effect<A | A2, never, R>;
|
|
6601
7145
|
};
|
|
7146
|
+
/**
|
|
7147
|
+
* Runs a sequence of effects and returns the result of the first successful
|
|
7148
|
+
* one.
|
|
7149
|
+
*
|
|
7150
|
+
* **Details**
|
|
7151
|
+
*
|
|
7152
|
+
* This function executes the provided effects in sequence, stopping at the
|
|
7153
|
+
* first success. If an effect succeeds, its result is returned immediately and
|
|
7154
|
+
* no further effects in the sequence are executed.
|
|
7155
|
+
*
|
|
7156
|
+
* If all effects fail, the returned effect fails with the error from the last
|
|
7157
|
+
* effect. If the collection is empty, the returned effect defects with an
|
|
7158
|
+
* `Error` whose message is `"Received an empty collection of effects"`.
|
|
7159
|
+
*
|
|
7160
|
+
* **When to Use**
|
|
7161
|
+
*
|
|
7162
|
+
* Use `firstSuccessOf` when you have prioritized fallback strategies, such as
|
|
7163
|
+
* attempting multiple APIs, reading configuration from several sources, or
|
|
7164
|
+
* trying alternative resource locations in order.
|
|
7165
|
+
*
|
|
7166
|
+
* @example
|
|
7167
|
+
* ```ts
|
|
7168
|
+
* import { Effect } from "effect"
|
|
7169
|
+
*
|
|
7170
|
+
* const primary = Effect.fail("primary unavailable")
|
|
7171
|
+
* const secondary = Effect.succeed("secondary result")
|
|
7172
|
+
* const tertiary = Effect.sync(() => {
|
|
7173
|
+
* throw new Error("not evaluated")
|
|
7174
|
+
* })
|
|
7175
|
+
*
|
|
7176
|
+
* const program = Effect.firstSuccessOf([
|
|
7177
|
+
* primary,
|
|
7178
|
+
* secondary,
|
|
7179
|
+
* tertiary
|
|
7180
|
+
* ])
|
|
7181
|
+
*
|
|
7182
|
+
* console.log(Effect.runSync(program))
|
|
7183
|
+
* // Output: "secondary result"
|
|
7184
|
+
* ```
|
|
7185
|
+
*
|
|
7186
|
+
* @since 2.0.0
|
|
7187
|
+
* @category Fallback
|
|
7188
|
+
*/
|
|
7189
|
+
export declare const firstSuccessOf: <Eff extends Effect<any, any, any>>(effects: Iterable<Eff>) => Effect<Success<Eff>, Error<Eff>, Services<Eff>>;
|
|
6602
7190
|
/**
|
|
6603
7191
|
* Adds a time limit to an effect, triggering a timeout if the effect exceeds
|
|
6604
7192
|
* the duration.
|
|
@@ -6692,7 +7280,7 @@ export declare const timeout: {
|
|
|
6692
7280
|
* @since 2.0.0
|
|
6693
7281
|
* @category Delays & Timeouts
|
|
6694
7282
|
*/
|
|
6695
|
-
(duration: Duration.
|
|
7283
|
+
(duration: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E | Cause.TimeoutError, R>;
|
|
6696
7284
|
/**
|
|
6697
7285
|
* Adds a time limit to an effect, triggering a timeout if the effect exceeds
|
|
6698
7286
|
* the duration.
|
|
@@ -6739,7 +7327,7 @@ export declare const timeout: {
|
|
|
6739
7327
|
* @since 2.0.0
|
|
6740
7328
|
* @category Delays & Timeouts
|
|
6741
7329
|
*/
|
|
6742
|
-
<A, E, R>(self: Effect<A, E, R>, duration: Duration.
|
|
7330
|
+
<A, E, R>(self: Effect<A, E, R>, duration: Duration.Input): Effect<A, E | Cause.TimeoutError, R>;
|
|
6743
7331
|
};
|
|
6744
7332
|
/**
|
|
6745
7333
|
* Handles timeouts by returning an `Option` that represents either the result
|
|
@@ -6840,7 +7428,7 @@ export declare const timeoutOption: {
|
|
|
6840
7428
|
* @since 3.1.0
|
|
6841
7429
|
* @category Delays & Timeouts
|
|
6842
7430
|
*/
|
|
6843
|
-
(duration: Duration.
|
|
7431
|
+
(duration: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<Option<A>, E, R>;
|
|
6844
7432
|
/**
|
|
6845
7433
|
* Handles timeouts by returning an `Option` that represents either the result
|
|
6846
7434
|
* or a timeout.
|
|
@@ -6890,7 +7478,7 @@ export declare const timeoutOption: {
|
|
|
6890
7478
|
* @since 3.1.0
|
|
6891
7479
|
* @category Delays & Timeouts
|
|
6892
7480
|
*/
|
|
6893
|
-
<A, E, R>(self: Effect<A, E, R>, duration: Duration.
|
|
7481
|
+
<A, E, R>(self: Effect<A, E, R>, duration: Duration.Input): Effect<Option<A>, E, R>;
|
|
6894
7482
|
};
|
|
6895
7483
|
/**
|
|
6896
7484
|
* Applies a timeout to an effect, with a fallback effect executed if the timeout is reached.
|
|
@@ -6911,7 +7499,7 @@ export declare const timeoutOption: {
|
|
|
6911
7499
|
* // Use cached data as fallback when timeout is reached
|
|
6912
7500
|
* const program = Effect.timeoutOrElse(slowQuery, {
|
|
6913
7501
|
* duration: "2 seconds",
|
|
6914
|
-
*
|
|
7502
|
+
* orElse: () =>
|
|
6915
7503
|
* Effect.gen(function*() {
|
|
6916
7504
|
* yield* Console.log("Query timed out, using cached data")
|
|
6917
7505
|
* return "Cached result"
|
|
@@ -6948,7 +7536,7 @@ export declare const timeoutOrElse: {
|
|
|
6948
7536
|
* // Use cached data as fallback when timeout is reached
|
|
6949
7537
|
* const program = Effect.timeoutOrElse(slowQuery, {
|
|
6950
7538
|
* duration: "2 seconds",
|
|
6951
|
-
*
|
|
7539
|
+
* orElse: () =>
|
|
6952
7540
|
* Effect.gen(function*() {
|
|
6953
7541
|
* yield* Console.log("Query timed out, using cached data")
|
|
6954
7542
|
* return "Cached result"
|
|
@@ -6966,8 +7554,8 @@ export declare const timeoutOrElse: {
|
|
|
6966
7554
|
* @category Delays & Timeouts
|
|
6967
7555
|
*/
|
|
6968
7556
|
<A2, E2, R2>(options: {
|
|
6969
|
-
readonly duration: Duration.
|
|
6970
|
-
readonly
|
|
7557
|
+
readonly duration: Duration.Input;
|
|
7558
|
+
readonly orElse: LazyArg<Effect<A2, E2, R2>>;
|
|
6971
7559
|
}): <A, E, R>(self: Effect<A, E, R>) => Effect<A | A2, E | E2, R | R2>;
|
|
6972
7560
|
/**
|
|
6973
7561
|
* Applies a timeout to an effect, with a fallback effect executed if the timeout is reached.
|
|
@@ -6988,7 +7576,7 @@ export declare const timeoutOrElse: {
|
|
|
6988
7576
|
* // Use cached data as fallback when timeout is reached
|
|
6989
7577
|
* const program = Effect.timeoutOrElse(slowQuery, {
|
|
6990
7578
|
* duration: "2 seconds",
|
|
6991
|
-
*
|
|
7579
|
+
* orElse: () =>
|
|
6992
7580
|
* Effect.gen(function*() {
|
|
6993
7581
|
* yield* Console.log("Query timed out, using cached data")
|
|
6994
7582
|
* return "Cached result"
|
|
@@ -7006,8 +7594,8 @@ export declare const timeoutOrElse: {
|
|
|
7006
7594
|
* @category Delays & Timeouts
|
|
7007
7595
|
*/
|
|
7008
7596
|
<A, E, R, A2, E2, R2>(self: Effect<A, E, R>, options: {
|
|
7009
|
-
readonly duration: Duration.
|
|
7010
|
-
readonly
|
|
7597
|
+
readonly duration: Duration.Input;
|
|
7598
|
+
readonly orElse: LazyArg<Effect<A2, E2, R2>>;
|
|
7011
7599
|
}): Effect<A | A2, E | E2, R | R2>;
|
|
7012
7600
|
};
|
|
7013
7601
|
/**
|
|
@@ -7051,7 +7639,7 @@ export declare const delay: {
|
|
|
7051
7639
|
* @since 2.0.0
|
|
7052
7640
|
* @category Delays & Timeouts
|
|
7053
7641
|
*/
|
|
7054
|
-
(duration: Duration.
|
|
7642
|
+
(duration: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, R>;
|
|
7055
7643
|
/**
|
|
7056
7644
|
* Returns an effect that is delayed from this effect by the specified
|
|
7057
7645
|
* `Duration`.
|
|
@@ -7072,7 +7660,7 @@ export declare const delay: {
|
|
|
7072
7660
|
* @since 2.0.0
|
|
7073
7661
|
* @category Delays & Timeouts
|
|
7074
7662
|
*/
|
|
7075
|
-
<A, E, R>(self: Effect<A, E, R>, duration: Duration.
|
|
7663
|
+
<A, E, R>(self: Effect<A, E, R>, duration: Duration.Input): Effect<A, E, R>;
|
|
7076
7664
|
};
|
|
7077
7665
|
/**
|
|
7078
7666
|
* Returns an effect that suspends for the specified duration. This method is
|
|
@@ -7096,7 +7684,7 @@ export declare const delay: {
|
|
|
7096
7684
|
* @since 2.0.0
|
|
7097
7685
|
* @category Delays & Timeouts
|
|
7098
7686
|
*/
|
|
7099
|
-
export declare const sleep: (duration: Duration.
|
|
7687
|
+
export declare const sleep: (duration: Duration.Input) => Effect<void>;
|
|
7100
7688
|
/**
|
|
7101
7689
|
* Measures the runtime of an effect and returns the duration with its result.
|
|
7102
7690
|
*
|
|
@@ -7389,12 +7977,12 @@ export declare const raceFirst: {
|
|
|
7389
7977
|
}): Effect<A | A2, E | E2, R | R2>;
|
|
7390
7978
|
};
|
|
7391
7979
|
/**
|
|
7392
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7393
|
-
* predicate
|
|
7980
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
7981
|
+
* predicate.
|
|
7394
7982
|
*
|
|
7395
7983
|
* @example
|
|
7396
7984
|
* ```ts
|
|
7397
|
-
* import { Effect
|
|
7985
|
+
* import { Effect } from "effect"
|
|
7398
7986
|
*
|
|
7399
7987
|
* // Sync predicate
|
|
7400
7988
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -7402,10 +7990,7 @@ export declare const raceFirst: {
|
|
|
7402
7990
|
* // Effectful predicate
|
|
7403
7991
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7404
7992
|
*
|
|
7405
|
-
* //
|
|
7406
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
7407
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
7408
|
-
* )
|
|
7993
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
7409
7994
|
* ```
|
|
7410
7995
|
*
|
|
7411
7996
|
* @since 2.0.0
|
|
@@ -7413,12 +7998,12 @@ export declare const raceFirst: {
|
|
|
7413
7998
|
*/
|
|
7414
7999
|
export declare const filter: {
|
|
7415
8000
|
/**
|
|
7416
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7417
|
-
* predicate
|
|
8001
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8002
|
+
* predicate.
|
|
7418
8003
|
*
|
|
7419
8004
|
* @example
|
|
7420
8005
|
* ```ts
|
|
7421
|
-
* import { Effect
|
|
8006
|
+
* import { Effect } from "effect"
|
|
7422
8007
|
*
|
|
7423
8008
|
* // Sync predicate
|
|
7424
8009
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -7426,10 +8011,7 @@ export declare const filter: {
|
|
|
7426
8011
|
* // Effectful predicate
|
|
7427
8012
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7428
8013
|
*
|
|
7429
|
-
* //
|
|
7430
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
7431
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
7432
|
-
* )
|
|
8014
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
7433
8015
|
* ```
|
|
7434
8016
|
*
|
|
7435
8017
|
* @since 2.0.0
|
|
@@ -7437,12 +8019,12 @@ export declare const filter: {
|
|
|
7437
8019
|
*/
|
|
7438
8020
|
<A, B extends A>(refinement: Predicate.Refinement<NoInfer<A>, B>): (elements: Iterable<A>) => Effect<Array<B>>;
|
|
7439
8021
|
/**
|
|
7440
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7441
|
-
* predicate
|
|
8022
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8023
|
+
* predicate.
|
|
7442
8024
|
*
|
|
7443
8025
|
* @example
|
|
7444
8026
|
* ```ts
|
|
7445
|
-
* import { Effect
|
|
8027
|
+
* import { Effect } from "effect"
|
|
7446
8028
|
*
|
|
7447
8029
|
* // Sync predicate
|
|
7448
8030
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -7450,10 +8032,7 @@ export declare const filter: {
|
|
|
7450
8032
|
* // Effectful predicate
|
|
7451
8033
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7452
8034
|
*
|
|
7453
|
-
* //
|
|
7454
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
7455
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
7456
|
-
* )
|
|
8035
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
7457
8036
|
* ```
|
|
7458
8037
|
*
|
|
7459
8038
|
* @since 2.0.0
|
|
@@ -7461,12 +8040,12 @@ export declare const filter: {
|
|
|
7461
8040
|
*/
|
|
7462
8041
|
<A>(predicate: Predicate.Predicate<NoInfer<A>>): (elements: Iterable<A>) => Effect<Array<A>>;
|
|
7463
8042
|
/**
|
|
7464
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7465
|
-
* predicate
|
|
8043
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8044
|
+
* predicate.
|
|
7466
8045
|
*
|
|
7467
8046
|
* @example
|
|
7468
8047
|
* ```ts
|
|
7469
|
-
* import { Effect
|
|
8048
|
+
* import { Effect } from "effect"
|
|
7470
8049
|
*
|
|
7471
8050
|
* // Sync predicate
|
|
7472
8051
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -7474,25 +8053,22 @@ export declare const filter: {
|
|
|
7474
8053
|
* // Effectful predicate
|
|
7475
8054
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7476
8055
|
*
|
|
7477
|
-
* //
|
|
7478
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
7479
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
7480
|
-
* )
|
|
8056
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
7481
8057
|
* ```
|
|
7482
8058
|
*
|
|
7483
8059
|
* @since 2.0.0
|
|
7484
8060
|
* @category Filtering
|
|
7485
8061
|
*/
|
|
7486
|
-
<A,
|
|
8062
|
+
<A, E, R>(predicate: (a: NoInfer<A>, i: number) => Effect<boolean, E, R>, options?: {
|
|
7487
8063
|
readonly concurrency?: Concurrency | undefined;
|
|
7488
|
-
}): (
|
|
8064
|
+
}): (iterable: Iterable<A>) => Effect<Array<A>, E, R>;
|
|
7489
8065
|
/**
|
|
7490
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7491
|
-
* predicate
|
|
8066
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8067
|
+
* predicate.
|
|
7492
8068
|
*
|
|
7493
8069
|
* @example
|
|
7494
8070
|
* ```ts
|
|
7495
|
-
* import { Effect
|
|
8071
|
+
* import { Effect } from "effect"
|
|
7496
8072
|
*
|
|
7497
8073
|
* // Sync predicate
|
|
7498
8074
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -7500,25 +8076,20 @@ export declare const filter: {
|
|
|
7500
8076
|
* // Effectful predicate
|
|
7501
8077
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7502
8078
|
*
|
|
7503
|
-
* //
|
|
7504
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
7505
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
7506
|
-
* )
|
|
8079
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
7507
8080
|
* ```
|
|
7508
8081
|
*
|
|
7509
8082
|
* @since 2.0.0
|
|
7510
8083
|
* @category Filtering
|
|
7511
8084
|
*/
|
|
7512
|
-
<A, B
|
|
7513
|
-
readonly concurrency?: Concurrency | undefined;
|
|
7514
|
-
}): (elements: Iterable<A>) => Effect<Array<B>, E, R>;
|
|
8085
|
+
<A, B extends A>(elements: Iterable<A>, refinement: Predicate.Refinement<A, B>): Effect<Array<B>>;
|
|
7515
8086
|
/**
|
|
7516
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7517
|
-
* predicate
|
|
8087
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8088
|
+
* predicate.
|
|
7518
8089
|
*
|
|
7519
8090
|
* @example
|
|
7520
8091
|
* ```ts
|
|
7521
|
-
* import { Effect
|
|
8092
|
+
* import { Effect } from "effect"
|
|
7522
8093
|
*
|
|
7523
8094
|
* // Sync predicate
|
|
7524
8095
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -7526,25 +8097,20 @@ export declare const filter: {
|
|
|
7526
8097
|
* // Effectful predicate
|
|
7527
8098
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7528
8099
|
*
|
|
7529
|
-
* //
|
|
7530
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
7531
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
7532
|
-
* )
|
|
8100
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
7533
8101
|
* ```
|
|
7534
8102
|
*
|
|
7535
8103
|
* @since 2.0.0
|
|
7536
8104
|
* @category Filtering
|
|
7537
8105
|
*/
|
|
7538
|
-
<A
|
|
7539
|
-
readonly concurrency?: Concurrency | undefined;
|
|
7540
|
-
}): (iterable: Iterable<A>) => Effect<Array<A>, E, R>;
|
|
8106
|
+
<A>(elements: Iterable<A>, predicate: Predicate.Predicate<A>): Effect<Array<A>>;
|
|
7541
8107
|
/**
|
|
7542
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7543
|
-
* predicate
|
|
8108
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8109
|
+
* predicate.
|
|
7544
8110
|
*
|
|
7545
8111
|
* @example
|
|
7546
8112
|
* ```ts
|
|
7547
|
-
* import { Effect
|
|
8113
|
+
* import { Effect } from "effect"
|
|
7548
8114
|
*
|
|
7549
8115
|
* // Sync predicate
|
|
7550
8116
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -7552,116 +8118,63 @@ export declare const filter: {
|
|
|
7552
8118
|
* // Effectful predicate
|
|
7553
8119
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7554
8120
|
*
|
|
7555
|
-
* //
|
|
7556
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
7557
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
7558
|
-
* )
|
|
8121
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
7559
8122
|
* ```
|
|
7560
8123
|
*
|
|
7561
8124
|
* @since 2.0.0
|
|
7562
8125
|
* @category Filtering
|
|
7563
8126
|
*/
|
|
7564
|
-
<A,
|
|
8127
|
+
<A, E, R>(iterable: Iterable<A>, predicate: (a: NoInfer<A>, i: number) => Effect<boolean, E, R>, options?: {
|
|
8128
|
+
readonly concurrency?: Concurrency | undefined;
|
|
8129
|
+
}): Effect<Array<A>, E, R>;
|
|
8130
|
+
};
|
|
8131
|
+
/**
|
|
8132
|
+
* Filters and maps elements of an iterable with a `Filter`.
|
|
8133
|
+
*
|
|
8134
|
+
* @since 4.0.0
|
|
8135
|
+
* @category Filtering
|
|
8136
|
+
*/
|
|
8137
|
+
export declare const filterMap: {
|
|
7565
8138
|
/**
|
|
7566
|
-
* Filters elements of an iterable
|
|
7567
|
-
* predicate, or `Filter.FilterEffect`.
|
|
7568
|
-
*
|
|
7569
|
-
* @example
|
|
7570
|
-
* ```ts
|
|
7571
|
-
* import { Effect, Filter, Result } from "effect"
|
|
7572
|
-
*
|
|
7573
|
-
* // Sync predicate
|
|
7574
|
-
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
8139
|
+
* Filters and maps elements of an iterable with a `Filter`.
|
|
7575
8140
|
*
|
|
7576
|
-
*
|
|
7577
|
-
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7578
|
-
*
|
|
7579
|
-
* // FilterEffect
|
|
7580
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
7581
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
7582
|
-
* )
|
|
7583
|
-
* ```
|
|
7584
|
-
*
|
|
7585
|
-
* @since 2.0.0
|
|
8141
|
+
* @since 4.0.0
|
|
7586
8142
|
* @category Filtering
|
|
7587
8143
|
*/
|
|
7588
|
-
<A>(
|
|
8144
|
+
<A, B, X>(filter: Filter.Filter<NoInfer<A>, B, X>): (elements: Iterable<A>) => Effect<Array<B>>;
|
|
7589
8145
|
/**
|
|
7590
|
-
* Filters elements of an iterable
|
|
7591
|
-
* predicate, or `Filter.FilterEffect`.
|
|
7592
|
-
*
|
|
7593
|
-
* @example
|
|
7594
|
-
* ```ts
|
|
7595
|
-
* import { Effect, Filter, Result } from "effect"
|
|
7596
|
-
*
|
|
7597
|
-
* // Sync predicate
|
|
7598
|
-
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
7599
|
-
*
|
|
7600
|
-
* // Effectful predicate
|
|
7601
|
-
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
8146
|
+
* Filters and maps elements of an iterable with a `Filter`.
|
|
7602
8147
|
*
|
|
7603
|
-
*
|
|
7604
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
7605
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
7606
|
-
* )
|
|
7607
|
-
* ```
|
|
7608
|
-
*
|
|
7609
|
-
* @since 2.0.0
|
|
8148
|
+
* @since 4.0.0
|
|
7610
8149
|
* @category Filtering
|
|
7611
8150
|
*/
|
|
7612
8151
|
<A, B, X>(elements: Iterable<A>, filter: Filter.Filter<NoInfer<A>, B, X>): Effect<Array<B>>;
|
|
8152
|
+
};
|
|
8153
|
+
/**
|
|
8154
|
+
* Effectfully filters and maps elements of an iterable with a `FilterEffect`.
|
|
8155
|
+
*
|
|
8156
|
+
* @since 4.0.0
|
|
8157
|
+
* @category Filtering
|
|
8158
|
+
*/
|
|
8159
|
+
export declare const filterMapEffect: {
|
|
7613
8160
|
/**
|
|
7614
|
-
*
|
|
7615
|
-
* predicate, or `Filter.FilterEffect`.
|
|
7616
|
-
*
|
|
7617
|
-
* @example
|
|
7618
|
-
* ```ts
|
|
7619
|
-
* import { Effect, Filter, Result } from "effect"
|
|
7620
|
-
*
|
|
7621
|
-
* // Sync predicate
|
|
7622
|
-
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
7623
|
-
*
|
|
7624
|
-
* // Effectful predicate
|
|
7625
|
-
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
8161
|
+
* Effectfully filters and maps elements of an iterable with a `FilterEffect`.
|
|
7626
8162
|
*
|
|
7627
|
-
*
|
|
7628
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
7629
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
7630
|
-
* )
|
|
7631
|
-
* ```
|
|
7632
|
-
*
|
|
7633
|
-
* @since 2.0.0
|
|
8163
|
+
* @since 4.0.0
|
|
7634
8164
|
* @category Filtering
|
|
7635
8165
|
*/
|
|
7636
|
-
<A, B, X, E, R>(
|
|
8166
|
+
<A, B, X, E, R>(filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R>, options?: {
|
|
7637
8167
|
readonly concurrency?: Concurrency | undefined;
|
|
7638
|
-
}): Effect<Array<B>, E, R>;
|
|
8168
|
+
}): (elements: Iterable<A>) => Effect<Array<B>, E, R>;
|
|
7639
8169
|
/**
|
|
7640
|
-
*
|
|
7641
|
-
* predicate, or `Filter.FilterEffect`.
|
|
7642
|
-
*
|
|
7643
|
-
* @example
|
|
7644
|
-
* ```ts
|
|
7645
|
-
* import { Effect, Filter, Result } from "effect"
|
|
7646
|
-
*
|
|
7647
|
-
* // Sync predicate
|
|
7648
|
-
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
7649
|
-
*
|
|
7650
|
-
* // Effectful predicate
|
|
7651
|
-
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7652
|
-
*
|
|
7653
|
-
* // FilterEffect
|
|
7654
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
7655
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
7656
|
-
* )
|
|
7657
|
-
* ```
|
|
8170
|
+
* Effectfully filters and maps elements of an iterable with a `FilterEffect`.
|
|
7658
8171
|
*
|
|
7659
|
-
* @since
|
|
8172
|
+
* @since 4.0.0
|
|
7660
8173
|
* @category Filtering
|
|
7661
8174
|
*/
|
|
7662
|
-
<A, E, R>(
|
|
8175
|
+
<A, B, X, E, R>(elements: Iterable<A>, filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R>, options?: {
|
|
7663
8176
|
readonly concurrency?: Concurrency | undefined;
|
|
7664
|
-
}): Effect<Array<
|
|
8177
|
+
}): Effect<Array<B>, E, R>;
|
|
7665
8178
|
};
|
|
7666
8179
|
/**
|
|
7667
8180
|
* Filters an effect, providing an alternative effect if the predicate fails.
|
|
@@ -7755,7 +8268,7 @@ export declare const filterOrElse: {
|
|
|
7755
8268
|
* @since 2.0.0
|
|
7756
8269
|
* @category Filtering
|
|
7757
8270
|
*/
|
|
7758
|
-
<A,
|
|
8271
|
+
<A, C, E2, R2>(predicate: Predicate.Predicate<NoInfer<A>>, orElse: (a: NoInfer<A>) => Effect<C, E2, R2>): <E, R>(self: Effect<A, E, R>) => Effect<A | C, E2 | E, R2 | R>;
|
|
7759
8272
|
/**
|
|
7760
8273
|
* Filters an effect, providing an alternative effect if the predicate fails.
|
|
7761
8274
|
*
|
|
@@ -7817,7 +8330,29 @@ export declare const filterOrElse: {
|
|
|
7817
8330
|
* @since 2.0.0
|
|
7818
8331
|
* @category Filtering
|
|
7819
8332
|
*/
|
|
7820
|
-
<A, E, R,
|
|
8333
|
+
<A, E, R, C, E2, R2>(self: Effect<A, E, R>, predicate: Predicate.Predicate<NoInfer<A>>, orElse: (a: NoInfer<A>) => Effect<C, E2, R2>): Effect<A | C, E | E2, R | R2>;
|
|
8334
|
+
};
|
|
8335
|
+
/**
|
|
8336
|
+
* Filters an effect with a `Filter`, providing an alternative effect on failure.
|
|
8337
|
+
*
|
|
8338
|
+
* @since 4.0.0
|
|
8339
|
+
* @category Filtering
|
|
8340
|
+
*/
|
|
8341
|
+
export declare const filterMapOrElse: {
|
|
8342
|
+
/**
|
|
8343
|
+
* Filters an effect with a `Filter`, providing an alternative effect on failure.
|
|
8344
|
+
*
|
|
8345
|
+
* @since 4.0.0
|
|
8346
|
+
* @category Filtering
|
|
8347
|
+
*/
|
|
8348
|
+
<A, B, X, C, E2, R2>(filter: Filter.Filter<NoInfer<A>, B, X>, orElse: (x: X) => Effect<C, E2, R2>): <E, R>(self: Effect<A, E, R>) => Effect<B | C, E2 | E, R2 | R>;
|
|
8349
|
+
/**
|
|
8350
|
+
* Filters an effect with a `Filter`, providing an alternative effect on failure.
|
|
8351
|
+
*
|
|
8352
|
+
* @since 4.0.0
|
|
8353
|
+
* @category Filtering
|
|
8354
|
+
*/
|
|
8355
|
+
<A, E, R, B, X, C, E2, R2>(self: Effect<A, E, R>, filter: Filter.Filter<NoInfer<A>, B, X>, orElse: (x: X) => Effect<C, E2, R2>): Effect<B | C, E | E2, R | R2>;
|
|
7821
8356
|
};
|
|
7822
8357
|
/**
|
|
7823
8358
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
@@ -7878,127 +8413,7 @@ export declare const filterOrFail: {
|
|
|
7878
8413
|
* @since 2.0.0
|
|
7879
8414
|
* @category Filtering
|
|
7880
8415
|
*/
|
|
7881
|
-
<A, E2, B extends A>(refinement: Predicate.Refinement<NoInfer<A>, B>, orFailWith: (a: NoInfer<A>) => E2): <E, R>(self: Effect<A, E, R>) => Effect<B, E2 | E, R>;
|
|
7882
|
-
/**
|
|
7883
|
-
* Filters an effect, failing with a custom error if the predicate fails.
|
|
7884
|
-
*
|
|
7885
|
-
* **Details**
|
|
7886
|
-
*
|
|
7887
|
-
* This function applies a predicate to the result of an effect. If the
|
|
7888
|
-
* predicate evaluates to `false`, the effect fails with either a custom
|
|
7889
|
-
* error (if `orFailWith` is provided) or a `NoSuchElementError`.
|
|
7890
|
-
*
|
|
7891
|
-
* @example
|
|
7892
|
-
* ```ts
|
|
7893
|
-
* import { Effect } from "effect"
|
|
7894
|
-
*
|
|
7895
|
-
* // An effect that produces a number
|
|
7896
|
-
* const program = Effect.succeed(5)
|
|
7897
|
-
*
|
|
7898
|
-
* // Filter for even numbers, fail for odd numbers
|
|
7899
|
-
* const filtered = Effect.filterOrFail(
|
|
7900
|
-
* program,
|
|
7901
|
-
* (n) => n % 2 === 0,
|
|
7902
|
-
* (n) => `Expected even number, got ${n}`
|
|
7903
|
-
* )
|
|
7904
|
-
*
|
|
7905
|
-
* // Result: Effect.fail("Expected even number, got 5")
|
|
7906
|
-
* ```
|
|
7907
|
-
*
|
|
7908
|
-
* @since 2.0.0
|
|
7909
|
-
* @category Filtering
|
|
7910
|
-
*/
|
|
7911
|
-
<A, E2>(predicate: Predicate.Predicate<NoInfer<A>>, orFailWith: (a: NoInfer<A>) => E2): <E, R>(self: Effect<A, E, R>) => Effect<A, E2 | E, R>;
|
|
7912
|
-
/**
|
|
7913
|
-
* Filters an effect, failing with a custom error if the predicate fails.
|
|
7914
|
-
*
|
|
7915
|
-
* **Details**
|
|
7916
|
-
*
|
|
7917
|
-
* This function applies a predicate to the result of an effect. If the
|
|
7918
|
-
* predicate evaluates to `false`, the effect fails with either a custom
|
|
7919
|
-
* error (if `orFailWith` is provided) or a `NoSuchElementError`.
|
|
7920
|
-
*
|
|
7921
|
-
* @example
|
|
7922
|
-
* ```ts
|
|
7923
|
-
* import { Effect } from "effect"
|
|
7924
|
-
*
|
|
7925
|
-
* // An effect that produces a number
|
|
7926
|
-
* const program = Effect.succeed(5)
|
|
7927
|
-
*
|
|
7928
|
-
* // Filter for even numbers, fail for odd numbers
|
|
7929
|
-
* const filtered = Effect.filterOrFail(
|
|
7930
|
-
* program,
|
|
7931
|
-
* (n) => n % 2 === 0,
|
|
7932
|
-
* (n) => `Expected even number, got ${n}`
|
|
7933
|
-
* )
|
|
7934
|
-
*
|
|
7935
|
-
* // Result: Effect.fail("Expected even number, got 5")
|
|
7936
|
-
* ```
|
|
7937
|
-
*
|
|
7938
|
-
* @since 2.0.0
|
|
7939
|
-
* @category Filtering
|
|
7940
|
-
*/
|
|
7941
|
-
<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>;
|
|
7942
|
-
/**
|
|
7943
|
-
* Filters an effect, failing with a custom error if the predicate fails.
|
|
7944
|
-
*
|
|
7945
|
-
* **Details**
|
|
7946
|
-
*
|
|
7947
|
-
* This function applies a predicate to the result of an effect. If the
|
|
7948
|
-
* predicate evaluates to `false`, the effect fails with either a custom
|
|
7949
|
-
* error (if `orFailWith` is provided) or a `NoSuchElementError`.
|
|
7950
|
-
*
|
|
7951
|
-
* @example
|
|
7952
|
-
* ```ts
|
|
7953
|
-
* import { Effect } from "effect"
|
|
7954
|
-
*
|
|
7955
|
-
* // An effect that produces a number
|
|
7956
|
-
* const program = Effect.succeed(5)
|
|
7957
|
-
*
|
|
7958
|
-
* // Filter for even numbers, fail for odd numbers
|
|
7959
|
-
* const filtered = Effect.filterOrFail(
|
|
7960
|
-
* program,
|
|
7961
|
-
* (n) => n % 2 === 0,
|
|
7962
|
-
* (n) => `Expected even number, got ${n}`
|
|
7963
|
-
* )
|
|
7964
|
-
*
|
|
7965
|
-
* // Result: Effect.fail("Expected even number, got 5")
|
|
7966
|
-
* ```
|
|
7967
|
-
*
|
|
7968
|
-
* @since 2.0.0
|
|
7969
|
-
* @category Filtering
|
|
7970
|
-
*/
|
|
7971
|
-
<A, B extends A>(refinement: Predicate.Refinement<NoInfer<A>, B>): <E, R>(self: Effect<A, E, R>) => Effect<B, Cause.NoSuchElementError | E, R>;
|
|
7972
|
-
/**
|
|
7973
|
-
* Filters an effect, failing with a custom error if the predicate fails.
|
|
7974
|
-
*
|
|
7975
|
-
* **Details**
|
|
7976
|
-
*
|
|
7977
|
-
* This function applies a predicate to the result of an effect. If the
|
|
7978
|
-
* predicate evaluates to `false`, the effect fails with either a custom
|
|
7979
|
-
* error (if `orFailWith` is provided) or a `NoSuchElementError`.
|
|
7980
|
-
*
|
|
7981
|
-
* @example
|
|
7982
|
-
* ```ts
|
|
7983
|
-
* import { Effect } from "effect"
|
|
7984
|
-
*
|
|
7985
|
-
* // An effect that produces a number
|
|
7986
|
-
* const program = Effect.succeed(5)
|
|
7987
|
-
*
|
|
7988
|
-
* // Filter for even numbers, fail for odd numbers
|
|
7989
|
-
* const filtered = Effect.filterOrFail(
|
|
7990
|
-
* program,
|
|
7991
|
-
* (n) => n % 2 === 0,
|
|
7992
|
-
* (n) => `Expected even number, got ${n}`
|
|
7993
|
-
* )
|
|
7994
|
-
*
|
|
7995
|
-
* // Result: Effect.fail("Expected even number, got 5")
|
|
7996
|
-
* ```
|
|
7997
|
-
*
|
|
7998
|
-
* @since 2.0.0
|
|
7999
|
-
* @category Filtering
|
|
8000
|
-
*/
|
|
8001
|
-
<A>(predicate: Predicate.Predicate<NoInfer<A>>): <E, R>(self: Effect<A, E, R>) => Effect<A, Cause.NoSuchElementError | E, R>;
|
|
8416
|
+
<A, E2, B extends A>(refinement: Predicate.Refinement<NoInfer<A>, B>, orFailWith: (a: NoInfer<A>) => E2): <E, R>(self: Effect<A, E, R>) => Effect<B, E2 | E, R>;
|
|
8002
8417
|
/**
|
|
8003
8418
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8004
8419
|
*
|
|
@@ -8028,7 +8443,7 @@ export declare const filterOrFail: {
|
|
|
8028
8443
|
* @since 2.0.0
|
|
8029
8444
|
* @category Filtering
|
|
8030
8445
|
*/
|
|
8031
|
-
<A,
|
|
8446
|
+
<A, E2>(predicate: Predicate.Predicate<NoInfer<A>>, orFailWith: (a: NoInfer<A>) => E2): <E, R>(self: Effect<A, E, R>) => Effect<A, E2 | E, R>;
|
|
8032
8447
|
/**
|
|
8033
8448
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8034
8449
|
*
|
|
@@ -8058,7 +8473,7 @@ export declare const filterOrFail: {
|
|
|
8058
8473
|
* @since 2.0.0
|
|
8059
8474
|
* @category Filtering
|
|
8060
8475
|
*/
|
|
8061
|
-
<A,
|
|
8476
|
+
<A, B extends A>(refinement: Predicate.Refinement<NoInfer<A>, B>): <E, R>(self: Effect<A, E, R>) => Effect<B, Cause.NoSuchElementError | E, R>;
|
|
8062
8477
|
/**
|
|
8063
8478
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8064
8479
|
*
|
|
@@ -8088,7 +8503,7 @@ export declare const filterOrFail: {
|
|
|
8088
8503
|
* @since 2.0.0
|
|
8089
8504
|
* @category Filtering
|
|
8090
8505
|
*/
|
|
8091
|
-
<A
|
|
8506
|
+
<A>(predicate: Predicate.Predicate<NoInfer<A>>): <E, R>(self: Effect<A, E, R>) => Effect<A, Cause.NoSuchElementError | E, R>;
|
|
8092
8507
|
/**
|
|
8093
8508
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8094
8509
|
*
|
|
@@ -8118,7 +8533,7 @@ export declare const filterOrFail: {
|
|
|
8118
8533
|
* @since 2.0.0
|
|
8119
8534
|
* @category Filtering
|
|
8120
8535
|
*/
|
|
8121
|
-
<A, E, R,
|
|
8536
|
+
<A, E, R, E2, B extends A>(self: Effect<A, E, R>, refinement: Predicate.Refinement<NoInfer<A>, B>, orFailWith: (a: NoInfer<A>) => E2): Effect<B, E2 | E, R>;
|
|
8122
8537
|
/**
|
|
8123
8538
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8124
8539
|
*
|
|
@@ -8148,7 +8563,7 @@ export declare const filterOrFail: {
|
|
|
8148
8563
|
* @since 2.0.0
|
|
8149
8564
|
* @category Filtering
|
|
8150
8565
|
*/
|
|
8151
|
-
<A, E, R,
|
|
8566
|
+
<A, E, R, E2>(self: Effect<A, E, R>, predicate: Predicate.Predicate<NoInfer<A>>, orFailWith: (a: NoInfer<A>) => E2): Effect<A, E2 | E, R>;
|
|
8152
8567
|
/**
|
|
8153
8568
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8154
8569
|
*
|
|
@@ -8178,7 +8593,7 @@ export declare const filterOrFail: {
|
|
|
8178
8593
|
* @since 2.0.0
|
|
8179
8594
|
* @category Filtering
|
|
8180
8595
|
*/
|
|
8181
|
-
<A, E, R>(self: Effect<A, E, R>,
|
|
8596
|
+
<A, E, R, B extends A>(self: Effect<A, E, R>, refinement: Predicate.Refinement<NoInfer<A>, B>): Effect<B, E | Cause.NoSuchElementError, R>;
|
|
8182
8597
|
/**
|
|
8183
8598
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8184
8599
|
*
|
|
@@ -8208,7 +8623,43 @@ export declare const filterOrFail: {
|
|
|
8208
8623
|
* @since 2.0.0
|
|
8209
8624
|
* @category Filtering
|
|
8210
8625
|
*/
|
|
8211
|
-
<A, E, R
|
|
8626
|
+
<A, E, R>(self: Effect<A, E, R>, predicate: Predicate.Predicate<NoInfer<A>>): Effect<A, E | Cause.NoSuchElementError, R>;
|
|
8627
|
+
};
|
|
8628
|
+
/**
|
|
8629
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
8630
|
+
*
|
|
8631
|
+
* @since 4.0.0
|
|
8632
|
+
* @category Filtering
|
|
8633
|
+
*/
|
|
8634
|
+
export declare const filterMapOrFail: {
|
|
8635
|
+
/**
|
|
8636
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
8637
|
+
*
|
|
8638
|
+
* @since 4.0.0
|
|
8639
|
+
* @category Filtering
|
|
8640
|
+
*/
|
|
8641
|
+
<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>;
|
|
8642
|
+
/**
|
|
8643
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
8644
|
+
*
|
|
8645
|
+
* @since 4.0.0
|
|
8646
|
+
* @category Filtering
|
|
8647
|
+
*/
|
|
8648
|
+
<A, B, X>(filter: Filter.Filter<NoInfer<A>, B, X>): <E, R>(self: Effect<A, E, R>) => Effect<B, Cause.NoSuchElementError | E, R>;
|
|
8649
|
+
/**
|
|
8650
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
8651
|
+
*
|
|
8652
|
+
* @since 4.0.0
|
|
8653
|
+
* @category Filtering
|
|
8654
|
+
*/
|
|
8655
|
+
<A, E, R, B, X, E2>(self: Effect<A, E, R>, filter: Filter.Filter<A, B, X>, orFailWith: (x: X) => E2): Effect<B, E2 | E, R>;
|
|
8656
|
+
/**
|
|
8657
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
8658
|
+
*
|
|
8659
|
+
* @since 4.0.0
|
|
8660
|
+
* @category Filtering
|
|
8661
|
+
*/
|
|
8662
|
+
<A, E, R, B, X>(self: Effect<A, E, R>, filter: Filter.Filter<A, B, X>): Effect<B, Cause.NoSuchElementError | E, R>;
|
|
8212
8663
|
};
|
|
8213
8664
|
/**
|
|
8214
8665
|
* Conditionally executes an effect based on a boolean condition.
|
|
@@ -8349,9 +8800,11 @@ export declare const when: {
|
|
|
8349
8800
|
* @example
|
|
8350
8801
|
* ```ts
|
|
8351
8802
|
* // Title: Handling Both Success and Failure Cases
|
|
8352
|
-
* import { Effect } from "effect"
|
|
8803
|
+
* import { Data, Effect } from "effect"
|
|
8353
8804
|
*
|
|
8354
|
-
*
|
|
8805
|
+
* class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
|
|
8806
|
+
*
|
|
8807
|
+
* const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
|
|
8355
8808
|
*
|
|
8356
8809
|
* const program1 = Effect.match(success, {
|
|
8357
8810
|
* onFailure: (error) => `failure: ${error.message}`,
|
|
@@ -8362,8 +8815,8 @@ export declare const when: {
|
|
|
8362
8815
|
* Effect.runPromise(program1).then(console.log)
|
|
8363
8816
|
* // Output: "success: 42"
|
|
8364
8817
|
*
|
|
8365
|
-
* const failure: Effect.Effect<number,
|
|
8366
|
-
* new
|
|
8818
|
+
* const failure: Effect.Effect<number, ExampleError> = Effect.fail(
|
|
8819
|
+
* new ExampleError({ message: "Uh oh!" })
|
|
8367
8820
|
* )
|
|
8368
8821
|
*
|
|
8369
8822
|
* const program2 = Effect.match(failure, {
|
|
@@ -8401,9 +8854,11 @@ export declare const match: {
|
|
|
8401
8854
|
* @example
|
|
8402
8855
|
* ```ts
|
|
8403
8856
|
* // Title: Handling Both Success and Failure Cases
|
|
8404
|
-
* import { Effect } from "effect"
|
|
8857
|
+
* import { Data, Effect } from "effect"
|
|
8858
|
+
*
|
|
8859
|
+
* class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
|
|
8405
8860
|
*
|
|
8406
|
-
* const success: Effect.Effect<number,
|
|
8861
|
+
* const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
|
|
8407
8862
|
*
|
|
8408
8863
|
* const program1 = Effect.match(success, {
|
|
8409
8864
|
* onFailure: (error) => `failure: ${error.message}`,
|
|
@@ -8414,8 +8869,8 @@ export declare const match: {
|
|
|
8414
8869
|
* Effect.runPromise(program1).then(console.log)
|
|
8415
8870
|
* // Output: "success: 42"
|
|
8416
8871
|
*
|
|
8417
|
-
* const failure: Effect.Effect<number,
|
|
8418
|
-
* new
|
|
8872
|
+
* const failure: Effect.Effect<number, ExampleError> = Effect.fail(
|
|
8873
|
+
* new ExampleError({ message: "Uh oh!" })
|
|
8419
8874
|
* )
|
|
8420
8875
|
*
|
|
8421
8876
|
* const program2 = Effect.match(failure, {
|
|
@@ -8456,9 +8911,11 @@ export declare const match: {
|
|
|
8456
8911
|
* @example
|
|
8457
8912
|
* ```ts
|
|
8458
8913
|
* // Title: Handling Both Success and Failure Cases
|
|
8459
|
-
* import { Effect } from "effect"
|
|
8914
|
+
* import { Data, Effect } from "effect"
|
|
8460
8915
|
*
|
|
8461
|
-
*
|
|
8916
|
+
* class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
|
|
8917
|
+
*
|
|
8918
|
+
* const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
|
|
8462
8919
|
*
|
|
8463
8920
|
* const program1 = Effect.match(success, {
|
|
8464
8921
|
* onFailure: (error) => `failure: ${error.message}`,
|
|
@@ -8469,8 +8926,8 @@ export declare const match: {
|
|
|
8469
8926
|
* Effect.runPromise(program1).then(console.log)
|
|
8470
8927
|
* // Output: "success: 42"
|
|
8471
8928
|
*
|
|
8472
|
-
* const failure: Effect.Effect<number,
|
|
8473
|
-
* new
|
|
8929
|
+
* const failure: Effect.Effect<number, ExampleError> = Effect.fail(
|
|
8930
|
+
* new ExampleError({ message: "Uh oh!" })
|
|
8474
8931
|
* )
|
|
8475
8932
|
*
|
|
8476
8933
|
* const program2 = Effect.match(failure, {
|
|
@@ -8872,9 +9329,11 @@ export declare const matchCauseEffectEager: {
|
|
|
8872
9329
|
*
|
|
8873
9330
|
* @example
|
|
8874
9331
|
* ```ts
|
|
8875
|
-
* import { Cause, Console, Effect, Result } from "effect"
|
|
9332
|
+
* import { Cause, Console, Data, Effect, Result } from "effect"
|
|
9333
|
+
*
|
|
9334
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
8876
9335
|
*
|
|
8877
|
-
* const task = Effect.fail(new
|
|
9336
|
+
* const task = Effect.fail(new TaskError({ message: "Task failed" }))
|
|
8878
9337
|
*
|
|
8879
9338
|
* const program = Effect.matchCauseEffect(task, {
|
|
8880
9339
|
* onFailure: (cause) =>
|
|
@@ -8924,9 +9383,11 @@ export declare const matchCauseEffect: {
|
|
|
8924
9383
|
*
|
|
8925
9384
|
* @example
|
|
8926
9385
|
* ```ts
|
|
8927
|
-
* import { Cause, Console, Effect, Result } from "effect"
|
|
9386
|
+
* import { Cause, Console, Data, Effect, Result } from "effect"
|
|
8928
9387
|
*
|
|
8929
|
-
*
|
|
9388
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
9389
|
+
*
|
|
9390
|
+
* const task = Effect.fail(new TaskError({ message: "Task failed" }))
|
|
8930
9391
|
*
|
|
8931
9392
|
* const program = Effect.matchCauseEffect(task, {
|
|
8932
9393
|
* onFailure: (cause) =>
|
|
@@ -8979,9 +9440,11 @@ export declare const matchCauseEffect: {
|
|
|
8979
9440
|
*
|
|
8980
9441
|
* @example
|
|
8981
9442
|
* ```ts
|
|
8982
|
-
* import { Cause, Console, Effect, Result } from "effect"
|
|
9443
|
+
* import { Cause, Console, Data, Effect, Result } from "effect"
|
|
9444
|
+
*
|
|
9445
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
8983
9446
|
*
|
|
8984
|
-
* const task = Effect.fail(new
|
|
9447
|
+
* const task = Effect.fail(new TaskError({ message: "Task failed" }))
|
|
8985
9448
|
*
|
|
8986
9449
|
* const program = Effect.matchCauseEffect(task, {
|
|
8987
9450
|
* onFailure: (cause) =>
|
|
@@ -9041,11 +9504,13 @@ export declare const matchCauseEffect: {
|
|
|
9041
9504
|
* @example
|
|
9042
9505
|
* ```ts
|
|
9043
9506
|
* // Title: Handling Both Success and Failure Cases with Side Effects
|
|
9044
|
-
* import { Effect } from "effect"
|
|
9507
|
+
* import { Data, Effect } from "effect"
|
|
9045
9508
|
*
|
|
9046
|
-
*
|
|
9047
|
-
*
|
|
9048
|
-
*
|
|
9509
|
+
* class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
|
|
9510
|
+
*
|
|
9511
|
+
* const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
|
|
9512
|
+
* const failure: Effect.Effect<number, ExampleError> = Effect.fail(
|
|
9513
|
+
* new ExampleError({ message: "Uh oh!" })
|
|
9049
9514
|
* )
|
|
9050
9515
|
*
|
|
9051
9516
|
* const program1 = Effect.matchEffect(success, {
|
|
@@ -9101,11 +9566,13 @@ export declare const matchEffect: {
|
|
|
9101
9566
|
* @example
|
|
9102
9567
|
* ```ts
|
|
9103
9568
|
* // Title: Handling Both Success and Failure Cases with Side Effects
|
|
9104
|
-
* import { Effect } from "effect"
|
|
9569
|
+
* import { Data, Effect } from "effect"
|
|
9570
|
+
*
|
|
9571
|
+
* class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
|
|
9105
9572
|
*
|
|
9106
|
-
* const success: Effect.Effect<number,
|
|
9107
|
-
* const failure: Effect.Effect<number,
|
|
9108
|
-
* new
|
|
9573
|
+
* const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
|
|
9574
|
+
* const failure: Effect.Effect<number, ExampleError> = Effect.fail(
|
|
9575
|
+
* new ExampleError({ message: "Uh oh!" })
|
|
9109
9576
|
* )
|
|
9110
9577
|
*
|
|
9111
9578
|
* const program1 = Effect.matchEffect(success, {
|
|
@@ -9164,11 +9631,13 @@ export declare const matchEffect: {
|
|
|
9164
9631
|
* @example
|
|
9165
9632
|
* ```ts
|
|
9166
9633
|
* // Title: Handling Both Success and Failure Cases with Side Effects
|
|
9167
|
-
* import { Effect } from "effect"
|
|
9634
|
+
* import { Data, Effect } from "effect"
|
|
9168
9635
|
*
|
|
9169
|
-
*
|
|
9170
|
-
*
|
|
9171
|
-
*
|
|
9636
|
+
* class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
|
|
9637
|
+
*
|
|
9638
|
+
* const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
|
|
9639
|
+
* const failure: Effect.Effect<number, ExampleError> = Effect.fail(
|
|
9640
|
+
* new ExampleError({ message: "Uh oh!" })
|
|
9172
9641
|
* )
|
|
9173
9642
|
*
|
|
9174
9643
|
* const program1 = Effect.matchEffect(success, {
|
|
@@ -9260,7 +9729,7 @@ export declare const isFailure: <A, E, R>(self: Effect<A, E, R>) => Effect<boole
|
|
|
9260
9729
|
*/
|
|
9261
9730
|
export declare const isSuccess: <A, E, R>(self: Effect<A, E, R>) => Effect<boolean, never, R>;
|
|
9262
9731
|
/**
|
|
9263
|
-
* Returns the complete
|
|
9732
|
+
* Returns the complete context.
|
|
9264
9733
|
*
|
|
9265
9734
|
* This function allows you to access all services that are currently available
|
|
9266
9735
|
* in the effect's environment. This can be useful for debugging, introspection,
|
|
@@ -9268,56 +9737,56 @@ export declare const isSuccess: <A, E, R>(self: Effect<A, E, R>) => Effect<boole
|
|
|
9268
9737
|
*
|
|
9269
9738
|
* @example
|
|
9270
9739
|
* ```ts
|
|
9271
|
-
* import { Console, Effect, Option,
|
|
9740
|
+
* import { Console, Effect, Option, Context } from "effect"
|
|
9272
9741
|
*
|
|
9273
|
-
* const Logger =
|
|
9742
|
+
* const Logger = Context.Service<{
|
|
9274
9743
|
* log: (msg: string) => void
|
|
9275
9744
|
* }>("Logger")
|
|
9276
|
-
* const Database =
|
|
9745
|
+
* const Database = Context.Service<{
|
|
9277
9746
|
* query: (sql: string) => string
|
|
9278
9747
|
* }>("Database")
|
|
9279
9748
|
*
|
|
9280
9749
|
* const program = Effect.gen(function*() {
|
|
9281
|
-
* const allServices = yield* Effect.
|
|
9750
|
+
* const allServices = yield* Effect.context()
|
|
9282
9751
|
*
|
|
9283
9752
|
* // Check if specific services are available
|
|
9284
|
-
* const loggerOption =
|
|
9285
|
-
* const databaseOption =
|
|
9753
|
+
* const loggerOption = Context.getOption(allServices, Logger)
|
|
9754
|
+
* const databaseOption = Context.getOption(allServices, Database)
|
|
9286
9755
|
*
|
|
9287
9756
|
* yield* Console.log(`Logger available: ${Option.isSome(loggerOption)}`)
|
|
9288
9757
|
* yield* Console.log(`Database available: ${Option.isSome(databaseOption)}`)
|
|
9289
9758
|
* })
|
|
9290
9759
|
*
|
|
9291
|
-
* const
|
|
9292
|
-
* .pipe(
|
|
9760
|
+
* const context = Context.make(Logger, { log: console.log })
|
|
9761
|
+
* .pipe(Context.add(Database, { query: () => "result" }))
|
|
9293
9762
|
*
|
|
9294
|
-
* const provided = Effect.
|
|
9763
|
+
* const provided = Effect.provideContext(program, context)
|
|
9295
9764
|
* ```
|
|
9296
9765
|
*
|
|
9297
9766
|
* @since 2.0.0
|
|
9298
9767
|
* @category Environment
|
|
9299
9768
|
*/
|
|
9300
|
-
export declare const
|
|
9769
|
+
export declare const context: <R = never>() => Effect<Context.Context<R>, never, R>;
|
|
9301
9770
|
/**
|
|
9302
|
-
* Transforms the current
|
|
9771
|
+
* Transforms the current context using the provided function.
|
|
9303
9772
|
*
|
|
9304
|
-
* This function allows you to access the complete
|
|
9773
|
+
* This function allows you to access the complete context and perform
|
|
9305
9774
|
* computations based on all available services. This is useful when you need
|
|
9306
9775
|
* to conditionally execute logic based on what services are available.
|
|
9307
9776
|
*
|
|
9308
9777
|
* @example
|
|
9309
9778
|
* ```ts
|
|
9310
|
-
* import { Console, Effect, Option,
|
|
9779
|
+
* import { Console, Effect, Option, Context } from "effect"
|
|
9311
9780
|
*
|
|
9312
|
-
* const Logger =
|
|
9781
|
+
* const Logger = Context.Service<{
|
|
9313
9782
|
* log: (msg: string) => void
|
|
9314
9783
|
* }>("Logger")
|
|
9315
|
-
* const Cache =
|
|
9784
|
+
* const Cache = Context.Service<{
|
|
9316
9785
|
* get: (key: string) => string | null
|
|
9317
9786
|
* }>("Cache")
|
|
9318
9787
|
*
|
|
9319
|
-
* const program = Effect.
|
|
9320
|
-
* const cacheOption =
|
|
9788
|
+
* const program = Effect.contextWith((services) => {
|
|
9789
|
+
* const cacheOption = Context.getOption(services, Cache)
|
|
9321
9790
|
* const hasCache = Option.isSome(cacheOption)
|
|
9322
9791
|
*
|
|
9323
9792
|
* if (hasCache) {
|
|
@@ -9342,7 +9811,7 @@ export declare const services: <R>() => Effect<ServiceMap.ServiceMap<R>, never,
|
|
|
9342
9811
|
* @since 2.0.0
|
|
9343
9812
|
* @category Environment
|
|
9344
9813
|
*/
|
|
9345
|
-
export declare const
|
|
9814
|
+
export declare const contextWith: <R, A, E, R2>(f: (context: Context.Context<R>) => Effect<A, E, R2>) => Effect<A, E, R | R2>;
|
|
9346
9815
|
/**
|
|
9347
9816
|
* Provides dependencies to an effect using layers or a context. Use `options.local`
|
|
9348
9817
|
* to build the layer every time; by default, layers are shared between provide
|
|
@@ -9350,16 +9819,16 @@ export declare const servicesWith: <R, A, E, R2>(f: (services: ServiceMap.Servic
|
|
|
9350
9819
|
*
|
|
9351
9820
|
* @example
|
|
9352
9821
|
* ```ts
|
|
9353
|
-
* import { Effect, Layer,
|
|
9822
|
+
* import { Effect, Layer, Context } from "effect"
|
|
9354
9823
|
*
|
|
9355
9824
|
* interface Database {
|
|
9356
9825
|
* readonly query: (sql: string) => Effect.Effect<string>
|
|
9357
9826
|
* }
|
|
9358
9827
|
*
|
|
9359
|
-
* const Database =
|
|
9828
|
+
* const Database = Context.Service<Database>("Database")
|
|
9360
9829
|
*
|
|
9361
9830
|
* const DatabaseLive = Layer.succeed(Database)({
|
|
9362
|
-
* query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
|
|
9831
|
+
* query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
|
|
9363
9832
|
* })
|
|
9364
9833
|
*
|
|
9365
9834
|
* const program = Effect.gen(function*() {
|
|
@@ -9384,16 +9853,16 @@ export declare const provide: {
|
|
|
9384
9853
|
*
|
|
9385
9854
|
* @example
|
|
9386
9855
|
* ```ts
|
|
9387
|
-
* import { Effect, Layer,
|
|
9856
|
+
* import { Effect, Layer, Context } from "effect"
|
|
9388
9857
|
*
|
|
9389
9858
|
* interface Database {
|
|
9390
9859
|
* readonly query: (sql: string) => Effect.Effect<string>
|
|
9391
9860
|
* }
|
|
9392
9861
|
*
|
|
9393
|
-
* const Database =
|
|
9862
|
+
* const Database = Context.Service<Database>("Database")
|
|
9394
9863
|
*
|
|
9395
9864
|
* const DatabaseLive = Layer.succeed(Database)({
|
|
9396
|
-
* query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
|
|
9865
|
+
* query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
|
|
9397
9866
|
* })
|
|
9398
9867
|
*
|
|
9399
9868
|
* const program = Effect.gen(function*() {
|
|
@@ -9420,16 +9889,16 @@ export declare const provide: {
|
|
|
9420
9889
|
*
|
|
9421
9890
|
* @example
|
|
9422
9891
|
* ```ts
|
|
9423
|
-
* import { Effect, Layer,
|
|
9892
|
+
* import { Effect, Layer, Context } from "effect"
|
|
9424
9893
|
*
|
|
9425
9894
|
* interface Database {
|
|
9426
9895
|
* readonly query: (sql: string) => Effect.Effect<string>
|
|
9427
9896
|
* }
|
|
9428
9897
|
*
|
|
9429
|
-
* const Database =
|
|
9898
|
+
* const Database = Context.Service<Database>("Database")
|
|
9430
9899
|
*
|
|
9431
9900
|
* const DatabaseLive = Layer.succeed(Database)({
|
|
9432
|
-
* query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
|
|
9901
|
+
* query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
|
|
9433
9902
|
* })
|
|
9434
9903
|
*
|
|
9435
9904
|
* const program = Effect.gen(function*() {
|
|
@@ -9456,16 +9925,16 @@ export declare const provide: {
|
|
|
9456
9925
|
*
|
|
9457
9926
|
* @example
|
|
9458
9927
|
* ```ts
|
|
9459
|
-
* import { Effect, Layer,
|
|
9928
|
+
* import { Effect, Layer, Context } from "effect"
|
|
9460
9929
|
*
|
|
9461
9930
|
* interface Database {
|
|
9462
9931
|
* readonly query: (sql: string) => Effect.Effect<string>
|
|
9463
9932
|
* }
|
|
9464
9933
|
*
|
|
9465
|
-
* const Database =
|
|
9934
|
+
* const Database = Context.Service<Database>("Database")
|
|
9466
9935
|
*
|
|
9467
9936
|
* const DatabaseLive = Layer.succeed(Database)({
|
|
9468
|
-
* query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
|
|
9937
|
+
* query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
|
|
9469
9938
|
* })
|
|
9470
9939
|
*
|
|
9471
9940
|
* const program = Effect.gen(function*() {
|
|
@@ -9482,7 +9951,7 @@ export declare const provide: {
|
|
|
9482
9951
|
* @since 2.0.0
|
|
9483
9952
|
* @category Environment
|
|
9484
9953
|
*/
|
|
9485
|
-
<R2>(context:
|
|
9954
|
+
<R2>(context: Context.Context<R2>): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, Exclude<R, R2>>;
|
|
9486
9955
|
/**
|
|
9487
9956
|
* Provides dependencies to an effect using layers or a context. Use `options.local`
|
|
9488
9957
|
* to build the layer every time; by default, layers are shared between provide
|
|
@@ -9490,16 +9959,16 @@ export declare const provide: {
|
|
|
9490
9959
|
*
|
|
9491
9960
|
* @example
|
|
9492
9961
|
* ```ts
|
|
9493
|
-
* import { Effect, Layer,
|
|
9962
|
+
* import { Effect, Layer, Context } from "effect"
|
|
9494
9963
|
*
|
|
9495
9964
|
* interface Database {
|
|
9496
9965
|
* readonly query: (sql: string) => Effect.Effect<string>
|
|
9497
9966
|
* }
|
|
9498
9967
|
*
|
|
9499
|
-
* const Database =
|
|
9968
|
+
* const Database = Context.Service<Database>("Database")
|
|
9500
9969
|
*
|
|
9501
9970
|
* const DatabaseLive = Layer.succeed(Database)({
|
|
9502
|
-
* query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
|
|
9971
|
+
* query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
|
|
9503
9972
|
* })
|
|
9504
9973
|
*
|
|
9505
9974
|
* const program = Effect.gen(function*() {
|
|
@@ -9526,16 +9995,16 @@ export declare const provide: {
|
|
|
9526
9995
|
*
|
|
9527
9996
|
* @example
|
|
9528
9997
|
* ```ts
|
|
9529
|
-
* import { Effect, Layer,
|
|
9998
|
+
* import { Effect, Layer, Context } from "effect"
|
|
9530
9999
|
*
|
|
9531
10000
|
* interface Database {
|
|
9532
10001
|
* readonly query: (sql: string) => Effect.Effect<string>
|
|
9533
10002
|
* }
|
|
9534
10003
|
*
|
|
9535
|
-
* const Database =
|
|
10004
|
+
* const Database = Context.Service<Database>("Database")
|
|
9536
10005
|
*
|
|
9537
10006
|
* const DatabaseLive = Layer.succeed(Database)({
|
|
9538
|
-
* query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
|
|
10007
|
+
* query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
|
|
9539
10008
|
* })
|
|
9540
10009
|
*
|
|
9541
10010
|
* const program = Effect.gen(function*() {
|
|
@@ -9562,16 +10031,16 @@ export declare const provide: {
|
|
|
9562
10031
|
*
|
|
9563
10032
|
* @example
|
|
9564
10033
|
* ```ts
|
|
9565
|
-
* import { Effect, Layer,
|
|
10034
|
+
* import { Effect, Layer, Context } from "effect"
|
|
9566
10035
|
*
|
|
9567
10036
|
* interface Database {
|
|
9568
10037
|
* readonly query: (sql: string) => Effect.Effect<string>
|
|
9569
10038
|
* }
|
|
9570
10039
|
*
|
|
9571
|
-
* const Database =
|
|
10040
|
+
* const Database = Context.Service<Database>("Database")
|
|
9572
10041
|
*
|
|
9573
10042
|
* const DatabaseLive = Layer.succeed(Database)({
|
|
9574
|
-
* query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
|
|
10043
|
+
* query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
|
|
9575
10044
|
* })
|
|
9576
10045
|
*
|
|
9577
10046
|
* const program = Effect.gen(function*() {
|
|
@@ -9588,32 +10057,32 @@ export declare const provide: {
|
|
|
9588
10057
|
* @since 2.0.0
|
|
9589
10058
|
* @category Environment
|
|
9590
10059
|
*/
|
|
9591
|
-
<A, E, R, R2>(self: Effect<A, E, R>, context:
|
|
10060
|
+
<A, E, R, R2>(self: Effect<A, E, R>, context: Context.Context<R2>): Effect<A, E, Exclude<R, R2>>;
|
|
9592
10061
|
};
|
|
9593
10062
|
/**
|
|
9594
|
-
* Provides a
|
|
10063
|
+
* Provides a context to an effect, fulfilling its service requirements.
|
|
9595
10064
|
*
|
|
9596
10065
|
* **Details**
|
|
9597
10066
|
*
|
|
9598
|
-
* This function provides multiple services at once by supplying a
|
|
10067
|
+
* This function provides multiple services at once by supplying a context
|
|
9599
10068
|
* that contains all the required services. It removes the provided services
|
|
9600
10069
|
* from the effect's requirements, making them available to the effect.
|
|
9601
10070
|
*
|
|
9602
10071
|
* @example
|
|
9603
10072
|
* ```ts
|
|
9604
|
-
* import { Effect,
|
|
10073
|
+
* import { Effect, Context } from "effect"
|
|
9605
10074
|
*
|
|
9606
10075
|
* // Define service keys
|
|
9607
|
-
* const Logger =
|
|
10076
|
+
* const Logger = Context.Service<{
|
|
9608
10077
|
* log: (msg: string) => void
|
|
9609
10078
|
* }>("Logger")
|
|
9610
|
-
* const Database =
|
|
10079
|
+
* const Database = Context.Service<{
|
|
9611
10080
|
* query: (sql: string) => string
|
|
9612
10081
|
* }>("Database")
|
|
9613
10082
|
*
|
|
9614
|
-
* // Create
|
|
9615
|
-
* const
|
|
9616
|
-
* .pipe(
|
|
10083
|
+
* // Create a context with multiple services
|
|
10084
|
+
* const context = Context.make(Logger, { log: console.log })
|
|
10085
|
+
* .pipe(Context.add(Database, { query: () => "result" }))
|
|
9617
10086
|
*
|
|
9618
10087
|
* // An effect that requires both services
|
|
9619
10088
|
* const program = Effect.gen(function*() {
|
|
@@ -9623,37 +10092,37 @@ export declare const provide: {
|
|
|
9623
10092
|
* return db.query("SELECT * FROM users")
|
|
9624
10093
|
* })
|
|
9625
10094
|
*
|
|
9626
|
-
* const provided = Effect.
|
|
10095
|
+
* const provided = Effect.provideContext(program, context)
|
|
9627
10096
|
* ```
|
|
9628
10097
|
*
|
|
9629
10098
|
* @since 2.0.0
|
|
9630
10099
|
* @category Environment
|
|
9631
10100
|
*/
|
|
9632
|
-
export declare const
|
|
10101
|
+
export declare const provideContext: {
|
|
9633
10102
|
/**
|
|
9634
|
-
* Provides a
|
|
10103
|
+
* Provides a context to an effect, fulfilling its service requirements.
|
|
9635
10104
|
*
|
|
9636
10105
|
* **Details**
|
|
9637
10106
|
*
|
|
9638
|
-
* This function provides multiple services at once by supplying a
|
|
10107
|
+
* This function provides multiple services at once by supplying a context
|
|
9639
10108
|
* that contains all the required services. It removes the provided services
|
|
9640
10109
|
* from the effect's requirements, making them available to the effect.
|
|
9641
10110
|
*
|
|
9642
10111
|
* @example
|
|
9643
10112
|
* ```ts
|
|
9644
|
-
* import { Effect,
|
|
10113
|
+
* import { Effect, Context } from "effect"
|
|
9645
10114
|
*
|
|
9646
10115
|
* // Define service keys
|
|
9647
|
-
* const Logger =
|
|
10116
|
+
* const Logger = Context.Service<{
|
|
9648
10117
|
* log: (msg: string) => void
|
|
9649
10118
|
* }>("Logger")
|
|
9650
|
-
* const Database =
|
|
10119
|
+
* const Database = Context.Service<{
|
|
9651
10120
|
* query: (sql: string) => string
|
|
9652
10121
|
* }>("Database")
|
|
9653
10122
|
*
|
|
9654
|
-
* // Create
|
|
9655
|
-
* const
|
|
9656
|
-
* .pipe(
|
|
10123
|
+
* // Create a context with multiple services
|
|
10124
|
+
* const context = Context.make(Logger, { log: console.log })
|
|
10125
|
+
* .pipe(Context.add(Database, { query: () => "result" }))
|
|
9657
10126
|
*
|
|
9658
10127
|
* // An effect that requires both services
|
|
9659
10128
|
* const program = Effect.gen(function*() {
|
|
@@ -9663,37 +10132,37 @@ export declare const provideServices: {
|
|
|
9663
10132
|
* return db.query("SELECT * FROM users")
|
|
9664
10133
|
* })
|
|
9665
10134
|
*
|
|
9666
|
-
* const provided = Effect.
|
|
10135
|
+
* const provided = Effect.provideContext(program, context)
|
|
9667
10136
|
* ```
|
|
9668
10137
|
*
|
|
9669
10138
|
* @since 2.0.0
|
|
9670
10139
|
* @category Environment
|
|
9671
10140
|
*/
|
|
9672
|
-
<XR>(context:
|
|
10141
|
+
<XR>(context: Context.Context<XR>): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, Exclude<R, XR>>;
|
|
9673
10142
|
/**
|
|
9674
|
-
* Provides a
|
|
10143
|
+
* Provides a context to an effect, fulfilling its service requirements.
|
|
9675
10144
|
*
|
|
9676
10145
|
* **Details**
|
|
9677
10146
|
*
|
|
9678
|
-
* This function provides multiple services at once by supplying a
|
|
10147
|
+
* This function provides multiple services at once by supplying a context
|
|
9679
10148
|
* that contains all the required services. It removes the provided services
|
|
9680
10149
|
* from the effect's requirements, making them available to the effect.
|
|
9681
10150
|
*
|
|
9682
10151
|
* @example
|
|
9683
10152
|
* ```ts
|
|
9684
|
-
* import { Effect,
|
|
10153
|
+
* import { Effect, Context } from "effect"
|
|
9685
10154
|
*
|
|
9686
10155
|
* // Define service keys
|
|
9687
|
-
* const Logger =
|
|
10156
|
+
* const Logger = Context.Service<{
|
|
9688
10157
|
* log: (msg: string) => void
|
|
9689
10158
|
* }>("Logger")
|
|
9690
|
-
* const Database =
|
|
10159
|
+
* const Database = Context.Service<{
|
|
9691
10160
|
* query: (sql: string) => string
|
|
9692
10161
|
* }>("Database")
|
|
9693
10162
|
*
|
|
9694
|
-
* // Create
|
|
9695
|
-
* const
|
|
9696
|
-
* .pipe(
|
|
10163
|
+
* // Create a context with multiple services
|
|
10164
|
+
* const context = Context.make(Logger, { log: console.log })
|
|
10165
|
+
* .pipe(Context.add(Database, { query: () => "result" }))
|
|
9697
10166
|
*
|
|
9698
10167
|
* // An effect that requires both services
|
|
9699
10168
|
* const program = Effect.gen(function*() {
|
|
@@ -9703,26 +10172,26 @@ export declare const provideServices: {
|
|
|
9703
10172
|
* return db.query("SELECT * FROM users")
|
|
9704
10173
|
* })
|
|
9705
10174
|
*
|
|
9706
|
-
* const provided = Effect.
|
|
10175
|
+
* const provided = Effect.provideContext(program, context)
|
|
9707
10176
|
* ```
|
|
9708
10177
|
*
|
|
9709
10178
|
* @since 2.0.0
|
|
9710
10179
|
* @category Environment
|
|
9711
10180
|
*/
|
|
9712
|
-
<A, E, R, XR>(self: Effect<A, E, R>, context:
|
|
10181
|
+
<A, E, R, XR>(self: Effect<A, E, R>, context: Context.Context<XR>): Effect<A, E, Exclude<R, XR>>;
|
|
9713
10182
|
};
|
|
9714
10183
|
/**
|
|
9715
10184
|
* Accesses a service from the context.
|
|
9716
10185
|
*
|
|
9717
10186
|
* @example
|
|
9718
10187
|
* ```ts
|
|
9719
|
-
* import { Effect,
|
|
10188
|
+
* import { Effect, Context } from "effect"
|
|
9720
10189
|
*
|
|
9721
10190
|
* interface Database {
|
|
9722
10191
|
* readonly query: (sql: string) => Effect.Effect<string>
|
|
9723
10192
|
* }
|
|
9724
10193
|
*
|
|
9725
|
-
* const Database =
|
|
10194
|
+
* const Database = Context.Service<Database>("Database")
|
|
9726
10195
|
*
|
|
9727
10196
|
* const program = Effect.gen(function*() {
|
|
9728
10197
|
* const db = yield* Effect.service(Database)
|
|
@@ -9731,9 +10200,9 @@ export declare const provideServices: {
|
|
|
9731
10200
|
* ```
|
|
9732
10201
|
*
|
|
9733
10202
|
* @since 4.0.0
|
|
9734
|
-
* @category
|
|
10203
|
+
* @category Context
|
|
9735
10204
|
*/
|
|
9736
|
-
export declare const service: <I, S>(service:
|
|
10205
|
+
export declare const service: <I, S>(service: Context.Key<I, S>) => Effect<S, never, I>;
|
|
9737
10206
|
/**
|
|
9738
10207
|
* Optionally accesses a service from the environment.
|
|
9739
10208
|
*
|
|
@@ -9746,10 +10215,10 @@ export declare const service: <I, S>(service: ServiceMap.Service<I, S>) => Effec
|
|
|
9746
10215
|
*
|
|
9747
10216
|
* @example
|
|
9748
10217
|
* ```ts
|
|
9749
|
-
* import { Effect, Option,
|
|
10218
|
+
* import { Effect, Option, Context } from "effect"
|
|
9750
10219
|
*
|
|
9751
10220
|
* // Define a service key
|
|
9752
|
-
* const Logger =
|
|
10221
|
+
* const Logger = Context.Service<{
|
|
9753
10222
|
* log: (msg: string) => void
|
|
9754
10223
|
* }>("Logger")
|
|
9755
10224
|
*
|
|
@@ -9766,9 +10235,9 @@ export declare const service: <I, S>(service: ServiceMap.Service<I, S>) => Effec
|
|
|
9766
10235
|
* ```
|
|
9767
10236
|
*
|
|
9768
10237
|
* @since 2.0.0
|
|
9769
|
-
* @category
|
|
10238
|
+
* @category Context
|
|
9770
10239
|
*/
|
|
9771
|
-
export declare const serviceOption: <I, S>(key:
|
|
10240
|
+
export declare const serviceOption: <I, S>(key: Context.Key<I, S>) => Effect<Option<S>>;
|
|
9772
10241
|
/**
|
|
9773
10242
|
* Provides part of the required context while leaving the rest unchanged.
|
|
9774
10243
|
*
|
|
@@ -9779,13 +10248,13 @@ export declare const serviceOption: <I, S>(key: ServiceMap.Service<I, S>) => Eff
|
|
|
9779
10248
|
*
|
|
9780
10249
|
* @example
|
|
9781
10250
|
* ```ts
|
|
9782
|
-
* import { Effect,
|
|
10251
|
+
* import { Effect, Context } from "effect"
|
|
9783
10252
|
*
|
|
9784
10253
|
* // Define services
|
|
9785
|
-
* const Logger =
|
|
10254
|
+
* const Logger = Context.Service<{
|
|
9786
10255
|
* log: (msg: string) => void
|
|
9787
10256
|
* }>("Logger")
|
|
9788
|
-
* const Config =
|
|
10257
|
+
* const Config = Context.Service<{
|
|
9789
10258
|
* name: string
|
|
9790
10259
|
* }>("Config")
|
|
9791
10260
|
*
|
|
@@ -9795,8 +10264,8 @@ export declare const serviceOption: <I, S>(key: ServiceMap.Service<I, S>) => Eff
|
|
|
9795
10264
|
*
|
|
9796
10265
|
* // Transform services by providing Config while keeping Logger requirement
|
|
9797
10266
|
* const configured = program.pipe(
|
|
9798
|
-
* Effect.
|
|
9799
|
-
*
|
|
10267
|
+
* Effect.updateContext((context: Context.Context<typeof Logger>) =>
|
|
10268
|
+
* Context.add(context, Config, { name: "World" })
|
|
9800
10269
|
* )
|
|
9801
10270
|
* )
|
|
9802
10271
|
*
|
|
@@ -9807,9 +10276,9 @@ export declare const serviceOption: <I, S>(key: ServiceMap.Service<I, S>) => Eff
|
|
|
9807
10276
|
* ```
|
|
9808
10277
|
*
|
|
9809
10278
|
* @since 4.0.0
|
|
9810
|
-
* @category
|
|
10279
|
+
* @category Context
|
|
9811
10280
|
*/
|
|
9812
|
-
export declare const
|
|
10281
|
+
export declare const updateContext: {
|
|
9813
10282
|
/**
|
|
9814
10283
|
* Provides part of the required context while leaving the rest unchanged.
|
|
9815
10284
|
*
|
|
@@ -9820,13 +10289,13 @@ export declare const updateServices: {
|
|
|
9820
10289
|
*
|
|
9821
10290
|
* @example
|
|
9822
10291
|
* ```ts
|
|
9823
|
-
* import { Effect,
|
|
10292
|
+
* import { Effect, Context } from "effect"
|
|
9824
10293
|
*
|
|
9825
10294
|
* // Define services
|
|
9826
|
-
* const Logger =
|
|
10295
|
+
* const Logger = Context.Service<{
|
|
9827
10296
|
* log: (msg: string) => void
|
|
9828
10297
|
* }>("Logger")
|
|
9829
|
-
* const Config =
|
|
10298
|
+
* const Config = Context.Service<{
|
|
9830
10299
|
* name: string
|
|
9831
10300
|
* }>("Config")
|
|
9832
10301
|
*
|
|
@@ -9836,8 +10305,8 @@ export declare const updateServices: {
|
|
|
9836
10305
|
*
|
|
9837
10306
|
* // Transform services by providing Config while keeping Logger requirement
|
|
9838
10307
|
* const configured = program.pipe(
|
|
9839
|
-
* Effect.
|
|
9840
|
-
*
|
|
10308
|
+
* Effect.updateContext((context: Context.Context<typeof Logger>) =>
|
|
10309
|
+
* Context.add(context, Config, { name: "World" })
|
|
9841
10310
|
* )
|
|
9842
10311
|
* )
|
|
9843
10312
|
*
|
|
@@ -9848,9 +10317,9 @@ export declare const updateServices: {
|
|
|
9848
10317
|
* ```
|
|
9849
10318
|
*
|
|
9850
10319
|
* @since 4.0.0
|
|
9851
|
-
* @category
|
|
10320
|
+
* @category Context
|
|
9852
10321
|
*/
|
|
9853
|
-
<R2, R>(f: (
|
|
10322
|
+
<R2, R>(f: (context: Context.Context<R2>) => Context.Context<NoInfer<R>>): <A, E>(self: Effect<A, E, R>) => Effect<A, E, R2>;
|
|
9854
10323
|
/**
|
|
9855
10324
|
* Provides part of the required context while leaving the rest unchanged.
|
|
9856
10325
|
*
|
|
@@ -9861,13 +10330,13 @@ export declare const updateServices: {
|
|
|
9861
10330
|
*
|
|
9862
10331
|
* @example
|
|
9863
10332
|
* ```ts
|
|
9864
|
-
* import { Effect,
|
|
10333
|
+
* import { Effect, Context } from "effect"
|
|
9865
10334
|
*
|
|
9866
10335
|
* // Define services
|
|
9867
|
-
* const Logger =
|
|
10336
|
+
* const Logger = Context.Service<{
|
|
9868
10337
|
* log: (msg: string) => void
|
|
9869
10338
|
* }>("Logger")
|
|
9870
|
-
* const Config =
|
|
10339
|
+
* const Config = Context.Service<{
|
|
9871
10340
|
* name: string
|
|
9872
10341
|
* }>("Config")
|
|
9873
10342
|
*
|
|
@@ -9877,8 +10346,8 @@ export declare const updateServices: {
|
|
|
9877
10346
|
*
|
|
9878
10347
|
* // Transform services by providing Config while keeping Logger requirement
|
|
9879
10348
|
* const configured = program.pipe(
|
|
9880
|
-
* Effect.
|
|
9881
|
-
*
|
|
10349
|
+
* Effect.updateContext((context: Context.Context<typeof Logger>) =>
|
|
10350
|
+
* Context.add(context, Config, { name: "World" })
|
|
9882
10351
|
* )
|
|
9883
10352
|
* )
|
|
9884
10353
|
*
|
|
@@ -9889,19 +10358,19 @@ export declare const updateServices: {
|
|
|
9889
10358
|
* ```
|
|
9890
10359
|
*
|
|
9891
10360
|
* @since 4.0.0
|
|
9892
|
-
* @category
|
|
10361
|
+
* @category Context
|
|
9893
10362
|
*/
|
|
9894
|
-
<A, E, R, R2>(self: Effect<A, E, R>, f: (
|
|
10363
|
+
<A, E, R, R2>(self: Effect<A, E, R>, f: (context: Context.Context<R2>) => Context.Context<NoInfer<R>>): Effect<A, E, R2>;
|
|
9895
10364
|
};
|
|
9896
10365
|
/**
|
|
9897
10366
|
* Updates the service with the required service entry.
|
|
9898
10367
|
*
|
|
9899
10368
|
* @example
|
|
9900
10369
|
* ```ts
|
|
9901
|
-
* import { Console, Effect,
|
|
10370
|
+
* import { Console, Effect, Context } from "effect"
|
|
9902
10371
|
*
|
|
9903
10372
|
* // Define a counter service
|
|
9904
|
-
* const Counter =
|
|
10373
|
+
* const Counter = Context.Service<{ count: number }>("Counter")
|
|
9905
10374
|
*
|
|
9906
10375
|
* const program = Effect.gen(function*() {
|
|
9907
10376
|
* const updatedCounter = yield* Effect.service(Counter)
|
|
@@ -9919,7 +10388,7 @@ export declare const updateServices: {
|
|
|
9919
10388
|
* ```
|
|
9920
10389
|
*
|
|
9921
10390
|
* @since 2.0.0
|
|
9922
|
-
* @category
|
|
10391
|
+
* @category Context
|
|
9923
10392
|
*/
|
|
9924
10393
|
export declare const updateService: {
|
|
9925
10394
|
/**
|
|
@@ -9927,10 +10396,10 @@ export declare const updateService: {
|
|
|
9927
10396
|
*
|
|
9928
10397
|
* @example
|
|
9929
10398
|
* ```ts
|
|
9930
|
-
* import { Console, Effect,
|
|
10399
|
+
* import { Console, Effect, Context } from "effect"
|
|
9931
10400
|
*
|
|
9932
10401
|
* // Define a counter service
|
|
9933
|
-
* const Counter =
|
|
10402
|
+
* const Counter = Context.Service<{ count: number }>("Counter")
|
|
9934
10403
|
*
|
|
9935
10404
|
* const program = Effect.gen(function*() {
|
|
9936
10405
|
* const updatedCounter = yield* Effect.service(Counter)
|
|
@@ -9948,18 +10417,18 @@ export declare const updateService: {
|
|
|
9948
10417
|
* ```
|
|
9949
10418
|
*
|
|
9950
10419
|
* @since 2.0.0
|
|
9951
|
-
* @category
|
|
10420
|
+
* @category Context
|
|
9952
10421
|
*/
|
|
9953
|
-
<I, A>(service:
|
|
10422
|
+
<I, A>(service: Context.Key<I, A>, f: (value: A) => A): <XA, E, R>(self: Effect<XA, E, R>) => Effect<XA, E, R | I>;
|
|
9954
10423
|
/**
|
|
9955
10424
|
* Updates the service with the required service entry.
|
|
9956
10425
|
*
|
|
9957
10426
|
* @example
|
|
9958
10427
|
* ```ts
|
|
9959
|
-
* import { Console, Effect,
|
|
10428
|
+
* import { Console, Effect, Context } from "effect"
|
|
9960
10429
|
*
|
|
9961
10430
|
* // Define a counter service
|
|
9962
|
-
* const Counter =
|
|
10431
|
+
* const Counter = Context.Service<{ count: number }>("Counter")
|
|
9963
10432
|
*
|
|
9964
10433
|
* const program = Effect.gen(function*() {
|
|
9965
10434
|
* const updatedCounter = yield* Effect.service(Counter)
|
|
@@ -9977,9 +10446,9 @@ export declare const updateService: {
|
|
|
9977
10446
|
* ```
|
|
9978
10447
|
*
|
|
9979
10448
|
* @since 2.0.0
|
|
9980
|
-
* @category
|
|
10449
|
+
* @category Context
|
|
9981
10450
|
*/
|
|
9982
|
-
<XA, E, R, I, A>(self: Effect<XA, E, R>, service:
|
|
10451
|
+
<XA, E, R, I, A>(self: Effect<XA, E, R>, service: Context.Key<I, A>, f: (value: A) => A): Effect<XA, E, R | I>;
|
|
9983
10452
|
};
|
|
9984
10453
|
/**
|
|
9985
10454
|
* The `provideService` function is used to provide an actual
|
|
@@ -9995,10 +10464,10 @@ export declare const updateService: {
|
|
|
9995
10464
|
*
|
|
9996
10465
|
* @example
|
|
9997
10466
|
* ```ts
|
|
9998
|
-
* import { Console, Effect,
|
|
10467
|
+
* import { Console, Effect, Context } from "effect"
|
|
9999
10468
|
*
|
|
10000
10469
|
* // Define a service for configuration
|
|
10001
|
-
* const Config =
|
|
10470
|
+
* const Config = Context.Service<{
|
|
10002
10471
|
* apiUrl: string
|
|
10003
10472
|
* timeout: number
|
|
10004
10473
|
* }>("Config")
|
|
@@ -10024,7 +10493,7 @@ export declare const updateService: {
|
|
|
10024
10493
|
* ```
|
|
10025
10494
|
*
|
|
10026
10495
|
* @since 2.0.0
|
|
10027
|
-
* @category
|
|
10496
|
+
* @category Context
|
|
10028
10497
|
*/
|
|
10029
10498
|
export declare const provideService: {
|
|
10030
10499
|
/**
|
|
@@ -10041,10 +10510,10 @@ export declare const provideService: {
|
|
|
10041
10510
|
*
|
|
10042
10511
|
* @example
|
|
10043
10512
|
* ```ts
|
|
10044
|
-
* import { Console, Effect,
|
|
10513
|
+
* import { Console, Effect, Context } from "effect"
|
|
10045
10514
|
*
|
|
10046
10515
|
* // Define a service for configuration
|
|
10047
|
-
* const Config =
|
|
10516
|
+
* const Config = Context.Service<{
|
|
10048
10517
|
* apiUrl: string
|
|
10049
10518
|
* timeout: number
|
|
10050
10519
|
* }>("Config")
|
|
@@ -10070,9 +10539,9 @@ export declare const provideService: {
|
|
|
10070
10539
|
* ```
|
|
10071
10540
|
*
|
|
10072
10541
|
* @since 2.0.0
|
|
10073
|
-
* @category
|
|
10542
|
+
* @category Context
|
|
10074
10543
|
*/
|
|
10075
|
-
<I, S>(service:
|
|
10544
|
+
<I, S>(service: Context.Key<I, S>): {
|
|
10076
10545
|
/**
|
|
10077
10546
|
* The `provideService` function is used to provide an actual
|
|
10078
10547
|
* implementation for a service in the context of an effect.
|
|
@@ -10087,10 +10556,10 @@ export declare const provideService: {
|
|
|
10087
10556
|
*
|
|
10088
10557
|
* @example
|
|
10089
10558
|
* ```ts
|
|
10090
|
-
* import { Console, Effect,
|
|
10559
|
+
* import { Console, Effect, Context } from "effect"
|
|
10091
10560
|
*
|
|
10092
10561
|
* // Define a service for configuration
|
|
10093
|
-
* const Config =
|
|
10562
|
+
* const Config = Context.Service<{
|
|
10094
10563
|
* apiUrl: string
|
|
10095
10564
|
* timeout: number
|
|
10096
10565
|
* }>("Config")
|
|
@@ -10116,7 +10585,7 @@ export declare const provideService: {
|
|
|
10116
10585
|
* ```
|
|
10117
10586
|
*
|
|
10118
10587
|
* @since 2.0.0
|
|
10119
|
-
* @category
|
|
10588
|
+
* @category Context
|
|
10120
10589
|
*/
|
|
10121
10590
|
(implementation: S): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, Exclude<R, I>>;
|
|
10122
10591
|
/**
|
|
@@ -10133,10 +10602,10 @@ export declare const provideService: {
|
|
|
10133
10602
|
*
|
|
10134
10603
|
* @example
|
|
10135
10604
|
* ```ts
|
|
10136
|
-
* import { Console, Effect,
|
|
10605
|
+
* import { Console, Effect, Context } from "effect"
|
|
10137
10606
|
*
|
|
10138
10607
|
* // Define a service for configuration
|
|
10139
|
-
* const Config =
|
|
10608
|
+
* const Config = Context.Service<{
|
|
10140
10609
|
* apiUrl: string
|
|
10141
10610
|
* timeout: number
|
|
10142
10611
|
* }>("Config")
|
|
@@ -10162,7 +10631,7 @@ export declare const provideService: {
|
|
|
10162
10631
|
* ```
|
|
10163
10632
|
*
|
|
10164
10633
|
* @since 2.0.0
|
|
10165
|
-
* @category
|
|
10634
|
+
* @category Context
|
|
10166
10635
|
*/
|
|
10167
10636
|
<A, E, R>(self: Effect<A, E, R>, implementation: S): Effect<A, E, Exclude<R, I>>;
|
|
10168
10637
|
};
|
|
@@ -10180,10 +10649,10 @@ export declare const provideService: {
|
|
|
10180
10649
|
*
|
|
10181
10650
|
* @example
|
|
10182
10651
|
* ```ts
|
|
10183
|
-
* import { Console, Effect,
|
|
10652
|
+
* import { Console, Effect, Context } from "effect"
|
|
10184
10653
|
*
|
|
10185
10654
|
* // Define a service for configuration
|
|
10186
|
-
* const Config =
|
|
10655
|
+
* const Config = Context.Service<{
|
|
10187
10656
|
* apiUrl: string
|
|
10188
10657
|
* timeout: number
|
|
10189
10658
|
* }>("Config")
|
|
@@ -10209,9 +10678,9 @@ export declare const provideService: {
|
|
|
10209
10678
|
* ```
|
|
10210
10679
|
*
|
|
10211
10680
|
* @since 2.0.0
|
|
10212
|
-
* @category
|
|
10681
|
+
* @category Context
|
|
10213
10682
|
*/
|
|
10214
|
-
<I, S>(service:
|
|
10683
|
+
<I, S>(service: Context.Key<I, S>, implementation: S): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, Exclude<R, I>>;
|
|
10215
10684
|
/**
|
|
10216
10685
|
* The `provideService` function is used to provide an actual
|
|
10217
10686
|
* implementation for a service in the context of an effect.
|
|
@@ -10226,10 +10695,10 @@ export declare const provideService: {
|
|
|
10226
10695
|
*
|
|
10227
10696
|
* @example
|
|
10228
10697
|
* ```ts
|
|
10229
|
-
* import { Console, Effect,
|
|
10698
|
+
* import { Console, Effect, Context } from "effect"
|
|
10230
10699
|
*
|
|
10231
10700
|
* // Define a service for configuration
|
|
10232
|
-
* const Config =
|
|
10701
|
+
* const Config = Context.Service<{
|
|
10233
10702
|
* apiUrl: string
|
|
10234
10703
|
* timeout: number
|
|
10235
10704
|
* }>("Config")
|
|
@@ -10255,9 +10724,9 @@ export declare const provideService: {
|
|
|
10255
10724
|
* ```
|
|
10256
10725
|
*
|
|
10257
10726
|
* @since 2.0.0
|
|
10258
|
-
* @category
|
|
10727
|
+
* @category Context
|
|
10259
10728
|
*/
|
|
10260
|
-
<A, E, R, I, S>(self: Effect<A, E, R>, service:
|
|
10729
|
+
<A, E, R, I, S>(self: Effect<A, E, R>, service: Context.Key<I, S>, implementation: S): Effect<A, E, Exclude<R, I>>;
|
|
10261
10730
|
};
|
|
10262
10731
|
/**
|
|
10263
10732
|
* Provides the effect with the single service it requires. If the effect
|
|
@@ -10271,13 +10740,13 @@ export declare const provideService: {
|
|
|
10271
10740
|
*
|
|
10272
10741
|
* @example
|
|
10273
10742
|
* ```ts
|
|
10274
|
-
* import { Console, Effect,
|
|
10743
|
+
* import { Console, Effect, Context } from "effect"
|
|
10275
10744
|
*
|
|
10276
10745
|
* // Define a database connection service
|
|
10277
10746
|
* interface DatabaseConnection {
|
|
10278
10747
|
* readonly query: (sql: string) => Effect.Effect<string>
|
|
10279
10748
|
* }
|
|
10280
|
-
* const Database =
|
|
10749
|
+
* const Database = Context.Service<DatabaseConnection>("Database")
|
|
10281
10750
|
*
|
|
10282
10751
|
* // Effect that creates a database connection
|
|
10283
10752
|
* const createConnection = Effect.gen(function*() {
|
|
@@ -10309,7 +10778,7 @@ export declare const provideService: {
|
|
|
10309
10778
|
* ```
|
|
10310
10779
|
*
|
|
10311
10780
|
* @since 2.0.0
|
|
10312
|
-
* @category
|
|
10781
|
+
* @category Context
|
|
10313
10782
|
*/
|
|
10314
10783
|
export declare const provideServiceEffect: {
|
|
10315
10784
|
/**
|
|
@@ -10324,13 +10793,13 @@ export declare const provideServiceEffect: {
|
|
|
10324
10793
|
*
|
|
10325
10794
|
* @example
|
|
10326
10795
|
* ```ts
|
|
10327
|
-
* import { Console, Effect,
|
|
10796
|
+
* import { Console, Effect, Context } from "effect"
|
|
10328
10797
|
*
|
|
10329
10798
|
* // Define a database connection service
|
|
10330
10799
|
* interface DatabaseConnection {
|
|
10331
10800
|
* readonly query: (sql: string) => Effect.Effect<string>
|
|
10332
10801
|
* }
|
|
10333
|
-
* const Database =
|
|
10802
|
+
* const Database = Context.Service<DatabaseConnection>("Database")
|
|
10334
10803
|
*
|
|
10335
10804
|
* // Effect that creates a database connection
|
|
10336
10805
|
* const createConnection = Effect.gen(function*() {
|
|
@@ -10362,9 +10831,9 @@ export declare const provideServiceEffect: {
|
|
|
10362
10831
|
* ```
|
|
10363
10832
|
*
|
|
10364
10833
|
* @since 2.0.0
|
|
10365
|
-
* @category
|
|
10834
|
+
* @category Context
|
|
10366
10835
|
*/
|
|
10367
|
-
<I, S, E2, R2>(service:
|
|
10836
|
+
<I, S, E2, R2>(service: Context.Key<I, S>, acquire: Effect<S, E2, R2>): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E | E2, Exclude<R, I> | R2>;
|
|
10368
10837
|
/**
|
|
10369
10838
|
* Provides the effect with the single service it requires. If the effect
|
|
10370
10839
|
* requires more than one service use `provide` instead.
|
|
@@ -10377,13 +10846,13 @@ export declare const provideServiceEffect: {
|
|
|
10377
10846
|
*
|
|
10378
10847
|
* @example
|
|
10379
10848
|
* ```ts
|
|
10380
|
-
* import { Console, Effect,
|
|
10849
|
+
* import { Console, Effect, Context } from "effect"
|
|
10381
10850
|
*
|
|
10382
10851
|
* // Define a database connection service
|
|
10383
10852
|
* interface DatabaseConnection {
|
|
10384
10853
|
* readonly query: (sql: string) => Effect.Effect<string>
|
|
10385
10854
|
* }
|
|
10386
|
-
* const Database =
|
|
10855
|
+
* const Database = Context.Service<DatabaseConnection>("Database")
|
|
10387
10856
|
*
|
|
10388
10857
|
* // Effect that creates a database connection
|
|
10389
10858
|
* const createConnection = Effect.gen(function*() {
|
|
@@ -10415,9 +10884,9 @@ export declare const provideServiceEffect: {
|
|
|
10415
10884
|
* ```
|
|
10416
10885
|
*
|
|
10417
10886
|
* @since 2.0.0
|
|
10418
|
-
* @category
|
|
10887
|
+
* @category Context
|
|
10419
10888
|
*/
|
|
10420
|
-
<A, E, R, I, S, E2, R2>(self: Effect<A, E, R>, service:
|
|
10889
|
+
<A, E, R, I, S, E2, R2>(self: Effect<A, E, R>, service: Context.Key<I, S>, acquire: Effect<S, E2, R2>): Effect<A, E | E2, Exclude<R, I> | R2>;
|
|
10421
10890
|
};
|
|
10422
10891
|
/**
|
|
10423
10892
|
* Sets the concurrency level for parallel operations within an effect.
|
|
@@ -10672,7 +11141,9 @@ export declare const scopedWith: <A, E, R>(f: (scope: Scope) => Effect<A, E, R>)
|
|
|
10672
11141
|
* @since 2.0.0
|
|
10673
11142
|
* @category Resource Management & Finalization
|
|
10674
11143
|
*/
|
|
10675
|
-
export declare const acquireRelease: <A, E, R>(acquire: Effect<A, E, R>, release: (a: A, exit: Exit.Exit<unknown, unknown>) => Effect<unknown
|
|
11144
|
+
export declare const acquireRelease: <A, E, R, R2>(acquire: Effect<A, E, R>, release: (a: A, exit: Exit.Exit<unknown, unknown>) => Effect<unknown, never, R2>, options?: {
|
|
11145
|
+
readonly interruptible?: boolean;
|
|
11146
|
+
}) => Effect<A, E, R | R2 | Scope>;
|
|
10676
11147
|
/**
|
|
10677
11148
|
* This function is used to ensure that an `Effect` value that represents the
|
|
10678
11149
|
* acquisition of a resource (for example, opening a file, launching a thread,
|
|
@@ -10914,9 +11385,11 @@ export declare const ensuring: {
|
|
|
10914
11385
|
*
|
|
10915
11386
|
* @example
|
|
10916
11387
|
* ```ts
|
|
10917
|
-
* import { Cause, Console, Effect } from "effect"
|
|
11388
|
+
* import { Cause, Data, Console, Effect } from "effect"
|
|
10918
11389
|
*
|
|
10919
|
-
*
|
|
11390
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
11391
|
+
*
|
|
11392
|
+
* const task = Effect.fail(new TaskError({ message: "Something went wrong" }))
|
|
10920
11393
|
*
|
|
10921
11394
|
* const program = Effect.onError(
|
|
10922
11395
|
* task,
|
|
@@ -10925,8 +11398,8 @@ export declare const ensuring: {
|
|
|
10925
11398
|
*
|
|
10926
11399
|
* Effect.runPromise(program).catch(console.error)
|
|
10927
11400
|
* // Output:
|
|
10928
|
-
* // Cleanup on error:
|
|
10929
|
-
* //
|
|
11401
|
+
* // Cleanup on error: TaskError: Something went wrong
|
|
11402
|
+
* // TaskError: Something went wrong
|
|
10930
11403
|
* ```
|
|
10931
11404
|
*
|
|
10932
11405
|
* @since 2.0.0
|
|
@@ -10939,9 +11412,11 @@ export declare const onError: {
|
|
|
10939
11412
|
*
|
|
10940
11413
|
* @example
|
|
10941
11414
|
* ```ts
|
|
10942
|
-
* import { Cause, Console, Effect } from "effect"
|
|
11415
|
+
* import { Cause, Data, Console, Effect } from "effect"
|
|
10943
11416
|
*
|
|
10944
|
-
*
|
|
11417
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
11418
|
+
*
|
|
11419
|
+
* const task = Effect.fail(new TaskError({ message: "Something went wrong" }))
|
|
10945
11420
|
*
|
|
10946
11421
|
* const program = Effect.onError(
|
|
10947
11422
|
* task,
|
|
@@ -10950,8 +11425,8 @@ export declare const onError: {
|
|
|
10950
11425
|
*
|
|
10951
11426
|
* Effect.runPromise(program).catch(console.error)
|
|
10952
11427
|
* // Output:
|
|
10953
|
-
* // Cleanup on error:
|
|
10954
|
-
* //
|
|
11428
|
+
* // Cleanup on error: TaskError: Something went wrong
|
|
11429
|
+
* // TaskError: Something went wrong
|
|
10955
11430
|
* ```
|
|
10956
11431
|
*
|
|
10957
11432
|
* @since 2.0.0
|
|
@@ -10964,9 +11439,11 @@ export declare const onError: {
|
|
|
10964
11439
|
*
|
|
10965
11440
|
* @example
|
|
10966
11441
|
* ```ts
|
|
10967
|
-
* import { Cause, Console, Effect } from "effect"
|
|
11442
|
+
* import { Cause, Data, Console, Effect } from "effect"
|
|
10968
11443
|
*
|
|
10969
|
-
*
|
|
11444
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
11445
|
+
*
|
|
11446
|
+
* const task = Effect.fail(new TaskError({ message: "Something went wrong" }))
|
|
10970
11447
|
*
|
|
10971
11448
|
* const program = Effect.onError(
|
|
10972
11449
|
* task,
|
|
@@ -10975,8 +11452,8 @@ export declare const onError: {
|
|
|
10975
11452
|
*
|
|
10976
11453
|
* Effect.runPromise(program).catch(console.error)
|
|
10977
11454
|
* // Output:
|
|
10978
|
-
* // Cleanup on error:
|
|
10979
|
-
* //
|
|
11455
|
+
* // Cleanup on error: TaskError: Something went wrong
|
|
11456
|
+
* // TaskError: Something went wrong
|
|
10980
11457
|
* ```
|
|
10981
11458
|
*
|
|
10982
11459
|
* @since 2.0.0
|
|
@@ -10986,7 +11463,7 @@ export declare const onError: {
|
|
|
10986
11463
|
};
|
|
10987
11464
|
/**
|
|
10988
11465
|
* Runs the finalizer only when this effect fails and the `Cause` matches the
|
|
10989
|
-
*
|
|
11466
|
+
* provided predicate.
|
|
10990
11467
|
*
|
|
10991
11468
|
* @example
|
|
10992
11469
|
* ```ts
|
|
@@ -11010,7 +11487,7 @@ export declare const onError: {
|
|
|
11010
11487
|
export declare const onErrorIf: {
|
|
11011
11488
|
/**
|
|
11012
11489
|
* Runs the finalizer only when this effect fails and the `Cause` matches the
|
|
11013
|
-
*
|
|
11490
|
+
* provided predicate.
|
|
11014
11491
|
*
|
|
11015
11492
|
* @example
|
|
11016
11493
|
* ```ts
|
|
@@ -11031,10 +11508,10 @@ export declare const onErrorIf: {
|
|
|
11031
11508
|
* @since 4.0.0
|
|
11032
11509
|
* @category Resource Management & Finalization
|
|
11033
11510
|
*/
|
|
11034
|
-
<E,
|
|
11511
|
+
<E, XE, XR>(predicate: Predicate.Predicate<Cause.Cause<E>>, f: (cause: Cause.Cause<E>) => Effect<void, XE, XR>): <A, R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>;
|
|
11035
11512
|
/**
|
|
11036
11513
|
* Runs the finalizer only when this effect fails and the `Cause` matches the
|
|
11037
|
-
*
|
|
11514
|
+
* provided predicate.
|
|
11038
11515
|
*
|
|
11039
11516
|
* @example
|
|
11040
11517
|
* ```ts
|
|
@@ -11055,7 +11532,29 @@ export declare const onErrorIf: {
|
|
|
11055
11532
|
* @since 4.0.0
|
|
11056
11533
|
* @category Resource Management & Finalization
|
|
11057
11534
|
*/
|
|
11058
|
-
<A, E, R, XE, XR
|
|
11535
|
+
<A, E, R, XE, XR>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Cause.Cause<E>>, f: (cause: Cause.Cause<E>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>;
|
|
11536
|
+
};
|
|
11537
|
+
/**
|
|
11538
|
+
* Runs the finalizer only when this effect fails and the cause matches the provided `Filter`.
|
|
11539
|
+
*
|
|
11540
|
+
* @since 4.0.0
|
|
11541
|
+
* @category Resource Management & Finalization
|
|
11542
|
+
*/
|
|
11543
|
+
export declare const onErrorFilter: {
|
|
11544
|
+
/**
|
|
11545
|
+
* Runs the finalizer only when this effect fails and the cause matches the provided `Filter`.
|
|
11546
|
+
*
|
|
11547
|
+
* @since 4.0.0
|
|
11548
|
+
* @category Resource Management & Finalization
|
|
11549
|
+
*/
|
|
11550
|
+
<A, E, EB, X, XE, XR>(filter: Filter.Filter<Cause.Cause<E>, EB, X>, f: (failure: EB, cause: Cause.Cause<E>) => Effect<void, XE, XR>): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>;
|
|
11551
|
+
/**
|
|
11552
|
+
* Runs the finalizer only when this effect fails and the cause matches the provided `Filter`.
|
|
11553
|
+
*
|
|
11554
|
+
* @since 4.0.0
|
|
11555
|
+
* @category Resource Management & Finalization
|
|
11556
|
+
*/
|
|
11557
|
+
<A, E, R, EB, X, XE, XR>(self: Effect<A, E, R>, filter: Filter.Filter<Cause.Cause<E>, EB, X>, f: (failure: EB, cause: Cause.Cause<E>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>;
|
|
11059
11558
|
};
|
|
11060
11559
|
/**
|
|
11061
11560
|
* The low level primitive that powers `onExit`.
|
|
@@ -11149,20 +11648,20 @@ export declare const onExit: {
|
|
|
11149
11648
|
<A, E, R, XE = never, XR = never>(self: Effect<A, E, R>, f: (exit: Exit.Exit<A, E>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>;
|
|
11150
11649
|
};
|
|
11151
11650
|
/**
|
|
11152
|
-
* Runs the cleanup effect only when the `Exit`
|
|
11153
|
-
*
|
|
11154
|
-
* The cleanup is skipped when the filter returns `Filter.fail`.
|
|
11651
|
+
* Runs the cleanup effect only when the `Exit` satisfies the provided
|
|
11652
|
+
* predicate.
|
|
11155
11653
|
*
|
|
11156
11654
|
* @example
|
|
11157
11655
|
* ```ts
|
|
11158
|
-
* import { Console, Effect, Exit
|
|
11159
|
-
*
|
|
11160
|
-
* const exitFilter = Filter.fromPredicate(Exit.isSuccess<number, never>)
|
|
11656
|
+
* import { Console, Effect, Exit } from "effect"
|
|
11161
11657
|
*
|
|
11162
11658
|
* const program = Effect.onExitIf(
|
|
11163
11659
|
* Effect.succeed(42),
|
|
11164
|
-
*
|
|
11165
|
-
* (
|
|
11660
|
+
* Exit.isSuccess,
|
|
11661
|
+
* (exit) =>
|
|
11662
|
+
* Exit.isSuccess(exit)
|
|
11663
|
+
* ? Console.log(`Succeeded with: ${exit.value}`)
|
|
11664
|
+
* : Effect.void
|
|
11166
11665
|
* )
|
|
11167
11666
|
* ```
|
|
11168
11667
|
*
|
|
@@ -11171,49 +11670,71 @@ export declare const onExit: {
|
|
|
11171
11670
|
*/
|
|
11172
11671
|
export declare const onExitIf: {
|
|
11173
11672
|
/**
|
|
11174
|
-
* Runs the cleanup effect only when the `Exit`
|
|
11175
|
-
*
|
|
11176
|
-
* The cleanup is skipped when the filter returns `Filter.fail`.
|
|
11673
|
+
* Runs the cleanup effect only when the `Exit` satisfies the provided
|
|
11674
|
+
* predicate.
|
|
11177
11675
|
*
|
|
11178
11676
|
* @example
|
|
11179
11677
|
* ```ts
|
|
11180
|
-
* import { Console, Effect, Exit
|
|
11181
|
-
*
|
|
11182
|
-
* const exitFilter = Filter.fromPredicate(Exit.isSuccess<number, never>)
|
|
11678
|
+
* import { Console, Effect, Exit } from "effect"
|
|
11183
11679
|
*
|
|
11184
11680
|
* const program = Effect.onExitIf(
|
|
11185
11681
|
* Effect.succeed(42),
|
|
11186
|
-
*
|
|
11187
|
-
* (
|
|
11682
|
+
* Exit.isSuccess,
|
|
11683
|
+
* (exit) =>
|
|
11684
|
+
* Exit.isSuccess(exit)
|
|
11685
|
+
* ? Console.log(`Succeeded with: ${exit.value}`)
|
|
11686
|
+
* : Effect.void
|
|
11188
11687
|
* )
|
|
11189
11688
|
* ```
|
|
11190
11689
|
*
|
|
11191
11690
|
* @since 4.0.0
|
|
11192
11691
|
* @category Resource Management & Finalization
|
|
11193
11692
|
*/
|
|
11194
|
-
<A, E, XE, XR
|
|
11693
|
+
<A, E, XE, XR>(predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>;
|
|
11195
11694
|
/**
|
|
11196
|
-
* Runs the cleanup effect only when the `Exit`
|
|
11197
|
-
*
|
|
11198
|
-
* The cleanup is skipped when the filter returns `Filter.fail`.
|
|
11695
|
+
* Runs the cleanup effect only when the `Exit` satisfies the provided
|
|
11696
|
+
* predicate.
|
|
11199
11697
|
*
|
|
11200
11698
|
* @example
|
|
11201
11699
|
* ```ts
|
|
11202
|
-
* import { Console, Effect, Exit
|
|
11203
|
-
*
|
|
11204
|
-
* const exitFilter = Filter.fromPredicate(Exit.isSuccess<number, never>)
|
|
11700
|
+
* import { Console, Effect, Exit } from "effect"
|
|
11205
11701
|
*
|
|
11206
11702
|
* const program = Effect.onExitIf(
|
|
11207
11703
|
* Effect.succeed(42),
|
|
11208
|
-
*
|
|
11209
|
-
* (
|
|
11704
|
+
* Exit.isSuccess,
|
|
11705
|
+
* (exit) =>
|
|
11706
|
+
* Exit.isSuccess(exit)
|
|
11707
|
+
* ? Console.log(`Succeeded with: ${exit.value}`)
|
|
11708
|
+
* : Effect.void
|
|
11210
11709
|
* )
|
|
11211
11710
|
* ```
|
|
11212
11711
|
*
|
|
11213
11712
|
* @since 4.0.0
|
|
11214
11713
|
* @category Resource Management & Finalization
|
|
11215
11714
|
*/
|
|
11216
|
-
<A, E, R, XE, XR
|
|
11715
|
+
<A, E, R, XE, XR>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>;
|
|
11716
|
+
};
|
|
11717
|
+
/**
|
|
11718
|
+
* Runs the cleanup effect only when the `Exit` matches the provided `Filter`.
|
|
11719
|
+
*
|
|
11720
|
+
* @since 4.0.0
|
|
11721
|
+
* @category Resource Management & Finalization
|
|
11722
|
+
*/
|
|
11723
|
+
export declare const onExitFilter: {
|
|
11724
|
+
/**
|
|
11725
|
+
* Runs the cleanup effect only when the `Exit` matches the provided `Filter`.
|
|
11726
|
+
*
|
|
11727
|
+
* @since 4.0.0
|
|
11728
|
+
* @category Resource Management & Finalization
|
|
11729
|
+
*/
|
|
11730
|
+
<A, E, XE, XR, B, X>(filter: Filter.Filter<Exit.Exit<NoInfer<A>, NoInfer<E>>, B, X>, f: (b: B, exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>;
|
|
11731
|
+
/**
|
|
11732
|
+
* Runs the cleanup effect only when the `Exit` matches the provided `Filter`.
|
|
11733
|
+
*
|
|
11734
|
+
* @since 4.0.0
|
|
11735
|
+
* @category Resource Management & Finalization
|
|
11736
|
+
*/
|
|
11737
|
+
<A, E, R, XE, XR, B, X>(self: Effect<A, E, R>, filter: Filter.Filter<Exit.Exit<NoInfer<A>, NoInfer<E>>, B, X>, f: (b: B, exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>;
|
|
11217
11738
|
};
|
|
11218
11739
|
/**
|
|
11219
11740
|
* Returns an effect that lazily computes a result and caches it for subsequent
|
|
@@ -11412,7 +11933,7 @@ export declare const cachedWithTTL: {
|
|
|
11412
11933
|
* @since 2.0.0
|
|
11413
11934
|
* @category Caching
|
|
11414
11935
|
*/
|
|
11415
|
-
(timeToLive: Duration.
|
|
11936
|
+
(timeToLive: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<Effect<A, E, R>>;
|
|
11416
11937
|
/**
|
|
11417
11938
|
* Returns an effect that caches its result for a specified `Duration`,
|
|
11418
11939
|
* known as "timeToLive" (TTL).
|
|
@@ -11479,7 +12000,7 @@ export declare const cachedWithTTL: {
|
|
|
11479
12000
|
* @since 2.0.0
|
|
11480
12001
|
* @category Caching
|
|
11481
12002
|
*/
|
|
11482
|
-
<A, E, R>(self: Effect<A, E, R>, timeToLive: Duration.
|
|
12003
|
+
<A, E, R>(self: Effect<A, E, R>, timeToLive: Duration.Input): Effect<Effect<A, E, R>>;
|
|
11483
12004
|
};
|
|
11484
12005
|
/**
|
|
11485
12006
|
* Caches an effect's result for a specified duration and allows manual
|
|
@@ -11620,7 +12141,7 @@ export declare const cachedInvalidateWithTTL: {
|
|
|
11620
12141
|
* @since 2.0.0
|
|
11621
12142
|
* @category Caching
|
|
11622
12143
|
*/
|
|
11623
|
-
(timeToLive: Duration.
|
|
12144
|
+
(timeToLive: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<[Effect<A, E, R>, Effect<void>]>;
|
|
11624
12145
|
/**
|
|
11625
12146
|
* Caches an effect's result for a specified duration and allows manual
|
|
11626
12147
|
* invalidation before expiration.
|
|
@@ -11690,7 +12211,7 @@ export declare const cachedInvalidateWithTTL: {
|
|
|
11690
12211
|
* @since 2.0.0
|
|
11691
12212
|
* @category Caching
|
|
11692
12213
|
*/
|
|
11693
|
-
<A, E, R>(self: Effect<A, E, R>, timeToLive: Duration.
|
|
12214
|
+
<A, E, R>(self: Effect<A, E, R>, timeToLive: Duration.Input): Effect<[Effect<A, E, R>, Effect<void>]>;
|
|
11694
12215
|
};
|
|
11695
12216
|
/**
|
|
11696
12217
|
* Returns an effect that is immediately interrupted.
|
|
@@ -11700,8 +12221,8 @@ export declare const cachedInvalidateWithTTL: {
|
|
|
11700
12221
|
* import { Effect } from "effect"
|
|
11701
12222
|
*
|
|
11702
12223
|
* const program = Effect.gen(function*() {
|
|
11703
|
-
* yield* Effect.interrupt
|
|
11704
|
-
* yield* Effect.succeed("This won't execute")
|
|
12224
|
+
* return yield* Effect.interrupt
|
|
12225
|
+
* yield* Effect.succeed("This won't execute and is unreachable")
|
|
11705
12226
|
* })
|
|
11706
12227
|
*
|
|
11707
12228
|
* Effect.runPromise(program).catch(console.error)
|
|
@@ -11890,6 +12411,13 @@ export declare const uninterruptibleMask: <A, E, R>(f: (restore: <AX, EX, RX>(ef
|
|
|
11890
12411
|
* @category Interruption
|
|
11891
12412
|
*/
|
|
11892
12413
|
export declare const interruptibleMask: <A, E, R>(f: (restore: <AX, EX, RX>(effect: Effect<AX, EX, RX>) => Effect<AX, EX, RX>) => Effect<A, E, R>) => Effect<A, E, R>;
|
|
12414
|
+
/**
|
|
12415
|
+
* Creates an AbortSignal that is managed by the provided scope.
|
|
12416
|
+
*
|
|
12417
|
+
* @since 4.0.0
|
|
12418
|
+
* @category Interruption
|
|
12419
|
+
*/
|
|
12420
|
+
export declare const abortSignal: Effect<AbortSignal, never, Scope>;
|
|
11893
12421
|
/**
|
|
11894
12422
|
* @since 2.0.0
|
|
11895
12423
|
* @category Repetition / Recursion
|
|
@@ -11918,10 +12446,10 @@ export declare namespace Repeat {
|
|
|
11918
12446
|
* ```
|
|
11919
12447
|
*/
|
|
11920
12448
|
type Return<R, E, A, O extends Options<A>> = Effect<O extends {
|
|
11921
|
-
schedule: Schedule<infer Out, infer _I, infer _E, infer _R>;
|
|
11922
|
-
} ? Out : O extends {
|
|
11923
12449
|
until: Predicate.Refinement<A, infer B>;
|
|
11924
|
-
} ? B :
|
|
12450
|
+
} ? B : O extends {
|
|
12451
|
+
while: Predicate.Refinement<A, infer B>;
|
|
12452
|
+
} ? Exclude<A, B> : A, E | (O extends {
|
|
11925
12453
|
schedule: Schedule<infer _Out, infer _I, infer E, infer _R>;
|
|
11926
12454
|
} ? E : never) | (O extends {
|
|
11927
12455
|
while: (...args: Array<any>) => Effect<infer _A, infer E, infer _R>;
|
|
@@ -12470,7 +12998,7 @@ export declare const repeat: {
|
|
|
12470
12998
|
* attempt++
|
|
12471
12999
|
* if (attempt <= 2) {
|
|
12472
13000
|
* yield* Console.log(`Attempt ${attempt} failed`)
|
|
12473
|
-
* yield* Effect.fail(`Error ${attempt}`)
|
|
13001
|
+
* return yield* Effect.fail(`Error ${attempt}`)
|
|
12474
13002
|
* }
|
|
12475
13003
|
* yield* Console.log(`Attempt ${attempt} succeeded`)
|
|
12476
13004
|
* return "success"
|
|
@@ -12520,7 +13048,7 @@ export declare const repeatOrElse: {
|
|
|
12520
13048
|
* attempt++
|
|
12521
13049
|
* if (attempt <= 2) {
|
|
12522
13050
|
* yield* Console.log(`Attempt ${attempt} failed`)
|
|
12523
|
-
* yield* Effect.fail(`Error ${attempt}`)
|
|
13051
|
+
* return yield* Effect.fail(`Error ${attempt}`)
|
|
12524
13052
|
* }
|
|
12525
13053
|
* yield* Console.log(`Attempt ${attempt} succeeded`)
|
|
12526
13054
|
* return "success"
|
|
@@ -12570,7 +13098,7 @@ export declare const repeatOrElse: {
|
|
|
12570
13098
|
* attempt++
|
|
12571
13099
|
* if (attempt <= 2) {
|
|
12572
13100
|
* yield* Console.log(`Attempt ${attempt} failed`)
|
|
12573
|
-
* yield* Effect.fail(`Error ${attempt}`)
|
|
13101
|
+
* return yield* Effect.fail(`Error ${attempt}`)
|
|
12574
13102
|
* }
|
|
12575
13103
|
* yield* Console.log(`Attempt ${attempt} succeeded`)
|
|
12576
13104
|
* return "success"
|
|
@@ -13969,7 +14497,7 @@ export declare const withParentSpan: {
|
|
|
13969
14497
|
* )
|
|
13970
14498
|
*
|
|
13971
14499
|
* const program = Effect.gen(function*() {
|
|
13972
|
-
* const name = yield* Effect.request(GetUser({ id: 1 }),
|
|
14500
|
+
* const name = yield* Effect.request(GetUser({ id: 1 }), resolver)
|
|
13973
14501
|
* yield* Console.log(name)
|
|
13974
14502
|
* })
|
|
13975
14503
|
* ```
|
|
@@ -14000,7 +14528,7 @@ export declare const request: {
|
|
|
14000
14528
|
* )
|
|
14001
14529
|
*
|
|
14002
14530
|
* const program = Effect.gen(function*() {
|
|
14003
|
-
* const name = yield* Effect.request(GetUser({ id: 1 }),
|
|
14531
|
+
* const name = yield* Effect.request(GetUser({ id: 1 }), resolver)
|
|
14004
14532
|
* yield* Console.log(name)
|
|
14005
14533
|
* })
|
|
14006
14534
|
* ```
|
|
@@ -14031,7 +14559,7 @@ export declare const request: {
|
|
|
14031
14559
|
* )
|
|
14032
14560
|
*
|
|
14033
14561
|
* const program = Effect.gen(function*() {
|
|
14034
|
-
* const name = yield* Effect.request(GetUser({ id: 1 }),
|
|
14562
|
+
* const name = yield* Effect.request(GetUser({ id: 1 }), resolver)
|
|
14035
14563
|
* yield* Console.log(name)
|
|
14036
14564
|
* })
|
|
14037
14565
|
* ```
|
|
@@ -14040,7 +14568,7 @@ export declare const request: {
|
|
|
14040
14568
|
};
|
|
14041
14569
|
/**
|
|
14042
14570
|
* Low-level entry point that registers a request with a resolver and delivers the exit value via `onExit`.
|
|
14043
|
-
* Use this when you already have a `
|
|
14571
|
+
* Use this when you already have a `Context` and need to enqueue a request outside an `Effect`.
|
|
14044
14572
|
*
|
|
14045
14573
|
* It returns a canceler that removes the pending request entry.
|
|
14046
14574
|
*
|
|
@@ -14050,7 +14578,7 @@ export declare const request: {
|
|
|
14050
14578
|
export declare const requestUnsafe: <A extends Request.Any>(self: A, options: {
|
|
14051
14579
|
readonly resolver: RequestResolver<A>;
|
|
14052
14580
|
readonly onExit: (exit: Exit.Exit<Request.Success<A>, Request.Error<A>>) => void;
|
|
14053
|
-
readonly
|
|
14581
|
+
readonly context: Context.Context<never>;
|
|
14054
14582
|
}) => () => void;
|
|
14055
14583
|
/**
|
|
14056
14584
|
* Returns an effect that forks this effect into its own separate fiber,
|
|
@@ -14240,7 +14768,7 @@ export declare const forkScoped: <Arg extends Effect<any, any, any> | {
|
|
|
14240
14768
|
}>(effectOrOptions?: Arg, options?: {
|
|
14241
14769
|
readonly startImmediately?: boolean | undefined;
|
|
14242
14770
|
readonly uninterruptible?: boolean | "inherit" | undefined;
|
|
14243
|
-
} | undefined) => [Arg] extends [Effect<infer _A, infer _E, infer _R>] ? Effect<Fiber<_A, _E>, never, _R> : <A, E, R>(self: Effect<A, E, R>) => Effect<Fiber<A, E>, never, R | Scope>;
|
|
14771
|
+
} | undefined) => [Arg] extends [Effect<infer _A, infer _E, infer _R>] ? Effect<Fiber<_A, _E>, never, _R | Scope> : <A, E, R>(self: Effect<A, E, R>) => Effect<Fiber<A, E>, never, R | Scope>;
|
|
14244
14772
|
/**
|
|
14245
14773
|
* Forks the effect into a new fiber attached to the global scope. Because the
|
|
14246
14774
|
* new fiber is attached to the global scope, when the fiber executing the
|
|
@@ -14360,6 +14888,7 @@ export interface RunOptions {
|
|
|
14360
14888
|
readonly signal?: AbortSignal | undefined;
|
|
14361
14889
|
readonly scheduler?: Scheduler | undefined;
|
|
14362
14890
|
readonly uninterruptible?: boolean | undefined;
|
|
14891
|
+
readonly onFiberStart?: ((fiber: Fiber<unknown, unknown>) => void) | undefined;
|
|
14363
14892
|
}
|
|
14364
14893
|
/**
|
|
14365
14894
|
* The foundational function for running effects, returning a "fiber" that can
|
|
@@ -14407,15 +14936,15 @@ export declare const runFork: <A, E>(effect: Effect<A, E, never>, options?: RunO
|
|
|
14407
14936
|
*
|
|
14408
14937
|
* @example
|
|
14409
14938
|
* ```ts
|
|
14410
|
-
* import { Effect,
|
|
14939
|
+
* import { Effect, Context } from "effect"
|
|
14411
14940
|
*
|
|
14412
14941
|
* interface Logger {
|
|
14413
14942
|
* log: (message: string) => void
|
|
14414
14943
|
* }
|
|
14415
14944
|
*
|
|
14416
|
-
* const Logger =
|
|
14945
|
+
* const Logger = Context.Service<Logger>("Logger")
|
|
14417
14946
|
*
|
|
14418
|
-
* const services =
|
|
14947
|
+
* const services = Context.make(Logger, {
|
|
14419
14948
|
* log: (message) => console.log(message)
|
|
14420
14949
|
* })
|
|
14421
14950
|
*
|
|
@@ -14431,7 +14960,7 @@ export declare const runFork: <A, E>(effect: Effect<A, E, never>, options?: RunO
|
|
|
14431
14960
|
* @since 4.0.0
|
|
14432
14961
|
* @category Running Effects
|
|
14433
14962
|
*/
|
|
14434
|
-
export declare const runForkWith: <R>(
|
|
14963
|
+
export declare const runForkWith: <R>(context: Context.Context<R>) => <A, E>(effect: Effect<A, E, R>, options?: RunOptions | undefined) => Fiber<A, E>;
|
|
14435
14964
|
/**
|
|
14436
14965
|
* Forks an effect with the provided services, registers `onExit` as a fiber observer, and returns an interruptor.
|
|
14437
14966
|
*
|
|
@@ -14439,15 +14968,15 @@ export declare const runForkWith: <R>(services: ServiceMap.ServiceMap<R>) => <A,
|
|
|
14439
14968
|
*
|
|
14440
14969
|
* @example
|
|
14441
14970
|
* ```ts
|
|
14442
|
-
* import { Console, Effect, Exit,
|
|
14971
|
+
* import { Console, Effect, Exit, Context } from "effect"
|
|
14443
14972
|
*
|
|
14444
14973
|
* interface Logger {
|
|
14445
14974
|
* log: (message: string) => Effect.Effect<void>
|
|
14446
14975
|
* }
|
|
14447
14976
|
*
|
|
14448
|
-
* const Logger =
|
|
14977
|
+
* const Logger = Context.Service<Logger>("Logger")
|
|
14449
14978
|
*
|
|
14450
|
-
* const services =
|
|
14979
|
+
* const services = Context.make(Logger, {
|
|
14451
14980
|
* log: (message) => Console.log(message)
|
|
14452
14981
|
* })
|
|
14453
14982
|
*
|
|
@@ -14472,7 +15001,7 @@ export declare const runForkWith: <R>(services: ServiceMap.ServiceMap<R>) => <A,
|
|
|
14472
15001
|
* @since 4.0.0
|
|
14473
15002
|
* @category Running Effects
|
|
14474
15003
|
*/
|
|
14475
|
-
export declare const runCallbackWith: <R>(
|
|
15004
|
+
export declare const runCallbackWith: <R>(context: Context.Context<R>) => <A, E>(effect: Effect<A, E, R>, options?: (RunOptions & {
|
|
14476
15005
|
readonly onExit: (exit: Exit.Exit<A, E>) => void;
|
|
14477
15006
|
}) | undefined) => (interruptor?: number | undefined) => void;
|
|
14478
15007
|
/**
|
|
@@ -14555,15 +15084,15 @@ export declare const runPromise: <A, E>(effect: Effect<A, E>, options?: RunOptio
|
|
|
14555
15084
|
*
|
|
14556
15085
|
* @example
|
|
14557
15086
|
* ```ts
|
|
14558
|
-
* import { Effect,
|
|
15087
|
+
* import { Effect, Context } from "effect"
|
|
14559
15088
|
*
|
|
14560
15089
|
* interface Config {
|
|
14561
15090
|
* apiUrl: string
|
|
14562
15091
|
* }
|
|
14563
15092
|
*
|
|
14564
|
-
* const Config =
|
|
15093
|
+
* const Config = Context.Service<Config>("Config")
|
|
14565
15094
|
*
|
|
14566
|
-
* const
|
|
15095
|
+
* const context = Context.make(Config, {
|
|
14567
15096
|
* apiUrl: "https://api.example.com"
|
|
14568
15097
|
* })
|
|
14569
15098
|
*
|
|
@@ -14572,13 +15101,13 @@ export declare const runPromise: <A, E>(effect: Effect<A, E>, options?: RunOptio
|
|
|
14572
15101
|
* return `Connecting to ${config.apiUrl}`
|
|
14573
15102
|
* })
|
|
14574
15103
|
*
|
|
14575
|
-
* Effect.runPromiseWith(
|
|
15104
|
+
* Effect.runPromiseWith(context)(program).then(console.log)
|
|
14576
15105
|
* ```
|
|
14577
15106
|
*
|
|
14578
15107
|
* @since 4.0.0
|
|
14579
15108
|
* @category Running Effects
|
|
14580
15109
|
*/
|
|
14581
|
-
export declare const runPromiseWith: <R>(
|
|
15110
|
+
export declare const runPromiseWith: <R>(context: Context.Context<R>) => <A, E>(effect: Effect<A, E, R>, options?: RunOptions | undefined) => Promise<A>;
|
|
14582
15111
|
/**
|
|
14583
15112
|
* Runs an effect and returns a `Promise` that resolves to an `Exit`, which
|
|
14584
15113
|
* represents the outcome (success or failure) of the effect.
|
|
@@ -14632,15 +15161,15 @@ export declare const runPromiseExit: <A, E>(effect: Effect<A, E>, options?: RunO
|
|
|
14632
15161
|
*
|
|
14633
15162
|
* @example
|
|
14634
15163
|
* ```ts
|
|
14635
|
-
* import { Effect, Exit,
|
|
15164
|
+
* import { Effect, Exit, Context } from "effect"
|
|
14636
15165
|
*
|
|
14637
15166
|
* interface Database {
|
|
14638
15167
|
* query: (sql: string) => string
|
|
14639
15168
|
* }
|
|
14640
15169
|
*
|
|
14641
|
-
* const Database =
|
|
15170
|
+
* const Database = Context.Service<Database>("Database")
|
|
14642
15171
|
*
|
|
14643
|
-
* const services =
|
|
15172
|
+
* const services = Context.make(Database, {
|
|
14644
15173
|
* query: (sql) => `Result for: ${sql}`
|
|
14645
15174
|
* })
|
|
14646
15175
|
*
|
|
@@ -14659,7 +15188,7 @@ export declare const runPromiseExit: <A, E>(effect: Effect<A, E>, options?: RunO
|
|
|
14659
15188
|
* @since 4.0.0
|
|
14660
15189
|
* @category Running Effects
|
|
14661
15190
|
*/
|
|
14662
|
-
export declare const runPromiseExitWith: <R>(
|
|
15191
|
+
export declare const runPromiseExitWith: <R>(context: Context.Context<R>) => <A, E>(effect: Effect<A, E, R>, options?: RunOptions | undefined) => Promise<Exit.Exit<A, E>>;
|
|
14663
15192
|
/**
|
|
14664
15193
|
* Executes an effect synchronously, running it immediately and returning the
|
|
14665
15194
|
* result.
|
|
@@ -14723,15 +15252,15 @@ export declare const runSync: <A, E>(effect: Effect<A, E>) => A;
|
|
|
14723
15252
|
*
|
|
14724
15253
|
* @example
|
|
14725
15254
|
* ```ts
|
|
14726
|
-
* import { Effect,
|
|
15255
|
+
* import { Effect, Context } from "effect"
|
|
14727
15256
|
*
|
|
14728
15257
|
* interface MathService {
|
|
14729
15258
|
* add: (a: number, b: number) => number
|
|
14730
15259
|
* }
|
|
14731
15260
|
*
|
|
14732
|
-
* const MathService =
|
|
15261
|
+
* const MathService = Context.Service<MathService>("MathService")
|
|
14733
15262
|
*
|
|
14734
|
-
* const
|
|
15263
|
+
* const context = Context.make(MathService, {
|
|
14735
15264
|
* add: (a, b) => a + b
|
|
14736
15265
|
* })
|
|
14737
15266
|
*
|
|
@@ -14740,14 +15269,14 @@ export declare const runSync: <A, E>(effect: Effect<A, E>) => A;
|
|
|
14740
15269
|
* return math.add(2, 3)
|
|
14741
15270
|
* })
|
|
14742
15271
|
*
|
|
14743
|
-
* const result = Effect.runSyncWith(
|
|
15272
|
+
* const result = Effect.runSyncWith(context)(program)
|
|
14744
15273
|
* console.log(result) // 5
|
|
14745
15274
|
* ```
|
|
14746
15275
|
*
|
|
14747
15276
|
* @since 4.0.0
|
|
14748
15277
|
* @category Running Effects
|
|
14749
15278
|
*/
|
|
14750
|
-
export declare const runSyncWith: <R>(
|
|
15279
|
+
export declare const runSyncWith: <R>(context: Context.Context<R>) => <A, E>(effect: Effect<A, E, R>) => A;
|
|
14751
15280
|
/**
|
|
14752
15281
|
* Runs an effect synchronously and returns the result as an `Exit` type, which
|
|
14753
15282
|
* represents the outcome (success or failure) of the effect.
|
|
@@ -14823,10 +15352,10 @@ export declare const runSyncExit: <A, E>(effect: Effect<A, E>) => Exit.Exit<A, E
|
|
|
14823
15352
|
*
|
|
14824
15353
|
* @example
|
|
14825
15354
|
* ```ts
|
|
14826
|
-
* import { Effect, Exit,
|
|
15355
|
+
* import { Effect, Exit, Context } from "effect"
|
|
14827
15356
|
*
|
|
14828
15357
|
* // Define a logger service
|
|
14829
|
-
* const Logger =
|
|
15358
|
+
* const Logger = Context.Service<{
|
|
14830
15359
|
* log: (msg: string) => void
|
|
14831
15360
|
* }>("Logger")
|
|
14832
15361
|
*
|
|
@@ -14836,12 +15365,12 @@ export declare const runSyncExit: <A, E>(effect: Effect<A, E>) => Exit.Exit<A, E
|
|
|
14836
15365
|
* return 42
|
|
14837
15366
|
* })
|
|
14838
15367
|
*
|
|
14839
|
-
* // Prepare
|
|
14840
|
-
* const
|
|
15368
|
+
* // Prepare context
|
|
15369
|
+
* const context = Context.make(Logger, {
|
|
14841
15370
|
* log: (msg) => console.log(`[LOG] ${msg}`)
|
|
14842
15371
|
* })
|
|
14843
15372
|
*
|
|
14844
|
-
* const exit = Effect.runSyncExitWith(
|
|
15373
|
+
* const exit = Effect.runSyncExitWith(context)(program)
|
|
14845
15374
|
*
|
|
14846
15375
|
* if (Exit.isSuccess(exit)) {
|
|
14847
15376
|
* console.log(`Success: ${exit.value}`)
|
|
@@ -14856,7 +15385,7 @@ export declare const runSyncExit: <A, E>(effect: Effect<A, E>) => Exit.Exit<A, E
|
|
|
14856
15385
|
* @since 4.0.0
|
|
14857
15386
|
* @category Running Effects
|
|
14858
15387
|
*/
|
|
14859
|
-
export declare const runSyncExitWith: <R>(
|
|
15388
|
+
export declare const runSyncExitWith: <R>(context: Context.Context<R>) => <A, E>(effect: Effect<A, E, R>) => Exit.Exit<A, E>;
|
|
14860
15389
|
/**
|
|
14861
15390
|
* Type helpers for functions built with `Effect.fn` and `Effect.fnUntraced`.
|
|
14862
15391
|
*
|
|
@@ -15546,7 +16075,7 @@ export declare const clockWith: <A, E, R>(f: (clock: Clock) => Effect<A, E, R>)
|
|
|
15546
16075
|
* @since 2.0.0
|
|
15547
16076
|
* @category Logging
|
|
15548
16077
|
*/
|
|
15549
|
-
export declare const logWithLevel: (level?:
|
|
16078
|
+
export declare const logWithLevel: (level?: Severity) => (...message: ReadonlyArray<any>) => Effect<void>;
|
|
15550
16079
|
/**
|
|
15551
16080
|
* Logs one or more messages using the default log level.
|
|
15552
16081
|
*
|
|
@@ -15813,6 +16342,85 @@ export declare const annotateLogs: {
|
|
|
15813
16342
|
<A, E, R>(effect: Effect<A, E, R>, key: string, value: unknown): Effect<A, E, R>;
|
|
15814
16343
|
<A, E, R>(effect: Effect<A, E, R>, values: Record<string, unknown>): Effect<A, E, R>;
|
|
15815
16344
|
};
|
|
16345
|
+
/**
|
|
16346
|
+
* Adds log annotations to the current scope.
|
|
16347
|
+
*
|
|
16348
|
+
* This differs from `annotateLogs`, which only annotates a specific effect.
|
|
16349
|
+
* `annotateLogsScoped` updates annotations for the entire current `Scope` and
|
|
16350
|
+
* restores the previous annotations when the scope closes.
|
|
16351
|
+
*
|
|
16352
|
+
* @example
|
|
16353
|
+
* ```ts
|
|
16354
|
+
* import { Effect } from "effect"
|
|
16355
|
+
*
|
|
16356
|
+
* const program = Effect.scoped(
|
|
16357
|
+
* Effect.gen(function*() {
|
|
16358
|
+
* yield* Effect.log("before")
|
|
16359
|
+
* yield* Effect.annotateLogsScoped({ requestId: "req-123" })
|
|
16360
|
+
* yield* Effect.log("inside scope")
|
|
16361
|
+
* })
|
|
16362
|
+
* )
|
|
16363
|
+
*
|
|
16364
|
+
* Effect.runPromise(program)
|
|
16365
|
+
* ```
|
|
16366
|
+
*
|
|
16367
|
+
* @since 4.0.0
|
|
16368
|
+
* @category Logging
|
|
16369
|
+
*/
|
|
16370
|
+
export declare const annotateLogsScoped: {
|
|
16371
|
+
/**
|
|
16372
|
+
* Adds log annotations to the current scope.
|
|
16373
|
+
*
|
|
16374
|
+
* This differs from `annotateLogs`, which only annotates a specific effect.
|
|
16375
|
+
* `annotateLogsScoped` updates annotations for the entire current `Scope` and
|
|
16376
|
+
* restores the previous annotations when the scope closes.
|
|
16377
|
+
*
|
|
16378
|
+
* @example
|
|
16379
|
+
* ```ts
|
|
16380
|
+
* import { Effect } from "effect"
|
|
16381
|
+
*
|
|
16382
|
+
* const program = Effect.scoped(
|
|
16383
|
+
* Effect.gen(function*() {
|
|
16384
|
+
* yield* Effect.log("before")
|
|
16385
|
+
* yield* Effect.annotateLogsScoped({ requestId: "req-123" })
|
|
16386
|
+
* yield* Effect.log("inside scope")
|
|
16387
|
+
* })
|
|
16388
|
+
* )
|
|
16389
|
+
*
|
|
16390
|
+
* Effect.runPromise(program)
|
|
16391
|
+
* ```
|
|
16392
|
+
*
|
|
16393
|
+
* @since 4.0.0
|
|
16394
|
+
* @category Logging
|
|
16395
|
+
*/
|
|
16396
|
+
(key: string, value: unknown): Effect<void, never, Scope>;
|
|
16397
|
+
/**
|
|
16398
|
+
* Adds log annotations to the current scope.
|
|
16399
|
+
*
|
|
16400
|
+
* This differs from `annotateLogs`, which only annotates a specific effect.
|
|
16401
|
+
* `annotateLogsScoped` updates annotations for the entire current `Scope` and
|
|
16402
|
+
* restores the previous annotations when the scope closes.
|
|
16403
|
+
*
|
|
16404
|
+
* @example
|
|
16405
|
+
* ```ts
|
|
16406
|
+
* import { Effect } from "effect"
|
|
16407
|
+
*
|
|
16408
|
+
* const program = Effect.scoped(
|
|
16409
|
+
* Effect.gen(function*() {
|
|
16410
|
+
* yield* Effect.log("before")
|
|
16411
|
+
* yield* Effect.annotateLogsScoped({ requestId: "req-123" })
|
|
16412
|
+
* yield* Effect.log("inside scope")
|
|
16413
|
+
* })
|
|
16414
|
+
* )
|
|
16415
|
+
*
|
|
16416
|
+
* Effect.runPromise(program)
|
|
16417
|
+
* ```
|
|
16418
|
+
*
|
|
16419
|
+
* @since 4.0.0
|
|
16420
|
+
* @category Logging
|
|
16421
|
+
*/
|
|
16422
|
+
(values: Record<string, unknown>): Effect<void, never, Scope>;
|
|
16423
|
+
};
|
|
15816
16424
|
/**
|
|
15817
16425
|
* Adds a span to each log line in this effect.
|
|
15818
16426
|
*
|
|
@@ -16348,18 +16956,20 @@ export declare const trackSuccesses: {
|
|
|
16348
16956
|
*
|
|
16349
16957
|
* @example
|
|
16350
16958
|
* ```ts
|
|
16351
|
-
* import { Effect, Metric } from "effect"
|
|
16959
|
+
* import { Data, Effect, Metric } from "effect"
|
|
16960
|
+
*
|
|
16961
|
+
* class ConnectionFailedError extends Data.TaggedError("ConnectionFailedError")<{}> {}
|
|
16352
16962
|
*
|
|
16353
16963
|
* // Track error types using frequency metric
|
|
16354
16964
|
* const errorTypeFrequency = Metric.frequency("error_types")
|
|
16355
16965
|
*
|
|
16356
|
-
* const program = Effect.fail(new
|
|
16357
|
-
* Effect.trackErrors(errorTypeFrequency, (error:
|
|
16966
|
+
* const program = Effect.fail(new ConnectionFailedError()).pipe(
|
|
16967
|
+
* Effect.trackErrors(errorTypeFrequency, (error: ConnectionFailedError) => error._tag)
|
|
16358
16968
|
* )
|
|
16359
16969
|
*
|
|
16360
16970
|
* Effect.runPromiseExit(program).then(() =>
|
|
16361
16971
|
* Effect.runPromise(Metric.value(errorTypeFrequency)).then(console.log)
|
|
16362
|
-
* // Output: { occurrences: Map(1) { "
|
|
16972
|
+
* // Output: { occurrences: Map(1) { "ConnectionFailedError" => 1 } }
|
|
16363
16973
|
* )
|
|
16364
16974
|
* ```
|
|
16365
16975
|
*
|
|
@@ -16394,18 +17004,20 @@ export declare const trackErrors: {
|
|
|
16394
17004
|
*
|
|
16395
17005
|
* @example
|
|
16396
17006
|
* ```ts
|
|
16397
|
-
* import { Effect, Metric } from "effect"
|
|
17007
|
+
* import { Data, Effect, Metric } from "effect"
|
|
17008
|
+
*
|
|
17009
|
+
* class ConnectionFailedError extends Data.TaggedError("ConnectionFailedError")<{}> {}
|
|
16398
17010
|
*
|
|
16399
17011
|
* // Track error types using frequency metric
|
|
16400
17012
|
* const errorTypeFrequency = Metric.frequency("error_types")
|
|
16401
17013
|
*
|
|
16402
|
-
* const program = Effect.fail(new
|
|
16403
|
-
* Effect.trackErrors(errorTypeFrequency, (error:
|
|
17014
|
+
* const program = Effect.fail(new ConnectionFailedError()).pipe(
|
|
17015
|
+
* Effect.trackErrors(errorTypeFrequency, (error: ConnectionFailedError) => error._tag)
|
|
16404
17016
|
* )
|
|
16405
17017
|
*
|
|
16406
17018
|
* Effect.runPromiseExit(program).then(() =>
|
|
16407
17019
|
* Effect.runPromise(Metric.value(errorTypeFrequency)).then(console.log)
|
|
16408
|
-
* // Output: { occurrences: Map(1) { "
|
|
17020
|
+
* // Output: { occurrences: Map(1) { "ConnectionFailedError" => 1 } }
|
|
16409
17021
|
* )
|
|
16410
17022
|
* ```
|
|
16411
17023
|
*
|
|
@@ -16440,18 +17052,20 @@ export declare const trackErrors: {
|
|
|
16440
17052
|
*
|
|
16441
17053
|
* @example
|
|
16442
17054
|
* ```ts
|
|
16443
|
-
* import { Effect, Metric } from "effect"
|
|
17055
|
+
* import { Data, Effect, Metric } from "effect"
|
|
17056
|
+
*
|
|
17057
|
+
* class ConnectionFailedError extends Data.TaggedError("ConnectionFailedError")<{}> {}
|
|
16444
17058
|
*
|
|
16445
17059
|
* // Track error types using frequency metric
|
|
16446
17060
|
* const errorTypeFrequency = Metric.frequency("error_types")
|
|
16447
17061
|
*
|
|
16448
|
-
* const program = Effect.fail(new
|
|
16449
|
-
* Effect.trackErrors(errorTypeFrequency, (error:
|
|
17062
|
+
* const program = Effect.fail(new ConnectionFailedError()).pipe(
|
|
17063
|
+
* Effect.trackErrors(errorTypeFrequency, (error: ConnectionFailedError) => error._tag)
|
|
16450
17064
|
* )
|
|
16451
17065
|
*
|
|
16452
17066
|
* Effect.runPromiseExit(program).then(() =>
|
|
16453
17067
|
* Effect.runPromise(Metric.value(errorTypeFrequency)).then(console.log)
|
|
16454
|
-
* // Output: { occurrences: Map(1) { "
|
|
17068
|
+
* // Output: { occurrences: Map(1) { "ConnectionFailedError" => 1 } }
|
|
16455
17069
|
* )
|
|
16456
17070
|
* ```
|
|
16457
17071
|
*
|
|
@@ -16486,18 +17100,20 @@ export declare const trackErrors: {
|
|
|
16486
17100
|
*
|
|
16487
17101
|
* @example
|
|
16488
17102
|
* ```ts
|
|
16489
|
-
* import { Effect, Metric } from "effect"
|
|
17103
|
+
* import { Data, Effect, Metric } from "effect"
|
|
17104
|
+
*
|
|
17105
|
+
* class ConnectionFailedError extends Data.TaggedError("ConnectionFailedError")<{}> {}
|
|
16490
17106
|
*
|
|
16491
17107
|
* // Track error types using frequency metric
|
|
16492
17108
|
* const errorTypeFrequency = Metric.frequency("error_types")
|
|
16493
17109
|
*
|
|
16494
|
-
* const program = Effect.fail(new
|
|
16495
|
-
* Effect.trackErrors(errorTypeFrequency, (error:
|
|
17110
|
+
* const program = Effect.fail(new ConnectionFailedError()).pipe(
|
|
17111
|
+
* Effect.trackErrors(errorTypeFrequency, (error: ConnectionFailedError) => error._tag)
|
|
16496
17112
|
* )
|
|
16497
17113
|
*
|
|
16498
17114
|
* Effect.runPromiseExit(program).then(() =>
|
|
16499
17115
|
* Effect.runPromise(Metric.value(errorTypeFrequency)).then(console.log)
|
|
16500
|
-
* // Output: { occurrences: Map(1) { "
|
|
17116
|
+
* // Output: { occurrences: Map(1) { "ConnectionFailedError" => 1 } }
|
|
16501
17117
|
* )
|
|
16502
17118
|
* ```
|
|
16503
17119
|
*
|
|
@@ -16532,18 +17148,20 @@ export declare const trackErrors: {
|
|
|
16532
17148
|
*
|
|
16533
17149
|
* @example
|
|
16534
17150
|
* ```ts
|
|
16535
|
-
* import { Effect, Metric } from "effect"
|
|
17151
|
+
* import { Data, Effect, Metric } from "effect"
|
|
17152
|
+
*
|
|
17153
|
+
* class ConnectionFailedError extends Data.TaggedError("ConnectionFailedError")<{}> {}
|
|
16536
17154
|
*
|
|
16537
17155
|
* // Track error types using frequency metric
|
|
16538
17156
|
* const errorTypeFrequency = Metric.frequency("error_types")
|
|
16539
17157
|
*
|
|
16540
|
-
* const program = Effect.fail(new
|
|
16541
|
-
* Effect.trackErrors(errorTypeFrequency, (error:
|
|
17158
|
+
* const program = Effect.fail(new ConnectionFailedError()).pipe(
|
|
17159
|
+
* Effect.trackErrors(errorTypeFrequency, (error: ConnectionFailedError) => error._tag)
|
|
16542
17160
|
* )
|
|
16543
17161
|
*
|
|
16544
17162
|
* Effect.runPromiseExit(program).then(() =>
|
|
16545
17163
|
* Effect.runPromise(Metric.value(errorTypeFrequency)).then(console.log)
|
|
16546
|
-
* // Output: { occurrences: Map(1) { "
|
|
17164
|
+
* // Output: { occurrences: Map(1) { "ConnectionFailedError" => 1 } }
|
|
16547
17165
|
* )
|
|
16548
17166
|
* ```
|
|
16549
17167
|
*
|
|
@@ -17024,7 +17642,7 @@ export declare const trackDuration: {
|
|
|
17024
17642
|
*/
|
|
17025
17643
|
<A, E, R, State>(self: Effect<A, E, R>, metric: Metric.Metric<Duration.Duration, State>): Effect<A, E, R>;
|
|
17026
17644
|
};
|
|
17027
|
-
declare const Transaction_base:
|
|
17645
|
+
declare const Transaction_base: Context.ServiceClass<Transaction, "effect/Effect/Transaction", {
|
|
17028
17646
|
retry: boolean;
|
|
17029
17647
|
readonly journal: Map<TxRef<any>, {
|
|
17030
17648
|
readonly version: number;
|
|
@@ -17055,19 +17673,22 @@ declare const Transaction_base: ServiceMap.ServiceClass<Transaction, "effect/Eff
|
|
|
17055
17673
|
export declare class Transaction extends Transaction_base {
|
|
17056
17674
|
}
|
|
17057
17675
|
/**
|
|
17058
|
-
* Defines a transaction. Transactions are "all or nothing" with respect to changes
|
|
17059
|
-
* transactional values (i.e. TxRef) that occur within the transaction body.
|
|
17676
|
+
* Defines a transaction boundary. Transactions are "all or nothing" with respect to changes
|
|
17677
|
+
* made to transactional values (i.e. TxRef) that occur within the transaction body.
|
|
17678
|
+
*
|
|
17679
|
+
* If called inside an active transaction, `tx` composes with the current transaction and reuses
|
|
17680
|
+
* its journal and retry state instead of creating a nested boundary.
|
|
17060
17681
|
*
|
|
17061
17682
|
* In Effect transactions are optimistic with retry, that means transactions are retried when:
|
|
17062
17683
|
*
|
|
17063
|
-
* - the body of the transaction explicitely calls to `Effect.
|
|
17684
|
+
* - the body of the transaction explicitely calls to `Effect.txRetry` and any of the
|
|
17064
17685
|
* accessed transactional values changes.
|
|
17065
17686
|
*
|
|
17066
17687
|
* - any of the accessed transactional values change during the execution of the transaction
|
|
17067
17688
|
* due to a different transaction committing before the current.
|
|
17068
17689
|
*
|
|
17069
|
-
*
|
|
17070
|
-
*
|
|
17690
|
+
* The outermost `tx` call creates the transaction boundary and commits or rolls back the full
|
|
17691
|
+
* composed transaction.
|
|
17071
17692
|
*
|
|
17072
17693
|
* @example
|
|
17073
17694
|
* ```ts
|
|
@@ -17077,10 +17698,10 @@ export declare class Transaction extends Transaction_base {
|
|
|
17077
17698
|
* const ref1 = yield* TxRef.make(0)
|
|
17078
17699
|
* const ref2 = yield* TxRef.make(0)
|
|
17079
17700
|
*
|
|
17080
|
-
* //
|
|
17081
|
-
* yield* Effect.
|
|
17701
|
+
* // Nested tx calls compose into the same transaction
|
|
17702
|
+
* yield* Effect.tx(Effect.gen(function*() {
|
|
17082
17703
|
* yield* TxRef.set(ref1, 10)
|
|
17083
|
-
* yield* TxRef.set(ref2, 20)
|
|
17704
|
+
* yield* Effect.tx(TxRef.set(ref2, 20))
|
|
17084
17705
|
* const sum = (yield* TxRef.get(ref1)) + (yield* TxRef.get(ref2))
|
|
17085
17706
|
* console.log(`Transaction sum: ${sum}`)
|
|
17086
17707
|
* }))
|
|
@@ -17093,122 +17714,7 @@ export declare class Transaction extends Transaction_base {
|
|
|
17093
17714
|
* @since 4.0.0
|
|
17094
17715
|
* @category Transactions
|
|
17095
17716
|
*/
|
|
17096
|
-
export declare const
|
|
17097
|
-
/**
|
|
17098
|
-
* Executes a function within a transaction context, providing access to the transaction state.
|
|
17099
|
-
*
|
|
17100
|
-
* @example
|
|
17101
|
-
* ```ts
|
|
17102
|
-
* import { Effect, TxRef } from "effect"
|
|
17103
|
-
*
|
|
17104
|
-
* const program = Effect.atomicWith((txState) =>
|
|
17105
|
-
* Effect.gen(function*() {
|
|
17106
|
-
* const ref = yield* TxRef.make(0)
|
|
17107
|
-
*
|
|
17108
|
-
* // Access transaction state for debugging
|
|
17109
|
-
* console.log(`Journal size: ${txState.journal.size}`)
|
|
17110
|
-
* console.log(`Retry flag: ${txState.retry}`)
|
|
17111
|
-
*
|
|
17112
|
-
* yield* TxRef.set(ref, 42)
|
|
17113
|
-
* return yield* TxRef.get(ref)
|
|
17114
|
-
* })
|
|
17115
|
-
* )
|
|
17116
|
-
*
|
|
17117
|
-
* Effect.runPromise(program).then(console.log) // 42
|
|
17118
|
-
* ```
|
|
17119
|
-
*
|
|
17120
|
-
* @since 4.0.0
|
|
17121
|
-
* @category Transactions
|
|
17122
|
-
*/
|
|
17123
|
-
export declare const atomicWith: <A, E, R>(f: (state: Transaction["Service"]) => Effect<A, E, R>) => Effect<A, E, Exclude<R, Transaction>>;
|
|
17124
|
-
/**
|
|
17125
|
-
* Creates an isolated transaction that never composes with parent transactions.
|
|
17126
|
-
*
|
|
17127
|
-
* **Details**
|
|
17128
|
-
*
|
|
17129
|
-
* Unlike `Effect.atomic`, which composes with parent transactions when nested,
|
|
17130
|
-
* `Effect.transaction` always creates a new isolated transaction boundary.
|
|
17131
|
-
* This ensures complete isolation between different transaction scopes.
|
|
17132
|
-
*
|
|
17133
|
-
* **Key Differences from Effect.atomic:**
|
|
17134
|
-
* - Always creates a new transaction, even when called within another transaction
|
|
17135
|
-
* - Parent transaction failures don't affect isolated transactions
|
|
17136
|
-
* - Isolated transaction failures don't affect parent transactions
|
|
17137
|
-
* - Each transaction has its own journal and retry logic
|
|
17138
|
-
*
|
|
17139
|
-
* **When to Use:**
|
|
17140
|
-
* - When you need guaranteed isolation between transaction scopes
|
|
17141
|
-
* - For implementing independent operations that shouldn't be affected by outer transactions
|
|
17142
|
-
* - When building transaction-based systems where isolation is critical
|
|
17143
|
-
*
|
|
17144
|
-
* @example
|
|
17145
|
-
* ```ts
|
|
17146
|
-
* import { Effect, TxRef } from "effect"
|
|
17147
|
-
*
|
|
17148
|
-
* const program = Effect.gen(function*() {
|
|
17149
|
-
* const ref1 = yield* TxRef.make(0)
|
|
17150
|
-
* const ref2 = yield* TxRef.make(100)
|
|
17151
|
-
*
|
|
17152
|
-
* // Nested atomic transaction - ref1 will be part of outer transaction
|
|
17153
|
-
* yield* Effect.atomic(Effect.gen(function*() {
|
|
17154
|
-
* yield* TxRef.set(ref1, 10)
|
|
17155
|
-
*
|
|
17156
|
-
* // This atomic operation composes with the parent
|
|
17157
|
-
* yield* Effect.atomic(Effect.gen(function*() {
|
|
17158
|
-
* yield* TxRef.set(ref1, 20) // Part of same transaction
|
|
17159
|
-
* }))
|
|
17160
|
-
* }))
|
|
17161
|
-
*
|
|
17162
|
-
* // Isolated transaction - ref2 will be in its own transaction
|
|
17163
|
-
* yield* Effect.transaction(Effect.gen(function*() {
|
|
17164
|
-
* yield* TxRef.set(ref2, 200)
|
|
17165
|
-
* }))
|
|
17166
|
-
*
|
|
17167
|
-
* const val1 = yield* TxRef.get(ref1) // 20
|
|
17168
|
-
* const val2 = yield* TxRef.get(ref2) // 200
|
|
17169
|
-
* return { ref1: val1, ref2: val2 }
|
|
17170
|
-
* })
|
|
17171
|
-
* ```
|
|
17172
|
-
*
|
|
17173
|
-
* @since 4.0.0
|
|
17174
|
-
* @category Transactions
|
|
17175
|
-
*/
|
|
17176
|
-
export declare const transaction: <A, E, R>(effect: Effect<A, E, R>) => Effect<A, E, Exclude<R, Transaction>>;
|
|
17177
|
-
/**
|
|
17178
|
-
* Executes a function within an isolated transaction context, providing access to the transaction state.
|
|
17179
|
-
*
|
|
17180
|
-
* This function always creates a new transaction boundary, regardless of whether it's called
|
|
17181
|
-
* within another transaction. This ensures complete isolation between transaction scopes.
|
|
17182
|
-
*
|
|
17183
|
-
* @example
|
|
17184
|
-
* ```ts
|
|
17185
|
-
* import { Effect, TxRef } from "effect"
|
|
17186
|
-
*
|
|
17187
|
-
* const program = Effect.transactionWith((txState) =>
|
|
17188
|
-
* Effect.gen(function*() {
|
|
17189
|
-
* const ref = yield* TxRef.make(0)
|
|
17190
|
-
*
|
|
17191
|
-
* // This transaction is isolated - it has its own journal
|
|
17192
|
-
* // txState.journal is independent of any parent transaction
|
|
17193
|
-
*
|
|
17194
|
-
* yield* TxRef.set(ref, 42)
|
|
17195
|
-
* return yield* TxRef.get(ref)
|
|
17196
|
-
* })
|
|
17197
|
-
* )
|
|
17198
|
-
*
|
|
17199
|
-
* // Even when nested in another atomic block, this transaction is isolated
|
|
17200
|
-
* const nestedProgram = Effect.atomic(
|
|
17201
|
-
* Effect.gen(function*() {
|
|
17202
|
-
* const result = yield* program // Runs in its own isolated transaction
|
|
17203
|
-
* return result
|
|
17204
|
-
* })
|
|
17205
|
-
* )
|
|
17206
|
-
* ```
|
|
17207
|
-
*
|
|
17208
|
-
* @since 4.0.0
|
|
17209
|
-
* @category Transactions
|
|
17210
|
-
*/
|
|
17211
|
-
export declare const transactionWith: <A, E, R>(f: (state: Transaction["Service"]) => Effect<A, E, R>) => Effect<A, E, Exclude<R, Transaction>>;
|
|
17717
|
+
export declare const tx: <A, E, R>(effect: Effect<A, E, R>) => Effect<A, E, Exclude<R, Transaction>>;
|
|
17212
17718
|
/**
|
|
17213
17719
|
* Signals that the current transaction needs to be retried.
|
|
17214
17720
|
*
|
|
@@ -17229,15 +17735,15 @@ export declare const transactionWith: <A, E, R>(f: (state: Transaction["Service"
|
|
|
17229
17735
|
* // forks a fiber that increases the value of `ref` every 100 millis
|
|
17230
17736
|
* yield* Effect.forkChild(Effect.forever(
|
|
17231
17737
|
* // update to transactional value
|
|
17232
|
-
* TxRef.update(ref, (n) => n + 1).pipe(Effect.delay("100 millis"))
|
|
17738
|
+
* Effect.tx(TxRef.update(ref, (n) => n + 1)).pipe(Effect.delay("100 millis"))
|
|
17233
17739
|
* ))
|
|
17234
17740
|
*
|
|
17235
17741
|
* // the following will retry 10 times until the `ref` value is 10
|
|
17236
|
-
* yield* Effect.
|
|
17742
|
+
* yield* Effect.tx(Effect.gen(function*() {
|
|
17237
17743
|
* const value = yield* TxRef.get(ref)
|
|
17238
17744
|
* if (value < 10) {
|
|
17239
17745
|
* yield* Effect.log(`retry due to value: ${value}`)
|
|
17240
|
-
* return yield* Effect.
|
|
17746
|
+
* return yield* Effect.txRetry
|
|
17241
17747
|
* }
|
|
17242
17748
|
* yield* Effect.log(`transaction done with value: ${value}`)
|
|
17243
17749
|
* }))
|
|
@@ -17246,7 +17752,7 @@ export declare const transactionWith: <A, E, R>(f: (state: Transaction["Service"
|
|
|
17246
17752
|
* Effect.runPromise(program).catch(console.error)
|
|
17247
17753
|
* ```
|
|
17248
17754
|
*/
|
|
17249
|
-
export declare const
|
|
17755
|
+
export declare const txRetry: Effect<never, never, Transaction>;
|
|
17250
17756
|
/**
|
|
17251
17757
|
* @since 4.0.0
|
|
17252
17758
|
* @category Effectify
|
|
@@ -17686,18 +18192,20 @@ export declare const satisfiesSuccessType: <A>() => <A2 extends A, E, R>(effect:
|
|
|
17686
18192
|
*
|
|
17687
18193
|
* @example
|
|
17688
18194
|
* ```ts
|
|
17689
|
-
* import { Effect } from "effect"
|
|
18195
|
+
* import { Data, Effect } from "effect"
|
|
18196
|
+
*
|
|
18197
|
+
* class ValidationError extends Data.TaggedError("ValidationError")<{}> {}
|
|
17690
18198
|
*
|
|
17691
|
-
* // Define a constraint that the error type must be
|
|
17692
|
-
* const satisfiesError = Effect.satisfiesErrorType<
|
|
18199
|
+
* // Define a constraint that the error type must be a ValidationError
|
|
18200
|
+
* const satisfiesError = Effect.satisfiesErrorType<ValidationError>()
|
|
17693
18201
|
*
|
|
17694
|
-
* // This works - Effect<number,
|
|
17695
|
-
* const validEffect = satisfiesError(Effect.fail(new
|
|
18202
|
+
* // This works - Effect<number, ValidationError, never> extends the constrained type
|
|
18203
|
+
* const validEffect = satisfiesError(Effect.fail(new ValidationError()))
|
|
17696
18204
|
*
|
|
17697
18205
|
* // This would cause a TypeScript compilation error:
|
|
17698
18206
|
* // const invalidEffect = satisfiesError(Effect.fail("string error"))
|
|
17699
18207
|
* // ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
17700
|
-
* // Type 'string' is not assignable to type '
|
|
18208
|
+
* // Type 'string' is not assignable to type 'ValidationError'
|
|
17701
18209
|
* ```
|
|
17702
18210
|
*
|
|
17703
18211
|
* @since 4.0.0
|