effect 4.0.0-beta.100 → 4.0.0-beta.102
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/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +81 -5
- package/dist/Array.js.map +1 -1
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +27 -9
- package/dist/Channel.js.map +1 -1
- package/dist/Config.d.ts +1 -1
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +6 -5
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.js +7 -7
- package/dist/ConfigProvider.js.map +1 -1
- package/dist/Data.d.ts.map +1 -1
- package/dist/Data.js +2 -1
- package/dist/Data.js.map +1 -1
- package/dist/Effect.d.ts +61 -100
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +66 -39
- package/dist/Effect.js.map +1 -1
- package/dist/FiberHandle.d.ts.map +1 -1
- package/dist/FiberHandle.js +3 -2
- package/dist/FiberHandle.js.map +1 -1
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +2 -1
- package/dist/Iterable.js.map +1 -1
- package/dist/JsonPatch.d.ts.map +1 -1
- package/dist/JsonPatch.js +4 -3
- package/dist/JsonPatch.js.map +1 -1
- package/dist/JsonSchema.d.ts.map +1 -1
- package/dist/JsonSchema.js +9 -11
- package/dist/JsonSchema.js.map +1 -1
- package/dist/Logger.d.ts.map +1 -1
- package/dist/Logger.js +3 -2
- package/dist/Logger.js.map +1 -1
- package/dist/ManagedRuntime.d.ts +9 -0
- package/dist/ManagedRuntime.d.ts.map +1 -1
- package/dist/ManagedRuntime.js +3 -0
- package/dist/ManagedRuntime.js.map +1 -1
- package/dist/Metric.d.ts.map +1 -1
- package/dist/Metric.js +4 -3
- package/dist/Metric.js.map +1 -1
- package/dist/MutableList.d.ts.map +1 -1
- package/dist/MutableList.js +4 -0
- package/dist/MutableList.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.map +1 -1
- package/dist/Option.js +2 -1
- package/dist/Option.js.map +1 -1
- package/dist/PartitionedSemaphore.d.ts.map +1 -1
- package/dist/PartitionedSemaphore.js +1 -4
- package/dist/PartitionedSemaphore.js.map +1 -1
- package/dist/Record.d.ts +93 -1
- package/dist/Record.d.ts.map +1 -1
- package/dist/Record.js +57 -19
- package/dist/Record.js.map +1 -1
- package/dist/References.d.ts +0 -45
- package/dist/References.d.ts.map +1 -1
- package/dist/References.js +0 -45
- package/dist/References.js.map +1 -1
- package/dist/Request.d.ts.map +1 -1
- package/dist/Request.js +9 -6
- package/dist/Request.js.map +1 -1
- package/dist/Result.d.ts.map +1 -1
- package/dist/Result.js +2 -1
- package/dist/Result.js.map +1 -1
- package/dist/Schema.d.ts +1269 -496
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +2308 -614
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +2 -2
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +189 -130
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaError.js +1 -1
- package/dist/SchemaError.js.map +1 -1
- package/dist/SchemaGetter.d.ts +13 -11
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +34 -24
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaIssue.js +1 -1
- package/dist/SchemaIssue.js.map +1 -1
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +1 -12
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +403 -1504
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +294 -2852
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +2 -2
- package/dist/SchemaTransformation.js +3 -3
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/Semaphore.d.ts +5 -3
- package/dist/Semaphore.d.ts.map +1 -1
- package/dist/Semaphore.js.map +1 -1
- package/dist/Stream.d.ts +15 -9
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +46 -16
- package/dist/Stream.js.map +1 -1
- package/dist/Struct.d.ts.map +1 -1
- package/dist/Struct.js +5 -4
- package/dist/Struct.js.map +1 -1
- package/dist/Types.d.ts +1 -3
- package/dist/Types.d.ts.map +1 -1
- package/dist/index.d.ts +0 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -4
- package/dist/index.js.map +1 -1
- package/dist/internal/core.js +3 -2
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/effect.js +119 -53
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/matcher.js +1 -1
- package/dist/internal/matcher.js.map +1 -1
- package/dist/internal/record.d.ts +0 -3
- package/dist/internal/record.d.ts.map +1 -1
- package/dist/internal/record.js +10 -5
- package/dist/internal/record.js.map +1 -1
- package/dist/internal/references.js +0 -4
- package/dist/internal/references.js.map +1 -1
- package/dist/internal/schema/annotations.js +12 -0
- package/dist/internal/schema/annotations.js.map +1 -1
- package/dist/internal/schema/fromJsonSchemaDocument.d.ts +2 -0
- package/dist/internal/schema/fromJsonSchemaDocument.d.ts.map +1 -0
- package/dist/internal/schema/fromJsonSchemaDocument.js +743 -0
- package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -0
- package/dist/internal/schema/fromRepresentation.d.ts +2 -0
- package/dist/internal/schema/fromRepresentation.d.ts.map +1 -0
- package/dist/internal/schema/fromRepresentation.js +252 -0
- package/dist/internal/schema/fromRepresentation.js.map +1 -0
- package/dist/internal/schema/schema.js +28 -40
- package/dist/internal/schema/schema.js.map +1 -1
- package/dist/internal/schema/{arbitrary.d.ts → toArbitrary.d.ts} +1 -1
- package/dist/internal/schema/toArbitrary.d.ts.map +1 -0
- package/dist/internal/schema/{arbitrary.js → toArbitrary.js} +8 -9
- package/dist/internal/schema/toArbitrary.js.map +1 -0
- package/dist/internal/schema/toCodeDocument.d.ts +2 -0
- package/dist/internal/schema/toCodeDocument.d.ts.map +1 -0
- package/dist/internal/schema/toCodeDocument.js +438 -0
- package/dist/internal/schema/toCodeDocument.js.map +1 -0
- package/dist/internal/schema/toEquivalence.d.ts +2 -0
- package/dist/internal/schema/toEquivalence.d.ts.map +1 -0
- package/dist/internal/schema/{equivalence.js → toEquivalence.js} +15 -13
- package/dist/internal/schema/toEquivalence.js.map +1 -0
- package/dist/internal/schema/toJsonSchemaDocument.d.ts +2 -0
- package/dist/internal/schema/toJsonSchemaDocument.d.ts.map +1 -0
- package/dist/internal/schema/toJsonSchemaDocument.js +466 -0
- package/dist/internal/schema/toJsonSchemaDocument.js.map +1 -0
- package/dist/internal/schema/toRepresentation.d.ts +2 -0
- package/dist/internal/schema/toRepresentation.d.ts.map +1 -0
- package/dist/internal/schema/toRepresentation.js +369 -0
- package/dist/internal/schema/toRepresentation.js.map +1 -0
- package/dist/internal/stackTraceLimit.js +3 -6
- package/dist/internal/stackTraceLimit.js.map +1 -1
- package/dist/testing/TestClock.js +4 -1
- package/dist/testing/TestClock.js.map +1 -1
- package/dist/unstable/ai/AiError.d.ts +26 -26
- package/dist/unstable/ai/AiError.d.ts.map +1 -1
- package/dist/unstable/ai/AiError.js +5 -4
- package/dist/unstable/ai/AiError.js.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts +21 -6
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.js +86 -316
- package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/EmbeddingModel.d.ts +1 -1
- package/dist/unstable/ai/EmbeddingModel.js +1 -1
- package/dist/unstable/ai/EmbeddingModel.js.map +1 -1
- package/dist/unstable/ai/LanguageModel.d.ts +4 -1
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +19 -17
- package/dist/unstable/ai/LanguageModel.js.map +1 -1
- package/dist/unstable/ai/McpSchema.d.ts +197 -197
- package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
- package/dist/unstable/ai/McpSchema.js +13 -13
- package/dist/unstable/ai/McpSchema.js.map +1 -1
- package/dist/unstable/ai/McpServer.d.ts +4 -4
- package/dist/unstable/ai/McpServer.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.js +116 -49
- package/dist/unstable/ai/McpServer.js.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts +32 -10
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js +193 -377
- package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Response.d.ts +19 -19
- package/dist/unstable/ai/Response.d.ts.map +1 -1
- package/dist/unstable/ai/Response.js +14 -14
- package/dist/unstable/ai/Response.js.map +1 -1
- package/dist/unstable/ai/Tool.d.ts +4 -0
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +11 -3
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/ai/Toolkit.d.ts +9 -1
- package/dist/unstable/ai/Toolkit.d.ts.map +1 -1
- package/dist/unstable/ai/Toolkit.js +14 -10
- package/dist/unstable/ai/Toolkit.js.map +1 -1
- package/dist/unstable/ai/internal/codec-transformer.js +15 -12
- package/dist/unstable/ai/internal/codec-transformer.js.map +1 -1
- package/dist/unstable/ai/internal/structured-output.d.ts +2 -0
- package/dist/unstable/ai/internal/structured-output.d.ts.map +1 -0
- package/dist/unstable/ai/internal/structured-output.js +316 -0
- package/dist/unstable/ai/internal/structured-output.js.map +1 -0
- package/dist/unstable/cli/CliError.d.ts +40 -2
- package/dist/unstable/cli/CliError.d.ts.map +1 -1
- package/dist/unstable/cli/CliError.js +45 -6
- package/dist/unstable/cli/CliError.js.map +1 -1
- package/dist/unstable/cli/Command.js +14 -5
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cli/Param.js +3 -3
- package/dist/unstable/cli/Param.js.map +1 -1
- package/dist/unstable/cli/Primitive.js +1 -1
- package/dist/unstable/cli/Primitive.js.map +1 -1
- package/dist/unstable/cli/internal/command.d.ts +3 -1
- package/dist/unstable/cli/internal/command.d.ts.map +1 -1
- package/dist/unstable/cli/internal/command.js +11 -4
- package/dist/unstable/cli/internal/command.js.map +1 -1
- package/dist/unstable/cli/internal/config.d.ts +0 -48
- package/dist/unstable/cli/internal/config.d.ts.map +1 -1
- package/dist/unstable/cli/internal/config.js +8 -10
- package/dist/unstable/cli/internal/config.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/cluster/Entity.js +1 -1
- package/dist/unstable/cluster/Entity.js.map +1 -1
- package/dist/unstable/cluster/Envelope.d.ts.map +1 -1
- package/dist/unstable/cluster/Envelope.js +2 -1
- package/dist/unstable/cluster/Envelope.js.map +1 -1
- package/dist/unstable/cluster/Reply.js +1 -1
- package/dist/unstable/cluster/Reply.js.map +1 -1
- package/dist/unstable/cluster/Runner.d.ts +1 -1
- package/dist/unstable/cluster/Runner.js +1 -1
- package/dist/unstable/cluster/Runner.js.map +1 -1
- package/dist/unstable/cluster/RunnerAddress.d.ts +1 -1
- package/dist/unstable/cluster/RunnerAddress.js +1 -1
- package/dist/unstable/cluster/RunnerAddress.js.map +1 -1
- package/dist/unstable/cluster/ShardId.js +1 -1
- package/dist/unstable/cluster/ShardId.js.map +1 -1
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +125 -24
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.d.ts +10 -2
- package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
- package/dist/unstable/cluster/SingleRunner.d.ts +4 -2
- package/dist/unstable/cluster/SingleRunner.d.ts.map +1 -1
- package/dist/unstable/cluster/SingleRunner.js +2 -1
- package/dist/unstable/cluster/SingleRunner.js.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.d.ts +7 -4
- package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.js +55 -24
- 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 +109 -62
- package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/unstable/cluster/internal/entityManager.js +19 -7
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/cluster/internal/shardLock.d.ts +2 -0
- package/dist/unstable/cluster/internal/shardLock.d.ts.map +1 -0
- package/dist/unstable/cluster/internal/shardLock.js +4 -0
- package/dist/unstable/cluster/internal/shardLock.js.map +1 -0
- package/dist/unstable/devtools/DevToolsSchema.d.ts +20 -20
- package/dist/unstable/devtools/DevToolsSchema.d.ts.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.js +8 -5
- package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
- package/dist/unstable/eventlog/EventJournal.d.ts +1 -1
- package/dist/unstable/eventlog/EventJournal.js +1 -1
- package/dist/unstable/eventlog/EventJournal.js.map +1 -1
- package/dist/unstable/eventlog/EventLog.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLog.js +15 -11
- package/dist/unstable/eventlog/EventLog.js.map +1 -1
- package/dist/unstable/eventlog/EventLogEncryption.d.ts +1 -1
- package/dist/unstable/eventlog/EventLogEncryption.js +1 -1
- package/dist/unstable/eventlog/EventLogEncryption.js.map +1 -1
- package/dist/unstable/eventlog/EventLogMessage.d.ts +26 -26
- package/dist/unstable/eventlog/EventLogMessage.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogMessage.js +8 -3
- package/dist/unstable/eventlog/EventLogMessage.js.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.d.ts +1 -1
- package/dist/unstable/eventlog/SqlEventJournal.js +2 -2
- package/dist/unstable/eventlog/SqlEventJournal.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerEncrypted.js +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerEncrypted.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js +3 -3
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js.map +1 -1
- package/dist/unstable/http/Cookies.d.ts.map +1 -1
- package/dist/unstable/http/Cookies.js +24 -22
- package/dist/unstable/http/Cookies.js.map +1 -1
- package/dist/unstable/http/Headers.js +8 -8
- package/dist/unstable/http/Headers.js.map +1 -1
- package/dist/unstable/http/HttpClientRequest.d.ts +44 -0
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.js +14 -0
- package/dist/unstable/http/HttpClientRequest.js.map +1 -1
- package/dist/unstable/http/HttpRouter.d.ts +2 -2
- package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
- package/dist/unstable/http/HttpRouter.js.map +1 -1
- package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRequest.js +5 -4
- package/dist/unstable/http/HttpServerRequest.js.map +1 -1
- package/dist/unstable/http/Multipart.d.ts.map +1 -1
- package/dist/unstable/http/Multipart.js +17 -15
- package/dist/unstable/http/Multipart.js.map +1 -1
- package/dist/unstable/http/Template.js +1 -1
- package/dist/unstable/http/Template.js.map +1 -1
- package/dist/unstable/http/UrlParams.d.ts.map +1 -1
- package/dist/unstable/http/UrlParams.js +17 -14
- package/dist/unstable/http/UrlParams.js.map +1 -1
- package/dist/unstable/httpapi/HttpApi.js +3 -3
- package/dist/unstable/httpapi/HttpApi.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.js +5 -5
- package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.js +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.js.map +1 -1
- package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/OpenApi.js +37 -24
- package/dist/unstable/httpapi/OpenApi.js.map +1 -1
- package/dist/unstable/observability/OtlpExporter.d.ts +72 -1
- package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.js +69 -4
- package/dist/unstable/observability/OtlpExporter.js.map +1 -1
- package/dist/unstable/observability/OtlpLogger.d.ts +4 -3
- package/dist/unstable/observability/OtlpLogger.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpLogger.js +2 -2
- package/dist/unstable/observability/OtlpLogger.js.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.d.ts +7 -3
- package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.js +5 -2
- package/dist/unstable/observability/OtlpMetrics.js.map +1 -1
- package/dist/unstable/observability/OtlpTracer.d.ts +4 -3
- package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpTracer.js +2 -2
- package/dist/unstable/observability/OtlpTracer.js.map +1 -1
- package/dist/unstable/persistence/Persistable.d.ts.map +1 -1
- package/dist/unstable/persistence/Persistable.js +2 -1
- package/dist/unstable/persistence/Persistable.js.map +1 -1
- package/dist/unstable/persistence/RateLimiter.d.ts +2 -2
- package/dist/unstable/persistence/RateLimiter.js +2 -2
- package/dist/unstable/persistence/RateLimiter.js.map +1 -1
- package/dist/unstable/persistence/Redis.d.ts.map +1 -1
- package/dist/unstable/persistence/Redis.js +2 -2
- package/dist/unstable/persistence/Redis.js.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.js +3 -1
- package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
- package/dist/unstable/reactivity/AsyncResult.d.ts.map +1 -1
- package/dist/unstable/reactivity/AsyncResult.js +4 -3
- package/dist/unstable/reactivity/AsyncResult.js.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts +83 -0
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +31 -0
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.js +1 -1
- package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +2 -1
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/schema/VariantSchema.d.ts +1 -2
- package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
- package/dist/unstable/schema/VariantSchema.js +13 -10
- package/dist/unstable/schema/VariantSchema.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts +1 -1
- package/dist/unstable/socket/Socket.js +1 -1
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/dist/unstable/sql/SqlError.d.ts +2 -2
- package/dist/unstable/sql/SqlError.js +2 -2
- package/dist/unstable/sql/SqlError.js.map +1 -1
- package/dist/unstable/sql/Statement.d.ts.map +1 -1
- package/dist/unstable/sql/Statement.js +7 -6
- package/dist/unstable/sql/Statement.js.map +1 -1
- package/package.json +1 -1
- package/src/Array.ts +86 -25
- package/src/Channel.ts +32 -14
- package/src/Config.ts +6 -5
- package/src/ConfigProvider.ts +7 -7
- package/src/Data.ts +3 -2
- package/src/Effect.ts +70 -116
- package/src/FiberHandle.ts +3 -2
- package/src/Iterable.ts +2 -1
- package/src/JsonPatch.ts +4 -3
- package/src/JsonSchema.ts +9 -11
- package/src/Logger.ts +3 -2
- package/src/ManagedRuntime.ts +13 -0
- package/src/Metric.ts +4 -3
- package/src/MutableList.ts +4 -0
- package/src/Optic.ts +5 -4
- package/src/Option.ts +2 -1
- package/src/PartitionedSemaphore.ts +1 -4
- package/src/Record.ts +119 -22
- package/src/References.ts +0 -46
- package/src/Request.ts +5 -7
- package/src/Result.ts +2 -1
- package/src/Schema.ts +2538 -987
- package/src/SchemaAST.ts +228 -149
- package/src/SchemaError.ts +1 -1
- package/src/SchemaGetter.ts +36 -29
- package/src/SchemaIssue.ts +1 -1
- package/src/SchemaParser.ts +1 -25
- package/src/SchemaRepresentation.ts +697 -3398
- package/src/SchemaTransformation.ts +3 -3
- package/src/Semaphore.ts +5 -3
- package/src/Stream.ts +63 -19
- package/src/Struct.ts +5 -4
- package/src/Types.ts +1 -3
- package/src/index.ts +0 -5
- package/src/internal/core.ts +4 -3
- package/src/internal/effect.ts +132 -70
- package/src/internal/matcher.ts +1 -1
- package/src/internal/record.ts +11 -7
- package/src/internal/references.ts +0 -5
- package/src/internal/schema/annotations.ts +44 -0
- package/src/internal/schema/fromJsonSchemaDocument.ts +957 -0
- package/src/internal/schema/fromRepresentation.ts +345 -0
- package/src/internal/schema/schema.ts +45 -46
- package/src/internal/schema/{arbitrary.ts → toArbitrary.ts} +8 -10
- package/src/internal/schema/toCodeDocument.ts +572 -0
- package/src/internal/schema/{equivalence.ts → toEquivalence.ts} +12 -7
- package/src/internal/schema/toJsonSchemaDocument.ts +475 -0
- package/src/internal/schema/toRepresentation.ts +401 -0
- package/src/internal/stackTraceLimit.ts +3 -7
- package/src/testing/TestClock.ts +1 -1
- package/src/unstable/ai/AiError.ts +5 -4
- package/src/unstable/ai/AnthropicStructuredOutput.ts +102 -333
- package/src/unstable/ai/EmbeddingModel.ts +1 -1
- package/src/unstable/ai/LanguageModel.ts +30 -28
- package/src/unstable/ai/McpSchema.ts +15 -15
- package/src/unstable/ai/McpServer.ts +172 -56
- package/src/unstable/ai/OpenAiStructuredOutput.ts +230 -395
- package/src/unstable/ai/Response.ts +24 -24
- package/src/unstable/ai/Tool.ts +22 -4
- package/src/unstable/ai/Toolkit.ts +19 -7
- package/src/unstable/ai/internal/codec-transformer.ts +13 -7
- package/src/unstable/ai/internal/structured-output.ts +458 -0
- package/src/unstable/cli/CliError.ts +51 -5
- package/src/unstable/cli/Command.ts +4 -4
- package/src/unstable/cli/Param.ts +3 -3
- package/src/unstable/cli/Primitive.ts +1 -1
- package/src/unstable/cli/internal/command.ts +13 -5
- package/src/unstable/cli/internal/config.ts +8 -10
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +3 -3
- package/src/unstable/cluster/Entity.ts +1 -1
- package/src/unstable/cluster/Envelope.ts +2 -1
- package/src/unstable/cluster/Reply.ts +1 -1
- package/src/unstable/cluster/Runner.ts +1 -1
- package/src/unstable/cluster/RunnerAddress.ts +1 -1
- package/src/unstable/cluster/ShardId.ts +1 -1
- package/src/unstable/cluster/Sharding.ts +161 -34
- package/src/unstable/cluster/ShardingConfig.ts +5 -1
- package/src/unstable/cluster/SingleRunner.ts +4 -2
- package/src/unstable/cluster/SqlMessageStorage.ts +83 -35
- package/src/unstable/cluster/SqlRunnerStorage.ts +186 -116
- package/src/unstable/cluster/internal/entityManager.ts +31 -10
- package/src/unstable/cluster/internal/shardLock.ts +9 -0
- package/src/unstable/devtools/DevToolsSchema.ts +10 -5
- package/src/unstable/eventlog/EventJournal.ts +1 -1
- package/src/unstable/eventlog/EventLog.ts +21 -11
- package/src/unstable/eventlog/EventLogEncryption.ts +1 -1
- package/src/unstable/eventlog/EventLogMessage.ts +10 -3
- package/src/unstable/eventlog/SqlEventJournal.ts +2 -2
- package/src/unstable/eventlog/SqlEventLogServerEncrypted.ts +1 -1
- package/src/unstable/eventlog/SqlEventLogServerUnencrypted.ts +6 -3
- package/src/unstable/http/Cookies.ts +29 -24
- package/src/unstable/http/Headers.ts +8 -8
- package/src/unstable/http/HttpClientRequest.ts +57 -0
- package/src/unstable/http/HttpRouter.ts +6 -3
- package/src/unstable/http/HttpServerRequest.ts +5 -4
- package/src/unstable/http/Multipart.ts +16 -13
- package/src/unstable/http/Template.ts +1 -1
- package/src/unstable/http/UrlParams.ts +17 -14
- package/src/unstable/httpapi/HttpApi.ts +3 -3
- package/src/unstable/httpapi/HttpApiClient.ts +5 -5
- package/src/unstable/httpapi/HttpApiGroup.ts +1 -1
- package/src/unstable/httpapi/OpenApi.ts +52 -28
- package/src/unstable/observability/OtlpExporter.ts +109 -5
- package/src/unstable/observability/OtlpLogger.ts +5 -5
- package/src/unstable/observability/OtlpMetrics.ts +8 -4
- package/src/unstable/observability/OtlpTracer.ts +8 -4
- package/src/unstable/persistence/Persistable.ts +3 -2
- package/src/unstable/persistence/RateLimiter.ts +2 -2
- package/src/unstable/persistence/Redis.ts +2 -2
- package/src/unstable/process/ChildProcessSpawner.ts +1 -1
- package/src/unstable/reactivity/AsyncResult.ts +4 -3
- package/src/unstable/reactivity/Atom.ts +92 -0
- package/src/unstable/reactivity/AtomRegistry.ts +1 -1
- package/src/unstable/rpc/RpcClient.ts +2 -1
- package/src/unstable/schema/VariantSchema.ts +14 -24
- package/src/unstable/socket/Socket.ts +1 -1
- package/src/unstable/sql/SqlError.ts +2 -2
- package/src/unstable/sql/Statement.ts +7 -6
- package/dist/SchemaUtils.d.ts +0 -28
- package/dist/SchemaUtils.d.ts.map +0 -1
- package/dist/SchemaUtils.js +0 -45
- package/dist/SchemaUtils.js.map +0 -1
- package/dist/internal/schema/arbitrary.d.ts.map +0 -1
- package/dist/internal/schema/arbitrary.js.map +0 -1
- package/dist/internal/schema/equivalence.d.ts +0 -2
- package/dist/internal/schema/equivalence.d.ts.map +0 -1
- package/dist/internal/schema/equivalence.js.map +0 -1
- package/dist/internal/schema/representation.d.ts +0 -2
- package/dist/internal/schema/representation.d.ts.map +0 -1
- package/dist/internal/schema/representation.js +0 -865
- package/dist/internal/schema/representation.js.map +0 -1
- package/src/SchemaUtils.ts +0 -51
- package/src/internal/schema/representation.ts +0 -795
|
@@ -0,0 +1,743 @@
|
|
|
1
|
+
import { unescapeToken } from "../../JsonPointer.js";
|
|
2
|
+
import { remainder } from "../../Number.js";
|
|
3
|
+
import * as Schema from "../../Schema.js";
|
|
4
|
+
import * as SchemaAST from "../../SchemaAST.js";
|
|
5
|
+
import { errorWithPath } from "../errors.js";
|
|
6
|
+
import * as InternalRecord from "../record.js";
|
|
7
|
+
import * as InternalAnnotations from "./annotations.js";
|
|
8
|
+
import { fromRepresentation, fromRepresentations } from "./fromRepresentation.js";
|
|
9
|
+
const never = {
|
|
10
|
+
_tag: "Never",
|
|
11
|
+
checks: []
|
|
12
|
+
};
|
|
13
|
+
const unknown = {
|
|
14
|
+
_tag: "Unknown",
|
|
15
|
+
checks: []
|
|
16
|
+
};
|
|
17
|
+
const string = {
|
|
18
|
+
_tag: "String",
|
|
19
|
+
checks: []
|
|
20
|
+
};
|
|
21
|
+
function makeLiteral(literal) {
|
|
22
|
+
return {
|
|
23
|
+
_tag: "Literal",
|
|
24
|
+
literal,
|
|
25
|
+
checks: []
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function annotate(representation, annotations) {
|
|
29
|
+
if (annotations === undefined) return representation;
|
|
30
|
+
if (representation._tag === "Reference") {
|
|
31
|
+
return {
|
|
32
|
+
_tag: "Suspend",
|
|
33
|
+
annotations,
|
|
34
|
+
checks: [],
|
|
35
|
+
thunk: representation
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
...representation,
|
|
40
|
+
annotations: {
|
|
41
|
+
...representation.annotations,
|
|
42
|
+
...annotations
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const jsonSchemaTypes = /*#__PURE__*/new Set(["null", "string", "number", "integer", "boolean", "object", "array"]);
|
|
47
|
+
const jsonSchemaStringKeys = ["minLength", "maxLength", "pattern", "format", "contentMediaType", "contentSchema"];
|
|
48
|
+
const jsonSchemaNumberKeys = ["minimum", "maximum", "exclusiveMinimum", "exclusiveMaximum", "multipleOf"];
|
|
49
|
+
const jsonSchemaObjectKeys = ["properties", "required", "additionalProperties", "patternProperties", "propertyNames", "minProperties", "maxProperties"];
|
|
50
|
+
const jsonSchemaArrayKeys = ["items", "prefixItems", "additionalItems", "minItems", "maxItems", "uniqueItems"];
|
|
51
|
+
function isImportedJsonSchemaType(input) {
|
|
52
|
+
return typeof input === "string" && jsonSchemaTypes.has(input);
|
|
53
|
+
}
|
|
54
|
+
function inferJsonSchemaType(schema) {
|
|
55
|
+
if (jsonSchemaStringKeys.some(key => schema[key] !== undefined)) return "string";
|
|
56
|
+
if (jsonSchemaNumberKeys.some(key => schema[key] !== undefined)) return "number";
|
|
57
|
+
if (jsonSchemaObjectKeys.some(key => schema[key] !== undefined)) return "object";
|
|
58
|
+
if (jsonSchemaArrayKeys.some(key => schema[key] !== undefined)) return "array";
|
|
59
|
+
}
|
|
60
|
+
function jsonSchemaReferenceKey($ref) {
|
|
61
|
+
const token = $ref.slice($ref.lastIndexOf("/") + 1);
|
|
62
|
+
return token.length === 0 ? undefined : unescapeToken(token);
|
|
63
|
+
}
|
|
64
|
+
function jsonSchemaFilter(id, payload, schemas) {
|
|
65
|
+
return {
|
|
66
|
+
_tag: "Filter",
|
|
67
|
+
aborted: false,
|
|
68
|
+
representation: {
|
|
69
|
+
id,
|
|
70
|
+
payload,
|
|
71
|
+
...(schemas === undefined ? undefined : {
|
|
72
|
+
schemas
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function addNumberCheck(checks, value, id, key) {
|
|
78
|
+
if (typeof value === "number") {
|
|
79
|
+
checks.push(jsonSchemaFilter(id, {
|
|
80
|
+
[key]: value
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function jsonSchemaAnnotations(schema) {
|
|
85
|
+
const annotations = {};
|
|
86
|
+
if (typeof schema.title === "string") annotations.title = schema.title;
|
|
87
|
+
if (typeof schema.description === "string") annotations.description = schema.description;
|
|
88
|
+
if (Object.hasOwn(schema, "default")) annotations.default = schema.default;
|
|
89
|
+
if (Array.isArray(schema.examples)) annotations.examples = schema.examples;
|
|
90
|
+
if (typeof schema.readOnly === "boolean") annotations.readOnly = schema.readOnly;
|
|
91
|
+
if (typeof schema.writeOnly === "boolean") annotations.writeOnly = schema.writeOnly;
|
|
92
|
+
if (typeof schema.format === "string") annotations.format = schema.format;
|
|
93
|
+
if (typeof schema.contentEncoding === "string") annotations.contentEncoding = schema.contentEncoding;
|
|
94
|
+
if (typeof schema.contentMediaType === "string") annotations.contentMediaType = schema.contentMediaType;
|
|
95
|
+
if (SchemaAST.isJson(schema.contentSchema)) annotations.contentSchema = schema.contentSchema;
|
|
96
|
+
return Object.keys(annotations).length === 0 ? undefined : annotations;
|
|
97
|
+
}
|
|
98
|
+
function jsonDeclaration(annotations) {
|
|
99
|
+
return {
|
|
100
|
+
_tag: "Declaration",
|
|
101
|
+
representation: {
|
|
102
|
+
id: "effect/schema/Json",
|
|
103
|
+
payload: null
|
|
104
|
+
},
|
|
105
|
+
annotations: {
|
|
106
|
+
...annotations,
|
|
107
|
+
expected: "JSON value"
|
|
108
|
+
},
|
|
109
|
+
checks: [],
|
|
110
|
+
typeParameters: []
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function unknownJsonSchemas(representation) {
|
|
114
|
+
switch (representation._tag) {
|
|
115
|
+
case "Unknown":
|
|
116
|
+
return jsonDeclaration(representation.annotations);
|
|
117
|
+
case "Suspend":
|
|
118
|
+
return {
|
|
119
|
+
...representation,
|
|
120
|
+
thunk: unknownJsonSchemas(representation.thunk)
|
|
121
|
+
};
|
|
122
|
+
case "Arrays":
|
|
123
|
+
return {
|
|
124
|
+
...representation,
|
|
125
|
+
elements: representation.elements.map(element => ({
|
|
126
|
+
...element,
|
|
127
|
+
type: unknownJsonSchemas(element.type)
|
|
128
|
+
})),
|
|
129
|
+
rest: representation.rest.map(unknownJsonSchemas)
|
|
130
|
+
};
|
|
131
|
+
case "Objects":
|
|
132
|
+
return {
|
|
133
|
+
...representation,
|
|
134
|
+
propertySignatures: representation.propertySignatures.map(property => ({
|
|
135
|
+
...property,
|
|
136
|
+
type: unknownJsonSchemas(property.type)
|
|
137
|
+
})),
|
|
138
|
+
indexSignatures: representation.indexSignatures.map(indexSignature => ({
|
|
139
|
+
parameter: unknownJsonSchemas(indexSignature.parameter),
|
|
140
|
+
type: unknownJsonSchemas(indexSignature.type)
|
|
141
|
+
})),
|
|
142
|
+
checks: representation.checks.map(unknownJsonSchemaCheck)
|
|
143
|
+
};
|
|
144
|
+
case "Union":
|
|
145
|
+
return {
|
|
146
|
+
...representation,
|
|
147
|
+
types: representation.types.map(unknownJsonSchemas)
|
|
148
|
+
};
|
|
149
|
+
default:
|
|
150
|
+
return representation;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function unknownJsonSchemaCheck(check) {
|
|
154
|
+
const representation = check.representation;
|
|
155
|
+
const schemas = representation?.schemas;
|
|
156
|
+
if (representation === undefined || schemas === undefined) {
|
|
157
|
+
return check;
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
...check,
|
|
161
|
+
representation: {
|
|
162
|
+
...representation,
|
|
163
|
+
schemas: schemas.map(unknownJsonSchemas)
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function translateJsonSchemaMultiDocument(document, options, singleRoot = false) {
|
|
168
|
+
const definitionCache = new Map();
|
|
169
|
+
const definitionsInProgress = new Set();
|
|
170
|
+
const annotatedReferences = [];
|
|
171
|
+
function translateDefinition(key, path, recursiveReferenceError) {
|
|
172
|
+
const cached = definitionCache.get(key);
|
|
173
|
+
if (cached !== undefined) return cached;
|
|
174
|
+
if (!Object.hasOwn(document.definitions, key)) {
|
|
175
|
+
throw errorWithPath(`Invalid reference ${key}`, [...path, "$ref"]);
|
|
176
|
+
}
|
|
177
|
+
if (definitionsInProgress.has(key)) {
|
|
178
|
+
throw errorWithPath(recursiveReferenceError ?? `Invalid reference ${key}`, [...path, "$ref"]);
|
|
179
|
+
}
|
|
180
|
+
definitionsInProgress.add(key);
|
|
181
|
+
const representation = recur(document.definitions[key], ["definitions", key]);
|
|
182
|
+
definitionsInProgress.delete(key);
|
|
183
|
+
definitionCache.set(key, representation);
|
|
184
|
+
return representation;
|
|
185
|
+
}
|
|
186
|
+
function resolveReference(reference, path, options, seen = new Set()) {
|
|
187
|
+
if (seen.has(reference.$ref)) {
|
|
188
|
+
throw errorWithPath(`Invalid reference ${reference.$ref}`, [...path, "$ref"]);
|
|
189
|
+
}
|
|
190
|
+
const nextSeen = new Set(seen).add(reference.$ref);
|
|
191
|
+
const representation = translateDefinition(reference.$ref, path, options?.recursiveReferenceError);
|
|
192
|
+
if (representation._tag === "Reference") {
|
|
193
|
+
return resolveReference(representation, path, options, nextSeen);
|
|
194
|
+
}
|
|
195
|
+
if (representation._tag === "Suspend" && representation.thunk._tag === "Reference") {
|
|
196
|
+
return annotate(resolveReference(representation.thunk, path, options, nextSeen), representation.annotations);
|
|
197
|
+
}
|
|
198
|
+
return representation;
|
|
199
|
+
}
|
|
200
|
+
function annotationsOf(representation) {
|
|
201
|
+
return representation._tag === "Reference" ? undefined : representation.annotations;
|
|
202
|
+
}
|
|
203
|
+
function mergeAnnotations(left, right) {
|
|
204
|
+
if (left === undefined) return right;
|
|
205
|
+
if (right === undefined) return left;
|
|
206
|
+
return {
|
|
207
|
+
...left,
|
|
208
|
+
...right
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
function combinedAnnotations(representation, left, right) {
|
|
212
|
+
return annotate(representation, mergeAnnotations(annotationsOf(left), annotationsOf(right)));
|
|
213
|
+
}
|
|
214
|
+
function asChecks(checks, annotations) {
|
|
215
|
+
if (checks.length === 0) return undefined;
|
|
216
|
+
if (annotations === undefined) return checks;
|
|
217
|
+
if (checks.length === 1 && checks[0].annotations === undefined) {
|
|
218
|
+
return [{
|
|
219
|
+
...checks[0],
|
|
220
|
+
annotations
|
|
221
|
+
}];
|
|
222
|
+
}
|
|
223
|
+
return [{
|
|
224
|
+
_tag: "FilterGroup",
|
|
225
|
+
checks: checks,
|
|
226
|
+
annotations
|
|
227
|
+
}];
|
|
228
|
+
}
|
|
229
|
+
function combineChecks(left, right, annotations, deduplicate = []) {
|
|
230
|
+
for (const id of deduplicate) {
|
|
231
|
+
if (left.some(check => checkId(check) === id)) {
|
|
232
|
+
right = right.filter(check => checkId(check) !== id);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
const checks = asChecks(right, annotations);
|
|
236
|
+
return checks === undefined ? undefined : [...left, ...checks];
|
|
237
|
+
}
|
|
238
|
+
function checkId(check) {
|
|
239
|
+
return check._tag === "Filter" ? check.representation?.id : undefined;
|
|
240
|
+
}
|
|
241
|
+
function satisfiesPrimitiveCheck(check, value) {
|
|
242
|
+
if (check._tag === "FilterGroup") {
|
|
243
|
+
return check.checks.every(check => satisfiesPrimitiveCheck(check, value));
|
|
244
|
+
}
|
|
245
|
+
const representation = check.representation;
|
|
246
|
+
const payload = representation.payload;
|
|
247
|
+
switch (representation.id) {
|
|
248
|
+
case "effect/schema/isMinLength":
|
|
249
|
+
return value.length >= payload.minLength;
|
|
250
|
+
case "effect/schema/isMaxLength":
|
|
251
|
+
return value.length <= payload.maxLength;
|
|
252
|
+
case "effect/schema/isPattern":
|
|
253
|
+
return new RegExp(payload.source, payload.flags).test(value);
|
|
254
|
+
case "effect/schema/isFinite":
|
|
255
|
+
return globalThis.Number.isFinite(value);
|
|
256
|
+
case "effect/schema/isInt":
|
|
257
|
+
return globalThis.Number.isSafeInteger(value);
|
|
258
|
+
case "effect/schema/isMultipleOf":
|
|
259
|
+
return remainder(value, payload.divisor) === 0;
|
|
260
|
+
case "effect/schema/isGreaterThan":
|
|
261
|
+
return value > payload.exclusiveMinimum;
|
|
262
|
+
case "effect/schema/isGreaterThanOrEqualTo":
|
|
263
|
+
return value >= payload.minimum;
|
|
264
|
+
case "effect/schema/isLessThan":
|
|
265
|
+
return value < payload.exclusiveMaximum;
|
|
266
|
+
case "effect/schema/isLessThanOrEqualTo":
|
|
267
|
+
return value <= payload.maximum;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
function satisfiesLiteral(representation, literal) {
|
|
271
|
+
const value = literal.literal;
|
|
272
|
+
if (representation._tag === "String" ? typeof value !== "string" : typeof value !== "number") {
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
return representation.checks.every(check => satisfiesPrimitiveCheck(check, value));
|
|
276
|
+
}
|
|
277
|
+
function combinePrimitiveWithLiteral(primitive, literal) {
|
|
278
|
+
const satisfies = primitive._tag === "Boolean" ? typeof literal.literal === "boolean" : satisfiesLiteral(primitive, literal);
|
|
279
|
+
return satisfies ? combinedAnnotations(literal, primitive, literal) : never;
|
|
280
|
+
}
|
|
281
|
+
function combineArrays(left, right, path) {
|
|
282
|
+
const elements = [];
|
|
283
|
+
const length = Math.max(left.elements.length, right.elements.length);
|
|
284
|
+
for (let index = 0; index < length; index++) {
|
|
285
|
+
const leftElement = left.elements[index];
|
|
286
|
+
const rightElement = right.elements[index];
|
|
287
|
+
const isOptional = leftElement?.isOptional !== false && rightElement?.isOptional !== false;
|
|
288
|
+
const leftType = leftElement?.type ?? left.rest[0];
|
|
289
|
+
const rightType = rightElement?.type ?? right.rest[0];
|
|
290
|
+
if (leftType === undefined || rightType === undefined) {
|
|
291
|
+
return isOptional ? {
|
|
292
|
+
elements,
|
|
293
|
+
rest: []
|
|
294
|
+
} : undefined;
|
|
295
|
+
}
|
|
296
|
+
const type = combine(leftType, rightType, [...path, "elements", index, "type"]);
|
|
297
|
+
if (type._tag === "Never") {
|
|
298
|
+
return isOptional ? {
|
|
299
|
+
elements,
|
|
300
|
+
rest: []
|
|
301
|
+
} : undefined;
|
|
302
|
+
}
|
|
303
|
+
elements.push({
|
|
304
|
+
isOptional,
|
|
305
|
+
type
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
const leftRest = left.rest[0];
|
|
309
|
+
const rightRest = right.rest[0];
|
|
310
|
+
if (leftRest === undefined || rightRest === undefined) {
|
|
311
|
+
return {
|
|
312
|
+
elements,
|
|
313
|
+
rest: []
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
const rest = combine(leftRest, rightRest, [...path, "rest", 0]);
|
|
317
|
+
return {
|
|
318
|
+
elements,
|
|
319
|
+
rest: rest._tag === "Never" ? [] : [rest]
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
function combineProperties(left, right, path) {
|
|
323
|
+
const rightByName = new Map(right.map(property => [property.name, property]));
|
|
324
|
+
const names = new Set();
|
|
325
|
+
const properties = left.map(property => {
|
|
326
|
+
const name = property.name;
|
|
327
|
+
names.add(name);
|
|
328
|
+
const other = rightByName.get(name);
|
|
329
|
+
if (other === undefined) return property;
|
|
330
|
+
return {
|
|
331
|
+
name: property.name,
|
|
332
|
+
type: combine(property.type, other.type, [...path, "properties", globalThis.String(name)]),
|
|
333
|
+
isOptional: property.isOptional && other.isOptional,
|
|
334
|
+
isMutable: false
|
|
335
|
+
};
|
|
336
|
+
});
|
|
337
|
+
for (const property of right) {
|
|
338
|
+
if (!names.has(property.name)) properties.push(property);
|
|
339
|
+
}
|
|
340
|
+
return properties;
|
|
341
|
+
}
|
|
342
|
+
function isUnconstrainedString(representation) {
|
|
343
|
+
return representation._tag === "String" && representation.checks.length === 0 && representation.annotations === undefined;
|
|
344
|
+
}
|
|
345
|
+
function combineIndexSignatures(left, right, path) {
|
|
346
|
+
if (left.length === 0 || right.length === 0) return [];
|
|
347
|
+
const signatures = [...left];
|
|
348
|
+
for (const signature of right) {
|
|
349
|
+
if (isUnconstrainedString(signature.parameter)) {
|
|
350
|
+
const index = signatures.findIndex(candidate => isUnconstrainedString(candidate.parameter));
|
|
351
|
+
if (index !== -1) {
|
|
352
|
+
signatures[index] = {
|
|
353
|
+
parameter: signatures[index].parameter,
|
|
354
|
+
type: combine(signatures[index].type, signature.type, [...path, "indexSignatures", index, "type"])
|
|
355
|
+
};
|
|
356
|
+
} else {
|
|
357
|
+
signatures.push(signature);
|
|
358
|
+
}
|
|
359
|
+
} else {
|
|
360
|
+
signatures.push(signature);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
return signatures;
|
|
364
|
+
}
|
|
365
|
+
function combine(left, right, path) {
|
|
366
|
+
if (left._tag === "Never") return left;
|
|
367
|
+
if (right._tag === "Never") return right;
|
|
368
|
+
if (left._tag === "Unknown") return combinedAnnotations(right, left, right);
|
|
369
|
+
if (right._tag === "Unknown") return combinedAnnotations(left, left, right);
|
|
370
|
+
if (left._tag === "Reference") return combine(resolveReference(left, path), right, path);
|
|
371
|
+
if (right._tag === "Reference") return combine(left, resolveReference(right, path), path);
|
|
372
|
+
if (left._tag === "Suspend") {
|
|
373
|
+
return annotate(combine(left.thunk, right, path), left.annotations);
|
|
374
|
+
}
|
|
375
|
+
if (right._tag === "Suspend") {
|
|
376
|
+
return annotate(combine(left, right.thunk, path), right.annotations);
|
|
377
|
+
}
|
|
378
|
+
if (left._tag === "Union") {
|
|
379
|
+
const types = left.types.map((type, index) => combine(type, right, [...path, "types", index])).filter(type => type._tag !== "Never");
|
|
380
|
+
if (types.length === 0) return never;
|
|
381
|
+
return annotate({
|
|
382
|
+
_tag: "Union",
|
|
383
|
+
types,
|
|
384
|
+
mode: left.mode,
|
|
385
|
+
checks: left.checks
|
|
386
|
+
}, left.annotations);
|
|
387
|
+
}
|
|
388
|
+
if (right._tag === "Union") return combine(right, left, path);
|
|
389
|
+
switch (left._tag) {
|
|
390
|
+
case "Null":
|
|
391
|
+
return right._tag === "Null" ? combinedAnnotations({
|
|
392
|
+
_tag: "Null",
|
|
393
|
+
checks: [...left.checks, ...right.checks]
|
|
394
|
+
}, left, right) : never;
|
|
395
|
+
case "String":
|
|
396
|
+
if (right._tag === "Literal") {
|
|
397
|
+
return combinePrimitiveWithLiteral(left, right);
|
|
398
|
+
}
|
|
399
|
+
if (right._tag !== "String") return never;
|
|
400
|
+
const stringChecks = combineChecks(left.checks, right.checks, right.annotations);
|
|
401
|
+
return annotate({
|
|
402
|
+
_tag: "String",
|
|
403
|
+
checks: stringChecks ?? left.checks
|
|
404
|
+
}, mergeAnnotations(left.annotations, stringChecks === undefined ? right.annotations : undefined));
|
|
405
|
+
case "Number":
|
|
406
|
+
if (right._tag === "Literal") {
|
|
407
|
+
return combinePrimitiveWithLiteral(left, right);
|
|
408
|
+
}
|
|
409
|
+
if (right._tag !== "Number") return never;
|
|
410
|
+
const numberChecks = combineChecks(left.checks, right.checks, right.annotations, ["effect/schema/isFinite", "effect/schema/isInt"]);
|
|
411
|
+
return annotate({
|
|
412
|
+
_tag: "Number",
|
|
413
|
+
checks: numberChecks ?? left.checks
|
|
414
|
+
}, mergeAnnotations(left.annotations, numberChecks === undefined ? right.annotations : undefined));
|
|
415
|
+
case "Boolean":
|
|
416
|
+
if (right._tag === "Literal") {
|
|
417
|
+
return combinePrimitiveWithLiteral(left, right);
|
|
418
|
+
}
|
|
419
|
+
return right._tag === "Boolean" ? combinedAnnotations({
|
|
420
|
+
_tag: "Boolean",
|
|
421
|
+
checks: [...left.checks, ...right.checks]
|
|
422
|
+
}, left, right) : never;
|
|
423
|
+
case "Literal":
|
|
424
|
+
if (right._tag === "Literal") {
|
|
425
|
+
return left.literal === right.literal ? combinedAnnotations({
|
|
426
|
+
...left,
|
|
427
|
+
checks: [...left.checks, ...right.checks]
|
|
428
|
+
}, left, right) : never;
|
|
429
|
+
}
|
|
430
|
+
if ((right._tag === "String" || right._tag === "Number") && satisfiesLiteral(right, left) || right._tag === "Boolean" && typeof left.literal === "boolean") {
|
|
431
|
+
return combinedAnnotations(left, left, right);
|
|
432
|
+
}
|
|
433
|
+
return never;
|
|
434
|
+
case "Arrays":
|
|
435
|
+
{
|
|
436
|
+
if (right._tag !== "Arrays") return never;
|
|
437
|
+
const arrays = combineArrays(left, right, path);
|
|
438
|
+
if (arrays === undefined) return never;
|
|
439
|
+
const arrayChecks = combineChecks(left.checks, right.checks, right.annotations, ["effect/schema/isUnique"]);
|
|
440
|
+
return annotate({
|
|
441
|
+
_tag: "Arrays",
|
|
442
|
+
elements: arrays.elements,
|
|
443
|
+
rest: arrays.rest,
|
|
444
|
+
checks: arrayChecks ?? left.checks
|
|
445
|
+
}, mergeAnnotations(left.annotations, arrayChecks === undefined ? right.annotations : undefined));
|
|
446
|
+
}
|
|
447
|
+
case "Objects":
|
|
448
|
+
{
|
|
449
|
+
if (right._tag !== "Objects") return never;
|
|
450
|
+
const objectChecks = combineChecks(left.checks, right.checks, right.annotations);
|
|
451
|
+
return annotate({
|
|
452
|
+
_tag: "Objects",
|
|
453
|
+
propertySignatures: combineProperties(left.propertySignatures, right.propertySignatures, path),
|
|
454
|
+
indexSignatures: combineIndexSignatures(left.indexSignatures, right.indexSignatures, path),
|
|
455
|
+
checks: objectChecks ?? left.checks
|
|
456
|
+
}, mergeAnnotations(left.annotations, objectChecks === undefined ? right.annotations : undefined));
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
function enter(input) {
|
|
461
|
+
if (typeof input !== "object" || input === null || Array.isArray(input)) {
|
|
462
|
+
return undefined;
|
|
463
|
+
}
|
|
464
|
+
const schema = input;
|
|
465
|
+
return options?.onEnter === undefined ? schema : options.onEnter(schema);
|
|
466
|
+
}
|
|
467
|
+
function recur(input, path) {
|
|
468
|
+
if (input === false) {
|
|
469
|
+
return never;
|
|
470
|
+
}
|
|
471
|
+
const schema = enter(input);
|
|
472
|
+
if (schema === undefined) {
|
|
473
|
+
return unknown;
|
|
474
|
+
}
|
|
475
|
+
let representation = on(schema, path);
|
|
476
|
+
if (representation._tag === "Reference") {
|
|
477
|
+
const siblingSchema = {
|
|
478
|
+
...schema,
|
|
479
|
+
$ref: undefined
|
|
480
|
+
};
|
|
481
|
+
for (const key of InternalAnnotations.jsonSchemaAnnotationKeys) {
|
|
482
|
+
delete siblingSchema[key];
|
|
483
|
+
}
|
|
484
|
+
const sibling = on(siblingSchema, path);
|
|
485
|
+
if (sibling._tag !== "Unknown") {
|
|
486
|
+
const reference = representation;
|
|
487
|
+
representation = combine(resolveReference(reference, path, {
|
|
488
|
+
recursiveReferenceError: `Unsupported assertion siblings on recursive reference ${reference.$ref}`
|
|
489
|
+
}), sibling, path);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
const annotations = jsonSchemaAnnotations(schema);
|
|
493
|
+
if (annotations !== undefined && representation._tag === "Reference") {
|
|
494
|
+
annotatedReferences.push({
|
|
495
|
+
reference: representation,
|
|
496
|
+
path
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
representation = annotate(representation, annotations);
|
|
500
|
+
if (Array.isArray(schema.allOf)) {
|
|
501
|
+
for (let index = 0; index < schema.allOf.length; index++) {
|
|
502
|
+
representation = combine(representation, recur(schema.allOf[index], [...path, "allOf", index]), [...path, "allOf", index]);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
for (const mode of ["anyOf", "oneOf"]) {
|
|
506
|
+
const members = schema[mode];
|
|
507
|
+
if (Array.isArray(members)) {
|
|
508
|
+
const union = {
|
|
509
|
+
_tag: "Union",
|
|
510
|
+
types: members.map((member, index) => recur(member, [...path, mode, index])),
|
|
511
|
+
mode,
|
|
512
|
+
checks: []
|
|
513
|
+
};
|
|
514
|
+
representation = combine(union, representation, [...path, mode]);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
return representation;
|
|
518
|
+
}
|
|
519
|
+
function on(schema, path) {
|
|
520
|
+
if (typeof schema.$ref === "string") {
|
|
521
|
+
const $ref = jsonSchemaReferenceKey(schema.$ref);
|
|
522
|
+
if ($ref !== undefined) {
|
|
523
|
+
return {
|
|
524
|
+
_tag: "Reference",
|
|
525
|
+
$ref
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
if (Object.hasOwn(schema, "const")) {
|
|
530
|
+
if (schema.const === null) {
|
|
531
|
+
return {
|
|
532
|
+
_tag: "Null",
|
|
533
|
+
checks: []
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
if (typeof schema.const === "string" || typeof schema.const === "number" || typeof schema.const === "boolean") {
|
|
537
|
+
return makeLiteral(schema.const);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
if (Array.isArray(schema.enum)) {
|
|
541
|
+
const types = [];
|
|
542
|
+
for (let index = 0; index < schema.enum.length; index++) {
|
|
543
|
+
const value = schema.enum[index];
|
|
544
|
+
if (value === null) {
|
|
545
|
+
types.push({
|
|
546
|
+
_tag: "Null",
|
|
547
|
+
checks: []
|
|
548
|
+
});
|
|
549
|
+
} else if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
550
|
+
types.push(makeLiteral(value));
|
|
551
|
+
} else {
|
|
552
|
+
types.push(recur(value, [...path, "enum", index]));
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
if (types.length === 1) {
|
|
556
|
+
return types[0];
|
|
557
|
+
}
|
|
558
|
+
return {
|
|
559
|
+
_tag: "Union",
|
|
560
|
+
types,
|
|
561
|
+
mode: "anyOf",
|
|
562
|
+
checks: []
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
if (Array.isArray(schema.type) && schema.type.every(isImportedJsonSchemaType)) {
|
|
566
|
+
return {
|
|
567
|
+
_tag: "Union",
|
|
568
|
+
types: schema.type.map(type => on({
|
|
569
|
+
...schema,
|
|
570
|
+
type
|
|
571
|
+
}, path)),
|
|
572
|
+
mode: "anyOf",
|
|
573
|
+
checks: []
|
|
574
|
+
};
|
|
575
|
+
}
|
|
576
|
+
const type = isImportedJsonSchemaType(schema.type) ? schema.type : inferJsonSchemaType(schema);
|
|
577
|
+
switch (type) {
|
|
578
|
+
case "null":
|
|
579
|
+
return {
|
|
580
|
+
_tag: "Null",
|
|
581
|
+
checks: []
|
|
582
|
+
};
|
|
583
|
+
case "string":
|
|
584
|
+
return {
|
|
585
|
+
_tag: "String",
|
|
586
|
+
checks: collectStringChecks(schema)
|
|
587
|
+
};
|
|
588
|
+
case "number":
|
|
589
|
+
case "integer":
|
|
590
|
+
return {
|
|
591
|
+
_tag: "Number",
|
|
592
|
+
checks: [jsonSchemaFilter(type === "number" ? "effect/schema/isFinite" : "effect/schema/isInt", null), ...collectNumberChecks(schema)]
|
|
593
|
+
};
|
|
594
|
+
case "boolean":
|
|
595
|
+
return {
|
|
596
|
+
_tag: "Boolean",
|
|
597
|
+
checks: []
|
|
598
|
+
};
|
|
599
|
+
case "array":
|
|
600
|
+
{
|
|
601
|
+
const minItems = typeof schema.minItems === "number" ? schema.minItems : 0;
|
|
602
|
+
const elements = Array.isArray(schema.prefixItems) ? schema.prefixItems.map((element, index) => ({
|
|
603
|
+
isOptional: index + 1 > minItems,
|
|
604
|
+
type: recur(element, [...path, "prefixItems", index])
|
|
605
|
+
})) : [];
|
|
606
|
+
const rest = schema.items !== undefined ? [recur(schema.items, [...path, "items"])] : schema.prefixItems !== undefined && typeof schema.maxItems === "number" ? [] : [unknown];
|
|
607
|
+
return {
|
|
608
|
+
_tag: "Arrays",
|
|
609
|
+
elements,
|
|
610
|
+
rest,
|
|
611
|
+
checks: collectArrayChecks(schema)
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
case "object":
|
|
615
|
+
return {
|
|
616
|
+
_tag: "Objects",
|
|
617
|
+
propertySignatures: collectProperties(schema, path),
|
|
618
|
+
indexSignatures: collectIndexSignatures(schema, path),
|
|
619
|
+
checks: collectObjectChecks(schema, path)
|
|
620
|
+
};
|
|
621
|
+
default:
|
|
622
|
+
return unknown;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
function collectStringChecks(schema) {
|
|
626
|
+
const checks = [];
|
|
627
|
+
addNumberCheck(checks, schema.minLength, "effect/schema/isMinLength", "minLength");
|
|
628
|
+
addNumberCheck(checks, schema.maxLength, "effect/schema/isMaxLength", "maxLength");
|
|
629
|
+
if (typeof schema.pattern === "string") {
|
|
630
|
+
checks.push(jsonSchemaFilter("effect/schema/isPattern", {
|
|
631
|
+
source: schema.pattern,
|
|
632
|
+
flags: ""
|
|
633
|
+
}));
|
|
634
|
+
}
|
|
635
|
+
return checks;
|
|
636
|
+
}
|
|
637
|
+
function collectNumberChecks(schema) {
|
|
638
|
+
const checks = [];
|
|
639
|
+
addNumberCheck(checks, schema.minimum, "effect/schema/isGreaterThanOrEqualTo", "minimum");
|
|
640
|
+
addNumberCheck(checks, schema.maximum, "effect/schema/isLessThanOrEqualTo", "maximum");
|
|
641
|
+
addNumberCheck(checks, schema.exclusiveMinimum, "effect/schema/isGreaterThan", "exclusiveMinimum");
|
|
642
|
+
addNumberCheck(checks, schema.exclusiveMaximum, "effect/schema/isLessThan", "exclusiveMaximum");
|
|
643
|
+
addNumberCheck(checks, schema.multipleOf, "effect/schema/isMultipleOf", "divisor");
|
|
644
|
+
return checks;
|
|
645
|
+
}
|
|
646
|
+
function collectArrayChecks(schema) {
|
|
647
|
+
const checks = [];
|
|
648
|
+
if (schema.prefixItems === undefined) {
|
|
649
|
+
addNumberCheck(checks, schema.minItems, "effect/schema/isMinLength", "minLength");
|
|
650
|
+
addNumberCheck(checks, schema.maxItems, "effect/schema/isMaxLength", "maxLength");
|
|
651
|
+
}
|
|
652
|
+
if (typeof schema.uniqueItems === "boolean") {
|
|
653
|
+
checks.push(jsonSchemaFilter("effect/schema/isUnique", null));
|
|
654
|
+
}
|
|
655
|
+
return checks;
|
|
656
|
+
}
|
|
657
|
+
function collectProperties(schema, path) {
|
|
658
|
+
const properties = typeof schema.properties === "object" && schema.properties !== null && !Array.isArray(schema.properties) ? schema.properties : {};
|
|
659
|
+
const required = Array.isArray(schema.required) ? schema.required.filter(key => typeof key === "string") : [];
|
|
660
|
+
const keys = new Set([...Object.keys(properties), ...required]);
|
|
661
|
+
return Array.from(keys, name => ({
|
|
662
|
+
name,
|
|
663
|
+
type: recur(properties[name], [...path, "properties", name]),
|
|
664
|
+
isOptional: !required.includes(name),
|
|
665
|
+
isMutable: false
|
|
666
|
+
}));
|
|
667
|
+
}
|
|
668
|
+
function collectIndexSignatures(schema, path) {
|
|
669
|
+
const signatures = [];
|
|
670
|
+
if (typeof schema.patternProperties === "object" && schema.patternProperties !== null && !Array.isArray(schema.patternProperties)) {
|
|
671
|
+
for (const [pattern, value] of Object.entries(schema.patternProperties)) {
|
|
672
|
+
signatures.push({
|
|
673
|
+
parameter: {
|
|
674
|
+
_tag: "String",
|
|
675
|
+
checks: [jsonSchemaFilter("effect/schema/isPattern", {
|
|
676
|
+
source: pattern,
|
|
677
|
+
flags: ""
|
|
678
|
+
})]
|
|
679
|
+
},
|
|
680
|
+
type: recur(value, [...path, "patternProperties", pattern])
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
if (schema.additionalProperties === undefined || schema.additionalProperties === true) {
|
|
685
|
+
signatures.push({
|
|
686
|
+
parameter: string,
|
|
687
|
+
type: unknown
|
|
688
|
+
});
|
|
689
|
+
} else if (typeof schema.additionalProperties === "object" && schema.additionalProperties !== null) {
|
|
690
|
+
signatures.push({
|
|
691
|
+
parameter: string,
|
|
692
|
+
type: recur(schema.additionalProperties, [...path, "additionalProperties"])
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
return signatures;
|
|
696
|
+
}
|
|
697
|
+
function collectObjectChecks(schema, path) {
|
|
698
|
+
const checks = [];
|
|
699
|
+
addNumberCheck(checks, schema.minProperties, "effect/schema/isMinProperties", "minProperties");
|
|
700
|
+
addNumberCheck(checks, schema.maxProperties, "effect/schema/isMaxProperties", "maxProperties");
|
|
701
|
+
if (schema.propertyNames !== undefined) {
|
|
702
|
+
checks.push(jsonSchemaFilter("effect/schema/isPropertyNames", null, [recur(schema.propertyNames, [...path, "propertyNames"])]));
|
|
703
|
+
}
|
|
704
|
+
return checks;
|
|
705
|
+
}
|
|
706
|
+
const references = {};
|
|
707
|
+
for (const key of Object.keys(document.definitions)) {
|
|
708
|
+
InternalRecord.assignProperty(references, key, unknownJsonSchemas(translateDefinition(key, ["definitions", key])));
|
|
709
|
+
}
|
|
710
|
+
const representations = document.schemas.map((schema, index) => unknownJsonSchemas(recur(schema, singleRoot ? ["schema"] : ["schemas", index])));
|
|
711
|
+
for (const {
|
|
712
|
+
reference,
|
|
713
|
+
path
|
|
714
|
+
} of annotatedReferences) {
|
|
715
|
+
resolveReference(reference, path);
|
|
716
|
+
}
|
|
717
|
+
return {
|
|
718
|
+
representations,
|
|
719
|
+
references
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
/** @internal */
|
|
723
|
+
function toRepresentation(document, options) {
|
|
724
|
+
const translated = translateJsonSchemaMultiDocument({
|
|
725
|
+
dialect: document.dialect,
|
|
726
|
+
schemas: [document.schema],
|
|
727
|
+
definitions: document.definitions
|
|
728
|
+
}, options, true);
|
|
729
|
+
return {
|
|
730
|
+
representation: translated.representations[0],
|
|
731
|
+
references: translated.references
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
const jsonSchemaRevivers = [Schema.JsonReviver, Schema.isPatternReviver, Schema.isFiniteReviver, Schema.isGreaterThanReviver, Schema.isGreaterThanOrEqualToReviver, Schema.isLessThanReviver, Schema.isLessThanOrEqualToReviver, Schema.isMultipleOfReviver, Schema.isIntReviver, Schema.isMinLengthReviver, Schema.isMaxLengthReviver, Schema.isMinPropertiesReviver, Schema.isMaxPropertiesReviver, Schema.isPropertyNamesReviver, Schema.isUniqueReviver];
|
|
735
|
+
/** @internal */
|
|
736
|
+
export function fromJsonSchemaDocument(document, options) {
|
|
737
|
+
return fromRepresentation(toRepresentation(document, options), jsonSchemaRevivers);
|
|
738
|
+
}
|
|
739
|
+
/** @internal */
|
|
740
|
+
export function fromJsonSchemaMultiDocument(document, options) {
|
|
741
|
+
return fromRepresentations(translateJsonSchemaMultiDocument(document, options), jsonSchemaRevivers);
|
|
742
|
+
}
|
|
743
|
+
//# sourceMappingURL=fromJsonSchemaDocument.js.map
|