effect 4.0.0-beta.2 → 4.0.0-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Array.d.ts +127 -299
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +102 -62
- package/dist/Array.js.map +1 -1
- package/dist/Cache.d.ts +2 -2
- package/dist/Cache.d.ts.map +1 -1
- package/dist/Cache.js +6 -5
- package/dist/Cache.js.map +1 -1
- package/dist/Cause.d.ts +1 -1
- package/dist/Cause.d.ts.map +1 -1
- package/dist/Channel.d.ts +116 -30
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +82 -37
- package/dist/Channel.js.map +1 -1
- package/dist/Chunk.d.ts +54 -247
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Chunk.js +36 -67
- package/dist/Chunk.js.map +1 -1
- package/dist/Combiner.d.ts +280 -13
- package/dist/Combiner.d.ts.map +1 -1
- package/dist/Combiner.js +198 -7
- package/dist/Combiner.js.map +1 -1
- package/dist/Config.d.ts +165 -9
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +62 -7
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.d.ts +1 -1
- package/dist/Cron.d.ts +1 -1
- package/dist/Data.d.ts +534 -365
- package/dist/Data.d.ts.map +1 -1
- package/dist/Data.js +132 -79
- package/dist/Data.js.map +1 -1
- package/dist/DateTime.d.ts +23 -161
- package/dist/DateTime.d.ts.map +1 -1
- package/dist/DateTime.js +6 -51
- package/dist/DateTime.js.map +1 -1
- package/dist/Duration.d.ts +12 -12
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +12 -12
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts +829 -692
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +263 -251
- package/dist/Effect.js.map +1 -1
- package/dist/Encoding.d.ts +194 -0
- package/dist/Encoding.d.ts.map +1 -0
- package/dist/Encoding.js +352 -0
- package/dist/Encoding.js.map +1 -0
- package/dist/Equal.d.ts +276 -109
- package/dist/Equal.d.ts.map +1 -1
- package/dist/Equal.js +124 -48
- package/dist/Equal.js.map +1 -1
- package/dist/ErrorReporter.d.ts +376 -0
- package/dist/ErrorReporter.d.ts.map +1 -0
- package/dist/ErrorReporter.js +246 -0
- package/dist/ErrorReporter.js.map +1 -0
- package/dist/Fiber.d.ts +2 -2
- package/dist/Fiber.d.ts.map +1 -1
- package/dist/Fiber.js.map +1 -1
- package/dist/FileSystem.d.ts +1 -1
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js +5 -5
- package/dist/FileSystem.js.map +1 -1
- package/dist/Filter.d.ts +30 -34
- package/dist/Filter.d.ts.map +1 -1
- package/dist/Filter.js +15 -13
- package/dist/Filter.js.map +1 -1
- package/dist/Formatter.d.ts +131 -47
- package/dist/Formatter.d.ts.map +1 -1
- package/dist/Formatter.js +229 -51
- package/dist/Formatter.js.map +1 -1
- package/dist/Graph.d.ts +1 -1
- package/dist/Graph.d.ts.map +1 -1
- package/dist/Graph.js +5 -8
- package/dist/Graph.js.map +1 -1
- package/dist/HashMap.d.ts +15 -14
- package/dist/HashMap.d.ts.map +1 -1
- package/dist/HashMap.js +4 -4
- package/dist/HashMap.js.map +1 -1
- package/dist/Iterable.d.ts +40 -39
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +94 -22
- package/dist/Iterable.js.map +1 -1
- package/dist/JsonSchema.d.ts +299 -10
- package/dist/JsonSchema.d.ts.map +1 -1
- package/dist/JsonSchema.js +323 -4
- package/dist/JsonSchema.js.map +1 -1
- package/dist/Latch.d.ts +109 -0
- package/dist/Latch.d.ts.map +1 -0
- package/dist/Latch.js +72 -0
- package/dist/Latch.js.map +1 -0
- package/dist/Layer.d.ts +9 -9
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js.map +1 -1
- package/dist/LayerMap.d.ts +4 -4
- package/dist/LayerMap.d.ts.map +1 -1
- package/dist/LogLevel.d.ts +32 -0
- package/dist/LogLevel.d.ts.map +1 -1
- package/dist/LogLevel.js +28 -100
- package/dist/LogLevel.js.map +1 -1
- package/dist/Logger.d.ts +29 -95
- package/dist/Logger.d.ts.map +1 -1
- package/dist/Logger.js +2 -3
- package/dist/Logger.js.map +1 -1
- package/dist/ManagedRuntime.d.ts +1 -1
- package/dist/ManagedRuntime.js +1 -1
- package/dist/Metric.d.ts +2 -2
- package/dist/Metric.d.ts.map +1 -1
- package/dist/Metric.js +1 -1
- package/dist/Metric.js.map +1 -1
- package/dist/Optic.d.ts +947 -18
- package/dist/Optic.d.ts.map +1 -1
- package/dist/Optic.js +454 -5
- package/dist/Optic.js.map +1 -1
- package/dist/Option.d.ts +22 -15
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js +14 -7
- package/dist/Option.js.map +1 -1
- package/dist/Pipeable.d.ts +17 -0
- package/dist/Pipeable.d.ts.map +1 -1
- package/dist/Pipeable.js +19 -1
- package/dist/Pipeable.js.map +1 -1
- package/dist/PlatformError.d.ts +10 -9
- package/dist/PlatformError.d.ts.map +1 -1
- package/dist/PlatformError.js +2 -2
- package/dist/PlatformError.js.map +1 -1
- package/dist/Pool.d.ts +6 -4
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +7 -5
- package/dist/Pool.js.map +1 -1
- package/dist/PubSub.d.ts +3 -2
- package/dist/PubSub.d.ts.map +1 -1
- package/dist/PubSub.js +3 -2
- package/dist/PubSub.js.map +1 -1
- package/dist/Pull.d.ts.map +1 -1
- package/dist/Pull.js +1 -1
- package/dist/Pull.js.map +1 -1
- package/dist/Queue.d.ts.map +1 -1
- package/dist/Queue.js +0 -1
- package/dist/Queue.js.map +1 -1
- package/dist/Random.d.ts +35 -1
- package/dist/Random.d.ts.map +1 -1
- package/dist/Random.js +46 -12
- package/dist/Random.js.map +1 -1
- package/dist/RcMap.d.ts +2 -2
- package/dist/RcMap.d.ts.map +1 -1
- package/dist/RcMap.js +1 -1
- package/dist/RcMap.js.map +1 -1
- package/dist/RcRef.d.ts +1 -1
- package/dist/RcRef.d.ts.map +1 -1
- package/dist/Record.d.ts +24 -120
- package/dist/Record.d.ts.map +1 -1
- package/dist/Record.js +21 -41
- package/dist/Record.js.map +1 -1
- package/dist/Reducer.d.ts +166 -7
- package/dist/Reducer.d.ts.map +1 -1
- package/dist/Reducer.js +135 -1
- package/dist/Reducer.js.map +1 -1
- package/dist/References.d.ts +3 -3
- package/dist/References.d.ts.map +1 -1
- package/dist/Request.d.ts +1 -1
- package/dist/Request.d.ts.map +1 -1
- package/dist/Request.js +2 -1
- package/dist/Request.js.map +1 -1
- package/dist/RequestResolver.d.ts +6 -26
- package/dist/RequestResolver.d.ts.map +1 -1
- package/dist/RequestResolver.js +0 -20
- package/dist/RequestResolver.js.map +1 -1
- package/dist/Result.d.ts +12 -0
- package/dist/Result.d.ts.map +1 -1
- package/dist/Result.js +12 -0
- package/dist/Result.js.map +1 -1
- package/dist/Schedule.d.ts +47 -20
- package/dist/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js +94 -34
- package/dist/Schedule.js.map +1 -1
- package/dist/Schema.d.ts +266 -50
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +426 -74
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +7 -6
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaGetter.d.ts +2 -2
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +12 -14
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaParser.d.ts +5 -0
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +10 -0
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +44 -43
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +43 -24
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +107 -3
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +159 -4
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/ScopedCache.d.ts +2 -2
- package/dist/ScopedCache.d.ts.map +1 -1
- package/dist/ScopedCache.js +1 -1
- package/dist/ScopedCache.js.map +1 -1
- package/dist/Semaphore.d.ts +211 -0
- package/dist/Semaphore.d.ts.map +1 -0
- package/dist/{PartitionedSemaphore.js → Semaphore.js} +97 -13
- package/dist/Semaphore.js.map +1 -0
- package/dist/ServiceMap.d.ts +39 -30
- package/dist/ServiceMap.d.ts.map +1 -1
- package/dist/ServiceMap.js +3 -3
- package/dist/ServiceMap.js.map +1 -1
- package/dist/Sink.d.ts +13 -13
- package/dist/Sink.d.ts.map +1 -1
- package/dist/Sink.js +53 -6
- package/dist/Sink.js.map +1 -1
- package/dist/Stream.d.ts +235 -423
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +124 -77
- package/dist/Stream.js.map +1 -1
- package/dist/Struct.d.ts +16 -0
- package/dist/Struct.d.ts.map +1 -1
- package/dist/Struct.js +22 -0
- package/dist/Struct.js.map +1 -1
- package/dist/SubscriptionRef.d.ts +2 -1
- package/dist/SubscriptionRef.d.ts.map +1 -1
- package/dist/SubscriptionRef.js +2 -1
- package/dist/SubscriptionRef.js.map +1 -1
- package/dist/SynchronizedRef.d.ts +2 -1
- package/dist/SynchronizedRef.d.ts.map +1 -1
- package/dist/SynchronizedRef.js +2 -1
- package/dist/SynchronizedRef.js.map +1 -1
- package/dist/Trie.d.ts +18 -17
- package/dist/Trie.d.ts.map +1 -1
- package/dist/Trie.js +5 -5
- package/dist/Trie.js.map +1 -1
- package/dist/TxChunk.d.ts +37 -37
- package/dist/TxChunk.d.ts.map +1 -1
- package/dist/TxChunk.js +3 -3
- package/dist/TxChunk.js.map +1 -1
- package/dist/TxDeferred.d.ts +328 -0
- package/dist/TxDeferred.d.ts.map +1 -0
- package/dist/TxDeferred.js +196 -0
- package/dist/TxDeferred.js.map +1 -0
- package/dist/TxHashMap.d.ts +84 -83
- package/dist/TxHashMap.d.ts.map +1 -1
- package/dist/TxHashMap.js +24 -24
- package/dist/TxHashMap.js.map +1 -1
- package/dist/TxHashSet.d.ts +35 -35
- package/dist/TxHashSet.d.ts.map +1 -1
- package/dist/TxHashSet.js +14 -14
- package/dist/TxHashSet.js.map +1 -1
- package/dist/TxPriorityQueue.d.ts +609 -0
- package/dist/TxPriorityQueue.d.ts.map +1 -0
- package/dist/TxPriorityQueue.js +415 -0
- package/dist/TxPriorityQueue.js.map +1 -0
- package/dist/TxPubSub.d.ts +585 -0
- package/dist/TxPubSub.d.ts.map +1 -0
- package/dist/TxPubSub.js +521 -0
- package/dist/TxPubSub.js.map +1 -0
- package/dist/TxQueue.d.ts +32 -32
- package/dist/TxQueue.d.ts.map +1 -1
- package/dist/TxQueue.js +26 -26
- package/dist/TxQueue.js.map +1 -1
- package/dist/TxReentrantLock.d.ts +523 -0
- package/dist/TxReentrantLock.d.ts.map +1 -0
- package/dist/TxReentrantLock.js +504 -0
- package/dist/TxReentrantLock.js.map +1 -0
- package/dist/TxRef.d.ts +34 -34
- package/dist/TxRef.d.ts.map +1 -1
- package/dist/TxRef.js +21 -14
- package/dist/TxRef.js.map +1 -1
- package/dist/TxSemaphore.d.ts +8 -8
- package/dist/TxSemaphore.d.ts.map +1 -1
- package/dist/TxSemaphore.js +7 -7
- package/dist/TxSemaphore.js.map +1 -1
- package/dist/TxSubscriptionRef.d.ts +508 -0
- package/dist/TxSubscriptionRef.d.ts.map +1 -0
- package/dist/TxSubscriptionRef.js +293 -0
- package/dist/TxSubscriptionRef.js.map +1 -0
- package/dist/Types.d.ts +84 -6
- package/dist/Types.d.ts.map +1 -1
- package/dist/index.d.ts +591 -20
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +591 -20
- package/dist/index.js.map +1 -1
- package/dist/internal/core.js +11 -3
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/dateTime.js +3 -11
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +263 -99
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/hashMap.js +5 -4
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/random.d.ts +2 -0
- package/dist/internal/random.d.ts.map +1 -0
- package/dist/internal/random.js +13 -0
- package/dist/internal/random.js.map +1 -0
- package/dist/internal/rcRef.js +3 -2
- package/dist/internal/rcRef.js.map +1 -1
- package/dist/internal/request.js +2 -2
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/schema/annotations.js +2 -0
- package/dist/internal/schema/annotations.js.map +1 -1
- package/dist/internal/schema/schema.js +1 -0
- package/dist/internal/schema/schema.js.map +1 -1
- package/dist/internal/trie.js +5 -4
- package/dist/internal/trie.js.map +1 -1
- package/dist/testing/TestClock.d.ts +7 -6
- package/dist/testing/TestClock.d.ts.map +1 -1
- package/dist/testing/TestClock.js +6 -4
- package/dist/testing/TestClock.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +8 -8
- package/dist/testing/TestSchema.d.ts.map +1 -1
- package/dist/testing/TestSchema.js.map +1 -1
- package/dist/unstable/ai/AiError.d.ts +128 -48
- package/dist/unstable/ai/AiError.d.ts.map +1 -1
- package/dist/unstable/ai/AiError.js +11 -12
- package/dist/unstable/ai/AiError.js.map +1 -1
- package/dist/unstable/ai/Chat.d.ts +3 -3
- package/dist/unstable/ai/Chat.d.ts.map +1 -1
- package/dist/unstable/ai/Chat.js +4 -3
- package/dist/unstable/ai/Chat.js.map +1 -1
- package/dist/unstable/ai/LanguageModel.d.ts +4 -2
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +86 -14
- package/dist/unstable/ai/LanguageModel.js.map +1 -1
- package/dist/unstable/ai/McpSchema.d.ts +163 -87
- package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
- package/dist/unstable/ai/McpSchema.js +49 -12
- package/dist/unstable/ai/McpSchema.js.map +1 -1
- package/dist/unstable/ai/McpServer.d.ts +1 -1
- package/dist/unstable/ai/McpServer.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.js +35 -7
- package/dist/unstable/ai/McpServer.js.map +1 -1
- package/dist/unstable/ai/Model.d.ts +25 -7
- package/dist/unstable/ai/Model.d.ts.map +1 -1
- package/dist/unstable/ai/Model.js +22 -6
- package/dist/unstable/ai/Model.js.map +1 -1
- package/dist/unstable/ai/Prompt.d.ts +20 -20
- package/dist/unstable/ai/Prompt.d.ts.map +1 -1
- package/dist/unstable/ai/Response.d.ts +26 -26
- package/dist/unstable/ai/Response.d.ts.map +1 -1
- package/dist/unstable/ai/Response.js +1 -1
- package/dist/unstable/ai/Response.js.map +1 -1
- package/dist/unstable/ai/Tool.d.ts +19 -3
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +14 -9
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/ai/index.d.ts +1 -1
- package/dist/unstable/ai/index.js +1 -1
- package/dist/unstable/cli/CliError.d.ts +5 -5
- package/dist/unstable/cli/CliOutput.js +59 -6
- package/dist/unstable/cli/CliOutput.js.map +1 -1
- package/dist/unstable/cli/Command.d.ts +276 -19
- package/dist/unstable/cli/Command.d.ts.map +1 -1
- package/dist/unstable/cli/Command.js +234 -36
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cli/GlobalFlag.d.ts +125 -0
- package/dist/unstable/cli/GlobalFlag.d.ts.map +1 -0
- package/dist/unstable/cli/GlobalFlag.js +118 -0
- package/dist/unstable/cli/GlobalFlag.js.map +1 -0
- package/dist/unstable/cli/HelpDoc.d.ts +70 -2
- package/dist/unstable/cli/HelpDoc.d.ts.map +1 -1
- package/dist/unstable/cli/index.d.ts +4 -0
- package/dist/unstable/cli/index.d.ts.map +1 -1
- package/dist/unstable/cli/index.js +4 -0
- package/dist/unstable/cli/index.js.map +1 -1
- package/dist/unstable/cli/internal/command.d.ts +17 -8
- package/dist/unstable/cli/internal/command.d.ts.map +1 -1
- package/dist/unstable/cli/internal/command.js +32 -23
- package/dist/unstable/cli/internal/command.js.map +1 -1
- package/dist/unstable/cli/internal/completions/CommandDescriptor.js +7 -2
- package/dist/unstable/cli/internal/completions/CommandDescriptor.js.map +1 -1
- package/dist/unstable/cli/internal/help.d.ts +33 -0
- package/dist/unstable/cli/internal/help.d.ts.map +1 -0
- package/dist/unstable/cli/internal/help.js +107 -0
- package/dist/unstable/cli/internal/help.js.map +1 -0
- package/dist/unstable/cli/internal/parser.js +29 -36
- package/dist/unstable/cli/internal/parser.js.map +1 -1
- package/dist/unstable/cluster/ClusterCron.d.ts +1 -1
- package/dist/unstable/cluster/ClusterCron.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterCron.js +1 -1
- package/dist/unstable/cluster/ClusterCron.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +4 -3
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/cluster/Entity.d.ts +7 -6
- package/dist/unstable/cluster/Entity.d.ts.map +1 -1
- package/dist/unstable/cluster/Entity.js.map +1 -1
- package/dist/unstable/cluster/EntityResource.d.ts +2 -2
- package/dist/unstable/cluster/EntityResource.d.ts.map +1 -1
- package/dist/unstable/cluster/Envelope.d.ts +1 -1
- package/dist/unstable/cluster/K8sHttpClient.d.ts +1 -1
- package/dist/unstable/cluster/K8sHttpClient.js +4 -4
- package/dist/unstable/cluster/K8sHttpClient.js.map +1 -1
- package/dist/unstable/cluster/Message.d.ts +10 -10
- package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/MessageStorage.js +2 -1
- package/dist/unstable/cluster/MessageStorage.js.map +1 -1
- package/dist/unstable/cluster/Reply.d.ts +6 -6
- package/dist/unstable/cluster/Runner.d.ts +1 -1
- package/dist/unstable/cluster/Runners.d.ts.map +1 -1
- package/dist/unstable/cluster/Runners.js +4 -3
- package/dist/unstable/cluster/Runners.js.map +1 -1
- package/dist/unstable/cluster/Sharding.d.ts +2 -2
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +9 -7
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.d.ts +21 -21
- package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.js +20 -20
- package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.js +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/unstable/cluster/internal/entityManager.js +5 -4
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/cluster/internal/entityReaper.js +2 -1
- package/dist/unstable/cluster/internal/entityReaper.js.map +1 -1
- package/dist/unstable/cluster/internal/resourceRef.js +2 -1
- package/dist/unstable/cluster/internal/resourceRef.js.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.d.ts +36 -36
- package/dist/unstable/encoding/Msgpack.d.ts +1 -1
- package/dist/unstable/encoding/Ndjson.d.ts +1 -1
- package/dist/unstable/encoding/Sse.d.ts +4 -4
- package/dist/unstable/encoding/Sse.d.ts.map +1 -1
- package/dist/unstable/encoding/Sse.js +1 -1
- package/dist/unstable/encoding/Sse.js.map +1 -1
- package/dist/unstable/eventlog/EventJournal.d.ts +2 -2
- package/dist/unstable/eventlog/EventLog.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLog.js +2 -1
- package/dist/unstable/eventlog/EventLog.js.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.d.ts +6 -6
- package/dist/unstable/http/Cookies.d.ts +3 -3
- package/dist/unstable/http/Cookies.d.ts.map +1 -1
- package/dist/unstable/http/Cookies.js +2 -2
- package/dist/unstable/http/Cookies.js.map +1 -1
- package/dist/unstable/http/Headers.d.ts.map +1 -1
- package/dist/unstable/http/Headers.js +27 -10
- package/dist/unstable/http/Headers.js.map +1 -1
- package/dist/unstable/http/HttpBody.d.ts +17 -2
- package/dist/unstable/http/HttpBody.d.ts.map +1 -1
- package/dist/unstable/http/HttpBody.js +28 -1
- package/dist/unstable/http/HttpBody.js.map +1 -1
- package/dist/unstable/http/HttpClient.d.ts +37 -13
- package/dist/unstable/http/HttpClient.d.ts.map +1 -1
- package/dist/unstable/http/HttpClient.js +4 -4
- package/dist/unstable/http/HttpClient.js.map +1 -1
- package/dist/unstable/http/HttpClientError.d.ts +7 -7
- package/dist/unstable/http/HttpClientRequest.d.ts +27 -11
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.js +15 -3
- package/dist/unstable/http/HttpClientRequest.js.map +1 -1
- package/dist/unstable/http/HttpEffect.d.ts +3 -8
- package/dist/unstable/http/HttpEffect.d.ts.map +1 -1
- package/dist/unstable/http/HttpEffect.js +42 -56
- package/dist/unstable/http/HttpEffect.js.map +1 -1
- package/dist/unstable/http/HttpMethod.d.ts +4 -4
- package/dist/unstable/http/HttpMethod.d.ts.map +1 -1
- package/dist/unstable/http/HttpMethod.js +3 -3
- package/dist/unstable/http/HttpMethod.js.map +1 -1
- package/dist/unstable/http/HttpMiddleware.d.ts +1 -6
- package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/unstable/http/HttpMiddleware.js +8 -17
- package/dist/unstable/http/HttpMiddleware.js.map +1 -1
- package/dist/unstable/http/HttpServerError.d.ts +20 -33
- package/dist/unstable/http/HttpServerError.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerError.js +37 -44
- package/dist/unstable/http/HttpServerError.js.map +1 -1
- package/dist/unstable/http/HttpServerRequest.d.ts +1 -1
- package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRespondable.d.ts +2 -2
- package/dist/unstable/http/HttpServerRespondable.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRespondable.js +5 -5
- package/dist/unstable/http/HttpServerRespondable.js.map +1 -1
- package/dist/unstable/http/HttpServerResponse.d.ts +2 -1
- package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerResponse.js +3 -1
- package/dist/unstable/http/HttpServerResponse.js.map +1 -1
- package/dist/unstable/http/Multipart.d.ts +3 -3
- package/dist/unstable/http/UrlParams.d.ts +14 -6
- package/dist/unstable/http/UrlParams.d.ts.map +1 -1
- package/dist/unstable/http/UrlParams.js +1 -1
- package/dist/unstable/http/UrlParams.js.map +1 -1
- package/dist/unstable/http/internal/preResponseHandler.d.ts +2 -0
- package/dist/unstable/http/internal/preResponseHandler.d.ts.map +1 -0
- package/dist/unstable/http/internal/preResponseHandler.js +10 -0
- package/dist/unstable/http/internal/preResponseHandler.js.map +1 -0
- package/dist/unstable/httpapi/HttpApi.d.ts +3 -3
- package/dist/unstable/httpapi/HttpApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApi.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts +11 -5
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +23 -12
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.d.ts +7 -2
- package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.js +3 -3
- package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +31 -44
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.js +15 -24
- package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.d.ts +11 -0
- package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.js +29 -9
- package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.d.ts +3 -3
- package/dist/unstable/httpapi/HttpApiGroup.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +4 -4
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.d.ts +6 -0
- package/dist/unstable/httpapi/HttpApiScalar.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSecurity.d.ts +2 -2
- package/dist/unstable/httpapi/HttpApiSecurity.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSecurity.js.map +1 -1
- package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/OpenApi.js +32 -21
- package/dist/unstable/httpapi/OpenApi.js.map +1 -1
- package/dist/unstable/observability/Otlp.d.ts +12 -12
- package/dist/unstable/observability/Otlp.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.d.ts +2 -2
- package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.js +1 -1
- package/dist/unstable/observability/OtlpExporter.js.map +1 -1
- package/dist/unstable/observability/OtlpLogger.d.ts +4 -4
- package/dist/unstable/observability/OtlpLogger.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpLogger.js +7 -4
- package/dist/unstable/observability/OtlpLogger.js.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.d.ts +4 -4
- package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpTracer.d.ts +4 -4
- package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/unstable/persistence/KeyValueStore.d.ts +1 -1
- package/dist/unstable/persistence/KeyValueStore.js +6 -6
- package/dist/unstable/persistence/KeyValueStore.js.map +1 -1
- package/dist/unstable/persistence/Persistable.d.ts +2 -2
- package/dist/unstable/persistence/Persistable.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedCache.d.ts +6 -5
- package/dist/unstable/persistence/PersistedCache.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedCache.js +2 -1
- package/dist/unstable/persistence/PersistedCache.js.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.d.ts +12 -12
- package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.js +12 -11
- package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
- package/dist/unstable/persistence/Persistence.d.ts +1 -1
- package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
- package/dist/unstable/persistence/Persistence.js +2 -2
- package/dist/unstable/persistence/Persistence.js.map +1 -1
- package/dist/unstable/persistence/RateLimiter.d.ts +3 -3
- package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
- package/dist/unstable/persistence/RateLimiter.js +1 -1
- package/dist/unstable/persistence/RateLimiter.js.map +1 -1
- package/dist/unstable/process/ChildProcess.d.ts +5 -128
- package/dist/unstable/process/ChildProcess.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcess.js +1 -65
- package/dist/unstable/process/ChildProcess.js.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.d.ts +45 -7
- package/dist/unstable/process/ChildProcessSpawner.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.js +21 -1
- package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts +10 -10
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +16 -13
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts +8 -8
- package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.js +3 -3
- package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.d.ts +6 -0
- package/dist/unstable/reactivity/AtomRegistry.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.js +24 -7
- package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.d.ts +1 -1
- package/dist/unstable/reactivity/AtomRpc.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.js +1 -1
- package/dist/unstable/reactivity/AtomRpc.js.map +1 -1
- package/dist/unstable/reactivity/Hydration.d.ts +39 -0
- package/dist/unstable/reactivity/Hydration.d.ts.map +1 -0
- package/dist/unstable/reactivity/Hydration.js +76 -0
- package/dist/unstable/reactivity/Hydration.js.map +1 -0
- package/dist/unstable/reactivity/index.d.ts +4 -0
- package/dist/unstable/reactivity/index.d.ts.map +1 -1
- package/dist/unstable/reactivity/index.js +4 -0
- package/dist/unstable/reactivity/index.js.map +1 -1
- package/dist/unstable/rpc/Rpc.d.ts +4 -4
- package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
- package/dist/unstable/rpc/Rpc.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts +5 -26
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +6 -13
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/rpc/RpcGroup.d.ts +2 -2
- package/dist/unstable/rpc/RpcGroup.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcGroup.js.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.d.ts +3 -3
- package/dist/unstable/rpc/RpcMiddleware.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.js.map +1 -1
- package/dist/unstable/rpc/RpcSchema.d.ts +13 -0
- package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSchema.js +14 -0
- package/dist/unstable/rpc/RpcSchema.js.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.js +34 -9
- package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts +0 -7
- package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +15 -15
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/rpc/Utils.d.ts.map +1 -1
- package/dist/unstable/rpc/Utils.js +2 -1
- package/dist/unstable/rpc/Utils.js.map +1 -1
- package/dist/unstable/schema/Model.d.ts +1 -1
- package/dist/unstable/schema/Model.d.ts.map +1 -1
- package/dist/unstable/schema/VariantSchema.d.ts +3 -3
- package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
- package/dist/unstable/schema/VariantSchema.js +3 -3
- package/dist/unstable/schema/VariantSchema.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts +4 -4
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +6 -5
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/dist/unstable/socket/SocketServer.d.ts +3 -3
- package/dist/unstable/sql/Migrator.d.ts +1 -1
- package/dist/unstable/sql/SqlClient.d.ts +1 -1
- package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
- package/dist/unstable/sql/SqlError.d.ts +14 -14
- package/dist/unstable/sql/SqlError.d.ts.map +1 -1
- package/dist/unstable/sql/SqlError.js +9 -3
- package/dist/unstable/sql/SqlError.js.map +1 -1
- package/dist/unstable/sql/SqlModel.d.ts +2 -2
- package/dist/unstable/sql/SqlModel.d.ts.map +1 -1
- package/dist/unstable/sql/SqlModel.js +3 -3
- package/dist/unstable/sql/SqlModel.js.map +1 -1
- package/dist/unstable/sql/SqlSchema.d.ts +16 -5
- package/dist/unstable/sql/SqlSchema.d.ts.map +1 -1
- package/dist/unstable/sql/SqlSchema.js +17 -7
- package/dist/unstable/sql/SqlSchema.js.map +1 -1
- package/dist/unstable/sql/Statement.js +0 -1
- package/dist/unstable/sql/Statement.js.map +1 -1
- package/dist/unstable/workers/Worker.d.ts.map +1 -1
- package/dist/unstable/workers/Worker.js +2 -1
- package/dist/unstable/workers/Worker.js.map +1 -1
- package/dist/unstable/workflow/DurableClock.d.ts +3 -3
- package/dist/unstable/workflow/DurableClock.d.ts.map +1 -1
- package/dist/unstable/workflow/DurableClock.js +3 -3
- package/dist/unstable/workflow/DurableClock.js.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.js +2 -2
- package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts +3 -3
- package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
- package/dist/unstable/workflow/Workflow.js +1 -1
- package/dist/unstable/workflow/Workflow.js.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts +12 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js +137 -1
- package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +2 -2
- package/src/Array.ts +190 -342
- package/src/Cache.ts +9 -8
- package/src/Cause.ts +1 -1
- package/src/Channel.ts +554 -138
- package/src/Chunk.ts +81 -268
- package/src/Combiner.ts +280 -13
- package/src/Config.ts +183 -21
- package/src/Data.ts +538 -374
- package/src/DateTime.ts +24 -164
- package/src/Duration.ts +15 -15
- package/src/Effect.ts +991 -800
- package/src/Encoding.ts +879 -0
- package/src/Equal.ts +278 -111
- package/src/ErrorReporter.ts +459 -0
- package/src/Fiber.ts +9 -2
- package/src/FileSystem.ts +7 -8
- package/src/Filter.ts +48 -58
- package/src/Formatter.ts +253 -51
- package/src/Graph.ts +24 -11
- package/src/HashMap.ts +15 -14
- package/src/Iterable.ts +105 -50
- package/src/JsonSchema.ts +383 -10
- package/src/Latch.ts +112 -0
- package/src/Layer.ts +11 -15
- package/src/LayerMap.ts +5 -5
- package/src/LogLevel.ts +37 -0
- package/src/Logger.ts +33 -100
- package/src/ManagedRuntime.ts +1 -1
- package/src/Metric.ts +4 -4
- package/src/Optic.ts +948 -19
- package/src/Option.ts +30 -20
- package/src/Pipeable.ts +32 -1
- package/src/PlatformError.ts +5 -5
- package/src/Pool.ts +13 -11
- package/src/PubSub.ts +10 -9
- package/src/Pull.ts +1 -1
- package/src/Queue.ts +0 -1
- package/src/Random.ts +51 -14
- package/src/RcMap.ts +5 -5
- package/src/RcRef.ts +1 -1
- package/src/Record.ts +43 -152
- package/src/Reducer.ts +166 -7
- package/src/References.ts +4 -4
- package/src/Request.ts +3 -2
- package/src/RequestResolver.ts +9 -29
- package/src/Result.ts +13 -0
- package/src/Schedule.ts +318 -160
- package/src/Schema.ts +661 -116
- package/src/SchemaAST.ts +7 -6
- package/src/SchemaGetter.ts +12 -14
- package/src/SchemaParser.ts +11 -0
- package/src/SchemaRepresentation.ts +43 -24
- package/src/SchemaTransformation.ts +189 -4
- package/src/ScopedCache.ts +3 -3
- package/src/Semaphore.ts +356 -0
- package/src/ServiceMap.ts +47 -38
- package/src/Sink.ts +78 -26
- package/src/Stream.ts +566 -601
- package/src/Struct.ts +26 -0
- package/src/SubscriptionRef.ts +3 -2
- package/src/SynchronizedRef.ts +3 -2
- package/src/Trie.ts +18 -17
- package/src/TxChunk.ts +72 -53
- package/src/TxDeferred.ts +394 -0
- package/src/TxHashMap.ts +332 -285
- package/src/TxHashSet.ts +111 -116
- package/src/TxPriorityQueue.ts +767 -0
- package/src/TxPubSub.ts +789 -0
- package/src/TxQueue.ts +241 -251
- package/src/TxReentrantLock.ts +753 -0
- package/src/TxRef.ts +50 -38
- package/src/TxSemaphore.ts +29 -32
- package/src/TxSubscriptionRef.ts +639 -0
- package/src/Types.ts +78 -2
- package/src/index.ts +600 -21
- package/src/internal/core.ts +12 -5
- package/src/internal/dateTime.ts +9 -30
- package/src/internal/effect.ts +744 -265
- package/src/internal/hashMap.ts +9 -7
- package/src/internal/random.ts +20 -0
- package/src/internal/rcRef.ts +4 -3
- package/src/internal/request.ts +2 -2
- package/src/internal/schema/annotations.ts +2 -0
- package/src/internal/schema/schema.ts +1 -0
- package/src/internal/trie.ts +16 -9
- package/src/testing/TestClock.ts +13 -11
- package/src/testing/TestSchema.ts +10 -10
- package/src/unstable/ai/AiError.ts +97 -44
- package/src/unstable/ai/Chat.ts +12 -11
- package/src/unstable/ai/LanguageModel.ts +129 -25
- package/src/unstable/ai/McpSchema.ts +59 -13
- package/src/unstable/ai/McpServer.ts +48 -9
- package/src/unstable/ai/Model.ts +40 -9
- package/src/unstable/ai/Prompt.ts +37 -37
- package/src/unstable/ai/Response.ts +25 -25
- package/src/unstable/ai/Tool.ts +19 -13
- package/src/unstable/ai/index.ts +1 -1
- package/src/unstable/cli/CliOutput.ts +75 -6
- package/src/unstable/cli/Command.ts +501 -60
- package/src/unstable/cli/GlobalFlag.ts +243 -0
- package/src/unstable/cli/HelpDoc.ts +80 -2
- package/src/unstable/cli/index.ts +5 -0
- package/src/unstable/cli/internal/command.ts +50 -34
- package/src/unstable/cli/internal/completions/CommandDescriptor.ts +7 -2
- package/src/unstable/cli/internal/help.ts +146 -0
- package/src/unstable/cli/internal/parser.ts +33 -54
- package/src/unstable/cluster/ClusterCron.ts +2 -2
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +5 -4
- package/src/unstable/cluster/Entity.ts +11 -10
- package/src/unstable/cluster/EntityResource.ts +4 -4
- package/src/unstable/cluster/Envelope.ts +1 -1
- package/src/unstable/cluster/K8sHttpClient.ts +5 -5
- package/src/unstable/cluster/MessageStorage.ts +3 -5
- package/src/unstable/cluster/Runners.ts +6 -5
- package/src/unstable/cluster/Sharding.ts +12 -10
- package/src/unstable/cluster/ShardingConfig.ts +30 -31
- package/src/unstable/cluster/SqlRunnerStorage.ts +1 -1
- package/src/unstable/cluster/internal/entityManager.ts +9 -8
- package/src/unstable/cluster/internal/entityReaper.ts +2 -1
- package/src/unstable/cluster/internal/resourceRef.ts +2 -1
- package/src/unstable/encoding/Sse.ts +3 -5
- package/src/unstable/eventlog/EventLog.ts +2 -1
- package/src/unstable/http/Cookies.ts +3 -3
- package/src/unstable/http/Headers.ts +28 -13
- package/src/unstable/http/HttpBody.ts +42 -1
- package/src/unstable/http/HttpClient.ts +58 -23
- package/src/unstable/http/HttpClientRequest.ts +38 -13
- package/src/unstable/http/HttpEffect.ts +46 -68
- package/src/unstable/http/HttpMethod.ts +16 -4
- package/src/unstable/http/HttpMiddleware.ts +9 -24
- package/src/unstable/http/HttpServerError.ts +42 -45
- package/src/unstable/http/HttpServerRequest.ts +1 -1
- package/src/unstable/http/HttpServerRespondable.ts +6 -6
- package/src/unstable/http/HttpServerResponse.ts +4 -2
- package/src/unstable/http/Multipart.ts +2 -2
- package/src/unstable/http/UrlParams.ts +20 -5
- package/src/unstable/http/internal/preResponseHandler.ts +15 -0
- package/src/unstable/httpapi/HttpApi.ts +5 -5
- package/src/unstable/httpapi/HttpApiBuilder.ts +77 -21
- package/src/unstable/httpapi/HttpApiClient.ts +14 -6
- package/src/unstable/httpapi/HttpApiEndpoint.ts +67 -83
- package/src/unstable/httpapi/HttpApiError.ts +30 -9
- package/src/unstable/httpapi/HttpApiGroup.ts +6 -6
- package/src/unstable/httpapi/HttpApiMiddleware.ts +4 -4
- package/src/unstable/httpapi/HttpApiScalar.ts +6 -0
- package/src/unstable/httpapi/HttpApiSecurity.ts +3 -3
- package/src/unstable/httpapi/OpenApi.ts +41 -23
- package/src/unstable/observability/Otlp.ts +12 -12
- package/src/unstable/observability/OtlpExporter.ts +3 -3
- package/src/unstable/observability/OtlpLogger.ts +13 -9
- package/src/unstable/observability/OtlpMetrics.ts +4 -4
- package/src/unstable/observability/OtlpTracer.ts +4 -4
- package/src/unstable/persistence/KeyValueStore.ts +6 -6
- package/src/unstable/persistence/Persistable.ts +2 -2
- package/src/unstable/persistence/PersistedCache.ts +20 -9
- package/src/unstable/persistence/PersistedQueue.ts +25 -24
- package/src/unstable/persistence/Persistence.ts +3 -3
- package/src/unstable/persistence/RateLimiter.ts +4 -4
- package/src/unstable/process/ChildProcess.ts +6 -208
- package/src/unstable/process/ChildProcessSpawner.ts +75 -14
- package/src/unstable/reactivity/Atom.ts +27 -25
- package/src/unstable/reactivity/AtomHttpApi.ts +21 -20
- package/src/unstable/reactivity/AtomRegistry.ts +31 -7
- package/src/unstable/reactivity/AtomRpc.ts +3 -3
- package/src/unstable/reactivity/Hydration.ts +112 -0
- package/src/unstable/reactivity/index.ts +5 -0
- package/src/unstable/rpc/Rpc.ts +6 -6
- package/src/unstable/rpc/RpcClient.ts +12 -54
- package/src/unstable/rpc/RpcGroup.ts +4 -4
- package/src/unstable/rpc/RpcMiddleware.ts +3 -3
- package/src/unstable/rpc/RpcSchema.ts +17 -0
- package/src/unstable/rpc/RpcSerialization.ts +44 -9
- package/src/unstable/rpc/RpcServer.ts +21 -30
- package/src/unstable/rpc/Utils.ts +2 -1
- package/src/unstable/schema/VariantSchema.ts +6 -6
- package/src/unstable/socket/Socket.ts +16 -17
- package/src/unstable/sql/SqlClient.ts +1 -1
- package/src/unstable/sql/SqlError.ts +11 -9
- package/src/unstable/sql/SqlModel.ts +5 -5
- package/src/unstable/sql/SqlSchema.ts +41 -25
- package/src/unstable/sql/Statement.ts +0 -1
- package/src/unstable/workers/Worker.ts +2 -1
- package/src/unstable/workflow/DurableClock.ts +8 -8
- package/src/unstable/workflow/DurableDeferred.ts +2 -2
- package/src/unstable/workflow/Workflow.ts +6 -2
- package/src/unstable/workflow/WorkflowEngine.ts +185 -2
- package/dist/PartitionedSemaphore.d.ts +0 -52
- package/dist/PartitionedSemaphore.d.ts.map +0 -1
- package/dist/PartitionedSemaphore.js.map +0 -1
- package/dist/encoding/Base64.d.ts +0 -67
- package/dist/encoding/Base64.d.ts.map +0 -1
- package/dist/encoding/Base64.js +0 -146
- package/dist/encoding/Base64.js.map +0 -1
- package/dist/encoding/Base64Url.d.ts +0 -60
- package/dist/encoding/Base64Url.d.ts.map +0 -1
- package/dist/encoding/Base64Url.js +0 -89
- package/dist/encoding/Base64Url.js.map +0 -1
- package/dist/encoding/EncodingError.d.ts +0 -31
- package/dist/encoding/EncodingError.d.ts.map +0 -1
- package/dist/encoding/EncodingError.js +0 -22
- package/dist/encoding/EncodingError.js.map +0 -1
- package/dist/encoding/Hex.d.ts +0 -61
- package/dist/encoding/Hex.d.ts.map +0 -1
- package/dist/encoding/Hex.js +0 -115
- package/dist/encoding/Hex.js.map +0 -1
- package/dist/encoding/index.d.ts +0 -26
- package/dist/encoding/index.d.ts.map +0 -1
- package/dist/encoding/index.js +0 -27
- package/dist/encoding/index.js.map +0 -1
- package/dist/unstable/cli/internal/builtInFlags.d.ts +0 -7
- package/dist/unstable/cli/internal/builtInFlags.d.ts.map +0 -1
- package/dist/unstable/cli/internal/builtInFlags.js +0 -44
- package/dist/unstable/cli/internal/builtInFlags.js.map +0 -1
- package/src/PartitionedSemaphore.ts +0 -182
- package/src/encoding/Base64.ts +0 -366
- package/src/encoding/Base64Url.ts +0 -104
- package/src/encoding/EncodingError.ts +0 -35
- package/src/encoding/Hex.ts +0 -390
- package/src/encoding/index.ts +0 -31
- package/src/unstable/cli/internal/builtInFlags.ts +0 -78
package/src/internal/effect.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type * as Console from "../Console.ts"
|
|
|
5
5
|
import * as Duration from "../Duration.ts"
|
|
6
6
|
import type * as Effect from "../Effect.ts"
|
|
7
7
|
import * as Equal from "../Equal.ts"
|
|
8
|
+
import type { ErrorReporter } from "../ErrorReporter.ts"
|
|
8
9
|
import type * as Exit from "../Exit.ts"
|
|
9
10
|
import type * as Fiber from "../Fiber.ts"
|
|
10
11
|
import * as Filter from "../Filter.ts"
|
|
@@ -14,6 +15,7 @@ import { constant, constFalse, constTrue, constUndefined, constVoid, dual, ident
|
|
|
14
15
|
import * as Hash from "../Hash.ts"
|
|
15
16
|
import { toJson, toStringUnknown } from "../Inspectable.ts"
|
|
16
17
|
import * as Iterable from "../Iterable.ts"
|
|
18
|
+
import type * as _Latch from "../Latch.ts"
|
|
17
19
|
import type * as Logger from "../Logger.ts"
|
|
18
20
|
import type * as LogLevel from "../LogLevel.ts"
|
|
19
21
|
import type * as Metric from "../Metric.ts"
|
|
@@ -48,7 +50,9 @@ import type {
|
|
|
48
50
|
ExcludeTag,
|
|
49
51
|
ExtractReason,
|
|
50
52
|
ExtractTag,
|
|
53
|
+
NarrowReason,
|
|
51
54
|
NoInfer,
|
|
55
|
+
OmitReason,
|
|
52
56
|
ReasonOf,
|
|
53
57
|
ReasonTags,
|
|
54
58
|
Simplify,
|
|
@@ -340,7 +344,8 @@ export const causePrettyErrors = <E>(self: Cause.Cause<E>): Array<Error> => {
|
|
|
340
344
|
return errors
|
|
341
345
|
}
|
|
342
346
|
|
|
343
|
-
|
|
347
|
+
/** @internal */
|
|
348
|
+
export const causePrettyError = (
|
|
344
349
|
original: Record<string, unknown> | Error,
|
|
345
350
|
annotations?: ReadonlyMap<string, unknown>
|
|
346
351
|
): Error => {
|
|
@@ -489,17 +494,33 @@ const fiberIdStore = { id: 0 }
|
|
|
489
494
|
export const getCurrentFiber = (): Fiber.Fiber<any, any> | undefined => (globalThis as any)[currentFiberTypeId]
|
|
490
495
|
|
|
491
496
|
const keepAlive = (() => {
|
|
497
|
+
let isAvailable: boolean | undefined
|
|
498
|
+
const start = () => {
|
|
499
|
+
if (isAvailable === true) return setInterval(constVoid, 2_147_483_647)
|
|
500
|
+
else if (isAvailable === false) return undefined
|
|
501
|
+
|
|
502
|
+
try {
|
|
503
|
+
const running = setInterval(constVoid, 2_147_483_647)
|
|
504
|
+
isAvailable = true
|
|
505
|
+
return running
|
|
506
|
+
} catch {
|
|
507
|
+
isAvailable = false
|
|
508
|
+
return undefined
|
|
509
|
+
}
|
|
510
|
+
}
|
|
492
511
|
let count = 0
|
|
493
512
|
let running: ReturnType<typeof globalThis.setInterval> | undefined = undefined
|
|
494
513
|
return ({
|
|
495
514
|
increment() {
|
|
496
515
|
count++
|
|
497
|
-
running
|
|
516
|
+
if (running === undefined) {
|
|
517
|
+
running = start()
|
|
518
|
+
}
|
|
498
519
|
},
|
|
499
520
|
decrement() {
|
|
500
521
|
count--
|
|
501
522
|
if (count === 0 && running !== undefined) {
|
|
502
|
-
|
|
523
|
+
clearInterval(running)
|
|
503
524
|
running = undefined
|
|
504
525
|
}
|
|
505
526
|
}
|
|
@@ -784,6 +805,7 @@ export const fiberJoinAll = <A extends Iterable<Fiber.Fiber<any, any>>>(self: A)
|
|
|
784
805
|
> =>
|
|
785
806
|
callback((resume) => {
|
|
786
807
|
const fibers = Array.from(self)
|
|
808
|
+
if (fibers.length === 0) return resume(succeed(Arr.empty() as any))
|
|
787
809
|
const out = new Array<any>(fibers.length) as Arr.NonEmptyArray<any>
|
|
788
810
|
const cancels = Arr.empty<() => void>()
|
|
789
811
|
let done = 0
|
|
@@ -812,13 +834,29 @@ export const fiberInterrupt = <A, E>(
|
|
|
812
834
|
|
|
813
835
|
/** @internal */
|
|
814
836
|
export const fiberInterruptAs: {
|
|
815
|
-
(
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
837
|
+
(
|
|
838
|
+
fiberId: number | undefined,
|
|
839
|
+
annotations?: ServiceMap.ServiceMap<never> | undefined
|
|
840
|
+
): <A, E>(self: Fiber.Fiber<A, E>) => Effect.Effect<void>
|
|
841
|
+
<A, E>(
|
|
842
|
+
self: Fiber.Fiber<A, E>,
|
|
843
|
+
fiberId: number | undefined,
|
|
844
|
+
annotations?: ServiceMap.ServiceMap<never> | undefined
|
|
845
|
+
): Effect.Effect<void>
|
|
846
|
+
} = dual(
|
|
847
|
+
(args) => hasProperty(args[0], FiberTypeId),
|
|
848
|
+
<A, E>(
|
|
849
|
+
self: Fiber.Fiber<A, E>,
|
|
850
|
+
fiberId: number | undefined,
|
|
851
|
+
annotations?: ServiceMap.ServiceMap<never> | undefined
|
|
852
|
+
): Effect.Effect<void> =>
|
|
853
|
+
withFiber((parent) => {
|
|
854
|
+
let ann = fiberStackAnnotations(parent)
|
|
855
|
+
ann = ann && annotations ? ServiceMap.merge(ann, annotations) : ann ?? annotations
|
|
856
|
+
self.interruptUnsafe(fiberId, ann)
|
|
857
|
+
return asVoid(fiberAwait(self))
|
|
858
|
+
})
|
|
859
|
+
)
|
|
822
860
|
|
|
823
861
|
/** @internal */
|
|
824
862
|
export const fiberInterruptAll = <A extends Iterable<Fiber.Fiber<any, any>>>(
|
|
@@ -1945,17 +1983,17 @@ export const exitFindErrorOption = <A, E>(self: Exit.Exit<A, E>): Option.Option<
|
|
|
1945
1983
|
|
|
1946
1984
|
/** @internal */
|
|
1947
1985
|
export const service: {
|
|
1948
|
-
<I, S>(service: ServiceMap.
|
|
1986
|
+
<I, S>(service: ServiceMap.Key<I, S>): Effect.Effect<S, never, I>
|
|
1949
1987
|
} = fromYieldable as any
|
|
1950
1988
|
|
|
1951
1989
|
/** @internal */
|
|
1952
1990
|
export const serviceOption = <I, S>(
|
|
1953
|
-
service: ServiceMap.
|
|
1991
|
+
service: ServiceMap.Key<I, S>
|
|
1954
1992
|
): Effect.Effect<Option.Option<S>> => withFiber((fiber) => succeed(ServiceMap.getOption(fiber.services, service)))
|
|
1955
1993
|
|
|
1956
1994
|
/** @internal */
|
|
1957
1995
|
export const serviceOptional = <I, S>(
|
|
1958
|
-
service: ServiceMap.
|
|
1996
|
+
service: ServiceMap.Key<I, S>
|
|
1959
1997
|
): Effect.Effect<S, Cause.NoSuchElementError> =>
|
|
1960
1998
|
withFiber((fiber) =>
|
|
1961
1999
|
fiber.services.mapUnsafe.has(service.key)
|
|
@@ -1983,23 +2021,8 @@ export const updateServices: {
|
|
|
1983
2021
|
const nextServices = f(prev)
|
|
1984
2022
|
if (prev === nextServices) return self as any
|
|
1985
2023
|
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))
|
|
2024
|
+
return onExitPrimitive(self, () => {
|
|
2025
|
+
fiber.setServices(prev)
|
|
2003
2026
|
return undefined
|
|
2004
2027
|
})
|
|
2005
2028
|
})
|
|
@@ -2008,27 +2031,26 @@ export const updateServices: {
|
|
|
2008
2031
|
/** @internal */
|
|
2009
2032
|
export const updateService: {
|
|
2010
2033
|
<I, A>(
|
|
2011
|
-
service: ServiceMap.
|
|
2034
|
+
service: ServiceMap.Key<I, A>,
|
|
2012
2035
|
f: (value: A) => A
|
|
2013
2036
|
): <XA, E, R>(self: Effect.Effect<XA, E, R>) => Effect.Effect<XA, E, R | I>
|
|
2014
2037
|
<XA, E, R, I, A>(
|
|
2015
2038
|
self: Effect.Effect<XA, E, R>,
|
|
2016
|
-
service: ServiceMap.
|
|
2039
|
+
service: ServiceMap.Key<I, A>,
|
|
2017
2040
|
f: (value: A) => A
|
|
2018
2041
|
): Effect.Effect<XA, E, R | I>
|
|
2019
2042
|
} = dual(
|
|
2020
2043
|
3,
|
|
2021
2044
|
<XA, E, R, I, A>(
|
|
2022
2045
|
self: Effect.Effect<XA, E, R>,
|
|
2023
|
-
service: ServiceMap.
|
|
2046
|
+
service: ServiceMap.Key<I, A>,
|
|
2024
2047
|
f: (value: A) => A
|
|
2025
2048
|
): Effect.Effect<XA, E, R | I> =>
|
|
2026
|
-
|
|
2027
|
-
const prev = ServiceMap.getUnsafe(
|
|
2049
|
+
updateServices(self, (s) => {
|
|
2050
|
+
const prev = ServiceMap.getUnsafe(s, service)
|
|
2028
2051
|
const next = f(prev)
|
|
2029
|
-
if (prev === next) return
|
|
2030
|
-
|
|
2031
|
-
return onExit(self, () => sync(() => fiber.setServices(ServiceMap.add(fiber.services, service, prev))))
|
|
2052
|
+
if (prev === next) return s
|
|
2053
|
+
return ServiceMap.add(s, service, next)
|
|
2032
2054
|
})
|
|
2033
2055
|
)
|
|
2034
2056
|
|
|
@@ -2066,20 +2088,20 @@ export const provideServices: {
|
|
|
2066
2088
|
/** @internal */
|
|
2067
2089
|
export const provideService: {
|
|
2068
2090
|
<I, S>(
|
|
2069
|
-
service: ServiceMap.
|
|
2091
|
+
service: ServiceMap.Key<I, S>
|
|
2070
2092
|
): {
|
|
2071
2093
|
(implementation: S): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, I>>
|
|
2072
2094
|
<A, E, R>(self: Effect.Effect<A, E, R>, implementation: S): Effect.Effect<A, E, Exclude<R, I>>
|
|
2073
2095
|
}
|
|
2074
2096
|
<I, S>(
|
|
2075
|
-
key: ServiceMap.
|
|
2097
|
+
key: ServiceMap.Key<I, S>,
|
|
2076
2098
|
implementation: S
|
|
2077
2099
|
): <A, E, R>(
|
|
2078
2100
|
self: Effect.Effect<A, E, R>
|
|
2079
2101
|
) => Effect.Effect<A, E, Exclude<R, I>>
|
|
2080
2102
|
<A, E, R, I, S>(
|
|
2081
2103
|
self: Effect.Effect<A, E, R>,
|
|
2082
|
-
service: ServiceMap.
|
|
2104
|
+
service: ServiceMap.Key<I, S>,
|
|
2083
2105
|
implementation: S
|
|
2084
2106
|
): Effect.Effect<A, E, Exclude<R, I>>
|
|
2085
2107
|
} = function(this: any) {
|
|
@@ -2092,34 +2114,33 @@ export const provideService: {
|
|
|
2092
2114
|
|
|
2093
2115
|
const provideServiceImpl = <A, E, R, I, S>(
|
|
2094
2116
|
self: Effect.Effect<A, E, R>,
|
|
2095
|
-
service: ServiceMap.
|
|
2117
|
+
service: ServiceMap.Key<I, S>,
|
|
2096
2118
|
implementation: S
|
|
2097
2119
|
): 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))))
|
|
2120
|
+
updateServices(self, (s) => {
|
|
2121
|
+
const prev = s.mapUnsafe.get(service.key)
|
|
2122
|
+
if (prev === implementation) return s
|
|
2123
|
+
return ServiceMap.add(s, service, implementation)
|
|
2103
2124
|
}) as any
|
|
2104
2125
|
|
|
2105
2126
|
/** @internal */
|
|
2106
2127
|
export const provideServiceEffect: {
|
|
2107
2128
|
<I, S, E2, R2>(
|
|
2108
|
-
service: ServiceMap.
|
|
2129
|
+
service: ServiceMap.Key<I, S>,
|
|
2109
2130
|
acquire: Effect.Effect<S, E2, R2>
|
|
2110
2131
|
): <A, E, R>(
|
|
2111
2132
|
self: Effect.Effect<A, E, R>
|
|
2112
2133
|
) => Effect.Effect<A, E | E2, Exclude<R, I> | R2>
|
|
2113
2134
|
<A, E, R, I, S, E2, R2>(
|
|
2114
2135
|
self: Effect.Effect<A, E, R>,
|
|
2115
|
-
service: ServiceMap.
|
|
2136
|
+
service: ServiceMap.Key<I, S>,
|
|
2116
2137
|
acquire: Effect.Effect<S, E2, R2>
|
|
2117
2138
|
): Effect.Effect<A, E | E2, Exclude<R, I> | R2>
|
|
2118
2139
|
} = dual(
|
|
2119
2140
|
3,
|
|
2120
2141
|
<A, E, R, I, S, E2, R2>(
|
|
2121
2142
|
self: Effect.Effect<A, E, R>,
|
|
2122
|
-
service: ServiceMap.
|
|
2143
|
+
service: ServiceMap.Key<I, S>,
|
|
2123
2144
|
acquire: Effect.Effect<S, E2, R2>
|
|
2124
2145
|
): Effect.Effect<A, E | E2, Exclude<R, I> | R2> =>
|
|
2125
2146
|
flatMap(acquire, (implementation) => provideService(self, service, implementation))
|
|
@@ -2203,19 +2224,12 @@ export const filterOrFail: {
|
|
|
2203
2224
|
predicate: Predicate.Predicate<NoInfer<A>>,
|
|
2204
2225
|
orFailWith: (a: NoInfer<A>) => E2
|
|
2205
2226
|
): <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
2227
|
<A, B extends A>(
|
|
2211
2228
|
refinement: Predicate.Refinement<NoInfer<A>, B>
|
|
2212
2229
|
): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<B, Cause.NoSuchElementError | E, R>
|
|
2213
2230
|
<A>(
|
|
2214
2231
|
predicate: Predicate.Predicate<NoInfer<A>>
|
|
2215
2232
|
): <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
2233
|
<A, E, R, E2, B extends A>(
|
|
2220
2234
|
self: Effect.Effect<A, E, R>,
|
|
2221
2235
|
refinement: Predicate.Refinement<NoInfer<A>, B>,
|
|
@@ -2226,11 +2240,6 @@ export const filterOrFail: {
|
|
|
2226
2240
|
predicate: Predicate.Predicate<NoInfer<A>>,
|
|
2227
2241
|
orFailWith: (a: NoInfer<A>) => E2
|
|
2228
2242
|
): 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
2243
|
<A, E, R, B extends A>(
|
|
2235
2244
|
self: Effect.Effect<A, E, R>,
|
|
2236
2245
|
refinement: Predicate.Refinement<NoInfer<A>, B>
|
|
@@ -2239,18 +2248,14 @@ export const filterOrFail: {
|
|
|
2239
2248
|
self: Effect.Effect<A, E, R>,
|
|
2240
2249
|
predicate: Predicate.Predicate<NoInfer<A>>
|
|
2241
2250
|
): 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
2251
|
} = dual((args) => isEffect(args[0]), <A, E, R, E2>(
|
|
2247
2252
|
self: Effect.Effect<A, E, R>,
|
|
2248
|
-
|
|
2253
|
+
predicate: Predicate.Predicate<NoInfer<A>>,
|
|
2249
2254
|
orFailWith?: (a: any) => E2
|
|
2250
2255
|
): Effect.Effect<any, E | E2 | Cause.NoSuchElementError, R> =>
|
|
2251
2256
|
filterOrElse(
|
|
2252
2257
|
self,
|
|
2253
|
-
|
|
2258
|
+
predicate as any,
|
|
2254
2259
|
orFailWith ? (a: any) => fail(orFailWith(a)) : () => fail(new NoSuchElementError() as E2)
|
|
2255
2260
|
))
|
|
2256
2261
|
|
|
@@ -2400,27 +2405,55 @@ const OnFailureProto = makePrimitiveProto({
|
|
|
2400
2405
|
|
|
2401
2406
|
/** @internal */
|
|
2402
2407
|
export const catchCauseIf: {
|
|
2403
|
-
<E,
|
|
2404
|
-
|
|
2405
|
-
f: (
|
|
2408
|
+
<E, B, E2, R2>(
|
|
2409
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
2410
|
+
f: (cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2406
2411
|
): <A, R>(
|
|
2407
2412
|
self: Effect.Effect<A, E, R>
|
|
2408
|
-
) => Effect.Effect<A | B,
|
|
2409
|
-
<A, E, R, B, E2, R2
|
|
2413
|
+
) => Effect.Effect<A | B, E | E2, R | R2>
|
|
2414
|
+
<A, E, R, B, E2, R2>(
|
|
2410
2415
|
self: Effect.Effect<A, E, R>,
|
|
2411
|
-
|
|
2412
|
-
f: (
|
|
2413
|
-
): Effect.Effect<A | B,
|
|
2416
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
2417
|
+
f: (cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2418
|
+
): Effect.Effect<A | B, E | E2, R | R2>
|
|
2414
2419
|
} = dual(
|
|
2415
2420
|
3,
|
|
2416
|
-
<A, E, R, B, E2, R2
|
|
2417
|
-
self: Effect.Effect<A, E, R>,
|
|
2418
|
-
|
|
2419
|
-
f: (
|
|
2420
|
-
): Effect.Effect<A | B,
|
|
2421
|
-
catchCause(self, (cause): Effect.Effect<B,
|
|
2422
|
-
|
|
2423
|
-
|
|
2421
|
+
<A, E, R, B, E2, R2>(
|
|
2422
|
+
self: Effect.Effect<A, E, R>,
|
|
2423
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
2424
|
+
f: (cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2425
|
+
): Effect.Effect<A | B, E | E2, R | R2> =>
|
|
2426
|
+
catchCause(self, (cause): Effect.Effect<B, E | E2, R2> => {
|
|
2427
|
+
if (!predicate(cause)) {
|
|
2428
|
+
return failCause(cause) as any
|
|
2429
|
+
}
|
|
2430
|
+
return internalCall(() => f(cause))
|
|
2431
|
+
})
|
|
2432
|
+
)
|
|
2433
|
+
|
|
2434
|
+
/** @internal */
|
|
2435
|
+
export const catchCauseFilter: {
|
|
2436
|
+
<E, B, E2, R2, EB, X extends Cause.Cause<any>>(
|
|
2437
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
2438
|
+
f: (failure: EB, cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2439
|
+
): <A, R>(
|
|
2440
|
+
self: Effect.Effect<A, E, R>
|
|
2441
|
+
) => Effect.Effect<A | B, Cause.Cause.Error<X> | E2, R | R2>
|
|
2442
|
+
<A, E, R, B, E2, R2, EB, X extends Cause.Cause<any>>(
|
|
2443
|
+
self: Effect.Effect<A, E, R>,
|
|
2444
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
2445
|
+
f: (failure: EB, cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2446
|
+
): Effect.Effect<A | B, Cause.Cause.Error<X> | E2, R | R2>
|
|
2447
|
+
} = dual(
|
|
2448
|
+
3,
|
|
2449
|
+
<A, E, R, B, E2, R2, EB, X extends Cause.Cause<any>>(
|
|
2450
|
+
self: Effect.Effect<A, E, R>,
|
|
2451
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
2452
|
+
f: (failure: EB, cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2453
|
+
): Effect.Effect<A | B, Cause.Cause.Error<X> | E2, R | R2> =>
|
|
2454
|
+
catchCause(self, (cause): Effect.Effect<B, Cause.Cause.Error<X> | E2, R2> => {
|
|
2455
|
+
const eb = filter(cause)
|
|
2456
|
+
return Result.isFailure(eb) ? failCause(eb.failure) : internalCall(() => f(eb.success, cause))
|
|
2424
2457
|
})
|
|
2425
2458
|
)
|
|
2426
2459
|
|
|
@@ -2438,7 +2471,7 @@ export const catch_: {
|
|
|
2438
2471
|
<A, E, R, B, E2, R2>(
|
|
2439
2472
|
self: Effect.Effect<A, E, R>,
|
|
2440
2473
|
f: (a: NoInfer<E>) => Effect.Effect<B, E2, R2>
|
|
2441
|
-
): Effect.Effect<A | B, E2, R | R2> =>
|
|
2474
|
+
): Effect.Effect<A | B, E2, R | R2> => catchCauseFilter(self, findError as any, (e: any) => f(e)) as any
|
|
2442
2475
|
)
|
|
2443
2476
|
|
|
2444
2477
|
/** @internal */
|
|
@@ -2469,7 +2502,7 @@ export const catchDefect: {
|
|
|
2469
2502
|
<A, E, R, B, E2, R2>(
|
|
2470
2503
|
self: Effect.Effect<A, E, R>,
|
|
2471
2504
|
f: (defect: unknown) => Effect.Effect<B, E2, R2>
|
|
2472
|
-
): Effect.Effect<A | B, E | E2, R | R2> =>
|
|
2505
|
+
): Effect.Effect<A | B, E | E2, R | R2> => catchCauseFilter(self, findDefect as any, f as any) as any
|
|
2473
2506
|
)
|
|
2474
2507
|
|
|
2475
2508
|
/** @internal */
|
|
@@ -2492,32 +2525,56 @@ export const tapCause: {
|
|
|
2492
2525
|
|
|
2493
2526
|
/** @internal */
|
|
2494
2527
|
export const tapCauseIf: {
|
|
2495
|
-
<E,
|
|
2496
|
-
|
|
2497
|
-
f: (
|
|
2528
|
+
<E, B, E2, R2>(
|
|
2529
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
2530
|
+
f: (cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2498
2531
|
): <A, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E | E2, R | R2>
|
|
2499
|
-
<A, E, R,
|
|
2532
|
+
<A, E, R, B, E2, R2>(
|
|
2500
2533
|
self: Effect.Effect<A, E, R>,
|
|
2501
|
-
|
|
2502
|
-
f: (
|
|
2534
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
2535
|
+
f: (cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2503
2536
|
): Effect.Effect<A, E | E2, R | R2>
|
|
2504
2537
|
} = dual(
|
|
2505
2538
|
3,
|
|
2506
|
-
<A, E, R,
|
|
2539
|
+
<A, E, R, B, E2, R2>(
|
|
2507
2540
|
self: Effect.Effect<A, E, R>,
|
|
2508
|
-
|
|
2509
|
-
f: (
|
|
2541
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
2542
|
+
f: (cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2510
2543
|
): Effect.Effect<A, E | E2, R | R2> =>
|
|
2511
2544
|
catchCauseIf(
|
|
2512
2545
|
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))
|
|
2546
|
+
predicate,
|
|
2547
|
+
(cause) => andThen(internalCall(() => f(cause)), failCause(cause))
|
|
2518
2548
|
)
|
|
2519
2549
|
)
|
|
2520
2550
|
|
|
2551
|
+
/** @internal */
|
|
2552
|
+
export const tapCauseFilter: {
|
|
2553
|
+
<E, B, E2, R2, EB, X extends Cause.Cause<any>>(
|
|
2554
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
2555
|
+
f: (a: EB, cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2556
|
+
): <A, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E | E2, R | R2>
|
|
2557
|
+
<A, E, R, B, E2, R2, EB, X extends Cause.Cause<any>>(
|
|
2558
|
+
self: Effect.Effect<A, E, R>,
|
|
2559
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
2560
|
+
f: (a: EB, cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2561
|
+
): Effect.Effect<A, E | E2, R | R2>
|
|
2562
|
+
} = dual(
|
|
2563
|
+
3,
|
|
2564
|
+
<A, E, R, B, E2, R2, EB, X extends Cause.Cause<any>>(
|
|
2565
|
+
self: Effect.Effect<A, E, R>,
|
|
2566
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
2567
|
+
f: (a: EB, cause: Cause.Cause<E>) => Effect.Effect<B, E2, R2>
|
|
2568
|
+
): Effect.Effect<A, E | E2, R | R2> =>
|
|
2569
|
+
catchCause(self, (cause) => {
|
|
2570
|
+
const result = filter(cause)
|
|
2571
|
+
if (Result.isFailure(result)) {
|
|
2572
|
+
return failCause(cause)
|
|
2573
|
+
}
|
|
2574
|
+
return andThen(internalCall(() => f(result.success, cause)), failCause(cause))
|
|
2575
|
+
})
|
|
2576
|
+
)
|
|
2577
|
+
|
|
2521
2578
|
/** @internal */
|
|
2522
2579
|
export const tapError: {
|
|
2523
2580
|
<E, B, E2, R2>(
|
|
@@ -2532,7 +2589,7 @@ export const tapError: {
|
|
|
2532
2589
|
<A, E, R, B, E2, R2>(
|
|
2533
2590
|
self: Effect.Effect<A, E, R>,
|
|
2534
2591
|
f: (e: NoInfer<E>) => Effect.Effect<B, E2, R2>
|
|
2535
|
-
): Effect.Effect<A, E | E2, R | R2> =>
|
|
2592
|
+
): Effect.Effect<A, E | E2, R | R2> => tapCauseFilter(self, findError as any, (e: any) => f(e)) as any
|
|
2536
2593
|
)
|
|
2537
2594
|
|
|
2538
2595
|
/** @internal */
|
|
@@ -2599,7 +2656,7 @@ export const tapDefect: {
|
|
|
2599
2656
|
<A, E, R, B, E2, R2>(
|
|
2600
2657
|
self: Effect.Effect<A, E, R>,
|
|
2601
2658
|
f: (defect: unknown) => Effect.Effect<B, E2, R2>
|
|
2602
|
-
): Effect.Effect<A, E | E2, R | R2> =>
|
|
2659
|
+
): Effect.Effect<A, E | E2, R | R2> => tapCauseFilter(self, findDefect as any, (_: any) => f(_)) as any
|
|
2603
2660
|
)
|
|
2604
2661
|
|
|
2605
2662
|
/** @internal */
|
|
@@ -2609,10 +2666,10 @@ export const catchIf: {
|
|
|
2609
2666
|
f: (e: EB) => Effect.Effect<A2, E2, R2>,
|
|
2610
2667
|
orElse?: ((e: Exclude<E, EB>) => Effect.Effect<A3, E3, R3>) | undefined
|
|
2611
2668
|
): <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:
|
|
2669
|
+
<E, A2, E2, R2, A3 = never, E3 = E, R3 = never>(
|
|
2670
|
+
predicate: Predicate.Predicate<NoInfer<E>>,
|
|
2671
|
+
f: (e: NoInfer<E>) => Effect.Effect<A2, E2, R2>,
|
|
2672
|
+
orElse?: ((e: NoInfer<E>) => Effect.Effect<A3, E3, R3>) | undefined
|
|
2616
2673
|
): <A, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
2617
2674
|
<A, E, R, EB extends E, A2, E2, R2, A3 = never, E3 = Exclude<E, EB>, R3 = never>(
|
|
2618
2675
|
self: Effect.Effect<A, E, R>,
|
|
@@ -2620,28 +2677,59 @@ export const catchIf: {
|
|
|
2620
2677
|
f: (e: EB) => Effect.Effect<A2, E2, R2>,
|
|
2621
2678
|
orElse?: ((e: Exclude<E, EB>) => Effect.Effect<A3, E3, R3>) | undefined
|
|
2622
2679
|
): Effect.Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
2623
|
-
<A, E, R,
|
|
2680
|
+
<A, E, R, A2, E2, R2, A3 = never, E3 = E, R3 = never>(
|
|
2681
|
+
self: Effect.Effect<A, E, R>,
|
|
2682
|
+
predicate: Predicate.Predicate<E>,
|
|
2683
|
+
f: (e: E) => Effect.Effect<A2, E2, R2>,
|
|
2684
|
+
orElse?: ((e: E) => Effect.Effect<A3, E3, R3>) | undefined
|
|
2685
|
+
): Effect.Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
2686
|
+
} = dual(
|
|
2687
|
+
(args) => isEffect(args[0]),
|
|
2688
|
+
<A, E, R, A2, E2, R2, A3 = never, E3 = E, R3 = never>(
|
|
2689
|
+
self: Effect.Effect<A, E, R>,
|
|
2690
|
+
predicate: Predicate.Predicate<E>,
|
|
2691
|
+
f: (e: E) => Effect.Effect<A2, E2, R2>,
|
|
2692
|
+
orElse?: ((e: E) => Effect.Effect<A3, E3, R3>) | undefined
|
|
2693
|
+
): Effect.Effect<A | A2 | A3, E2 | E3, R | R2 | R3> =>
|
|
2694
|
+
catchCause(self, (cause): Effect.Effect<A2 | A3, E2 | E3, R2 | R3> => {
|
|
2695
|
+
const error = findError(cause)
|
|
2696
|
+
if (Result.isFailure(error)) return failCause(error.failure)
|
|
2697
|
+
if (!predicate(error.success)) {
|
|
2698
|
+
return orElse ? internalCall(() => orElse(error.success as any)) : failCause(cause as any as Cause.Cause<E3>)
|
|
2699
|
+
}
|
|
2700
|
+
return internalCall(() => f(error.success as any))
|
|
2701
|
+
})
|
|
2702
|
+
)
|
|
2703
|
+
|
|
2704
|
+
/** @internal */
|
|
2705
|
+
export const catchFilter: {
|
|
2706
|
+
<E, EB, A2, E2, R2, X, A3 = never, E3 = X, R3 = never>(
|
|
2707
|
+
filter: Filter.Filter<NoInfer<E>, EB, X>,
|
|
2708
|
+
f: (e: EB) => Effect.Effect<A2, E2, R2>,
|
|
2709
|
+
orElse?: ((e: X) => Effect.Effect<A3, E3, R3>) | undefined
|
|
2710
|
+
): <A, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
2711
|
+
<A, E, R, EB, A2, E2, R2, X, A3 = never, E3 = X, R3 = never>(
|
|
2624
2712
|
self: Effect.Effect<A, E, R>,
|
|
2625
|
-
filter: Filter.
|
|
2626
|
-
f: (e:
|
|
2627
|
-
orElse?: ((e:
|
|
2713
|
+
filter: Filter.Filter<NoInfer<E>, EB, X>,
|
|
2714
|
+
f: (e: EB) => Effect.Effect<A2, E2, R2>,
|
|
2715
|
+
orElse?: ((e: X) => Effect.Effect<A3, E3, R3>) | undefined
|
|
2628
2716
|
): Effect.Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
2629
2717
|
} = dual(
|
|
2630
2718
|
(args) => isEffect(args[0]),
|
|
2631
2719
|
<A, E, R, EB, A2, E2, R2, X, A3 = never, E3 = X, R3 = never>(
|
|
2632
2720
|
self: Effect.Effect<A, E, R>,
|
|
2633
|
-
filter: Filter.Filter<NoInfer<E>, EB, X
|
|
2721
|
+
filter: Filter.Filter<NoInfer<E>, EB, X>,
|
|
2634
2722
|
f: (e: EB) => Effect.Effect<A2, E2, R2>,
|
|
2635
2723
|
orElse?: ((e: X) => Effect.Effect<A3, E3, R3>) | undefined
|
|
2636
2724
|
): Effect.Effect<A | A2 | A3, E2 | E3, R | R2 | R3> =>
|
|
2637
2725
|
catchCause(self, (cause): Effect.Effect<A2 | A3, E2 | E3, R2 | R3> => {
|
|
2638
2726
|
const error = findError(cause)
|
|
2639
2727
|
if (Result.isFailure(error)) return failCause(error.failure)
|
|
2640
|
-
const result =
|
|
2728
|
+
const result = filter(error.success)
|
|
2641
2729
|
if (Result.isFailure(result)) {
|
|
2642
2730
|
return orElse ? internalCall(() => orElse(result.failure as any)) : failCause(cause as any as Cause.Cause<E3>)
|
|
2643
2731
|
}
|
|
2644
|
-
return internalCall(() => f(result.success
|
|
2732
|
+
return internalCall(() => f(result.success))
|
|
2645
2733
|
})
|
|
2646
2734
|
)
|
|
2647
2735
|
|
|
@@ -2777,7 +2865,7 @@ export const catchTags: {
|
|
|
2777
2865
|
>
|
|
2778
2866
|
} = dual((args) => isEffect(args[0]), (self: Effect.Effect<any, any, any>, cases: Record<string, any>, orElse: any) => {
|
|
2779
2867
|
let keys: Array<string>
|
|
2780
|
-
return
|
|
2868
|
+
return catchFilter(
|
|
2781
2869
|
self,
|
|
2782
2870
|
(e) => {
|
|
2783
2871
|
keys ??= Object.keys(cases)
|
|
@@ -2787,7 +2875,7 @@ export const catchTags: {
|
|
|
2787
2875
|
},
|
|
2788
2876
|
(e: any) => internalCall(() => cases[e["_tag"] as string](e)),
|
|
2789
2877
|
orElse
|
|
2790
|
-
)
|
|
2878
|
+
) as any
|
|
2791
2879
|
})
|
|
2792
2880
|
|
|
2793
2881
|
/** @internal */
|
|
@@ -2805,8 +2893,16 @@ export const catchReason: {
|
|
|
2805
2893
|
>(
|
|
2806
2894
|
errorTag: K,
|
|
2807
2895
|
reasonTag: RK,
|
|
2808
|
-
f: (
|
|
2809
|
-
|
|
2896
|
+
f: (
|
|
2897
|
+
reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK>,
|
|
2898
|
+
error: NarrowReason<ExtractTag<NoInfer<E>, K>, RK>
|
|
2899
|
+
) => Effect.Effect<A2, E2, R2>,
|
|
2900
|
+
orElse?:
|
|
2901
|
+
| ((
|
|
2902
|
+
reasons: ExcludeReason<ExtractTag<NoInfer<E>, K>, RK>,
|
|
2903
|
+
error: OmitReason<ExtractTag<NoInfer<E>, K>, RK>
|
|
2904
|
+
) => Effect.Effect<A3, E3, R3>)
|
|
2905
|
+
| undefined
|
|
2810
2906
|
): <A, R>(
|
|
2811
2907
|
self: Effect.Effect<A, E, R>
|
|
2812
2908
|
) => Effect.Effect<
|
|
@@ -2830,8 +2926,16 @@ export const catchReason: {
|
|
|
2830
2926
|
self: Effect.Effect<A, E, R>,
|
|
2831
2927
|
errorTag: K,
|
|
2832
2928
|
reasonTag: RK,
|
|
2833
|
-
f: (
|
|
2834
|
-
|
|
2929
|
+
f: (
|
|
2930
|
+
reason: ExtractReason<ExtractTag<E, K>, RK>,
|
|
2931
|
+
error: NarrowReason<ExtractTag<E, K>, RK>
|
|
2932
|
+
) => Effect.Effect<A2, E2, R2>,
|
|
2933
|
+
orElse?:
|
|
2934
|
+
| ((
|
|
2935
|
+
reasons: ExcludeReason<ExtractTag<E, K>, RK>,
|
|
2936
|
+
error: OmitReason<ExtractTag<E, K>, RK>
|
|
2937
|
+
) => Effect.Effect<A3, E3, R3>)
|
|
2938
|
+
| undefined
|
|
2835
2939
|
): Effect.Effect<
|
|
2836
2940
|
A | A2 | Exclude<A3, unassigned>,
|
|
2837
2941
|
(A3 extends unassigned ? E : ExcludeTag<E, K>) | E2 | E3,
|
|
@@ -2855,8 +2959,13 @@ export const catchReason: {
|
|
|
2855
2959
|
self: Effect.Effect<A, E, R>,
|
|
2856
2960
|
errorTag: K,
|
|
2857
2961
|
reasonTag: RK,
|
|
2858
|
-
f: (reason: ExtractReason<ExtractTag<E, K>, RK>) => Effect.Effect<A2, E2, R2>,
|
|
2859
|
-
orElse?:
|
|
2962
|
+
f: (reason: ExtractReason<ExtractTag<E, K>, RK>, error: ExtractTag<E, K>) => Effect.Effect<A2, E2, R2>,
|
|
2963
|
+
orElse?:
|
|
2964
|
+
| ((
|
|
2965
|
+
reasons: ExcludeReason<ExtractTag<E, K>, RK>,
|
|
2966
|
+
error: OmitReason<ExtractTag<E, K>, RK>
|
|
2967
|
+
) => Effect.Effect<A3, E3, R3>)
|
|
2968
|
+
| undefined
|
|
2860
2969
|
): Effect.Effect<
|
|
2861
2970
|
A | A2 | Exclude<A3, unassigned>,
|
|
2862
2971
|
(A3 extends unassigned ? E : ExcludeTag<E, K>) | E2 | E3,
|
|
@@ -2867,8 +2976,8 @@ export const catchReason: {
|
|
|
2867
2976
|
((e: any) => isTagged(e, errorTag) && hasProperty(e, "reason")) as any,
|
|
2868
2977
|
(e: any): Effect.Effect<A2 | A3, E | E2 | E3, R2 | R3> => {
|
|
2869
2978
|
const reason = e.reason as any
|
|
2870
|
-
if (isTagged(reason, reasonTag)) return f(reason as any)
|
|
2871
|
-
return orElse ? internalCall(() => orElse(reason)) : fail(e)
|
|
2979
|
+
if (isTagged(reason, reasonTag)) return f(reason as any, e)
|
|
2980
|
+
return orElse ? internalCall(() => orElse(reason, e)) : fail(e)
|
|
2872
2981
|
}
|
|
2873
2982
|
) as any
|
|
2874
2983
|
)
|
|
@@ -2880,7 +2989,8 @@ export const catchReasons: {
|
|
|
2880
2989
|
E,
|
|
2881
2990
|
Cases extends {
|
|
2882
2991
|
[RK in ReasonTags<ExtractTag<NoInfer<E>, K>>]+?: (
|
|
2883
|
-
reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK
|
|
2992
|
+
reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK>,
|
|
2993
|
+
error: NarrowReason<ExtractTag<NoInfer<E>, K>, RK>
|
|
2884
2994
|
) => Effect.Effect<any, any, any>
|
|
2885
2995
|
},
|
|
2886
2996
|
A2 = unassigned,
|
|
@@ -2891,7 +3001,8 @@ export const catchReasons: {
|
|
|
2891
3001
|
cases: Cases,
|
|
2892
3002
|
orElse?:
|
|
2893
3003
|
| ((
|
|
2894
|
-
reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string
|
|
3004
|
+
reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>,
|
|
3005
|
+
error: OmitReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>
|
|
2895
3006
|
) => Effect.Effect<A2, E2, R2>)
|
|
2896
3007
|
| undefined
|
|
2897
3008
|
): <A, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<
|
|
@@ -2918,7 +3029,8 @@ export const catchReasons: {
|
|
|
2918
3029
|
K extends Tags<E>,
|
|
2919
3030
|
Cases extends {
|
|
2920
3031
|
[RK in ReasonTags<ExtractTag<E, K>>]+?: (
|
|
2921
|
-
reason: ExtractReason<ExtractTag<E, K>, RK
|
|
3032
|
+
reason: ExtractReason<ExtractTag<E, K>, RK>,
|
|
3033
|
+
error: NarrowReason<ExtractTag<E, K>, RK>
|
|
2922
3034
|
) => Effect.Effect<any, any, any>
|
|
2923
3035
|
},
|
|
2924
3036
|
A2 = unassigned,
|
|
@@ -2930,7 +3042,8 @@ export const catchReasons: {
|
|
|
2930
3042
|
cases: Cases,
|
|
2931
3043
|
orElse?:
|
|
2932
3044
|
| ((
|
|
2933
|
-
reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string
|
|
3045
|
+
reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>,
|
|
3046
|
+
error: OmitReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>
|
|
2934
3047
|
) => Effect.Effect<A2, E2, R2>)
|
|
2935
3048
|
| undefined
|
|
2936
3049
|
): Effect.Effect<
|
|
@@ -2963,9 +3076,9 @@ export const catchReasons: {
|
|
|
2963
3076
|
const reason = e.reason
|
|
2964
3077
|
keys ??= Object.keys(cases)
|
|
2965
3078
|
if (keys.includes(reason._tag)) {
|
|
2966
|
-
return internalCall(() => (cases as any)[reason._tag](reason))
|
|
3079
|
+
return internalCall(() => (cases as any)[reason._tag](reason, e))
|
|
2967
3080
|
}
|
|
2968
|
-
return orElse ? internalCall(() => orElse(reason)) : fail(e)
|
|
3081
|
+
return orElse ? internalCall(() => orElse(reason, e)) : fail(e)
|
|
2969
3082
|
}
|
|
2970
3083
|
)
|
|
2971
3084
|
})
|
|
@@ -2998,7 +3111,7 @@ export const unwrapReason: {
|
|
|
2998
3111
|
self: Effect.Effect<A, E, R>,
|
|
2999
3112
|
errorTag: K
|
|
3000
3113
|
): Effect.Effect<A, ExcludeTag<E, K> | ReasonOf<ExtractTag<E, K>>, R> =>
|
|
3001
|
-
|
|
3114
|
+
catchFilter(
|
|
3002
3115
|
self,
|
|
3003
3116
|
(e: any) => {
|
|
3004
3117
|
if (isTagged(e, errorTag) && hasProperty(e, "reason")) {
|
|
@@ -3007,7 +3120,7 @@ export const unwrapReason: {
|
|
|
3007
3120
|
return Result.fail(e)
|
|
3008
3121
|
},
|
|
3009
3122
|
fail as any
|
|
3010
|
-
)
|
|
3123
|
+
) as any
|
|
3011
3124
|
)
|
|
3012
3125
|
|
|
3013
3126
|
/** @internal */
|
|
@@ -3091,14 +3204,14 @@ export const eventually = <A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect
|
|
|
3091
3204
|
/** @internal */
|
|
3092
3205
|
export const ignore: <
|
|
3093
3206
|
Arg extends Effect.Effect<any, any, any> | {
|
|
3094
|
-
readonly log?: boolean | LogLevel.
|
|
3207
|
+
readonly log?: boolean | LogLevel.Severity | undefined
|
|
3095
3208
|
} | undefined = {
|
|
3096
|
-
readonly log?: boolean | LogLevel.
|
|
3209
|
+
readonly log?: boolean | LogLevel.Severity | undefined
|
|
3097
3210
|
}
|
|
3098
3211
|
>(
|
|
3099
3212
|
effectOrOptions: Arg,
|
|
3100
3213
|
options?: {
|
|
3101
|
-
readonly log?: boolean | LogLevel.
|
|
3214
|
+
readonly log?: boolean | LogLevel.Severity | undefined
|
|
3102
3215
|
} | undefined
|
|
3103
3216
|
) => [Arg] extends [Effect.Effect<infer _A, infer _E, infer _R>] ? Effect.Effect<void, never, _R>
|
|
3104
3217
|
: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<void, never, R> = dual(
|
|
@@ -3106,7 +3219,7 @@ export const ignore: <
|
|
|
3106
3219
|
<A, E, R>(
|
|
3107
3220
|
self: Effect.Effect<A, E, R>,
|
|
3108
3221
|
options?: {
|
|
3109
|
-
readonly log?: boolean | LogLevel.
|
|
3222
|
+
readonly log?: boolean | LogLevel.Severity | undefined
|
|
3110
3223
|
} | undefined
|
|
3111
3224
|
): Effect.Effect<void, never, R> => {
|
|
3112
3225
|
if (!options?.log) {
|
|
@@ -3126,14 +3239,14 @@ export const ignore: <
|
|
|
3126
3239
|
/** @internal */
|
|
3127
3240
|
export const ignoreCause: <
|
|
3128
3241
|
Arg extends Effect.Effect<any, any, any> | {
|
|
3129
|
-
readonly log?: boolean | LogLevel.
|
|
3242
|
+
readonly log?: boolean | LogLevel.Severity | undefined
|
|
3130
3243
|
} | undefined = {
|
|
3131
|
-
readonly log?: boolean | LogLevel.
|
|
3244
|
+
readonly log?: boolean | LogLevel.Severity | undefined
|
|
3132
3245
|
}
|
|
3133
3246
|
>(
|
|
3134
3247
|
effectOrOptions: Arg,
|
|
3135
3248
|
options?: {
|
|
3136
|
-
readonly log?: boolean | LogLevel.
|
|
3249
|
+
readonly log?: boolean | LogLevel.Severity | undefined
|
|
3137
3250
|
} | undefined
|
|
3138
3251
|
) => [Arg] extends [Effect.Effect<infer _A, infer _E, infer _R>] ? Effect.Effect<void, never, _R>
|
|
3139
3252
|
: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<void, never, R> = dual(
|
|
@@ -3141,7 +3254,7 @@ export const ignoreCause: <
|
|
|
3141
3254
|
<A, E, R>(
|
|
3142
3255
|
self: Effect.Effect<A, E, R>,
|
|
3143
3256
|
options?: {
|
|
3144
|
-
readonly log?: boolean | LogLevel.
|
|
3257
|
+
readonly log?: boolean | LogLevel.Severity | undefined
|
|
3145
3258
|
} | undefined
|
|
3146
3259
|
): Effect.Effect<void, never, R> => {
|
|
3147
3260
|
if (!options?.log) {
|
|
@@ -3403,24 +3516,24 @@ export const isSuccess: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect
|
|
|
3403
3516
|
/** @internal */
|
|
3404
3517
|
export const delay: {
|
|
3405
3518
|
(
|
|
3406
|
-
duration: Duration.
|
|
3519
|
+
duration: Duration.Input
|
|
3407
3520
|
): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
|
|
3408
3521
|
<A, E, R>(
|
|
3409
3522
|
self: Effect.Effect<A, E, R>,
|
|
3410
|
-
duration: Duration.
|
|
3523
|
+
duration: Duration.Input
|
|
3411
3524
|
): Effect.Effect<A, E, R>
|
|
3412
3525
|
} = dual(
|
|
3413
3526
|
2,
|
|
3414
3527
|
<A, E, R>(
|
|
3415
3528
|
self: Effect.Effect<A, E, R>,
|
|
3416
|
-
duration: Duration.
|
|
3529
|
+
duration: Duration.Input
|
|
3417
3530
|
): Effect.Effect<A, E, R> => andThen(sleep(duration), self)
|
|
3418
3531
|
)
|
|
3419
3532
|
|
|
3420
3533
|
/** @internal */
|
|
3421
3534
|
export const timeoutOrElse: {
|
|
3422
3535
|
<A2, E2, R2>(options: {
|
|
3423
|
-
readonly duration: Duration.
|
|
3536
|
+
readonly duration: Duration.Input
|
|
3424
3537
|
readonly onTimeout: LazyArg<Effect.Effect<A2, E2, R2>>
|
|
3425
3538
|
}): <A, E, R>(
|
|
3426
3539
|
self: Effect.Effect<A, E, R>
|
|
@@ -3428,7 +3541,7 @@ export const timeoutOrElse: {
|
|
|
3428
3541
|
<A, E, R, A2, E2, R2>(
|
|
3429
3542
|
self: Effect.Effect<A, E, R>,
|
|
3430
3543
|
options: {
|
|
3431
|
-
readonly duration: Duration.
|
|
3544
|
+
readonly duration: Duration.Input
|
|
3432
3545
|
readonly onTimeout: LazyArg<Effect.Effect<A2, E2, R2>>
|
|
3433
3546
|
}
|
|
3434
3547
|
): Effect.Effect<A | A2, E | E2, R | R2>
|
|
@@ -3437,7 +3550,7 @@ export const timeoutOrElse: {
|
|
|
3437
3550
|
<A, E, R, A2, E2, R2>(
|
|
3438
3551
|
self: Effect.Effect<A, E, R>,
|
|
3439
3552
|
options: {
|
|
3440
|
-
readonly duration: Duration.
|
|
3553
|
+
readonly duration: Duration.Input
|
|
3441
3554
|
readonly onTimeout: LazyArg<Effect.Effect<A2, E2, R2>>
|
|
3442
3555
|
}
|
|
3443
3556
|
): Effect.Effect<A | A2, E | E2, R | R2> =>
|
|
@@ -3450,19 +3563,19 @@ export const timeoutOrElse: {
|
|
|
3450
3563
|
/** @internal */
|
|
3451
3564
|
export const timeout: {
|
|
3452
3565
|
(
|
|
3453
|
-
duration: Duration.
|
|
3566
|
+
duration: Duration.Input
|
|
3454
3567
|
): <A, E, R>(
|
|
3455
3568
|
self: Effect.Effect<A, E, R>
|
|
3456
3569
|
) => Effect.Effect<A, E | Cause.TimeoutError, R>
|
|
3457
3570
|
<A, E, R>(
|
|
3458
3571
|
self: Effect.Effect<A, E, R>,
|
|
3459
|
-
duration: Duration.
|
|
3572
|
+
duration: Duration.Input
|
|
3460
3573
|
): Effect.Effect<A, E | Cause.TimeoutError, R>
|
|
3461
3574
|
} = dual(
|
|
3462
3575
|
2,
|
|
3463
3576
|
<A, E, R>(
|
|
3464
3577
|
self: Effect.Effect<A, E, R>,
|
|
3465
|
-
duration: Duration.
|
|
3578
|
+
duration: Duration.Input
|
|
3466
3579
|
): Effect.Effect<A, E | TimeoutError, R> =>
|
|
3467
3580
|
timeoutOrElse(self, {
|
|
3468
3581
|
duration,
|
|
@@ -3473,19 +3586,19 @@ export const timeout: {
|
|
|
3473
3586
|
/** @internal */
|
|
3474
3587
|
export const timeoutOption: {
|
|
3475
3588
|
(
|
|
3476
|
-
duration: Duration.
|
|
3589
|
+
duration: Duration.Input
|
|
3477
3590
|
): <A, E, R>(
|
|
3478
3591
|
self: Effect.Effect<A, E, R>
|
|
3479
3592
|
) => Effect.Effect<Option.Option<A>, E, R>
|
|
3480
3593
|
<A, E, R>(
|
|
3481
3594
|
self: Effect.Effect<A, E, R>,
|
|
3482
|
-
duration: Duration.
|
|
3595
|
+
duration: Duration.Input
|
|
3483
3596
|
): Effect.Effect<Option.Option<A>, E, R>
|
|
3484
3597
|
} = dual(
|
|
3485
3598
|
2,
|
|
3486
3599
|
<A, E, R>(
|
|
3487
3600
|
self: Effect.Effect<A, E, R>,
|
|
3488
|
-
duration: Duration.
|
|
3601
|
+
duration: Duration.Input
|
|
3489
3602
|
): Effect.Effect<Option.Option<A>, E, R> =>
|
|
3490
3603
|
raceFirst(
|
|
3491
3604
|
asSome(self),
|
|
@@ -3646,11 +3759,11 @@ export const provideScope: {
|
|
|
3646
3759
|
/** @internal */
|
|
3647
3760
|
export const scoped = <A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect<A, E, Exclude<R, Scope.Scope>> =>
|
|
3648
3761
|
withFiber((fiber) => {
|
|
3649
|
-
const prev =
|
|
3762
|
+
const prev = fiber.services
|
|
3650
3763
|
const scope = scopeMakeUnsafe()
|
|
3651
3764
|
fiber.setServices(ServiceMap.add(fiber.services, scopeTag, scope))
|
|
3652
3765
|
return onExitPrimitive(self, (exit) => {
|
|
3653
|
-
fiber.setServices(
|
|
3766
|
+
fiber.setServices(prev)
|
|
3654
3767
|
return scopeCloseUnsafe(scope, exit)
|
|
3655
3768
|
})
|
|
3656
3769
|
}) as any
|
|
@@ -3758,34 +3871,51 @@ export const ensuring: {
|
|
|
3758
3871
|
|
|
3759
3872
|
/** @internal */
|
|
3760
3873
|
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>
|
|
3874
|
+
<A, E, XE, XR>(
|
|
3875
|
+
predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>,
|
|
3876
|
+
f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect.Effect<void, XE, XR>
|
|
3767
3877
|
): <R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E | XE, R | XR>
|
|
3768
|
-
<A, E, R, XE, XR
|
|
3878
|
+
<A, E, R, XE, XR>(
|
|
3769
3879
|
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>
|
|
3880
|
+
predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>,
|
|
3881
|
+
f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect.Effect<void, XE, XR>
|
|
3775
3882
|
): Effect.Effect<A, E | XE, R | XR>
|
|
3776
3883
|
} = dual(
|
|
3777
3884
|
3,
|
|
3778
|
-
<A, E, R, XE, XR
|
|
3885
|
+
<A, E, R, XE, XR>(
|
|
3779
3886
|
self: Effect.Effect<A, E, R>,
|
|
3780
|
-
|
|
3781
|
-
f: (
|
|
3782
|
-
pass: Filter.Pass<Exit.Exit<NoInfer<A>, NoInfer<E>>, Result>,
|
|
3783
|
-
exit: Exit.Exit<NoInfer<A>, NoInfer<E>>
|
|
3784
|
-
) => Effect.Effect<void, XE, XR>
|
|
3887
|
+
predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>,
|
|
3888
|
+
f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect.Effect<void, XE, XR>
|
|
3785
3889
|
): Effect.Effect<A, E | XE, R | XR> =>
|
|
3786
3890
|
onExit(self, (exit) => {
|
|
3787
|
-
|
|
3788
|
-
|
|
3891
|
+
if (!predicate(exit)) {
|
|
3892
|
+
return void_
|
|
3893
|
+
}
|
|
3894
|
+
return f(exit)
|
|
3895
|
+
})
|
|
3896
|
+
)
|
|
3897
|
+
|
|
3898
|
+
/** @internal */
|
|
3899
|
+
export const onExitFilter: {
|
|
3900
|
+
<A, E, XE, XR, B, X>(
|
|
3901
|
+
filter: Filter.Filter<Exit.Exit<NoInfer<A>, NoInfer<E>>, B, X>,
|
|
3902
|
+
f: (b: B, exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect.Effect<void, XE, XR>
|
|
3903
|
+
): <R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E | XE, R | XR>
|
|
3904
|
+
<A, E, R, XE, XR, B, X>(
|
|
3905
|
+
self: Effect.Effect<A, E, R>,
|
|
3906
|
+
filter: Filter.Filter<Exit.Exit<NoInfer<A>, NoInfer<E>>, B, X>,
|
|
3907
|
+
f: (b: B, exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect.Effect<void, XE, XR>
|
|
3908
|
+
): Effect.Effect<A, E | XE, R | XR>
|
|
3909
|
+
} = dual(
|
|
3910
|
+
3,
|
|
3911
|
+
<A, E, R, XE, XR, B, X>(
|
|
3912
|
+
self: Effect.Effect<A, E, R>,
|
|
3913
|
+
filter: Filter.Filter<Exit.Exit<NoInfer<A>, NoInfer<E>>, B, X>,
|
|
3914
|
+
f: (b: B, exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect.Effect<void, XE, XR>
|
|
3915
|
+
): Effect.Effect<A, E | XE, R | XR> =>
|
|
3916
|
+
onExit(self, (exit) => {
|
|
3917
|
+
const b = filter(exit)
|
|
3918
|
+
return Result.isFailure(b) ? void_ : f(b.success, exit)
|
|
3789
3919
|
})
|
|
3790
3920
|
)
|
|
3791
3921
|
|
|
@@ -3803,37 +3933,66 @@ export const onError: {
|
|
|
3803
3933
|
<A, E, R, XE, XR>(
|
|
3804
3934
|
self: Effect.Effect<A, E, R>,
|
|
3805
3935
|
f: (cause: Cause.Cause<NoInfer<E>>) => Effect.Effect<void, XE, XR>
|
|
3806
|
-
): Effect.Effect<A, E | XE, R | XR> =>
|
|
3936
|
+
): Effect.Effect<A, E | XE, R | XR> => onExitFilter(self, exitFilterCause as any, f as any) as any
|
|
3807
3937
|
)
|
|
3808
3938
|
|
|
3809
3939
|
/** @internal */
|
|
3810
3940
|
export const onErrorIf: {
|
|
3811
|
-
<E,
|
|
3812
|
-
|
|
3813
|
-
f: (
|
|
3941
|
+
<E, XE, XR>(
|
|
3942
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
3943
|
+
f: (cause: Cause.Cause<E>) => Effect.Effect<void, XE, XR>
|
|
3814
3944
|
): <A, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E | XE, R | XR>
|
|
3815
|
-
<A, E, R, XE, XR
|
|
3945
|
+
<A, E, R, XE, XR>(
|
|
3816
3946
|
self: Effect.Effect<A, E, R>,
|
|
3817
|
-
|
|
3818
|
-
f: (
|
|
3947
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
3948
|
+
f: (cause: Cause.Cause<E>) => Effect.Effect<void, XE, XR>
|
|
3819
3949
|
): Effect.Effect<A, E | XE, R | XR>
|
|
3820
3950
|
} = dual(
|
|
3821
3951
|
3,
|
|
3822
|
-
<A, E, R, XE, XR
|
|
3952
|
+
<A, E, R, XE, XR>(
|
|
3823
3953
|
self: Effect.Effect<A, E, R>,
|
|
3824
|
-
|
|
3825
|
-
f: (
|
|
3954
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
3955
|
+
f: (cause: Cause.Cause<E>) => Effect.Effect<void, XE, XR>
|
|
3826
3956
|
): Effect.Effect<A, E | XE, R | XR> =>
|
|
3827
3957
|
onExitIf(
|
|
3828
3958
|
self,
|
|
3829
|
-
(
|
|
3830
|
-
if (exit._tag !== "Failure")
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3959
|
+
(exit): exit is Exit.Failure<A, E> => {
|
|
3960
|
+
if (exit._tag !== "Failure") {
|
|
3961
|
+
return false
|
|
3962
|
+
}
|
|
3963
|
+
return predicate(exit.cause)
|
|
3964
|
+
},
|
|
3965
|
+
(exit) => f((exit as Exit.Failure<A, E>).cause)
|
|
3834
3966
|
) as any
|
|
3835
3967
|
)
|
|
3836
3968
|
|
|
3969
|
+
/** @internal */
|
|
3970
|
+
export const onErrorFilter: {
|
|
3971
|
+
<A, E, EB, X, XE, XR>(
|
|
3972
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
3973
|
+
f: (failure: EB, cause: Cause.Cause<E>) => Effect.Effect<void, XE, XR>
|
|
3974
|
+
): <R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E | XE, R | XR>
|
|
3975
|
+
<A, E, R, EB, X, XE, XR>(
|
|
3976
|
+
self: Effect.Effect<A, E, R>,
|
|
3977
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
3978
|
+
f: (failure: EB, cause: Cause.Cause<E>) => Effect.Effect<void, XE, XR>
|
|
3979
|
+
): Effect.Effect<A, E | XE, R | XR>
|
|
3980
|
+
} = dual(
|
|
3981
|
+
3,
|
|
3982
|
+
<A, E, R, EB, X, XE, XR>(
|
|
3983
|
+
self: Effect.Effect<A, E, R>,
|
|
3984
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
3985
|
+
f: (failure: EB, cause: Cause.Cause<E>) => Effect.Effect<void, XE, XR>
|
|
3986
|
+
): Effect.Effect<A, E | XE, R | XR> =>
|
|
3987
|
+
onExit(self, (exit) => {
|
|
3988
|
+
if (exit._tag !== "Failure") {
|
|
3989
|
+
return void_
|
|
3990
|
+
}
|
|
3991
|
+
const result = filter(exit.cause)
|
|
3992
|
+
return Result.isFailure(result) ? void_ : f(result.success, exit.cause)
|
|
3993
|
+
})
|
|
3994
|
+
)
|
|
3995
|
+
|
|
3837
3996
|
/** @internal */
|
|
3838
3997
|
export const onInterrupt: {
|
|
3839
3998
|
<XE, XR>(
|
|
@@ -3848,8 +4007,7 @@ export const onInterrupt: {
|
|
|
3848
4007
|
<A, E, R, XE, XR>(
|
|
3849
4008
|
self: Effect.Effect<A, E, R>,
|
|
3850
4009
|
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)
|
|
4010
|
+
): Effect.Effect<A, E | XE, R | XR> => onErrorFilter(causeFilterInterruptors as any, finalizer)(self) as any
|
|
3853
4011
|
)
|
|
3854
4012
|
|
|
3855
4013
|
/** @internal */
|
|
@@ -3873,19 +4031,19 @@ export const acquireUseRelease = <Resource, E, R, A, E2, R2, E3, R3>(
|
|
|
3873
4031
|
|
|
3874
4032
|
/** @internal */
|
|
3875
4033
|
export const cachedInvalidateWithTTL: {
|
|
3876
|
-
(timeToLive: Duration.
|
|
4034
|
+
(timeToLive: Duration.Input): <A, E, R>(
|
|
3877
4035
|
self: Effect.Effect<A, E, R>
|
|
3878
4036
|
) => Effect.Effect<[Effect.Effect<A, E, R>, Effect.Effect<void>]>
|
|
3879
4037
|
<A, E, R>(
|
|
3880
4038
|
self: Effect.Effect<A, E, R>,
|
|
3881
|
-
timeToLive: Duration.
|
|
4039
|
+
timeToLive: Duration.Input
|
|
3882
4040
|
): Effect.Effect<[Effect.Effect<A, E, R>, Effect.Effect<void>]>
|
|
3883
4041
|
} = dual(2, <A, E, R>(
|
|
3884
4042
|
self: Effect.Effect<A, E, R>,
|
|
3885
|
-
ttl: Duration.
|
|
4043
|
+
ttl: Duration.Input
|
|
3886
4044
|
): Effect.Effect<[Effect.Effect<A, E, R>, Effect.Effect<void>]> =>
|
|
3887
4045
|
sync(() => {
|
|
3888
|
-
const ttlMillis = Duration.toMillis(Duration.
|
|
4046
|
+
const ttlMillis = Duration.toMillis(Duration.fromInputUnsafe(ttl))
|
|
3889
4047
|
const isFinite = Number.isFinite(ttlMillis)
|
|
3890
4048
|
const latch = makeLatchUnsafe(false)
|
|
3891
4049
|
let expiresAt = 0
|
|
@@ -3918,17 +4076,17 @@ export const cachedInvalidateWithTTL: {
|
|
|
3918
4076
|
/** @internal */
|
|
3919
4077
|
export const cachedWithTTL: {
|
|
3920
4078
|
(
|
|
3921
|
-
timeToLive: Duration.
|
|
4079
|
+
timeToLive: Duration.Input
|
|
3922
4080
|
): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<Effect.Effect<A, E, R>>
|
|
3923
4081
|
<A, E, R>(
|
|
3924
4082
|
self: Effect.Effect<A, E, R>,
|
|
3925
|
-
timeToLive: Duration.
|
|
4083
|
+
timeToLive: Duration.Input
|
|
3926
4084
|
): Effect.Effect<Effect.Effect<A, E, R>>
|
|
3927
4085
|
} = dual(
|
|
3928
4086
|
2,
|
|
3929
4087
|
<A, E, R>(
|
|
3930
4088
|
self: Effect.Effect<A, E, R>,
|
|
3931
|
-
timeToLive: Duration.
|
|
4089
|
+
timeToLive: Duration.Input
|
|
3932
4090
|
): Effect.Effect<Effect.Effect<A, E, R>> => map(cachedInvalidateWithTTL(self, timeToLive), (tuple) => tuple[0])
|
|
3933
4091
|
)
|
|
3934
4092
|
|
|
@@ -4074,10 +4232,147 @@ export const partition: {
|
|
|
4074
4232
|
): Effect.Effect<[excluded: Array<E>, satisfying: Array<B>], never, R> =>
|
|
4075
4233
|
map(
|
|
4076
4234
|
forEach(elements, (a, i) => result(f(a, i)), options),
|
|
4077
|
-
(results) => Arr.
|
|
4235
|
+
(results) => Arr.partition(results, identity)
|
|
4236
|
+
)
|
|
4237
|
+
)
|
|
4238
|
+
|
|
4239
|
+
/** @internal */
|
|
4240
|
+
export const validate: {
|
|
4241
|
+
<A, B, E, R>(
|
|
4242
|
+
f: (a: A, i: number) => Effect.Effect<B, E, R>,
|
|
4243
|
+
options?: {
|
|
4244
|
+
readonly concurrency?: Concurrency | undefined
|
|
4245
|
+
readonly discard?: false | undefined
|
|
4246
|
+
} | undefined
|
|
4247
|
+
): (elements: Iterable<A>) => Effect.Effect<Array<B>, Arr.NonEmptyArray<E>, R>
|
|
4248
|
+
<A, B, E, R>(
|
|
4249
|
+
f: (a: A, i: number) => Effect.Effect<B, E, R>,
|
|
4250
|
+
options: {
|
|
4251
|
+
readonly concurrency?: Concurrency | undefined
|
|
4252
|
+
readonly discard: true
|
|
4253
|
+
}
|
|
4254
|
+
): (elements: Iterable<A>) => Effect.Effect<void, Arr.NonEmptyArray<E>, R>
|
|
4255
|
+
<A, B, E, R>(
|
|
4256
|
+
elements: Iterable<A>,
|
|
4257
|
+
f: (a: A, i: number) => Effect.Effect<B, E, R>,
|
|
4258
|
+
options?: {
|
|
4259
|
+
readonly concurrency?: Concurrency | undefined
|
|
4260
|
+
readonly discard?: false | undefined
|
|
4261
|
+
} | undefined
|
|
4262
|
+
): Effect.Effect<Array<B>, Arr.NonEmptyArray<E>, R>
|
|
4263
|
+
<A, B, E, R>(
|
|
4264
|
+
elements: Iterable<A>,
|
|
4265
|
+
f: (a: A, i: number) => Effect.Effect<B, E, R>,
|
|
4266
|
+
options: {
|
|
4267
|
+
readonly concurrency?: Concurrency | undefined
|
|
4268
|
+
readonly discard: true
|
|
4269
|
+
}
|
|
4270
|
+
): Effect.Effect<void, Arr.NonEmptyArray<E>, R>
|
|
4271
|
+
} = dual(
|
|
4272
|
+
(args) => isIterable(args[0]) && !isEffect(args[0]),
|
|
4273
|
+
<A, B, E, R>(
|
|
4274
|
+
elements: Iterable<A>,
|
|
4275
|
+
f: (a: A, i: number) => Effect.Effect<B, E, R>,
|
|
4276
|
+
options?: {
|
|
4277
|
+
readonly concurrency?: Concurrency | undefined
|
|
4278
|
+
readonly discard?: boolean | undefined
|
|
4279
|
+
} | undefined
|
|
4280
|
+
): Effect.Effect<Array<B> | void, Arr.NonEmptyArray<E>, R> =>
|
|
4281
|
+
flatMap(
|
|
4282
|
+
partition(elements, f, { concurrency: options?.concurrency }),
|
|
4283
|
+
([excluded, satisfying]) => {
|
|
4284
|
+
if (Arr.isArrayNonEmpty(excluded)) {
|
|
4285
|
+
return fail(excluded)
|
|
4286
|
+
}
|
|
4287
|
+
return options?.discard ? void_ : succeed(satisfying)
|
|
4288
|
+
}
|
|
4078
4289
|
)
|
|
4079
4290
|
)
|
|
4080
4291
|
|
|
4292
|
+
/** @internal */
|
|
4293
|
+
export const findFirst: {
|
|
4294
|
+
<A, E, R>(
|
|
4295
|
+
predicate: (a: NoInfer<A>, i: number) => Effect.Effect<boolean, E, R>
|
|
4296
|
+
): (elements: Iterable<A>) => Effect.Effect<Option.Option<A>, E, R>
|
|
4297
|
+
<A, E, R>(
|
|
4298
|
+
elements: Iterable<A>,
|
|
4299
|
+
predicate: (a: NoInfer<A>, i: number) => Effect.Effect<boolean, E, R>
|
|
4300
|
+
): Effect.Effect<Option.Option<A>, E, R>
|
|
4301
|
+
} = dual(
|
|
4302
|
+
(args) => isIterable(args[0]) && !isEffect(args[0]),
|
|
4303
|
+
<A, E, R>(
|
|
4304
|
+
elements: Iterable<A>,
|
|
4305
|
+
predicate: (a: A, i: number) => Effect.Effect<boolean, E, R>
|
|
4306
|
+
): Effect.Effect<Option.Option<A>, E, R> =>
|
|
4307
|
+
suspend(() => {
|
|
4308
|
+
const iterator = elements[Symbol.iterator]()
|
|
4309
|
+
const next = iterator.next()
|
|
4310
|
+
if (!next.done) {
|
|
4311
|
+
return findFirstLoop(iterator, 0, predicate, next.value)
|
|
4312
|
+
}
|
|
4313
|
+
return succeed(Option.none())
|
|
4314
|
+
})
|
|
4315
|
+
)
|
|
4316
|
+
|
|
4317
|
+
const findFirstLoop = <A, E, R>(
|
|
4318
|
+
iterator: Iterator<A>,
|
|
4319
|
+
index: number,
|
|
4320
|
+
predicate: (a: A, i: number) => Effect.Effect<boolean, E, R>,
|
|
4321
|
+
value: A
|
|
4322
|
+
): Effect.Effect<Option.Option<A>, E, R> =>
|
|
4323
|
+
flatMap(predicate(value, index), (keep) => {
|
|
4324
|
+
if (keep) {
|
|
4325
|
+
return succeed(Option.some(value))
|
|
4326
|
+
}
|
|
4327
|
+
const next = iterator.next()
|
|
4328
|
+
if (!next.done) {
|
|
4329
|
+
return findFirstLoop(iterator, index + 1, predicate, next.value)
|
|
4330
|
+
}
|
|
4331
|
+
return succeed(Option.none())
|
|
4332
|
+
})
|
|
4333
|
+
|
|
4334
|
+
/** @internal */
|
|
4335
|
+
export const findFirstFilter: {
|
|
4336
|
+
<A, B, X, E, R>(
|
|
4337
|
+
filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R, [i: number]>
|
|
4338
|
+
): (elements: Iterable<A>) => Effect.Effect<Option.Option<B>, E, R>
|
|
4339
|
+
<A, B, X, E, R>(
|
|
4340
|
+
elements: Iterable<A>,
|
|
4341
|
+
filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R, [i: number]>
|
|
4342
|
+
): Effect.Effect<Option.Option<B>, E, R>
|
|
4343
|
+
} = dual(
|
|
4344
|
+
(args) => isIterable(args[0]) && !isEffect(args[0]),
|
|
4345
|
+
<A, B, X, E, R>(
|
|
4346
|
+
elements: Iterable<A>,
|
|
4347
|
+
filter: Filter.FilterEffect<A, B, X, E, R, [i: number]>
|
|
4348
|
+
): Effect.Effect<Option.Option<B>, E, R> =>
|
|
4349
|
+
suspend(() => {
|
|
4350
|
+
const iterator = elements[Symbol.iterator]()
|
|
4351
|
+
const next = iterator.next()
|
|
4352
|
+
if (!next.done) {
|
|
4353
|
+
return findFirstFilterLoop(iterator, 0, filter, next.value)
|
|
4354
|
+
}
|
|
4355
|
+
return succeed(Option.none())
|
|
4356
|
+
})
|
|
4357
|
+
)
|
|
4358
|
+
|
|
4359
|
+
const findFirstFilterLoop = <A, B, X, E, R>(
|
|
4360
|
+
iterator: Iterator<A>,
|
|
4361
|
+
index: number,
|
|
4362
|
+
filter: Filter.FilterEffect<A, B, X, E, R, [i: number]>,
|
|
4363
|
+
value: A
|
|
4364
|
+
): Effect.Effect<Option.Option<B>, E, R> =>
|
|
4365
|
+
flatMap(filter(value, index), (result) => {
|
|
4366
|
+
if (Result.isSuccess(result)) {
|
|
4367
|
+
return succeed(Option.some(result.success))
|
|
4368
|
+
}
|
|
4369
|
+
const next = iterator.next()
|
|
4370
|
+
if (!next.done) {
|
|
4371
|
+
return findFirstFilterLoop(iterator, index + 1, filter, next.value)
|
|
4372
|
+
}
|
|
4373
|
+
return succeed(Option.none())
|
|
4374
|
+
})
|
|
4375
|
+
|
|
4081
4376
|
/** @internal */
|
|
4082
4377
|
export const whileLoop: <A, E, R>(options: {
|
|
4083
4378
|
readonly while: LazyArg<boolean>
|
|
@@ -4249,33 +4544,85 @@ export const filterOrElse: {
|
|
|
4249
4544
|
refinement: Predicate.Refinement<NoInfer<A>, B>,
|
|
4250
4545
|
orElse: (a: EqualsWith<A, B, NoInfer<A>, Exclude<NoInfer<A>, B>>) => Effect.Effect<C, E2, R2>
|
|
4251
4546
|
): <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<
|
|
4547
|
+
<A, C, E2, R2>(
|
|
4548
|
+
predicate: Predicate.Predicate<NoInfer<A>>,
|
|
4549
|
+
orElse: (a: NoInfer<A>) => Effect.Effect<C, E2, R2>
|
|
4550
|
+
): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A | C, E2 | E, R2 | R>
|
|
4256
4551
|
<A, E, R, C, E2, R2, B extends A>(
|
|
4257
4552
|
self: Effect.Effect<A, E, R>,
|
|
4258
4553
|
refinement: Predicate.Refinement<A, B>,
|
|
4259
4554
|
orElse: (a: EqualsWith<A, B, A, Exclude<A, B>>) => Effect.Effect<C, E2, R2>
|
|
4260
4555
|
): Effect.Effect<B | C, E | E2, R | R2>
|
|
4261
|
-
<A, E, R,
|
|
4556
|
+
<A, E, R, C, E2, R2>(
|
|
4262
4557
|
self: Effect.Effect<A, E, R>,
|
|
4263
|
-
|
|
4264
|
-
orElse: (a:
|
|
4265
|
-
): Effect.Effect<
|
|
4266
|
-
} = dual(3, <A, E, R,
|
|
4558
|
+
predicate: Predicate.Predicate<NoInfer<A>>,
|
|
4559
|
+
orElse: (a: NoInfer<A>) => Effect.Effect<C, E2, R2>
|
|
4560
|
+
): Effect.Effect<A | C, E | E2, R | R2>
|
|
4561
|
+
} = dual(3, <A, E, R, B, E2, R2>(
|
|
4267
4562
|
self: Effect.Effect<A, E, R>,
|
|
4268
|
-
|
|
4269
|
-
orElse: (a:
|
|
4270
|
-
): Effect.Effect<
|
|
4563
|
+
predicate: Predicate.Predicate<A>,
|
|
4564
|
+
orElse: (a: A) => Effect.Effect<B, E2, R2>
|
|
4565
|
+
): Effect.Effect<A | B, E | E2, R | R2> =>
|
|
4566
|
+
flatMap(
|
|
4567
|
+
self,
|
|
4568
|
+
(a) => predicate(a) ? succeed<A | B>(a) : orElse(a)
|
|
4569
|
+
))
|
|
4570
|
+
|
|
4571
|
+
/** @internal */
|
|
4572
|
+
export const filterMapOrElse: {
|
|
4573
|
+
<A, B, X, C, E2, R2>(
|
|
4574
|
+
filter: Filter.Filter<NoInfer<A>, B, X>,
|
|
4575
|
+
orElse: (x: X) => Effect.Effect<C, E2, R2>
|
|
4576
|
+
): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<B | C, E2 | E, R2 | R>
|
|
4577
|
+
<A, E, R, B, X, C, E2, R2>(
|
|
4578
|
+
self: Effect.Effect<A, E, R>,
|
|
4579
|
+
filter: Filter.Filter<NoInfer<A>, B, X>,
|
|
4580
|
+
orElse: (x: X) => Effect.Effect<C, E2, R2>
|
|
4581
|
+
): Effect.Effect<B | C, E | E2, R | R2>
|
|
4582
|
+
} = dual(3, <A, E, R, B, X, C, E2, R2>(
|
|
4583
|
+
self: Effect.Effect<A, E, R>,
|
|
4584
|
+
filter: Filter.Filter<NoInfer<A>, B, X>,
|
|
4585
|
+
orElse: (x: X) => Effect.Effect<C, E2, R2>
|
|
4586
|
+
): Effect.Effect<B | C, E | E2, R | R2> =>
|
|
4271
4587
|
flatMap(
|
|
4272
4588
|
self,
|
|
4273
4589
|
(a) => {
|
|
4274
|
-
const result =
|
|
4275
|
-
return Result.isFailure(result)
|
|
4590
|
+
const result = filter(a)
|
|
4591
|
+
return (Result.isFailure(result)
|
|
4592
|
+
? orElse(result.failure)
|
|
4593
|
+
: succeed(result.success)) as Effect.Effect<B | C, E2, R2>
|
|
4276
4594
|
}
|
|
4277
4595
|
))
|
|
4278
4596
|
|
|
4597
|
+
/* @internal */
|
|
4598
|
+
export const filterMapOrFail: {
|
|
4599
|
+
<A, B, X, E2>(
|
|
4600
|
+
filter: Filter.Filter<NoInfer<A>, B, X>,
|
|
4601
|
+
orFailWith: (x: X) => E2
|
|
4602
|
+
): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<B, E2 | E, R>
|
|
4603
|
+
<A, B, X>(
|
|
4604
|
+
filter: Filter.Filter<NoInfer<A>, B, X>
|
|
4605
|
+
): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<B, Cause.NoSuchElementError | E, R>
|
|
4606
|
+
<A, E, R, B, X, E2>(
|
|
4607
|
+
self: Effect.Effect<A, E, R>,
|
|
4608
|
+
filter: Filter.Filter<NoInfer<A>, B, X>,
|
|
4609
|
+
orFailWith: (x: X) => E2
|
|
4610
|
+
): Effect.Effect<B, E2 | E, R>
|
|
4611
|
+
<A, E, R, B, X>(
|
|
4612
|
+
self: Effect.Effect<A, E, R>,
|
|
4613
|
+
filter: Filter.Filter<NoInfer<A>, B, X>
|
|
4614
|
+
): Effect.Effect<B, Cause.NoSuchElementError | E, R>
|
|
4615
|
+
} = dual((args) => isEffect(args[0]), <A, E, R, B, X, E2>(
|
|
4616
|
+
self: Effect.Effect<A, E, R>,
|
|
4617
|
+
filter: Filter.Filter<NoInfer<A>, B, X>,
|
|
4618
|
+
orFailWith?: (x: X) => E2
|
|
4619
|
+
): Effect.Effect<B, E2 | Cause.NoSuchElementError | E, R> =>
|
|
4620
|
+
filterMapOrElse(
|
|
4621
|
+
self,
|
|
4622
|
+
filter,
|
|
4623
|
+
orFailWith ? (x: X) => fail(orFailWith(x)) : () => fail(new NoSuchElementError() as E2)
|
|
4624
|
+
))
|
|
4625
|
+
|
|
4279
4626
|
/** @internal */
|
|
4280
4627
|
export const filter: {
|
|
4281
4628
|
<A, B extends A>(
|
|
@@ -4284,13 +4631,6 @@ export const filter: {
|
|
|
4284
4631
|
<A>(
|
|
4285
4632
|
predicate: Predicate.Predicate<NoInfer<A>>
|
|
4286
4633
|
): (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
4634
|
<A, E, R>(
|
|
4295
4635
|
predicate: (a: NoInfer<A>, i: number) => Effect.Effect<boolean, E, R>,
|
|
4296
4636
|
options?: { readonly concurrency?: Concurrency | undefined }
|
|
@@ -4303,15 +4643,6 @@ export const filter: {
|
|
|
4303
4643
|
elements: Iterable<A>,
|
|
4304
4644
|
predicate: Predicate.Predicate<A>
|
|
4305
4645
|
): 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
4646
|
<A, E, R>(
|
|
4316
4647
|
iterable: Iterable<A>,
|
|
4317
4648
|
predicate: (a: NoInfer<A>, i: number) => Effect.Effect<boolean, E, R>,
|
|
@@ -4319,36 +4650,27 @@ export const filter: {
|
|
|
4319
4650
|
): Effect.Effect<Array<A>, E, R>
|
|
4320
4651
|
} = dual(
|
|
4321
4652
|
(args) => isIterable(args[0]) && !isEffect(args[0]),
|
|
4322
|
-
<A,
|
|
4653
|
+
<A, E, R>(
|
|
4323
4654
|
elements: Iterable<A>,
|
|
4324
|
-
|
|
4325
|
-
| Filter.FilterEffect<A, B, X, E, R>
|
|
4655
|
+
predicate:
|
|
4326
4656
|
| Predicate.Predicate<A>
|
|
4327
4657
|
| ((a: A, i: number) => Effect.Effect<boolean, E, R>),
|
|
4328
4658
|
options?: { readonly concurrency?: Concurrency | undefined }
|
|
4329
|
-
): Effect.Effect<Array<
|
|
4659
|
+
): Effect.Effect<Array<A>, E, R> =>
|
|
4330
4660
|
suspend(() => {
|
|
4331
|
-
const out: Array<
|
|
4661
|
+
const out: Array<A> = []
|
|
4332
4662
|
return as(
|
|
4333
4663
|
forEach(
|
|
4334
4664
|
elements,
|
|
4335
4665
|
(a, i) => {
|
|
4336
|
-
const result = (
|
|
4666
|
+
const result = (predicate as Function)(a, i)
|
|
4337
4667
|
if (typeof result === "boolean") {
|
|
4338
4668
|
if (result) out.push(a)
|
|
4339
4669
|
return void_ as any
|
|
4340
4670
|
}
|
|
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)
|
|
4671
|
+
return map(result, (keep) => {
|
|
4672
|
+
if (keep) {
|
|
4673
|
+
out.push(a)
|
|
4352
4674
|
}
|
|
4353
4675
|
})
|
|
4354
4676
|
},
|
|
@@ -4362,6 +4684,72 @@ export const filter: {
|
|
|
4362
4684
|
})
|
|
4363
4685
|
)
|
|
4364
4686
|
|
|
4687
|
+
/** @internal */
|
|
4688
|
+
export const filterMap: {
|
|
4689
|
+
<A, B, X>(
|
|
4690
|
+
filter: Filter.Filter<NoInfer<A>, B, X>
|
|
4691
|
+
): (elements: Iterable<A>) => Effect.Effect<Array<B>>
|
|
4692
|
+
<A, B, X>(
|
|
4693
|
+
elements: Iterable<A>,
|
|
4694
|
+
filter: Filter.Filter<NoInfer<A>, B, X>
|
|
4695
|
+
): Effect.Effect<Array<B>>
|
|
4696
|
+
} = dual(
|
|
4697
|
+
(args) => isIterable(args[0]) && !isEffect(args[0]),
|
|
4698
|
+
<A, B, X>(
|
|
4699
|
+
elements: Iterable<A>,
|
|
4700
|
+
filter: Filter.Filter<A, B, X>
|
|
4701
|
+
): Effect.Effect<Array<B>> =>
|
|
4702
|
+
suspend(() => {
|
|
4703
|
+
const out: Array<B> = []
|
|
4704
|
+
for (const a of elements) {
|
|
4705
|
+
const result = filter(a)
|
|
4706
|
+
if (Result.isSuccess(result)) {
|
|
4707
|
+
out.push(result.success)
|
|
4708
|
+
}
|
|
4709
|
+
}
|
|
4710
|
+
return succeed(out)
|
|
4711
|
+
})
|
|
4712
|
+
)
|
|
4713
|
+
|
|
4714
|
+
/** @internal */
|
|
4715
|
+
export const filterMapEffect: {
|
|
4716
|
+
<A, B, X, E, R>(
|
|
4717
|
+
filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R>,
|
|
4718
|
+
options?: { readonly concurrency?: Concurrency | undefined }
|
|
4719
|
+
): (elements: Iterable<A>) => Effect.Effect<Array<B>, E, R>
|
|
4720
|
+
<A, B, X, E, R>(
|
|
4721
|
+
elements: Iterable<A>,
|
|
4722
|
+
filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R>,
|
|
4723
|
+
options?: { readonly concurrency?: Concurrency | undefined }
|
|
4724
|
+
): Effect.Effect<Array<B>, E, R>
|
|
4725
|
+
} = dual(
|
|
4726
|
+
(args) => isIterable(args[0]) && !isEffect(args[0]),
|
|
4727
|
+
<A, B, X, E, R>(
|
|
4728
|
+
elements: Iterable<A>,
|
|
4729
|
+
filter: Filter.FilterEffect<A, B, X, E, R>,
|
|
4730
|
+
options?: { readonly concurrency?: Concurrency | undefined }
|
|
4731
|
+
): Effect.Effect<Array<B>, E, R> =>
|
|
4732
|
+
suspend(() => {
|
|
4733
|
+
const out: Array<B> = []
|
|
4734
|
+
return as(
|
|
4735
|
+
forEach(
|
|
4736
|
+
elements,
|
|
4737
|
+
(a) =>
|
|
4738
|
+
map(filter(a), (result) => {
|
|
4739
|
+
if (Result.isSuccess(result)) {
|
|
4740
|
+
out.push(result.success)
|
|
4741
|
+
}
|
|
4742
|
+
}),
|
|
4743
|
+
{
|
|
4744
|
+
discard: true,
|
|
4745
|
+
concurrency: options?.concurrency
|
|
4746
|
+
}
|
|
4747
|
+
),
|
|
4748
|
+
out
|
|
4749
|
+
)
|
|
4750
|
+
})
|
|
4751
|
+
)
|
|
4752
|
+
|
|
4365
4753
|
// ----------------------------------------------------------------------------
|
|
4366
4754
|
// do notation
|
|
4367
4755
|
// ----------------------------------------------------------------------------
|
|
@@ -4772,25 +5160,27 @@ class Semaphore {
|
|
|
4772
5160
|
return this.permits - this.taken
|
|
4773
5161
|
}
|
|
4774
5162
|
|
|
4775
|
-
readonly take = (n: number): Effect.Effect<number> =>
|
|
4776
|
-
|
|
5163
|
+
readonly take = (n: number): Effect.Effect<number> => {
|
|
5164
|
+
const take: Effect.Effect<number> = suspend(() => {
|
|
4777
5165
|
if (this.free < n) {
|
|
4778
|
-
|
|
4779
|
-
if (this.free
|
|
4780
|
-
|
|
5166
|
+
return callback((resume) => {
|
|
5167
|
+
if (this.free >= n) return resume(take)
|
|
5168
|
+
const observer = () => {
|
|
5169
|
+
if (this.free < n) return
|
|
5170
|
+
this.waiters.delete(observer)
|
|
5171
|
+
resume(take)
|
|
4781
5172
|
}
|
|
4782
|
-
this.waiters.
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
this.waiters.add(observer)
|
|
4787
|
-
return sync(() => {
|
|
4788
|
-
this.waiters.delete(observer)
|
|
5173
|
+
this.waiters.add(observer)
|
|
5174
|
+
return sync(() => {
|
|
5175
|
+
this.waiters.delete(observer)
|
|
5176
|
+
})
|
|
4789
5177
|
})
|
|
4790
5178
|
}
|
|
4791
5179
|
this.taken += n
|
|
4792
|
-
return
|
|
5180
|
+
return succeed(n)
|
|
4793
5181
|
})
|
|
5182
|
+
return take
|
|
5183
|
+
}
|
|
4794
5184
|
|
|
4795
5185
|
updateTakenUnsafe(fiber: Fiber.Fiber<any, any>, f: (n: number) => number): Effect.Effect<number> {
|
|
4796
5186
|
this.taken = f(this.taken)
|
|
@@ -4828,7 +5218,10 @@ class Semaphore {
|
|
|
4828
5218
|
|
|
4829
5219
|
readonly withPermits = (n: number) => <A, E, R>(self: Effect.Effect<A, E, R>) =>
|
|
4830
5220
|
uninterruptibleMask((restore) =>
|
|
4831
|
-
flatMap(
|
|
5221
|
+
flatMap(
|
|
5222
|
+
restore(this.take(n)),
|
|
5223
|
+
(permits) => onExitPrimitive(restore(self), () => this.release(permits), true)
|
|
5224
|
+
)
|
|
4832
5225
|
)
|
|
4833
5226
|
|
|
4834
5227
|
readonly withPermit = this.withPermits(1)
|
|
@@ -4854,7 +5247,7 @@ export const makeSemaphore = (permits: number) => sync(() => makeSemaphoreUnsafe
|
|
|
4854
5247
|
const succeedTrue = succeed(true)
|
|
4855
5248
|
const succeedFalse = succeed(false)
|
|
4856
5249
|
|
|
4857
|
-
class Latch implements
|
|
5250
|
+
class Latch implements _Latch.Latch {
|
|
4858
5251
|
waiters: Array<(_: Effect.Effect<void>) => void> = []
|
|
4859
5252
|
scheduled = false
|
|
4860
5253
|
private isOpen: boolean
|
|
@@ -4914,7 +5307,7 @@ class Latch implements Effect.Latch {
|
|
|
4914
5307
|
}
|
|
4915
5308
|
|
|
4916
5309
|
/** @internal */
|
|
4917
|
-
export const makeLatchUnsafe = (open?: boolean | undefined):
|
|
5310
|
+
export const makeLatchUnsafe = (open?: boolean | undefined): _Latch.Latch => new Latch(open ?? false)
|
|
4918
5311
|
|
|
4919
5312
|
/** @internal */
|
|
4920
5313
|
export const makeLatch = (open?: boolean | undefined) => sync(() => makeLatchUnsafe(open))
|
|
@@ -5344,8 +5737,8 @@ export const clockWith = <A, E, R>(f: (clock: Clock.Clock) => Effect.Effect<A, E
|
|
|
5344
5737
|
withFiber((fiber) => f(fiber.getRef(ClockRef)))
|
|
5345
5738
|
|
|
5346
5739
|
/** @internal */
|
|
5347
|
-
export const sleep = (duration: Duration.
|
|
5348
|
-
clockWith((clock) => clock.sleep(Duration.
|
|
5740
|
+
export const sleep = (duration: Duration.Input): Effect.Effect<void> =>
|
|
5741
|
+
clockWith((clock) => clock.sleep(Duration.fromInputUnsafe(duration)))
|
|
5349
5742
|
|
|
5350
5743
|
/** @internal */
|
|
5351
5744
|
export const currentTimeMillis: Effect.Effect<number> = clockWith((clock) => clock.currentTimeMillis)
|
|
@@ -5477,6 +5870,40 @@ export const LogToStderr = ServiceMap.Reference<boolean>("effect/Logger/LogToStd
|
|
|
5477
5870
|
defaultValue: constFalse
|
|
5478
5871
|
})
|
|
5479
5872
|
|
|
5873
|
+
/** @internal */
|
|
5874
|
+
export const annotateLogsScoped: {
|
|
5875
|
+
(key: string, value: unknown): Effect.Effect<void, never, Scope.Scope>
|
|
5876
|
+
(values: Record<string, unknown>): Effect.Effect<void, never, Scope.Scope>
|
|
5877
|
+
} = function() {
|
|
5878
|
+
const entries = typeof arguments[0] === "string" ?
|
|
5879
|
+
[[arguments[0], arguments[1]]] :
|
|
5880
|
+
Object.entries(arguments[0])
|
|
5881
|
+
return uninterruptible(withFiber((fiber) => {
|
|
5882
|
+
const prev = fiber.getRef(CurrentLogAnnotations)
|
|
5883
|
+
const next = { ...prev }
|
|
5884
|
+
for (let i = 0; i < entries.length; i++) {
|
|
5885
|
+
const [key, value] = entries[i]
|
|
5886
|
+
next[key] = value
|
|
5887
|
+
}
|
|
5888
|
+
fiber.setServices(ServiceMap.add(fiber.services, CurrentLogAnnotations, next))
|
|
5889
|
+
return scopeAddFinalizerExit(ServiceMap.getUnsafe(fiber.services, scopeTag), (_) => {
|
|
5890
|
+
const current = fiber.getRef(CurrentLogAnnotations)
|
|
5891
|
+
const next = { ...current }
|
|
5892
|
+
for (let i = 0; i < entries.length; i++) {
|
|
5893
|
+
const [key, value] = entries[i]
|
|
5894
|
+
if (current[key] !== value) continue
|
|
5895
|
+
if (key in prev) {
|
|
5896
|
+
next[key] = prev[key]
|
|
5897
|
+
} else {
|
|
5898
|
+
delete next[key]
|
|
5899
|
+
}
|
|
5900
|
+
}
|
|
5901
|
+
fiber.setServices(ServiceMap.add(fiber.services, CurrentLogAnnotations, next))
|
|
5902
|
+
return void_
|
|
5903
|
+
})
|
|
5904
|
+
}))
|
|
5905
|
+
}
|
|
5906
|
+
|
|
5480
5907
|
/** @internal */
|
|
5481
5908
|
export const LoggerTypeId = "~effect/Logger"
|
|
5482
5909
|
|
|
@@ -5492,7 +5919,7 @@ const LoggerProto = {
|
|
|
5492
5919
|
|
|
5493
5920
|
/** @internal */
|
|
5494
5921
|
export const loggerMake = <Message, Output>(
|
|
5495
|
-
log: (options: Logger.
|
|
5922
|
+
log: (options: Logger.Options<Message>) => Output
|
|
5496
5923
|
): Logger.Logger<Message, Output> => {
|
|
5497
5924
|
const self = Object.create(LoggerProto)
|
|
5498
5925
|
self.log = log
|
|
@@ -5532,7 +5959,7 @@ export const structuredMessage = (u: unknown): unknown => {
|
|
|
5532
5959
|
}
|
|
5533
5960
|
|
|
5534
5961
|
/** @internal */
|
|
5535
|
-
export const logWithLevel = (level?: LogLevel.
|
|
5962
|
+
export const logWithLevel = (level?: LogLevel.Severity) =>
|
|
5536
5963
|
(
|
|
5537
5964
|
...message: ReadonlyArray<any>
|
|
5538
5965
|
): Effect.Effect<void> => {
|
|
@@ -5823,3 +6250,55 @@ const undefined_ = succeed(undefined)
|
|
|
5823
6250
|
|
|
5824
6251
|
/** @internal */
|
|
5825
6252
|
export { undefined_ as undefined }
|
|
6253
|
+
|
|
6254
|
+
// ----------------------------------------------------------------------------
|
|
6255
|
+
// ErrorReporter
|
|
6256
|
+
// ----------------------------------------------------------------------------
|
|
6257
|
+
|
|
6258
|
+
/** @internal */
|
|
6259
|
+
export const CurrentErrorReporters = ServiceMap.Reference<
|
|
6260
|
+
ReadonlySet<ErrorReporter>
|
|
6261
|
+
>("effect/ErrorReporter/CurrentErrorReporters", {
|
|
6262
|
+
defaultValue: () => new Set()
|
|
6263
|
+
})
|
|
6264
|
+
|
|
6265
|
+
/** @internal */
|
|
6266
|
+
export const withErrorReporting: <
|
|
6267
|
+
Arg extends Effect.Effect<any, any, any> | {
|
|
6268
|
+
readonly defectsOnly?: boolean | undefined
|
|
6269
|
+
} | undefined = {
|
|
6270
|
+
readonly defectsOnly?: boolean | undefined
|
|
6271
|
+
}
|
|
6272
|
+
>(
|
|
6273
|
+
effectOrOptions: Arg,
|
|
6274
|
+
options?: {
|
|
6275
|
+
readonly defectsOnly?: boolean | undefined
|
|
6276
|
+
} | undefined
|
|
6277
|
+
) => [Arg] extends [Effect.Effect<infer _A, infer _E, infer _R>] ? Arg
|
|
6278
|
+
: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R> = dual(
|
|
6279
|
+
(args) => isEffect(args[0]),
|
|
6280
|
+
<A, E, R>(
|
|
6281
|
+
self: Effect.Effect<A, E, R>,
|
|
6282
|
+
options?: {
|
|
6283
|
+
readonly defectsOnly?: boolean | undefined
|
|
6284
|
+
} | undefined
|
|
6285
|
+
): Effect.Effect<A, E, R> =>
|
|
6286
|
+
onError(self, (cause) =>
|
|
6287
|
+
withFiber((fiber) => {
|
|
6288
|
+
reportCauseUnsafe(fiber, cause, options?.defectsOnly)
|
|
6289
|
+
return void_
|
|
6290
|
+
}))
|
|
6291
|
+
)
|
|
6292
|
+
|
|
6293
|
+
/** @internal */
|
|
6294
|
+
export const reportCauseUnsafe = (
|
|
6295
|
+
fiber: Fiber.Fiber<unknown, unknown>,
|
|
6296
|
+
cause: Cause.Cause<unknown>,
|
|
6297
|
+
defectsOnly?: boolean
|
|
6298
|
+
) => {
|
|
6299
|
+
const reporters = fiber.getRef(CurrentErrorReporters)
|
|
6300
|
+
if (reporters.size === 0) return
|
|
6301
|
+
if (defectsOnly && !hasDies(cause)) return
|
|
6302
|
+
const opts = { cause, fiber, timestamp: fiber.getRef(ClockRef).currentTimeNanosUnsafe() }
|
|
6303
|
+
reporters.forEach((reporter) => reporter.report(opts))
|
|
6304
|
+
}
|