effect 4.0.0-beta.4 → 4.0.0-beta.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Array.d.ts +213 -385
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +149 -102
- package/dist/Array.js.map +1 -1
- package/dist/BigDecimal.d.ts +82 -45
- package/dist/BigDecimal.d.ts.map +1 -1
- package/dist/BigDecimal.js +87 -38
- package/dist/BigDecimal.js.map +1 -1
- package/dist/BigInt.d.ts +39 -32
- package/dist/BigInt.d.ts.map +1 -1
- package/dist/BigInt.js +32 -29
- package/dist/BigInt.js.map +1 -1
- package/dist/Brand.d.ts +1 -1
- package/dist/Brand.d.ts.map +1 -1
- package/dist/Brand.js +1 -1
- package/dist/Brand.js.map +1 -1
- package/dist/Cache.d.ts +2 -2
- package/dist/Cache.d.ts.map +1 -1
- package/dist/Cache.js +6 -5
- package/dist/Cache.js.map +1 -1
- package/dist/Cause.d.ts +33 -2
- package/dist/Cause.d.ts.map +1 -1
- package/dist/Cause.js +19 -0
- package/dist/Cause.js.map +1 -1
- package/dist/Channel.d.ts +130 -35
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +96 -45
- package/dist/Channel.js.map +1 -1
- package/dist/Chunk.d.ts +112 -304
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Chunk.js +56 -88
- package/dist/Chunk.js.map +1 -1
- package/dist/Combiner.d.ts +280 -13
- package/dist/Combiner.d.ts.map +1 -1
- package/dist/Combiner.js +198 -7
- package/dist/Combiner.js.map +1 -1
- package/dist/Config.d.ts +169 -9
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +69 -11
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.d.ts +1 -1
- package/dist/Cron.d.ts +11 -7
- package/dist/Cron.d.ts.map +1 -1
- package/dist/Cron.js +120 -63
- package/dist/Cron.js.map +1 -1
- package/dist/Data.d.ts +535 -366
- package/dist/Data.d.ts.map +1 -1
- package/dist/Data.js +132 -79
- package/dist/Data.js.map +1 -1
- package/dist/DateTime.d.ts +72 -253
- package/dist/DateTime.d.ts.map +1 -1
- package/dist/DateTime.js +15 -60
- package/dist/DateTime.js.map +1 -1
- package/dist/Deferred.d.ts +7 -5
- package/dist/Deferred.d.ts.map +1 -1
- package/dist/Deferred.js +7 -5
- package/dist/Deferred.js.map +1 -1
- package/dist/Duration.d.ts +62 -32
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +108 -78
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts +1225 -951
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +398 -338
- package/dist/Effect.js.map +1 -1
- package/dist/Encoding.d.ts +194 -0
- package/dist/Encoding.d.ts.map +1 -0
- package/dist/Encoding.js +352 -0
- package/dist/Encoding.js.map +1 -0
- package/dist/Equal.d.ts +276 -109
- package/dist/Equal.d.ts.map +1 -1
- package/dist/Equal.js +124 -48
- package/dist/Equal.js.map +1 -1
- package/dist/Equivalence.d.ts +60 -3
- package/dist/Equivalence.d.ts.map +1 -1
- package/dist/Equivalence.js +70 -13
- package/dist/Equivalence.js.map +1 -1
- package/dist/ErrorReporter.d.ts +374 -0
- package/dist/ErrorReporter.d.ts.map +1 -0
- package/dist/ErrorReporter.js +245 -0
- package/dist/ErrorReporter.js.map +1 -0
- package/dist/Exit.d.ts +24 -12
- package/dist/Exit.d.ts.map +1 -1
- package/dist/Exit.js +8 -4
- package/dist/Exit.js.map +1 -1
- package/dist/Fiber.d.ts +5 -3
- package/dist/Fiber.d.ts.map +1 -1
- package/dist/Fiber.js.map +1 -1
- package/dist/FiberHandle.d.ts +9 -8
- package/dist/FiberHandle.d.ts.map +1 -1
- package/dist/FiberHandle.js +8 -7
- package/dist/FiberHandle.js.map +1 -1
- package/dist/FiberMap.d.ts +20 -19
- package/dist/FiberMap.d.ts.map +1 -1
- package/dist/FiberMap.js +6 -6
- package/dist/FiberMap.js.map +1 -1
- package/dist/FileSystem.d.ts +18 -17
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js +17 -13
- package/dist/FileSystem.js.map +1 -1
- package/dist/Filter.d.ts +34 -38
- package/dist/Filter.d.ts.map +1 -1
- package/dist/Filter.js +15 -13
- package/dist/Filter.js.map +1 -1
- package/dist/Formatter.d.ts +131 -47
- package/dist/Formatter.d.ts.map +1 -1
- package/dist/Formatter.js +229 -51
- package/dist/Formatter.js.map +1 -1
- package/dist/Function.d.ts +1 -9
- package/dist/Function.d.ts.map +1 -1
- package/dist/Function.js +2 -10
- package/dist/Function.js.map +1 -1
- package/dist/Graph.d.ts +65 -65
- package/dist/Graph.d.ts.map +1 -1
- package/dist/Graph.js +60 -62
- package/dist/Graph.js.map +1 -1
- package/dist/HashMap.d.ts +26 -19
- package/dist/HashMap.d.ts.map +1 -1
- package/dist/HashMap.js +7 -5
- package/dist/HashMap.js.map +1 -1
- package/dist/Iterable.d.ts +50 -50
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +106 -34
- package/dist/Iterable.js.map +1 -1
- package/dist/JsonSchema.d.ts +299 -10
- package/dist/JsonSchema.d.ts.map +1 -1
- package/dist/JsonSchema.js +323 -4
- package/dist/JsonSchema.js.map +1 -1
- package/dist/Latch.d.ts +175 -0
- package/dist/Latch.d.ts.map +1 -0
- package/dist/Latch.js +130 -0
- package/dist/Latch.js.map +1 -0
- package/dist/Layer.d.ts +306 -129
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +93 -48
- package/dist/Layer.js.map +1 -1
- package/dist/LayerMap.d.ts +9 -8
- package/dist/LayerMap.d.ts.map +1 -1
- package/dist/LayerMap.js +3 -3
- package/dist/LayerMap.js.map +1 -1
- package/dist/LogLevel.d.ts +32 -0
- package/dist/LogLevel.d.ts.map +1 -1
- package/dist/LogLevel.js +28 -100
- package/dist/LogLevel.js.map +1 -1
- package/dist/Logger.d.ts +29 -95
- package/dist/Logger.d.ts.map +1 -1
- package/dist/Logger.js +2 -3
- package/dist/Logger.js.map +1 -1
- package/dist/ManagedRuntime.d.ts +2 -2
- package/dist/ManagedRuntime.d.ts.map +1 -1
- package/dist/ManagedRuntime.js +21 -9
- package/dist/ManagedRuntime.js.map +1 -1
- package/dist/Metric.d.ts +4 -6
- package/dist/Metric.d.ts.map +1 -1
- package/dist/Metric.js +3 -5
- package/dist/Metric.js.map +1 -1
- package/dist/MutableHashMap.d.ts +7 -0
- package/dist/MutableHashMap.d.ts.map +1 -1
- package/dist/MutableHashMap.js +8 -0
- package/dist/MutableHashMap.js.map +1 -1
- package/dist/MutableHashSet.d.ts +7 -0
- package/dist/MutableHashSet.d.ts.map +1 -1
- package/dist/MutableHashSet.js +8 -0
- package/dist/MutableHashSet.js.map +1 -1
- package/dist/Newtype.d.ts +291 -0
- package/dist/Newtype.d.ts.map +1 -0
- package/dist/Newtype.js +161 -0
- package/dist/Newtype.js.map +1 -0
- package/dist/Number.d.ts +74 -18
- package/dist/Number.d.ts.map +1 -1
- package/dist/Number.js +34 -15
- package/dist/Number.js.map +1 -1
- package/dist/Optic.d.ts +947 -18
- package/dist/Optic.d.ts.map +1 -1
- package/dist/Optic.js +454 -5
- package/dist/Optic.js.map +1 -1
- package/dist/Option.d.ts +25 -16
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js +15 -9
- package/dist/Option.js.map +1 -1
- package/dist/Order.d.ts +6 -1
- package/dist/Order.d.ts.map +1 -1
- package/dist/Order.js +19 -14
- package/dist/Order.js.map +1 -1
- package/dist/PartitionedSemaphore.d.ts +146 -15
- package/dist/PartitionedSemaphore.d.ts.map +1 -1
- package/dist/PartitionedSemaphore.js +174 -61
- package/dist/PartitionedSemaphore.js.map +1 -1
- package/dist/Pipeable.d.ts +17 -0
- package/dist/Pipeable.d.ts.map +1 -1
- package/dist/Pipeable.js +19 -1
- package/dist/Pipeable.js.map +1 -1
- package/dist/PlatformError.d.ts +10 -9
- package/dist/PlatformError.d.ts.map +1 -1
- package/dist/PlatformError.js +2 -2
- package/dist/PlatformError.js.map +1 -1
- package/dist/Pool.d.ts +6 -4
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +7 -5
- package/dist/Pool.js.map +1 -1
- package/dist/PubSub.d.ts +8 -6
- package/dist/PubSub.d.ts.map +1 -1
- package/dist/PubSub.js +18 -10
- package/dist/PubSub.js.map +1 -1
- package/dist/Pull.d.ts.map +1 -1
- package/dist/Pull.js +1 -1
- package/dist/Pull.js.map +1 -1
- package/dist/Queue.d.ts +9 -6
- package/dist/Queue.d.ts.map +1 -1
- package/dist/Queue.js +7 -5
- package/dist/Queue.js.map +1 -1
- package/dist/Random.d.ts +35 -1
- package/dist/Random.d.ts.map +1 -1
- package/dist/Random.js +46 -12
- package/dist/Random.js.map +1 -1
- package/dist/RcMap.d.ts +2 -2
- package/dist/RcMap.d.ts.map +1 -1
- package/dist/RcMap.js +1 -1
- package/dist/RcMap.js.map +1 -1
- package/dist/RcRef.d.ts +1 -1
- package/dist/RcRef.d.ts.map +1 -1
- package/dist/Record.d.ts +63 -160
- package/dist/Record.d.ts.map +1 -1
- package/dist/Record.js +37 -56
- package/dist/Record.js.map +1 -1
- package/dist/Reducer.d.ts +166 -7
- package/dist/Reducer.d.ts.map +1 -1
- package/dist/Reducer.js +135 -1
- package/dist/Reducer.js.map +1 -1
- package/dist/References.d.ts +242 -226
- package/dist/References.d.ts.map +1 -1
- package/dist/References.js +240 -247
- package/dist/References.js.map +1 -1
- package/dist/Request.d.ts +1 -1
- package/dist/Request.d.ts.map +1 -1
- package/dist/Request.js +2 -1
- package/dist/Request.js.map +1 -1
- package/dist/RequestResolver.d.ts +25 -45
- package/dist/RequestResolver.d.ts.map +1 -1
- package/dist/RequestResolver.js +10 -30
- package/dist/RequestResolver.js.map +1 -1
- package/dist/Resource.d.ts.map +1 -1
- package/dist/Resource.js +2 -1
- package/dist/Resource.js.map +1 -1
- package/dist/Result.d.ts +1 -1
- package/dist/Result.d.ts.map +1 -1
- package/dist/Result.js +1 -2
- package/dist/Result.js.map +1 -1
- package/dist/Runtime.d.ts +66 -0
- package/dist/Runtime.d.ts.map +1 -1
- package/dist/Runtime.js +79 -6
- package/dist/Runtime.js.map +1 -1
- package/dist/Schedule.d.ts +174 -291
- package/dist/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js +160 -134
- package/dist/Schedule.js.map +1 -1
- package/dist/Scheduler.d.ts +34 -123
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/Scheduler.js +31 -123
- package/dist/Scheduler.js.map +1 -1
- package/dist/Schema.d.ts +2722 -247
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +1947 -224
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +7 -2
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +131 -25
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaGetter.d.ts +5 -5
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +18 -18
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaParser.d.ts +44 -54
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +55 -2
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +46 -45
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +49 -24
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +107 -3
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +173 -13
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/ScopedCache.d.ts +2 -2
- package/dist/ScopedCache.d.ts.map +1 -1
- package/dist/ScopedCache.js +1 -1
- package/dist/ScopedCache.js.map +1 -1
- package/dist/Semaphore.d.ts +307 -0
- package/dist/Semaphore.d.ts.map +1 -0
- package/dist/Semaphore.js +222 -0
- package/dist/Semaphore.js.map +1 -0
- package/dist/ServiceMap.d.ts +76 -52
- package/dist/ServiceMap.d.ts.map +1 -1
- package/dist/ServiceMap.js +45 -29
- package/dist/ServiceMap.js.map +1 -1
- package/dist/Sink.d.ts +18 -15
- package/dist/Sink.d.ts.map +1 -1
- package/dist/Sink.js +53 -6
- package/dist/Sink.js.map +1 -1
- package/dist/Stdio.d.ts +16 -4
- package/dist/Stdio.d.ts.map +1 -1
- package/dist/Stdio.js +18 -0
- package/dist/Stdio.js.map +1 -1
- package/dist/Stream.d.ts +284 -431
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +189 -88
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +114 -47
- package/dist/String.d.ts.map +1 -1
- package/dist/String.js +29 -47
- package/dist/String.js.map +1 -1
- package/dist/Struct.d.ts +23 -7
- package/dist/Struct.d.ts.map +1 -1
- package/dist/Struct.js +22 -0
- package/dist/Struct.js.map +1 -1
- package/dist/SubscriptionRef.d.ts +3 -3
- package/dist/SubscriptionRef.d.ts.map +1 -1
- package/dist/SubscriptionRef.js +85 -117
- package/dist/SubscriptionRef.js.map +1 -1
- package/dist/SynchronizedRef.d.ts +2 -1
- package/dist/SynchronizedRef.d.ts.map +1 -1
- package/dist/SynchronizedRef.js +2 -1
- package/dist/SynchronizedRef.js.map +1 -1
- package/dist/Terminal.d.ts +2 -1
- package/dist/Terminal.d.ts.map +1 -1
- package/dist/Terminal.js.map +1 -1
- package/dist/Tracer.d.ts +5 -4
- package/dist/Tracer.d.ts.map +1 -1
- package/dist/Tracer.js +2 -1
- package/dist/Tracer.js.map +1 -1
- package/dist/Trie.d.ts +44 -31
- package/dist/Trie.d.ts.map +1 -1
- package/dist/Trie.js +13 -9
- package/dist/Trie.js.map +1 -1
- package/dist/TxChunk.d.ts +37 -37
- package/dist/TxChunk.d.ts.map +1 -1
- package/dist/TxChunk.js +3 -3
- package/dist/TxChunk.js.map +1 -1
- package/dist/TxDeferred.d.ts +328 -0
- package/dist/TxDeferred.d.ts.map +1 -0
- package/dist/TxDeferred.js +197 -0
- package/dist/TxDeferred.js.map +1 -0
- package/dist/TxHashMap.d.ts +159 -140
- package/dist/TxHashMap.d.ts.map +1 -1
- package/dist/TxHashMap.js +51 -44
- package/dist/TxHashMap.js.map +1 -1
- package/dist/TxHashSet.d.ts +36 -36
- package/dist/TxHashSet.d.ts.map +1 -1
- package/dist/TxHashSet.js +16 -15
- package/dist/TxHashSet.js.map +1 -1
- package/dist/TxPriorityQueue.d.ts +609 -0
- package/dist/TxPriorityQueue.d.ts.map +1 -0
- package/dist/TxPriorityQueue.js +416 -0
- package/dist/TxPriorityQueue.js.map +1 -0
- package/dist/TxPubSub.d.ts +585 -0
- package/dist/TxPubSub.d.ts.map +1 -0
- package/dist/TxPubSub.js +521 -0
- package/dist/TxPubSub.js.map +1 -0
- package/dist/TxQueue.d.ts +32 -32
- package/dist/TxQueue.d.ts.map +1 -1
- package/dist/TxQueue.js +26 -26
- package/dist/TxQueue.js.map +1 -1
- package/dist/TxReentrantLock.d.ts +523 -0
- package/dist/TxReentrantLock.d.ts.map +1 -0
- package/dist/TxReentrantLock.js +504 -0
- package/dist/TxReentrantLock.js.map +1 -0
- package/dist/TxRef.d.ts +34 -34
- package/dist/TxRef.d.ts.map +1 -1
- package/dist/TxRef.js +21 -14
- package/dist/TxRef.js.map +1 -1
- package/dist/TxSemaphore.d.ts +170 -10
- package/dist/TxSemaphore.d.ts.map +1 -1
- package/dist/TxSemaphore.js +23 -8
- package/dist/TxSemaphore.js.map +1 -1
- package/dist/TxSubscriptionRef.d.ts +508 -0
- package/dist/TxSubscriptionRef.d.ts.map +1 -0
- package/dist/TxSubscriptionRef.js +293 -0
- package/dist/TxSubscriptionRef.js.map +1 -0
- package/dist/Types.d.ts +80 -23
- package/dist/Types.d.ts.map +1 -1
- package/dist/Utils.d.ts +137 -65
- package/dist/Utils.d.ts.map +1 -1
- package/dist/Utils.js +38 -66
- package/dist/Utils.js.map +1 -1
- package/dist/index.d.ts +806 -55
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +806 -55
- package/dist/index.js.map +1 -1
- package/dist/internal/core.js +11 -3
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/dateTime.js +77 -71
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +284 -201
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/hashMap.js +7 -5
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/option.js +6 -0
- package/dist/internal/option.js.map +1 -1
- package/dist/internal/random.d.ts +2 -0
- package/dist/internal/random.d.ts.map +1 -0
- package/dist/internal/random.js +13 -0
- package/dist/internal/random.js.map +1 -0
- package/dist/internal/rcRef.js +3 -2
- package/dist/internal/rcRef.js.map +1 -1
- package/dist/internal/references.d.ts +2 -0
- package/dist/internal/references.d.ts.map +1 -0
- package/dist/internal/references.js +51 -0
- package/dist/internal/references.js.map +1 -0
- package/dist/internal/request.js +2 -2
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/schema/annotations.js +2 -0
- package/dist/internal/schema/annotations.js.map +1 -1
- package/dist/internal/schema/representation.js +75 -106
- package/dist/internal/schema/representation.js.map +1 -1
- package/dist/internal/schema/schema.js +1 -0
- package/dist/internal/schema/schema.js.map +1 -1
- package/dist/internal/schema/to-codec.js +7 -10
- package/dist/internal/schema/to-codec.js.map +1 -1
- package/dist/internal/trie.js +8 -7
- package/dist/internal/trie.js.map +1 -1
- package/dist/testing/TestClock.d.ts +8 -7
- package/dist/testing/TestClock.d.ts.map +1 -1
- package/dist/testing/TestClock.js +6 -4
- package/dist/testing/TestClock.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +266 -32
- package/dist/testing/TestSchema.d.ts.map +1 -1
- package/dist/testing/TestSchema.js +296 -23
- package/dist/testing/TestSchema.js.map +1 -1
- package/dist/testing/index.d.ts +64 -1
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +64 -1
- package/dist/testing/index.js.map +1 -1
- package/dist/unstable/ai/AiError.d.ts +136 -54
- package/dist/unstable/ai/AiError.d.ts.map +1 -1
- package/dist/unstable/ai/AiError.js +28 -23
- package/dist/unstable/ai/AiError.js.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.js +4 -0
- package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Chat.d.ts +35 -7
- package/dist/unstable/ai/Chat.d.ts.map +1 -1
- package/dist/unstable/ai/Chat.js +38 -44
- package/dist/unstable/ai/Chat.js.map +1 -1
- package/dist/unstable/ai/EmbeddingModel.d.ts +130 -0
- package/dist/unstable/ai/EmbeddingModel.d.ts.map +1 -0
- package/dist/unstable/ai/EmbeddingModel.js +127 -0
- package/dist/unstable/ai/EmbeddingModel.js.map +1 -0
- package/dist/unstable/ai/LanguageModel.d.ts +117 -47
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +258 -59
- package/dist/unstable/ai/LanguageModel.js.map +1 -1
- package/dist/unstable/ai/McpSchema.d.ts +183 -88
- package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
- package/dist/unstable/ai/McpSchema.js +57 -12
- package/dist/unstable/ai/McpSchema.js.map +1 -1
- package/dist/unstable/ai/McpServer.d.ts +66 -13
- package/dist/unstable/ai/McpServer.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.js +193 -51
- package/dist/unstable/ai/McpServer.js.map +1 -1
- package/dist/unstable/ai/Model.d.ts +25 -7
- package/dist/unstable/ai/Model.d.ts.map +1 -1
- package/dist/unstable/ai/Model.js +22 -6
- package/dist/unstable/ai/Model.js.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js +4 -0
- package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Prompt.d.ts +20 -20
- package/dist/unstable/ai/Prompt.d.ts.map +1 -1
- package/dist/unstable/ai/Response.d.ts +26 -26
- package/dist/unstable/ai/Response.d.ts.map +1 -1
- package/dist/unstable/ai/Response.js +1 -1
- package/dist/unstable/ai/Response.js.map +1 -1
- package/dist/unstable/ai/ResponseIdTracker.d.ts +38 -0
- package/dist/unstable/ai/ResponseIdTracker.d.ts.map +1 -0
- package/dist/unstable/ai/ResponseIdTracker.js +68 -0
- package/dist/unstable/ai/ResponseIdTracker.js.map +1 -0
- package/dist/unstable/ai/Tool.d.ts +34 -4
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +28 -10
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/ai/Toolkit.d.ts +1 -1
- package/dist/unstable/ai/Toolkit.d.ts.map +1 -1
- package/dist/unstable/ai/Toolkit.js +4 -11
- package/dist/unstable/ai/Toolkit.js.map +1 -1
- package/dist/unstable/ai/index.d.ts +22 -1
- package/dist/unstable/ai/index.d.ts.map +1 -1
- package/dist/unstable/ai/index.js +22 -1
- package/dist/unstable/ai/index.js.map +1 -1
- package/dist/unstable/ai/internal/codec-transformer.js +0 -5
- package/dist/unstable/ai/internal/codec-transformer.js.map +1 -1
- package/dist/unstable/cli/Argument.d.ts +2 -4
- package/dist/unstable/cli/Argument.d.ts.map +1 -1
- package/dist/unstable/cli/Argument.js +1 -3
- package/dist/unstable/cli/Argument.js.map +1 -1
- package/dist/unstable/cli/CliError.d.ts +27 -60
- package/dist/unstable/cli/CliError.d.ts.map +1 -1
- package/dist/unstable/cli/CliError.js +25 -57
- package/dist/unstable/cli/CliError.js.map +1 -1
- package/dist/unstable/cli/CliOutput.d.ts +3 -2
- package/dist/unstable/cli/CliOutput.d.ts.map +1 -1
- package/dist/unstable/cli/CliOutput.js +65 -10
- package/dist/unstable/cli/CliOutput.js.map +1 -1
- package/dist/unstable/cli/Command.d.ts +371 -58
- package/dist/unstable/cli/Command.d.ts.map +1 -1
- package/dist/unstable/cli/Command.js +328 -67
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cli/Completions.d.ts +16 -0
- package/dist/unstable/cli/Completions.d.ts.map +1 -0
- package/dist/unstable/cli/Completions.js +23 -0
- package/dist/unstable/cli/Completions.js.map +1 -0
- package/dist/unstable/cli/Flag.d.ts +2 -2
- package/dist/unstable/cli/Flag.d.ts.map +1 -1
- package/dist/unstable/cli/Flag.js +1 -1
- package/dist/unstable/cli/Flag.js.map +1 -1
- package/dist/unstable/cli/GlobalFlag.d.ts +125 -0
- package/dist/unstable/cli/GlobalFlag.d.ts.map +1 -0
- package/dist/unstable/cli/GlobalFlag.js +118 -0
- package/dist/unstable/cli/GlobalFlag.js.map +1 -0
- package/dist/unstable/cli/HelpDoc.d.ts +81 -11
- package/dist/unstable/cli/HelpDoc.d.ts.map +1 -1
- package/dist/unstable/cli/Param.d.ts +4 -4
- package/dist/unstable/cli/Param.d.ts.map +1 -1
- package/dist/unstable/cli/Param.js +7 -7
- package/dist/unstable/cli/Param.js.map +1 -1
- package/dist/unstable/cli/Primitive.d.ts +2 -2
- package/dist/unstable/cli/Primitive.d.ts.map +1 -1
- package/dist/unstable/cli/Primitive.js +1 -1
- package/dist/unstable/cli/Primitive.js.map +1 -1
- package/dist/unstable/cli/Prompt.js +259 -85
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/cli/index.d.ts +8 -0
- package/dist/unstable/cli/index.d.ts.map +1 -1
- package/dist/unstable/cli/index.js +8 -0
- package/dist/unstable/cli/index.js.map +1 -1
- package/dist/unstable/cli/internal/command.d.ts +40 -14
- package/dist/unstable/cli/internal/command.d.ts.map +1 -1
- package/dist/unstable/cli/internal/command.js +72 -46
- package/dist/unstable/cli/internal/command.js.map +1 -1
- package/dist/unstable/cli/internal/completions/CommandDescriptor.js +16 -4
- package/dist/unstable/cli/internal/completions/CommandDescriptor.js.map +1 -1
- package/dist/unstable/cli/internal/config.js +42 -0
- package/dist/unstable/cli/internal/config.js.map +1 -1
- package/dist/unstable/cli/internal/help.d.ts +33 -0
- package/dist/unstable/cli/internal/help.d.ts.map +1 -0
- package/dist/unstable/cli/internal/help.js +125 -0
- package/dist/unstable/cli/internal/help.js.map +1 -0
- package/dist/unstable/cli/internal/parser.js +61 -43
- package/dist/unstable/cli/internal/parser.js.map +1 -1
- package/dist/unstable/cluster/ClusterCron.d.ts +1 -1
- package/dist/unstable/cluster/ClusterCron.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterCron.js +1 -1
- package/dist/unstable/cluster/ClusterCron.js.map +1 -1
- package/dist/unstable/cluster/ClusterSchema.d.ts +18 -0
- package/dist/unstable/cluster/ClusterSchema.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterSchema.js +21 -1
- package/dist/unstable/cluster/ClusterSchema.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts +3 -2
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +35 -29
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/cluster/DeliverAt.js +1 -1
- package/dist/unstable/cluster/DeliverAt.js.map +1 -1
- package/dist/unstable/cluster/Entity.d.ts +10 -8
- package/dist/unstable/cluster/Entity.d.ts.map +1 -1
- package/dist/unstable/cluster/Entity.js +8 -7
- package/dist/unstable/cluster/Entity.js.map +1 -1
- package/dist/unstable/cluster/EntityAddress.d.ts.map +1 -1
- package/dist/unstable/cluster/EntityAddress.js +1 -1
- package/dist/unstable/cluster/EntityAddress.js.map +1 -1
- package/dist/unstable/cluster/EntityResource.d.ts +2 -2
- package/dist/unstable/cluster/EntityResource.d.ts.map +1 -1
- package/dist/unstable/cluster/Envelope.d.ts +1 -1
- package/dist/unstable/cluster/K8sHttpClient.d.ts +1 -1
- package/dist/unstable/cluster/K8sHttpClient.js +4 -4
- package/dist/unstable/cluster/K8sHttpClient.js.map +1 -1
- package/dist/unstable/cluster/Message.d.ts +18 -15
- package/dist/unstable/cluster/Message.d.ts.map +1 -1
- package/dist/unstable/cluster/Message.js +15 -7
- package/dist/unstable/cluster/Message.js.map +1 -1
- package/dist/unstable/cluster/MessageStorage.d.ts +33 -10
- package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/MessageStorage.js +36 -20
- package/dist/unstable/cluster/MessageStorage.js.map +1 -1
- package/dist/unstable/cluster/Reply.d.ts +8 -7
- package/dist/unstable/cluster/Reply.d.ts.map +1 -1
- package/dist/unstable/cluster/Reply.js +4 -3
- package/dist/unstable/cluster/Reply.js.map +1 -1
- package/dist/unstable/cluster/Runner.d.ts +1 -1
- package/dist/unstable/cluster/Runner.d.ts.map +1 -1
- package/dist/unstable/cluster/Runner.js +1 -1
- package/dist/unstable/cluster/Runner.js.map +1 -1
- package/dist/unstable/cluster/RunnerAddress.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerAddress.js +1 -1
- package/dist/unstable/cluster/RunnerAddress.js.map +1 -1
- package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerServer.js +9 -8
- package/dist/unstable/cluster/RunnerServer.js.map +1 -1
- package/dist/unstable/cluster/Runners.d.ts +2 -1
- package/dist/unstable/cluster/Runners.d.ts.map +1 -1
- package/dist/unstable/cluster/Runners.js +11 -9
- package/dist/unstable/cluster/Runners.js.map +1 -1
- package/dist/unstable/cluster/ShardId.js +3 -3
- package/dist/unstable/cluster/ShardId.js.map +1 -1
- package/dist/unstable/cluster/Sharding.d.ts +2 -2
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +51 -39
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.d.ts +26 -25
- package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.js +24 -24
- package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.js +25 -19
- package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.js +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/unstable/cluster/internal/entityManager.js +24 -18
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/cluster/internal/entityReaper.js +2 -1
- package/dist/unstable/cluster/internal/entityReaper.js.map +1 -1
- package/dist/unstable/cluster/internal/resourceRef.js +2 -1
- package/dist/unstable/cluster/internal/resourceRef.js.map +1 -1
- package/dist/unstable/devtools/DevToolsClient.d.ts.map +1 -1
- package/dist/unstable/devtools/DevToolsClient.js +4 -3
- package/dist/unstable/devtools/DevToolsClient.js.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.d.ts +40 -40
- package/dist/unstable/devtools/DevToolsSchema.d.ts.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.js +9 -2
- package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
- package/dist/unstable/encoding/Msgpack.d.ts +1 -1
- package/dist/unstable/encoding/Ndjson.d.ts +9 -9
- package/dist/unstable/encoding/Ndjson.d.ts.map +1 -1
- package/dist/unstable/encoding/Ndjson.js.map +1 -1
- package/dist/unstable/encoding/Sse.d.ts +4 -4
- package/dist/unstable/encoding/Sse.d.ts.map +1 -1
- package/dist/unstable/encoding/Sse.js +1 -1
- package/dist/unstable/encoding/Sse.js.map +1 -1
- package/dist/unstable/eventlog/EventJournal.d.ts +2 -2
- package/dist/unstable/eventlog/EventJournal.js +2 -2
- package/dist/unstable/eventlog/EventJournal.js.map +1 -1
- package/dist/unstable/eventlog/EventLog.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLog.js +3 -2
- package/dist/unstable/eventlog/EventLog.js.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.d.ts +6 -6
- package/dist/unstable/eventlog/SqlEventLogJournal.js +2 -2
- package/dist/unstable/eventlog/SqlEventLogJournal.js.map +1 -1
- package/dist/unstable/http/Cookies.d.ts +52 -7
- package/dist/unstable/http/Cookies.d.ts.map +1 -1
- package/dist/unstable/http/Cookies.js +27 -6
- package/dist/unstable/http/Cookies.js.map +1 -1
- package/dist/unstable/http/Etag.d.ts.map +1 -1
- package/dist/unstable/http/Etag.js +5 -1
- package/dist/unstable/http/Etag.js.map +1 -1
- package/dist/unstable/http/Headers.d.ts +19 -2
- package/dist/unstable/http/Headers.d.ts.map +1 -1
- package/dist/unstable/http/Headers.js +40 -11
- package/dist/unstable/http/Headers.js.map +1 -1
- package/dist/unstable/http/HttpBody.d.ts +1 -1
- package/dist/unstable/http/HttpClient.d.ts +117 -15
- package/dist/unstable/http/HttpClient.d.ts.map +1 -1
- package/dist/unstable/http/HttpClient.js +191 -13
- package/dist/unstable/http/HttpClient.js.map +1 -1
- package/dist/unstable/http/HttpClientError.d.ts +7 -7
- package/dist/unstable/http/HttpClientRequest.d.ts +43 -15
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.js +131 -21
- package/dist/unstable/http/HttpClientRequest.js.map +1 -1
- package/dist/unstable/http/HttpClientResponse.d.ts +2 -1
- package/dist/unstable/http/HttpClientResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientResponse.js +6 -1
- package/dist/unstable/http/HttpClientResponse.js.map +1 -1
- package/dist/unstable/http/HttpEffect.d.ts +7 -5
- package/dist/unstable/http/HttpEffect.d.ts.map +1 -1
- package/dist/unstable/http/HttpEffect.js +46 -54
- package/dist/unstable/http/HttpEffect.js.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.d.ts +3 -2
- package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
- package/dist/unstable/http/HttpMethod.d.ts +4 -4
- package/dist/unstable/http/HttpMethod.d.ts.map +1 -1
- package/dist/unstable/http/HttpMethod.js +3 -3
- package/dist/unstable/http/HttpMethod.js.map +1 -1
- package/dist/unstable/http/HttpMiddleware.d.ts +1 -6
- package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/unstable/http/HttpMiddleware.js +24 -32
- package/dist/unstable/http/HttpMiddleware.js.map +1 -1
- package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
- package/dist/unstable/http/HttpPlatform.js +3 -2
- package/dist/unstable/http/HttpPlatform.js.map +1 -1
- package/dist/unstable/http/HttpRouter.d.ts +2 -1
- package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
- package/dist/unstable/http/HttpRouter.js +7 -7
- package/dist/unstable/http/HttpRouter.js.map +1 -1
- package/dist/unstable/http/HttpServer.d.ts.map +1 -1
- package/dist/unstable/http/HttpServer.js +2 -2
- package/dist/unstable/http/HttpServer.js.map +1 -1
- package/dist/unstable/http/HttpServerError.d.ts +22 -34
- package/dist/unstable/http/HttpServerError.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerError.js +39 -45
- package/dist/unstable/http/HttpServerError.js.map +1 -1
- package/dist/unstable/http/HttpServerRequest.d.ts +15 -3
- package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRequest.js +301 -7
- package/dist/unstable/http/HttpServerRequest.js.map +1 -1
- package/dist/unstable/http/HttpServerRespondable.d.ts +2 -2
- package/dist/unstable/http/HttpServerRespondable.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRespondable.js +5 -5
- package/dist/unstable/http/HttpServerRespondable.js.map +1 -1
- package/dist/unstable/http/HttpServerResponse.d.ts +50 -3
- package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerResponse.js +236 -1
- package/dist/unstable/http/HttpServerResponse.js.map +1 -1
- package/dist/unstable/http/HttpStaticServer.d.ts +69 -0
- package/dist/unstable/http/HttpStaticServer.d.ts.map +1 -0
- package/dist/unstable/http/HttpStaticServer.js +353 -0
- package/dist/unstable/http/HttpStaticServer.js.map +1 -0
- package/dist/unstable/http/HttpTraceContext.d.ts +3 -2
- package/dist/unstable/http/HttpTraceContext.d.ts.map +1 -1
- package/dist/unstable/http/HttpTraceContext.js +27 -15
- package/dist/unstable/http/HttpTraceContext.js.map +1 -1
- package/dist/unstable/http/Multipart.d.ts +3 -3
- package/dist/unstable/http/Url.d.ts +604 -0
- package/dist/unstable/http/Url.d.ts.map +1 -0
- package/dist/unstable/http/Url.js +256 -0
- package/dist/unstable/http/Url.js.map +1 -0
- package/dist/unstable/http/UrlParams.d.ts +19 -10
- package/dist/unstable/http/UrlParams.d.ts.map +1 -1
- package/dist/unstable/http/UrlParams.js +6 -7
- package/dist/unstable/http/UrlParams.js.map +1 -1
- package/dist/unstable/http/index.d.ts +8 -0
- package/dist/unstable/http/index.d.ts.map +1 -1
- package/dist/unstable/http/index.js +8 -0
- package/dist/unstable/http/index.js.map +1 -1
- package/dist/unstable/http/internal/preResponseHandler.d.ts +2 -0
- package/dist/unstable/http/internal/preResponseHandler.d.ts.map +1 -0
- package/dist/unstable/http/internal/preResponseHandler.js +10 -0
- package/dist/unstable/http/internal/preResponseHandler.js.map +1 -0
- package/dist/unstable/httpapi/HttpApi.d.ts +4 -4
- package/dist/unstable/httpapi/HttpApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApi.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts +11 -5
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +40 -27
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.d.ts +83 -7
- package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.js +78 -10
- package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +207 -101
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.js +49 -43
- package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.d.ts +31 -14
- package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.js +125 -32
- package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.d.ts +4 -3
- package/dist/unstable/httpapi/HttpApiGroup.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +46 -15
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.js +32 -3
- package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.d.ts +6 -0
- package/dist/unstable/httpapi/HttpApiScalar.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.d.ts +6 -3
- package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.js +20 -2
- package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSecurity.d.ts +2 -2
- package/dist/unstable/httpapi/HttpApiSecurity.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSecurity.js.map +1 -1
- package/dist/unstable/httpapi/OpenApi.d.ts +1 -0
- package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/OpenApi.js +34 -26
- package/dist/unstable/httpapi/OpenApi.js.map +1 -1
- package/dist/unstable/observability/Otlp.d.ts +12 -12
- package/dist/unstable/observability/Otlp.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.d.ts +2 -2
- package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.js +3 -3
- package/dist/unstable/observability/OtlpExporter.js.map +1 -1
- package/dist/unstable/observability/OtlpLogger.d.ts +4 -4
- package/dist/unstable/observability/OtlpLogger.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpLogger.js +7 -4
- package/dist/unstable/observability/OtlpLogger.js.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.d.ts +4 -4
- package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpTracer.d.ts +4 -4
- package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpTracer.js +7 -3
- package/dist/unstable/observability/OtlpTracer.js.map +1 -1
- package/dist/unstable/persistence/KeyValueStore.d.ts +1 -1
- package/dist/unstable/persistence/KeyValueStore.js +6 -6
- package/dist/unstable/persistence/KeyValueStore.js.map +1 -1
- package/dist/unstable/persistence/Persistable.d.ts +2 -2
- package/dist/unstable/persistence/Persistable.d.ts.map +1 -1
- package/dist/unstable/persistence/Persistable.js +1 -1
- package/dist/unstable/persistence/Persistable.js.map +1 -1
- package/dist/unstable/persistence/PersistedCache.d.ts +6 -5
- package/dist/unstable/persistence/PersistedCache.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedCache.js +2 -1
- package/dist/unstable/persistence/PersistedCache.js.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.d.ts +12 -12
- package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.js +12 -11
- package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
- package/dist/unstable/persistence/Persistence.d.ts +1 -1
- package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
- package/dist/unstable/persistence/Persistence.js +2 -2
- package/dist/unstable/persistence/Persistence.js.map +1 -1
- package/dist/unstable/persistence/RateLimiter.d.ts +3 -3
- package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
- package/dist/unstable/persistence/RateLimiter.js +1 -1
- package/dist/unstable/persistence/RateLimiter.js.map +1 -1
- package/dist/unstable/process/ChildProcess.d.ts +5 -128
- package/dist/unstable/process/ChildProcess.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcess.js +1 -65
- package/dist/unstable/process/ChildProcess.js.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.d.ts +45 -7
- package/dist/unstable/process/ChildProcessSpawner.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.js +21 -1
- package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts +73 -12
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +108 -25
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts +17 -15
- package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.js +45 -15
- package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.d.ts +6 -0
- package/dist/unstable/reactivity/AtomRegistry.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.js +54 -11
- package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.d.ts +9 -9
- package/dist/unstable/reactivity/AtomRpc.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.js +47 -21
- package/dist/unstable/reactivity/AtomRpc.js.map +1 -1
- package/dist/unstable/reactivity/Hydration.d.ts +39 -0
- package/dist/unstable/reactivity/Hydration.d.ts.map +1 -0
- package/dist/unstable/reactivity/Hydration.js +76 -0
- package/dist/unstable/reactivity/Hydration.js.map +1 -0
- package/dist/unstable/reactivity/index.d.ts +4 -0
- package/dist/unstable/reactivity/index.d.ts.map +1 -1
- package/dist/unstable/reactivity/index.js +4 -0
- package/dist/unstable/reactivity/index.js.map +1 -1
- package/dist/unstable/rpc/Rpc.d.ts +6 -5
- package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
- package/dist/unstable/rpc/Rpc.js +4 -3
- package/dist/unstable/rpc/Rpc.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts +5 -26
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +53 -43
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/rpc/RpcGroup.d.ts +3 -5
- package/dist/unstable/rpc/RpcGroup.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcGroup.js.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.d.ts +8 -8
- package/dist/unstable/rpc/RpcMiddleware.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.js.map +1 -1
- package/dist/unstable/rpc/RpcSchema.d.ts +13 -0
- package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSchema.js +17 -2
- package/dist/unstable/rpc/RpcSchema.js.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.js +39 -11
- package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts +6 -10
- package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +20 -19
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/rpc/Utils.d.ts.map +1 -1
- package/dist/unstable/rpc/Utils.js +3 -2
- package/dist/unstable/rpc/Utils.js.map +1 -1
- package/dist/unstable/schema/Model.d.ts +22 -1
- package/dist/unstable/schema/Model.d.ts.map +1 -1
- package/dist/unstable/schema/Model.js +15 -0
- package/dist/unstable/schema/Model.js.map +1 -1
- package/dist/unstable/schema/VariantSchema.d.ts +6 -6
- package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
- package/dist/unstable/schema/VariantSchema.js +6 -6
- package/dist/unstable/schema/VariantSchema.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts +6 -5
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +12 -9
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/dist/unstable/socket/SocketServer.d.ts +3 -3
- package/dist/unstable/sql/Migrator.d.ts +1 -1
- package/dist/unstable/sql/Migrator.d.ts.map +1 -1
- package/dist/unstable/sql/Migrator.js +2 -2
- package/dist/unstable/sql/Migrator.js.map +1 -1
- package/dist/unstable/sql/SqlClient.d.ts +1 -1
- package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
- package/dist/unstable/sql/SqlClient.js +1 -1
- package/dist/unstable/sql/SqlClient.js.map +1 -1
- package/dist/unstable/sql/SqlError.d.ts +237 -17
- package/dist/unstable/sql/SqlError.d.ts.map +1 -1
- package/dist/unstable/sql/SqlError.js +260 -4
- package/dist/unstable/sql/SqlError.js.map +1 -1
- package/dist/unstable/sql/SqlModel.d.ts +2 -2
- package/dist/unstable/sql/SqlModel.d.ts.map +1 -1
- package/dist/unstable/sql/SqlModel.js +3 -3
- package/dist/unstable/sql/SqlModel.js.map +1 -1
- package/dist/unstable/sql/SqlResolver.d.ts.map +1 -1
- package/dist/unstable/sql/SqlResolver.js +17 -8
- package/dist/unstable/sql/SqlResolver.js.map +1 -1
- package/dist/unstable/sql/SqlSchema.d.ts +17 -6
- package/dist/unstable/sql/SqlSchema.d.ts.map +1 -1
- package/dist/unstable/sql/SqlSchema.js +17 -7
- package/dist/unstable/sql/SqlSchema.js.map +1 -1
- package/dist/unstable/sql/Statement.js +0 -1
- package/dist/unstable/sql/Statement.js.map +1 -1
- package/dist/unstable/workers/Worker.d.ts.map +1 -1
- package/dist/unstable/workers/Worker.js +2 -1
- package/dist/unstable/workers/Worker.js.map +1 -1
- package/dist/unstable/workflow/Activity.d.ts +5 -0
- package/dist/unstable/workflow/Activity.d.ts.map +1 -1
- package/dist/unstable/workflow/Activity.js +13 -0
- package/dist/unstable/workflow/Activity.js.map +1 -1
- package/dist/unstable/workflow/DurableClock.d.ts +3 -3
- package/dist/unstable/workflow/DurableClock.d.ts.map +1 -1
- package/dist/unstable/workflow/DurableClock.js +3 -3
- package/dist/unstable/workflow/DurableClock.js.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.js +8 -8
- package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts +5 -4
- package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
- package/dist/unstable/workflow/Workflow.js +1 -1
- package/dist/unstable/workflow/Workflow.js.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts +17 -5
- package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js +153 -12
- package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +2 -2
- package/src/Array.ts +304 -447
- package/src/BigDecimal.ts +117 -66
- package/src/BigInt.ts +49 -41
- package/src/Brand.ts +1 -1
- package/src/Cache.ts +9 -8
- package/src/Cause.ts +37 -2
- package/src/Channel.ts +582 -154
- package/src/Chunk.ts +149 -331
- package/src/Combiner.ts +280 -13
- package/src/Config.ts +195 -25
- package/src/Cron.ts +155 -63
- package/src/Data.ts +539 -376
- package/src/DateTime.ts +75 -256
- package/src/Deferred.ts +8 -6
- package/src/Duration.ts +122 -66
- package/src/Effect.ts +1484 -1157
- package/src/Encoding.ts +879 -0
- package/src/Equal.ts +278 -111
- package/src/Equivalence.ts +114 -52
- package/src/ErrorReporter.ts +458 -0
- package/src/Exit.ts +24 -12
- package/src/Fiber.ts +12 -3
- package/src/FiberHandle.ts +10 -9
- package/src/FiberMap.ts +22 -22
- package/src/FileSystem.ts +34 -31
- package/src/Filter.ts +52 -63
- package/src/Formatter.ts +253 -51
- package/src/Function.ts +2 -10
- package/src/Graph.ts +131 -117
- package/src/HashMap.ts +26 -19
- package/src/Iterable.ts +117 -63
- package/src/JsonSchema.ts +383 -10
- package/src/Latch.ts +194 -0
- package/src/Layer.ts +394 -160
- package/src/LayerMap.ts +11 -9
- package/src/LogLevel.ts +37 -0
- package/src/Logger.ts +33 -100
- package/src/ManagedRuntime.ts +35 -22
- package/src/Metric.ts +6 -8
- package/src/MutableHashMap.ts +9 -0
- package/src/MutableHashSet.ts +9 -0
- package/src/Newtype.ts +308 -0
- package/src/Number.ts +85 -26
- package/src/Optic.ts +948 -19
- package/src/Option.ts +34 -24
- package/src/Order.ts +39 -32
- package/src/PartitionedSemaphore.ts +288 -56
- package/src/Pipeable.ts +32 -1
- package/src/PlatformError.ts +5 -5
- package/src/Pool.ts +13 -11
- package/src/PubSub.ts +30 -20
- package/src/Pull.ts +1 -1
- package/src/Queue.ts +11 -9
- package/src/Random.ts +51 -14
- package/src/RcMap.ts +5 -5
- package/src/RcRef.ts +1 -1
- package/src/Record.ts +94 -199
- package/src/Reducer.ts +166 -7
- package/src/References.ts +283 -287
- package/src/Request.ts +3 -2
- package/src/RequestResolver.ts +29 -49
- package/src/Resource.ts +2 -1
- package/src/Result.ts +2 -4
- package/src/Runtime.ts +102 -6
- package/src/Schedule.ts +458 -449
- package/src/Scheduler.ts +49 -126
- package/src/Schema.ts +3298 -392
- package/src/SchemaAST.ts +172 -33
- package/src/SchemaGetter.ts +19 -21
- package/src/SchemaParser.ts +92 -27
- package/src/SchemaRepresentation.ts +51 -26
- package/src/SchemaTransformation.ts +198 -13
- package/src/ScopedCache.ts +3 -3
- package/src/Semaphore.ts +444 -0
- package/src/ServiceMap.ts +144 -97
- package/src/Sink.ts +83 -28
- package/src/Stdio.ts +27 -4
- package/src/Stream.ts +687 -617
- package/src/String.ts +122 -69
- package/src/Struct.ts +33 -7
- package/src/SubscriptionRef.ts +101 -120
- package/src/SynchronizedRef.ts +3 -2
- package/src/Terminal.ts +2 -1
- package/src/Tracer.ts +6 -5
- package/src/Trie.ts +44 -31
- package/src/TxChunk.ts +72 -53
- package/src/TxDeferred.ts +394 -0
- package/src/TxHashMap.ts +409 -343
- package/src/TxHashSet.ts +113 -118
- package/src/TxPriorityQueue.ts +766 -0
- package/src/TxPubSub.ts +789 -0
- package/src/TxQueue.ts +241 -251
- package/src/TxReentrantLock.ts +753 -0
- package/src/TxRef.ts +50 -38
- package/src/TxSemaphore.ts +217 -44
- package/src/TxSubscriptionRef.ts +639 -0
- package/src/Types.ts +73 -19
- package/src/Utils.ts +137 -111
- package/src/index.ts +816 -56
- package/src/internal/core.ts +12 -5
- package/src/internal/dateTime.ts +91 -96
- package/src/internal/effect.ts +844 -432
- package/src/internal/hashMap.ts +12 -10
- package/src/internal/option.ts +7 -0
- package/src/internal/random.ts +20 -0
- package/src/internal/rcRef.ts +4 -3
- package/src/internal/references.ts +72 -0
- package/src/internal/request.ts +2 -2
- package/src/internal/schema/annotations.ts +2 -0
- package/src/internal/schema/representation.ts +73 -94
- package/src/internal/schema/schema.ts +1 -0
- package/src/internal/schema/to-codec.ts +7 -17
- package/src/internal/trie.ts +21 -15
- package/src/testing/TestClock.ts +13 -11
- package/src/testing/TestSchema.ts +332 -35
- package/src/testing/index.ts +64 -1
- package/src/unstable/ai/AiError.ts +111 -54
- package/src/unstable/ai/AnthropicStructuredOutput.ts +4 -0
- package/src/unstable/ai/Chat.ts +134 -85
- package/src/unstable/ai/EmbeddingModel.ts +209 -0
- package/src/unstable/ai/LanguageModel.ts +683 -253
- package/src/unstable/ai/McpSchema.ts +73 -13
- package/src/unstable/ai/McpServer.ts +271 -61
- package/src/unstable/ai/Model.ts +40 -9
- package/src/unstable/ai/OpenAiStructuredOutput.ts +4 -0
- package/src/unstable/ai/Prompt.ts +37 -37
- package/src/unstable/ai/Response.ts +25 -25
- package/src/unstable/ai/ResponseIdTracker.ts +97 -0
- package/src/unstable/ai/Tool.ts +42 -16
- package/src/unstable/ai/Toolkit.ts +5 -14
- package/src/unstable/ai/index.ts +24 -1
- package/src/unstable/ai/internal/codec-transformer.ts +0 -7
- package/src/unstable/cli/Argument.ts +2 -4
- package/src/unstable/cli/CliError.ts +47 -59
- package/src/unstable/cli/CliOutput.ts +85 -13
- package/src/unstable/cli/Command.ts +801 -192
- package/src/unstable/cli/Completions.ts +36 -0
- package/src/unstable/cli/Flag.ts +2 -2
- package/src/unstable/cli/GlobalFlag.ts +242 -0
- package/src/unstable/cli/HelpDoc.ts +91 -11
- package/src/unstable/cli/Param.ts +15 -11
- package/src/unstable/cli/Primitive.ts +2 -2
- package/src/unstable/cli/Prompt.ts +265 -101
- package/src/unstable/cli/index.ts +10 -0
- package/src/unstable/cli/internal/command.ts +109 -63
- package/src/unstable/cli/internal/completions/CommandDescriptor.ts +10 -4
- package/src/unstable/cli/internal/config.ts +49 -0
- package/src/unstable/cli/internal/help.ts +171 -0
- package/src/unstable/cli/internal/parser.ts +71 -63
- package/src/unstable/cluster/ClusterCron.ts +2 -2
- package/src/unstable/cluster/ClusterSchema.ts +29 -1
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +62 -37
- package/src/unstable/cluster/DeliverAt.ts +1 -1
- package/src/unstable/cluster/Entity.ts +25 -22
- package/src/unstable/cluster/EntityAddress.ts +1 -1
- package/src/unstable/cluster/EntityResource.ts +4 -4
- package/src/unstable/cluster/Envelope.ts +1 -1
- package/src/unstable/cluster/K8sHttpClient.ts +5 -5
- package/src/unstable/cluster/Message.ts +28 -15
- package/src/unstable/cluster/MessageStorage.ts +66 -36
- package/src/unstable/cluster/Reply.ts +7 -4
- package/src/unstable/cluster/Runner.ts +1 -1
- package/src/unstable/cluster/RunnerAddress.ts +1 -1
- package/src/unstable/cluster/RunnerServer.ts +10 -13
- package/src/unstable/cluster/Runners.ts +14 -12
- package/src/unstable/cluster/ShardId.ts +2 -2
- package/src/unstable/cluster/Sharding.ts +66 -49
- package/src/unstable/cluster/ShardingConfig.ts +36 -37
- package/src/unstable/cluster/SqlMessageStorage.ts +31 -19
- package/src/unstable/cluster/SqlRunnerStorage.ts +1 -1
- package/src/unstable/cluster/internal/entityManager.ts +50 -34
- package/src/unstable/cluster/internal/entityReaper.ts +2 -1
- package/src/unstable/cluster/internal/resourceRef.ts +2 -1
- package/src/unstable/devtools/DevToolsClient.ts +23 -18
- package/src/unstable/devtools/DevToolsSchema.ts +16 -3
- package/src/unstable/encoding/Ndjson.ts +17 -17
- package/src/unstable/encoding/Sse.ts +3 -5
- package/src/unstable/eventlog/EventJournal.ts +2 -2
- package/src/unstable/eventlog/EventLog.ts +3 -2
- package/src/unstable/eventlog/SqlEventLogJournal.ts +2 -2
- package/src/unstable/http/Cookies.ts +94 -11
- package/src/unstable/http/Etag.ts +5 -3
- package/src/unstable/http/Headers.ts +68 -18
- package/src/unstable/http/HttpClient.ts +376 -34
- package/src/unstable/http/HttpClientRequest.ts +151 -39
- package/src/unstable/http/HttpClientResponse.ts +12 -6
- package/src/unstable/http/HttpEffect.ts +54 -68
- package/src/unstable/http/HttpIncomingMessage.ts +3 -2
- package/src/unstable/http/HttpMethod.ts +16 -4
- package/src/unstable/http/HttpMiddleware.ts +25 -39
- package/src/unstable/http/HttpPlatform.ts +3 -2
- package/src/unstable/http/HttpRouter.ts +9 -9
- package/src/unstable/http/HttpServer.ts +3 -9
- package/src/unstable/http/HttpServerError.ts +45 -47
- package/src/unstable/http/HttpServerRequest.ts +407 -16
- package/src/unstable/http/HttpServerRespondable.ts +6 -6
- package/src/unstable/http/HttpServerResponse.ts +345 -7
- package/src/unstable/http/HttpStaticServer.ts +456 -0
- package/src/unstable/http/HttpTraceContext.ts +31 -17
- package/src/unstable/http/Multipart.ts +2 -2
- package/src/unstable/http/Url.ts +650 -0
- package/src/unstable/http/UrlParams.ts +31 -19
- package/src/unstable/http/index.ts +10 -0
- package/src/unstable/http/internal/preResponseHandler.ts +15 -0
- package/src/unstable/httpapi/HttpApi.ts +6 -6
- package/src/unstable/httpapi/HttpApiBuilder.ts +106 -41
- package/src/unstable/httpapi/HttpApiClient.ts +180 -28
- package/src/unstable/httpapi/HttpApiEndpoint.ts +216 -104
- package/src/unstable/httpapi/HttpApiError.ts +108 -30
- package/src/unstable/httpapi/HttpApiGroup.ts +7 -6
- package/src/unstable/httpapi/HttpApiMiddleware.ts +83 -22
- package/src/unstable/httpapi/HttpApiScalar.ts +6 -0
- package/src/unstable/httpapi/HttpApiSchema.ts +21 -3
- package/src/unstable/httpapi/HttpApiSecurity.ts +3 -3
- package/src/unstable/httpapi/OpenApi.ts +44 -29
- package/src/unstable/observability/Otlp.ts +12 -12
- package/src/unstable/observability/OtlpExporter.ts +8 -5
- package/src/unstable/observability/OtlpLogger.ts +13 -9
- package/src/unstable/observability/OtlpMetrics.ts +4 -4
- package/src/unstable/observability/OtlpTracer.ts +12 -8
- package/src/unstable/persistence/KeyValueStore.ts +6 -6
- package/src/unstable/persistence/Persistable.ts +3 -3
- package/src/unstable/persistence/PersistedCache.ts +20 -9
- package/src/unstable/persistence/PersistedQueue.ts +25 -24
- package/src/unstable/persistence/Persistence.ts +3 -3
- package/src/unstable/persistence/RateLimiter.ts +4 -4
- package/src/unstable/process/ChildProcess.ts +6 -208
- package/src/unstable/process/ChildProcessSpawner.ts +75 -14
- package/src/unstable/reactivity/Atom.ts +212 -54
- package/src/unstable/reactivity/AtomHttpApi.ts +81 -41
- package/src/unstable/reactivity/AtomRegistry.ts +66 -12
- package/src/unstable/reactivity/AtomRpc.ts +51 -20
- package/src/unstable/reactivity/Hydration.ts +112 -0
- package/src/unstable/reactivity/index.ts +5 -0
- package/src/unstable/rpc/Rpc.ts +12 -12
- package/src/unstable/rpc/RpcClient.ts +67 -96
- package/src/unstable/rpc/RpcGroup.ts +7 -7
- package/src/unstable/rpc/RpcMiddleware.ts +15 -9
- package/src/unstable/rpc/RpcSchema.ts +23 -5
- package/src/unstable/rpc/RpcSerialization.ts +49 -11
- package/src/unstable/rpc/RpcServer.ts +31 -35
- package/src/unstable/rpc/Utils.ts +3 -2
- package/src/unstable/schema/Model.ts +31 -0
- package/src/unstable/schema/VariantSchema.ts +10 -10
- package/src/unstable/socket/Socket.ts +31 -27
- package/src/unstable/sql/Migrator.ts +7 -5
- package/src/unstable/sql/SqlClient.ts +6 -4
- package/src/unstable/sql/SqlError.ts +365 -11
- package/src/unstable/sql/SqlModel.ts +5 -5
- package/src/unstable/sql/SqlResolver.ts +17 -7
- package/src/unstable/sql/SqlSchema.ts +42 -26
- package/src/unstable/sql/Statement.ts +0 -1
- package/src/unstable/workers/Worker.ts +2 -1
- package/src/unstable/workflow/Activity.ts +23 -0
- package/src/unstable/workflow/DurableClock.ts +8 -8
- package/src/unstable/workflow/DurableDeferred.ts +8 -8
- package/src/unstable/workflow/Workflow.ts +7 -3
- package/src/unstable/workflow/WorkflowEngine.ts +211 -19
- package/dist/NullOr.d.ts +0 -149
- package/dist/NullOr.d.ts.map +0 -1
- package/dist/NullOr.js +0 -152
- package/dist/NullOr.js.map +0 -1
- package/dist/encoding/Base64.d.ts +0 -67
- package/dist/encoding/Base64.d.ts.map +0 -1
- package/dist/encoding/Base64.js +0 -146
- package/dist/encoding/Base64.js.map +0 -1
- package/dist/encoding/Base64Url.d.ts +0 -60
- package/dist/encoding/Base64Url.d.ts.map +0 -1
- package/dist/encoding/Base64Url.js +0 -89
- package/dist/encoding/Base64Url.js.map +0 -1
- package/dist/encoding/EncodingError.d.ts +0 -31
- package/dist/encoding/EncodingError.d.ts.map +0 -1
- package/dist/encoding/EncodingError.js +0 -22
- package/dist/encoding/EncodingError.js.map +0 -1
- package/dist/encoding/Hex.d.ts +0 -61
- package/dist/encoding/Hex.d.ts.map +0 -1
- package/dist/encoding/Hex.js +0 -115
- package/dist/encoding/Hex.js.map +0 -1
- package/dist/encoding/index.d.ts +0 -26
- package/dist/encoding/index.d.ts.map +0 -1
- package/dist/encoding/index.js +0 -27
- package/dist/encoding/index.js.map +0 -1
- package/dist/unstable/cli/internal/builtInFlags.d.ts +0 -7
- package/dist/unstable/cli/internal/builtInFlags.d.ts.map +0 -1
- package/dist/unstable/cli/internal/builtInFlags.js +0 -44
- package/dist/unstable/cli/internal/builtInFlags.js.map +0 -1
- package/dist/unstable/cli/internal/completions/Completions.d.ts +0 -2
- package/dist/unstable/cli/internal/completions/Completions.d.ts.map +0 -1
- package/dist/unstable/cli/internal/completions/Completions.js +0 -23
- package/dist/unstable/cli/internal/completions/Completions.js.map +0 -1
- package/src/NullOr.ts +0 -204
- package/src/encoding/Base64.ts +0 -366
- package/src/encoding/Base64Url.ts +0 -104
- package/src/encoding/EncodingError.ts +0 -35
- package/src/encoding/Hex.ts +0 -390
- package/src/encoding/index.ts +0 -31
- package/src/unstable/cli/internal/builtInFlags.ts +0 -78
- package/src/unstable/cli/internal/completions/Completions.ts +0 -31
package/src/Schedule.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*
|
|
13
13
|
* // Retry with exponential backoff
|
|
14
14
|
* const retryPolicy = Schedule.exponential("100 millis", 2.0)
|
|
15
|
-
* .pipe(Schedule.
|
|
15
|
+
* .pipe(Schedule.both(Schedule.recurs(3)))
|
|
16
16
|
*
|
|
17
17
|
* const program = Effect.gen(function*() {
|
|
18
18
|
* // This will retry up to 3 times with exponential backoff
|
|
@@ -36,8 +36,9 @@ import * as Duration from "./Duration.ts"
|
|
|
36
36
|
import type { Effect } from "./Effect.ts"
|
|
37
37
|
import type { LazyArg } from "./Function.ts"
|
|
38
38
|
import { constant, dual, identity } from "./Function.ts"
|
|
39
|
-
|
|
39
|
+
import { isEffect } from "./internal/core.ts"
|
|
40
40
|
import * as effect from "./internal/effect.ts"
|
|
41
|
+
import * as random from "./internal/random.ts"
|
|
41
42
|
import { type Pipeable, pipeArguments } from "./Pipeable.ts"
|
|
42
43
|
import { hasProperty } from "./Predicate.ts"
|
|
43
44
|
import * as Pull from "./Pull.ts"
|
|
@@ -47,6 +48,8 @@ import type { Contravariant, Covariant, Mutable } from "./Types.ts"
|
|
|
47
48
|
|
|
48
49
|
const TypeId = "~effect/Schedule"
|
|
49
50
|
|
|
51
|
+
const randomNext: Effect<number> = random.Random.useSync((random) => random.nextDoubleUnsafe())
|
|
52
|
+
|
|
50
53
|
/**
|
|
51
54
|
* A Schedule defines a strategy for repeating or retrying effects based on some policy.
|
|
52
55
|
*
|
|
@@ -56,7 +59,7 @@ const TypeId = "~effect/Schedule"
|
|
|
56
59
|
*
|
|
57
60
|
* // Basic retry schedule - retry up to 3 times with exponential backoff
|
|
58
61
|
* const retrySchedule = Schedule.exponential("100 millis").pipe(
|
|
59
|
-
* Schedule.
|
|
62
|
+
* Schedule.both(Schedule.recurs(3))
|
|
60
63
|
* )
|
|
61
64
|
*
|
|
62
65
|
* // Basic repeat schedule - repeat every 30 seconds forever
|
|
@@ -69,7 +72,7 @@ const TypeId = "~effect/Schedule"
|
|
|
69
72
|
* const program = Effect.gen(function*() {
|
|
70
73
|
* // Using retry schedule
|
|
71
74
|
* const result1 = yield* Effect.retry(
|
|
72
|
-
* Effect.fail("temporary error"),
|
|
75
|
+
* Effect.suspend(() => Math.random() > 0.5 ? Effect.fail("temporary error") : Effect.succeed("Success")),
|
|
73
76
|
* retrySchedule
|
|
74
77
|
* )
|
|
75
78
|
*
|
|
@@ -197,7 +200,7 @@ export const CurrentMetadata = ServiceMap.Reference<Metadata>("effect/Schedule/C
|
|
|
197
200
|
* Effect.gen(function*() {
|
|
198
201
|
* attempt++
|
|
199
202
|
* if (attempt < 3) {
|
|
200
|
-
* yield* Effect.fail(`Attempt ${attempt} failed`)
|
|
203
|
+
* return yield* Effect.fail(`Attempt ${attempt} failed`)
|
|
201
204
|
* }
|
|
202
205
|
* return `Success on attempt ${attempt}`
|
|
203
206
|
* }),
|
|
@@ -333,7 +336,7 @@ export const isSchedule = (u: unknown): u is Schedule<unknown, never, unknown, u
|
|
|
333
336
|
*
|
|
334
337
|
* // These can be combined and transformed as needed
|
|
335
338
|
* const complexSchedule = simpleSchedule.pipe(
|
|
336
|
-
* Schedule.
|
|
339
|
+
* Schedule.both(Schedule.recurs(3))
|
|
337
340
|
* )
|
|
338
341
|
* ```
|
|
339
342
|
*
|
|
@@ -520,7 +523,9 @@ export const toStepWithSleep = <Output, Input, Error, Env>(
|
|
|
520
523
|
*
|
|
521
524
|
* @example
|
|
522
525
|
* ```ts
|
|
523
|
-
* import { Console, Duration, Effect, Schedule } from "effect"
|
|
526
|
+
* import { Console, Data, Duration, Effect, Schedule } from "effect"
|
|
527
|
+
*
|
|
528
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
524
529
|
*
|
|
525
530
|
* // Add random jitter to schedule delays
|
|
526
531
|
* const jitteredSchedule = Schedule.addDelay(
|
|
@@ -616,7 +621,7 @@ export const toStepWithSleep = <Output, Input, Error, Env>(
|
|
|
616
621
|
* Effect.gen(function*() {
|
|
617
622
|
* attempt++
|
|
618
623
|
* if (attempt < 5) {
|
|
619
|
-
* yield* Effect.fail(new
|
|
624
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
620
625
|
* }
|
|
621
626
|
* return `Success on attempt ${attempt}`
|
|
622
627
|
* }),
|
|
@@ -637,7 +642,9 @@ export const addDelay: {
|
|
|
637
642
|
*
|
|
638
643
|
* @example
|
|
639
644
|
* ```ts
|
|
640
|
-
* import { Console, Duration, Effect, Schedule } from "effect"
|
|
645
|
+
* import { Console, Data, Duration, Effect, Schedule } from "effect"
|
|
646
|
+
*
|
|
647
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
641
648
|
*
|
|
642
649
|
* // Add random jitter to schedule delays
|
|
643
650
|
* const jitteredSchedule = Schedule.addDelay(
|
|
@@ -733,7 +740,7 @@ export const addDelay: {
|
|
|
733
740
|
* Effect.gen(function*() {
|
|
734
741
|
* attempt++
|
|
735
742
|
* if (attempt < 5) {
|
|
736
|
-
* yield* Effect.fail(new
|
|
743
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
737
744
|
* }
|
|
738
745
|
* return `Success on attempt ${attempt}`
|
|
739
746
|
* }),
|
|
@@ -747,7 +754,7 @@ export const addDelay: {
|
|
|
747
754
|
* @since 2.0.0
|
|
748
755
|
* @category utils
|
|
749
756
|
*/
|
|
750
|
-
<Output, Error2 = never, Env2 = never>(f: (output: Output) => Effect<Duration.
|
|
757
|
+
<Output, Error2 = never, Env2 = never>(f: (output: Output) => Effect<Duration.Input, Error2, Env2>): <Input, Error, Env>(
|
|
751
758
|
self: Schedule<Output, Input, Error, Env>
|
|
752
759
|
) => Schedule<Output, Input, Error | Error2, Env | Env2>
|
|
753
760
|
/**
|
|
@@ -756,7 +763,9 @@ export const addDelay: {
|
|
|
756
763
|
*
|
|
757
764
|
* @example
|
|
758
765
|
* ```ts
|
|
759
|
-
* import { Console, Duration, Effect, Schedule } from "effect"
|
|
766
|
+
* import { Console, Data, Duration, Effect, Schedule } from "effect"
|
|
767
|
+
*
|
|
768
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
760
769
|
*
|
|
761
770
|
* // Add random jitter to schedule delays
|
|
762
771
|
* const jitteredSchedule = Schedule.addDelay(
|
|
@@ -852,7 +861,7 @@ export const addDelay: {
|
|
|
852
861
|
* Effect.gen(function*() {
|
|
853
862
|
* attempt++
|
|
854
863
|
* if (attempt < 5) {
|
|
855
|
-
* yield* Effect.fail(new
|
|
864
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
856
865
|
* }
|
|
857
866
|
* return `Success on attempt ${attempt}`
|
|
858
867
|
* }),
|
|
@@ -868,17 +877,16 @@ export const addDelay: {
|
|
|
868
877
|
*/
|
|
869
878
|
<Output, Input, Error, Env, Error2 = never, Env2 = never>(
|
|
870
879
|
self: Schedule<Output, Input, Error, Env>,
|
|
871
|
-
f: (output: Output) => Effect<Duration.
|
|
880
|
+
f: (output: Output) => Effect<Duration.Input, Error2, Env2>
|
|
872
881
|
): Schedule<Output, Input, Error | Error2, Env | Env2>
|
|
873
882
|
} = dual(2, <Output, Input, Error, Env, Error2 = never, Env2 = never>(
|
|
874
883
|
self: Schedule<Output, Input, Error, Env>,
|
|
875
|
-
f: (output: Output) => Effect<Duration.
|
|
884
|
+
f: (output: Output) => Effect<Duration.Input, Error2, Env2>
|
|
876
885
|
): Schedule<Output, Input, Error | Error2, Env | Env2> =>
|
|
877
886
|
modifyDelay(
|
|
878
887
|
self,
|
|
879
888
|
(output, delay) =>
|
|
880
|
-
effect.map(f(output), (d) =>
|
|
881
|
-
Duration.sum(Duration.fromDurationInputUnsafe(d), Duration.fromDurationInputUnsafe(delay)))
|
|
889
|
+
effect.map(f(output), (d) => Duration.sum(Duration.fromInputUnsafe(d), Duration.fromInputUnsafe(delay)))
|
|
882
890
|
))
|
|
883
891
|
|
|
884
892
|
/**
|
|
@@ -888,7 +896,9 @@ export const addDelay: {
|
|
|
888
896
|
*
|
|
889
897
|
* @example
|
|
890
898
|
* ```ts
|
|
891
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
899
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
900
|
+
*
|
|
901
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
892
902
|
*
|
|
893
903
|
* // First retry 3 times quickly, then switch to slower retries
|
|
894
904
|
* const quickRetries = Schedule.exponential("100 millis").pipe(
|
|
@@ -907,7 +917,7 @@ export const addDelay: {
|
|
|
907
917
|
* attempt++
|
|
908
918
|
* yield* Console.log(`Attempt ${attempt}`)
|
|
909
919
|
* if (attempt < 6) {
|
|
910
|
-
* yield* Effect.fail(new
|
|
920
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Failure ${attempt}` }))
|
|
911
921
|
* }
|
|
912
922
|
* return `Success on attempt ${attempt}`
|
|
913
923
|
* }),
|
|
@@ -927,7 +937,9 @@ export const andThen: {
|
|
|
927
937
|
*
|
|
928
938
|
* @example
|
|
929
939
|
* ```ts
|
|
930
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
940
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
941
|
+
*
|
|
942
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
931
943
|
*
|
|
932
944
|
* // First retry 3 times quickly, then switch to slower retries
|
|
933
945
|
* const quickRetries = Schedule.exponential("100 millis").pipe(
|
|
@@ -946,7 +958,7 @@ export const andThen: {
|
|
|
946
958
|
* attempt++
|
|
947
959
|
* yield* Console.log(`Attempt ${attempt}`)
|
|
948
960
|
* if (attempt < 6) {
|
|
949
|
-
* yield* Effect.fail(new
|
|
961
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Failure ${attempt}` }))
|
|
950
962
|
* }
|
|
951
963
|
* return `Success on attempt ${attempt}`
|
|
952
964
|
* }),
|
|
@@ -968,7 +980,9 @@ export const andThen: {
|
|
|
968
980
|
*
|
|
969
981
|
* @example
|
|
970
982
|
* ```ts
|
|
971
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
983
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
984
|
+
*
|
|
985
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
972
986
|
*
|
|
973
987
|
* // First retry 3 times quickly, then switch to slower retries
|
|
974
988
|
* const quickRetries = Schedule.exponential("100 millis").pipe(
|
|
@@ -987,7 +1001,7 @@ export const andThen: {
|
|
|
987
1001
|
* attempt++
|
|
988
1002
|
* yield* Console.log(`Attempt ${attempt}`)
|
|
989
1003
|
* if (attempt < 6) {
|
|
990
|
-
* yield* Effect.fail(new
|
|
1004
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Failure ${attempt}` }))
|
|
991
1005
|
* }
|
|
992
1006
|
* return `Success on attempt ${attempt}`
|
|
993
1007
|
* }),
|
|
@@ -1140,116 +1154,211 @@ export const andThenResult: {
|
|
|
1140
1154
|
} = dual(2, <Output, Input, Error, Env, Output2, Input2, Error2, Env2>(
|
|
1141
1155
|
self: Schedule<Output, Input, Error, Env>,
|
|
1142
1156
|
other: Schedule<Output2, Input2, Error2, Env2>
|
|
1143
|
-
): Schedule<Result.Result<
|
|
1144
|
-
fromStep(effect.
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1157
|
+
): Schedule<Result.Result<Output, Output2>, Input & Input2, Error | Error2, Env | Env2> =>
|
|
1158
|
+
fromStep(effect.sync(() => {
|
|
1159
|
+
let currentSide = 0
|
|
1160
|
+
let currentStep:
|
|
1161
|
+
| undefined
|
|
1162
|
+
| ((now: number, input: Input & Input2) => Pull.Pull<
|
|
1163
|
+
[Result.Result<Output, Output2>, Duration.Duration],
|
|
1149
1164
|
Error | Error2,
|
|
1150
|
-
Output
|
|
1165
|
+
Result.Result<Output, Output2>,
|
|
1151
1166
|
Env | Env2
|
|
1152
|
-
>
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1167
|
+
>)
|
|
1168
|
+
const left = map(self, Result.succeed)
|
|
1169
|
+
const right = map(other, Result.fail)
|
|
1170
|
+
return function recur(
|
|
1171
|
+
now,
|
|
1172
|
+
input
|
|
1173
|
+
): Pull.Pull<
|
|
1174
|
+
[Result.Result<Output, Output2>, Duration.Duration],
|
|
1175
|
+
Error | Error2,
|
|
1176
|
+
Result.Result<Output, Output2>,
|
|
1177
|
+
Env | Env2
|
|
1178
|
+
> {
|
|
1179
|
+
if (currentStep) return currentStep(now, input)
|
|
1180
|
+
return toStep<
|
|
1181
|
+
/**
|
|
1182
|
+
* Returns a new `Schedule` that will first execute the left (i.e. `self`)
|
|
1183
|
+
* schedule to completion. Once the left schedule is complete, the right (i.e.
|
|
1184
|
+
* `other`) schedule will be executed to completion.
|
|
1185
|
+
*
|
|
1186
|
+
* The output of the resulting schedule is a `Result` where outputs of the
|
|
1187
|
+
* left schedule are emitted as `Result.Err<Output>` and outputs of the right
|
|
1188
|
+
* schedule are emitted as `Result.Ok<Output>`.
|
|
1189
|
+
*
|
|
1190
|
+
* @example
|
|
1191
|
+
* ```ts
|
|
1192
|
+
* import { Console, Effect, Result, Schedule } from "effect"
|
|
1193
|
+
*
|
|
1194
|
+
* // Track which phase of the schedule we're in
|
|
1195
|
+
* const phaseTracker = Schedule.andThenResult(
|
|
1196
|
+
* Schedule.exponential("100 millis").pipe(Schedule.take(2)),
|
|
1197
|
+
* Schedule.spaced("500 millis").pipe(Schedule.take(2))
|
|
1198
|
+
* )
|
|
1199
|
+
*
|
|
1200
|
+
* const program = Effect.gen(function*() {
|
|
1201
|
+
* yield* Effect.repeat(
|
|
1202
|
+
* Effect.gen(function*() {
|
|
1203
|
+
* yield* Console.log("Task executed")
|
|
1204
|
+
* return "task-result"
|
|
1205
|
+
* }),
|
|
1206
|
+
* phaseTracker.pipe(
|
|
1207
|
+
* Schedule.tapOutput((result) =>
|
|
1208
|
+
* Result.match(result, {
|
|
1209
|
+
* onFailure: (phase1Output) => Console.log(`Phase 1: ${phase1Output}`),
|
|
1210
|
+
* onSuccess: (phase2Output) => Console.log(`Phase 2: ${phase2Output}`)
|
|
1211
|
+
* })
|
|
1212
|
+
* )
|
|
1213
|
+
* )
|
|
1214
|
+
* )
|
|
1215
|
+
* })
|
|
1216
|
+
* ```
|
|
1217
|
+
*
|
|
1218
|
+
* @since 2.0.0
|
|
1219
|
+
* @category sequencing
|
|
1220
|
+
*/
|
|
1221
|
+
Result.Result<Output, Output2>,
|
|
1222
|
+
/**
|
|
1223
|
+
* Returns a new `Schedule` that will first execute the left (i.e. `self`)
|
|
1224
|
+
* schedule to completion. Once the left schedule is complete, the right (i.e.
|
|
1225
|
+
* `other`) schedule will be executed to completion.
|
|
1226
|
+
*
|
|
1227
|
+
* The output of the resulting schedule is a `Result` where outputs of the
|
|
1228
|
+
* left schedule are emitted as `Result.Err<Output>` and outputs of the right
|
|
1229
|
+
* schedule are emitted as `Result.Ok<Output>`.
|
|
1230
|
+
*
|
|
1231
|
+
* @example
|
|
1232
|
+
* ```ts
|
|
1233
|
+
* import { Console, Effect, Result, Schedule } from "effect"
|
|
1234
|
+
*
|
|
1235
|
+
* // Track which phase of the schedule we're in
|
|
1236
|
+
* const phaseTracker = Schedule.andThenResult(
|
|
1237
|
+
* Schedule.exponential("100 millis").pipe(Schedule.take(2)),
|
|
1238
|
+
* Schedule.spaced("500 millis").pipe(Schedule.take(2))
|
|
1239
|
+
* )
|
|
1240
|
+
*
|
|
1241
|
+
* const program = Effect.gen(function*() {
|
|
1242
|
+
* yield* Effect.repeat(
|
|
1243
|
+
* Effect.gen(function*() {
|
|
1244
|
+
* yield* Console.log("Task executed")
|
|
1245
|
+
* return "task-result"
|
|
1246
|
+
* }),
|
|
1247
|
+
* phaseTracker.pipe(
|
|
1248
|
+
* Schedule.tapOutput((result) =>
|
|
1249
|
+
* Result.match(result, {
|
|
1250
|
+
* onFailure: (phase1Output) => Console.log(`Phase 1: ${phase1Output}`),
|
|
1251
|
+
* onSuccess: (phase2Output) => Console.log(`Phase 2: ${phase2Output}`)
|
|
1252
|
+
* })
|
|
1253
|
+
* )
|
|
1254
|
+
* )
|
|
1255
|
+
* )
|
|
1256
|
+
* })
|
|
1257
|
+
* ```
|
|
1258
|
+
*
|
|
1259
|
+
* @since 2.0.0
|
|
1260
|
+
* @category sequencing
|
|
1261
|
+
*/
|
|
1262
|
+
Input & Input2,
|
|
1263
|
+
/**
|
|
1264
|
+
* Returns a new `Schedule` that will first execute the left (i.e. `self`)
|
|
1265
|
+
* schedule to completion. Once the left schedule is complete, the right (i.e.
|
|
1266
|
+
* `other`) schedule will be executed to completion.
|
|
1267
|
+
*
|
|
1268
|
+
* The output of the resulting schedule is a `Result` where outputs of the
|
|
1269
|
+
* left schedule are emitted as `Result.Err<Output>` and outputs of the right
|
|
1270
|
+
* schedule are emitted as `Result.Ok<Output>`.
|
|
1271
|
+
*
|
|
1272
|
+
* @example
|
|
1273
|
+
* ```ts
|
|
1274
|
+
* import { Console, Effect, Result, Schedule } from "effect"
|
|
1275
|
+
*
|
|
1276
|
+
* // Track which phase of the schedule we're in
|
|
1277
|
+
* const phaseTracker = Schedule.andThenResult(
|
|
1278
|
+
* Schedule.exponential("100 millis").pipe(Schedule.take(2)),
|
|
1279
|
+
* Schedule.spaced("500 millis").pipe(Schedule.take(2))
|
|
1280
|
+
* )
|
|
1281
|
+
*
|
|
1282
|
+
* const program = Effect.gen(function*() {
|
|
1283
|
+
* yield* Effect.repeat(
|
|
1284
|
+
* Effect.gen(function*() {
|
|
1285
|
+
* yield* Console.log("Task executed")
|
|
1286
|
+
* return "task-result"
|
|
1287
|
+
* }),
|
|
1288
|
+
* phaseTracker.pipe(
|
|
1289
|
+
* Schedule.tapOutput((result) =>
|
|
1290
|
+
* Result.match(result, {
|
|
1291
|
+
* onFailure: (phase1Output) => Console.log(`Phase 1: ${phase1Output}`),
|
|
1292
|
+
* onSuccess: (phase2Output) => Console.log(`Phase 2: ${phase2Output}`)
|
|
1293
|
+
* })
|
|
1294
|
+
* )
|
|
1295
|
+
* )
|
|
1296
|
+
* )
|
|
1297
|
+
* })
|
|
1298
|
+
* ```
|
|
1299
|
+
*
|
|
1300
|
+
* @since 2.0.0
|
|
1301
|
+
* @category sequencing
|
|
1302
|
+
*/
|
|
1303
|
+
Error | Error2,
|
|
1304
|
+
/**
|
|
1305
|
+
* Returns a new `Schedule` that will first execute the left (i.e. `self`)
|
|
1306
|
+
* schedule to completion. Once the left schedule is complete, the right (i.e.
|
|
1307
|
+
* `other`) schedule will be executed to completion.
|
|
1308
|
+
*
|
|
1309
|
+
* The output of the resulting schedule is a `Result` where outputs of the
|
|
1310
|
+
* left schedule are emitted as `Result.Err<Output>` and outputs of the right
|
|
1311
|
+
* schedule are emitted as `Result.Ok<Output>`.
|
|
1312
|
+
*
|
|
1313
|
+
* @example
|
|
1314
|
+
* ```ts
|
|
1315
|
+
* import { Console, Effect, Result, Schedule } from "effect"
|
|
1316
|
+
*
|
|
1317
|
+
* // Track which phase of the schedule we're in
|
|
1318
|
+
* const phaseTracker = Schedule.andThenResult(
|
|
1319
|
+
* Schedule.exponential("100 millis").pipe(Schedule.take(2)),
|
|
1320
|
+
* Schedule.spaced("500 millis").pipe(Schedule.take(2))
|
|
1321
|
+
* )
|
|
1322
|
+
*
|
|
1323
|
+
* const program = Effect.gen(function*() {
|
|
1324
|
+
* yield* Effect.repeat(
|
|
1325
|
+
* Effect.gen(function*() {
|
|
1326
|
+
* yield* Console.log("Task executed")
|
|
1327
|
+
* return "task-result"
|
|
1328
|
+
* }),
|
|
1329
|
+
* phaseTracker.pipe(
|
|
1330
|
+
* Schedule.tapOutput((result) =>
|
|
1331
|
+
* Result.match(result, {
|
|
1332
|
+
* onFailure: (phase1Output) => Console.log(`Phase 1: ${phase1Output}`),
|
|
1333
|
+
* onSuccess: (phase2Output) => Console.log(`Phase 2: ${phase2Output}`)
|
|
1334
|
+
* })
|
|
1335
|
+
* )
|
|
1336
|
+
* )
|
|
1337
|
+
* )
|
|
1338
|
+
* })
|
|
1339
|
+
* ```
|
|
1340
|
+
*
|
|
1341
|
+
* @since 2.0.0
|
|
1342
|
+
* @category sequencing
|
|
1343
|
+
*/
|
|
1344
|
+
Env | Env2
|
|
1345
|
+
>(currentSide === 0 ? left : right).pipe(
|
|
1346
|
+
effect.flatMap((step) => {
|
|
1347
|
+
currentSide++
|
|
1348
|
+
if (currentSide === 1) {
|
|
1349
|
+
currentStep = (now, input) =>
|
|
1350
|
+
Pull.catchDone(step(now, input), (_) => {
|
|
1351
|
+
currentStep = undefined
|
|
1352
|
+
return recur(now, input)
|
|
1353
|
+
})
|
|
1354
|
+
return currentStep(now, input)
|
|
1355
|
+
}
|
|
1356
|
+
currentStep = step
|
|
1357
|
+
return currentStep(now, input)
|
|
1358
|
+
})
|
|
1359
|
+
);
|
|
1360
|
+
};
|
|
1361
|
+
})))
|
|
1253
1362
|
|
|
1254
1363
|
/**
|
|
1255
1364
|
* Combines two `Schedule`s by recurring if both of the two schedules want
|
|
@@ -1258,7 +1367,9 @@ export const andThenResult: {
|
|
|
1258
1367
|
*
|
|
1259
1368
|
* @example
|
|
1260
1369
|
* ```ts
|
|
1261
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
1370
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
1371
|
+
*
|
|
1372
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
1262
1373
|
*
|
|
1263
1374
|
* // Both schedules must want to continue for the combined schedule to continue
|
|
1264
1375
|
* const timeLimit = Schedule.spaced("1 second").pipe(Schedule.take(5)) // max 5 times
|
|
@@ -1300,7 +1411,7 @@ export const andThenResult: {
|
|
|
1300
1411
|
* yield* Console.log(`Retry attempt ${attempt}`)
|
|
1301
1412
|
*
|
|
1302
1413
|
* if (attempt < 3) {
|
|
1303
|
-
* yield* Effect.fail(new
|
|
1414
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
1304
1415
|
* }
|
|
1305
1416
|
*
|
|
1306
1417
|
* return `Success on attempt ${attempt}`
|
|
@@ -1326,7 +1437,9 @@ export const both: {
|
|
|
1326
1437
|
*
|
|
1327
1438
|
* @example
|
|
1328
1439
|
* ```ts
|
|
1329
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
1440
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
1441
|
+
*
|
|
1442
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
1330
1443
|
*
|
|
1331
1444
|
* // Both schedules must want to continue for the combined schedule to continue
|
|
1332
1445
|
* const timeLimit = Schedule.spaced("1 second").pipe(Schedule.take(5)) // max 5 times
|
|
@@ -1368,7 +1481,7 @@ export const both: {
|
|
|
1368
1481
|
* yield* Console.log(`Retry attempt ${attempt}`)
|
|
1369
1482
|
*
|
|
1370
1483
|
* if (attempt < 3) {
|
|
1371
|
-
* yield* Effect.fail(new
|
|
1484
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
1372
1485
|
* }
|
|
1373
1486
|
*
|
|
1374
1487
|
* return `Success on attempt ${attempt}`
|
|
@@ -1396,7 +1509,9 @@ export const both: {
|
|
|
1396
1509
|
*
|
|
1397
1510
|
* @example
|
|
1398
1511
|
* ```ts
|
|
1399
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
1512
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
1513
|
+
*
|
|
1514
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
1400
1515
|
*
|
|
1401
1516
|
* // Both schedules must want to continue for the combined schedule to continue
|
|
1402
1517
|
* const timeLimit = Schedule.spaced("1 second").pipe(Schedule.take(5)) // max 5 times
|
|
@@ -1438,7 +1553,7 @@ export const both: {
|
|
|
1438
1553
|
* yield* Console.log(`Retry attempt ${attempt}`)
|
|
1439
1554
|
*
|
|
1440
1555
|
* if (attempt < 3) {
|
|
1441
|
-
* yield* Effect.fail(new
|
|
1556
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
1442
1557
|
* }
|
|
1443
1558
|
*
|
|
1444
1559
|
* return `Success on attempt ${attempt}`
|
|
@@ -1838,205 +1953,6 @@ export const bothWith: {
|
|
|
1838
1953
|
})
|
|
1839
1954
|
)))
|
|
1840
1955
|
|
|
1841
|
-
/**
|
|
1842
|
-
* Returns a new `Schedule` that combines two schedules by running them
|
|
1843
|
-
* sequentially. First the current schedule runs to completion, then the
|
|
1844
|
-
* other schedule runs to completion. The output is a tuple of both results.
|
|
1845
|
-
*
|
|
1846
|
-
* @example
|
|
1847
|
-
* ```ts
|
|
1848
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
1849
|
-
*
|
|
1850
|
-
* // Compose a quick retry phase followed by slower retry phase
|
|
1851
|
-
* const fastRetries = Schedule.exponential("100 millis").pipe(
|
|
1852
|
-
* Schedule.compose(Schedule.recurs(3)) // 3 fast retries
|
|
1853
|
-
* )
|
|
1854
|
-
*
|
|
1855
|
-
* const slowRetries = Schedule.exponential("2 seconds").pipe(
|
|
1856
|
-
* Schedule.compose(Schedule.recurs(2)) // 2 slow retries
|
|
1857
|
-
* )
|
|
1858
|
-
*
|
|
1859
|
-
* // Sequential composition: fast retries first, then slow retries
|
|
1860
|
-
* const composedRetry = Schedule.compose(fastRetries, slowRetries)
|
|
1861
|
-
* // Outputs: [number_from_fast_phase, number_from_slow_phase]
|
|
1862
|
-
*
|
|
1863
|
-
* const program = Effect.gen(function*() {
|
|
1864
|
-
* let attempt = 0
|
|
1865
|
-
*
|
|
1866
|
-
* const result = yield* Effect.retry(
|
|
1867
|
-
* Effect.gen(function*() {
|
|
1868
|
-
* attempt++
|
|
1869
|
-
* yield* Console.log(`Attempt ${attempt}`)
|
|
1870
|
-
*
|
|
1871
|
-
* if (attempt < 7) { // Needs both phases to succeed
|
|
1872
|
-
* yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
1873
|
-
* }
|
|
1874
|
-
*
|
|
1875
|
-
* return `Success on attempt ${attempt}`
|
|
1876
|
-
* }),
|
|
1877
|
-
* composedRetry.pipe(
|
|
1878
|
-
* Schedule.tapOutput(([fastResult, slowResult]) =>
|
|
1879
|
-
* Console.log(`Fast phase: ${fastResult}, Slow phase: ${slowResult}`)
|
|
1880
|
-
* )
|
|
1881
|
-
* )
|
|
1882
|
-
* )
|
|
1883
|
-
*
|
|
1884
|
-
* yield* Console.log(`Final result: ${result}`)
|
|
1885
|
-
* })
|
|
1886
|
-
*
|
|
1887
|
-
* // Compose different schedule types
|
|
1888
|
-
* const warmupAndMaintenance = Schedule.compose(
|
|
1889
|
-
* Schedule.fixed("500 millis").pipe(Schedule.take(5)), // 5 warmup cycles
|
|
1890
|
-
* Schedule.spaced("5 seconds") // then regular maintenance
|
|
1891
|
-
* )
|
|
1892
|
-
*
|
|
1893
|
-
* // Progressive backoff: fixed first, then exponential
|
|
1894
|
-
* const progressiveBackoff = Schedule.compose(
|
|
1895
|
-
* Schedule.fixed("100 millis").pipe(Schedule.take(3)), // Fixed: 100ms, 100ms, 100ms
|
|
1896
|
-
* Schedule.exponential("500 millis").pipe(Schedule.take(3)) // Then exponential: 500ms, 1s, 2s
|
|
1897
|
-
* )
|
|
1898
|
-
* ```
|
|
1899
|
-
*
|
|
1900
|
-
* @since 2.0.0
|
|
1901
|
-
* @category sequencing
|
|
1902
|
-
*/
|
|
1903
|
-
export const compose: {
|
|
1904
|
-
/**
|
|
1905
|
-
* Returns a new `Schedule` that combines two schedules by running them
|
|
1906
|
-
* sequentially. First the current schedule runs to completion, then the
|
|
1907
|
-
* other schedule runs to completion. The output is a tuple of both results.
|
|
1908
|
-
*
|
|
1909
|
-
* @example
|
|
1910
|
-
* ```ts
|
|
1911
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
1912
|
-
*
|
|
1913
|
-
* // Compose a quick retry phase followed by slower retry phase
|
|
1914
|
-
* const fastRetries = Schedule.exponential("100 millis").pipe(
|
|
1915
|
-
* Schedule.compose(Schedule.recurs(3)) // 3 fast retries
|
|
1916
|
-
* )
|
|
1917
|
-
*
|
|
1918
|
-
* const slowRetries = Schedule.exponential("2 seconds").pipe(
|
|
1919
|
-
* Schedule.compose(Schedule.recurs(2)) // 2 slow retries
|
|
1920
|
-
* )
|
|
1921
|
-
*
|
|
1922
|
-
* // Sequential composition: fast retries first, then slow retries
|
|
1923
|
-
* const composedRetry = Schedule.compose(fastRetries, slowRetries)
|
|
1924
|
-
* // Outputs: [number_from_fast_phase, number_from_slow_phase]
|
|
1925
|
-
*
|
|
1926
|
-
* const program = Effect.gen(function*() {
|
|
1927
|
-
* let attempt = 0
|
|
1928
|
-
*
|
|
1929
|
-
* const result = yield* Effect.retry(
|
|
1930
|
-
* Effect.gen(function*() {
|
|
1931
|
-
* attempt++
|
|
1932
|
-
* yield* Console.log(`Attempt ${attempt}`)
|
|
1933
|
-
*
|
|
1934
|
-
* if (attempt < 7) { // Needs both phases to succeed
|
|
1935
|
-
* yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
1936
|
-
* }
|
|
1937
|
-
*
|
|
1938
|
-
* return `Success on attempt ${attempt}`
|
|
1939
|
-
* }),
|
|
1940
|
-
* composedRetry.pipe(
|
|
1941
|
-
* Schedule.tapOutput(([fastResult, slowResult]) =>
|
|
1942
|
-
* Console.log(`Fast phase: ${fastResult}, Slow phase: ${slowResult}`)
|
|
1943
|
-
* )
|
|
1944
|
-
* )
|
|
1945
|
-
* )
|
|
1946
|
-
*
|
|
1947
|
-
* yield* Console.log(`Final result: ${result}`)
|
|
1948
|
-
* })
|
|
1949
|
-
*
|
|
1950
|
-
* // Compose different schedule types
|
|
1951
|
-
* const warmupAndMaintenance = Schedule.compose(
|
|
1952
|
-
* Schedule.fixed("500 millis").pipe(Schedule.take(5)), // 5 warmup cycles
|
|
1953
|
-
* Schedule.spaced("5 seconds") // then regular maintenance
|
|
1954
|
-
* )
|
|
1955
|
-
*
|
|
1956
|
-
* // Progressive backoff: fixed first, then exponential
|
|
1957
|
-
* const progressiveBackoff = Schedule.compose(
|
|
1958
|
-
* Schedule.fixed("100 millis").pipe(Schedule.take(3)), // Fixed: 100ms, 100ms, 100ms
|
|
1959
|
-
* Schedule.exponential("500 millis").pipe(Schedule.take(3)) // Then exponential: 500ms, 1s, 2s
|
|
1960
|
-
* )
|
|
1961
|
-
* ```
|
|
1962
|
-
*
|
|
1963
|
-
* @since 2.0.0
|
|
1964
|
-
* @category sequencing
|
|
1965
|
-
*/
|
|
1966
|
-
<Output2, Input2, Error2, Env2>(other: Schedule<Output2, Input2, Error2, Env2>): <Output, Input, Error, Env>(
|
|
1967
|
-
self: Schedule<Output, Input, Error, Env>
|
|
1968
|
-
) => Schedule<[Output, Output2], Input & Input2, Error | Error2, Env | Env2>
|
|
1969
|
-
/**
|
|
1970
|
-
* Returns a new `Schedule` that combines two schedules by running them
|
|
1971
|
-
* sequentially. First the current schedule runs to completion, then the
|
|
1972
|
-
* other schedule runs to completion. The output is a tuple of both results.
|
|
1973
|
-
*
|
|
1974
|
-
* @example
|
|
1975
|
-
* ```ts
|
|
1976
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
1977
|
-
*
|
|
1978
|
-
* // Compose a quick retry phase followed by slower retry phase
|
|
1979
|
-
* const fastRetries = Schedule.exponential("100 millis").pipe(
|
|
1980
|
-
* Schedule.compose(Schedule.recurs(3)) // 3 fast retries
|
|
1981
|
-
* )
|
|
1982
|
-
*
|
|
1983
|
-
* const slowRetries = Schedule.exponential("2 seconds").pipe(
|
|
1984
|
-
* Schedule.compose(Schedule.recurs(2)) // 2 slow retries
|
|
1985
|
-
* )
|
|
1986
|
-
*
|
|
1987
|
-
* // Sequential composition: fast retries first, then slow retries
|
|
1988
|
-
* const composedRetry = Schedule.compose(fastRetries, slowRetries)
|
|
1989
|
-
* // Outputs: [number_from_fast_phase, number_from_slow_phase]
|
|
1990
|
-
*
|
|
1991
|
-
* const program = Effect.gen(function*() {
|
|
1992
|
-
* let attempt = 0
|
|
1993
|
-
*
|
|
1994
|
-
* const result = yield* Effect.retry(
|
|
1995
|
-
* Effect.gen(function*() {
|
|
1996
|
-
* attempt++
|
|
1997
|
-
* yield* Console.log(`Attempt ${attempt}`)
|
|
1998
|
-
*
|
|
1999
|
-
* if (attempt < 7) { // Needs both phases to succeed
|
|
2000
|
-
* yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
2001
|
-
* }
|
|
2002
|
-
*
|
|
2003
|
-
* return `Success on attempt ${attempt}`
|
|
2004
|
-
* }),
|
|
2005
|
-
* composedRetry.pipe(
|
|
2006
|
-
* Schedule.tapOutput(([fastResult, slowResult]) =>
|
|
2007
|
-
* Console.log(`Fast phase: ${fastResult}, Slow phase: ${slowResult}`)
|
|
2008
|
-
* )
|
|
2009
|
-
* )
|
|
2010
|
-
* )
|
|
2011
|
-
*
|
|
2012
|
-
* yield* Console.log(`Final result: ${result}`)
|
|
2013
|
-
* })
|
|
2014
|
-
*
|
|
2015
|
-
* // Compose different schedule types
|
|
2016
|
-
* const warmupAndMaintenance = Schedule.compose(
|
|
2017
|
-
* Schedule.fixed("500 millis").pipe(Schedule.take(5)), // 5 warmup cycles
|
|
2018
|
-
* Schedule.spaced("5 seconds") // then regular maintenance
|
|
2019
|
-
* )
|
|
2020
|
-
*
|
|
2021
|
-
* // Progressive backoff: fixed first, then exponential
|
|
2022
|
-
* const progressiveBackoff = Schedule.compose(
|
|
2023
|
-
* Schedule.fixed("100 millis").pipe(Schedule.take(3)), // Fixed: 100ms, 100ms, 100ms
|
|
2024
|
-
* Schedule.exponential("500 millis").pipe(Schedule.take(3)) // Then exponential: 500ms, 1s, 2s
|
|
2025
|
-
* )
|
|
2026
|
-
* ```
|
|
2027
|
-
*
|
|
2028
|
-
* @since 2.0.0
|
|
2029
|
-
* @category sequencing
|
|
2030
|
-
*/
|
|
2031
|
-
<Output, Input, Error, Env, Output2, Input2, Error2, Env2>(
|
|
2032
|
-
self: Schedule<Output, Input, Error, Env>,
|
|
2033
|
-
other: Schedule<Output2, Input2, Error2, Env2>
|
|
2034
|
-
): Schedule<[Output, Output2], Input & Input2, Error | Error2, Env | Env2>
|
|
2035
|
-
} = dual(2, <Output, Input, Error, Env, Output2, Input2, Error2, Env2>(
|
|
2036
|
-
self: Schedule<Output, Input, Error, Env>,
|
|
2037
|
-
other: Schedule<Output2, Input2, Error2, Env2>
|
|
2038
|
-
): Schedule<[Output, Output2], Input & Input2, Error | Error2, Env | Env2> => both(self, other))
|
|
2039
|
-
|
|
2040
1956
|
/**
|
|
2041
1957
|
* Returns a new `Schedule` that always recurs, collecting all inputs of the
|
|
2042
1958
|
* schedule into an array.
|
|
@@ -2313,7 +2229,7 @@ export const collectWhile: {
|
|
|
2313
2229
|
<Input, Output, Error2 = never, Env2 = never>(
|
|
2314
2230
|
predicate: (
|
|
2315
2231
|
metadata: Metadata<Output, Input>
|
|
2316
|
-
) => Effect<boolean, Error2, Env2>
|
|
2232
|
+
) => boolean | Effect<boolean, Error2, Env2>
|
|
2317
2233
|
): <Error, Env>(
|
|
2318
2234
|
self: Schedule<Output, Input, Error, Env>
|
|
2319
2235
|
) => Schedule<Array<Output>, Input, Error | Error2, Env | Env2>
|
|
@@ -2425,19 +2341,18 @@ export const collectWhile: {
|
|
|
2425
2341
|
self: Schedule<Output, Input, Error, Env>,
|
|
2426
2342
|
predicate: (
|
|
2427
2343
|
metadata: Metadata<Output, Input>
|
|
2428
|
-
) => Effect<boolean, Error2, Env2>
|
|
2344
|
+
) => boolean | Effect<boolean, Error2, Env2>
|
|
2429
2345
|
): Schedule<Array<Output>, Input, Error | Error2, Env | Env2>
|
|
2430
2346
|
} = dual(2, <Output, Input, Error, Env, Error2 = never, Env2 = never>(
|
|
2431
2347
|
self: Schedule<Output, Input, Error, Env>,
|
|
2432
2348
|
predicate: (
|
|
2433
2349
|
metadata: Metadata<Output, Input>
|
|
2434
|
-
) => Effect<boolean, Error2, Env2>
|
|
2350
|
+
) => boolean | Effect<boolean, Error2, Env2>
|
|
2435
2351
|
): Schedule<Array<Output>, Input, Error | Error2, Env | Env2> =>
|
|
2436
|
-
reduce(while_(self, predicate), () => [] as Array<Output>, (outputs, output) =>
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
})())))
|
|
2352
|
+
reduce(while_(self, predicate), () => [] as Array<Output>, (outputs, output) => {
|
|
2353
|
+
outputs.push(output)
|
|
2354
|
+
return outputs
|
|
2355
|
+
}))
|
|
2441
2356
|
|
|
2442
2357
|
/**
|
|
2443
2358
|
* Returns a new `Schedule` that recurs on the specified `Cron` schedule and
|
|
@@ -2445,7 +2360,9 @@ export const collectWhile: {
|
|
|
2445
2360
|
*
|
|
2446
2361
|
* @example
|
|
2447
2362
|
* ```ts
|
|
2448
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
2363
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
2364
|
+
*
|
|
2365
|
+
* class ScheduledTaskError extends Data.TaggedError("ScheduledTaskError")<{ readonly message: string }> {}
|
|
2449
2366
|
*
|
|
2450
2367
|
* // Run every minute
|
|
2451
2368
|
* const everyMinute = Schedule.cron("* * * * *")
|
|
@@ -2546,7 +2463,7 @@ export const collectWhile: {
|
|
|
2546
2463
|
* yield* Console.log("Complex scheduled task...")
|
|
2547
2464
|
* // Simulate occasional failures
|
|
2548
2465
|
* if (Math.random() < 0.3) {
|
|
2549
|
-
* yield* Effect.fail(new
|
|
2466
|
+
* return yield* Effect.fail(new ScheduledTaskError({ message: "Scheduled task failed" }))
|
|
2550
2467
|
* }
|
|
2551
2468
|
* return "success"
|
|
2552
2469
|
* }),
|
|
@@ -2569,7 +2486,9 @@ export const cron: {
|
|
|
2569
2486
|
*
|
|
2570
2487
|
* @example
|
|
2571
2488
|
* ```ts
|
|
2572
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
2489
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
2490
|
+
*
|
|
2491
|
+
* class ScheduledTaskError extends Data.TaggedError("ScheduledTaskError")<{ readonly message: string }> {}
|
|
2573
2492
|
*
|
|
2574
2493
|
* // Run every minute
|
|
2575
2494
|
* const everyMinute = Schedule.cron("* * * * *")
|
|
@@ -2670,7 +2589,7 @@ export const cron: {
|
|
|
2670
2589
|
* yield* Console.log("Complex scheduled task...")
|
|
2671
2590
|
* // Simulate occasional failures
|
|
2672
2591
|
* if (Math.random() < 0.3) {
|
|
2673
|
-
* yield* Effect.fail(new
|
|
2592
|
+
* return yield* Effect.fail(new ScheduledTaskError({ message: "Scheduled task failed" }))
|
|
2674
2593
|
* }
|
|
2675
2594
|
* return "success"
|
|
2676
2595
|
* }),
|
|
@@ -2693,7 +2612,9 @@ export const cron: {
|
|
|
2693
2612
|
*
|
|
2694
2613
|
* @example
|
|
2695
2614
|
* ```ts
|
|
2696
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
2615
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
2616
|
+
*
|
|
2617
|
+
* class ScheduledTaskError extends Data.TaggedError("ScheduledTaskError")<{ readonly message: string }> {}
|
|
2697
2618
|
*
|
|
2698
2619
|
* // Run every minute
|
|
2699
2620
|
* const everyMinute = Schedule.cron("* * * * *")
|
|
@@ -2794,7 +2715,7 @@ export const cron: {
|
|
|
2794
2715
|
* yield* Console.log("Complex scheduled task...")
|
|
2795
2716
|
* // Simulate occasional failures
|
|
2796
2717
|
* if (Math.random() < 0.3) {
|
|
2797
|
-
* yield* Effect.fail(new
|
|
2718
|
+
* return yield* Effect.fail(new ScheduledTaskError({ message: "Scheduled task failed" }))
|
|
2798
2719
|
* }
|
|
2799
2720
|
* return "success"
|
|
2800
2721
|
* }),
|
|
@@ -2925,8 +2846,8 @@ export const delays = <Out, In, E, R>(self: Schedule<Out, In, E, R>): Schedule<D
|
|
|
2925
2846
|
* @since 2.0.0
|
|
2926
2847
|
* @category constructors
|
|
2927
2848
|
*/
|
|
2928
|
-
export const duration = (durationInput: Duration.
|
|
2929
|
-
const duration = Duration.
|
|
2849
|
+
export const duration = (durationInput: Duration.Input): Schedule<Duration.Duration> => {
|
|
2850
|
+
const duration = Duration.fromInputUnsafe(durationInput)
|
|
2930
2851
|
return fromStepWithMetadata(effect.succeed((meta) =>
|
|
2931
2852
|
meta.attempt === 1
|
|
2932
2853
|
? effect.succeed([duration, duration])
|
|
@@ -2940,7 +2861,9 @@ export const duration = (durationInput: Duration.DurationInput): Schedule<Durati
|
|
|
2940
2861
|
*
|
|
2941
2862
|
* @example
|
|
2942
2863
|
* ```ts
|
|
2943
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
2864
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
2865
|
+
*
|
|
2866
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
2944
2867
|
*
|
|
2945
2868
|
* // Run a task for exactly 5 seconds, regardless of how many iterations
|
|
2946
2869
|
* const fiveSecondSchedule = Schedule.during("5 seconds")
|
|
@@ -3002,7 +2925,7 @@ export const duration = (durationInput: Duration.DurationInput): Schedule<Durati
|
|
|
3002
2925
|
* yield* Console.log(`Retry attempt ${attempt}`)
|
|
3003
2926
|
*
|
|
3004
2927
|
* if (Math.random() < 0.8) { // 80% failure rate
|
|
3005
|
-
* yield* Effect.fail(new
|
|
2928
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
3006
2929
|
* }
|
|
3007
2930
|
*
|
|
3008
2931
|
* return `Success on attempt ${attempt}`
|
|
@@ -3019,10 +2942,10 @@ export const duration = (durationInput: Duration.DurationInput): Schedule<Durati
|
|
|
3019
2942
|
* @since 4.0.0
|
|
3020
2943
|
* @category constructors
|
|
3021
2944
|
*/
|
|
3022
|
-
export const during = (duration: Duration.
|
|
2945
|
+
export const during = (duration: Duration.Input): Schedule<Duration.Duration> =>
|
|
3023
2946
|
while_(
|
|
3024
2947
|
elapsed,
|
|
3025
|
-
({ output }) => effect.succeed(Duration.isLessThanOrEqualTo(output, Duration.
|
|
2948
|
+
({ output }) => effect.succeed(Duration.isLessThanOrEqualTo(output, Duration.fromInputUnsafe(duration)))
|
|
3026
2949
|
)
|
|
3027
2950
|
|
|
3028
2951
|
/**
|
|
@@ -3032,7 +2955,9 @@ export const during = (duration: Duration.DurationInput): Schedule<Duration.Dura
|
|
|
3032
2955
|
*
|
|
3033
2956
|
* @example
|
|
3034
2957
|
* ```ts
|
|
3035
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
2958
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
2959
|
+
*
|
|
2960
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
3036
2961
|
*
|
|
3037
2962
|
* // Either continues as long as at least one schedule wants to continue
|
|
3038
2963
|
* const timeBasedSchedule = Schedule.spaced("2 seconds").pipe(Schedule.take(3))
|
|
@@ -3076,7 +3001,7 @@ export const during = (duration: Duration.DurationInput): Schedule<Duration.Dura
|
|
|
3076
3001
|
* yield* Console.log(`Retry attempt ${attempt}`)
|
|
3077
3002
|
*
|
|
3078
3003
|
* if (attempt < 6) {
|
|
3079
|
-
* yield* Effect.fail(new
|
|
3004
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
3080
3005
|
* }
|
|
3081
3006
|
*
|
|
3082
3007
|
* return `Success on attempt ${attempt}`
|
|
@@ -3102,7 +3027,9 @@ export const either: {
|
|
|
3102
3027
|
*
|
|
3103
3028
|
* @example
|
|
3104
3029
|
* ```ts
|
|
3105
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
3030
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
3031
|
+
*
|
|
3032
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
3106
3033
|
*
|
|
3107
3034
|
* // Either continues as long as at least one schedule wants to continue
|
|
3108
3035
|
* const timeBasedSchedule = Schedule.spaced("2 seconds").pipe(Schedule.take(3))
|
|
@@ -3146,7 +3073,7 @@ export const either: {
|
|
|
3146
3073
|
* yield* Console.log(`Retry attempt ${attempt}`)
|
|
3147
3074
|
*
|
|
3148
3075
|
* if (attempt < 6) {
|
|
3149
|
-
* yield* Effect.fail(new
|
|
3076
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
3150
3077
|
* }
|
|
3151
3078
|
*
|
|
3152
3079
|
* return `Success on attempt ${attempt}`
|
|
@@ -3174,7 +3101,9 @@ export const either: {
|
|
|
3174
3101
|
*
|
|
3175
3102
|
* @example
|
|
3176
3103
|
* ```ts
|
|
3177
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
3104
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
3105
|
+
*
|
|
3106
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
3178
3107
|
*
|
|
3179
3108
|
* // Either continues as long as at least one schedule wants to continue
|
|
3180
3109
|
* const timeBasedSchedule = Schedule.spaced("2 seconds").pipe(Schedule.take(3))
|
|
@@ -3218,7 +3147,7 @@ export const either: {
|
|
|
3218
3147
|
* yield* Console.log(`Retry attempt ${attempt}`)
|
|
3219
3148
|
*
|
|
3220
3149
|
* if (attempt < 6) {
|
|
3221
|
-
* yield* Effect.fail(new
|
|
3150
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
3222
3151
|
* }
|
|
3223
3152
|
*
|
|
3224
3153
|
* return `Success on attempt ${attempt}`
|
|
@@ -3722,7 +3651,9 @@ export const elapsed: Schedule<Duration.Duration> = fromStepWithMetadata(
|
|
|
3722
3651
|
*
|
|
3723
3652
|
* @example
|
|
3724
3653
|
* ```ts
|
|
3725
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
3654
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
3655
|
+
*
|
|
3656
|
+
* class RetryFailure extends Data.TaggedError("RetryFailure")<{ readonly message: string }> {}
|
|
3726
3657
|
*
|
|
3727
3658
|
* // Basic exponential backoff with default factor of 2
|
|
3728
3659
|
* const basicExponential = Schedule.exponential("100 millis")
|
|
@@ -3734,7 +3665,7 @@ export const elapsed: Schedule<Duration.Duration> = fromStepWithMetadata(
|
|
|
3734
3665
|
*
|
|
3735
3666
|
* // Retry with exponential backoff (limited to 5 attempts)
|
|
3736
3667
|
* const retryPolicy = Schedule.exponential("50 millis").pipe(
|
|
3737
|
-
* Schedule.
|
|
3668
|
+
* Schedule.both(Schedule.recurs(5))
|
|
3738
3669
|
* )
|
|
3739
3670
|
*
|
|
3740
3671
|
* const program = Effect.gen(function*() {
|
|
@@ -3745,7 +3676,7 @@ export const elapsed: Schedule<Duration.Duration> = fromStepWithMetadata(
|
|
|
3745
3676
|
* attempt++
|
|
3746
3677
|
* if (attempt < 4) {
|
|
3747
3678
|
* yield* Console.log(`Attempt ${attempt} failed, retrying...`)
|
|
3748
|
-
* yield* Effect.fail(new
|
|
3679
|
+
* return yield* Effect.fail(new RetryFailure({ message: `Failure ${attempt}` }))
|
|
3749
3680
|
* }
|
|
3750
3681
|
* return `Success on attempt ${attempt}`
|
|
3751
3682
|
* }),
|
|
@@ -3762,10 +3693,10 @@ export const elapsed: Schedule<Duration.Duration> = fromStepWithMetadata(
|
|
|
3762
3693
|
* @category constructors
|
|
3763
3694
|
*/
|
|
3764
3695
|
export const exponential = (
|
|
3765
|
-
base: Duration.
|
|
3696
|
+
base: Duration.Input,
|
|
3766
3697
|
factor: number = 2
|
|
3767
3698
|
): Schedule<Duration.Duration> => {
|
|
3768
|
-
const baseMillis = Duration.toMillis(Duration.
|
|
3699
|
+
const baseMillis = Duration.toMillis(Duration.fromInputUnsafe(base))
|
|
3769
3700
|
return fromStepWithMetadata(effect.succeed((meta) => {
|
|
3770
3701
|
const duration = Duration.millis(baseMillis * Math.pow(factor, meta.attempt - 1))
|
|
3771
3702
|
return effect.succeed([duration, duration])
|
|
@@ -3779,7 +3710,9 @@ export const exponential = (
|
|
|
3779
3710
|
*
|
|
3780
3711
|
* @example
|
|
3781
3712
|
* ```ts
|
|
3782
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
3713
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
3714
|
+
*
|
|
3715
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
3783
3716
|
*
|
|
3784
3717
|
* // Basic fibonacci schedule starting with 100ms
|
|
3785
3718
|
* const fibSchedule = Schedule.fibonacci("100 millis")
|
|
@@ -3795,13 +3728,13 @@ export const exponential = (
|
|
|
3795
3728
|
* yield* Console.log(`Attempt ${attempt}`)
|
|
3796
3729
|
*
|
|
3797
3730
|
* if (attempt < 5) {
|
|
3798
|
-
* yield* Effect.fail(new
|
|
3731
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
3799
3732
|
* }
|
|
3800
3733
|
*
|
|
3801
3734
|
* return `Success on attempt ${attempt}`
|
|
3802
3735
|
* }),
|
|
3803
3736
|
* Schedule.fibonacci("50 millis").pipe(
|
|
3804
|
-
* Schedule.
|
|
3737
|
+
* Schedule.both(Schedule.recurs(6)), // Maximum 6 retries
|
|
3805
3738
|
* Schedule.tapOutput((delay) => Console.log(`Next retry in ${delay}`))
|
|
3806
3739
|
* )
|
|
3807
3740
|
* )
|
|
@@ -3836,8 +3769,8 @@ export const exponential = (
|
|
|
3836
3769
|
* @since 2.0.0
|
|
3837
3770
|
* @category constructors
|
|
3838
3771
|
*/
|
|
3839
|
-
export const fibonacci = (one: Duration.
|
|
3840
|
-
const oneMillis = Duration.toMillis(Duration.
|
|
3772
|
+
export const fibonacci = (one: Duration.Input): Schedule<Duration.Duration> => {
|
|
3773
|
+
const oneMillis = Duration.toMillis(Duration.fromInputUnsafe(one))
|
|
3841
3774
|
return fromStep(effect.sync(() => {
|
|
3842
3775
|
let a = 0
|
|
3843
3776
|
let b = oneMillis
|
|
@@ -3913,16 +3846,28 @@ export const fibonacci = (one: Duration.DurationInput): Schedule<Duration.Durati
|
|
|
3913
3846
|
* @since 2.0.0
|
|
3914
3847
|
* @category constructors
|
|
3915
3848
|
*/
|
|
3916
|
-
export const fixed = (interval: Duration.
|
|
3917
|
-
const window = Duration.toMillis(Duration.
|
|
3918
|
-
return fromStepWithMetadata(effect.
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3849
|
+
export const fixed = (interval: Duration.Input): Schedule<number> => {
|
|
3850
|
+
const window = Duration.toMillis(Duration.fromInputUnsafe(interval))
|
|
3851
|
+
return fromStepWithMetadata(effect.sync(() => {
|
|
3852
|
+
let start = 0
|
|
3853
|
+
let lastRun = 0
|
|
3854
|
+
return (meta) =>
|
|
3855
|
+
effect.sync(() => {
|
|
3856
|
+
if (window === 0) {
|
|
3857
|
+
return [meta.attempt - 1, Duration.zero] as const
|
|
3858
|
+
}
|
|
3859
|
+
if (meta.attempt === 1) {
|
|
3860
|
+
start = meta.now
|
|
3861
|
+
lastRun = meta.now + window
|
|
3862
|
+
return [0, Duration.millis(window)] as const
|
|
3863
|
+
}
|
|
3864
|
+
const runningBehind = meta.now > (lastRun + window)
|
|
3865
|
+
const boundary = window - ((meta.now - start) % window)
|
|
3866
|
+
const delay = runningBehind ? 0 : boundary === 0 ? window : boundary
|
|
3867
|
+
lastRun = runningBehind ? meta.now : meta.now + delay
|
|
3868
|
+
return [meta.attempt - 1, Duration.millis(delay)] as const
|
|
3869
|
+
})
|
|
3870
|
+
}))
|
|
3926
3871
|
}
|
|
3927
3872
|
|
|
3928
3873
|
/**
|
|
@@ -4050,7 +3995,7 @@ export const map: {
|
|
|
4050
3995
|
* @since 2.0.0
|
|
4051
3996
|
* @category mapping
|
|
4052
3997
|
*/
|
|
4053
|
-
<Output, Output2, Error2 = never, Env2 = never>(f: (output: Output) => Effect<Output2, Error2, Env2>): <Input, Error, Env>(
|
|
3998
|
+
<Output, Output2, Error2 = never, Env2 = never>(f: (output: Output) => Output2 | Effect<Output2, Error2, Env2>): <Input, Error, Env>(
|
|
4054
3999
|
self: Schedule<Output, Input, Error, Env>
|
|
4055
4000
|
) => Schedule<Output2, Input, Error | Error2, Env | Env2>
|
|
4056
4001
|
/**
|
|
@@ -4117,17 +4062,24 @@ export const map: {
|
|
|
4117
4062
|
*/
|
|
4118
4063
|
<Output, Input, Error, Env, Output2, Error2 = never, Env2 = never>(
|
|
4119
4064
|
self: Schedule<Output, Input, Error, Env>,
|
|
4120
|
-
f: (output: Output) => Effect<Output2, Error2, Env2>
|
|
4065
|
+
f: (output: Output) => Output2 | Effect<Output2, Error2, Env2>
|
|
4121
4066
|
): Schedule<Output2, Input, Error | Error2, Env | Env2>
|
|
4122
4067
|
} = dual(2, <Output, Input, Error, Env, Output2, Error2 = never, Env2 = never>(
|
|
4123
4068
|
self: Schedule<Output, Input, Error, Env>,
|
|
4124
|
-
f: (output: Output) => Effect<Output2, Error2, Env2>
|
|
4069
|
+
f: (output: Output) => Output2 | Effect<Output2, Error2, Env2>
|
|
4125
4070
|
): Schedule<Output2, Input, Error | Error2, Env | Env2> => {
|
|
4126
4071
|
const handle = Pull.matchEffect({
|
|
4127
|
-
onSuccess: ([output, duration]: [Output, Duration.Duration]) =>
|
|
4128
|
-
|
|
4072
|
+
onSuccess: ([output, duration]: [Output, Duration.Duration]) => {
|
|
4073
|
+
const result = f(output)
|
|
4074
|
+
if (!isEffect(result)) return effect.succeed([result, duration] as [Output2, Duration.Duration])
|
|
4075
|
+
return effect.map(result, (output) => [output, duration] as [Output2, Duration.Duration])
|
|
4076
|
+
},
|
|
4129
4077
|
onFailure: effect.failCause<Error>,
|
|
4130
|
-
onDone: (output: Output) =>
|
|
4078
|
+
onDone: (output: Output) => {
|
|
4079
|
+
const result = f(output)
|
|
4080
|
+
if (!isEffect(result)) return Cause.done(result as Output2)
|
|
4081
|
+
return effect.flatMap(result, Cause.done)
|
|
4082
|
+
}
|
|
4131
4083
|
})
|
|
4132
4084
|
return fromStep(effect.map(toStep(self), (step) => (now, input) => handle(step(now, input))))
|
|
4133
4085
|
})
|
|
@@ -4201,7 +4153,7 @@ export const modifyDelay: {
|
|
|
4201
4153
|
f: (
|
|
4202
4154
|
output: Output,
|
|
4203
4155
|
delay: Duration.Duration
|
|
4204
|
-
) => Effect<Duration.
|
|
4156
|
+
) => Effect<Duration.Input, Error2, Env2>
|
|
4205
4157
|
): <Input, Error, Env>(
|
|
4206
4158
|
self: Schedule<Output, Input, Error, Env>
|
|
4207
4159
|
) => Schedule<Output, Input, Error | Error2, Env | Env2>
|
|
@@ -4241,22 +4193,39 @@ export const modifyDelay: {
|
|
|
4241
4193
|
self: Schedule<Output, Input, Error, Env>,
|
|
4242
4194
|
f: (
|
|
4243
4195
|
output: Output,
|
|
4244
|
-
delay: Duration.
|
|
4245
|
-
) => Effect<Duration.
|
|
4196
|
+
delay: Duration.Input
|
|
4197
|
+
) => Effect<Duration.Input, Error2, Env2>
|
|
4246
4198
|
): Schedule<Output, Input, Error | Error2, Env | Env2>
|
|
4247
4199
|
} = dual(2, <Output, Input, Error, Env, Error2 = never, Env2 = never>(
|
|
4248
4200
|
self: Schedule<Output, Input, Error, Env>,
|
|
4249
4201
|
f: (
|
|
4250
4202
|
output: Output,
|
|
4251
|
-
delay: Duration.
|
|
4252
|
-
) => Effect<Duration.
|
|
4203
|
+
delay: Duration.Input
|
|
4204
|
+
) => Effect<Duration.Input, Error2, Env2>
|
|
4253
4205
|
): Schedule<Output, Input, Error | Error2, Env | Env2> =>
|
|
4254
4206
|
fromStep(effect.map(toStep(self), (step) => (now, input) =>
|
|
4255
4207
|
effect.flatMap(
|
|
4256
4208
|
step(now, input),
|
|
4257
|
-
([output, delay]) => effect.map(f(output, delay), (delay) => [output, Duration.
|
|
4209
|
+
([output, delay]) => effect.map(f(output, delay), (delay) => [output, Duration.fromInputUnsafe(delay)])
|
|
4258
4210
|
))))
|
|
4259
4211
|
|
|
4212
|
+
/**
|
|
4213
|
+
* Returns a new `Schedule` that randomly adjusts each recurrence delay.
|
|
4214
|
+
*
|
|
4215
|
+
* Delays are jittered between `80%` and `120%` of the original delay.
|
|
4216
|
+
*
|
|
4217
|
+
* @since 2.0.0
|
|
4218
|
+
* @category utilities
|
|
4219
|
+
*/
|
|
4220
|
+
export const jittered = <Output, Input, Error, Env>(
|
|
4221
|
+
self: Schedule<Output, Input, Error, Env>
|
|
4222
|
+
): Schedule<Output, Input, Error, Env> =>
|
|
4223
|
+
modifyDelay(self, (_, delay) =>
|
|
4224
|
+
effect.map(randomNext, (random) => {
|
|
4225
|
+
const millis = Duration.toMillis(Duration.fromInputUnsafe(delay))
|
|
4226
|
+
return Duration.millis(millis * 0.8 * (1 - random) + millis * 1.2 * random)
|
|
4227
|
+
}))
|
|
4228
|
+
|
|
4260
4229
|
/**
|
|
4261
4230
|
* Returns a new `Schedule` that outputs the inputs of the specified schedule.
|
|
4262
4231
|
*
|
|
@@ -4301,7 +4270,9 @@ export const passthrough = <Output, Input, Error, Env>(
|
|
|
4301
4270
|
*
|
|
4302
4271
|
* @example
|
|
4303
4272
|
* ```ts
|
|
4304
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
4273
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
4274
|
+
*
|
|
4275
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
4305
4276
|
*
|
|
4306
4277
|
* // Basic recurs - retry at most 3 times
|
|
4307
4278
|
* const maxThreeAttempts = Schedule.recurs(3)
|
|
@@ -4316,7 +4287,7 @@ export const passthrough = <Output, Input, Error, Env>(
|
|
|
4316
4287
|
* yield* Console.log(`Attempt ${attempt}`)
|
|
4317
4288
|
*
|
|
4318
4289
|
* if (attempt < 4) {
|
|
4319
|
-
* yield* Effect.fail(new
|
|
4290
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
4320
4291
|
* }
|
|
4321
4292
|
*
|
|
4322
4293
|
* return `Success on attempt ${attempt}`
|
|
@@ -4329,7 +4300,7 @@ export const passthrough = <Output, Input, Error, Env>(
|
|
|
4329
4300
|
*
|
|
4330
4301
|
* // Combining recurs with other schedules for sophisticated retry logic
|
|
4331
4302
|
* const complexRetry = Schedule.exponential("100 millis").pipe(
|
|
4332
|
-
* Schedule.
|
|
4303
|
+
* Schedule.both(Schedule.recurs(3)) // At most 3 attempts
|
|
4333
4304
|
* )
|
|
4334
4305
|
*
|
|
4335
4306
|
* // Repeat an effect exactly 10 times
|
|
@@ -4577,7 +4548,7 @@ export const reduce: {
|
|
|
4577
4548
|
*/
|
|
4578
4549
|
<State, Output, Error2 = never, Env2 = never>(
|
|
4579
4550
|
initial: LazyArg<State>,
|
|
4580
|
-
combine: (state: State, output: Output) => Effect<State, Error2, Env2>
|
|
4551
|
+
combine: (state: State, output: Output) => State | Effect<State, Error2, Env2>
|
|
4581
4552
|
): <Input, Error, Env>(
|
|
4582
4553
|
self: Schedule<Output, Input, Error, Env>
|
|
4583
4554
|
) => Schedule<State, Input, Error | Error2, Env | Env2>
|
|
@@ -4695,24 +4666,33 @@ export const reduce: {
|
|
|
4695
4666
|
<Output, Input, Error, Env, State, Error2 = never, Env2 = never>(
|
|
4696
4667
|
self: Schedule<Output, Input, Error, Env>,
|
|
4697
4668
|
initial: LazyArg<State>,
|
|
4698
|
-
combine: (state: State, output: Output) => Effect<State, Error2, Env2>
|
|
4669
|
+
combine: (state: State, output: Output) => State | Effect<State, Error2, Env2>
|
|
4699
4670
|
): Schedule<State, Input, Error | Error2, Env | Env2>
|
|
4700
4671
|
} = dual(3, <Output, Input, Error, Env, State, Error2 = never, Env2 = never>(
|
|
4701
4672
|
self: Schedule<Output, Input, Error, Env>,
|
|
4702
4673
|
initial: LazyArg<State>,
|
|
4703
|
-
combine: (state: State, output: Output) => Effect<State, Error2, Env2>
|
|
4674
|
+
combine: (state: State, output: Output) => State | Effect<State, Error2, Env2>
|
|
4704
4675
|
): Schedule<State, Input, Error | Error2, Env | Env2> =>
|
|
4705
4676
|
fromStep(effect.map(toStep(self), (step) => {
|
|
4706
4677
|
let state = initial()
|
|
4707
4678
|
return (now, input) =>
|
|
4708
4679
|
Pull.matchEffect(step(now, input), {
|
|
4709
|
-
onSuccess
|
|
4710
|
-
|
|
4680
|
+
onSuccess([output, delay]) {
|
|
4681
|
+
const next = combine(state, output)
|
|
4682
|
+
if (!isEffect(next)) {
|
|
4683
|
+
state = next
|
|
4684
|
+
return effect.succeed([next, delay] as [State, Duration.Duration])
|
|
4685
|
+
}
|
|
4686
|
+
return effect.map(next, (nextState) => {
|
|
4711
4687
|
state = nextState
|
|
4712
4688
|
return [nextState, delay]
|
|
4713
|
-
})
|
|
4689
|
+
})
|
|
4690
|
+
},
|
|
4714
4691
|
onFailure: effect.failCause,
|
|
4715
|
-
onDone
|
|
4692
|
+
onDone(output) {
|
|
4693
|
+
const next = combine(state, output)
|
|
4694
|
+
return isEffect(next) ? effect.flatMap(next, Cause.done) : Cause.done(next)
|
|
4695
|
+
}
|
|
4716
4696
|
})
|
|
4717
4697
|
})))
|
|
4718
4698
|
|
|
@@ -4747,7 +4727,7 @@ export const reduce: {
|
|
|
4747
4727
|
*
|
|
4748
4728
|
* // Simple spaced schedule with limited repetitions
|
|
4749
4729
|
* const limitedSpaced = Schedule.spaced("100 millis").pipe(
|
|
4750
|
-
* Schedule.
|
|
4730
|
+
* Schedule.both(Schedule.recurs(5)) // at most 5 times
|
|
4751
4731
|
* )
|
|
4752
4732
|
*
|
|
4753
4733
|
* const program = Effect.gen(function*() {
|
|
@@ -4765,8 +4745,8 @@ export const reduce: {
|
|
|
4765
4745
|
* @since 2.0.0
|
|
4766
4746
|
* @category constructors
|
|
4767
4747
|
*/
|
|
4768
|
-
export const spaced = (duration: Duration.
|
|
4769
|
-
const decoded = Duration.
|
|
4748
|
+
export const spaced = (duration: Duration.Input): Schedule<number> => {
|
|
4749
|
+
const decoded = Duration.fromInputUnsafe(duration)
|
|
4770
4750
|
return fromStepWithMetadata(effect.succeed((meta) => effect.succeed([meta.attempt - 1, decoded])))
|
|
4771
4751
|
}
|
|
4772
4752
|
|
|
@@ -4777,12 +4757,14 @@ export const spaced = (duration: Duration.DurationInput): Schedule<number> => {
|
|
|
4777
4757
|
*
|
|
4778
4758
|
* @example
|
|
4779
4759
|
* ```ts
|
|
4780
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
4760
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
4761
|
+
*
|
|
4762
|
+
* class RetryError extends Data.TaggedError("RetryError")<{ readonly message: string }> {}
|
|
4781
4763
|
*
|
|
4782
4764
|
* // Log retry errors for debugging
|
|
4783
4765
|
* const errorLoggingSchedule = Schedule.exponential("100 millis").pipe(
|
|
4784
4766
|
* Schedule.take(3),
|
|
4785
|
-
* Schedule.tapInput((error:
|
|
4767
|
+
* Schedule.tapInput((error: RetryError) =>
|
|
4786
4768
|
* Console.log(`Retry triggered by error: ${String(error)}`)
|
|
4787
4769
|
* )
|
|
4788
4770
|
* )
|
|
@@ -4794,7 +4776,7 @@ export const spaced = (duration: Duration.DurationInput): Schedule<number> => {
|
|
|
4794
4776
|
* Effect.gen(function*() {
|
|
4795
4777
|
* attempt++
|
|
4796
4778
|
* if (attempt < 4) {
|
|
4797
|
-
* yield* Effect.fail(new
|
|
4779
|
+
* return yield* Effect.fail(new RetryError({ message: `Network timeout on attempt ${attempt}` }))
|
|
4798
4780
|
* }
|
|
4799
4781
|
* return `Success on attempt ${attempt}`
|
|
4800
4782
|
* }),
|
|
@@ -4843,7 +4825,7 @@ export const spaced = (duration: Duration.DurationInput): Schedule<number> => {
|
|
|
4843
4825
|
* // Conditional alerting based on input
|
|
4844
4826
|
* const alertingSchedule = Schedule.exponential("200 millis").pipe(
|
|
4845
4827
|
* Schedule.take(6),
|
|
4846
|
-
* Schedule.tapInput((error:
|
|
4828
|
+
* Schedule.tapInput((error: RetryError) =>
|
|
4847
4829
|
* Effect.gen(function*() {
|
|
4848
4830
|
* if (String(error).includes("critical")) {
|
|
4849
4831
|
* yield* Console.log(`🚨 CRITICAL ERROR: ${String(error)}`)
|
|
@@ -4865,7 +4847,7 @@ export const spaced = (duration: Duration.DurationInput): Schedule<number> => {
|
|
|
4865
4847
|
* const errorType = isCritical
|
|
4866
4848
|
* ? "critical database failure"
|
|
4867
4849
|
* : "temporary network issue"
|
|
4868
|
-
* yield* Effect.fail(new
|
|
4850
|
+
* return yield* Effect.fail(new RetryError({ message: errorType }))
|
|
4869
4851
|
* }),
|
|
4870
4852
|
* alertingSchedule
|
|
4871
4853
|
* ).pipe(
|
|
@@ -4878,10 +4860,10 @@ export const spaced = (duration: Duration.DurationInput): Schedule<number> => {
|
|
|
4878
4860
|
* // Chain multiple input taps for different purposes
|
|
4879
4861
|
* const comprehensiveSchedule = Schedule.fibonacci("100 millis").pipe(
|
|
4880
4862
|
* Schedule.take(5),
|
|
4881
|
-
* Schedule.tapInput((error:
|
|
4882
|
-
* Console.log(`Error occurred: ${error.
|
|
4863
|
+
* Schedule.tapInput((error: RetryError) =>
|
|
4864
|
+
* Console.log(`Error occurred: ${error._tag}`)
|
|
4883
4865
|
* ),
|
|
4884
|
-
* Schedule.tapInput((error:
|
|
4866
|
+
* Schedule.tapInput((error: RetryError) =>
|
|
4885
4867
|
* String(error).length > 20
|
|
4886
4868
|
* ? Console.log("📝 Long error message detected")
|
|
4887
4869
|
* : Effect.void
|
|
@@ -4900,12 +4882,14 @@ export const tapInput: {
|
|
|
4900
4882
|
*
|
|
4901
4883
|
* @example
|
|
4902
4884
|
* ```ts
|
|
4903
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
4885
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
4886
|
+
*
|
|
4887
|
+
* class RetryError extends Data.TaggedError("RetryError")<{ readonly message: string }> {}
|
|
4904
4888
|
*
|
|
4905
4889
|
* // Log retry errors for debugging
|
|
4906
4890
|
* const errorLoggingSchedule = Schedule.exponential("100 millis").pipe(
|
|
4907
4891
|
* Schedule.take(3),
|
|
4908
|
-
* Schedule.tapInput((error:
|
|
4892
|
+
* Schedule.tapInput((error: RetryError) =>
|
|
4909
4893
|
* Console.log(`Retry triggered by error: ${String(error)}`)
|
|
4910
4894
|
* )
|
|
4911
4895
|
* )
|
|
@@ -4917,7 +4901,7 @@ export const tapInput: {
|
|
|
4917
4901
|
* Effect.gen(function*() {
|
|
4918
4902
|
* attempt++
|
|
4919
4903
|
* if (attempt < 4) {
|
|
4920
|
-
* yield* Effect.fail(new
|
|
4904
|
+
* return yield* Effect.fail(new RetryError({ message: `Network timeout on attempt ${attempt}` }))
|
|
4921
4905
|
* }
|
|
4922
4906
|
* return `Success on attempt ${attempt}`
|
|
4923
4907
|
* }),
|
|
@@ -4966,7 +4950,7 @@ export const tapInput: {
|
|
|
4966
4950
|
* // Conditional alerting based on input
|
|
4967
4951
|
* const alertingSchedule = Schedule.exponential("200 millis").pipe(
|
|
4968
4952
|
* Schedule.take(6),
|
|
4969
|
-
* Schedule.tapInput((error:
|
|
4953
|
+
* Schedule.tapInput((error: RetryError) =>
|
|
4970
4954
|
* Effect.gen(function*() {
|
|
4971
4955
|
* if (String(error).includes("critical")) {
|
|
4972
4956
|
* yield* Console.log(`🚨 CRITICAL ERROR: ${String(error)}`)
|
|
@@ -4988,7 +4972,7 @@ export const tapInput: {
|
|
|
4988
4972
|
* const errorType = isCritical
|
|
4989
4973
|
* ? "critical database failure"
|
|
4990
4974
|
* : "temporary network issue"
|
|
4991
|
-
* yield* Effect.fail(new
|
|
4975
|
+
* return yield* Effect.fail(new RetryError({ message: errorType }))
|
|
4992
4976
|
* }),
|
|
4993
4977
|
* alertingSchedule
|
|
4994
4978
|
* ).pipe(
|
|
@@ -5001,10 +4985,10 @@ export const tapInput: {
|
|
|
5001
4985
|
* // Chain multiple input taps for different purposes
|
|
5002
4986
|
* const comprehensiveSchedule = Schedule.fibonacci("100 millis").pipe(
|
|
5003
4987
|
* Schedule.take(5),
|
|
5004
|
-
* Schedule.tapInput((error:
|
|
5005
|
-
* Console.log(`Error occurred: ${error.
|
|
4988
|
+
* Schedule.tapInput((error: RetryError) =>
|
|
4989
|
+
* Console.log(`Error occurred: ${error._tag}`)
|
|
5006
4990
|
* ),
|
|
5007
|
-
* Schedule.tapInput((error:
|
|
4991
|
+
* Schedule.tapInput((error: RetryError) =>
|
|
5008
4992
|
* String(error).length > 20
|
|
5009
4993
|
* ? Console.log("📝 Long error message detected")
|
|
5010
4994
|
* : Effect.void
|
|
@@ -5025,12 +5009,14 @@ export const tapInput: {
|
|
|
5025
5009
|
*
|
|
5026
5010
|
* @example
|
|
5027
5011
|
* ```ts
|
|
5028
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
5012
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
5013
|
+
*
|
|
5014
|
+
* class RetryError extends Data.TaggedError("RetryError")<{ readonly message: string }> {}
|
|
5029
5015
|
*
|
|
5030
5016
|
* // Log retry errors for debugging
|
|
5031
5017
|
* const errorLoggingSchedule = Schedule.exponential("100 millis").pipe(
|
|
5032
5018
|
* Schedule.take(3),
|
|
5033
|
-
* Schedule.tapInput((error:
|
|
5019
|
+
* Schedule.tapInput((error: RetryError) =>
|
|
5034
5020
|
* Console.log(`Retry triggered by error: ${String(error)}`)
|
|
5035
5021
|
* )
|
|
5036
5022
|
* )
|
|
@@ -5042,7 +5028,7 @@ export const tapInput: {
|
|
|
5042
5028
|
* Effect.gen(function*() {
|
|
5043
5029
|
* attempt++
|
|
5044
5030
|
* if (attempt < 4) {
|
|
5045
|
-
* yield* Effect.fail(new
|
|
5031
|
+
* return yield* Effect.fail(new RetryError({ message: `Network timeout on attempt ${attempt}` }))
|
|
5046
5032
|
* }
|
|
5047
5033
|
* return `Success on attempt ${attempt}`
|
|
5048
5034
|
* }),
|
|
@@ -5091,7 +5077,7 @@ export const tapInput: {
|
|
|
5091
5077
|
* // Conditional alerting based on input
|
|
5092
5078
|
* const alertingSchedule = Schedule.exponential("200 millis").pipe(
|
|
5093
5079
|
* Schedule.take(6),
|
|
5094
|
-
* Schedule.tapInput((error:
|
|
5080
|
+
* Schedule.tapInput((error: RetryError) =>
|
|
5095
5081
|
* Effect.gen(function*() {
|
|
5096
5082
|
* if (String(error).includes("critical")) {
|
|
5097
5083
|
* yield* Console.log(`🚨 CRITICAL ERROR: ${String(error)}`)
|
|
@@ -5113,7 +5099,7 @@ export const tapInput: {
|
|
|
5113
5099
|
* const errorType = isCritical
|
|
5114
5100
|
* ? "critical database failure"
|
|
5115
5101
|
* : "temporary network issue"
|
|
5116
|
-
* yield* Effect.fail(new
|
|
5102
|
+
* return yield* Effect.fail(new RetryError({ message: errorType }))
|
|
5117
5103
|
* }),
|
|
5118
5104
|
* alertingSchedule
|
|
5119
5105
|
* ).pipe(
|
|
@@ -5126,10 +5112,10 @@ export const tapInput: {
|
|
|
5126
5112
|
* // Chain multiple input taps for different purposes
|
|
5127
5113
|
* const comprehensiveSchedule = Schedule.fibonacci("100 millis").pipe(
|
|
5128
5114
|
* Schedule.take(5),
|
|
5129
|
-
* Schedule.tapInput((error:
|
|
5130
|
-
* Console.log(`Error occurred: ${error.
|
|
5115
|
+
* Schedule.tapInput((error: RetryError) =>
|
|
5116
|
+
* Console.log(`Error occurred: ${error._tag}`)
|
|
5131
5117
|
* ),
|
|
5132
|
-
* Schedule.tapInput((error:
|
|
5118
|
+
* Schedule.tapInput((error: RetryError) =>
|
|
5133
5119
|
* String(error).length > 20
|
|
5134
5120
|
* ? Console.log("📝 Long error message detected")
|
|
5135
5121
|
* : Effect.void
|
|
@@ -5160,7 +5146,9 @@ export const tapInput: {
|
|
|
5160
5146
|
*
|
|
5161
5147
|
* @example
|
|
5162
5148
|
* ```ts
|
|
5163
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
5149
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
5150
|
+
*
|
|
5151
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
5164
5152
|
*
|
|
5165
5153
|
* // Log schedule outputs for debugging/monitoring
|
|
5166
5154
|
* const monitoredSchedule = Schedule.exponential("100 millis").pipe(
|
|
@@ -5175,7 +5163,7 @@ export const tapInput: {
|
|
|
5175
5163
|
* Effect.gen(function*() {
|
|
5176
5164
|
* attempt++
|
|
5177
5165
|
* if (attempt < 4) {
|
|
5178
|
-
* yield* Effect.fail(new
|
|
5166
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
5179
5167
|
* }
|
|
5180
5168
|
* return `Success on attempt ${attempt}`
|
|
5181
5169
|
* }),
|
|
@@ -5244,7 +5232,9 @@ export const tapOutput: {
|
|
|
5244
5232
|
*
|
|
5245
5233
|
* @example
|
|
5246
5234
|
* ```ts
|
|
5247
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
5235
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
5236
|
+
*
|
|
5237
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
5248
5238
|
*
|
|
5249
5239
|
* // Log schedule outputs for debugging/monitoring
|
|
5250
5240
|
* const monitoredSchedule = Schedule.exponential("100 millis").pipe(
|
|
@@ -5259,7 +5249,7 @@ export const tapOutput: {
|
|
|
5259
5249
|
* Effect.gen(function*() {
|
|
5260
5250
|
* attempt++
|
|
5261
5251
|
* if (attempt < 4) {
|
|
5262
|
-
* yield* Effect.fail(new
|
|
5252
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
5263
5253
|
* }
|
|
5264
5254
|
* return `Success on attempt ${attempt}`
|
|
5265
5255
|
* }),
|
|
@@ -5330,7 +5320,9 @@ export const tapOutput: {
|
|
|
5330
5320
|
*
|
|
5331
5321
|
* @example
|
|
5332
5322
|
* ```ts
|
|
5333
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
5323
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
5324
|
+
*
|
|
5325
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
5334
5326
|
*
|
|
5335
5327
|
* // Log schedule outputs for debugging/monitoring
|
|
5336
5328
|
* const monitoredSchedule = Schedule.exponential("100 millis").pipe(
|
|
@@ -5345,7 +5337,7 @@ export const tapOutput: {
|
|
|
5345
5337
|
* Effect.gen(function*() {
|
|
5346
5338
|
* attempt++
|
|
5347
5339
|
* if (attempt < 4) {
|
|
5348
|
-
* yield* Effect.fail(new
|
|
5340
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
5349
5341
|
* }
|
|
5350
5342
|
* return `Success on attempt ${attempt}`
|
|
5351
5343
|
* }),
|
|
@@ -5426,7 +5418,9 @@ export const tapOutput: {
|
|
|
5426
5418
|
*
|
|
5427
5419
|
* @example
|
|
5428
5420
|
* ```ts
|
|
5429
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
5421
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
5422
|
+
*
|
|
5423
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
5430
5424
|
*
|
|
5431
5425
|
* // Limit an infinite schedule to run only 5 times
|
|
5432
5426
|
* const limitedHeartbeat = Schedule.spaced("1 second").pipe(
|
|
@@ -5459,7 +5453,7 @@ export const tapOutput: {
|
|
|
5459
5453
|
* yield* Console.log(`Attempt ${attempt}`)
|
|
5460
5454
|
*
|
|
5461
5455
|
* if (attempt < 5) { // Will fail more than 3 times
|
|
5462
|
-
* yield* Effect.fail(new
|
|
5456
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
5463
5457
|
* }
|
|
5464
5458
|
*
|
|
5465
5459
|
* return `Success on attempt ${attempt}`
|
|
@@ -5505,7 +5499,9 @@ export const take: {
|
|
|
5505
5499
|
*
|
|
5506
5500
|
* @example
|
|
5507
5501
|
* ```ts
|
|
5508
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
5502
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
5503
|
+
*
|
|
5504
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
5509
5505
|
*
|
|
5510
5506
|
* // Limit an infinite schedule to run only 5 times
|
|
5511
5507
|
* const limitedHeartbeat = Schedule.spaced("1 second").pipe(
|
|
@@ -5538,7 +5534,7 @@ export const take: {
|
|
|
5538
5534
|
* yield* Console.log(`Attempt ${attempt}`)
|
|
5539
5535
|
*
|
|
5540
5536
|
* if (attempt < 5) { // Will fail more than 3 times
|
|
5541
|
-
* yield* Effect.fail(new
|
|
5537
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
5542
5538
|
* }
|
|
5543
5539
|
*
|
|
5544
5540
|
* return `Success on attempt ${attempt}`
|
|
@@ -5586,7 +5582,9 @@ export const take: {
|
|
|
5586
5582
|
*
|
|
5587
5583
|
* @example
|
|
5588
5584
|
* ```ts
|
|
5589
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
5585
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
5586
|
+
*
|
|
5587
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
5590
5588
|
*
|
|
5591
5589
|
* // Limit an infinite schedule to run only 5 times
|
|
5592
5590
|
* const limitedHeartbeat = Schedule.spaced("1 second").pipe(
|
|
@@ -5619,7 +5617,7 @@ export const take: {
|
|
|
5619
5617
|
* yield* Console.log(`Attempt ${attempt}`)
|
|
5620
5618
|
*
|
|
5621
5619
|
* if (attempt < 5) { // Will fail more than 3 times
|
|
5622
|
-
* yield* Effect.fail(new
|
|
5620
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
5623
5621
|
* }
|
|
5624
5622
|
*
|
|
5625
5623
|
* return `Success on attempt ${attempt}`
|
|
@@ -5779,7 +5777,7 @@ const while_: {
|
|
|
5779
5777
|
<Input, Output, Error2 = never, Env2 = never>(
|
|
5780
5778
|
predicate: (
|
|
5781
5779
|
metadata: Metadata<Output, Input>
|
|
5782
|
-
) => Effect<boolean, Error2, Env2>
|
|
5780
|
+
) => boolean | Effect<boolean, Error2, Env2>
|
|
5783
5781
|
): <Error, Env>(
|
|
5784
5782
|
self: Schedule<Output, Input, Error, Env>
|
|
5785
5783
|
) => Schedule<Output, Input, Error | Error2, Env | Env2>
|
|
@@ -5787,21 +5785,22 @@ const while_: {
|
|
|
5787
5785
|
self: Schedule<Output, Input, Error, Env>,
|
|
5788
5786
|
predicate: (
|
|
5789
5787
|
metadata: Metadata<Output, Input>
|
|
5790
|
-
) => Effect<boolean, Error2, Env2>
|
|
5788
|
+
) => boolean | Effect<boolean, Error2, Env2>
|
|
5791
5789
|
): Schedule<Output, Input, Error | Error2, Env | Env2>
|
|
5792
5790
|
} = dual(2, <Output, Input, Error, Env, Error2 = never, Env2 = never>(
|
|
5793
5791
|
self: Schedule<Output, Input, Error, Env>,
|
|
5794
5792
|
predicate: (
|
|
5795
5793
|
metadata: Metadata<Output, Input>
|
|
5796
|
-
) => Effect<boolean, Error2, Env2>
|
|
5794
|
+
) => boolean | Effect<boolean, Error2, Env2>
|
|
5797
5795
|
): Schedule<Output, Input, Error | Error2, Env | Env2> =>
|
|
5798
5796
|
fromStep(effect.map(toStep(self), (step) => {
|
|
5799
5797
|
const meta = metadataFn()
|
|
5800
5798
|
return (now, input) =>
|
|
5801
5799
|
effect.flatMap(step(now, input), (result) => {
|
|
5802
5800
|
const [output, duration] = result
|
|
5801
|
+
const eff = predicate({ ...meta(now, input), output, duration })
|
|
5803
5802
|
return effect.flatMap(
|
|
5804
|
-
|
|
5803
|
+
isEffect(eff) ? eff : effect.succeed(eff),
|
|
5805
5804
|
(check) => (check ? effect.succeed(result) : Cause.done(output))
|
|
5806
5805
|
)
|
|
5807
5806
|
})
|
|
@@ -5856,8 +5855,8 @@ export {
|
|
|
5856
5855
|
* @since 2.0.0
|
|
5857
5856
|
* @category constructors
|
|
5858
5857
|
*/
|
|
5859
|
-
export const windowed = (interval: Duration.
|
|
5860
|
-
const window = Duration.toMillis(Duration.
|
|
5858
|
+
export const windowed = (interval: Duration.Input): Schedule<number> => {
|
|
5859
|
+
const window = Duration.toMillis(Duration.fromInputUnsafe(interval))
|
|
5861
5860
|
return fromStepWithMetadata(effect.succeed((meta) =>
|
|
5862
5861
|
effect.sync(() => [
|
|
5863
5862
|
meta.attempt - 1,
|
|
@@ -5947,6 +5946,16 @@ export const satisfiesInputType = <T>() =>
|
|
|
5947
5946
|
self: Schedule<Output, Input, Error, Env>
|
|
5948
5947
|
): Schedule<Output, Input, Error, Env> => self
|
|
5949
5948
|
|
|
5949
|
+
/**
|
|
5950
|
+
* Sets the input type of the provided schedule to a specified type, without
|
|
5951
|
+
* altering the schedule's behavior.
|
|
5952
|
+
*
|
|
5953
|
+
* @since 2.0.0
|
|
5954
|
+
* @category ensuring types
|
|
5955
|
+
*/
|
|
5956
|
+
export const setInputType =
|
|
5957
|
+
<T>() => <Output, Error, Env>(self: Schedule<Output, T, Error, Env>): Schedule<Output, T, Error, Env> => self
|
|
5958
|
+
|
|
5950
5959
|
/**
|
|
5951
5960
|
* Ensures that the provided schedule respects a specified output type.
|
|
5952
5961
|
*
|