effect 4.0.0-beta.6 → 4.0.0-beta.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Array.d.ts +213 -385
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +149 -102
- package/dist/Array.js.map +1 -1
- package/dist/BigDecimal.d.ts +82 -45
- package/dist/BigDecimal.d.ts.map +1 -1
- package/dist/BigDecimal.js +105 -52
- package/dist/BigDecimal.js.map +1 -1
- package/dist/BigInt.d.ts +39 -32
- package/dist/BigInt.d.ts.map +1 -1
- package/dist/BigInt.js +36 -33
- package/dist/BigInt.js.map +1 -1
- package/dist/Brand.d.ts +3 -5
- package/dist/Brand.d.ts.map +1 -1
- package/dist/Brand.js +1 -1
- package/dist/Brand.js.map +1 -1
- package/dist/Cache.d.ts +14 -45
- package/dist/Cache.d.ts.map +1 -1
- package/dist/Cache.js +21 -47
- package/dist/Cache.js.map +1 -1
- package/dist/Cause.d.ts +53 -22
- package/dist/Cause.d.ts.map +1 -1
- package/dist/Cause.js +108 -10
- package/dist/Cause.js.map +1 -1
- package/dist/Channel.d.ts +166 -48
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +176 -87
- package/dist/Channel.js.map +1 -1
- package/dist/Chunk.d.ts +112 -304
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Chunk.js +56 -88
- package/dist/Chunk.js.map +1 -1
- package/dist/Clock.d.ts +2 -2
- package/dist/Clock.d.ts.map +1 -1
- package/dist/Clock.js.map +1 -1
- package/dist/Combiner.d.ts +280 -13
- package/dist/Combiner.d.ts.map +1 -1
- package/dist/Combiner.js +198 -7
- package/dist/Combiner.js.map +1 -1
- package/dist/Config.d.ts +189 -29
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +85 -35
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.d.ts +6 -6
- package/dist/ConfigProvider.d.ts.map +1 -1
- package/dist/ConfigProvider.js +5 -5
- package/dist/ConfigProvider.js.map +1 -1
- package/dist/Console.d.ts +2 -2
- package/dist/Console.d.ts.map +1 -1
- package/dist/Console.js.map +1 -1
- package/dist/Context.d.ts +1150 -0
- package/dist/Context.d.ts.map +1 -0
- package/dist/{ServiceMap.js → Context.js} +181 -165
- package/dist/Context.js.map +1 -0
- package/dist/Cron.d.ts +11 -7
- package/dist/Cron.d.ts.map +1 -1
- package/dist/Cron.js +120 -63
- package/dist/Cron.js.map +1 -1
- package/dist/Data.d.ts +533 -365
- package/dist/Data.d.ts.map +1 -1
- package/dist/Data.js +125 -73
- package/dist/Data.js.map +1 -1
- package/dist/DateTime.d.ts +74 -255
- package/dist/DateTime.d.ts.map +1 -1
- package/dist/DateTime.js +17 -62
- package/dist/DateTime.js.map +1 -1
- package/dist/Deferred.d.ts +12 -5
- package/dist/Deferred.d.ts.map +1 -1
- package/dist/Deferred.js +13 -5
- package/dist/Deferred.js.map +1 -1
- package/dist/Duration.d.ts +74 -40
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +126 -87
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts +1435 -927
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +516 -328
- package/dist/Effect.js.map +1 -1
- package/dist/Effectable.d.ts +29 -0
- package/dist/Effectable.d.ts.map +1 -0
- package/dist/Effectable.js +31 -0
- package/dist/Effectable.js.map +1 -0
- package/dist/Encoding.d.ts +1 -1
- package/dist/Equal.d.ts +276 -109
- package/dist/Equal.d.ts.map +1 -1
- package/dist/Equal.js +140 -48
- package/dist/Equal.js.map +1 -1
- package/dist/Equivalence.d.ts +60 -3
- package/dist/Equivalence.d.ts.map +1 -1
- package/dist/Equivalence.js +70 -13
- package/dist/Equivalence.js.map +1 -1
- package/dist/ErrorReporter.d.ts +374 -0
- package/dist/ErrorReporter.d.ts.map +1 -0
- package/dist/ErrorReporter.js +245 -0
- package/dist/ErrorReporter.js.map +1 -0
- package/dist/ExecutionPlan.d.ts +6 -6
- package/dist/ExecutionPlan.d.ts.map +1 -1
- package/dist/ExecutionPlan.js +4 -4
- package/dist/ExecutionPlan.js.map +1 -1
- package/dist/Exit.d.ts +24 -12
- package/dist/Exit.d.ts.map +1 -1
- package/dist/Exit.js +8 -4
- package/dist/Exit.js.map +1 -1
- package/dist/Fiber.d.ts +10 -8
- package/dist/Fiber.d.ts.map +1 -1
- package/dist/Fiber.js.map +1 -1
- package/dist/FiberHandle.d.ts +11 -10
- package/dist/FiberHandle.d.ts.map +1 -1
- package/dist/FiberHandle.js +12 -11
- package/dist/FiberHandle.js.map +1 -1
- package/dist/FiberMap.d.ts +22 -21
- package/dist/FiberMap.d.ts.map +1 -1
- package/dist/FiberMap.js +10 -10
- package/dist/FiberMap.js.map +1 -1
- package/dist/FiberSet.d.ts +2 -2
- package/dist/FiberSet.d.ts.map +1 -1
- package/dist/FiberSet.js +4 -4
- package/dist/FiberSet.js.map +1 -1
- package/dist/FileSystem.d.ts +20 -19
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js +15 -11
- package/dist/FileSystem.js.map +1 -1
- package/dist/Filter.d.ts +4 -37
- package/dist/Filter.d.ts.map +1 -1
- package/dist/Filter.js +0 -13
- package/dist/Filter.js.map +1 -1
- package/dist/Formatter.d.ts +131 -47
- package/dist/Formatter.d.ts.map +1 -1
- package/dist/Formatter.js +243 -55
- package/dist/Formatter.js.map +1 -1
- package/dist/Function.d.ts +1 -9
- package/dist/Function.d.ts.map +1 -1
- package/dist/Function.js +2 -10
- package/dist/Function.js.map +1 -1
- package/dist/Graph.d.ts +65 -65
- package/dist/Graph.d.ts.map +1 -1
- package/dist/Graph.js +58 -60
- package/dist/Graph.js.map +1 -1
- package/dist/Hash.js +1 -1
- package/dist/Hash.js.map +1 -1
- package/dist/HashMap.d.ts +26 -19
- package/dist/HashMap.d.ts.map +1 -1
- package/dist/HashMap.js +7 -5
- package/dist/HashMap.js.map +1 -1
- package/dist/Inspectable.d.ts +0 -4
- package/dist/Inspectable.d.ts.map +1 -1
- package/dist/Inspectable.js +4 -13
- package/dist/Inspectable.js.map +1 -1
- package/dist/Iterable.d.ts +50 -50
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +106 -34
- package/dist/Iterable.js.map +1 -1
- package/dist/JsonSchema.d.ts +299 -10
- package/dist/JsonSchema.d.ts.map +1 -1
- package/dist/JsonSchema.js +323 -4
- package/dist/JsonSchema.js.map +1 -1
- package/dist/Latch.d.ts +69 -3
- package/dist/Latch.d.ts.map +1 -1
- package/dist/Latch.js +58 -0
- package/dist/Latch.js.map +1 -1
- package/dist/Layer.d.ts +599 -379
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +249 -180
- package/dist/Layer.js.map +1 -1
- package/dist/LayerMap.d.ts +27 -26
- package/dist/LayerMap.d.ts.map +1 -1
- package/dist/LayerMap.js +21 -18
- package/dist/LayerMap.js.map +1 -1
- package/dist/LogLevel.d.ts +32 -0
- package/dist/LogLevel.d.ts.map +1 -1
- package/dist/LogLevel.js +28 -100
- package/dist/LogLevel.js.map +1 -1
- package/dist/Logger.d.ts +31 -97
- package/dist/Logger.d.ts.map +1 -1
- package/dist/Logger.js +2 -3
- package/dist/Logger.js.map +1 -1
- package/dist/ManagedRuntime.d.ts +8 -8
- package/dist/ManagedRuntime.d.ts.map +1 -1
- package/dist/ManagedRuntime.js +34 -25
- package/dist/ManagedRuntime.js.map +1 -1
- package/dist/Metric.d.ts +23 -25
- package/dist/Metric.d.ts.map +1 -1
- package/dist/Metric.js +24 -26
- package/dist/Metric.js.map +1 -1
- package/dist/MutableHashMap.d.ts +7 -0
- package/dist/MutableHashMap.d.ts.map +1 -1
- package/dist/MutableHashMap.js +8 -0
- package/dist/MutableHashMap.js.map +1 -1
- package/dist/MutableHashSet.d.ts +7 -0
- package/dist/MutableHashSet.d.ts.map +1 -1
- package/dist/MutableHashSet.js +8 -0
- package/dist/MutableHashSet.js.map +1 -1
- package/dist/MutableList.d.ts.map +1 -1
- package/dist/MutableList.js +3 -0
- package/dist/MutableList.js.map +1 -1
- package/dist/Newtype.d.ts +291 -0
- package/dist/Newtype.d.ts.map +1 -0
- package/dist/Newtype.js +161 -0
- package/dist/Newtype.js.map +1 -0
- package/dist/Number.d.ts +74 -18
- package/dist/Number.d.ts.map +1 -1
- package/dist/Number.js +46 -18
- package/dist/Number.js.map +1 -1
- package/dist/Optic.d.ts +947 -18
- package/dist/Optic.d.ts.map +1 -1
- package/dist/Optic.js +454 -5
- package/dist/Optic.js.map +1 -1
- package/dist/Option.d.ts +25 -16
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js +15 -9
- package/dist/Option.js.map +1 -1
- package/dist/Order.d.ts +6 -1
- package/dist/Order.d.ts.map +1 -1
- package/dist/Order.js +19 -14
- package/dist/Order.js.map +1 -1
- package/dist/PartitionedSemaphore.d.ts +183 -0
- package/dist/PartitionedSemaphore.d.ts.map +1 -0
- package/dist/PartitionedSemaphore.js +231 -0
- package/dist/PartitionedSemaphore.js.map +1 -0
- package/dist/Path.d.ts +2 -2
- package/dist/Path.d.ts.map +1 -1
- package/dist/Path.js +2 -2
- package/dist/Path.js.map +1 -1
- package/dist/PlatformError.d.ts +2 -2
- package/dist/Pool.d.ts +1 -1
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +5 -5
- package/dist/Pool.js.map +1 -1
- package/dist/Predicate.d.ts +1 -1
- package/dist/Predicate.d.ts.map +1 -1
- package/dist/PubSub.d.ts +5 -4
- package/dist/PubSub.d.ts.map +1 -1
- package/dist/PubSub.js +15 -8
- package/dist/PubSub.js.map +1 -1
- package/dist/Pull.d.ts.map +1 -1
- package/dist/Pull.js +1 -1
- package/dist/Pull.js.map +1 -1
- package/dist/Queue.d.ts +9 -6
- package/dist/Queue.d.ts.map +1 -1
- package/dist/Queue.js +7 -5
- package/dist/Queue.js.map +1 -1
- package/dist/Random.d.ts +36 -2
- package/dist/Random.d.ts.map +1 -1
- package/dist/Random.js +46 -35
- package/dist/Random.js.map +1 -1
- package/dist/RcMap.d.ts +4 -4
- package/dist/RcMap.d.ts.map +1 -1
- package/dist/RcMap.js +13 -13
- package/dist/RcMap.js.map +1 -1
- package/dist/RcRef.d.ts +1 -1
- package/dist/RcRef.d.ts.map +1 -1
- package/dist/Record.d.ts +63 -160
- package/dist/Record.d.ts.map +1 -1
- package/dist/Record.js +37 -56
- package/dist/Record.js.map +1 -1
- package/dist/Redactable.d.ts +139 -62
- package/dist/Redactable.d.ts.map +1 -1
- package/dist/Redactable.js +59 -55
- package/dist/Redactable.js.map +1 -1
- package/dist/Reducer.d.ts +166 -7
- package/dist/Reducer.d.ts.map +1 -1
- package/dist/Reducer.js +135 -1
- package/dist/Reducer.js.map +1 -1
- package/dist/References.d.ts +257 -229
- package/dist/References.d.ts.map +1 -1
- package/dist/References.js +240 -259
- package/dist/References.js.map +1 -1
- package/dist/Request.d.ts +5 -5
- package/dist/Request.d.ts.map +1 -1
- package/dist/Request.js.map +1 -1
- package/dist/RequestResolver.d.ts +25 -25
- package/dist/RequestResolver.d.ts.map +1 -1
- package/dist/RequestResolver.js +15 -16
- package/dist/RequestResolver.js.map +1 -1
- package/dist/Resource.d.ts +0 -3
- package/dist/Resource.d.ts.map +1 -1
- package/dist/Resource.js +5 -4
- package/dist/Resource.js.map +1 -1
- package/dist/Result.d.ts +1 -1
- package/dist/Result.d.ts.map +1 -1
- package/dist/Result.js +1 -2
- package/dist/Result.js.map +1 -1
- package/dist/Runtime.d.ts +66 -0
- package/dist/Runtime.d.ts.map +1 -1
- package/dist/Runtime.js +79 -6
- package/dist/Runtime.js.map +1 -1
- package/dist/Schedule.d.ts +174 -291
- package/dist/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js +132 -120
- package/dist/Schedule.js.map +1 -1
- package/dist/Scheduler.d.ts +36 -125
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/Scheduler.js +37 -126
- package/dist/Scheduler.js.map +1 -1
- package/dist/Schema.d.ts +3213 -392
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +2058 -252
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +13 -2
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +340 -257
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaGetter.d.ts +55 -13
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +73 -11
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaIssue.d.ts.map +1 -1
- package/dist/SchemaIssue.js +29 -11
- package/dist/SchemaIssue.js.map +1 -1
- package/dist/SchemaParser.d.ts +44 -54
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +69 -4
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +2 -2
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +63 -39
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +245 -3
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +297 -33
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/Scope.d.ts +2 -2
- package/dist/Scope.d.ts.map +1 -1
- package/dist/Scope.js.map +1 -1
- package/dist/ScopedCache.d.ts +2 -2
- package/dist/ScopedCache.d.ts.map +1 -1
- package/dist/ScopedCache.js +5 -5
- package/dist/ScopedCache.js.map +1 -1
- package/dist/Semaphore.d.ts +148 -52
- package/dist/Semaphore.d.ts.map +1 -1
- package/dist/Semaphore.js +135 -117
- package/dist/Semaphore.js.map +1 -1
- package/dist/Sink.d.ts +22 -19
- package/dist/Sink.d.ts.map +1 -1
- package/dist/Sink.js +54 -7
- package/dist/Sink.js.map +1 -1
- package/dist/Stdio.d.ts +18 -6
- package/dist/Stdio.d.ts.map +1 -1
- package/dist/Stdio.js +20 -2
- package/dist/Stdio.js.map +1 -1
- package/dist/Stream.d.ts +465 -542
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +329 -145
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +114 -47
- package/dist/String.d.ts.map +1 -1
- package/dist/String.js +29 -47
- package/dist/String.js.map +1 -1
- package/dist/Struct.d.ts +7 -7
- package/dist/Struct.d.ts.map +1 -1
- package/dist/SubscriptionRef.d.ts +1 -2
- package/dist/SubscriptionRef.d.ts.map +1 -1
- package/dist/SubscriptionRef.js +83 -116
- package/dist/SubscriptionRef.js.map +1 -1
- package/dist/Terminal.d.ts +5 -4
- package/dist/Terminal.d.ts.map +1 -1
- package/dist/Terminal.js +2 -2
- package/dist/Terminal.js.map +1 -1
- package/dist/Tracer.d.ts +21 -20
- package/dist/Tracer.d.ts.map +1 -1
- package/dist/Tracer.js +13 -9
- package/dist/Tracer.js.map +1 -1
- package/dist/Trie.d.ts +44 -31
- package/dist/Trie.d.ts.map +1 -1
- package/dist/Trie.js +13 -9
- package/dist/Trie.js.map +1 -1
- package/dist/TxChunk.d.ts +4 -4
- package/dist/TxChunk.d.ts.map +1 -1
- package/dist/TxChunk.js +4 -4
- package/dist/TxChunk.js.map +1 -1
- package/dist/TxDeferred.d.ts +328 -0
- package/dist/TxDeferred.d.ts.map +1 -0
- package/dist/TxDeferred.js +197 -0
- package/dist/TxDeferred.js.map +1 -0
- package/dist/TxHashMap.d.ts +105 -86
- package/dist/TxHashMap.d.ts.map +1 -1
- package/dist/TxHashMap.js +51 -44
- package/dist/TxHashMap.js.map +1 -1
- package/dist/TxHashSet.d.ts +2 -2
- package/dist/TxHashSet.d.ts.map +1 -1
- package/dist/TxHashSet.js +16 -15
- package/dist/TxHashSet.js.map +1 -1
- package/dist/TxPriorityQueue.d.ts +609 -0
- package/dist/TxPriorityQueue.d.ts.map +1 -0
- package/dist/TxPriorityQueue.js +416 -0
- package/dist/TxPriorityQueue.js.map +1 -0
- package/dist/TxPubSub.d.ts +585 -0
- package/dist/TxPubSub.d.ts.map +1 -0
- package/dist/TxPubSub.js +521 -0
- package/dist/TxPubSub.js.map +1 -0
- package/dist/TxQueue.d.ts +1 -1
- package/dist/TxQueue.d.ts.map +1 -1
- package/dist/TxQueue.js +42 -57
- package/dist/TxQueue.js.map +1 -1
- package/dist/TxReentrantLock.d.ts +500 -0
- package/dist/TxReentrantLock.d.ts.map +1 -0
- package/dist/TxReentrantLock.js +481 -0
- package/dist/TxReentrantLock.js.map +1 -0
- package/dist/TxRef.d.ts +14 -20
- package/dist/TxRef.d.ts.map +1 -1
- package/dist/TxRef.js +8 -10
- package/dist/TxRef.js.map +1 -1
- package/dist/TxSemaphore.d.ts +162 -2
- package/dist/TxSemaphore.d.ts.map +1 -1
- package/dist/TxSemaphore.js +25 -10
- package/dist/TxSemaphore.js.map +1 -1
- package/dist/TxSubscriptionRef.d.ts +508 -0
- package/dist/TxSubscriptionRef.d.ts.map +1 -0
- package/dist/TxSubscriptionRef.js +293 -0
- package/dist/TxSubscriptionRef.js.map +1 -0
- package/dist/Types.d.ts +80 -22
- package/dist/Types.d.ts.map +1 -1
- package/dist/Unify.d.ts +8 -2
- package/dist/Unify.d.ts.map +1 -1
- package/dist/Unify.js.map +1 -1
- package/dist/Utils.d.ts +137 -65
- package/dist/Utils.d.ts.map +1 -1
- package/dist/Utils.js +38 -66
- package/dist/Utils.js.map +1 -1
- package/dist/index.d.ts +886 -71
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +886 -71
- package/dist/index.js.map +1 -1
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/dateTime.js +77 -71
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +502 -326
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/hashMap.js +7 -5
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/layer.js +3 -3
- package/dist/internal/layer.js.map +1 -1
- package/dist/internal/option.js +6 -0
- package/dist/internal/option.js.map +1 -1
- package/dist/internal/random.d.ts +2 -0
- package/dist/internal/random.d.ts.map +1 -0
- package/dist/internal/random.js +13 -0
- package/dist/internal/random.js.map +1 -0
- package/dist/internal/rcRef.js +9 -9
- package/dist/internal/rcRef.js.map +1 -1
- package/dist/internal/references.d.ts +2 -0
- package/dist/internal/references.d.ts.map +1 -0
- package/dist/internal/references.js +51 -0
- package/dist/internal/references.js.map +1 -0
- package/dist/internal/request.js +6 -6
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/schedule.js +1 -1
- package/dist/internal/schedule.js.map +1 -1
- package/dist/internal/schema/annotations.js +2 -0
- package/dist/internal/schema/annotations.js.map +1 -1
- package/dist/internal/schema/representation.js +87 -109
- package/dist/internal/schema/representation.js.map +1 -1
- package/dist/internal/schema/schema.d.ts +10 -1
- package/dist/internal/schema/schema.d.ts.map +1 -1
- package/dist/internal/schema/schema.js +59 -1
- package/dist/internal/schema/schema.js.map +1 -1
- package/dist/internal/trie.js +8 -7
- package/dist/internal/trie.js.map +1 -1
- package/dist/testing/TestClock.d.ts +5 -5
- package/dist/testing/TestClock.d.ts.map +1 -1
- package/dist/testing/TestClock.js +2 -2
- package/dist/testing/TestClock.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +267 -33
- package/dist/testing/TestSchema.d.ts.map +1 -1
- package/dist/testing/TestSchema.js +296 -23
- package/dist/testing/TestSchema.js.map +1 -1
- package/dist/testing/index.d.ts +64 -1
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +64 -1
- package/dist/testing/index.js.map +1 -1
- package/dist/unstable/ai/AiError.d.ts +127 -45
- package/dist/unstable/ai/AiError.d.ts.map +1 -1
- package/dist/unstable/ai/AiError.js +29 -23
- package/dist/unstable/ai/AiError.js.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.js +9 -2
- package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Chat.d.ts +39 -11
- package/dist/unstable/ai/Chat.d.ts.map +1 -1
- package/dist/unstable/ai/Chat.js +40 -47
- package/dist/unstable/ai/Chat.js.map +1 -1
- package/dist/unstable/ai/EmbeddingModel.d.ts +130 -0
- package/dist/unstable/ai/EmbeddingModel.d.ts.map +1 -0
- package/dist/unstable/ai/EmbeddingModel.js +127 -0
- package/dist/unstable/ai/EmbeddingModel.js.map +1 -0
- package/dist/unstable/ai/IdGenerator.d.ts +2 -2
- package/dist/unstable/ai/IdGenerator.d.ts.map +1 -1
- package/dist/unstable/ai/IdGenerator.js +2 -2
- package/dist/unstable/ai/IdGenerator.js.map +1 -1
- package/dist/unstable/ai/LanguageModel.d.ts +119 -49
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +260 -61
- package/dist/unstable/ai/LanguageModel.js.map +1 -1
- package/dist/unstable/ai/McpSchema.d.ts +207 -112
- package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
- package/dist/unstable/ai/McpSchema.js +71 -19
- package/dist/unstable/ai/McpSchema.js.map +1 -1
- package/dist/unstable/ai/McpServer.d.ts +68 -15
- package/dist/unstable/ai/McpServer.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.js +225 -73
- package/dist/unstable/ai/McpServer.js.map +1 -1
- package/dist/unstable/ai/Model.d.ts +27 -9
- package/dist/unstable/ai/Model.d.ts.map +1 -1
- package/dist/unstable/ai/Model.js +25 -9
- package/dist/unstable/ai/Model.js.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js +9 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Prompt.d.ts +17 -17
- package/dist/unstable/ai/Prompt.d.ts.map +1 -1
- package/dist/unstable/ai/Prompt.js +6 -9
- package/dist/unstable/ai/Prompt.js.map +1 -1
- package/dist/unstable/ai/Response.d.ts +24 -24
- package/dist/unstable/ai/Response.d.ts.map +1 -1
- package/dist/unstable/ai/Response.js +7 -8
- package/dist/unstable/ai/Response.js.map +1 -1
- package/dist/unstable/ai/ResponseIdTracker.d.ts +38 -0
- package/dist/unstable/ai/ResponseIdTracker.d.ts.map +1 -0
- package/dist/unstable/ai/ResponseIdTracker.js +68 -0
- package/dist/unstable/ai/ResponseIdTracker.js.map +1 -0
- package/dist/unstable/ai/Telemetry.d.ts +35 -2
- package/dist/unstable/ai/Telemetry.d.ts.map +1 -1
- package/dist/unstable/ai/Telemetry.js +2 -2
- package/dist/unstable/ai/Telemetry.js.map +1 -1
- package/dist/unstable/ai/Tokenizer.d.ts +2 -2
- package/dist/unstable/ai/Tokenizer.d.ts.map +1 -1
- package/dist/unstable/ai/Tokenizer.js +2 -2
- package/dist/unstable/ai/Tokenizer.js.map +1 -1
- package/dist/unstable/ai/Tool.d.ts +46 -16
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +68 -22
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/ai/Toolkit.d.ts +4 -4
- package/dist/unstable/ai/Toolkit.d.ts.map +1 -1
- package/dist/unstable/ai/Toolkit.js +14 -21
- package/dist/unstable/ai/Toolkit.js.map +1 -1
- package/dist/unstable/ai/index.d.ts +22 -1
- package/dist/unstable/ai/index.d.ts.map +1 -1
- package/dist/unstable/ai/index.js +22 -1
- package/dist/unstable/ai/index.js.map +1 -1
- package/dist/unstable/ai/internal/codec-transformer.js +5 -7
- package/dist/unstable/ai/internal/codec-transformer.js.map +1 -1
- package/dist/unstable/cli/Argument.d.ts +4 -7
- package/dist/unstable/cli/Argument.d.ts.map +1 -1
- package/dist/unstable/cli/Argument.js +1 -3
- package/dist/unstable/cli/Argument.js.map +1 -1
- package/dist/unstable/cli/CliError.d.ts +51 -63
- package/dist/unstable/cli/CliError.d.ts.map +1 -1
- package/dist/unstable/cli/CliError.js +32 -57
- package/dist/unstable/cli/CliError.js.map +1 -1
- package/dist/unstable/cli/CliOutput.d.ts +5 -4
- package/dist/unstable/cli/CliOutput.d.ts.map +1 -1
- package/dist/unstable/cli/CliOutput.js +67 -12
- package/dist/unstable/cli/CliOutput.js.map +1 -1
- package/dist/unstable/cli/Command.d.ts +372 -59
- package/dist/unstable/cli/Command.d.ts.map +1 -1
- package/dist/unstable/cli/Command.js +328 -66
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cli/Completions.d.ts +97 -0
- package/dist/unstable/cli/Completions.d.ts.map +1 -0
- package/dist/unstable/cli/Completions.js +25 -0
- package/dist/unstable/cli/Completions.js.map +1 -0
- package/dist/unstable/cli/Flag.d.ts +4 -5
- package/dist/unstable/cli/Flag.d.ts.map +1 -1
- package/dist/unstable/cli/Flag.js +1 -1
- package/dist/unstable/cli/Flag.js.map +1 -1
- package/dist/unstable/cli/GlobalFlag.d.ts +125 -0
- package/dist/unstable/cli/GlobalFlag.d.ts.map +1 -0
- package/dist/unstable/cli/GlobalFlag.js +118 -0
- package/dist/unstable/cli/GlobalFlag.js.map +1 -0
- package/dist/unstable/cli/HelpDoc.d.ts +81 -11
- package/dist/unstable/cli/HelpDoc.d.ts.map +1 -1
- package/dist/unstable/cli/Param.d.ts +34 -6
- package/dist/unstable/cli/Param.d.ts.map +1 -1
- package/dist/unstable/cli/Param.js +24 -14
- package/dist/unstable/cli/Param.js.map +1 -1
- package/dist/unstable/cli/Primitive.d.ts +2 -2
- package/dist/unstable/cli/Primitive.d.ts.map +1 -1
- package/dist/unstable/cli/Primitive.js +1 -1
- package/dist/unstable/cli/Primitive.js.map +1 -1
- package/dist/unstable/cli/Prompt.js +266 -86
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/cli/index.d.ts +10 -0
- package/dist/unstable/cli/index.d.ts.map +1 -1
- package/dist/unstable/cli/index.js +10 -0
- package/dist/unstable/cli/index.js.map +1 -1
- package/dist/unstable/cli/internal/command.d.ts +41 -15
- package/dist/unstable/cli/internal/command.d.ts.map +1 -1
- package/dist/unstable/cli/internal/command.js +84 -47
- package/dist/unstable/cli/internal/command.js.map +1 -1
- package/dist/unstable/cli/internal/completions/bash.js.map +1 -1
- package/dist/unstable/cli/internal/completions/descriptor.d.ts +2 -0
- package/dist/unstable/cli/internal/completions/descriptor.d.ts.map +1 -0
- package/dist/unstable/cli/internal/completions/{CommandDescriptor.js → descriptor.js} +17 -5
- package/dist/unstable/cli/internal/completions/descriptor.js.map +1 -0
- package/dist/unstable/cli/internal/completions/fish.js.map +1 -1
- package/dist/unstable/cli/internal/completions/zsh.js.map +1 -1
- package/dist/unstable/cli/internal/config.js +42 -0
- package/dist/unstable/cli/internal/config.js.map +1 -1
- package/dist/unstable/cli/internal/help.d.ts +33 -0
- package/dist/unstable/cli/internal/help.d.ts.map +1 -0
- package/dist/unstable/cli/internal/help.js +125 -0
- package/dist/unstable/cli/internal/help.js.map +1 -0
- package/dist/unstable/cli/internal/parser.js +155 -58
- package/dist/unstable/cli/internal/parser.js.map +1 -1
- package/dist/unstable/cluster/ClusterCron.d.ts +1 -1
- package/dist/unstable/cluster/ClusterCron.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterCron.js +1 -1
- package/dist/unstable/cluster/ClusterCron.js.map +1 -1
- package/dist/unstable/cluster/ClusterError.d.ts +7 -7
- package/dist/unstable/cluster/ClusterSchema.d.ts +28 -7
- package/dist/unstable/cluster/ClusterSchema.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterSchema.js +28 -8
- package/dist/unstable/cluster/ClusterSchema.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts +4 -2
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +96 -63
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/cluster/DeliverAt.js +1 -1
- package/dist/unstable/cluster/DeliverAt.js.map +1 -1
- package/dist/unstable/cluster/Entity.d.ts +17 -16
- package/dist/unstable/cluster/Entity.d.ts.map +1 -1
- package/dist/unstable/cluster/Entity.js +31 -25
- package/dist/unstable/cluster/Entity.js.map +1 -1
- package/dist/unstable/cluster/EntityAddress.d.ts +2 -2
- package/dist/unstable/cluster/EntityAddress.d.ts.map +1 -1
- package/dist/unstable/cluster/EntityAddress.js +1 -1
- package/dist/unstable/cluster/EntityAddress.js.map +1 -1
- package/dist/unstable/cluster/EntityProxy.js +3 -3
- package/dist/unstable/cluster/EntityProxy.js.map +1 -1
- package/dist/unstable/cluster/EntityProxyServer.d.ts.map +1 -1
- package/dist/unstable/cluster/EntityProxyServer.js +6 -6
- package/dist/unstable/cluster/EntityProxyServer.js.map +1 -1
- package/dist/unstable/cluster/EntityResource.d.ts +4 -4
- package/dist/unstable/cluster/EntityResource.d.ts.map +1 -1
- package/dist/unstable/cluster/EntityResource.js +2 -2
- package/dist/unstable/cluster/EntityResource.js.map +1 -1
- package/dist/unstable/cluster/Envelope.d.ts +3 -3
- package/dist/unstable/cluster/HttpRunner.js +2 -2
- package/dist/unstable/cluster/HttpRunner.js.map +1 -1
- package/dist/unstable/cluster/K8sHttpClient.d.ts +5 -5
- package/dist/unstable/cluster/K8sHttpClient.d.ts.map +1 -1
- package/dist/unstable/cluster/K8sHttpClient.js +7 -7
- package/dist/unstable/cluster/K8sHttpClient.js.map +1 -1
- package/dist/unstable/cluster/Message.d.ts +16 -10
- package/dist/unstable/cluster/Message.d.ts.map +1 -1
- package/dist/unstable/cluster/Message.js +16 -8
- package/dist/unstable/cluster/Message.js.map +1 -1
- package/dist/unstable/cluster/MessageStorage.d.ts +46 -23
- package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/MessageStorage.js +40 -25
- package/dist/unstable/cluster/MessageStorage.js.map +1 -1
- package/dist/unstable/cluster/Reply.d.ts +7 -6
- package/dist/unstable/cluster/Reply.d.ts.map +1 -1
- package/dist/unstable/cluster/Reply.js +8 -7
- package/dist/unstable/cluster/Reply.js.map +1 -1
- package/dist/unstable/cluster/Runner.d.ts +1 -1
- package/dist/unstable/cluster/Runner.d.ts.map +1 -1
- package/dist/unstable/cluster/Runner.js +1 -1
- package/dist/unstable/cluster/Runner.js.map +1 -1
- package/dist/unstable/cluster/RunnerAddress.d.ts +1 -1
- package/dist/unstable/cluster/RunnerAddress.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerAddress.js +1 -1
- package/dist/unstable/cluster/RunnerAddress.js.map +1 -1
- package/dist/unstable/cluster/RunnerHealth.d.ts +2 -2
- package/dist/unstable/cluster/RunnerHealth.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerHealth.js +2 -2
- package/dist/unstable/cluster/RunnerHealth.js.map +1 -1
- package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerServer.js +10 -9
- package/dist/unstable/cluster/RunnerServer.js.map +1 -1
- package/dist/unstable/cluster/RunnerStorage.d.ts +12 -12
- package/dist/unstable/cluster/RunnerStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerStorage.js +3 -3
- package/dist/unstable/cluster/RunnerStorage.js.map +1 -1
- package/dist/unstable/cluster/Runners.d.ts +5 -4
- package/dist/unstable/cluster/Runners.d.ts.map +1 -1
- package/dist/unstable/cluster/Runners.js +16 -14
- package/dist/unstable/cluster/Runners.js.map +1 -1
- package/dist/unstable/cluster/ShardId.d.ts +35 -49
- package/dist/unstable/cluster/ShardId.d.ts.map +1 -1
- package/dist/unstable/cluster/ShardId.js +65 -67
- package/dist/unstable/cluster/ShardId.js.map +1 -1
- package/dist/unstable/cluster/Sharding.d.ts +4 -4
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +59 -49
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.d.ts +28 -27
- package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.js +27 -27
- package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
- package/dist/unstable/cluster/SingletonAddress.d.ts +2 -2
- package/dist/unstable/cluster/Snowflake.d.ts +2 -2
- package/dist/unstable/cluster/Snowflake.d.ts.map +1 -1
- package/dist/unstable/cluster/Snowflake.js +2 -2
- package/dist/unstable/cluster/Snowflake.js.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.js +24 -20
- package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.js +7 -7
- package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/unstable/cluster/internal/entityManager.js +30 -24
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/cluster/internal/entityReaper.js +2 -2
- package/dist/unstable/cluster/internal/entityReaper.js.map +1 -1
- package/dist/unstable/cluster/internal/resourceMap.js +3 -3
- package/dist/unstable/cluster/internal/resourceMap.js.map +1 -1
- package/dist/unstable/devtools/DevToolsClient.d.ts +2 -2
- package/dist/unstable/devtools/DevToolsClient.d.ts.map +1 -1
- package/dist/unstable/devtools/DevToolsClient.js +9 -8
- package/dist/unstable/devtools/DevToolsClient.js.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.d.ts +4 -4
- package/dist/unstable/devtools/DevToolsSchema.d.ts.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.js +9 -2
- package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
- package/dist/unstable/encoding/Msgpack.d.ts +1 -1
- package/dist/unstable/encoding/Ndjson.d.ts +9 -9
- package/dist/unstable/encoding/Ndjson.d.ts.map +1 -1
- package/dist/unstable/encoding/Ndjson.js.map +1 -1
- package/dist/unstable/encoding/Sse.d.ts +3 -3
- package/dist/unstable/encoding/Sse.d.ts.map +1 -1
- package/dist/unstable/encoding/Sse.js +1 -1
- package/dist/unstable/encoding/Sse.js.map +1 -1
- package/dist/unstable/eventlog/Event.d.ts +0 -6
- package/dist/unstable/eventlog/Event.d.ts.map +1 -1
- package/dist/unstable/eventlog/Event.js +0 -5
- package/dist/unstable/eventlog/Event.js.map +1 -1
- package/dist/unstable/eventlog/EventGroup.d.ts +0 -2
- package/dist/unstable/eventlog/EventGroup.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventGroup.js +0 -2
- package/dist/unstable/eventlog/EventGroup.js.map +1 -1
- package/dist/unstable/eventlog/EventJournal.d.ts +27 -10
- package/dist/unstable/eventlog/EventJournal.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventJournal.js +130 -71
- package/dist/unstable/eventlog/EventJournal.js.map +1 -1
- package/dist/unstable/eventlog/EventLog.d.ts +94 -37
- package/dist/unstable/eventlog/EventLog.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLog.js +225 -151
- package/dist/unstable/eventlog/EventLog.js.map +1 -1
- package/dist/unstable/eventlog/EventLogEncryption.d.ts +11 -9
- package/dist/unstable/eventlog/EventLogEncryption.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogEncryption.js +15 -17
- package/dist/unstable/eventlog/EventLogEncryption.js.map +1 -1
- package/dist/unstable/eventlog/EventLogMessage.d.ts +228 -0
- package/dist/unstable/eventlog/EventLogMessage.d.ts.map +1 -0
- package/dist/unstable/eventlog/EventLogMessage.js +214 -0
- package/dist/unstable/eventlog/EventLogMessage.js.map +1 -0
- package/dist/unstable/eventlog/EventLogRemote.d.ts +112 -194
- package/dist/unstable/eventlog/EventLogRemote.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.js +168 -322
- package/dist/unstable/eventlog/EventLogRemote.js.map +1 -1
- package/dist/unstable/eventlog/EventLogServer.d.ts +26 -48
- package/dist/unstable/eventlog/EventLogServer.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogServer.js +128 -199
- package/dist/unstable/eventlog/EventLogServer.js.map +1 -1
- package/dist/unstable/eventlog/EventLogServerEncrypted.d.ts +60 -0
- package/dist/unstable/eventlog/EventLogServerEncrypted.d.ts.map +1 -0
- package/dist/unstable/eventlog/EventLogServerEncrypted.js +166 -0
- package/dist/unstable/eventlog/EventLogServerEncrypted.js.map +1 -0
- package/dist/unstable/eventlog/EventLogServerUnencrypted.d.ts +183 -0
- package/dist/unstable/eventlog/EventLogServerUnencrypted.d.ts.map +1 -0
- package/dist/unstable/eventlog/EventLogServerUnencrypted.js +461 -0
- package/dist/unstable/eventlog/EventLogServerUnencrypted.js.map +1 -0
- package/dist/unstable/eventlog/EventLogSessionAuth.d.ts +117 -0
- package/dist/unstable/eventlog/EventLogSessionAuth.d.ts.map +1 -0
- package/dist/unstable/eventlog/EventLogSessionAuth.js +284 -0
- package/dist/unstable/eventlog/EventLogSessionAuth.js.map +1 -0
- package/dist/unstable/eventlog/{SqlEventLogJournal.d.ts → SqlEventJournal.d.ts} +2 -2
- package/dist/unstable/eventlog/SqlEventJournal.d.ts.map +1 -0
- package/dist/unstable/eventlog/{SqlEventLogJournal.js → SqlEventJournal.js} +28 -21
- package/dist/unstable/eventlog/SqlEventJournal.js.map +1 -0
- package/dist/unstable/eventlog/{SqlEventLogServer.d.ts → SqlEventLogServerEncrypted.d.ts} +5 -5
- package/dist/unstable/eventlog/SqlEventLogServerEncrypted.d.ts.map +1 -0
- package/dist/unstable/eventlog/{SqlEventLogServer.js → SqlEventLogServerEncrypted.js} +69 -27
- package/dist/unstable/eventlog/SqlEventLogServerEncrypted.js.map +1 -0
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.d.ts +25 -0
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.d.ts.map +1 -0
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js +355 -0
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js.map +1 -0
- package/dist/unstable/eventlog/index.d.ts +22 -2
- package/dist/unstable/eventlog/index.d.ts.map +1 -1
- package/dist/unstable/eventlog/index.js +22 -2
- package/dist/unstable/eventlog/index.js.map +1 -1
- package/dist/unstable/eventlog/internal/identityRootSecretDerivation.d.ts +2 -0
- package/dist/unstable/eventlog/internal/identityRootSecretDerivation.d.ts.map +1 -0
- package/dist/unstable/eventlog/internal/identityRootSecretDerivation.js +89 -0
- package/dist/unstable/eventlog/internal/identityRootSecretDerivation.js.map +1 -0
- package/dist/unstable/http/Cookies.d.ts +51 -6
- package/dist/unstable/http/Cookies.d.ts.map +1 -1
- package/dist/unstable/http/Cookies.js +27 -6
- package/dist/unstable/http/Cookies.js.map +1 -1
- package/dist/unstable/http/Etag.d.ts +2 -2
- package/dist/unstable/http/Etag.d.ts.map +1 -1
- package/dist/unstable/http/Etag.js +7 -3
- package/dist/unstable/http/Etag.js.map +1 -1
- package/dist/unstable/http/FetchHttpClient.d.ts +6 -3
- package/dist/unstable/http/FetchHttpClient.d.ts.map +1 -1
- package/dist/unstable/http/FetchHttpClient.js +5 -5
- package/dist/unstable/http/FetchHttpClient.js.map +1 -1
- package/dist/unstable/http/Headers.d.ts +24 -4
- package/dist/unstable/http/Headers.d.ts.map +1 -1
- package/dist/unstable/http/Headers.js +42 -13
- package/dist/unstable/http/Headers.js.map +1 -1
- package/dist/unstable/http/HttpBody.d.ts +1 -1
- package/dist/unstable/http/HttpClient.d.ts +125 -21
- package/dist/unstable/http/HttpClient.d.ts.map +1 -1
- package/dist/unstable/http/HttpClient.js +197 -19
- package/dist/unstable/http/HttpClient.js.map +1 -1
- package/dist/unstable/http/HttpClientError.d.ts +8 -8
- package/dist/unstable/http/HttpClientRequest.d.ts +43 -15
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.js +131 -21
- package/dist/unstable/http/HttpClientRequest.js.map +1 -1
- package/dist/unstable/http/HttpClientResponse.d.ts +2 -1
- package/dist/unstable/http/HttpClientResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientResponse.js +18 -3
- package/dist/unstable/http/HttpClientResponse.js.map +1 -1
- package/dist/unstable/http/HttpEffect.d.ts +13 -11
- package/dist/unstable/http/HttpEffect.d.ts.map +1 -1
- package/dist/unstable/http/HttpEffect.js +51 -51
- package/dist/unstable/http/HttpEffect.js.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.d.ts +5 -4
- package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.js +6 -10
- package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
- package/dist/unstable/http/HttpMethod.d.ts +4 -4
- package/dist/unstable/http/HttpMethod.d.ts.map +1 -1
- package/dist/unstable/http/HttpMethod.js +3 -3
- package/dist/unstable/http/HttpMethod.js.map +1 -1
- package/dist/unstable/http/HttpMiddleware.d.ts +4 -9
- package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/unstable/http/HttpMiddleware.js +47 -43
- package/dist/unstable/http/HttpMiddleware.js.map +1 -1
- package/dist/unstable/http/HttpPlatform.d.ts +2 -2
- package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
- package/dist/unstable/http/HttpPlatform.js +5 -4
- package/dist/unstable/http/HttpPlatform.js.map +1 -1
- package/dist/unstable/http/HttpRouter.d.ts +9 -8
- package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
- package/dist/unstable/http/HttpRouter.js +36 -36
- package/dist/unstable/http/HttpRouter.js.map +1 -1
- package/dist/unstable/http/HttpServer.d.ts +2 -2
- package/dist/unstable/http/HttpServer.d.ts.map +1 -1
- package/dist/unstable/http/HttpServer.js +4 -4
- package/dist/unstable/http/HttpServer.js.map +1 -1
- package/dist/unstable/http/HttpServerError.d.ts +22 -34
- package/dist/unstable/http/HttpServerError.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerError.js +39 -45
- package/dist/unstable/http/HttpServerError.js.map +1 -1
- package/dist/unstable/http/HttpServerRequest.d.ts +19 -7
- package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRequest.js +307 -13
- package/dist/unstable/http/HttpServerRequest.js.map +1 -1
- package/dist/unstable/http/HttpServerRespondable.d.ts +2 -2
- package/dist/unstable/http/HttpServerRespondable.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRespondable.js +5 -5
- package/dist/unstable/http/HttpServerRespondable.js.map +1 -1
- package/dist/unstable/http/HttpServerResponse.d.ts +52 -5
- package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerResponse.js +240 -5
- package/dist/unstable/http/HttpServerResponse.js.map +1 -1
- package/dist/unstable/http/HttpStaticServer.d.ts +69 -0
- package/dist/unstable/http/HttpStaticServer.d.ts.map +1 -0
- package/dist/unstable/http/HttpStaticServer.js +353 -0
- package/dist/unstable/http/HttpStaticServer.js.map +1 -0
- package/dist/unstable/http/HttpTraceContext.d.ts +3 -2
- package/dist/unstable/http/HttpTraceContext.d.ts.map +1 -1
- package/dist/unstable/http/HttpTraceContext.js +27 -15
- package/dist/unstable/http/HttpTraceContext.js.map +1 -1
- package/dist/unstable/http/Multipart.d.ts +7 -7
- package/dist/unstable/http/Multipart.d.ts.map +1 -1
- package/dist/unstable/http/Multipart.js +7 -7
- package/dist/unstable/http/Multipart.js.map +1 -1
- package/dist/unstable/http/Url.d.ts +604 -0
- package/dist/unstable/http/Url.d.ts.map +1 -0
- package/dist/unstable/http/Url.js +256 -0
- package/dist/unstable/http/Url.js.map +1 -0
- package/dist/unstable/http/UrlParams.d.ts +18 -9
- package/dist/unstable/http/UrlParams.d.ts.map +1 -1
- package/dist/unstable/http/UrlParams.js +6 -7
- package/dist/unstable/http/UrlParams.js.map +1 -1
- package/dist/unstable/http/index.d.ts +8 -0
- package/dist/unstable/http/index.d.ts.map +1 -1
- package/dist/unstable/http/index.js +8 -0
- package/dist/unstable/http/index.js.map +1 -1
- package/dist/unstable/http/internal/preResponseHandler.d.ts +2 -0
- package/dist/unstable/http/internal/preResponseHandler.d.ts.map +1 -0
- package/dist/unstable/http/internal/preResponseHandler.js +10 -0
- package/dist/unstable/http/internal/preResponseHandler.js.map +1 -0
- package/dist/unstable/httpapi/HttpApi.d.ts +11 -11
- package/dist/unstable/httpapi/HttpApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApi.js +8 -8
- package/dist/unstable/httpapi/HttpApi.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts +12 -9
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +73 -48
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.d.ts +82 -7
- package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.js +79 -11
- package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +210 -105
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.js +52 -47
- package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.d.ts +66 -29
- package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.js +138 -32
- package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.d.ts +9 -8
- package/dist/unstable/httpapi/HttpApiGroup.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.js +4 -4
- package/dist/unstable/httpapi/HttpApiGroup.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +49 -17
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.js +38 -8
- package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.d.ts +88 -9
- package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.js +86 -11
- package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSecurity.d.ts +9 -6
- package/dist/unstable/httpapi/HttpApiSecurity.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSecurity.js +6 -6
- package/dist/unstable/httpapi/HttpApiSecurity.js.map +1 -1
- package/dist/unstable/httpapi/OpenApi.d.ts +17 -25
- package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/OpenApi.js +59 -60
- package/dist/unstable/httpapi/OpenApi.js.map +1 -1
- package/dist/unstable/observability/Otlp.d.ts +12 -12
- package/dist/unstable/observability/Otlp.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.d.ts +2 -2
- package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.js +8 -8
- package/dist/unstable/observability/OtlpExporter.js.map +1 -1
- package/dist/unstable/observability/OtlpLogger.d.ts +4 -4
- package/dist/unstable/observability/OtlpLogger.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpLogger.js +7 -4
- package/dist/unstable/observability/OtlpLogger.js.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.d.ts +4 -4
- package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.js +2 -2
- package/dist/unstable/observability/OtlpMetrics.js.map +1 -1
- package/dist/unstable/observability/OtlpSerialization.d.ts +2 -2
- package/dist/unstable/observability/OtlpSerialization.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpSerialization.js +2 -2
- package/dist/unstable/observability/OtlpSerialization.js.map +1 -1
- package/dist/unstable/observability/OtlpTracer.d.ts +4 -4
- package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpTracer.js +7 -3
- package/dist/unstable/observability/OtlpTracer.js.map +1 -1
- package/dist/unstable/observability/PrometheusMetrics.d.ts +3 -3
- package/dist/unstable/observability/PrometheusMetrics.d.ts.map +1 -1
- package/dist/unstable/observability/PrometheusMetrics.js +4 -33
- package/dist/unstable/observability/PrometheusMetrics.js.map +1 -1
- package/dist/unstable/observability/internal/protobuf.js +4 -4
- package/dist/unstable/observability/internal/protobuf.js.map +1 -1
- package/dist/unstable/persistence/KeyValueStore.d.ts +24 -3
- package/dist/unstable/persistence/KeyValueStore.d.ts.map +1 -1
- package/dist/unstable/persistence/KeyValueStore.js +144 -2
- package/dist/unstable/persistence/KeyValueStore.js.map +1 -1
- package/dist/unstable/persistence/Persistable.d.ts +2 -2
- package/dist/unstable/persistence/Persistable.d.ts.map +1 -1
- package/dist/unstable/persistence/Persistable.js +1 -1
- package/dist/unstable/persistence/Persistable.js.map +1 -1
- package/dist/unstable/persistence/PersistedCache.d.ts +1 -2
- package/dist/unstable/persistence/PersistedCache.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedCache.js +10 -11
- package/dist/unstable/persistence/PersistedCache.js.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.d.ts +16 -16
- package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.js +9 -9
- package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
- package/dist/unstable/persistence/Persistence.d.ts +5 -5
- package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
- package/dist/unstable/persistence/Persistence.js +5 -5
- package/dist/unstable/persistence/Persistence.js.map +1 -1
- package/dist/unstable/persistence/RateLimiter.d.ts +9 -9
- package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
- package/dist/unstable/persistence/RateLimiter.js +4 -4
- package/dist/unstable/persistence/RateLimiter.js.map +1 -1
- package/dist/unstable/persistence/Redis.d.ts +3 -3
- package/dist/unstable/persistence/Redis.d.ts.map +1 -1
- package/dist/unstable/persistence/Redis.js +2 -2
- package/dist/unstable/persistence/Redis.js.map +1 -1
- package/dist/unstable/process/ChildProcess.d.ts +5 -128
- package/dist/unstable/process/ChildProcess.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcess.js +1 -65
- package/dist/unstable/process/ChildProcess.js.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.d.ts +83 -8
- package/dist/unstable/process/ChildProcessSpawner.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.js +22 -2
- package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
- package/dist/unstable/reactivity/AsyncResult.d.ts +37 -17
- package/dist/unstable/reactivity/AsyncResult.d.ts.map +1 -1
- package/dist/unstable/reactivity/AsyncResult.js +9 -0
- package/dist/unstable/reactivity/AsyncResult.js.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts +108 -47
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +105 -25
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts +25 -20
- package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.js +58 -26
- package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.d.ts +8 -2
- package/dist/unstable/reactivity/AtomRegistry.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.js +57 -14
- package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.d.ts +12 -12
- package/dist/unstable/reactivity/AtomRpc.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.js +59 -31
- package/dist/unstable/reactivity/AtomRpc.js.map +1 -1
- package/dist/unstable/reactivity/Reactivity.d.ts +2 -2
- package/dist/unstable/reactivity/Reactivity.d.ts.map +1 -1
- package/dist/unstable/reactivity/Reactivity.js +6 -6
- package/dist/unstable/reactivity/Reactivity.js.map +1 -1
- package/dist/unstable/rpc/Rpc.d.ts +137 -19
- package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
- package/dist/unstable/rpc/Rpc.js +99 -7
- package/dist/unstable/rpc/Rpc.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts +26 -47
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +117 -75
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/rpc/RpcClientError.d.ts +2 -2
- package/dist/unstable/rpc/RpcGroup.d.ts +15 -11
- package/dist/unstable/rpc/RpcGroup.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcGroup.js +30 -20
- package/dist/unstable/rpc/RpcGroup.js.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.d.ts +12 -12
- package/dist/unstable/rpc/RpcMiddleware.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.js +5 -5
- package/dist/unstable/rpc/RpcMiddleware.js.map +1 -1
- package/dist/unstable/rpc/RpcSchema.d.ts +14 -1
- package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSchema.js +17 -2
- package/dist/unstable/rpc/RpcSchema.js.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.d.ts +13 -2
- package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.js +60 -27
- package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts +8 -12
- package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +73 -43
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/rpc/RpcWorker.d.ts +2 -2
- package/dist/unstable/rpc/RpcWorker.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcWorker.js +4 -4
- package/dist/unstable/rpc/RpcWorker.js.map +1 -1
- package/dist/unstable/rpc/Utils.d.ts +6 -3
- package/dist/unstable/rpc/Utils.d.ts.map +1 -1
- package/dist/unstable/rpc/Utils.js +46 -5
- package/dist/unstable/rpc/Utils.js.map +1 -1
- package/dist/unstable/schema/Model.d.ts +24 -3
- package/dist/unstable/schema/Model.d.ts.map +1 -1
- package/dist/unstable/schema/Model.js +17 -4
- package/dist/unstable/schema/Model.js.map +1 -1
- package/dist/unstable/schema/VariantSchema.d.ts +7 -7
- package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
- package/dist/unstable/schema/VariantSchema.js +7 -18
- package/dist/unstable/schema/VariantSchema.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts +35 -15
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +34 -27
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/dist/unstable/socket/SocketServer.d.ts +8 -5
- package/dist/unstable/socket/SocketServer.d.ts.map +1 -1
- package/dist/unstable/socket/SocketServer.js +2 -2
- package/dist/unstable/socket/SocketServer.js.map +1 -1
- package/dist/unstable/sql/Migrator.d.ts +1 -1
- package/dist/unstable/sql/Migrator.d.ts.map +1 -1
- package/dist/unstable/sql/Migrator.js +2 -2
- package/dist/unstable/sql/Migrator.js.map +1 -1
- package/dist/unstable/sql/SqlClient.d.ts +24 -6
- package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
- package/dist/unstable/sql/SqlClient.js +37 -32
- package/dist/unstable/sql/SqlClient.js.map +1 -1
- package/dist/unstable/sql/SqlConnection.d.ts +2 -2
- package/dist/unstable/sql/SqlConnection.d.ts.map +1 -1
- package/dist/unstable/sql/SqlConnection.js +5 -2
- package/dist/unstable/sql/SqlConnection.js.map +1 -1
- package/dist/unstable/sql/SqlError.d.ts +237 -17
- package/dist/unstable/sql/SqlError.d.ts.map +1 -1
- package/dist/unstable/sql/SqlError.js +260 -4
- package/dist/unstable/sql/SqlError.js.map +1 -1
- package/dist/unstable/sql/SqlModel.d.ts +8 -9
- package/dist/unstable/sql/SqlModel.d.ts.map +1 -1
- package/dist/unstable/sql/SqlModel.js +12 -38
- package/dist/unstable/sql/SqlModel.js.map +1 -1
- package/dist/unstable/sql/SqlResolver.js +24 -17
- package/dist/unstable/sql/SqlResolver.js.map +1 -1
- package/dist/unstable/sql/SqlSchema.d.ts +17 -6
- package/dist/unstable/sql/SqlSchema.d.ts.map +1 -1
- package/dist/unstable/sql/SqlSchema.js +17 -7
- package/dist/unstable/sql/SqlSchema.js.map +1 -1
- package/dist/unstable/sql/Statement.d.ts +3 -5
- package/dist/unstable/sql/Statement.d.ts.map +1 -1
- package/dist/unstable/sql/Statement.js +14 -13
- package/dist/unstable/sql/Statement.js.map +1 -1
- package/dist/unstable/workers/Transferable.d.ts +4 -4
- package/dist/unstable/workers/Transferable.d.ts.map +1 -1
- package/dist/unstable/workers/Transferable.js +7 -7
- package/dist/unstable/workers/Transferable.js.map +1 -1
- package/dist/unstable/workers/Worker.d.ts +3 -3
- package/dist/unstable/workers/Worker.d.ts.map +1 -1
- package/dist/unstable/workers/Worker.js +6 -3
- package/dist/unstable/workers/Worker.js.map +1 -1
- package/dist/unstable/workers/WorkerError.d.ts +5 -5
- package/dist/unstable/workers/WorkerRunner.d.ts +2 -2
- package/dist/unstable/workers/WorkerRunner.d.ts.map +1 -1
- package/dist/unstable/workers/WorkerRunner.js +5 -2
- package/dist/unstable/workers/WorkerRunner.js.map +1 -1
- package/dist/unstable/workflow/Activity.d.ts +8 -3
- package/dist/unstable/workflow/Activity.d.ts.map +1 -1
- package/dist/unstable/workflow/Activity.js +25 -11
- package/dist/unstable/workflow/Activity.js.map +1 -1
- package/dist/unstable/workflow/DurableClock.d.ts +3 -6
- package/dist/unstable/workflow/DurableClock.d.ts.map +1 -1
- package/dist/unstable/workflow/DurableClock.js +6 -6
- package/dist/unstable/workflow/DurableClock.js.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.d.ts +2 -5
- package/dist/unstable/workflow/DurableDeferred.d.ts.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.js +33 -15
- package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts +12 -14
- package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
- package/dist/unstable/workflow/Workflow.js +30 -26
- package/dist/unstable/workflow/Workflow.js.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts +24 -7
- package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js +165 -16
- package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
- package/dist/unstable/workflow/WorkflowProxyServer.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowProxyServer.js +4 -4
- package/dist/unstable/workflow/WorkflowProxyServer.js.map +1 -1
- package/package.json +11 -10
- package/src/Array.ts +304 -447
- package/src/BigDecimal.ts +137 -82
- package/src/BigInt.ts +53 -45
- package/src/Brand.ts +3 -5
- package/src/Cache.ts +27 -54
- package/src/Cause.ts +57 -22
- package/src/Channel.ts +687 -220
- package/src/Chunk.ts +149 -331
- package/src/Clock.ts +2 -2
- package/src/Combiner.ts +280 -13
- package/src/Config.ts +214 -52
- package/src/ConfigProvider.ts +5 -5
- package/src/Console.ts +2 -2
- package/src/Context.ts +1454 -0
- package/src/Cron.ts +155 -63
- package/src/Data.ts +530 -368
- package/src/DateTime.ts +77 -258
- package/src/Deferred.ts +15 -6
- package/src/Duration.ts +151 -81
- package/src/Effect.ts +1633 -1055
- package/src/Effectable.ts +47 -0
- package/src/Equal.ts +293 -109
- package/src/Equivalence.ts +114 -52
- package/src/ErrorReporter.ts +458 -0
- package/src/ExecutionPlan.ts +8 -9
- package/src/Exit.ts +24 -12
- package/src/Fiber.ts +17 -8
- package/src/FiberHandle.ts +15 -14
- package/src/FiberMap.ts +27 -27
- package/src/FiberSet.ts +5 -5
- package/src/FileSystem.ts +30 -26
- package/src/Filter.ts +4 -62
- package/src/Formatter.ts +268 -60
- package/src/Function.ts +2 -10
- package/src/Graph.ts +123 -112
- package/src/Hash.ts +2 -2
- package/src/HashMap.ts +26 -19
- package/src/Inspectable.ts +2 -22
- package/src/Iterable.ts +117 -63
- package/src/JsonSchema.ts +383 -10
- package/src/Latch.ts +85 -3
- package/src/Layer.ts +728 -441
- package/src/LayerMap.ts +38 -35
- package/src/LogLevel.ts +37 -0
- package/src/Logger.ts +35 -102
- package/src/ManagedRuntime.ts +61 -48
- package/src/Metric.ts +64 -66
- package/src/MutableHashMap.ts +9 -0
- package/src/MutableHashSet.ts +9 -0
- package/src/MutableList.ts +3 -0
- package/src/Newtype.ts +308 -0
- package/src/Number.ts +98 -29
- package/src/Optic.ts +948 -19
- package/src/Option.ts +34 -24
- package/src/Order.ts +39 -32
- package/src/PartitionedSemaphore.ts +414 -0
- package/src/Path.ts +2 -2
- package/src/Pool.ts +9 -9
- package/src/Predicate.ts +1 -1
- package/src/PubSub.ts +20 -11
- package/src/Pull.ts +1 -1
- package/src/Queue.ts +11 -9
- package/src/Random.ts +51 -14
- package/src/RcMap.ts +19 -19
- package/src/RcRef.ts +1 -1
- package/src/Record.ts +94 -199
- package/src/Redactable.ts +146 -72
- package/src/Reducer.ts +166 -7
- package/src/References.ts +283 -287
- package/src/Request.ts +5 -5
- package/src/RequestResolver.ts +34 -35
- package/src/Resource.ts +6 -5
- package/src/Result.ts +2 -4
- package/src/Runtime.ts +102 -6
- package/src/Schedule.ts +243 -336
- package/src/Scheduler.ts +52 -129
- package/src/Schema.ts +3769 -597
- package/src/SchemaAST.ts +480 -302
- package/src/SchemaGetter.ts +80 -24
- package/src/SchemaIssue.ts +28 -15
- package/src/SchemaParser.ts +100 -29
- package/src/SchemaRepresentation.ts +57 -33
- package/src/SchemaTransformation.ts +321 -32
- package/src/Scope.ts +2 -2
- package/src/ScopedCache.ts +8 -8
- package/src/Semaphore.ts +268 -182
- package/src/Sink.ts +89 -34
- package/src/Stdio.ts +29 -6
- package/src/Stream.ts +908 -752
- package/src/String.ts +122 -69
- package/src/Struct.ts +7 -7
- package/src/SubscriptionRef.ts +98 -118
- package/src/Terminal.ts +5 -4
- package/src/Tracer.ts +23 -22
- package/src/Trie.ts +44 -31
- package/src/TxChunk.ts +26 -16
- package/src/TxDeferred.ts +391 -0
- package/src/TxHashMap.ts +347 -291
- package/src/TxHashSet.ts +54 -61
- package/src/TxPriorityQueue.ts +762 -0
- package/src/TxPubSub.ts +787 -0
- package/src/TxQueue.ts +221 -245
- package/src/TxReentrantLock.ts +729 -0
- package/src/TxRef.ts +31 -31
- package/src/TxSemaphore.ts +203 -31
- package/src/TxSubscriptionRef.ts +637 -0
- package/src/Types.ts +75 -23
- package/src/Unify.ts +26 -2
- package/src/Utils.ts +137 -111
- package/src/index.ts +896 -73
- package/src/internal/core.ts +9 -10
- package/src/internal/dateTime.ts +91 -96
- package/src/internal/effect.ts +1179 -614
- package/src/internal/hashMap.ts +12 -10
- package/src/internal/layer.ts +7 -7
- package/src/internal/option.ts +7 -0
- package/src/internal/random.ts +20 -0
- package/src/internal/rcRef.ts +12 -12
- package/src/internal/references.ts +72 -0
- package/src/internal/request.ts +8 -8
- package/src/internal/schedule.ts +3 -1
- package/src/internal/schema/annotations.ts +2 -0
- package/src/internal/schema/representation.ts +82 -97
- package/src/internal/schema/schema.ts +68 -1
- package/src/internal/trie.ts +21 -15
- package/src/testing/TestClock.ts +6 -6
- package/src/testing/TestSchema.ts +333 -36
- package/src/testing/index.ts +64 -1
- package/src/unstable/ai/AiError.ts +111 -53
- package/src/unstable/ai/AnthropicStructuredOutput.ts +7 -3
- package/src/unstable/ai/Chat.ts +136 -88
- package/src/unstable/ai/EmbeddingModel.ts +209 -0
- package/src/unstable/ai/IdGenerator.ts +2 -2
- package/src/unstable/ai/LanguageModel.ts +685 -255
- package/src/unstable/ai/McpSchema.ts +84 -22
- package/src/unstable/ai/McpServer.ts +307 -87
- package/src/unstable/ai/Model.ts +44 -13
- package/src/unstable/ai/OpenAiStructuredOutput.ts +9 -2
- package/src/unstable/ai/Prompt.ts +23 -29
- package/src/unstable/ai/Response.ts +29 -31
- package/src/unstable/ai/ResponseIdTracker.ts +95 -0
- package/src/unstable/ai/Telemetry.ts +2 -2
- package/src/unstable/ai/Tokenizer.ts +2 -2
- package/src/unstable/ai/Tool.ts +62 -36
- package/src/unstable/ai/Toolkit.ts +17 -26
- package/src/unstable/ai/index.ts +24 -1
- package/src/unstable/ai/internal/codec-transformer.ts +3 -9
- package/src/unstable/cli/Argument.ts +5 -8
- package/src/unstable/cli/CliError.ts +67 -66
- package/src/unstable/cli/CliOutput.ts +87 -15
- package/src/unstable/cli/Command.ts +808 -193
- package/src/unstable/cli/Completions.ts +107 -0
- package/src/unstable/cli/Flag.ts +5 -6
- package/src/unstable/cli/GlobalFlag.ts +242 -0
- package/src/unstable/cli/HelpDoc.ts +91 -11
- package/src/unstable/cli/Param.ts +54 -27
- package/src/unstable/cli/Primitive.ts +2 -2
- package/src/unstable/cli/Prompt.ts +275 -104
- package/src/unstable/cli/index.ts +12 -0
- package/src/unstable/cli/internal/command.ts +125 -64
- package/src/unstable/cli/internal/completions/bash.ts +7 -7
- package/src/unstable/cli/internal/completions/{CommandDescriptor.ts → descriptor.ts} +16 -58
- package/src/unstable/cli/internal/completions/fish.ts +7 -7
- package/src/unstable/cli/internal/completions/zsh.ts +8 -14
- package/src/unstable/cli/internal/config.ts +49 -0
- package/src/unstable/cli/internal/help.ts +171 -0
- package/src/unstable/cli/internal/parser.ts +201 -84
- package/src/unstable/cluster/ClusterCron.ts +2 -2
- package/src/unstable/cluster/ClusterSchema.ts +38 -10
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +142 -80
- package/src/unstable/cluster/DeliverAt.ts +1 -1
- package/src/unstable/cluster/Entity.ts +58 -45
- package/src/unstable/cluster/EntityAddress.ts +1 -1
- package/src/unstable/cluster/EntityProxy.ts +3 -3
- package/src/unstable/cluster/EntityProxyServer.ts +6 -6
- package/src/unstable/cluster/EntityResource.ts +6 -6
- package/src/unstable/cluster/HttpRunner.ts +2 -2
- package/src/unstable/cluster/K8sHttpClient.ts +10 -10
- package/src/unstable/cluster/Message.ts +30 -17
- package/src/unstable/cluster/MessageStorage.ts +74 -45
- package/src/unstable/cluster/Reply.ts +13 -10
- package/src/unstable/cluster/Runner.ts +1 -1
- package/src/unstable/cluster/RunnerAddress.ts +1 -1
- package/src/unstable/cluster/RunnerHealth.ts +2 -2
- package/src/unstable/cluster/RunnerServer.ts +11 -14
- package/src/unstable/cluster/RunnerStorage.ts +9 -9
- package/src/unstable/cluster/Runners.ts +22 -18
- package/src/unstable/cluster/ShardId.ts +84 -74
- package/src/unstable/cluster/Sharding.ts +75 -60
- package/src/unstable/cluster/ShardingConfig.ts +39 -40
- package/src/unstable/cluster/Snowflake.ts +2 -2
- package/src/unstable/cluster/SqlMessageStorage.ts +29 -20
- package/src/unstable/cluster/SqlRunnerStorage.ts +13 -7
- package/src/unstable/cluster/internal/entityManager.ts +60 -41
- package/src/unstable/cluster/internal/entityReaper.ts +2 -2
- package/src/unstable/cluster/internal/resourceMap.ts +3 -3
- package/src/unstable/devtools/DevToolsClient.ts +26 -21
- package/src/unstable/devtools/DevToolsSchema.ts +16 -3
- package/src/unstable/encoding/Ndjson.ts +17 -17
- package/src/unstable/encoding/Sse.ts +3 -5
- package/src/unstable/eventlog/Event.ts +0 -8
- package/src/unstable/eventlog/EventGroup.ts +0 -4
- package/src/unstable/eventlog/EventJournal.ts +148 -80
- package/src/unstable/eventlog/EventLog.ts +360 -234
- package/src/unstable/eventlog/EventLogEncryption.ts +18 -32
- package/src/unstable/eventlog/EventLogMessage.ts +277 -0
- package/src/unstable/eventlog/EventLogRemote.ts +264 -410
- package/src/unstable/eventlog/EventLogServer.ts +183 -275
- package/src/unstable/eventlog/EventLogServerEncrypted.ts +206 -0
- package/src/unstable/eventlog/EventLogServerUnencrypted.ts +749 -0
- package/src/unstable/eventlog/EventLogSessionAuth.ts +437 -0
- package/src/unstable/eventlog/{SqlEventLogJournal.ts → SqlEventJournal.ts} +38 -22
- package/src/unstable/eventlog/{SqlEventLogServer.ts → SqlEventLogServerEncrypted.ts} +110 -43
- package/src/unstable/eventlog/SqlEventLogServerUnencrypted.ts +506 -0
- package/src/unstable/eventlog/index.ts +27 -2
- package/src/unstable/eventlog/internal/identityRootSecretDerivation.ts +153 -0
- package/src/unstable/http/Cookies.ts +94 -11
- package/src/unstable/http/Etag.ts +7 -5
- package/src/unstable/http/FetchHttpClient.ts +5 -5
- package/src/unstable/http/Headers.ts +70 -20
- package/src/unstable/http/HttpClient.ts +385 -42
- package/src/unstable/http/HttpClientRequest.ts +151 -39
- package/src/unstable/http/HttpClientResponse.ts +24 -8
- package/src/unstable/http/HttpEffect.ts +71 -77
- package/src/unstable/http/HttpIncomingMessage.ts +9 -8
- package/src/unstable/http/HttpMethod.ts +16 -4
- package/src/unstable/http/HttpMiddleware.ts +50 -50
- package/src/unstable/http/HttpPlatform.ts +5 -4
- package/src/unstable/http/HttpRouter.ts +46 -46
- package/src/unstable/http/HttpServer.ts +5 -11
- package/src/unstable/http/HttpServerError.ts +45 -47
- package/src/unstable/http/HttpServerRequest.ts +414 -23
- package/src/unstable/http/HttpServerRespondable.ts +6 -6
- package/src/unstable/http/HttpServerResponse.ts +351 -13
- package/src/unstable/http/HttpStaticServer.ts +456 -0
- package/src/unstable/http/HttpTraceContext.ts +31 -17
- package/src/unstable/http/Multipart.ts +8 -8
- package/src/unstable/http/Url.ts +650 -0
- package/src/unstable/http/UrlParams.ts +30 -18
- package/src/unstable/http/index.ts +10 -0
- package/src/unstable/http/internal/preResponseHandler.ts +15 -0
- package/src/unstable/httpapi/HttpApi.ts +22 -22
- package/src/unstable/httpapi/HttpApiBuilder.ts +156 -66
- package/src/unstable/httpapi/HttpApiClient.ts +185 -34
- package/src/unstable/httpapi/HttpApiEndpoint.ts +225 -114
- package/src/unstable/httpapi/HttpApiError.ts +129 -30
- package/src/unstable/httpapi/HttpApiGroup.ts +18 -17
- package/src/unstable/httpapi/HttpApiMiddleware.ts +95 -32
- package/src/unstable/httpapi/HttpApiSchema.ts +106 -11
- package/src/unstable/httpapi/HttpApiSecurity.ts +13 -13
- package/src/unstable/httpapi/OpenApi.ts +74 -73
- package/src/unstable/observability/Otlp.ts +12 -12
- package/src/unstable/observability/OtlpExporter.ts +14 -10
- package/src/unstable/observability/OtlpLogger.ts +13 -9
- package/src/unstable/observability/OtlpMetrics.ts +6 -6
- package/src/unstable/observability/OtlpSerialization.ts +2 -2
- package/src/unstable/observability/OtlpTracer.ts +14 -10
- package/src/unstable/observability/PrometheusMetrics.ts +5 -5
- package/src/unstable/observability/internal/protobuf.ts +4 -4
- package/src/unstable/persistence/KeyValueStore.ts +226 -3
- package/src/unstable/persistence/Persistable.ts +3 -3
- package/src/unstable/persistence/PersistedCache.ts +20 -17
- package/src/unstable/persistence/PersistedQueue.ts +21 -21
- package/src/unstable/persistence/Persistence.ts +7 -7
- package/src/unstable/persistence/RateLimiter.ts +7 -7
- package/src/unstable/persistence/Redis.ts +2 -2
- package/src/unstable/process/ChildProcess.ts +6 -208
- package/src/unstable/process/ChildProcessSpawner.ts +114 -15
- package/src/unstable/reactivity/AsyncResult.ts +59 -17
- package/src/unstable/reactivity/Atom.ts +280 -124
- package/src/unstable/reactivity/AtomHttpApi.ts +127 -61
- package/src/unstable/reactivity/AtomRegistry.ts +70 -16
- package/src/unstable/reactivity/AtomRpc.ts +82 -37
- package/src/unstable/reactivity/Reactivity.ts +6 -6
- package/src/unstable/rpc/Rpc.ts +212 -32
- package/src/unstable/rpc/RpcClient.ts +161 -142
- package/src/unstable/rpc/RpcGroup.ts +51 -34
- package/src/unstable/rpc/RpcMiddleware.ts +28 -22
- package/src/unstable/rpc/RpcSchema.ts +24 -6
- package/src/unstable/rpc/RpcSerialization.ts +97 -54
- package/src/unstable/rpc/RpcServer.ts +91 -65
- package/src/unstable/rpc/RpcWorker.ts +5 -5
- package/src/unstable/rpc/Utils.ts +63 -4
- package/src/unstable/schema/Model.ts +35 -6
- package/src/unstable/schema/VariantSchema.ts +14 -27
- package/src/unstable/socket/Socket.ts +102 -62
- package/src/unstable/socket/SocketServer.ts +2 -2
- package/src/unstable/sql/Migrator.ts +7 -5
- package/src/unstable/sql/SqlClient.ts +48 -19
- package/src/unstable/sql/SqlConnection.ts +2 -2
- package/src/unstable/sql/SqlError.ts +365 -11
- package/src/unstable/sql/SqlModel.ts +57 -85
- package/src/unstable/sql/SqlResolver.ts +28 -20
- package/src/unstable/sql/SqlSchema.ts +42 -26
- package/src/unstable/sql/Statement.ts +21 -25
- package/src/unstable/workers/Transferable.ts +17 -19
- package/src/unstable/workers/Worker.ts +4 -4
- package/src/unstable/workers/WorkerRunner.ts +2 -2
- package/src/unstable/workflow/Activity.ts +36 -13
- package/src/unstable/workflow/DurableClock.ts +11 -11
- package/src/unstable/workflow/DurableDeferred.ts +36 -18
- package/src/unstable/workflow/Workflow.ts +46 -35
- package/src/unstable/workflow/WorkflowEngine.ts +236 -23
- package/src/unstable/workflow/WorkflowProxyServer.ts +4 -4
- package/dist/NullOr.d.ts +0 -149
- package/dist/NullOr.d.ts.map +0 -1
- package/dist/NullOr.js +0 -152
- package/dist/NullOr.js.map +0 -1
- package/dist/ServiceMap.d.ts +0 -1126
- package/dist/ServiceMap.d.ts.map +0 -1
- package/dist/ServiceMap.js.map +0 -1
- package/dist/internal/schema/to-codec.d.ts +0 -2
- package/dist/internal/schema/to-codec.d.ts.map +0 -1
- package/dist/internal/schema/to-codec.js +0 -129
- package/dist/internal/schema/to-codec.js.map +0 -1
- package/dist/unstable/cli/internal/builtInFlags.d.ts +0 -7
- package/dist/unstable/cli/internal/builtInFlags.d.ts.map +0 -1
- package/dist/unstable/cli/internal/builtInFlags.js +0 -44
- package/dist/unstable/cli/internal/builtInFlags.js.map +0 -1
- package/dist/unstable/cli/internal/completions/CommandDescriptor.d.ts +0 -2
- package/dist/unstable/cli/internal/completions/CommandDescriptor.d.ts.map +0 -1
- package/dist/unstable/cli/internal/completions/CommandDescriptor.js.map +0 -1
- package/dist/unstable/cli/internal/completions/Completions.d.ts +0 -2
- package/dist/unstable/cli/internal/completions/Completions.d.ts.map +0 -1
- package/dist/unstable/cli/internal/completions/Completions.js +0 -23
- package/dist/unstable/cli/internal/completions/Completions.js.map +0 -1
- package/dist/unstable/eventlog/SqlEventLogJournal.d.ts.map +0 -1
- package/dist/unstable/eventlog/SqlEventLogJournal.js.map +0 -1
- package/dist/unstable/eventlog/SqlEventLogServer.d.ts.map +0 -1
- package/dist/unstable/eventlog/SqlEventLogServer.js.map +0 -1
- package/src/NullOr.ts +0 -204
- package/src/ServiceMap.ts +0 -1410
- package/src/internal/schema/to-codec.ts +0 -148
- package/src/unstable/cli/internal/builtInFlags.ts +0 -78
- package/src/unstable/cli/internal/completions/Completions.ts +0 -31
package/src/internal/effect.ts
CHANGED
|
@@ -2,6 +2,7 @@ import * as Arr from "../Array.ts"
|
|
|
2
2
|
import type * as Cause from "../Cause.ts"
|
|
3
3
|
import type * as Clock from "../Clock.ts"
|
|
4
4
|
import type * as Console from "../Console.ts"
|
|
5
|
+
import * as Context from "../Context.ts"
|
|
5
6
|
import * as Duration from "../Duration.ts"
|
|
6
7
|
import type * as Effect from "../Effect.ts"
|
|
7
8
|
import * as Equal from "../Equal.ts"
|
|
@@ -24,23 +25,10 @@ import { pipeArguments } from "../Pipeable.ts"
|
|
|
24
25
|
import type * as Predicate from "../Predicate.ts"
|
|
25
26
|
import { hasProperty, isIterable, isString, isTagged } from "../Predicate.ts"
|
|
26
27
|
import { currentFiberTypeId, redact } from "../Redactable.ts"
|
|
27
|
-
import {
|
|
28
|
-
CurrentConcurrency,
|
|
29
|
-
CurrentLogAnnotations,
|
|
30
|
-
CurrentLogLevel,
|
|
31
|
-
CurrentLogSpans,
|
|
32
|
-
CurrentStackFrame,
|
|
33
|
-
MinimumLogLevel,
|
|
34
|
-
type StackFrame,
|
|
35
|
-
TracerEnabled,
|
|
36
|
-
TracerSpanAnnotations,
|
|
37
|
-
TracerSpanLinks,
|
|
38
|
-
TracerTimingEnabled
|
|
39
|
-
} from "../References.ts"
|
|
28
|
+
import type { StackFrame } from "../References.ts"
|
|
40
29
|
import * as Result from "../Result.ts"
|
|
41
30
|
import * as Scheduler from "../Scheduler.ts"
|
|
42
31
|
import type * as Scope from "../Scope.ts"
|
|
43
|
-
import * as ServiceMap from "../ServiceMap.ts"
|
|
44
32
|
import * as Tracer from "../Tracer.ts"
|
|
45
33
|
import type {
|
|
46
34
|
Concurrency,
|
|
@@ -49,7 +37,9 @@ import type {
|
|
|
49
37
|
ExcludeTag,
|
|
50
38
|
ExtractReason,
|
|
51
39
|
ExtractTag,
|
|
40
|
+
NarrowReason,
|
|
52
41
|
NoInfer,
|
|
42
|
+
OmitReason,
|
|
53
43
|
ReasonOf,
|
|
54
44
|
ReasonTags,
|
|
55
45
|
Simplify,
|
|
@@ -68,7 +58,6 @@ import {
|
|
|
68
58
|
contA,
|
|
69
59
|
contAll,
|
|
70
60
|
contE,
|
|
71
|
-
Die,
|
|
72
61
|
evaluate,
|
|
73
62
|
exitDie,
|
|
74
63
|
exitFail,
|
|
@@ -94,6 +83,19 @@ import {
|
|
|
94
83
|
} from "./core.ts"
|
|
95
84
|
import * as doNotation from "./doNotation.ts"
|
|
96
85
|
import * as InternalMetric from "./metric.ts"
|
|
86
|
+
import {
|
|
87
|
+
CurrentConcurrency,
|
|
88
|
+
CurrentErrorReporters,
|
|
89
|
+
CurrentLogAnnotations,
|
|
90
|
+
CurrentLogLevel,
|
|
91
|
+
CurrentLogSpans,
|
|
92
|
+
CurrentStackFrame,
|
|
93
|
+
MinimumLogLevel,
|
|
94
|
+
TracerEnabled,
|
|
95
|
+
TracerSpanAnnotations,
|
|
96
|
+
TracerSpanLinks,
|
|
97
|
+
TracerTimingEnabled
|
|
98
|
+
} from "./references.ts"
|
|
97
99
|
import { addSpanStackTrace, type ErrorWithStackTraceLimit, makeStackCleaner } from "./tracer.ts"
|
|
98
100
|
import { version } from "./version.ts"
|
|
99
101
|
|
|
@@ -213,17 +215,18 @@ export const causeInterruptors = <E>(self: Cause.Cause<E>): ReadonlySet<number>
|
|
|
213
215
|
const emptySet = new Set<number>()
|
|
214
216
|
|
|
215
217
|
/** @internal */
|
|
216
|
-
export const hasInterruptsOnly = <E>(self: Cause.Cause<E>): boolean =>
|
|
218
|
+
export const hasInterruptsOnly = <E>(self: Cause.Cause<E>): boolean =>
|
|
219
|
+
self.reasons.length > 0 && self.reasons.every(isInterruptReason)
|
|
217
220
|
|
|
218
221
|
/** @internal */
|
|
219
222
|
export const reasonAnnotations = <E>(
|
|
220
223
|
self: Cause.Reason<E>
|
|
221
|
-
):
|
|
224
|
+
): Context.Context<never> => Context.makeUnsafe(self.annotations)
|
|
222
225
|
|
|
223
226
|
/** @internal */
|
|
224
227
|
export const causeAnnotations = <E>(
|
|
225
228
|
self: Cause.Cause<E>
|
|
226
|
-
):
|
|
229
|
+
): Context.Context<never> => {
|
|
227
230
|
const map = new Map<string, unknown>()
|
|
228
231
|
for (const f of self.reasons) {
|
|
229
232
|
if (f.annotations.size > 0) {
|
|
@@ -232,7 +235,7 @@ export const causeAnnotations = <E>(
|
|
|
232
235
|
}
|
|
233
236
|
}
|
|
234
237
|
}
|
|
235
|
-
return
|
|
238
|
+
return Context.makeUnsafe(map)
|
|
236
239
|
}
|
|
237
240
|
|
|
238
241
|
/** @internal */
|
|
@@ -341,7 +344,8 @@ export const causePrettyErrors = <E>(self: Cause.Cause<E>): Array<Error> => {
|
|
|
341
344
|
return errors
|
|
342
345
|
}
|
|
343
346
|
|
|
344
|
-
|
|
347
|
+
/** @internal */
|
|
348
|
+
export const causePrettyError = (
|
|
345
349
|
original: Record<string, unknown> | Error,
|
|
346
350
|
annotations?: ReadonlyMap<string, unknown>
|
|
347
351
|
): Error => {
|
|
@@ -489,32 +493,14 @@ const fiberIdStore = { id: 0 }
|
|
|
489
493
|
/** @internal */
|
|
490
494
|
export const getCurrentFiber = (): Fiber.Fiber<any, any> | undefined => (globalThis as any)[currentFiberTypeId]
|
|
491
495
|
|
|
492
|
-
const keepAlive = (() => {
|
|
493
|
-
let count = 0
|
|
494
|
-
let running: ReturnType<typeof globalThis.setInterval> | undefined = undefined
|
|
495
|
-
return ({
|
|
496
|
-
increment() {
|
|
497
|
-
count++
|
|
498
|
-
running ??= globalThis.setInterval(constVoid, 2_147_483_647)
|
|
499
|
-
},
|
|
500
|
-
decrement() {
|
|
501
|
-
count--
|
|
502
|
-
if (count === 0 && running !== undefined) {
|
|
503
|
-
globalThis.clearInterval(running)
|
|
504
|
-
running = undefined
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
})
|
|
508
|
-
})()
|
|
509
|
-
|
|
510
496
|
/** @internal */
|
|
511
497
|
export class FiberImpl<A = any, E = any> implements Fiber.Fiber<A, E> {
|
|
512
498
|
constructor(
|
|
513
|
-
|
|
499
|
+
context: Context.Context<never>,
|
|
514
500
|
interruptible: boolean = true
|
|
515
501
|
) {
|
|
516
502
|
this[FiberTypeId] = fiberVariance as any
|
|
517
|
-
this.
|
|
503
|
+
this.setContext(context)
|
|
518
504
|
this.id = ++fiberIdStore.id
|
|
519
505
|
this.currentOpCount = 0
|
|
520
506
|
this.currentLoopCount = 0
|
|
@@ -525,6 +511,7 @@ export class FiberImpl<A = any, E = any> implements Fiber.Fiber<A, E> {
|
|
|
525
511
|
this._children = undefined
|
|
526
512
|
this._interruptedCause = undefined
|
|
527
513
|
this._yielded = undefined
|
|
514
|
+
this.runtimeMetrics?.recordFiberStart(this.context)
|
|
528
515
|
}
|
|
529
516
|
|
|
530
517
|
readonly [FiberTypeId]: Fiber.Fiber.Variance<A, E>
|
|
@@ -541,8 +528,8 @@ export class FiberImpl<A = any, E = any> implements Fiber.Fiber<A, E> {
|
|
|
541
528
|
_interruptedCause: Cause.Cause<never> | undefined
|
|
542
529
|
_yielded: Exit.Exit<any, any> | (() => void) | undefined
|
|
543
530
|
|
|
544
|
-
// set in
|
|
545
|
-
|
|
531
|
+
// set in setContext
|
|
532
|
+
context!: Context.Context<never>
|
|
546
533
|
currentScheduler!: Scheduler.Scheduler
|
|
547
534
|
currentTracerContext: Tracer.Tracer["context"]
|
|
548
535
|
currentSpan: Tracer.AnySpan | undefined
|
|
@@ -551,9 +538,15 @@ export class FiberImpl<A = any, E = any> implements Fiber.Fiber<A, E> {
|
|
|
551
538
|
currentStackFrame: StackFrame | undefined
|
|
552
539
|
runtimeMetrics: Metric.FiberRuntimeMetricsService | undefined
|
|
553
540
|
maxOpsBeforeYield!: number
|
|
541
|
+
currentPreventYield!: boolean
|
|
542
|
+
|
|
543
|
+
_dispatcher: Scheduler.SchedulerDispatcher | undefined = undefined
|
|
544
|
+
get currentDispatcher(): Scheduler.SchedulerDispatcher {
|
|
545
|
+
return this._dispatcher ??= this.currentScheduler.makeDispatcher()
|
|
546
|
+
}
|
|
554
547
|
|
|
555
|
-
getRef<X>(ref:
|
|
556
|
-
return
|
|
548
|
+
getRef<X>(ref: Context.Reference<X>): X {
|
|
549
|
+
return Context.getReferenceUnsafe(this.context, ref)
|
|
557
550
|
}
|
|
558
551
|
addObserver(cb: (exit: Exit.Exit<A, E>) => void): () => void {
|
|
559
552
|
if (this._exit) {
|
|
@@ -568,13 +561,13 @@ export class FiberImpl<A = any, E = any> implements Fiber.Fiber<A, E> {
|
|
|
568
561
|
}
|
|
569
562
|
}
|
|
570
563
|
}
|
|
571
|
-
interruptUnsafe(fiberId?: number | undefined, annotations?:
|
|
564
|
+
interruptUnsafe(fiberId?: number | undefined, annotations?: Context.Context<never> | undefined): void {
|
|
572
565
|
if (this._exit) {
|
|
573
566
|
return
|
|
574
567
|
}
|
|
575
568
|
let cause = causeInterrupt(fiberId)
|
|
576
569
|
if (this.currentStackFrame) {
|
|
577
|
-
cause = causeAnnotate(cause,
|
|
570
|
+
cause = causeAnnotate(cause, Context.make(CauseStackTrace, this.currentStackFrame))
|
|
578
571
|
}
|
|
579
572
|
if (annotations) {
|
|
580
573
|
cause = causeAnnotate(cause, annotations)
|
|
@@ -590,7 +583,6 @@ export class FiberImpl<A = any, E = any> implements Fiber.Fiber<A, E> {
|
|
|
590
583
|
return this._exit
|
|
591
584
|
}
|
|
592
585
|
evaluate(effect: Primitive): void {
|
|
593
|
-
this.runtimeMetrics?.recordFiberStart(this.services)
|
|
594
586
|
if (this._exit) {
|
|
595
587
|
return
|
|
596
588
|
} else if (this._yielded !== undefined) {
|
|
@@ -611,7 +603,7 @@ export class FiberImpl<A = any, E = any> implements Fiber.Fiber<A, E> {
|
|
|
611
603
|
}
|
|
612
604
|
|
|
613
605
|
this._exit = exit
|
|
614
|
-
this.runtimeMetrics?.recordFiberEnd(this.
|
|
606
|
+
this.runtimeMetrics?.recordFiberEnd(this.context, this._exit)
|
|
615
607
|
for (let i = 0; i < this._observers.length; i++) {
|
|
616
608
|
this._observers[i](exit)
|
|
617
609
|
}
|
|
@@ -629,6 +621,7 @@ export class FiberImpl<A = any, E = any> implements Fiber.Fiber<A, E> {
|
|
|
629
621
|
this.currentOpCount++
|
|
630
622
|
if (
|
|
631
623
|
!yielding &&
|
|
624
|
+
!this.currentPreventYield &&
|
|
632
625
|
this.currentScheduler.shouldYield(this as any)
|
|
633
626
|
) {
|
|
634
627
|
yielding = true
|
|
@@ -684,16 +677,21 @@ export class FiberImpl<A = any, E = any> implements Fiber.Fiber<A, E> {
|
|
|
684
677
|
pipe() {
|
|
685
678
|
return pipeArguments(this, arguments)
|
|
686
679
|
}
|
|
687
|
-
|
|
688
|
-
this.
|
|
689
|
-
|
|
690
|
-
|
|
680
|
+
setContext(context: Context.Context<never>): void {
|
|
681
|
+
this.context = context
|
|
682
|
+
const scheduler = this.getRef(Scheduler.Scheduler)
|
|
683
|
+
if (scheduler !== this.currentScheduler) {
|
|
684
|
+
this.currentScheduler = scheduler
|
|
685
|
+
this._dispatcher = undefined
|
|
686
|
+
}
|
|
687
|
+
this.currentSpan = context.mapUnsafe.get(Tracer.ParentSpanKey)
|
|
691
688
|
this.currentLogLevel = this.getRef(CurrentLogLevel)
|
|
692
689
|
this.minimumLogLevel = this.getRef(MinimumLogLevel)
|
|
693
|
-
this.currentStackFrame =
|
|
690
|
+
this.currentStackFrame = context.mapUnsafe.get(CurrentStackFrame.key)
|
|
694
691
|
this.maxOpsBeforeYield = this.getRef(Scheduler.MaxOpsBeforeYield)
|
|
695
|
-
this.
|
|
696
|
-
|
|
692
|
+
this.currentPreventYield = this.getRef(Scheduler.PreventSchedulerYield)
|
|
693
|
+
this.runtimeMetrics = context.mapUnsafe.get(InternalMetric.FiberRuntimeMetricsKey)
|
|
694
|
+
const currentTracer = context.mapUnsafe.get(Tracer.TracerKey)
|
|
697
695
|
this.currentTracerContext = currentTracer ? currentTracer["context"] : undefined
|
|
698
696
|
}
|
|
699
697
|
get currentSpanLocal(): Tracer.Span | undefined {
|
|
@@ -711,7 +709,7 @@ const fiberStackAnnotations = (fiber: Fiber.Fiber<any, any>) => {
|
|
|
711
709
|
if (!fiber.currentStackFrame) return undefined
|
|
712
710
|
const annotations = new Map<string, unknown>()
|
|
713
711
|
annotations.set(CauseStackTrace.key, fiber.currentStackFrame)
|
|
714
|
-
return
|
|
712
|
+
return Context.makeUnsafe(annotations)
|
|
715
713
|
}
|
|
716
714
|
|
|
717
715
|
const fiberInterruptChildren = (fiber: FiberImpl) => {
|
|
@@ -785,6 +783,7 @@ export const fiberJoinAll = <A extends Iterable<Fiber.Fiber<any, any>>>(self: A)
|
|
|
785
783
|
> =>
|
|
786
784
|
callback((resume) => {
|
|
787
785
|
const fibers = Array.from(self)
|
|
786
|
+
if (fibers.length === 0) return resume(succeed(Arr.empty() as any))
|
|
788
787
|
const out = new Array<any>(fibers.length) as Arr.NonEmptyArray<any>
|
|
789
788
|
const cancels = Arr.empty<() => void>()
|
|
790
789
|
let done = 0
|
|
@@ -813,13 +812,29 @@ export const fiberInterrupt = <A, E>(
|
|
|
813
812
|
|
|
814
813
|
/** @internal */
|
|
815
814
|
export const fiberInterruptAs: {
|
|
816
|
-
(
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
815
|
+
(
|
|
816
|
+
fiberId: number | undefined,
|
|
817
|
+
annotations?: Context.Context<never> | undefined
|
|
818
|
+
): <A, E>(self: Fiber.Fiber<A, E>) => Effect.Effect<void>
|
|
819
|
+
<A, E>(
|
|
820
|
+
self: Fiber.Fiber<A, E>,
|
|
821
|
+
fiberId: number | undefined,
|
|
822
|
+
annotations?: Context.Context<never> | undefined
|
|
823
|
+
): Effect.Effect<void>
|
|
824
|
+
} = dual(
|
|
825
|
+
(args) => hasProperty(args[0], FiberTypeId),
|
|
826
|
+
<A, E>(
|
|
827
|
+
self: Fiber.Fiber<A, E>,
|
|
828
|
+
fiberId: number | undefined,
|
|
829
|
+
annotations?: Context.Context<never> | undefined
|
|
830
|
+
): Effect.Effect<void> =>
|
|
831
|
+
withFiber((parent) => {
|
|
832
|
+
let ann = fiberStackAnnotations(parent)
|
|
833
|
+
ann = ann && annotations ? Context.merge(ann, annotations) : ann ?? annotations
|
|
834
|
+
self.interruptUnsafe(fiberId, ann)
|
|
835
|
+
return asVoid(fiberAwait(self))
|
|
836
|
+
})
|
|
837
|
+
)
|
|
823
838
|
|
|
824
839
|
/** @internal */
|
|
825
840
|
export const fiberInterruptAll = <A extends Iterable<Fiber.Fiber<any, any>>>(
|
|
@@ -896,7 +911,7 @@ export const yieldNowWith: (priority?: number) => Effect.Effect<void> = makePrim
|
|
|
896
911
|
op: "Yield",
|
|
897
912
|
[evaluate](fiber) {
|
|
898
913
|
let resumed = false
|
|
899
|
-
fiber.
|
|
914
|
+
fiber.currentDispatcher.scheduleTask(() => {
|
|
900
915
|
if (resumed) return
|
|
901
916
|
fiber.evaluate(exitVoid as any)
|
|
902
917
|
}, this[args] ?? 0)
|
|
@@ -1019,10 +1034,8 @@ const callbackOptions: <A, E = never, R = never>(
|
|
|
1019
1034
|
}, controller?.signal)
|
|
1020
1035
|
if (yielded !== false) return yielded
|
|
1021
1036
|
yielded = true
|
|
1022
|
-
keepAlive.increment()
|
|
1023
1037
|
fiber._yielded = () => {
|
|
1024
1038
|
resumed = true
|
|
1025
|
-
keepAlive.decrement()
|
|
1026
1039
|
}
|
|
1027
1040
|
if (controller === undefined && onCancel === undefined) {
|
|
1028
1041
|
return Yield
|
|
@@ -1096,7 +1109,7 @@ export const fnUntraced: Effect.fn.Untraced = (
|
|
|
1096
1109
|
body: Function,
|
|
1097
1110
|
...pipeables: Array<any>
|
|
1098
1111
|
) => {
|
|
1099
|
-
|
|
1112
|
+
const fn = pipeables.length === 0
|
|
1100
1113
|
? function(this: any) {
|
|
1101
1114
|
return suspend(() => fromIteratorUnsafe(body.apply(this, arguments)))
|
|
1102
1115
|
}
|
|
@@ -1107,8 +1120,15 @@ export const fnUntraced: Effect.fn.Untraced = (
|
|
|
1107
1120
|
}
|
|
1108
1121
|
return effect
|
|
1109
1122
|
}
|
|
1123
|
+
return defineFunctionLength(body.length, fn)
|
|
1110
1124
|
}
|
|
1111
1125
|
|
|
1126
|
+
const defineFunctionLength = <F extends Function>(length: number, fn: F): F =>
|
|
1127
|
+
Object.defineProperty(fn, "length", {
|
|
1128
|
+
value: length,
|
|
1129
|
+
configurable: true
|
|
1130
|
+
})
|
|
1131
|
+
|
|
1112
1132
|
const fnStackCleaner = makeStackCleaner(2)
|
|
1113
1133
|
|
|
1114
1134
|
/** @internal */
|
|
@@ -1149,7 +1169,7 @@ const makeFn = (
|
|
|
1149
1169
|
? bodyOrOptions
|
|
1150
1170
|
: (pipeables.pop()!).bind(bodyOrOptions.self)
|
|
1151
1171
|
|
|
1152
|
-
return function(this: any, ...args: Array<any>) {
|
|
1172
|
+
return defineFunctionLength(body.length, function(this: any, ...args: Array<any>) {
|
|
1153
1173
|
let result = suspend(() => {
|
|
1154
1174
|
const iter = body.apply(this, arguments)
|
|
1155
1175
|
return isEffect(iter) ? iter : fromIteratorUnsafe(iter)
|
|
@@ -1179,7 +1199,7 @@ const makeFn = (
|
|
|
1179
1199
|
}
|
|
1180
1200
|
})
|
|
1181
1201
|
)
|
|
1182
|
-
}
|
|
1202
|
+
})
|
|
1183
1203
|
}
|
|
1184
1204
|
|
|
1185
1205
|
/** @internal */
|
|
@@ -1187,17 +1207,20 @@ export const fnUntracedEager: Effect.fn.Untraced = (
|
|
|
1187
1207
|
body: Function,
|
|
1188
1208
|
...pipeables: Array<any>
|
|
1189
1209
|
) =>
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
let effect = fromIteratorEagerUnsafe(() => body.apply(this, arguments))
|
|
1196
|
-
for (const pipeable of pipeables) {
|
|
1197
|
-
effect = pipeable(effect)
|
|
1210
|
+
defineFunctionLength(
|
|
1211
|
+
body.length,
|
|
1212
|
+
pipeables.length === 0
|
|
1213
|
+
? function(this: any) {
|
|
1214
|
+
return fromIteratorEagerUnsafe(() => body.apply(this, arguments))
|
|
1198
1215
|
}
|
|
1199
|
-
|
|
1200
|
-
|
|
1216
|
+
: function(this: any) {
|
|
1217
|
+
let effect = fromIteratorEagerUnsafe(() => body.apply(this, arguments))
|
|
1218
|
+
for (const pipeable of pipeables) {
|
|
1219
|
+
effect = pipeable(effect)
|
|
1220
|
+
}
|
|
1221
|
+
return effect
|
|
1222
|
+
}
|
|
1223
|
+
)
|
|
1201
1224
|
|
|
1202
1225
|
const fromIteratorEagerUnsafe = (
|
|
1203
1226
|
evaluate: () => Iterator<Effect.Yieldable<any, any, any, any>>
|
|
@@ -1946,61 +1969,46 @@ export const exitFindErrorOption = <A, E>(self: Exit.Exit<A, E>): Option.Option<
|
|
|
1946
1969
|
|
|
1947
1970
|
/** @internal */
|
|
1948
1971
|
export const service: {
|
|
1949
|
-
<I, S>(service:
|
|
1972
|
+
<I, S>(service: Context.Key<I, S>): Effect.Effect<S, never, I>
|
|
1950
1973
|
} = fromYieldable as any
|
|
1951
1974
|
|
|
1952
1975
|
/** @internal */
|
|
1953
1976
|
export const serviceOption = <I, S>(
|
|
1954
|
-
service:
|
|
1955
|
-
): Effect.Effect<Option.Option<S>> => withFiber((fiber) => succeed(
|
|
1977
|
+
service: Context.Key<I, S>
|
|
1978
|
+
): Effect.Effect<Option.Option<S>> => withFiber((fiber) => succeed(Context.getOption(fiber.context, service)))
|
|
1956
1979
|
|
|
1957
1980
|
/** @internal */
|
|
1958
1981
|
export const serviceOptional = <I, S>(
|
|
1959
|
-
service:
|
|
1982
|
+
service: Context.Key<I, S>
|
|
1960
1983
|
): Effect.Effect<S, Cause.NoSuchElementError> =>
|
|
1961
1984
|
withFiber((fiber) =>
|
|
1962
|
-
fiber.
|
|
1963
|
-
? succeed(
|
|
1985
|
+
fiber.context.mapUnsafe.has(service.key)
|
|
1986
|
+
? succeed(Context.getUnsafe(fiber.context, service))
|
|
1964
1987
|
: fail(new NoSuchElementError())
|
|
1965
1988
|
)
|
|
1966
1989
|
|
|
1967
1990
|
/** @internal */
|
|
1968
|
-
export const
|
|
1991
|
+
export const updateContext: {
|
|
1969
1992
|
<R2, R>(
|
|
1970
|
-
f: (
|
|
1993
|
+
f: (context: Context.Context<R2>) => Context.Context<NoInfer<R>>
|
|
1971
1994
|
): <A, E>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R2>
|
|
1972
1995
|
<A, E, R, R2>(
|
|
1973
1996
|
self: Effect.Effect<A, E, R>,
|
|
1974
|
-
f: (
|
|
1997
|
+
f: (context: Context.Context<R2>) => Context.Context<NoInfer<R>>
|
|
1975
1998
|
): Effect.Effect<A, E, R2>
|
|
1976
1999
|
} = dual(
|
|
1977
2000
|
2,
|
|
1978
2001
|
<A, E, R, R2>(
|
|
1979
2002
|
self: Effect.Effect<A, E, R>,
|
|
1980
|
-
f: (
|
|
2003
|
+
f: (context: Context.Context<R2>) => Context.Context<NoInfer<R>>
|
|
1981
2004
|
): Effect.Effect<A, E, R2> =>
|
|
1982
2005
|
withFiber<A, E, R2>((fiber) => {
|
|
1983
|
-
const
|
|
1984
|
-
const
|
|
1985
|
-
if (
|
|
1986
|
-
fiber.
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
if (!prev.mapUnsafe.has(key) || value !== prev.mapUnsafe.get(key)) {
|
|
1990
|
-
newServices.set(key, value)
|
|
1991
|
-
}
|
|
1992
|
-
}
|
|
1993
|
-
return onExitPrimitive(self as any, () => {
|
|
1994
|
-
const map = new Map(fiber.services.mapUnsafe)
|
|
1995
|
-
for (const [key, value] of newServices) {
|
|
1996
|
-
if (value !== map.get(key)) continue
|
|
1997
|
-
if (prev.mapUnsafe.has(key)) {
|
|
1998
|
-
map.set(key, prev.mapUnsafe.get(key))
|
|
1999
|
-
} else {
|
|
2000
|
-
map.delete(key)
|
|
2001
|
-
}
|
|
2002
|
-
}
|
|
2003
|
-
fiber.setServices(ServiceMap.makeUnsafe(map))
|
|
2006
|
+
const prevContext = fiber.context as Context.Context<R2>
|
|
2007
|
+
const nextContext = f(prevContext)
|
|
2008
|
+
if (prevContext === nextContext) return self as any
|
|
2009
|
+
fiber.setContext(nextContext)
|
|
2010
|
+
return onExitPrimitive(self, () => {
|
|
2011
|
+
fiber.setContext(prevContext)
|
|
2004
2012
|
return undefined
|
|
2005
2013
|
})
|
|
2006
2014
|
})
|
|
@@ -2009,78 +2017,77 @@ export const updateServices: {
|
|
|
2009
2017
|
/** @internal */
|
|
2010
2018
|
export const updateService: {
|
|
2011
2019
|
<I, A>(
|
|
2012
|
-
service:
|
|
2020
|
+
service: Context.Key<I, A>,
|
|
2013
2021
|
f: (value: A) => A
|
|
2014
2022
|
): <XA, E, R>(self: Effect.Effect<XA, E, R>) => Effect.Effect<XA, E, R | I>
|
|
2015
2023
|
<XA, E, R, I, A>(
|
|
2016
2024
|
self: Effect.Effect<XA, E, R>,
|
|
2017
|
-
service:
|
|
2025
|
+
service: Context.Key<I, A>,
|
|
2018
2026
|
f: (value: A) => A
|
|
2019
2027
|
): Effect.Effect<XA, E, R | I>
|
|
2020
2028
|
} = dual(
|
|
2021
2029
|
3,
|
|
2022
2030
|
<XA, E, R, I, A>(
|
|
2023
2031
|
self: Effect.Effect<XA, E, R>,
|
|
2024
|
-
service:
|
|
2032
|
+
service: Context.Key<I, A>,
|
|
2025
2033
|
f: (value: A) => A
|
|
2026
2034
|
): Effect.Effect<XA, E, R | I> =>
|
|
2027
|
-
|
|
2028
|
-
const prev =
|
|
2035
|
+
updateContext(self, (s) => {
|
|
2036
|
+
const prev = Context.getUnsafe(s, service)
|
|
2029
2037
|
const next = f(prev)
|
|
2030
|
-
if (prev === next) return
|
|
2031
|
-
|
|
2032
|
-
return onExit(self, () => sync(() => fiber.setServices(ServiceMap.add(fiber.services, service, prev))))
|
|
2038
|
+
if (prev === next) return s
|
|
2039
|
+
return Context.add(s, service, next)
|
|
2033
2040
|
})
|
|
2034
2041
|
)
|
|
2035
2042
|
|
|
2036
2043
|
/** @internal */
|
|
2037
|
-
export const
|
|
2038
|
-
const
|
|
2044
|
+
export const context = <R = never>(): Effect.Effect<Context.Context<R>> => getContext as any
|
|
2045
|
+
const getContext = withFiber((fiber) => succeed(fiber.context))
|
|
2039
2046
|
|
|
2040
2047
|
/** @internal */
|
|
2041
|
-
export const
|
|
2042
|
-
f: (
|
|
2043
|
-
): Effect.Effect<A, E, R | R2> => withFiber((fiber) => f(fiber.
|
|
2048
|
+
export const contextWith = <R, A, E, R2>(
|
|
2049
|
+
f: (context: Context.Context<R>) => Effect.Effect<A, E, R2>
|
|
2050
|
+
): Effect.Effect<A, E, R | R2> => withFiber((fiber) => f(fiber.context as Context.Context<R>))
|
|
2044
2051
|
|
|
2045
2052
|
/** @internal */
|
|
2046
|
-
export const
|
|
2053
|
+
export const provideContext: {
|
|
2047
2054
|
<XR>(
|
|
2048
|
-
|
|
2055
|
+
context: Context.Context<XR>
|
|
2049
2056
|
): <A, E, R>(
|
|
2050
2057
|
self: Effect.Effect<A, E, R>
|
|
2051
2058
|
) => Effect.Effect<A, E, Exclude<R, XR>>
|
|
2052
2059
|
<A, E, R, XR>(
|
|
2053
2060
|
self: Effect.Effect<A, E, R>,
|
|
2054
|
-
|
|
2061
|
+
context: Context.Context<XR>
|
|
2055
2062
|
): Effect.Effect<A, E, Exclude<R, XR>>
|
|
2056
2063
|
} = dual(
|
|
2057
2064
|
2,
|
|
2058
2065
|
<A, E, R, XR>(
|
|
2059
2066
|
self: Effect.Effect<A, E, R>,
|
|
2060
|
-
|
|
2067
|
+
context: Context.Context<XR>
|
|
2061
2068
|
): Effect.Effect<A, E, Exclude<R, XR>> => {
|
|
2062
2069
|
if (effectIsExit(self)) return self as any
|
|
2063
|
-
return
|
|
2070
|
+
return updateContext(self, Context.merge(context)) as any
|
|
2064
2071
|
}
|
|
2065
2072
|
)
|
|
2066
2073
|
|
|
2067
2074
|
/** @internal */
|
|
2068
2075
|
export const provideService: {
|
|
2069
2076
|
<I, S>(
|
|
2070
|
-
service:
|
|
2077
|
+
service: Context.Key<I, S>
|
|
2071
2078
|
): {
|
|
2072
2079
|
(implementation: S): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, I>>
|
|
2073
2080
|
<A, E, R>(self: Effect.Effect<A, E, R>, implementation: S): Effect.Effect<A, E, Exclude<R, I>>
|
|
2074
2081
|
}
|
|
2075
2082
|
<I, S>(
|
|
2076
|
-
key:
|
|
2083
|
+
key: Context.Key<I, S>,
|
|
2077
2084
|
implementation: S
|
|
2078
2085
|
): <A, E, R>(
|
|
2079
2086
|
self: Effect.Effect<A, E, R>
|
|
2080
2087
|
) => Effect.Effect<A, E, Exclude<R, I>>
|
|
2081
2088
|
<A, E, R, I, S>(
|
|
2082
2089
|
self: Effect.Effect<A, E, R>,
|
|
2083
|
-
service:
|
|
2090
|
+
service: Context.Key<I, S>,
|
|
2084
2091
|
implementation: S
|
|
2085
2092
|
): Effect.Effect<A, E, Exclude<R, I>>
|
|
2086
2093
|
} = function(this: any) {
|
|
@@ -2093,34 +2100,33 @@ export const provideService: {
|
|
|
2093
2100
|
|
|
2094
2101
|
const provideServiceImpl = <A, E, R, I, S>(
|
|
2095
2102
|
self: Effect.Effect<A, E, R>,
|
|
2096
|
-
service:
|
|
2103
|
+
service: Context.Key<I, S>,
|
|
2097
2104
|
implementation: S
|
|
2098
2105
|
): Effect.Effect<A, E, Exclude<R, I>> =>
|
|
2099
|
-
|
|
2100
|
-
const prev =
|
|
2101
|
-
if (prev
|
|
2102
|
-
|
|
2103
|
-
return onExit(self, () => sync(() => fiber.setServices(ServiceMap.addOrOmit(fiber.services, service, prev))))
|
|
2106
|
+
updateContext(self, (s) => {
|
|
2107
|
+
const prev = s.mapUnsafe.get(service.key)
|
|
2108
|
+
if (prev === implementation) return s
|
|
2109
|
+
return Context.add(s, service, implementation)
|
|
2104
2110
|
}) as any
|
|
2105
2111
|
|
|
2106
2112
|
/** @internal */
|
|
2107
2113
|
export const provideServiceEffect: {
|
|
2108
2114
|
<I, S, E2, R2>(
|
|
2109
|
-
service:
|
|
2115
|
+
service: Context.Key<I, S>,
|
|
2110
2116
|
acquire: Effect.Effect<S, E2, R2>
|
|
2111
2117
|
): <A, E, R>(
|
|
2112
2118
|
self: Effect.Effect<A, E, R>
|
|
2113
2119
|
) => Effect.Effect<A, E | E2, Exclude<R, I> | R2>
|
|
2114
2120
|
<A, E, R, I, S, E2, R2>(
|
|
2115
2121
|
self: Effect.Effect<A, E, R>,
|
|
2116
|
-
service:
|
|
2122
|
+
service: Context.Key<I, S>,
|
|
2117
2123
|
acquire: Effect.Effect<S, E2, R2>
|
|
2118
2124
|
): Effect.Effect<A, E | E2, Exclude<R, I> | R2>
|
|
2119
2125
|
} = dual(
|
|
2120
2126
|
3,
|
|
2121
2127
|
<A, E, R, I, S, E2, R2>(
|
|
2122
2128
|
self: Effect.Effect<A, E, R>,
|
|
2123
|
-
service:
|
|
2129
|
+
service: Context.Key<I, S>,
|
|
2124
2130
|
acquire: Effect.Effect<S, E2, R2>
|
|
2125
2131
|
): Effect.Effect<A, E | E2, Exclude<R, I> | R2> =>
|
|
2126
2132
|
flatMap(acquire, (implementation) => provideService(self, service, implementation))
|
|
@@ -2204,19 +2210,12 @@ export const filterOrFail: {
|
|
|
2204
2210
|
predicate: Predicate.Predicate<NoInfer<A>>,
|
|
2205
2211
|
orFailWith: (a: NoInfer<A>) => E2
|
|
2206
2212
|
): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E2 | E, R>
|
|
2207
|
-
<A, B, X, E2>(
|
|
2208
|
-
filter: Filter.Filter<NoInfer<A>, B, X>,
|
|
2209
|
-
orFailWith: (x: X) => E2
|
|
2210
|
-
): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<B, E2 | E, R>
|
|
2211
2213
|
<A, B extends A>(
|
|
2212
2214
|
refinement: Predicate.Refinement<NoInfer<A>, B>
|
|
2213
2215
|
): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<B, Cause.NoSuchElementError | E, R>
|
|
2214
2216
|
<A>(
|
|
2215
2217
|
predicate: Predicate.Predicate<NoInfer<A>>
|
|
2216
2218
|
): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, Cause.NoSuchElementError | E, R>
|
|
2217
|
-
<A, B, X>(
|
|
2218
|
-
filter: Filter.Filter<NoInfer<A>, B, X>
|
|
2219
|
-
): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<B, Cause.NoSuchElementError | E, R>
|
|
2220
2219
|
<A, E, R, E2, B extends A>(
|
|
2221
2220
|
self: Effect.Effect<A, E, R>,
|
|
2222
2221
|
refinement: Predicate.Refinement<NoInfer<A>, B>,
|
|
@@ -2227,11 +2226,6 @@ export const filterOrFail: {
|
|
|
2227
2226
|
predicate: Predicate.Predicate<NoInfer<A>>,
|
|
2228
2227
|
orFailWith: (a: NoInfer<A>) => E2
|
|
2229
2228
|
): Effect.Effect<A, E2 | E, R>
|
|
2230
|
-
<A, E, R, B, X, E2>(
|
|
2231
|
-
self: Effect.Effect<A, E, R>,
|
|
2232
|
-
filter: Filter.Filter<A, B, X>,
|
|
2233
|
-
orFailWith: (x: X) => E2
|
|
2234
|
-
): Effect.Effect<B, E2 | E, R>
|
|
2235
2229
|
<A, E, R, B extends A>(
|
|
2236
2230
|
self: Effect.Effect<A, E, R>,
|
|
2237
2231
|
refinement: Predicate.Refinement<NoInfer<A>, B>
|
|
@@ -2240,18 +2234,14 @@ export const filterOrFail: {
|
|
|
2240
2234
|
self: Effect.Effect<A, E, R>,
|
|
2241
2235
|
predicate: Predicate.Predicate<NoInfer<A>>
|
|
2242
2236
|
): Effect.Effect<A, E | Cause.NoSuchElementError, R>
|
|
2243
|
-
<A, E, R, B, X>(
|
|
2244
|
-
self: Effect.Effect<A, E, R>,
|
|
2245
|
-
filter: Filter.Filter<A, B, X>
|
|
2246
|
-
): Effect.Effect<B, E | Cause.NoSuchElementError, R>
|
|
2247
2237
|
} = dual((args) => isEffect(args[0]), <A, E, R, E2>(
|
|
2248
2238
|
self: Effect.Effect<A, E, R>,
|
|
2249
|
-
|
|
2239
|
+
predicate: Predicate.Predicate<NoInfer<A>>,
|
|
2250
2240
|
orFailWith?: (a: any) => E2
|
|
2251
2241
|
): Effect.Effect<any, E | E2 | Cause.NoSuchElementError, R> =>
|
|
2252
2242
|
filterOrElse(
|
|
2253
2243
|
self,
|
|
2254
|
-
|
|
2244
|
+
predicate as any,
|
|
2255
2245
|
orFailWith ? (a: any) => fail(orFailWith(a)) : () => fail(new NoSuchElementError() as E2)
|
|
2256
2246
|
))
|
|
2257
2247
|
|
|
@@ -2401,27 +2391,55 @@ const OnFailureProto = makePrimitiveProto({
|
|
|
2401
2391
|
|
|
2402
2392
|
/** @internal */
|
|
2403
2393
|
export const catchCauseIf: {
|
|
2404
|
-
<E,
|
|
2405
|
-
|
|
2406
|
-
f: (
|
|
2394
|
+
<E, B, E2, R2>(
|
|
2395
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
2396
|
+
f: (cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2397
|
+
): <A, R>(
|
|
2398
|
+
self: Effect.Effect<A, E, R>
|
|
2399
|
+
) => Effect.Effect<A | B, E | E2, R | R2>
|
|
2400
|
+
<A, E, R, B, E2, R2>(
|
|
2401
|
+
self: Effect.Effect<A, E, R>,
|
|
2402
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
2403
|
+
f: (cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2404
|
+
): Effect.Effect<A | B, E | E2, R | R2>
|
|
2405
|
+
} = dual(
|
|
2406
|
+
3,
|
|
2407
|
+
<A, E, R, B, E2, R2>(
|
|
2408
|
+
self: Effect.Effect<A, E, R>,
|
|
2409
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
2410
|
+
f: (cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2411
|
+
): Effect.Effect<A | B, E | E2, R | R2> =>
|
|
2412
|
+
catchCause(self, (cause): Effect.Effect<B, E | E2, R2> => {
|
|
2413
|
+
if (!predicate(cause)) {
|
|
2414
|
+
return failCause(cause) as any
|
|
2415
|
+
}
|
|
2416
|
+
return internalCall(() => f(cause))
|
|
2417
|
+
})
|
|
2418
|
+
)
|
|
2419
|
+
|
|
2420
|
+
/** @internal */
|
|
2421
|
+
export const catchCauseFilter: {
|
|
2422
|
+
<E, B, E2, R2, EB, X extends Cause.Cause<any>>(
|
|
2423
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
2424
|
+
f: (failure: EB, cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2407
2425
|
): <A, R>(
|
|
2408
2426
|
self: Effect.Effect<A, E, R>
|
|
2409
|
-
) => Effect.Effect<A | B, Cause.Cause.Error<
|
|
2410
|
-
<A, E, R, B, E2, R2,
|
|
2427
|
+
) => Effect.Effect<A | B, Cause.Cause.Error<X> | E2, R | R2>
|
|
2428
|
+
<A, E, R, B, E2, R2, EB, X extends Cause.Cause<any>>(
|
|
2411
2429
|
self: Effect.Effect<A, E, R>,
|
|
2412
|
-
filter: Filter.
|
|
2413
|
-
f: (failure:
|
|
2414
|
-
): Effect.Effect<A | B, Cause.Cause.Error<
|
|
2430
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
2431
|
+
f: (failure: EB, cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2432
|
+
): Effect.Effect<A | B, Cause.Cause.Error<X> | E2, R | R2>
|
|
2415
2433
|
} = dual(
|
|
2416
2434
|
3,
|
|
2417
|
-
<A, E, R, B, E2, R2,
|
|
2418
|
-
self: Effect.Effect<A, E, R>,
|
|
2419
|
-
filter: Filter.
|
|
2420
|
-
f: (failure:
|
|
2421
|
-
): Effect.Effect<A | B, Cause.Cause.Error<
|
|
2422
|
-
catchCause(self, (cause): Effect.Effect<B, Cause.Cause.Error<
|
|
2423
|
-
const eb =
|
|
2424
|
-
return
|
|
2435
|
+
<A, E, R, B, E2, R2, EB, X extends Cause.Cause<any>>(
|
|
2436
|
+
self: Effect.Effect<A, E, R>,
|
|
2437
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
2438
|
+
f: (failure: EB, cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2439
|
+
): Effect.Effect<A | B, Cause.Cause.Error<X> | E2, R | R2> =>
|
|
2440
|
+
catchCause(self, (cause): Effect.Effect<B, Cause.Cause.Error<X> | E2, R2> => {
|
|
2441
|
+
const eb = filter(cause)
|
|
2442
|
+
return Result.isFailure(eb) ? failCause(eb.failure) : internalCall(() => f(eb.success, cause))
|
|
2425
2443
|
})
|
|
2426
2444
|
)
|
|
2427
2445
|
|
|
@@ -2439,7 +2457,7 @@ export const catch_: {
|
|
|
2439
2457
|
<A, E, R, B, E2, R2>(
|
|
2440
2458
|
self: Effect.Effect<A, E, R>,
|
|
2441
2459
|
f: (a: NoInfer<E>) => Effect.Effect<B, E2, R2>
|
|
2442
|
-
): Effect.Effect<A | B, E2, R | R2> =>
|
|
2460
|
+
): Effect.Effect<A | B, E2, R | R2> => catchCauseFilter(self, findError as any, (e: any) => f(e)) as any
|
|
2443
2461
|
)
|
|
2444
2462
|
|
|
2445
2463
|
/** @internal */
|
|
@@ -2470,7 +2488,7 @@ export const catchDefect: {
|
|
|
2470
2488
|
<A, E, R, B, E2, R2>(
|
|
2471
2489
|
self: Effect.Effect<A, E, R>,
|
|
2472
2490
|
f: (defect: unknown) => Effect.Effect<B, E2, R2>
|
|
2473
|
-
): Effect.Effect<A | B, E | E2, R | R2> =>
|
|
2491
|
+
): Effect.Effect<A | B, E | E2, R | R2> => catchCauseFilter(self, findDefect as any, f as any) as any
|
|
2474
2492
|
)
|
|
2475
2493
|
|
|
2476
2494
|
/** @internal */
|
|
@@ -2493,32 +2511,56 @@ export const tapCause: {
|
|
|
2493
2511
|
|
|
2494
2512
|
/** @internal */
|
|
2495
2513
|
export const tapCauseIf: {
|
|
2496
|
-
<E,
|
|
2497
|
-
|
|
2498
|
-
f: (
|
|
2514
|
+
<E, B, E2, R2>(
|
|
2515
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
2516
|
+
f: (cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2499
2517
|
): <A, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E | E2, R | R2>
|
|
2500
|
-
<A, E, R,
|
|
2518
|
+
<A, E, R, B, E2, R2>(
|
|
2501
2519
|
self: Effect.Effect<A, E, R>,
|
|
2502
|
-
|
|
2503
|
-
f: (
|
|
2520
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
2521
|
+
f: (cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2504
2522
|
): Effect.Effect<A, E | E2, R | R2>
|
|
2505
2523
|
} = dual(
|
|
2506
2524
|
3,
|
|
2507
|
-
<A, E, R,
|
|
2525
|
+
<A, E, R, B, E2, R2>(
|
|
2508
2526
|
self: Effect.Effect<A, E, R>,
|
|
2509
|
-
|
|
2510
|
-
f: (
|
|
2527
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
2528
|
+
f: (cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2511
2529
|
): Effect.Effect<A, E | E2, R | R2> =>
|
|
2512
2530
|
catchCauseIf(
|
|
2513
2531
|
self,
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
return Result.isFailure(result) ? Result.fail(cause) : result
|
|
2517
|
-
}) as any,
|
|
2518
|
-
(failure: any, cause: Cause.Cause<E>) => andThen(internalCall(() => f(failure, cause)), failCause(cause))
|
|
2532
|
+
predicate,
|
|
2533
|
+
(cause) => andThen(internalCall(() => f(cause)), failCause(cause))
|
|
2519
2534
|
)
|
|
2520
2535
|
)
|
|
2521
2536
|
|
|
2537
|
+
/** @internal */
|
|
2538
|
+
export const tapCauseFilter: {
|
|
2539
|
+
<E, B, E2, R2, EB, X extends Cause.Cause<any>>(
|
|
2540
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
2541
|
+
f: (a: EB, cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2542
|
+
): <A, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E | E2, R | R2>
|
|
2543
|
+
<A, E, R, B, E2, R2, EB, X extends Cause.Cause<any>>(
|
|
2544
|
+
self: Effect.Effect<A, E, R>,
|
|
2545
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
2546
|
+
f: (a: EB, cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2547
|
+
): Effect.Effect<A, E | E2, R | R2>
|
|
2548
|
+
} = dual(
|
|
2549
|
+
3,
|
|
2550
|
+
<A, E, R, B, E2, R2, EB, X extends Cause.Cause<any>>(
|
|
2551
|
+
self: Effect.Effect<A, E, R>,
|
|
2552
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
2553
|
+
f: (a: EB, cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2554
|
+
): Effect.Effect<A, E | E2, R | R2> =>
|
|
2555
|
+
catchCause(self, (cause) => {
|
|
2556
|
+
const result = filter(cause)
|
|
2557
|
+
if (Result.isFailure(result)) {
|
|
2558
|
+
return failCause(cause)
|
|
2559
|
+
}
|
|
2560
|
+
return andThen(internalCall(() => f(result.success, cause)), failCause(cause))
|
|
2561
|
+
})
|
|
2562
|
+
)
|
|
2563
|
+
|
|
2522
2564
|
/** @internal */
|
|
2523
2565
|
export const tapError: {
|
|
2524
2566
|
<E, B, E2, R2>(
|
|
@@ -2533,7 +2575,7 @@ export const tapError: {
|
|
|
2533
2575
|
<A, E, R, B, E2, R2>(
|
|
2534
2576
|
self: Effect.Effect<A, E, R>,
|
|
2535
2577
|
f: (e: NoInfer<E>) => Effect.Effect<B, E2, R2>
|
|
2536
|
-
): Effect.Effect<A, E | E2, R | R2> =>
|
|
2578
|
+
): Effect.Effect<A, E | E2, R | R2> => tapCauseFilter(self, findError as any, (e: any) => f(e)) as any
|
|
2537
2579
|
)
|
|
2538
2580
|
|
|
2539
2581
|
/** @internal */
|
|
@@ -2600,7 +2642,7 @@ export const tapDefect: {
|
|
|
2600
2642
|
<A, E, R, B, E2, R2>(
|
|
2601
2643
|
self: Effect.Effect<A, E, R>,
|
|
2602
2644
|
f: (defect: unknown) => Effect.Effect<B, E2, R2>
|
|
2603
|
-
): Effect.Effect<A, E | E2, R | R2> =>
|
|
2645
|
+
): Effect.Effect<A, E | E2, R | R2> => tapCauseFilter(self, findDefect as any, (_: any) => f(_)) as any
|
|
2604
2646
|
)
|
|
2605
2647
|
|
|
2606
2648
|
/** @internal */
|
|
@@ -2610,10 +2652,10 @@ export const catchIf: {
|
|
|
2610
2652
|
f: (e: EB) => Effect.Effect<A2, E2, R2>,
|
|
2611
2653
|
orElse?: ((e: Exclude<E, EB>) => Effect.Effect<A3, E3, R3>) | undefined
|
|
2612
2654
|
): <A, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
2613
|
-
<E,
|
|
2614
|
-
|
|
2615
|
-
f: (e:
|
|
2616
|
-
orElse?: ((e:
|
|
2655
|
+
<E, A2, E2, R2, A3 = never, E3 = E, R3 = never>(
|
|
2656
|
+
predicate: Predicate.Predicate<NoInfer<E>>,
|
|
2657
|
+
f: (e: NoInfer<E>) => Effect.Effect<A2, E2, R2>,
|
|
2658
|
+
orElse?: ((e: NoInfer<E>) => Effect.Effect<A3, E3, R3>) | undefined
|
|
2617
2659
|
): <A, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
2618
2660
|
<A, E, R, EB extends E, A2, E2, R2, A3 = never, E3 = Exclude<E, EB>, R3 = never>(
|
|
2619
2661
|
self: Effect.Effect<A, E, R>,
|
|
@@ -2621,28 +2663,59 @@ export const catchIf: {
|
|
|
2621
2663
|
f: (e: EB) => Effect.Effect<A2, E2, R2>,
|
|
2622
2664
|
orElse?: ((e: Exclude<E, EB>) => Effect.Effect<A3, E3, R3>) | undefined
|
|
2623
2665
|
): Effect.Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
2624
|
-
<A, E, R,
|
|
2666
|
+
<A, E, R, A2, E2, R2, A3 = never, E3 = E, R3 = never>(
|
|
2667
|
+
self: Effect.Effect<A, E, R>,
|
|
2668
|
+
predicate: Predicate.Predicate<E>,
|
|
2669
|
+
f: (e: E) => Effect.Effect<A2, E2, R2>,
|
|
2670
|
+
orElse?: ((e: E) => Effect.Effect<A3, E3, R3>) | undefined
|
|
2671
|
+
): Effect.Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
2672
|
+
} = dual(
|
|
2673
|
+
(args) => isEffect(args[0]),
|
|
2674
|
+
<A, E, R, A2, E2, R2, A3 = never, E3 = E, R3 = never>(
|
|
2675
|
+
self: Effect.Effect<A, E, R>,
|
|
2676
|
+
predicate: Predicate.Predicate<E>,
|
|
2677
|
+
f: (e: E) => Effect.Effect<A2, E2, R2>,
|
|
2678
|
+
orElse?: ((e: E) => Effect.Effect<A3, E3, R3>) | undefined
|
|
2679
|
+
): Effect.Effect<A | A2 | A3, E2 | E3, R | R2 | R3> =>
|
|
2680
|
+
catchCause(self, (cause): Effect.Effect<A2 | A3, E2 | E3, R2 | R3> => {
|
|
2681
|
+
const error = findError(cause)
|
|
2682
|
+
if (Result.isFailure(error)) return failCause(error.failure)
|
|
2683
|
+
if (!predicate(error.success)) {
|
|
2684
|
+
return orElse ? internalCall(() => orElse(error.success as any)) : failCause(cause as any as Cause.Cause<E3>)
|
|
2685
|
+
}
|
|
2686
|
+
return internalCall(() => f(error.success as any))
|
|
2687
|
+
})
|
|
2688
|
+
)
|
|
2689
|
+
|
|
2690
|
+
/** @internal */
|
|
2691
|
+
export const catchFilter: {
|
|
2692
|
+
<E, EB, A2, E2, R2, X, A3 = never, E3 = X, R3 = never>(
|
|
2693
|
+
filter: Filter.Filter<NoInfer<E>, EB, X>,
|
|
2694
|
+
f: (e: EB) => Effect.Effect<A2, E2, R2>,
|
|
2695
|
+
orElse?: ((e: X) => Effect.Effect<A3, E3, R3>) | undefined
|
|
2696
|
+
): <A, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
2697
|
+
<A, E, R, EB, A2, E2, R2, X, A3 = never, E3 = X, R3 = never>(
|
|
2625
2698
|
self: Effect.Effect<A, E, R>,
|
|
2626
|
-
filter: Filter.
|
|
2627
|
-
f: (e:
|
|
2628
|
-
orElse?: ((e:
|
|
2699
|
+
filter: Filter.Filter<NoInfer<E>, EB, X>,
|
|
2700
|
+
f: (e: EB) => Effect.Effect<A2, E2, R2>,
|
|
2701
|
+
orElse?: ((e: X) => Effect.Effect<A3, E3, R3>) | undefined
|
|
2629
2702
|
): Effect.Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
2630
2703
|
} = dual(
|
|
2631
2704
|
(args) => isEffect(args[0]),
|
|
2632
2705
|
<A, E, R, EB, A2, E2, R2, X, A3 = never, E3 = X, R3 = never>(
|
|
2633
2706
|
self: Effect.Effect<A, E, R>,
|
|
2634
|
-
filter: Filter.Filter<NoInfer<E>, EB, X
|
|
2707
|
+
filter: Filter.Filter<NoInfer<E>, EB, X>,
|
|
2635
2708
|
f: (e: EB) => Effect.Effect<A2, E2, R2>,
|
|
2636
2709
|
orElse?: ((e: X) => Effect.Effect<A3, E3, R3>) | undefined
|
|
2637
2710
|
): Effect.Effect<A | A2 | A3, E2 | E3, R | R2 | R3> =>
|
|
2638
2711
|
catchCause(self, (cause): Effect.Effect<A2 | A3, E2 | E3, R2 | R3> => {
|
|
2639
2712
|
const error = findError(cause)
|
|
2640
2713
|
if (Result.isFailure(error)) return failCause(error.failure)
|
|
2641
|
-
const result =
|
|
2714
|
+
const result = filter(error.success)
|
|
2642
2715
|
if (Result.isFailure(result)) {
|
|
2643
2716
|
return orElse ? internalCall(() => orElse(result.failure as any)) : failCause(cause as any as Cause.Cause<E3>)
|
|
2644
2717
|
}
|
|
2645
|
-
return internalCall(() => f(result.success
|
|
2718
|
+
return internalCall(() => f(result.success))
|
|
2646
2719
|
})
|
|
2647
2720
|
)
|
|
2648
2721
|
|
|
@@ -2778,7 +2851,7 @@ export const catchTags: {
|
|
|
2778
2851
|
>
|
|
2779
2852
|
} = dual((args) => isEffect(args[0]), (self: Effect.Effect<any, any, any>, cases: Record<string, any>, orElse: any) => {
|
|
2780
2853
|
let keys: Array<string>
|
|
2781
|
-
return
|
|
2854
|
+
return catchFilter(
|
|
2782
2855
|
self,
|
|
2783
2856
|
(e) => {
|
|
2784
2857
|
keys ??= Object.keys(cases)
|
|
@@ -2788,7 +2861,7 @@ export const catchTags: {
|
|
|
2788
2861
|
},
|
|
2789
2862
|
(e: any) => internalCall(() => cases[e["_tag"] as string](e)),
|
|
2790
2863
|
orElse
|
|
2791
|
-
)
|
|
2864
|
+
) as any
|
|
2792
2865
|
})
|
|
2793
2866
|
|
|
2794
2867
|
/** @internal */
|
|
@@ -2806,8 +2879,16 @@ export const catchReason: {
|
|
|
2806
2879
|
>(
|
|
2807
2880
|
errorTag: K,
|
|
2808
2881
|
reasonTag: RK,
|
|
2809
|
-
f: (
|
|
2810
|
-
|
|
2882
|
+
f: (
|
|
2883
|
+
reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK>,
|
|
2884
|
+
error: NarrowReason<ExtractTag<NoInfer<E>, K>, RK>
|
|
2885
|
+
) => Effect.Effect<A2, E2, R2>,
|
|
2886
|
+
orElse?:
|
|
2887
|
+
| ((
|
|
2888
|
+
reasons: ExcludeReason<ExtractTag<NoInfer<E>, K>, RK>,
|
|
2889
|
+
error: OmitReason<ExtractTag<NoInfer<E>, K>, RK>
|
|
2890
|
+
) => Effect.Effect<A3, E3, R3>)
|
|
2891
|
+
| undefined
|
|
2811
2892
|
): <A, R>(
|
|
2812
2893
|
self: Effect.Effect<A, E, R>
|
|
2813
2894
|
) => Effect.Effect<
|
|
@@ -2831,8 +2912,16 @@ export const catchReason: {
|
|
|
2831
2912
|
self: Effect.Effect<A, E, R>,
|
|
2832
2913
|
errorTag: K,
|
|
2833
2914
|
reasonTag: RK,
|
|
2834
|
-
f: (
|
|
2835
|
-
|
|
2915
|
+
f: (
|
|
2916
|
+
reason: ExtractReason<ExtractTag<E, K>, RK>,
|
|
2917
|
+
error: NarrowReason<ExtractTag<E, K>, RK>
|
|
2918
|
+
) => Effect.Effect<A2, E2, R2>,
|
|
2919
|
+
orElse?:
|
|
2920
|
+
| ((
|
|
2921
|
+
reasons: ExcludeReason<ExtractTag<E, K>, RK>,
|
|
2922
|
+
error: OmitReason<ExtractTag<E, K>, RK>
|
|
2923
|
+
) => Effect.Effect<A3, E3, R3>)
|
|
2924
|
+
| undefined
|
|
2836
2925
|
): Effect.Effect<
|
|
2837
2926
|
A | A2 | Exclude<A3, unassigned>,
|
|
2838
2927
|
(A3 extends unassigned ? E : ExcludeTag<E, K>) | E2 | E3,
|
|
@@ -2856,8 +2945,13 @@ export const catchReason: {
|
|
|
2856
2945
|
self: Effect.Effect<A, E, R>,
|
|
2857
2946
|
errorTag: K,
|
|
2858
2947
|
reasonTag: RK,
|
|
2859
|
-
f: (reason: ExtractReason<ExtractTag<E, K>, RK>) => Effect.Effect<A2, E2, R2>,
|
|
2860
|
-
orElse?:
|
|
2948
|
+
f: (reason: ExtractReason<ExtractTag<E, K>, RK>, error: ExtractTag<E, K>) => Effect.Effect<A2, E2, R2>,
|
|
2949
|
+
orElse?:
|
|
2950
|
+
| ((
|
|
2951
|
+
reasons: ExcludeReason<ExtractTag<E, K>, RK>,
|
|
2952
|
+
error: OmitReason<ExtractTag<E, K>, RK>
|
|
2953
|
+
) => Effect.Effect<A3, E3, R3>)
|
|
2954
|
+
| undefined
|
|
2861
2955
|
): Effect.Effect<
|
|
2862
2956
|
A | A2 | Exclude<A3, unassigned>,
|
|
2863
2957
|
(A3 extends unassigned ? E : ExcludeTag<E, K>) | E2 | E3,
|
|
@@ -2868,8 +2962,8 @@ export const catchReason: {
|
|
|
2868
2962
|
((e: any) => isTagged(e, errorTag) && hasProperty(e, "reason")) as any,
|
|
2869
2963
|
(e: any): Effect.Effect<A2 | A3, E | E2 | E3, R2 | R3> => {
|
|
2870
2964
|
const reason = e.reason as any
|
|
2871
|
-
if (isTagged(reason, reasonTag)) return f(reason as any)
|
|
2872
|
-
return orElse ? internalCall(() => orElse(reason)) : fail(e)
|
|
2965
|
+
if (isTagged(reason, reasonTag)) return f(reason as any, e)
|
|
2966
|
+
return orElse ? internalCall(() => orElse(reason, e)) : fail(e)
|
|
2873
2967
|
}
|
|
2874
2968
|
) as any
|
|
2875
2969
|
)
|
|
@@ -2881,7 +2975,8 @@ export const catchReasons: {
|
|
|
2881
2975
|
E,
|
|
2882
2976
|
Cases extends {
|
|
2883
2977
|
[RK in ReasonTags<ExtractTag<NoInfer<E>, K>>]+?: (
|
|
2884
|
-
reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK
|
|
2978
|
+
reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK>,
|
|
2979
|
+
error: NarrowReason<ExtractTag<NoInfer<E>, K>, RK>
|
|
2885
2980
|
) => Effect.Effect<any, any, any>
|
|
2886
2981
|
},
|
|
2887
2982
|
A2 = unassigned,
|
|
@@ -2892,7 +2987,8 @@ export const catchReasons: {
|
|
|
2892
2987
|
cases: Cases,
|
|
2893
2988
|
orElse?:
|
|
2894
2989
|
| ((
|
|
2895
|
-
reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string
|
|
2990
|
+
reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>,
|
|
2991
|
+
error: OmitReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>
|
|
2896
2992
|
) => Effect.Effect<A2, E2, R2>)
|
|
2897
2993
|
| undefined
|
|
2898
2994
|
): <A, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<
|
|
@@ -2919,7 +3015,8 @@ export const catchReasons: {
|
|
|
2919
3015
|
K extends Tags<E>,
|
|
2920
3016
|
Cases extends {
|
|
2921
3017
|
[RK in ReasonTags<ExtractTag<E, K>>]+?: (
|
|
2922
|
-
reason: ExtractReason<ExtractTag<E, K>, RK
|
|
3018
|
+
reason: ExtractReason<ExtractTag<E, K>, RK>,
|
|
3019
|
+
error: NarrowReason<ExtractTag<E, K>, RK>
|
|
2923
3020
|
) => Effect.Effect<any, any, any>
|
|
2924
3021
|
},
|
|
2925
3022
|
A2 = unassigned,
|
|
@@ -2931,7 +3028,8 @@ export const catchReasons: {
|
|
|
2931
3028
|
cases: Cases,
|
|
2932
3029
|
orElse?:
|
|
2933
3030
|
| ((
|
|
2934
|
-
reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string
|
|
3031
|
+
reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>,
|
|
3032
|
+
error: OmitReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>
|
|
2935
3033
|
) => Effect.Effect<A2, E2, R2>)
|
|
2936
3034
|
| undefined
|
|
2937
3035
|
): Effect.Effect<
|
|
@@ -2964,9 +3062,9 @@ export const catchReasons: {
|
|
|
2964
3062
|
const reason = e.reason
|
|
2965
3063
|
keys ??= Object.keys(cases)
|
|
2966
3064
|
if (keys.includes(reason._tag)) {
|
|
2967
|
-
return internalCall(() => (cases as any)[reason._tag](reason))
|
|
3065
|
+
return internalCall(() => (cases as any)[reason._tag](reason, e))
|
|
2968
3066
|
}
|
|
2969
|
-
return orElse ? internalCall(() => orElse(reason)) : fail(e)
|
|
3067
|
+
return orElse ? internalCall(() => orElse(reason, e)) : fail(e)
|
|
2970
3068
|
}
|
|
2971
3069
|
)
|
|
2972
3070
|
})
|
|
@@ -2999,7 +3097,7 @@ export const unwrapReason: {
|
|
|
2999
3097
|
self: Effect.Effect<A, E, R>,
|
|
3000
3098
|
errorTag: K
|
|
3001
3099
|
): Effect.Effect<A, ExcludeTag<E, K> | ReasonOf<ExtractTag<E, K>>, R> =>
|
|
3002
|
-
|
|
3100
|
+
catchFilter(
|
|
3003
3101
|
self,
|
|
3004
3102
|
(e: any) => {
|
|
3005
3103
|
if (isTagged(e, errorTag) && hasProperty(e, "reason")) {
|
|
@@ -3008,7 +3106,7 @@ export const unwrapReason: {
|
|
|
3008
3106
|
return Result.fail(e)
|
|
3009
3107
|
},
|
|
3010
3108
|
fail as any
|
|
3011
|
-
)
|
|
3109
|
+
) as any
|
|
3012
3110
|
)
|
|
3013
3111
|
|
|
3014
3112
|
/** @internal */
|
|
@@ -3085,6 +3183,24 @@ export const orElseSucceed: {
|
|
|
3085
3183
|
): Effect.Effect<A | B, never, R> => catch_(self, (_) => sync(f))
|
|
3086
3184
|
)
|
|
3087
3185
|
|
|
3186
|
+
/** @internal */
|
|
3187
|
+
export const firstSuccessOf = <Eff extends Effect.Effect<any, any, any>>(
|
|
3188
|
+
effects: Iterable<Eff>
|
|
3189
|
+
): Effect.Effect<Effect.Success<Eff>, Effect.Error<Eff>, Effect.Services<Eff>> =>
|
|
3190
|
+
suspend(() => {
|
|
3191
|
+
const iterator = effects[Symbol.iterator]()
|
|
3192
|
+
let state = iterator.next()
|
|
3193
|
+
if (state.done) {
|
|
3194
|
+
return die(new Error("Received an empty collection of effects"))
|
|
3195
|
+
}
|
|
3196
|
+
function loop(current: IteratorYieldResult<Eff>): Eff {
|
|
3197
|
+
const next = iterator.next()
|
|
3198
|
+
if (next.done) return current.value
|
|
3199
|
+
return catch_(current.value, (_) => loop(next)) as any
|
|
3200
|
+
}
|
|
3201
|
+
return loop(state)
|
|
3202
|
+
})
|
|
3203
|
+
|
|
3088
3204
|
/** @internal */
|
|
3089
3205
|
export const eventually = <A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect<A, never, R> =>
|
|
3090
3206
|
catch_(self, (_) => flatMap(yieldNow, () => eventually(self)))
|
|
@@ -3092,14 +3208,17 @@ export const eventually = <A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect
|
|
|
3092
3208
|
/** @internal */
|
|
3093
3209
|
export const ignore: <
|
|
3094
3210
|
Arg extends Effect.Effect<any, any, any> | {
|
|
3095
|
-
readonly log?: boolean | LogLevel.
|
|
3211
|
+
readonly log?: boolean | LogLevel.Severity | undefined
|
|
3212
|
+
readonly message?: string | undefined
|
|
3096
3213
|
} | undefined = {
|
|
3097
|
-
readonly log?: boolean | LogLevel.
|
|
3214
|
+
readonly log?: boolean | LogLevel.Severity | undefined
|
|
3215
|
+
readonly message?: string | undefined
|
|
3098
3216
|
}
|
|
3099
3217
|
>(
|
|
3100
3218
|
effectOrOptions: Arg,
|
|
3101
3219
|
options?: {
|
|
3102
|
-
readonly log?: boolean | LogLevel.
|
|
3220
|
+
readonly log?: boolean | LogLevel.Severity | undefined
|
|
3221
|
+
readonly message?: string | undefined
|
|
3103
3222
|
} | undefined
|
|
3104
3223
|
) => [Arg] extends [Effect.Effect<infer _A, infer _E, infer _R>] ? Effect.Effect<void, never, _R>
|
|
3105
3224
|
: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<void, never, R> = dual(
|
|
@@ -3107,7 +3226,8 @@ export const ignore: <
|
|
|
3107
3226
|
<A, E, R>(
|
|
3108
3227
|
self: Effect.Effect<A, E, R>,
|
|
3109
3228
|
options?: {
|
|
3110
|
-
readonly log?: boolean | LogLevel.
|
|
3229
|
+
readonly log?: boolean | LogLevel.Severity | undefined
|
|
3230
|
+
readonly message?: string | undefined
|
|
3111
3231
|
} | undefined
|
|
3112
3232
|
): Effect.Effect<void, never, R> => {
|
|
3113
3233
|
if (!options?.log) {
|
|
@@ -3117,7 +3237,11 @@ export const ignore: <
|
|
|
3117
3237
|
return matchCauseEffect(self, {
|
|
3118
3238
|
onFailure(cause) {
|
|
3119
3239
|
const failure = findFail(cause)
|
|
3120
|
-
return Result.isFailure(failure)
|
|
3240
|
+
return Result.isFailure(failure)
|
|
3241
|
+
? failCause(failure.failure)
|
|
3242
|
+
: options.message === undefined
|
|
3243
|
+
? logEffect(cause)
|
|
3244
|
+
: logEffect(options.message, cause)
|
|
3121
3245
|
},
|
|
3122
3246
|
onSuccess: (_) => void_
|
|
3123
3247
|
})
|
|
@@ -3127,14 +3251,17 @@ export const ignore: <
|
|
|
3127
3251
|
/** @internal */
|
|
3128
3252
|
export const ignoreCause: <
|
|
3129
3253
|
Arg extends Effect.Effect<any, any, any> | {
|
|
3130
|
-
readonly log?: boolean | LogLevel.
|
|
3254
|
+
readonly log?: boolean | LogLevel.Severity | undefined
|
|
3255
|
+
readonly message?: string | undefined
|
|
3131
3256
|
} | undefined = {
|
|
3132
|
-
readonly log?: boolean | LogLevel.
|
|
3257
|
+
readonly log?: boolean | LogLevel.Severity | undefined
|
|
3258
|
+
readonly message?: string | undefined
|
|
3133
3259
|
}
|
|
3134
3260
|
>(
|
|
3135
3261
|
effectOrOptions: Arg,
|
|
3136
3262
|
options?: {
|
|
3137
|
-
readonly log?: boolean | LogLevel.
|
|
3263
|
+
readonly log?: boolean | LogLevel.Severity | undefined
|
|
3264
|
+
readonly message?: string | undefined
|
|
3138
3265
|
} | undefined
|
|
3139
3266
|
) => [Arg] extends [Effect.Effect<infer _A, infer _E, infer _R>] ? Effect.Effect<void, never, _R>
|
|
3140
3267
|
: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<void, never, R> = dual(
|
|
@@ -3142,14 +3269,18 @@ export const ignoreCause: <
|
|
|
3142
3269
|
<A, E, R>(
|
|
3143
3270
|
self: Effect.Effect<A, E, R>,
|
|
3144
3271
|
options?: {
|
|
3145
|
-
readonly log?: boolean | LogLevel.
|
|
3272
|
+
readonly log?: boolean | LogLevel.Severity | undefined
|
|
3273
|
+
readonly message?: string | undefined
|
|
3146
3274
|
} | undefined
|
|
3147
3275
|
): Effect.Effect<void, never, R> => {
|
|
3148
3276
|
if (!options?.log) {
|
|
3149
3277
|
return matchCauseEffect(self, { onFailure: (_) => void_, onSuccess: (_) => void_ })
|
|
3150
3278
|
}
|
|
3151
3279
|
const logEffect = logWithLevel(options.log === true ? undefined : options.log)
|
|
3152
|
-
return matchCauseEffect(self, {
|
|
3280
|
+
return matchCauseEffect(self, {
|
|
3281
|
+
onFailure: (cause) => options.message === undefined ? logEffect(cause) : logEffect(options.message, cause),
|
|
3282
|
+
onSuccess: (_) => void_
|
|
3283
|
+
})
|
|
3153
3284
|
}
|
|
3154
3285
|
)
|
|
3155
3286
|
|
|
@@ -3404,33 +3535,33 @@ export const isSuccess: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect
|
|
|
3404
3535
|
/** @internal */
|
|
3405
3536
|
export const delay: {
|
|
3406
3537
|
(
|
|
3407
|
-
duration: Duration.
|
|
3538
|
+
duration: Duration.Input
|
|
3408
3539
|
): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
|
|
3409
3540
|
<A, E, R>(
|
|
3410
3541
|
self: Effect.Effect<A, E, R>,
|
|
3411
|
-
duration: Duration.
|
|
3542
|
+
duration: Duration.Input
|
|
3412
3543
|
): Effect.Effect<A, E, R>
|
|
3413
3544
|
} = dual(
|
|
3414
3545
|
2,
|
|
3415
3546
|
<A, E, R>(
|
|
3416
3547
|
self: Effect.Effect<A, E, R>,
|
|
3417
|
-
duration: Duration.
|
|
3548
|
+
duration: Duration.Input
|
|
3418
3549
|
): Effect.Effect<A, E, R> => andThen(sleep(duration), self)
|
|
3419
3550
|
)
|
|
3420
3551
|
|
|
3421
3552
|
/** @internal */
|
|
3422
3553
|
export const timeoutOrElse: {
|
|
3423
3554
|
<A2, E2, R2>(options: {
|
|
3424
|
-
readonly duration: Duration.
|
|
3425
|
-
readonly
|
|
3555
|
+
readonly duration: Duration.Input
|
|
3556
|
+
readonly orElse: LazyArg<Effect.Effect<A2, E2, R2>>
|
|
3426
3557
|
}): <A, E, R>(
|
|
3427
3558
|
self: Effect.Effect<A, E, R>
|
|
3428
3559
|
) => Effect.Effect<A | A2, E | E2, R | R2>
|
|
3429
3560
|
<A, E, R, A2, E2, R2>(
|
|
3430
3561
|
self: Effect.Effect<A, E, R>,
|
|
3431
3562
|
options: {
|
|
3432
|
-
readonly duration: Duration.
|
|
3433
|
-
readonly
|
|
3563
|
+
readonly duration: Duration.Input
|
|
3564
|
+
readonly orElse: LazyArg<Effect.Effect<A2, E2, R2>>
|
|
3434
3565
|
}
|
|
3435
3566
|
): Effect.Effect<A | A2, E | E2, R | R2>
|
|
3436
3567
|
} = dual(
|
|
@@ -3438,55 +3569,55 @@ export const timeoutOrElse: {
|
|
|
3438
3569
|
<A, E, R, A2, E2, R2>(
|
|
3439
3570
|
self: Effect.Effect<A, E, R>,
|
|
3440
3571
|
options: {
|
|
3441
|
-
readonly duration: Duration.
|
|
3442
|
-
readonly
|
|
3572
|
+
readonly duration: Duration.Input
|
|
3573
|
+
readonly orElse: LazyArg<Effect.Effect<A2, E2, R2>>
|
|
3443
3574
|
}
|
|
3444
3575
|
): Effect.Effect<A | A2, E | E2, R | R2> =>
|
|
3445
3576
|
raceFirst(
|
|
3446
3577
|
self,
|
|
3447
|
-
flatMap(sleep(options.duration), options.
|
|
3578
|
+
flatMap(sleep(options.duration), options.orElse)
|
|
3448
3579
|
)
|
|
3449
3580
|
)
|
|
3450
3581
|
|
|
3451
3582
|
/** @internal */
|
|
3452
3583
|
export const timeout: {
|
|
3453
3584
|
(
|
|
3454
|
-
duration: Duration.
|
|
3585
|
+
duration: Duration.Input
|
|
3455
3586
|
): <A, E, R>(
|
|
3456
3587
|
self: Effect.Effect<A, E, R>
|
|
3457
3588
|
) => Effect.Effect<A, E | Cause.TimeoutError, R>
|
|
3458
3589
|
<A, E, R>(
|
|
3459
3590
|
self: Effect.Effect<A, E, R>,
|
|
3460
|
-
duration: Duration.
|
|
3591
|
+
duration: Duration.Input
|
|
3461
3592
|
): Effect.Effect<A, E | Cause.TimeoutError, R>
|
|
3462
3593
|
} = dual(
|
|
3463
3594
|
2,
|
|
3464
3595
|
<A, E, R>(
|
|
3465
3596
|
self: Effect.Effect<A, E, R>,
|
|
3466
|
-
duration: Duration.
|
|
3597
|
+
duration: Duration.Input
|
|
3467
3598
|
): Effect.Effect<A, E | TimeoutError, R> =>
|
|
3468
3599
|
timeoutOrElse(self, {
|
|
3469
3600
|
duration,
|
|
3470
|
-
|
|
3601
|
+
orElse: () => fail(new TimeoutError())
|
|
3471
3602
|
})
|
|
3472
3603
|
)
|
|
3473
3604
|
|
|
3474
3605
|
/** @internal */
|
|
3475
3606
|
export const timeoutOption: {
|
|
3476
3607
|
(
|
|
3477
|
-
duration: Duration.
|
|
3608
|
+
duration: Duration.Input
|
|
3478
3609
|
): <A, E, R>(
|
|
3479
3610
|
self: Effect.Effect<A, E, R>
|
|
3480
3611
|
) => Effect.Effect<Option.Option<A>, E, R>
|
|
3481
3612
|
<A, E, R>(
|
|
3482
3613
|
self: Effect.Effect<A, E, R>,
|
|
3483
|
-
duration: Duration.
|
|
3614
|
+
duration: Duration.Input
|
|
3484
3615
|
): Effect.Effect<Option.Option<A>, E, R>
|
|
3485
3616
|
} = dual(
|
|
3486
3617
|
2,
|
|
3487
3618
|
<A, E, R>(
|
|
3488
3619
|
self: Effect.Effect<A, E, R>,
|
|
3489
|
-
duration: Duration.
|
|
3620
|
+
duration: Duration.Input
|
|
3490
3621
|
): Effect.Effect<Option.Option<A>, E, R> =>
|
|
3491
3622
|
raceFirst(
|
|
3492
3623
|
asSome(self),
|
|
@@ -3514,7 +3645,7 @@ export const ScopeTypeId = "~effect/Scope"
|
|
|
3514
3645
|
export const ScopeCloseableTypeId = "~effect/Scope/Closeable"
|
|
3515
3646
|
|
|
3516
3647
|
/** @internal */
|
|
3517
|
-
export const scopeTag:
|
|
3648
|
+
export const scopeTag: Context.Service<Scope.Scope, Scope.Scope> = Context.Service<Scope.Scope>("effect/Scope")
|
|
3518
3649
|
|
|
3519
3650
|
/** @internal */
|
|
3520
3651
|
export const scopeClose = <A, E>(self: Scope.Scope, exit_: Exit.Exit<A, E>) =>
|
|
@@ -3647,11 +3778,11 @@ export const provideScope: {
|
|
|
3647
3778
|
/** @internal */
|
|
3648
3779
|
export const scoped = <A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect<A, E, Exclude<R, Scope.Scope>> =>
|
|
3649
3780
|
withFiber((fiber) => {
|
|
3650
|
-
const prev =
|
|
3781
|
+
const prev = fiber.context
|
|
3651
3782
|
const scope = scopeMakeUnsafe()
|
|
3652
|
-
fiber.
|
|
3783
|
+
fiber.setContext(Context.add(fiber.context, scopeTag, scope))
|
|
3653
3784
|
return onExitPrimitive(self, (exit) => {
|
|
3654
|
-
fiber.
|
|
3785
|
+
fiber.setContext(prev)
|
|
3655
3786
|
return scopeCloseUnsafe(scope, exit)
|
|
3656
3787
|
})
|
|
3657
3788
|
}) as any
|
|
@@ -3678,13 +3809,22 @@ export const scopedWith = <A, E, R>(
|
|
|
3678
3809
|
})
|
|
3679
3810
|
|
|
3680
3811
|
/** @internal */
|
|
3681
|
-
export const acquireRelease = <A, E, R>(
|
|
3812
|
+
export const acquireRelease = <A, E, R, R2>(
|
|
3682
3813
|
acquire: Effect.Effect<A, E, R>,
|
|
3683
|
-
release: (a: A, exit: Exit.Exit<unknown, unknown>) => Effect.Effect<unknown
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3814
|
+
release: (a: A, exit: Exit.Exit<unknown, unknown>) => Effect.Effect<unknown, never, R2>,
|
|
3815
|
+
options?: { readonly interruptible?: boolean }
|
|
3816
|
+
): Effect.Effect<A, E, R | R2 | Scope.Scope> =>
|
|
3817
|
+
contextWith((context: Context.Context<R2>) =>
|
|
3818
|
+
uninterruptibleMask((restore) =>
|
|
3819
|
+
flatMap(
|
|
3820
|
+
scope,
|
|
3821
|
+
(scope) =>
|
|
3822
|
+
tap(
|
|
3823
|
+
options?.interruptible ? restore(acquire) : acquire,
|
|
3824
|
+
(a) => scopeAddFinalizerExit(scope, (exit) => provideContext(release(a, exit), context))
|
|
3825
|
+
)
|
|
3826
|
+
)
|
|
3827
|
+
)
|
|
3688
3828
|
)
|
|
3689
3829
|
|
|
3690
3830
|
/** @internal */
|
|
@@ -3694,8 +3834,8 @@ export const addFinalizer = <R>(
|
|
|
3694
3834
|
flatMap(
|
|
3695
3835
|
scope,
|
|
3696
3836
|
(scope) =>
|
|
3697
|
-
|
|
3698
|
-
scopeAddFinalizerExit(scope, (exit) =>
|
|
3837
|
+
contextWith((context: Context.Context<R>) =>
|
|
3838
|
+
scopeAddFinalizerExit(scope, (exit) => provideContext(finalizer(exit), context))
|
|
3699
3839
|
)
|
|
3700
3840
|
)
|
|
3701
3841
|
|
|
@@ -3759,34 +3899,51 @@ export const ensuring: {
|
|
|
3759
3899
|
|
|
3760
3900
|
/** @internal */
|
|
3761
3901
|
export const onExitIf: {
|
|
3762
|
-
<A, E, XE, XR
|
|
3763
|
-
|
|
3764
|
-
f: (
|
|
3765
|
-
pass: Filter.Pass<Exit.Exit<NoInfer<A>, NoInfer<E>>, Result>,
|
|
3766
|
-
exit: Exit.Exit<NoInfer<A>, NoInfer<E>>
|
|
3767
|
-
) => Effect.Effect<void, XE, XR>
|
|
3902
|
+
<A, E, XE, XR>(
|
|
3903
|
+
predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>,
|
|
3904
|
+
f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect.Effect<void, XE, XR>
|
|
3768
3905
|
): <R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E | XE, R | XR>
|
|
3769
|
-
<A, E, R, XE, XR
|
|
3906
|
+
<A, E, R, XE, XR>(
|
|
3770
3907
|
self: Effect.Effect<A, E, R>,
|
|
3771
|
-
|
|
3772
|
-
f: (
|
|
3773
|
-
pass: Filter.Pass<Exit.Exit<NoInfer<A>, NoInfer<E>>, Result>,
|
|
3774
|
-
exit: Exit.Exit<NoInfer<A>, NoInfer<E>>
|
|
3775
|
-
) => Effect.Effect<void, XE, XR>
|
|
3908
|
+
predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>,
|
|
3909
|
+
f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect.Effect<void, XE, XR>
|
|
3776
3910
|
): Effect.Effect<A, E | XE, R | XR>
|
|
3777
3911
|
} = dual(
|
|
3778
3912
|
3,
|
|
3779
|
-
<A, E, R, XE, XR
|
|
3913
|
+
<A, E, R, XE, XR>(
|
|
3780
3914
|
self: Effect.Effect<A, E, R>,
|
|
3781
|
-
|
|
3782
|
-
f: (
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3915
|
+
predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>,
|
|
3916
|
+
f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect.Effect<void, XE, XR>
|
|
3917
|
+
): Effect.Effect<A, E | XE, R | XR> =>
|
|
3918
|
+
onExit(self, (exit) => {
|
|
3919
|
+
if (!predicate(exit)) {
|
|
3920
|
+
return void_
|
|
3921
|
+
}
|
|
3922
|
+
return f(exit)
|
|
3923
|
+
})
|
|
3924
|
+
)
|
|
3925
|
+
|
|
3926
|
+
/** @internal */
|
|
3927
|
+
export const onExitFilter: {
|
|
3928
|
+
<A, E, XE, XR, B, X>(
|
|
3929
|
+
filter: Filter.Filter<Exit.Exit<NoInfer<A>, NoInfer<E>>, B, X>,
|
|
3930
|
+
f: (b: B, exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect.Effect<void, XE, XR>
|
|
3931
|
+
): <R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E | XE, R | XR>
|
|
3932
|
+
<A, E, R, XE, XR, B, X>(
|
|
3933
|
+
self: Effect.Effect<A, E, R>,
|
|
3934
|
+
filter: Filter.Filter<Exit.Exit<NoInfer<A>, NoInfer<E>>, B, X>,
|
|
3935
|
+
f: (b: B, exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect.Effect<void, XE, XR>
|
|
3936
|
+
): Effect.Effect<A, E | XE, R | XR>
|
|
3937
|
+
} = dual(
|
|
3938
|
+
3,
|
|
3939
|
+
<A, E, R, XE, XR, B, X>(
|
|
3940
|
+
self: Effect.Effect<A, E, R>,
|
|
3941
|
+
filter: Filter.Filter<Exit.Exit<NoInfer<A>, NoInfer<E>>, B, X>,
|
|
3942
|
+
f: (b: B, exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect.Effect<void, XE, XR>
|
|
3786
3943
|
): Effect.Effect<A, E | XE, R | XR> =>
|
|
3787
3944
|
onExit(self, (exit) => {
|
|
3788
|
-
const
|
|
3789
|
-
return Result.isFailure(
|
|
3945
|
+
const b = filter(exit)
|
|
3946
|
+
return Result.isFailure(b) ? void_ : f(b.success, exit)
|
|
3790
3947
|
})
|
|
3791
3948
|
)
|
|
3792
3949
|
|
|
@@ -3804,37 +3961,66 @@ export const onError: {
|
|
|
3804
3961
|
<A, E, R, XE, XR>(
|
|
3805
3962
|
self: Effect.Effect<A, E, R>,
|
|
3806
3963
|
f: (cause: Cause.Cause<NoInfer<E>>) => Effect.Effect<void, XE, XR>
|
|
3807
|
-
): Effect.Effect<A, E | XE, R | XR> =>
|
|
3964
|
+
): Effect.Effect<A, E | XE, R | XR> => onExitFilter(self, exitFilterCause as any, f as any) as any
|
|
3808
3965
|
)
|
|
3809
3966
|
|
|
3810
3967
|
/** @internal */
|
|
3811
3968
|
export const onErrorIf: {
|
|
3812
|
-
<E,
|
|
3813
|
-
|
|
3814
|
-
f: (
|
|
3969
|
+
<E, XE, XR>(
|
|
3970
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
3971
|
+
f: (cause: Cause.Cause<E>) => Effect.Effect<void, XE, XR>
|
|
3815
3972
|
): <A, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E | XE, R | XR>
|
|
3816
|
-
<A, E, R, XE, XR
|
|
3973
|
+
<A, E, R, XE, XR>(
|
|
3817
3974
|
self: Effect.Effect<A, E, R>,
|
|
3818
|
-
|
|
3819
|
-
f: (
|
|
3975
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
3976
|
+
f: (cause: Cause.Cause<E>) => Effect.Effect<void, XE, XR>
|
|
3820
3977
|
): Effect.Effect<A, E | XE, R | XR>
|
|
3821
3978
|
} = dual(
|
|
3822
3979
|
3,
|
|
3823
|
-
<A, E, R, XE, XR
|
|
3980
|
+
<A, E, R, XE, XR>(
|
|
3824
3981
|
self: Effect.Effect<A, E, R>,
|
|
3825
|
-
|
|
3826
|
-
f: (
|
|
3982
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
3983
|
+
f: (cause: Cause.Cause<E>) => Effect.Effect<void, XE, XR>
|
|
3827
3984
|
): Effect.Effect<A, E | XE, R | XR> =>
|
|
3828
3985
|
onExitIf(
|
|
3829
3986
|
self,
|
|
3830
|
-
(
|
|
3831
|
-
if (exit._tag !== "Failure")
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3987
|
+
(exit): exit is Exit.Failure<A, E> => {
|
|
3988
|
+
if (exit._tag !== "Failure") {
|
|
3989
|
+
return false
|
|
3990
|
+
}
|
|
3991
|
+
return predicate(exit.cause)
|
|
3992
|
+
},
|
|
3993
|
+
(exit) => f((exit as Exit.Failure<A, E>).cause)
|
|
3835
3994
|
) as any
|
|
3836
3995
|
)
|
|
3837
3996
|
|
|
3997
|
+
/** @internal */
|
|
3998
|
+
export const onErrorFilter: {
|
|
3999
|
+
<A, E, EB, X, XE, XR>(
|
|
4000
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
4001
|
+
f: (failure: EB, cause: Cause.Cause<E>) => Effect.Effect<void, XE, XR>
|
|
4002
|
+
): <R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E | XE, R | XR>
|
|
4003
|
+
<A, E, R, EB, X, XE, XR>(
|
|
4004
|
+
self: Effect.Effect<A, E, R>,
|
|
4005
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
4006
|
+
f: (failure: EB, cause: Cause.Cause<E>) => Effect.Effect<void, XE, XR>
|
|
4007
|
+
): Effect.Effect<A, E | XE, R | XR>
|
|
4008
|
+
} = dual(
|
|
4009
|
+
3,
|
|
4010
|
+
<A, E, R, EB, X, XE, XR>(
|
|
4011
|
+
self: Effect.Effect<A, E, R>,
|
|
4012
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
4013
|
+
f: (failure: EB, cause: Cause.Cause<E>) => Effect.Effect<void, XE, XR>
|
|
4014
|
+
): Effect.Effect<A, E | XE, R | XR> =>
|
|
4015
|
+
onExit(self, (exit) => {
|
|
4016
|
+
if (exit._tag !== "Failure") {
|
|
4017
|
+
return void_
|
|
4018
|
+
}
|
|
4019
|
+
const result = filter(exit.cause)
|
|
4020
|
+
return Result.isFailure(result) ? void_ : f(result.success, exit.cause)
|
|
4021
|
+
})
|
|
4022
|
+
)
|
|
4023
|
+
|
|
3838
4024
|
/** @internal */
|
|
3839
4025
|
export const onInterrupt: {
|
|
3840
4026
|
<XE, XR>(
|
|
@@ -3849,8 +4035,7 @@ export const onInterrupt: {
|
|
|
3849
4035
|
<A, E, R, XE, XR>(
|
|
3850
4036
|
self: Effect.Effect<A, E, R>,
|
|
3851
4037
|
finalizer: (interruptors: ReadonlySet<number>) => Effect.Effect<void, XE, XR>
|
|
3852
|
-
): Effect.Effect<A, E | XE, R | XR> =>
|
|
3853
|
-
onErrorIf<E, Result.Result<Set<number>, Cause.Cause<E>>, XE, XR>(causeFilterInterruptors, finalizer)(self)
|
|
4038
|
+
): Effect.Effect<A, E | XE, R | XR> => onErrorFilter(causeFilterInterruptors as any, finalizer)(self) as any
|
|
3854
4039
|
)
|
|
3855
4040
|
|
|
3856
4041
|
/** @internal */
|
|
@@ -3874,19 +4059,19 @@ export const acquireUseRelease = <Resource, E, R, A, E2, R2, E3, R3>(
|
|
|
3874
4059
|
|
|
3875
4060
|
/** @internal */
|
|
3876
4061
|
export const cachedInvalidateWithTTL: {
|
|
3877
|
-
(timeToLive: Duration.
|
|
4062
|
+
(timeToLive: Duration.Input): <A, E, R>(
|
|
3878
4063
|
self: Effect.Effect<A, E, R>
|
|
3879
4064
|
) => Effect.Effect<[Effect.Effect<A, E, R>, Effect.Effect<void>]>
|
|
3880
4065
|
<A, E, R>(
|
|
3881
4066
|
self: Effect.Effect<A, E, R>,
|
|
3882
|
-
timeToLive: Duration.
|
|
4067
|
+
timeToLive: Duration.Input
|
|
3883
4068
|
): Effect.Effect<[Effect.Effect<A, E, R>, Effect.Effect<void>]>
|
|
3884
4069
|
} = dual(2, <A, E, R>(
|
|
3885
4070
|
self: Effect.Effect<A, E, R>,
|
|
3886
|
-
ttl: Duration.
|
|
4071
|
+
ttl: Duration.Input
|
|
3887
4072
|
): Effect.Effect<[Effect.Effect<A, E, R>, Effect.Effect<void>]> =>
|
|
3888
4073
|
sync(() => {
|
|
3889
|
-
const ttlMillis = Duration.toMillis(Duration.
|
|
4074
|
+
const ttlMillis = Duration.toMillis(Duration.fromInputUnsafe(ttl))
|
|
3890
4075
|
const isFinite = Number.isFinite(ttlMillis)
|
|
3891
4076
|
const latch = makeLatchUnsafe(false)
|
|
3892
4077
|
let expiresAt = 0
|
|
@@ -3895,7 +4080,8 @@ export const cachedInvalidateWithTTL: {
|
|
|
3895
4080
|
const wait = flatMap(latch.await, () => exit!)
|
|
3896
4081
|
return [
|
|
3897
4082
|
withFiber((fiber) => {
|
|
3898
|
-
const
|
|
4083
|
+
const clock = fiber.getRef(ClockRef)
|
|
4084
|
+
const now = isFinite ? clock.currentTimeMillisUnsafe() : 0
|
|
3899
4085
|
if (running || now < expiresAt) return exit ?? wait
|
|
3900
4086
|
running = true
|
|
3901
4087
|
latch.closeUnsafe()
|
|
@@ -3903,7 +4089,7 @@ export const cachedInvalidateWithTTL: {
|
|
|
3903
4089
|
return onExit(self, (exit_) =>
|
|
3904
4090
|
sync(() => {
|
|
3905
4091
|
running = false
|
|
3906
|
-
expiresAt =
|
|
4092
|
+
expiresAt = clock.currentTimeMillisUnsafe() + ttlMillis
|
|
3907
4093
|
exit = exit_
|
|
3908
4094
|
latch.openUnsafe()
|
|
3909
4095
|
}))
|
|
@@ -3919,17 +4105,17 @@ export const cachedInvalidateWithTTL: {
|
|
|
3919
4105
|
/** @internal */
|
|
3920
4106
|
export const cachedWithTTL: {
|
|
3921
4107
|
(
|
|
3922
|
-
timeToLive: Duration.
|
|
4108
|
+
timeToLive: Duration.Input
|
|
3923
4109
|
): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<Effect.Effect<A, E, R>>
|
|
3924
4110
|
<A, E, R>(
|
|
3925
4111
|
self: Effect.Effect<A, E, R>,
|
|
3926
|
-
timeToLive: Duration.
|
|
4112
|
+
timeToLive: Duration.Input
|
|
3927
4113
|
): Effect.Effect<Effect.Effect<A, E, R>>
|
|
3928
4114
|
} = dual(
|
|
3929
4115
|
2,
|
|
3930
4116
|
<A, E, R>(
|
|
3931
4117
|
self: Effect.Effect<A, E, R>,
|
|
3932
|
-
timeToLive: Duration.
|
|
4118
|
+
timeToLive: Duration.Input
|
|
3933
4119
|
): Effect.Effect<Effect.Effect<A, E, R>> => map(cachedInvalidateWithTTL(self, timeToLive), (tuple) => tuple[0])
|
|
3934
4120
|
)
|
|
3935
4121
|
|
|
@@ -4009,6 +4195,15 @@ export const interruptibleMask = <A, E, R>(
|
|
|
4009
4195
|
return f(uninterruptible)
|
|
4010
4196
|
})
|
|
4011
4197
|
|
|
4198
|
+
/** @internal */
|
|
4199
|
+
export const abortSignal: Effect.Effect<AbortSignal, never, Scope.Scope> = map(
|
|
4200
|
+
acquireRelease(
|
|
4201
|
+
sync(() => new AbortController()),
|
|
4202
|
+
(controller) => sync(() => controller.abort())
|
|
4203
|
+
),
|
|
4204
|
+
(_) => _.signal
|
|
4205
|
+
)
|
|
4206
|
+
|
|
4012
4207
|
// ========================================================================
|
|
4013
4208
|
// collecting & elements
|
|
4014
4209
|
// ========================================================================
|
|
@@ -4075,57 +4270,194 @@ export const partition: {
|
|
|
4075
4270
|
): Effect.Effect<[excluded: Array<E>, satisfying: Array<B>], never, R> =>
|
|
4076
4271
|
map(
|
|
4077
4272
|
forEach(elements, (a, i) => result(f(a, i)), options),
|
|
4078
|
-
(results) => Arr.
|
|
4273
|
+
(results) => Arr.partition(results, identity)
|
|
4079
4274
|
)
|
|
4080
4275
|
)
|
|
4081
4276
|
|
|
4082
4277
|
/** @internal */
|
|
4083
|
-
export const
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
readonly step: (a: A) => void
|
|
4087
|
-
}) => Effect.Effect<void, E, R> = makePrimitive({
|
|
4088
|
-
op: "While",
|
|
4089
|
-
[contA](value, fiber) {
|
|
4090
|
-
this[args].step(value)
|
|
4091
|
-
if (this[args].while()) {
|
|
4092
|
-
fiber._stack.push(this)
|
|
4093
|
-
return this[args].body()
|
|
4094
|
-
}
|
|
4095
|
-
return exitVoid
|
|
4096
|
-
},
|
|
4097
|
-
[evaluate](fiber) {
|
|
4098
|
-
if (this[args].while()) {
|
|
4099
|
-
fiber._stack.push(this)
|
|
4100
|
-
return this[args].body()
|
|
4101
|
-
}
|
|
4102
|
-
return exitVoid
|
|
4103
|
-
}
|
|
4104
|
-
})
|
|
4105
|
-
|
|
4106
|
-
/** @internal */
|
|
4107
|
-
export const forEach: {
|
|
4108
|
-
<B, E, R, S extends Iterable<any>, const Discard extends boolean = false>(
|
|
4109
|
-
f: (a: Arr.ReadonlyArray.Infer<S>, i: number) => Effect.Effect<B, E, R>,
|
|
4278
|
+
export const validate: {
|
|
4279
|
+
<A, B, E, R>(
|
|
4280
|
+
f: (a: A, i: number) => Effect.Effect<B, E, R>,
|
|
4110
4281
|
options?: {
|
|
4111
4282
|
readonly concurrency?: Concurrency | undefined
|
|
4112
|
-
readonly discard?:
|
|
4283
|
+
readonly discard?: false | undefined
|
|
4113
4284
|
} | undefined
|
|
4114
|
-
): (
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4285
|
+
): (elements: Iterable<A>) => Effect.Effect<Array<B>, Arr.NonEmptyArray<E>, R>
|
|
4286
|
+
<A, B, E, R>(
|
|
4287
|
+
f: (a: A, i: number) => Effect.Effect<B, E, R>,
|
|
4288
|
+
options: {
|
|
4289
|
+
readonly concurrency?: Concurrency | undefined
|
|
4290
|
+
readonly discard: true
|
|
4291
|
+
}
|
|
4292
|
+
): (elements: Iterable<A>) => Effect.Effect<void, Arr.NonEmptyArray<E>, R>
|
|
4293
|
+
<A, B, E, R>(
|
|
4294
|
+
elements: Iterable<A>,
|
|
4295
|
+
f: (a: A, i: number) => Effect.Effect<B, E, R>,
|
|
4120
4296
|
options?: {
|
|
4121
4297
|
readonly concurrency?: Concurrency | undefined
|
|
4122
|
-
readonly discard?:
|
|
4298
|
+
readonly discard?: false | undefined
|
|
4123
4299
|
} | undefined
|
|
4124
|
-
): Effect.Effect<
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4300
|
+
): Effect.Effect<Array<B>, Arr.NonEmptyArray<E>, R>
|
|
4301
|
+
<A, B, E, R>(
|
|
4302
|
+
elements: Iterable<A>,
|
|
4303
|
+
f: (a: A, i: number) => Effect.Effect<B, E, R>,
|
|
4304
|
+
options: {
|
|
4305
|
+
readonly concurrency?: Concurrency | undefined
|
|
4306
|
+
readonly discard: true
|
|
4307
|
+
}
|
|
4308
|
+
): Effect.Effect<void, Arr.NonEmptyArray<E>, R>
|
|
4309
|
+
} = dual(
|
|
4310
|
+
(args) => isIterable(args[0]) && !isEffect(args[0]),
|
|
4311
|
+
<A, B, E, R>(
|
|
4312
|
+
elements: Iterable<A>,
|
|
4313
|
+
f: (a: A, i: number) => Effect.Effect<B, E, R>,
|
|
4314
|
+
options?: {
|
|
4315
|
+
readonly concurrency?: Concurrency | undefined
|
|
4316
|
+
readonly discard?: boolean | undefined
|
|
4317
|
+
} | undefined
|
|
4318
|
+
): Effect.Effect<Array<B> | void, Arr.NonEmptyArray<E>, R> =>
|
|
4319
|
+
flatMap(
|
|
4320
|
+
partition(elements, f, { concurrency: options?.concurrency }),
|
|
4321
|
+
([excluded, satisfying]) => {
|
|
4322
|
+
if (Arr.isArrayNonEmpty(excluded)) {
|
|
4323
|
+
return fail(excluded)
|
|
4324
|
+
}
|
|
4325
|
+
return options?.discard ? void_ : succeed(satisfying)
|
|
4326
|
+
}
|
|
4327
|
+
)
|
|
4328
|
+
)
|
|
4329
|
+
|
|
4330
|
+
/** @internal */
|
|
4331
|
+
export const findFirst: {
|
|
4332
|
+
<A, E, R>(
|
|
4333
|
+
predicate: (a: NoInfer<A>, i: number) => Effect.Effect<boolean, E, R>
|
|
4334
|
+
): (elements: Iterable<A>) => Effect.Effect<Option.Option<A>, E, R>
|
|
4335
|
+
<A, E, R>(
|
|
4336
|
+
elements: Iterable<A>,
|
|
4337
|
+
predicate: (a: NoInfer<A>, i: number) => Effect.Effect<boolean, E, R>
|
|
4338
|
+
): Effect.Effect<Option.Option<A>, E, R>
|
|
4339
|
+
} = dual(
|
|
4340
|
+
(args) => isIterable(args[0]) && !isEffect(args[0]),
|
|
4341
|
+
<A, E, R>(
|
|
4342
|
+
elements: Iterable<A>,
|
|
4343
|
+
predicate: (a: A, i: number) => Effect.Effect<boolean, E, R>
|
|
4344
|
+
): Effect.Effect<Option.Option<A>, E, R> =>
|
|
4345
|
+
suspend(() => {
|
|
4346
|
+
const iterator = elements[Symbol.iterator]()
|
|
4347
|
+
const next = iterator.next()
|
|
4348
|
+
if (!next.done) {
|
|
4349
|
+
return findFirstLoop(iterator, 0, predicate, next.value)
|
|
4350
|
+
}
|
|
4351
|
+
return succeed(Option.none())
|
|
4352
|
+
})
|
|
4353
|
+
)
|
|
4354
|
+
|
|
4355
|
+
const findFirstLoop = <A, E, R>(
|
|
4356
|
+
iterator: Iterator<A>,
|
|
4357
|
+
index: number,
|
|
4358
|
+
predicate: (a: A, i: number) => Effect.Effect<boolean, E, R>,
|
|
4359
|
+
value: A
|
|
4360
|
+
): Effect.Effect<Option.Option<A>, E, R> =>
|
|
4361
|
+
flatMap(predicate(value, index), (keep) => {
|
|
4362
|
+
if (keep) {
|
|
4363
|
+
return succeed(Option.some(value))
|
|
4364
|
+
}
|
|
4365
|
+
const next = iterator.next()
|
|
4366
|
+
if (!next.done) {
|
|
4367
|
+
return findFirstLoop(iterator, index + 1, predicate, next.value)
|
|
4368
|
+
}
|
|
4369
|
+
return succeed(Option.none())
|
|
4370
|
+
})
|
|
4371
|
+
|
|
4372
|
+
/** @internal */
|
|
4373
|
+
export const findFirstFilter: {
|
|
4374
|
+
<A, B, X, E, R>(
|
|
4375
|
+
filter: (input: NoInfer<A>, i: number) => Effect.Effect<Result.Result<B, X>, E, R>
|
|
4376
|
+
): (elements: Iterable<A>) => Effect.Effect<Option.Option<B>, E, R>
|
|
4377
|
+
<A, B, X, E, R>(
|
|
4378
|
+
elements: Iterable<A>,
|
|
4379
|
+
filter: (input: NoInfer<A>, i: number) => Effect.Effect<Result.Result<B, X>, E, R>
|
|
4380
|
+
): Effect.Effect<Option.Option<B>, E, R>
|
|
4381
|
+
} = dual(
|
|
4382
|
+
(args) => isIterable(args[0]) && !isEffect(args[0]),
|
|
4383
|
+
<A, B, X, E, R>(
|
|
4384
|
+
elements: Iterable<A>,
|
|
4385
|
+
filter: (input: A, i: number) => Effect.Effect<Result.Result<B, X>, E, R>
|
|
4386
|
+
): Effect.Effect<Option.Option<B>, E, R> =>
|
|
4387
|
+
suspend(() => {
|
|
4388
|
+
const iterator = elements[Symbol.iterator]()
|
|
4389
|
+
const next = iterator.next()
|
|
4390
|
+
if (!next.done) {
|
|
4391
|
+
return findFirstFilterLoop(iterator, 0, filter, next.value)
|
|
4392
|
+
}
|
|
4393
|
+
return succeed(Option.none())
|
|
4394
|
+
})
|
|
4395
|
+
)
|
|
4396
|
+
|
|
4397
|
+
const findFirstFilterLoop = <A, B, X, E, R>(
|
|
4398
|
+
iterator: Iterator<A>,
|
|
4399
|
+
index: number,
|
|
4400
|
+
filter: (input: A, i: number) => Effect.Effect<Result.Result<B, X>, E, R>,
|
|
4401
|
+
value: A
|
|
4402
|
+
): Effect.Effect<Option.Option<B>, E, R> =>
|
|
4403
|
+
flatMap(filter(value, index), (result) => {
|
|
4404
|
+
if (Result.isSuccess(result)) {
|
|
4405
|
+
return succeed(Option.some(result.success))
|
|
4406
|
+
}
|
|
4407
|
+
const next = iterator.next()
|
|
4408
|
+
if (!next.done) {
|
|
4409
|
+
return findFirstFilterLoop(iterator, index + 1, filter, next.value)
|
|
4410
|
+
}
|
|
4411
|
+
return succeed(Option.none())
|
|
4412
|
+
})
|
|
4413
|
+
|
|
4414
|
+
/** @internal */
|
|
4415
|
+
export const whileLoop: <A, E, R>(options: {
|
|
4416
|
+
readonly while: LazyArg<boolean>
|
|
4417
|
+
readonly body: LazyArg<Effect.Effect<A, E, R>>
|
|
4418
|
+
readonly step: (a: A) => void
|
|
4419
|
+
}) => Effect.Effect<void, E, R> = makePrimitive({
|
|
4420
|
+
op: "While",
|
|
4421
|
+
[contA](value, fiber) {
|
|
4422
|
+
this[args].step(value)
|
|
4423
|
+
if (this[args].while()) {
|
|
4424
|
+
fiber._stack.push(this)
|
|
4425
|
+
return this[args].body()
|
|
4426
|
+
}
|
|
4427
|
+
return exitVoid
|
|
4428
|
+
},
|
|
4429
|
+
[evaluate](fiber) {
|
|
4430
|
+
if (this[args].while()) {
|
|
4431
|
+
fiber._stack.push(this)
|
|
4432
|
+
return this[args].body()
|
|
4433
|
+
}
|
|
4434
|
+
return exitVoid
|
|
4435
|
+
}
|
|
4436
|
+
})
|
|
4437
|
+
|
|
4438
|
+
/** @internal */
|
|
4439
|
+
export const forEach: {
|
|
4440
|
+
<B, E, R, S extends Iterable<any>, const Discard extends boolean = false>(
|
|
4441
|
+
f: (a: Arr.ReadonlyArray.Infer<S>, i: number) => Effect.Effect<B, E, R>,
|
|
4442
|
+
options?: {
|
|
4443
|
+
readonly concurrency?: Concurrency | undefined
|
|
4444
|
+
readonly discard?: Discard | undefined
|
|
4445
|
+
} | undefined
|
|
4446
|
+
): (
|
|
4447
|
+
self: S
|
|
4448
|
+
) => Effect.Effect<Discard extends false ? Arr.ReadonlyArray.With<S, B> : void, E, R>
|
|
4449
|
+
<B, E, R, S extends Iterable<any>, const Discard extends boolean = false>(
|
|
4450
|
+
self: S,
|
|
4451
|
+
f: (a: Arr.ReadonlyArray.Infer<S>, i: number) => Effect.Effect<B, E, R>,
|
|
4452
|
+
options?: {
|
|
4453
|
+
readonly concurrency?: Concurrency | undefined
|
|
4454
|
+
readonly discard?: Discard | undefined
|
|
4455
|
+
} | undefined
|
|
4456
|
+
): Effect.Effect<Discard extends false ? Arr.ReadonlyArray.With<S, B> : void, E, R>
|
|
4457
|
+
} = dual((args) => typeof args[1] === "function", <A, B, E, R>(
|
|
4458
|
+
iterable: Iterable<A>,
|
|
4459
|
+
f: (a: A, index: number) => Effect.Effect<B, E, R>,
|
|
4460
|
+
options?: {
|
|
4129
4461
|
readonly concurrency?: Concurrency | undefined
|
|
4130
4462
|
readonly discard?: boolean | undefined
|
|
4131
4463
|
}
|
|
@@ -4151,72 +4483,8 @@ export const forEach: {
|
|
|
4151
4483
|
const out: Array<B> | undefined = options?.discard
|
|
4152
4484
|
? undefined
|
|
4153
4485
|
: new Array(length)
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
return callback((resume) => {
|
|
4158
|
-
const fibers = new Set<Fiber.Fiber<unknown, unknown>>()
|
|
4159
|
-
const failures: Array<Cause.Reason<E>> = []
|
|
4160
|
-
let failed = false
|
|
4161
|
-
let inProgress = 0
|
|
4162
|
-
let doneCount = 0
|
|
4163
|
-
let pumping = false
|
|
4164
|
-
let interrupted = false
|
|
4165
|
-
function pump() {
|
|
4166
|
-
pumping = true
|
|
4167
|
-
while (inProgress < concurrency && index < length) {
|
|
4168
|
-
const currentIndex = index
|
|
4169
|
-
const item = items[currentIndex]
|
|
4170
|
-
index++
|
|
4171
|
-
inProgress++
|
|
4172
|
-
try {
|
|
4173
|
-
const child = forkUnsafe(parent, f(item, currentIndex), true, true, "inherit")
|
|
4174
|
-
fibers.add(child)
|
|
4175
|
-
child.addObserver((exit) => {
|
|
4176
|
-
if (interrupted) {
|
|
4177
|
-
return
|
|
4178
|
-
}
|
|
4179
|
-
fibers.delete(child)
|
|
4180
|
-
if (exit._tag === "Failure") {
|
|
4181
|
-
if (!failed) {
|
|
4182
|
-
failed = true
|
|
4183
|
-
length = index
|
|
4184
|
-
failures.push(...exit.cause.reasons)
|
|
4185
|
-
fibers.forEach((fiber) => fiber.interruptUnsafe(parent.id, annotations))
|
|
4186
|
-
} else {
|
|
4187
|
-
for (const f of exit.cause.reasons) {
|
|
4188
|
-
if (f._tag === "Interrupt") continue
|
|
4189
|
-
failures.push(f)
|
|
4190
|
-
}
|
|
4191
|
-
}
|
|
4192
|
-
} else if (out !== undefined) {
|
|
4193
|
-
out[currentIndex] = exit.value
|
|
4194
|
-
}
|
|
4195
|
-
doneCount++
|
|
4196
|
-
inProgress--
|
|
4197
|
-
if (doneCount === length) {
|
|
4198
|
-
resume(failures.length > 0 ? exitFailCause(causeFromReasons(failures)) : succeed(out))
|
|
4199
|
-
} else if (!pumping && !failed && inProgress < concurrency) {
|
|
4200
|
-
pump()
|
|
4201
|
-
}
|
|
4202
|
-
})
|
|
4203
|
-
} catch (err) {
|
|
4204
|
-
failed = true
|
|
4205
|
-
length = index
|
|
4206
|
-
failures.push(new Die(err))
|
|
4207
|
-
fibers.forEach((fiber) => fiber.interruptUnsafe(parent.id, annotations))
|
|
4208
|
-
}
|
|
4209
|
-
}
|
|
4210
|
-
pumping = false
|
|
4211
|
-
}
|
|
4212
|
-
pump()
|
|
4213
|
-
|
|
4214
|
-
return suspend(() => {
|
|
4215
|
-
interrupted = true
|
|
4216
|
-
index = length
|
|
4217
|
-
return fiberInterruptAll(fibers)
|
|
4218
|
-
})
|
|
4219
|
-
})
|
|
4486
|
+
const eff = forEachConcurrent({ f, out }, items, { concurrency })
|
|
4487
|
+
return eff ? as(eff, out as any) : succeed(out as any)
|
|
4220
4488
|
}))
|
|
4221
4489
|
|
|
4222
4490
|
const forEachSequential = <A, B, E, R>(
|
|
@@ -4244,39 +4512,273 @@ const forEachSequential = <A, B, E, R>(
|
|
|
4244
4512
|
)
|
|
4245
4513
|
})
|
|
4246
4514
|
|
|
4515
|
+
const iterateEagerImpl = <S, A, X, E, R, E2>(options: {
|
|
4516
|
+
readonly onItem: (state: S, item: A, index: number) => Effect.Effect<X, E, R>
|
|
4517
|
+
readonly step: (state: NoInfer<S>, item: A, exit: Exit.Exit<X, E>, index: number) => Exit.Exit<void, E2> | void
|
|
4518
|
+
}): (
|
|
4519
|
+
initialState: S,
|
|
4520
|
+
items: ReadonlyArray<A>,
|
|
4521
|
+
options?: {
|
|
4522
|
+
readonly concurrency?: number | undefined
|
|
4523
|
+
readonly start?: number | undefined
|
|
4524
|
+
readonly end?: number | undefined
|
|
4525
|
+
}
|
|
4526
|
+
) => Effect.Effect<void, E | E2, R> | undefined => {
|
|
4527
|
+
const onItem = options.onItem
|
|
4528
|
+
const step = options.step
|
|
4529
|
+
|
|
4530
|
+
return (
|
|
4531
|
+
state: S,
|
|
4532
|
+
items: ReadonlyArray<A>,
|
|
4533
|
+
opts: {
|
|
4534
|
+
readonly concurrency?: number | undefined
|
|
4535
|
+
readonly start?: number | undefined
|
|
4536
|
+
readonly end?: number | undefined
|
|
4537
|
+
} | undefined
|
|
4538
|
+
): Effect.Effect<void, E | E2, R> | undefined => {
|
|
4539
|
+
let index = opts?.start ?? 0
|
|
4540
|
+
const end = opts?.end ?? items.length
|
|
4541
|
+
const concurrency = opts?.concurrency ?? 1
|
|
4542
|
+
let done = false
|
|
4543
|
+
let parentFiber: Fiber.Fiber<any, any> | undefined
|
|
4544
|
+
let fibers: Set<Fiber.Fiber<any, any>> | undefined
|
|
4545
|
+
let resume: ((effect: Effect.Effect<void, E | E2, R>) => void) | undefined
|
|
4546
|
+
let interrupted = false
|
|
4547
|
+
let terminal: Exit.Exit<void, E | E2> | void
|
|
4548
|
+
let effect: Effect.Effect<X, E, R> | undefined
|
|
4549
|
+
|
|
4550
|
+
const go = (): Effect.Effect<void, E | E2, R> | undefined => {
|
|
4551
|
+
let paused = false
|
|
4552
|
+
for (; !terminal && index < end; index++) {
|
|
4553
|
+
const item = items[index]
|
|
4554
|
+
const eff = effect ?? onItem(state, item, index)
|
|
4555
|
+
|
|
4556
|
+
// fast case (already an exit)
|
|
4557
|
+
if (effectIsExit(eff)) {
|
|
4558
|
+
terminal = step(state, item, eff, index)
|
|
4559
|
+
if (terminal) break
|
|
4560
|
+
|
|
4561
|
+
// Use flatMap for concurrency of 1
|
|
4562
|
+
} else if (concurrency === 1) {
|
|
4563
|
+
return flatMap(exit(eff), (exit) => {
|
|
4564
|
+
terminal = step(state, item, exit, index)
|
|
4565
|
+
index++
|
|
4566
|
+
return terminal ?? go() ?? void_
|
|
4567
|
+
})
|
|
4568
|
+
|
|
4569
|
+
// We have an effect, so enter "async" mode
|
|
4570
|
+
} else if (!parentFiber) {
|
|
4571
|
+
return callback((cb) => {
|
|
4572
|
+
parentFiber = getCurrentFiber()!
|
|
4573
|
+
effect = eff
|
|
4574
|
+
resume = cb
|
|
4575
|
+
const result = go()
|
|
4576
|
+
if (result) return cb(result)
|
|
4577
|
+
return suspend(() => {
|
|
4578
|
+
terminal = exitVoid
|
|
4579
|
+
interrupted = true
|
|
4580
|
+
return fibers ? fiberInterruptAll(fibers) : void_
|
|
4581
|
+
})
|
|
4582
|
+
})
|
|
4583
|
+
|
|
4584
|
+
// Fork the effect with concurrency > 1
|
|
4585
|
+
} else {
|
|
4586
|
+
// Clear the temporary effect from capturing the parentFiber
|
|
4587
|
+
effect = undefined
|
|
4588
|
+
|
|
4589
|
+
const fiber = forkUnsafe(parentFiber, eff, true, true, "inherit")
|
|
4590
|
+
if (fiber._exit) {
|
|
4591
|
+
terminal = step(state, item, fiber._exit, index)
|
|
4592
|
+
if (terminal) break
|
|
4593
|
+
continue
|
|
4594
|
+
}
|
|
4595
|
+
|
|
4596
|
+
// Add the fiber to the Set
|
|
4597
|
+
if (fibers) fibers.add(fiber)
|
|
4598
|
+
else fibers = new Set([fiber])
|
|
4599
|
+
|
|
4600
|
+
const currentIndex = index
|
|
4601
|
+
fiber.addObserver((exit) => {
|
|
4602
|
+
fibers!.delete(fiber)
|
|
4603
|
+
if (terminal) {
|
|
4604
|
+
if (!interrupted && exit._tag === "Failure") {
|
|
4605
|
+
for (const reason of exit.cause.reasons) {
|
|
4606
|
+
if (reason._tag === "Interrupt") continue
|
|
4607
|
+
else if (terminal._tag === "Failure") {
|
|
4608
|
+
;(terminal.cause.reasons as Array<any>).push(reason)
|
|
4609
|
+
} else {
|
|
4610
|
+
terminal = exitFailCause(causeFromReasons([reason]))
|
|
4611
|
+
}
|
|
4612
|
+
}
|
|
4613
|
+
}
|
|
4614
|
+
} else {
|
|
4615
|
+
const result = step(state, item, exit, currentIndex)
|
|
4616
|
+
if (result) {
|
|
4617
|
+
terminal = result._tag === "Failure"
|
|
4618
|
+
? exitFailCause(causeFromReasons(result.cause.reasons.slice()))
|
|
4619
|
+
: result
|
|
4620
|
+
go()
|
|
4621
|
+
}
|
|
4622
|
+
}
|
|
4623
|
+
|
|
4624
|
+
if (paused) {
|
|
4625
|
+
const eff = go()
|
|
4626
|
+
if (eff) resume!(eff)
|
|
4627
|
+
} else if (done && fibers!.size === 0) {
|
|
4628
|
+
resume!(terminal ?? void_)
|
|
4629
|
+
}
|
|
4630
|
+
})
|
|
4631
|
+
|
|
4632
|
+
// Check if we have reached the concurrency limit
|
|
4633
|
+
if (fibers.size < concurrency) continue
|
|
4634
|
+
paused = true
|
|
4635
|
+
index++
|
|
4636
|
+
return
|
|
4637
|
+
}
|
|
4638
|
+
}
|
|
4639
|
+
|
|
4640
|
+
done = true
|
|
4641
|
+
|
|
4642
|
+
if (terminal) {
|
|
4643
|
+
if (fibers && fibers.size > 0) {
|
|
4644
|
+
const annotations = fiberStackAnnotations(parentFiber!)
|
|
4645
|
+
fibers.forEach((f) => f.interruptUnsafe(parentFiber!.id, annotations))
|
|
4646
|
+
return
|
|
4647
|
+
}
|
|
4648
|
+
if (resume || terminal._tag === "Failure") {
|
|
4649
|
+
return terminal
|
|
4650
|
+
}
|
|
4651
|
+
} else if (resume) {
|
|
4652
|
+
if (!fibers) {
|
|
4653
|
+
return exitVoid
|
|
4654
|
+
} else if (fibers.size === 0) {
|
|
4655
|
+
resume(void_)
|
|
4656
|
+
}
|
|
4657
|
+
}
|
|
4658
|
+
}
|
|
4659
|
+
|
|
4660
|
+
return go()
|
|
4661
|
+
}
|
|
4662
|
+
}
|
|
4663
|
+
|
|
4664
|
+
/** @internal */
|
|
4665
|
+
export const iterateEager = <S, A>(): <X, E, R, E2>(options: {
|
|
4666
|
+
readonly onItem: (state: S, item: A, index: number) => Effect.Effect<X, E, R>
|
|
4667
|
+
readonly step: (state: NoInfer<S>, item: A, exit: Exit.Exit<X, E>, index: number) => Exit.Exit<void, E2> | void
|
|
4668
|
+
}) => (
|
|
4669
|
+
initialState: S,
|
|
4670
|
+
items: ReadonlyArray<A>,
|
|
4671
|
+
options?: {
|
|
4672
|
+
readonly concurrency?: number | undefined
|
|
4673
|
+
readonly start?: number | undefined
|
|
4674
|
+
readonly end?: number | undefined
|
|
4675
|
+
}
|
|
4676
|
+
) => Effect.Effect<void, E | E2, R> | undefined => iterateEagerImpl
|
|
4677
|
+
|
|
4678
|
+
const forEachConcurrent = iterateEagerImpl({
|
|
4679
|
+
onItem(
|
|
4680
|
+
state: {
|
|
4681
|
+
readonly f: (a: any, i: number) => Effect.Effect<any, any, any>
|
|
4682
|
+
readonly out: Array<any> | undefined
|
|
4683
|
+
},
|
|
4684
|
+
item,
|
|
4685
|
+
index
|
|
4686
|
+
) {
|
|
4687
|
+
return state.f(item, index)
|
|
4688
|
+
},
|
|
4689
|
+
step(state, _, exit, index) {
|
|
4690
|
+
if (exit._tag === "Failure") return exit
|
|
4691
|
+
else if (state.out) {
|
|
4692
|
+
state.out[index] = exit.value
|
|
4693
|
+
}
|
|
4694
|
+
}
|
|
4695
|
+
})
|
|
4696
|
+
|
|
4247
4697
|
/* @internal */
|
|
4248
4698
|
export const filterOrElse: {
|
|
4249
4699
|
<A, C, E2, R2, B extends A>(
|
|
4250
4700
|
refinement: Predicate.Refinement<NoInfer<A>, B>,
|
|
4251
4701
|
orElse: (a: EqualsWith<A, B, NoInfer<A>, Exclude<NoInfer<A>, B>>) => Effect.Effect<C, E2, R2>
|
|
4252
4702
|
): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<B | C, E2 | E, R2 | R>
|
|
4253
|
-
<A,
|
|
4254
|
-
|
|
4255
|
-
orElse: (a:
|
|
4256
|
-
): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<
|
|
4703
|
+
<A, C, E2, R2>(
|
|
4704
|
+
predicate: Predicate.Predicate<NoInfer<A>>,
|
|
4705
|
+
orElse: (a: NoInfer<A>) => Effect.Effect<C, E2, R2>
|
|
4706
|
+
): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A | C, E2 | E, R2 | R>
|
|
4257
4707
|
<A, E, R, C, E2, R2, B extends A>(
|
|
4258
4708
|
self: Effect.Effect<A, E, R>,
|
|
4259
4709
|
refinement: Predicate.Refinement<A, B>,
|
|
4260
4710
|
orElse: (a: EqualsWith<A, B, A, Exclude<A, B>>) => Effect.Effect<C, E2, R2>
|
|
4261
4711
|
): Effect.Effect<B | C, E | E2, R | R2>
|
|
4262
|
-
<A, E, R,
|
|
4712
|
+
<A, E, R, C, E2, R2>(
|
|
4713
|
+
self: Effect.Effect<A, E, R>,
|
|
4714
|
+
predicate: Predicate.Predicate<NoInfer<A>>,
|
|
4715
|
+
orElse: (a: NoInfer<A>) => Effect.Effect<C, E2, R2>
|
|
4716
|
+
): Effect.Effect<A | C, E | E2, R | R2>
|
|
4717
|
+
} = dual(3, <A, E, R, B, E2, R2>(
|
|
4718
|
+
self: Effect.Effect<A, E, R>,
|
|
4719
|
+
predicate: Predicate.Predicate<A>,
|
|
4720
|
+
orElse: (a: A) => Effect.Effect<B, E2, R2>
|
|
4721
|
+
): Effect.Effect<A | B, E | E2, R | R2> =>
|
|
4722
|
+
flatMap(
|
|
4723
|
+
self,
|
|
4724
|
+
(a) => predicate(a) ? succeed<A | B>(a) : orElse(a)
|
|
4725
|
+
))
|
|
4726
|
+
|
|
4727
|
+
/** @internal */
|
|
4728
|
+
export const filterMapOrElse: {
|
|
4729
|
+
<A, B, X, C, E2, R2>(
|
|
4730
|
+
filter: Filter.Filter<NoInfer<A>, B, X>,
|
|
4731
|
+
orElse: (x: X) => Effect.Effect<C, E2, R2>
|
|
4732
|
+
): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<B | C, E2 | E, R2 | R>
|
|
4733
|
+
<A, E, R, B, X, C, E2, R2>(
|
|
4263
4734
|
self: Effect.Effect<A, E, R>,
|
|
4264
|
-
filter: Filter.
|
|
4265
|
-
orElse: (
|
|
4266
|
-
): Effect.Effect<
|
|
4267
|
-
} = dual(3, <A, E, R,
|
|
4735
|
+
filter: Filter.Filter<NoInfer<A>, B, X>,
|
|
4736
|
+
orElse: (x: X) => Effect.Effect<C, E2, R2>
|
|
4737
|
+
): Effect.Effect<B | C, E | E2, R | R2>
|
|
4738
|
+
} = dual(3, <A, E, R, B, X, C, E2, R2>(
|
|
4268
4739
|
self: Effect.Effect<A, E, R>,
|
|
4269
|
-
filter: Filter.
|
|
4270
|
-
orElse: (
|
|
4271
|
-
): Effect.Effect<
|
|
4740
|
+
filter: Filter.Filter<NoInfer<A>, B, X>,
|
|
4741
|
+
orElse: (x: X) => Effect.Effect<C, E2, R2>
|
|
4742
|
+
): Effect.Effect<B | C, E | E2, R | R2> =>
|
|
4272
4743
|
flatMap(
|
|
4273
4744
|
self,
|
|
4274
4745
|
(a) => {
|
|
4275
|
-
const result =
|
|
4276
|
-
return Result.isFailure(result)
|
|
4746
|
+
const result = filter(a)
|
|
4747
|
+
return (Result.isFailure(result)
|
|
4748
|
+
? orElse(result.failure)
|
|
4749
|
+
: succeed(result.success)) as Effect.Effect<B | C, E2, R2>
|
|
4277
4750
|
}
|
|
4278
4751
|
))
|
|
4279
4752
|
|
|
4753
|
+
/* @internal */
|
|
4754
|
+
export const filterMapOrFail: {
|
|
4755
|
+
<A, B, X, E2>(
|
|
4756
|
+
filter: Filter.Filter<NoInfer<A>, B, X>,
|
|
4757
|
+
orFailWith: (x: X) => E2
|
|
4758
|
+
): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<B, E2 | E, R>
|
|
4759
|
+
<A, B, X>(
|
|
4760
|
+
filter: Filter.Filter<NoInfer<A>, B, X>
|
|
4761
|
+
): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<B, Cause.NoSuchElementError | E, R>
|
|
4762
|
+
<A, E, R, B, X, E2>(
|
|
4763
|
+
self: Effect.Effect<A, E, R>,
|
|
4764
|
+
filter: Filter.Filter<NoInfer<A>, B, X>,
|
|
4765
|
+
orFailWith: (x: X) => E2
|
|
4766
|
+
): Effect.Effect<B, E2 | E, R>
|
|
4767
|
+
<A, E, R, B, X>(
|
|
4768
|
+
self: Effect.Effect<A, E, R>,
|
|
4769
|
+
filter: Filter.Filter<NoInfer<A>, B, X>
|
|
4770
|
+
): Effect.Effect<B, Cause.NoSuchElementError | E, R>
|
|
4771
|
+
} = dual((args) => isEffect(args[0]), <A, E, R, B, X, E2>(
|
|
4772
|
+
self: Effect.Effect<A, E, R>,
|
|
4773
|
+
filter: Filter.Filter<NoInfer<A>, B, X>,
|
|
4774
|
+
orFailWith?: (x: X) => E2
|
|
4775
|
+
): Effect.Effect<B, E2 | Cause.NoSuchElementError | E, R> =>
|
|
4776
|
+
filterMapOrElse(
|
|
4777
|
+
self,
|
|
4778
|
+
filter,
|
|
4779
|
+
orFailWith ? (x: X) => fail(orFailWith(x)) : () => fail(new NoSuchElementError() as E2)
|
|
4780
|
+
))
|
|
4781
|
+
|
|
4280
4782
|
/** @internal */
|
|
4281
4783
|
export const filter: {
|
|
4282
4784
|
<A, B extends A>(
|
|
@@ -4285,13 +4787,6 @@ export const filter: {
|
|
|
4285
4787
|
<A>(
|
|
4286
4788
|
predicate: Predicate.Predicate<NoInfer<A>>
|
|
4287
4789
|
): (elements: Iterable<A>) => Effect.Effect<Array<A>>
|
|
4288
|
-
<A, B, X>(
|
|
4289
|
-
filter: Filter.Filter<NoInfer<A>, B, X>
|
|
4290
|
-
): (elements: Iterable<A>) => Effect.Effect<Array<B>>
|
|
4291
|
-
<A, B, X, E, R>(
|
|
4292
|
-
filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R>,
|
|
4293
|
-
options?: { readonly concurrency?: Concurrency | undefined }
|
|
4294
|
-
): (elements: Iterable<A>) => Effect.Effect<Array<B>, E, R>
|
|
4295
4790
|
<A, E, R>(
|
|
4296
4791
|
predicate: (a: NoInfer<A>, i: number) => Effect.Effect<boolean, E, R>,
|
|
4297
4792
|
options?: { readonly concurrency?: Concurrency | undefined }
|
|
@@ -4304,15 +4799,6 @@ export const filter: {
|
|
|
4304
4799
|
elements: Iterable<A>,
|
|
4305
4800
|
predicate: Predicate.Predicate<A>
|
|
4306
4801
|
): Effect.Effect<Array<A>>
|
|
4307
|
-
<A, B, X>(
|
|
4308
|
-
elements: Iterable<A>,
|
|
4309
|
-
filter: Filter.Filter<NoInfer<A>, B, X>
|
|
4310
|
-
): Effect.Effect<Array<B>>
|
|
4311
|
-
<A, B, X, E, R>(
|
|
4312
|
-
elements: Iterable<A>,
|
|
4313
|
-
filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R>,
|
|
4314
|
-
options?: { readonly concurrency?: Concurrency | undefined }
|
|
4315
|
-
): Effect.Effect<Array<B>, E, R>
|
|
4316
4802
|
<A, E, R>(
|
|
4317
4803
|
iterable: Iterable<A>,
|
|
4318
4804
|
predicate: (a: NoInfer<A>, i: number) => Effect.Effect<boolean, E, R>,
|
|
@@ -4320,36 +4806,27 @@ export const filter: {
|
|
|
4320
4806
|
): Effect.Effect<Array<A>, E, R>
|
|
4321
4807
|
} = dual(
|
|
4322
4808
|
(args) => isIterable(args[0]) && !isEffect(args[0]),
|
|
4323
|
-
<A,
|
|
4809
|
+
<A, E, R>(
|
|
4324
4810
|
elements: Iterable<A>,
|
|
4325
|
-
|
|
4326
|
-
| Filter.FilterEffect<A, B, X, E, R>
|
|
4811
|
+
predicate:
|
|
4327
4812
|
| Predicate.Predicate<A>
|
|
4328
4813
|
| ((a: A, i: number) => Effect.Effect<boolean, E, R>),
|
|
4329
4814
|
options?: { readonly concurrency?: Concurrency | undefined }
|
|
4330
|
-
): Effect.Effect<Array<
|
|
4815
|
+
): Effect.Effect<Array<A>, E, R> =>
|
|
4331
4816
|
suspend(() => {
|
|
4332
|
-
const out: Array<
|
|
4817
|
+
const out: Array<A> = []
|
|
4333
4818
|
return as(
|
|
4334
4819
|
forEach(
|
|
4335
4820
|
elements,
|
|
4336
4821
|
(a, i) => {
|
|
4337
|
-
const result = (
|
|
4822
|
+
const result = (predicate as Function)(a, i)
|
|
4338
4823
|
if (typeof result === "boolean") {
|
|
4339
4824
|
if (result) out.push(a)
|
|
4340
4825
|
return void_ as any
|
|
4341
4826
|
}
|
|
4342
|
-
|
|
4343
|
-
if (
|
|
4344
|
-
out.push(
|
|
4345
|
-
}
|
|
4346
|
-
return void_ as any
|
|
4347
|
-
}
|
|
4348
|
-
return map(result, (r: any) => {
|
|
4349
|
-
if (typeof r === "boolean") {
|
|
4350
|
-
if (r) out.push(a)
|
|
4351
|
-
} else if (!Result.isFailure(r)) {
|
|
4352
|
-
out.push(r.success)
|
|
4827
|
+
return map(result, (keep) => {
|
|
4828
|
+
if (keep) {
|
|
4829
|
+
out.push(a)
|
|
4353
4830
|
}
|
|
4354
4831
|
})
|
|
4355
4832
|
},
|
|
@@ -4363,6 +4840,72 @@ export const filter: {
|
|
|
4363
4840
|
})
|
|
4364
4841
|
)
|
|
4365
4842
|
|
|
4843
|
+
/** @internal */
|
|
4844
|
+
export const filterMap: {
|
|
4845
|
+
<A, B, X>(
|
|
4846
|
+
filter: Filter.Filter<NoInfer<A>, B, X>
|
|
4847
|
+
): (elements: Iterable<A>) => Effect.Effect<Array<B>>
|
|
4848
|
+
<A, B, X>(
|
|
4849
|
+
elements: Iterable<A>,
|
|
4850
|
+
filter: Filter.Filter<NoInfer<A>, B, X>
|
|
4851
|
+
): Effect.Effect<Array<B>>
|
|
4852
|
+
} = dual(
|
|
4853
|
+
(args) => isIterable(args[0]) && !isEffect(args[0]),
|
|
4854
|
+
<A, B, X>(
|
|
4855
|
+
elements: Iterable<A>,
|
|
4856
|
+
filter: Filter.Filter<A, B, X>
|
|
4857
|
+
): Effect.Effect<Array<B>> =>
|
|
4858
|
+
suspend(() => {
|
|
4859
|
+
const out: Array<B> = []
|
|
4860
|
+
for (const a of elements) {
|
|
4861
|
+
const result = filter(a)
|
|
4862
|
+
if (Result.isSuccess(result)) {
|
|
4863
|
+
out.push(result.success)
|
|
4864
|
+
}
|
|
4865
|
+
}
|
|
4866
|
+
return succeed(out)
|
|
4867
|
+
})
|
|
4868
|
+
)
|
|
4869
|
+
|
|
4870
|
+
/** @internal */
|
|
4871
|
+
export const filterMapEffect: {
|
|
4872
|
+
<A, B, X, E, R>(
|
|
4873
|
+
filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R>,
|
|
4874
|
+
options?: { readonly concurrency?: Concurrency | undefined }
|
|
4875
|
+
): (elements: Iterable<A>) => Effect.Effect<Array<B>, E, R>
|
|
4876
|
+
<A, B, X, E, R>(
|
|
4877
|
+
elements: Iterable<A>,
|
|
4878
|
+
filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R>,
|
|
4879
|
+
options?: { readonly concurrency?: Concurrency | undefined }
|
|
4880
|
+
): Effect.Effect<Array<B>, E, R>
|
|
4881
|
+
} = dual(
|
|
4882
|
+
(args) => isIterable(args[0]) && !isEffect(args[0]),
|
|
4883
|
+
<A, B, X, E, R>(
|
|
4884
|
+
elements: Iterable<A>,
|
|
4885
|
+
filter: Filter.FilterEffect<A, B, X, E, R>,
|
|
4886
|
+
options?: { readonly concurrency?: Concurrency | undefined }
|
|
4887
|
+
): Effect.Effect<Array<B>, E, R> =>
|
|
4888
|
+
suspend(() => {
|
|
4889
|
+
const out: Array<B> = []
|
|
4890
|
+
return as(
|
|
4891
|
+
forEach(
|
|
4892
|
+
elements,
|
|
4893
|
+
(a) =>
|
|
4894
|
+
map(filter(a), (result) => {
|
|
4895
|
+
if (Result.isSuccess(result)) {
|
|
4896
|
+
out.push(result.success)
|
|
4897
|
+
}
|
|
4898
|
+
}),
|
|
4899
|
+
{
|
|
4900
|
+
discard: true,
|
|
4901
|
+
concurrency: options?.concurrency
|
|
4902
|
+
}
|
|
4903
|
+
),
|
|
4904
|
+
out
|
|
4905
|
+
)
|
|
4906
|
+
})
|
|
4907
|
+
)
|
|
4908
|
+
|
|
4366
4909
|
// ----------------------------------------------------------------------------
|
|
4367
4910
|
// do notation
|
|
4368
4911
|
// ----------------------------------------------------------------------------
|
|
@@ -4463,13 +5006,13 @@ export const forkUnsafe = <FA, FE, A, E, R>(
|
|
|
4463
5006
|
immediate = false,
|
|
4464
5007
|
daemon = false,
|
|
4465
5008
|
uninterruptible: boolean | "inherit" = false
|
|
4466
|
-
):
|
|
5009
|
+
): FiberImpl<A, E> => {
|
|
4467
5010
|
const interruptible = uninterruptible === "inherit" ? parent.interruptible : !uninterruptible
|
|
4468
|
-
const child = new FiberImpl<A, E>(parent.
|
|
5011
|
+
const child = new FiberImpl<A, E>(parent.context, interruptible)
|
|
4469
5012
|
if (immediate) {
|
|
4470
5013
|
child.evaluate(effect as any)
|
|
4471
5014
|
} else {
|
|
4472
|
-
parent.
|
|
5015
|
+
parent.currentDispatcher.scheduleTask(() => child.evaluate(effect as any), 0)
|
|
4473
5016
|
}
|
|
4474
5017
|
if (!daemon && !child._exit) {
|
|
4475
5018
|
parent.children().add(child)
|
|
@@ -4589,7 +5132,8 @@ export const forkScoped: {
|
|
|
4589
5132
|
readonly startImmediately?: boolean | undefined
|
|
4590
5133
|
readonly uninterruptible?: boolean | "inherit" | undefined
|
|
4591
5134
|
} | undefined
|
|
4592
|
-
): [Arg] extends [Effect.Effect<infer _A, infer _E, infer _R>] ?
|
|
5135
|
+
): [Arg] extends [Effect.Effect<infer _A, infer _E, infer _R>] ?
|
|
5136
|
+
Effect.Effect<Fiber.Fiber<_A, _E>, never, _R | Scope.Scope>
|
|
4593
5137
|
: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<Fiber.Fiber<A, E>, never, R | Scope.Scope>
|
|
4594
5138
|
} = dual((args) => isEffect(args[0]), <A, E, R>(
|
|
4595
5139
|
self: Effect.Effect<A, E, R>,
|
|
@@ -4604,15 +5148,13 @@ export const forkScoped: {
|
|
|
4604
5148
|
// ----------------------------------------------------------------------------
|
|
4605
5149
|
|
|
4606
5150
|
/** @internal */
|
|
4607
|
-
export const runForkWith = <R>(
|
|
5151
|
+
export const runForkWith = <R>(context: Context.Context<R>) =>
|
|
4608
5152
|
<A, E>(
|
|
4609
5153
|
effect: Effect.Effect<A, E, R>,
|
|
4610
5154
|
options?: Effect.RunOptions | undefined
|
|
4611
5155
|
): Fiber.Fiber<A, E> => {
|
|
4612
|
-
const scheduler = options?.scheduler ||
|
|
4613
|
-
(!services.mapUnsafe.has(Scheduler.Scheduler.key) && new Scheduler.MixedScheduler())
|
|
4614
5156
|
const fiber = new FiberImpl<A, E>(
|
|
4615
|
-
scheduler ?
|
|
5157
|
+
options?.scheduler ? Context.add(context, Scheduler.Scheduler, options.scheduler) : context,
|
|
4616
5158
|
options?.uninterruptible !== true
|
|
4617
5159
|
)
|
|
4618
5160
|
fiber.evaluate(effect as any)
|
|
@@ -4627,6 +5169,9 @@ export const runForkWith = <R>(services: ServiceMap.ServiceMap<R>) =>
|
|
|
4627
5169
|
fiber.addObserver(() => options.signal!.removeEventListener("abort", abort))
|
|
4628
5170
|
}
|
|
4629
5171
|
}
|
|
5172
|
+
if (options?.onFiberStart) {
|
|
5173
|
+
options.onFiberStart(fiber)
|
|
5174
|
+
}
|
|
4630
5175
|
return fiber
|
|
4631
5176
|
}
|
|
4632
5177
|
|
|
@@ -4657,11 +5202,11 @@ export const fiberRunIn: {
|
|
|
4657
5202
|
export const runFork: <A, E>(
|
|
4658
5203
|
effect: Effect.Effect<A, E, never>,
|
|
4659
5204
|
options?: Effect.RunOptions | undefined
|
|
4660
|
-
) => Fiber.Fiber<A, E> = runForkWith(
|
|
5205
|
+
) => Fiber.Fiber<A, E> = runForkWith(Context.empty())
|
|
4661
5206
|
|
|
4662
5207
|
/** @internal */
|
|
4663
|
-
export const runCallbackWith = <R>(
|
|
4664
|
-
const runFork = runForkWith(
|
|
5208
|
+
export const runCallbackWith = <R>(context: Context.Context<R>) => {
|
|
5209
|
+
const runFork = runForkWith(context)
|
|
4665
5210
|
return <A, E>(
|
|
4666
5211
|
effect: Effect.Effect<A, E, R>,
|
|
4667
5212
|
options?:
|
|
@@ -4681,11 +5226,11 @@ export const runCallbackWith = <R>(services: ServiceMap.ServiceMap<R>) => {
|
|
|
4681
5226
|
}
|
|
4682
5227
|
|
|
4683
5228
|
/** @internal */
|
|
4684
|
-
export const runCallback = runCallbackWith(
|
|
5229
|
+
export const runCallback = runCallbackWith(Context.empty())
|
|
4685
5230
|
|
|
4686
5231
|
/** @internal */
|
|
4687
|
-
export const runPromiseExitWith = <R>(
|
|
4688
|
-
const runFork = runForkWith(
|
|
5232
|
+
export const runPromiseExitWith = <R>(context: Context.Context<R>) => {
|
|
5233
|
+
const runFork = runForkWith(context)
|
|
4689
5234
|
return <A, E>(
|
|
4690
5235
|
effect: Effect.Effect<A, E, R>,
|
|
4691
5236
|
options?: Effect.RunOptions | undefined
|
|
@@ -4698,11 +5243,11 @@ export const runPromiseExitWith = <R>(services: ServiceMap.ServiceMap<R>) => {
|
|
|
4698
5243
|
}
|
|
4699
5244
|
|
|
4700
5245
|
/** @internal */
|
|
4701
|
-
export const runPromiseExit = runPromiseExitWith(
|
|
5246
|
+
export const runPromiseExit = runPromiseExitWith(Context.empty())
|
|
4702
5247
|
|
|
4703
5248
|
/** @internal */
|
|
4704
|
-
export const runPromiseWith = <R>(
|
|
4705
|
-
const runPromiseExit = runPromiseExitWith(
|
|
5249
|
+
export const runPromiseWith = <R>(context: Context.Context<R>) => {
|
|
5250
|
+
const runPromiseExit = runPromiseExitWith(context)
|
|
4706
5251
|
return <A, E>(
|
|
4707
5252
|
effect: Effect.Effect<A, E, R>,
|
|
4708
5253
|
options?:
|
|
@@ -4723,28 +5268,28 @@ export const runPromise: <A, E>(
|
|
|
4723
5268
|
options?:
|
|
4724
5269
|
| Effect.RunOptions
|
|
4725
5270
|
| undefined
|
|
4726
|
-
) => Promise<A> = runPromiseWith(
|
|
5271
|
+
) => Promise<A> = runPromiseWith(Context.empty())
|
|
4727
5272
|
|
|
4728
5273
|
/** @internal */
|
|
4729
|
-
export const runSyncExitWith = <R>(
|
|
4730
|
-
const runFork = runForkWith(
|
|
5274
|
+
export const runSyncExitWith = <R>(context: Context.Context<R>) => {
|
|
5275
|
+
const runFork = runForkWith(context)
|
|
4731
5276
|
return <A, E>(effect: Effect.Effect<A, E, R>): Exit.Exit<A, E> => {
|
|
4732
5277
|
if (effectIsExit(effect)) return effect
|
|
4733
5278
|
const scheduler = new Scheduler.MixedScheduler("sync")
|
|
4734
5279
|
const fiber = runFork(effect, { scheduler })
|
|
4735
|
-
|
|
4736
|
-
return (fiber as FiberImpl<A, E>)._exit ?? exitDie(fiber)
|
|
5280
|
+
fiber.currentDispatcher?.flush()
|
|
5281
|
+
return (fiber as FiberImpl<A, E>)._exit ?? exitDie(new AsyncFiberError(fiber))
|
|
4737
5282
|
}
|
|
4738
5283
|
}
|
|
4739
5284
|
|
|
4740
5285
|
/** @internal */
|
|
4741
5286
|
export const runSyncExit: <A, E>(effect: Effect.Effect<A, E>) => Exit.Exit<A, E> = runSyncExitWith(
|
|
4742
|
-
|
|
5287
|
+
Context.empty()
|
|
4743
5288
|
)
|
|
4744
5289
|
|
|
4745
5290
|
/** @internal */
|
|
4746
|
-
export const runSyncWith = <R>(
|
|
4747
|
-
const runSyncExit = runSyncExitWith(
|
|
5291
|
+
export const runSyncWith = <R>(context: Context.Context<R>) => {
|
|
5292
|
+
const runSyncExit = runSyncExitWith(context)
|
|
4748
5293
|
return <A, E>(effect: Effect.Effect<A, E, R>): A => {
|
|
4749
5294
|
const exit = runSyncExit(effect)
|
|
4750
5295
|
if (exit._tag === "Failure") throw causeSquash(exit.cause)
|
|
@@ -4753,104 +5298,7 @@ export const runSyncWith = <R>(services: ServiceMap.ServiceMap<R>) => {
|
|
|
4753
5298
|
}
|
|
4754
5299
|
|
|
4755
5300
|
/** @internal */
|
|
4756
|
-
export const runSync: <A, E>(effect: Effect.Effect<A, E>) => A = runSyncWith(
|
|
4757
|
-
|
|
4758
|
-
// ----------------------------------------------------------------------------
|
|
4759
|
-
// Semaphore
|
|
4760
|
-
// ----------------------------------------------------------------------------
|
|
4761
|
-
|
|
4762
|
-
/** @internal */
|
|
4763
|
-
class Semaphore {
|
|
4764
|
-
public waiters = new Set<() => void>()
|
|
4765
|
-
public taken = 0
|
|
4766
|
-
public permits: number
|
|
4767
|
-
|
|
4768
|
-
constructor(permits: number) {
|
|
4769
|
-
this.permits = permits
|
|
4770
|
-
}
|
|
4771
|
-
|
|
4772
|
-
get free() {
|
|
4773
|
-
return this.permits - this.taken
|
|
4774
|
-
}
|
|
4775
|
-
|
|
4776
|
-
readonly take = (n: number): Effect.Effect<number> =>
|
|
4777
|
-
callback<number>((resume) => {
|
|
4778
|
-
if (this.free < n) {
|
|
4779
|
-
const observer = () => {
|
|
4780
|
-
if (this.free < n) {
|
|
4781
|
-
return
|
|
4782
|
-
}
|
|
4783
|
-
this.waiters.delete(observer)
|
|
4784
|
-
this.taken += n
|
|
4785
|
-
resume(succeed(n))
|
|
4786
|
-
}
|
|
4787
|
-
this.waiters.add(observer)
|
|
4788
|
-
return sync(() => {
|
|
4789
|
-
this.waiters.delete(observer)
|
|
4790
|
-
})
|
|
4791
|
-
}
|
|
4792
|
-
this.taken += n
|
|
4793
|
-
return resume(succeed(n))
|
|
4794
|
-
})
|
|
4795
|
-
|
|
4796
|
-
updateTakenUnsafe(fiber: Fiber.Fiber<any, any>, f: (n: number) => number): Effect.Effect<number> {
|
|
4797
|
-
this.taken = f(this.taken)
|
|
4798
|
-
if (this.waiters.size > 0) {
|
|
4799
|
-
fiber.currentScheduler.scheduleTask(() => {
|
|
4800
|
-
const iter = this.waiters.values()
|
|
4801
|
-
let item = iter.next()
|
|
4802
|
-
while (item.done === false && this.free > 0) {
|
|
4803
|
-
item.value()
|
|
4804
|
-
item = iter.next()
|
|
4805
|
-
}
|
|
4806
|
-
}, 0)
|
|
4807
|
-
}
|
|
4808
|
-
return succeed(this.free)
|
|
4809
|
-
}
|
|
4810
|
-
|
|
4811
|
-
updateTaken(f: (n: number) => number): Effect.Effect<number> {
|
|
4812
|
-
return withFiber((fiber) => this.updateTakenUnsafe(fiber, f))
|
|
4813
|
-
}
|
|
4814
|
-
|
|
4815
|
-
readonly resize = (permits: number) =>
|
|
4816
|
-
asVoid(
|
|
4817
|
-
withFiber((fiber) => {
|
|
4818
|
-
this.permits = permits
|
|
4819
|
-
if (this.free < 0) {
|
|
4820
|
-
return void_
|
|
4821
|
-
}
|
|
4822
|
-
return this.updateTakenUnsafe(fiber, (taken) => taken)
|
|
4823
|
-
})
|
|
4824
|
-
)
|
|
4825
|
-
|
|
4826
|
-
readonly release = (n: number): Effect.Effect<number> => this.updateTaken((taken) => taken - n)
|
|
4827
|
-
|
|
4828
|
-
readonly releaseAll: Effect.Effect<number> = this.updateTaken((_) => 0)
|
|
4829
|
-
|
|
4830
|
-
readonly withPermits = (n: number) => <A, E, R>(self: Effect.Effect<A, E, R>) =>
|
|
4831
|
-
uninterruptibleMask((restore) =>
|
|
4832
|
-
flatMap(restore(this.take(n)), (permits) => ensuring(restore(self), this.release(permits)))
|
|
4833
|
-
)
|
|
4834
|
-
|
|
4835
|
-
readonly withPermit = this.withPermits(1)
|
|
4836
|
-
|
|
4837
|
-
readonly withPermitsIfAvailable = (n: number) => <A, E, R>(self: Effect.Effect<A, E, R>) =>
|
|
4838
|
-
uninterruptibleMask((restore) =>
|
|
4839
|
-
suspend(() => {
|
|
4840
|
-
if (this.free < n) {
|
|
4841
|
-
return succeedNone
|
|
4842
|
-
}
|
|
4843
|
-
this.taken += n
|
|
4844
|
-
return ensuring(restore(asSome(self)), this.release(n))
|
|
4845
|
-
})
|
|
4846
|
-
)
|
|
4847
|
-
}
|
|
4848
|
-
|
|
4849
|
-
/** @internal */
|
|
4850
|
-
export const makeSemaphoreUnsafe = (permits: number): Semaphore => new Semaphore(permits)
|
|
4851
|
-
|
|
4852
|
-
/** @internal */
|
|
4853
|
-
export const makeSemaphore = (permits: number) => sync(() => makeSemaphoreUnsafe(permits))
|
|
5301
|
+
export const runSync: <A, E>(effect: Effect.Effect<A, E>) => A = runSyncWith(Context.empty())
|
|
4854
5302
|
|
|
4855
5303
|
const succeedTrue = succeed(true)
|
|
4856
5304
|
const succeedFalse = succeed(false)
|
|
@@ -4869,7 +5317,7 @@ class Latch implements _Latch.Latch {
|
|
|
4869
5317
|
return succeedTrue
|
|
4870
5318
|
}
|
|
4871
5319
|
this.scheduled = true
|
|
4872
|
-
fiber.
|
|
5320
|
+
fiber.currentDispatcher.scheduleTask(this.flushWaiters, 0)
|
|
4873
5321
|
return succeedTrue
|
|
4874
5322
|
}
|
|
4875
5323
|
private flushWaiters = () => {
|
|
@@ -4886,7 +5334,7 @@ class Latch implements _Latch.Latch {
|
|
|
4886
5334
|
this.isOpen = true
|
|
4887
5335
|
return this.scheduleUnsafe(fiber)
|
|
4888
5336
|
})
|
|
4889
|
-
release = withFiber<boolean>((fiber) => this.
|
|
5337
|
+
release = withFiber<boolean>((fiber) => this.isOpen ? succeedFalse : this.scheduleUnsafe(fiber))
|
|
4890
5338
|
openUnsafe() {
|
|
4891
5339
|
if (this.isOpen) return false
|
|
4892
5340
|
this.isOpen = true
|
|
@@ -4911,7 +5359,7 @@ class Latch implements _Latch.Latch {
|
|
|
4911
5359
|
return true
|
|
4912
5360
|
}
|
|
4913
5361
|
close = sync(() => this.closeUnsafe())
|
|
4914
|
-
whenOpen = <A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> =>
|
|
5362
|
+
whenOpen = <A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> => flatMap(this.await, () => self)
|
|
4915
5363
|
}
|
|
4916
5364
|
|
|
4917
5365
|
/** @internal */
|
|
@@ -4974,16 +5422,15 @@ const NoopSpanProto: Omit<Tracer.Span, "parent" | "name" | "annotations" | "leve
|
|
|
4974
5422
|
/** @internal */
|
|
4975
5423
|
export const noopSpan = (options: {
|
|
4976
5424
|
readonly name: string
|
|
4977
|
-
readonly parent: Tracer.AnySpan
|
|
4978
|
-
readonly annotations:
|
|
5425
|
+
readonly parent: Option.Option<Tracer.AnySpan>
|
|
5426
|
+
readonly annotations: Context.Context<never>
|
|
4979
5427
|
}): Tracer.Span => Object.assign(Object.create(NoopSpanProto), options)
|
|
4980
5428
|
|
|
4981
|
-
const filterDisablePropagation = (span: Tracer.AnySpan | undefined): Tracer.AnySpan
|
|
4982
|
-
if (span)
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
}
|
|
5429
|
+
const filterDisablePropagation = (span: Tracer.AnySpan | undefined): Option.Option<Tracer.AnySpan> => {
|
|
5430
|
+
if (!span) return Option.none()
|
|
5431
|
+
return Context.get(span.annotations, Tracer.DisablePropagation)
|
|
5432
|
+
? span._tag === "Span" ? filterDisablePropagation(Option.getOrUndefined(span.parent)) : Option.none()
|
|
5433
|
+
: Option.some(span)
|
|
4987
5434
|
}
|
|
4988
5435
|
|
|
4989
5436
|
/** @internal */
|
|
@@ -4993,8 +5440,12 @@ export const makeSpanUnsafe = <XA, XE>(
|
|
|
4993
5440
|
options: Tracer.SpanOptionsNoTrace | undefined
|
|
4994
5441
|
) => {
|
|
4995
5442
|
const disablePropagation = !fiber.getRef(TracerEnabled) ||
|
|
4996
|
-
(options?.annotations &&
|
|
4997
|
-
const parent = options?.parent
|
|
5443
|
+
(options?.annotations && Context.get(options.annotations, Tracer.DisablePropagation))
|
|
5444
|
+
const parent = options?.parent !== undefined
|
|
5445
|
+
? Option.some(options.parent)
|
|
5446
|
+
: options?.root
|
|
5447
|
+
? Option.none<Tracer.AnySpan>()
|
|
5448
|
+
: filterDisablePropagation(fiber.currentSpan)
|
|
4998
5449
|
|
|
4999
5450
|
let span: Tracer.Span
|
|
5000
5451
|
|
|
@@ -5002,8 +5453,8 @@ export const makeSpanUnsafe = <XA, XE>(
|
|
|
5002
5453
|
span = noopSpan({
|
|
5003
5454
|
name,
|
|
5004
5455
|
parent,
|
|
5005
|
-
annotations:
|
|
5006
|
-
options?.annotations ??
|
|
5456
|
+
annotations: Context.add(
|
|
5457
|
+
options?.annotations ?? Context.empty(),
|
|
5007
5458
|
Tracer.DisablePropagation,
|
|
5008
5459
|
true
|
|
5009
5460
|
)
|
|
@@ -5023,13 +5474,13 @@ export const makeSpanUnsafe = <XA, XE>(
|
|
|
5023
5474
|
span = tracer.span({
|
|
5024
5475
|
name,
|
|
5025
5476
|
parent,
|
|
5026
|
-
annotations: options?.annotations ??
|
|
5477
|
+
annotations: options?.annotations ?? Context.empty(),
|
|
5027
5478
|
links,
|
|
5028
|
-
startTime: timingEnabled ? clock.currentTimeNanosUnsafe() :
|
|
5479
|
+
startTime: timingEnabled ? clock.currentTimeNanosUnsafe() : BigInt(0),
|
|
5029
5480
|
kind: options?.kind ?? "internal",
|
|
5030
|
-
root: options?.root ??
|
|
5481
|
+
root: options?.root ?? Option.isNone(parent),
|
|
5031
5482
|
sampled: options?.sampled ??
|
|
5032
|
-
(parent
|
|
5483
|
+
(Option.isSome(parent) && parent.value.sampled === false
|
|
5033
5484
|
? false
|
|
5034
5485
|
: !isLogLevelGreaterThan(fiber.getRef(Tracer.MinimumTraceLevel), level))
|
|
5035
5486
|
})
|
|
@@ -5060,7 +5511,7 @@ export const makeSpanScoped = (
|
|
|
5060
5511
|
): Effect.Effect<Tracer.Span, never, Scope.Scope> =>
|
|
5061
5512
|
uninterruptible(
|
|
5062
5513
|
withFiber((fiber) => {
|
|
5063
|
-
const scope =
|
|
5514
|
+
const scope = Context.getUnsafe(fiber.context, scopeTag)
|
|
5064
5515
|
const span = makeSpanUnsafe(fiber, name, options ?? {})
|
|
5065
5516
|
const clock = fiber.getRef(ClockRef)
|
|
5066
5517
|
const timingEnabled = fiber.getRef(TracerTimingEnabled)
|
|
@@ -5292,7 +5743,7 @@ export const currentParentSpan: Effect.Effect<Tracer.AnySpan, Cause.NoSuchElemen
|
|
|
5292
5743
|
// ----------------------------------------------------------------------------
|
|
5293
5744
|
|
|
5294
5745
|
/** @internal */
|
|
5295
|
-
export const ClockRef =
|
|
5746
|
+
export const ClockRef = Context.Reference<Clock.Clock>("effect/Clock", {
|
|
5296
5747
|
defaultValue: (): Clock.Clock => new ClockImpl()
|
|
5297
5748
|
})
|
|
5298
5749
|
|
|
@@ -5345,8 +5796,8 @@ export const clockWith = <A, E, R>(f: (clock: Clock.Clock) => Effect.Effect<A, E
|
|
|
5345
5796
|
withFiber((fiber) => f(fiber.getRef(ClockRef)))
|
|
5346
5797
|
|
|
5347
5798
|
/** @internal */
|
|
5348
|
-
export const sleep = (duration: Duration.
|
|
5349
|
-
clockWith((clock) => clock.sleep(Duration.
|
|
5799
|
+
export const sleep = (duration: Duration.Input): Effect.Effect<void> =>
|
|
5800
|
+
clockWith((clock) => clock.sleep(Duration.fromInputUnsafe(duration)))
|
|
5350
5801
|
|
|
5351
5802
|
/** @internal */
|
|
5352
5803
|
export const currentTimeMillis: Effect.Effect<number> = clockWith((clock) => clock.currentTimeMillis)
|
|
@@ -5404,6 +5855,28 @@ export class ExceededCapacityError extends TaggedError("ExceededCapacityError")
|
|
|
5404
5855
|
}
|
|
5405
5856
|
}
|
|
5406
5857
|
|
|
5858
|
+
/** @internal */
|
|
5859
|
+
export const AsyncFiberErrorTypeId = "~effect/Cause/AsyncFiberError"
|
|
5860
|
+
|
|
5861
|
+
/** @internal */
|
|
5862
|
+
export const isAsyncFiberError = (
|
|
5863
|
+
u: unknown
|
|
5864
|
+
): u is Cause.AsyncFiberError => hasProperty(u, AsyncFiberErrorTypeId)
|
|
5865
|
+
|
|
5866
|
+
/** @internal */
|
|
5867
|
+
export class AsyncFiberError extends TaggedError("AsyncFiberError")<{
|
|
5868
|
+
fiber: Fiber.Fiber<unknown, unknown>
|
|
5869
|
+
message: string
|
|
5870
|
+
}> {
|
|
5871
|
+
readonly [AsyncFiberErrorTypeId] = AsyncFiberErrorTypeId
|
|
5872
|
+
constructor(fiber: Fiber.Fiber<unknown, unknown>) {
|
|
5873
|
+
super({
|
|
5874
|
+
message: "An asynchronous Effect was executed with Effect.runSync",
|
|
5875
|
+
fiber
|
|
5876
|
+
})
|
|
5877
|
+
}
|
|
5878
|
+
}
|
|
5879
|
+
|
|
5407
5880
|
/** @internal */
|
|
5408
5881
|
export const UnknownErrorTypeId = "~effect/Cause/UnknownError"
|
|
5409
5882
|
|
|
@@ -5413,7 +5886,10 @@ export const isUnknownError = (
|
|
|
5413
5886
|
): u is Cause.UnknownError => hasProperty(u, UnknownErrorTypeId)
|
|
5414
5887
|
|
|
5415
5888
|
/** @internal */
|
|
5416
|
-
export class UnknownError extends TaggedError("UnknownError")
|
|
5889
|
+
export class UnknownError extends TaggedError("UnknownError")<{
|
|
5890
|
+
cause: unknown
|
|
5891
|
+
message?: string | undefined
|
|
5892
|
+
}> {
|
|
5417
5893
|
readonly [UnknownErrorTypeId] = UnknownErrorTypeId
|
|
5418
5894
|
constructor(cause: unknown, message?: string) {
|
|
5419
5895
|
super({ message, cause } as any)
|
|
@@ -5425,7 +5901,7 @@ export class UnknownError extends TaggedError("UnknownError") {
|
|
|
5425
5901
|
// ----------------------------------------------------------------------------
|
|
5426
5902
|
|
|
5427
5903
|
/** @internal */
|
|
5428
|
-
export const ConsoleRef =
|
|
5904
|
+
export const ConsoleRef = Context.Reference<Console.Console>(
|
|
5429
5905
|
"effect/Console/CurrentConsole",
|
|
5430
5906
|
{ defaultValue: (): Console.Console => globalThis.console }
|
|
5431
5907
|
)
|
|
@@ -5467,17 +5943,51 @@ export const isLogLevelGreaterThan = Order.isGreaterThan(LogLevelOrder)
|
|
|
5467
5943
|
// ----------------------------------------------------------------------------
|
|
5468
5944
|
|
|
5469
5945
|
/** @internal */
|
|
5470
|
-
export const CurrentLoggers =
|
|
5946
|
+
export const CurrentLoggers = Context.Reference<
|
|
5471
5947
|
ReadonlySet<Logger.Logger<unknown, any>>
|
|
5472
5948
|
>("effect/Loggers/CurrentLoggers", {
|
|
5473
5949
|
defaultValue: () => new Set([defaultLogger, tracerLogger])
|
|
5474
5950
|
})
|
|
5475
5951
|
|
|
5476
5952
|
/** @internal */
|
|
5477
|
-
export const LogToStderr =
|
|
5953
|
+
export const LogToStderr = Context.Reference<boolean>("effect/Logger/LogToStderr", {
|
|
5478
5954
|
defaultValue: constFalse
|
|
5479
5955
|
})
|
|
5480
5956
|
|
|
5957
|
+
/** @internal */
|
|
5958
|
+
export const annotateLogsScoped: {
|
|
5959
|
+
(key: string, value: unknown): Effect.Effect<void, never, Scope.Scope>
|
|
5960
|
+
(values: Record<string, unknown>): Effect.Effect<void, never, Scope.Scope>
|
|
5961
|
+
} = function() {
|
|
5962
|
+
const entries = typeof arguments[0] === "string" ?
|
|
5963
|
+
[[arguments[0], arguments[1]]] :
|
|
5964
|
+
Object.entries(arguments[0])
|
|
5965
|
+
return uninterruptible(withFiber((fiber) => {
|
|
5966
|
+
const prev = fiber.getRef(CurrentLogAnnotations)
|
|
5967
|
+
const next = { ...prev }
|
|
5968
|
+
for (let i = 0; i < entries.length; i++) {
|
|
5969
|
+
const [key, value] = entries[i]
|
|
5970
|
+
next[key] = value
|
|
5971
|
+
}
|
|
5972
|
+
fiber.setContext(Context.add(fiber.context, CurrentLogAnnotations, next))
|
|
5973
|
+
return scopeAddFinalizerExit(Context.getUnsafe(fiber.context, scopeTag), (_) => {
|
|
5974
|
+
const current = fiber.getRef(CurrentLogAnnotations)
|
|
5975
|
+
const next = { ...current }
|
|
5976
|
+
for (let i = 0; i < entries.length; i++) {
|
|
5977
|
+
const [key, value] = entries[i]
|
|
5978
|
+
if (current[key] !== value) continue
|
|
5979
|
+
if (key in prev) {
|
|
5980
|
+
next[key] = prev[key]
|
|
5981
|
+
} else {
|
|
5982
|
+
delete next[key]
|
|
5983
|
+
}
|
|
5984
|
+
}
|
|
5985
|
+
fiber.setContext(Context.add(fiber.context, CurrentLogAnnotations, next))
|
|
5986
|
+
return void_
|
|
5987
|
+
})
|
|
5988
|
+
}))
|
|
5989
|
+
}
|
|
5990
|
+
|
|
5481
5991
|
/** @internal */
|
|
5482
5992
|
export const LoggerTypeId = "~effect/Logger"
|
|
5483
5993
|
|
|
@@ -5493,7 +6003,7 @@ const LoggerProto = {
|
|
|
5493
6003
|
|
|
5494
6004
|
/** @internal */
|
|
5495
6005
|
export const loggerMake = <Message, Output>(
|
|
5496
|
-
log: (options: Logger.
|
|
6006
|
+
log: (options: Logger.Options<Message>) => Output
|
|
5497
6007
|
): Logger.Logger<Message, Output> => {
|
|
5498
6008
|
const self = Object.create(LoggerProto)
|
|
5499
6009
|
self.log = log
|
|
@@ -5533,7 +6043,7 @@ export const structuredMessage = (u: unknown): unknown => {
|
|
|
5533
6043
|
}
|
|
5534
6044
|
|
|
5535
6045
|
/** @internal */
|
|
5536
|
-
export const logWithLevel = (level?: LogLevel.
|
|
6046
|
+
export const logWithLevel = (level?: LogLevel.Severity) =>
|
|
5537
6047
|
(
|
|
5538
6048
|
...message: ReadonlyArray<any>
|
|
5539
6049
|
): Effect.Effect<void> => {
|
|
@@ -5652,10 +6162,11 @@ const prettyLoggerTty = (options: {
|
|
|
5652
6162
|
readonly formatDate: (date: Date) => string
|
|
5653
6163
|
}) => {
|
|
5654
6164
|
const processIsBun = typeof process === "object" && "isBun" in process && process.isBun === true
|
|
5655
|
-
const color = options.colors
|
|
6165
|
+
const color = options.colors ? withColor : withColorNoop
|
|
5656
6166
|
return loggerMake<unknown, void>(
|
|
5657
6167
|
({ cause, date, fiber, logLevel, message: message_ }) => {
|
|
5658
6168
|
const console = fiber.getRef(ConsoleRef)
|
|
6169
|
+
// oxlint-disable-next-line no-console
|
|
5659
6170
|
const log = fiber.getRef(LogToStderr) ? console.error : console.log
|
|
5660
6171
|
|
|
5661
6172
|
const message = Array.isArray(message_) ? message_.slice() : [message_]
|
|
@@ -5681,6 +6192,7 @@ const prettyLoggerTty = (options: {
|
|
|
5681
6192
|
}
|
|
5682
6193
|
|
|
5683
6194
|
log(firstLine)
|
|
6195
|
+
// oxlint-disable-next-line no-console
|
|
5684
6196
|
if (!processIsBun) console.group()
|
|
5685
6197
|
|
|
5686
6198
|
if (cause.reasons.length > 0) {
|
|
@@ -5698,6 +6210,7 @@ const prettyLoggerTty = (options: {
|
|
|
5698
6210
|
log(color(`${key}:`, colors.bold, colors.white), redact(value))
|
|
5699
6211
|
}
|
|
5700
6212
|
|
|
6213
|
+
// oxlint-disable-next-line no-console
|
|
5701
6214
|
if (!processIsBun) console.groupEnd()
|
|
5702
6215
|
}
|
|
5703
6216
|
)
|
|
@@ -5744,14 +6257,17 @@ const prettyLoggerBrowser = (options: {
|
|
|
5744
6257
|
}
|
|
5745
6258
|
}
|
|
5746
6259
|
|
|
6260
|
+
// oxlint-disable-next-line no-console
|
|
5747
6261
|
console.groupCollapsed(firstLine, ...firstParams)
|
|
5748
6262
|
|
|
5749
6263
|
if (cause.reasons.length > 0) {
|
|
6264
|
+
// oxlint-disable-next-line no-console
|
|
5750
6265
|
console.error(causePretty(cause))
|
|
5751
6266
|
}
|
|
5752
6267
|
|
|
5753
6268
|
if (messageIndex < message.length) {
|
|
5754
6269
|
for (; messageIndex < message.length; messageIndex++) {
|
|
6270
|
+
// oxlint-disable-next-line no-console
|
|
5755
6271
|
console.log(redact(message[messageIndex]))
|
|
5756
6272
|
}
|
|
5757
6273
|
}
|
|
@@ -5760,12 +6276,15 @@ const prettyLoggerBrowser = (options: {
|
|
|
5760
6276
|
for (const [key, value] of Object.entries(annotations)) {
|
|
5761
6277
|
const redacted = redact(value)
|
|
5762
6278
|
if (options.colors) {
|
|
6279
|
+
// oxlint-disable-next-line no-console
|
|
5763
6280
|
console.log(`%c${key}:`, "color:gray", redacted)
|
|
5764
6281
|
} else {
|
|
6282
|
+
// oxlint-disable-next-line no-console
|
|
5765
6283
|
console.log(`${key}:`, redacted)
|
|
5766
6284
|
}
|
|
5767
6285
|
}
|
|
5768
6286
|
|
|
6287
|
+
// oxlint-disable-next-line no-console
|
|
5769
6288
|
console.groupEnd()
|
|
5770
6289
|
}
|
|
5771
6290
|
)
|
|
@@ -5775,7 +6294,7 @@ const prettyLoggerBrowser = (options: {
|
|
|
5775
6294
|
export const defaultLogger = loggerMake<unknown, void>(({ cause, date, fiber, logLevel, message }) => {
|
|
5776
6295
|
const message_ = Array.isArray(message) ? message.slice() : [message]
|
|
5777
6296
|
if (cause.reasons.length > 0) {
|
|
5778
|
-
message_.
|
|
6297
|
+
message_.push(causePretty(cause))
|
|
5779
6298
|
}
|
|
5780
6299
|
const now = date.getTime()
|
|
5781
6300
|
const spans = fiber.getRef(CurrentLogSpans)
|
|
@@ -5788,6 +6307,7 @@ export const defaultLogger = loggerMake<unknown, void>(({ cause, date, fiber, lo
|
|
|
5788
6307
|
message_.push(annotations)
|
|
5789
6308
|
}
|
|
5790
6309
|
const console = fiber.getRef(ConsoleRef)
|
|
6310
|
+
// oxlint-disable-next-line no-console
|
|
5791
6311
|
const log = fiber.getRef(LogToStderr) ? console.error : console.log
|
|
5792
6312
|
log(`[${defaultDateFormat(date)}] ${logLevel.toUpperCase()} (#${fiber.id})${spanString}:`, ...message_)
|
|
5793
6313
|
})
|
|
@@ -5824,3 +6344,48 @@ const undefined_ = succeed(undefined)
|
|
|
5824
6344
|
|
|
5825
6345
|
/** @internal */
|
|
5826
6346
|
export { undefined_ as undefined }
|
|
6347
|
+
|
|
6348
|
+
// ----------------------------------------------------------------------------
|
|
6349
|
+
// ErrorReporter
|
|
6350
|
+
// ----------------------------------------------------------------------------
|
|
6351
|
+
|
|
6352
|
+
/** @internal */
|
|
6353
|
+
export const withErrorReporting: <
|
|
6354
|
+
Arg extends Effect.Effect<any, any, any> | {
|
|
6355
|
+
readonly defectsOnly?: boolean | undefined
|
|
6356
|
+
} | undefined = {
|
|
6357
|
+
readonly defectsOnly?: boolean | undefined
|
|
6358
|
+
}
|
|
6359
|
+
>(
|
|
6360
|
+
effectOrOptions: Arg,
|
|
6361
|
+
options?: {
|
|
6362
|
+
readonly defectsOnly?: boolean | undefined
|
|
6363
|
+
} | undefined
|
|
6364
|
+
) => [Arg] extends [Effect.Effect<infer _A, infer _E, infer _R>] ? Arg
|
|
6365
|
+
: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R> = dual(
|
|
6366
|
+
(args) => isEffect(args[0]),
|
|
6367
|
+
<A, E, R>(
|
|
6368
|
+
self: Effect.Effect<A, E, R>,
|
|
6369
|
+
options?: {
|
|
6370
|
+
readonly defectsOnly?: boolean | undefined
|
|
6371
|
+
} | undefined
|
|
6372
|
+
): Effect.Effect<A, E, R> =>
|
|
6373
|
+
onError(self, (cause) =>
|
|
6374
|
+
withFiber((fiber) => {
|
|
6375
|
+
reportCauseUnsafe(fiber, cause, options?.defectsOnly)
|
|
6376
|
+
return void_
|
|
6377
|
+
}))
|
|
6378
|
+
)
|
|
6379
|
+
|
|
6380
|
+
/** @internal */
|
|
6381
|
+
export const reportCauseUnsafe = (
|
|
6382
|
+
fiber: Fiber.Fiber<unknown, unknown>,
|
|
6383
|
+
cause: Cause.Cause<unknown>,
|
|
6384
|
+
defectsOnly?: boolean
|
|
6385
|
+
) => {
|
|
6386
|
+
const reporters = fiber.getRef(CurrentErrorReporters)
|
|
6387
|
+
if (reporters.size === 0) return
|
|
6388
|
+
if (defectsOnly && !hasDies(cause)) return
|
|
6389
|
+
const opts = { cause, fiber, timestamp: fiber.getRef(ClockRef).currentTimeNanosUnsafe() }
|
|
6390
|
+
reporters.forEach((reporter) => reporter.report(opts))
|
|
6391
|
+
}
|