effect 4.0.0-beta.6 → 4.0.0-beta.60
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 +1391 -927
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +472 -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 +488 -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 +4 -4
- package/dist/unstable/cluster/K8sHttpClient.d.ts.map +1 -1
- package/dist/unstable/cluster/K8sHttpClient.js +6 -6
- 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 +59 -40
- 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 +1581 -1050
- 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 +1168 -621
- 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 +7 -7
- 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 +134 -54
- 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"
|
|
1912
|
+
*
|
|
1913
|
+
* class OperationFailedError extends Data.TaggedError("OperationFailedError")<{}> {}
|
|
1539
1914
|
*
|
|
1540
|
-
* // ┌─── Effect<never,
|
|
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"
|
|
1935
|
+
*
|
|
1936
|
+
* class ProgramError extends Data.TaggedError("ProgramError")<{ readonly failedAt: Date }> {}
|
|
1560
1937
|
*
|
|
1561
|
-
* const program = Effect.failSync(() => new
|
|
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
|
-
|
|
3840
|
-
}
|
|
4248
|
+
}), A2 = never, E2 = Exclude<E, {
|
|
4249
|
+
_tag: keyof Cases;
|
|
4250
|
+
}>, R2 = never>(self: Effect<A, E, R>, cases: Cases, orElse?: ((e: Exclude<E, {
|
|
3841
4251
|
_tag: keyof Cases;
|
|
3842
|
-
}> | {
|
|
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.
|
|
@@ -6692,7 +7236,7 @@ export declare const timeout: {
|
|
|
6692
7236
|
* @since 2.0.0
|
|
6693
7237
|
* @category Delays & Timeouts
|
|
6694
7238
|
*/
|
|
6695
|
-
(duration: Duration.
|
|
7239
|
+
(duration: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E | Cause.TimeoutError, R>;
|
|
6696
7240
|
/**
|
|
6697
7241
|
* Adds a time limit to an effect, triggering a timeout if the effect exceeds
|
|
6698
7242
|
* the duration.
|
|
@@ -6739,7 +7283,7 @@ export declare const timeout: {
|
|
|
6739
7283
|
* @since 2.0.0
|
|
6740
7284
|
* @category Delays & Timeouts
|
|
6741
7285
|
*/
|
|
6742
|
-
<A, E, R>(self: Effect<A, E, R>, duration: Duration.
|
|
7286
|
+
<A, E, R>(self: Effect<A, E, R>, duration: Duration.Input): Effect<A, E | Cause.TimeoutError, R>;
|
|
6743
7287
|
};
|
|
6744
7288
|
/**
|
|
6745
7289
|
* Handles timeouts by returning an `Option` that represents either the result
|
|
@@ -6840,7 +7384,7 @@ export declare const timeoutOption: {
|
|
|
6840
7384
|
* @since 3.1.0
|
|
6841
7385
|
* @category Delays & Timeouts
|
|
6842
7386
|
*/
|
|
6843
|
-
(duration: Duration.
|
|
7387
|
+
(duration: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<Option<A>, E, R>;
|
|
6844
7388
|
/**
|
|
6845
7389
|
* Handles timeouts by returning an `Option` that represents either the result
|
|
6846
7390
|
* or a timeout.
|
|
@@ -6890,7 +7434,7 @@ export declare const timeoutOption: {
|
|
|
6890
7434
|
* @since 3.1.0
|
|
6891
7435
|
* @category Delays & Timeouts
|
|
6892
7436
|
*/
|
|
6893
|
-
<A, E, R>(self: Effect<A, E, R>, duration: Duration.
|
|
7437
|
+
<A, E, R>(self: Effect<A, E, R>, duration: Duration.Input): Effect<Option<A>, E, R>;
|
|
6894
7438
|
};
|
|
6895
7439
|
/**
|
|
6896
7440
|
* Applies a timeout to an effect, with a fallback effect executed if the timeout is reached.
|
|
@@ -6911,7 +7455,7 @@ export declare const timeoutOption: {
|
|
|
6911
7455
|
* // Use cached data as fallback when timeout is reached
|
|
6912
7456
|
* const program = Effect.timeoutOrElse(slowQuery, {
|
|
6913
7457
|
* duration: "2 seconds",
|
|
6914
|
-
*
|
|
7458
|
+
* orElse: () =>
|
|
6915
7459
|
* Effect.gen(function*() {
|
|
6916
7460
|
* yield* Console.log("Query timed out, using cached data")
|
|
6917
7461
|
* return "Cached result"
|
|
@@ -6948,7 +7492,7 @@ export declare const timeoutOrElse: {
|
|
|
6948
7492
|
* // Use cached data as fallback when timeout is reached
|
|
6949
7493
|
* const program = Effect.timeoutOrElse(slowQuery, {
|
|
6950
7494
|
* duration: "2 seconds",
|
|
6951
|
-
*
|
|
7495
|
+
* orElse: () =>
|
|
6952
7496
|
* Effect.gen(function*() {
|
|
6953
7497
|
* yield* Console.log("Query timed out, using cached data")
|
|
6954
7498
|
* return "Cached result"
|
|
@@ -6966,8 +7510,8 @@ export declare const timeoutOrElse: {
|
|
|
6966
7510
|
* @category Delays & Timeouts
|
|
6967
7511
|
*/
|
|
6968
7512
|
<A2, E2, R2>(options: {
|
|
6969
|
-
readonly duration: Duration.
|
|
6970
|
-
readonly
|
|
7513
|
+
readonly duration: Duration.Input;
|
|
7514
|
+
readonly orElse: LazyArg<Effect<A2, E2, R2>>;
|
|
6971
7515
|
}): <A, E, R>(self: Effect<A, E, R>) => Effect<A | A2, E | E2, R | R2>;
|
|
6972
7516
|
/**
|
|
6973
7517
|
* Applies a timeout to an effect, with a fallback effect executed if the timeout is reached.
|
|
@@ -6988,7 +7532,7 @@ export declare const timeoutOrElse: {
|
|
|
6988
7532
|
* // Use cached data as fallback when timeout is reached
|
|
6989
7533
|
* const program = Effect.timeoutOrElse(slowQuery, {
|
|
6990
7534
|
* duration: "2 seconds",
|
|
6991
|
-
*
|
|
7535
|
+
* orElse: () =>
|
|
6992
7536
|
* Effect.gen(function*() {
|
|
6993
7537
|
* yield* Console.log("Query timed out, using cached data")
|
|
6994
7538
|
* return "Cached result"
|
|
@@ -7006,8 +7550,8 @@ export declare const timeoutOrElse: {
|
|
|
7006
7550
|
* @category Delays & Timeouts
|
|
7007
7551
|
*/
|
|
7008
7552
|
<A, E, R, A2, E2, R2>(self: Effect<A, E, R>, options: {
|
|
7009
|
-
readonly duration: Duration.
|
|
7010
|
-
readonly
|
|
7553
|
+
readonly duration: Duration.Input;
|
|
7554
|
+
readonly orElse: LazyArg<Effect<A2, E2, R2>>;
|
|
7011
7555
|
}): Effect<A | A2, E | E2, R | R2>;
|
|
7012
7556
|
};
|
|
7013
7557
|
/**
|
|
@@ -7051,7 +7595,7 @@ export declare const delay: {
|
|
|
7051
7595
|
* @since 2.0.0
|
|
7052
7596
|
* @category Delays & Timeouts
|
|
7053
7597
|
*/
|
|
7054
|
-
(duration: Duration.
|
|
7598
|
+
(duration: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, R>;
|
|
7055
7599
|
/**
|
|
7056
7600
|
* Returns an effect that is delayed from this effect by the specified
|
|
7057
7601
|
* `Duration`.
|
|
@@ -7072,7 +7616,7 @@ export declare const delay: {
|
|
|
7072
7616
|
* @since 2.0.0
|
|
7073
7617
|
* @category Delays & Timeouts
|
|
7074
7618
|
*/
|
|
7075
|
-
<A, E, R>(self: Effect<A, E, R>, duration: Duration.
|
|
7619
|
+
<A, E, R>(self: Effect<A, E, R>, duration: Duration.Input): Effect<A, E, R>;
|
|
7076
7620
|
};
|
|
7077
7621
|
/**
|
|
7078
7622
|
* Returns an effect that suspends for the specified duration. This method is
|
|
@@ -7096,7 +7640,7 @@ export declare const delay: {
|
|
|
7096
7640
|
* @since 2.0.0
|
|
7097
7641
|
* @category Delays & Timeouts
|
|
7098
7642
|
*/
|
|
7099
|
-
export declare const sleep: (duration: Duration.
|
|
7643
|
+
export declare const sleep: (duration: Duration.Input) => Effect<void>;
|
|
7100
7644
|
/**
|
|
7101
7645
|
* Measures the runtime of an effect and returns the duration with its result.
|
|
7102
7646
|
*
|
|
@@ -7389,12 +7933,12 @@ export declare const raceFirst: {
|
|
|
7389
7933
|
}): Effect<A | A2, E | E2, R | R2>;
|
|
7390
7934
|
};
|
|
7391
7935
|
/**
|
|
7392
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7393
|
-
* predicate
|
|
7936
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
7937
|
+
* predicate.
|
|
7394
7938
|
*
|
|
7395
7939
|
* @example
|
|
7396
7940
|
* ```ts
|
|
7397
|
-
* import { Effect
|
|
7941
|
+
* import { Effect } from "effect"
|
|
7398
7942
|
*
|
|
7399
7943
|
* // Sync predicate
|
|
7400
7944
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -7402,10 +7946,7 @@ export declare const raceFirst: {
|
|
|
7402
7946
|
* // Effectful predicate
|
|
7403
7947
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7404
7948
|
*
|
|
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
|
-
* )
|
|
7949
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
7409
7950
|
* ```
|
|
7410
7951
|
*
|
|
7411
7952
|
* @since 2.0.0
|
|
@@ -7413,12 +7954,12 @@ export declare const raceFirst: {
|
|
|
7413
7954
|
*/
|
|
7414
7955
|
export declare const filter: {
|
|
7415
7956
|
/**
|
|
7416
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7417
|
-
* predicate
|
|
7957
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
7958
|
+
* predicate.
|
|
7418
7959
|
*
|
|
7419
7960
|
* @example
|
|
7420
7961
|
* ```ts
|
|
7421
|
-
* import { Effect
|
|
7962
|
+
* import { Effect } from "effect"
|
|
7422
7963
|
*
|
|
7423
7964
|
* // Sync predicate
|
|
7424
7965
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -7426,10 +7967,7 @@ export declare const filter: {
|
|
|
7426
7967
|
* // Effectful predicate
|
|
7427
7968
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7428
7969
|
*
|
|
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
|
-
* )
|
|
7970
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
7433
7971
|
* ```
|
|
7434
7972
|
*
|
|
7435
7973
|
* @since 2.0.0
|
|
@@ -7437,12 +7975,12 @@ export declare const filter: {
|
|
|
7437
7975
|
*/
|
|
7438
7976
|
<A, B extends A>(refinement: Predicate.Refinement<NoInfer<A>, B>): (elements: Iterable<A>) => Effect<Array<B>>;
|
|
7439
7977
|
/**
|
|
7440
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7441
|
-
* predicate
|
|
7978
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
7979
|
+
* predicate.
|
|
7442
7980
|
*
|
|
7443
7981
|
* @example
|
|
7444
7982
|
* ```ts
|
|
7445
|
-
* import { Effect
|
|
7983
|
+
* import { Effect } from "effect"
|
|
7446
7984
|
*
|
|
7447
7985
|
* // Sync predicate
|
|
7448
7986
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -7450,10 +7988,7 @@ export declare const filter: {
|
|
|
7450
7988
|
* // Effectful predicate
|
|
7451
7989
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7452
7990
|
*
|
|
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
|
-
* )
|
|
7991
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
7457
7992
|
* ```
|
|
7458
7993
|
*
|
|
7459
7994
|
* @since 2.0.0
|
|
@@ -7461,12 +7996,12 @@ export declare const filter: {
|
|
|
7461
7996
|
*/
|
|
7462
7997
|
<A>(predicate: Predicate.Predicate<NoInfer<A>>): (elements: Iterable<A>) => Effect<Array<A>>;
|
|
7463
7998
|
/**
|
|
7464
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7465
|
-
* predicate
|
|
7999
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8000
|
+
* predicate.
|
|
7466
8001
|
*
|
|
7467
8002
|
* @example
|
|
7468
8003
|
* ```ts
|
|
7469
|
-
* import { Effect
|
|
8004
|
+
* import { Effect } from "effect"
|
|
7470
8005
|
*
|
|
7471
8006
|
* // Sync predicate
|
|
7472
8007
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -7474,25 +8009,22 @@ export declare const filter: {
|
|
|
7474
8009
|
* // Effectful predicate
|
|
7475
8010
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7476
8011
|
*
|
|
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
|
-
* )
|
|
8012
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
7481
8013
|
* ```
|
|
7482
8014
|
*
|
|
7483
8015
|
* @since 2.0.0
|
|
7484
8016
|
* @category Filtering
|
|
7485
8017
|
*/
|
|
7486
|
-
<A,
|
|
8018
|
+
<A, E, R>(predicate: (a: NoInfer<A>, i: number) => Effect<boolean, E, R>, options?: {
|
|
7487
8019
|
readonly concurrency?: Concurrency | undefined;
|
|
7488
|
-
}): (
|
|
8020
|
+
}): (iterable: Iterable<A>) => Effect<Array<A>, E, R>;
|
|
7489
8021
|
/**
|
|
7490
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7491
|
-
* predicate
|
|
8022
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8023
|
+
* predicate.
|
|
7492
8024
|
*
|
|
7493
8025
|
* @example
|
|
7494
8026
|
* ```ts
|
|
7495
|
-
* import { Effect
|
|
8027
|
+
* import { Effect } from "effect"
|
|
7496
8028
|
*
|
|
7497
8029
|
* // Sync predicate
|
|
7498
8030
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -7500,25 +8032,20 @@ export declare const filter: {
|
|
|
7500
8032
|
* // Effectful predicate
|
|
7501
8033
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7502
8034
|
*
|
|
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
|
-
* )
|
|
8035
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
7507
8036
|
* ```
|
|
7508
8037
|
*
|
|
7509
8038
|
* @since 2.0.0
|
|
7510
8039
|
* @category Filtering
|
|
7511
8040
|
*/
|
|
7512
|
-
<A, B
|
|
7513
|
-
readonly concurrency?: Concurrency | undefined;
|
|
7514
|
-
}): (elements: Iterable<A>) => Effect<Array<B>, E, R>;
|
|
8041
|
+
<A, B extends A>(elements: Iterable<A>, refinement: Predicate.Refinement<A, B>): Effect<Array<B>>;
|
|
7515
8042
|
/**
|
|
7516
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7517
|
-
* predicate
|
|
8043
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8044
|
+
* predicate.
|
|
7518
8045
|
*
|
|
7519
8046
|
* @example
|
|
7520
8047
|
* ```ts
|
|
7521
|
-
* import { Effect
|
|
8048
|
+
* import { Effect } from "effect"
|
|
7522
8049
|
*
|
|
7523
8050
|
* // Sync predicate
|
|
7524
8051
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -7526,25 +8053,20 @@ export declare const filter: {
|
|
|
7526
8053
|
* // Effectful predicate
|
|
7527
8054
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7528
8055
|
*
|
|
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
|
-
* )
|
|
8056
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
7533
8057
|
* ```
|
|
7534
8058
|
*
|
|
7535
8059
|
* @since 2.0.0
|
|
7536
8060
|
* @category Filtering
|
|
7537
8061
|
*/
|
|
7538
|
-
<A
|
|
7539
|
-
readonly concurrency?: Concurrency | undefined;
|
|
7540
|
-
}): (iterable: Iterable<A>) => Effect<Array<A>, E, R>;
|
|
8062
|
+
<A>(elements: Iterable<A>, predicate: Predicate.Predicate<A>): Effect<Array<A>>;
|
|
7541
8063
|
/**
|
|
7542
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7543
|
-
* predicate
|
|
8064
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8065
|
+
* predicate.
|
|
7544
8066
|
*
|
|
7545
8067
|
* @example
|
|
7546
8068
|
* ```ts
|
|
7547
|
-
* import { Effect
|
|
8069
|
+
* import { Effect } from "effect"
|
|
7548
8070
|
*
|
|
7549
8071
|
* // Sync predicate
|
|
7550
8072
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -7552,116 +8074,63 @@ export declare const filter: {
|
|
|
7552
8074
|
* // Effectful predicate
|
|
7553
8075
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7554
8076
|
*
|
|
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
|
-
* )
|
|
8077
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
7559
8078
|
* ```
|
|
7560
8079
|
*
|
|
7561
8080
|
* @since 2.0.0
|
|
7562
8081
|
* @category Filtering
|
|
7563
8082
|
*/
|
|
7564
|
-
<A,
|
|
8083
|
+
<A, E, R>(iterable: Iterable<A>, predicate: (a: NoInfer<A>, i: number) => Effect<boolean, E, R>, options?: {
|
|
8084
|
+
readonly concurrency?: Concurrency | undefined;
|
|
8085
|
+
}): Effect<Array<A>, E, R>;
|
|
8086
|
+
};
|
|
8087
|
+
/**
|
|
8088
|
+
* Filters and maps elements of an iterable with a `Filter`.
|
|
8089
|
+
*
|
|
8090
|
+
* @since 4.0.0
|
|
8091
|
+
* @category Filtering
|
|
8092
|
+
*/
|
|
8093
|
+
export declare const filterMap: {
|
|
7565
8094
|
/**
|
|
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)
|
|
7575
|
-
*
|
|
7576
|
-
* // Effectful predicate
|
|
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
|
-
* ```
|
|
8095
|
+
* Filters and maps elements of an iterable with a `Filter`.
|
|
7584
8096
|
*
|
|
7585
|
-
* @since
|
|
8097
|
+
* @since 4.0.0
|
|
7586
8098
|
* @category Filtering
|
|
7587
8099
|
*/
|
|
7588
|
-
<A>(
|
|
8100
|
+
<A, B, X>(filter: Filter.Filter<NoInfer<A>, B, X>): (elements: Iterable<A>) => Effect<Array<B>>;
|
|
7589
8101
|
/**
|
|
7590
|
-
* Filters elements of an iterable
|
|
7591
|
-
* predicate, or `Filter.FilterEffect`.
|
|
8102
|
+
* Filters and maps elements of an iterable with a `Filter`.
|
|
7592
8103
|
*
|
|
7593
|
-
* @
|
|
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))
|
|
7602
|
-
*
|
|
7603
|
-
* // FilterEffect
|
|
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
|
|
8104
|
+
* @since 4.0.0
|
|
7610
8105
|
* @category Filtering
|
|
7611
8106
|
*/
|
|
7612
8107
|
<A, B, X>(elements: Iterable<A>, filter: Filter.Filter<NoInfer<A>, B, X>): Effect<Array<B>>;
|
|
8108
|
+
};
|
|
8109
|
+
/**
|
|
8110
|
+
* Effectfully filters and maps elements of an iterable with a `FilterEffect`.
|
|
8111
|
+
*
|
|
8112
|
+
* @since 4.0.0
|
|
8113
|
+
* @category Filtering
|
|
8114
|
+
*/
|
|
8115
|
+
export declare const filterMapEffect: {
|
|
7613
8116
|
/**
|
|
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))
|
|
7626
|
-
*
|
|
7627
|
-
* // FilterEffect
|
|
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
|
-
* ```
|
|
8117
|
+
* Effectfully filters and maps elements of an iterable with a `FilterEffect`.
|
|
7632
8118
|
*
|
|
7633
|
-
* @since
|
|
8119
|
+
* @since 4.0.0
|
|
7634
8120
|
* @category Filtering
|
|
7635
8121
|
*/
|
|
7636
|
-
<A, B, X, E, R>(
|
|
8122
|
+
<A, B, X, E, R>(filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R>, options?: {
|
|
7637
8123
|
readonly concurrency?: Concurrency | undefined;
|
|
7638
|
-
}): Effect<Array<B>, E, R>;
|
|
8124
|
+
}): (elements: Iterable<A>) => Effect<Array<B>, E, R>;
|
|
7639
8125
|
/**
|
|
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
|
-
* ```
|
|
8126
|
+
* Effectfully filters and maps elements of an iterable with a `FilterEffect`.
|
|
7658
8127
|
*
|
|
7659
|
-
* @since
|
|
8128
|
+
* @since 4.0.0
|
|
7660
8129
|
* @category Filtering
|
|
7661
8130
|
*/
|
|
7662
|
-
<A, E, R>(
|
|
8131
|
+
<A, B, X, E, R>(elements: Iterable<A>, filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R>, options?: {
|
|
7663
8132
|
readonly concurrency?: Concurrency | undefined;
|
|
7664
|
-
}): Effect<Array<
|
|
8133
|
+
}): Effect<Array<B>, E, R>;
|
|
7665
8134
|
};
|
|
7666
8135
|
/**
|
|
7667
8136
|
* Filters an effect, providing an alternative effect if the predicate fails.
|
|
@@ -7755,7 +8224,7 @@ export declare const filterOrElse: {
|
|
|
7755
8224
|
* @since 2.0.0
|
|
7756
8225
|
* @category Filtering
|
|
7757
8226
|
*/
|
|
7758
|
-
<A,
|
|
8227
|
+
<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
8228
|
/**
|
|
7760
8229
|
* Filters an effect, providing an alternative effect if the predicate fails.
|
|
7761
8230
|
*
|
|
@@ -7817,7 +8286,29 @@ export declare const filterOrElse: {
|
|
|
7817
8286
|
* @since 2.0.0
|
|
7818
8287
|
* @category Filtering
|
|
7819
8288
|
*/
|
|
7820
|
-
<A, E, R,
|
|
8289
|
+
<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>;
|
|
8290
|
+
};
|
|
8291
|
+
/**
|
|
8292
|
+
* Filters an effect with a `Filter`, providing an alternative effect on failure.
|
|
8293
|
+
*
|
|
8294
|
+
* @since 4.0.0
|
|
8295
|
+
* @category Filtering
|
|
8296
|
+
*/
|
|
8297
|
+
export declare const filterMapOrElse: {
|
|
8298
|
+
/**
|
|
8299
|
+
* Filters an effect with a `Filter`, providing an alternative effect on failure.
|
|
8300
|
+
*
|
|
8301
|
+
* @since 4.0.0
|
|
8302
|
+
* @category Filtering
|
|
8303
|
+
*/
|
|
8304
|
+
<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>;
|
|
8305
|
+
/**
|
|
8306
|
+
* Filters an effect with a `Filter`, providing an alternative effect on failure.
|
|
8307
|
+
*
|
|
8308
|
+
* @since 4.0.0
|
|
8309
|
+
* @category Filtering
|
|
8310
|
+
*/
|
|
8311
|
+
<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
8312
|
};
|
|
7822
8313
|
/**
|
|
7823
8314
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
@@ -7878,127 +8369,7 @@ export declare const filterOrFail: {
|
|
|
7878
8369
|
* @since 2.0.0
|
|
7879
8370
|
* @category Filtering
|
|
7880
8371
|
*/
|
|
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>;
|
|
8372
|
+
<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
8373
|
/**
|
|
8003
8374
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8004
8375
|
*
|
|
@@ -8028,7 +8399,7 @@ export declare const filterOrFail: {
|
|
|
8028
8399
|
* @since 2.0.0
|
|
8029
8400
|
* @category Filtering
|
|
8030
8401
|
*/
|
|
8031
|
-
<A,
|
|
8402
|
+
<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
8403
|
/**
|
|
8033
8404
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8034
8405
|
*
|
|
@@ -8058,7 +8429,7 @@ export declare const filterOrFail: {
|
|
|
8058
8429
|
* @since 2.0.0
|
|
8059
8430
|
* @category Filtering
|
|
8060
8431
|
*/
|
|
8061
|
-
<A,
|
|
8432
|
+
<A, B extends A>(refinement: Predicate.Refinement<NoInfer<A>, B>): <E, R>(self: Effect<A, E, R>) => Effect<B, Cause.NoSuchElementError | E, R>;
|
|
8062
8433
|
/**
|
|
8063
8434
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8064
8435
|
*
|
|
@@ -8088,7 +8459,7 @@ export declare const filterOrFail: {
|
|
|
8088
8459
|
* @since 2.0.0
|
|
8089
8460
|
* @category Filtering
|
|
8090
8461
|
*/
|
|
8091
|
-
<A
|
|
8462
|
+
<A>(predicate: Predicate.Predicate<NoInfer<A>>): <E, R>(self: Effect<A, E, R>) => Effect<A, Cause.NoSuchElementError | E, R>;
|
|
8092
8463
|
/**
|
|
8093
8464
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8094
8465
|
*
|
|
@@ -8118,7 +8489,7 @@ export declare const filterOrFail: {
|
|
|
8118
8489
|
* @since 2.0.0
|
|
8119
8490
|
* @category Filtering
|
|
8120
8491
|
*/
|
|
8121
|
-
<A, E, R,
|
|
8492
|
+
<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
8493
|
/**
|
|
8123
8494
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8124
8495
|
*
|
|
@@ -8148,7 +8519,7 @@ export declare const filterOrFail: {
|
|
|
8148
8519
|
* @since 2.0.0
|
|
8149
8520
|
* @category Filtering
|
|
8150
8521
|
*/
|
|
8151
|
-
<A, E, R,
|
|
8522
|
+
<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
8523
|
/**
|
|
8153
8524
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8154
8525
|
*
|
|
@@ -8178,7 +8549,7 @@ export declare const filterOrFail: {
|
|
|
8178
8549
|
* @since 2.0.0
|
|
8179
8550
|
* @category Filtering
|
|
8180
8551
|
*/
|
|
8181
|
-
<A, E, R>(self: Effect<A, E, R>,
|
|
8552
|
+
<A, E, R, B extends A>(self: Effect<A, E, R>, refinement: Predicate.Refinement<NoInfer<A>, B>): Effect<B, E | Cause.NoSuchElementError, R>;
|
|
8182
8553
|
/**
|
|
8183
8554
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8184
8555
|
*
|
|
@@ -8208,7 +8579,43 @@ export declare const filterOrFail: {
|
|
|
8208
8579
|
* @since 2.0.0
|
|
8209
8580
|
* @category Filtering
|
|
8210
8581
|
*/
|
|
8211
|
-
<A, E, R
|
|
8582
|
+
<A, E, R>(self: Effect<A, E, R>, predicate: Predicate.Predicate<NoInfer<A>>): Effect<A, E | Cause.NoSuchElementError, R>;
|
|
8583
|
+
};
|
|
8584
|
+
/**
|
|
8585
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
8586
|
+
*
|
|
8587
|
+
* @since 4.0.0
|
|
8588
|
+
* @category Filtering
|
|
8589
|
+
*/
|
|
8590
|
+
export declare const filterMapOrFail: {
|
|
8591
|
+
/**
|
|
8592
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
8593
|
+
*
|
|
8594
|
+
* @since 4.0.0
|
|
8595
|
+
* @category Filtering
|
|
8596
|
+
*/
|
|
8597
|
+
<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>;
|
|
8598
|
+
/**
|
|
8599
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
8600
|
+
*
|
|
8601
|
+
* @since 4.0.0
|
|
8602
|
+
* @category Filtering
|
|
8603
|
+
*/
|
|
8604
|
+
<A, B, X>(filter: Filter.Filter<NoInfer<A>, B, X>): <E, R>(self: Effect<A, E, R>) => Effect<B, Cause.NoSuchElementError | E, R>;
|
|
8605
|
+
/**
|
|
8606
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
8607
|
+
*
|
|
8608
|
+
* @since 4.0.0
|
|
8609
|
+
* @category Filtering
|
|
8610
|
+
*/
|
|
8611
|
+
<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>;
|
|
8612
|
+
/**
|
|
8613
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
8614
|
+
*
|
|
8615
|
+
* @since 4.0.0
|
|
8616
|
+
* @category Filtering
|
|
8617
|
+
*/
|
|
8618
|
+
<A, E, R, B, X>(self: Effect<A, E, R>, filter: Filter.Filter<A, B, X>): Effect<B, Cause.NoSuchElementError | E, R>;
|
|
8212
8619
|
};
|
|
8213
8620
|
/**
|
|
8214
8621
|
* Conditionally executes an effect based on a boolean condition.
|
|
@@ -8349,9 +8756,11 @@ export declare const when: {
|
|
|
8349
8756
|
* @example
|
|
8350
8757
|
* ```ts
|
|
8351
8758
|
* // Title: Handling Both Success and Failure Cases
|
|
8352
|
-
* import { Effect } from "effect"
|
|
8759
|
+
* import { Data, Effect } from "effect"
|
|
8353
8760
|
*
|
|
8354
|
-
*
|
|
8761
|
+
* class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
|
|
8762
|
+
*
|
|
8763
|
+
* const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
|
|
8355
8764
|
*
|
|
8356
8765
|
* const program1 = Effect.match(success, {
|
|
8357
8766
|
* onFailure: (error) => `failure: ${error.message}`,
|
|
@@ -8362,8 +8771,8 @@ export declare const when: {
|
|
|
8362
8771
|
* Effect.runPromise(program1).then(console.log)
|
|
8363
8772
|
* // Output: "success: 42"
|
|
8364
8773
|
*
|
|
8365
|
-
* const failure: Effect.Effect<number,
|
|
8366
|
-
* new
|
|
8774
|
+
* const failure: Effect.Effect<number, ExampleError> = Effect.fail(
|
|
8775
|
+
* new ExampleError({ message: "Uh oh!" })
|
|
8367
8776
|
* )
|
|
8368
8777
|
*
|
|
8369
8778
|
* const program2 = Effect.match(failure, {
|
|
@@ -8401,9 +8810,11 @@ export declare const match: {
|
|
|
8401
8810
|
* @example
|
|
8402
8811
|
* ```ts
|
|
8403
8812
|
* // Title: Handling Both Success and Failure Cases
|
|
8404
|
-
* import { Effect } from "effect"
|
|
8813
|
+
* import { Data, Effect } from "effect"
|
|
8814
|
+
*
|
|
8815
|
+
* class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
|
|
8405
8816
|
*
|
|
8406
|
-
* const success: Effect.Effect<number,
|
|
8817
|
+
* const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
|
|
8407
8818
|
*
|
|
8408
8819
|
* const program1 = Effect.match(success, {
|
|
8409
8820
|
* onFailure: (error) => `failure: ${error.message}`,
|
|
@@ -8414,8 +8825,8 @@ export declare const match: {
|
|
|
8414
8825
|
* Effect.runPromise(program1).then(console.log)
|
|
8415
8826
|
* // Output: "success: 42"
|
|
8416
8827
|
*
|
|
8417
|
-
* const failure: Effect.Effect<number,
|
|
8418
|
-
* new
|
|
8828
|
+
* const failure: Effect.Effect<number, ExampleError> = Effect.fail(
|
|
8829
|
+
* new ExampleError({ message: "Uh oh!" })
|
|
8419
8830
|
* )
|
|
8420
8831
|
*
|
|
8421
8832
|
* const program2 = Effect.match(failure, {
|
|
@@ -8456,9 +8867,11 @@ export declare const match: {
|
|
|
8456
8867
|
* @example
|
|
8457
8868
|
* ```ts
|
|
8458
8869
|
* // Title: Handling Both Success and Failure Cases
|
|
8459
|
-
* import { Effect } from "effect"
|
|
8870
|
+
* import { Data, Effect } from "effect"
|
|
8460
8871
|
*
|
|
8461
|
-
*
|
|
8872
|
+
* class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
|
|
8873
|
+
*
|
|
8874
|
+
* const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
|
|
8462
8875
|
*
|
|
8463
8876
|
* const program1 = Effect.match(success, {
|
|
8464
8877
|
* onFailure: (error) => `failure: ${error.message}`,
|
|
@@ -8469,8 +8882,8 @@ export declare const match: {
|
|
|
8469
8882
|
* Effect.runPromise(program1).then(console.log)
|
|
8470
8883
|
* // Output: "success: 42"
|
|
8471
8884
|
*
|
|
8472
|
-
* const failure: Effect.Effect<number,
|
|
8473
|
-
* new
|
|
8885
|
+
* const failure: Effect.Effect<number, ExampleError> = Effect.fail(
|
|
8886
|
+
* new ExampleError({ message: "Uh oh!" })
|
|
8474
8887
|
* )
|
|
8475
8888
|
*
|
|
8476
8889
|
* const program2 = Effect.match(failure, {
|
|
@@ -8872,9 +9285,11 @@ export declare const matchCauseEffectEager: {
|
|
|
8872
9285
|
*
|
|
8873
9286
|
* @example
|
|
8874
9287
|
* ```ts
|
|
8875
|
-
* import { Cause, Console, Effect, Result } from "effect"
|
|
9288
|
+
* import { Cause, Console, Data, Effect, Result } from "effect"
|
|
9289
|
+
*
|
|
9290
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
8876
9291
|
*
|
|
8877
|
-
* const task = Effect.fail(new
|
|
9292
|
+
* const task = Effect.fail(new TaskError({ message: "Task failed" }))
|
|
8878
9293
|
*
|
|
8879
9294
|
* const program = Effect.matchCauseEffect(task, {
|
|
8880
9295
|
* onFailure: (cause) =>
|
|
@@ -8924,9 +9339,11 @@ export declare const matchCauseEffect: {
|
|
|
8924
9339
|
*
|
|
8925
9340
|
* @example
|
|
8926
9341
|
* ```ts
|
|
8927
|
-
* import { Cause, Console, Effect, Result } from "effect"
|
|
9342
|
+
* import { Cause, Console, Data, Effect, Result } from "effect"
|
|
8928
9343
|
*
|
|
8929
|
-
*
|
|
9344
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
9345
|
+
*
|
|
9346
|
+
* const task = Effect.fail(new TaskError({ message: "Task failed" }))
|
|
8930
9347
|
*
|
|
8931
9348
|
* const program = Effect.matchCauseEffect(task, {
|
|
8932
9349
|
* onFailure: (cause) =>
|
|
@@ -8979,9 +9396,11 @@ export declare const matchCauseEffect: {
|
|
|
8979
9396
|
*
|
|
8980
9397
|
* @example
|
|
8981
9398
|
* ```ts
|
|
8982
|
-
* import { Cause, Console, Effect, Result } from "effect"
|
|
9399
|
+
* import { Cause, Console, Data, Effect, Result } from "effect"
|
|
9400
|
+
*
|
|
9401
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
8983
9402
|
*
|
|
8984
|
-
* const task = Effect.fail(new
|
|
9403
|
+
* const task = Effect.fail(new TaskError({ message: "Task failed" }))
|
|
8985
9404
|
*
|
|
8986
9405
|
* const program = Effect.matchCauseEffect(task, {
|
|
8987
9406
|
* onFailure: (cause) =>
|
|
@@ -9041,11 +9460,13 @@ export declare const matchCauseEffect: {
|
|
|
9041
9460
|
* @example
|
|
9042
9461
|
* ```ts
|
|
9043
9462
|
* // Title: Handling Both Success and Failure Cases with Side Effects
|
|
9044
|
-
* import { Effect } from "effect"
|
|
9463
|
+
* import { Data, Effect } from "effect"
|
|
9045
9464
|
*
|
|
9046
|
-
*
|
|
9047
|
-
*
|
|
9048
|
-
*
|
|
9465
|
+
* class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
|
|
9466
|
+
*
|
|
9467
|
+
* const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
|
|
9468
|
+
* const failure: Effect.Effect<number, ExampleError> = Effect.fail(
|
|
9469
|
+
* new ExampleError({ message: "Uh oh!" })
|
|
9049
9470
|
* )
|
|
9050
9471
|
*
|
|
9051
9472
|
* const program1 = Effect.matchEffect(success, {
|
|
@@ -9101,11 +9522,13 @@ export declare const matchEffect: {
|
|
|
9101
9522
|
* @example
|
|
9102
9523
|
* ```ts
|
|
9103
9524
|
* // Title: Handling Both Success and Failure Cases with Side Effects
|
|
9104
|
-
* import { Effect } from "effect"
|
|
9525
|
+
* import { Data, Effect } from "effect"
|
|
9526
|
+
*
|
|
9527
|
+
* class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
|
|
9105
9528
|
*
|
|
9106
|
-
* const success: Effect.Effect<number,
|
|
9107
|
-
* const failure: Effect.Effect<number,
|
|
9108
|
-
* new
|
|
9529
|
+
* const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
|
|
9530
|
+
* const failure: Effect.Effect<number, ExampleError> = Effect.fail(
|
|
9531
|
+
* new ExampleError({ message: "Uh oh!" })
|
|
9109
9532
|
* )
|
|
9110
9533
|
*
|
|
9111
9534
|
* const program1 = Effect.matchEffect(success, {
|
|
@@ -9164,11 +9587,13 @@ export declare const matchEffect: {
|
|
|
9164
9587
|
* @example
|
|
9165
9588
|
* ```ts
|
|
9166
9589
|
* // Title: Handling Both Success and Failure Cases with Side Effects
|
|
9167
|
-
* import { Effect } from "effect"
|
|
9590
|
+
* import { Data, Effect } from "effect"
|
|
9168
9591
|
*
|
|
9169
|
-
*
|
|
9170
|
-
*
|
|
9171
|
-
*
|
|
9592
|
+
* class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
|
|
9593
|
+
*
|
|
9594
|
+
* const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
|
|
9595
|
+
* const failure: Effect.Effect<number, ExampleError> = Effect.fail(
|
|
9596
|
+
* new ExampleError({ message: "Uh oh!" })
|
|
9172
9597
|
* )
|
|
9173
9598
|
*
|
|
9174
9599
|
* const program1 = Effect.matchEffect(success, {
|
|
@@ -9260,7 +9685,7 @@ export declare const isFailure: <A, E, R>(self: Effect<A, E, R>) => Effect<boole
|
|
|
9260
9685
|
*/
|
|
9261
9686
|
export declare const isSuccess: <A, E, R>(self: Effect<A, E, R>) => Effect<boolean, never, R>;
|
|
9262
9687
|
/**
|
|
9263
|
-
* Returns the complete
|
|
9688
|
+
* Returns the complete context.
|
|
9264
9689
|
*
|
|
9265
9690
|
* This function allows you to access all services that are currently available
|
|
9266
9691
|
* in the effect's environment. This can be useful for debugging, introspection,
|
|
@@ -9268,56 +9693,56 @@ export declare const isSuccess: <A, E, R>(self: Effect<A, E, R>) => Effect<boole
|
|
|
9268
9693
|
*
|
|
9269
9694
|
* @example
|
|
9270
9695
|
* ```ts
|
|
9271
|
-
* import { Console, Effect, Option,
|
|
9696
|
+
* import { Console, Effect, Option, Context } from "effect"
|
|
9272
9697
|
*
|
|
9273
|
-
* const Logger =
|
|
9698
|
+
* const Logger = Context.Service<{
|
|
9274
9699
|
* log: (msg: string) => void
|
|
9275
9700
|
* }>("Logger")
|
|
9276
|
-
* const Database =
|
|
9701
|
+
* const Database = Context.Service<{
|
|
9277
9702
|
* query: (sql: string) => string
|
|
9278
9703
|
* }>("Database")
|
|
9279
9704
|
*
|
|
9280
9705
|
* const program = Effect.gen(function*() {
|
|
9281
|
-
* const allServices = yield* Effect.
|
|
9706
|
+
* const allServices = yield* Effect.context()
|
|
9282
9707
|
*
|
|
9283
9708
|
* // Check if specific services are available
|
|
9284
|
-
* const loggerOption =
|
|
9285
|
-
* const databaseOption =
|
|
9709
|
+
* const loggerOption = Context.getOption(allServices, Logger)
|
|
9710
|
+
* const databaseOption = Context.getOption(allServices, Database)
|
|
9286
9711
|
*
|
|
9287
9712
|
* yield* Console.log(`Logger available: ${Option.isSome(loggerOption)}`)
|
|
9288
9713
|
* yield* Console.log(`Database available: ${Option.isSome(databaseOption)}`)
|
|
9289
9714
|
* })
|
|
9290
9715
|
*
|
|
9291
|
-
* const
|
|
9292
|
-
* .pipe(
|
|
9716
|
+
* const context = Context.make(Logger, { log: console.log })
|
|
9717
|
+
* .pipe(Context.add(Database, { query: () => "result" }))
|
|
9293
9718
|
*
|
|
9294
|
-
* const provided = Effect.
|
|
9719
|
+
* const provided = Effect.provideContext(program, context)
|
|
9295
9720
|
* ```
|
|
9296
9721
|
*
|
|
9297
9722
|
* @since 2.0.0
|
|
9298
9723
|
* @category Environment
|
|
9299
9724
|
*/
|
|
9300
|
-
export declare const
|
|
9725
|
+
export declare const context: <R = never>() => Effect<Context.Context<R>, never, R>;
|
|
9301
9726
|
/**
|
|
9302
|
-
* Transforms the current
|
|
9727
|
+
* Transforms the current context using the provided function.
|
|
9303
9728
|
*
|
|
9304
|
-
* This function allows you to access the complete
|
|
9729
|
+
* This function allows you to access the complete context and perform
|
|
9305
9730
|
* computations based on all available services. This is useful when you need
|
|
9306
9731
|
* to conditionally execute logic based on what services are available.
|
|
9307
9732
|
*
|
|
9308
9733
|
* @example
|
|
9309
9734
|
* ```ts
|
|
9310
|
-
* import { Console, Effect, Option,
|
|
9735
|
+
* import { Console, Effect, Option, Context } from "effect"
|
|
9311
9736
|
*
|
|
9312
|
-
* const Logger =
|
|
9737
|
+
* const Logger = Context.Service<{
|
|
9313
9738
|
* log: (msg: string) => void
|
|
9314
9739
|
* }>("Logger")
|
|
9315
|
-
* const Cache =
|
|
9740
|
+
* const Cache = Context.Service<{
|
|
9316
9741
|
* get: (key: string) => string | null
|
|
9317
9742
|
* }>("Cache")
|
|
9318
9743
|
*
|
|
9319
|
-
* const program = Effect.
|
|
9320
|
-
* const cacheOption =
|
|
9744
|
+
* const program = Effect.contextWith((services) => {
|
|
9745
|
+
* const cacheOption = Context.getOption(services, Cache)
|
|
9321
9746
|
* const hasCache = Option.isSome(cacheOption)
|
|
9322
9747
|
*
|
|
9323
9748
|
* if (hasCache) {
|
|
@@ -9342,7 +9767,7 @@ export declare const services: <R>() => Effect<ServiceMap.ServiceMap<R>, never,
|
|
|
9342
9767
|
* @since 2.0.0
|
|
9343
9768
|
* @category Environment
|
|
9344
9769
|
*/
|
|
9345
|
-
export declare const
|
|
9770
|
+
export declare const contextWith: <R, A, E, R2>(f: (context: Context.Context<R>) => Effect<A, E, R2>) => Effect<A, E, R | R2>;
|
|
9346
9771
|
/**
|
|
9347
9772
|
* Provides dependencies to an effect using layers or a context. Use `options.local`
|
|
9348
9773
|
* to build the layer every time; by default, layers are shared between provide
|
|
@@ -9350,16 +9775,16 @@ export declare const servicesWith: <R, A, E, R2>(f: (services: ServiceMap.Servic
|
|
|
9350
9775
|
*
|
|
9351
9776
|
* @example
|
|
9352
9777
|
* ```ts
|
|
9353
|
-
* import { Effect, Layer,
|
|
9778
|
+
* import { Effect, Layer, Context } from "effect"
|
|
9354
9779
|
*
|
|
9355
9780
|
* interface Database {
|
|
9356
9781
|
* readonly query: (sql: string) => Effect.Effect<string>
|
|
9357
9782
|
* }
|
|
9358
9783
|
*
|
|
9359
|
-
* const Database =
|
|
9784
|
+
* const Database = Context.Service<Database>("Database")
|
|
9360
9785
|
*
|
|
9361
9786
|
* const DatabaseLive = Layer.succeed(Database)({
|
|
9362
|
-
* query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
|
|
9787
|
+
* query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
|
|
9363
9788
|
* })
|
|
9364
9789
|
*
|
|
9365
9790
|
* const program = Effect.gen(function*() {
|
|
@@ -9384,16 +9809,16 @@ export declare const provide: {
|
|
|
9384
9809
|
*
|
|
9385
9810
|
* @example
|
|
9386
9811
|
* ```ts
|
|
9387
|
-
* import { Effect, Layer,
|
|
9812
|
+
* import { Effect, Layer, Context } from "effect"
|
|
9388
9813
|
*
|
|
9389
9814
|
* interface Database {
|
|
9390
9815
|
* readonly query: (sql: string) => Effect.Effect<string>
|
|
9391
9816
|
* }
|
|
9392
9817
|
*
|
|
9393
|
-
* const Database =
|
|
9818
|
+
* const Database = Context.Service<Database>("Database")
|
|
9394
9819
|
*
|
|
9395
9820
|
* const DatabaseLive = Layer.succeed(Database)({
|
|
9396
|
-
* query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
|
|
9821
|
+
* query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
|
|
9397
9822
|
* })
|
|
9398
9823
|
*
|
|
9399
9824
|
* const program = Effect.gen(function*() {
|
|
@@ -9420,16 +9845,16 @@ export declare const provide: {
|
|
|
9420
9845
|
*
|
|
9421
9846
|
* @example
|
|
9422
9847
|
* ```ts
|
|
9423
|
-
* import { Effect, Layer,
|
|
9848
|
+
* import { Effect, Layer, Context } from "effect"
|
|
9424
9849
|
*
|
|
9425
9850
|
* interface Database {
|
|
9426
9851
|
* readonly query: (sql: string) => Effect.Effect<string>
|
|
9427
9852
|
* }
|
|
9428
9853
|
*
|
|
9429
|
-
* const Database =
|
|
9854
|
+
* const Database = Context.Service<Database>("Database")
|
|
9430
9855
|
*
|
|
9431
9856
|
* const DatabaseLive = Layer.succeed(Database)({
|
|
9432
|
-
* query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
|
|
9857
|
+
* query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
|
|
9433
9858
|
* })
|
|
9434
9859
|
*
|
|
9435
9860
|
* const program = Effect.gen(function*() {
|
|
@@ -9456,16 +9881,16 @@ export declare const provide: {
|
|
|
9456
9881
|
*
|
|
9457
9882
|
* @example
|
|
9458
9883
|
* ```ts
|
|
9459
|
-
* import { Effect, Layer,
|
|
9884
|
+
* import { Effect, Layer, Context } from "effect"
|
|
9460
9885
|
*
|
|
9461
9886
|
* interface Database {
|
|
9462
9887
|
* readonly query: (sql: string) => Effect.Effect<string>
|
|
9463
9888
|
* }
|
|
9464
9889
|
*
|
|
9465
|
-
* const Database =
|
|
9890
|
+
* const Database = Context.Service<Database>("Database")
|
|
9466
9891
|
*
|
|
9467
9892
|
* const DatabaseLive = Layer.succeed(Database)({
|
|
9468
|
-
* query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
|
|
9893
|
+
* query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
|
|
9469
9894
|
* })
|
|
9470
9895
|
*
|
|
9471
9896
|
* const program = Effect.gen(function*() {
|
|
@@ -9482,7 +9907,7 @@ export declare const provide: {
|
|
|
9482
9907
|
* @since 2.0.0
|
|
9483
9908
|
* @category Environment
|
|
9484
9909
|
*/
|
|
9485
|
-
<R2>(context:
|
|
9910
|
+
<R2>(context: Context.Context<R2>): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, Exclude<R, R2>>;
|
|
9486
9911
|
/**
|
|
9487
9912
|
* Provides dependencies to an effect using layers or a context. Use `options.local`
|
|
9488
9913
|
* to build the layer every time; by default, layers are shared between provide
|
|
@@ -9490,16 +9915,16 @@ export declare const provide: {
|
|
|
9490
9915
|
*
|
|
9491
9916
|
* @example
|
|
9492
9917
|
* ```ts
|
|
9493
|
-
* import { Effect, Layer,
|
|
9918
|
+
* import { Effect, Layer, Context } from "effect"
|
|
9494
9919
|
*
|
|
9495
9920
|
* interface Database {
|
|
9496
9921
|
* readonly query: (sql: string) => Effect.Effect<string>
|
|
9497
9922
|
* }
|
|
9498
9923
|
*
|
|
9499
|
-
* const Database =
|
|
9924
|
+
* const Database = Context.Service<Database>("Database")
|
|
9500
9925
|
*
|
|
9501
9926
|
* const DatabaseLive = Layer.succeed(Database)({
|
|
9502
|
-
* query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
|
|
9927
|
+
* query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
|
|
9503
9928
|
* })
|
|
9504
9929
|
*
|
|
9505
9930
|
* const program = Effect.gen(function*() {
|
|
@@ -9526,16 +9951,16 @@ export declare const provide: {
|
|
|
9526
9951
|
*
|
|
9527
9952
|
* @example
|
|
9528
9953
|
* ```ts
|
|
9529
|
-
* import { Effect, Layer,
|
|
9954
|
+
* import { Effect, Layer, Context } from "effect"
|
|
9530
9955
|
*
|
|
9531
9956
|
* interface Database {
|
|
9532
9957
|
* readonly query: (sql: string) => Effect.Effect<string>
|
|
9533
9958
|
* }
|
|
9534
9959
|
*
|
|
9535
|
-
* const Database =
|
|
9960
|
+
* const Database = Context.Service<Database>("Database")
|
|
9536
9961
|
*
|
|
9537
9962
|
* const DatabaseLive = Layer.succeed(Database)({
|
|
9538
|
-
* query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
|
|
9963
|
+
* query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
|
|
9539
9964
|
* })
|
|
9540
9965
|
*
|
|
9541
9966
|
* const program = Effect.gen(function*() {
|
|
@@ -9562,16 +9987,16 @@ export declare const provide: {
|
|
|
9562
9987
|
*
|
|
9563
9988
|
* @example
|
|
9564
9989
|
* ```ts
|
|
9565
|
-
* import { Effect, Layer,
|
|
9990
|
+
* import { Effect, Layer, Context } from "effect"
|
|
9566
9991
|
*
|
|
9567
9992
|
* interface Database {
|
|
9568
9993
|
* readonly query: (sql: string) => Effect.Effect<string>
|
|
9569
9994
|
* }
|
|
9570
9995
|
*
|
|
9571
|
-
* const Database =
|
|
9996
|
+
* const Database = Context.Service<Database>("Database")
|
|
9572
9997
|
*
|
|
9573
9998
|
* const DatabaseLive = Layer.succeed(Database)({
|
|
9574
|
-
* query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
|
|
9999
|
+
* query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
|
|
9575
10000
|
* })
|
|
9576
10001
|
*
|
|
9577
10002
|
* const program = Effect.gen(function*() {
|
|
@@ -9588,32 +10013,32 @@ export declare const provide: {
|
|
|
9588
10013
|
* @since 2.0.0
|
|
9589
10014
|
* @category Environment
|
|
9590
10015
|
*/
|
|
9591
|
-
<A, E, R, R2>(self: Effect<A, E, R>, context:
|
|
10016
|
+
<A, E, R, R2>(self: Effect<A, E, R>, context: Context.Context<R2>): Effect<A, E, Exclude<R, R2>>;
|
|
9592
10017
|
};
|
|
9593
10018
|
/**
|
|
9594
|
-
* Provides a
|
|
10019
|
+
* Provides a context to an effect, fulfilling its service requirements.
|
|
9595
10020
|
*
|
|
9596
10021
|
* **Details**
|
|
9597
10022
|
*
|
|
9598
|
-
* This function provides multiple services at once by supplying a
|
|
10023
|
+
* This function provides multiple services at once by supplying a context
|
|
9599
10024
|
* that contains all the required services. It removes the provided services
|
|
9600
10025
|
* from the effect's requirements, making them available to the effect.
|
|
9601
10026
|
*
|
|
9602
10027
|
* @example
|
|
9603
10028
|
* ```ts
|
|
9604
|
-
* import { Effect,
|
|
10029
|
+
* import { Effect, Context } from "effect"
|
|
9605
10030
|
*
|
|
9606
10031
|
* // Define service keys
|
|
9607
|
-
* const Logger =
|
|
10032
|
+
* const Logger = Context.Service<{
|
|
9608
10033
|
* log: (msg: string) => void
|
|
9609
10034
|
* }>("Logger")
|
|
9610
|
-
* const Database =
|
|
10035
|
+
* const Database = Context.Service<{
|
|
9611
10036
|
* query: (sql: string) => string
|
|
9612
10037
|
* }>("Database")
|
|
9613
10038
|
*
|
|
9614
|
-
* // Create
|
|
9615
|
-
* const
|
|
9616
|
-
* .pipe(
|
|
10039
|
+
* // Create a context with multiple services
|
|
10040
|
+
* const context = Context.make(Logger, { log: console.log })
|
|
10041
|
+
* .pipe(Context.add(Database, { query: () => "result" }))
|
|
9617
10042
|
*
|
|
9618
10043
|
* // An effect that requires both services
|
|
9619
10044
|
* const program = Effect.gen(function*() {
|
|
@@ -9623,37 +10048,37 @@ export declare const provide: {
|
|
|
9623
10048
|
* return db.query("SELECT * FROM users")
|
|
9624
10049
|
* })
|
|
9625
10050
|
*
|
|
9626
|
-
* const provided = Effect.
|
|
10051
|
+
* const provided = Effect.provideContext(program, context)
|
|
9627
10052
|
* ```
|
|
9628
10053
|
*
|
|
9629
10054
|
* @since 2.0.0
|
|
9630
10055
|
* @category Environment
|
|
9631
10056
|
*/
|
|
9632
|
-
export declare const
|
|
10057
|
+
export declare const provideContext: {
|
|
9633
10058
|
/**
|
|
9634
|
-
* Provides a
|
|
10059
|
+
* Provides a context to an effect, fulfilling its service requirements.
|
|
9635
10060
|
*
|
|
9636
10061
|
* **Details**
|
|
9637
10062
|
*
|
|
9638
|
-
* This function provides multiple services at once by supplying a
|
|
10063
|
+
* This function provides multiple services at once by supplying a context
|
|
9639
10064
|
* that contains all the required services. It removes the provided services
|
|
9640
10065
|
* from the effect's requirements, making them available to the effect.
|
|
9641
10066
|
*
|
|
9642
10067
|
* @example
|
|
9643
10068
|
* ```ts
|
|
9644
|
-
* import { Effect,
|
|
10069
|
+
* import { Effect, Context } from "effect"
|
|
9645
10070
|
*
|
|
9646
10071
|
* // Define service keys
|
|
9647
|
-
* const Logger =
|
|
10072
|
+
* const Logger = Context.Service<{
|
|
9648
10073
|
* log: (msg: string) => void
|
|
9649
10074
|
* }>("Logger")
|
|
9650
|
-
* const Database =
|
|
10075
|
+
* const Database = Context.Service<{
|
|
9651
10076
|
* query: (sql: string) => string
|
|
9652
10077
|
* }>("Database")
|
|
9653
10078
|
*
|
|
9654
|
-
* // Create
|
|
9655
|
-
* const
|
|
9656
|
-
* .pipe(
|
|
10079
|
+
* // Create a context with multiple services
|
|
10080
|
+
* const context = Context.make(Logger, { log: console.log })
|
|
10081
|
+
* .pipe(Context.add(Database, { query: () => "result" }))
|
|
9657
10082
|
*
|
|
9658
10083
|
* // An effect that requires both services
|
|
9659
10084
|
* const program = Effect.gen(function*() {
|
|
@@ -9663,37 +10088,37 @@ export declare const provideServices: {
|
|
|
9663
10088
|
* return db.query("SELECT * FROM users")
|
|
9664
10089
|
* })
|
|
9665
10090
|
*
|
|
9666
|
-
* const provided = Effect.
|
|
10091
|
+
* const provided = Effect.provideContext(program, context)
|
|
9667
10092
|
* ```
|
|
9668
10093
|
*
|
|
9669
10094
|
* @since 2.0.0
|
|
9670
10095
|
* @category Environment
|
|
9671
10096
|
*/
|
|
9672
|
-
<XR>(context:
|
|
10097
|
+
<XR>(context: Context.Context<XR>): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, Exclude<R, XR>>;
|
|
9673
10098
|
/**
|
|
9674
|
-
* Provides a
|
|
10099
|
+
* Provides a context to an effect, fulfilling its service requirements.
|
|
9675
10100
|
*
|
|
9676
10101
|
* **Details**
|
|
9677
10102
|
*
|
|
9678
|
-
* This function provides multiple services at once by supplying a
|
|
10103
|
+
* This function provides multiple services at once by supplying a context
|
|
9679
10104
|
* that contains all the required services. It removes the provided services
|
|
9680
10105
|
* from the effect's requirements, making them available to the effect.
|
|
9681
10106
|
*
|
|
9682
10107
|
* @example
|
|
9683
10108
|
* ```ts
|
|
9684
|
-
* import { Effect,
|
|
10109
|
+
* import { Effect, Context } from "effect"
|
|
9685
10110
|
*
|
|
9686
10111
|
* // Define service keys
|
|
9687
|
-
* const Logger =
|
|
10112
|
+
* const Logger = Context.Service<{
|
|
9688
10113
|
* log: (msg: string) => void
|
|
9689
10114
|
* }>("Logger")
|
|
9690
|
-
* const Database =
|
|
10115
|
+
* const Database = Context.Service<{
|
|
9691
10116
|
* query: (sql: string) => string
|
|
9692
10117
|
* }>("Database")
|
|
9693
10118
|
*
|
|
9694
|
-
* // Create
|
|
9695
|
-
* const
|
|
9696
|
-
* .pipe(
|
|
10119
|
+
* // Create a context with multiple services
|
|
10120
|
+
* const context = Context.make(Logger, { log: console.log })
|
|
10121
|
+
* .pipe(Context.add(Database, { query: () => "result" }))
|
|
9697
10122
|
*
|
|
9698
10123
|
* // An effect that requires both services
|
|
9699
10124
|
* const program = Effect.gen(function*() {
|
|
@@ -9703,26 +10128,26 @@ export declare const provideServices: {
|
|
|
9703
10128
|
* return db.query("SELECT * FROM users")
|
|
9704
10129
|
* })
|
|
9705
10130
|
*
|
|
9706
|
-
* const provided = Effect.
|
|
10131
|
+
* const provided = Effect.provideContext(program, context)
|
|
9707
10132
|
* ```
|
|
9708
10133
|
*
|
|
9709
10134
|
* @since 2.0.0
|
|
9710
10135
|
* @category Environment
|
|
9711
10136
|
*/
|
|
9712
|
-
<A, E, R, XR>(self: Effect<A, E, R>, context:
|
|
10137
|
+
<A, E, R, XR>(self: Effect<A, E, R>, context: Context.Context<XR>): Effect<A, E, Exclude<R, XR>>;
|
|
9713
10138
|
};
|
|
9714
10139
|
/**
|
|
9715
10140
|
* Accesses a service from the context.
|
|
9716
10141
|
*
|
|
9717
10142
|
* @example
|
|
9718
10143
|
* ```ts
|
|
9719
|
-
* import { Effect,
|
|
10144
|
+
* import { Effect, Context } from "effect"
|
|
9720
10145
|
*
|
|
9721
10146
|
* interface Database {
|
|
9722
10147
|
* readonly query: (sql: string) => Effect.Effect<string>
|
|
9723
10148
|
* }
|
|
9724
10149
|
*
|
|
9725
|
-
* const Database =
|
|
10150
|
+
* const Database = Context.Service<Database>("Database")
|
|
9726
10151
|
*
|
|
9727
10152
|
* const program = Effect.gen(function*() {
|
|
9728
10153
|
* const db = yield* Effect.service(Database)
|
|
@@ -9731,9 +10156,9 @@ export declare const provideServices: {
|
|
|
9731
10156
|
* ```
|
|
9732
10157
|
*
|
|
9733
10158
|
* @since 4.0.0
|
|
9734
|
-
* @category
|
|
10159
|
+
* @category Context
|
|
9735
10160
|
*/
|
|
9736
|
-
export declare const service: <I, S>(service:
|
|
10161
|
+
export declare const service: <I, S>(service: Context.Key<I, S>) => Effect<S, never, I>;
|
|
9737
10162
|
/**
|
|
9738
10163
|
* Optionally accesses a service from the environment.
|
|
9739
10164
|
*
|
|
@@ -9746,10 +10171,10 @@ export declare const service: <I, S>(service: ServiceMap.Service<I, S>) => Effec
|
|
|
9746
10171
|
*
|
|
9747
10172
|
* @example
|
|
9748
10173
|
* ```ts
|
|
9749
|
-
* import { Effect, Option,
|
|
10174
|
+
* import { Effect, Option, Context } from "effect"
|
|
9750
10175
|
*
|
|
9751
10176
|
* // Define a service key
|
|
9752
|
-
* const Logger =
|
|
10177
|
+
* const Logger = Context.Service<{
|
|
9753
10178
|
* log: (msg: string) => void
|
|
9754
10179
|
* }>("Logger")
|
|
9755
10180
|
*
|
|
@@ -9766,9 +10191,9 @@ export declare const service: <I, S>(service: ServiceMap.Service<I, S>) => Effec
|
|
|
9766
10191
|
* ```
|
|
9767
10192
|
*
|
|
9768
10193
|
* @since 2.0.0
|
|
9769
|
-
* @category
|
|
10194
|
+
* @category Context
|
|
9770
10195
|
*/
|
|
9771
|
-
export declare const serviceOption: <I, S>(key:
|
|
10196
|
+
export declare const serviceOption: <I, S>(key: Context.Key<I, S>) => Effect<Option<S>>;
|
|
9772
10197
|
/**
|
|
9773
10198
|
* Provides part of the required context while leaving the rest unchanged.
|
|
9774
10199
|
*
|
|
@@ -9779,13 +10204,13 @@ export declare const serviceOption: <I, S>(key: ServiceMap.Service<I, S>) => Eff
|
|
|
9779
10204
|
*
|
|
9780
10205
|
* @example
|
|
9781
10206
|
* ```ts
|
|
9782
|
-
* import { Effect,
|
|
10207
|
+
* import { Effect, Context } from "effect"
|
|
9783
10208
|
*
|
|
9784
10209
|
* // Define services
|
|
9785
|
-
* const Logger =
|
|
10210
|
+
* const Logger = Context.Service<{
|
|
9786
10211
|
* log: (msg: string) => void
|
|
9787
10212
|
* }>("Logger")
|
|
9788
|
-
* const Config =
|
|
10213
|
+
* const Config = Context.Service<{
|
|
9789
10214
|
* name: string
|
|
9790
10215
|
* }>("Config")
|
|
9791
10216
|
*
|
|
@@ -9795,8 +10220,8 @@ export declare const serviceOption: <I, S>(key: ServiceMap.Service<I, S>) => Eff
|
|
|
9795
10220
|
*
|
|
9796
10221
|
* // Transform services by providing Config while keeping Logger requirement
|
|
9797
10222
|
* const configured = program.pipe(
|
|
9798
|
-
* Effect.
|
|
9799
|
-
*
|
|
10223
|
+
* Effect.updateContext((context: Context.Context<typeof Logger>) =>
|
|
10224
|
+
* Context.add(context, Config, { name: "World" })
|
|
9800
10225
|
* )
|
|
9801
10226
|
* )
|
|
9802
10227
|
*
|
|
@@ -9807,9 +10232,9 @@ export declare const serviceOption: <I, S>(key: ServiceMap.Service<I, S>) => Eff
|
|
|
9807
10232
|
* ```
|
|
9808
10233
|
*
|
|
9809
10234
|
* @since 4.0.0
|
|
9810
|
-
* @category
|
|
10235
|
+
* @category Context
|
|
9811
10236
|
*/
|
|
9812
|
-
export declare const
|
|
10237
|
+
export declare const updateContext: {
|
|
9813
10238
|
/**
|
|
9814
10239
|
* Provides part of the required context while leaving the rest unchanged.
|
|
9815
10240
|
*
|
|
@@ -9820,13 +10245,13 @@ export declare const updateServices: {
|
|
|
9820
10245
|
*
|
|
9821
10246
|
* @example
|
|
9822
10247
|
* ```ts
|
|
9823
|
-
* import { Effect,
|
|
10248
|
+
* import { Effect, Context } from "effect"
|
|
9824
10249
|
*
|
|
9825
10250
|
* // Define services
|
|
9826
|
-
* const Logger =
|
|
10251
|
+
* const Logger = Context.Service<{
|
|
9827
10252
|
* log: (msg: string) => void
|
|
9828
10253
|
* }>("Logger")
|
|
9829
|
-
* const Config =
|
|
10254
|
+
* const Config = Context.Service<{
|
|
9830
10255
|
* name: string
|
|
9831
10256
|
* }>("Config")
|
|
9832
10257
|
*
|
|
@@ -9836,8 +10261,8 @@ export declare const updateServices: {
|
|
|
9836
10261
|
*
|
|
9837
10262
|
* // Transform services by providing Config while keeping Logger requirement
|
|
9838
10263
|
* const configured = program.pipe(
|
|
9839
|
-
* Effect.
|
|
9840
|
-
*
|
|
10264
|
+
* Effect.updateContext((context: Context.Context<typeof Logger>) =>
|
|
10265
|
+
* Context.add(context, Config, { name: "World" })
|
|
9841
10266
|
* )
|
|
9842
10267
|
* )
|
|
9843
10268
|
*
|
|
@@ -9848,9 +10273,9 @@ export declare const updateServices: {
|
|
|
9848
10273
|
* ```
|
|
9849
10274
|
*
|
|
9850
10275
|
* @since 4.0.0
|
|
9851
|
-
* @category
|
|
10276
|
+
* @category Context
|
|
9852
10277
|
*/
|
|
9853
|
-
<R2, R>(f: (
|
|
10278
|
+
<R2, R>(f: (context: Context.Context<R2>) => Context.Context<NoInfer<R>>): <A, E>(self: Effect<A, E, R>) => Effect<A, E, R2>;
|
|
9854
10279
|
/**
|
|
9855
10280
|
* Provides part of the required context while leaving the rest unchanged.
|
|
9856
10281
|
*
|
|
@@ -9861,13 +10286,13 @@ export declare const updateServices: {
|
|
|
9861
10286
|
*
|
|
9862
10287
|
* @example
|
|
9863
10288
|
* ```ts
|
|
9864
|
-
* import { Effect,
|
|
10289
|
+
* import { Effect, Context } from "effect"
|
|
9865
10290
|
*
|
|
9866
10291
|
* // Define services
|
|
9867
|
-
* const Logger =
|
|
10292
|
+
* const Logger = Context.Service<{
|
|
9868
10293
|
* log: (msg: string) => void
|
|
9869
10294
|
* }>("Logger")
|
|
9870
|
-
* const Config =
|
|
10295
|
+
* const Config = Context.Service<{
|
|
9871
10296
|
* name: string
|
|
9872
10297
|
* }>("Config")
|
|
9873
10298
|
*
|
|
@@ -9877,8 +10302,8 @@ export declare const updateServices: {
|
|
|
9877
10302
|
*
|
|
9878
10303
|
* // Transform services by providing Config while keeping Logger requirement
|
|
9879
10304
|
* const configured = program.pipe(
|
|
9880
|
-
* Effect.
|
|
9881
|
-
*
|
|
10305
|
+
* Effect.updateContext((context: Context.Context<typeof Logger>) =>
|
|
10306
|
+
* Context.add(context, Config, { name: "World" })
|
|
9882
10307
|
* )
|
|
9883
10308
|
* )
|
|
9884
10309
|
*
|
|
@@ -9889,19 +10314,19 @@ export declare const updateServices: {
|
|
|
9889
10314
|
* ```
|
|
9890
10315
|
*
|
|
9891
10316
|
* @since 4.0.0
|
|
9892
|
-
* @category
|
|
10317
|
+
* @category Context
|
|
9893
10318
|
*/
|
|
9894
|
-
<A, E, R, R2>(self: Effect<A, E, R>, f: (
|
|
10319
|
+
<A, E, R, R2>(self: Effect<A, E, R>, f: (context: Context.Context<R2>) => Context.Context<NoInfer<R>>): Effect<A, E, R2>;
|
|
9895
10320
|
};
|
|
9896
10321
|
/**
|
|
9897
10322
|
* Updates the service with the required service entry.
|
|
9898
10323
|
*
|
|
9899
10324
|
* @example
|
|
9900
10325
|
* ```ts
|
|
9901
|
-
* import { Console, Effect,
|
|
10326
|
+
* import { Console, Effect, Context } from "effect"
|
|
9902
10327
|
*
|
|
9903
10328
|
* // Define a counter service
|
|
9904
|
-
* const Counter =
|
|
10329
|
+
* const Counter = Context.Service<{ count: number }>("Counter")
|
|
9905
10330
|
*
|
|
9906
10331
|
* const program = Effect.gen(function*() {
|
|
9907
10332
|
* const updatedCounter = yield* Effect.service(Counter)
|
|
@@ -9919,7 +10344,7 @@ export declare const updateServices: {
|
|
|
9919
10344
|
* ```
|
|
9920
10345
|
*
|
|
9921
10346
|
* @since 2.0.0
|
|
9922
|
-
* @category
|
|
10347
|
+
* @category Context
|
|
9923
10348
|
*/
|
|
9924
10349
|
export declare const updateService: {
|
|
9925
10350
|
/**
|
|
@@ -9927,10 +10352,10 @@ export declare const updateService: {
|
|
|
9927
10352
|
*
|
|
9928
10353
|
* @example
|
|
9929
10354
|
* ```ts
|
|
9930
|
-
* import { Console, Effect,
|
|
10355
|
+
* import { Console, Effect, Context } from "effect"
|
|
9931
10356
|
*
|
|
9932
10357
|
* // Define a counter service
|
|
9933
|
-
* const Counter =
|
|
10358
|
+
* const Counter = Context.Service<{ count: number }>("Counter")
|
|
9934
10359
|
*
|
|
9935
10360
|
* const program = Effect.gen(function*() {
|
|
9936
10361
|
* const updatedCounter = yield* Effect.service(Counter)
|
|
@@ -9948,18 +10373,18 @@ export declare const updateService: {
|
|
|
9948
10373
|
* ```
|
|
9949
10374
|
*
|
|
9950
10375
|
* @since 2.0.0
|
|
9951
|
-
* @category
|
|
10376
|
+
* @category Context
|
|
9952
10377
|
*/
|
|
9953
|
-
<I, A>(service:
|
|
10378
|
+
<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
10379
|
/**
|
|
9955
10380
|
* Updates the service with the required service entry.
|
|
9956
10381
|
*
|
|
9957
10382
|
* @example
|
|
9958
10383
|
* ```ts
|
|
9959
|
-
* import { Console, Effect,
|
|
10384
|
+
* import { Console, Effect, Context } from "effect"
|
|
9960
10385
|
*
|
|
9961
10386
|
* // Define a counter service
|
|
9962
|
-
* const Counter =
|
|
10387
|
+
* const Counter = Context.Service<{ count: number }>("Counter")
|
|
9963
10388
|
*
|
|
9964
10389
|
* const program = Effect.gen(function*() {
|
|
9965
10390
|
* const updatedCounter = yield* Effect.service(Counter)
|
|
@@ -9977,9 +10402,9 @@ export declare const updateService: {
|
|
|
9977
10402
|
* ```
|
|
9978
10403
|
*
|
|
9979
10404
|
* @since 2.0.0
|
|
9980
|
-
* @category
|
|
10405
|
+
* @category Context
|
|
9981
10406
|
*/
|
|
9982
|
-
<XA, E, R, I, A>(self: Effect<XA, E, R>, service:
|
|
10407
|
+
<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
10408
|
};
|
|
9984
10409
|
/**
|
|
9985
10410
|
* The `provideService` function is used to provide an actual
|
|
@@ -9995,10 +10420,10 @@ export declare const updateService: {
|
|
|
9995
10420
|
*
|
|
9996
10421
|
* @example
|
|
9997
10422
|
* ```ts
|
|
9998
|
-
* import { Console, Effect,
|
|
10423
|
+
* import { Console, Effect, Context } from "effect"
|
|
9999
10424
|
*
|
|
10000
10425
|
* // Define a service for configuration
|
|
10001
|
-
* const Config =
|
|
10426
|
+
* const Config = Context.Service<{
|
|
10002
10427
|
* apiUrl: string
|
|
10003
10428
|
* timeout: number
|
|
10004
10429
|
* }>("Config")
|
|
@@ -10024,7 +10449,7 @@ export declare const updateService: {
|
|
|
10024
10449
|
* ```
|
|
10025
10450
|
*
|
|
10026
10451
|
* @since 2.0.0
|
|
10027
|
-
* @category
|
|
10452
|
+
* @category Context
|
|
10028
10453
|
*/
|
|
10029
10454
|
export declare const provideService: {
|
|
10030
10455
|
/**
|
|
@@ -10041,10 +10466,10 @@ export declare const provideService: {
|
|
|
10041
10466
|
*
|
|
10042
10467
|
* @example
|
|
10043
10468
|
* ```ts
|
|
10044
|
-
* import { Console, Effect,
|
|
10469
|
+
* import { Console, Effect, Context } from "effect"
|
|
10045
10470
|
*
|
|
10046
10471
|
* // Define a service for configuration
|
|
10047
|
-
* const Config =
|
|
10472
|
+
* const Config = Context.Service<{
|
|
10048
10473
|
* apiUrl: string
|
|
10049
10474
|
* timeout: number
|
|
10050
10475
|
* }>("Config")
|
|
@@ -10070,9 +10495,9 @@ export declare const provideService: {
|
|
|
10070
10495
|
* ```
|
|
10071
10496
|
*
|
|
10072
10497
|
* @since 2.0.0
|
|
10073
|
-
* @category
|
|
10498
|
+
* @category Context
|
|
10074
10499
|
*/
|
|
10075
|
-
<I, S>(service:
|
|
10500
|
+
<I, S>(service: Context.Key<I, S>): {
|
|
10076
10501
|
/**
|
|
10077
10502
|
* The `provideService` function is used to provide an actual
|
|
10078
10503
|
* implementation for a service in the context of an effect.
|
|
@@ -10087,10 +10512,10 @@ export declare const provideService: {
|
|
|
10087
10512
|
*
|
|
10088
10513
|
* @example
|
|
10089
10514
|
* ```ts
|
|
10090
|
-
* import { Console, Effect,
|
|
10515
|
+
* import { Console, Effect, Context } from "effect"
|
|
10091
10516
|
*
|
|
10092
10517
|
* // Define a service for configuration
|
|
10093
|
-
* const Config =
|
|
10518
|
+
* const Config = Context.Service<{
|
|
10094
10519
|
* apiUrl: string
|
|
10095
10520
|
* timeout: number
|
|
10096
10521
|
* }>("Config")
|
|
@@ -10116,7 +10541,7 @@ export declare const provideService: {
|
|
|
10116
10541
|
* ```
|
|
10117
10542
|
*
|
|
10118
10543
|
* @since 2.0.0
|
|
10119
|
-
* @category
|
|
10544
|
+
* @category Context
|
|
10120
10545
|
*/
|
|
10121
10546
|
(implementation: S): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, Exclude<R, I>>;
|
|
10122
10547
|
/**
|
|
@@ -10133,10 +10558,10 @@ export declare const provideService: {
|
|
|
10133
10558
|
*
|
|
10134
10559
|
* @example
|
|
10135
10560
|
* ```ts
|
|
10136
|
-
* import { Console, Effect,
|
|
10561
|
+
* import { Console, Effect, Context } from "effect"
|
|
10137
10562
|
*
|
|
10138
10563
|
* // Define a service for configuration
|
|
10139
|
-
* const Config =
|
|
10564
|
+
* const Config = Context.Service<{
|
|
10140
10565
|
* apiUrl: string
|
|
10141
10566
|
* timeout: number
|
|
10142
10567
|
* }>("Config")
|
|
@@ -10162,7 +10587,7 @@ export declare const provideService: {
|
|
|
10162
10587
|
* ```
|
|
10163
10588
|
*
|
|
10164
10589
|
* @since 2.0.0
|
|
10165
|
-
* @category
|
|
10590
|
+
* @category Context
|
|
10166
10591
|
*/
|
|
10167
10592
|
<A, E, R>(self: Effect<A, E, R>, implementation: S): Effect<A, E, Exclude<R, I>>;
|
|
10168
10593
|
};
|
|
@@ -10180,10 +10605,10 @@ export declare const provideService: {
|
|
|
10180
10605
|
*
|
|
10181
10606
|
* @example
|
|
10182
10607
|
* ```ts
|
|
10183
|
-
* import { Console, Effect,
|
|
10608
|
+
* import { Console, Effect, Context } from "effect"
|
|
10184
10609
|
*
|
|
10185
10610
|
* // Define a service for configuration
|
|
10186
|
-
* const Config =
|
|
10611
|
+
* const Config = Context.Service<{
|
|
10187
10612
|
* apiUrl: string
|
|
10188
10613
|
* timeout: number
|
|
10189
10614
|
* }>("Config")
|
|
@@ -10209,9 +10634,9 @@ export declare const provideService: {
|
|
|
10209
10634
|
* ```
|
|
10210
10635
|
*
|
|
10211
10636
|
* @since 2.0.0
|
|
10212
|
-
* @category
|
|
10637
|
+
* @category Context
|
|
10213
10638
|
*/
|
|
10214
|
-
<I, S>(service:
|
|
10639
|
+
<I, S>(service: Context.Key<I, S>, implementation: S): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, Exclude<R, I>>;
|
|
10215
10640
|
/**
|
|
10216
10641
|
* The `provideService` function is used to provide an actual
|
|
10217
10642
|
* implementation for a service in the context of an effect.
|
|
@@ -10226,10 +10651,10 @@ export declare const provideService: {
|
|
|
10226
10651
|
*
|
|
10227
10652
|
* @example
|
|
10228
10653
|
* ```ts
|
|
10229
|
-
* import { Console, Effect,
|
|
10654
|
+
* import { Console, Effect, Context } from "effect"
|
|
10230
10655
|
*
|
|
10231
10656
|
* // Define a service for configuration
|
|
10232
|
-
* const Config =
|
|
10657
|
+
* const Config = Context.Service<{
|
|
10233
10658
|
* apiUrl: string
|
|
10234
10659
|
* timeout: number
|
|
10235
10660
|
* }>("Config")
|
|
@@ -10255,9 +10680,9 @@ export declare const provideService: {
|
|
|
10255
10680
|
* ```
|
|
10256
10681
|
*
|
|
10257
10682
|
* @since 2.0.0
|
|
10258
|
-
* @category
|
|
10683
|
+
* @category Context
|
|
10259
10684
|
*/
|
|
10260
|
-
<A, E, R, I, S>(self: Effect<A, E, R>, service:
|
|
10685
|
+
<A, E, R, I, S>(self: Effect<A, E, R>, service: Context.Key<I, S>, implementation: S): Effect<A, E, Exclude<R, I>>;
|
|
10261
10686
|
};
|
|
10262
10687
|
/**
|
|
10263
10688
|
* Provides the effect with the single service it requires. If the effect
|
|
@@ -10271,13 +10696,13 @@ export declare const provideService: {
|
|
|
10271
10696
|
*
|
|
10272
10697
|
* @example
|
|
10273
10698
|
* ```ts
|
|
10274
|
-
* import { Console, Effect,
|
|
10699
|
+
* import { Console, Effect, Context } from "effect"
|
|
10275
10700
|
*
|
|
10276
10701
|
* // Define a database connection service
|
|
10277
10702
|
* interface DatabaseConnection {
|
|
10278
10703
|
* readonly query: (sql: string) => Effect.Effect<string>
|
|
10279
10704
|
* }
|
|
10280
|
-
* const Database =
|
|
10705
|
+
* const Database = Context.Service<DatabaseConnection>("Database")
|
|
10281
10706
|
*
|
|
10282
10707
|
* // Effect that creates a database connection
|
|
10283
10708
|
* const createConnection = Effect.gen(function*() {
|
|
@@ -10309,7 +10734,7 @@ export declare const provideService: {
|
|
|
10309
10734
|
* ```
|
|
10310
10735
|
*
|
|
10311
10736
|
* @since 2.0.0
|
|
10312
|
-
* @category
|
|
10737
|
+
* @category Context
|
|
10313
10738
|
*/
|
|
10314
10739
|
export declare const provideServiceEffect: {
|
|
10315
10740
|
/**
|
|
@@ -10324,13 +10749,13 @@ export declare const provideServiceEffect: {
|
|
|
10324
10749
|
*
|
|
10325
10750
|
* @example
|
|
10326
10751
|
* ```ts
|
|
10327
|
-
* import { Console, Effect,
|
|
10752
|
+
* import { Console, Effect, Context } from "effect"
|
|
10328
10753
|
*
|
|
10329
10754
|
* // Define a database connection service
|
|
10330
10755
|
* interface DatabaseConnection {
|
|
10331
10756
|
* readonly query: (sql: string) => Effect.Effect<string>
|
|
10332
10757
|
* }
|
|
10333
|
-
* const Database =
|
|
10758
|
+
* const Database = Context.Service<DatabaseConnection>("Database")
|
|
10334
10759
|
*
|
|
10335
10760
|
* // Effect that creates a database connection
|
|
10336
10761
|
* const createConnection = Effect.gen(function*() {
|
|
@@ -10362,9 +10787,9 @@ export declare const provideServiceEffect: {
|
|
|
10362
10787
|
* ```
|
|
10363
10788
|
*
|
|
10364
10789
|
* @since 2.0.0
|
|
10365
|
-
* @category
|
|
10790
|
+
* @category Context
|
|
10366
10791
|
*/
|
|
10367
|
-
<I, S, E2, R2>(service:
|
|
10792
|
+
<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
10793
|
/**
|
|
10369
10794
|
* Provides the effect with the single service it requires. If the effect
|
|
10370
10795
|
* requires more than one service use `provide` instead.
|
|
@@ -10377,13 +10802,13 @@ export declare const provideServiceEffect: {
|
|
|
10377
10802
|
*
|
|
10378
10803
|
* @example
|
|
10379
10804
|
* ```ts
|
|
10380
|
-
* import { Console, Effect,
|
|
10805
|
+
* import { Console, Effect, Context } from "effect"
|
|
10381
10806
|
*
|
|
10382
10807
|
* // Define a database connection service
|
|
10383
10808
|
* interface DatabaseConnection {
|
|
10384
10809
|
* readonly query: (sql: string) => Effect.Effect<string>
|
|
10385
10810
|
* }
|
|
10386
|
-
* const Database =
|
|
10811
|
+
* const Database = Context.Service<DatabaseConnection>("Database")
|
|
10387
10812
|
*
|
|
10388
10813
|
* // Effect that creates a database connection
|
|
10389
10814
|
* const createConnection = Effect.gen(function*() {
|
|
@@ -10415,9 +10840,9 @@ export declare const provideServiceEffect: {
|
|
|
10415
10840
|
* ```
|
|
10416
10841
|
*
|
|
10417
10842
|
* @since 2.0.0
|
|
10418
|
-
* @category
|
|
10843
|
+
* @category Context
|
|
10419
10844
|
*/
|
|
10420
|
-
<A, E, R, I, S, E2, R2>(self: Effect<A, E, R>, service:
|
|
10845
|
+
<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
10846
|
};
|
|
10422
10847
|
/**
|
|
10423
10848
|
* Sets the concurrency level for parallel operations within an effect.
|
|
@@ -10672,7 +11097,9 @@ export declare const scopedWith: <A, E, R>(f: (scope: Scope) => Effect<A, E, R>)
|
|
|
10672
11097
|
* @since 2.0.0
|
|
10673
11098
|
* @category Resource Management & Finalization
|
|
10674
11099
|
*/
|
|
10675
|
-
export declare const acquireRelease: <A, E, R>(acquire: Effect<A, E, R>, release: (a: A, exit: Exit.Exit<unknown, unknown>) => Effect<unknown
|
|
11100
|
+
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?: {
|
|
11101
|
+
readonly interruptible?: boolean;
|
|
11102
|
+
}) => Effect<A, E, R | R2 | Scope>;
|
|
10676
11103
|
/**
|
|
10677
11104
|
* This function is used to ensure that an `Effect` value that represents the
|
|
10678
11105
|
* acquisition of a resource (for example, opening a file, launching a thread,
|
|
@@ -10914,9 +11341,11 @@ export declare const ensuring: {
|
|
|
10914
11341
|
*
|
|
10915
11342
|
* @example
|
|
10916
11343
|
* ```ts
|
|
10917
|
-
* import { Cause, Console, Effect } from "effect"
|
|
11344
|
+
* import { Cause, Data, Console, Effect } from "effect"
|
|
10918
11345
|
*
|
|
10919
|
-
*
|
|
11346
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
11347
|
+
*
|
|
11348
|
+
* const task = Effect.fail(new TaskError({ message: "Something went wrong" }))
|
|
10920
11349
|
*
|
|
10921
11350
|
* const program = Effect.onError(
|
|
10922
11351
|
* task,
|
|
@@ -10925,8 +11354,8 @@ export declare const ensuring: {
|
|
|
10925
11354
|
*
|
|
10926
11355
|
* Effect.runPromise(program).catch(console.error)
|
|
10927
11356
|
* // Output:
|
|
10928
|
-
* // Cleanup on error:
|
|
10929
|
-
* //
|
|
11357
|
+
* // Cleanup on error: TaskError: Something went wrong
|
|
11358
|
+
* // TaskError: Something went wrong
|
|
10930
11359
|
* ```
|
|
10931
11360
|
*
|
|
10932
11361
|
* @since 2.0.0
|
|
@@ -10939,9 +11368,11 @@ export declare const onError: {
|
|
|
10939
11368
|
*
|
|
10940
11369
|
* @example
|
|
10941
11370
|
* ```ts
|
|
10942
|
-
* import { Cause, Console, Effect } from "effect"
|
|
11371
|
+
* import { Cause, Data, Console, Effect } from "effect"
|
|
10943
11372
|
*
|
|
10944
|
-
*
|
|
11373
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
11374
|
+
*
|
|
11375
|
+
* const task = Effect.fail(new TaskError({ message: "Something went wrong" }))
|
|
10945
11376
|
*
|
|
10946
11377
|
* const program = Effect.onError(
|
|
10947
11378
|
* task,
|
|
@@ -10950,8 +11381,8 @@ export declare const onError: {
|
|
|
10950
11381
|
*
|
|
10951
11382
|
* Effect.runPromise(program).catch(console.error)
|
|
10952
11383
|
* // Output:
|
|
10953
|
-
* // Cleanup on error:
|
|
10954
|
-
* //
|
|
11384
|
+
* // Cleanup on error: TaskError: Something went wrong
|
|
11385
|
+
* // TaskError: Something went wrong
|
|
10955
11386
|
* ```
|
|
10956
11387
|
*
|
|
10957
11388
|
* @since 2.0.0
|
|
@@ -10964,9 +11395,11 @@ export declare const onError: {
|
|
|
10964
11395
|
*
|
|
10965
11396
|
* @example
|
|
10966
11397
|
* ```ts
|
|
10967
|
-
* import { Cause, Console, Effect } from "effect"
|
|
11398
|
+
* import { Cause, Data, Console, Effect } from "effect"
|
|
10968
11399
|
*
|
|
10969
|
-
*
|
|
11400
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
11401
|
+
*
|
|
11402
|
+
* const task = Effect.fail(new TaskError({ message: "Something went wrong" }))
|
|
10970
11403
|
*
|
|
10971
11404
|
* const program = Effect.onError(
|
|
10972
11405
|
* task,
|
|
@@ -10975,8 +11408,8 @@ export declare const onError: {
|
|
|
10975
11408
|
*
|
|
10976
11409
|
* Effect.runPromise(program).catch(console.error)
|
|
10977
11410
|
* // Output:
|
|
10978
|
-
* // Cleanup on error:
|
|
10979
|
-
* //
|
|
11411
|
+
* // Cleanup on error: TaskError: Something went wrong
|
|
11412
|
+
* // TaskError: Something went wrong
|
|
10980
11413
|
* ```
|
|
10981
11414
|
*
|
|
10982
11415
|
* @since 2.0.0
|
|
@@ -10986,7 +11419,7 @@ export declare const onError: {
|
|
|
10986
11419
|
};
|
|
10987
11420
|
/**
|
|
10988
11421
|
* Runs the finalizer only when this effect fails and the `Cause` matches the
|
|
10989
|
-
*
|
|
11422
|
+
* provided predicate.
|
|
10990
11423
|
*
|
|
10991
11424
|
* @example
|
|
10992
11425
|
* ```ts
|
|
@@ -11010,7 +11443,7 @@ export declare const onError: {
|
|
|
11010
11443
|
export declare const onErrorIf: {
|
|
11011
11444
|
/**
|
|
11012
11445
|
* Runs the finalizer only when this effect fails and the `Cause` matches the
|
|
11013
|
-
*
|
|
11446
|
+
* provided predicate.
|
|
11014
11447
|
*
|
|
11015
11448
|
* @example
|
|
11016
11449
|
* ```ts
|
|
@@ -11031,10 +11464,10 @@ export declare const onErrorIf: {
|
|
|
11031
11464
|
* @since 4.0.0
|
|
11032
11465
|
* @category Resource Management & Finalization
|
|
11033
11466
|
*/
|
|
11034
|
-
<E,
|
|
11467
|
+
<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
11468
|
/**
|
|
11036
11469
|
* Runs the finalizer only when this effect fails and the `Cause` matches the
|
|
11037
|
-
*
|
|
11470
|
+
* provided predicate.
|
|
11038
11471
|
*
|
|
11039
11472
|
* @example
|
|
11040
11473
|
* ```ts
|
|
@@ -11055,7 +11488,29 @@ export declare const onErrorIf: {
|
|
|
11055
11488
|
* @since 4.0.0
|
|
11056
11489
|
* @category Resource Management & Finalization
|
|
11057
11490
|
*/
|
|
11058
|
-
<A, E, R, XE, XR
|
|
11491
|
+
<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>;
|
|
11492
|
+
};
|
|
11493
|
+
/**
|
|
11494
|
+
* Runs the finalizer only when this effect fails and the cause matches the provided `Filter`.
|
|
11495
|
+
*
|
|
11496
|
+
* @since 4.0.0
|
|
11497
|
+
* @category Resource Management & Finalization
|
|
11498
|
+
*/
|
|
11499
|
+
export declare const onErrorFilter: {
|
|
11500
|
+
/**
|
|
11501
|
+
* Runs the finalizer only when this effect fails and the cause matches the provided `Filter`.
|
|
11502
|
+
*
|
|
11503
|
+
* @since 4.0.0
|
|
11504
|
+
* @category Resource Management & Finalization
|
|
11505
|
+
*/
|
|
11506
|
+
<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>;
|
|
11507
|
+
/**
|
|
11508
|
+
* Runs the finalizer only when this effect fails and the cause matches the provided `Filter`.
|
|
11509
|
+
*
|
|
11510
|
+
* @since 4.0.0
|
|
11511
|
+
* @category Resource Management & Finalization
|
|
11512
|
+
*/
|
|
11513
|
+
<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
11514
|
};
|
|
11060
11515
|
/**
|
|
11061
11516
|
* The low level primitive that powers `onExit`.
|
|
@@ -11149,20 +11604,20 @@ export declare const onExit: {
|
|
|
11149
11604
|
<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
11605
|
};
|
|
11151
11606
|
/**
|
|
11152
|
-
* Runs the cleanup effect only when the `Exit`
|
|
11153
|
-
*
|
|
11154
|
-
* The cleanup is skipped when the filter returns `Filter.fail`.
|
|
11607
|
+
* Runs the cleanup effect only when the `Exit` satisfies the provided
|
|
11608
|
+
* predicate.
|
|
11155
11609
|
*
|
|
11156
11610
|
* @example
|
|
11157
11611
|
* ```ts
|
|
11158
|
-
* import { Console, Effect, Exit
|
|
11159
|
-
*
|
|
11160
|
-
* const exitFilter = Filter.fromPredicate(Exit.isSuccess<number, never>)
|
|
11612
|
+
* import { Console, Effect, Exit } from "effect"
|
|
11161
11613
|
*
|
|
11162
11614
|
* const program = Effect.onExitIf(
|
|
11163
11615
|
* Effect.succeed(42),
|
|
11164
|
-
*
|
|
11165
|
-
* (
|
|
11616
|
+
* Exit.isSuccess,
|
|
11617
|
+
* (exit) =>
|
|
11618
|
+
* Exit.isSuccess(exit)
|
|
11619
|
+
* ? Console.log(`Succeeded with: ${exit.value}`)
|
|
11620
|
+
* : Effect.void
|
|
11166
11621
|
* )
|
|
11167
11622
|
* ```
|
|
11168
11623
|
*
|
|
@@ -11171,49 +11626,71 @@ export declare const onExit: {
|
|
|
11171
11626
|
*/
|
|
11172
11627
|
export declare const onExitIf: {
|
|
11173
11628
|
/**
|
|
11174
|
-
* Runs the cleanup effect only when the `Exit`
|
|
11175
|
-
*
|
|
11176
|
-
* The cleanup is skipped when the filter returns `Filter.fail`.
|
|
11629
|
+
* Runs the cleanup effect only when the `Exit` satisfies the provided
|
|
11630
|
+
* predicate.
|
|
11177
11631
|
*
|
|
11178
11632
|
* @example
|
|
11179
11633
|
* ```ts
|
|
11180
|
-
* import { Console, Effect, Exit
|
|
11181
|
-
*
|
|
11182
|
-
* const exitFilter = Filter.fromPredicate(Exit.isSuccess<number, never>)
|
|
11634
|
+
* import { Console, Effect, Exit } from "effect"
|
|
11183
11635
|
*
|
|
11184
11636
|
* const program = Effect.onExitIf(
|
|
11185
11637
|
* Effect.succeed(42),
|
|
11186
|
-
*
|
|
11187
|
-
* (
|
|
11638
|
+
* Exit.isSuccess,
|
|
11639
|
+
* (exit) =>
|
|
11640
|
+
* Exit.isSuccess(exit)
|
|
11641
|
+
* ? Console.log(`Succeeded with: ${exit.value}`)
|
|
11642
|
+
* : Effect.void
|
|
11188
11643
|
* )
|
|
11189
11644
|
* ```
|
|
11190
11645
|
*
|
|
11191
11646
|
* @since 4.0.0
|
|
11192
11647
|
* @category Resource Management & Finalization
|
|
11193
11648
|
*/
|
|
11194
|
-
<A, E, XE, XR
|
|
11649
|
+
<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
11650
|
/**
|
|
11196
|
-
* Runs the cleanup effect only when the `Exit`
|
|
11197
|
-
*
|
|
11198
|
-
* The cleanup is skipped when the filter returns `Filter.fail`.
|
|
11651
|
+
* Runs the cleanup effect only when the `Exit` satisfies the provided
|
|
11652
|
+
* predicate.
|
|
11199
11653
|
*
|
|
11200
11654
|
* @example
|
|
11201
11655
|
* ```ts
|
|
11202
|
-
* import { Console, Effect, Exit
|
|
11203
|
-
*
|
|
11204
|
-
* const exitFilter = Filter.fromPredicate(Exit.isSuccess<number, never>)
|
|
11656
|
+
* import { Console, Effect, Exit } from "effect"
|
|
11205
11657
|
*
|
|
11206
11658
|
* const program = Effect.onExitIf(
|
|
11207
11659
|
* Effect.succeed(42),
|
|
11208
|
-
*
|
|
11209
|
-
* (
|
|
11660
|
+
* Exit.isSuccess,
|
|
11661
|
+
* (exit) =>
|
|
11662
|
+
* Exit.isSuccess(exit)
|
|
11663
|
+
* ? Console.log(`Succeeded with: ${exit.value}`)
|
|
11664
|
+
* : Effect.void
|
|
11210
11665
|
* )
|
|
11211
11666
|
* ```
|
|
11212
11667
|
*
|
|
11213
11668
|
* @since 4.0.0
|
|
11214
11669
|
* @category Resource Management & Finalization
|
|
11215
11670
|
*/
|
|
11216
|
-
<A, E, R, XE, XR
|
|
11671
|
+
<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>;
|
|
11672
|
+
};
|
|
11673
|
+
/**
|
|
11674
|
+
* Runs the cleanup effect only when the `Exit` matches the provided `Filter`.
|
|
11675
|
+
*
|
|
11676
|
+
* @since 4.0.0
|
|
11677
|
+
* @category Resource Management & Finalization
|
|
11678
|
+
*/
|
|
11679
|
+
export declare const onExitFilter: {
|
|
11680
|
+
/**
|
|
11681
|
+
* Runs the cleanup effect only when the `Exit` matches the provided `Filter`.
|
|
11682
|
+
*
|
|
11683
|
+
* @since 4.0.0
|
|
11684
|
+
* @category Resource Management & Finalization
|
|
11685
|
+
*/
|
|
11686
|
+
<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>;
|
|
11687
|
+
/**
|
|
11688
|
+
* Runs the cleanup effect only when the `Exit` matches the provided `Filter`.
|
|
11689
|
+
*
|
|
11690
|
+
* @since 4.0.0
|
|
11691
|
+
* @category Resource Management & Finalization
|
|
11692
|
+
*/
|
|
11693
|
+
<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
11694
|
};
|
|
11218
11695
|
/**
|
|
11219
11696
|
* Returns an effect that lazily computes a result and caches it for subsequent
|
|
@@ -11412,7 +11889,7 @@ export declare const cachedWithTTL: {
|
|
|
11412
11889
|
* @since 2.0.0
|
|
11413
11890
|
* @category Caching
|
|
11414
11891
|
*/
|
|
11415
|
-
(timeToLive: Duration.
|
|
11892
|
+
(timeToLive: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<Effect<A, E, R>>;
|
|
11416
11893
|
/**
|
|
11417
11894
|
* Returns an effect that caches its result for a specified `Duration`,
|
|
11418
11895
|
* known as "timeToLive" (TTL).
|
|
@@ -11479,7 +11956,7 @@ export declare const cachedWithTTL: {
|
|
|
11479
11956
|
* @since 2.0.0
|
|
11480
11957
|
* @category Caching
|
|
11481
11958
|
*/
|
|
11482
|
-
<A, E, R>(self: Effect<A, E, R>, timeToLive: Duration.
|
|
11959
|
+
<A, E, R>(self: Effect<A, E, R>, timeToLive: Duration.Input): Effect<Effect<A, E, R>>;
|
|
11483
11960
|
};
|
|
11484
11961
|
/**
|
|
11485
11962
|
* Caches an effect's result for a specified duration and allows manual
|
|
@@ -11620,7 +12097,7 @@ export declare const cachedInvalidateWithTTL: {
|
|
|
11620
12097
|
* @since 2.0.0
|
|
11621
12098
|
* @category Caching
|
|
11622
12099
|
*/
|
|
11623
|
-
(timeToLive: Duration.
|
|
12100
|
+
(timeToLive: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<[Effect<A, E, R>, Effect<void>]>;
|
|
11624
12101
|
/**
|
|
11625
12102
|
* Caches an effect's result for a specified duration and allows manual
|
|
11626
12103
|
* invalidation before expiration.
|
|
@@ -11690,7 +12167,7 @@ export declare const cachedInvalidateWithTTL: {
|
|
|
11690
12167
|
* @since 2.0.0
|
|
11691
12168
|
* @category Caching
|
|
11692
12169
|
*/
|
|
11693
|
-
<A, E, R>(self: Effect<A, E, R>, timeToLive: Duration.
|
|
12170
|
+
<A, E, R>(self: Effect<A, E, R>, timeToLive: Duration.Input): Effect<[Effect<A, E, R>, Effect<void>]>;
|
|
11694
12171
|
};
|
|
11695
12172
|
/**
|
|
11696
12173
|
* Returns an effect that is immediately interrupted.
|
|
@@ -11700,8 +12177,8 @@ export declare const cachedInvalidateWithTTL: {
|
|
|
11700
12177
|
* import { Effect } from "effect"
|
|
11701
12178
|
*
|
|
11702
12179
|
* const program = Effect.gen(function*() {
|
|
11703
|
-
* yield* Effect.interrupt
|
|
11704
|
-
* yield* Effect.succeed("This won't execute")
|
|
12180
|
+
* return yield* Effect.interrupt
|
|
12181
|
+
* yield* Effect.succeed("This won't execute and is unreachable")
|
|
11705
12182
|
* })
|
|
11706
12183
|
*
|
|
11707
12184
|
* Effect.runPromise(program).catch(console.error)
|
|
@@ -11890,6 +12367,13 @@ export declare const uninterruptibleMask: <A, E, R>(f: (restore: <AX, EX, RX>(ef
|
|
|
11890
12367
|
* @category Interruption
|
|
11891
12368
|
*/
|
|
11892
12369
|
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>;
|
|
12370
|
+
/**
|
|
12371
|
+
* Creates an AbortSignal that is managed by the provided scope.
|
|
12372
|
+
*
|
|
12373
|
+
* @since 4.0.0
|
|
12374
|
+
* @category Interruption
|
|
12375
|
+
*/
|
|
12376
|
+
export declare const abortSignal: Effect<AbortSignal, never, Scope>;
|
|
11893
12377
|
/**
|
|
11894
12378
|
* @since 2.0.0
|
|
11895
12379
|
* @category Repetition / Recursion
|
|
@@ -11918,10 +12402,10 @@ export declare namespace Repeat {
|
|
|
11918
12402
|
* ```
|
|
11919
12403
|
*/
|
|
11920
12404
|
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
12405
|
until: Predicate.Refinement<A, infer B>;
|
|
11924
|
-
} ? B :
|
|
12406
|
+
} ? B : O extends {
|
|
12407
|
+
while: Predicate.Refinement<A, infer B>;
|
|
12408
|
+
} ? Exclude<A, B> : A, E | (O extends {
|
|
11925
12409
|
schedule: Schedule<infer _Out, infer _I, infer E, infer _R>;
|
|
11926
12410
|
} ? E : never) | (O extends {
|
|
11927
12411
|
while: (...args: Array<any>) => Effect<infer _A, infer E, infer _R>;
|
|
@@ -12470,7 +12954,7 @@ export declare const repeat: {
|
|
|
12470
12954
|
* attempt++
|
|
12471
12955
|
* if (attempt <= 2) {
|
|
12472
12956
|
* yield* Console.log(`Attempt ${attempt} failed`)
|
|
12473
|
-
* yield* Effect.fail(`Error ${attempt}`)
|
|
12957
|
+
* return yield* Effect.fail(`Error ${attempt}`)
|
|
12474
12958
|
* }
|
|
12475
12959
|
* yield* Console.log(`Attempt ${attempt} succeeded`)
|
|
12476
12960
|
* return "success"
|
|
@@ -12520,7 +13004,7 @@ export declare const repeatOrElse: {
|
|
|
12520
13004
|
* attempt++
|
|
12521
13005
|
* if (attempt <= 2) {
|
|
12522
13006
|
* yield* Console.log(`Attempt ${attempt} failed`)
|
|
12523
|
-
* yield* Effect.fail(`Error ${attempt}`)
|
|
13007
|
+
* return yield* Effect.fail(`Error ${attempt}`)
|
|
12524
13008
|
* }
|
|
12525
13009
|
* yield* Console.log(`Attempt ${attempt} succeeded`)
|
|
12526
13010
|
* return "success"
|
|
@@ -12570,7 +13054,7 @@ export declare const repeatOrElse: {
|
|
|
12570
13054
|
* attempt++
|
|
12571
13055
|
* if (attempt <= 2) {
|
|
12572
13056
|
* yield* Console.log(`Attempt ${attempt} failed`)
|
|
12573
|
-
* yield* Effect.fail(`Error ${attempt}`)
|
|
13057
|
+
* return yield* Effect.fail(`Error ${attempt}`)
|
|
12574
13058
|
* }
|
|
12575
13059
|
* yield* Console.log(`Attempt ${attempt} succeeded`)
|
|
12576
13060
|
* return "success"
|
|
@@ -13969,7 +14453,7 @@ export declare const withParentSpan: {
|
|
|
13969
14453
|
* )
|
|
13970
14454
|
*
|
|
13971
14455
|
* const program = Effect.gen(function*() {
|
|
13972
|
-
* const name = yield* Effect.request(GetUser({ id: 1 }),
|
|
14456
|
+
* const name = yield* Effect.request(GetUser({ id: 1 }), resolver)
|
|
13973
14457
|
* yield* Console.log(name)
|
|
13974
14458
|
* })
|
|
13975
14459
|
* ```
|
|
@@ -14000,7 +14484,7 @@ export declare const request: {
|
|
|
14000
14484
|
* )
|
|
14001
14485
|
*
|
|
14002
14486
|
* const program = Effect.gen(function*() {
|
|
14003
|
-
* const name = yield* Effect.request(GetUser({ id: 1 }),
|
|
14487
|
+
* const name = yield* Effect.request(GetUser({ id: 1 }), resolver)
|
|
14004
14488
|
* yield* Console.log(name)
|
|
14005
14489
|
* })
|
|
14006
14490
|
* ```
|
|
@@ -14031,7 +14515,7 @@ export declare const request: {
|
|
|
14031
14515
|
* )
|
|
14032
14516
|
*
|
|
14033
14517
|
* const program = Effect.gen(function*() {
|
|
14034
|
-
* const name = yield* Effect.request(GetUser({ id: 1 }),
|
|
14518
|
+
* const name = yield* Effect.request(GetUser({ id: 1 }), resolver)
|
|
14035
14519
|
* yield* Console.log(name)
|
|
14036
14520
|
* })
|
|
14037
14521
|
* ```
|
|
@@ -14040,7 +14524,7 @@ export declare const request: {
|
|
|
14040
14524
|
};
|
|
14041
14525
|
/**
|
|
14042
14526
|
* 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 `
|
|
14527
|
+
* Use this when you already have a `Context` and need to enqueue a request outside an `Effect`.
|
|
14044
14528
|
*
|
|
14045
14529
|
* It returns a canceler that removes the pending request entry.
|
|
14046
14530
|
*
|
|
@@ -14050,7 +14534,7 @@ export declare const request: {
|
|
|
14050
14534
|
export declare const requestUnsafe: <A extends Request.Any>(self: A, options: {
|
|
14051
14535
|
readonly resolver: RequestResolver<A>;
|
|
14052
14536
|
readonly onExit: (exit: Exit.Exit<Request.Success<A>, Request.Error<A>>) => void;
|
|
14053
|
-
readonly
|
|
14537
|
+
readonly context: Context.Context<never>;
|
|
14054
14538
|
}) => () => void;
|
|
14055
14539
|
/**
|
|
14056
14540
|
* Returns an effect that forks this effect into its own separate fiber,
|
|
@@ -14240,7 +14724,7 @@ export declare const forkScoped: <Arg extends Effect<any, any, any> | {
|
|
|
14240
14724
|
}>(effectOrOptions?: Arg, options?: {
|
|
14241
14725
|
readonly startImmediately?: boolean | undefined;
|
|
14242
14726
|
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>;
|
|
14727
|
+
} | 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
14728
|
/**
|
|
14245
14729
|
* Forks the effect into a new fiber attached to the global scope. Because the
|
|
14246
14730
|
* new fiber is attached to the global scope, when the fiber executing the
|
|
@@ -14360,6 +14844,7 @@ export interface RunOptions {
|
|
|
14360
14844
|
readonly signal?: AbortSignal | undefined;
|
|
14361
14845
|
readonly scheduler?: Scheduler | undefined;
|
|
14362
14846
|
readonly uninterruptible?: boolean | undefined;
|
|
14847
|
+
readonly onFiberStart?: ((fiber: Fiber<unknown, unknown>) => void) | undefined;
|
|
14363
14848
|
}
|
|
14364
14849
|
/**
|
|
14365
14850
|
* The foundational function for running effects, returning a "fiber" that can
|
|
@@ -14407,15 +14892,15 @@ export declare const runFork: <A, E>(effect: Effect<A, E, never>, options?: RunO
|
|
|
14407
14892
|
*
|
|
14408
14893
|
* @example
|
|
14409
14894
|
* ```ts
|
|
14410
|
-
* import { Effect,
|
|
14895
|
+
* import { Effect, Context } from "effect"
|
|
14411
14896
|
*
|
|
14412
14897
|
* interface Logger {
|
|
14413
14898
|
* log: (message: string) => void
|
|
14414
14899
|
* }
|
|
14415
14900
|
*
|
|
14416
|
-
* const Logger =
|
|
14901
|
+
* const Logger = Context.Service<Logger>("Logger")
|
|
14417
14902
|
*
|
|
14418
|
-
* const services =
|
|
14903
|
+
* const services = Context.make(Logger, {
|
|
14419
14904
|
* log: (message) => console.log(message)
|
|
14420
14905
|
* })
|
|
14421
14906
|
*
|
|
@@ -14431,7 +14916,7 @@ export declare const runFork: <A, E>(effect: Effect<A, E, never>, options?: RunO
|
|
|
14431
14916
|
* @since 4.0.0
|
|
14432
14917
|
* @category Running Effects
|
|
14433
14918
|
*/
|
|
14434
|
-
export declare const runForkWith: <R>(
|
|
14919
|
+
export declare const runForkWith: <R>(context: Context.Context<R>) => <A, E>(effect: Effect<A, E, R>, options?: RunOptions | undefined) => Fiber<A, E>;
|
|
14435
14920
|
/**
|
|
14436
14921
|
* Forks an effect with the provided services, registers `onExit` as a fiber observer, and returns an interruptor.
|
|
14437
14922
|
*
|
|
@@ -14439,15 +14924,15 @@ export declare const runForkWith: <R>(services: ServiceMap.ServiceMap<R>) => <A,
|
|
|
14439
14924
|
*
|
|
14440
14925
|
* @example
|
|
14441
14926
|
* ```ts
|
|
14442
|
-
* import { Console, Effect, Exit,
|
|
14927
|
+
* import { Console, Effect, Exit, Context } from "effect"
|
|
14443
14928
|
*
|
|
14444
14929
|
* interface Logger {
|
|
14445
14930
|
* log: (message: string) => Effect.Effect<void>
|
|
14446
14931
|
* }
|
|
14447
14932
|
*
|
|
14448
|
-
* const Logger =
|
|
14933
|
+
* const Logger = Context.Service<Logger>("Logger")
|
|
14449
14934
|
*
|
|
14450
|
-
* const services =
|
|
14935
|
+
* const services = Context.make(Logger, {
|
|
14451
14936
|
* log: (message) => Console.log(message)
|
|
14452
14937
|
* })
|
|
14453
14938
|
*
|
|
@@ -14472,7 +14957,7 @@ export declare const runForkWith: <R>(services: ServiceMap.ServiceMap<R>) => <A,
|
|
|
14472
14957
|
* @since 4.0.0
|
|
14473
14958
|
* @category Running Effects
|
|
14474
14959
|
*/
|
|
14475
|
-
export declare const runCallbackWith: <R>(
|
|
14960
|
+
export declare const runCallbackWith: <R>(context: Context.Context<R>) => <A, E>(effect: Effect<A, E, R>, options?: (RunOptions & {
|
|
14476
14961
|
readonly onExit: (exit: Exit.Exit<A, E>) => void;
|
|
14477
14962
|
}) | undefined) => (interruptor?: number | undefined) => void;
|
|
14478
14963
|
/**
|
|
@@ -14555,15 +15040,15 @@ export declare const runPromise: <A, E>(effect: Effect<A, E>, options?: RunOptio
|
|
|
14555
15040
|
*
|
|
14556
15041
|
* @example
|
|
14557
15042
|
* ```ts
|
|
14558
|
-
* import { Effect,
|
|
15043
|
+
* import { Effect, Context } from "effect"
|
|
14559
15044
|
*
|
|
14560
15045
|
* interface Config {
|
|
14561
15046
|
* apiUrl: string
|
|
14562
15047
|
* }
|
|
14563
15048
|
*
|
|
14564
|
-
* const Config =
|
|
15049
|
+
* const Config = Context.Service<Config>("Config")
|
|
14565
15050
|
*
|
|
14566
|
-
* const
|
|
15051
|
+
* const context = Context.make(Config, {
|
|
14567
15052
|
* apiUrl: "https://api.example.com"
|
|
14568
15053
|
* })
|
|
14569
15054
|
*
|
|
@@ -14572,13 +15057,13 @@ export declare const runPromise: <A, E>(effect: Effect<A, E>, options?: RunOptio
|
|
|
14572
15057
|
* return `Connecting to ${config.apiUrl}`
|
|
14573
15058
|
* })
|
|
14574
15059
|
*
|
|
14575
|
-
* Effect.runPromiseWith(
|
|
15060
|
+
* Effect.runPromiseWith(context)(program).then(console.log)
|
|
14576
15061
|
* ```
|
|
14577
15062
|
*
|
|
14578
15063
|
* @since 4.0.0
|
|
14579
15064
|
* @category Running Effects
|
|
14580
15065
|
*/
|
|
14581
|
-
export declare const runPromiseWith: <R>(
|
|
15066
|
+
export declare const runPromiseWith: <R>(context: Context.Context<R>) => <A, E>(effect: Effect<A, E, R>, options?: RunOptions | undefined) => Promise<A>;
|
|
14582
15067
|
/**
|
|
14583
15068
|
* Runs an effect and returns a `Promise` that resolves to an `Exit`, which
|
|
14584
15069
|
* represents the outcome (success or failure) of the effect.
|
|
@@ -14632,15 +15117,15 @@ export declare const runPromiseExit: <A, E>(effect: Effect<A, E>, options?: RunO
|
|
|
14632
15117
|
*
|
|
14633
15118
|
* @example
|
|
14634
15119
|
* ```ts
|
|
14635
|
-
* import { Effect, Exit,
|
|
15120
|
+
* import { Effect, Exit, Context } from "effect"
|
|
14636
15121
|
*
|
|
14637
15122
|
* interface Database {
|
|
14638
15123
|
* query: (sql: string) => string
|
|
14639
15124
|
* }
|
|
14640
15125
|
*
|
|
14641
|
-
* const Database =
|
|
15126
|
+
* const Database = Context.Service<Database>("Database")
|
|
14642
15127
|
*
|
|
14643
|
-
* const services =
|
|
15128
|
+
* const services = Context.make(Database, {
|
|
14644
15129
|
* query: (sql) => `Result for: ${sql}`
|
|
14645
15130
|
* })
|
|
14646
15131
|
*
|
|
@@ -14659,7 +15144,7 @@ export declare const runPromiseExit: <A, E>(effect: Effect<A, E>, options?: RunO
|
|
|
14659
15144
|
* @since 4.0.0
|
|
14660
15145
|
* @category Running Effects
|
|
14661
15146
|
*/
|
|
14662
|
-
export declare const runPromiseExitWith: <R>(
|
|
15147
|
+
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
15148
|
/**
|
|
14664
15149
|
* Executes an effect synchronously, running it immediately and returning the
|
|
14665
15150
|
* result.
|
|
@@ -14723,15 +15208,15 @@ export declare const runSync: <A, E>(effect: Effect<A, E>) => A;
|
|
|
14723
15208
|
*
|
|
14724
15209
|
* @example
|
|
14725
15210
|
* ```ts
|
|
14726
|
-
* import { Effect,
|
|
15211
|
+
* import { Effect, Context } from "effect"
|
|
14727
15212
|
*
|
|
14728
15213
|
* interface MathService {
|
|
14729
15214
|
* add: (a: number, b: number) => number
|
|
14730
15215
|
* }
|
|
14731
15216
|
*
|
|
14732
|
-
* const MathService =
|
|
15217
|
+
* const MathService = Context.Service<MathService>("MathService")
|
|
14733
15218
|
*
|
|
14734
|
-
* const
|
|
15219
|
+
* const context = Context.make(MathService, {
|
|
14735
15220
|
* add: (a, b) => a + b
|
|
14736
15221
|
* })
|
|
14737
15222
|
*
|
|
@@ -14740,14 +15225,14 @@ export declare const runSync: <A, E>(effect: Effect<A, E>) => A;
|
|
|
14740
15225
|
* return math.add(2, 3)
|
|
14741
15226
|
* })
|
|
14742
15227
|
*
|
|
14743
|
-
* const result = Effect.runSyncWith(
|
|
15228
|
+
* const result = Effect.runSyncWith(context)(program)
|
|
14744
15229
|
* console.log(result) // 5
|
|
14745
15230
|
* ```
|
|
14746
15231
|
*
|
|
14747
15232
|
* @since 4.0.0
|
|
14748
15233
|
* @category Running Effects
|
|
14749
15234
|
*/
|
|
14750
|
-
export declare const runSyncWith: <R>(
|
|
15235
|
+
export declare const runSyncWith: <R>(context: Context.Context<R>) => <A, E>(effect: Effect<A, E, R>) => A;
|
|
14751
15236
|
/**
|
|
14752
15237
|
* Runs an effect synchronously and returns the result as an `Exit` type, which
|
|
14753
15238
|
* represents the outcome (success or failure) of the effect.
|
|
@@ -14823,10 +15308,10 @@ export declare const runSyncExit: <A, E>(effect: Effect<A, E>) => Exit.Exit<A, E
|
|
|
14823
15308
|
*
|
|
14824
15309
|
* @example
|
|
14825
15310
|
* ```ts
|
|
14826
|
-
* import { Effect, Exit,
|
|
15311
|
+
* import { Effect, Exit, Context } from "effect"
|
|
14827
15312
|
*
|
|
14828
15313
|
* // Define a logger service
|
|
14829
|
-
* const Logger =
|
|
15314
|
+
* const Logger = Context.Service<{
|
|
14830
15315
|
* log: (msg: string) => void
|
|
14831
15316
|
* }>("Logger")
|
|
14832
15317
|
*
|
|
@@ -14836,12 +15321,12 @@ export declare const runSyncExit: <A, E>(effect: Effect<A, E>) => Exit.Exit<A, E
|
|
|
14836
15321
|
* return 42
|
|
14837
15322
|
* })
|
|
14838
15323
|
*
|
|
14839
|
-
* // Prepare
|
|
14840
|
-
* const
|
|
15324
|
+
* // Prepare context
|
|
15325
|
+
* const context = Context.make(Logger, {
|
|
14841
15326
|
* log: (msg) => console.log(`[LOG] ${msg}`)
|
|
14842
15327
|
* })
|
|
14843
15328
|
*
|
|
14844
|
-
* const exit = Effect.runSyncExitWith(
|
|
15329
|
+
* const exit = Effect.runSyncExitWith(context)(program)
|
|
14845
15330
|
*
|
|
14846
15331
|
* if (Exit.isSuccess(exit)) {
|
|
14847
15332
|
* console.log(`Success: ${exit.value}`)
|
|
@@ -14856,7 +15341,7 @@ export declare const runSyncExit: <A, E>(effect: Effect<A, E>) => Exit.Exit<A, E
|
|
|
14856
15341
|
* @since 4.0.0
|
|
14857
15342
|
* @category Running Effects
|
|
14858
15343
|
*/
|
|
14859
|
-
export declare const runSyncExitWith: <R>(
|
|
15344
|
+
export declare const runSyncExitWith: <R>(context: Context.Context<R>) => <A, E>(effect: Effect<A, E, R>) => Exit.Exit<A, E>;
|
|
14860
15345
|
/**
|
|
14861
15346
|
* Type helpers for functions built with `Effect.fn` and `Effect.fnUntraced`.
|
|
14862
15347
|
*
|
|
@@ -15546,7 +16031,7 @@ export declare const clockWith: <A, E, R>(f: (clock: Clock) => Effect<A, E, R>)
|
|
|
15546
16031
|
* @since 2.0.0
|
|
15547
16032
|
* @category Logging
|
|
15548
16033
|
*/
|
|
15549
|
-
export declare const logWithLevel: (level?:
|
|
16034
|
+
export declare const logWithLevel: (level?: Severity) => (...message: ReadonlyArray<any>) => Effect<void>;
|
|
15550
16035
|
/**
|
|
15551
16036
|
* Logs one or more messages using the default log level.
|
|
15552
16037
|
*
|
|
@@ -15813,6 +16298,85 @@ export declare const annotateLogs: {
|
|
|
15813
16298
|
<A, E, R>(effect: Effect<A, E, R>, key: string, value: unknown): Effect<A, E, R>;
|
|
15814
16299
|
<A, E, R>(effect: Effect<A, E, R>, values: Record<string, unknown>): Effect<A, E, R>;
|
|
15815
16300
|
};
|
|
16301
|
+
/**
|
|
16302
|
+
* Adds log annotations to the current scope.
|
|
16303
|
+
*
|
|
16304
|
+
* This differs from `annotateLogs`, which only annotates a specific effect.
|
|
16305
|
+
* `annotateLogsScoped` updates annotations for the entire current `Scope` and
|
|
16306
|
+
* restores the previous annotations when the scope closes.
|
|
16307
|
+
*
|
|
16308
|
+
* @example
|
|
16309
|
+
* ```ts
|
|
16310
|
+
* import { Effect } from "effect"
|
|
16311
|
+
*
|
|
16312
|
+
* const program = Effect.scoped(
|
|
16313
|
+
* Effect.gen(function*() {
|
|
16314
|
+
* yield* Effect.log("before")
|
|
16315
|
+
* yield* Effect.annotateLogsScoped({ requestId: "req-123" })
|
|
16316
|
+
* yield* Effect.log("inside scope")
|
|
16317
|
+
* })
|
|
16318
|
+
* )
|
|
16319
|
+
*
|
|
16320
|
+
* Effect.runPromise(program)
|
|
16321
|
+
* ```
|
|
16322
|
+
*
|
|
16323
|
+
* @since 4.0.0
|
|
16324
|
+
* @category Logging
|
|
16325
|
+
*/
|
|
16326
|
+
export declare const annotateLogsScoped: {
|
|
16327
|
+
/**
|
|
16328
|
+
* Adds log annotations to the current scope.
|
|
16329
|
+
*
|
|
16330
|
+
* This differs from `annotateLogs`, which only annotates a specific effect.
|
|
16331
|
+
* `annotateLogsScoped` updates annotations for the entire current `Scope` and
|
|
16332
|
+
* restores the previous annotations when the scope closes.
|
|
16333
|
+
*
|
|
16334
|
+
* @example
|
|
16335
|
+
* ```ts
|
|
16336
|
+
* import { Effect } from "effect"
|
|
16337
|
+
*
|
|
16338
|
+
* const program = Effect.scoped(
|
|
16339
|
+
* Effect.gen(function*() {
|
|
16340
|
+
* yield* Effect.log("before")
|
|
16341
|
+
* yield* Effect.annotateLogsScoped({ requestId: "req-123" })
|
|
16342
|
+
* yield* Effect.log("inside scope")
|
|
16343
|
+
* })
|
|
16344
|
+
* )
|
|
16345
|
+
*
|
|
16346
|
+
* Effect.runPromise(program)
|
|
16347
|
+
* ```
|
|
16348
|
+
*
|
|
16349
|
+
* @since 4.0.0
|
|
16350
|
+
* @category Logging
|
|
16351
|
+
*/
|
|
16352
|
+
(key: string, value: unknown): Effect<void, never, Scope>;
|
|
16353
|
+
/**
|
|
16354
|
+
* Adds log annotations to the current scope.
|
|
16355
|
+
*
|
|
16356
|
+
* This differs from `annotateLogs`, which only annotates a specific effect.
|
|
16357
|
+
* `annotateLogsScoped` updates annotations for the entire current `Scope` and
|
|
16358
|
+
* restores the previous annotations when the scope closes.
|
|
16359
|
+
*
|
|
16360
|
+
* @example
|
|
16361
|
+
* ```ts
|
|
16362
|
+
* import { Effect } from "effect"
|
|
16363
|
+
*
|
|
16364
|
+
* const program = Effect.scoped(
|
|
16365
|
+
* Effect.gen(function*() {
|
|
16366
|
+
* yield* Effect.log("before")
|
|
16367
|
+
* yield* Effect.annotateLogsScoped({ requestId: "req-123" })
|
|
16368
|
+
* yield* Effect.log("inside scope")
|
|
16369
|
+
* })
|
|
16370
|
+
* )
|
|
16371
|
+
*
|
|
16372
|
+
* Effect.runPromise(program)
|
|
16373
|
+
* ```
|
|
16374
|
+
*
|
|
16375
|
+
* @since 4.0.0
|
|
16376
|
+
* @category Logging
|
|
16377
|
+
*/
|
|
16378
|
+
(values: Record<string, unknown>): Effect<void, never, Scope>;
|
|
16379
|
+
};
|
|
15816
16380
|
/**
|
|
15817
16381
|
* Adds a span to each log line in this effect.
|
|
15818
16382
|
*
|
|
@@ -16348,18 +16912,20 @@ export declare const trackSuccesses: {
|
|
|
16348
16912
|
*
|
|
16349
16913
|
* @example
|
|
16350
16914
|
* ```ts
|
|
16351
|
-
* import { Effect, Metric } from "effect"
|
|
16915
|
+
* import { Data, Effect, Metric } from "effect"
|
|
16916
|
+
*
|
|
16917
|
+
* class ConnectionFailedError extends Data.TaggedError("ConnectionFailedError")<{}> {}
|
|
16352
16918
|
*
|
|
16353
16919
|
* // Track error types using frequency metric
|
|
16354
16920
|
* const errorTypeFrequency = Metric.frequency("error_types")
|
|
16355
16921
|
*
|
|
16356
|
-
* const program = Effect.fail(new
|
|
16357
|
-
* Effect.trackErrors(errorTypeFrequency, (error:
|
|
16922
|
+
* const program = Effect.fail(new ConnectionFailedError()).pipe(
|
|
16923
|
+
* Effect.trackErrors(errorTypeFrequency, (error: ConnectionFailedError) => error._tag)
|
|
16358
16924
|
* )
|
|
16359
16925
|
*
|
|
16360
16926
|
* Effect.runPromiseExit(program).then(() =>
|
|
16361
16927
|
* Effect.runPromise(Metric.value(errorTypeFrequency)).then(console.log)
|
|
16362
|
-
* // Output: { occurrences: Map(1) { "
|
|
16928
|
+
* // Output: { occurrences: Map(1) { "ConnectionFailedError" => 1 } }
|
|
16363
16929
|
* )
|
|
16364
16930
|
* ```
|
|
16365
16931
|
*
|
|
@@ -16394,18 +16960,20 @@ export declare const trackErrors: {
|
|
|
16394
16960
|
*
|
|
16395
16961
|
* @example
|
|
16396
16962
|
* ```ts
|
|
16397
|
-
* import { Effect, Metric } from "effect"
|
|
16963
|
+
* import { Data, Effect, Metric } from "effect"
|
|
16964
|
+
*
|
|
16965
|
+
* class ConnectionFailedError extends Data.TaggedError("ConnectionFailedError")<{}> {}
|
|
16398
16966
|
*
|
|
16399
16967
|
* // Track error types using frequency metric
|
|
16400
16968
|
* const errorTypeFrequency = Metric.frequency("error_types")
|
|
16401
16969
|
*
|
|
16402
|
-
* const program = Effect.fail(new
|
|
16403
|
-
* Effect.trackErrors(errorTypeFrequency, (error:
|
|
16970
|
+
* const program = Effect.fail(new ConnectionFailedError()).pipe(
|
|
16971
|
+
* Effect.trackErrors(errorTypeFrequency, (error: ConnectionFailedError) => error._tag)
|
|
16404
16972
|
* )
|
|
16405
16973
|
*
|
|
16406
16974
|
* Effect.runPromiseExit(program).then(() =>
|
|
16407
16975
|
* Effect.runPromise(Metric.value(errorTypeFrequency)).then(console.log)
|
|
16408
|
-
* // Output: { occurrences: Map(1) { "
|
|
16976
|
+
* // Output: { occurrences: Map(1) { "ConnectionFailedError" => 1 } }
|
|
16409
16977
|
* )
|
|
16410
16978
|
* ```
|
|
16411
16979
|
*
|
|
@@ -16440,18 +17008,20 @@ export declare const trackErrors: {
|
|
|
16440
17008
|
*
|
|
16441
17009
|
* @example
|
|
16442
17010
|
* ```ts
|
|
16443
|
-
* import { Effect, Metric } from "effect"
|
|
17011
|
+
* import { Data, Effect, Metric } from "effect"
|
|
17012
|
+
*
|
|
17013
|
+
* class ConnectionFailedError extends Data.TaggedError("ConnectionFailedError")<{}> {}
|
|
16444
17014
|
*
|
|
16445
17015
|
* // Track error types using frequency metric
|
|
16446
17016
|
* const errorTypeFrequency = Metric.frequency("error_types")
|
|
16447
17017
|
*
|
|
16448
|
-
* const program = Effect.fail(new
|
|
16449
|
-
* Effect.trackErrors(errorTypeFrequency, (error:
|
|
17018
|
+
* const program = Effect.fail(new ConnectionFailedError()).pipe(
|
|
17019
|
+
* Effect.trackErrors(errorTypeFrequency, (error: ConnectionFailedError) => error._tag)
|
|
16450
17020
|
* )
|
|
16451
17021
|
*
|
|
16452
17022
|
* Effect.runPromiseExit(program).then(() =>
|
|
16453
17023
|
* Effect.runPromise(Metric.value(errorTypeFrequency)).then(console.log)
|
|
16454
|
-
* // Output: { occurrences: Map(1) { "
|
|
17024
|
+
* // Output: { occurrences: Map(1) { "ConnectionFailedError" => 1 } }
|
|
16455
17025
|
* )
|
|
16456
17026
|
* ```
|
|
16457
17027
|
*
|
|
@@ -16486,18 +17056,20 @@ export declare const trackErrors: {
|
|
|
16486
17056
|
*
|
|
16487
17057
|
* @example
|
|
16488
17058
|
* ```ts
|
|
16489
|
-
* import { Effect, Metric } from "effect"
|
|
17059
|
+
* import { Data, Effect, Metric } from "effect"
|
|
17060
|
+
*
|
|
17061
|
+
* class ConnectionFailedError extends Data.TaggedError("ConnectionFailedError")<{}> {}
|
|
16490
17062
|
*
|
|
16491
17063
|
* // Track error types using frequency metric
|
|
16492
17064
|
* const errorTypeFrequency = Metric.frequency("error_types")
|
|
16493
17065
|
*
|
|
16494
|
-
* const program = Effect.fail(new
|
|
16495
|
-
* Effect.trackErrors(errorTypeFrequency, (error:
|
|
17066
|
+
* const program = Effect.fail(new ConnectionFailedError()).pipe(
|
|
17067
|
+
* Effect.trackErrors(errorTypeFrequency, (error: ConnectionFailedError) => error._tag)
|
|
16496
17068
|
* )
|
|
16497
17069
|
*
|
|
16498
17070
|
* Effect.runPromiseExit(program).then(() =>
|
|
16499
17071
|
* Effect.runPromise(Metric.value(errorTypeFrequency)).then(console.log)
|
|
16500
|
-
* // Output: { occurrences: Map(1) { "
|
|
17072
|
+
* // Output: { occurrences: Map(1) { "ConnectionFailedError" => 1 } }
|
|
16501
17073
|
* )
|
|
16502
17074
|
* ```
|
|
16503
17075
|
*
|
|
@@ -16532,18 +17104,20 @@ export declare const trackErrors: {
|
|
|
16532
17104
|
*
|
|
16533
17105
|
* @example
|
|
16534
17106
|
* ```ts
|
|
16535
|
-
* import { Effect, Metric } from "effect"
|
|
17107
|
+
* import { Data, Effect, Metric } from "effect"
|
|
17108
|
+
*
|
|
17109
|
+
* class ConnectionFailedError extends Data.TaggedError("ConnectionFailedError")<{}> {}
|
|
16536
17110
|
*
|
|
16537
17111
|
* // Track error types using frequency metric
|
|
16538
17112
|
* const errorTypeFrequency = Metric.frequency("error_types")
|
|
16539
17113
|
*
|
|
16540
|
-
* const program = Effect.fail(new
|
|
16541
|
-
* Effect.trackErrors(errorTypeFrequency, (error:
|
|
17114
|
+
* const program = Effect.fail(new ConnectionFailedError()).pipe(
|
|
17115
|
+
* Effect.trackErrors(errorTypeFrequency, (error: ConnectionFailedError) => error._tag)
|
|
16542
17116
|
* )
|
|
16543
17117
|
*
|
|
16544
17118
|
* Effect.runPromiseExit(program).then(() =>
|
|
16545
17119
|
* Effect.runPromise(Metric.value(errorTypeFrequency)).then(console.log)
|
|
16546
|
-
* // Output: { occurrences: Map(1) { "
|
|
17120
|
+
* // Output: { occurrences: Map(1) { "ConnectionFailedError" => 1 } }
|
|
16547
17121
|
* )
|
|
16548
17122
|
* ```
|
|
16549
17123
|
*
|
|
@@ -17024,7 +17598,7 @@ export declare const trackDuration: {
|
|
|
17024
17598
|
*/
|
|
17025
17599
|
<A, E, R, State>(self: Effect<A, E, R>, metric: Metric.Metric<Duration.Duration, State>): Effect<A, E, R>;
|
|
17026
17600
|
};
|
|
17027
|
-
declare const Transaction_base:
|
|
17601
|
+
declare const Transaction_base: Context.ServiceClass<Transaction, "effect/Effect/Transaction", {
|
|
17028
17602
|
retry: boolean;
|
|
17029
17603
|
readonly journal: Map<TxRef<any>, {
|
|
17030
17604
|
readonly version: number;
|
|
@@ -17055,19 +17629,22 @@ declare const Transaction_base: ServiceMap.ServiceClass<Transaction, "effect/Eff
|
|
|
17055
17629
|
export declare class Transaction extends Transaction_base {
|
|
17056
17630
|
}
|
|
17057
17631
|
/**
|
|
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.
|
|
17632
|
+
* Defines a transaction boundary. Transactions are "all or nothing" with respect to changes
|
|
17633
|
+
* made to transactional values (i.e. TxRef) that occur within the transaction body.
|
|
17634
|
+
*
|
|
17635
|
+
* If called inside an active transaction, `tx` composes with the current transaction and reuses
|
|
17636
|
+
* its journal and retry state instead of creating a nested boundary.
|
|
17060
17637
|
*
|
|
17061
17638
|
* In Effect transactions are optimistic with retry, that means transactions are retried when:
|
|
17062
17639
|
*
|
|
17063
|
-
* - the body of the transaction explicitely calls to `Effect.
|
|
17640
|
+
* - the body of the transaction explicitely calls to `Effect.txRetry` and any of the
|
|
17064
17641
|
* accessed transactional values changes.
|
|
17065
17642
|
*
|
|
17066
17643
|
* - any of the accessed transactional values change during the execution of the transaction
|
|
17067
17644
|
* due to a different transaction committing before the current.
|
|
17068
17645
|
*
|
|
17069
|
-
*
|
|
17070
|
-
*
|
|
17646
|
+
* The outermost `tx` call creates the transaction boundary and commits or rolls back the full
|
|
17647
|
+
* composed transaction.
|
|
17071
17648
|
*
|
|
17072
17649
|
* @example
|
|
17073
17650
|
* ```ts
|
|
@@ -17077,10 +17654,10 @@ export declare class Transaction extends Transaction_base {
|
|
|
17077
17654
|
* const ref1 = yield* TxRef.make(0)
|
|
17078
17655
|
* const ref2 = yield* TxRef.make(0)
|
|
17079
17656
|
*
|
|
17080
|
-
* //
|
|
17081
|
-
* yield* Effect.
|
|
17657
|
+
* // Nested tx calls compose into the same transaction
|
|
17658
|
+
* yield* Effect.tx(Effect.gen(function*() {
|
|
17082
17659
|
* yield* TxRef.set(ref1, 10)
|
|
17083
|
-
* yield* TxRef.set(ref2, 20)
|
|
17660
|
+
* yield* Effect.tx(TxRef.set(ref2, 20))
|
|
17084
17661
|
* const sum = (yield* TxRef.get(ref1)) + (yield* TxRef.get(ref2))
|
|
17085
17662
|
* console.log(`Transaction sum: ${sum}`)
|
|
17086
17663
|
* }))
|
|
@@ -17093,122 +17670,7 @@ export declare class Transaction extends Transaction_base {
|
|
|
17093
17670
|
* @since 4.0.0
|
|
17094
17671
|
* @category Transactions
|
|
17095
17672
|
*/
|
|
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>>;
|
|
17673
|
+
export declare const tx: <A, E, R>(effect: Effect<A, E, R>) => Effect<A, E, Exclude<R, Transaction>>;
|
|
17212
17674
|
/**
|
|
17213
17675
|
* Signals that the current transaction needs to be retried.
|
|
17214
17676
|
*
|
|
@@ -17229,15 +17691,15 @@ export declare const transactionWith: <A, E, R>(f: (state: Transaction["Service"
|
|
|
17229
17691
|
* // forks a fiber that increases the value of `ref` every 100 millis
|
|
17230
17692
|
* yield* Effect.forkChild(Effect.forever(
|
|
17231
17693
|
* // update to transactional value
|
|
17232
|
-
* TxRef.update(ref, (n) => n + 1).pipe(Effect.delay("100 millis"))
|
|
17694
|
+
* Effect.tx(TxRef.update(ref, (n) => n + 1)).pipe(Effect.delay("100 millis"))
|
|
17233
17695
|
* ))
|
|
17234
17696
|
*
|
|
17235
17697
|
* // the following will retry 10 times until the `ref` value is 10
|
|
17236
|
-
* yield* Effect.
|
|
17698
|
+
* yield* Effect.tx(Effect.gen(function*() {
|
|
17237
17699
|
* const value = yield* TxRef.get(ref)
|
|
17238
17700
|
* if (value < 10) {
|
|
17239
17701
|
* yield* Effect.log(`retry due to value: ${value}`)
|
|
17240
|
-
* return yield* Effect.
|
|
17702
|
+
* return yield* Effect.txRetry
|
|
17241
17703
|
* }
|
|
17242
17704
|
* yield* Effect.log(`transaction done with value: ${value}`)
|
|
17243
17705
|
* }))
|
|
@@ -17246,7 +17708,7 @@ export declare const transactionWith: <A, E, R>(f: (state: Transaction["Service"
|
|
|
17246
17708
|
* Effect.runPromise(program).catch(console.error)
|
|
17247
17709
|
* ```
|
|
17248
17710
|
*/
|
|
17249
|
-
export declare const
|
|
17711
|
+
export declare const txRetry: Effect<never, never, Transaction>;
|
|
17250
17712
|
/**
|
|
17251
17713
|
* @since 4.0.0
|
|
17252
17714
|
* @category Effectify
|
|
@@ -17686,18 +18148,20 @@ export declare const satisfiesSuccessType: <A>() => <A2 extends A, E, R>(effect:
|
|
|
17686
18148
|
*
|
|
17687
18149
|
* @example
|
|
17688
18150
|
* ```ts
|
|
17689
|
-
* import { Effect } from "effect"
|
|
18151
|
+
* import { Data, Effect } from "effect"
|
|
18152
|
+
*
|
|
18153
|
+
* class ValidationError extends Data.TaggedError("ValidationError")<{}> {}
|
|
17690
18154
|
*
|
|
17691
|
-
* // Define a constraint that the error type must be
|
|
17692
|
-
* const satisfiesError = Effect.satisfiesErrorType<
|
|
18155
|
+
* // Define a constraint that the error type must be a ValidationError
|
|
18156
|
+
* const satisfiesError = Effect.satisfiesErrorType<ValidationError>()
|
|
17693
18157
|
*
|
|
17694
|
-
* // This works - Effect<number,
|
|
17695
|
-
* const validEffect = satisfiesError(Effect.fail(new
|
|
18158
|
+
* // This works - Effect<number, ValidationError, never> extends the constrained type
|
|
18159
|
+
* const validEffect = satisfiesError(Effect.fail(new ValidationError()))
|
|
17696
18160
|
*
|
|
17697
18161
|
* // This would cause a TypeScript compilation error:
|
|
17698
18162
|
* // const invalidEffect = satisfiesError(Effect.fail("string error"))
|
|
17699
18163
|
* // ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
17700
|
-
* // Type 'string' is not assignable to type '
|
|
18164
|
+
* // Type 'string' is not assignable to type 'ValidationError'
|
|
17701
18165
|
* ```
|
|
17702
18166
|
*
|
|
17703
18167
|
* @since 4.0.0
|