effect 4.0.0-rc.112 → 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 +86 -50
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +58 -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 +66 -39
- 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 +33 -15
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +58 -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.js +8 -22
- 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 +1 -3
- package/dist/LayerMap.d.ts.map +1 -1
- package/dist/LayerMap.js +7 -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 +38 -1
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +81 -5
- 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.map +1 -1
- package/dist/RcMap.js +15 -9
- package/dist/RcMap.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 +2155 -2415
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +2755 -4174
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +354 -183
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +277 -601
- 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 +122 -188
- package/dist/SchemaIssue.d.ts.map +1 -1
- package/dist/SchemaIssue.js +48 -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 +1099 -16
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +1341 -20
- 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/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/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 +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -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 +386 -251
- 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 +14 -12
- 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 +74 -23
- package/dist/unstable/ai/AiError.d.ts.map +1 -1
- package/dist/unstable/ai/AiError.js +59 -5
- package/dist/unstable/ai/AiError.js.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.js +2 -1
- 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 +21 -12
- package/dist/unstable/ai/McpServer.js.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js +2 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Prompt.d.ts +1 -1
- 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/structured-output.js +8 -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 +26 -3
- package/dist/unstable/cli/CliOutput.js.map +1 -1
- package/dist/unstable/cli/Command.d.ts +73 -73
- package/dist/unstable/cli/Command.js +18 -18
- 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 +23 -24
- package/dist/unstable/cli/Prompt.d.ts.map +1 -1
- package/dist/unstable/cli/Prompt.js +68 -63
- package/dist/unstable/cli/Prompt.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/zsh.js +2 -2
- 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.map +1 -1
- package/dist/unstable/cli/internal/wizard.js +14 -13
- 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 +4 -4
- package/dist/unstable/cluster/Envelope.d.ts.map +1 -1
- package/dist/unstable/cluster/Envelope.js +2 -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 +5 -2
- package/dist/unstable/cluster/HttpRunner.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 +28 -9
- package/dist/unstable/cluster/MessageStorage.js.map +1 -1
- package/dist/unstable/cluster/Reply.d.ts +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 +7 -4
- 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 +27 -3
- package/dist/unstable/encoding/SchemaBinary.d.ts.map +1 -1
- package/dist/unstable/encoding/SchemaBinary.js +108 -39
- package/dist/unstable/encoding/SchemaBinary.js.map +1 -1
- 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 +0 -4
- package/dist/unstable/encoding/index.d.ts.map +1 -1
- package/dist/unstable/encoding/index.js +0 -4
- 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 +7 -7
- package/dist/unstable/eventlog/EventJournal.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventJournal.js +9 -9
- 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 +4 -4
- 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.map +1 -1
- package/dist/unstable/eventlog/SqlEventJournal.js +26 -13
- 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 +23 -6
- 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/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/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.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +64 -64
- 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 +3 -1
- package/dist/unstable/rpc/RpcMessage.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMessage.js +1 -1
- 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 +5 -39
- package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.js +22 -115
- package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +104 -57
- 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/package.json +7 -9
- package/src/Array.ts +118 -67
- 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 +183 -48
- 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 +66 -41
- package/src/JsonPatch.ts +4 -4
- package/src/JsonPointer.ts +97 -4
- package/src/JsonSchema.ts +8 -26
- package/src/Layer.ts +59 -18
- package/src/LayerMap.ts +8 -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 +125 -8
- 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 +20 -13
- 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 +4809 -6368
- package/src/SchemaAST.ts +1031 -284
- package/src/SchemaGetter.ts +75 -21
- package/src/SchemaIssue.ts +259 -15
- package/src/SchemaParser.ts +2 -12
- package/src/SchemaRepresentation.ts +1593 -29
- package/src/SchemaTransformation.ts +145 -22
- package/src/ScopedCache.ts +10 -3
- package/src/Sink.ts +31 -15
- 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 +5 -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 +475 -295
- 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 +14 -29
- 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 +69 -5
- package/src/unstable/ai/AnthropicStructuredOutput.ts +4 -1
- 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 +36 -20
- package/src/unstable/ai/OpenAiStructuredOutput.ts +4 -1
- package/src/unstable/ai/Prompt.ts +19 -4
- 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/structured-output.ts +5 -5
- 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 +40 -3
- package/src/unstable/cli/Command.ts +74 -74
- 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 +88 -87
- package/src/unstable/cli/internal/completions/descriptor.ts +23 -11
- package/src/unstable/cli/internal/completions/zsh.ts +2 -2
- 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 +18 -13
- 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 +3 -3
- package/src/unstable/cluster/HttpRunner.ts +7 -2
- package/src/unstable/cluster/MessageStorage.ts +62 -21
- package/src/unstable/cluster/Reply.ts +2 -2
- 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 +12 -4
- 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 +150 -44
- 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 +0 -5
- package/src/unstable/eventlog/Event.ts +7 -7
- package/src/unstable/eventlog/EventJournal.ts +9 -9
- package/src/unstable/eventlog/EventLog.ts +5 -5
- 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 +32 -9
- 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 +52 -6
- 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/HttpApiSchema.ts +14 -7
- 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 +62 -59
- package/src/unstable/rpc/RpcMessage.ts +3 -1
- package/src/unstable/rpc/RpcMiddleware.ts +7 -5
- package/src/unstable/rpc/RpcSerialization.ts +27 -117
- package/src/unstable/rpc/RpcServer.ts +143 -80
- 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/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
|
-
*
|
|
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.
|
|
504
534
|
*
|
|
505
|
-
* @default
|
|
535
|
+
* @default undefined
|
|
506
536
|
*/
|
|
507
|
-
readonly
|
|
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.
|
|
517
|
-
*
|
|
518
|
-
* @default 1
|
|
519
|
-
*/
|
|
520
|
-
readonly concurrency?: number | "unbounded" | undefined
|
|
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,15 +681,9 @@ export abstract class Base {
|
|
|
657
681
|
}
|
|
658
682
|
}
|
|
659
683
|
|
|
660
|
-
|
|
661
|
-
* Parser factory carried by a {@link Declaration}.
|
|
662
|
-
*
|
|
663
|
-
* @category models
|
|
664
|
-
* @since 4.0.0
|
|
665
|
-
*/
|
|
666
|
-
export type DeclarationRun = (
|
|
684
|
+
type DeclarationRun = (
|
|
667
685
|
typeParameters: ReadonlyArray<AST>
|
|
668
|
-
) => (input: unknown, self: Declaration, options: ParseOptions) => Effect.Effect<any, SchemaIssue.Issue
|
|
686
|
+
) => (input: unknown, self: Declaration, options: ParseOptions) => Effect.Effect<any, SchemaIssue.Issue>
|
|
669
687
|
|
|
670
688
|
/**
|
|
671
689
|
* AST node for user-defined opaque types with custom parsing logic.
|
|
@@ -680,20 +698,60 @@ export type DeclarationRun = (
|
|
|
680
698
|
* - `typeParameters` — inner schemas this declaration is parameterized over
|
|
681
699
|
* (e.g. the element type for a custom collection).
|
|
682
700
|
* - `run` — factory that receives `typeParameters` and returns a parser that
|
|
683
|
-
* validates or transforms raw input.
|
|
701
|
+
* validates or transforms raw input. The `Effect` returned by the parser must
|
|
702
|
+
* complete synchronously.
|
|
684
703
|
*
|
|
685
704
|
* @see {@link isDeclaration}
|
|
686
705
|
* @category models
|
|
687
|
-
* @since
|
|
706
|
+
* @since 4.0.0
|
|
707
|
+
*/
|
|
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
|
|
688
737
|
*/
|
|
689
|
-
export
|
|
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 {
|
|
690
748
|
readonly _tag = "Declaration"
|
|
691
749
|
readonly typeParameters: ReadonlyArray<AST>
|
|
692
750
|
readonly run: DeclarationRun
|
|
693
751
|
readonly encodingChecks: Checks | undefined
|
|
694
752
|
/**
|
|
695
753
|
* Parser factory {@link flip} swaps in, so a declaration can behave
|
|
696
|
-
* differently when encoding. `undefined` reuses
|
|
754
|
+
* differently when encoding. `undefined` reuses `run`.
|
|
697
755
|
*/
|
|
698
756
|
readonly encodingRun: DeclarationRun | undefined
|
|
699
757
|
|
|
@@ -762,7 +820,28 @@ export class Declaration extends Base {
|
|
|
762
820
|
* @category models
|
|
763
821
|
* @since 4.0.0
|
|
764
822
|
*/
|
|
765
|
-
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 {
|
|
766
845
|
readonly _tag = "Null"
|
|
767
846
|
/** @internal */
|
|
768
847
|
getParser() {
|
|
@@ -802,7 +881,31 @@ export {
|
|
|
802
881
|
* @category models
|
|
803
882
|
* @since 4.0.0
|
|
804
883
|
*/
|
|
805
|
-
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 {
|
|
806
909
|
readonly _tag = "Undefined"
|
|
807
910
|
/** @internal */
|
|
808
911
|
getParser() {
|
|
@@ -862,7 +965,33 @@ export {
|
|
|
862
965
|
* @category models
|
|
863
966
|
* @since 4.0.0
|
|
864
967
|
*/
|
|
865
|
-
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 {
|
|
866
995
|
readonly _tag = "Void"
|
|
867
996
|
/** @internal */
|
|
868
997
|
getParser() {
|
|
@@ -917,7 +1046,28 @@ export {
|
|
|
917
1046
|
* @category models
|
|
918
1047
|
* @since 4.0.0
|
|
919
1048
|
*/
|
|
920
|
-
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 {
|
|
921
1071
|
readonly _tag = "Never"
|
|
922
1072
|
/** @internal */
|
|
923
1073
|
getParser() {
|
|
@@ -954,7 +1104,28 @@ export const never = new Never()
|
|
|
954
1104
|
* @category models
|
|
955
1105
|
* @since 4.0.0
|
|
956
1106
|
*/
|
|
957
|
-
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 {
|
|
958
1129
|
readonly _tag = "Any"
|
|
959
1130
|
/** @internal */
|
|
960
1131
|
getParser() {
|
|
@@ -994,7 +1165,28 @@ export const any = new Any()
|
|
|
994
1165
|
* @category models
|
|
995
1166
|
* @since 4.0.0
|
|
996
1167
|
*/
|
|
997
|
-
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 {
|
|
998
1190
|
readonly _tag = "Unknown"
|
|
999
1191
|
/** @internal */
|
|
1000
1192
|
getParser() {
|
|
@@ -1029,9 +1221,30 @@ export const unknown = new Unknown()
|
|
|
1029
1221
|
* @see {@link isObjectKeyword}
|
|
1030
1222
|
*
|
|
1031
1223
|
* @category models
|
|
1032
|
-
* @since
|
|
1224
|
+
* @since 4.0.0
|
|
1225
|
+
*/
|
|
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
|
|
1033
1241
|
*/
|
|
1034
|
-
export
|
|
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 {
|
|
1035
1248
|
readonly _tag = "ObjectKeyword"
|
|
1036
1249
|
/** @internal */
|
|
1037
1250
|
getParser() {
|
|
@@ -1071,7 +1284,43 @@ export const objectKeyword = new ObjectKeyword()
|
|
|
1071
1284
|
* @category models
|
|
1072
1285
|
* @since 4.0.0
|
|
1073
1286
|
*/
|
|
1074
|
-
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 {
|
|
1075
1324
|
readonly _tag = "Enum"
|
|
1076
1325
|
readonly enums: ReadonlyArray<readonly [string, string | number]>
|
|
1077
1326
|
|
|
@@ -1083,6 +1332,11 @@ export class Enum extends Base {
|
|
|
1083
1332
|
context?: Context
|
|
1084
1333
|
) {
|
|
1085
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
|
+
}
|
|
1086
1340
|
this.enums = enums
|
|
1087
1341
|
}
|
|
1088
1342
|
/** @internal */
|
|
@@ -1099,7 +1353,7 @@ export class Enum extends Base {
|
|
|
1099
1353
|
const coercions = Object.fromEntries(this.enums.map(([_, v]) => [globalThis.String(v), v]))
|
|
1100
1354
|
return replaceEncoding(this, [
|
|
1101
1355
|
new Link(
|
|
1102
|
-
new Union(Object.keys(coercions).map((k) => new Literal(k))
|
|
1356
|
+
new Union(Object.keys(coercions).map((k) => new Literal(k))),
|
|
1103
1357
|
new SchemaTransformation.Transformation(
|
|
1104
1358
|
SchemaGetter.transform((s) => coercions[s]),
|
|
1105
1359
|
SchemaGetter.String()
|
|
@@ -1123,20 +1377,34 @@ type TemplateLiteralPart =
|
|
|
1123
1377
|
| TemplateLiteral
|
|
1124
1378
|
| Union<TemplateLiteralPart>
|
|
1125
1379
|
|
|
1126
|
-
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
|
|
1127
1386
|
switch (ast._tag) {
|
|
1128
1387
|
case "String":
|
|
1129
1388
|
case "Number":
|
|
1130
1389
|
case "BigInt":
|
|
1131
|
-
|
|
1390
|
+
valid = true
|
|
1391
|
+
break
|
|
1132
1392
|
case "Literal":
|
|
1393
|
+
valid = !ast.checks
|
|
1394
|
+
break
|
|
1133
1395
|
case "TemplateLiteral":
|
|
1134
|
-
|
|
1396
|
+
valid = !ast.checks &&
|
|
1397
|
+
ast.parts.every((part, index) => isTemplateLiteralPart(part, `${path}.parts[${index}]`, validated))
|
|
1398
|
+
break
|
|
1135
1399
|
case "Union":
|
|
1136
|
-
|
|
1400
|
+
valid = !ast.checks &&
|
|
1401
|
+
ast.types.every((part, index) => isTemplateLiteralPart(part, `${path}.types[${index}]`, validated))
|
|
1402
|
+
break
|
|
1137
1403
|
default:
|
|
1138
1404
|
return false
|
|
1139
1405
|
}
|
|
1406
|
+
if (valid) validated.add(ast)
|
|
1407
|
+
return valid
|
|
1140
1408
|
}
|
|
1141
1409
|
|
|
1142
1410
|
/**
|
|
@@ -1150,9 +1418,46 @@ function isTemplateLiteralPart(ast: AST): ast is TemplateLiteralPart {
|
|
|
1150
1418
|
*
|
|
1151
1419
|
* @see {@link isTemplateLiteral}
|
|
1152
1420
|
* @category models
|
|
1153
|
-
* @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
|
|
1154
1453
|
*/
|
|
1155
|
-
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 {
|
|
1156
1461
|
readonly _tag = "TemplateLiteral"
|
|
1157
1462
|
readonly parts: ReadonlyArray<AST>
|
|
1158
1463
|
/** @internal */
|
|
@@ -1172,14 +1477,14 @@ export class TemplateLiteral extends Base {
|
|
|
1172
1477
|
super(annotations, checks, encoding, context)
|
|
1173
1478
|
const encodedParts: Array<TemplateLiteralPart> = []
|
|
1174
1479
|
const literals: Array<string | undefined> = []
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
} else {
|
|
1181
|
-
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}`)
|
|
1182
1485
|
}
|
|
1486
|
+
encodedParts.push(part)
|
|
1487
|
+
literals.push(part._tag === "Literal" ? globalThis.String(part.literal) : undefined)
|
|
1183
1488
|
}
|
|
1184
1489
|
const suffixLengths = new Array<number>(encodedParts.length + 1)
|
|
1185
1490
|
suffixLengths[encodedParts.length] = 0
|
|
@@ -1193,7 +1498,8 @@ export class TemplateLiteral extends Base {
|
|
|
1193
1498
|
}
|
|
1194
1499
|
/** @internal */
|
|
1195
1500
|
getParser(compile: SchemaParser.Compiler): SchemaParser.Parser {
|
|
1196
|
-
const
|
|
1501
|
+
const tuple = new Arrays(false, this.parts.map(partFromString), [])
|
|
1502
|
+
const parser = compile(decodeTo(string, tuple, templateLiteralTransformation(this)))
|
|
1197
1503
|
return (input, options) => {
|
|
1198
1504
|
if (input === InternalParser.missing) return InternalParser.missingExit
|
|
1199
1505
|
const result = parser(input, options)
|
|
@@ -1214,28 +1520,46 @@ export class TemplateLiteral extends Base {
|
|
|
1214
1520
|
matchPart(s: string, options: ParseOptions): string | undefined {
|
|
1215
1521
|
return segmentTemplateLiteralParts(this, s, options) === undefined ? undefined : s
|
|
1216
1522
|
}
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
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
|
|
1236
1541
|
)
|
|
1237
|
-
|
|
1238
|
-
|
|
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
|
+
)
|
|
1239
1563
|
}
|
|
1240
1564
|
|
|
1241
1565
|
/**
|
|
@@ -1248,9 +1572,35 @@ export class TemplateLiteral extends Base {
|
|
|
1248
1572
|
*
|
|
1249
1573
|
* @see {@link isUniqueSymbol}
|
|
1250
1574
|
* @category models
|
|
1251
|
-
* @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
|
|
1252
1596
|
*/
|
|
1253
|
-
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 {
|
|
1254
1604
|
readonly _tag = "UniqueSymbol"
|
|
1255
1605
|
readonly symbol: symbol
|
|
1256
1606
|
|
|
@@ -1270,7 +1620,13 @@ export class UniqueSymbol extends Base {
|
|
|
1270
1620
|
}
|
|
1271
1621
|
/** @internal */
|
|
1272
1622
|
toCodecStringTree(): AST {
|
|
1273
|
-
|
|
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
|
+
])
|
|
1274
1630
|
}
|
|
1275
1631
|
/** @internal */
|
|
1276
1632
|
getExpected(): string {
|
|
@@ -1295,8 +1651,10 @@ export type LiteralValue = string | number | boolean | bigint
|
|
|
1295
1651
|
* **Details**
|
|
1296
1652
|
*
|
|
1297
1653
|
* Parsing succeeds only when the input is strictly equal (`===`) to the
|
|
1298
|
-
* stored `literal
|
|
1299
|
-
* 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.
|
|
1300
1658
|
*
|
|
1301
1659
|
* **Example** (Creating a literal AST)
|
|
1302
1660
|
*
|
|
@@ -1307,12 +1665,44 @@ export type LiteralValue = string | number | boolean | bigint
|
|
|
1307
1665
|
* ast.literal // => "active"
|
|
1308
1666
|
* ```
|
|
1309
1667
|
*
|
|
1310
|
-
* @see {@link LiteralValue}
|
|
1311
|
-
* @see {@link isLiteral}
|
|
1312
|
-
* @category models
|
|
1313
|
-
* @since
|
|
1668
|
+
* @see {@link LiteralValue}
|
|
1669
|
+
* @see {@link isLiteral}
|
|
1670
|
+
* @category models
|
|
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
|
|
1314
1698
|
*/
|
|
1315
|
-
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 {
|
|
1316
1706
|
readonly _tag = "Literal"
|
|
1317
1707
|
readonly literal: LiteralValue
|
|
1318
1708
|
|
|
@@ -1373,7 +1763,31 @@ function literalToString(ast: Literal): Literal {
|
|
|
1373
1763
|
* @category models
|
|
1374
1764
|
* @since 4.0.0
|
|
1375
1765
|
*/
|
|
1376
|
-
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 {
|
|
1377
1791
|
readonly _tag = "String"
|
|
1378
1792
|
/** @internal */
|
|
1379
1793
|
getParser() {
|
|
@@ -1424,7 +1838,40 @@ export const string = new String()
|
|
|
1424
1838
|
* @category models
|
|
1425
1839
|
* @since 4.0.0
|
|
1426
1840
|
*/
|
|
1427
|
-
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 {
|
|
1428
1875
|
readonly _tag = "Number"
|
|
1429
1876
|
/** @internal */
|
|
1430
1877
|
getParser() {
|
|
@@ -1499,7 +1946,28 @@ export const number = new Number()
|
|
|
1499
1946
|
* @category models
|
|
1500
1947
|
* @since 4.0.0
|
|
1501
1948
|
*/
|
|
1502
|
-
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 {
|
|
1503
1971
|
readonly _tag = "Boolean"
|
|
1504
1972
|
/** @internal */
|
|
1505
1973
|
getParser() {
|
|
@@ -1545,7 +2013,34 @@ export const boolean = new Boolean()
|
|
|
1545
2013
|
* @category models
|
|
1546
2014
|
* @since 4.0.0
|
|
1547
2015
|
*/
|
|
1548
|
-
export
|
|
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
|
|
2036
|
+
* @since 4.0.0
|
|
2037
|
+
*/
|
|
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 {
|
|
1549
2044
|
readonly _tag = "Symbol"
|
|
1550
2045
|
/** @internal */
|
|
1551
2046
|
getParser() {
|
|
@@ -1599,7 +2094,34 @@ export const symbol = new Symbol()
|
|
|
1599
2094
|
* @category models
|
|
1600
2095
|
* @since 4.0.0
|
|
1601
2096
|
*/
|
|
1602
|
-
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 {
|
|
1603
2125
|
readonly _tag = "BigInt"
|
|
1604
2126
|
/** @internal */
|
|
1605
2127
|
getParser() {
|
|
@@ -1649,7 +2171,7 @@ export const bigInt = new BigInt()
|
|
|
1649
2171
|
* **Details**
|
|
1650
2172
|
*
|
|
1651
2173
|
* - `elements` — positional element types (tuple elements). An element is
|
|
1652
|
-
* optional if its
|
|
2174
|
+
* optional if its context's `isOptional` field is `true`.
|
|
1653
2175
|
* - `rest` — the rest/variadic element types. When non-empty, the first
|
|
1654
2176
|
* entry is the "spread" type (e.g. `...Array<string>`), and subsequent
|
|
1655
2177
|
* entries are trailing positional elements after the spread.
|
|
@@ -1680,7 +2202,42 @@ export const bigInt = new BigInt()
|
|
|
1680
2202
|
* @category models
|
|
1681
2203
|
* @since 4.0.0
|
|
1682
2204
|
*/
|
|
1683
|
-
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 {
|
|
1684
2241
|
readonly _tag = "Arrays"
|
|
1685
2242
|
readonly isMutable: boolean
|
|
1686
2243
|
readonly elements: ReadonlyArray<AST>
|
|
@@ -1772,11 +2329,11 @@ export class Arrays extends Base {
|
|
|
1772
2329
|
issues: undefined as Arr.NonEmptyArray<SchemaIssue.Issue> | undefined,
|
|
1773
2330
|
options
|
|
1774
2331
|
}
|
|
1775
|
-
const
|
|
1776
|
-
const
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
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 })
|
|
1780
2337
|
if (eff) yield* eff
|
|
1781
2338
|
|
|
1782
2339
|
// ---------------------------------------------
|
|
@@ -1834,7 +2391,7 @@ export class Arrays extends Base {
|
|
|
1834
2391
|
return "array"
|
|
1835
2392
|
}
|
|
1836
2393
|
}
|
|
1837
|
-
|
|
2394
|
+
type ArrayParserState = {
|
|
1838
2395
|
readonly ast: AST
|
|
1839
2396
|
readonly input: unknown
|
|
1840
2397
|
readonly len: number
|
|
@@ -1846,12 +2403,14 @@ const parseArray = iterateEager<{
|
|
|
1846
2403
|
readonly options: ParseOptions
|
|
1847
2404
|
readonly output: Array<unknown>
|
|
1848
2405
|
issues: Array<SchemaIssue.Issue> | undefined
|
|
1849
|
-
}
|
|
1850
|
-
|
|
2406
|
+
}
|
|
2407
|
+
|
|
2408
|
+
const parseArrayOptions = {
|
|
2409
|
+
onItem(s: ArrayParserState, item: unknown, i: number) {
|
|
1851
2410
|
const value = i < s.len ? item : InternalParser.missing
|
|
1852
2411
|
return s.getParser(s.tailThreshold, i).parser(value, s.options)
|
|
1853
2412
|
},
|
|
1854
|
-
step(s, item, exit, i) {
|
|
2413
|
+
step(s: ArrayParserState, item: unknown, exit: Exit.Exit<unknown, SchemaIssue.Issue>, i: number) {
|
|
1855
2414
|
if (exit._tag === "Failure") {
|
|
1856
2415
|
return wrapPropertyKeyIssue(s, s.ast, i, exit)
|
|
1857
2416
|
}
|
|
@@ -1874,13 +2433,11 @@ const parseArray = iterateEager<{
|
|
|
1874
2433
|
}
|
|
1875
2434
|
}
|
|
1876
2435
|
}
|
|
1877
|
-
})
|
|
1878
|
-
|
|
1879
|
-
const resolveConcurrency = (value: number | "unbounded" | undefined) => {
|
|
1880
|
-
value = value === "unbounded" ? Infinity : value ?? 1
|
|
1881
|
-
return value > 1 ? { concurrency: value } : undefined
|
|
1882
2436
|
}
|
|
1883
2437
|
|
|
2438
|
+
const parseArray = iterateEager<ArrayParserState, unknown>()(parseArrayOptions)
|
|
2439
|
+
const parseArrayConcurrent = iterateConcurrent<ArrayParserState, unknown>()(parseArrayOptions)
|
|
2440
|
+
|
|
1884
2441
|
const wrapPropertyKeyIssue = (
|
|
1885
2442
|
s: {
|
|
1886
2443
|
readonly input: unknown
|
|
@@ -1969,9 +2526,20 @@ export function getIndexSignatureKeys(
|
|
|
1969
2526
|
*
|
|
1970
2527
|
* @see {@link Objects}
|
|
1971
2528
|
* @category models
|
|
1972
|
-
* @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
|
|
1973
2541
|
*/
|
|
1974
|
-
export
|
|
2542
|
+
export const PropertySignature: new(name: PropertyKey, type: AST) => PropertySignature = class {
|
|
1975
2543
|
readonly name: PropertyKey
|
|
1976
2544
|
readonly type: AST
|
|
1977
2545
|
|
|
@@ -2031,9 +2599,20 @@ function isIndexSignatureParameter(ast: AST): ast is IndexSignatureParameter {
|
|
|
2031
2599
|
* @see {@link Objects}
|
|
2032
2600
|
* @see {@link PropertySignature}
|
|
2033
2601
|
* @category models
|
|
2034
|
-
* @since
|
|
2602
|
+
* @since 4.0.0
|
|
2603
|
+
*/
|
|
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
|
|
2035
2614
|
*/
|
|
2036
|
-
export
|
|
2615
|
+
export const IndexSignature: new(parameter: AST, type: AST) => IndexSignature = class {
|
|
2037
2616
|
readonly parameter: IndexSignatureParameter
|
|
2038
2617
|
readonly type: AST
|
|
2039
2618
|
|
|
@@ -2094,7 +2673,40 @@ export class IndexSignature {
|
|
|
2094
2673
|
* @category models
|
|
2095
2674
|
* @since 4.0.0
|
|
2096
2675
|
*/
|
|
2097
|
-
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 {
|
|
2098
2710
|
readonly _tag = "Objects"
|
|
2099
2711
|
readonly propertySignatures: ReadonlyArray<PropertySignature>
|
|
2100
2712
|
readonly indexSignatures: ReadonlyArray<IndexSignature>
|
|
@@ -2129,7 +2741,7 @@ export class Objects extends Base {
|
|
|
2129
2741
|
const ast = this
|
|
2130
2742
|
const expectedKeys: Array<PropertyKey> = []
|
|
2131
2743
|
for (const ps of ast.propertySignatures) {
|
|
2132
|
-
expectedKeys.push(ps.name)
|
|
2744
|
+
expectedKeys.push(typeof ps.name === "number" ? globalThis.String(ps.name) : ps.name)
|
|
2133
2745
|
}
|
|
2134
2746
|
const hasProperties = expectedKeys.length
|
|
2135
2747
|
const indexCount = ast.indexSignatures.length
|
|
@@ -2164,7 +2776,10 @@ export class Objects extends Base {
|
|
|
2164
2776
|
? inputValue
|
|
2165
2777
|
: (exitValue as InternalParser.Success<unknown, SchemaIssue.Issue>)[InternalParser.args]
|
|
2166
2778
|
if (k2 !== InternalParser.missing && value !== InternalParser.missing) {
|
|
2167
|
-
if (
|
|
2779
|
+
if (
|
|
2780
|
+
hasProperties &&
|
|
2781
|
+
(expectedKeysSet!.has(key) || expectedKeysSet!.has(typeof k2 === "number" ? globalThis.String(k2) : k2))
|
|
2782
|
+
) return Exit.void
|
|
2168
2783
|
InternalRecord.assignProperty(s.out, k2, value)
|
|
2169
2784
|
}
|
|
2170
2785
|
return Exit.void
|
|
@@ -2205,13 +2820,13 @@ export class Objects extends Base {
|
|
|
2205
2820
|
? finishIndex(s, key, key, inputValue, result)
|
|
2206
2821
|
: Effect.flatMap(Effect.exit(result), (exit) => finishIndex(s, key, key, inputValue, exit))
|
|
2207
2822
|
}
|
|
2208
|
-
const parseIndexes = indexCount
|
|
2209
|
-
|
|
2210
|
-
onItem: (s, [key, index]) =>
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
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
|
|
2215
2830
|
const compileMembers = (): Array<ParsedProperty> => {
|
|
2216
2831
|
if (!properties) {
|
|
2217
2832
|
properties = ast.propertySignatures.map((ps) => ({
|
|
@@ -2252,62 +2867,65 @@ export class Objects extends Base {
|
|
|
2252
2867
|
}
|
|
2253
2868
|
const errorsAllOption = options.errors === "all"
|
|
2254
2869
|
const onExcessPropertyError = options.onExcessProperty === "error"
|
|
2255
|
-
const
|
|
2870
|
+
const concurrency = options.concurrency === undefined ? 1 : resolveConcurrency(options.concurrency)
|
|
2256
2871
|
|
|
2257
2872
|
// ---------------------------------------------
|
|
2258
2873
|
// handle excess properties
|
|
2259
2874
|
// ---------------------------------------------
|
|
2260
|
-
|
|
2261
|
-
|
|
2875
|
+
const indexKeys = indexCount && onExcessPropertyError
|
|
2876
|
+
? ast.indexSignatures.map((index) => getIndexSignatureKeys(record, index.parameter, options))
|
|
2877
|
+
: undefined
|
|
2878
|
+
if (onExcessPropertyError) {
|
|
2262
2879
|
expectedKeysSet ??= new Set(expectedKeys)
|
|
2263
|
-
|
|
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)
|
|
2264
2887
|
for (let i = 0; i < inputKeys.length; i++) {
|
|
2265
2888
|
const key = inputKeys[i]
|
|
2266
|
-
if (!
|
|
2889
|
+
if (!coveredKeys.has(key)) {
|
|
2267
2890
|
// key is unexpected
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
if (
|
|
2272
|
-
|
|
2273
|
-
state.issues.push(issue)
|
|
2274
|
-
} else {
|
|
2275
|
-
state.issues = [issue]
|
|
2276
|
-
}
|
|
2277
|
-
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)
|
|
2278
2896
|
} else {
|
|
2279
|
-
|
|
2280
|
-
new SchemaIssue.Composite(ast, [issue], input, options)
|
|
2281
|
-
)
|
|
2897
|
+
state.issues = [issue]
|
|
2282
2898
|
}
|
|
2899
|
+
continue
|
|
2283
2900
|
} else {
|
|
2284
|
-
|
|
2285
|
-
|
|
2901
|
+
return yield* Effect.fail(
|
|
2902
|
+
new SchemaIssue.Composite(ast, [issue], input, options)
|
|
2903
|
+
)
|
|
2286
2904
|
}
|
|
2287
2905
|
}
|
|
2288
2906
|
}
|
|
2289
2907
|
}
|
|
2290
2908
|
|
|
2291
|
-
const concurrency = resolveConcurrency(options?.concurrency)
|
|
2292
|
-
|
|
2293
2909
|
// ---------------------------------------------
|
|
2294
2910
|
// handle property signatures
|
|
2295
2911
|
// ---------------------------------------------
|
|
2296
2912
|
if (hasProperties) {
|
|
2297
|
-
const eff =
|
|
2913
|
+
const eff = concurrency === 1
|
|
2914
|
+
? parseProperties(state, properties!)
|
|
2915
|
+
: parsePropertiesConcurrent(state, properties!, { concurrency })
|
|
2298
2916
|
if (eff) yield* eff
|
|
2299
2917
|
}
|
|
2300
2918
|
|
|
2301
2919
|
// ---------------------------------------------
|
|
2302
2920
|
// handle index signatures
|
|
2303
2921
|
// ---------------------------------------------
|
|
2304
|
-
if (indexCount &&
|
|
2922
|
+
if (indexCount && concurrency === 1) {
|
|
2305
2923
|
for (let i = 0; i < indexCount; i++) {
|
|
2306
2924
|
const index = indexes![i]
|
|
2307
2925
|
const parse = index.is.parameter === string ? parseStringIndex : parseIndex
|
|
2308
|
-
const keys = index.is.parameter === string
|
|
2926
|
+
const keys = indexKeys?.[i] ?? (index.is.parameter === string
|
|
2309
2927
|
? Object.keys(record)
|
|
2310
|
-
: getIndexSignatureKeys(record, index.is.parameter, options)
|
|
2928
|
+
: getIndexSignatureKeys(record, index.is.parameter, options))
|
|
2311
2929
|
for (let j = 0; j < keys.length; j++) {
|
|
2312
2930
|
const eff = parse(state, keys[j], index)
|
|
2313
2931
|
if (!effectIsExit(eff)) yield* eff
|
|
@@ -2315,15 +2933,17 @@ export class Objects extends Base {
|
|
|
2315
2933
|
}
|
|
2316
2934
|
}
|
|
2317
2935
|
} else if (parseIndexes) {
|
|
2318
|
-
const keyPairs = Arr.empty<[PropertyKey, Index]>()
|
|
2936
|
+
const keyPairs = Arr.empty<readonly [PropertyKey, Index]>()
|
|
2319
2937
|
for (let i = 0; i < indexCount; i++) {
|
|
2320
2938
|
const index = indexes![i]
|
|
2321
|
-
const keys =
|
|
2939
|
+
const keys = indexKeys?.[i] ?? (index.is.parameter === string
|
|
2940
|
+
? Object.keys(record)
|
|
2941
|
+
: getIndexSignatureKeys(record, index.is.parameter, options))
|
|
2322
2942
|
for (let j = 0; j < keys.length; j++) {
|
|
2323
2943
|
keyPairs.push([keys[j], index])
|
|
2324
2944
|
}
|
|
2325
2945
|
}
|
|
2326
|
-
const eff = parseIndexes(state, keyPairs, concurrency)
|
|
2946
|
+
const eff = parseIndexes(state, keyPairs, { concurrency })
|
|
2327
2947
|
if (eff) yield* eff
|
|
2328
2948
|
}
|
|
2329
2949
|
|
|
@@ -2332,17 +2952,6 @@ export class Objects extends Base {
|
|
|
2332
2952
|
new SchemaIssue.Composite(ast, state.issues, input, options)
|
|
2333
2953
|
)
|
|
2334
2954
|
}
|
|
2335
|
-
if (options.propertyOrder === "original") {
|
|
2336
|
-
// preserve input keys order
|
|
2337
|
-
const keys = (inputKeys ?? Reflect.ownKeys(record)).concat(expectedKeys)
|
|
2338
|
-
const preserved: Record<PropertyKey, unknown> = {}
|
|
2339
|
-
for (const key of keys) {
|
|
2340
|
-
if (Object.hasOwn(out, key)) {
|
|
2341
|
-
InternalRecord.assignProperty(preserved, key, out[key])
|
|
2342
|
-
}
|
|
2343
|
-
}
|
|
2344
|
-
return preserved
|
|
2345
|
-
}
|
|
2346
2955
|
return out
|
|
2347
2956
|
})
|
|
2348
2957
|
|
|
@@ -2372,8 +2981,7 @@ export class Objects extends Base {
|
|
|
2372
2981
|
if (
|
|
2373
2982
|
options.errors === "all" ||
|
|
2374
2983
|
options.onExcessProperty !== undefined ||
|
|
2375
|
-
options.
|
|
2376
|
-
options.concurrency !== undefined
|
|
2984
|
+
(options.concurrency !== undefined && resolveConcurrency(options.concurrency) !== 1)
|
|
2377
2985
|
) {
|
|
2378
2986
|
return fallback(input, options)
|
|
2379
2987
|
}
|
|
@@ -2388,7 +2996,7 @@ export class Objects extends Base {
|
|
|
2388
2996
|
for (let index = 0; index < props.length; index++) {
|
|
2389
2997
|
const property = props[index]
|
|
2390
2998
|
const name = property.name
|
|
2391
|
-
const hasKey =
|
|
2999
|
+
const hasKey = hasPropertySignature(record, name)
|
|
2392
3000
|
const value = hasKey ? record[name] : InternalParser.missing
|
|
2393
3001
|
const exit = property.parser(value, options)
|
|
2394
3002
|
if (!effectIsExit(exit)) {
|
|
@@ -2498,9 +3106,9 @@ function stepProperty(
|
|
|
2498
3106
|
}
|
|
2499
3107
|
}
|
|
2500
3108
|
|
|
2501
|
-
const
|
|
2502
|
-
onItem(s, p) {
|
|
2503
|
-
if (!
|
|
3109
|
+
const parsePropertiesOptions = {
|
|
3110
|
+
onItem(s: ObjectParserState, p: ParsedProperty) {
|
|
3111
|
+
if (!hasPropertySignature(s.input, p.name)) {
|
|
2504
3112
|
return p.parser(InternalParser.missing, s.options)
|
|
2505
3113
|
}
|
|
2506
3114
|
const value = s.input[p.name]
|
|
@@ -2508,7 +3116,10 @@ const parseProperties = iterateEager<ObjectParserState, ParsedProperty>()({
|
|
|
2508
3116
|
return p.parser(value, s.options)
|
|
2509
3117
|
},
|
|
2510
3118
|
step: stepProperty
|
|
2511
|
-
}
|
|
3119
|
+
}
|
|
3120
|
+
|
|
3121
|
+
const parseProperties = iterateEager<ObjectParserState, ParsedProperty>()(parsePropertiesOptions)
|
|
3122
|
+
const parsePropertiesConcurrent = iterateConcurrent<ObjectParserState, ParsedProperty>()(parsePropertiesOptions)
|
|
2512
3123
|
|
|
2513
3124
|
function combineChecks(a: Checks | undefined, b: Checks | undefined): Checks | undefined {
|
|
2514
3125
|
if (!a) return b
|
|
@@ -2548,10 +3159,10 @@ export function tuple<Elements extends Schema.Tuple.Elements>(
|
|
|
2548
3159
|
/** @internal */
|
|
2549
3160
|
export function union<Members extends ReadonlyArray<{ readonly ast: AST }>>(
|
|
2550
3161
|
members: Members,
|
|
2551
|
-
|
|
3162
|
+
options: UnionOptions | undefined,
|
|
2552
3163
|
checks: Checks | undefined
|
|
2553
3164
|
): Union<Members[number]["ast"]> {
|
|
2554
|
-
return new Union(members.map(getAST),
|
|
3165
|
+
return new Union(members.map(getAST), options, undefined, checks)
|
|
2555
3166
|
}
|
|
2556
3167
|
|
|
2557
3168
|
/** @internal */
|
|
@@ -2578,6 +3189,23 @@ export function tupleWithRest(ast: Arrays, rest: ReadonlyArray<AST>): Arrays {
|
|
|
2578
3189
|
return new Arrays(ast.isMutable, ast.elements, rest, undefined, ast.checks)
|
|
2579
3190
|
}
|
|
2580
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
|
+
|
|
2581
3209
|
type Type =
|
|
2582
3210
|
| "null"
|
|
2583
3211
|
| "array"
|
|
@@ -2715,6 +3343,9 @@ type SentinelIndex = Map<PropertyKey, SentinelEntry>
|
|
|
2715
3343
|
const candidateIndexCache = new WeakMap<ReadonlyArray<AST>, CandidateIndex>()
|
|
2716
3344
|
const emptyCandidates: ReadonlyArray<never> = Object.freeze([])
|
|
2717
3345
|
|
|
3346
|
+
const hasPropertySignature = (input: object, key: PropertyKey): boolean =>
|
|
3347
|
+
key === "__proto__" ? Object.hasOwn(input, key) : key in input
|
|
3348
|
+
|
|
2718
3349
|
function getIndex(types: ReadonlyArray<AST>): CandidateIndex {
|
|
2719
3350
|
let index = candidateIndexCache.get(types)
|
|
2720
3351
|
if (index) return index
|
|
@@ -2772,7 +3403,7 @@ function getIndex(types: ReadonlyArray<AST>): CandidateIndex {
|
|
|
2772
3403
|
}
|
|
2773
3404
|
index = (input, isConstructor) => {
|
|
2774
3405
|
if (Predicate.isObjectKeyword(input)) {
|
|
2775
|
-
const value =
|
|
3406
|
+
const value = hasPropertySignature(input, key) ? (input as any)[key] : undefined
|
|
2776
3407
|
if (value !== undefined) return candidates.get(value) ?? emptyCandidates
|
|
2777
3408
|
if (isConstructor) return types
|
|
2778
3409
|
}
|
|
@@ -2804,7 +3435,7 @@ function getIndex(types: ReadonlyArray<AST>): CandidateIndex {
|
|
|
2804
3435
|
// discriminated candidate.
|
|
2805
3436
|
if (commonSentinel) {
|
|
2806
3437
|
const [key, [byValue]] = commonSentinel
|
|
2807
|
-
const hasKey =
|
|
3438
|
+
const hasKey = hasPropertySignature(input, key)
|
|
2808
3439
|
const value = hasKey ? (input as any)[key] : undefined
|
|
2809
3440
|
if (hasKey && (!isConstructor || value !== undefined)) {
|
|
2810
3441
|
const match = byValue.get(value)
|
|
@@ -2818,7 +3449,7 @@ function getIndex(types: ReadonlyArray<AST>): CandidateIndex {
|
|
|
2818
3449
|
// absent and undefined keys as unconstrained and therefore selects every candidate that owns the key.
|
|
2819
3450
|
if (directKey === undefined) {
|
|
2820
3451
|
for (const [key, [byValue, all]] of bySentinel) {
|
|
2821
|
-
const hasKey =
|
|
3452
|
+
const hasKey = hasPropertySignature(input, key)
|
|
2822
3453
|
const value = hasKey ? (input as any)[key] : undefined
|
|
2823
3454
|
if (hasKey && (!isConstructor || value !== undefined)) {
|
|
2824
3455
|
const match = byValue.get(value)
|
|
@@ -2833,7 +3464,7 @@ function getIndex(types: ReadonlyArray<AST>): CandidateIndex {
|
|
|
2833
3464
|
// Missing keys are neutral. An observed key rejects only selected candidates that own it and do not match.
|
|
2834
3465
|
for (const [key, [byValue, all]] of bySentinel) {
|
|
2835
3466
|
if (key === directKey) continue
|
|
2836
|
-
const hasKey =
|
|
3467
|
+
const hasKey = hasPropertySignature(input, key)
|
|
2837
3468
|
const value = hasKey ? (input as any)[key] : undefined
|
|
2838
3469
|
if (hasKey && (!isConstructor || value !== undefined)) {
|
|
2839
3470
|
const match = byValue.get(value)
|
|
@@ -2886,7 +3517,7 @@ export function getCandidates(
|
|
|
2886
3517
|
* **Details**
|
|
2887
3518
|
*
|
|
2888
3519
|
* - `types` — the member AST nodes.
|
|
2889
|
-
* - `mode`
|
|
3520
|
+
* - `options.mode` selects matching behavior. `"anyOf"` succeeds on the first match;
|
|
2890
3521
|
* `"oneOf"` requires exactly one member to match (fails if multiple do).
|
|
2891
3522
|
*
|
|
2892
3523
|
* During parsing, members are tried in order. An internal candidate index
|
|
@@ -2902,23 +3533,70 @@ export function getCandidates(
|
|
|
2902
3533
|
* const ast = schema.ast
|
|
2903
3534
|
*
|
|
2904
3535
|
* if (SchemaAST.isUnion(ast)) {
|
|
2905
|
-
* [ast.types.length, ast.mode] // => [2, "anyOf"]
|
|
3536
|
+
* [ast.types.length, ast.options?.mode ?? "anyOf"] // => [2, "anyOf"]
|
|
2906
3537
|
* }
|
|
2907
3538
|
* ```
|
|
2908
3539
|
*
|
|
2909
3540
|
* @see {@link isUnion}
|
|
2910
3541
|
* @category models
|
|
2911
|
-
* @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
|
|
2912
3582
|
*/
|
|
2913
|
-
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 {
|
|
2914
3592
|
readonly _tag = "Union"
|
|
2915
3593
|
readonly types: ReadonlyArray<A>
|
|
2916
|
-
readonly
|
|
3594
|
+
readonly options: UnionOptions | undefined
|
|
2917
3595
|
readonly encodingChecks: Checks | undefined
|
|
2918
3596
|
|
|
2919
3597
|
constructor(
|
|
2920
3598
|
types: ReadonlyArray<A>,
|
|
2921
|
-
|
|
3599
|
+
options?: UnionOptions,
|
|
2922
3600
|
annotations?: Schema.Annotations.Annotations,
|
|
2923
3601
|
checks?: Checks,
|
|
2924
3602
|
encoding?: Encoding,
|
|
@@ -2927,7 +3605,7 @@ export class Union<A extends AST = AST> extends Base {
|
|
|
2927
3605
|
) {
|
|
2928
3606
|
super(annotations, checks, encoding, context)
|
|
2929
3607
|
this.types = types
|
|
2930
|
-
this.
|
|
3608
|
+
this.options = options
|
|
2931
3609
|
this.encodingChecks = encodingChecks
|
|
2932
3610
|
}
|
|
2933
3611
|
/** @internal */
|
|
@@ -2944,6 +3622,9 @@ export class Union<A extends AST = AST> extends Base {
|
|
|
2944
3622
|
}
|
|
2945
3623
|
const candidates = getCandidates(input, ast.types, compileConstructorDefault !== undefined)
|
|
2946
3624
|
|
|
3625
|
+
if (candidates.length === 0) {
|
|
3626
|
+
return Effect.fail(new SchemaIssue.AnyOf(ast, [], input, options))
|
|
3627
|
+
}
|
|
2947
3628
|
if (candidates.length === 1) {
|
|
2948
3629
|
const result = compile(candidates[0])(input, options)
|
|
2949
3630
|
if ((result as Exit.Exit<unknown, SchemaIssue.Issue>)._tag === "Success") return result
|
|
@@ -2957,12 +3638,11 @@ export class Union<A extends AST = AST> extends Base {
|
|
|
2957
3638
|
compile,
|
|
2958
3639
|
input,
|
|
2959
3640
|
out: undefined,
|
|
2960
|
-
successes: ast.mode === "oneOf" ? [] : undefined,
|
|
3641
|
+
successes: ast.options?.mode === "oneOf" ? [] : undefined,
|
|
2961
3642
|
issues: undefined as Arr.NonEmptyArray<SchemaIssue.Issue> | undefined,
|
|
2962
3643
|
options
|
|
2963
3644
|
}
|
|
2964
|
-
const
|
|
2965
|
-
const eff = parseUnion(state, candidates, concurrency ? { ...concurrency, orderedStep: true } : undefined)
|
|
3645
|
+
const eff = parseUnion(state, candidates)
|
|
2966
3646
|
if (!eff) {
|
|
2967
3647
|
if (state.out) return state.out
|
|
2968
3648
|
return Effect.fail(new SchemaIssue.AnyOf(ast, state.issues ?? [], input, options))
|
|
@@ -2974,18 +3654,22 @@ export class Union<A extends AST = AST> extends Base {
|
|
|
2974
3654
|
})
|
|
2975
3655
|
}
|
|
2976
3656
|
}
|
|
2977
|
-
private _rebuild(
|
|
3657
|
+
private _rebuild(
|
|
3658
|
+
recur: (ast: AST) => AST,
|
|
3659
|
+
checks: Checks | undefined,
|
|
3660
|
+
encodingChecks: Checks | undefined
|
|
3661
|
+
): Union<AST> {
|
|
2978
3662
|
const types = mapOrSame(this.types, recur)
|
|
2979
3663
|
return types === this.types && checks === this.checks && encodingChecks === this.encodingChecks ?
|
|
2980
3664
|
this :
|
|
2981
|
-
new Union(types, this.
|
|
3665
|
+
new Union(types, this.options, this.annotations, checks, undefined, this.context, encodingChecks)
|
|
2982
3666
|
}
|
|
2983
3667
|
/** @internal */
|
|
2984
|
-
recur(recur: (ast: AST) => AST) {
|
|
3668
|
+
recur(recur: (ast: AST) => AST): Union<AST> {
|
|
2985
3669
|
return this._rebuild(recur, this.checks, this.encodingChecks)
|
|
2986
3670
|
}
|
|
2987
3671
|
/** @internal */
|
|
2988
|
-
flip(recur: (ast: AST) => AST) {
|
|
3672
|
+
flip(recur: (ast: AST) => AST): Union<AST> {
|
|
2989
3673
|
return this._rebuild(recur, this.encodingChecks, this.checks)
|
|
2990
3674
|
}
|
|
2991
3675
|
/** @internal */
|
|
@@ -3086,7 +3770,7 @@ const nonFiniteLiterals = new Union([
|
|
|
3086
3770
|
new Literal("Infinity"),
|
|
3087
3771
|
new Literal("-Infinity"),
|
|
3088
3772
|
new Literal("NaN")
|
|
3089
|
-
]
|
|
3773
|
+
])
|
|
3090
3774
|
|
|
3091
3775
|
function formatIsMutable(isMutable: boolean | undefined): string {
|
|
3092
3776
|
return isMutable ? "" : "readonly "
|
|
@@ -3139,9 +3823,35 @@ export function memoizeThunk<A>(f: () => A): () => A {
|
|
|
3139
3823
|
*
|
|
3140
3824
|
* @see {@link isSuspend}
|
|
3141
3825
|
* @category models
|
|
3142
|
-
* @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
|
|
3143
3847
|
*/
|
|
3144
|
-
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 {
|
|
3145
3855
|
readonly _tag = "Suspend"
|
|
3146
3856
|
readonly thunk: () => AST
|
|
3147
3857
|
|
|
@@ -3204,7 +3914,32 @@ export class Suspend extends Base {
|
|
|
3204
3914
|
* @category models
|
|
3205
3915
|
* @since 4.0.0
|
|
3206
3916
|
*/
|
|
3207
|
-
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 {
|
|
3208
3943
|
readonly _tag = "Filter"
|
|
3209
3944
|
readonly run: (input: E, self: AST, options: ParseOptions) => SchemaIssue.Issue | undefined
|
|
3210
3945
|
readonly annotations: Schema.Annotations.Filter | undefined
|
|
@@ -3252,7 +3987,30 @@ export class Filter<in E> extends Pipeable.Class {
|
|
|
3252
3987
|
* @category models
|
|
3253
3988
|
* @since 4.0.0
|
|
3254
3989
|
*/
|
|
3255
|
-
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 {
|
|
3256
4014
|
readonly _tag = "FilterGroup"
|
|
3257
4015
|
readonly checks: readonly [Check<E>, ...Array<Check<E>>]
|
|
3258
4016
|
readonly annotations: Schema.Annotations.Filter | undefined
|
|
@@ -3280,7 +4038,7 @@ export class FilterGroup<in E> extends Pipeable.Class {
|
|
|
3280
4038
|
*
|
|
3281
4039
|
* **Details**
|
|
3282
4040
|
*
|
|
3283
|
-
* Stored in
|
|
4041
|
+
* Stored in an AST node's {@link Checks} array.
|
|
3284
4042
|
*
|
|
3285
4043
|
* @see {@link Filter}
|
|
3286
4044
|
* @see {@link FilterGroup}
|
|
@@ -3326,11 +4084,8 @@ export function isFinite(annotations?: Schema.Annotations.Filter) {
|
|
|
3326
4084
|
},
|
|
3327
4085
|
toJsonSchema: () => ({ type: "number" }),
|
|
3328
4086
|
toCode: () => ({ runtime: "Schema.isFinite()" }),
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
noInfinity: true,
|
|
3332
|
-
noNaN: true
|
|
3333
|
-
}
|
|
4087
|
+
arbitraryConstraint: {
|
|
4088
|
+
number: "finite"
|
|
3334
4089
|
},
|
|
3335
4090
|
...annotations
|
|
3336
4091
|
}
|
|
@@ -3341,7 +4096,7 @@ export function isFinite(annotations?: Schema.Annotations.Filter) {
|
|
|
3341
4096
|
export const finite = appendChecks(number, [isFinite()])
|
|
3342
4097
|
|
|
3343
4098
|
const numberToJson = new Link(
|
|
3344
|
-
new Union([finite, nonFiniteLiterals]
|
|
4099
|
+
new Union([finite, nonFiniteLiterals]),
|
|
3345
4100
|
new SchemaTransformation.Transformation(
|
|
3346
4101
|
SchemaGetter.Number(),
|
|
3347
4102
|
SchemaGetter.transform((n) => globalThis.Number.isFinite(n) ? n : globalThis.String(n))
|
|
@@ -3367,8 +4122,12 @@ const numberToJson = new Link(
|
|
|
3367
4122
|
*
|
|
3368
4123
|
* **Gotchas**
|
|
3369
4124
|
*
|
|
3370
|
-
*
|
|
3371
|
-
* 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.
|
|
3372
4131
|
*
|
|
3373
4132
|
* **Example** (Validating an email pattern)
|
|
3374
4133
|
*
|
|
@@ -3399,10 +4158,8 @@ export function isPattern(regExp: globalThis.RegExp, annotations?: Schema.Annota
|
|
|
3399
4158
|
payload: { source, flags: regExp.flags }
|
|
3400
4159
|
},
|
|
3401
4160
|
toJsonSchema: () => ({ pattern: source }),
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
patterns: [regExp.source]
|
|
3405
|
-
}
|
|
4161
|
+
arbitraryConstraint: {
|
|
4162
|
+
patterns: [{ source: regExp.source, flags: regExp.flags }]
|
|
3406
4163
|
},
|
|
3407
4164
|
...annotations
|
|
3408
4165
|
}
|
|
@@ -3614,7 +4371,7 @@ const optionalKeyLastLink = applyToLastLink(optionalKey)
|
|
|
3614
4371
|
|
|
3615
4372
|
/** @internal */
|
|
3616
4373
|
export const optional = memoize(<A extends AST>(ast: A): Union<A | Undefined> =>
|
|
3617
|
-
optionalKey(new Union([ast, undefined_]
|
|
4374
|
+
optionalKey(new Union([ast, undefined_]))
|
|
3618
4375
|
)
|
|
3619
4376
|
|
|
3620
4377
|
/** @internal */
|
|
@@ -3651,9 +4408,8 @@ export function withConstructorDefault<A extends AST>(
|
|
|
3651
4408
|
*
|
|
3652
4409
|
* **Details**
|
|
3653
4410
|
*
|
|
3654
|
-
* This is the low-level primitive behind `Schema.
|
|
3655
|
-
*
|
|
3656
|
-
* 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.
|
|
3657
4413
|
*
|
|
3658
4414
|
* - Returns a new AST with the same type as `to`.
|
|
3659
4415
|
*
|
|
@@ -3723,7 +4479,7 @@ export function record(key: AST, value: AST): Objects {
|
|
|
3723
4479
|
* Checks `ast.context?.isOptional`. Defaults to `false` when no
|
|
3724
4480
|
* {@link Context} is set.
|
|
3725
4481
|
*
|
|
3726
|
-
* @see
|
|
4482
|
+
* @see `Schema.optionalKey`
|
|
3727
4483
|
* @see {@link Context}
|
|
3728
4484
|
* @category predicates
|
|
3729
4485
|
* @since 4.0.0
|
|
@@ -3886,7 +4642,7 @@ function fromConst<const T>(
|
|
|
3886
4642
|
ast: AST,
|
|
3887
4643
|
value: T
|
|
3888
4644
|
): SchemaParser.Parser {
|
|
3889
|
-
const succeed = InternalParser.succeed(value)
|
|
4645
|
+
const succeed = value === 0 ? InternalParser.sameExit : InternalParser.succeed(value)
|
|
3890
4646
|
return (input, options) => {
|
|
3891
4647
|
if (input === InternalParser.missing) return InternalParser.missingExit
|
|
3892
4648
|
if (input === value) return succeed
|
|
@@ -3959,14 +4715,6 @@ function segmentTemplateLiteralParts(
|
|
|
3959
4715
|
return go(0, 0) ? out : undefined
|
|
3960
4716
|
}
|
|
3961
4717
|
|
|
3962
|
-
/** @internal */
|
|
3963
|
-
export const enumsToLiterals = memoize((ast: Enum): Union<Literal> => {
|
|
3964
|
-
return new Union(
|
|
3965
|
-
ast.enums.map((e) => new Literal(e[1], { title: e[0] })),
|
|
3966
|
-
"anyOf"
|
|
3967
|
-
)
|
|
3968
|
-
})
|
|
3969
|
-
|
|
3970
4718
|
const parameterFromPropertyKey = applyToSelfOrLastLinkEncodingIdempotent((ast) => {
|
|
3971
4719
|
switch (ast._tag) {
|
|
3972
4720
|
default:
|
|
@@ -4038,7 +4786,7 @@ const finiteToString = new Link(
|
|
|
4038
4786
|
)
|
|
4039
4787
|
|
|
4040
4788
|
const numberToString = new Link(
|
|
4041
|
-
new Union([finiteString, nonFiniteLiterals]
|
|
4789
|
+
new Union([finiteString, nonFiniteLiterals]),
|
|
4042
4790
|
SchemaTransformation.numberFromString
|
|
4043
4791
|
)
|
|
4044
4792
|
|
|
@@ -4075,7 +4823,7 @@ const bigIntToString = new Link(
|
|
|
4075
4823
|
SchemaTransformation.bigintFromString
|
|
4076
4824
|
)
|
|
4077
4825
|
|
|
4078
|
-
const REGEXP_PATTERN = "Symbol\\((
|
|
4826
|
+
const REGEXP_PATTERN = "Symbol\\(([\\s\\S]*)\\)"
|
|
4079
4827
|
|
|
4080
4828
|
const isStringSymbolRegExp = new globalThis.RegExp(`^${REGEXP_PATTERN}$`)
|
|
4081
4829
|
|
|
@@ -4089,7 +4837,7 @@ const symbolToString = new Link(
|
|
|
4089
4837
|
symbolString,
|
|
4090
4838
|
new SchemaTransformation.Transformation(
|
|
4091
4839
|
SchemaGetter.transform((description) => globalThis.Symbol.for(isStringSymbolRegExp.exec(description)![1])),
|
|
4092
|
-
SchemaGetter.
|
|
4840
|
+
SchemaGetter.transformEffect((sym: symbol, options) => {
|
|
4093
4841
|
const key = globalThis.Symbol.keyFor(sym)
|
|
4094
4842
|
if (key !== undefined) {
|
|
4095
4843
|
return Effect.succeed(globalThis.String(sym))
|
|
@@ -4187,7 +4935,7 @@ export function getConstructorDescriptor(ast: AST): ConstructorDescriptor | unde
|
|
|
4187
4935
|
*
|
|
4188
4936
|
* If the node has {@link Checks}, returns annotations from the last check
|
|
4189
4937
|
* (which is where user-supplied annotations end up after `.pipe(Schema.annotations(...))`).
|
|
4190
|
-
* Otherwise returns `
|
|
4938
|
+
* Otherwise returns the node's `annotations` directly.
|
|
4191
4939
|
*
|
|
4192
4940
|
* **Example** (Reading annotations)
|
|
4193
4941
|
*
|
|
@@ -4362,8 +5110,7 @@ export const Json = new Declaration(
|
|
|
4362
5110
|
},
|
|
4363
5111
|
expected: "JSON value",
|
|
4364
5112
|
toCodecJson: () => undefined,
|
|
4365
|
-
toCodecStringTree: () => unknownToStringTree
|
|
4366
|
-
toArbitrary: () => (fc: typeof FastCheck) => fc.jsonValue()
|
|
5113
|
+
toCodecStringTree: () => unknownToStringTree
|
|
4367
5114
|
}
|
|
4368
5115
|
)
|
|
4369
5116
|
|
|
@@ -4386,7 +5133,7 @@ export const objectKeywordToJson = new Link(
|
|
|
4386
5133
|
new Union([
|
|
4387
5134
|
new Arrays(false, [], [Json]),
|
|
4388
5135
|
new Objects([], [new IndexSignature(string, Json)])
|
|
4389
|
-
]
|
|
5136
|
+
]),
|
|
4390
5137
|
SchemaTransformation.passthrough()
|
|
4391
5138
|
)
|
|
4392
5139
|
|