effect 4.0.0-rc.111 → 4.0.0-rc.113
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +24 -9
- package/CLAUDE.md +24 -9
- package/ai-docs/package.json +2 -2
- package/ai-docs/src/01_effect/01_basics/02_effect-fn.ts +18 -5
- package/ai-docs/src/01_effect/01_basics/index.md +5 -3
- package/ai-docs/src/01_effect/03_services/20_layer-composition.ts +1 -1
- package/ai-docs/src/01_effect/03_services/20_layer-unwrap.ts +2 -2
- package/ai-docs/src/01_effect/05_resources/10_acquire-release.ts +2 -2
- package/ai-docs/src/03_stream/30_encoding.ts +5 -7
- package/ai-docs/src/08_observability/10_logging.ts +1 -1
- package/ai-docs/src/70_cli/10_basics.ts +7 -7
- package/ai-docs/src/71_ai/10_language-model.ts +2 -2
- package/ai-docs/src/71_ai/20_tools.ts +1 -1
- package/ai-docs/src/71_ai/30_chat.ts +1 -1
- package/dist/Array.d.ts +109 -52
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +65 -32
- package/dist/Array.js.map +1 -1
- package/dist/BigDecimal.d.ts +5 -1
- package/dist/BigDecimal.d.ts.map +1 -1
- package/dist/BigDecimal.js +40 -23
- package/dist/BigDecimal.js.map +1 -1
- package/dist/ByteSize.d.ts +633 -0
- package/dist/ByteSize.d.ts.map +1 -0
- package/dist/ByteSize.js +524 -0
- package/dist/ByteSize.js.map +1 -0
- package/dist/Cache.d.ts.map +1 -1
- package/dist/Cache.js +17 -3
- package/dist/Cache.js.map +1 -1
- package/dist/Cause.d.ts +1 -1
- package/dist/Cause.d.ts.map +1 -1
- package/dist/Channel.d.ts +97 -24
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +68 -41
- package/dist/Channel.js.map +1 -1
- package/dist/Chunk.d.ts +49 -28
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Chunk.js +27 -18
- package/dist/Chunk.js.map +1 -1
- package/dist/Config.d.ts +162 -201
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +103 -212
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.d.ts +4 -4
- package/dist/ConfigProvider.d.ts.map +1 -1
- package/dist/ConfigProvider.js +7 -7
- package/dist/ConfigProvider.js.map +1 -1
- package/dist/Context.d.ts +31 -0
- package/dist/Context.d.ts.map +1 -1
- package/dist/Context.js.map +1 -1
- package/dist/Cron.d.ts +2 -2
- package/dist/Cron.d.ts.map +1 -1
- package/dist/Cron.js +2 -2
- package/dist/Cron.js.map +1 -1
- package/dist/Crypto.d.ts +1 -1
- package/dist/Crypto.d.ts.map +1 -1
- package/dist/Crypto.js +3 -2
- package/dist/Crypto.js.map +1 -1
- package/dist/DateTime.d.ts +2 -2
- package/dist/DateTime.d.ts.map +1 -1
- package/dist/Deferred.d.ts.map +1 -1
- package/dist/Deferred.js +6 -6
- package/dist/Deferred.js.map +1 -1
- package/dist/Duration.d.ts +1 -1
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +1 -1
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts +220 -113
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +27 -26
- package/dist/Effect.js.map +1 -1
- package/dist/Effectable.d.ts +58 -2
- package/dist/Effectable.d.ts.map +1 -1
- package/dist/Effectable.js +58 -6
- package/dist/Effectable.js.map +1 -1
- package/dist/Encoding.d.ts +3 -1
- package/dist/Encoding.d.ts.map +1 -1
- package/dist/Encoding.js +40 -10
- package/dist/Encoding.js.map +1 -1
- package/dist/Equal.d.ts +1 -1
- package/dist/Equal.d.ts.map +1 -1
- package/dist/Equal.js +1 -1
- package/dist/Equal.js.map +1 -1
- package/dist/ExecutionPlan.d.ts.map +1 -1
- package/dist/ExecutionPlan.js +1 -0
- package/dist/ExecutionPlan.js.map +1 -1
- package/dist/Fiber.d.ts +32 -8
- package/dist/Fiber.d.ts.map +1 -1
- package/dist/Fiber.js.map +1 -1
- package/dist/FiberHandle.js +3 -3
- package/dist/FiberHandle.js.map +1 -1
- package/dist/FiberMap.d.ts +12 -6
- package/dist/FiberMap.d.ts.map +1 -1
- package/dist/FiberMap.js +11 -6
- package/dist/FiberMap.js.map +1 -1
- package/dist/FileSystem.d.ts +42 -210
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js +16 -148
- package/dist/FileSystem.js.map +1 -1
- package/dist/Formatter.d.ts +1 -0
- package/dist/Formatter.d.ts.map +1 -1
- package/dist/Formatter.js +19 -3
- package/dist/Formatter.js.map +1 -1
- package/dist/Graph.d.ts +48 -20
- package/dist/Graph.d.ts.map +1 -1
- package/dist/Graph.js +20 -5
- package/dist/Graph.js.map +1 -1
- package/dist/Hash.d.ts +1 -1
- package/dist/Hash.d.ts.map +1 -1
- package/dist/Hash.js +5 -14
- package/dist/Hash.js.map +1 -1
- package/dist/HashMap.d.ts +1 -1
- package/dist/HashMap.d.ts.map +1 -1
- package/dist/HashRing.d.ts +6 -1
- package/dist/HashRing.d.ts.map +1 -1
- package/dist/HashRing.js +9 -2
- package/dist/HashRing.js.map +1 -1
- package/dist/HashSet.d.ts +1 -1
- package/dist/HashSet.d.ts.map +1 -1
- package/dist/HashSet.js.map +1 -1
- package/dist/Iterable.d.ts +56 -17
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +65 -45
- package/dist/Iterable.js.map +1 -1
- package/dist/JsonPatch.js +4 -4
- package/dist/JsonPatch.js.map +1 -1
- package/dist/JsonPointer.d.ts +68 -4
- package/dist/JsonPointer.d.ts.map +1 -1
- package/dist/JsonPointer.js +90 -4
- package/dist/JsonPointer.js.map +1 -1
- package/dist/JsonSchema.d.ts +67 -94
- package/dist/JsonSchema.d.ts.map +1 -1
- package/dist/JsonSchema.js +752 -397
- package/dist/JsonSchema.js.map +1 -1
- package/dist/Layer.d.ts +47 -4
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +4 -6
- package/dist/Layer.js.map +1 -1
- package/dist/LayerMap.d.ts +24 -3
- package/dist/LayerMap.d.ts.map +1 -1
- package/dist/LayerMap.js +9 -5
- package/dist/LayerMap.js.map +1 -1
- package/dist/LayerRef.d.ts.map +1 -1
- package/dist/LayerRef.js +7 -5
- package/dist/LayerRef.js.map +1 -1
- package/dist/Logger.d.ts +114 -9
- package/dist/Logger.d.ts.map +1 -1
- package/dist/Logger.js +109 -9
- package/dist/Logger.js.map +1 -1
- package/dist/ManagedRuntime.js +1 -1
- package/dist/ManagedRuntime.js.map +1 -1
- package/dist/Match.d.ts +43 -31
- package/dist/Match.d.ts.map +1 -1
- package/dist/Match.js +5 -2
- package/dist/Match.js.map +1 -1
- package/dist/Metric.d.ts +11 -4
- package/dist/Metric.d.ts.map +1 -1
- package/dist/Metric.js +14 -18
- package/dist/Metric.js.map +1 -1
- package/dist/MutableHashMap.d.ts +1 -1
- package/dist/MutableHashMap.d.ts.map +1 -1
- package/dist/MutableHashMap.js +1 -1
- package/dist/MutableHashMap.js.map +1 -1
- package/dist/MutableHashSet.d.ts +1 -1
- package/dist/MutableHashSet.d.ts.map +1 -1
- package/dist/MutableHashSet.js +1 -1
- package/dist/MutableHashSet.js.map +1 -1
- package/dist/MutableList.d.ts +13 -2
- package/dist/MutableList.d.ts.map +1 -1
- package/dist/MutableList.js +18 -2
- package/dist/MutableList.js.map +1 -1
- package/dist/Number.d.ts +6 -0
- package/dist/Number.d.ts.map +1 -1
- package/dist/Number.js +3 -1
- package/dist/Number.js.map +1 -1
- package/dist/Optic.d.ts.map +1 -1
- package/dist/Optic.js +5 -4
- package/dist/Optic.js.map +1 -1
- package/dist/Option.d.ts +1 -1
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js +1 -1
- package/dist/Option.js.map +1 -1
- package/dist/Order.d.ts +1 -0
- package/dist/Order.d.ts.map +1 -1
- package/dist/Order.js +3 -1
- package/dist/Order.js.map +1 -1
- package/dist/PartitionedSemaphore.d.ts.map +1 -1
- package/dist/PartitionedSemaphore.js +1 -2
- package/dist/PartitionedSemaphore.js.map +1 -1
- package/dist/Path.d.ts +1 -1
- package/dist/Path.d.ts.map +1 -1
- package/dist/Path.js +1 -1
- package/dist/Path.js.map +1 -1
- package/dist/PlatformError.d.ts +1 -1
- package/dist/PlatformError.d.ts.map +1 -1
- package/dist/PlatformError.js +1 -1
- package/dist/PlatformError.js.map +1 -1
- package/dist/Pool.d.ts +137 -10
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +332 -75
- package/dist/Pool.js.map +1 -1
- package/dist/PrimaryKey.d.ts +1 -1
- package/dist/PrimaryKey.d.ts.map +1 -1
- package/dist/PrimaryKey.js +1 -1
- package/dist/PrimaryKey.js.map +1 -1
- package/dist/PubSub.d.ts +21 -9
- package/dist/PubSub.d.ts.map +1 -1
- package/dist/PubSub.js +18 -14
- package/dist/PubSub.js.map +1 -1
- package/dist/Queue.d.ts +82 -6
- package/dist/Queue.d.ts.map +1 -1
- package/dist/Queue.js +116 -27
- package/dist/Queue.js.map +1 -1
- package/dist/Random.d.ts +17 -4
- package/dist/Random.d.ts.map +1 -1
- package/dist/Random.js +1 -1
- package/dist/Random.js.map +1 -1
- package/dist/RcMap.d.ts +137 -0
- package/dist/RcMap.d.ts.map +1 -1
- package/dist/RcMap.js +72 -9
- package/dist/RcMap.js.map +1 -1
- package/dist/Record.d.ts +13 -0
- package/dist/Record.d.ts.map +1 -1
- package/dist/Record.js.map +1 -1
- package/dist/Redacted.d.ts +1 -1
- package/dist/Redacted.d.ts.map +1 -1
- package/dist/Redacted.js +1 -1
- package/dist/Redacted.js.map +1 -1
- package/dist/RequestResolver.d.ts +15 -9
- package/dist/RequestResolver.d.ts.map +1 -1
- package/dist/RequestResolver.js +33 -15
- package/dist/RequestResolver.js.map +1 -1
- package/dist/Result.d.ts +1 -1
- package/dist/Result.d.ts.map +1 -1
- package/dist/Result.js +1 -1
- package/dist/Result.js.map +1 -1
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/Scheduler.js +19 -10
- package/dist/Scheduler.js.map +1 -1
- package/dist/Schema.d.ts +2200 -2433
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +2797 -4184
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +359 -176
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +373 -630
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaGetter.d.ts +46 -22
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +56 -53
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaIssue.d.ts +123 -200
- package/dist/SchemaIssue.d.ts.map +1 -1
- package/dist/SchemaIssue.js +59 -263
- package/dist/SchemaIssue.js.map +1 -1
- package/dist/SchemaParser.js +2 -9
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +1276 -172
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +1371 -29
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +49 -16
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +75 -98
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/Scope.d.ts +9 -2
- package/dist/Scope.d.ts.map +1 -1
- package/dist/Scope.js.map +1 -1
- package/dist/ScopedCache.d.ts.map +1 -1
- package/dist/ScopedCache.js +10 -3
- package/dist/ScopedCache.js.map +1 -1
- package/dist/Sink.d.ts +9 -4
- package/dist/Sink.d.ts.map +1 -1
- package/dist/Sink.js +49 -31
- package/dist/Sink.js.map +1 -1
- package/dist/StandardSchema.d.ts +125 -0
- package/dist/StandardSchema.d.ts.map +1 -0
- package/dist/StandardSchema.js +9 -0
- package/dist/StandardSchema.js.map +1 -0
- package/dist/Stream.d.ts +221 -35
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +168 -84
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +16 -6
- package/dist/String.d.ts.map +1 -1
- package/dist/String.js +12 -5
- package/dist/String.js.map +1 -1
- package/dist/Struct.d.ts.map +1 -1
- package/dist/Struct.js +7 -4
- package/dist/Struct.js.map +1 -1
- package/dist/SynchronizedRef.d.ts +3 -2
- package/dist/SynchronizedRef.d.ts.map +1 -1
- package/dist/SynchronizedRef.js.map +1 -1
- package/dist/Terminal.d.ts +3 -3
- package/dist/Terminal.d.ts.map +1 -1
- package/dist/Terminal.js +3 -3
- package/dist/Terminal.js.map +1 -1
- package/dist/Tracer.d.ts +27 -7
- package/dist/Tracer.d.ts.map +1 -1
- package/dist/Tracer.js +38 -13
- package/dist/Tracer.js.map +1 -1
- package/dist/Trie.d.ts +1 -1
- package/dist/Trie.d.ts.map +1 -1
- package/dist/Tuple.d.ts +2 -1
- package/dist/Tuple.d.ts.map +1 -1
- package/dist/Tuple.js.map +1 -1
- package/dist/TxChunk.d.ts +1 -1
- package/dist/TxChunk.d.ts.map +1 -1
- package/dist/TxChunk.js +1 -1
- package/dist/TxChunk.js.map +1 -1
- package/dist/TxDeferred.d.ts +1 -1
- package/dist/TxDeferred.d.ts.map +1 -1
- package/dist/TxDeferred.js +1 -1
- package/dist/TxDeferred.js.map +1 -1
- package/dist/TxHashMap.d.ts +1 -1
- package/dist/TxHashMap.d.ts.map +1 -1
- package/dist/TxHashMap.js +1 -1
- package/dist/TxHashMap.js.map +1 -1
- package/dist/TxHashSet.d.ts +1 -1
- package/dist/TxHashSet.d.ts.map +1 -1
- package/dist/TxHashSet.js +1 -1
- package/dist/TxHashSet.js.map +1 -1
- package/dist/TxPriorityQueue.d.ts +1 -1
- package/dist/TxPriorityQueue.d.ts.map +1 -1
- package/dist/TxPriorityQueue.js +1 -1
- package/dist/TxPriorityQueue.js.map +1 -1
- package/dist/TxPubSub.d.ts +1 -1
- package/dist/TxPubSub.d.ts.map +1 -1
- package/dist/TxPubSub.js +1 -1
- package/dist/TxPubSub.js.map +1 -1
- package/dist/TxQueue.d.ts +9 -9
- package/dist/TxQueue.d.ts.map +1 -1
- package/dist/TxQueue.js +93 -86
- package/dist/TxQueue.js.map +1 -1
- package/dist/TxReentrantLock.d.ts +29 -1
- package/dist/TxReentrantLock.d.ts.map +1 -1
- package/dist/TxReentrantLock.js +29 -1
- package/dist/TxReentrantLock.js.map +1 -1
- package/dist/TxRef.d.ts +1 -1
- package/dist/TxRef.d.ts.map +1 -1
- package/dist/TxRef.js +1 -1
- package/dist/TxRef.js.map +1 -1
- package/dist/TxSemaphore.d.ts +1 -1
- package/dist/TxSemaphore.d.ts.map +1 -1
- package/dist/TxSemaphore.js +1 -1
- package/dist/TxSemaphore.js.map +1 -1
- package/dist/TxSubscriptionRef.d.ts +1 -1
- package/dist/TxSubscriptionRef.d.ts.map +1 -1
- package/dist/TxSubscriptionRef.js +1 -1
- package/dist/TxSubscriptionRef.js.map +1 -1
- package/dist/Types.d.ts +33 -19
- package/dist/Types.d.ts.map +1 -1
- package/dist/Utils.d.ts.map +1 -1
- package/dist/Utils.js +2 -1
- package/dist/Utils.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/arbitrary/model.d.ts +2 -0
- package/dist/internal/arbitrary/model.d.ts.map +1 -0
- package/dist/internal/arbitrary/model.js +495 -0
- package/dist/internal/arbitrary/model.js.map +1 -0
- package/dist/internal/arbitrary/regexp.d.ts +2 -0
- package/dist/internal/arbitrary/regexp.d.ts.map +1 -0
- package/dist/internal/arbitrary/regexp.js +789 -0
- package/dist/internal/arbitrary/regexp.js.map +1 -0
- package/dist/internal/arbitrary/runner.d.ts +2 -0
- package/dist/internal/arbitrary/runner.d.ts.map +1 -0
- package/dist/internal/arbitrary/runner.js +496 -0
- package/dist/internal/arbitrary/runner.js.map +1 -0
- package/dist/internal/arbitrary/schema.d.ts.map +1 -0
- package/dist/internal/arbitrary/schema.js +1340 -0
- package/dist/internal/arbitrary/schema.js.map +1 -0
- package/dist/internal/core.js +27 -13
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/count.d.ts +2 -0
- package/dist/internal/count.d.ts.map +1 -0
- package/dist/internal/count.js +14 -0
- package/dist/internal/count.js.map +1 -0
- package/dist/internal/dateTime.js +4 -10
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +416 -258
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/graph.js +3 -1
- package/dist/internal/graph.js.map +1 -1
- package/dist/internal/hashMap.js +5 -3
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/hashSet.js +1 -1
- package/dist/internal/hashSet.js.map +1 -1
- package/dist/internal/matcher.js +1 -1
- package/dist/internal/matcher.js.map +1 -1
- package/dist/internal/metric.js +1 -1
- package/dist/internal/metric.js.map +1 -1
- package/dist/internal/option.js +6 -5
- package/dist/internal/option.js.map +1 -1
- package/dist/internal/random.js +17 -0
- package/dist/internal/random.js.map +1 -1
- package/dist/internal/rcRef.js +10 -7
- package/dist/internal/rcRef.js.map +1 -1
- package/dist/internal/references.js +1 -0
- package/dist/internal/references.js.map +1 -1
- package/dist/internal/request.js +13 -6
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/result.js +11 -9
- package/dist/internal/result.js.map +1 -1
- package/dist/internal/schema/annotations.js +1 -1
- package/dist/internal/schema/annotations.js.map +1 -1
- package/dist/internal/schema/fromJsonSchemaDocument.js +238 -132
- package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -1
- package/dist/internal/schema/fromRepresentation.js +5 -5
- package/dist/internal/schema/fromRepresentation.js.map +1 -1
- package/dist/internal/schema/make.d.ts +2 -0
- package/dist/internal/schema/make.d.ts.map +1 -0
- package/dist/internal/schema/{schema.js → make.js} +1 -25
- package/dist/internal/schema/make.js.map +1 -0
- package/dist/internal/schema/parser.d.ts +0 -12
- package/dist/internal/schema/parser.d.ts.map +1 -1
- package/dist/internal/schema/parser.js +7 -0
- package/dist/internal/schema/parser.js.map +1 -1
- package/dist/internal/schema/standardSchema.d.ts +2 -0
- package/dist/internal/schema/standardSchema.d.ts.map +1 -0
- package/dist/internal/schema/standardSchema.js +112 -0
- package/dist/internal/schema/standardSchema.js.map +1 -0
- package/dist/internal/schema/toCodeDocument.js +34 -22
- package/dist/internal/schema/toCodeDocument.js.map +1 -1
- package/dist/internal/schema/toCodec.d.ts +2 -0
- package/dist/internal/schema/toCodec.d.ts.map +1 -0
- package/dist/internal/schema/toCodec.js +242 -0
- package/dist/internal/schema/toCodec.js.map +1 -0
- package/dist/internal/schema/toDifferJsonPatch.d.ts +2 -0
- package/dist/internal/schema/toDifferJsonPatch.d.ts.map +1 -0
- package/dist/internal/schema/toDifferJsonPatch.js +20 -0
- package/dist/internal/schema/toDifferJsonPatch.js.map +1 -0
- package/dist/internal/schema/toEncoderXml.d.ts +2 -0
- package/dist/internal/schema/toEncoderXml.d.ts.map +1 -0
- package/dist/internal/schema/toEncoderXml.js +104 -0
- package/dist/internal/schema/toEncoderXml.js.map +1 -0
- package/dist/internal/schema/toEquivalence.js +66 -0
- package/dist/internal/schema/toEquivalence.js.map +1 -1
- package/dist/internal/schema/toFormatter.d.ts +2 -0
- package/dist/internal/schema/toFormatter.d.ts.map +1 -0
- package/dist/internal/schema/toFormatter.js +227 -0
- package/dist/internal/schema/toFormatter.js.map +1 -0
- package/dist/internal/schema/toIso.d.ts +2 -0
- package/dist/internal/schema/toIso.d.ts.map +1 -0
- package/dist/internal/schema/toIso.js +17 -0
- package/dist/internal/schema/toIso.js.map +1 -0
- package/dist/internal/schema/toJsonSchemaDocument.js +122 -71
- package/dist/internal/schema/toJsonSchemaDocument.js.map +1 -1
- package/dist/internal/schema/toRepresentation.js +3 -1
- package/dist/internal/schema/toRepresentation.js.map +1 -1
- package/dist/internal/schemaError.d.ts +4 -0
- package/dist/internal/schemaError.d.ts.map +1 -0
- package/dist/internal/schemaError.js +6 -0
- package/dist/internal/schemaError.js.map +1 -0
- package/dist/internal/stream.js +5 -6
- package/dist/internal/stream.js.map +1 -1
- package/dist/internal/tracer.d.ts +1 -3
- package/dist/internal/tracer.d.ts.map +1 -1
- package/dist/internal/tracer.js +6 -0
- package/dist/internal/tracer.js.map +1 -1
- package/dist/internal/trie.js +2 -2
- package/dist/internal/trie.js.map +1 -1
- package/dist/internal/uuid.d.ts +1 -2
- package/dist/internal/uuid.d.ts.map +1 -1
- package/dist/internal/uuid.js +2 -0
- package/dist/internal/uuid.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +9 -11
- package/dist/testing/TestSchema.d.ts.map +1 -1
- package/dist/testing/TestSchema.js +20 -18
- package/dist/testing/TestSchema.js.map +1 -1
- package/dist/testing/index.d.ts +0 -4
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +0 -4
- package/dist/testing/index.js.map +1 -1
- package/dist/unstable/ai/AiError.d.ts +98 -23
- package/dist/unstable/ai/AiError.d.ts.map +1 -1
- package/dist/unstable/ai/AiError.js +98 -6
- package/dist/unstable/ai/AiError.js.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.js +5 -16
- package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Chat.d.ts +27 -32
- package/dist/unstable/ai/Chat.d.ts.map +1 -1
- package/dist/unstable/ai/Chat.js +10 -13
- package/dist/unstable/ai/Chat.js.map +1 -1
- package/dist/unstable/ai/EmbeddingModel.d.ts +23 -16
- package/dist/unstable/ai/EmbeddingModel.d.ts.map +1 -1
- package/dist/unstable/ai/EmbeddingModel.js +13 -11
- package/dist/unstable/ai/EmbeddingModel.js.map +1 -1
- package/dist/unstable/ai/LanguageModel.d.ts +48 -37
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +150 -47
- package/dist/unstable/ai/LanguageModel.js.map +1 -1
- package/dist/unstable/ai/McpServer.d.ts +2 -2
- package/dist/unstable/ai/McpServer.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.js +87 -78
- package/dist/unstable/ai/McpServer.js.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js +3 -14
- package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Prompt.d.ts +2 -2
- package/dist/unstable/ai/Prompt.d.ts.map +1 -1
- package/dist/unstable/ai/Prompt.js +15 -4
- package/dist/unstable/ai/Prompt.js.map +1 -1
- package/dist/unstable/ai/Response.d.ts +37 -94
- package/dist/unstable/ai/Response.d.ts.map +1 -1
- package/dist/unstable/ai/Response.js +46 -96
- package/dist/unstable/ai/Response.js.map +1 -1
- package/dist/unstable/ai/Tokenizer.js +4 -5
- package/dist/unstable/ai/Tokenizer.js.map +1 -1
- package/dist/unstable/ai/Tool.d.ts +38 -20
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +27 -1
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/ai/Toolkit.d.ts +1 -1
- package/dist/unstable/ai/Toolkit.d.ts.map +1 -1
- package/dist/unstable/ai/Toolkit.js +30 -18
- package/dist/unstable/ai/Toolkit.js.map +1 -1
- package/dist/unstable/ai/internal/codec-transformer.js +2 -2
- package/dist/unstable/ai/internal/codec-transformer.js.map +1 -1
- package/dist/unstable/ai/internal/structured-output.js +28 -5
- package/dist/unstable/ai/internal/structured-output.js.map +1 -1
- package/dist/unstable/arbitrary/Arbitrary.d.ts +626 -0
- package/dist/unstable/arbitrary/Arbitrary.d.ts.map +1 -0
- package/dist/unstable/arbitrary/Arbitrary.js +238 -0
- package/dist/unstable/arbitrary/Arbitrary.js.map +1 -0
- package/dist/unstable/arbitrary/index.d.ts +8 -0
- package/dist/unstable/arbitrary/index.d.ts.map +1 -0
- package/dist/unstable/arbitrary/index.js +9 -0
- package/dist/unstable/arbitrary/index.js.map +1 -0
- package/dist/unstable/cli/Argument.d.ts +104 -108
- package/dist/unstable/cli/Argument.d.ts.map +1 -1
- package/dist/unstable/cli/Argument.js +56 -57
- package/dist/unstable/cli/Argument.js.map +1 -1
- package/dist/unstable/cli/CliError.d.ts +2 -0
- package/dist/unstable/cli/CliError.d.ts.map +1 -1
- package/dist/unstable/cli/CliError.js +2 -0
- package/dist/unstable/cli/CliError.js.map +1 -1
- package/dist/unstable/cli/CliOutput.js +27 -4
- package/dist/unstable/cli/CliOutput.js.map +1 -1
- package/dist/unstable/cli/Command.d.ts +73 -73
- package/dist/unstable/cli/Command.d.ts.map +1 -1
- package/dist/unstable/cli/Command.js +22 -22
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cli/Completions.d.ts +4 -4
- package/dist/unstable/cli/Completions.d.ts.map +1 -1
- package/dist/unstable/cli/Flag.d.ts +150 -161
- package/dist/unstable/cli/Flag.d.ts.map +1 -1
- package/dist/unstable/cli/Flag.js +79 -90
- package/dist/unstable/cli/Flag.js.map +1 -1
- package/dist/unstable/cli/GlobalFlag.d.ts +3 -3
- package/dist/unstable/cli/GlobalFlag.js +13 -13
- package/dist/unstable/cli/GlobalFlag.js.map +1 -1
- package/dist/unstable/cli/Param.d.ts +118 -126
- package/dist/unstable/cli/Param.d.ts.map +1 -1
- package/dist/unstable/cli/Param.js +104 -113
- package/dist/unstable/cli/Param.js.map +1 -1
- package/dist/unstable/cli/Primitive.d.ts +69 -58
- package/dist/unstable/cli/Primitive.d.ts.map +1 -1
- package/dist/unstable/cli/Primitive.js +65 -66
- package/dist/unstable/cli/Primitive.js.map +1 -1
- package/dist/unstable/cli/Prompt.d.ts +113 -59
- package/dist/unstable/cli/Prompt.d.ts.map +1 -1
- package/dist/unstable/cli/Prompt.js +391 -327
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/cli/internal/completions/bash.js +109 -38
- package/dist/unstable/cli/internal/completions/bash.js.map +1 -1
- package/dist/unstable/cli/internal/completions/descriptor.js +23 -11
- package/dist/unstable/cli/internal/completions/descriptor.js.map +1 -1
- package/dist/unstable/cli/internal/completions/fish.js +15 -7
- package/dist/unstable/cli/internal/completions/fish.js.map +1 -1
- package/dist/unstable/cli/internal/completions/zsh.js +6 -4
- package/dist/unstable/cli/internal/completions/zsh.js.map +1 -1
- package/dist/unstable/cli/internal/config.js +4 -4
- package/dist/unstable/cli/internal/parser.js +1 -1
- package/dist/unstable/cli/internal/parser.js.map +1 -1
- package/dist/unstable/cli/internal/wizard.d.ts +5 -1
- package/dist/unstable/cli/internal/wizard.d.ts.map +1 -1
- package/dist/unstable/cli/internal/wizard.js +34 -26
- package/dist/unstable/cli/internal/wizard.js.map +1 -1
- package/dist/unstable/cluster/ClusterSchema.d.ts +13 -0
- package/dist/unstable/cluster/ClusterSchema.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterSchema.js +16 -1
- package/dist/unstable/cluster/ClusterSchema.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +57 -14
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/cluster/Entity.d.ts.map +1 -1
- package/dist/unstable/cluster/Entity.js +2 -0
- package/dist/unstable/cluster/Entity.js.map +1 -1
- package/dist/unstable/cluster/EntityProxyServer.d.ts +2 -2
- package/dist/unstable/cluster/EntityProxyServer.d.ts.map +1 -1
- package/dist/unstable/cluster/EntityProxyServer.js.map +1 -1
- package/dist/unstable/cluster/Envelope.d.ts +22 -5
- package/dist/unstable/cluster/Envelope.d.ts.map +1 -1
- package/dist/unstable/cluster/Envelope.js +23 -3
- package/dist/unstable/cluster/Envelope.js.map +1 -1
- package/dist/unstable/cluster/HttpRunner.d.ts.map +1 -1
- package/dist/unstable/cluster/HttpRunner.js +32 -13
- package/dist/unstable/cluster/HttpRunner.js.map +1 -1
- package/dist/unstable/cluster/Message.d.ts +17 -5
- package/dist/unstable/cluster/Message.d.ts.map +1 -1
- package/dist/unstable/cluster/Message.js +21 -8
- package/dist/unstable/cluster/Message.js.map +1 -1
- package/dist/unstable/cluster/MessageStorage.d.ts +34 -4
- package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/MessageStorage.js +33 -12
- package/dist/unstable/cluster/MessageStorage.js.map +1 -1
- package/dist/unstable/cluster/Reply.d.ts +5 -4
- package/dist/unstable/cluster/Reply.d.ts.map +1 -1
- package/dist/unstable/cluster/Reply.js +21 -12
- package/dist/unstable/cluster/Reply.js.map +1 -1
- package/dist/unstable/cluster/RunnerServer.d.ts +1 -1
- package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerServer.js +12 -6
- package/dist/unstable/cluster/RunnerServer.js.map +1 -1
- package/dist/unstable/cluster/Runners.d.ts +11 -5
- package/dist/unstable/cluster/Runners.d.ts.map +1 -1
- package/dist/unstable/cluster/Runners.js +56 -35
- package/dist/unstable/cluster/Runners.js.map +1 -1
- package/dist/unstable/cluster/Sharding.d.ts +1 -1
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +32 -17
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.js +23 -23
- package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
- package/dist/unstable/cluster/SocketRunner.d.ts +2 -2
- package/dist/unstable/cluster/SocketRunner.d.ts.map +1 -1
- package/dist/unstable/cluster/SocketRunner.js +4 -3
- package/dist/unstable/cluster/SocketRunner.js.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.js +11 -8
- package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.js +11 -4
- package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/unstable/cluster/internal/clusterAbandon.d.ts +5 -0
- package/dist/unstable/cluster/internal/clusterAbandon.d.ts.map +1 -0
- package/dist/unstable/cluster/internal/clusterAbandon.js +9 -0
- package/dist/unstable/cluster/internal/clusterAbandon.js.map +1 -0
- package/dist/unstable/cluster/internal/entityManager.js +10 -6
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/cluster/internal/interruptors.js +30 -1
- package/dist/unstable/cluster/internal/interruptors.js.map +1 -1
- package/dist/unstable/cluster/internal/resourceRef.js +12 -7
- package/dist/unstable/cluster/internal/resourceRef.js.map +1 -1
- package/dist/unstable/devtools/DevToolsClient.d.ts.map +1 -1
- package/dist/unstable/devtools/DevToolsClient.js +12 -7
- package/dist/unstable/devtools/DevToolsClient.js.map +1 -1
- package/dist/unstable/encoding/Ini.d.ts +2 -0
- package/dist/unstable/encoding/Ini.d.ts.map +1 -1
- package/dist/unstable/encoding/Ini.js +2 -0
- package/dist/unstable/encoding/Ini.js.map +1 -1
- package/dist/unstable/encoding/SchemaBinary.d.ts +273 -0
- package/dist/unstable/encoding/SchemaBinary.d.ts.map +1 -0
- package/dist/unstable/encoding/SchemaBinary.js +4573 -0
- package/dist/unstable/encoding/SchemaBinary.js.map +1 -0
- package/dist/unstable/encoding/Sse.js +1 -1
- package/dist/unstable/encoding/Sse.js.map +1 -1
- package/dist/unstable/encoding/Toml.d.ts +2 -0
- package/dist/unstable/encoding/Toml.d.ts.map +1 -1
- package/dist/unstable/encoding/Toml.js +6 -4
- package/dist/unstable/encoding/Toml.js.map +1 -1
- package/dist/unstable/encoding/Yaml.d.ts +2 -0
- package/dist/unstable/encoding/Yaml.d.ts.map +1 -1
- package/dist/unstable/encoding/Yaml.js +16 -5
- package/dist/unstable/encoding/Yaml.js.map +1 -1
- package/dist/unstable/encoding/index.d.ts +2 -2
- package/dist/unstable/encoding/index.d.ts.map +1 -1
- package/dist/unstable/encoding/index.js +2 -2
- package/dist/unstable/encoding/index.js.map +1 -1
- package/dist/unstable/eventlog/Event.d.ts +5 -5
- package/dist/unstable/eventlog/Event.d.ts.map +1 -1
- package/dist/unstable/eventlog/Event.js +3 -3
- package/dist/unstable/eventlog/Event.js.map +1 -1
- package/dist/unstable/eventlog/EventJournal.d.ts +15 -9
- package/dist/unstable/eventlog/EventJournal.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventJournal.js +26 -12
- package/dist/unstable/eventlog/EventJournal.js.map +1 -1
- package/dist/unstable/eventlog/EventLog.d.ts +1 -1
- package/dist/unstable/eventlog/EventLog.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLog.js +13 -9
- package/dist/unstable/eventlog/EventLog.js.map +1 -1
- package/dist/unstable/eventlog/EventLogMessage.d.ts +11 -5
- package/dist/unstable/eventlog/EventLogMessage.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogMessage.js +25 -15
- package/dist/unstable/eventlog/EventLogMessage.js.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.d.ts +7 -1
- package/dist/unstable/eventlog/EventLogRemote.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.js +13 -3
- package/dist/unstable/eventlog/EventLogRemote.js.map +1 -1
- package/dist/unstable/eventlog/EventLogServerUnencrypted.js +2 -2
- package/dist/unstable/eventlog/EventLogServerUnencrypted.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventJournal.d.ts +0 -10
- package/dist/unstable/eventlog/SqlEventJournal.d.ts.map +1 -1
- package/dist/unstable/eventlog/SqlEventJournal.js +29 -14
- package/dist/unstable/eventlog/SqlEventJournal.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.d.ts.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js +5 -1
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js.map +1 -1
- package/dist/unstable/http/Cookies.d.ts +1 -45
- package/dist/unstable/http/Cookies.d.ts.map +1 -1
- package/dist/unstable/http/Cookies.js +2 -64
- package/dist/unstable/http/Cookies.js.map +1 -1
- package/dist/unstable/http/FetchHttpClient.js +1 -1
- package/dist/unstable/http/FetchHttpClient.js.map +1 -1
- package/dist/unstable/http/FindMyWay/internal/router.js +124 -33
- package/dist/unstable/http/FindMyWay/internal/router.js.map +1 -1
- package/dist/unstable/http/FindMyWay.d.ts +15 -5
- package/dist/unstable/http/FindMyWay.d.ts.map +1 -1
- package/dist/unstable/http/FindMyWay.js +3 -1
- package/dist/unstable/http/FindMyWay.js.map +1 -1
- package/dist/unstable/http/Headers.d.ts +0 -22
- package/dist/unstable/http/Headers.d.ts.map +1 -1
- package/dist/unstable/http/Headers.js +3 -34
- package/dist/unstable/http/Headers.js.map +1 -1
- package/dist/unstable/http/HttpBody.d.ts +41 -10
- package/dist/unstable/http/HttpBody.d.ts.map +1 -1
- package/dist/unstable/http/HttpBody.js +64 -10
- package/dist/unstable/http/HttpBody.js.map +1 -1
- package/dist/unstable/http/HttpClient.d.ts +1 -1
- package/dist/unstable/http/HttpClient.d.ts.map +1 -1
- package/dist/unstable/http/HttpClient.js +28 -18
- package/dist/unstable/http/HttpClient.js.map +1 -1
- package/dist/unstable/http/HttpClientRequest.d.ts +28 -6
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.js +8 -19
- package/dist/unstable/http/HttpClientRequest.js.map +1 -1
- package/dist/unstable/http/HttpClientResponse.d.ts +6 -1
- package/dist/unstable/http/HttpClientResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientResponse.js +10 -6
- package/dist/unstable/http/HttpClientResponse.js.map +1 -1
- package/dist/unstable/http/HttpEffect.d.ts +16 -0
- package/dist/unstable/http/HttpEffect.d.ts.map +1 -1
- package/dist/unstable/http/HttpEffect.js +121 -65
- package/dist/unstable/http/HttpEffect.js.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.d.ts +3 -3
- package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.js +1 -13
- package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
- package/dist/unstable/http/HttpMiddleware.d.ts +1 -1
- package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/unstable/http/HttpMiddleware.js +29 -21
- package/dist/unstable/http/HttpMiddleware.js.map +1 -1
- package/dist/unstable/http/HttpPlatform.d.ts +12 -11
- package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
- package/dist/unstable/http/HttpPlatform.js +36 -10
- package/dist/unstable/http/HttpPlatform.js.map +1 -1
- package/dist/unstable/http/HttpRouter.d.ts +5 -1
- package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
- package/dist/unstable/http/HttpRouter.js +22 -8
- package/dist/unstable/http/HttpRouter.js.map +1 -1
- package/dist/unstable/http/HttpServer.d.ts +11 -42
- package/dist/unstable/http/HttpServer.d.ts.map +1 -1
- package/dist/unstable/http/HttpServer.js +16 -20
- package/dist/unstable/http/HttpServer.js.map +1 -1
- package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRequest.js +11 -11
- package/dist/unstable/http/HttpServerRequest.js.map +1 -1
- package/dist/unstable/http/HttpServerRespondable.js +1 -1
- package/dist/unstable/http/HttpServerRespondable.js.map +1 -1
- package/dist/unstable/http/HttpServerResponse.d.ts +9 -13
- package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerResponse.js +34 -44
- package/dist/unstable/http/HttpServerResponse.js.map +1 -1
- package/dist/unstable/http/HttpStaticServer.d.ts +2 -2
- package/dist/unstable/http/HttpStaticServer.d.ts.map +1 -1
- package/dist/unstable/http/HttpStaticServer.js +19 -19
- package/dist/unstable/http/HttpStaticServer.js.map +1 -1
- package/dist/unstable/http/Mime.d.ts +28 -0
- package/dist/unstable/http/Mime.d.ts.map +1 -0
- package/dist/unstable/http/Mime.js +72 -0
- package/dist/unstable/http/Mime.js.map +1 -0
- package/dist/unstable/http/Multipart.d.ts +22 -9
- package/dist/unstable/http/Multipart.d.ts.map +1 -1
- package/dist/unstable/http/Multipart.js +26 -10
- package/dist/unstable/http/Multipart.js.map +1 -1
- package/dist/unstable/http/MultipartParser/internal/multipart.d.ts +1 -1
- package/dist/unstable/http/MultipartParser/internal/multipart.d.ts.map +1 -1
- package/dist/unstable/http/MultipartParser/internal/multipart.js +8 -3
- package/dist/unstable/http/MultipartParser/internal/multipart.js.map +1 -1
- package/dist/unstable/http/MultipartParser.d.ts +4 -3
- package/dist/unstable/http/MultipartParser.d.ts.map +1 -1
- package/dist/unstable/http/MultipartParser.js.map +1 -1
- package/dist/unstable/http/UrlParams.d.ts +0 -97
- package/dist/unstable/http/UrlParams.d.ts.map +1 -1
- package/dist/unstable/http/UrlParams.js +3 -104
- package/dist/unstable/http/UrlParams.js.map +1 -1
- package/dist/unstable/http/index.d.ts +4 -0
- package/dist/unstable/http/index.d.ts.map +1 -1
- package/dist/unstable/http/index.js +4 -0
- package/dist/unstable/http/index.js.map +1 -1
- package/dist/unstable/http/internal/compression.js +8 -11
- package/dist/unstable/http/internal/compression.js.map +1 -1
- package/dist/unstable/http/internal/headers.d.ts +2 -0
- package/dist/unstable/http/internal/headers.d.ts.map +1 -0
- package/dist/unstable/http/internal/headers.js +5 -0
- package/dist/unstable/http/internal/headers.js.map +1 -0
- package/dist/unstable/http/internal/httpBody.js +8 -0
- package/dist/unstable/http/internal/httpBody.js.map +1 -1
- package/dist/unstable/http/internal/mimeTypes.d.ts +361 -0
- package/dist/unstable/http/internal/mimeTypes.d.ts.map +1 -0
- package/dist/unstable/http/internal/mimeTypes.js +363 -0
- package/dist/unstable/http/internal/mimeTypes.js.map +1 -0
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts +13 -0
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +28 -11
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.d.ts +4 -3
- package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.js +25 -13
- package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +8 -3
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.js +9 -6
- package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.js +3 -1
- package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.js +7 -5
- package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.js +15 -12
- package/dist/unstable/httpapi/HttpApiScalar.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.d.ts +12 -0
- package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.js +8 -10
- package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSwagger.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSwagger.js +6 -3
- package/dist/unstable/httpapi/HttpApiSwagger.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiTest.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiTest.js +8 -2
- package/dist/unstable/httpapi/HttpApiTest.js.map +1 -1
- package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/OpenApi.js +31 -20
- package/dist/unstable/httpapi/OpenApi.js.map +1 -1
- package/dist/unstable/net/IpInterface.d.ts +140 -0
- package/dist/unstable/net/IpInterface.d.ts.map +1 -0
- package/dist/unstable/net/IpInterface.js +149 -0
- package/dist/unstable/net/IpInterface.js.map +1 -0
- package/dist/unstable/net/IpNetwork.d.ts +227 -0
- package/dist/unstable/net/IpNetwork.d.ts.map +1 -0
- package/dist/unstable/net/IpNetwork.js +239 -0
- package/dist/unstable/net/IpNetwork.js.map +1 -0
- package/dist/unstable/net/NetAddress.d.ts +705 -0
- package/dist/unstable/net/NetAddress.d.ts.map +1 -0
- package/dist/unstable/net/NetAddress.js +956 -0
- package/dist/unstable/net/NetAddress.js.map +1 -0
- package/dist/unstable/net/index.d.ts +16 -0
- package/dist/unstable/net/index.d.ts.map +1 -0
- package/dist/unstable/net/index.js +17 -0
- package/dist/unstable/net/index.js.map +1 -0
- package/dist/unstable/observability/OtlpExporter.d.ts +1 -0
- package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.js +4 -6
- package/dist/unstable/observability/OtlpExporter.js.map +1 -1
- package/dist/unstable/observability/OtlpLogger.js +9 -9
- package/dist/unstable/observability/OtlpLogger.js.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.js +9 -8
- package/dist/unstable/observability/OtlpMetrics.js.map +1 -1
- package/dist/unstable/observability/OtlpResource.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpResource.js +2 -2
- package/dist/unstable/observability/OtlpResource.js.map +1 -1
- package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpTracer.js +82 -55
- package/dist/unstable/observability/OtlpTracer.js.map +1 -1
- package/dist/unstable/observability/internal/otlpEnv.d.ts +1 -1
- package/dist/unstable/observability/internal/otlpEnv.d.ts.map +1 -1
- package/dist/unstable/observability/internal/otlpEnv.js +5 -9
- package/dist/unstable/observability/internal/otlpEnv.js.map +1 -1
- package/dist/unstable/persistence/PersistedCache.js +1 -1
- package/dist/unstable/persistence/PersistedCache.js.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.d.ts +114 -14
- package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.js +799 -234
- package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
- package/dist/unstable/persistence/RateLimiter.d.ts +28 -15
- package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
- package/dist/unstable/persistence/RateLimiter.js +33 -41
- package/dist/unstable/persistence/RateLimiter.js.map +1 -1
- package/dist/unstable/process/ChildProcess.d.ts +8 -2
- package/dist/unstable/process/ChildProcess.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcess.js +7 -2
- package/dist/unstable/process/ChildProcess.js.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.d.ts +1 -1
- package/dist/unstable/process/ChildProcessSpawner.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.js +1 -1
- package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +6 -3
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts +3 -6
- package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.js +6 -3
- package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.js +2 -3
- package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.d.ts +2 -2
- package/dist/unstable/reactivity/AtomRpc.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.js +1 -1
- package/dist/unstable/reactivity/AtomRpc.js.map +1 -1
- package/dist/unstable/reactivity/Hydration.d.ts +6 -4
- package/dist/unstable/reactivity/Hydration.d.ts.map +1 -1
- package/dist/unstable/reactivity/Hydration.js +20 -6
- package/dist/unstable/reactivity/Hydration.js.map +1 -1
- package/dist/unstable/reactivity/Reactivity.d.ts +26 -26
- package/dist/unstable/reactivity/Reactivity.d.ts.map +1 -1
- package/dist/unstable/reactivity/Reactivity.js +10 -12
- package/dist/unstable/reactivity/Reactivity.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts +5 -0
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +94 -81
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/rpc/RpcClientError.d.ts +1 -1
- package/dist/unstable/rpc/RpcMessage.d.ts +66 -7
- package/dist/unstable/rpc/RpcMessage.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMessage.js +68 -9
- package/dist/unstable/rpc/RpcMessage.js.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.js +7 -5
- package/dist/unstable/rpc/RpcMiddleware.js.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.d.ts +28 -33
- package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.js +56 -92
- package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts +25 -0
- package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +125 -68
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/schema/Model.d.ts.map +1 -1
- package/dist/unstable/schema/Model.js +7 -6
- package/dist/unstable/schema/Model.js.map +1 -1
- package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
- package/dist/unstable/schema/VariantSchema.js +3 -0
- package/dist/unstable/schema/VariantSchema.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts +287 -102
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +408 -215
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/dist/unstable/socket/SocketServer.d.ts +5 -32
- package/dist/unstable/socket/SocketServer.d.ts.map +1 -1
- package/dist/unstable/socket/SocketServer.js +3 -3
- package/dist/unstable/socket/SocketServer.js.map +1 -1
- package/dist/unstable/sql/SqlClient.d.ts +20 -0
- package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
- package/dist/unstable/sql/SqlClient.js +14 -7
- package/dist/unstable/sql/SqlClient.js.map +1 -1
- package/dist/unstable/sql/SqlConnection.d.ts +15 -0
- package/dist/unstable/sql/SqlConnection.d.ts.map +1 -1
- package/dist/unstable/sql/SqlConnection.js.map +1 -1
- package/dist/unstable/sql/SqlModel.d.ts +1 -1
- package/dist/unstable/sql/SqlModel.d.ts.map +1 -1
- package/dist/unstable/sql/Statement.d.ts +13 -5
- package/dist/unstable/sql/Statement.d.ts.map +1 -1
- package/dist/unstable/sql/Statement.js +29 -15
- package/dist/unstable/sql/Statement.js.map +1 -1
- package/dist/unstable/workers/Transferable.js +1 -1
- package/dist/unstable/workers/Worker.d.ts.map +1 -1
- package/dist/unstable/workers/Worker.js +3 -1
- package/dist/unstable/workers/Worker.js.map +1 -1
- package/dist/unstable/workflow/Activity.d.ts +7 -0
- package/dist/unstable/workflow/Activity.d.ts.map +1 -1
- package/dist/unstable/workflow/Activity.js +14 -4
- package/dist/unstable/workflow/Activity.js.map +1 -1
- package/dist/unstable/workflow/DurableClock.js +1 -1
- package/dist/unstable/workflow/DurableClock.js.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.d.ts +2 -2
- package/dist/unstable/workflow/DurableDeferred.d.ts.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
- package/dist/unstable/workflow/DurableQueue.d.ts +8 -0
- package/dist/unstable/workflow/DurableQueue.d.ts.map +1 -1
- package/dist/unstable/workflow/DurableQueue.js +8 -0
- package/dist/unstable/workflow/DurableQueue.js.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts +5 -0
- package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
- package/dist/unstable/workflow/Workflow.js +70 -12
- package/dist/unstable/workflow/Workflow.js.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts +6 -0
- package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js +11 -0
- package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
- package/dist/unstable/workflow/WorkflowProxy.d.ts +2 -2
- package/dist/unstable/workflow/WorkflowProxy.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowProxy.js +4 -2
- package/dist/unstable/workflow/WorkflowProxy.js.map +1 -1
- package/package.json +8 -10
- package/src/Array.ts +142 -70
- package/src/BigDecimal.ts +50 -28
- package/src/ByteSize.ts +838 -0
- package/src/Cache.ts +17 -3
- package/src/Cause.ts +1 -1
- package/src/Channel.ts +185 -50
- package/src/Chunk.ts +65 -36
- package/src/Config.ts +237 -248
- package/src/ConfigProvider.ts +7 -8
- package/src/Context.ts +31 -0
- package/src/Cron.ts +2 -2
- package/src/Crypto.ts +3 -2
- package/src/Deferred.ts +7 -6
- package/src/Duration.ts +1 -1
- package/src/Effect.ts +226 -122
- package/src/Effectable.ts +78 -9
- package/src/Encoding.ts +101 -11
- package/src/Equal.ts +1 -1
- package/src/ExecutionPlan.ts +3 -0
- package/src/Fiber.ts +33 -8
- package/src/FiberHandle.ts +3 -3
- package/src/FiberMap.ts +19 -10
- package/src/FileSystem.ts +55 -230
- package/src/Formatter.ts +21 -3
- package/src/Graph.ts +55 -25
- package/src/Hash.ts +5 -16
- package/src/HashRing.ts +9 -2
- package/src/HashSet.ts +56 -0
- package/src/Iterable.ts +90 -44
- package/src/JsonPatch.ts +4 -4
- package/src/JsonPointer.ts +97 -4
- package/src/JsonSchema.ts +998 -476
- package/src/Layer.ts +59 -18
- package/src/LayerMap.ts +38 -6
- package/src/LayerRef.ts +7 -5
- package/src/Logger.ts +125 -18
- package/src/ManagedRuntime.ts +1 -1
- package/src/Match.ts +33 -14
- package/src/Metric.ts +24 -21
- package/src/MutableHashMap.ts +1 -1
- package/src/MutableHashSet.ts +1 -1
- package/src/MutableList.ts +18 -2
- package/src/Number.ts +7 -1
- package/src/Optic.ts +8 -4
- package/src/Option.ts +1 -1
- package/src/Order.ts +3 -1
- package/src/PartitionedSemaphore.ts +1 -2
- package/src/Path.ts +1 -1
- package/src/PlatformError.ts +1 -1
- package/src/Pool.ts +535 -134
- package/src/PrimaryKey.ts +1 -1
- package/src/PubSub.ts +32 -20
- package/src/Queue.ts +119 -28
- package/src/Random.ts +20 -6
- package/src/RcMap.ts +176 -13
- package/src/Record.ts +15 -0
- package/src/Redacted.ts +1 -1
- package/src/RequestResolver.ts +49 -26
- package/src/Result.ts +1 -1
- package/src/Scheduler.ts +21 -11
- package/src/Schema.ts +5032 -6518
- package/src/SchemaAST.ts +1156 -316
- package/src/SchemaGetter.ts +75 -21
- package/src/SchemaIssue.ts +260 -16
- package/src/SchemaParser.ts +2 -12
- package/src/SchemaRepresentation.ts +1774 -189
- package/src/SchemaTransformation.ts +145 -22
- package/src/Scope.ts +9 -2
- package/src/ScopedCache.ts +10 -3
- package/src/Sink.ts +31 -15
- package/src/StandardSchema.ts +207 -0
- package/src/Stream.ts +294 -76
- package/src/String.ts +20 -9
- package/src/Struct.ts +8 -4
- package/src/SynchronizedRef.ts +3 -5
- package/src/Terminal.ts +3 -3
- package/src/Tracer.ts +43 -14
- package/src/Tuple.ts +3 -1
- package/src/TxChunk.ts +1 -1
- package/src/TxDeferred.ts +1 -1
- package/src/TxHashMap.ts +1 -1
- package/src/TxHashSet.ts +92 -11
- package/src/TxPriorityQueue.ts +1 -1
- package/src/TxPubSub.ts +1 -1
- package/src/TxQueue.ts +22 -17
- package/src/TxReentrantLock.ts +29 -1
- package/src/TxRef.ts +1 -1
- package/src/TxSemaphore.ts +1 -1
- package/src/TxSubscriptionRef.ts +1 -1
- package/src/Types.ts +40 -17
- package/src/Utils.ts +3 -1
- package/src/index.ts +10 -0
- package/src/internal/arbitrary/model.ts +701 -0
- package/src/internal/arbitrary/regexp.ts +855 -0
- package/src/internal/arbitrary/runner.ts +608 -0
- package/src/internal/arbitrary/schema.ts +1800 -0
- package/src/internal/core.ts +48 -22
- package/src/internal/count.ts +14 -0
- package/src/internal/dateTime.ts +8 -10
- package/src/internal/effect.ts +510 -301
- package/src/internal/graph.ts +6 -1
- package/src/internal/hashMap.ts +5 -3
- package/src/internal/hashSet.ts +1 -1
- package/src/internal/matcher.ts +34 -19
- package/src/internal/metric.ts +1 -1
- package/src/internal/option.ts +8 -6
- package/src/internal/random.ts +20 -7
- package/src/internal/rcRef.ts +10 -7
- package/src/internal/references.ts +1 -0
- package/src/internal/request.ts +12 -7
- package/src/internal/result.ts +15 -11
- package/src/internal/schema/annotations.ts +3 -3
- package/src/internal/schema/fromJsonSchemaDocument.ts +326 -160
- package/src/internal/schema/fromRepresentation.ts +5 -3
- package/src/internal/schema/{schema.ts → make.ts} +0 -40
- package/src/internal/schema/parser.ts +8 -0
- package/src/internal/schema/standardSchema.ts +125 -0
- package/src/internal/schema/toCodeDocument.ts +58 -44
- package/src/internal/schema/toCodec.ts +312 -0
- package/src/internal/schema/toDifferJsonPatch.ts +24 -0
- package/src/internal/schema/toEncoderXml.ts +110 -0
- package/src/internal/schema/toEquivalence.ts +76 -0
- package/src/internal/schema/toFormatter.ts +230 -0
- package/src/internal/schema/toIso.ts +20 -0
- package/src/internal/schema/toJsonSchemaDocument.ts +125 -67
- package/src/internal/schema/toRepresentation.ts +1 -1
- package/src/internal/schemaError.ts +8 -0
- package/src/internal/stream.ts +14 -6
- package/src/internal/tracer.ts +4 -0
- package/src/internal/trie.ts +5 -2
- package/src/internal/uuid.ts +4 -0
- package/src/testing/TestSchema.ts +36 -30
- package/src/testing/index.ts +0 -5
- package/src/unstable/ai/AiError.ts +126 -6
- package/src/unstable/ai/AnthropicStructuredOutput.ts +8 -5
- package/src/unstable/ai/Chat.ts +35 -36
- package/src/unstable/ai/EmbeddingModel.ts +27 -15
- package/src/unstable/ai/LanguageModel.ts +283 -100
- package/src/unstable/ai/McpServer.ts +105 -92
- package/src/unstable/ai/OpenAiStructuredOutput.ts +6 -3
- package/src/unstable/ai/Prompt.ts +20 -5
- package/src/unstable/ai/Response.ts +107 -189
- package/src/unstable/ai/Tokenizer.ts +4 -5
- package/src/unstable/ai/Tool.ts +58 -35
- package/src/unstable/ai/Toolkit.ts +43 -37
- package/src/unstable/ai/internal/codec-transformer.ts +3 -2
- package/src/unstable/ai/internal/structured-output.ts +29 -6
- package/src/unstable/arbitrary/Arbitrary.ts +715 -0
- package/src/unstable/arbitrary/index.ts +10 -0
- package/src/unstable/cli/Argument.ts +111 -115
- package/src/unstable/cli/CliError.ts +2 -0
- package/src/unstable/cli/CliOutput.ts +41 -4
- package/src/unstable/cli/Command.ts +79 -78
- package/src/unstable/cli/Completions.ts +4 -4
- package/src/unstable/cli/Flag.ts +158 -169
- package/src/unstable/cli/GlobalFlag.ts +13 -13
- package/src/unstable/cli/Param.ts +150 -159
- package/src/unstable/cli/Primitive.ts +75 -76
- package/src/unstable/cli/Prompt.ts +543 -408
- package/src/unstable/cli/internal/completions/bash.ts +113 -38
- package/src/unstable/cli/internal/completions/descriptor.ts +23 -11
- package/src/unstable/cli/internal/completions/fish.ts +17 -9
- package/src/unstable/cli/internal/completions/zsh.ts +7 -4
- package/src/unstable/cli/internal/config.ts +4 -4
- package/src/unstable/cli/internal/parser.ts +1 -1
- package/src/unstable/cli/internal/wizard.ts +60 -32
- package/src/unstable/cluster/ClusterSchema.ts +19 -1
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +66 -16
- package/src/unstable/cluster/Entity.ts +3 -0
- package/src/unstable/cluster/EntityProxyServer.ts +6 -2
- package/src/unstable/cluster/Envelope.ts +32 -3
- package/src/unstable/cluster/HttpRunner.ts +52 -25
- package/src/unstable/cluster/Message.ts +35 -13
- package/src/unstable/cluster/MessageStorage.ts +69 -24
- package/src/unstable/cluster/Reply.ts +36 -19
- package/src/unstable/cluster/RunnerServer.ts +21 -11
- package/src/unstable/cluster/Runners.ts +93 -80
- package/src/unstable/cluster/Sharding.ts +44 -19
- package/src/unstable/cluster/ShardingConfig.ts +23 -23
- package/src/unstable/cluster/SocketRunner.ts +5 -4
- package/src/unstable/cluster/SqlMessageStorage.ts +12 -8
- package/src/unstable/cluster/SqlRunnerStorage.ts +18 -10
- package/src/unstable/cluster/internal/clusterAbandon.ts +14 -0
- package/src/unstable/cluster/internal/entityManager.ts +15 -6
- package/src/unstable/cluster/internal/interruptors.ts +58 -1
- package/src/unstable/cluster/internal/resourceRef.ts +15 -7
- package/src/unstable/devtools/DevToolsClient.ts +13 -3
- package/src/unstable/encoding/Ini.ts +2 -0
- package/src/unstable/encoding/SchemaBinary.ts +5308 -0
- package/src/unstable/encoding/Sse.ts +1 -1
- package/src/unstable/encoding/Toml.ts +7 -5
- package/src/unstable/encoding/Yaml.ts +18 -5
- package/src/unstable/encoding/index.ts +2 -2
- package/src/unstable/eventlog/Event.ts +7 -7
- package/src/unstable/eventlog/EventJournal.ts +22 -15
- package/src/unstable/eventlog/EventLog.ts +24 -14
- package/src/unstable/eventlog/EventLogMessage.ts +25 -15
- package/src/unstable/eventlog/EventLogRemote.ts +15 -4
- package/src/unstable/eventlog/EventLogServerUnencrypted.ts +2 -2
- package/src/unstable/eventlog/SqlEventJournal.ts +35 -10
- package/src/unstable/eventlog/SqlEventLogServerUnencrypted.ts +11 -1
- package/src/unstable/http/Cookies.ts +2 -102
- package/src/unstable/http/FetchHttpClient.ts +1 -1
- package/src/unstable/http/FindMyWay/internal/router.ts +139 -33
- package/src/unstable/http/FindMyWay.ts +15 -5
- package/src/unstable/http/Headers.ts +3 -48
- package/src/unstable/http/HttpBody.ts +107 -36
- package/src/unstable/http/HttpClient.ts +41 -30
- package/src/unstable/http/HttpClientRequest.ts +32 -18
- package/src/unstable/http/HttpClientResponse.ts +16 -3
- package/src/unstable/http/HttpEffect.ts +145 -73
- package/src/unstable/http/HttpIncomingMessage.ts +4 -4
- package/src/unstable/http/HttpMiddleware.ts +43 -24
- package/src/unstable/http/HttpPlatform.ts +62 -20
- package/src/unstable/http/HttpRouter.ts +27 -16
- package/src/unstable/http/HttpServer.ts +18 -57
- package/src/unstable/http/HttpServerRequest.ts +17 -15
- package/src/unstable/http/HttpServerRespondable.ts +1 -1
- package/src/unstable/http/HttpServerResponse.ts +49 -40
- package/src/unstable/http/HttpStaticServer.ts +30 -28
- package/src/unstable/http/Mime.ts +76 -0
- package/src/unstable/http/Multipart.ts +35 -18
- package/src/unstable/http/MultipartParser/internal/multipart.ts +10 -3
- package/src/unstable/http/MultipartParser.ts +4 -3
- package/src/unstable/http/UrlParams.ts +3 -161
- package/src/unstable/http/index.ts +5 -0
- package/src/unstable/http/internal/compression.ts +11 -12
- package/src/unstable/http/internal/headers.ts +7 -0
- package/src/unstable/http/internal/httpBody.ts +9 -0
- package/src/unstable/http/internal/mimeTypes.ts +395 -0
- package/src/unstable/httpapi/HttpApiBuilder.ts +63 -11
- package/src/unstable/httpapi/HttpApiClient.ts +44 -24
- package/src/unstable/httpapi/HttpApiEndpoint.ts +24 -11
- package/src/unstable/httpapi/HttpApiError.ts +3 -1
- package/src/unstable/httpapi/HttpApiMiddleware.ts +7 -5
- package/src/unstable/httpapi/HttpApiScalar.ts +30 -27
- package/src/unstable/httpapi/HttpApiSchema.ts +14 -7
- package/src/unstable/httpapi/HttpApiSwagger.ts +6 -3
- package/src/unstable/httpapi/HttpApiTest.ts +6 -1
- package/src/unstable/httpapi/OpenApi.ts +32 -22
- package/src/unstable/net/IpInterface.ts +242 -0
- package/src/unstable/net/IpNetwork.ts +357 -0
- package/src/unstable/net/NetAddress.ts +1271 -0
- package/src/unstable/net/index.ts +20 -0
- package/src/unstable/observability/OtlpExporter.ts +5 -6
- package/src/unstable/observability/OtlpLogger.ts +9 -9
- package/src/unstable/observability/OtlpMetrics.ts +9 -8
- package/src/unstable/observability/OtlpResource.ts +5 -4
- package/src/unstable/observability/OtlpTracer.ts +103 -81
- package/src/unstable/observability/internal/otlpEnv.ts +10 -13
- package/src/unstable/persistence/PersistedCache.ts +1 -1
- package/src/unstable/persistence/PersistedQueue.ts +1100 -291
- package/src/unstable/persistence/RateLimiter.ts +64 -58
- package/src/unstable/process/ChildProcess.ts +15 -4
- package/src/unstable/process/ChildProcessSpawner.ts +1 -1
- package/src/unstable/reactivity/Atom.ts +6 -3
- package/src/unstable/reactivity/AtomHttpApi.ts +21 -10
- package/src/unstable/reactivity/AtomRegistry.ts +2 -4
- package/src/unstable/reactivity/AtomRpc.ts +6 -5
- package/src/unstable/reactivity/Hydration.ts +26 -7
- package/src/unstable/reactivity/Reactivity.ts +49 -36
- package/src/unstable/rpc/RpcClient.ts +100 -82
- package/src/unstable/rpc/RpcMessage.ts +78 -11
- package/src/unstable/rpc/RpcMiddleware.ts +7 -5
- package/src/unstable/rpc/RpcSerialization.ts +82 -92
- package/src/unstable/rpc/RpcServer.ts +171 -93
- package/src/unstable/schema/Model.ts +8 -7
- package/src/unstable/schema/VariantSchema.ts +3 -0
- package/src/unstable/socket/Socket.ts +714 -383
- package/src/unstable/socket/SocketServer.ts +5 -35
- package/src/unstable/sql/SqlClient.ts +42 -7
- package/src/unstable/sql/SqlConnection.ts +18 -0
- package/src/unstable/sql/SqlModel.ts +1 -1
- package/src/unstable/sql/Statement.ts +46 -20
- package/src/unstable/workers/Transferable.ts +1 -1
- package/src/unstable/workers/Worker.ts +3 -1
- package/src/unstable/workflow/Activity.ts +20 -9
- package/src/unstable/workflow/DurableClock.ts +1 -1
- package/src/unstable/workflow/DurableDeferred.ts +6 -0
- package/src/unstable/workflow/DurableQueue.ts +8 -0
- package/src/unstable/workflow/Workflow.ts +105 -28
- package/src/unstable/workflow/WorkflowEngine.ts +22 -0
- package/src/unstable/workflow/WorkflowProxy.ts +8 -4
- package/dist/internal/schema/schema.d.ts.map +0 -1
- package/dist/internal/schema/schema.js.map +0 -1
- package/dist/internal/schema/toArbitrary.d.ts +0 -2
- package/dist/internal/schema/toArbitrary.d.ts.map +0 -1
- package/dist/internal/schema/toArbitrary.js +0 -705
- package/dist/internal/schema/toArbitrary.js.map +0 -1
- package/dist/testing/FastCheck.d.ts +0 -90
- package/dist/testing/FastCheck.d.ts.map +0 -1
- package/dist/testing/FastCheck.js +0 -90
- package/dist/testing/FastCheck.js.map +0 -1
- package/dist/unstable/encoding/Msgpack.d.ts +0 -185
- package/dist/unstable/encoding/Msgpack.d.ts.map +0 -1
- package/dist/unstable/encoding/Msgpack.js +0 -227
- package/dist/unstable/encoding/Msgpack.js.map +0 -1
- package/src/internal/schema/toArbitrary.ts +0 -843
- package/src/testing/FastCheck.ts +0 -90
- package/src/unstable/encoding/Msgpack.ts +0 -432
- /package/dist/internal/{schema → arbitrary}/schema.d.ts +0 -0
package/src/JsonSchema.ts
CHANGED
|
@@ -4,15 +4,13 @@
|
|
|
4
4
|
* OpenAPI 3.0, and OpenAPI 3.1; conversions normalize through
|
|
5
5
|
* `Document<"draft-2020-12">` before emitting another dialect, including
|
|
6
6
|
* JSON Schema Draft-04. The module also defines document types, meta-schema
|
|
7
|
-
* constants, OpenAPI component-key helpers
|
|
7
|
+
* constants, and OpenAPI component-key helpers.
|
|
8
8
|
*
|
|
9
9
|
* @since 4.0.0
|
|
10
10
|
*/
|
|
11
|
-
import * as Arr from "./Array.ts"
|
|
12
11
|
import * as InternalRecord from "./internal/record.ts"
|
|
13
|
-
import {
|
|
12
|
+
import { formatUriFragment, parseUriFragment } from "./JsonPointer.ts"
|
|
14
13
|
import * as Predicate from "./Predicate.ts"
|
|
15
|
-
import * as Rec from "./Record.ts"
|
|
16
14
|
|
|
17
15
|
/**
|
|
18
16
|
* A plain object representing a single JSON Schema node.
|
|
@@ -83,8 +81,6 @@ export type Type = "string" | "number" | "boolean" | "array" | "object" | "null"
|
|
|
83
81
|
*
|
|
84
82
|
* @see {@link Document} for a single root schema with definitions
|
|
85
83
|
* @see {@link MultiDocument} for multiple root schemas sharing definitions
|
|
86
|
-
* @see {@link resolve$ref} for resolving a `$ref` against definitions
|
|
87
|
-
*
|
|
88
84
|
* @category models
|
|
89
85
|
* @since 4.0.0
|
|
90
86
|
*/
|
|
@@ -215,47 +211,20 @@ export const META_SCHEMA_URI_DRAFT_07 = "http://json-schema.org/draft-07/schema#
|
|
|
215
211
|
*/
|
|
216
212
|
export const META_SCHEMA_URI_DRAFT_2020_12 = "https://json-schema.org/draft/2020-12/schema"
|
|
217
213
|
|
|
218
|
-
const
|
|
219
|
-
const RE_DEFS = /^#\/\$defs(?=\/|$)/
|
|
220
|
-
const RE_COMPONENTS_SCHEMAS = /^#\/components\/schemas(?=\/|$)/
|
|
221
|
-
|
|
222
|
-
const DRAFT_04_COPY_KEYWORDS = new Set([
|
|
223
|
-
"$ref",
|
|
224
|
-
"type",
|
|
225
|
-
"required",
|
|
226
|
-
"enum",
|
|
227
|
-
"title",
|
|
228
|
-
"description",
|
|
229
|
-
"default",
|
|
230
|
-
"format",
|
|
231
|
-
"pattern",
|
|
232
|
-
"minLength",
|
|
233
|
-
"maxLength",
|
|
234
|
-
"minItems",
|
|
235
|
-
"maxItems",
|
|
236
|
-
"minProperties",
|
|
237
|
-
"maxProperties",
|
|
238
|
-
"multipleOf",
|
|
239
|
-
"uniqueItems"
|
|
240
|
-
])
|
|
214
|
+
const META_SCHEMA_URI_OPEN_API_3_1 = "https://spec.openapis.org/oas/3.1/dialect/base"
|
|
241
215
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
"examples",
|
|
246
|
-
"readOnly",
|
|
247
|
-
"writeOnly",
|
|
248
|
-
"minimum",
|
|
249
|
-
"maximum",
|
|
250
|
-
"exclusiveMinimum",
|
|
251
|
-
"exclusiveMaximum"
|
|
252
|
-
])
|
|
216
|
+
function isMetaSchemaUri(value: unknown, uri: string): boolean {
|
|
217
|
+
return value === uri || value === (uri.endsWith("#") ? uri.slice(0, -1) : `${uri}#`)
|
|
218
|
+
}
|
|
253
219
|
|
|
254
|
-
|
|
255
|
-
const
|
|
220
|
+
function rewriteOpenApiComponentsReference(reference: string): string {
|
|
221
|
+
const path = reference.startsWith("#") ? parseUriFragment(reference) : undefined
|
|
222
|
+
return path !== undefined && path[0] === "components" && path[1] === "schemas"
|
|
223
|
+
? formatUriFragment(["$defs", ...path.slice(2)])
|
|
224
|
+
: reference
|
|
225
|
+
}
|
|
256
226
|
|
|
257
|
-
const
|
|
258
|
-
const ARRAY_SUBSCHEMA_KEYWORDS = new Set(["allOf", "anyOf", "oneOf"])
|
|
227
|
+
const OPEN_API_31_TARGET_COLLISIONS = ["example", "discriminator", "xml", "externalDocs"]
|
|
259
228
|
|
|
260
229
|
/**
|
|
261
230
|
* Parses a raw Draft-07 JSON Schema into a `Document<"draft-2020-12">`.
|
|
@@ -268,13 +237,21 @@ const ARRAY_SUBSCHEMA_KEYWORDS = new Set(["allOf", "anyOf", "oneOf"])
|
|
|
268
237
|
* **Details**
|
|
269
238
|
*
|
|
270
239
|
* This converts Draft-07 tuple syntax (`items` as array plus
|
|
271
|
-
* `additionalItems`) to Draft-2020-12 form (`prefixItems` plus `items`),
|
|
272
|
-
*
|
|
273
|
-
* `
|
|
240
|
+
* `additionalItems`) to Draft-2020-12 form (`prefixItems` plus `items`), splits
|
|
241
|
+
* `dependencies` into `dependentRequired` and `dependentSchemas`, converts
|
|
242
|
+
* plain-name `$id` fragments to `$anchor`, and extracts root-level
|
|
243
|
+
* `definitions` into the `definitions` field. Local JSON Pointer refs are
|
|
244
|
+
* relocated when one of these structural conversions moves its target.
|
|
274
245
|
*
|
|
275
246
|
* **Gotchas**
|
|
276
247
|
*
|
|
277
|
-
*
|
|
248
|
+
* Unknown and custom keywords are copied as opaque values. Their contents are
|
|
249
|
+
* not treated as nested schemas. Draft-07 keywords such as `if` / `then` /
|
|
250
|
+
* `else` and `contains` are preserved and their subschemas are converted.
|
|
251
|
+
* Siblings of a valid Draft-07 `$ref` are ignored according to Draft-07
|
|
252
|
+
* semantics. The conversion throws when a Draft-07 `$id` fragment cannot be
|
|
253
|
+
* represented as a Draft-2020-12 `$anchor`, or when an unknown Draft-07
|
|
254
|
+
* keyword would become an active Draft-2020-12 keyword after copying.
|
|
278
255
|
*
|
|
279
256
|
* **Example** (Parsing a Draft-07 schema)
|
|
280
257
|
*
|
|
@@ -303,76 +280,7 @@ const ARRAY_SUBSCHEMA_KEYWORDS = new Set(["allOf", "anyOf", "oneOf"])
|
|
|
303
280
|
* @since 4.0.0
|
|
304
281
|
*/
|
|
305
282
|
export function fromSchemaDraft07(js: JsonSchema): Document<"draft-2020-12"> {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
const schema = walk(js, true) as JsonSchema
|
|
309
|
-
return {
|
|
310
|
-
dialect: "draft-2020-12",
|
|
311
|
-
schema,
|
|
312
|
-
definitions: definitions ?? {}
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
function walk(node: unknown, isRoot: boolean): unknown {
|
|
316
|
-
if (Array.isArray(node)) return node.map(walkNested)
|
|
317
|
-
if (!Predicate.isObject(node)) return node
|
|
318
|
-
|
|
319
|
-
const out: Record<string, unknown> = {}
|
|
320
|
-
|
|
321
|
-
let prefixItems: unknown = undefined
|
|
322
|
-
let additionalItems: unknown = undefined
|
|
323
|
-
|
|
324
|
-
for (const k of Object.keys(node)) {
|
|
325
|
-
const v = node[k]
|
|
326
|
-
|
|
327
|
-
if (k === "$ref") {
|
|
328
|
-
out.$ref = typeof v === "string" ? v.replace(RE_DEFINITIONS, "#/$defs") : v
|
|
329
|
-
continue
|
|
330
|
-
}
|
|
331
|
-
if (DRAFT_07_COPY_KEYWORDS.has(k)) {
|
|
332
|
-
out[k] = v
|
|
333
|
-
continue
|
|
334
|
-
}
|
|
335
|
-
if (rewriteSubschemaKeyword(out, k, v, walkNested, DRAFT_07_SINGLE_SUBSCHEMA_KEYWORDS)) continue
|
|
336
|
-
|
|
337
|
-
switch (k) {
|
|
338
|
-
case "definitions": {
|
|
339
|
-
const mapped = mapObject(v, walkNested)
|
|
340
|
-
if (isRoot) {
|
|
341
|
-
definitions = mapped as Definitions | undefined
|
|
342
|
-
} else {
|
|
343
|
-
out.definitions = mapped ?? v
|
|
344
|
-
}
|
|
345
|
-
break
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
case "items":
|
|
349
|
-
prefixItems = v
|
|
350
|
-
break
|
|
351
|
-
case "additionalItems":
|
|
352
|
-
additionalItems = v
|
|
353
|
-
break
|
|
354
|
-
|
|
355
|
-
default:
|
|
356
|
-
break
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
// Draft-07 tuples -> 2020-12 tuples
|
|
361
|
-
if (prefixItems !== undefined) {
|
|
362
|
-
if (Array.isArray(prefixItems)) {
|
|
363
|
-
out.prefixItems = prefixItems.map(walkNested)
|
|
364
|
-
if (additionalItems !== undefined) out.items = walkNested(additionalItems)
|
|
365
|
-
} else {
|
|
366
|
-
out.items = walkNested(prefixItems)
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
return out
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
function walkNested(node: unknown): unknown {
|
|
374
|
-
return walk(node, false)
|
|
375
|
-
}
|
|
283
|
+
return fromSchemaDraft2020_12(convertDraft07(js))
|
|
376
284
|
}
|
|
377
285
|
|
|
378
286
|
/**
|
|
@@ -427,8 +335,17 @@ export function fromSchemaDraft2020_12(js: JsonSchema): Document<"draft-2020-12"
|
|
|
427
335
|
*
|
|
428
336
|
* **Details**
|
|
429
337
|
*
|
|
430
|
-
* This rewrites `#/components/schemas/...` refs to `#/$defs/...`,
|
|
431
|
-
* to
|
|
338
|
+
* This rewrites `#/components/schemas/...` refs to `#/$defs/...`, normalizes the
|
|
339
|
+
* OpenAPI base dialect URI to Draft 2020-12, converts the deprecated singular
|
|
340
|
+
* `example` field to `examples`, then delegates to
|
|
341
|
+
* {@link fromSchemaDraft2020_12}.
|
|
342
|
+
*
|
|
343
|
+
* **Gotchas**
|
|
344
|
+
*
|
|
345
|
+
* When both `example` and `examples` are present, the singular example is
|
|
346
|
+
* prepended to the array. Custom `$schema` dialect URIs and unknown keywords
|
|
347
|
+
* are copied opaquely. Component references inside a schema resource identified
|
|
348
|
+
* by `$id` are left unchanged because they are relative to that resource.
|
|
432
349
|
*
|
|
433
350
|
* **Example** (Parsing an OpenAPI 3.1 schema)
|
|
434
351
|
*
|
|
@@ -452,7 +369,20 @@ export function fromSchemaDraft2020_12(js: JsonSchema): Document<"draft-2020-12"
|
|
|
452
369
|
* @since 4.0.0
|
|
453
370
|
*/
|
|
454
371
|
export function fromSchemaOpenApi3_1(js: JsonSchema): Document<"draft-2020-12"> {
|
|
455
|
-
const
|
|
372
|
+
const isRootResource = createsResource(js.$id)
|
|
373
|
+
const schema = transformSchema(js, (schema, inEmbeddedResource) => {
|
|
374
|
+
if (!isRootResource && !inEmbeddedResource) rewriteSchemaRef(schema, rewriteOpenApiComponentsReference)
|
|
375
|
+
if (isMetaSchemaUri(schema.$schema, META_SCHEMA_URI_OPEN_API_3_1)) {
|
|
376
|
+
InternalRecord.assignProperty(schema, "$schema", META_SCHEMA_URI_DRAFT_2020_12)
|
|
377
|
+
}
|
|
378
|
+
if (Object.hasOwn(schema, "example")) {
|
|
379
|
+
const examples = schema.examples
|
|
380
|
+
if (examples === undefined || Array.isArray(examples)) {
|
|
381
|
+
InternalRecord.assignProperty(schema, "examples", [schema.example, ...(examples ?? [])])
|
|
382
|
+
delete schema.example
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}) as JsonSchema
|
|
456
386
|
return fromSchemaDraft2020_12(schema)
|
|
457
387
|
}
|
|
458
388
|
|
|
@@ -466,10 +396,19 @@ export function fromSchemaOpenApi3_1(js: JsonSchema): Document<"draft-2020-12">
|
|
|
466
396
|
*
|
|
467
397
|
* **Details**
|
|
468
398
|
*
|
|
469
|
-
* This
|
|
470
|
-
* `example`,
|
|
471
|
-
*
|
|
472
|
-
*
|
|
399
|
+
* This directly converts OpenAPI 3.0 schema objects to Draft-2020-12. It
|
|
400
|
+
* handles `nullable`, singular `example`, boolean `exclusiveMinimum` and
|
|
401
|
+
* `exclusiveMaximum`, and OpenAPI component refs. Only values in OpenAPI
|
|
402
|
+
* schema positions are traversed as schemas.
|
|
403
|
+
*
|
|
404
|
+
* **Gotchas**
|
|
405
|
+
*
|
|
406
|
+
* OpenAPI 3.0 `nullable` is applied only when the same Schema Object has an
|
|
407
|
+
* explicit string `type`; other constraints such as `enum` are left
|
|
408
|
+
* unchanged. Unknown keywords, vendor extensions, and annotation values are
|
|
409
|
+
* copied opaquely unless their name would become active in Draft 2020-12 and
|
|
410
|
+
* change meaning, in which case conversion throws. Siblings of a valid
|
|
411
|
+
* OpenAPI 3.0 `$ref` are ignored.
|
|
473
412
|
*
|
|
474
413
|
* **Example** (Parsing an OpenAPI 3.0 nullable schema)
|
|
475
414
|
*
|
|
@@ -491,8 +430,7 @@ export function fromSchemaOpenApi3_1(js: JsonSchema): Document<"draft-2020-12">
|
|
|
491
430
|
* @since 4.0.0
|
|
492
431
|
*/
|
|
493
432
|
export function fromSchemaOpenApi3_0(schema: JsonSchema): Document<"draft-2020-12"> {
|
|
494
|
-
|
|
495
|
-
return fromSchemaDraft07(normalized as JsonSchema)
|
|
433
|
+
return fromSchemaDraft2020_12(convertOpenApi30(schema))
|
|
496
434
|
}
|
|
497
435
|
|
|
498
436
|
/**
|
|
@@ -507,12 +445,20 @@ export function fromSchemaOpenApi3_0(schema: JsonSchema): Document<"draft-2020-1
|
|
|
507
445
|
*
|
|
508
446
|
* This rewrites `#/$defs/...` refs to `#/definitions/...`, converts
|
|
509
447
|
* Draft-2020-12 tuple syntax (`prefixItems` plus `items`) to Draft-07 form
|
|
510
|
-
* (`items` as array plus `additionalItems`),
|
|
511
|
-
* and
|
|
448
|
+
* (`items` as array plus `additionalItems`), merges `dependentRequired` and
|
|
449
|
+
* `dependentSchemas` into `dependencies`, and converts both the root schema
|
|
450
|
+
* and all definitions. Local JSON Pointer refs are relocated when structural
|
|
451
|
+
* keywords move.
|
|
512
452
|
*
|
|
513
453
|
* **Gotchas**
|
|
514
454
|
*
|
|
515
|
-
*
|
|
455
|
+
* Unknown and custom keywords are copied as opaque values. Known keywords
|
|
456
|
+
* that Draft-07 cannot represent cause the conversion to throw
|
|
457
|
+
* instead of being dropped. These include dynamic references,
|
|
458
|
+
* `unevaluatedProperties`, `unevaluatedItems`, and non-default `minContains`
|
|
459
|
+
* or `maxContains` constraints. Conversion also throws when an opaque
|
|
460
|
+
* Draft-2020-12 keyword would collide with an active Draft-07 keyword, or when
|
|
461
|
+
* `$id` and `$anchor` occur together because Draft-07 cannot preserve both identifiers.
|
|
516
462
|
*
|
|
517
463
|
* **Example** (Converting to Draft-07)
|
|
518
464
|
*
|
|
@@ -540,8 +486,7 @@ export function fromSchemaOpenApi3_0(schema: JsonSchema): Document<"draft-2020-1
|
|
|
540
486
|
export function toDocumentDraft07(document: Document<"draft-2020-12">): Document<"draft-07"> {
|
|
541
487
|
return {
|
|
542
488
|
dialect: "draft-07",
|
|
543
|
-
|
|
544
|
-
definitions: Rec.map(document.definitions, toSchemaDraft07)
|
|
489
|
+
...convertDocument(document, draft07Adapter)
|
|
545
490
|
}
|
|
546
491
|
}
|
|
547
492
|
|
|
@@ -555,14 +500,23 @@ export function toDocumentDraft07(document: Document<"draft-2020-12">): Document
|
|
|
555
500
|
*
|
|
556
501
|
* **Details**
|
|
557
502
|
*
|
|
558
|
-
* This rewrites `#/$defs/...` refs to `#/definitions/...`, converts
|
|
559
|
-
* syntax, lowers `const` to `enum`,
|
|
560
|
-
*
|
|
503
|
+
* This directly rewrites `#/$defs/...` refs to `#/definitions/...`, converts
|
|
504
|
+
* tuple syntax, merges canonical dependencies, lowers `const` to `enum`,
|
|
505
|
+
* converts numeric exclusive bounds to the Draft-04 boolean form, lowers
|
|
506
|
+
* conditionals and basic `contains` through boolean applicators, and converts
|
|
507
|
+
* both the root schema and all definitions.
|
|
561
508
|
*
|
|
562
509
|
* **Gotchas**
|
|
563
510
|
*
|
|
564
|
-
*
|
|
565
|
-
*
|
|
511
|
+
* Unknown and custom keywords are copied as opaque values. Newer annotation
|
|
512
|
+
* keywords are preserved as Draft-04 extensions. Known keywords
|
|
513
|
+
* without a Draft-04 equivalent, including `propertyNames`, non-default
|
|
514
|
+
* `contains` cardinality, dynamic references, and unevaluated constraints,
|
|
515
|
+
* cause the conversion to throw instead of being dropped. A conditional with
|
|
516
|
+
* both branches also throws when lowering it would duplicate a nested schema
|
|
517
|
+
* identifier. Conversion also throws when an opaque Draft-2020-12 keyword
|
|
518
|
+
* would collide with an active Draft-04 keyword, or when `$id` and `$anchor`
|
|
519
|
+
* occur together because Draft-04 cannot preserve both identifiers.
|
|
566
520
|
*
|
|
567
521
|
* **Example** (Converting exclusive bounds)
|
|
568
522
|
*
|
|
@@ -582,166 +536,14 @@ export function toDocumentDraft07(document: Document<"draft-2020-12">): Document
|
|
|
582
536
|
* @since 4.0.0
|
|
583
537
|
*/
|
|
584
538
|
export function toDocumentDraft04(document: Document<"draft-2020-12">): Document<"draft-04"> {
|
|
585
|
-
const draft07 = toDocumentDraft07(document)
|
|
586
539
|
return {
|
|
587
540
|
dialect: "draft-04",
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
function toSchemaDraft04(schema: JsonSchema): JsonSchema {
|
|
594
|
-
return walk(schema) as JsonSchema
|
|
595
|
-
|
|
596
|
-
function walk(node: unknown): unknown {
|
|
597
|
-
if (node === true) return {}
|
|
598
|
-
if (node === false) return { not: {} }
|
|
599
|
-
if (Array.isArray(node)) return node.map(walk)
|
|
600
|
-
if (!Predicate.isObject(node)) return node
|
|
601
|
-
|
|
602
|
-
const src = node as Record<string, unknown>
|
|
603
|
-
const out: Record<string, unknown> = {}
|
|
604
|
-
|
|
605
|
-
let hasConst = false
|
|
606
|
-
let constValue: unknown = undefined
|
|
607
|
-
|
|
608
|
-
for (const k of Object.keys(src)) {
|
|
609
|
-
const v = src[k]
|
|
610
|
-
|
|
611
|
-
if (DRAFT_04_COPY_KEYWORDS.has(k)) {
|
|
612
|
-
out[k] = v
|
|
613
|
-
continue
|
|
614
|
-
}
|
|
615
|
-
if (rewriteSubschemaKeyword(out, k, v, walk, DRAFT_04_SINGLE_SUBSCHEMA_KEYWORDS)) continue
|
|
616
|
-
|
|
617
|
-
switch (k) {
|
|
618
|
-
case "const":
|
|
619
|
-
hasConst = true
|
|
620
|
-
constValue = v
|
|
621
|
-
break
|
|
622
|
-
|
|
623
|
-
case "minimum":
|
|
624
|
-
case "maximum":
|
|
625
|
-
case "exclusiveMinimum":
|
|
626
|
-
case "exclusiveMaximum":
|
|
627
|
-
break
|
|
628
|
-
|
|
629
|
-
case "additionalProperties":
|
|
630
|
-
case "additionalItems":
|
|
631
|
-
out[k] = typeof v === "boolean" ? v : walk(v)
|
|
632
|
-
break
|
|
633
|
-
|
|
634
|
-
case "items":
|
|
635
|
-
out.items = Array.isArray(v) ? v.map(walk) : walk(v)
|
|
636
|
-
break
|
|
637
|
-
|
|
638
|
-
default:
|
|
639
|
-
break
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
convertExclusiveBound(src, out, "minimum", "exclusiveMinimum", (bound, exclusive) => bound > exclusive)
|
|
644
|
-
convertExclusiveBound(src, out, "maximum", "exclusiveMaximum", (bound, exclusive) => bound < exclusive)
|
|
645
|
-
|
|
646
|
-
if (hasConst) {
|
|
647
|
-
const constSchema = { enum: [constValue] }
|
|
648
|
-
if (Object.hasOwn(src, "enum")) {
|
|
649
|
-
out.allOf = Array.isArray(out.allOf) ? [...out.allOf, constSchema] : [constSchema]
|
|
650
|
-
} else {
|
|
651
|
-
out.enum = constSchema.enum
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
return out
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
function convertExclusiveBound(
|
|
660
|
-
src: Record<string, unknown>,
|
|
661
|
-
out: Record<string, unknown>,
|
|
662
|
-
boundKey: "minimum" | "maximum",
|
|
663
|
-
exclusiveKey: "exclusiveMinimum" | "exclusiveMaximum",
|
|
664
|
-
isBoundStricter: (bound: number, exclusive: number) => boolean
|
|
665
|
-
): void {
|
|
666
|
-
const bound = src[boundKey]
|
|
667
|
-
const exclusive = src[exclusiveKey]
|
|
668
|
-
|
|
669
|
-
if (typeof exclusive === "number") {
|
|
670
|
-
if (typeof bound === "number" && isBoundStricter(bound, exclusive)) {
|
|
671
|
-
out[boundKey] = bound
|
|
672
|
-
} else {
|
|
673
|
-
out[boundKey] = exclusive
|
|
674
|
-
out[exclusiveKey] = true
|
|
675
|
-
}
|
|
676
|
-
} else if (bound !== undefined) {
|
|
677
|
-
out[boundKey] = bound
|
|
541
|
+
...convertDocument(document, draft04Adapter, {
|
|
542
|
+
booleanAdapter: (schema) => schema ? {} : { not: {} }
|
|
543
|
+
})
|
|
678
544
|
}
|
|
679
545
|
}
|
|
680
546
|
|
|
681
|
-
function toSchemaDraft07(schema: JsonSchema): JsonSchema {
|
|
682
|
-
return transformSchema(schema, (src) => {
|
|
683
|
-
rewriteSchemaRef(src, (ref) => ref.replace(RE_DEFS, "#/definitions"))
|
|
684
|
-
const out: Record<string, unknown> = {}
|
|
685
|
-
|
|
686
|
-
let prefixItems: unknown = undefined
|
|
687
|
-
let items: unknown = undefined
|
|
688
|
-
|
|
689
|
-
for (const k of Object.keys(src)) {
|
|
690
|
-
const v = src[k]
|
|
691
|
-
|
|
692
|
-
if (k === "required" && Array.isArray(v) && v.length === 0) continue
|
|
693
|
-
if (DRAFT_07_COPY_KEYWORDS.has(k)) {
|
|
694
|
-
out[k] = v
|
|
695
|
-
continue
|
|
696
|
-
}
|
|
697
|
-
if (
|
|
698
|
-
MAP_SUBSCHEMA_KEYWORDS.has(k) ||
|
|
699
|
-
ARRAY_SUBSCHEMA_KEYWORDS.has(k) ||
|
|
700
|
-
DRAFT_07_SINGLE_SUBSCHEMA_KEYWORDS.has(k)
|
|
701
|
-
) {
|
|
702
|
-
out[k] = v
|
|
703
|
-
continue
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
switch (k) {
|
|
707
|
-
// Tuple handling (2020-12 form)
|
|
708
|
-
case "prefixItems":
|
|
709
|
-
prefixItems = v
|
|
710
|
-
break
|
|
711
|
-
case "items":
|
|
712
|
-
items = v
|
|
713
|
-
break
|
|
714
|
-
|
|
715
|
-
default:
|
|
716
|
-
// drop everything else (subset)
|
|
717
|
-
break
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
// 2020-12 tuples -> Draft-07 tuples
|
|
722
|
-
if (prefixItems !== undefined) {
|
|
723
|
-
if (Array.isArray(prefixItems)) {
|
|
724
|
-
out.items = prefixItems
|
|
725
|
-
if (items !== undefined) out.additionalItems = items
|
|
726
|
-
} else {
|
|
727
|
-
// Non-standard, but keep a reasonable behavior
|
|
728
|
-
out.items = prefixItems
|
|
729
|
-
}
|
|
730
|
-
} else if (items !== undefined) {
|
|
731
|
-
// Regular items schema stays as items
|
|
732
|
-
out.items = items
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
const $ref = out.$ref
|
|
736
|
-
if (typeof $ref === "string" && Object.keys(out).length > 1) {
|
|
737
|
-
delete out.$ref
|
|
738
|
-
out.allOf = [{ $ref }, ...(Array.isArray(out.allOf) ? out.allOf : [])]
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
return out
|
|
742
|
-
}) as JsonSchema
|
|
743
|
-
}
|
|
744
|
-
|
|
745
547
|
/**
|
|
746
548
|
* Converts a `MultiDocument<"draft-2020-12">` to a
|
|
747
549
|
* `MultiDocument<"openapi-3.1">`.
|
|
@@ -763,7 +565,12 @@ function toSchemaDraft07(schema: JsonSchema): JsonSchema {
|
|
|
763
565
|
*
|
|
764
566
|
* **Gotchas**
|
|
765
567
|
*
|
|
766
|
-
* External refs and local refs outside `#/$defs` are left unchanged.
|
|
568
|
+
* External refs and local refs outside `#/$defs` are left unchanged. Conversion
|
|
569
|
+
* throws when a custom keyword would become an active OpenAPI keyword and
|
|
570
|
+
* therefore change meaning. References inside schema resources identified by
|
|
571
|
+
* `$id` are left unchanged. Conversion throws when an identified root schema
|
|
572
|
+
* references the detached shared definitions pool because OpenAPI cannot
|
|
573
|
+
* preserve that fragment reference.
|
|
767
574
|
*
|
|
768
575
|
* **Example** (Converting to OpenAPI 3.1)
|
|
769
576
|
*
|
|
@@ -811,26 +618,52 @@ export function toMultiDocumentOpenApi3_1(multiDocument: MultiDocument<"draft-20
|
|
|
811
618
|
keyMap.set(key, candidate)
|
|
812
619
|
}
|
|
813
620
|
|
|
814
|
-
function rewrite(
|
|
815
|
-
|
|
816
|
-
|
|
621
|
+
function rewrite(
|
|
622
|
+
schema: JsonSchema,
|
|
623
|
+
rejectSharedDefinitionRefs = false
|
|
624
|
+
): JsonSchema {
|
|
625
|
+
const isRootResource = createsResource(schema.$id)
|
|
626
|
+
const localDefinitions = Predicate.isObject(schema.$defs) ? schema.$defs : undefined
|
|
627
|
+
return transformSchema(schema, (schema, inEmbeddedResource) => {
|
|
628
|
+
rejectKeywordCollisions(schema, OPEN_API_31_TARGET_COLLISIONS, "OpenAPI 3.1", "Draft 2020-12")
|
|
629
|
+
rewriteSchemaRef(schema, (reference, keyword) => {
|
|
630
|
+
const path = reference.startsWith("#") ? parseUriFragment(reference) : undefined
|
|
631
|
+
if (path === undefined || path[0] !== "$defs" || path.length < 2) return reference
|
|
632
|
+
const key = path[1]
|
|
633
|
+
if (isRootResource) {
|
|
634
|
+
if (
|
|
635
|
+
rejectSharedDefinitionRefs &&
|
|
636
|
+
!inEmbeddedResource &&
|
|
637
|
+
Object.hasOwn(multiDocument.definitions, key) &&
|
|
638
|
+
(localDefinitions === undefined || !Object.hasOwn(localDefinitions, key))
|
|
639
|
+
) {
|
|
640
|
+
unsupported(keyword, "OpenAPI 3.1", "a schema resource cannot reference the shared definitions pool")
|
|
641
|
+
}
|
|
642
|
+
return reference
|
|
643
|
+
}
|
|
644
|
+
return inEmbeddedResource
|
|
645
|
+
? reference
|
|
646
|
+
: formatUriFragment(["components", "schemas", keyMap.get(key) ?? key, ...path.slice(2)])
|
|
647
|
+
})
|
|
648
|
+
}) as JsonSchema
|
|
649
|
+
}
|
|
817
650
|
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
651
|
+
const schemas = multiDocument.schemas.map((schema) => rewrite(schema, true)) as unknown as MultiDocument<
|
|
652
|
+
"openapi-3.1"
|
|
653
|
+
>["schemas"]
|
|
654
|
+
const definitions: Definitions = {}
|
|
655
|
+
for (const key of definitionKeys) {
|
|
656
|
+
InternalRecord.assignProperty(
|
|
657
|
+
definitions,
|
|
658
|
+
keyMap.get(key) ?? key,
|
|
659
|
+
rewrite(multiDocument.definitions[key])
|
|
660
|
+
)
|
|
825
661
|
}
|
|
826
662
|
|
|
827
663
|
return {
|
|
828
664
|
dialect: "openapi-3.1",
|
|
829
|
-
schemas
|
|
830
|
-
definitions
|
|
831
|
-
multiDocument.definitions,
|
|
832
|
-
(definition, key) => [keyMap.get(key) ?? key, rewrite(definition)]
|
|
833
|
-
)
|
|
665
|
+
schemas,
|
|
666
|
+
definitions
|
|
834
667
|
}
|
|
835
668
|
}
|
|
836
669
|
|
|
@@ -847,14 +680,23 @@ export function sanitizeOpenApiComponentsSchemasKey(s: string): string {
|
|
|
847
680
|
return s.length === 0 ? "_" : s.replace(/[^a-zA-Z0-9._-]/gu, "_");
|
|
848
681
|
}
|
|
849
682
|
|
|
683
|
+
/** @internal */
|
|
684
|
+
export function getReferenceKey($ref: string): string | undefined {
|
|
685
|
+
const path = $ref.startsWith("#") ? parseUriFragment($ref) : undefined
|
|
686
|
+
return path !== undefined && path.length === 2 && path[0] === "$defs"
|
|
687
|
+
? path[1]
|
|
688
|
+
: undefined
|
|
689
|
+
}
|
|
690
|
+
|
|
850
691
|
function transformSchema(
|
|
851
692
|
node: unknown,
|
|
852
|
-
transform: (schema: Record<string, unknown
|
|
693
|
+
transform: (schema: Record<string, unknown>, inEmbeddedResource: boolean) => void
|
|
853
694
|
): unknown {
|
|
854
|
-
return walk(node)
|
|
695
|
+
return walk(node, false, true)
|
|
855
696
|
|
|
856
|
-
function walk(node: unknown): unknown {
|
|
697
|
+
function walk(node: unknown, inheritedResource: boolean, isRoot = false): unknown {
|
|
857
698
|
if (!Predicate.isObject(node)) return node
|
|
699
|
+
const inEmbeddedResource = inheritedResource || (!isRoot && createsResource(node.$id))
|
|
858
700
|
|
|
859
701
|
const out: Record<string, unknown> = {}
|
|
860
702
|
for (const key of Object.keys(node)) {
|
|
@@ -865,13 +707,13 @@ function transformSchema(
|
|
|
865
707
|
case "properties":
|
|
866
708
|
case "patternProperties":
|
|
867
709
|
case "dependentSchemas":
|
|
868
|
-
transformed = mapObject(value, walk) ?? value
|
|
710
|
+
transformed = mapObject(value, (value) => walk(value, inEmbeddedResource)) ?? value
|
|
869
711
|
break
|
|
870
712
|
case "allOf":
|
|
871
713
|
case "anyOf":
|
|
872
714
|
case "oneOf":
|
|
873
715
|
case "prefixItems":
|
|
874
|
-
transformed = Array.isArray(value) ? value.map(walk) : value
|
|
716
|
+
transformed = Array.isArray(value) ? value.map((value) => walk(value, inEmbeddedResource)) : value
|
|
875
717
|
break
|
|
876
718
|
case "not":
|
|
877
719
|
case "additionalProperties":
|
|
@@ -884,222 +726,902 @@ function transformSchema(
|
|
|
884
726
|
case "then":
|
|
885
727
|
case "else":
|
|
886
728
|
case "contentSchema":
|
|
887
|
-
transformed = walk(value)
|
|
729
|
+
transformed = walk(value, inEmbeddedResource)
|
|
888
730
|
}
|
|
889
731
|
InternalRecord.assignProperty(out, key, transformed)
|
|
890
732
|
}
|
|
891
|
-
|
|
733
|
+
transform(out, inEmbeddedResource)
|
|
734
|
+
return out
|
|
892
735
|
}
|
|
893
736
|
}
|
|
894
737
|
|
|
895
738
|
/** @internal */
|
|
896
739
|
export function rewriteRefs(schema: JsonSchema, rewrite: ($ref: string) => string): JsonSchema {
|
|
897
|
-
return transformSchema(schema, (schema) =>
|
|
740
|
+
return transformSchema(schema, (schema) => {
|
|
741
|
+
rewriteSchemaRef(schema, rewrite)
|
|
742
|
+
}) as JsonSchema
|
|
898
743
|
}
|
|
899
744
|
|
|
900
745
|
function rewriteSchemaRef(
|
|
901
746
|
schema: Record<string, unknown>,
|
|
902
|
-
rewrite: ($ref: string) => string
|
|
903
|
-
):
|
|
747
|
+
rewrite: ($ref: string, keyword: "$ref" | "$dynamicRef") => string
|
|
748
|
+
): void {
|
|
904
749
|
if (typeof schema.$ref === "string") {
|
|
905
|
-
InternalRecord.assignProperty(schema, "$ref", rewrite(schema.$ref))
|
|
750
|
+
InternalRecord.assignProperty(schema, "$ref", rewrite(schema.$ref, "$ref"))
|
|
751
|
+
}
|
|
752
|
+
if (typeof schema.$dynamicRef === "string") {
|
|
753
|
+
InternalRecord.assignProperty(schema, "$dynamicRef", rewrite(schema.$dynamicRef, "$dynamicRef"))
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
function mapObject(
|
|
758
|
+
value: unknown,
|
|
759
|
+
f: (node: unknown, key: string) => unknown
|
|
760
|
+
): Record<string, unknown> | undefined {
|
|
761
|
+
if (!Predicate.isObject(value)) return undefined
|
|
762
|
+
const out: Record<string, unknown> = {}
|
|
763
|
+
for (const key of Object.keys(value)) {
|
|
764
|
+
InternalRecord.assignProperty(out, key, f(value[key], key))
|
|
765
|
+
}
|
|
766
|
+
return out
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
type Path = ReadonlyArray<string>
|
|
770
|
+
type Convert = (root: unknown, sourcePath?: Path, targetPath?: Path) => unknown
|
|
771
|
+
|
|
772
|
+
interface Context {
|
|
773
|
+
readonly isDocumentRoot: boolean
|
|
774
|
+
readonly schema: (value: unknown, sourceKey: string, targetKey?: string) => unknown
|
|
775
|
+
readonly schemaAt: (value: unknown, sourcePath: Path, targetPath: Path) => unknown
|
|
776
|
+
readonly schemaArray: (value: unknown, sourceKey: string, targetKey?: string) => unknown
|
|
777
|
+
readonly schemaMap: (value: unknown, sourceKey: string, targetKey?: string) => unknown
|
|
778
|
+
readonly reference: (out: JsonSchema, value: unknown) => void
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
type Adapter = (schema: JsonSchema, context: Context) => JsonSchema
|
|
782
|
+
|
|
783
|
+
type PendingReference = readonly [out: JsonSchema, value: string, sourceResource: string]
|
|
784
|
+
|
|
785
|
+
interface ResourceScope {
|
|
786
|
+
readonly parent?: ResourceScope
|
|
787
|
+
readonly sourceRoot: Path
|
|
788
|
+
readonly targetRoot: Path
|
|
789
|
+
readonly uri: string
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
interface ConverterOptions {
|
|
793
|
+
readonly booleanAdapter?: (schema: boolean) => JsonSchema | boolean
|
|
794
|
+
readonly trackIds?: boolean
|
|
795
|
+
readonly ignoreRefSiblings?: boolean
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
// Adapters decide which values are schemas. The kernel only handles recursion,
|
|
799
|
+
// resource scopes, and reference relocation between structural source/target paths.
|
|
800
|
+
function runConverter<A>(adapter: Adapter, options: ConverterOptions | undefined, use: (convert: Convert) => A): A {
|
|
801
|
+
const locations = new Map<string, Path>()
|
|
802
|
+
const references: Array<PendingReference> = []
|
|
803
|
+
let rootUri = ROOT_URI
|
|
804
|
+
|
|
805
|
+
function convert(root: unknown, sourcePath: Path = [], targetPath: Path = []): unknown {
|
|
806
|
+
if (sourcePath.length === 0 && options?.trackIds) {
|
|
807
|
+
const id = Predicate.isObject(root) ? getResourceId(root) : undefined
|
|
808
|
+
rootUri = resolveResourceUri(id, ROOT_URI) ?? ROOT_URI
|
|
809
|
+
}
|
|
810
|
+
return loop(root, sourcePath, targetPath, { sourceRoot: [], targetRoot: [], uri: rootUri })
|
|
906
811
|
}
|
|
907
|
-
|
|
812
|
+
|
|
813
|
+
function finish(): void {
|
|
814
|
+
for (const [out, value, sourceResource] of references) {
|
|
815
|
+
let reference = value
|
|
816
|
+
const resolved = resolveUrl(value, sourceResource)
|
|
817
|
+
if (resolved !== undefined) {
|
|
818
|
+
const sourcePointer = parseUriFragment(resolved.hash)
|
|
819
|
+
resolved.hash = ""
|
|
820
|
+
if (sourcePointer !== undefined) {
|
|
821
|
+
const targetPath = locations.get(locationKey(resolved.href, sourcePointer))
|
|
822
|
+
if (targetPath !== undefined) reference = relocateReference(value, targetPath)
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
InternalRecord.assignProperty(out, "$ref", reference)
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
const out = use(convert)
|
|
830
|
+
finish()
|
|
831
|
+
return out
|
|
832
|
+
|
|
833
|
+
function loop(
|
|
834
|
+
node: unknown,
|
|
835
|
+
sourcePath: Path,
|
|
836
|
+
targetPath: Path,
|
|
837
|
+
resourceScope: ResourceScope
|
|
838
|
+
): unknown {
|
|
839
|
+
if (typeof node === "boolean") {
|
|
840
|
+
recordLocations(sourcePath, targetPath, resourceScope)
|
|
841
|
+
return options?.booleanAdapter?.(node) ?? node
|
|
842
|
+
}
|
|
843
|
+
if (!Predicate.isObject(node)) return node
|
|
844
|
+
|
|
845
|
+
let currentResourceScope = resourceScope
|
|
846
|
+
const id = getResourceId(node)
|
|
847
|
+
if (sourcePath.length > 0 && options?.trackIds && createsResource(id)) {
|
|
848
|
+
const uri = resolveResourceUri(id, resourceScope.uri)
|
|
849
|
+
if (uri !== undefined) {
|
|
850
|
+
currentResourceScope = {
|
|
851
|
+
parent: resourceScope,
|
|
852
|
+
sourceRoot: sourcePath,
|
|
853
|
+
targetRoot: targetPath,
|
|
854
|
+
uri
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
recordLocations(sourcePath, targetPath, currentResourceScope)
|
|
859
|
+
const currentResource = currentResourceScope.uri
|
|
860
|
+
|
|
861
|
+
const context: Context = {
|
|
862
|
+
isDocumentRoot: sourcePath.length === 0,
|
|
863
|
+
schema(value, sourceKey, targetKey = sourceKey) {
|
|
864
|
+
return loop(value, [...sourcePath, sourceKey], [...targetPath, targetKey], currentResourceScope)
|
|
865
|
+
},
|
|
866
|
+
schemaAt(value, sourceSuffix, targetSuffix) {
|
|
867
|
+
return loop(value, [...sourcePath, ...sourceSuffix], [...targetPath, ...targetSuffix], currentResourceScope)
|
|
868
|
+
},
|
|
869
|
+
schemaArray(value, sourceKey, targetKey = sourceKey) {
|
|
870
|
+
return Array.isArray(value)
|
|
871
|
+
? value.map((item, index) =>
|
|
872
|
+
loop(
|
|
873
|
+
item,
|
|
874
|
+
[...sourcePath, sourceKey, String(index)],
|
|
875
|
+
[...targetPath, targetKey, String(index)],
|
|
876
|
+
currentResourceScope
|
|
877
|
+
)
|
|
878
|
+
)
|
|
879
|
+
: value
|
|
880
|
+
},
|
|
881
|
+
schemaMap(value, sourceKey, targetKey = sourceKey) {
|
|
882
|
+
if (!Predicate.isObject(value)) return value
|
|
883
|
+
return mapObject(value, (item, key) =>
|
|
884
|
+
loop(
|
|
885
|
+
item,
|
|
886
|
+
[...sourcePath, sourceKey, key],
|
|
887
|
+
[...targetPath, targetKey, key],
|
|
888
|
+
currentResourceScope
|
|
889
|
+
))
|
|
890
|
+
},
|
|
891
|
+
reference(out, value) {
|
|
892
|
+
if (typeof value === "string") {
|
|
893
|
+
references.push([out, value, currentResource])
|
|
894
|
+
} else {
|
|
895
|
+
InternalRecord.assignProperty(out, "$ref", value)
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
return adapter(node, context)
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
function getResourceId(schema: JsonSchema): unknown {
|
|
903
|
+
return options?.ignoreRefSiblings === true && typeof schema.$ref === "string" ? undefined : schema.$id
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
function recordLocations(sourcePath: Path, targetPath: Path, scope: ResourceScope): void {
|
|
907
|
+
// A JSON Pointer can address an embedded schema from any containing resource.
|
|
908
|
+
if (scope.parent !== undefined) recordLocations(sourcePath, targetPath, scope.parent)
|
|
909
|
+
locations.set(
|
|
910
|
+
locationKey(scope.uri, sourcePath.slice(scope.sourceRoot.length)),
|
|
911
|
+
targetPath.slice(scope.targetRoot.length)
|
|
912
|
+
)
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
const ROOT_URI = "https://effect.invalid/.json-schema/"
|
|
917
|
+
|
|
918
|
+
function resolveUrl(value: string, base: string): URL | undefined {
|
|
919
|
+
return URL.canParse(value, base) ? new URL(value, base) : undefined
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
function resolveResourceUri(value: unknown, base: string): string | undefined {
|
|
923
|
+
if (typeof value !== "string") return undefined
|
|
924
|
+
const url = resolveUrl(value, base)
|
|
925
|
+
if (url === undefined) return undefined
|
|
926
|
+
url.hash = ""
|
|
927
|
+
return url.href
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
function relocateReference(reference: string, targetPath: Path): string {
|
|
931
|
+
const index = reference.indexOf("#")
|
|
932
|
+
if (index === -1 && targetPath.length === 0) return reference
|
|
933
|
+
const uri = index === -1 ? reference : reference.slice(0, index)
|
|
934
|
+
return `${uri}${formatUriFragment(targetPath)}`
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
function locationKey(resource: string, pointer: Path): string {
|
|
938
|
+
return `${resource}\u0000${JSON.stringify(pointer)}`
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
function createsResource(id: unknown): boolean {
|
|
942
|
+
return typeof id === "string" && id.length > 0 && id[0] !== "#"
|
|
908
943
|
}
|
|
909
944
|
|
|
910
|
-
function
|
|
911
|
-
return
|
|
945
|
+
function convertSchema(root: JsonSchema, adapter: Adapter, options?: ConverterOptions): JsonSchema {
|
|
946
|
+
return runConverter(adapter, options, (convert) => convert(root) as JsonSchema)
|
|
912
947
|
}
|
|
913
948
|
|
|
914
|
-
function
|
|
915
|
-
|
|
949
|
+
function convertDocument(
|
|
950
|
+
document: Document<"draft-2020-12">,
|
|
951
|
+
adapter: Adapter,
|
|
952
|
+
options?: ConverterOptions
|
|
953
|
+
): { readonly schema: JsonSchema; readonly definitions: Definitions } {
|
|
954
|
+
return runConverter(adapter, { ...options, trackIds: true }, (convert) => ({
|
|
955
|
+
schema: convert(document.schema) as JsonSchema,
|
|
956
|
+
definitions: mapObject(
|
|
957
|
+
document.definitions,
|
|
958
|
+
(definition, key) => convert(definition, ["$defs", key], ["definitions", key]) as JsonSchema
|
|
959
|
+
) as Definitions
|
|
960
|
+
}))
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
const SCHEMA_MAP_KEYWORDS = new Set(["properties", "patternProperties"])
|
|
964
|
+
const SCHEMA_ARRAY_KEYWORDS = new Set(["allOf", "anyOf", "oneOf"])
|
|
965
|
+
const JSON_SCHEMA_SINGLE_KEYWORDS = new Set([
|
|
966
|
+
"not",
|
|
967
|
+
"additionalProperties",
|
|
968
|
+
"propertyNames",
|
|
969
|
+
"contains",
|
|
970
|
+
"if",
|
|
971
|
+
"then",
|
|
972
|
+
"else",
|
|
973
|
+
"contentSchema"
|
|
974
|
+
])
|
|
975
|
+
const OPEN_API_30_SCHEMA_MAP_KEYWORDS = new Set(["properties"])
|
|
976
|
+
const OPEN_API_30_SCHEMA_SINGLE_KEYWORDS = new Set(["not", "items", "additionalProperties"])
|
|
977
|
+
const DRAFT_04_SCHEMA_SINGLE_KEYWORDS = new Set(["not", "additionalProperties", "contentSchema"])
|
|
978
|
+
|
|
979
|
+
function convertSubschemaKeyword(
|
|
980
|
+
out: JsonSchema,
|
|
916
981
|
key: string,
|
|
917
982
|
value: unknown,
|
|
918
|
-
|
|
919
|
-
singleKeywords: ReadonlySet<string
|
|
983
|
+
context: Context,
|
|
984
|
+
singleKeywords: ReadonlySet<string>,
|
|
985
|
+
mapKeywords: ReadonlySet<string> = SCHEMA_MAP_KEYWORDS
|
|
920
986
|
): boolean {
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
return true
|
|
928
|
-
}
|
|
929
|
-
if (!singleKeywords.has(key)) return false
|
|
930
|
-
out[key] = rewrite(value)
|
|
987
|
+
let converted: unknown
|
|
988
|
+
if (mapKeywords.has(key)) converted = context.schemaMap(value, key)
|
|
989
|
+
else if (SCHEMA_ARRAY_KEYWORDS.has(key)) converted = context.schemaArray(value, key)
|
|
990
|
+
else if (singleKeywords.has(key)) converted = context.schema(value, key)
|
|
991
|
+
else return false
|
|
992
|
+
InternalRecord.assignProperty(out, key, converted)
|
|
931
993
|
return true
|
|
932
994
|
}
|
|
933
995
|
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
996
|
+
const PRE_2020_TO_2020_COLLISIONS = [
|
|
997
|
+
"$anchor",
|
|
998
|
+
"$defs",
|
|
999
|
+
"$dynamicAnchor",
|
|
1000
|
+
"$dynamicRef",
|
|
1001
|
+
"$vocabulary",
|
|
1002
|
+
"contentSchema",
|
|
1003
|
+
"dependentRequired",
|
|
1004
|
+
"dependentSchemas",
|
|
1005
|
+
"maxContains",
|
|
1006
|
+
"minContains",
|
|
1007
|
+
"prefixItems",
|
|
1008
|
+
"unevaluatedItems",
|
|
1009
|
+
"unevaluatedProperties"
|
|
1010
|
+
]
|
|
1011
|
+
const DRAFT_07_TO_2020_COLLISIONS = [...PRE_2020_TO_2020_COLLISIONS, "deprecated"]
|
|
1012
|
+
const OPEN_API_30_TO_2020_COLLISIONS = [
|
|
1013
|
+
...PRE_2020_TO_2020_COLLISIONS,
|
|
1014
|
+
"$comment",
|
|
1015
|
+
"$id",
|
|
1016
|
+
"$schema",
|
|
1017
|
+
"const",
|
|
1018
|
+
"contains",
|
|
1019
|
+
"contentEncoding",
|
|
1020
|
+
"contentMediaType",
|
|
1021
|
+
"else",
|
|
1022
|
+
"examples",
|
|
1023
|
+
"if",
|
|
1024
|
+
"patternProperties",
|
|
1025
|
+
"propertyNames",
|
|
1026
|
+
"then"
|
|
1027
|
+
]
|
|
1028
|
+
const ANCHOR_REGEXP = /^[A-Za-z_][-A-Za-z0-9._]*$/
|
|
1029
|
+
const LEGACY_ID_FRAGMENT_REGEXP = /^[A-Za-z][-A-Za-z0-9._:]*$/
|
|
1030
|
+
|
|
1031
|
+
function convertDraft07(root: JsonSchema): JsonSchema {
|
|
1032
|
+
return convertSchema(root, (source, context) => {
|
|
1033
|
+
const out: JsonSchema = {}
|
|
1034
|
+
|
|
1035
|
+
if (typeof source.$ref === "string") {
|
|
1036
|
+
context.reference(out, source.$ref)
|
|
1037
|
+
if (Object.hasOwn(source, "definitions")) {
|
|
1038
|
+
InternalRecord.assignProperty(out, "$defs", context.schemaMap(source.definitions, "definitions", "$defs"))
|
|
1039
|
+
}
|
|
1040
|
+
return out
|
|
1041
|
+
}
|
|
1042
|
+
rejectKeywordCollisions(source, DRAFT_07_TO_2020_COLLISIONS, "Draft 2020-12", "Draft-07")
|
|
1043
|
+
|
|
1044
|
+
let items: unknown = undefined
|
|
1045
|
+
let additionalItems: unknown = undefined
|
|
937
1046
|
|
|
938
|
-
|
|
939
|
-
|
|
1047
|
+
for (const key of Object.keys(source)) {
|
|
1048
|
+
const value = source[key]
|
|
1049
|
+
if (convertSubschemaKeyword(out, key, value, context, JSON_SCHEMA_SINGLE_KEYWORDS)) continue
|
|
1050
|
+
switch (key) {
|
|
1051
|
+
case "$schema":
|
|
1052
|
+
InternalRecord.assignProperty(
|
|
1053
|
+
out,
|
|
1054
|
+
key,
|
|
1055
|
+
isMetaSchemaUri(value, META_SCHEMA_URI_DRAFT_07) ? META_SCHEMA_URI_DRAFT_2020_12 : value
|
|
1056
|
+
)
|
|
1057
|
+
break
|
|
1058
|
+
case "$id":
|
|
1059
|
+
convertDraft07Id(out, value)
|
|
1060
|
+
break
|
|
1061
|
+
case "definitions":
|
|
1062
|
+
InternalRecord.assignProperty(out, "$defs", context.schemaMap(value, key, "$defs"))
|
|
1063
|
+
break
|
|
1064
|
+
case "dependencies": {
|
|
1065
|
+
if (!Predicate.isObject(value)) {
|
|
1066
|
+
InternalRecord.assignProperty(out, key, value)
|
|
1067
|
+
break
|
|
1068
|
+
}
|
|
1069
|
+
const dependentRequired: JsonSchema = {}
|
|
1070
|
+
const dependentSchemas: JsonSchema = {}
|
|
1071
|
+
for (const dependency of Object.keys(value)) {
|
|
1072
|
+
const dependencyValue = value[dependency]
|
|
1073
|
+
InternalRecord.assignProperty(
|
|
1074
|
+
Array.isArray(dependencyValue) ? dependentRequired : dependentSchemas,
|
|
1075
|
+
dependency,
|
|
1076
|
+
Array.isArray(dependencyValue)
|
|
1077
|
+
? dependencyValue
|
|
1078
|
+
: context.schemaAt(
|
|
1079
|
+
dependencyValue,
|
|
1080
|
+
["dependencies", dependency],
|
|
1081
|
+
["dependentSchemas", dependency]
|
|
1082
|
+
)
|
|
1083
|
+
)
|
|
1084
|
+
}
|
|
1085
|
+
if (Object.keys(dependentRequired).length > 0) {
|
|
1086
|
+
InternalRecord.assignProperty(out, "dependentRequired", dependentRequired)
|
|
1087
|
+
}
|
|
1088
|
+
if (Object.keys(dependentSchemas).length > 0) {
|
|
1089
|
+
InternalRecord.assignProperty(out, "dependentSchemas", dependentSchemas)
|
|
1090
|
+
}
|
|
1091
|
+
break
|
|
1092
|
+
}
|
|
1093
|
+
case "items":
|
|
1094
|
+
items = value
|
|
1095
|
+
break
|
|
1096
|
+
case "additionalItems":
|
|
1097
|
+
additionalItems = value
|
|
1098
|
+
break
|
|
1099
|
+
default:
|
|
1100
|
+
InternalRecord.assignProperty(out, key, value)
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
940
1103
|
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
1104
|
+
if (items !== undefined) {
|
|
1105
|
+
if (Array.isArray(items)) {
|
|
1106
|
+
InternalRecord.assignProperty(out, "prefixItems", context.schemaArray(items, "items", "prefixItems"))
|
|
1107
|
+
if (additionalItems !== undefined) {
|
|
1108
|
+
InternalRecord.assignProperty(out, "items", context.schema(additionalItems, "additionalItems", "items"))
|
|
1109
|
+
}
|
|
1110
|
+
} else {
|
|
1111
|
+
InternalRecord.assignProperty(out, "items", context.schema(items, "items"))
|
|
948
1112
|
}
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
return out
|
|
1116
|
+
}, { trackIds: true, ignoreRefSiblings: true })
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
function convertDraft07Id(out: JsonSchema, value: unknown): void {
|
|
1120
|
+
if (typeof value !== "string" || !value.includes("#")) {
|
|
1121
|
+
InternalRecord.assignProperty(out, "$id", value)
|
|
1122
|
+
return
|
|
1123
|
+
}
|
|
1124
|
+
const fragmentIndex = value.indexOf("#")
|
|
1125
|
+
const id = value.slice(0, fragmentIndex)
|
|
1126
|
+
const anchor = value.slice(fragmentIndex + 1)
|
|
1127
|
+
if (anchor.length === 0) {
|
|
1128
|
+
if (id.length > 0) InternalRecord.assignProperty(out, "$id", id)
|
|
1129
|
+
return
|
|
1130
|
+
}
|
|
1131
|
+
if (!ANCHOR_REGEXP.test(anchor)) {
|
|
1132
|
+
unsupported("$id", "Draft 2020-12", `fragment "#${anchor}" is not a valid $anchor`)
|
|
1133
|
+
}
|
|
1134
|
+
if (id.length > 0) InternalRecord.assignProperty(out, "$id", id)
|
|
1135
|
+
InternalRecord.assignProperty(out, "$anchor", anchor)
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
function unsupported(keyword: string, dialect: string, details: string): never {
|
|
1139
|
+
throw new Error(`Cannot convert JSON Schema keyword "${keyword}" to ${dialect}: ${details}`)
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
function rejectKeywordCollisions(
|
|
1143
|
+
source: JsonSchema,
|
|
1144
|
+
keywords: ReadonlyArray<string>,
|
|
1145
|
+
targetDialect: string,
|
|
1146
|
+
sourceDialect: string
|
|
1147
|
+
): void {
|
|
1148
|
+
for (const keyword of keywords) {
|
|
1149
|
+
if (Object.hasOwn(source, keyword)) {
|
|
1150
|
+
unsupported(keyword, targetDialect, `it is not active in ${sourceDialect} but would become active in the target`)
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
const DRAFT_07_TARGET_COLLISIONS = ["additionalItems", "definitions", "dependencies"]
|
|
1156
|
+
|
|
1157
|
+
function convertMetaSchemaKeyword(
|
|
1158
|
+
out: JsonSchema,
|
|
1159
|
+
value: unknown,
|
|
1160
|
+
context: Context,
|
|
1161
|
+
targetUri: string,
|
|
1162
|
+
targetDialect: string
|
|
1163
|
+
): void {
|
|
1164
|
+
if (context.isDocumentRoot) {
|
|
1165
|
+
InternalRecord.assignProperty(
|
|
1166
|
+
out,
|
|
1167
|
+
"$schema",
|
|
1168
|
+
isMetaSchemaUri(value, META_SCHEMA_URI_DRAFT_2020_12) ? targetUri : value
|
|
1169
|
+
)
|
|
1170
|
+
} else if (!isMetaSchemaUri(value, META_SCHEMA_URI_DRAFT_2020_12)) {
|
|
1171
|
+
unsupported("$schema", targetDialect, "an embedded resource cannot declare a different dialect")
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
function draft07Adapter(source: JsonSchema, context: Context): JsonSchema {
|
|
1176
|
+
rejectKeywordCollisions(source, DRAFT_07_TARGET_COLLISIONS, "Draft-07", "Draft 2020-12")
|
|
1177
|
+
const out: JsonSchema = {}
|
|
1178
|
+
let reference: unknown = undefined
|
|
1179
|
+
let prefixItems: unknown = undefined
|
|
1180
|
+
let items: unknown = undefined
|
|
1181
|
+
|
|
1182
|
+
for (const key of Object.keys(source)) {
|
|
1183
|
+
const value = source[key]
|
|
1184
|
+
if (convertSubschemaKeyword(out, key, value, context, JSON_SCHEMA_SINGLE_KEYWORDS)) continue
|
|
1185
|
+
switch (key) {
|
|
1186
|
+
case "$ref":
|
|
1187
|
+
reference = value
|
|
1188
|
+
break
|
|
1189
|
+
case "$schema":
|
|
1190
|
+
convertMetaSchemaKeyword(out, value, context, META_SCHEMA_URI_DRAFT_07, "Draft-07")
|
|
1191
|
+
break
|
|
1192
|
+
case "$id":
|
|
1193
|
+
case "$anchor":
|
|
1194
|
+
break
|
|
1195
|
+
case "$defs":
|
|
1196
|
+
InternalRecord.assignProperty(out, "definitions", context.schemaMap(value, key, "definitions"))
|
|
1197
|
+
break
|
|
1198
|
+
case "prefixItems":
|
|
1199
|
+
prefixItems = value
|
|
1200
|
+
break
|
|
1201
|
+
case "items":
|
|
1202
|
+
items = value
|
|
1203
|
+
break
|
|
1204
|
+
case "dependentRequired":
|
|
1205
|
+
case "dependentSchemas":
|
|
1206
|
+
case "minContains":
|
|
1207
|
+
case "maxContains":
|
|
1208
|
+
break
|
|
1209
|
+
case "$dynamicRef":
|
|
1210
|
+
case "$dynamicAnchor":
|
|
1211
|
+
case "$vocabulary":
|
|
1212
|
+
case "unevaluatedProperties":
|
|
1213
|
+
case "unevaluatedItems":
|
|
1214
|
+
unsupported(key, "Draft-07", "the target dialect has no equivalent")
|
|
1215
|
+
case "required":
|
|
1216
|
+
if (Array.isArray(value) && value.length === 0) break
|
|
1217
|
+
InternalRecord.assignProperty(out, key, value)
|
|
1218
|
+
break
|
|
1219
|
+
default:
|
|
1220
|
+
InternalRecord.assignProperty(out, key, value)
|
|
953
1221
|
}
|
|
954
1222
|
}
|
|
955
1223
|
|
|
956
|
-
|
|
957
|
-
out = adjustExclusivity(out)
|
|
1224
|
+
convertTuple(out, prefixItems, items, context)
|
|
958
1225
|
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
1226
|
+
if (Object.hasOwn(source, "contains")) {
|
|
1227
|
+
const minContains = source.minContains
|
|
1228
|
+
const maxContains = source.maxContains
|
|
1229
|
+
if ((minContains !== undefined && minContains !== 1) || maxContains !== undefined) {
|
|
1230
|
+
unsupported("minContains/maxContains", "Draft-07", "contains cardinality cannot be represented")
|
|
1231
|
+
}
|
|
1232
|
+
if (Object.hasOwn(source, "minContains")) InternalRecord.assignProperty(out, "minContains", minContains)
|
|
1233
|
+
} else {
|
|
1234
|
+
if (Object.hasOwn(source, "minContains")) InternalRecord.assignProperty(out, "minContains", source.minContains)
|
|
1235
|
+
if (Object.hasOwn(source, "maxContains")) InternalRecord.assignProperty(out, "maxContains", source.maxContains)
|
|
962
1236
|
}
|
|
963
|
-
|
|
1237
|
+
|
|
1238
|
+
convertDependencies(source, out, context, "draft-07")
|
|
1239
|
+
convertLegacyId(source, out, "$id", "Draft-07")
|
|
1240
|
+
|
|
1241
|
+
convertReference(out, reference, context)
|
|
964
1242
|
|
|
965
1243
|
return out
|
|
966
1244
|
}
|
|
967
1245
|
|
|
968
|
-
function
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
)
|
|
1246
|
+
function convertTuple(out: JsonSchema, prefixItems: unknown, items: unknown, context: Context): void {
|
|
1247
|
+
if (prefixItems === undefined) {
|
|
1248
|
+
if (items !== undefined) InternalRecord.assignProperty(out, "items", context.schema(items, "items"))
|
|
1249
|
+
return
|
|
1250
|
+
}
|
|
1251
|
+
InternalRecord.assignProperty(out, "items", context.schemaArray(prefixItems, "prefixItems", "items"))
|
|
1252
|
+
if (items !== undefined) {
|
|
1253
|
+
InternalRecord.assignProperty(out, "additionalItems", context.schema(items, "items", "additionalItems"))
|
|
1254
|
+
}
|
|
974
1255
|
}
|
|
975
1256
|
|
|
976
|
-
function
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
if (typeof exclusive !== "boolean") return node
|
|
983
|
-
|
|
984
|
-
const out = { ...node }
|
|
985
|
-
if (exclusive && typeof node[boundKey] === "number") {
|
|
986
|
-
out[exclusiveKey] = node[boundKey]
|
|
987
|
-
delete out[boundKey]
|
|
1257
|
+
function convertReference(out: JsonSchema, reference: unknown, context: Context): void {
|
|
1258
|
+
if (reference === undefined) return
|
|
1259
|
+
if (typeof reference === "string" && Object.keys(out).length > 0) {
|
|
1260
|
+
const referenceSchema: JsonSchema = {}
|
|
1261
|
+
context.reference(referenceSchema, reference)
|
|
1262
|
+
appendAllOf(out, referenceSchema)
|
|
988
1263
|
} else {
|
|
989
|
-
|
|
1264
|
+
context.reference(out, reference)
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
function convertDependencies(
|
|
1269
|
+
source: JsonSchema,
|
|
1270
|
+
out: JsonSchema,
|
|
1271
|
+
context: Context,
|
|
1272
|
+
targetDialect: "draft-04" | "draft-07"
|
|
1273
|
+
): void {
|
|
1274
|
+
const dependentRequired = Predicate.isObject(source.dependentRequired) ? source.dependentRequired : undefined
|
|
1275
|
+
const dependentSchemas = Predicate.isObject(source.dependentSchemas) ? source.dependentSchemas : undefined
|
|
1276
|
+
if (dependentRequired === undefined && dependentSchemas === undefined) return
|
|
1277
|
+
|
|
1278
|
+
const dependencies: JsonSchema = {}
|
|
1279
|
+
const keys = new Set([
|
|
1280
|
+
...Object.keys(dependentRequired ?? {}),
|
|
1281
|
+
...Object.keys(dependentSchemas ?? {})
|
|
1282
|
+
])
|
|
1283
|
+
for (const key of keys) {
|
|
1284
|
+
const required = dependentRequired?.[key]
|
|
1285
|
+
const dependency = dependentSchemas?.[key]
|
|
1286
|
+
const omitRequired = targetDialect === "draft-04" && Array.isArray(required) && required.length === 0
|
|
1287
|
+
if (dependency === undefined) {
|
|
1288
|
+
if (!omitRequired) InternalRecord.assignProperty(dependencies, key, required)
|
|
1289
|
+
} else if (required === undefined || omitRequired) {
|
|
1290
|
+
InternalRecord.assignProperty(
|
|
1291
|
+
dependencies,
|
|
1292
|
+
key,
|
|
1293
|
+
context.schemaAt(dependency, ["dependentSchemas", key], ["dependencies", key])
|
|
1294
|
+
)
|
|
1295
|
+
} else {
|
|
1296
|
+
InternalRecord.assignProperty(dependencies, key, {
|
|
1297
|
+
allOf: [
|
|
1298
|
+
context.schemaAt(dependency, ["dependentSchemas", key], ["dependencies", key, "allOf", "0"]),
|
|
1299
|
+
{ required }
|
|
1300
|
+
]
|
|
1301
|
+
})
|
|
1302
|
+
}
|
|
990
1303
|
}
|
|
1304
|
+
if (Object.keys(dependencies).length > 0) InternalRecord.assignProperty(out, "dependencies", dependencies)
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
function convertOpenApi30(root: JsonSchema): JsonSchema {
|
|
1308
|
+
return convertSchema(root, (source, context) => {
|
|
1309
|
+
const out: JsonSchema = {}
|
|
1310
|
+
|
|
1311
|
+
if (typeof source.$ref === "string") {
|
|
1312
|
+
context.reference(out, rewriteOpenApiComponentsReference(source.$ref))
|
|
1313
|
+
return out
|
|
1314
|
+
}
|
|
1315
|
+
rejectKeywordCollisions(source, OPEN_API_30_TO_2020_COLLISIONS, "Draft 2020-12", "OpenAPI 3.0")
|
|
1316
|
+
|
|
1317
|
+
for (const key of Object.keys(source)) {
|
|
1318
|
+
const value = source[key]
|
|
1319
|
+
if (
|
|
1320
|
+
convertSubschemaKeyword(
|
|
1321
|
+
out,
|
|
1322
|
+
key,
|
|
1323
|
+
value,
|
|
1324
|
+
context,
|
|
1325
|
+
OPEN_API_30_SCHEMA_SINGLE_KEYWORDS,
|
|
1326
|
+
OPEN_API_30_SCHEMA_MAP_KEYWORDS
|
|
1327
|
+
)
|
|
1328
|
+
) {
|
|
1329
|
+
continue
|
|
1330
|
+
}
|
|
1331
|
+
switch (key) {
|
|
1332
|
+
case "example":
|
|
1333
|
+
InternalRecord.assignProperty(out, "examples", [value])
|
|
1334
|
+
break
|
|
1335
|
+
case "nullable":
|
|
1336
|
+
case "exclusiveMinimum":
|
|
1337
|
+
case "exclusiveMaximum":
|
|
1338
|
+
break
|
|
1339
|
+
default:
|
|
1340
|
+
InternalRecord.assignProperty(out, key, value)
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
convertOpenApiExclusiveBound(source, out, "minimum")
|
|
1345
|
+
convertOpenApiExclusiveBound(source, out, "maximum")
|
|
1346
|
+
|
|
1347
|
+
if (source.nullable === true && typeof source.type === "string") {
|
|
1348
|
+
InternalRecord.assignProperty(out, "type", [source.type, "null"])
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
return out
|
|
1352
|
+
})
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
function convertOpenApiExclusiveBound(
|
|
1356
|
+
source: JsonSchema,
|
|
1357
|
+
out: JsonSchema,
|
|
1358
|
+
boundKey: "minimum" | "maximum"
|
|
1359
|
+
): void {
|
|
1360
|
+
const exclusiveKey = boundKey === "minimum" ? "exclusiveMinimum" : "exclusiveMaximum"
|
|
1361
|
+
const exclusive = source[exclusiveKey]
|
|
1362
|
+
if (typeof exclusive !== "boolean") {
|
|
1363
|
+
if (exclusive !== undefined) InternalRecord.assignProperty(out, exclusiveKey, exclusive)
|
|
1364
|
+
return
|
|
1365
|
+
}
|
|
1366
|
+
if (exclusive && typeof source[boundKey] === "number") {
|
|
1367
|
+
InternalRecord.assignProperty(out, exclusiveKey, source[boundKey])
|
|
1368
|
+
delete out[boundKey]
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
const DRAFT_04_TARGET_COLLISIONS = ["additionalItems", "definitions", "dependencies", "id"]
|
|
1373
|
+
|
|
1374
|
+
function draft04Adapter(source: JsonSchema, context: Context): JsonSchema {
|
|
1375
|
+
rejectKeywordCollisions(source, DRAFT_04_TARGET_COLLISIONS, "Draft-04", "Draft 2020-12")
|
|
1376
|
+
const out: JsonSchema = {}
|
|
1377
|
+
let reference: unknown = undefined
|
|
1378
|
+
let prefixItems: unknown = undefined
|
|
1379
|
+
let items: unknown = undefined
|
|
1380
|
+
let constSchema: JsonSchema | undefined
|
|
1381
|
+
|
|
1382
|
+
for (const key of Object.keys(source)) {
|
|
1383
|
+
const value = source[key]
|
|
1384
|
+
if (convertSubschemaKeyword(out, key, value, context, DRAFT_04_SCHEMA_SINGLE_KEYWORDS)) continue
|
|
1385
|
+
switch (key) {
|
|
1386
|
+
case "$ref":
|
|
1387
|
+
reference = value
|
|
1388
|
+
break
|
|
1389
|
+
case "$schema":
|
|
1390
|
+
convertMetaSchemaKeyword(out, value, context, META_SCHEMA_URI_DRAFT_04, "Draft-04")
|
|
1391
|
+
break
|
|
1392
|
+
case "$id":
|
|
1393
|
+
case "$anchor":
|
|
1394
|
+
break
|
|
1395
|
+
case "$defs":
|
|
1396
|
+
InternalRecord.assignProperty(out, "definitions", context.schemaMap(value, key, "definitions"))
|
|
1397
|
+
break
|
|
1398
|
+
case "prefixItems":
|
|
1399
|
+
prefixItems = value
|
|
1400
|
+
break
|
|
1401
|
+
case "items":
|
|
1402
|
+
items = value
|
|
1403
|
+
break
|
|
1404
|
+
case "$dynamicRef":
|
|
1405
|
+
case "$dynamicAnchor":
|
|
1406
|
+
case "$vocabulary":
|
|
1407
|
+
case "unevaluatedProperties":
|
|
1408
|
+
case "unevaluatedItems":
|
|
1409
|
+
case "propertyNames":
|
|
1410
|
+
unsupported(key, "Draft-04", "the target dialect has no equivalent")
|
|
1411
|
+
case "dependentRequired":
|
|
1412
|
+
case "dependentSchemas":
|
|
1413
|
+
case "contains":
|
|
1414
|
+
case "minContains":
|
|
1415
|
+
case "maxContains":
|
|
1416
|
+
case "if":
|
|
1417
|
+
case "then":
|
|
1418
|
+
case "else":
|
|
1419
|
+
case "minimum":
|
|
1420
|
+
case "maximum":
|
|
1421
|
+
case "exclusiveMinimum":
|
|
1422
|
+
case "exclusiveMaximum":
|
|
1423
|
+
break
|
|
1424
|
+
case "const":
|
|
1425
|
+
constSchema = { enum: [value] }
|
|
1426
|
+
break
|
|
1427
|
+
case "required":
|
|
1428
|
+
if (Array.isArray(value) && value.length === 0) break
|
|
1429
|
+
InternalRecord.assignProperty(out, key, value)
|
|
1430
|
+
break
|
|
1431
|
+
default:
|
|
1432
|
+
InternalRecord.assignProperty(out, key, value)
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
convertTuple(out, prefixItems, items, context)
|
|
1437
|
+
|
|
1438
|
+
convertDraft04ExclusiveBound(source, out, "minimum")
|
|
1439
|
+
convertDraft04ExclusiveBound(source, out, "maximum")
|
|
1440
|
+
convertDependencies(source, out, context, "draft-04")
|
|
1441
|
+
convertLegacyId(source, out, "id", "Draft-04")
|
|
1442
|
+
convertDraft04Conditionals(source, out, context)
|
|
1443
|
+
convertDraft04Contains(source, out, context)
|
|
1444
|
+
|
|
1445
|
+
if (constSchema !== undefined) {
|
|
1446
|
+
if (Object.hasOwn(source, "enum")) {
|
|
1447
|
+
appendAllOf(out, constSchema)
|
|
1448
|
+
} else {
|
|
1449
|
+
InternalRecord.assignProperty(out, "enum", constSchema.enum)
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
convertReference(out, reference, context)
|
|
1454
|
+
|
|
991
1455
|
return out
|
|
992
1456
|
}
|
|
993
1457
|
|
|
994
|
-
function
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1458
|
+
function convertDraft04Conditionals(source: JsonSchema, out: JsonSchema, context: Context): void {
|
|
1459
|
+
const hasIf = Object.hasOwn(source, "if")
|
|
1460
|
+
const hasThen = Object.hasOwn(source, "then")
|
|
1461
|
+
const hasElse = Object.hasOwn(source, "else")
|
|
1462
|
+
if (!hasIf || (!hasThen && !hasElse)) {
|
|
1463
|
+
if (hasIf) InternalRecord.assignProperty(out, "if", context.schema(source.if, "if"))
|
|
1464
|
+
if (hasThen) InternalRecord.assignProperty(out, "then", context.schema(source.then, "then"))
|
|
1465
|
+
if (hasElse) InternalRecord.assignProperty(out, "else", context.schema(source.else, "else"))
|
|
1466
|
+
return
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
const index = Array.isArray(out.allOf) ? out.allOf.length : 0
|
|
1470
|
+
const base = ["allOf", String(index), "anyOf"] as const
|
|
1471
|
+
const convertBranch = (key: "if" | "then" | "else", targetPath: Path): unknown =>
|
|
1472
|
+
context.schemaAt(source[key], [key], [...base, ...targetPath])
|
|
1473
|
+
let conditional: JsonSchema
|
|
1474
|
+
if (hasThen && hasElse) {
|
|
1475
|
+
if (hasSchemaIdentifier(source.if)) {
|
|
1476
|
+
unsupported("if", "Draft-04", "lowering both branches would duplicate a schema identifier")
|
|
1477
|
+
}
|
|
1478
|
+
// (if AND then) OR ((NOT if) AND else)
|
|
1479
|
+
conditional = {
|
|
1480
|
+
anyOf: [
|
|
1481
|
+
{
|
|
1482
|
+
allOf: [
|
|
1483
|
+
convertBranch("if", ["0", "allOf", "0"]),
|
|
1484
|
+
convertBranch("then", ["0", "allOf", "1"])
|
|
1485
|
+
]
|
|
1486
|
+
},
|
|
1487
|
+
{
|
|
1488
|
+
allOf: [
|
|
1489
|
+
{ not: convertBranch("if", ["1", "allOf", "0", "not"]) },
|
|
1490
|
+
convertBranch("else", ["1", "allOf", "1"])
|
|
1491
|
+
]
|
|
1492
|
+
}
|
|
1493
|
+
]
|
|
1494
|
+
}
|
|
1495
|
+
} else if (hasThen) {
|
|
1496
|
+
// (NOT if) OR then
|
|
1497
|
+
conditional = {
|
|
1498
|
+
anyOf: [
|
|
1499
|
+
{ not: convertBranch("if", ["0", "not"]) },
|
|
1500
|
+
convertBranch("then", ["1"])
|
|
1501
|
+
]
|
|
1502
|
+
}
|
|
1503
|
+
} else {
|
|
1504
|
+
// if OR else
|
|
1505
|
+
conditional = {
|
|
1506
|
+
anyOf: [
|
|
1507
|
+
convertBranch("if", ["0"]),
|
|
1508
|
+
convertBranch("else", ["1"])
|
|
1509
|
+
]
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
appendAllOf(out, conditional)
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
function hasSchemaIdentifier(node: unknown): boolean {
|
|
1516
|
+
if (!Predicate.isObject(node)) return false
|
|
1517
|
+
if (Object.hasOwn(node, "$id") || Object.hasOwn(node, "$anchor")) return true
|
|
1518
|
+
for (const key of Object.keys(node)) {
|
|
1519
|
+
const value = node[key]
|
|
1520
|
+
switch (key) {
|
|
1521
|
+
case "$defs":
|
|
1522
|
+
case "properties":
|
|
1523
|
+
case "patternProperties":
|
|
1524
|
+
case "dependentSchemas":
|
|
1525
|
+
if (Predicate.isObject(value) && Object.values(value).some(hasSchemaIdentifier)) return true
|
|
1526
|
+
break
|
|
1527
|
+
case "allOf":
|
|
1528
|
+
case "anyOf":
|
|
1529
|
+
case "oneOf":
|
|
1530
|
+
case "prefixItems":
|
|
1531
|
+
if (Array.isArray(value) && value.some(hasSchemaIdentifier)) return true
|
|
1532
|
+
break
|
|
1533
|
+
case "not":
|
|
1534
|
+
case "additionalProperties":
|
|
1535
|
+
case "propertyNames":
|
|
1536
|
+
case "unevaluatedProperties":
|
|
1537
|
+
case "items":
|
|
1538
|
+
case "contains":
|
|
1539
|
+
case "unevaluatedItems":
|
|
1540
|
+
case "if":
|
|
1541
|
+
case "then":
|
|
1542
|
+
case "else":
|
|
1543
|
+
case "contentSchema":
|
|
1544
|
+
if (hasSchemaIdentifier(value)) return true
|
|
1545
|
+
}
|
|
1001
1546
|
}
|
|
1547
|
+
return false
|
|
1548
|
+
}
|
|
1002
1549
|
|
|
1003
|
-
|
|
1004
|
-
if (
|
|
1550
|
+
function convertDraft04Contains(source: JsonSchema, out: JsonSchema, context: Context): void {
|
|
1551
|
+
if (!Object.hasOwn(source, "contains")) {
|
|
1552
|
+
if (Object.hasOwn(source, "minContains")) InternalRecord.assignProperty(out, "minContains", source.minContains)
|
|
1553
|
+
if (Object.hasOwn(source, "maxContains")) InternalRecord.assignProperty(out, "maxContains", source.maxContains)
|
|
1554
|
+
return
|
|
1555
|
+
}
|
|
1005
1556
|
|
|
1006
|
-
|
|
1007
|
-
|
|
1557
|
+
const minContains = source.minContains
|
|
1558
|
+
const maxContains = source.maxContains
|
|
1559
|
+
if ((minContains !== undefined && minContains !== 1) || maxContains !== undefined) {
|
|
1560
|
+
unsupported("minContains/maxContains", "Draft-04", "contains cardinality cannot be represented")
|
|
1561
|
+
}
|
|
1008
1562
|
|
|
1009
|
-
|
|
1010
|
-
|
|
1563
|
+
const index = Array.isArray(out.allOf) ? out.allOf.length : 0
|
|
1564
|
+
const contains = context.schemaAt(
|
|
1565
|
+
source.contains,
|
|
1566
|
+
["contains"],
|
|
1567
|
+
["allOf", String(index), "anyOf", "1", "not", "items", "not"]
|
|
1568
|
+
)
|
|
1569
|
+
appendAllOf(out, {
|
|
1570
|
+
anyOf: [
|
|
1571
|
+
{ not: { type: "array" } },
|
|
1572
|
+
{ not: { items: { not: contains } } }
|
|
1573
|
+
]
|
|
1574
|
+
})
|
|
1011
1575
|
}
|
|
1012
1576
|
|
|
1013
|
-
function
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
if (Array.isArray(t)) return t.includes("null") ? node : { ...node, type: [...t, "null"] }
|
|
1017
|
-
return node
|
|
1577
|
+
function appendAllOf(out: JsonSchema, schema: JsonSchema): void {
|
|
1578
|
+
if (Array.isArray(out.allOf)) out.allOf.push(schema)
|
|
1579
|
+
else InternalRecord.assignProperty(out, "allOf", [schema])
|
|
1018
1580
|
}
|
|
1019
1581
|
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
* const definitions: JsonSchema.Definitions = {
|
|
1044
|
-
* User: { type: "object", properties: { name: { type: "string" } } }
|
|
1045
|
-
* }
|
|
1046
|
-
*
|
|
1047
|
-
* JsonSchema.resolve$ref("#/$defs/User", definitions) // => { type: "object", properties: { name: { type: "string" } } }
|
|
1048
|
-
* JsonSchema.resolve$ref("#/$defs/Unknown", definitions) // => undefined
|
|
1049
|
-
* ```
|
|
1050
|
-
*
|
|
1051
|
-
* @see {@link resolveTopLevel$ref}
|
|
1052
|
-
* @see {@link Definitions}
|
|
1053
|
-
* @category getters
|
|
1054
|
-
* @since 4.0.0
|
|
1055
|
-
*/
|
|
1056
|
-
export function resolve$ref($ref: string, definitions: Definitions): JsonSchema | undefined {
|
|
1057
|
-
const tokens = $ref.split("/")
|
|
1058
|
-
const identifier = unescapeToken(tokens[tokens.length - 1])
|
|
1059
|
-
if (Object.hasOwn(definitions, identifier)) return definitions[identifier]
|
|
1582
|
+
function convertLegacyId(
|
|
1583
|
+
source: JsonSchema,
|
|
1584
|
+
out: JsonSchema,
|
|
1585
|
+
targetKey: "$id" | "id",
|
|
1586
|
+
dialect: string
|
|
1587
|
+
): void {
|
|
1588
|
+
const id = source.$id
|
|
1589
|
+
const anchor = source.$anchor
|
|
1590
|
+
if (anchor === undefined) {
|
|
1591
|
+
if (id !== undefined) InternalRecord.assignProperty(out, targetKey, id)
|
|
1592
|
+
return
|
|
1593
|
+
}
|
|
1594
|
+
if (typeof anchor !== "string" || !ANCHOR_REGEXP.test(anchor)) {
|
|
1595
|
+
unsupported("$anchor", dialect, "the anchor is not valid")
|
|
1596
|
+
}
|
|
1597
|
+
if (!LEGACY_ID_FRAGMENT_REGEXP.test(anchor)) {
|
|
1598
|
+
unsupported("$anchor", dialect, "the anchor cannot be represented as a plain-name fragment identifier")
|
|
1599
|
+
}
|
|
1600
|
+
if (id === undefined) {
|
|
1601
|
+
InternalRecord.assignProperty(out, targetKey, `#${anchor}`)
|
|
1602
|
+
} else {
|
|
1603
|
+
unsupported("$anchor", dialect, "it cannot be combined with the schema $id")
|
|
1604
|
+
}
|
|
1060
1605
|
}
|
|
1061
1606
|
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
* import { JsonSchema } from "effect"
|
|
1079
|
-
*
|
|
1080
|
-
* const doc: JsonSchema.Document<"draft-2020-12"> = {
|
|
1081
|
-
* dialect: "draft-2020-12",
|
|
1082
|
-
* schema: { $ref: "#/$defs/User" },
|
|
1083
|
-
* definitions: {
|
|
1084
|
-
* User: { type: "object", properties: { name: { type: "string" } } }
|
|
1085
|
-
* }
|
|
1086
|
-
* }
|
|
1087
|
-
*
|
|
1088
|
-
* const resolved = JsonSchema.resolveTopLevel$ref(doc)
|
|
1089
|
-
* resolved.schema // => { type: "object", properties: { name: { type: "string" } } }
|
|
1090
|
-
* ```
|
|
1091
|
-
*
|
|
1092
|
-
* @see {@link resolve$ref}
|
|
1093
|
-
* @see {@link Document}
|
|
1094
|
-
* @category transforming
|
|
1095
|
-
* @since 4.0.0
|
|
1096
|
-
*/
|
|
1097
|
-
export function resolveTopLevel$ref(document: Document<"draft-2020-12">): Document<"draft-2020-12"> {
|
|
1098
|
-
if (typeof document.schema.$ref === "string") {
|
|
1099
|
-
const schema = resolve$ref(document.schema.$ref, document.definitions)
|
|
1100
|
-
if (schema !== undefined) {
|
|
1101
|
-
return { ...document, schema }
|
|
1607
|
+
function convertDraft04ExclusiveBound(
|
|
1608
|
+
source: JsonSchema,
|
|
1609
|
+
out: JsonSchema,
|
|
1610
|
+
boundKey: "minimum" | "maximum"
|
|
1611
|
+
): void {
|
|
1612
|
+
const exclusiveKey = boundKey === "minimum" ? "exclusiveMinimum" : "exclusiveMaximum"
|
|
1613
|
+
const bound = source[boundKey]
|
|
1614
|
+
const exclusive = source[exclusiveKey]
|
|
1615
|
+
if (typeof exclusive === "number") {
|
|
1616
|
+
const isBoundStricter = typeof bound === "number" &&
|
|
1617
|
+
(boundKey === "minimum" ? bound > exclusive : bound < exclusive)
|
|
1618
|
+
if (isBoundStricter) {
|
|
1619
|
+
InternalRecord.assignProperty(out, boundKey, bound)
|
|
1620
|
+
} else {
|
|
1621
|
+
InternalRecord.assignProperty(out, boundKey, exclusive)
|
|
1622
|
+
InternalRecord.assignProperty(out, exclusiveKey, true)
|
|
1102
1623
|
}
|
|
1624
|
+
} else if (bound !== undefined) {
|
|
1625
|
+
InternalRecord.assignProperty(out, boundKey, bound)
|
|
1103
1626
|
}
|
|
1104
|
-
return document
|
|
1105
1627
|
}
|