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/dist/Schema.d.ts
CHANGED
|
@@ -1,9 +1,94 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* Define data shapes, validate unknown input, and transform values between formats.
|
|
3
|
+
*
|
|
4
|
+
* ## Mental model
|
|
5
|
+
*
|
|
6
|
+
* - **Schema** — a description of a data shape. Every schema carries a decoded
|
|
7
|
+
* *Type* (the value you work with) and an *Encoded* representation (the
|
|
8
|
+
* serialized form, e.g. JSON).
|
|
9
|
+
* - **Decoding** — turning unknown external data (API responses, form
|
|
10
|
+
* submissions, config files) into typed, validated values.
|
|
11
|
+
* - **Encoding** — turning typed values back into a serializable format.
|
|
12
|
+
* - **Codec** — a schema that tracks both Type and Encoded, so it can decode
|
|
13
|
+
* *and* encode. Most concrete schemas are Codecs.
|
|
14
|
+
* - **Check / Filter** — a constraint attached to a schema (e.g. `isMinLength`,
|
|
15
|
+
* `isGreaterThan`). Attach them with `.check(...)`.
|
|
16
|
+
* - **Transformation** — a pair of functions (decode + encode) that convert
|
|
17
|
+
* values between two schemas. Created with {@link decodeTo} / {@link encodeTo}.
|
|
18
|
+
* - **Annotation** — metadata attached to a schema (title, description, custom
|
|
19
|
+
* keys). Attach with `.annotate(...)`.
|
|
20
|
+
*
|
|
21
|
+
* ## Common tasks
|
|
22
|
+
*
|
|
23
|
+
* - Define a struct: {@link Struct}
|
|
24
|
+
* - Define a union: {@link Union}, {@link TaggedUnion}, {@link Literals}
|
|
25
|
+
* - Define an array: {@link ArraySchema}, {@link NonEmptyArray}
|
|
26
|
+
* - Define a record: {@link Record}
|
|
27
|
+
* - Define a tuple: {@link Tuple}, {@link TupleWithRest}
|
|
28
|
+
* - Validate unknown data synchronously: {@link decodeUnknownSync}
|
|
29
|
+
* - Validate unknown data (Effect): {@link decodeUnknownEffect}
|
|
30
|
+
* - Encode a value: {@link encodeUnknownSync}, {@link encodeUnknownEffect}
|
|
31
|
+
* - Type guard: {@link is}
|
|
32
|
+
* - Assertion: {@link asserts}
|
|
33
|
+
* - Add constraints: `.check(...)` with filters like {@link isMinLength},
|
|
34
|
+
* {@link isGreaterThan}, {@link isPattern}, {@link isUUID}
|
|
35
|
+
* - Transform between schemas: {@link decodeTo}, {@link encodeTo}
|
|
36
|
+
* - Add a default for missing keys: {@link withDecodingDefault}, {@link withDecodingDefaultKey}
|
|
37
|
+
* - Create branded types: {@link brand}
|
|
38
|
+
* - Define classes with validation: {@link Class}, {@link TaggedClass}
|
|
39
|
+
* - Define error classes: {@link ErrorClass}, {@link TaggedErrorClass}
|
|
40
|
+
* - Generate JSON Schema: {@link toJsonSchemaDocument}
|
|
41
|
+
* - Generate test data: {@link toArbitrary}
|
|
42
|
+
* - Derive equivalence: {@link toEquivalence}
|
|
43
|
+
*
|
|
44
|
+
* ## Gotchas
|
|
45
|
+
*
|
|
46
|
+
* - `Schema.optional` creates `T | undefined` (key can be missing *or*
|
|
47
|
+
* `undefined`). Use `Schema.optionalKey` for exact optional properties.
|
|
48
|
+
* - `decodeTo` is curried: use `from.pipe(Schema.decodeTo(to, ...))`.
|
|
49
|
+
* - `decodeUnknownSync` throws on failure. Use `decodeUnknownExit` or
|
|
50
|
+
* `decodeUnknownOption` for non-throwing alternatives.
|
|
51
|
+
* - Filters do not change the TypeScript type. Use {@link refine} or
|
|
52
|
+
* {@link brand} to narrow the type.
|
|
53
|
+
* - Recursive schemas require {@link suspend} to avoid infinite loops.
|
|
54
|
+
*
|
|
55
|
+
* ## Quickstart
|
|
56
|
+
*
|
|
57
|
+
* **Example** (Validate a user object)
|
|
58
|
+
*
|
|
59
|
+
* ```ts
|
|
60
|
+
* import { Schema } from "effect"
|
|
61
|
+
*
|
|
62
|
+
* const User = Schema.Struct({
|
|
63
|
+
* name: Schema.String.check(Schema.isMinLength(1)),
|
|
64
|
+
* age: Schema.Number.check(Schema.isGreaterThanOrEqualTo(0)),
|
|
65
|
+
* email: Schema.optionalKey(Schema.String)
|
|
66
|
+
* })
|
|
67
|
+
*
|
|
68
|
+
* // Decode unknown input — throws on failure
|
|
69
|
+
* const user = Schema.decodeUnknownSync(User)({
|
|
70
|
+
* name: "Alice",
|
|
71
|
+
* age: 30
|
|
72
|
+
* })
|
|
73
|
+
*
|
|
74
|
+
* console.log(user)
|
|
75
|
+
* // { name: "Alice", age: 30 }
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* @see {@link Schema} — type-level view tracking only the decoded Type
|
|
79
|
+
* @see {@link Codec} — type-level view tracking both Type and Encoded
|
|
80
|
+
* @see {@link Struct} — define object shapes
|
|
81
|
+
* @see {@link decodeUnknownSync} — synchronous validation
|
|
82
|
+
* @see {@link decodeTo} — schema transformations
|
|
83
|
+
*
|
|
2
84
|
* @since 4.0.0
|
|
3
85
|
*/
|
|
86
|
+
/** @effect-diagnostics schemaStructWithTag:skip-file */
|
|
4
87
|
import type { StandardJSONSchemaV1, StandardSchemaV1 } from "@standard-schema/spec";
|
|
88
|
+
import * as BigDecimal_ from "./BigDecimal.ts";
|
|
5
89
|
import type * as Brand from "./Brand.ts";
|
|
6
90
|
import * as Cause_ from "./Cause.ts";
|
|
91
|
+
import * as Chunk_ from "./Chunk.ts";
|
|
7
92
|
import type * as Combiner from "./Combiner.ts";
|
|
8
93
|
import * as DateTime from "./DateTime.ts";
|
|
9
94
|
import type { Differ } from "./Differ.ts";
|
|
@@ -12,6 +97,8 @@ import * as Effect from "./Effect.ts";
|
|
|
12
97
|
import * as Equivalence from "./Equivalence.ts";
|
|
13
98
|
import * as Exit_ from "./Exit.ts";
|
|
14
99
|
import type { Formatter } from "./Formatter.ts";
|
|
100
|
+
import * as HashMap_ from "./HashMap.ts";
|
|
101
|
+
import * as HashSet_ from "./HashSet.ts";
|
|
15
102
|
import * as JsonPatch from "./JsonPatch.ts";
|
|
16
103
|
import * as JsonSchema from "./JsonSchema.ts";
|
|
17
104
|
import * as Optic_ from "./Optic.ts";
|
|
@@ -29,28 +116,42 @@ import type { Assign, Lambda, Mutable, Simplify } from "./Struct.ts";
|
|
|
29
116
|
import * as Struct_ from "./Struct.ts";
|
|
30
117
|
import * as FastCheck from "./testing/FastCheck.ts";
|
|
31
118
|
import type { UnionToIntersection } from "./Types.ts";
|
|
119
|
+
import type { Unify } from "./Unify.ts";
|
|
32
120
|
declare const TypeId = "~effect/Schema/Schema";
|
|
33
121
|
/**
|
|
34
|
-
*
|
|
122
|
+
* Whether a schema field is required or optional within a struct.
|
|
123
|
+
*
|
|
124
|
+
* @see {@link optionalKey} — mark a struct field as optional
|
|
125
|
+
* @see {@link optional} — mark a struct field as optional with `| undefined`
|
|
35
126
|
*
|
|
36
127
|
* @since 4.0.0
|
|
37
128
|
*/
|
|
38
129
|
export type Optionality = "required" | "optional";
|
|
39
130
|
/**
|
|
40
|
-
*
|
|
131
|
+
* Whether a schema field is readonly or mutable within a struct.
|
|
132
|
+
*
|
|
133
|
+
* @see {@link mutableKey} — mark a struct field as mutable
|
|
41
134
|
*
|
|
42
135
|
* @since 4.0.0
|
|
43
136
|
*/
|
|
44
137
|
export type Mutability = "readonly" | "mutable";
|
|
45
138
|
/**
|
|
46
|
-
*
|
|
139
|
+
* Whether a schema field has a constructor default value.
|
|
140
|
+
*
|
|
141
|
+
* @see {@link withConstructorDefault} — add a default to a schema field
|
|
142
|
+
* @see {@link tag} — creates a literal field with a constructor default
|
|
47
143
|
*
|
|
48
144
|
* @since 4.0.0
|
|
49
145
|
*/
|
|
50
146
|
export type ConstructorDefault = "no-default" | "with-default";
|
|
51
147
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
148
|
+
* Options for `makeUnsafe` and Class constructors.
|
|
149
|
+
*
|
|
150
|
+
* When to use:
|
|
151
|
+
* - Pass `disableChecks: true` to skip validation when you trust the data.
|
|
152
|
+
* - Pass `parseOptions` to control error reporting behavior.
|
|
153
|
+
*
|
|
154
|
+
* @see {@link Bottom.makeUnsafe}
|
|
54
155
|
*
|
|
55
156
|
* @since 4.0.0
|
|
56
157
|
*/
|
|
@@ -62,18 +163,22 @@ export interface MakeOptions {
|
|
|
62
163
|
/**
|
|
63
164
|
* Whether to disable validation for the schema.
|
|
64
165
|
*/
|
|
65
|
-
readonly
|
|
166
|
+
readonly disableChecks?: boolean | undefined;
|
|
66
167
|
}
|
|
67
168
|
/**
|
|
68
|
-
* The base interface for all schemas
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
169
|
+
* The fully-parameterized base interface for all schemas. Exposes all 14 type
|
|
170
|
+
* parameters controlling type inference, mutability, optionality, services,
|
|
171
|
+
* and transformation behavior.
|
|
172
|
+
*
|
|
173
|
+
* When to use:
|
|
174
|
+
* - You are writing advanced generic schema utilities or performing schema
|
|
175
|
+
* introspection.
|
|
176
|
+
* - In user code, prefer {@link Schema}, {@link Codec}, {@link Decoder}, or
|
|
177
|
+
* {@link Encoder} instead.
|
|
72
178
|
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* transformation characteristics.
|
|
179
|
+
* @see {@link Top} — the existential "any schema" type (erased type params)
|
|
180
|
+
* @see {@link Schema} — tracks only the decoded Type
|
|
181
|
+
* @see {@link Codec} — tracks Type + Encoded
|
|
77
182
|
*
|
|
78
183
|
* @since 4.0.0
|
|
79
184
|
*/
|
|
@@ -103,71 +208,202 @@ export interface Bottom<out T, out E, out RD, out RE, out Ast extends AST.AST, o
|
|
|
103
208
|
* @throws {Error} The issue is contained in the error cause.
|
|
104
209
|
*/
|
|
105
210
|
makeUnsafe(input: this["~type.make.in"], options?: MakeOptions): this["Type"];
|
|
211
|
+
makeOption(input: this["~type.make.in"], options?: MakeOptions): Option_.Option<this["Type"]>;
|
|
106
212
|
}
|
|
107
213
|
/**
|
|
214
|
+
* The schema type returned by {@link declareConstructor}, tracking the decoded
|
|
215
|
+
* type `T`, the encoded type `E`, and the list of type-parameter schemas
|
|
216
|
+
* `TypeParameters`.
|
|
217
|
+
*
|
|
218
|
+
* @category Constructors
|
|
108
219
|
* @since 4.0.0
|
|
109
220
|
*/
|
|
110
221
|
export interface declareConstructor<T, E, TypeParameters extends ReadonlyArray<Top>, Iso = T> extends Bottom<T, E, TypeParameters[number]["DecodingServices"], TypeParameters[number]["EncodingServices"], AST.Declaration, declareConstructor<T, E, TypeParameters, Iso>, T, Iso, TypeParameters> {
|
|
111
222
|
readonly "~rebuild.out": this;
|
|
112
223
|
}
|
|
113
224
|
/**
|
|
114
|
-
*
|
|
225
|
+
* Creates a schema for a **parametric** type (a generic container such as
|
|
226
|
+
* `Array<A>`, `Option<A>`, etc.) by accepting a list of type-parameter schemas
|
|
227
|
+
* and a decoder factory.
|
|
228
|
+
*
|
|
229
|
+
* The outer call `declareConstructor<T, E, Iso>()` fixes the decoded type `T`,
|
|
230
|
+
* the encoded type `E`, and the optional iso type. The inner call receives:
|
|
231
|
+
* - `typeParameters` — the concrete schemas for each type variable
|
|
232
|
+
* - `run` — a factory that, given resolved codecs for each type parameter,
|
|
233
|
+
* returns a parsing function `(u, ast, options) => Effect<T, Issue>`
|
|
234
|
+
* - `annotations` — optional metadata
|
|
235
|
+
*
|
|
236
|
+
* @see {@link declare} for creating schemas for non-parametric types.
|
|
237
|
+
*
|
|
238
|
+
* **Example** (Schema for a parametric `Box<A>` type)
|
|
239
|
+
*
|
|
240
|
+
* ```ts
|
|
241
|
+
* import { Effect, Schema } from "effect"
|
|
242
|
+
* import * as SchemaParser from "effect/SchemaParser"
|
|
243
|
+
* import * as Issue from "effect/SchemaIssue"
|
|
244
|
+
* import * as Option from "effect/Option"
|
|
245
|
+
*
|
|
246
|
+
* interface Box<A> {
|
|
247
|
+
* readonly value: A
|
|
248
|
+
* }
|
|
249
|
+
*
|
|
250
|
+
* const isBox = (u: unknown): u is Box<unknown> =>
|
|
251
|
+
* typeof u === "object" && u !== null && "value" in u
|
|
252
|
+
*
|
|
253
|
+
* const Box = <A extends Schema.Top>(item: A) =>
|
|
254
|
+
* Schema.declareConstructor<Box<A["Type"]>, Box<A["Encoded"]>>()(
|
|
255
|
+
* [item],
|
|
256
|
+
* ([itemCodec]) =>
|
|
257
|
+
* (u, ast, options) => {
|
|
258
|
+
* if (!isBox(u)) {
|
|
259
|
+
* return Effect.fail(new Issue.InvalidType(ast, Option.some(u)))
|
|
260
|
+
* }
|
|
261
|
+
* return Effect.map(
|
|
262
|
+
* SchemaParser.decodeUnknownEffect(itemCodec)(u.value, options),
|
|
263
|
+
* (value) => ({ value })
|
|
264
|
+
* )
|
|
265
|
+
* }
|
|
266
|
+
* )
|
|
115
267
|
*
|
|
116
|
-
*
|
|
268
|
+
* const schema = Box(Schema.Number)
|
|
269
|
+
* ```
|
|
117
270
|
*
|
|
118
271
|
* @category Constructors
|
|
119
272
|
* @since 4.0.0
|
|
120
273
|
*/
|
|
121
274
|
export declare function declareConstructor<T, E = T, Iso = T>(): <const TypeParameters extends ReadonlyArray<Top>>(typeParameters: TypeParameters, run: (typeParameters: { readonly [K in keyof TypeParameters]: Codec<TypeParameters[K]["Type"], TypeParameters[K]["Encoded"]>; }) => (u: unknown, self: AST.Declaration, options: AST.ParseOptions) => Effect.Effect<T, Issue.Issue>, annotations?: Annotations.Declaration<T, TypeParameters>) => declareConstructor<T, E, TypeParameters, Iso>;
|
|
122
275
|
/**
|
|
276
|
+
* The schema type returned by {@link declare}, representing a non-parametric
|
|
277
|
+
* opaque type `T` with no type parameters.
|
|
278
|
+
*
|
|
123
279
|
* @category Constructors
|
|
124
280
|
* @since 4.0.0
|
|
125
281
|
*/
|
|
126
282
|
export interface declare<T, Iso = T> extends declareConstructor<T, T, readonly [], Iso> {
|
|
127
283
|
}
|
|
128
284
|
/**
|
|
129
|
-
*
|
|
285
|
+
* Creates a schema for a **non-parametric** opaque type using a type-guard
|
|
286
|
+
* function. The schema accepts any unknown value and succeeds when `is` returns
|
|
287
|
+
* `true`, failing with an `InvalidType` issue otherwise.
|
|
288
|
+
*
|
|
289
|
+
* Use this when the type has no type parameters. For parametric types such as
|
|
290
|
+
* `Option<A>` or `Array<A>`, use {@link declareConstructor} instead.
|
|
291
|
+
*
|
|
292
|
+
* **Example** (Schema for a custom `UserId` branded type)
|
|
293
|
+
*
|
|
294
|
+
* ```ts
|
|
295
|
+
* import { Schema } from "effect"
|
|
296
|
+
*
|
|
297
|
+
* type UserId = string & { readonly _tag: "UserId" }
|
|
298
|
+
*
|
|
299
|
+
* const isUserId = (u: unknown): u is UserId =>
|
|
300
|
+
* typeof u === "string" && u.startsWith("user_")
|
|
301
|
+
*
|
|
302
|
+
* const UserId = Schema.declare<UserId>(isUserId, {
|
|
303
|
+
* title: "UserId",
|
|
304
|
+
* description: "A user identifier starting with 'user_'"
|
|
305
|
+
* })
|
|
306
|
+
* ```
|
|
130
307
|
*
|
|
131
308
|
* @see {@link declareConstructor} for creating schemas for parametric types.
|
|
132
309
|
*
|
|
310
|
+
* @category Constructors
|
|
133
311
|
* @since 4.0.0
|
|
134
312
|
*/
|
|
135
313
|
export declare function declare<T, Iso = T>(is: (u: unknown) => u is T, annotations?: Annotations.Declaration<T> | undefined): declare<T, Iso>;
|
|
136
314
|
/**
|
|
137
|
-
*
|
|
138
|
-
* parameters.
|
|
315
|
+
* Widens a schema's type to the fully-parameterized {@link Bottom} interface,
|
|
316
|
+
* making all 14 type parameters visible to TypeScript.
|
|
317
|
+
*
|
|
318
|
+
* Normally, concrete schema interfaces (e.g. `Schema<string>`) hide most type
|
|
319
|
+
* parameters. `revealBottom` is useful when writing generic utilities that need
|
|
320
|
+
* to inspect or propagate the complete set of type parameters.
|
|
321
|
+
*
|
|
322
|
+
* **Example** (Inspecting all type parameters of a schema)
|
|
323
|
+
*
|
|
324
|
+
* ```ts
|
|
325
|
+
* import { Schema } from "effect"
|
|
326
|
+
*
|
|
327
|
+
* const schema = Schema.String
|
|
328
|
+
*
|
|
329
|
+
* // Widen to Bottom to access all 14 type parameters
|
|
330
|
+
* const bottom = Schema.revealBottom(schema)
|
|
331
|
+
*
|
|
332
|
+
* // `bottom` now exposes Type, Encoded, DecodingServices, EncodingServices,
|
|
333
|
+
* // ast, ~rebuild.out, ~type.make.in, Iso, ~type.parameters, etc.
|
|
334
|
+
* type T = typeof bottom["Type"] // string
|
|
335
|
+
* type E = typeof bottom["Encoded"] // string
|
|
336
|
+
* ```
|
|
139
337
|
*
|
|
140
338
|
* @since 4.0.0
|
|
141
339
|
*/
|
|
142
340
|
export declare function revealBottom<S extends Top>(bottom: S): Bottom<S["Type"], S["Encoded"], S["DecodingServices"], S["EncodingServices"], S["ast"], S["~rebuild.out"], S["~type.make.in"], S["Iso"], S["~type.parameters"], S["~type.make"], S["~type.mutability"], S["~type.optionality"], S["~type.constructor.default"], S["~encoded.mutability"], S["~encoded.optionality"]>;
|
|
143
341
|
/**
|
|
144
342
|
* Adds metadata annotations to a schema without changing its runtime behavior.
|
|
145
|
-
*
|
|
146
|
-
*
|
|
343
|
+
* This is the pipeable (curried) counterpart of the `.annotate` method.
|
|
344
|
+
*
|
|
345
|
+
* Annotations provide extra context used by documentation generators, JSON
|
|
346
|
+
* Schema converters, error formatters, and other tooling. Common keys include
|
|
347
|
+
* `title`, `description`, `examples`, `message`, and `identifier`.
|
|
348
|
+
*
|
|
349
|
+
* **Example** (Adding a title and description)
|
|
350
|
+
*
|
|
351
|
+
* ```ts
|
|
352
|
+
* import { Schema } from "effect"
|
|
353
|
+
*
|
|
354
|
+
* const Age = Schema.Number.pipe(
|
|
355
|
+
* Schema.annotate({
|
|
356
|
+
* title: "Age",
|
|
357
|
+
* description: "A non-negative integer representing age in years"
|
|
358
|
+
* })
|
|
359
|
+
* )
|
|
360
|
+
* ```
|
|
147
361
|
*
|
|
148
362
|
* @category Annotations
|
|
149
363
|
* @since 4.0.0
|
|
150
364
|
*/
|
|
151
365
|
export declare function annotate<S extends Top>(annotations: S["~annotate.in"]): (self: S) => S["~rebuild.out"];
|
|
152
366
|
/**
|
|
153
|
-
* Adds key-
|
|
154
|
-
*
|
|
155
|
-
*
|
|
367
|
+
* Adds key-level annotations to a schema field. This is the pipeable
|
|
368
|
+
* (curried) counterpart of the `.annotateKey` method.
|
|
369
|
+
*
|
|
370
|
+
* Key annotations apply to a field's position inside a `Struct` or `Tuple`
|
|
371
|
+
* rather than to the field's value type. They can carry a
|
|
372
|
+
* `messageMissingKey` to customise the error shown when the field is absent,
|
|
373
|
+
* as well as standard documentation fields such as `title`, `description`,
|
|
374
|
+
* and `examples`.
|
|
375
|
+
*
|
|
376
|
+
* **Example** (Custom missing-key message for a required field)
|
|
377
|
+
*
|
|
378
|
+
* ```ts
|
|
379
|
+
* import { Schema } from "effect"
|
|
380
|
+
*
|
|
381
|
+
* const schema = Schema.Struct({
|
|
382
|
+
* username: Schema.String.pipe(
|
|
383
|
+
* Schema.annotateKey({
|
|
384
|
+
* description: "The username used to log in",
|
|
385
|
+
* messageMissingKey: "Username is required"
|
|
386
|
+
* })
|
|
387
|
+
* )
|
|
388
|
+
* })
|
|
389
|
+
* ```
|
|
156
390
|
*
|
|
157
391
|
* @category Annotations
|
|
158
392
|
* @since 4.0.0
|
|
159
393
|
*/
|
|
160
394
|
export declare function annotateKey<S extends Top>(annotations: Annotations.Key<S["Type"]>): (self: S) => S["~rebuild.out"];
|
|
161
395
|
/**
|
|
162
|
-
* The
|
|
396
|
+
* The existential "any schema" type — all type parameters are erased to `unknown`.
|
|
163
397
|
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
398
|
+
* Use `Top` as a constraint when writing generic utilities that must accept *any*
|
|
399
|
+
* schema regardless of its `Type`, `Encoded`, or service requirements. It is the
|
|
400
|
+
* widest possible schema type and therefore gives you the least static information.
|
|
167
401
|
*
|
|
168
|
-
*
|
|
169
|
-
* -
|
|
170
|
-
* -
|
|
402
|
+
* In user code prefer the narrower interfaces:
|
|
403
|
+
* - {@link Schema}`<T>` — when you only care about the decoded type
|
|
404
|
+
* - {@link Codec}`<T, E, RD, RE>` — when you need the encoded type and service requirements
|
|
405
|
+
* - {@link Decoder}`<T, RD>` — for decode-only APIs
|
|
406
|
+
* - {@link Encoder}`<E, RE>` — for encode-only APIs
|
|
171
407
|
*
|
|
172
408
|
* @since 4.0.0
|
|
173
409
|
*/
|
|
@@ -175,24 +411,52 @@ export interface Top extends Bottom<unknown, unknown, unknown, unknown, AST.AST,
|
|
|
175
411
|
unknown, Mutability, Optionality, ConstructorDefault, Mutability, Optionality> {
|
|
176
412
|
}
|
|
177
413
|
/**
|
|
414
|
+
* Namespace of type-level helpers for {@link Schema}.
|
|
415
|
+
*
|
|
178
416
|
* @since 4.0.0
|
|
179
417
|
*/
|
|
180
418
|
export declare namespace Schema {
|
|
181
419
|
/**
|
|
420
|
+
* Extracts the decoded `Type` from a schema.
|
|
421
|
+
*
|
|
422
|
+
* **Example** (Extracting the decoded type)
|
|
423
|
+
*
|
|
424
|
+
* ```ts
|
|
425
|
+
* import { Schema } from "effect"
|
|
426
|
+
*
|
|
427
|
+
* const Person = Schema.Struct({ name: Schema.String, age: Schema.Number })
|
|
428
|
+
* type Person = Schema.Schema.Type<typeof Person>
|
|
429
|
+
* // { readonly name: string; readonly age: number }
|
|
430
|
+
* ```
|
|
431
|
+
*
|
|
182
432
|
* @since 4.0.0
|
|
183
433
|
*/
|
|
184
|
-
type Type<S extends Top
|
|
434
|
+
type Type<S> = S extends Top ? S["Type"] : never;
|
|
185
435
|
}
|
|
186
436
|
/**
|
|
187
|
-
* A typed view of a schema that tracks the decoded (output) type `T`.
|
|
437
|
+
* A typed view of a schema that tracks only the decoded (output) type `T`.
|
|
188
438
|
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
439
|
+
* Use `Schema<T>` as a constraint when you want to accept "any schema that
|
|
440
|
+
* decodes to `T`" and do not need to know or constrain the encoded
|
|
441
|
+
* representation, required services, or any other type parameters.
|
|
442
|
+
*
|
|
443
|
+
* This is a structural interface — concrete schema values are produced by the
|
|
444
|
+
* constructors in this module (e.g. {@link Struct}, {@link String}, {@link Number}).
|
|
445
|
+
* When you also need the encoded type or service requirements, use {@link Codec}.
|
|
446
|
+
*
|
|
447
|
+
* **Example** (Function that accepts any schema decoding to `string`)
|
|
448
|
+
*
|
|
449
|
+
* ```ts
|
|
450
|
+
* import { Schema } from "effect"
|
|
451
|
+
*
|
|
452
|
+
* declare function print(schema: Schema.Schema<string>): void
|
|
453
|
+
*
|
|
454
|
+
* print(Schema.String) // ok
|
|
455
|
+
* print(Schema.NonEmptyString) // ok
|
|
456
|
+
* ```
|
|
192
457
|
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
* - If you also need the encoded type (or decoding/encoding services), use {@link Codec}.
|
|
458
|
+
* @see {@link Codec} — also tracks Encoded, DecodingServices, EncodingServices
|
|
459
|
+
* @see {@link Schema.Type} — extract the decoded type at the type level
|
|
196
460
|
*
|
|
197
461
|
* @since 4.0.0
|
|
198
462
|
*/
|
|
@@ -201,29 +465,83 @@ export interface Schema<out T> extends Top {
|
|
|
201
465
|
readonly "~rebuild.out": Schema<T>;
|
|
202
466
|
}
|
|
203
467
|
/**
|
|
468
|
+
* Namespace of type-level helpers for {@link Codec}.
|
|
469
|
+
*
|
|
204
470
|
* @since 4.0.0
|
|
205
471
|
*/
|
|
206
472
|
export declare namespace Codec {
|
|
207
473
|
/**
|
|
474
|
+
* Extracts the encoded (`Encoded`) type from a schema.
|
|
475
|
+
*
|
|
476
|
+
* **Example** (Extracting the encoded type)
|
|
477
|
+
*
|
|
478
|
+
* ```ts
|
|
479
|
+
* import { Schema } from "effect"
|
|
480
|
+
*
|
|
481
|
+
* const schema = Schema.NumberFromString
|
|
482
|
+
* type Enc = Schema.Codec.Encoded<typeof schema>
|
|
483
|
+
* // string
|
|
484
|
+
* ```
|
|
485
|
+
*
|
|
208
486
|
* @since 4.0.0
|
|
209
487
|
*/
|
|
210
|
-
type Encoded<S extends Top
|
|
488
|
+
type Encoded<S> = S extends Top ? S["Encoded"] : never;
|
|
211
489
|
/**
|
|
490
|
+
* Extracts the Effect services required during *decoding* from a schema.
|
|
491
|
+
*
|
|
492
|
+
* **Example** (Checking decoding service requirements)
|
|
493
|
+
*
|
|
494
|
+
* ```ts
|
|
495
|
+
* import { Schema } from "effect"
|
|
496
|
+
*
|
|
497
|
+
* const schema = Schema.String
|
|
498
|
+
* type RD = Schema.Codec.DecodingServices<typeof schema>
|
|
499
|
+
* // never
|
|
500
|
+
* ```
|
|
501
|
+
*
|
|
212
502
|
* @since 4.0.0
|
|
213
503
|
*/
|
|
214
|
-
type DecodingServices<S extends Top
|
|
504
|
+
type DecodingServices<S> = S extends Top ? S["DecodingServices"] : never;
|
|
215
505
|
/**
|
|
506
|
+
* Extracts the Effect services required during *encoding* from a schema.
|
|
507
|
+
*
|
|
508
|
+
* **Example** (Checking encoding service requirements)
|
|
509
|
+
*
|
|
510
|
+
* ```ts
|
|
511
|
+
* import { Schema } from "effect"
|
|
512
|
+
*
|
|
513
|
+
* const schema = Schema.String
|
|
514
|
+
* type RE = Schema.Codec.EncodingServices<typeof schema>
|
|
515
|
+
* // never
|
|
516
|
+
* ```
|
|
517
|
+
*
|
|
216
518
|
* @since 4.0.0
|
|
217
519
|
*/
|
|
218
|
-
type EncodingServices<S extends Top
|
|
520
|
+
type EncodingServices<S> = S extends Top ? S["EncodingServices"] : never;
|
|
219
521
|
/**
|
|
522
|
+
* Converts a schema type into an assertion function signature. The resulting
|
|
523
|
+
* function narrows its argument to `I & S["Type"]`. Only schemas with
|
|
524
|
+
* `DecodingServices: never` (i.e. no required services) can be used here.
|
|
525
|
+
*
|
|
526
|
+
* Produced by {@link asserts}.
|
|
527
|
+
*
|
|
220
528
|
* @since 4.0.0
|
|
221
529
|
*/
|
|
222
|
-
type ToAsserts<S extends Top &
|
|
223
|
-
readonly DecodingServices: never;
|
|
224
|
-
}> = <I>(input: I) => asserts input is I & S["Type"];
|
|
530
|
+
type ToAsserts<S extends Top> = <I>(input: I) => asserts input is I & S["Type"];
|
|
225
531
|
}
|
|
226
532
|
/**
|
|
533
|
+
* A schema that additionally supports optic (lens/prism) operations.
|
|
534
|
+
*
|
|
535
|
+
* `Optic<T, Iso>` extends {@link Schema}`<T>` with an `Iso` type that
|
|
536
|
+
* describes the isomorphic counterpart used by the optic layer. Crucially,
|
|
537
|
+
* decoding and encoding require *no* Effect services (`DecodingServices` and
|
|
538
|
+
* `EncodingServices` are both `never`), which means the optic can operate
|
|
539
|
+
* purely without an Effect runtime.
|
|
540
|
+
*
|
|
541
|
+
* Most primitive schemas (e.g. `Schema.String`, `Schema.Number`) implement
|
|
542
|
+
* `Optic` automatically. You normally interact with this interface through
|
|
543
|
+
* {@link Optic_} utilities rather than constructing it directly.
|
|
544
|
+
*
|
|
227
545
|
* @since 4.0.0
|
|
228
546
|
*/
|
|
229
547
|
export interface Optic<out T, out Iso> extends Schema<T> {
|
|
@@ -233,16 +551,32 @@ export interface Optic<out T, out Iso> extends Schema<T> {
|
|
|
233
551
|
readonly "~rebuild.out": Optic<T, Iso>;
|
|
234
552
|
}
|
|
235
553
|
/**
|
|
236
|
-
* A schema that tracks
|
|
554
|
+
* A schema that tracks the decoded type `T`, the encoded type `E`, and the
|
|
555
|
+
* Effect services required during decoding (`RD`) and encoding (`RE`).
|
|
237
556
|
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
557
|
+
* Use `Codec<T, E, RD, RE>` when you need to preserve full type information
|
|
558
|
+
* about a schema — both what it decodes to and what it serializes from/to.
|
|
559
|
+
* Most concrete schemas produced by this module implement `Codec`.
|
|
560
|
+
*
|
|
561
|
+
* For APIs that only need one direction, prefer the narrower views:
|
|
562
|
+
* - {@link Decoder}`<T, RD>` — decode-only
|
|
563
|
+
* - {@link Encoder}`<E, RE>` — encode-only
|
|
564
|
+
* - {@link Schema}`<T>` — type-only (no encoded representation)
|
|
565
|
+
*
|
|
566
|
+
* **Example** (Accepting a codec that decodes to `number` from `string`)
|
|
567
|
+
*
|
|
568
|
+
* ```ts
|
|
569
|
+
* import { Schema } from "effect"
|
|
570
|
+
*
|
|
571
|
+
* declare function serialize<T>(codec: Schema.Codec<T, string>): string
|
|
572
|
+
*
|
|
573
|
+
* serialize(Schema.NumberFromString) // ok — decodes number, encoded as string
|
|
574
|
+
* ```
|
|
242
575
|
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
*
|
|
576
|
+
* @see {@link Codec.Encoded} — extract the encoded type
|
|
577
|
+
* @see {@link Codec.DecodingServices} — extract required decoding services
|
|
578
|
+
* @see {@link Codec.EncodingServices} — extract required encoding services
|
|
579
|
+
* @see {@link revealCodec} — helper to make TypeScript infer the full Codec type
|
|
246
580
|
*
|
|
247
581
|
* @since 4.0.0
|
|
248
582
|
*/
|
|
@@ -253,11 +587,22 @@ export interface Codec<out T, out E = T, out RD = never, out RE = never> extends
|
|
|
253
587
|
readonly "~rebuild.out": Codec<T, E, RD, RE>;
|
|
254
588
|
}
|
|
255
589
|
/**
|
|
256
|
-
* A
|
|
590
|
+
* A {@link Codec} view for APIs that only *decode* (parse/validate) values.
|
|
257
591
|
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
592
|
+
* Use `Decoder<T, RD>` to accept "any schema that can decode to `T`" without
|
|
593
|
+
* constraining or depending on the encoded representation (`Encoded` is
|
|
594
|
+
* `unknown`) or encoding services.
|
|
595
|
+
*
|
|
596
|
+
* **Example** (Function that only needs to decode)
|
|
597
|
+
*
|
|
598
|
+
* ```ts
|
|
599
|
+
* import { Schema } from "effect"
|
|
600
|
+
*
|
|
601
|
+
* declare function validate<T>(decoder: Schema.Decoder<T>): (input: unknown) => T
|
|
602
|
+
*
|
|
603
|
+
* validate(Schema.String) // ok
|
|
604
|
+
* validate(Schema.NumberFromString) // ok
|
|
605
|
+
* ```
|
|
261
606
|
*
|
|
262
607
|
* @since 4.0.0
|
|
263
608
|
*/
|
|
@@ -265,11 +610,22 @@ export interface Decoder<out T, out RD = never> extends Codec<T, unknown, RD, un
|
|
|
265
610
|
readonly "~rebuild.out": Decoder<T, RD>;
|
|
266
611
|
}
|
|
267
612
|
/**
|
|
268
|
-
* A
|
|
613
|
+
* A {@link Codec} view for APIs that only *encode* values.
|
|
269
614
|
*
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
*
|
|
615
|
+
* Use `Encoder<E, RE>` to accept "any schema that can encode to `E`" without
|
|
616
|
+
* constraining or depending on the decoded `Type` (`Type` is `unknown`) or
|
|
617
|
+
* decoding services.
|
|
618
|
+
*
|
|
619
|
+
* **Example** (Function that only needs to encode)
|
|
620
|
+
*
|
|
621
|
+
* ```ts
|
|
622
|
+
* import { Schema } from "effect"
|
|
623
|
+
*
|
|
624
|
+
* declare function serialize<E>(encoder: Schema.Encoder<E>): (value: unknown) => E
|
|
625
|
+
*
|
|
626
|
+
* serialize(Schema.String) // ok — encodes to string
|
|
627
|
+
* serialize(Schema.NumberFromString) // ok — encodes number to string
|
|
628
|
+
* ```
|
|
273
629
|
*
|
|
274
630
|
* @since 4.0.0
|
|
275
631
|
*/
|
|
@@ -277,17 +633,54 @@ export interface Encoder<out E, out RE = never> extends Codec<unknown, E, unknow
|
|
|
277
633
|
readonly "~rebuild.out": Encoder<E, RE>;
|
|
278
634
|
}
|
|
279
635
|
/**
|
|
636
|
+
* Identity function that widens a value to the full {@link Codec} interface,
|
|
637
|
+
* prompting TypeScript to infer all four type parameters (`T`, `E`, `RD`, `RE`).
|
|
638
|
+
*
|
|
639
|
+
* When a schema is stored in a variable typed as `Schema<T>` or `Top`, the
|
|
640
|
+
* encoded type and service requirements are erased. Passing the value through
|
|
641
|
+
* `revealCodec` recovers those parameters without any runtime cost.
|
|
642
|
+
*
|
|
643
|
+
* **Example** (Recovering encoded type from a schema variable)
|
|
644
|
+
*
|
|
645
|
+
* ```ts
|
|
646
|
+
* import { Schema } from "effect"
|
|
647
|
+
*
|
|
648
|
+
* const schema: Schema.Schema<number> = Schema.NumberFromString
|
|
649
|
+
*
|
|
650
|
+
* // Without revealCodec, Encoded is unknown
|
|
651
|
+
* const codec = Schema.revealCodec(schema)
|
|
652
|
+
* type Enc = typeof codec["Encoded"] // string
|
|
653
|
+
* ```
|
|
654
|
+
*
|
|
280
655
|
* @since 4.0.0
|
|
281
656
|
*/
|
|
282
657
|
export declare function revealCodec<T, E, RD, RE>(codec: Codec<T, E, RD, RE>): Codec<T, E, RD, RE>;
|
|
283
658
|
declare const SchemaErrorTypeId = "~effect/Schema/SchemaError";
|
|
284
659
|
/**
|
|
285
|
-
*
|
|
660
|
+
* Error thrown (or returned as the error channel value) when schema decoding
|
|
661
|
+
* or encoding fails.
|
|
662
|
+
*
|
|
663
|
+
* The `issue` field contains a structured {@link Issue.Issue} tree describing
|
|
664
|
+
* every validation failure, including the path to the problematic value,
|
|
665
|
+
* expected types, and actual values received. `message` renders the issue tree
|
|
666
|
+
* as a human-readable string.
|
|
667
|
+
*
|
|
668
|
+
* Use {@link isSchemaError} to narrow an unknown value to `SchemaError`.
|
|
669
|
+
*
|
|
670
|
+
* **Example** (Catching a SchemaError)
|
|
286
671
|
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
*
|
|
290
|
-
*
|
|
672
|
+
* ```ts
|
|
673
|
+
* import { Schema } from "effect"
|
|
674
|
+
*
|
|
675
|
+
* try {
|
|
676
|
+
* Schema.decodeUnknownSync(Schema.Number)("not a number")
|
|
677
|
+
* } catch (err) {
|
|
678
|
+
* if (Schema.isSchemaError(err)) {
|
|
679
|
+
* console.log(err.message)
|
|
680
|
+
* // Expected number, actual "not a number"
|
|
681
|
+
* }
|
|
682
|
+
* }
|
|
683
|
+
* ```
|
|
291
684
|
*
|
|
292
685
|
* @since 4.0.0
|
|
293
686
|
*/
|
|
@@ -301,6 +694,22 @@ export declare class SchemaError {
|
|
|
301
694
|
toString(): string;
|
|
302
695
|
}
|
|
303
696
|
/**
|
|
697
|
+
* Returns `true` if `u` is a {@link SchemaError}.
|
|
698
|
+
*
|
|
699
|
+
* **Example** (Type guard in a catch block)
|
|
700
|
+
*
|
|
701
|
+
* ```ts
|
|
702
|
+
* import { Schema } from "effect"
|
|
703
|
+
*
|
|
704
|
+
* try {
|
|
705
|
+
* Schema.decodeUnknownSync(Schema.Number)("oops")
|
|
706
|
+
* } catch (err) {
|
|
707
|
+
* if (Schema.isSchemaError(err)) {
|
|
708
|
+
* console.log(err._tag) // "SchemaError"
|
|
709
|
+
* }
|
|
710
|
+
* }
|
|
711
|
+
* ```
|
|
712
|
+
*
|
|
304
713
|
* @since 4.0.0
|
|
305
714
|
*/
|
|
306
715
|
export declare function isSchemaError(u: unknown): u is SchemaError;
|
|
@@ -365,9 +774,7 @@ export declare function isSchemaError(u: unknown): u is SchemaError;
|
|
|
365
774
|
* @category Standard Schema
|
|
366
775
|
* @since 4.0.0
|
|
367
776
|
*/
|
|
368
|
-
export declare function toStandardSchemaV1<S extends
|
|
369
|
-
readonly DecodingServices: never;
|
|
370
|
-
}>(self: S, options?: {
|
|
777
|
+
export declare function toStandardSchemaV1<S extends Decoder<unknown>>(self: S, options?: {
|
|
371
778
|
readonly leafHook?: Issue.LeafHook | undefined;
|
|
372
779
|
readonly checkHook?: Issue.CheckHook | undefined;
|
|
373
780
|
readonly parseOptions?: AST.ParseOptions | undefined;
|
|
@@ -450,139 +857,257 @@ export declare const is: typeof Parser.is;
|
|
|
450
857
|
*/
|
|
451
858
|
export declare const asserts: typeof Parser.asserts;
|
|
452
859
|
/**
|
|
860
|
+
* Decodes an `unknown` input against a schema, returning an `Effect` that
|
|
861
|
+
* succeeds with the decoded value or fails with a {@link SchemaError}. Use this
|
|
862
|
+
* when the input type is not statically known. Prefer {@link decodeEffect} when
|
|
863
|
+
* the input is already typed as the schema's `Encoded` type.
|
|
864
|
+
*
|
|
453
865
|
* @category Decoding
|
|
454
866
|
* @since 4.0.0
|
|
455
867
|
*/
|
|
456
868
|
export declare function decodeUnknownEffect<S extends Top>(schema: S): (input: unknown, options?: AST.ParseOptions) => Effect.Effect<S["Type"], SchemaError, S["DecodingServices"]>;
|
|
457
869
|
/**
|
|
870
|
+
* Decodes a typed input (the schema's `Encoded` type) against a schema,
|
|
871
|
+
* returning an `Effect` that succeeds with the decoded value or fails with a
|
|
872
|
+
* {@link SchemaError}. Use this when the input is already typed; for `unknown`
|
|
873
|
+
* input use {@link decodeUnknownEffect}.
|
|
874
|
+
*
|
|
458
875
|
* @category Decoding
|
|
459
876
|
* @since 4.0.0
|
|
460
877
|
*/
|
|
461
878
|
export declare const decodeEffect: <S extends Top>(schema: S) => (input: S["Encoded"], options?: AST.ParseOptions) => Effect.Effect<S["Type"], SchemaError, S["DecodingServices"]>;
|
|
462
879
|
/**
|
|
880
|
+
* Decodes an `unknown` input against a schema synchronously, returning an
|
|
881
|
+
* `Exit` that is either a `Success` with the decoded value or a `Failure` with
|
|
882
|
+
* a {@link SchemaError}. Only usable with schemas that have no
|
|
883
|
+
* `DecodingServices` requirement. Prefer {@link decodeExit} when the input is
|
|
884
|
+
* already typed as the schema's `Encoded` type.
|
|
885
|
+
*
|
|
463
886
|
* @category Decoding
|
|
464
887
|
* @since 4.0.0
|
|
465
888
|
*/
|
|
466
|
-
export declare function decodeUnknownExit<S extends
|
|
467
|
-
readonly DecodingServices: never;
|
|
468
|
-
}>(schema: S): (input: unknown, options?: AST.ParseOptions) => Exit_.Exit<S["Type"], SchemaError>;
|
|
889
|
+
export declare function decodeUnknownExit<S extends Decoder<unknown>>(schema: S): (input: unknown, options?: AST.ParseOptions) => Exit_.Exit<S["Type"], SchemaError>;
|
|
469
890
|
/**
|
|
891
|
+
* Decodes a typed input (the schema's `Encoded` type) against a schema
|
|
892
|
+
* synchronously, returning an `Exit` that is either a `Success` with the
|
|
893
|
+
* decoded value or a `Failure` with a {@link SchemaError}. Only usable with
|
|
894
|
+
* schemas that have no `DecodingServices` requirement. For `unknown` input use
|
|
895
|
+
* {@link decodeUnknownExit}.
|
|
896
|
+
*
|
|
470
897
|
* @category Decoding
|
|
471
898
|
* @since 4.0.0
|
|
472
899
|
*/
|
|
473
|
-
export declare const decodeExit: <S extends
|
|
474
|
-
readonly DecodingServices: never;
|
|
475
|
-
}>(schema: S) => (input: S["Encoded"], options?: AST.ParseOptions) => Exit_.Exit<S["Type"], SchemaError>;
|
|
900
|
+
export declare const decodeExit: <S extends Decoder<unknown>>(schema: S) => (input: S["Encoded"], options?: AST.ParseOptions) => Exit_.Exit<S["Type"], SchemaError>;
|
|
476
901
|
/**
|
|
902
|
+
* Decodes an `unknown` input against a schema, returning an `Option` that is
|
|
903
|
+
* `Some` with the decoded value on success or `None` on failure. Prefer this
|
|
904
|
+
* over {@link decodeUnknownExit} or {@link decodeUnknownEffect} when you only
|
|
905
|
+
* need to know whether decoding succeeded and don't need error details. For
|
|
906
|
+
* typed input use {@link decodeOption}.
|
|
907
|
+
*
|
|
477
908
|
* @category Decoding
|
|
478
909
|
* @since 4.0.0
|
|
479
910
|
*/
|
|
480
911
|
export declare const decodeUnknownOption: typeof Parser.decodeUnknownOption;
|
|
912
|
+
/**
|
|
913
|
+
* Decodes a typed input (the schema's `Encoded` type) against a schema,
|
|
914
|
+
* returning an `Option` that is `Some` with the decoded value on success or
|
|
915
|
+
* `None` on failure. For `unknown` input use {@link decodeUnknownOption}.
|
|
916
|
+
*
|
|
917
|
+
* @category Decoding
|
|
918
|
+
* @since 4.0.0
|
|
919
|
+
*/
|
|
920
|
+
export declare const decodeOption: <S extends Decoder<unknown>>(schema: S) => (input: S["Encoded"], options?: AST.ParseOptions) => Option_.Option<S["Type"]>;
|
|
921
|
+
/**
|
|
922
|
+
* Decodes an `unknown` input against a schema, returning a `Promise` that
|
|
923
|
+
* resolves with the decoded value or rejects with a {@link SchemaError}. Useful
|
|
924
|
+
* for integrating with Promise-based APIs. For typed input use
|
|
925
|
+
* {@link decodePromise}.
|
|
926
|
+
*
|
|
927
|
+
* @category Decoding
|
|
928
|
+
* @since 4.0.0
|
|
929
|
+
*/
|
|
930
|
+
export declare const decodeUnknownResult: typeof Parser.decodeUnknownResult;
|
|
481
931
|
/**
|
|
482
932
|
* @category Decoding
|
|
483
933
|
* @since 4.0.0
|
|
484
934
|
*/
|
|
485
|
-
export declare const
|
|
486
|
-
readonly DecodingServices: never;
|
|
487
|
-
}>(schema: S) => (input: S["Encoded"], options?: AST.ParseOptions) => Option_.Option<S["Type"]>;
|
|
935
|
+
export declare const decodeResult: <S extends Decoder<unknown>>(schema: S) => (input: S["Encoded"], options?: AST.ParseOptions) => Result_.Result<S["Type"], Issue.Issue>;
|
|
488
936
|
/**
|
|
489
937
|
* @category Decoding
|
|
490
938
|
* @since 4.0.0
|
|
491
939
|
*/
|
|
492
940
|
export declare const decodeUnknownPromise: typeof Parser.decodeUnknownPromise;
|
|
493
941
|
/**
|
|
942
|
+
* Decodes a typed input (the schema's `Encoded` type) against a schema,
|
|
943
|
+
* returning a `Promise` that resolves with the decoded value or rejects with a
|
|
944
|
+
* {@link SchemaError}. For `unknown` input use {@link decodeUnknownPromise}.
|
|
945
|
+
*
|
|
494
946
|
* @category Decoding
|
|
495
947
|
* @since 4.0.0
|
|
496
948
|
*/
|
|
497
949
|
export declare const decodePromise: typeof Parser.decodePromise;
|
|
498
950
|
/**
|
|
951
|
+
* Decodes an `unknown` input against a schema synchronously, throwing a
|
|
952
|
+
* {@link SchemaError} on failure. Use this when you want to validate data at a
|
|
953
|
+
* boundary and treat a schema mismatch as an unrecoverable error. For
|
|
954
|
+
* non-throwing alternatives see {@link decodeUnknownOption},
|
|
955
|
+
* {@link decodeUnknownExit}, or {@link decodeUnknownEffect}. For typed input
|
|
956
|
+
* use {@link decodeSync}.
|
|
957
|
+
*
|
|
958
|
+
* **Example** (Decoding with a transformation schema)
|
|
959
|
+
*
|
|
960
|
+
* ```ts
|
|
961
|
+
* import { Schema } from "effect"
|
|
962
|
+
*
|
|
963
|
+
* const NumberFromString = Schema.NumberFromString
|
|
964
|
+
*
|
|
965
|
+
* console.log(Schema.decodeUnknownSync(NumberFromString)("42"))
|
|
966
|
+
* // Output: 42
|
|
967
|
+
*
|
|
968
|
+
* Schema.decodeUnknownSync(NumberFromString)("not a number")
|
|
969
|
+
* // throws SchemaError: NumberFromString
|
|
970
|
+
* // └─ Encoded side transformation failure
|
|
971
|
+
* // └─ NumberFromString
|
|
972
|
+
* // └─ Expected a numeric string, actual "not a number"
|
|
973
|
+
* ```
|
|
974
|
+
*
|
|
499
975
|
* @category Decoding
|
|
500
976
|
* @since 4.0.0
|
|
501
977
|
*/
|
|
502
978
|
export declare const decodeUnknownSync: typeof Parser.decodeUnknownSync;
|
|
503
979
|
/**
|
|
980
|
+
* Decodes a typed input (the schema's `Encoded` type) against a schema
|
|
981
|
+
* synchronously, throwing a {@link SchemaError} on failure. For `unknown` input
|
|
982
|
+
* use {@link decodeUnknownSync}.
|
|
983
|
+
*
|
|
504
984
|
* @category Decoding
|
|
505
985
|
* @since 4.0.0
|
|
506
986
|
*/
|
|
507
|
-
export declare const decodeSync: <S extends
|
|
508
|
-
readonly DecodingServices: never;
|
|
509
|
-
}>(schema: S) => (input: S["Encoded"], options?: AST.ParseOptions) => S["Type"];
|
|
987
|
+
export declare const decodeSync: <S extends Decoder<unknown>>(schema: S) => (input: S["Encoded"], options?: AST.ParseOptions) => S["Type"];
|
|
510
988
|
/**
|
|
989
|
+
* Encodes an `unknown` input against a schema, returning an `Effect` that
|
|
990
|
+
* succeeds with the encoded value or fails with a {@link SchemaError}. Use this
|
|
991
|
+
* when the input type is not statically known. Prefer {@link encodeEffect} when
|
|
992
|
+
* the input is already typed as the schema's `Type`.
|
|
993
|
+
*
|
|
994
|
+
* **Example** (Encoding a value to a string)
|
|
995
|
+
*
|
|
996
|
+
* ```ts
|
|
997
|
+
* import { Effect, Schema } from "effect"
|
|
998
|
+
*
|
|
999
|
+
* const NumberFromString = Schema.NumberFromString
|
|
1000
|
+
*
|
|
1001
|
+
* Effect.runPromise(Schema.encodeUnknownEffect(NumberFromString)(42)).then(console.log)
|
|
1002
|
+
* // Output: "42"
|
|
1003
|
+
* ```
|
|
1004
|
+
*
|
|
511
1005
|
* @category Encoding
|
|
512
1006
|
* @since 4.0.0
|
|
513
1007
|
*/
|
|
514
1008
|
export declare function encodeUnknownEffect<S extends Top>(schema: S): (input: unknown, options?: AST.ParseOptions) => Effect.Effect<S["Encoded"], SchemaError, S["EncodingServices"]>;
|
|
515
1009
|
/**
|
|
1010
|
+
* Encodes a typed input (the schema's `Type`) against a schema, returning an
|
|
1011
|
+
* `Effect` that succeeds with the encoded value or fails with a
|
|
1012
|
+
* {@link SchemaError}. Use this when the input is already typed; for `unknown`
|
|
1013
|
+
* input use {@link encodeUnknownEffect}.
|
|
1014
|
+
*
|
|
516
1015
|
* @category Encoding
|
|
517
1016
|
* @since 4.0.0
|
|
518
1017
|
*/
|
|
519
1018
|
export declare const encodeEffect: <S extends Top>(schema: S) => (input: S["Type"], options?: AST.ParseOptions) => Effect.Effect<S["Encoded"], SchemaError, S["EncodingServices"]>;
|
|
520
1019
|
/**
|
|
1020
|
+
* Encodes an `unknown` input against a schema synchronously, returning an
|
|
1021
|
+
* `Exit` that is either a `Success` with the encoded value or a `Failure` with
|
|
1022
|
+
* a {@link SchemaError}. Only usable with schemas that have no
|
|
1023
|
+
* `EncodingServices` requirement. Prefer {@link encodeExit} when the input is
|
|
1024
|
+
* already typed as the schema's `Type`.
|
|
1025
|
+
*
|
|
521
1026
|
* @category Encoding
|
|
522
1027
|
* @since 4.0.0
|
|
523
1028
|
*/
|
|
524
|
-
export declare function encodeUnknownExit<S extends
|
|
525
|
-
readonly EncodingServices: never;
|
|
526
|
-
}>(schema: S): (input: unknown, options?: AST.ParseOptions) => Exit_.Exit<S["Encoded"], SchemaError>;
|
|
1029
|
+
export declare function encodeUnknownExit<S extends Encoder<unknown>>(schema: S): (input: unknown, options?: AST.ParseOptions) => Exit_.Exit<S["Encoded"], SchemaError>;
|
|
527
1030
|
/**
|
|
1031
|
+
* Encodes a typed input (the schema's `Type`) against a schema synchronously,
|
|
1032
|
+
* returning an `Exit` that is either a `Success` with the encoded value or a
|
|
1033
|
+
* `Failure` with a {@link SchemaError}. Only usable with schemas that have no
|
|
1034
|
+
* `EncodingServices` requirement. For `unknown` input use
|
|
1035
|
+
* {@link encodeUnknownExit}.
|
|
1036
|
+
*
|
|
528
1037
|
* @category Encoding
|
|
529
1038
|
* @since 4.0.0
|
|
530
1039
|
*/
|
|
531
|
-
export declare const encodeExit: <S extends
|
|
532
|
-
readonly EncodingServices: never;
|
|
533
|
-
}>(schema: S) => (input: S["Type"], options?: AST.ParseOptions) => Exit_.Exit<S["Encoded"], SchemaError>;
|
|
1040
|
+
export declare const encodeExit: <S extends Encoder<unknown>>(schema: S) => (input: S["Type"], options?: AST.ParseOptions) => Exit_.Exit<S["Encoded"], SchemaError>;
|
|
534
1041
|
/**
|
|
1042
|
+
* Encodes an `unknown` input against a schema, returning an `Option` that is
|
|
1043
|
+
* `Some` with the encoded value on success or `None` on failure. Prefer this
|
|
1044
|
+
* over {@link encodeUnknownExit} or {@link encodeUnknownEffect} when you only
|
|
1045
|
+
* need to know whether encoding succeeded and don't need error details. For
|
|
1046
|
+
* typed input use {@link encodeOption}.
|
|
1047
|
+
*
|
|
535
1048
|
* @category Encoding
|
|
536
1049
|
* @since 4.0.0
|
|
537
1050
|
*/
|
|
538
1051
|
export declare const encodeUnknownOption: typeof Parser.encodeUnknownOption;
|
|
539
1052
|
/**
|
|
1053
|
+
* Encodes a typed input (the schema's `Type`) against a schema, returning an
|
|
1054
|
+
* `Option` that is `Some` with the encoded value on success or `None` on
|
|
1055
|
+
* failure. For `unknown` input use {@link encodeUnknownOption}.
|
|
1056
|
+
*
|
|
540
1057
|
* @category Encoding
|
|
541
1058
|
* @since 4.0.0
|
|
542
1059
|
*/
|
|
543
|
-
export declare const encodeOption: <S extends
|
|
544
|
-
readonly EncodingServices: never;
|
|
545
|
-
}>(schema: S) => (input: S["Type"], options?: AST.ParseOptions) => Option_.Option<S["Encoded"]>;
|
|
1060
|
+
export declare const encodeOption: <S extends Encoder<unknown>>(schema: S) => (input: S["Type"], options?: AST.ParseOptions) => Option_.Option<S["Encoded"]>;
|
|
546
1061
|
/**
|
|
1062
|
+
* Encodes an `unknown` input against a schema, returning a `Promise` that
|
|
1063
|
+
* resolves with the encoded value or rejects with a {@link SchemaError}. Useful
|
|
1064
|
+
* for integrating with Promise-based APIs. For typed input use
|
|
1065
|
+
* {@link encodePromise}.
|
|
1066
|
+
*
|
|
547
1067
|
* @category Encoding
|
|
548
1068
|
* @since 4.0.0
|
|
549
1069
|
*/
|
|
550
|
-
export declare const
|
|
551
|
-
readonly EncodingServices: never;
|
|
552
|
-
}>(schema: S) => (input: unknown, options?: AST.ParseOptions) => Promise<S["Encoded"]>;
|
|
1070
|
+
export declare const encodeUnknownResult: typeof Parser.encodeUnknownResult;
|
|
553
1071
|
/**
|
|
554
1072
|
* @category Encoding
|
|
555
1073
|
* @since 4.0.0
|
|
556
1074
|
*/
|
|
557
|
-
export declare const
|
|
558
|
-
readonly EncodingServices: never;
|
|
559
|
-
}>(schema: S) => (input: S["Type"], options?: AST.ParseOptions) => Promise<S["Encoded"]>;
|
|
1075
|
+
export declare const encodeResult: <S extends Encoder<unknown>>(schema: S) => (input: S["Type"], options?: AST.ParseOptions) => Result_.Result<S["Encoded"], Issue.Issue>;
|
|
560
1076
|
/**
|
|
561
1077
|
* @category Encoding
|
|
562
1078
|
* @since 4.0.0
|
|
563
1079
|
*/
|
|
564
|
-
export declare const
|
|
1080
|
+
export declare const encodeUnknownPromise: <S extends Encoder<unknown>>(schema: S) => (input: unknown, options?: AST.ParseOptions) => Promise<S["Encoded"]>;
|
|
565
1081
|
/**
|
|
1082
|
+
* Encodes a typed input (the schema's `Type`) against a schema, returning a
|
|
1083
|
+
* `Promise` that resolves with the encoded value or rejects with a
|
|
1084
|
+
* {@link SchemaError}. For `unknown` input use {@link encodeUnknownPromise}.
|
|
1085
|
+
*
|
|
566
1086
|
* @category Encoding
|
|
567
1087
|
* @since 4.0.0
|
|
568
1088
|
*/
|
|
569
|
-
export declare const
|
|
570
|
-
readonly EncodingServices: never;
|
|
571
|
-
}>(schema: S) => (input: S["Type"], options
|
|
1089
|
+
export declare const encodePromise: <S extends Encoder<unknown>>(schema: S) => (input: S["Type"], options?: AST.ParseOptions) => Promise<S["Encoded"]>;
|
|
572
1090
|
/**
|
|
573
|
-
*
|
|
574
|
-
*
|
|
575
|
-
*
|
|
576
|
-
* -
|
|
577
|
-
*
|
|
1091
|
+
* Encodes an `unknown` input against a schema synchronously, throwing a
|
|
1092
|
+
* {@link SchemaError} on failure. Use this when you want to serialize data at a
|
|
1093
|
+
* boundary and treat a schema mismatch as an unrecoverable error. For
|
|
1094
|
+
* non-throwing alternatives see {@link encodeUnknownOption},
|
|
1095
|
+
* {@link encodeUnknownExit}, or {@link encodeUnknownEffect}. For typed input
|
|
1096
|
+
* use {@link encodeSync}.
|
|
578
1097
|
*
|
|
579
|
-
*
|
|
580
|
-
*
|
|
581
|
-
|
|
1098
|
+
* @category Encoding
|
|
1099
|
+
* @since 4.0.0
|
|
1100
|
+
*/
|
|
1101
|
+
export declare const encodeUnknownSync: typeof Parser.encodeUnknownSync;
|
|
1102
|
+
/**
|
|
1103
|
+
* Encodes a typed input (the schema's `Type`) against a schema synchronously,
|
|
1104
|
+
* throwing a {@link SchemaError} on failure. For `unknown` input use
|
|
1105
|
+
* {@link encodeUnknownSync}.
|
|
582
1106
|
*
|
|
1107
|
+
* @category Encoding
|
|
583
1108
|
* @since 4.0.0
|
|
584
1109
|
*/
|
|
585
|
-
?: AST.ParseOptions) => S["Encoded"];
|
|
1110
|
+
export declare const encodeSync: <S extends Encoder<unknown>>(schema: S) => (input: S["Type"], options?: AST.ParseOptions) => S["Encoded"];
|
|
586
1111
|
/**
|
|
587
1112
|
* Creates a schema from an AST (Abstract Syntax Tree) node.
|
|
588
1113
|
*
|
|
@@ -607,6 +1132,10 @@ export declare const make: <S extends Top>(ast: S["ast"], options?: object) => S
|
|
|
607
1132
|
*/
|
|
608
1133
|
export declare function isSchema(u: unknown): u is Top;
|
|
609
1134
|
/**
|
|
1135
|
+
* Schema type for an exact optional struct key. The key may be absent, but
|
|
1136
|
+
* when present must match the wrapped schema (no implicit `undefined`).
|
|
1137
|
+
* Produced by {@link optionalKey}.
|
|
1138
|
+
*
|
|
610
1139
|
* @since 4.0.0
|
|
611
1140
|
*/
|
|
612
1141
|
export interface optionalKey<S extends Top> extends Bottom<S["Type"], S["Encoded"], S["DecodingServices"], S["EncodingServices"], S["ast"], optionalKey<S>, S["~type.make.in"], S["Iso"], S["~type.parameters"], S["~type.make"], S["~type.mutability"], "optional", S["~type.constructor.default"], S["~encoded.mutability"], "optional"> {
|
|
@@ -644,10 +1173,16 @@ interface requiredKeyLambda extends Lambda {
|
|
|
644
1173
|
readonly "~lambda.out": this["~lambda.in"] extends optionalKey<Top> ? this["~lambda.in"]["schema"] : "Error: schema not eligible for requiredKey";
|
|
645
1174
|
}
|
|
646
1175
|
/**
|
|
1176
|
+
* Reverses {@link optionalKey}, returning the inner required schema. Only
|
|
1177
|
+
* applicable to schemas already wrapped with `optionalKey`.
|
|
1178
|
+
*
|
|
647
1179
|
* @since 4.0.0
|
|
648
1180
|
*/
|
|
649
1181
|
export declare const requiredKey: requiredKeyLambda;
|
|
650
1182
|
/**
|
|
1183
|
+
* Schema type for an optional struct key that also accepts `undefined`.
|
|
1184
|
+
* Equivalent to `optionalKey<UndefinedOr<S>>`. Produced by {@link optional}.
|
|
1185
|
+
*
|
|
651
1186
|
* @since 4.0.0
|
|
652
1187
|
*/
|
|
653
1188
|
export interface optional<S extends Top> extends optionalKey<UndefinedOr<S>> {
|
|
@@ -657,27 +1192,26 @@ interface optionalLambda extends Lambda {
|
|
|
657
1192
|
readonly "~lambda.out": this["~lambda.in"] extends Top ? optional<this["~lambda.in"]> : never;
|
|
658
1193
|
}
|
|
659
1194
|
/**
|
|
660
|
-
*
|
|
1195
|
+
* Marks a struct field as optional, allowing the key to be absent or
|
|
661
1196
|
* `undefined`.
|
|
662
1197
|
*
|
|
663
|
-
*
|
|
664
|
-
*
|
|
665
|
-
*
|
|
666
|
-
*
|
|
667
|
-
* - Can contain the specified schema type
|
|
1198
|
+
* explicitly set to `undefined`. Equivalent to `optionalKey(UndefinedOr(S))`.
|
|
1199
|
+
*
|
|
1200
|
+
* Use {@link optionalKey} instead if you want exact optional semantics (absent
|
|
1201
|
+
* only, not `undefined`).
|
|
668
1202
|
*
|
|
669
|
-
* **Example** (
|
|
1203
|
+
* **Example** (Optional field accepting undefined)
|
|
670
1204
|
*
|
|
671
1205
|
* ```ts
|
|
672
1206
|
* import { Schema } from "effect"
|
|
673
1207
|
*
|
|
674
1208
|
* const schema = Schema.Struct({
|
|
675
1209
|
* name: Schema.String,
|
|
676
|
-
* age: Schema.
|
|
1210
|
+
* age: Schema.optional(Schema.Number)
|
|
677
1211
|
* })
|
|
678
1212
|
*
|
|
679
|
-
* //
|
|
680
|
-
* type Person = typeof schema
|
|
1213
|
+
* // { readonly name: string; readonly age?: number | undefined }
|
|
1214
|
+
* type Person = typeof schema.Type
|
|
681
1215
|
* ```
|
|
682
1216
|
*
|
|
683
1217
|
* @since 4.0.0
|
|
@@ -688,10 +1222,16 @@ interface requiredLambda extends Lambda {
|
|
|
688
1222
|
readonly "~lambda.out": this["~lambda.in"] extends optional<Top> ? this["~lambda.in"]["schema"]["members"][0] : "Error: schema not eligible for required";
|
|
689
1223
|
}
|
|
690
1224
|
/**
|
|
1225
|
+
* Reverses {@link optional}, returning the inner schema (unwrapping `UndefinedOr`).
|
|
1226
|
+
* Only applicable to schemas already wrapped with `optional`.
|
|
1227
|
+
*
|
|
691
1228
|
* @since 4.0.0
|
|
692
1229
|
*/
|
|
693
1230
|
export declare const required: requiredLambda;
|
|
694
1231
|
/**
|
|
1232
|
+
* Schema type for a mutable struct key. The key's property is writable.
|
|
1233
|
+
* Produced by {@link mutableKey}.
|
|
1234
|
+
*
|
|
695
1235
|
* @since 4.0.0
|
|
696
1236
|
*/
|
|
697
1237
|
export interface mutableKey<S extends Top> extends Bottom<S["Type"], S["Encoded"], S["DecodingServices"], S["EncodingServices"], S["ast"], mutableKey<S>, S["~type.make.in"], S["Iso"], S["~type.parameters"], S["~type.make"], "mutable", S["~type.optionality"], S["~type.constructor.default"], "mutable", S["~encoded.optionality"]> {
|
|
@@ -703,6 +1243,9 @@ interface mutableKeyLambda extends Lambda {
|
|
|
703
1243
|
readonly "~lambda.out": this["~lambda.in"] extends Top ? mutableKey<this["~lambda.in"]> : never;
|
|
704
1244
|
}
|
|
705
1245
|
/**
|
|
1246
|
+
* Makes a struct field mutable (removes the `readonly` modifier on the property).
|
|
1247
|
+
* Use {@link readonlyKey} to reverse.
|
|
1248
|
+
*
|
|
706
1249
|
* @since 4.0.0
|
|
707
1250
|
*/
|
|
708
1251
|
export declare const mutableKey: mutableKeyLambda;
|
|
@@ -711,10 +1254,16 @@ interface readonlyKeyLambda extends Lambda {
|
|
|
711
1254
|
readonly "~lambda.out": this["~lambda.in"] extends mutableKey<Top> ? this["~lambda.in"]["schema"] : "Error: schema not eligible for readonlyKey";
|
|
712
1255
|
}
|
|
713
1256
|
/**
|
|
1257
|
+
* Reverses {@link mutableKey}, returning the inner schema as readonly again.
|
|
1258
|
+
* Only applicable to schemas already wrapped with `mutableKey`.
|
|
1259
|
+
*
|
|
714
1260
|
* @since 4.0.0
|
|
715
1261
|
*/
|
|
716
1262
|
export declare const readonlyKey: readonlyKeyLambda;
|
|
717
1263
|
/**
|
|
1264
|
+
* Schema type that collapses a transformation schema to its decoded `Type` on
|
|
1265
|
+
* both sides (Type = Encoded = S["Type"]). Produced by {@link toType}.
|
|
1266
|
+
*
|
|
718
1267
|
* @since 4.0.0
|
|
719
1268
|
*/
|
|
720
1269
|
export interface toType<S extends Top> extends Bottom<S["Type"], S["Type"], never, never, S["ast"], toType<S>, S["~type.make.in"], S["Iso"], S["~type.parameters"], S["~type.make"], S["~type.mutability"], S["~type.optionality"], S["~type.constructor.default"], S["~encoded.mutability"], S["~encoded.optionality"]> {
|
|
@@ -725,10 +1274,16 @@ interface toTypeLambda extends Lambda {
|
|
|
725
1274
|
readonly "~lambda.out": this["~lambda.in"] extends Top ? toType<this["~lambda.in"]> : never;
|
|
726
1275
|
}
|
|
727
1276
|
/**
|
|
1277
|
+
* Extracts the type-side schema: sets `Encoded` to equal the decoded `Type`,
|
|
1278
|
+
* discarding the encoding transformation path.
|
|
1279
|
+
*
|
|
728
1280
|
* @since 4.0.0
|
|
729
1281
|
*/
|
|
730
1282
|
export declare const toType: toTypeLambda;
|
|
731
1283
|
/**
|
|
1284
|
+
* Schema type that collapses a transformation schema to its `Encoded` side on
|
|
1285
|
+
* both sides (Type = Encoded = S["Encoded"]). Produced by {@link toEncoded}.
|
|
1286
|
+
*
|
|
732
1287
|
* @since 4.0.0
|
|
733
1288
|
*/
|
|
734
1289
|
export interface toEncoded<S extends Top> extends Bottom<S["Encoded"], S["Encoded"], never, never, AST.AST, toEncoded<S>, S["Encoded"], S["Encoded"], ReadonlyArray<Top>, S["Encoded"], S["~type.mutability"], S["~type.optionality"], S["~type.constructor.default"], S["~encoded.mutability"], S["~encoded.optionality"]> {
|
|
@@ -739,11 +1294,17 @@ interface toEncodedLambda extends Lambda {
|
|
|
739
1294
|
readonly "~lambda.out": this["~lambda.in"] extends Top ? toEncoded<this["~lambda.in"]> : never;
|
|
740
1295
|
}
|
|
741
1296
|
/**
|
|
1297
|
+
* Extracts the encoded-side schema: sets `Type` to equal the `Encoded`,
|
|
1298
|
+
* discarding the decoding transformation path.
|
|
1299
|
+
*
|
|
742
1300
|
* @since 4.0.0
|
|
743
1301
|
*/
|
|
744
1302
|
export declare const toEncoded: toEncodedLambda;
|
|
745
1303
|
declare const FlipTypeId = "~effect/Schema/flip";
|
|
746
1304
|
/**
|
|
1305
|
+
* Schema type representing a flipped schema where `Type` and `Encoded` are
|
|
1306
|
+
* swapped. Produced by {@link flip}.
|
|
1307
|
+
*
|
|
747
1308
|
* @since 4.0.0
|
|
748
1309
|
*/
|
|
749
1310
|
export interface flip<S extends Top> extends Bottom<S["Encoded"], S["Type"], S["EncodingServices"], S["DecodingServices"], AST.AST, flip<S>, S["Encoded"], S["Encoded"], ReadonlyArray<Top>, S["Encoded"], S["~encoded.mutability"], S["~encoded.optionality"], ConstructorDefault, S["~type.mutability"], S["~type.optionality"]> {
|
|
@@ -752,10 +1313,26 @@ export interface flip<S extends Top> extends Bottom<S["Encoded"], S["Type"], S["
|
|
|
752
1313
|
readonly schema: S;
|
|
753
1314
|
}
|
|
754
1315
|
/**
|
|
1316
|
+
* Swaps the `Type` and `Encoded` of a schema, inverting the transformation
|
|
1317
|
+
* direction. Calling `flip` twice returns the original schema.
|
|
1318
|
+
*
|
|
1319
|
+
* **Example** (Flip a number-from-string schema)
|
|
1320
|
+
*
|
|
1321
|
+
* ```ts
|
|
1322
|
+
* import { Schema } from "effect"
|
|
1323
|
+
*
|
|
1324
|
+
* // NumberFromString: decodes string → number
|
|
1325
|
+
* const flipped = Schema.flip(Schema.NumberFromString)
|
|
1326
|
+
* // flipped: decodes number → string
|
|
1327
|
+
* ```
|
|
1328
|
+
*
|
|
755
1329
|
* @since 4.0.0
|
|
756
1330
|
*/
|
|
757
1331
|
export declare function flip<S extends Top>(schema: S): S extends flip<infer F> ? F["~rebuild.out"] : flip<S>;
|
|
758
1332
|
/**
|
|
1333
|
+
* Represents a schema for a single literal value.
|
|
1334
|
+
*
|
|
1335
|
+
* @see {@link Literal} for the constructor function.
|
|
759
1336
|
* @since 4.0.0
|
|
760
1337
|
*/
|
|
761
1338
|
export interface Literal<L extends AST.LiteralValue> extends Bottom<L, L, never, never, AST.Literal, Literal<L>> {
|
|
@@ -764,6 +1341,16 @@ export interface Literal<L extends AST.LiteralValue> extends Bottom<L, L, never,
|
|
|
764
1341
|
transform<L2 extends AST.LiteralValue>(to: L2): decodeTo<Literal<L2>, Literal<L>>;
|
|
765
1342
|
}
|
|
766
1343
|
/**
|
|
1344
|
+
* Creates a schema for a single literal value (string, number, bigint, boolean, or null).
|
|
1345
|
+
*
|
|
1346
|
+
* **Example** (String literal)
|
|
1347
|
+
* ```ts
|
|
1348
|
+
* import { Schema } from "effect"
|
|
1349
|
+
*
|
|
1350
|
+
* const schema = Schema.Literal("hello")
|
|
1351
|
+
* // Type: Schema.Literal<"hello">
|
|
1352
|
+
* ```
|
|
1353
|
+
*
|
|
767
1354
|
* @see {@link Literals} for a schema that represents a union of literals.
|
|
768
1355
|
* @see {@link tag} for a schema that represents a literal value that can be
|
|
769
1356
|
* used as a discriminator field in tagged unions and has a constructor default.
|
|
@@ -771,6 +1358,8 @@ export interface Literal<L extends AST.LiteralValue> extends Bottom<L, L, never,
|
|
|
771
1358
|
*/
|
|
772
1359
|
export declare function Literal<L extends AST.LiteralValue>(literal: L): Literal<L>;
|
|
773
1360
|
/**
|
|
1361
|
+
* Namespace for {@link TemplateLiteral} helper types.
|
|
1362
|
+
*
|
|
774
1363
|
* @since 4.0.0
|
|
775
1364
|
*/
|
|
776
1365
|
export declare namespace TemplateLiteral {
|
|
@@ -799,6 +1388,10 @@ export declare namespace TemplateLiteral {
|
|
|
799
1388
|
type Encoded<Parts> = Parts extends readonly [...infer Init, infer Last] ? AppendType<Encoded<Init>, Last> : ``;
|
|
800
1389
|
}
|
|
801
1390
|
/**
|
|
1391
|
+
* Represents a schema that validates strings matching a template literal pattern.
|
|
1392
|
+
* The encoded type is a string formed by concatenating the parts.
|
|
1393
|
+
*
|
|
1394
|
+
* @see {@link TemplateLiteral} for the constructor function.
|
|
802
1395
|
* @since 4.0.0
|
|
803
1396
|
*/
|
|
804
1397
|
export interface TemplateLiteral<Parts extends TemplateLiteral.Parts> extends Bottom<TemplateLiteral.Encoded<Parts>, TemplateLiteral.Encoded<Parts>, never, never, AST.TemplateLiteral, TemplateLiteral<Parts>> {
|
|
@@ -806,10 +1399,24 @@ export interface TemplateLiteral<Parts extends TemplateLiteral.Parts> extends Bo
|
|
|
806
1399
|
readonly parts: Parts;
|
|
807
1400
|
}
|
|
808
1401
|
/**
|
|
809
|
-
*
|
|
810
|
-
|
|
811
|
-
|
|
1402
|
+
* Creates a schema that validates strings matching a template literal pattern. Each part can be
|
|
1403
|
+
* a literal string/number/bigint or a schema whose encoded type is a string, number, or bigint.
|
|
1404
|
+
*
|
|
1405
|
+
* **Example** (URL path pattern)
|
|
1406
|
+
* ```ts
|
|
1407
|
+
* import { Schema } from "effect"
|
|
1408
|
+
*
|
|
1409
|
+
* const schema = Schema.TemplateLiteral(["/user/", Schema.Number])
|
|
1410
|
+
* // matches strings like "/user/123", "/user/42", etc.
|
|
1411
|
+
* ```
|
|
1412
|
+
*
|
|
1413
|
+
* @see {@link TemplateLiteralParser} for a schema that also parses matched parts into a tuple.
|
|
1414
|
+
* @since 4.0.0
|
|
1415
|
+
*/
|
|
1416
|
+
export declare function TemplateLiteral<const Parts extends TemplateLiteral.Parts>(parts: Parts): TemplateLiteral<Parts>;
|
|
812
1417
|
/**
|
|
1418
|
+
* Namespace for {@link TemplateLiteralParser} helper types.
|
|
1419
|
+
*
|
|
813
1420
|
* @since 4.0.0
|
|
814
1421
|
*/
|
|
815
1422
|
export declare namespace TemplateLiteralParser {
|
|
@@ -822,6 +1429,10 @@ export declare namespace TemplateLiteralParser {
|
|
|
822
1429
|
] : [];
|
|
823
1430
|
}
|
|
824
1431
|
/**
|
|
1432
|
+
* Represents a schema that validates strings matching a template literal pattern and decodes
|
|
1433
|
+
* them into a tuple of typed values, one per schema part.
|
|
1434
|
+
*
|
|
1435
|
+
* @see {@link TemplateLiteralParser} for the constructor function.
|
|
825
1436
|
* @since 4.0.0
|
|
826
1437
|
*/
|
|
827
1438
|
export interface TemplateLiteralParser<Parts extends TemplateLiteral.Parts> extends Bottom<TemplateLiteralParser.Type<Parts>, TemplateLiteral.Encoded<Parts>, never, never, AST.Arrays, TemplateLiteralParser<Parts>> {
|
|
@@ -829,10 +1440,26 @@ export interface TemplateLiteralParser<Parts extends TemplateLiteral.Parts> exte
|
|
|
829
1440
|
readonly parts: Parts;
|
|
830
1441
|
}
|
|
831
1442
|
/**
|
|
1443
|
+
* Like {@link TemplateLiteral} but decodes the matched string into a readonly tuple of typed values,
|
|
1444
|
+
* one element per schema part.
|
|
1445
|
+
*
|
|
1446
|
+
* **Example** (Parse path parameters)
|
|
1447
|
+
* ```ts
|
|
1448
|
+
* import { Schema } from "effect"
|
|
1449
|
+
*
|
|
1450
|
+
* const schema = Schema.TemplateLiteralParser(["/user/", Schema.NumberFromString])
|
|
1451
|
+
* // decodes "/user/42" => readonly ["/user/", 42]
|
|
1452
|
+
* ```
|
|
1453
|
+
*
|
|
1454
|
+
* @see {@link TemplateLiteral} for a validation-only version that keeps the string encoded.
|
|
832
1455
|
* @since 4.0.0
|
|
833
1456
|
*/
|
|
834
1457
|
export declare function TemplateLiteralParser<const Parts extends TemplateLiteral.Parts>(parts: Parts): TemplateLiteralParser<Parts>;
|
|
835
1458
|
/**
|
|
1459
|
+
* Represents a schema derived from a TypeScript `const enum` or a plain enum object,
|
|
1460
|
+
* accepting any of its values.
|
|
1461
|
+
*
|
|
1462
|
+
* @see {@link Enum} for the constructor function.
|
|
836
1463
|
* @since 4.0.0
|
|
837
1464
|
*/
|
|
838
1465
|
export interface Enum<A extends {
|
|
@@ -842,176 +1469,262 @@ export interface Enum<A extends {
|
|
|
842
1469
|
readonly enums: A;
|
|
843
1470
|
}
|
|
844
1471
|
/**
|
|
1472
|
+
* Creates a schema from a TypeScript enum object. Validates that the input is one of the enum's values.
|
|
1473
|
+
*
|
|
1474
|
+
* **Example** (Direction enum)
|
|
1475
|
+
* ```ts
|
|
1476
|
+
* import { Schema } from "effect"
|
|
1477
|
+
*
|
|
1478
|
+
* enum Direction {
|
|
1479
|
+
* Up = "Up",
|
|
1480
|
+
* Down = "Down"
|
|
1481
|
+
* }
|
|
1482
|
+
*
|
|
1483
|
+
* const schema = Schema.Enum(Direction)
|
|
1484
|
+
* // accepts "Up" or "Down"
|
|
1485
|
+
* ```
|
|
1486
|
+
*
|
|
845
1487
|
* @since 4.0.0
|
|
846
1488
|
*/
|
|
847
1489
|
export declare function Enum<A extends {
|
|
848
1490
|
[x: string]: string | number;
|
|
849
1491
|
}>(enums: A): Enum<A>;
|
|
850
1492
|
/**
|
|
1493
|
+
* Schema for the `never` type. Always fails validation.
|
|
1494
|
+
*
|
|
1495
|
+
* @see {@link Never} for the schema value.
|
|
851
1496
|
* @since 4.0.0
|
|
852
1497
|
*/
|
|
853
1498
|
export interface Never extends Bottom<never, never, never, never, AST.Never, Never> {
|
|
854
1499
|
readonly "~rebuild.out": this;
|
|
855
1500
|
}
|
|
856
1501
|
/**
|
|
1502
|
+
* Schema for the `never` type. Always fails validation — no value satisfies it.
|
|
1503
|
+
*
|
|
857
1504
|
* @since 4.0.0
|
|
858
1505
|
*/
|
|
859
1506
|
export declare const Never: Never;
|
|
860
1507
|
/**
|
|
1508
|
+
* Schema for the `any` type. Accepts any value without validation.
|
|
1509
|
+
*
|
|
1510
|
+
* @see {@link Any} for the schema value.
|
|
861
1511
|
* @since 4.0.0
|
|
862
1512
|
*/
|
|
863
1513
|
export interface Any extends Bottom<any, any, never, never, AST.Any, Any> {
|
|
864
1514
|
readonly "~rebuild.out": this;
|
|
865
1515
|
}
|
|
866
1516
|
/**
|
|
1517
|
+
* Schema for the `any` type. Accepts any value without validation.
|
|
1518
|
+
*
|
|
1519
|
+
* @see {@link Unknown} for a safer alternative that uses `unknown`.
|
|
867
1520
|
* @since 4.0.0
|
|
868
1521
|
*/
|
|
869
1522
|
export declare const Any: Any;
|
|
870
1523
|
/**
|
|
1524
|
+
* Schema for the `unknown` type. Accepts any value without validation.
|
|
1525
|
+
*
|
|
1526
|
+
* @see {@link Unknown} for the schema value.
|
|
871
1527
|
* @since 4.0.0
|
|
872
1528
|
*/
|
|
873
1529
|
export interface Unknown extends Bottom<unknown, unknown, never, never, AST.Unknown, Unknown> {
|
|
874
1530
|
readonly "~rebuild.out": this;
|
|
875
1531
|
}
|
|
876
1532
|
/**
|
|
1533
|
+
* Schema for the `unknown` type. Accepts any value without validation.
|
|
1534
|
+
*
|
|
1535
|
+
* @see {@link Any} for the `any` variant.
|
|
877
1536
|
* @since 4.0.0
|
|
878
1537
|
*/
|
|
879
1538
|
export declare const Unknown: Unknown;
|
|
880
1539
|
/**
|
|
1540
|
+
* Schema for the `null` literal. Validates that the input is strictly `null`.
|
|
1541
|
+
*
|
|
1542
|
+
* @see {@link Null} for the schema value.
|
|
881
1543
|
* @since 4.0.0
|
|
882
1544
|
*/
|
|
883
1545
|
export interface Null extends Bottom<null, null, never, never, AST.Null, Null> {
|
|
884
1546
|
readonly "~rebuild.out": this;
|
|
885
1547
|
}
|
|
886
1548
|
/**
|
|
1549
|
+
* Schema for the `null` literal. Validates that the input is strictly `null`.
|
|
1550
|
+
*
|
|
1551
|
+
* @see {@link NullOr} for a union with another schema.
|
|
887
1552
|
* @since 4.0.0
|
|
888
1553
|
*/
|
|
889
1554
|
export declare const Null: Null;
|
|
890
1555
|
/**
|
|
1556
|
+
* Schema for the `undefined` literal. Validates that the input is strictly `undefined`.
|
|
1557
|
+
*
|
|
1558
|
+
* @see {@link Undefined} for the schema value.
|
|
891
1559
|
* @since 4.0.0
|
|
892
1560
|
*/
|
|
893
1561
|
export interface Undefined extends Bottom<undefined, undefined, never, never, AST.Undefined, Undefined> {
|
|
894
1562
|
readonly "~rebuild.out": this;
|
|
895
1563
|
}
|
|
896
1564
|
/**
|
|
1565
|
+
* Schema for the `undefined` literal. Validates that the input is strictly `undefined`.
|
|
1566
|
+
*
|
|
1567
|
+
* @see {@link UndefinedOr} for a union with another schema.
|
|
897
1568
|
* @since 4.0.0
|
|
898
1569
|
*/
|
|
899
1570
|
export declare const Undefined: Undefined;
|
|
900
1571
|
/**
|
|
1572
|
+
* Schema for `string` values.
|
|
1573
|
+
*
|
|
1574
|
+
* @see {@link String} for the schema value.
|
|
901
1575
|
* @since 4.0.0
|
|
902
1576
|
*/
|
|
903
1577
|
export interface String extends Bottom<string, string, never, never, AST.String, String> {
|
|
904
1578
|
readonly "~rebuild.out": this;
|
|
905
1579
|
}
|
|
906
1580
|
/**
|
|
907
|
-
*
|
|
1581
|
+
* Schema for `string` values. Validates that the input is `typeof` `"string"`.
|
|
908
1582
|
*
|
|
909
1583
|
* @since 4.0.0
|
|
910
1584
|
*/
|
|
911
1585
|
export declare const String: String;
|
|
912
1586
|
/**
|
|
1587
|
+
* Schema for `number` values, including `NaN`, `Infinity`, and `-Infinity`.
|
|
1588
|
+
*
|
|
1589
|
+
* @see {@link Number} for the schema value.
|
|
913
1590
|
* @since 4.0.0
|
|
914
1591
|
*/
|
|
915
1592
|
export interface Number extends Bottom<number, number, never, never, AST.Number, Number> {
|
|
916
1593
|
readonly "~rebuild.out": this;
|
|
917
1594
|
}
|
|
918
1595
|
/**
|
|
919
|
-
*
|
|
1596
|
+
* Schema for `number` values, including `NaN`, `Infinity`, and `-Infinity`.
|
|
920
1597
|
*
|
|
921
1598
|
* **Default Json Serializer**
|
|
922
1599
|
*
|
|
923
|
-
* -
|
|
924
|
-
* -
|
|
1600
|
+
* - Finite numbers are serialized as numbers.
|
|
1601
|
+
* - Non-finite values are serialized as strings (`"NaN"`, `"Infinity"`, `"-Infinity"`).
|
|
925
1602
|
*
|
|
1603
|
+
* @see {@link Finite} for a schema that excludes non-finite values.
|
|
926
1604
|
* @since 4.0.0
|
|
927
1605
|
*/
|
|
928
1606
|
export declare const Number: Number;
|
|
929
1607
|
/**
|
|
1608
|
+
* Schema for `boolean` values.
|
|
1609
|
+
*
|
|
1610
|
+
* @see {@link Boolean} for the schema value.
|
|
930
1611
|
* @since 4.0.0
|
|
931
1612
|
*/
|
|
932
1613
|
export interface Boolean extends Bottom<boolean, boolean, never, never, AST.Boolean, Boolean> {
|
|
933
1614
|
readonly "~rebuild.out": this;
|
|
934
1615
|
}
|
|
935
1616
|
/**
|
|
936
|
-
*
|
|
1617
|
+
* Schema for `boolean` values. Validates that the input is `typeof` `"boolean"`.
|
|
937
1618
|
*
|
|
938
1619
|
* @category Boolean
|
|
939
1620
|
* @since 4.0.0
|
|
940
1621
|
*/
|
|
941
1622
|
export declare const Boolean: Boolean;
|
|
942
1623
|
/**
|
|
1624
|
+
* Schema for `symbol` values.
|
|
1625
|
+
*
|
|
1626
|
+
* @see {@link Symbol} for the schema value.
|
|
943
1627
|
* @since 4.0.0
|
|
944
1628
|
*/
|
|
945
1629
|
export interface Symbol extends Bottom<symbol, symbol, never, never, AST.Symbol, Symbol> {
|
|
946
1630
|
readonly "~rebuild.out": this;
|
|
947
1631
|
}
|
|
948
1632
|
/**
|
|
949
|
-
*
|
|
1633
|
+
* Schema for `symbol` values. Validates that the input is `typeof` `"symbol"`.
|
|
950
1634
|
*
|
|
1635
|
+
* @see {@link UniqueSymbol} for a schema that matches a specific symbol.
|
|
951
1636
|
* @since 4.0.0
|
|
952
1637
|
*/
|
|
953
1638
|
export declare const Symbol: Symbol;
|
|
954
1639
|
/**
|
|
1640
|
+
* Schema for `bigint` values.
|
|
1641
|
+
*
|
|
1642
|
+
* @see {@link BigInt} for the schema value.
|
|
955
1643
|
* @since 4.0.0
|
|
956
1644
|
*/
|
|
957
1645
|
export interface BigInt extends Bottom<bigint, bigint, never, never, AST.BigInt, BigInt> {
|
|
958
1646
|
readonly "~rebuild.out": this;
|
|
959
1647
|
}
|
|
960
1648
|
/**
|
|
961
|
-
*
|
|
1649
|
+
* Schema for `bigint` values. Validates that the input is `typeof` `"bigint"`.
|
|
962
1650
|
*
|
|
963
1651
|
* @since 4.0.0
|
|
964
1652
|
*/
|
|
965
1653
|
export declare const BigInt: BigInt;
|
|
966
1654
|
/**
|
|
1655
|
+
* Schema for the `void` type.
|
|
1656
|
+
*
|
|
1657
|
+
* @see {@link Void} for the schema value.
|
|
967
1658
|
* @since 4.0.0
|
|
968
1659
|
*/
|
|
969
1660
|
export interface Void extends Bottom<void, void, never, never, AST.Void, Void> {
|
|
970
1661
|
readonly "~rebuild.out": this;
|
|
971
1662
|
}
|
|
972
1663
|
/**
|
|
973
|
-
*
|
|
1664
|
+
* Schema for the `void` type. Accepts `undefined` as the encoded value.
|
|
974
1665
|
*
|
|
975
1666
|
* @since 4.0.0
|
|
976
1667
|
*/
|
|
977
1668
|
export declare const Void: Void;
|
|
978
1669
|
/**
|
|
1670
|
+
* Schema for the `object` type keyword.
|
|
1671
|
+
*
|
|
1672
|
+
* @see {@link ObjectKeyword} for the schema value.
|
|
979
1673
|
* @since 4.0.0
|
|
980
1674
|
*/
|
|
981
1675
|
export interface ObjectKeyword extends Bottom<object, object, never, never, AST.ObjectKeyword, ObjectKeyword> {
|
|
982
1676
|
readonly "~rebuild.out": this;
|
|
983
1677
|
}
|
|
984
1678
|
/**
|
|
985
|
-
*
|
|
1679
|
+
* Schema for the `object` type. Validates that the input is a non-null object or function
|
|
1680
|
+
* (i.e. `typeof value === "object" && value !== null || typeof value === "function"`).
|
|
986
1681
|
*
|
|
987
1682
|
* @since 4.0.0
|
|
988
1683
|
*/
|
|
989
1684
|
export declare const ObjectKeyword: ObjectKeyword;
|
|
990
1685
|
/**
|
|
1686
|
+
* Represents a schema for a specific unique symbol.
|
|
1687
|
+
*
|
|
1688
|
+
* @see {@link UniqueSymbol} for the constructor function.
|
|
991
1689
|
* @since 4.0.0
|
|
992
1690
|
*/
|
|
993
1691
|
export interface UniqueSymbol<sym extends symbol> extends Bottom<sym, sym, never, never, AST.UniqueSymbol, UniqueSymbol<sym>> {
|
|
994
1692
|
readonly "~rebuild.out": this;
|
|
995
1693
|
}
|
|
996
1694
|
/**
|
|
997
|
-
*
|
|
998
|
-
*
|
|
999
|
-
* **Example**
|
|
1695
|
+
* Creates a schema for a specific symbol. Only that exact symbol satisfies the schema.
|
|
1000
1696
|
*
|
|
1697
|
+
* **Example** (Specific symbol)
|
|
1001
1698
|
* ```ts
|
|
1002
1699
|
* import { Schema } from "effect"
|
|
1003
1700
|
*
|
|
1004
|
-
* const
|
|
1005
|
-
* const schema = Schema.UniqueSymbol(
|
|
1701
|
+
* const mySymbol = Symbol.for("mySymbol")
|
|
1702
|
+
* const schema = Schema.UniqueSymbol(mySymbol)
|
|
1006
1703
|
* ```
|
|
1704
|
+
*
|
|
1705
|
+
* @see {@link Symbol} for a schema that accepts any symbol.
|
|
1007
1706
|
* @since 4.0.0
|
|
1008
1707
|
*/
|
|
1009
1708
|
export declare function UniqueSymbol<const sym extends symbol>(symbol: sym): UniqueSymbol<sym>;
|
|
1010
1709
|
/**
|
|
1710
|
+
* Namespace for struct field type utilities.
|
|
1711
|
+
*
|
|
1712
|
+
* These types compute the decoded `Type`, encoded `Encoded`, and constructor
|
|
1713
|
+
* input `MakeIn` of a {@link Struct} from its field map, handling optional,
|
|
1714
|
+
* mutable, and other field modifiers automatically.
|
|
1715
|
+
*
|
|
1716
|
+
* - `Struct.Fields` — constraint for the field map object
|
|
1717
|
+
* - `Struct.Type<F>` — decoded type of the struct
|
|
1718
|
+
* - `Struct.Encoded<F>` — encoded type of the struct
|
|
1719
|
+
* - `Struct.MakeIn<F>` — constructor input (optional/defaulted fields may be omitted)
|
|
1720
|
+
* - `Struct.DecodingServices<F>` / `Struct.EncodingServices<F>` — required services
|
|
1721
|
+
*
|
|
1011
1722
|
* @since 4.0.0
|
|
1012
1723
|
*/
|
|
1013
1724
|
export declare namespace Struct {
|
|
1014
1725
|
/**
|
|
1726
|
+
* Constraint for a struct field map: an object whose values are schemas.
|
|
1727
|
+
*
|
|
1015
1728
|
* @since 4.0.0
|
|
1016
1729
|
*/
|
|
1017
1730
|
type Fields = {
|
|
@@ -1039,7 +1752,7 @@ export declare namespace Struct {
|
|
|
1039
1752
|
/**
|
|
1040
1753
|
* @since 4.0.0
|
|
1041
1754
|
*/
|
|
1042
|
-
type Type<F extends Fields> = Type_<F
|
|
1755
|
+
type Type<F extends Fields> = Simplify<Type_<F>>;
|
|
1043
1756
|
type Iso_<F extends Fields, O extends keyof F = TypeOptionalKeys<F>, M extends keyof F = TypeMutableKeys<F>> = {
|
|
1044
1757
|
readonly [K in Exclude<keyof F, M | O>]: F[K]["Iso"];
|
|
1045
1758
|
} & {
|
|
@@ -1052,7 +1765,7 @@ export declare namespace Struct {
|
|
|
1052
1765
|
/**
|
|
1053
1766
|
* @since 4.0.0
|
|
1054
1767
|
*/
|
|
1055
|
-
type Iso<F extends Fields> = Iso_<F
|
|
1768
|
+
type Iso<F extends Fields> = Simplify<Iso_<F>>;
|
|
1056
1769
|
type EncodedOptionalKeys<Fields extends Struct.Fields> = {
|
|
1057
1770
|
[K in keyof Fields]: Fields[K] extends {
|
|
1058
1771
|
readonly "~encoded.optionality": "optional";
|
|
@@ -1075,7 +1788,7 @@ export declare namespace Struct {
|
|
|
1075
1788
|
/**
|
|
1076
1789
|
* @since 4.0.0
|
|
1077
1790
|
*/
|
|
1078
|
-
type Encoded<F extends Fields> = Encoded_<F
|
|
1791
|
+
type Encoded<F extends Fields> = Simplify<Encoded_<F>>;
|
|
1079
1792
|
/**
|
|
1080
1793
|
* @since 4.0.0
|
|
1081
1794
|
*/
|
|
@@ -1101,13 +1814,34 @@ export declare namespace Struct {
|
|
|
1101
1814
|
/**
|
|
1102
1815
|
* @since 4.0.0
|
|
1103
1816
|
*/
|
|
1104
|
-
type MakeIn<F extends Fields> = MakeIn_<F
|
|
1817
|
+
type MakeIn<F extends Fields> = Simplify<MakeIn_<F>>;
|
|
1105
1818
|
}
|
|
1106
1819
|
/**
|
|
1107
1820
|
* @since 4.0.0
|
|
1108
1821
|
*/
|
|
1109
|
-
export interface Struct<Fields extends Struct.Fields> extends Bottom<
|
|
1822
|
+
export interface Struct<Fields extends Struct.Fields> extends Bottom<Struct.Type<Fields>, Struct.Encoded<Fields>, Struct.DecodingServices<Fields>, Struct.EncodingServices<Fields>, AST.Objects, Struct<Fields>, Struct.MakeIn<Fields>, Struct.Iso<Fields>> {
|
|
1110
1823
|
readonly "~rebuild.out": this;
|
|
1824
|
+
/**
|
|
1825
|
+
* The field definitions of this struct. Spread them into a new struct to
|
|
1826
|
+
* reuse fields across schemas.
|
|
1827
|
+
*
|
|
1828
|
+
* **Example** (Reusing fields across structs)
|
|
1829
|
+
*
|
|
1830
|
+
* ```ts
|
|
1831
|
+
* import { Schema } from "effect"
|
|
1832
|
+
*
|
|
1833
|
+
* const Timestamped = Schema.Struct({
|
|
1834
|
+
* createdAt: Schema.Date,
|
|
1835
|
+
* updatedAt: Schema.Date
|
|
1836
|
+
* })
|
|
1837
|
+
*
|
|
1838
|
+
* const User = Schema.Struct({
|
|
1839
|
+
* ...Timestamped.fields,
|
|
1840
|
+
* name: Schema.String,
|
|
1841
|
+
* email: Schema.String
|
|
1842
|
+
* })
|
|
1843
|
+
* ```
|
|
1844
|
+
*/
|
|
1111
1845
|
readonly fields: Fields;
|
|
1112
1846
|
/**
|
|
1113
1847
|
* Returns a new struct with the fields modified by the provided function.
|
|
@@ -1128,6 +1862,34 @@ export interface Struct<Fields extends Struct.Fields> extends Bottom<Simplify<St
|
|
|
1128
1862
|
} | undefined): Struct<Simplify<Readonly<To>>>;
|
|
1129
1863
|
}
|
|
1130
1864
|
/**
|
|
1865
|
+
* Defines a struct schema from a map of field schemas.
|
|
1866
|
+
*
|
|
1867
|
+
* Each field value is a schema. Use {@link optionalKey} or {@link optional} to
|
|
1868
|
+
* mark fields as optional, and {@link mutableKey} to mark them as mutable.
|
|
1869
|
+
*
|
|
1870
|
+
* The resulting schema's `Type` is a readonly object type with the fields'
|
|
1871
|
+
* decoded types. The `Encoded` form mirrors the field schemas' encoded types.
|
|
1872
|
+
*
|
|
1873
|
+
* **Example** (Basic struct)
|
|
1874
|
+
*
|
|
1875
|
+
* ```ts
|
|
1876
|
+
* import { Schema } from "effect"
|
|
1877
|
+
*
|
|
1878
|
+
* const Person = Schema.Struct({
|
|
1879
|
+
* name: Schema.String,
|
|
1880
|
+
* age: Schema.Number,
|
|
1881
|
+
* email: Schema.optionalKey(Schema.String)
|
|
1882
|
+
* })
|
|
1883
|
+
*
|
|
1884
|
+
* // { readonly name: string; readonly age: number; readonly email?: string }
|
|
1885
|
+
* type Person = typeof Person.Type
|
|
1886
|
+
*
|
|
1887
|
+
* const alice = Schema.decodeUnknownSync(Person)({ name: "Alice", age: 30 })
|
|
1888
|
+
* console.log(alice)
|
|
1889
|
+
* // { name: 'Alice', age: 30 }
|
|
1890
|
+
* ```
|
|
1891
|
+
*
|
|
1892
|
+
* @category Constructors
|
|
1131
1893
|
* @since 4.0.0
|
|
1132
1894
|
*/
|
|
1133
1895
|
export declare function Struct<const Fields extends Struct.Fields>(fields: Fields): Struct<Fields>;
|
|
@@ -1155,13 +1917,60 @@ interface fieldsAssign<NewFields extends Struct.Fields> extends Lambda {
|
|
|
1155
1917
|
*/
|
|
1156
1918
|
export declare function fieldsAssign<const NewFields extends Struct.Fields>(fields: NewFields): fieldsAssign<NewFields>;
|
|
1157
1919
|
/**
|
|
1920
|
+
* Renames struct keys in the encoded form without changing the decoded type.
|
|
1921
|
+
*
|
|
1922
|
+
* Takes a partial mapping `{ decodedKey: encodedKey }` and produces a
|
|
1923
|
+
* transformation schema that decodes from the renamed keys and encodes back to
|
|
1924
|
+
* the renamed keys. Keys not present in the mapping are left unchanged.
|
|
1925
|
+
*
|
|
1926
|
+
* **Example** (Rename `name` to `full_name` in the encoded form)
|
|
1927
|
+
*
|
|
1928
|
+
* ```ts
|
|
1929
|
+
* import { Schema } from "effect"
|
|
1930
|
+
*
|
|
1931
|
+
* const Person = Schema.Struct({ name: Schema.String, age: Schema.Number })
|
|
1932
|
+
* const Encoded = Person.pipe(Schema.encodeKeys({ name: "full_name" }))
|
|
1933
|
+
*
|
|
1934
|
+
* // Decodes { full_name: "Alice", age: 30 } → { name: "Alice", age: 30 }
|
|
1935
|
+
* const alice = Schema.decodeUnknownSync(Encoded)({ full_name: "Alice", age: 30 })
|
|
1936
|
+
* console.log(alice)
|
|
1937
|
+
* // { name: 'Alice', age: 30 }
|
|
1938
|
+
* ```
|
|
1939
|
+
*
|
|
1158
1940
|
* @category Struct transformations
|
|
1159
1941
|
* @since 4.0.0
|
|
1160
1942
|
*/
|
|
1161
|
-
export declare function encodeKeys<S extends
|
|
1943
|
+
export declare function encodeKeys<S extends Top & {
|
|
1944
|
+
readonly fields: Struct.Fields;
|
|
1945
|
+
}, const M extends {
|
|
1162
1946
|
readonly [K in keyof S["fields"]]?: PropertyKey;
|
|
1163
1947
|
}>(mapping: M): (self: S) => decodeTo<S, Struct<{ [K in keyof S["fields"] as K extends keyof M ? M[K] extends PropertyKey ? M[K] : K : K]: toEncoded<S["fields"][K]>; }>>;
|
|
1164
1948
|
/**
|
|
1949
|
+
* Adds derived fields to a struct schema during decoding.
|
|
1950
|
+
*
|
|
1951
|
+
* Each new field is derived from the decoded struct value via a function that
|
|
1952
|
+
* returns `Option`. On encoding the derived fields are stripped. This allows
|
|
1953
|
+
* computed or enriched fields to live in the decoded type without appearing in
|
|
1954
|
+
* the encoded form.
|
|
1955
|
+
*
|
|
1956
|
+
* **Example** (Add a computed `fullName` field)
|
|
1957
|
+
*
|
|
1958
|
+
* ```ts
|
|
1959
|
+
* import { Option, Schema } from "effect"
|
|
1960
|
+
*
|
|
1961
|
+
* const Person = Schema.Struct({ first: Schema.String, last: Schema.String })
|
|
1962
|
+
* const Extended = Person.pipe(
|
|
1963
|
+
* Schema.extendTo(
|
|
1964
|
+
* { fullName: Schema.String },
|
|
1965
|
+
* { fullName: (p) => Option.some(`${p.first} ${p.last}`) }
|
|
1966
|
+
* )
|
|
1967
|
+
* )
|
|
1968
|
+
*
|
|
1969
|
+
* const alice = Schema.decodeUnknownSync(Extended)({ first: "Alice", last: "Smith" })
|
|
1970
|
+
* console.log(alice.fullName)
|
|
1971
|
+
* // Alice Smith
|
|
1972
|
+
* ```
|
|
1973
|
+
*
|
|
1165
1974
|
* @since 4.0.0
|
|
1166
1975
|
* @experimental
|
|
1167
1976
|
*/
|
|
@@ -1173,6 +1982,12 @@ derive: {
|
|
|
1173
1982
|
readonly [K in keyof Fields]: (s: S["Type"]) => Option_.Option<Fields[K]["Type"]>;
|
|
1174
1983
|
}): (self: S) => decodeTo<Struct<Simplify<{ [K in keyof S["fields"]]: toType<S["fields"][K]>; } & Fields>>, S>;
|
|
1175
1984
|
/**
|
|
1985
|
+
* Namespace for `Record` type utilities.
|
|
1986
|
+
*
|
|
1987
|
+
* - `Record.Key` — constraint for the key schema (must encode to `PropertyKey`)
|
|
1988
|
+
* - `Record.Type<K, V>` — decoded type of the record
|
|
1989
|
+
* - `Record.Encoded<K, V>` — encoded type of the record
|
|
1990
|
+
*
|
|
1176
1991
|
* @since 4.0.0
|
|
1177
1992
|
*/
|
|
1178
1993
|
export declare namespace Record {
|
|
@@ -1183,10 +1998,6 @@ export declare namespace Record {
|
|
|
1183
1998
|
readonly "~type.make": PropertyKey;
|
|
1184
1999
|
readonly "Iso": PropertyKey;
|
|
1185
2000
|
}
|
|
1186
|
-
/**
|
|
1187
|
-
* @since 4.0.0
|
|
1188
|
-
*/
|
|
1189
|
-
type Record = Record$<Record.Key, Top>;
|
|
1190
2001
|
/**
|
|
1191
2002
|
* @since 4.0.0
|
|
1192
2003
|
*/
|
|
@@ -1269,14 +2080,35 @@ export declare namespace Record {
|
|
|
1269
2080
|
};
|
|
1270
2081
|
}
|
|
1271
2082
|
/**
|
|
2083
|
+
* Schema type for a key-value record (map) with a typed key and value schema.
|
|
2084
|
+
* Produced by {@link Record}.
|
|
2085
|
+
*
|
|
1272
2086
|
* @since 4.0.0
|
|
1273
2087
|
*/
|
|
1274
|
-
export interface Record
|
|
2088
|
+
export interface $Record<Key extends Record.Key, Value extends Top> extends Bottom<Record.Type<Key, Value>, Record.Encoded<Key, Value>, Record.DecodingServices<Key, Value>, Record.EncodingServices<Key, Value>, AST.Objects, $Record<Key, Value>, Simplify<Record.MakeIn<Key, Value>>, Record.Iso<Key, Value>> {
|
|
1275
2089
|
readonly "~rebuild.out": this;
|
|
1276
2090
|
readonly key: Key;
|
|
1277
2091
|
readonly value: Value;
|
|
1278
2092
|
}
|
|
1279
2093
|
/**
|
|
2094
|
+
* Defines a record (dictionary) schema with typed keys and values.
|
|
2095
|
+
*
|
|
2096
|
+
* **Example** (String-keyed record of numbers)
|
|
2097
|
+
*
|
|
2098
|
+
* ```ts
|
|
2099
|
+
* import { Schema } from "effect"
|
|
2100
|
+
*
|
|
2101
|
+
* const schema = Schema.Record(Schema.String, Schema.Number)
|
|
2102
|
+
*
|
|
2103
|
+
* // { readonly [x: string]: number }
|
|
2104
|
+
* type R = typeof schema.Type
|
|
2105
|
+
*
|
|
2106
|
+
* const result = Schema.decodeUnknownSync(schema)({ a: 1, b: 2 })
|
|
2107
|
+
* console.log(result)
|
|
2108
|
+
* // { a: 1, b: 2 }
|
|
2109
|
+
* ```
|
|
2110
|
+
*
|
|
2111
|
+
* @category Constructors
|
|
1280
2112
|
* @since 4.0.0
|
|
1281
2113
|
*/
|
|
1282
2114
|
export declare function Record<Key extends Record.Key, Value extends Top>(key: Key, value: Value, options?: {
|
|
@@ -1284,8 +2116,13 @@ export declare function Record<Key extends Record.Key, Value extends Top>(key: K
|
|
|
1284
2116
|
readonly decode?: Combiner.Combiner<readonly [Key["Type"], Value["Type"]]> | undefined;
|
|
1285
2117
|
readonly encode?: Combiner.Combiner<readonly [Key["Encoded"], Value["Encoded"]]> | undefined;
|
|
1286
2118
|
};
|
|
1287
|
-
}): Record
|
|
2119
|
+
}): $Record<Key, Value>;
|
|
1288
2120
|
/**
|
|
2121
|
+
* Namespace for `StructWithRest` type utilities.
|
|
2122
|
+
*
|
|
2123
|
+
* - `StructWithRest.Type<S, R>` — decoded type (struct type intersected with record types)
|
|
2124
|
+
* - `StructWithRest.Encoded<S, R>` — encoded type
|
|
2125
|
+
*
|
|
1289
2126
|
* @since 4.0.0
|
|
1290
2127
|
*/
|
|
1291
2128
|
export declare namespace StructWithRest {
|
|
@@ -1298,7 +2135,7 @@ export declare namespace StructWithRest {
|
|
|
1298
2135
|
/**
|
|
1299
2136
|
* @since 4.0.0
|
|
1300
2137
|
*/
|
|
1301
|
-
type Records = ReadonlyArray<Record.
|
|
2138
|
+
type Records = ReadonlyArray<$Record<Record.Key, Top>>;
|
|
1302
2139
|
type MergeTuple<T extends ReadonlyArray<unknown>> = T extends readonly [infer Head, ...infer Tail] ? Head & MergeTuple<Tail> : {};
|
|
1303
2140
|
/**
|
|
1304
2141
|
* @since 4.0.0
|
|
@@ -1338,6 +2175,9 @@ export declare namespace StructWithRest {
|
|
|
1338
2175
|
}>;
|
|
1339
2176
|
}
|
|
1340
2177
|
/**
|
|
2178
|
+
* Schema type for a struct combined with one or more record schemas. Produced
|
|
2179
|
+
* by {@link StructWithRest}.
|
|
2180
|
+
*
|
|
1341
2181
|
* @since 4.0.0
|
|
1342
2182
|
*/
|
|
1343
2183
|
export interface StructWithRest<S extends StructWithRest.Objects, Records extends StructWithRest.Records> extends Bottom<Simplify<StructWithRest.Type<S, Records>>, Simplify<StructWithRest.Encoded<S, Records>>, StructWithRest.DecodingServices<S, Records>, StructWithRest.EncodingServices<S, Records>, AST.Objects, StructWithRest<S, Records>, Simplify<StructWithRest.MakeIn<S, Records>>, Simplify<StructWithRest.Iso<S, Records>>> {
|
|
@@ -1346,10 +2186,35 @@ export interface StructWithRest<S extends StructWithRest.Objects, Records extend
|
|
|
1346
2186
|
readonly records: Records;
|
|
1347
2187
|
}
|
|
1348
2188
|
/**
|
|
2189
|
+
* Extends a struct schema with one or more record (index-signature) schemas,
|
|
2190
|
+
* producing a schema whose decoded type intersects the struct and all records.
|
|
2191
|
+
*
|
|
2192
|
+
* **Example** (Struct with string-indexed extra keys)
|
|
2193
|
+
*
|
|
2194
|
+
* ```ts
|
|
2195
|
+
* import { Schema } from "effect"
|
|
2196
|
+
*
|
|
2197
|
+
* const schema = Schema.StructWithRest(
|
|
2198
|
+
* Schema.Struct({ id: Schema.Number }),
|
|
2199
|
+
* [Schema.Record(Schema.String, Schema.String)]
|
|
2200
|
+
* )
|
|
2201
|
+
*
|
|
2202
|
+
* // { readonly id: number } & { readonly [x: string]: string }
|
|
2203
|
+
* type T = typeof schema.Type
|
|
2204
|
+
* ```
|
|
2205
|
+
*
|
|
2206
|
+
* @category Constructors
|
|
1349
2207
|
* @since 4.0.0
|
|
1350
2208
|
*/
|
|
1351
2209
|
export declare function StructWithRest<const S extends StructWithRest.Objects, const Records extends StructWithRest.Records>(schema: S, records: Records): StructWithRest<S, Records>;
|
|
1352
2210
|
/**
|
|
2211
|
+
* Namespace for `Tuple` type utilities.
|
|
2212
|
+
*
|
|
2213
|
+
* - `Tuple.Elements` — constraint for the element schema array
|
|
2214
|
+
* - `Tuple.Type<E>` — decoded tuple type
|
|
2215
|
+
* - `Tuple.Encoded<E>` — encoded tuple type
|
|
2216
|
+
* - `Tuple.MakeIn<E>` — constructor input tuple
|
|
2217
|
+
*
|
|
1353
2218
|
* @since 4.0.0
|
|
1354
2219
|
*/
|
|
1355
2220
|
export declare namespace Tuple {
|
|
@@ -1405,6 +2270,8 @@ export declare namespace Tuple {
|
|
|
1405
2270
|
type MakeIn<E extends Elements> = MakeIn_<E>;
|
|
1406
2271
|
}
|
|
1407
2272
|
/**
|
|
2273
|
+
* Schema type for a fixed-length tuple. Produced by {@link Tuple}.
|
|
2274
|
+
*
|
|
1408
2275
|
* @since 4.0.0
|
|
1409
2276
|
*/
|
|
1410
2277
|
export interface Tuple<Elements extends Tuple.Elements> extends Bottom<Tuple.Type<Elements>, Tuple.Encoded<Elements>, Tuple.DecodingServices<Elements>, Tuple.EncodingServices<Elements>, AST.Arrays, Tuple<Elements>, Tuple.MakeIn<Elements>, Tuple.Iso<Elements>> {
|
|
@@ -1429,11 +2296,32 @@ export interface Tuple<Elements extends Tuple.Elements> extends Bottom<Tuple.Typ
|
|
|
1429
2296
|
} | undefined): Tuple<Simplify<Readonly<To>>>;
|
|
1430
2297
|
}
|
|
1431
2298
|
/**
|
|
2299
|
+
* Defines a fixed-length tuple schema from an array of element schemas.
|
|
2300
|
+
*
|
|
2301
|
+
* **Example** (Pair of string and number)
|
|
2302
|
+
*
|
|
2303
|
+
* ```ts
|
|
2304
|
+
* import { Schema } from "effect"
|
|
2305
|
+
*
|
|
2306
|
+
* const schema = Schema.Tuple([Schema.String, Schema.Number])
|
|
2307
|
+
*
|
|
2308
|
+
* const pair = Schema.decodeUnknownSync(schema)(["hello", 42])
|
|
2309
|
+
* console.log(pair)
|
|
2310
|
+
* // [ 'hello', 42 ]
|
|
2311
|
+
* ```
|
|
2312
|
+
*
|
|
1432
2313
|
* @category Constructors
|
|
1433
2314
|
* @since 4.0.0
|
|
1434
2315
|
*/
|
|
1435
2316
|
export declare function Tuple<const Elements extends ReadonlyArray<Top>>(elements: Elements): Tuple<Elements>;
|
|
1436
2317
|
/**
|
|
2318
|
+
* Namespace for `TupleWithRest` type utilities.
|
|
2319
|
+
*
|
|
2320
|
+
* - `TupleWithRest.TupleType` — constraint for the leading tuple schema
|
|
2321
|
+
* - `TupleWithRest.Rest` — the rest element schema(s)
|
|
2322
|
+
* - `TupleWithRest.Type<T, R>` — decoded type (fixed elements + rest)
|
|
2323
|
+
* - `TupleWithRest.Encoded<T, R>` — encoded type
|
|
2324
|
+
*
|
|
1437
2325
|
* @since 4.0.0
|
|
1438
2326
|
*/
|
|
1439
2327
|
export declare namespace TupleWithRest {
|
|
@@ -1493,6 +2381,9 @@ export declare namespace TupleWithRest {
|
|
|
1493
2381
|
] : M;
|
|
1494
2382
|
}
|
|
1495
2383
|
/**
|
|
2384
|
+
* Schema type for a tuple with additional rest elements. Produced by
|
|
2385
|
+
* {@link TupleWithRest}.
|
|
2386
|
+
*
|
|
1496
2387
|
* @since 4.0.0
|
|
1497
2388
|
*/
|
|
1498
2389
|
export interface TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest> extends Bottom<TupleWithRest.Type<S["Type"], Rest>, TupleWithRest.Encoded<S["Encoded"], Rest>, S["DecodingServices"] | Rest[number]["DecodingServices"], S["EncodingServices"] | Rest[number]["EncodingServices"], AST.Arrays, TupleWithRest<S, Rest>, TupleWithRest.MakeIn<S["~type.make"], Rest>, TupleWithRest.Iso<S["Iso"], Rest>> {
|
|
@@ -1501,27 +2392,71 @@ export interface TupleWithRest<S extends TupleWithRest.TupleType, Rest extends T
|
|
|
1501
2392
|
readonly rest: Rest;
|
|
1502
2393
|
}
|
|
1503
2394
|
/**
|
|
2395
|
+
* Extends a fixed-length tuple schema with rest elements, creating a variadic
|
|
2396
|
+
* tuple that starts with the fixed elements and ends with zero or more rest
|
|
2397
|
+
* elements.
|
|
2398
|
+
*
|
|
2399
|
+
* **Example** (Tuple with rest)
|
|
2400
|
+
*
|
|
2401
|
+
* ```ts
|
|
2402
|
+
* import { Schema } from "effect"
|
|
2403
|
+
*
|
|
2404
|
+
* // [string, number, ...boolean[]]
|
|
2405
|
+
* const schema = Schema.TupleWithRest(
|
|
2406
|
+
* Schema.Tuple([Schema.String, Schema.Number]),
|
|
2407
|
+
* [Schema.Boolean]
|
|
2408
|
+
* )
|
|
2409
|
+
*
|
|
2410
|
+
* const result = Schema.decodeUnknownSync(schema)(["hello", 1, true, false])
|
|
2411
|
+
* console.log(result)
|
|
2412
|
+
* // [ 'hello', 1, true, false ]
|
|
2413
|
+
* ```
|
|
2414
|
+
*
|
|
1504
2415
|
* @category Constructors
|
|
1505
2416
|
* @since 4.0.0
|
|
1506
2417
|
*/
|
|
1507
2418
|
export declare function TupleWithRest<S extends Tuple<Tuple.Elements>, const Rest extends TupleWithRest.Rest>(schema: S, rest: Rest): TupleWithRest<S, Rest>;
|
|
1508
2419
|
/**
|
|
2420
|
+
* Schema type for a `ReadonlyArray`. Produced by {@link ArraySchema}.
|
|
2421
|
+
*
|
|
1509
2422
|
* @since 4.0.0
|
|
1510
2423
|
*/
|
|
1511
|
-
export interface Array
|
|
2424
|
+
export interface $Array<S extends Top> extends Bottom<ReadonlyArray<S["Type"]>, ReadonlyArray<S["Encoded"]>, S["DecodingServices"], S["EncodingServices"], AST.Arrays, $Array<S>, ReadonlyArray<S["~type.make"]>, ReadonlyArray<S["Iso"]>> {
|
|
1512
2425
|
readonly "~rebuild.out": this;
|
|
1513
2426
|
readonly schema: S;
|
|
1514
2427
|
}
|
|
1515
2428
|
interface ArrayLambda extends Lambda {
|
|
1516
|
-
<S extends Top>(self: S): Array
|
|
1517
|
-
readonly "~lambda.out": this["~lambda.in"] extends Top ? Array
|
|
2429
|
+
<S extends Top>(self: S): $Array<S>;
|
|
2430
|
+
readonly "~lambda.out": this["~lambda.in"] extends Top ? $Array<this["~lambda.in"]> : never;
|
|
1518
2431
|
}
|
|
1519
2432
|
/**
|
|
1520
2433
|
* @category Constructors
|
|
1521
2434
|
* @since 4.0.0
|
|
1522
2435
|
*/
|
|
1523
|
-
|
|
2436
|
+
declare const ArraySchema: ArrayLambda;
|
|
2437
|
+
export {
|
|
2438
|
+
/**
|
|
2439
|
+
* Defines a `ReadonlyArray` schema for a given element schema.
|
|
2440
|
+
*
|
|
2441
|
+
* **Example** (Array of strings)
|
|
2442
|
+
*
|
|
2443
|
+
* ```ts
|
|
2444
|
+
* import { Schema } from "effect"
|
|
2445
|
+
*
|
|
2446
|
+
* const schema = Schema.Array(Schema.String)
|
|
2447
|
+
*
|
|
2448
|
+
* const result = Schema.decodeUnknownSync(schema)(["a", "b", "c"])
|
|
2449
|
+
* console.log(result)
|
|
2450
|
+
* // [ 'a', 'b', 'c' ]
|
|
2451
|
+
* ```
|
|
2452
|
+
*
|
|
2453
|
+
* @category Constructors
|
|
2454
|
+
* @since 4.0.0
|
|
2455
|
+
*/
|
|
2456
|
+
ArraySchema as Array };
|
|
1524
2457
|
/**
|
|
2458
|
+
* Schema type for a non-empty `ReadonlyArray`. Produced by {@link NonEmptyArray}.
|
|
2459
|
+
*
|
|
1525
2460
|
* @since 4.0.0
|
|
1526
2461
|
*/
|
|
1527
2462
|
export interface NonEmptyArray<S extends Top> extends Bottom<readonly [S["Type"], ...Array<S["Type"]>], readonly [S["Encoded"], ...Array<S["Encoded"]>], S["DecodingServices"], S["EncodingServices"], AST.Arrays, NonEmptyArray<S>, readonly [S["~type.make"], ...Array<S["~type.make"]>], readonly [S["Iso"], ...Array<S["Iso"]>]> {
|
|
@@ -1533,14 +2468,51 @@ interface NonEmptyArrayLambda extends Lambda {
|
|
|
1533
2468
|
readonly "~lambda.out": this["~lambda.in"] extends Top ? NonEmptyArray<this["~lambda.in"]> : never;
|
|
1534
2469
|
}
|
|
1535
2470
|
/**
|
|
2471
|
+
* Defines a non-empty `ReadonlyArray` schema — at least one element required.
|
|
2472
|
+
* Type is `readonly [T, ...T[]]`.
|
|
2473
|
+
*
|
|
2474
|
+
* **Example** (Non-empty array of numbers)
|
|
2475
|
+
*
|
|
2476
|
+
* ```ts
|
|
2477
|
+
* import { Schema } from "effect"
|
|
2478
|
+
*
|
|
2479
|
+
* const schema = Schema.NonEmptyArray(Schema.Number)
|
|
2480
|
+
*
|
|
2481
|
+
* Schema.decodeUnknownSync(schema)([1, 2, 3]) // ok
|
|
2482
|
+
* Schema.decodeUnknownSync(schema)([]) // throws
|
|
2483
|
+
* ```
|
|
2484
|
+
*
|
|
1536
2485
|
* @category Constructors
|
|
1537
2486
|
* @since 4.0.0
|
|
1538
2487
|
*/
|
|
1539
2488
|
export declare const NonEmptyArray: NonEmptyArrayLambda;
|
|
1540
2489
|
/**
|
|
2490
|
+
* @category Arrays
|
|
2491
|
+
* @since 4.0.0
|
|
2492
|
+
*/
|
|
2493
|
+
export interface ArrayEnsure<S extends Top> extends decodeTo<$Array<toType<S>>, Union<readonly [S, $Array<S>]>> {
|
|
2494
|
+
}
|
|
2495
|
+
/**
|
|
2496
|
+
* Decodes a single value or an array of values into an array.
|
|
2497
|
+
*
|
|
2498
|
+
* Decoding:
|
|
2499
|
+
* - a single value is decoded as a one-element array
|
|
2500
|
+
* - an array is decoded as-is
|
|
2501
|
+
*
|
|
2502
|
+
* Encoding:
|
|
2503
|
+
* - a one-element array is encoded as a single value
|
|
2504
|
+
* - arrays with more than one element are encoded as arrays
|
|
2505
|
+
*
|
|
2506
|
+
* @category Arrays
|
|
2507
|
+
* @since 4.0.0
|
|
2508
|
+
*/
|
|
2509
|
+
export declare function ArrayEnsure<S extends Top>(schema: S): ArrayEnsure<S>;
|
|
2510
|
+
/**
|
|
2511
|
+
* Schema type for an array with unique elements. Produced by {@link UniqueArray}.
|
|
2512
|
+
*
|
|
1541
2513
|
* @since 4.0.0
|
|
1542
2514
|
*/
|
|
1543
|
-
export interface UniqueArray<S extends Top> extends Array
|
|
2515
|
+
export interface UniqueArray<S extends Top> extends $Array<S> {
|
|
1544
2516
|
}
|
|
1545
2517
|
/**
|
|
1546
2518
|
* Returns a new array schema that ensures all elements are unique.
|
|
@@ -1553,6 +2525,9 @@ export interface UniqueArray<S extends Top> extends Array$<S> {
|
|
|
1553
2525
|
*/
|
|
1554
2526
|
export declare function UniqueArray<S extends Top>(item: S): UniqueArray<S>;
|
|
1555
2527
|
/**
|
|
2528
|
+
* Schema type that makes array or tuple elements mutable (removes `readonly`).
|
|
2529
|
+
* Produced by {@link mutable}.
|
|
2530
|
+
*
|
|
1556
2531
|
* @since 4.0.0
|
|
1557
2532
|
*/
|
|
1558
2533
|
export interface mutable<S extends Top & {
|
|
@@ -1570,12 +2545,25 @@ interface mutableLambda extends Lambda {
|
|
|
1570
2545
|
} ? mutable<this["~lambda.in"]> : "Error: schema not eligible for mutable";
|
|
1571
2546
|
}
|
|
1572
2547
|
/**
|
|
1573
|
-
* Makes
|
|
2548
|
+
* Makes an array or tuple schema mutable, removing the `readonly` modifier.
|
|
2549
|
+
*
|
|
2550
|
+
* **Example** (Mutable array)
|
|
2551
|
+
*
|
|
2552
|
+
* ```ts
|
|
2553
|
+
* import { Schema } from "effect"
|
|
2554
|
+
*
|
|
2555
|
+
* const schema = Schema.mutable(Schema.Array(Schema.Number))
|
|
2556
|
+
*
|
|
2557
|
+
* // number[] (mutable)
|
|
2558
|
+
* type T = typeof schema.Type
|
|
2559
|
+
* ```
|
|
1574
2560
|
*
|
|
1575
2561
|
* @since 4.0.0
|
|
1576
2562
|
*/
|
|
1577
2563
|
export declare const mutable: mutableLambda;
|
|
1578
2564
|
/**
|
|
2565
|
+
* Schema type for a union of multiple schemas. Produced by {@link Union}.
|
|
2566
|
+
*
|
|
1579
2567
|
* @since 4.0.0
|
|
1580
2568
|
*/
|
|
1581
2569
|
export interface Union<Members extends ReadonlyArray<Top>> extends Bottom<{
|
|
@@ -1614,12 +2602,23 @@ export interface Union<Members extends ReadonlyArray<Top>> extends Bottom<{
|
|
|
1614
2602
|
} | undefined): Union<Simplify<Readonly<To>>>;
|
|
1615
2603
|
}
|
|
1616
2604
|
/**
|
|
1617
|
-
* Creates a schema
|
|
2605
|
+
* Creates a union schema from an array of member schemas. Members are tested in
|
|
2606
|
+
* order; the first match is returned.
|
|
2607
|
+
*
|
|
2608
|
+
* Optionally, specify `mode`:
|
|
2609
|
+
* - `"anyOf"` (default) — matches if any member matches.
|
|
2610
|
+
* - `"oneOf"` — matches if exactly one member matches.
|
|
2611
|
+
*
|
|
2612
|
+
* **Example** (String or number union)
|
|
1618
2613
|
*
|
|
1619
|
-
*
|
|
2614
|
+
* ```ts
|
|
2615
|
+
* import { Schema } from "effect"
|
|
1620
2616
|
*
|
|
1621
|
-
*
|
|
1622
|
-
*
|
|
2617
|
+
* const schema = Schema.Union([Schema.String, Schema.Number])
|
|
2618
|
+
*
|
|
2619
|
+
* Schema.decodeUnknownSync(schema)("hello") // "hello"
|
|
2620
|
+
* Schema.decodeUnknownSync(schema)(42) // 42
|
|
2621
|
+
* ```
|
|
1623
2622
|
*
|
|
1624
2623
|
* @category Constructors
|
|
1625
2624
|
* @since 4.0.0
|
|
@@ -1628,6 +2627,9 @@ export declare function Union<const Members extends ReadonlyArray<Top>>(members:
|
|
|
1628
2627
|
mode?: "anyOf" | "oneOf";
|
|
1629
2628
|
}): Union<Members>;
|
|
1630
2629
|
/**
|
|
2630
|
+
* Represents a union schema of multiple literal values.
|
|
2631
|
+
*
|
|
2632
|
+
* @see {@link Literals} for the constructor function.
|
|
1631
2633
|
* @since 4.0.0
|
|
1632
2634
|
*/
|
|
1633
2635
|
export interface Literals<L extends ReadonlyArray<AST.LiteralValue>> extends Bottom<L[number], L[number], never, never, AST.Union<AST.Literal>, Literals<L>> {
|
|
@@ -1648,12 +2650,24 @@ export interface Literals<L extends ReadonlyArray<AST.LiteralValue>> extends Bot
|
|
|
1648
2650
|
}>;
|
|
1649
2651
|
}
|
|
1650
2652
|
/**
|
|
2653
|
+
* Creates a union schema from an array of literal values.
|
|
2654
|
+
*
|
|
2655
|
+
* **Example** (Status codes)
|
|
2656
|
+
* ```ts
|
|
2657
|
+
* import { Schema } from "effect"
|
|
2658
|
+
*
|
|
2659
|
+
* const schema = Schema.Literals(["active", "inactive", "pending"])
|
|
2660
|
+
* // accepts "active", "inactive", or "pending"
|
|
2661
|
+
* ```
|
|
2662
|
+
*
|
|
1651
2663
|
* @see {@link Literal} for a schema that represents a single literal.
|
|
1652
2664
|
* @category Constructors
|
|
1653
2665
|
* @since 4.0.0
|
|
1654
2666
|
*/
|
|
1655
2667
|
export declare function Literals<const L extends ReadonlyArray<AST.LiteralValue>>(literals: L): Literals<L>;
|
|
1656
2668
|
/**
|
|
2669
|
+
* Schema type for `S | null`. Produced by {@link NullOr}.
|
|
2670
|
+
*
|
|
1657
2671
|
* @since 4.0.0
|
|
1658
2672
|
*/
|
|
1659
2673
|
export interface NullOr<S extends Top> extends Union<readonly [S, Null]> {
|
|
@@ -1663,11 +2677,15 @@ interface NullOrLambda extends Lambda {
|
|
|
1663
2677
|
readonly "~lambda.out": this["~lambda.in"] extends Top ? NullOr<this["~lambda.in"]> : never;
|
|
1664
2678
|
}
|
|
1665
2679
|
/**
|
|
2680
|
+
* Creates a union schema of `S | null`.
|
|
2681
|
+
*
|
|
1666
2682
|
* @category Constructors
|
|
1667
2683
|
* @since 4.0.0
|
|
1668
2684
|
*/
|
|
1669
2685
|
export declare const NullOr: NullOrLambda;
|
|
1670
2686
|
/**
|
|
2687
|
+
* Schema type for `S | undefined`. Produced by {@link UndefinedOr}.
|
|
2688
|
+
*
|
|
1671
2689
|
* @since 4.0.0
|
|
1672
2690
|
*/
|
|
1673
2691
|
export interface UndefinedOr<S extends Top> extends Union<readonly [S, Undefined]> {
|
|
@@ -1677,11 +2695,14 @@ interface UndefinedOrLambda extends Lambda {
|
|
|
1677
2695
|
readonly "~lambda.out": this["~lambda.in"] extends Top ? UndefinedOr<this["~lambda.in"]> : never;
|
|
1678
2696
|
}
|
|
1679
2697
|
/**
|
|
2698
|
+
* Creates a union schema of `S | undefined`.
|
|
2699
|
+
*
|
|
1680
2700
|
* @category Constructors
|
|
1681
2701
|
* @since 4.0.0
|
|
1682
2702
|
*/
|
|
1683
2703
|
export declare const UndefinedOr: UndefinedOrLambda;
|
|
1684
2704
|
/**
|
|
2705
|
+
* Schema type for `S | null | undefined`. Produced by {@link NullishOr}.
|
|
1685
2706
|
* @since 4.0.0
|
|
1686
2707
|
*/
|
|
1687
2708
|
export interface NullishOr<S extends Top> extends Union<readonly [S, Null, Undefined]> {
|
|
@@ -1691,11 +2712,13 @@ interface NullishOrLambda extends Lambda {
|
|
|
1691
2712
|
readonly "~lambda.out": this["~lambda.in"] extends Top ? NullishOr<this["~lambda.in"]> : never;
|
|
1692
2713
|
}
|
|
1693
2714
|
/**
|
|
2715
|
+
* Creates a union schema of `S | null | undefined`.
|
|
1694
2716
|
* @category Constructors
|
|
1695
2717
|
* @since 4.0.0
|
|
1696
2718
|
*/
|
|
1697
2719
|
export declare const NullishOr: NullishOrLambda;
|
|
1698
2720
|
/**
|
|
2721
|
+
* Schema type wrapping a lazily-evaluated schema. Produced by {@link suspend}.
|
|
1699
2722
|
* @since 4.0.0
|
|
1700
2723
|
*/
|
|
1701
2724
|
export interface suspend<S extends Top> extends Bottom<S["Type"], S["Encoded"], S["DecodingServices"], S["EncodingServices"], AST.Suspend, suspend<S>, S["~type.make.in"], S["Iso"], S["~type.parameters"], S["~type.make"], S["~type.mutability"], S["~type.optionality"], S["~type.constructor.default"], S["~encoded.mutability"], S["~encoded.optionality"]> {
|
|
@@ -1706,16 +2729,46 @@ export interface suspend<S extends Top> extends Bottom<S["Type"], S["Encoded"],
|
|
|
1706
2729
|
* essential for creating recursive schemas where a schema references itself,
|
|
1707
2730
|
* preventing infinite recursion during schema definition.
|
|
1708
2731
|
*
|
|
2732
|
+
* **Example** (Recursive tree schema)
|
|
2733
|
+
* ```ts
|
|
2734
|
+
* import { Schema } from "effect"
|
|
2735
|
+
*
|
|
2736
|
+
* interface Tree {
|
|
2737
|
+
* readonly value: number
|
|
2738
|
+
* readonly children: ReadonlyArray<Tree>
|
|
2739
|
+
* }
|
|
2740
|
+
*
|
|
2741
|
+
* const Tree = Schema.Struct({
|
|
2742
|
+
* value: Schema.Number,
|
|
2743
|
+
* children: Schema.Array(Schema.suspend((): Schema.Codec<Tree> => Tree))
|
|
2744
|
+
* })
|
|
2745
|
+
* ```
|
|
2746
|
+
*
|
|
1709
2747
|
* @category Constructors
|
|
1710
2748
|
* @since 4.0.0
|
|
1711
2749
|
*/
|
|
1712
2750
|
export declare function suspend<S extends Top>(f: () => S): suspend<S>;
|
|
1713
2751
|
/**
|
|
2752
|
+
* Pipeable function that attaches one or more filter checks to a schema without
|
|
2753
|
+
* changing the TypeScript type.
|
|
2754
|
+
*
|
|
2755
|
+
* **Example** (Adding checks to a schema)
|
|
2756
|
+
* ```ts
|
|
2757
|
+
* import { Schema } from "effect"
|
|
2758
|
+
*
|
|
2759
|
+
* const AgeSchema = Schema.Number.pipe(
|
|
2760
|
+
* Schema.check(Schema.isGreaterThanOrEqualTo(0), Schema.isLessThanOrEqualTo(120))
|
|
2761
|
+
* )
|
|
2762
|
+
* ```
|
|
2763
|
+
*
|
|
1714
2764
|
* @category Filtering
|
|
1715
2765
|
* @since 4.0.0
|
|
1716
2766
|
*/
|
|
1717
2767
|
export declare function check<S extends Top>(...checks: readonly [AST.Check<S["Type"]>, ...Array<AST.Check<S["Type"]>>]): (self: S) => S["~rebuild.out"];
|
|
1718
2768
|
/**
|
|
2769
|
+
* The output type of {@link refine}, narrowing the schema's `Type` to `T` via a
|
|
2770
|
+
* type guard.
|
|
2771
|
+
*
|
|
1719
2772
|
* @since 4.0.0
|
|
1720
2773
|
*/
|
|
1721
2774
|
export interface refine<T extends S["Type"], S extends Top> extends Bottom<T, S["Encoded"], S["DecodingServices"], S["EncodingServices"], S["ast"], refine<T, S>, S["~type.make.in"], T, S["~type.parameters"], T, S["~type.mutability"], S["~type.optionality"], S["~type.constructor.default"], S["~encoded.mutability"], S["~encoded.optionality"]> {
|
|
@@ -1723,12 +2776,18 @@ export interface refine<T extends S["Type"], S extends Top> extends Bottom<T, S[
|
|
|
1723
2776
|
readonly schema: S;
|
|
1724
2777
|
}
|
|
1725
2778
|
/**
|
|
2779
|
+
* Narrows the TypeScript type of a schema's output via a type guard predicate,
|
|
2780
|
+
* attaching the guard as a runtime filter check.
|
|
2781
|
+
*
|
|
1726
2782
|
* @category Filtering
|
|
1727
2783
|
* @since 4.0.0
|
|
1728
2784
|
*/
|
|
1729
2785
|
export declare function refine<S extends Top, T extends S["Type"]>(refinement: (value: S["Type"]) => value is T, annotations?: Annotations.Filter): (schema: S) => refine<T, S>;
|
|
1730
2786
|
type DistributeBrands<B> = UnionToIntersection<B extends infer U extends string ? Brand.Brand<U> : never>;
|
|
1731
2787
|
/**
|
|
2788
|
+
* The output type of {@link brand}, intersecting the schema's `Type` with one or
|
|
2789
|
+
* more {@link Brand.Brand} tags.
|
|
2790
|
+
*
|
|
1732
2791
|
* @since 4.0.0
|
|
1733
2792
|
*/
|
|
1734
2793
|
export interface brand<S extends Top, B> extends Bottom<S["Type"] & DistributeBrands<B>, S["Encoded"], S["DecodingServices"], S["EncodingServices"], S["ast"], brand<S, B>, S["~type.make.in"], S["Type"] & DistributeBrands<B>, S["~type.parameters"], S["Type"] & DistributeBrands<B>, S["~type.mutability"], S["~type.optionality"], S["~type.constructor.default"], S["~encoded.mutability"], S["~encoded.optionality"]> {
|
|
@@ -1737,20 +2796,30 @@ export interface brand<S extends Top, B> extends Bottom<S["Type"] & DistributeBr
|
|
|
1737
2796
|
readonly identifier: string;
|
|
1738
2797
|
}
|
|
1739
2798
|
/**
|
|
1740
|
-
* Adds a brand to a schema
|
|
2799
|
+
* Adds a nominal brand to a schema, intersecting the output type with
|
|
2800
|
+
* `Brand.Brand<B>` to prevent accidental mixing of structurally identical types.
|
|
1741
2801
|
*
|
|
1742
2802
|
* @category Branding
|
|
1743
2803
|
* @since 4.0.0
|
|
1744
2804
|
*/
|
|
1745
2805
|
export declare function brand<B extends string>(identifier: B): <S extends Top>(schema: S) => brand<S["~rebuild.out"], B>;
|
|
1746
2806
|
/**
|
|
1747
|
-
* @
|
|
2807
|
+
* Creates a branded schema from a {@link Brand.Constructor}, applying the
|
|
2808
|
+
* constructor's checks and brand tag to the underlying schema.
|
|
2809
|
+
*
|
|
2810
|
+
* @category Branding
|
|
1748
2811
|
* @since 4.0.0
|
|
1749
2812
|
*/
|
|
1750
2813
|
export declare function fromBrand<A extends Brand.Brand<any>>(identifier: string, ctor: Brand.Constructor<A>): <S extends Top & {
|
|
1751
2814
|
readonly "Type": Brand.Brand.Unbranded<A>;
|
|
1752
2815
|
}>(self: S) => brand<S["~rebuild.out"], Brand.Brand.Keys<A>>;
|
|
1753
2816
|
/**
|
|
2817
|
+
* A schema that wraps another schema and intercepts its decoding pipeline.
|
|
2818
|
+
*
|
|
2819
|
+
* The interceptor receives the full decoding `Effect` and may replace, modify,
|
|
2820
|
+
* or augment it — including adding service requirements via `RD`.
|
|
2821
|
+
*
|
|
2822
|
+
* @see {@link middlewareDecoding} for the constructor
|
|
1754
2823
|
* @since 4.0.0
|
|
1755
2824
|
*/
|
|
1756
2825
|
export interface middlewareDecoding<S extends Top, RD> extends Bottom<S["Type"], S["Encoded"], RD, S["EncodingServices"], S["ast"], middlewareDecoding<S, RD>, S["~type.make.in"], S["Iso"], S["~type.parameters"], S["~type.make"], S["~type.mutability"], S["~type.optionality"], S["~type.constructor.default"], S["~encoded.mutability"], S["~encoded.optionality"]> {
|
|
@@ -1758,10 +2827,35 @@ export interface middlewareDecoding<S extends Top, RD> extends Bottom<S["Type"],
|
|
|
1758
2827
|
readonly schema: S;
|
|
1759
2828
|
}
|
|
1760
2829
|
/**
|
|
2830
|
+
* Intercepts the decoding pipeline of a schema.
|
|
2831
|
+
*
|
|
2832
|
+
* The provided function receives the current decoding `Effect` and `ParseOptions`,
|
|
2833
|
+
* and returns a new `Effect` — potentially adding service requirements (`RD`),
|
|
2834
|
+
* recovering from errors, or augmenting the result.
|
|
2835
|
+
*
|
|
2836
|
+
* **Example** (Logging decode failures)
|
|
2837
|
+
*
|
|
2838
|
+
* ```ts
|
|
2839
|
+
* import { Effect, Schema } from "effect"
|
|
2840
|
+
*
|
|
2841
|
+
* const Logged = Schema.String.pipe(
|
|
2842
|
+
* Schema.middlewareDecoding((effect) =>
|
|
2843
|
+
* Effect.tapError(effect, (issue) => Effect.log("decode failed", issue))
|
|
2844
|
+
* )
|
|
2845
|
+
* )
|
|
2846
|
+
* ```
|
|
2847
|
+
*
|
|
2848
|
+
* @see {@link catchDecoding} for a simpler error-recovery variant
|
|
1761
2849
|
* @since 4.0.0
|
|
1762
2850
|
*/
|
|
1763
2851
|
export declare function middlewareDecoding<S extends Top, RD>(decode: (effect: Effect.Effect<Option_.Option<S["Type"]>, Issue.Issue, S["DecodingServices"]>, options: AST.ParseOptions) => Effect.Effect<Option_.Option<S["Type"]>, Issue.Issue, RD>): (schema: S) => middlewareDecoding<S, RD>;
|
|
1764
2852
|
/**
|
|
2853
|
+
* A schema that wraps another schema and intercepts its encoding pipeline.
|
|
2854
|
+
*
|
|
2855
|
+
* The interceptor receives the full encoding `Effect` and may replace, modify,
|
|
2856
|
+
* or augment it — including adding service requirements via `RE`.
|
|
2857
|
+
*
|
|
2858
|
+
* @see {@link middlewareEncoding} for the constructor
|
|
1765
2859
|
* @since 4.0.0
|
|
1766
2860
|
*/
|
|
1767
2861
|
export interface middlewareEncoding<S extends Top, RE> extends Bottom<S["Type"], S["Encoded"], S["DecodingServices"], RE, S["ast"], middlewareEncoding<S, RE>, S["~type.make.in"], S["Iso"], S["~type.parameters"], S["~type.make"], S["~type.mutability"], S["~type.optionality"], S["~type.constructor.default"], S["~encoded.mutability"], S["~encoded.optionality"]> {
|
|
@@ -1769,26 +2863,77 @@ export interface middlewareEncoding<S extends Top, RE> extends Bottom<S["Type"],
|
|
|
1769
2863
|
readonly schema: S;
|
|
1770
2864
|
}
|
|
1771
2865
|
/**
|
|
2866
|
+
* Intercepts the encoding pipeline of a schema.
|
|
2867
|
+
*
|
|
2868
|
+
* The provided function receives the current encoding `Effect` and `ParseOptions`,
|
|
2869
|
+
* and returns a new `Effect` — potentially adding service requirements (`RE`),
|
|
2870
|
+
* recovering from errors, or augmenting the result.
|
|
2871
|
+
*
|
|
2872
|
+
* **Example** (Logging encode failures)
|
|
2873
|
+
*
|
|
2874
|
+
* ```ts
|
|
2875
|
+
* import { Effect, Schema } from "effect"
|
|
2876
|
+
*
|
|
2877
|
+
* const Logged = Schema.String.pipe(
|
|
2878
|
+
* Schema.middlewareEncoding((effect) =>
|
|
2879
|
+
* Effect.tapError(effect, (issue) => Effect.log("encode failed", issue))
|
|
2880
|
+
* )
|
|
2881
|
+
* )
|
|
2882
|
+
* ```
|
|
2883
|
+
*
|
|
2884
|
+
* @see {@link catchEncoding} for a simpler error-recovery variant
|
|
1772
2885
|
* @since 4.0.0
|
|
1773
2886
|
*/
|
|
1774
2887
|
export declare function middlewareEncoding<S extends Top, RE>(encode: (effect: Effect.Effect<Option_.Option<S["Encoded"]>, Issue.Issue, S["EncodingServices"]>, options: AST.ParseOptions) => Effect.Effect<Option_.Option<S["Encoded"]>, Issue.Issue, RE>): (schema: S) => middlewareEncoding<S, RE>;
|
|
1775
2888
|
/**
|
|
1776
|
-
*
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
*
|
|
1781
|
-
|
|
2889
|
+
* Recovers from a decoding error by providing a fallback value.
|
|
2890
|
+
*
|
|
2891
|
+
* The handler receives the `Issue` and returns an `Effect` that either
|
|
2892
|
+
* succeeds with a fallback value or re-fails with a (possibly different) issue.
|
|
2893
|
+
*
|
|
2894
|
+
* **Example** (Returning a default on decode failure)
|
|
2895
|
+
*
|
|
2896
|
+
* ```ts
|
|
2897
|
+
* import { Effect, Option, Schema } from "effect"
|
|
2898
|
+
*
|
|
2899
|
+
* const schema = Schema.Number.pipe(
|
|
2900
|
+
* Schema.catchDecoding((_issue) => Effect.succeed(Option.some(0)))
|
|
2901
|
+
* )
|
|
2902
|
+
* ```
|
|
2903
|
+
*
|
|
2904
|
+
* @see {@link catchDecodingWithContext} to add service requirements to the handler
|
|
2905
|
+
* @since 4.0.0
|
|
2906
|
+
*/
|
|
2907
|
+
export declare function catchDecoding<S extends Top>(f: (issue: Issue.Issue) => Effect.Effect<Option_.Option<S["Type"]>, Issue.Issue>): (self: S) => S["~rebuild.out"];
|
|
2908
|
+
/**
|
|
2909
|
+
* Like {@link catchDecoding}, but the handler may require Effect services (`R`).
|
|
2910
|
+
*
|
|
2911
|
+
* @since 4.0.0
|
|
2912
|
+
*/
|
|
1782
2913
|
export declare function catchDecodingWithContext<S extends Top, R = never>(f: (issue: Issue.Issue) => Effect.Effect<Option_.Option<S["Type"]>, Issue.Issue, R>): (self: S) => middlewareDecoding<S, S["DecodingServices"] | R>;
|
|
1783
2914
|
/**
|
|
2915
|
+
* Recovers from an encoding error by providing a fallback value.
|
|
2916
|
+
*
|
|
2917
|
+
* The handler receives the `Issue` and returns an `Effect` that either
|
|
2918
|
+
* succeeds with a fallback value or re-fails with a (possibly different) issue.
|
|
2919
|
+
*
|
|
2920
|
+
* @see {@link catchEncodingWithContext} to add service requirements to the handler
|
|
1784
2921
|
* @since 4.0.0
|
|
1785
2922
|
*/
|
|
1786
2923
|
export declare function catchEncoding<S extends Top>(f: (issue: Issue.Issue) => Effect.Effect<Option_.Option<S["Encoded"]>, Issue.Issue>): (self: S) => S["~rebuild.out"];
|
|
1787
2924
|
/**
|
|
2925
|
+
* Like {@link catchEncoding}, but the handler may require Effect services (`R`).
|
|
2926
|
+
*
|
|
1788
2927
|
* @since 4.0.0
|
|
1789
2928
|
*/
|
|
1790
2929
|
export declare function catchEncodingWithContext<S extends Top, R = never>(f: (issue: Issue.Issue) => Effect.Effect<Option_.Option<S["Encoded"]>, Issue.Issue, R>): (self: S) => middlewareEncoding<S, S["EncodingServices"] | R>;
|
|
1791
2930
|
/**
|
|
2931
|
+
* The type produced by {@link decodeTo} when a custom transformation is provided.
|
|
2932
|
+
*
|
|
2933
|
+
* - `Type` is `To["Type"]`, `Encoded` is `From["Encoded"]`
|
|
2934
|
+
* - Decoding services from both `from` and `to` are combined
|
|
2935
|
+
*
|
|
2936
|
+
* @see {@link compose} for the passthrough (no transformation) variant
|
|
1792
2937
|
* @since 4.0.0
|
|
1793
2938
|
*/
|
|
1794
2939
|
export interface decodeTo<To extends Top, From extends Top, RD = never, RE = never> extends Bottom<To["Type"], From["Encoded"], To["DecodingServices"] | From["DecodingServices"] | RD, To["EncodingServices"] | From["EncodingServices"] | RE, To["ast"], decodeTo<To, From, RD, RE>, To["~type.make.in"], To["Iso"], To["~type.parameters"], To["~type.make"], To["~type.mutability"], To["~type.optionality"], To["~type.constructor.default"], From["~encoded.mutability"], From["~encoded.optionality"]> {
|
|
@@ -1797,6 +2942,12 @@ export interface decodeTo<To extends Top, From extends Top, RD = never, RE = nev
|
|
|
1797
2942
|
readonly to: To;
|
|
1798
2943
|
}
|
|
1799
2944
|
/**
|
|
2945
|
+
* The type produced by {@link decodeTo} when called without a custom transformation (passthrough composition).
|
|
2946
|
+
*
|
|
2947
|
+
* Equivalent to {@link decodeTo} with `RD = never` and `RE = never`, meaning the schemas
|
|
2948
|
+
* are composed using their natural encoding/decoding chain.
|
|
2949
|
+
*
|
|
2950
|
+
* @see {@link decodeTo} for the transformation variant
|
|
1800
2951
|
* @since 4.0.0
|
|
1801
2952
|
*/
|
|
1802
2953
|
export interface compose<To extends Top, From extends Top> extends decodeTo<To, From> {
|
|
@@ -1890,6 +3041,25 @@ export declare function decode<S extends Top, RD = never, RE = never>(transforma
|
|
|
1890
3041
|
readonly encode: Getter.Getter<S["Type"], S["Type"], RE>;
|
|
1891
3042
|
}): (self: S) => decodeTo<toType<S>, S, RD, RE>;
|
|
1892
3043
|
/**
|
|
3044
|
+
* Like {@link decodeTo} but reverses the direction: the `from` schema acts as the target (decoded type)
|
|
3045
|
+
* and `to` acts as the encoded source.
|
|
3046
|
+
*
|
|
3047
|
+
* `encodeTo(to)(from)` is equivalent to `to.pipe(decodeTo(from))` — useful when it reads more
|
|
3048
|
+
* naturally to specify the encoded schema first.
|
|
3049
|
+
*
|
|
3050
|
+
* **Example** (Encode a number back to string)
|
|
3051
|
+
*
|
|
3052
|
+
* ```ts
|
|
3053
|
+
* import { Schema, SchemaGetter } from "effect"
|
|
3054
|
+
*
|
|
3055
|
+
* const NumberFromString = Schema.Number.pipe(
|
|
3056
|
+
* Schema.encodeTo(Schema.String, {
|
|
3057
|
+
* decode: SchemaGetter.transform((s: string) => Number(s)),
|
|
3058
|
+
* encode: SchemaGetter.transform((n: number) => String(n))
|
|
3059
|
+
* })
|
|
3060
|
+
* )
|
|
3061
|
+
* ```
|
|
3062
|
+
*
|
|
1893
3063
|
* @since 4.0.0
|
|
1894
3064
|
*/
|
|
1895
3065
|
export declare function encodeTo<To extends Top>(to: To): <From extends Top>(from: From) => decodeTo<From, To>;
|
|
@@ -1898,6 +3068,25 @@ export declare function encodeTo<To extends Top, From extends Top, RD = never, R
|
|
|
1898
3068
|
readonly encode: Getter.Getter<NoInfer<To["Type"]>, NoInfer<From["Encoded"]>, RE>;
|
|
1899
3069
|
}): (from: From) => decodeTo<From, To, RD, RE>;
|
|
1900
3070
|
/**
|
|
3071
|
+
* Applies a transformation to a schema's encoded type, creating a new schema where encoding/decoding
|
|
3072
|
+
* operate on `S["Encoded"]` rather than `S["Type"]`.
|
|
3073
|
+
*
|
|
3074
|
+
* The `decode` getter maps `S["Encoded"]` → `S["Encoded"]` (applied during decoding),
|
|
3075
|
+
* and the `encode` getter maps `S["Encoded"]` → `S["Encoded"]` (applied during encoding).
|
|
3076
|
+
*
|
|
3077
|
+
* **Example** (Upper-casing encoded strings)
|
|
3078
|
+
*
|
|
3079
|
+
* ```ts
|
|
3080
|
+
* import { Schema, SchemaGetter } from "effect"
|
|
3081
|
+
*
|
|
3082
|
+
* const UpperFromLower = Schema.String.pipe(
|
|
3083
|
+
* Schema.encode({
|
|
3084
|
+
* decode: SchemaGetter.transform((s: string) => s.toLowerCase()),
|
|
3085
|
+
* encode: SchemaGetter.transform((s: string) => s.toUpperCase())
|
|
3086
|
+
* })
|
|
3087
|
+
* )
|
|
3088
|
+
* ```
|
|
3089
|
+
*
|
|
1901
3090
|
* @since 4.0.0
|
|
1902
3091
|
*/
|
|
1903
3092
|
export declare function encode<S extends Top, RD = never, RE = never>(transformation: {
|
|
@@ -1905,12 +3094,19 @@ export declare function encode<S extends Top, RD = never, RE = never>(transforma
|
|
|
1905
3094
|
readonly encode: Getter.Getter<S["Encoded"], S["Encoded"], RE>;
|
|
1906
3095
|
}): (self: S) => decodeTo<S, toEncoded<S>, RD, RE>;
|
|
1907
3096
|
/**
|
|
3097
|
+
* Constraint used to ensure a schema field does not already have a constructor default.
|
|
3098
|
+
*
|
|
3099
|
+
* Only schemas that satisfy this constraint can be passed to {@link withConstructorDefault}.
|
|
3100
|
+
*
|
|
1908
3101
|
* @since 4.0.0
|
|
1909
3102
|
*/
|
|
1910
3103
|
export interface WithoutConstructorDefault {
|
|
1911
3104
|
readonly "~type.constructor.default": "no-default";
|
|
1912
3105
|
}
|
|
1913
3106
|
/**
|
|
3107
|
+
* The type produced by {@link withConstructorDefault} — a schema with `"~type.constructor.default": "with-default"`.
|
|
3108
|
+
*
|
|
3109
|
+
* @see {@link withConstructorDefault} for the constructor
|
|
1914
3110
|
* @since 4.0.0
|
|
1915
3111
|
*/
|
|
1916
3112
|
export interface withConstructorDefault<S extends Top & WithoutConstructorDefault> extends Bottom<S["Type"], S["Encoded"], S["DecodingServices"], S["EncodingServices"], S["ast"], withConstructorDefault<S>, S["~type.make.in"], S["Iso"], S["~type.parameters"], S["~type.make"], S["~type.mutability"], S["~type.optionality"], "with-default", S["~encoded.mutability"], S["~encoded.optionality"]> {
|
|
@@ -1918,15 +3114,50 @@ export interface withConstructorDefault<S extends Top & WithoutConstructorDefaul
|
|
|
1918
3114
|
readonly schema: S;
|
|
1919
3115
|
}
|
|
1920
3116
|
/**
|
|
3117
|
+
* Attaches a constructor default value to a schema field.
|
|
3118
|
+
*
|
|
3119
|
+
* The `defaultValue` function receives `Option.some(undefined)` when the field is
|
|
3120
|
+
* explicitly set to `undefined`, or `Option.none()` when the field is absent.
|
|
3121
|
+
* Return `Option.some(value)` to supply a default, or `Option.none()` to leave the
|
|
3122
|
+
* field required. An `Effect` may be returned for async or service-dependent defaults.
|
|
3123
|
+
*
|
|
3124
|
+
* Constructor defaults are applied only during `makeUnsafe` / `make`, not during
|
|
3125
|
+
* decoding or encoding.
|
|
3126
|
+
*
|
|
3127
|
+
* **Example** (Optional field with a static default)
|
|
3128
|
+
*
|
|
3129
|
+
* ```ts
|
|
3130
|
+
* import { Option, Schema } from "effect"
|
|
3131
|
+
*
|
|
3132
|
+
* const MySchema = Schema.Struct({
|
|
3133
|
+
* name: Schema.String.pipe(
|
|
3134
|
+
* Schema.optionalKey,
|
|
3135
|
+
* Schema.withConstructorDefault(() => Option.some("anonymous"))
|
|
3136
|
+
* )
|
|
3137
|
+
* })
|
|
3138
|
+
*
|
|
3139
|
+
* const value = MySchema.makeUnsafe({})
|
|
3140
|
+
* // value: { name: "anonymous" }
|
|
3141
|
+
* ```
|
|
3142
|
+
*
|
|
1921
3143
|
* @since 4.0.0
|
|
1922
3144
|
*/
|
|
1923
3145
|
export declare function withConstructorDefault<S extends Top & WithoutConstructorDefault>(defaultValue: (input: Option_.Option<undefined>) => Option_.Option<S["~type.make.in"]> | Effect.Effect<Option_.Option<S["~type.make.in"]>>): (schema: S) => withConstructorDefault<S>;
|
|
1924
3146
|
/**
|
|
3147
|
+
* The type produced by {@link withDecodingDefaultKey} — a schema that decodes from an `optionalKey` encoded source.
|
|
3148
|
+
*
|
|
3149
|
+
* @see {@link withDecodingDefaultKey} for the constructor
|
|
1925
3150
|
* @since 4.0.0
|
|
1926
3151
|
*/
|
|
1927
3152
|
export interface withDecodingDefaultKey<S extends Top> extends decodeTo<S, optionalKey<toEncoded<S>>> {
|
|
1928
3153
|
}
|
|
1929
3154
|
/**
|
|
3155
|
+
* Options for {@link withDecodingDefaultKey} and {@link withDecodingDefault}.
|
|
3156
|
+
*
|
|
3157
|
+
* - `encodingStrategy`:
|
|
3158
|
+
* - `"passthrough"` (default): pass the value through during encoding
|
|
3159
|
+
* - `"omit"`: omit the key from the encoded output
|
|
3160
|
+
*
|
|
1930
3161
|
* @since 4.0.0
|
|
1931
3162
|
*/
|
|
1932
3163
|
export type DecodingDefaultOptions = {
|
|
@@ -1939,10 +3170,34 @@ export type DecodingDefaultOptions = {
|
|
|
1939
3170
|
* - `passthrough`: (default) Pass the default value through to the output.
|
|
1940
3171
|
* - `omit`: Omit the value from the output.
|
|
1941
3172
|
*
|
|
3173
|
+
* Provides a default value for a missing key during decoding.
|
|
3174
|
+
*
|
|
3175
|
+
* When the key is absent from the input, `defaultValue()` is called to supply a value.
|
|
3176
|
+
* During encoding, the behavior is controlled by `options.encodingStrategy`:
|
|
3177
|
+
* - `"passthrough"` (default): include the value in the output
|
|
3178
|
+
* - `"omit"`: omit the key from the output
|
|
3179
|
+
*
|
|
3180
|
+
* **Example** (Default for a missing struct key)
|
|
3181
|
+
*
|
|
3182
|
+
* ```ts
|
|
3183
|
+
* import { Schema } from "effect"
|
|
3184
|
+
*
|
|
3185
|
+
* const MySchema = Schema.Struct({
|
|
3186
|
+
* name: Schema.String.pipe(Schema.withDecodingDefaultKey(() => "anonymous"))
|
|
3187
|
+
* })
|
|
3188
|
+
*
|
|
3189
|
+
* const result = Schema.decodeUnknownSync(MySchema)({})
|
|
3190
|
+
* // result: { name: "anonymous" }
|
|
3191
|
+
* ```
|
|
3192
|
+
*
|
|
3193
|
+
* @see {@link withDecodingDefault} for the `optional` (value-level) variant
|
|
1942
3194
|
* @since 4.0.0
|
|
1943
3195
|
*/
|
|
1944
3196
|
export declare function withDecodingDefaultKey<S extends Top>(defaultValue: () => S["Encoded"], options?: DecodingDefaultOptions): (self: S) => withDecodingDefaultKey<S>;
|
|
1945
3197
|
/**
|
|
3198
|
+
* The type produced by {@link withDecodingDefault} — a schema that decodes from an `optional` encoded source.
|
|
3199
|
+
*
|
|
3200
|
+
* @see {@link withDecodingDefault} for the constructor
|
|
1946
3201
|
* @since 4.0.0
|
|
1947
3202
|
*/
|
|
1948
3203
|
export interface withDecodingDefault<S extends Top> extends decodeTo<S, optional<toEncoded<S>>> {
|
|
@@ -1954,34 +3209,93 @@ export interface withDecodingDefault<S extends Top> extends decodeTo<S, optional
|
|
|
1954
3209
|
* - `passthrough`: (default) Pass the default value through to the output.
|
|
1955
3210
|
* - `omit`: Omit the value from the output.
|
|
1956
3211
|
*
|
|
3212
|
+
* Provides a default value for an `optional` field during decoding.
|
|
3213
|
+
*
|
|
3214
|
+
* Similar to {@link withDecodingDefaultKey} but works on `optional` (value-level optional)
|
|
3215
|
+
* rather than `optionalKey` (key-level optional).
|
|
3216
|
+
*
|
|
3217
|
+
* When the value is `undefined` or absent, `defaultValue()` is called to supply a value.
|
|
3218
|
+
* During encoding, the behavior is controlled by `options.encodingStrategy`:
|
|
3219
|
+
* - `"passthrough"` (default): include the value in the output
|
|
3220
|
+
* - `"omit"`: omit the value from the output
|
|
3221
|
+
*
|
|
3222
|
+
* **Example** (Default for an optional field value)
|
|
3223
|
+
*
|
|
3224
|
+
* ```ts
|
|
3225
|
+
* import { Schema } from "effect"
|
|
3226
|
+
*
|
|
3227
|
+
* const MySchema = Schema.Struct({
|
|
3228
|
+
* name: Schema.String.pipe(Schema.optional, Schema.withDecodingDefault(() => "anonymous"))
|
|
3229
|
+
* })
|
|
3230
|
+
*
|
|
3231
|
+
* const result = Schema.decodeUnknownSync(MySchema)({ name: undefined })
|
|
3232
|
+
* // result: { name: "anonymous" }
|
|
3233
|
+
* ```
|
|
3234
|
+
*
|
|
3235
|
+
* @see {@link withDecodingDefaultKey} for the key-level variant
|
|
1957
3236
|
* @since 4.0.0
|
|
1958
3237
|
*/
|
|
1959
3238
|
export declare function withDecodingDefault<S extends Top>(defaultValue: () => S["Encoded"], options?: DecodingDefaultOptions): (self: S) => withDecodingDefault<S>;
|
|
1960
3239
|
/**
|
|
3240
|
+
* The type produced by {@link tag} — a literal schema with a constructor default.
|
|
3241
|
+
*
|
|
3242
|
+
* Used as the type of the `_tag` field in {@link TaggedStruct} and related helpers.
|
|
3243
|
+
*
|
|
3244
|
+
* @see {@link tag} for the constructor
|
|
1961
3245
|
* @since 4.0.0
|
|
1962
3246
|
*/
|
|
1963
3247
|
export interface tag<Tag extends AST.LiteralValue> extends withConstructorDefault<Literal<Tag>> {
|
|
1964
3248
|
}
|
|
1965
3249
|
/**
|
|
1966
|
-
*
|
|
1967
|
-
*
|
|
3250
|
+
* Combines a {@link Literal} schema with {@link withConstructorDefault}, making it ideal
|
|
3251
|
+
* for discriminator fields in tagged unions. When constructing via `makeUnsafe`, the
|
|
3252
|
+
* `_tag` field can be omitted and will be filled automatically.
|
|
3253
|
+
*
|
|
3254
|
+
* **Example** (Discriminated union tag)
|
|
3255
|
+
*
|
|
3256
|
+
* ```ts
|
|
3257
|
+
* import { Schema } from "effect"
|
|
3258
|
+
*
|
|
3259
|
+
* const A = Schema.Struct({ _tag: Schema.tag("A"), value: Schema.Number })
|
|
1968
3260
|
*
|
|
1969
|
-
*
|
|
1970
|
-
*
|
|
1971
|
-
*
|
|
1972
|
-
*
|
|
3261
|
+
* // _tag is optional in makeUnsafe, auto-filled to "A"
|
|
3262
|
+
* const a = A.makeUnsafe({ value: 42 })
|
|
3263
|
+
* // a: { _tag: "A", value: 42 }
|
|
3264
|
+
* ```
|
|
1973
3265
|
*
|
|
3266
|
+
* @see {@link tagDefaultOmit} to also omit the tag during encoding
|
|
3267
|
+
* @see {@link TaggedStruct} for a shorthand that adds `_tag` automatically
|
|
1974
3268
|
* @since 4.0.0
|
|
1975
3269
|
*/
|
|
1976
3270
|
export declare function tag<Tag extends AST.LiteralValue>(literal: Tag): tag<Tag>;
|
|
1977
3271
|
/**
|
|
1978
|
-
*
|
|
1979
|
-
* the
|
|
3272
|
+
* Like {@link tag}, but additionally omits the tag field from the encoded output.
|
|
3273
|
+
* Useful when the encoded form (e.g. JSON) does not include the discriminator key,
|
|
3274
|
+
* but the decoded type and constructor still need it.
|
|
3275
|
+
*
|
|
3276
|
+
* **Example** (Tag omitted during encoding)
|
|
3277
|
+
*
|
|
3278
|
+
* ```ts
|
|
3279
|
+
* import { Schema } from "effect"
|
|
3280
|
+
*
|
|
3281
|
+
* const A = Schema.Struct({
|
|
3282
|
+
* _tag: Schema.tagDefaultOmit("A"),
|
|
3283
|
+
* value: Schema.Number
|
|
3284
|
+
* })
|
|
3285
|
+
*
|
|
3286
|
+
* // Encode strips the _tag field
|
|
3287
|
+
* const encoded = Schema.encodeUnknownSync(A)({ _tag: "A", value: 1 })
|
|
3288
|
+
* // encoded: { value: 1 }
|
|
3289
|
+
* ```
|
|
1980
3290
|
*
|
|
3291
|
+
* @see {@link tag} for the variant that keeps the tag during encoding
|
|
1981
3292
|
* @since 4.0.0
|
|
1982
3293
|
*/
|
|
1983
3294
|
export declare function tagDefaultOmit<Tag extends AST.LiteralValue>(literal: Tag): withDecodingDefaultKey<tag<Tag>>;
|
|
1984
3295
|
/**
|
|
3296
|
+
* The type produced by {@link TaggedStruct} — a {@link Struct} with an extra `_tag` field of type {@link tag}.
|
|
3297
|
+
*
|
|
3298
|
+
* @see {@link TaggedStruct} for the constructor
|
|
1985
3299
|
* @since 4.0.0
|
|
1986
3300
|
*/
|
|
1987
3301
|
export type TaggedStruct<Tag extends AST.LiteralValue, Fields extends Struct.Fields> = Struct<Simplify<{
|
|
@@ -2053,15 +3367,18 @@ type TaggedUnionUtils<Tag extends PropertyKey, Members extends ReadonlyArray<Top
|
|
|
2053
3367
|
[M in Flattened[number] as M["Type"][Tag]]: (u: unknown) => u is M["Type"];
|
|
2054
3368
|
};
|
|
2055
3369
|
readonly match: {
|
|
2056
|
-
<
|
|
2057
|
-
[M in Flattened[number] as M["Type"][Tag]]: (value: M["Type"]) =>
|
|
2058
|
-
}):
|
|
2059
|
-
<
|
|
2060
|
-
[M in Flattened[number] as M["Type"][Tag]]: (value: M["Type"]) =>
|
|
2061
|
-
}): (value: Members[number]["Type"]) =>
|
|
3370
|
+
<Cases extends {
|
|
3371
|
+
[M in Flattened[number] as M["Type"][Tag]]: (value: M["Type"]) => any;
|
|
3372
|
+
}>(value: Members[number]["Type"], cases: Cases): Cases[keyof Cases] extends (value: any) => infer R ? Unify<R> : never;
|
|
3373
|
+
<Cases extends {
|
|
3374
|
+
[M in Flattened[number] as M["Type"][Tag]]: (value: M["Type"]) => any;
|
|
3375
|
+
}>(cases: Cases): (value: Members[number]["Type"]) => Cases[keyof Cases] extends (value: any) => infer R ? Unify<R> : never;
|
|
2062
3376
|
};
|
|
2063
3377
|
};
|
|
2064
3378
|
/**
|
|
3379
|
+
* The type produced by {@link toTaggedUnion} — a {@link Union} augmented with `cases`, `guards`, `isAnyOf`, and `match` utilities.
|
|
3380
|
+
*
|
|
3381
|
+
* @see {@link toTaggedUnion} for the constructor
|
|
2065
3382
|
* @since 4.0.0
|
|
2066
3383
|
* @experimental
|
|
2067
3384
|
*/
|
|
@@ -2071,6 +3388,26 @@ export type toTaggedUnion<Tag extends PropertyKey, Members extends ReadonlyArray
|
|
|
2071
3388
|
};
|
|
2072
3389
|
}>> = Union<Members> & TaggedUnionUtils<Tag, Members>;
|
|
2073
3390
|
/**
|
|
3391
|
+
* Augments an existing {@link Union} of tagged structs with utility methods keyed by the discriminant field.
|
|
3392
|
+
*
|
|
3393
|
+
* **Example** (Adding tagged-union utilities to an existing union)
|
|
3394
|
+
*
|
|
3395
|
+
* ```ts
|
|
3396
|
+
* import { Schema } from "effect"
|
|
3397
|
+
*
|
|
3398
|
+
* const A = Schema.TaggedStruct("A", { value: Schema.Number })
|
|
3399
|
+
* const B = Schema.TaggedStruct("B", { name: Schema.String })
|
|
3400
|
+
*
|
|
3401
|
+
* const MyUnion = Schema.Union([A, B]).pipe(Schema.toTaggedUnion("_tag"))
|
|
3402
|
+
*
|
|
3403
|
+
* // Pattern-match on the union
|
|
3404
|
+
* const result = MyUnion.match({ _tag: "A", value: 1 }, {
|
|
3405
|
+
* A: (a) => `number: ${a.value}`,
|
|
3406
|
+
* B: (b) => `name: ${b.name}`
|
|
3407
|
+
* })
|
|
3408
|
+
* ```
|
|
3409
|
+
*
|
|
3410
|
+
* @see {@link TaggedUnion} for a shorthand that builds the union from scratch
|
|
2074
3411
|
* @since 4.0.0
|
|
2075
3412
|
* @experimental
|
|
2076
3413
|
*/
|
|
@@ -2078,6 +3415,10 @@ export declare function toTaggedUnion<const Tag extends PropertyKey>(tag: Tag):
|
|
|
2078
3415
|
readonly Type: { readonly [K in Tag]: PropertyKey; };
|
|
2079
3416
|
}>>(self: Union<Members>) => toTaggedUnion<Tag, Members>;
|
|
2080
3417
|
/**
|
|
3418
|
+
* A union schema that exposes `cases`, `guards`, `isAnyOf`, and `match` utilities keyed by the `_tag` discriminant.
|
|
3419
|
+
* Produced by {@link TaggedUnion}.
|
|
3420
|
+
*
|
|
3421
|
+
* @see {@link TaggedUnion} for the constructor
|
|
2081
3422
|
* @since 4.0.0
|
|
2082
3423
|
* @experimental
|
|
2083
3424
|
*/
|
|
@@ -2110,6 +3451,28 @@ export interface TaggedUnion<Cases extends Record<string, Top>> extends Bottom<{
|
|
|
2110
3451
|
};
|
|
2111
3452
|
}
|
|
2112
3453
|
/**
|
|
3454
|
+
* Builds a discriminated union from a record of field sets, one per variant.
|
|
3455
|
+
* Each key becomes the `_tag` literal and the value is passed to {@link TaggedStruct}.
|
|
3456
|
+
* The result includes `cases`, `guards`, `isAnyOf`, and `match` utilities.
|
|
3457
|
+
*
|
|
3458
|
+
* **Example** (Discriminated union with pattern matching)
|
|
3459
|
+
*
|
|
3460
|
+
* ```ts
|
|
3461
|
+
* import { Schema } from "effect"
|
|
3462
|
+
*
|
|
3463
|
+
* const Shape = Schema.TaggedUnion({
|
|
3464
|
+
* Circle: { radius: Schema.Number },
|
|
3465
|
+
* Rectangle: { width: Schema.Number, height: Schema.Number }
|
|
3466
|
+
* })
|
|
3467
|
+
*
|
|
3468
|
+
* // Pattern-match on a decoded value
|
|
3469
|
+
* const area = Shape.match({ _tag: "Circle", radius: 5 }, {
|
|
3470
|
+
* Circle: (c) => Math.PI * c.radius ** 2,
|
|
3471
|
+
* Rectangle: (r) => r.width * r.height
|
|
3472
|
+
* })
|
|
3473
|
+
* ```
|
|
3474
|
+
*
|
|
3475
|
+
* @see {@link toTaggedUnion} to augment an existing union instead
|
|
2113
3476
|
* @category Constructors
|
|
2114
3477
|
* @since 4.0.0
|
|
2115
3478
|
*/
|
|
@@ -2117,29 +3480,69 @@ export declare function TaggedUnion<const CasesByTag extends Record<string, Stru
|
|
|
2117
3480
|
readonly [K in keyof CasesByTag & string]: TaggedStruct<K, CasesByTag[K]>;
|
|
2118
3481
|
}>;
|
|
2119
3482
|
/**
|
|
3483
|
+
* The interface type for schemas created by {@link Opaque}.
|
|
3484
|
+
* Carries the same encoded/decoded shape as `S` but replaces `Type` with `Self & Brand`,
|
|
3485
|
+
* making the decoded value nominally distinct.
|
|
3486
|
+
*
|
|
3487
|
+
* @see {@link Opaque} for the constructor
|
|
2120
3488
|
* @since 4.0.0
|
|
2121
3489
|
*/
|
|
2122
3490
|
export interface Opaque<Self, S extends Top, Brand> extends Bottom<Self, S["Encoded"], S["DecodingServices"], S["EncodingServices"], S["ast"], S["~rebuild.out"], S["~type.make.in"], S["Iso"], S["~type.parameters"], S["~type.make"], S["~type.mutability"], S["~type.optionality"], S["~type.constructor.default"], S["~encoded.mutability"], S["~encoded.optionality"]> {
|
|
2123
3491
|
new (_: never): S["Type"] & Brand;
|
|
2124
3492
|
}
|
|
2125
3493
|
/**
|
|
3494
|
+
* Wraps a schema so that its decoded `Type` becomes a nominally distinct type `Self`.
|
|
3495
|
+
* Useful for creating opaque types that are structurally identical to a base schema
|
|
3496
|
+
* but type-incompatible with it.
|
|
3497
|
+
*
|
|
3498
|
+
* **Example** (Opaque user ID)
|
|
3499
|
+
*
|
|
3500
|
+
* ```ts
|
|
3501
|
+
* import { Schema } from "effect"
|
|
3502
|
+
*
|
|
3503
|
+
* type UserId = string & { readonly _tag: "UserId" }
|
|
3504
|
+
* const UserId = Schema.Opaque<UserId>()(Schema.String)
|
|
3505
|
+
*
|
|
3506
|
+
* // Decoded value is UserId, not plain string
|
|
3507
|
+
* const id = Schema.decodeUnknownSync(UserId)("abc")
|
|
3508
|
+
* // id: UserId
|
|
3509
|
+
* ```
|
|
3510
|
+
*
|
|
2126
3511
|
* @since 4.0.0
|
|
2127
3512
|
*/
|
|
2128
3513
|
export declare function Opaque<Self, Brand = {}>(): <S extends Top>(schema: S) => Opaque<Self, S, Brand> & Omit<S, "Type">;
|
|
2129
3514
|
/**
|
|
3515
|
+
* The type produced by {@link instanceOf} — a declaration schema that validates class instances.
|
|
3516
|
+
*
|
|
3517
|
+
* @see {@link instanceOf} for the constructor
|
|
2130
3518
|
* @since 4.0.0
|
|
2131
3519
|
*/
|
|
2132
3520
|
export interface instanceOf<T, Iso = T> extends declare<T, Iso> {
|
|
2133
3521
|
readonly "~rebuild.out": this;
|
|
2134
3522
|
}
|
|
2135
3523
|
/**
|
|
2136
|
-
* Creates a schema that validates
|
|
3524
|
+
* Creates a schema that validates values using `instanceof`.
|
|
3525
|
+
* Decoding and encoding pass the value through unchanged.
|
|
3526
|
+
*
|
|
3527
|
+
* **Example** (Schema for a built-in class)
|
|
3528
|
+
*
|
|
3529
|
+
* ```ts
|
|
3530
|
+
* import { Schema } from "effect"
|
|
3531
|
+
*
|
|
3532
|
+
* const DateSchema = Schema.instanceOf(Date)
|
|
3533
|
+
*
|
|
3534
|
+
* const decoded = Schema.decodeUnknownSync(DateSchema)(new Date("2024-01-01"))
|
|
3535
|
+
* // decoded: Date
|
|
3536
|
+
* ```
|
|
2137
3537
|
*
|
|
2138
3538
|
* @category Constructors
|
|
2139
3539
|
* @since 4.0.0
|
|
2140
3540
|
*/
|
|
2141
3541
|
export declare function instanceOf<C extends abstract new (...args: any) => any, Iso = InstanceType<C>>(constructor: C, annotations?: Annotations.Declaration<InstanceType<C>> | undefined): instanceOf<InstanceType<C>, Iso>;
|
|
2142
3542
|
/**
|
|
3543
|
+
* Constructs an `AST.Link` that describes how a value of type `T` encodes to and decodes from a `To` schema.
|
|
3544
|
+
* Used when building low-level AST transformations that bridge two schema types.
|
|
3545
|
+
*
|
|
2143
3546
|
* @since 4.0.0
|
|
2144
3547
|
* @experimental
|
|
2145
3548
|
*/
|
|
@@ -2148,6 +3551,22 @@ export declare function link<T>(): <To extends Top>(encodeTo: To, transformation
|
|
|
2148
3551
|
readonly encode: Getter.Getter<NoInfer<To["Type"]>, T>;
|
|
2149
3552
|
}) => AST.Link;
|
|
2150
3553
|
/**
|
|
3554
|
+
* Creates a custom filter check from a predicate function. The predicate
|
|
3555
|
+
* receives the input value, the schema's AST, and parse options, and returns
|
|
3556
|
+
* `true`/`undefined` on success or a failure description on error.
|
|
3557
|
+
*
|
|
3558
|
+
* **Example** (Custom filter check)
|
|
3559
|
+
* ```ts
|
|
3560
|
+
* import { Schema } from "effect"
|
|
3561
|
+
*
|
|
3562
|
+
* // Check that a number is even
|
|
3563
|
+
* const isEven = Schema.makeFilter(
|
|
3564
|
+
* (n: number) => n % 2 === 0 || "expected an even number"
|
|
3565
|
+
* )
|
|
3566
|
+
*
|
|
3567
|
+
* const EvenNumber = Schema.Number.check(isEven)
|
|
3568
|
+
* ```
|
|
3569
|
+
*
|
|
2151
3570
|
* @category Checks Constructors
|
|
2152
3571
|
* @since 4.0.0
|
|
2153
3572
|
*/
|
|
@@ -2156,6 +3575,9 @@ export declare const makeFilter: <T>(filter: (input: T, ast: AST.AST, options: A
|
|
|
2156
3575
|
readonly message: string;
|
|
2157
3576
|
}, annotations?: Annotations.Filter | undefined, abort?: boolean) => AST.Filter<T>;
|
|
2158
3577
|
/**
|
|
3578
|
+
* Groups multiple checks into a single {@link AST.FilterGroup}, applying
|
|
3579
|
+
* optional shared annotations to the group as a whole.
|
|
3580
|
+
*
|
|
2159
3581
|
* @category Checks Constructors
|
|
2160
3582
|
* @since 4.0.0
|
|
2161
3583
|
*/
|
|
@@ -2262,7 +3684,7 @@ export declare const isStringSymbol: (annotations?: Annotations.Filter) => AST.F
|
|
|
2262
3684
|
* @category String checks
|
|
2263
3685
|
* @since 4.0.0
|
|
2264
3686
|
*/
|
|
2265
|
-
export declare function isUUID(version
|
|
3687
|
+
export declare function isUUID(version?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8, annotations?: Annotations.Filter): AST.Filter<string>;
|
|
2266
3688
|
/**
|
|
2267
3689
|
* Validates that a string is a valid ULID (Universally Unique Lexicographically
|
|
2268
3690
|
* Sortable Identifier).
|
|
@@ -2453,6 +3875,9 @@ export declare function isUncapitalized(annotations?: Annotations.Filter): AST.F
|
|
|
2453
3875
|
*/
|
|
2454
3876
|
export declare function isFinite(annotations?: Annotations.Filter): AST.Filter<number>;
|
|
2455
3877
|
/**
|
|
3878
|
+
* Generic factory for creating a "greater than" (`>`) check for any ordered
|
|
3879
|
+
* type by supplying an {@link Order.Order} instance.
|
|
3880
|
+
*
|
|
2456
3881
|
* @category Order checks
|
|
2457
3882
|
* @since 4.0.0
|
|
2458
3883
|
*/
|
|
@@ -2462,6 +3887,9 @@ export declare function makeIsGreaterThan<T>(options: {
|
|
|
2462
3887
|
readonly formatter?: Formatter<T> | undefined;
|
|
2463
3888
|
}): (exclusiveMinimum: T, annotations?: Annotations.Filter) => AST.Filter<T>;
|
|
2464
3889
|
/**
|
|
3890
|
+
* Generic factory for creating a ">=" check for any ordered type by supplying
|
|
3891
|
+
* an {@link Order.Order} instance.
|
|
3892
|
+
*
|
|
2465
3893
|
* @category Order checks
|
|
2466
3894
|
* @since 4.0.0
|
|
2467
3895
|
*/
|
|
@@ -2471,6 +3899,9 @@ export declare function makeIsGreaterThanOrEqualTo<T>(options: {
|
|
|
2471
3899
|
readonly formatter?: Formatter<T> | undefined;
|
|
2472
3900
|
}): (minimum: T, annotations?: Annotations.Filter) => AST.Filter<T>;
|
|
2473
3901
|
/**
|
|
3902
|
+
* Generic factory for creating a "<" check for any ordered type by supplying
|
|
3903
|
+
* an {@link Order.Order} instance.
|
|
3904
|
+
*
|
|
2474
3905
|
* @category Order checks
|
|
2475
3906
|
* @since 4.0.0
|
|
2476
3907
|
*/
|
|
@@ -2480,6 +3911,9 @@ export declare function makeIsLessThan<T>(options: {
|
|
|
2480
3911
|
readonly formatter?: Formatter<T> | undefined;
|
|
2481
3912
|
}): (exclusiveMaximum: T, annotations?: Annotations.Filter) => AST.Filter<T>;
|
|
2482
3913
|
/**
|
|
3914
|
+
* Generic factory for creating a "<=" check for any ordered type by supplying
|
|
3915
|
+
* an {@link Order.Order} instance.
|
|
3916
|
+
*
|
|
2483
3917
|
* @category Order checks
|
|
2484
3918
|
* @since 4.0.0
|
|
2485
3919
|
*/
|
|
@@ -2489,6 +3923,9 @@ export declare function makeIsLessThanOrEqualTo<T>(options: {
|
|
|
2489
3923
|
readonly formatter?: Formatter<T> | undefined;
|
|
2490
3924
|
}): (maximum: T, annotations?: Annotations.Filter) => AST.Filter<T>;
|
|
2491
3925
|
/**
|
|
3926
|
+
* Generic factory for creating an inclusive/exclusive range check for any
|
|
3927
|
+
* ordered type by supplying an {@link Order.Order} instance.
|
|
3928
|
+
*
|
|
2492
3929
|
* @category Order checks
|
|
2493
3930
|
* @since 4.0.0
|
|
2494
3931
|
*/
|
|
@@ -2508,6 +3945,9 @@ export declare function makeIsBetween<T>(deriveOptions: {
|
|
|
2508
3945
|
readonly exclusiveMaximum?: boolean | undefined;
|
|
2509
3946
|
}, annotations?: Annotations.Filter) => AST.Filter<T>;
|
|
2510
3947
|
/**
|
|
3948
|
+
* Generic factory for creating a divisibility check for any numeric type by
|
|
3949
|
+
* supplying a remainder function and a zero value.
|
|
3950
|
+
*
|
|
2511
3951
|
* @category Numeric checks
|
|
2512
3952
|
* @since 4.0.0
|
|
2513
3953
|
*/
|
|
@@ -2856,6 +4296,48 @@ export declare const isBetweenBigInt: (options: {
|
|
|
2856
4296
|
readonly exclusiveMinimum?: boolean | undefined;
|
|
2857
4297
|
readonly exclusiveMaximum?: boolean | undefined;
|
|
2858
4298
|
}, annotations?: Annotations.Filter) => AST.Filter<bigint>;
|
|
4299
|
+
/**
|
|
4300
|
+
* Validates that a BigDecimal is greater than the specified value (exclusive).
|
|
4301
|
+
*
|
|
4302
|
+
* @category BigDecimal checks
|
|
4303
|
+
* @since 4.0.0
|
|
4304
|
+
*/
|
|
4305
|
+
export declare const isGreaterThanBigDecimal: (exclusiveMinimum: BigDecimal_.BigDecimal, annotations?: Annotations.Filter) => AST.Filter<BigDecimal_.BigDecimal>;
|
|
4306
|
+
/**
|
|
4307
|
+
* Validates that a BigDecimal is greater than or equal to the specified value
|
|
4308
|
+
* (inclusive).
|
|
4309
|
+
*
|
|
4310
|
+
* @category BigDecimal checks
|
|
4311
|
+
* @since 4.0.0
|
|
4312
|
+
*/
|
|
4313
|
+
export declare const isGreaterThanOrEqualToBigDecimal: (minimum: BigDecimal_.BigDecimal, annotations?: Annotations.Filter) => AST.Filter<BigDecimal_.BigDecimal>;
|
|
4314
|
+
/**
|
|
4315
|
+
* Validates that a BigDecimal is less than the specified value (exclusive).
|
|
4316
|
+
*
|
|
4317
|
+
* @category BigDecimal checks
|
|
4318
|
+
* @since 4.0.0
|
|
4319
|
+
*/
|
|
4320
|
+
export declare const isLessThanBigDecimal: (exclusiveMaximum: BigDecimal_.BigDecimal, annotations?: Annotations.Filter) => AST.Filter<BigDecimal_.BigDecimal>;
|
|
4321
|
+
/**
|
|
4322
|
+
* Validates that a BigDecimal is less than or equal to the specified value
|
|
4323
|
+
* (inclusive).
|
|
4324
|
+
*
|
|
4325
|
+
* @category BigDecimal checks
|
|
4326
|
+
* @since 4.0.0
|
|
4327
|
+
*/
|
|
4328
|
+
export declare const isLessThanOrEqualToBigDecimal: (maximum: BigDecimal_.BigDecimal, annotations?: Annotations.Filter) => AST.Filter<BigDecimal_.BigDecimal>;
|
|
4329
|
+
/**
|
|
4330
|
+
* Validates that a BigDecimal is within a specified range.
|
|
4331
|
+
*
|
|
4332
|
+
* @category BigDecimal checks
|
|
4333
|
+
* @since 4.0.0
|
|
4334
|
+
*/
|
|
4335
|
+
export declare const isBetweenBigDecimal: (options: {
|
|
4336
|
+
readonly minimum: BigDecimal_.BigDecimal;
|
|
4337
|
+
readonly maximum: BigDecimal_.BigDecimal;
|
|
4338
|
+
readonly exclusiveMinimum?: boolean | undefined;
|
|
4339
|
+
readonly exclusiveMaximum?: boolean | undefined;
|
|
4340
|
+
}, annotations?: Annotations.Filter) => AST.Filter<BigDecimal_.BigDecimal>;
|
|
2859
4341
|
/**
|
|
2860
4342
|
* Validates that a value has at least the specified length. Works with strings
|
|
2861
4343
|
* and arrays.
|
|
@@ -2871,6 +4353,14 @@ export declare const isBetweenBigInt: (options: {
|
|
|
2871
4353
|
* constraint to ensure generated strings or arrays have at least the required
|
|
2872
4354
|
* length.
|
|
2873
4355
|
*
|
|
4356
|
+
* **Example** (Minimum length check)
|
|
4357
|
+
* ```ts
|
|
4358
|
+
* import { Schema } from "effect"
|
|
4359
|
+
*
|
|
4360
|
+
* const NonEmptyStringSchema = Schema.String.check(Schema.isMinLength(1))
|
|
4361
|
+
* const NonEmptyArraySchema = Schema.Array(Schema.Number).check(Schema.isMinLength(1))
|
|
4362
|
+
* ```
|
|
4363
|
+
*
|
|
2874
4364
|
* @category Length checks
|
|
2875
4365
|
* @since 4.0.0
|
|
2876
4366
|
*/
|
|
@@ -3086,6 +4576,7 @@ export declare function isPropertyNames(keySchema: Top, annotations?: Annotation
|
|
|
3086
4576
|
* constraint using the provided equivalence function to ensure generated arrays
|
|
3087
4577
|
* contain only unique items.
|
|
3088
4578
|
*
|
|
4579
|
+
* @category Array checks
|
|
3089
4580
|
* @since 4.0.0
|
|
3090
4581
|
*/
|
|
3091
4582
|
export declare function isUnique<T>(annotations?: Annotations.Filter): AST.Filter<readonly T[]>;
|
|
@@ -3103,6 +4594,23 @@ export declare const NonEmptyString: String;
|
|
|
3103
4594
|
*/
|
|
3104
4595
|
export declare const Char: String;
|
|
3105
4596
|
/**
|
|
4597
|
+
* Schema for the `Option<A>` type, representing an optional value that is
|
|
4598
|
+
* either `None` or `Some<A>`.
|
|
4599
|
+
*
|
|
4600
|
+
* **Example** (Option schema)
|
|
4601
|
+
*
|
|
4602
|
+
* ```ts
|
|
4603
|
+
* import { Schema } from "effect"
|
|
4604
|
+
* import { Option } from "effect"
|
|
4605
|
+
*
|
|
4606
|
+
* const schema = Schema.Option(Schema.Number)
|
|
4607
|
+
*
|
|
4608
|
+
* Schema.decodeUnknownSync(schema)(Option.some(1))
|
|
4609
|
+
* // => Some(1)
|
|
4610
|
+
* Schema.decodeUnknownSync(schema)(Option.none())
|
|
4611
|
+
* // => None
|
|
4612
|
+
* ```
|
|
4613
|
+
*
|
|
3106
4614
|
* @category Option
|
|
3107
4615
|
* @since 4.0.0
|
|
3108
4616
|
*/
|
|
@@ -3120,11 +4628,16 @@ export type OptionIso<A extends Top> = {
|
|
|
3120
4628
|
readonly value: A["Iso"];
|
|
3121
4629
|
};
|
|
3122
4630
|
/**
|
|
4631
|
+
* Creates a schema for `Option<A>`. See {@link Option} for details.
|
|
4632
|
+
*
|
|
3123
4633
|
* @category Option
|
|
3124
4634
|
* @since 4.0.0
|
|
3125
4635
|
*/
|
|
3126
4636
|
export declare function Option<A extends Top>(value: A): Option<A>;
|
|
3127
4637
|
/**
|
|
4638
|
+
* Schema type for {@link OptionFromNullOr}.
|
|
4639
|
+
*
|
|
4640
|
+
* @category Option
|
|
3128
4641
|
* @since 4.0.0
|
|
3129
4642
|
*/
|
|
3130
4643
|
export interface OptionFromNullOr<S extends Top> extends decodeTo<Option<toType<S>>, NullOr<S>> {
|
|
@@ -3145,6 +4658,57 @@ export interface OptionFromNullOr<S extends Top> extends decodeTo<Option<toType<
|
|
|
3145
4658
|
*/
|
|
3146
4659
|
export declare function OptionFromNullOr<S extends Top>(schema: S): OptionFromNullOr<S>;
|
|
3147
4660
|
/**
|
|
4661
|
+
* Schema type for {@link OptionFromUndefinedOr}.
|
|
4662
|
+
*
|
|
4663
|
+
* @category Option
|
|
4664
|
+
* @since 4.0.0
|
|
4665
|
+
*/
|
|
4666
|
+
export interface OptionFromUndefinedOr<S extends Top> extends decodeTo<Option<toType<S>>, UndefinedOr<S>> {
|
|
4667
|
+
}
|
|
4668
|
+
/**
|
|
4669
|
+
* Decodes an undefined-or value `T` to a required `Option<T>` value.
|
|
4670
|
+
*
|
|
4671
|
+
* Decoding:
|
|
4672
|
+
* - `undefined` is decoded as `None`
|
|
4673
|
+
* - other values are decoded as `Some`
|
|
4674
|
+
*
|
|
4675
|
+
* Encoding:
|
|
4676
|
+
* - `None` is encoded as `undefined`
|
|
4677
|
+
* - `Some` is encoded as the value
|
|
4678
|
+
*
|
|
4679
|
+
* @category Option
|
|
4680
|
+
* @since 4.0.0
|
|
4681
|
+
*/
|
|
4682
|
+
export declare function OptionFromUndefinedOr<S extends Top>(schema: S): OptionFromUndefinedOr<S>;
|
|
4683
|
+
/**
|
|
4684
|
+
* Schema type for {@link OptionFromNullishOr}.
|
|
4685
|
+
*
|
|
4686
|
+
* @category Option
|
|
4687
|
+
* @since 4.0.0
|
|
4688
|
+
*/
|
|
4689
|
+
export interface OptionFromNullishOr<S extends Top> extends decodeTo<Option<toType<S>>, NullishOr<S>> {
|
|
4690
|
+
}
|
|
4691
|
+
/**
|
|
4692
|
+
* Decodes a nullish value `T` to a required `Option<T>` value.
|
|
4693
|
+
*
|
|
4694
|
+
* Decoding:
|
|
4695
|
+
* - `null` and `undefined` are decoded as `None`
|
|
4696
|
+
* - other values are decoded as `Some`
|
|
4697
|
+
*
|
|
4698
|
+
* Encoding:
|
|
4699
|
+
* - `None` is encoded as `null` or `undefined` depending on the provided `options.onNoneEncoding` (defaults to `undefined`)
|
|
4700
|
+
* - `Some` is encoded as the value
|
|
4701
|
+
*
|
|
4702
|
+
* @category Option
|
|
4703
|
+
* @since 4.0.0
|
|
4704
|
+
*/
|
|
4705
|
+
export declare function OptionFromNullishOr<S extends Top>(schema: S, options?: {
|
|
4706
|
+
onNoneEncoding: null | undefined;
|
|
4707
|
+
}): OptionFromNullishOr<S>;
|
|
4708
|
+
/**
|
|
4709
|
+
* Schema type for {@link OptionFromOptionalKey}.
|
|
4710
|
+
*
|
|
4711
|
+
* @category Option
|
|
3148
4712
|
* @since 4.0.0
|
|
3149
4713
|
*/
|
|
3150
4714
|
export interface OptionFromOptionalKey<S extends Top> extends decodeTo<Option<toType<S>>, optionalKey<S>> {
|
|
@@ -3165,6 +4729,9 @@ export interface OptionFromOptionalKey<S extends Top> extends decodeTo<Option<to
|
|
|
3165
4729
|
*/
|
|
3166
4730
|
export declare function OptionFromOptionalKey<S extends Top>(schema: S): OptionFromOptionalKey<S>;
|
|
3167
4731
|
/**
|
|
4732
|
+
* Schema type for {@link OptionFromOptional}.
|
|
4733
|
+
*
|
|
4734
|
+
* @category Option
|
|
3168
4735
|
* @since 4.0.0
|
|
3169
4736
|
*/
|
|
3170
4737
|
export interface OptionFromOptional<S extends Top> extends decodeTo<Option<toType<S>>, optional<S>> {
|
|
@@ -3187,6 +4754,39 @@ export interface OptionFromOptional<S extends Top> extends decodeTo<Option<toTyp
|
|
|
3187
4754
|
*/
|
|
3188
4755
|
export declare function OptionFromOptional<S extends Top>(schema: S): OptionFromOptional<S>;
|
|
3189
4756
|
/**
|
|
4757
|
+
* Schema type for {@link OptionFromOptionalNullOr}.
|
|
4758
|
+
*
|
|
4759
|
+
* @category Option
|
|
4760
|
+
* @since 4.0.0
|
|
4761
|
+
*/
|
|
4762
|
+
export interface OptionFromOptionalNullOr<S extends Top> extends decodeTo<Option<toType<S>>, optional<NullOr<S>>> {
|
|
4763
|
+
}
|
|
4764
|
+
/**
|
|
4765
|
+
* Decodes an optional or `null` or `undefined` value `A` to a required `Option<A>`
|
|
4766
|
+
* value.
|
|
4767
|
+
*
|
|
4768
|
+
* Decoding:
|
|
4769
|
+
* - a missing key is decoded as `None`
|
|
4770
|
+
* - a present key with an `undefined` value is decoded as `None`
|
|
4771
|
+
* - a present key with a `null` value is decoded as `None`
|
|
4772
|
+
* - all other values are decoded as `Some`
|
|
4773
|
+
*
|
|
4774
|
+
* Encoding (controlled by `options.onNoneEncoding`):
|
|
4775
|
+
* - `"omit"` (default): `None` is encoded as a missing key
|
|
4776
|
+
* - `null`: `None` is encoded as `null`
|
|
4777
|
+
* - `undefined`: `None` is encoded as `undefined`
|
|
4778
|
+
* - `Some` is always encoded as the value
|
|
4779
|
+
*
|
|
4780
|
+
* @category Option
|
|
4781
|
+
* @since 4.0.0
|
|
4782
|
+
*/
|
|
4783
|
+
export declare function OptionFromOptionalNullOr<S extends Top>(schema: S, options?: {
|
|
4784
|
+
readonly onNoneEncoding: "omit" | null | undefined;
|
|
4785
|
+
}): OptionFromOptionalNullOr<S>;
|
|
4786
|
+
/**
|
|
4787
|
+
* Schema for the `Result<A, E>` type, representing a computation that either
|
|
4788
|
+
* succeeds with `A` or fails with `E`.
|
|
4789
|
+
*
|
|
3190
4790
|
* @category Result
|
|
3191
4791
|
* @since 4.0.0
|
|
3192
4792
|
*/
|
|
@@ -3206,11 +4806,16 @@ export type ResultIso<A extends Top, E extends Top> = {
|
|
|
3206
4806
|
readonly failure: E["Iso"];
|
|
3207
4807
|
};
|
|
3208
4808
|
/**
|
|
4809
|
+
* Creates a schema for `Result<A, E>`. See {@link Result} for details.
|
|
4810
|
+
*
|
|
3209
4811
|
* @category Result
|
|
3210
4812
|
* @since 4.0.0
|
|
3211
4813
|
*/
|
|
3212
4814
|
export declare function Result<A extends Top, E extends Top>(success: A, failure: E): Result<A, E>;
|
|
3213
4815
|
/**
|
|
4816
|
+
* Schema for the `Redacted<A>` type, providing secure handling of sensitive
|
|
4817
|
+
* values. The inner value is hidden from error messages.
|
|
4818
|
+
*
|
|
3214
4819
|
* @category Redacted
|
|
3215
4820
|
* @since 4.0.0
|
|
3216
4821
|
*/
|
|
@@ -3244,17 +4849,26 @@ export declare function Redacted<S extends Top>(value: S, options?: {
|
|
|
3244
4849
|
readonly label?: string | undefined;
|
|
3245
4850
|
}): Redacted<S>;
|
|
3246
4851
|
/**
|
|
4852
|
+
* Schema type for {@link RedactedFromValue}.
|
|
4853
|
+
*
|
|
3247
4854
|
* @category Redacted
|
|
3248
4855
|
* @since 4.0.0
|
|
3249
4856
|
*/
|
|
3250
4857
|
export interface RedactedFromValue<S extends Top> extends decodeTo<Redacted<toType<S>>, middlewareDecoding<S, S["DecodingServices"]>> {
|
|
3251
4858
|
}
|
|
3252
4859
|
/**
|
|
4860
|
+
* Middleware that wraps decoded errors in `Redacted`, preventing sensitive
|
|
4861
|
+
* schema details from leaking in error messages.
|
|
4862
|
+
*
|
|
3253
4863
|
* @category Redacted
|
|
3254
4864
|
* @since 4.0.0
|
|
3255
4865
|
*/
|
|
3256
4866
|
export declare function redact<S extends Top>(schema: S): middlewareDecoding<S, S["DecodingServices"]>;
|
|
3257
4867
|
/**
|
|
4868
|
+
* Decodes a value and wraps it in `Redacted<A>`. Unlike {@link Redacted} which
|
|
4869
|
+
* expects the input to already be a `Redacted` instance, this schema decodes
|
|
4870
|
+
* the raw value and wraps it.
|
|
4871
|
+
*
|
|
3258
4872
|
* @category Redacted
|
|
3259
4873
|
* @since 4.0.0
|
|
3260
4874
|
*/
|
|
@@ -3262,18 +4876,22 @@ export declare function RedactedFromValue<S extends Top>(value: S, options?: {
|
|
|
3262
4876
|
readonly label?: string | undefined;
|
|
3263
4877
|
}): RedactedFromValue<S>;
|
|
3264
4878
|
/**
|
|
3265
|
-
*
|
|
4879
|
+
* Schema for a single `Cause.Reason<E>`, representing one reason a fiber may
|
|
4880
|
+
* fail: a typed error (`Fail`), an unexpected defect (`Die`), or an interrupt
|
|
4881
|
+
* (`Interrupt`).
|
|
4882
|
+
*
|
|
4883
|
+
* @category CauseReason
|
|
3266
4884
|
* @since 4.0.0
|
|
3267
4885
|
*/
|
|
3268
|
-
export interface
|
|
4886
|
+
export interface CauseReason<E extends Top, D extends Top> extends declareConstructor<Cause_.Reason<E["Type"]>, Cause_.Reason<E["Encoded"]>, readonly [E, D], CauseReasonIso<E, D>> {
|
|
3269
4887
|
readonly error: E;
|
|
3270
4888
|
readonly defect: D;
|
|
3271
4889
|
}
|
|
3272
4890
|
/**
|
|
3273
|
-
* @category
|
|
4891
|
+
* @category CauseReason
|
|
3274
4892
|
* @since 4.0.0
|
|
3275
4893
|
*/
|
|
3276
|
-
export type
|
|
4894
|
+
export type CauseReasonIso<E extends Top, D extends Top> = {
|
|
3277
4895
|
readonly _tag: "Fail";
|
|
3278
4896
|
readonly error: E["Iso"];
|
|
3279
4897
|
} | {
|
|
@@ -3284,11 +4902,16 @@ export type CauseFailureIso<E extends Top, D extends Top> = {
|
|
|
3284
4902
|
readonly fiberId: number | undefined;
|
|
3285
4903
|
};
|
|
3286
4904
|
/**
|
|
3287
|
-
* @
|
|
4905
|
+
* Creates a schema for `Cause.Reason<E>`. See {@link CauseReason} for details.
|
|
4906
|
+
*
|
|
4907
|
+
* @category CauseReason
|
|
3288
4908
|
* @since 4.0.0
|
|
3289
4909
|
*/
|
|
3290
|
-
export declare function
|
|
4910
|
+
export declare function CauseReason<E extends Top, D extends Top>(error: E, defect: D): CauseReason<E, D>;
|
|
3291
4911
|
/**
|
|
4912
|
+
* Schema for `Cause<E>`, an ordered collection of reasons a fiber failed,
|
|
4913
|
+
* combining typed errors, defects, and interrupts.
|
|
4914
|
+
*
|
|
3292
4915
|
* @category Cause
|
|
3293
4916
|
* @since 4.0.0
|
|
3294
4917
|
*/
|
|
@@ -3300,13 +4923,18 @@ export interface Cause<E extends Top, D extends Top> extends declareConstructor<
|
|
|
3300
4923
|
* @category Cause
|
|
3301
4924
|
* @since 4.0.0
|
|
3302
4925
|
*/
|
|
3303
|
-
export type CauseIso<E extends Top, D extends Top> = ReadonlyArray<
|
|
4926
|
+
export type CauseIso<E extends Top, D extends Top> = ReadonlyArray<CauseReasonIso<E, D>>;
|
|
3304
4927
|
/**
|
|
4928
|
+
* Creates a schema for `Cause<E>`. See {@link Cause} for details.
|
|
4929
|
+
*
|
|
3305
4930
|
* @category Cause
|
|
3306
4931
|
* @since 4.0.0
|
|
3307
4932
|
*/
|
|
3308
4933
|
export declare function Cause<E extends Top, D extends Top>(error: E, defect: D): Cause<E, D>;
|
|
3309
4934
|
/**
|
|
4935
|
+
* Schema type for {@link Error}.
|
|
4936
|
+
*
|
|
4937
|
+
* @category Schemas
|
|
3310
4938
|
* @since 4.0.0
|
|
3311
4939
|
*/
|
|
3312
4940
|
export interface Error extends instanceOf<globalThis.Error> {
|
|
@@ -3332,6 +4960,9 @@ export declare const Error: Error;
|
|
|
3332
4960
|
*/
|
|
3333
4961
|
export declare const ErrorWithStack: Error;
|
|
3334
4962
|
/**
|
|
4963
|
+
* Schema type for {@link Defect}.
|
|
4964
|
+
*
|
|
4965
|
+
* @category Schemas
|
|
3335
4966
|
* @since 4.0.0
|
|
3336
4967
|
*/
|
|
3337
4968
|
export interface Defect extends Union<readonly [
|
|
@@ -3359,6 +4990,9 @@ export declare const Defect: Defect;
|
|
|
3359
4990
|
*/
|
|
3360
4991
|
export declare const DefectWithStack: Defect;
|
|
3361
4992
|
/**
|
|
4993
|
+
* Schema for `Exit<A, E>`, representing the result of a fiber execution —
|
|
4994
|
+
* either a success with value `A` or a failure with `Cause<E>`.
|
|
4995
|
+
*
|
|
3362
4996
|
* @category Exit
|
|
3363
4997
|
* @since 4.0.0
|
|
3364
4998
|
*/
|
|
@@ -3379,15 +5013,19 @@ export type ExitIso<A extends Top, E extends Top, D extends Top> = {
|
|
|
3379
5013
|
readonly cause: CauseIso<E, D>;
|
|
3380
5014
|
};
|
|
3381
5015
|
/**
|
|
5016
|
+
* Creates a schema for `Exit<A, E>`. See {@link Exit} for details.
|
|
5017
|
+
*
|
|
3382
5018
|
* @category Exit
|
|
3383
5019
|
* @since 4.0.0
|
|
3384
5020
|
*/
|
|
3385
5021
|
export declare function Exit<A extends Top, E extends Top, D extends Top>(value: A, error: E, defect: D): Exit<A, E, D>;
|
|
3386
5022
|
/**
|
|
5023
|
+
* Schema type for {@link ReadonlyMap}.
|
|
5024
|
+
*
|
|
3387
5025
|
* @category ReadonlyMap
|
|
3388
5026
|
* @since 4.0.0
|
|
3389
5027
|
*/
|
|
3390
|
-
export interface ReadonlyMap
|
|
5028
|
+
export interface $ReadonlyMap<Key extends Top, Value extends Top> extends declareConstructor<globalThis.ReadonlyMap<Key["Type"], Value["Type"]>, globalThis.ReadonlyMap<Key["Encoded"], Value["Encoded"]>, readonly [Key, Value], ReadonlyMapIso<Key, Value>> {
|
|
3391
5029
|
readonly key: Key;
|
|
3392
5030
|
readonly value: Value;
|
|
3393
5031
|
}
|
|
@@ -3403,12 +5041,38 @@ export type ReadonlyMapIso<Key extends Top, Value extends Top> = ReadonlyArray<r
|
|
|
3403
5041
|
* @category ReadonlyMap
|
|
3404
5042
|
* @since 4.0.0
|
|
3405
5043
|
*/
|
|
3406
|
-
export declare function ReadonlyMap<Key extends Top, Value extends Top>(key: Key, value: Value): ReadonlyMap
|
|
5044
|
+
export declare function ReadonlyMap<Key extends Top, Value extends Top>(key: Key, value: Value): $ReadonlyMap<Key, Value>;
|
|
5045
|
+
/**
|
|
5046
|
+
* Schema for an Effect `HashMap` where keys and values must conform to the
|
|
5047
|
+
* provided schemas.
|
|
5048
|
+
*
|
|
5049
|
+
* @category HashMap
|
|
5050
|
+
* @since 4.0.0
|
|
5051
|
+
*/
|
|
5052
|
+
export interface HashMap<Key extends Top, Value extends Top> extends declareConstructor<HashMap_.HashMap<Key["Type"], Value["Type"]>, HashMap_.HashMap<Key["Encoded"], Value["Encoded"]>, readonly [Key, Value], HashMapIso<Key, Value>> {
|
|
5053
|
+
readonly key: Key;
|
|
5054
|
+
readonly value: Value;
|
|
5055
|
+
}
|
|
5056
|
+
/**
|
|
5057
|
+
* @category HashMap
|
|
5058
|
+
* @since 4.0.0
|
|
5059
|
+
*/
|
|
5060
|
+
export type HashMapIso<Key extends Top, Value extends Top> = ReadonlyArray<readonly [Key["Iso"], Value["Iso"]]>;
|
|
3407
5061
|
/**
|
|
5062
|
+
* Creates a schema that validates a `HashMap` where keys and values must
|
|
5063
|
+
* conform to the provided schemas.
|
|
5064
|
+
*
|
|
5065
|
+
* @category HashMap
|
|
5066
|
+
* @since 4.0.0
|
|
5067
|
+
*/
|
|
5068
|
+
export declare function HashMap<Key extends Top, Value extends Top>(key: Key, value: Value): HashMap<Key, Value>;
|
|
5069
|
+
/**
|
|
5070
|
+
* Schema type for {@link ReadonlySet}.
|
|
5071
|
+
*
|
|
3408
5072
|
* @category ReadonlySet
|
|
3409
5073
|
* @since 4.0.0
|
|
3410
5074
|
*/
|
|
3411
|
-
export interface ReadonlySet
|
|
5075
|
+
export interface $ReadonlySet<Value extends Top> extends declareConstructor<globalThis.ReadonlySet<Value["Type"]>, globalThis.ReadonlySet<Value["Encoded"]>, readonly [Value], ReadonlySetIso<Value>> {
|
|
3412
5076
|
readonly value: Value;
|
|
3413
5077
|
}
|
|
3414
5078
|
/**
|
|
@@ -3420,17 +5084,74 @@ export type ReadonlySetIso<Value extends Top> = ReadonlyArray<Value["Iso"]>;
|
|
|
3420
5084
|
* @category ReadonlySet
|
|
3421
5085
|
* @since 4.0.0
|
|
3422
5086
|
*/
|
|
3423
|
-
export declare function ReadonlySet<Value extends Top>(value: Value): ReadonlySet
|
|
5087
|
+
export declare function ReadonlySet<Value extends Top>(value: Value): $ReadonlySet<Value>;
|
|
3424
5088
|
/**
|
|
5089
|
+
* Schema for an Effect `HashSet` where values must conform to the provided
|
|
5090
|
+
* schema.
|
|
5091
|
+
*
|
|
5092
|
+
* @category HashSet
|
|
5093
|
+
* @since 4.0.0
|
|
5094
|
+
*/
|
|
5095
|
+
export interface HashSet<Value extends Top> extends declareConstructor<HashSet_.HashSet<Value["Type"]>, HashSet_.HashSet<Value["Encoded"]>, readonly [Value], HashSetIso<Value>> {
|
|
5096
|
+
readonly value: Value;
|
|
5097
|
+
}
|
|
5098
|
+
/**
|
|
5099
|
+
* @category HashSet
|
|
5100
|
+
* @since 4.0.0
|
|
5101
|
+
*/
|
|
5102
|
+
export type HashSetIso<Value extends Top> = ReadonlyArray<Value["Iso"]>;
|
|
5103
|
+
/**
|
|
5104
|
+
* Creates a schema that validates a `HashSet` where values must conform to the
|
|
5105
|
+
* provided schema.
|
|
5106
|
+
*
|
|
5107
|
+
* @category HashSet
|
|
5108
|
+
* @since 4.0.0
|
|
5109
|
+
*/
|
|
5110
|
+
export declare function HashSet<Value extends Top>(value: Value): HashSet<Value>;
|
|
5111
|
+
/**
|
|
5112
|
+
* Schema for an Effect `Chunk` (immutable array-like collection) where values
|
|
5113
|
+
* must conform to the provided schema.
|
|
5114
|
+
*
|
|
5115
|
+
* @category Chunk
|
|
5116
|
+
* @since 4.0.0
|
|
5117
|
+
*/
|
|
5118
|
+
export interface Chunk<Value extends Top> extends declareConstructor<Chunk_.Chunk<Value["Type"]>, Chunk_.Chunk<Value["Encoded"]>, readonly [Value], ChunkIso<Value>> {
|
|
5119
|
+
readonly value: Value;
|
|
5120
|
+
}
|
|
5121
|
+
/**
|
|
5122
|
+
* @category Chunk
|
|
5123
|
+
* @since 4.0.0
|
|
5124
|
+
*/
|
|
5125
|
+
export type ChunkIso<Value extends Top> = ReadonlyArray<Value["Iso"]>;
|
|
5126
|
+
/**
|
|
5127
|
+
* Creates a schema that validates a `Chunk` where values must conform to the
|
|
5128
|
+
* provided schema.
|
|
5129
|
+
*
|
|
5130
|
+
* @category Chunk
|
|
5131
|
+
* @since 4.0.0
|
|
5132
|
+
*/
|
|
5133
|
+
export declare function Chunk<Value extends Top>(value: Value): Chunk<Value>;
|
|
5134
|
+
/**
|
|
5135
|
+
* Schema type for {@link RegExp}.
|
|
5136
|
+
*
|
|
5137
|
+
* @category Schemas
|
|
3425
5138
|
* @since 4.0.0
|
|
3426
5139
|
*/
|
|
3427
5140
|
export interface RegExp extends instanceOf<globalThis.RegExp> {
|
|
3428
5141
|
}
|
|
3429
5142
|
/**
|
|
5143
|
+
* Schema for JavaScript `RegExp` objects.
|
|
5144
|
+
*
|
|
5145
|
+
* The default JSON serializer encodes a `RegExp` as `{ source, flags }`.
|
|
5146
|
+
*
|
|
5147
|
+
* @category Schemas
|
|
3430
5148
|
* @since 4.0.0
|
|
3431
5149
|
*/
|
|
3432
5150
|
export declare const RegExp: RegExp;
|
|
3433
5151
|
/**
|
|
5152
|
+
* Schema type for {@link URL}.
|
|
5153
|
+
*
|
|
5154
|
+
* @category URL
|
|
3434
5155
|
* @since 4.0.0
|
|
3435
5156
|
*/
|
|
3436
5157
|
export interface URL extends instanceOf<globalThis.URL> {
|
|
@@ -3447,6 +5168,9 @@ export interface URL extends instanceOf<globalThis.URL> {
|
|
|
3447
5168
|
*/
|
|
3448
5169
|
export declare const URL: URL;
|
|
3449
5170
|
/**
|
|
5171
|
+
* Schema type for {@link URLFromString}.
|
|
5172
|
+
*
|
|
5173
|
+
* @category URL
|
|
3450
5174
|
* @since 4.0.0
|
|
3451
5175
|
*/
|
|
3452
5176
|
export interface URLFromString extends decodeTo<URL, String> {
|
|
@@ -3465,6 +5189,9 @@ export interface URLFromString extends decodeTo<URL, String> {
|
|
|
3465
5189
|
*/
|
|
3466
5190
|
export declare const URLFromString: URLFromString;
|
|
3467
5191
|
/**
|
|
5192
|
+
* Schema type for {@link Date}.
|
|
5193
|
+
*
|
|
5194
|
+
* @category Schemas
|
|
3468
5195
|
* @since 4.0.0
|
|
3469
5196
|
*/
|
|
3470
5197
|
export interface Date extends instanceOf<globalThis.Date> {
|
|
@@ -3473,12 +5200,26 @@ export interface Date extends instanceOf<globalThis.Date> {
|
|
|
3473
5200
|
* A schema for JavaScript `Date` objects.
|
|
3474
5201
|
*
|
|
3475
5202
|
* This schema accepts any `Date` instance, including invalid dates (e.g., `new
|
|
3476
|
-
* Date("invalid")`). For validating only valid dates, use
|
|
5203
|
+
* Date("invalid")`). For validating only valid dates, use {@link DateValid}
|
|
5204
|
+
* instead. The default JSON serializer encodes `Date` as an ISO 8601 string.
|
|
5205
|
+
*
|
|
5206
|
+
* **Example** (Date schema)
|
|
5207
|
+
*
|
|
5208
|
+
* ```ts
|
|
5209
|
+
* import { Schema } from "effect"
|
|
3477
5210
|
*
|
|
5211
|
+
* Schema.decodeUnknownSync(Schema.Date)(new Date("2024-01-01"))
|
|
5212
|
+
* // => Date { 2024-01-01T00:00:00.000Z }
|
|
5213
|
+
* ```
|
|
5214
|
+
*
|
|
5215
|
+
* @category Schemas
|
|
3478
5216
|
* @since 4.0.0
|
|
3479
5217
|
*/
|
|
3480
5218
|
export declare const Date: Date;
|
|
3481
5219
|
/**
|
|
5220
|
+
* Schema type for {@link DateValid}.
|
|
5221
|
+
*
|
|
5222
|
+
* @category Schemas
|
|
3482
5223
|
* @since 4.0.0
|
|
3483
5224
|
*/
|
|
3484
5225
|
export interface DateValid extends Date {
|
|
@@ -3493,6 +5234,9 @@ export interface DateValid extends Date {
|
|
|
3493
5234
|
*/
|
|
3494
5235
|
export declare const DateValid: Date;
|
|
3495
5236
|
/**
|
|
5237
|
+
* Schema type for {@link Duration}.
|
|
5238
|
+
*
|
|
5239
|
+
* @category Duration
|
|
3496
5240
|
* @since 4.0.0
|
|
3497
5241
|
*/
|
|
3498
5242
|
export interface Duration extends declare<Duration_.Duration> {
|
|
@@ -3500,14 +5244,28 @@ export interface Duration extends declare<Duration_.Duration> {
|
|
|
3500
5244
|
/**
|
|
3501
5245
|
* A schema for `Duration` values.
|
|
3502
5246
|
*
|
|
3503
|
-
*
|
|
5247
|
+
* The default JSON serializer encodes `Duration` as a tagged object with the
|
|
5248
|
+
* duration type and value.
|
|
5249
|
+
*
|
|
5250
|
+
* **Example** (Duration schema)
|
|
3504
5251
|
*
|
|
3505
|
-
*
|
|
5252
|
+
* ```ts
|
|
5253
|
+
* import { Schema } from "effect"
|
|
5254
|
+
* import { Duration } from "effect"
|
|
5255
|
+
*
|
|
5256
|
+
* Schema.decodeUnknownSync(Schema.Duration)(Duration.seconds(5))
|
|
5257
|
+
* // => Duration(5s)
|
|
5258
|
+
* ```
|
|
5259
|
+
*
|
|
5260
|
+
* @category Duration
|
|
3506
5261
|
*
|
|
3507
5262
|
* @since 4.0.0
|
|
3508
5263
|
*/
|
|
3509
5264
|
export declare const Duration: Duration;
|
|
3510
5265
|
/**
|
|
5266
|
+
* Schema type for {@link DurationFromNanos}.
|
|
5267
|
+
*
|
|
5268
|
+
* @category Duration
|
|
3511
5269
|
* @since 4.0.0
|
|
3512
5270
|
*/
|
|
3513
5271
|
export interface DurationFromNanos extends decodeTo<Duration, BigInt> {
|
|
@@ -3527,6 +5285,9 @@ export interface DurationFromNanos extends decodeTo<Duration, BigInt> {
|
|
|
3527
5285
|
*/
|
|
3528
5286
|
export declare const DurationFromNanos: DurationFromNanos;
|
|
3529
5287
|
/**
|
|
5288
|
+
* Schema type for {@link DurationFromMillis}.
|
|
5289
|
+
*
|
|
5290
|
+
* @category Duration
|
|
3530
5291
|
* @since 4.0.0
|
|
3531
5292
|
*/
|
|
3532
5293
|
export interface DurationFromMillis extends decodeTo<Duration, Number> {
|
|
@@ -3549,6 +5310,27 @@ export interface DurationFromMillis extends decodeTo<Duration, Number> {
|
|
|
3549
5310
|
*/
|
|
3550
5311
|
export declare const DurationFromMillis: DurationFromMillis;
|
|
3551
5312
|
/**
|
|
5313
|
+
* Schema type for {@link BigDecimal}.
|
|
5314
|
+
*
|
|
5315
|
+
* @category Schemas
|
|
5316
|
+
* @since 4.0.0
|
|
5317
|
+
*/
|
|
5318
|
+
export interface BigDecimal extends declare<BigDecimal_.BigDecimal> {
|
|
5319
|
+
}
|
|
5320
|
+
/**
|
|
5321
|
+
* A schema for `BigDecimal` values.
|
|
5322
|
+
*
|
|
5323
|
+
* **Default JSON serializer**
|
|
5324
|
+
*
|
|
5325
|
+
* - encodes `BigDecimal` as a `string`
|
|
5326
|
+
*
|
|
5327
|
+
* @since 4.0.0
|
|
5328
|
+
*/
|
|
5329
|
+
export declare const BigDecimal: BigDecimal;
|
|
5330
|
+
/**
|
|
5331
|
+
* Schema type for {@link UnknownFromJsonString}.
|
|
5332
|
+
*
|
|
5333
|
+
* @category JSON
|
|
3552
5334
|
* @since 4.0.0
|
|
3553
5335
|
*/
|
|
3554
5336
|
export interface UnknownFromJsonString extends fromJsonString<Unknown> {
|
|
@@ -3577,6 +5359,9 @@ export interface UnknownFromJsonString extends fromJsonString<Unknown> {
|
|
|
3577
5359
|
*/
|
|
3578
5360
|
export declare const UnknownFromJsonString: fromJsonString<Unknown>;
|
|
3579
5361
|
/**
|
|
5362
|
+
* Schema type for {@link fromJsonString}.
|
|
5363
|
+
*
|
|
5364
|
+
* @category JSON
|
|
3580
5365
|
* @since 4.0.0
|
|
3581
5366
|
*/
|
|
3582
5367
|
export interface fromJsonString<S extends Top> extends decodeTo<S, String> {
|
|
@@ -3646,24 +5431,45 @@ export interface fromJsonString<S extends Top> extends decodeTo<S, String> {
|
|
|
3646
5431
|
*/
|
|
3647
5432
|
export declare function fromJsonString<S extends Top>(schema: S): fromJsonString<S>;
|
|
3648
5433
|
/**
|
|
5434
|
+
* Schema type for {@link File}.
|
|
5435
|
+
*
|
|
5436
|
+
* @category Schemas
|
|
3649
5437
|
* @since 4.0.0
|
|
3650
5438
|
*/
|
|
3651
5439
|
export interface File extends instanceOf<globalThis.File> {
|
|
3652
5440
|
}
|
|
3653
5441
|
/**
|
|
5442
|
+
* Schema for JavaScript `File` objects.
|
|
5443
|
+
*
|
|
5444
|
+
* The default JSON serializer encodes a `File` as `{ data, type, name, lastModified }`
|
|
5445
|
+
* where `data` is base64-encoded.
|
|
5446
|
+
*
|
|
5447
|
+
* @category Schemas
|
|
3654
5448
|
* @since 4.0.0
|
|
3655
5449
|
*/
|
|
3656
5450
|
export declare const File: File;
|
|
3657
5451
|
/**
|
|
5452
|
+
* Schema type for {@link FormData}.
|
|
5453
|
+
*
|
|
5454
|
+
* @category Schemas
|
|
3658
5455
|
* @since 4.0.0
|
|
3659
5456
|
*/
|
|
3660
5457
|
export interface FormData extends instanceOf<globalThis.FormData> {
|
|
3661
5458
|
}
|
|
3662
5459
|
/**
|
|
5460
|
+
* Schema for JavaScript `FormData` objects.
|
|
5461
|
+
*
|
|
5462
|
+
* The default JSON serializer encodes a `FormData` as an array of `[key, entry]`
|
|
5463
|
+
* pairs where each entry is tagged as `"String"` or `"File"`.
|
|
5464
|
+
*
|
|
5465
|
+
* @category Schemas
|
|
3663
5466
|
* @since 4.0.0
|
|
3664
5467
|
*/
|
|
3665
5468
|
export declare const FormData: FormData;
|
|
3666
5469
|
/**
|
|
5470
|
+
* Schema type for {@link fromFormData}.
|
|
5471
|
+
*
|
|
5472
|
+
* @category Schemas
|
|
3667
5473
|
* @since 4.0.0
|
|
3668
5474
|
*/
|
|
3669
5475
|
export interface fromFormData<S extends Top> extends decodeTo<S, FormData> {
|
|
@@ -3753,15 +5559,26 @@ export interface fromFormData<S extends Top> extends decodeTo<S, FormData> {
|
|
|
3753
5559
|
*/
|
|
3754
5560
|
export declare function fromFormData<S extends Top>(schema: S): fromFormData<S>;
|
|
3755
5561
|
/**
|
|
5562
|
+
* Schema type for {@link URLSearchParams}.
|
|
5563
|
+
*
|
|
5564
|
+
* @category Schemas
|
|
3756
5565
|
* @since 4.0.0
|
|
3757
5566
|
*/
|
|
3758
5567
|
export interface URLSearchParams extends instanceOf<globalThis.URLSearchParams> {
|
|
3759
5568
|
}
|
|
3760
5569
|
/**
|
|
5570
|
+
* Schema for JavaScript `URLSearchParams` objects.
|
|
5571
|
+
*
|
|
5572
|
+
* The default JSON serializer encodes a `URLSearchParams` as a query string.
|
|
5573
|
+
*
|
|
5574
|
+
* @category Schemas
|
|
3761
5575
|
* @since 4.0.0
|
|
3762
5576
|
*/
|
|
3763
5577
|
export declare const URLSearchParams: URLSearchParams;
|
|
3764
5578
|
/**
|
|
5579
|
+
* Schema type for {@link fromURLSearchParams}.
|
|
5580
|
+
*
|
|
5581
|
+
* @category Schemas
|
|
3765
5582
|
* @since 4.0.0
|
|
3766
5583
|
*/
|
|
3767
5584
|
export interface fromURLSearchParams<S extends Top> extends decodeTo<S, URLSearchParams> {
|
|
@@ -3842,6 +5659,9 @@ export interface fromURLSearchParams<S extends Top> extends decodeTo<S, URLSearc
|
|
|
3842
5659
|
*/
|
|
3843
5660
|
export declare function fromURLSearchParams<S extends Top>(schema: S): fromURLSearchParams<S>;
|
|
3844
5661
|
/**
|
|
5662
|
+
* Schema type for {@link Finite}.
|
|
5663
|
+
*
|
|
5664
|
+
* @category Schemas
|
|
3845
5665
|
* @since 4.0.0
|
|
3846
5666
|
*/
|
|
3847
5667
|
export interface Finite extends Number {
|
|
@@ -3853,6 +5673,9 @@ export interface Finite extends Number {
|
|
|
3853
5673
|
*/
|
|
3854
5674
|
export declare const Finite: Finite;
|
|
3855
5675
|
/**
|
|
5676
|
+
* Schema type for {@link Int}.
|
|
5677
|
+
*
|
|
5678
|
+
* @category Schemas
|
|
3856
5679
|
* @since 4.0.0
|
|
3857
5680
|
*/
|
|
3858
5681
|
export interface Int extends Number {
|
|
@@ -3864,6 +5687,9 @@ export interface Int extends Number {
|
|
|
3864
5687
|
*/
|
|
3865
5688
|
export declare const Int: Int;
|
|
3866
5689
|
/**
|
|
5690
|
+
* Schema type for {@link NumberFromString}.
|
|
5691
|
+
*
|
|
5692
|
+
* @category Schemas
|
|
3867
5693
|
* @since 4.0.0
|
|
3868
5694
|
*/
|
|
3869
5695
|
export interface NumberFromString extends decodeTo<Finite, String> {
|
|
@@ -3881,6 +5707,9 @@ export interface NumberFromString extends decodeTo<Finite, String> {
|
|
|
3881
5707
|
*/
|
|
3882
5708
|
export declare const NumberFromString: NumberFromString;
|
|
3883
5709
|
/**
|
|
5710
|
+
* Schema type for {@link FiniteFromString}.
|
|
5711
|
+
*
|
|
5712
|
+
* @category Schemas
|
|
3884
5713
|
* @since 4.0.0
|
|
3885
5714
|
*/
|
|
3886
5715
|
export interface FiniteFromString extends decodeTo<Finite, String> {
|
|
@@ -3899,6 +5728,9 @@ export interface FiniteFromString extends decodeTo<Finite, String> {
|
|
|
3899
5728
|
*/
|
|
3900
5729
|
export declare const FiniteFromString: FiniteFromString;
|
|
3901
5730
|
/**
|
|
5731
|
+
* Schema type for {@link Trimmed}.
|
|
5732
|
+
*
|
|
5733
|
+
* @category Schemas
|
|
3902
5734
|
* @since 4.0.0
|
|
3903
5735
|
*/
|
|
3904
5736
|
export interface Trimmed extends String {
|
|
@@ -3910,6 +5742,9 @@ export interface Trimmed extends String {
|
|
|
3910
5742
|
*/
|
|
3911
5743
|
export declare const Trimmed: Trimmed;
|
|
3912
5744
|
/**
|
|
5745
|
+
* Schema type for {@link Trim}.
|
|
5746
|
+
*
|
|
5747
|
+
* @category Schemas
|
|
3913
5748
|
* @since 4.0.0
|
|
3914
5749
|
*/
|
|
3915
5750
|
export interface Trim extends decodeTo<Trimmed, String> {
|
|
@@ -3927,6 +5762,9 @@ export interface Trim extends decodeTo<Trimmed, String> {
|
|
|
3927
5762
|
*/
|
|
3928
5763
|
export declare const Trim: Trim;
|
|
3929
5764
|
/**
|
|
5765
|
+
* A union schema for JavaScript property keys: `number | symbol | string`.
|
|
5766
|
+
*
|
|
5767
|
+
* @category Schemas
|
|
3930
5768
|
* @since 4.0.0
|
|
3931
5769
|
*/
|
|
3932
5770
|
export declare const PropertyKey: Union<readonly [Finite, Symbol, String]>;
|
|
@@ -3934,14 +5772,17 @@ export declare const PropertyKey: Union<readonly [Finite, Symbol, String]>;
|
|
|
3934
5772
|
* @since 4.0.0
|
|
3935
5773
|
*/
|
|
3936
5774
|
export declare const StandardSchemaV1FailureResult: Struct<{
|
|
3937
|
-
readonly issues: Array
|
|
5775
|
+
readonly issues: $Array<Struct<{
|
|
3938
5776
|
readonly message: String;
|
|
3939
|
-
readonly path: optional<
|
|
5777
|
+
readonly path: optional<$Array<Union<readonly [Union<readonly [Finite, Symbol, String]>, Struct<{
|
|
3940
5778
|
readonly key: Union<readonly [Finite, Symbol, String]>;
|
|
3941
5779
|
}>]>>>;
|
|
3942
5780
|
}>>;
|
|
3943
5781
|
}>;
|
|
3944
5782
|
/**
|
|
5783
|
+
* Schema type for {@link BooleanFromBit}.
|
|
5784
|
+
*
|
|
5785
|
+
* @category Schemas
|
|
3945
5786
|
* @since 4.0.0
|
|
3946
5787
|
*/
|
|
3947
5788
|
export interface BooleanFromBit extends decodeTo<Boolean, Literals<readonly [0, 1]>> {
|
|
@@ -3954,6 +5795,9 @@ export interface BooleanFromBit extends decodeTo<Boolean, Literals<readonly [0,
|
|
|
3954
5795
|
*/
|
|
3955
5796
|
export declare const BooleanFromBit: BooleanFromBit;
|
|
3956
5797
|
/**
|
|
5798
|
+
* Schema type for {@link Uint8Array}.
|
|
5799
|
+
*
|
|
5800
|
+
* @category Schemas
|
|
3957
5801
|
* @since 4.0.0
|
|
3958
5802
|
*/
|
|
3959
5803
|
export interface Uint8Array extends instanceOf<globalThis.Uint8Array<ArrayBufferLike>> {
|
|
@@ -3970,6 +5814,9 @@ export interface Uint8Array extends instanceOf<globalThis.Uint8Array<ArrayBuffer
|
|
|
3970
5814
|
*/
|
|
3971
5815
|
export declare const Uint8Array: Uint8Array;
|
|
3972
5816
|
/**
|
|
5817
|
+
* Schema type for {@link Uint8ArrayFromBase64}.
|
|
5818
|
+
*
|
|
5819
|
+
* @category Schemas
|
|
3973
5820
|
* @since 4.0.0
|
|
3974
5821
|
*/
|
|
3975
5822
|
export interface Uint8ArrayFromBase64 extends decodeTo<Uint8Array, String> {
|
|
@@ -3989,6 +5836,9 @@ export interface Uint8ArrayFromBase64 extends decodeTo<Uint8Array, String> {
|
|
|
3989
5836
|
*/
|
|
3990
5837
|
export declare const Uint8ArrayFromBase64: Uint8ArrayFromBase64;
|
|
3991
5838
|
/**
|
|
5839
|
+
* Schema type for {@link Uint8ArrayFromBase64Url}.
|
|
5840
|
+
*
|
|
5841
|
+
* @category Schemas
|
|
3992
5842
|
* @since 4.0.0
|
|
3993
5843
|
*/
|
|
3994
5844
|
export interface Uint8ArrayFromBase64Url extends decodeTo<Uint8Array, String> {
|
|
@@ -4008,6 +5858,9 @@ export interface Uint8ArrayFromBase64Url extends decodeTo<Uint8Array, String> {
|
|
|
4008
5858
|
*/
|
|
4009
5859
|
export declare const Uint8ArrayFromBase64Url: Uint8ArrayFromBase64Url;
|
|
4010
5860
|
/**
|
|
5861
|
+
* Schema type for {@link Uint8ArrayFromHex}.
|
|
5862
|
+
*
|
|
5863
|
+
* @category Schemas
|
|
4011
5864
|
* @since 4.0.0
|
|
4012
5865
|
*/
|
|
4013
5866
|
export interface Uint8ArrayFromHex extends decodeTo<Uint8Array, String> {
|
|
@@ -4027,6 +5880,9 @@ export interface Uint8ArrayFromHex extends decodeTo<Uint8Array, String> {
|
|
|
4027
5880
|
*/
|
|
4028
5881
|
export declare const Uint8ArrayFromHex: Uint8ArrayFromHex;
|
|
4029
5882
|
/**
|
|
5883
|
+
* Schema type for {@link DateTimeUtc}.
|
|
5884
|
+
*
|
|
5885
|
+
* @category DateTime
|
|
4030
5886
|
* @since 4.0.0
|
|
4031
5887
|
*/
|
|
4032
5888
|
export interface DateTimeUtc extends declare<DateTime.Utc> {
|
|
@@ -4043,6 +5899,9 @@ export interface DateTimeUtc extends declare<DateTime.Utc> {
|
|
|
4043
5899
|
*/
|
|
4044
5900
|
export declare const DateTimeUtc: DateTimeUtc;
|
|
4045
5901
|
/**
|
|
5902
|
+
* Schema type for {@link DateTimeUtcFromDate}.
|
|
5903
|
+
*
|
|
5904
|
+
* @category DateTime
|
|
4046
5905
|
* @since 4.0.0
|
|
4047
5906
|
*/
|
|
4048
5907
|
export interface DateTimeUtcFromDate extends decodeTo<DateTimeUtc, Date> {
|
|
@@ -4061,6 +5920,9 @@ export interface DateTimeUtcFromDate extends decodeTo<DateTimeUtc, Date> {
|
|
|
4061
5920
|
*/
|
|
4062
5921
|
export declare const DateTimeUtcFromDate: DateTimeUtcFromDate;
|
|
4063
5922
|
/**
|
|
5923
|
+
* Schema type for {@link DateTimeUtcFromString}.
|
|
5924
|
+
*
|
|
5925
|
+
* @category DateTime
|
|
4064
5926
|
* @since 4.0.0
|
|
4065
5927
|
*/
|
|
4066
5928
|
export interface DateTimeUtcFromString extends decodeTo<DateTimeUtc, String> {
|
|
@@ -4081,6 +5943,9 @@ export interface DateTimeUtcFromString extends decodeTo<DateTimeUtc, String> {
|
|
|
4081
5943
|
*/
|
|
4082
5944
|
export declare const DateTimeUtcFromString: DateTimeUtcFromString;
|
|
4083
5945
|
/**
|
|
5946
|
+
* Schema type for {@link DateTimeUtcFromMillis}.
|
|
5947
|
+
*
|
|
5948
|
+
* @category DateTime
|
|
4084
5949
|
* @since 4.0.0
|
|
4085
5950
|
*/
|
|
4086
5951
|
export interface DateTimeUtcFromMillis extends decodeTo<instanceOf<DateTime.Utc>, Number> {
|
|
@@ -4099,12 +5964,98 @@ export interface DateTimeUtcFromMillis extends decodeTo<instanceOf<DateTime.Utc>
|
|
|
4099
5964
|
*/
|
|
4100
5965
|
export declare const DateTimeUtcFromMillis: DateTimeUtcFromMillis;
|
|
4101
5966
|
/**
|
|
5967
|
+
* Schema type for {@link TimeZoneOffset}.
|
|
5968
|
+
*
|
|
5969
|
+
* @category DateTime
|
|
5970
|
+
* @since 4.0.0
|
|
5971
|
+
*/
|
|
5972
|
+
export interface TimeZoneOffset extends declare<DateTime.TimeZone.Offset> {
|
|
5973
|
+
}
|
|
5974
|
+
/**
|
|
5975
|
+
* A schema for `DateTime.TimeZone.Offset` values.
|
|
5976
|
+
*
|
|
5977
|
+
* **Default JSON serializer**
|
|
5978
|
+
*
|
|
5979
|
+
* - encodes `DateTime.TimeZone.Offset` as a number (offset in milliseconds)
|
|
5980
|
+
*
|
|
5981
|
+
* @category DateTime
|
|
5982
|
+
* @since 4.0.0
|
|
5983
|
+
*/
|
|
5984
|
+
export declare const TimeZoneOffset: TimeZoneOffset;
|
|
5985
|
+
/**
|
|
5986
|
+
* Schema type for {@link TimeZoneNamed}.
|
|
5987
|
+
*
|
|
5988
|
+
* @category DateTime
|
|
5989
|
+
* @since 4.0.0
|
|
5990
|
+
*/
|
|
5991
|
+
export interface TimeZoneNamed extends declare<DateTime.TimeZone.Named> {
|
|
5992
|
+
}
|
|
5993
|
+
/**
|
|
5994
|
+
* A schema for `DateTime.TimeZone.Named` values.
|
|
5995
|
+
*
|
|
5996
|
+
* **Default JSON serializer**
|
|
5997
|
+
*
|
|
5998
|
+
* - encodes `DateTime.TimeZone.Named` as a string (IANA time zone identifier)
|
|
5999
|
+
*
|
|
6000
|
+
* @category DateTime
|
|
6001
|
+
* @since 4.0.0
|
|
6002
|
+
*/
|
|
6003
|
+
export declare const TimeZoneNamed: TimeZoneNamed;
|
|
6004
|
+
/**
|
|
6005
|
+
* Schema type for {@link TimeZone}.
|
|
6006
|
+
*
|
|
6007
|
+
* @category DateTime
|
|
6008
|
+
* @since 4.0.0
|
|
6009
|
+
*/
|
|
6010
|
+
export interface TimeZone extends declare<DateTime.TimeZone> {
|
|
6011
|
+
}
|
|
6012
|
+
/**
|
|
6013
|
+
* A schema for `DateTime.TimeZone` values.
|
|
6014
|
+
*
|
|
6015
|
+
* **Default JSON serializer**
|
|
6016
|
+
*
|
|
6017
|
+
* - encodes `DateTime.TimeZone` as a string (IANA identifier or offset like
|
|
6018
|
+
* `+03:00`)
|
|
6019
|
+
*
|
|
6020
|
+
* @category DateTime
|
|
6021
|
+
* @since 4.0.0
|
|
6022
|
+
*/
|
|
6023
|
+
export declare const TimeZone: TimeZone;
|
|
6024
|
+
/**
|
|
6025
|
+
* Schema type for {@link DateTimeZoned}.
|
|
6026
|
+
*
|
|
6027
|
+
* @category DateTime
|
|
6028
|
+
* @since 4.0.0
|
|
6029
|
+
*/
|
|
6030
|
+
export interface DateTimeZoned extends declare<DateTime.Zoned> {
|
|
6031
|
+
}
|
|
6032
|
+
/**
|
|
6033
|
+
* A schema for `DateTime.Zoned` values.
|
|
6034
|
+
*
|
|
6035
|
+
* **Default JSON serializer**
|
|
6036
|
+
*
|
|
6037
|
+
* - encodes `DateTime.Zoned` as a string in the format
|
|
6038
|
+
* `YYYY-MM-DDTHH:mm:ss.sss+HH:MM[Time/Zone]`
|
|
6039
|
+
*
|
|
6040
|
+
* @category DateTime
|
|
6041
|
+
* @since 4.0.0
|
|
6042
|
+
*/
|
|
6043
|
+
export declare const DateTimeZoned: DateTimeZoned;
|
|
6044
|
+
/**
|
|
6045
|
+
* Interface for schema-backed classes created with {@link Class}.
|
|
6046
|
+
*
|
|
6047
|
+
* A `Class` is a TypeScript class whose constructor validates its input
|
|
6048
|
+
* against a {@link Struct} schema. Instances are always structurally valid.
|
|
6049
|
+
*
|
|
6050
|
+
* The interface exposes the schema's `fields`, an `identifier` string, and
|
|
6051
|
+
* helpers such as `mapFields`, `annotate`, `check`, and `extend`.
|
|
6052
|
+
*
|
|
4102
6053
|
* @since 4.0.0
|
|
4103
6054
|
*/
|
|
4104
6055
|
export interface Class<Self, S extends Top & {
|
|
4105
6056
|
readonly fields: Struct.Fields;
|
|
4106
6057
|
}, Inherited> extends Bottom<Self, S["Encoded"], S["DecodingServices"], S["EncodingServices"], AST.Declaration, decodeTo<declareConstructor<Self, S["Encoded"], readonly [S], S["Iso"]>, S>, S["~type.make.in"], S["Iso"], readonly [S], Self, S["~type.mutability"], S["~type.optionality"], S["~type.constructor.default"], S["~encoded.mutability"], S["~encoded.optionality"]> {
|
|
4107
|
-
new (props: S["~type.make.in"], options?: MakeOptions): S["Type"] & Inherited;
|
|
6058
|
+
new (...args: {} extends S["~type.make.in"] ? [props?: S["~type.make.in"], options?: MakeOptions] : [props: S["~type.make.in"], options?: MakeOptions]): S["Type"] & Inherited;
|
|
4108
6059
|
readonly identifier: string;
|
|
4109
6060
|
readonly fields: S["fields"];
|
|
4110
6061
|
/**
|
|
@@ -4127,6 +6078,10 @@ export interface Class<Self, S extends Top & {
|
|
|
4127
6078
|
}
|
|
4128
6079
|
type AddStaticMembers<C, Static> = C & Pick<Static, Exclude<keyof Static, keyof C>>;
|
|
4129
6080
|
/**
|
|
6081
|
+
* A {@link Class} that additionally exposes an `extend` method, allowing
|
|
6082
|
+
* subclasses to be derived with extra fields while inheriting all parent
|
|
6083
|
+
* fields and validation.
|
|
6084
|
+
*
|
|
4130
6085
|
* @since 4.0.0
|
|
4131
6086
|
*/
|
|
4132
6087
|
export interface ExtendableClass<Self, S extends Top & {
|
|
@@ -4135,21 +6090,181 @@ export interface ExtendableClass<Self, S extends Top & {
|
|
|
4135
6090
|
extend<Extended, Static = {}, Brand = {}>(identifier: string): <NewFields extends Struct.Fields>(fields: NewFields, annotations?: Annotations.Declaration<Extended, readonly [Struct<Simplify<Assign<S["fields"], NewFields>>>]>) => AddStaticMembers<ExtendableClass<Extended, Struct<Simplify<Assign<S["fields"], NewFields>>>, Self & Brand>, Static>;
|
|
4136
6091
|
}
|
|
4137
6092
|
/**
|
|
6093
|
+
* Creates a schema-backed class whose constructor validates input against a
|
|
6094
|
+
* {@link Struct} schema. Construction throws a {@link SchemaError} on invalid
|
|
6095
|
+
* input (unless `disableChecks` is set in the options).
|
|
6096
|
+
*
|
|
6097
|
+
* Pass the desired class type as the first type parameter. The second optional
|
|
6098
|
+
* type parameter can be used to add nominal brands.
|
|
6099
|
+
*
|
|
6100
|
+
* **Example** (Basic class)
|
|
6101
|
+
*
|
|
6102
|
+
* ```ts
|
|
6103
|
+
* import { Schema } from "effect"
|
|
6104
|
+
*
|
|
6105
|
+
* class Person extends Schema.Class<Person>("Person")({
|
|
6106
|
+
* name: Schema.String,
|
|
6107
|
+
* age: Schema.Number
|
|
6108
|
+
* }) {}
|
|
6109
|
+
*
|
|
6110
|
+
* const alice = new Person({ name: "Alice", age: 30 })
|
|
6111
|
+
* console.log(alice.name) // "Alice"
|
|
6112
|
+
* console.log(`${alice}`) // "Person({ name: Alice, age: 30 })"
|
|
6113
|
+
* ```
|
|
6114
|
+
*
|
|
6115
|
+
* **Example** (Extending a class)
|
|
6116
|
+
*
|
|
6117
|
+
* ```ts
|
|
6118
|
+
* import { Schema } from "effect"
|
|
6119
|
+
*
|
|
6120
|
+
* class Animal extends Schema.Class<Animal>("Animal")({
|
|
6121
|
+
* name: Schema.String
|
|
6122
|
+
* }) {}
|
|
6123
|
+
*
|
|
6124
|
+
* class Dog extends Animal.extend<Dog>("Dog")({
|
|
6125
|
+
* breed: Schema.String
|
|
6126
|
+
* }) {}
|
|
6127
|
+
*
|
|
6128
|
+
* const dog = new Dog({ name: "Rex", breed: "Labrador" })
|
|
6129
|
+
* console.log(dog.name) // "Rex"
|
|
6130
|
+
* console.log(dog.breed) // "Labrador"
|
|
6131
|
+
* ```
|
|
6132
|
+
*
|
|
4138
6133
|
* @category Constructors
|
|
4139
6134
|
* @since 4.0.0
|
|
4140
6135
|
*/
|
|
4141
6136
|
export declare const Class: {
|
|
4142
6137
|
/**
|
|
6138
|
+
* Creates a schema-backed class whose constructor validates input against a
|
|
6139
|
+
* {@link Struct} schema. Construction throws a {@link SchemaError} on invalid
|
|
6140
|
+
* input (unless `disableChecks` is set in the options).
|
|
6141
|
+
*
|
|
6142
|
+
* Pass the desired class type as the first type parameter. The second optional
|
|
6143
|
+
* type parameter can be used to add nominal brands.
|
|
6144
|
+
*
|
|
6145
|
+
* **Example** (Basic class)
|
|
6146
|
+
*
|
|
6147
|
+
* ```ts
|
|
6148
|
+
* import { Schema } from "effect"
|
|
6149
|
+
*
|
|
6150
|
+
* class Person extends Schema.Class<Person>("Person")({
|
|
6151
|
+
* name: Schema.String,
|
|
6152
|
+
* age: Schema.Number
|
|
6153
|
+
* }) {}
|
|
6154
|
+
*
|
|
6155
|
+
* const alice = new Person({ name: "Alice", age: 30 })
|
|
6156
|
+
* console.log(alice.name) // "Alice"
|
|
6157
|
+
* console.log(`${alice}`) // "Person({ name: Alice, age: 30 })"
|
|
6158
|
+
* ```
|
|
6159
|
+
*
|
|
6160
|
+
* **Example** (Extending a class)
|
|
6161
|
+
*
|
|
6162
|
+
* ```ts
|
|
6163
|
+
* import { Schema } from "effect"
|
|
6164
|
+
*
|
|
6165
|
+
* class Animal extends Schema.Class<Animal>("Animal")({
|
|
6166
|
+
* name: Schema.String
|
|
6167
|
+
* }) {}
|
|
6168
|
+
*
|
|
6169
|
+
* class Dog extends Animal.extend<Dog>("Dog")({
|
|
6170
|
+
* breed: Schema.String
|
|
6171
|
+
* }) {}
|
|
6172
|
+
*
|
|
6173
|
+
* const dog = new Dog({ name: "Rex", breed: "Labrador" })
|
|
6174
|
+
* console.log(dog.name) // "Rex"
|
|
6175
|
+
* console.log(dog.breed) // "Labrador"
|
|
6176
|
+
* ```
|
|
6177
|
+
*
|
|
4143
6178
|
* @category Constructors
|
|
4144
6179
|
* @since 4.0.0
|
|
4145
6180
|
*/
|
|
4146
6181
|
<Self, Brand = {}>(identifier: string): {
|
|
4147
6182
|
/**
|
|
6183
|
+
* Creates a schema-backed class whose constructor validates input against a
|
|
6184
|
+
* {@link Struct} schema. Construction throws a {@link SchemaError} on invalid
|
|
6185
|
+
* input (unless `disableChecks` is set in the options).
|
|
6186
|
+
*
|
|
6187
|
+
* Pass the desired class type as the first type parameter. The second optional
|
|
6188
|
+
* type parameter can be used to add nominal brands.
|
|
6189
|
+
*
|
|
6190
|
+
* **Example** (Basic class)
|
|
6191
|
+
*
|
|
6192
|
+
* ```ts
|
|
6193
|
+
* import { Schema } from "effect"
|
|
6194
|
+
*
|
|
6195
|
+
* class Person extends Schema.Class<Person>("Person")({
|
|
6196
|
+
* name: Schema.String,
|
|
6197
|
+
* age: Schema.Number
|
|
6198
|
+
* }) {}
|
|
6199
|
+
*
|
|
6200
|
+
* const alice = new Person({ name: "Alice", age: 30 })
|
|
6201
|
+
* console.log(alice.name) // "Alice"
|
|
6202
|
+
* console.log(`${alice}`) // "Person({ name: Alice, age: 30 })"
|
|
6203
|
+
* ```
|
|
6204
|
+
*
|
|
6205
|
+
* **Example** (Extending a class)
|
|
6206
|
+
*
|
|
6207
|
+
* ```ts
|
|
6208
|
+
* import { Schema } from "effect"
|
|
6209
|
+
*
|
|
6210
|
+
* class Animal extends Schema.Class<Animal>("Animal")({
|
|
6211
|
+
* name: Schema.String
|
|
6212
|
+
* }) {}
|
|
6213
|
+
*
|
|
6214
|
+
* class Dog extends Animal.extend<Dog>("Dog")({
|
|
6215
|
+
* breed: Schema.String
|
|
6216
|
+
* }) {}
|
|
6217
|
+
*
|
|
6218
|
+
* const dog = new Dog({ name: "Rex", breed: "Labrador" })
|
|
6219
|
+
* console.log(dog.name) // "Rex"
|
|
6220
|
+
* console.log(dog.breed) // "Labrador"
|
|
6221
|
+
* ```
|
|
6222
|
+
*
|
|
4148
6223
|
* @category Constructors
|
|
4149
6224
|
* @since 4.0.0
|
|
4150
6225
|
*/
|
|
4151
6226
|
<const Fields extends Struct.Fields>(fields: Fields, annotations?: Annotations.Declaration<Self, readonly [Struct<Fields>]>): ExtendableClass<Self, Struct<Fields>, Brand>;
|
|
4152
6227
|
/**
|
|
6228
|
+
* Creates a schema-backed class whose constructor validates input against a
|
|
6229
|
+
* {@link Struct} schema. Construction throws a {@link SchemaError} on invalid
|
|
6230
|
+
* input (unless `disableChecks` is set in the options).
|
|
6231
|
+
*
|
|
6232
|
+
* Pass the desired class type as the first type parameter. The second optional
|
|
6233
|
+
* type parameter can be used to add nominal brands.
|
|
6234
|
+
*
|
|
6235
|
+
* **Example** (Basic class)
|
|
6236
|
+
*
|
|
6237
|
+
* ```ts
|
|
6238
|
+
* import { Schema } from "effect"
|
|
6239
|
+
*
|
|
6240
|
+
* class Person extends Schema.Class<Person>("Person")({
|
|
6241
|
+
* name: Schema.String,
|
|
6242
|
+
* age: Schema.Number
|
|
6243
|
+
* }) {}
|
|
6244
|
+
*
|
|
6245
|
+
* const alice = new Person({ name: "Alice", age: 30 })
|
|
6246
|
+
* console.log(alice.name) // "Alice"
|
|
6247
|
+
* console.log(`${alice}`) // "Person({ name: Alice, age: 30 })"
|
|
6248
|
+
* ```
|
|
6249
|
+
*
|
|
6250
|
+
* **Example** (Extending a class)
|
|
6251
|
+
*
|
|
6252
|
+
* ```ts
|
|
6253
|
+
* import { Schema } from "effect"
|
|
6254
|
+
*
|
|
6255
|
+
* class Animal extends Schema.Class<Animal>("Animal")({
|
|
6256
|
+
* name: Schema.String
|
|
6257
|
+
* }) {}
|
|
6258
|
+
*
|
|
6259
|
+
* class Dog extends Animal.extend<Dog>("Dog")({
|
|
6260
|
+
* breed: Schema.String
|
|
6261
|
+
* }) {}
|
|
6262
|
+
*
|
|
6263
|
+
* const dog = new Dog({ name: "Rex", breed: "Labrador" })
|
|
6264
|
+
* console.log(dog.name) // "Rex"
|
|
6265
|
+
* console.log(dog.breed) // "Labrador"
|
|
6266
|
+
* ```
|
|
6267
|
+
*
|
|
4153
6268
|
* @category Constructors
|
|
4154
6269
|
* @since 4.0.0
|
|
4155
6270
|
*/
|
|
@@ -4157,21 +6272,105 @@ export declare const Class: {
|
|
|
4157
6272
|
};
|
|
4158
6273
|
};
|
|
4159
6274
|
/**
|
|
6275
|
+
* Like {@link Class} but automatically adds a `_tag` literal field set to the
|
|
6276
|
+
* given `tag` value. This makes instances compatible with tagged union
|
|
6277
|
+
* discrimination patterns.
|
|
6278
|
+
*
|
|
6279
|
+
* The optional `identifier` parameter overrides the schema identifier;
|
|
6280
|
+
* it defaults to the `tag` value.
|
|
6281
|
+
*
|
|
6282
|
+
* **Example** (Tagged class)
|
|
6283
|
+
*
|
|
6284
|
+
* ```ts
|
|
6285
|
+
* import { Schema } from "effect"
|
|
6286
|
+
*
|
|
6287
|
+
* class Circle extends Schema.TaggedClass<Circle>()("Circle", {
|
|
6288
|
+
* radius: Schema.Number
|
|
6289
|
+
* }) {}
|
|
6290
|
+
*
|
|
6291
|
+
* const c = new Circle({ radius: 5 })
|
|
6292
|
+
* console.log(c._tag) // "Circle"
|
|
6293
|
+
* console.log(c.radius) // 5
|
|
6294
|
+
* ```
|
|
6295
|
+
*
|
|
4160
6296
|
* @category Constructors
|
|
4161
6297
|
* @since 4.0.0
|
|
4162
6298
|
*/
|
|
4163
6299
|
export declare const TaggedClass: {
|
|
4164
6300
|
/**
|
|
6301
|
+
* Like {@link Class} but automatically adds a `_tag` literal field set to the
|
|
6302
|
+
* given `tag` value. This makes instances compatible with tagged union
|
|
6303
|
+
* discrimination patterns.
|
|
6304
|
+
*
|
|
6305
|
+
* The optional `identifier` parameter overrides the schema identifier;
|
|
6306
|
+
* it defaults to the `tag` value.
|
|
6307
|
+
*
|
|
6308
|
+
* **Example** (Tagged class)
|
|
6309
|
+
*
|
|
6310
|
+
* ```ts
|
|
6311
|
+
* import { Schema } from "effect"
|
|
6312
|
+
*
|
|
6313
|
+
* class Circle extends Schema.TaggedClass<Circle>()("Circle", {
|
|
6314
|
+
* radius: Schema.Number
|
|
6315
|
+
* }) {}
|
|
6316
|
+
*
|
|
6317
|
+
* const c = new Circle({ radius: 5 })
|
|
6318
|
+
* console.log(c._tag) // "Circle"
|
|
6319
|
+
* console.log(c.radius) // 5
|
|
6320
|
+
* ```
|
|
6321
|
+
*
|
|
4165
6322
|
* @category Constructors
|
|
4166
6323
|
* @since 4.0.0
|
|
4167
6324
|
*/
|
|
4168
6325
|
<Self, Brand = {}>(identifier?: string): {
|
|
4169
6326
|
/**
|
|
6327
|
+
* Like {@link Class} but automatically adds a `_tag` literal field set to the
|
|
6328
|
+
* given `tag` value. This makes instances compatible with tagged union
|
|
6329
|
+
* discrimination patterns.
|
|
6330
|
+
*
|
|
6331
|
+
* The optional `identifier` parameter overrides the schema identifier;
|
|
6332
|
+
* it defaults to the `tag` value.
|
|
6333
|
+
*
|
|
6334
|
+
* **Example** (Tagged class)
|
|
6335
|
+
*
|
|
6336
|
+
* ```ts
|
|
6337
|
+
* import { Schema } from "effect"
|
|
6338
|
+
*
|
|
6339
|
+
* class Circle extends Schema.TaggedClass<Circle>()("Circle", {
|
|
6340
|
+
* radius: Schema.Number
|
|
6341
|
+
* }) {}
|
|
6342
|
+
*
|
|
6343
|
+
* const c = new Circle({ radius: 5 })
|
|
6344
|
+
* console.log(c._tag) // "Circle"
|
|
6345
|
+
* console.log(c.radius) // 5
|
|
6346
|
+
* ```
|
|
6347
|
+
*
|
|
4170
6348
|
* @category Constructors
|
|
4171
6349
|
* @since 4.0.0
|
|
4172
6350
|
*/
|
|
4173
6351
|
<Tag extends string, const Fields extends Struct.Fields>(tag: Tag, fields: Fields, annotations?: Annotations.Declaration<Self, readonly [TaggedStruct<Tag, Fields>]>): ExtendableClass<Self, TaggedStruct<Tag, Fields>, Brand>;
|
|
4174
6352
|
/**
|
|
6353
|
+
* Like {@link Class} but automatically adds a `_tag` literal field set to the
|
|
6354
|
+
* given `tag` value. This makes instances compatible with tagged union
|
|
6355
|
+
* discrimination patterns.
|
|
6356
|
+
*
|
|
6357
|
+
* The optional `identifier` parameter overrides the schema identifier;
|
|
6358
|
+
* it defaults to the `tag` value.
|
|
6359
|
+
*
|
|
6360
|
+
* **Example** (Tagged class)
|
|
6361
|
+
*
|
|
6362
|
+
* ```ts
|
|
6363
|
+
* import { Schema } from "effect"
|
|
6364
|
+
*
|
|
6365
|
+
* class Circle extends Schema.TaggedClass<Circle>()("Circle", {
|
|
6366
|
+
* radius: Schema.Number
|
|
6367
|
+
* }) {}
|
|
6368
|
+
*
|
|
6369
|
+
* const c = new Circle({ radius: 5 })
|
|
6370
|
+
* console.log(c._tag) // "Circle"
|
|
6371
|
+
* console.log(c.radius) // 5
|
|
6372
|
+
* ```
|
|
6373
|
+
*
|
|
4175
6374
|
* @category Constructors
|
|
4176
6375
|
* @since 4.0.0
|
|
4177
6376
|
*/
|
|
@@ -4183,6 +6382,10 @@ export declare const TaggedClass: {
|
|
|
4183
6382
|
};
|
|
4184
6383
|
};
|
|
4185
6384
|
/**
|
|
6385
|
+
* Interface for schema-backed error classes created with {@link ErrorClass}.
|
|
6386
|
+
* Extends {@link ExtendableClass} and is also a `YieldableError`, so instances
|
|
6387
|
+
* can be yielded inside `Effect.gen` as failures.
|
|
6388
|
+
*
|
|
4186
6389
|
* @since 4.0.0
|
|
4187
6390
|
*/
|
|
4188
6391
|
export interface ErrorClass<Self, S extends Top & {
|
|
@@ -4190,21 +6393,97 @@ export interface ErrorClass<Self, S extends Top & {
|
|
|
4190
6393
|
}, Inherited> extends ExtendableClass<Self, S, Inherited> {
|
|
4191
6394
|
}
|
|
4192
6395
|
/**
|
|
6396
|
+
* Creates a schema-backed error class that can be used as a typed,
|
|
6397
|
+
* yieldable error in Effect programs. Combines {@link Class} validation with
|
|
6398
|
+
* the `YieldableError` interface so instances can be yielded directly inside
|
|
6399
|
+
* `Effect.gen`.
|
|
6400
|
+
*
|
|
6401
|
+
* **Example** (Schema-backed error)
|
|
6402
|
+
*
|
|
6403
|
+
* ```ts
|
|
6404
|
+
* import { Effect, Schema } from "effect"
|
|
6405
|
+
*
|
|
6406
|
+
* class NotFound extends Schema.ErrorClass<NotFound>("NotFound")({
|
|
6407
|
+
* id: Schema.Number
|
|
6408
|
+
* }) {}
|
|
6409
|
+
*
|
|
6410
|
+
* const program = Effect.gen(function*() {
|
|
6411
|
+
* yield* new NotFound({ id: 1 })
|
|
6412
|
+
* })
|
|
6413
|
+
* ```
|
|
6414
|
+
*
|
|
4193
6415
|
* @category Constructors
|
|
4194
6416
|
* @since 4.0.0
|
|
4195
6417
|
*/
|
|
4196
6418
|
export declare const ErrorClass: {
|
|
4197
6419
|
/**
|
|
6420
|
+
* Creates a schema-backed error class that can be used as a typed,
|
|
6421
|
+
* yieldable error in Effect programs. Combines {@link Class} validation with
|
|
6422
|
+
* the `YieldableError` interface so instances can be yielded directly inside
|
|
6423
|
+
* `Effect.gen`.
|
|
6424
|
+
*
|
|
6425
|
+
* **Example** (Schema-backed error)
|
|
6426
|
+
*
|
|
6427
|
+
* ```ts
|
|
6428
|
+
* import { Effect, Schema } from "effect"
|
|
6429
|
+
*
|
|
6430
|
+
* class NotFound extends Schema.ErrorClass<NotFound>("NotFound")({
|
|
6431
|
+
* id: Schema.Number
|
|
6432
|
+
* }) {}
|
|
6433
|
+
*
|
|
6434
|
+
* const program = Effect.gen(function*() {
|
|
6435
|
+
* yield* new NotFound({ id: 1 })
|
|
6436
|
+
* })
|
|
6437
|
+
* ```
|
|
6438
|
+
*
|
|
4198
6439
|
* @category Constructors
|
|
4199
6440
|
* @since 4.0.0
|
|
4200
6441
|
*/
|
|
4201
6442
|
<Self, Brand = {}>(identifier: string): {
|
|
4202
6443
|
/**
|
|
6444
|
+
* Creates a schema-backed error class that can be used as a typed,
|
|
6445
|
+
* yieldable error in Effect programs. Combines {@link Class} validation with
|
|
6446
|
+
* the `YieldableError` interface so instances can be yielded directly inside
|
|
6447
|
+
* `Effect.gen`.
|
|
6448
|
+
*
|
|
6449
|
+
* **Example** (Schema-backed error)
|
|
6450
|
+
*
|
|
6451
|
+
* ```ts
|
|
6452
|
+
* import { Effect, Schema } from "effect"
|
|
6453
|
+
*
|
|
6454
|
+
* class NotFound extends Schema.ErrorClass<NotFound>("NotFound")({
|
|
6455
|
+
* id: Schema.Number
|
|
6456
|
+
* }) {}
|
|
6457
|
+
*
|
|
6458
|
+
* const program = Effect.gen(function*() {
|
|
6459
|
+
* yield* new NotFound({ id: 1 })
|
|
6460
|
+
* })
|
|
6461
|
+
* ```
|
|
6462
|
+
*
|
|
4203
6463
|
* @category Constructors
|
|
4204
6464
|
* @since 4.0.0
|
|
4205
6465
|
*/
|
|
4206
6466
|
<const Fields extends Struct.Fields>(fields: Fields, annotations?: Annotations.Declaration<Self, readonly [Struct<Fields>]>): ErrorClass<Self, Struct<Fields>, Cause_.YieldableError & Brand>;
|
|
4207
6467
|
/**
|
|
6468
|
+
* Creates a schema-backed error class that can be used as a typed,
|
|
6469
|
+
* yieldable error in Effect programs. Combines {@link Class} validation with
|
|
6470
|
+
* the `YieldableError` interface so instances can be yielded directly inside
|
|
6471
|
+
* `Effect.gen`.
|
|
6472
|
+
*
|
|
6473
|
+
* **Example** (Schema-backed error)
|
|
6474
|
+
*
|
|
6475
|
+
* ```ts
|
|
6476
|
+
* import { Effect, Schema } from "effect"
|
|
6477
|
+
*
|
|
6478
|
+
* class NotFound extends Schema.ErrorClass<NotFound>("NotFound")({
|
|
6479
|
+
* id: Schema.Number
|
|
6480
|
+
* }) {}
|
|
6481
|
+
*
|
|
6482
|
+
* const program = Effect.gen(function*() {
|
|
6483
|
+
* yield* new NotFound({ id: 1 })
|
|
6484
|
+
* })
|
|
6485
|
+
* ```
|
|
6486
|
+
*
|
|
4208
6487
|
* @category Constructors
|
|
4209
6488
|
* @since 4.0.0
|
|
4210
6489
|
*/
|
|
@@ -4212,21 +6491,93 @@ export declare const ErrorClass: {
|
|
|
4212
6491
|
};
|
|
4213
6492
|
};
|
|
4214
6493
|
/**
|
|
6494
|
+
* Like {@link ErrorClass} but automatically adds a `_tag` literal field. The
|
|
6495
|
+
* resulting class is both a schema-validated, yieldable error and a tagged
|
|
6496
|
+
* union member.
|
|
6497
|
+
*
|
|
6498
|
+
* **Example** (Tagged error class)
|
|
6499
|
+
*
|
|
6500
|
+
* ```ts
|
|
6501
|
+
* import { Effect, Schema } from "effect"
|
|
6502
|
+
*
|
|
6503
|
+
* class NotFound extends Schema.TaggedErrorClass<NotFound>()("NotFound", {
|
|
6504
|
+
* id: Schema.Number
|
|
6505
|
+
* }) {}
|
|
6506
|
+
*
|
|
6507
|
+
* const program = Effect.gen(function*() {
|
|
6508
|
+
* yield* new NotFound({ id: 42 })
|
|
6509
|
+
* })
|
|
6510
|
+
* ```
|
|
6511
|
+
*
|
|
4215
6512
|
* @category Constructors
|
|
4216
6513
|
* @since 4.0.0
|
|
4217
6514
|
*/
|
|
4218
6515
|
export declare const TaggedErrorClass: {
|
|
4219
6516
|
/**
|
|
6517
|
+
* Like {@link ErrorClass} but automatically adds a `_tag` literal field. The
|
|
6518
|
+
* resulting class is both a schema-validated, yieldable error and a tagged
|
|
6519
|
+
* union member.
|
|
6520
|
+
*
|
|
6521
|
+
* **Example** (Tagged error class)
|
|
6522
|
+
*
|
|
6523
|
+
* ```ts
|
|
6524
|
+
* import { Effect, Schema } from "effect"
|
|
6525
|
+
*
|
|
6526
|
+
* class NotFound extends Schema.TaggedErrorClass<NotFound>()("NotFound", {
|
|
6527
|
+
* id: Schema.Number
|
|
6528
|
+
* }) {}
|
|
6529
|
+
*
|
|
6530
|
+
* const program = Effect.gen(function*() {
|
|
6531
|
+
* yield* new NotFound({ id: 42 })
|
|
6532
|
+
* })
|
|
6533
|
+
* ```
|
|
6534
|
+
*
|
|
4220
6535
|
* @category Constructors
|
|
4221
6536
|
* @since 4.0.0
|
|
4222
6537
|
*/
|
|
4223
6538
|
<Self, Brand = {}>(identifier?: string): {
|
|
4224
6539
|
/**
|
|
6540
|
+
* Like {@link ErrorClass} but automatically adds a `_tag` literal field. The
|
|
6541
|
+
* resulting class is both a schema-validated, yieldable error and a tagged
|
|
6542
|
+
* union member.
|
|
6543
|
+
*
|
|
6544
|
+
* **Example** (Tagged error class)
|
|
6545
|
+
*
|
|
6546
|
+
* ```ts
|
|
6547
|
+
* import { Effect, Schema } from "effect"
|
|
6548
|
+
*
|
|
6549
|
+
* class NotFound extends Schema.TaggedErrorClass<NotFound>()("NotFound", {
|
|
6550
|
+
* id: Schema.Number
|
|
6551
|
+
* }) {}
|
|
6552
|
+
*
|
|
6553
|
+
* const program = Effect.gen(function*() {
|
|
6554
|
+
* yield* new NotFound({ id: 42 })
|
|
6555
|
+
* })
|
|
6556
|
+
* ```
|
|
6557
|
+
*
|
|
4225
6558
|
* @category Constructors
|
|
4226
6559
|
* @since 4.0.0
|
|
4227
6560
|
*/
|
|
4228
6561
|
<Tag extends string, const Fields extends Struct.Fields>(tag: Tag, fields: Fields, annotations?: Annotations.Declaration<Self, readonly [TaggedStruct<Tag, Fields>]>): ErrorClass<Self, TaggedStruct<Tag, Fields>, Cause_.YieldableError & Brand>;
|
|
4229
6562
|
/**
|
|
6563
|
+
* Like {@link ErrorClass} but automatically adds a `_tag` literal field. The
|
|
6564
|
+
* resulting class is both a schema-validated, yieldable error and a tagged
|
|
6565
|
+
* union member.
|
|
6566
|
+
*
|
|
6567
|
+
* **Example** (Tagged error class)
|
|
6568
|
+
*
|
|
6569
|
+
* ```ts
|
|
6570
|
+
* import { Effect, Schema } from "effect"
|
|
6571
|
+
*
|
|
6572
|
+
* class NotFound extends Schema.TaggedErrorClass<NotFound>()("NotFound", {
|
|
6573
|
+
* id: Schema.Number
|
|
6574
|
+
* }) {}
|
|
6575
|
+
*
|
|
6576
|
+
* const program = Effect.gen(function*() {
|
|
6577
|
+
* yield* new NotFound({ id: 42 })
|
|
6578
|
+
* })
|
|
6579
|
+
* ```
|
|
6580
|
+
*
|
|
4230
6581
|
* @category Constructors
|
|
4231
6582
|
* @since 4.0.0
|
|
4232
6583
|
*/
|
|
@@ -4238,16 +6589,43 @@ export declare const TaggedErrorClass: {
|
|
|
4238
6589
|
};
|
|
4239
6590
|
};
|
|
4240
6591
|
/**
|
|
6592
|
+
* A thunk that, given the `fast-check` module, returns an `Arbitrary<T>`.
|
|
6593
|
+
* Use this type when you need to defer instantiation of the arbitrary, for
|
|
6594
|
+
* example to support recursive schemas.
|
|
6595
|
+
*
|
|
4241
6596
|
* @category Arbitrary
|
|
4242
6597
|
* @since 4.0.0
|
|
4243
6598
|
*/
|
|
4244
6599
|
export type LazyArbitrary<T> = (fc: typeof FastCheck) => FastCheck.Arbitrary<T>;
|
|
4245
6600
|
/**
|
|
6601
|
+
* Derives a {@link LazyArbitrary} from a schema. The result is memoized so
|
|
6602
|
+
* repeated calls with the same schema are cheap.
|
|
6603
|
+
*
|
|
6604
|
+
* Prefer {@link toArbitrary} when you just need the arbitrary directly.
|
|
6605
|
+
*
|
|
4246
6606
|
* @category Arbitrary
|
|
4247
6607
|
* @since 4.0.0
|
|
4248
6608
|
*/
|
|
4249
6609
|
export declare function toArbitraryLazy<S extends Top>(schema: S): LazyArbitrary<S["Type"]>;
|
|
4250
6610
|
/**
|
|
6611
|
+
* Derives a `fast-check` `Arbitrary` from a schema for property-based
|
|
6612
|
+
* testing. The derived arbitrary generates values that satisfy the schema.
|
|
6613
|
+
*
|
|
6614
|
+
* **Example** (Generating arbitrary values)
|
|
6615
|
+
*
|
|
6616
|
+
* ```ts
|
|
6617
|
+
* import { Schema } from "effect"
|
|
6618
|
+
* import * as FastCheck from "fast-check"
|
|
6619
|
+
*
|
|
6620
|
+
* const PersonArb = Schema.toArbitrary(
|
|
6621
|
+
* Schema.Struct({ name: Schema.String, age: Schema.Number })
|
|
6622
|
+
* )
|
|
6623
|
+
*
|
|
6624
|
+
* // Sample a random value
|
|
6625
|
+
* const sample = FastCheck.sample(PersonArb, 1)[0]
|
|
6626
|
+
* console.log(typeof sample.name) // "string"
|
|
6627
|
+
* ```
|
|
6628
|
+
*
|
|
4251
6629
|
* @category Arbitrary
|
|
4252
6630
|
* @since 4.0.0
|
|
4253
6631
|
*/
|
|
@@ -4263,6 +6641,13 @@ export declare function toArbitrary<S extends Top>(schema: S): FastCheck.Arbitra
|
|
|
4263
6641
|
*/
|
|
4264
6642
|
export declare function overrideToFormatter<S extends Top>(toFormatter: () => Formatter<S["Type"]>): (self: S) => S["~rebuild.out"];
|
|
4265
6643
|
/**
|
|
6644
|
+
* Derives a string formatter function from a schema. The formatter converts
|
|
6645
|
+
* a value to its human-readable string representation, recursing into structs,
|
|
6646
|
+
* arrays, and unions.
|
|
6647
|
+
*
|
|
6648
|
+
* The optional `onBefore` hook lets you intercept specific AST nodes before
|
|
6649
|
+
* the default formatting logic runs.
|
|
6650
|
+
*
|
|
4266
6651
|
* @category Formatter
|
|
4267
6652
|
* @since 4.0.0
|
|
4268
6653
|
*/
|
|
@@ -4270,26 +6655,46 @@ export declare function toFormatter<T>(schema: Schema<T>, options?: {
|
|
|
4270
6655
|
readonly onBefore?: ((ast: AST.AST, recur: (ast: AST.AST) => Formatter<any>) => Formatter<any> | undefined) | undefined;
|
|
4271
6656
|
}): Formatter<T>;
|
|
4272
6657
|
/**
|
|
4273
|
-
*
|
|
4274
|
-
*
|
|
4275
|
-
*
|
|
4276
|
-
* the schema invariant.
|
|
6658
|
+
* Overrides the equivalence derivation for a schema by supplying a custom
|
|
6659
|
+
* `Equivalence`. Use this when the default structural equivalence derived by
|
|
6660
|
+
* {@link toEquivalence} is not appropriate for a type.
|
|
4277
6661
|
*
|
|
4278
6662
|
* @category Equivalence
|
|
4279
6663
|
* @since 4.0.0
|
|
4280
6664
|
*/
|
|
4281
6665
|
export declare function overrideToEquivalence<S extends Top>(toEquivalence: () => Equivalence.Equivalence<S["Type"]>): (self: S) => S["~rebuild.out"];
|
|
4282
6666
|
/**
|
|
6667
|
+
* Derives an `Equivalence` from a schema. Two values are considered equal when
|
|
6668
|
+
* every field (and nested field) compares equal according to the schema
|
|
6669
|
+
* structure.
|
|
6670
|
+
*
|
|
6671
|
+
* **Example** (Struct equivalence)
|
|
6672
|
+
*
|
|
6673
|
+
* ```ts
|
|
6674
|
+
* import { Schema } from "effect"
|
|
6675
|
+
*
|
|
6676
|
+
* const eq = Schema.toEquivalence(Schema.Struct({ id: Schema.Number, name: Schema.String }))
|
|
6677
|
+
*
|
|
6678
|
+
* console.log(eq({ id: 1, name: "Alice" }, { id: 1, name: "Alice" })) // true
|
|
6679
|
+
* console.log(eq({ id: 1, name: "Alice" }, { id: 2, name: "Alice" })) // false
|
|
6680
|
+
* ```
|
|
6681
|
+
*
|
|
4283
6682
|
* @category Equivalence
|
|
4284
6683
|
* @since 4.0.0
|
|
4285
6684
|
*/
|
|
4286
6685
|
export declare function toEquivalence<T>(schema: Schema<T>): Equivalence.Equivalence<T>;
|
|
4287
6686
|
/**
|
|
6687
|
+
* Derives an intermediate `SchemaRepresentation.Document` from a schema. This
|
|
6688
|
+
* document is used internally by {@link toJsonSchemaDocument} and related
|
|
6689
|
+
* functions to produce JSON Schema output.
|
|
6690
|
+
*
|
|
4288
6691
|
* @category Representation
|
|
4289
6692
|
* @since 4.0.0
|
|
4290
6693
|
*/
|
|
4291
6694
|
export declare function toRepresentation(schema: Top): SchemaRepresentation.Document;
|
|
4292
6695
|
/**
|
|
6696
|
+
* Options for {@link toJsonSchemaDocument}.
|
|
6697
|
+
*
|
|
4293
6698
|
* @since 4.0.0
|
|
4294
6699
|
*/
|
|
4295
6700
|
export interface ToJsonSchemaOptions {
|
|
@@ -4319,22 +6724,31 @@ export interface ToJsonSchemaOptions {
|
|
|
4319
6724
|
*/
|
|
4320
6725
|
export declare function toJsonSchemaDocument(schema: Top, options?: ToJsonSchemaOptions): JsonSchema.Document<"draft-2020-12">;
|
|
4321
6726
|
/**
|
|
4322
|
-
*
|
|
6727
|
+
* Derives a canonical JSON codec from a schema. The encoded form is `unknown`
|
|
6728
|
+
* (any JSON-compatible value), decoded to the schema's `Type`.
|
|
6729
|
+
*
|
|
6730
|
+
* @category Canonical Codecs
|
|
4323
6731
|
* @since 4.0.0
|
|
4324
6732
|
*/
|
|
4325
|
-
export declare function toCodecJson<T, E, RD, RE>(schema: Codec<T, E, RD, RE>): Codec<T,
|
|
6733
|
+
export declare function toCodecJson<T, E, RD, RE>(schema: Codec<T, E, RD, RE>): Codec<T, Json, RD, RE>;
|
|
4326
6734
|
/**
|
|
4327
|
-
*
|
|
6735
|
+
* Derives an isomorphism codec from a schema. The encoded form is the
|
|
6736
|
+
* schema's `Iso` type — the intermediate representation used for round-tripping.
|
|
6737
|
+
*
|
|
6738
|
+
* @category Canonical Codecs
|
|
4328
6739
|
* @since 4.0.0
|
|
4329
6740
|
*/
|
|
4330
6741
|
export declare function toCodecIso<S extends Top>(schema: S): Codec<S["Type"], S["Iso"]>;
|
|
4331
6742
|
/**
|
|
4332
|
-
* @
|
|
6743
|
+
* A {@link Tree} of `string | undefined` nodes. Leaf values are either a
|
|
6744
|
+
* string representation or `undefined` for opaque/declaration types.
|
|
6745
|
+
*
|
|
6746
|
+
* @category Canonical Codecs
|
|
4333
6747
|
* @since 4.0.0
|
|
4334
6748
|
*/
|
|
4335
6749
|
export type StringTree = Tree<string | undefined>;
|
|
4336
6750
|
/**
|
|
4337
|
-
* The StringTree
|
|
6751
|
+
* The StringTree canonical codec converts **every leaf value to a string**, while
|
|
4338
6752
|
* preserving the original structure.
|
|
4339
6753
|
*
|
|
4340
6754
|
* Declarations are converted to `undefined` (unless they have a
|
|
@@ -4348,7 +6762,7 @@ export type StringTree = Tree<string | undefined>;
|
|
|
4348
6762
|
*
|
|
4349
6763
|
* Defaults to `false`.
|
|
4350
6764
|
*
|
|
4351
|
-
* @category
|
|
6765
|
+
* @category Canonical Codecs
|
|
4352
6766
|
* @since 4.0.0
|
|
4353
6767
|
*/
|
|
4354
6768
|
export declare function toCodecStringTree<T, E, RD, RE>(schema: Codec<T, E, RD, RE>): Codec<T, StringTree, RD, RE>;
|
|
@@ -4368,26 +6782,40 @@ type XmlEncoderOptions = {
|
|
|
4368
6782
|
readonly sortKeys?: boolean | undefined;
|
|
4369
6783
|
};
|
|
4370
6784
|
/**
|
|
4371
|
-
*
|
|
6785
|
+
* Derives an XML encoder from a codec. Encodes a value to an XML string by
|
|
6786
|
+
* first converting it through {@link toCodecStringTree}, then serializing the
|
|
6787
|
+
* resulting tree to XML.
|
|
6788
|
+
*
|
|
6789
|
+
* @category Canonical Codecs
|
|
4372
6790
|
* @since 4.0.0
|
|
4373
6791
|
*/
|
|
4374
6792
|
export declare function toEncoderXml<T, E, RD, RE>(codec: Codec<T, E, RD, RE>, options?: XmlEncoderOptions): (t: T) => Effect.Effect<string, SchemaError, RE>;
|
|
4375
6793
|
/**
|
|
6794
|
+
* Derives an `Iso` optic from a schema that isomorphically converts between
|
|
6795
|
+
* the schema's `Type` and its `Iso` (intermediate / serialized form).
|
|
6796
|
+
*
|
|
4376
6797
|
* @category Optic
|
|
4377
6798
|
* @since 4.0.0
|
|
4378
6799
|
*/
|
|
4379
6800
|
export declare function toIso<S extends Top>(schema: S): Optic_.Iso<S["Type"], S["Iso"]>;
|
|
4380
6801
|
/**
|
|
6802
|
+
* Returns an identity `Iso` over the schema's source (`Type`) side.
|
|
6803
|
+
*
|
|
4381
6804
|
* @category Optic
|
|
4382
6805
|
* @since 4.0.0
|
|
4383
6806
|
*/
|
|
4384
6807
|
export declare function toIsoSource<S extends Top>(_: S): Optic_.Iso<S["Type"], S["Type"]>;
|
|
4385
6808
|
/**
|
|
6809
|
+
* Returns an identity `Iso` over the schema's focus (`Iso`) side.
|
|
6810
|
+
*
|
|
4386
6811
|
* @category Optic
|
|
4387
6812
|
* @since 4.0.0
|
|
4388
6813
|
*/
|
|
4389
6814
|
export declare function toIsoFocus<S extends Top>(_: S): Optic_.Iso<S["Iso"], S["Iso"]>;
|
|
4390
6815
|
/**
|
|
6816
|
+
* The schema type returned by {@link overrideToCodecIso}. Carries a custom
|
|
6817
|
+
* `Iso` type parameter and exposes the original `schema`.
|
|
6818
|
+
*
|
|
4391
6819
|
* @category Optic
|
|
4392
6820
|
* @since 4.0.0
|
|
4393
6821
|
*/
|
|
@@ -4396,10 +6824,11 @@ export interface overrideToCodecIso<S extends Top, Iso> extends Bottom<S["Type"]
|
|
|
4396
6824
|
readonly schema: S;
|
|
4397
6825
|
}
|
|
4398
6826
|
/**
|
|
4399
|
-
*
|
|
4400
|
-
*
|
|
4401
|
-
*
|
|
4402
|
-
* the
|
|
6827
|
+
* Overrides the ISO codec derivation for a schema by providing a target codec
|
|
6828
|
+
* and explicit `decode`/`encode` getters. The resulting schema carries a
|
|
6829
|
+
* custom `Iso` type, which changes the schema's type parameter — use
|
|
6830
|
+
* {@link overrideToCodecIso} when the default ISO transformation is not
|
|
6831
|
+
* appropriate.
|
|
4403
6832
|
*
|
|
4404
6833
|
* @category Optic
|
|
4405
6834
|
* @since 4.0.0
|
|
@@ -4409,6 +6838,10 @@ export declare function overrideToCodecIso<S extends Top, Iso>(to: Codec<Iso>, t
|
|
|
4409
6838
|
readonly encode: Getter.Getter<Iso, S["Type"]>;
|
|
4410
6839
|
}): (schema: S) => overrideToCodecIso<S, Iso>;
|
|
4411
6840
|
/**
|
|
6841
|
+
* Derives a JSON Patch differ from a codec. Serializes values to JSON (via
|
|
6842
|
+
* {@link toCodecJson}), computes RFC 6902 JSON Patch operations between old
|
|
6843
|
+
* and new values, and can apply patches back to the typed value.
|
|
6844
|
+
*
|
|
4412
6845
|
* @category JsonPatch
|
|
4413
6846
|
* @since 4.0.0
|
|
4414
6847
|
*/
|
|
@@ -4417,53 +6850,47 @@ export declare function toDifferJsonPatch<T, E>(schema: Codec<T, E>): Differ<T,
|
|
|
4417
6850
|
* @category Tree
|
|
4418
6851
|
* @since 4.0.0
|
|
4419
6852
|
*/
|
|
4420
|
-
export type Tree<Node> = Node |
|
|
6853
|
+
export type Tree<Node> = Node | TreeRecord<Node> | ReadonlyArray<Tree<Node>>;
|
|
4421
6854
|
/**
|
|
6855
|
+
* A record node in a {@link Tree}: an object mapping string keys to child
|
|
6856
|
+
* `Tree` nodes.
|
|
6857
|
+
*
|
|
4422
6858
|
* @category Tree
|
|
4423
6859
|
* @since 4.0.0
|
|
4424
6860
|
*/
|
|
4425
|
-
export interface
|
|
6861
|
+
export interface TreeRecord<A> {
|
|
4426
6862
|
readonly [x: string]: Tree<A>;
|
|
4427
6863
|
}
|
|
4428
6864
|
/**
|
|
6865
|
+
* Creates a recursive schema for a {@link Tree} of values described by `node`.
|
|
6866
|
+
* The resulting schema accepts a single node value, an array of trees, or an
|
|
6867
|
+
* object whose values are trees.
|
|
6868
|
+
*
|
|
4429
6869
|
* @category Tree
|
|
4430
6870
|
* @since 4.0.0
|
|
4431
6871
|
*/
|
|
4432
|
-
export declare function Tree<S extends Top>(node: S): Union<readonly [S, Array
|
|
4433
|
-
/**
|
|
4434
|
-
* @category Tree
|
|
4435
|
-
* @since 4.0.0
|
|
4436
|
-
*/
|
|
4437
|
-
export type MutableTree<A> = A | MutableTreeRecord<A> | Array<MutableTree<A>>;
|
|
4438
|
-
/**
|
|
4439
|
-
* @category Tree
|
|
4440
|
-
* @since 4.0.0
|
|
4441
|
-
*/
|
|
4442
|
-
export interface MutableTreeRecord<A> {
|
|
4443
|
-
[x: string]: MutableTree<A>;
|
|
4444
|
-
}
|
|
4445
|
-
/**
|
|
4446
|
-
* @category Tree
|
|
4447
|
-
* @since 4.0.0
|
|
4448
|
-
*/
|
|
4449
|
-
export declare function MutableTree<S extends Top>(node: S): Union<readonly [S, mutable<Array$<suspend<Codec<MutableTree<S["Type"]>, MutableTree<S["Encoded"]>, S["DecodingServices"], S["EncodingServices"]>>>>, Record$<String, mutableKey<suspend<Codec<MutableTree<S["Type"]>, MutableTree<S["Encoded"]>, S["DecodingServices"], S["EncodingServices"]>>>>]>;
|
|
6872
|
+
export declare function Tree<S extends Top>(node: S): Union<readonly [S, $Array<suspend<Codec<Tree<S["Type"]>, Tree<S["Encoded"]>, S["DecodingServices"], S["EncodingServices"]>>>, $Record<String, suspend<Codec<Tree<S["Type"]>, Tree<S["Encoded"]>, S["DecodingServices"], S["EncodingServices"]>>>]>;
|
|
4450
6873
|
/**
|
|
6874
|
+
* Recursive TypeScript type for any valid immutable JSON value: `null`,
|
|
6875
|
+
* `number`, `boolean`, `string`, a readonly array of `Json` values, or a
|
|
6876
|
+
* readonly record of `string → Json`. For the corresponding schema, see the
|
|
6877
|
+
* {@link Json} const.
|
|
6878
|
+
*
|
|
4451
6879
|
* @category JSON
|
|
4452
6880
|
* @since 4.0.0
|
|
4453
6881
|
*/
|
|
4454
6882
|
export type Json = null | number | boolean | string | JsonArray | JsonObject;
|
|
4455
6883
|
/**
|
|
4456
|
-
* @
|
|
4457
|
-
*
|
|
4458
|
-
*/
|
|
4459
|
-
export declare const Json: Codec<Json>;
|
|
4460
|
-
/**
|
|
6884
|
+
* A readonly array of {@link Json} values.
|
|
6885
|
+
*
|
|
4461
6886
|
* @category JSON
|
|
4462
6887
|
* @since 4.0.0
|
|
4463
6888
|
*/
|
|
4464
6889
|
export interface JsonArray extends ReadonlyArray<Json> {
|
|
4465
6890
|
}
|
|
4466
6891
|
/**
|
|
6892
|
+
* A readonly record whose values are {@link Json} values.
|
|
6893
|
+
*
|
|
4467
6894
|
* @category JSON
|
|
4468
6895
|
* @since 4.0.0
|
|
4469
6896
|
*/
|
|
@@ -4471,28 +6898,51 @@ export interface JsonObject {
|
|
|
4471
6898
|
readonly [x: string]: Json;
|
|
4472
6899
|
}
|
|
4473
6900
|
/**
|
|
6901
|
+
* Schema that accepts and validates any immutable JSON-compatible value.
|
|
6902
|
+
*
|
|
6903
|
+
* **Example** (Validating a JSON value)
|
|
6904
|
+
*
|
|
6905
|
+
* ```ts
|
|
6906
|
+
* import { Schema } from "effect"
|
|
6907
|
+
*
|
|
6908
|
+
* const result = Schema.decodeUnknownOption(Schema.Json)({ key: [1, true, null] })
|
|
6909
|
+
* console.log(result._tag) // "Some"
|
|
6910
|
+
* ```
|
|
6911
|
+
*
|
|
4474
6912
|
* @category JSON
|
|
4475
6913
|
* @since 4.0.0
|
|
4476
6914
|
*/
|
|
4477
|
-
export
|
|
6915
|
+
export declare const Json: Codec<Json>;
|
|
4478
6916
|
/**
|
|
4479
6917
|
* @category JSON
|
|
4480
6918
|
* @since 4.0.0
|
|
4481
6919
|
*/
|
|
4482
|
-
export
|
|
6920
|
+
export type MutableJson = null | number | boolean | string | MutableJsonArray | MutableJsonObject;
|
|
4483
6921
|
/**
|
|
6922
|
+
* A mutable array of {@link MutableJson} values.
|
|
6923
|
+
*
|
|
4484
6924
|
* @category JSON
|
|
4485
6925
|
* @since 4.0.0
|
|
4486
6926
|
*/
|
|
4487
6927
|
export interface MutableJsonArray extends Array<MutableJson> {
|
|
4488
6928
|
}
|
|
4489
6929
|
/**
|
|
6930
|
+
* A mutable record whose values are {@link MutableJson} values.
|
|
6931
|
+
*
|
|
4490
6932
|
* @category JSON
|
|
4491
6933
|
* @since 4.0.0
|
|
4492
6934
|
*/
|
|
4493
6935
|
export interface MutableJsonObject {
|
|
4494
6936
|
[x: string]: MutableJson;
|
|
4495
6937
|
}
|
|
6938
|
+
/**
|
|
6939
|
+
* Schema that accepts any mutable JSON-compatible value. See {@link Json} for
|
|
6940
|
+
* the immutable variant.
|
|
6941
|
+
*
|
|
6942
|
+
* @category JSON
|
|
6943
|
+
* @since 4.0.0
|
|
6944
|
+
*/
|
|
6945
|
+
export declare const MutableJson: Codec<MutableJson>;
|
|
4496
6946
|
/**
|
|
4497
6947
|
* Return all the typed annotations from the schema.
|
|
4498
6948
|
*
|
|
@@ -4501,6 +6951,13 @@ export interface MutableJsonObject {
|
|
|
4501
6951
|
*/
|
|
4502
6952
|
export declare function resolveInto<S extends Top>(schema: S): S["~annotate.in"] | undefined;
|
|
4503
6953
|
/**
|
|
6954
|
+
* The `Annotations` namespace groups all annotation interfaces used to attach
|
|
6955
|
+
* metadata to schemas. Annotations control documentation, validation messages,
|
|
6956
|
+
* JSON Schema generation, equivalence, arbitrary generation, and more.
|
|
6957
|
+
*
|
|
6958
|
+
* Use {@link resolveInto} to read the annotations attached to a schema at
|
|
6959
|
+
* runtime.
|
|
6960
|
+
*
|
|
4504
6961
|
* @since 4.0.0
|
|
4505
6962
|
*/
|
|
4506
6963
|
export declare namespace Annotations {
|
|
@@ -4549,6 +7006,9 @@ export declare namespace Annotations {
|
|
|
4549
7006
|
readonly [x: string]: unknown;
|
|
4550
7007
|
}
|
|
4551
7008
|
/**
|
|
7009
|
+
* Annotations shared by all schema nodes. These map to common JSON Schema /
|
|
7010
|
+
* OpenAPI fields: `title`, `description`, `format`, etc.
|
|
7011
|
+
*
|
|
4552
7012
|
* @since 4.0.0
|
|
4553
7013
|
*/
|
|
4554
7014
|
interface Augment extends Annotations {
|
|
@@ -4563,6 +7023,8 @@ export declare namespace Annotations {
|
|
|
4563
7023
|
readonly contentMediaType?: string | undefined;
|
|
4564
7024
|
}
|
|
4565
7025
|
/**
|
|
7026
|
+
* Extends {@link Augment} with type-parametric `default` and `examples` fields.
|
|
7027
|
+
*
|
|
4566
7028
|
* @since 4.0.0
|
|
4567
7029
|
*/
|
|
4568
7030
|
interface Documentation<T> extends Augment {
|
|
@@ -4570,6 +7032,10 @@ export declare namespace Annotations {
|
|
|
4570
7032
|
readonly examples?: ReadonlyArray<T> | undefined;
|
|
4571
7033
|
}
|
|
4572
7034
|
/**
|
|
7035
|
+
* Annotations for struct property schemas. Extends {@link Documentation}
|
|
7036
|
+
* with an optional `messageMissingKey` to override the error message when
|
|
7037
|
+
* the property key is absent during decoding.
|
|
7038
|
+
*
|
|
4573
7039
|
* @category Model
|
|
4574
7040
|
* @since 4.0.0
|
|
4575
7041
|
*/
|
|
@@ -4580,6 +7046,11 @@ export declare namespace Annotations {
|
|
|
4580
7046
|
readonly messageMissingKey?: string | undefined;
|
|
4581
7047
|
}
|
|
4582
7048
|
/**
|
|
7049
|
+
* Base annotations shared by all composite schema nodes. Extends
|
|
7050
|
+
* {@link Documentation} with error messages, branding, parse options, and
|
|
7051
|
+
* arbitrary generation hooks. {@link Declaration} and other annotation
|
|
7052
|
+
* interfaces build on top of this.
|
|
7053
|
+
*
|
|
4583
7054
|
* @category Model
|
|
4584
7055
|
* @since 4.0.0
|
|
4585
7056
|
*/
|
|
@@ -4622,6 +7093,12 @@ export declare namespace Annotations {
|
|
|
4622
7093
|
};
|
|
4623
7094
|
}
|
|
4624
7095
|
/**
|
|
7096
|
+
* Full annotation set for `Declaration` schema nodes — used when defining
|
|
7097
|
+
* custom, opaque schema types via `Schema.declare`. Extends {@link Bottom}
|
|
7098
|
+
* with optional codec, arbitrary, equivalence, and formatter hooks so that
|
|
7099
|
+
* derived capabilities (JSON encoding, property testing, etc.) can be
|
|
7100
|
+
* provided for the custom type.
|
|
7101
|
+
*
|
|
4625
7102
|
* @category Model
|
|
4626
7103
|
* @since 4.0.0
|
|
4627
7104
|
*/
|
|
@@ -4643,10 +7120,9 @@ export declare namespace Annotations {
|
|
|
4643
7120
|
} | undefined;
|
|
4644
7121
|
}
|
|
4645
7122
|
/**
|
|
4646
|
-
*
|
|
4647
|
-
*
|
|
4648
|
-
*
|
|
4649
|
-
* invariant
|
|
7123
|
+
* Annotations for filter schema nodes (created via `Schema.filter`). Extends
|
|
7124
|
+
* {@link Augment} with an optional error message, identifier, and metadata.
|
|
7125
|
+
* Filters are intentionally non-parametric to keep them covariant.
|
|
4650
7126
|
*
|
|
4651
7127
|
* @category Model
|
|
4652
7128
|
* @since 4.0.0
|
|
@@ -4983,5 +7459,4 @@ export declare namespace Annotations {
|
|
|
4983
7459
|
*/
|
|
4984
7460
|
type Meta = MetaDefinitions[keyof MetaDefinitions];
|
|
4985
7461
|
}
|
|
4986
|
-
export {};
|
|
4987
7462
|
//# sourceMappingURL=Schema.d.ts.map
|