effect 4.0.0-beta.4 → 4.0.0-beta.40
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 +46 -45
- package/dist/BigDecimal.d.ts.map +1 -1
- package/dist/BigDecimal.js +35 -38
- 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 +32 -29
- package/dist/BigInt.js.map +1 -1
- package/dist/Brand.d.ts +1 -1
- 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 +2 -2
- package/dist/Cache.d.ts.map +1 -1
- package/dist/Cache.js +6 -5
- package/dist/Cache.js.map +1 -1
- package/dist/Cause.d.ts +33 -2
- package/dist/Cause.d.ts.map +1 -1
- package/dist/Cause.js +19 -0
- package/dist/Cause.js.map +1 -1
- package/dist/Channel.d.ts +130 -35
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +96 -45
- 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/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 +169 -9
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +69 -11
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.d.ts +1 -1
- 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 +535 -366
- package/dist/Data.d.ts.map +1 -1
- package/dist/Data.js +132 -79
- package/dist/Data.js.map +1 -1
- package/dist/DateTime.d.ts +72 -253
- package/dist/DateTime.d.ts.map +1 -1
- package/dist/DateTime.js +15 -60
- package/dist/DateTime.js.map +1 -1
- package/dist/Deferred.d.ts +7 -5
- package/dist/Deferred.d.ts.map +1 -1
- package/dist/Deferred.js +7 -5
- package/dist/Deferred.js.map +1 -1
- package/dist/Duration.d.ts +62 -32
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +108 -78
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts +1224 -951
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +398 -338
- package/dist/Effect.js.map +1 -1
- package/dist/Encoding.d.ts +194 -0
- package/dist/Encoding.d.ts.map +1 -0
- package/dist/Encoding.js +352 -0
- package/dist/Encoding.js.map +1 -0
- package/dist/Equal.d.ts +276 -109
- package/dist/Equal.d.ts.map +1 -1
- package/dist/Equal.js +124 -48
- package/dist/Equal.js.map +1 -1
- package/dist/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/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 +5 -3
- package/dist/Fiber.d.ts.map +1 -1
- package/dist/Fiber.js.map +1 -1
- package/dist/FiberHandle.d.ts +9 -8
- package/dist/FiberHandle.d.ts.map +1 -1
- package/dist/FiberHandle.js +8 -7
- package/dist/FiberHandle.js.map +1 -1
- package/dist/FiberMap.d.ts +20 -19
- package/dist/FiberMap.d.ts.map +1 -1
- package/dist/FiberMap.js +6 -6
- package/dist/FiberMap.js.map +1 -1
- package/dist/FileSystem.d.ts +18 -17
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js +17 -13
- package/dist/FileSystem.js.map +1 -1
- package/dist/Filter.d.ts +34 -38
- package/dist/Filter.d.ts.map +1 -1
- package/dist/Filter.js +15 -13
- package/dist/Filter.js.map +1 -1
- package/dist/Formatter.d.ts +131 -47
- package/dist/Formatter.d.ts.map +1 -1
- package/dist/Formatter.js +229 -51
- package/dist/Formatter.js.map +1 -1
- package/dist/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 +60 -62
- package/dist/Graph.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/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 +175 -0
- package/dist/Latch.d.ts.map +1 -0
- package/dist/Latch.js +130 -0
- package/dist/Latch.js.map +1 -0
- package/dist/Layer.d.ts +306 -129
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +92 -47
- package/dist/Layer.js.map +1 -1
- package/dist/LayerMap.d.ts +9 -8
- package/dist/LayerMap.d.ts.map +1 -1
- package/dist/LayerMap.js +3 -3
- 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 +29 -95
- package/dist/Logger.d.ts.map +1 -1
- package/dist/Logger.js +2 -3
- package/dist/Logger.js.map +1 -1
- package/dist/ManagedRuntime.d.ts +2 -2
- package/dist/ManagedRuntime.js +2 -2
- package/dist/Metric.d.ts +4 -6
- package/dist/Metric.d.ts.map +1 -1
- package/dist/Metric.js +3 -5
- 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/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 +34 -15
- 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 +146 -15
- package/dist/PartitionedSemaphore.d.ts.map +1 -1
- package/dist/PartitionedSemaphore.js +174 -61
- package/dist/PartitionedSemaphore.js.map +1 -1
- package/dist/Pipeable.d.ts +17 -0
- package/dist/Pipeable.d.ts.map +1 -1
- package/dist/Pipeable.js +19 -1
- package/dist/Pipeable.js.map +1 -1
- package/dist/PlatformError.d.ts +10 -9
- package/dist/PlatformError.d.ts.map +1 -1
- package/dist/PlatformError.js +2 -2
- package/dist/PlatformError.js.map +1 -1
- package/dist/Pool.d.ts +6 -4
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +7 -5
- package/dist/Pool.js.map +1 -1
- package/dist/PubSub.d.ts +8 -6
- package/dist/PubSub.d.ts.map +1 -1
- package/dist/PubSub.js +18 -10
- 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 +35 -1
- package/dist/Random.d.ts.map +1 -1
- package/dist/Random.js +46 -12
- package/dist/Random.js.map +1 -1
- package/dist/RcMap.d.ts +2 -2
- package/dist/RcMap.d.ts.map +1 -1
- package/dist/RcMap.js +1 -1
- package/dist/RcMap.js.map +1 -1
- package/dist/RcRef.d.ts +1 -1
- package/dist/RcRef.d.ts.map +1 -1
- package/dist/Record.d.ts +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/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 +242 -226
- package/dist/References.d.ts.map +1 -1
- package/dist/References.js +240 -247
- package/dist/References.js.map +1 -1
- package/dist/Request.d.ts +1 -1
- package/dist/Request.d.ts.map +1 -1
- package/dist/Request.js +2 -1
- package/dist/Request.js.map +1 -1
- package/dist/RequestResolver.d.ts +25 -45
- package/dist/RequestResolver.d.ts.map +1 -1
- package/dist/RequestResolver.js +10 -30
- package/dist/RequestResolver.js.map +1 -1
- package/dist/Resource.d.ts.map +1 -1
- package/dist/Resource.js +2 -1
- 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 +160 -134
- package/dist/Schedule.js.map +1 -1
- package/dist/Scheduler.d.ts +34 -123
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/Scheduler.js +31 -123
- package/dist/Scheduler.js.map +1 -1
- package/dist/Schema.d.ts +2722 -247
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +1947 -224
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +7 -2
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +131 -25
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaGetter.d.ts +5 -5
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +18 -18
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaParser.d.ts +44 -54
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +55 -2
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +46 -45
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +49 -24
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +107 -3
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +173 -13
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/ScopedCache.d.ts +2 -2
- package/dist/ScopedCache.d.ts.map +1 -1
- package/dist/ScopedCache.js +1 -1
- package/dist/ScopedCache.js.map +1 -1
- package/dist/Semaphore.d.ts +307 -0
- package/dist/Semaphore.d.ts.map +1 -0
- package/dist/Semaphore.js +222 -0
- package/dist/Semaphore.js.map +1 -0
- package/dist/ServiceMap.d.ts +67 -31
- package/dist/ServiceMap.d.ts.map +1 -1
- package/dist/ServiceMap.js +39 -24
- package/dist/ServiceMap.js.map +1 -1
- package/dist/Sink.d.ts +18 -15
- package/dist/Sink.d.ts.map +1 -1
- package/dist/Sink.js +53 -6
- package/dist/Sink.js.map +1 -1
- package/dist/Stdio.d.ts +16 -4
- package/dist/Stdio.d.ts.map +1 -1
- package/dist/Stdio.js +18 -0
- package/dist/Stdio.js.map +1 -1
- package/dist/Stream.d.ts +284 -431
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +189 -88
- 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 +23 -7
- package/dist/Struct.d.ts.map +1 -1
- package/dist/Struct.js +22 -0
- package/dist/Struct.js.map +1 -1
- package/dist/SubscriptionRef.d.ts +3 -3
- package/dist/SubscriptionRef.d.ts.map +1 -1
- package/dist/SubscriptionRef.js +85 -117
- package/dist/SubscriptionRef.js.map +1 -1
- package/dist/SynchronizedRef.d.ts +2 -1
- package/dist/SynchronizedRef.d.ts.map +1 -1
- package/dist/SynchronizedRef.js +2 -1
- package/dist/SynchronizedRef.js.map +1 -1
- package/dist/Terminal.d.ts +2 -1
- package/dist/Terminal.d.ts.map +1 -1
- package/dist/Terminal.js.map +1 -1
- package/dist/Tracer.d.ts +5 -4
- package/dist/Tracer.d.ts.map +1 -1
- package/dist/Tracer.js +2 -1
- 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 +37 -37
- package/dist/TxChunk.d.ts.map +1 -1
- package/dist/TxChunk.js +3 -3
- package/dist/TxChunk.js.map +1 -1
- package/dist/TxDeferred.d.ts +328 -0
- package/dist/TxDeferred.d.ts.map +1 -0
- package/dist/TxDeferred.js +197 -0
- package/dist/TxDeferred.js.map +1 -0
- package/dist/TxHashMap.d.ts +159 -140
- 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 +36 -36
- 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 +32 -32
- package/dist/TxQueue.d.ts.map +1 -1
- package/dist/TxQueue.js +26 -26
- package/dist/TxQueue.js.map +1 -1
- package/dist/TxReentrantLock.d.ts +523 -0
- package/dist/TxReentrantLock.d.ts.map +1 -0
- package/dist/TxReentrantLock.js +504 -0
- package/dist/TxReentrantLock.js.map +1 -0
- package/dist/TxRef.d.ts +34 -34
- package/dist/TxRef.d.ts.map +1 -1
- package/dist/TxRef.js +21 -14
- package/dist/TxRef.js.map +1 -1
- package/dist/TxSemaphore.d.ts +170 -10
- package/dist/TxSemaphore.d.ts.map +1 -1
- package/dist/TxSemaphore.js +23 -8
- 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 -23
- package/dist/Types.d.ts.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 +804 -53
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +804 -53
- package/dist/index.js.map +1 -1
- package/dist/internal/core.js +11 -3
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/dateTime.js +77 -71
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +281 -201
- 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/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 +3 -2
- 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 +2 -2
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/schema/annotations.js +2 -0
- package/dist/internal/schema/annotations.js.map +1 -1
- package/dist/internal/schema/representation.js +47 -106
- package/dist/internal/schema/representation.js.map +1 -1
- package/dist/internal/schema/schema.js +1 -0
- package/dist/internal/schema/schema.js.map +1 -1
- package/dist/internal/schema/to-codec.js +7 -10
- package/dist/internal/schema/to-codec.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 +8 -7
- package/dist/testing/TestClock.d.ts.map +1 -1
- package/dist/testing/TestClock.js +6 -4
- package/dist/testing/TestClock.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +266 -32
- 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 +136 -54
- package/dist/unstable/ai/AiError.d.ts.map +1 -1
- package/dist/unstable/ai/AiError.js +28 -23
- package/dist/unstable/ai/AiError.js.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.js +4 -0
- package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Chat.d.ts +7 -8
- package/dist/unstable/ai/Chat.d.ts.map +1 -1
- package/dist/unstable/ai/Chat.js +38 -44
- 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/LanguageModel.d.ts +53 -45
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +265 -143
- package/dist/unstable/ai/LanguageModel.js.map +1 -1
- package/dist/unstable/ai/McpSchema.d.ts +183 -88
- package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
- package/dist/unstable/ai/McpSchema.js +57 -12
- package/dist/unstable/ai/McpSchema.js.map +1 -1
- package/dist/unstable/ai/McpServer.d.ts +66 -13
- package/dist/unstable/ai/McpServer.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.js +193 -51
- package/dist/unstable/ai/McpServer.js.map +1 -1
- package/dist/unstable/ai/Model.d.ts +25 -7
- package/dist/unstable/ai/Model.d.ts.map +1 -1
- package/dist/unstable/ai/Model.js +22 -6
- package/dist/unstable/ai/Model.js.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js +4 -0
- package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Prompt.d.ts +20 -20
- package/dist/unstable/ai/Prompt.d.ts.map +1 -1
- package/dist/unstable/ai/Response.d.ts +26 -26
- package/dist/unstable/ai/Response.d.ts.map +1 -1
- package/dist/unstable/ai/Response.js +1 -1
- package/dist/unstable/ai/Response.js.map +1 -1
- package/dist/unstable/ai/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/Tool.d.ts +34 -4
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +28 -10
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/ai/Toolkit.d.ts +1 -1
- package/dist/unstable/ai/Toolkit.d.ts.map +1 -1
- package/dist/unstable/ai/Toolkit.js +4 -11
- 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 +0 -5
- package/dist/unstable/ai/internal/codec-transformer.js.map +1 -1
- package/dist/unstable/cli/Argument.d.ts +2 -4
- 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 +27 -60
- package/dist/unstable/cli/CliError.d.ts.map +1 -1
- package/dist/unstable/cli/CliError.js +25 -57
- package/dist/unstable/cli/CliError.js.map +1 -1
- package/dist/unstable/cli/CliOutput.d.ts +3 -2
- package/dist/unstable/cli/CliOutput.d.ts.map +1 -1
- package/dist/unstable/cli/CliOutput.js +65 -10
- package/dist/unstable/cli/CliOutput.js.map +1 -1
- package/dist/unstable/cli/Command.d.ts +371 -58
- package/dist/unstable/cli/Command.d.ts.map +1 -1
- package/dist/unstable/cli/Command.js +328 -67
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cli/Completions.d.ts +16 -0
- package/dist/unstable/cli/Completions.d.ts.map +1 -0
- package/dist/unstable/cli/Completions.js +23 -0
- package/dist/unstable/cli/Completions.js.map +1 -0
- package/dist/unstable/cli/Flag.d.ts +2 -2
- 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 +4 -4
- package/dist/unstable/cli/Param.d.ts.map +1 -1
- package/dist/unstable/cli/Param.js +7 -7
- 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 +258 -84
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/cli/index.d.ts +8 -0
- package/dist/unstable/cli/index.d.ts.map +1 -1
- package/dist/unstable/cli/index.js +8 -0
- package/dist/unstable/cli/index.js.map +1 -1
- package/dist/unstable/cli/internal/command.d.ts +40 -14
- package/dist/unstable/cli/internal/command.d.ts.map +1 -1
- package/dist/unstable/cli/internal/command.js +72 -46
- package/dist/unstable/cli/internal/command.js.map +1 -1
- package/dist/unstable/cli/internal/completions/CommandDescriptor.js +16 -4
- package/dist/unstable/cli/internal/completions/CommandDescriptor.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 +61 -43
- package/dist/unstable/cli/internal/parser.js.map +1 -1
- package/dist/unstable/cluster/ClusterCron.d.ts +1 -1
- package/dist/unstable/cluster/ClusterCron.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterCron.js +1 -1
- package/dist/unstable/cluster/ClusterCron.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts +3 -2
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +29 -26
- 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 +10 -8
- package/dist/unstable/cluster/Entity.d.ts.map +1 -1
- package/dist/unstable/cluster/Entity.js +7 -7
- package/dist/unstable/cluster/Entity.js.map +1 -1
- 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/EntityResource.d.ts +2 -2
- package/dist/unstable/cluster/EntityResource.d.ts.map +1 -1
- package/dist/unstable/cluster/Envelope.d.ts +1 -1
- package/dist/unstable/cluster/K8sHttpClient.d.ts +1 -1
- package/dist/unstable/cluster/K8sHttpClient.js +4 -4
- package/dist/unstable/cluster/K8sHttpClient.js.map +1 -1
- package/dist/unstable/cluster/Message.d.ts +14 -13
- package/dist/unstable/cluster/Message.d.ts.map +1 -1
- package/dist/unstable/cluster/Message.js +3 -2
- package/dist/unstable/cluster/Message.js.map +1 -1
- package/dist/unstable/cluster/MessageStorage.d.ts +10 -10
- package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/MessageStorage.js +14 -13
- package/dist/unstable/cluster/MessageStorage.js.map +1 -1
- package/dist/unstable/cluster/Reply.d.ts +8 -7
- package/dist/unstable/cluster/Reply.d.ts.map +1 -1
- package/dist/unstable/cluster/Reply.js +4 -3
- 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.map +1 -1
- package/dist/unstable/cluster/RunnerAddress.js +1 -1
- package/dist/unstable/cluster/RunnerAddress.js.map +1 -1
- package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerServer.js +9 -8
- package/dist/unstable/cluster/RunnerServer.js.map +1 -1
- package/dist/unstable/cluster/Runners.d.ts +2 -1
- package/dist/unstable/cluster/Runners.d.ts.map +1 -1
- package/dist/unstable/cluster/Runners.js +11 -9
- package/dist/unstable/cluster/Runners.js.map +1 -1
- package/dist/unstable/cluster/ShardId.js +3 -3
- package/dist/unstable/cluster/ShardId.js.map +1 -1
- package/dist/unstable/cluster/Sharding.d.ts +2 -2
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +28 -20
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.d.ts +26 -25
- package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.js +24 -24
- package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.js +19 -18
- package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.js +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/unstable/cluster/internal/entityManager.js +14 -14
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/cluster/internal/entityReaper.js +2 -1
- package/dist/unstable/cluster/internal/entityReaper.js.map +1 -1
- package/dist/unstable/cluster/internal/resourceRef.js +2 -1
- package/dist/unstable/cluster/internal/resourceRef.js.map +1 -1
- package/dist/unstable/devtools/DevToolsClient.d.ts.map +1 -1
- package/dist/unstable/devtools/DevToolsClient.js +4 -3
- package/dist/unstable/devtools/DevToolsClient.js.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.d.ts +40 -40
- 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 +4 -4
- package/dist/unstable/encoding/Sse.d.ts.map +1 -1
- package/dist/unstable/encoding/Sse.js +1 -1
- package/dist/unstable/encoding/Sse.js.map +1 -1
- package/dist/unstable/eventlog/EventJournal.d.ts +2 -2
- package/dist/unstable/eventlog/EventJournal.js +2 -2
- package/dist/unstable/eventlog/EventJournal.js.map +1 -1
- package/dist/unstable/eventlog/EventLog.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLog.js +3 -2
- package/dist/unstable/eventlog/EventLog.js.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.d.ts +6 -6
- package/dist/unstable/eventlog/SqlEventLogJournal.js +2 -2
- package/dist/unstable/eventlog/SqlEventLogJournal.js.map +1 -1
- package/dist/unstable/http/Cookies.d.ts +52 -7
- 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.map +1 -1
- package/dist/unstable/http/Etag.js +5 -1
- package/dist/unstable/http/Etag.js.map +1 -1
- package/dist/unstable/http/Headers.d.ts +19 -2
- package/dist/unstable/http/Headers.d.ts.map +1 -1
- package/dist/unstable/http/Headers.js +40 -11
- 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 +117 -15
- package/dist/unstable/http/HttpClient.d.ts.map +1 -1
- package/dist/unstable/http/HttpClient.js +191 -13
- package/dist/unstable/http/HttpClient.js.map +1 -1
- package/dist/unstable/http/HttpClientError.d.ts +7 -7
- package/dist/unstable/http/HttpClientRequest.d.ts +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 +6 -1
- package/dist/unstable/http/HttpClientResponse.js.map +1 -1
- package/dist/unstable/http/HttpEffect.d.ts +7 -5
- package/dist/unstable/http/HttpEffect.d.ts.map +1 -1
- package/dist/unstable/http/HttpEffect.js +46 -54
- package/dist/unstable/http/HttpEffect.js.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.d.ts +3 -2
- package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
- 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 +1 -6
- package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/unstable/http/HttpMiddleware.js +24 -32
- package/dist/unstable/http/HttpMiddleware.js.map +1 -1
- package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
- package/dist/unstable/http/HttpPlatform.js +3 -2
- package/dist/unstable/http/HttpPlatform.js.map +1 -1
- package/dist/unstable/http/HttpRouter.d.ts +2 -1
- package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
- package/dist/unstable/http/HttpRouter.js +7 -7
- package/dist/unstable/http/HttpRouter.js.map +1 -1
- package/dist/unstable/http/HttpServer.d.ts.map +1 -1
- package/dist/unstable/http/HttpServer.js +2 -2
- 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 +15 -3
- package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRequest.js +301 -7
- 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 +50 -3
- package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerResponse.js +236 -1
- 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 +3 -3
- 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 +19 -10
- 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 +4 -4
- package/dist/unstable/httpapi/HttpApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApi.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts +11 -5
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +40 -27
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.d.ts +83 -7
- package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.js +78 -10
- package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +207 -101
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.js +49 -43
- package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.d.ts +31 -14
- package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.js +125 -32
- package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.d.ts +4 -3
- package/dist/unstable/httpapi/HttpApiGroup.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +46 -15
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.js +32 -3
- package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.d.ts +6 -0
- package/dist/unstable/httpapi/HttpApiScalar.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.d.ts +5 -0
- package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.js +20 -2
- package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSecurity.d.ts +2 -2
- package/dist/unstable/httpapi/HttpApiSecurity.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSecurity.js.map +1 -1
- package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/OpenApi.js +34 -26
- 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 +3 -3
- package/dist/unstable/observability/OtlpExporter.js.map +1 -1
- package/dist/unstable/observability/OtlpLogger.d.ts +4 -4
- package/dist/unstable/observability/OtlpLogger.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpLogger.js +7 -4
- package/dist/unstable/observability/OtlpLogger.js.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.d.ts +4 -4
- package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpTracer.d.ts +4 -4
- package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpTracer.js +7 -3
- package/dist/unstable/observability/OtlpTracer.js.map +1 -1
- package/dist/unstable/persistence/KeyValueStore.d.ts +1 -1
- package/dist/unstable/persistence/KeyValueStore.js +6 -6
- package/dist/unstable/persistence/KeyValueStore.js.map +1 -1
- package/dist/unstable/persistence/Persistable.d.ts +2 -2
- package/dist/unstable/persistence/Persistable.d.ts.map +1 -1
- package/dist/unstable/persistence/Persistable.js +1 -1
- package/dist/unstable/persistence/Persistable.js.map +1 -1
- package/dist/unstable/persistence/PersistedCache.d.ts +6 -5
- package/dist/unstable/persistence/PersistedCache.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedCache.js +2 -1
- package/dist/unstable/persistence/PersistedCache.js.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.d.ts +12 -12
- package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.js +12 -11
- package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
- package/dist/unstable/persistence/Persistence.d.ts +1 -1
- package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
- package/dist/unstable/persistence/Persistence.js +2 -2
- package/dist/unstable/persistence/Persistence.js.map +1 -1
- package/dist/unstable/persistence/RateLimiter.d.ts +3 -3
- package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
- package/dist/unstable/persistence/RateLimiter.js +1 -1
- package/dist/unstable/persistence/RateLimiter.js.map +1 -1
- package/dist/unstable/process/ChildProcess.d.ts +5 -128
- package/dist/unstable/process/ChildProcess.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcess.js +1 -65
- package/dist/unstable/process/ChildProcess.js.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.d.ts +45 -7
- package/dist/unstable/process/ChildProcessSpawner.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.js +21 -1
- package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts +73 -12
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +108 -25
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts +17 -15
- package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.js +45 -15
- package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.d.ts +6 -0
- package/dist/unstable/reactivity/AtomRegistry.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.js +54 -11
- package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.d.ts +9 -9
- package/dist/unstable/reactivity/AtomRpc.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.js +47 -21
- package/dist/unstable/reactivity/AtomRpc.js.map +1 -1
- package/dist/unstable/reactivity/Hydration.d.ts +39 -0
- package/dist/unstable/reactivity/Hydration.d.ts.map +1 -0
- package/dist/unstable/reactivity/Hydration.js +76 -0
- package/dist/unstable/reactivity/Hydration.js.map +1 -0
- package/dist/unstable/reactivity/index.d.ts +4 -0
- package/dist/unstable/reactivity/index.d.ts.map +1 -1
- package/dist/unstable/reactivity/index.js +4 -0
- package/dist/unstable/reactivity/index.js.map +1 -1
- package/dist/unstable/rpc/Rpc.d.ts +5 -5
- package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
- package/dist/unstable/rpc/Rpc.js +4 -3
- package/dist/unstable/rpc/Rpc.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts +5 -26
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +10 -17
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/rpc/RpcGroup.d.ts +3 -5
- package/dist/unstable/rpc/RpcGroup.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcGroup.js.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.d.ts +8 -8
- package/dist/unstable/rpc/RpcMiddleware.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.js.map +1 -1
- package/dist/unstable/rpc/RpcSchema.d.ts +13 -0
- package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSchema.js +17 -2
- package/dist/unstable/rpc/RpcSchema.js.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.js +39 -11
- package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts +6 -10
- package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +20 -19
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/rpc/Utils.d.ts.map +1 -1
- package/dist/unstable/rpc/Utils.js +3 -2
- package/dist/unstable/rpc/Utils.js.map +1 -1
- package/dist/unstable/schema/Model.d.ts +22 -1
- package/dist/unstable/schema/Model.d.ts.map +1 -1
- package/dist/unstable/schema/Model.js +15 -0
- package/dist/unstable/schema/Model.js.map +1 -1
- package/dist/unstable/schema/VariantSchema.d.ts +6 -6
- package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
- package/dist/unstable/schema/VariantSchema.js +6 -6
- package/dist/unstable/schema/VariantSchema.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts +6 -5
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +12 -9
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/dist/unstable/socket/SocketServer.d.ts +3 -3
- package/dist/unstable/sql/Migrator.d.ts +1 -1
- package/dist/unstable/sql/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 +1 -1
- package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
- package/dist/unstable/sql/SqlClient.js +1 -1
- package/dist/unstable/sql/SqlClient.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 +2 -2
- package/dist/unstable/sql/SqlModel.d.ts.map +1 -1
- package/dist/unstable/sql/SqlModel.js +3 -3
- package/dist/unstable/sql/SqlModel.js.map +1 -1
- package/dist/unstable/sql/SqlResolver.d.ts.map +1 -1
- package/dist/unstable/sql/SqlResolver.js +17 -8
- 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.js +0 -1
- package/dist/unstable/sql/Statement.js.map +1 -1
- package/dist/unstable/workers/Worker.d.ts.map +1 -1
- package/dist/unstable/workers/Worker.js +2 -1
- package/dist/unstable/workers/Worker.js.map +1 -1
- package/dist/unstable/workflow/DurableClock.d.ts +3 -3
- package/dist/unstable/workflow/DurableClock.d.ts.map +1 -1
- package/dist/unstable/workflow/DurableClock.js +3 -3
- package/dist/unstable/workflow/DurableClock.js.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.js +8 -8
- package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts +5 -4
- package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
- package/dist/unstable/workflow/Workflow.js +1 -1
- package/dist/unstable/workflow/Workflow.js.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts +17 -5
- package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js +153 -12
- package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +2 -2
- package/src/Array.ts +304 -447
- package/src/BigDecimal.ts +63 -66
- package/src/BigInt.ts +49 -41
- package/src/Brand.ts +1 -1
- package/src/Cache.ts +9 -8
- package/src/Cause.ts +37 -2
- package/src/Channel.ts +582 -154
- package/src/Chunk.ts +149 -331
- package/src/Combiner.ts +280 -13
- package/src/Config.ts +195 -25
- package/src/Cron.ts +155 -63
- package/src/Data.ts +539 -376
- package/src/DateTime.ts +75 -256
- package/src/Deferred.ts +8 -6
- package/src/Duration.ts +122 -66
- package/src/Effect.ts +1483 -1157
- package/src/Encoding.ts +879 -0
- package/src/Equal.ts +278 -111
- package/src/Equivalence.ts +114 -52
- package/src/ErrorReporter.ts +458 -0
- package/src/Exit.ts +24 -12
- package/src/Fiber.ts +12 -3
- package/src/FiberHandle.ts +10 -9
- package/src/FiberMap.ts +22 -22
- package/src/FileSystem.ts +34 -31
- package/src/Filter.ts +52 -63
- package/src/Formatter.ts +253 -51
- package/src/Function.ts +2 -10
- package/src/Graph.ts +131 -117
- package/src/HashMap.ts +26 -19
- package/src/Iterable.ts +117 -63
- package/src/JsonSchema.ts +383 -10
- package/src/Latch.ts +194 -0
- package/src/Layer.ts +393 -159
- package/src/LayerMap.ts +11 -9
- package/src/LogLevel.ts +37 -0
- package/src/Logger.ts +33 -100
- package/src/ManagedRuntime.ts +2 -2
- package/src/Metric.ts +6 -8
- package/src/MutableHashMap.ts +9 -0
- package/src/MutableHashSet.ts +9 -0
- package/src/Newtype.ts +308 -0
- package/src/Number.ts +85 -26
- package/src/Optic.ts +948 -19
- package/src/Option.ts +34 -24
- package/src/Order.ts +39 -32
- package/src/PartitionedSemaphore.ts +288 -56
- package/src/Pipeable.ts +32 -1
- package/src/PlatformError.ts +5 -5
- package/src/Pool.ts +13 -11
- package/src/PubSub.ts +30 -20
- package/src/Pull.ts +1 -1
- package/src/Queue.ts +11 -9
- package/src/Random.ts +51 -14
- package/src/RcMap.ts +5 -5
- package/src/RcRef.ts +1 -1
- package/src/Record.ts +94 -199
- package/src/Reducer.ts +166 -7
- package/src/References.ts +283 -287
- package/src/Request.ts +3 -2
- package/src/RequestResolver.ts +29 -49
- package/src/Resource.ts +2 -1
- package/src/Result.ts +2 -4
- package/src/Runtime.ts +102 -6
- package/src/Schedule.ts +458 -449
- package/src/Scheduler.ts +49 -126
- package/src/Schema.ts +3298 -392
- package/src/SchemaAST.ts +172 -33
- package/src/SchemaGetter.ts +19 -21
- package/src/SchemaParser.ts +92 -27
- package/src/SchemaRepresentation.ts +51 -26
- package/src/SchemaTransformation.ts +198 -13
- package/src/ScopedCache.ts +3 -3
- package/src/Semaphore.ts +444 -0
- package/src/ServiceMap.ts +133 -71
- package/src/Sink.ts +83 -28
- package/src/Stdio.ts +27 -4
- package/src/Stream.ts +687 -617
- package/src/String.ts +122 -69
- package/src/Struct.ts +33 -7
- package/src/SubscriptionRef.ts +101 -120
- package/src/SynchronizedRef.ts +3 -2
- package/src/Terminal.ts +2 -1
- package/src/Tracer.ts +6 -5
- package/src/Trie.ts +44 -31
- package/src/TxChunk.ts +72 -53
- package/src/TxDeferred.ts +394 -0
- package/src/TxHashMap.ts +409 -343
- package/src/TxHashSet.ts +113 -118
- package/src/TxPriorityQueue.ts +766 -0
- package/src/TxPubSub.ts +789 -0
- package/src/TxQueue.ts +241 -251
- package/src/TxReentrantLock.ts +753 -0
- package/src/TxRef.ts +50 -38
- package/src/TxSemaphore.ts +217 -44
- package/src/TxSubscriptionRef.ts +639 -0
- package/src/Types.ts +73 -19
- package/src/Utils.ts +137 -111
- package/src/index.ts +814 -54
- package/src/internal/core.ts +12 -5
- package/src/internal/dateTime.ts +91 -96
- package/src/internal/effect.ts +841 -432
- package/src/internal/hashMap.ts +12 -10
- package/src/internal/option.ts +7 -0
- package/src/internal/random.ts +20 -0
- package/src/internal/rcRef.ts +4 -3
- package/src/internal/references.ts +72 -0
- package/src/internal/request.ts +2 -2
- package/src/internal/schema/annotations.ts +2 -0
- package/src/internal/schema/representation.ts +45 -94
- package/src/internal/schema/schema.ts +1 -0
- package/src/internal/schema/to-codec.ts +7 -17
- package/src/internal/trie.ts +21 -15
- package/src/testing/TestClock.ts +13 -11
- package/src/testing/TestSchema.ts +332 -35
- package/src/testing/index.ts +64 -1
- package/src/unstable/ai/AiError.ts +111 -54
- package/src/unstable/ai/AnthropicStructuredOutput.ts +4 -0
- package/src/unstable/ai/Chat.ts +62 -74
- package/src/unstable/ai/EmbeddingModel.ts +209 -0
- package/src/unstable/ai/LanguageModel.ts +544 -230
- package/src/unstable/ai/McpSchema.ts +73 -13
- package/src/unstable/ai/McpServer.ts +271 -61
- package/src/unstable/ai/Model.ts +40 -9
- package/src/unstable/ai/OpenAiStructuredOutput.ts +4 -0
- package/src/unstable/ai/Prompt.ts +37 -37
- package/src/unstable/ai/Response.ts +25 -25
- package/src/unstable/ai/ResponseIdTracker.ts +97 -0
- package/src/unstable/ai/Tool.ts +42 -16
- package/src/unstable/ai/Toolkit.ts +5 -14
- package/src/unstable/ai/index.ts +24 -1
- package/src/unstable/ai/internal/codec-transformer.ts +0 -7
- package/src/unstable/cli/Argument.ts +2 -4
- package/src/unstable/cli/CliError.ts +47 -59
- package/src/unstable/cli/CliOutput.ts +85 -13
- package/src/unstable/cli/Command.ts +801 -192
- package/src/unstable/cli/Completions.ts +36 -0
- package/src/unstable/cli/Flag.ts +2 -2
- package/src/unstable/cli/GlobalFlag.ts +242 -0
- package/src/unstable/cli/HelpDoc.ts +91 -11
- package/src/unstable/cli/Param.ts +15 -11
- package/src/unstable/cli/Primitive.ts +2 -2
- package/src/unstable/cli/Prompt.ts +262 -100
- package/src/unstable/cli/index.ts +10 -0
- package/src/unstable/cli/internal/command.ts +109 -63
- package/src/unstable/cli/internal/completions/CommandDescriptor.ts +10 -4
- 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 +71 -63
- package/src/unstable/cluster/ClusterCron.ts +2 -2
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +40 -34
- package/src/unstable/cluster/DeliverAt.ts +1 -1
- package/src/unstable/cluster/Entity.ts +24 -22
- package/src/unstable/cluster/EntityAddress.ts +1 -1
- package/src/unstable/cluster/EntityResource.ts +4 -4
- package/src/unstable/cluster/Envelope.ts +1 -1
- package/src/unstable/cluster/K8sHttpClient.ts +5 -5
- package/src/unstable/cluster/Message.ts +6 -5
- package/src/unstable/cluster/MessageStorage.ts +29 -30
- package/src/unstable/cluster/Reply.ts +7 -4
- package/src/unstable/cluster/Runner.ts +1 -1
- package/src/unstable/cluster/RunnerAddress.ts +1 -1
- package/src/unstable/cluster/RunnerServer.ts +10 -13
- package/src/unstable/cluster/Runners.ts +14 -12
- package/src/unstable/cluster/ShardId.ts +2 -2
- package/src/unstable/cluster/Sharding.ts +36 -27
- package/src/unstable/cluster/ShardingConfig.ts +36 -37
- package/src/unstable/cluster/SqlMessageStorage.ts +21 -18
- package/src/unstable/cluster/SqlRunnerStorage.ts +1 -1
- package/src/unstable/cluster/internal/entityManager.ts +36 -29
- package/src/unstable/cluster/internal/entityReaper.ts +2 -1
- package/src/unstable/cluster/internal/resourceRef.ts +2 -1
- package/src/unstable/devtools/DevToolsClient.ts +23 -18
- 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/EventJournal.ts +2 -2
- package/src/unstable/eventlog/EventLog.ts +3 -2
- package/src/unstable/eventlog/SqlEventLogJournal.ts +2 -2
- package/src/unstable/http/Cookies.ts +94 -11
- package/src/unstable/http/Etag.ts +5 -3
- package/src/unstable/http/Headers.ts +68 -18
- package/src/unstable/http/HttpClient.ts +376 -34
- package/src/unstable/http/HttpClientRequest.ts +151 -39
- package/src/unstable/http/HttpClientResponse.ts +12 -6
- package/src/unstable/http/HttpEffect.ts +54 -68
- package/src/unstable/http/HttpIncomingMessage.ts +3 -2
- package/src/unstable/http/HttpMethod.ts +16 -4
- package/src/unstable/http/HttpMiddleware.ts +25 -39
- package/src/unstable/http/HttpPlatform.ts +3 -2
- package/src/unstable/http/HttpRouter.ts +9 -9
- package/src/unstable/http/HttpServer.ts +3 -9
- package/src/unstable/http/HttpServerError.ts +45 -47
- package/src/unstable/http/HttpServerRequest.ts +407 -16
- package/src/unstable/http/HttpServerRespondable.ts +6 -6
- package/src/unstable/http/HttpServerResponse.ts +345 -7
- package/src/unstable/http/HttpStaticServer.ts +456 -0
- package/src/unstable/http/HttpTraceContext.ts +31 -17
- package/src/unstable/http/Multipart.ts +2 -2
- package/src/unstable/http/Url.ts +650 -0
- package/src/unstable/http/UrlParams.ts +31 -19
- package/src/unstable/http/index.ts +10 -0
- package/src/unstable/http/internal/preResponseHandler.ts +15 -0
- package/src/unstable/httpapi/HttpApi.ts +6 -6
- package/src/unstable/httpapi/HttpApiBuilder.ts +106 -41
- package/src/unstable/httpapi/HttpApiClient.ts +180 -28
- package/src/unstable/httpapi/HttpApiEndpoint.ts +216 -104
- package/src/unstable/httpapi/HttpApiError.ts +108 -30
- package/src/unstable/httpapi/HttpApiGroup.ts +7 -6
- package/src/unstable/httpapi/HttpApiMiddleware.ts +83 -22
- package/src/unstable/httpapi/HttpApiScalar.ts +6 -0
- package/src/unstable/httpapi/HttpApiSchema.ts +20 -2
- package/src/unstable/httpapi/HttpApiSecurity.ts +3 -3
- package/src/unstable/httpapi/OpenApi.ts +43 -29
- package/src/unstable/observability/Otlp.ts +12 -12
- package/src/unstable/observability/OtlpExporter.ts +8 -5
- package/src/unstable/observability/OtlpLogger.ts +13 -9
- package/src/unstable/observability/OtlpMetrics.ts +4 -4
- package/src/unstable/observability/OtlpTracer.ts +12 -8
- package/src/unstable/persistence/KeyValueStore.ts +6 -6
- package/src/unstable/persistence/Persistable.ts +3 -3
- package/src/unstable/persistence/PersistedCache.ts +20 -9
- package/src/unstable/persistence/PersistedQueue.ts +25 -24
- package/src/unstable/persistence/Persistence.ts +3 -3
- package/src/unstable/persistence/RateLimiter.ts +4 -4
- package/src/unstable/process/ChildProcess.ts +6 -208
- package/src/unstable/process/ChildProcessSpawner.ts +75 -14
- package/src/unstable/reactivity/Atom.ts +212 -54
- package/src/unstable/reactivity/AtomHttpApi.ts +81 -41
- package/src/unstable/reactivity/AtomRegistry.ts +66 -12
- package/src/unstable/reactivity/AtomRpc.ts +51 -20
- package/src/unstable/reactivity/Hydration.ts +112 -0
- package/src/unstable/reactivity/index.ts +5 -0
- package/src/unstable/rpc/Rpc.ts +11 -12
- package/src/unstable/rpc/RpcClient.ts +22 -63
- package/src/unstable/rpc/RpcGroup.ts +7 -7
- package/src/unstable/rpc/RpcMiddleware.ts +15 -9
- package/src/unstable/rpc/RpcSchema.ts +23 -5
- package/src/unstable/rpc/RpcSerialization.ts +49 -11
- package/src/unstable/rpc/RpcServer.ts +31 -35
- package/src/unstable/rpc/Utils.ts +3 -2
- package/src/unstable/schema/Model.ts +31 -0
- package/src/unstable/schema/VariantSchema.ts +10 -10
- package/src/unstable/socket/Socket.ts +31 -27
- package/src/unstable/sql/Migrator.ts +7 -5
- package/src/unstable/sql/SqlClient.ts +6 -4
- package/src/unstable/sql/SqlError.ts +365 -11
- package/src/unstable/sql/SqlModel.ts +5 -5
- package/src/unstable/sql/SqlResolver.ts +17 -7
- package/src/unstable/sql/SqlSchema.ts +42 -26
- package/src/unstable/sql/Statement.ts +0 -1
- package/src/unstable/workers/Worker.ts +2 -1
- package/src/unstable/workflow/DurableClock.ts +8 -8
- package/src/unstable/workflow/DurableDeferred.ts +8 -8
- package/src/unstable/workflow/Workflow.ts +7 -3
- package/src/unstable/workflow/WorkflowEngine.ts +211 -19
- 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/encoding/Base64.d.ts +0 -67
- package/dist/encoding/Base64.d.ts.map +0 -1
- package/dist/encoding/Base64.js +0 -146
- package/dist/encoding/Base64.js.map +0 -1
- package/dist/encoding/Base64Url.d.ts +0 -60
- package/dist/encoding/Base64Url.d.ts.map +0 -1
- package/dist/encoding/Base64Url.js +0 -89
- package/dist/encoding/Base64Url.js.map +0 -1
- package/dist/encoding/EncodingError.d.ts +0 -31
- package/dist/encoding/EncodingError.d.ts.map +0 -1
- package/dist/encoding/EncodingError.js +0 -22
- package/dist/encoding/EncodingError.js.map +0 -1
- package/dist/encoding/Hex.d.ts +0 -61
- package/dist/encoding/Hex.d.ts.map +0 -1
- package/dist/encoding/Hex.js +0 -115
- package/dist/encoding/Hex.js.map +0 -1
- package/dist/encoding/index.d.ts +0 -26
- package/dist/encoding/index.d.ts.map +0 -1
- package/dist/encoding/index.js +0 -27
- package/dist/encoding/index.js.map +0 -1
- package/dist/unstable/cli/internal/builtInFlags.d.ts +0 -7
- package/dist/unstable/cli/internal/builtInFlags.d.ts.map +0 -1
- package/dist/unstable/cli/internal/builtInFlags.js +0 -44
- package/dist/unstable/cli/internal/builtInFlags.js.map +0 -1
- package/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/src/NullOr.ts +0 -204
- package/src/encoding/Base64.ts +0 -366
- package/src/encoding/Base64Url.ts +0 -104
- package/src/encoding/EncodingError.ts +0 -35
- package/src/encoding/Hex.ts +0 -390
- package/src/encoding/index.ts +0 -31
- package/src/unstable/cli/internal/builtInFlags.ts +0 -78
- package/src/unstable/cli/internal/completions/Completions.ts +0 -31
package/src/internal/effect.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { constant, constFalse, constTrue, constUndefined, constVoid, dual, ident
|
|
|
14
14
|
import * as Hash from "../Hash.ts"
|
|
15
15
|
import { toJson, toStringUnknown } from "../Inspectable.ts"
|
|
16
16
|
import * as Iterable from "../Iterable.ts"
|
|
17
|
+
import type * as _Latch from "../Latch.ts"
|
|
17
18
|
import type * as Logger from "../Logger.ts"
|
|
18
19
|
import type * as LogLevel from "../LogLevel.ts"
|
|
19
20
|
import type * as Metric from "../Metric.ts"
|
|
@@ -23,19 +24,7 @@ import { pipeArguments } from "../Pipeable.ts"
|
|
|
23
24
|
import type * as Predicate from "../Predicate.ts"
|
|
24
25
|
import { hasProperty, isIterable, isString, isTagged } from "../Predicate.ts"
|
|
25
26
|
import { currentFiberTypeId, redact } from "../Redactable.ts"
|
|
26
|
-
import {
|
|
27
|
-
CurrentConcurrency,
|
|
28
|
-
CurrentLogAnnotations,
|
|
29
|
-
CurrentLogLevel,
|
|
30
|
-
CurrentLogSpans,
|
|
31
|
-
CurrentStackFrame,
|
|
32
|
-
MinimumLogLevel,
|
|
33
|
-
type StackFrame,
|
|
34
|
-
TracerEnabled,
|
|
35
|
-
TracerSpanAnnotations,
|
|
36
|
-
TracerSpanLinks,
|
|
37
|
-
TracerTimingEnabled
|
|
38
|
-
} from "../References.ts"
|
|
27
|
+
import type { StackFrame } from "../References.ts"
|
|
39
28
|
import * as Result from "../Result.ts"
|
|
40
29
|
import * as Scheduler from "../Scheduler.ts"
|
|
41
30
|
import type * as Scope from "../Scope.ts"
|
|
@@ -48,7 +37,9 @@ import type {
|
|
|
48
37
|
ExcludeTag,
|
|
49
38
|
ExtractReason,
|
|
50
39
|
ExtractTag,
|
|
40
|
+
NarrowReason,
|
|
51
41
|
NoInfer,
|
|
42
|
+
OmitReason,
|
|
52
43
|
ReasonOf,
|
|
53
44
|
ReasonTags,
|
|
54
45
|
Simplify,
|
|
@@ -93,6 +84,19 @@ import {
|
|
|
93
84
|
} from "./core.ts"
|
|
94
85
|
import * as doNotation from "./doNotation.ts"
|
|
95
86
|
import * as InternalMetric from "./metric.ts"
|
|
87
|
+
import {
|
|
88
|
+
CurrentConcurrency,
|
|
89
|
+
CurrentErrorReporters,
|
|
90
|
+
CurrentLogAnnotations,
|
|
91
|
+
CurrentLogLevel,
|
|
92
|
+
CurrentLogSpans,
|
|
93
|
+
CurrentStackFrame,
|
|
94
|
+
MinimumLogLevel,
|
|
95
|
+
TracerEnabled,
|
|
96
|
+
TracerSpanAnnotations,
|
|
97
|
+
TracerSpanLinks,
|
|
98
|
+
TracerTimingEnabled
|
|
99
|
+
} from "./references.ts"
|
|
96
100
|
import { addSpanStackTrace, type ErrorWithStackTraceLimit, makeStackCleaner } from "./tracer.ts"
|
|
97
101
|
import { version } from "./version.ts"
|
|
98
102
|
|
|
@@ -212,7 +216,8 @@ export const causeInterruptors = <E>(self: Cause.Cause<E>): ReadonlySet<number>
|
|
|
212
216
|
const emptySet = new Set<number>()
|
|
213
217
|
|
|
214
218
|
/** @internal */
|
|
215
|
-
export const hasInterruptsOnly = <E>(self: Cause.Cause<E>): boolean =>
|
|
219
|
+
export const hasInterruptsOnly = <E>(self: Cause.Cause<E>): boolean =>
|
|
220
|
+
self.reasons.length > 0 && self.reasons.every(isInterruptReason)
|
|
216
221
|
|
|
217
222
|
/** @internal */
|
|
218
223
|
export const reasonAnnotations = <E>(
|
|
@@ -340,7 +345,8 @@ export const causePrettyErrors = <E>(self: Cause.Cause<E>): Array<Error> => {
|
|
|
340
345
|
return errors
|
|
341
346
|
}
|
|
342
347
|
|
|
343
|
-
|
|
348
|
+
/** @internal */
|
|
349
|
+
export const causePrettyError = (
|
|
344
350
|
original: Record<string, unknown> | Error,
|
|
345
351
|
annotations?: ReadonlyMap<string, unknown>
|
|
346
352
|
): Error => {
|
|
@@ -488,24 +494,6 @@ const fiberIdStore = { id: 0 }
|
|
|
488
494
|
/** @internal */
|
|
489
495
|
export const getCurrentFiber = (): Fiber.Fiber<any, any> | undefined => (globalThis as any)[currentFiberTypeId]
|
|
490
496
|
|
|
491
|
-
const keepAlive = (() => {
|
|
492
|
-
let count = 0
|
|
493
|
-
let running: ReturnType<typeof globalThis.setInterval> | undefined = undefined
|
|
494
|
-
return ({
|
|
495
|
-
increment() {
|
|
496
|
-
count++
|
|
497
|
-
running ??= globalThis.setInterval(constVoid, 2_147_483_647)
|
|
498
|
-
},
|
|
499
|
-
decrement() {
|
|
500
|
-
count--
|
|
501
|
-
if (count === 0 && running !== undefined) {
|
|
502
|
-
globalThis.clearInterval(running)
|
|
503
|
-
running = undefined
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
})
|
|
507
|
-
})()
|
|
508
|
-
|
|
509
497
|
/** @internal */
|
|
510
498
|
export class FiberImpl<A = any, E = any> implements Fiber.Fiber<A, E> {
|
|
511
499
|
constructor(
|
|
@@ -550,6 +538,12 @@ export class FiberImpl<A = any, E = any> implements Fiber.Fiber<A, E> {
|
|
|
550
538
|
currentStackFrame: StackFrame | undefined
|
|
551
539
|
runtimeMetrics: Metric.FiberRuntimeMetricsService | undefined
|
|
552
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
|
+
}
|
|
553
547
|
|
|
554
548
|
getRef<X>(ref: ServiceMap.Reference<X>): X {
|
|
555
549
|
return ServiceMap.getReferenceUnsafe(this.services, ref)
|
|
@@ -628,6 +622,7 @@ export class FiberImpl<A = any, E = any> implements Fiber.Fiber<A, E> {
|
|
|
628
622
|
this.currentOpCount++
|
|
629
623
|
if (
|
|
630
624
|
!yielding &&
|
|
625
|
+
!this.currentPreventYield &&
|
|
631
626
|
this.currentScheduler.shouldYield(this as any)
|
|
632
627
|
) {
|
|
633
628
|
yielding = true
|
|
@@ -685,12 +680,17 @@ export class FiberImpl<A = any, E = any> implements Fiber.Fiber<A, E> {
|
|
|
685
680
|
}
|
|
686
681
|
setServices(services: ServiceMap.ServiceMap<never>): void {
|
|
687
682
|
this.services = services
|
|
688
|
-
|
|
683
|
+
const scheduler = this.getRef(Scheduler.Scheduler)
|
|
684
|
+
if (scheduler !== this.currentScheduler) {
|
|
685
|
+
this.currentScheduler = scheduler
|
|
686
|
+
this._dispatcher = undefined
|
|
687
|
+
}
|
|
689
688
|
this.currentSpan = services.mapUnsafe.get(Tracer.ParentSpanKey)
|
|
690
689
|
this.currentLogLevel = this.getRef(CurrentLogLevel)
|
|
691
690
|
this.minimumLogLevel = this.getRef(MinimumLogLevel)
|
|
692
691
|
this.currentStackFrame = services.mapUnsafe.get(CurrentStackFrame.key)
|
|
693
692
|
this.maxOpsBeforeYield = this.getRef(Scheduler.MaxOpsBeforeYield)
|
|
693
|
+
this.currentPreventYield = this.getRef(Scheduler.PreventSchedulerYield)
|
|
694
694
|
this.runtimeMetrics = services.mapUnsafe.get(InternalMetric.FiberRuntimeMetricsKey)
|
|
695
695
|
const currentTracer = services.mapUnsafe.get(Tracer.TracerKey)
|
|
696
696
|
this.currentTracerContext = currentTracer ? currentTracer["context"] : undefined
|
|
@@ -784,6 +784,7 @@ export const fiberJoinAll = <A extends Iterable<Fiber.Fiber<any, any>>>(self: A)
|
|
|
784
784
|
> =>
|
|
785
785
|
callback((resume) => {
|
|
786
786
|
const fibers = Array.from(self)
|
|
787
|
+
if (fibers.length === 0) return resume(succeed(Arr.empty() as any))
|
|
787
788
|
const out = new Array<any>(fibers.length) as Arr.NonEmptyArray<any>
|
|
788
789
|
const cancels = Arr.empty<() => void>()
|
|
789
790
|
let done = 0
|
|
@@ -812,13 +813,29 @@ export const fiberInterrupt = <A, E>(
|
|
|
812
813
|
|
|
813
814
|
/** @internal */
|
|
814
815
|
export const fiberInterruptAs: {
|
|
815
|
-
(
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
816
|
+
(
|
|
817
|
+
fiberId: number | undefined,
|
|
818
|
+
annotations?: ServiceMap.ServiceMap<never> | undefined
|
|
819
|
+
): <A, E>(self: Fiber.Fiber<A, E>) => Effect.Effect<void>
|
|
820
|
+
<A, E>(
|
|
821
|
+
self: Fiber.Fiber<A, E>,
|
|
822
|
+
fiberId: number | undefined,
|
|
823
|
+
annotations?: ServiceMap.ServiceMap<never> | undefined
|
|
824
|
+
): Effect.Effect<void>
|
|
825
|
+
} = dual(
|
|
826
|
+
(args) => hasProperty(args[0], FiberTypeId),
|
|
827
|
+
<A, E>(
|
|
828
|
+
self: Fiber.Fiber<A, E>,
|
|
829
|
+
fiberId: number | undefined,
|
|
830
|
+
annotations?: ServiceMap.ServiceMap<never> | undefined
|
|
831
|
+
): Effect.Effect<void> =>
|
|
832
|
+
withFiber((parent) => {
|
|
833
|
+
let ann = fiberStackAnnotations(parent)
|
|
834
|
+
ann = ann && annotations ? ServiceMap.merge(ann, annotations) : ann ?? annotations
|
|
835
|
+
self.interruptUnsafe(fiberId, ann)
|
|
836
|
+
return asVoid(fiberAwait(self))
|
|
837
|
+
})
|
|
838
|
+
)
|
|
822
839
|
|
|
823
840
|
/** @internal */
|
|
824
841
|
export const fiberInterruptAll = <A extends Iterable<Fiber.Fiber<any, any>>>(
|
|
@@ -895,7 +912,7 @@ export const yieldNowWith: (priority?: number) => Effect.Effect<void> = makePrim
|
|
|
895
912
|
op: "Yield",
|
|
896
913
|
[evaluate](fiber) {
|
|
897
914
|
let resumed = false
|
|
898
|
-
fiber.
|
|
915
|
+
fiber.currentDispatcher.scheduleTask(() => {
|
|
899
916
|
if (resumed) return
|
|
900
917
|
fiber.evaluate(exitVoid as any)
|
|
901
918
|
}, this[args] ?? 0)
|
|
@@ -1018,10 +1035,8 @@ const callbackOptions: <A, E = never, R = never>(
|
|
|
1018
1035
|
}, controller?.signal)
|
|
1019
1036
|
if (yielded !== false) return yielded
|
|
1020
1037
|
yielded = true
|
|
1021
|
-
keepAlive.increment()
|
|
1022
1038
|
fiber._yielded = () => {
|
|
1023
1039
|
resumed = true
|
|
1024
|
-
keepAlive.decrement()
|
|
1025
1040
|
}
|
|
1026
1041
|
if (controller === undefined && onCancel === undefined) {
|
|
1027
1042
|
return Yield
|
|
@@ -1095,7 +1110,7 @@ export const fnUntraced: Effect.fn.Untraced = (
|
|
|
1095
1110
|
body: Function,
|
|
1096
1111
|
...pipeables: Array<any>
|
|
1097
1112
|
) => {
|
|
1098
|
-
|
|
1113
|
+
const fn = pipeables.length === 0
|
|
1099
1114
|
? function(this: any) {
|
|
1100
1115
|
return suspend(() => fromIteratorUnsafe(body.apply(this, arguments)))
|
|
1101
1116
|
}
|
|
@@ -1106,8 +1121,15 @@ export const fnUntraced: Effect.fn.Untraced = (
|
|
|
1106
1121
|
}
|
|
1107
1122
|
return effect
|
|
1108
1123
|
}
|
|
1124
|
+
return defineFunctionLength(body.length, fn)
|
|
1109
1125
|
}
|
|
1110
1126
|
|
|
1127
|
+
const defineFunctionLength = <F extends Function>(length: number, fn: F): F =>
|
|
1128
|
+
Object.defineProperty(fn, "length", {
|
|
1129
|
+
value: length,
|
|
1130
|
+
configurable: true
|
|
1131
|
+
})
|
|
1132
|
+
|
|
1111
1133
|
const fnStackCleaner = makeStackCleaner(2)
|
|
1112
1134
|
|
|
1113
1135
|
/** @internal */
|
|
@@ -1148,7 +1170,7 @@ const makeFn = (
|
|
|
1148
1170
|
? bodyOrOptions
|
|
1149
1171
|
: (pipeables.pop()!).bind(bodyOrOptions.self)
|
|
1150
1172
|
|
|
1151
|
-
return function(this: any, ...args: Array<any>) {
|
|
1173
|
+
return defineFunctionLength(body.length, function(this: any, ...args: Array<any>) {
|
|
1152
1174
|
let result = suspend(() => {
|
|
1153
1175
|
const iter = body.apply(this, arguments)
|
|
1154
1176
|
return isEffect(iter) ? iter : fromIteratorUnsafe(iter)
|
|
@@ -1178,7 +1200,7 @@ const makeFn = (
|
|
|
1178
1200
|
}
|
|
1179
1201
|
})
|
|
1180
1202
|
)
|
|
1181
|
-
}
|
|
1203
|
+
})
|
|
1182
1204
|
}
|
|
1183
1205
|
|
|
1184
1206
|
/** @internal */
|
|
@@ -1186,17 +1208,20 @@ export const fnUntracedEager: Effect.fn.Untraced = (
|
|
|
1186
1208
|
body: Function,
|
|
1187
1209
|
...pipeables: Array<any>
|
|
1188
1210
|
) =>
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
let effect = fromIteratorEagerUnsafe(() => body.apply(this, arguments))
|
|
1195
|
-
for (const pipeable of pipeables) {
|
|
1196
|
-
effect = pipeable(effect)
|
|
1211
|
+
defineFunctionLength(
|
|
1212
|
+
body.length,
|
|
1213
|
+
pipeables.length === 0
|
|
1214
|
+
? function(this: any) {
|
|
1215
|
+
return fromIteratorEagerUnsafe(() => body.apply(this, arguments))
|
|
1197
1216
|
}
|
|
1198
|
-
|
|
1199
|
-
|
|
1217
|
+
: function(this: any) {
|
|
1218
|
+
let effect = fromIteratorEagerUnsafe(() => body.apply(this, arguments))
|
|
1219
|
+
for (const pipeable of pipeables) {
|
|
1220
|
+
effect = pipeable(effect)
|
|
1221
|
+
}
|
|
1222
|
+
return effect
|
|
1223
|
+
}
|
|
1224
|
+
)
|
|
1200
1225
|
|
|
1201
1226
|
const fromIteratorEagerUnsafe = (
|
|
1202
1227
|
evaluate: () => Iterator<Effect.Yieldable<any, any, any, any>>
|
|
@@ -1945,17 +1970,17 @@ export const exitFindErrorOption = <A, E>(self: Exit.Exit<A, E>): Option.Option<
|
|
|
1945
1970
|
|
|
1946
1971
|
/** @internal */
|
|
1947
1972
|
export const service: {
|
|
1948
|
-
<I, S>(service: ServiceMap.
|
|
1973
|
+
<I, S>(service: ServiceMap.Key<I, S>): Effect.Effect<S, never, I>
|
|
1949
1974
|
} = fromYieldable as any
|
|
1950
1975
|
|
|
1951
1976
|
/** @internal */
|
|
1952
1977
|
export const serviceOption = <I, S>(
|
|
1953
|
-
service: ServiceMap.
|
|
1978
|
+
service: ServiceMap.Key<I, S>
|
|
1954
1979
|
): Effect.Effect<Option.Option<S>> => withFiber((fiber) => succeed(ServiceMap.getOption(fiber.services, service)))
|
|
1955
1980
|
|
|
1956
1981
|
/** @internal */
|
|
1957
1982
|
export const serviceOptional = <I, S>(
|
|
1958
|
-
service: ServiceMap.
|
|
1983
|
+
service: ServiceMap.Key<I, S>
|
|
1959
1984
|
): Effect.Effect<S, Cause.NoSuchElementError> =>
|
|
1960
1985
|
withFiber((fiber) =>
|
|
1961
1986
|
fiber.services.mapUnsafe.has(service.key)
|
|
@@ -1983,23 +2008,8 @@ export const updateServices: {
|
|
|
1983
2008
|
const nextServices = f(prev)
|
|
1984
2009
|
if (prev === nextServices) return self as any
|
|
1985
2010
|
fiber.setServices(nextServices)
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
if (!prev.mapUnsafe.has(key) || value !== prev.mapUnsafe.get(key)) {
|
|
1989
|
-
newServices.set(key, value)
|
|
1990
|
-
}
|
|
1991
|
-
}
|
|
1992
|
-
return onExitPrimitive(self as any, () => {
|
|
1993
|
-
const map = new Map(fiber.services.mapUnsafe)
|
|
1994
|
-
for (const [key, value] of newServices) {
|
|
1995
|
-
if (value !== map.get(key)) continue
|
|
1996
|
-
if (prev.mapUnsafe.has(key)) {
|
|
1997
|
-
map.set(key, prev.mapUnsafe.get(key))
|
|
1998
|
-
} else {
|
|
1999
|
-
map.delete(key)
|
|
2000
|
-
}
|
|
2001
|
-
}
|
|
2002
|
-
fiber.setServices(ServiceMap.makeUnsafe(map))
|
|
2011
|
+
return onExitPrimitive(self, () => {
|
|
2012
|
+
fiber.setServices(prev)
|
|
2003
2013
|
return undefined
|
|
2004
2014
|
})
|
|
2005
2015
|
})
|
|
@@ -2008,27 +2018,26 @@ export const updateServices: {
|
|
|
2008
2018
|
/** @internal */
|
|
2009
2019
|
export const updateService: {
|
|
2010
2020
|
<I, A>(
|
|
2011
|
-
service: ServiceMap.
|
|
2021
|
+
service: ServiceMap.Key<I, A>,
|
|
2012
2022
|
f: (value: A) => A
|
|
2013
2023
|
): <XA, E, R>(self: Effect.Effect<XA, E, R>) => Effect.Effect<XA, E, R | I>
|
|
2014
2024
|
<XA, E, R, I, A>(
|
|
2015
2025
|
self: Effect.Effect<XA, E, R>,
|
|
2016
|
-
service: ServiceMap.
|
|
2026
|
+
service: ServiceMap.Key<I, A>,
|
|
2017
2027
|
f: (value: A) => A
|
|
2018
2028
|
): Effect.Effect<XA, E, R | I>
|
|
2019
2029
|
} = dual(
|
|
2020
2030
|
3,
|
|
2021
2031
|
<XA, E, R, I, A>(
|
|
2022
2032
|
self: Effect.Effect<XA, E, R>,
|
|
2023
|
-
service: ServiceMap.
|
|
2033
|
+
service: ServiceMap.Key<I, A>,
|
|
2024
2034
|
f: (value: A) => A
|
|
2025
2035
|
): Effect.Effect<XA, E, R | I> =>
|
|
2026
|
-
|
|
2027
|
-
const prev = ServiceMap.getUnsafe(
|
|
2036
|
+
updateServices(self, (s) => {
|
|
2037
|
+
const prev = ServiceMap.getUnsafe(s, service)
|
|
2028
2038
|
const next = f(prev)
|
|
2029
|
-
if (prev === next) return
|
|
2030
|
-
|
|
2031
|
-
return onExit(self, () => sync(() => fiber.setServices(ServiceMap.add(fiber.services, service, prev))))
|
|
2039
|
+
if (prev === next) return s
|
|
2040
|
+
return ServiceMap.add(s, service, next)
|
|
2032
2041
|
})
|
|
2033
2042
|
)
|
|
2034
2043
|
|
|
@@ -2066,20 +2075,20 @@ export const provideServices: {
|
|
|
2066
2075
|
/** @internal */
|
|
2067
2076
|
export const provideService: {
|
|
2068
2077
|
<I, S>(
|
|
2069
|
-
service: ServiceMap.
|
|
2078
|
+
service: ServiceMap.Key<I, S>
|
|
2070
2079
|
): {
|
|
2071
2080
|
(implementation: S): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, I>>
|
|
2072
2081
|
<A, E, R>(self: Effect.Effect<A, E, R>, implementation: S): Effect.Effect<A, E, Exclude<R, I>>
|
|
2073
2082
|
}
|
|
2074
2083
|
<I, S>(
|
|
2075
|
-
key: ServiceMap.
|
|
2084
|
+
key: ServiceMap.Key<I, S>,
|
|
2076
2085
|
implementation: S
|
|
2077
2086
|
): <A, E, R>(
|
|
2078
2087
|
self: Effect.Effect<A, E, R>
|
|
2079
2088
|
) => Effect.Effect<A, E, Exclude<R, I>>
|
|
2080
2089
|
<A, E, R, I, S>(
|
|
2081
2090
|
self: Effect.Effect<A, E, R>,
|
|
2082
|
-
service: ServiceMap.
|
|
2091
|
+
service: ServiceMap.Key<I, S>,
|
|
2083
2092
|
implementation: S
|
|
2084
2093
|
): Effect.Effect<A, E, Exclude<R, I>>
|
|
2085
2094
|
} = function(this: any) {
|
|
@@ -2092,34 +2101,33 @@ export const provideService: {
|
|
|
2092
2101
|
|
|
2093
2102
|
const provideServiceImpl = <A, E, R, I, S>(
|
|
2094
2103
|
self: Effect.Effect<A, E, R>,
|
|
2095
|
-
service: ServiceMap.
|
|
2104
|
+
service: ServiceMap.Key<I, S>,
|
|
2096
2105
|
implementation: S
|
|
2097
2106
|
): Effect.Effect<A, E, Exclude<R, I>> =>
|
|
2098
|
-
|
|
2099
|
-
const prev =
|
|
2100
|
-
if (prev
|
|
2101
|
-
|
|
2102
|
-
return onExit(self, () => sync(() => fiber.setServices(ServiceMap.addOrOmit(fiber.services, service, prev))))
|
|
2107
|
+
updateServices(self, (s) => {
|
|
2108
|
+
const prev = s.mapUnsafe.get(service.key)
|
|
2109
|
+
if (prev === implementation) return s
|
|
2110
|
+
return ServiceMap.add(s, service, implementation)
|
|
2103
2111
|
}) as any
|
|
2104
2112
|
|
|
2105
2113
|
/** @internal */
|
|
2106
2114
|
export const provideServiceEffect: {
|
|
2107
2115
|
<I, S, E2, R2>(
|
|
2108
|
-
service: ServiceMap.
|
|
2116
|
+
service: ServiceMap.Key<I, S>,
|
|
2109
2117
|
acquire: Effect.Effect<S, E2, R2>
|
|
2110
2118
|
): <A, E, R>(
|
|
2111
2119
|
self: Effect.Effect<A, E, R>
|
|
2112
2120
|
) => Effect.Effect<A, E | E2, Exclude<R, I> | R2>
|
|
2113
2121
|
<A, E, R, I, S, E2, R2>(
|
|
2114
2122
|
self: Effect.Effect<A, E, R>,
|
|
2115
|
-
service: ServiceMap.
|
|
2123
|
+
service: ServiceMap.Key<I, S>,
|
|
2116
2124
|
acquire: Effect.Effect<S, E2, R2>
|
|
2117
2125
|
): Effect.Effect<A, E | E2, Exclude<R, I> | R2>
|
|
2118
2126
|
} = dual(
|
|
2119
2127
|
3,
|
|
2120
2128
|
<A, E, R, I, S, E2, R2>(
|
|
2121
2129
|
self: Effect.Effect<A, E, R>,
|
|
2122
|
-
service: ServiceMap.
|
|
2130
|
+
service: ServiceMap.Key<I, S>,
|
|
2123
2131
|
acquire: Effect.Effect<S, E2, R2>
|
|
2124
2132
|
): Effect.Effect<A, E | E2, Exclude<R, I> | R2> =>
|
|
2125
2133
|
flatMap(acquire, (implementation) => provideService(self, service, implementation))
|
|
@@ -2203,19 +2211,12 @@ export const filterOrFail: {
|
|
|
2203
2211
|
predicate: Predicate.Predicate<NoInfer<A>>,
|
|
2204
2212
|
orFailWith: (a: NoInfer<A>) => E2
|
|
2205
2213
|
): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E2 | E, R>
|
|
2206
|
-
<A, B, X, E2>(
|
|
2207
|
-
filter: Filter.Filter<NoInfer<A>, B, X>,
|
|
2208
|
-
orFailWith: (x: X) => E2
|
|
2209
|
-
): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<B, E2 | E, R>
|
|
2210
2214
|
<A, B extends A>(
|
|
2211
2215
|
refinement: Predicate.Refinement<NoInfer<A>, B>
|
|
2212
2216
|
): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<B, Cause.NoSuchElementError | E, R>
|
|
2213
2217
|
<A>(
|
|
2214
2218
|
predicate: Predicate.Predicate<NoInfer<A>>
|
|
2215
2219
|
): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, Cause.NoSuchElementError | E, R>
|
|
2216
|
-
<A, B, X>(
|
|
2217
|
-
filter: Filter.Filter<NoInfer<A>, B, X>
|
|
2218
|
-
): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<B, Cause.NoSuchElementError | E, R>
|
|
2219
2220
|
<A, E, R, E2, B extends A>(
|
|
2220
2221
|
self: Effect.Effect<A, E, R>,
|
|
2221
2222
|
refinement: Predicate.Refinement<NoInfer<A>, B>,
|
|
@@ -2226,11 +2227,6 @@ export const filterOrFail: {
|
|
|
2226
2227
|
predicate: Predicate.Predicate<NoInfer<A>>,
|
|
2227
2228
|
orFailWith: (a: NoInfer<A>) => E2
|
|
2228
2229
|
): Effect.Effect<A, E2 | E, R>
|
|
2229
|
-
<A, E, R, B, X, E2>(
|
|
2230
|
-
self: Effect.Effect<A, E, R>,
|
|
2231
|
-
filter: Filter.Filter<A, B, X>,
|
|
2232
|
-
orFailWith: (x: X) => E2
|
|
2233
|
-
): Effect.Effect<B, E2 | E, R>
|
|
2234
2230
|
<A, E, R, B extends A>(
|
|
2235
2231
|
self: Effect.Effect<A, E, R>,
|
|
2236
2232
|
refinement: Predicate.Refinement<NoInfer<A>, B>
|
|
@@ -2239,18 +2235,14 @@ export const filterOrFail: {
|
|
|
2239
2235
|
self: Effect.Effect<A, E, R>,
|
|
2240
2236
|
predicate: Predicate.Predicate<NoInfer<A>>
|
|
2241
2237
|
): Effect.Effect<A, E | Cause.NoSuchElementError, R>
|
|
2242
|
-
<A, E, R, B, X>(
|
|
2243
|
-
self: Effect.Effect<A, E, R>,
|
|
2244
|
-
filter: Filter.Filter<A, B, X>
|
|
2245
|
-
): Effect.Effect<B, E | Cause.NoSuchElementError, R>
|
|
2246
2238
|
} = dual((args) => isEffect(args[0]), <A, E, R, E2>(
|
|
2247
2239
|
self: Effect.Effect<A, E, R>,
|
|
2248
|
-
|
|
2240
|
+
predicate: Predicate.Predicate<NoInfer<A>>,
|
|
2249
2241
|
orFailWith?: (a: any) => E2
|
|
2250
2242
|
): Effect.Effect<any, E | E2 | Cause.NoSuchElementError, R> =>
|
|
2251
2243
|
filterOrElse(
|
|
2252
2244
|
self,
|
|
2253
|
-
|
|
2245
|
+
predicate as any,
|
|
2254
2246
|
orFailWith ? (a: any) => fail(orFailWith(a)) : () => fail(new NoSuchElementError() as E2)
|
|
2255
2247
|
))
|
|
2256
2248
|
|
|
@@ -2400,27 +2392,55 @@ const OnFailureProto = makePrimitiveProto({
|
|
|
2400
2392
|
|
|
2401
2393
|
/** @internal */
|
|
2402
2394
|
export const catchCauseIf: {
|
|
2403
|
-
<E,
|
|
2404
|
-
|
|
2405
|
-
f: (
|
|
2395
|
+
<E, B, E2, R2>(
|
|
2396
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
2397
|
+
f: (cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2398
|
+
): <A, R>(
|
|
2399
|
+
self: Effect.Effect<A, E, R>
|
|
2400
|
+
) => Effect.Effect<A | B, E | E2, R | R2>
|
|
2401
|
+
<A, E, R, B, E2, R2>(
|
|
2402
|
+
self: Effect.Effect<A, E, R>,
|
|
2403
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
2404
|
+
f: (cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2405
|
+
): Effect.Effect<A | B, E | E2, R | R2>
|
|
2406
|
+
} = dual(
|
|
2407
|
+
3,
|
|
2408
|
+
<A, E, R, B, E2, R2>(
|
|
2409
|
+
self: Effect.Effect<A, E, R>,
|
|
2410
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
2411
|
+
f: (cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2412
|
+
): Effect.Effect<A | B, E | E2, R | R2> =>
|
|
2413
|
+
catchCause(self, (cause): Effect.Effect<B, E | E2, R2> => {
|
|
2414
|
+
if (!predicate(cause)) {
|
|
2415
|
+
return failCause(cause) as any
|
|
2416
|
+
}
|
|
2417
|
+
return internalCall(() => f(cause))
|
|
2418
|
+
})
|
|
2419
|
+
)
|
|
2420
|
+
|
|
2421
|
+
/** @internal */
|
|
2422
|
+
export const catchCauseFilter: {
|
|
2423
|
+
<E, B, E2, R2, EB, X extends Cause.Cause<any>>(
|
|
2424
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
2425
|
+
f: (failure: EB, cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2406
2426
|
): <A, R>(
|
|
2407
2427
|
self: Effect.Effect<A, E, R>
|
|
2408
|
-
) => Effect.Effect<A | B, Cause.Cause.Error<
|
|
2409
|
-
<A, E, R, B, E2, R2,
|
|
2428
|
+
) => Effect.Effect<A | B, Cause.Cause.Error<X> | E2, R | R2>
|
|
2429
|
+
<A, E, R, B, E2, R2, EB, X extends Cause.Cause<any>>(
|
|
2410
2430
|
self: Effect.Effect<A, E, R>,
|
|
2411
|
-
filter: Filter.
|
|
2412
|
-
f: (failure:
|
|
2413
|
-
): Effect.Effect<A | B, Cause.Cause.Error<
|
|
2431
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
2432
|
+
f: (failure: EB, cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2433
|
+
): Effect.Effect<A | B, Cause.Cause.Error<X> | E2, R | R2>
|
|
2414
2434
|
} = dual(
|
|
2415
2435
|
3,
|
|
2416
|
-
<A, E, R, B, E2, R2,
|
|
2417
|
-
self: Effect.Effect<A, E, R>,
|
|
2418
|
-
filter: Filter.
|
|
2419
|
-
f: (failure:
|
|
2420
|
-
): Effect.Effect<A | B, Cause.Cause.Error<
|
|
2421
|
-
catchCause(self, (cause): Effect.Effect<B, Cause.Cause.Error<
|
|
2422
|
-
const eb =
|
|
2423
|
-
return
|
|
2436
|
+
<A, E, R, B, E2, R2, EB, X extends Cause.Cause<any>>(
|
|
2437
|
+
self: Effect.Effect<A, E, R>,
|
|
2438
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
2439
|
+
f: (failure: EB, cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2440
|
+
): Effect.Effect<A | B, Cause.Cause.Error<X> | E2, R | R2> =>
|
|
2441
|
+
catchCause(self, (cause): Effect.Effect<B, Cause.Cause.Error<X> | E2, R2> => {
|
|
2442
|
+
const eb = filter(cause)
|
|
2443
|
+
return Result.isFailure(eb) ? failCause(eb.failure) : internalCall(() => f(eb.success, cause))
|
|
2424
2444
|
})
|
|
2425
2445
|
)
|
|
2426
2446
|
|
|
@@ -2438,7 +2458,7 @@ export const catch_: {
|
|
|
2438
2458
|
<A, E, R, B, E2, R2>(
|
|
2439
2459
|
self: Effect.Effect<A, E, R>,
|
|
2440
2460
|
f: (a: NoInfer<E>) => Effect.Effect<B, E2, R2>
|
|
2441
|
-
): Effect.Effect<A | B, E2, R | R2> =>
|
|
2461
|
+
): Effect.Effect<A | B, E2, R | R2> => catchCauseFilter(self, findError as any, (e: any) => f(e)) as any
|
|
2442
2462
|
)
|
|
2443
2463
|
|
|
2444
2464
|
/** @internal */
|
|
@@ -2469,7 +2489,7 @@ export const catchDefect: {
|
|
|
2469
2489
|
<A, E, R, B, E2, R2>(
|
|
2470
2490
|
self: Effect.Effect<A, E, R>,
|
|
2471
2491
|
f: (defect: unknown) => Effect.Effect<B, E2, R2>
|
|
2472
|
-
): Effect.Effect<A | B, E | E2, R | R2> =>
|
|
2492
|
+
): Effect.Effect<A | B, E | E2, R | R2> => catchCauseFilter(self, findDefect as any, f as any) as any
|
|
2473
2493
|
)
|
|
2474
2494
|
|
|
2475
2495
|
/** @internal */
|
|
@@ -2492,32 +2512,56 @@ export const tapCause: {
|
|
|
2492
2512
|
|
|
2493
2513
|
/** @internal */
|
|
2494
2514
|
export const tapCauseIf: {
|
|
2495
|
-
<E,
|
|
2496
|
-
|
|
2497
|
-
f: (
|
|
2515
|
+
<E, B, E2, R2>(
|
|
2516
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
2517
|
+
f: (cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2498
2518
|
): <A, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E | E2, R | R2>
|
|
2499
|
-
<A, E, R,
|
|
2519
|
+
<A, E, R, B, E2, R2>(
|
|
2500
2520
|
self: Effect.Effect<A, E, R>,
|
|
2501
|
-
|
|
2502
|
-
f: (
|
|
2521
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
2522
|
+
f: (cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2503
2523
|
): Effect.Effect<A, E | E2, R | R2>
|
|
2504
2524
|
} = dual(
|
|
2505
2525
|
3,
|
|
2506
|
-
<A, E, R,
|
|
2526
|
+
<A, E, R, B, E2, R2>(
|
|
2507
2527
|
self: Effect.Effect<A, E, R>,
|
|
2508
|
-
|
|
2509
|
-
f: (
|
|
2528
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
2529
|
+
f: (cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2510
2530
|
): Effect.Effect<A, E | E2, R | R2> =>
|
|
2511
2531
|
catchCauseIf(
|
|
2512
2532
|
self,
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
return Result.isFailure(result) ? Result.fail(cause) : result
|
|
2516
|
-
}) as any,
|
|
2517
|
-
(failure: any, cause: Cause.Cause<E>) => andThen(internalCall(() => f(failure, cause)), failCause(cause))
|
|
2533
|
+
predicate,
|
|
2534
|
+
(cause) => andThen(internalCall(() => f(cause)), failCause(cause))
|
|
2518
2535
|
)
|
|
2519
2536
|
)
|
|
2520
2537
|
|
|
2538
|
+
/** @internal */
|
|
2539
|
+
export const tapCauseFilter: {
|
|
2540
|
+
<E, B, E2, R2, EB, X extends Cause.Cause<any>>(
|
|
2541
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
2542
|
+
f: (a: EB, cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2543
|
+
): <A, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E | E2, R | R2>
|
|
2544
|
+
<A, E, R, B, E2, R2, EB, X extends Cause.Cause<any>>(
|
|
2545
|
+
self: Effect.Effect<A, E, R>,
|
|
2546
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
2547
|
+
f: (a: EB, cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2548
|
+
): Effect.Effect<A, E | E2, R | R2>
|
|
2549
|
+
} = dual(
|
|
2550
|
+
3,
|
|
2551
|
+
<A, E, R, B, E2, R2, EB, X extends Cause.Cause<any>>(
|
|
2552
|
+
self: Effect.Effect<A, E, R>,
|
|
2553
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
2554
|
+
f: (a: EB, cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2555
|
+
): Effect.Effect<A, E | E2, R | R2> =>
|
|
2556
|
+
catchCause(self, (cause) => {
|
|
2557
|
+
const result = filter(cause)
|
|
2558
|
+
if (Result.isFailure(result)) {
|
|
2559
|
+
return failCause(cause)
|
|
2560
|
+
}
|
|
2561
|
+
return andThen(internalCall(() => f(result.success, cause)), failCause(cause))
|
|
2562
|
+
})
|
|
2563
|
+
)
|
|
2564
|
+
|
|
2521
2565
|
/** @internal */
|
|
2522
2566
|
export const tapError: {
|
|
2523
2567
|
<E, B, E2, R2>(
|
|
@@ -2532,7 +2576,7 @@ export const tapError: {
|
|
|
2532
2576
|
<A, E, R, B, E2, R2>(
|
|
2533
2577
|
self: Effect.Effect<A, E, R>,
|
|
2534
2578
|
f: (e: NoInfer<E>) => Effect.Effect<B, E2, R2>
|
|
2535
|
-
): Effect.Effect<A, E | E2, R | R2> =>
|
|
2579
|
+
): Effect.Effect<A, E | E2, R | R2> => tapCauseFilter(self, findError as any, (e: any) => f(e)) as any
|
|
2536
2580
|
)
|
|
2537
2581
|
|
|
2538
2582
|
/** @internal */
|
|
@@ -2599,7 +2643,7 @@ export const tapDefect: {
|
|
|
2599
2643
|
<A, E, R, B, E2, R2>(
|
|
2600
2644
|
self: Effect.Effect<A, E, R>,
|
|
2601
2645
|
f: (defect: unknown) => Effect.Effect<B, E2, R2>
|
|
2602
|
-
): Effect.Effect<A, E | E2, R | R2> =>
|
|
2646
|
+
): Effect.Effect<A, E | E2, R | R2> => tapCauseFilter(self, findDefect as any, (_: any) => f(_)) as any
|
|
2603
2647
|
)
|
|
2604
2648
|
|
|
2605
2649
|
/** @internal */
|
|
@@ -2609,10 +2653,10 @@ export const catchIf: {
|
|
|
2609
2653
|
f: (e: EB) => Effect.Effect<A2, E2, R2>,
|
|
2610
2654
|
orElse?: ((e: Exclude<E, EB>) => Effect.Effect<A3, E3, R3>) | undefined
|
|
2611
2655
|
): <A, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
2612
|
-
<E,
|
|
2613
|
-
|
|
2614
|
-
f: (e:
|
|
2615
|
-
orElse?: ((e:
|
|
2656
|
+
<E, A2, E2, R2, A3 = never, E3 = E, R3 = never>(
|
|
2657
|
+
predicate: Predicate.Predicate<NoInfer<E>>,
|
|
2658
|
+
f: (e: NoInfer<E>) => Effect.Effect<A2, E2, R2>,
|
|
2659
|
+
orElse?: ((e: NoInfer<E>) => Effect.Effect<A3, E3, R3>) | undefined
|
|
2616
2660
|
): <A, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
2617
2661
|
<A, E, R, EB extends E, A2, E2, R2, A3 = never, E3 = Exclude<E, EB>, R3 = never>(
|
|
2618
2662
|
self: Effect.Effect<A, E, R>,
|
|
@@ -2620,28 +2664,59 @@ export const catchIf: {
|
|
|
2620
2664
|
f: (e: EB) => Effect.Effect<A2, E2, R2>,
|
|
2621
2665
|
orElse?: ((e: Exclude<E, EB>) => Effect.Effect<A3, E3, R3>) | undefined
|
|
2622
2666
|
): Effect.Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
2623
|
-
<A, E, R,
|
|
2667
|
+
<A, E, R, A2, E2, R2, A3 = never, E3 = E, R3 = never>(
|
|
2668
|
+
self: Effect.Effect<A, E, R>,
|
|
2669
|
+
predicate: Predicate.Predicate<E>,
|
|
2670
|
+
f: (e: E) => Effect.Effect<A2, E2, R2>,
|
|
2671
|
+
orElse?: ((e: E) => Effect.Effect<A3, E3, R3>) | undefined
|
|
2672
|
+
): Effect.Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
2673
|
+
} = dual(
|
|
2674
|
+
(args) => isEffect(args[0]),
|
|
2675
|
+
<A, E, R, A2, E2, R2, A3 = never, E3 = E, R3 = never>(
|
|
2676
|
+
self: Effect.Effect<A, E, R>,
|
|
2677
|
+
predicate: Predicate.Predicate<E>,
|
|
2678
|
+
f: (e: E) => Effect.Effect<A2, E2, R2>,
|
|
2679
|
+
orElse?: ((e: E) => Effect.Effect<A3, E3, R3>) | undefined
|
|
2680
|
+
): Effect.Effect<A | A2 | A3, E2 | E3, R | R2 | R3> =>
|
|
2681
|
+
catchCause(self, (cause): Effect.Effect<A2 | A3, E2 | E3, R2 | R3> => {
|
|
2682
|
+
const error = findError(cause)
|
|
2683
|
+
if (Result.isFailure(error)) return failCause(error.failure)
|
|
2684
|
+
if (!predicate(error.success)) {
|
|
2685
|
+
return orElse ? internalCall(() => orElse(error.success as any)) : failCause(cause as any as Cause.Cause<E3>)
|
|
2686
|
+
}
|
|
2687
|
+
return internalCall(() => f(error.success as any))
|
|
2688
|
+
})
|
|
2689
|
+
)
|
|
2690
|
+
|
|
2691
|
+
/** @internal */
|
|
2692
|
+
export const catchFilter: {
|
|
2693
|
+
<E, EB, A2, E2, R2, X, A3 = never, E3 = X, R3 = never>(
|
|
2694
|
+
filter: Filter.Filter<NoInfer<E>, EB, X>,
|
|
2695
|
+
f: (e: EB) => Effect.Effect<A2, E2, R2>,
|
|
2696
|
+
orElse?: ((e: X) => Effect.Effect<A3, E3, R3>) | undefined
|
|
2697
|
+
): <A, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
2698
|
+
<A, E, R, EB, A2, E2, R2, X, A3 = never, E3 = X, R3 = never>(
|
|
2624
2699
|
self: Effect.Effect<A, E, R>,
|
|
2625
|
-
filter: Filter.
|
|
2626
|
-
f: (e:
|
|
2627
|
-
orElse?: ((e:
|
|
2700
|
+
filter: Filter.Filter<NoInfer<E>, EB, X>,
|
|
2701
|
+
f: (e: EB) => Effect.Effect<A2, E2, R2>,
|
|
2702
|
+
orElse?: ((e: X) => Effect.Effect<A3, E3, R3>) | undefined
|
|
2628
2703
|
): Effect.Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
2629
2704
|
} = dual(
|
|
2630
2705
|
(args) => isEffect(args[0]),
|
|
2631
2706
|
<A, E, R, EB, A2, E2, R2, X, A3 = never, E3 = X, R3 = never>(
|
|
2632
2707
|
self: Effect.Effect<A, E, R>,
|
|
2633
|
-
filter: Filter.Filter<NoInfer<E>, EB, X
|
|
2708
|
+
filter: Filter.Filter<NoInfer<E>, EB, X>,
|
|
2634
2709
|
f: (e: EB) => Effect.Effect<A2, E2, R2>,
|
|
2635
2710
|
orElse?: ((e: X) => Effect.Effect<A3, E3, R3>) | undefined
|
|
2636
2711
|
): Effect.Effect<A | A2 | A3, E2 | E3, R | R2 | R3> =>
|
|
2637
2712
|
catchCause(self, (cause): Effect.Effect<A2 | A3, E2 | E3, R2 | R3> => {
|
|
2638
2713
|
const error = findError(cause)
|
|
2639
2714
|
if (Result.isFailure(error)) return failCause(error.failure)
|
|
2640
|
-
const result =
|
|
2715
|
+
const result = filter(error.success)
|
|
2641
2716
|
if (Result.isFailure(result)) {
|
|
2642
2717
|
return orElse ? internalCall(() => orElse(result.failure as any)) : failCause(cause as any as Cause.Cause<E3>)
|
|
2643
2718
|
}
|
|
2644
|
-
return internalCall(() => f(result.success
|
|
2719
|
+
return internalCall(() => f(result.success))
|
|
2645
2720
|
})
|
|
2646
2721
|
)
|
|
2647
2722
|
|
|
@@ -2777,7 +2852,7 @@ export const catchTags: {
|
|
|
2777
2852
|
>
|
|
2778
2853
|
} = dual((args) => isEffect(args[0]), (self: Effect.Effect<any, any, any>, cases: Record<string, any>, orElse: any) => {
|
|
2779
2854
|
let keys: Array<string>
|
|
2780
|
-
return
|
|
2855
|
+
return catchFilter(
|
|
2781
2856
|
self,
|
|
2782
2857
|
(e) => {
|
|
2783
2858
|
keys ??= Object.keys(cases)
|
|
@@ -2787,7 +2862,7 @@ export const catchTags: {
|
|
|
2787
2862
|
},
|
|
2788
2863
|
(e: any) => internalCall(() => cases[e["_tag"] as string](e)),
|
|
2789
2864
|
orElse
|
|
2790
|
-
)
|
|
2865
|
+
) as any
|
|
2791
2866
|
})
|
|
2792
2867
|
|
|
2793
2868
|
/** @internal */
|
|
@@ -2805,8 +2880,16 @@ export const catchReason: {
|
|
|
2805
2880
|
>(
|
|
2806
2881
|
errorTag: K,
|
|
2807
2882
|
reasonTag: RK,
|
|
2808
|
-
f: (
|
|
2809
|
-
|
|
2883
|
+
f: (
|
|
2884
|
+
reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK>,
|
|
2885
|
+
error: NarrowReason<ExtractTag<NoInfer<E>, K>, RK>
|
|
2886
|
+
) => Effect.Effect<A2, E2, R2>,
|
|
2887
|
+
orElse?:
|
|
2888
|
+
| ((
|
|
2889
|
+
reasons: ExcludeReason<ExtractTag<NoInfer<E>, K>, RK>,
|
|
2890
|
+
error: OmitReason<ExtractTag<NoInfer<E>, K>, RK>
|
|
2891
|
+
) => Effect.Effect<A3, E3, R3>)
|
|
2892
|
+
| undefined
|
|
2810
2893
|
): <A, R>(
|
|
2811
2894
|
self: Effect.Effect<A, E, R>
|
|
2812
2895
|
) => Effect.Effect<
|
|
@@ -2830,8 +2913,16 @@ export const catchReason: {
|
|
|
2830
2913
|
self: Effect.Effect<A, E, R>,
|
|
2831
2914
|
errorTag: K,
|
|
2832
2915
|
reasonTag: RK,
|
|
2833
|
-
f: (
|
|
2834
|
-
|
|
2916
|
+
f: (
|
|
2917
|
+
reason: ExtractReason<ExtractTag<E, K>, RK>,
|
|
2918
|
+
error: NarrowReason<ExtractTag<E, K>, RK>
|
|
2919
|
+
) => Effect.Effect<A2, E2, R2>,
|
|
2920
|
+
orElse?:
|
|
2921
|
+
| ((
|
|
2922
|
+
reasons: ExcludeReason<ExtractTag<E, K>, RK>,
|
|
2923
|
+
error: OmitReason<ExtractTag<E, K>, RK>
|
|
2924
|
+
) => Effect.Effect<A3, E3, R3>)
|
|
2925
|
+
| undefined
|
|
2835
2926
|
): Effect.Effect<
|
|
2836
2927
|
A | A2 | Exclude<A3, unassigned>,
|
|
2837
2928
|
(A3 extends unassigned ? E : ExcludeTag<E, K>) | E2 | E3,
|
|
@@ -2855,8 +2946,13 @@ export const catchReason: {
|
|
|
2855
2946
|
self: Effect.Effect<A, E, R>,
|
|
2856
2947
|
errorTag: K,
|
|
2857
2948
|
reasonTag: RK,
|
|
2858
|
-
f: (reason: ExtractReason<ExtractTag<E, K>, RK>) => Effect.Effect<A2, E2, R2>,
|
|
2859
|
-
orElse?:
|
|
2949
|
+
f: (reason: ExtractReason<ExtractTag<E, K>, RK>, error: ExtractTag<E, K>) => Effect.Effect<A2, E2, R2>,
|
|
2950
|
+
orElse?:
|
|
2951
|
+
| ((
|
|
2952
|
+
reasons: ExcludeReason<ExtractTag<E, K>, RK>,
|
|
2953
|
+
error: OmitReason<ExtractTag<E, K>, RK>
|
|
2954
|
+
) => Effect.Effect<A3, E3, R3>)
|
|
2955
|
+
| undefined
|
|
2860
2956
|
): Effect.Effect<
|
|
2861
2957
|
A | A2 | Exclude<A3, unassigned>,
|
|
2862
2958
|
(A3 extends unassigned ? E : ExcludeTag<E, K>) | E2 | E3,
|
|
@@ -2867,8 +2963,8 @@ export const catchReason: {
|
|
|
2867
2963
|
((e: any) => isTagged(e, errorTag) && hasProperty(e, "reason")) as any,
|
|
2868
2964
|
(e: any): Effect.Effect<A2 | A3, E | E2 | E3, R2 | R3> => {
|
|
2869
2965
|
const reason = e.reason as any
|
|
2870
|
-
if (isTagged(reason, reasonTag)) return f(reason as any)
|
|
2871
|
-
return orElse ? internalCall(() => orElse(reason)) : fail(e)
|
|
2966
|
+
if (isTagged(reason, reasonTag)) return f(reason as any, e)
|
|
2967
|
+
return orElse ? internalCall(() => orElse(reason, e)) : fail(e)
|
|
2872
2968
|
}
|
|
2873
2969
|
) as any
|
|
2874
2970
|
)
|
|
@@ -2880,7 +2976,8 @@ export const catchReasons: {
|
|
|
2880
2976
|
E,
|
|
2881
2977
|
Cases extends {
|
|
2882
2978
|
[RK in ReasonTags<ExtractTag<NoInfer<E>, K>>]+?: (
|
|
2883
|
-
reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK
|
|
2979
|
+
reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK>,
|
|
2980
|
+
error: NarrowReason<ExtractTag<NoInfer<E>, K>, RK>
|
|
2884
2981
|
) => Effect.Effect<any, any, any>
|
|
2885
2982
|
},
|
|
2886
2983
|
A2 = unassigned,
|
|
@@ -2891,7 +2988,8 @@ export const catchReasons: {
|
|
|
2891
2988
|
cases: Cases,
|
|
2892
2989
|
orElse?:
|
|
2893
2990
|
| ((
|
|
2894
|
-
reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string
|
|
2991
|
+
reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>,
|
|
2992
|
+
error: OmitReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>
|
|
2895
2993
|
) => Effect.Effect<A2, E2, R2>)
|
|
2896
2994
|
| undefined
|
|
2897
2995
|
): <A, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<
|
|
@@ -2918,7 +3016,8 @@ export const catchReasons: {
|
|
|
2918
3016
|
K extends Tags<E>,
|
|
2919
3017
|
Cases extends {
|
|
2920
3018
|
[RK in ReasonTags<ExtractTag<E, K>>]+?: (
|
|
2921
|
-
reason: ExtractReason<ExtractTag<E, K>, RK
|
|
3019
|
+
reason: ExtractReason<ExtractTag<E, K>, RK>,
|
|
3020
|
+
error: NarrowReason<ExtractTag<E, K>, RK>
|
|
2922
3021
|
) => Effect.Effect<any, any, any>
|
|
2923
3022
|
},
|
|
2924
3023
|
A2 = unassigned,
|
|
@@ -2930,7 +3029,8 @@ export const catchReasons: {
|
|
|
2930
3029
|
cases: Cases,
|
|
2931
3030
|
orElse?:
|
|
2932
3031
|
| ((
|
|
2933
|
-
reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string
|
|
3032
|
+
reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>,
|
|
3033
|
+
error: OmitReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>
|
|
2934
3034
|
) => Effect.Effect<A2, E2, R2>)
|
|
2935
3035
|
| undefined
|
|
2936
3036
|
): Effect.Effect<
|
|
@@ -2963,9 +3063,9 @@ export const catchReasons: {
|
|
|
2963
3063
|
const reason = e.reason
|
|
2964
3064
|
keys ??= Object.keys(cases)
|
|
2965
3065
|
if (keys.includes(reason._tag)) {
|
|
2966
|
-
return internalCall(() => (cases as any)[reason._tag](reason))
|
|
3066
|
+
return internalCall(() => (cases as any)[reason._tag](reason, e))
|
|
2967
3067
|
}
|
|
2968
|
-
return orElse ? internalCall(() => orElse(reason)) : fail(e)
|
|
3068
|
+
return orElse ? internalCall(() => orElse(reason, e)) : fail(e)
|
|
2969
3069
|
}
|
|
2970
3070
|
)
|
|
2971
3071
|
})
|
|
@@ -2998,7 +3098,7 @@ export const unwrapReason: {
|
|
|
2998
3098
|
self: Effect.Effect<A, E, R>,
|
|
2999
3099
|
errorTag: K
|
|
3000
3100
|
): Effect.Effect<A, ExcludeTag<E, K> | ReasonOf<ExtractTag<E, K>>, R> =>
|
|
3001
|
-
|
|
3101
|
+
catchFilter(
|
|
3002
3102
|
self,
|
|
3003
3103
|
(e: any) => {
|
|
3004
3104
|
if (isTagged(e, errorTag) && hasProperty(e, "reason")) {
|
|
@@ -3007,7 +3107,7 @@ export const unwrapReason: {
|
|
|
3007
3107
|
return Result.fail(e)
|
|
3008
3108
|
},
|
|
3009
3109
|
fail as any
|
|
3010
|
-
)
|
|
3110
|
+
) as any
|
|
3011
3111
|
)
|
|
3012
3112
|
|
|
3013
3113
|
/** @internal */
|
|
@@ -3091,14 +3191,17 @@ export const eventually = <A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect
|
|
|
3091
3191
|
/** @internal */
|
|
3092
3192
|
export const ignore: <
|
|
3093
3193
|
Arg extends Effect.Effect<any, any, any> | {
|
|
3094
|
-
readonly log?: boolean | LogLevel.
|
|
3194
|
+
readonly log?: boolean | LogLevel.Severity | undefined
|
|
3195
|
+
readonly message?: string | undefined
|
|
3095
3196
|
} | undefined = {
|
|
3096
|
-
readonly log?: boolean | LogLevel.
|
|
3197
|
+
readonly log?: boolean | LogLevel.Severity | undefined
|
|
3198
|
+
readonly message?: string | undefined
|
|
3097
3199
|
}
|
|
3098
3200
|
>(
|
|
3099
3201
|
effectOrOptions: Arg,
|
|
3100
3202
|
options?: {
|
|
3101
|
-
readonly log?: boolean | LogLevel.
|
|
3203
|
+
readonly log?: boolean | LogLevel.Severity | undefined
|
|
3204
|
+
readonly message?: string | undefined
|
|
3102
3205
|
} | undefined
|
|
3103
3206
|
) => [Arg] extends [Effect.Effect<infer _A, infer _E, infer _R>] ? Effect.Effect<void, never, _R>
|
|
3104
3207
|
: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<void, never, R> = dual(
|
|
@@ -3106,7 +3209,8 @@ export const ignore: <
|
|
|
3106
3209
|
<A, E, R>(
|
|
3107
3210
|
self: Effect.Effect<A, E, R>,
|
|
3108
3211
|
options?: {
|
|
3109
|
-
readonly log?: boolean | LogLevel.
|
|
3212
|
+
readonly log?: boolean | LogLevel.Severity | undefined
|
|
3213
|
+
readonly message?: string | undefined
|
|
3110
3214
|
} | undefined
|
|
3111
3215
|
): Effect.Effect<void, never, R> => {
|
|
3112
3216
|
if (!options?.log) {
|
|
@@ -3116,7 +3220,11 @@ export const ignore: <
|
|
|
3116
3220
|
return matchCauseEffect(self, {
|
|
3117
3221
|
onFailure(cause) {
|
|
3118
3222
|
const failure = findFail(cause)
|
|
3119
|
-
return Result.isFailure(failure)
|
|
3223
|
+
return Result.isFailure(failure)
|
|
3224
|
+
? failCause(failure.failure)
|
|
3225
|
+
: options.message === undefined
|
|
3226
|
+
? logEffect(cause)
|
|
3227
|
+
: logEffect(options.message, cause)
|
|
3120
3228
|
},
|
|
3121
3229
|
onSuccess: (_) => void_
|
|
3122
3230
|
})
|
|
@@ -3126,14 +3234,17 @@ export const ignore: <
|
|
|
3126
3234
|
/** @internal */
|
|
3127
3235
|
export const ignoreCause: <
|
|
3128
3236
|
Arg extends Effect.Effect<any, any, any> | {
|
|
3129
|
-
readonly log?: boolean | LogLevel.
|
|
3237
|
+
readonly log?: boolean | LogLevel.Severity | undefined
|
|
3238
|
+
readonly message?: string | undefined
|
|
3130
3239
|
} | undefined = {
|
|
3131
|
-
readonly log?: boolean | LogLevel.
|
|
3240
|
+
readonly log?: boolean | LogLevel.Severity | undefined
|
|
3241
|
+
readonly message?: string | undefined
|
|
3132
3242
|
}
|
|
3133
3243
|
>(
|
|
3134
3244
|
effectOrOptions: Arg,
|
|
3135
3245
|
options?: {
|
|
3136
|
-
readonly log?: boolean | LogLevel.
|
|
3246
|
+
readonly log?: boolean | LogLevel.Severity | undefined
|
|
3247
|
+
readonly message?: string | undefined
|
|
3137
3248
|
} | undefined
|
|
3138
3249
|
) => [Arg] extends [Effect.Effect<infer _A, infer _E, infer _R>] ? Effect.Effect<void, never, _R>
|
|
3139
3250
|
: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<void, never, R> = dual(
|
|
@@ -3141,14 +3252,18 @@ export const ignoreCause: <
|
|
|
3141
3252
|
<A, E, R>(
|
|
3142
3253
|
self: Effect.Effect<A, E, R>,
|
|
3143
3254
|
options?: {
|
|
3144
|
-
readonly log?: boolean | LogLevel.
|
|
3255
|
+
readonly log?: boolean | LogLevel.Severity | undefined
|
|
3256
|
+
readonly message?: string | undefined
|
|
3145
3257
|
} | undefined
|
|
3146
3258
|
): Effect.Effect<void, never, R> => {
|
|
3147
3259
|
if (!options?.log) {
|
|
3148
3260
|
return matchCauseEffect(self, { onFailure: (_) => void_, onSuccess: (_) => void_ })
|
|
3149
3261
|
}
|
|
3150
3262
|
const logEffect = logWithLevel(options.log === true ? undefined : options.log)
|
|
3151
|
-
return matchCauseEffect(self, {
|
|
3263
|
+
return matchCauseEffect(self, {
|
|
3264
|
+
onFailure: (cause) => options.message === undefined ? logEffect(cause) : logEffect(options.message, cause),
|
|
3265
|
+
onSuccess: (_) => void_
|
|
3266
|
+
})
|
|
3152
3267
|
}
|
|
3153
3268
|
)
|
|
3154
3269
|
|
|
@@ -3403,33 +3518,33 @@ export const isSuccess: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect
|
|
|
3403
3518
|
/** @internal */
|
|
3404
3519
|
export const delay: {
|
|
3405
3520
|
(
|
|
3406
|
-
duration: Duration.
|
|
3521
|
+
duration: Duration.Input
|
|
3407
3522
|
): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
|
|
3408
3523
|
<A, E, R>(
|
|
3409
3524
|
self: Effect.Effect<A, E, R>,
|
|
3410
|
-
duration: Duration.
|
|
3525
|
+
duration: Duration.Input
|
|
3411
3526
|
): Effect.Effect<A, E, R>
|
|
3412
3527
|
} = dual(
|
|
3413
3528
|
2,
|
|
3414
3529
|
<A, E, R>(
|
|
3415
3530
|
self: Effect.Effect<A, E, R>,
|
|
3416
|
-
duration: Duration.
|
|
3531
|
+
duration: Duration.Input
|
|
3417
3532
|
): Effect.Effect<A, E, R> => andThen(sleep(duration), self)
|
|
3418
3533
|
)
|
|
3419
3534
|
|
|
3420
3535
|
/** @internal */
|
|
3421
3536
|
export const timeoutOrElse: {
|
|
3422
3537
|
<A2, E2, R2>(options: {
|
|
3423
|
-
readonly duration: Duration.
|
|
3424
|
-
readonly
|
|
3538
|
+
readonly duration: Duration.Input
|
|
3539
|
+
readonly orElse: LazyArg<Effect.Effect<A2, E2, R2>>
|
|
3425
3540
|
}): <A, E, R>(
|
|
3426
3541
|
self: Effect.Effect<A, E, R>
|
|
3427
3542
|
) => Effect.Effect<A | A2, E | E2, R | R2>
|
|
3428
3543
|
<A, E, R, A2, E2, R2>(
|
|
3429
3544
|
self: Effect.Effect<A, E, R>,
|
|
3430
3545
|
options: {
|
|
3431
|
-
readonly duration: Duration.
|
|
3432
|
-
readonly
|
|
3546
|
+
readonly duration: Duration.Input
|
|
3547
|
+
readonly orElse: LazyArg<Effect.Effect<A2, E2, R2>>
|
|
3433
3548
|
}
|
|
3434
3549
|
): Effect.Effect<A | A2, E | E2, R | R2>
|
|
3435
3550
|
} = dual(
|
|
@@ -3437,55 +3552,55 @@ export const timeoutOrElse: {
|
|
|
3437
3552
|
<A, E, R, A2, E2, R2>(
|
|
3438
3553
|
self: Effect.Effect<A, E, R>,
|
|
3439
3554
|
options: {
|
|
3440
|
-
readonly duration: Duration.
|
|
3441
|
-
readonly
|
|
3555
|
+
readonly duration: Duration.Input
|
|
3556
|
+
readonly orElse: LazyArg<Effect.Effect<A2, E2, R2>>
|
|
3442
3557
|
}
|
|
3443
3558
|
): Effect.Effect<A | A2, E | E2, R | R2> =>
|
|
3444
3559
|
raceFirst(
|
|
3445
3560
|
self,
|
|
3446
|
-
flatMap(sleep(options.duration), options.
|
|
3561
|
+
flatMap(sleep(options.duration), options.orElse)
|
|
3447
3562
|
)
|
|
3448
3563
|
)
|
|
3449
3564
|
|
|
3450
3565
|
/** @internal */
|
|
3451
3566
|
export const timeout: {
|
|
3452
3567
|
(
|
|
3453
|
-
duration: Duration.
|
|
3568
|
+
duration: Duration.Input
|
|
3454
3569
|
): <A, E, R>(
|
|
3455
3570
|
self: Effect.Effect<A, E, R>
|
|
3456
3571
|
) => Effect.Effect<A, E | Cause.TimeoutError, R>
|
|
3457
3572
|
<A, E, R>(
|
|
3458
3573
|
self: Effect.Effect<A, E, R>,
|
|
3459
|
-
duration: Duration.
|
|
3574
|
+
duration: Duration.Input
|
|
3460
3575
|
): Effect.Effect<A, E | Cause.TimeoutError, R>
|
|
3461
3576
|
} = dual(
|
|
3462
3577
|
2,
|
|
3463
3578
|
<A, E, R>(
|
|
3464
3579
|
self: Effect.Effect<A, E, R>,
|
|
3465
|
-
duration: Duration.
|
|
3580
|
+
duration: Duration.Input
|
|
3466
3581
|
): Effect.Effect<A, E | TimeoutError, R> =>
|
|
3467
3582
|
timeoutOrElse(self, {
|
|
3468
3583
|
duration,
|
|
3469
|
-
|
|
3584
|
+
orElse: () => fail(new TimeoutError())
|
|
3470
3585
|
})
|
|
3471
3586
|
)
|
|
3472
3587
|
|
|
3473
3588
|
/** @internal */
|
|
3474
3589
|
export const timeoutOption: {
|
|
3475
3590
|
(
|
|
3476
|
-
duration: Duration.
|
|
3591
|
+
duration: Duration.Input
|
|
3477
3592
|
): <A, E, R>(
|
|
3478
3593
|
self: Effect.Effect<A, E, R>
|
|
3479
3594
|
) => Effect.Effect<Option.Option<A>, E, R>
|
|
3480
3595
|
<A, E, R>(
|
|
3481
3596
|
self: Effect.Effect<A, E, R>,
|
|
3482
|
-
duration: Duration.
|
|
3597
|
+
duration: Duration.Input
|
|
3483
3598
|
): Effect.Effect<Option.Option<A>, E, R>
|
|
3484
3599
|
} = dual(
|
|
3485
3600
|
2,
|
|
3486
3601
|
<A, E, R>(
|
|
3487
3602
|
self: Effect.Effect<A, E, R>,
|
|
3488
|
-
duration: Duration.
|
|
3603
|
+
duration: Duration.Input
|
|
3489
3604
|
): Effect.Effect<Option.Option<A>, E, R> =>
|
|
3490
3605
|
raceFirst(
|
|
3491
3606
|
asSome(self),
|
|
@@ -3646,11 +3761,11 @@ export const provideScope: {
|
|
|
3646
3761
|
/** @internal */
|
|
3647
3762
|
export const scoped = <A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect<A, E, Exclude<R, Scope.Scope>> =>
|
|
3648
3763
|
withFiber((fiber) => {
|
|
3649
|
-
const prev =
|
|
3764
|
+
const prev = fiber.services
|
|
3650
3765
|
const scope = scopeMakeUnsafe()
|
|
3651
3766
|
fiber.setServices(ServiceMap.add(fiber.services, scopeTag, scope))
|
|
3652
3767
|
return onExitPrimitive(self, (exit) => {
|
|
3653
|
-
fiber.setServices(
|
|
3768
|
+
fiber.setServices(prev)
|
|
3654
3769
|
return scopeCloseUnsafe(scope, exit)
|
|
3655
3770
|
})
|
|
3656
3771
|
}) as any
|
|
@@ -3677,13 +3792,22 @@ export const scopedWith = <A, E, R>(
|
|
|
3677
3792
|
})
|
|
3678
3793
|
|
|
3679
3794
|
/** @internal */
|
|
3680
|
-
export const acquireRelease = <A, E, R>(
|
|
3795
|
+
export const acquireRelease = <A, E, R, R2>(
|
|
3681
3796
|
acquire: Effect.Effect<A, E, R>,
|
|
3682
|
-
release: (a: A, exit: Exit.Exit<unknown, unknown>) => Effect.Effect<unknown
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3797
|
+
release: (a: A, exit: Exit.Exit<unknown, unknown>) => Effect.Effect<unknown, never, R2>,
|
|
3798
|
+
options?: { readonly interruptible?: boolean }
|
|
3799
|
+
): Effect.Effect<A, E, R | R2 | Scope.Scope> =>
|
|
3800
|
+
servicesWith((services: ServiceMap.ServiceMap<R2>) =>
|
|
3801
|
+
uninterruptibleMask((restore) =>
|
|
3802
|
+
flatMap(
|
|
3803
|
+
scope,
|
|
3804
|
+
(scope) =>
|
|
3805
|
+
tap(
|
|
3806
|
+
options?.interruptible ? restore(acquire) : acquire,
|
|
3807
|
+
(a) => scopeAddFinalizerExit(scope, (exit) => provideServices(release(a, exit), services))
|
|
3808
|
+
)
|
|
3809
|
+
)
|
|
3810
|
+
)
|
|
3687
3811
|
)
|
|
3688
3812
|
|
|
3689
3813
|
/** @internal */
|
|
@@ -3758,34 +3882,51 @@ export const ensuring: {
|
|
|
3758
3882
|
|
|
3759
3883
|
/** @internal */
|
|
3760
3884
|
export const onExitIf: {
|
|
3761
|
-
<A, E, XE, XR
|
|
3762
|
-
|
|
3763
|
-
f: (
|
|
3764
|
-
pass: Filter.Pass<Exit.Exit<NoInfer<A>, NoInfer<E>>, Result>,
|
|
3765
|
-
exit: Exit.Exit<NoInfer<A>, NoInfer<E>>
|
|
3766
|
-
) => Effect.Effect<void, XE, XR>
|
|
3885
|
+
<A, E, XE, XR>(
|
|
3886
|
+
predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>,
|
|
3887
|
+
f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect.Effect<void, XE, XR>
|
|
3767
3888
|
): <R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E | XE, R | XR>
|
|
3768
|
-
<A, E, R, XE, XR
|
|
3889
|
+
<A, E, R, XE, XR>(
|
|
3769
3890
|
self: Effect.Effect<A, E, R>,
|
|
3770
|
-
|
|
3771
|
-
f: (
|
|
3772
|
-
pass: Filter.Pass<Exit.Exit<NoInfer<A>, NoInfer<E>>, Result>,
|
|
3773
|
-
exit: Exit.Exit<NoInfer<A>, NoInfer<E>>
|
|
3774
|
-
) => Effect.Effect<void, XE, XR>
|
|
3891
|
+
predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>,
|
|
3892
|
+
f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect.Effect<void, XE, XR>
|
|
3775
3893
|
): Effect.Effect<A, E | XE, R | XR>
|
|
3776
3894
|
} = dual(
|
|
3777
3895
|
3,
|
|
3778
|
-
<A, E, R, XE, XR
|
|
3896
|
+
<A, E, R, XE, XR>(
|
|
3779
3897
|
self: Effect.Effect<A, E, R>,
|
|
3780
|
-
|
|
3781
|
-
f: (
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3898
|
+
predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>,
|
|
3899
|
+
f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect.Effect<void, XE, XR>
|
|
3900
|
+
): Effect.Effect<A, E | XE, R | XR> =>
|
|
3901
|
+
onExit(self, (exit) => {
|
|
3902
|
+
if (!predicate(exit)) {
|
|
3903
|
+
return void_
|
|
3904
|
+
}
|
|
3905
|
+
return f(exit)
|
|
3906
|
+
})
|
|
3907
|
+
)
|
|
3908
|
+
|
|
3909
|
+
/** @internal */
|
|
3910
|
+
export const onExitFilter: {
|
|
3911
|
+
<A, E, XE, XR, B, X>(
|
|
3912
|
+
filter: Filter.Filter<Exit.Exit<NoInfer<A>, NoInfer<E>>, B, X>,
|
|
3913
|
+
f: (b: B, exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect.Effect<void, XE, XR>
|
|
3914
|
+
): <R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E | XE, R | XR>
|
|
3915
|
+
<A, E, R, XE, XR, B, X>(
|
|
3916
|
+
self: Effect.Effect<A, E, R>,
|
|
3917
|
+
filter: Filter.Filter<Exit.Exit<NoInfer<A>, NoInfer<E>>, B, X>,
|
|
3918
|
+
f: (b: B, exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect.Effect<void, XE, XR>
|
|
3919
|
+
): Effect.Effect<A, E | XE, R | XR>
|
|
3920
|
+
} = dual(
|
|
3921
|
+
3,
|
|
3922
|
+
<A, E, R, XE, XR, B, X>(
|
|
3923
|
+
self: Effect.Effect<A, E, R>,
|
|
3924
|
+
filter: Filter.Filter<Exit.Exit<NoInfer<A>, NoInfer<E>>, B, X>,
|
|
3925
|
+
f: (b: B, exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect.Effect<void, XE, XR>
|
|
3785
3926
|
): Effect.Effect<A, E | XE, R | XR> =>
|
|
3786
3927
|
onExit(self, (exit) => {
|
|
3787
|
-
const
|
|
3788
|
-
return Result.isFailure(
|
|
3928
|
+
const b = filter(exit)
|
|
3929
|
+
return Result.isFailure(b) ? void_ : f(b.success, exit)
|
|
3789
3930
|
})
|
|
3790
3931
|
)
|
|
3791
3932
|
|
|
@@ -3803,37 +3944,66 @@ export const onError: {
|
|
|
3803
3944
|
<A, E, R, XE, XR>(
|
|
3804
3945
|
self: Effect.Effect<A, E, R>,
|
|
3805
3946
|
f: (cause: Cause.Cause<NoInfer<E>>) => Effect.Effect<void, XE, XR>
|
|
3806
|
-
): Effect.Effect<A, E | XE, R | XR> =>
|
|
3947
|
+
): Effect.Effect<A, E | XE, R | XR> => onExitFilter(self, exitFilterCause as any, f as any) as any
|
|
3807
3948
|
)
|
|
3808
3949
|
|
|
3809
3950
|
/** @internal */
|
|
3810
3951
|
export const onErrorIf: {
|
|
3811
|
-
<E,
|
|
3812
|
-
|
|
3813
|
-
f: (
|
|
3952
|
+
<E, XE, XR>(
|
|
3953
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
3954
|
+
f: (cause: Cause.Cause<E>) => Effect.Effect<void, XE, XR>
|
|
3814
3955
|
): <A, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E | XE, R | XR>
|
|
3815
|
-
<A, E, R, XE, XR
|
|
3956
|
+
<A, E, R, XE, XR>(
|
|
3816
3957
|
self: Effect.Effect<A, E, R>,
|
|
3817
|
-
|
|
3818
|
-
f: (
|
|
3958
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
3959
|
+
f: (cause: Cause.Cause<E>) => Effect.Effect<void, XE, XR>
|
|
3819
3960
|
): Effect.Effect<A, E | XE, R | XR>
|
|
3820
3961
|
} = dual(
|
|
3821
3962
|
3,
|
|
3822
|
-
<A, E, R, XE, XR
|
|
3963
|
+
<A, E, R, XE, XR>(
|
|
3823
3964
|
self: Effect.Effect<A, E, R>,
|
|
3824
|
-
|
|
3825
|
-
f: (
|
|
3965
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
3966
|
+
f: (cause: Cause.Cause<E>) => Effect.Effect<void, XE, XR>
|
|
3826
3967
|
): Effect.Effect<A, E | XE, R | XR> =>
|
|
3827
3968
|
onExitIf(
|
|
3828
3969
|
self,
|
|
3829
|
-
(
|
|
3830
|
-
if (exit._tag !== "Failure")
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3970
|
+
(exit): exit is Exit.Failure<A, E> => {
|
|
3971
|
+
if (exit._tag !== "Failure") {
|
|
3972
|
+
return false
|
|
3973
|
+
}
|
|
3974
|
+
return predicate(exit.cause)
|
|
3975
|
+
},
|
|
3976
|
+
(exit) => f((exit as Exit.Failure<A, E>).cause)
|
|
3834
3977
|
) as any
|
|
3835
3978
|
)
|
|
3836
3979
|
|
|
3980
|
+
/** @internal */
|
|
3981
|
+
export const onErrorFilter: {
|
|
3982
|
+
<A, E, EB, X, XE, XR>(
|
|
3983
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
3984
|
+
f: (failure: EB, cause: Cause.Cause<E>) => Effect.Effect<void, XE, XR>
|
|
3985
|
+
): <R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E | XE, R | XR>
|
|
3986
|
+
<A, E, R, EB, X, XE, XR>(
|
|
3987
|
+
self: Effect.Effect<A, E, R>,
|
|
3988
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
3989
|
+
f: (failure: EB, cause: Cause.Cause<E>) => Effect.Effect<void, XE, XR>
|
|
3990
|
+
): Effect.Effect<A, E | XE, R | XR>
|
|
3991
|
+
} = dual(
|
|
3992
|
+
3,
|
|
3993
|
+
<A, E, R, EB, X, XE, XR>(
|
|
3994
|
+
self: Effect.Effect<A, E, R>,
|
|
3995
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
3996
|
+
f: (failure: EB, cause: Cause.Cause<E>) => Effect.Effect<void, XE, XR>
|
|
3997
|
+
): Effect.Effect<A, E | XE, R | XR> =>
|
|
3998
|
+
onExit(self, (exit) => {
|
|
3999
|
+
if (exit._tag !== "Failure") {
|
|
4000
|
+
return void_
|
|
4001
|
+
}
|
|
4002
|
+
const result = filter(exit.cause)
|
|
4003
|
+
return Result.isFailure(result) ? void_ : f(result.success, exit.cause)
|
|
4004
|
+
})
|
|
4005
|
+
)
|
|
4006
|
+
|
|
3837
4007
|
/** @internal */
|
|
3838
4008
|
export const onInterrupt: {
|
|
3839
4009
|
<XE, XR>(
|
|
@@ -3848,8 +4018,7 @@ export const onInterrupt: {
|
|
|
3848
4018
|
<A, E, R, XE, XR>(
|
|
3849
4019
|
self: Effect.Effect<A, E, R>,
|
|
3850
4020
|
finalizer: (interruptors: ReadonlySet<number>) => Effect.Effect<void, XE, XR>
|
|
3851
|
-
): Effect.Effect<A, E | XE, R | XR> =>
|
|
3852
|
-
onErrorIf<E, Result.Result<Set<number>, Cause.Cause<E>>, XE, XR>(causeFilterInterruptors, finalizer)(self)
|
|
4021
|
+
): Effect.Effect<A, E | XE, R | XR> => onErrorFilter(causeFilterInterruptors as any, finalizer)(self) as any
|
|
3853
4022
|
)
|
|
3854
4023
|
|
|
3855
4024
|
/** @internal */
|
|
@@ -3873,19 +4042,19 @@ export const acquireUseRelease = <Resource, E, R, A, E2, R2, E3, R3>(
|
|
|
3873
4042
|
|
|
3874
4043
|
/** @internal */
|
|
3875
4044
|
export const cachedInvalidateWithTTL: {
|
|
3876
|
-
(timeToLive: Duration.
|
|
4045
|
+
(timeToLive: Duration.Input): <A, E, R>(
|
|
3877
4046
|
self: Effect.Effect<A, E, R>
|
|
3878
4047
|
) => Effect.Effect<[Effect.Effect<A, E, R>, Effect.Effect<void>]>
|
|
3879
4048
|
<A, E, R>(
|
|
3880
4049
|
self: Effect.Effect<A, E, R>,
|
|
3881
|
-
timeToLive: Duration.
|
|
4050
|
+
timeToLive: Duration.Input
|
|
3882
4051
|
): Effect.Effect<[Effect.Effect<A, E, R>, Effect.Effect<void>]>
|
|
3883
4052
|
} = dual(2, <A, E, R>(
|
|
3884
4053
|
self: Effect.Effect<A, E, R>,
|
|
3885
|
-
ttl: Duration.
|
|
4054
|
+
ttl: Duration.Input
|
|
3886
4055
|
): Effect.Effect<[Effect.Effect<A, E, R>, Effect.Effect<void>]> =>
|
|
3887
4056
|
sync(() => {
|
|
3888
|
-
const ttlMillis = Duration.toMillis(Duration.
|
|
4057
|
+
const ttlMillis = Duration.toMillis(Duration.fromInputUnsafe(ttl))
|
|
3889
4058
|
const isFinite = Number.isFinite(ttlMillis)
|
|
3890
4059
|
const latch = makeLatchUnsafe(false)
|
|
3891
4060
|
let expiresAt = 0
|
|
@@ -3894,7 +4063,8 @@ export const cachedInvalidateWithTTL: {
|
|
|
3894
4063
|
const wait = flatMap(latch.await, () => exit!)
|
|
3895
4064
|
return [
|
|
3896
4065
|
withFiber((fiber) => {
|
|
3897
|
-
const
|
|
4066
|
+
const clock = fiber.getRef(ClockRef)
|
|
4067
|
+
const now = isFinite ? clock.currentTimeMillisUnsafe() : 0
|
|
3898
4068
|
if (running || now < expiresAt) return exit ?? wait
|
|
3899
4069
|
running = true
|
|
3900
4070
|
latch.closeUnsafe()
|
|
@@ -3902,7 +4072,7 @@ export const cachedInvalidateWithTTL: {
|
|
|
3902
4072
|
return onExit(self, (exit_) =>
|
|
3903
4073
|
sync(() => {
|
|
3904
4074
|
running = false
|
|
3905
|
-
expiresAt =
|
|
4075
|
+
expiresAt = clock.currentTimeMillisUnsafe() + ttlMillis
|
|
3906
4076
|
exit = exit_
|
|
3907
4077
|
latch.openUnsafe()
|
|
3908
4078
|
}))
|
|
@@ -3918,17 +4088,17 @@ export const cachedInvalidateWithTTL: {
|
|
|
3918
4088
|
/** @internal */
|
|
3919
4089
|
export const cachedWithTTL: {
|
|
3920
4090
|
(
|
|
3921
|
-
timeToLive: Duration.
|
|
4091
|
+
timeToLive: Duration.Input
|
|
3922
4092
|
): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<Effect.Effect<A, E, R>>
|
|
3923
4093
|
<A, E, R>(
|
|
3924
4094
|
self: Effect.Effect<A, E, R>,
|
|
3925
|
-
timeToLive: Duration.
|
|
4095
|
+
timeToLive: Duration.Input
|
|
3926
4096
|
): Effect.Effect<Effect.Effect<A, E, R>>
|
|
3927
4097
|
} = dual(
|
|
3928
4098
|
2,
|
|
3929
4099
|
<A, E, R>(
|
|
3930
4100
|
self: Effect.Effect<A, E, R>,
|
|
3931
|
-
timeToLive: Duration.
|
|
4101
|
+
timeToLive: Duration.Input
|
|
3932
4102
|
): Effect.Effect<Effect.Effect<A, E, R>> => map(cachedInvalidateWithTTL(self, timeToLive), (tuple) => tuple[0])
|
|
3933
4103
|
)
|
|
3934
4104
|
|
|
@@ -4074,10 +4244,147 @@ export const partition: {
|
|
|
4074
4244
|
): Effect.Effect<[excluded: Array<E>, satisfying: Array<B>], never, R> =>
|
|
4075
4245
|
map(
|
|
4076
4246
|
forEach(elements, (a, i) => result(f(a, i)), options),
|
|
4077
|
-
(results) => Arr.
|
|
4247
|
+
(results) => Arr.partition(results, identity)
|
|
4248
|
+
)
|
|
4249
|
+
)
|
|
4250
|
+
|
|
4251
|
+
/** @internal */
|
|
4252
|
+
export const validate: {
|
|
4253
|
+
<A, B, E, R>(
|
|
4254
|
+
f: (a: A, i: number) => Effect.Effect<B, E, R>,
|
|
4255
|
+
options?: {
|
|
4256
|
+
readonly concurrency?: Concurrency | undefined
|
|
4257
|
+
readonly discard?: false | undefined
|
|
4258
|
+
} | undefined
|
|
4259
|
+
): (elements: Iterable<A>) => Effect.Effect<Array<B>, Arr.NonEmptyArray<E>, R>
|
|
4260
|
+
<A, B, E, R>(
|
|
4261
|
+
f: (a: A, i: number) => Effect.Effect<B, E, R>,
|
|
4262
|
+
options: {
|
|
4263
|
+
readonly concurrency?: Concurrency | undefined
|
|
4264
|
+
readonly discard: true
|
|
4265
|
+
}
|
|
4266
|
+
): (elements: Iterable<A>) => Effect.Effect<void, Arr.NonEmptyArray<E>, R>
|
|
4267
|
+
<A, B, E, R>(
|
|
4268
|
+
elements: Iterable<A>,
|
|
4269
|
+
f: (a: A, i: number) => Effect.Effect<B, E, R>,
|
|
4270
|
+
options?: {
|
|
4271
|
+
readonly concurrency?: Concurrency | undefined
|
|
4272
|
+
readonly discard?: false | undefined
|
|
4273
|
+
} | undefined
|
|
4274
|
+
): Effect.Effect<Array<B>, Arr.NonEmptyArray<E>, R>
|
|
4275
|
+
<A, B, E, R>(
|
|
4276
|
+
elements: Iterable<A>,
|
|
4277
|
+
f: (a: A, i: number) => Effect.Effect<B, E, R>,
|
|
4278
|
+
options: {
|
|
4279
|
+
readonly concurrency?: Concurrency | undefined
|
|
4280
|
+
readonly discard: true
|
|
4281
|
+
}
|
|
4282
|
+
): Effect.Effect<void, Arr.NonEmptyArray<E>, R>
|
|
4283
|
+
} = dual(
|
|
4284
|
+
(args) => isIterable(args[0]) && !isEffect(args[0]),
|
|
4285
|
+
<A, B, E, R>(
|
|
4286
|
+
elements: Iterable<A>,
|
|
4287
|
+
f: (a: A, i: number) => Effect.Effect<B, E, R>,
|
|
4288
|
+
options?: {
|
|
4289
|
+
readonly concurrency?: Concurrency | undefined
|
|
4290
|
+
readonly discard?: boolean | undefined
|
|
4291
|
+
} | undefined
|
|
4292
|
+
): Effect.Effect<Array<B> | void, Arr.NonEmptyArray<E>, R> =>
|
|
4293
|
+
flatMap(
|
|
4294
|
+
partition(elements, f, { concurrency: options?.concurrency }),
|
|
4295
|
+
([excluded, satisfying]) => {
|
|
4296
|
+
if (Arr.isArrayNonEmpty(excluded)) {
|
|
4297
|
+
return fail(excluded)
|
|
4298
|
+
}
|
|
4299
|
+
return options?.discard ? void_ : succeed(satisfying)
|
|
4300
|
+
}
|
|
4078
4301
|
)
|
|
4079
4302
|
)
|
|
4080
4303
|
|
|
4304
|
+
/** @internal */
|
|
4305
|
+
export const findFirst: {
|
|
4306
|
+
<A, E, R>(
|
|
4307
|
+
predicate: (a: NoInfer<A>, i: number) => Effect.Effect<boolean, E, R>
|
|
4308
|
+
): (elements: Iterable<A>) => Effect.Effect<Option.Option<A>, E, R>
|
|
4309
|
+
<A, E, R>(
|
|
4310
|
+
elements: Iterable<A>,
|
|
4311
|
+
predicate: (a: NoInfer<A>, i: number) => Effect.Effect<boolean, E, R>
|
|
4312
|
+
): Effect.Effect<Option.Option<A>, E, R>
|
|
4313
|
+
} = dual(
|
|
4314
|
+
(args) => isIterable(args[0]) && !isEffect(args[0]),
|
|
4315
|
+
<A, E, R>(
|
|
4316
|
+
elements: Iterable<A>,
|
|
4317
|
+
predicate: (a: A, i: number) => Effect.Effect<boolean, E, R>
|
|
4318
|
+
): Effect.Effect<Option.Option<A>, E, R> =>
|
|
4319
|
+
suspend(() => {
|
|
4320
|
+
const iterator = elements[Symbol.iterator]()
|
|
4321
|
+
const next = iterator.next()
|
|
4322
|
+
if (!next.done) {
|
|
4323
|
+
return findFirstLoop(iterator, 0, predicate, next.value)
|
|
4324
|
+
}
|
|
4325
|
+
return succeed(Option.none())
|
|
4326
|
+
})
|
|
4327
|
+
)
|
|
4328
|
+
|
|
4329
|
+
const findFirstLoop = <A, E, R>(
|
|
4330
|
+
iterator: Iterator<A>,
|
|
4331
|
+
index: number,
|
|
4332
|
+
predicate: (a: A, i: number) => Effect.Effect<boolean, E, R>,
|
|
4333
|
+
value: A
|
|
4334
|
+
): Effect.Effect<Option.Option<A>, E, R> =>
|
|
4335
|
+
flatMap(predicate(value, index), (keep) => {
|
|
4336
|
+
if (keep) {
|
|
4337
|
+
return succeed(Option.some(value))
|
|
4338
|
+
}
|
|
4339
|
+
const next = iterator.next()
|
|
4340
|
+
if (!next.done) {
|
|
4341
|
+
return findFirstLoop(iterator, index + 1, predicate, next.value)
|
|
4342
|
+
}
|
|
4343
|
+
return succeed(Option.none())
|
|
4344
|
+
})
|
|
4345
|
+
|
|
4346
|
+
/** @internal */
|
|
4347
|
+
export const findFirstFilter: {
|
|
4348
|
+
<A, B, X, E, R>(
|
|
4349
|
+
filter: (input: NoInfer<A>, i: number) => Effect.Effect<Result.Result<B, X>, E, R>
|
|
4350
|
+
): (elements: Iterable<A>) => Effect.Effect<Option.Option<B>, E, R>
|
|
4351
|
+
<A, B, X, E, R>(
|
|
4352
|
+
elements: Iterable<A>,
|
|
4353
|
+
filter: (input: NoInfer<A>, i: number) => Effect.Effect<Result.Result<B, X>, E, R>
|
|
4354
|
+
): Effect.Effect<Option.Option<B>, E, R>
|
|
4355
|
+
} = dual(
|
|
4356
|
+
(args) => isIterable(args[0]) && !isEffect(args[0]),
|
|
4357
|
+
<A, B, X, E, R>(
|
|
4358
|
+
elements: Iterable<A>,
|
|
4359
|
+
filter: (input: A, i: number) => Effect.Effect<Result.Result<B, X>, E, R>
|
|
4360
|
+
): Effect.Effect<Option.Option<B>, E, R> =>
|
|
4361
|
+
suspend(() => {
|
|
4362
|
+
const iterator = elements[Symbol.iterator]()
|
|
4363
|
+
const next = iterator.next()
|
|
4364
|
+
if (!next.done) {
|
|
4365
|
+
return findFirstFilterLoop(iterator, 0, filter, next.value)
|
|
4366
|
+
}
|
|
4367
|
+
return succeed(Option.none())
|
|
4368
|
+
})
|
|
4369
|
+
)
|
|
4370
|
+
|
|
4371
|
+
const findFirstFilterLoop = <A, B, X, E, R>(
|
|
4372
|
+
iterator: Iterator<A>,
|
|
4373
|
+
index: number,
|
|
4374
|
+
filter: (input: A, i: number) => Effect.Effect<Result.Result<B, X>, E, R>,
|
|
4375
|
+
value: A
|
|
4376
|
+
): Effect.Effect<Option.Option<B>, E, R> =>
|
|
4377
|
+
flatMap(filter(value, index), (result) => {
|
|
4378
|
+
if (Result.isSuccess(result)) {
|
|
4379
|
+
return succeed(Option.some(result.success))
|
|
4380
|
+
}
|
|
4381
|
+
const next = iterator.next()
|
|
4382
|
+
if (!next.done) {
|
|
4383
|
+
return findFirstFilterLoop(iterator, index + 1, filter, next.value)
|
|
4384
|
+
}
|
|
4385
|
+
return succeed(Option.none())
|
|
4386
|
+
})
|
|
4387
|
+
|
|
4081
4388
|
/** @internal */
|
|
4082
4389
|
export const whileLoop: <A, E, R>(options: {
|
|
4083
4390
|
readonly while: LazyArg<boolean>
|
|
@@ -4249,33 +4556,85 @@ export const filterOrElse: {
|
|
|
4249
4556
|
refinement: Predicate.Refinement<NoInfer<A>, B>,
|
|
4250
4557
|
orElse: (a: EqualsWith<A, B, NoInfer<A>, Exclude<NoInfer<A>, B>>) => Effect.Effect<C, E2, R2>
|
|
4251
4558
|
): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<B | C, E2 | E, R2 | R>
|
|
4252
|
-
<A,
|
|
4253
|
-
|
|
4254
|
-
orElse: (a:
|
|
4255
|
-
): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<
|
|
4559
|
+
<A, C, E2, R2>(
|
|
4560
|
+
predicate: Predicate.Predicate<NoInfer<A>>,
|
|
4561
|
+
orElse: (a: NoInfer<A>) => Effect.Effect<C, E2, R2>
|
|
4562
|
+
): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A | C, E2 | E, R2 | R>
|
|
4256
4563
|
<A, E, R, C, E2, R2, B extends A>(
|
|
4257
4564
|
self: Effect.Effect<A, E, R>,
|
|
4258
4565
|
refinement: Predicate.Refinement<A, B>,
|
|
4259
4566
|
orElse: (a: EqualsWith<A, B, A, Exclude<A, B>>) => Effect.Effect<C, E2, R2>
|
|
4260
4567
|
): Effect.Effect<B | C, E | E2, R | R2>
|
|
4261
|
-
<A, E, R,
|
|
4568
|
+
<A, E, R, C, E2, R2>(
|
|
4262
4569
|
self: Effect.Effect<A, E, R>,
|
|
4263
|
-
|
|
4264
|
-
orElse: (a:
|
|
4265
|
-
): Effect.Effect<
|
|
4266
|
-
} = dual(3, <A, E, R,
|
|
4570
|
+
predicate: Predicate.Predicate<NoInfer<A>>,
|
|
4571
|
+
orElse: (a: NoInfer<A>) => Effect.Effect<C, E2, R2>
|
|
4572
|
+
): Effect.Effect<A | C, E | E2, R | R2>
|
|
4573
|
+
} = dual(3, <A, E, R, B, E2, R2>(
|
|
4267
4574
|
self: Effect.Effect<A, E, R>,
|
|
4268
|
-
|
|
4269
|
-
orElse: (a:
|
|
4270
|
-
): Effect.Effect<
|
|
4575
|
+
predicate: Predicate.Predicate<A>,
|
|
4576
|
+
orElse: (a: A) => Effect.Effect<B, E2, R2>
|
|
4577
|
+
): Effect.Effect<A | B, E | E2, R | R2> =>
|
|
4578
|
+
flatMap(
|
|
4579
|
+
self,
|
|
4580
|
+
(a) => predicate(a) ? succeed<A | B>(a) : orElse(a)
|
|
4581
|
+
))
|
|
4582
|
+
|
|
4583
|
+
/** @internal */
|
|
4584
|
+
export const filterMapOrElse: {
|
|
4585
|
+
<A, B, X, C, E2, R2>(
|
|
4586
|
+
filter: Filter.Filter<NoInfer<A>, B, X>,
|
|
4587
|
+
orElse: (x: X) => Effect.Effect<C, E2, R2>
|
|
4588
|
+
): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<B | C, E2 | E, R2 | R>
|
|
4589
|
+
<A, E, R, B, X, C, E2, R2>(
|
|
4590
|
+
self: Effect.Effect<A, E, R>,
|
|
4591
|
+
filter: Filter.Filter<NoInfer<A>, B, X>,
|
|
4592
|
+
orElse: (x: X) => Effect.Effect<C, E2, R2>
|
|
4593
|
+
): Effect.Effect<B | C, E | E2, R | R2>
|
|
4594
|
+
} = dual(3, <A, E, R, B, X, C, E2, R2>(
|
|
4595
|
+
self: Effect.Effect<A, E, R>,
|
|
4596
|
+
filter: Filter.Filter<NoInfer<A>, B, X>,
|
|
4597
|
+
orElse: (x: X) => Effect.Effect<C, E2, R2>
|
|
4598
|
+
): Effect.Effect<B | C, E | E2, R | R2> =>
|
|
4271
4599
|
flatMap(
|
|
4272
4600
|
self,
|
|
4273
4601
|
(a) => {
|
|
4274
|
-
const result =
|
|
4275
|
-
return Result.isFailure(result)
|
|
4602
|
+
const result = filter(a)
|
|
4603
|
+
return (Result.isFailure(result)
|
|
4604
|
+
? orElse(result.failure)
|
|
4605
|
+
: succeed(result.success)) as Effect.Effect<B | C, E2, R2>
|
|
4276
4606
|
}
|
|
4277
4607
|
))
|
|
4278
4608
|
|
|
4609
|
+
/* @internal */
|
|
4610
|
+
export const filterMapOrFail: {
|
|
4611
|
+
<A, B, X, E2>(
|
|
4612
|
+
filter: Filter.Filter<NoInfer<A>, B, X>,
|
|
4613
|
+
orFailWith: (x: X) => E2
|
|
4614
|
+
): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<B, E2 | E, R>
|
|
4615
|
+
<A, B, X>(
|
|
4616
|
+
filter: Filter.Filter<NoInfer<A>, B, X>
|
|
4617
|
+
): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<B, Cause.NoSuchElementError | E, R>
|
|
4618
|
+
<A, E, R, B, X, E2>(
|
|
4619
|
+
self: Effect.Effect<A, E, R>,
|
|
4620
|
+
filter: Filter.Filter<NoInfer<A>, B, X>,
|
|
4621
|
+
orFailWith: (x: X) => E2
|
|
4622
|
+
): Effect.Effect<B, E2 | E, R>
|
|
4623
|
+
<A, E, R, B, X>(
|
|
4624
|
+
self: Effect.Effect<A, E, R>,
|
|
4625
|
+
filter: Filter.Filter<NoInfer<A>, B, X>
|
|
4626
|
+
): Effect.Effect<B, Cause.NoSuchElementError | E, R>
|
|
4627
|
+
} = dual((args) => isEffect(args[0]), <A, E, R, B, X, E2>(
|
|
4628
|
+
self: Effect.Effect<A, E, R>,
|
|
4629
|
+
filter: Filter.Filter<NoInfer<A>, B, X>,
|
|
4630
|
+
orFailWith?: (x: X) => E2
|
|
4631
|
+
): Effect.Effect<B, E2 | Cause.NoSuchElementError | E, R> =>
|
|
4632
|
+
filterMapOrElse(
|
|
4633
|
+
self,
|
|
4634
|
+
filter,
|
|
4635
|
+
orFailWith ? (x: X) => fail(orFailWith(x)) : () => fail(new NoSuchElementError() as E2)
|
|
4636
|
+
))
|
|
4637
|
+
|
|
4279
4638
|
/** @internal */
|
|
4280
4639
|
export const filter: {
|
|
4281
4640
|
<A, B extends A>(
|
|
@@ -4284,13 +4643,6 @@ export const filter: {
|
|
|
4284
4643
|
<A>(
|
|
4285
4644
|
predicate: Predicate.Predicate<NoInfer<A>>
|
|
4286
4645
|
): (elements: Iterable<A>) => Effect.Effect<Array<A>>
|
|
4287
|
-
<A, B, X>(
|
|
4288
|
-
filter: Filter.Filter<NoInfer<A>, B, X>
|
|
4289
|
-
): (elements: Iterable<A>) => Effect.Effect<Array<B>>
|
|
4290
|
-
<A, B, X, E, R>(
|
|
4291
|
-
filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R>,
|
|
4292
|
-
options?: { readonly concurrency?: Concurrency | undefined }
|
|
4293
|
-
): (elements: Iterable<A>) => Effect.Effect<Array<B>, E, R>
|
|
4294
4646
|
<A, E, R>(
|
|
4295
4647
|
predicate: (a: NoInfer<A>, i: number) => Effect.Effect<boolean, E, R>,
|
|
4296
4648
|
options?: { readonly concurrency?: Concurrency | undefined }
|
|
@@ -4303,15 +4655,6 @@ export const filter: {
|
|
|
4303
4655
|
elements: Iterable<A>,
|
|
4304
4656
|
predicate: Predicate.Predicate<A>
|
|
4305
4657
|
): Effect.Effect<Array<A>>
|
|
4306
|
-
<A, B, X>(
|
|
4307
|
-
elements: Iterable<A>,
|
|
4308
|
-
filter: Filter.Filter<NoInfer<A>, B, X>
|
|
4309
|
-
): Effect.Effect<Array<B>>
|
|
4310
|
-
<A, B, X, E, R>(
|
|
4311
|
-
elements: Iterable<A>,
|
|
4312
|
-
filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R>,
|
|
4313
|
-
options?: { readonly concurrency?: Concurrency | undefined }
|
|
4314
|
-
): Effect.Effect<Array<B>, E, R>
|
|
4315
4658
|
<A, E, R>(
|
|
4316
4659
|
iterable: Iterable<A>,
|
|
4317
4660
|
predicate: (a: NoInfer<A>, i: number) => Effect.Effect<boolean, E, R>,
|
|
@@ -4319,36 +4662,27 @@ export const filter: {
|
|
|
4319
4662
|
): Effect.Effect<Array<A>, E, R>
|
|
4320
4663
|
} = dual(
|
|
4321
4664
|
(args) => isIterable(args[0]) && !isEffect(args[0]),
|
|
4322
|
-
<A,
|
|
4665
|
+
<A, E, R>(
|
|
4323
4666
|
elements: Iterable<A>,
|
|
4324
|
-
|
|
4325
|
-
| Filter.FilterEffect<A, B, X, E, R>
|
|
4667
|
+
predicate:
|
|
4326
4668
|
| Predicate.Predicate<A>
|
|
4327
4669
|
| ((a: A, i: number) => Effect.Effect<boolean, E, R>),
|
|
4328
4670
|
options?: { readonly concurrency?: Concurrency | undefined }
|
|
4329
|
-
): Effect.Effect<Array<
|
|
4671
|
+
): Effect.Effect<Array<A>, E, R> =>
|
|
4330
4672
|
suspend(() => {
|
|
4331
|
-
const out: Array<
|
|
4673
|
+
const out: Array<A> = []
|
|
4332
4674
|
return as(
|
|
4333
4675
|
forEach(
|
|
4334
4676
|
elements,
|
|
4335
4677
|
(a, i) => {
|
|
4336
|
-
const result = (
|
|
4678
|
+
const result = (predicate as Function)(a, i)
|
|
4337
4679
|
if (typeof result === "boolean") {
|
|
4338
4680
|
if (result) out.push(a)
|
|
4339
4681
|
return void_ as any
|
|
4340
4682
|
}
|
|
4341
|
-
|
|
4342
|
-
if (
|
|
4343
|
-
out.push(
|
|
4344
|
-
}
|
|
4345
|
-
return void_ as any
|
|
4346
|
-
}
|
|
4347
|
-
return map(result, (r: any) => {
|
|
4348
|
-
if (typeof r === "boolean") {
|
|
4349
|
-
if (r) out.push(a)
|
|
4350
|
-
} else if (!Result.isFailure(r)) {
|
|
4351
|
-
out.push(r.success)
|
|
4683
|
+
return map(result, (keep) => {
|
|
4684
|
+
if (keep) {
|
|
4685
|
+
out.push(a)
|
|
4352
4686
|
}
|
|
4353
4687
|
})
|
|
4354
4688
|
},
|
|
@@ -4362,6 +4696,72 @@ export const filter: {
|
|
|
4362
4696
|
})
|
|
4363
4697
|
)
|
|
4364
4698
|
|
|
4699
|
+
/** @internal */
|
|
4700
|
+
export const filterMap: {
|
|
4701
|
+
<A, B, X>(
|
|
4702
|
+
filter: Filter.Filter<NoInfer<A>, B, X>
|
|
4703
|
+
): (elements: Iterable<A>) => Effect.Effect<Array<B>>
|
|
4704
|
+
<A, B, X>(
|
|
4705
|
+
elements: Iterable<A>,
|
|
4706
|
+
filter: Filter.Filter<NoInfer<A>, B, X>
|
|
4707
|
+
): Effect.Effect<Array<B>>
|
|
4708
|
+
} = dual(
|
|
4709
|
+
(args) => isIterable(args[0]) && !isEffect(args[0]),
|
|
4710
|
+
<A, B, X>(
|
|
4711
|
+
elements: Iterable<A>,
|
|
4712
|
+
filter: Filter.Filter<A, B, X>
|
|
4713
|
+
): Effect.Effect<Array<B>> =>
|
|
4714
|
+
suspend(() => {
|
|
4715
|
+
const out: Array<B> = []
|
|
4716
|
+
for (const a of elements) {
|
|
4717
|
+
const result = filter(a)
|
|
4718
|
+
if (Result.isSuccess(result)) {
|
|
4719
|
+
out.push(result.success)
|
|
4720
|
+
}
|
|
4721
|
+
}
|
|
4722
|
+
return succeed(out)
|
|
4723
|
+
})
|
|
4724
|
+
)
|
|
4725
|
+
|
|
4726
|
+
/** @internal */
|
|
4727
|
+
export const filterMapEffect: {
|
|
4728
|
+
<A, B, X, E, R>(
|
|
4729
|
+
filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R>,
|
|
4730
|
+
options?: { readonly concurrency?: Concurrency | undefined }
|
|
4731
|
+
): (elements: Iterable<A>) => Effect.Effect<Array<B>, E, R>
|
|
4732
|
+
<A, B, X, E, R>(
|
|
4733
|
+
elements: Iterable<A>,
|
|
4734
|
+
filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R>,
|
|
4735
|
+
options?: { readonly concurrency?: Concurrency | undefined }
|
|
4736
|
+
): Effect.Effect<Array<B>, E, R>
|
|
4737
|
+
} = dual(
|
|
4738
|
+
(args) => isIterable(args[0]) && !isEffect(args[0]),
|
|
4739
|
+
<A, B, X, E, R>(
|
|
4740
|
+
elements: Iterable<A>,
|
|
4741
|
+
filter: Filter.FilterEffect<A, B, X, E, R>,
|
|
4742
|
+
options?: { readonly concurrency?: Concurrency | undefined }
|
|
4743
|
+
): Effect.Effect<Array<B>, E, R> =>
|
|
4744
|
+
suspend(() => {
|
|
4745
|
+
const out: Array<B> = []
|
|
4746
|
+
return as(
|
|
4747
|
+
forEach(
|
|
4748
|
+
elements,
|
|
4749
|
+
(a) =>
|
|
4750
|
+
map(filter(a), (result) => {
|
|
4751
|
+
if (Result.isSuccess(result)) {
|
|
4752
|
+
out.push(result.success)
|
|
4753
|
+
}
|
|
4754
|
+
}),
|
|
4755
|
+
{
|
|
4756
|
+
discard: true,
|
|
4757
|
+
concurrency: options?.concurrency
|
|
4758
|
+
}
|
|
4759
|
+
),
|
|
4760
|
+
out
|
|
4761
|
+
)
|
|
4762
|
+
})
|
|
4763
|
+
)
|
|
4764
|
+
|
|
4365
4765
|
// ----------------------------------------------------------------------------
|
|
4366
4766
|
// do notation
|
|
4367
4767
|
// ----------------------------------------------------------------------------
|
|
@@ -4468,7 +4868,7 @@ export const forkUnsafe = <FA, FE, A, E, R>(
|
|
|
4468
4868
|
if (immediate) {
|
|
4469
4869
|
child.evaluate(effect as any)
|
|
4470
4870
|
} else {
|
|
4471
|
-
parent.
|
|
4871
|
+
parent.currentDispatcher.scheduleTask(() => child.evaluate(effect as any), 0)
|
|
4472
4872
|
}
|
|
4473
4873
|
if (!daemon && !child._exit) {
|
|
4474
4874
|
parent.children().add(child)
|
|
@@ -4588,7 +4988,8 @@ export const forkScoped: {
|
|
|
4588
4988
|
readonly startImmediately?: boolean | undefined
|
|
4589
4989
|
readonly uninterruptible?: boolean | "inherit" | undefined
|
|
4590
4990
|
} | undefined
|
|
4591
|
-
): [Arg] extends [Effect.Effect<infer _A, infer _E, infer _R>] ?
|
|
4991
|
+
): [Arg] extends [Effect.Effect<infer _A, infer _E, infer _R>] ?
|
|
4992
|
+
Effect.Effect<Fiber.Fiber<_A, _E>, never, _R | Scope.Scope>
|
|
4592
4993
|
: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<Fiber.Fiber<A, E>, never, R | Scope.Scope>
|
|
4593
4994
|
} = dual((args) => isEffect(args[0]), <A, E, R>(
|
|
4594
4995
|
self: Effect.Effect<A, E, R>,
|
|
@@ -4608,10 +5009,8 @@ export const runForkWith = <R>(services: ServiceMap.ServiceMap<R>) =>
|
|
|
4608
5009
|
effect: Effect.Effect<A, E, R>,
|
|
4609
5010
|
options?: Effect.RunOptions | undefined
|
|
4610
5011
|
): Fiber.Fiber<A, E> => {
|
|
4611
|
-
const scheduler = options?.scheduler ||
|
|
4612
|
-
(!services.mapUnsafe.has(Scheduler.Scheduler.key) && new Scheduler.MixedScheduler())
|
|
4613
5012
|
const fiber = new FiberImpl<A, E>(
|
|
4614
|
-
scheduler ? ServiceMap.add(services, Scheduler.Scheduler, scheduler) : services,
|
|
5013
|
+
options?.scheduler ? ServiceMap.add(services, Scheduler.Scheduler, options.scheduler) : services,
|
|
4615
5014
|
options?.uninterruptible !== true
|
|
4616
5015
|
)
|
|
4617
5016
|
fiber.evaluate(effect as any)
|
|
@@ -4731,8 +5130,8 @@ export const runSyncExitWith = <R>(services: ServiceMap.ServiceMap<R>) => {
|
|
|
4731
5130
|
if (effectIsExit(effect)) return effect
|
|
4732
5131
|
const scheduler = new Scheduler.MixedScheduler("sync")
|
|
4733
5132
|
const fiber = runFork(effect, { scheduler })
|
|
4734
|
-
|
|
4735
|
-
return (fiber as FiberImpl<A, E>)._exit ?? exitDie(fiber)
|
|
5133
|
+
fiber.currentDispatcher?.flush()
|
|
5134
|
+
return (fiber as FiberImpl<A, E>)._exit ?? exitDie(new AsyncFiberError(fiber))
|
|
4736
5135
|
}
|
|
4737
5136
|
}
|
|
4738
5137
|
|
|
@@ -4754,107 +5153,10 @@ export const runSyncWith = <R>(services: ServiceMap.ServiceMap<R>) => {
|
|
|
4754
5153
|
/** @internal */
|
|
4755
5154
|
export const runSync: <A, E>(effect: Effect.Effect<A, E>) => A = runSyncWith(ServiceMap.empty())
|
|
4756
5155
|
|
|
4757
|
-
// ----------------------------------------------------------------------------
|
|
4758
|
-
// Semaphore
|
|
4759
|
-
// ----------------------------------------------------------------------------
|
|
4760
|
-
|
|
4761
|
-
/** @internal */
|
|
4762
|
-
class Semaphore {
|
|
4763
|
-
public waiters = new Set<() => void>()
|
|
4764
|
-
public taken = 0
|
|
4765
|
-
public permits: number
|
|
4766
|
-
|
|
4767
|
-
constructor(permits: number) {
|
|
4768
|
-
this.permits = permits
|
|
4769
|
-
}
|
|
4770
|
-
|
|
4771
|
-
get free() {
|
|
4772
|
-
return this.permits - this.taken
|
|
4773
|
-
}
|
|
4774
|
-
|
|
4775
|
-
readonly take = (n: number): Effect.Effect<number> =>
|
|
4776
|
-
callback<number>((resume) => {
|
|
4777
|
-
if (this.free < n) {
|
|
4778
|
-
const observer = () => {
|
|
4779
|
-
if (this.free < n) {
|
|
4780
|
-
return
|
|
4781
|
-
}
|
|
4782
|
-
this.waiters.delete(observer)
|
|
4783
|
-
this.taken += n
|
|
4784
|
-
resume(succeed(n))
|
|
4785
|
-
}
|
|
4786
|
-
this.waiters.add(observer)
|
|
4787
|
-
return sync(() => {
|
|
4788
|
-
this.waiters.delete(observer)
|
|
4789
|
-
})
|
|
4790
|
-
}
|
|
4791
|
-
this.taken += n
|
|
4792
|
-
return resume(succeed(n))
|
|
4793
|
-
})
|
|
4794
|
-
|
|
4795
|
-
updateTakenUnsafe(fiber: Fiber.Fiber<any, any>, f: (n: number) => number): Effect.Effect<number> {
|
|
4796
|
-
this.taken = f(this.taken)
|
|
4797
|
-
if (this.waiters.size > 0) {
|
|
4798
|
-
fiber.currentScheduler.scheduleTask(() => {
|
|
4799
|
-
const iter = this.waiters.values()
|
|
4800
|
-
let item = iter.next()
|
|
4801
|
-
while (item.done === false && this.free > 0) {
|
|
4802
|
-
item.value()
|
|
4803
|
-
item = iter.next()
|
|
4804
|
-
}
|
|
4805
|
-
}, 0)
|
|
4806
|
-
}
|
|
4807
|
-
return succeed(this.free)
|
|
4808
|
-
}
|
|
4809
|
-
|
|
4810
|
-
updateTaken(f: (n: number) => number): Effect.Effect<number> {
|
|
4811
|
-
return withFiber((fiber) => this.updateTakenUnsafe(fiber, f))
|
|
4812
|
-
}
|
|
4813
|
-
|
|
4814
|
-
readonly resize = (permits: number) =>
|
|
4815
|
-
asVoid(
|
|
4816
|
-
withFiber((fiber) => {
|
|
4817
|
-
this.permits = permits
|
|
4818
|
-
if (this.free < 0) {
|
|
4819
|
-
return void_
|
|
4820
|
-
}
|
|
4821
|
-
return this.updateTakenUnsafe(fiber, (taken) => taken)
|
|
4822
|
-
})
|
|
4823
|
-
)
|
|
4824
|
-
|
|
4825
|
-
readonly release = (n: number): Effect.Effect<number> => this.updateTaken((taken) => taken - n)
|
|
4826
|
-
|
|
4827
|
-
readonly releaseAll: Effect.Effect<number> = this.updateTaken((_) => 0)
|
|
4828
|
-
|
|
4829
|
-
readonly withPermits = (n: number) => <A, E, R>(self: Effect.Effect<A, E, R>) =>
|
|
4830
|
-
uninterruptibleMask((restore) =>
|
|
4831
|
-
flatMap(restore(this.take(n)), (permits) => ensuring(restore(self), this.release(permits)))
|
|
4832
|
-
)
|
|
4833
|
-
|
|
4834
|
-
readonly withPermit = this.withPermits(1)
|
|
4835
|
-
|
|
4836
|
-
readonly withPermitsIfAvailable = (n: number) => <A, E, R>(self: Effect.Effect<A, E, R>) =>
|
|
4837
|
-
uninterruptibleMask((restore) =>
|
|
4838
|
-
suspend(() => {
|
|
4839
|
-
if (this.free < n) {
|
|
4840
|
-
return succeedNone
|
|
4841
|
-
}
|
|
4842
|
-
this.taken += n
|
|
4843
|
-
return ensuring(restore(asSome(self)), this.release(n))
|
|
4844
|
-
})
|
|
4845
|
-
)
|
|
4846
|
-
}
|
|
4847
|
-
|
|
4848
|
-
/** @internal */
|
|
4849
|
-
export const makeSemaphoreUnsafe = (permits: number): Semaphore => new Semaphore(permits)
|
|
4850
|
-
|
|
4851
|
-
/** @internal */
|
|
4852
|
-
export const makeSemaphore = (permits: number) => sync(() => makeSemaphoreUnsafe(permits))
|
|
4853
|
-
|
|
4854
5156
|
const succeedTrue = succeed(true)
|
|
4855
5157
|
const succeedFalse = succeed(false)
|
|
4856
5158
|
|
|
4857
|
-
class Latch implements
|
|
5159
|
+
class Latch implements _Latch.Latch {
|
|
4858
5160
|
waiters: Array<(_: Effect.Effect<void>) => void> = []
|
|
4859
5161
|
scheduled = false
|
|
4860
5162
|
private isOpen: boolean
|
|
@@ -4868,7 +5170,7 @@ class Latch implements Effect.Latch {
|
|
|
4868
5170
|
return succeedTrue
|
|
4869
5171
|
}
|
|
4870
5172
|
this.scheduled = true
|
|
4871
|
-
fiber.
|
|
5173
|
+
fiber.currentDispatcher.scheduleTask(this.flushWaiters, 0)
|
|
4872
5174
|
return succeedTrue
|
|
4873
5175
|
}
|
|
4874
5176
|
private flushWaiters = () => {
|
|
@@ -4910,11 +5212,11 @@ class Latch implements Effect.Latch {
|
|
|
4910
5212
|
return true
|
|
4911
5213
|
}
|
|
4912
5214
|
close = sync(() => this.closeUnsafe())
|
|
4913
|
-
whenOpen = <A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> =>
|
|
5215
|
+
whenOpen = <A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> => flatMap(this.await, () => self)
|
|
4914
5216
|
}
|
|
4915
5217
|
|
|
4916
5218
|
/** @internal */
|
|
4917
|
-
export const makeLatchUnsafe = (open?: boolean | undefined):
|
|
5219
|
+
export const makeLatchUnsafe = (open?: boolean | undefined): _Latch.Latch => new Latch(open ?? false)
|
|
4918
5220
|
|
|
4919
5221
|
/** @internal */
|
|
4920
5222
|
export const makeLatch = (open?: boolean | undefined) => sync(() => makeLatchUnsafe(open))
|
|
@@ -4973,16 +5275,15 @@ const NoopSpanProto: Omit<Tracer.Span, "parent" | "name" | "annotations" | "leve
|
|
|
4973
5275
|
/** @internal */
|
|
4974
5276
|
export const noopSpan = (options: {
|
|
4975
5277
|
readonly name: string
|
|
4976
|
-
readonly parent: Tracer.AnySpan
|
|
5278
|
+
readonly parent: Option.Option<Tracer.AnySpan>
|
|
4977
5279
|
readonly annotations: ServiceMap.ServiceMap<never>
|
|
4978
5280
|
}): Tracer.Span => Object.assign(Object.create(NoopSpanProto), options)
|
|
4979
5281
|
|
|
4980
|
-
const filterDisablePropagation = (span: Tracer.AnySpan | undefined): Tracer.AnySpan
|
|
4981
|
-
if (span)
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
}
|
|
5282
|
+
const filterDisablePropagation = (span: Tracer.AnySpan | undefined): Option.Option<Tracer.AnySpan> => {
|
|
5283
|
+
if (!span) return Option.none()
|
|
5284
|
+
return ServiceMap.get(span.annotations, Tracer.DisablePropagation)
|
|
5285
|
+
? span._tag === "Span" ? filterDisablePropagation(Option.getOrUndefined(span.parent)) : Option.none()
|
|
5286
|
+
: Option.some(span)
|
|
4986
5287
|
}
|
|
4987
5288
|
|
|
4988
5289
|
/** @internal */
|
|
@@ -4993,7 +5294,11 @@ export const makeSpanUnsafe = <XA, XE>(
|
|
|
4993
5294
|
) => {
|
|
4994
5295
|
const disablePropagation = !fiber.getRef(TracerEnabled) ||
|
|
4995
5296
|
(options?.annotations && ServiceMap.get(options.annotations, Tracer.DisablePropagation))
|
|
4996
|
-
const parent = options?.parent
|
|
5297
|
+
const parent = options?.parent !== undefined
|
|
5298
|
+
? Option.some(options.parent)
|
|
5299
|
+
: options?.root
|
|
5300
|
+
? Option.none<Tracer.AnySpan>()
|
|
5301
|
+
: filterDisablePropagation(fiber.currentSpan)
|
|
4997
5302
|
|
|
4998
5303
|
let span: Tracer.Span
|
|
4999
5304
|
|
|
@@ -5026,9 +5331,9 @@ export const makeSpanUnsafe = <XA, XE>(
|
|
|
5026
5331
|
links,
|
|
5027
5332
|
startTime: timingEnabled ? clock.currentTimeNanosUnsafe() : 0n,
|
|
5028
5333
|
kind: options?.kind ?? "internal",
|
|
5029
|
-
root: options?.root ??
|
|
5334
|
+
root: options?.root ?? Option.isNone(parent),
|
|
5030
5335
|
sampled: options?.sampled ??
|
|
5031
|
-
(parent
|
|
5336
|
+
(Option.isSome(parent) && parent.value.sampled === false
|
|
5032
5337
|
? false
|
|
5033
5338
|
: !isLogLevelGreaterThan(fiber.getRef(Tracer.MinimumTraceLevel), level))
|
|
5034
5339
|
})
|
|
@@ -5344,8 +5649,8 @@ export const clockWith = <A, E, R>(f: (clock: Clock.Clock) => Effect.Effect<A, E
|
|
|
5344
5649
|
withFiber((fiber) => f(fiber.getRef(ClockRef)))
|
|
5345
5650
|
|
|
5346
5651
|
/** @internal */
|
|
5347
|
-
export const sleep = (duration: Duration.
|
|
5348
|
-
clockWith((clock) => clock.sleep(Duration.
|
|
5652
|
+
export const sleep = (duration: Duration.Input): Effect.Effect<void> =>
|
|
5653
|
+
clockWith((clock) => clock.sleep(Duration.fromInputUnsafe(duration)))
|
|
5349
5654
|
|
|
5350
5655
|
/** @internal */
|
|
5351
5656
|
export const currentTimeMillis: Effect.Effect<number> = clockWith((clock) => clock.currentTimeMillis)
|
|
@@ -5403,6 +5708,28 @@ export class ExceededCapacityError extends TaggedError("ExceededCapacityError")
|
|
|
5403
5708
|
}
|
|
5404
5709
|
}
|
|
5405
5710
|
|
|
5711
|
+
/** @internal */
|
|
5712
|
+
export const AsyncFiberErrorTypeId = "~effect/Cause/AsyncFiberError"
|
|
5713
|
+
|
|
5714
|
+
/** @internal */
|
|
5715
|
+
export const isAsyncFiberError = (
|
|
5716
|
+
u: unknown
|
|
5717
|
+
): u is Cause.AsyncFiberError => hasProperty(u, AsyncFiberErrorTypeId)
|
|
5718
|
+
|
|
5719
|
+
/** @internal */
|
|
5720
|
+
export class AsyncFiberError extends TaggedError("AsyncFiberError")<{
|
|
5721
|
+
fiber: Fiber.Fiber<unknown, unknown>
|
|
5722
|
+
message: string
|
|
5723
|
+
}> {
|
|
5724
|
+
readonly [AsyncFiberErrorTypeId] = AsyncFiberErrorTypeId
|
|
5725
|
+
constructor(fiber: Fiber.Fiber<unknown, unknown>) {
|
|
5726
|
+
super({
|
|
5727
|
+
message: "An asynchronous Effect was executed with Effect.runSync",
|
|
5728
|
+
fiber
|
|
5729
|
+
})
|
|
5730
|
+
}
|
|
5731
|
+
}
|
|
5732
|
+
|
|
5406
5733
|
/** @internal */
|
|
5407
5734
|
export const UnknownErrorTypeId = "~effect/Cause/UnknownError"
|
|
5408
5735
|
|
|
@@ -5412,7 +5739,10 @@ export const isUnknownError = (
|
|
|
5412
5739
|
): u is Cause.UnknownError => hasProperty(u, UnknownErrorTypeId)
|
|
5413
5740
|
|
|
5414
5741
|
/** @internal */
|
|
5415
|
-
export class UnknownError extends TaggedError("UnknownError")
|
|
5742
|
+
export class UnknownError extends TaggedError("UnknownError")<{
|
|
5743
|
+
cause: unknown
|
|
5744
|
+
message?: string | undefined
|
|
5745
|
+
}> {
|
|
5416
5746
|
readonly [UnknownErrorTypeId] = UnknownErrorTypeId
|
|
5417
5747
|
constructor(cause: unknown, message?: string) {
|
|
5418
5748
|
super({ message, cause } as any)
|
|
@@ -5477,6 +5807,40 @@ export const LogToStderr = ServiceMap.Reference<boolean>("effect/Logger/LogToStd
|
|
|
5477
5807
|
defaultValue: constFalse
|
|
5478
5808
|
})
|
|
5479
5809
|
|
|
5810
|
+
/** @internal */
|
|
5811
|
+
export const annotateLogsScoped: {
|
|
5812
|
+
(key: string, value: unknown): Effect.Effect<void, never, Scope.Scope>
|
|
5813
|
+
(values: Record<string, unknown>): Effect.Effect<void, never, Scope.Scope>
|
|
5814
|
+
} = function() {
|
|
5815
|
+
const entries = typeof arguments[0] === "string" ?
|
|
5816
|
+
[[arguments[0], arguments[1]]] :
|
|
5817
|
+
Object.entries(arguments[0])
|
|
5818
|
+
return uninterruptible(withFiber((fiber) => {
|
|
5819
|
+
const prev = fiber.getRef(CurrentLogAnnotations)
|
|
5820
|
+
const next = { ...prev }
|
|
5821
|
+
for (let i = 0; i < entries.length; i++) {
|
|
5822
|
+
const [key, value] = entries[i]
|
|
5823
|
+
next[key] = value
|
|
5824
|
+
}
|
|
5825
|
+
fiber.setServices(ServiceMap.add(fiber.services, CurrentLogAnnotations, next))
|
|
5826
|
+
return scopeAddFinalizerExit(ServiceMap.getUnsafe(fiber.services, scopeTag), (_) => {
|
|
5827
|
+
const current = fiber.getRef(CurrentLogAnnotations)
|
|
5828
|
+
const next = { ...current }
|
|
5829
|
+
for (let i = 0; i < entries.length; i++) {
|
|
5830
|
+
const [key, value] = entries[i]
|
|
5831
|
+
if (current[key] !== value) continue
|
|
5832
|
+
if (key in prev) {
|
|
5833
|
+
next[key] = prev[key]
|
|
5834
|
+
} else {
|
|
5835
|
+
delete next[key]
|
|
5836
|
+
}
|
|
5837
|
+
}
|
|
5838
|
+
fiber.setServices(ServiceMap.add(fiber.services, CurrentLogAnnotations, next))
|
|
5839
|
+
return void_
|
|
5840
|
+
})
|
|
5841
|
+
}))
|
|
5842
|
+
}
|
|
5843
|
+
|
|
5480
5844
|
/** @internal */
|
|
5481
5845
|
export const LoggerTypeId = "~effect/Logger"
|
|
5482
5846
|
|
|
@@ -5492,7 +5856,7 @@ const LoggerProto = {
|
|
|
5492
5856
|
|
|
5493
5857
|
/** @internal */
|
|
5494
5858
|
export const loggerMake = <Message, Output>(
|
|
5495
|
-
log: (options: Logger.
|
|
5859
|
+
log: (options: Logger.Options<Message>) => Output
|
|
5496
5860
|
): Logger.Logger<Message, Output> => {
|
|
5497
5861
|
const self = Object.create(LoggerProto)
|
|
5498
5862
|
self.log = log
|
|
@@ -5532,7 +5896,7 @@ export const structuredMessage = (u: unknown): unknown => {
|
|
|
5532
5896
|
}
|
|
5533
5897
|
|
|
5534
5898
|
/** @internal */
|
|
5535
|
-
export const logWithLevel = (level?: LogLevel.
|
|
5899
|
+
export const logWithLevel = (level?: LogLevel.Severity) =>
|
|
5536
5900
|
(
|
|
5537
5901
|
...message: ReadonlyArray<any>
|
|
5538
5902
|
): Effect.Effect<void> => {
|
|
@@ -5651,7 +6015,7 @@ const prettyLoggerTty = (options: {
|
|
|
5651
6015
|
readonly formatDate: (date: Date) => string
|
|
5652
6016
|
}) => {
|
|
5653
6017
|
const processIsBun = typeof process === "object" && "isBun" in process && process.isBun === true
|
|
5654
|
-
const color = options.colors
|
|
6018
|
+
const color = options.colors ? withColor : withColorNoop
|
|
5655
6019
|
return loggerMake<unknown, void>(
|
|
5656
6020
|
({ cause, date, fiber, logLevel, message: message_ }) => {
|
|
5657
6021
|
const console = fiber.getRef(ConsoleRef)
|
|
@@ -5774,7 +6138,7 @@ const prettyLoggerBrowser = (options: {
|
|
|
5774
6138
|
export const defaultLogger = loggerMake<unknown, void>(({ cause, date, fiber, logLevel, message }) => {
|
|
5775
6139
|
const message_ = Array.isArray(message) ? message.slice() : [message]
|
|
5776
6140
|
if (cause.reasons.length > 0) {
|
|
5777
|
-
message_.
|
|
6141
|
+
message_.push(causePretty(cause))
|
|
5778
6142
|
}
|
|
5779
6143
|
const now = date.getTime()
|
|
5780
6144
|
const spans = fiber.getRef(CurrentLogSpans)
|
|
@@ -5823,3 +6187,48 @@ const undefined_ = succeed(undefined)
|
|
|
5823
6187
|
|
|
5824
6188
|
/** @internal */
|
|
5825
6189
|
export { undefined_ as undefined }
|
|
6190
|
+
|
|
6191
|
+
// ----------------------------------------------------------------------------
|
|
6192
|
+
// ErrorReporter
|
|
6193
|
+
// ----------------------------------------------------------------------------
|
|
6194
|
+
|
|
6195
|
+
/** @internal */
|
|
6196
|
+
export const withErrorReporting: <
|
|
6197
|
+
Arg extends Effect.Effect<any, any, any> | {
|
|
6198
|
+
readonly defectsOnly?: boolean | undefined
|
|
6199
|
+
} | undefined = {
|
|
6200
|
+
readonly defectsOnly?: boolean | undefined
|
|
6201
|
+
}
|
|
6202
|
+
>(
|
|
6203
|
+
effectOrOptions: Arg,
|
|
6204
|
+
options?: {
|
|
6205
|
+
readonly defectsOnly?: boolean | undefined
|
|
6206
|
+
} | undefined
|
|
6207
|
+
) => [Arg] extends [Effect.Effect<infer _A, infer _E, infer _R>] ? Arg
|
|
6208
|
+
: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R> = dual(
|
|
6209
|
+
(args) => isEffect(args[0]),
|
|
6210
|
+
<A, E, R>(
|
|
6211
|
+
self: Effect.Effect<A, E, R>,
|
|
6212
|
+
options?: {
|
|
6213
|
+
readonly defectsOnly?: boolean | undefined
|
|
6214
|
+
} | undefined
|
|
6215
|
+
): Effect.Effect<A, E, R> =>
|
|
6216
|
+
onError(self, (cause) =>
|
|
6217
|
+
withFiber((fiber) => {
|
|
6218
|
+
reportCauseUnsafe(fiber, cause, options?.defectsOnly)
|
|
6219
|
+
return void_
|
|
6220
|
+
}))
|
|
6221
|
+
)
|
|
6222
|
+
|
|
6223
|
+
/** @internal */
|
|
6224
|
+
export const reportCauseUnsafe = (
|
|
6225
|
+
fiber: Fiber.Fiber<unknown, unknown>,
|
|
6226
|
+
cause: Cause.Cause<unknown>,
|
|
6227
|
+
defectsOnly?: boolean
|
|
6228
|
+
) => {
|
|
6229
|
+
const reporters = fiber.getRef(CurrentErrorReporters)
|
|
6230
|
+
if (reporters.size === 0) return
|
|
6231
|
+
if (defectsOnly && !hasDies(cause)) return
|
|
6232
|
+
const opts = { cause, fiber, timestamp: fiber.getRef(ClockRef).currentTimeNanosUnsafe() }
|
|
6233
|
+
reporters.forEach((reporter) => reporter.report(opts))
|
|
6234
|
+
}
|