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/dist/JsonSchema.js
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.js";
|
|
12
11
|
import * as InternalRecord from "./internal/record.js";
|
|
13
|
-
import {
|
|
12
|
+
import { formatUriFragment, parseUriFragment } from "./JsonPointer.js";
|
|
14
13
|
import * as Predicate from "./Predicate.js";
|
|
15
|
-
import * as Rec from "./Record.js";
|
|
16
14
|
/**
|
|
17
15
|
* Represents the `$schema` meta-schema URI for JSON Schema Draft-04.
|
|
18
16
|
*
|
|
@@ -65,15 +63,15 @@ export const META_SCHEMA_URI_DRAFT_07 = "http://json-schema.org/draft-07/schema#
|
|
|
65
63
|
* @since 4.0.0
|
|
66
64
|
*/
|
|
67
65
|
export const META_SCHEMA_URI_DRAFT_2020_12 = "https://json-schema.org/draft/2020-12/schema";
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const
|
|
66
|
+
const META_SCHEMA_URI_OPEN_API_3_1 = "https://spec.openapis.org/oas/3.1/dialect/base";
|
|
67
|
+
function isMetaSchemaUri(value, uri) {
|
|
68
|
+
return value === uri || value === (uri.endsWith("#") ? uri.slice(0, -1) : `${uri}#`);
|
|
69
|
+
}
|
|
70
|
+
function rewriteOpenApiComponentsReference(reference) {
|
|
71
|
+
const path = reference.startsWith("#") ? parseUriFragment(reference) : undefined;
|
|
72
|
+
return path !== undefined && path[0] === "components" && path[1] === "schemas" ? formatUriFragment(["$defs", ...path.slice(2)]) : reference;
|
|
73
|
+
}
|
|
74
|
+
const OPEN_API_31_TARGET_COLLISIONS = ["example", "discriminator", "xml", "externalDocs"];
|
|
77
75
|
/**
|
|
78
76
|
* Parses a raw Draft-07 JSON Schema into a `Document<"draft-2020-12">`.
|
|
79
77
|
*
|
|
@@ -85,13 +83,21 @@ const ARRAY_SUBSCHEMA_KEYWORDS = /*#__PURE__*/new Set(["allOf", "anyOf", "oneOf"
|
|
|
85
83
|
* **Details**
|
|
86
84
|
*
|
|
87
85
|
* This converts Draft-07 tuple syntax (`items` as array plus
|
|
88
|
-
* `additionalItems`) to Draft-2020-12 form (`prefixItems` plus `items`),
|
|
89
|
-
*
|
|
90
|
-
* `
|
|
86
|
+
* `additionalItems`) to Draft-2020-12 form (`prefixItems` plus `items`), splits
|
|
87
|
+
* `dependencies` into `dependentRequired` and `dependentSchemas`, converts
|
|
88
|
+
* plain-name `$id` fragments to `$anchor`, and extracts root-level
|
|
89
|
+
* `definitions` into the `definitions` field. Local JSON Pointer refs are
|
|
90
|
+
* relocated when one of these structural conversions moves its target.
|
|
91
91
|
*
|
|
92
92
|
* **Gotchas**
|
|
93
93
|
*
|
|
94
|
-
*
|
|
94
|
+
* Unknown and custom keywords are copied as opaque values. Their contents are
|
|
95
|
+
* not treated as nested schemas. Draft-07 keywords such as `if` / `then` /
|
|
96
|
+
* `else` and `contains` are preserved and their subschemas are converted.
|
|
97
|
+
* Siblings of a valid Draft-07 `$ref` are ignored according to Draft-07
|
|
98
|
+
* semantics. The conversion throws when a Draft-07 `$id` fragment cannot be
|
|
99
|
+
* represented as a Draft-2020-12 `$anchor`, or when an unknown Draft-07
|
|
100
|
+
* keyword would become an active Draft-2020-12 keyword after copying.
|
|
95
101
|
*
|
|
96
102
|
* **Example** (Parsing a Draft-07 schema)
|
|
97
103
|
*
|
|
@@ -120,65 +126,7 @@ const ARRAY_SUBSCHEMA_KEYWORDS = /*#__PURE__*/new Set(["allOf", "anyOf", "oneOf"
|
|
|
120
126
|
* @since 4.0.0
|
|
121
127
|
*/
|
|
122
128
|
export function fromSchemaDraft07(js) {
|
|
123
|
-
|
|
124
|
-
const schema = walk(js, true);
|
|
125
|
-
return {
|
|
126
|
-
dialect: "draft-2020-12",
|
|
127
|
-
schema,
|
|
128
|
-
definitions: definitions ?? {}
|
|
129
|
-
};
|
|
130
|
-
function walk(node, isRoot) {
|
|
131
|
-
if (Array.isArray(node)) return node.map(walkNested);
|
|
132
|
-
if (!Predicate.isObject(node)) return node;
|
|
133
|
-
const out = {};
|
|
134
|
-
let prefixItems = undefined;
|
|
135
|
-
let additionalItems = undefined;
|
|
136
|
-
for (const k of Object.keys(node)) {
|
|
137
|
-
const v = node[k];
|
|
138
|
-
if (k === "$ref") {
|
|
139
|
-
out.$ref = typeof v === "string" ? v.replace(RE_DEFINITIONS, "#/$defs") : v;
|
|
140
|
-
continue;
|
|
141
|
-
}
|
|
142
|
-
if (DRAFT_07_COPY_KEYWORDS.has(k)) {
|
|
143
|
-
out[k] = v;
|
|
144
|
-
continue;
|
|
145
|
-
}
|
|
146
|
-
if (rewriteSubschemaKeyword(out, k, v, walkNested, DRAFT_07_SINGLE_SUBSCHEMA_KEYWORDS)) continue;
|
|
147
|
-
switch (k) {
|
|
148
|
-
case "definitions":
|
|
149
|
-
{
|
|
150
|
-
const mapped = mapObject(v, walkNested);
|
|
151
|
-
if (isRoot) {
|
|
152
|
-
definitions = mapped;
|
|
153
|
-
} else {
|
|
154
|
-
out.definitions = mapped ?? v;
|
|
155
|
-
}
|
|
156
|
-
break;
|
|
157
|
-
}
|
|
158
|
-
case "items":
|
|
159
|
-
prefixItems = v;
|
|
160
|
-
break;
|
|
161
|
-
case "additionalItems":
|
|
162
|
-
additionalItems = v;
|
|
163
|
-
break;
|
|
164
|
-
default:
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
// Draft-07 tuples -> 2020-12 tuples
|
|
169
|
-
if (prefixItems !== undefined) {
|
|
170
|
-
if (Array.isArray(prefixItems)) {
|
|
171
|
-
out.prefixItems = prefixItems.map(walkNested);
|
|
172
|
-
if (additionalItems !== undefined) out.items = walkNested(additionalItems);
|
|
173
|
-
} else {
|
|
174
|
-
out.items = walkNested(prefixItems);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
return out;
|
|
178
|
-
}
|
|
179
|
-
function walkNested(node) {
|
|
180
|
-
return walk(node, false);
|
|
181
|
-
}
|
|
129
|
+
return fromSchemaDraft2020_12(convertDraft07(js));
|
|
182
130
|
}
|
|
183
131
|
/**
|
|
184
132
|
* Parses a raw Draft-2020-12 JSON Schema into a `Document<"draft-2020-12">`.
|
|
@@ -234,8 +182,17 @@ export function fromSchemaDraft2020_12(js) {
|
|
|
234
182
|
*
|
|
235
183
|
* **Details**
|
|
236
184
|
*
|
|
237
|
-
* This rewrites `#/components/schemas/...` refs to `#/$defs/...`,
|
|
238
|
-
* to
|
|
185
|
+
* This rewrites `#/components/schemas/...` refs to `#/$defs/...`, normalizes the
|
|
186
|
+
* OpenAPI base dialect URI to Draft 2020-12, converts the deprecated singular
|
|
187
|
+
* `example` field to `examples`, then delegates to
|
|
188
|
+
* {@link fromSchemaDraft2020_12}.
|
|
189
|
+
*
|
|
190
|
+
* **Gotchas**
|
|
191
|
+
*
|
|
192
|
+
* When both `example` and `examples` are present, the singular example is
|
|
193
|
+
* prepended to the array. Custom `$schema` dialect URIs and unknown keywords
|
|
194
|
+
* are copied opaquely. Component references inside a schema resource identified
|
|
195
|
+
* by `$id` are left unchanged because they are relative to that resource.
|
|
239
196
|
*
|
|
240
197
|
* **Example** (Parsing an OpenAPI 3.1 schema)
|
|
241
198
|
*
|
|
@@ -259,7 +216,20 @@ export function fromSchemaDraft2020_12(js) {
|
|
|
259
216
|
* @since 4.0.0
|
|
260
217
|
*/
|
|
261
218
|
export function fromSchemaOpenApi3_1(js) {
|
|
262
|
-
const
|
|
219
|
+
const isRootResource = createsResource(js.$id);
|
|
220
|
+
const schema = transformSchema(js, (schema, inEmbeddedResource) => {
|
|
221
|
+
if (!isRootResource && !inEmbeddedResource) rewriteSchemaRef(schema, rewriteOpenApiComponentsReference);
|
|
222
|
+
if (isMetaSchemaUri(schema.$schema, META_SCHEMA_URI_OPEN_API_3_1)) {
|
|
223
|
+
InternalRecord.assignProperty(schema, "$schema", META_SCHEMA_URI_DRAFT_2020_12);
|
|
224
|
+
}
|
|
225
|
+
if (Object.hasOwn(schema, "example")) {
|
|
226
|
+
const examples = schema.examples;
|
|
227
|
+
if (examples === undefined || Array.isArray(examples)) {
|
|
228
|
+
InternalRecord.assignProperty(schema, "examples", [schema.example, ...(examples ?? [])]);
|
|
229
|
+
delete schema.example;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
});
|
|
263
233
|
return fromSchemaDraft2020_12(schema);
|
|
264
234
|
}
|
|
265
235
|
/**
|
|
@@ -272,10 +242,19 @@ export function fromSchemaOpenApi3_1(js) {
|
|
|
272
242
|
*
|
|
273
243
|
* **Details**
|
|
274
244
|
*
|
|
275
|
-
* This
|
|
276
|
-
* `example`,
|
|
277
|
-
*
|
|
278
|
-
*
|
|
245
|
+
* This directly converts OpenAPI 3.0 schema objects to Draft-2020-12. It
|
|
246
|
+
* handles `nullable`, singular `example`, boolean `exclusiveMinimum` and
|
|
247
|
+
* `exclusiveMaximum`, and OpenAPI component refs. Only values in OpenAPI
|
|
248
|
+
* schema positions are traversed as schemas.
|
|
249
|
+
*
|
|
250
|
+
* **Gotchas**
|
|
251
|
+
*
|
|
252
|
+
* OpenAPI 3.0 `nullable` is applied only when the same Schema Object has an
|
|
253
|
+
* explicit string `type`; other constraints such as `enum` are left
|
|
254
|
+
* unchanged. Unknown keywords, vendor extensions, and annotation values are
|
|
255
|
+
* copied opaquely unless their name would become active in Draft 2020-12 and
|
|
256
|
+
* change meaning, in which case conversion throws. Siblings of a valid
|
|
257
|
+
* OpenAPI 3.0 `$ref` are ignored.
|
|
279
258
|
*
|
|
280
259
|
* **Example** (Parsing an OpenAPI 3.0 nullable schema)
|
|
281
260
|
*
|
|
@@ -297,8 +276,7 @@ export function fromSchemaOpenApi3_1(js) {
|
|
|
297
276
|
* @since 4.0.0
|
|
298
277
|
*/
|
|
299
278
|
export function fromSchemaOpenApi3_0(schema) {
|
|
300
|
-
|
|
301
|
-
return fromSchemaDraft07(normalized);
|
|
279
|
+
return fromSchemaDraft2020_12(convertOpenApi30(schema));
|
|
302
280
|
}
|
|
303
281
|
/**
|
|
304
282
|
* Converts a `Document<"draft-2020-12">` to a `Document<"draft-07">`.
|
|
@@ -312,12 +290,20 @@ export function fromSchemaOpenApi3_0(schema) {
|
|
|
312
290
|
*
|
|
313
291
|
* This rewrites `#/$defs/...` refs to `#/definitions/...`, converts
|
|
314
292
|
* Draft-2020-12 tuple syntax (`prefixItems` plus `items`) to Draft-07 form
|
|
315
|
-
* (`items` as array plus `additionalItems`),
|
|
316
|
-
* and
|
|
293
|
+
* (`items` as array plus `additionalItems`), merges `dependentRequired` and
|
|
294
|
+
* `dependentSchemas` into `dependencies`, and converts both the root schema
|
|
295
|
+
* and all definitions. Local JSON Pointer refs are relocated when structural
|
|
296
|
+
* keywords move.
|
|
317
297
|
*
|
|
318
298
|
* **Gotchas**
|
|
319
299
|
*
|
|
320
|
-
*
|
|
300
|
+
* Unknown and custom keywords are copied as opaque values. Known keywords
|
|
301
|
+
* that Draft-07 cannot represent cause the conversion to throw
|
|
302
|
+
* instead of being dropped. These include dynamic references,
|
|
303
|
+
* `unevaluatedProperties`, `unevaluatedItems`, and non-default `minContains`
|
|
304
|
+
* or `maxContains` constraints. Conversion also throws when an opaque
|
|
305
|
+
* Draft-2020-12 keyword would collide with an active Draft-07 keyword, or when
|
|
306
|
+
* `$id` and `$anchor` occur together because Draft-07 cannot preserve both identifiers.
|
|
321
307
|
*
|
|
322
308
|
* **Example** (Converting to Draft-07)
|
|
323
309
|
*
|
|
@@ -345,8 +331,7 @@ export function fromSchemaOpenApi3_0(schema) {
|
|
|
345
331
|
export function toDocumentDraft07(document) {
|
|
346
332
|
return {
|
|
347
333
|
dialect: "draft-07",
|
|
348
|
-
|
|
349
|
-
definitions: Rec.map(document.definitions, toSchemaDraft07)
|
|
334
|
+
...convertDocument(document, draft07Adapter)
|
|
350
335
|
};
|
|
351
336
|
}
|
|
352
337
|
/**
|
|
@@ -359,14 +344,23 @@ export function toDocumentDraft07(document) {
|
|
|
359
344
|
*
|
|
360
345
|
* **Details**
|
|
361
346
|
*
|
|
362
|
-
* This rewrites `#/$defs/...` refs to `#/definitions/...`, converts
|
|
363
|
-
* syntax, lowers `const` to `enum`,
|
|
364
|
-
*
|
|
347
|
+
* This directly rewrites `#/$defs/...` refs to `#/definitions/...`, converts
|
|
348
|
+
* tuple syntax, merges canonical dependencies, lowers `const` to `enum`,
|
|
349
|
+
* converts numeric exclusive bounds to the Draft-04 boolean form, lowers
|
|
350
|
+
* conditionals and basic `contains` through boolean applicators, and converts
|
|
351
|
+
* both the root schema and all definitions.
|
|
365
352
|
*
|
|
366
353
|
* **Gotchas**
|
|
367
354
|
*
|
|
368
|
-
*
|
|
369
|
-
*
|
|
355
|
+
* Unknown and custom keywords are copied as opaque values. Newer annotation
|
|
356
|
+
* keywords are preserved as Draft-04 extensions. Known keywords
|
|
357
|
+
* without a Draft-04 equivalent, including `propertyNames`, non-default
|
|
358
|
+
* `contains` cardinality, dynamic references, and unevaluated constraints,
|
|
359
|
+
* cause the conversion to throw instead of being dropped. A conditional with
|
|
360
|
+
* both branches also throws when lowering it would duplicate a nested schema
|
|
361
|
+
* identifier. Conversion also throws when an opaque Draft-2020-12 keyword
|
|
362
|
+
* would collide with an active Draft-04 keyword, or when `$id` and `$anchor`
|
|
363
|
+
* occur together because Draft-04 cannot preserve both identifiers.
|
|
370
364
|
*
|
|
371
365
|
* **Example** (Converting exclusive bounds)
|
|
372
366
|
*
|
|
@@ -386,135 +380,14 @@ export function toDocumentDraft07(document) {
|
|
|
386
380
|
* @since 4.0.0
|
|
387
381
|
*/
|
|
388
382
|
export function toDocumentDraft04(document) {
|
|
389
|
-
const draft07 = toDocumentDraft07(document);
|
|
390
383
|
return {
|
|
391
384
|
dialect: "draft-04",
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
}
|
|
396
|
-
function toSchemaDraft04(schema) {
|
|
397
|
-
return walk(schema);
|
|
398
|
-
function walk(node) {
|
|
399
|
-
if (node === true) return {};
|
|
400
|
-
if (node === false) return {
|
|
401
|
-
not: {}
|
|
402
|
-
};
|
|
403
|
-
if (Array.isArray(node)) return node.map(walk);
|
|
404
|
-
if (!Predicate.isObject(node)) return node;
|
|
405
|
-
const src = node;
|
|
406
|
-
const out = {};
|
|
407
|
-
let hasConst = false;
|
|
408
|
-
let constValue = undefined;
|
|
409
|
-
for (const k of Object.keys(src)) {
|
|
410
|
-
const v = src[k];
|
|
411
|
-
if (DRAFT_04_COPY_KEYWORDS.has(k)) {
|
|
412
|
-
out[k] = v;
|
|
413
|
-
continue;
|
|
414
|
-
}
|
|
415
|
-
if (rewriteSubschemaKeyword(out, k, v, walk, DRAFT_04_SINGLE_SUBSCHEMA_KEYWORDS)) continue;
|
|
416
|
-
switch (k) {
|
|
417
|
-
case "const":
|
|
418
|
-
hasConst = true;
|
|
419
|
-
constValue = v;
|
|
420
|
-
break;
|
|
421
|
-
case "minimum":
|
|
422
|
-
case "maximum":
|
|
423
|
-
case "exclusiveMinimum":
|
|
424
|
-
case "exclusiveMaximum":
|
|
425
|
-
break;
|
|
426
|
-
case "additionalProperties":
|
|
427
|
-
case "additionalItems":
|
|
428
|
-
out[k] = typeof v === "boolean" ? v : walk(v);
|
|
429
|
-
break;
|
|
430
|
-
case "items":
|
|
431
|
-
out.items = Array.isArray(v) ? v.map(walk) : walk(v);
|
|
432
|
-
break;
|
|
433
|
-
default:
|
|
434
|
-
break;
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
convertExclusiveBound(src, out, "minimum", "exclusiveMinimum", (bound, exclusive) => bound > exclusive);
|
|
438
|
-
convertExclusiveBound(src, out, "maximum", "exclusiveMaximum", (bound, exclusive) => bound < exclusive);
|
|
439
|
-
if (hasConst) {
|
|
440
|
-
const constSchema = {
|
|
441
|
-
enum: [constValue]
|
|
442
|
-
};
|
|
443
|
-
if (Object.hasOwn(src, "enum")) {
|
|
444
|
-
out.allOf = Array.isArray(out.allOf) ? [...out.allOf, constSchema] : [constSchema];
|
|
445
|
-
} else {
|
|
446
|
-
out.enum = constSchema.enum;
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
return out;
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
function convertExclusiveBound(src, out, boundKey, exclusiveKey, isBoundStricter) {
|
|
453
|
-
const bound = src[boundKey];
|
|
454
|
-
const exclusive = src[exclusiveKey];
|
|
455
|
-
if (typeof exclusive === "number") {
|
|
456
|
-
if (typeof bound === "number" && isBoundStricter(bound, exclusive)) {
|
|
457
|
-
out[boundKey] = bound;
|
|
458
|
-
} else {
|
|
459
|
-
out[boundKey] = exclusive;
|
|
460
|
-
out[exclusiveKey] = true;
|
|
461
|
-
}
|
|
462
|
-
} else if (bound !== undefined) {
|
|
463
|
-
out[boundKey] = bound;
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
function toSchemaDraft07(schema) {
|
|
467
|
-
return transformSchema(schema, src => {
|
|
468
|
-
rewriteSchemaRef(src, ref => ref.replace(RE_DEFS, "#/definitions"));
|
|
469
|
-
const out = {};
|
|
470
|
-
let prefixItems = undefined;
|
|
471
|
-
let items = undefined;
|
|
472
|
-
for (const k of Object.keys(src)) {
|
|
473
|
-
const v = src[k];
|
|
474
|
-
if (k === "required" && Array.isArray(v) && v.length === 0) continue;
|
|
475
|
-
if (DRAFT_07_COPY_KEYWORDS.has(k)) {
|
|
476
|
-
out[k] = v;
|
|
477
|
-
continue;
|
|
478
|
-
}
|
|
479
|
-
if (MAP_SUBSCHEMA_KEYWORDS.has(k) || ARRAY_SUBSCHEMA_KEYWORDS.has(k) || DRAFT_07_SINGLE_SUBSCHEMA_KEYWORDS.has(k)) {
|
|
480
|
-
out[k] = v;
|
|
481
|
-
continue;
|
|
482
|
-
}
|
|
483
|
-
switch (k) {
|
|
484
|
-
// Tuple handling (2020-12 form)
|
|
485
|
-
case "prefixItems":
|
|
486
|
-
prefixItems = v;
|
|
487
|
-
break;
|
|
488
|
-
case "items":
|
|
489
|
-
items = v;
|
|
490
|
-
break;
|
|
491
|
-
default:
|
|
492
|
-
// drop everything else (subset)
|
|
493
|
-
break;
|
|
385
|
+
...convertDocument(document, draft04Adapter, {
|
|
386
|
+
booleanAdapter: schema => schema ? {} : {
|
|
387
|
+
not: {}
|
|
494
388
|
}
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
if (prefixItems !== undefined) {
|
|
498
|
-
if (Array.isArray(prefixItems)) {
|
|
499
|
-
out.items = prefixItems;
|
|
500
|
-
if (items !== undefined) out.additionalItems = items;
|
|
501
|
-
} else {
|
|
502
|
-
// Non-standard, but keep a reasonable behavior
|
|
503
|
-
out.items = prefixItems;
|
|
504
|
-
}
|
|
505
|
-
} else if (items !== undefined) {
|
|
506
|
-
// Regular items schema stays as items
|
|
507
|
-
out.items = items;
|
|
508
|
-
}
|
|
509
|
-
const $ref = out.$ref;
|
|
510
|
-
if (typeof $ref === "string" && Object.keys(out).length > 1) {
|
|
511
|
-
delete out.$ref;
|
|
512
|
-
out.allOf = [{
|
|
513
|
-
$ref
|
|
514
|
-
}, ...(Array.isArray(out.allOf) ? out.allOf : [])];
|
|
515
|
-
}
|
|
516
|
-
return out;
|
|
517
|
-
});
|
|
389
|
+
})
|
|
390
|
+
};
|
|
518
391
|
}
|
|
519
392
|
/**
|
|
520
393
|
* Converts a `MultiDocument<"draft-2020-12">` to a
|
|
@@ -537,7 +410,12 @@ function toSchemaDraft07(schema) {
|
|
|
537
410
|
*
|
|
538
411
|
* **Gotchas**
|
|
539
412
|
*
|
|
540
|
-
* External refs and local refs outside `#/$defs` are left unchanged.
|
|
413
|
+
* External refs and local refs outside `#/$defs` are left unchanged. Conversion
|
|
414
|
+
* throws when a custom keyword would become an active OpenAPI keyword and
|
|
415
|
+
* therefore change meaning. References inside schema resources identified by
|
|
416
|
+
* `$id` are left unchanged. Conversion throws when an identified root schema
|
|
417
|
+
* references the detached shared definitions pool because OpenAPI cannot
|
|
418
|
+
* preserve that fragment reference.
|
|
541
419
|
*
|
|
542
420
|
* **Example** (Converting to OpenAPI 3.1)
|
|
543
421
|
*
|
|
@@ -580,21 +458,34 @@ export function toMultiDocumentOpenApi3_1(multiDocument) {
|
|
|
580
458
|
usedKeys.add(candidate);
|
|
581
459
|
keyMap.set(key, candidate);
|
|
582
460
|
}
|
|
583
|
-
function rewrite(schema) {
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
461
|
+
function rewrite(schema, rejectSharedDefinitionRefs = false) {
|
|
462
|
+
const isRootResource = createsResource(schema.$id);
|
|
463
|
+
const localDefinitions = Predicate.isObject(schema.$defs) ? schema.$defs : undefined;
|
|
464
|
+
return transformSchema(schema, (schema, inEmbeddedResource) => {
|
|
465
|
+
rejectKeywordCollisions(schema, OPEN_API_31_TARGET_COLLISIONS, "OpenAPI 3.1", "Draft 2020-12");
|
|
466
|
+
rewriteSchemaRef(schema, (reference, keyword) => {
|
|
467
|
+
const path = reference.startsWith("#") ? parseUriFragment(reference) : undefined;
|
|
468
|
+
if (path === undefined || path[0] !== "$defs" || path.length < 2) return reference;
|
|
469
|
+
const key = path[1];
|
|
470
|
+
if (isRootResource) {
|
|
471
|
+
if (rejectSharedDefinitionRefs && !inEmbeddedResource && Object.hasOwn(multiDocument.definitions, key) && (localDefinitions === undefined || !Object.hasOwn(localDefinitions, key))) {
|
|
472
|
+
unsupported(keyword, "OpenAPI 3.1", "a schema resource cannot reference the shared definitions pool");
|
|
473
|
+
}
|
|
474
|
+
return reference;
|
|
475
|
+
}
|
|
476
|
+
return inEmbeddedResource ? reference : formatUriFragment(["components", "schemas", keyMap.get(key) ?? key, ...path.slice(2)]);
|
|
477
|
+
});
|
|
592
478
|
});
|
|
593
479
|
}
|
|
480
|
+
const schemas = multiDocument.schemas.map(schema => rewrite(schema, true));
|
|
481
|
+
const definitions = {};
|
|
482
|
+
for (const key of definitionKeys) {
|
|
483
|
+
InternalRecord.assignProperty(definitions, keyMap.get(key) ?? key, rewrite(multiDocument.definitions[key]));
|
|
484
|
+
}
|
|
594
485
|
return {
|
|
595
486
|
dialect: "openapi-3.1",
|
|
596
|
-
schemas
|
|
597
|
-
definitions
|
|
487
|
+
schemas,
|
|
488
|
+
definitions
|
|
598
489
|
};
|
|
599
490
|
}
|
|
600
491
|
/** @internal */
|
|
@@ -608,10 +499,16 @@ export const VALID_OPEN_API_COMPONENTS_SCHEMAS_KEY_REGEXP = /^[a-zA-Z0-9.\-_]+$/
|
|
|
608
499
|
export function sanitizeOpenApiComponentsSchemasKey(s) {
|
|
609
500
|
return s.length === 0 ? "_" : s.replace(/[^a-zA-Z0-9._-]/gu, "_");
|
|
610
501
|
}
|
|
502
|
+
/** @internal */
|
|
503
|
+
export function getReferenceKey($ref) {
|
|
504
|
+
const path = $ref.startsWith("#") ? parseUriFragment($ref) : undefined;
|
|
505
|
+
return path !== undefined && path.length === 2 && path[0] === "$defs" ? path[1] : undefined;
|
|
506
|
+
}
|
|
611
507
|
function transformSchema(node, transform) {
|
|
612
|
-
return walk(node);
|
|
613
|
-
function walk(node) {
|
|
508
|
+
return walk(node, false, true);
|
|
509
|
+
function walk(node, inheritedResource, isRoot = false) {
|
|
614
510
|
if (!Predicate.isObject(node)) return node;
|
|
511
|
+
const inEmbeddedResource = inheritedResource || !isRoot && createsResource(node.$id);
|
|
615
512
|
const out = {};
|
|
616
513
|
for (const key of Object.keys(node)) {
|
|
617
514
|
const value = node[key];
|
|
@@ -621,13 +518,13 @@ function transformSchema(node, transform) {
|
|
|
621
518
|
case "properties":
|
|
622
519
|
case "patternProperties":
|
|
623
520
|
case "dependentSchemas":
|
|
624
|
-
transformed = mapObject(value, walk) ?? value;
|
|
521
|
+
transformed = mapObject(value, value => walk(value, inEmbeddedResource)) ?? value;
|
|
625
522
|
break;
|
|
626
523
|
case "allOf":
|
|
627
524
|
case "anyOf":
|
|
628
525
|
case "oneOf":
|
|
629
526
|
case "prefixItems":
|
|
630
|
-
transformed = Array.isArray(value) ? value.map(walk) : value;
|
|
527
|
+
transformed = Array.isArray(value) ? value.map(value => walk(value, inEmbeddedResource)) : value;
|
|
631
528
|
break;
|
|
632
529
|
case "not":
|
|
633
530
|
case "additionalProperties":
|
|
@@ -640,201 +537,659 @@ function transformSchema(node, transform) {
|
|
|
640
537
|
case "then":
|
|
641
538
|
case "else":
|
|
642
539
|
case "contentSchema":
|
|
643
|
-
transformed = walk(value);
|
|
540
|
+
transformed = walk(value, inEmbeddedResource);
|
|
644
541
|
}
|
|
645
542
|
InternalRecord.assignProperty(out, key, transformed);
|
|
646
543
|
}
|
|
647
|
-
|
|
544
|
+
transform(out, inEmbeddedResource);
|
|
545
|
+
return out;
|
|
648
546
|
}
|
|
649
547
|
}
|
|
650
548
|
/** @internal */
|
|
651
549
|
export function rewriteRefs(schema, rewrite) {
|
|
652
|
-
return transformSchema(schema, schema =>
|
|
550
|
+
return transformSchema(schema, schema => {
|
|
551
|
+
rewriteSchemaRef(schema, rewrite);
|
|
552
|
+
});
|
|
653
553
|
}
|
|
654
554
|
function rewriteSchemaRef(schema, rewrite) {
|
|
655
555
|
if (typeof schema.$ref === "string") {
|
|
656
|
-
InternalRecord.assignProperty(schema, "$ref", rewrite(schema.$ref));
|
|
556
|
+
InternalRecord.assignProperty(schema, "$ref", rewrite(schema.$ref, "$ref"));
|
|
557
|
+
}
|
|
558
|
+
if (typeof schema.$dynamicRef === "string") {
|
|
559
|
+
InternalRecord.assignProperty(schema, "$dynamicRef", rewrite(schema.$dynamicRef, "$dynamicRef"));
|
|
657
560
|
}
|
|
658
|
-
return schema;
|
|
659
561
|
}
|
|
660
562
|
function mapObject(value, f) {
|
|
661
|
-
|
|
563
|
+
if (!Predicate.isObject(value)) return undefined;
|
|
564
|
+
const out = {};
|
|
565
|
+
for (const key of Object.keys(value)) {
|
|
566
|
+
InternalRecord.assignProperty(out, key, f(value[key], key));
|
|
567
|
+
}
|
|
568
|
+
return out;
|
|
662
569
|
}
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
570
|
+
// Adapters decide which values are schemas. The kernel only handles recursion,
|
|
571
|
+
// resource scopes, and reference relocation between structural source/target paths.
|
|
572
|
+
function runConverter(adapter, options, use) {
|
|
573
|
+
const locations = new Map();
|
|
574
|
+
const references = [];
|
|
575
|
+
let rootUri = ROOT_URI;
|
|
576
|
+
function convert(root, sourcePath = [], targetPath = []) {
|
|
577
|
+
if (sourcePath.length === 0 && options?.trackIds) {
|
|
578
|
+
const id = Predicate.isObject(root) ? getResourceId(root) : undefined;
|
|
579
|
+
rootUri = resolveResourceUri(id, ROOT_URI) ?? ROOT_URI;
|
|
580
|
+
}
|
|
581
|
+
return loop(root, sourcePath, targetPath, {
|
|
582
|
+
sourceRoot: [],
|
|
583
|
+
targetRoot: [],
|
|
584
|
+
uri: rootUri
|
|
585
|
+
});
|
|
667
586
|
}
|
|
668
|
-
|
|
669
|
-
out
|
|
670
|
-
|
|
587
|
+
function finish() {
|
|
588
|
+
for (const [out, value, sourceResource] of references) {
|
|
589
|
+
let reference = value;
|
|
590
|
+
const resolved = resolveUrl(value, sourceResource);
|
|
591
|
+
if (resolved !== undefined) {
|
|
592
|
+
const sourcePointer = parseUriFragment(resolved.hash);
|
|
593
|
+
resolved.hash = "";
|
|
594
|
+
if (sourcePointer !== undefined) {
|
|
595
|
+
const targetPath = locations.get(locationKey(resolved.href, sourcePointer));
|
|
596
|
+
if (targetPath !== undefined) reference = relocateReference(value, targetPath);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
InternalRecord.assignProperty(out, "$ref", reference);
|
|
600
|
+
}
|
|
671
601
|
}
|
|
672
|
-
|
|
673
|
-
|
|
602
|
+
const out = use(convert);
|
|
603
|
+
finish();
|
|
604
|
+
return out;
|
|
605
|
+
function loop(node, sourcePath, targetPath, resourceScope) {
|
|
606
|
+
if (typeof node === "boolean") {
|
|
607
|
+
recordLocations(sourcePath, targetPath, resourceScope);
|
|
608
|
+
return options?.booleanAdapter?.(node) ?? node;
|
|
609
|
+
}
|
|
610
|
+
if (!Predicate.isObject(node)) return node;
|
|
611
|
+
let currentResourceScope = resourceScope;
|
|
612
|
+
const id = getResourceId(node);
|
|
613
|
+
if (sourcePath.length > 0 && options?.trackIds && createsResource(id)) {
|
|
614
|
+
const uri = resolveResourceUri(id, resourceScope.uri);
|
|
615
|
+
if (uri !== undefined) {
|
|
616
|
+
currentResourceScope = {
|
|
617
|
+
parent: resourceScope,
|
|
618
|
+
sourceRoot: sourcePath,
|
|
619
|
+
targetRoot: targetPath,
|
|
620
|
+
uri
|
|
621
|
+
};
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
recordLocations(sourcePath, targetPath, currentResourceScope);
|
|
625
|
+
const currentResource = currentResourceScope.uri;
|
|
626
|
+
const context = {
|
|
627
|
+
isDocumentRoot: sourcePath.length === 0,
|
|
628
|
+
schema(value, sourceKey, targetKey = sourceKey) {
|
|
629
|
+
return loop(value, [...sourcePath, sourceKey], [...targetPath, targetKey], currentResourceScope);
|
|
630
|
+
},
|
|
631
|
+
schemaAt(value, sourceSuffix, targetSuffix) {
|
|
632
|
+
return loop(value, [...sourcePath, ...sourceSuffix], [...targetPath, ...targetSuffix], currentResourceScope);
|
|
633
|
+
},
|
|
634
|
+
schemaArray(value, sourceKey, targetKey = sourceKey) {
|
|
635
|
+
return Array.isArray(value) ? value.map((item, index) => loop(item, [...sourcePath, sourceKey, String(index)], [...targetPath, targetKey, String(index)], currentResourceScope)) : value;
|
|
636
|
+
},
|
|
637
|
+
schemaMap(value, sourceKey, targetKey = sourceKey) {
|
|
638
|
+
if (!Predicate.isObject(value)) return value;
|
|
639
|
+
return mapObject(value, (item, key) => loop(item, [...sourcePath, sourceKey, key], [...targetPath, targetKey, key], currentResourceScope));
|
|
640
|
+
},
|
|
641
|
+
reference(out, value) {
|
|
642
|
+
if (typeof value === "string") {
|
|
643
|
+
references.push([out, value, currentResource]);
|
|
644
|
+
} else {
|
|
645
|
+
InternalRecord.assignProperty(out, "$ref", value);
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
};
|
|
649
|
+
return adapter(node, context);
|
|
650
|
+
}
|
|
651
|
+
function getResourceId(schema) {
|
|
652
|
+
return options?.ignoreRefSiblings === true && typeof schema.$ref === "string" ? undefined : schema.$id;
|
|
653
|
+
}
|
|
654
|
+
function recordLocations(sourcePath, targetPath, scope) {
|
|
655
|
+
// A JSON Pointer can address an embedded schema from any containing resource.
|
|
656
|
+
if (scope.parent !== undefined) recordLocations(sourcePath, targetPath, scope.parent);
|
|
657
|
+
locations.set(locationKey(scope.uri, sourcePath.slice(scope.sourceRoot.length)), targetPath.slice(scope.targetRoot.length));
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
const ROOT_URI = "https://effect.invalid/.json-schema/";
|
|
661
|
+
function resolveUrl(value, base) {
|
|
662
|
+
return URL.canParse(value, base) ? new URL(value, base) : undefined;
|
|
663
|
+
}
|
|
664
|
+
function resolveResourceUri(value, base) {
|
|
665
|
+
if (typeof value !== "string") return undefined;
|
|
666
|
+
const url = resolveUrl(value, base);
|
|
667
|
+
if (url === undefined) return undefined;
|
|
668
|
+
url.hash = "";
|
|
669
|
+
return url.href;
|
|
670
|
+
}
|
|
671
|
+
function relocateReference(reference, targetPath) {
|
|
672
|
+
const index = reference.indexOf("#");
|
|
673
|
+
if (index === -1 && targetPath.length === 0) return reference;
|
|
674
|
+
const uri = index === -1 ? reference : reference.slice(0, index);
|
|
675
|
+
return `${uri}${formatUriFragment(targetPath)}`;
|
|
676
|
+
}
|
|
677
|
+
function locationKey(resource, pointer) {
|
|
678
|
+
return `${resource}\u0000${JSON.stringify(pointer)}`;
|
|
679
|
+
}
|
|
680
|
+
function createsResource(id) {
|
|
681
|
+
return typeof id === "string" && id.length > 0 && id[0] !== "#";
|
|
682
|
+
}
|
|
683
|
+
function convertSchema(root, adapter, options) {
|
|
684
|
+
return runConverter(adapter, options, convert => convert(root));
|
|
685
|
+
}
|
|
686
|
+
function convertDocument(document, adapter, options) {
|
|
687
|
+
return runConverter(adapter, {
|
|
688
|
+
...options,
|
|
689
|
+
trackIds: true
|
|
690
|
+
}, convert => ({
|
|
691
|
+
schema: convert(document.schema),
|
|
692
|
+
definitions: mapObject(document.definitions, (definition, key) => convert(definition, ["$defs", key], ["definitions", key]))
|
|
693
|
+
}));
|
|
694
|
+
}
|
|
695
|
+
const SCHEMA_MAP_KEYWORDS = /*#__PURE__*/new Set(["properties", "patternProperties"]);
|
|
696
|
+
const SCHEMA_ARRAY_KEYWORDS = /*#__PURE__*/new Set(["allOf", "anyOf", "oneOf"]);
|
|
697
|
+
const JSON_SCHEMA_SINGLE_KEYWORDS = /*#__PURE__*/new Set(["not", "additionalProperties", "propertyNames", "contains", "if", "then", "else", "contentSchema"]);
|
|
698
|
+
const OPEN_API_30_SCHEMA_MAP_KEYWORDS = /*#__PURE__*/new Set(["properties"]);
|
|
699
|
+
const OPEN_API_30_SCHEMA_SINGLE_KEYWORDS = /*#__PURE__*/new Set(["not", "items", "additionalProperties"]);
|
|
700
|
+
const DRAFT_04_SCHEMA_SINGLE_KEYWORDS = /*#__PURE__*/new Set(["not", "additionalProperties", "contentSchema"]);
|
|
701
|
+
function convertSubschemaKeyword(out, key, value, context, singleKeywords, mapKeywords = SCHEMA_MAP_KEYWORDS) {
|
|
702
|
+
let converted;
|
|
703
|
+
if (mapKeywords.has(key)) converted = context.schemaMap(value, key);else if (SCHEMA_ARRAY_KEYWORDS.has(key)) converted = context.schemaArray(value, key);else if (singleKeywords.has(key)) converted = context.schema(value, key);else return false;
|
|
704
|
+
InternalRecord.assignProperty(out, key, converted);
|
|
674
705
|
return true;
|
|
675
706
|
}
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
if (
|
|
687
|
-
out.
|
|
707
|
+
const PRE_2020_TO_2020_COLLISIONS = ["$anchor", "$defs", "$dynamicAnchor", "$dynamicRef", "$vocabulary", "contentSchema", "dependentRequired", "dependentSchemas", "maxContains", "minContains", "prefixItems", "unevaluatedItems", "unevaluatedProperties"];
|
|
708
|
+
const DRAFT_07_TO_2020_COLLISIONS = [...PRE_2020_TO_2020_COLLISIONS, "deprecated"];
|
|
709
|
+
const OPEN_API_30_TO_2020_COLLISIONS = [...PRE_2020_TO_2020_COLLISIONS, "$comment", "$id", "$schema", "const", "contains", "contentEncoding", "contentMediaType", "else", "examples", "if", "patternProperties", "propertyNames", "then"];
|
|
710
|
+
const ANCHOR_REGEXP = /^[A-Za-z_][-A-Za-z0-9._]*$/;
|
|
711
|
+
const LEGACY_ID_FRAGMENT_REGEXP = /^[A-Za-z][-A-Za-z0-9._:]*$/;
|
|
712
|
+
function convertDraft07(root) {
|
|
713
|
+
return convertSchema(root, (source, context) => {
|
|
714
|
+
const out = {};
|
|
715
|
+
if (typeof source.$ref === "string") {
|
|
716
|
+
context.reference(out, source.$ref);
|
|
717
|
+
if (Object.hasOwn(source, "definitions")) {
|
|
718
|
+
InternalRecord.assignProperty(out, "$defs", context.schemaMap(source.definitions, "definitions", "$defs"));
|
|
688
719
|
}
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
720
|
+
return out;
|
|
721
|
+
}
|
|
722
|
+
rejectKeywordCollisions(source, DRAFT_07_TO_2020_COLLISIONS, "Draft 2020-12", "Draft-07");
|
|
723
|
+
let items = undefined;
|
|
724
|
+
let additionalItems = undefined;
|
|
725
|
+
for (const key of Object.keys(source)) {
|
|
726
|
+
const value = source[key];
|
|
727
|
+
if (convertSubschemaKeyword(out, key, value, context, JSON_SCHEMA_SINGLE_KEYWORDS)) continue;
|
|
728
|
+
switch (key) {
|
|
729
|
+
case "$schema":
|
|
730
|
+
InternalRecord.assignProperty(out, key, isMetaSchemaUri(value, META_SCHEMA_URI_DRAFT_07) ? META_SCHEMA_URI_DRAFT_2020_12 : value);
|
|
731
|
+
break;
|
|
732
|
+
case "$id":
|
|
733
|
+
convertDraft07Id(out, value);
|
|
734
|
+
break;
|
|
735
|
+
case "definitions":
|
|
736
|
+
InternalRecord.assignProperty(out, "$defs", context.schemaMap(value, key, "$defs"));
|
|
737
|
+
break;
|
|
738
|
+
case "dependencies":
|
|
739
|
+
{
|
|
740
|
+
if (!Predicate.isObject(value)) {
|
|
741
|
+
InternalRecord.assignProperty(out, key, value);
|
|
742
|
+
break;
|
|
743
|
+
}
|
|
744
|
+
const dependentRequired = {};
|
|
745
|
+
const dependentSchemas = {};
|
|
746
|
+
for (const dependency of Object.keys(value)) {
|
|
747
|
+
const dependencyValue = value[dependency];
|
|
748
|
+
InternalRecord.assignProperty(Array.isArray(dependencyValue) ? dependentRequired : dependentSchemas, dependency, Array.isArray(dependencyValue) ? dependencyValue : context.schemaAt(dependencyValue, ["dependencies", dependency], ["dependentSchemas", dependency]));
|
|
749
|
+
}
|
|
750
|
+
if (Object.keys(dependentRequired).length > 0) {
|
|
751
|
+
InternalRecord.assignProperty(out, "dependentRequired", dependentRequired);
|
|
752
|
+
}
|
|
753
|
+
if (Object.keys(dependentSchemas).length > 0) {
|
|
754
|
+
InternalRecord.assignProperty(out, "dependentSchemas", dependentSchemas);
|
|
755
|
+
}
|
|
756
|
+
break;
|
|
757
|
+
}
|
|
758
|
+
case "items":
|
|
759
|
+
items = value;
|
|
760
|
+
break;
|
|
761
|
+
case "additionalItems":
|
|
762
|
+
additionalItems = value;
|
|
763
|
+
break;
|
|
764
|
+
default:
|
|
765
|
+
InternalRecord.assignProperty(out, key, value);
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
if (items !== undefined) {
|
|
769
|
+
if (Array.isArray(items)) {
|
|
770
|
+
InternalRecord.assignProperty(out, "prefixItems", context.schemaArray(items, "items", "prefixItems"));
|
|
771
|
+
if (additionalItems !== undefined) {
|
|
772
|
+
InternalRecord.assignProperty(out, "items", context.schema(additionalItems, "additionalItems", "items"));
|
|
773
|
+
}
|
|
774
|
+
} else {
|
|
775
|
+
InternalRecord.assignProperty(out, "items", context.schema(items, "items"));
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
return out;
|
|
779
|
+
}, {
|
|
780
|
+
trackIds: true,
|
|
781
|
+
ignoreRefSiblings: true
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
function convertDraft07Id(out, value) {
|
|
785
|
+
if (typeof value !== "string" || !value.includes("#")) {
|
|
786
|
+
InternalRecord.assignProperty(out, "$id", value);
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
789
|
+
const fragmentIndex = value.indexOf("#");
|
|
790
|
+
const id = value.slice(0, fragmentIndex);
|
|
791
|
+
const anchor = value.slice(fragmentIndex + 1);
|
|
792
|
+
if (anchor.length === 0) {
|
|
793
|
+
if (id.length > 0) InternalRecord.assignProperty(out, "$id", id);
|
|
794
|
+
return;
|
|
795
|
+
}
|
|
796
|
+
if (!ANCHOR_REGEXP.test(anchor)) {
|
|
797
|
+
unsupported("$id", "Draft 2020-12", `fragment "#${anchor}" is not a valid $anchor`);
|
|
798
|
+
}
|
|
799
|
+
if (id.length > 0) InternalRecord.assignProperty(out, "$id", id);
|
|
800
|
+
InternalRecord.assignProperty(out, "$anchor", anchor);
|
|
801
|
+
}
|
|
802
|
+
function unsupported(keyword, dialect, details) {
|
|
803
|
+
throw new Error(`Cannot convert JSON Schema keyword "${keyword}" to ${dialect}: ${details}`);
|
|
804
|
+
}
|
|
805
|
+
function rejectKeywordCollisions(source, keywords, targetDialect, sourceDialect) {
|
|
806
|
+
for (const keyword of keywords) {
|
|
807
|
+
if (Object.hasOwn(source, keyword)) {
|
|
808
|
+
unsupported(keyword, targetDialect, `it is not active in ${sourceDialect} but would become active in the target`);
|
|
693
809
|
}
|
|
694
810
|
}
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
if (
|
|
699
|
-
out
|
|
811
|
+
}
|
|
812
|
+
const DRAFT_07_TARGET_COLLISIONS = ["additionalItems", "definitions", "dependencies"];
|
|
813
|
+
function convertMetaSchemaKeyword(out, value, context, targetUri, targetDialect) {
|
|
814
|
+
if (context.isDocumentRoot) {
|
|
815
|
+
InternalRecord.assignProperty(out, "$schema", isMetaSchemaUri(value, META_SCHEMA_URI_DRAFT_2020_12) ? targetUri : value);
|
|
816
|
+
} else if (!isMetaSchemaUri(value, META_SCHEMA_URI_DRAFT_2020_12)) {
|
|
817
|
+
unsupported("$schema", targetDialect, "an embedded resource cannot declare a different dialect");
|
|
700
818
|
}
|
|
701
|
-
|
|
819
|
+
}
|
|
820
|
+
function draft07Adapter(source, context) {
|
|
821
|
+
rejectKeywordCollisions(source, DRAFT_07_TARGET_COLLISIONS, "Draft-07", "Draft 2020-12");
|
|
822
|
+
const out = {};
|
|
823
|
+
let reference = undefined;
|
|
824
|
+
let prefixItems = undefined;
|
|
825
|
+
let items = undefined;
|
|
826
|
+
for (const key of Object.keys(source)) {
|
|
827
|
+
const value = source[key];
|
|
828
|
+
if (convertSubschemaKeyword(out, key, value, context, JSON_SCHEMA_SINGLE_KEYWORDS)) continue;
|
|
829
|
+
switch (key) {
|
|
830
|
+
case "$ref":
|
|
831
|
+
reference = value;
|
|
832
|
+
break;
|
|
833
|
+
case "$schema":
|
|
834
|
+
convertMetaSchemaKeyword(out, value, context, META_SCHEMA_URI_DRAFT_07, "Draft-07");
|
|
835
|
+
break;
|
|
836
|
+
case "$id":
|
|
837
|
+
case "$anchor":
|
|
838
|
+
break;
|
|
839
|
+
case "$defs":
|
|
840
|
+
InternalRecord.assignProperty(out, "definitions", context.schemaMap(value, key, "definitions"));
|
|
841
|
+
break;
|
|
842
|
+
case "prefixItems":
|
|
843
|
+
prefixItems = value;
|
|
844
|
+
break;
|
|
845
|
+
case "items":
|
|
846
|
+
items = value;
|
|
847
|
+
break;
|
|
848
|
+
case "dependentRequired":
|
|
849
|
+
case "dependentSchemas":
|
|
850
|
+
case "minContains":
|
|
851
|
+
case "maxContains":
|
|
852
|
+
break;
|
|
853
|
+
case "$dynamicRef":
|
|
854
|
+
case "$dynamicAnchor":
|
|
855
|
+
case "$vocabulary":
|
|
856
|
+
case "unevaluatedProperties":
|
|
857
|
+
case "unevaluatedItems":
|
|
858
|
+
unsupported(key, "Draft-07", "the target dialect has no equivalent");
|
|
859
|
+
case "required":
|
|
860
|
+
if (Array.isArray(value) && value.length === 0) break;
|
|
861
|
+
InternalRecord.assignProperty(out, key, value);
|
|
862
|
+
break;
|
|
863
|
+
default:
|
|
864
|
+
InternalRecord.assignProperty(out, key, value);
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
convertTuple(out, prefixItems, items, context);
|
|
868
|
+
if (Object.hasOwn(source, "contains")) {
|
|
869
|
+
const minContains = source.minContains;
|
|
870
|
+
const maxContains = source.maxContains;
|
|
871
|
+
if (minContains !== undefined && minContains !== 1 || maxContains !== undefined) {
|
|
872
|
+
unsupported("minContains/maxContains", "Draft-07", "contains cardinality cannot be represented");
|
|
873
|
+
}
|
|
874
|
+
if (Object.hasOwn(source, "minContains")) InternalRecord.assignProperty(out, "minContains", minContains);
|
|
875
|
+
} else {
|
|
876
|
+
if (Object.hasOwn(source, "minContains")) InternalRecord.assignProperty(out, "minContains", source.minContains);
|
|
877
|
+
if (Object.hasOwn(source, "maxContains")) InternalRecord.assignProperty(out, "maxContains", source.maxContains);
|
|
878
|
+
}
|
|
879
|
+
convertDependencies(source, out, context, "draft-07");
|
|
880
|
+
convertLegacyId(source, out, "$id", "Draft-07");
|
|
881
|
+
convertReference(out, reference, context);
|
|
702
882
|
return out;
|
|
703
883
|
}
|
|
704
|
-
function
|
|
705
|
-
|
|
884
|
+
function convertTuple(out, prefixItems, items, context) {
|
|
885
|
+
if (prefixItems === undefined) {
|
|
886
|
+
if (items !== undefined) InternalRecord.assignProperty(out, "items", context.schema(items, "items"));
|
|
887
|
+
return;
|
|
888
|
+
}
|
|
889
|
+
InternalRecord.assignProperty(out, "items", context.schemaArray(prefixItems, "prefixItems", "items"));
|
|
890
|
+
if (items !== undefined) {
|
|
891
|
+
InternalRecord.assignProperty(out, "additionalItems", context.schema(items, "items", "additionalItems"));
|
|
892
|
+
}
|
|
706
893
|
}
|
|
707
|
-
function
|
|
708
|
-
|
|
709
|
-
if (typeof
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
if (exclusive && typeof node[boundKey] === "number") {
|
|
714
|
-
out[exclusiveKey] = node[boundKey];
|
|
715
|
-
delete out[boundKey];
|
|
894
|
+
function convertReference(out, reference, context) {
|
|
895
|
+
if (reference === undefined) return;
|
|
896
|
+
if (typeof reference === "string" && Object.keys(out).length > 0) {
|
|
897
|
+
const referenceSchema = {};
|
|
898
|
+
context.reference(referenceSchema, reference);
|
|
899
|
+
appendAllOf(out, referenceSchema);
|
|
716
900
|
} else {
|
|
717
|
-
|
|
901
|
+
context.reference(out, reference);
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
function convertDependencies(source, out, context, targetDialect) {
|
|
905
|
+
const dependentRequired = Predicate.isObject(source.dependentRequired) ? source.dependentRequired : undefined;
|
|
906
|
+
const dependentSchemas = Predicate.isObject(source.dependentSchemas) ? source.dependentSchemas : undefined;
|
|
907
|
+
if (dependentRequired === undefined && dependentSchemas === undefined) return;
|
|
908
|
+
const dependencies = {};
|
|
909
|
+
const keys = new Set([...Object.keys(dependentRequired ?? {}), ...Object.keys(dependentSchemas ?? {})]);
|
|
910
|
+
for (const key of keys) {
|
|
911
|
+
const required = dependentRequired?.[key];
|
|
912
|
+
const dependency = dependentSchemas?.[key];
|
|
913
|
+
const omitRequired = targetDialect === "draft-04" && Array.isArray(required) && required.length === 0;
|
|
914
|
+
if (dependency === undefined) {
|
|
915
|
+
if (!omitRequired) InternalRecord.assignProperty(dependencies, key, required);
|
|
916
|
+
} else if (required === undefined || omitRequired) {
|
|
917
|
+
InternalRecord.assignProperty(dependencies, key, context.schemaAt(dependency, ["dependentSchemas", key], ["dependencies", key]));
|
|
918
|
+
} else {
|
|
919
|
+
InternalRecord.assignProperty(dependencies, key, {
|
|
920
|
+
allOf: [context.schemaAt(dependency, ["dependentSchemas", key], ["dependencies", key, "allOf", "0"]), {
|
|
921
|
+
required
|
|
922
|
+
}]
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
if (Object.keys(dependencies).length > 0) InternalRecord.assignProperty(out, "dependencies", dependencies);
|
|
927
|
+
}
|
|
928
|
+
function convertOpenApi30(root) {
|
|
929
|
+
return convertSchema(root, (source, context) => {
|
|
930
|
+
const out = {};
|
|
931
|
+
if (typeof source.$ref === "string") {
|
|
932
|
+
context.reference(out, rewriteOpenApiComponentsReference(source.$ref));
|
|
933
|
+
return out;
|
|
934
|
+
}
|
|
935
|
+
rejectKeywordCollisions(source, OPEN_API_30_TO_2020_COLLISIONS, "Draft 2020-12", "OpenAPI 3.0");
|
|
936
|
+
for (const key of Object.keys(source)) {
|
|
937
|
+
const value = source[key];
|
|
938
|
+
if (convertSubschemaKeyword(out, key, value, context, OPEN_API_30_SCHEMA_SINGLE_KEYWORDS, OPEN_API_30_SCHEMA_MAP_KEYWORDS)) {
|
|
939
|
+
continue;
|
|
940
|
+
}
|
|
941
|
+
switch (key) {
|
|
942
|
+
case "example":
|
|
943
|
+
InternalRecord.assignProperty(out, "examples", [value]);
|
|
944
|
+
break;
|
|
945
|
+
case "nullable":
|
|
946
|
+
case "exclusiveMinimum":
|
|
947
|
+
case "exclusiveMaximum":
|
|
948
|
+
break;
|
|
949
|
+
default:
|
|
950
|
+
InternalRecord.assignProperty(out, key, value);
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
convertOpenApiExclusiveBound(source, out, "minimum");
|
|
954
|
+
convertOpenApiExclusiveBound(source, out, "maximum");
|
|
955
|
+
if (source.nullable === true && typeof source.type === "string") {
|
|
956
|
+
InternalRecord.assignProperty(out, "type", [source.type, "null"]);
|
|
957
|
+
}
|
|
958
|
+
return out;
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
function convertOpenApiExclusiveBound(source, out, boundKey) {
|
|
962
|
+
const exclusiveKey = boundKey === "minimum" ? "exclusiveMinimum" : "exclusiveMaximum";
|
|
963
|
+
const exclusive = source[exclusiveKey];
|
|
964
|
+
if (typeof exclusive !== "boolean") {
|
|
965
|
+
if (exclusive !== undefined) InternalRecord.assignProperty(out, exclusiveKey, exclusive);
|
|
966
|
+
return;
|
|
967
|
+
}
|
|
968
|
+
if (exclusive && typeof source[boundKey] === "number") {
|
|
969
|
+
InternalRecord.assignProperty(out, exclusiveKey, source[boundKey]);
|
|
970
|
+
delete out[boundKey];
|
|
718
971
|
}
|
|
972
|
+
}
|
|
973
|
+
const DRAFT_04_TARGET_COLLISIONS = ["additionalItems", "definitions", "dependencies", "id"];
|
|
974
|
+
function draft04Adapter(source, context) {
|
|
975
|
+
rejectKeywordCollisions(source, DRAFT_04_TARGET_COLLISIONS, "Draft-04", "Draft 2020-12");
|
|
976
|
+
const out = {};
|
|
977
|
+
let reference = undefined;
|
|
978
|
+
let prefixItems = undefined;
|
|
979
|
+
let items = undefined;
|
|
980
|
+
let constSchema;
|
|
981
|
+
for (const key of Object.keys(source)) {
|
|
982
|
+
const value = source[key];
|
|
983
|
+
if (convertSubschemaKeyword(out, key, value, context, DRAFT_04_SCHEMA_SINGLE_KEYWORDS)) continue;
|
|
984
|
+
switch (key) {
|
|
985
|
+
case "$ref":
|
|
986
|
+
reference = value;
|
|
987
|
+
break;
|
|
988
|
+
case "$schema":
|
|
989
|
+
convertMetaSchemaKeyword(out, value, context, META_SCHEMA_URI_DRAFT_04, "Draft-04");
|
|
990
|
+
break;
|
|
991
|
+
case "$id":
|
|
992
|
+
case "$anchor":
|
|
993
|
+
break;
|
|
994
|
+
case "$defs":
|
|
995
|
+
InternalRecord.assignProperty(out, "definitions", context.schemaMap(value, key, "definitions"));
|
|
996
|
+
break;
|
|
997
|
+
case "prefixItems":
|
|
998
|
+
prefixItems = value;
|
|
999
|
+
break;
|
|
1000
|
+
case "items":
|
|
1001
|
+
items = value;
|
|
1002
|
+
break;
|
|
1003
|
+
case "$dynamicRef":
|
|
1004
|
+
case "$dynamicAnchor":
|
|
1005
|
+
case "$vocabulary":
|
|
1006
|
+
case "unevaluatedProperties":
|
|
1007
|
+
case "unevaluatedItems":
|
|
1008
|
+
case "propertyNames":
|
|
1009
|
+
unsupported(key, "Draft-04", "the target dialect has no equivalent");
|
|
1010
|
+
case "dependentRequired":
|
|
1011
|
+
case "dependentSchemas":
|
|
1012
|
+
case "contains":
|
|
1013
|
+
case "minContains":
|
|
1014
|
+
case "maxContains":
|
|
1015
|
+
case "if":
|
|
1016
|
+
case "then":
|
|
1017
|
+
case "else":
|
|
1018
|
+
case "minimum":
|
|
1019
|
+
case "maximum":
|
|
1020
|
+
case "exclusiveMinimum":
|
|
1021
|
+
case "exclusiveMaximum":
|
|
1022
|
+
break;
|
|
1023
|
+
case "const":
|
|
1024
|
+
constSchema = {
|
|
1025
|
+
enum: [value]
|
|
1026
|
+
};
|
|
1027
|
+
break;
|
|
1028
|
+
case "required":
|
|
1029
|
+
if (Array.isArray(value) && value.length === 0) break;
|
|
1030
|
+
InternalRecord.assignProperty(out, key, value);
|
|
1031
|
+
break;
|
|
1032
|
+
default:
|
|
1033
|
+
InternalRecord.assignProperty(out, key, value);
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
convertTuple(out, prefixItems, items, context);
|
|
1037
|
+
convertDraft04ExclusiveBound(source, out, "minimum");
|
|
1038
|
+
convertDraft04ExclusiveBound(source, out, "maximum");
|
|
1039
|
+
convertDependencies(source, out, context, "draft-04");
|
|
1040
|
+
convertLegacyId(source, out, "id", "Draft-04");
|
|
1041
|
+
convertDraft04Conditionals(source, out, context);
|
|
1042
|
+
convertDraft04Contains(source, out, context);
|
|
1043
|
+
if (constSchema !== undefined) {
|
|
1044
|
+
if (Object.hasOwn(source, "enum")) {
|
|
1045
|
+
appendAllOf(out, constSchema);
|
|
1046
|
+
} else {
|
|
1047
|
+
InternalRecord.assignProperty(out, "enum", constSchema.enum);
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
convertReference(out, reference, context);
|
|
719
1051
|
return out;
|
|
720
1052
|
}
|
|
721
|
-
function
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
1053
|
+
function convertDraft04Conditionals(source, out, context) {
|
|
1054
|
+
const hasIf = Object.hasOwn(source, "if");
|
|
1055
|
+
const hasThen = Object.hasOwn(source, "then");
|
|
1056
|
+
const hasElse = Object.hasOwn(source, "else");
|
|
1057
|
+
if (!hasIf || !hasThen && !hasElse) {
|
|
1058
|
+
if (hasIf) InternalRecord.assignProperty(out, "if", context.schema(source.if, "if"));
|
|
1059
|
+
if (hasThen) InternalRecord.assignProperty(out, "then", context.schema(source.then, "then"));
|
|
1060
|
+
if (hasElse) InternalRecord.assignProperty(out, "else", context.schema(source.else, "else"));
|
|
1061
|
+
return;
|
|
728
1062
|
}
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
1063
|
+
const index = Array.isArray(out.allOf) ? out.allOf.length : 0;
|
|
1064
|
+
const base = ["allOf", String(index), "anyOf"];
|
|
1065
|
+
const convertBranch = (key, targetPath) => context.schemaAt(source[key], [key], [...base, ...targetPath]);
|
|
1066
|
+
let conditional;
|
|
1067
|
+
if (hasThen && hasElse) {
|
|
1068
|
+
if (hasSchemaIdentifier(source.if)) {
|
|
1069
|
+
unsupported("if", "Draft-04", "lowering both branches would duplicate a schema identifier");
|
|
1070
|
+
}
|
|
1071
|
+
// (if AND then) OR ((NOT if) AND else)
|
|
1072
|
+
conditional = {
|
|
1073
|
+
anyOf: [{
|
|
1074
|
+
allOf: [convertBranch("if", ["0", "allOf", "0"]), convertBranch("then", ["0", "allOf", "1"])]
|
|
1075
|
+
}, {
|
|
1076
|
+
allOf: [{
|
|
1077
|
+
not: convertBranch("if", ["1", "allOf", "0", "not"])
|
|
1078
|
+
}, convertBranch("else", ["1", "allOf", "1"])]
|
|
1079
|
+
}]
|
|
1080
|
+
};
|
|
1081
|
+
} else if (hasThen) {
|
|
1082
|
+
// (NOT if) OR then
|
|
1083
|
+
conditional = {
|
|
1084
|
+
anyOf: [{
|
|
1085
|
+
not: convertBranch("if", ["0", "not"])
|
|
1086
|
+
}, convertBranch("then", ["1"])]
|
|
1087
|
+
};
|
|
1088
|
+
} else {
|
|
1089
|
+
// if OR else
|
|
1090
|
+
conditional = {
|
|
1091
|
+
anyOf: [convertBranch("if", ["0"]), convertBranch("else", ["1"])]
|
|
1092
|
+
};
|
|
1093
|
+
}
|
|
1094
|
+
appendAllOf(out, conditional);
|
|
1095
|
+
}
|
|
1096
|
+
function hasSchemaIdentifier(node) {
|
|
1097
|
+
if (!Predicate.isObject(node)) return false;
|
|
1098
|
+
if (Object.hasOwn(node, "$id") || Object.hasOwn(node, "$anchor")) return true;
|
|
1099
|
+
for (const key of Object.keys(node)) {
|
|
1100
|
+
const value = node[key];
|
|
1101
|
+
switch (key) {
|
|
1102
|
+
case "$defs":
|
|
1103
|
+
case "properties":
|
|
1104
|
+
case "patternProperties":
|
|
1105
|
+
case "dependentSchemas":
|
|
1106
|
+
if (Predicate.isObject(value) && Object.values(value).some(hasSchemaIdentifier)) return true;
|
|
1107
|
+
break;
|
|
1108
|
+
case "allOf":
|
|
1109
|
+
case "anyOf":
|
|
1110
|
+
case "oneOf":
|
|
1111
|
+
case "prefixItems":
|
|
1112
|
+
if (Array.isArray(value) && value.some(hasSchemaIdentifier)) return true;
|
|
1113
|
+
break;
|
|
1114
|
+
case "not":
|
|
1115
|
+
case "additionalProperties":
|
|
1116
|
+
case "propertyNames":
|
|
1117
|
+
case "unevaluatedProperties":
|
|
1118
|
+
case "items":
|
|
1119
|
+
case "contains":
|
|
1120
|
+
case "unevaluatedItems":
|
|
1121
|
+
case "if":
|
|
1122
|
+
case "then":
|
|
1123
|
+
case "else":
|
|
1124
|
+
case "contentSchema":
|
|
1125
|
+
if (hasSchemaIdentifier(value)) return true;
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
return false;
|
|
1129
|
+
}
|
|
1130
|
+
function convertDraft04Contains(source, out, context) {
|
|
1131
|
+
if (!Object.hasOwn(source, "contains")) {
|
|
1132
|
+
if (Object.hasOwn(source, "minContains")) InternalRecord.assignProperty(out, "minContains", source.minContains);
|
|
1133
|
+
if (Object.hasOwn(source, "maxContains")) InternalRecord.assignProperty(out, "maxContains", source.maxContains);
|
|
1134
|
+
return;
|
|
1135
|
+
}
|
|
1136
|
+
const minContains = source.minContains;
|
|
1137
|
+
const maxContains = source.maxContains;
|
|
1138
|
+
if (minContains !== undefined && minContains !== 1 || maxContains !== undefined) {
|
|
1139
|
+
unsupported("minContains/maxContains", "Draft-04", "contains cardinality cannot be represented");
|
|
1140
|
+
}
|
|
1141
|
+
const index = Array.isArray(out.allOf) ? out.allOf.length : 0;
|
|
1142
|
+
const contains = context.schemaAt(source.contains, ["contains"], ["allOf", String(index), "anyOf", "1", "not", "items", "not"]);
|
|
1143
|
+
appendAllOf(out, {
|
|
1144
|
+
anyOf: [{
|
|
1145
|
+
not: {
|
|
1146
|
+
type: "array"
|
|
1147
|
+
}
|
|
1148
|
+
}, {
|
|
1149
|
+
not: {
|
|
1150
|
+
items: {
|
|
1151
|
+
not: contains
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
737
1154
|
}]
|
|
738
|
-
};
|
|
1155
|
+
});
|
|
739
1156
|
}
|
|
740
|
-
function
|
|
741
|
-
|
|
742
|
-
if (typeof t === "string") return t === "null" ? node : {
|
|
743
|
-
...node,
|
|
744
|
-
type: [t, "null"]
|
|
745
|
-
};
|
|
746
|
-
if (Array.isArray(t)) return t.includes("null") ? node : {
|
|
747
|
-
...node,
|
|
748
|
-
type: [...t, "null"]
|
|
749
|
-
};
|
|
750
|
-
return node;
|
|
1157
|
+
function appendAllOf(out, schema) {
|
|
1158
|
+
if (Array.isArray(out.allOf)) out.allOf.push(schema);else InternalRecord.assignProperty(out, "allOf", [schema]);
|
|
751
1159
|
}
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
* **Example** (Resolving a $ref)
|
|
771
|
-
*
|
|
772
|
-
* ```ts import.meta.vitest
|
|
773
|
-
* import { JsonSchema } from "effect"
|
|
774
|
-
*
|
|
775
|
-
* const definitions: JsonSchema.Definitions = {
|
|
776
|
-
* User: { type: "object", properties: { name: { type: "string" } } }
|
|
777
|
-
* }
|
|
778
|
-
*
|
|
779
|
-
* JsonSchema.resolve$ref("#/$defs/User", definitions) // => { type: "object", properties: { name: { type: "string" } } }
|
|
780
|
-
* JsonSchema.resolve$ref("#/$defs/Unknown", definitions) // => undefined
|
|
781
|
-
* ```
|
|
782
|
-
*
|
|
783
|
-
* @see {@link resolveTopLevel$ref}
|
|
784
|
-
* @see {@link Definitions}
|
|
785
|
-
* @category getters
|
|
786
|
-
* @since 4.0.0
|
|
787
|
-
*/
|
|
788
|
-
export function resolve$ref($ref, definitions) {
|
|
789
|
-
const tokens = $ref.split("/");
|
|
790
|
-
const identifier = unescapeToken(tokens[tokens.length - 1]);
|
|
791
|
-
if (Object.hasOwn(definitions, identifier)) return definitions[identifier];
|
|
1160
|
+
function convertLegacyId(source, out, targetKey, dialect) {
|
|
1161
|
+
const id = source.$id;
|
|
1162
|
+
const anchor = source.$anchor;
|
|
1163
|
+
if (anchor === undefined) {
|
|
1164
|
+
if (id !== undefined) InternalRecord.assignProperty(out, targetKey, id);
|
|
1165
|
+
return;
|
|
1166
|
+
}
|
|
1167
|
+
if (typeof anchor !== "string" || !ANCHOR_REGEXP.test(anchor)) {
|
|
1168
|
+
unsupported("$anchor", dialect, "the anchor is not valid");
|
|
1169
|
+
}
|
|
1170
|
+
if (!LEGACY_ID_FRAGMENT_REGEXP.test(anchor)) {
|
|
1171
|
+
unsupported("$anchor", dialect, "the anchor cannot be represented as a plain-name fragment identifier");
|
|
1172
|
+
}
|
|
1173
|
+
if (id === undefined) {
|
|
1174
|
+
InternalRecord.assignProperty(out, targetKey, `#${anchor}`);
|
|
1175
|
+
} else {
|
|
1176
|
+
unsupported("$anchor", dialect, "it cannot be combined with the schema $id");
|
|
1177
|
+
}
|
|
792
1178
|
}
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
* the resolved schema.
|
|
805
|
-
*
|
|
806
|
-
* **Example** (Resolving a top-level $ref)
|
|
807
|
-
*
|
|
808
|
-
* ```ts import.meta.vitest
|
|
809
|
-
* import { JsonSchema } from "effect"
|
|
810
|
-
*
|
|
811
|
-
* const doc: JsonSchema.Document<"draft-2020-12"> = {
|
|
812
|
-
* dialect: "draft-2020-12",
|
|
813
|
-
* schema: { $ref: "#/$defs/User" },
|
|
814
|
-
* definitions: {
|
|
815
|
-
* User: { type: "object", properties: { name: { type: "string" } } }
|
|
816
|
-
* }
|
|
817
|
-
* }
|
|
818
|
-
*
|
|
819
|
-
* const resolved = JsonSchema.resolveTopLevel$ref(doc)
|
|
820
|
-
* resolved.schema // => { type: "object", properties: { name: { type: "string" } } }
|
|
821
|
-
* ```
|
|
822
|
-
*
|
|
823
|
-
* @see {@link resolve$ref}
|
|
824
|
-
* @see {@link Document}
|
|
825
|
-
* @category transforming
|
|
826
|
-
* @since 4.0.0
|
|
827
|
-
*/
|
|
828
|
-
export function resolveTopLevel$ref(document) {
|
|
829
|
-
if (typeof document.schema.$ref === "string") {
|
|
830
|
-
const schema = resolve$ref(document.schema.$ref, document.definitions);
|
|
831
|
-
if (schema !== undefined) {
|
|
832
|
-
return {
|
|
833
|
-
...document,
|
|
834
|
-
schema
|
|
835
|
-
};
|
|
1179
|
+
function convertDraft04ExclusiveBound(source, out, boundKey) {
|
|
1180
|
+
const exclusiveKey = boundKey === "minimum" ? "exclusiveMinimum" : "exclusiveMaximum";
|
|
1181
|
+
const bound = source[boundKey];
|
|
1182
|
+
const exclusive = source[exclusiveKey];
|
|
1183
|
+
if (typeof exclusive === "number") {
|
|
1184
|
+
const isBoundStricter = typeof bound === "number" && (boundKey === "minimum" ? bound > exclusive : bound < exclusive);
|
|
1185
|
+
if (isBoundStricter) {
|
|
1186
|
+
InternalRecord.assignProperty(out, boundKey, bound);
|
|
1187
|
+
} else {
|
|
1188
|
+
InternalRecord.assignProperty(out, boundKey, exclusive);
|
|
1189
|
+
InternalRecord.assignProperty(out, exclusiveKey, true);
|
|
836
1190
|
}
|
|
1191
|
+
} else if (bound !== undefined) {
|
|
1192
|
+
InternalRecord.assignProperty(out, boundKey, bound);
|
|
837
1193
|
}
|
|
838
|
-
return document;
|
|
839
1194
|
}
|
|
840
1195
|
//# sourceMappingURL=JsonSchema.js.map
|