effect 3.13.1 → 3.13.3
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/cjs/Array.js.map +1 -1
- package/dist/cjs/Channel.js.map +1 -1
- package/dist/cjs/Chunk.js.map +1 -1
- package/dist/cjs/Context.js.map +1 -1
- package/dist/cjs/DateTime.js.map +1 -1
- package/dist/cjs/Duration.js +1 -3
- package/dist/cjs/Duration.js.map +1 -1
- package/dist/cjs/Effect.js.map +1 -1
- package/dist/cjs/Either.js.map +1 -1
- package/dist/cjs/Exit.js.map +1 -1
- package/dist/cjs/FiberHandle.js +5 -3
- package/dist/cjs/FiberHandle.js.map +1 -1
- package/dist/cjs/FiberMap.js +5 -3
- package/dist/cjs/FiberMap.js.map +1 -1
- package/dist/cjs/FiberSet.js +6 -3
- package/dist/cjs/FiberSet.js.map +1 -1
- package/dist/cjs/Function.js.map +1 -1
- package/dist/cjs/HashSet.js.map +1 -1
- package/dist/cjs/Iterable.js.map +1 -1
- package/dist/cjs/JSONSchema.js +7 -7
- package/dist/cjs/JSONSchema.js.map +1 -1
- package/dist/cjs/Layer.js.map +1 -1
- package/dist/cjs/List.js.map +1 -1
- package/dist/cjs/Logger.js.map +1 -1
- package/dist/cjs/Metric.js.map +1 -1
- package/dist/cjs/MetricKey.js.map +1 -1
- package/dist/cjs/MetricPolling.js.map +1 -1
- package/dist/cjs/Micro.js.map +1 -1
- package/dist/cjs/MutableHashMap.js.map +1 -1
- package/dist/cjs/Option.js +3 -15
- package/dist/cjs/Option.js.map +1 -1
- package/dist/cjs/ParseResult.js +1 -1
- package/dist/cjs/ParseResult.js.map +1 -1
- package/dist/cjs/Predicate.js.map +1 -1
- package/dist/cjs/Record.js.map +1 -1
- package/dist/cjs/Request.js.map +1 -1
- package/dist/cjs/RequestResolver.js.map +1 -1
- package/dist/cjs/STM.js.map +1 -1
- package/dist/cjs/Schedule.js.map +1 -1
- package/dist/cjs/Schema.js +593 -522
- package/dist/cjs/Schema.js.map +1 -1
- package/dist/cjs/SchemaAST.js +1 -1
- package/dist/cjs/SchemaAST.js.map +1 -1
- package/dist/cjs/Sink.js.map +1 -1
- package/dist/cjs/SortedMap.js.map +1 -1
- package/dist/cjs/Stream.js.map +1 -1
- package/dist/cjs/Struct.js.map +1 -1
- package/dist/cjs/Subscribable.js.map +1 -1
- package/dist/cjs/SubscriptionRef.js.map +1 -1
- package/dist/cjs/SynchronizedRef.js.map +1 -1
- package/dist/cjs/TArray.js.map +1 -1
- package/dist/cjs/TMap.js.map +1 -1
- package/dist/cjs/TRef.js.map +1 -1
- package/dist/cjs/Take.js.map +1 -1
- package/dist/cjs/TestServices.js.map +1 -1
- package/dist/cjs/Unify.js.map +1 -1
- package/dist/cjs/internal/fiberRuntime.js +4 -5
- package/dist/cjs/internal/fiberRuntime.js.map +1 -1
- package/dist/cjs/internal/stm/core.js +5 -5
- package/dist/cjs/internal/stm/core.js.map +1 -1
- package/dist/cjs/internal/stm/entry.js.map +1 -0
- package/dist/cjs/internal/stm/journal.js.map +1 -0
- package/dist/cjs/internal/stm/stm.js +2 -2
- package/dist/cjs/internal/stm/stm.js.map +1 -1
- package/dist/cjs/internal/stm/{stm/stmState.js → stmState.js} +7 -7
- package/dist/cjs/internal/stm/stmState.js.map +1 -0
- package/dist/cjs/internal/stm/{stm/tExit.js → tExit.js} +5 -5
- package/dist/cjs/internal/stm/tExit.js.map +1 -0
- package/dist/cjs/internal/stm/tMap.js.map +1 -1
- package/dist/cjs/internal/stm/tRef.js +2 -2
- package/dist/cjs/internal/stm/tRef.js.map +1 -1
- package/dist/cjs/internal/stm/{stm/tryCommit.js → tryCommit.js} +1 -1
- package/dist/cjs/internal/stm/tryCommit.js.map +1 -0
- package/dist/cjs/internal/stm/txnId.js.map +1 -0
- package/dist/cjs/internal/stm/versioned.js.map +1 -0
- package/dist/cjs/internal/version.js +1 -1
- package/dist/dts/Array.d.ts +6 -6
- package/dist/dts/Array.d.ts.map +1 -1
- package/dist/dts/Cause.d.ts.map +1 -1
- package/dist/dts/Channel.d.ts.map +1 -1
- package/dist/dts/ChildExecutorDecision.d.ts.map +1 -1
- package/dist/dts/Chunk.d.ts.map +1 -1
- package/dist/dts/Config.d.ts.map +1 -1
- package/dist/dts/ConfigProvider.d.ts.map +1 -1
- package/dist/dts/Console.d.ts.map +1 -1
- package/dist/dts/Context.d.ts +1 -1
- package/dist/dts/Context.d.ts.map +1 -1
- package/dist/dts/DateTime.d.ts.map +1 -1
- package/dist/dts/Duration.d.ts +1 -3
- package/dist/dts/Duration.d.ts.map +1 -1
- package/dist/dts/Effect.d.ts.map +1 -1
- package/dist/dts/Either.d.ts.map +1 -1
- package/dist/dts/ExecutionStrategy.d.ts.map +1 -1
- package/dist/dts/Exit.d.ts.map +1 -1
- package/dist/dts/Fiber.d.ts.map +1 -1
- package/dist/dts/FiberHandle.d.ts.map +1 -1
- package/dist/dts/FiberMap.d.ts.map +1 -1
- package/dist/dts/FiberRefsPatch.d.ts.map +1 -1
- package/dist/dts/FiberSet.d.ts.map +1 -1
- package/dist/dts/Function.d.ts.map +1 -1
- package/dist/dts/GroupBy.d.ts.map +1 -1
- package/dist/dts/HashSet.d.ts.map +1 -1
- package/dist/dts/Iterable.d.ts.map +1 -1
- package/dist/dts/Layer.d.ts.map +1 -1
- package/dist/dts/List.d.ts.map +1 -1
- package/dist/dts/Logger.d.ts.map +1 -1
- package/dist/dts/Mailbox.d.ts.map +1 -1
- package/dist/dts/MergeDecision.d.ts.map +1 -1
- package/dist/dts/MergeStrategy.d.ts.map +1 -1
- package/dist/dts/Metric.d.ts.map +1 -1
- package/dist/dts/MetricKey.d.ts.map +1 -1
- package/dist/dts/MetricPolling.d.ts.map +1 -1
- package/dist/dts/Micro.d.ts.map +1 -1
- package/dist/dts/MutableHashMap.d.ts.map +1 -1
- package/dist/dts/Option.d.ts +3 -42
- package/dist/dts/Option.d.ts.map +1 -1
- package/dist/dts/ParseResult.d.ts.map +1 -1
- package/dist/dts/Predicate.d.ts.map +1 -1
- package/dist/dts/RcMap.d.ts.map +1 -1
- package/dist/dts/Record.d.ts.map +1 -1
- package/dist/dts/RedBlackTree.d.ts.map +1 -1
- package/dist/dts/Request.d.ts.map +1 -1
- package/dist/dts/RequestResolver.d.ts.map +1 -1
- package/dist/dts/Runtime.d.ts.map +1 -1
- package/dist/dts/STM.d.ts.map +1 -1
- package/dist/dts/Schedule.d.ts.map +1 -1
- package/dist/dts/Schema.d.ts +394 -271
- package/dist/dts/Schema.d.ts.map +1 -1
- package/dist/dts/Sink.d.ts.map +1 -1
- package/dist/dts/SortedMap.d.ts.map +1 -1
- package/dist/dts/Stream.d.ts.map +1 -1
- package/dist/dts/StreamHaltStrategy.d.ts.map +1 -1
- package/dist/dts/Struct.d.ts.map +1 -1
- package/dist/dts/Subscribable.d.ts.map +1 -1
- package/dist/dts/SubscriptionRef.d.ts.map +1 -1
- package/dist/dts/SynchronizedRef.d.ts.map +1 -1
- package/dist/dts/TArray.d.ts.map +1 -1
- package/dist/dts/TMap.d.ts.map +1 -1
- package/dist/dts/TSubscriptionRef.d.ts.map +1 -1
- package/dist/dts/Take.d.ts.map +1 -1
- package/dist/dts/TestServices.d.ts.map +1 -1
- package/dist/dts/Unify.d.ts.map +1 -1
- package/dist/dts/UpstreamPullRequest.d.ts.map +1 -1
- package/dist/dts/UpstreamPullStrategy.d.ts.map +1 -1
- package/dist/dts/internal/stm/entry.d.ts.map +1 -0
- package/dist/dts/internal/stm/journal.d.ts.map +1 -0
- package/dist/dts/internal/stm/stmState.d.ts.map +1 -0
- package/dist/dts/internal/stm/tExit.d.ts.map +1 -0
- package/dist/dts/internal/stm/tryCommit.d.ts.map +1 -0
- package/dist/dts/internal/stm/txnId.d.ts.map +1 -0
- package/dist/dts/internal/stm/versioned.d.ts.map +1 -0
- package/dist/esm/Array.js.map +1 -1
- package/dist/esm/Channel.js.map +1 -1
- package/dist/esm/Chunk.js.map +1 -1
- package/dist/esm/Context.js.map +1 -1
- package/dist/esm/DateTime.js.map +1 -1
- package/dist/esm/Duration.js +1 -3
- package/dist/esm/Duration.js.map +1 -1
- package/dist/esm/Effect.js.map +1 -1
- package/dist/esm/Either.js.map +1 -1
- package/dist/esm/Exit.js.map +1 -1
- package/dist/esm/FiberHandle.js +5 -3
- package/dist/esm/FiberHandle.js.map +1 -1
- package/dist/esm/FiberMap.js +5 -3
- package/dist/esm/FiberMap.js.map +1 -1
- package/dist/esm/FiberSet.js +6 -3
- package/dist/esm/FiberSet.js.map +1 -1
- package/dist/esm/Function.js.map +1 -1
- package/dist/esm/HashSet.js.map +1 -1
- package/dist/esm/Iterable.js.map +1 -1
- package/dist/esm/JSONSchema.js +7 -7
- package/dist/esm/JSONSchema.js.map +1 -1
- package/dist/esm/Layer.js.map +1 -1
- package/dist/esm/List.js.map +1 -1
- package/dist/esm/Logger.js.map +1 -1
- package/dist/esm/Metric.js.map +1 -1
- package/dist/esm/MetricKey.js.map +1 -1
- package/dist/esm/MetricPolling.js.map +1 -1
- package/dist/esm/Micro.js.map +1 -1
- package/dist/esm/MutableHashMap.js.map +1 -1
- package/dist/esm/Option.js +3 -15
- package/dist/esm/Option.js.map +1 -1
- package/dist/esm/ParseResult.js +1 -1
- package/dist/esm/ParseResult.js.map +1 -1
- package/dist/esm/Predicate.js.map +1 -1
- package/dist/esm/Record.js.map +1 -1
- package/dist/esm/Request.js.map +1 -1
- package/dist/esm/RequestResolver.js.map +1 -1
- package/dist/esm/STM.js.map +1 -1
- package/dist/esm/Schedule.js.map +1 -1
- package/dist/esm/Schema.js +538 -490
- package/dist/esm/Schema.js.map +1 -1
- package/dist/esm/SchemaAST.js +1 -1
- package/dist/esm/SchemaAST.js.map +1 -1
- package/dist/esm/Sink.js.map +1 -1
- package/dist/esm/SortedMap.js.map +1 -1
- package/dist/esm/Stream.js.map +1 -1
- package/dist/esm/Struct.js.map +1 -1
- package/dist/esm/Subscribable.js.map +1 -1
- package/dist/esm/SubscriptionRef.js.map +1 -1
- package/dist/esm/SynchronizedRef.js.map +1 -1
- package/dist/esm/TArray.js.map +1 -1
- package/dist/esm/TMap.js.map +1 -1
- package/dist/esm/TRef.js.map +1 -1
- package/dist/esm/Take.js.map +1 -1
- package/dist/esm/TestServices.js.map +1 -1
- package/dist/esm/Unify.js.map +1 -1
- package/dist/esm/internal/fiberRuntime.js +4 -5
- package/dist/esm/internal/fiberRuntime.js.map +1 -1
- package/dist/esm/internal/stm/core.js +5 -5
- package/dist/esm/internal/stm/core.js.map +1 -1
- package/dist/esm/internal/stm/entry.js.map +1 -0
- package/dist/esm/internal/stm/journal.js.map +1 -0
- package/dist/esm/internal/stm/stm.js +2 -2
- package/dist/esm/internal/stm/stm.js.map +1 -1
- package/dist/esm/internal/stm/{stm/stmState.js → stmState.js} +7 -7
- package/dist/esm/internal/stm/stmState.js.map +1 -0
- package/dist/esm/internal/stm/{stm/tExit.js → tExit.js} +5 -5
- package/dist/esm/internal/stm/tExit.js.map +1 -0
- package/dist/esm/internal/stm/tMap.js.map +1 -1
- package/dist/esm/internal/stm/tRef.js +2 -2
- package/dist/esm/internal/stm/tRef.js.map +1 -1
- package/dist/esm/internal/stm/{stm/tryCommit.js → tryCommit.js} +1 -1
- package/dist/esm/internal/stm/tryCommit.js.map +1 -0
- package/dist/esm/internal/stm/txnId.js.map +1 -0
- package/dist/esm/internal/stm/versioned.js.map +1 -0
- package/dist/esm/internal/version.js +1 -1
- package/package.json +1 -1
- package/src/Array.ts +26 -86
- package/src/Cause.ts +20 -20
- package/src/Channel.ts +14 -44
- package/src/ChildExecutorDecision.ts +11 -11
- package/src/Chunk.ts +23 -36
- package/src/Config.ts +27 -27
- package/src/ConfigProvider.ts +3 -3
- package/src/Console.ts +9 -9
- package/src/Context.ts +3 -10
- package/src/DateTime.ts +96 -104
- package/src/Duration.ts +1 -3
- package/src/Effect.ts +64 -229
- package/src/Either.ts +2 -8
- package/src/ExecutionStrategy.ts +11 -11
- package/src/Exit.ts +27 -29
- package/src/Fiber.ts +9 -9
- package/src/FiberHandle.ts +11 -7
- package/src/FiberMap.ts +11 -7
- package/src/FiberRefsPatch.ts +3 -3
- package/src/FiberSet.ts +9 -7
- package/src/Function.ts +2 -8
- package/src/GroupBy.ts +5 -5
- package/src/HashSet.ts +2 -7
- package/src/Iterable.ts +2 -7
- package/src/JSONSchema.ts +7 -7
- package/src/Layer.ts +22 -77
- package/src/List.ts +32 -43
- package/src/Logger.ts +21 -55
- package/src/Mailbox.ts +9 -9
- package/src/MergeDecision.ts +9 -9
- package/src/MergeStrategy.ts +9 -9
- package/src/Metric.ts +13 -47
- package/src/MetricKey.ts +4 -16
- package/src/MetricPolling.ts +1 -3
- package/src/Micro.ts +43 -104
- package/src/MutableHashMap.ts +1 -4
- package/src/Option.ts +8 -50
- package/src/ParseResult.ts +5 -17
- package/src/Predicate.ts +2 -6
- package/src/RcMap.ts +10 -10
- package/src/Record.ts +24 -90
- package/src/RedBlackTree.ts +14 -14
- package/src/Request.ts +2 -7
- package/src/RequestResolver.ts +6 -22
- package/src/Runtime.ts +4 -4
- package/src/STM.ts +17 -67
- package/src/Schedule.ts +37 -126
- package/src/Schema.ts +1429 -1256
- package/src/SchemaAST.ts +1 -1
- package/src/Sink.ts +20 -68
- package/src/SortedMap.ts +1 -3
- package/src/Stream.ts +86 -311
- package/src/StreamHaltStrategy.ts +13 -13
- package/src/Struct.ts +2 -7
- package/src/Subscribable.ts +1 -3
- package/src/SubscriptionRef.ts +1 -3
- package/src/SynchronizedRef.ts +17 -19
- package/src/TArray.ts +7 -10
- package/src/TMap.ts +4 -13
- package/src/TRef.ts +3 -3
- package/src/TSubscriptionRef.ts +3 -3
- package/src/Take.ts +24 -29
- package/src/TestServices.ts +1 -3
- package/src/Unify.ts +1 -3
- package/src/UpstreamPullRequest.ts +9 -9
- package/src/UpstreamPullStrategy.ts +9 -9
- package/src/internal/fiberRuntime.ts +5 -4
- package/src/internal/stm/core.ts +5 -5
- package/src/internal/stm/{stm/entry.ts → entry.ts} +1 -1
- package/src/internal/stm/{stm/journal.ts → journal.ts} +1 -1
- package/src/internal/stm/stm.ts +2 -2
- package/src/internal/stm/{stm/stmState.ts → stmState.ts} +7 -7
- package/src/internal/stm/{stm/tExit.ts → tExit.ts} +7 -7
- package/src/internal/stm/tMap.ts +1 -1
- package/src/internal/stm/tRef.ts +4 -4
- package/src/internal/stm/{stm/tryCommit.ts → tryCommit.ts} +2 -2
- package/src/internal/version.ts +1 -1
- package/dist/cjs/internal/stm/stm/entry.js.map +0 -1
- package/dist/cjs/internal/stm/stm/journal.js.map +0 -1
- package/dist/cjs/internal/stm/stm/opCodes/stm.js +0 -31
- package/dist/cjs/internal/stm/stm/opCodes/stm.js.map +0 -1
- package/dist/cjs/internal/stm/stm/opCodes/stmState.js +0 -13
- package/dist/cjs/internal/stm/stm/opCodes/stmState.js.map +0 -1
- package/dist/cjs/internal/stm/stm/opCodes/strategy.js +0 -13
- package/dist/cjs/internal/stm/stm/opCodes/strategy.js.map +0 -1
- package/dist/cjs/internal/stm/stm/opCodes/tExit.js +0 -17
- package/dist/cjs/internal/stm/stm/opCodes/tExit.js.map +0 -1
- package/dist/cjs/internal/stm/stm/opCodes/tryCommit.js +0 -11
- package/dist/cjs/internal/stm/stm/opCodes/tryCommit.js.map +0 -1
- package/dist/cjs/internal/stm/stm/stmState.js.map +0 -1
- package/dist/cjs/internal/stm/stm/tExit.js.map +0 -1
- package/dist/cjs/internal/stm/stm/tryCommit.js.map +0 -1
- package/dist/cjs/internal/stm/stm/txnId.js.map +0 -1
- package/dist/cjs/internal/stm/stm/versioned.js.map +0 -1
- package/dist/dts/internal/stm/stm/entry.d.ts.map +0 -1
- package/dist/dts/internal/stm/stm/journal.d.ts.map +0 -1
- package/dist/dts/internal/stm/stm/opCodes/stm.d.ts +0 -2
- package/dist/dts/internal/stm/stm/opCodes/stm.d.ts.map +0 -1
- package/dist/dts/internal/stm/stm/opCodes/stmState.d.ts.map +0 -1
- package/dist/dts/internal/stm/stm/opCodes/strategy.d.ts +0 -2
- package/dist/dts/internal/stm/stm/opCodes/strategy.d.ts.map +0 -1
- package/dist/dts/internal/stm/stm/opCodes/tExit.d.ts +0 -2
- package/dist/dts/internal/stm/stm/opCodes/tExit.d.ts.map +0 -1
- package/dist/dts/internal/stm/stm/opCodes/tryCommit.d.ts.map +0 -1
- package/dist/dts/internal/stm/stm/stmState.d.ts +0 -2
- package/dist/dts/internal/stm/stm/stmState.d.ts.map +0 -1
- package/dist/dts/internal/stm/stm/tExit.d.ts.map +0 -1
- package/dist/dts/internal/stm/stm/tryCommit.d.ts +0 -2
- package/dist/dts/internal/stm/stm/tryCommit.d.ts.map +0 -1
- package/dist/dts/internal/stm/stm/txnId.d.ts.map +0 -1
- package/dist/dts/internal/stm/stm/versioned.d.ts.map +0 -1
- package/dist/esm/internal/stm/stm/entry.js.map +0 -1
- package/dist/esm/internal/stm/stm/journal.js.map +0 -1
- package/dist/esm/internal/stm/stm/opCodes/stm.js +0 -25
- package/dist/esm/internal/stm/stm/opCodes/stm.js.map +0 -1
- package/dist/esm/internal/stm/stm/opCodes/stmState.js +0 -7
- package/dist/esm/internal/stm/stm/opCodes/stmState.js.map +0 -1
- package/dist/esm/internal/stm/stm/opCodes/strategy.js +0 -7
- package/dist/esm/internal/stm/stm/opCodes/strategy.js.map +0 -1
- package/dist/esm/internal/stm/stm/opCodes/tExit.js +0 -11
- package/dist/esm/internal/stm/stm/opCodes/tExit.js.map +0 -1
- package/dist/esm/internal/stm/stm/opCodes/tryCommit.js +0 -5
- package/dist/esm/internal/stm/stm/opCodes/tryCommit.js.map +0 -1
- package/dist/esm/internal/stm/stm/stmState.js.map +0 -1
- package/dist/esm/internal/stm/stm/tExit.js.map +0 -1
- package/dist/esm/internal/stm/stm/tryCommit.js.map +0 -1
- package/dist/esm/internal/stm/stm/txnId.js.map +0 -1
- package/dist/esm/internal/stm/stm/versioned.js.map +0 -1
- package/src/internal/stm/stm/opCodes/stm.ts +0 -71
- package/src/internal/stm/stm/opCodes/stmState.ts +0 -17
- package/src/internal/stm/stm/opCodes/strategy.ts +0 -17
- package/src/internal/stm/stm/opCodes/tExit.ts +0 -29
- package/src/internal/stm/stm/opCodes/tryCommit.ts +0 -11
- /package/dist/cjs/internal/stm/{stm/entry.js → entry.js} +0 -0
- /package/dist/cjs/internal/stm/{stm/journal.js → journal.js} +0 -0
- /package/dist/cjs/internal/stm/{stm/txnId.js → txnId.js} +0 -0
- /package/dist/cjs/internal/stm/{stm/versioned.js → versioned.js} +0 -0
- /package/dist/dts/internal/stm/{stm/entry.d.ts → entry.d.ts} +0 -0
- /package/dist/dts/internal/stm/{stm/journal.d.ts → journal.d.ts} +0 -0
- /package/dist/dts/internal/stm/{stm/opCodes/stmState.d.ts → stmState.d.ts} +0 -0
- /package/dist/dts/internal/stm/{stm/tExit.d.ts → tExit.d.ts} +0 -0
- /package/dist/dts/internal/stm/{stm/opCodes/tryCommit.d.ts → tryCommit.d.ts} +0 -0
- /package/dist/dts/internal/stm/{stm/txnId.d.ts → txnId.d.ts} +0 -0
- /package/dist/dts/internal/stm/{stm/versioned.d.ts → versioned.d.ts} +0 -0
- /package/dist/esm/internal/stm/{stm/entry.js → entry.js} +0 -0
- /package/dist/esm/internal/stm/{stm/journal.js → journal.js} +0 -0
- /package/dist/esm/internal/stm/{stm/txnId.js → txnId.js} +0 -0
- /package/dist/esm/internal/stm/{stm/versioned.js → versioned.js} +0 -0
- /package/src/internal/stm/{stm/txnId.ts → txnId.ts} +0 -0
- /package/src/internal/stm/{stm/versioned.ts → versioned.ts} +0 -0
package/src/Schema.ts
CHANGED
|
@@ -42,7 +42,6 @@ import type { Pipeable } from "./Pipeable.js"
|
|
|
42
42
|
import { pipeArguments } from "./Pipeable.js"
|
|
43
43
|
import * as Predicate from "./Predicate.js"
|
|
44
44
|
import type * as pretty_ from "./Pretty.js"
|
|
45
|
-
import * as record_ from "./Record.js"
|
|
46
45
|
import * as redacted_ from "./Redacted.js"
|
|
47
46
|
import * as Request from "./Request.js"
|
|
48
47
|
import * as scheduler_ from "./Scheduler.js"
|
|
@@ -93,6 +92,22 @@ export interface Schema<in out A, in out I = A, out R = never> extends Schema.Va
|
|
|
93
92
|
annotations(annotations: Annotations.GenericSchema<A>): Schema<A, I, R>
|
|
94
93
|
}
|
|
95
94
|
|
|
95
|
+
/**
|
|
96
|
+
* @category annotations
|
|
97
|
+
* @since 3.10.0
|
|
98
|
+
*/
|
|
99
|
+
export interface Annotable<Self extends Schema<A, I, R>, A, I = A, R = never> extends Schema<A, I, R> {
|
|
100
|
+
annotations(annotations: Annotations.GenericSchema<A>): Self
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @category annotations
|
|
105
|
+
* @since 3.10.0
|
|
106
|
+
*/
|
|
107
|
+
export interface AnnotableClass<Self extends Schema<A, I, R>, A, I = A, R = never> extends Annotable<Self, A, I, R> {
|
|
108
|
+
new(_: never): Schema.Variance<A, I, R>
|
|
109
|
+
}
|
|
110
|
+
|
|
96
111
|
/**
|
|
97
112
|
* @category model
|
|
98
113
|
* @since 3.10.0
|
|
@@ -103,23 +118,25 @@ export interface SchemaClass<A, I = A, R = never> extends AnnotableClass<SchemaC
|
|
|
103
118
|
* @category constructors
|
|
104
119
|
* @since 3.10.0
|
|
105
120
|
*/
|
|
106
|
-
export
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
121
|
+
export function make<A, I = A, R = never>(ast: AST.AST): SchemaClass<A, I, R> {
|
|
122
|
+
return class SchemaClass {
|
|
123
|
+
[TypeId] = variance
|
|
124
|
+
static ast = ast
|
|
125
|
+
static annotations(annotations: Annotations.GenericSchema<A>) {
|
|
126
|
+
return make<A, I, R>(mergeSchemaAnnotations(this.ast, annotations))
|
|
127
|
+
}
|
|
128
|
+
static pipe() {
|
|
129
|
+
return pipeArguments(this, arguments)
|
|
130
|
+
}
|
|
131
|
+
static toString() {
|
|
132
|
+
return String(ast)
|
|
133
|
+
}
|
|
134
|
+
static Type: A
|
|
135
|
+
static Encoded: I
|
|
136
|
+
static Context: R
|
|
137
|
+
static [TypeId] = variance
|
|
117
138
|
}
|
|
118
|
-
|
|
119
|
-
static Encoded: I
|
|
120
|
-
static Context: R
|
|
121
|
-
static [TypeId] = variance
|
|
122
|
-
})
|
|
139
|
+
}
|
|
123
140
|
|
|
124
141
|
const variance = {
|
|
125
142
|
/* c8 ignore next */
|
|
@@ -277,28 +294,14 @@ export declare namespace Annotable {
|
|
|
277
294
|
| Annotable<any, never, never, unknown>
|
|
278
295
|
}
|
|
279
296
|
|
|
280
|
-
/**
|
|
281
|
-
* @category annotations
|
|
282
|
-
* @since 3.10.0
|
|
283
|
-
*/
|
|
284
|
-
export interface Annotable<Self extends Schema<A, I, R>, A, I = A, R = never> extends Schema<A, I, R> {
|
|
285
|
-
annotations(annotations: Annotations.GenericSchema<A>): Self
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* @category annotations
|
|
290
|
-
* @since 3.10.0
|
|
291
|
-
*/
|
|
292
|
-
export interface AnnotableClass<Self extends Schema<A, I, R>, A, I = A, R = never> extends Annotable<Self, A, I, R> {
|
|
293
|
-
new(_: never): Schema.Variance<A, I, R>
|
|
294
|
-
}
|
|
295
|
-
|
|
296
297
|
/**
|
|
297
298
|
* @since 3.10.0
|
|
298
299
|
*/
|
|
299
|
-
export
|
|
300
|
+
export function asSchema<S extends Schema.All>(
|
|
300
301
|
schema: S
|
|
301
|
-
): Schema<Schema.Type<S>, Schema.Encoded<S>, Schema.Context<S>>
|
|
302
|
+
): Schema<Schema.Type<S>, Schema.Encoded<S>, Schema.Context<S>> {
|
|
303
|
+
return schema as any
|
|
304
|
+
}
|
|
302
305
|
|
|
303
306
|
/**
|
|
304
307
|
* @category formatting
|
|
@@ -668,22 +671,25 @@ export interface Literal<Literals extends array_.NonEmptyReadonlyArray<AST.Liter
|
|
|
668
671
|
readonly literals: Readonly<Literals>
|
|
669
672
|
}
|
|
670
673
|
|
|
671
|
-
|
|
674
|
+
function getDefaultLiteralAST<Literals extends array_.NonEmptyReadonlyArray<AST.LiteralValue>>(
|
|
672
675
|
literals: Literals
|
|
673
|
-
)
|
|
674
|
-
AST.isMembers(literals)
|
|
676
|
+
): AST.AST {
|
|
677
|
+
return AST.isMembers(literals)
|
|
675
678
|
? AST.Union.make(AST.mapMembers(literals, (literal) => new AST.Literal(literal)))
|
|
676
679
|
: new AST.Literal(literals[0])
|
|
680
|
+
}
|
|
677
681
|
|
|
678
|
-
|
|
682
|
+
function makeLiteralClass<Literals extends array_.NonEmptyReadonlyArray<AST.LiteralValue>>(
|
|
679
683
|
literals: Literals,
|
|
680
684
|
ast: AST.AST = getDefaultLiteralAST(literals)
|
|
681
|
-
): Literal<Literals>
|
|
682
|
-
|
|
683
|
-
|
|
685
|
+
): Literal<Literals> {
|
|
686
|
+
return class LiteralClass extends make<Literals[number]>(ast) {
|
|
687
|
+
static override annotations(annotations: Annotations.Schema<Literals[number]>): Literal<Literals> {
|
|
688
|
+
return makeLiteralClass(this.literals, mergeSchemaAnnotations(this.ast, annotations))
|
|
689
|
+
}
|
|
690
|
+
static literals = [...literals] as Literals
|
|
684
691
|
}
|
|
685
|
-
|
|
686
|
-
})
|
|
692
|
+
}
|
|
687
693
|
|
|
688
694
|
/**
|
|
689
695
|
* @category constructors
|
|
@@ -695,10 +701,10 @@ export function Literal<Literals extends array_.NonEmptyReadonlyArray<AST.Litera
|
|
|
695
701
|
export function Literal(): Never
|
|
696
702
|
export function Literal<Literals extends ReadonlyArray<AST.LiteralValue>>(
|
|
697
703
|
...literals: Literals
|
|
698
|
-
):
|
|
704
|
+
): SchemaClass<Literals[number]>
|
|
699
705
|
export function Literal<Literals extends ReadonlyArray<AST.LiteralValue>>(
|
|
700
706
|
...literals: Literals
|
|
701
|
-
):
|
|
707
|
+
): SchemaClass<Literals[number]> | Never {
|
|
702
708
|
return array_.isNonEmptyReadonlyArray(literals) ? makeLiteralClass(literals) : Never
|
|
703
709
|
}
|
|
704
710
|
|
|
@@ -938,11 +944,11 @@ export const TemplateLiteralParser = <Params extends array_.NonEmptyReadonlyArra
|
|
|
938
944
|
}
|
|
939
945
|
return class TemplateLiteralParserClass extends transformOrFail(from, to, {
|
|
940
946
|
strict: false,
|
|
941
|
-
decode: (
|
|
942
|
-
const match = re.exec(
|
|
947
|
+
decode: (i, _, ast) => {
|
|
948
|
+
const match = re.exec(i)
|
|
943
949
|
return match
|
|
944
950
|
? ParseResult.succeed(match.slice(1, params.length + 1))
|
|
945
|
-
: ParseResult.fail(new ParseResult.Type(ast,
|
|
951
|
+
: ParseResult.fail(new ParseResult.Type(ast, i, `${re.source}: no match for ${JSON.stringify(i)}`))
|
|
946
952
|
},
|
|
947
953
|
encode: (tuple) => ParseResult.succeed(tuple.join(""))
|
|
948
954
|
}) {
|
|
@@ -986,7 +992,8 @@ const declareConstructor = <
|
|
|
986
992
|
},
|
|
987
993
|
annotations?: Annotations.Schema<A, TypeParameters>
|
|
988
994
|
): SchemaClass<A, I, Schema.Context<TypeParameters[number]>> =>
|
|
989
|
-
|
|
995
|
+
makeDeclareClass(
|
|
996
|
+
typeParameters,
|
|
990
997
|
new AST.Declaration(
|
|
991
998
|
typeParameters.map((tp) => tp.ast),
|
|
992
999
|
(...typeParameters) => options.decode(...typeParameters.map(make) as any),
|
|
@@ -1002,7 +1009,46 @@ const declarePrimitive = <A>(
|
|
|
1002
1009
|
const decodeUnknown = () => (input: unknown, _: ParseOptions, ast: AST.Declaration) =>
|
|
1003
1010
|
is(input) ? ParseResult.succeed(input) : ParseResult.fail(new ParseResult.Type(ast, input))
|
|
1004
1011
|
const encodeUnknown = decodeUnknown
|
|
1005
|
-
return
|
|
1012
|
+
return makeDeclareClass([], new AST.Declaration([], decodeUnknown, encodeUnknown, toASTAnnotations(annotations)))
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
/**
|
|
1016
|
+
* @category api interface
|
|
1017
|
+
* @since 3.13.3
|
|
1018
|
+
*/
|
|
1019
|
+
export interface declare<
|
|
1020
|
+
A,
|
|
1021
|
+
I = A,
|
|
1022
|
+
P extends ReadonlyArray<Schema.All> = readonly [],
|
|
1023
|
+
R = Schema.Context<P[number]>
|
|
1024
|
+
> extends AnnotableClass<declare<A, I, P, R>, A, I, R> {
|
|
1025
|
+
readonly typeParameters: Readonly<P>
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
/**
|
|
1029
|
+
* @category api interface
|
|
1030
|
+
* @since 3.13.3
|
|
1031
|
+
*/
|
|
1032
|
+
export interface AnnotableDeclare<
|
|
1033
|
+
Self extends declare<A, I, P, R>,
|
|
1034
|
+
A,
|
|
1035
|
+
I = A,
|
|
1036
|
+
P extends ReadonlyArray<Schema.All> = readonly [],
|
|
1037
|
+
R = Schema.Context<P[number]>
|
|
1038
|
+
> extends declare<A, I, P, R> {
|
|
1039
|
+
annotations(annotations: Annotations.Schema<A>): Self
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
function makeDeclareClass<P extends ReadonlyArray<Schema.All>, A, I, R>(
|
|
1043
|
+
typeParameters: P,
|
|
1044
|
+
ast: AST.AST
|
|
1045
|
+
): declare<A, I, P, R> {
|
|
1046
|
+
return class DeclareClass extends make<A, I, R>(ast) {
|
|
1047
|
+
static override annotations(annotations: Annotations.Schema<A>): declare<A, I, P, R> {
|
|
1048
|
+
return makeDeclareClass(this.typeParameters, mergeSchemaAnnotations(this.ast, annotations))
|
|
1049
|
+
}
|
|
1050
|
+
static typeParameters = [...typeParameters] as any as P
|
|
1051
|
+
}
|
|
1006
1052
|
}
|
|
1007
1053
|
|
|
1008
1054
|
/**
|
|
@@ -1020,7 +1066,7 @@ export const declare: {
|
|
|
1020
1066
|
* @category constructors
|
|
1021
1067
|
* @since 3.10.0
|
|
1022
1068
|
*/
|
|
1023
|
-
<A>(is: (input: unknown) => input is A, annotations?: Annotations.Schema<A>):
|
|
1069
|
+
<A>(is: (input: unknown) => input is A, annotations?: Annotations.Schema<A>): declare<A>
|
|
1024
1070
|
/**
|
|
1025
1071
|
* The constraint `R extends Schema.Context<P[number]>` enforces dependencies solely from `typeParameters`.
|
|
1026
1072
|
* This ensures that when you call `Schema.to` or `Schema.from`, you receive a schema with a `never` context.
|
|
@@ -1028,7 +1074,7 @@ export const declare: {
|
|
|
1028
1074
|
* @category constructors
|
|
1029
1075
|
* @since 3.10.0
|
|
1030
1076
|
*/
|
|
1031
|
-
<const P extends ReadonlyArray<Schema.All
|
|
1077
|
+
<A, I, const P extends ReadonlyArray<Schema.All>>(
|
|
1032
1078
|
typeParameters: P,
|
|
1033
1079
|
options: {
|
|
1034
1080
|
readonly decode: (
|
|
@@ -1047,7 +1093,7 @@ export const declare: {
|
|
|
1047
1093
|
) => Effect.Effect<I, ParseResult.ParseIssue, never>
|
|
1048
1094
|
},
|
|
1049
1095
|
annotations?: Annotations.Schema<A, { readonly [K in keyof P]: Schema.Type<P[K]> }>
|
|
1050
|
-
):
|
|
1096
|
+
): declare<A, I, P>
|
|
1051
1097
|
} = function() {
|
|
1052
1098
|
if (Array.isArray(arguments[0])) {
|
|
1053
1099
|
const typeParameters = arguments[0]
|
|
@@ -1074,8 +1120,9 @@ export const fromBrand = <C extends Brand<string | symbol>, A extends Brand.Unbr
|
|
|
1074
1120
|
constructor: Brand.Constructor<C>,
|
|
1075
1121
|
annotations?: Annotations.Filter<C, A>
|
|
1076
1122
|
) =>
|
|
1077
|
-
<I, R>(self: Schema<A, I, R>): BrandSchema<A & C, I, R> =>
|
|
1078
|
-
|
|
1123
|
+
<I, R>(self: Schema<A, I, R>): BrandSchema<A & C, I, R> => {
|
|
1124
|
+
const out = makeBrandClass(
|
|
1125
|
+
self,
|
|
1079
1126
|
new AST.Refinement(
|
|
1080
1127
|
self.ast,
|
|
1081
1128
|
function predicate(a: A, _: ParseOptions, ast: AST.AST): option_.Option<ParseResult.ParseIssue> {
|
|
@@ -1091,6 +1138,8 @@ export const fromBrand = <C extends Brand<string | symbol>, A extends Brand.Unbr
|
|
|
1091
1138
|
})
|
|
1092
1139
|
)
|
|
1093
1140
|
)
|
|
1141
|
+
return out as any
|
|
1142
|
+
}
|
|
1094
1143
|
|
|
1095
1144
|
/**
|
|
1096
1145
|
* @category schema id
|
|
@@ -1102,7 +1151,7 @@ export const InstanceOfSchemaId: unique symbol = Symbol.for("effect/SchemaId/Ins
|
|
|
1102
1151
|
* @category api interface
|
|
1103
1152
|
* @since 3.10.0
|
|
1104
1153
|
*/
|
|
1105
|
-
export interface instanceOf<A> extends
|
|
1154
|
+
export interface instanceOf<A> extends AnnotableDeclare<instanceOf<A>, A> {}
|
|
1106
1155
|
|
|
1107
1156
|
/**
|
|
1108
1157
|
* @category constructors
|
|
@@ -1220,26 +1269,27 @@ export interface Union<Members extends ReadonlyArray<Schema.All>> extends
|
|
|
1220
1269
|
>
|
|
1221
1270
|
{
|
|
1222
1271
|
readonly members: Readonly<Members>
|
|
1223
|
-
annotations(annotations: Annotations.Schema<Schema.Type<Members[number]>>): Union<Members>
|
|
1224
1272
|
}
|
|
1225
1273
|
|
|
1226
1274
|
const getDefaultUnionAST = <Members extends AST.Members<Schema.All>>(members: Members): AST.AST =>
|
|
1227
1275
|
AST.Union.make(members.map((m) => m.ast))
|
|
1228
1276
|
|
|
1229
|
-
|
|
1277
|
+
function makeUnionClass<Members extends AST.Members<Schema.All>>(
|
|
1230
1278
|
members: Members,
|
|
1231
1279
|
ast: AST.AST = getDefaultUnionAST(members)
|
|
1232
|
-
): Union<
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1280
|
+
): Union<Members> {
|
|
1281
|
+
return class UnionClass extends make<
|
|
1282
|
+
Schema.Type<Members[number]>,
|
|
1283
|
+
Schema.Encoded<Members[number]>,
|
|
1284
|
+
Schema.Context<Members[number]>
|
|
1285
|
+
>(ast) {
|
|
1286
|
+
static override annotations(annotations: Annotations.Schema<Schema.Type<Members[number]>>): Union<Members> {
|
|
1287
|
+
return makeUnionClass(this.members, mergeSchemaAnnotations(this.ast, annotations))
|
|
1288
|
+
}
|
|
1240
1289
|
|
|
1241
|
-
|
|
1242
|
-
}
|
|
1290
|
+
static members = [...members]
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1243
1293
|
|
|
1244
1294
|
/**
|
|
1245
1295
|
* @category combinators
|
|
@@ -1454,25 +1504,27 @@ const getDefaultTupleTypeAST = <Elements extends TupleType.Elements, Rest extend
|
|
|
1454
1504
|
true
|
|
1455
1505
|
)
|
|
1456
1506
|
|
|
1457
|
-
|
|
1507
|
+
function makeTupleTypeClass<Elements extends TupleType.Elements, Rest extends TupleType.Rest>(
|
|
1458
1508
|
elements: Elements,
|
|
1459
1509
|
rest: Rest,
|
|
1460
1510
|
ast: AST.AST = getDefaultTupleTypeAST(elements, rest)
|
|
1461
|
-
)
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
>
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1511
|
+
) {
|
|
1512
|
+
return class TupleTypeClass extends make<
|
|
1513
|
+
TupleType.Type<Elements, Rest>,
|
|
1514
|
+
TupleType.Encoded<Elements, Rest>,
|
|
1515
|
+
Schema.Context<Elements[number]> | Schema.Context<Rest[number]>
|
|
1516
|
+
>(ast) {
|
|
1517
|
+
static override annotations(
|
|
1518
|
+
annotations: Annotations.Schema<TupleType.Type<Elements, Rest>>
|
|
1519
|
+
): TupleType<Elements, Rest> {
|
|
1520
|
+
return makeTupleTypeClass(this.elements, this.rest, mergeSchemaAnnotations(this.ast, annotations))
|
|
1521
|
+
}
|
|
1471
1522
|
|
|
1472
|
-
|
|
1523
|
+
static elements = [...elements] as any as Elements
|
|
1473
1524
|
|
|
1474
|
-
|
|
1475
|
-
}
|
|
1525
|
+
static rest = [...rest] as any as Rest
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1476
1528
|
|
|
1477
1529
|
/**
|
|
1478
1530
|
* @category api interface
|
|
@@ -1482,6 +1534,22 @@ export interface Tuple<Elements extends TupleType.Elements> extends TupleType<El
|
|
|
1482
1534
|
annotations(annotations: Annotations.Schema<TupleType.Type<Elements, []>>): Tuple<Elements>
|
|
1483
1535
|
}
|
|
1484
1536
|
|
|
1537
|
+
/**
|
|
1538
|
+
* @category api interface
|
|
1539
|
+
* @since 3.13.3
|
|
1540
|
+
*/
|
|
1541
|
+
export interface Tuple2<Fst extends Schema.Any, Snd extends Schema.Any> extends
|
|
1542
|
+
AnnotableClass<
|
|
1543
|
+
Tuple2<Fst, Snd>,
|
|
1544
|
+
readonly [Schema.Type<Fst>, Schema.Type<Snd>],
|
|
1545
|
+
readonly [Schema.Encoded<Fst>, Schema.Encoded<Snd>],
|
|
1546
|
+
Schema.Context<Fst> | Schema.Context<Snd>
|
|
1547
|
+
>
|
|
1548
|
+
{
|
|
1549
|
+
readonly elements: readonly [Fst, Snd]
|
|
1550
|
+
readonly rest: readonly []
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1485
1553
|
/**
|
|
1486
1554
|
* @category constructors
|
|
1487
1555
|
* @since 3.10.0
|
|
@@ -1490,6 +1558,7 @@ export function Tuple<
|
|
|
1490
1558
|
const Elements extends TupleType.Elements,
|
|
1491
1559
|
Rest extends array_.NonEmptyReadonlyArray<TupleType.Rest[number]>
|
|
1492
1560
|
>(elements: Elements, ...rest: Rest): TupleType<Elements, Rest>
|
|
1561
|
+
export function Tuple<Fst extends Schema.Any, Snd extends Schema.Any>(fst: Fst, snd: Snd): Tuple2<Fst, Snd>
|
|
1493
1562
|
export function Tuple<Elements extends TupleType.Elements>(...elements: Elements): Tuple<Elements>
|
|
1494
1563
|
export function Tuple(...args: ReadonlyArray<any>): any {
|
|
1495
1564
|
return Array.isArray(args[0])
|
|
@@ -1506,16 +1575,18 @@ export interface Array$<Value extends Schema.Any> extends TupleType<[], [Value]>
|
|
|
1506
1575
|
annotations(annotations: Annotations.Schema<TupleType.Type<[], [Value]>>): Array$<Value>
|
|
1507
1576
|
}
|
|
1508
1577
|
|
|
1509
|
-
|
|
1578
|
+
function makeArrayClass<Value extends Schema.Any>(
|
|
1510
1579
|
value: Value,
|
|
1511
1580
|
ast?: AST.AST
|
|
1512
|
-
): Array$<Value>
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1581
|
+
): Array$<Value> {
|
|
1582
|
+
return class ArrayClass extends makeTupleTypeClass<[], [Value]>([], [value], ast) {
|
|
1583
|
+
static override annotations(annotations: Annotations.Schema<TupleType.Type<[], [Value]>>) {
|
|
1584
|
+
return makeArrayClass(this.value, mergeSchemaAnnotations(this.ast, annotations))
|
|
1585
|
+
}
|
|
1516
1586
|
|
|
1517
|
-
|
|
1518
|
-
}
|
|
1587
|
+
static value = value
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1519
1590
|
|
|
1520
1591
|
const Array$ = <Value extends Schema.Any>(value: Value): Array$<Value> => makeArrayClass(value)
|
|
1521
1592
|
|
|
@@ -1531,83 +1602,77 @@ export {
|
|
|
1531
1602
|
* @category api interface
|
|
1532
1603
|
* @since 3.10.0
|
|
1533
1604
|
*/
|
|
1534
|
-
export interface NonEmptyArray<Value extends Schema.Any> extends
|
|
1605
|
+
export interface NonEmptyArray<Value extends Schema.Any> extends
|
|
1606
|
+
AnnotableClass<
|
|
1607
|
+
NonEmptyArray<Value>,
|
|
1608
|
+
array_.NonEmptyReadonlyArray<Schema.Type<Value>>,
|
|
1609
|
+
array_.NonEmptyReadonlyArray<Schema.Encoded<Value>>,
|
|
1610
|
+
Schema.Context<Value>
|
|
1611
|
+
>
|
|
1612
|
+
{
|
|
1613
|
+
readonly elements: readonly [Value]
|
|
1614
|
+
readonly rest: readonly [Value]
|
|
1535
1615
|
readonly value: Value
|
|
1536
|
-
annotations(annotations: Annotations.Schema<TupleType.Type<[Value], [Value]>>): NonEmptyArray<Value>
|
|
1537
1616
|
}
|
|
1538
1617
|
|
|
1539
|
-
|
|
1618
|
+
function makeNonEmptyArrayClass<Value extends Schema.Any>(
|
|
1540
1619
|
value: Value,
|
|
1541
1620
|
ast?: AST.AST
|
|
1542
|
-
)
|
|
1543
|
-
Value
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
}
|
|
1621
|
+
) {
|
|
1622
|
+
return class NonEmptyArrayClass extends makeTupleTypeClass<[Value], [Value]>([value], [value], ast) {
|
|
1623
|
+
static override annotations(annotations: Annotations.Schema<TupleType.Type<[Value], [Value]>>) {
|
|
1624
|
+
return makeNonEmptyArrayClass(this.value, mergeSchemaAnnotations(this.ast, annotations))
|
|
1625
|
+
}
|
|
1548
1626
|
|
|
1549
|
-
|
|
1550
|
-
}
|
|
1627
|
+
static value = value
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1551
1630
|
|
|
1552
1631
|
/**
|
|
1553
1632
|
* @category constructors
|
|
1554
1633
|
* @since 3.10.0
|
|
1555
1634
|
*/
|
|
1556
1635
|
export const NonEmptyArray = <Value extends Schema.Any>(value: Value): NonEmptyArray<Value> =>
|
|
1557
|
-
makeNonEmptyArrayClass(value)
|
|
1636
|
+
makeNonEmptyArrayClass(value) as any
|
|
1558
1637
|
|
|
1559
1638
|
/**
|
|
1560
1639
|
* @category api interface
|
|
1561
1640
|
* @since 3.10.0
|
|
1562
1641
|
*/
|
|
1563
|
-
export interface ArrayEnsure<Value extends Schema.Any>
|
|
1564
|
-
|
|
1565
|
-
ArrayEnsure<Value>,
|
|
1566
|
-
ReadonlyArray<Schema.Type<Value>>,
|
|
1567
|
-
Schema.Encoded<Value> | ReadonlyArray<Schema.Encoded<Value>>,
|
|
1568
|
-
Schema.Context<Value>
|
|
1569
|
-
>
|
|
1642
|
+
export interface ArrayEnsure<Value extends Schema.Any>
|
|
1643
|
+
extends transform<Union<[Value, Array$<Value>]>, Array$<SchemaClass<Schema.Type<Value>>>>
|
|
1570
1644
|
{}
|
|
1571
1645
|
|
|
1572
1646
|
/**
|
|
1573
1647
|
* @category constructors
|
|
1574
1648
|
* @since 3.10.0
|
|
1575
1649
|
*/
|
|
1576
|
-
export
|
|
1577
|
-
|
|
1578
|
-
return class ArrayEnsureClass extends transform(Union(value_, Array$(value_)), Array$(typeSchema(value_)), {
|
|
1650
|
+
export function ArrayEnsure<Value extends Schema.Any>(value: Value): ArrayEnsure<Value> {
|
|
1651
|
+
return transform(Union(value, Array$(value)), Array$(typeSchema(asSchema(value))), {
|
|
1579
1652
|
strict: true,
|
|
1580
|
-
decode: array_.ensure,
|
|
1581
|
-
encode: (
|
|
1582
|
-
})
|
|
1653
|
+
decode: (i) => array_.ensure(i),
|
|
1654
|
+
encode: (a) => a.length === 1 ? a[0] : a
|
|
1655
|
+
})
|
|
1583
1656
|
}
|
|
1584
1657
|
|
|
1585
1658
|
/**
|
|
1586
1659
|
* @category api interface
|
|
1587
1660
|
* @since 3.10.0
|
|
1588
1661
|
*/
|
|
1589
|
-
export interface NonEmptyArrayEnsure<Value extends Schema.Any>
|
|
1590
|
-
|
|
1591
|
-
NonEmptyArrayEnsure<Value>,
|
|
1592
|
-
array_.NonEmptyReadonlyArray<Schema.Type<Value>>,
|
|
1593
|
-
Schema.Encoded<Value> | array_.NonEmptyReadonlyArray<Schema.Encoded<Value>>,
|
|
1594
|
-
Schema.Context<Value>
|
|
1595
|
-
>
|
|
1662
|
+
export interface NonEmptyArrayEnsure<Value extends Schema.Any>
|
|
1663
|
+
extends transform<Union<[Value, NonEmptyArray<Value>]>, NonEmptyArray<SchemaClass<Schema.Type<Value>>>>
|
|
1596
1664
|
{}
|
|
1597
1665
|
|
|
1598
1666
|
/**
|
|
1599
1667
|
* @category constructors
|
|
1600
1668
|
* @since 3.10.0
|
|
1601
1669
|
*/
|
|
1602
|
-
export
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
encode: (arr) => arr.length === 1 ? arr[0] : arr
|
|
1609
|
-
})
|
|
1610
|
-
{}
|
|
1670
|
+
export function NonEmptyArrayEnsure<Value extends Schema.Any>(value: Value): NonEmptyArrayEnsure<Value> {
|
|
1671
|
+
return transform(Union(value, NonEmptyArray(value)), NonEmptyArray(typeSchema(asSchema(value))), {
|
|
1672
|
+
strict: true,
|
|
1673
|
+
decode: (i) => array_.isNonEmptyReadonlyArray(i) ? i : array_.of(i),
|
|
1674
|
+
encode: (a) => a.length === 1 ? a[0] : a
|
|
1675
|
+
})
|
|
1611
1676
|
}
|
|
1612
1677
|
|
|
1613
1678
|
/**
|
|
@@ -2549,17 +2614,12 @@ export const optionalWith: {
|
|
|
2549
2614
|
* @category PropertySignature
|
|
2550
2615
|
* @since 3.10.0
|
|
2551
2616
|
*/
|
|
2552
|
-
<S extends Schema.All, Options extends OptionalOptions<Schema.Type<S>>>(
|
|
2553
|
-
options: Options
|
|
2554
|
-
): (self: S) => optionalWith<S, Options>
|
|
2617
|
+
<S extends Schema.All, Options extends OptionalOptions<Schema.Type<S>>>(options: Options): (self: S) => optionalWith<S, Options>
|
|
2555
2618
|
/**
|
|
2556
2619
|
* @category PropertySignature
|
|
2557
2620
|
* @since 3.10.0
|
|
2558
2621
|
*/
|
|
2559
|
-
<S extends Schema.All, Options extends OptionalOptions<Schema.Type<S>>>(
|
|
2560
|
-
self: S,
|
|
2561
|
-
options: Options
|
|
2562
|
-
): optionalWith<S, Options>
|
|
2622
|
+
<S extends Schema.All, Options extends OptionalOptions<Schema.Type<S>>>(self: S, options: Options): optionalWith<S, Options>
|
|
2563
2623
|
} = dual((args) => isSchema(args[0]), (self, options) => {
|
|
2564
2624
|
return new PropertySignatureWithFromImpl(optionalPropertySignatureAST(self, options), self)
|
|
2565
2625
|
})
|
|
@@ -2577,45 +2637,47 @@ export declare namespace Struct {
|
|
|
2577
2637
|
| PropertySignature.All
|
|
2578
2638
|
}
|
|
2579
2639
|
|
|
2580
|
-
type
|
|
2581
|
-
|
|
2582
|
-
|
|
2640
|
+
type OptionalEncodedPropertySignature =
|
|
2641
|
+
| PropertySignature<PropertySignature.Token, any, PropertyKey, "?:", any, boolean, unknown>
|
|
2642
|
+
| PropertySignature<PropertySignature.Token, any, PropertyKey, "?:", never, boolean, unknown>
|
|
2643
|
+
| PropertySignature<PropertySignature.Token, never, PropertyKey, "?:", any, boolean, unknown>
|
|
2644
|
+
| PropertySignature<PropertySignature.Token, never, PropertyKey, "?:", never, boolean, unknown>
|
|
2583
2645
|
|
|
2584
|
-
type
|
|
2585
|
-
[K in keyof Fields]: Fields[K] extends
|
|
2586
|
-
| PropertySignature<PropertySignature.Token, any, PropertyKey, "?:", any, boolean, unknown>
|
|
2587
|
-
| PropertySignature<PropertySignature.Token, any, PropertyKey, "?:", never, boolean, unknown>
|
|
2588
|
-
| PropertySignature<PropertySignature.Token, never, PropertyKey, "?:", any, boolean, unknown>
|
|
2589
|
-
| PropertySignature<PropertySignature.Token, never, PropertyKey, "?:", never, boolean, unknown> ? K
|
|
2646
|
+
type EncodedOptionalKeys<Fields extends Struct.Fields> = {
|
|
2647
|
+
[K in keyof Fields]: Fields[K] extends OptionalEncodedPropertySignature ? K
|
|
2590
2648
|
: never
|
|
2591
2649
|
}[keyof Fields]
|
|
2592
2650
|
|
|
2593
|
-
type
|
|
2594
|
-
[K in keyof Fields]: Fields[K] extends OptionalPropertySignature ? K : never
|
|
2595
|
-
}[keyof Fields]
|
|
2596
|
-
|
|
2597
|
-
type OptionalPropertySignature =
|
|
2651
|
+
type OptionalTypePropertySignature =
|
|
2598
2652
|
| PropertySignature<"?:", any, PropertyKey, PropertySignature.Token, any, boolean, unknown>
|
|
2599
2653
|
| PropertySignature<"?:", any, PropertyKey, PropertySignature.Token, never, boolean, unknown>
|
|
2600
2654
|
| PropertySignature<"?:", never, PropertyKey, PropertySignature.Token, any, boolean, unknown>
|
|
2601
2655
|
| PropertySignature<"?:", never, PropertyKey, PropertySignature.Token, never, boolean, unknown>
|
|
2602
2656
|
|
|
2657
|
+
// type TypeOptionalKeys<Fields extends Struct.Fields> = {
|
|
2658
|
+
// [K in keyof Fields]: Fields[K] extends OptionalTypePropertySignature ? K : never
|
|
2659
|
+
// }[keyof Fields]
|
|
2660
|
+
|
|
2603
2661
|
/**
|
|
2604
2662
|
* @since 3.10.0
|
|
2605
2663
|
*/
|
|
2606
2664
|
export type Type<F extends Fields> = Types.UnionToIntersection<
|
|
2607
2665
|
{
|
|
2608
|
-
[K in keyof F]: F[K] extends
|
|
2666
|
+
[K in keyof F]: F[K] extends OptionalTypePropertySignature ? { readonly [H in K]?: Schema.Type<F[H]> } :
|
|
2609
2667
|
{ readonly [h in K]: Schema.Type<F[h]> }
|
|
2610
2668
|
}[keyof F]
|
|
2611
2669
|
> extends infer Q ? Q : never
|
|
2612
2670
|
|
|
2671
|
+
type Key<F extends Fields, K extends keyof F> = [K] extends [never] ? never :
|
|
2672
|
+
F[K] extends PropertySignature.All<infer Key> ? [Key] extends [never] ? K : Key :
|
|
2673
|
+
K
|
|
2674
|
+
|
|
2613
2675
|
/**
|
|
2614
2676
|
* @since 3.10.0
|
|
2615
2677
|
*/
|
|
2616
2678
|
export type Encoded<F extends Fields> =
|
|
2617
|
-
& { readonly [K in Exclude<keyof F,
|
|
2618
|
-
& { readonly [K in
|
|
2679
|
+
& { readonly [K in Exclude<keyof F, EncodedOptionalKeys<F>> as Key<F, K>]: Schema.Encoded<F[K]> }
|
|
2680
|
+
& { readonly [K in EncodedOptionalKeys<F> as Key<F, K>]?: Schema.Encoded<F[K]> }
|
|
2619
2681
|
|
|
2620
2682
|
/**
|
|
2621
2683
|
* @since 3.10.0
|
|
@@ -2633,7 +2695,7 @@ export declare namespace Struct {
|
|
|
2633
2695
|
*/
|
|
2634
2696
|
export type Constructor<F extends Fields> = Types.UnionToIntersection<
|
|
2635
2697
|
{
|
|
2636
|
-
[K in keyof F]: F[K] extends
|
|
2698
|
+
[K in keyof F]: F[K] extends OptionalTypePropertySignature ? { readonly [H in K]?: Schema.Type<F[H]> } :
|
|
2637
2699
|
F[K] extends PropertySignatureWithDefault ? { readonly [H in K]?: Schema.Type<F[H]> } :
|
|
2638
2700
|
{ readonly [h in K]: Schema.Type<F[h]> }
|
|
2639
2701
|
}[keyof F]
|
|
@@ -3094,7 +3156,7 @@ export const pluck: {
|
|
|
3094
3156
|
* @category struct transformations
|
|
3095
3157
|
* @since 3.10.0
|
|
3096
3158
|
*/
|
|
3097
|
-
<A, I, K extends keyof A & keyof I>(key: K): <R>(schema: Schema<A, I, R>) =>
|
|
3159
|
+
<A, I, K extends keyof A & keyof I>(key: K): <R>(schema: Schema<A, I, R>) => SchemaClass<A[K], Simplify<Pick<I, K>>, R>
|
|
3098
3160
|
/**
|
|
3099
3161
|
* Given a schema `Schema<A, I, R>` and a key `key: K`, this function extracts a specific field from the `A` type,
|
|
3100
3162
|
* producing a new schema that represents a transformation from the `{ readonly [key]: I[K] }` type to `A[K]`.
|
|
@@ -3125,7 +3187,7 @@ export const pluck: {
|
|
|
3125
3187
|
* @category struct transformations
|
|
3126
3188
|
* @since 3.10.0
|
|
3127
3189
|
*/
|
|
3128
|
-
<A, I, R, K extends keyof A & keyof I>(schema: Schema<A, I, R>, key: K):
|
|
3190
|
+
<A, I, R, K extends keyof A & keyof I>(schema: Schema<A, I, R>, key: K): SchemaClass<A[K], Simplify<Pick<I, K>>, R>
|
|
3129
3191
|
} = dual(
|
|
3130
3192
|
2,
|
|
3131
3193
|
<A, I, R, K extends keyof A & keyof I>(
|
|
@@ -3133,108 +3195,107 @@ export const pluck: {
|
|
|
3133
3195
|
key: K
|
|
3134
3196
|
): Schema<A[K], Pick<I, K>, R> => {
|
|
3135
3197
|
const ps = AST.getPropertyKeyIndexedAccess(AST.typeAST(schema.ast), key)
|
|
3136
|
-
const value = make
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
>(ps.isOptional ? AST.orUndefined(ps.type) : ps.type)
|
|
3229
|
-
return transform(
|
|
3198
|
+
const value = make</**
|
|
3199
|
+
* Given a schema `Schema<A, I, R>` and a key `key: K`, this function extracts a specific field from the `A` type,
|
|
3200
|
+
* producing a new schema that represents a transformation from the `{ readonly [key]: I[K] }` type to `A[K]`.
|
|
3201
|
+
*
|
|
3202
|
+
* @example
|
|
3203
|
+
* ```ts
|
|
3204
|
+
* import * as Schema from "effect/Schema"
|
|
3205
|
+
*
|
|
3206
|
+
* // ---------------------------------------------
|
|
3207
|
+
* // use case: pull out a single field from a
|
|
3208
|
+
* // struct through a transformation
|
|
3209
|
+
* // ---------------------------------------------
|
|
3210
|
+
*
|
|
3211
|
+
* const mytable = Schema.Struct({
|
|
3212
|
+
* column1: Schema.NumberFromString,
|
|
3213
|
+
* column2: Schema.Number
|
|
3214
|
+
* })
|
|
3215
|
+
*
|
|
3216
|
+
* // const pullOutColumn: S.Schema<number, {
|
|
3217
|
+
* // readonly column1: string;
|
|
3218
|
+
* // }, never>
|
|
3219
|
+
* const pullOutColumn = mytable.pipe(Schema.pluck("column1"))
|
|
3220
|
+
*
|
|
3221
|
+
* console.log(Schema.decodeUnknownEither(Schema.Array(pullOutColumn))([{ column1: "1", column2: 100 }, { column1: "2", column2: 300 }]))
|
|
3222
|
+
* // Output: { _id: 'Either', _tag: 'Right', right: [ 1, 2 ] }
|
|
3223
|
+
* ```
|
|
3224
|
+
*
|
|
3225
|
+
* @category struct transformations
|
|
3226
|
+
* @since 3.10.0
|
|
3227
|
+
*/
|
|
3228
|
+
A[K], /**
|
|
3229
|
+
* Given a schema `Schema<A, I, R>` and a key `key: K`, this function extracts a specific field from the `A` type,
|
|
3230
|
+
* producing a new schema that represents a transformation from the `{ readonly [key]: I[K] }` type to `A[K]`.
|
|
3231
|
+
*
|
|
3232
|
+
* @example
|
|
3233
|
+
* ```ts
|
|
3234
|
+
* import * as Schema from "effect/Schema"
|
|
3235
|
+
*
|
|
3236
|
+
* // ---------------------------------------------
|
|
3237
|
+
* // use case: pull out a single field from a
|
|
3238
|
+
* // struct through a transformation
|
|
3239
|
+
* // ---------------------------------------------
|
|
3240
|
+
*
|
|
3241
|
+
* const mytable = Schema.Struct({
|
|
3242
|
+
* column1: Schema.NumberFromString,
|
|
3243
|
+
* column2: Schema.Number
|
|
3244
|
+
* })
|
|
3245
|
+
*
|
|
3246
|
+
* // const pullOutColumn: S.Schema<number, {
|
|
3247
|
+
* // readonly column1: string;
|
|
3248
|
+
* // }, never>
|
|
3249
|
+
* const pullOutColumn = mytable.pipe(Schema.pluck("column1"))
|
|
3250
|
+
*
|
|
3251
|
+
* console.log(Schema.decodeUnknownEither(Schema.Array(pullOutColumn))([{ column1: "1", column2: 100 }, { column1: "2", column2: 300 }]))
|
|
3252
|
+
* // Output: { _id: 'Either', _tag: 'Right', right: [ 1, 2 ] }
|
|
3253
|
+
* ```
|
|
3254
|
+
*
|
|
3255
|
+
* @category struct transformations
|
|
3256
|
+
* @since 3.10.0
|
|
3257
|
+
*/
|
|
3258
|
+
A[K], /**
|
|
3259
|
+
* Given a schema `Schema<A, I, R>` and a key `key: K`, this function extracts a specific field from the `A` type,
|
|
3260
|
+
* producing a new schema that represents a transformation from the `{ readonly [key]: I[K] }` type to `A[K]`.
|
|
3261
|
+
*
|
|
3262
|
+
* @example
|
|
3263
|
+
* ```ts
|
|
3264
|
+
* import * as Schema from "effect/Schema"
|
|
3265
|
+
*
|
|
3266
|
+
* // ---------------------------------------------
|
|
3267
|
+
* // use case: pull out a single field from a
|
|
3268
|
+
* // struct through a transformation
|
|
3269
|
+
* // ---------------------------------------------
|
|
3270
|
+
*
|
|
3271
|
+
* const mytable = Schema.Struct({
|
|
3272
|
+
* column1: Schema.NumberFromString,
|
|
3273
|
+
* column2: Schema.Number
|
|
3274
|
+
* })
|
|
3275
|
+
*
|
|
3276
|
+
* // const pullOutColumn: S.Schema<number, {
|
|
3277
|
+
* // readonly column1: string;
|
|
3278
|
+
* // }, never>
|
|
3279
|
+
* const pullOutColumn = mytable.pipe(Schema.pluck("column1"))
|
|
3280
|
+
*
|
|
3281
|
+
* console.log(Schema.decodeUnknownEither(Schema.Array(pullOutColumn))([{ column1: "1", column2: 100 }, { column1: "2", column2: 300 }]))
|
|
3282
|
+
* // Output: { _id: 'Either', _tag: 'Right', right: [ 1, 2 ] }
|
|
3283
|
+
* ```
|
|
3284
|
+
*
|
|
3285
|
+
* @category struct transformations
|
|
3286
|
+
* @since 3.10.0
|
|
3287
|
+
*/
|
|
3288
|
+
R>(ps.isOptional ? AST.orUndefined(ps.type) : ps.type)
|
|
3289
|
+
const out = transform(
|
|
3230
3290
|
schema.pipe(pick(key)),
|
|
3231
3291
|
value,
|
|
3232
3292
|
{
|
|
3233
3293
|
strict: true,
|
|
3234
|
-
decode: (
|
|
3235
|
-
encode: (
|
|
3294
|
+
decode: (i) => i[key],
|
|
3295
|
+
encode: (a) => ps.isOptional && a === undefined ? {} : { [key]: a } as any
|
|
3236
3296
|
}
|
|
3237
3297
|
)
|
|
3298
|
+
return out
|
|
3238
3299
|
}
|
|
3239
3300
|
)
|
|
3240
3301
|
|
|
@@ -3255,20 +3316,26 @@ export interface BrandSchema<A extends Brand<any>, I = A, R = never>
|
|
|
3255
3316
|
export interface brand<S extends Schema.Any, B extends string | symbol>
|
|
3256
3317
|
extends BrandSchema<Schema.Type<S> & Brand<B>, Schema.Encoded<S>, Schema.Context<S>>
|
|
3257
3318
|
{
|
|
3319
|
+
readonly from: S
|
|
3258
3320
|
annotations(annotations: Annotations.Schema<Schema.Type<S> & Brand<B>>): brand<S, B>
|
|
3259
3321
|
}
|
|
3260
3322
|
|
|
3261
|
-
|
|
3323
|
+
function makeBrandClass<S extends Schema.Any, B extends string | symbol>(
|
|
3324
|
+
from: S,
|
|
3262
3325
|
ast: AST.AST
|
|
3263
|
-
): brand<S, B>
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3326
|
+
): brand<S, B> {
|
|
3327
|
+
return class BrandClass extends make<Schema.Type<S> & Brand<B>, Schema.Encoded<S>, Schema.Context<S>>(ast) {
|
|
3328
|
+
static override annotations(annotations: Annotations.Schema<Schema.Type<S> & Brand<B>>): brand<S, B> {
|
|
3329
|
+
return makeBrandClass(this.from, mergeSchemaAnnotations(this.ast, annotations))
|
|
3330
|
+
}
|
|
3267
3331
|
|
|
3268
|
-
|
|
3269
|
-
|
|
3332
|
+
static make = (a: Brand.Unbranded<Schema.Type<S> & Brand<B>>, options?: MakeOptions): Schema.Type<S> & Brand<B> => {
|
|
3333
|
+
return getDisableValidationMakeOption(options) ? a : ParseResult.validateSync(this)(a)
|
|
3334
|
+
}
|
|
3335
|
+
|
|
3336
|
+
static from = from
|
|
3270
3337
|
}
|
|
3271
|
-
}
|
|
3338
|
+
}
|
|
3272
3339
|
|
|
3273
3340
|
/**
|
|
3274
3341
|
* Returns a nominal branded schema by applying a brand to a given schema.
|
|
@@ -3307,7 +3374,7 @@ export const brand = <S extends Schema.AnyNoContext, B extends string | symbol>(
|
|
|
3307
3374
|
...annotations
|
|
3308
3375
|
})
|
|
3309
3376
|
)
|
|
3310
|
-
return makeBrandClass(ast)
|
|
3377
|
+
return makeBrandClass(self, ast)
|
|
3311
3378
|
}
|
|
3312
3379
|
|
|
3313
3380
|
/**
|
|
@@ -3335,10 +3402,7 @@ export const partialWith: {
|
|
|
3335
3402
|
* @category combinators
|
|
3336
3403
|
* @since 3.10.0
|
|
3337
3404
|
*/
|
|
3338
|
-
<A, I, R, const Options extends { readonly exact: true } | undefined>(
|
|
3339
|
-
self: Schema<A, I, R>,
|
|
3340
|
-
options: Options
|
|
3341
|
-
): SchemaClass<{ [K in keyof A]?: A[K] }, { [K in keyof I]?: I[K] }, R>
|
|
3405
|
+
<A, I, R, const Options extends { readonly exact: true } | undefined>(self: Schema<A, I, R>, options: Options): SchemaClass<{ [K in keyof A]?: A[K] }, { [K in keyof I]?: I[K] }, R>
|
|
3342
3406
|
} = dual((args) => isSchema(args[0]), <A, I, R>(
|
|
3343
3407
|
self: Schema<A, I, R>,
|
|
3344
3408
|
options: { readonly exact: true }
|
|
@@ -3710,61 +3774,55 @@ export const compose: {
|
|
|
3710
3774
|
* @category combinators
|
|
3711
3775
|
* @since 3.10.0
|
|
3712
3776
|
*/
|
|
3713
|
-
<
|
|
3777
|
+
<To extends Schema.Any, From extends Schema.Any, C extends Schema.Type<From>>(to: To & Schema<Schema.Type<To>, C, Schema.Context<To>>): (from: From) => transform<From, To>
|
|
3714
3778
|
/**
|
|
3715
3779
|
* @category combinators
|
|
3716
3780
|
* @since 3.10.0
|
|
3717
3781
|
*/
|
|
3718
|
-
<
|
|
3782
|
+
<To extends Schema.Any>(to: To): <From extends Schema.Any, B extends Schema.Encoded<To>>(
|
|
3783
|
+
from: From & Schema<B, Schema.Encoded<From>, Schema.Context<From>>
|
|
3784
|
+
) => transform<From, To>
|
|
3719
3785
|
/**
|
|
3720
3786
|
* @category combinators
|
|
3721
3787
|
* @since 3.10.0
|
|
3722
3788
|
*/
|
|
3723
|
-
<
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
): <A, R1>(from: Schema<B, A, R1>) => SchemaClass<C, A, R1 | R2>
|
|
3789
|
+
<To extends Schema.Any>(to: To, options?: { readonly strict: true }): <From extends Schema.Any>(
|
|
3790
|
+
from: From & Schema<Schema.Encoded<To>, Schema.Encoded<From>, Schema.Context<From>>
|
|
3791
|
+
) => transform<From, To>
|
|
3727
3792
|
/**
|
|
3728
3793
|
* @category combinators
|
|
3729
3794
|
* @since 3.10.0
|
|
3730
3795
|
*/
|
|
3731
|
-
<
|
|
3732
|
-
to: Schema<D, C, R2>,
|
|
3733
|
-
options: { readonly strict: false }
|
|
3734
|
-
): <B, A, R1>(from: Schema<B, A, R1>) => SchemaClass<D, A, R1 | R2>
|
|
3796
|
+
<To extends Schema.Any>(to: To, options: { readonly strict: false }): <From extends Schema.Any>(from: From) => transform<From, To>
|
|
3735
3797
|
|
|
3736
3798
|
/**
|
|
3737
3799
|
* @category combinators
|
|
3738
3800
|
* @since 3.10.0
|
|
3739
3801
|
*/
|
|
3740
|
-
<
|
|
3802
|
+
<From extends Schema.Any, To extends Schema.Any, C extends Schema.Type<From>>(from: From, to: To & Schema<Schema.Type<To>, C, Schema.Context<To>>): transform<From, To>
|
|
3741
3803
|
/**
|
|
3742
3804
|
* @category combinators
|
|
3743
3805
|
* @since 3.10.0
|
|
3744
3806
|
*/
|
|
3745
|
-
<
|
|
3807
|
+
<From extends Schema.Any, B extends Schema.Encoded<To>, To extends Schema.Any>(from: From & Schema<B, Schema.Encoded<From>, Schema.Context<From>>, to: To): transform<From, To>
|
|
3746
3808
|
/**
|
|
3747
3809
|
* @category combinators
|
|
3748
3810
|
* @since 3.10.0
|
|
3749
3811
|
*/
|
|
3750
|
-
<
|
|
3751
|
-
from: Schema<
|
|
3752
|
-
to:
|
|
3812
|
+
<From extends Schema.Any, To extends Schema.Any>(
|
|
3813
|
+
from: From & Schema<Schema.Encoded<To>, Schema.Encoded<From>, Schema.Context<From>>,
|
|
3814
|
+
to: To,
|
|
3753
3815
|
options?: { readonly strict: true }
|
|
3754
|
-
):
|
|
3816
|
+
): transform<From, To>
|
|
3755
3817
|
/**
|
|
3756
3818
|
* @category combinators
|
|
3757
3819
|
* @since 3.10.0
|
|
3758
3820
|
*/
|
|
3759
|
-
<
|
|
3760
|
-
from: Schema<B, A, R1>,
|
|
3761
|
-
to: Schema<D, C, R2>,
|
|
3762
|
-
options: { readonly strict: false }
|
|
3763
|
-
): SchemaClass<D, A, R1 | R2>
|
|
3821
|
+
<From extends Schema.Any, To extends Schema.Any>(from: From, to: To, options: { readonly strict: false }): transform<From, To>
|
|
3764
3822
|
} = dual(
|
|
3765
3823
|
(args) => isSchema(args[1]),
|
|
3766
3824
|
<B, A, R1, D, C, R2>(from: Schema<B, A, R1>, to: Schema<D, C, R2>): SchemaClass<D, A, R1 | R2> =>
|
|
3767
|
-
|
|
3825
|
+
makeTransformationClass(from, to, AST.compose(from.ast, to.ast))
|
|
3768
3826
|
)
|
|
3769
3827
|
|
|
3770
3828
|
/**
|
|
@@ -3809,29 +3867,27 @@ export interface refine<A, From extends Schema.Any>
|
|
|
3809
3867
|
make(a: Schema.Type<From>, options?: MakeOptions): A
|
|
3810
3868
|
}
|
|
3811
3869
|
|
|
3812
|
-
|
|
3870
|
+
function makeRefineClass<From extends Schema.Any, A>(
|
|
3813
3871
|
from: From,
|
|
3814
|
-
filter: (
|
|
3815
|
-
a: Schema.Type<From>,
|
|
3816
|
-
options: ParseOptions,
|
|
3817
|
-
self: AST.Refinement
|
|
3818
|
-
) => option_.Option<ParseResult.ParseIssue>,
|
|
3872
|
+
filter: (a: Schema.Type<From>, options: ParseOptions, self: AST.Refinement) => option_.Option<ParseResult.ParseIssue>,
|
|
3819
3873
|
ast: AST.AST
|
|
3820
|
-
): refine<A, From>
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3874
|
+
): refine<A, From> {
|
|
3875
|
+
return class RefineClass extends make<A, Schema.Encoded<From>, Schema.Context<From>>(ast) {
|
|
3876
|
+
static override annotations(annotations: Annotations.Schema<A>): refine<A, From> {
|
|
3877
|
+
return makeRefineClass(this.from, this.filter, mergeSchemaAnnotations(this.ast, annotations))
|
|
3878
|
+
}
|
|
3824
3879
|
|
|
3825
|
-
|
|
3880
|
+
static [RefineSchemaId] = from
|
|
3826
3881
|
|
|
3827
|
-
|
|
3882
|
+
static from = from
|
|
3828
3883
|
|
|
3829
|
-
|
|
3884
|
+
static filter = filter
|
|
3830
3885
|
|
|
3831
|
-
|
|
3832
|
-
|
|
3886
|
+
static make = (a: Schema.Type<From>, options?: MakeOptions): A => {
|
|
3887
|
+
return getDisableValidationMakeOption(options) ? a : ParseResult.validateSync(this)(a)
|
|
3888
|
+
}
|
|
3833
3889
|
}
|
|
3834
|
-
}
|
|
3890
|
+
}
|
|
3835
3891
|
|
|
3836
3892
|
/**
|
|
3837
3893
|
* @category api interface
|
|
@@ -3988,16 +4044,16 @@ export const filterEffect: {
|
|
|
3988
4044
|
typeSchema(self),
|
|
3989
4045
|
{
|
|
3990
4046
|
strict: true,
|
|
3991
|
-
decode: (
|
|
4047
|
+
decode: (i, options, ast) =>
|
|
3992
4048
|
ParseResult.flatMap(
|
|
3993
|
-
f(
|
|
4049
|
+
f(i, options, ast),
|
|
3994
4050
|
(filterReturnType) =>
|
|
3995
|
-
option_.match(toFilterParseIssue(filterReturnType, ast,
|
|
3996
|
-
onNone: () => ParseResult.succeed(
|
|
4051
|
+
option_.match(toFilterParseIssue(filterReturnType, ast, i), {
|
|
4052
|
+
onNone: () => ParseResult.succeed(i),
|
|
3997
4053
|
onSome: ParseResult.fail
|
|
3998
4054
|
})
|
|
3999
4055
|
),
|
|
4000
|
-
encode: ParseResult.succeed
|
|
4056
|
+
encode: (a) => ParseResult.succeed(a)
|
|
4001
4057
|
}
|
|
4002
4058
|
))
|
|
4003
4059
|
|
|
@@ -4005,7 +4061,7 @@ export const filterEffect: {
|
|
|
4005
4061
|
* @category api interface
|
|
4006
4062
|
* @since 3.10.0
|
|
4007
4063
|
*/
|
|
4008
|
-
export interface transformOrFail<From extends Schema.
|
|
4064
|
+
export interface transformOrFail<From extends Schema.All, To extends Schema.All, R = never> extends
|
|
4009
4065
|
AnnotableClass<
|
|
4010
4066
|
transformOrFail<From, To, R>,
|
|
4011
4067
|
Schema.Type<To>,
|
|
@@ -4017,29 +4073,27 @@ export interface transformOrFail<From extends Schema.Any, To extends Schema.Any,
|
|
|
4017
4073
|
readonly to: To
|
|
4018
4074
|
}
|
|
4019
4075
|
|
|
4020
|
-
|
|
4076
|
+
function makeTransformationClass<From extends Schema.Any, To extends Schema.Any, R>(
|
|
4021
4077
|
from: From,
|
|
4022
4078
|
to: To,
|
|
4023
4079
|
ast: AST.AST
|
|
4024
|
-
): transformOrFail<
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
mergeSchemaAnnotations(this.ast, annotations)
|
|
4036
|
-
)
|
|
4037
|
-
}
|
|
4080
|
+
): transformOrFail<From, To, R> {
|
|
4081
|
+
return class TransformationClass
|
|
4082
|
+
extends make<Schema.Type<To>, Schema.Encoded<From>, Schema.Context<From> | Schema.Context<To> | R>(ast)
|
|
4083
|
+
{
|
|
4084
|
+
static override annotations(annotations: Annotations.Schema<Schema.Type<To>>) {
|
|
4085
|
+
return makeTransformationClass<From, To, R>(
|
|
4086
|
+
this.from,
|
|
4087
|
+
this.to,
|
|
4088
|
+
mergeSchemaAnnotations(this.ast, annotations)
|
|
4089
|
+
)
|
|
4090
|
+
}
|
|
4038
4091
|
|
|
4039
|
-
|
|
4092
|
+
static from = from
|
|
4040
4093
|
|
|
4041
|
-
|
|
4042
|
-
}
|
|
4094
|
+
static to = to
|
|
4095
|
+
}
|
|
4096
|
+
}
|
|
4043
4097
|
|
|
4044
4098
|
/**
|
|
4045
4099
|
* Create a new `Schema` by transforming the input and output of an existing `Schema`
|
|
@@ -4160,7 +4214,7 @@ export const transformOrFail: {
|
|
|
4160
4214
|
* @category api interface
|
|
4161
4215
|
* @since 3.10.0
|
|
4162
4216
|
*/
|
|
4163
|
-
export interface transform<From extends Schema.
|
|
4217
|
+
export interface transform<From extends Schema.All, To extends Schema.All> extends transformOrFail<From, To> {
|
|
4164
4218
|
annotations(annotations: Annotations.Schema<Schema.Type<To>>): transform<From, To>
|
|
4165
4219
|
}
|
|
4166
4220
|
|
|
@@ -4236,7 +4290,11 @@ export const transform: {
|
|
|
4236
4290
|
* @category api interface
|
|
4237
4291
|
* @since 3.10.0
|
|
4238
4292
|
*/
|
|
4239
|
-
export interface transformLiteral<Type
|
|
4293
|
+
export interface transformLiteral<Type extends AST.LiteralValue, Encoded extends AST.LiteralValue>
|
|
4294
|
+
extends transform<Literal<[Encoded]>, Literal<[Type]>>
|
|
4295
|
+
{
|
|
4296
|
+
annotations(annotations: Annotations.Schema<Type>): transformLiteral<Type, Encoded>
|
|
4297
|
+
}
|
|
4240
4298
|
|
|
4241
4299
|
/**
|
|
4242
4300
|
* Creates a new `Schema` which transforms literal values.
|
|
@@ -4253,11 +4311,16 @@ export interface transformLiteral<Type, Encoded> extends Annotable<transformLite
|
|
|
4253
4311
|
* @category constructors
|
|
4254
4312
|
* @since 3.10.0
|
|
4255
4313
|
*/
|
|
4256
|
-
export
|
|
4314
|
+
export function transformLiteral<Encoded extends AST.LiteralValue, Type extends AST.LiteralValue>(
|
|
4257
4315
|
from: Encoded,
|
|
4258
4316
|
to: Type
|
|
4259
|
-
): transformLiteral<Type, Encoded>
|
|
4260
|
-
transform(Literal(from), Literal(to), {
|
|
4317
|
+
): transformLiteral<Type, Encoded> {
|
|
4318
|
+
return transform(Literal(from), Literal(to), {
|
|
4319
|
+
strict: true,
|
|
4320
|
+
decode: () => to,
|
|
4321
|
+
encode: () => from
|
|
4322
|
+
})
|
|
4323
|
+
}
|
|
4261
4324
|
|
|
4262
4325
|
/**
|
|
4263
4326
|
* Creates a new `Schema` which maps between corresponding literal values.
|
|
@@ -4573,17 +4636,19 @@ export const TrimmedSchemaId: unique symbol = Symbol.for("effect/SchemaId/Trimme
|
|
|
4573
4636
|
* @category string filters
|
|
4574
4637
|
* @since 3.10.0
|
|
4575
4638
|
*/
|
|
4576
|
-
export const trimmed =
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
}
|
|
4586
|
-
|
|
4639
|
+
export const trimmed = <S extends Schema.Any>(
|
|
4640
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
4641
|
+
) =>
|
|
4642
|
+
<A extends string>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
4643
|
+
self.pipe(
|
|
4644
|
+
filter((a) => a === a.trim(), {
|
|
4645
|
+
schemaId: TrimmedSchemaId,
|
|
4646
|
+
title: "trimmed",
|
|
4647
|
+
description: "a string with no leading or trailing whitespace",
|
|
4648
|
+
jsonSchema: { pattern: "^\\S[\\s\\S]*\\S$|^\\S$|^$" },
|
|
4649
|
+
...annotations
|
|
4650
|
+
})
|
|
4651
|
+
)
|
|
4587
4652
|
|
|
4588
4653
|
/**
|
|
4589
4654
|
* @category schema id
|
|
@@ -4601,23 +4666,21 @@ export type MaxLengthSchemaId = typeof MaxLengthSchemaId
|
|
|
4601
4666
|
* @category string filters
|
|
4602
4667
|
* @since 3.10.0
|
|
4603
4668
|
*/
|
|
4604
|
-
export const maxLength =
|
|
4605
|
-
maxLength: number,
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
}
|
|
4669
|
+
export const maxLength =
|
|
4670
|
+
<S extends Schema.Any>(maxLength: number, annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
4671
|
+
<A extends string>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
4672
|
+
self.pipe(
|
|
4673
|
+
filter(
|
|
4674
|
+
(a) => a.length <= maxLength,
|
|
4675
|
+
{
|
|
4676
|
+
schemaId: MaxLengthSchemaId,
|
|
4677
|
+
title: `maxLength(${maxLength})`,
|
|
4678
|
+
description: `a string at most ${maxLength} character(s) long`,
|
|
4679
|
+
jsonSchema: { maxLength },
|
|
4680
|
+
...annotations
|
|
4681
|
+
}
|
|
4682
|
+
)
|
|
4619
4683
|
)
|
|
4620
|
-
)
|
|
4621
4684
|
|
|
4622
4685
|
/**
|
|
4623
4686
|
* @category schema id
|
|
@@ -4635,11 +4698,11 @@ export type MinLengthSchemaId = typeof MinLengthSchemaId
|
|
|
4635
4698
|
* @category string filters
|
|
4636
4699
|
* @since 3.10.0
|
|
4637
4700
|
*/
|
|
4638
|
-
export const minLength = <
|
|
4701
|
+
export const minLength = <S extends Schema.Any>(
|
|
4639
4702
|
minLength: number,
|
|
4640
|
-
annotations?: Annotations.Filter<
|
|
4703
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
4641
4704
|
) =>
|
|
4642
|
-
<
|
|
4705
|
+
<A extends string>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
4643
4706
|
self.pipe(
|
|
4644
4707
|
filter(
|
|
4645
4708
|
(a) => a.length >= minLength,
|
|
@@ -4653,6 +4716,51 @@ export const minLength = <A extends string>(
|
|
|
4653
4716
|
)
|
|
4654
4717
|
)
|
|
4655
4718
|
|
|
4719
|
+
/**
|
|
4720
|
+
* @category schema id
|
|
4721
|
+
* @since 3.10.0
|
|
4722
|
+
*/
|
|
4723
|
+
export const LengthSchemaId: unique symbol = schemaId_.LengthSchemaId
|
|
4724
|
+
|
|
4725
|
+
/**
|
|
4726
|
+
* @category schema id
|
|
4727
|
+
* @since 3.10.0
|
|
4728
|
+
*/
|
|
4729
|
+
export type LengthSchemaId = typeof LengthSchemaId
|
|
4730
|
+
|
|
4731
|
+
/**
|
|
4732
|
+
* @category string filters
|
|
4733
|
+
* @since 3.10.0
|
|
4734
|
+
*/
|
|
4735
|
+
export const length = <S extends Schema.Any>(
|
|
4736
|
+
length: number | { readonly min: number; readonly max: number },
|
|
4737
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
4738
|
+
) =>
|
|
4739
|
+
<A extends string>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> => {
|
|
4740
|
+
const minLength = Predicate.isObject(length) ? Math.max(0, Math.floor(length.min)) : Math.max(0, Math.floor(length))
|
|
4741
|
+
const maxLength = Predicate.isObject(length) ? Math.max(minLength, Math.floor(length.max)) : minLength
|
|
4742
|
+
if (minLength !== maxLength) {
|
|
4743
|
+
return self.pipe(
|
|
4744
|
+
filter((a) => a.length >= minLength && a.length <= maxLength, {
|
|
4745
|
+
schemaId: LengthSchemaId,
|
|
4746
|
+
title: `length({ min: ${minLength}, max: ${maxLength})`,
|
|
4747
|
+
description: `a string at least ${minLength} character(s) and at most ${maxLength} character(s) long`,
|
|
4748
|
+
jsonSchema: { minLength, maxLength },
|
|
4749
|
+
...annotations
|
|
4750
|
+
})
|
|
4751
|
+
)
|
|
4752
|
+
}
|
|
4753
|
+
return self.pipe(
|
|
4754
|
+
filter((a) => a.length === minLength, {
|
|
4755
|
+
schemaId: LengthSchemaId,
|
|
4756
|
+
title: `length(${minLength})`,
|
|
4757
|
+
description: minLength === 1 ? `a single character` : `a string ${minLength} character(s) long`,
|
|
4758
|
+
jsonSchema: { minLength, maxLength: minLength },
|
|
4759
|
+
...annotations
|
|
4760
|
+
})
|
|
4761
|
+
)
|
|
4762
|
+
}
|
|
4763
|
+
|
|
4656
4764
|
/**
|
|
4657
4765
|
* @category schema id
|
|
4658
4766
|
* @since 3.10.0
|
|
@@ -4663,15 +4771,15 @@ export const PatternSchemaId: unique symbol = Symbol.for("effect/SchemaId/Patter
|
|
|
4663
4771
|
* @category string filters
|
|
4664
4772
|
* @since 3.10.0
|
|
4665
4773
|
*/
|
|
4666
|
-
export const pattern = <
|
|
4774
|
+
export const pattern = <S extends Schema.Any>(
|
|
4667
4775
|
regex: RegExp,
|
|
4668
|
-
annotations?: Annotations.Filter<
|
|
4776
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
4669
4777
|
) =>
|
|
4670
|
-
<
|
|
4778
|
+
<A extends string>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> => {
|
|
4671
4779
|
const source = regex.source
|
|
4672
4780
|
return self.pipe(
|
|
4673
4781
|
filter(
|
|
4674
|
-
(a)
|
|
4782
|
+
(a) => {
|
|
4675
4783
|
// The following line ensures that `lastIndex` is reset to `0` in case the user has specified the `g` flag
|
|
4676
4784
|
regex.lastIndex = 0
|
|
4677
4785
|
return regex.test(a)
|
|
@@ -4698,11 +4806,11 @@ export const StartsWithSchemaId: unique symbol = Symbol.for("effect/SchemaId/Sta
|
|
|
4698
4806
|
* @category string filters
|
|
4699
4807
|
* @since 3.10.0
|
|
4700
4808
|
*/
|
|
4701
|
-
export const startsWith = <
|
|
4809
|
+
export const startsWith = <S extends Schema.Any>(
|
|
4702
4810
|
startsWith: string,
|
|
4703
|
-
annotations?: Annotations.Filter<
|
|
4811
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
4704
4812
|
) =>
|
|
4705
|
-
<
|
|
4813
|
+
<A extends string>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> => {
|
|
4706
4814
|
const formatted = JSON.stringify(startsWith)
|
|
4707
4815
|
return self.pipe(
|
|
4708
4816
|
filter(
|
|
@@ -4729,11 +4837,11 @@ export const EndsWithSchemaId: unique symbol = Symbol.for("effect/SchemaId/EndsW
|
|
|
4729
4837
|
* @category string filters
|
|
4730
4838
|
* @since 3.10.0
|
|
4731
4839
|
*/
|
|
4732
|
-
export const endsWith = <
|
|
4840
|
+
export const endsWith = <S extends Schema.Any>(
|
|
4733
4841
|
endsWith: string,
|
|
4734
|
-
annotations?: Annotations.Filter<
|
|
4842
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
4735
4843
|
) =>
|
|
4736
|
-
<
|
|
4844
|
+
<A extends string>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> => {
|
|
4737
4845
|
const formatted = JSON.stringify(endsWith)
|
|
4738
4846
|
return self.pipe(
|
|
4739
4847
|
filter(
|
|
@@ -4760,11 +4868,11 @@ export const IncludesSchemaId: unique symbol = Symbol.for("effect/SchemaId/Inclu
|
|
|
4760
4868
|
* @category string filters
|
|
4761
4869
|
* @since 3.10.0
|
|
4762
4870
|
*/
|
|
4763
|
-
export const includes = <
|
|
4871
|
+
export const includes = <S extends Schema.Any>(
|
|
4764
4872
|
searchString: string,
|
|
4765
|
-
annotations?: Annotations.Filter<
|
|
4873
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
4766
4874
|
) =>
|
|
4767
|
-
<
|
|
4875
|
+
<A extends string>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> => {
|
|
4768
4876
|
const formatted = JSON.stringify(searchString)
|
|
4769
4877
|
return self.pipe(
|
|
4770
4878
|
filter(
|
|
@@ -4794,7 +4902,8 @@ export const LowercasedSchemaId: unique symbol = Symbol.for("effect/SchemaId/Low
|
|
|
4794
4902
|
* @since 3.10.0
|
|
4795
4903
|
*/
|
|
4796
4904
|
export const lowercased =
|
|
4797
|
-
<
|
|
4905
|
+
<S extends Schema.Any>(annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
4906
|
+
<A extends string>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
4798
4907
|
self.pipe(
|
|
4799
4908
|
filter((a) => a === a.toLowerCase(), {
|
|
4800
4909
|
schemaId: LowercasedSchemaId,
|
|
@@ -4817,22 +4926,23 @@ export class Lowercased extends String$.pipe(
|
|
|
4817
4926
|
* @category schema id
|
|
4818
4927
|
* @since 3.10.0
|
|
4819
4928
|
*/
|
|
4820
|
-
export const
|
|
4929
|
+
export const UppercasedSchemaId: unique symbol = Symbol.for("effect/SchemaId/Uppercased")
|
|
4821
4930
|
|
|
4822
4931
|
/**
|
|
4823
|
-
* Verifies that a string is
|
|
4932
|
+
* Verifies that a string is uppercased.
|
|
4824
4933
|
*
|
|
4825
4934
|
* @category string filters
|
|
4826
4935
|
* @since 3.10.0
|
|
4827
4936
|
*/
|
|
4828
|
-
export const
|
|
4829
|
-
<
|
|
4937
|
+
export const uppercased =
|
|
4938
|
+
<S extends Schema.Any>(annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
4939
|
+
<A extends string>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
4830
4940
|
self.pipe(
|
|
4831
|
-
filter((a) => a
|
|
4832
|
-
schemaId:
|
|
4833
|
-
title: "
|
|
4834
|
-
description: "
|
|
4835
|
-
jsonSchema: { pattern: "^[^a-z]
|
|
4941
|
+
filter((a) => a === a.toUpperCase(), {
|
|
4942
|
+
schemaId: UppercasedSchemaId,
|
|
4943
|
+
title: "uppercased",
|
|
4944
|
+
description: "an uppercase string",
|
|
4945
|
+
jsonSchema: { pattern: "^[^a-z]*$" },
|
|
4836
4946
|
...annotations
|
|
4837
4947
|
})
|
|
4838
4948
|
)
|
|
@@ -4841,30 +4951,31 @@ export const capitalized =
|
|
|
4841
4951
|
* @category string constructors
|
|
4842
4952
|
* @since 3.10.0
|
|
4843
4953
|
*/
|
|
4844
|
-
export class
|
|
4845
|
-
|
|
4954
|
+
export class Uppercased extends String$.pipe(
|
|
4955
|
+
uppercased({ identifier: "Uppercased" })
|
|
4846
4956
|
) {}
|
|
4847
4957
|
|
|
4848
4958
|
/**
|
|
4849
4959
|
* @category schema id
|
|
4850
4960
|
* @since 3.10.0
|
|
4851
4961
|
*/
|
|
4852
|
-
export const
|
|
4962
|
+
export const CapitalizedSchemaId: unique symbol = Symbol.for("effect/SchemaId/Capitalized")
|
|
4853
4963
|
|
|
4854
4964
|
/**
|
|
4855
|
-
* Verifies that a string is
|
|
4965
|
+
* Verifies that a string is capitalized.
|
|
4856
4966
|
*
|
|
4857
4967
|
* @category string filters
|
|
4858
4968
|
* @since 3.10.0
|
|
4859
4969
|
*/
|
|
4860
|
-
export const
|
|
4861
|
-
<
|
|
4970
|
+
export const capitalized =
|
|
4971
|
+
<S extends Schema.Any>(annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
4972
|
+
<A extends string>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
4862
4973
|
self.pipe(
|
|
4863
|
-
filter((a) => a[0]?.
|
|
4864
|
-
schemaId:
|
|
4865
|
-
title: "
|
|
4866
|
-
description: "a
|
|
4867
|
-
jsonSchema: { pattern: "^[^
|
|
4974
|
+
filter((a) => a[0]?.toUpperCase() === a[0], {
|
|
4975
|
+
schemaId: CapitalizedSchemaId,
|
|
4976
|
+
title: "capitalized",
|
|
4977
|
+
description: "a capitalized string",
|
|
4978
|
+
jsonSchema: { pattern: "^[^a-z]?.*$" },
|
|
4868
4979
|
...annotations
|
|
4869
4980
|
})
|
|
4870
4981
|
)
|
|
@@ -4873,30 +4984,31 @@ export const uncapitalized =
|
|
|
4873
4984
|
* @category string constructors
|
|
4874
4985
|
* @since 3.10.0
|
|
4875
4986
|
*/
|
|
4876
|
-
export class
|
|
4877
|
-
|
|
4987
|
+
export class Capitalized extends String$.pipe(
|
|
4988
|
+
capitalized({ identifier: "Capitalized" })
|
|
4878
4989
|
) {}
|
|
4879
4990
|
|
|
4880
4991
|
/**
|
|
4881
4992
|
* @category schema id
|
|
4882
4993
|
* @since 3.10.0
|
|
4883
4994
|
*/
|
|
4884
|
-
export const
|
|
4995
|
+
export const UncapitalizedSchemaId: unique symbol = Symbol.for("effect/SchemaId/Uncapitalized")
|
|
4885
4996
|
|
|
4886
4997
|
/**
|
|
4887
|
-
* Verifies that a string is
|
|
4998
|
+
* Verifies that a string is uncapitalized.
|
|
4888
4999
|
*
|
|
4889
5000
|
* @category string filters
|
|
4890
5001
|
* @since 3.10.0
|
|
4891
5002
|
*/
|
|
4892
|
-
export const
|
|
4893
|
-
<
|
|
5003
|
+
export const uncapitalized =
|
|
5004
|
+
<S extends Schema.Any>(annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
5005
|
+
<A extends string>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
4894
5006
|
self.pipe(
|
|
4895
|
-
filter((a) => a === a
|
|
4896
|
-
schemaId:
|
|
4897
|
-
title: "
|
|
4898
|
-
description: "
|
|
4899
|
-
jsonSchema: { pattern: "^[^
|
|
5007
|
+
filter((a) => a[0]?.toLowerCase() === a[0], {
|
|
5008
|
+
schemaId: UncapitalizedSchemaId,
|
|
5009
|
+
title: "uncapitalized",
|
|
5010
|
+
description: "a uncapitalized string",
|
|
5011
|
+
jsonSchema: { pattern: "^[^A-Z]?.*$" },
|
|
4900
5012
|
...annotations
|
|
4901
5013
|
})
|
|
4902
5014
|
)
|
|
@@ -4905,55 +5017,10 @@ export const uppercased =
|
|
|
4905
5017
|
* @category string constructors
|
|
4906
5018
|
* @since 3.10.0
|
|
4907
5019
|
*/
|
|
4908
|
-
export class
|
|
4909
|
-
|
|
5020
|
+
export class Uncapitalized extends String$.pipe(
|
|
5021
|
+
uncapitalized({ identifier: "Uncapitalized" })
|
|
4910
5022
|
) {}
|
|
4911
5023
|
|
|
4912
|
-
/**
|
|
4913
|
-
* @category schema id
|
|
4914
|
-
* @since 3.10.0
|
|
4915
|
-
*/
|
|
4916
|
-
export const LengthSchemaId: unique symbol = schemaId_.LengthSchemaId
|
|
4917
|
-
|
|
4918
|
-
/**
|
|
4919
|
-
* @category schema id
|
|
4920
|
-
* @since 3.10.0
|
|
4921
|
-
*/
|
|
4922
|
-
export type LengthSchemaId = typeof LengthSchemaId
|
|
4923
|
-
|
|
4924
|
-
/**
|
|
4925
|
-
* @category string filters
|
|
4926
|
-
* @since 3.10.0
|
|
4927
|
-
*/
|
|
4928
|
-
export const length = <A extends string>(
|
|
4929
|
-
length: number | { readonly min: number; readonly max: number },
|
|
4930
|
-
annotations?: Annotations.Filter<A>
|
|
4931
|
-
) =>
|
|
4932
|
-
<I, R>(self: Schema<A, I, R>): filter<Schema<A, I, R>> => {
|
|
4933
|
-
const minLength = Predicate.isObject(length) ? Math.max(0, Math.floor(length.min)) : Math.max(0, Math.floor(length))
|
|
4934
|
-
const maxLength = Predicate.isObject(length) ? Math.max(minLength, Math.floor(length.max)) : minLength
|
|
4935
|
-
if (minLength !== maxLength) {
|
|
4936
|
-
return self.pipe(
|
|
4937
|
-
filter((a) => a.length >= minLength && a.length <= maxLength, {
|
|
4938
|
-
schemaId: LengthSchemaId,
|
|
4939
|
-
title: `length({ min: ${minLength}, max: ${maxLength})`,
|
|
4940
|
-
description: `a string at least ${minLength} character(s) and at most ${maxLength} character(s) long`,
|
|
4941
|
-
jsonSchema: { minLength, maxLength },
|
|
4942
|
-
...annotations
|
|
4943
|
-
})
|
|
4944
|
-
)
|
|
4945
|
-
}
|
|
4946
|
-
return self.pipe(
|
|
4947
|
-
filter((a) => a.length === minLength, {
|
|
4948
|
-
schemaId: LengthSchemaId,
|
|
4949
|
-
title: `length(${minLength})`,
|
|
4950
|
-
description: minLength === 1 ? `a single character` : `a string ${minLength} character(s) long`,
|
|
4951
|
-
jsonSchema: { minLength, maxLength: minLength },
|
|
4952
|
-
...annotations
|
|
4953
|
-
})
|
|
4954
|
-
)
|
|
4955
|
-
}
|
|
4956
|
-
|
|
4957
5024
|
/**
|
|
4958
5025
|
* A schema representing a single character.
|
|
4959
5026
|
*
|
|
@@ -4966,9 +5033,9 @@ export class Char extends String$.pipe(length(1, { identifier: "Char" })) {}
|
|
|
4966
5033
|
* @category string filters
|
|
4967
5034
|
* @since 3.10.0
|
|
4968
5035
|
*/
|
|
4969
|
-
export const nonEmptyString = <
|
|
4970
|
-
annotations?: Annotations.Filter<
|
|
4971
|
-
): <
|
|
5036
|
+
export const nonEmptyString = <S extends Schema.Any>(
|
|
5037
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
5038
|
+
): <A extends string>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>) => filter<S> =>
|
|
4972
5039
|
minLength(1, {
|
|
4973
5040
|
title: "nonEmptyString",
|
|
4974
5041
|
description: "a non empty string",
|
|
@@ -4984,7 +5051,11 @@ export const nonEmptyString = <A extends string>(
|
|
|
4984
5051
|
export class Lowercase extends transform(
|
|
4985
5052
|
String$.annotations({ description: "a string that will be converted to lowercase" }),
|
|
4986
5053
|
Lowercased,
|
|
4987
|
-
{
|
|
5054
|
+
{
|
|
5055
|
+
strict: true,
|
|
5056
|
+
decode: (i) => i.toLowerCase(),
|
|
5057
|
+
encode: identity
|
|
5058
|
+
}
|
|
4988
5059
|
).annotations({ identifier: "Lowercase" }) {}
|
|
4989
5060
|
|
|
4990
5061
|
/**
|
|
@@ -4996,7 +5067,11 @@ export class Lowercase extends transform(
|
|
|
4996
5067
|
export class Uppercase extends transform(
|
|
4997
5068
|
String$.annotations({ description: "a string that will be converted to uppercase" }),
|
|
4998
5069
|
Uppercased,
|
|
4999
|
-
{
|
|
5070
|
+
{
|
|
5071
|
+
strict: true,
|
|
5072
|
+
decode: (i) => i.toUpperCase(),
|
|
5073
|
+
encode: identity
|
|
5074
|
+
}
|
|
5000
5075
|
).annotations({ identifier: "Uppercase" }) {}
|
|
5001
5076
|
|
|
5002
5077
|
/**
|
|
@@ -5008,7 +5083,11 @@ export class Uppercase extends transform(
|
|
|
5008
5083
|
export class Capitalize extends transform(
|
|
5009
5084
|
String$.annotations({ description: "a string that will be converted to a capitalized format" }),
|
|
5010
5085
|
Capitalized,
|
|
5011
|
-
{
|
|
5086
|
+
{
|
|
5087
|
+
strict: true,
|
|
5088
|
+
decode: (i) => string_.capitalize(i),
|
|
5089
|
+
encode: identity
|
|
5090
|
+
}
|
|
5012
5091
|
).annotations({ identifier: "Capitalize" }) {}
|
|
5013
5092
|
|
|
5014
5093
|
/**
|
|
@@ -5020,7 +5099,11 @@ export class Capitalize extends transform(
|
|
|
5020
5099
|
export class Uncapitalize extends transform(
|
|
5021
5100
|
String$.annotations({ description: "a string that will be converted to an uncapitalized format" }),
|
|
5022
5101
|
Uncapitalized,
|
|
5023
|
-
{
|
|
5102
|
+
{
|
|
5103
|
+
strict: true,
|
|
5104
|
+
decode: (i) => string_.uncapitalize(i),
|
|
5105
|
+
encode: identity
|
|
5106
|
+
}
|
|
5024
5107
|
).annotations({ identifier: "Uncapitalize" }) {}
|
|
5025
5108
|
|
|
5026
5109
|
/**
|
|
@@ -5060,7 +5143,11 @@ export class NonEmptyTrimmedString extends Trimmed.pipe(
|
|
|
5060
5143
|
export class Trim extends transform(
|
|
5061
5144
|
String$.annotations({ description: "a string that will be trimmed" }),
|
|
5062
5145
|
Trimmed,
|
|
5063
|
-
{
|
|
5146
|
+
{
|
|
5147
|
+
strict: true,
|
|
5148
|
+
decode: (i) => i.trim(),
|
|
5149
|
+
encode: identity
|
|
5150
|
+
}
|
|
5064
5151
|
).annotations({ identifier: "Trim" }) {}
|
|
5065
5152
|
|
|
5066
5153
|
/**
|
|
@@ -5069,11 +5156,15 @@ export class Trim extends transform(
|
|
|
5069
5156
|
* @category string transformations
|
|
5070
5157
|
* @since 3.10.0
|
|
5071
5158
|
*/
|
|
5072
|
-
export const split = (separator: string): transform<
|
|
5159
|
+
export const split = (separator: string): transform<SchemaClass<string>, Array$<typeof String$>> =>
|
|
5073
5160
|
transform(
|
|
5074
5161
|
String$.annotations({ description: "a string that will be split" }),
|
|
5075
5162
|
Array$(String$),
|
|
5076
|
-
{
|
|
5163
|
+
{
|
|
5164
|
+
strict: true,
|
|
5165
|
+
decode: (i) => i.split(separator),
|
|
5166
|
+
encode: (a) => a.join(separator)
|
|
5167
|
+
}
|
|
5077
5168
|
)
|
|
5078
5169
|
|
|
5079
5170
|
/**
|
|
@@ -5087,23 +5178,21 @@ export type ParseJsonOptions = {
|
|
|
5087
5178
|
|
|
5088
5179
|
const getErrorMessage = (e: unknown): string => e instanceof Error ? e.message : String(e)
|
|
5089
5180
|
|
|
5090
|
-
const getParseJsonTransformation = (options?: ParseJsonOptions) =>
|
|
5181
|
+
const getParseJsonTransformation = (options?: ParseJsonOptions): SchemaClass<unknown, string> =>
|
|
5091
5182
|
transformOrFail(
|
|
5092
|
-
String$.annotations({
|
|
5093
|
-
[AST.DescriptionAnnotationId]: "a string to be decoded into JSON"
|
|
5094
|
-
}),
|
|
5183
|
+
String$.annotations({ description: "a string to be decoded into JSON" }),
|
|
5095
5184
|
Unknown,
|
|
5096
5185
|
{
|
|
5097
5186
|
strict: true,
|
|
5098
|
-
decode: (
|
|
5187
|
+
decode: (i, _, ast) =>
|
|
5099
5188
|
ParseResult.try({
|
|
5100
|
-
try: () => JSON.parse(
|
|
5101
|
-
catch: (e) => new ParseResult.Type(ast,
|
|
5189
|
+
try: () => JSON.parse(i, options?.reviver),
|
|
5190
|
+
catch: (e) => new ParseResult.Type(ast, i, getErrorMessage(e))
|
|
5102
5191
|
}),
|
|
5103
|
-
encode: (
|
|
5192
|
+
encode: (a, _, ast) =>
|
|
5104
5193
|
ParseResult.try({
|
|
5105
|
-
try: () => JSON.stringify(
|
|
5106
|
-
catch: (e) => new ParseResult.Type(ast,
|
|
5194
|
+
try: () => JSON.stringify(a, options?.replacer, options?.space),
|
|
5195
|
+
catch: (e) => new ParseResult.Type(ast, a, getErrorMessage(e))
|
|
5107
5196
|
})
|
|
5108
5197
|
}
|
|
5109
5198
|
).annotations({
|
|
@@ -5150,7 +5239,7 @@ export const parseJson: {
|
|
|
5150
5239
|
* @category string transformations
|
|
5151
5240
|
* @since 3.10.0
|
|
5152
5241
|
*/
|
|
5153
|
-
<
|
|
5242
|
+
<S extends Schema.Any>(schema: S, options?: ParseJsonOptions): transform<SchemaClass<unknown, string>, S>
|
|
5154
5243
|
/**
|
|
5155
5244
|
* The `ParseJson` combinator provides a method to convert JSON strings into the `unknown` type using the underlying
|
|
5156
5245
|
* functionality of `JSON.parse`. It also utilizes `JSON.stringify` for encoding.
|
|
@@ -5257,17 +5346,17 @@ class URL$ extends transformOrFail(
|
|
|
5257
5346
|
URLFromSelf,
|
|
5258
5347
|
{
|
|
5259
5348
|
strict: true,
|
|
5260
|
-
decode: (
|
|
5349
|
+
decode: (i, _, ast) =>
|
|
5261
5350
|
ParseResult.try({
|
|
5262
|
-
try: () => new URL(
|
|
5351
|
+
try: () => new URL(i),
|
|
5263
5352
|
catch: (e) =>
|
|
5264
5353
|
new ParseResult.Type(
|
|
5265
5354
|
ast,
|
|
5266
|
-
|
|
5267
|
-
`Unable to decode ${JSON.stringify(
|
|
5355
|
+
i,
|
|
5356
|
+
`Unable to decode ${JSON.stringify(i)} into a URL. ${getErrorMessage(e)}`
|
|
5268
5357
|
)
|
|
5269
5358
|
}),
|
|
5270
|
-
encode: (
|
|
5359
|
+
encode: (a) => ParseResult.succeed(a.toString())
|
|
5271
5360
|
}
|
|
5272
5361
|
).annotations({
|
|
5273
5362
|
identifier: "URL",
|
|
@@ -5304,7 +5393,8 @@ export type FiniteSchemaId = typeof FiniteSchemaId
|
|
|
5304
5393
|
* @since 3.10.0
|
|
5305
5394
|
*/
|
|
5306
5395
|
export const finite =
|
|
5307
|
-
<
|
|
5396
|
+
<S extends Schema.Any>(annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
5397
|
+
<A extends number>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
5308
5398
|
self.pipe(
|
|
5309
5399
|
filter(Number.isFinite, {
|
|
5310
5400
|
schemaId: FiniteSchemaId,
|
|
@@ -5333,11 +5423,11 @@ export type GreaterThanSchemaId = typeof GreaterThanSchemaId
|
|
|
5333
5423
|
* @category number filters
|
|
5334
5424
|
* @since 3.10.0
|
|
5335
5425
|
*/
|
|
5336
|
-
export const greaterThan = <
|
|
5426
|
+
export const greaterThan = <S extends Schema.Any>(
|
|
5337
5427
|
exclusiveMinimum: number,
|
|
5338
|
-
annotations?: Annotations.Filter<
|
|
5428
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
5339
5429
|
) =>
|
|
5340
|
-
<
|
|
5430
|
+
<A extends number>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
5341
5431
|
self.pipe(
|
|
5342
5432
|
filter((a) => a > exclusiveMinimum, {
|
|
5343
5433
|
schemaId: GreaterThanSchemaId,
|
|
@@ -5366,11 +5456,11 @@ export type GreaterThanOrEqualToSchemaId = typeof GreaterThanOrEqualToSchemaId
|
|
|
5366
5456
|
* @category number filters
|
|
5367
5457
|
* @since 3.10.0
|
|
5368
5458
|
*/
|
|
5369
|
-
export const greaterThanOrEqualTo = <
|
|
5459
|
+
export const greaterThanOrEqualTo = <S extends Schema.Any>(
|
|
5370
5460
|
minimum: number,
|
|
5371
|
-
annotations?: Annotations.Filter<
|
|
5461
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
5372
5462
|
) =>
|
|
5373
|
-
<
|
|
5463
|
+
<A extends number>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
5374
5464
|
self.pipe(
|
|
5375
5465
|
filter((a) => a >= minimum, {
|
|
5376
5466
|
schemaId: GreaterThanOrEqualToSchemaId,
|
|
@@ -5391,11 +5481,11 @@ export const MultipleOfSchemaId: unique symbol = Symbol.for("effect/SchemaId/Mul
|
|
|
5391
5481
|
* @category number filters
|
|
5392
5482
|
* @since 3.10.0
|
|
5393
5483
|
*/
|
|
5394
|
-
export const multipleOf = <
|
|
5484
|
+
export const multipleOf = <S extends Schema.Any>(
|
|
5395
5485
|
divisor: number,
|
|
5396
|
-
annotations?: Annotations.Filter<
|
|
5486
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
5397
5487
|
) =>
|
|
5398
|
-
<
|
|
5488
|
+
<A extends number>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> => {
|
|
5399
5489
|
const positiveDivisor = Math.abs(divisor) // spec requires positive divisor
|
|
5400
5490
|
return self.pipe(
|
|
5401
5491
|
filter((a) => number_.remainder(a, divisor) === 0, {
|
|
@@ -5427,7 +5517,8 @@ export type IntSchemaId = typeof IntSchemaId
|
|
|
5427
5517
|
* @since 3.10.0
|
|
5428
5518
|
*/
|
|
5429
5519
|
export const int =
|
|
5430
|
-
<
|
|
5520
|
+
<S extends Schema.Any>(annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
5521
|
+
<A extends number>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
5431
5522
|
self.pipe(
|
|
5432
5523
|
filter((a) => Number.isSafeInteger(a), {
|
|
5433
5524
|
schemaId: IntSchemaId,
|
|
@@ -5457,8 +5548,8 @@ export type LessThanSchemaId = typeof LessThanSchemaId
|
|
|
5457
5548
|
* @since 3.10.0
|
|
5458
5549
|
*/
|
|
5459
5550
|
export const lessThan =
|
|
5460
|
-
<
|
|
5461
|
-
<
|
|
5551
|
+
<S extends Schema.Any>(exclusiveMaximum: number, annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
5552
|
+
<A extends number>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
5462
5553
|
self.pipe(
|
|
5463
5554
|
filter((a) => a < exclusiveMaximum, {
|
|
5464
5555
|
schemaId: LessThanSchemaId,
|
|
@@ -5487,11 +5578,11 @@ export type LessThanOrEqualToSchemaId = typeof LessThanOrEqualToSchemaId
|
|
|
5487
5578
|
* @category number filters
|
|
5488
5579
|
* @since 3.10.0
|
|
5489
5580
|
*/
|
|
5490
|
-
export const lessThanOrEqualTo = <
|
|
5581
|
+
export const lessThanOrEqualTo = <S extends Schema.Any>(
|
|
5491
5582
|
maximum: number,
|
|
5492
|
-
annotations?: Annotations.Filter<
|
|
5583
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
5493
5584
|
) =>
|
|
5494
|
-
<
|
|
5585
|
+
<A extends number>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
5495
5586
|
self.pipe(
|
|
5496
5587
|
filter((a) => a <= maximum, {
|
|
5497
5588
|
schemaId: LessThanOrEqualToSchemaId,
|
|
@@ -5520,12 +5611,12 @@ export type BetweenSchemaId = typeof BetweenSchemaId
|
|
|
5520
5611
|
* @category number filters
|
|
5521
5612
|
* @since 3.10.0
|
|
5522
5613
|
*/
|
|
5523
|
-
export const between = <
|
|
5614
|
+
export const between = <S extends Schema.Any>(
|
|
5524
5615
|
minimum: number,
|
|
5525
5616
|
maximum: number,
|
|
5526
|
-
annotations?: Annotations.Filter<
|
|
5617
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
5527
5618
|
) =>
|
|
5528
|
-
<
|
|
5619
|
+
<A extends number>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
5529
5620
|
self.pipe(
|
|
5530
5621
|
filter((a) => a >= minimum && a <= maximum, {
|
|
5531
5622
|
schemaId: BetweenSchemaId,
|
|
@@ -5553,7 +5644,8 @@ export type NonNaNSchemaId = typeof NonNaNSchemaId
|
|
|
5553
5644
|
* @since 3.10.0
|
|
5554
5645
|
*/
|
|
5555
5646
|
export const nonNaN =
|
|
5556
|
-
<
|
|
5647
|
+
<S extends Schema.Any>(annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
5648
|
+
<A extends number>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
5557
5649
|
self.pipe(
|
|
5558
5650
|
filter((a) => !Number.isNaN(a), {
|
|
5559
5651
|
schemaId: NonNaNSchemaId,
|
|
@@ -5567,34 +5659,36 @@ export const nonNaN =
|
|
|
5567
5659
|
* @category number filters
|
|
5568
5660
|
* @since 3.10.0
|
|
5569
5661
|
*/
|
|
5570
|
-
export const positive = <
|
|
5571
|
-
annotations?: Annotations.Filter<
|
|
5572
|
-
): <
|
|
5662
|
+
export const positive = <S extends Schema.Any>(
|
|
5663
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
5664
|
+
): <A extends number>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>) => filter<S> =>
|
|
5665
|
+
greaterThan(0, { title: "positive", ...annotations })
|
|
5573
5666
|
|
|
5574
5667
|
/**
|
|
5575
5668
|
* @category number filters
|
|
5576
5669
|
* @since 3.10.0
|
|
5577
5670
|
*/
|
|
5578
|
-
export const negative = <
|
|
5579
|
-
annotations?: Annotations.Filter<
|
|
5580
|
-
): <
|
|
5671
|
+
export const negative = <S extends Schema.Any>(
|
|
5672
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
5673
|
+
): <A extends number>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>) => filter<S> =>
|
|
5674
|
+
lessThan(0, { title: "negative", ...annotations })
|
|
5581
5675
|
|
|
5582
5676
|
/**
|
|
5583
5677
|
* @category number filters
|
|
5584
5678
|
* @since 3.10.0
|
|
5585
5679
|
*/
|
|
5586
|
-
export const nonPositive = <
|
|
5587
|
-
annotations?: Annotations.Filter<
|
|
5588
|
-
): <
|
|
5680
|
+
export const nonPositive = <S extends Schema.Any>(
|
|
5681
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
5682
|
+
): <A extends number>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>) => filter<S> =>
|
|
5589
5683
|
lessThanOrEqualTo(0, { title: "nonPositive", ...annotations })
|
|
5590
5684
|
|
|
5591
5685
|
/**
|
|
5592
5686
|
* @category number filters
|
|
5593
5687
|
* @since 3.10.0
|
|
5594
5688
|
*/
|
|
5595
|
-
export const nonNegative = <
|
|
5596
|
-
annotations?: Annotations.Filter<
|
|
5597
|
-
): <
|
|
5689
|
+
export const nonNegative = <S extends Schema.Any>(
|
|
5690
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
5691
|
+
): <A extends number>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>) => filter<S> =>
|
|
5598
5692
|
greaterThanOrEqualTo(0, { title: "nonNegative", ...annotations })
|
|
5599
5693
|
|
|
5600
5694
|
/**
|
|
@@ -5603,40 +5697,51 @@ export const nonNegative = <A extends number>(
|
|
|
5603
5697
|
* @category number transformations
|
|
5604
5698
|
* @since 3.10.0
|
|
5605
5699
|
*/
|
|
5606
|
-
export const clamp =
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
5613
|
-
|
|
5700
|
+
export const clamp = (minimum: number, maximum: number) =>
|
|
5701
|
+
<S extends Schema.Any, A extends number>(
|
|
5702
|
+
self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>
|
|
5703
|
+
): transform<S, filter<SchemaClass<A>>> => {
|
|
5704
|
+
return transform(
|
|
5705
|
+
self,
|
|
5706
|
+
typeSchema(self).pipe(between(minimum, maximum)),
|
|
5707
|
+
{
|
|
5708
|
+
strict: false,
|
|
5709
|
+
decode: (i) => number_.clamp(i, { minimum, maximum }),
|
|
5710
|
+
encode: identity
|
|
5711
|
+
}
|
|
5712
|
+
)
|
|
5713
|
+
}
|
|
5614
5714
|
|
|
5615
5715
|
/**
|
|
5616
|
-
* Transforms a `string` into a `number` by parsing the string using the `parse`
|
|
5716
|
+
* Transforms a `string` into a `number` by parsing the string using the `parse`
|
|
5717
|
+
* function of the `effect/Number` module.
|
|
5617
5718
|
*
|
|
5618
|
-
* It returns an error if the value can't be converted (for example when
|
|
5719
|
+
* It returns an error if the value can't be converted (for example when
|
|
5720
|
+
* non-numeric characters are provided).
|
|
5619
5721
|
*
|
|
5620
|
-
* The following special string values are supported: "NaN", "Infinity",
|
|
5722
|
+
* The following special string values are supported: "NaN", "Infinity",
|
|
5723
|
+
* "-Infinity".
|
|
5621
5724
|
*
|
|
5622
5725
|
* @category number transformations
|
|
5623
5726
|
* @since 3.10.0
|
|
5624
5727
|
*/
|
|
5625
|
-
export
|
|
5626
|
-
self: Schema<A,
|
|
5627
|
-
): transformOrFail<
|
|
5628
|
-
transformOrFail(
|
|
5728
|
+
export function parseNumber<S extends Schema.Any, A extends string>(
|
|
5729
|
+
self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>
|
|
5730
|
+
): transformOrFail<S, typeof Number$> {
|
|
5731
|
+
return transformOrFail(
|
|
5629
5732
|
self,
|
|
5630
5733
|
Number$,
|
|
5631
5734
|
{
|
|
5632
5735
|
strict: false,
|
|
5633
|
-
decode: (
|
|
5634
|
-
ParseResult.fromOption(
|
|
5635
|
-
|
|
5636
|
-
|
|
5637
|
-
|
|
5736
|
+
decode: (i, _, ast) =>
|
|
5737
|
+
ParseResult.fromOption(
|
|
5738
|
+
number_.parse(i),
|
|
5739
|
+
() => new ParseResult.Type(ast, i, `Unable to decode ${JSON.stringify(i)} into a number`)
|
|
5740
|
+
),
|
|
5741
|
+
encode: (a) => ParseResult.succeed(String(a))
|
|
5638
5742
|
}
|
|
5639
5743
|
)
|
|
5744
|
+
}
|
|
5640
5745
|
|
|
5641
5746
|
/**
|
|
5642
5747
|
* This schema transforms a `string` into a `number` by parsing the string using the `parse` function of the `effect/Number` module.
|
|
@@ -5747,11 +5852,11 @@ export class JsonNumber extends Number$.pipe(
|
|
|
5747
5852
|
*/
|
|
5748
5853
|
export class Not extends transform(Boolean$.annotations({ description: "a boolean that will be negated" }), Boolean$, {
|
|
5749
5854
|
strict: true,
|
|
5750
|
-
decode: boolean_.not,
|
|
5751
|
-
encode: boolean_.not
|
|
5855
|
+
decode: (i) => boolean_.not(i),
|
|
5856
|
+
encode: (a) => boolean_.not(a)
|
|
5752
5857
|
}) {}
|
|
5753
5858
|
|
|
5754
|
-
const encodeSymbol = (sym: symbol,
|
|
5859
|
+
const encodeSymbol = (sym: symbol, ast: AST.AST) => {
|
|
5755
5860
|
const key = Symbol.keyFor(sym)
|
|
5756
5861
|
return key === undefined
|
|
5757
5862
|
? ParseResult.fail(
|
|
@@ -5768,8 +5873,8 @@ class Symbol$ extends transformOrFail(
|
|
|
5768
5873
|
SymbolFromSelf,
|
|
5769
5874
|
{
|
|
5770
5875
|
strict: false,
|
|
5771
|
-
decode: decodeSymbol,
|
|
5772
|
-
encode: encodeSymbol
|
|
5876
|
+
decode: (i) => decodeSymbol(i),
|
|
5877
|
+
encode: (a, _, ast) => encodeSymbol(a, ast)
|
|
5773
5878
|
}
|
|
5774
5879
|
).annotations({ identifier: "Symbol" }) {}
|
|
5775
5880
|
|
|
@@ -5783,20 +5888,6 @@ export {
|
|
|
5783
5888
|
Symbol$ as Symbol
|
|
5784
5889
|
}
|
|
5785
5890
|
|
|
5786
|
-
const SymbolStruct = TaggedStruct("symbol", {
|
|
5787
|
-
key: String$
|
|
5788
|
-
}).annotations({ description: "an object to be decoded into a globally shared symbol" })
|
|
5789
|
-
|
|
5790
|
-
const SymbolFromStruct = transformOrFail(
|
|
5791
|
-
SymbolStruct,
|
|
5792
|
-
SymbolFromSelf,
|
|
5793
|
-
{
|
|
5794
|
-
strict: true,
|
|
5795
|
-
decode: ({ key }) => decodeSymbol(key),
|
|
5796
|
-
encode: (sym, _, ast) => ParseResult.map(encodeSymbol(sym, _, ast), (key) => SymbolStruct.make({ key }))
|
|
5797
|
-
}
|
|
5798
|
-
)
|
|
5799
|
-
|
|
5800
5891
|
/**
|
|
5801
5892
|
* @category schema id
|
|
5802
5893
|
* @since 3.10.0
|
|
@@ -5813,11 +5904,11 @@ export type GreaterThanBigIntSchemaId = typeof GreaterThanBigIntSchemaId
|
|
|
5813
5904
|
* @category bigint filters
|
|
5814
5905
|
* @since 3.10.0
|
|
5815
5906
|
*/
|
|
5816
|
-
export const greaterThanBigInt = <
|
|
5907
|
+
export const greaterThanBigInt = <S extends Schema.Any>(
|
|
5817
5908
|
min: bigint,
|
|
5818
|
-
annotations?: Annotations.Filter<
|
|
5909
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
5819
5910
|
) =>
|
|
5820
|
-
<
|
|
5911
|
+
<A extends bigint>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
5821
5912
|
self.pipe(
|
|
5822
5913
|
filter((a) => a > min, {
|
|
5823
5914
|
schemaId: GreaterThanBigIntSchemaId,
|
|
@@ -5844,11 +5935,11 @@ export type GreaterThanOrEqualToBigIntSchemaId = typeof GreaterThanOrEqualToBigI
|
|
|
5844
5935
|
* @category bigint filters
|
|
5845
5936
|
* @since 3.10.0
|
|
5846
5937
|
*/
|
|
5847
|
-
export const greaterThanOrEqualToBigInt = <
|
|
5938
|
+
export const greaterThanOrEqualToBigInt = <S extends Schema.Any>(
|
|
5848
5939
|
min: bigint,
|
|
5849
|
-
annotations?: Annotations.Filter<
|
|
5940
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
5850
5941
|
) =>
|
|
5851
|
-
<
|
|
5942
|
+
<A extends bigint>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
5852
5943
|
self.pipe(
|
|
5853
5944
|
filter((a) => a >= min, {
|
|
5854
5945
|
schemaId: GreaterThanOrEqualToBigIntSchemaId,
|
|
@@ -5877,11 +5968,11 @@ export type LessThanBigIntSchemaId = typeof LessThanBigIntSchemaId
|
|
|
5877
5968
|
* @category bigint filters
|
|
5878
5969
|
* @since 3.10.0
|
|
5879
5970
|
*/
|
|
5880
|
-
export const lessThanBigInt = <
|
|
5971
|
+
export const lessThanBigInt = <S extends Schema.Any>(
|
|
5881
5972
|
max: bigint,
|
|
5882
|
-
annotations?: Annotations.Filter<
|
|
5973
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
5883
5974
|
) =>
|
|
5884
|
-
<
|
|
5975
|
+
<A extends bigint>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
5885
5976
|
self.pipe(
|
|
5886
5977
|
filter((a) => a < max, {
|
|
5887
5978
|
schemaId: LessThanBigIntSchemaId,
|
|
@@ -5908,11 +5999,11 @@ export type LessThanOrEqualToBigIntSchemaId = typeof LessThanOrEqualToBigIntSche
|
|
|
5908
5999
|
* @category bigint filters
|
|
5909
6000
|
* @since 3.10.0
|
|
5910
6001
|
*/
|
|
5911
|
-
export const lessThanOrEqualToBigInt = <
|
|
6002
|
+
export const lessThanOrEqualToBigInt = <S extends Schema.Any>(
|
|
5912
6003
|
max: bigint,
|
|
5913
|
-
annotations?: Annotations.Filter<
|
|
6004
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
5914
6005
|
) =>
|
|
5915
|
-
<
|
|
6006
|
+
<A extends bigint>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
5916
6007
|
self.pipe(
|
|
5917
6008
|
filter((a) => a <= max, {
|
|
5918
6009
|
schemaId: LessThanOrEqualToBigIntSchemaId,
|
|
@@ -5939,12 +6030,12 @@ export type BetweenBigIntSchemaId = typeof BetweenBigIntSchemaId
|
|
|
5939
6030
|
* @category bigint filters
|
|
5940
6031
|
* @since 3.10.0
|
|
5941
6032
|
*/
|
|
5942
|
-
export const betweenBigInt = <
|
|
6033
|
+
export const betweenBigInt = <S extends Schema.Any>(
|
|
5943
6034
|
min: bigint,
|
|
5944
6035
|
max: bigint,
|
|
5945
|
-
annotations?: Annotations.Filter<
|
|
6036
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
5946
6037
|
) =>
|
|
5947
|
-
<
|
|
6038
|
+
<A extends bigint>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
5948
6039
|
self.pipe(
|
|
5949
6040
|
filter((a) => a >= min && a <= max, {
|
|
5950
6041
|
schemaId: BetweenBigIntSchemaId,
|
|
@@ -5959,36 +6050,36 @@ export const betweenBigInt = <A extends bigint>(
|
|
|
5959
6050
|
* @category bigint filters
|
|
5960
6051
|
* @since 3.10.0
|
|
5961
6052
|
*/
|
|
5962
|
-
export const positiveBigInt = <
|
|
5963
|
-
annotations?: Annotations.Filter<
|
|
5964
|
-
): <
|
|
6053
|
+
export const positiveBigInt = <S extends Schema.Any>(
|
|
6054
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
6055
|
+
): <A extends bigint>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>) => filter<S> =>
|
|
5965
6056
|
greaterThanBigInt(0n, { title: "positiveBigInt", ...annotations })
|
|
5966
6057
|
|
|
5967
6058
|
/**
|
|
5968
6059
|
* @category bigint filters
|
|
5969
6060
|
* @since 3.10.0
|
|
5970
6061
|
*/
|
|
5971
|
-
export const negativeBigInt = <
|
|
5972
|
-
annotations?: Annotations.Filter<
|
|
5973
|
-
): <
|
|
6062
|
+
export const negativeBigInt = <S extends Schema.Any>(
|
|
6063
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
6064
|
+
): <A extends bigint>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>) => filter<S> =>
|
|
5974
6065
|
lessThanBigInt(0n, { title: "negativeBigInt", ...annotations })
|
|
5975
6066
|
|
|
5976
6067
|
/**
|
|
5977
6068
|
* @category bigint filters
|
|
5978
6069
|
* @since 3.10.0
|
|
5979
6070
|
*/
|
|
5980
|
-
export const nonNegativeBigInt = <
|
|
5981
|
-
annotations?: Annotations.Filter<
|
|
5982
|
-
): <
|
|
6071
|
+
export const nonNegativeBigInt = <S extends Schema.Any>(
|
|
6072
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
6073
|
+
): <A extends bigint>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>) => filter<S> =>
|
|
5983
6074
|
greaterThanOrEqualToBigInt(0n, { title: "nonNegativeBigInt", ...annotations })
|
|
5984
6075
|
|
|
5985
6076
|
/**
|
|
5986
6077
|
* @category bigint filters
|
|
5987
6078
|
* @since 3.10.0
|
|
5988
6079
|
*/
|
|
5989
|
-
export const nonPositiveBigInt = <
|
|
5990
|
-
annotations?: Annotations.Filter<
|
|
5991
|
-
): <
|
|
6080
|
+
export const nonPositiveBigInt = <S extends Schema.Any>(
|
|
6081
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
6082
|
+
): <A extends bigint>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>) => filter<S> =>
|
|
5992
6083
|
lessThanOrEqualToBigInt(0n, { title: "nonPositiveBigInt", ...annotations })
|
|
5993
6084
|
|
|
5994
6085
|
/**
|
|
@@ -5997,14 +6088,19 @@ export const nonPositiveBigInt = <A extends bigint>(
|
|
|
5997
6088
|
* @category bigint transformations
|
|
5998
6089
|
* @since 3.10.0
|
|
5999
6090
|
*/
|
|
6000
|
-
export const clampBigInt =
|
|
6001
|
-
|
|
6002
|
-
|
|
6003
|
-
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
|
|
6091
|
+
export const clampBigInt = (minimum: bigint, maximum: bigint) =>
|
|
6092
|
+
<S extends Schema.Any, A extends bigint>(
|
|
6093
|
+
self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>
|
|
6094
|
+
): transform<S, filter<SchemaClass<A>>> =>
|
|
6095
|
+
transform(
|
|
6096
|
+
self,
|
|
6097
|
+
self.pipe(typeSchema, betweenBigInt(minimum, maximum)),
|
|
6098
|
+
{
|
|
6099
|
+
strict: false,
|
|
6100
|
+
decode: (i) => bigInt_.clamp(i, { minimum, maximum }),
|
|
6101
|
+
encode: identity
|
|
6102
|
+
}
|
|
6103
|
+
)
|
|
6008
6104
|
|
|
6009
6105
|
/** @ignore */
|
|
6010
6106
|
class BigInt$ extends transformOrFail(
|
|
@@ -6012,12 +6108,12 @@ class BigInt$ extends transformOrFail(
|
|
|
6012
6108
|
BigIntFromSelf,
|
|
6013
6109
|
{
|
|
6014
6110
|
strict: true,
|
|
6015
|
-
decode: (
|
|
6111
|
+
decode: (i, _, ast) =>
|
|
6016
6112
|
ParseResult.fromOption(
|
|
6017
|
-
bigInt_.fromString(
|
|
6018
|
-
() => new ParseResult.Type(ast,
|
|
6113
|
+
bigInt_.fromString(i),
|
|
6114
|
+
() => new ParseResult.Type(ast, i, `Unable to decode ${JSON.stringify(i)} into a bigint`)
|
|
6019
6115
|
),
|
|
6020
|
-
encode: (
|
|
6116
|
+
encode: (a) => ParseResult.succeed(String(a))
|
|
6021
6117
|
}
|
|
6022
6118
|
).annotations({ identifier: "BigInt" }) {}
|
|
6023
6119
|
|
|
@@ -6110,15 +6206,15 @@ export class BigIntFromNumber extends transformOrFail(
|
|
|
6110
6206
|
BigIntFromSelf.pipe(betweenBigInt(BigInt(Number.MIN_SAFE_INTEGER), BigInt(Number.MAX_SAFE_INTEGER))),
|
|
6111
6207
|
{
|
|
6112
6208
|
strict: true,
|
|
6113
|
-
decode: (
|
|
6209
|
+
decode: (i, _, ast) =>
|
|
6114
6210
|
ParseResult.fromOption(
|
|
6115
|
-
bigInt_.fromNumber(
|
|
6116
|
-
() => new ParseResult.Type(ast,
|
|
6211
|
+
bigInt_.fromNumber(i),
|
|
6212
|
+
() => new ParseResult.Type(ast, i, `Unable to decode ${i} into a bigint`)
|
|
6117
6213
|
),
|
|
6118
|
-
encode: (
|
|
6214
|
+
encode: (a, _, ast) =>
|
|
6119
6215
|
ParseResult.fromOption(
|
|
6120
|
-
bigInt_.toNumber(
|
|
6121
|
-
() => new ParseResult.Type(ast,
|
|
6216
|
+
bigInt_.toNumber(a),
|
|
6217
|
+
() => new ParseResult.Type(ast, a, `Unable to encode ${a}n into a number`)
|
|
6122
6218
|
)
|
|
6123
6219
|
}
|
|
6124
6220
|
).annotations({ identifier: "BigIntFromNumber" }) {}
|
|
@@ -6150,11 +6246,11 @@ const redactedParse = <A, R>(
|
|
|
6150
6246
|
* @since 3.10.0
|
|
6151
6247
|
*/
|
|
6152
6248
|
export interface RedactedFromSelf<Value extends Schema.Any> extends
|
|
6153
|
-
|
|
6249
|
+
AnnotableDeclare<
|
|
6154
6250
|
RedactedFromSelf<Value>,
|
|
6155
6251
|
redacted_.Redacted<Schema.Type<Value>>,
|
|
6156
6252
|
redacted_.Redacted<Schema.Encoded<Value>>,
|
|
6157
|
-
|
|
6253
|
+
[Value]
|
|
6158
6254
|
>
|
|
6159
6255
|
{}
|
|
6160
6256
|
|
|
@@ -6162,9 +6258,7 @@ export interface RedactedFromSelf<Value extends Schema.Any> extends
|
|
|
6162
6258
|
* @category Redacted constructors
|
|
6163
6259
|
* @since 3.10.0
|
|
6164
6260
|
*/
|
|
6165
|
-
export const RedactedFromSelf = <Value extends Schema.Any>(
|
|
6166
|
-
value: Value
|
|
6167
|
-
): RedactedFromSelf<Value> =>
|
|
6261
|
+
export const RedactedFromSelf = <Value extends Schema.Any>(value: Value): RedactedFromSelf<Value> =>
|
|
6168
6262
|
declare(
|
|
6169
6263
|
[value],
|
|
6170
6264
|
{
|
|
@@ -6183,31 +6277,25 @@ export const RedactedFromSelf = <Value extends Schema.Any>(
|
|
|
6183
6277
|
* @category api interface
|
|
6184
6278
|
* @since 3.10.0
|
|
6185
6279
|
*/
|
|
6186
|
-
export interface Redacted<Value extends Schema.Any>
|
|
6187
|
-
|
|
6188
|
-
Redacted<Value>,
|
|
6189
|
-
redacted_.Redacted<Schema.Type<Value>>,
|
|
6190
|
-
Schema.Encoded<Value>,
|
|
6191
|
-
Schema.Context<Value>
|
|
6192
|
-
>
|
|
6280
|
+
export interface Redacted<Value extends Schema.Any>
|
|
6281
|
+
extends transform<Value, RedactedFromSelf<SchemaClass<Schema.Type<Value>>>>
|
|
6193
6282
|
{}
|
|
6194
6283
|
|
|
6195
6284
|
/**
|
|
6196
|
-
* A
|
|
6285
|
+
* A transformation that transform a `Schema<A, I, R>` into a
|
|
6286
|
+
* `RedactedFromSelf<A>`.
|
|
6197
6287
|
*
|
|
6198
6288
|
* @category Redacted transformations
|
|
6199
6289
|
* @since 3.10.0
|
|
6200
6290
|
*/
|
|
6201
|
-
export
|
|
6202
|
-
value: Value
|
|
6203
|
-
): Redacted<Value> => {
|
|
6291
|
+
export function Redacted<Value extends Schema.Any>(value: Value): Redacted<Value> {
|
|
6204
6292
|
return transform(
|
|
6205
6293
|
value,
|
|
6206
|
-
RedactedFromSelf(typeSchema(value)),
|
|
6294
|
+
RedactedFromSelf(typeSchema(asSchema(value))),
|
|
6207
6295
|
{
|
|
6208
6296
|
strict: true,
|
|
6209
|
-
decode: (
|
|
6210
|
-
encode: (
|
|
6297
|
+
decode: (i) => redacted_.make(i),
|
|
6298
|
+
encode: (a) => redacted_.value(a)
|
|
6211
6299
|
}
|
|
6212
6300
|
)
|
|
6213
6301
|
}
|
|
@@ -6243,11 +6331,10 @@ export class DurationFromNanos extends transformOrFail(
|
|
|
6243
6331
|
DurationFromSelf.pipe(filter((duration) => duration_.isFinite(duration), { description: "a finite duration" })),
|
|
6244
6332
|
{
|
|
6245
6333
|
strict: true,
|
|
6246
|
-
decode: (
|
|
6247
|
-
encode: (
|
|
6248
|
-
option_.match(duration_.toNanos(
|
|
6249
|
-
onNone: () =>
|
|
6250
|
-
ParseResult.fail(new ParseResult.Type(ast, duration, `Unable to encode ${duration} into a bigint`)),
|
|
6334
|
+
decode: (i) => ParseResult.succeed(duration_.nanos(i)),
|
|
6335
|
+
encode: (a, _, ast) =>
|
|
6336
|
+
option_.match(duration_.toNanos(a), {
|
|
6337
|
+
onNone: () => ParseResult.fail(new ParseResult.Type(ast, a, `Unable to encode ${a} into a bigint`)),
|
|
6251
6338
|
onSome: (nanos) => ParseResult.succeed(nanos)
|
|
6252
6339
|
})
|
|
6253
6340
|
}
|
|
@@ -6275,8 +6362,8 @@ export class DurationFromMillis extends transform(
|
|
|
6275
6362
|
DurationFromSelf,
|
|
6276
6363
|
{
|
|
6277
6364
|
strict: true,
|
|
6278
|
-
decode: (
|
|
6279
|
-
encode: (
|
|
6365
|
+
decode: (i) => duration_.millis(i),
|
|
6366
|
+
encode: (a) => duration_.toMillis(a)
|
|
6280
6367
|
}
|
|
6281
6368
|
).annotations({ identifier: "DurationFromMillis" }) {}
|
|
6282
6369
|
|
|
@@ -6338,26 +6425,26 @@ export class Duration extends transform(
|
|
|
6338
6425
|
DurationFromSelf,
|
|
6339
6426
|
{
|
|
6340
6427
|
strict: true,
|
|
6341
|
-
decode: (
|
|
6342
|
-
if (isDurationValue(
|
|
6343
|
-
switch (
|
|
6428
|
+
decode: (i) => {
|
|
6429
|
+
if (isDurationValue(i)) {
|
|
6430
|
+
switch (i._tag) {
|
|
6344
6431
|
case "Millis":
|
|
6345
|
-
return duration_.millis(
|
|
6432
|
+
return duration_.millis(i.millis)
|
|
6346
6433
|
case "Nanos":
|
|
6347
|
-
return duration_.nanos(
|
|
6434
|
+
return duration_.nanos(i.nanos)
|
|
6348
6435
|
case "Infinity":
|
|
6349
6436
|
return duration_.infinity
|
|
6350
6437
|
}
|
|
6351
6438
|
}
|
|
6352
|
-
const [seconds, nanos] =
|
|
6439
|
+
const [seconds, nanos] = i
|
|
6353
6440
|
return seconds === -1 ? duration_.infinity : duration_.nanos(BigInt(seconds) * BigInt(1e9) + BigInt(nanos))
|
|
6354
6441
|
},
|
|
6355
|
-
encode: (
|
|
6356
|
-
switch (
|
|
6442
|
+
encode: (a) => {
|
|
6443
|
+
switch (a.value._tag) {
|
|
6357
6444
|
case "Millis":
|
|
6358
|
-
return DurationValueMillis.make({ millis:
|
|
6445
|
+
return DurationValueMillis.make({ millis: a.value.millis })
|
|
6359
6446
|
case "Nanos":
|
|
6360
|
-
return DurationValueNanos.make({ nanos:
|
|
6447
|
+
return DurationValueNanos.make({ nanos: a.value.nanos })
|
|
6361
6448
|
case "Infinity":
|
|
6362
6449
|
return durationValueInfinity
|
|
6363
6450
|
}
|
|
@@ -6373,11 +6460,17 @@ export class Duration extends transform(
|
|
|
6373
6460
|
*/
|
|
6374
6461
|
export const clampDuration =
|
|
6375
6462
|
(minimum: duration_.DurationInput, maximum: duration_.DurationInput) =>
|
|
6376
|
-
<
|
|
6463
|
+
<S extends Schema.Any, A extends duration_.Duration>(
|
|
6464
|
+
self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>
|
|
6465
|
+
): transform<S, filter<SchemaClass<A>>> =>
|
|
6377
6466
|
transform(
|
|
6378
6467
|
self,
|
|
6379
6468
|
self.pipe(typeSchema, betweenDuration(minimum, maximum)),
|
|
6380
|
-
{
|
|
6469
|
+
{
|
|
6470
|
+
strict: false,
|
|
6471
|
+
decode: (i) => duration_.clamp(i, { minimum, maximum }),
|
|
6472
|
+
encode: identity
|
|
6473
|
+
}
|
|
6381
6474
|
)
|
|
6382
6475
|
|
|
6383
6476
|
/**
|
|
@@ -6390,11 +6483,11 @@ export const LessThanDurationSchemaId: unique symbol = Symbol.for("effect/Schema
|
|
|
6390
6483
|
* @category Duration filters
|
|
6391
6484
|
* @since 3.10.0
|
|
6392
6485
|
*/
|
|
6393
|
-
export const lessThanDuration = <
|
|
6486
|
+
export const lessThanDuration = <S extends Schema.Any>(
|
|
6394
6487
|
max: duration_.DurationInput,
|
|
6395
|
-
annotations?: Annotations.Filter<
|
|
6488
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
6396
6489
|
) =>
|
|
6397
|
-
<
|
|
6490
|
+
<A extends duration_.Duration>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
6398
6491
|
self.pipe(
|
|
6399
6492
|
filter((a) => duration_.lessThan(a, max), {
|
|
6400
6493
|
schemaId: LessThanDurationSchemaId,
|
|
@@ -6417,11 +6510,11 @@ export const LessThanOrEqualToDurationSchemaId: unique symbol = Symbol.for(
|
|
|
6417
6510
|
* @category Duration filters
|
|
6418
6511
|
* @since 3.10.0
|
|
6419
6512
|
*/
|
|
6420
|
-
export const lessThanOrEqualToDuration = <
|
|
6513
|
+
export const lessThanOrEqualToDuration = <S extends Schema.Any>(
|
|
6421
6514
|
max: duration_.DurationInput,
|
|
6422
|
-
annotations?: Annotations.Filter<
|
|
6515
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
6423
6516
|
) =>
|
|
6424
|
-
<
|
|
6517
|
+
<A extends duration_.Duration>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
6425
6518
|
self.pipe(
|
|
6426
6519
|
filter((a) => duration_.lessThanOrEqualTo(a, max), {
|
|
6427
6520
|
schemaId: LessThanDurationSchemaId,
|
|
@@ -6442,11 +6535,11 @@ export const GreaterThanDurationSchemaId: unique symbol = Symbol.for("effect/Sch
|
|
|
6442
6535
|
* @category Duration filters
|
|
6443
6536
|
* @since 3.10.0
|
|
6444
6537
|
*/
|
|
6445
|
-
export const greaterThanDuration = <
|
|
6538
|
+
export const greaterThanDuration = <S extends Schema.Any>(
|
|
6446
6539
|
min: duration_.DurationInput,
|
|
6447
|
-
annotations?: Annotations.Filter<
|
|
6540
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
6448
6541
|
) =>
|
|
6449
|
-
<
|
|
6542
|
+
<A extends duration_.Duration>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
6450
6543
|
self.pipe(
|
|
6451
6544
|
filter((a) => duration_.greaterThan(a, min), {
|
|
6452
6545
|
schemaId: GreaterThanDurationSchemaId,
|
|
@@ -6469,11 +6562,11 @@ export const GreaterThanOrEqualToDurationSchemaId: unique symbol = Symbol.for(
|
|
|
6469
6562
|
* @category Duration filters
|
|
6470
6563
|
* @since 3.10.0
|
|
6471
6564
|
*/
|
|
6472
|
-
export const greaterThanOrEqualToDuration = <
|
|
6565
|
+
export const greaterThanOrEqualToDuration = <S extends Schema.Any>(
|
|
6473
6566
|
min: duration_.DurationInput,
|
|
6474
|
-
annotations?: Annotations.Filter<
|
|
6567
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
6475
6568
|
) =>
|
|
6476
|
-
<
|
|
6569
|
+
<A extends duration_.Duration>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
6477
6570
|
self.pipe(
|
|
6478
6571
|
filter((a) => duration_.greaterThanOrEqualTo(a, min), {
|
|
6479
6572
|
schemaId: GreaterThanOrEqualToDurationSchemaId,
|
|
@@ -6494,12 +6587,12 @@ export const BetweenDurationSchemaId: unique symbol = Symbol.for("effect/SchemaI
|
|
|
6494
6587
|
* @category Duration filters
|
|
6495
6588
|
* @since 3.10.0
|
|
6496
6589
|
*/
|
|
6497
|
-
export const betweenDuration = <
|
|
6590
|
+
export const betweenDuration = <S extends Schema.Any>(
|
|
6498
6591
|
minimum: duration_.DurationInput,
|
|
6499
6592
|
maximum: duration_.DurationInput,
|
|
6500
|
-
annotations?: Annotations.Filter<
|
|
6593
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
6501
6594
|
) =>
|
|
6502
|
-
<
|
|
6595
|
+
<A extends duration_.Duration>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
6503
6596
|
self.pipe(
|
|
6504
6597
|
filter((a) => duration_.between(a, { minimum, maximum }), {
|
|
6505
6598
|
schemaId: BetweenDurationSchemaId,
|
|
@@ -6514,7 +6607,7 @@ export const betweenDuration = <A extends duration_.Duration>(
|
|
|
6514
6607
|
* @category Uint8Array constructors
|
|
6515
6608
|
* @since 3.10.0
|
|
6516
6609
|
*/
|
|
6517
|
-
export
|
|
6610
|
+
export class Uint8ArrayFromSelf extends declare(
|
|
6518
6611
|
Predicate.isUint8Array,
|
|
6519
6612
|
{
|
|
6520
6613
|
identifier: "Uint8ArrayFromSelf",
|
|
@@ -6522,26 +6615,31 @@ export const Uint8ArrayFromSelf: Schema<Uint8Array> = declare(
|
|
|
6522
6615
|
arbitrary: (): LazyArbitrary<Uint8Array> => (fc) => fc.uint8Array(),
|
|
6523
6616
|
equivalence: (): Equivalence.Equivalence<Uint8Array> => array_.getEquivalence(Equal.equals) as any
|
|
6524
6617
|
}
|
|
6525
|
-
)
|
|
6618
|
+
) {}
|
|
6526
6619
|
|
|
6527
6620
|
/**
|
|
6528
6621
|
* @category number constructors
|
|
6529
6622
|
* @since 3.11.10
|
|
6530
6623
|
*/
|
|
6531
|
-
export
|
|
6624
|
+
export class Uint8 extends Number$.pipe(
|
|
6532
6625
|
between(0, 255, {
|
|
6533
6626
|
identifier: "Uint8",
|
|
6534
6627
|
description: "a 8-bit unsigned integer"
|
|
6535
6628
|
})
|
|
6536
|
-
)
|
|
6629
|
+
) {}
|
|
6537
6630
|
|
|
6538
|
-
|
|
6631
|
+
/** @ignore */
|
|
6632
|
+
class Uint8Array$ extends transform(
|
|
6539
6633
|
Array$(Uint8).annotations({
|
|
6540
6634
|
description: "an array of 8-bit unsigned integers to be decoded into a Uint8Array"
|
|
6541
6635
|
}),
|
|
6542
6636
|
Uint8ArrayFromSelf,
|
|
6543
|
-
{
|
|
6544
|
-
|
|
6637
|
+
{
|
|
6638
|
+
strict: true,
|
|
6639
|
+
decode: (i) => Uint8Array.from(i),
|
|
6640
|
+
encode: (a) => Array.from(a)
|
|
6641
|
+
}
|
|
6642
|
+
).annotations({ identifier: "Uint8Array" }) {}
|
|
6545
6643
|
|
|
6546
6644
|
export {
|
|
6547
6645
|
/**
|
|
@@ -6563,12 +6661,12 @@ const makeUint8ArrayTransformation = (
|
|
|
6563
6661
|
Uint8ArrayFromSelf,
|
|
6564
6662
|
{
|
|
6565
6663
|
strict: true,
|
|
6566
|
-
decode: (
|
|
6664
|
+
decode: (i, _, ast) =>
|
|
6567
6665
|
either_.mapLeft(
|
|
6568
|
-
decode(
|
|
6569
|
-
(decodeException) => new ParseResult.Type(ast,
|
|
6666
|
+
decode(i),
|
|
6667
|
+
(decodeException) => new ParseResult.Type(ast, i, decodeException.message)
|
|
6570
6668
|
),
|
|
6571
|
-
encode: (
|
|
6669
|
+
encode: (a) => ParseResult.succeed(encode(a))
|
|
6572
6670
|
}
|
|
6573
6671
|
).annotations({ identifier: id })
|
|
6574
6672
|
|
|
@@ -6620,12 +6718,12 @@ const makeEncodingTransformation = (
|
|
|
6620
6718
|
String$,
|
|
6621
6719
|
{
|
|
6622
6720
|
strict: true,
|
|
6623
|
-
decode: (
|
|
6721
|
+
decode: (i, _, ast) =>
|
|
6624
6722
|
either_.mapLeft(
|
|
6625
|
-
decode(
|
|
6626
|
-
(decodeException) => new ParseResult.Type(ast,
|
|
6723
|
+
decode(i),
|
|
6724
|
+
(decodeException) => new ParseResult.Type(ast, i, decodeException.message)
|
|
6627
6725
|
),
|
|
6628
|
-
encode: (
|
|
6726
|
+
encode: (a) => ParseResult.succeed(encode(a))
|
|
6629
6727
|
}
|
|
6630
6728
|
).annotations({ identifier: `StringFrom${id}` })
|
|
6631
6729
|
|
|
@@ -6694,15 +6792,15 @@ export const StringFromUriComponent = transformOrFail(
|
|
|
6694
6792
|
String$,
|
|
6695
6793
|
{
|
|
6696
6794
|
strict: true,
|
|
6697
|
-
decode: (
|
|
6795
|
+
decode: (i, _, ast) =>
|
|
6698
6796
|
either_.mapLeft(
|
|
6699
|
-
Encoding.decodeUriComponent(
|
|
6700
|
-
(decodeException) => new ParseResult.Type(ast,
|
|
6797
|
+
Encoding.decodeUriComponent(i),
|
|
6798
|
+
(decodeException) => new ParseResult.Type(ast, i, decodeException.message)
|
|
6701
6799
|
),
|
|
6702
|
-
encode: (
|
|
6800
|
+
encode: (a, _, ast) =>
|
|
6703
6801
|
either_.mapLeft(
|
|
6704
|
-
Encoding.encodeUriComponent(
|
|
6705
|
-
(encodeException) => new ParseResult.Type(ast,
|
|
6802
|
+
Encoding.encodeUriComponent(a),
|
|
6803
|
+
(encodeException) => new ParseResult.Type(ast, a, encodeException.message)
|
|
6706
6804
|
)
|
|
6707
6805
|
}
|
|
6708
6806
|
).annotations({ identifier: `StringFromUriComponent` })
|
|
@@ -6723,11 +6821,11 @@ export type MinItemsSchemaId = typeof MinItemsSchemaId
|
|
|
6723
6821
|
* @category ReadonlyArray filters
|
|
6724
6822
|
* @since 3.10.0
|
|
6725
6823
|
*/
|
|
6726
|
-
export const minItems = <
|
|
6824
|
+
export const minItems = <S extends Schema.Any>(
|
|
6727
6825
|
n: number,
|
|
6728
|
-
annotations?: Annotations.Filter<
|
|
6826
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
6729
6827
|
) =>
|
|
6730
|
-
<
|
|
6828
|
+
<A extends ReadonlyArray<any>>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> => {
|
|
6731
6829
|
const minItems = Math.floor(n)
|
|
6732
6830
|
if (minItems < 1) {
|
|
6733
6831
|
throw new Error(
|
|
@@ -6765,11 +6863,11 @@ export type MaxItemsSchemaId = typeof MaxItemsSchemaId
|
|
|
6765
6863
|
* @category ReadonlyArray filters
|
|
6766
6864
|
* @since 3.10.0
|
|
6767
6865
|
*/
|
|
6768
|
-
export const maxItems = <
|
|
6866
|
+
export const maxItems = <S extends Schema.Any>(
|
|
6769
6867
|
n: number,
|
|
6770
|
-
annotations?: Annotations.Filter<
|
|
6868
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
6771
6869
|
) =>
|
|
6772
|
-
<
|
|
6870
|
+
<A extends ReadonlyArray<any>>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> => {
|
|
6773
6871
|
const maxItems = Math.floor(n)
|
|
6774
6872
|
if (maxItems < 1) {
|
|
6775
6873
|
throw new Error(
|
|
@@ -6804,11 +6902,11 @@ export type ItemsCountSchemaId = typeof ItemsCountSchemaId
|
|
|
6804
6902
|
* @category ReadonlyArray filters
|
|
6805
6903
|
* @since 3.10.0
|
|
6806
6904
|
*/
|
|
6807
|
-
export const itemsCount = <
|
|
6905
|
+
export const itemsCount = <S extends Schema.Any>(
|
|
6808
6906
|
n: number,
|
|
6809
|
-
annotations?: Annotations.Filter<
|
|
6907
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
6810
6908
|
) =>
|
|
6811
|
-
<
|
|
6909
|
+
<A extends ReadonlyArray<any>>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> => {
|
|
6812
6910
|
const itemsCount = Math.floor(n)
|
|
6813
6911
|
if (itemsCount < 0) {
|
|
6814
6912
|
throw new Error(
|
|
@@ -6841,12 +6939,23 @@ export const getNumberIndexedAccess = <A extends ReadonlyArray<any>, I extends R
|
|
|
6841
6939
|
* @category ReadonlyArray transformations
|
|
6842
6940
|
* @since 3.10.0
|
|
6843
6941
|
*/
|
|
6844
|
-
export
|
|
6845
|
-
|
|
6942
|
+
export function head<S extends Schema.Any, A extends ReadonlyArray<unknown>>(
|
|
6943
|
+
self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>
|
|
6944
|
+
): transform<S, OptionFromSelf<SchemaClass<A[number]>>> {
|
|
6945
|
+
return transform(
|
|
6846
6946
|
self,
|
|
6847
6947
|
OptionFromSelf(getNumberIndexedAccess(typeSchema(self))),
|
|
6848
|
-
{
|
|
6948
|
+
{
|
|
6949
|
+
strict: false,
|
|
6950
|
+
decode: (i) => array_.head(i),
|
|
6951
|
+
encode: (a) =>
|
|
6952
|
+
option_.match(a, {
|
|
6953
|
+
onNone: () => [],
|
|
6954
|
+
onSome: array_.of
|
|
6955
|
+
})
|
|
6956
|
+
}
|
|
6849
6957
|
)
|
|
6958
|
+
}
|
|
6850
6959
|
|
|
6851
6960
|
/**
|
|
6852
6961
|
* Get the first element of a `NonEmptyReadonlyArray`.
|
|
@@ -6854,12 +6963,19 @@ export const head = <A, I, R>(self: Schema<ReadonlyArray<A>, I, R>): SchemaClass
|
|
|
6854
6963
|
* @category NonEmptyReadonlyArray transformations
|
|
6855
6964
|
* @since 3.12.0
|
|
6856
6965
|
*/
|
|
6857
|
-
export
|
|
6858
|
-
|
|
6966
|
+
export function headNonEmpty<S extends Schema.Any, A extends array_.NonEmptyReadonlyArray<unknown>>(
|
|
6967
|
+
self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>
|
|
6968
|
+
): transform<S, SchemaClass<A[number]>> {
|
|
6969
|
+
return transform(
|
|
6859
6970
|
self,
|
|
6860
6971
|
getNumberIndexedAccess(typeSchema(self)),
|
|
6861
|
-
{
|
|
6972
|
+
{
|
|
6973
|
+
strict: false,
|
|
6974
|
+
decode: (i) => array_.headNonEmpty(i),
|
|
6975
|
+
encode: (a) => array_.of(a)
|
|
6976
|
+
}
|
|
6862
6977
|
)
|
|
6978
|
+
}
|
|
6863
6979
|
|
|
6864
6980
|
/**
|
|
6865
6981
|
* Retrieves the first element of a `ReadonlyArray`.
|
|
@@ -6878,7 +6994,9 @@ export const headOrElse: {
|
|
|
6878
6994
|
* @category ReadonlyArray transformations
|
|
6879
6995
|
* @since 3.10.0
|
|
6880
6996
|
*/
|
|
6881
|
-
<A
|
|
6997
|
+
<S extends Schema.Any, A extends ReadonlyArray<unknown>>(fallback?: LazyArg<A[number]>): (
|
|
6998
|
+
self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>
|
|
6999
|
+
) => transform<S, SchemaClass<A[number]>>
|
|
6882
7000
|
/**
|
|
6883
7001
|
* Retrieves the first element of a `ReadonlyArray`.
|
|
6884
7002
|
*
|
|
@@ -6887,21 +7005,27 @@ export const headOrElse: {
|
|
|
6887
7005
|
* @category ReadonlyArray transformations
|
|
6888
7006
|
* @since 3.10.0
|
|
6889
7007
|
*/
|
|
6890
|
-
<
|
|
7008
|
+
<S extends Schema.Any, A extends ReadonlyArray<unknown>>(
|
|
7009
|
+
self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>,
|
|
7010
|
+
fallback?: LazyArg<A[number]>
|
|
7011
|
+
): transform<S, SchemaClass<A[number]>>
|
|
6891
7012
|
} = dual(
|
|
6892
7013
|
(args) => isSchema(args[0]),
|
|
6893
|
-
<A, I, R>(
|
|
7014
|
+
<A, I, R>(
|
|
7015
|
+
self: Schema<ReadonlyArray<A>, I, R>,
|
|
7016
|
+
fallback?: LazyArg<A>
|
|
7017
|
+
): transform<Schema<ReadonlyArray<A>, I, R>, SchemaClass<A>> =>
|
|
6894
7018
|
transformOrFail(
|
|
6895
7019
|
self,
|
|
6896
7020
|
getNumberIndexedAccess(typeSchema(self)),
|
|
6897
7021
|
{
|
|
6898
7022
|
strict: true,
|
|
6899
|
-
decode: (
|
|
6900
|
-
|
|
6901
|
-
? ParseResult.succeed(
|
|
7023
|
+
decode: (i, _, ast) =>
|
|
7024
|
+
i.length > 0
|
|
7025
|
+
? ParseResult.succeed(i[0])
|
|
6902
7026
|
: fallback
|
|
6903
7027
|
? ParseResult.succeed(fallback())
|
|
6904
|
-
: ParseResult.fail(new ParseResult.Type(ast,
|
|
7028
|
+
: ParseResult.fail(new ParseResult.Type(ast, i, "Unable to retrieve the first element of an empty array")),
|
|
6905
7029
|
encode: (a) => ParseResult.succeed(array_.of(a))
|
|
6906
7030
|
}
|
|
6907
7031
|
)
|
|
@@ -6923,7 +7047,8 @@ export const ValidDateSchemaId: unique symbol = Symbol.for("effect/SchemaId/Vali
|
|
|
6923
7047
|
* @since 3.10.0
|
|
6924
7048
|
*/
|
|
6925
7049
|
export const validDate =
|
|
6926
|
-
(annotations?: Annotations.Filter<
|
|
7050
|
+
<S extends Schema.Any>(annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
7051
|
+
<A extends Date>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
6927
7052
|
self.pipe(
|
|
6928
7053
|
filter((a) => !Number.isNaN(a.getTime()), {
|
|
6929
7054
|
schemaId: ValidDateSchemaId,
|
|
@@ -6944,13 +7069,13 @@ export const LessThanDateSchemaId: unique symbol = Symbol.for("effect/SchemaId/L
|
|
|
6944
7069
|
* @category Date filters
|
|
6945
7070
|
* @since 3.10.0
|
|
6946
7071
|
*/
|
|
6947
|
-
export const lessThanDate = <
|
|
7072
|
+
export const lessThanDate = <S extends Schema.Any>(
|
|
6948
7073
|
max: Date,
|
|
6949
|
-
annotations?: Annotations.Filter<
|
|
7074
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
6950
7075
|
) =>
|
|
6951
|
-
<
|
|
7076
|
+
<A extends Date>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
6952
7077
|
self.pipe(
|
|
6953
|
-
filter((a) => a < max, {
|
|
7078
|
+
filter((a: Date) => a < max, {
|
|
6954
7079
|
schemaId: LessThanDateSchemaId,
|
|
6955
7080
|
[LessThanDateSchemaId]: { max },
|
|
6956
7081
|
title: `lessThanDate(${util_.formatDate(max)})`,
|
|
@@ -6971,13 +7096,13 @@ export const LessThanOrEqualToDateSchemaId: unique symbol = Symbol.for(
|
|
|
6971
7096
|
* @category Date filters
|
|
6972
7097
|
* @since 3.10.0
|
|
6973
7098
|
*/
|
|
6974
|
-
export const lessThanOrEqualToDate = <
|
|
7099
|
+
export const lessThanOrEqualToDate = <S extends Schema.Any>(
|
|
6975
7100
|
max: Date,
|
|
6976
|
-
annotations?: Annotations.Filter<
|
|
7101
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
6977
7102
|
) =>
|
|
6978
|
-
<
|
|
7103
|
+
<A extends Date>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
6979
7104
|
self.pipe(
|
|
6980
|
-
filter((a) => a <= max, {
|
|
7105
|
+
filter((a: Date) => a <= max, {
|
|
6981
7106
|
schemaId: LessThanDateSchemaId,
|
|
6982
7107
|
[LessThanDateSchemaId]: { max },
|
|
6983
7108
|
title: `lessThanOrEqualToDate(${util_.formatDate(max)})`,
|
|
@@ -6996,13 +7121,13 @@ export const GreaterThanDateSchemaId: unique symbol = Symbol.for("effect/SchemaI
|
|
|
6996
7121
|
* @category Date filters
|
|
6997
7122
|
* @since 3.10.0
|
|
6998
7123
|
*/
|
|
6999
|
-
export const greaterThanDate = <
|
|
7124
|
+
export const greaterThanDate = <S extends Schema.Any>(
|
|
7000
7125
|
min: Date,
|
|
7001
|
-
annotations?: Annotations.Filter<
|
|
7126
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
7002
7127
|
) =>
|
|
7003
|
-
<
|
|
7128
|
+
<A extends Date>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
7004
7129
|
self.pipe(
|
|
7005
|
-
filter((a) => a > min, {
|
|
7130
|
+
filter((a: Date) => a > min, {
|
|
7006
7131
|
schemaId: GreaterThanDateSchemaId,
|
|
7007
7132
|
[GreaterThanDateSchemaId]: { min },
|
|
7008
7133
|
title: `greaterThanDate(${util_.formatDate(min)})`,
|
|
@@ -7023,13 +7148,13 @@ export const GreaterThanOrEqualToDateSchemaId: unique symbol = Symbol.for(
|
|
|
7023
7148
|
* @category Date filters
|
|
7024
7149
|
* @since 3.10.0
|
|
7025
7150
|
*/
|
|
7026
|
-
export const greaterThanOrEqualToDate = <
|
|
7151
|
+
export const greaterThanOrEqualToDate = <S extends Schema.Any>(
|
|
7027
7152
|
min: Date,
|
|
7028
|
-
annotations?: Annotations.Filter<
|
|
7153
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
7029
7154
|
) =>
|
|
7030
|
-
<
|
|
7155
|
+
<A extends Date>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
7031
7156
|
self.pipe(
|
|
7032
|
-
filter((a) => a >= min, {
|
|
7157
|
+
filter((a: Date) => a >= min, {
|
|
7033
7158
|
schemaId: GreaterThanOrEqualToDateSchemaId,
|
|
7034
7159
|
[GreaterThanOrEqualToDateSchemaId]: { min },
|
|
7035
7160
|
title: `greaterThanOrEqualToDate(${util_.formatDate(min)})`,
|
|
@@ -7048,14 +7173,14 @@ export const BetweenDateSchemaId: unique symbol = Symbol.for("effect/SchemaId/Be
|
|
|
7048
7173
|
* @category Date filters
|
|
7049
7174
|
* @since 3.10.0
|
|
7050
7175
|
*/
|
|
7051
|
-
export const betweenDate = <
|
|
7176
|
+
export const betweenDate = <S extends Schema.Any>(
|
|
7052
7177
|
min: Date,
|
|
7053
7178
|
max: Date,
|
|
7054
|
-
annotations?: Annotations.Filter<
|
|
7179
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
7055
7180
|
) =>
|
|
7056
|
-
<
|
|
7181
|
+
<A extends Date>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
7057
7182
|
self.pipe(
|
|
7058
|
-
filter((a) => a <= max && a >= min, {
|
|
7183
|
+
filter((a: Date) => a <= max && a >= min, {
|
|
7059
7184
|
schemaId: BetweenDateSchemaId,
|
|
7060
7185
|
[BetweenDateSchemaId]: { max, min },
|
|
7061
7186
|
title: `betweenDate(${util_.formatDate(min)}, ${util_.formatDate(max)})`,
|
|
@@ -7125,7 +7250,11 @@ export class ValidDateFromSelf extends DateFromSelf.pipe(
|
|
|
7125
7250
|
export class DateFromString extends transform(
|
|
7126
7251
|
String$.annotations({ description: "a string to be decoded into a Date" }),
|
|
7127
7252
|
DateFromSelf,
|
|
7128
|
-
{
|
|
7253
|
+
{
|
|
7254
|
+
strict: true,
|
|
7255
|
+
decode: (i) => new Date(i),
|
|
7256
|
+
encode: (a) => util_.formatDate(a)
|
|
7257
|
+
}
|
|
7129
7258
|
).annotations({ identifier: "DateFromString" }) {}
|
|
7130
7259
|
|
|
7131
7260
|
/** @ignore */
|
|
@@ -7159,7 +7288,11 @@ export {
|
|
|
7159
7288
|
export class DateFromNumber extends transform(
|
|
7160
7289
|
Number$.annotations({ description: "a number to be decoded into a Date" }),
|
|
7161
7290
|
DateFromSelf,
|
|
7162
|
-
{
|
|
7291
|
+
{
|
|
7292
|
+
strict: true,
|
|
7293
|
+
decode: (i) => new Date(i),
|
|
7294
|
+
encode: (a) => a.getTime()
|
|
7295
|
+
}
|
|
7163
7296
|
).annotations({ identifier: "DateFromNumber" }) {}
|
|
7164
7297
|
|
|
7165
7298
|
/**
|
|
@@ -7180,7 +7313,7 @@ export class DateTimeUtcFromSelf extends declare(
|
|
|
7180
7313
|
}
|
|
7181
7314
|
) {}
|
|
7182
7315
|
|
|
7183
|
-
const decodeDateTimeUtc = <A extends dateTime.DateTime.Input>(input: A,
|
|
7316
|
+
const decodeDateTimeUtc = <A extends dateTime.DateTime.Input>(input: A, ast: AST.AST) =>
|
|
7184
7317
|
ParseResult.try({
|
|
7185
7318
|
try: () => dateTime.unsafeMake(input),
|
|
7186
7319
|
catch: () => new ParseResult.Type(ast, input, `Unable to decode ${util_.formatUnknown(input)} into a DateTime.Utc`)
|
|
@@ -7197,8 +7330,8 @@ export class DateTimeUtcFromNumber extends transformOrFail(
|
|
|
7197
7330
|
DateTimeUtcFromSelf,
|
|
7198
7331
|
{
|
|
7199
7332
|
strict: true,
|
|
7200
|
-
decode: decodeDateTimeUtc,
|
|
7201
|
-
encode: (
|
|
7333
|
+
decode: (i, _, ast) => decodeDateTimeUtc(i, ast),
|
|
7334
|
+
encode: (a) => ParseResult.succeed(dateTime.toEpochMillis(a))
|
|
7202
7335
|
}
|
|
7203
7336
|
).annotations({ identifier: "DateTimeUtcFromNumber" }) {}
|
|
7204
7337
|
|
|
@@ -7213,8 +7346,8 @@ export class DateTimeUtcFromDate extends transformOrFail(
|
|
|
7213
7346
|
DateTimeUtcFromSelf,
|
|
7214
7347
|
{
|
|
7215
7348
|
strict: true,
|
|
7216
|
-
decode: decodeDateTimeUtc,
|
|
7217
|
-
encode: (
|
|
7349
|
+
decode: (i, _, ast) => decodeDateTimeUtc(i, ast),
|
|
7350
|
+
encode: (a) => ParseResult.succeed(dateTime.toDateUtc(a))
|
|
7218
7351
|
}
|
|
7219
7352
|
).annotations({ identifier: "DateTimeUtcFromDate" }) {}
|
|
7220
7353
|
|
|
@@ -7229,8 +7362,8 @@ export class DateTimeUtc extends transformOrFail(
|
|
|
7229
7362
|
DateTimeUtcFromSelf,
|
|
7230
7363
|
{
|
|
7231
7364
|
strict: true,
|
|
7232
|
-
decode: decodeDateTimeUtc,
|
|
7233
|
-
encode: (
|
|
7365
|
+
decode: (i, _, ast) => decodeDateTimeUtc(i, ast),
|
|
7366
|
+
encode: (a) => ParseResult.succeed(dateTime.formatIso(a))
|
|
7234
7367
|
}
|
|
7235
7368
|
).annotations({ identifier: "DateTimeUtc" }) {}
|
|
7236
7369
|
|
|
@@ -7262,7 +7395,11 @@ export class TimeZoneOffsetFromSelf extends declare(
|
|
|
7262
7395
|
export class TimeZoneOffset extends transform(
|
|
7263
7396
|
Number$.annotations({ description: "a number to be decoded into a TimeZone.Offset" }),
|
|
7264
7397
|
TimeZoneOffsetFromSelf,
|
|
7265
|
-
{
|
|
7398
|
+
{
|
|
7399
|
+
strict: true,
|
|
7400
|
+
decode: (i) => dateTime.zoneMakeOffset(i),
|
|
7401
|
+
encode: (a) => a.offset
|
|
7402
|
+
}
|
|
7266
7403
|
).annotations({ identifier: "TimeZoneOffset" }) {}
|
|
7267
7404
|
|
|
7268
7405
|
const timeZoneNamedArbitrary = (): LazyArbitrary<dateTime.TimeZone.Named> => (fc) =>
|
|
@@ -7295,12 +7432,12 @@ export class TimeZoneNamed extends transformOrFail(
|
|
|
7295
7432
|
TimeZoneNamedFromSelf,
|
|
7296
7433
|
{
|
|
7297
7434
|
strict: true,
|
|
7298
|
-
decode: (
|
|
7435
|
+
decode: (i, _, ast) =>
|
|
7299
7436
|
ParseResult.try({
|
|
7300
|
-
try: () => dateTime.zoneUnsafeMakeNamed(
|
|
7301
|
-
catch: () => new ParseResult.Type(ast,
|
|
7437
|
+
try: () => dateTime.zoneUnsafeMakeNamed(i),
|
|
7438
|
+
catch: () => new ParseResult.Type(ast, i, `Unable to decode ${JSON.stringify(i)} into a TimeZone.Named`)
|
|
7302
7439
|
}),
|
|
7303
|
-
encode: (
|
|
7440
|
+
encode: (a) => ParseResult.succeed(a.id)
|
|
7304
7441
|
}
|
|
7305
7442
|
).annotations({ identifier: "TimeZoneNamed" }) {}
|
|
7306
7443
|
|
|
@@ -7321,13 +7458,13 @@ export class TimeZone extends transformOrFail(
|
|
|
7321
7458
|
TimeZoneFromSelf,
|
|
7322
7459
|
{
|
|
7323
7460
|
strict: true,
|
|
7324
|
-
decode: (
|
|
7325
|
-
option_.match(dateTime.zoneFromString(
|
|
7461
|
+
decode: (i, _, ast) =>
|
|
7462
|
+
option_.match(dateTime.zoneFromString(i), {
|
|
7326
7463
|
onNone: () =>
|
|
7327
|
-
ParseResult.fail(new ParseResult.Type(ast,
|
|
7464
|
+
ParseResult.fail(new ParseResult.Type(ast, i, `Unable to decode ${JSON.stringify(i)} into a TimeZone`)),
|
|
7328
7465
|
onSome: ParseResult.succeed
|
|
7329
7466
|
}),
|
|
7330
|
-
encode: (
|
|
7467
|
+
encode: (a) => ParseResult.succeed(dateTime.zoneToString(a))
|
|
7331
7468
|
}
|
|
7332
7469
|
).annotations({ identifier: "TimeZone" }) {}
|
|
7333
7470
|
|
|
@@ -7373,13 +7510,13 @@ export class DateTimeZoned extends transformOrFail(
|
|
|
7373
7510
|
DateTimeZonedFromSelf,
|
|
7374
7511
|
{
|
|
7375
7512
|
strict: true,
|
|
7376
|
-
decode: (
|
|
7377
|
-
option_.match(dateTime.makeZonedFromString(
|
|
7513
|
+
decode: (i, _, ast) =>
|
|
7514
|
+
option_.match(dateTime.makeZonedFromString(i), {
|
|
7378
7515
|
onNone: () =>
|
|
7379
|
-
ParseResult.fail(new ParseResult.Type(ast,
|
|
7516
|
+
ParseResult.fail(new ParseResult.Type(ast, i, `Unable to decode ${JSON.stringify(i)} into a DateTime.Zoned`)),
|
|
7380
7517
|
onSome: ParseResult.succeed
|
|
7381
7518
|
}),
|
|
7382
|
-
encode: (
|
|
7519
|
+
encode: (a) => ParseResult.succeed(dateTime.formatIsoZoned(a))
|
|
7383
7520
|
}
|
|
7384
7521
|
).annotations({ identifier: "DateTimeZoned" }) {}
|
|
7385
7522
|
|
|
@@ -7400,13 +7537,13 @@ const OptionNoneEncoded = Struct({
|
|
|
7400
7537
|
_tag: Literal("None")
|
|
7401
7538
|
}).annotations({ description: "NoneEncoded" })
|
|
7402
7539
|
|
|
7403
|
-
const optionSomeEncoded = <
|
|
7540
|
+
const optionSomeEncoded = <Value extends Schema.Any>(value: Value) =>
|
|
7404
7541
|
Struct({
|
|
7405
7542
|
_tag: Literal("Some"),
|
|
7406
7543
|
value
|
|
7407
7544
|
}).annotations({ description: `SomeEncoded<${format(value)}>` })
|
|
7408
7545
|
|
|
7409
|
-
const optionEncoded = <
|
|
7546
|
+
const optionEncoded = <Value extends Schema.Any>(value: Value) =>
|
|
7410
7547
|
Union(
|
|
7411
7548
|
OptionNoneEncoded,
|
|
7412
7549
|
optionSomeEncoded(value)
|
|
@@ -7445,11 +7582,11 @@ const optionParse =
|
|
|
7445
7582
|
* @since 3.10.0
|
|
7446
7583
|
*/
|
|
7447
7584
|
export interface OptionFromSelf<Value extends Schema.Any> extends
|
|
7448
|
-
|
|
7585
|
+
AnnotableDeclare<
|
|
7449
7586
|
OptionFromSelf<Value>,
|
|
7450
7587
|
option_.Option<Schema.Type<Value>>,
|
|
7451
7588
|
option_.Option<Schema.Encoded<Value>>,
|
|
7452
|
-
|
|
7589
|
+
[Value]
|
|
7453
7590
|
>
|
|
7454
7591
|
{}
|
|
7455
7592
|
|
|
@@ -7457,9 +7594,7 @@ export interface OptionFromSelf<Value extends Schema.Any> extends
|
|
|
7457
7594
|
* @category Option transformations
|
|
7458
7595
|
* @since 3.10.0
|
|
7459
7596
|
*/
|
|
7460
|
-
export const OptionFromSelf = <Value extends Schema.Any>(
|
|
7461
|
-
value: Value
|
|
7462
|
-
): OptionFromSelf<Value> => {
|
|
7597
|
+
export const OptionFromSelf = <Value extends Schema.Any>(value: Value): OptionFromSelf<Value> => {
|
|
7463
7598
|
return declare(
|
|
7464
7599
|
[value],
|
|
7465
7600
|
{
|
|
@@ -7475,72 +7610,68 @@ export const OptionFromSelf = <Value extends Schema.Any>(
|
|
|
7475
7610
|
)
|
|
7476
7611
|
}
|
|
7477
7612
|
|
|
7478
|
-
const makeNoneEncoded = {
|
|
7479
|
-
_tag: "None"
|
|
7480
|
-
} as const
|
|
7481
|
-
const makeSomeEncoded = <A>(value: A) => ({
|
|
7482
|
-
_tag: "Some",
|
|
7483
|
-
value
|
|
7484
|
-
} as const)
|
|
7485
|
-
|
|
7486
7613
|
/**
|
|
7487
7614
|
* @category api interface
|
|
7488
7615
|
* @since 3.10.0
|
|
7489
7616
|
*/
|
|
7490
7617
|
export interface Option<Value extends Schema.Any> extends
|
|
7491
|
-
|
|
7492
|
-
|
|
7493
|
-
|
|
7494
|
-
|
|
7495
|
-
|
|
7618
|
+
transform<
|
|
7619
|
+
Union<[
|
|
7620
|
+
Struct<{ _tag: Literal<["None"]> }>,
|
|
7621
|
+
Struct<{ _tag: Literal<["Some"]>; value: Value }>
|
|
7622
|
+
]>,
|
|
7623
|
+
OptionFromSelf<SchemaClass<Schema.Type<Value>>>
|
|
7496
7624
|
>
|
|
7497
7625
|
{}
|
|
7498
7626
|
|
|
7627
|
+
const makeNoneEncoded = {
|
|
7628
|
+
_tag: "None"
|
|
7629
|
+
} as const
|
|
7630
|
+
|
|
7631
|
+
const makeSomeEncoded = <A>(value: A) => ({
|
|
7632
|
+
_tag: "Some",
|
|
7633
|
+
value
|
|
7634
|
+
} as const)
|
|
7635
|
+
|
|
7499
7636
|
/**
|
|
7500
7637
|
* @category Option transformations
|
|
7501
7638
|
* @since 3.10.0
|
|
7502
7639
|
*/
|
|
7503
|
-
export
|
|
7640
|
+
export function Option<Value extends Schema.Any>(value: Value): Option<Value> {
|
|
7504
7641
|
const value_ = asSchema(value)
|
|
7505
|
-
|
|
7642
|
+
const out = transform(
|
|
7506
7643
|
optionEncoded(value_),
|
|
7507
7644
|
OptionFromSelf(typeSchema(value_)),
|
|
7508
7645
|
{
|
|
7509
7646
|
strict: true,
|
|
7510
|
-
decode: optionDecode,
|
|
7511
|
-
encode:
|
|
7512
|
-
|
|
7513
|
-
|
|
7514
|
-
|
|
7647
|
+
decode: (i) => optionDecode(i),
|
|
7648
|
+
encode: (a) =>
|
|
7649
|
+
option_.match(a, {
|
|
7650
|
+
onNone: () => makeNoneEncoded,
|
|
7651
|
+
onSome: makeSomeEncoded
|
|
7652
|
+
})
|
|
7515
7653
|
}
|
|
7516
7654
|
)
|
|
7655
|
+
return out as any
|
|
7517
7656
|
}
|
|
7518
7657
|
|
|
7519
7658
|
/**
|
|
7520
7659
|
* @category api interface
|
|
7521
7660
|
* @since 3.10.0
|
|
7522
7661
|
*/
|
|
7523
|
-
export interface OptionFromNullOr<Value extends Schema.Any>
|
|
7524
|
-
|
|
7525
|
-
OptionFromNullOr<Value>,
|
|
7526
|
-
option_.Option<Schema.Type<Value>>,
|
|
7527
|
-
Schema.Encoded<Value> | null,
|
|
7528
|
-
Schema.Context<Value>
|
|
7529
|
-
>
|
|
7662
|
+
export interface OptionFromNullOr<Value extends Schema.Any>
|
|
7663
|
+
extends transform<NullOr<Value>, OptionFromSelf<SchemaClass<Schema.Type<Value>>>>
|
|
7530
7664
|
{}
|
|
7531
7665
|
|
|
7532
7666
|
/**
|
|
7533
7667
|
* @category Option transformations
|
|
7534
7668
|
* @since 3.10.0
|
|
7535
7669
|
*/
|
|
7536
|
-
export
|
|
7537
|
-
value
|
|
7538
|
-
): OptionFromNullOr<Value> => {
|
|
7539
|
-
const value_ = asSchema(value)
|
|
7540
|
-
return transform(NullOr(value_), OptionFromSelf(typeSchema(value_)), {
|
|
7670
|
+
export function OptionFromNullOr<Value extends Schema.Any>(value: Value): OptionFromNullOr<Value> {
|
|
7671
|
+
return transform(NullOr(value), OptionFromSelf(typeSchema(asSchema(value))), {
|
|
7541
7672
|
strict: true,
|
|
7542
|
-
decode: option_.fromNullable,
|
|
7543
|
-
encode: option_.getOrNull
|
|
7673
|
+
decode: (i) => option_.fromNullable(i),
|
|
7674
|
+
encode: (a) => option_.getOrNull(a)
|
|
7544
7675
|
})
|
|
7545
7676
|
}
|
|
7546
7677
|
|
|
@@ -7548,31 +7679,27 @@ export const OptionFromNullOr = <Value extends Schema.Any>(
|
|
|
7548
7679
|
* @category api interface
|
|
7549
7680
|
* @since 3.10.0
|
|
7550
7681
|
*/
|
|
7551
|
-
export interface OptionFromNullishOr<Value extends Schema.Any>
|
|
7552
|
-
|
|
7553
|
-
OptionFromNullishOr<Value>,
|
|
7554
|
-
option_.Option<Schema.Type<Value>>,
|
|
7555
|
-
Schema.Encoded<Value> | null | undefined,
|
|
7556
|
-
Schema.Context<Value>
|
|
7557
|
-
>
|
|
7682
|
+
export interface OptionFromNullishOr<Value extends Schema.Any>
|
|
7683
|
+
extends transform<NullishOr<Value>, OptionFromSelf<SchemaClass<Schema.Type<Value>>>>
|
|
7558
7684
|
{}
|
|
7559
7685
|
|
|
7560
7686
|
/**
|
|
7561
7687
|
* @category Option transformations
|
|
7562
7688
|
* @since 3.10.0
|
|
7563
7689
|
*/
|
|
7564
|
-
export
|
|
7690
|
+
export function OptionFromNullishOr<Value extends Schema.Any>(
|
|
7565
7691
|
value: Value,
|
|
7566
7692
|
onNoneEncoding: null | undefined
|
|
7567
|
-
): OptionFromNullishOr<Value>
|
|
7568
|
-
const value_ = asSchema(value)
|
|
7693
|
+
): OptionFromNullishOr<Value> {
|
|
7569
7694
|
return transform(
|
|
7570
|
-
NullishOr(
|
|
7571
|
-
OptionFromSelf(typeSchema(
|
|
7695
|
+
NullishOr(value),
|
|
7696
|
+
OptionFromSelf(typeSchema(asSchema(value))),
|
|
7572
7697
|
{
|
|
7573
7698
|
strict: true,
|
|
7574
|
-
decode: option_.fromNullable,
|
|
7575
|
-
encode: onNoneEncoding === null ?
|
|
7699
|
+
decode: (i) => option_.fromNullable(i),
|
|
7700
|
+
encode: onNoneEncoding === null ?
|
|
7701
|
+
(a) => option_.getOrNull(a) :
|
|
7702
|
+
(a) => option_.getOrUndefined(a)
|
|
7576
7703
|
}
|
|
7577
7704
|
)
|
|
7578
7705
|
}
|
|
@@ -7581,27 +7708,19 @@ export const OptionFromNullishOr = <Value extends Schema.Any>(
|
|
|
7581
7708
|
* @category api interface
|
|
7582
7709
|
* @since 3.10.0
|
|
7583
7710
|
*/
|
|
7584
|
-
export interface OptionFromUndefinedOr<Value extends Schema.Any>
|
|
7585
|
-
|
|
7586
|
-
OptionFromUndefinedOr<Value>,
|
|
7587
|
-
option_.Option<Schema.Type<Value>>,
|
|
7588
|
-
Schema.Encoded<Value> | undefined,
|
|
7589
|
-
Schema.Context<Value>
|
|
7590
|
-
>
|
|
7711
|
+
export interface OptionFromUndefinedOr<Value extends Schema.Any>
|
|
7712
|
+
extends transform<UndefinedOr<Value>, OptionFromSelf<SchemaClass<Schema.Type<Value>>>>
|
|
7591
7713
|
{}
|
|
7592
7714
|
|
|
7593
7715
|
/**
|
|
7594
7716
|
* @category Option transformations
|
|
7595
7717
|
* @since 3.10.0
|
|
7596
7718
|
*/
|
|
7597
|
-
export
|
|
7598
|
-
value
|
|
7599
|
-
): OptionFromUndefinedOr<Value> => {
|
|
7600
|
-
const value_ = asSchema(value)
|
|
7601
|
-
return transform(UndefinedOr(value_), OptionFromSelf(typeSchema(value_)), {
|
|
7719
|
+
export function OptionFromUndefinedOr<Value extends Schema.Any>(value: Value): OptionFromUndefinedOr<Value> {
|
|
7720
|
+
return transform(UndefinedOr(value), OptionFromSelf(typeSchema(asSchema(value))), {
|
|
7602
7721
|
strict: true,
|
|
7603
|
-
decode: option_.fromNullable,
|
|
7604
|
-
encode: option_.getOrUndefined
|
|
7722
|
+
decode: (i) => option_.fromNullable(i),
|
|
7723
|
+
encode: (a) => option_.getOrUndefined(a)
|
|
7605
7724
|
})
|
|
7606
7725
|
}
|
|
7607
7726
|
|
|
@@ -7622,11 +7741,11 @@ export const OptionFromUndefinedOr = <Value extends Schema.Any>(
|
|
|
7622
7741
|
* @category Option transformations
|
|
7623
7742
|
* @since 3.10.0
|
|
7624
7743
|
*/
|
|
7625
|
-
export
|
|
7744
|
+
export class OptionFromNonEmptyTrimmedString extends transform(String$, OptionFromSelf(NonEmptyTrimmedString), {
|
|
7626
7745
|
strict: true,
|
|
7627
|
-
decode: (
|
|
7628
|
-
encode: option_.getOrElse(() => "")
|
|
7629
|
-
})
|
|
7746
|
+
decode: (i) => option_.filter(option_.some(i.trim()), string_.isNonEmpty),
|
|
7747
|
+
encode: (a) => option_.getOrElse(a, () => "")
|
|
7748
|
+
}) {}
|
|
7630
7749
|
|
|
7631
7750
|
/**
|
|
7632
7751
|
* @category Either utils
|
|
@@ -7652,21 +7771,21 @@ export type LeftEncoded<IE> = {
|
|
|
7652
7771
|
*/
|
|
7653
7772
|
export type EitherEncoded<IR, IL> = RightEncoded<IR> | LeftEncoded<IL>
|
|
7654
7773
|
|
|
7655
|
-
const rightEncoded = <
|
|
7774
|
+
const rightEncoded = <Right extends Schema.All>(right: Right) =>
|
|
7656
7775
|
Struct({
|
|
7657
7776
|
_tag: Literal("Right"),
|
|
7658
7777
|
right
|
|
7659
7778
|
}).annotations({ description: `RightEncoded<${format(right)}>` })
|
|
7660
7779
|
|
|
7661
|
-
const leftEncoded = <
|
|
7780
|
+
const leftEncoded = <Left extends Schema.All>(left: Left) =>
|
|
7662
7781
|
Struct({
|
|
7663
7782
|
_tag: Literal("Left"),
|
|
7664
7783
|
left
|
|
7665
7784
|
}).annotations({ description: `LeftEncoded<${format(left)}>` })
|
|
7666
7785
|
|
|
7667
|
-
const eitherEncoded = <
|
|
7668
|
-
right:
|
|
7669
|
-
left:
|
|
7786
|
+
const eitherEncoded = <Right extends Schema.All, Left extends Schema.All>(
|
|
7787
|
+
right: Right,
|
|
7788
|
+
left: Left
|
|
7670
7789
|
) =>
|
|
7671
7790
|
Union(rightEncoded(right), leftEncoded(left)).annotations({
|
|
7672
7791
|
description: `EitherEncoded<${format(left)}, ${format(right)}>`
|
|
@@ -7711,11 +7830,11 @@ const eitherParse = <RR, R, LR, L>(
|
|
|
7711
7830
|
* @since 3.10.0
|
|
7712
7831
|
*/
|
|
7713
7832
|
export interface EitherFromSelf<R extends Schema.All, L extends Schema.All> extends
|
|
7714
|
-
|
|
7833
|
+
AnnotableDeclare<
|
|
7715
7834
|
EitherFromSelf<R, L>,
|
|
7716
7835
|
either_.Either<Schema.Type<R>, Schema.Type<L>>,
|
|
7717
7836
|
either_.Either<Schema.Encoded<R>, Schema.Encoded<L>>,
|
|
7718
|
-
|
|
7837
|
+
[R, L]
|
|
7719
7838
|
>
|
|
7720
7839
|
{}
|
|
7721
7840
|
|
|
@@ -7755,12 +7874,19 @@ const makeRightEncoded = <A>(right: A) => (({
|
|
|
7755
7874
|
* @category api interface
|
|
7756
7875
|
* @since 3.10.0
|
|
7757
7876
|
*/
|
|
7758
|
-
export interface Either<
|
|
7759
|
-
|
|
7760
|
-
|
|
7761
|
-
|
|
7762
|
-
|
|
7763
|
-
|
|
7877
|
+
export interface Either<Right extends Schema.All, Left extends Schema.All> extends
|
|
7878
|
+
transform<
|
|
7879
|
+
Union<[
|
|
7880
|
+
Struct<{
|
|
7881
|
+
_tag: Literal<["Right"]>
|
|
7882
|
+
right: Right
|
|
7883
|
+
}>,
|
|
7884
|
+
Struct<{
|
|
7885
|
+
_tag: Literal<["Left"]>
|
|
7886
|
+
left: Left
|
|
7887
|
+
}>
|
|
7888
|
+
]>,
|
|
7889
|
+
EitherFromSelf<SchemaClass<Schema.Type<Right>>, SchemaClass<Schema.Type<Left>>>
|
|
7764
7890
|
>
|
|
7765
7891
|
{}
|
|
7766
7892
|
|
|
@@ -7774,27 +7900,33 @@ export const Either = <R extends Schema.All, L extends Schema.All>({ left, right
|
|
|
7774
7900
|
}): Either<R, L> => {
|
|
7775
7901
|
const right_ = asSchema(right)
|
|
7776
7902
|
const left_ = asSchema(left)
|
|
7777
|
-
|
|
7903
|
+
const out = transform(
|
|
7778
7904
|
eitherEncoded(right_, left_),
|
|
7779
7905
|
EitherFromSelf({ left: typeSchema(left_), right: typeSchema(right_) }),
|
|
7780
7906
|
{
|
|
7781
7907
|
strict: true,
|
|
7782
|
-
decode: eitherDecode,
|
|
7783
|
-
encode:
|
|
7908
|
+
decode: (i) => eitherDecode(i),
|
|
7909
|
+
encode: (a) =>
|
|
7910
|
+
either_.match(a, {
|
|
7911
|
+
onLeft: makeLeftEncoded,
|
|
7912
|
+
onRight: makeRightEncoded
|
|
7913
|
+
})
|
|
7784
7914
|
}
|
|
7785
7915
|
)
|
|
7916
|
+
return out as any
|
|
7786
7917
|
}
|
|
7787
7918
|
|
|
7788
7919
|
/**
|
|
7789
7920
|
* @category api interface
|
|
7790
7921
|
* @since 3.10.0
|
|
7791
7922
|
*/
|
|
7792
|
-
export interface EitherFromUnion<
|
|
7793
|
-
|
|
7794
|
-
|
|
7795
|
-
|
|
7796
|
-
|
|
7797
|
-
|
|
7923
|
+
export interface EitherFromUnion<Right extends Schema.All, Left extends Schema.All> extends
|
|
7924
|
+
transform<
|
|
7925
|
+
Union<[
|
|
7926
|
+
transform<Right, Struct<{ _tag: Literal<["Right"]>; right: SchemaClass<Schema.Type<Right>> }>>,
|
|
7927
|
+
transform<Left, Struct<{ _tag: Literal<["Left"]>; right: SchemaClass<Schema.Type<Left>> }>>
|
|
7928
|
+
]>,
|
|
7929
|
+
EitherFromSelf<SchemaClass<Schema.Type<Right>>, SchemaClass<Schema.Type<Left>>>
|
|
7798
7930
|
>
|
|
7799
7931
|
{}
|
|
7800
7932
|
|
|
@@ -7810,33 +7942,38 @@ export interface EitherFromUnion<R extends Schema.All, L extends Schema.All> ext
|
|
|
7810
7942
|
* @category Either transformations
|
|
7811
7943
|
* @since 3.10.0
|
|
7812
7944
|
*/
|
|
7813
|
-
export const EitherFromUnion = <
|
|
7814
|
-
readonly left:
|
|
7815
|
-
readonly right:
|
|
7816
|
-
}): EitherFromUnion<
|
|
7945
|
+
export const EitherFromUnion = <Right extends Schema.All, Left extends Schema.All>({ left, right }: {
|
|
7946
|
+
readonly left: Left
|
|
7947
|
+
readonly right: Right
|
|
7948
|
+
}): EitherFromUnion<Right, Left> => {
|
|
7817
7949
|
const right_ = asSchema(right)
|
|
7818
7950
|
const left_ = asSchema(left)
|
|
7819
7951
|
const toright = typeSchema(right_)
|
|
7820
7952
|
const toleft = typeSchema(left_)
|
|
7821
7953
|
const fromRight = transform(right_, rightEncoded(toright), {
|
|
7822
7954
|
strict: true,
|
|
7823
|
-
decode: makeRightEncoded,
|
|
7824
|
-
encode: (
|
|
7955
|
+
decode: (i) => makeRightEncoded(i),
|
|
7956
|
+
encode: (a) => a.right
|
|
7825
7957
|
})
|
|
7826
7958
|
const fromLeft = transform(left_, leftEncoded(toleft), {
|
|
7827
7959
|
strict: true,
|
|
7828
|
-
decode: makeLeftEncoded,
|
|
7829
|
-
encode: (
|
|
7960
|
+
decode: (i) => makeLeftEncoded(i),
|
|
7961
|
+
encode: (a) => a.left
|
|
7830
7962
|
})
|
|
7831
|
-
|
|
7963
|
+
const out = transform(
|
|
7832
7964
|
Union(fromRight, fromLeft),
|
|
7833
7965
|
EitherFromSelf({ left: toleft, right: toright }),
|
|
7834
7966
|
{
|
|
7835
7967
|
strict: true,
|
|
7836
|
-
decode: (
|
|
7837
|
-
encode:
|
|
7968
|
+
decode: (i) => i._tag === "Left" ? either_.left(i.left) : either_.right(i.right),
|
|
7969
|
+
encode: (a) =>
|
|
7970
|
+
either_.match(a, {
|
|
7971
|
+
onLeft: makeLeftEncoded,
|
|
7972
|
+
onRight: makeRightEncoded
|
|
7973
|
+
})
|
|
7838
7974
|
}
|
|
7839
7975
|
)
|
|
7976
|
+
return out as any
|
|
7840
7977
|
}
|
|
7841
7978
|
|
|
7842
7979
|
const mapArbitrary = <K, V>(
|
|
@@ -7884,11 +8021,11 @@ const readonlyMapParse = <R, K, V>(
|
|
|
7884
8021
|
* @since 3.10.0
|
|
7885
8022
|
*/
|
|
7886
8023
|
export interface ReadonlyMapFromSelf<K extends Schema.Any, V extends Schema.Any> extends
|
|
7887
|
-
|
|
8024
|
+
AnnotableDeclare<
|
|
7888
8025
|
ReadonlyMapFromSelf<K, V>,
|
|
7889
8026
|
ReadonlyMap<Schema.Type<K>, Schema.Type<V>>,
|
|
7890
8027
|
ReadonlyMap<Schema.Encoded<K>, Schema.Encoded<V>>,
|
|
7891
|
-
|
|
8028
|
+
[K, V]
|
|
7892
8029
|
>
|
|
7893
8030
|
{}
|
|
7894
8031
|
|
|
@@ -7925,11 +8062,11 @@ export const ReadonlyMapFromSelf = <K extends Schema.Any, V extends Schema.Any>(
|
|
|
7925
8062
|
* @since 3.10.0
|
|
7926
8063
|
*/
|
|
7927
8064
|
export interface MapFromSelf<K extends Schema.Any, V extends Schema.Any> extends
|
|
7928
|
-
|
|
8065
|
+
AnnotableDeclare<
|
|
7929
8066
|
MapFromSelf<K, V>,
|
|
7930
8067
|
Map<Schema.Type<K>, Schema.Type<V>>,
|
|
7931
8068
|
ReadonlyMap<Schema.Encoded<K>, Schema.Encoded<V>>,
|
|
7932
|
-
|
|
8069
|
+
[K, V]
|
|
7933
8070
|
>
|
|
7934
8071
|
{}
|
|
7935
8072
|
|
|
@@ -7946,29 +8083,26 @@ export const MapFromSelf = <K extends Schema.Any, V extends Schema.Any>({ key, v
|
|
|
7946
8083
|
* @category api interface
|
|
7947
8084
|
* @since 3.10.0
|
|
7948
8085
|
*/
|
|
7949
|
-
export interface ReadonlyMap$<K extends Schema.Any, V extends Schema.Any>
|
|
7950
|
-
|
|
7951
|
-
ReadonlyMap$<K, V>,
|
|
7952
|
-
ReadonlyMap<Schema.Type<K>, Schema.Type<V>>,
|
|
7953
|
-
ReadonlyArray<readonly [Schema.Encoded<K>, Schema.Encoded<V>]>,
|
|
7954
|
-
Schema.Context<K> | Schema.Context<V>
|
|
7955
|
-
>
|
|
8086
|
+
export interface ReadonlyMap$<K extends Schema.Any, V extends Schema.Any>
|
|
8087
|
+
extends transform<Array$<Tuple2<K, V>>, ReadonlyMapFromSelf<SchemaClass<Schema.Type<K>>, SchemaClass<Schema.Type<V>>>>
|
|
7956
8088
|
{}
|
|
7957
8089
|
|
|
7958
8090
|
/**
|
|
7959
8091
|
* @category ReadonlyMap transformations
|
|
7960
8092
|
* @since 3.10.0
|
|
7961
8093
|
*/
|
|
7962
|
-
export
|
|
8094
|
+
export function ReadonlyMap<K extends Schema.Any, V extends Schema.Any>({ key, value }: {
|
|
7963
8095
|
readonly key: K
|
|
7964
8096
|
readonly value: V
|
|
7965
|
-
}): ReadonlyMap$<K, V>
|
|
7966
|
-
const key_ = asSchema(key)
|
|
7967
|
-
const value_ = asSchema(value)
|
|
8097
|
+
}): ReadonlyMap$<K, V> {
|
|
7968
8098
|
return transform(
|
|
7969
|
-
Array$(Tuple(
|
|
7970
|
-
ReadonlyMapFromSelf({ key: typeSchema(
|
|
7971
|
-
{
|
|
8099
|
+
Array$(Tuple(key, value)),
|
|
8100
|
+
ReadonlyMapFromSelf({ key: typeSchema(asSchema(key)), value: typeSchema(asSchema(value)) }),
|
|
8101
|
+
{
|
|
8102
|
+
strict: true,
|
|
8103
|
+
decode: (i) => new Map(i),
|
|
8104
|
+
encode: (a) => Array.from(a.entries())
|
|
8105
|
+
}
|
|
7972
8106
|
)
|
|
7973
8107
|
}
|
|
7974
8108
|
|
|
@@ -7976,25 +8110,23 @@ export const ReadonlyMap = <K extends Schema.Any, V extends Schema.Any>({ key, v
|
|
|
7976
8110
|
* @category api interface
|
|
7977
8111
|
* @since 3.10.0
|
|
7978
8112
|
*/
|
|
7979
|
-
export interface Map$<K extends Schema.Any, V extends Schema.Any>
|
|
7980
|
-
|
|
7981
|
-
Map$<K, V>,
|
|
7982
|
-
Map<Schema.Type<K>, Schema.Type<V>>,
|
|
7983
|
-
ReadonlyArray<readonly [Schema.Encoded<K>, Schema.Encoded<V>]>,
|
|
7984
|
-
Schema.Context<K> | Schema.Context<V>
|
|
7985
|
-
>
|
|
8113
|
+
export interface Map$<K extends Schema.Any, V extends Schema.Any>
|
|
8114
|
+
extends transform<Array$<Tuple2<K, V>>, MapFromSelf<SchemaClass<Schema.Type<K>>, SchemaClass<Schema.Type<V>>>>
|
|
7986
8115
|
{}
|
|
7987
8116
|
|
|
7988
|
-
|
|
8117
|
+
/** @ignore */
|
|
8118
|
+
function map<K extends Schema.Any, V extends Schema.Any>({ key, value }: {
|
|
7989
8119
|
readonly key: K
|
|
7990
8120
|
readonly value: V
|
|
7991
|
-
}): Map$<K, V>
|
|
7992
|
-
const key_ = asSchema(key)
|
|
7993
|
-
const value_ = asSchema(value)
|
|
8121
|
+
}): Map$<K, V> {
|
|
7994
8122
|
return transform(
|
|
7995
|
-
Array$(Tuple(
|
|
7996
|
-
MapFromSelf({ key: typeSchema(
|
|
7997
|
-
{
|
|
8123
|
+
Array$(Tuple(key, value)),
|
|
8124
|
+
MapFromSelf({ key: typeSchema(asSchema(key)), value: typeSchema(asSchema(value)) }),
|
|
8125
|
+
{
|
|
8126
|
+
strict: true,
|
|
8127
|
+
decode: (i) => new Map(i),
|
|
8128
|
+
encode: (a) => Array.from(a.entries())
|
|
8129
|
+
}
|
|
7998
8130
|
)
|
|
7999
8131
|
}
|
|
8000
8132
|
|
|
@@ -8013,7 +8145,7 @@ export {
|
|
|
8013
8145
|
export const ReadonlyMapFromRecord = <KA, KR, VA, VI, VR>({ key, value }: {
|
|
8014
8146
|
key: Schema<KA, string, KR>
|
|
8015
8147
|
value: Schema<VA, VI, VR>
|
|
8016
|
-
}):
|
|
8148
|
+
}): SchemaClass<ReadonlyMap<KA, VA>, { readonly [x: string]: VI }, KR | VR> =>
|
|
8017
8149
|
transform(
|
|
8018
8150
|
Record({ key: encodedBoundSchema(key), value }).annotations({
|
|
8019
8151
|
description: "a record to be decoded into a ReadonlyMap"
|
|
@@ -8021,8 +8153,8 @@ export const ReadonlyMapFromRecord = <KA, KR, VA, VI, VR>({ key, value }: {
|
|
|
8021
8153
|
ReadonlyMapFromSelf({ key, value: typeSchema(value) }),
|
|
8022
8154
|
{
|
|
8023
8155
|
strict: true,
|
|
8024
|
-
decode: (
|
|
8025
|
-
encode:
|
|
8156
|
+
decode: (i) => new Map(Object.entries(i)),
|
|
8157
|
+
encode: (a) => Object.fromEntries(a)
|
|
8026
8158
|
}
|
|
8027
8159
|
)
|
|
8028
8160
|
|
|
@@ -8033,7 +8165,7 @@ export const ReadonlyMapFromRecord = <KA, KR, VA, VI, VR>({ key, value }: {
|
|
|
8033
8165
|
export const MapFromRecord = <KA, KR, VA, VI, VR>({ key, value }: {
|
|
8034
8166
|
key: Schema<KA, string, KR>
|
|
8035
8167
|
value: Schema<VA, VI, VR>
|
|
8036
|
-
}):
|
|
8168
|
+
}): SchemaClass<Map<KA, VA>, { readonly [x: string]: VI }, KR | VR> =>
|
|
8037
8169
|
transform(
|
|
8038
8170
|
Record({ key: encodedBoundSchema(key), value }).annotations({
|
|
8039
8171
|
description: "a record to be decoded into a Map"
|
|
@@ -8041,8 +8173,8 @@ export const MapFromRecord = <KA, KR, VA, VI, VR>({ key, value }: {
|
|
|
8041
8173
|
MapFromSelf({ key, value: typeSchema(value) }),
|
|
8042
8174
|
{
|
|
8043
8175
|
strict: true,
|
|
8044
|
-
decode: (
|
|
8045
|
-
encode:
|
|
8176
|
+
decode: (i) => new Map(Object.entries(i)),
|
|
8177
|
+
encode: (a) => Object.fromEntries(a)
|
|
8046
8178
|
}
|
|
8047
8179
|
)
|
|
8048
8180
|
|
|
@@ -8075,11 +8207,11 @@ const readonlySetParse = <A, R>(
|
|
|
8075
8207
|
* @since 3.10.0
|
|
8076
8208
|
*/
|
|
8077
8209
|
export interface ReadonlySetFromSelf<Value extends Schema.Any> extends
|
|
8078
|
-
|
|
8210
|
+
AnnotableDeclare<
|
|
8079
8211
|
ReadonlySetFromSelf<Value>,
|
|
8080
8212
|
ReadonlySet<Schema.Type<Value>>,
|
|
8081
8213
|
ReadonlySet<Schema.Encoded<Value>>,
|
|
8082
|
-
|
|
8214
|
+
[Value]
|
|
8083
8215
|
>
|
|
8084
8216
|
{}
|
|
8085
8217
|
|
|
@@ -8110,11 +8242,11 @@ export const ReadonlySetFromSelf = <Value extends Schema.Any>(value: Value): Rea
|
|
|
8110
8242
|
* @since 3.10.0
|
|
8111
8243
|
*/
|
|
8112
8244
|
export interface SetFromSelf<Value extends Schema.Any> extends
|
|
8113
|
-
|
|
8245
|
+
AnnotableDeclare<
|
|
8114
8246
|
SetFromSelf<Value>,
|
|
8115
8247
|
Set<Schema.Type<Value>>,
|
|
8116
8248
|
ReadonlySet<Schema.Encoded<Value>>,
|
|
8117
|
-
|
|
8249
|
+
[Value]
|
|
8118
8250
|
>
|
|
8119
8251
|
{}
|
|
8120
8252
|
|
|
@@ -8129,25 +8261,23 @@ export const SetFromSelf = <Value extends Schema.Any>(value: Value): SetFromSelf
|
|
|
8129
8261
|
* @category api interface
|
|
8130
8262
|
* @since 3.10.0
|
|
8131
8263
|
*/
|
|
8132
|
-
export interface ReadonlySet$<Value extends Schema.Any>
|
|
8133
|
-
|
|
8134
|
-
ReadonlySet$<Value>,
|
|
8135
|
-
ReadonlySet<Schema.Type<Value>>,
|
|
8136
|
-
ReadonlyArray<Schema.Encoded<Value>>,
|
|
8137
|
-
Schema.Context<Value>
|
|
8138
|
-
>
|
|
8264
|
+
export interface ReadonlySet$<Value extends Schema.Any>
|
|
8265
|
+
extends transform<Array$<Value>, ReadonlySetFromSelf<SchemaClass<Schema.Type<Value>>>>
|
|
8139
8266
|
{}
|
|
8140
8267
|
|
|
8141
8268
|
/**
|
|
8142
8269
|
* @category ReadonlySet transformations
|
|
8143
8270
|
* @since 3.10.0
|
|
8144
8271
|
*/
|
|
8145
|
-
export
|
|
8146
|
-
const value_ = asSchema(value)
|
|
8272
|
+
export function ReadonlySet<Value extends Schema.Any>(value: Value): ReadonlySet$<Value> {
|
|
8147
8273
|
return transform(
|
|
8148
|
-
Array$(
|
|
8149
|
-
ReadonlySetFromSelf(typeSchema(
|
|
8150
|
-
{
|
|
8274
|
+
Array$(value),
|
|
8275
|
+
ReadonlySetFromSelf(typeSchema(asSchema(value))),
|
|
8276
|
+
{
|
|
8277
|
+
strict: true,
|
|
8278
|
+
decode: (i) => new Set(i),
|
|
8279
|
+
encode: (a) => Array.from(a)
|
|
8280
|
+
}
|
|
8151
8281
|
)
|
|
8152
8282
|
}
|
|
8153
8283
|
|
|
@@ -8155,21 +8285,20 @@ export const ReadonlySet = <Value extends Schema.Any>(value: Value): ReadonlySet
|
|
|
8155
8285
|
* @category api interface
|
|
8156
8286
|
* @since 3.10.0
|
|
8157
8287
|
*/
|
|
8158
|
-
export interface Set$<Value extends Schema.Any>
|
|
8159
|
-
|
|
8160
|
-
Set$<Value>,
|
|
8161
|
-
Set<Schema.Type<Value>>,
|
|
8162
|
-
ReadonlyArray<Schema.Encoded<Value>>,
|
|
8163
|
-
Schema.Context<Value>
|
|
8164
|
-
>
|
|
8288
|
+
export interface Set$<Value extends Schema.Any>
|
|
8289
|
+
extends transform<Array$<Value>, SetFromSelf<SchemaClass<Schema.Type<Value>>>>
|
|
8165
8290
|
{}
|
|
8166
8291
|
|
|
8167
|
-
|
|
8168
|
-
|
|
8292
|
+
/** @ignore */
|
|
8293
|
+
function set<Value extends Schema.Any>(value: Value): Set$<Value> {
|
|
8169
8294
|
return transform(
|
|
8170
|
-
Array$(
|
|
8171
|
-
SetFromSelf(typeSchema(
|
|
8172
|
-
{
|
|
8295
|
+
Array$(value),
|
|
8296
|
+
SetFromSelf(typeSchema(asSchema(value))),
|
|
8297
|
+
{
|
|
8298
|
+
strict: true,
|
|
8299
|
+
decode: (i) => new Set(i),
|
|
8300
|
+
encode: (a) => Array.from(a)
|
|
8301
|
+
}
|
|
8173
8302
|
)
|
|
8174
8303
|
}
|
|
8175
8304
|
|
|
@@ -8211,13 +8340,13 @@ export class BigDecimal extends transformOrFail(
|
|
|
8211
8340
|
BigDecimalFromSelf,
|
|
8212
8341
|
{
|
|
8213
8342
|
strict: true,
|
|
8214
|
-
decode: (
|
|
8215
|
-
bigDecimal_.fromString(
|
|
8343
|
+
decode: (i, _, ast) =>
|
|
8344
|
+
bigDecimal_.fromString(i).pipe(option_.match({
|
|
8216
8345
|
onNone: () =>
|
|
8217
|
-
ParseResult.fail(new ParseResult.Type(ast,
|
|
8346
|
+
ParseResult.fail(new ParseResult.Type(ast, i, `Unable to decode ${JSON.stringify(i)} into a BigDecimal`)),
|
|
8218
8347
|
onSome: (val) => ParseResult.succeed(bigDecimal_.normalize(val))
|
|
8219
8348
|
})),
|
|
8220
|
-
encode: (
|
|
8349
|
+
encode: (a) => ParseResult.succeed(bigDecimal_.format(bigDecimal_.normalize(a)))
|
|
8221
8350
|
}
|
|
8222
8351
|
).annotations({ identifier: "BigDecimal" }) {}
|
|
8223
8352
|
|
|
@@ -8233,8 +8362,8 @@ export class BigDecimalFromNumber extends transform(
|
|
|
8233
8362
|
BigDecimalFromSelf,
|
|
8234
8363
|
{
|
|
8235
8364
|
strict: true,
|
|
8236
|
-
decode: bigDecimal_.unsafeFromNumber,
|
|
8237
|
-
encode: bigDecimal_.unsafeToNumber
|
|
8365
|
+
decode: (i) => bigDecimal_.unsafeFromNumber(i),
|
|
8366
|
+
encode: (a) => bigDecimal_.unsafeToNumber(a)
|
|
8238
8367
|
}
|
|
8239
8368
|
).annotations({ identifier: "BigDecimalFromNumber" }) {}
|
|
8240
8369
|
|
|
@@ -8248,22 +8377,20 @@ export const GreaterThanBigDecimalSchemaId: unique symbol = Symbol.for("effect/S
|
|
|
8248
8377
|
* @category BigDecimal filters
|
|
8249
8378
|
* @since 3.10.0
|
|
8250
8379
|
*/
|
|
8251
|
-
export const greaterThanBigDecimal =
|
|
8252
|
-
min: bigDecimal_.BigDecimal,
|
|
8253
|
-
|
|
8254
|
-
)
|
|
8255
|
-
|
|
8256
|
-
|
|
8257
|
-
|
|
8258
|
-
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
|
|
8262
|
-
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
)
|
|
8266
|
-
}
|
|
8380
|
+
export const greaterThanBigDecimal =
|
|
8381
|
+
<S extends Schema.Any>(min: bigDecimal_.BigDecimal, annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
8382
|
+
<A extends bigDecimal_.BigDecimal>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> => {
|
|
8383
|
+
const formatted = bigDecimal_.format(min)
|
|
8384
|
+
return self.pipe(
|
|
8385
|
+
filter((a) => bigDecimal_.greaterThan(a, min), {
|
|
8386
|
+
schemaId: GreaterThanBigDecimalSchemaId,
|
|
8387
|
+
[GreaterThanBigDecimalSchemaId]: { min },
|
|
8388
|
+
title: `greaterThanBigDecimal(${formatted})`,
|
|
8389
|
+
description: `a BigDecimal greater than ${formatted}`,
|
|
8390
|
+
...annotations
|
|
8391
|
+
})
|
|
8392
|
+
)
|
|
8393
|
+
}
|
|
8267
8394
|
|
|
8268
8395
|
/**
|
|
8269
8396
|
* @category schema id
|
|
@@ -8277,22 +8404,20 @@ export const GreaterThanOrEqualToBigDecimalSchemaId: unique symbol = Symbol.for(
|
|
|
8277
8404
|
* @category BigDecimal filters
|
|
8278
8405
|
* @since 3.10.0
|
|
8279
8406
|
*/
|
|
8280
|
-
export const greaterThanOrEqualToBigDecimal =
|
|
8281
|
-
min: bigDecimal_.BigDecimal,
|
|
8282
|
-
|
|
8283
|
-
)
|
|
8284
|
-
|
|
8285
|
-
|
|
8286
|
-
|
|
8287
|
-
|
|
8288
|
-
|
|
8289
|
-
|
|
8290
|
-
|
|
8291
|
-
|
|
8292
|
-
|
|
8293
|
-
|
|
8294
|
-
)
|
|
8295
|
-
}
|
|
8407
|
+
export const greaterThanOrEqualToBigDecimal =
|
|
8408
|
+
<S extends Schema.Any>(min: bigDecimal_.BigDecimal, annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
8409
|
+
<A extends bigDecimal_.BigDecimal>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> => {
|
|
8410
|
+
const formatted = bigDecimal_.format(min)
|
|
8411
|
+
return self.pipe(
|
|
8412
|
+
filter((a) => bigDecimal_.greaterThanOrEqualTo(a, min), {
|
|
8413
|
+
schemaId: GreaterThanOrEqualToBigDecimalSchemaId,
|
|
8414
|
+
[GreaterThanOrEqualToBigDecimalSchemaId]: { min },
|
|
8415
|
+
title: `greaterThanOrEqualToBigDecimal(${formatted})`,
|
|
8416
|
+
description: `a BigDecimal greater than or equal to ${formatted}`,
|
|
8417
|
+
...annotations
|
|
8418
|
+
})
|
|
8419
|
+
)
|
|
8420
|
+
}
|
|
8296
8421
|
|
|
8297
8422
|
/**
|
|
8298
8423
|
* @category schema id
|
|
@@ -8304,22 +8429,20 @@ export const LessThanBigDecimalSchemaId: unique symbol = Symbol.for("effect/Sche
|
|
|
8304
8429
|
* @category BigDecimal filters
|
|
8305
8430
|
* @since 3.10.0
|
|
8306
8431
|
*/
|
|
8307
|
-
export const lessThanBigDecimal =
|
|
8308
|
-
max: bigDecimal_.BigDecimal,
|
|
8309
|
-
|
|
8310
|
-
)
|
|
8311
|
-
|
|
8312
|
-
|
|
8313
|
-
|
|
8314
|
-
|
|
8315
|
-
|
|
8316
|
-
|
|
8317
|
-
|
|
8318
|
-
|
|
8319
|
-
|
|
8320
|
-
|
|
8321
|
-
)
|
|
8322
|
-
}
|
|
8432
|
+
export const lessThanBigDecimal =
|
|
8433
|
+
<S extends Schema.Any>(max: bigDecimal_.BigDecimal, annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
8434
|
+
<A extends bigDecimal_.BigDecimal>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> => {
|
|
8435
|
+
const formatted = bigDecimal_.format(max)
|
|
8436
|
+
return self.pipe(
|
|
8437
|
+
filter((a) => bigDecimal_.lessThan(a, max), {
|
|
8438
|
+
schemaId: LessThanBigDecimalSchemaId,
|
|
8439
|
+
[LessThanBigDecimalSchemaId]: { max },
|
|
8440
|
+
title: `lessThanBigDecimal(${formatted})`,
|
|
8441
|
+
description: `a BigDecimal less than ${formatted}`,
|
|
8442
|
+
...annotations
|
|
8443
|
+
})
|
|
8444
|
+
)
|
|
8445
|
+
}
|
|
8323
8446
|
|
|
8324
8447
|
/**
|
|
8325
8448
|
* @category schema id
|
|
@@ -8333,22 +8456,20 @@ export const LessThanOrEqualToBigDecimalSchemaId: unique symbol = Symbol.for(
|
|
|
8333
8456
|
* @category BigDecimal filters
|
|
8334
8457
|
* @since 3.10.0
|
|
8335
8458
|
*/
|
|
8336
|
-
export const lessThanOrEqualToBigDecimal =
|
|
8337
|
-
max: bigDecimal_.BigDecimal,
|
|
8338
|
-
|
|
8339
|
-
)
|
|
8340
|
-
|
|
8341
|
-
|
|
8342
|
-
|
|
8343
|
-
|
|
8344
|
-
|
|
8345
|
-
|
|
8346
|
-
|
|
8347
|
-
|
|
8348
|
-
|
|
8349
|
-
|
|
8350
|
-
)
|
|
8351
|
-
}
|
|
8459
|
+
export const lessThanOrEqualToBigDecimal =
|
|
8460
|
+
<S extends Schema.Any>(max: bigDecimal_.BigDecimal, annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
8461
|
+
<A extends bigDecimal_.BigDecimal>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> => {
|
|
8462
|
+
const formatted = bigDecimal_.format(max)
|
|
8463
|
+
return self.pipe(
|
|
8464
|
+
filter((a) => bigDecimal_.lessThanOrEqualTo(a, max), {
|
|
8465
|
+
schemaId: LessThanOrEqualToBigDecimalSchemaId,
|
|
8466
|
+
[LessThanOrEqualToBigDecimalSchemaId]: { max },
|
|
8467
|
+
title: `lessThanOrEqualToBigDecimal(${formatted})`,
|
|
8468
|
+
description: `a BigDecimal less than or equal to ${formatted}`,
|
|
8469
|
+
...annotations
|
|
8470
|
+
})
|
|
8471
|
+
)
|
|
8472
|
+
}
|
|
8352
8473
|
|
|
8353
8474
|
/**
|
|
8354
8475
|
* @category schema id
|
|
@@ -8362,18 +8483,17 @@ export const PositiveBigDecimalSchemaId: unique symbol = Symbol.for(
|
|
|
8362
8483
|
* @category BigDecimal filters
|
|
8363
8484
|
* @since 3.10.0
|
|
8364
8485
|
*/
|
|
8365
|
-
export const positiveBigDecimal =
|
|
8366
|
-
annotations?: Annotations.Filter<
|
|
8367
|
-
) =>
|
|
8368
|
-
|
|
8369
|
-
|
|
8370
|
-
|
|
8371
|
-
|
|
8372
|
-
|
|
8373
|
-
|
|
8374
|
-
|
|
8375
|
-
|
|
8376
|
-
)
|
|
8486
|
+
export const positiveBigDecimal =
|
|
8487
|
+
<S extends Schema.Any>(annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
8488
|
+
<A extends bigDecimal_.BigDecimal>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
8489
|
+
self.pipe(
|
|
8490
|
+
filter((a) => bigDecimal_.isPositive(a), {
|
|
8491
|
+
schemaId: PositiveBigDecimalSchemaId,
|
|
8492
|
+
title: "positiveBigDecimal",
|
|
8493
|
+
description: `a positive BigDecimal`,
|
|
8494
|
+
...annotations
|
|
8495
|
+
})
|
|
8496
|
+
)
|
|
8377
8497
|
|
|
8378
8498
|
/**
|
|
8379
8499
|
* @category BigDecimal constructors
|
|
@@ -8395,18 +8515,17 @@ export const NonNegativeBigDecimalSchemaId: unique symbol = Symbol.for(
|
|
|
8395
8515
|
* @category BigDecimal filters
|
|
8396
8516
|
* @since 3.10.0
|
|
8397
8517
|
*/
|
|
8398
|
-
export const nonNegativeBigDecimal =
|
|
8399
|
-
annotations?: Annotations.Filter<
|
|
8400
|
-
) =>
|
|
8401
|
-
|
|
8402
|
-
|
|
8403
|
-
|
|
8404
|
-
|
|
8405
|
-
|
|
8406
|
-
|
|
8407
|
-
|
|
8408
|
-
|
|
8409
|
-
)
|
|
8518
|
+
export const nonNegativeBigDecimal =
|
|
8519
|
+
<S extends Schema.Any>(annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
8520
|
+
<A extends bigDecimal_.BigDecimal>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
8521
|
+
self.pipe(
|
|
8522
|
+
filter((a) => a.value >= 0n, {
|
|
8523
|
+
schemaId: NonNegativeBigDecimalSchemaId,
|
|
8524
|
+
title: "nonNegativeBigDecimal",
|
|
8525
|
+
description: `a non-negative BigDecimal`,
|
|
8526
|
+
...annotations
|
|
8527
|
+
})
|
|
8528
|
+
)
|
|
8410
8529
|
|
|
8411
8530
|
/**
|
|
8412
8531
|
* @category BigDecimal constructors
|
|
@@ -8428,18 +8547,17 @@ export const NegativeBigDecimalSchemaId: unique symbol = Symbol.for(
|
|
|
8428
8547
|
* @category BigDecimal filters
|
|
8429
8548
|
* @since 3.10.0
|
|
8430
8549
|
*/
|
|
8431
|
-
export const negativeBigDecimal =
|
|
8432
|
-
annotations?: Annotations.Filter<
|
|
8433
|
-
) =>
|
|
8434
|
-
|
|
8435
|
-
|
|
8436
|
-
|
|
8437
|
-
|
|
8438
|
-
|
|
8439
|
-
|
|
8440
|
-
|
|
8441
|
-
|
|
8442
|
-
)
|
|
8550
|
+
export const negativeBigDecimal =
|
|
8551
|
+
<S extends Schema.Any>(annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
8552
|
+
<A extends bigDecimal_.BigDecimal>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
8553
|
+
self.pipe(
|
|
8554
|
+
filter((a) => bigDecimal_.isNegative(a), {
|
|
8555
|
+
schemaId: NegativeBigDecimalSchemaId,
|
|
8556
|
+
title: "negativeBigDecimal",
|
|
8557
|
+
description: `a negative BigDecimal`,
|
|
8558
|
+
...annotations
|
|
8559
|
+
})
|
|
8560
|
+
)
|
|
8443
8561
|
|
|
8444
8562
|
/**
|
|
8445
8563
|
* @category BigDecimal constructors
|
|
@@ -8461,18 +8579,17 @@ export const NonPositiveBigDecimalSchemaId: unique symbol = Symbol.for(
|
|
|
8461
8579
|
* @category BigDecimal filters
|
|
8462
8580
|
* @since 3.10.0
|
|
8463
8581
|
*/
|
|
8464
|
-
export const nonPositiveBigDecimal =
|
|
8465
|
-
annotations?: Annotations.Filter<
|
|
8466
|
-
) =>
|
|
8467
|
-
|
|
8468
|
-
|
|
8469
|
-
|
|
8470
|
-
|
|
8471
|
-
|
|
8472
|
-
|
|
8473
|
-
|
|
8474
|
-
|
|
8475
|
-
)
|
|
8582
|
+
export const nonPositiveBigDecimal =
|
|
8583
|
+
<S extends Schema.Any>(annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
8584
|
+
<A extends bigDecimal_.BigDecimal>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
8585
|
+
self.pipe(
|
|
8586
|
+
filter((a) => a.value <= 0n, {
|
|
8587
|
+
schemaId: NonPositiveBigDecimalSchemaId,
|
|
8588
|
+
title: "nonPositiveBigDecimal",
|
|
8589
|
+
description: `a non-positive BigDecimal`,
|
|
8590
|
+
...annotations
|
|
8591
|
+
})
|
|
8592
|
+
)
|
|
8476
8593
|
|
|
8477
8594
|
/**
|
|
8478
8595
|
* @category BigDecimal constructors
|
|
@@ -8492,12 +8609,12 @@ export const BetweenBigDecimalSchemaId: unique symbol = Symbol.for("effect/Schem
|
|
|
8492
8609
|
* @category BigDecimal filters
|
|
8493
8610
|
* @since 3.10.0
|
|
8494
8611
|
*/
|
|
8495
|
-
export const betweenBigDecimal = <
|
|
8612
|
+
export const betweenBigDecimal = <S extends Schema.Any>(
|
|
8496
8613
|
minimum: bigDecimal_.BigDecimal,
|
|
8497
8614
|
maximum: bigDecimal_.BigDecimal,
|
|
8498
|
-
annotations?: Annotations.Filter<
|
|
8615
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
8499
8616
|
) =>
|
|
8500
|
-
<
|
|
8617
|
+
<A extends bigDecimal_.BigDecimal>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> => {
|
|
8501
8618
|
const formattedMinimum = bigDecimal_.format(minimum)
|
|
8502
8619
|
const formattedMaximum = bigDecimal_.format(maximum)
|
|
8503
8620
|
return self.pipe(
|
|
@@ -8519,11 +8636,17 @@ export const betweenBigDecimal = <A extends bigDecimal_.BigDecimal>(
|
|
|
8519
8636
|
*/
|
|
8520
8637
|
export const clampBigDecimal =
|
|
8521
8638
|
(minimum: bigDecimal_.BigDecimal, maximum: bigDecimal_.BigDecimal) =>
|
|
8522
|
-
<
|
|
8639
|
+
<S extends Schema.Any, A extends bigDecimal_.BigDecimal>(
|
|
8640
|
+
self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>
|
|
8641
|
+
): transform<S, filter<SchemaClass<A>>> =>
|
|
8523
8642
|
transform(
|
|
8524
8643
|
self,
|
|
8525
8644
|
self.pipe(typeSchema, betweenBigDecimal(minimum, maximum)),
|
|
8526
|
-
{
|
|
8645
|
+
{
|
|
8646
|
+
strict: false,
|
|
8647
|
+
decode: (i) => bigDecimal_.clamp(i, { minimum, maximum }),
|
|
8648
|
+
encode: identity
|
|
8649
|
+
}
|
|
8527
8650
|
)
|
|
8528
8651
|
|
|
8529
8652
|
const chunkArbitrary =
|
|
@@ -8550,11 +8673,11 @@ const chunkParse = <A, R>(
|
|
|
8550
8673
|
* @since 3.10.0
|
|
8551
8674
|
*/
|
|
8552
8675
|
export interface ChunkFromSelf<Value extends Schema.Any> extends
|
|
8553
|
-
|
|
8676
|
+
AnnotableDeclare<
|
|
8554
8677
|
ChunkFromSelf<Value>,
|
|
8555
8678
|
chunk_.Chunk<Schema.Type<Value>>,
|
|
8556
8679
|
chunk_.Chunk<Schema.Encoded<Value>>,
|
|
8557
|
-
|
|
8680
|
+
[Value]
|
|
8558
8681
|
>
|
|
8559
8682
|
{}
|
|
8560
8683
|
|
|
@@ -8582,28 +8705,22 @@ export const ChunkFromSelf = <Value extends Schema.Any>(value: Value): ChunkFrom
|
|
|
8582
8705
|
* @category api interface
|
|
8583
8706
|
* @since 3.10.0
|
|
8584
8707
|
*/
|
|
8585
|
-
export interface Chunk<Value extends Schema.Any>
|
|
8586
|
-
|
|
8587
|
-
Chunk<Value>,
|
|
8588
|
-
chunk_.Chunk<Schema.Type<Value>>,
|
|
8589
|
-
ReadonlyArray<Schema.Encoded<Value>>,
|
|
8590
|
-
Schema.Context<Value>
|
|
8591
|
-
>
|
|
8708
|
+
export interface Chunk<Value extends Schema.Any>
|
|
8709
|
+
extends transform<Array$<Value>, ChunkFromSelf<SchemaClass<Schema.Type<Value>>>>
|
|
8592
8710
|
{}
|
|
8593
8711
|
|
|
8594
8712
|
/**
|
|
8595
8713
|
* @category Chunk transformations
|
|
8596
8714
|
* @since 3.10.0
|
|
8597
8715
|
*/
|
|
8598
|
-
export
|
|
8599
|
-
const value_ = asSchema(value)
|
|
8716
|
+
export function Chunk<Value extends Schema.Any>(value: Value): Chunk<Value> {
|
|
8600
8717
|
return transform(
|
|
8601
|
-
Array$(
|
|
8602
|
-
ChunkFromSelf(typeSchema(
|
|
8718
|
+
Array$(value),
|
|
8719
|
+
ChunkFromSelf(typeSchema(asSchema(value))),
|
|
8603
8720
|
{
|
|
8604
8721
|
strict: true,
|
|
8605
|
-
decode: (
|
|
8606
|
-
encode: chunk_.toReadonlyArray
|
|
8722
|
+
decode: (i) => i.length === 0 ? chunk_.empty() : chunk_.fromIterable(i),
|
|
8723
|
+
encode: (a) => chunk_.toReadonlyArray(a)
|
|
8607
8724
|
}
|
|
8608
8725
|
)
|
|
8609
8726
|
}
|
|
@@ -8613,11 +8730,11 @@ export const Chunk = <Value extends Schema.Any>(value: Value): Chunk<Value> => {
|
|
|
8613
8730
|
* @since 3.10.0
|
|
8614
8731
|
*/
|
|
8615
8732
|
export interface NonEmptyChunkFromSelf<Value extends Schema.Any> extends
|
|
8616
|
-
|
|
8733
|
+
AnnotableDeclare<
|
|
8617
8734
|
NonEmptyChunkFromSelf<Value>,
|
|
8618
8735
|
chunk_.NonEmptyChunk<Schema.Type<Value>>,
|
|
8619
8736
|
chunk_.NonEmptyChunk<Schema.Encoded<Value>>,
|
|
8620
|
-
|
|
8737
|
+
[Value]
|
|
8621
8738
|
>
|
|
8622
8739
|
{}
|
|
8623
8740
|
|
|
@@ -8659,89 +8776,116 @@ export const NonEmptyChunkFromSelf = <Value extends Schema.Any>(value: Value): N
|
|
|
8659
8776
|
* @category api interface
|
|
8660
8777
|
* @since 3.10.0
|
|
8661
8778
|
*/
|
|
8662
|
-
export interface NonEmptyChunk<Value extends Schema.Any>
|
|
8663
|
-
|
|
8664
|
-
NonEmptyChunk<Value>,
|
|
8665
|
-
chunk_.NonEmptyChunk<Schema.Type<Value>>,
|
|
8666
|
-
array_.NonEmptyReadonlyArray<Schema.Encoded<Value>>,
|
|
8667
|
-
Schema.Context<Value>
|
|
8668
|
-
>
|
|
8779
|
+
export interface NonEmptyChunk<Value extends Schema.Any>
|
|
8780
|
+
extends transform<NonEmptyArray<Value>, NonEmptyChunkFromSelf<SchemaClass<Schema.Type<Value>>>>
|
|
8669
8781
|
{}
|
|
8670
8782
|
|
|
8671
8783
|
/**
|
|
8672
8784
|
* @category Chunk transformations
|
|
8673
8785
|
* @since 3.10.0
|
|
8674
8786
|
*/
|
|
8675
|
-
export
|
|
8676
|
-
const value_ = asSchema(value)
|
|
8787
|
+
export function NonEmptyChunk<Value extends Schema.Any>(value: Value): NonEmptyChunk<Value> {
|
|
8677
8788
|
return transform(
|
|
8678
|
-
NonEmptyArray(
|
|
8679
|
-
NonEmptyChunkFromSelf(typeSchema(
|
|
8680
|
-
{
|
|
8789
|
+
NonEmptyArray(value),
|
|
8790
|
+
NonEmptyChunkFromSelf(typeSchema(asSchema(value))),
|
|
8791
|
+
{
|
|
8792
|
+
strict: true,
|
|
8793
|
+
decode: (i) => chunk_.unsafeFromNonEmptyArray(i),
|
|
8794
|
+
encode: (a) => chunk_.toReadonlyArray(a)
|
|
8795
|
+
}
|
|
8681
8796
|
)
|
|
8682
8797
|
}
|
|
8683
8798
|
|
|
8684
|
-
const
|
|
8799
|
+
const decodeData = <A extends Readonly<Record<string, unknown>> | ReadonlyArray<unknown>>(a: A): A =>
|
|
8685
8800
|
Array.isArray(a) ? data_.array(a) : data_.struct(a)
|
|
8686
8801
|
|
|
8687
|
-
const dataArbitrary = <A extends Readonly<Record<string,
|
|
8802
|
+
const dataArbitrary = <A extends Readonly<Record<string, unknown>> | ReadonlyArray<unknown>>(
|
|
8688
8803
|
item: LazyArbitrary<A>
|
|
8689
8804
|
): LazyArbitrary<A> =>
|
|
8690
|
-
(fc) => item(fc).map(
|
|
8805
|
+
(fc) => item(fc).map(decodeData)
|
|
8691
8806
|
|
|
8692
|
-
const dataPretty = <A extends Readonly<Record<string,
|
|
8807
|
+
const dataPretty = <A extends Readonly<Record<string, unknown>> | ReadonlyArray<unknown>>(
|
|
8693
8808
|
item: pretty_.Pretty<A>
|
|
8694
8809
|
): pretty_.Pretty<A> =>
|
|
8695
8810
|
(d) => `Data(${item(d)})`
|
|
8696
8811
|
|
|
8697
|
-
const dataParse = <R, A extends Readonly<Record<string,
|
|
8812
|
+
const dataParse = <R, A extends Readonly<Record<string, unknown>> | ReadonlyArray<unknown>>(
|
|
8698
8813
|
decodeUnknown: ParseResult.DecodeUnknown<A, R>
|
|
8699
8814
|
): ParseResult.DeclarationDecodeUnknown<A, R> =>
|
|
8700
8815
|
(u, options, ast) =>
|
|
8701
8816
|
Equal.isEqual(u) ?
|
|
8702
|
-
toComposite(decodeUnknown(u, options),
|
|
8817
|
+
toComposite(decodeUnknown(u, options), decodeData, ast, u)
|
|
8703
8818
|
: ParseResult.fail(new ParseResult.Type(ast, u))
|
|
8704
8819
|
|
|
8705
8820
|
/**
|
|
8821
|
+
* @category api interface
|
|
8822
|
+
* @since 3.13.3
|
|
8823
|
+
*/
|
|
8824
|
+
export interface DataFromSelf<Value extends Schema.Any> extends
|
|
8825
|
+
AnnotableDeclare<
|
|
8826
|
+
DataFromSelf<Value>,
|
|
8827
|
+
Schema.Type<Value>,
|
|
8828
|
+
Schema.Encoded<Value>,
|
|
8829
|
+
[Value]
|
|
8830
|
+
>
|
|
8831
|
+
{}
|
|
8832
|
+
|
|
8833
|
+
/**
|
|
8834
|
+
* Type and Encoded must extend `Readonly<Record<string, any>> |
|
|
8835
|
+
* ReadonlyArray<any>` to be compatible with this API.
|
|
8836
|
+
*
|
|
8706
8837
|
* @category Data transformations
|
|
8707
8838
|
* @since 3.10.0
|
|
8708
8839
|
*/
|
|
8709
8840
|
export const DataFromSelf = <
|
|
8710
|
-
|
|
8711
|
-
|
|
8712
|
-
|
|
8713
|
-
>(
|
|
8714
|
-
|
|
8715
|
-
|
|
8716
|
-
declare(
|
|
8717
|
-
[item],
|
|
8841
|
+
S extends Schema.Any,
|
|
8842
|
+
A extends Readonly<Record<string, unknown>> | ReadonlyArray<unknown>,
|
|
8843
|
+
I extends Readonly<Record<string, unknown>> | ReadonlyArray<unknown>
|
|
8844
|
+
>(value: S & Schema<A & Schema.Type<S>, I & Schema.Encoded<S>, Schema.Context<S>>): DataFromSelf<S> => {
|
|
8845
|
+
return declare(
|
|
8846
|
+
[value],
|
|
8718
8847
|
{
|
|
8719
8848
|
decode: (item) => dataParse(ParseResult.decodeUnknown(item)),
|
|
8720
8849
|
encode: (item) => dataParse(ParseResult.encodeUnknown(item))
|
|
8721
8850
|
},
|
|
8722
8851
|
{
|
|
8723
|
-
description: `Data<${format(
|
|
8852
|
+
description: `Data<${format(value)}>`,
|
|
8724
8853
|
pretty: dataPretty,
|
|
8725
8854
|
arbitrary: dataArbitrary
|
|
8726
8855
|
}
|
|
8727
8856
|
)
|
|
8857
|
+
}
|
|
8728
8858
|
|
|
8729
8859
|
/**
|
|
8860
|
+
* @category api interface
|
|
8861
|
+
* @since 3.13.3
|
|
8862
|
+
*/
|
|
8863
|
+
export interface Data<Value extends Schema.Any>
|
|
8864
|
+
extends transform<Value, DataFromSelf<SchemaClass<Schema.Type<Value>>>>
|
|
8865
|
+
{}
|
|
8866
|
+
|
|
8867
|
+
/**
|
|
8868
|
+
* Type and Encoded must extend `Readonly<Record<string, any>> |
|
|
8869
|
+
* ReadonlyArray<any>` to be compatible with this API.
|
|
8870
|
+
*
|
|
8730
8871
|
* @category Data transformations
|
|
8731
8872
|
* @since 3.10.0
|
|
8732
8873
|
*/
|
|
8733
8874
|
export const Data = <
|
|
8734
|
-
|
|
8735
|
-
|
|
8736
|
-
|
|
8737
|
-
>(
|
|
8738
|
-
|
|
8739
|
-
|
|
8740
|
-
|
|
8741
|
-
|
|
8742
|
-
|
|
8743
|
-
|
|
8875
|
+
S extends Schema.Any,
|
|
8876
|
+
A extends Readonly<Record<string, unknown>> | ReadonlyArray<unknown>,
|
|
8877
|
+
I extends Readonly<Record<string, unknown>> | ReadonlyArray<unknown>
|
|
8878
|
+
>(value: S & Schema<A & Schema.Type<S>, I & Schema.Encoded<S>, Schema.Context<S>>): Data<S> => {
|
|
8879
|
+
return transform(
|
|
8880
|
+
value,
|
|
8881
|
+
DataFromSelf(typeSchema(value)),
|
|
8882
|
+
{
|
|
8883
|
+
strict: false,
|
|
8884
|
+
decode: (i) => decodeData(i),
|
|
8885
|
+
encode: (a) => Array.isArray(a) ? Array.from(a) : Object.assign({}, a)
|
|
8886
|
+
}
|
|
8744
8887
|
)
|
|
8888
|
+
}
|
|
8745
8889
|
|
|
8746
8890
|
type MissingSelfGeneric<Usage extends string, Params extends string = ""> =
|
|
8747
8891
|
`Missing \`Self\` generic - use \`class Self extends ${Usage}<Self>()(${Params}{ ... })\``
|
|
@@ -8805,7 +8949,7 @@ export interface Class<Self, Fields extends Struct.Fields, I, R, C, Inherited, P
|
|
|
8805
8949
|
*/
|
|
8806
8950
|
extend<Extended = never>(identifier: string): <NewFields extends Struct.Fields>(
|
|
8807
8951
|
fields: NewFields | HasFields<NewFields>,
|
|
8808
|
-
annotations?: ClassAnnotations<Extended, Struct.Type<Fields & NewFields
|
|
8952
|
+
annotations?: ClassAnnotations<Extended, Simplify<Struct.Type<Fields & NewFields>>>
|
|
8809
8953
|
) => [Extended] extends [never] ? MissingSelfGeneric<"Base.extend">
|
|
8810
8954
|
: Class<
|
|
8811
8955
|
Extended,
|
|
@@ -8864,7 +9008,7 @@ export interface Class<Self, Fields extends Struct.Fields, I, R, C, Inherited, P
|
|
|
8864
9008
|
ast: AST.Transformation
|
|
8865
9009
|
) => Effect.Effect<Struct.Type<Fields>, ParseResult.ParseIssue, R3>
|
|
8866
9010
|
},
|
|
8867
|
-
annotations?: ClassAnnotations<Transformed, Struct.Type<Fields & NewFields
|
|
9011
|
+
annotations?: ClassAnnotations<Transformed, Simplify<Struct.Type<Fields & NewFields>>>
|
|
8868
9012
|
) => [Transformed] extends [never] ? MissingSelfGeneric<"Base.transformOrFail">
|
|
8869
9013
|
: Class<
|
|
8870
9014
|
Transformed,
|
|
@@ -8923,7 +9067,7 @@ export interface Class<Self, Fields extends Struct.Fields, I, R, C, Inherited, P
|
|
|
8923
9067
|
ast: AST.Transformation
|
|
8924
9068
|
) => Effect.Effect<I, ParseResult.ParseIssue, R3>
|
|
8925
9069
|
},
|
|
8926
|
-
annotations?: ClassAnnotations<Transformed, Struct.Type<Fields & NewFields
|
|
9070
|
+
annotations?: ClassAnnotations<Transformed, Simplify<Struct.Type<Fields & NewFields>>>
|
|
8927
9071
|
) => [Transformed] extends [never] ? MissingSelfGeneric<"Base.transformOrFailFrom">
|
|
8928
9072
|
: Class<
|
|
8929
9073
|
Transformed,
|
|
@@ -8974,7 +9118,7 @@ const getFieldsFromFieldsOr = <Fields extends Struct.Fields>(fieldsOr: Fields |
|
|
|
8974
9118
|
export const Class = <Self = never>(identifier: string) =>
|
|
8975
9119
|
<Fields extends Struct.Fields>(
|
|
8976
9120
|
fieldsOr: Fields | HasFields<Fields>,
|
|
8977
|
-
annotations?: ClassAnnotations<Self, Struct.Type<Fields
|
|
9121
|
+
annotations?: ClassAnnotations<Self, Simplify<Struct.Type<Fields>>>
|
|
8978
9122
|
): [Self] extends [never] ? MissingSelfGeneric<"Class">
|
|
8979
9123
|
: Class<
|
|
8980
9124
|
Self,
|
|
@@ -9033,7 +9177,7 @@ export const TaggedClass = <Self = never>(identifier?: string) =>
|
|
|
9033
9177
|
<Tag extends string, Fields extends Struct.Fields>(
|
|
9034
9178
|
tag: Tag,
|
|
9035
9179
|
fieldsOr: Fields | HasFields<Fields>,
|
|
9036
|
-
annotations?: ClassAnnotations<Self, Struct.Type<{ readonly _tag: tag<Tag> } & Fields
|
|
9180
|
+
annotations?: ClassAnnotations<Self, Simplify<Struct.Type<{ readonly _tag: tag<Tag> } & Fields>>>
|
|
9037
9181
|
): [Self] extends [never] ? MissingSelfGeneric<"TaggedClass", `"Tag", `>
|
|
9038
9182
|
: TaggedClass<Self, Tag, { readonly _tag: tag<Tag> } & Fields> =>
|
|
9039
9183
|
{
|
|
@@ -9096,7 +9240,7 @@ export const TaggedError = <Self = never>(identifier?: string) =>
|
|
|
9096
9240
|
<Tag extends string, Fields extends Struct.Fields>(
|
|
9097
9241
|
tag: Tag,
|
|
9098
9242
|
fieldsOr: Fields | HasFields<Fields>,
|
|
9099
|
-
annotations?: ClassAnnotations<Self, Struct.Type<{ readonly _tag: tag<Tag> } & Fields
|
|
9243
|
+
annotations?: ClassAnnotations<Self, Simplify<Struct.Type<{ readonly _tag: tag<Tag> } & Fields>>>
|
|
9100
9244
|
): [Self] extends [never] ? MissingSelfGeneric<"TaggedError", `"Tag", `>
|
|
9101
9245
|
: TaggedErrorClass<
|
|
9102
9246
|
Self,
|
|
@@ -9140,7 +9284,8 @@ const extendFields = (a: Struct.Fields, b: Struct.Fields): Struct.Fields => {
|
|
|
9140
9284
|
return out
|
|
9141
9285
|
}
|
|
9142
9286
|
|
|
9143
|
-
|
|
9287
|
+
/** @internal */
|
|
9288
|
+
export type MakeOptions = boolean | {
|
|
9144
9289
|
readonly disableValidation?: boolean
|
|
9145
9290
|
}
|
|
9146
9291
|
|
|
@@ -9265,7 +9410,11 @@ const makeClass = <Fields extends Struct.Fields>(
|
|
|
9265
9410
|
out = transform(
|
|
9266
9411
|
encodedSide,
|
|
9267
9412
|
declaration,
|
|
9268
|
-
{
|
|
9413
|
+
{
|
|
9414
|
+
strict: true,
|
|
9415
|
+
decode: (i) => new this(i, true),
|
|
9416
|
+
encode: identity
|
|
9417
|
+
}
|
|
9269
9418
|
).annotations({
|
|
9270
9419
|
[AST.SurrogateAnnotationId]: transformationSurrogate.ast,
|
|
9271
9420
|
...transformationAnnotations
|
|
@@ -9303,7 +9452,7 @@ const makeClass = <Fields extends Struct.Fields>(
|
|
|
9303
9452
|
static extend<Extended, NewFields extends Struct.Fields>(identifier: string) {
|
|
9304
9453
|
return (
|
|
9305
9454
|
newFieldsOr: NewFields | HasFields<NewFields>,
|
|
9306
|
-
annotations?: ClassAnnotations<Extended, Struct.Type<Fields & NewFields
|
|
9455
|
+
annotations?: ClassAnnotations<Extended, Simplify<Struct.Type<Fields & NewFields>>>
|
|
9307
9456
|
) => {
|
|
9308
9457
|
const newFields = getFieldsFromFieldsOr(newFieldsOr)
|
|
9309
9458
|
const newSchema = getSchemaFromFieldsOr(newFieldsOr)
|
|
@@ -9323,7 +9472,7 @@ const makeClass = <Fields extends Struct.Fields>(
|
|
|
9323
9472
|
return (
|
|
9324
9473
|
newFieldsOr: NewFields,
|
|
9325
9474
|
options: any,
|
|
9326
|
-
annotations?: ClassAnnotations<Transformed, Struct.Type<Fields & NewFields
|
|
9475
|
+
annotations?: ClassAnnotations<Transformed, Simplify<Struct.Type<Fields & NewFields>>>
|
|
9327
9476
|
) => {
|
|
9328
9477
|
const transformedFields: Struct.Fields = extendFields(fields, newFieldsOr)
|
|
9329
9478
|
return makeClass({
|
|
@@ -9345,7 +9494,7 @@ const makeClass = <Fields extends Struct.Fields>(
|
|
|
9345
9494
|
return (
|
|
9346
9495
|
newFields: NewFields,
|
|
9347
9496
|
options: any,
|
|
9348
|
-
annotations?: ClassAnnotations<Transformed, Struct.Type<Fields & NewFields
|
|
9497
|
+
annotations?: ClassAnnotations<Transformed, Simplify<Struct.Type<Fields & NewFields>>>
|
|
9349
9498
|
) => {
|
|
9350
9499
|
const transformedFields: Struct.Fields = extendFields(fields, newFields)
|
|
9351
9500
|
return makeClass({
|
|
@@ -9491,7 +9640,11 @@ const fiberIdEncode = (input: fiberId_.FiberId): FiberIdEncoded => {
|
|
|
9491
9640
|
export class FiberId extends transform(
|
|
9492
9641
|
FiberIdEncoded,
|
|
9493
9642
|
FiberIdFromSelf,
|
|
9494
|
-
{
|
|
9643
|
+
{
|
|
9644
|
+
strict: true,
|
|
9645
|
+
decode: (i) => fiberIdDecode(i),
|
|
9646
|
+
encode: (a) => fiberIdEncode(a)
|
|
9647
|
+
}
|
|
9495
9648
|
).annotations({ identifier: "FiberId" }) {}
|
|
9496
9649
|
|
|
9497
9650
|
/**
|
|
@@ -9525,7 +9678,7 @@ export type CauseEncoded<E, D> =
|
|
|
9525
9678
|
readonly right: CauseEncoded<E, D>
|
|
9526
9679
|
}
|
|
9527
9680
|
|
|
9528
|
-
const causeDieEncoded = <
|
|
9681
|
+
const causeDieEncoded = <Defect extends Schema.Any>(defect: Defect) =>
|
|
9529
9682
|
Struct({
|
|
9530
9683
|
_tag: Literal("Die"),
|
|
9531
9684
|
defect
|
|
@@ -9535,7 +9688,7 @@ const CauseEmptyEncoded = Struct({
|
|
|
9535
9688
|
_tag: Literal("Empty")
|
|
9536
9689
|
})
|
|
9537
9690
|
|
|
9538
|
-
const causeFailEncoded = <E
|
|
9691
|
+
const causeFailEncoded = <E extends Schema.Any>(error: E) =>
|
|
9539
9692
|
Struct({
|
|
9540
9693
|
_tag: Literal("Fail"),
|
|
9541
9694
|
error
|
|
@@ -9546,32 +9699,36 @@ const CauseInterruptEncoded = Struct({
|
|
|
9546
9699
|
fiberId: FiberIdEncoded
|
|
9547
9700
|
})
|
|
9548
9701
|
|
|
9549
|
-
const
|
|
9550
|
-
|
|
9551
|
-
|
|
9552
|
-
|
|
9553
|
-
|
|
9554
|
-
|
|
9555
|
-
|
|
9556
|
-
|
|
9557
|
-
|
|
9558
|
-
|
|
9559
|
-
|
|
9560
|
-
|
|
9561
|
-
|
|
9562
|
-
|
|
9563
|
-
|
|
9564
|
-
|
|
9565
|
-
defect: Schema<D, DI, R2>
|
|
9566
|
-
): Schema<CauseEncoded<E, D>, CauseEncoded<EI, DI>, R1 | R2> => {
|
|
9567
|
-
const recur = suspend(() => out)
|
|
9568
|
-
const out: Schema<CauseEncoded<E, D>, CauseEncoded<EI, DI>, R1 | R2> = Union(
|
|
9702
|
+
const causeEncoded = <E extends Schema.All, D extends Schema.All>(
|
|
9703
|
+
error: E,
|
|
9704
|
+
defect: D
|
|
9705
|
+
): SchemaClass<
|
|
9706
|
+
CauseEncoded<Schema.Type<E>, Schema.Type<D>>,
|
|
9707
|
+
CauseEncoded<Schema.Encoded<E>, Schema.Encoded<D>>,
|
|
9708
|
+
Schema.Context<E> | Schema.Context<D>
|
|
9709
|
+
> => {
|
|
9710
|
+
const error_ = asSchema(error)
|
|
9711
|
+
const defect_ = asSchema(defect)
|
|
9712
|
+
const suspended = suspend((): Schema<
|
|
9713
|
+
CauseEncoded<Schema.Type<E>, Schema.Type<D>>,
|
|
9714
|
+
CauseEncoded<Schema.Encoded<E>, Schema.Encoded<D>>,
|
|
9715
|
+
Schema.Context<E> | Schema.Context<D>
|
|
9716
|
+
> => out)
|
|
9717
|
+
const out = Union(
|
|
9569
9718
|
CauseEmptyEncoded,
|
|
9570
|
-
causeFailEncoded(
|
|
9571
|
-
causeDieEncoded(
|
|
9719
|
+
causeFailEncoded(error_),
|
|
9720
|
+
causeDieEncoded(defect_),
|
|
9572
9721
|
CauseInterruptEncoded,
|
|
9573
|
-
|
|
9574
|
-
|
|
9722
|
+
Struct({
|
|
9723
|
+
_tag: Literal("Sequential"),
|
|
9724
|
+
left: suspended,
|
|
9725
|
+
right: suspended
|
|
9726
|
+
}),
|
|
9727
|
+
Struct({
|
|
9728
|
+
_tag: Literal("Parallel"),
|
|
9729
|
+
left: suspended,
|
|
9730
|
+
right: suspended
|
|
9731
|
+
})
|
|
9575
9732
|
).annotations({ title: `CauseEncoded<${format(error)}>` })
|
|
9576
9733
|
return out
|
|
9577
9734
|
}
|
|
@@ -9631,11 +9788,11 @@ const causeParse = <A, D, R>(
|
|
|
9631
9788
|
* @since 3.10.0
|
|
9632
9789
|
*/
|
|
9633
9790
|
export interface CauseFromSelf<E extends Schema.All, D extends Schema.All> extends
|
|
9634
|
-
|
|
9791
|
+
AnnotableDeclare<
|
|
9635
9792
|
CauseFromSelf<E, D>,
|
|
9636
9793
|
cause_.Cause<Schema.Type<E>>,
|
|
9637
9794
|
cause_.Cause<Schema.Encoded<E>>,
|
|
9638
|
-
|
|
9795
|
+
[E, D]
|
|
9639
9796
|
>
|
|
9640
9797
|
{}
|
|
9641
9798
|
|
|
@@ -9708,11 +9865,13 @@ function causeEncode<E>(cause: cause_.Cause<E>): CauseEncoded<E, unknown> {
|
|
|
9708
9865
|
* @since 3.10.0
|
|
9709
9866
|
*/
|
|
9710
9867
|
export interface Cause<E extends Schema.All, D extends Schema.All> extends
|
|
9711
|
-
|
|
9712
|
-
|
|
9713
|
-
|
|
9714
|
-
|
|
9715
|
-
|
|
9868
|
+
transform<
|
|
9869
|
+
SchemaClass<
|
|
9870
|
+
CauseEncoded<Schema.Type<E>, Schema.Type<Defect>>,
|
|
9871
|
+
CauseEncoded<Schema.Encoded<E>, Schema.Encoded<Defect>>,
|
|
9872
|
+
Schema.Context<E> | Schema.Context<D>
|
|
9873
|
+
>,
|
|
9874
|
+
CauseFromSelf<SchemaClass<Schema.Type<E>>, SchemaClass<Schema.Type<D>>>
|
|
9716
9875
|
>
|
|
9717
9876
|
{}
|
|
9718
9877
|
|
|
@@ -9726,19 +9885,18 @@ export const Cause = <E extends Schema.All, D extends Schema.All>({ defect, erro
|
|
|
9726
9885
|
}): Cause<E, D> => {
|
|
9727
9886
|
const error_ = asSchema(error)
|
|
9728
9887
|
const defect_ = asSchema(defect)
|
|
9729
|
-
|
|
9888
|
+
const out = transform(
|
|
9730
9889
|
causeEncoded(error_, defect_),
|
|
9731
|
-
CauseFromSelf({ error: typeSchema(error_), defect:
|
|
9732
|
-
{
|
|
9890
|
+
CauseFromSelf({ error: typeSchema(error_), defect: typeSchema(defect_) }),
|
|
9891
|
+
{
|
|
9892
|
+
strict: false,
|
|
9893
|
+
decode: (i) => causeDecode(i),
|
|
9894
|
+
encode: (a) => causeEncode(a)
|
|
9895
|
+
}
|
|
9733
9896
|
)
|
|
9897
|
+
return out as any
|
|
9734
9898
|
}
|
|
9735
9899
|
|
|
9736
|
-
/**
|
|
9737
|
-
* @category api interface
|
|
9738
|
-
* @since 3.10.0
|
|
9739
|
-
*/
|
|
9740
|
-
export interface Defect extends transform<typeof Unknown, typeof Unknown> {}
|
|
9741
|
-
|
|
9742
9900
|
/**
|
|
9743
9901
|
* Defines a schema for handling JavaScript errors (`Error` instances) and other types of defects.
|
|
9744
9902
|
* It decodes objects into Error instances if they match the expected structure (i.e., have a `message` and optionally a `name` and `stack`),
|
|
@@ -9752,34 +9910,34 @@ export interface Defect extends transform<typeof Unknown, typeof Unknown> {}
|
|
|
9752
9910
|
* @category defect
|
|
9753
9911
|
* @since 3.10.0
|
|
9754
9912
|
*/
|
|
9755
|
-
export
|
|
9913
|
+
export class Defect extends transform(
|
|
9756
9914
|
Unknown,
|
|
9757
9915
|
Unknown,
|
|
9758
9916
|
{
|
|
9759
9917
|
strict: true,
|
|
9760
|
-
decode: (
|
|
9761
|
-
if (Predicate.isObject(
|
|
9762
|
-
const err = new Error(
|
|
9763
|
-
if ("name" in
|
|
9764
|
-
err.name =
|
|
9918
|
+
decode: (i) => {
|
|
9919
|
+
if (Predicate.isObject(i) && "message" in i && typeof i.message === "string") {
|
|
9920
|
+
const err = new Error(i.message, { cause: i })
|
|
9921
|
+
if ("name" in i && typeof i.name === "string") {
|
|
9922
|
+
err.name = i.name
|
|
9765
9923
|
}
|
|
9766
|
-
err.stack = "stack" in
|
|
9924
|
+
err.stack = "stack" in i && typeof i.stack === "string" ? i.stack : ""
|
|
9767
9925
|
return err
|
|
9768
9926
|
}
|
|
9769
|
-
return String(
|
|
9927
|
+
return String(i)
|
|
9770
9928
|
},
|
|
9771
|
-
encode: (
|
|
9772
|
-
if (
|
|
9929
|
+
encode: (a) => {
|
|
9930
|
+
if (a instanceof Error) {
|
|
9773
9931
|
return {
|
|
9774
|
-
name:
|
|
9775
|
-
message:
|
|
9932
|
+
name: a.name,
|
|
9933
|
+
message: a.message
|
|
9776
9934
|
// no stack because of security reasons
|
|
9777
9935
|
}
|
|
9778
9936
|
}
|
|
9779
|
-
return internalCause_.prettyErrorMessage(
|
|
9937
|
+
return internalCause_.prettyErrorMessage(a)
|
|
9780
9938
|
}
|
|
9781
9939
|
}
|
|
9782
|
-
).annotations({ identifier: "Defect" })
|
|
9940
|
+
).annotations({ identifier: "Defect" }) {}
|
|
9783
9941
|
|
|
9784
9942
|
/**
|
|
9785
9943
|
* @category Exit utils
|
|
@@ -9795,34 +9953,35 @@ export type ExitEncoded<A, E, D> =
|
|
|
9795
9953
|
readonly value: A
|
|
9796
9954
|
}
|
|
9797
9955
|
|
|
9798
|
-
const exitFailureEncoded = <E
|
|
9799
|
-
error:
|
|
9800
|
-
defect:
|
|
9956
|
+
const exitFailureEncoded = <E extends Schema.All, D extends Schema.All>(
|
|
9957
|
+
error: E,
|
|
9958
|
+
defect: D
|
|
9801
9959
|
) =>
|
|
9802
9960
|
Struct({
|
|
9803
9961
|
_tag: Literal("Failure"),
|
|
9804
9962
|
cause: causeEncoded(error, defect)
|
|
9805
9963
|
})
|
|
9806
9964
|
|
|
9807
|
-
const exitSuccessEncoded = <A
|
|
9808
|
-
value:
|
|
9965
|
+
const exitSuccessEncoded = <A extends Schema.All>(
|
|
9966
|
+
value: A
|
|
9809
9967
|
) =>
|
|
9810
9968
|
Struct({
|
|
9811
9969
|
_tag: Literal("Success"),
|
|
9812
9970
|
value
|
|
9813
9971
|
})
|
|
9814
9972
|
|
|
9815
|
-
const exitEncoded = <A
|
|
9816
|
-
value:
|
|
9817
|
-
error:
|
|
9818
|
-
defect:
|
|
9819
|
-
)
|
|
9820
|
-
Union(
|
|
9973
|
+
const exitEncoded = <A extends Schema.All, E extends Schema.All, D extends Schema.Any>(
|
|
9974
|
+
value: A,
|
|
9975
|
+
error: E,
|
|
9976
|
+
defect: D
|
|
9977
|
+
) => {
|
|
9978
|
+
return Union(
|
|
9821
9979
|
exitFailureEncoded(error, defect),
|
|
9822
9980
|
exitSuccessEncoded(value)
|
|
9823
9981
|
).annotations({
|
|
9824
9982
|
title: `ExitEncoded<${format(value)}, ${format(error)}, ${format(defect)}>`
|
|
9825
9983
|
})
|
|
9984
|
+
}
|
|
9826
9985
|
|
|
9827
9986
|
const exitDecode = <A, E>(input: ExitEncoded<A, E, unknown>): exit_.Exit<A, E> => {
|
|
9828
9987
|
switch (input._tag) {
|
|
@@ -9866,13 +10025,14 @@ const exitParse = <A, R, E, ER>(
|
|
|
9866
10025
|
* @category api interface
|
|
9867
10026
|
* @since 3.10.0
|
|
9868
10027
|
*/
|
|
9869
|
-
export interface ExitFromSelf<A extends Schema.All, E extends Schema.All, D extends Schema.All>
|
|
9870
|
-
|
|
9871
|
-
|
|
9872
|
-
|
|
9873
|
-
|
|
9874
|
-
|
|
9875
|
-
|
|
10028
|
+
export interface ExitFromSelf<A extends Schema.All, E extends Schema.All, D extends Schema.All>
|
|
10029
|
+
extends
|
|
10030
|
+
AnnotableDeclare<
|
|
10031
|
+
ExitFromSelf<A, E, D>,
|
|
10032
|
+
exit_.Exit<Schema.Type<A>, Schema.Type<E>>,
|
|
10033
|
+
exit_.Exit<Schema.Encoded<A>, Schema.Encoded<E>>,
|
|
10034
|
+
[A, E, D]
|
|
10035
|
+
>
|
|
9876
10036
|
{}
|
|
9877
10037
|
|
|
9878
10038
|
/**
|
|
@@ -9912,11 +10072,22 @@ export const ExitFromSelf = <A extends Schema.All, E extends Schema.All, D exten
|
|
|
9912
10072
|
* @since 3.10.0
|
|
9913
10073
|
*/
|
|
9914
10074
|
export interface Exit<A extends Schema.All, E extends Schema.All, D extends Schema.All> extends
|
|
9915
|
-
|
|
9916
|
-
|
|
9917
|
-
|
|
9918
|
-
|
|
9919
|
-
|
|
10075
|
+
transform<
|
|
10076
|
+
Union<[
|
|
10077
|
+
Struct<{
|
|
10078
|
+
_tag: Literal<["Failure"]>
|
|
10079
|
+
cause: SchemaClass<
|
|
10080
|
+
CauseEncoded<Schema.Type<E>, Schema.Type<D>>,
|
|
10081
|
+
CauseEncoded<Schema.Encoded<E>, Schema.Encoded<D>>,
|
|
10082
|
+
Schema.Context<E> | Schema.Context<D>
|
|
10083
|
+
>
|
|
10084
|
+
}>,
|
|
10085
|
+
Struct<{
|
|
10086
|
+
_tag: Literal<["Success"]>
|
|
10087
|
+
value: A
|
|
10088
|
+
}>
|
|
10089
|
+
]>,
|
|
10090
|
+
ExitFromSelf<SchemaClass<Schema.Type<A>>, SchemaClass<Schema.Type<E>>, SchemaClass<Schema.Type<D>>>
|
|
9920
10091
|
>
|
|
9921
10092
|
{}
|
|
9922
10093
|
|
|
@@ -9934,18 +10105,19 @@ export const Exit = <A extends Schema.All, E extends Schema.All, D extends Schem
|
|
|
9934
10105
|
const success_ = asSchema(success)
|
|
9935
10106
|
const failure_ = asSchema(failure)
|
|
9936
10107
|
const defect_ = asSchema(defect)
|
|
9937
|
-
|
|
10108
|
+
const out = transform(
|
|
9938
10109
|
exitEncoded(success_, failure_, defect_),
|
|
9939
|
-
ExitFromSelf({ failure: typeSchema(failure_), success: typeSchema(success_), defect:
|
|
10110
|
+
ExitFromSelf({ failure: typeSchema(failure_), success: typeSchema(success_), defect: typeSchema(defect_) }),
|
|
9940
10111
|
{
|
|
9941
10112
|
strict: false,
|
|
9942
|
-
decode: exitDecode,
|
|
9943
|
-
encode: (
|
|
9944
|
-
|
|
9945
|
-
? { _tag: "Failure", cause:
|
|
9946
|
-
: { _tag: "Success", value:
|
|
10113
|
+
decode: (i) => exitDecode(i),
|
|
10114
|
+
encode: (a) =>
|
|
10115
|
+
a._tag === "Failure"
|
|
10116
|
+
? { _tag: "Failure", cause: a.cause } as const
|
|
10117
|
+
: { _tag: "Success", value: a.value } as const
|
|
9947
10118
|
}
|
|
9948
10119
|
)
|
|
10120
|
+
return out as any
|
|
9949
10121
|
}
|
|
9950
10122
|
|
|
9951
10123
|
const hashSetArbitrary =
|
|
@@ -9979,11 +10151,11 @@ const hashSetParse = <A, R>(
|
|
|
9979
10151
|
* @since 3.10.0
|
|
9980
10152
|
*/
|
|
9981
10153
|
export interface HashSetFromSelf<Value extends Schema.Any> extends
|
|
9982
|
-
|
|
10154
|
+
AnnotableDeclare<
|
|
9983
10155
|
HashSetFromSelf<Value>,
|
|
9984
10156
|
hashSet_.HashSet<Schema.Type<Value>>,
|
|
9985
10157
|
hashSet_.HashSet<Schema.Encoded<Value>>,
|
|
9986
|
-
|
|
10158
|
+
[Value]
|
|
9987
10159
|
>
|
|
9988
10160
|
{}
|
|
9989
10161
|
|
|
@@ -10013,25 +10185,23 @@ export const HashSetFromSelf = <Value extends Schema.Any>(
|
|
|
10013
10185
|
* @category api interface
|
|
10014
10186
|
* @since 3.10.0
|
|
10015
10187
|
*/
|
|
10016
|
-
export interface HashSet<Value extends Schema.Any>
|
|
10017
|
-
|
|
10018
|
-
HashSet<Value>,
|
|
10019
|
-
hashSet_.HashSet<Schema.Type<Value>>,
|
|
10020
|
-
ReadonlyArray<Schema.Encoded<Value>>,
|
|
10021
|
-
Schema.Context<Value>
|
|
10022
|
-
>
|
|
10188
|
+
export interface HashSet<Value extends Schema.Any>
|
|
10189
|
+
extends transform<Array$<Value>, HashSetFromSelf<SchemaClass<Schema.Type<Value>>>>
|
|
10023
10190
|
{}
|
|
10024
10191
|
|
|
10025
10192
|
/**
|
|
10026
10193
|
* @category HashSet transformations
|
|
10027
10194
|
* @since 3.10.0
|
|
10028
10195
|
*/
|
|
10029
|
-
export
|
|
10030
|
-
const value_ = asSchema(value)
|
|
10196
|
+
export function HashSet<Value extends Schema.Any>(value: Value): HashSet<Value> {
|
|
10031
10197
|
return transform(
|
|
10032
|
-
Array$(
|
|
10033
|
-
HashSetFromSelf(typeSchema(
|
|
10034
|
-
{
|
|
10198
|
+
Array$(value),
|
|
10199
|
+
HashSetFromSelf(typeSchema(asSchema(value))),
|
|
10200
|
+
{
|
|
10201
|
+
strict: true,
|
|
10202
|
+
decode: (i) => hashSet_.fromIterable(i),
|
|
10203
|
+
encode: (a) => Array.from(a)
|
|
10204
|
+
}
|
|
10035
10205
|
)
|
|
10036
10206
|
}
|
|
10037
10207
|
|
|
@@ -10079,11 +10249,11 @@ const hashMapParse = <R, K, V>(
|
|
|
10079
10249
|
* @since 3.10.0
|
|
10080
10250
|
*/
|
|
10081
10251
|
export interface HashMapFromSelf<K extends Schema.Any, V extends Schema.Any> extends
|
|
10082
|
-
|
|
10252
|
+
AnnotableDeclare<
|
|
10083
10253
|
HashMapFromSelf<K, V>,
|
|
10084
10254
|
hashMap_.HashMap<Schema.Type<K>, Schema.Type<V>>,
|
|
10085
10255
|
hashMap_.HashMap<Schema.Encoded<K>, Schema.Encoded<V>>,
|
|
10086
|
-
|
|
10256
|
+
[K, V]
|
|
10087
10257
|
>
|
|
10088
10258
|
{}
|
|
10089
10259
|
|
|
@@ -10114,13 +10284,8 @@ export const HashMapFromSelf = <K extends Schema.Any, V extends Schema.Any>({ ke
|
|
|
10114
10284
|
* @category api interface
|
|
10115
10285
|
* @since 3.10.0
|
|
10116
10286
|
*/
|
|
10117
|
-
export interface HashMap<K extends Schema.Any, V extends Schema.Any>
|
|
10118
|
-
|
|
10119
|
-
HashMap<K, V>,
|
|
10120
|
-
hashMap_.HashMap<Schema.Type<K>, Schema.Type<V>>,
|
|
10121
|
-
ReadonlyArray<readonly [Schema.Encoded<K>, Schema.Encoded<V>]>,
|
|
10122
|
-
Schema.Context<K> | Schema.Context<V>
|
|
10123
|
-
>
|
|
10287
|
+
export interface HashMap<K extends Schema.Any, V extends Schema.Any>
|
|
10288
|
+
extends transform<Array$<Tuple2<K, V>>, HashMapFromSelf<SchemaClass<Schema.Type<K>>, SchemaClass<Schema.Type<V>>>>
|
|
10124
10289
|
{}
|
|
10125
10290
|
|
|
10126
10291
|
/**
|
|
@@ -10131,12 +10296,14 @@ export const HashMap = <K extends Schema.Any, V extends Schema.Any>({ key, value
|
|
|
10131
10296
|
readonly key: K
|
|
10132
10297
|
readonly value: V
|
|
10133
10298
|
}): HashMap<K, V> => {
|
|
10134
|
-
const key_ = asSchema(key)
|
|
10135
|
-
const value_ = asSchema(value)
|
|
10136
10299
|
return transform(
|
|
10137
|
-
Array$(Tuple(
|
|
10138
|
-
HashMapFromSelf({ key: typeSchema(
|
|
10139
|
-
{
|
|
10300
|
+
Array$(Tuple(key, value)),
|
|
10301
|
+
HashMapFromSelf({ key: typeSchema(asSchema(key)), value: typeSchema(asSchema(value)) }),
|
|
10302
|
+
{
|
|
10303
|
+
strict: true,
|
|
10304
|
+
decode: (i) => hashMap_.fromIterable(i),
|
|
10305
|
+
encode: (a) => Array.from(a)
|
|
10306
|
+
}
|
|
10140
10307
|
)
|
|
10141
10308
|
}
|
|
10142
10309
|
|
|
@@ -10169,11 +10336,11 @@ const listParse = <A, R>(
|
|
|
10169
10336
|
* @since 3.10.0
|
|
10170
10337
|
*/
|
|
10171
10338
|
export interface ListFromSelf<Value extends Schema.Any> extends
|
|
10172
|
-
|
|
10339
|
+
AnnotableDeclare<
|
|
10173
10340
|
ListFromSelf<Value>,
|
|
10174
10341
|
list_.List<Schema.Type<Value>>,
|
|
10175
10342
|
list_.List<Schema.Encoded<Value>>,
|
|
10176
|
-
|
|
10343
|
+
[Value]
|
|
10177
10344
|
>
|
|
10178
10345
|
{}
|
|
10179
10346
|
|
|
@@ -10203,25 +10370,23 @@ export const ListFromSelf = <Value extends Schema.Any>(
|
|
|
10203
10370
|
* @category api interface
|
|
10204
10371
|
* @since 3.10.0
|
|
10205
10372
|
*/
|
|
10206
|
-
export interface List<Value extends Schema.Any>
|
|
10207
|
-
|
|
10208
|
-
List<Value>,
|
|
10209
|
-
list_.List<Schema.Type<Value>>,
|
|
10210
|
-
ReadonlyArray<Schema.Encoded<Value>>,
|
|
10211
|
-
Schema.Context<Value>
|
|
10212
|
-
>
|
|
10373
|
+
export interface List<Value extends Schema.Any>
|
|
10374
|
+
extends transform<Array$<Value>, ListFromSelf<SchemaClass<Schema.Type<Value>>>>
|
|
10213
10375
|
{}
|
|
10214
10376
|
|
|
10215
10377
|
/**
|
|
10216
10378
|
* @category List transformations
|
|
10217
10379
|
* @since 3.10.0
|
|
10218
10380
|
*/
|
|
10219
|
-
export
|
|
10220
|
-
const value_ = asSchema(value)
|
|
10381
|
+
export function List<Value extends Schema.Any>(value: Value): List<Value> {
|
|
10221
10382
|
return transform(
|
|
10222
|
-
Array$(
|
|
10223
|
-
ListFromSelf(typeSchema(
|
|
10224
|
-
{
|
|
10383
|
+
Array$(value),
|
|
10384
|
+
ListFromSelf(typeSchema(asSchema(value))),
|
|
10385
|
+
{
|
|
10386
|
+
strict: true,
|
|
10387
|
+
decode: (i) => list_.fromIterable(i),
|
|
10388
|
+
encode: (a) => Array.from(a)
|
|
10389
|
+
}
|
|
10225
10390
|
)
|
|
10226
10391
|
}
|
|
10227
10392
|
|
|
@@ -10259,11 +10424,11 @@ const sortedSetParse = <A, R>(
|
|
|
10259
10424
|
* @since 3.10.0
|
|
10260
10425
|
*/
|
|
10261
10426
|
export interface SortedSetFromSelf<Value extends Schema.Any> extends
|
|
10262
|
-
|
|
10427
|
+
AnnotableDeclare<
|
|
10263
10428
|
SortedSetFromSelf<Value>,
|
|
10264
10429
|
sortedSet_.SortedSet<Schema.Type<Value>>,
|
|
10265
10430
|
sortedSet_.SortedSet<Schema.Encoded<Value>>,
|
|
10266
|
-
|
|
10431
|
+
[Value]
|
|
10267
10432
|
>
|
|
10268
10433
|
{}
|
|
10269
10434
|
|
|
@@ -10295,32 +10460,26 @@ export const SortedSetFromSelf = <Value extends Schema.Any>(
|
|
|
10295
10460
|
* @category api interface
|
|
10296
10461
|
* @since 3.10.0
|
|
10297
10462
|
*/
|
|
10298
|
-
export interface SortedSet<Value extends Schema.Any>
|
|
10299
|
-
|
|
10300
|
-
SortedSet<Value>,
|
|
10301
|
-
sortedSet_.SortedSet<Schema.Type<Value>>,
|
|
10302
|
-
ReadonlyArray<Schema.Encoded<Value>>,
|
|
10303
|
-
Schema.Context<Value>
|
|
10304
|
-
>
|
|
10463
|
+
export interface SortedSet<Value extends Schema.Any>
|
|
10464
|
+
extends transform<Array$<Value>, SortedSetFromSelf<SchemaClass<Schema.Type<Value>>>>
|
|
10305
10465
|
{}
|
|
10306
10466
|
|
|
10307
10467
|
/**
|
|
10308
10468
|
* @category SortedSet transformations
|
|
10309
10469
|
* @since 3.10.0
|
|
10310
10470
|
*/
|
|
10311
|
-
export
|
|
10471
|
+
export function SortedSet<Value extends Schema.Any>(
|
|
10312
10472
|
value: Value,
|
|
10313
10473
|
ordA: Order.Order<Schema.Type<Value>>
|
|
10314
|
-
): SortedSet<Value>
|
|
10315
|
-
const
|
|
10316
|
-
const to = typeSchema(value_)
|
|
10474
|
+
): SortedSet<Value> {
|
|
10475
|
+
const to = typeSchema(asSchema(value))
|
|
10317
10476
|
return transform(
|
|
10318
|
-
Array$(
|
|
10477
|
+
Array$(value),
|
|
10319
10478
|
SortedSetFromSelf<typeof to>(to, ordA, ordA),
|
|
10320
10479
|
{
|
|
10321
10480
|
strict: true,
|
|
10322
|
-
decode: (
|
|
10323
|
-
encode: (
|
|
10481
|
+
decode: (i) => sortedSet_.fromIterable(i, ordA),
|
|
10482
|
+
encode: (a) => Array.from(sortedSet_.values(a))
|
|
10324
10483
|
}
|
|
10325
10484
|
)
|
|
10326
10485
|
}
|
|
@@ -10336,7 +10495,11 @@ export const SortedSet = <Value extends Schema.Any>(
|
|
|
10336
10495
|
export class BooleanFromUnknown extends transform(
|
|
10337
10496
|
Unknown,
|
|
10338
10497
|
Boolean$,
|
|
10339
|
-
{
|
|
10498
|
+
{
|
|
10499
|
+
strict: true,
|
|
10500
|
+
decode: (i) => Predicate.isTruthy(i),
|
|
10501
|
+
encode: identity
|
|
10502
|
+
}
|
|
10340
10503
|
).annotations({ identifier: "BooleanFromUnknown" }) {}
|
|
10341
10504
|
|
|
10342
10505
|
/**
|
|
@@ -10349,7 +10512,11 @@ export class BooleanFromUnknown extends transform(
|
|
|
10349
10512
|
export class BooleanFromString extends transform(
|
|
10350
10513
|
Literal("true", "false").annotations({ description: "a string to be decoded into a boolean" }),
|
|
10351
10514
|
Boolean$,
|
|
10352
|
-
{
|
|
10515
|
+
{
|
|
10516
|
+
strict: true,
|
|
10517
|
+
decode: (i) => i === "true",
|
|
10518
|
+
encode: (a) => a ? "true" : "false"
|
|
10519
|
+
}
|
|
10353
10520
|
).annotations({ identifier: "BooleanFromString" }) {}
|
|
10354
10521
|
|
|
10355
10522
|
/**
|
|
@@ -10617,9 +10784,7 @@ export const deserializeFailure: {
|
|
|
10617
10784
|
* @since 3.10.0
|
|
10618
10785
|
* @category decoding
|
|
10619
10786
|
*/
|
|
10620
|
-
(
|
|
10621
|
-
value: unknown
|
|
10622
|
-
): <SA, SI, FA, FI, R>(self: WithResult<SA, SI, FA, FI, R>) => Effect.Effect<FA, ParseResult.ParseError, R>
|
|
10787
|
+
(value: unknown): <SA, SI, FA, FI, R>(self: WithResult<SA, SI, FA, FI, R>) => Effect.Effect<FA, ParseResult.ParseError, R>
|
|
10623
10788
|
/**
|
|
10624
10789
|
* @since 3.10.0
|
|
10625
10790
|
* @category decoding
|
|
@@ -10697,10 +10862,7 @@ export const serializeExit: {
|
|
|
10697
10862
|
* @since 3.10.0
|
|
10698
10863
|
* @category encoding
|
|
10699
10864
|
*/
|
|
10700
|
-
<SA, SI, FA, FI, R>(
|
|
10701
|
-
self: WithResult<SA, SI, FA, FI, R>,
|
|
10702
|
-
value: exit_.Exit<SA, FA>
|
|
10703
|
-
): Effect.Effect<ExitEncoded<SI, FI, unknown>, ParseResult.ParseError, R>
|
|
10865
|
+
<SA, SI, FA, FI, R>(self: WithResult<SA, SI, FA, FI, R>, value: exit_.Exit<SA, FA>): Effect.Effect<ExitEncoded<SI, FI, unknown>, ParseResult.ParseError, R>
|
|
10704
10866
|
} = dual(2, <SA, SI, FA, FI, R>(
|
|
10705
10867
|
self: WithResult<SA, SI, FA, FI, R>,
|
|
10706
10868
|
value: exit_.Exit<SA, FA>
|
|
@@ -10722,10 +10884,7 @@ export const deserializeExit: {
|
|
|
10722
10884
|
* @since 3.10.0
|
|
10723
10885
|
* @category decoding
|
|
10724
10886
|
*/
|
|
10725
|
-
<SA, SI, FA, FI, R>(
|
|
10726
|
-
self: WithResult<SA, SI, FA, FI, R>,
|
|
10727
|
-
value: unknown
|
|
10728
|
-
): Effect.Effect<exit_.Exit<SA, FA>, ParseResult.ParseError, R>
|
|
10887
|
+
<SA, SI, FA, FI, R>(self: WithResult<SA, SI, FA, FI, R>, value: unknown): Effect.Effect<exit_.Exit<SA, FA>, ParseResult.ParseError, R>
|
|
10729
10888
|
} = dual(2, <SA, SI, FA, FI, R>(
|
|
10730
10889
|
self: WithResult<SA, SI, FA, FI, R>,
|
|
10731
10890
|
value: unknown
|
|
@@ -10902,7 +11061,7 @@ export const TaggedRequest =
|
|
|
10902
11061
|
success: Success
|
|
10903
11062
|
payload: Payload
|
|
10904
11063
|
},
|
|
10905
|
-
annotations?: ClassAnnotations<Self, Struct.Type<{ readonly _tag: tag<Tag> } & Payload
|
|
11064
|
+
annotations?: ClassAnnotations<Self, Simplify<Struct.Type<{ readonly _tag: tag<Tag> } & Payload>>>
|
|
10906
11065
|
): [Self] extends [never] ? MissingSelfGeneric<"TaggedRequest", `"Tag", SuccessSchema, FailureSchema, `>
|
|
10907
11066
|
: TaggedRequestClass<
|
|
10908
11067
|
Self,
|
|
@@ -11124,6 +11283,20 @@ const go = (ast: AST.AST, path: ReadonlyArray<PropertyKey>): Equivalence.Equival
|
|
|
11124
11283
|
}
|
|
11125
11284
|
}
|
|
11126
11285
|
|
|
11286
|
+
const SymbolStruct = TaggedStruct("symbol", {
|
|
11287
|
+
key: String$
|
|
11288
|
+
}).annotations({ description: "an object to be decoded into a globally shared symbol" })
|
|
11289
|
+
|
|
11290
|
+
const SymbolFromStruct = transformOrFail(
|
|
11291
|
+
SymbolStruct,
|
|
11292
|
+
SymbolFromSelf,
|
|
11293
|
+
{
|
|
11294
|
+
strict: true,
|
|
11295
|
+
decode: (i) => decodeSymbol(i.key),
|
|
11296
|
+
encode: (a, _, ast) => ParseResult.map(encodeSymbol(a, ast), (key) => SymbolStruct.make({ key }))
|
|
11297
|
+
}
|
|
11298
|
+
)
|
|
11299
|
+
|
|
11127
11300
|
/** @ignore */
|
|
11128
11301
|
class PropertyKey$ extends Union(String$, Number$, SymbolFromStruct).annotations({ identifier: "PropertyKey" }) {}
|
|
11129
11302
|
|