effect 4.0.0-rc.111 → 4.0.0-rc.113
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/AGENTS.md +24 -9
- package/CLAUDE.md +24 -9
- package/ai-docs/package.json +2 -2
- package/ai-docs/src/01_effect/01_basics/02_effect-fn.ts +18 -5
- package/ai-docs/src/01_effect/01_basics/index.md +5 -3
- package/ai-docs/src/01_effect/03_services/20_layer-composition.ts +1 -1
- package/ai-docs/src/01_effect/03_services/20_layer-unwrap.ts +2 -2
- package/ai-docs/src/01_effect/05_resources/10_acquire-release.ts +2 -2
- package/ai-docs/src/03_stream/30_encoding.ts +5 -7
- package/ai-docs/src/08_observability/10_logging.ts +1 -1
- package/ai-docs/src/70_cli/10_basics.ts +7 -7
- package/ai-docs/src/71_ai/10_language-model.ts +2 -2
- package/ai-docs/src/71_ai/20_tools.ts +1 -1
- package/ai-docs/src/71_ai/30_chat.ts +1 -1
- package/dist/Array.d.ts +109 -52
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +65 -32
- package/dist/Array.js.map +1 -1
- package/dist/BigDecimal.d.ts +5 -1
- package/dist/BigDecimal.d.ts.map +1 -1
- package/dist/BigDecimal.js +40 -23
- package/dist/BigDecimal.js.map +1 -1
- package/dist/ByteSize.d.ts +633 -0
- package/dist/ByteSize.d.ts.map +1 -0
- package/dist/ByteSize.js +524 -0
- package/dist/ByteSize.js.map +1 -0
- package/dist/Cache.d.ts.map +1 -1
- package/dist/Cache.js +17 -3
- package/dist/Cache.js.map +1 -1
- package/dist/Cause.d.ts +1 -1
- package/dist/Cause.d.ts.map +1 -1
- package/dist/Channel.d.ts +97 -24
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +68 -41
- package/dist/Channel.js.map +1 -1
- package/dist/Chunk.d.ts +49 -28
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Chunk.js +27 -18
- package/dist/Chunk.js.map +1 -1
- package/dist/Config.d.ts +162 -201
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +103 -212
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.d.ts +4 -4
- package/dist/ConfigProvider.d.ts.map +1 -1
- package/dist/ConfigProvider.js +7 -7
- package/dist/ConfigProvider.js.map +1 -1
- package/dist/Context.d.ts +31 -0
- package/dist/Context.d.ts.map +1 -1
- package/dist/Context.js.map +1 -1
- package/dist/Cron.d.ts +2 -2
- package/dist/Cron.d.ts.map +1 -1
- package/dist/Cron.js +2 -2
- package/dist/Cron.js.map +1 -1
- package/dist/Crypto.d.ts +1 -1
- package/dist/Crypto.d.ts.map +1 -1
- package/dist/Crypto.js +3 -2
- package/dist/Crypto.js.map +1 -1
- package/dist/DateTime.d.ts +2 -2
- package/dist/DateTime.d.ts.map +1 -1
- package/dist/Deferred.d.ts.map +1 -1
- package/dist/Deferred.js +6 -6
- package/dist/Deferred.js.map +1 -1
- package/dist/Duration.d.ts +1 -1
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +1 -1
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts +220 -113
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +27 -26
- package/dist/Effect.js.map +1 -1
- package/dist/Effectable.d.ts +58 -2
- package/dist/Effectable.d.ts.map +1 -1
- package/dist/Effectable.js +58 -6
- package/dist/Effectable.js.map +1 -1
- package/dist/Encoding.d.ts +3 -1
- package/dist/Encoding.d.ts.map +1 -1
- package/dist/Encoding.js +40 -10
- package/dist/Encoding.js.map +1 -1
- package/dist/Equal.d.ts +1 -1
- package/dist/Equal.d.ts.map +1 -1
- package/dist/Equal.js +1 -1
- package/dist/Equal.js.map +1 -1
- package/dist/ExecutionPlan.d.ts.map +1 -1
- package/dist/ExecutionPlan.js +1 -0
- package/dist/ExecutionPlan.js.map +1 -1
- package/dist/Fiber.d.ts +32 -8
- package/dist/Fiber.d.ts.map +1 -1
- package/dist/Fiber.js.map +1 -1
- package/dist/FiberHandle.js +3 -3
- package/dist/FiberHandle.js.map +1 -1
- package/dist/FiberMap.d.ts +12 -6
- package/dist/FiberMap.d.ts.map +1 -1
- package/dist/FiberMap.js +11 -6
- package/dist/FiberMap.js.map +1 -1
- package/dist/FileSystem.d.ts +42 -210
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js +16 -148
- package/dist/FileSystem.js.map +1 -1
- package/dist/Formatter.d.ts +1 -0
- package/dist/Formatter.d.ts.map +1 -1
- package/dist/Formatter.js +19 -3
- package/dist/Formatter.js.map +1 -1
- package/dist/Graph.d.ts +48 -20
- package/dist/Graph.d.ts.map +1 -1
- package/dist/Graph.js +20 -5
- package/dist/Graph.js.map +1 -1
- package/dist/Hash.d.ts +1 -1
- package/dist/Hash.d.ts.map +1 -1
- package/dist/Hash.js +5 -14
- package/dist/Hash.js.map +1 -1
- package/dist/HashMap.d.ts +1 -1
- package/dist/HashMap.d.ts.map +1 -1
- package/dist/HashRing.d.ts +6 -1
- package/dist/HashRing.d.ts.map +1 -1
- package/dist/HashRing.js +9 -2
- package/dist/HashRing.js.map +1 -1
- package/dist/HashSet.d.ts +1 -1
- package/dist/HashSet.d.ts.map +1 -1
- package/dist/HashSet.js.map +1 -1
- package/dist/Iterable.d.ts +56 -17
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +65 -45
- package/dist/Iterable.js.map +1 -1
- package/dist/JsonPatch.js +4 -4
- package/dist/JsonPatch.js.map +1 -1
- package/dist/JsonPointer.d.ts +68 -4
- package/dist/JsonPointer.d.ts.map +1 -1
- package/dist/JsonPointer.js +90 -4
- package/dist/JsonPointer.js.map +1 -1
- package/dist/JsonSchema.d.ts +67 -94
- package/dist/JsonSchema.d.ts.map +1 -1
- package/dist/JsonSchema.js +752 -397
- package/dist/JsonSchema.js.map +1 -1
- package/dist/Layer.d.ts +47 -4
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +4 -6
- package/dist/Layer.js.map +1 -1
- package/dist/LayerMap.d.ts +24 -3
- package/dist/LayerMap.d.ts.map +1 -1
- package/dist/LayerMap.js +9 -5
- package/dist/LayerMap.js.map +1 -1
- package/dist/LayerRef.d.ts.map +1 -1
- package/dist/LayerRef.js +7 -5
- package/dist/LayerRef.js.map +1 -1
- package/dist/Logger.d.ts +114 -9
- package/dist/Logger.d.ts.map +1 -1
- package/dist/Logger.js +109 -9
- package/dist/Logger.js.map +1 -1
- package/dist/ManagedRuntime.js +1 -1
- package/dist/ManagedRuntime.js.map +1 -1
- package/dist/Match.d.ts +43 -31
- package/dist/Match.d.ts.map +1 -1
- package/dist/Match.js +5 -2
- package/dist/Match.js.map +1 -1
- package/dist/Metric.d.ts +11 -4
- package/dist/Metric.d.ts.map +1 -1
- package/dist/Metric.js +14 -18
- package/dist/Metric.js.map +1 -1
- package/dist/MutableHashMap.d.ts +1 -1
- package/dist/MutableHashMap.d.ts.map +1 -1
- package/dist/MutableHashMap.js +1 -1
- package/dist/MutableHashMap.js.map +1 -1
- package/dist/MutableHashSet.d.ts +1 -1
- package/dist/MutableHashSet.d.ts.map +1 -1
- package/dist/MutableHashSet.js +1 -1
- package/dist/MutableHashSet.js.map +1 -1
- package/dist/MutableList.d.ts +13 -2
- package/dist/MutableList.d.ts.map +1 -1
- package/dist/MutableList.js +18 -2
- package/dist/MutableList.js.map +1 -1
- package/dist/Number.d.ts +6 -0
- package/dist/Number.d.ts.map +1 -1
- package/dist/Number.js +3 -1
- package/dist/Number.js.map +1 -1
- package/dist/Optic.d.ts.map +1 -1
- package/dist/Optic.js +5 -4
- package/dist/Optic.js.map +1 -1
- package/dist/Option.d.ts +1 -1
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js +1 -1
- package/dist/Option.js.map +1 -1
- package/dist/Order.d.ts +1 -0
- package/dist/Order.d.ts.map +1 -1
- package/dist/Order.js +3 -1
- package/dist/Order.js.map +1 -1
- package/dist/PartitionedSemaphore.d.ts.map +1 -1
- package/dist/PartitionedSemaphore.js +1 -2
- package/dist/PartitionedSemaphore.js.map +1 -1
- package/dist/Path.d.ts +1 -1
- package/dist/Path.d.ts.map +1 -1
- package/dist/Path.js +1 -1
- package/dist/Path.js.map +1 -1
- package/dist/PlatformError.d.ts +1 -1
- package/dist/PlatformError.d.ts.map +1 -1
- package/dist/PlatformError.js +1 -1
- package/dist/PlatformError.js.map +1 -1
- package/dist/Pool.d.ts +137 -10
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +332 -75
- package/dist/Pool.js.map +1 -1
- package/dist/PrimaryKey.d.ts +1 -1
- package/dist/PrimaryKey.d.ts.map +1 -1
- package/dist/PrimaryKey.js +1 -1
- package/dist/PrimaryKey.js.map +1 -1
- package/dist/PubSub.d.ts +21 -9
- package/dist/PubSub.d.ts.map +1 -1
- package/dist/PubSub.js +18 -14
- package/dist/PubSub.js.map +1 -1
- package/dist/Queue.d.ts +82 -6
- package/dist/Queue.d.ts.map +1 -1
- package/dist/Queue.js +116 -27
- package/dist/Queue.js.map +1 -1
- package/dist/Random.d.ts +17 -4
- package/dist/Random.d.ts.map +1 -1
- package/dist/Random.js +1 -1
- package/dist/Random.js.map +1 -1
- package/dist/RcMap.d.ts +137 -0
- package/dist/RcMap.d.ts.map +1 -1
- package/dist/RcMap.js +72 -9
- package/dist/RcMap.js.map +1 -1
- package/dist/Record.d.ts +13 -0
- package/dist/Record.d.ts.map +1 -1
- package/dist/Record.js.map +1 -1
- package/dist/Redacted.d.ts +1 -1
- package/dist/Redacted.d.ts.map +1 -1
- package/dist/Redacted.js +1 -1
- package/dist/Redacted.js.map +1 -1
- package/dist/RequestResolver.d.ts +15 -9
- package/dist/RequestResolver.d.ts.map +1 -1
- package/dist/RequestResolver.js +33 -15
- package/dist/RequestResolver.js.map +1 -1
- package/dist/Result.d.ts +1 -1
- package/dist/Result.d.ts.map +1 -1
- package/dist/Result.js +1 -1
- package/dist/Result.js.map +1 -1
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/Scheduler.js +19 -10
- package/dist/Scheduler.js.map +1 -1
- package/dist/Schema.d.ts +2200 -2433
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +2797 -4184
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +359 -176
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +373 -630
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaGetter.d.ts +46 -22
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +56 -53
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaIssue.d.ts +123 -200
- package/dist/SchemaIssue.d.ts.map +1 -1
- package/dist/SchemaIssue.js +59 -263
- package/dist/SchemaIssue.js.map +1 -1
- package/dist/SchemaParser.js +2 -9
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +1276 -172
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +1371 -29
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +49 -16
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +75 -98
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/Scope.d.ts +9 -2
- package/dist/Scope.d.ts.map +1 -1
- package/dist/Scope.js.map +1 -1
- package/dist/ScopedCache.d.ts.map +1 -1
- package/dist/ScopedCache.js +10 -3
- package/dist/ScopedCache.js.map +1 -1
- package/dist/Sink.d.ts +9 -4
- package/dist/Sink.d.ts.map +1 -1
- package/dist/Sink.js +49 -31
- package/dist/Sink.js.map +1 -1
- package/dist/StandardSchema.d.ts +125 -0
- package/dist/StandardSchema.d.ts.map +1 -0
- package/dist/StandardSchema.js +9 -0
- package/dist/StandardSchema.js.map +1 -0
- package/dist/Stream.d.ts +221 -35
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +168 -84
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +16 -6
- package/dist/String.d.ts.map +1 -1
- package/dist/String.js +12 -5
- package/dist/String.js.map +1 -1
- package/dist/Struct.d.ts.map +1 -1
- package/dist/Struct.js +7 -4
- package/dist/Struct.js.map +1 -1
- package/dist/SynchronizedRef.d.ts +3 -2
- package/dist/SynchronizedRef.d.ts.map +1 -1
- package/dist/SynchronizedRef.js.map +1 -1
- package/dist/Terminal.d.ts +3 -3
- package/dist/Terminal.d.ts.map +1 -1
- package/dist/Terminal.js +3 -3
- package/dist/Terminal.js.map +1 -1
- package/dist/Tracer.d.ts +27 -7
- package/dist/Tracer.d.ts.map +1 -1
- package/dist/Tracer.js +38 -13
- package/dist/Tracer.js.map +1 -1
- package/dist/Trie.d.ts +1 -1
- package/dist/Trie.d.ts.map +1 -1
- package/dist/Tuple.d.ts +2 -1
- package/dist/Tuple.d.ts.map +1 -1
- package/dist/Tuple.js.map +1 -1
- package/dist/TxChunk.d.ts +1 -1
- package/dist/TxChunk.d.ts.map +1 -1
- package/dist/TxChunk.js +1 -1
- package/dist/TxChunk.js.map +1 -1
- package/dist/TxDeferred.d.ts +1 -1
- package/dist/TxDeferred.d.ts.map +1 -1
- package/dist/TxDeferred.js +1 -1
- package/dist/TxDeferred.js.map +1 -1
- package/dist/TxHashMap.d.ts +1 -1
- package/dist/TxHashMap.d.ts.map +1 -1
- package/dist/TxHashMap.js +1 -1
- package/dist/TxHashMap.js.map +1 -1
- package/dist/TxHashSet.d.ts +1 -1
- package/dist/TxHashSet.d.ts.map +1 -1
- package/dist/TxHashSet.js +1 -1
- package/dist/TxHashSet.js.map +1 -1
- package/dist/TxPriorityQueue.d.ts +1 -1
- package/dist/TxPriorityQueue.d.ts.map +1 -1
- package/dist/TxPriorityQueue.js +1 -1
- package/dist/TxPriorityQueue.js.map +1 -1
- package/dist/TxPubSub.d.ts +1 -1
- package/dist/TxPubSub.d.ts.map +1 -1
- package/dist/TxPubSub.js +1 -1
- package/dist/TxPubSub.js.map +1 -1
- package/dist/TxQueue.d.ts +9 -9
- package/dist/TxQueue.d.ts.map +1 -1
- package/dist/TxQueue.js +93 -86
- package/dist/TxQueue.js.map +1 -1
- package/dist/TxReentrantLock.d.ts +29 -1
- package/dist/TxReentrantLock.d.ts.map +1 -1
- package/dist/TxReentrantLock.js +29 -1
- package/dist/TxReentrantLock.js.map +1 -1
- package/dist/TxRef.d.ts +1 -1
- package/dist/TxRef.d.ts.map +1 -1
- package/dist/TxRef.js +1 -1
- package/dist/TxRef.js.map +1 -1
- package/dist/TxSemaphore.d.ts +1 -1
- package/dist/TxSemaphore.d.ts.map +1 -1
- package/dist/TxSemaphore.js +1 -1
- package/dist/TxSemaphore.js.map +1 -1
- package/dist/TxSubscriptionRef.d.ts +1 -1
- package/dist/TxSubscriptionRef.d.ts.map +1 -1
- package/dist/TxSubscriptionRef.js +1 -1
- package/dist/TxSubscriptionRef.js.map +1 -1
- package/dist/Types.d.ts +33 -19
- package/dist/Types.d.ts.map +1 -1
- package/dist/Utils.d.ts.map +1 -1
- package/dist/Utils.js +2 -1
- package/dist/Utils.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/arbitrary/model.d.ts +2 -0
- package/dist/internal/arbitrary/model.d.ts.map +1 -0
- package/dist/internal/arbitrary/model.js +495 -0
- package/dist/internal/arbitrary/model.js.map +1 -0
- package/dist/internal/arbitrary/regexp.d.ts +2 -0
- package/dist/internal/arbitrary/regexp.d.ts.map +1 -0
- package/dist/internal/arbitrary/regexp.js +789 -0
- package/dist/internal/arbitrary/regexp.js.map +1 -0
- package/dist/internal/arbitrary/runner.d.ts +2 -0
- package/dist/internal/arbitrary/runner.d.ts.map +1 -0
- package/dist/internal/arbitrary/runner.js +496 -0
- package/dist/internal/arbitrary/runner.js.map +1 -0
- package/dist/internal/arbitrary/schema.d.ts.map +1 -0
- package/dist/internal/arbitrary/schema.js +1340 -0
- package/dist/internal/arbitrary/schema.js.map +1 -0
- package/dist/internal/core.js +27 -13
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/count.d.ts +2 -0
- package/dist/internal/count.d.ts.map +1 -0
- package/dist/internal/count.js +14 -0
- package/dist/internal/count.js.map +1 -0
- package/dist/internal/dateTime.js +4 -10
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +416 -258
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/graph.js +3 -1
- package/dist/internal/graph.js.map +1 -1
- package/dist/internal/hashMap.js +5 -3
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/hashSet.js +1 -1
- package/dist/internal/hashSet.js.map +1 -1
- package/dist/internal/matcher.js +1 -1
- package/dist/internal/matcher.js.map +1 -1
- package/dist/internal/metric.js +1 -1
- package/dist/internal/metric.js.map +1 -1
- package/dist/internal/option.js +6 -5
- package/dist/internal/option.js.map +1 -1
- package/dist/internal/random.js +17 -0
- package/dist/internal/random.js.map +1 -1
- package/dist/internal/rcRef.js +10 -7
- package/dist/internal/rcRef.js.map +1 -1
- package/dist/internal/references.js +1 -0
- package/dist/internal/references.js.map +1 -1
- package/dist/internal/request.js +13 -6
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/result.js +11 -9
- package/dist/internal/result.js.map +1 -1
- package/dist/internal/schema/annotations.js +1 -1
- package/dist/internal/schema/annotations.js.map +1 -1
- package/dist/internal/schema/fromJsonSchemaDocument.js +238 -132
- package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -1
- package/dist/internal/schema/fromRepresentation.js +5 -5
- package/dist/internal/schema/fromRepresentation.js.map +1 -1
- package/dist/internal/schema/make.d.ts +2 -0
- package/dist/internal/schema/make.d.ts.map +1 -0
- package/dist/internal/schema/{schema.js → make.js} +1 -25
- package/dist/internal/schema/make.js.map +1 -0
- package/dist/internal/schema/parser.d.ts +0 -12
- package/dist/internal/schema/parser.d.ts.map +1 -1
- package/dist/internal/schema/parser.js +7 -0
- package/dist/internal/schema/parser.js.map +1 -1
- package/dist/internal/schema/standardSchema.d.ts +2 -0
- package/dist/internal/schema/standardSchema.d.ts.map +1 -0
- package/dist/internal/schema/standardSchema.js +112 -0
- package/dist/internal/schema/standardSchema.js.map +1 -0
- package/dist/internal/schema/toCodeDocument.js +34 -22
- package/dist/internal/schema/toCodeDocument.js.map +1 -1
- package/dist/internal/schema/toCodec.d.ts +2 -0
- package/dist/internal/schema/toCodec.d.ts.map +1 -0
- package/dist/internal/schema/toCodec.js +242 -0
- package/dist/internal/schema/toCodec.js.map +1 -0
- package/dist/internal/schema/toDifferJsonPatch.d.ts +2 -0
- package/dist/internal/schema/toDifferJsonPatch.d.ts.map +1 -0
- package/dist/internal/schema/toDifferJsonPatch.js +20 -0
- package/dist/internal/schema/toDifferJsonPatch.js.map +1 -0
- package/dist/internal/schema/toEncoderXml.d.ts +2 -0
- package/dist/internal/schema/toEncoderXml.d.ts.map +1 -0
- package/dist/internal/schema/toEncoderXml.js +104 -0
- package/dist/internal/schema/toEncoderXml.js.map +1 -0
- package/dist/internal/schema/toEquivalence.js +66 -0
- package/dist/internal/schema/toEquivalence.js.map +1 -1
- package/dist/internal/schema/toFormatter.d.ts +2 -0
- package/dist/internal/schema/toFormatter.d.ts.map +1 -0
- package/dist/internal/schema/toFormatter.js +227 -0
- package/dist/internal/schema/toFormatter.js.map +1 -0
- package/dist/internal/schema/toIso.d.ts +2 -0
- package/dist/internal/schema/toIso.d.ts.map +1 -0
- package/dist/internal/schema/toIso.js +17 -0
- package/dist/internal/schema/toIso.js.map +1 -0
- package/dist/internal/schema/toJsonSchemaDocument.js +122 -71
- package/dist/internal/schema/toJsonSchemaDocument.js.map +1 -1
- package/dist/internal/schema/toRepresentation.js +3 -1
- package/dist/internal/schema/toRepresentation.js.map +1 -1
- package/dist/internal/schemaError.d.ts +4 -0
- package/dist/internal/schemaError.d.ts.map +1 -0
- package/dist/internal/schemaError.js +6 -0
- package/dist/internal/schemaError.js.map +1 -0
- package/dist/internal/stream.js +5 -6
- package/dist/internal/stream.js.map +1 -1
- package/dist/internal/tracer.d.ts +1 -3
- package/dist/internal/tracer.d.ts.map +1 -1
- package/dist/internal/tracer.js +6 -0
- package/dist/internal/tracer.js.map +1 -1
- package/dist/internal/trie.js +2 -2
- package/dist/internal/trie.js.map +1 -1
- package/dist/internal/uuid.d.ts +1 -2
- package/dist/internal/uuid.d.ts.map +1 -1
- package/dist/internal/uuid.js +2 -0
- package/dist/internal/uuid.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +9 -11
- package/dist/testing/TestSchema.d.ts.map +1 -1
- package/dist/testing/TestSchema.js +20 -18
- package/dist/testing/TestSchema.js.map +1 -1
- package/dist/testing/index.d.ts +0 -4
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +0 -4
- package/dist/testing/index.js.map +1 -1
- package/dist/unstable/ai/AiError.d.ts +98 -23
- package/dist/unstable/ai/AiError.d.ts.map +1 -1
- package/dist/unstable/ai/AiError.js +98 -6
- package/dist/unstable/ai/AiError.js.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.js +5 -16
- package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Chat.d.ts +27 -32
- package/dist/unstable/ai/Chat.d.ts.map +1 -1
- package/dist/unstable/ai/Chat.js +10 -13
- package/dist/unstable/ai/Chat.js.map +1 -1
- package/dist/unstable/ai/EmbeddingModel.d.ts +23 -16
- package/dist/unstable/ai/EmbeddingModel.d.ts.map +1 -1
- package/dist/unstable/ai/EmbeddingModel.js +13 -11
- package/dist/unstable/ai/EmbeddingModel.js.map +1 -1
- package/dist/unstable/ai/LanguageModel.d.ts +48 -37
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +150 -47
- package/dist/unstable/ai/LanguageModel.js.map +1 -1
- package/dist/unstable/ai/McpServer.d.ts +2 -2
- package/dist/unstable/ai/McpServer.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.js +87 -78
- package/dist/unstable/ai/McpServer.js.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js +3 -14
- package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Prompt.d.ts +2 -2
- package/dist/unstable/ai/Prompt.d.ts.map +1 -1
- package/dist/unstable/ai/Prompt.js +15 -4
- package/dist/unstable/ai/Prompt.js.map +1 -1
- package/dist/unstable/ai/Response.d.ts +37 -94
- package/dist/unstable/ai/Response.d.ts.map +1 -1
- package/dist/unstable/ai/Response.js +46 -96
- package/dist/unstable/ai/Response.js.map +1 -1
- package/dist/unstable/ai/Tokenizer.js +4 -5
- package/dist/unstable/ai/Tokenizer.js.map +1 -1
- package/dist/unstable/ai/Tool.d.ts +38 -20
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +27 -1
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/ai/Toolkit.d.ts +1 -1
- package/dist/unstable/ai/Toolkit.d.ts.map +1 -1
- package/dist/unstable/ai/Toolkit.js +30 -18
- package/dist/unstable/ai/Toolkit.js.map +1 -1
- package/dist/unstable/ai/internal/codec-transformer.js +2 -2
- package/dist/unstable/ai/internal/codec-transformer.js.map +1 -1
- package/dist/unstable/ai/internal/structured-output.js +28 -5
- package/dist/unstable/ai/internal/structured-output.js.map +1 -1
- package/dist/unstable/arbitrary/Arbitrary.d.ts +626 -0
- package/dist/unstable/arbitrary/Arbitrary.d.ts.map +1 -0
- package/dist/unstable/arbitrary/Arbitrary.js +238 -0
- package/dist/unstable/arbitrary/Arbitrary.js.map +1 -0
- package/dist/unstable/arbitrary/index.d.ts +8 -0
- package/dist/unstable/arbitrary/index.d.ts.map +1 -0
- package/dist/unstable/arbitrary/index.js +9 -0
- package/dist/unstable/arbitrary/index.js.map +1 -0
- package/dist/unstable/cli/Argument.d.ts +104 -108
- package/dist/unstable/cli/Argument.d.ts.map +1 -1
- package/dist/unstable/cli/Argument.js +56 -57
- package/dist/unstable/cli/Argument.js.map +1 -1
- package/dist/unstable/cli/CliError.d.ts +2 -0
- package/dist/unstable/cli/CliError.d.ts.map +1 -1
- package/dist/unstable/cli/CliError.js +2 -0
- package/dist/unstable/cli/CliError.js.map +1 -1
- package/dist/unstable/cli/CliOutput.js +27 -4
- package/dist/unstable/cli/CliOutput.js.map +1 -1
- package/dist/unstable/cli/Command.d.ts +73 -73
- package/dist/unstable/cli/Command.d.ts.map +1 -1
- package/dist/unstable/cli/Command.js +22 -22
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cli/Completions.d.ts +4 -4
- package/dist/unstable/cli/Completions.d.ts.map +1 -1
- package/dist/unstable/cli/Flag.d.ts +150 -161
- package/dist/unstable/cli/Flag.d.ts.map +1 -1
- package/dist/unstable/cli/Flag.js +79 -90
- package/dist/unstable/cli/Flag.js.map +1 -1
- package/dist/unstable/cli/GlobalFlag.d.ts +3 -3
- package/dist/unstable/cli/GlobalFlag.js +13 -13
- package/dist/unstable/cli/GlobalFlag.js.map +1 -1
- package/dist/unstable/cli/Param.d.ts +118 -126
- package/dist/unstable/cli/Param.d.ts.map +1 -1
- package/dist/unstable/cli/Param.js +104 -113
- package/dist/unstable/cli/Param.js.map +1 -1
- package/dist/unstable/cli/Primitive.d.ts +69 -58
- package/dist/unstable/cli/Primitive.d.ts.map +1 -1
- package/dist/unstable/cli/Primitive.js +65 -66
- package/dist/unstable/cli/Primitive.js.map +1 -1
- package/dist/unstable/cli/Prompt.d.ts +113 -59
- package/dist/unstable/cli/Prompt.d.ts.map +1 -1
- package/dist/unstable/cli/Prompt.js +391 -327
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/cli/internal/completions/bash.js +109 -38
- package/dist/unstable/cli/internal/completions/bash.js.map +1 -1
- package/dist/unstable/cli/internal/completions/descriptor.js +23 -11
- package/dist/unstable/cli/internal/completions/descriptor.js.map +1 -1
- package/dist/unstable/cli/internal/completions/fish.js +15 -7
- package/dist/unstable/cli/internal/completions/fish.js.map +1 -1
- package/dist/unstable/cli/internal/completions/zsh.js +6 -4
- package/dist/unstable/cli/internal/completions/zsh.js.map +1 -1
- package/dist/unstable/cli/internal/config.js +4 -4
- package/dist/unstable/cli/internal/parser.js +1 -1
- package/dist/unstable/cli/internal/parser.js.map +1 -1
- package/dist/unstable/cli/internal/wizard.d.ts +5 -1
- package/dist/unstable/cli/internal/wizard.d.ts.map +1 -1
- package/dist/unstable/cli/internal/wizard.js +34 -26
- package/dist/unstable/cli/internal/wizard.js.map +1 -1
- package/dist/unstable/cluster/ClusterSchema.d.ts +13 -0
- package/dist/unstable/cluster/ClusterSchema.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterSchema.js +16 -1
- package/dist/unstable/cluster/ClusterSchema.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +57 -14
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/cluster/Entity.d.ts.map +1 -1
- package/dist/unstable/cluster/Entity.js +2 -0
- package/dist/unstable/cluster/Entity.js.map +1 -1
- package/dist/unstable/cluster/EntityProxyServer.d.ts +2 -2
- package/dist/unstable/cluster/EntityProxyServer.d.ts.map +1 -1
- package/dist/unstable/cluster/EntityProxyServer.js.map +1 -1
- package/dist/unstable/cluster/Envelope.d.ts +22 -5
- package/dist/unstable/cluster/Envelope.d.ts.map +1 -1
- package/dist/unstable/cluster/Envelope.js +23 -3
- package/dist/unstable/cluster/Envelope.js.map +1 -1
- package/dist/unstable/cluster/HttpRunner.d.ts.map +1 -1
- package/dist/unstable/cluster/HttpRunner.js +32 -13
- package/dist/unstable/cluster/HttpRunner.js.map +1 -1
- package/dist/unstable/cluster/Message.d.ts +17 -5
- package/dist/unstable/cluster/Message.d.ts.map +1 -1
- package/dist/unstable/cluster/Message.js +21 -8
- package/dist/unstable/cluster/Message.js.map +1 -1
- package/dist/unstable/cluster/MessageStorage.d.ts +34 -4
- package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/MessageStorage.js +33 -12
- package/dist/unstable/cluster/MessageStorage.js.map +1 -1
- package/dist/unstable/cluster/Reply.d.ts +5 -4
- package/dist/unstable/cluster/Reply.d.ts.map +1 -1
- package/dist/unstable/cluster/Reply.js +21 -12
- package/dist/unstable/cluster/Reply.js.map +1 -1
- package/dist/unstable/cluster/RunnerServer.d.ts +1 -1
- package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerServer.js +12 -6
- package/dist/unstable/cluster/RunnerServer.js.map +1 -1
- package/dist/unstable/cluster/Runners.d.ts +11 -5
- package/dist/unstable/cluster/Runners.d.ts.map +1 -1
- package/dist/unstable/cluster/Runners.js +56 -35
- package/dist/unstable/cluster/Runners.js.map +1 -1
- package/dist/unstable/cluster/Sharding.d.ts +1 -1
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +32 -17
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.js +23 -23
- package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
- package/dist/unstable/cluster/SocketRunner.d.ts +2 -2
- package/dist/unstable/cluster/SocketRunner.d.ts.map +1 -1
- package/dist/unstable/cluster/SocketRunner.js +4 -3
- package/dist/unstable/cluster/SocketRunner.js.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.js +11 -8
- package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.js +11 -4
- package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/unstable/cluster/internal/clusterAbandon.d.ts +5 -0
- package/dist/unstable/cluster/internal/clusterAbandon.d.ts.map +1 -0
- package/dist/unstable/cluster/internal/clusterAbandon.js +9 -0
- package/dist/unstable/cluster/internal/clusterAbandon.js.map +1 -0
- package/dist/unstable/cluster/internal/entityManager.js +10 -6
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/cluster/internal/interruptors.js +30 -1
- package/dist/unstable/cluster/internal/interruptors.js.map +1 -1
- package/dist/unstable/cluster/internal/resourceRef.js +12 -7
- package/dist/unstable/cluster/internal/resourceRef.js.map +1 -1
- package/dist/unstable/devtools/DevToolsClient.d.ts.map +1 -1
- package/dist/unstable/devtools/DevToolsClient.js +12 -7
- package/dist/unstable/devtools/DevToolsClient.js.map +1 -1
- package/dist/unstable/encoding/Ini.d.ts +2 -0
- package/dist/unstable/encoding/Ini.d.ts.map +1 -1
- package/dist/unstable/encoding/Ini.js +2 -0
- package/dist/unstable/encoding/Ini.js.map +1 -1
- package/dist/unstable/encoding/SchemaBinary.d.ts +273 -0
- package/dist/unstable/encoding/SchemaBinary.d.ts.map +1 -0
- package/dist/unstable/encoding/SchemaBinary.js +4573 -0
- package/dist/unstable/encoding/SchemaBinary.js.map +1 -0
- package/dist/unstable/encoding/Sse.js +1 -1
- package/dist/unstable/encoding/Sse.js.map +1 -1
- package/dist/unstable/encoding/Toml.d.ts +2 -0
- package/dist/unstable/encoding/Toml.d.ts.map +1 -1
- package/dist/unstable/encoding/Toml.js +6 -4
- package/dist/unstable/encoding/Toml.js.map +1 -1
- package/dist/unstable/encoding/Yaml.d.ts +2 -0
- package/dist/unstable/encoding/Yaml.d.ts.map +1 -1
- package/dist/unstable/encoding/Yaml.js +16 -5
- package/dist/unstable/encoding/Yaml.js.map +1 -1
- package/dist/unstable/encoding/index.d.ts +2 -2
- package/dist/unstable/encoding/index.d.ts.map +1 -1
- package/dist/unstable/encoding/index.js +2 -2
- package/dist/unstable/encoding/index.js.map +1 -1
- package/dist/unstable/eventlog/Event.d.ts +5 -5
- package/dist/unstable/eventlog/Event.d.ts.map +1 -1
- package/dist/unstable/eventlog/Event.js +3 -3
- package/dist/unstable/eventlog/Event.js.map +1 -1
- package/dist/unstable/eventlog/EventJournal.d.ts +15 -9
- package/dist/unstable/eventlog/EventJournal.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventJournal.js +26 -12
- package/dist/unstable/eventlog/EventJournal.js.map +1 -1
- package/dist/unstable/eventlog/EventLog.d.ts +1 -1
- package/dist/unstable/eventlog/EventLog.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLog.js +13 -9
- package/dist/unstable/eventlog/EventLog.js.map +1 -1
- package/dist/unstable/eventlog/EventLogMessage.d.ts +11 -5
- package/dist/unstable/eventlog/EventLogMessage.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogMessage.js +25 -15
- package/dist/unstable/eventlog/EventLogMessage.js.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.d.ts +7 -1
- package/dist/unstable/eventlog/EventLogRemote.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.js +13 -3
- package/dist/unstable/eventlog/EventLogRemote.js.map +1 -1
- package/dist/unstable/eventlog/EventLogServerUnencrypted.js +2 -2
- package/dist/unstable/eventlog/EventLogServerUnencrypted.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventJournal.d.ts +0 -10
- package/dist/unstable/eventlog/SqlEventJournal.d.ts.map +1 -1
- package/dist/unstable/eventlog/SqlEventJournal.js +29 -14
- package/dist/unstable/eventlog/SqlEventJournal.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.d.ts.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js +5 -1
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js.map +1 -1
- package/dist/unstable/http/Cookies.d.ts +1 -45
- package/dist/unstable/http/Cookies.d.ts.map +1 -1
- package/dist/unstable/http/Cookies.js +2 -64
- package/dist/unstable/http/Cookies.js.map +1 -1
- package/dist/unstable/http/FetchHttpClient.js +1 -1
- package/dist/unstable/http/FetchHttpClient.js.map +1 -1
- package/dist/unstable/http/FindMyWay/internal/router.js +124 -33
- package/dist/unstable/http/FindMyWay/internal/router.js.map +1 -1
- package/dist/unstable/http/FindMyWay.d.ts +15 -5
- package/dist/unstable/http/FindMyWay.d.ts.map +1 -1
- package/dist/unstable/http/FindMyWay.js +3 -1
- package/dist/unstable/http/FindMyWay.js.map +1 -1
- package/dist/unstable/http/Headers.d.ts +0 -22
- package/dist/unstable/http/Headers.d.ts.map +1 -1
- package/dist/unstable/http/Headers.js +3 -34
- package/dist/unstable/http/Headers.js.map +1 -1
- package/dist/unstable/http/HttpBody.d.ts +41 -10
- package/dist/unstable/http/HttpBody.d.ts.map +1 -1
- package/dist/unstable/http/HttpBody.js +64 -10
- package/dist/unstable/http/HttpBody.js.map +1 -1
- package/dist/unstable/http/HttpClient.d.ts +1 -1
- package/dist/unstable/http/HttpClient.d.ts.map +1 -1
- package/dist/unstable/http/HttpClient.js +28 -18
- package/dist/unstable/http/HttpClient.js.map +1 -1
- package/dist/unstable/http/HttpClientRequest.d.ts +28 -6
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.js +8 -19
- package/dist/unstable/http/HttpClientRequest.js.map +1 -1
- package/dist/unstable/http/HttpClientResponse.d.ts +6 -1
- package/dist/unstable/http/HttpClientResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientResponse.js +10 -6
- package/dist/unstable/http/HttpClientResponse.js.map +1 -1
- package/dist/unstable/http/HttpEffect.d.ts +16 -0
- package/dist/unstable/http/HttpEffect.d.ts.map +1 -1
- package/dist/unstable/http/HttpEffect.js +121 -65
- package/dist/unstable/http/HttpEffect.js.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.d.ts +3 -3
- package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.js +1 -13
- package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
- package/dist/unstable/http/HttpMiddleware.d.ts +1 -1
- package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/unstable/http/HttpMiddleware.js +29 -21
- package/dist/unstable/http/HttpMiddleware.js.map +1 -1
- package/dist/unstable/http/HttpPlatform.d.ts +12 -11
- package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
- package/dist/unstable/http/HttpPlatform.js +36 -10
- package/dist/unstable/http/HttpPlatform.js.map +1 -1
- package/dist/unstable/http/HttpRouter.d.ts +5 -1
- package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
- package/dist/unstable/http/HttpRouter.js +22 -8
- package/dist/unstable/http/HttpRouter.js.map +1 -1
- package/dist/unstable/http/HttpServer.d.ts +11 -42
- package/dist/unstable/http/HttpServer.d.ts.map +1 -1
- package/dist/unstable/http/HttpServer.js +16 -20
- package/dist/unstable/http/HttpServer.js.map +1 -1
- package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRequest.js +11 -11
- package/dist/unstable/http/HttpServerRequest.js.map +1 -1
- package/dist/unstable/http/HttpServerRespondable.js +1 -1
- package/dist/unstable/http/HttpServerRespondable.js.map +1 -1
- package/dist/unstable/http/HttpServerResponse.d.ts +9 -13
- package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerResponse.js +34 -44
- package/dist/unstable/http/HttpServerResponse.js.map +1 -1
- package/dist/unstable/http/HttpStaticServer.d.ts +2 -2
- package/dist/unstable/http/HttpStaticServer.d.ts.map +1 -1
- package/dist/unstable/http/HttpStaticServer.js +19 -19
- package/dist/unstable/http/HttpStaticServer.js.map +1 -1
- package/dist/unstable/http/Mime.d.ts +28 -0
- package/dist/unstable/http/Mime.d.ts.map +1 -0
- package/dist/unstable/http/Mime.js +72 -0
- package/dist/unstable/http/Mime.js.map +1 -0
- package/dist/unstable/http/Multipart.d.ts +22 -9
- package/dist/unstable/http/Multipart.d.ts.map +1 -1
- package/dist/unstable/http/Multipart.js +26 -10
- package/dist/unstable/http/Multipart.js.map +1 -1
- package/dist/unstable/http/MultipartParser/internal/multipart.d.ts +1 -1
- package/dist/unstable/http/MultipartParser/internal/multipart.d.ts.map +1 -1
- package/dist/unstable/http/MultipartParser/internal/multipart.js +8 -3
- package/dist/unstable/http/MultipartParser/internal/multipart.js.map +1 -1
- package/dist/unstable/http/MultipartParser.d.ts +4 -3
- package/dist/unstable/http/MultipartParser.d.ts.map +1 -1
- package/dist/unstable/http/MultipartParser.js.map +1 -1
- package/dist/unstable/http/UrlParams.d.ts +0 -97
- package/dist/unstable/http/UrlParams.d.ts.map +1 -1
- package/dist/unstable/http/UrlParams.js +3 -104
- package/dist/unstable/http/UrlParams.js.map +1 -1
- package/dist/unstable/http/index.d.ts +4 -0
- package/dist/unstable/http/index.d.ts.map +1 -1
- package/dist/unstable/http/index.js +4 -0
- package/dist/unstable/http/index.js.map +1 -1
- package/dist/unstable/http/internal/compression.js +8 -11
- package/dist/unstable/http/internal/compression.js.map +1 -1
- package/dist/unstable/http/internal/headers.d.ts +2 -0
- package/dist/unstable/http/internal/headers.d.ts.map +1 -0
- package/dist/unstable/http/internal/headers.js +5 -0
- package/dist/unstable/http/internal/headers.js.map +1 -0
- package/dist/unstable/http/internal/httpBody.js +8 -0
- package/dist/unstable/http/internal/httpBody.js.map +1 -1
- package/dist/unstable/http/internal/mimeTypes.d.ts +361 -0
- package/dist/unstable/http/internal/mimeTypes.d.ts.map +1 -0
- package/dist/unstable/http/internal/mimeTypes.js +363 -0
- package/dist/unstable/http/internal/mimeTypes.js.map +1 -0
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts +13 -0
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +28 -11
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.d.ts +4 -3
- package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.js +25 -13
- package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +8 -3
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.js +9 -6
- package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.js +3 -1
- package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.js +7 -5
- package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.js +15 -12
- package/dist/unstable/httpapi/HttpApiScalar.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.d.ts +12 -0
- package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.js +8 -10
- package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSwagger.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSwagger.js +6 -3
- package/dist/unstable/httpapi/HttpApiSwagger.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiTest.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiTest.js +8 -2
- package/dist/unstable/httpapi/HttpApiTest.js.map +1 -1
- package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/OpenApi.js +31 -20
- package/dist/unstable/httpapi/OpenApi.js.map +1 -1
- package/dist/unstable/net/IpInterface.d.ts +140 -0
- package/dist/unstable/net/IpInterface.d.ts.map +1 -0
- package/dist/unstable/net/IpInterface.js +149 -0
- package/dist/unstable/net/IpInterface.js.map +1 -0
- package/dist/unstable/net/IpNetwork.d.ts +227 -0
- package/dist/unstable/net/IpNetwork.d.ts.map +1 -0
- package/dist/unstable/net/IpNetwork.js +239 -0
- package/dist/unstable/net/IpNetwork.js.map +1 -0
- package/dist/unstable/net/NetAddress.d.ts +705 -0
- package/dist/unstable/net/NetAddress.d.ts.map +1 -0
- package/dist/unstable/net/NetAddress.js +956 -0
- package/dist/unstable/net/NetAddress.js.map +1 -0
- package/dist/unstable/net/index.d.ts +16 -0
- package/dist/unstable/net/index.d.ts.map +1 -0
- package/dist/unstable/net/index.js +17 -0
- package/dist/unstable/net/index.js.map +1 -0
- package/dist/unstable/observability/OtlpExporter.d.ts +1 -0
- package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.js +4 -6
- package/dist/unstable/observability/OtlpExporter.js.map +1 -1
- package/dist/unstable/observability/OtlpLogger.js +9 -9
- package/dist/unstable/observability/OtlpLogger.js.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.js +9 -8
- package/dist/unstable/observability/OtlpMetrics.js.map +1 -1
- package/dist/unstable/observability/OtlpResource.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpResource.js +2 -2
- package/dist/unstable/observability/OtlpResource.js.map +1 -1
- package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpTracer.js +82 -55
- package/dist/unstable/observability/OtlpTracer.js.map +1 -1
- package/dist/unstable/observability/internal/otlpEnv.d.ts +1 -1
- package/dist/unstable/observability/internal/otlpEnv.d.ts.map +1 -1
- package/dist/unstable/observability/internal/otlpEnv.js +5 -9
- package/dist/unstable/observability/internal/otlpEnv.js.map +1 -1
- package/dist/unstable/persistence/PersistedCache.js +1 -1
- package/dist/unstable/persistence/PersistedCache.js.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.d.ts +114 -14
- package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.js +799 -234
- package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
- package/dist/unstable/persistence/RateLimiter.d.ts +28 -15
- package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
- package/dist/unstable/persistence/RateLimiter.js +33 -41
- package/dist/unstable/persistence/RateLimiter.js.map +1 -1
- package/dist/unstable/process/ChildProcess.d.ts +8 -2
- package/dist/unstable/process/ChildProcess.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcess.js +7 -2
- package/dist/unstable/process/ChildProcess.js.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.d.ts +1 -1
- package/dist/unstable/process/ChildProcessSpawner.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.js +1 -1
- package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +6 -3
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts +3 -6
- package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.js +6 -3
- package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.js +2 -3
- package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.d.ts +2 -2
- package/dist/unstable/reactivity/AtomRpc.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.js +1 -1
- package/dist/unstable/reactivity/AtomRpc.js.map +1 -1
- package/dist/unstable/reactivity/Hydration.d.ts +6 -4
- package/dist/unstable/reactivity/Hydration.d.ts.map +1 -1
- package/dist/unstable/reactivity/Hydration.js +20 -6
- package/dist/unstable/reactivity/Hydration.js.map +1 -1
- package/dist/unstable/reactivity/Reactivity.d.ts +26 -26
- package/dist/unstable/reactivity/Reactivity.d.ts.map +1 -1
- package/dist/unstable/reactivity/Reactivity.js +10 -12
- package/dist/unstable/reactivity/Reactivity.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts +5 -0
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +94 -81
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/rpc/RpcClientError.d.ts +1 -1
- package/dist/unstable/rpc/RpcMessage.d.ts +66 -7
- package/dist/unstable/rpc/RpcMessage.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMessage.js +68 -9
- package/dist/unstable/rpc/RpcMessage.js.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.js +7 -5
- package/dist/unstable/rpc/RpcMiddleware.js.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.d.ts +28 -33
- package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.js +56 -92
- package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts +25 -0
- package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +125 -68
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/schema/Model.d.ts.map +1 -1
- package/dist/unstable/schema/Model.js +7 -6
- package/dist/unstable/schema/Model.js.map +1 -1
- package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
- package/dist/unstable/schema/VariantSchema.js +3 -0
- package/dist/unstable/schema/VariantSchema.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts +287 -102
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +408 -215
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/dist/unstable/socket/SocketServer.d.ts +5 -32
- package/dist/unstable/socket/SocketServer.d.ts.map +1 -1
- package/dist/unstable/socket/SocketServer.js +3 -3
- package/dist/unstable/socket/SocketServer.js.map +1 -1
- package/dist/unstable/sql/SqlClient.d.ts +20 -0
- package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
- package/dist/unstable/sql/SqlClient.js +14 -7
- package/dist/unstable/sql/SqlClient.js.map +1 -1
- package/dist/unstable/sql/SqlConnection.d.ts +15 -0
- package/dist/unstable/sql/SqlConnection.d.ts.map +1 -1
- package/dist/unstable/sql/SqlConnection.js.map +1 -1
- package/dist/unstable/sql/SqlModel.d.ts +1 -1
- package/dist/unstable/sql/SqlModel.d.ts.map +1 -1
- package/dist/unstable/sql/Statement.d.ts +13 -5
- package/dist/unstable/sql/Statement.d.ts.map +1 -1
- package/dist/unstable/sql/Statement.js +29 -15
- package/dist/unstable/sql/Statement.js.map +1 -1
- package/dist/unstable/workers/Transferable.js +1 -1
- package/dist/unstable/workers/Worker.d.ts.map +1 -1
- package/dist/unstable/workers/Worker.js +3 -1
- package/dist/unstable/workers/Worker.js.map +1 -1
- package/dist/unstable/workflow/Activity.d.ts +7 -0
- package/dist/unstable/workflow/Activity.d.ts.map +1 -1
- package/dist/unstable/workflow/Activity.js +14 -4
- package/dist/unstable/workflow/Activity.js.map +1 -1
- package/dist/unstable/workflow/DurableClock.js +1 -1
- package/dist/unstable/workflow/DurableClock.js.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.d.ts +2 -2
- package/dist/unstable/workflow/DurableDeferred.d.ts.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
- package/dist/unstable/workflow/DurableQueue.d.ts +8 -0
- package/dist/unstable/workflow/DurableQueue.d.ts.map +1 -1
- package/dist/unstable/workflow/DurableQueue.js +8 -0
- package/dist/unstable/workflow/DurableQueue.js.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts +5 -0
- package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
- package/dist/unstable/workflow/Workflow.js +70 -12
- package/dist/unstable/workflow/Workflow.js.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts +6 -0
- package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js +11 -0
- package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
- package/dist/unstable/workflow/WorkflowProxy.d.ts +2 -2
- package/dist/unstable/workflow/WorkflowProxy.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowProxy.js +4 -2
- package/dist/unstable/workflow/WorkflowProxy.js.map +1 -1
- package/package.json +8 -10
- package/src/Array.ts +142 -70
- package/src/BigDecimal.ts +50 -28
- package/src/ByteSize.ts +838 -0
- package/src/Cache.ts +17 -3
- package/src/Cause.ts +1 -1
- package/src/Channel.ts +185 -50
- package/src/Chunk.ts +65 -36
- package/src/Config.ts +237 -248
- package/src/ConfigProvider.ts +7 -8
- package/src/Context.ts +31 -0
- package/src/Cron.ts +2 -2
- package/src/Crypto.ts +3 -2
- package/src/Deferred.ts +7 -6
- package/src/Duration.ts +1 -1
- package/src/Effect.ts +226 -122
- package/src/Effectable.ts +78 -9
- package/src/Encoding.ts +101 -11
- package/src/Equal.ts +1 -1
- package/src/ExecutionPlan.ts +3 -0
- package/src/Fiber.ts +33 -8
- package/src/FiberHandle.ts +3 -3
- package/src/FiberMap.ts +19 -10
- package/src/FileSystem.ts +55 -230
- package/src/Formatter.ts +21 -3
- package/src/Graph.ts +55 -25
- package/src/Hash.ts +5 -16
- package/src/HashRing.ts +9 -2
- package/src/HashSet.ts +56 -0
- package/src/Iterable.ts +90 -44
- package/src/JsonPatch.ts +4 -4
- package/src/JsonPointer.ts +97 -4
- package/src/JsonSchema.ts +998 -476
- package/src/Layer.ts +59 -18
- package/src/LayerMap.ts +38 -6
- package/src/LayerRef.ts +7 -5
- package/src/Logger.ts +125 -18
- package/src/ManagedRuntime.ts +1 -1
- package/src/Match.ts +33 -14
- package/src/Metric.ts +24 -21
- package/src/MutableHashMap.ts +1 -1
- package/src/MutableHashSet.ts +1 -1
- package/src/MutableList.ts +18 -2
- package/src/Number.ts +7 -1
- package/src/Optic.ts +8 -4
- package/src/Option.ts +1 -1
- package/src/Order.ts +3 -1
- package/src/PartitionedSemaphore.ts +1 -2
- package/src/Path.ts +1 -1
- package/src/PlatformError.ts +1 -1
- package/src/Pool.ts +535 -134
- package/src/PrimaryKey.ts +1 -1
- package/src/PubSub.ts +32 -20
- package/src/Queue.ts +119 -28
- package/src/Random.ts +20 -6
- package/src/RcMap.ts +176 -13
- package/src/Record.ts +15 -0
- package/src/Redacted.ts +1 -1
- package/src/RequestResolver.ts +49 -26
- package/src/Result.ts +1 -1
- package/src/Scheduler.ts +21 -11
- package/src/Schema.ts +5032 -6518
- package/src/SchemaAST.ts +1156 -316
- package/src/SchemaGetter.ts +75 -21
- package/src/SchemaIssue.ts +260 -16
- package/src/SchemaParser.ts +2 -12
- package/src/SchemaRepresentation.ts +1774 -189
- package/src/SchemaTransformation.ts +145 -22
- package/src/Scope.ts +9 -2
- package/src/ScopedCache.ts +10 -3
- package/src/Sink.ts +31 -15
- package/src/StandardSchema.ts +207 -0
- package/src/Stream.ts +294 -76
- package/src/String.ts +20 -9
- package/src/Struct.ts +8 -4
- package/src/SynchronizedRef.ts +3 -5
- package/src/Terminal.ts +3 -3
- package/src/Tracer.ts +43 -14
- package/src/Tuple.ts +3 -1
- package/src/TxChunk.ts +1 -1
- package/src/TxDeferred.ts +1 -1
- package/src/TxHashMap.ts +1 -1
- package/src/TxHashSet.ts +92 -11
- package/src/TxPriorityQueue.ts +1 -1
- package/src/TxPubSub.ts +1 -1
- package/src/TxQueue.ts +22 -17
- package/src/TxReentrantLock.ts +29 -1
- package/src/TxRef.ts +1 -1
- package/src/TxSemaphore.ts +1 -1
- package/src/TxSubscriptionRef.ts +1 -1
- package/src/Types.ts +40 -17
- package/src/Utils.ts +3 -1
- package/src/index.ts +10 -0
- package/src/internal/arbitrary/model.ts +701 -0
- package/src/internal/arbitrary/regexp.ts +855 -0
- package/src/internal/arbitrary/runner.ts +608 -0
- package/src/internal/arbitrary/schema.ts +1800 -0
- package/src/internal/core.ts +48 -22
- package/src/internal/count.ts +14 -0
- package/src/internal/dateTime.ts +8 -10
- package/src/internal/effect.ts +510 -301
- package/src/internal/graph.ts +6 -1
- package/src/internal/hashMap.ts +5 -3
- package/src/internal/hashSet.ts +1 -1
- package/src/internal/matcher.ts +34 -19
- package/src/internal/metric.ts +1 -1
- package/src/internal/option.ts +8 -6
- package/src/internal/random.ts +20 -7
- package/src/internal/rcRef.ts +10 -7
- package/src/internal/references.ts +1 -0
- package/src/internal/request.ts +12 -7
- package/src/internal/result.ts +15 -11
- package/src/internal/schema/annotations.ts +3 -3
- package/src/internal/schema/fromJsonSchemaDocument.ts +326 -160
- package/src/internal/schema/fromRepresentation.ts +5 -3
- package/src/internal/schema/{schema.ts → make.ts} +0 -40
- package/src/internal/schema/parser.ts +8 -0
- package/src/internal/schema/standardSchema.ts +125 -0
- package/src/internal/schema/toCodeDocument.ts +58 -44
- package/src/internal/schema/toCodec.ts +312 -0
- package/src/internal/schema/toDifferJsonPatch.ts +24 -0
- package/src/internal/schema/toEncoderXml.ts +110 -0
- package/src/internal/schema/toEquivalence.ts +76 -0
- package/src/internal/schema/toFormatter.ts +230 -0
- package/src/internal/schema/toIso.ts +20 -0
- package/src/internal/schema/toJsonSchemaDocument.ts +125 -67
- package/src/internal/schema/toRepresentation.ts +1 -1
- package/src/internal/schemaError.ts +8 -0
- package/src/internal/stream.ts +14 -6
- package/src/internal/tracer.ts +4 -0
- package/src/internal/trie.ts +5 -2
- package/src/internal/uuid.ts +4 -0
- package/src/testing/TestSchema.ts +36 -30
- package/src/testing/index.ts +0 -5
- package/src/unstable/ai/AiError.ts +126 -6
- package/src/unstable/ai/AnthropicStructuredOutput.ts +8 -5
- package/src/unstable/ai/Chat.ts +35 -36
- package/src/unstable/ai/EmbeddingModel.ts +27 -15
- package/src/unstable/ai/LanguageModel.ts +283 -100
- package/src/unstable/ai/McpServer.ts +105 -92
- package/src/unstable/ai/OpenAiStructuredOutput.ts +6 -3
- package/src/unstable/ai/Prompt.ts +20 -5
- package/src/unstable/ai/Response.ts +107 -189
- package/src/unstable/ai/Tokenizer.ts +4 -5
- package/src/unstable/ai/Tool.ts +58 -35
- package/src/unstable/ai/Toolkit.ts +43 -37
- package/src/unstable/ai/internal/codec-transformer.ts +3 -2
- package/src/unstable/ai/internal/structured-output.ts +29 -6
- package/src/unstable/arbitrary/Arbitrary.ts +715 -0
- package/src/unstable/arbitrary/index.ts +10 -0
- package/src/unstable/cli/Argument.ts +111 -115
- package/src/unstable/cli/CliError.ts +2 -0
- package/src/unstable/cli/CliOutput.ts +41 -4
- package/src/unstable/cli/Command.ts +79 -78
- package/src/unstable/cli/Completions.ts +4 -4
- package/src/unstable/cli/Flag.ts +158 -169
- package/src/unstable/cli/GlobalFlag.ts +13 -13
- package/src/unstable/cli/Param.ts +150 -159
- package/src/unstable/cli/Primitive.ts +75 -76
- package/src/unstable/cli/Prompt.ts +543 -408
- package/src/unstable/cli/internal/completions/bash.ts +113 -38
- package/src/unstable/cli/internal/completions/descriptor.ts +23 -11
- package/src/unstable/cli/internal/completions/fish.ts +17 -9
- package/src/unstable/cli/internal/completions/zsh.ts +7 -4
- package/src/unstable/cli/internal/config.ts +4 -4
- package/src/unstable/cli/internal/parser.ts +1 -1
- package/src/unstable/cli/internal/wizard.ts +60 -32
- package/src/unstable/cluster/ClusterSchema.ts +19 -1
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +66 -16
- package/src/unstable/cluster/Entity.ts +3 -0
- package/src/unstable/cluster/EntityProxyServer.ts +6 -2
- package/src/unstable/cluster/Envelope.ts +32 -3
- package/src/unstable/cluster/HttpRunner.ts +52 -25
- package/src/unstable/cluster/Message.ts +35 -13
- package/src/unstable/cluster/MessageStorage.ts +69 -24
- package/src/unstable/cluster/Reply.ts +36 -19
- package/src/unstable/cluster/RunnerServer.ts +21 -11
- package/src/unstable/cluster/Runners.ts +93 -80
- package/src/unstable/cluster/Sharding.ts +44 -19
- package/src/unstable/cluster/ShardingConfig.ts +23 -23
- package/src/unstable/cluster/SocketRunner.ts +5 -4
- package/src/unstable/cluster/SqlMessageStorage.ts +12 -8
- package/src/unstable/cluster/SqlRunnerStorage.ts +18 -10
- package/src/unstable/cluster/internal/clusterAbandon.ts +14 -0
- package/src/unstable/cluster/internal/entityManager.ts +15 -6
- package/src/unstable/cluster/internal/interruptors.ts +58 -1
- package/src/unstable/cluster/internal/resourceRef.ts +15 -7
- package/src/unstable/devtools/DevToolsClient.ts +13 -3
- package/src/unstable/encoding/Ini.ts +2 -0
- package/src/unstable/encoding/SchemaBinary.ts +5308 -0
- package/src/unstable/encoding/Sse.ts +1 -1
- package/src/unstable/encoding/Toml.ts +7 -5
- package/src/unstable/encoding/Yaml.ts +18 -5
- package/src/unstable/encoding/index.ts +2 -2
- package/src/unstable/eventlog/Event.ts +7 -7
- package/src/unstable/eventlog/EventJournal.ts +22 -15
- package/src/unstable/eventlog/EventLog.ts +24 -14
- package/src/unstable/eventlog/EventLogMessage.ts +25 -15
- package/src/unstable/eventlog/EventLogRemote.ts +15 -4
- package/src/unstable/eventlog/EventLogServerUnencrypted.ts +2 -2
- package/src/unstable/eventlog/SqlEventJournal.ts +35 -10
- package/src/unstable/eventlog/SqlEventLogServerUnencrypted.ts +11 -1
- package/src/unstable/http/Cookies.ts +2 -102
- package/src/unstable/http/FetchHttpClient.ts +1 -1
- package/src/unstable/http/FindMyWay/internal/router.ts +139 -33
- package/src/unstable/http/FindMyWay.ts +15 -5
- package/src/unstable/http/Headers.ts +3 -48
- package/src/unstable/http/HttpBody.ts +107 -36
- package/src/unstable/http/HttpClient.ts +41 -30
- package/src/unstable/http/HttpClientRequest.ts +32 -18
- package/src/unstable/http/HttpClientResponse.ts +16 -3
- package/src/unstable/http/HttpEffect.ts +145 -73
- package/src/unstable/http/HttpIncomingMessage.ts +4 -4
- package/src/unstable/http/HttpMiddleware.ts +43 -24
- package/src/unstable/http/HttpPlatform.ts +62 -20
- package/src/unstable/http/HttpRouter.ts +27 -16
- package/src/unstable/http/HttpServer.ts +18 -57
- package/src/unstable/http/HttpServerRequest.ts +17 -15
- package/src/unstable/http/HttpServerRespondable.ts +1 -1
- package/src/unstable/http/HttpServerResponse.ts +49 -40
- package/src/unstable/http/HttpStaticServer.ts +30 -28
- package/src/unstable/http/Mime.ts +76 -0
- package/src/unstable/http/Multipart.ts +35 -18
- package/src/unstable/http/MultipartParser/internal/multipart.ts +10 -3
- package/src/unstable/http/MultipartParser.ts +4 -3
- package/src/unstable/http/UrlParams.ts +3 -161
- package/src/unstable/http/index.ts +5 -0
- package/src/unstable/http/internal/compression.ts +11 -12
- package/src/unstable/http/internal/headers.ts +7 -0
- package/src/unstable/http/internal/httpBody.ts +9 -0
- package/src/unstable/http/internal/mimeTypes.ts +395 -0
- package/src/unstable/httpapi/HttpApiBuilder.ts +63 -11
- package/src/unstable/httpapi/HttpApiClient.ts +44 -24
- package/src/unstable/httpapi/HttpApiEndpoint.ts +24 -11
- package/src/unstable/httpapi/HttpApiError.ts +3 -1
- package/src/unstable/httpapi/HttpApiMiddleware.ts +7 -5
- package/src/unstable/httpapi/HttpApiScalar.ts +30 -27
- package/src/unstable/httpapi/HttpApiSchema.ts +14 -7
- package/src/unstable/httpapi/HttpApiSwagger.ts +6 -3
- package/src/unstable/httpapi/HttpApiTest.ts +6 -1
- package/src/unstable/httpapi/OpenApi.ts +32 -22
- package/src/unstable/net/IpInterface.ts +242 -0
- package/src/unstable/net/IpNetwork.ts +357 -0
- package/src/unstable/net/NetAddress.ts +1271 -0
- package/src/unstable/net/index.ts +20 -0
- package/src/unstable/observability/OtlpExporter.ts +5 -6
- package/src/unstable/observability/OtlpLogger.ts +9 -9
- package/src/unstable/observability/OtlpMetrics.ts +9 -8
- package/src/unstable/observability/OtlpResource.ts +5 -4
- package/src/unstable/observability/OtlpTracer.ts +103 -81
- package/src/unstable/observability/internal/otlpEnv.ts +10 -13
- package/src/unstable/persistence/PersistedCache.ts +1 -1
- package/src/unstable/persistence/PersistedQueue.ts +1100 -291
- package/src/unstable/persistence/RateLimiter.ts +64 -58
- package/src/unstable/process/ChildProcess.ts +15 -4
- package/src/unstable/process/ChildProcessSpawner.ts +1 -1
- package/src/unstable/reactivity/Atom.ts +6 -3
- package/src/unstable/reactivity/AtomHttpApi.ts +21 -10
- package/src/unstable/reactivity/AtomRegistry.ts +2 -4
- package/src/unstable/reactivity/AtomRpc.ts +6 -5
- package/src/unstable/reactivity/Hydration.ts +26 -7
- package/src/unstable/reactivity/Reactivity.ts +49 -36
- package/src/unstable/rpc/RpcClient.ts +100 -82
- package/src/unstable/rpc/RpcMessage.ts +78 -11
- package/src/unstable/rpc/RpcMiddleware.ts +7 -5
- package/src/unstable/rpc/RpcSerialization.ts +82 -92
- package/src/unstable/rpc/RpcServer.ts +171 -93
- package/src/unstable/schema/Model.ts +8 -7
- package/src/unstable/schema/VariantSchema.ts +3 -0
- package/src/unstable/socket/Socket.ts +714 -383
- package/src/unstable/socket/SocketServer.ts +5 -35
- package/src/unstable/sql/SqlClient.ts +42 -7
- package/src/unstable/sql/SqlConnection.ts +18 -0
- package/src/unstable/sql/SqlModel.ts +1 -1
- package/src/unstable/sql/Statement.ts +46 -20
- package/src/unstable/workers/Transferable.ts +1 -1
- package/src/unstable/workers/Worker.ts +3 -1
- package/src/unstable/workflow/Activity.ts +20 -9
- package/src/unstable/workflow/DurableClock.ts +1 -1
- package/src/unstable/workflow/DurableDeferred.ts +6 -0
- package/src/unstable/workflow/DurableQueue.ts +8 -0
- package/src/unstable/workflow/Workflow.ts +105 -28
- package/src/unstable/workflow/WorkflowEngine.ts +22 -0
- package/src/unstable/workflow/WorkflowProxy.ts +8 -4
- package/dist/internal/schema/schema.d.ts.map +0 -1
- package/dist/internal/schema/schema.js.map +0 -1
- package/dist/internal/schema/toArbitrary.d.ts +0 -2
- package/dist/internal/schema/toArbitrary.d.ts.map +0 -1
- package/dist/internal/schema/toArbitrary.js +0 -705
- package/dist/internal/schema/toArbitrary.js.map +0 -1
- package/dist/testing/FastCheck.d.ts +0 -90
- package/dist/testing/FastCheck.d.ts.map +0 -1
- package/dist/testing/FastCheck.js +0 -90
- package/dist/testing/FastCheck.js.map +0 -1
- package/dist/unstable/encoding/Msgpack.d.ts +0 -185
- package/dist/unstable/encoding/Msgpack.d.ts.map +0 -1
- package/dist/unstable/encoding/Msgpack.js +0 -227
- package/dist/unstable/encoding/Msgpack.js.map +0 -1
- package/src/internal/schema/toArbitrary.ts +0 -843
- package/src/testing/FastCheck.ts +0 -90
- package/src/unstable/encoding/Msgpack.ts +0 -432
- /package/dist/internal/{schema → arbitrary}/schema.d.ts +0 -0
package/src/SchemaAST.ts
CHANGED
|
@@ -17,7 +17,7 @@ import * as Effect from "./Effect.ts"
|
|
|
17
17
|
import * as Exit from "./Exit.ts"
|
|
18
18
|
import { format, formatPropertyKey } from "./Formatter.ts"
|
|
19
19
|
import { identity, memoize, memoizeIdempotent } from "./Function.ts"
|
|
20
|
-
import { effectIsExit, iterateEager } from "./internal/effect.ts"
|
|
20
|
+
import { effectIsExit, iterateConcurrent, iterateEager, resolveConcurrency } from "./internal/effect.ts"
|
|
21
21
|
import * as InternalRecord from "./internal/record.ts"
|
|
22
22
|
import * as InternalAnnotations from "./internal/schema/annotations.ts"
|
|
23
23
|
import * as InternalSchemaCause from "./internal/schema/cause.ts"
|
|
@@ -30,7 +30,7 @@ import * as SchemaGetter from "./SchemaGetter.ts"
|
|
|
30
30
|
import * as SchemaIssue from "./SchemaIssue.ts"
|
|
31
31
|
import type * as SchemaParser from "./SchemaParser.ts"
|
|
32
32
|
import * as SchemaTransformation from "./SchemaTransformation.ts"
|
|
33
|
-
import type * as
|
|
33
|
+
import type * as Types from "./Types.ts"
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* Discriminated union of all AST node types.
|
|
@@ -41,14 +41,13 @@ import type * as FastCheck from "./testing/FastCheck.ts"
|
|
|
41
41
|
* ({@link isString}, {@link isObjects}, etc.) to narrow to a specific variant,
|
|
42
42
|
* then access variant-specific fields.
|
|
43
43
|
*
|
|
44
|
-
* - All variants share the
|
|
45
|
-
*
|
|
44
|
+
* - All variants share the `annotations`, `checks`, `encoding`, and `context`
|
|
45
|
+
* fields.
|
|
46
46
|
* - Discriminate on the `_tag` field (e.g. `"String"`, `"Objects"`, `"Union"`).
|
|
47
47
|
*
|
|
48
|
-
* @see {@link Base}
|
|
49
48
|
* @see {@link isAST}
|
|
50
49
|
* @category models
|
|
51
|
-
* @since
|
|
50
|
+
* @since 4.0.0
|
|
52
51
|
*/
|
|
53
52
|
export type AST =
|
|
54
53
|
| Declaration
|
|
@@ -398,7 +397,25 @@ export const isSuspend = makeGuard("Suspend")
|
|
|
398
397
|
* @category models
|
|
399
398
|
* @since 4.0.0
|
|
400
399
|
*/
|
|
401
|
-
export
|
|
400
|
+
export interface Link {
|
|
401
|
+
readonly to: AST
|
|
402
|
+
readonly transformation:
|
|
403
|
+
| SchemaTransformation.Transformation<any, any, any, any>
|
|
404
|
+
| SchemaTransformation.Middleware<any, any, any, any, any, any>
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Constructs a {@link Link}.
|
|
409
|
+
*
|
|
410
|
+
* @category constructors
|
|
411
|
+
* @since 4.0.0
|
|
412
|
+
*/
|
|
413
|
+
export const Link: new(
|
|
414
|
+
to: AST,
|
|
415
|
+
transformation:
|
|
416
|
+
| SchemaTransformation.Transformation<any, any, any, any>
|
|
417
|
+
| SchemaTransformation.Middleware<any, any, any, any, any, any>
|
|
418
|
+
) => Link = class {
|
|
402
419
|
readonly to: AST
|
|
403
420
|
readonly transformation:
|
|
404
421
|
| SchemaTransformation.Transformation<any, any, any, any>
|
|
@@ -421,7 +438,7 @@ export class Link {
|
|
|
421
438
|
*
|
|
422
439
|
* **Details**
|
|
423
440
|
*
|
|
424
|
-
* Stored on
|
|
441
|
+
* Stored on an AST node's `encoding` field. When `undefined`, the node has no
|
|
425
442
|
* encoding transformation (type and encoded forms are identical).
|
|
426
443
|
*
|
|
427
444
|
* @see {@link Link}
|
|
@@ -437,22 +454,25 @@ export type Encoding = readonly [Link, ...Array<Link>]
|
|
|
437
454
|
* **Details**
|
|
438
455
|
*
|
|
439
456
|
* Pass to `Schema.decodeUnknown`, `Schema.encode`, and related APIs to customize
|
|
440
|
-
* error reporting, excess property handling,
|
|
441
|
-
*
|
|
457
|
+
* error reporting, excess property handling, check execution, and product
|
|
458
|
+
* concurrency. Options apply throughout the parse; schema annotations do not
|
|
459
|
+
* override them.
|
|
442
460
|
*
|
|
443
461
|
* - `errors` — `"first"` (default) stops at the first error; `"all"` collects
|
|
444
462
|
* every error.
|
|
445
463
|
* - `onExcessProperty` — `"ignore"` (default) strips unknown object keys;
|
|
446
|
-
* `"error"` fails
|
|
447
|
-
* - `propertyOrder` — `"none"` (default) lets the system choose key order;
|
|
448
|
-
* `"original"` preserves input key order.
|
|
464
|
+
* `"error"` fails.
|
|
449
465
|
* - `disableChecks` — skips validation checks while still applying defaults and
|
|
450
466
|
* transformations.
|
|
451
|
-
* - `concurrency` —
|
|
452
|
-
*
|
|
467
|
+
* - `concurrency` — controls concurrent parsing of tuple elements, array
|
|
468
|
+
* elements, struct fields, and record entries using the same semantics as
|
|
469
|
+
* `Effect.forEach`; the default is sequential.
|
|
453
470
|
* - `reportInput` — includes rejected input values in value-bearing schema
|
|
454
471
|
* issues.
|
|
455
472
|
*
|
|
473
|
+
* Object property order is unspecified, including in values passed to checks.
|
|
474
|
+
* Decoding and encoding do not guarantee preservation of input key order.
|
|
475
|
+
*
|
|
456
476
|
* @category options
|
|
457
477
|
* @since 3.10.0
|
|
458
478
|
*/
|
|
@@ -476,48 +496,45 @@ export interface ParseOptions {
|
|
|
476
496
|
* **Details**
|
|
477
497
|
*
|
|
478
498
|
* The default, `"ignore"`, strips unspecified properties from the output. Use
|
|
479
|
-
* `"error"` to fail when an excess property is present
|
|
480
|
-
*
|
|
499
|
+
* `"error"` to fail when an excess property is present. A key is covered by a
|
|
500
|
+
* declared property or any index signature selecting that key. This applies
|
|
501
|
+
* to structs, records, and structs with rest. Values must satisfy every
|
|
502
|
+
* applicable index signature. Empty structs keep their non-nullish behavior.
|
|
481
503
|
*
|
|
482
504
|
* @default "ignore"
|
|
483
505
|
*/
|
|
484
|
-
readonly onExcessProperty?: "ignore" | "error" |
|
|
506
|
+
readonly onExcessProperty?: "ignore" | "error" | undefined
|
|
485
507
|
|
|
486
508
|
/**
|
|
487
|
-
*
|
|
488
|
-
*
|
|
489
|
-
|
|
490
|
-
|
|
509
|
+
* Whether to disable checks while still applying defaults and
|
|
510
|
+
* transformations.
|
|
511
|
+
*/
|
|
512
|
+
readonly disableChecks?: boolean | undefined
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Controls how many children of a product schema may parse concurrently.
|
|
491
516
|
*
|
|
492
517
|
* **Details**
|
|
493
518
|
*
|
|
494
|
-
*
|
|
495
|
-
*
|
|
519
|
+
* This option has the same concurrency semantics as {@link Effect.forEach}.
|
|
520
|
+
* It applies to tuples, arrays, structs, records, and structs with rest. Each
|
|
521
|
+
* nested product applies the limit independently. Union members remain
|
|
522
|
+
* sequential, though products inside the current union member still receive
|
|
523
|
+
* the option.
|
|
496
524
|
*
|
|
497
|
-
*
|
|
498
|
-
*
|
|
525
|
+
* Array and tuple outputs retain their element order. Other observable work,
|
|
526
|
+
* including issue accumulation and colliding transformed record keys, follows
|
|
527
|
+
* effect completion order when concurrency is greater than `1`.
|
|
499
528
|
*
|
|
500
529
|
* **Gotchas**
|
|
501
530
|
*
|
|
502
|
-
*
|
|
503
|
-
*
|
|
504
|
-
*
|
|
505
|
-
* @default "none"
|
|
506
|
-
*/
|
|
507
|
-
readonly propertyOrder?: "none" | "original" | undefined
|
|
508
|
-
|
|
509
|
-
/**
|
|
510
|
-
* Whether to disable checks while still applying defaults and
|
|
511
|
-
* transformations.
|
|
512
|
-
*/
|
|
513
|
-
readonly disableChecks?: boolean | undefined
|
|
514
|
-
|
|
515
|
-
/**
|
|
516
|
-
* The maximum number of async effects to run concurrently.
|
|
531
|
+
* With `errors: "first"`, the first observed child failure interrupts the
|
|
532
|
+
* remaining children and may not belong to the earliest product position.
|
|
533
|
+
* Concurrent children may perform effects before another child fails.
|
|
517
534
|
*
|
|
518
|
-
* @default
|
|
535
|
+
* @default undefined
|
|
519
536
|
*/
|
|
520
|
-
readonly concurrency?:
|
|
537
|
+
readonly concurrency?: Types.Concurrency | undefined
|
|
521
538
|
|
|
522
539
|
/**
|
|
523
540
|
* Whether schema issues should retain and report rejected input values.
|
|
@@ -533,13 +550,12 @@ export interface ParseOptions {
|
|
|
533
550
|
* Enabling this option can retain or disclose secrets, personally
|
|
534
551
|
* identifiable information, and large object graphs. The `input` field is
|
|
535
552
|
* enumerable and may be included by object enumeration, spread, or
|
|
536
|
-
* serialization.
|
|
537
|
-
*
|
|
538
|
-
*
|
|
539
|
-
*
|
|
540
|
-
*
|
|
541
|
-
*
|
|
542
|
-
* annotations remain the caller's responsibility regardless of this option.
|
|
553
|
+
* serialization. Issues returned directly by user-defined declarations,
|
|
554
|
+
* checks, transformations, and middleware are not modified; their authors
|
|
555
|
+
* decide whether to retain an input. To respect this option, pass the
|
|
556
|
+
* callback's input and parse options directly to a value-bearing issue
|
|
557
|
+
* constructor. Custom messages and annotations remain the caller's
|
|
558
|
+
* responsibility regardless of this option.
|
|
543
559
|
* Formatting an issue with `SchemaIssue.makeFormatterDefault()`, reading
|
|
544
560
|
* `SchemaError.message`, or formatting a Standard Schema failure can disclose
|
|
545
561
|
* retained input.
|
|
@@ -553,7 +569,7 @@ export interface ParseOptions {
|
|
|
553
569
|
export const defaultParseOptions: ParseOptions = {}
|
|
554
570
|
|
|
555
571
|
/**
|
|
556
|
-
* Represents per-property metadata attached to AST
|
|
572
|
+
* Represents per-property metadata attached to an AST node's `context` field.
|
|
557
573
|
*
|
|
558
574
|
* **Details**
|
|
559
575
|
*
|
|
@@ -568,12 +584,31 @@ export const defaultParseOptions: ParseOptions = {}
|
|
|
568
584
|
* - `annotations` — key-level annotations (e.g. description of the key
|
|
569
585
|
* itself).
|
|
570
586
|
*
|
|
571
|
-
* @see
|
|
587
|
+
* @see `Schema.optionalKey`
|
|
572
588
|
* @see {@link isOptional}
|
|
573
589
|
* @category models
|
|
574
590
|
* @since 4.0.0
|
|
575
591
|
*/
|
|
576
|
-
export
|
|
592
|
+
export interface Context {
|
|
593
|
+
readonly isOptional: boolean
|
|
594
|
+
readonly isMutable: boolean
|
|
595
|
+
/** Used for constructor default values (e.g. `withConstructorDefault` API) */
|
|
596
|
+
readonly constructorDefault: Link | undefined
|
|
597
|
+
readonly annotations: Schema.Annotations.Key<unknown> | undefined
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* Constructs a {@link Context}.
|
|
602
|
+
*
|
|
603
|
+
* @category constructors
|
|
604
|
+
* @since 4.0.0
|
|
605
|
+
*/
|
|
606
|
+
export const Context: new(
|
|
607
|
+
isOptional: boolean,
|
|
608
|
+
isMutable: boolean, /** Used for constructor default values (e.g. `withConstructorDefault` API) */
|
|
609
|
+
constructorDefault?: Link | undefined,
|
|
610
|
+
annotations?: Schema.Annotations.Key<unknown> | undefined
|
|
611
|
+
) => Context = class {
|
|
577
612
|
readonly isOptional: boolean
|
|
578
613
|
readonly isMutable: boolean
|
|
579
614
|
/** Used for constructor default values (e.g. `withConstructorDefault` API) */
|
|
@@ -595,8 +630,8 @@ export class Context {
|
|
|
595
630
|
}
|
|
596
631
|
|
|
597
632
|
/**
|
|
598
|
-
* Non-empty array of validation {@link Check} values attached to an AST node
|
|
599
|
-
*
|
|
633
|
+
* Non-empty array of validation {@link Check} values attached to an AST node's
|
|
634
|
+
* `checks` field.
|
|
600
635
|
*
|
|
601
636
|
* **Details**
|
|
602
637
|
*
|
|
@@ -612,28 +647,17 @@ export class Context {
|
|
|
612
647
|
export type Checks = readonly [Check<any>, ...Array<Check<any>>]
|
|
613
648
|
|
|
614
649
|
const TypeId = "~effect/Schema"
|
|
650
|
+
interface ASTNode {
|
|
651
|
+
readonly [TypeId]: typeof TypeId
|
|
652
|
+
readonly _tag: string
|
|
653
|
+
readonly annotations: Schema.Annotations.Annotations | undefined
|
|
654
|
+
readonly checks: Checks | undefined
|
|
655
|
+
readonly encoding: Encoding | undefined
|
|
656
|
+
readonly context: Context | undefined
|
|
657
|
+
toString(): string
|
|
658
|
+
}
|
|
615
659
|
|
|
616
|
-
|
|
617
|
-
* Represents the abstract base class for all {@link AST} node variants.
|
|
618
|
-
*
|
|
619
|
-
* **Details**
|
|
620
|
-
*
|
|
621
|
-
* Every AST node extends `Base` and inherits these fields:
|
|
622
|
-
*
|
|
623
|
-
* - `annotations` — user-supplied metadata (identifier, title, description,
|
|
624
|
-
* arbitrary keys).
|
|
625
|
-
* - `checks` — optional {@link Checks} for post-type-match validation.
|
|
626
|
-
* - `encoding` — optional {@link Encoding} chain for type ↔ wire
|
|
627
|
-
* transformations.
|
|
628
|
-
* - `context` — optional {@link Context} for per-property metadata.
|
|
629
|
-
*
|
|
630
|
-
* Subclasses add a `_tag` discriminant and variant-specific data.
|
|
631
|
-
*
|
|
632
|
-
* @see {@link AST}
|
|
633
|
-
* @category models
|
|
634
|
-
* @since 4.0.0
|
|
635
|
-
*/
|
|
636
|
-
export abstract class Base {
|
|
660
|
+
abstract class ASTNodeImpl implements ASTNode {
|
|
637
661
|
readonly [TypeId] = TypeId
|
|
638
662
|
abstract readonly _tag: string
|
|
639
663
|
readonly annotations: Schema.Annotations.Annotations | undefined
|
|
@@ -657,6 +681,10 @@ export abstract class Base {
|
|
|
657
681
|
}
|
|
658
682
|
}
|
|
659
683
|
|
|
684
|
+
type DeclarationRun = (
|
|
685
|
+
typeParameters: ReadonlyArray<AST>
|
|
686
|
+
) => (input: unknown, self: Declaration, options: ParseOptions) => Effect.Effect<any, SchemaIssue.Issue>
|
|
687
|
+
|
|
660
688
|
/**
|
|
661
689
|
* AST node for user-defined opaque types with custom parsing logic.
|
|
662
690
|
*
|
|
@@ -670,35 +698,78 @@ export abstract class Base {
|
|
|
670
698
|
* - `typeParameters` — inner schemas this declaration is parameterized over
|
|
671
699
|
* (e.g. the element type for a custom collection).
|
|
672
700
|
* - `run` — factory that receives `typeParameters` and returns a parser that
|
|
673
|
-
* validates or transforms raw input.
|
|
701
|
+
* validates or transforms raw input. The `Effect` returned by the parser must
|
|
702
|
+
* complete synchronously.
|
|
674
703
|
*
|
|
675
704
|
* @see {@link isDeclaration}
|
|
676
705
|
* @category models
|
|
677
|
-
* @since
|
|
706
|
+
* @since 4.0.0
|
|
678
707
|
*/
|
|
679
|
-
export
|
|
708
|
+
export interface Declaration extends ASTNode {
|
|
709
|
+
readonly _tag: "Declaration"
|
|
710
|
+
readonly typeParameters: ReadonlyArray<AST>
|
|
711
|
+
readonly run: DeclarationRun
|
|
712
|
+
readonly encodingChecks: Checks | undefined
|
|
713
|
+
/**
|
|
714
|
+
* Parser factory {@link flip} swaps in, so a declaration can behave
|
|
715
|
+
* differently when encoding. `undefined` reuses `run`.
|
|
716
|
+
*/
|
|
717
|
+
readonly encodingRun: DeclarationRun | undefined
|
|
718
|
+
/** @internal */
|
|
719
|
+
|
|
720
|
+
getParser(): SchemaParser.Parser
|
|
721
|
+
/** @internal */
|
|
722
|
+
|
|
723
|
+
recur(recur: (ast: AST) => AST): Declaration
|
|
724
|
+
/** @internal */
|
|
725
|
+
|
|
726
|
+
flip(recur: (ast: AST) => AST): Declaration
|
|
727
|
+
/** @internal */
|
|
728
|
+
|
|
729
|
+
getExpected(): string
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
/**
|
|
733
|
+
* Constructs a {@link Declaration}.
|
|
734
|
+
*
|
|
735
|
+
* @category constructors
|
|
736
|
+
* @since 4.0.0
|
|
737
|
+
*/
|
|
738
|
+
export const Declaration: new(
|
|
739
|
+
typeParameters: ReadonlyArray<AST>,
|
|
740
|
+
run: DeclarationRun,
|
|
741
|
+
annotations?: Schema.Annotations.Annotations,
|
|
742
|
+
checks?: Checks,
|
|
743
|
+
encoding?: Encoding,
|
|
744
|
+
context?: Context,
|
|
745
|
+
encodingChecks?: Checks,
|
|
746
|
+
encodingRun?: DeclarationRun
|
|
747
|
+
) => Declaration = class extends ASTNodeImpl {
|
|
680
748
|
readonly _tag = "Declaration"
|
|
681
749
|
readonly typeParameters: ReadonlyArray<AST>
|
|
682
|
-
readonly run:
|
|
683
|
-
typeParameters: ReadonlyArray<AST>
|
|
684
|
-
) => (input: unknown, self: Declaration, options: ParseOptions) => Effect.Effect<any, SchemaIssue.Issue, any>
|
|
750
|
+
readonly run: DeclarationRun
|
|
685
751
|
readonly encodingChecks: Checks | undefined
|
|
752
|
+
/**
|
|
753
|
+
* Parser factory {@link flip} swaps in, so a declaration can behave
|
|
754
|
+
* differently when encoding. `undefined` reuses `run`.
|
|
755
|
+
*/
|
|
756
|
+
readonly encodingRun: DeclarationRun | undefined
|
|
686
757
|
|
|
687
758
|
constructor(
|
|
688
759
|
typeParameters: ReadonlyArray<AST>,
|
|
689
|
-
run:
|
|
690
|
-
typeParameters: ReadonlyArray<AST>
|
|
691
|
-
) => (input: unknown, self: Declaration, options: ParseOptions) => Effect.Effect<any, SchemaIssue.Issue, any>,
|
|
760
|
+
run: DeclarationRun,
|
|
692
761
|
annotations?: Schema.Annotations.Annotations,
|
|
693
762
|
checks?: Checks,
|
|
694
763
|
encoding?: Encoding,
|
|
695
764
|
context?: Context,
|
|
696
|
-
encodingChecks?: Checks
|
|
765
|
+
encodingChecks?: Checks,
|
|
766
|
+
encodingRun?: DeclarationRun
|
|
697
767
|
) {
|
|
698
768
|
super(annotations, checks, encoding, context)
|
|
699
769
|
this.typeParameters = typeParameters
|
|
700
770
|
this.run = run
|
|
701
771
|
this.encodingChecks = encodingChecks
|
|
772
|
+
this.encodingRun = encodingRun
|
|
702
773
|
}
|
|
703
774
|
/** @internal */
|
|
704
775
|
getParser(): SchemaParser.Parser {
|
|
@@ -708,19 +779,26 @@ export class Declaration extends Base {
|
|
|
708
779
|
return (run ??= this.run(this.typeParameters))(input, this, options)
|
|
709
780
|
}
|
|
710
781
|
}
|
|
711
|
-
private _rebuild(
|
|
782
|
+
private _rebuild(
|
|
783
|
+
recur: (ast: AST) => AST,
|
|
784
|
+
checks: Checks | undefined,
|
|
785
|
+
encodingChecks: Checks | undefined,
|
|
786
|
+
run: DeclarationRun,
|
|
787
|
+
encodingRun: DeclarationRun | undefined
|
|
788
|
+
) {
|
|
712
789
|
const tps = mapOrSame(this.typeParameters, recur)
|
|
713
|
-
return tps === this.typeParameters && checks === this.checks && encodingChecks === this.encodingChecks
|
|
790
|
+
return tps === this.typeParameters && checks === this.checks && encodingChecks === this.encodingChecks &&
|
|
791
|
+
run === this.run && encodingRun === this.encodingRun ?
|
|
714
792
|
this :
|
|
715
|
-
new Declaration(tps,
|
|
793
|
+
new Declaration(tps, run, this.annotations, checks, undefined, this.context, encodingChecks, encodingRun)
|
|
716
794
|
}
|
|
717
795
|
/** @internal */
|
|
718
796
|
recur(recur: (ast: AST) => AST) {
|
|
719
|
-
return this._rebuild(recur, this.checks, this.encodingChecks)
|
|
797
|
+
return this._rebuild(recur, this.checks, this.encodingChecks, this.run, this.encodingRun)
|
|
720
798
|
}
|
|
721
799
|
/** @internal */
|
|
722
800
|
flip(recur: (ast: AST) => AST) {
|
|
723
|
-
return this._rebuild(recur, this.encodingChecks, this.checks)
|
|
801
|
+
return this._rebuild(recur, this.encodingChecks, this.checks, this.encodingRun ?? this.run, this.run)
|
|
724
802
|
}
|
|
725
803
|
/** @internal */
|
|
726
804
|
getExpected(): string {
|
|
@@ -742,7 +820,28 @@ export class Declaration extends Base {
|
|
|
742
820
|
* @category models
|
|
743
821
|
* @since 4.0.0
|
|
744
822
|
*/
|
|
745
|
-
export
|
|
823
|
+
export interface Null extends ASTNode {
|
|
824
|
+
readonly _tag: "Null"
|
|
825
|
+
/** @internal */
|
|
826
|
+
|
|
827
|
+
getParser(): SchemaParser.Parser
|
|
828
|
+
/** @internal */
|
|
829
|
+
|
|
830
|
+
getExpected(): string
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
/**
|
|
834
|
+
* Constructs a {@link Null}.
|
|
835
|
+
*
|
|
836
|
+
* @category constructors
|
|
837
|
+
* @since 4.0.0
|
|
838
|
+
*/
|
|
839
|
+
export const Null: new(
|
|
840
|
+
annotations?: Schema.Annotations.Annotations | undefined,
|
|
841
|
+
checks?: Checks | undefined,
|
|
842
|
+
encoding?: Encoding | undefined,
|
|
843
|
+
context?: Context | undefined
|
|
844
|
+
) => Null = class extends ASTNodeImpl {
|
|
746
845
|
readonly _tag = "Null"
|
|
747
846
|
/** @internal */
|
|
748
847
|
getParser() {
|
|
@@ -782,7 +881,31 @@ export {
|
|
|
782
881
|
* @category models
|
|
783
882
|
* @since 4.0.0
|
|
784
883
|
*/
|
|
785
|
-
export
|
|
884
|
+
export interface Undefined extends ASTNode {
|
|
885
|
+
readonly _tag: "Undefined"
|
|
886
|
+
/** @internal */
|
|
887
|
+
|
|
888
|
+
getParser(): SchemaParser.Parser
|
|
889
|
+
/** @internal */
|
|
890
|
+
|
|
891
|
+
toCodecJson(): AST
|
|
892
|
+
/** @internal */
|
|
893
|
+
|
|
894
|
+
getExpected(): string
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
/**
|
|
898
|
+
* Constructs a {@link Undefined}.
|
|
899
|
+
*
|
|
900
|
+
* @category constructors
|
|
901
|
+
* @since 4.0.0
|
|
902
|
+
*/
|
|
903
|
+
export const Undefined: new(
|
|
904
|
+
annotations?: Schema.Annotations.Annotations | undefined,
|
|
905
|
+
checks?: Checks | undefined,
|
|
906
|
+
encoding?: Encoding | undefined,
|
|
907
|
+
context?: Context | undefined
|
|
908
|
+
) => Undefined = class extends ASTNodeImpl {
|
|
786
909
|
readonly _tag = "Undefined"
|
|
787
910
|
/** @internal */
|
|
788
911
|
getParser() {
|
|
@@ -842,7 +965,33 @@ export {
|
|
|
842
965
|
* @category models
|
|
843
966
|
* @since 4.0.0
|
|
844
967
|
*/
|
|
845
|
-
export
|
|
968
|
+
export interface Void extends ASTNode {
|
|
969
|
+
readonly _tag: "Void"
|
|
970
|
+
/** @internal */
|
|
971
|
+
|
|
972
|
+
getParser(): (
|
|
973
|
+
input: unknown
|
|
974
|
+
) => InternalParser.Success<undefined, never> | InternalParser.Success<typeof InternalParser.missing, never>
|
|
975
|
+
/** @internal */
|
|
976
|
+
|
|
977
|
+
toCodecJson(): AST
|
|
978
|
+
/** @internal */
|
|
979
|
+
|
|
980
|
+
getExpected(): string
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
/**
|
|
984
|
+
* Constructs a {@link Void}.
|
|
985
|
+
*
|
|
986
|
+
* @category constructors
|
|
987
|
+
* @since 4.0.0
|
|
988
|
+
*/
|
|
989
|
+
export const Void: new(
|
|
990
|
+
annotations?: Schema.Annotations.Annotations | undefined,
|
|
991
|
+
checks?: Checks | undefined,
|
|
992
|
+
encoding?: Encoding | undefined,
|
|
993
|
+
context?: Context | undefined
|
|
994
|
+
) => Void = class extends ASTNodeImpl {
|
|
846
995
|
readonly _tag = "Void"
|
|
847
996
|
/** @internal */
|
|
848
997
|
getParser() {
|
|
@@ -897,7 +1046,28 @@ export {
|
|
|
897
1046
|
* @category models
|
|
898
1047
|
* @since 4.0.0
|
|
899
1048
|
*/
|
|
900
|
-
export
|
|
1049
|
+
export interface Never extends ASTNode {
|
|
1050
|
+
readonly _tag: "Never"
|
|
1051
|
+
/** @internal */
|
|
1052
|
+
|
|
1053
|
+
getParser(): SchemaParser.Parser
|
|
1054
|
+
/** @internal */
|
|
1055
|
+
|
|
1056
|
+
getExpected(): string
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
/**
|
|
1060
|
+
* Constructs a {@link Never}.
|
|
1061
|
+
*
|
|
1062
|
+
* @category constructors
|
|
1063
|
+
* @since 4.0.0
|
|
1064
|
+
*/
|
|
1065
|
+
export const Never: new(
|
|
1066
|
+
annotations?: Schema.Annotations.Annotations | undefined,
|
|
1067
|
+
checks?: Checks | undefined,
|
|
1068
|
+
encoding?: Encoding | undefined,
|
|
1069
|
+
context?: Context | undefined
|
|
1070
|
+
) => Never = class extends ASTNodeImpl {
|
|
901
1071
|
readonly _tag = "Never"
|
|
902
1072
|
/** @internal */
|
|
903
1073
|
getParser() {
|
|
@@ -934,7 +1104,28 @@ export const never = new Never()
|
|
|
934
1104
|
* @category models
|
|
935
1105
|
* @since 4.0.0
|
|
936
1106
|
*/
|
|
937
|
-
export
|
|
1107
|
+
export interface Any extends ASTNode {
|
|
1108
|
+
readonly _tag: "Any"
|
|
1109
|
+
/** @internal */
|
|
1110
|
+
|
|
1111
|
+
getParser(): SchemaParser.Parser
|
|
1112
|
+
/** @internal */
|
|
1113
|
+
|
|
1114
|
+
getExpected(): string
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
/**
|
|
1118
|
+
* Constructs a {@link Any}.
|
|
1119
|
+
*
|
|
1120
|
+
* @category constructors
|
|
1121
|
+
* @since 4.0.0
|
|
1122
|
+
*/
|
|
1123
|
+
export const Any: new(
|
|
1124
|
+
annotations?: Schema.Annotations.Annotations | undefined,
|
|
1125
|
+
checks?: Checks | undefined,
|
|
1126
|
+
encoding?: Encoding | undefined,
|
|
1127
|
+
context?: Context | undefined
|
|
1128
|
+
) => Any = class extends ASTNodeImpl {
|
|
938
1129
|
readonly _tag = "Any"
|
|
939
1130
|
/** @internal */
|
|
940
1131
|
getParser() {
|
|
@@ -974,7 +1165,28 @@ export const any = new Any()
|
|
|
974
1165
|
* @category models
|
|
975
1166
|
* @since 4.0.0
|
|
976
1167
|
*/
|
|
977
|
-
export
|
|
1168
|
+
export interface Unknown extends ASTNode {
|
|
1169
|
+
readonly _tag: "Unknown"
|
|
1170
|
+
/** @internal */
|
|
1171
|
+
|
|
1172
|
+
getParser(): SchemaParser.Parser
|
|
1173
|
+
/** @internal */
|
|
1174
|
+
|
|
1175
|
+
getExpected(): string
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
/**
|
|
1179
|
+
* Constructs a {@link Unknown}.
|
|
1180
|
+
*
|
|
1181
|
+
* @category constructors
|
|
1182
|
+
* @since 4.0.0
|
|
1183
|
+
*/
|
|
1184
|
+
export const Unknown: new(
|
|
1185
|
+
annotations?: Schema.Annotations.Annotations | undefined,
|
|
1186
|
+
checks?: Checks | undefined,
|
|
1187
|
+
encoding?: Encoding | undefined,
|
|
1188
|
+
context?: Context | undefined
|
|
1189
|
+
) => Unknown = class extends ASTNodeImpl {
|
|
978
1190
|
readonly _tag = "Unknown"
|
|
979
1191
|
/** @internal */
|
|
980
1192
|
getParser() {
|
|
@@ -1009,9 +1221,30 @@ export const unknown = new Unknown()
|
|
|
1009
1221
|
* @see {@link isObjectKeyword}
|
|
1010
1222
|
*
|
|
1011
1223
|
* @category models
|
|
1012
|
-
* @since
|
|
1224
|
+
* @since 4.0.0
|
|
1013
1225
|
*/
|
|
1014
|
-
export
|
|
1226
|
+
export interface ObjectKeyword extends ASTNode {
|
|
1227
|
+
readonly _tag: "ObjectKeyword"
|
|
1228
|
+
/** @internal */
|
|
1229
|
+
|
|
1230
|
+
getParser(): SchemaParser.Parser
|
|
1231
|
+
/** @internal */
|
|
1232
|
+
|
|
1233
|
+
getExpected(): string
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
/**
|
|
1237
|
+
* Constructs a {@link ObjectKeyword}.
|
|
1238
|
+
*
|
|
1239
|
+
* @category constructors
|
|
1240
|
+
* @since 4.0.0
|
|
1241
|
+
*/
|
|
1242
|
+
export const ObjectKeyword: new(
|
|
1243
|
+
annotations?: Schema.Annotations.Annotations | undefined,
|
|
1244
|
+
checks?: Checks | undefined,
|
|
1245
|
+
encoding?: Encoding | undefined,
|
|
1246
|
+
context?: Context | undefined
|
|
1247
|
+
) => ObjectKeyword = class extends ASTNodeImpl {
|
|
1015
1248
|
readonly _tag = "ObjectKeyword"
|
|
1016
1249
|
/** @internal */
|
|
1017
1250
|
getParser() {
|
|
@@ -1051,7 +1284,43 @@ export const objectKeyword = new ObjectKeyword()
|
|
|
1051
1284
|
* @category models
|
|
1052
1285
|
* @since 4.0.0
|
|
1053
1286
|
*/
|
|
1054
|
-
export
|
|
1287
|
+
export interface Enum extends ASTNode {
|
|
1288
|
+
readonly _tag: "Enum"
|
|
1289
|
+
readonly enums: ReadonlyArray<
|
|
1290
|
+
readonly [
|
|
1291
|
+
string,
|
|
1292
|
+
string | number
|
|
1293
|
+
]
|
|
1294
|
+
>
|
|
1295
|
+
/** @internal */
|
|
1296
|
+
|
|
1297
|
+
getParser(): SchemaParser.Parser
|
|
1298
|
+
/** @internal */
|
|
1299
|
+
|
|
1300
|
+
toCodecStringTree(): AST
|
|
1301
|
+
/** @internal */
|
|
1302
|
+
|
|
1303
|
+
getExpected(): string
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
/**
|
|
1307
|
+
* Constructs a {@link Enum}. Numeric values must be finite.
|
|
1308
|
+
*
|
|
1309
|
+
* @category constructors
|
|
1310
|
+
* @since 4.0.0
|
|
1311
|
+
*/
|
|
1312
|
+
export const Enum: new(
|
|
1313
|
+
enums: ReadonlyArray<
|
|
1314
|
+
readonly [
|
|
1315
|
+
string,
|
|
1316
|
+
string | number
|
|
1317
|
+
]
|
|
1318
|
+
>,
|
|
1319
|
+
annotations?: Schema.Annotations.Annotations,
|
|
1320
|
+
checks?: Checks,
|
|
1321
|
+
encoding?: Encoding,
|
|
1322
|
+
context?: Context
|
|
1323
|
+
) => Enum = class extends ASTNodeImpl {
|
|
1055
1324
|
readonly _tag = "Enum"
|
|
1056
1325
|
readonly enums: ReadonlyArray<readonly [string, string | number]>
|
|
1057
1326
|
|
|
@@ -1063,6 +1332,11 @@ export class Enum extends Base {
|
|
|
1063
1332
|
context?: Context
|
|
1064
1333
|
) {
|
|
1065
1334
|
super(annotations, checks, encoding, context)
|
|
1335
|
+
for (const [, value] of enums) {
|
|
1336
|
+
if (typeof value === "number" && !globalThis.Number.isFinite(value)) {
|
|
1337
|
+
throw new Error(`A numeric enum value must be finite, got ${format(value)}`)
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1066
1340
|
this.enums = enums
|
|
1067
1341
|
}
|
|
1068
1342
|
/** @internal */
|
|
@@ -1079,7 +1353,7 @@ export class Enum extends Base {
|
|
|
1079
1353
|
const coercions = Object.fromEntries(this.enums.map(([_, v]) => [globalThis.String(v), v]))
|
|
1080
1354
|
return replaceEncoding(this, [
|
|
1081
1355
|
new Link(
|
|
1082
|
-
new Union(Object.keys(coercions).map((k) => new Literal(k))
|
|
1356
|
+
new Union(Object.keys(coercions).map((k) => new Literal(k))),
|
|
1083
1357
|
new SchemaTransformation.Transformation(
|
|
1084
1358
|
SchemaGetter.transform((s) => coercions[s]),
|
|
1085
1359
|
SchemaGetter.String()
|
|
@@ -1103,20 +1377,34 @@ type TemplateLiteralPart =
|
|
|
1103
1377
|
| TemplateLiteral
|
|
1104
1378
|
| Union<TemplateLiteralPart>
|
|
1105
1379
|
|
|
1106
|
-
function isTemplateLiteralPart(ast: AST): ast is TemplateLiteralPart {
|
|
1380
|
+
function isTemplateLiteralPart(ast: AST, path: string, validated: WeakSet<AST>): ast is TemplateLiteralPart {
|
|
1381
|
+
if (validated.has(ast)) return true
|
|
1382
|
+
if (ast.encoding) {
|
|
1383
|
+
throw new Error(`TemplateLiteral parts cannot have an encoding at ${path}`)
|
|
1384
|
+
}
|
|
1385
|
+
let valid: boolean
|
|
1107
1386
|
switch (ast._tag) {
|
|
1108
1387
|
case "String":
|
|
1109
1388
|
case "Number":
|
|
1110
1389
|
case "BigInt":
|
|
1111
|
-
|
|
1390
|
+
valid = true
|
|
1391
|
+
break
|
|
1112
1392
|
case "Literal":
|
|
1393
|
+
valid = !ast.checks
|
|
1394
|
+
break
|
|
1113
1395
|
case "TemplateLiteral":
|
|
1114
|
-
|
|
1396
|
+
valid = !ast.checks &&
|
|
1397
|
+
ast.parts.every((part, index) => isTemplateLiteralPart(part, `${path}.parts[${index}]`, validated))
|
|
1398
|
+
break
|
|
1115
1399
|
case "Union":
|
|
1116
|
-
|
|
1400
|
+
valid = !ast.checks &&
|
|
1401
|
+
ast.types.every((part, index) => isTemplateLiteralPart(part, `${path}.types[${index}]`, validated))
|
|
1402
|
+
break
|
|
1117
1403
|
default:
|
|
1118
1404
|
return false
|
|
1119
1405
|
}
|
|
1406
|
+
if (valid) validated.add(ast)
|
|
1407
|
+
return valid
|
|
1120
1408
|
}
|
|
1121
1409
|
|
|
1122
1410
|
/**
|
|
@@ -1130,9 +1418,46 @@ function isTemplateLiteralPart(ast: AST): ast is TemplateLiteralPart {
|
|
|
1130
1418
|
*
|
|
1131
1419
|
* @see {@link isTemplateLiteral}
|
|
1132
1420
|
* @category models
|
|
1133
|
-
* @since
|
|
1421
|
+
* @since 4.0.0
|
|
1422
|
+
*/
|
|
1423
|
+
export interface TemplateLiteral extends ASTNode {
|
|
1424
|
+
readonly _tag: "TemplateLiteral"
|
|
1425
|
+
readonly parts: ReadonlyArray<AST>
|
|
1426
|
+
/** @internal */
|
|
1427
|
+
readonly encodedParts: ReadonlyArray<TemplateLiteralPart>
|
|
1428
|
+
/** @internal */
|
|
1429
|
+
readonly literals: ReadonlyArray<string | undefined>
|
|
1430
|
+
/** @internal */
|
|
1431
|
+
readonly suffixLengths: ReadonlyArray<number>
|
|
1432
|
+
/** @internal */
|
|
1433
|
+
|
|
1434
|
+
getParser(compile: SchemaParser.Compiler): SchemaParser.Parser
|
|
1435
|
+
/** @internal */
|
|
1436
|
+
|
|
1437
|
+
getExpected(): string
|
|
1438
|
+
/** @internal */
|
|
1439
|
+
|
|
1440
|
+
matchPart(s: string, options: ParseOptions): string | undefined
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
/**
|
|
1444
|
+
* Constructs a {@link TemplateLiteral}.
|
|
1445
|
+
*
|
|
1446
|
+
* **Gotchas**
|
|
1447
|
+
*
|
|
1448
|
+
* Throws if a part contains an encoding, including inside unions or nested
|
|
1449
|
+
* template literals. Parts must describe their values without transformations.
|
|
1450
|
+
*
|
|
1451
|
+
* @category constructors
|
|
1452
|
+
* @since 4.0.0
|
|
1134
1453
|
*/
|
|
1135
|
-
export
|
|
1454
|
+
export const TemplateLiteral: new(
|
|
1455
|
+
parts: ReadonlyArray<AST>,
|
|
1456
|
+
annotations?: Schema.Annotations.Annotations,
|
|
1457
|
+
checks?: Checks,
|
|
1458
|
+
encoding?: Encoding,
|
|
1459
|
+
context?: Context
|
|
1460
|
+
) => TemplateLiteral = class extends ASTNodeImpl {
|
|
1136
1461
|
readonly _tag = "TemplateLiteral"
|
|
1137
1462
|
readonly parts: ReadonlyArray<AST>
|
|
1138
1463
|
/** @internal */
|
|
@@ -1152,14 +1477,14 @@ export class TemplateLiteral extends Base {
|
|
|
1152
1477
|
super(annotations, checks, encoding, context)
|
|
1153
1478
|
const encodedParts: Array<TemplateLiteralPart> = []
|
|
1154
1479
|
const literals: Array<string | undefined> = []
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
} else {
|
|
1161
|
-
throw new Error(`Invalid TemplateLiteral part ${encoded._tag}`)
|
|
1480
|
+
const validated = new WeakSet<AST>()
|
|
1481
|
+
for (let index = 0; index < parts.length; index++) {
|
|
1482
|
+
const part = parts[index]
|
|
1483
|
+
if (!isTemplateLiteralPart(part, `parts[${index}]`, validated)) {
|
|
1484
|
+
throw new Error(`Invalid TemplateLiteral part ${part._tag}`)
|
|
1162
1485
|
}
|
|
1486
|
+
encodedParts.push(part)
|
|
1487
|
+
literals.push(part._tag === "Literal" ? globalThis.String(part.literal) : undefined)
|
|
1163
1488
|
}
|
|
1164
1489
|
const suffixLengths = new Array<number>(encodedParts.length + 1)
|
|
1165
1490
|
suffixLengths[encodedParts.length] = 0
|
|
@@ -1173,7 +1498,8 @@ export class TemplateLiteral extends Base {
|
|
|
1173
1498
|
}
|
|
1174
1499
|
/** @internal */
|
|
1175
1500
|
getParser(compile: SchemaParser.Compiler): SchemaParser.Parser {
|
|
1176
|
-
const
|
|
1501
|
+
const tuple = new Arrays(false, this.parts.map(partFromString), [])
|
|
1502
|
+
const parser = compile(decodeTo(string, tuple, templateLiteralTransformation(this)))
|
|
1177
1503
|
return (input, options) => {
|
|
1178
1504
|
if (input === InternalParser.missing) return InternalParser.missingExit
|
|
1179
1505
|
const result = parser(input, options)
|
|
@@ -1194,28 +1520,46 @@ export class TemplateLiteral extends Base {
|
|
|
1194
1520
|
matchPart(s: string, options: ParseOptions): string | undefined {
|
|
1195
1521
|
return segmentTemplateLiteralParts(this, s, options) === undefined ? undefined : s
|
|
1196
1522
|
}
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
SchemaGetter.transform((parts) => parts.join(""))
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
/** @internal */
|
|
1526
|
+
export function templateLiteralParser(parts: ReadonlyArray<AST>): Arrays {
|
|
1527
|
+
// Encoded members can overlap even when decoding selects exactly one member.
|
|
1528
|
+
// Match their spellings here; the original tuple enforces the union's mode.
|
|
1529
|
+
const normalize = memoize((encoded: AST): AST => {
|
|
1530
|
+
if (encoded._tag !== "Union") return encoded
|
|
1531
|
+
const types = mapOrSame(encoded.types, normalize)
|
|
1532
|
+
return (encoded.options?.mode ?? "anyOf") === "anyOf" && types === encoded.types
|
|
1533
|
+
? encoded
|
|
1534
|
+
: new Union(
|
|
1535
|
+
types,
|
|
1536
|
+
encoded.options === undefined ? undefined : { ...encoded.options, mode: "anyOf" },
|
|
1537
|
+
encoded.annotations,
|
|
1538
|
+
encoded.checks,
|
|
1539
|
+
undefined,
|
|
1540
|
+
encoded.context
|
|
1216
1541
|
)
|
|
1217
|
-
|
|
1218
|
-
|
|
1542
|
+
})
|
|
1543
|
+
const template = new TemplateLiteral(parts.map((part) => normalize(toEncoded(part))))
|
|
1544
|
+
const tuple = new Arrays(false, parts.map(partFromString), [])
|
|
1545
|
+
return decodeTo(template, tuple, templateLiteralTransformation(template))
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
function templateLiteralTransformation(template: TemplateLiteral) {
|
|
1549
|
+
return new SchemaTransformation.Transformation(
|
|
1550
|
+
SchemaGetter.transformEffect((s: string, options) => {
|
|
1551
|
+
const segments = segmentTemplateLiteralParts(template, s, options)
|
|
1552
|
+
if (segments) return Effect.succeed(segments)
|
|
1553
|
+
return Effect.fail(
|
|
1554
|
+
new SchemaIssue.InvalidValue(
|
|
1555
|
+
{ expected: "a string matching template literal parts" },
|
|
1556
|
+
s,
|
|
1557
|
+
options
|
|
1558
|
+
)
|
|
1559
|
+
)
|
|
1560
|
+
}),
|
|
1561
|
+
SchemaGetter.transform((parts: ReadonlyArray<string>) => parts.join(""))
|
|
1562
|
+
)
|
|
1219
1563
|
}
|
|
1220
1564
|
|
|
1221
1565
|
/**
|
|
@@ -1228,9 +1572,35 @@ export class TemplateLiteral extends Base {
|
|
|
1228
1572
|
*
|
|
1229
1573
|
* @see {@link isUniqueSymbol}
|
|
1230
1574
|
* @category models
|
|
1231
|
-
* @since
|
|
1575
|
+
* @since 4.0.0
|
|
1576
|
+
*/
|
|
1577
|
+
export interface UniqueSymbol extends ASTNode {
|
|
1578
|
+
readonly _tag: "UniqueSymbol"
|
|
1579
|
+
readonly symbol: symbol
|
|
1580
|
+
/** @internal */
|
|
1581
|
+
|
|
1582
|
+
getParser(): SchemaParser.Parser
|
|
1583
|
+
/** @internal */
|
|
1584
|
+
|
|
1585
|
+
toCodecStringTree(): AST
|
|
1586
|
+
/** @internal */
|
|
1587
|
+
|
|
1588
|
+
getExpected(): string
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
/**
|
|
1592
|
+
* Constructs a {@link UniqueSymbol}.
|
|
1593
|
+
*
|
|
1594
|
+
* @category constructors
|
|
1595
|
+
* @since 4.0.0
|
|
1232
1596
|
*/
|
|
1233
|
-
export
|
|
1597
|
+
export const UniqueSymbol: new(
|
|
1598
|
+
symbol: symbol,
|
|
1599
|
+
annotations?: Schema.Annotations.Annotations,
|
|
1600
|
+
checks?: Checks,
|
|
1601
|
+
encoding?: Encoding,
|
|
1602
|
+
context?: Context
|
|
1603
|
+
) => UniqueSymbol = class extends ASTNodeImpl {
|
|
1234
1604
|
readonly _tag = "UniqueSymbol"
|
|
1235
1605
|
readonly symbol: symbol
|
|
1236
1606
|
|
|
@@ -1250,7 +1620,13 @@ export class UniqueSymbol extends Base {
|
|
|
1250
1620
|
}
|
|
1251
1621
|
/** @internal */
|
|
1252
1622
|
toCodecStringTree(): AST {
|
|
1253
|
-
|
|
1623
|
+
const key = globalThis.Symbol.keyFor(this.symbol)
|
|
1624
|
+
return replaceEncoding(this, [
|
|
1625
|
+
new Link(
|
|
1626
|
+
key === undefined ? never : new Literal(globalThis.String(this.symbol)),
|
|
1627
|
+
symbolToString.transformation
|
|
1628
|
+
)
|
|
1629
|
+
])
|
|
1254
1630
|
}
|
|
1255
1631
|
/** @internal */
|
|
1256
1632
|
getExpected(): string {
|
|
@@ -1275,8 +1651,10 @@ export type LiteralValue = string | number | boolean | bigint
|
|
|
1275
1651
|
* **Details**
|
|
1276
1652
|
*
|
|
1277
1653
|
* Parsing succeeds only when the input is strictly equal (`===`) to the
|
|
1278
|
-
* stored `literal
|
|
1279
|
-
* and
|
|
1654
|
+
* stored `literal`, preserving the input value. Both `0` and `-0` are accepted
|
|
1655
|
+
* by either zero literal, and parsing preserves the input's sign. Numeric
|
|
1656
|
+
* literals must be finite. `Infinity`, `-Infinity`, and `NaN` are rejected at
|
|
1657
|
+
* construction time.
|
|
1280
1658
|
*
|
|
1281
1659
|
* **Example** (Creating a literal AST)
|
|
1282
1660
|
*
|
|
@@ -1290,9 +1668,41 @@ export type LiteralValue = string | number | boolean | bigint
|
|
|
1290
1668
|
* @see {@link LiteralValue}
|
|
1291
1669
|
* @see {@link isLiteral}
|
|
1292
1670
|
* @category models
|
|
1293
|
-
* @since
|
|
1671
|
+
* @since 4.0.0
|
|
1672
|
+
*/
|
|
1673
|
+
export interface Literal extends ASTNode {
|
|
1674
|
+
readonly _tag: "Literal"
|
|
1675
|
+
readonly literal: LiteralValue
|
|
1676
|
+
/** @internal */
|
|
1677
|
+
|
|
1678
|
+
getParser(): SchemaParser.Parser
|
|
1679
|
+
/** @internal */
|
|
1680
|
+
|
|
1681
|
+
matchPart(s: string, _options: ParseOptions): LiteralValue | undefined
|
|
1682
|
+
/** @internal */
|
|
1683
|
+
|
|
1684
|
+
toCodecJson(): AST
|
|
1685
|
+
/** @internal */
|
|
1686
|
+
|
|
1687
|
+
toCodecStringTree(): AST
|
|
1688
|
+
/** @internal */
|
|
1689
|
+
|
|
1690
|
+
getExpected(): string
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1693
|
+
/**
|
|
1694
|
+
* Constructs a {@link Literal}.
|
|
1695
|
+
*
|
|
1696
|
+
* @category constructors
|
|
1697
|
+
* @since 4.0.0
|
|
1294
1698
|
*/
|
|
1295
|
-
export
|
|
1699
|
+
export const Literal: new(
|
|
1700
|
+
literal: LiteralValue,
|
|
1701
|
+
annotations?: Schema.Annotations.Annotations,
|
|
1702
|
+
checks?: Checks,
|
|
1703
|
+
encoding?: Encoding,
|
|
1704
|
+
context?: Context
|
|
1705
|
+
) => Literal = class extends ASTNodeImpl {
|
|
1296
1706
|
readonly _tag = "Literal"
|
|
1297
1707
|
readonly literal: LiteralValue
|
|
1298
1708
|
|
|
@@ -1353,7 +1763,31 @@ function literalToString(ast: Literal): Literal {
|
|
|
1353
1763
|
* @category models
|
|
1354
1764
|
* @since 4.0.0
|
|
1355
1765
|
*/
|
|
1356
|
-
export
|
|
1766
|
+
export interface String extends ASTNode {
|
|
1767
|
+
readonly _tag: "String"
|
|
1768
|
+
/** @internal */
|
|
1769
|
+
|
|
1770
|
+
getParser(): SchemaParser.Parser
|
|
1771
|
+
/** @internal */
|
|
1772
|
+
|
|
1773
|
+
matchPart(s: string, options: ParseOptions): string | undefined
|
|
1774
|
+
/** @internal */
|
|
1775
|
+
|
|
1776
|
+
getExpected(): string
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
/**
|
|
1780
|
+
* Constructs a {@link String}.
|
|
1781
|
+
*
|
|
1782
|
+
* @category constructors
|
|
1783
|
+
* @since 4.0.0
|
|
1784
|
+
*/
|
|
1785
|
+
export const String: new(
|
|
1786
|
+
annotations?: Schema.Annotations.Annotations | undefined,
|
|
1787
|
+
checks?: Checks | undefined,
|
|
1788
|
+
encoding?: Encoding | undefined,
|
|
1789
|
+
context?: Context | undefined
|
|
1790
|
+
) => String = class extends ASTNodeImpl {
|
|
1357
1791
|
readonly _tag = "String"
|
|
1358
1792
|
/** @internal */
|
|
1359
1793
|
getParser() {
|
|
@@ -1404,7 +1838,40 @@ export const string = new String()
|
|
|
1404
1838
|
* @category models
|
|
1405
1839
|
* @since 4.0.0
|
|
1406
1840
|
*/
|
|
1407
|
-
export
|
|
1841
|
+
export interface Number extends ASTNode {
|
|
1842
|
+
readonly _tag: "Number"
|
|
1843
|
+
/** @internal */
|
|
1844
|
+
|
|
1845
|
+
getParser(): SchemaParser.Parser
|
|
1846
|
+
/** @internal */
|
|
1847
|
+
|
|
1848
|
+
matchKey(s: string, options: ParseOptions): number | undefined
|
|
1849
|
+
/** @internal */
|
|
1850
|
+
|
|
1851
|
+
matchPart(s: string, options: ParseOptions): number | undefined
|
|
1852
|
+
/** @internal */
|
|
1853
|
+
|
|
1854
|
+
toCodecJson(): AST
|
|
1855
|
+
/** @internal */
|
|
1856
|
+
|
|
1857
|
+
toCodecStringTree(): AST
|
|
1858
|
+
/** @internal */
|
|
1859
|
+
|
|
1860
|
+
getExpected(): string
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1863
|
+
/**
|
|
1864
|
+
* Constructs a {@link Number}.
|
|
1865
|
+
*
|
|
1866
|
+
* @category constructors
|
|
1867
|
+
* @since 4.0.0
|
|
1868
|
+
*/
|
|
1869
|
+
export const Number: new(
|
|
1870
|
+
annotations?: Schema.Annotations.Annotations | undefined,
|
|
1871
|
+
checks?: Checks | undefined,
|
|
1872
|
+
encoding?: Encoding | undefined,
|
|
1873
|
+
context?: Context | undefined
|
|
1874
|
+
) => Number = class extends ASTNodeImpl {
|
|
1408
1875
|
readonly _tag = "Number"
|
|
1409
1876
|
/** @internal */
|
|
1410
1877
|
getParser() {
|
|
@@ -1479,7 +1946,28 @@ export const number = new Number()
|
|
|
1479
1946
|
* @category models
|
|
1480
1947
|
* @since 4.0.0
|
|
1481
1948
|
*/
|
|
1482
|
-
export
|
|
1949
|
+
export interface Boolean extends ASTNode {
|
|
1950
|
+
readonly _tag: "Boolean"
|
|
1951
|
+
/** @internal */
|
|
1952
|
+
|
|
1953
|
+
getParser(): SchemaParser.Parser
|
|
1954
|
+
/** @internal */
|
|
1955
|
+
|
|
1956
|
+
getExpected(): string
|
|
1957
|
+
}
|
|
1958
|
+
|
|
1959
|
+
/**
|
|
1960
|
+
* Constructs a {@link Boolean}.
|
|
1961
|
+
*
|
|
1962
|
+
* @category constructors
|
|
1963
|
+
* @since 4.0.0
|
|
1964
|
+
*/
|
|
1965
|
+
export const Boolean: new(
|
|
1966
|
+
annotations?: Schema.Annotations.Annotations | undefined,
|
|
1967
|
+
checks?: Checks | undefined,
|
|
1968
|
+
encoding?: Encoding | undefined,
|
|
1969
|
+
context?: Context | undefined
|
|
1970
|
+
) => Boolean = class extends ASTNodeImpl {
|
|
1483
1971
|
readonly _tag = "Boolean"
|
|
1484
1972
|
/** @internal */
|
|
1485
1973
|
getParser() {
|
|
@@ -1520,12 +2008,39 @@ export const boolean = new Boolean()
|
|
|
1520
2008
|
* When serialized to a string-based codec, symbols are converted via
|
|
1521
2009
|
* `Symbol.keyFor` and must be registered with `Symbol.for`.
|
|
1522
2010
|
*
|
|
1523
|
-
* @see {@link symbol}
|
|
1524
|
-
* @see {@link isSymbol}
|
|
1525
|
-
* @category models
|
|
2011
|
+
* @see {@link symbol}
|
|
2012
|
+
* @see {@link isSymbol}
|
|
2013
|
+
* @category models
|
|
2014
|
+
* @since 4.0.0
|
|
2015
|
+
*/
|
|
2016
|
+
export interface Symbol extends ASTNode {
|
|
2017
|
+
readonly _tag: "Symbol"
|
|
2018
|
+
/** @internal */
|
|
2019
|
+
|
|
2020
|
+
getParser(): SchemaParser.Parser
|
|
2021
|
+
/** @internal */
|
|
2022
|
+
|
|
2023
|
+
matchKey(s: symbol, options: ParseOptions): symbol | undefined
|
|
2024
|
+
/** @internal */
|
|
2025
|
+
|
|
2026
|
+
toCodecStringTree(): AST
|
|
2027
|
+
/** @internal */
|
|
2028
|
+
|
|
2029
|
+
getExpected(): string
|
|
2030
|
+
}
|
|
2031
|
+
|
|
2032
|
+
/**
|
|
2033
|
+
* Constructs a {@link Symbol}.
|
|
2034
|
+
*
|
|
2035
|
+
* @category constructors
|
|
1526
2036
|
* @since 4.0.0
|
|
1527
2037
|
*/
|
|
1528
|
-
export
|
|
2038
|
+
export const Symbol: new(
|
|
2039
|
+
annotations?: Schema.Annotations.Annotations | undefined,
|
|
2040
|
+
checks?: Checks | undefined,
|
|
2041
|
+
encoding?: Encoding | undefined,
|
|
2042
|
+
context?: Context | undefined
|
|
2043
|
+
) => Symbol = class extends ASTNodeImpl {
|
|
1529
2044
|
readonly _tag = "Symbol"
|
|
1530
2045
|
/** @internal */
|
|
1531
2046
|
getParser() {
|
|
@@ -1579,7 +2094,34 @@ export const symbol = new Symbol()
|
|
|
1579
2094
|
* @category models
|
|
1580
2095
|
* @since 4.0.0
|
|
1581
2096
|
*/
|
|
1582
|
-
export
|
|
2097
|
+
export interface BigInt extends ASTNode {
|
|
2098
|
+
readonly _tag: "BigInt"
|
|
2099
|
+
/** @internal */
|
|
2100
|
+
|
|
2101
|
+
getParser(): SchemaParser.Parser
|
|
2102
|
+
/** @internal */
|
|
2103
|
+
|
|
2104
|
+
matchPart(s: string, options: ParseOptions): bigint | undefined
|
|
2105
|
+
/** @internal */
|
|
2106
|
+
|
|
2107
|
+
toCodecStringTree(): AST
|
|
2108
|
+
/** @internal */
|
|
2109
|
+
|
|
2110
|
+
getExpected(): string
|
|
2111
|
+
}
|
|
2112
|
+
|
|
2113
|
+
/**
|
|
2114
|
+
* Constructs a {@link BigInt}.
|
|
2115
|
+
*
|
|
2116
|
+
* @category constructors
|
|
2117
|
+
* @since 4.0.0
|
|
2118
|
+
*/
|
|
2119
|
+
export const BigInt: new(
|
|
2120
|
+
annotations?: Schema.Annotations.Annotations | undefined,
|
|
2121
|
+
checks?: Checks | undefined,
|
|
2122
|
+
encoding?: Encoding | undefined,
|
|
2123
|
+
context?: Context | undefined
|
|
2124
|
+
) => BigInt = class extends ASTNodeImpl {
|
|
1583
2125
|
readonly _tag = "BigInt"
|
|
1584
2126
|
/** @internal */
|
|
1585
2127
|
getParser() {
|
|
@@ -1629,7 +2171,7 @@ export const bigInt = new BigInt()
|
|
|
1629
2171
|
* **Details**
|
|
1630
2172
|
*
|
|
1631
2173
|
* - `elements` — positional element types (tuple elements). An element is
|
|
1632
|
-
* optional if its
|
|
2174
|
+
* optional if its context's `isOptional` field is `true`.
|
|
1633
2175
|
* - `rest` — the rest/variadic element types. When non-empty, the first
|
|
1634
2176
|
* entry is the "spread" type (e.g. `...Array<string>`), and subsequent
|
|
1635
2177
|
* entries are trailing positional elements after the spread.
|
|
@@ -1660,7 +2202,42 @@ export const bigInt = new BigInt()
|
|
|
1660
2202
|
* @category models
|
|
1661
2203
|
* @since 4.0.0
|
|
1662
2204
|
*/
|
|
1663
|
-
export
|
|
2205
|
+
export interface Arrays extends ASTNode {
|
|
2206
|
+
readonly _tag: "Arrays"
|
|
2207
|
+
readonly isMutable: boolean
|
|
2208
|
+
readonly elements: ReadonlyArray<AST>
|
|
2209
|
+
readonly rest: ReadonlyArray<AST>
|
|
2210
|
+
readonly encodingChecks: Checks | undefined
|
|
2211
|
+
/** @internal */
|
|
2212
|
+
|
|
2213
|
+
getParser(compile: SchemaParser.Compiler, compileConstructorDefault?: SchemaParser.Compiler): SchemaParser.Parser
|
|
2214
|
+
/** @internal */
|
|
2215
|
+
|
|
2216
|
+
recur(recur: (ast: AST) => AST): Arrays
|
|
2217
|
+
/** @internal */
|
|
2218
|
+
|
|
2219
|
+
flip(recur: (ast: AST) => AST): Arrays
|
|
2220
|
+
/** @internal */
|
|
2221
|
+
|
|
2222
|
+
getExpected(): string
|
|
2223
|
+
}
|
|
2224
|
+
|
|
2225
|
+
/**
|
|
2226
|
+
* Constructs a {@link Arrays}.
|
|
2227
|
+
*
|
|
2228
|
+
* @category constructors
|
|
2229
|
+
* @since 4.0.0
|
|
2230
|
+
*/
|
|
2231
|
+
export const Arrays: new(
|
|
2232
|
+
isMutable: boolean,
|
|
2233
|
+
elements: ReadonlyArray<AST>,
|
|
2234
|
+
rest: ReadonlyArray<AST>,
|
|
2235
|
+
annotations?: Schema.Annotations.Annotations,
|
|
2236
|
+
checks?: Checks,
|
|
2237
|
+
encoding?: Encoding,
|
|
2238
|
+
context?: Context,
|
|
2239
|
+
encodingChecks?: Checks
|
|
2240
|
+
) => Arrays = class extends ASTNodeImpl {
|
|
1664
2241
|
readonly _tag = "Arrays"
|
|
1665
2242
|
readonly isMutable: boolean
|
|
1666
2243
|
readonly elements: ReadonlyArray<AST>
|
|
@@ -1752,11 +2329,11 @@ export class Arrays extends Base {
|
|
|
1752
2329
|
issues: undefined as Arr.NonEmptyArray<SchemaIssue.Issue> | undefined,
|
|
1753
2330
|
options
|
|
1754
2331
|
}
|
|
1755
|
-
const
|
|
1756
|
-
const
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
2332
|
+
const end = ast.rest.length === 0 ? elementLen : Math.max(len, elementLen + tailLen)
|
|
2333
|
+
const concurrency = options.concurrency === undefined ? 1 : resolveConcurrency(options.concurrency)
|
|
2334
|
+
const eff = concurrency === 1
|
|
2335
|
+
? parseArray(state, input, 0, end)
|
|
2336
|
+
: parseArrayConcurrent(state, input, { concurrency, end })
|
|
1760
2337
|
if (eff) yield* eff
|
|
1761
2338
|
|
|
1762
2339
|
// ---------------------------------------------
|
|
@@ -1814,7 +2391,7 @@ export class Arrays extends Base {
|
|
|
1814
2391
|
return "array"
|
|
1815
2392
|
}
|
|
1816
2393
|
}
|
|
1817
|
-
|
|
2394
|
+
type ArrayParserState = {
|
|
1818
2395
|
readonly ast: AST
|
|
1819
2396
|
readonly input: unknown
|
|
1820
2397
|
readonly len: number
|
|
@@ -1826,12 +2403,14 @@ const parseArray = iterateEager<{
|
|
|
1826
2403
|
readonly options: ParseOptions
|
|
1827
2404
|
readonly output: Array<unknown>
|
|
1828
2405
|
issues: Array<SchemaIssue.Issue> | undefined
|
|
1829
|
-
}
|
|
1830
|
-
|
|
2406
|
+
}
|
|
2407
|
+
|
|
2408
|
+
const parseArrayOptions = {
|
|
2409
|
+
onItem(s: ArrayParserState, item: unknown, i: number) {
|
|
1831
2410
|
const value = i < s.len ? item : InternalParser.missing
|
|
1832
2411
|
return s.getParser(s.tailThreshold, i).parser(value, s.options)
|
|
1833
2412
|
},
|
|
1834
|
-
step(s, item, exit, i) {
|
|
2413
|
+
step(s: ArrayParserState, item: unknown, exit: Exit.Exit<unknown, SchemaIssue.Issue>, i: number) {
|
|
1835
2414
|
if (exit._tag === "Failure") {
|
|
1836
2415
|
return wrapPropertyKeyIssue(s, s.ast, i, exit)
|
|
1837
2416
|
}
|
|
@@ -1854,13 +2433,11 @@ const parseArray = iterateEager<{
|
|
|
1854
2433
|
}
|
|
1855
2434
|
}
|
|
1856
2435
|
}
|
|
1857
|
-
})
|
|
1858
|
-
|
|
1859
|
-
const resolveConcurrency = (value: number | "unbounded" | undefined) => {
|
|
1860
|
-
value = value === "unbounded" ? Infinity : value ?? 1
|
|
1861
|
-
return value > 1 ? { concurrency: value } : undefined
|
|
1862
2436
|
}
|
|
1863
2437
|
|
|
2438
|
+
const parseArray = iterateEager<ArrayParserState, unknown>()(parseArrayOptions)
|
|
2439
|
+
const parseArrayConcurrent = iterateConcurrent<ArrayParserState, unknown>()(parseArrayOptions)
|
|
2440
|
+
|
|
1864
2441
|
const wrapPropertyKeyIssue = (
|
|
1865
2442
|
s: {
|
|
1866
2443
|
readonly input: unknown
|
|
@@ -1949,9 +2526,20 @@ export function getIndexSignatureKeys(
|
|
|
1949
2526
|
*
|
|
1950
2527
|
* @see {@link Objects}
|
|
1951
2528
|
* @category models
|
|
1952
|
-
* @since
|
|
2529
|
+
* @since 4.0.0
|
|
2530
|
+
*/
|
|
2531
|
+
export interface PropertySignature {
|
|
2532
|
+
readonly name: PropertyKey
|
|
2533
|
+
readonly type: AST
|
|
2534
|
+
}
|
|
2535
|
+
|
|
2536
|
+
/**
|
|
2537
|
+
* Constructs a {@link PropertySignature}.
|
|
2538
|
+
*
|
|
2539
|
+
* @category constructors
|
|
2540
|
+
* @since 4.0.0
|
|
1953
2541
|
*/
|
|
1954
|
-
export
|
|
2542
|
+
export const PropertySignature: new(name: PropertyKey, type: AST) => PropertySignature = class {
|
|
1955
2543
|
readonly name: PropertyKey
|
|
1956
2544
|
readonly type: AST
|
|
1957
2545
|
|
|
@@ -2011,9 +2599,20 @@ function isIndexSignatureParameter(ast: AST): ast is IndexSignatureParameter {
|
|
|
2011
2599
|
* @see {@link Objects}
|
|
2012
2600
|
* @see {@link PropertySignature}
|
|
2013
2601
|
* @category models
|
|
2014
|
-
* @since
|
|
2602
|
+
* @since 4.0.0
|
|
2015
2603
|
*/
|
|
2016
|
-
export
|
|
2604
|
+
export interface IndexSignature {
|
|
2605
|
+
readonly parameter: IndexSignatureParameter
|
|
2606
|
+
readonly type: AST
|
|
2607
|
+
}
|
|
2608
|
+
|
|
2609
|
+
/**
|
|
2610
|
+
* Constructs a {@link IndexSignature}.
|
|
2611
|
+
*
|
|
2612
|
+
* @category constructors
|
|
2613
|
+
* @since 4.0.0
|
|
2614
|
+
*/
|
|
2615
|
+
export const IndexSignature: new(parameter: AST, type: AST) => IndexSignature = class {
|
|
2017
2616
|
readonly parameter: IndexSignatureParameter
|
|
2018
2617
|
readonly type: AST
|
|
2019
2618
|
|
|
@@ -2074,7 +2673,40 @@ export class IndexSignature {
|
|
|
2074
2673
|
* @category models
|
|
2075
2674
|
* @since 4.0.0
|
|
2076
2675
|
*/
|
|
2077
|
-
export
|
|
2676
|
+
export interface Objects extends ASTNode {
|
|
2677
|
+
readonly _tag: "Objects"
|
|
2678
|
+
readonly propertySignatures: ReadonlyArray<PropertySignature>
|
|
2679
|
+
readonly indexSignatures: ReadonlyArray<IndexSignature>
|
|
2680
|
+
readonly encodingChecks: Checks | undefined
|
|
2681
|
+
/** @internal */
|
|
2682
|
+
|
|
2683
|
+
getParser(compile: SchemaParser.Compiler, compileConstructorDefault?: SchemaParser.Compiler): SchemaParser.Parser
|
|
2684
|
+
/** @internal */
|
|
2685
|
+
|
|
2686
|
+
flip(recur: (ast: AST) => AST): AST
|
|
2687
|
+
/** @internal */
|
|
2688
|
+
|
|
2689
|
+
recur(recur: (ast: AST) => AST, recurParameter?: (ast: AST) => AST): AST
|
|
2690
|
+
/** @internal */
|
|
2691
|
+
|
|
2692
|
+
getExpected(): string
|
|
2693
|
+
}
|
|
2694
|
+
|
|
2695
|
+
/**
|
|
2696
|
+
* Constructs a {@link Objects}.
|
|
2697
|
+
*
|
|
2698
|
+
* @category constructors
|
|
2699
|
+
* @since 4.0.0
|
|
2700
|
+
*/
|
|
2701
|
+
export const Objects: new(
|
|
2702
|
+
propertySignatures: ReadonlyArray<PropertySignature>,
|
|
2703
|
+
indexSignatures: ReadonlyArray<IndexSignature>,
|
|
2704
|
+
annotations?: Schema.Annotations.Annotations,
|
|
2705
|
+
checks?: Checks,
|
|
2706
|
+
encoding?: Encoding,
|
|
2707
|
+
context?: Context,
|
|
2708
|
+
encodingChecks?: Checks
|
|
2709
|
+
) => Objects = class extends ASTNodeImpl {
|
|
2078
2710
|
readonly _tag = "Objects"
|
|
2079
2711
|
readonly propertySignatures: ReadonlyArray<PropertySignature>
|
|
2080
2712
|
readonly indexSignatures: ReadonlyArray<IndexSignature>
|
|
@@ -2109,7 +2741,7 @@ export class Objects extends Base {
|
|
|
2109
2741
|
const ast = this
|
|
2110
2742
|
const expectedKeys: Array<PropertyKey> = []
|
|
2111
2743
|
for (const ps of ast.propertySignatures) {
|
|
2112
|
-
expectedKeys.push(ps.name)
|
|
2744
|
+
expectedKeys.push(typeof ps.name === "number" ? globalThis.String(ps.name) : ps.name)
|
|
2113
2745
|
}
|
|
2114
2746
|
const hasProperties = expectedKeys.length
|
|
2115
2747
|
const indexCount = ast.indexSignatures.length
|
|
@@ -2144,7 +2776,10 @@ export class Objects extends Base {
|
|
|
2144
2776
|
? inputValue
|
|
2145
2777
|
: (exitValue as InternalParser.Success<unknown, SchemaIssue.Issue>)[InternalParser.args]
|
|
2146
2778
|
if (k2 !== InternalParser.missing && value !== InternalParser.missing) {
|
|
2147
|
-
if (
|
|
2779
|
+
if (
|
|
2780
|
+
hasProperties &&
|
|
2781
|
+
(expectedKeysSet!.has(key) || expectedKeysSet!.has(typeof k2 === "number" ? globalThis.String(k2) : k2))
|
|
2782
|
+
) return Exit.void
|
|
2148
2783
|
InternalRecord.assignProperty(s.out, k2, value)
|
|
2149
2784
|
}
|
|
2150
2785
|
return Exit.void
|
|
@@ -2185,22 +2820,14 @@ export class Objects extends Base {
|
|
|
2185
2820
|
? finishIndex(s, key, key, inputValue, result)
|
|
2186
2821
|
: Effect.flatMap(Effect.exit(result), (exit) => finishIndex(s, key, key, inputValue, exit))
|
|
2187
2822
|
}
|
|
2188
|
-
const parseIndexes = indexCount
|
|
2189
|
-
|
|
2190
|
-
onItem: (s, [key, index]) =>
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
if (input === InternalParser.missing) {
|
|
2197
|
-
return InternalParser.missing
|
|
2198
|
-
}
|
|
2199
|
-
|
|
2200
|
-
// If the input is not a record, return early with an error
|
|
2201
|
-
if (!(typeof input === "object" && input !== null && !Array.isArray(input))) {
|
|
2202
|
-
return yield* Effect.fail(new SchemaIssue.InvalidType(ast, input, options))
|
|
2203
|
-
}
|
|
2823
|
+
const parseIndexes = indexCount
|
|
2824
|
+
? iterateConcurrent<ObjectParserState, readonly [key: PropertyKey, index: Index]>()({
|
|
2825
|
+
onItem: (s, [key, index]) =>
|
|
2826
|
+
index.is.parameter === string ? parseStringIndex(s, key, index) : parseIndex(s, key, index),
|
|
2827
|
+
step: (_s, _item, exit) => exit._tag === "Failure" ? exit : undefined
|
|
2828
|
+
})
|
|
2829
|
+
: undefined
|
|
2830
|
+
const compileMembers = (): Array<ParsedProperty> => {
|
|
2204
2831
|
if (!properties) {
|
|
2205
2832
|
properties = ast.propertySignatures.map((ps) => ({
|
|
2206
2833
|
parser: compileConstructorDefault(ps.type),
|
|
@@ -2215,6 +2842,19 @@ export class Objects extends Base {
|
|
|
2215
2842
|
}))
|
|
2216
2843
|
: undefined
|
|
2217
2844
|
}
|
|
2845
|
+
return properties
|
|
2846
|
+
}
|
|
2847
|
+
|
|
2848
|
+
const fallback: SchemaParser.Parser = Effect.fnUntracedEager(function*(input, options) {
|
|
2849
|
+
if (input === InternalParser.missing) {
|
|
2850
|
+
return InternalParser.missing
|
|
2851
|
+
}
|
|
2852
|
+
|
|
2853
|
+
// If the input is not a record, return early with an error
|
|
2854
|
+
if (!(typeof input === "object" && input !== null && !Array.isArray(input))) {
|
|
2855
|
+
return yield* Effect.fail(new SchemaIssue.InvalidType(ast, input, options))
|
|
2856
|
+
}
|
|
2857
|
+
compileMembers()
|
|
2218
2858
|
|
|
2219
2859
|
const record = input as Record<PropertyKey, unknown>
|
|
2220
2860
|
const out: Record<PropertyKey, unknown> = {}
|
|
@@ -2227,62 +2867,65 @@ export class Objects extends Base {
|
|
|
2227
2867
|
}
|
|
2228
2868
|
const errorsAllOption = options.errors === "all"
|
|
2229
2869
|
const onExcessPropertyError = options.onExcessProperty === "error"
|
|
2230
|
-
const
|
|
2870
|
+
const concurrency = options.concurrency === undefined ? 1 : resolveConcurrency(options.concurrency)
|
|
2231
2871
|
|
|
2232
2872
|
// ---------------------------------------------
|
|
2233
2873
|
// handle excess properties
|
|
2234
2874
|
// ---------------------------------------------
|
|
2235
|
-
|
|
2236
|
-
|
|
2875
|
+
const indexKeys = indexCount && onExcessPropertyError
|
|
2876
|
+
? ast.indexSignatures.map((index) => getIndexSignatureKeys(record, index.parameter, options))
|
|
2877
|
+
: undefined
|
|
2878
|
+
if (onExcessPropertyError) {
|
|
2237
2879
|
expectedKeysSet ??= new Set(expectedKeys)
|
|
2238
|
-
|
|
2880
|
+
const coveredKeys = indexKeys ? new Set(expectedKeysSet) : expectedKeysSet
|
|
2881
|
+
if (indexKeys) {
|
|
2882
|
+
for (const keys of indexKeys) {
|
|
2883
|
+
for (const key of keys) coveredKeys.add(key)
|
|
2884
|
+
}
|
|
2885
|
+
}
|
|
2886
|
+
const inputKeys = Reflect.ownKeys(record)
|
|
2239
2887
|
for (let i = 0; i < inputKeys.length; i++) {
|
|
2240
2888
|
const key = inputKeys[i]
|
|
2241
|
-
if (!
|
|
2889
|
+
if (!coveredKeys.has(key)) {
|
|
2242
2890
|
// key is unexpected
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
if (
|
|
2247
|
-
|
|
2248
|
-
state.issues.push(issue)
|
|
2249
|
-
} else {
|
|
2250
|
-
state.issues = [issue]
|
|
2251
|
-
}
|
|
2252
|
-
continue
|
|
2891
|
+
const unexpected = new SchemaIssue.UnexpectedKey(ast, record[key], options)
|
|
2892
|
+
const issue = new SchemaIssue.Pointer([key], unexpected)
|
|
2893
|
+
if (errorsAllOption) {
|
|
2894
|
+
if (state.issues) {
|
|
2895
|
+
state.issues.push(issue)
|
|
2253
2896
|
} else {
|
|
2254
|
-
|
|
2255
|
-
new SchemaIssue.Composite(ast, [issue], input, options)
|
|
2256
|
-
)
|
|
2897
|
+
state.issues = [issue]
|
|
2257
2898
|
}
|
|
2899
|
+
continue
|
|
2258
2900
|
} else {
|
|
2259
|
-
|
|
2260
|
-
|
|
2901
|
+
return yield* Effect.fail(
|
|
2902
|
+
new SchemaIssue.Composite(ast, [issue], input, options)
|
|
2903
|
+
)
|
|
2261
2904
|
}
|
|
2262
2905
|
}
|
|
2263
2906
|
}
|
|
2264
2907
|
}
|
|
2265
2908
|
|
|
2266
|
-
const concurrency = resolveConcurrency(options?.concurrency)
|
|
2267
|
-
|
|
2268
2909
|
// ---------------------------------------------
|
|
2269
2910
|
// handle property signatures
|
|
2270
2911
|
// ---------------------------------------------
|
|
2271
2912
|
if (hasProperties) {
|
|
2272
|
-
const eff =
|
|
2913
|
+
const eff = concurrency === 1
|
|
2914
|
+
? parseProperties(state, properties!)
|
|
2915
|
+
: parsePropertiesConcurrent(state, properties!, { concurrency })
|
|
2273
2916
|
if (eff) yield* eff
|
|
2274
2917
|
}
|
|
2275
2918
|
|
|
2276
2919
|
// ---------------------------------------------
|
|
2277
2920
|
// handle index signatures
|
|
2278
2921
|
// ---------------------------------------------
|
|
2279
|
-
if (indexCount &&
|
|
2922
|
+
if (indexCount && concurrency === 1) {
|
|
2280
2923
|
for (let i = 0; i < indexCount; i++) {
|
|
2281
2924
|
const index = indexes![i]
|
|
2282
2925
|
const parse = index.is.parameter === string ? parseStringIndex : parseIndex
|
|
2283
|
-
const keys = index.is.parameter === string
|
|
2926
|
+
const keys = indexKeys?.[i] ?? (index.is.parameter === string
|
|
2284
2927
|
? Object.keys(record)
|
|
2285
|
-
: getIndexSignatureKeys(record, index.is.parameter, options)
|
|
2928
|
+
: getIndexSignatureKeys(record, index.is.parameter, options))
|
|
2286
2929
|
for (let j = 0; j < keys.length; j++) {
|
|
2287
2930
|
const eff = parse(state, keys[j], index)
|
|
2288
2931
|
if (!effectIsExit(eff)) yield* eff
|
|
@@ -2290,15 +2933,17 @@ export class Objects extends Base {
|
|
|
2290
2933
|
}
|
|
2291
2934
|
}
|
|
2292
2935
|
} else if (parseIndexes) {
|
|
2293
|
-
const keyPairs = Arr.empty<[PropertyKey, Index]>()
|
|
2936
|
+
const keyPairs = Arr.empty<readonly [PropertyKey, Index]>()
|
|
2294
2937
|
for (let i = 0; i < indexCount; i++) {
|
|
2295
2938
|
const index = indexes![i]
|
|
2296
|
-
const keys =
|
|
2939
|
+
const keys = indexKeys?.[i] ?? (index.is.parameter === string
|
|
2940
|
+
? Object.keys(record)
|
|
2941
|
+
: getIndexSignatureKeys(record, index.is.parameter, options))
|
|
2297
2942
|
for (let j = 0; j < keys.length; j++) {
|
|
2298
2943
|
keyPairs.push([keys[j], index])
|
|
2299
2944
|
}
|
|
2300
2945
|
}
|
|
2301
|
-
const eff = parseIndexes(state, keyPairs, concurrency)
|
|
2946
|
+
const eff = parseIndexes(state, keyPairs, { concurrency })
|
|
2302
2947
|
if (eff) yield* eff
|
|
2303
2948
|
}
|
|
2304
2949
|
|
|
@@ -2307,19 +2952,69 @@ export class Objects extends Base {
|
|
|
2307
2952
|
new SchemaIssue.Composite(ast, state.issues, input, options)
|
|
2308
2953
|
)
|
|
2309
2954
|
}
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2955
|
+
return out
|
|
2956
|
+
})
|
|
2957
|
+
|
|
2958
|
+
if (indexCount) return fallback
|
|
2959
|
+
|
|
2960
|
+
// Resumes at the property whose parser suspended, without replaying the
|
|
2961
|
+
// properties already parsed.
|
|
2962
|
+
const resume = (
|
|
2963
|
+
state: ObjectParserState,
|
|
2964
|
+
index: number,
|
|
2965
|
+
pending: Effect.Effect<unknown, SchemaIssue.Issue, any>
|
|
2966
|
+
): Effect.Effect<unknown, SchemaIssue.Issue, any> => {
|
|
2967
|
+
const property = properties![index]
|
|
2968
|
+
return Effect.flatMap(Effect.exit(pending), (exit) => {
|
|
2969
|
+
const terminal = stepProperty(state, property, exit)
|
|
2970
|
+
if (terminal) return terminal
|
|
2971
|
+
const done = () => InternalParser.succeed(state.out)
|
|
2972
|
+
const eff = parseProperties(state, properties!.slice(index + 1))
|
|
2973
|
+
return eff ? Effect.flatMapEager(eff, done) : done()
|
|
2974
|
+
})
|
|
2975
|
+
}
|
|
2976
|
+
|
|
2977
|
+
// Fast path: a struct without index signatures, under the default parse
|
|
2978
|
+
// options, needs none of the generator the fallback runs per value.
|
|
2979
|
+
return (input, options) => {
|
|
2980
|
+
if (input === InternalParser.missing) return InternalParser.missingExit
|
|
2981
|
+
if (
|
|
2982
|
+
options.errors === "all" ||
|
|
2983
|
+
options.onExcessProperty !== undefined ||
|
|
2984
|
+
(options.concurrency !== undefined && resolveConcurrency(options.concurrency) !== 1)
|
|
2985
|
+
) {
|
|
2986
|
+
return fallback(input, options)
|
|
2987
|
+
}
|
|
2988
|
+
if (!(typeof input === "object" && input !== null && !Array.isArray(input))) {
|
|
2989
|
+
return Effect.fail(new SchemaIssue.InvalidType(ast, input, options))
|
|
2990
|
+
}
|
|
2991
|
+
const props = compileMembers()
|
|
2992
|
+
const record = input as Record<PropertyKey, unknown>
|
|
2993
|
+
const out: Record<PropertyKey, unknown> = {}
|
|
2994
|
+
const state: ObjectParserState = { ast, input: record, out, issues: undefined, options }
|
|
2995
|
+
try {
|
|
2996
|
+
for (let index = 0; index < props.length; index++) {
|
|
2997
|
+
const property = props[index]
|
|
2998
|
+
const name = property.name
|
|
2999
|
+
const hasKey = hasPropertySignature(record, name)
|
|
3000
|
+
const value = hasKey ? record[name] : InternalParser.missing
|
|
3001
|
+
const exit = property.parser(value, options)
|
|
3002
|
+
if (!effectIsExit(exit)) {
|
|
3003
|
+
return resume(state, index, exit)
|
|
2317
3004
|
}
|
|
3005
|
+
if (exit === InternalParser.sameExit) {
|
|
3006
|
+
if (hasKey) InternalRecord.assignProperty(out, name, value)
|
|
3007
|
+
continue
|
|
3008
|
+
}
|
|
3009
|
+
const terminal = stepProperty(state, property, exit)
|
|
3010
|
+
if (terminal) return terminal
|
|
2318
3011
|
}
|
|
2319
|
-
|
|
3012
|
+
} catch (error) {
|
|
3013
|
+
// `Effect.fnUntracedEager` turns a synchronous throw into a defect
|
|
3014
|
+
return Effect.die(error)
|
|
2320
3015
|
}
|
|
2321
|
-
return out
|
|
2322
|
-
}
|
|
3016
|
+
return InternalParser.succeed(out)
|
|
3017
|
+
}
|
|
2323
3018
|
}
|
|
2324
3019
|
private _rebuild(
|
|
2325
3020
|
recur: (ast: AST) => AST,
|
|
@@ -2382,40 +3077,49 @@ type ParsedProperty = {
|
|
|
2382
3077
|
readonly type: AST
|
|
2383
3078
|
}
|
|
2384
3079
|
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
3080
|
+
function stepProperty(
|
|
3081
|
+
s: ObjectParserState,
|
|
3082
|
+
p: ParsedProperty,
|
|
3083
|
+
exit: Exit.Exit<unknown, SchemaIssue.Issue>
|
|
3084
|
+
): Exit.Exit<void, SchemaIssue.Issue> | void {
|
|
3085
|
+
if (exit._tag === "Failure") {
|
|
3086
|
+
return wrapPropertyKeyIssue(s, s.ast, p.name, exit)
|
|
3087
|
+
}
|
|
3088
|
+
if (exit === InternalParser.sameExit) return
|
|
3089
|
+
const value = (exit as InternalParser.Success<unknown, SchemaIssue.Issue>)[InternalParser.args]
|
|
3090
|
+
if (value !== InternalParser.missing) {
|
|
3091
|
+
InternalRecord.assignProperty(s.out, p.name, value)
|
|
3092
|
+
return
|
|
3093
|
+
}
|
|
3094
|
+
delete s.out[p.name]
|
|
3095
|
+
if (!isOptional(p.type)) {
|
|
3096
|
+
const issue = new SchemaIssue.Pointer([p.name], new SchemaIssue.MissingKey(p.type.context?.annotations))
|
|
3097
|
+
if (s.options.errors === "all") {
|
|
3098
|
+
if (s.issues) s.issues.push(issue)
|
|
3099
|
+
else s.issues = [issue]
|
|
3100
|
+
return
|
|
3101
|
+
} else {
|
|
3102
|
+
return Exit.fail(
|
|
3103
|
+
new SchemaIssue.Composite(s.ast, [issue], s.input, s.options)
|
|
3104
|
+
)
|
|
3105
|
+
}
|
|
3106
|
+
}
|
|
3107
|
+
}
|
|
3108
|
+
|
|
3109
|
+
const parsePropertiesOptions = {
|
|
3110
|
+
onItem(s: ObjectParserState, p: ParsedProperty) {
|
|
3111
|
+
if (!hasPropertySignature(s.input, p.name)) {
|
|
2388
3112
|
return p.parser(InternalParser.missing, s.options)
|
|
2389
3113
|
}
|
|
2390
3114
|
const value = s.input[p.name]
|
|
2391
3115
|
InternalRecord.assignProperty(s.out, p.name, value)
|
|
2392
3116
|
return p.parser(value, s.options)
|
|
2393
3117
|
},
|
|
2394
|
-
step
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
const value = (exit as InternalParser.Success<unknown, SchemaIssue.Issue>)[InternalParser.args]
|
|
2400
|
-
if (value !== InternalParser.missing) {
|
|
2401
|
-
InternalRecord.assignProperty(s.out, p.name, value)
|
|
2402
|
-
return
|
|
2403
|
-
}
|
|
2404
|
-
delete s.out[p.name]
|
|
2405
|
-
if (!isOptional(p.type)) {
|
|
2406
|
-
const issue = new SchemaIssue.Pointer([p.name], new SchemaIssue.MissingKey(p.type.context?.annotations))
|
|
2407
|
-
if (s.options.errors === "all") {
|
|
2408
|
-
if (s.issues) s.issues.push(issue)
|
|
2409
|
-
else s.issues = [issue]
|
|
2410
|
-
return
|
|
2411
|
-
} else {
|
|
2412
|
-
return Exit.fail(
|
|
2413
|
-
new SchemaIssue.Composite(s.ast, [issue], s.input, s.options)
|
|
2414
|
-
)
|
|
2415
|
-
}
|
|
2416
|
-
}
|
|
2417
|
-
}
|
|
2418
|
-
})
|
|
3118
|
+
step: stepProperty
|
|
3119
|
+
}
|
|
3120
|
+
|
|
3121
|
+
const parseProperties = iterateEager<ObjectParserState, ParsedProperty>()(parsePropertiesOptions)
|
|
3122
|
+
const parsePropertiesConcurrent = iterateConcurrent<ObjectParserState, ParsedProperty>()(parsePropertiesOptions)
|
|
2419
3123
|
|
|
2420
3124
|
function combineChecks(a: Checks | undefined, b: Checks | undefined): Checks | undefined {
|
|
2421
3125
|
if (!a) return b
|
|
@@ -2455,10 +3159,10 @@ export function tuple<Elements extends Schema.Tuple.Elements>(
|
|
|
2455
3159
|
/** @internal */
|
|
2456
3160
|
export function union<Members extends ReadonlyArray<{ readonly ast: AST }>>(
|
|
2457
3161
|
members: Members,
|
|
2458
|
-
|
|
3162
|
+
options: UnionOptions | undefined,
|
|
2459
3163
|
checks: Checks | undefined
|
|
2460
3164
|
): Union<Members[number]["ast"]> {
|
|
2461
|
-
return new Union(members.map(getAST),
|
|
3165
|
+
return new Union(members.map(getAST), options, undefined, checks)
|
|
2462
3166
|
}
|
|
2463
3167
|
|
|
2464
3168
|
/** @internal */
|
|
@@ -2485,6 +3189,23 @@ export function tupleWithRest(ast: Arrays, rest: ReadonlyArray<AST>): Arrays {
|
|
|
2485
3189
|
return new Arrays(ast.isMutable, ast.elements, rest, undefined, ast.checks)
|
|
2486
3190
|
}
|
|
2487
3191
|
|
|
3192
|
+
/** @internal */
|
|
3193
|
+
export function mutable(ast: Arrays): Arrays {
|
|
3194
|
+
if (ast.encoding) {
|
|
3195
|
+
throw new Error("mutable does not support encodings")
|
|
3196
|
+
}
|
|
3197
|
+
return new Arrays(
|
|
3198
|
+
true,
|
|
3199
|
+
ast.elements,
|
|
3200
|
+
ast.rest,
|
|
3201
|
+
ast.annotations,
|
|
3202
|
+
ast.checks,
|
|
3203
|
+
undefined,
|
|
3204
|
+
ast.context,
|
|
3205
|
+
ast.encodingChecks
|
|
3206
|
+
)
|
|
3207
|
+
}
|
|
3208
|
+
|
|
2488
3209
|
type Type =
|
|
2489
3210
|
| "null"
|
|
2490
3211
|
| "array"
|
|
@@ -2622,6 +3343,9 @@ type SentinelIndex = Map<PropertyKey, SentinelEntry>
|
|
|
2622
3343
|
const candidateIndexCache = new WeakMap<ReadonlyArray<AST>, CandidateIndex>()
|
|
2623
3344
|
const emptyCandidates: ReadonlyArray<never> = Object.freeze([])
|
|
2624
3345
|
|
|
3346
|
+
const hasPropertySignature = (input: object, key: PropertyKey): boolean =>
|
|
3347
|
+
key === "__proto__" ? Object.hasOwn(input, key) : key in input
|
|
3348
|
+
|
|
2625
3349
|
function getIndex(types: ReadonlyArray<AST>): CandidateIndex {
|
|
2626
3350
|
let index = candidateIndexCache.get(types)
|
|
2627
3351
|
if (index) return index
|
|
@@ -2679,7 +3403,7 @@ function getIndex(types: ReadonlyArray<AST>): CandidateIndex {
|
|
|
2679
3403
|
}
|
|
2680
3404
|
index = (input, isConstructor) => {
|
|
2681
3405
|
if (Predicate.isObjectKeyword(input)) {
|
|
2682
|
-
const value =
|
|
3406
|
+
const value = hasPropertySignature(input, key) ? (input as any)[key] : undefined
|
|
2683
3407
|
if (value !== undefined) return candidates.get(value) ?? emptyCandidates
|
|
2684
3408
|
if (isConstructor) return types
|
|
2685
3409
|
}
|
|
@@ -2711,7 +3435,7 @@ function getIndex(types: ReadonlyArray<AST>): CandidateIndex {
|
|
|
2711
3435
|
// discriminated candidate.
|
|
2712
3436
|
if (commonSentinel) {
|
|
2713
3437
|
const [key, [byValue]] = commonSentinel
|
|
2714
|
-
const hasKey =
|
|
3438
|
+
const hasKey = hasPropertySignature(input, key)
|
|
2715
3439
|
const value = hasKey ? (input as any)[key] : undefined
|
|
2716
3440
|
if (hasKey && (!isConstructor || value !== undefined)) {
|
|
2717
3441
|
const match = byValue.get(value)
|
|
@@ -2725,7 +3449,7 @@ function getIndex(types: ReadonlyArray<AST>): CandidateIndex {
|
|
|
2725
3449
|
// absent and undefined keys as unconstrained and therefore selects every candidate that owns the key.
|
|
2726
3450
|
if (directKey === undefined) {
|
|
2727
3451
|
for (const [key, [byValue, all]] of bySentinel) {
|
|
2728
|
-
const hasKey =
|
|
3452
|
+
const hasKey = hasPropertySignature(input, key)
|
|
2729
3453
|
const value = hasKey ? (input as any)[key] : undefined
|
|
2730
3454
|
if (hasKey && (!isConstructor || value !== undefined)) {
|
|
2731
3455
|
const match = byValue.get(value)
|
|
@@ -2740,7 +3464,7 @@ function getIndex(types: ReadonlyArray<AST>): CandidateIndex {
|
|
|
2740
3464
|
// Missing keys are neutral. An observed key rejects only selected candidates that own it and do not match.
|
|
2741
3465
|
for (const [key, [byValue, all]] of bySentinel) {
|
|
2742
3466
|
if (key === directKey) continue
|
|
2743
|
-
const hasKey =
|
|
3467
|
+
const hasKey = hasPropertySignature(input, key)
|
|
2744
3468
|
const value = hasKey ? (input as any)[key] : undefined
|
|
2745
3469
|
if (hasKey && (!isConstructor || value !== undefined)) {
|
|
2746
3470
|
const match = byValue.get(value)
|
|
@@ -2793,7 +3517,7 @@ export function getCandidates(
|
|
|
2793
3517
|
* **Details**
|
|
2794
3518
|
*
|
|
2795
3519
|
* - `types` — the member AST nodes.
|
|
2796
|
-
* - `mode`
|
|
3520
|
+
* - `options.mode` selects matching behavior. `"anyOf"` succeeds on the first match;
|
|
2797
3521
|
* `"oneOf"` requires exactly one member to match (fails if multiple do).
|
|
2798
3522
|
*
|
|
2799
3523
|
* During parsing, members are tried in order. An internal candidate index
|
|
@@ -2809,23 +3533,70 @@ export function getCandidates(
|
|
|
2809
3533
|
* const ast = schema.ast
|
|
2810
3534
|
*
|
|
2811
3535
|
* if (SchemaAST.isUnion(ast)) {
|
|
2812
|
-
* [ast.types.length, ast.mode] // => [2, "anyOf"]
|
|
3536
|
+
* [ast.types.length, ast.options?.mode ?? "anyOf"] // => [2, "anyOf"]
|
|
2813
3537
|
* }
|
|
2814
3538
|
* ```
|
|
2815
3539
|
*
|
|
2816
3540
|
* @see {@link isUnion}
|
|
2817
3541
|
* @category models
|
|
2818
|
-
* @since
|
|
3542
|
+
* @since 4.0.0
|
|
3543
|
+
*/
|
|
3544
|
+
export interface Union<A extends AST = AST> extends ASTNode {
|
|
3545
|
+
readonly _tag: "Union"
|
|
3546
|
+
readonly types: ReadonlyArray<A>
|
|
3547
|
+
readonly options: UnionOptions | undefined
|
|
3548
|
+
readonly encodingChecks: Checks | undefined
|
|
3549
|
+
/** @internal */
|
|
3550
|
+
|
|
3551
|
+
getParser(compile: SchemaParser.Compiler, compileConstructorDefault?: SchemaParser.Compiler): SchemaParser.Parser
|
|
3552
|
+
/** @internal */
|
|
3553
|
+
|
|
3554
|
+
recur(recur: (ast: AST) => AST): Union<AST>
|
|
3555
|
+
/** @internal */
|
|
3556
|
+
|
|
3557
|
+
flip(recur: (ast: AST) => AST): Union<AST>
|
|
3558
|
+
/** @internal */
|
|
3559
|
+
|
|
3560
|
+
matchPart(s: string, options: ParseOptions): LiteralValue | undefined
|
|
3561
|
+
/** @internal */
|
|
3562
|
+
|
|
3563
|
+
getExpected(getExpected: (ast: AST) => string): string
|
|
3564
|
+
}
|
|
3565
|
+
|
|
3566
|
+
/**
|
|
3567
|
+
* Local matching options stored on {@link Union} nodes.
|
|
3568
|
+
*
|
|
3569
|
+
* @category options
|
|
3570
|
+
* @since 4.0.0
|
|
3571
|
+
*/
|
|
3572
|
+
export interface UnionOptions {
|
|
3573
|
+
/** Defaults to `"anyOf"`; `"oneOf"` requires exactly one matching member. */
|
|
3574
|
+
readonly mode?: "anyOf" | "oneOf" | undefined
|
|
3575
|
+
}
|
|
3576
|
+
|
|
3577
|
+
/**
|
|
3578
|
+
* Constructs a {@link Union}.
|
|
3579
|
+
*
|
|
3580
|
+
* @category constructors
|
|
3581
|
+
* @since 4.0.0
|
|
2819
3582
|
*/
|
|
2820
|
-
export
|
|
3583
|
+
export const Union: new<A extends AST = AST>(
|
|
3584
|
+
types: ReadonlyArray<A>,
|
|
3585
|
+
options?: UnionOptions,
|
|
3586
|
+
annotations?: Schema.Annotations.Annotations,
|
|
3587
|
+
checks?: Checks,
|
|
3588
|
+
encoding?: Encoding,
|
|
3589
|
+
context?: Context,
|
|
3590
|
+
encodingChecks?: Checks
|
|
3591
|
+
) => Union<A> = class<A extends AST = AST> extends ASTNodeImpl {
|
|
2821
3592
|
readonly _tag = "Union"
|
|
2822
3593
|
readonly types: ReadonlyArray<A>
|
|
2823
|
-
readonly
|
|
3594
|
+
readonly options: UnionOptions | undefined
|
|
2824
3595
|
readonly encodingChecks: Checks | undefined
|
|
2825
3596
|
|
|
2826
3597
|
constructor(
|
|
2827
3598
|
types: ReadonlyArray<A>,
|
|
2828
|
-
|
|
3599
|
+
options?: UnionOptions,
|
|
2829
3600
|
annotations?: Schema.Annotations.Annotations,
|
|
2830
3601
|
checks?: Checks,
|
|
2831
3602
|
encoding?: Encoding,
|
|
@@ -2834,7 +3605,7 @@ export class Union<A extends AST = AST> extends Base {
|
|
|
2834
3605
|
) {
|
|
2835
3606
|
super(annotations, checks, encoding, context)
|
|
2836
3607
|
this.types = types
|
|
2837
|
-
this.
|
|
3608
|
+
this.options = options
|
|
2838
3609
|
this.encodingChecks = encodingChecks
|
|
2839
3610
|
}
|
|
2840
3611
|
/** @internal */
|
|
@@ -2851,6 +3622,9 @@ export class Union<A extends AST = AST> extends Base {
|
|
|
2851
3622
|
}
|
|
2852
3623
|
const candidates = getCandidates(input, ast.types, compileConstructorDefault !== undefined)
|
|
2853
3624
|
|
|
3625
|
+
if (candidates.length === 0) {
|
|
3626
|
+
return Effect.fail(new SchemaIssue.AnyOf(ast, [], input, options))
|
|
3627
|
+
}
|
|
2854
3628
|
if (candidates.length === 1) {
|
|
2855
3629
|
const result = compile(candidates[0])(input, options)
|
|
2856
3630
|
if ((result as Exit.Exit<unknown, SchemaIssue.Issue>)._tag === "Success") return result
|
|
@@ -2864,12 +3638,11 @@ export class Union<A extends AST = AST> extends Base {
|
|
|
2864
3638
|
compile,
|
|
2865
3639
|
input,
|
|
2866
3640
|
out: undefined,
|
|
2867
|
-
successes: ast.mode === "oneOf" ? [] : undefined,
|
|
3641
|
+
successes: ast.options?.mode === "oneOf" ? [] : undefined,
|
|
2868
3642
|
issues: undefined as Arr.NonEmptyArray<SchemaIssue.Issue> | undefined,
|
|
2869
3643
|
options
|
|
2870
3644
|
}
|
|
2871
|
-
const
|
|
2872
|
-
const eff = parseUnion(state, candidates, concurrency ? { ...concurrency, orderedStep: true } : undefined)
|
|
3645
|
+
const eff = parseUnion(state, candidates)
|
|
2873
3646
|
if (!eff) {
|
|
2874
3647
|
if (state.out) return state.out
|
|
2875
3648
|
return Effect.fail(new SchemaIssue.AnyOf(ast, state.issues ?? [], input, options))
|
|
@@ -2881,18 +3654,22 @@ export class Union<A extends AST = AST> extends Base {
|
|
|
2881
3654
|
})
|
|
2882
3655
|
}
|
|
2883
3656
|
}
|
|
2884
|
-
private _rebuild(
|
|
3657
|
+
private _rebuild(
|
|
3658
|
+
recur: (ast: AST) => AST,
|
|
3659
|
+
checks: Checks | undefined,
|
|
3660
|
+
encodingChecks: Checks | undefined
|
|
3661
|
+
): Union<AST> {
|
|
2885
3662
|
const types = mapOrSame(this.types, recur)
|
|
2886
3663
|
return types === this.types && checks === this.checks && encodingChecks === this.encodingChecks ?
|
|
2887
3664
|
this :
|
|
2888
|
-
new Union(types, this.
|
|
3665
|
+
new Union(types, this.options, this.annotations, checks, undefined, this.context, encodingChecks)
|
|
2889
3666
|
}
|
|
2890
3667
|
/** @internal */
|
|
2891
|
-
recur(recur: (ast: AST) => AST) {
|
|
3668
|
+
recur(recur: (ast: AST) => AST): Union<AST> {
|
|
2892
3669
|
return this._rebuild(recur, this.checks, this.encodingChecks)
|
|
2893
3670
|
}
|
|
2894
3671
|
/** @internal */
|
|
2895
|
-
flip(recur: (ast: AST) => AST) {
|
|
3672
|
+
flip(recur: (ast: AST) => AST): Union<AST> {
|
|
2896
3673
|
return this._rebuild(recur, this.encodingChecks, this.checks)
|
|
2897
3674
|
}
|
|
2898
3675
|
/** @internal */
|
|
@@ -2993,7 +3770,7 @@ const nonFiniteLiterals = new Union([
|
|
|
2993
3770
|
new Literal("Infinity"),
|
|
2994
3771
|
new Literal("-Infinity"),
|
|
2995
3772
|
new Literal("NaN")
|
|
2996
|
-
]
|
|
3773
|
+
])
|
|
2997
3774
|
|
|
2998
3775
|
function formatIsMutable(isMutable: boolean | undefined): string {
|
|
2999
3776
|
return isMutable ? "" : "readonly "
|
|
@@ -3046,9 +3823,35 @@ export function memoizeThunk<A>(f: () => A): () => A {
|
|
|
3046
3823
|
*
|
|
3047
3824
|
* @see {@link isSuspend}
|
|
3048
3825
|
* @category models
|
|
3049
|
-
* @since
|
|
3826
|
+
* @since 4.0.0
|
|
3827
|
+
*/
|
|
3828
|
+
export interface Suspend extends ASTNode {
|
|
3829
|
+
readonly _tag: "Suspend"
|
|
3830
|
+
readonly thunk: () => AST
|
|
3831
|
+
/** @internal */
|
|
3832
|
+
|
|
3833
|
+
getParser(compile: SchemaParser.Compiler): SchemaParser.Parser
|
|
3834
|
+
/** @internal */
|
|
3835
|
+
|
|
3836
|
+
recur(recur: (ast: AST) => AST): Suspend
|
|
3837
|
+
/** @internal */
|
|
3838
|
+
|
|
3839
|
+
getExpected(getExpected: (ast: AST) => string): string
|
|
3840
|
+
}
|
|
3841
|
+
|
|
3842
|
+
/**
|
|
3843
|
+
* Constructs a {@link Suspend}.
|
|
3844
|
+
*
|
|
3845
|
+
* @category constructors
|
|
3846
|
+
* @since 4.0.0
|
|
3050
3847
|
*/
|
|
3051
|
-
export
|
|
3848
|
+
export const Suspend: new(
|
|
3849
|
+
thunk: () => AST,
|
|
3850
|
+
annotations?: Schema.Annotations.Annotations,
|
|
3851
|
+
checks?: Checks,
|
|
3852
|
+
encoding?: Encoding,
|
|
3853
|
+
context?: Context
|
|
3854
|
+
) => Suspend = class extends ASTNodeImpl {
|
|
3052
3855
|
readonly _tag = "Suspend"
|
|
3053
3856
|
readonly thunk: () => AST
|
|
3054
3857
|
|
|
@@ -3111,7 +3914,32 @@ export class Suspend extends Base {
|
|
|
3111
3914
|
* @category models
|
|
3112
3915
|
* @since 4.0.0
|
|
3113
3916
|
*/
|
|
3114
|
-
export
|
|
3917
|
+
export interface Filter<in E> extends Pipeable.Pipeable {
|
|
3918
|
+
readonly _tag: "Filter"
|
|
3919
|
+
readonly run: (input: E, self: AST, options: ParseOptions) => SchemaIssue.Issue | undefined
|
|
3920
|
+
readonly annotations: Schema.Annotations.Filter | undefined
|
|
3921
|
+
/**
|
|
3922
|
+
* Whether the parsing process should be aborted after this check has failed.
|
|
3923
|
+
*/
|
|
3924
|
+
readonly aborted: boolean
|
|
3925
|
+
annotate(annotations: Schema.Annotations.Filter): Filter<E>
|
|
3926
|
+
abort(): Filter<E>
|
|
3927
|
+
and(other: Check<E>, annotations?: Schema.Annotations.Filter): FilterGroup<E>
|
|
3928
|
+
}
|
|
3929
|
+
|
|
3930
|
+
/**
|
|
3931
|
+
* Constructs a {@link Filter}.
|
|
3932
|
+
*
|
|
3933
|
+
* @category constructors
|
|
3934
|
+
* @since 4.0.0
|
|
3935
|
+
*/
|
|
3936
|
+
export const Filter: new<E>(
|
|
3937
|
+
run: (input: E, self: AST, options: ParseOptions) => SchemaIssue.Issue | undefined,
|
|
3938
|
+
annotations?: Schema.Annotations.Filter | undefined, /**
|
|
3939
|
+
* Whether the parsing process should be aborted after this check has failed.
|
|
3940
|
+
*/
|
|
3941
|
+
aborted?: boolean
|
|
3942
|
+
) => Filter<E> = class<in E> extends Pipeable.Class {
|
|
3115
3943
|
readonly _tag = "Filter"
|
|
3116
3944
|
readonly run: (input: E, self: AST, options: ParseOptions) => SchemaIssue.Issue | undefined
|
|
3117
3945
|
readonly annotations: Schema.Annotations.Filter | undefined
|
|
@@ -3159,7 +3987,30 @@ export class Filter<in E> extends Pipeable.Class {
|
|
|
3159
3987
|
* @category models
|
|
3160
3988
|
* @since 4.0.0
|
|
3161
3989
|
*/
|
|
3162
|
-
export
|
|
3990
|
+
export interface FilterGroup<in E> extends Pipeable.Pipeable {
|
|
3991
|
+
readonly _tag: "FilterGroup"
|
|
3992
|
+
readonly checks: readonly [
|
|
3993
|
+
Check<E>,
|
|
3994
|
+
...Array<Check<E>>
|
|
3995
|
+
]
|
|
3996
|
+
readonly annotations: Schema.Annotations.Filter | undefined
|
|
3997
|
+
annotate(annotations: Schema.Annotations.Filter): FilterGroup<E>
|
|
3998
|
+
and(other: Check<E>, annotations?: Schema.Annotations.Filter): FilterGroup<E>
|
|
3999
|
+
}
|
|
4000
|
+
|
|
4001
|
+
/**
|
|
4002
|
+
* Constructs a {@link FilterGroup}.
|
|
4003
|
+
*
|
|
4004
|
+
* @category constructors
|
|
4005
|
+
* @since 4.0.0
|
|
4006
|
+
*/
|
|
4007
|
+
export const FilterGroup: new<E>(
|
|
4008
|
+
checks: readonly [
|
|
4009
|
+
Check<E>,
|
|
4010
|
+
...Array<Check<E>>
|
|
4011
|
+
],
|
|
4012
|
+
annotations?: Schema.Annotations.Filter | undefined
|
|
4013
|
+
) => FilterGroup<E> = class<in E> extends Pipeable.Class {
|
|
3163
4014
|
readonly _tag = "FilterGroup"
|
|
3164
4015
|
readonly checks: readonly [Check<E>, ...Array<Check<E>>]
|
|
3165
4016
|
readonly annotations: Schema.Annotations.Filter | undefined
|
|
@@ -3187,7 +4038,7 @@ export class FilterGroup<in E> extends Pipeable.Class {
|
|
|
3187
4038
|
*
|
|
3188
4039
|
* **Details**
|
|
3189
4040
|
*
|
|
3190
|
-
* Stored in
|
|
4041
|
+
* Stored in an AST node's {@link Checks} array.
|
|
3191
4042
|
*
|
|
3192
4043
|
* @see {@link Filter}
|
|
3193
4044
|
* @see {@link FilterGroup}
|
|
@@ -3233,11 +4084,8 @@ export function isFinite(annotations?: Schema.Annotations.Filter) {
|
|
|
3233
4084
|
},
|
|
3234
4085
|
toJsonSchema: () => ({ type: "number" }),
|
|
3235
4086
|
toCode: () => ({ runtime: "Schema.isFinite()" }),
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
noInfinity: true,
|
|
3239
|
-
noNaN: true
|
|
3240
|
-
}
|
|
4087
|
+
arbitraryConstraint: {
|
|
4088
|
+
number: "finite"
|
|
3241
4089
|
},
|
|
3242
4090
|
...annotations
|
|
3243
4091
|
}
|
|
@@ -3248,7 +4096,7 @@ export function isFinite(annotations?: Schema.Annotations.Filter) {
|
|
|
3248
4096
|
export const finite = appendChecks(number, [isFinite()])
|
|
3249
4097
|
|
|
3250
4098
|
const numberToJson = new Link(
|
|
3251
|
-
new Union([finite, nonFiniteLiterals]
|
|
4099
|
+
new Union([finite, nonFiniteLiterals]),
|
|
3252
4100
|
new SchemaTransformation.Transformation(
|
|
3253
4101
|
SchemaGetter.Number(),
|
|
3254
4102
|
SchemaGetter.transform((n) => globalThis.Number.isFinite(n) ? n : globalThis.String(n))
|
|
@@ -3274,8 +4122,12 @@ const numberToJson = new Link(
|
|
|
3274
4122
|
*
|
|
3275
4123
|
* **Gotchas**
|
|
3276
4124
|
*
|
|
3277
|
-
*
|
|
3278
|
-
* flags
|
|
4125
|
+
* Arbitrary metadata preserves both `regExp.source` and `regExp.flags`.
|
|
4126
|
+
* Implementations that cannot consume all flags may still use the source as a
|
|
4127
|
+
* generation hint because the Schema filter validates every generated value.
|
|
4128
|
+
* JSON Schema has no way to carry JavaScript regular-expression flags. The
|
|
4129
|
+
* generated `pattern` contains the source only, so validation can differ when
|
|
4130
|
+
* the RegExp uses flags or relies on JavaScript's non-Unicode behavior.
|
|
3279
4131
|
*
|
|
3280
4132
|
* **Example** (Validating an email pattern)
|
|
3281
4133
|
*
|
|
@@ -3306,10 +4158,8 @@ export function isPattern(regExp: globalThis.RegExp, annotations?: Schema.Annota
|
|
|
3306
4158
|
payload: { source, flags: regExp.flags }
|
|
3307
4159
|
},
|
|
3308
4160
|
toJsonSchema: () => ({ pattern: source }),
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
patterns: [regExp.source]
|
|
3312
|
-
}
|
|
4161
|
+
arbitraryConstraint: {
|
|
4162
|
+
patterns: [{ source: regExp.source, flags: regExp.flags }]
|
|
3313
4163
|
},
|
|
3314
4164
|
...annotations
|
|
3315
4165
|
}
|
|
@@ -3521,7 +4371,7 @@ const optionalKeyLastLink = applyToLastLink(optionalKey)
|
|
|
3521
4371
|
|
|
3522
4372
|
/** @internal */
|
|
3523
4373
|
export const optional = memoize(<A extends AST>(ast: A): Union<A | Undefined> =>
|
|
3524
|
-
optionalKey(new Union([ast, undefined_]
|
|
4374
|
+
optionalKey(new Union([ast, undefined_]))
|
|
3525
4375
|
)
|
|
3526
4376
|
|
|
3527
4377
|
/** @internal */
|
|
@@ -3558,9 +4408,8 @@ export function withConstructorDefault<A extends AST>(
|
|
|
3558
4408
|
*
|
|
3559
4409
|
* **Details**
|
|
3560
4410
|
*
|
|
3561
|
-
* This is the low-level primitive behind `Schema.
|
|
3562
|
-
*
|
|
3563
|
-
* encoding chain.
|
|
4411
|
+
* This is the low-level primitive behind `Schema.decodeTo`. It appends a
|
|
4412
|
+
* {@link Link} to the `to` node's encoding chain.
|
|
3564
4413
|
*
|
|
3565
4414
|
* - Returns a new AST with the same type as `to`.
|
|
3566
4415
|
*
|
|
@@ -3630,7 +4479,7 @@ export function record(key: AST, value: AST): Objects {
|
|
|
3630
4479
|
* Checks `ast.context?.isOptional`. Defaults to `false` when no
|
|
3631
4480
|
* {@link Context} is set.
|
|
3632
4481
|
*
|
|
3633
|
-
* @see
|
|
4482
|
+
* @see `Schema.optionalKey`
|
|
3634
4483
|
* @see {@link Context}
|
|
3635
4484
|
* @category predicates
|
|
3636
4485
|
* @since 4.0.0
|
|
@@ -3793,7 +4642,7 @@ function fromConst<const T>(
|
|
|
3793
4642
|
ast: AST,
|
|
3794
4643
|
value: T
|
|
3795
4644
|
): SchemaParser.Parser {
|
|
3796
|
-
const succeed = InternalParser.succeed(value)
|
|
4645
|
+
const succeed = value === 0 ? InternalParser.sameExit : InternalParser.succeed(value)
|
|
3797
4646
|
return (input, options) => {
|
|
3798
4647
|
if (input === InternalParser.missing) return InternalParser.missingExit
|
|
3799
4648
|
if (input === value) return succeed
|
|
@@ -3866,14 +4715,6 @@ function segmentTemplateLiteralParts(
|
|
|
3866
4715
|
return go(0, 0) ? out : undefined
|
|
3867
4716
|
}
|
|
3868
4717
|
|
|
3869
|
-
/** @internal */
|
|
3870
|
-
export const enumsToLiterals = memoize((ast: Enum): Union<Literal> => {
|
|
3871
|
-
return new Union(
|
|
3872
|
-
ast.enums.map((e) => new Literal(e[1], { title: e[0] })),
|
|
3873
|
-
"anyOf"
|
|
3874
|
-
)
|
|
3875
|
-
})
|
|
3876
|
-
|
|
3877
4718
|
const parameterFromPropertyKey = applyToSelfOrLastLinkEncodingIdempotent((ast) => {
|
|
3878
4719
|
switch (ast._tag) {
|
|
3879
4720
|
default:
|
|
@@ -3945,7 +4786,7 @@ const finiteToString = new Link(
|
|
|
3945
4786
|
)
|
|
3946
4787
|
|
|
3947
4788
|
const numberToString = new Link(
|
|
3948
|
-
new Union([finiteString, nonFiniteLiterals]
|
|
4789
|
+
new Union([finiteString, nonFiniteLiterals]),
|
|
3949
4790
|
SchemaTransformation.numberFromString
|
|
3950
4791
|
)
|
|
3951
4792
|
|
|
@@ -3982,7 +4823,7 @@ const bigIntToString = new Link(
|
|
|
3982
4823
|
SchemaTransformation.bigintFromString
|
|
3983
4824
|
)
|
|
3984
4825
|
|
|
3985
|
-
const REGEXP_PATTERN = "Symbol\\((
|
|
4826
|
+
const REGEXP_PATTERN = "Symbol\\(([\\s\\S]*)\\)"
|
|
3986
4827
|
|
|
3987
4828
|
const isStringSymbolRegExp = new globalThis.RegExp(`^${REGEXP_PATTERN}$`)
|
|
3988
4829
|
|
|
@@ -3996,7 +4837,7 @@ const symbolToString = new Link(
|
|
|
3996
4837
|
symbolString,
|
|
3997
4838
|
new SchemaTransformation.Transformation(
|
|
3998
4839
|
SchemaGetter.transform((description) => globalThis.Symbol.for(isStringSymbolRegExp.exec(description)![1])),
|
|
3999
|
-
SchemaGetter.
|
|
4840
|
+
SchemaGetter.transformEffect((sym: symbol, options) => {
|
|
4000
4841
|
const key = globalThis.Symbol.keyFor(sym)
|
|
4001
4842
|
if (key !== undefined) {
|
|
4002
4843
|
return Effect.succeed(globalThis.String(sym))
|
|
@@ -4094,7 +4935,7 @@ export function getConstructorDescriptor(ast: AST): ConstructorDescriptor | unde
|
|
|
4094
4935
|
*
|
|
4095
4936
|
* If the node has {@link Checks}, returns annotations from the last check
|
|
4096
4937
|
* (which is where user-supplied annotations end up after `.pipe(Schema.annotations(...))`).
|
|
4097
|
-
* Otherwise returns `
|
|
4938
|
+
* Otherwise returns the node's `annotations` directly.
|
|
4098
4939
|
*
|
|
4099
4940
|
* **Example** (Reading annotations)
|
|
4100
4941
|
*
|
|
@@ -4269,8 +5110,7 @@ export const Json = new Declaration(
|
|
|
4269
5110
|
},
|
|
4270
5111
|
expected: "JSON value",
|
|
4271
5112
|
toCodecJson: () => undefined,
|
|
4272
|
-
toCodecStringTree: () => unknownToStringTree
|
|
4273
|
-
toArbitrary: () => (fc: typeof FastCheck) => fc.jsonValue()
|
|
5113
|
+
toCodecStringTree: () => unknownToStringTree
|
|
4274
5114
|
}
|
|
4275
5115
|
)
|
|
4276
5116
|
|
|
@@ -4293,7 +5133,7 @@ export const objectKeywordToJson = new Link(
|
|
|
4293
5133
|
new Union([
|
|
4294
5134
|
new Arrays(false, [], [Json]),
|
|
4295
5135
|
new Objects([], [new IndexSignature(string, Json)])
|
|
4296
|
-
]
|
|
5136
|
+
]),
|
|
4297
5137
|
SchemaTransformation.passthrough()
|
|
4298
5138
|
)
|
|
4299
5139
|
|