effect 4.0.0-rc.112 → 4.0.0-rc.113
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +24 -9
- package/CLAUDE.md +24 -9
- package/ai-docs/package.json +2 -2
- package/ai-docs/src/01_effect/01_basics/02_effect-fn.ts +18 -5
- package/ai-docs/src/01_effect/01_basics/index.md +5 -3
- package/ai-docs/src/01_effect/03_services/20_layer-composition.ts +1 -1
- package/ai-docs/src/01_effect/03_services/20_layer-unwrap.ts +2 -2
- package/ai-docs/src/01_effect/05_resources/10_acquire-release.ts +2 -2
- package/ai-docs/src/03_stream/30_encoding.ts +5 -7
- package/ai-docs/src/08_observability/10_logging.ts +1 -1
- package/ai-docs/src/70_cli/10_basics.ts +7 -7
- package/ai-docs/src/71_ai/10_language-model.ts +2 -2
- package/ai-docs/src/71_ai/20_tools.ts +1 -1
- package/ai-docs/src/71_ai/30_chat.ts +1 -1
- package/dist/Array.d.ts +86 -50
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +58 -32
- package/dist/Array.js.map +1 -1
- package/dist/BigDecimal.d.ts +5 -1
- package/dist/BigDecimal.d.ts.map +1 -1
- package/dist/BigDecimal.js +40 -23
- package/dist/BigDecimal.js.map +1 -1
- package/dist/ByteSize.d.ts +633 -0
- package/dist/ByteSize.d.ts.map +1 -0
- package/dist/ByteSize.js +524 -0
- package/dist/ByteSize.js.map +1 -0
- package/dist/Cache.d.ts.map +1 -1
- package/dist/Cache.js +17 -3
- package/dist/Cache.js.map +1 -1
- package/dist/Cause.d.ts +1 -1
- package/dist/Cause.d.ts.map +1 -1
- package/dist/Channel.d.ts +97 -24
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +66 -39
- package/dist/Channel.js.map +1 -1
- package/dist/Chunk.d.ts +49 -28
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Chunk.js +27 -18
- package/dist/Chunk.js.map +1 -1
- package/dist/Config.d.ts +162 -201
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +103 -212
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.d.ts +4 -4
- package/dist/ConfigProvider.d.ts.map +1 -1
- package/dist/ConfigProvider.js +7 -7
- package/dist/ConfigProvider.js.map +1 -1
- package/dist/Context.d.ts +31 -0
- package/dist/Context.d.ts.map +1 -1
- package/dist/Context.js.map +1 -1
- package/dist/Cron.d.ts +2 -2
- package/dist/Cron.d.ts.map +1 -1
- package/dist/Cron.js +2 -2
- package/dist/Cron.js.map +1 -1
- package/dist/Crypto.d.ts +1 -1
- package/dist/Crypto.d.ts.map +1 -1
- package/dist/Crypto.js +3 -2
- package/dist/Crypto.js.map +1 -1
- package/dist/DateTime.d.ts +2 -2
- package/dist/DateTime.d.ts.map +1 -1
- package/dist/Deferred.d.ts.map +1 -1
- package/dist/Deferred.js +6 -6
- package/dist/Deferred.js.map +1 -1
- package/dist/Duration.d.ts +1 -1
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +1 -1
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts +220 -113
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +27 -26
- package/dist/Effect.js.map +1 -1
- package/dist/Effectable.d.ts +58 -2
- package/dist/Effectable.d.ts.map +1 -1
- package/dist/Effectable.js +58 -6
- package/dist/Effectable.js.map +1 -1
- package/dist/Encoding.d.ts +3 -1
- package/dist/Encoding.d.ts.map +1 -1
- package/dist/Encoding.js +40 -10
- package/dist/Encoding.js.map +1 -1
- package/dist/Equal.d.ts +1 -1
- package/dist/Equal.d.ts.map +1 -1
- package/dist/Equal.js +1 -1
- package/dist/Equal.js.map +1 -1
- package/dist/ExecutionPlan.d.ts.map +1 -1
- package/dist/ExecutionPlan.js +1 -0
- package/dist/ExecutionPlan.js.map +1 -1
- package/dist/Fiber.d.ts +32 -8
- package/dist/Fiber.d.ts.map +1 -1
- package/dist/Fiber.js.map +1 -1
- package/dist/FiberHandle.js +3 -3
- package/dist/FiberHandle.js.map +1 -1
- package/dist/FiberMap.d.ts +12 -6
- package/dist/FiberMap.d.ts.map +1 -1
- package/dist/FiberMap.js +11 -6
- package/dist/FiberMap.js.map +1 -1
- package/dist/FileSystem.d.ts +42 -210
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js +16 -148
- package/dist/FileSystem.js.map +1 -1
- package/dist/Formatter.d.ts +1 -0
- package/dist/Formatter.d.ts.map +1 -1
- package/dist/Formatter.js +19 -3
- package/dist/Formatter.js.map +1 -1
- package/dist/Graph.d.ts +48 -20
- package/dist/Graph.d.ts.map +1 -1
- package/dist/Graph.js +20 -5
- package/dist/Graph.js.map +1 -1
- package/dist/Hash.d.ts +1 -1
- package/dist/Hash.d.ts.map +1 -1
- package/dist/Hash.js +5 -14
- package/dist/Hash.js.map +1 -1
- package/dist/HashMap.d.ts +1 -1
- package/dist/HashMap.d.ts.map +1 -1
- package/dist/HashRing.d.ts +6 -1
- package/dist/HashRing.d.ts.map +1 -1
- package/dist/HashRing.js +9 -2
- package/dist/HashRing.js.map +1 -1
- package/dist/HashSet.d.ts +1 -1
- package/dist/HashSet.d.ts.map +1 -1
- package/dist/HashSet.js.map +1 -1
- package/dist/Iterable.d.ts +33 -15
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +58 -45
- package/dist/Iterable.js.map +1 -1
- package/dist/JsonPatch.js +4 -4
- package/dist/JsonPatch.js.map +1 -1
- package/dist/JsonPointer.d.ts +68 -4
- package/dist/JsonPointer.d.ts.map +1 -1
- package/dist/JsonPointer.js +90 -4
- package/dist/JsonPointer.js.map +1 -1
- package/dist/JsonSchema.js +8 -22
- package/dist/JsonSchema.js.map +1 -1
- package/dist/Layer.d.ts +47 -4
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +4 -6
- package/dist/Layer.js.map +1 -1
- package/dist/LayerMap.d.ts +1 -3
- package/dist/LayerMap.d.ts.map +1 -1
- package/dist/LayerMap.js +7 -5
- package/dist/LayerMap.js.map +1 -1
- package/dist/LayerRef.d.ts.map +1 -1
- package/dist/LayerRef.js +7 -5
- package/dist/LayerRef.js.map +1 -1
- package/dist/Logger.d.ts +114 -9
- package/dist/Logger.d.ts.map +1 -1
- package/dist/Logger.js +109 -9
- package/dist/Logger.js.map +1 -1
- package/dist/ManagedRuntime.js +1 -1
- package/dist/ManagedRuntime.js.map +1 -1
- package/dist/Match.d.ts +43 -31
- package/dist/Match.d.ts.map +1 -1
- package/dist/Match.js +5 -2
- package/dist/Match.js.map +1 -1
- package/dist/Metric.d.ts +11 -4
- package/dist/Metric.d.ts.map +1 -1
- package/dist/Metric.js +14 -18
- package/dist/Metric.js.map +1 -1
- package/dist/MutableHashMap.d.ts +1 -1
- package/dist/MutableHashMap.d.ts.map +1 -1
- package/dist/MutableHashMap.js +1 -1
- package/dist/MutableHashMap.js.map +1 -1
- package/dist/MutableHashSet.d.ts +1 -1
- package/dist/MutableHashSet.d.ts.map +1 -1
- package/dist/MutableHashSet.js +1 -1
- package/dist/MutableHashSet.js.map +1 -1
- package/dist/MutableList.d.ts +13 -2
- package/dist/MutableList.d.ts.map +1 -1
- package/dist/MutableList.js +18 -2
- package/dist/MutableList.js.map +1 -1
- package/dist/Number.d.ts +6 -0
- package/dist/Number.d.ts.map +1 -1
- package/dist/Number.js +3 -1
- package/dist/Number.js.map +1 -1
- package/dist/Optic.d.ts.map +1 -1
- package/dist/Optic.js +5 -4
- package/dist/Optic.js.map +1 -1
- package/dist/Option.d.ts +1 -1
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js +1 -1
- package/dist/Option.js.map +1 -1
- package/dist/Order.d.ts +1 -0
- package/dist/Order.d.ts.map +1 -1
- package/dist/Order.js +3 -1
- package/dist/Order.js.map +1 -1
- package/dist/PartitionedSemaphore.d.ts.map +1 -1
- package/dist/PartitionedSemaphore.js +1 -2
- package/dist/PartitionedSemaphore.js.map +1 -1
- package/dist/Path.d.ts +1 -1
- package/dist/Path.d.ts.map +1 -1
- package/dist/Path.js +1 -1
- package/dist/Path.js.map +1 -1
- package/dist/PlatformError.d.ts +1 -1
- package/dist/PlatformError.d.ts.map +1 -1
- package/dist/PlatformError.js +1 -1
- package/dist/PlatformError.js.map +1 -1
- package/dist/Pool.d.ts +38 -1
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +81 -5
- package/dist/Pool.js.map +1 -1
- package/dist/PrimaryKey.d.ts +1 -1
- package/dist/PrimaryKey.d.ts.map +1 -1
- package/dist/PrimaryKey.js +1 -1
- package/dist/PrimaryKey.js.map +1 -1
- package/dist/PubSub.d.ts +21 -9
- package/dist/PubSub.d.ts.map +1 -1
- package/dist/PubSub.js +18 -14
- package/dist/PubSub.js.map +1 -1
- package/dist/Queue.d.ts +82 -6
- package/dist/Queue.d.ts.map +1 -1
- package/dist/Queue.js +116 -27
- package/dist/Queue.js.map +1 -1
- package/dist/Random.d.ts +17 -4
- package/dist/Random.d.ts.map +1 -1
- package/dist/Random.js +1 -1
- package/dist/Random.js.map +1 -1
- package/dist/RcMap.d.ts.map +1 -1
- package/dist/RcMap.js +15 -9
- package/dist/RcMap.js.map +1 -1
- package/dist/Redacted.d.ts +1 -1
- package/dist/Redacted.d.ts.map +1 -1
- package/dist/Redacted.js +1 -1
- package/dist/Redacted.js.map +1 -1
- package/dist/RequestResolver.d.ts +15 -9
- package/dist/RequestResolver.d.ts.map +1 -1
- package/dist/RequestResolver.js +33 -15
- package/dist/RequestResolver.js.map +1 -1
- package/dist/Result.d.ts +1 -1
- package/dist/Result.d.ts.map +1 -1
- package/dist/Result.js +1 -1
- package/dist/Result.js.map +1 -1
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/Scheduler.js +19 -10
- package/dist/Scheduler.js.map +1 -1
- package/dist/Schema.d.ts +2155 -2415
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +2755 -4174
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +354 -183
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +277 -601
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaGetter.d.ts +46 -22
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +56 -53
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaIssue.d.ts +122 -188
- package/dist/SchemaIssue.d.ts.map +1 -1
- package/dist/SchemaIssue.js +48 -263
- package/dist/SchemaIssue.js.map +1 -1
- package/dist/SchemaParser.js +2 -9
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +1099 -16
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +1341 -20
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +49 -16
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +75 -98
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/ScopedCache.d.ts.map +1 -1
- package/dist/ScopedCache.js +10 -3
- package/dist/ScopedCache.js.map +1 -1
- package/dist/Sink.d.ts +9 -4
- package/dist/Sink.d.ts.map +1 -1
- package/dist/Sink.js +49 -31
- package/dist/Sink.js.map +1 -1
- package/dist/Stream.d.ts +221 -35
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +168 -84
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +16 -6
- package/dist/String.d.ts.map +1 -1
- package/dist/String.js +12 -5
- package/dist/String.js.map +1 -1
- package/dist/Struct.d.ts.map +1 -1
- package/dist/Struct.js +7 -4
- package/dist/Struct.js.map +1 -1
- package/dist/SynchronizedRef.d.ts +3 -2
- package/dist/SynchronizedRef.d.ts.map +1 -1
- package/dist/SynchronizedRef.js.map +1 -1
- package/dist/Terminal.d.ts +3 -3
- package/dist/Terminal.d.ts.map +1 -1
- package/dist/Terminal.js +3 -3
- package/dist/Terminal.js.map +1 -1
- package/dist/Tracer.d.ts +27 -7
- package/dist/Tracer.d.ts.map +1 -1
- package/dist/Tracer.js +38 -13
- package/dist/Tracer.js.map +1 -1
- package/dist/Trie.d.ts +1 -1
- package/dist/Trie.d.ts.map +1 -1
- package/dist/Tuple.d.ts +2 -1
- package/dist/Tuple.d.ts.map +1 -1
- package/dist/Tuple.js.map +1 -1
- package/dist/TxChunk.d.ts +1 -1
- package/dist/TxChunk.d.ts.map +1 -1
- package/dist/TxChunk.js +1 -1
- package/dist/TxChunk.js.map +1 -1
- package/dist/TxDeferred.d.ts +1 -1
- package/dist/TxDeferred.d.ts.map +1 -1
- package/dist/TxDeferred.js +1 -1
- package/dist/TxDeferred.js.map +1 -1
- package/dist/TxHashMap.d.ts +1 -1
- package/dist/TxHashMap.d.ts.map +1 -1
- package/dist/TxHashMap.js +1 -1
- package/dist/TxHashMap.js.map +1 -1
- package/dist/TxHashSet.d.ts +1 -1
- package/dist/TxHashSet.d.ts.map +1 -1
- package/dist/TxHashSet.js +1 -1
- package/dist/TxHashSet.js.map +1 -1
- package/dist/TxPriorityQueue.d.ts +1 -1
- package/dist/TxPriorityQueue.d.ts.map +1 -1
- package/dist/TxPriorityQueue.js +1 -1
- package/dist/TxPriorityQueue.js.map +1 -1
- package/dist/TxPubSub.d.ts +1 -1
- package/dist/TxPubSub.d.ts.map +1 -1
- package/dist/TxPubSub.js +1 -1
- package/dist/TxPubSub.js.map +1 -1
- package/dist/TxQueue.d.ts +9 -9
- package/dist/TxQueue.d.ts.map +1 -1
- package/dist/TxQueue.js +93 -86
- package/dist/TxQueue.js.map +1 -1
- package/dist/TxReentrantLock.d.ts +29 -1
- package/dist/TxReentrantLock.d.ts.map +1 -1
- package/dist/TxReentrantLock.js +29 -1
- package/dist/TxReentrantLock.js.map +1 -1
- package/dist/TxRef.d.ts +1 -1
- package/dist/TxRef.d.ts.map +1 -1
- package/dist/TxRef.js +1 -1
- package/dist/TxRef.js.map +1 -1
- package/dist/TxSemaphore.d.ts +1 -1
- package/dist/TxSemaphore.d.ts.map +1 -1
- package/dist/TxSemaphore.js +1 -1
- package/dist/TxSemaphore.js.map +1 -1
- package/dist/TxSubscriptionRef.d.ts +1 -1
- package/dist/TxSubscriptionRef.d.ts.map +1 -1
- package/dist/TxSubscriptionRef.js +1 -1
- package/dist/TxSubscriptionRef.js.map +1 -1
- package/dist/Types.d.ts +33 -19
- package/dist/Types.d.ts.map +1 -1
- package/dist/Utils.d.ts.map +1 -1
- package/dist/Utils.js +2 -1
- package/dist/Utils.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/arbitrary/model.d.ts +2 -0
- package/dist/internal/arbitrary/model.d.ts.map +1 -0
- package/dist/internal/arbitrary/model.js +495 -0
- package/dist/internal/arbitrary/model.js.map +1 -0
- package/dist/internal/arbitrary/regexp.d.ts +2 -0
- package/dist/internal/arbitrary/regexp.d.ts.map +1 -0
- package/dist/internal/arbitrary/regexp.js +789 -0
- package/dist/internal/arbitrary/regexp.js.map +1 -0
- package/dist/internal/arbitrary/runner.d.ts +2 -0
- package/dist/internal/arbitrary/runner.d.ts.map +1 -0
- package/dist/internal/arbitrary/runner.js +496 -0
- package/dist/internal/arbitrary/runner.js.map +1 -0
- package/dist/internal/arbitrary/schema.d.ts.map +1 -0
- package/dist/internal/arbitrary/schema.js +1340 -0
- package/dist/internal/arbitrary/schema.js.map +1 -0
- package/dist/internal/core.js +27 -13
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/count.d.ts +2 -0
- package/dist/internal/count.d.ts.map +1 -0
- package/dist/internal/count.js +14 -0
- package/dist/internal/count.js.map +1 -0
- package/dist/internal/dateTime.js +4 -10
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +386 -251
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/graph.js +3 -1
- package/dist/internal/graph.js.map +1 -1
- package/dist/internal/hashMap.js +5 -3
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/hashSet.js +1 -1
- package/dist/internal/hashSet.js.map +1 -1
- package/dist/internal/matcher.js +1 -1
- package/dist/internal/matcher.js.map +1 -1
- package/dist/internal/metric.js +1 -1
- package/dist/internal/metric.js.map +1 -1
- package/dist/internal/option.js +6 -5
- package/dist/internal/option.js.map +1 -1
- package/dist/internal/random.js +17 -0
- package/dist/internal/random.js.map +1 -1
- package/dist/internal/rcRef.js +10 -7
- package/dist/internal/rcRef.js.map +1 -1
- package/dist/internal/references.js +1 -0
- package/dist/internal/references.js.map +1 -1
- package/dist/internal/request.js +13 -6
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/result.js +11 -9
- package/dist/internal/result.js.map +1 -1
- package/dist/internal/schema/annotations.js +1 -1
- package/dist/internal/schema/annotations.js.map +1 -1
- package/dist/internal/schema/fromJsonSchemaDocument.js +14 -12
- package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -1
- package/dist/internal/schema/fromRepresentation.js +5 -5
- package/dist/internal/schema/fromRepresentation.js.map +1 -1
- package/dist/internal/schema/make.d.ts +2 -0
- package/dist/internal/schema/make.d.ts.map +1 -0
- package/dist/internal/schema/{schema.js → make.js} +1 -25
- package/dist/internal/schema/make.js.map +1 -0
- package/dist/internal/schema/parser.d.ts +0 -12
- package/dist/internal/schema/parser.d.ts.map +1 -1
- package/dist/internal/schema/parser.js +7 -0
- package/dist/internal/schema/parser.js.map +1 -1
- package/dist/internal/schema/standardSchema.d.ts +2 -0
- package/dist/internal/schema/standardSchema.d.ts.map +1 -0
- package/dist/internal/schema/standardSchema.js +112 -0
- package/dist/internal/schema/standardSchema.js.map +1 -0
- package/dist/internal/schema/toCodeDocument.js +34 -22
- package/dist/internal/schema/toCodeDocument.js.map +1 -1
- package/dist/internal/schema/toCodec.d.ts +2 -0
- package/dist/internal/schema/toCodec.d.ts.map +1 -0
- package/dist/internal/schema/toCodec.js +242 -0
- package/dist/internal/schema/toCodec.js.map +1 -0
- package/dist/internal/schema/toDifferJsonPatch.d.ts +2 -0
- package/dist/internal/schema/toDifferJsonPatch.d.ts.map +1 -0
- package/dist/internal/schema/toDifferJsonPatch.js +20 -0
- package/dist/internal/schema/toDifferJsonPatch.js.map +1 -0
- package/dist/internal/schema/toEncoderXml.d.ts +2 -0
- package/dist/internal/schema/toEncoderXml.d.ts.map +1 -0
- package/dist/internal/schema/toEncoderXml.js +104 -0
- package/dist/internal/schema/toEncoderXml.js.map +1 -0
- package/dist/internal/schema/toEquivalence.js +66 -0
- package/dist/internal/schema/toEquivalence.js.map +1 -1
- package/dist/internal/schema/toFormatter.d.ts +2 -0
- package/dist/internal/schema/toFormatter.d.ts.map +1 -0
- package/dist/internal/schema/toFormatter.js +227 -0
- package/dist/internal/schema/toFormatter.js.map +1 -0
- package/dist/internal/schema/toIso.d.ts +2 -0
- package/dist/internal/schema/toIso.d.ts.map +1 -0
- package/dist/internal/schema/toIso.js +17 -0
- package/dist/internal/schema/toIso.js.map +1 -0
- package/dist/internal/schema/toJsonSchemaDocument.js +122 -71
- package/dist/internal/schema/toJsonSchemaDocument.js.map +1 -1
- package/dist/internal/schema/toRepresentation.js +3 -1
- package/dist/internal/schema/toRepresentation.js.map +1 -1
- package/dist/internal/schemaError.d.ts +4 -0
- package/dist/internal/schemaError.d.ts.map +1 -0
- package/dist/internal/schemaError.js +6 -0
- package/dist/internal/schemaError.js.map +1 -0
- package/dist/internal/stream.js +5 -6
- package/dist/internal/stream.js.map +1 -1
- package/dist/internal/tracer.d.ts +1 -3
- package/dist/internal/tracer.d.ts.map +1 -1
- package/dist/internal/tracer.js +6 -0
- package/dist/internal/tracer.js.map +1 -1
- package/dist/internal/trie.js +2 -2
- package/dist/internal/trie.js.map +1 -1
- package/dist/internal/uuid.d.ts +1 -2
- package/dist/internal/uuid.d.ts.map +1 -1
- package/dist/internal/uuid.js +2 -0
- package/dist/internal/uuid.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +9 -11
- package/dist/testing/TestSchema.d.ts.map +1 -1
- package/dist/testing/TestSchema.js +20 -18
- package/dist/testing/TestSchema.js.map +1 -1
- package/dist/testing/index.d.ts +0 -4
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +0 -4
- package/dist/testing/index.js.map +1 -1
- package/dist/unstable/ai/AiError.d.ts +74 -23
- package/dist/unstable/ai/AiError.d.ts.map +1 -1
- package/dist/unstable/ai/AiError.js +59 -5
- package/dist/unstable/ai/AiError.js.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.js +2 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Chat.d.ts +27 -32
- package/dist/unstable/ai/Chat.d.ts.map +1 -1
- package/dist/unstable/ai/Chat.js +10 -13
- package/dist/unstable/ai/Chat.js.map +1 -1
- package/dist/unstable/ai/EmbeddingModel.d.ts +23 -16
- package/dist/unstable/ai/EmbeddingModel.d.ts.map +1 -1
- package/dist/unstable/ai/EmbeddingModel.js +13 -11
- package/dist/unstable/ai/EmbeddingModel.js.map +1 -1
- package/dist/unstable/ai/LanguageModel.d.ts +48 -37
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +150 -47
- package/dist/unstable/ai/LanguageModel.js.map +1 -1
- package/dist/unstable/ai/McpServer.d.ts +2 -2
- package/dist/unstable/ai/McpServer.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.js +21 -12
- package/dist/unstable/ai/McpServer.js.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js +2 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Prompt.d.ts +1 -1
- package/dist/unstable/ai/Prompt.d.ts.map +1 -1
- package/dist/unstable/ai/Prompt.js +15 -4
- package/dist/unstable/ai/Prompt.js.map +1 -1
- package/dist/unstable/ai/Response.d.ts +37 -94
- package/dist/unstable/ai/Response.d.ts.map +1 -1
- package/dist/unstable/ai/Response.js +46 -96
- package/dist/unstable/ai/Response.js.map +1 -1
- package/dist/unstable/ai/Tokenizer.js +4 -5
- package/dist/unstable/ai/Tokenizer.js.map +1 -1
- package/dist/unstable/ai/Tool.d.ts +38 -20
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +27 -1
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/ai/Toolkit.d.ts +1 -1
- package/dist/unstable/ai/Toolkit.d.ts.map +1 -1
- package/dist/unstable/ai/Toolkit.js +30 -18
- package/dist/unstable/ai/Toolkit.js.map +1 -1
- package/dist/unstable/ai/internal/structured-output.js +8 -5
- package/dist/unstable/ai/internal/structured-output.js.map +1 -1
- package/dist/unstable/arbitrary/Arbitrary.d.ts +626 -0
- package/dist/unstable/arbitrary/Arbitrary.d.ts.map +1 -0
- package/dist/unstable/arbitrary/Arbitrary.js +238 -0
- package/dist/unstable/arbitrary/Arbitrary.js.map +1 -0
- package/dist/unstable/arbitrary/index.d.ts +8 -0
- package/dist/unstable/arbitrary/index.d.ts.map +1 -0
- package/dist/unstable/arbitrary/index.js +9 -0
- package/dist/unstable/arbitrary/index.js.map +1 -0
- package/dist/unstable/cli/Argument.d.ts +104 -108
- package/dist/unstable/cli/Argument.d.ts.map +1 -1
- package/dist/unstable/cli/Argument.js +56 -57
- package/dist/unstable/cli/Argument.js.map +1 -1
- package/dist/unstable/cli/CliError.d.ts +2 -0
- package/dist/unstable/cli/CliError.d.ts.map +1 -1
- package/dist/unstable/cli/CliError.js +2 -0
- package/dist/unstable/cli/CliError.js.map +1 -1
- package/dist/unstable/cli/CliOutput.js +26 -3
- package/dist/unstable/cli/CliOutput.js.map +1 -1
- package/dist/unstable/cli/Command.d.ts +73 -73
- package/dist/unstable/cli/Command.js +18 -18
- package/dist/unstable/cli/Completions.d.ts +4 -4
- package/dist/unstable/cli/Completions.d.ts.map +1 -1
- package/dist/unstable/cli/Flag.d.ts +150 -161
- package/dist/unstable/cli/Flag.d.ts.map +1 -1
- package/dist/unstable/cli/Flag.js +79 -90
- package/dist/unstable/cli/Flag.js.map +1 -1
- package/dist/unstable/cli/GlobalFlag.d.ts +3 -3
- package/dist/unstable/cli/GlobalFlag.js +13 -13
- package/dist/unstable/cli/GlobalFlag.js.map +1 -1
- package/dist/unstable/cli/Param.d.ts +118 -126
- package/dist/unstable/cli/Param.d.ts.map +1 -1
- package/dist/unstable/cli/Param.js +104 -113
- package/dist/unstable/cli/Param.js.map +1 -1
- package/dist/unstable/cli/Primitive.d.ts +69 -58
- package/dist/unstable/cli/Primitive.d.ts.map +1 -1
- package/dist/unstable/cli/Primitive.js +65 -66
- package/dist/unstable/cli/Primitive.js.map +1 -1
- package/dist/unstable/cli/Prompt.d.ts +23 -24
- package/dist/unstable/cli/Prompt.d.ts.map +1 -1
- package/dist/unstable/cli/Prompt.js +68 -63
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/cli/internal/completions/descriptor.js +23 -11
- package/dist/unstable/cli/internal/completions/descriptor.js.map +1 -1
- package/dist/unstable/cli/internal/completions/zsh.js +2 -2
- package/dist/unstable/cli/internal/completions/zsh.js.map +1 -1
- package/dist/unstable/cli/internal/config.js +4 -4
- package/dist/unstable/cli/internal/parser.js +1 -1
- package/dist/unstable/cli/internal/parser.js.map +1 -1
- package/dist/unstable/cli/internal/wizard.d.ts.map +1 -1
- package/dist/unstable/cli/internal/wizard.js +14 -13
- package/dist/unstable/cli/internal/wizard.js.map +1 -1
- package/dist/unstable/cluster/ClusterSchema.d.ts +13 -0
- package/dist/unstable/cluster/ClusterSchema.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterSchema.js +16 -1
- package/dist/unstable/cluster/ClusterSchema.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +57 -14
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/cluster/Entity.d.ts.map +1 -1
- package/dist/unstable/cluster/Entity.js +2 -0
- package/dist/unstable/cluster/Entity.js.map +1 -1
- package/dist/unstable/cluster/EntityProxyServer.d.ts +2 -2
- package/dist/unstable/cluster/EntityProxyServer.d.ts.map +1 -1
- package/dist/unstable/cluster/EntityProxyServer.js.map +1 -1
- package/dist/unstable/cluster/Envelope.d.ts +4 -4
- package/dist/unstable/cluster/Envelope.d.ts.map +1 -1
- package/dist/unstable/cluster/Envelope.js +2 -3
- package/dist/unstable/cluster/Envelope.js.map +1 -1
- package/dist/unstable/cluster/HttpRunner.d.ts.map +1 -1
- package/dist/unstable/cluster/HttpRunner.js +5 -2
- package/dist/unstable/cluster/HttpRunner.js.map +1 -1
- package/dist/unstable/cluster/MessageStorage.d.ts +34 -4
- package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/MessageStorage.js +28 -9
- package/dist/unstable/cluster/MessageStorage.js.map +1 -1
- package/dist/unstable/cluster/Reply.d.ts +1 -1
- package/dist/unstable/cluster/Sharding.d.ts +1 -1
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +32 -17
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.js +23 -23
- package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
- package/dist/unstable/cluster/SocketRunner.d.ts +2 -2
- package/dist/unstable/cluster/SocketRunner.d.ts.map +1 -1
- package/dist/unstable/cluster/SocketRunner.js +4 -3
- package/dist/unstable/cluster/SocketRunner.js.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.js +11 -8
- package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.js +11 -4
- package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/unstable/cluster/internal/clusterAbandon.d.ts +5 -0
- package/dist/unstable/cluster/internal/clusterAbandon.d.ts.map +1 -0
- package/dist/unstable/cluster/internal/clusterAbandon.js +9 -0
- package/dist/unstable/cluster/internal/clusterAbandon.js.map +1 -0
- package/dist/unstable/cluster/internal/entityManager.js +7 -4
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/cluster/internal/interruptors.js +30 -1
- package/dist/unstable/cluster/internal/interruptors.js.map +1 -1
- package/dist/unstable/cluster/internal/resourceRef.js +12 -7
- package/dist/unstable/cluster/internal/resourceRef.js.map +1 -1
- package/dist/unstable/devtools/DevToolsClient.d.ts.map +1 -1
- package/dist/unstable/devtools/DevToolsClient.js +12 -7
- package/dist/unstable/devtools/DevToolsClient.js.map +1 -1
- package/dist/unstable/encoding/Ini.d.ts +2 -0
- package/dist/unstable/encoding/Ini.d.ts.map +1 -1
- package/dist/unstable/encoding/Ini.js +2 -0
- package/dist/unstable/encoding/Ini.js.map +1 -1
- package/dist/unstable/encoding/SchemaBinary.d.ts +27 -3
- package/dist/unstable/encoding/SchemaBinary.d.ts.map +1 -1
- package/dist/unstable/encoding/SchemaBinary.js +108 -39
- package/dist/unstable/encoding/SchemaBinary.js.map +1 -1
- package/dist/unstable/encoding/Sse.js +1 -1
- package/dist/unstable/encoding/Sse.js.map +1 -1
- package/dist/unstable/encoding/Toml.d.ts +2 -0
- package/dist/unstable/encoding/Toml.d.ts.map +1 -1
- package/dist/unstable/encoding/Toml.js +6 -4
- package/dist/unstable/encoding/Toml.js.map +1 -1
- package/dist/unstable/encoding/Yaml.d.ts +2 -0
- package/dist/unstable/encoding/Yaml.d.ts.map +1 -1
- package/dist/unstable/encoding/Yaml.js +16 -5
- package/dist/unstable/encoding/Yaml.js.map +1 -1
- package/dist/unstable/encoding/index.d.ts +0 -4
- package/dist/unstable/encoding/index.d.ts.map +1 -1
- package/dist/unstable/encoding/index.js +0 -4
- package/dist/unstable/encoding/index.js.map +1 -1
- package/dist/unstable/eventlog/Event.d.ts +5 -5
- package/dist/unstable/eventlog/Event.d.ts.map +1 -1
- package/dist/unstable/eventlog/Event.js +3 -3
- package/dist/unstable/eventlog/Event.js.map +1 -1
- package/dist/unstable/eventlog/EventJournal.d.ts +7 -7
- package/dist/unstable/eventlog/EventJournal.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventJournal.js +9 -9
- package/dist/unstable/eventlog/EventJournal.js.map +1 -1
- package/dist/unstable/eventlog/EventLog.d.ts +1 -1
- package/dist/unstable/eventlog/EventLog.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLog.js +4 -4
- package/dist/unstable/eventlog/EventLog.js.map +1 -1
- package/dist/unstable/eventlog/EventLogMessage.d.ts +11 -5
- package/dist/unstable/eventlog/EventLogMessage.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogMessage.js +25 -15
- package/dist/unstable/eventlog/EventLogMessage.js.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.d.ts +7 -1
- package/dist/unstable/eventlog/EventLogRemote.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.js +13 -3
- package/dist/unstable/eventlog/EventLogRemote.js.map +1 -1
- package/dist/unstable/eventlog/EventLogServerUnencrypted.js +2 -2
- package/dist/unstable/eventlog/EventLogServerUnencrypted.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventJournal.d.ts.map +1 -1
- package/dist/unstable/eventlog/SqlEventJournal.js +26 -13
- package/dist/unstable/eventlog/SqlEventJournal.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.d.ts.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js +5 -1
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js.map +1 -1
- package/dist/unstable/http/Cookies.d.ts +1 -45
- package/dist/unstable/http/Cookies.d.ts.map +1 -1
- package/dist/unstable/http/Cookies.js +2 -64
- package/dist/unstable/http/Cookies.js.map +1 -1
- package/dist/unstable/http/FetchHttpClient.js +1 -1
- package/dist/unstable/http/FetchHttpClient.js.map +1 -1
- package/dist/unstable/http/FindMyWay/internal/router.js +124 -33
- package/dist/unstable/http/FindMyWay/internal/router.js.map +1 -1
- package/dist/unstable/http/FindMyWay.d.ts +15 -5
- package/dist/unstable/http/FindMyWay.d.ts.map +1 -1
- package/dist/unstable/http/FindMyWay.js +3 -1
- package/dist/unstable/http/FindMyWay.js.map +1 -1
- package/dist/unstable/http/Headers.d.ts +0 -22
- package/dist/unstable/http/Headers.d.ts.map +1 -1
- package/dist/unstable/http/Headers.js +3 -34
- package/dist/unstable/http/Headers.js.map +1 -1
- package/dist/unstable/http/HttpBody.d.ts +41 -10
- package/dist/unstable/http/HttpBody.d.ts.map +1 -1
- package/dist/unstable/http/HttpBody.js +64 -10
- package/dist/unstable/http/HttpBody.js.map +1 -1
- package/dist/unstable/http/HttpClient.d.ts +1 -1
- package/dist/unstable/http/HttpClient.d.ts.map +1 -1
- package/dist/unstable/http/HttpClient.js +28 -18
- package/dist/unstable/http/HttpClient.js.map +1 -1
- package/dist/unstable/http/HttpClientRequest.d.ts +28 -6
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.js +8 -19
- package/dist/unstable/http/HttpClientRequest.js.map +1 -1
- package/dist/unstable/http/HttpClientResponse.d.ts +6 -1
- package/dist/unstable/http/HttpClientResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientResponse.js +10 -6
- package/dist/unstable/http/HttpClientResponse.js.map +1 -1
- package/dist/unstable/http/HttpEffect.d.ts +16 -0
- package/dist/unstable/http/HttpEffect.d.ts.map +1 -1
- package/dist/unstable/http/HttpEffect.js +121 -65
- package/dist/unstable/http/HttpEffect.js.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.d.ts +3 -3
- package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.js +1 -13
- package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
- package/dist/unstable/http/HttpMiddleware.d.ts +1 -1
- package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/unstable/http/HttpMiddleware.js +29 -21
- package/dist/unstable/http/HttpMiddleware.js.map +1 -1
- package/dist/unstable/http/HttpPlatform.d.ts +12 -11
- package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
- package/dist/unstable/http/HttpPlatform.js +36 -10
- package/dist/unstable/http/HttpPlatform.js.map +1 -1
- package/dist/unstable/http/HttpRouter.d.ts +5 -1
- package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
- package/dist/unstable/http/HttpRouter.js +22 -8
- package/dist/unstable/http/HttpRouter.js.map +1 -1
- package/dist/unstable/http/HttpServer.d.ts +11 -42
- package/dist/unstable/http/HttpServer.d.ts.map +1 -1
- package/dist/unstable/http/HttpServer.js +16 -20
- package/dist/unstable/http/HttpServer.js.map +1 -1
- package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRequest.js +11 -11
- package/dist/unstable/http/HttpServerRequest.js.map +1 -1
- package/dist/unstable/http/HttpServerRespondable.js +1 -1
- package/dist/unstable/http/HttpServerRespondable.js.map +1 -1
- package/dist/unstable/http/HttpServerResponse.d.ts +9 -13
- package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerResponse.js +34 -44
- package/dist/unstable/http/HttpServerResponse.js.map +1 -1
- package/dist/unstable/http/HttpStaticServer.d.ts +2 -2
- package/dist/unstable/http/HttpStaticServer.d.ts.map +1 -1
- package/dist/unstable/http/HttpStaticServer.js +19 -19
- package/dist/unstable/http/HttpStaticServer.js.map +1 -1
- package/dist/unstable/http/Mime.d.ts +28 -0
- package/dist/unstable/http/Mime.d.ts.map +1 -0
- package/dist/unstable/http/Mime.js +72 -0
- package/dist/unstable/http/Mime.js.map +1 -0
- package/dist/unstable/http/Multipart.d.ts +22 -9
- package/dist/unstable/http/Multipart.d.ts.map +1 -1
- package/dist/unstable/http/Multipart.js +26 -10
- package/dist/unstable/http/Multipart.js.map +1 -1
- package/dist/unstable/http/MultipartParser/internal/multipart.d.ts +1 -1
- package/dist/unstable/http/MultipartParser/internal/multipart.d.ts.map +1 -1
- package/dist/unstable/http/MultipartParser/internal/multipart.js +8 -3
- package/dist/unstable/http/MultipartParser/internal/multipart.js.map +1 -1
- package/dist/unstable/http/MultipartParser.d.ts +4 -3
- package/dist/unstable/http/MultipartParser.d.ts.map +1 -1
- package/dist/unstable/http/MultipartParser.js.map +1 -1
- package/dist/unstable/http/UrlParams.d.ts +0 -97
- package/dist/unstable/http/UrlParams.d.ts.map +1 -1
- package/dist/unstable/http/UrlParams.js +3 -104
- package/dist/unstable/http/UrlParams.js.map +1 -1
- package/dist/unstable/http/index.d.ts +4 -0
- package/dist/unstable/http/index.d.ts.map +1 -1
- package/dist/unstable/http/index.js +4 -0
- package/dist/unstable/http/index.js.map +1 -1
- package/dist/unstable/http/internal/compression.js +8 -11
- package/dist/unstable/http/internal/compression.js.map +1 -1
- package/dist/unstable/http/internal/headers.d.ts +2 -0
- package/dist/unstable/http/internal/headers.d.ts.map +1 -0
- package/dist/unstable/http/internal/headers.js +5 -0
- package/dist/unstable/http/internal/headers.js.map +1 -0
- package/dist/unstable/http/internal/httpBody.js +8 -0
- package/dist/unstable/http/internal/httpBody.js.map +1 -1
- package/dist/unstable/http/internal/mimeTypes.d.ts +361 -0
- package/dist/unstable/http/internal/mimeTypes.d.ts.map +1 -0
- package/dist/unstable/http/internal/mimeTypes.js +363 -0
- package/dist/unstable/http/internal/mimeTypes.js.map +1 -0
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts +13 -0
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +23 -6
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.d.ts +4 -3
- package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.js +25 -13
- package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +8 -3
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.js +9 -6
- package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.js +3 -1
- package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.js +7 -5
- package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.d.ts +12 -0
- package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.js +8 -10
- package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiTest.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiTest.js +8 -2
- package/dist/unstable/httpapi/HttpApiTest.js.map +1 -1
- package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/OpenApi.js +31 -20
- package/dist/unstable/httpapi/OpenApi.js.map +1 -1
- package/dist/unstable/net/IpInterface.d.ts +140 -0
- package/dist/unstable/net/IpInterface.d.ts.map +1 -0
- package/dist/unstable/net/IpInterface.js +149 -0
- package/dist/unstable/net/IpInterface.js.map +1 -0
- package/dist/unstable/net/IpNetwork.d.ts +227 -0
- package/dist/unstable/net/IpNetwork.d.ts.map +1 -0
- package/dist/unstable/net/IpNetwork.js +239 -0
- package/dist/unstable/net/IpNetwork.js.map +1 -0
- package/dist/unstable/net/NetAddress.d.ts +705 -0
- package/dist/unstable/net/NetAddress.d.ts.map +1 -0
- package/dist/unstable/net/NetAddress.js +956 -0
- package/dist/unstable/net/NetAddress.js.map +1 -0
- package/dist/unstable/net/index.d.ts +16 -0
- package/dist/unstable/net/index.d.ts.map +1 -0
- package/dist/unstable/net/index.js +17 -0
- package/dist/unstable/net/index.js.map +1 -0
- package/dist/unstable/observability/OtlpExporter.d.ts +1 -0
- package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.js +4 -6
- package/dist/unstable/observability/OtlpExporter.js.map +1 -1
- package/dist/unstable/observability/OtlpLogger.js +9 -9
- package/dist/unstable/observability/OtlpLogger.js.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.js +9 -8
- package/dist/unstable/observability/OtlpMetrics.js.map +1 -1
- package/dist/unstable/observability/OtlpResource.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpResource.js +2 -2
- package/dist/unstable/observability/OtlpResource.js.map +1 -1
- package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpTracer.js +82 -55
- package/dist/unstable/observability/OtlpTracer.js.map +1 -1
- package/dist/unstable/observability/internal/otlpEnv.d.ts +1 -1
- package/dist/unstable/observability/internal/otlpEnv.d.ts.map +1 -1
- package/dist/unstable/observability/internal/otlpEnv.js +5 -9
- package/dist/unstable/observability/internal/otlpEnv.js.map +1 -1
- package/dist/unstable/persistence/PersistedCache.js +1 -1
- package/dist/unstable/persistence/PersistedCache.js.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.d.ts +114 -14
- package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.js +799 -234
- package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
- package/dist/unstable/persistence/RateLimiter.d.ts +28 -15
- package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
- package/dist/unstable/persistence/RateLimiter.js +33 -41
- package/dist/unstable/persistence/RateLimiter.js.map +1 -1
- package/dist/unstable/process/ChildProcess.d.ts +8 -2
- package/dist/unstable/process/ChildProcess.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcess.js +7 -2
- package/dist/unstable/process/ChildProcess.js.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.d.ts +1 -1
- package/dist/unstable/process/ChildProcessSpawner.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.js +1 -1
- package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +6 -3
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts +3 -6
- package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.js +6 -3
- package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.js +2 -3
- package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.d.ts +2 -2
- package/dist/unstable/reactivity/AtomRpc.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.js +1 -1
- package/dist/unstable/reactivity/AtomRpc.js.map +1 -1
- package/dist/unstable/reactivity/Hydration.d.ts +6 -4
- package/dist/unstable/reactivity/Hydration.d.ts.map +1 -1
- package/dist/unstable/reactivity/Hydration.js +20 -6
- package/dist/unstable/reactivity/Hydration.js.map +1 -1
- package/dist/unstable/reactivity/Reactivity.d.ts +26 -26
- package/dist/unstable/reactivity/Reactivity.d.ts.map +1 -1
- package/dist/unstable/reactivity/Reactivity.js +10 -12
- package/dist/unstable/reactivity/Reactivity.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +64 -64
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/rpc/RpcClientError.d.ts +1 -1
- package/dist/unstable/rpc/RpcMessage.d.ts +3 -1
- package/dist/unstable/rpc/RpcMessage.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMessage.js +1 -1
- package/dist/unstable/rpc/RpcMessage.js.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.js +7 -5
- package/dist/unstable/rpc/RpcMiddleware.js.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.d.ts +5 -39
- package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.js +22 -115
- package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +104 -57
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/schema/Model.d.ts.map +1 -1
- package/dist/unstable/schema/Model.js +7 -6
- package/dist/unstable/schema/Model.js.map +1 -1
- package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
- package/dist/unstable/schema/VariantSchema.js +3 -0
- package/dist/unstable/schema/VariantSchema.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts +287 -102
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +408 -215
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/dist/unstable/socket/SocketServer.d.ts +5 -32
- package/dist/unstable/socket/SocketServer.d.ts.map +1 -1
- package/dist/unstable/socket/SocketServer.js +3 -3
- package/dist/unstable/socket/SocketServer.js.map +1 -1
- package/dist/unstable/sql/SqlClient.d.ts +20 -0
- package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
- package/dist/unstable/sql/SqlClient.js +14 -7
- package/dist/unstable/sql/SqlClient.js.map +1 -1
- package/dist/unstable/sql/SqlConnection.d.ts +15 -0
- package/dist/unstable/sql/SqlConnection.d.ts.map +1 -1
- package/dist/unstable/sql/SqlConnection.js.map +1 -1
- package/dist/unstable/sql/SqlModel.d.ts +1 -1
- package/dist/unstable/sql/SqlModel.d.ts.map +1 -1
- package/dist/unstable/sql/Statement.d.ts +13 -5
- package/dist/unstable/sql/Statement.d.ts.map +1 -1
- package/dist/unstable/sql/Statement.js +29 -15
- package/dist/unstable/sql/Statement.js.map +1 -1
- package/dist/unstable/workers/Transferable.js +1 -1
- package/dist/unstable/workers/Worker.d.ts.map +1 -1
- package/dist/unstable/workers/Worker.js +3 -1
- package/dist/unstable/workers/Worker.js.map +1 -1
- package/dist/unstable/workflow/Activity.d.ts +7 -0
- package/dist/unstable/workflow/Activity.d.ts.map +1 -1
- package/dist/unstable/workflow/Activity.js +14 -4
- package/dist/unstable/workflow/Activity.js.map +1 -1
- package/dist/unstable/workflow/DurableClock.js +1 -1
- package/dist/unstable/workflow/DurableClock.js.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.d.ts +2 -2
- package/dist/unstable/workflow/DurableDeferred.d.ts.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
- package/dist/unstable/workflow/DurableQueue.d.ts +8 -0
- package/dist/unstable/workflow/DurableQueue.d.ts.map +1 -1
- package/dist/unstable/workflow/DurableQueue.js +8 -0
- package/dist/unstable/workflow/DurableQueue.js.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts +5 -0
- package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
- package/dist/unstable/workflow/Workflow.js +70 -12
- package/dist/unstable/workflow/Workflow.js.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts +6 -0
- package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js +11 -0
- package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +7 -9
- package/src/Array.ts +118 -67
- package/src/BigDecimal.ts +50 -28
- package/src/ByteSize.ts +838 -0
- package/src/Cache.ts +17 -3
- package/src/Cause.ts +1 -1
- package/src/Channel.ts +183 -48
- package/src/Chunk.ts +65 -36
- package/src/Config.ts +237 -248
- package/src/ConfigProvider.ts +7 -8
- package/src/Context.ts +31 -0
- package/src/Cron.ts +2 -2
- package/src/Crypto.ts +3 -2
- package/src/Deferred.ts +7 -6
- package/src/Duration.ts +1 -1
- package/src/Effect.ts +226 -122
- package/src/Effectable.ts +78 -9
- package/src/Encoding.ts +101 -11
- package/src/Equal.ts +1 -1
- package/src/ExecutionPlan.ts +3 -0
- package/src/Fiber.ts +33 -8
- package/src/FiberHandle.ts +3 -3
- package/src/FiberMap.ts +19 -10
- package/src/FileSystem.ts +55 -230
- package/src/Formatter.ts +21 -3
- package/src/Graph.ts +55 -25
- package/src/Hash.ts +5 -16
- package/src/HashRing.ts +9 -2
- package/src/HashSet.ts +56 -0
- package/src/Iterable.ts +66 -41
- package/src/JsonPatch.ts +4 -4
- package/src/JsonPointer.ts +97 -4
- package/src/JsonSchema.ts +8 -26
- package/src/Layer.ts +59 -18
- package/src/LayerMap.ts +8 -6
- package/src/LayerRef.ts +7 -5
- package/src/Logger.ts +125 -18
- package/src/ManagedRuntime.ts +1 -1
- package/src/Match.ts +33 -14
- package/src/Metric.ts +24 -21
- package/src/MutableHashMap.ts +1 -1
- package/src/MutableHashSet.ts +1 -1
- package/src/MutableList.ts +18 -2
- package/src/Number.ts +7 -1
- package/src/Optic.ts +8 -4
- package/src/Option.ts +1 -1
- package/src/Order.ts +3 -1
- package/src/PartitionedSemaphore.ts +1 -2
- package/src/Path.ts +1 -1
- package/src/PlatformError.ts +1 -1
- package/src/Pool.ts +125 -8
- package/src/PrimaryKey.ts +1 -1
- package/src/PubSub.ts +32 -20
- package/src/Queue.ts +119 -28
- package/src/Random.ts +20 -6
- package/src/RcMap.ts +20 -13
- package/src/Redacted.ts +1 -1
- package/src/RequestResolver.ts +49 -26
- package/src/Result.ts +1 -1
- package/src/Scheduler.ts +21 -11
- package/src/Schema.ts +4809 -6368
- package/src/SchemaAST.ts +1031 -284
- package/src/SchemaGetter.ts +75 -21
- package/src/SchemaIssue.ts +259 -15
- package/src/SchemaParser.ts +2 -12
- package/src/SchemaRepresentation.ts +1593 -29
- package/src/SchemaTransformation.ts +145 -22
- package/src/ScopedCache.ts +10 -3
- package/src/Sink.ts +31 -15
- package/src/Stream.ts +294 -76
- package/src/String.ts +20 -9
- package/src/Struct.ts +8 -4
- package/src/SynchronizedRef.ts +3 -5
- package/src/Terminal.ts +3 -3
- package/src/Tracer.ts +43 -14
- package/src/Tuple.ts +3 -1
- package/src/TxChunk.ts +1 -1
- package/src/TxDeferred.ts +1 -1
- package/src/TxHashMap.ts +1 -1
- package/src/TxHashSet.ts +92 -11
- package/src/TxPriorityQueue.ts +1 -1
- package/src/TxPubSub.ts +1 -1
- package/src/TxQueue.ts +22 -17
- package/src/TxReentrantLock.ts +29 -1
- package/src/TxRef.ts +1 -1
- package/src/TxSemaphore.ts +1 -1
- package/src/TxSubscriptionRef.ts +1 -1
- package/src/Types.ts +40 -17
- package/src/Utils.ts +3 -1
- package/src/index.ts +5 -0
- package/src/internal/arbitrary/model.ts +701 -0
- package/src/internal/arbitrary/regexp.ts +855 -0
- package/src/internal/arbitrary/runner.ts +608 -0
- package/src/internal/arbitrary/schema.ts +1800 -0
- package/src/internal/core.ts +48 -22
- package/src/internal/count.ts +14 -0
- package/src/internal/dateTime.ts +8 -10
- package/src/internal/effect.ts +475 -295
- package/src/internal/graph.ts +6 -1
- package/src/internal/hashMap.ts +5 -3
- package/src/internal/hashSet.ts +1 -1
- package/src/internal/matcher.ts +34 -19
- package/src/internal/metric.ts +1 -1
- package/src/internal/option.ts +8 -6
- package/src/internal/random.ts +20 -7
- package/src/internal/rcRef.ts +10 -7
- package/src/internal/references.ts +1 -0
- package/src/internal/request.ts +12 -7
- package/src/internal/result.ts +15 -11
- package/src/internal/schema/annotations.ts +3 -3
- package/src/internal/schema/fromJsonSchemaDocument.ts +14 -29
- package/src/internal/schema/fromRepresentation.ts +5 -3
- package/src/internal/schema/{schema.ts → make.ts} +0 -40
- package/src/internal/schema/parser.ts +8 -0
- package/src/internal/schema/standardSchema.ts +125 -0
- package/src/internal/schema/toCodeDocument.ts +58 -44
- package/src/internal/schema/toCodec.ts +312 -0
- package/src/internal/schema/toDifferJsonPatch.ts +24 -0
- package/src/internal/schema/toEncoderXml.ts +110 -0
- package/src/internal/schema/toEquivalence.ts +76 -0
- package/src/internal/schema/toFormatter.ts +230 -0
- package/src/internal/schema/toIso.ts +20 -0
- package/src/internal/schema/toJsonSchemaDocument.ts +125 -67
- package/src/internal/schema/toRepresentation.ts +1 -1
- package/src/internal/schemaError.ts +8 -0
- package/src/internal/stream.ts +14 -6
- package/src/internal/tracer.ts +4 -0
- package/src/internal/trie.ts +5 -2
- package/src/internal/uuid.ts +4 -0
- package/src/testing/TestSchema.ts +36 -30
- package/src/testing/index.ts +0 -5
- package/src/unstable/ai/AiError.ts +69 -5
- package/src/unstable/ai/AnthropicStructuredOutput.ts +4 -1
- package/src/unstable/ai/Chat.ts +35 -36
- package/src/unstable/ai/EmbeddingModel.ts +27 -15
- package/src/unstable/ai/LanguageModel.ts +283 -100
- package/src/unstable/ai/McpServer.ts +36 -20
- package/src/unstable/ai/OpenAiStructuredOutput.ts +4 -1
- package/src/unstable/ai/Prompt.ts +19 -4
- package/src/unstable/ai/Response.ts +107 -189
- package/src/unstable/ai/Tokenizer.ts +4 -5
- package/src/unstable/ai/Tool.ts +58 -35
- package/src/unstable/ai/Toolkit.ts +43 -37
- package/src/unstable/ai/internal/structured-output.ts +5 -5
- package/src/unstable/arbitrary/Arbitrary.ts +715 -0
- package/src/unstable/arbitrary/index.ts +10 -0
- package/src/unstable/cli/Argument.ts +111 -115
- package/src/unstable/cli/CliError.ts +2 -0
- package/src/unstable/cli/CliOutput.ts +40 -3
- package/src/unstable/cli/Command.ts +74 -74
- package/src/unstable/cli/Completions.ts +4 -4
- package/src/unstable/cli/Flag.ts +158 -169
- package/src/unstable/cli/GlobalFlag.ts +13 -13
- package/src/unstable/cli/Param.ts +150 -159
- package/src/unstable/cli/Primitive.ts +75 -76
- package/src/unstable/cli/Prompt.ts +88 -87
- package/src/unstable/cli/internal/completions/descriptor.ts +23 -11
- package/src/unstable/cli/internal/completions/zsh.ts +2 -2
- package/src/unstable/cli/internal/config.ts +4 -4
- package/src/unstable/cli/internal/parser.ts +1 -1
- package/src/unstable/cli/internal/wizard.ts +18 -13
- package/src/unstable/cluster/ClusterSchema.ts +19 -1
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +66 -16
- package/src/unstable/cluster/Entity.ts +3 -0
- package/src/unstable/cluster/EntityProxyServer.ts +6 -2
- package/src/unstable/cluster/Envelope.ts +3 -3
- package/src/unstable/cluster/HttpRunner.ts +7 -2
- package/src/unstable/cluster/MessageStorage.ts +62 -21
- package/src/unstable/cluster/Reply.ts +2 -2
- package/src/unstable/cluster/Sharding.ts +44 -19
- package/src/unstable/cluster/ShardingConfig.ts +23 -23
- package/src/unstable/cluster/SocketRunner.ts +5 -4
- package/src/unstable/cluster/SqlMessageStorage.ts +12 -8
- package/src/unstable/cluster/SqlRunnerStorage.ts +18 -10
- package/src/unstable/cluster/internal/clusterAbandon.ts +14 -0
- package/src/unstable/cluster/internal/entityManager.ts +12 -4
- package/src/unstable/cluster/internal/interruptors.ts +58 -1
- package/src/unstable/cluster/internal/resourceRef.ts +15 -7
- package/src/unstable/devtools/DevToolsClient.ts +13 -3
- package/src/unstable/encoding/Ini.ts +2 -0
- package/src/unstable/encoding/SchemaBinary.ts +150 -44
- package/src/unstable/encoding/Sse.ts +1 -1
- package/src/unstable/encoding/Toml.ts +7 -5
- package/src/unstable/encoding/Yaml.ts +18 -5
- package/src/unstable/encoding/index.ts +0 -5
- package/src/unstable/eventlog/Event.ts +7 -7
- package/src/unstable/eventlog/EventJournal.ts +9 -9
- package/src/unstable/eventlog/EventLog.ts +5 -5
- package/src/unstable/eventlog/EventLogMessage.ts +25 -15
- package/src/unstable/eventlog/EventLogRemote.ts +15 -4
- package/src/unstable/eventlog/EventLogServerUnencrypted.ts +2 -2
- package/src/unstable/eventlog/SqlEventJournal.ts +32 -9
- package/src/unstable/eventlog/SqlEventLogServerUnencrypted.ts +11 -1
- package/src/unstable/http/Cookies.ts +2 -102
- package/src/unstable/http/FetchHttpClient.ts +1 -1
- package/src/unstable/http/FindMyWay/internal/router.ts +139 -33
- package/src/unstable/http/FindMyWay.ts +15 -5
- package/src/unstable/http/Headers.ts +3 -48
- package/src/unstable/http/HttpBody.ts +107 -36
- package/src/unstable/http/HttpClient.ts +41 -30
- package/src/unstable/http/HttpClientRequest.ts +32 -18
- package/src/unstable/http/HttpClientResponse.ts +16 -3
- package/src/unstable/http/HttpEffect.ts +145 -73
- package/src/unstable/http/HttpIncomingMessage.ts +4 -4
- package/src/unstable/http/HttpMiddleware.ts +43 -24
- package/src/unstable/http/HttpPlatform.ts +62 -20
- package/src/unstable/http/HttpRouter.ts +27 -16
- package/src/unstable/http/HttpServer.ts +18 -57
- package/src/unstable/http/HttpServerRequest.ts +17 -15
- package/src/unstable/http/HttpServerRespondable.ts +1 -1
- package/src/unstable/http/HttpServerResponse.ts +49 -40
- package/src/unstable/http/HttpStaticServer.ts +30 -28
- package/src/unstable/http/Mime.ts +76 -0
- package/src/unstable/http/Multipart.ts +35 -18
- package/src/unstable/http/MultipartParser/internal/multipart.ts +10 -3
- package/src/unstable/http/MultipartParser.ts +4 -3
- package/src/unstable/http/UrlParams.ts +3 -161
- package/src/unstable/http/index.ts +5 -0
- package/src/unstable/http/internal/compression.ts +11 -12
- package/src/unstable/http/internal/headers.ts +7 -0
- package/src/unstable/http/internal/httpBody.ts +9 -0
- package/src/unstable/http/internal/mimeTypes.ts +395 -0
- package/src/unstable/httpapi/HttpApiBuilder.ts +52 -6
- package/src/unstable/httpapi/HttpApiClient.ts +44 -24
- package/src/unstable/httpapi/HttpApiEndpoint.ts +24 -11
- package/src/unstable/httpapi/HttpApiError.ts +3 -1
- package/src/unstable/httpapi/HttpApiMiddleware.ts +7 -5
- package/src/unstable/httpapi/HttpApiSchema.ts +14 -7
- package/src/unstable/httpapi/HttpApiTest.ts +6 -1
- package/src/unstable/httpapi/OpenApi.ts +32 -22
- package/src/unstable/net/IpInterface.ts +242 -0
- package/src/unstable/net/IpNetwork.ts +357 -0
- package/src/unstable/net/NetAddress.ts +1271 -0
- package/src/unstable/net/index.ts +20 -0
- package/src/unstable/observability/OtlpExporter.ts +5 -6
- package/src/unstable/observability/OtlpLogger.ts +9 -9
- package/src/unstable/observability/OtlpMetrics.ts +9 -8
- package/src/unstable/observability/OtlpResource.ts +5 -4
- package/src/unstable/observability/OtlpTracer.ts +103 -81
- package/src/unstable/observability/internal/otlpEnv.ts +10 -13
- package/src/unstable/persistence/PersistedCache.ts +1 -1
- package/src/unstable/persistence/PersistedQueue.ts +1100 -291
- package/src/unstable/persistence/RateLimiter.ts +64 -58
- package/src/unstable/process/ChildProcess.ts +15 -4
- package/src/unstable/process/ChildProcessSpawner.ts +1 -1
- package/src/unstable/reactivity/Atom.ts +6 -3
- package/src/unstable/reactivity/AtomHttpApi.ts +21 -10
- package/src/unstable/reactivity/AtomRegistry.ts +2 -4
- package/src/unstable/reactivity/AtomRpc.ts +6 -5
- package/src/unstable/reactivity/Hydration.ts +26 -7
- package/src/unstable/reactivity/Reactivity.ts +49 -36
- package/src/unstable/rpc/RpcClient.ts +62 -59
- package/src/unstable/rpc/RpcMessage.ts +3 -1
- package/src/unstable/rpc/RpcMiddleware.ts +7 -5
- package/src/unstable/rpc/RpcSerialization.ts +27 -117
- package/src/unstable/rpc/RpcServer.ts +143 -80
- package/src/unstable/schema/Model.ts +8 -7
- package/src/unstable/schema/VariantSchema.ts +3 -0
- package/src/unstable/socket/Socket.ts +714 -383
- package/src/unstable/socket/SocketServer.ts +5 -35
- package/src/unstable/sql/SqlClient.ts +42 -7
- package/src/unstable/sql/SqlConnection.ts +18 -0
- package/src/unstable/sql/SqlModel.ts +1 -1
- package/src/unstable/sql/Statement.ts +46 -20
- package/src/unstable/workers/Transferable.ts +1 -1
- package/src/unstable/workers/Worker.ts +3 -1
- package/src/unstable/workflow/Activity.ts +20 -9
- package/src/unstable/workflow/DurableClock.ts +1 -1
- package/src/unstable/workflow/DurableDeferred.ts +6 -0
- package/src/unstable/workflow/DurableQueue.ts +8 -0
- package/src/unstable/workflow/Workflow.ts +105 -28
- package/src/unstable/workflow/WorkflowEngine.ts +22 -0
- package/dist/internal/schema/schema.d.ts.map +0 -1
- package/dist/internal/schema/schema.js.map +0 -1
- package/dist/internal/schema/toArbitrary.d.ts +0 -2
- package/dist/internal/schema/toArbitrary.d.ts.map +0 -1
- package/dist/internal/schema/toArbitrary.js +0 -705
- package/dist/internal/schema/toArbitrary.js.map +0 -1
- package/dist/testing/FastCheck.d.ts +0 -90
- package/dist/testing/FastCheck.d.ts.map +0 -1
- package/dist/testing/FastCheck.js +0 -90
- package/dist/testing/FastCheck.js.map +0 -1
- package/dist/unstable/encoding/Msgpack.d.ts +0 -185
- package/dist/unstable/encoding/Msgpack.d.ts.map +0 -1
- package/dist/unstable/encoding/Msgpack.js +0 -227
- package/dist/unstable/encoding/Msgpack.js.map +0 -1
- package/src/internal/schema/toArbitrary.ts +0 -843
- package/src/testing/FastCheck.ts +0 -90
- package/src/unstable/encoding/Msgpack.ts +0 -432
- /package/dist/internal/{schema → arbitrary}/schema.d.ts +0 -0
|
@@ -0,0 +1,1340 @@
|
|
|
1
|
+
import * as Effect from "../../Effect.js";
|
|
2
|
+
import * as Equal from "../../Equal.js";
|
|
3
|
+
import { identity } from "../../Function.js";
|
|
4
|
+
import * as Hash from "../../Hash.js";
|
|
5
|
+
import * as Option from "../../Option.js";
|
|
6
|
+
import * as Order from "../../Order.js";
|
|
7
|
+
import * as Schema from "../../Schema.js";
|
|
8
|
+
import * as SchemaAST from "../../SchemaAST.js";
|
|
9
|
+
import * as SchemaGetter from "../../SchemaGetter.js";
|
|
10
|
+
import * as SchemaParser from "../../SchemaParser.js";
|
|
11
|
+
import { effectIsExit } from "../effect.js";
|
|
12
|
+
import { errorWithPath } from "../errors.js";
|
|
13
|
+
import * as InternalRecord from "../record.js";
|
|
14
|
+
import * as Model from "./model.js";
|
|
15
|
+
import * as Regexp from "./regexp.js";
|
|
16
|
+
const infinity = Number.POSITIVE_INFINITY;
|
|
17
|
+
const finiteNumberConstraint = {
|
|
18
|
+
number: "finite"
|
|
19
|
+
};
|
|
20
|
+
const optionMatch = {
|
|
21
|
+
onFailure: Option.none,
|
|
22
|
+
onSuccess: Option.some
|
|
23
|
+
};
|
|
24
|
+
const optionComputation = self => {
|
|
25
|
+
const result = Effect.matchEager(self, optionMatch);
|
|
26
|
+
return effectIsExit(result) && result._tag === "Success" ? result.value : result;
|
|
27
|
+
};
|
|
28
|
+
/** @internal */
|
|
29
|
+
export function compileValidator(schema) {
|
|
30
|
+
const parse = SchemaParser.run(SchemaAST.toType(schema.ast));
|
|
31
|
+
return value => optionComputation(parse(value));
|
|
32
|
+
}
|
|
33
|
+
function arbitraryError(what, path) {
|
|
34
|
+
return errorWithPath(`Unable to derive an arbitrary for ${what}`, path);
|
|
35
|
+
}
|
|
36
|
+
function sumCosts(costs) {
|
|
37
|
+
let out = 0;
|
|
38
|
+
for (const cost of costs) {
|
|
39
|
+
if (cost === infinity) return infinity;
|
|
40
|
+
out += cost;
|
|
41
|
+
}
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
function mergeOrderedBound(order, self, selfExclusive, that, thatExclusive, takeComparison) {
|
|
45
|
+
if (that === undefined || self === undefined) {
|
|
46
|
+
return that === undefined ? [self, selfExclusive] : [that, thatExclusive];
|
|
47
|
+
}
|
|
48
|
+
const comparison = order(self, that);
|
|
49
|
+
return comparison === takeComparison ? [that, thatExclusive] : comparison === 0 ? [self, selfExclusive || thatExclusive] : [self, selfExclusive];
|
|
50
|
+
}
|
|
51
|
+
function mergeMinimum(self, that) {
|
|
52
|
+
return self === undefined ? that : that === undefined ? self : Math.max(self, that);
|
|
53
|
+
}
|
|
54
|
+
function mergeMaximum(self, that) {
|
|
55
|
+
return self === undefined ? that : that === undefined ? self : Math.min(self, that);
|
|
56
|
+
}
|
|
57
|
+
function mergeConstraint(self, that) {
|
|
58
|
+
const order = that.order ?? self?.order;
|
|
59
|
+
if (self?.order !== undefined && that.order !== undefined && self.order !== that.order) {
|
|
60
|
+
throw new Error("Cannot merge ordered arbitrary constraints with different Order instances");
|
|
61
|
+
}
|
|
62
|
+
const [minimum, exclusiveMinimum] = order === undefined ? [that.minimum ?? self?.minimum, that.exclusiveMinimum ?? self?.exclusiveMinimum] : mergeOrderedBound(order, self?.minimum, self?.exclusiveMinimum, that.minimum, that.exclusiveMinimum, -1);
|
|
63
|
+
const [maximum, exclusiveMaximum] = order === undefined ? [that.maximum ?? self?.maximum, that.exclusiveMaximum ?? self?.exclusiveMaximum] : mergeOrderedBound(order, self?.maximum, self?.exclusiveMaximum, that.maximum, that.exclusiveMaximum, 1);
|
|
64
|
+
const minLength = mergeMinimum(self?.minLength, that.minLength);
|
|
65
|
+
const maxLength = mergeMaximum(self?.maxLength, that.maxLength);
|
|
66
|
+
const minSize = mergeMinimum(self?.minSize, that.minSize);
|
|
67
|
+
const maxSize = mergeMaximum(self?.maxSize, that.maxSize);
|
|
68
|
+
const minProperties = mergeMinimum(self?.minProperties, that.minProperties);
|
|
69
|
+
const maxProperties = mergeMaximum(self?.maxProperties, that.maxProperties);
|
|
70
|
+
const patterns = self?.patterns === undefined ? that.patterns : that.patterns === undefined ? self.patterns : [...self.patterns, ...that.patterns];
|
|
71
|
+
const number = self?.number === "integer" || that.number === "integer" ? "integer" : self?.number === "finite" || that.number === "finite" ? "finite" : undefined;
|
|
72
|
+
const uniqueBy = that.uniqueBy ?? self?.uniqueBy;
|
|
73
|
+
return {
|
|
74
|
+
...(order === undefined ? undefined : {
|
|
75
|
+
order
|
|
76
|
+
}),
|
|
77
|
+
...(minimum === undefined ? undefined : {
|
|
78
|
+
minimum
|
|
79
|
+
}),
|
|
80
|
+
...(exclusiveMinimum === true ? {
|
|
81
|
+
exclusiveMinimum: true
|
|
82
|
+
} : undefined),
|
|
83
|
+
...(maximum === undefined ? undefined : {
|
|
84
|
+
maximum
|
|
85
|
+
}),
|
|
86
|
+
...(exclusiveMaximum === true ? {
|
|
87
|
+
exclusiveMaximum: true
|
|
88
|
+
} : undefined),
|
|
89
|
+
...(minLength === undefined ? undefined : {
|
|
90
|
+
minLength
|
|
91
|
+
}),
|
|
92
|
+
...(maxLength === undefined ? undefined : {
|
|
93
|
+
maxLength
|
|
94
|
+
}),
|
|
95
|
+
...(minSize === undefined ? undefined : {
|
|
96
|
+
minSize
|
|
97
|
+
}),
|
|
98
|
+
...(maxSize === undefined ? undefined : {
|
|
99
|
+
maxSize
|
|
100
|
+
}),
|
|
101
|
+
...(minProperties === undefined ? undefined : {
|
|
102
|
+
minProperties
|
|
103
|
+
}),
|
|
104
|
+
...(maxProperties === undefined ? undefined : {
|
|
105
|
+
maxProperties
|
|
106
|
+
}),
|
|
107
|
+
...(patterns === undefined ? undefined : {
|
|
108
|
+
patterns
|
|
109
|
+
}),
|
|
110
|
+
...(number === undefined ? undefined : {
|
|
111
|
+
number
|
|
112
|
+
}),
|
|
113
|
+
...(uniqueBy === undefined ? undefined : {
|
|
114
|
+
uniqueBy
|
|
115
|
+
})
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function collectChecks(checks, inherited) {
|
|
119
|
+
let constraint = inherited;
|
|
120
|
+
const filters = [];
|
|
121
|
+
const visit = check => {
|
|
122
|
+
const next = check.annotations?.arbitraryConstraint;
|
|
123
|
+
if (next !== undefined) constraint = mergeConstraint(constraint, next);
|
|
124
|
+
if (check._tag === "Filter") {
|
|
125
|
+
filters.push(check);
|
|
126
|
+
} else {
|
|
127
|
+
check.checks.forEach(visit);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
checks?.forEach(visit);
|
|
131
|
+
return {
|
|
132
|
+
constraint,
|
|
133
|
+
filters
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function applyFilters(compiled, ast, filters) {
|
|
137
|
+
if (filters.length === 0) return;
|
|
138
|
+
const generate = compiled.generate;
|
|
139
|
+
const passes = value => {
|
|
140
|
+
for (let index = 0; index < filters.length; index++) {
|
|
141
|
+
if (filters[index].run(value, ast, SchemaAST.defaultParseOptions) !== undefined) return false;
|
|
142
|
+
}
|
|
143
|
+
return true;
|
|
144
|
+
};
|
|
145
|
+
compiled.generate = state => Model.mapGeneration(generate(state), attempt => {
|
|
146
|
+
if (attempt._tag === "Discarded") return Model.discarded;
|
|
147
|
+
if (!state.shrinks) return passes(attempt.value) ? attempt : Model.discarded;
|
|
148
|
+
const sample = Model.filterSample(attempt, passes);
|
|
149
|
+
return sample ?? Model.discarded;
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
function validateConstraint(constraint, path) {
|
|
153
|
+
if (constraint === undefined) return;
|
|
154
|
+
const cardinalities = [[constraint.minLength, constraint.maxLength], [constraint.minSize, constraint.maxSize], [constraint.minProperties, constraint.maxProperties]];
|
|
155
|
+
for (const [minimum, maximum] of cardinalities) {
|
|
156
|
+
if (minimum !== undefined && (!Number.isSafeInteger(minimum) || minimum < 0) || maximum !== undefined && (!Number.isSafeInteger(maximum) || maximum < 0) || minimum !== undefined && maximum !== undefined && minimum > maximum) {
|
|
157
|
+
throw arbitraryError("constraints", path);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (constraint.order !== undefined && constraint.minimum !== undefined && constraint.maximum !== undefined) {
|
|
161
|
+
const comparison = constraint.order(constraint.minimum, constraint.maximum);
|
|
162
|
+
if (comparison > 0 || comparison === 0 && (constraint.exclusiveMinimum === true || constraint.exclusiveMaximum === true)) {
|
|
163
|
+
throw arbitraryError("constraints", path);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
function withoutOrder(constraint) {
|
|
168
|
+
if (constraint === undefined) return undefined;
|
|
169
|
+
const {
|
|
170
|
+
order: _,
|
|
171
|
+
...out
|
|
172
|
+
} = constraint;
|
|
173
|
+
return Object.keys(out).length === 0 ? undefined : out;
|
|
174
|
+
}
|
|
175
|
+
const minimumDateTimestamp = -8_640_000_000_000_000;
|
|
176
|
+
const maximumDateTimestamp = 8_640_000_000_000_000;
|
|
177
|
+
const regexpArbitraryFlags = ["g", "i", "m", "s", "u", "y"];
|
|
178
|
+
function jsonSchema() {
|
|
179
|
+
let schema;
|
|
180
|
+
schema = Schema.Union([Schema.Null, Schema.Finite, Schema.Boolean, Schema.String, Schema.Array(Schema.suspend(() => schema)), Schema.Record(Schema.String, Schema.suspend(() => schema))]);
|
|
181
|
+
return schema;
|
|
182
|
+
}
|
|
183
|
+
function regexpSchema() {
|
|
184
|
+
return Schema.Struct({
|
|
185
|
+
source: Schema.Literals(["", ".", ".*", "\\d+", "\\w+", "[a-z]+", "[A-Z]+", "[0-9]+", "^[a-zA-Z0-9]+$", "^\\d{4}-\\d{2}-\\d{2}$"]),
|
|
186
|
+
flags: Schema.Struct({
|
|
187
|
+
g: Schema.Boolean,
|
|
188
|
+
i: Schema.Boolean,
|
|
189
|
+
m: Schema.Boolean,
|
|
190
|
+
s: Schema.Boolean,
|
|
191
|
+
u: Schema.Boolean,
|
|
192
|
+
y: Schema.Boolean
|
|
193
|
+
})
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
function urlSchema() {
|
|
197
|
+
return Schema.Struct({
|
|
198
|
+
protocol: Schema.Literals(["http", "https"]),
|
|
199
|
+
label: Schema.String.check(Schema.isPattern(/^[a-z0-9]+$/), Schema.isMinLength(1), Schema.isMaxLength(63)),
|
|
200
|
+
suffix: Schema.String.check(Schema.isPattern(/^[a-z]+$/), Schema.isMinLength(2), Schema.isMaxLength(10)),
|
|
201
|
+
path: Schema.Array(Schema.String.check(Schema.isPattern(/^[A-Za-z0-9._~%-]*$/), Schema.isMaxLength(16))).check(Schema.isMaxLength(4))
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
function dateSchema(constraint) {
|
|
205
|
+
const minimum = Math.max(minimumDateTimestamp, constraint?.minimum === undefined ? minimumDateTimestamp : constraint.minimum.getTime() + (constraint.exclusiveMinimum === true ? 1 : 0));
|
|
206
|
+
const maximum = Math.min(maximumDateTimestamp, constraint?.maximum === undefined ? maximumDateTimestamp : constraint.maximum.getTime() - (constraint.exclusiveMaximum === true ? 1 : 0));
|
|
207
|
+
return Schema.Int.check(Schema.isBetween({
|
|
208
|
+
minimum,
|
|
209
|
+
maximum
|
|
210
|
+
}));
|
|
211
|
+
}
|
|
212
|
+
const linkToArbitrary = Schema.linkDecoding;
|
|
213
|
+
function builtInDeclarationLink(ast, typeParameters, constraint) {
|
|
214
|
+
const representation = ast.annotations?.representation;
|
|
215
|
+
if (representation === undefined) return undefined;
|
|
216
|
+
switch (representation.id) {
|
|
217
|
+
case "effect/schema/Json":
|
|
218
|
+
return linkToArbitrary()(jsonSchema(), SchemaGetter.passthrough());
|
|
219
|
+
case "effect/schema/MutableJson":
|
|
220
|
+
return linkToArbitrary()(jsonSchema(), SchemaGetter.passthrough({
|
|
221
|
+
strict: false
|
|
222
|
+
}));
|
|
223
|
+
case "effect/schema/RegExp":
|
|
224
|
+
return linkToArbitrary()(regexpSchema(), SchemaGetter.transform(({
|
|
225
|
+
flags,
|
|
226
|
+
source
|
|
227
|
+
}) => new globalThis.RegExp(source, regexpArbitraryFlags.filter(flag => flags[flag]).join(""))));
|
|
228
|
+
case "effect/schema/URL":
|
|
229
|
+
return linkToArbitrary()(urlSchema(), SchemaGetter.transform(({
|
|
230
|
+
label,
|
|
231
|
+
path,
|
|
232
|
+
protocol,
|
|
233
|
+
suffix
|
|
234
|
+
}) => new globalThis.URL(`${protocol}://${label}.${suffix}/${path.join("/")}`)));
|
|
235
|
+
case "effect/schema/Date":
|
|
236
|
+
return linkToArbitrary()(dateSchema(constraint), SchemaGetter.Date());
|
|
237
|
+
case "effect/schema/ReadonlyMap":
|
|
238
|
+
{
|
|
239
|
+
const [key, value] = typeParameters;
|
|
240
|
+
return linkToArbitrary()(Schema.withArrayLengthConstraints(Schema.Array(Schema.Tuple([key, value])).check(Schema.isUniqueKey()), constraint?.minSize, constraint?.maxSize), SchemaGetter.transform(entries => new globalThis.Map(entries)));
|
|
241
|
+
}
|
|
242
|
+
case "effect/schema/ReadonlySet":
|
|
243
|
+
return linkToArbitrary()(Schema.withArrayLengthConstraints(Schema.Array(typeParameters[0]).check(Schema.isUnique()), constraint?.minSize, constraint?.maxSize), SchemaGetter.transform(values => new globalThis.Set(values)));
|
|
244
|
+
case "effect/schema/Uint8Array":
|
|
245
|
+
return linkToArbitrary()(Schema.withArrayLengthConstraints(Schema.Array(Schema.Int.check(Schema.isBetween({
|
|
246
|
+
minimum: 0,
|
|
247
|
+
maximum: 255
|
|
248
|
+
}))), constraint?.minLength, constraint?.maxLength), SchemaGetter.transform(values => globalThis.Uint8Array.from(values)));
|
|
249
|
+
default:
|
|
250
|
+
return undefined;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
function lengthBounds(constraint, keys, path, label) {
|
|
254
|
+
const minimum = constraint?.[keys[0]] ?? 0;
|
|
255
|
+
const maximum = constraint?.[keys[1]];
|
|
256
|
+
if (!Number.isSafeInteger(minimum) || minimum < 0 || maximum !== undefined && (!Number.isSafeInteger(maximum) || maximum < minimum)) {
|
|
257
|
+
throw arbitraryError(`${label} constraints`, path);
|
|
258
|
+
}
|
|
259
|
+
return [minimum, maximum];
|
|
260
|
+
}
|
|
261
|
+
function constant(value) {
|
|
262
|
+
const sample = Model.makeSample(value);
|
|
263
|
+
return Model.makeCompiled([], () => 0, () => sample);
|
|
264
|
+
}
|
|
265
|
+
function replaceAt(values, index, value) {
|
|
266
|
+
const out = values.slice();
|
|
267
|
+
out[index] = value;
|
|
268
|
+
return out;
|
|
269
|
+
}
|
|
270
|
+
function arraySample(children, shape, shrinks = true) {
|
|
271
|
+
if (!shrinks) return Model.makeSample(children.map(child => child.value));
|
|
272
|
+
const product = Model.productSample(children, children => children.map(child => child.value), children => arraySample(children, shape));
|
|
273
|
+
// Like fast-check v4.9.0's ArrayArbitrary (MIT), structural shrinks are tried before element shrinks.
|
|
274
|
+
// https://github.com/dubzzz/fast-check/blob/v4.9.0/packages/fast-check/src/arbitrary/_internals/ArrayArbitrary.ts
|
|
275
|
+
const structural = [];
|
|
276
|
+
if (shape.repeatCount > 0 && children.length - 1 >= shape.minimum) {
|
|
277
|
+
const index = shape.fixedCount + shape.repeatCount - 1;
|
|
278
|
+
structural.push(() => arraySample(children.slice(0, index).concat(children.slice(index + 1)), {
|
|
279
|
+
...shape,
|
|
280
|
+
repeatCount: shape.repeatCount - 1
|
|
281
|
+
}));
|
|
282
|
+
} else if (shape.optionalCount > 0 && shape.repeatCount === 0 && shape.tailCount === 0 && children.length - 1 >= shape.minimum) {
|
|
283
|
+
structural.push(() => arraySample(children.slice(0, -1), {
|
|
284
|
+
...shape,
|
|
285
|
+
fixedCount: shape.fixedCount - 1,
|
|
286
|
+
optionalCount: shape.optionalCount - 1
|
|
287
|
+
}));
|
|
288
|
+
}
|
|
289
|
+
if (structural.length === 0) return product;
|
|
290
|
+
const structuralPull = Effect.map(Model.pullFromArray(structural), make => make());
|
|
291
|
+
return Model.makeSample(product.value, product.shrinks === undefined ? structuralPull : Model.concatPulls([structuralPull, product.shrinks]));
|
|
292
|
+
}
|
|
293
|
+
function normalizePropertyKeySample(sample) {
|
|
294
|
+
const filtered = Model.filterSample(sample, value => typeof value === "string" || typeof value === "number" || typeof value === "symbol");
|
|
295
|
+
return filtered === undefined ? undefined : Model.mapSample(filtered, value => typeof value === "symbol" ? value : globalThis.String(value));
|
|
296
|
+
}
|
|
297
|
+
function objectSample(entries, minimum, nullPrototype, shrinks = true) {
|
|
298
|
+
const make = entries => {
|
|
299
|
+
const out = Model.makeObject(nullPrototype);
|
|
300
|
+
for (const entry of entries) InternalRecord.assignProperty(out, entry.key, entry.sample.value);
|
|
301
|
+
return out;
|
|
302
|
+
};
|
|
303
|
+
if (!shrinks) return Model.makeSample(make(entries));
|
|
304
|
+
const childPulls = entries.flatMap((entry, index) => entry.sample.shrinks === undefined ? [] : [Effect.map(entry.sample.shrinks, attempt => Model.mapAttempt(attempt, sample => objectSample(replaceAt(entries, index, {
|
|
305
|
+
...entry,
|
|
306
|
+
sample
|
|
307
|
+
}), minimum, nullPrototype)))]);
|
|
308
|
+
// Key shrinking uses the same uniqueness-preserving descendant filtering principle as fast-check v4.9.0's
|
|
309
|
+
// ArrayArbitrary (MIT). Structural removals and value shrinks retain their established precedence.
|
|
310
|
+
// https://github.com/dubzzz/fast-check/blob/v4.9.0/packages/fast-check/src/arbitrary/_internals/ArrayArbitrary.ts
|
|
311
|
+
const keyPulls = entries.flatMap((entry, index) => {
|
|
312
|
+
if (entry.keySample === undefined || entry.keySample.shrinks === undefined) return [];
|
|
313
|
+
const filtered = Model.filterSample(entry.keySample, key => !entries.some((other, otherIndex) => otherIndex !== index && other.key === key));
|
|
314
|
+
if (filtered?.shrinks === undefined) return [];
|
|
315
|
+
return [Effect.map(filtered.shrinks, attempt => Model.mapAttempt(attempt, keySample => objectSample(replaceAt(entries, index, {
|
|
316
|
+
...entry,
|
|
317
|
+
key: keySample.value,
|
|
318
|
+
keySample
|
|
319
|
+
}), minimum, nullPrototype)))];
|
|
320
|
+
});
|
|
321
|
+
const structural = entries.length <= minimum ? [] : entries.flatMap((entry, index) => entry.removable ? [() => objectSample(entries.slice(0, index).concat(entries.slice(index + 1)), minimum, nullPrototype)] : []);
|
|
322
|
+
const descendantPulls = [...childPulls, ...keyPulls];
|
|
323
|
+
const pulls = structural.length === 0 ? descendantPulls : [Effect.map(Model.pullFromArray(structural), make => make()), ...descendantPulls];
|
|
324
|
+
return Model.makeSample(make(entries), pulls.length === 0 ? undefined : Model.concatPulls(pulls));
|
|
325
|
+
}
|
|
326
|
+
const generateSamples = (children, state, additionalReserved = 0) => {
|
|
327
|
+
let reserved = additionalReserved;
|
|
328
|
+
let recursive;
|
|
329
|
+
for (let index = 0; index < children.length; index++) {
|
|
330
|
+
const child = children[index];
|
|
331
|
+
if (reserved !== infinity) reserved += child.minCost;
|
|
332
|
+
if (child.mayRecurse) (recursive ??= []).push(index);
|
|
333
|
+
}
|
|
334
|
+
if (reserved > state.budget.remaining) return undefined;
|
|
335
|
+
let order;
|
|
336
|
+
if (recursive !== undefined && recursive.length > 1) {
|
|
337
|
+
order = children.map((_, index) => index);
|
|
338
|
+
const shuffled = Model.shuffle(state, recursive);
|
|
339
|
+
let next = 0;
|
|
340
|
+
for (let index = 0; index < order.length; index++) {
|
|
341
|
+
if (children[index].mayRecurse) order[index] = shuffled[next++];
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return Model.generateProduct(children, state, order, reserved);
|
|
345
|
+
};
|
|
346
|
+
const generateRequiredObjectValues = (properties, state, nullPrototype) => {
|
|
347
|
+
let reserved = 0;
|
|
348
|
+
let recursive;
|
|
349
|
+
for (let index = 0; index < properties.length; index++) {
|
|
350
|
+
const child = properties[index].compiled;
|
|
351
|
+
if (reserved !== infinity) reserved += child.minCost;
|
|
352
|
+
if (child.mayRecurse) (recursive ??= []).push(index);
|
|
353
|
+
}
|
|
354
|
+
if (reserved > state.budget.remaining) return Model.discarded;
|
|
355
|
+
let order;
|
|
356
|
+
if (recursive !== undefined && recursive.length > 1) {
|
|
357
|
+
order = properties.map((_, index) => index);
|
|
358
|
+
const shuffled = Model.shuffle(state, recursive);
|
|
359
|
+
let next = 0;
|
|
360
|
+
for (let index = 0; index < order.length; index++) {
|
|
361
|
+
if (properties[index].compiled.mayRecurse) order[index] = shuffled[next++];
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
const values = new Array(properties.length);
|
|
365
|
+
let index = 0;
|
|
366
|
+
const loop = () => {
|
|
367
|
+
while (index < properties.length) {
|
|
368
|
+
const childIndex = order?.[index] ?? index;
|
|
369
|
+
index++;
|
|
370
|
+
const child = properties[childIndex];
|
|
371
|
+
reserved -= child.compiled.minCost;
|
|
372
|
+
const generated = Model.generateWithReservedBudget(child.compiled, state, reserved);
|
|
373
|
+
if (Model.isAttempt(generated)) {
|
|
374
|
+
if (generated._tag === "Discarded") return Model.discarded;
|
|
375
|
+
values[childIndex] = generated.value;
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
378
|
+
return Effect.flatMapEager(generated, attempt => {
|
|
379
|
+
if (attempt._tag === "Discarded") return Effect.succeed(Model.discarded);
|
|
380
|
+
values[childIndex] = attempt.value;
|
|
381
|
+
return Model.toEffectGeneration(loop());
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
const out = Model.makeObject(nullPrototype);
|
|
385
|
+
for (let index = 0; index < properties.length; index++) {
|
|
386
|
+
InternalRecord.assignProperty(out, properties[index].property.name, values[index]);
|
|
387
|
+
}
|
|
388
|
+
return Model.makeSample(out);
|
|
389
|
+
};
|
|
390
|
+
return loop();
|
|
391
|
+
};
|
|
392
|
+
const generateRepeatedValues = (child, count, state) => {
|
|
393
|
+
// The packed push loop follows fast-check v4.9.0's ArrayArbitrary generation strategy (MIT).
|
|
394
|
+
// https://github.com/dubzzz/fast-check/blob/v4.9.0/packages/fast-check/src/arbitrary/_internals/ArrayArbitrary.ts
|
|
395
|
+
const out = [];
|
|
396
|
+
let remaining = count;
|
|
397
|
+
let reserved = count * child.minCost;
|
|
398
|
+
const loop = () => {
|
|
399
|
+
while (remaining > 0) {
|
|
400
|
+
reserved -= child.minCost;
|
|
401
|
+
const generated = Model.generateWithReservedBudget(child, state, reserved);
|
|
402
|
+
if (Model.isAttempt(generated)) {
|
|
403
|
+
if (generated._tag === "Discarded") return Model.discarded;
|
|
404
|
+
out.push(generated.value);
|
|
405
|
+
remaining--;
|
|
406
|
+
continue;
|
|
407
|
+
}
|
|
408
|
+
return Effect.flatMapEager(generated, attempt => {
|
|
409
|
+
if (attempt._tag === "Discarded") return Effect.succeed(Model.discarded);
|
|
410
|
+
out.push(attempt.value);
|
|
411
|
+
remaining--;
|
|
412
|
+
return Model.toEffectGeneration(loop());
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
return Model.makeSample(out);
|
|
416
|
+
};
|
|
417
|
+
return loop();
|
|
418
|
+
};
|
|
419
|
+
const generateRepeatedRecursiveValues = (child, count, state) => {
|
|
420
|
+
const out = new Array(count);
|
|
421
|
+
const order = Model.shuffle(state, Array.from({
|
|
422
|
+
length: count
|
|
423
|
+
}, (_, index) => index));
|
|
424
|
+
let index = 0;
|
|
425
|
+
let reserved = count * child.minCost;
|
|
426
|
+
const loop = () => {
|
|
427
|
+
while (index < count) {
|
|
428
|
+
reserved -= child.minCost;
|
|
429
|
+
const generated = Model.generateWithReservedBudget(child, state, reserved);
|
|
430
|
+
if (Model.isAttempt(generated)) {
|
|
431
|
+
if (generated._tag === "Discarded") return Model.discarded;
|
|
432
|
+
out[order[index++]] = generated.value;
|
|
433
|
+
continue;
|
|
434
|
+
}
|
|
435
|
+
return Effect.flatMapEager(generated, attempt => {
|
|
436
|
+
if (attempt._tag === "Discarded") return Effect.succeed(Model.discarded);
|
|
437
|
+
out[order[index++]] = attempt.value;
|
|
438
|
+
return Model.toEffectGeneration(loop());
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
return Model.makeSample(out);
|
|
442
|
+
};
|
|
443
|
+
return loop();
|
|
444
|
+
};
|
|
445
|
+
// Selector-based uniqueness and primitive Set tracking follow fast-check v4.9.0's uniqueArray and SameValueSet
|
|
446
|
+
// strategies (MIT). Hash buckets extend them with Effect's equality semantics for objects.
|
|
447
|
+
// https://github.com/dubzzz/fast-check/blob/v4.9.0/packages/fast-check/src/arbitrary/uniqueArray.ts
|
|
448
|
+
// https://github.com/dubzzz/fast-check/blob/v4.9.0/packages/fast-check/src/arbitrary/_internals/helpers/SameValueSet.ts
|
|
449
|
+
const makeUniqueAdder = () => {
|
|
450
|
+
let primitives;
|
|
451
|
+
let buckets;
|
|
452
|
+
return value => {
|
|
453
|
+
if (value === null || typeof value !== "object" && typeof value !== "function") {
|
|
454
|
+
const set = primitives ??= new Set();
|
|
455
|
+
const size = set.size;
|
|
456
|
+
set.add(value);
|
|
457
|
+
return set.size !== size;
|
|
458
|
+
}
|
|
459
|
+
const hash = Hash.hash(value);
|
|
460
|
+
const map = buckets ??= new Map();
|
|
461
|
+
const bucket = map.get(hash);
|
|
462
|
+
if (bucket !== undefined) {
|
|
463
|
+
for (let index = 0; index < bucket.length; index++) {
|
|
464
|
+
if (Equal.equals(bucket[index], value)) return false;
|
|
465
|
+
}
|
|
466
|
+
bucket.push(value);
|
|
467
|
+
} else {
|
|
468
|
+
map.set(hash, [value]);
|
|
469
|
+
}
|
|
470
|
+
return true;
|
|
471
|
+
};
|
|
472
|
+
};
|
|
473
|
+
const makeUniqueAdderBy = uniqueBy => {
|
|
474
|
+
const add = makeUniqueAdder();
|
|
475
|
+
return uniqueBy === identity ? add : input => add(uniqueBy(input));
|
|
476
|
+
};
|
|
477
|
+
const generateRepeatedUniqueValues = (child, count, state, uniqueBy) => {
|
|
478
|
+
const out = [];
|
|
479
|
+
const addUnique = makeUniqueAdderBy(uniqueBy);
|
|
480
|
+
let remaining = count;
|
|
481
|
+
let reserved = count * child.minCost;
|
|
482
|
+
let retries = 0;
|
|
483
|
+
let budget = state.budget.remaining;
|
|
484
|
+
const loop = () => {
|
|
485
|
+
while (remaining > 0) {
|
|
486
|
+
if (retries === 0) {
|
|
487
|
+
reserved -= child.minCost;
|
|
488
|
+
budget = state.budget.remaining;
|
|
489
|
+
}
|
|
490
|
+
const generated = Model.generateWithReservedBudget(child, state, reserved);
|
|
491
|
+
if (Model.isAttempt(generated)) {
|
|
492
|
+
if (generated._tag === "Discarded") return Model.discarded;
|
|
493
|
+
if (!addUnique(generated.value)) {
|
|
494
|
+
if (++retries >= count) return Model.discarded;
|
|
495
|
+
state.budget.remaining = budget;
|
|
496
|
+
continue;
|
|
497
|
+
}
|
|
498
|
+
out.push(generated.value);
|
|
499
|
+
remaining--;
|
|
500
|
+
retries = 0;
|
|
501
|
+
continue;
|
|
502
|
+
}
|
|
503
|
+
return Effect.flatMapEager(generated, attempt => {
|
|
504
|
+
if (attempt._tag === "Discarded") return Effect.succeed(Model.discarded);
|
|
505
|
+
if (!addUnique(attempt.value)) {
|
|
506
|
+
if (++retries >= count) return Effect.succeed(Model.discarded);
|
|
507
|
+
state.budget.remaining = budget;
|
|
508
|
+
} else {
|
|
509
|
+
out.push(attempt.value);
|
|
510
|
+
remaining--;
|
|
511
|
+
retries = 0;
|
|
512
|
+
}
|
|
513
|
+
return Model.toEffectGeneration(loop());
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
return Model.makeSample(out);
|
|
517
|
+
};
|
|
518
|
+
return loop();
|
|
519
|
+
};
|
|
520
|
+
function shrinkString(value, minimum) {
|
|
521
|
+
const values = value.length <= minimum ? [] : [value.slice(0, minimum), value.slice(0, Math.max(minimum, Math.floor(value.length / 2))), value.slice(0, -1)];
|
|
522
|
+
// fast-check v4.9.0 builds strings from shrinkable units (MIT). Effect keeps UTF-16 code units as its string domain
|
|
523
|
+
// and applies its integer-halving shrink toward the Effect-owned null-unit target.
|
|
524
|
+
// https://github.com/dubzzz/fast-check/blob/v4.9.0/packages/fast-check/src/arbitrary/string.ts
|
|
525
|
+
for (let index = 0; index < value.length; index++) {
|
|
526
|
+
for (const candidate of shrinkInteger(value.charCodeAt(index), 0, true)) {
|
|
527
|
+
values.push(value.slice(0, index) + globalThis.String.fromCharCode(candidate.value) + value.slice(index + 1));
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
return [...new Set(values)].filter(candidate => candidate !== value);
|
|
531
|
+
}
|
|
532
|
+
// Edge-case injection is inspired by fast-check v4.9.0's cached dangerous slices (MIT). The concrete corpus is
|
|
533
|
+
// Effect-owned and also covers control, numeric-property, and UTF-16 boundaries.
|
|
534
|
+
// https://github.com/dubzzz/fast-check/blob/v4.9.0/packages/fast-check/src/arbitrary/_internals/helpers/SlicesForStringBuilder.ts
|
|
535
|
+
const stringEdgeCases = ["", " ", "\t", "\n", "\0", "0", "-1", "4294967295", "__proto__", "constructor", "prototype", "toString", "\uD800", "\uDC00", "😀"];
|
|
536
|
+
function randomString(state, minimum, maximum) {
|
|
537
|
+
if (Model.randomInt(state, 1, state.biasFactor) === 1) {
|
|
538
|
+
let eligible = 0;
|
|
539
|
+
for (const value of stringEdgeCases) {
|
|
540
|
+
if (value.length >= minimum && value.length <= maximum) eligible++;
|
|
541
|
+
}
|
|
542
|
+
if (eligible > 0) {
|
|
543
|
+
let target = Model.randomIndex(state, eligible);
|
|
544
|
+
for (const value of stringEdgeCases) {
|
|
545
|
+
if (value.length < minimum || value.length > maximum) continue;
|
|
546
|
+
if (target-- === 0) return value;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
const length = Model.randomLength(state, minimum, maximum);
|
|
551
|
+
let value = "";
|
|
552
|
+
for (let index = 0; index < length; index++) {
|
|
553
|
+
value += globalThis.String.fromCharCode(Model.randomInt(state, 32, 126));
|
|
554
|
+
}
|
|
555
|
+
return value;
|
|
556
|
+
}
|
|
557
|
+
function numberBounds(constraint, integer, path) {
|
|
558
|
+
const ordered = constraint?.order === Order.Number ? constraint : undefined;
|
|
559
|
+
let minimum = ordered?.minimum;
|
|
560
|
+
let maximum = ordered?.maximum;
|
|
561
|
+
if (minimum !== undefined && Number.isNaN(minimum) || maximum !== undefined && Number.isNaN(maximum)) {
|
|
562
|
+
throw arbitraryError(integer ? "integer constraints" : "number constraints", path);
|
|
563
|
+
}
|
|
564
|
+
if (integer) {
|
|
565
|
+
if (minimum !== undefined) {
|
|
566
|
+
minimum = ordered?.exclusiveMinimum === true ? Math.floor(minimum) + 1 : Math.ceil(minimum);
|
|
567
|
+
}
|
|
568
|
+
if (maximum !== undefined) {
|
|
569
|
+
maximum = ordered?.exclusiveMaximum === true ? Math.ceil(maximum) - 1 : Math.floor(maximum);
|
|
570
|
+
}
|
|
571
|
+
} else {
|
|
572
|
+
if (minimum !== undefined && ordered?.exclusiveMinimum === true && minimum === Infinity) {
|
|
573
|
+
throw arbitraryError("number constraints", path);
|
|
574
|
+
}
|
|
575
|
+
if (maximum !== undefined && ordered?.exclusiveMaximum === true && maximum === -Infinity) {
|
|
576
|
+
throw arbitraryError("number constraints", path);
|
|
577
|
+
}
|
|
578
|
+
if (minimum !== undefined) {
|
|
579
|
+
minimum = ordered?.exclusiveMinimum === true ? Model.nextNumber(minimum) : minimum === 0 ? -0 : minimum;
|
|
580
|
+
}
|
|
581
|
+
if (maximum !== undefined) {
|
|
582
|
+
maximum = ordered?.exclusiveMaximum === true ? Model.previousNumber(maximum) : maximum === 0 ? 0 : maximum;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
if (integer || constraint?.number === "finite") {
|
|
586
|
+
if (minimum === Infinity || maximum === -Infinity) {
|
|
587
|
+
throw arbitraryError(integer ? "integer constraints" : "number constraints", path);
|
|
588
|
+
}
|
|
589
|
+
if (minimum === -Infinity) minimum = integer ? Number.MIN_SAFE_INTEGER : -Number.MAX_VALUE;
|
|
590
|
+
if (maximum === Infinity) maximum = integer ? Number.MAX_SAFE_INTEGER : Number.MAX_VALUE;
|
|
591
|
+
}
|
|
592
|
+
if (integer) {
|
|
593
|
+
if (minimum !== undefined && minimum > Number.MAX_SAFE_INTEGER || maximum !== undefined && maximum < Number.MIN_SAFE_INTEGER) {
|
|
594
|
+
throw arbitraryError("integer constraints", path);
|
|
595
|
+
}
|
|
596
|
+
if (minimum !== undefined) minimum = Math.max(minimum, Number.MIN_SAFE_INTEGER);
|
|
597
|
+
if (maximum !== undefined) maximum = Math.min(maximum, Number.MAX_SAFE_INTEGER);
|
|
598
|
+
}
|
|
599
|
+
if (minimum !== undefined && maximum !== undefined && (integer ? minimum > maximum : Model.numberToIndex(minimum) > Model.numberToIndex(maximum))) {
|
|
600
|
+
throw arbitraryError(integer ? "integer constraints" : "number constraints", path);
|
|
601
|
+
}
|
|
602
|
+
return {
|
|
603
|
+
minimum,
|
|
604
|
+
maximum
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
function shrinkInteger(current, target, tryTargetAsap) {
|
|
608
|
+
const out = [];
|
|
609
|
+
const realGap = current - target;
|
|
610
|
+
let previous = tryTargetAsap ? undefined : target;
|
|
611
|
+
for (let toRemove = tryTargetAsap ? realGap : Math.trunc(realGap / 2); toRemove !== 0; toRemove = Math.trunc(toRemove / 2)) {
|
|
612
|
+
const value = toRemove === realGap ? target : current - toRemove;
|
|
613
|
+
out.push({
|
|
614
|
+
value,
|
|
615
|
+
context: previous
|
|
616
|
+
});
|
|
617
|
+
previous = value;
|
|
618
|
+
}
|
|
619
|
+
return out;
|
|
620
|
+
}
|
|
621
|
+
function shrinkNumber(current, target, tryTargetAsap) {
|
|
622
|
+
if (Number.isNaN(current)) return [{
|
|
623
|
+
value: target,
|
|
624
|
+
context: undefined
|
|
625
|
+
}];
|
|
626
|
+
const currentIndex = Model.numberToIndex(current);
|
|
627
|
+
const targetIndex = Model.numberToIndex(target);
|
|
628
|
+
const realGap = currentIndex - targetIndex;
|
|
629
|
+
let previous = tryTargetAsap ? undefined : target;
|
|
630
|
+
const out = [];
|
|
631
|
+
for (let toRemove = tryTargetAsap ? realGap : realGap / BigInt(2); toRemove !== BigInt(0); toRemove /= BigInt(2)) {
|
|
632
|
+
const value = toRemove === realGap ? target : Model.indexToNumber(currentIndex - toRemove);
|
|
633
|
+
out.push({
|
|
634
|
+
value,
|
|
635
|
+
context: previous
|
|
636
|
+
});
|
|
637
|
+
previous = value;
|
|
638
|
+
}
|
|
639
|
+
return out;
|
|
640
|
+
}
|
|
641
|
+
function numberTarget(minimum, maximum) {
|
|
642
|
+
if (minimum !== undefined && minimum > 0) return minimum;
|
|
643
|
+
if (maximum !== undefined && maximum < 0) return maximum;
|
|
644
|
+
return 0;
|
|
645
|
+
}
|
|
646
|
+
function numberSample(value, minimum, maximum, integer, context) {
|
|
647
|
+
if (!integer) {
|
|
648
|
+
// fast-check v4.9.0's double arbitrary shrinks the monotone IEEE-754 index through its BigInt arbitrary (MIT).
|
|
649
|
+
// The sample keeps the equivalent last-passing index context without exposing either representation.
|
|
650
|
+
// https://github.com/dubzzz/fast-check/blob/v4.9.0/packages/fast-check/src/arbitrary/double.ts
|
|
651
|
+
let candidates;
|
|
652
|
+
const target = numberTarget(minimum, maximum);
|
|
653
|
+
if (context === undefined) {
|
|
654
|
+
candidates = shrinkNumber(value, target, true);
|
|
655
|
+
} else if (!Number.isNaN(value) && (Model.numberToIndex(value) === Model.numberToIndex(context) + BigInt(1) || Model.numberToIndex(value) === Model.numberToIndex(context) - BigInt(1))) {
|
|
656
|
+
candidates = [{
|
|
657
|
+
value: context,
|
|
658
|
+
context: undefined
|
|
659
|
+
}];
|
|
660
|
+
} else {
|
|
661
|
+
candidates = shrinkNumber(value, context, false);
|
|
662
|
+
}
|
|
663
|
+
return Model.makeSample(value, candidates.length === 0 ? undefined : Effect.map(Model.pullFromArray(candidates), candidate => numberSample(candidate.value, minimum, maximum, false, candidate.context)));
|
|
664
|
+
}
|
|
665
|
+
// The passing-value context and halving sequence are adapted from fast-check v4.9.0's IntegerArbitrary and
|
|
666
|
+
// ShrinkInteger (MIT). Retaining the closest passing candidate lets the runner converge on a local failure boundary.
|
|
667
|
+
// https://github.com/dubzzz/fast-check/blob/v4.9.0/packages/fast-check/src/arbitrary/_internals/IntegerArbitrary.ts
|
|
668
|
+
// https://github.com/dubzzz/fast-check/blob/v4.9.0/packages/fast-check/src/arbitrary/_internals/helpers/ShrinkInteger.ts
|
|
669
|
+
let candidates;
|
|
670
|
+
if (context === undefined) {
|
|
671
|
+
const target = Math.min(maximum ?? 0, Math.max(minimum ?? 0, 0));
|
|
672
|
+
candidates = shrinkInteger(value, target, true);
|
|
673
|
+
} else if (value > 0 && value === context + 1 && (minimum === undefined || value > minimum) || value < 0 && value === context - 1 && (maximum === undefined || value < maximum)) {
|
|
674
|
+
candidates = [{
|
|
675
|
+
value: context,
|
|
676
|
+
context: undefined
|
|
677
|
+
}];
|
|
678
|
+
} else {
|
|
679
|
+
candidates = shrinkInteger(value, context, false);
|
|
680
|
+
}
|
|
681
|
+
return Model.makeSample(value, candidates.length === 0 ? undefined : Effect.map(Model.pullFromArray(candidates), candidate => numberSample(candidate.value, minimum, maximum, true, candidate.context)));
|
|
682
|
+
}
|
|
683
|
+
function shrinkBigInt(current, target, tryTargetAsap) {
|
|
684
|
+
const out = [];
|
|
685
|
+
const realGap = current - target;
|
|
686
|
+
let previous = tryTargetAsap ? undefined : target;
|
|
687
|
+
for (let toRemove = tryTargetAsap ? realGap : realGap / BigInt(2); toRemove !== BigInt(0); toRemove /= BigInt(2)) {
|
|
688
|
+
const value = current - toRemove;
|
|
689
|
+
out.push({
|
|
690
|
+
value,
|
|
691
|
+
context: previous
|
|
692
|
+
});
|
|
693
|
+
previous = value;
|
|
694
|
+
}
|
|
695
|
+
return out;
|
|
696
|
+
}
|
|
697
|
+
function bigIntSample(value, minimum, maximum, context) {
|
|
698
|
+
// The passing-value context and gap-halving sequence are adapted from fast-check v4.9.0's BigIntArbitrary and
|
|
699
|
+
// ShrinkBigInt (MIT). Retaining the closest passing candidate lets the runner converge on a local failure boundary.
|
|
700
|
+
// https://github.com/dubzzz/fast-check/blob/v4.9.0/packages/fast-check/src/arbitrary/_internals/BigIntArbitrary.ts
|
|
701
|
+
// https://github.com/dubzzz/fast-check/blob/v4.9.0/packages/fast-check/src/arbitrary/_internals/helpers/ShrinkBigInt.ts
|
|
702
|
+
let candidates;
|
|
703
|
+
if (context === undefined) {
|
|
704
|
+
const target = minimum !== undefined && minimum > BigInt(0) ? minimum : maximum !== undefined && maximum < BigInt(0) ? maximum : BigInt(0);
|
|
705
|
+
candidates = shrinkBigInt(value, target, true);
|
|
706
|
+
} else if (value > BigInt(0) && value === context + BigInt(1) && (minimum === undefined || value > minimum) || value < BigInt(0) && value === context - BigInt(1) && (maximum === undefined || value < maximum)) {
|
|
707
|
+
candidates = [{
|
|
708
|
+
value: context,
|
|
709
|
+
context: undefined
|
|
710
|
+
}];
|
|
711
|
+
} else {
|
|
712
|
+
candidates = shrinkBigInt(value, context, false);
|
|
713
|
+
}
|
|
714
|
+
return Model.makeSample(value, candidates.length === 0 ? undefined : Effect.map(Model.pullFromArray(candidates), candidate => bigIntSample(candidate.value, minimum, maximum, candidate.context)));
|
|
715
|
+
}
|
|
716
|
+
/** @internal */
|
|
717
|
+
export function compile(schema) {
|
|
718
|
+
const rootAst = SchemaAST.toType(schema.ast);
|
|
719
|
+
const cache = new WeakMap();
|
|
720
|
+
const nodes = [];
|
|
721
|
+
const suspendBodies = new Map();
|
|
722
|
+
const pending = [];
|
|
723
|
+
const recur = (ast, path, inherited) => {
|
|
724
|
+
let entries = cache.get(ast);
|
|
725
|
+
const cached = entries?.get(inherited);
|
|
726
|
+
if (cached !== undefined) return cached;
|
|
727
|
+
if (entries === undefined) {
|
|
728
|
+
entries = new Map();
|
|
729
|
+
cache.set(ast, entries);
|
|
730
|
+
}
|
|
731
|
+
const placeholder = Model.makeCompiled([], () => infinity, () => Model.discarded);
|
|
732
|
+
entries.set(inherited, placeholder);
|
|
733
|
+
nodes.push(placeholder);
|
|
734
|
+
pending.push(() => {
|
|
735
|
+
const checks = collectChecks(ast.checks, inherited);
|
|
736
|
+
const baseAst = ast.checks === undefined ? ast : SchemaAST.replaceChecks(ast, undefined);
|
|
737
|
+
const base = compileBase(baseAst, path, checks.constraint);
|
|
738
|
+
if (baseAst._tag === "Suspend") {
|
|
739
|
+
const body = base.dependencies[0];
|
|
740
|
+
placeholder.dependencies = [body];
|
|
741
|
+
placeholder.computeMinCost = () => {
|
|
742
|
+
if (body.minCost === infinity) return infinity;
|
|
743
|
+
return body.minCost + (placeholder.recursive ? 1 : 0);
|
|
744
|
+
};
|
|
745
|
+
placeholder.generate = state => Effect.suspend(() => {
|
|
746
|
+
if (placeholder.recursive) {
|
|
747
|
+
if (state.budget.remaining <= 0) return Effect.succeed(Model.discarded);
|
|
748
|
+
state.budget.remaining--;
|
|
749
|
+
}
|
|
750
|
+
return Model.toEffectGeneration(body.generate(state));
|
|
751
|
+
});
|
|
752
|
+
suspendBodies.set(placeholder, body);
|
|
753
|
+
} else {
|
|
754
|
+
placeholder.dependencies = base.dependencies;
|
|
755
|
+
placeholder.computeMinCost = base.computeMinCost;
|
|
756
|
+
placeholder.generate = base.generate;
|
|
757
|
+
}
|
|
758
|
+
applyFilters(placeholder, ast, checks.filters);
|
|
759
|
+
});
|
|
760
|
+
return placeholder;
|
|
761
|
+
};
|
|
762
|
+
const compileBase = (ast, path, constraint) => {
|
|
763
|
+
switch (ast._tag) {
|
|
764
|
+
case "Never":
|
|
765
|
+
throw arbitraryError("Never", path);
|
|
766
|
+
case "Null":
|
|
767
|
+
return constant(null);
|
|
768
|
+
case "Undefined":
|
|
769
|
+
case "Void":
|
|
770
|
+
return constant(undefined);
|
|
771
|
+
case "Literal":
|
|
772
|
+
return constant(ast.literal);
|
|
773
|
+
case "UniqueSymbol":
|
|
774
|
+
return constant(ast.symbol);
|
|
775
|
+
case "Boolean":
|
|
776
|
+
return Model.makeCompiled([], () => 0, state => {
|
|
777
|
+
const value = Model.randomBoolean(state);
|
|
778
|
+
return Model.makeSample(value, state.shrinks && value ? Model.pullFromArray([Model.makeSample(false)]) : undefined);
|
|
779
|
+
});
|
|
780
|
+
case "String":
|
|
781
|
+
{
|
|
782
|
+
const patterns = [];
|
|
783
|
+
for (const candidate of constraint?.patterns ?? []) {
|
|
784
|
+
const pattern = Regexp.compile(candidate);
|
|
785
|
+
if (pattern !== undefined) patterns.push(pattern);
|
|
786
|
+
}
|
|
787
|
+
const [minimum, maximum] = lengthBounds(constraint, ["minLength", "maxLength"], path, "string");
|
|
788
|
+
return Model.makeCompiled([], () => 0, state => {
|
|
789
|
+
const pattern = patterns.length === 0 ? undefined : patterns.length === 1 ? patterns[0] : patterns[Model.randomIndex(state, patterns.length)];
|
|
790
|
+
const currentMaximum = Math.max(minimum, pattern?.minimumLength ?? 0, state.size);
|
|
791
|
+
const upper = maximum === undefined ? currentMaximum : Math.min(maximum, currentMaximum);
|
|
792
|
+
let value;
|
|
793
|
+
if (pattern === undefined) {
|
|
794
|
+
value = randomString(state, minimum, upper);
|
|
795
|
+
} else {
|
|
796
|
+
value = pattern.generate(state, minimum, upper);
|
|
797
|
+
}
|
|
798
|
+
if (value === undefined) return Model.discarded;
|
|
799
|
+
return state.shrinks ? Model.sampleFromShrink(value, pattern === undefined ? value => shrinkString(value, minimum) : value => pattern.shrink(value, minimum)) : Model.makeSample(value);
|
|
800
|
+
});
|
|
801
|
+
}
|
|
802
|
+
case "Number":
|
|
803
|
+
{
|
|
804
|
+
const integer = constraint?.number === "integer";
|
|
805
|
+
const bounds = numberBounds(constraint, integer, path);
|
|
806
|
+
const numberMinimum = bounds.minimum ?? (constraint?.number !== undefined ? -Number.MAX_VALUE : Number.NEGATIVE_INFINITY);
|
|
807
|
+
const numberMaximum = bounds.maximum ?? (constraint?.number !== undefined ? Number.MAX_VALUE : Number.POSITIVE_INFINITY);
|
|
808
|
+
const randomNumber = integer ? undefined : Model.makeRandomNumber(numberMinimum, numberMaximum, constraint?.number === undefined && bounds.minimum === undefined);
|
|
809
|
+
let integerMinimum;
|
|
810
|
+
let integerMaximum;
|
|
811
|
+
let randomInteger;
|
|
812
|
+
return Model.makeCompiled([], () => 0, state => {
|
|
813
|
+
let minimum = numberMinimum;
|
|
814
|
+
let maximum = numberMaximum;
|
|
815
|
+
if (integer) {
|
|
816
|
+
const magnitude = Math.max(1, state.size * state.size);
|
|
817
|
+
const center = bounds.minimum !== undefined && bounds.minimum > 0 ? bounds.minimum : bounds.maximum !== undefined && bounds.maximum < 0 ? bounds.maximum : 0;
|
|
818
|
+
minimum = bounds.minimum ?? center - magnitude;
|
|
819
|
+
maximum = bounds.maximum ?? center + magnitude;
|
|
820
|
+
if (randomInteger === undefined || minimum !== integerMinimum || maximum !== integerMaximum) {
|
|
821
|
+
integerMinimum = minimum;
|
|
822
|
+
integerMaximum = maximum;
|
|
823
|
+
randomInteger = Model.makeRandomNumericInt(minimum, maximum);
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
const value = integer ? randomInteger(state) : randomNumber(state);
|
|
827
|
+
return state.shrinks ? numberSample(value, bounds.minimum, bounds.maximum, integer) : Model.makeSample(value);
|
|
828
|
+
});
|
|
829
|
+
}
|
|
830
|
+
case "BigInt":
|
|
831
|
+
{
|
|
832
|
+
const ordered = constraint?.order === Order.BigInt ? constraint : undefined;
|
|
833
|
+
let minimum = ordered?.minimum;
|
|
834
|
+
let maximum = ordered?.maximum;
|
|
835
|
+
if (minimum !== undefined && ordered?.exclusiveMinimum === true) minimum++;
|
|
836
|
+
if (maximum !== undefined && ordered?.exclusiveMaximum === true) maximum--;
|
|
837
|
+
if (minimum !== undefined && maximum !== undefined && minimum > maximum) {
|
|
838
|
+
throw arbitraryError("bigint constraints", path);
|
|
839
|
+
}
|
|
840
|
+
let previousLow;
|
|
841
|
+
let previousHigh;
|
|
842
|
+
let randomBigInt;
|
|
843
|
+
return Model.makeCompiled([], () => 0, state => {
|
|
844
|
+
const magnitude = BigInt(Math.max(1, state.size * state.size));
|
|
845
|
+
const center = minimum !== undefined && minimum > BigInt(0) ? minimum : maximum !== undefined && maximum < BigInt(0) ? maximum : BigInt(0);
|
|
846
|
+
const low = minimum ?? center - magnitude;
|
|
847
|
+
const high = maximum ?? center + magnitude;
|
|
848
|
+
if (randomBigInt === undefined || low !== previousLow || high !== previousHigh) {
|
|
849
|
+
previousLow = low;
|
|
850
|
+
previousHigh = high;
|
|
851
|
+
randomBigInt = Model.makeRandomNumericBigInt(low, high);
|
|
852
|
+
}
|
|
853
|
+
const value = randomBigInt(state);
|
|
854
|
+
return state.shrinks ? bigIntSample(value, minimum, maximum) : Model.makeSample(value);
|
|
855
|
+
});
|
|
856
|
+
}
|
|
857
|
+
case "Symbol":
|
|
858
|
+
{
|
|
859
|
+
const strings = recur(SchemaAST.string, path, constraint);
|
|
860
|
+
return Model.makeCompiled([strings], () => strings.minCost, state => Model.mapGeneration(strings.generate(state), attempt => attempt._tag === "Discarded" ? attempt : Model.mapSample(attempt, value => Symbol.for(value))));
|
|
861
|
+
}
|
|
862
|
+
case "Unknown":
|
|
863
|
+
case "Any":
|
|
864
|
+
{
|
|
865
|
+
const json = recur(Schema.Json.ast, path);
|
|
866
|
+
return Model.makeCompiled([json], () => json.minCost, state => json.generate(state));
|
|
867
|
+
}
|
|
868
|
+
case "ObjectKeyword":
|
|
869
|
+
{
|
|
870
|
+
const json = recur(Schema.Json.ast, path);
|
|
871
|
+
return Model.makeCompiled([json], () => 0, state => Model.mapGeneration(json.generate(state), attempt => {
|
|
872
|
+
if (attempt._tag === "Generated" && typeof attempt.value === "object" && attempt.value !== null) {
|
|
873
|
+
return attempt;
|
|
874
|
+
}
|
|
875
|
+
return Model.makeSample({});
|
|
876
|
+
}));
|
|
877
|
+
}
|
|
878
|
+
case "Enum":
|
|
879
|
+
{
|
|
880
|
+
const values = [...new Set(ast.enums.map(([, value]) => value))];
|
|
881
|
+
if (values.length === 0) throw arbitraryError("an enum with no members", path);
|
|
882
|
+
return Model.makeCompiled([], () => 0, state => Model.makeSample(values[Model.randomIndex(state, values.length)]));
|
|
883
|
+
}
|
|
884
|
+
case "TemplateLiteral":
|
|
885
|
+
{
|
|
886
|
+
const parts = ast.parts.map((part, index) => recur(part, [...path, index], finiteNumberConstraint));
|
|
887
|
+
return Model.makeCompiled(parts, () => sumCosts(parts.map(part => part.minCost)), state => Model.mapComputation(generateSamples(parts, state), generated => {
|
|
888
|
+
if (generated === undefined) return Model.discarded;
|
|
889
|
+
const sample = arraySample(generated, {
|
|
890
|
+
fixedCount: generated.length,
|
|
891
|
+
optionalCount: 0,
|
|
892
|
+
repeatCount: 0,
|
|
893
|
+
tailCount: 0,
|
|
894
|
+
minimum: generated.length
|
|
895
|
+
}, state.shrinks);
|
|
896
|
+
return Model.mapSample(sample, parts => parts.map(globalThis.String).join(""));
|
|
897
|
+
}));
|
|
898
|
+
}
|
|
899
|
+
case "Union":
|
|
900
|
+
{
|
|
901
|
+
const members = ast.types.map(member => recur(member, path, constraint));
|
|
902
|
+
if (members.length === 0) throw arbitraryError("a union with no members", path);
|
|
903
|
+
let generate = state => Model.generateUnion(members, state);
|
|
904
|
+
if (ast.options?.mode === "oneOf") {
|
|
905
|
+
const parse = SchemaParser.run(ast);
|
|
906
|
+
const validate = value => optionComputation(parse(value));
|
|
907
|
+
generate = state => Model.filterMapGeneration(Model.generateUnion(members, state), validate);
|
|
908
|
+
}
|
|
909
|
+
return Model.makeCompiled(members, () => Math.min(...members.map(member => member.minCost)), generate);
|
|
910
|
+
}
|
|
911
|
+
case "Arrays":
|
|
912
|
+
return compileArrays(ast, path, constraint);
|
|
913
|
+
case "Objects":
|
|
914
|
+
{
|
|
915
|
+
const compiled = compileObjects(ast, path, constraint);
|
|
916
|
+
if (ast.indexSignatures.length === 0 || ast.indexSignatures.length === 1 && ast.propertySignatures.length === 0) return compiled;
|
|
917
|
+
const parse = SchemaParser.run(new SchemaAST.Objects([], ast.indexSignatures));
|
|
918
|
+
const generate = compiled.generate;
|
|
919
|
+
compiled.generate = state => Model.filterMapGeneration(generate(state), value => Model.mapComputation(optionComputation(parse(value)), parsed => Option.isNone(parsed) ? parsed : Option.some(value)));
|
|
920
|
+
return compiled;
|
|
921
|
+
}
|
|
922
|
+
case "Suspend":
|
|
923
|
+
{
|
|
924
|
+
const body = recur(ast.thunk(), path);
|
|
925
|
+
return Model.makeCompiled([body], () => body.minCost, state => body.generate(state));
|
|
926
|
+
}
|
|
927
|
+
case "Declaration":
|
|
928
|
+
return compileDeclaration(ast, path, constraint);
|
|
929
|
+
}
|
|
930
|
+
};
|
|
931
|
+
const compileArrays = (ast, path, constraint) => {
|
|
932
|
+
const uniqueBy = constraint?.uniqueBy;
|
|
933
|
+
const elements = ast.elements.map((element, index) => ({
|
|
934
|
+
optional: SchemaAST.isOptional(element),
|
|
935
|
+
compiled: recur(element, [...path, index])
|
|
936
|
+
}));
|
|
937
|
+
const requiredCount = elements.findIndex(element => element.optional);
|
|
938
|
+
const required = requiredCount === -1 ? elements.length : requiredCount;
|
|
939
|
+
const optional = elements.length - required;
|
|
940
|
+
const rest = ast.rest.map((element, index) => recur(element, [...path, elements.length + index]));
|
|
941
|
+
const head = rest[0];
|
|
942
|
+
const tail = rest.slice(1);
|
|
943
|
+
const [minimum, maximum] = lengthBounds(constraint, ["minLength", "maxLength"], path, "array");
|
|
944
|
+
if (maximum !== undefined && maximum < required + tail.length || head === undefined && minimum > elements.length + tail.length) {
|
|
945
|
+
throw arbitraryError("array constraints", path);
|
|
946
|
+
}
|
|
947
|
+
const dependencies = [...elements.map(element => element.compiled), ...rest];
|
|
948
|
+
const combinations = limit => {
|
|
949
|
+
const out = [];
|
|
950
|
+
const requiredCost = sumCosts(elements.slice(0, required).map(element => element.compiled.minCost));
|
|
951
|
+
const tailCost = sumCosts(tail.map(element => element.minCost));
|
|
952
|
+
const currentMaximum = Math.max(minimum, required + tail.length, limit);
|
|
953
|
+
const upper = maximum === undefined ? currentMaximum : Math.min(maximum, currentMaximum);
|
|
954
|
+
for (let optionalCount = 0; optionalCount <= optional; optionalCount++) {
|
|
955
|
+
const fixed = required + optionalCount + tail.length;
|
|
956
|
+
const minimumRepeat = Math.max(0, minimum - fixed);
|
|
957
|
+
const maximumRepeat = head === undefined ? 0 : Math.max(minimumRepeat, upper - fixed);
|
|
958
|
+
if (fixed + minimumRepeat > upper || head === undefined && minimumRepeat > 0) continue;
|
|
959
|
+
const optionalCost = sumCosts(elements.slice(required, required + optionalCount).map(element => element.compiled.minCost));
|
|
960
|
+
for (let repeat = minimumRepeat; repeat <= maximumRepeat; repeat++) {
|
|
961
|
+
if ((repeat > 0 || tail.length > 0) && optionalCount < optional) continue;
|
|
962
|
+
const repeatCost = repeat === 0 ? 0 : repeat * (head?.minCost ?? 0);
|
|
963
|
+
const cost = requiredCost + optionalCost + tailCost + repeatCost;
|
|
964
|
+
out.push([optionalCount, repeat, cost]);
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
return out;
|
|
968
|
+
};
|
|
969
|
+
let cachedLimit;
|
|
970
|
+
let cachedBudget;
|
|
971
|
+
let cachedCombinations = [];
|
|
972
|
+
let cachedPossible = [];
|
|
973
|
+
const possibleCombinations = (limit, budget) => {
|
|
974
|
+
if (limit !== cachedLimit) {
|
|
975
|
+
cachedLimit = limit;
|
|
976
|
+
cachedBudget = undefined;
|
|
977
|
+
cachedCombinations = combinations(limit);
|
|
978
|
+
}
|
|
979
|
+
if (budget !== cachedBudget) {
|
|
980
|
+
cachedBudget = budget;
|
|
981
|
+
cachedPossible = cachedCombinations.filter(([,, cost]) => cost <= budget);
|
|
982
|
+
}
|
|
983
|
+
return cachedPossible;
|
|
984
|
+
};
|
|
985
|
+
return Model.makeCompiled(dependencies, () => {
|
|
986
|
+
const possible = combinations(0);
|
|
987
|
+
return possible.length === 0 ? infinity : Math.min(...possible.map(([,, cost]) => cost));
|
|
988
|
+
}, state => {
|
|
989
|
+
const possible = possibleCombinations(state.size, state.budget.remaining);
|
|
990
|
+
if (possible.length === 0) return Model.discarded;
|
|
991
|
+
const [optionalCount, repeatCount] = possible[Model.randomLength(state, 0, possible.length - 1)];
|
|
992
|
+
// Explicit collection minima must stay productive while progressive checks are still at size zero.
|
|
993
|
+
const itemState = state.size >= repeatCount ? state : {
|
|
994
|
+
...state,
|
|
995
|
+
size: repeatCount
|
|
996
|
+
};
|
|
997
|
+
// Lower homogeneous arrays directly when no shrink context is needed.
|
|
998
|
+
if (!state.shrinks && elements.length === 0 && tail.length === 0 && head !== undefined && (!head.mayRecurse || uniqueBy === undefined)) {
|
|
999
|
+
return head.mayRecurse ? generateRepeatedRecursiveValues(head, repeatCount, itemState) : uniqueBy !== undefined ? generateRepeatedUniqueValues(head, repeatCount, itemState, uniqueBy) : generateRepeatedValues(head, repeatCount, itemState);
|
|
1000
|
+
}
|
|
1001
|
+
const selected = [...elements.slice(0, required + optionalCount).map(element => element.compiled), ...Array.from({
|
|
1002
|
+
length: repeatCount
|
|
1003
|
+
}, () => head), ...tail];
|
|
1004
|
+
const makeAttempt = generated => arraySample(generated, {
|
|
1005
|
+
fixedCount: required + optionalCount,
|
|
1006
|
+
optionalCount,
|
|
1007
|
+
repeatCount,
|
|
1008
|
+
tailCount: tail.length,
|
|
1009
|
+
minimum
|
|
1010
|
+
}, state.shrinks);
|
|
1011
|
+
if (uniqueBy === undefined) {
|
|
1012
|
+
return Model.mapComputation(generateSamples(selected, itemState), generated => generated === undefined ? Model.discarded : makeAttempt(generated));
|
|
1013
|
+
}
|
|
1014
|
+
// The requested-length consecutive duplicate circuit breaker follows fast-check v4.9.0's ArrayArbitrary
|
|
1015
|
+
// strategy (MIT).
|
|
1016
|
+
// https://github.com/dubzzz/fast-check/blob/v4.9.0/packages/fast-check/src/arbitrary/_internals/ArrayArbitrary.ts
|
|
1017
|
+
const generated = [];
|
|
1018
|
+
const addUnique = makeUniqueAdderBy(uniqueBy);
|
|
1019
|
+
let reserved = sumCosts(selected.map(child => child.minCost));
|
|
1020
|
+
const maximumRetries = selected.length;
|
|
1021
|
+
let index = 0;
|
|
1022
|
+
let retries = 0;
|
|
1023
|
+
let budget = state.budget.remaining;
|
|
1024
|
+
const loop = () => {
|
|
1025
|
+
while (index < selected.length) {
|
|
1026
|
+
const child = selected[index];
|
|
1027
|
+
if (retries === 0) {
|
|
1028
|
+
reserved -= child.minCost;
|
|
1029
|
+
budget = state.budget.remaining;
|
|
1030
|
+
}
|
|
1031
|
+
const generatedChild = Model.generateWithReservedBudget(child, itemState, reserved);
|
|
1032
|
+
if (Model.isAttempt(generatedChild)) {
|
|
1033
|
+
const attempt = generatedChild;
|
|
1034
|
+
if (attempt._tag === "Discarded") return Model.discarded;
|
|
1035
|
+
if (!addUnique(attempt.value)) {
|
|
1036
|
+
if (++retries >= maximumRetries) return Model.discarded;
|
|
1037
|
+
state.budget.remaining = budget;
|
|
1038
|
+
continue;
|
|
1039
|
+
}
|
|
1040
|
+
generated.push(attempt);
|
|
1041
|
+
index++;
|
|
1042
|
+
retries = 0;
|
|
1043
|
+
continue;
|
|
1044
|
+
}
|
|
1045
|
+
return Effect.flatMapEager(generatedChild, attempt => {
|
|
1046
|
+
if (attempt._tag === "Discarded") return Effect.succeed(Model.discarded);
|
|
1047
|
+
if (!addUnique(attempt.value)) {
|
|
1048
|
+
if (++retries >= maximumRetries) return Effect.succeed(Model.discarded);
|
|
1049
|
+
state.budget.remaining = budget;
|
|
1050
|
+
} else {
|
|
1051
|
+
generated.push(attempt);
|
|
1052
|
+
index++;
|
|
1053
|
+
retries = 0;
|
|
1054
|
+
}
|
|
1055
|
+
return Model.toEffect(loop());
|
|
1056
|
+
});
|
|
1057
|
+
}
|
|
1058
|
+
return makeAttempt(generated);
|
|
1059
|
+
};
|
|
1060
|
+
return loop();
|
|
1061
|
+
});
|
|
1062
|
+
};
|
|
1063
|
+
const compileObjects = (ast, path, constraint) => {
|
|
1064
|
+
const constrainedIndexes = ast.indexSignatures.flatMap((index, position) => {
|
|
1065
|
+
const constraint = collectChecks(index.type.checks, undefined).constraint;
|
|
1066
|
+
return constraint === undefined ? [] : [{
|
|
1067
|
+
index,
|
|
1068
|
+
position,
|
|
1069
|
+
constraint
|
|
1070
|
+
}];
|
|
1071
|
+
});
|
|
1072
|
+
const compileIndexedValue = (type, path) => {
|
|
1073
|
+
const compiled = recur(type, path);
|
|
1074
|
+
// Scalar specializations have no recursive dependencies and keep the same minimum cost.
|
|
1075
|
+
const candidates = type._tag === "String" || type._tag === "Number" || type._tag === "BigInt" ? constrainedIndexes.filter(({
|
|
1076
|
+
index
|
|
1077
|
+
}) => index.type !== type && index.type._tag === type._tag) : [];
|
|
1078
|
+
const specializations = new Map();
|
|
1079
|
+
const forKey = key => {
|
|
1080
|
+
if (candidates.length === 0) return compiled;
|
|
1081
|
+
const input = {
|
|
1082
|
+
[key]: undefined
|
|
1083
|
+
};
|
|
1084
|
+
const matching = candidates.filter(({
|
|
1085
|
+
index
|
|
1086
|
+
}) => SchemaAST.getIndexSignatureKeys(input, index.parameter).length > 0);
|
|
1087
|
+
if (matching.length === 0) return compiled;
|
|
1088
|
+
const cacheKey = matching.map(({
|
|
1089
|
+
position
|
|
1090
|
+
}) => position).join(",");
|
|
1091
|
+
const cached = specializations.get(cacheKey);
|
|
1092
|
+
if (cached !== undefined) return cached;
|
|
1093
|
+
let specialized = compiled;
|
|
1094
|
+
try {
|
|
1095
|
+
let inherited;
|
|
1096
|
+
for (const match of matching) inherited = mergeConstraint(inherited, match.constraint);
|
|
1097
|
+
const checks = collectChecks(type.checks, inherited);
|
|
1098
|
+
specialized = compileBase(type, path, checks.constraint);
|
|
1099
|
+
specialized.minCost = 0;
|
|
1100
|
+
applyFilters(specialized, type, checks.filters);
|
|
1101
|
+
} catch {
|
|
1102
|
+
// Incompatible scalar constraints keep the original generator and indexed validation.
|
|
1103
|
+
}
|
|
1104
|
+
specializations.set(cacheKey, specialized);
|
|
1105
|
+
return specialized;
|
|
1106
|
+
};
|
|
1107
|
+
return {
|
|
1108
|
+
compiled,
|
|
1109
|
+
forKey
|
|
1110
|
+
};
|
|
1111
|
+
};
|
|
1112
|
+
const properties = ast.propertySignatures.map(property => ({
|
|
1113
|
+
property,
|
|
1114
|
+
optional: SchemaAST.isOptional(property.type),
|
|
1115
|
+
compiled: compileIndexedValue(property.type, [...path, property.name]).forKey(property.name)
|
|
1116
|
+
}));
|
|
1117
|
+
const indexes = ast.indexSignatures.map((index, position) => {
|
|
1118
|
+
const value = compileIndexedValue(index.type, [...path, `index-${position}-value`]);
|
|
1119
|
+
return {
|
|
1120
|
+
parameter: recur(index.parameter, [...path, `index-${position}-key`]),
|
|
1121
|
+
value: value.compiled,
|
|
1122
|
+
valueForKey: value.forKey
|
|
1123
|
+
};
|
|
1124
|
+
});
|
|
1125
|
+
const required = properties.filter(property => !property.optional);
|
|
1126
|
+
const optional = properties.filter(property => property.optional);
|
|
1127
|
+
const [minimum, maximum] = lengthBounds(constraint, ["minProperties", "maxProperties"], path, "object property");
|
|
1128
|
+
if (maximum !== undefined && maximum < required.length || indexes.length === 0 && minimum > properties.length) {
|
|
1129
|
+
throw arbitraryError("object property constraints", path);
|
|
1130
|
+
}
|
|
1131
|
+
const needed = Math.max(0, minimum - required.length);
|
|
1132
|
+
const minOptional = indexes.length === 0 ? needed : 0;
|
|
1133
|
+
const fallbackOptionalCount = Math.min(optional.length, needed);
|
|
1134
|
+
const dependencies = [...properties.map(property => property.compiled), ...indexes.flatMap(index => [index.parameter, index.value])];
|
|
1135
|
+
return Model.makeCompiled(dependencies, () => {
|
|
1136
|
+
const requiredCost = sumCosts(required.map(property => property.compiled.minCost));
|
|
1137
|
+
const optionalCosts = optional.map(property => property.compiled.minCost).sort((a, b) => a - b);
|
|
1138
|
+
if (needed <= optionalCosts.length) return requiredCost + sumCosts(optionalCosts.slice(0, needed));
|
|
1139
|
+
if (indexes.length === 0) return infinity;
|
|
1140
|
+
const indexCost = Math.min(...indexes.map(index => index.parameter.minCost + index.value.minCost));
|
|
1141
|
+
return requiredCost + sumCosts(optionalCosts) + (needed - optionalCosts.length) * indexCost;
|
|
1142
|
+
}, state => {
|
|
1143
|
+
if (!state.shrinks && optional.length === 0 && indexes.length === 0) {
|
|
1144
|
+
return generateRequiredObjectValues(required, state, state.nullPrototype);
|
|
1145
|
+
}
|
|
1146
|
+
const currentMaximum = Math.max(minimum, required.length, state.size);
|
|
1147
|
+
const upper = maximum === undefined ? currentMaximum : Math.min(maximum, currentMaximum);
|
|
1148
|
+
const maxOptional = Math.min(optional.length, upper - required.length);
|
|
1149
|
+
const minimumIndexCost = indexes.length === 0 ? infinity : Math.min(...indexes.map(index => index.parameter.minCost + index.value.minCost));
|
|
1150
|
+
const optionalCount = Model.randomInt(state, minOptional, maxOptional);
|
|
1151
|
+
const shuffledOptional = optionalCount === 0 ? undefined : Model.shuffle(state, optional);
|
|
1152
|
+
let selectedOptional = optionalCount === 0 ? [] : shuffledOptional.slice(0, optionalCount);
|
|
1153
|
+
let named = [...required, ...selectedOptional];
|
|
1154
|
+
let minimumIndexes = Math.max(0, minimum - named.length);
|
|
1155
|
+
let namedCost = sumCosts(named.map(property => property.compiled.minCost));
|
|
1156
|
+
if (namedCost + (minimumIndexes === 0 ? 0 : minimumIndexes * minimumIndexCost) > state.budget.remaining) {
|
|
1157
|
+
selectedOptional = (shuffledOptional ?? Model.shuffle(state, optional)).sort((a, b) => a.compiled.minCost - b.compiled.minCost).slice(0, fallbackOptionalCount);
|
|
1158
|
+
named = [...required, ...selectedOptional];
|
|
1159
|
+
minimumIndexes = Math.max(0, minimum - named.length);
|
|
1160
|
+
namedCost = sumCosts(named.map(property => property.compiled.minCost));
|
|
1161
|
+
}
|
|
1162
|
+
const maximumIndexes = indexes.length === 0 ? 0 : upper - named.length;
|
|
1163
|
+
const affordableIndexes = minimumIndexCost === 0 ? maximumIndexes : minimumIndexCost === infinity ? 0 : Math.min(maximumIndexes, Math.floor((state.budget.remaining - namedCost) / minimumIndexCost));
|
|
1164
|
+
if (affordableIndexes < minimumIndexes) return Model.discarded;
|
|
1165
|
+
const indexCount = Model.randomLength(state, minimumIndexes, affordableIndexes);
|
|
1166
|
+
const indexReserved = indexCount === 0 ? 0 : indexCount * minimumIndexCost;
|
|
1167
|
+
return Model.flatMapComputation(generateSamples(named.map(property => property.compiled), state, indexReserved), samples => {
|
|
1168
|
+
if (samples === undefined) return Model.discarded;
|
|
1169
|
+
const entries = samples.map((sample, index) => ({
|
|
1170
|
+
key: named[index].property.name,
|
|
1171
|
+
sample,
|
|
1172
|
+
removable: named[index].optional
|
|
1173
|
+
}));
|
|
1174
|
+
if (indexCount === 0) {
|
|
1175
|
+
return objectSample(entries, minimum, state.nullPrototype, state.shrinks);
|
|
1176
|
+
}
|
|
1177
|
+
return Effect.gen(function* () {
|
|
1178
|
+
for (let position = 0; position < indexCount; position++) {
|
|
1179
|
+
const futureReserved = (indexCount - position - 1) * minimumIndexCost;
|
|
1180
|
+
const eligible = indexes.filter(index => index.parameter.minCost + index.value.minCost + futureReserved <= state.budget.remaining);
|
|
1181
|
+
if (eligible.length === 0) return Model.discarded;
|
|
1182
|
+
const index = eligible[Model.randomIndex(state, eligible.length)];
|
|
1183
|
+
const budget = state.budget.remaining;
|
|
1184
|
+
const reservedAfterKey = index.value.minCost + futureReserved;
|
|
1185
|
+
// Multiple required index entries need enough key diversity before progressive size can advance.
|
|
1186
|
+
const keyState = state.size >= indexCount ? state : {
|
|
1187
|
+
...state,
|
|
1188
|
+
size: indexCount
|
|
1189
|
+
};
|
|
1190
|
+
let keyAttempt = yield* Model.toEffectGeneration(Model.generateWithReservedBudget(index.parameter, keyState, reservedAfterKey));
|
|
1191
|
+
let keySample;
|
|
1192
|
+
let retries = 0;
|
|
1193
|
+
while (true) {
|
|
1194
|
+
if (keyAttempt._tag === "Discarded") return Model.discarded;
|
|
1195
|
+
const normalized = normalizePropertyKeySample(keyAttempt);
|
|
1196
|
+
if (normalized === undefined) return Model.discarded;
|
|
1197
|
+
keySample = normalized;
|
|
1198
|
+
if (!entries.some(entry => entry.key === keySample.value)) break;
|
|
1199
|
+
if (retries++ >= 10) return Model.discarded;
|
|
1200
|
+
state.budget.remaining = budget;
|
|
1201
|
+
keyAttempt = yield* Model.toEffectGeneration(Model.generateWithReservedBudget(index.parameter, keyState, reservedAfterKey));
|
|
1202
|
+
}
|
|
1203
|
+
const value = yield* Model.toEffectGeneration(Model.generateWithReservedBudget(index.valueForKey(keySample.value), state, futureReserved));
|
|
1204
|
+
if (value._tag === "Discarded") return Model.discarded;
|
|
1205
|
+
entries.push({
|
|
1206
|
+
key: keySample.value,
|
|
1207
|
+
keySample,
|
|
1208
|
+
sample: value,
|
|
1209
|
+
removable: true
|
|
1210
|
+
});
|
|
1211
|
+
}
|
|
1212
|
+
return objectSample(entries, minimum, state.nullPrototype, state.shrinks);
|
|
1213
|
+
});
|
|
1214
|
+
});
|
|
1215
|
+
});
|
|
1216
|
+
};
|
|
1217
|
+
const compileDeclaration = (ast, path, constraint) => {
|
|
1218
|
+
validateConstraint(constraint, path);
|
|
1219
|
+
const typeParameters = ast.typeParameters.map((parameter, index) => recur(parameter, [...path, index]));
|
|
1220
|
+
const parameters = ast.typeParameters.map(parameter => Schema.make(SchemaAST.toType(parameter)));
|
|
1221
|
+
const getArbitrary = ast.annotations?.toCodecArbitrary;
|
|
1222
|
+
let link;
|
|
1223
|
+
if (typeof getArbitrary === "function") {
|
|
1224
|
+
link = getArbitrary({
|
|
1225
|
+
typeParameters: parameters,
|
|
1226
|
+
constraint: withoutOrder(constraint)
|
|
1227
|
+
});
|
|
1228
|
+
} else {
|
|
1229
|
+
const builtInLink = builtInDeclarationLink(ast, parameters, withoutOrder(constraint));
|
|
1230
|
+
if (builtInLink !== undefined) {
|
|
1231
|
+
link = builtInLink;
|
|
1232
|
+
} else {
|
|
1233
|
+
const getJson = ast.annotations?.toCodecJson;
|
|
1234
|
+
if (typeof getJson === "function") {
|
|
1235
|
+
const jsonLink = getJson(parameters);
|
|
1236
|
+
if (jsonLink === undefined) throw arbitraryError("an opaque self-canonical Declaration", path);
|
|
1237
|
+
link = jsonLink;
|
|
1238
|
+
} else {
|
|
1239
|
+
const get = ast.annotations?.toCodec;
|
|
1240
|
+
if (typeof get !== "function") throw arbitraryError("an unsupported Declaration", path);
|
|
1241
|
+
link = get(parameters);
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
const target = recur(SchemaAST.toType(link.to), path);
|
|
1246
|
+
const decodeDeclaration = SchemaParser.run(ast);
|
|
1247
|
+
const decode = value => {
|
|
1248
|
+
const transformed = link.transformation._tag === "Transformation" ? link.transformation.decode.run(Option.some(value), SchemaAST.defaultParseOptions) : link.transformation.decode(Effect.succeed(Option.some(value)), SchemaAST.defaultParseOptions);
|
|
1249
|
+
return Model.flatMapComputation(optionComputation(transformed), outer => {
|
|
1250
|
+
if (Option.isNone(outer) || Option.isNone(outer.value)) return Option.none();
|
|
1251
|
+
return optionComputation(decodeDeclaration(outer.value.value));
|
|
1252
|
+
});
|
|
1253
|
+
};
|
|
1254
|
+
return Model.makeCompiled([target, ...typeParameters], () => target.minCost, state => Model.filterMapGeneration(target.generate(state), decode));
|
|
1255
|
+
};
|
|
1256
|
+
const root = recur(rootAst, []);
|
|
1257
|
+
for (let index = 0; index < pending.length; index++) pending[index]();
|
|
1258
|
+
const dependents = analyzeDependencyGraph(nodes, suspendBodies);
|
|
1259
|
+
const recursiveQueue = nodes.filter(node => node.recursive);
|
|
1260
|
+
for (let index = 0; index < recursiveQueue.length; index++) {
|
|
1261
|
+
const node = recursiveQueue[index];
|
|
1262
|
+
if (node.mayRecurse) continue;
|
|
1263
|
+
node.mayRecurse = true;
|
|
1264
|
+
recursiveQueue.push(...dependents.get(node));
|
|
1265
|
+
}
|
|
1266
|
+
const queue = nodes.slice();
|
|
1267
|
+
const queued = new Set(nodes);
|
|
1268
|
+
for (let index = 0; index < queue.length; index++) {
|
|
1269
|
+
const node = queue[index];
|
|
1270
|
+
queued.delete(node);
|
|
1271
|
+
const next = node.computeMinCost();
|
|
1272
|
+
if (next >= node.minCost) continue;
|
|
1273
|
+
node.minCost = next;
|
|
1274
|
+
for (const dependent of dependents.get(node)) {
|
|
1275
|
+
if (!queued.has(dependent)) {
|
|
1276
|
+
queued.add(dependent);
|
|
1277
|
+
queue.push(dependent);
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
if (root.minCost === infinity) {
|
|
1282
|
+
throw arbitraryError("a recursive schema without a finite generation path", []);
|
|
1283
|
+
}
|
|
1284
|
+
return root;
|
|
1285
|
+
}
|
|
1286
|
+
function analyzeDependencyGraph(nodes, suspendBodies) {
|
|
1287
|
+
const visited = new Set();
|
|
1288
|
+
const finished = [];
|
|
1289
|
+
for (const root of nodes) {
|
|
1290
|
+
if (visited.has(root)) continue;
|
|
1291
|
+
visited.add(root);
|
|
1292
|
+
const stack = [{
|
|
1293
|
+
node: root,
|
|
1294
|
+
index: 0
|
|
1295
|
+
}];
|
|
1296
|
+
while (stack.length > 0) {
|
|
1297
|
+
const frame = stack[stack.length - 1];
|
|
1298
|
+
if (frame.index < frame.node.dependencies.length) {
|
|
1299
|
+
const dependency = frame.node.dependencies[frame.index++];
|
|
1300
|
+
if (!visited.has(dependency)) {
|
|
1301
|
+
visited.add(dependency);
|
|
1302
|
+
stack.push({
|
|
1303
|
+
node: dependency,
|
|
1304
|
+
index: 0
|
|
1305
|
+
});
|
|
1306
|
+
}
|
|
1307
|
+
} else {
|
|
1308
|
+
finished.push(frame.node);
|
|
1309
|
+
stack.pop();
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
const reverse = new Map();
|
|
1314
|
+
for (const node of visited) reverse.set(node, []);
|
|
1315
|
+
for (const node of visited) {
|
|
1316
|
+
for (const dependency of node.dependencies) reverse.get(dependency)?.push(node);
|
|
1317
|
+
}
|
|
1318
|
+
const component = new Map();
|
|
1319
|
+
let componentId = 0;
|
|
1320
|
+
for (let index = finished.length - 1; index >= 0; index--) {
|
|
1321
|
+
const root = finished[index];
|
|
1322
|
+
if (component.has(root)) continue;
|
|
1323
|
+
component.set(root, componentId);
|
|
1324
|
+
const stack = [root];
|
|
1325
|
+
while (stack.length > 0) {
|
|
1326
|
+
const node = stack.pop();
|
|
1327
|
+
for (const dependency of reverse.get(node)) {
|
|
1328
|
+
if (component.has(dependency)) continue;
|
|
1329
|
+
component.set(dependency, componentId);
|
|
1330
|
+
stack.push(dependency);
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
componentId++;
|
|
1334
|
+
}
|
|
1335
|
+
for (const [suspend, body] of suspendBodies) {
|
|
1336
|
+
suspend.recursive = component.get(suspend) === component.get(body);
|
|
1337
|
+
}
|
|
1338
|
+
return reverse;
|
|
1339
|
+
}
|
|
1340
|
+
//# sourceMappingURL=schema.js.map
|